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

Side by Side Diff: crypto/rsa_private_key_nss.cc

Issue 36593002: crypto/nss_util: Get TPM slot id, do lookup by id instead of by name. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sandbox debugging crap 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
OLDNEW
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 #include "crypto/rsa_private_key.h" 5 #include "crypto/rsa_private_key.h"
6 6
7 #include <cryptohi.h> 7 #include <cryptohi.h>
8 #include <keyhi.h> 8 #include <keyhi.h>
9 #include <pk11pub.h> 9 #include <pk11pub.h>
10 #include <secmod.h> 10 #include <secmod.h>
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 NOTREACHED(); 92 NOTREACHED();
93 delete copy; 93 delete copy;
94 return NULL; 94 return NULL;
95 } 95 }
96 return copy; 96 return copy;
97 } 97 }
98 98
99 // static 99 // static
100 RSAPrivateKey* RSAPrivateKey::FindFromPublicKeyInfo( 100 RSAPrivateKey* RSAPrivateKey::FindFromPublicKeyInfo(
101 const std::vector<uint8>& input) { 101 const std::vector<uint8>& input) {
102 LOG(ERROR) << "HIIIIIIIIIIIIIIIIIIIIIIIIIII";
102 EnsureNSSInit(); 103 EnsureNSSInit();
103 104
104 scoped_ptr<RSAPrivateKey> result(new RSAPrivateKey); 105 scoped_ptr<RSAPrivateKey> result(new RSAPrivateKey);
105 106
106 // First, decode and save the public key. 107 // First, decode and save the public key.
107 SECItem key_der; 108 SECItem key_der;
108 key_der.type = siBuffer; 109 key_der.type = siBuffer;
109 key_der.data = const_cast<unsigned char*>(&input[0]); 110 key_der.data = const_cast<unsigned char*>(&input[0]);
110 key_der.len = input.size(); 111 key_der.len = input.size();
111 112
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 if (!der_pubkey.get()) { 190 if (!der_pubkey.get()) {
190 NOTREACHED(); 191 NOTREACHED();
191 return false; 192 return false;
192 } 193 }
193 194
194 output->assign(der_pubkey->data, der_pubkey->data + der_pubkey->len); 195 output->assign(der_pubkey->data, der_pubkey->data + der_pubkey->len);
195 return true; 196 return true;
196 } 197 }
197 198
198 RSAPrivateKey::RSAPrivateKey() : key_(NULL), public_key_(NULL) { 199 RSAPrivateKey::RSAPrivateKey() : key_(NULL), public_key_(NULL) {
200 LOG(ERROR) << "HIIIIIIIIIIIIIIIIIIIIIIIIIII";
199 EnsureNSSInit(); 201 EnsureNSSInit();
200 } 202 }
201 203
202 // static 204 // static
203 RSAPrivateKey* RSAPrivateKey::CreateWithParams(uint16 num_bits, 205 RSAPrivateKey* RSAPrivateKey::CreateWithParams(uint16 num_bits,
204 bool permanent, 206 bool permanent,
205 bool sensitive) { 207 bool sensitive) {
206 #if !defined(USE_NSS) 208 #if !defined(USE_NSS)
207 if (permanent) { 209 if (permanent) {
208 NOTIMPLEMENTED(); 210 NOTIMPLEMENTED();
209 return NULL; 211 return NULL;
210 } 212 }
211 #endif 213 #endif
212 214
215 LOG(ERROR) << "HIIIIIIIIIIIIIIIIIIIIIIIIIII";
213 EnsureNSSInit(); 216 EnsureNSSInit();
214 217
215 scoped_ptr<RSAPrivateKey> result(new RSAPrivateKey); 218 scoped_ptr<RSAPrivateKey> result(new RSAPrivateKey);
216 219
217 ScopedPK11Slot slot(permanent ? GetPrivateNSSKeySlot() : 220 ScopedPK11Slot slot(permanent ? GetPrivateNSSKeySlot() :
218 PK11_GetInternalSlot()); 221 PK11_GetInternalSlot());
219 if (!slot.get()) 222 if (!slot.get())
220 return NULL; 223 return NULL;
221 224
222 PK11RSAGenParams param; 225 PK11RSAGenParams param;
(...skipping 18 matching lines...) Expand all
241 #if !defined(USE_NSS) 244 #if !defined(USE_NSS)
242 if (permanent) { 245 if (permanent) {
243 NOTIMPLEMENTED(); 246 NOTIMPLEMENTED();
244 return NULL; 247 return NULL;
245 } 248 }
246 #endif 249 #endif
247 250
248 // This method currently leaks some memory. 251 // This method currently leaks some memory.
249 // See http://crbug.com/34742. 252 // See http://crbug.com/34742.
250 ANNOTATE_SCOPED_MEMORY_LEAK; 253 ANNOTATE_SCOPED_MEMORY_LEAK;
254 LOG(ERROR) << "HIIIIIIIIIIIIIIIIIIIIIIIIIII";
251 EnsureNSSInit(); 255 EnsureNSSInit();
252 256
253 scoped_ptr<RSAPrivateKey> result(new RSAPrivateKey); 257 scoped_ptr<RSAPrivateKey> result(new RSAPrivateKey);
254 258
255 ScopedPK11Slot slot(permanent ? GetPrivateNSSKeySlot() : 259 ScopedPK11Slot slot(permanent ? GetPrivateNSSKeySlot() :
256 PK11_GetInternalSlot()); 260 PK11_GetInternalSlot());
257 if (!slot.get()) 261 if (!slot.get())
258 return NULL; 262 return NULL;
259 263
260 SECItem der_private_key_info; 264 SECItem der_private_key_info;
(...skipping 14 matching lines...) Expand all
275 result->public_key_ = SECKEY_ConvertToPublicKey(result->key_); 279 result->public_key_ = SECKEY_ConvertToPublicKey(result->key_);
276 if (!result->public_key_) { 280 if (!result->public_key_) {
277 NOTREACHED(); 281 NOTREACHED();
278 return NULL; 282 return NULL;
279 } 283 }
280 284
281 return result.release(); 285 return result.release();
282 } 286 }
283 287
284 } // namespace crypto 288 } // namespace crypto
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698