use of com.webauthn4j.validator.exception.BadAttestationStatementException in project webauthn4j by webauthn4j.
the class DCAttestationDataValidator method validateKeyId.
private void validateKeyId(@NonNull CoreRegistrationData registrationData) {
DCAttestationData dcAttestationData = (DCAttestationData) registrationData;
byte[] keyId = dcAttestationData.getKeyId();
// noinspection ConstantConditions as null check is already done in caller
byte[] credentialId = registrationData.getAttestationObject().getAuthenticatorData().getAttestedCredentialData().getCredentialId();
// there is no need to prevent timing attack and it is OK to use `Arrays.equals` instead of `MessageDigest.isEqual` here.
if (!Arrays.equals(keyId, credentialId)) {
throw new BadAttestationStatementException("key identifier doesn't match credentialId.");
}
}
use of com.webauthn4j.validator.exception.BadAttestationStatementException in project webauthn4j by webauthn4j.
the class AppleAppAttestAttestationStatementValidator method extractNonce.
byte[] extractNonce(X509Certificate attestationCertificate) {
byte[] attestationExtensionBytes = attestationCertificate.getExtensionValue(APPLE_CRED_CERT_EXTENSION_OID);
if (attestationExtensionBytes == null) {
throw new BadAttestationStatementException("Apple X.509 extension not found");
}
Asn1OctetString envelope = new Asn1OctetString();
try {
envelope.decode(attestationExtensionBytes);
Asn1Container container = (Asn1Container) Asn1Parser.parse(ByteBuffer.wrap(envelope.getValue()));
Asn1OctetString subEnvelop = new Asn1OctetString();
subEnvelop.decode(container.getChildren().get(0));
return subEnvelop.getValue();
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
Aggregations