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

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: Add Unittest 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
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::CreateFromKeypair(
85 SECKEYPrivateKeyStr* key,
86 SECKEYPublicKeyStr* public_key) {
Ryan Sleevi 2013/05/07 19:45:23 From an API perspective, there should be a little
Chris Masone 2013/05/07 21:00:39 Done.
87 RSAPrivateKey* copy = new RSAPrivateKey();
88 copy->key_ = SECKEY_CopyPrivateKey(key);
89 copy->public_key_ = SECKEY_CopyPublicKey(public_key);
90 return copy;
91 }
92
93 // static
84 RSAPrivateKey* RSAPrivateKey::FindFromPublicKeyInfo( 94 RSAPrivateKey* RSAPrivateKey::FindFromPublicKeyInfo(
85 const std::vector<uint8>& input) { 95 const std::vector<uint8>& input) {
86 EnsureNSSInit(); 96 EnsureNSSInit();
87 97
88 scoped_ptr<RSAPrivateKey> result(new RSAPrivateKey); 98 scoped_ptr<RSAPrivateKey> result(new RSAPrivateKey);
89 99
90 // First, decode and save the public key. 100 // First, decode and save the public key.
91 SECItem key_der; 101 SECItem key_der;
92 key_der.type = siBuffer; 102 key_der.type = siBuffer;
93 key_der.data = const_cast<unsigned char*>(&input[0]); 103 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_); 252 result->public_key_ = SECKEY_ConvertToPublicKey(result->key_);
243 if (!result->public_key_) { 253 if (!result->public_key_) {
244 NOTREACHED(); 254 NOTREACHED();
245 return NULL; 255 return NULL;
246 } 256 }
247 257
248 return result.release(); 258 return result.release();
249 } 259 }
250 260
251 } // namespace crypto 261 } // namespace crypto
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698