feat(webauthn): emit SubjectPublicKeyInfo from getPublicKey()#230
Merged
Conversation
msirringhaus
approved these changes
May 27, 2026
Collaborator
msirringhaus
left a comment
There was a problem hiding this comment.
I'm not a cryptography expert, but lgtm
0ac08f3 to
1c17ed4
Compare
WebAuthn L3 §5.2.1.1 mandates DER-encoded SubjectPublicKeyInfo from AuthenticatorAttestationResponse.getPublicKey() for credentials using ES256, EdDSA Ed25519 and RS256, and null for any algorithm the user agent does not understand. Until now libwebauthn was emitting raw COSE_Key bytes there, which RPs could not feed into SubtleCrypto or the standard library X.509 parsers. A new cose::to_spki helper converts the stored COSE_Key bytes into SPKI for the mandatory floor. ESP256 (RFC 9864, -9) maps to the same SPKI as ES256 per WebAuthn L3 §5.8.5. Unsupported algorithms return Ok(None) so the JSON IDL response emits null per spec. Malformed keys for understood algorithms return Err. The conversion uses the spki and der crates, both already in the transitive dependency tree via p256.
6d11d68 to
4361b0b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
WebAuthn L3 §5.2.1.1 says
AuthenticatorAttestationResponse.getPublicKey()returns DER-encoded SubjectPublicKeyInfo for credentials using ES256, EdDSA Ed25519 and RS256, and null for any algorithm the user agent does not implement. libwebauthn was emitting raw COSE bytes there instead, which relying parties could not feed intoSubtleCryptoor standard X.509 parsers.A new converter produces SPKI for the WebAuthn L3 floor plus ESP256, which is equivalent to ES256 per RFC 9864. Algorithms outside the supported set return null per spec. Malformed keys for understood algorithms surface as an error.
The conversion uses the
spkianddercrates from RustCrypto, both already in the transitive dependency tree viap256, so no new external runtime crates land. Adding new algorithm support later is a small per-algorithm addition.Stacked on top of #229.