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 "net/cert/x509_cert_types.h" | 5 #include "net/cert/x509_cert_types.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 #include <wincrypt.h> | |
9 | 8 |
10 #include "base/logging.h" | 9 #include "base/logging.h" |
11 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
12 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
13 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
14 #include "crypto/capi_util.h" | 13 #include "crypto/capi_util.h" |
| 14 #include "crypto/wincrypt_shim.h" |
15 | 15 |
16 #pragma comment(lib, "crypt32.lib") | 16 #pragma comment(lib, "crypt32.lib") |
17 | 17 |
18 namespace net { | 18 namespace net { |
19 | 19 |
20 namespace { | 20 namespace { |
21 | 21 |
22 // A list of OIDs to decode. Any OID not on this list will be ignored for | 22 // A list of OIDs to decode. Any OID not on this list will be ignored for |
23 // purposes of parsing. | 23 // purposes of parsing. |
24 const char* kOIDs[] = { | 24 const char* kOIDs[] = { |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 DCHECK(ber_name_data); | 90 DCHECK(ber_name_data); |
91 | 91 |
92 CRYPT_DECODE_PARA decode_para; | 92 CRYPT_DECODE_PARA decode_para; |
93 decode_para.cbSize = sizeof(decode_para); | 93 decode_para.cbSize = sizeof(decode_para); |
94 decode_para.pfnAlloc = crypto::CryptAlloc; | 94 decode_para.pfnAlloc = crypto::CryptAlloc; |
95 decode_para.pfnFree = crypto::CryptFree; | 95 decode_para.pfnFree = crypto::CryptFree; |
96 CERT_NAME_INFO* name_info = NULL; | 96 CERT_NAME_INFO* name_info = NULL; |
97 DWORD name_info_size = 0; | 97 DWORD name_info_size = 0; |
98 BOOL rv; | 98 BOOL rv; |
99 rv = CryptDecodeObjectEx(X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, | 99 rv = CryptDecodeObjectEx(X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, |
100 X509_NAME, | 100 WINCRYPT_X509_NAME, |
101 reinterpret_cast<const BYTE*>(ber_name_data), | 101 reinterpret_cast<const BYTE*>(ber_name_data), |
102 length, | 102 length, |
103 CRYPT_DECODE_ALLOC_FLAG | CRYPT_DECODE_NOCOPY_FLAG, | 103 CRYPT_DECODE_ALLOC_FLAG | CRYPT_DECODE_NOCOPY_FLAG, |
104 &decode_para, | 104 &decode_para, |
105 &name_info, &name_info_size); | 105 &name_info, &name_info_size); |
106 if (!rv) | 106 if (!rv) |
107 return false; | 107 return false; |
108 scoped_ptr<CERT_NAME_INFO, base::FreeDeleter> scoped_name_info(name_info); | 108 scoped_ptr<CERT_NAME_INFO, base::FreeDeleter> scoped_name_info(name_info); |
109 | 109 |
110 std::vector<std::string> common_names, locality_names, state_names, | 110 std::vector<std::string> common_names, locality_names, state_names, |
(...skipping 19 matching lines...) Expand all Loading... |
130 } | 130 } |
131 | 131 |
132 SetSingle(common_names, &this->common_name); | 132 SetSingle(common_names, &this->common_name); |
133 SetSingle(locality_names, &this->locality_name); | 133 SetSingle(locality_names, &this->locality_name); |
134 SetSingle(state_names, &this->state_or_province_name); | 134 SetSingle(state_names, &this->state_or_province_name); |
135 SetSingle(country_names, &this->country_name); | 135 SetSingle(country_names, &this->country_name); |
136 return true; | 136 return true; |
137 } | 137 } |
138 | 138 |
139 } // namespace net | 139 } // namespace net |
OLD | NEW |