@@ -7,10 +7,10 @@ const {
77 ERR_OUT_OF_RANGE
88} = require ( 'internal/errors' ) . codes ;
99const {
10+ checkIsArrayBufferView,
1011 getDefaultEncoding,
1112 toBuf
1213} = require ( 'internal/crypto/util' ) ;
13- const { isArrayBufferView } = require ( 'internal/util/types' ) ;
1414const {
1515 PBKDF2
1616} = process . binding ( 'crypto' ) ;
@@ -39,19 +39,8 @@ function _pbkdf2(password, salt, iterations, keylen, digest, callback) {
3939 if ( digest !== null && typeof digest !== 'string' )
4040 throw new ERR_INVALID_ARG_TYPE ( 'digest' , [ 'string' , 'null' ] , digest ) ;
4141
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 ) ) ;
5544
5645 if ( typeof iterations !== 'number' )
5746 throw new ERR_INVALID_ARG_TYPE ( 'iterations' , 'number' , iterations ) ;
0 commit comments