Skip to content

Commit d164e53

Browse files
panvatargos
authored andcommitted
test,crypto: update WebCryptoAPI WPT
PR-URL: #50039 Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Matthew Aitken <maitken033380023@gmail.com>
1 parent 3b867e4 commit d164e53

5 files changed

Lines changed: 36 additions & 2 deletions

File tree

‎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/f4e7e32fd0/WebCryptoAPI
34+
- WebCryptoAPI: https://github.com/web-platform-tests/wpt/tree/d4e14d714c/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/import_export/okp_importKey.https.any.js‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@
8181
}
8282

8383
testFormat(format,algorithm,data,vector.name,usages,extractable);
84+
85+
// Test for https://github.com/WICG/webcrypto-secure-curves/pull/24
86+
if(format==="jwk"&&extractable){
87+
testJwkAlgBehaviours(algorithm,data.jwk,vector.name,usages);
88+
}
8489
});
8590

8691
});
@@ -92,6 +97,11 @@
9297
vardata=keyData[vector.name];
9398

9499
testFormat(format,algorithm,data,vector.name,usages,extractable);
100+
101+
// Test for https://github.com/WICG/webcrypto-secure-curves/pull/24
102+
if(format==="jwk"&&extractable){
103+
testJwkAlgBehaviours(algorithm,data.jwk,vector.name,usages);
104+
}
95105
});
96106
});
97107
});
@@ -126,6 +136,28 @@
126136
},"Good parameters: "+keySize.toString()+" bits "+parameterString(format,keyData[format],algorithm,extractable,usages));
127137
}
128138

139+
// Test importKey/exportKey "alg" behaviours, alg is ignored upon import and alg is missing for Ed25519 and Ed448 JWK export
140+
// https://github.com/WICG/webcrypto-secure-curves/pull/24
141+
functiontestJwkAlgBehaviours(algorithm,keyData,crv,usages){
142+
promise_test(function(test){
143+
returnsubtle.importKey('jwk',{ ...keyData,alg: 'this is ignored'},algorithm,true,usages).
144+
then(function(key){
145+
assert_equals(key.constructor,CryptoKey,"Imported a CryptoKey object");
146+
147+
returnsubtle.exportKey('jwk',key).
148+
then(function(result){
149+
assert_equals(Object.keys(result).length,keyData.d ? 6 : 5,"Correct number of JWK members");
150+
assert_equals(result.alg,undefined,'No JWK "alg" member is present');
151+
assert_true(equalJwk(keyData,result),"Round trip works");
152+
},function(err){
153+
assert_unreached("Threw an unexpected error: "+err.toString());
154+
});
155+
},function(err){
156+
assert_unreached("Threw an unexpected error: "+err.toString());
157+
});
158+
},"Good parameters with ignored JWK alg: "+crv.toString()+" "+parameterString('jwk',keyData,algorithm,true,usages));
159+
}
160+
129161

130162

131163
// Helper methods follow:

‎test/fixtures/wpt/WebCryptoAPI/sign_verify/eddsa.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ function run_test() {
167167
promise_test(function(test){
168168
returnsubtle.sign(algorithm,vector.privateKey,vector.data)
169169
.then(function(signature){
170+
assert_true(equalBuffers(signature,vector.signature),"Signing did not give the expected output");
170171
// Can we verify the signature?
171172
returnsubtle.verify(algorithm,vector.publicKey,signature,vector.data)
172173
.then(function(is_verified){

‎test/fixtures/wpt/WebCryptoAPI/sign_verify/hmac.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ function run_test() {
117117
promise_test(function(test){
118118
returnsubtle.sign({name: "HMAC",hash: vector.hash},vector.key,vector.plaintext)
119119
.then(function(signature){
120+
assert_true(equalBuffers(signature,vector.signature),"Signing did not give the expected output");
120121
// Can we get the verify the new signature?
121122
returnsubtle.verify({name: "HMAC",hash: vector.hash},vector.key,signature,vector.plaintext)
122123
.then(function(is_verified){

‎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": "f4e7e32fd0d4937f5b024602c6bf665ebeb1fa17",
87+
"commit": "d4e14d714c5242e174ba9aec43caf5eb514d0f09",
8888
"path": "WebCryptoAPI"
8989
},
9090
"webidl/ecmascript-binding/es-exceptions": {

0 commit comments

Comments
 (0)