Skip to content

Commit

Permalink
Remove crypto/curve25519.h in favor of BoringSSL's.
Browse files Browse the repository at this point in the history
They're the exact same functions, only with BoringSSL/C-style
argument order rather than Chromium/C++-style. (Outputs first
rather than last.) The //crypto version is just a wrapper.

BUG=none

Review-Url: https://codereview.chromium.org/2457153003
Cr-Commit-Position: refs/heads/master@{#447090}
  • Loading branch information
davidben authored and Commit bot committed Jan 30, 2017
1 parent 6168501 commit d27673a
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 156 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
#include "components/certificate_reporting/error_report.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/test/test_utils.h"
#include "crypto/curve25519.h"
#include "net/base/upload_bytes_element_reader.h"
#include "net/base/upload_data_stream.h"
#include "net/url_request/url_request_filter.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/boringssl/src/include/openssl/curve25519.h"

namespace {

Expand Down Expand Up @@ -376,7 +376,7 @@ void CertificateReportingServiceObserver::OnServiceReset() {

CertificateReportingServiceTestHelper::CertificateReportingServiceTestHelper() {
memset(server_private_key_, 1, sizeof(server_private_key_));
crypto::curve25519::ScalarBaseMult(server_private_key_, server_public_key_);
X25519_public_from_private(server_public_key_, server_private_key_);
}

CertificateReportingServiceTestHelper::
Expand Down
3 changes: 2 additions & 1 deletion components/certificate_reporting/DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ include_rules = [
"+components/network_time",
"+components/prefs",
"+crypto",
"+net"
"+net",
"+third_party/boringssl/src/include",
]
12 changes: 6 additions & 6 deletions components/certificate_reporting/error_reporter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
#include "base/memory/ptr_util.h"
#include "components/certificate_reporting/encrypted_cert_logger.pb.h"
#include "crypto/aead.h"
#include "crypto/curve25519.h"
#include "crypto/hkdf.h"
#include "crypto/random.h"
#include "net/url_request/report_sender.h"
#include "third_party/boringssl/src/include/openssl/curve25519.h"

namespace certificate_reporting {

Expand All @@ -36,8 +36,8 @@ bool GetHkdfSubkeySecret(size_t subkey_length,
const uint8_t* private_key,
const uint8_t* public_key,
std::string* secret) {
uint8_t shared_secret[crypto::curve25519::kBytes];
if (!crypto::curve25519::ScalarMult(private_key, public_key, shared_secret))
uint8_t shared_secret[X25519_SHARED_KEY_LEN];
if (!X25519(shared_secret, private_key, public_key))
return false;

// By mistake, the HKDF label here ends up with an extra null byte on
Expand All @@ -64,11 +64,11 @@ bool EncryptSerializedReport(const uint8_t* server_public_key,
const std::string& report,
EncryptedCertLoggerRequest* encrypted_report) {
// Generate an ephemeral key pair to generate a shared secret.
uint8_t public_key[crypto::curve25519::kBytes];
uint8_t private_key[crypto::curve25519::kScalarBytes];
uint8_t public_key[X25519_PUBLIC_VALUE_LEN];
uint8_t private_key[X25519_PRIVATE_KEY_LEN];

crypto::RandBytes(private_key, sizeof(private_key));
crypto::curve25519::ScalarBaseMult(private_key, public_key);
X25519_public_from_private(public_key, private_key);

crypto::Aead aead(crypto::Aead::AES_128_CTR_HMAC_SHA256);
std::string key;
Expand Down
4 changes: 2 additions & 2 deletions components/certificate_reporting/error_reporter_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
#include "components/certificate_reporting/encrypted_cert_logger.pb.h"
#include "crypto/curve25519.h"
#include "net/test/url_request/url_request_failed_job.h"
#include "net/test/url_request/url_request_mock_data_job.h"
#include "net/url_request/report_sender.h"
#include "net/url_request/url_request_test_util.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/boringssl/src/include/openssl/curve25519.h"

namespace certificate_reporting {

Expand Down Expand Up @@ -103,7 +103,7 @@ class ErrorReporterTest : public ::testing::Test {
public:
ErrorReporterTest() {
memset(server_private_key_, 1, sizeof(server_private_key_));
crypto::curve25519::ScalarBaseMult(server_private_key_, server_public_key_);
X25519_public_from_private(server_public_key_, server_private_key_);
}

~ErrorReporterTest() override {}
Expand Down
3 changes: 0 additions & 3 deletions crypto/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ component("crypto") {
"crypto_export.h",
"cssm_init.cc",
"cssm_init.h",
"curve25519.cc",
"curve25519.h",
"ec_private_key.cc",
"ec_private_key.h",
"ec_signature_creator.cc",
Expand Down Expand Up @@ -134,7 +132,6 @@ component("crypto") {
test("crypto_unittests") {
sources = [
"aead_unittest.cc",
"curve25519_unittest.cc",
"ec_private_key_unittest.cc",
"ec_signature_creator_unittest.cc",
"encryptor_unittest.cc",
Expand Down
27 changes: 0 additions & 27 deletions crypto/curve25519.cc

This file was deleted.

56 changes: 0 additions & 56 deletions crypto/curve25519.h

This file was deleted.

59 changes: 0 additions & 59 deletions crypto/curve25519_unittest.cc

This file was deleted.

0 comments on commit d27673a

Please sign in to comment.