| OLD | NEW |
| 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 { | 88 ECPrivateKey* ECPrivateKey::Copy() const { |
| 89 scoped_ptr<ECPrivateKey> copy(new ECPrivateKey); | 89 scoped_ptr<ECPrivateKey> copy(new ECPrivateKey); |
| 90 if (key_) | 90 if (key_) |
| 91 copy->key_ = EVP_PKEY_dup(key_); | 91 copy->key_ = EVP_PKEY_up_ref(key_); |
| 92 return copy.release(); | 92 return copy.release(); |
| 93 } | 93 } |
| 94 | 94 |
| 95 // static | 95 // static |
| 96 bool ECPrivateKey::IsSupported() { return true; } | 96 bool ECPrivateKey::IsSupported() { return true; } |
| 97 | 97 |
| 98 // static | 98 // static |
| 99 ECPrivateKey* ECPrivateKey::Create() { | 99 ECPrivateKey* ECPrivateKey::Create() { |
| 100 OpenSSLErrStackTracer err_tracer(FROM_HERE); | 100 OpenSSLErrStackTracer err_tracer(FROM_HERE); |
| 101 | 101 |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 OpenSSLErrStackTracer err_tracer(FROM_HERE); | 229 OpenSSLErrStackTracer err_tracer(FROM_HERE); |
| 230 ScopedEC_KEY ec_key(EVP_PKEY_get1_EC_KEY(key_)); | 230 ScopedEC_KEY ec_key(EVP_PKEY_get1_EC_KEY(key_)); |
| 231 return ExportKey(ec_key.get(), | 231 return ExportKey(ec_key.get(), |
| 232 reinterpret_cast<ExportDataFunction>(i2d_ECParameters), | 232 reinterpret_cast<ExportDataFunction>(i2d_ECParameters), |
| 233 output); | 233 output); |
| 234 } | 234 } |
| 235 | 235 |
| 236 ECPrivateKey::ECPrivateKey() : key_(NULL) {} | 236 ECPrivateKey::ECPrivateKey() : key_(NULL) {} |
| 237 | 237 |
| 238 } // namespace crypto | 238 } // namespace crypto |
| OLD | NEW |