Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9dfb36f

Browse filesBrowse files
panvatargos
authored andcommitted
test,crypto: update WebCryptoAPI WPT
PR-URL: #51533 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
1 parent 365a9dc commit 9dfb36f
Copy full SHA for 9dfb36f

File tree

Expand file treeCollapse file tree

7 files changed

+59
-3
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

7 files changed

+59
-3
lines changed
Open diff view settings
Collapse file

‎test/fixtures/wpt/README.md‎

Copy file name to clipboardExpand all lines: test/fixtures/wpt/README.md
+1-1Lines changed: 1 addition & 1 deletion
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Last update:
3232
- user-timing: https://github.com/web-platform-tests/wpt/tree/5ae85bf826/user-timing
3333
- wasm/jsapi: https://github.com/web-platform-tests/wpt/tree/cde25e7e3c/wasm/jsapi
3434
- wasm/webapi: https://github.com/web-platform-tests/wpt/tree/fd1b23eeaa/wasm/webapi
35-
- WebCryptoAPI: https://github.com/web-platform-tests/wpt/tree/d4e14d714c/WebCryptoAPI
35+
- WebCryptoAPI: https://github.com/web-platform-tests/wpt/tree/5e042cbc4e/WebCryptoAPI
3636
- webidl/ecmascript-binding/es-exceptions: https://github.com/web-platform-tests/wpt/tree/a370aad338/webidl/ecmascript-binding/es-exceptions
3737
- webmessaging/broadcastchannel: https://github.com/web-platform-tests/wpt/tree/e97fac4791/webmessaging/broadcastchannel
3838

Collapse file

‎test/fixtures/wpt/WebCryptoAPI/derive_bits_keys/cfrg_curves_bits.js‎

Copy file name to clipboardExpand all lines: test/fixtures/wpt/WebCryptoAPI/derive_bits_keys/cfrg_curves_bits.js
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,15 @@ function define_tests() {
6060
}, algorithmName + " mixed case parameters");
6161

6262
// Null length
63+
// "Null" is not valid per the current spec
64+
// - https://github.com/w3c/webcrypto/issues/322
65+
// - https://github.com/w3c/webcrypto/issues/329
66+
//
67+
// Proposal for a spec change:
68+
// - https://github.com/w3c/webcrypto/pull/345
69+
//
70+
// This test case may be replaced by these new tests:
71+
// - https://github.com/web-platform-tests/wpt/pull/43400
6372
promise_test(function(test) {
6473
return subtle.deriveBits({name: algorithmName, public: publicKeys[algorithmName]}, privateKeys[algorithmName], null)
6574
.then(function(derivation) {
Collapse file

‎test/fixtures/wpt/WebCryptoAPI/derive_bits_keys/ecdh_bits.js‎

Copy file name to clipboardExpand all lines: test/fixtures/wpt/WebCryptoAPI/derive_bits_keys/ecdh_bits.js
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,15 @@ function define_tests() {
5656
}, namedCurve + " mixed case parameters");
5757

5858
// Null length
59+
// "Null" is not valid per the current spec
60+
// - https://github.com/w3c/webcrypto/issues/322
61+
// - https://github.com/w3c/webcrypto/issues/329
62+
//
63+
// Proposal for a spec change:
64+
// - https://github.com/w3c/webcrypto/pull/345
65+
//
66+
// This test case may be replaced by these new tests:
67+
// - https://github.com/web-platform-tests/wpt/pull/43400
5968
promise_test(function(test) {
6069
return subtle.deriveBits({name: "ECDH", public: publicKeys[namedCurve]}, privateKeys[namedCurve], null)
6170
.then(function(derivation) {
Collapse file

‎test/fixtures/wpt/WebCryptoAPI/derive_bits_keys/hkdf.js‎

Copy file name to clipboardExpand all lines: test/fixtures/wpt/WebCryptoAPI/derive_bits_keys/hkdf.js
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,15 @@ function define_tests() {
140140
}, testName + " with missing info");
141141

142142
// length null (OperationError)
143+
// "Null" is not valid per the current spec
144+
// - https://github.com/w3c/webcrypto/issues/322
145+
// - https://github.com/w3c/webcrypto/issues/329
146+
//
147+
// Proposal for a spec change:
148+
// - https://github.com/w3c/webcrypto/pull/345
149+
//
150+
// This test case may be replaced by these new tests:
151+
// - https://github.com/web-platform-tests/wpt/pull/43400
143152
subsetTest(promise_test, function(test) {
144153
return subtle.deriveBits(algorithm, baseKeys[derivedKeySize], null)
145154
.then(function(derivation) {
Collapse file

‎test/fixtures/wpt/WebCryptoAPI/derive_bits_keys/pbkdf2.js‎

Copy file name to clipboardExpand all lines: test/fixtures/wpt/WebCryptoAPI/derive_bits_keys/pbkdf2.js
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,15 @@ function define_tests() {
105105

106106
// Test various error conditions for deriveBits below:
107107
// length null (OperationError)
108+
// "Null" is not valid per the current spec
109+
// - https://github.com/w3c/webcrypto/issues/322
110+
// - https://github.com/w3c/webcrypto/issues/329
111+
//
112+
// Proposal for a spec change:
113+
// - https://github.com/w3c/webcrypto/pull/345
114+
//
115+
// This test case may be replaced by these new tests:
116+
// - https://github.com/web-platform-tests/wpt/pull/43400
108117
subsetTest(promise_test, function(test) {
109118
return subtle.deriveBits({name: "PBKDF2", salt: salts[saltSize], hash: hashName, iterations: parseInt(iterations)}, baseKeys[passwordSize], null)
110119
.then(function(derivation) {
Collapse file

‎test/fixtures/wpt/WebCryptoAPI/import_export/ec_importKey.https.any.js‎

Copy file name to clipboardExpand all lines: test/fixtures/wpt/WebCryptoAPI/import_export/ec_importKey.https.any.js
+21-1Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@
8080
}
8181

8282
testFormat(format, algorithm, data, curve, usages, extractable);
83+
if (vector.name === 'ECDH' && format === 'jwk') {
84+
testEcdhJwkAlg(algorithm, { ...data.jwk, alg: 'any alg works here' }, curve, usages, extractable);
85+
}
8386
});
8487

8588
});
@@ -90,11 +93,13 @@
9093
var data = keyData[curve];
9194
allValidUsages(vector.privateUsages).forEach(function(usages) {
9295
testFormat(format, algorithm, data, curve, usages, extractable);
96+
if (vector.name === 'ECDH' && format === 'jwk') {
97+
testEcdhJwkAlg(algorithm, { ...data.jwk, alg: 'any alg works here' }, curve, usages, extractable);
98+
}
9399
});
94100
testEmptyUsages(format, algorithm, data, curve, extractable);
95101
});
96102
});
97-
98103
});
99104
});
100105

@@ -151,6 +156,21 @@
151156
}, "Empty Usages: " + keySize.toString() + " bits " + parameterString(format, false, keyData, algorithm, extractable, usages));
152157
}
153158

159+
// Test ECDH importKey with a JWK format
160+
// Should succeed with any "alg" value
161+
function testEcdhJwkAlg(algorithm, keyData, keySize, usages, extractable) {
162+
const format = "jwk";
163+
promise_test(function(test) {
164+
return subtle.importKey(format, keyData, algorithm, extractable, usages).
165+
then(function(key) {
166+
assert_equals(key.constructor, CryptoKey, "Imported a CryptoKey object");
167+
assert_goodCryptoKey(key, algorithm, extractable, usages, keyData.d ? 'private' : 'public');
168+
}, function(err) {
169+
assert_unreached("Threw an unexpected error: " + err.toString());
170+
});
171+
}, "ECDH any JWK alg: " + keySize.toString() + " bits " + parameterString(format, false, keyData, algorithm, extractable, usages));
172+
}
173+
154174

155175

156176
// Helper methods follow:
Collapse file

‎test/fixtures/wpt/versions.json‎

Copy file name to clipboardExpand all lines: test/fixtures/wpt/versions.json
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888
"path": "wasm/webapi"
8989
},
9090
"WebCryptoAPI": {
91-
"commit": "d4e14d714c5242e174ba9aec43caf5eb514d0f09",
91+
"commit": "5e042cbc4ecab7b2279a5fd411c6daa24ca886c6",
9292
"path": "WebCryptoAPI"
9393
},
9494
"webidl/ecmascript-binding/es-exceptions": {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.