Skip to content

Commit

Permalink
Drop dependency on COSE-Java
Browse files Browse the repository at this point in the history
  • Loading branch information
emlun committed Feb 12, 2024
1 parent 2cd916c commit e1500d8
Show file tree
Hide file tree
Showing 18 changed files with 21 additions and 43 deletions.
1 change: 0 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ dependencies {
constraints {
api(constraintLibs.bundles.jackson)
api(constraintLibs.cbor)
api(constraintLibs.cose)
api(constraintLibs.guava)
api(constraintLibs.httpclient5)
api(constraintLibs.slf4j)
Expand Down
1 change: 0 additions & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ dependencyResolutionManagement {
versionCatalogs {
create("constraintLibs") {
library("cbor", "com.upokecenter:cbor:[4.5.1,5)")
library("cose", "com.augustcellars.cose:cose-java:[1.0.0,2)")
library("guava", "com.google.guava:guava:[24.1.1,33)")
library("httpclient5", "org.apache.httpcomponents.client5:httpclient5:[5.0.0,6)")
library("slf4j", "org.slf4j:slf4j-api:[1.7.25,3)")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ dependencies {
testImplementation("junit:junit:4.12")
testImplementation("org.mockito:mockito-core:[2.27.0,3)")

// Runtime-only internal dependency of webauthn-server-core
testImplementation("com.augustcellars.cose:cose-java:[1.0.0,2)")

// Transitive dependencies from coreTestOutput
testImplementation("org.scala-lang:scala-library:[2.13.1,3)")
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import static org.junit.Assert.assertTrue;

import COSE.CoseException;
import com.yubico.webauthn.data.AttestationObject;
import com.yubico.webauthn.data.RelyingPartyIdentity;
import java.io.IOException;
Expand Down Expand Up @@ -72,7 +71,7 @@ public void bouncyCastleProviderIsNotLoadedAfterInstantiatingRelyingParty() {

@Test
public void bouncyCastleProviderIsNotLoadedAfterAttemptingToLoadEddsaKey()
throws IOException, CoseException, InvalidKeySpecException {
throws IOException, InvalidKeySpecException {
try {
WebAuthnCodecs.importCosePublicKey(
new AttestationObject(
Expand All @@ -92,7 +91,7 @@ public void bouncyCastleProviderIsNotLoadedAfterAttemptingToLoadEddsaKey()

@Test(expected = NoSuchAlgorithmException.class)
public void doesNotFallBackToBouncyCastleAutomatically()
throws IOException, CoseException, InvalidKeySpecException, NoSuchAlgorithmException {
throws IOException, InvalidKeySpecException, NoSuchAlgorithmException {
for (Provider prov : Security.getProviders()) {
Security.removeProvider(prov.getName());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import COSE.CoseException;
import com.yubico.webauthn.data.AttestationObject;
import com.yubico.webauthn.data.RelyingPartyIdentity;
import java.io.IOException;
Expand Down Expand Up @@ -47,7 +46,7 @@ public void tearDown() {

@Test
public void importRsa()
throws IOException, CoseException, NoSuchAlgorithmException, InvalidKeySpecException {
throws IOException, NoSuchAlgorithmException, InvalidKeySpecException {
PublicKey key =
WebAuthnCodecs.importCosePublicKey(
new AttestationObject(
Expand All @@ -61,7 +60,7 @@ public void importRsa()

@Test
public void importEcdsa()
throws IOException, CoseException, NoSuchAlgorithmException, InvalidKeySpecException {
throws IOException, NoSuchAlgorithmException, InvalidKeySpecException {
PublicKey key =
WebAuthnCodecs.importCosePublicKey(
new AttestationObject(
Expand All @@ -75,7 +74,7 @@ public void importEcdsa()

@Test
public void importEddsa()
throws IOException, CoseException, NoSuchAlgorithmException, InvalidKeySpecException {
throws IOException, NoSuchAlgorithmException, InvalidKeySpecException {
PublicKey key =
WebAuthnCodecs.importCosePublicKey(
new AttestationObject(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ dependencies {
testImplementation("junit:junit:4.12")
testImplementation("org.mockito:mockito-core:[2.27.0,3)")

// Runtime-only internal dependency of webauthn-server-core
testImplementation("com.augustcellars.cose:cose-java:[1.0.0,2)")

// Transitive dependencies from coreTestOutput
testImplementation("org.scala-lang:scala-library:[2.13.1,3)")
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import static org.junit.Assert.assertTrue;

import COSE.CoseException;
import com.yubico.webauthn.data.AttestationObject;
import com.yubico.webauthn.data.RelyingPartyIdentity;
import java.io.IOException;
Expand Down Expand Up @@ -51,7 +50,7 @@ public void bouncyCastleProviderIsNotLoadedAfterInstantiatingRelyingParty() {

@Test
public void bouncyCastleProviderIsNotLoadedAfterAttemptingToLoadEddsaKey()
throws IOException, CoseException, InvalidKeySpecException {
throws IOException, InvalidKeySpecException {
try {
WebAuthnCodecs.importCosePublicKey(
new AttestationObject(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import static org.junit.Assert.assertEquals;

import COSE.CoseException;
import com.yubico.webauthn.data.AttestationObject;
import com.yubico.webauthn.data.RelyingPartyIdentity;
import java.io.IOException;
Expand Down Expand Up @@ -45,7 +44,7 @@ public void tearDown() {

@Test
public void importRsa()
throws IOException, CoseException, NoSuchAlgorithmException, InvalidKeySpecException {
throws IOException, NoSuchAlgorithmException, InvalidKeySpecException {
PublicKey key =
WebAuthnCodecs.importCosePublicKey(
new AttestationObject(
Expand All @@ -59,7 +58,7 @@ public void importRsa()

@Test
public void importEcdsa()
throws IOException, CoseException, NoSuchAlgorithmException, InvalidKeySpecException {
throws IOException, NoSuchAlgorithmException, InvalidKeySpecException {
PublicKey key =
WebAuthnCodecs.importCosePublicKey(
new AttestationObject(
Expand Down
1 change: 0 additions & 1 deletion webauthn-server-core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ dependencies {
api(platform(rootProject))

implementation(project(":yubico-util"))
implementation("com.augustcellars.cose:cose-java")
implementation("com.fasterxml.jackson.core:jackson-databind")
implementation("com.google.guava:guava")
implementation("com.upokecenter:cbor")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

package com.yubico.webauthn;

import COSE.CoseException;
import com.yubico.webauthn.data.AttestationObject;
import com.yubico.webauthn.data.AttestationType;
import com.yubico.webauthn.data.ByteArray;
Expand All @@ -34,7 +33,7 @@
interface AttestationStatementVerifier {

AttestationType getAttestationType(AttestationObject attestation)
throws IOException, CoseException, CertificateException;
throws IOException, CertificateException;

boolean verifyAttestationSignature(
AttestationObject attestationObject, ByteArray clientDataJsonHash);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

import static com.yubico.webauthn.Crypto.isP256;

import COSE.CoseException;
import com.fasterxml.jackson.databind.JsonNode;
import com.yubico.internal.util.ExceptionUtil;
import com.yubico.webauthn.data.AttestationObject;
Expand Down Expand Up @@ -76,7 +75,7 @@ private static boolean validSelfSignature(X509Certificate cert) {
}

private static ByteArray getRawUserPublicKey(AttestationObject attestationObject)
throws IOException, CoseException {
throws IOException {
final ByteArray pubkeyCose =
attestationObject
.getAuthenticatorData()
Expand All @@ -102,7 +101,7 @@ private static ByteArray getRawUserPublicKey(AttestationObject attestationObject

@Override
public AttestationType getAttestationType(AttestationObject attestationObject)
throws CoseException, IOException, CertificateException {
throws IOException, CertificateException {
X509Certificate attestationCertificate = getAttestationCertificate(attestationObject);

if (attestationCertificate.getPublicKey() instanceof ECPublicKey
Expand Down Expand Up @@ -153,7 +152,7 @@ && isP256(((ECPublicKey) attestationCertificate.getPublicKey()).getParams()))) {

try {
userPublicKey = getRawUserPublicKey(attestationObject);
} catch (IOException | CoseException e) {
} catch (IOException e) {
RuntimeException err =
new RuntimeException(
String.format(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

import static com.yubico.internal.util.ExceptionUtil.assertTrue;

import COSE.CoseException;
import com.yubico.internal.util.OptionalUtil;
import com.yubico.webauthn.data.AuthenticatorAssertionResponse;
import com.yubico.webauthn.data.ByteArray;
Expand Down Expand Up @@ -508,7 +507,7 @@ public void validate() {

try {
key = WebAuthnCodecs.importCosePublicKey(cose);
} catch (CoseException | IOException | InvalidKeySpecException e) {
} catch (IOException | InvalidKeySpecException e) {
throw new IllegalArgumentException(
String.format(
"Failed to decode public key: Credential ID: %s COSE: %s",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import static com.yubico.internal.util.ExceptionUtil.assertTrue;
import static com.yubico.internal.util.ExceptionUtil.wrapAndLog;

import COSE.CoseException;
import com.upokecenter.cbor.CBORObject;
import com.yubico.internal.util.CertificateParser;
import com.yubico.internal.util.OptionalUtil;
Expand Down Expand Up @@ -345,7 +344,7 @@ public void validate() {
.collect(Collectors.toList()));
try {
WebAuthnCodecs.importCosePublicKey(publicKeyCose);
} catch (CoseException | IOException | InvalidKeySpecException | NoSuchAlgorithmException e) {
} catch (IOException | InvalidKeySpecException | NoSuchAlgorithmException e) {
throw wrapAndLog(log, "Failed to parse credential public key", e);
}
}
Expand Down Expand Up @@ -431,7 +430,7 @@ public AttestationType attestationType() {
return AttestationType.UNKNOWN;
}
}
} catch (IOException | CoseException | CertificateException e) {
} catch (IOException | CertificateException e) {
throw new IllegalArgumentException("Failed to resolve attestation type.", e);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

package com.yubico.webauthn;

import COSE.CoseException;
import com.fasterxml.jackson.databind.JsonNode;
import com.upokecenter.cbor.CBORObject;
import com.yubico.internal.util.CertificateParser;
Expand Down Expand Up @@ -95,7 +94,7 @@ private boolean verifySelfAttestationSignature(
.getAttestedCredentialData()
.get()
.getCredentialPublicKey());
} catch (IOException | CoseException | InvalidKeySpecException e) {
} catch (IOException | InvalidKeySpecException e) {
throw ExceptionUtil.wrapAndLog(
log,
String.format(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

package com.yubico.webauthn;

import COSE.CoseException;
import com.fasterxml.jackson.annotation.JsonAlias;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnore;
Expand Down Expand Up @@ -99,7 +98,7 @@ public final class RegisteredCredential {
@NonNull
@JsonIgnore
public PublicKey getParsedPublicKey()
throws InvalidKeySpecException, NoSuchAlgorithmException, CoseException, IOException {
throws InvalidKeySpecException, NoSuchAlgorithmException, IOException {
return WebAuthnCodecs.importCosePublicKey(getPublicKeyCose());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

package com.yubico.webauthn;

import COSE.CoseException;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
Expand Down Expand Up @@ -299,7 +298,7 @@ public ByteArray getPublicKeyCose() {
@NonNull
@JsonIgnore
public PublicKey getParsedPublicKey()
throws InvalidKeySpecException, NoSuchAlgorithmException, CoseException, IOException {
throws InvalidKeySpecException, NoSuchAlgorithmException, IOException {
return WebAuthnCodecs.importCosePublicKey(getPublicKeyCose());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

package com.yubico.webauthn;

import COSE.CoseException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.upokecenter.cbor.CBORObject;
Expand Down Expand Up @@ -178,7 +177,7 @@ public boolean verifyAttestationSignature(
// is identical to the credentialPublicKey in the attestedCredentialData in authenticatorData.
try {
verifyPublicKeysMatch(attestationObject, pubArea);
} catch (CoseException | IOException | InvalidKeySpecException | NoSuchAlgorithmException e) {
} catch (IOException | InvalidKeySpecException | NoSuchAlgorithmException e) {
throw new RuntimeException(
"Failed to verify that public key in TPM attestation matches public key in authData.", e);
}
Expand Down Expand Up @@ -267,7 +266,7 @@ private void validateCertInfo(
}

private void verifyPublicKeysMatch(AttestationObject attestationObject, TpmtPublic pubArea)
throws CoseException, IOException, InvalidKeySpecException, NoSuchAlgorithmException {
throws IOException, InvalidKeySpecException, NoSuchAlgorithmException {
final PublicKey credentialPubKey =
WebAuthnCodecs.importCosePublicKey(
attestationObject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

package com.yubico.webauthn;

import COSE.CoseException;
import com.google.common.primitives.Bytes;
import com.upokecenter.cbor.CBORObject;
import com.yubico.webauthn.data.ByteArray;
Expand Down Expand Up @@ -133,7 +132,7 @@ static ByteArray rawEcKeyToCose(ByteArray key) {
}

static PublicKey importCosePublicKey(ByteArray key)
throws CoseException, IOException, InvalidKeySpecException, NoSuchAlgorithmException {
throws IOException, InvalidKeySpecException, NoSuchAlgorithmException {
CBORObject cose = CBORObject.DecodeFromBytes(key.getBytes());
final int kty = cose.get(CBORObject.FromObject(1)).AsInt32();
switch (kty) {
Expand Down

0 comments on commit e1500d8

Please sign in to comment.