1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-25 15:29:32 -05:00

fix(ext/crypto): remove EdDSA alg key checks and export (#20331)

As per https://github.com/WICG/webcrypto-secure-curves/pull/24 this
removes the check for Ed25519 JWK `alg` during importKey and removes the
`alg` for Ed25519 keys during JWK exportKey.
This commit is contained in:
Filip Skokan 2023-08-31 14:56:26 +02:00 committed by GitHub
parent 653e668c20
commit 9d58c896dc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2273,18 +2273,13 @@ function importKeyEd25519(
} }
// 5. // 5.
if (jwk.alg !== undefined && jwk.alg !== "EdDSA") {
throw new DOMException("Invalid algorithm", "DataError");
}
// 6.
if ( if (
keyUsages.length > 0 && jwk.use !== undefined && jwk.use !== "sig" keyUsages.length > 0 && jwk.use !== undefined && jwk.use !== "sig"
) { ) {
throw new DOMException("Invalid key usage", "DataError"); throw new DOMException("Invalid key usage", "DataError");
} }
// 7. // 6.
if (jwk.key_ops !== undefined) { if (jwk.key_ops !== undefined) {
if ( if (
ArrayPrototypeFind( ArrayPrototypeFind(
@ -2311,12 +2306,12 @@ function importKeyEd25519(
} }
} }
// 8. // 7.
if (jwk.ext !== undefined && jwk.ext === false && extractable) { if (jwk.ext !== undefined && jwk.ext === false && extractable) {
throw new DOMException("Invalid key extractability", "DataError"); throw new DOMException("Invalid key extractability", "DataError");
} }
// 9. // 8.
if (jwk.d !== undefined) { if (jwk.d !== undefined) {
// https://www.rfc-editor.org/rfc/rfc8037#section-2 // https://www.rfc-editor.org/rfc/rfc8037#section-2
let privateKeyData; let privateKeyData;
@ -4089,7 +4084,6 @@ function exportKeyEd25519(format, key, innerKey) {
: ops.op_crypto_base64url_encode(innerKey); : ops.op_crypto_base64url_encode(innerKey);
const jwk = { const jwk = {
kty: "OKP", kty: "OKP",
alg: "EdDSA",
crv: "Ed25519", crv: "Ed25519",
x, x,
"key_ops": key.usages, "key_ops": key.usages,