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

Unified Diff: components/sync/base/nigori.cc

Issue 2813453004: [sync] Fix decryption failure caused by missing user_key (Closed)
Patch Set: [sync] Fix decryption failure caused by missing user_key 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
Index: components/sync/base/nigori.cc
diff --git a/components/sync/base/nigori.cc b/components/sync/base/nigori.cc
index 03c61b23472a34410579a40e987186db3bcde1d8..ef9f7d6eeb728e4380c1ae122803f279163ad9a9 100644
--- a/components/sync/base/nigori.cc
+++ b/components/sync/base/nigori.cc
@@ -79,6 +79,11 @@ bool Nigori::InitByDerivation(const std::string& hostname,
if (!user_salt->GetRawKey(&raw_user_salt))
return false;
+ // Kuser = PBKDF2(P, Suser, Nuser, 16)
+ user_key_ = SymmetricKey::DeriveKeyFromPassword(
+ SymmetricKey::AES, password, raw_user_salt, kUserIterations,
+ kDerivedKeySizeInBits);
pavely 2017/04/10 21:27:29 Could you keep DCHECK and return value check for I
Patrick Noland 2017/04/10 23:43:06 Done.
+
// Kenc = PBKDF2(P, Suser, Nenc, 16)
encryption_key_ = SymmetricKey::DeriveKeyFromPassword(
SymmetricKey::AES, password, raw_user_salt, kEncryptionIterations,
@@ -94,8 +99,11 @@ bool Nigori::InitByDerivation(const std::string& hostname,
return encryption_key_ && mac_key_;
}
-bool Nigori::InitByImport(const std::string& encryption_key,
+bool Nigori::InitByImport(const std::string& user_key,
+ const std::string& encryption_key,
const std::string& mac_key) {
+ user_key_ = SymmetricKey::Import(SymmetricKey::AES, user_key);
pavely 2017/04/10 21:27:29 Could you add a comment here or in nigori.h explai
Patrick Noland 2017/04/10 23:43:06 Done.
+
encryption_key_ = SymmetricKey::Import(SymmetricKey::AES, encryption_key);
DCHECK(encryption_key_);
@@ -223,11 +231,14 @@ bool Nigori::Decrypt(const std::string& encrypted, std::string* value) const {
return true;
}
-bool Nigori::ExportKeys(std::string* encryption_key,
+bool Nigori::ExportKeys(std::string* user_key,
+ std::string* encryption_key,
std::string* mac_key) const {
DCHECK(encryption_key);
DCHECK(mac_key);
+ user_key_->GetRawKey(user_key);
+
return encryption_key_->GetRawKey(encryption_key) &&
mac_key_->GetRawKey(mac_key);
}

Powered by Google App Engine
This is Rietveld 408576698