| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/chromeos/login/parallel_authenticator.h" | 5 #include "chrome/browser/chromeos/login/parallel_authenticator.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 attempt->user_context.username, | 180 attempt->user_context.username, |
| 181 attempt->ascii_hash, | 181 attempt->ascii_hash, |
| 182 base::Bind(&TriggerResolve, attempt, resolver)); | 182 base::Bind(&TriggerResolve, attempt, resolver)); |
| 183 } | 183 } |
| 184 | 184 |
| 185 // Returns hash of |password|, salted with the system salt. | 185 // Returns hash of |password|, salted with the system salt. |
| 186 std::string HashPassword(const std::string& password) { | 186 std::string HashPassword(const std::string& password) { |
| 187 // Get salt, ascii encode, update sha with that, then update with ascii | 187 // Get salt, ascii encode, update sha with that, then update with ascii |
| 188 // of password, then end. | 188 // of password, then end. |
| 189 std::string ascii_salt = CryptohomeLibrary::Get()->GetSystemSalt(); | 189 std::string ascii_salt = CryptohomeLibrary::Get()->GetSystemSalt(); |
| 190 // TODO(stevenjb/nkostylev): Handle empty system salt gracefully. |
| 191 CHECK(!ascii_salt.empty()); |
| 190 char passhash_buf[kPasswordHashLength]; | 192 char passhash_buf[kPasswordHashLength]; |
| 191 | 193 |
| 192 // Hash salt and password | 194 // Hash salt and password |
| 193 crypto::SHA256HashString(ascii_salt + password, | 195 crypto::SHA256HashString(ascii_salt + password, |
| 194 &passhash_buf, sizeof(passhash_buf)); | 196 &passhash_buf, sizeof(passhash_buf)); |
| 195 | 197 |
| 196 // Only want the top half for 'weak' hashing so that the passphrase is not | 198 // Only want the top half for 'weak' hashing so that the passphrase is not |
| 197 // immediately exposed even if the output is reversed. | 199 // immediately exposed even if the output is reversed. |
| 198 const int encoded_length = sizeof(passhash_buf) / 2; | 200 const int encoded_length = sizeof(passhash_buf) / 2; |
| 199 | 201 |
| (...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 839 Resolve(); | 841 Resolve(); |
| 840 } | 842 } |
| 841 | 843 |
| 842 void ParallelAuthenticator::SetOwnerState(bool owner_check_finished, | 844 void ParallelAuthenticator::SetOwnerState(bool owner_check_finished, |
| 843 bool check_result) { | 845 bool check_result) { |
| 844 owner_is_verified_ = owner_check_finished; | 846 owner_is_verified_ = owner_check_finished; |
| 845 user_can_login_ = check_result; | 847 user_can_login_ = check_result; |
| 846 } | 848 } |
| 847 | 849 |
| 848 } // namespace chromeos | 850 } // namespace chromeos |
| OLD | NEW |