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

Side by Side Diff: net/cert/x509_certificate_openssl.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 unified diff | Download patch
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 <openssl/asn1.h> 7 #include <openssl/asn1.h>
8 #include <openssl/bytestring.h> 8 #include <openssl/bytestring.h>
9 #include <openssl/crypto.h> 9 #include <openssl/crypto.h>
10 #include <openssl/obj_mac.h> 10 #include <openssl/obj_mac.h>
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 SHA1HashValue X509Certificate::CalculateFingerprint(OSCertHandle cert) { 293 SHA1HashValue X509Certificate::CalculateFingerprint(OSCertHandle cert) {
294 SHA1HashValue sha1; 294 SHA1HashValue sha1;
295 unsigned int sha1_size = static_cast<unsigned int>(sizeof(sha1.data)); 295 unsigned int sha1_size = static_cast<unsigned int>(sizeof(sha1.data));
296 int ret = X509_digest(cert, EVP_sha1(), sha1.data, &sha1_size); 296 int ret = X509_digest(cert, EVP_sha1(), sha1.data, &sha1_size);
297 CHECK(ret); 297 CHECK(ret);
298 CHECK_EQ(sha1_size, sizeof(sha1.data)); 298 CHECK_EQ(sha1_size, sizeof(sha1.data));
299 return sha1; 299 return sha1;
300 } 300 }
301 301
302 // static 302 // static
303 SHA256HashValue X509Certificate::CalculateFingerprint256(OSCertHandle cert) {
304 SHA256HashValue sha256;
305 unsigned int sha256_size = static_cast<unsigned int>(sizeof(sha256.data));
306 int ret = X509_digest(cert, EVP_sha256(), sha256.data, &sha256_size);
307 CHECK(ret);
308 CHECK_EQ(sha256_size, sizeof(sha256.data));
309 return sha256;
310 }
311
312 // static
303 SHA1HashValue X509Certificate::CalculateCAFingerprint( 313 SHA1HashValue X509Certificate::CalculateCAFingerprint(
304 const OSCertHandles& intermediates) { 314 const OSCertHandles& intermediates) {
305 SHA1HashValue sha1; 315 SHA1HashValue sha1;
306 memset(sha1.data, 0, sizeof(sha1.data)); 316 memset(sha1.data, 0, sizeof(sha1.data));
307 317
308 SHA_CTX sha1_ctx; 318 SHA_CTX sha1_ctx;
309 SHA1_Init(&sha1_ctx); 319 SHA1_Init(&sha1_ctx);
310 DERCache der_cache; 320 DERCache der_cache;
311 for (size_t i = 0; i < intermediates.size(); ++i) { 321 for (size_t i = 0; i < intermediates.size(); ++i) {
312 if (!GetDERAndCacheIfNeeded(intermediates[i], &der_cache)) 322 if (!GetDERAndCacheIfNeeded(intermediates[i], &der_cache))
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 if (X509_NAME_cmp(issuer, cert_names[n]) == 0) { 517 if (X509_NAME_cmp(issuer, cert_names[n]) == 0) {
508 return true; 518 return true;
509 } 519 }
510 } 520 }
511 } 521 }
512 522
513 return false; 523 return false;
514 } 524 }
515 525
516 } // namespace net 526 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698