Skip to content

Commit

Permalink
fix(block-ciphers): cbc: use array offsets (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
nkeor authored Sep 29, 2023
1 parent 31be5e2 commit 7486524
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/block-modes/cbc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class Cbc<T extends BlockCipher> extends BlockCipherMode<T> {
decrypt(data: Uint8Array): Uint8Array {
this.checkBlockSize(data.length);

const view = new DataView(data.buffer);
const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
const decrypted = data.slice();
const decryptedView = new DataView(decrypted.buffer);

Expand Down
2 changes: 1 addition & 1 deletion src/block-modes/cfb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class Cfb<T extends BlockCipher> extends BlockCipherMode<T> {
encrypt(data: Uint8Array): Uint8Array {
data = pad(data, this.padding, this.blockSize);

const view = new DataView(data.buffer);
const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
const encrypted = new Uint8Array(data.length);
const encryptedView = new DataView(encrypted.buffer);

Expand Down

0 comments on commit 7486524

Please sign in to comment.