@@ -294,6 +294,24 @@ describe('limits test', function() {
294
294
} , Error ) ;
295
295
} ) ;
296
296
297
+ it ( 'should throw with too big N' , function ( ) {
298
+ assert . throws ( function ( ) {
299
+ scrypt ( v . password , v . salt , { N : ( ( - 1 ) >>> 0 ) + 1 , r : v . r , dkLen : v . dkLen } ) ;
300
+ } , Error ) ;
301
+ } ) ;
302
+
303
+ it ( 'should throw with too small N' , function ( ) {
304
+ assert . throws ( function ( ) {
305
+ scrypt ( v . password , v . salt , { N : 1 , r : v . r , dkLen : v . dkLen } ) ;
306
+ } , Error ) ;
307
+ } ) ;
308
+
309
+ it ( 'should throw when N is not power of two' , function ( ) {
310
+ assert . throws ( function ( ) {
311
+ scrypt ( v . password , v . salt , { N : 123 , r : v . r , dkLen : v . dkLen } ) ;
312
+ } , Error ) ;
313
+ } ) ;
314
+
297
315
it ( 'should throw with too large parameters' , function ( ) {
298
316
assert . throws ( function ( ) {
299
317
scrypt ( v . password , v . salt , v . logN , 1 << 31 , v . dkLen ) ;
@@ -306,6 +324,12 @@ describe('limits test', function() {
306
324
} , Error ) ;
307
325
} ) ;
308
326
327
+ it ( 'should throw when p = 0' , function ( ) {
328
+ assert . throws ( function ( ) {
329
+ scrypt ( v . password , v . salt , { logN : v . logN , r : v . r , p : 0 , dkLen : v . dkLen } ) ;
330
+ } , Error ) ;
331
+ } ) ;
332
+
309
333
} ) ;
310
334
311
335
describe ( 'argument order test' , function ( ) {
@@ -341,6 +365,25 @@ describe('argument order test', function() {
341
365
} , 'hex' ) ;
342
366
} ) ;
343
367
368
+ } ) ;
369
+
370
+ describe ( 'options test' , function ( ) {
371
+ var v = shortInput ;
372
+
373
+ it ( 'should throw when given too many arguments' , function ( ) {
374
+ assert . throws ( function ( ) {
375
+ scrypt ( v . password , v . salt , { logN : v . logN , r : 1 , dkLen : v . dkLen } , 666 , function ( ) { } ) ;
376
+ } , Error ) ;
377
+ } ) ;
378
+
379
+ it ( 'should throw when there is no N or logN' , function ( ) {
380
+ assert . throws ( function ( ) {
381
+ scrypt ( v . password , v . salt , { r : 1 , dkLen : v . dkLen } ) ;
382
+ } , Error ) ;
383
+ } ) ;
384
+
385
+
386
+
344
387
} ) ;
345
388
346
389
describe ( 'encoding test' , function ( ) {
0 commit comments