OLD | NEW |
1 // Copyright (c) 2011 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 <keyhi.h> // SECKEY_DestroyPrivateKey | 10 #include <keyhi.h> // SECKEY_DestroyPrivateKey |
11 #include <keythi.h> // SECKEYPrivateKey | 11 #include <keythi.h> // SECKEYPrivateKey |
12 #include <pk11pub.h> // PK11_FindKeyByAnyCert | 12 #include <pk11pub.h> // PK11_FindKeyByAnyCert |
13 #include <seccomon.h> // SECItem | 13 #include <seccomon.h> // SECItem |
14 #include <sechash.h> | 14 #include <sechash.h> |
15 | 15 |
16 #include "base/logging.h" | 16 #include "base/logging.h" |
17 #include "base/string_number_conversions.h" | 17 #include "base/string_number_conversions.h" |
18 #include "crypto/nss_util.h" | 18 #include "crypto/nss_util.h" |
| 19 #include "crypto/scoped_nss_types.h" |
19 #include "net/base/x509_certificate.h" | 20 #include "net/base/x509_certificate.h" |
20 #include "chrome/third_party/mozilla_security_manager/nsNSSCertHelper.h" | 21 #include "chrome/third_party/mozilla_security_manager/nsNSSCertHelper.h" |
21 #include "chrome/third_party/mozilla_security_manager/nsNSSCertificate.h" | 22 #include "chrome/third_party/mozilla_security_manager/nsNSSCertificate.h" |
22 #include "chrome/third_party/mozilla_security_manager/nsUsageArrayHelper.h" | 23 #include "chrome/third_party/mozilla_security_manager/nsUsageArrayHelper.h" |
23 | 24 |
24 namespace psm = mozilla_security_manager; | 25 namespace psm = mozilla_security_manager; |
25 | 26 |
26 namespace { | 27 namespace { |
27 | 28 |
28 // Convert a char* return value from NSS into a std::string and free the NSS | 29 // Convert a char* return value from NSS into a std::string and free the NSS |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 cert_handles->clear(); | 325 cert_handles->clear(); |
325 } | 326 } |
326 | 327 |
327 string GetDerString(X509Certificate::OSCertHandle cert_handle) { | 328 string GetDerString(X509Certificate::OSCertHandle cert_handle) { |
328 return string(reinterpret_cast<const char*>(cert_handle->derCert.data), | 329 return string(reinterpret_cast<const char*>(cert_handle->derCert.data), |
329 cert_handle->derCert.len); | 330 cert_handle->derCert.len); |
330 } | 331 } |
331 | 332 |
332 string GetCMSString(const X509Certificate::OSCertHandles& cert_chain, | 333 string GetCMSString(const X509Certificate::OSCertHandles& cert_chain, |
333 size_t start, size_t end) { | 334 size_t start, size_t end) { |
334 ScopedPRArenaPool arena(PORT_NewArena(1024)); | 335 crypto::ScopedPLArenaPool arena(PORT_NewArena(1024)); |
335 DCHECK(arena.get()); | 336 DCHECK(arena.get()); |
336 | 337 |
337 ScopedNSSCMSMessage message(NSS_CMSMessage_Create(arena.get())); | 338 ScopedNSSCMSMessage message(NSS_CMSMessage_Create(arena.get())); |
338 DCHECK(message.get()); | 339 DCHECK(message.get()); |
339 | 340 |
340 // First, create SignedData with the certificate only (no chain). | 341 // First, create SignedData with the certificate only (no chain). |
341 ScopedNSSCMSSignedData signed_data(NSS_CMSSignedData_CreateCertsOnly( | 342 ScopedNSSCMSSignedData signed_data(NSS_CMSSignedData_CreateCertsOnly( |
342 message.get(), cert_chain[start], PR_FALSE)); | 343 message.get(), cert_chain[start], PR_FALSE)); |
343 if (!signed_data.get()) { | 344 if (!signed_data.get()) { |
344 DLOG(ERROR) << "NSS_CMSSignedData_Create failed"; | 345 DLOG(ERROR) << "NSS_CMSSignedData_Create failed"; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 string ProcessRawBitsSignatureWrap(X509Certificate::OSCertHandle cert_handle) { | 404 string ProcessRawBitsSignatureWrap(X509Certificate::OSCertHandle cert_handle) { |
404 return ProcessRawBits(cert_handle->signatureWrap.signature.data, | 405 return ProcessRawBits(cert_handle->signatureWrap.signature.data, |
405 cert_handle->signatureWrap.signature.len); | 406 cert_handle->signatureWrap.signature.len); |
406 } | 407 } |
407 | 408 |
408 void RegisterDynamicOids() { | 409 void RegisterDynamicOids() { |
409 psm::RegisterDynamicOids(); | 410 psm::RegisterDynamicOids(); |
410 } | 411 } |
411 | 412 |
412 } // namespace x509_certificate_model | 413 } // namespace x509_certificate_model |
OLD | NEW |