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

Side by Side Diff: crypto/ec_private_key_openssl.cc

Issue 66213002: NSS: {EC,RSA}PrivateKey shouldn't call crypto::GetPublicNSSKeySlot or GetPrivateNSSKeySlot. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove the checks again Created 7 years, 1 month 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
« no previous file with comments | « crypto/ec_private_key_nss.cc ('k') | crypto/rsa_private_key.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "crypto/ec_private_key.h" 5 #include "crypto/ec_private_key.h"
6 6
7 #include <openssl/ec.h> 7 #include <openssl/ec.h>
8 #include <openssl/evp.h> 8 #include <openssl/evp.h>
9 #include <openssl/pkcs12.h> 9 #include <openssl/pkcs12.h>
10 #include <openssl/x509.h> 10 #include <openssl/x509.h>
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 94
95 scoped_ptr<ECPrivateKey> result(new ECPrivateKey()); 95 scoped_ptr<ECPrivateKey> result(new ECPrivateKey());
96 result->key_ = EVP_PKEY_new(); 96 result->key_ = EVP_PKEY_new();
97 if (!result->key_ || !EVP_PKEY_set1_EC_KEY(result->key_, ec_key.get())) 97 if (!result->key_ || !EVP_PKEY_set1_EC_KEY(result->key_, ec_key.get()))
98 return NULL; 98 return NULL;
99 99
100 return result.release(); 100 return result.release();
101 } 101 }
102 102
103 // static 103 // static
104 ECPrivateKey* ECPrivateKey::CreateSensitive() {
105 NOTIMPLEMENTED();
106 return NULL;
107 }
108
109 // static
110 ECPrivateKey* ECPrivateKey::CreateFromEncryptedPrivateKeyInfo( 104 ECPrivateKey* ECPrivateKey::CreateFromEncryptedPrivateKeyInfo(
111 const std::string& password, 105 const std::string& password,
112 const std::vector<uint8>& encrypted_private_key_info, 106 const std::vector<uint8>& encrypted_private_key_info,
113 const std::vector<uint8>& subject_public_key_info) { 107 const std::vector<uint8>& subject_public_key_info) {
114 // NOTE: The |subject_public_key_info| can be ignored here, it is only 108 // NOTE: The |subject_public_key_info| can be ignored here, it is only
115 // useful for the NSS implementation (which uses the public key's SHA1 109 // useful for the NSS implementation (which uses the public key's SHA1
116 // as a lookup key when storing the private one in its store). 110 // as a lookup key when storing the private one in its store).
117 if (encrypted_private_key_info.empty()) 111 if (encrypted_private_key_info.empty())
118 return NULL; 112 return NULL;
119 113
(...skipping 23 matching lines...) Expand all
143 137
144 // Create a new EVP_PKEY for it. 138 // Create a new EVP_PKEY for it.
145 scoped_ptr<ECPrivateKey> result(new ECPrivateKey); 139 scoped_ptr<ECPrivateKey> result(new ECPrivateKey);
146 result->key_ = EVP_PKCS82PKEY(p8_decrypted.get()); 140 result->key_ = EVP_PKCS82PKEY(p8_decrypted.get());
147 if (!result->key_) 141 if (!result->key_)
148 return NULL; 142 return NULL;
149 143
150 return result.release(); 144 return result.release();
151 } 145 }
152 146
153 // static
154 ECPrivateKey* ECPrivateKey::CreateSensitiveFromEncryptedPrivateKeyInfo(
155 const std::string& password,
156 const std::vector<uint8>& encrypted_private_key_info,
157 const std::vector<uint8>& subject_public_key_info) {
158 NOTIMPLEMENTED();
159 return NULL;
160 }
161
162 bool ECPrivateKey::ExportEncryptedPrivateKey( 147 bool ECPrivateKey::ExportEncryptedPrivateKey(
163 const std::string& password, 148 const std::string& password,
164 int iterations, 149 int iterations,
165 std::vector<uint8>* output) { 150 std::vector<uint8>* output) {
166 OpenSSLErrStackTracer err_tracer(FROM_HERE); 151 OpenSSLErrStackTracer err_tracer(FROM_HERE);
167 // Convert into a PKCS#8 object. 152 // Convert into a PKCS#8 object.
168 ScopedOpenSSL<PKCS8_PRIV_KEY_INFO, PKCS8_PRIV_KEY_INFO_free> pkcs8( 153 ScopedOpenSSL<PKCS8_PRIV_KEY_INFO, PKCS8_PRIV_KEY_INFO_free> pkcs8(
169 EVP_PKEY2PKCS8(key_)); 154 EVP_PKEY2PKCS8(key_));
170 if (!pkcs8.get()) 155 if (!pkcs8.get())
171 return false; 156 return false;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 OpenSSLErrStackTracer err_tracer(FROM_HERE); 195 OpenSSLErrStackTracer err_tracer(FROM_HERE);
211 ScopedOpenSSL<EC_KEY, EC_KEY_free> ec_key(EVP_PKEY_get1_EC_KEY(key_)); 196 ScopedOpenSSL<EC_KEY, EC_KEY_free> ec_key(EVP_PKEY_get1_EC_KEY(key_));
212 return ExportKey(ec_key.get(), 197 return ExportKey(ec_key.get(),
213 reinterpret_cast<ExportDataFunction>(i2d_ECParameters), 198 reinterpret_cast<ExportDataFunction>(i2d_ECParameters),
214 output); 199 output);
215 } 200 }
216 201
217 ECPrivateKey::ECPrivateKey() : key_(NULL) {} 202 ECPrivateKey::ECPrivateKey() : key_(NULL) {}
218 203
219 } // namespace crypto 204 } // namespace crypto
OLDNEW
« no previous file with comments | « crypto/ec_private_key_nss.cc ('k') | crypto/rsa_private_key.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698