mirror of
https://github.com/denoland/deno.git
synced 2025-02-08 07:16:56 -05:00
fix(ext/crypto): optional additionalData in encrypt/decrypt (#13669)
This commit is contained in:
parent
074f53234a
commit
77a9683425
2 changed files with 7 additions and 6 deletions
|
@ -1443,7 +1443,7 @@ Deno.test(async function testAesGcmEncrypt() {
|
||||||
const data = new Uint8Array([1, 2, 3]);
|
const data = new Uint8Array([1, 2, 3]);
|
||||||
|
|
||||||
const cipherText = await crypto.subtle.encrypt(
|
const cipherText = await crypto.subtle.encrypt(
|
||||||
{ name: "AES-GCM", iv, additionalData: new Uint8Array() },
|
{ name: "AES-GCM", iv },
|
||||||
key,
|
key,
|
||||||
data,
|
data,
|
||||||
);
|
);
|
||||||
|
@ -1457,7 +1457,7 @@ Deno.test(async function testAesGcmEncrypt() {
|
||||||
);
|
);
|
||||||
|
|
||||||
const plainText = await crypto.subtle.decrypt(
|
const plainText = await crypto.subtle.decrypt(
|
||||||
{ name: "AES-GCM", iv, additionalData: new Uint8Array() },
|
{ name: "AES-GCM", iv },
|
||||||
key,
|
key,
|
||||||
cipherText,
|
cipherText,
|
||||||
);
|
);
|
||||||
|
@ -1655,14 +1655,14 @@ Deno.test(async function testAesGcmTagLength() {
|
||||||
// encrypt won't fail, it will simply truncate the tag
|
// encrypt won't fail, it will simply truncate the tag
|
||||||
// as expected.
|
// as expected.
|
||||||
const encrypted = await crypto.subtle.encrypt(
|
const encrypted = await crypto.subtle.encrypt(
|
||||||
{ name: "AES-GCM", iv, tagLength: 96, additionalData: new Uint8Array() },
|
{ name: "AES-GCM", iv, tagLength: 96 },
|
||||||
key,
|
key,
|
||||||
new Uint8Array(32),
|
new Uint8Array(32),
|
||||||
);
|
);
|
||||||
|
|
||||||
await assertRejects(async () => {
|
await assertRejects(async () => {
|
||||||
await crypto.subtle.decrypt(
|
await crypto.subtle.decrypt(
|
||||||
{ name: "AES-GCM", iv, tagLength: 96, additionalData: new Uint8Array() },
|
{ name: "AES-GCM", iv, tagLength: 96 },
|
||||||
key,
|
key,
|
||||||
encrypted,
|
encrypted,
|
||||||
);
|
);
|
||||||
|
|
|
@ -691,7 +691,8 @@
|
||||||
algorithm: "AES-GCM",
|
algorithm: "AES-GCM",
|
||||||
length: key[_algorithm].length,
|
length: key[_algorithm].length,
|
||||||
iv: normalizedAlgorithm.iv,
|
iv: normalizedAlgorithm.iv,
|
||||||
additionalData: normalizedAlgorithm.additionalData,
|
additionalData: normalizedAlgorithm.additionalData ||
|
||||||
|
null,
|
||||||
tagLength: normalizedAlgorithm.tagLength,
|
tagLength: normalizedAlgorithm.tagLength,
|
||||||
}, data);
|
}, data);
|
||||||
|
|
||||||
|
@ -3825,7 +3826,7 @@
|
||||||
algorithm: "AES-GCM",
|
algorithm: "AES-GCM",
|
||||||
length: key[_algorithm].length,
|
length: key[_algorithm].length,
|
||||||
iv: normalizedAlgorithm.iv,
|
iv: normalizedAlgorithm.iv,
|
||||||
additionalData: normalizedAlgorithm.additionalData,
|
additionalData: normalizedAlgorithm.additionalData || null,
|
||||||
tagLength: normalizedAlgorithm.tagLength,
|
tagLength: normalizedAlgorithm.tagLength,
|
||||||
}, data);
|
}, data);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue