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

Side by Side Diff: crypto/rsa_private_key_nss.cc

Issue 14941007: Add RSAPrivateKey::CreateFromKeypair() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: API fixups Created 7 years, 7 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
« no previous file with comments | « crypto/rsa_private_key.h ('k') | crypto/rsa_private_key_nss_unittest.cc » ('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) 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 74
75 // static 75 // static
76 RSAPrivateKey* RSAPrivateKey::CreateSensitiveFromPrivateKeyInfo( 76 RSAPrivateKey* RSAPrivateKey::CreateSensitiveFromPrivateKeyInfo(
77 const std::vector<uint8>& input) { 77 const std::vector<uint8>& input) {
78 return CreateFromPrivateKeyInfoWithParams(input, 78 return CreateFromPrivateKeyInfoWithParams(input,
79 PR_TRUE /* permanent */, 79 PR_TRUE /* permanent */,
80 PR_TRUE /* sensitive */); 80 PR_TRUE /* sensitive */);
81 } 81 }
82 82
83 // static 83 // static
84 RSAPrivateKey* RSAPrivateKey::CreateFromKey(SECKEYPrivateKey* key) {
85 DCHECK(key);
86 if (SECKEY_GetPrivateKeyType(key) != rsaKey)
87 return NULL;
88 RSAPrivateKey* copy = new RSAPrivateKey();
89 copy->key_ = SECKEY_CopyPrivateKey(key);
90 copy->public_key_ = SECKEY_ConvertToPublicKey(key);
91 return copy;
Ryan Sleevi 2013/05/07 21:07:50 if (!copy->key_ || !copy->public_key_) { NOTREAC
Chris Masone 2013/05/07 21:16:38 Done.
92 }
93
94 // static
84 RSAPrivateKey* RSAPrivateKey::FindFromPublicKeyInfo( 95 RSAPrivateKey* RSAPrivateKey::FindFromPublicKeyInfo(
85 const std::vector<uint8>& input) { 96 const std::vector<uint8>& input) {
86 EnsureNSSInit(); 97 EnsureNSSInit();
87 98
88 scoped_ptr<RSAPrivateKey> result(new RSAPrivateKey); 99 scoped_ptr<RSAPrivateKey> result(new RSAPrivateKey);
89 100
90 // First, decode and save the public key. 101 // First, decode and save the public key.
91 SECItem key_der; 102 SECItem key_der;
92 key_der.type = siBuffer; 103 key_der.type = siBuffer;
93 key_der.data = const_cast<unsigned char*>(&input[0]); 104 key_der.data = const_cast<unsigned char*>(&input[0]);
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 result->public_key_ = SECKEY_ConvertToPublicKey(result->key_); 253 result->public_key_ = SECKEY_ConvertToPublicKey(result->key_);
243 if (!result->public_key_) { 254 if (!result->public_key_) {
244 NOTREACHED(); 255 NOTREACHED();
245 return NULL; 256 return NULL;
246 } 257 }
247 258
248 return result.release(); 259 return result.release();
249 } 260 }
250 261
251 } // namespace crypto 262 } // namespace crypto
OLDNEW
« no previous file with comments | « crypto/rsa_private_key.h ('k') | crypto/rsa_private_key_nss_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698