Skip to content

Conversation

V02460
Copy link
Contributor

@V02460 V02460 commented Aug 8, 2025

Implements deriving a key’s ID if no explicit kid is provided. Contains unit tests and documentation.

secrets.keys.[].kid can now be omitted and in this case the kid is automatically derived. If the field is set, the behavior is the same as before.

Edit: The derived kid is now the key’s RFC 7638 JWK Thumbprint.

The derived kid is based on a key’s fingerprint: it simply takes the first four bytes and hex-encodes them.

For creating the fingerprinting function I took inspiration from how OpenSSH and AWS are doing their key fingerprinting. They take some canonical byte-representation and hash them, but differ in the used hashing function and whether the private key or corresponding public key is used. I ended up using sha256 hashing on the corresponding public key encoded as PSCK#8 DER.

Copy link
Member

@sandhose sandhose left a comment

Choose a reason for hiding this comment

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

Looks good overall

Copy link
Member

@sandhose sandhose left a comment

Choose a reason for hiding this comment

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

I'm happy with that, thanks!

@sandhose sandhose changed the title Derive kid from key Automatically derive the kid from the key fingerprint if missing Sep 2, 2025
@sandhose sandhose added A-Configuration Related on what is configurable and how it can be configured T-Enhancement New feature of request labels Sep 2, 2025
@sandhose sandhose merged commit 6eac7ed into element-hq:main Sep 2, 2025
35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Configuration Related on what is configurable and how it can be configured T-Enhancement New feature of request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants