Skip to content
Merged
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
11 changes: 10 additions & 1 deletion 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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is true for all JWK key types then?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, at least for all algorithms in Web Crypto, the JWK export steps only have additional steps for private keys, not for public keys.

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