OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef CRYPTO_RSA_PRIVATE_KEY_H_ | 5 #ifndef CRYPTO_RSA_PRIVATE_KEY_H_ |
6 #define CRYPTO_RSA_PRIVATE_KEY_H_ | 6 #define CRYPTO_RSA_PRIVATE_KEY_H_ |
7 | 7 |
8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
9 | 9 |
10 #include <list> | 10 #include <list> |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 | 209 |
210 // Import an existing public key, and then search for the private | 210 // Import an existing public key, and then search for the private |
211 // half in the slot specified by |slot|. The format of the public | 211 // half in the slot specified by |slot|. The format of the public |
212 // key blob is is an X509 SubjectPublicKeyInfo block. This can return | 212 // key blob is is an X509 SubjectPublicKeyInfo block. This can return |
213 // NULL if initialization fails or the private key cannot be found. | 213 // NULL if initialization fails or the private key cannot be found. |
214 // The caller takes ownership of the returned object, but nothing new | 214 // The caller takes ownership of the returned object, but nothing new |
215 // is created in the slot. | 215 // is created in the slot. |
216 static RSAPrivateKey* FindFromPublicKeyInfoInSlot( | 216 static RSAPrivateKey* FindFromPublicKeyInfoInSlot( |
217 const std::vector<uint8>& input, | 217 const std::vector<uint8>& input, |
218 PK11SlotInfo* slot); | 218 PK11SlotInfo* slot); |
| 219 #elif defined(USE_OPENSSL) |
| 220 // Create a new instance from an existing EVP_PKEY, taking a |
| 221 // reference to it. |key| must be an RSA key. Returns NULL on |
| 222 // failure. |
| 223 static RSAPrivateKey* CreateFromKey(EVP_PKEY* key); |
| 224 |
219 #endif | 225 #endif |
220 | 226 |
221 #if defined(USE_OPENSSL) | 227 #if defined(USE_OPENSSL) |
222 EVP_PKEY* key() { return key_; } | 228 EVP_PKEY* key() { return key_; } |
223 #else | 229 #else |
224 SECKEYPrivateKey* key() { return key_; } | 230 SECKEYPrivateKey* key() { return key_; } |
225 SECKEYPublicKey* public_key() { return public_key_; } | 231 SECKEYPublicKey* public_key() { return public_key_; } |
226 #endif | 232 #endif |
227 | 233 |
228 // Creates a copy of the object. | 234 // Creates a copy of the object. |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 SECKEYPrivateKey* key_; | 284 SECKEYPrivateKey* key_; |
279 SECKEYPublicKey* public_key_; | 285 SECKEYPublicKey* public_key_; |
280 #endif | 286 #endif |
281 | 287 |
282 DISALLOW_COPY_AND_ASSIGN(RSAPrivateKey); | 288 DISALLOW_COPY_AND_ASSIGN(RSAPrivateKey); |
283 }; | 289 }; |
284 | 290 |
285 } // namespace crypto | 291 } // namespace crypto |
286 | 292 |
287 #endif // CRYPTO_RSA_PRIVATE_KEY_H_ | 293 #endif // CRYPTO_RSA_PRIVATE_KEY_H_ |
OLD | NEW |