@@ -7,10 +7,10 @@ const {
7
7
ERR_OUT_OF_RANGE
8
8
} = require ( 'internal/errors' ) . codes ;
9
9
const {
10
+ checkIsArrayBufferView,
10
11
getDefaultEncoding,
11
12
toBuf
12
13
} = require ( 'internal/crypto/util' ) ;
13
- const { isArrayBufferView } = require ( 'internal/util/types' ) ;
14
14
const {
15
15
PBKDF2
16
16
} = process . binding ( 'crypto' ) ;
@@ -39,19 +39,8 @@ function _pbkdf2(password, salt, iterations, keylen, digest, callback) {
39
39
if ( digest !== null && typeof digest !== 'string' )
40
40
throw new ERR_INVALID_ARG_TYPE ( 'digest' , [ 'string' , 'null' ] , digest ) ;
41
41
42
- password = toBuf ( password ) ;
43
- salt = toBuf ( salt ) ;
44
-
45
- if ( ! isArrayBufferView ( password ) ) {
46
- throw new ERR_INVALID_ARG_TYPE ( 'password' ,
47
- [ 'string' , 'Buffer' , 'TypedArray' ] ,
48
- password ) ;
49
- }
50
-
51
- if ( ! isArrayBufferView ( salt ) ) {
52
- throw new ERR_INVALID_ARG_TYPE ( 'salt' ,
53
- [ 'string' , 'Buffer' , 'TypedArray' ] , salt ) ;
54
- }
42
+ password = checkIsArrayBufferView ( 'password' , toBuf ( password ) ) ;
43
+ salt = checkIsArrayBufferView ( 'salt' , toBuf ( salt ) ) ;
55
44
56
45
if ( typeof iterations !== 'number' )
57
46
throw new ERR_INVALID_ARG_TYPE ( 'iterations' , 'number' , iterations ) ;
0 commit comments