@@ -236,17 +236,19 @@ function Cipheriv(cipher, key, iv, options) {
236236 createCipherWithIV . call ( this , cipher , key , options , true , iv ) ;
237237}
238238
239- inherits ( Cipheriv , LazyTransform ) ;
240-
241- Cipheriv . prototype . _transform = Cipher . prototype . _transform ;
242- Cipheriv . prototype . _flush = Cipher . prototype . _flush ;
243- Cipheriv . prototype . update = Cipher . prototype . update ;
244- Cipheriv . prototype . final = Cipher . prototype . final ;
245- Cipheriv . prototype . setAutoPadding = Cipher . prototype . setAutoPadding ;
246- Cipheriv . prototype . getAuthTag = Cipher . prototype . getAuthTag ;
247- Cipheriv . prototype . setAuthTag = Cipher . prototype . setAuthTag ;
248- Cipheriv . prototype . setAAD = Cipher . prototype . setAAD ;
239+ function addCipherPrototypeFunctions ( constructor ) {
240+ constructor . prototype . _transform = Cipher . prototype . _transform ;
241+ constructor . prototype . _flush = Cipher . prototype . _flush ;
242+ constructor . prototype . update = Cipher . prototype . update ;
243+ constructor . prototype . final = Cipher . prototype . final ;
244+ constructor . prototype . setAutoPadding = Cipher . prototype . setAutoPadding ;
245+ constructor . prototype . getAuthTag = Cipher . prototype . getAuthTag ;
246+ constructor . prototype . setAuthTag = Cipher . prototype . setAuthTag ;
247+ constructor . prototype . setAAD = Cipher . prototype . setAAD ;
248+ }
249249
250+ inherits ( Cipheriv , LazyTransform ) ;
251+ addCipherPrototypeFunctions ( Cipheriv ) ;
250252
251253const finaltol = deprecate ( Cipher . prototype . final ,
252254 'crypto.Decipher.finaltol is deprecated. Use ' +
@@ -260,16 +262,8 @@ function Decipher(cipher, password, options) {
260262}
261263
262264inherits ( Decipher , LazyTransform ) ;
263-
264- Decipher . prototype . _transform = Cipher . prototype . _transform ;
265- Decipher . prototype . _flush = Cipher . prototype . _flush ;
266- Decipher . prototype . update = Cipher . prototype . update ;
267- Decipher . prototype . final = Cipher . prototype . final ;
265+ addCipherPrototypeFunctions ( Decipher ) ;
268266Decipher . prototype . finaltol = finaltol ;
269- Decipher . prototype . setAutoPadding = Cipher . prototype . setAutoPadding ;
270- Decipher . prototype . getAuthTag = Cipher . prototype . getAuthTag ;
271- Decipher . prototype . setAuthTag = Cipher . prototype . setAuthTag ;
272- Decipher . prototype . setAAD = Cipher . prototype . setAAD ;
273267
274268
275269function Decipheriv ( cipher , key , iv , options ) {
@@ -280,17 +274,8 @@ function Decipheriv(cipher, key, iv, options) {
280274}
281275
282276inherits ( Decipheriv , LazyTransform ) ;
283-
284- Decipheriv . prototype . _transform = Cipher . prototype . _transform ;
285- Decipheriv . prototype . _flush = Cipher . prototype . _flush ;
286- Decipheriv . prototype . update = Cipher . prototype . update ;
287- Decipheriv . prototype . final = Cipher . prototype . final ;
277+ addCipherPrototypeFunctions ( Decipheriv ) ;
288278Decipheriv . prototype . finaltol = finaltol ;
289- Decipheriv . prototype . setAutoPadding = Cipher . prototype . setAutoPadding ;
290- Decipheriv . prototype . getAuthTag = Cipher . prototype . getAuthTag ;
291- Decipheriv . prototype . setAuthTag = Cipher . prototype . setAuthTag ;
292- Decipheriv . prototype . setAAD = Cipher . prototype . setAAD ;
293-
294279
295280module . exports = {
296281 Cipher,
0 commit comments