| 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 "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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 return true; | 57 return true; |
| 58 } | 58 } |
| 59 | 59 |
| 60 // Generates a DER encoded SignedPublicKeyAndChallenge structure from the | 60 // Generates a DER encoded SignedPublicKeyAndChallenge structure from the |
| 61 // signing key of |prov| and the specified ASCII |challenge| string and | 61 // signing key of |prov| and the specified ASCII |challenge| string and |
| 62 // appends it to |output|. | 62 // appends it to |output|. |
| 63 // True if the encoding was successfully generated. | 63 // True if the encoding was successfully generated. |
| 64 bool GetSignedPublicKeyAndChallenge(HCRYPTPROV prov, | 64 bool GetSignedPublicKeyAndChallenge(HCRYPTPROV prov, |
| 65 const std::string& challenge, | 65 const std::string& challenge, |
| 66 std::string* output) { | 66 std::string* output) { |
| 67 std::wstring wide_challenge = ASCIIToWide(challenge); | 67 std::wstring wide_challenge = base::ASCIIToWide(challenge); |
| 68 std::vector<BYTE> spki; | 68 std::vector<BYTE> spki; |
| 69 | 69 |
| 70 if (!GetSubjectPublicKeyInfo(prov, &spki)) | 70 if (!GetSubjectPublicKeyInfo(prov, &spki)) |
| 71 return false; | 71 return false; |
| 72 | 72 |
| 73 // PublicKeyAndChallenge ::= SEQUENCE { | 73 // PublicKeyAndChallenge ::= SEQUENCE { |
| 74 // spki SubjectPublicKeyInfo, | 74 // spki SubjectPublicKeyInfo, |
| 75 // challenge IA5STRING | 75 // challenge IA5STRING |
| 76 // } | 76 // } |
| 77 CERT_KEYGEN_REQUEST_INFO pkac; | 77 CERT_KEYGEN_REQUEST_INFO pkac; |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 | 212 |
| 213 std::string result; | 213 std::string result; |
| 214 base::Base64Encode(spkac, &result); | 214 base::Base64Encode(spkac, &result); |
| 215 | 215 |
| 216 VLOG(1) << "Keygen succeeded"; | 216 VLOG(1) << "Keygen succeeded"; |
| 217 return result; | 217 return result; |
| 218 } | 218 } |
| 219 } | 219 } |
| 220 | 220 |
| 221 } // namespace net | 221 } // namespace net |
| OLD | NEW |