@@ -15,12 +15,9 @@ const {
1515const {
1616 validateFunction,
1717 validateInt32,
18- validateInteger,
1918 validateString,
2019} = require ( 'internal/validators' ) ;
2120
22- const { ERR_MISSING_OPTION } = require ( 'internal/errors' ) . codes ;
23-
2421const {
2522 getArrayBufferOrView,
2623 getDefaultEncoding,
@@ -101,19 +98,12 @@ function check(password, salt, iterations, keylen, digest) {
10198
10299const pbkdf2Promise = promisify ( pbkdf2 ) ;
103100async function pbkdf2DeriveBits ( algorithm , baseKey , length ) {
104- const { iterations } = algorithm ;
105- let { hash } = algorithm ;
106- const salt = getArrayBufferOrView ( algorithm . salt , 'algorithm.salt' ) ;
107- if ( hash === undefined )
108- throw new ERR_MISSING_OPTION ( 'algorithm.hash' ) ;
109- validateInteger ( iterations , 'algorithm.iterations' ) ;
101+ const { iterations, hash, salt } = algorithm ;
110102 if ( iterations === 0 )
111103 throw lazyDOMException (
112104 'iterations cannot be zero' ,
113105 'OperationError' ) ;
114106
115- hash = normalizeHashName ( hash . name ) ;
116-
117107 const raw = baseKey [ kKeyObject ] . export ( ) ;
118108
119109 if ( length === 0 )
@@ -128,7 +118,9 @@ async function pbkdf2DeriveBits(algorithm, baseKey, length) {
128118
129119 let result ;
130120 try {
131- result = await pbkdf2Promise ( raw , salt , iterations , length / 8 , hash ) ;
121+ result = await pbkdf2Promise (
122+ raw , salt , iterations , length / 8 , normalizeHashName ( hash . name ) ,
123+ ) ;
132124 } catch ( err ) {
133125 throw lazyDOMException (
134126 'The operation failed for an operation-specific reason' ,
0 commit comments