Skip to content

Commit

Permalink
chacha: add type check
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmillr committed Oct 6, 2024
1 parent 428b211 commit 455255e
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/chacha.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ export const _poly1305_aead =
abytes(nonce);
return {
encrypt(plaintext: Uint8Array, output?: Uint8Array) {
abytes(plaintext);
const plength = plaintext.length;
const clength = plength + tagLength;
if (output) {
Expand All @@ -254,6 +255,7 @@ export const _poly1305_aead =
return output;
},
decrypt(ciphertext: Uint8Array, output?: Uint8Array) {
abytes(ciphertext);
const clength = ciphertext.length;
const plength = clength - tagLength;
if (clength < tagLength)
Expand Down

0 comments on commit 455255e

Please sign in to comment.