Skip to content

Commit

Permalink
Fix getOutput
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmillr committed Nov 26, 2024
1 parent 65db01f commit b09b292
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/aes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ export const gcm = /* @__PURE__ */ wrapCipher(
const out = new Uint8Array(plaintext.length + tagLength);
const toClean: (Uint8Array | Uint32Array)[] = [xk, authKey, counter, tagMask];
if (!isAligned32(plaintext)) toClean.push((plaintext = copyBytes(plaintext)));
ctr32(xk, false, counter, plaintext, out);
ctr32(xk, false, counter, plaintext, out.subarray(0, plaintext.length));
const tag = _computeTag(authKey, tagMask, out.subarray(0, out.length - tagLength));
toClean.push(tag);
out.set(tag, plaintext.length);
Expand Down
2 changes: 1 addition & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ export type XorStream = (

export function getOutput(expectedLength: number, out?: Uint8Array, onlyAligned = true) {
if (out === undefined) return new Uint8Array(expectedLength);
if (out.length < expectedLength)
if (out.length !== expectedLength)
throw new Error(
'invalid output length, expected at least ' + expectedLength + ', got: ' + out.length
);
Expand Down

0 comments on commit b09b292

Please sign in to comment.