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

Side by Side Diff: crypto/ec_private_key_openssl.cc

Issue 1133303003: Add support for crypto::ECPrivateKey::Copy when built with BoringSSL (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: switch back to dup; remove unnecessary check Created 5 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
« no previous file with comments | « crypto/ec_private_key.h ('k') | crypto/ec_private_key_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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/ec_private_key.h" 5 #include "crypto/ec_private_key.h"
6 6
7 #include <openssl/ec.h> 7 #include <openssl/ec.h>
8 #include <openssl/evp.h> 8 #include <openssl/evp.h>
9 #include <openssl/pkcs12.h> 9 #include <openssl/pkcs12.h>
10 #include <openssl/x509.h> 10 #include <openssl/x509.h>
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 return true; 78 return true;
79 } 79 }
80 80
81 } // namespace 81 } // namespace
82 82
83 ECPrivateKey::~ECPrivateKey() { 83 ECPrivateKey::~ECPrivateKey() {
84 if (key_) 84 if (key_)
85 EVP_PKEY_free(key_); 85 EVP_PKEY_free(key_);
86 } 86 }
87 87
88 ECPrivateKey* ECPrivateKey::Copy() const {
89 scoped_ptr<ECPrivateKey> copy(new ECPrivateKey);
90 if (key_)
91 copy->key_ = EVP_PKEY_dup(key_);
92 return copy.release();
93 }
94
88 // static 95 // static
89 bool ECPrivateKey::IsSupported() { return true; } 96 bool ECPrivateKey::IsSupported() { return true; }
90 97
91 // static 98 // static
92 ECPrivateKey* ECPrivateKey::Create() { 99 ECPrivateKey* ECPrivateKey::Create() {
93 OpenSSLErrStackTracer err_tracer(FROM_HERE); 100 OpenSSLErrStackTracer err_tracer(FROM_HERE);
94 101
95 ScopedEC_KEY ec_key(EC_KEY_new_by_curve_name(NID_X9_62_prime256v1)); 102 ScopedEC_KEY ec_key(EC_KEY_new_by_curve_name(NID_X9_62_prime256v1));
96 if (!ec_key.get() || !EC_KEY_generate_key(ec_key.get())) 103 if (!ec_key.get() || !EC_KEY_generate_key(ec_key.get()))
97 return NULL; 104 return NULL;
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 OpenSSLErrStackTracer err_tracer(FROM_HERE); 229 OpenSSLErrStackTracer err_tracer(FROM_HERE);
223 ScopedEC_KEY ec_key(EVP_PKEY_get1_EC_KEY(key_)); 230 ScopedEC_KEY ec_key(EVP_PKEY_get1_EC_KEY(key_));
224 return ExportKey(ec_key.get(), 231 return ExportKey(ec_key.get(),
225 reinterpret_cast<ExportDataFunction>(i2d_ECParameters), 232 reinterpret_cast<ExportDataFunction>(i2d_ECParameters),
226 output); 233 output);
227 } 234 }
228 235
229 ECPrivateKey::ECPrivateKey() : key_(NULL) {} 236 ECPrivateKey::ECPrivateKey() : key_(NULL) {}
230 237
231 } // namespace crypto 238 } // namespace crypto
OLDNEW
« no previous file with comments | « crypto/ec_private_key.h ('k') | crypto/ec_private_key_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698