@@ -236,17 +236,19 @@ function Cipheriv(cipher, key, iv, options) {
236
236
createCipherWithIV . call ( this , cipher , key , options , true , iv ) ;
237
237
}
238
238
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
+ }
249
249
250
+ inherits ( Cipheriv , LazyTransform ) ;
251
+ addCipherPrototypeFunctions ( Cipheriv ) ;
250
252
251
253
const finaltol = deprecate ( Cipher . prototype . final ,
252
254
'crypto.Decipher.finaltol is deprecated. Use ' +
@@ -260,16 +262,8 @@ function Decipher(cipher, password, options) {
260
262
}
261
263
262
264
inherits ( 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 ) ;
268
266
Decipher . 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 ;
273
267
274
268
275
269
function Decipheriv ( cipher , key , iv , options ) {
@@ -280,17 +274,8 @@ function Decipheriv(cipher, key, iv, options) {
280
274
}
281
275
282
276
inherits ( 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 ) ;
288
278
Decipheriv . 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
-
294
279
295
280
module . exports = {
296
281
Cipher,
0 commit comments