| 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 "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/numerics/safe_conversions.h" |
| 17 #include "base/strings/string_number_conversions.h" | 18 #include "base/strings/string_number_conversions.h" |
| 18 #include "chrome/third_party/mozilla_security_manager/nsNSSCertHelper.h" | 19 #include "chrome/third_party/mozilla_security_manager/nsNSSCertHelper.h" |
| 19 #include "chrome/third_party/mozilla_security_manager/nsNSSCertificate.h" | 20 #include "chrome/third_party/mozilla_security_manager/nsNSSCertificate.h" |
| 20 #include "chrome/third_party/mozilla_security_manager/nsUsageArrayHelper.h" | 21 #include "chrome/third_party/mozilla_security_manager/nsUsageArrayHelper.h" |
| 21 #include "crypto/nss_util.h" | 22 #include "crypto/nss_util.h" |
| 22 #include "crypto/scoped_nss_types.h" | 23 #include "crypto/scoped_nss_types.h" |
| 23 #include "net/cert/x509_certificate.h" | 24 #include "net/cert/x509_certificate.h" |
| 24 | 25 |
| 25 namespace psm = mozilla_security_manager; | 26 namespace psm = mozilla_security_manager; |
| 26 | 27 |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 string GetTokenName(X509Certificate::OSCertHandle cert_handle) { | 119 string GetTokenName(X509Certificate::OSCertHandle cert_handle) { |
| 119 return psm::GetCertTokenName(cert_handle); | 120 return psm::GetCertTokenName(cert_handle); |
| 120 } | 121 } |
| 121 | 122 |
| 122 string GetVersion(X509Certificate::OSCertHandle cert_handle) { | 123 string GetVersion(X509Certificate::OSCertHandle cert_handle) { |
| 123 // If the version field is omitted from the certificate, the default | 124 // If the version field is omitted from the certificate, the default |
| 124 // value is v1(0). | 125 // value is v1(0). |
| 125 unsigned long version = 0; | 126 unsigned long version = 0; |
| 126 if (cert_handle->version.len == 0 || | 127 if (cert_handle->version.len == 0 || |
| 127 SEC_ASN1DecodeInteger(&cert_handle->version, &version) == SECSuccess) { | 128 SEC_ASN1DecodeInteger(&cert_handle->version, &version) == SECSuccess) { |
| 128 return base::UintToString(version + 1); | 129 return base::Uint64ToString(base::strict_cast<uint64>(version + 1)); |
| 129 } | 130 } |
| 130 return std::string(); | 131 return std::string(); |
| 131 } | 132 } |
| 132 | 133 |
| 133 net::CertType GetType(X509Certificate::OSCertHandle cert_handle) { | 134 net::CertType GetType(X509Certificate::OSCertHandle cert_handle) { |
| 134 return psm::GetCertType(cert_handle); | 135 return psm::GetCertType(cert_handle); |
| 135 } | 136 } |
| 136 | 137 |
| 137 void GetUsageStrings(X509Certificate::OSCertHandle cert_handle, | 138 void GetUsageStrings(X509Certificate::OSCertHandle cert_handle, |
| 138 std::vector<string>* usages) { | 139 std::vector<string>* usages) { |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 string ProcessSubjectPublicKeyInfo(X509Certificate::OSCertHandle cert_handle) { | 294 string ProcessSubjectPublicKeyInfo(X509Certificate::OSCertHandle cert_handle) { |
| 294 return psm::ProcessSubjectPublicKeyInfo(&cert_handle->subjectPublicKeyInfo); | 295 return psm::ProcessSubjectPublicKeyInfo(&cert_handle->subjectPublicKeyInfo); |
| 295 } | 296 } |
| 296 | 297 |
| 297 string ProcessRawBitsSignatureWrap(X509Certificate::OSCertHandle cert_handle) { | 298 string ProcessRawBitsSignatureWrap(X509Certificate::OSCertHandle cert_handle) { |
| 298 return ProcessRawBits(cert_handle->signatureWrap.signature.data, | 299 return ProcessRawBits(cert_handle->signatureWrap.signature.data, |
| 299 cert_handle->signatureWrap.signature.len); | 300 cert_handle->signatureWrap.signature.len); |
| 300 } | 301 } |
| 301 | 302 |
| 302 } // namespace x509_certificate_model | 303 } // namespace x509_certificate_model |
| OLD | NEW |