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

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

Issue 2934893003: Deleted redundant SymmetricKey::GetRawKey(). (Closed)
Patch Set: Rebased to fix conflict with ToT. Created 3 years, 6 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/nigori.h ('k') | components/sync/base/nigori_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/sync/base/nigori.cc
diff --git a/components/sync/base/nigori.cc b/components/sync/base/nigori.cc
index e3067cc6c4cbb08eb3c007d7142fca42836407f1..5204521e36ba8bad55d14feb3753de25ed56ef9a 100644
--- a/components/sync/base/nigori.cc
+++ b/components/sync/base/nigori.cc
@@ -75,25 +75,21 @@ bool Nigori::InitByDerivation(const std::string& hostname,
kSaltKeySizeInBits));
DCHECK(user_salt);
- std::string raw_user_salt;
- 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,
+ SymmetricKey::AES, password, user_salt->key(), kUserIterations,
kDerivedKeySizeInBits);
DCHECK(user_key_);
// Kenc = PBKDF2(P, Suser, Nenc, 16)
encryption_key_ = SymmetricKey::DeriveKeyFromPassword(
- SymmetricKey::AES, password, raw_user_salt, kEncryptionIterations,
+ SymmetricKey::AES, password, user_salt->key(), kEncryptionIterations,
kDerivedKeySizeInBits);
DCHECK(encryption_key_);
// Kmac = PBKDF2(P, Suser, Nmac, 16)
mac_key_ = SymmetricKey::DeriveKeyFromPassword(
- SymmetricKey::HMAC_SHA1, password, raw_user_salt, kSigningIterations,
+ SymmetricKey::HMAC_SHA1, password, user_salt->key(), kSigningIterations,
kDerivedKeySizeInBits);
DCHECK(mac_key_);
@@ -132,12 +128,8 @@ bool Nigori::Permute(Type type,
if (!encryptor.Encrypt(plaintext.str(), &ciphertext))
return false;
- std::string raw_mac_key;
- if (!mac_key_->GetRawKey(&raw_mac_key))
- return false;
-
HMAC hmac(HMAC::SHA256);
- if (!hmac.Init(raw_mac_key))
+ if (!hmac.Init(mac_key_->key()))
return false;
std::vector<unsigned char> hash(kHashSize);
@@ -168,12 +160,8 @@ bool Nigori::Encrypt(const std::string& value, std::string* encrypted) const {
if (!encryptor.Encrypt(value, &ciphertext))
return false;
- std::string raw_mac_key;
- if (!mac_key_->GetRawKey(&raw_mac_key))
- return false;
-
HMAC hmac(HMAC::SHA256);
- if (!hmac.Init(raw_mac_key))
+ if (!hmac.Init(mac_key_->key()))
return false;
std::vector<unsigned char> hash(kHashSize);
@@ -206,12 +194,8 @@ bool Nigori::Decrypt(const std::string& encrypted, std::string* value) const {
input.substr(kIvSize, input.size() - (kIvSize + kHashSize)));
std::string hash(input.substr(input.size() - kHashSize, kHashSize));
- std::string raw_mac_key;
- if (!mac_key_->GetRawKey(&raw_mac_key))
- return false;
-
HMAC hmac(HMAC::SHA256);
- if (!hmac.Init(raw_mac_key))
+ if (!hmac.Init(mac_key_->key()))
return false;
std::vector<unsigned char> expected(kHashSize);
@@ -232,7 +216,7 @@ bool Nigori::Decrypt(const std::string& encrypted, std::string* value) const {
return true;
}
-bool Nigori::ExportKeys(std::string* user_key,
+void Nigori::ExportKeys(std::string* user_key,
std::string* encryption_key,
std::string* mac_key) const {
DCHECK(encryption_key);
@@ -240,12 +224,12 @@ bool Nigori::ExportKeys(std::string* user_key,
DCHECK(user_key);
if (user_key_)
- user_key_->GetRawKey(user_key);
+ *user_key = user_key_->key();
else
user_key->clear();
- return encryption_key_->GetRawKey(encryption_key) &&
- mac_key_->GetRawKey(mac_key);
+ *encryption_key = encryption_key_->key();
+ *mac_key = mac_key_->key();
}
} // namespace syncer
« no previous file with comments | « components/sync/base/nigori.h ('k') | components/sync/base/nigori_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698