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

Side by Side Diff: crypto/ec_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_EC_PRIVATE_KEY_H_ 5 #ifndef CRYPTO_EC_PRIVATE_KEY_H_
6 #define CRYPTO_EC_PRIVATE_KEY_H_ 6 #define CRYPTO_EC_PRIVATE_KEY_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 24 matching lines...) Expand all
35 ~ECPrivateKey(); 35 ~ECPrivateKey();
36 36
37 // Returns whether the system supports elliptic curve cryptography. 37 // Returns whether the system supports elliptic curve cryptography.
38 static bool IsSupported(); 38 static bool IsSupported();
39 39
40 // Creates a new random instance. Can return NULL if initialization fails. 40 // Creates a new random instance. Can return NULL if initialization fails.
41 // The created key will use the NIST P-256 curve. 41 // The created key will use the NIST P-256 curve.
42 // TODO(mattm): Add a curve parameter. 42 // TODO(mattm): Add a curve parameter.
43 static ECPrivateKey* Create(); 43 static ECPrivateKey* Create();
44 44
45 #if defined(USE_NSS)
46 // Creates a new random instance in |slot|. Can return NULL if initialization
47 // fails. The created key is permanent and is not exportable in plaintext
48 // form.
49 static ECPrivateKey* CreateSensitive(PK11SlotInfo* slot);
50 #endif
51
52 // Creates a new instance by importing an existing key pair. 45 // Creates a new instance by importing an existing key pair.
53 // The key pair is given as an ASN.1-encoded PKCS #8 EncryptedPrivateKeyInfo 46 // The key pair is given as an ASN.1-encoded PKCS #8 EncryptedPrivateKeyInfo
54 // block and an X.509 SubjectPublicKeyInfo block. 47 // block and an X.509 SubjectPublicKeyInfo block.
55 // Returns NULL if initialization fails. 48 // Returns NULL if initialization fails.
56 static ECPrivateKey* CreateFromEncryptedPrivateKeyInfo( 49 static ECPrivateKey* CreateFromEncryptedPrivateKeyInfo(
57 const std::string& password, 50 const std::string& password,
58 const std::vector<uint8>& encrypted_private_key_info, 51 const std::vector<uint8>& encrypted_private_key_info,
59 const std::vector<uint8>& subject_public_key_info); 52 const std::vector<uint8>& subject_public_key_info);
60 53
61 #if defined(USE_NSS)
62 // Creates a new instance in |slot| by importing an existing key pair.
63 // The key pair is given as an ASN.1-encoded PKCS #8 EncryptedPrivateKeyInfo
64 // block and an X.509 SubjectPublicKeyInfo block.
65 // This can return NULL if initialization fails. The created key is permanent
66 // and is not exportable in plaintext form.
67 static ECPrivateKey* CreateSensitiveFromEncryptedPrivateKeyInfo(
68 PK11SlotInfo* slot,
69 const std::string& password,
70 const std::vector<uint8>& encrypted_private_key_info,
71 const std::vector<uint8>& subject_public_key_info);
72 #endif
73
74 #if !defined(USE_OPENSSL) 54 #if !defined(USE_OPENSSL)
75 // Imports the key pair into |slot| and returns in |public_key| and |key|. 55 // Imports the key pair into |slot| and returns in |public_key| and |key|.
76 // Shortcut for code that needs to keep a reference directly to NSS types 56 // Shortcut for code that needs to keep a reference directly to NSS types
77 // without having to create a ECPrivateKey object and make a copy of them. 57 // without having to create a ECPrivateKey object and make a copy of them.
78 // TODO(mattm): move this function to some NSS util file. 58 // TODO(mattm): move this function to some NSS util file.
79 static bool ImportFromEncryptedPrivateKeyInfo( 59 static bool ImportFromEncryptedPrivateKeyInfo(
80 PK11SlotInfo* slot, 60 PK11SlotInfo* slot,
81 const std::string& password, 61 const std::string& password,
82 const uint8* encrypted_private_key_info, 62 const uint8* encrypted_private_key_info,
83 size_t encrypted_private_key_info_len, 63 size_t encrypted_private_key_info_len,
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 ECPrivateKey(); 103 ECPrivateKey();
124 104
125 #if !defined(USE_OPENSSL) 105 #if !defined(USE_OPENSSL)
126 // Shared helper for Create() and CreateSensitive(). 106 // Shared helper for Create() and CreateSensitive().
127 // TODO(cmasone): consider replacing |permanent| and |sensitive| with a 107 // TODO(cmasone): consider replacing |permanent| and |sensitive| with a
128 // flags arg created by ORing together some enumerated values. 108 // flags arg created by ORing together some enumerated values.
129 static ECPrivateKey* CreateWithParams(PK11SlotInfo* slot, 109 static ECPrivateKey* CreateWithParams(PK11SlotInfo* slot,
130 bool permanent, 110 bool permanent,
131 bool sensitive); 111 bool sensitive);
132 112
133 // Shared helper for CreateFromEncryptedPrivateKeyInfo() and 113 // Helper for CreateFromEncryptedPrivateKeyInfo().
134 // CreateSensitiveFromEncryptedPrivateKeyInfo().
135 static ECPrivateKey* CreateFromEncryptedPrivateKeyInfoWithParams( 114 static ECPrivateKey* CreateFromEncryptedPrivateKeyInfoWithParams(
136 PK11SlotInfo* slot, 115 PK11SlotInfo* slot,
137 const std::string& password, 116 const std::string& password,
138 const std::vector<uint8>& encrypted_private_key_info, 117 const std::vector<uint8>& encrypted_private_key_info,
139 const std::vector<uint8>& subject_public_key_info, 118 const std::vector<uint8>& subject_public_key_info,
140 bool permanent, 119 bool permanent,
141 bool sensitive); 120 bool sensitive);
142 #endif 121 #endif
143 122
144 #if defined(USE_OPENSSL) 123 #if defined(USE_OPENSSL)
145 EVP_PKEY* key_; 124 EVP_PKEY* key_;
146 #else 125 #else
147 SECKEYPrivateKey* key_; 126 SECKEYPrivateKey* key_;
148 SECKEYPublicKey* public_key_; 127 SECKEYPublicKey* public_key_;
149 #endif 128 #endif
150 129
151 DISALLOW_COPY_AND_ASSIGN(ECPrivateKey); 130 DISALLOW_COPY_AND_ASSIGN(ECPrivateKey);
152 }; 131 };
153 132
154 133
155 } // namespace crypto 134 } // namespace crypto
156 135
157 #endif // CRYPTO_EC_PRIVATE_KEY_H_ 136 #endif // CRYPTO_EC_PRIVATE_KEY_H_
OLDNEW
« build/linux/system.gyp ('K') | « crypto/crypto.gyp ('k') | crypto/ec_private_key_nss.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698