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/sync/base/nigori.h

Issue 2813453004: [sync] Fix decryption failure caused by missing user_key (Closed)
Patch Set: Restore derivation check, add tests Created 3 years, 8 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 | « components/sync/base/cryptographer.cc ('k') | components/sync/base/nigori.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/sync/base/nigori.h
diff --git a/components/sync/base/nigori.h b/components/sync/base/nigori.h
index d0088c38ec13852649fdbb2107f2e227d8aac111..92c77b4079e07b7867dc54a342656ef68c309ba0 100644
--- a/components/sync/base/nigori.h
+++ b/components/sync/base/nigori.h
@@ -41,7 +41,8 @@ class Nigori {
// Initialize the client by importing the given keys instead of deriving new
// ones.
- bool InitByImport(const std::string& encryption_key,
+ bool InitByImport(const std::string& user_key,
+ const std::string& encryption_key,
const std::string& mac_key);
// Derives a secure lookup name from |type| and |name|. If |hostname|,
@@ -59,7 +60,9 @@ class Nigori {
bool Decrypt(const std::string& value, std::string* decrypted) const;
// Exports the raw derived keys.
- bool ExportKeys(std::string* encryption_key, std::string* mac_key) const;
+ bool ExportKeys(std::string* user_key,
+ std::string* encryption_key,
+ std::string* mac_key) const;
static const char kSaltSalt[]; // The salt used to derive the user salt.
static const size_t kSaltKeySizeInBits = 128;
@@ -68,10 +71,16 @@ class Nigori {
static const size_t kHashSize = 32;
static const size_t kSaltIterations = 1001;
+ static const size_t kUserIterations = 1002;
static const size_t kEncryptionIterations = 1003;
static const size_t kSigningIterations = 1004;
private:
+ // user_key isn't used any more, but legacy clients will fail to import a
+ // nigori node without one. We preserve it for the sake of those clients, but
+ // it should be removed once enough clients have upgraded to code that doesn't
+ // enforce its presence.
+ std::unique_ptr<crypto::SymmetricKey> user_key_;
std::unique_ptr<crypto::SymmetricKey> encryption_key_;
std::unique_ptr<crypto::SymmetricKey> mac_key_;
};
« no previous file with comments | « components/sync/base/cryptographer.cc ('k') | components/sync/base/nigori.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698