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 |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 name = name.substr(colon_pos + 1); | 118 name = name.substr(colon_pos + 1); |
119 } | 119 } |
120 return name; | 120 return name; |
121 } | 121 } |
122 | 122 |
123 string GetTokenName(X509Certificate::OSCertHandle cert_handle) { | 123 string GetTokenName(X509Certificate::OSCertHandle cert_handle) { |
124 return psm::GetCertTokenName(cert_handle); | 124 return psm::GetCertTokenName(cert_handle); |
125 } | 125 } |
126 | 126 |
127 string GetVersion(X509Certificate::OSCertHandle cert_handle) { | 127 string GetVersion(X509Certificate::OSCertHandle cert_handle) { |
128 unsigned long version = ULONG_MAX; | 128 // If the version field is omitted from the certificate, the default |
129 if (SEC_ASN1DecodeInteger(&cert_handle->version, &version) == SECSuccess && | 129 // value is v1(0). |
130 version != ULONG_MAX) | 130 unsigned long version = 0; |
| 131 if (cert_handle->version.len == 0 || |
| 132 SEC_ASN1DecodeInteger(&cert_handle->version, &version) == SECSuccess) { |
131 return base::UintToString(version + 1); | 133 return base::UintToString(version + 1); |
| 134 } |
132 return ""; | 135 return ""; |
133 } | 136 } |
134 | 137 |
135 net::CertType GetType(X509Certificate::OSCertHandle cert_handle) { | 138 net::CertType GetType(X509Certificate::OSCertHandle cert_handle) { |
136 return psm::GetCertType(cert_handle); | 139 return psm::GetCertType(cert_handle); |
137 } | 140 } |
138 | 141 |
139 string GetEmailAddress(X509Certificate::OSCertHandle cert_handle) { | 142 string GetEmailAddress(X509Certificate::OSCertHandle cert_handle) { |
140 if (cert_handle->emailAddr) | 143 if (cert_handle->emailAddr) |
141 return cert_handle->emailAddr; | 144 return cert_handle->emailAddr; |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 string ProcessRawBitsSignatureWrap(X509Certificate::OSCertHandle cert_handle) { | 407 string ProcessRawBitsSignatureWrap(X509Certificate::OSCertHandle cert_handle) { |
405 return ProcessRawBits(cert_handle->signatureWrap.signature.data, | 408 return ProcessRawBits(cert_handle->signatureWrap.signature.data, |
406 cert_handle->signatureWrap.signature.len); | 409 cert_handle->signatureWrap.signature.len); |
407 } | 410 } |
408 | 411 |
409 void RegisterDynamicOids() { | 412 void RegisterDynamicOids() { |
410 psm::RegisterDynamicOids(); | 413 psm::RegisterDynamicOids(); |
411 } | 414 } |
412 | 415 |
413 } // namespace x509_certificate_model | 416 } // namespace x509_certificate_model |
OLD | NEW |