| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 | 81 |
| 82 | 82 |
| 83 static OSStatus CreateRSAKeyPair(int size_in_bits, | 83 static OSStatus CreateRSAKeyPair(int size_in_bits, |
| 84 SecKeyRef* out_pub_key, | 84 SecKeyRef* out_pub_key, |
| 85 SecKeyRef* out_priv_key); | 85 SecKeyRef* out_priv_key); |
| 86 static OSStatus SignData(CSSM_DATA data, | 86 static OSStatus SignData(CSSM_DATA data, |
| 87 SecKeyRef private_key, | 87 SecKeyRef private_key, |
| 88 CSSM_DATA* signature); | 88 CSSM_DATA* signature); |
| 89 | 89 |
| 90 | 90 |
| 91 bool KeygenHandler::KeyLocation::Equals( |
| 92 const KeygenHandler::KeyLocation& location) const { |
| 93 return keychain_path == location.keychain_path; |
| 94 } |
| 95 |
| 91 std::string KeygenHandler::GenKeyAndSignChallenge() { | 96 std::string KeygenHandler::GenKeyAndSignChallenge() { |
| 92 std::string result; | 97 std::string result; |
| 93 OSStatus err; | 98 OSStatus err; |
| 94 SecKeyRef public_key = NULL; | 99 SecKeyRef public_key = NULL; |
| 95 SecKeyRef private_key = NULL; | 100 SecKeyRef private_key = NULL; |
| 96 SecAsn1CoderRef coder = NULL; | 101 SecAsn1CoderRef coder = NULL; |
| 97 CSSM_DATA signature = {0, NULL}; | 102 CSSM_DATA signature = {0, NULL}; |
| 98 | 103 |
| 99 { | 104 { |
| 100 // Create the key-pair. | 105 // Create the key-pair. |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 CSSM_ALGID_MD5WithRSA, | 248 CSSM_ALGID_MD5WithRSA, |
| 244 &cc_handle); | 249 &cc_handle); |
| 245 if (err) | 250 if (err) |
| 246 return err; | 251 return err; |
| 247 err = CSSM_SignData(cc_handle, &data, 1, CSSM_ALGID_NONE, signature); | 252 err = CSSM_SignData(cc_handle, &data, 1, CSSM_ALGID_NONE, signature); |
| 248 CSSM_DeleteContext(cc_handle); | 253 CSSM_DeleteContext(cc_handle); |
| 249 return err; | 254 return err; |
| 250 } | 255 } |
| 251 | 256 |
| 252 } // namespace net | 257 } // namespace net |
| OLD | NEW |