Skip to content

Commit

Permalink
Merge pull request #34 from antonioconselheiro/bugfix/aes-gcm-missing…
Browse files Browse the repository at this point in the history
…-argument-for-webcrypto

including default value for ADD argument in webcrypto aes-gcm algorithm
  • Loading branch information
paulmillr authored Apr 29, 2024
2 parents 4d74d8d + f805739 commit 9f0a098
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/webcrypto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,11 @@ type BlockMode = (typeof mode)[keyof typeof mode];
function getCryptParams(algo: BlockMode, nonce: Uint8Array, AAD?: Uint8Array) {
if (algo === mode.CBC) return { name: mode.CBC, iv: nonce };
if (algo === mode.CTR) return { name: mode.CTR, counter: nonce, length: 64 };
if (algo === mode.GCM) return { name: mode.GCM, iv: nonce, additionalData: AAD };
if (algo === mode.GCM) {
if (AAD) return { name: mode.GCM, iv: nonce, additionalData: AAD };
else return { name: mode.GCM, iv: nonce };
}

throw new Error('unknown aes block mode');
}

Expand Down

0 comments on commit 9f0a098

Please sign in to comment.