Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(160)

Side by Side Diff: chrome/browser/signin/easy_unlock_service.cc

Issue 729803002: Easy Sign-in: Use TPM RSA key to sign nonce in sign-in protocol (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/easy_unlock_service.h" 5 #include "chrome/browser/signin/easy_unlock_service.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/logging.h" 9 #include "base/logging.h"
10 #include "base/metrics/histogram_macros.h" 10 #include "base/metrics/histogram_macros.h"
(...skipping 22 matching lines...) Expand all
33 #include "device/bluetooth/bluetooth_adapter_factory.h" 33 #include "device/bluetooth/bluetooth_adapter_factory.h"
34 #include "extensions/browser/event_router.h" 34 #include "extensions/browser/event_router.h"
35 #include "extensions/browser/extension_registry.h" 35 #include "extensions/browser/extension_registry.h"
36 #include "extensions/browser/extension_system.h" 36 #include "extensions/browser/extension_system.h"
37 #include "extensions/common/one_shot_event.h" 37 #include "extensions/common/one_shot_event.h"
38 #include "grit/browser_resources.h" 38 #include "grit/browser_resources.h"
39 39
40 #if defined(OS_CHROMEOS) 40 #if defined(OS_CHROMEOS)
41 #include "base/sys_info.h" 41 #include "base/sys_info.h"
42 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_key_manager.h" 42 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_key_manager.h"
43 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_tpm_key_manager. h"
44 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_tpm_key_manager_ factory.h"
43 #include "chrome/browser/chromeos/login/session/user_session_manager.h" 45 #include "chrome/browser/chromeos/login/session/user_session_manager.h"
44 #include "chrome/browser/chromeos/profiles/profile_helper.h" 46 #include "chrome/browser/chromeos/profiles/profile_helper.h"
45 #include "chromeos/dbus/dbus_thread_manager.h" 47 #include "chromeos/dbus/dbus_thread_manager.h"
46 #include "chromeos/dbus/power_manager_client.h" 48 #include "chromeos/dbus/power_manager_client.h"
49 #include "components/user_manager/user_manager.h"
47 #endif 50 #endif
48 51
49 namespace { 52 namespace {
50 53
51 extensions::ComponentLoader* GetComponentLoader( 54 extensions::ComponentLoader* GetComponentLoader(
52 content::BrowserContext* context) { 55 content::BrowserContext* context) {
53 extensions::ExtensionSystem* extension_system = 56 extensions::ExtensionSystem* extension_system =
54 extensions::ExtensionSystem::Get(context); 57 extensions::ExtensionSystem::Get(context);
55 ExtensionService* extension_service = extension_system->extension_service(); 58 ExtensionService* extension_service = extension_system->extension_service();
56 return extension_service->component_loader(); 59 return extension_service->component_loader();
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 base::WeakPtrFactory<PowerMonitor> weak_ptr_factory_; 194 base::WeakPtrFactory<PowerMonitor> weak_ptr_factory_;
192 195
193 DISALLOW_COPY_AND_ASSIGN(PowerMonitor); 196 DISALLOW_COPY_AND_ASSIGN(PowerMonitor);
194 }; 197 };
195 #endif 198 #endif
196 199
197 EasyUnlockService::EasyUnlockService(Profile* profile) 200 EasyUnlockService::EasyUnlockService(Profile* profile)
198 : profile_(profile), 201 : profile_(profile),
199 bluetooth_detector_(new BluetoothDetector(this)), 202 bluetooth_detector_(new BluetoothDetector(this)),
200 shut_down_(false), 203 shut_down_(false),
204 tpm_key_checked_(false),
201 weak_ptr_factory_(this) { 205 weak_ptr_factory_(this) {
202 extensions::ExtensionSystem::Get(profile_)->ready().Post( 206 extensions::ExtensionSystem::Get(profile_)->ready().Post(
203 FROM_HERE, 207 FROM_HERE,
204 base::Bind(&EasyUnlockService::Initialize, 208 base::Bind(&EasyUnlockService::Initialize,
205 weak_ptr_factory_.GetWeakPtr())); 209 weak_ptr_factory_.GetWeakPtr()));
206 } 210 }
207 211
208 EasyUnlockService::~EasyUnlockService() { 212 EasyUnlockService::~EasyUnlockService() {
209 } 213 }
210 214
(...skipping 14 matching lines...) Expand all
225 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); 229 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
226 registry->RegisterBooleanPref( 230 registry->RegisterBooleanPref(
227 prefs::kEasyUnlockProximityRequired, 231 prefs::kEasyUnlockProximityRequired,
228 false, 232 false,
229 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); 233 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
230 } 234 }
231 235
232 // static 236 // static
233 void EasyUnlockService::RegisterPrefs(PrefRegistrySimple* registry) { 237 void EasyUnlockService::RegisterPrefs(PrefRegistrySimple* registry) {
234 registry->RegisterDictionaryPref(prefs::kEasyUnlockHardlockState); 238 registry->RegisterDictionaryPref(prefs::kEasyUnlockHardlockState);
239 #if defined(OS_CHROMEOS)
240 EasyUnlockTpmKeyManager::RegisterLocalStatePrefs(registry);
241 #endif
235 } 242 }
236 243
237 // static 244 // static
238 void EasyUnlockService::ResetLocalStateForUser(const std::string& user_id) { 245 void EasyUnlockService::ResetLocalStateForUser(const std::string& user_id) {
239 DCHECK(!user_id.empty()); 246 DCHECK(!user_id.empty());
240 247
241 PrefService* local_state = GetLocalState(); 248 PrefService* local_state = GetLocalState();
242 if (!local_state) 249 if (!local_state)
243 return; 250 return;
244 251
245 DictionaryPrefUpdate update(local_state, prefs::kEasyUnlockHardlockState); 252 DictionaryPrefUpdate update(local_state, prefs::kEasyUnlockHardlockState);
246 update->RemoveWithoutPathExpansion(user_id, NULL); 253 update->RemoveWithoutPathExpansion(user_id, NULL);
254
255 #if defined(OS_CHROMEOS)
256 EasyUnlockTpmKeyManager::ResetLocalStateForUser(user_id);
257 #endif
247 } 258 }
248 259
249 bool EasyUnlockService::IsAllowed() { 260 bool EasyUnlockService::IsAllowed() {
250 if (shut_down_) 261 if (shut_down_)
251 return false; 262 return false;
252 263
253 if (CommandLine::ForCurrentProcess()->HasSwitch( 264 if (CommandLine::ForCurrentProcess()->HasSwitch(
254 proximity_auth::switches::kDisableEasyUnlock)) { 265 proximity_auth::switches::kDisableEasyUnlock)) {
255 return false; 266 return false;
256 } 267 }
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 return; 558 return;
548 extensions::ExtensionSystem* extension_system = 559 extensions::ExtensionSystem* extension_system =
549 extensions::ExtensionSystem::Get(profile_); 560 extensions::ExtensionSystem::Get(profile_);
550 extension_system->extension_service()->ReloadExtension( 561 extension_system->extension_service()->ReloadExtension(
551 extension_misc::kEasyUnlockAppId); 562 extension_misc::kEasyUnlockAppId);
552 NotifyUserUpdated(); 563 NotifyUserUpdated();
553 } 564 }
554 565
555 void EasyUnlockService::UpdateAppState() { 566 void EasyUnlockService::UpdateAppState() {
556 if (IsAllowed()) { 567 if (IsAllowed()) {
568 EnsureTpmKeyPresentIfNeeded();
557 LoadApp(); 569 LoadApp();
558 570
559 #if defined(OS_CHROMEOS) 571 #if defined(OS_CHROMEOS)
560 if (!power_monitor_) 572 if (!power_monitor_)
561 power_monitor_.reset(new PowerMonitor(this)); 573 power_monitor_.reset(new PowerMonitor(this));
562 #endif 574 #endif
563 } else { 575 } else {
564 bool bluetooth_waking_up = false; 576 bool bluetooth_waking_up = false;
565 #if defined(OS_CHROMEOS) 577 #if defined(OS_CHROMEOS)
566 // If the service is not allowed due to bluetooth not being detected just 578 // If the service is not allowed due to bluetooth not being detected just
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
684 } 696 }
685 #endif 697 #endif
686 698
687 void EasyUnlockService::PrepareForSuspend() { 699 void EasyUnlockService::PrepareForSuspend() {
688 DisableAppIfLoaded(); 700 DisableAppIfLoaded();
689 if (screenlock_state_handler_ && screenlock_state_handler_->IsActive()) { 701 if (screenlock_state_handler_ && screenlock_state_handler_->IsActive()) {
690 UpdateScreenlockState( 702 UpdateScreenlockState(
691 EasyUnlockScreenlockStateHandler::STATE_BLUETOOTH_CONNECTING); 703 EasyUnlockScreenlockStateHandler::STATE_BLUETOOTH_CONNECTING);
692 } 704 }
693 } 705 }
706
707 void EasyUnlockService::EnsureTpmKeyPresentIfNeeded() {
708 if (tpm_key_checked_ || GetType() != TYPE_REGULAR || GetUserEmail().empty())
709 return;
710
711 #if defined(OS_CHROMEOS)
712 // If this is called before the session is started, the chances are Chrome
713 // is restarting in order to apply user flags. Don't check TPM keys in this
714 // case.
715 if (!user_manager::UserManager::Get() ||
716 !user_manager::UserManager::Get()->IsSessionStarted())
717 return;
718
719 // TODO(tbarzic): Set check_private_key only if previous sign-in attempt
720 // failed.
721 EasyUnlockTpmKeyManagerFactory::GetInstance()->Get(profile_)
722 ->PrepareTpmKey(true /* check_private_key */,
723 base::Closure());
724 #endif // defined(OS_CHROMEOS)
725
726 tpm_key_checked_ = true;
727 }
OLDNEW
« no previous file with comments | « chrome/browser/signin/easy_unlock_service.h ('k') | chrome/browser/signin/easy_unlock_service_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698