Index: ash/login/lock_screen_controller.cc |
diff --git a/ash/login/lock_screen_controller.cc b/ash/login/lock_screen_controller.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..b1d1b815777be7ff48716f51e8016f929916f57e |
--- /dev/null |
+++ b/ash/login/lock_screen_controller.cc |
@@ -0,0 +1,52 @@ |
+// Copyright 2017 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "ash/login/lock_screen_controller.h" |
+ |
+#include "chromeos/cryptohome/system_salt_getter.h" |
+#include "chromeos/login/auth/user_context.h" |
+ |
+namespace ash { |
+ |
+LockScreenController::LockScreenController() { |
+ chromeos::SystemSaltGetter::Get()->GetSystemSalt(base::Bind( |
+ &LockScreenController::OnSaltObtained, base::Unretained(this))); |
+} |
+ |
+LockScreenController::~LockScreenController() {} |
+ |
+void LockScreenController::BindRequest(mojom::LockScreenRequest request) { |
+ bindings_.AddBinding(this, std::move(request)); |
+} |
+ |
+void LockScreenController::AuthenticateUser(const AccountId& account_id, |
+ const std::string& password, |
+ bool authenticated_by_pin) { |
+ // Hash password before sending through mojo. |
jdufault
2017/05/13 00:57:40
Instead of caching system_salt_ you can call throu
xiaoyinh(OOO Sep 11-29)
2017/05/15 20:13:05
Good point, thanks! I keep the caching part with t
|
+ chromeos::UserContext user_context(account_id); |
+ chromeos::Key key(password); |
jdufault
2017/05/13 00:57:39
Unfortunately PIN is hashed differently. See [1].
xiaoyinh(OOO Sep 11-29)
2017/05/15 20:13:05
Added a TODO. Thanks for the information.
|
+ key.Transform(chromeos::Key::KEY_TYPE_SALTED_SHA256_TOP_HALF, system_salt_); |
+ if (lock_screen_client_) { |
+ lock_screen_client_->AuthenticateUser(account_id, key.GetSecret(), |
+ authenticated_by_pin); |
+ } |
+} |
+ |
+void LockScreenController::SetClient(mojom::LockScreenClientPtr client) { |
+ lock_screen_client_ = std::move(client); |
+} |
+ |
+void LockScreenController::ShowErrorMessage() { |
+ NOTIMPLEMENTED(); |
+} |
+ |
+void LockScreenController::ClearErrors() { |
+ NOTIMPLEMENTED(); |
+} |
+ |
+void LockScreenController::OnSaltObtained(const std::string& system_salt) { |
+ system_salt_ = system_salt; |
+} |
+ |
+} // namespace ash |