OLD | NEW |
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 <cert.h> | 7 #include <cert.h> |
8 #include <cryptohi.h> | 8 #include <cryptohi.h> |
9 #include <keyhi.h> | 9 #include <keyhi.h> |
10 #include <nss.h> | 10 #include <nss.h> |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 DCHECK_NE(0U, cert->derCert.len); | 218 DCHECK_NE(0U, cert->derCert.len); |
219 | 219 |
220 SECStatus rv = HASH_HashBuf(HASH_AlgSHA1, sha1.data, | 220 SECStatus rv = HASH_HashBuf(HASH_AlgSHA1, sha1.data, |
221 cert->derCert.data, cert->derCert.len); | 221 cert->derCert.data, cert->derCert.len); |
222 DCHECK_EQ(SECSuccess, rv); | 222 DCHECK_EQ(SECSuccess, rv); |
223 | 223 |
224 return sha1; | 224 return sha1; |
225 } | 225 } |
226 | 226 |
227 // static | 227 // static |
| 228 SHA256HashValue X509Certificate::CalculateFingerprint256(OSCertHandle cert) { |
| 229 SHA256HashValue sha256; |
| 230 memset(sha256.data, 0, sizeof(sha256.data)); |
| 231 |
| 232 DCHECK(NULL != cert->derCert.data); |
| 233 DCHECK_NE(0U, cert->derCert.len); |
| 234 |
| 235 SECStatus rv = HASH_HashBuf( |
| 236 HASH_AlgSHA256, sha256.data, cert->derCert.data, cert->derCert.len); |
| 237 DCHECK_EQ(SECSuccess, rv); |
| 238 |
| 239 return sha256; |
| 240 } |
| 241 |
| 242 // static |
228 SHA1HashValue X509Certificate::CalculateCAFingerprint( | 243 SHA1HashValue X509Certificate::CalculateCAFingerprint( |
229 const OSCertHandles& intermediates) { | 244 const OSCertHandles& intermediates) { |
230 SHA1HashValue sha1; | 245 SHA1HashValue sha1; |
231 memset(sha1.data, 0, sizeof(sha1.data)); | 246 memset(sha1.data, 0, sizeof(sha1.data)); |
232 | 247 |
233 HASHContext* sha1_ctx = HASH_Create(HASH_AlgSHA1); | 248 HASHContext* sha1_ctx = HASH_Create(HASH_AlgSHA1); |
234 if (!sha1_ctx) | 249 if (!sha1_ctx) |
235 return sha1; | 250 return sha1; |
236 HASH_Begin(sha1_ctx); | 251 HASH_Begin(sha1_ctx); |
237 for (size_t i = 0; i < intermediates.size(); ++i) { | 252 for (size_t i = 0; i < intermediates.size(); ++i) { |
(...skipping 22 matching lines...) Expand all Loading... |
260 } | 275 } |
261 | 276 |
262 // static | 277 // static |
263 void X509Certificate::GetPublicKeyInfo(OSCertHandle cert_handle, | 278 void X509Certificate::GetPublicKeyInfo(OSCertHandle cert_handle, |
264 size_t* size_bits, | 279 size_t* size_bits, |
265 PublicKeyType* type) { | 280 PublicKeyType* type) { |
266 x509_util::GetPublicKeyInfo(cert_handle, size_bits, type); | 281 x509_util::GetPublicKeyInfo(cert_handle, size_bits, type); |
267 } | 282 } |
268 | 283 |
269 } // namespace net | 284 } // namespace net |
OLD | NEW |