diff options
author | Shawn Willden <swillden@google.com> | 2020-09-17 07:16:42 -0600 |
---|---|---|
committer | Shawn Willden <swillden@google.com> | 2020-09-17 07:16:42 -0600 |
commit | 3cb73bde9aaa62119b82f509e13dbaaa726f0af1 (patch) | |
tree | b8c0320b662507c4489918d20c031ee6b991563f | |
parent | 47172a0b2e41a2d48154fb8a62c1a86fef5ba58a (diff) | |
download | android-key-attestation-3cb73bde9aaa62119b82f509e13dbaaa726f0af1.tar.gz |
Correct root certificate check.
The test that the root certificate matches the Google root should
check that the public keys match, rather than doing a bytewise
comparison of the entire certificate contents. This allows the
certificate to be updated (which has been done once) without breaking
the comparison, as long as the public key remains the same.
Note that it's safe to check only the public key because the chain of
signatures has already been checked.
-rw-r--r-- | server/src/main/java/com/android/example/KeyAttestationExample.java | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/server/src/main/java/com/android/example/KeyAttestationExample.java b/server/src/main/java/com/android/example/KeyAttestationExample.java index a0a52b4..a503dc7 100644 --- a/server/src/main/java/com/android/example/KeyAttestationExample.java +++ b/server/src/main/java/com/android/example/KeyAttestationExample.java @@ -241,7 +241,8 @@ public class KeyAttestationExample { .generateCertificate( new ByteArrayInputStream(GOOGLE_ROOT_CERTIFICATE.getBytes(UTF_8))); if (Arrays.equals( - secureRoot.getTBSCertificate(), certs[certs.length - 1].getTBSCertificate())) { + secureRoot.getPublicKey().getEncoded(), + certs[certs.length - 1].getPublicKey().getEncoded())) { System.out.println( "The root certificate is correct, so this attestation is trustworthy, as long as none of" + " the certificates in the chain have been revoked. A production-level system" |