Skip to content

Commit 4b4a457

Browse files
nodejs-github-botaduh95
authored andcommitted
test: update WPT for WebCryptoAPI to 76dfa54e5d
PR-URL: #56093 Reviewed-By: Filip Skokan <panva.ip@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Jason Zhang <xzha4350@gmail.com>
1 parent 155ee7a commit 4b4a457

File tree

5 files changed

+108
-2
lines changed

5 files changed

+108
-2
lines changed

test/fixtures/wpt/README.md

+1-1
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/ecf39b605f/WebCryptoAPI
35+
- WebCryptoAPI: https://github.com/web-platform-tests/wpt/tree/76dfa54e5d/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/6495c91853/webmessaging/broadcastchannel
3838
- webstorage: https://github.com/web-platform-tests/wpt/tree/9dafa89214/webstorage

test/fixtures/wpt/WebCryptoAPI/import_export/ec_importKey_failures_fixtures.js

+22
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@ function getMismatchedJWKKeyData(algorithm) {
1919
return [];
2020
}
2121

22+
function getMismatchedKtyField(algorithm) {
23+
return mismatchedKtyField[algorithm.name];
24+
}
25+
26+
function getMismatchedCrvField(algorithm) {
27+
return mismatchedCrvField[algorithm.name];
28+
}
29+
2230
var validKeyData = {
2331
"P-521": [
2432
{
@@ -201,3 +209,17 @@ var missingJWKFieldKeyData = {
201209
}
202210
]
203211
};
212+
213+
// The 'kty' field doesn't match the key algorithm.
214+
var mismatchedKtyField = {
215+
"P-521": "OKP",
216+
"P-256": "OKP",
217+
"P-384": "OKP",
218+
}
219+
220+
// The 'kty' field doesn't match the key algorithm.
221+
var mismatchedCrvField = {
222+
"P-521": "P-256",
223+
"P-256": "P-384",
224+
"P-384": "P-521",
225+
}

test/fixtures/wpt/WebCryptoAPI/import_export/importKey_failures.js

+60
Original file line numberDiff line numberDiff line change
@@ -207,4 +207,64 @@ function run_test(algorithmNames) {
207207
});
208208
});
209209

210+
// The 'kty' field is not correct.
211+
testVectors.forEach(function(vector) {
212+
var name = vector.name;
213+
allAlgorithmSpecifiersFor(name).forEach(function(algorithm) {
214+
getValidKeyData(algorithm).forEach(function(test) {
215+
if (test.format === "jwk") {
216+
var data = {crv: test.data.crv, kty: test.data.kty, d: test.data.d, x: test.data.x, d: test.data.d};
217+
data.kty = getMismatchedKtyField(algorithm);
218+
var usages = validUsages(vector, 'jwk', test.data);
219+
testError('jwk', algorithm, data, name, usages, true, "DataError", "Invalid 'kty' field");
220+
}
221+
});
222+
});
223+
});
224+
225+
// The 'ext' field is not correct.
226+
testVectors.forEach(function(vector) {
227+
var name = vector.name;
228+
allAlgorithmSpecifiersFor(name).forEach(function(algorithm) {
229+
getValidKeyData(algorithm).forEach(function(test) {
230+
if (test.format === "jwk") {
231+
var data = {crv: test.data.crv, kty: test.data.kty, d: test.data.d, x: test.data.x, d: test.data.d};
232+
data.ext = false;
233+
var usages = validUsages(vector, 'jwk', test.data);
234+
testError('jwk', algorithm, data, name, usages, true, "DataError", "Import from a non-extractable");
235+
}
236+
});
237+
});
238+
});
239+
240+
// The 'use' field is incorrect.
241+
testVectors.forEach(function(vector) {
242+
var name = vector.name;
243+
allAlgorithmSpecifiersFor(name).forEach(function(algorithm) {
244+
getValidKeyData(algorithm).forEach(function(test) {
245+
if (test.format === "jwk") {
246+
var data = {crv: test.data.crv, kty: test.data.kty, d: test.data.d, x: test.data.x, d: test.data.d};
247+
data.use = "invalid";
248+
var usages = validUsages(vector, 'jwk', test.data);
249+
if (usages.length !== 0)
250+
testError('jwk', algorithm, data, name, usages, true, "DataError", "Invalid 'use' field");
251+
}
252+
});
253+
});
254+
});
255+
256+
// The 'crv' field is incorrect.
257+
testVectors.forEach(function(vector) {
258+
var name = vector.name;
259+
allAlgorithmSpecifiersFor(name).forEach(function(algorithm) {
260+
getValidKeyData(algorithm).forEach(function(test) {
261+
if (test.format === "jwk") {
262+
var data = {crv: test.data.crv, kty: test.data.kty, d: test.data.d, x: test.data.x, d: test.data.d};
263+
data.crv = getMismatchedCrvField(algorithm)
264+
var usages = validUsages(vector, 'jwk', test.data);
265+
testError('jwk', algorithm, data, name, usages, true, "DataError", "Invalid 'crv' field");
266+
}
267+
});
268+
});
269+
});
210270
}

test/fixtures/wpt/WebCryptoAPI/import_export/okp_importKey_failures_fixtures.js

+24
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@ function getMismatchedJWKKeyData(algorithm) {
1717
return mismatchedJWKKeyData[algorithm.name];
1818
}
1919

20+
function getMismatchedKtyField(algorithm) {
21+
return mismatchedKtyField[algorithm.name];
22+
}
23+
24+
function getMismatchedCrvField(algorithm) {
25+
return mismatchedCrvField[algorithm.name];
26+
}
27+
2028
var validKeyData = {
2129
"Ed25519": [
2230
{
@@ -412,3 +420,19 @@ var mismatchedJWKKeyData = {
412420
},
413421
],
414422
}
423+
424+
// The 'kty' field doesn't match the key algorithm.
425+
var mismatchedKtyField = {
426+
"Ed25519": "EC",
427+
"X25519": "EC",
428+
"Ed448": "EC",
429+
"X448": "EC",
430+
}
431+
432+
// The 'kty' field doesn't match the key algorithm.
433+
var mismatchedCrvField = {
434+
"Ed25519": "X25519",
435+
"X25519": "Ed448",
436+
"Ed448": "X25519",
437+
"X448": "Ed25519",
438+
}

test/fixtures/wpt/versions.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888
"path": "wasm/webapi"
8989
},
9090
"WebCryptoAPI": {
91-
"commit": "ecf39b605f4d2b5d7ef4fe344063c2856c9f105c",
91+
"commit": "76dfa54e5df7f8cee7501cc6d598cf647c2b8564",
9292
"path": "WebCryptoAPI"
9393
},
9494
"webidl/ecmascript-binding/es-exceptions": {

0 commit comments

Comments
 (0)