| 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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 | 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() { | 97 std::string KeygenHandler::GenKeyAndSignChallenge() { |
| 103 std::string result; | 98 std::string result; |
| 104 OSStatus err; | 99 OSStatus err; |
| 105 SecKeyRef public_key = NULL; | 100 SecKeyRef public_key = NULL; |
| 106 SecKeyRef private_key = NULL; | 101 SecKeyRef private_key = NULL; |
| 107 SecAsn1CoderRef coder = NULL; | 102 SecAsn1CoderRef coder = NULL; |
| 108 CSSM_DATA signature = {0, NULL}; | 103 CSSM_DATA signature = {0, NULL}; |
| 109 | 104 |
| 110 { | 105 { |
| 111 // Create the key-pair. | 106 // Create the key-pair. |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 CSSM_ALGID_MD5WithRSA, | 249 CSSM_ALGID_MD5WithRSA, |
| 255 &cc_handle); | 250 &cc_handle); |
| 256 if (err) | 251 if (err) |
| 257 return err; | 252 return err; |
| 258 err = CSSM_SignData(cc_handle, &data, 1, CSSM_ALGID_NONE, signature); | 253 err = CSSM_SignData(cc_handle, &data, 1, CSSM_ALGID_NONE, signature); |
| 259 CSSM_DeleteContext(cc_handle); | 254 CSSM_DeleteContext(cc_handle); |
| 260 return err; | 255 return err; |
| 261 } | 256 } |
| 262 | 257 |
| 263 } // namespace net | 258 } // namespace net |
| OLD | NEW |