| Index: net/quic/core/crypto/p256_key_exchange.cc
|
| diff --git a/net/quic/core/crypto/p256_key_exchange.cc b/net/quic/core/crypto/p256_key_exchange.cc
|
| index 6e401a6ace01211a329c4dda85930bf3657bb97a..3a92118d3df854c1ad9ec8c48ae01ad7db8aedbf 100644
|
| --- a/net/quic/core/crypto/p256_key_exchange.cc
|
| +++ b/net/quic/core/crypto/p256_key_exchange.cc
|
| @@ -8,6 +8,8 @@
|
| #include <openssl/ecdh.h>
|
| #include <openssl/evp.h>
|
|
|
| +#include <utility>
|
| +
|
| #include "base/logging.h"
|
|
|
| using base::StringPiece;
|
| @@ -15,8 +17,9 @@ using std::string;
|
|
|
| namespace net {
|
|
|
| -P256KeyExchange::P256KeyExchange(EC_KEY* private_key, const uint8_t* public_key)
|
| - : private_key_(private_key) {
|
| +P256KeyExchange::P256KeyExchange(bssl::UniquePtr<EC_KEY> private_key,
|
| + const uint8_t* public_key)
|
| + : private_key_(std::move(private_key)) {
|
| memcpy(public_key_, public_key, sizeof(public_key_));
|
| }
|
|
|
| @@ -30,7 +33,7 @@ P256KeyExchange* P256KeyExchange::New(StringPiece key) {
|
| }
|
|
|
| const uint8_t* keyp = reinterpret_cast<const uint8_t*>(key.data());
|
| - crypto::ScopedEC_KEY private_key(
|
| + bssl::UniquePtr<EC_KEY> private_key(
|
| d2i_ECPrivateKey(nullptr, &keyp, key.size()));
|
| if (!private_key.get() || !EC_KEY_check_key(private_key.get())) {
|
| DVLOG(1) << "Private key is invalid.";
|
| @@ -46,12 +49,12 @@ P256KeyExchange* P256KeyExchange::New(StringPiece key) {
|
| return nullptr;
|
| }
|
|
|
| - return new P256KeyExchange(private_key.release(), public_key);
|
| + return new P256KeyExchange(std::move(private_key), public_key);
|
| }
|
|
|
| // static
|
| string P256KeyExchange::NewPrivateKey() {
|
| - crypto::ScopedEC_KEY key(EC_KEY_new_by_curve_name(NID_X9_62_prime256v1));
|
| + bssl::UniquePtr<EC_KEY> key(EC_KEY_new_by_curve_name(NID_X9_62_prime256v1));
|
| if (!key.get() || !EC_KEY_generate_key(key.get())) {
|
| DVLOG(1) << "Can't generate a new private key.";
|
| return string();
|
| @@ -84,7 +87,7 @@ bool P256KeyExchange::CalculateSharedKey(StringPiece peer_public_value,
|
| return false;
|
| }
|
|
|
| - crypto::ScopedEC_POINT point(
|
| + bssl::UniquePtr<EC_POINT> point(
|
| EC_POINT_new(EC_KEY_get0_group(private_key_.get())));
|
| if (!point ||
|
| !EC_POINT_oct2point(/* also test if point is on curve */
|
|
|