Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(612)

Unified Diff: net/cert/x509_certificate_unittest.cc

Issue 462543002: Certificate Transparency: Code for unpacking EV cert hashes whitelist (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebasing on master Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: net/cert/x509_certificate_unittest.cc
diff --git a/net/cert/x509_certificate_unittest.cc b/net/cert/x509_certificate_unittest.cc
index fb16ed5cd90ea96fe0648949275c377a6324db3e..f52758ab73ecfa9b8ab75254d8f8511e20c7e0a8 100644
--- a/net/cert/x509_certificate_unittest.cc
+++ b/net/cert/x509_certificate_unittest.cc
@@ -323,6 +323,24 @@ TEST(X509CertificateTest, SerialNumbers) {
paypal_null_serial, sizeof(paypal_null_serial)) == 0);
}
+TEST(X509CertificateTest, SHA256FingerprintsCorrectly) {
+ scoped_refptr<X509Certificate> google_cert(
+ X509Certificate::CreateFromBytes(
+ reinterpret_cast<const char*>(google_der), sizeof(google_der)));
+
+ static const uint8 google_sha256_fingerprint[32] = {
+ 0x21, 0xaf, 0x58, 0x74, 0xea, 0x6b, 0xad, 0xbd, 0xe4, 0xb3, 0xb1, 0xaa,
+ 0x53, 0x32, 0x80, 0x8f, 0xbf, 0x8a, 0x24, 0x7d, 0x98, 0xec, 0x7f, 0x77,
+ 0x49, 0x38, 0x42, 0x81, 0x26, 0x7f, 0xed, 0x38
+ };
+
+ SHA256HashValue fingerprint = X509Certificate::CalculateFingerprint256(
+ google_cert->os_cert_handle());
+
+ for (size_t i = 0; i < 32; ++i)
+ EXPECT_EQ(google_sha256_fingerprint[i], fingerprint.data[i]);
+}
+
TEST(X509CertificateTest, CAFingerprints) {
base::FilePath certs_dir = GetTestCertsDirectory();

Powered by Google App Engine
This is Rietveld 408576698