Commit c681bac0 authored by davidben's avatar davidben Committed by Commit bot

Replace EVP_PKEY_dup calls with EVP_PKEY_up_ref.

This is a no-op change. BoringSSL deprecated EVP_PKEY_dup in favor of a new
EVP_PKEY_up_ref. This makes it more obvious there isn't actually a copy and is
more consistent with other ref-counted types.

See https://boringssl.googlesource.com/boringssl/+/517da2f1efc91b179dfb1898f826b18a6a38f547%5E%21/#F3

BUG=none

Review URL: https://codereview.chromium.org/1129083007

Cr-Commit-Position: refs/heads/master@{#329732}
parent a3116351
...@@ -88,7 +88,7 @@ ECPrivateKey::~ECPrivateKey() { ...@@ -88,7 +88,7 @@ ECPrivateKey::~ECPrivateKey() {
ECPrivateKey* ECPrivateKey::Copy() const { ECPrivateKey* ECPrivateKey::Copy() const {
scoped_ptr<ECPrivateKey> copy(new ECPrivateKey); scoped_ptr<ECPrivateKey> copy(new ECPrivateKey);
if (key_) if (key_)
copy->key_ = EVP_PKEY_dup(key_); copy->key_ = EVP_PKEY_up_ref(key_);
return copy.release(); return copy.release();
} }
......
...@@ -103,7 +103,7 @@ RSAPrivateKey* RSAPrivateKey::CreateFromKey(EVP_PKEY* key) { ...@@ -103,7 +103,7 @@ RSAPrivateKey* RSAPrivateKey::CreateFromKey(EVP_PKEY* key) {
if (EVP_PKEY_type(key->type) != EVP_PKEY_RSA) if (EVP_PKEY_type(key->type) != EVP_PKEY_RSA)
return NULL; return NULL;
RSAPrivateKey* copy = new RSAPrivateKey(); RSAPrivateKey* copy = new RSAPrivateKey();
copy->key_ = EVP_PKEY_dup(key); copy->key_ = EVP_PKEY_up_ref(key);
return copy; return copy;
} }
......
...@@ -36,7 +36,7 @@ class MemoryKeyPairStore { ...@@ -36,7 +36,7 @@ class MemoryKeyPairStore {
} }
bool StoreKeyPair(EVP_PKEY* pkey) { bool StoreKeyPair(EVP_PKEY* pkey) {
EVP_PKEY_dup(pkey); EVP_PKEY_up_ref(pkey);
base::AutoLock lock(lock_); base::AutoLock lock(lock_);
keys_.push_back(pkey); keys_.push_back(pkey);
return true; return true;
......
...@@ -37,18 +37,17 @@ OpenSSLClientKeyStore::OpenSSLClientKeyStore() { ...@@ -37,18 +37,17 @@ OpenSSLClientKeyStore::OpenSSLClientKeyStore() {
OpenSSLClientKeyStore::~OpenSSLClientKeyStore() { OpenSSLClientKeyStore::~OpenSSLClientKeyStore() {
} }
OpenSSLClientKeyStore::KeyPair::KeyPair(EVP_PKEY* pub_key, OpenSSLClientKeyStore::KeyPair::KeyPair(EVP_PKEY* pub_key, EVP_PKEY* priv_key)
EVP_PKEY* priv_key) : public_key(EVP_PKEY_up_ref(pub_key)),
: public_key(EVP_PKEY_dup(pub_key)), private_key(EVP_PKEY_up_ref(priv_key)) {
private_key(EVP_PKEY_dup(priv_key)) {
} }
OpenSSLClientKeyStore::KeyPair::~KeyPair() { OpenSSLClientKeyStore::KeyPair::~KeyPair() {
} }
OpenSSLClientKeyStore::KeyPair::KeyPair(const KeyPair& other) OpenSSLClientKeyStore::KeyPair::KeyPair(const KeyPair& other)
: public_key(EVP_PKEY_dup(other.public_key.get())), : public_key(EVP_PKEY_up_ref(other.public_key.get())),
private_key(EVP_PKEY_dup(other.private_key.get())) { private_key(EVP_PKEY_up_ref(other.private_key.get())) {
} }
void OpenSSLClientKeyStore::KeyPair::operator=(KeyPair other) { void OpenSSLClientKeyStore::KeyPair::operator=(KeyPair other) {
...@@ -109,7 +108,8 @@ crypto::ScopedEVP_PKEY OpenSSLClientKeyStore::FetchClientCertPrivateKey( ...@@ -109,7 +108,8 @@ crypto::ScopedEVP_PKEY OpenSSLClientKeyStore::FetchClientCertPrivateKey(
if (index < 0) if (index < 0)
return crypto::ScopedEVP_PKEY(); return crypto::ScopedEVP_PKEY();
return crypto::ScopedEVP_PKEY(EVP_PKEY_dup(pairs_[index].private_key.get())); return crypto::ScopedEVP_PKEY(
EVP_PKEY_up_ref(pairs_[index].private_key.get()));
} }
void OpenSSLClientKeyStore::Flush() { void OpenSSLClientKeyStore::Flush() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment