Skip to content

Commit

Permalink
fix(ext/crypto): remove EdDSA alg key checks and export (#20331)
Browse files Browse the repository at this point in the history
As per WICG/webcrypto-secure-curves#24 this
removes the check for Ed25519 JWK `alg` during importKey and removes the
`alg` for Ed25519 keys during JWK exportKey.
  • Loading branch information
panva authored Aug 31, 2023
1 parent 653e668 commit 9d58c89
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions ext/crypto/00_crypto.js
Original file line number Diff line number Diff line change
Expand Up @@ -2273,18 +2273,13 @@ function importKeyEd25519(
}

// 5.
if (jwk.alg !== undefined && jwk.alg !== "EdDSA") {
throw new DOMException("Invalid algorithm", "DataError");
}

// 6.
if (
keyUsages.length > 0 && jwk.use !== undefined && jwk.use !== "sig"
) {
throw new DOMException("Invalid key usage", "DataError");
}

// 7.
// 6.
if (jwk.key_ops !== undefined) {
if (
ArrayPrototypeFind(
Expand All @@ -2311,12 +2306,12 @@ function importKeyEd25519(
}
}

// 8.
// 7.
if (jwk.ext !== undefined && jwk.ext === false && extractable) {
throw new DOMException("Invalid key extractability", "DataError");
}

// 9.
// 8.
if (jwk.d !== undefined) {
// https://www.rfc-editor.org/rfc/rfc8037#section-2
let privateKeyData;
Expand Down Expand Up @@ -4089,7 +4084,6 @@ function exportKeyEd25519(format, key, innerKey) {
: ops.op_crypto_base64url_encode(innerKey);
const jwk = {
kty: "OKP",
alg: "EdDSA",
crv: "Ed25519",
x,
"key_ops": key.usages,
Expand Down

0 comments on commit 9d58c89

Please sign in to comment.