Skip to content

Commit

Permalink
including default value for ADD argument in webcrypto aes-gcm algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
antonioconselheiro committed Apr 28, 2024
1 parent 4d74d8d commit 3dd2734
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/webcrypto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ 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)
return { name: mode.GCM, iv: nonce, additionalData: AAD || new Uint8Array(0) };
throw new Error('unknown aes block mode');
}

Expand Down

0 comments on commit 3dd2734

Please sign in to comment.