Index: chrome/browser/chromeos/settings/token_encryptor.cc |
diff --git a/chrome/browser/chromeos/settings/token_encryptor.cc b/chrome/browser/chromeos/settings/token_encryptor.cc |
index 269e8cb85ab8ea29bb3e2786b9b78db257011df5..39727d9a67a860f0071bf661d233eb0feae24f2d 100644 |
--- a/chrome/browser/chromeos/settings/token_encryptor.cc |
+++ b/chrome/browser/chromeos/settings/token_encryptor.cc |
@@ -22,7 +22,13 @@ namespace { |
const size_t kNonceSize = 16; |
} // namespace |
-CryptohomeTokenEncryptor::CryptohomeTokenEncryptor() { |
+CryptohomeTokenEncryptor::CryptohomeTokenEncryptor( |
+ const std::string& system_salt) |
+ : system_salt_(system_salt) { |
+ DCHECK(!system_salt.empty()); |
+ // TODO: should this use the system salt for both the password and the salt |
pastarmovj
2013/10/24 09:43:20
nit: Please put an owner of this todo.
satorux1
2013/10/24 10:23:14
Sure. will find out the engineer who added this co
satorux1
2013/10/25 02:36:02
Assigned this TODO to davidroche@ who originally a
|
+ // value, or should this use a separate salt value? |
+ system_salt_key_.reset(PassphraseToKey(system_salt_, system_salt_)); |
} |
CryptohomeTokenEncryptor::~CryptohomeTokenEncryptor() { |
@@ -34,7 +40,7 @@ std::string CryptohomeTokenEncryptor::EncryptWithSystemSalt( |
if (!base::SysInfo::IsRunningOnChromeOS()) |
return token; |
- if (!LoadSystemSaltKey()) { |
+ if (!system_salt_key_) { |
LOG(WARNING) << "System salt key is not available for encrypt."; |
return std::string(); |
} |
@@ -49,7 +55,7 @@ std::string CryptohomeTokenEncryptor::DecryptWithSystemSalt( |
if (!base::SysInfo::IsRunningOnChromeOS()) |
return encrypted_token_hex; |
- if (!LoadSystemSaltKey()) { |
+ if (!system_salt_key_) { |
LOG(WARNING) << "System salt key is not available for decrypt."; |
return std::string(); |
} |
@@ -58,19 +64,6 @@ std::string CryptohomeTokenEncryptor::DecryptWithSystemSalt( |
encrypted_token_hex); |
} |
-// TODO: should this use the system salt for both the password and the salt |
-// value, or should this use a separate salt value? |
-bool CryptohomeTokenEncryptor::LoadSystemSaltKey() { |
- // Assume the system salt should be obtained beforehand at login time. |
- if (system_salt_.empty()) |
- system_salt_ = SystemSaltGetter::Get()->GetCachedSystemSalt(); |
- if (system_salt_.empty()) |
- return false; |
- if (!system_salt_key_.get()) |
- system_salt_key_.reset(PassphraseToKey(system_salt_, system_salt_)); |
- return system_salt_key_.get(); |
-} |
- |
crypto::SymmetricKey* CryptohomeTokenEncryptor::PassphraseToKey( |
const std::string& passphrase, |
const std::string& salt) { |