Skip to content

Commit ca9b2f6

Browse files
committed
Merge pull request #349 from Yubico/eliminate-cose-java
Eliminate COSE-Java dependency
2 parents 3c7913c + abcb0e0 commit ca9b2f6

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

webauthn-server-core/src/main/java/com/yubico/webauthn/WebAuthnCodecs.java

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,29 +47,31 @@ final class WebAuthnCodecs {
4747
private static final ByteArray EC_PUBLIC_KEY_OID =
4848
new ByteArray(
4949
new byte[] {
50-
0x2A, -122, 0x48, -50, 0x3D, 0x02, 0x01
50+
0x2A, (byte) 0x86, 0x48, (byte) 0xCE, 0x3D, 2, 1
5151
}); // OID 1.2.840.10045.2.1 ecPublicKey (ANSI X9.62 public key type)
5252
private static final ByteArray P256_CURVE_OID =
5353
new ByteArray(
54-
new byte[] {0x2A, -122, 0x48, -50, 0x3D, 0x03, 0x01, 7}); // OID 1.2.840.10045.3.1.7
54+
new byte[] {
55+
0x2A, (byte) 0x86, 0x48, (byte) 0xCE, 0x3D, 3, 1, 7 // OID 1.2.840.10045.3.1.7
56+
});
5557
private static final ByteArray P384_CURVE_OID =
56-
new ByteArray(new byte[] {0x2B, -127, 0x04, 0, 34}); // OID 1.3.132.0.34
58+
new ByteArray(new byte[] {0x2B, (byte) 0x81, 0x04, 0, 34}); // OID 1.3.132.0.34
5759
private static final ByteArray P512_CURVE_OID =
58-
new ByteArray(new byte[] {0x2B, -127, 0x04, 0, 35}); // OID 1.3.132.0.35
60+
new ByteArray(new byte[] {0x2B, (byte) 0x81, 0x04, 0, 35}); // OID 1.3.132.0.35
5961

6062
private static final ByteArray ED25519_ALG_ID =
6163
new ByteArray(
6264
new byte[] {
6365
// SEQUENCE (5 bytes)
6466
0x30,
65-
0x05,
67+
5,
6668
// OID (3 bytes)
6769
0x06,
68-
0x03,
70+
3,
6971
// OID 1.3.101.112
7072
0x2B,
71-
0x65,
72-
0x70
73+
101,
74+
112
7375
});
7476

7577
static ByteArray ecPublicKeyToRaw(ECPublicKey key) {
@@ -149,13 +151,10 @@ static PublicKey importCosePublicKey(ByteArray key)
149151
final int kty = cose.get(CBORObject.FromObject(1)).AsInt32();
150152
switch (kty) {
151153
case 1:
152-
// COSE-JAVA is hardcoded to ed25519-java provider ("EdDSA") which would require an
153-
// additional dependency to parse EdDSA keys via the OneKey constructor
154154
return importCoseEdDsaPublicKey(cose);
155155
case 2:
156156
return importCoseEcdsaPublicKey(cose);
157157
case 3:
158-
// COSE-JAVA supports RSA in v1.1.0 but not in v1.0.0
159158
return importCoseRsaPublicKey(cose);
160159
default:
161160
throw new IllegalArgumentException("Unsupported key type: " + kty);

0 commit comments

Comments
 (0)