Yubico / java-webauthn-server

Server-side Web Authentication library for Java https://www.w3.org/TR/webauthn/#rp-operations
Other
465 stars 142 forks source link

Extract DER-encoded public key from `RegistrationResult`/`AssertionResult`? #288

Open iaik-jheher opened 1 year ago

iaik-jheher commented 1 year ago

We have a business requirement to submit credential public keys to a third-party library for accreditation. This library only accepts Java PublicKey implementations (and expects them to return DER-encoded byte arrays from getEncoded()).

Internally, java-webauthn-server presumably already has to parse the COSE-encoded public key; would it be possible to expose this in a more "common" standard form, such as DER-encoded bytes?

(I am trying to avoid implementing COSE parsing myself.)

emlun commented 1 year ago

Hi! There are a few options here:

Both of the above options are available today without any changes to existing libraries, though you may need to add a few dependencies to your application.

We'll also consider adding a java.security.PublicKey getter to the *Result types, or maybe RegisteredCredential, in a future java-webauthn-server release. That seems like a reasonable thing to support.

iaik-jheher commented 1 year ago

Thanks for your quick response!

The client-side getPublicKey() method does not seem like a workable solution for us, since we use authenticator attestation. Since only the COSE public key is attested, we would need to re-verify that the two provided public keys match (which would require us to parse the COSE-encoded key, putting us back where we started.)

Thanks for the insights on how the library itself handles COSE parsing, though -- it looks like less of a complexity nightmare than anticipated. Still, we think it'd also be an appropriate thing for the library to provide.

PS: RegistrationResult does not currently expose the to-be-registered credential as a RegisteredCredential, so adding it there would not (by itself) expose the needed information.