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

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

Issue 6312157: Add ability to create self signed certs to mac. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More code cleanup Created 9 years, 10 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 ~PrivateKeyInfoCodec(); 57 ~PrivateKeyInfoCodec();
58 58
59 // Exports the contents of the integer components to the ASN.1 DER encoding 59 // Exports the contents of the integer components to the ASN.1 DER encoding
60 // of the PrivateKeyInfo structure to |output|. 60 // of the PrivateKeyInfo structure to |output|.
61 bool Export(std::vector<uint8>* output); 61 bool Export(std::vector<uint8>* output);
62 62
63 // Exports the contents of the integer components to the ASN.1 DER encoding 63 // Exports the contents of the integer components to the ASN.1 DER encoding
64 // of the PublicKeyInfo structure to |output|. 64 // of the PublicKeyInfo structure to |output|.
65 bool ExportPublicKeyInfo(std::vector<uint8>* output); 65 bool ExportPublicKeyInfo(std::vector<uint8>* output);
66 66
67 // Exports the contents of the integer components to the ASN.1 DER encoding
68 // of the RSAPublicKey structure to |output|.
69 bool ExportPublicKey(std::vector<uint8>* output);
70
67 // Parses the ASN.1 DER encoding of the PrivateKeyInfo structure in |input| 71 // Parses the ASN.1 DER encoding of the PrivateKeyInfo structure in |input|
68 // and populates the integer components with |big_endian_| byte-significance. 72 // and populates the integer components with |big_endian_| byte-significance.
69 // IMPORTANT NOTE: This is currently *not* security-approved for importing 73 // IMPORTANT NOTE: This is currently *not* security-approved for importing
70 // keys from unstrusted sources. 74 // keys from unstrusted sources.
71 bool Import(const std::vector<uint8>& input); 75 bool Import(const std::vector<uint8>& input);
72 76
73 // Accessors to the contents of the integer components of the PrivateKeyInfo 77 // Accessors to the contents of the integer components of the PrivateKeyInfo
74 // structure. 78 // structure.
75 std::vector<uint8>* modulus() { return &modulus_; }; 79 std::vector<uint8>* modulus() { return &modulus_; };
76 std::vector<uint8>* public_exponent() { return &public_exponent_; }; 80 std::vector<uint8>* public_exponent() { return &public_exponent_; };
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 #if defined(USE_OPENSSL) 212 #if defined(USE_OPENSSL)
209 EVP_PKEY* key() { return key_; } 213 EVP_PKEY* key() { return key_; }
210 #elif defined(USE_NSS) 214 #elif defined(USE_NSS)
211 SECKEYPrivateKeyStr* key() { return key_; } 215 SECKEYPrivateKeyStr* key() { return key_; }
212 SECKEYPublicKeyStr* public_key() { return public_key_; } 216 SECKEYPublicKeyStr* public_key() { return public_key_; }
213 #elif defined(OS_WIN) 217 #elif defined(OS_WIN)
214 HCRYPTPROV provider() { return provider_; } 218 HCRYPTPROV provider() { return provider_; }
215 HCRYPTKEY key() { return key_; } 219 HCRYPTKEY key() { return key_; }
216 #elif defined(OS_MACOSX) 220 #elif defined(OS_MACOSX)
217 CSSM_KEY_PTR key() { return &key_; } 221 CSSM_KEY_PTR key() { return &key_; }
222 CSSM_KEY_PTR public_key() { return &public_key_; }
218 #endif 223 #endif
219 224
220 // Exports the private key to a PKCS #1 PrivateKey block. 225 // Exports the private key to a PKCS #1 PrivateKey block.
221 bool ExportPrivateKey(std::vector<uint8>* output); 226 bool ExportPrivateKey(std::vector<uint8>* output);
222 227
223 // Exports the public key to an X509 SubjectPublicKeyInfo block. 228 // Exports the public key to an X509 SubjectPublicKeyInfo block.
224 bool ExportPublicKey(std::vector<uint8>* output); 229 bool ExportPublicKey(std::vector<uint8>* output);
225 230
226 private: 231 private:
227 #if defined(USE_NSS) 232 #if defined(USE_NSS)
(...skipping 22 matching lines...) Expand all
250 #elif defined(USE_NSS) 255 #elif defined(USE_NSS)
251 SECKEYPrivateKeyStr* key_; 256 SECKEYPrivateKeyStr* key_;
252 SECKEYPublicKeyStr* public_key_; 257 SECKEYPublicKeyStr* public_key_;
253 #elif defined(OS_WIN) 258 #elif defined(OS_WIN)
254 bool InitProvider(); 259 bool InitProvider();
255 260
256 ScopedHCRYPTPROV provider_; 261 ScopedHCRYPTPROV provider_;
257 ScopedHCRYPTKEY key_; 262 ScopedHCRYPTKEY key_;
258 #elif defined(OS_MACOSX) 263 #elif defined(OS_MACOSX)
259 CSSM_KEY key_; 264 CSSM_KEY key_;
265 CSSM_KEY public_key_;
260 #endif 266 #endif
261 267
262 DISALLOW_COPY_AND_ASSIGN(RSAPrivateKey); 268 DISALLOW_COPY_AND_ASSIGN(RSAPrivateKey);
263 }; 269 };
264 270
265 } // namespace base 271 } // namespace base
266 272
267 #endif // BASE_CRYPTO_RSA_PRIVATE_KEY_H_ 273 #endif // BASE_CRYPTO_RSA_PRIVATE_KEY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698