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 <Security/SecAsn1Coder.h> | 7 #include <Security/SecAsn1Coder.h> |
8 #include <Security/SecAsn1Templates.h> | 8 #include <Security/SecAsn1Templates.h> |
9 #include <Security/Security.h> | 9 #include <Security/Security.h> |
10 | 10 |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 }; | 86 }; |
87 | 87 |
88 | 88 |
89 static OSStatus CreateRSAKeyPair(int size_in_bits, | 89 static OSStatus CreateRSAKeyPair(int size_in_bits, |
90 SecKeyRef* out_pub_key, | 90 SecKeyRef* out_pub_key, |
91 SecKeyRef* out_priv_key); | 91 SecKeyRef* out_priv_key); |
92 static OSStatus SignData(CSSM_DATA data, | 92 static OSStatus SignData(CSSM_DATA data, |
93 SecKeyRef private_key, | 93 SecKeyRef private_key, |
94 CSSM_DATA* signature); | 94 CSSM_DATA* signature); |
95 | 95 |
96 | |
97 bool KeygenHandler::KeyLocation::Equals( | |
98 const KeygenHandler::KeyLocation& location) const { | |
99 return keychain_path == location.keychain_path; | |
100 } | |
101 | |
102 std::string KeygenHandler::GenKeyAndSignChallenge() { | 96 std::string KeygenHandler::GenKeyAndSignChallenge() { |
103 std::string result; | 97 std::string result; |
104 OSStatus err; | 98 OSStatus err; |
105 SecKeyRef public_key = NULL; | 99 SecKeyRef public_key = NULL; |
106 SecKeyRef private_key = NULL; | 100 SecKeyRef private_key = NULL; |
107 SecAsn1CoderRef coder = NULL; | 101 SecAsn1CoderRef coder = NULL; |
108 CSSM_DATA signature = {0, NULL}; | 102 CSSM_DATA signature = {0, NULL}; |
109 | 103 |
110 { | 104 { |
111 // Create the key-pair. | 105 // Create the key-pair. |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 CSSM_ALGID_MD5WithRSA, | 248 CSSM_ALGID_MD5WithRSA, |
255 &cc_handle); | 249 &cc_handle); |
256 if (err) | 250 if (err) |
257 return err; | 251 return err; |
258 err = CSSM_SignData(cc_handle, &data, 1, CSSM_ALGID_NONE, signature); | 252 err = CSSM_SignData(cc_handle, &data, 1, CSSM_ALGID_NONE, signature); |
259 CSSM_DeleteContext(cc_handle); | 253 CSSM_DeleteContext(cc_handle); |
260 return err; | 254 return err; |
261 } | 255 } |
262 | 256 |
263 } // namespace net | 257 } // namespace net |
OLD | NEW |