OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/common/net/x509_certificate_model.h" | 5 #include "chrome/common/net/x509_certificate_model.h" |
6 | 6 |
7 #include <cert.h> | 7 #include <cert.h> |
8 #include <cms.h> | 8 #include <cms.h> |
9 #include <hasht.h> | 9 #include <hasht.h> |
10 #include <pk11pub.h> | 10 #include <pk11pub.h> |
11 #include <sechash.h> | 11 #include <sechash.h> |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 } | 266 } |
267 | 267 |
268 string HashCertSHA256(X509Certificate::OSCertHandle cert_handle) { | 268 string HashCertSHA256(X509Certificate::OSCertHandle cert_handle) { |
269 return HashCert(cert_handle, HASH_AlgSHA256, SHA256_LENGTH); | 269 return HashCert(cert_handle, HASH_AlgSHA256, SHA256_LENGTH); |
270 } | 270 } |
271 | 271 |
272 string HashCertSHA1(X509Certificate::OSCertHandle cert_handle) { | 272 string HashCertSHA1(X509Certificate::OSCertHandle cert_handle) { |
273 return HashCert(cert_handle, HASH_AlgSHA1, SHA1_LENGTH); | 273 return HashCert(cert_handle, HASH_AlgSHA1, SHA1_LENGTH); |
274 } | 274 } |
275 | 275 |
276 void GetCertChainFromCert(X509Certificate::OSCertHandle cert_handle, | |
277 X509Certificate::OSCertHandles* cert_handles) { | |
278 CERTCertList* cert_list = | |
279 CERT_GetCertChainFromCert(cert_handle, PR_Now(), certUsageSSLServer); | |
280 CERTCertListNode* node; | |
281 for (node = CERT_LIST_HEAD(cert_list); | |
282 !CERT_LIST_END(node, cert_list); | |
283 node = CERT_LIST_NEXT(node)) { | |
284 cert_handles->push_back(CERT_DupCertificate(node->cert)); | |
285 } | |
286 CERT_DestroyCertList(cert_list); | |
287 } | |
288 | |
289 void DestroyCertChain(X509Certificate::OSCertHandles* cert_handles) { | |
290 for (X509Certificate::OSCertHandles::iterator i(cert_handles->begin()); | |
291 i != cert_handles->end(); ++i) | |
292 CERT_DestroyCertificate(*i); | |
293 cert_handles->clear(); | |
294 } | |
295 | |
296 string GetDerString(X509Certificate::OSCertHandle cert_handle) { | 276 string GetDerString(X509Certificate::OSCertHandle cert_handle) { |
297 return string(reinterpret_cast<const char*>(cert_handle->derCert.data), | 277 return string(reinterpret_cast<const char*>(cert_handle->derCert.data), |
298 cert_handle->derCert.len); | 278 cert_handle->derCert.len); |
299 } | 279 } |
300 | 280 |
301 string GetCMSString(const X509Certificate::OSCertHandles& cert_chain, | 281 string GetCMSString(const X509Certificate::OSCertHandles& cert_chain, |
302 size_t start, size_t end) { | 282 size_t start, size_t end) { |
303 ScopedPRArenaPool arena(PORT_NewArena(1024)); | 283 ScopedPRArenaPool arena(PORT_NewArena(1024)); |
304 CHECK(arena.get()); | 284 CHECK(arena.get()); |
305 | 285 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 | 351 |
372 string ProcessRawBitsSignatureWrap(X509Certificate::OSCertHandle cert_handle) { | 352 string ProcessRawBitsSignatureWrap(X509Certificate::OSCertHandle cert_handle) { |
373 return ProcessRawBits(cert_handle->signatureWrap.signature.data, | 353 return ProcessRawBits(cert_handle->signatureWrap.signature.data, |
374 cert_handle->signatureWrap.signature.len); | 354 cert_handle->signatureWrap.signature.len); |
375 } | 355 } |
376 | 356 |
377 void RegisterDynamicOids() { | 357 void RegisterDynamicOids() { |
378 } | 358 } |
379 | 359 |
380 } // namespace x509_certificate_model | 360 } // namespace x509_certificate_model |
OLD | NEW |