Skip to content

feat(webauthn): emit SubjectPublicKeyInfo from getPublicKey()#230

Merged
AlfioEmanueleFresta merged 1 commit into
masterfrom
feat/cose-spki-emission
May 28, 2026
Merged

feat(webauthn): emit SubjectPublicKeyInfo from getPublicKey()#230
AlfioEmanueleFresta merged 1 commit into
masterfrom
feat/cose-spki-emission

Conversation

@AlfioEmanueleFresta
Copy link
Copy Markdown
Member

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 into SubtleCrypto or 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 spki and der crates from RustCrypto, both already in the transitive dependency tree via p256, so no new external runtime crates land. Adding new algorithm support later is a small per-algorithm addition.

Stacked on top of #229.

@AlfioEmanueleFresta AlfioEmanueleFresta marked this pull request as ready for review May 27, 2026 07:36
Copy link
Copy Markdown
Collaborator

@msirringhaus msirringhaus 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 not a cryptography expert, but lgtm

@AlfioEmanueleFresta AlfioEmanueleFresta force-pushed the feat/cose-opaque-credential-key branch from 0ac08f3 to 1c17ed4 Compare May 28, 2026 17:53
Base automatically changed from feat/cose-opaque-credential-key to master May 28, 2026 18:49
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.
@AlfioEmanueleFresta AlfioEmanueleFresta force-pushed the feat/cose-spki-emission branch from 6d11d68 to 4361b0b Compare May 28, 2026 18:57
@AlfioEmanueleFresta AlfioEmanueleFresta merged commit 70cb6a6 into master May 28, 2026
4 checks passed
@AlfioEmanueleFresta AlfioEmanueleFresta deleted the feat/cose-spki-emission branch May 28, 2026 22:33
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