Skip to content

Commit 5b23b02

Browse files
authored
fix: required-arg checks, validation ordering, and length=null in subtle (#1024)
1 parent d2c46b1 commit 5b23b02

4 files changed

Lines changed: 642 additions & 74 deletions

File tree

example/src/hooks/useTestsList.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ import '../tests/subtle/sign_verify';
4646
import '../tests/subtle/supports';
4747
import '../tests/subtle/getPublicKey';
4848
import '../tests/subtle/usage_canonicalization';
49+
import '../tests/subtle/validation_ordering';
4950
import '../tests/subtle/wrap_unwrap';
5051
import '../tests/utils/utils_tests';
5152
import '../tests/utils/encoding_tests';

example/src/tests/subtle/encrypt_decrypt.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ async function testRSAEncryptionWrongKey({
279279
return assertThrowsAsync(
280280
async () =>
281281
await subtle.encrypt(algorithm, privateKey as CryptoKey, plaintext),
282-
'The requested operation is not valid for the provided key',
282+
'InvalidAccessError',
283283
);
284284
}
285285

@@ -301,7 +301,7 @@ async function testRSAEncryptionBadUsage({
301301
return assertThrowsAsync(
302302
async () =>
303303
await subtle.encrypt(algorithm, publicKey as CryptoKey, plaintext),
304-
'The requested operation is not valid',
304+
'InvalidAccessError',
305305
);
306306
}
307307

@@ -328,7 +328,7 @@ async function testRSADecryptionWrongKey({
328328
return assertThrowsAsync(
329329
async () =>
330330
await subtle.decrypt(algorithm, publicKey as CryptoKey, ciphertext),
331-
'The requested operation is not valid',
331+
'InvalidAccessError',
332332
);
333333
}
334334

@@ -355,7 +355,7 @@ async function testRSADecryptionBadUsage({
355355
return assertThrowsAsync(
356356
async () =>
357357
await subtle.decrypt(algorithm, publicKey as CryptoKey, ciphertext),
358-
'The requested operation is not valid',
358+
'InvalidAccessError',
359359
);
360360
}
361361

@@ -647,7 +647,7 @@ test(SUITE, 'ChaCha20-Poly1305 wrong key usage encrypt', async () => {
647647
key as CryptoKey,
648648
getRandomValues(new Uint8Array(32)),
649649
),
650-
'The requested operation is not valid for the provided key',
650+
'InvalidAccessError',
651651
);
652652
});
653653

@@ -674,7 +674,7 @@ test(SUITE, 'ChaCha20-Poly1305 wrong key usage decrypt', async () => {
674674
key as CryptoKey,
675675
ciphertext,
676676
),
677-
'The requested operation is not valid for the provided key',
677+
'InvalidAccessError',
678678
);
679679
});
680680

@@ -936,7 +936,7 @@ async function testAESEncryptNoEncrypt({
936936

937937
await assertThrowsAsync(
938938
async () => await subtle.encrypt(algorithm, key, plaintext),
939-
'The requested operation is not valid for the provided key',
939+
'InvalidAccessError',
940940
);
941941
}
942942

@@ -962,7 +962,7 @@ async function testAESEncryptNoDecrypt({
962962

963963
await assertThrowsAsync(
964964
async () => await subtle.decrypt(algorithm, key, output),
965-
'The requested operation is not valid for the provided key',
965+
'InvalidAccessError',
966966
);
967967
}
968968

@@ -982,7 +982,7 @@ async function testAESEncryptWrongAlg(
982982

983983
await assertThrowsAsync(
984984
async () => await subtle.encrypt(algorithm, key, plaintext),
985-
'The requested operation is not valid for the provided key',
985+
'InvalidAccessError',
986986
);
987987
}
988988

0 commit comments

Comments
 (0)