Skip to content

Commit ef12e41

Browse files
panvapull[bot]
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 7999212 commit ef12e41

File tree

5 files changed

+36
-2
lines changed

5 files changed

+36
-2
lines changed

test/fixtures/wpt/README.md

+1-1
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

+32
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
var data = 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+
function testJwkAlgBehaviours(algorithm, keyData, crv, usages) {
142+
promise_test(function(test) {
143+
return subtle.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+
return subtle.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

+1
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ function run_test() {
167167
promise_test(function(test) {
168168
return subtle.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
return subtle.verify(algorithm, vector.publicKey, signature, vector.data)
172173
.then(function(is_verified) {

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

+1
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ function run_test() {
117117
promise_test(function(test) {
118118
return subtle.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
return subtle.verify({name: "HMAC", hash: vector.hash}, vector.key, signature, vector.plaintext)
122123
.then(function(is_verified) {

test/fixtures/wpt/versions.json

+1-1
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)