Skip to content

Commit 2aa7252

Browse files
hubertchaochromium-wpt-export-bot
authored andcommitted
[WebCrypto] Add WebCryptoAPI WPT for CryptoKey serialization
We added ML-DSA and ML-KEM with broken CryptoKey serialization, but this wasn't exposed because there was no WPT test for it. Add a WPT test for serialization by roundtripping a message with a CryptoKey and comparing the exportKey results. (The other main way to do CryptoKey serialization is to use an IndexedDB. Posting messages was simpler.) Bug: 512509718 Change-Id: I7499ec3a05b6b9e72f22c00e0815f4f847027fe3 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7842729 Reviewed-by: Daniel Cheng <dcheng@chromium.org> Reviewed-by: David Benjamin <davidben@chromium.org> Commit-Queue: Hubert Chao <hchao@chromium.org> Cr-Commit-Position: refs/heads/main@{#1631811}
1 parent 8485628 commit 2aa7252

21 files changed

Lines changed: 346 additions & 0 deletions
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// META: title=WebCryptoAPI: CryptoKey serialization
2+
// META: script=../util/helpers.js
3+
// META: script=serialization.js
4+
run_test([
5+
{
6+
name: 'AES-CBC',
7+
resultType: 'CryptoKey',
8+
usages: ['encrypt', 'decrypt', 'wrapKey', 'unwrapKey'],
9+
exportFormat: 'raw'
10+
},
11+
]);
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// META: title=WebCryptoAPI: CryptoKey serialization
2+
// META: script=../util/helpers.js
3+
// META: script=serialization.js
4+
run_test([
5+
{
6+
name: 'AES-CTR',
7+
resultType: 'CryptoKey',
8+
usages: ['encrypt', 'decrypt', 'wrapKey', 'unwrapKey'],
9+
exportFormat: 'raw'
10+
},
11+
]);
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// META: title=WebCryptoAPI: CryptoKey serialization
2+
// META: script=../util/helpers.js
3+
// META: script=serialization.js
4+
run_test([
5+
{
6+
name: 'AES-GCM',
7+
resultType: 'CryptoKey',
8+
usages: ['encrypt', 'decrypt', 'wrapKey', 'unwrapKey'],
9+
exportFormat: 'raw'
10+
},
11+
]);
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// META: title=WebCryptoAPI: CryptoKey serialization
2+
// META: script=../util/helpers.js
3+
// META: script=serialization.js
4+
run_test([
5+
{
6+
name: 'AES-KW',
7+
resultType: 'CryptoKey',
8+
usages: ['wrapKey', 'unwrapKey'],
9+
exportFormat: 'raw'
10+
},
11+
]);
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// META: title=WebCryptoAPI: CryptoKey serialization
2+
// META: script=../util/helpers.js
3+
// META: script=serialization.js
4+
run_test([
5+
{
6+
name: 'AES-OCB',
7+
resultType: 'CryptoKey',
8+
usages: ['encrypt', 'decrypt', 'wrapKey', 'unwrapKey'],
9+
exportFormat: 'raw-secret'
10+
},
11+
]);
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// META: title=WebCryptoAPI: CryptoKey serialization
2+
// META: script=../util/helpers.js
3+
// META: script=serialization.js
4+
run_test([
5+
{
6+
name: 'ChaCha20-Poly1305',
7+
resultType: 'CryptoKey',
8+
usages: ['encrypt', 'decrypt', 'wrapKey', 'unwrapKey'],
9+
exportFormat: 'raw-secret'
10+
},
11+
]);
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// META: title=WebCryptoAPI: CryptoKey serialization
2+
// META: script=../util/helpers.js
3+
// META: script=serialization.js
4+
run_test([
5+
{
6+
name: 'ECDH',
7+
resultType: 'CryptoKeyPair',
8+
usages: ['deriveKey', 'deriveBits'],
9+
publicFormat: 'raw',
10+
privateFormat: 'pkcs8'
11+
},
12+
]);
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// META: title=WebCryptoAPI: CryptoKey serialization
2+
// META: script=../util/helpers.js
3+
// META: script=serialization.js
4+
run_test([
5+
{
6+
name: 'ECDSA',
7+
resultType: 'CryptoKeyPair',
8+
usages: ['sign', 'verify'],
9+
publicFormat: 'raw',
10+
privateFormat: 'pkcs8'
11+
},
12+
]);
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// META: title=WebCryptoAPI: CryptoKey serialization
2+
// META: script=../util/helpers.js
3+
// META: script=serialization.js
4+
run_test([
5+
{
6+
name: 'Ed25519',
7+
resultType: 'CryptoKeyPair',
8+
usages: ['sign', 'verify'],
9+
publicFormat: 'raw',
10+
privateFormat: 'pkcs8'
11+
},
12+
]);
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// META: title=WebCryptoAPI: CryptoKey serialization
2+
// META: script=../util/helpers.js
3+
// META: script=serialization.js
4+
run_test([
5+
{
6+
name: 'Ed448',
7+
resultType: 'CryptoKeyPair',
8+
usages: ['sign', 'verify'],
9+
publicFormat: 'raw',
10+
privateFormat: 'pkcs8'
11+
},
12+
]);

0 commit comments

Comments
 (0)