Skip to content

test: update WPT for WebCryptoAPI to ab08796857 #59129

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion test/fixtures/wpt/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Last update:
- wasm/jsapi: https://github.com/web-platform-tests/wpt/tree/cde25e7e3c/wasm/jsapi
- wasm/webapi: https://github.com/web-platform-tests/wpt/tree/fd1b23eeaa/wasm/webapi
- web-locks: https://github.com/web-platform-tests/wpt/tree/10a122a6bc/web-locks
- WebCryptoAPI: https://github.com/web-platform-tests/wpt/tree/591c95ce61/WebCryptoAPI
- WebCryptoAPI: https://github.com/web-platform-tests/wpt/tree/ab08796857/WebCryptoAPI
- webidl/ecmascript-binding/es-exceptions: https://github.com/web-platform-tests/wpt/tree/2f96fa1996/webidl/ecmascript-binding/es-exceptions
- webmessaging/broadcastchannel: https://github.com/web-platform-tests/wpt/tree/6495c91853/webmessaging/broadcastchannel
- webstorage: https://github.com/web-platform-tests/wpt/tree/1291340aaa/webstorage
Expand Down
11 changes: 10 additions & 1 deletion test/fixtures/wpt/WebCryptoAPI/generateKey/successes.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ function run_test(algorithmNames, slowTest) {
})
.then(async function (result) {
if (resultType === "CryptoKeyPair") {
await Promise.all([
const [jwkPub,,, jwkPriv] = await Promise.all([
subtle.exportKey('jwk', result.publicKey),
subtle.exportKey('spki', result.publicKey),
result.publicKey.algorithm.name.startsWith('RSA') ? undefined : subtle.exportKey('raw', result.publicKey),
Expand All @@ -84,6 +84,15 @@ function run_test(algorithmNames, slowTest) {
subtle.exportKey('pkcs8', result.privateKey),
] : [])
]);

if (extractable) {
// Test that the JWK public key is a superset of the JWK private key.
for (const [prop, value] of Object.entries(jwkPub)) {
if (prop !== 'key_ops') {
assert_equals(value, jwkPriv[prop], `Property ${prop} is equal in public and private JWK`);
}
}
}
} else {
if (extractable) {
await Promise.all([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ function getMismatchedJWKKeyData(algorithm) {
}

function getMismatchedKtyField(algorithm) {
return mismatchedKtyField[algorithm.name];
return mismatchedKtyField[algorithm.namedCurve];
}

function getMismatchedCrvField(algorithm) {
return mismatchedCrvField[algorithm.name];
return mismatchedCrvField[algorithm.namedCurve];
}

var validKeyData = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ function run_test(algorithmNames) {
allAlgorithmSpecifiersFor(name).forEach(function(algorithm) {
getValidKeyData(algorithm).forEach(function(test) {
if (test.format === "jwk") {
var data = {crv: test.data.crv, kty: test.data.kty, d: test.data.d, x: test.data.x, d: test.data.d};
var data = {crv: test.data.crv, kty: test.data.kty, d: test.data.d, x: test.data.x, y: test.data.y};
data.use = "invalid";
var usages = validUsages(vector, 'jwk', test.data);
if (usages.length !== 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,27 @@
// helper functions that generate all possible test parameters for
// different situations.
function getValidKeyData(algorithm) {
return validKeyData[algorithm.name];
return validKeyData[algorithm.name || algorithm];
}

function getBadKeyLengthData(algorithm) {
return badKeyLengthData[algorithm.name];
return badKeyLengthData[algorithm.name || algorithm];
}

function getMissingJWKFieldKeyData(algorithm) {
return missingJWKFieldKeyData[algorithm.name];
return missingJWKFieldKeyData[algorithm.name || algorithm];
}

function getMismatchedJWKKeyData(algorithm) {
return mismatchedJWKKeyData[algorithm.name];
return mismatchedJWKKeyData[algorithm.name || algorithm];
}

function getMismatchedKtyField(algorithm) {
return mismatchedKtyField[algorithm.name];
return mismatchedKtyField[algorithm.name || algorithm];
}

function getMismatchedCrvField(algorithm) {
return mismatchedCrvField[algorithm.name];
return mismatchedCrvField[algorithm.name || algorithm];
}

var validKeyData = {
Expand Down
5 changes: 5 additions & 0 deletions test/fixtures/wpt/WebCryptoAPI/util/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ function objectToString(obj) {
// Is key a CryptoKey object with correct algorithm, extractable, and usages?
// Is it a secret, private, or public kind of key?
function assert_goodCryptoKey(key, algorithm, extractable, usages, kind) {
if (typeof algorithm === "string") {
algorithm = { name: algorithm };
}

var correctUsages = [];

var registeredAlgorithmName;
Expand Down Expand Up @@ -203,6 +207,7 @@ function allAlgorithmSpecifiersFor(algorithmName) {
results.push({name: algorithmName, namedCurve: curveName});
});
} else if (algorithmName.toUpperCase().substring(0, 1) === "X" || algorithmName.toUpperCase().substring(0, 2) === "ED") {
results.push(algorithmName);
results.push({ name: algorithmName });
}

Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/wpt/versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
"path": "web-locks"
},
"WebCryptoAPI": {
"commit": "591c95ce6174690b92833cd92859ce2807714591",
"commit": "ab08796857072c5a93e27e0a25effba2e07dad11",
"path": "WebCryptoAPI"
},
"webidl/ecmascript-binding/es-exceptions": {
Expand Down
Loading