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

Unified Diff: sync/util/cryptographer.cc

Issue 10455012: [Sync] Add support for performing a GetKey on startup. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 8 years, 5 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
« sync/test/engine/mock_connection_manager.cc ('K') | « sync/util/cryptographer.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sync/util/cryptographer.cc
diff --git a/sync/util/cryptographer.cc b/sync/util/cryptographer.cc
index 59e8a1aceb0d988592459cbc35d6a3f5eae99ac6..47eb1997f5146cd07c90f4b4f02646d5574d13b2 100644
--- a/sync/util/cryptographer.cc
+++ b/sync/util/cryptographer.cc
@@ -25,6 +25,7 @@ Cryptographer::Observer::~Observer() {}
Cryptographer::Cryptographer(Encryptor* encryptor)
: encryptor_(encryptor),
default_nigori_(NULL),
+ keystore_nigori_(NULL),
encrypted_types_(SensitiveTypes()),
encrypt_everything_(false) {
DCHECK(encryptor);
@@ -308,6 +309,26 @@ Cryptographer::UpdateResult Cryptographer::Update(
return Cryptographer::SUCCESS;
}
+bool Cryptographer::SetKeystoreKey(const std::string& keystore_key) {
+ if (keystore_key.empty())
+ return false;
+ KeyParams params = {"localhost", "dummy", keystore_key};
+
+ // AddKey updates the default nigori, so we save the current default and
+ // make sure the keystore_nigori_ gets updated instead.
+ NigoriMap::value_type* old_default = default_nigori_;
+ if (AddKey(params)) {
+ keystore_nigori_ = default_nigori_;
+ default_nigori_ = old_default;
+ return true;
+ }
+ return false;
+}
+
+bool Cryptographer::HasKeystoreKey() {
+ return keystore_nigori_ != NULL;
+}
+
// Static
syncer::ModelTypeSet Cryptographer::SensitiveTypes() {
// Both of these have their own encryption schemes, but we include them
« sync/test/engine/mock_connection_manager.cc ('K') | « sync/util/cryptographer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698