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

Side by Side Diff: crypto/rsa_private_key.h

Issue 881213004: Support building BoringSSL with NSS certificates. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
OLDNEW
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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 173
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_OPENSSL)
184 // Create a new instance from an existing EVP_PKEY, taking a
185 // reference to it. |key| must be an RSA key. Returns NULL on
186 // failure.
187 static RSAPrivateKey* CreateFromKey(EVP_PKEY* key);
188 #elif defined(USE_NSS)
184 // Create a new random instance in |slot|. Can return NULL if initialization 189 // 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 190 // fails. The created key is permanent and is not exportable in plaintext
186 // form. 191 // form.
187 static RSAPrivateKey* CreateSensitive(PK11SlotInfo* slot, uint16 num_bits); 192 static RSAPrivateKey* CreateSensitive(PK11SlotInfo* slot, uint16 num_bits);
188 193
189 // Create a new instance in |slot| by importing an existing private key. The 194 // 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 195 // format is an ASN.1-encoded PrivateKeyInfo block from PKCS #8. This can
191 // return NULL if initialization fails. 196 // return NULL if initialization fails.
192 // The created key is permanent and is not exportable in plaintext form. 197 // The created key is permanent and is not exportable in plaintext form.
193 static RSAPrivateKey* CreateSensitiveFromPrivateKeyInfo( 198 static RSAPrivateKey* CreateSensitiveFromPrivateKeyInfo(
(...skipping 15 matching lines...) Expand all
209 214
210 // Import an existing public key, and then search for the private 215 // Import an existing public key, and then search for the private
211 // half in the slot specified by |slot|. The format of the public 216 // half in the slot specified by |slot|. The format of the public
212 // key blob is is an X509 SubjectPublicKeyInfo block. This can return 217 // key blob is is an X509 SubjectPublicKeyInfo block. This can return
213 // NULL if initialization fails or the private key cannot be found. 218 // NULL if initialization fails or the private key cannot be found.
214 // The caller takes ownership of the returned object, but nothing new 219 // The caller takes ownership of the returned object, but nothing new
215 // is created in the slot. 220 // is created in the slot.
216 static RSAPrivateKey* FindFromPublicKeyInfoInSlot( 221 static RSAPrivateKey* FindFromPublicKeyInfoInSlot(
217 const std::vector<uint8>& input, 222 const std::vector<uint8>& input,
218 PK11SlotInfo* slot); 223 PK11SlotInfo* slot);
219 #elif defined(USE_OPENSSL)
220 // Create a new instance from an existing EVP_PKEY, taking a
221 // reference to it. |key| must be an RSA key. Returns NULL on
222 // failure.
223 static RSAPrivateKey* CreateFromKey(EVP_PKEY* key);
224
225 #endif 224 #endif
226 225
227 #if defined(USE_OPENSSL) 226 #if defined(USE_OPENSSL)
228 EVP_PKEY* key() { return key_; } 227 EVP_PKEY* key() { return key_; }
229 #else 228 #else
230 SECKEYPrivateKey* key() { return key_; } 229 SECKEYPrivateKey* key() { return key_; }
231 SECKEYPublicKey* public_key() { return public_key_; } 230 SECKEYPublicKey* public_key() { return public_key_; }
232 #endif 231 #endif
233 232
234 // Creates a copy of the object. 233 // Creates a copy of the object.
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 SECKEYPrivateKey* key_; 283 SECKEYPrivateKey* key_;
285 SECKEYPublicKey* public_key_; 284 SECKEYPublicKey* public_key_;
286 #endif 285 #endif
287 286
288 DISALLOW_COPY_AND_ASSIGN(RSAPrivateKey); 287 DISALLOW_COPY_AND_ASSIGN(RSAPrivateKey);
289 }; 288 };
290 289
291 } // namespace crypto 290 } // namespace crypto
292 291
293 #endif // CRYPTO_RSA_PRIVATE_KEY_H_ 292 #endif // CRYPTO_RSA_PRIVATE_KEY_H_
OLDNEW
« build/linux/system.gyp ('K') | « crypto/ec_private_key_nss.cc ('k') | net/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698