Skip to content

Commit

Permalink
do not call transform padding for zero length tail
Browse files Browse the repository at this point in the history
  • Loading branch information
tugrul committed Mar 12, 2023
1 parent 21c90a7 commit 1393bc5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/transform/block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export class BlockEncrypt extends Block {

_flush(callback: TransformCallback) {
try {
this.push(this._cipher.transform(this._pad(this._tail)));
this._tail.length > 0 && this.push(this._cipher.transform(this._pad(this._tail)));
return callback(null);
} catch (err) {
return callback(err as Error | null | undefined);
Expand Down Expand Up @@ -77,7 +77,7 @@ export class BlockDecrypt extends Block {
const target = this._cipher.transform(this._tail);

try {
this.push(this._unpad(target));
this._tail.length > 0 && this.push(this._unpad(target));
return callback(null);
} catch (err) {
return callback(err as Error | null | undefined);
Expand Down

0 comments on commit 1393bc5

Please sign in to comment.