Skip to content

Commit b48efd6

Browse files
WebCryptoAPI: Add tests cases for incorrect casing of the 'alg' JWK member (#51788)
1 parent 81c5132 commit b48efd6

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

WebCryptoAPI/import_export/importKey_failures.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,4 +267,23 @@ function run_test(algorithmNames) {
267267
});
268268
});
269269
});
270+
271+
// Use an 'alg' field with incorrect casing.
272+
testVectors.forEach(function(vector) {
273+
var name = vector.name;
274+
if (name !== "Ed25519" && name !== "Ed448")
275+
return; // The rest ignore the 'alg' field.
276+
allAlgorithmSpecifiersFor(name).forEach(function(algorithm) {
277+
getValidKeyData(algorithm).forEach(function(test) {
278+
if (test.format === "jwk") {
279+
var data = {crv: test.data.crv, kty: test.data.kty, d: test.data.d, x: test.data.x, y: test.data.y};
280+
var usages = validUsages(vector, 'jwk', test.data);
281+
[name.toLowerCase(), name.toUpperCase()].forEach(function(algName) {
282+
data.alg = algName;
283+
testError('jwk', algorithm, data, name, usages, true, "DataError", "Invalid 'alg' field '" + data.alg + "'");
284+
});
285+
}
286+
});
287+
});
288+
});
270289
}

0 commit comments

Comments
 (0)