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

Side by Side Diff: base/crypto/rsa_private_key.h

Issue 5047003: Implements RSAPrivateKey for openssl. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: git diff trunk Created 10 years, 1 month 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 | base/crypto/rsa_private_key_openssl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #ifndef BASE_CRYPTO_RSA_PRIVATE_KEY_H_ 5 #ifndef BASE_CRYPTO_RSA_PRIVATE_KEY_H_
6 #define BASE_CRYPTO_RSA_PRIVATE_KEY_H_ 6 #define BASE_CRYPTO_RSA_PRIVATE_KEY_H_
7 #pragma once 7 #pragma once
8 8
9 #include "build/build_config.h" 9 #include "build/build_config.h"
10 10
11 #if defined(USE_NSS) 11 #if defined(USE_OPENSSL)
12 // Forward declaration for openssl/*.h
13 typedef struct evp_pkey_st EVP_PKEY;
14 #elif defined(USE_NSS)
12 // Forward declaration. 15 // Forward declaration.
13 struct SECKEYPrivateKeyStr; 16 struct SECKEYPrivateKeyStr;
14 struct SECKEYPublicKeyStr; 17 struct SECKEYPublicKeyStr;
15 #elif defined(OS_MACOSX) 18 #elif defined(OS_MACOSX)
16 #include <Security/cssm.h> 19 #include <Security/cssm.h>
17 #endif 20 #endif
18 21
19 #include <list> 22 #include <list>
20 #include <vector> 23 #include <vector>
21 24
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 #elif defined(OS_MACOSX) 212 #elif defined(OS_MACOSX)
210 CSSM_KEY_PTR key() { return &key_; } 213 CSSM_KEY_PTR key() { return &key_; }
211 #endif 214 #endif
212 215
213 // Exports the private key to a PKCS #1 PrivateKey block. 216 // Exports the private key to a PKCS #1 PrivateKey block.
214 bool ExportPrivateKey(std::vector<uint8>* output); 217 bool ExportPrivateKey(std::vector<uint8>* output);
215 218
216 // Exports the public key to an X509 SubjectPublicKeyInfo block. 219 // Exports the public key to an X509 SubjectPublicKeyInfo block.
217 bool ExportPublicKey(std::vector<uint8>* output); 220 bool ExportPublicKey(std::vector<uint8>* output);
218 221
219 private: 222 private:
220 #if defined(USE_NSS) 223 #if defined(USE_NSS)
221 FRIEND_TEST_ALL_PREFIXES(RSAPrivateKeyNSSTest, FindFromPublicKey); 224 FRIEND_TEST_ALL_PREFIXES(RSAPrivateKeyNSSTest, FindFromPublicKey);
222 FRIEND_TEST_ALL_PREFIXES(RSAPrivateKeyNSSTest, FailedFindFromPublicKey); 225 FRIEND_TEST_ALL_PREFIXES(RSAPrivateKeyNSSTest, FailedFindFromPublicKey);
223 #endif 226 #endif
224 227
225 // Constructor is private. Use one of the Create*() or Find*() 228 // Constructor is private. Use one of the Create*() or Find*()
226 // methods above instead. 229 // methods above instead.
227 RSAPrivateKey(); 230 RSAPrivateKey();
228 231
229 // Shared helper for Create() and CreateSensitive(). 232 // Shared helper for Create() and CreateSensitive().
230 // TODO(cmasone): consider replacing |permanent| and |sensitive| with a 233 // TODO(cmasone): consider replacing |permanent| and |sensitive| with a
231 // flags arg created by ORing together some enumerated values. 234 // flags arg created by ORing together some enumerated values.
232 static RSAPrivateKey* CreateWithParams(uint16 num_bits, 235 static RSAPrivateKey* CreateWithParams(uint16 num_bits,
233 bool permanent, 236 bool permanent,
234 bool sensitive); 237 bool sensitive);
235 238
236 // Shared helper for CreateFromPrivateKeyInfo() and 239 // Shared helper for CreateFromPrivateKeyInfo() and
237 // CreateSensitiveFromPrivateKeyInfo(). 240 // CreateSensitiveFromPrivateKeyInfo().
238 static RSAPrivateKey* CreateFromPrivateKeyInfoWithParams( 241 static RSAPrivateKey* CreateFromPrivateKeyInfoWithParams(
239 const std::vector<uint8>& input, bool permanent, bool sensitive); 242 const std::vector<uint8>& input, bool permanent, bool sensitive);
240 243
241 #if defined(USE_NSS) 244 #if defined(USE_OPENSSL)
245 EVP_PKEY* key_;
246 #elif defined(USE_NSS)
242 SECKEYPrivateKeyStr* key_; 247 SECKEYPrivateKeyStr* key_;
243 SECKEYPublicKeyStr* public_key_; 248 SECKEYPublicKeyStr* public_key_;
244 #elif defined(OS_WIN) 249 #elif defined(OS_WIN)
245 bool InitProvider(); 250 bool InitProvider();
246 251
247 ScopedHCRYPTPROV provider_; 252 ScopedHCRYPTPROV provider_;
248 ScopedHCRYPTKEY key_; 253 ScopedHCRYPTKEY key_;
249 #elif defined(OS_MACOSX) 254 #elif defined(OS_MACOSX)
250 CSSM_KEY key_; 255 CSSM_KEY key_;
251 #endif 256 #endif
252 257
253 DISALLOW_COPY_AND_ASSIGN(RSAPrivateKey); 258 DISALLOW_COPY_AND_ASSIGN(RSAPrivateKey);
254 }; 259 };
255 260
256 } // namespace base 261 } // namespace base
257 262
258 #endif // BASE_CRYPTO_RSA_PRIVATE_KEY_H_ 263 #endif // BASE_CRYPTO_RSA_PRIVATE_KEY_H_
OLDNEW
« no previous file with comments | « no previous file | base/crypto/rsa_private_key_openssl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698