Skip to content
This repository has been archived by the owner on Nov 9, 2023. It is now read-only.

Adds most logic needed for validating cert chain #101

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

leshi
Copy link
Contributor

@leshi leshi commented Feb 12, 2016

Notes:

  • This is completely backward compatible to what U2F does now.
  • The registration request can now have more than one X.509
    certificate. The chain must be DER encoded (basically, the X.509
    certs are DER encoded and then concatenated one after anoter.
  • As noted in many comments, the leaf is in the 0th element of the
    chain, followed by intermediary certs.
  • The current code does not yet ship with the final Android attestation
    root CA, so all Android attestations will have "chain validated:
    false"

} catch (CertificateEncodingException e) {
throw new RuntimeException();
}
this.attestationCert = X509Util.encodeCertArray(tokenData.getAttestationCertificateChain());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: this is no longer just a cert. Could you use a longer name, e.g. attestationCertChain? attestationCertOrCertAndChain? Ick.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Notes:
 * This is completely backward compatible to what U2F does now.
 * The registration request can now have more than one X.509
   certificate.  The chain must be DER encoded (basically, the X.509
   certs are DER encoded and then concatenated one after anoter.
 * As noted in many comments, the leaf is in the 0th element of the
   chain, followed by intermediary certs.
 * The current code does not yet ship with the final Android attestation
   root CA, so all Android attestations will have "chain validated:
   false"
@leshi
Copy link
Contributor Author

leshi commented Mar 3, 2016

Ping

import com.google.u2f.U2FException;
import com.google.u2f.key.messages.AuthenticateRequest;
import com.google.u2f.key.messages.AuthenticateResponse;
import com.google.u2f.key.messages.RegisterRequest;
import com.google.u2f.key.messages.RegisterResponse;
import com.google.u2f.tools.X509Util;

import org.bouncycastle.util.Arrays;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't java.util.Arrays.copyOfRange sufficient? It's in jre7, at least.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, removed.

}

// Now attempt to verify up to one of the roots
boolean validated = true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This default value, combined with the for loop that will not execute for an empty caCerts list, will allow the caller to get validated = true when the caCerts list is empty. Perhaps that's what you mean, but it certainly looks odd.

@cpiper cpiper force-pushed the master branch 4 times, most recently from 8590f57 to 14205c3 Compare September 18, 2018 18:47
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants