@@ -138,20 +138,12 @@ function createCipherWithIV(cipher, key, options, decipher, iv) {
138138// the Cipher class is defined using the legacy function syntax rather than
139139// ES6 classes.
140140
141- function Cipher ( cipher , password , options ) {
142- if ( ! ( this instanceof Cipher ) )
143- return new Cipher ( cipher , password , options ) ;
144- }
145-
146- ObjectSetPrototypeOf ( Cipher . prototype , LazyTransform . prototype ) ;
147- ObjectSetPrototypeOf ( Cipher , LazyTransform ) ;
148-
149- Cipher . prototype . _transform = function _transform ( chunk , encoding , callback ) {
141+ function _transform ( chunk , encoding , callback ) {
150142 this . push ( this [ kHandle ] . update ( chunk , encoding ) ) ;
151143 callback ( ) ;
152144} ;
153145
154- Cipher . prototype . _flush = function _flush ( callback ) {
146+ function _flush ( callback ) {
155147 try {
156148 this . push ( this [ kHandle ] . final ( ) ) ;
157149 } catch ( e ) {
@@ -161,7 +153,7 @@ Cipher.prototype._flush = function _flush(callback) {
161153 callback ( ) ;
162154} ;
163155
164- Cipher . prototype . update = function update ( data , inputEncoding , outputEncoding ) {
156+ function update ( data , inputEncoding , outputEncoding ) {
165157 if ( typeof data === 'string' ) {
166158 validateEncoding ( data , inputEncoding ) ;
167159 } else if ( ! isArrayBufferView ( data ) ) {
@@ -179,8 +171,7 @@ Cipher.prototype.update = function update(data, inputEncoding, outputEncoding) {
179171 return ret ;
180172} ;
181173
182-
183- Cipher . prototype . final = function final ( outputEncoding ) {
174+ function final ( outputEncoding ) {
184175 const ret = this [ kHandle ] . final ( ) ;
185176
186177 if ( outputEncoding && outputEncoding !== 'buffer' ) {
@@ -191,29 +182,27 @@ Cipher.prototype.final = function final(outputEncoding) {
191182 return ret ;
192183} ;
193184
194-
195- Cipher . prototype . setAutoPadding = function setAutoPadding ( ap ) {
185+ function setAutoPadding ( ap ) {
196186 if ( ! this [ kHandle ] . setAutoPadding ( ! ! ap ) )
197187 throw new ERR_CRYPTO_INVALID_STATE ( 'setAutoPadding' ) ;
198188 return this ;
199189} ;
200190
201- Cipher . prototype . getAuthTag = function getAuthTag ( ) {
191+ function getAuthTag ( ) {
202192 const ret = this [ kHandle ] . getAuthTag ( ) ;
203193 if ( ret === undefined )
204194 throw new ERR_CRYPTO_INVALID_STATE ( 'getAuthTag' ) ;
205195 return ret ;
206196} ;
207197
208-
209198function setAuthTag ( tagbuf , encoding ) {
210199 tagbuf = getArrayBufferOrView ( tagbuf , 'buffer' , encoding ) ;
211200 if ( ! this [ kHandle ] . setAuthTag ( tagbuf ) )
212201 throw new ERR_CRYPTO_INVALID_STATE ( 'setAuthTag' ) ;
213202 return this ;
214203}
215204
216- Cipher . prototype . setAAD = function setAAD ( aadbuf , options ) {
205+ function setAAD ( aadbuf , options ) {
217206 const encoding = getStringOption ( options , 'encoding' ) ;
218207 const plaintextLength = getUIntOption ( options , 'plaintextLength' ) ;
219208 aadbuf = getArrayBufferOrView ( aadbuf , 'aadbuf' , encoding ) ;
@@ -235,42 +224,27 @@ function Cipheriv(cipher, key, iv, options) {
235224}
236225
237226function addCipherPrototypeFunctions ( constructor ) {
238- constructor . prototype . _transform = Cipher . prototype . _transform ;
239- constructor . prototype . _flush = Cipher . prototype . _flush ;
240- constructor . prototype . update = Cipher . prototype . update ;
241- constructor . prototype . final = Cipher . prototype . final ;
242- constructor . prototype . setAutoPadding = Cipher . prototype . setAutoPadding ;
227+ constructor . prototype . _transform = _transform ;
228+ constructor . prototype . _flush = _flush ;
229+ constructor . prototype . update = update ;
230+ constructor . prototype . final = final ;
231+ constructor . prototype . setAutoPadding = setAutoPadding ;
243232 if ( constructor === Cipheriv ) {
244- constructor . prototype . getAuthTag = Cipher . prototype . getAuthTag ;
233+ constructor . prototype . getAuthTag = getAuthTag ;
245234 } else {
246235 constructor . prototype . setAuthTag = setAuthTag ;
247236 }
248- constructor . prototype . setAAD = Cipher . prototype . setAAD ;
237+ constructor . prototype . setAAD = setAAD ;
249238}
250239
251240ObjectSetPrototypeOf ( Cipheriv . prototype , LazyTransform . prototype ) ;
252241ObjectSetPrototypeOf ( Cipheriv , LazyTransform ) ;
253242addCipherPrototypeFunctions ( Cipheriv ) ;
254243
255- // The Decipher class is part of the legacy Node.js crypto API. It exposes
256- // a stream-based encryption/decryption model. For backwards compatibility
257- // the Decipher class is defined using the legacy function syntax rather than
258- // ES6 classes.
259-
260- function Decipher ( cipher , password , options ) {
261- if ( ! ( this instanceof Decipher ) )
262- return new Decipher ( cipher , password , options ) ;
263- }
264-
265- ObjectSetPrototypeOf ( Decipher . prototype , LazyTransform . prototype ) ;
266- ObjectSetPrototypeOf ( Decipher , LazyTransform ) ;
267- addCipherPrototypeFunctions ( Decipher ) ;
268-
269244// The Decipheriv class is part of the legacy Node.js crypto API. It exposes
270245// a stream-based encryption/decryption model. For backwards compatibility
271246// the Decipheriv class is defined using the legacy function syntax rather than
272247// ES6 classes.
273-
274248function Decipheriv ( cipher , key , iv , options ) {
275249 if ( ! ( this instanceof Decipheriv ) )
276250 return new Decipheriv ( cipher , key , iv , options ) ;
0 commit comments