@@ -294,6 +294,24 @@ describe('limits test', function() {
294294 } , Error ) ;
295295 } ) ;
296296
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+
297315 it ( 'should throw with too large parameters' , function ( ) {
298316 assert . throws ( function ( ) {
299317 scrypt ( v . password , v . salt , v . logN , 1 << 31 , v . dkLen ) ;
@@ -306,6 +324,12 @@ describe('limits test', function() {
306324 } , Error ) ;
307325 } ) ;
308326
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+
309333} ) ;
310334
311335describe ( 'argument order test' , function ( ) {
@@ -341,6 +365,25 @@ describe('argument order test', function() {
341365 } , 'hex' ) ;
342366 } ) ;
343367
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+
344387} ) ;
345388
346389describe ( 'encoding test' , function ( ) {
0 commit comments