Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(38)

Side by Side Diff: crypto/rsa_private_key.h

Issue 14941007: Add RSAPrivateKey::CreateFromKeypair() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: API fixups Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | crypto/rsa_private_key_nss.cc » ('j') | crypto/rsa_private_key_nss.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 typedef struct SECKEYPrivateKeyStr SECKEYPrivateKey;
16 struct SECKEYPublicKeyStr; 16 typedef struct SECKEYPublicKeyStr SECKEYPublicKey;
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
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 // Create a new instance by referencing an existing private key
205 // structure. Does not import the key.
206 static RSAPrivateKey* CreateFromKey(SECKEYPrivateKey* key);
207 #endif
208
203 // Import an existing public key, and then search for the private 209 // 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 210 // half in the key database. The format of the public key blob is is
205 // an X509 SubjectPublicKeyInfo block. This can return NULL if 211 // an X509 SubjectPublicKeyInfo block. This can return NULL if
206 // initialization fails or the private key cannot be found. The 212 // initialization fails or the private key cannot be found. The
207 // caller takes ownership of the returned object, but nothing new is 213 // caller takes ownership of the returned object, but nothing new is
208 // created in the key database. 214 // created in the key database.
209 // 215 //
210 // NOTE: Currently only available if USE_NSS is defined. 216 // NOTE: Currently only available if USE_NSS is defined.
211 static RSAPrivateKey* FindFromPublicKeyInfo( 217 static RSAPrivateKey* FindFromPublicKeyInfo(
212 const std::vector<uint8>& input); 218 const std::vector<uint8>& input);
213 219
214 #if defined(USE_OPENSSL) 220 #if defined(USE_OPENSSL)
215 EVP_PKEY* key() { return key_; } 221 EVP_PKEY* key() { return key_; }
216 #elif defined(USE_NSS) 222 #elif defined(USE_NSS)
217 SECKEYPrivateKeyStr* key() { return key_; } 223 SECKEYPrivateKey* key() { return key_; }
218 SECKEYPublicKeyStr* public_key() { return public_key_; } 224 SECKEYPublicKey* public_key() { return public_key_; }
219 #elif defined(OS_WIN) 225 #elif defined(OS_WIN)
220 HCRYPTPROV provider() { return provider_; } 226 HCRYPTPROV provider() { return provider_; }
221 HCRYPTKEY key() { return key_; } 227 HCRYPTKEY key() { return key_; }
222 #elif defined(OS_IOS) 228 #elif defined(OS_IOS)
223 SecKeyRef key() { return key_; } 229 SecKeyRef key() { return key_; }
224 SecKeyRef public_key() { return public_key_; } 230 SecKeyRef public_key() { return public_key_; }
225 #elif defined(OS_MACOSX) 231 #elif defined(OS_MACOSX)
226 CSSM_KEY_PTR key() { return &key_; } 232 CSSM_KEY_PTR key() { return &key_; }
227 CSSM_KEY_PTR public_key() { return &public_key_; } 233 CSSM_KEY_PTR public_key() { return &public_key_; }
228 #endif 234 #endif
(...skipping 25 matching lines...) Expand all
254 bool sensitive); 260 bool sensitive);
255 261
256 // Shared helper for CreateFromPrivateKeyInfo() and 262 // Shared helper for CreateFromPrivateKeyInfo() and
257 // CreateSensitiveFromPrivateKeyInfo(). 263 // CreateSensitiveFromPrivateKeyInfo().
258 static RSAPrivateKey* CreateFromPrivateKeyInfoWithParams( 264 static RSAPrivateKey* CreateFromPrivateKeyInfoWithParams(
259 const std::vector<uint8>& input, bool permanent, bool sensitive); 265 const std::vector<uint8>& input, bool permanent, bool sensitive);
260 266
261 #if defined(USE_OPENSSL) 267 #if defined(USE_OPENSSL)
262 EVP_PKEY* key_; 268 EVP_PKEY* key_;
263 #elif defined(USE_NSS) 269 #elif defined(USE_NSS)
264 SECKEYPrivateKeyStr* key_; 270 SECKEYPrivateKey* key_;
265 SECKEYPublicKeyStr* public_key_; 271 SECKEYPublicKey* public_key_;
266 #elif defined(OS_WIN) 272 #elif defined(OS_WIN)
267 bool InitProvider(); 273 bool InitProvider();
268 274
269 ScopedHCRYPTPROV provider_; 275 ScopedHCRYPTPROV provider_;
270 ScopedHCRYPTKEY key_; 276 ScopedHCRYPTKEY key_;
271 #elif defined(OS_IOS) 277 #elif defined(OS_IOS)
272 SecKeyRef key_; 278 SecKeyRef key_;
273 SecKeyRef public_key_; 279 SecKeyRef public_key_;
274 #elif defined(OS_MACOSX) 280 #elif defined(OS_MACOSX)
275 CSSM_KEY key_; 281 CSSM_KEY key_;
276 CSSM_KEY public_key_; 282 CSSM_KEY public_key_;
277 #endif 283 #endif
278 284
279 DISALLOW_COPY_AND_ASSIGN(RSAPrivateKey); 285 DISALLOW_COPY_AND_ASSIGN(RSAPrivateKey);
280 }; 286 };
281 287
282 } // namespace crypto 288 } // namespace crypto
283 289
284 #endif // CRYPTO_RSA_PRIVATE_KEY_H_ 290 #endif // CRYPTO_RSA_PRIVATE_KEY_H_
OLDNEW
« no previous file with comments | « no previous file | crypto/rsa_private_key_nss.cc » ('j') | crypto/rsa_private_key_nss.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698