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,14 +235,16 @@ void DeviceOAuth2TokenService::DidGetSystemSalt( ...@@ -235,14 +235,16 @@ 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);
if (!encrypted_refresh_token.empty()) {
CryptohomeTokenEncryptor encryptor(system_salt_); CryptohomeTokenEncryptor encryptor(system_salt_);
refresh_token_ = encryptor.DecryptWithSystemSalt(encrypted_refresh_token); refresh_token_ = encryptor.DecryptWithSystemSalt(encrypted_refresh_token);
if (!encrypted_refresh_token.empty() && refresh_token_.empty()) { if (refresh_token_.empty()) {
LOG(ERROR) << "Failed to decrypt refresh token."; LOG(ERROR) << "Failed to decrypt refresh token.";
state_ = STATE_NO_TOKEN; state_ = STATE_NO_TOKEN;
FireRefreshTokensLoaded(); FireRefreshTokensLoaded();
return; 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