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

Unified Diff: net/quic/core/crypto/p256_key_exchange.cc

Issue 2400033005: Use BoringSSL scopers in //net. (Closed)
Patch Set: eroman comments Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/quic/core/crypto/p256_key_exchange.h ('k') | net/quic/test_tools/crypto_test_utils.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 */
« no previous file with comments | « net/quic/core/crypto/p256_key_exchange.h ('k') | net/quic/test_tools/crypto_test_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698