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

Side by Side Diff: crypto/rsa_private_key_nss.cc

Issue 306433003: enterprise.platformKeys: Support the publicExponent parameter. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 | 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 SECKEY_DestroyPublicKey(public_key_); 80 SECKEY_DestroyPublicKey(public_key_);
81 } 81 }
82 82
83 // static 83 // static
84 RSAPrivateKey* RSAPrivateKey::Create(uint16 num_bits) { 84 RSAPrivateKey* RSAPrivateKey::Create(uint16 num_bits) {
85 EnsureNSSInit(); 85 EnsureNSSInit();
86 86
87 ScopedPK11Slot slot(PK11_GetInternalSlot()); 87 ScopedPK11Slot slot(PK11_GetInternalSlot());
88 return CreateWithParams(slot.get(), 88 return CreateWithParams(slot.get(),
89 num_bits, 89 num_bits,
90 kDefaultPublicExponent,
90 false /* not permanent */, 91 false /* not permanent */,
91 false /* not sensitive */); 92 false /* not sensitive */);
92 } 93 }
93 94
94 // static 95 // static
95 RSAPrivateKey* RSAPrivateKey::CreateFromPrivateKeyInfo( 96 RSAPrivateKey* RSAPrivateKey::CreateFromPrivateKeyInfo(
96 const std::vector<uint8>& input) { 97 const std::vector<uint8>& input) {
97 EnsureNSSInit(); 98 EnsureNSSInit();
98 99
99 ScopedPK11Slot slot(PK11_GetInternalSlot()); 100 ScopedPK11Slot slot(PK11_GetInternalSlot());
100 return CreateFromPrivateKeyInfoWithParams( 101 return CreateFromPrivateKeyInfoWithParams(
101 slot.get(), 102 slot.get(),
102 input, 103 input,
103 false /* not permanent */, 104 false /* not permanent */,
104 false /* not sensitive */); 105 false /* not sensitive */);
105 } 106 }
106 107
107 #if defined(USE_NSS) 108 #if defined(USE_NSS)
109 uint64 RSAPrivateKey::kDefaultPublicExponent = 65537L;
Ryan Sleevi 2014/06/03 19:35:29 1) Wrong suffix 2) Wrong format for declaring cons
110
108 // static 111 // static
109 RSAPrivateKey* RSAPrivateKey::CreateSensitive(PK11SlotInfo* slot, 112 RSAPrivateKey* RSAPrivateKey::CreateSensitive(PK11SlotInfo* slot,
110 uint16 num_bits) { 113 uint16 num_bits,
114 uint64 public_exponent) {
111 return CreateWithParams(slot, 115 return CreateWithParams(slot,
112 num_bits, 116 num_bits,
117 public_exponent,
113 true /* permanent */, 118 true /* permanent */,
114 true /* sensitive */); 119 true /* sensitive */);
115 } 120 }
116 121
117 // static 122 // static
118 RSAPrivateKey* RSAPrivateKey::CreateSensitiveFromPrivateKeyInfo( 123 RSAPrivateKey* RSAPrivateKey::CreateSensitiveFromPrivateKeyInfo(
119 PK11SlotInfo* slot, 124 PK11SlotInfo* slot,
120 const std::vector<uint8>& input) { 125 const std::vector<uint8>& input) {
121 return CreateFromPrivateKeyInfoWithParams(slot, 126 return CreateFromPrivateKeyInfoWithParams(slot,
122 input, 127 input,
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 return true; 242 return true;
238 } 243 }
239 244
240 RSAPrivateKey::RSAPrivateKey() : key_(NULL), public_key_(NULL) { 245 RSAPrivateKey::RSAPrivateKey() : key_(NULL), public_key_(NULL) {
241 EnsureNSSInit(); 246 EnsureNSSInit();
242 } 247 }
243 248
244 // static 249 // static
245 RSAPrivateKey* RSAPrivateKey::CreateWithParams(PK11SlotInfo* slot, 250 RSAPrivateKey* RSAPrivateKey::CreateWithParams(PK11SlotInfo* slot,
246 uint16 num_bits, 251 uint16 num_bits,
252 uint64 public_exponent,
247 bool permanent, 253 bool permanent,
248 bool sensitive) { 254 bool sensitive) {
249 if (!slot) 255 if (!slot)
250 return NULL; 256 return NULL;
251 257
252 scoped_ptr<RSAPrivateKey> result(new RSAPrivateKey); 258 scoped_ptr<RSAPrivateKey> result(new RSAPrivateKey);
253 259
254 PK11RSAGenParams param; 260 PK11RSAGenParams param;
255 param.keySizeInBits = num_bits; 261 param.keySizeInBits = num_bits;
256 param.pe = 65537L; 262 param.pe = public_exponent;
257 result->key_ = PK11_GenerateKeyPair(slot, 263 result->key_ = PK11_GenerateKeyPair(slot,
258 CKM_RSA_PKCS_KEY_PAIR_GEN, 264 CKM_RSA_PKCS_KEY_PAIR_GEN,
259 &param, 265 &param,
260 &result->public_key_, 266 &result->public_key_,
261 permanent, 267 permanent,
262 sensitive, 268 sensitive,
263 NULL); 269 NULL);
264 if (!result->key_) 270 if (!result->key_)
265 return NULL; 271 return NULL;
266 272
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 if (!result->public_key_) { 318 if (!result->public_key_) {
313 NOTREACHED(); 319 NOTREACHED();
314 return NULL; 320 return NULL;
315 } 321 }
316 322
317 return result.release(); 323 return result.release();
318 } 324 }
319 #endif // defined(USE_NSS) 325 #endif // defined(USE_NSS)
320 326
321 } // namespace crypto 327 } // namespace crypto
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698