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

Side by Side Diff: crypto/rsa_private_key_openssl.cc

Issue 7342047: Cleanup base/stl_util (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: removed STLAssign* Created 9 years, 5 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 <openssl/evp.h> 7 #include <openssl/evp.h>
8 #include <openssl/pkcs12.h> 8 #include <openssl/pkcs12.h>
9 #include <openssl/rsa.h> 9 #include <openssl/rsa.h>
10 10
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/stl_util-inl.h" 13 #include "base/stl_util.h"
14 #include "crypto/openssl_util.h" 14 #include "crypto/openssl_util.h"
15 15
16 namespace crypto { 16 namespace crypto {
17 17
18 namespace { 18 namespace {
19 19
20 // Function pointer definition, for injecting the required key export function 20 // Function pointer definition, for injecting the required key export function
21 // into ExportKey, below. The supplied function should export EVP_PKEY into 21 // into ExportKey, below. The supplied function should export EVP_PKEY into
22 // the supplied BIO, returning 1 on success or 0 on failure. 22 // the supplied BIO, returning 1 on success or 0 on failure.
23 typedef int (ExportFunction)(BIO*, EVP_PKEY*); 23 typedef int (ExportFunction)(BIO*, EVP_PKEY*);
(...skipping 10 matching lines...) Expand all
34 34
35 int res = export_fn(bio.get(), key); 35 int res = export_fn(bio.get(), key);
36 if (!res) 36 if (!res)
37 return false; 37 return false;
38 38
39 char* data = NULL; 39 char* data = NULL;
40 long len = BIO_get_mem_data(bio.get(), &data); 40 long len = BIO_get_mem_data(bio.get(), &data);
41 if (!data || len < 0) 41 if (!data || len < 0)
42 return false; 42 return false;
43 43
44 STLAssignToVector(output, reinterpret_cast<const uint8*>(data), len); 44 std::vector<uint8> for_output(data, data + len);
45 output->swap(for_output);
45 return true; 46 return true;
46 } 47 }
47 48
48 } // namespace 49 } // namespace
49 50
50 // static 51 // static
51 RSAPrivateKey* RSAPrivateKey::Create(uint16 num_bits) { 52 RSAPrivateKey* RSAPrivateKey::Create(uint16 num_bits) {
52 OpenSSLErrStackTracer err_tracer(FROM_HERE); 53 OpenSSLErrStackTracer err_tracer(FROM_HERE);
53 54
54 ScopedOpenSSL<RSA, RSA_free> rsa_key(RSA_new()); 55 ScopedOpenSSL<RSA, RSA_free> rsa_key(RSA_new());
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 127
127 bool RSAPrivateKey::ExportPrivateKey(std::vector<uint8>* output) { 128 bool RSAPrivateKey::ExportPrivateKey(std::vector<uint8>* output) {
128 return ExportKey(key_, i2d_PKCS8PrivateKeyInfo_bio, output); 129 return ExportKey(key_, i2d_PKCS8PrivateKeyInfo_bio, output);
129 } 130 }
130 131
131 bool RSAPrivateKey::ExportPublicKey(std::vector<uint8>* output) { 132 bool RSAPrivateKey::ExportPublicKey(std::vector<uint8>* output) {
132 return ExportKey(key_, i2d_PUBKEY_bio, output); 133 return ExportKey(key_, i2d_PUBKEY_bio, output);
133 } 134 }
134 135
135 } // namespace crypto 136 } // namespace crypto
OLDNEW
« base/stl_util.h ('K') | « crypto/hmac_openssl.cc ('k') | crypto/sha2.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698