| OLD | NEW |
| 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 #include <list> | 10 #include <list> |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 // Create a new random instance. Can return NULL if initialization fails. | 174 // Create a new random instance. Can return NULL if initialization fails. |
| 175 static RSAPrivateKey* Create(uint16 num_bits); | 175 static RSAPrivateKey* Create(uint16 num_bits); |
| 176 | 176 |
| 177 // Create a new instance by importing an existing private key. The format is | 177 // Create a new instance by importing an existing private key. The format is |
| 178 // an ASN.1-encoded PrivateKeyInfo block from PKCS #8. This can return NULL if | 178 // an ASN.1-encoded PrivateKeyInfo block from PKCS #8. This can return NULL if |
| 179 // initialization fails. | 179 // initialization fails. |
| 180 static RSAPrivateKey* CreateFromPrivateKeyInfo( | 180 static RSAPrivateKey* CreateFromPrivateKeyInfo( |
| 181 const std::vector<uint8>& input); | 181 const std::vector<uint8>& input); |
| 182 | 182 |
| 183 #if defined(USE_NSS) | 183 #if defined(USE_NSS) |
| 184 static uint64 kDefaultPublicExponent; |
| 185 |
| 184 // Create a new random instance in |slot|. Can return NULL if initialization | 186 // Create a new random instance in |slot|. Can return NULL if initialization |
| 185 // fails. The created key is permanent and is not exportable in plaintext | 187 // fails. The created key is permanent and is not exportable in plaintext |
| 186 // form. | 188 // form. |
| 187 static RSAPrivateKey* CreateSensitive(PK11SlotInfo* slot, uint16 num_bits); | 189 static RSAPrivateKey* CreateSensitive(PK11SlotInfo* slot, |
| 190 uint16 num_bits, |
| 191 uint64 public_exponent); |
| 188 | 192 |
| 189 // Create a new instance in |slot| by importing an existing private key. The | 193 // Create a new instance in |slot| by importing an existing private key. The |
| 190 // format is an ASN.1-encoded PrivateKeyInfo block from PKCS #8. This can | 194 // format is an ASN.1-encoded PrivateKeyInfo block from PKCS #8. This can |
| 191 // return NULL if initialization fails. | 195 // return NULL if initialization fails. |
| 192 // The created key is permanent and is not exportable in plaintext form. | 196 // The created key is permanent and is not exportable in plaintext form. |
| 193 static RSAPrivateKey* CreateSensitiveFromPrivateKeyInfo( | 197 static RSAPrivateKey* CreateSensitiveFromPrivateKeyInfo( |
| 194 PK11SlotInfo* slot, | 198 PK11SlotInfo* slot, |
| 195 const std::vector<uint8>& input); | 199 const std::vector<uint8>& input); |
| 196 | 200 |
| 197 // Create a new instance by referencing an existing private key | 201 // Create a new instance by referencing an existing private key |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 // methods above instead. | 248 // methods above instead. |
| 245 RSAPrivateKey(); | 249 RSAPrivateKey(); |
| 246 | 250 |
| 247 #if !defined(USE_OPENSSL) | 251 #if !defined(USE_OPENSSL) |
| 248 // Shared helper for Create() and CreateSensitive(). | 252 // Shared helper for Create() and CreateSensitive(). |
| 249 // TODO(cmasone): consider replacing |permanent| and |sensitive| with a | 253 // TODO(cmasone): consider replacing |permanent| and |sensitive| with a |
| 250 // flags arg created by ORing together some enumerated values. | 254 // flags arg created by ORing together some enumerated values. |
| 251 // Note: |permanent| is only supported when USE_NSS is defined. | 255 // Note: |permanent| is only supported when USE_NSS is defined. |
| 252 static RSAPrivateKey* CreateWithParams(PK11SlotInfo* slot, | 256 static RSAPrivateKey* CreateWithParams(PK11SlotInfo* slot, |
| 253 uint16 num_bits, | 257 uint16 num_bits, |
| 258 uint64 public_exponent, |
| 254 bool permanent, | 259 bool permanent, |
| 255 bool sensitive); | 260 bool sensitive); |
| 256 | 261 |
| 257 // Shared helper for CreateFromPrivateKeyInfo() and | 262 // Shared helper for CreateFromPrivateKeyInfo() and |
| 258 // CreateSensitiveFromPrivateKeyInfo(). | 263 // CreateSensitiveFromPrivateKeyInfo(). |
| 259 // Note: |permanent| is only supported when USE_NSS is defined. | 264 // Note: |permanent| is only supported when USE_NSS is defined. |
| 260 static RSAPrivateKey* CreateFromPrivateKeyInfoWithParams( | 265 static RSAPrivateKey* CreateFromPrivateKeyInfoWithParams( |
| 261 PK11SlotInfo* slot, | 266 PK11SlotInfo* slot, |
| 262 const std::vector<uint8>& input, | 267 const std::vector<uint8>& input, |
| 263 bool permanent, | 268 bool permanent, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 278 SECKEYPrivateKey* key_; | 283 SECKEYPrivateKey* key_; |
| 279 SECKEYPublicKey* public_key_; | 284 SECKEYPublicKey* public_key_; |
| 280 #endif | 285 #endif |
| 281 | 286 |
| 282 DISALLOW_COPY_AND_ASSIGN(RSAPrivateKey); | 287 DISALLOW_COPY_AND_ASSIGN(RSAPrivateKey); |
| 283 }; | 288 }; |
| 284 | 289 |
| 285 } // namespace crypto | 290 } // namespace crypto |
| 286 | 291 |
| 287 #endif // CRYPTO_RSA_PRIVATE_KEY_H_ | 292 #endif // CRYPTO_RSA_PRIVATE_KEY_H_ |
| OLD | NEW |