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

Unified Diff: chrome/browser/chromeos/settings/token_encryptor.cc

Issue 39443002: settings: Add async system salt retrieval logic in DeviceOAuth2TokenServiceFactory (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address comments Created 7 years, 2 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 | « chrome/browser/chromeos/settings/token_encryptor.h ('k') | chrome/chrome_tests_unit.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..fe555f9764ea6693759b1341da971d86ae82e8ee 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(davidroche): should this use the system salt for both the password
+ // and the salt 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) {
« no previous file with comments | « chrome/browser/chromeos/settings/token_encryptor.h ('k') | chrome/chrome_tests_unit.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698