22
33const {
44 ObjectSetPrototypeOf,
5+ ReflectApply,
6+ StringPrototypeToLowerCase,
57} = primordials ;
68
79const {
@@ -118,22 +120,22 @@ function createCipherBase(cipher, credential, options, decipher, iv) {
118120 }
119121 this . _decoder = null ;
120122
121- LazyTransform . call ( this , options ) ;
123+ ReflectApply ( LazyTransform , this , [ options ] ) ;
122124}
123125
124126function createCipher ( cipher , password , options , decipher ) {
125127 validateString ( cipher , 'cipher' ) ;
126128 password = getArrayBufferOrView ( password , 'password' ) ;
127129
128- createCipherBase . call ( this , cipher , password , options , decipher ) ;
130+ ReflectApply ( createCipherBase , this , [ cipher , password , options , decipher ] ) ;
129131}
130132
131133function createCipherWithIV ( cipher , key , options , decipher , iv ) {
132134 validateString ( cipher , 'cipher' ) ;
133135 const encoding = getStringOption ( options , 'encoding' ) ;
134136 key = prepareSecretKey ( key , encoding ) ;
135137 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 ] ) ;
137139}
138140
139141// The Cipher class is part of the legacy Node.js crypto API. It exposes
@@ -145,7 +147,7 @@ function Cipher(cipher, password, options) {
145147 if ( ! ( this instanceof Cipher ) )
146148 return new Cipher ( cipher , password , options ) ;
147149
148- createCipher . call ( this , cipher , password , options , true ) ;
150+ ReflectApply ( createCipher , this , [ cipher , password , options , true ] ) ;
149151}
150152
151153ObjectSetPrototypeOf ( Cipher . prototype , LazyTransform . prototype ) ;
@@ -241,7 +243,7 @@ function Cipheriv(cipher, key, iv, options) {
241243 if ( ! ( this instanceof Cipheriv ) )
242244 return new Cipheriv ( cipher , key , iv , options ) ;
243245
244- createCipherWithIV . call ( this , cipher , key , options , true , iv ) ;
246+ ReflectApply ( createCipherWithIV , this , [ cipher , key , options , true , iv ] ) ;
245247}
246248
247249function addCipherPrototypeFunctions ( constructor ) {
@@ -271,7 +273,7 @@ function Decipher(cipher, password, options) {
271273 if ( ! ( this instanceof Decipher ) )
272274 return new Decipher ( cipher , password , options ) ;
273275
274- createCipher . call ( this , cipher , password , options , false ) ;
276+ ReflectApply ( createCipher , this , [ cipher , password , options , false ] ) ;
275277}
276278
277279ObjectSetPrototypeOf ( Decipher . prototype , LazyTransform . prototype ) ;
@@ -287,7 +289,7 @@ function Decipheriv(cipher, key, iv, options) {
287289 if ( ! ( this instanceof Decipheriv ) )
288290 return new Decipheriv ( cipher , key , iv , options ) ;
289291
290- createCipherWithIV . call ( this , cipher , key , options , false , iv ) ;
292+ ReflectApply ( createCipherWithIV , this , [ cipher , key , options , false , iv ] ) ;
291293}
292294
293295ObjectSetPrototypeOf ( Decipheriv . prototype , LazyTransform . prototype ) ;
@@ -315,8 +317,8 @@ function getCipherInfo(nameOrNid, options) {
315317
316318 const ret = _getCipherInfo ( { } , nameOrNid , keyLength , ivLength ) ;
317319 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 ) ;
320322 }
321323 return ret ;
322324}
0 commit comments