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

Side by Side Diff: crypto/rsa_private_key.h

Issue 6805019: Move crypto files out of base, to a top level directory. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 8 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 CRYPTO_RSA_PRIVATE_KEY_H_
6 #define BASE_CRYPTO_RSA_PRIVATE_KEY_H_ 6 #define 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_OPENSSL) 11 #if defined(USE_OPENSSL)
12 // Forward declaration for openssl/*.h 12 // Forward declaration for openssl/*.h
13 typedef struct evp_pkey_st EVP_PKEY; 13 typedef struct evp_pkey_st EVP_PKEY;
14 #elif defined(USE_NSS) 14 #elif defined(USE_NSS)
15 // Forward declaration. 15 // Forward declaration.
16 struct SECKEYPrivateKeyStr; 16 struct SECKEYPrivateKeyStr;
17 struct SECKEYPublicKeyStr; 17 struct SECKEYPublicKeyStr;
18 #elif defined(OS_MACOSX) 18 #elif defined(OS_MACOSX)
19 #include <Security/cssm.h> 19 #include <Security/cssm.h>
20 #endif 20 #endif
21 21
22 #include <list> 22 #include <list>
23 #include <vector> 23 #include <vector>
24 24
25 #include "base/base_api.h"
26 #include "base/basictypes.h" 25 #include "base/basictypes.h"
27 26
28 #if defined(OS_WIN) 27 #if defined(OS_WIN)
29 #include "base/crypto/scoped_capi_types.h" 28 #include "crypto/scoped_capi_types.h"
30 #endif 29 #endif
31 #if defined(USE_NSS) 30 #if defined(USE_NSS)
32 #include "base/gtest_prod_util.h" 31 #include "base/gtest_prod_util.h"
33 #endif 32 #endif
34 33
35 namespace base { 34 namespace crypto {
36 35
37 // Used internally by RSAPrivateKey for serializing and deserializing 36 // Used internally by RSAPrivateKey for serializing and deserializing
38 // PKCS #8 PrivateKeyInfo and PublicKeyInfo. 37 // PKCS #8 PrivateKeyInfo and PublicKeyInfo.
39 class BASE_API PrivateKeyInfoCodec { 38 class PrivateKeyInfoCodec {
40 public: 39 public:
41 40
42 // ASN.1 encoding of the AlgorithmIdentifier from PKCS #8. 41 // ASN.1 encoding of the AlgorithmIdentifier from PKCS #8.
43 static const uint8 kRsaAlgorithmIdentifier[]; 42 static const uint8 kRsaAlgorithmIdentifier[];
44 43
45 // ASN.1 tags for some types we use. 44 // ASN.1 tags for some types we use.
46 static const uint8 kBitStringTag = 0x03; 45 static const uint8 kBitStringTag = 0x03;
47 static const uint8 kIntegerTag = 0x02; 46 static const uint8 kIntegerTag = 0x02;
48 static const uint8 kNullTag = 0x05; 47 static const uint8 kNullTag = 0x05;
49 static const uint8 kOctetStringTag = 0x04; 48 static const uint8 kOctetStringTag = 0x04;
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 std::vector<uint8> exponent1_; 163 std::vector<uint8> exponent1_;
165 std::vector<uint8> exponent2_; 164 std::vector<uint8> exponent2_;
166 std::vector<uint8> coefficient_; 165 std::vector<uint8> coefficient_;
167 166
168 DISALLOW_COPY_AND_ASSIGN(PrivateKeyInfoCodec); 167 DISALLOW_COPY_AND_ASSIGN(PrivateKeyInfoCodec);
169 }; 168 };
170 169
171 // Encapsulates an RSA private key. Can be used to generate new keys, export 170 // Encapsulates an RSA private key. Can be used to generate new keys, export
172 // keys to other formats, or to extract a public key. 171 // keys to other formats, or to extract a public key.
173 // TODO(hclam): This class should be ref-counted so it can be reused easily. 172 // TODO(hclam): This class should be ref-counted so it can be reused easily.
174 class BASE_API RSAPrivateKey { 173 class RSAPrivateKey {
175 public: 174 public:
176 ~RSAPrivateKey(); 175 ~RSAPrivateKey();
177 176
178 // Create a new random instance. Can return NULL if initialization fails. 177 // Create a new random instance. Can return NULL if initialization fails.
179 static RSAPrivateKey* Create(uint16 num_bits); 178 static RSAPrivateKey* Create(uint16 num_bits);
180 179
181 // Create a new random instance. Can return NULL if initialization fails. 180 // Create a new random instance. Can return NULL if initialization fails.
182 // The created key is permanent and is not exportable in plaintext form. 181 // The created key is permanent and is not exportable in plaintext form.
183 // 182 //
184 // NOTE: Currently only available if USE_NSS is defined. 183 // NOTE: Currently only available if USE_NSS is defined.
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 ScopedHCRYPTPROV provider_; 261 ScopedHCRYPTPROV provider_;
263 ScopedHCRYPTKEY key_; 262 ScopedHCRYPTKEY key_;
264 #elif defined(OS_MACOSX) 263 #elif defined(OS_MACOSX)
265 CSSM_KEY key_; 264 CSSM_KEY key_;
266 CSSM_KEY public_key_; 265 CSSM_KEY public_key_;
267 #endif 266 #endif
268 267
269 DISALLOW_COPY_AND_ASSIGN(RSAPrivateKey); 268 DISALLOW_COPY_AND_ASSIGN(RSAPrivateKey);
270 }; 269 };
271 270
272 } // namespace base 271 } // namespace crypto
273 272
274 #endif // BASE_CRYPTO_RSA_PRIVATE_KEY_H_ 273 #endif // CRYPTO_RSA_PRIVATE_KEY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698