Skip to content

Incorrect Thumbprint on Ed25519 #484

@scovetta

Description

@scovetta

The Jwk::thumbprint() function appears to incorrectly generate a thumbprint value using the unquoted crv string, which differs from how we're generating it above and how other implementations do it. It appears to have been a typo.

  EllipticCurve::Ed25519 => {
      format!(
          r#"{{crv:{},"kty":{},"x":"{}"}}"#,      // <--- Note that crv isn't double quoted.
          serde_json::to_string(&a.curve).unwrap(),
          serde_json::to_string(&a.key_type).unwrap(),
          a.x,
      )
  }

Earlier:

  AlgorithmParameters::EllipticCurve(a) => match a.curve {
      EllipticCurve::P256 | EllipticCurve::P384 | EllipticCurve::P521 => {
          format!(
              r#"{{"crv":{},"kty":{},"x":"{}","y":"{}"}}"#,
              serde_json::to_string(&a.curve).unwrap(),
              serde_json::to_string(&a.key_type).unwrap(),
              a.x,
              a.y,
          )
      }
      EllipticCurve::Ed25519 => panic!("EllipticCurve can't contain this curve type"),
  },

I will submit a PR with a fix.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions