Skip to content

Commit

Permalink
Merge branch 'attestation-type-attestation-ca'
Browse files Browse the repository at this point in the history
  • Loading branch information
emlun committed Apr 10, 2019
2 parents 589fd2a + fbdaa51 commit 229507f
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -487,11 +487,13 @@ public Optional<AttestationTrustResolver> trustResolver() {
case SELF_ATTESTATION:
return Optional.empty();

case ATTESTATION_CA:
case BASIC:
switch (attestation.getFormat()) {
case "android-safetynet":
case "fido-u2f":
case "packed":
case "tpm":
return metadataService.map(KnownX509TrustAnchorsTrustResolver::new);
default:
throw new UnsupportedOperationException(String.format(
Expand Down Expand Up @@ -529,6 +531,7 @@ public void validate() {
assure(allowUntrustedAttestation, "Self attestation is not allowed.");
break;

case ATTESTATION_CA:
case BASIC:
assure(allowUntrustedAttestation || attestationTrusted(), "Failed to derive trust for attestation key.");
break;
Expand All @@ -553,6 +556,7 @@ public boolean attestationTrusted() {
case NONE:
return false;

case ATTESTATION_CA:
case BASIC:
return attestationMetadata().filter(Attestation::isTrusted).isPresent();
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ object RegistrationTestData {
) { override def regenerate() = TestAuthenticator.createSelfAttestedCredential(attestationStatementFormat = "packed", alg = Some(COSEAlgorithmIdentifier.RS256)) }
}
object Tpm {
val PrivacyCa: RegistrationTestData = Packed.SelfAttestation.editAttestationObject("fmt", "tpm")
val PrivacyCa: RegistrationTestData = Packed.BasicAttestation.editAttestationObject("fmt", "tpm")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1687,19 +1687,19 @@ class RelyingPartyRegistrationSpec extends FunSpec with Matchers with GeneratorD

describe("The default RelyingParty settings") {

it("accept registrations with no attestation.") {
val rp = RelyingParty.builder()
.identity(RelyingPartyIdentity.builder().id("localhost").name("Test party").build())
.credentialRepository(emptyCredentialRepository)
.build()

val request = rp.startRegistration(StartRegistrationOptions.builder()
.user(UserIdentity.builder().name("test").displayName("Test Testsson").id(new ByteArray(Array())).build())
.build()
).toBuilder()
.challenge(RegistrationTestData.NoneAttestation.Default.clientData.getChallenge)
.build()
val rp = RelyingParty.builder()
.identity(RelyingPartyIdentity.builder().id("localhost").name("Test party").build())
.credentialRepository(emptyCredentialRepository)
.build()

val request = rp.startRegistration(StartRegistrationOptions.builder()
.user(UserIdentity.builder().name("test").displayName("Test Testsson").id(new ByteArray(Array())).build())
.build()
).toBuilder()
.challenge(RegistrationTestData.NoneAttestation.Default.clientData.getChallenge)
.build()

it("accept registrations with no attestation.") {
val result = rp.finishRegistration(FinishRegistrationOptions.builder()
.request(request)
.response(RegistrationTestData.NoneAttestation.Default.response)
Expand All @@ -1710,6 +1710,17 @@ class RelyingPartyRegistrationSpec extends FunSpec with Matchers with GeneratorD
result.getKeyId.getId should equal (RegistrationTestData.NoneAttestation.Default.response.getId)
}

it("accept TPM attestations but reports they're untrusted.") {
val result = rp.finishRegistration(FinishRegistrationOptions.builder()
.request(request)
.response(RegistrationTestData.Tpm.PrivacyCa.response)
.build()
)

result.isAttestationTrusted should be (false)
result.getKeyId.getId should equal (RegistrationTestData.Tpm.PrivacyCa.response.getId)
}

}

}
Expand Down

0 comments on commit 229507f

Please sign in to comment.