Proposal Details
Even though X25519 key pairs (not to be confused with Ed25519 key pairs) can't be used to establish TLS connections, there are still cases in which you want to use them in combination with X.509 certificates. For example, if X25519 is used to perform public key authenticated encryption (e.g., NaCl's crypto_box), X.509 certificates may be used to authenticate the identity of the peer before encrypting/decrypting. RFC 8410 added the ability to embed X25519 public keys into X.509 certificates for such use cases.
Right now x509.ParseCertificate() completes successfully when presented with a certificate containing an X25519 public key. Unfortunately, it does end up discarding the public key, as Certificate.PublicKeyAlgorithm and Certificate.PublicKey will be set to UnknownPublicKeyAlgorithm and nil, respectively.
The proposal here is to actually let x509.ParseCertificate() extract the public key from the certificate and return it in the form of an *ecdh.PublicKey. The PublicKeyAlgorithm enumeration will be extended to include an additional element for this public key algorithm, which will simply be called X25519.
Code changes can be found here: https://go-review.googlesource.com/c/go/+/632875
Proposal Details
Even though X25519 key pairs (not to be confused with Ed25519 key pairs) can't be used to establish TLS connections, there are still cases in which you want to use them in combination with X.509 certificates. For example, if X25519 is used to perform public key authenticated encryption (e.g., NaCl's crypto_box), X.509 certificates may be used to authenticate the identity of the peer before encrypting/decrypting. RFC 8410 added the ability to embed X25519 public keys into X.509 certificates for such use cases.
Right now
x509.ParseCertificate()completes successfully when presented with a certificate containing an X25519 public key. Unfortunately, it does end up discarding the public key, asCertificate.PublicKeyAlgorithmandCertificate.PublicKeywill be set toUnknownPublicKeyAlgorithmandnil, respectively.The proposal here is to actually let
x509.ParseCertificate()extract the public key from the certificate and return it in the form of an*ecdh.PublicKey. ThePublicKeyAlgorithmenumeration will be extended to include an additional element for this public key algorithm, which will simply be calledX25519.Code changes can be found here: https://go-review.googlesource.com/c/go/+/632875