From 1393bc54915dc8ecf6cc71128df4674923f61161 Mon Sep 17 00:00:00 2001 From: Tugrul Topuz Date: Sun, 12 Mar 2023 18:18:41 +0300 Subject: [PATCH] do not call transform padding for zero length tail --- src/transform/block.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/transform/block.ts b/src/transform/block.ts index 1c51300..29ec368 100644 --- a/src/transform/block.ts +++ b/src/transform/block.ts @@ -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); @@ -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);