traits icon indicating copy to clipboard operation
traits copied to clipboard

JWK Serialization for RFC7638 Thumbprints

Open alexrudy opened this issue 3 years ago • 2 comments

The JwkEcKey struct supports serialization to JSON, but does so in a manner where the fields are always specified to match the human-readable output (i.e. with kty first). Unfortunately, this makes the serialization incompatible with RFC7638, JSON Web Key Thumbprints, which requires that fields are serialized in lexicographic order.

It would be great to have either (a) the default serialization output lexicographic order, so that it can be used as the input to a JWK thumbprint, or (b) a wrapper struct for serializing a JWK in lexicographic order to create a JWK thumbprint.

I guess, ideally, this would end up in the JOSE crate, but I'm opening the issue here b/c this is where I discovered the issue, and it looks like the JOSE crate isn't yet implemented.

alexrudy avatar Feb 20 '23 02:02 alexrudy

We can order the keys alphabetically, that's fine. Would you care to open a PR?

tarcieri avatar Feb 24 '23 15:02 tarcieri

Will do!

alexrudy avatar Feb 25 '23 21:02 alexrudy

@alexrudy if this is still relevant, can you refile against https://github.com/rustcrypto/jose? Thanks!

tarcieri avatar Aug 18 '25 19:08 tarcieri