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 | |
243 SHA1HashValue X509Certificate::CalculateCAFingerprint( | 228 SHA1HashValue X509Certificate::CalculateCAFingerprint( |
244 const OSCertHandles& intermediates) { | 229 const OSCertHandles& intermediates) { |
245 SHA1HashValue sha1; | 230 SHA1HashValue sha1; |
246 memset(sha1.data, 0, sizeof(sha1.data)); | 231 memset(sha1.data, 0, sizeof(sha1.data)); |
247 | 232 |
248 HASHContext* sha1_ctx = HASH_Create(HASH_AlgSHA1); | 233 HASHContext* sha1_ctx = HASH_Create(HASH_AlgSHA1); |
249 if (!sha1_ctx) | 234 if (!sha1_ctx) |
250 return sha1; | 235 return sha1; |
251 HASH_Begin(sha1_ctx); | 236 HASH_Begin(sha1_ctx); |
252 for (size_t i = 0; i < intermediates.size(); ++i) { | 237 for (size_t i = 0; i < intermediates.size(); ++i) { |
(...skipping 22 matching lines...) Expand all Loading... |
275 } | 260 } |
276 | 261 |
277 // static | 262 // static |
278 void X509Certificate::GetPublicKeyInfo(OSCertHandle cert_handle, | 263 void X509Certificate::GetPublicKeyInfo(OSCertHandle cert_handle, |
279 size_t* size_bits, | 264 size_t* size_bits, |
280 PublicKeyType* type) { | 265 PublicKeyType* type) { |
281 x509_util::GetPublicKeyInfo(cert_handle, size_bits, type); | 266 x509_util::GetPublicKeyInfo(cert_handle, size_bits, type); |
282 } | 267 } |
283 | 268 |
284 } // namespace net | 269 } // namespace net |
OLD | NEW |