@@ -97,50 +97,68 @@ function runTests (name, compat) {
97
97
} , / N o c a l l b a c k p r o v i d e d t o p b k d f 2 / )
98
98
} )
99
99
100
- tape ( name + ' should throw if the password is not a buffer or string or Uint8Array ' , function ( t ) {
100
+ tape ( name + ' should throw if the password is not a string or an ArrayBuffer ' , function ( t ) {
101
101
t . plan ( 2 )
102
102
103
103
t . throws ( function ( ) {
104
104
compat . pbkdf2 ( [ 'a' ] , 'salt' , 1 , 32 , 'sha1' , function ( ) { } )
105
- } , / P a s s w o r d m u s t b e a B u f f e r , U i n t 8 A r r a y o r s t r i n g / )
105
+ } , / P a s s w o r d m u s t b e a s t r i n g o r a n A r r a y B u f f e r / )
106
106
107
107
t . throws ( function ( ) {
108
108
compat . pbkdf2Sync ( [ 'a' ] , 'salt' , 1 , 32 , 'sha1' )
109
- } , / P a s s w o r d m u s t b e a B u f f e r , U i n t 8 A r r a y o r s t r i n g / )
109
+ } , / P a s s w o r d m u s t b e a s t r i n g o r a n A r r a y B u f f e r / )
110
110
} )
111
111
112
- tape ( name + ' should throw if the salt is not a buffer or string or Uint8Array ' , function ( t ) {
112
+ tape ( name + ' should throw if the salt is not a string or an ArrayBuffer ' , function ( t ) {
113
113
t . plan ( 2 )
114
114
115
115
t . throws ( function ( ) {
116
116
compat . pbkdf2 ( 'pass' , [ 'salt' ] , 1 , 32 , 'sha1' )
117
- } , / S a l t m u s t b e a B u f f e r , U i n t 8 A r r a y o r s t r i n g / )
117
+ } , / S a l t m u s t b e a s t r i n g o r a n A r r a y B u f f e r / )
118
118
119
119
t . throws ( function ( ) {
120
120
compat . pbkdf2Sync ( 'pass' , [ 'salt' ] , 1 , 32 , 'sha1' )
121
- } , / S a l t m u s t b e a B u f f e r , U i n t 8 A r r a y o r s t r i n g / )
121
+ } , / S a l t m u s t b e a s t r i n g o r a n A r r a y B u f f e r / )
122
122
} )
123
123
124
124
var algos = [ 'sha1' , 'sha224' , 'sha256' , 'sha384' , 'sha512' , 'ripemd160' ]
125
125
algos . forEach ( function ( algorithm ) {
126
126
fixtures . valid . forEach ( function ( f ) {
127
- var key , salt
127
+ var key , keyType , salt , saltType
128
128
if ( f . keyUint8Array ) {
129
129
key = new Uint8Array ( f . keyUint8Array )
130
+ keyType = 'Uint8Array'
131
+ } else if ( f . keyInt32Array ) {
132
+ key = new Int32Array ( f . keyInt32Array )
133
+ keyType = 'Int32Array'
134
+ } else if ( f . keyFloat64Array ) {
135
+ key = new Float64Array ( f . keyFloat64Array )
136
+ keyType = 'Float64Array'
130
137
} else if ( f . keyHex ) {
131
138
key = Buffer . from ( f . keyHex , 'hex' )
139
+ keyType = 'hex'
132
140
} else {
133
141
key = f . key
142
+ keyType = 'string'
134
143
}
135
144
if ( f . saltUint8Array ) {
136
145
salt = new Uint8Array ( f . saltUint8Array )
146
+ saltType = 'Uint8Array'
147
+ } else if ( f . saltInt32Array ) {
148
+ salt = new Int32Array ( f . saltInt32Array )
149
+ saltType = 'Int32Array'
150
+ } else if ( f . saltFloat64Array ) {
151
+ salt = new Float64Array ( f . saltFloat64Array )
152
+ saltType = 'Float64Array'
137
153
} else if ( f . saltHex ) {
138
154
salt = Buffer . from ( f . saltHex , 'hex' )
155
+ saltType = 'hex'
139
156
} else {
140
157
salt = f . salt
158
+ saltType = 'string'
141
159
}
142
160
var expected = f . results [ algorithm ]
143
- var description = algorithm + ' encodes ' + key + ' (' + f . salt + ') with ' + algorithm + ' to ' + expected
161
+ var description = algorithm + ' encodes " ' + key + '" (' + keyType + ') with salt "' + salt + '" (' + saltType + ') with ' + algorithm + ' to ' + expected
144
162
145
163
tape ( name + ' async w/ ' + description , function ( t ) {
146
164
t . plan ( 2 )
0 commit comments