OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/base/keygen_handler.h" | 5 #include "net/base/keygen_handler.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 #include <wincrypt.h> | 8 #include <wincrypt.h> |
9 #pragma comment(lib, "crypt32.lib") | 9 #pragma comment(lib, "crypt32.lib") |
10 #include <rpc.h> | 10 #include <rpc.h> |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 | 78 |
79 return true; | 79 return true; |
80 } | 80 } |
81 | 81 |
82 // Appends a DER IA5String containing |challenge| to |output|. | 82 // Appends a DER IA5String containing |challenge| to |output|. |
83 // Returns true if encoding was successful. | 83 // Returns true if encoding was successful. |
84 bool EncodeChallenge(const std::string& challenge, std::vector<BYTE>* output) { | 84 bool EncodeChallenge(const std::string& challenge, std::vector<BYTE>* output) { |
85 CERT_NAME_VALUE challenge_nv; | 85 CERT_NAME_VALUE challenge_nv; |
86 challenge_nv.dwValueType = CERT_RDN_IA5_STRING; | 86 challenge_nv.dwValueType = CERT_RDN_IA5_STRING; |
87 challenge_nv.Value.pbData = const_cast<BYTE*>( | 87 challenge_nv.Value.pbData = const_cast<BYTE*>( |
88 reinterpret_cast<const BYTE*>(challenge.c_str())); | 88 reinterpret_cast<const BYTE*>(challenge.data())); |
89 challenge_nv.Value.cbData = challenge.size(); | 89 challenge_nv.Value.cbData = challenge.size(); |
90 | 90 |
91 return EncodeAndAppendType(X509_ANY_STRING, &challenge_nv, output); | 91 return EncodeAndAppendType(X509_ANY_STRING, &challenge_nv, output); |
92 } | 92 } |
93 | 93 |
94 // Appends a DER SubjectPublicKeyInfo structure for the signing key in |prov| | 94 // Appends a DER SubjectPublicKeyInfo structure for the signing key in |prov| |
95 // to |output|. | 95 // to |output|. |
96 // Returns true if encoding was successful. | 96 // Returns true if encoding was successful. |
97 bool EncodeSubjectPublicKeyInfo(HCRYPTPROV prov, std::vector<BYTE>* output) { | 97 bool EncodeSubjectPublicKeyInfo(HCRYPTPROV prov, std::vector<BYTE>* output) { |
98 BOOL ok; | 98 BOOL ok; |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 // Fully destroys any of the keys that were created and releases prov. | 359 // Fully destroys any of the keys that were created and releases prov. |
360 CryptAcquireContext(&prov, new_key_id.c_str(), NULL, PROV_RSA_FULL, | 360 CryptAcquireContext(&prov, new_key_id.c_str(), NULL, PROV_RSA_FULL, |
361 CRYPT_SILENT | CRYPT_DELETEKEYSET); | 361 CRYPT_SILENT | CRYPT_DELETEKEYSET); |
362 } | 362 } |
363 } | 363 } |
364 | 364 |
365 return result; | 365 return result; |
366 } | 366 } |
367 | 367 |
368 } // namespace net | 368 } // namespace net |
OLD | NEW |