@@ -12,37 +12,37 @@ var crypto = require('crypto');
12
12
// Test PBKDF2 with RFC 6070 test vectors (except #4)
13
13
//
14
14
function testPBKDF2 ( password , salt , iterations , keylen , expected ) {
15
- var actual = crypto . pbkdf2Sync ( password , salt , iterations , keylen ) ;
15
+ var actual = crypto . pbkdf2Sync ( password , salt , iterations , keylen , 'sha256' ) ;
16
16
assert . equal ( actual . toString ( 'binary' ) , expected ) ;
17
17
18
- crypto . pbkdf2 ( password , salt , iterations , keylen , function ( err , actual ) {
18
+ crypto . pbkdf2 ( password , salt , iterations , keylen , 'sha256' , ( err , actual ) => {
19
19
assert . equal ( actual . toString ( 'binary' ) , expected ) ;
20
20
} ) ;
21
21
}
22
22
23
23
24
24
testPBKDF2 ( 'password' , 'salt' , 1 , 20 ,
25
- '\x0c\x60\xc8\x0f\x96\x1f\x0e\x71\xf3\xa9\xb5\x24 ' +
26
- '\xaf\x60\x12\x06\x2f\xe0\x37\xa6 ' ) ;
25
+ '\x12\x0f\xb6\xcf\xfc\xf8\xb3\x2c\x43\xe7\x22\x52 ' +
26
+ '\x56\xc4\xf8\x37\xa8\x65\x48\xc9 ' ) ;
27
27
28
28
testPBKDF2 ( 'password' , 'salt' , 2 , 20 ,
29
- '\xea\x6c\x01\x4d\xc7\x2d\x6f\x8c\xcd\x1e\xd9\x2a ' +
30
- '\xce\x1d\x41\xf0\xd8\xde\x89\x57 ' ) ;
29
+ '\xae\x4d\x0c\x95\xaf\x6b\x46\xd3\x2d\x0a\xdf\xf9 ' +
30
+ '\x28\xf0\x6d\xd0\x2a\x30\x3f\x8e ' ) ;
31
31
32
32
testPBKDF2 ( 'password' , 'salt' , 4096 , 20 ,
33
- '\x4b\x00\x79\x01\xb7\x65\x48\x9a\xbe\xad\x49\xd9\x26 ' +
34
- '\xf7\x21\xd0\x65\xa4\x29\xc1 ' ) ;
33
+ '\xc5\xe4\x78\xd5\x92\x88\xc8\x41\xaa\x53\x0d\xb6 ' +
34
+ '\x84\x5c\x4c\x8d\x96\x28\x93\xa0 ' ) ;
35
35
36
36
testPBKDF2 ( 'passwordPASSWORDpassword' ,
37
37
'saltSALTsaltSALTsaltSALTsaltSALTsalt' ,
38
38
4096 ,
39
39
25 ,
40
- '\x3d\x2e\xec\x4f\xe4\x1c\x84\x9b\x80\xc8\ xd8\x36\x62 ' +
41
- '\xc0\xe4\x4a\x8b\x29\x1a\x96\x4c\xf2\xf0\x70\x38 ' ) ;
40
+ '\x34\x8c\x89\xdb\xcb\xd3\x2b\x2f\x32\ xd8\x14\xb8\x11 ' +
41
+ '\x6e\x84\xcf\x2b\x17\x34\x7e\xbc\x18\x00\x18\x1c ' ) ;
42
42
43
43
testPBKDF2 ( 'pass\0word' , 'sa\0lt' , 4096 , 16 ,
44
- '\x56\xfa\x6a\xa7\x55\x48\x09\x9d\xcc\x37\xd7\xf0\x34 ' +
45
- '\x25\xe0\xc3 ' ) ;
44
+ '\x89\xb6\x9d\x05\x16\xf8\x29\x89\x3c\x69\x62\x26\x65 ' +
45
+ '\x0a\x86\x87 ' ) ;
46
46
47
47
var expected =
48
48
'64c486c55d30d4c5a079b8823b7d7cb37ff0556f537da8410233bcec330ed956' ;
@@ -62,28 +62,28 @@ assert.throws(function() {
62
62
63
63
// Should not work with Infinity key length
64
64
assert . throws ( function ( ) {
65
- crypto . pbkdf2 ( 'password' , 'salt' , 1 , Infinity , common . fail ) ;
65
+ crypto . pbkdf2 ( 'password' , 'salt' , 1 , Infinity , 'sha256' , common . fail ) ;
66
66
} , function ( err ) {
67
67
return err instanceof Error && err . message === 'Bad key length' ;
68
68
} ) ;
69
69
70
70
// Should not work with negative Infinity key length
71
71
assert . throws ( function ( ) {
72
- crypto . pbkdf2 ( 'password' , 'salt' , 1 , - Infinity , common . fail ) ;
72
+ crypto . pbkdf2 ( 'password' , 'salt' , 1 , - Infinity , 'sha256' , common . fail ) ;
73
73
} , function ( err ) {
74
74
return err instanceof Error && err . message === 'Bad key length' ;
75
75
} ) ;
76
76
77
77
// Should not work with NaN key length
78
78
assert . throws ( function ( ) {
79
- crypto . pbkdf2 ( 'password' , 'salt' , 1 , NaN , common . fail ) ;
79
+ crypto . pbkdf2 ( 'password' , 'salt' , 1 , NaN , 'sha256' , common . fail ) ;
80
80
} , function ( err ) {
81
81
return err instanceof Error && err . message === 'Bad key length' ;
82
82
} ) ;
83
83
84
84
// Should not work with negative key length
85
85
assert . throws ( function ( ) {
86
- crypto . pbkdf2 ( 'password' , 'salt' , 1 , - 1 , common . fail ) ;
86
+ crypto . pbkdf2 ( 'password' , 'salt' , 1 , - 1 , 'sha256' , common . fail ) ;
87
87
} , function ( err ) {
88
88
return err instanceof Error && err . message === 'Bad key length' ;
89
89
} ) ;
0 commit comments