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

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: 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
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 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 SHA1HashValue X509Certificate::CalculateFingerprint(OSCertHandle cert) { 287 SHA1HashValue X509Certificate::CalculateFingerprint(OSCertHandle cert) {
288 SHA1HashValue sha1; 288 SHA1HashValue sha1;
289 unsigned int sha1_size = static_cast<unsigned int>(sizeof(sha1.data)); 289 unsigned int sha1_size = static_cast<unsigned int>(sizeof(sha1.data));
290 int ret = X509_digest(cert, EVP_sha1(), sha1.data, &sha1_size); 290 int ret = X509_digest(cert, EVP_sha1(), sha1.data, &sha1_size);
291 CHECK(ret); 291 CHECK(ret);
292 CHECK_EQ(sha1_size, sizeof(sha1.data)); 292 CHECK_EQ(sha1_size, sizeof(sha1.data));
293 return sha1; 293 return sha1;
294 } 294 }
295 295
296 // static 296 // static
297 SHA256HashValue X509Certificate::CalculateFingerprint256(OSCertHandle cert) {
298 SHA256HashValue sha256;
299 unsigned int sha256_size = static_cast<unsigned int>(sizeof(sha256.data));
300 int ret = X509_digest(cert, EVP_sha256(), sha256.data, &sha256_size);
301 CHECK(ret);
302 CHECK_EQ(sha256_size, sizeof(sha256.data));
303 return sha256;
304 }
305
306 // static
297 SHA1HashValue X509Certificate::CalculateCAFingerprint( 307 SHA1HashValue X509Certificate::CalculateCAFingerprint(
298 const OSCertHandles& intermediates) { 308 const OSCertHandles& intermediates) {
299 SHA1HashValue sha1; 309 SHA1HashValue sha1;
300 memset(sha1.data, 0, sizeof(sha1.data)); 310 memset(sha1.data, 0, sizeof(sha1.data));
301 311
302 SHA_CTX sha1_ctx; 312 SHA_CTX sha1_ctx;
303 SHA1_Init(&sha1_ctx); 313 SHA1_Init(&sha1_ctx);
304 DERCache der_cache; 314 DERCache der_cache;
305 for (size_t i = 0; i < intermediates.size(); ++i) { 315 for (size_t i = 0; i < intermediates.size(); ++i) {
306 if (!GetDERAndCacheIfNeeded(intermediates[i], &der_cache)) 316 if (!GetDERAndCacheIfNeeded(intermediates[i], &der_cache))
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 if (X509_NAME_cmp(issuer, cert_names[n]) == 0) { 511 if (X509_NAME_cmp(issuer, cert_names[n]) == 0) {
502 return true; 512 return true;
503 } 513 }
504 } 514 }
505 } 515 }
506 516
507 return false; 517 return false;
508 } 518 }
509 519
510 } // namespace net 520 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698