#include <openssl/evp.h>
#include <openssl/x509.h>
+#include <algorithm>
#include "base/memory/scoped_ptr.h"
#include "base/memory/singleton.h"
private_key(EVP_PKEY_dup(other.private_key.get())) {
}
-void OpenSSLClientKeyStore::KeyPair::operator=(const KeyPair& other) {
- // Use a temporary ScopedEVP_PKEY because scoped_ptr does not allow resetting
- // to the current value, even though it's safe here.
- crypto::ScopedEVP_PKEY public_key_tmp(EVP_PKEY_dup(other.public_key.get()));
- crypto::ScopedEVP_PKEY private_key_tmp(EVP_PKEY_dup(other.private_key.get()));
- public_key.reset();
- public_key = public_key_tmp.Pass();
- private_key.reset();
- private_key = private_key_tmp.Pass();
+void OpenSSLClientKeyStore::KeyPair::operator=(KeyPair other) {
+ swap(other);
+}
+
+void OpenSSLClientKeyStore::KeyPair::swap(KeyPair& other) {
+ using std::swap;
+ swap(public_key, other.public_key);
+ swap(private_key, other.private_key);
}
int OpenSSLClientKeyStore::FindKeyPairIndex(EVP_PKEY* public_key) {