Skip to content

Commit 1c47da1

Browse files
panvarichardlau
authored andcommitted
test,crypto: update WebCryptoAPI WPT
PR-URL: #51533 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]>
1 parent f91786b commit 1c47da1

File tree

7 files changed

+59
-3
lines changed

7 files changed

+59
-3
lines changed

‎test/fixtures/wpt/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Last update:
3131
- user-timing: https://github.com/web-platform-tests/wpt/tree/5ae85bf826/user-timing
3232
- wasm/jsapi: https://github.com/web-platform-tests/wpt/tree/cde25e7e3c/wasm/jsapi
3333
- wasm/webapi: https://github.com/web-platform-tests/wpt/tree/fd1b23eeaa/wasm/webapi
34-
- WebCryptoAPI: https://github.com/web-platform-tests/wpt/tree/d4e14d714c/WebCryptoAPI
34+
- WebCryptoAPI: https://github.com/web-platform-tests/wpt/tree/5e042cbc4e/WebCryptoAPI
3535
- webidl/ecmascript-binding/es-exceptions: https://github.com/web-platform-tests/wpt/tree/a370aad338/webidl/ecmascript-binding/es-exceptions
3636
- webmessaging/broadcastchannel: https://github.com/web-platform-tests/wpt/tree/e97fac4791/webmessaging/broadcastchannel
3737

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

Lines 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
returnsubtle.deriveBits({name: algorithmName,public: publicKeys[algorithmName]},privateKeys[algorithmName],null)
6574
.then(function(derivation){

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

Lines 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
returnsubtle.deriveBits({name: "ECDH",public: publicKeys[namedCurve]},privateKeys[namedCurve],null)
6170
.then(function(derivation){

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

Lines 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
returnsubtle.deriveBits(algorithm,baseKeys[derivedKeySize],null)
145154
.then(function(derivation){

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

Lines 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
returnsubtle.deriveBits({name: "PBKDF2",salt: salts[saltSize],hash: hashName,iterations: parseInt(iterations)},baseKeys[passwordSize],null)
110119
.then(function(derivation){

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

Lines 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
vardata=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+
functiontestEcdhJwkAlg(algorithm,keyData,keySize,usages,extractable){
162+
constformat="jwk";
163+
promise_test(function(test){
164+
returnsubtle.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:

‎test/fixtures/wpt/versions.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
"path": "wasm/webapi"
8585
},
8686
"WebCryptoAPI":{
87-
"commit": "d4e14d714c5242e174ba9aec43caf5eb514d0f09",
87+
"commit": "5e042cbc4ecab7b2279a5fd411c6daa24ca886c6",
8888
"path": "WebCryptoAPI"
8989
},
9090
"webidl/ecmascript-binding/es-exceptions":{

0 commit comments

Comments
(0)