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