Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "ash/login/lock_screen_controller.h" | |
| 6 | |
| 7 #include "chromeos/cryptohome/system_salt_getter.h" | |
| 8 #include "chromeos/login/auth/user_context.h" | |
| 9 | |
| 10 namespace ash { | |
| 11 | |
| 12 LockScreenController::LockScreenController() { | |
| 13 chromeos::SystemSaltGetter::Get()->GetSystemSalt(base::Bind( | |
|
xiyuan
2017/05/15 20:39:41
SystemSaltGetter::Get() could return nullptr on te
xiaoyinh(OOO Sep 11-29)
2017/05/16 17:32:50
Done. Added "+chromeos/cryptohome" in ash/mus/DEPS
| |
| 14 &LockScreenController::OnSaltObtained, base::Unretained(this))); | |
| 15 } | |
| 16 | |
| 17 LockScreenController::~LockScreenController() {} | |
| 18 | |
| 19 void LockScreenController::BindRequest(mojom::LockScreenRequest request) { | |
| 20 bindings_.AddBinding(this, std::move(request)); | |
| 21 } | |
| 22 | |
| 23 void LockScreenController::AuthenticateUser(const AccountId& account_id, | |
| 24 const std::string& password, | |
| 25 bool authenticated_by_pin) { | |
| 26 if (!system_salt_.empty()) { | |
| 27 DoAuthenticateUser(account_id, password, authenticated_by_pin, | |
| 28 system_salt_); | |
| 29 return; | |
| 30 } | |
| 31 | |
| 32 chromeos::SystemSaltGetter::Get()->GetSystemSalt(base::Bind( | |
| 33 &LockScreenController::DoAuthenticateUser, base::Unretained(this), | |
| 34 account_id, password, authenticated_by_pin)); | |
| 35 } | |
| 36 | |
| 37 void LockScreenController::SetClient(mojom::LockScreenClientPtr client) { | |
| 38 lock_screen_client_ = std::move(client); | |
| 39 } | |
| 40 | |
| 41 void LockScreenController::ShowErrorMessage() { | |
| 42 NOTIMPLEMENTED(); | |
| 43 } | |
| 44 | |
| 45 void LockScreenController::ClearErrors() { | |
| 46 NOTIMPLEMENTED(); | |
| 47 } | |
| 48 | |
| 49 void LockScreenController::DoAuthenticateUser(const AccountId& account_id, | |
| 50 const std::string& password, | |
| 51 bool authenticated_by_pin, | |
| 52 const std::string& system_salt) { | |
| 53 system_salt_ = system_salt; | |
| 54 | |
| 55 // Hash password before sending through mojo. | |
| 56 // TODO(xiaoyinh@): Pin is hashed differently by using a different salt and | |
| 57 // a different hash algorithm. Update this part in PinStorage. | |
| 58 chromeos::UserContext user_context(account_id); | |
|
xiyuan
2017/05/15 20:39:41
|user_context| not used?
xiaoyinh(OOO Sep 11-29)
2017/05/16 17:32:49
Removed, thanks!
| |
| 59 chromeos::Key key(password); | |
| 60 key.Transform(chromeos::Key::KEY_TYPE_SALTED_SHA256_TOP_HALF, system_salt); | |
| 61 if (lock_screen_client_) { | |
| 62 lock_screen_client_->AuthenticateUser(account_id, key.GetSecret(), | |
| 63 authenticated_by_pin); | |
| 64 } | |
| 65 } | |
| 66 | |
| 67 void LockScreenController::OnSaltObtained(const std::string& system_salt) { | |
| 68 system_salt_ = system_salt; | |
| 69 } | |
|
James Cook
2017/05/15 21:15:00
Please write a test for this class. It can be some
xiaoyinh(OOO Sep 11-29)
2017/05/16 17:32:49
Thanks!
I wrote a very simple test to verify that
| |
| 70 | |
| 71 } // namespace ash | |
| OLD | NEW |