| OLD | NEW |
| 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 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 #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/basictypes.h" | 25 #include "base/basictypes.h" |
| 26 #include "crypto/crypto_api.h" |
| 26 | 27 |
| 27 #if defined(OS_WIN) | 28 #if defined(OS_WIN) |
| 28 #include "crypto/scoped_capi_types.h" | 29 #include "crypto/scoped_capi_types.h" |
| 29 #endif | 30 #endif |
| 30 #if defined(USE_NSS) | 31 #if defined(USE_NSS) |
| 31 #include "base/gtest_prod_util.h" | 32 #include "base/gtest_prod_util.h" |
| 32 #endif | 33 #endif |
| 33 | 34 |
| 34 namespace crypto { | 35 namespace crypto { |
| 35 | 36 |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 std::vector<uint8> exponent1_; | 164 std::vector<uint8> exponent1_; |
| 164 std::vector<uint8> exponent2_; | 165 std::vector<uint8> exponent2_; |
| 165 std::vector<uint8> coefficient_; | 166 std::vector<uint8> coefficient_; |
| 166 | 167 |
| 167 DISALLOW_COPY_AND_ASSIGN(PrivateKeyInfoCodec); | 168 DISALLOW_COPY_AND_ASSIGN(PrivateKeyInfoCodec); |
| 168 }; | 169 }; |
| 169 | 170 |
| 170 // Encapsulates an RSA private key. Can be used to generate new keys, export | 171 // Encapsulates an RSA private key. Can be used to generate new keys, export |
| 171 // keys to other formats, or to extract a public key. | 172 // keys to other formats, or to extract a public key. |
| 172 // TODO(hclam): This class should be ref-counted so it can be reused easily. | 173 // TODO(hclam): This class should be ref-counted so it can be reused easily. |
| 173 class RSAPrivateKey { | 174 class CRYPTO_API RSAPrivateKey { |
| 174 public: | 175 public: |
| 175 ~RSAPrivateKey(); | 176 ~RSAPrivateKey(); |
| 176 | 177 |
| 177 // Create a new random instance. Can return NULL if initialization fails. | 178 // Create a new random instance. Can return NULL if initialization fails. |
| 178 static RSAPrivateKey* Create(uint16 num_bits); | 179 static RSAPrivateKey* Create(uint16 num_bits); |
| 179 | 180 |
| 180 // Create a new random instance. Can return NULL if initialization fails. | 181 // Create a new random instance. Can return NULL if initialization fails. |
| 181 // The created key is permanent and is not exportable in plaintext form. | 182 // The created key is permanent and is not exportable in plaintext form. |
| 182 // | 183 // |
| 183 // NOTE: Currently only available if USE_NSS is defined. | 184 // NOTE: Currently only available if USE_NSS is defined. |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 CSSM_KEY key_; | 265 CSSM_KEY key_; |
| 265 CSSM_KEY public_key_; | 266 CSSM_KEY public_key_; |
| 266 #endif | 267 #endif |
| 267 | 268 |
| 268 DISALLOW_COPY_AND_ASSIGN(RSAPrivateKey); | 269 DISALLOW_COPY_AND_ASSIGN(RSAPrivateKey); |
| 269 }; | 270 }; |
| 270 | 271 |
| 271 } // namespace crypto | 272 } // namespace crypto |
| 272 | 273 |
| 273 #endif // CRYPTO_RSA_PRIVATE_KEY_H_ | 274 #endif // CRYPTO_RSA_PRIVATE_KEY_H_ |
| OLD | NEW |