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/managed/managed_user_authenticator.h" | 5 #include "chrome/browser/chromeos/login/managed/managed_user_authenticator.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "chrome/browser/chromeos/boot_times_loader.h" | 10 #include "chrome/browser/chromeos/boot_times_loader.h" |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
96 "CryptohomeAddKey-LMU-End", | 96 "CryptohomeAddKey-LMU-End", |
97 attempt, | 97 attempt, |
98 resolver)); | 98 resolver)); |
99 } | 99 } |
100 | 100 |
101 // Returns hash of |password|, salted with the system salt. | 101 // Returns hash of |password|, salted with the system salt. |
102 std::string HashPassword(const std::string& password) { | 102 std::string HashPassword(const std::string& password) { |
103 // Get salt, ascii encode, update sha with that, then update with ascii | 103 // Get salt, ascii encode, update sha with that, then update with ascii |
104 // of password, then end. | 104 // of password, then end. |
105 std::string ascii_salt = CryptohomeLibrary::Get()->GetSystemSalt(); | 105 std::string ascii_salt = CryptohomeLibrary::Get()->GetSystemSalt(); |
106 // TODO(stevenjb/nkostylev): Handle empty system salt gracefully. | |
107 CHECK(!ascii_salt.empty()); | |
zel
2013/09/20 16:28:05
same here
| |
106 char passhash_buf[kPasswordHashLength]; | 108 char passhash_buf[kPasswordHashLength]; |
107 | 109 |
108 // Hash salt and password | 110 // Hash salt and password |
109 crypto::SHA256HashString( | 111 crypto::SHA256HashString( |
110 ascii_salt + password, &passhash_buf, sizeof(passhash_buf)); | 112 ascii_salt + password, &passhash_buf, sizeof(passhash_buf)); |
111 | 113 |
112 // Only want the top half for 'weak' hashing so that the passphrase is not | 114 // Only want the top half for 'weak' hashing so that the passphrase is not |
113 // immediately exposed even if the output is reversed. | 115 // immediately exposed even if the output is reversed. |
114 const int encoded_length = sizeof(passhash_buf) / 2; | 116 const int encoded_length = sizeof(passhash_buf) / 2; |
115 | 117 |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
347 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 349 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
348 return hash_obtained_; | 350 return hash_obtained_; |
349 } | 351 } |
350 | 352 |
351 std::string ManagedUserAuthenticator::AuthAttempt::hash() { | 353 std::string ManagedUserAuthenticator::AuthAttempt::hash() { |
352 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 354 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
353 return hash_; | 355 return hash_; |
354 } | 356 } |
355 | 357 |
356 } // namespace chromeos | 358 } // namespace chromeos |
OLD | NEW |