Skip to content

Commit 4c758f4

Browse files
committed
Merge branch 'tpm-attestation' into release-2.1.0
2 parents 20194f1 + 8667912 commit 4c758f4

File tree

17 files changed

+2534
-180
lines changed

17 files changed

+2534
-180
lines changed

NEWS

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ New features:
1717
* Added method `FidoMetadataDownloader.refreshBlob()`.
1818
* Added function `COSEAlgorithmIdentifier.fromPublicKey(ByteArray)`.
1919
* Added method `AssertionResult.getCredential(): RegisteredCredential`.
20+
* Added support for the `"tpm"` attestation statement format.
21+
* Added support for ES384 and ES512 signature algorithms.
22+
* Added property `policyTreeValidator` to `TrustRootsResult`. If set, the given
23+
predicate function will be used to validate the certificate policy tree after
24+
successful attestation certificate path validation. This may be required for
25+
some JCA providers to accept attestation certificates with critical
26+
certificate policy extensions.
2027

2128
Fixes:
2229

webauthn-server-attestation/src/test/scala/com/yubico/fido/metadata/FidoMds3Spec.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ class FidoMds3Spec extends AnyFunSpec with Matchers {
312312
attestationMaker = AttestationMaker.packed(
313313
AttestationSigner.ca(
314314
COSEAlgorithmIdentifier.ES256,
315-
aaguid = aaguidA.asBytes,
315+
aaguid = Some(aaguidA.asBytes),
316316
validFrom = CertValidFrom,
317317
validTo = CertValidTo,
318318
)

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,18 @@ public static boolean verifySignature(
9696

9797
public static ByteArray sha256(ByteArray bytes) {
9898
//noinspection UnstableApiUsage
99+
// TODO remove noinspection
99100
return new ByteArray(Hashing.sha256().hashBytes(bytes.getBytes()).asBytes());
100101
}
101102

103+
public static ByteArray sha384(ByteArray bytes) {
104+
return new ByteArray(Hashing.sha384().hashBytes(bytes.getBytes()).asBytes());
105+
}
106+
107+
public static ByteArray sha512(ByteArray bytes) {
108+
return new ByteArray(Hashing.sha512().hashBytes(bytes.getBytes()).asBytes());
109+
}
110+
102111
public static ByteArray sha256(String str) {
103112
return sha256(new ByteArray(str.getBytes(StandardCharsets.UTF_8)));
104113
}

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

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
import java.security.cert.CertPathValidatorException;
5151
import java.security.cert.CertificateException;
5252
import java.security.cert.CertificateFactory;
53+
import java.security.cert.PKIXCertPathValidatorResult;
5354
import java.security.cert.PKIXParameters;
5455
import java.security.cert.TrustAnchor;
5556
import java.security.cert.X509Certificate;
@@ -373,6 +374,8 @@ public Optional<AttestationStatementVerifier> attestationStatementVerifier() {
373374
return Optional.of(new AndroidSafetynetAttestationStatementVerifier());
374375
case "apple":
375376
return Optional.of(new AppleAttestationStatementVerifier());
377+
case "tpm":
378+
return Optional.of(new TpmAttestationStatementVerifier());
376379
default:
377380
return Optional.empty();
378381
}
@@ -411,9 +414,6 @@ public AttestationType attestationType() {
411414
case "android-key":
412415
// TODO delete this once android-key attestation verification is implemented
413416
return AttestationType.BASIC;
414-
case "tpm":
415-
// TODO delete this once tpm attestation verification is implemented
416-
return AttestationType.ATTESTATION_CA;
417417
default:
418418
return AttestationType.UNKNOWN;
419419
}
@@ -536,9 +536,26 @@ public boolean attestationTrusted() {
536536
.collect(Collectors.toSet()));
537537
pathParams.setDate(Date.from(clock.instant()));
538538
pathParams.setRevocationEnabled(trustRoots.get().isEnableRevocationChecking());
539+
pathParams.setPolicyQualifiersRejected(
540+
!trustRoots.get().getPolicyTreeValidator().isPresent());
539541
trustRoots.get().getCertStore().ifPresent(pathParams::addCertStore);
540-
cpv.validate(certPath, pathParams);
541-
return true;
542+
final PKIXCertPathValidatorResult result =
543+
(PKIXCertPathValidatorResult) cpv.validate(certPath, pathParams);
544+
return trustRoots
545+
.get()
546+
.getPolicyTreeValidator()
547+
.map(
548+
policyNodePredicate -> {
549+
if (policyNodePredicate.test(result.getPolicyTree())) {
550+
return true;
551+
} else {
552+
log.info(
553+
"Failed to derive trust in attestation statement: Certificate path policy tree does not satisfy policy tree validator. Attestation object: {}",
554+
response.getResponse().getAttestationObject());
555+
return false;
556+
}
557+
})
558+
.orElse(true);
542559
}
543560

544561
} catch (CertPathValidatorException e) {

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,11 +210,13 @@ public class RelyingParty {
210210
* <p>This is a list of acceptable public key algorithms and their parameters, ordered from most
211211
* to least preferred.
212212
*
213-
* <p>The default is the following list:
213+
* <p>The default is the following list, in order:
214214
*
215215
* <ol>
216216
* <li>{@link com.yubico.webauthn.data.PublicKeyCredentialParameters#ES256 ES256}
217217
* <li>{@link com.yubico.webauthn.data.PublicKeyCredentialParameters#EdDSA EdDSA}
218+
* <li>{@link com.yubico.webauthn.data.PublicKeyCredentialParameters#ES256 ES384}
219+
* <li>{@link com.yubico.webauthn.data.PublicKeyCredentialParameters#ES256 ES512}
218220
* <li>{@link com.yubico.webauthn.data.PublicKeyCredentialParameters#RS256 RS256}
219221
* </ol>
220222
*
@@ -228,6 +230,8 @@ public class RelyingParty {
228230
Arrays.asList(
229231
PublicKeyCredentialParameters.ES256,
230232
PublicKeyCredentialParameters.EdDSA,
233+
PublicKeyCredentialParameters.ES384,
234+
PublicKeyCredentialParameters.ES512,
231235
PublicKeyCredentialParameters.RS256));
232236

233237
/**
@@ -417,6 +421,8 @@ private static List<PublicKeyCredentialParameters> filterAvailableAlgorithms(
417421
break;
418422

419423
case ES256:
424+
case ES384:
425+
case ES512:
420426
KeyFactory.getInstance("EC");
421427
break;
422428

0 commit comments

Comments
 (0)