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

Unified Diff: components/certificate_reporting/error_reporter.cc

Issue 1459783002: Roll src/third_party/boringssl/src d7421ebf6..3ac32b1ed (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix build, estark comments Created 5 years, 1 month 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 | « DEPS ('k') | crypto/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/certificate_reporting/error_reporter.cc
diff --git a/components/certificate_reporting/error_reporter.cc b/components/certificate_reporting/error_reporter.cc
index d811112c3ef989e61c498a3fdc82b23f7171c8ad..a013063558037f82326f16e07d5ed61151e7c29d 100644
--- a/components/certificate_reporting/error_reporter.cc
+++ b/components/certificate_reporting/error_reporter.cc
@@ -34,11 +34,13 @@ static const uint32 kServerPublicKeyVersion = 1;
static const char kHkdfLabel[] = "certificate report";
-std::string GetHkdfSubkeySecret(size_t subkey_length,
- const uint8* private_key,
- const uint8* public_key) {
+bool GetHkdfSubkeySecret(size_t subkey_length,
+ const uint8* private_key,
+ const uint8* public_key,
+ std::string* secret) {
uint8 shared_secret[crypto::curve25519::kBytes];
- crypto::curve25519::ScalarMult(private_key, public_key, shared_secret);
+ if (!crypto::curve25519::ScalarMult(private_key, public_key, shared_secret))
+ return false;
// By mistake, the HKDF label here ends up with an extra null byte on
// the end, due to using sizeof(kHkdfLabel) in the StringPiece
@@ -55,7 +57,8 @@ std::string GetHkdfSubkeySecret(size_t subkey_length,
base::StringPiece(kHkdfLabel, sizeof(kHkdfLabel)),
0 /* key bytes */, 0 /* iv bytes */, subkey_length);
- return hkdf.subkey_secret().as_string();
+ *secret = hkdf.subkey_secret().as_string();
+ return true;
}
bool EncryptSerializedReport(const uint8* server_public_key,
@@ -70,9 +73,13 @@ bool EncryptSerializedReport(const uint8* server_public_key,
crypto::curve25519::ScalarBaseMult(private_key, public_key);
crypto::Aead aead(crypto::Aead::AES_128_CTR_HMAC_SHA256);
- const std::string key =
- GetHkdfSubkeySecret(aead.KeyLength(), private_key,
- reinterpret_cast<const uint8*>(server_public_key));
+ std::string key;
+ if (!GetHkdfSubkeySecret(aead.KeyLength(), private_key,
+ reinterpret_cast<const uint8*>(server_public_key),
+ &key)) {
+ LOG(ERROR) << "Error getting subkey secret.";
+ return false;
+ }
aead.Init(&key);
// Use an all-zero nonce because the key is random per-message.
@@ -157,10 +164,14 @@ bool ErrorReporter::DecryptErrorReport(
const EncryptedCertLoggerRequest& encrypted_report,
std::string* decrypted_serialized_report) {
crypto::Aead aead(crypto::Aead::AES_128_CTR_HMAC_SHA256);
- const std::string key =
- GetHkdfSubkeySecret(aead.KeyLength(), server_private_key,
- reinterpret_cast<const uint8*>(
- encrypted_report.client_public_key().data()));
+ std::string key;
+ if (!GetHkdfSubkeySecret(aead.KeyLength(), server_private_key,
+ reinterpret_cast<const uint8*>(
+ encrypted_report.client_public_key().data()),
+ &key)) {
+ LOG(ERROR) << "Error getting subkey secret.";
+ return false;
+ }
aead.Init(&key);
// Use an all-zero nonce because the key is random per-message.
« no previous file with comments | « DEPS ('k') | crypto/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698