Do not try to decrypt empty refresh token

Calling DecryptWithSystemSalt() with an empty string results in a WARNING in the log.

BUG=393341

Review URL: https://codereview.chromium.org/384383002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@282943 0039d316-1c4b-4281-b951-d872f2087c98
parent 3e46ef2d
...@@ -235,13 +235,15 @@ void DeviceOAuth2TokenService::DidGetSystemSalt( ...@@ -235,13 +235,15 @@ void DeviceOAuth2TokenService::DidGetSystemSalt(
// Otherwise, load the refresh token from |local_state_|. // Otherwise, load the refresh token from |local_state_|.
std::string encrypted_refresh_token = std::string encrypted_refresh_token =
local_state_->GetString(prefs::kDeviceRobotAnyApiRefreshToken); local_state_->GetString(prefs::kDeviceRobotAnyApiRefreshToken);
CryptohomeTokenEncryptor encryptor(system_salt_); if (!encrypted_refresh_token.empty()) {
refresh_token_ = encryptor.DecryptWithSystemSalt(encrypted_refresh_token); CryptohomeTokenEncryptor encryptor(system_salt_);
if (!encrypted_refresh_token.empty() && refresh_token_.empty()) { refresh_token_ = encryptor.DecryptWithSystemSalt(encrypted_refresh_token);
LOG(ERROR) << "Failed to decrypt refresh token."; if (refresh_token_.empty()) {
state_ = STATE_NO_TOKEN; LOG(ERROR) << "Failed to decrypt refresh token.";
FireRefreshTokensLoaded(); state_ = STATE_NO_TOKEN;
return; FireRefreshTokensLoaded();
return;
}
} }
state_ = STATE_VALIDATION_PENDING; state_ = STATE_VALIDATION_PENDING;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment