@@ -15,12 +15,9 @@ const {
15
15
const {
16
16
validateFunction,
17
17
validateInt32,
18
- validateInteger,
19
18
validateString,
20
19
} = require ( 'internal/validators' ) ;
21
20
22
- const { ERR_MISSING_OPTION } = require ( 'internal/errors' ) . codes ;
23
-
24
21
const {
25
22
getArrayBufferOrView,
26
23
getDefaultEncoding,
@@ -101,19 +98,12 @@ function check(password, salt, iterations, keylen, digest) {
101
98
102
99
const pbkdf2Promise = promisify ( pbkdf2 ) ;
103
100
async 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 ;
110
102
if ( iterations === 0 )
111
103
throw lazyDOMException (
112
104
'iterations cannot be zero' ,
113
105
'OperationError' ) ;
114
106
115
- hash = normalizeHashName ( hash . name ) ;
116
-
117
107
const raw = baseKey [ kKeyObject ] . export ( ) ;
118
108
119
109
if ( length === 0 )
@@ -128,7 +118,9 @@ async function pbkdf2DeriveBits(algorithm, baseKey, length) {
128
118
129
119
let result ;
130
120
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
+ ) ;
132
124
} catch ( err ) {
133
125
throw lazyDOMException (
134
126
'The operation failed for an operation-specific reason' ,
0 commit comments