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

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

Issue 2457153003: Remove crypto/curve25519.h in favor of BoringSSL's. (Closed)
Patch Set: \ 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 | « crypto/curve25519_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/core/crypto/curve25519_key_exchange.cc
diff --git a/net/quic/core/crypto/curve25519_key_exchange.cc b/net/quic/core/crypto/curve25519_key_exchange.cc
index 7bb7e30569f51fdbbc7061d513c115406b4920d3..6cf1c7652c6e68774273c6ba9904449e35bed1e1 100644
--- a/net/quic/core/crypto/curve25519_key_exchange.cc
+++ b/net/quic/core/crypto/curve25519_key_exchange.cc
@@ -5,8 +5,8 @@
#include "net/quic/core/crypto/curve25519_key_exchange.h"
#include "base/logging.h"
-#include "crypto/curve25519.h"
#include "net/quic/core/crypto/quic_random.h"
+#include "third_party/boringssl/src/include/openssl/curve25519.h"
using base::StringPiece;
using std::string;
@@ -19,29 +19,19 @@ Curve25519KeyExchange::~Curve25519KeyExchange() {}
// static
Curve25519KeyExchange* Curve25519KeyExchange::New(StringPiece private_key) {
- Curve25519KeyExchange* ka;
- // We don't want to #include the NaCl headers in the public header file, so
- // we use literals for the sizes of private_key_ and public_key_. Here we
- // assert that those values are equal to the values from the NaCl header.
- static_assert(sizeof(ka->private_key_) == crypto::curve25519::kScalarBytes,
- "header out of sync");
- static_assert(sizeof(ka->public_key_) == crypto::curve25519::kBytes,
- "header out of sync");
-
- if (private_key.size() != crypto::curve25519::kScalarBytes) {
+ if (private_key.size() != 32) {
Ryan Hamilton 2016/10/31 18:31:11 This file is key in sync with the internal reposit
davidben 2016/10/31 18:36:19 Sure. Though probably after the latter comment is
Ryan Hamilton 2016/10/31 18:46:07 Great, thanks! Let me know if I can help...
return nullptr;
}
- ka = new Curve25519KeyExchange();
- memcpy(ka->private_key_, private_key.data(),
- crypto::curve25519::kScalarBytes);
- crypto::curve25519::ScalarBaseMult(ka->private_key_, ka->public_key_);
+ Curve25519KeyExchange* ka = new Curve25519KeyExchange();
+ memcpy(ka->private_key_, private_key.data(), 32);
Ryan Hamilton 2016/10/31 18:31:11 instead of 32 in several places, can we make this
davidben 2016/10/31 18:36:19 They're just 32 in the header. I can add some cons
Ryan Hamilton 2016/10/31 18:46:07 Fee free to make the constant local to this file.
davidben 2016/10/31 18:49:56 Eh, it's a fair comment and one that I think shoul
+ X25519_public_from_private(ka->public_key_, ka->private_key_);
return ka;
}
// static
string Curve25519KeyExchange::NewPrivateKey(QuicRandom* rand) {
- uint8_t private_key[crypto::curve25519::kScalarBytes];
+ uint8_t private_key[32];
rand->RandBytes(private_key, sizeof(private_key));
// This makes |private_key| a valid scalar, as specified on
@@ -59,14 +49,13 @@ KeyExchange* Curve25519KeyExchange::NewKeyPair(QuicRandom* rand) const {
bool Curve25519KeyExchange::CalculateSharedKey(StringPiece peer_public_value,
string* out_result) const {
- if (peer_public_value.size() != crypto::curve25519::kBytes) {
+ if (peer_public_value.size() != 32) {
return false;
}
- uint8_t result[crypto::curve25519::kBytes];
- if (!crypto::curve25519::ScalarMult(
- private_key_,
- reinterpret_cast<const uint8_t*>(peer_public_value.data()), result)) {
+ uint8_t result[32];
+ if (!X25519(result, private_key_,
+ reinterpret_cast<const uint8_t*>(peer_public_value.data()))) {
return false;
}
out_result->assign(reinterpret_cast<char*>(result), sizeof(result));
« no previous file with comments | « crypto/curve25519_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698