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

Side by Side Diff: net/cert/x509_certificate_ios.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.h ('k') | net/cert/x509_certificate_mac.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 <CommonCrypto/CommonDigest.h> 7 #include <CommonCrypto/CommonDigest.h>
8 #include <Security/Security.h> 8 #include <Security/Security.h>
9 9
10 #include <cert.h> 10 #include <cert.h>
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 if (!cert_data) 177 if (!cert_data)
178 return sha1; 178 return sha1;
179 DCHECK(CFDataGetBytePtr(cert_data)); 179 DCHECK(CFDataGetBytePtr(cert_data));
180 DCHECK_NE(0, CFDataGetLength(cert_data)); 180 DCHECK_NE(0, CFDataGetLength(cert_data));
181 CC_SHA1(CFDataGetBytePtr(cert_data), CFDataGetLength(cert_data), sha1.data); 181 CC_SHA1(CFDataGetBytePtr(cert_data), CFDataGetLength(cert_data), sha1.data);
182 182
183 return sha1; 183 return sha1;
184 } 184 }
185 185
186 // static 186 // static
187 SHA256HashValue X509Certificate::CalculateFingerprint256(OSCertHandle cert) {
188 SHA256HashValue sha256;
189 memset(sha256.data, 0, sizeof(sha256.data));
190
191 ScopedCFTypeRef<CFDataRef> cert_data(SecCertificateCopyData(cert));
192 if (!cert_data)
193 return sha256;
194 DCHECK(CFDataGetBytePtr(cert_data));
195 DCHECK_NE(0, CFDataGetLength(cert_data));
196 CC_SHA256(
197 CFDataGetBytePtr(cert_data), CFDataGetLength(cert_data), sha256.data);
198
199 return sha256;
200 }
201
202 // static
187 SHA1HashValue X509Certificate::CalculateCAFingerprint( 203 SHA1HashValue X509Certificate::CalculateCAFingerprint(
188 const OSCertHandles& intermediates) { 204 const OSCertHandles& intermediates) {
189 SHA1HashValue sha1; 205 SHA1HashValue sha1;
190 memset(sha1.data, 0, sizeof(sha1.data)); 206 memset(sha1.data, 0, sizeof(sha1.data));
191 207
192 // The CC_SHA(3cc) man page says all CC_SHA1_xxx routines return 1, so 208 // The CC_SHA(3cc) man page says all CC_SHA1_xxx routines return 1, so
193 // we don't check their return values. 209 // we don't check their return values.
194 CC_SHA1_CTX sha1_ctx; 210 CC_SHA1_CTX sha1_ctx;
195 CC_SHA1_Init(&sha1_ctx); 211 CC_SHA1_Init(&sha1_ctx);
196 for (size_t i = 0; i < intermediates.size(); ++i) { 212 for (size_t i = 0; i < intermediates.size(); ++i) {
(...skipping 29 matching lines...) Expand all
226 242
227 // static 243 // static
228 void X509Certificate::GetPublicKeyInfo(OSCertHandle cert_handle, 244 void X509Certificate::GetPublicKeyInfo(OSCertHandle cert_handle,
229 size_t* size_bits, 245 size_t* size_bits,
230 PublicKeyType* type) { 246 PublicKeyType* type) {
231 x509_util_ios::NSSCertificate nss_cert(cert_handle); 247 x509_util_ios::NSSCertificate nss_cert(cert_handle);
232 x509_util::GetPublicKeyInfo(nss_cert.cert_handle(), size_bits, type); 248 x509_util::GetPublicKeyInfo(nss_cert.cert_handle(), size_bits, type);
233 } 249 }
234 250
235 } // namespace net 251 } // namespace net
OLDNEW
« no previous file with comments | « net/cert/x509_certificate.h ('k') | net/cert/x509_certificate_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698