Search in sources :

Example 11 with AttestationCertificatePath

use of com.webauthn4j.data.attestation.statement.AttestationCertificatePath in project webauthn4j by webauthn4j.

the class AttestationCertificatePathConverterTest method test.

@Test
void test() {
    AttestationCertificatePath attestationCertificatePath = new AttestationCertificatePath(Collections.singletonList(TestAttestationUtil.load2tierTestAuthenticatorAttestationCertificate()));
    byte[] cbor = cborConverter.writeValueAsBytes(attestationCertificatePath);
    AttestationCertificatePath restored = cborConverter.readValue(cbor, AttestationCertificatePath.class);
    assertThat(restored).isEqualTo(attestationCertificatePath);
}
Also used : AttestationCertificatePath(com.webauthn4j.data.attestation.statement.AttestationCertificatePath) Test(org.junit.jupiter.api.Test)

Example 12 with AttestationCertificatePath

use of com.webauthn4j.data.attestation.statement.AttestationCertificatePath in project webauthn4j by webauthn4j.

the class AndroidKeyAttestationStatementValidator method getPublicKey.

@NonNull
private PublicKey getPublicKey(@NonNull AndroidKeyAttestationStatement attestationStatement) {
    AttestationCertificatePath x5c = attestationStatement.getX5c();
    Certificate cert = x5c.getEndEntityAttestationCertificate().getCertificate();
    return cert.getPublicKey();
}
Also used : AttestationCertificatePath(com.webauthn4j.data.attestation.statement.AttestationCertificatePath) Certificate(java.security.cert.Certificate) NonNull(org.checkerframework.checker.nullness.qual.NonNull)

Example 13 with AttestationCertificatePath

use of com.webauthn4j.data.attestation.statement.AttestationCertificatePath in project webauthn4j by webauthn4j.

the class AppleAppAttestAttestationStatementTest method constructor_test.

@Test
void constructor_test() {
    AttestationCertificatePath attestationCertificatePath = new AttestationCertificatePath();
    assertAll(() -> assertThatThrownBy(() -> new AppleAppAttestAttestationStatement(null, new byte[32])).isInstanceOf(IllegalArgumentException.class), () -> assertThatThrownBy(() -> new AppleAppAttestAttestationStatement(attestationCertificatePath, null)).isInstanceOf(IllegalArgumentException.class));
}
Also used : AttestationCertificatePath(com.webauthn4j.data.attestation.statement.AttestationCertificatePath) Test(org.junit.jupiter.api.Test)

Example 14 with AttestationCertificatePath

use of com.webauthn4j.data.attestation.statement.AttestationCertificatePath in project webauthn4j by webauthn4j.

the class AppleAppAttestAttestationStatementValidatorTest method validateX5c_empty_AttestationCertificatePath_test.

@Test
void validateX5c_empty_AttestationCertificatePath_test() {
    final AppleAppAttestAttestationStatement appleAppAttestAttestationStatement = new AppleAppAttestAttestationStatement(new AttestationCertificatePath(), new byte[32]);
    assertThatThrownBy(() -> target.validateX5c(appleAppAttestAttestationStatement)).isInstanceOf(BadAttestationStatementException.class);
}
Also used : AttestationCertificatePath(com.webauthn4j.data.attestation.statement.AttestationCertificatePath) AppleAppAttestAttestationStatement(com.webauthn4j.appattest.data.attestation.statement.AppleAppAttestAttestationStatement) Test(org.junit.jupiter.api.Test)

Example 15 with AttestationCertificatePath

use of com.webauthn4j.data.attestation.statement.AttestationCertificatePath in project webauthn4j by webauthn4j.

the class AndroidKeyAuthenticator method createAttestationStatement.

@Override
public AttestationStatement createAttestationStatement(AttestationStatementRequest attestationStatementRequest, RegistrationEmulationOption registrationEmulationOption) {
    byte[] signature;
    if (registrationEmulationOption.isSignatureOverrideEnabled()) {
        signature = registrationEmulationOption.getSignature();
    } else {
        signature = TestDataUtil.calculateSignature(attestationStatementRequest.getCredentialKeyPair().getPrivate(), attestationStatementRequest.getSignedData());
    }
    AttestationOption attestationOption = registrationEmulationOption.getAttestationOption() == null ? new AndroidKeyAttestationOption() : registrationEmulationOption.getAttestationOption();
    X509Certificate attestationCertificate = getAttestationCertificate(attestationStatementRequest, attestationOption);
    AttestationCertificatePath attestationCertificates = new AttestationCertificatePath(attestationCertificate, this.getCACertificatePath());
    return new AndroidKeyAttestationStatement(COSEAlgorithmIdentifier.ES256, signature, attestationCertificates);
}
Also used : AndroidKeyAttestationStatement(com.webauthn4j.data.attestation.statement.AndroidKeyAttestationStatement) AttestationCertificatePath(com.webauthn4j.data.attestation.statement.AttestationCertificatePath) X509Certificate(java.security.cert.X509Certificate)

Aggregations

AttestationCertificatePath (com.webauthn4j.data.attestation.statement.AttestationCertificatePath)17 Test (org.junit.jupiter.api.Test)12 AndroidKeyAttestationStatement (com.webauthn4j.data.attestation.statement.AndroidKeyAttestationStatement)3 FIDOU2FAttestationStatement (com.webauthn4j.data.attestation.statement.FIDOU2FAttestationStatement)3 PackedAttestationStatement (com.webauthn4j.data.attestation.statement.PackedAttestationStatement)3 X509Certificate (java.security.cert.X509Certificate)3 AppleAppAttestAttestationStatement (com.webauthn4j.appattest.data.attestation.statement.AppleAppAttestAttestationStatement)2 AttestationObject (com.webauthn4j.data.attestation.AttestationObject)2 CertificateBaseAttestationStatement (com.webauthn4j.data.attestation.statement.CertificateBaseAttestationStatement)2 RegistrationExtensionAuthenticatorOutput (com.webauthn4j.data.extension.authenticator.RegistrationExtensionAuthenticatorOutput)2 TrustAnchor (java.security.cert.TrustAnchor)2 AAGUID (com.webauthn4j.data.attestation.authenticator.AAGUID)1 AttestedCredentialData (com.webauthn4j.data.attestation.authenticator.AttestedCredentialData)1 AuthenticatorData (com.webauthn4j.data.attestation.authenticator.AuthenticatorData)1 EC2COSEKey (com.webauthn4j.data.attestation.authenticator.EC2COSEKey)1 AttestationStatement (com.webauthn4j.data.attestation.statement.AttestationStatement)1 CredentialCreationResponse (com.webauthn4j.test.authenticator.CredentialCreationResponse)1 UnexpectedCheckedException (com.webauthn4j.util.exception.UnexpectedCheckedException)1 RegistrationObject (com.webauthn4j.validator.RegistrationObject)1 BigInteger (java.math.BigInteger)1