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

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

Issue 2114703002: Ignore Crypto-Key header values that do not have "dh" values (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: lowercase v Created 4 years, 6 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_encryption_provider_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_encryption_provider.cc
diff --git a/components/gcm_driver/crypto/gcm_encryption_provider.cc b/components/gcm_driver/crypto/gcm_encryption_provider.cc
index 35015369f5d25a0746e0783489422bf78a21ced6..9532d3b595dfcacf02bad328c48bccc6cf4fdabc 100644
--- a/components/gcm_driver/crypto/gcm_encryption_provider.cc
+++ b/components/gcm_driver/crypto/gcm_encryption_provider.cc
@@ -150,7 +150,29 @@ void GCMEncryptionProvider::DecryptMessage(
return;
}
- if (crypto_key_header_iterator.dh().empty()) {
+ // Ignore values that don't include the "dh" property. When using VAPID, it is
+ // valid for the application server to supply multiple values.
+ while (crypto_key_header_iterator.dh().empty() &&
+ crypto_key_header_iterator.GetNext()) {}
+
+ bool valid_crypto_key_header = false;
+ std::string dh;
+
+ if (!crypto_key_header_iterator.dh().empty()) {
+ dh = crypto_key_header_iterator.dh();
+ valid_crypto_key_header = true;
+
+ // Guard against the "dh" property being included more than once.
+ while (crypto_key_header_iterator.GetNext()) {
+ if (crypto_key_header_iterator.dh().empty())
+ continue;
+
+ valid_crypto_key_header = false;
+ break;
+ }
+ }
+
+ if (!valid_crypto_key_header) {
DLOG(ERROR) << "Invalid values supplied in the Crypto-Key header";
callback.Run(DECRYPTION_RESULT_INVALID_CRYPTO_KEY_HEADER,
IncomingMessage());
@@ -164,8 +186,7 @@ void GCMEncryptionProvider::DecryptMessage(
base::Bind(&GCMEncryptionProvider::DecryptMessageWithKey,
weak_ptr_factory_.GetWeakPtr(), message,
callback, encryption_header_iterator.salt(),
- crypto_key_header_iterator.dh(),
- encryption_header_iterator.rs()));
+ dh, encryption_header_iterator.rs()));
}
void GCMEncryptionProvider::DidGetEncryptionInfo(
« no previous file with comments | « no previous file | components/gcm_driver/crypto/gcm_encryption_provider_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698