2
2
3
3
const {
4
4
ObjectSetPrototypeOf,
5
+ ReflectApply,
6
+ StringPrototypeToLowerCase,
5
7
} = primordials ;
6
8
7
9
const {
@@ -118,22 +120,22 @@ function createCipherBase(cipher, credential, options, decipher, iv) {
118
120
}
119
121
this . _decoder = null ;
120
122
121
- LazyTransform . call ( this , options ) ;
123
+ ReflectApply ( LazyTransform , this , [ options ] ) ;
122
124
}
123
125
124
126
function createCipher ( cipher , password , options , decipher ) {
125
127
validateString ( cipher , 'cipher' ) ;
126
128
password = getArrayBufferOrView ( password , 'password' ) ;
127
129
128
- createCipherBase . call ( this , cipher , password , options , decipher ) ;
130
+ ReflectApply ( createCipherBase , this , [ cipher , password , options , decipher ] ) ;
129
131
}
130
132
131
133
function createCipherWithIV ( cipher , key , options , decipher , iv ) {
132
134
validateString ( cipher , 'cipher' ) ;
133
135
const encoding = getStringOption ( options , 'encoding' ) ;
134
136
key = prepareSecretKey ( key , encoding ) ;
135
137
iv = iv === null ? null : getArrayBufferOrView ( iv , 'iv' ) ;
136
- createCipherBase . call ( this , cipher , key , options , decipher , iv ) ;
138
+ ReflectApply ( createCipherBase , this , [ cipher , key , options , decipher , iv ] ) ;
137
139
}
138
140
139
141
// The Cipher class is part of the legacy Node.js crypto API. It exposes
@@ -145,7 +147,7 @@ function Cipher(cipher, password, options) {
145
147
if ( ! ( this instanceof Cipher ) )
146
148
return new Cipher ( cipher , password , options ) ;
147
149
148
- createCipher . call ( this , cipher , password , options , true ) ;
150
+ ReflectApply ( createCipher , this , [ cipher , password , options , true ] ) ;
149
151
}
150
152
151
153
ObjectSetPrototypeOf ( Cipher . prototype , LazyTransform . prototype ) ;
@@ -241,7 +243,7 @@ function Cipheriv(cipher, key, iv, options) {
241
243
if ( ! ( this instanceof Cipheriv ) )
242
244
return new Cipheriv ( cipher , key , iv , options ) ;
243
245
244
- createCipherWithIV . call ( this , cipher , key , options , true , iv ) ;
246
+ ReflectApply ( createCipherWithIV , this , [ cipher , key , options , true , iv ] ) ;
245
247
}
246
248
247
249
function addCipherPrototypeFunctions ( constructor ) {
@@ -271,7 +273,7 @@ function Decipher(cipher, password, options) {
271
273
if ( ! ( this instanceof Decipher ) )
272
274
return new Decipher ( cipher , password , options ) ;
273
275
274
- createCipher . call ( this , cipher , password , options , false ) ;
276
+ ReflectApply ( createCipher , this , [ cipher , password , options , false ] ) ;
275
277
}
276
278
277
279
ObjectSetPrototypeOf ( Decipher . prototype , LazyTransform . prototype ) ;
@@ -287,7 +289,7 @@ function Decipheriv(cipher, key, iv, options) {
287
289
if ( ! ( this instanceof Decipheriv ) )
288
290
return new Decipheriv ( cipher , key , iv , options ) ;
289
291
290
- createCipherWithIV . call ( this , cipher , key , options , false , iv ) ;
292
+ ReflectApply ( createCipherWithIV , this , [ cipher , key , options , false , iv ] ) ;
291
293
}
292
294
293
295
ObjectSetPrototypeOf ( Decipheriv . prototype , LazyTransform . prototype ) ;
@@ -315,8 +317,8 @@ function getCipherInfo(nameOrNid, options) {
315
317
316
318
const ret = _getCipherInfo ( { } , nameOrNid , keyLength , ivLength ) ;
317
319
if ( ret !== undefined ) {
318
- if ( ret . name ) ret . name = ret . name . toLowerCase ( ) ;
319
- if ( ret . type ) ret . type = ret . type . toLowerCase ( ) ;
320
+ if ( ret . name ) ret . name = StringPrototypeToLowerCase ( ret . name ) ;
321
+ if ( ret . type ) ret . type = StringPrototypeToLowerCase ( ret . type ) ;
320
322
}
321
323
return ret ;
322
324
}
0 commit comments