Skip to content

Jwk::from_encoding_key rejects PKCS#8 v2 (RFC 5958) Ed25519 private keys #544

In review

Description

@fewerner

Jwk::from_encoding_key returns InvalidEddsaKey for an Ed25519 private key in PKCS#8 v2 format.

In src/jwk.rs, the EdDSA branch of Jwk::from_encoding_key works out the curve from the length of the whole PKCS#8 DER document:

let curve_type: EllipticCurve = match key.as_bytes().len() {
    // 16 byte header + 32 byte Ed25519 key
    48 => Ok(EllipticCurve::Ed25519),
    _ => Err(Error::from(ErrorKind::InvalidEddsaKey)),
}?;

A v1 Ed25519 key is exactly 48 bytes. A v2 key is longer because it includes the public key field, so it fails this check.

Activity

  1. changed the title [-]Jwk::from_encoding_key rejects PKCS#8 v2 (RFC 5958) Ed25519 private keys[/-] [+]`Jwk::from_encoding_key` rejects PKCS#8 v2 (RFC 5958) Ed25519 private keys[/+] on Sep 28, 2026
  2. arckoor commented on Sep 28, 2026

    @arckoor
    Collaborator

    Yup, see discussion here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions