Skip to content

Commit a0b1e8f

Browse files
nodejs-github-botruyadorno
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 fe2b344 commit a0b1e8f

File tree

5 files changed

+108
-2
lines changed

5 files changed

+108
-2
lines changed

test/fixtures/wpt/README.md

Lines changed: 1 addition & 1 deletion
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

Lines changed: 22 additions & 0 deletions
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

Lines changed: 60 additions & 0 deletions
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

Lines changed: 24 additions & 0 deletions
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

Lines 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": "ecf39b605f4d2b5d7ef4fe344063c2856c9f105c",
91+
"commit": "76dfa54e5df7f8cee7501cc6d598cf647c2b8564",
9292
"path": "WebCryptoAPI"
9393
},
9494
"webidl/ecmascript-binding/es-exceptions": {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy