| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/signin/local_auth.h" | 5 #include "chrome/browser/signin/local_auth.h" |
| 6 | 6 |
| 7 #include "base/base64.h" | 7 #include "base/base64.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 | 168 |
| 169 } // namespace | 169 } // namespace |
| 170 | 170 |
| 171 std::string LocalAuth::TruncateStringByBits(const std::string& str, | 171 std::string LocalAuth::TruncateStringByBits(const std::string& str, |
| 172 const size_t len_bits) { | 172 const size_t len_bits) { |
| 173 return ::TruncateStringByBits(str, len_bits); | 173 return ::TruncateStringByBits(str, len_bits); |
| 174 } | 174 } |
| 175 | 175 |
| 176 void LocalAuth::RegisterLocalAuthPrefs( | 176 void LocalAuth::RegisterLocalAuthPrefs( |
| 177 user_prefs::PrefRegistrySyncable* registry) { | 177 user_prefs::PrefRegistrySyncable* registry) { |
| 178 registry->RegisterStringPref( | 178 registry->RegisterStringPref(prefs::kGoogleServicesPasswordHash, |
| 179 prefs::kGoogleServicesPasswordHash, | 179 std::string()); |
| 180 std::string(), | |
| 181 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | |
| 182 } | 180 } |
| 183 | 181 |
| 184 void LocalAuth::SetLocalAuthCredentialsWithEncoding(size_t info_index, | 182 void LocalAuth::SetLocalAuthCredentialsWithEncoding(size_t info_index, |
| 185 const std::string& password, | 183 const std::string& password, |
| 186 char encoding_version) { | 184 char encoding_version) { |
| 187 const HashEncoding& encoding = encodings[(encoding_version - '0') - 1]; | 185 const HashEncoding& encoding = encodings[(encoding_version - '0') - 1]; |
| 188 | 186 |
| 189 // Salt should be random data, as long as the hash length, and different with | 187 // Salt should be random data, as long as the hash length, and different with |
| 190 // every save. | 188 // every save. |
| 191 std::string salt_str; | 189 std::string salt_str; |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 if (passwords_match && (hash_encoding->version - '0') != NUM_HASH_ENCODINGS) | 268 if (passwords_match && (hash_encoding->version - '0') != NUM_HASH_ENCODINGS) |
| 271 SetLocalAuthCredentials(info_index, password); | 269 SetLocalAuthCredentials(info_index, password); |
| 272 return passwords_match; | 270 return passwords_match; |
| 273 } | 271 } |
| 274 | 272 |
| 275 bool LocalAuth::ValidateLocalAuthCredentials(const Profile* profile, | 273 bool LocalAuth::ValidateLocalAuthCredentials(const Profile* profile, |
| 276 const std::string& password) { | 274 const std::string& password) { |
| 277 return ValidateLocalAuthCredentials(GetProfileInfoIndexOfProfile(profile), | 275 return ValidateLocalAuthCredentials(GetProfileInfoIndexOfProfile(profile), |
| 278 password); | 276 password); |
| 279 } | 277 } |
| OLD | NEW |