mirror of
https://github.com/denoland/deno.git
synced 2025-01-18 03:44:05 -05:00
tests: deflake crypto InvalidIntializationVector (#13040)
Use fixed data that is known to error as the test intends.
This commit is contained in:
parent
f530189c50
commit
6f8f1cc244
1 changed files with 9 additions and 4 deletions
|
@ -746,19 +746,24 @@ Deno.test(async function testUnwrapKey() {
|
||||||
});
|
});
|
||||||
|
|
||||||
Deno.test(async function testDecryptWithInvalidIntializationVector() {
|
Deno.test(async function testDecryptWithInvalidIntializationVector() {
|
||||||
const data = new Uint8Array([42, 42, 42, 42]);
|
// deno-fmt-ignore
|
||||||
const key = await crypto.subtle.generateKey(
|
const data = new Uint8Array([42,42,42,42,42,42,42,42,42,42,42,42,42,42,42]);
|
||||||
|
const key = await crypto.subtle.importKey(
|
||||||
|
"raw",
|
||||||
|
new Uint8Array(16),
|
||||||
{ name: "AES-CBC", length: 256 },
|
{ name: "AES-CBC", length: 256 },
|
||||||
true,
|
true,
|
||||||
["encrypt", "decrypt"],
|
["encrypt", "decrypt"],
|
||||||
);
|
);
|
||||||
const initVector = crypto.getRandomValues(new Uint8Array(16));
|
// deno-fmt-ignore
|
||||||
|
const initVector = new Uint8Array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]);
|
||||||
const encrypted = await crypto.subtle.encrypt(
|
const encrypted = await crypto.subtle.encrypt(
|
||||||
{ name: "AES-CBC", iv: initVector },
|
{ name: "AES-CBC", iv: initVector },
|
||||||
key,
|
key,
|
||||||
data,
|
data,
|
||||||
);
|
);
|
||||||
const initVector2 = crypto.getRandomValues(new Uint8Array(16));
|
// deno-fmt-ignore
|
||||||
|
const initVector2 = new Uint8Array([15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0]);
|
||||||
await assertRejects(async () => {
|
await assertRejects(async () => {
|
||||||
await crypto.subtle.decrypt(
|
await crypto.subtle.decrypt(
|
||||||
{ name: "AES-CBC", iv: initVector2 },
|
{ name: "AES-CBC", iv: initVector2 },
|
||||||
|
|
Loading…
Add table
Reference in a new issue