@@ -18,7 +18,6 @@ import {
1818 op_node_decipheriv_decrypt ,
1919 op_node_decipheriv_final ,
2020 op_node_decipheriv_set_aad ,
21- op_node_decipheriv_take ,
2221 op_node_private_decrypt ,
2322 op_node_private_encrypt ,
2423 op_node_public_encrypt ,
@@ -352,14 +351,6 @@ export class Decipheriv extends Transform implements Cipher {
352351 }
353352
354353 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-
363354 let buf = new Buffer ( 16 ) ;
364355 op_node_decipheriv_final (
365356 this . #context,
@@ -369,6 +360,13 @@ export class Decipheriv extends Transform implements Cipher {
369360 this . #authTag || NO_TAG ,
370361 ) ;
371362
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+
372370 buf = buf . subarray ( 0 , 16 - buf . at ( - 1 ) ) ; // Padded in Pkcs7 mode
373371 return encoding === "buffer" ? buf : buf . toString ( encoding ) ;
374372 }
0 commit comments