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

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: Fred's comments 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
Index: sync/util/cryptographer.cc
diff --git a/sync/util/cryptographer.cc b/sync/util/cryptographer.cc
index 2c0d7945120ed594f6a1938ca871ea55339f3177..d63166bb4c7d21c741b321bba7aedb34ba118d29 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
ModelTypeSet Cryptographer::SensitiveTypes() {
// Both of these have their own encryption schemes, but we include them

Powered by Google App Engine
This is Rietveld 408576698