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

Unified Diff: components/gcm_driver/crypto/gcm_message_cryptographer.cc

Issue 2708383002: Be strict about input in the GCMMessageCryptographer (Closed)
Patch Set: rebase Created 3 years, 7 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 | « no previous file | components/gcm_driver/crypto/gcm_message_cryptographer_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/gcm_driver/crypto/gcm_message_cryptographer.cc
diff --git a/components/gcm_driver/crypto/gcm_message_cryptographer.cc b/components/gcm_driver/crypto/gcm_message_cryptographer.cc
index d11989174215f04dea77c29f528ac6be758a666f..662b9abec892a4c66bd96560758669a16fe0f1ae 100644
--- a/components/gcm_driver/crypto/gcm_message_cryptographer.cc
+++ b/components/gcm_driver/crypto/gcm_message_cryptographer.cc
@@ -185,15 +185,12 @@ bool GCMMessageCryptographer::Encrypt(
std::string* ciphertext) const {
DCHECK_EQ(recipient_public_key.size(), 65u);
DCHECK_EQ(sender_public_key.size(), 65u);
+ DCHECK_EQ(ecdh_shared_secret.size(), 32u);
+ DCHECK_EQ(auth_secret.size(), 16u);
+ DCHECK_EQ(salt.size(), 16u);
DCHECK(record_size);
DCHECK(ciphertext);
- // TODO(peter): DCHECK the lengths of |ecdh_shared_secret|, |auth_secret| and
- // |salt|.
-
- if (salt.size() != kSaltSize)
- return false;
-
std::string prk = encryption_scheme_->DerivePseudoRandomKey(
ecdh_shared_secret, auth_secret);
@@ -229,11 +226,11 @@ bool GCMMessageCryptographer::Decrypt(
std::string* plaintext) const {
DCHECK_EQ(recipient_public_key.size(), 65u);
DCHECK_EQ(sender_public_key.size(), 65u);
+ DCHECK_EQ(ecdh_shared_secret.size(), 32u);
+ DCHECK_EQ(auth_secret.size(), 16u);
+ DCHECK_EQ(salt.size(), 16u);
DCHECK(plaintext);
- // TODO(peter): DCHECK the lengths of |ecdh_shared_secret|, |auth_secret| and
- // |salt|.
-
if (record_size <= 1)
return false;
« no previous file with comments | « no previous file | components/gcm_driver/crypto/gcm_message_cryptographer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698