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

Side by Side 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: Addressing comments + adding method for determining presence of valid EV whitelist. Created 6 years, 3 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 unified diff | Download patch
« no previous file with comments | « net/cert/x509_certificate_openssl.cc ('k') | net/cert/x509_certificate_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/cert/x509_certificate.h" 5 #include "net/cert/x509_certificate.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/pickle.h" 10 #include "base/pickle.h"
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 reinterpret_cast<const char*>(paypal_null_der), 316 reinterpret_cast<const char*>(paypal_null_der),
317 sizeof(paypal_null_der))); 317 sizeof(paypal_null_der)));
318 318
319 static const uint8 paypal_null_serial[3] = {0x00, 0xf0, 0x9b}; 319 static const uint8 paypal_null_serial[3] = {0x00, 0xf0, 0x9b};
320 ASSERT_EQ(sizeof(paypal_null_serial), 320 ASSERT_EQ(sizeof(paypal_null_serial),
321 paypal_null_cert->serial_number().size()); 321 paypal_null_cert->serial_number().size());
322 EXPECT_TRUE(memcmp(paypal_null_cert->serial_number().data(), 322 EXPECT_TRUE(memcmp(paypal_null_cert->serial_number().data(),
323 paypal_null_serial, sizeof(paypal_null_serial)) == 0); 323 paypal_null_serial, sizeof(paypal_null_serial)) == 0);
324 } 324 }
325 325
326 TEST(X509CertificateTest, SHA256FingerprintsCorrectly) {
327 scoped_refptr<X509Certificate> google_cert(X509Certificate::CreateFromBytes(
328 reinterpret_cast<const char*>(google_der), sizeof(google_der)));
329
330 static const uint8 google_sha256_fingerprint[32] = {
331 0x21, 0xaf, 0x58, 0x74, 0xea, 0x6b, 0xad, 0xbd, 0xe4, 0xb3, 0xb1,
332 0xaa, 0x53, 0x32, 0x80, 0x8f, 0xbf, 0x8a, 0x24, 0x7d, 0x98, 0xec,
333 0x7f, 0x77, 0x49, 0x38, 0x42, 0x81, 0x26, 0x7f, 0xed, 0x38};
334
335 SHA256HashValue fingerprint =
336 X509Certificate::CalculateFingerprint256(google_cert->os_cert_handle());
337
338 for (size_t i = 0; i < 32; ++i)
339 EXPECT_EQ(google_sha256_fingerprint[i], fingerprint.data[i]);
340 }
341
326 TEST(X509CertificateTest, CAFingerprints) { 342 TEST(X509CertificateTest, CAFingerprints) {
327 base::FilePath certs_dir = GetTestCertsDirectory(); 343 base::FilePath certs_dir = GetTestCertsDirectory();
328 344
329 scoped_refptr<X509Certificate> server_cert = 345 scoped_refptr<X509Certificate> server_cert =
330 ImportCertFromFile(certs_dir, "salesforce_com_test.pem"); 346 ImportCertFromFile(certs_dir, "salesforce_com_test.pem");
331 ASSERT_NE(static_cast<X509Certificate*>(NULL), server_cert.get()); 347 ASSERT_NE(static_cast<X509Certificate*>(NULL), server_cert.get());
332 348
333 scoped_refptr<X509Certificate> intermediate_cert1 = 349 scoped_refptr<X509Certificate> intermediate_cert1 =
334 ImportCertFromFile(certs_dir, "verisign_intermediate_ca_2011.pem"); 350 ImportCertFromFile(certs_dir, "verisign_intermediate_ca_2011.pem");
335 ASSERT_NE(static_cast<X509Certificate*>(NULL), intermediate_cert1.get()); 351 ASSERT_NE(static_cast<X509Certificate*>(NULL), intermediate_cert1.get());
(...skipping 931 matching lines...) Expand 10 before | Expand all | Expand 10 after
1267 &actual_type); 1283 &actual_type);
1268 1284
1269 EXPECT_EQ(data.expected_bits, actual_bits); 1285 EXPECT_EQ(data.expected_bits, actual_bits);
1270 EXPECT_EQ(data.expected_type, actual_type); 1286 EXPECT_EQ(data.expected_type, actual_type);
1271 } 1287 }
1272 1288
1273 INSTANTIATE_TEST_CASE_P(, X509CertificatePublicKeyInfoTest, 1289 INSTANTIATE_TEST_CASE_P(, X509CertificatePublicKeyInfoTest,
1274 testing::ValuesIn(kPublicKeyInfoTestData)); 1290 testing::ValuesIn(kPublicKeyInfoTestData));
1275 1291
1276 } // namespace net 1292 } // namespace net
OLDNEW
« no previous file with comments | « net/cert/x509_certificate_openssl.cc ('k') | net/cert/x509_certificate_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698