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

Side by Side Diff: net/cert/x509_certificate_openssl.cc

Issue 547603002: Certificate Transparency: Code for unpacking EV cert hashes whitelist (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Avoiding globals in favour of passing the SSLConfigService around Created 6 years, 2 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 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 SHA1HashValue X509Certificate::CalculateFingerprint(OSCertHandle cert) { 223 SHA1HashValue X509Certificate::CalculateFingerprint(OSCertHandle cert) {
224 SHA1HashValue sha1; 224 SHA1HashValue sha1;
225 unsigned int sha1_size = static_cast<unsigned int>(sizeof(sha1.data)); 225 unsigned int sha1_size = static_cast<unsigned int>(sizeof(sha1.data));
226 int ret = X509_digest(cert, EVP_sha1(), sha1.data, &sha1_size); 226 int ret = X509_digest(cert, EVP_sha1(), sha1.data, &sha1_size);
227 CHECK(ret); 227 CHECK(ret);
228 CHECK_EQ(sha1_size, sizeof(sha1.data)); 228 CHECK_EQ(sha1_size, sizeof(sha1.data));
229 return sha1; 229 return sha1;
230 } 230 }
231 231
232 // static 232 // static
233 SHA256HashValue X509Certificate::CalculateFingerprint256(OSCertHandle cert) {
234 SHA256HashValue sha256;
235 unsigned int sha256_size = static_cast<unsigned int>(sizeof(sha256.data));
236 int ret = X509_digest(cert, EVP_sha256(), sha256.data, &sha256_size);
237 CHECK(ret);
238 CHECK_EQ(sha256_size, sizeof(sha256.data));
239 return sha256;
240 }
241
242 // static
233 SHA1HashValue X509Certificate::CalculateCAFingerprint( 243 SHA1HashValue X509Certificate::CalculateCAFingerprint(
234 const OSCertHandles& intermediates) { 244 const OSCertHandles& intermediates) {
235 SHA1HashValue sha1; 245 SHA1HashValue sha1;
236 memset(sha1.data, 0, sizeof(sha1.data)); 246 memset(sha1.data, 0, sizeof(sha1.data));
237 247
238 SHA_CTX sha1_ctx; 248 SHA_CTX sha1_ctx;
239 SHA1_Init(&sha1_ctx); 249 SHA1_Init(&sha1_ctx);
240 base::StringPiece der; 250 base::StringPiece der;
241 for (size_t i = 0; i < intermediates.size(); ++i) { 251 for (size_t i = 0; i < intermediates.size(); ++i) {
242 if (!x509_util::GetDER(intermediates[i], &der)) 252 if (!x509_util::GetDER(intermediates[i], &der))
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 if (X509_NAME_cmp(issuer, cert_names[n]) == 0) { 443 if (X509_NAME_cmp(issuer, cert_names[n]) == 0) {
434 return true; 444 return true;
435 } 445 }
436 } 446 }
437 } 447 }
438 448
439 return false; 449 return false;
440 } 450 }
441 451
442 } // namespace net 452 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698