File tree Expand file tree Collapse file tree 2 files changed +27
-1
lines changed
main/java/com/yubico/webauthn
test/scala/com/yubico/webauthn Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -197,4 +197,29 @@ default PublicKeyCredentialDescriptor toPublicKeyCredentialDescriptor() {
197
197
.transports (getTransports ())
198
198
.build ();
199
199
}
200
+
201
+ /**
202
+ * Convert a credential public key from U2F format to COSE_Key format.
203
+ *
204
+ * <p>The U2F JavaScript API encoded credential public keys in <code>ALG_KEY_ECC_X962_RAW</code>
205
+ * format as specified in <a
206
+ * href="https://fidoalliance.org/specs/fido-v2.0-id-20180227/fido-registry-v2.0-id-20180227.html#public-key-representation-formats">FIDO
207
+ * Registry §3.6.2 Public Key Representation Formats</a>. If your database has credential public
208
+ * keys stored in this format, those public keys need to be converted to COSE_Key format before
209
+ * they can be used by a {@link CredentialRecord} instance. This function performs the conversion.
210
+ *
211
+ * <p>If your application has only used the <code>navigator.credentials.create()</code> API to
212
+ * register credentials, you likely do not need this function.
213
+ *
214
+ * @param es256RawKey a credential public key in <code>ALG_KEY_ECC_X962_RAW</code> format as
215
+ * specified in <a
216
+ * href="https://fidoalliance.org/specs/fido-v2.0-id-20180227/fido-registry-v2.0-id-20180227.html#public-key-representation-formats">FIDO
217
+ * Registry §3.6.2 Public Key Representation Formats</a>.
218
+ * @return a credential public key in COSE_Key format, suitable to be returned by {@link
219
+ * CredentialRecord#getPublicKeyCose()}.
220
+ * @see RegisteredCredential.RegisteredCredentialBuilder#publicKeyEs256Raw(ByteArray)
221
+ */
222
+ static ByteArray cosePublicKeyFromEs256Raw (final ByteArray es256RawKey ) {
223
+ return WebAuthnCodecs .rawEcKeyToCose (es256RawKey );
224
+ }
200
225
}
Original file line number Diff line number Diff line change @@ -2525,7 +2525,8 @@ class RelyingPartyV2AssertionSpec
2525
2525
Helpers .CredentialRepositoryV2 .withUser(
2526
2526
testData.userId,
2527
2527
credentialId = testData.assertion.get.response.getId,
2528
- publicKeyCose = WebAuthnCodecs .rawEcKeyToCose(u2fPubkey),
2528
+ publicKeyCose =
2529
+ CredentialRecord .cosePublicKeyFromEs256Raw(u2fPubkey),
2529
2530
)
2530
2531
)
2531
2532
.usernameRepository(
You can’t perform that action at this time.
0 commit comments