fix(ext/node): support Ed25519, X25519, and P-521 keys in X509Certificate.publicKey#32267
Open
bartlomieju wants to merge 1 commit intodenoland:mainfrom
Open
fix(ext/node): support Ed25519, X25519, and P-521 keys in X509Certificate.publicKey#32267bartlomieju wants to merge 1 commit intodenoland:mainfrom
bartlomieju wants to merge 1 commit intodenoland:mainfrom
Conversation
…cate.publicKey Adds support for extracting Ed25519, X25519, and P-521 (secp521r1) public keys from X509 certificates via `X509Certificate.prototype.publicKey`. Also adds full P-521 EC key support across the node:crypto compat layer (key parsing, export, signing, verification, ECDH, generation, and JWK). Ref: denoland#27211 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
X509Certificate.prototype.publicKeythrowing "unsupported x509 public key type" for Ed25519 and X25519 certificatesX509Certificate.prototype.publicKeythrowing "unsupported ec named curve" for P-521 (secp521r1) EC certificatesnode:cryptocompat layerRef: #27211
What changed
Ed25519 / X25519 in X509Certificate.publicKey
KeyObjectHandle::new_x509_public_key()relied on x509-parser'sspki.parsed()which returnsPublicKey::Unknownfor Ed25519/X25519 keys (the library doesn't have specific variants for these). The catch-all_arm now checks the algorithm OID and constructs the appropriate key objects.P-521 support (new)
Added P-521 (
secp521r1) support everywhere P-384 was already handled:Cargo.tomlecdhandjwkfeatures to thep521workspace depext/node_crypto/Cargo.tomlp521.workspace = trueext/node_crypto/keys.rsEcPublicKey::P521/EcPrivateKey::P521variants, OID constant, key parsing (PKCS8/SEC1/SPKI/X509), JWK import/export, DER export, key generation, key detailsext/node_crypto/sign.rsext/node_crypto/lib.rsext/node_crypto/x509.rsTests
Added two unit tests in
tests/unit_node/crypto/crypto_key_test.ts:What's still not implemented
The issue reporter also mentions
createPublicKeyfailing for these certificate types — that path is separate from the X509 path and may need its own fix (untested here).Other gaps found during this work:
KeyObject.prototype.equalsis not implemented (returnsERR_NOT_IMPLEMENTED)Test plan
cargo buildsucceedscargo test -p deno_node_cryptopassesdeno test --no-check --allow-all --config tests/config/deno.json tests/unit_node/crypto/crypto_key_test.ts --filter "X509Certificate publicKey for"🤖 Generated with Claude Code