Skip to content

Commit

Permalink
decrypt stream padding size check & error message
Browse files Browse the repository at this point in the history
  • Loading branch information
tugrul committed Oct 6, 2024
1 parent b8ceb6f commit c9133fe
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/transform/block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,9 @@ export class BlockDecrypt extends Block {
return callback(new Error('Finishing data cannot be empty'));
}

if ((this._tail.length % this._cipher.getBlockSize()) !== 0) {
return callback(new Error('Finishing data not matches the block size'));
if ((this._tail.length % this._cipher.getBlockSize()) !== 0
&& this._cipher.isPaddingRequired()) {
return callback(new Error('Finishing data does not match the block size'));
}

const target = this._cipher.transform(this._tail);
Expand Down

0 comments on commit c9133fe

Please sign in to comment.