@@ -18,7 +18,6 @@ import {
18
18
op_node_decipheriv_decrypt ,
19
19
op_node_decipheriv_final ,
20
20
op_node_decipheriv_set_aad ,
21
- op_node_decipheriv_take ,
22
21
op_node_private_decrypt ,
23
22
op_node_private_encrypt ,
24
23
op_node_public_encrypt ,
@@ -352,14 +351,6 @@ export class Decipheriv extends Transform implements Cipher {
352
351
}
353
352
354
353
final ( encoding : string = getDefaultEncoding ( ) ) : Buffer | string {
355
- if ( ! this . #needsBlockCache || this . #cache. cache . byteLength === 0 ) {
356
- op_node_decipheriv_take ( this . #context) ;
357
- return encoding === "buffer" ? Buffer . from ( [ ] ) : "" ;
358
- }
359
- if ( this . #cache. cache . byteLength != 16 ) {
360
- throw new Error ( "Invalid final block size" ) ;
361
- }
362
-
363
354
let buf = new Buffer ( 16 ) ;
364
355
op_node_decipheriv_final (
365
356
this . #context,
@@ -369,6 +360,13 @@ export class Decipheriv extends Transform implements Cipher {
369
360
this . #authTag || NO_TAG ,
370
361
) ;
371
362
363
+ if ( ! this . #needsBlockCache || this . #cache. cache . byteLength === 0 ) {
364
+ return encoding === "buffer" ? Buffer . from ( [ ] ) : "" ;
365
+ }
366
+ if ( this . #cache. cache . byteLength != 16 ) {
367
+ throw new Error ( "Invalid final block size" ) ;
368
+ }
369
+
372
370
buf = buf . subarray ( 0 , 16 - buf . at ( - 1 ) ) ; // Padded in Pkcs7 mode
373
371
return encoding === "buffer" ? buf : buf . toString ( encoding ) ;
374
372
}
0 commit comments