Skip to content

feat: add ES512 support - #555

Closed
gjasny wants to merge 1 commit into
Keats:masterfrom
gjasny:add-es512
Closed

gjasny wants to merge 1 commit into
Keats:masterfrom
gjasny:add-es512

Conversation

@gjasny

@gjasny gjasny commented Nov 10, 2026

Copy link
Copy Markdown

Hello,

I had some JWT and wanted to decode them with jwt-ui to visualize the content. Unfortunately, my tokens use the ES512 algorithm which jsonwebtoken does not support. This patch is the result of Claude adding ES512 support.

My rust knowledge is very basic so I cannot really judge if all of the changes are sensible. Nevertheless the code worked for me and I'd like to share it in good faith.

Thanks,
Gregor


Add ES512 (ECDSA with P-521 and SHA-512) to Algorithm and KeyAlgorithm, and implement signing, verification and JWK creation for P-521 keys in both crypto backends.

  • aws_lc_rs: use ECDSA_P521_SHA512_FIXED(_SIGNING).
  • rust_crypto: add the p521 crate. The RustCrypto ECDSA signers are now generated by one macro that decodes PKCS#8 into a SecretKey and converts it to a signing key. ES256/ES384 output is unchanged (both old and new paths use RFC 6979).
  • p521 0.13 signs with a random nonce from OsRng instead of RFC 6979, so rust_crypto ES512 signatures are valid but not deterministic.
  • Recognise 133-byte uncompressed P-521 public keys when building a JWK from a DecodingKey.

Tests use the RFC 7520 P-521 key (section 3.2) and the ES512 JWS (section 4.3).

Add ES512 (ECDSA with P-521 and SHA-512) to `Algorithm` and
`KeyAlgorithm`, and implement signing, verification and JWK
creation for P-521 keys in both crypto backends.

- aws_lc_rs: use ECDSA_P521_SHA512_FIXED(_SIGNING).
- rust_crypto: add the `p521` crate. The RustCrypto ECDSA signers
  are now generated by one macro that decodes PKCS#8 into a
  `SecretKey` and converts it to a signing key. ES256/ES384 output
  is unchanged (both old and new paths use RFC 6979).
- p521 0.13 signs with a random nonce from OsRng instead of RFC 6979,
  so rust_crypto ES512 signatures are valid but not deterministic.
- Recognise 133-byte uncompressed P-521 public keys when building a
  JWK from a DecodingKey.

Tests use the RFC 7520 P-521 key (section 3.2) and the ES512 JWS
(section 4.3).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

macro_rules! define_ecdsa_signer {
($name:ident, $alg:expr, $signing_key:ty) => {
($name:ident, $alg:expr, $secret_key:ty, $signing_key:ty, $signature:ty, $from_secret:expr) => {

@gjasny gjasny Nov 10, 2026 •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The updated crypto stack from #536 will simplify the define_ecdsa_signer macro, again.

@arckoor

arckoor commented Nov 10, 2026

Copy link
Copy Markdown
Collaborator

Really? #532

@arckoor arckoor closed this Nov 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants