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

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

Issue 1953273002: Add support to GCMKeyStore for multiple keys per app_id (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@iid6fixstore
Patch Set: Simplify Decrypt fallback by banning IID token & GCM reg from sharing same app_id Created 4 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
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 a89fedfb3b09817bd044178ed41380343484fdaf..87df533ee713ef0dc12b7466a53d6f76cd452fe6 100644
--- a/components/gcm_driver/crypto/gcm_encryption_provider.cc
+++ b/components/gcm_driver/crypto/gcm_encryption_provider.cc
@@ -77,18 +77,22 @@ void GCMEncryptionProvider::Init(
void GCMEncryptionProvider::GetEncryptionInfo(
const std::string& app_id,
+ const std::string& instance_id_authorized_entity,
const EncryptionInfoCallback& callback) {
DCHECK(key_store_);
- key_store_->GetKeys(
- app_id, base::Bind(&GCMEncryptionProvider::DidGetEncryptionInfo,
- weak_ptr_factory_.GetWeakPtr(), app_id, callback));
+ key_store_->GetKeys(app_id, instance_id_authorized_entity,
+ false /* fallback_to_empty_authorized_entity */,
+ base::Bind(&GCMEncryptionProvider::DidGetEncryptionInfo,
+ weak_ptr_factory_.GetWeakPtr(), app_id,
+ instance_id_authorized_entity, callback));
}
void GCMEncryptionProvider::RemoveEncryptionInfo(
const std::string& app_id,
+ const std::string& instance_id_authorized_entity,
const base::Closure& callback) {
DCHECK(key_store_);
- key_store_->RemoveKeys(app_id, callback);
+ key_store_->RemoveKeys(app_id, instance_id_authorized_entity, callback);
}
bool GCMEncryptionProvider::IsEncryptedMessage(const IncomingMessage& message)
@@ -155,23 +159,31 @@ void GCMEncryptionProvider::DecryptMessage(
return;
}
- key_store_->GetKeys(
- app_id, base::Bind(&GCMEncryptionProvider::DecryptMessageWithKey,
- weak_ptr_factory_.GetWeakPtr(), message,
- callback, encryption_header_values[0].salt,
- crypto_key_header_values[0].dh,
- encryption_header_values[0].rs));
+ // At this point we don't know whether this message is for an InstanceID token
+ // (key store owner = app_id + ',' + sender_id) or a legacy GCM registration
Peter Beverloo 2016/05/09 14:10:09 Mentioning the key store owner and its format has
johnme 2016/05/09 18:15:54 I changed this to: " // Use |fallback_to_empty_a
+ // (key store owner = app_id). Try the more specific one first; if that fails,
+ // DecryptMessageWithKey will fall back to the other.
+ key_store_->GetKeys(app_id,
+ message.sender_id /* instance_id_authorized_entity */,
+ true /* fallback_to_empty_authorized_entity */,
+ base::Bind(&GCMEncryptionProvider::DecryptMessageWithKey,
+ weak_ptr_factory_.GetWeakPtr(), message,
+ callback, encryption_header_values[0].salt,
+ crypto_key_header_values[0].dh,
+ encryption_header_values[0].rs));
}
void GCMEncryptionProvider::DidGetEncryptionInfo(
const std::string& app_id,
+ const std::string& instance_id_authorized_entity,
const EncryptionInfoCallback& callback,
const KeyPair& pair,
const std::string& auth_secret) {
if (!pair.IsInitialized()) {
key_store_->CreateKeys(
- app_id, base::Bind(&GCMEncryptionProvider::DidCreateEncryptionInfo,
- weak_ptr_factory_.GetWeakPtr(), callback));
+ app_id, instance_id_authorized_entity,
+ base::Bind(&GCMEncryptionProvider::DidCreateEncryptionInfo,
+ weak_ptr_factory_.GetWeakPtr(), callback));
return;
}

Powered by Google App Engine
This is Rietveld 408576698