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 #if defined(USE_OPENSSL) | 10 #if defined(USE_OPENSSL) |
11 // Forward declaration for openssl/*.h | 11 // Forward declaration for openssl/*.h |
12 typedef struct evp_pkey_st EVP_PKEY; | 12 typedef struct evp_pkey_st EVP_PKEY; |
13 #elif defined(USE_NSS) | 13 #elif defined(USE_NSS) |
14 // Forward declaration. | 14 // Forward declaration. |
15 struct SECKEYPrivateKeyStr; | 15 struct SECKEYPrivateKeyStr; |
16 struct SECKEYPublicKeyStr; | 16 struct SECKEYPublicKeyStr; |
Ryan Sleevi
2013/05/07 19:45:23
minor nit: Would you mind updating these to be
ty
Chris Masone
2013/05/07 21:00:39
Done.
| |
17 #elif defined(OS_IOS) | 17 #elif defined(OS_IOS) |
18 #include <Security/Security.h> | 18 #include <Security/Security.h> |
19 #elif defined(OS_MACOSX) | 19 #elif defined(OS_MACOSX) |
20 #include <Security/cssm.h> | 20 #include <Security/cssm.h> |
21 #endif | 21 #endif |
22 | 22 |
23 #include <list> | 23 #include <list> |
24 #include <vector> | 24 #include <vector> |
25 | 25 |
26 #include "base/basictypes.h" | 26 #include "base/basictypes.h" |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
193 | 193 |
194 // Create a new instance by importing an existing private key. The format is | 194 // Create a new instance by importing an existing private key. The format is |
195 // an ASN.1-encoded PrivateKeyInfo block from PKCS #8. This can return NULL if | 195 // an ASN.1-encoded PrivateKeyInfo block from PKCS #8. This can return NULL if |
196 // initialization fails. | 196 // initialization fails. |
197 // The created key is permanent and is not exportable in plaintext form. | 197 // The created key is permanent and is not exportable in plaintext form. |
198 // | 198 // |
199 // NOTE: Currently only available if USE_NSS is defined. | 199 // NOTE: Currently only available if USE_NSS is defined. |
200 static RSAPrivateKey* CreateSensitiveFromPrivateKeyInfo( | 200 static RSAPrivateKey* CreateSensitiveFromPrivateKeyInfo( |
201 const std::vector<uint8>& input); | 201 const std::vector<uint8>& input); |
202 | 202 |
203 #if defined(USE_NSS) | |
204 static RSAPrivateKey* CreateFromKeypair(SECKEYPrivateKeyStr* key, | |
205 SECKEYPublicKeyStr* public_key); | |
206 #endif | |
207 | |
203 // Import an existing public key, and then search for the private | 208 // Import an existing public key, and then search for the private |
204 // half in the key database. The format of the public key blob is is | 209 // half in the key database. The format of the public key blob is is |
205 // an X509 SubjectPublicKeyInfo block. This can return NULL if | 210 // an X509 SubjectPublicKeyInfo block. This can return NULL if |
206 // initialization fails or the private key cannot be found. The | 211 // initialization fails or the private key cannot be found. The |
207 // caller takes ownership of the returned object, but nothing new is | 212 // caller takes ownership of the returned object, but nothing new is |
208 // created in the key database. | 213 // created in the key database. |
209 // | 214 // |
210 // NOTE: Currently only available if USE_NSS is defined. | 215 // NOTE: Currently only available if USE_NSS is defined. |
211 static RSAPrivateKey* FindFromPublicKeyInfo( | 216 static RSAPrivateKey* FindFromPublicKeyInfo( |
212 const std::vector<uint8>& input); | 217 const std::vector<uint8>& input); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
275 CSSM_KEY key_; | 280 CSSM_KEY key_; |
276 CSSM_KEY public_key_; | 281 CSSM_KEY public_key_; |
277 #endif | 282 #endif |
278 | 283 |
279 DISALLOW_COPY_AND_ASSIGN(RSAPrivateKey); | 284 DISALLOW_COPY_AND_ASSIGN(RSAPrivateKey); |
280 }; | 285 }; |
281 | 286 |
282 } // namespace crypto | 287 } // namespace crypto |
283 | 288 |
284 #endif // CRYPTO_RSA_PRIVATE_KEY_H_ | 289 #endif // CRYPTO_RSA_PRIVATE_KEY_H_ |
OLD | NEW |