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

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/prefs/pref_registry_simple.h" 10 #include "base/prefs/pref_registry_simple.h"
(...skipping 21 matching lines...) Expand all
32 #include "device/bluetooth/bluetooth_adapter_factory.h" 32 #include "device/bluetooth/bluetooth_adapter_factory.h"
33 #include "extensions/browser/event_router.h" 33 #include "extensions/browser/event_router.h"
34 #include "extensions/browser/extension_registry.h" 34 #include "extensions/browser/extension_registry.h"
35 #include "extensions/browser/extension_system.h" 35 #include "extensions/browser/extension_system.h"
36 #include "extensions/common/one_shot_event.h" 36 #include "extensions/common/one_shot_event.h"
37 #include "grit/browser_resources.h" 37 #include "grit/browser_resources.h"
38 38
39 #if defined(OS_CHROMEOS) 39 #if defined(OS_CHROMEOS)
40 #include "base/sys_info.h" 40 #include "base/sys_info.h"
41 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_key_manager.h" 41 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_key_manager.h"
42 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_tpm_key_manager. h"
43 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_tpm_key_manager_ factory.h"
42 #include "chrome/browser/chromeos/login/session/user_session_manager.h" 44 #include "chrome/browser/chromeos/login/session/user_session_manager.h"
43 #include "chrome/browser/chromeos/profiles/profile_helper.h" 45 #include "chrome/browser/chromeos/profiles/profile_helper.h"
44 #include "chromeos/dbus/dbus_thread_manager.h" 46 #include "chromeos/dbus/dbus_thread_manager.h"
45 #include "chromeos/dbus/power_manager_client.h" 47 #include "chromeos/dbus/power_manager_client.h"
48 #include "components/user_manager/user_manager.h"
46 #endif 49 #endif
47 50
48 namespace { 51 namespace {
49 52
50 extensions::ComponentLoader* GetComponentLoader( 53 extensions::ComponentLoader* GetComponentLoader(
51 content::BrowserContext* context) { 54 content::BrowserContext* context) {
52 extensions::ExtensionSystem* extension_system = 55 extensions::ExtensionSystem* extension_system =
53 extensions::ExtensionSystem::Get(context); 56 extensions::ExtensionSystem::Get(context);
54 ExtensionService* extension_service = extension_system->extension_service(); 57 ExtensionService* extension_service = extension_system->extension_service();
55 return extension_service->component_loader(); 58 return extension_service->component_loader();
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 base::WeakPtrFactory<PowerMonitor> weak_ptr_factory_; 179 base::WeakPtrFactory<PowerMonitor> weak_ptr_factory_;
177 180
178 DISALLOW_COPY_AND_ASSIGN(PowerMonitor); 181 DISALLOW_COPY_AND_ASSIGN(PowerMonitor);
179 }; 182 };
180 #endif 183 #endif
181 184
182 EasyUnlockService::EasyUnlockService(Profile* profile) 185 EasyUnlockService::EasyUnlockService(Profile* profile)
183 : profile_(profile), 186 : profile_(profile),
184 bluetooth_detector_(new BluetoothDetector(this)), 187 bluetooth_detector_(new BluetoothDetector(this)),
185 shut_down_(false), 188 shut_down_(false),
189 tpm_key_checked_(false),
186 weak_ptr_factory_(this) { 190 weak_ptr_factory_(this) {
187 extensions::ExtensionSystem::Get(profile_)->ready().Post( 191 extensions::ExtensionSystem::Get(profile_)->ready().Post(
188 FROM_HERE, 192 FROM_HERE,
189 base::Bind(&EasyUnlockService::Initialize, 193 base::Bind(&EasyUnlockService::Initialize,
190 weak_ptr_factory_.GetWeakPtr())); 194 weak_ptr_factory_.GetWeakPtr()));
191 } 195 }
192 196
193 EasyUnlockService::~EasyUnlockService() { 197 EasyUnlockService::~EasyUnlockService() {
194 } 198 }
195 199
(...skipping 14 matching lines...) Expand all
210 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); 214 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
211 registry->RegisterBooleanPref( 215 registry->RegisterBooleanPref(
212 prefs::kEasyUnlockProximityRequired, 216 prefs::kEasyUnlockProximityRequired,
213 false, 217 false,
214 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); 218 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
215 } 219 }
216 220
217 // static 221 // static
218 void EasyUnlockService::RegisterPrefs(PrefRegistrySimple* registry) { 222 void EasyUnlockService::RegisterPrefs(PrefRegistrySimple* registry) {
219 registry->RegisterDictionaryPref(prefs::kEasyUnlockHardlockState); 223 registry->RegisterDictionaryPref(prefs::kEasyUnlockHardlockState);
224 #if defined(OS_CHROMEOS)
225 EasyUnlockTpmKeyManager::RegisterLocalStatePrefs(registry);
226 #endif
220 } 227 }
221 228
222 // static 229 // static
223 void EasyUnlockService::ResetLocalStateForUser(const std::string& user_id) { 230 void EasyUnlockService::ResetLocalStateForUser(const std::string& user_id) {
224 DCHECK(!user_id.empty()); 231 DCHECK(!user_id.empty());
225 232
226 PrefService* local_state = GetLocalState(); 233 PrefService* local_state = GetLocalState();
227 if (!local_state) 234 if (!local_state)
228 return; 235 return;
229 236
230 DictionaryPrefUpdate update(local_state, prefs::kEasyUnlockHardlockState); 237 DictionaryPrefUpdate update(local_state, prefs::kEasyUnlockHardlockState);
231 update->RemoveWithoutPathExpansion(user_id, NULL); 238 update->RemoveWithoutPathExpansion(user_id, NULL);
239
240 #if defined(OS_CHROMEOS)
241 EasyUnlockTpmKeyManager::ResetLocalStateForUser(user_id);
242 #endif
232 } 243 }
233 244
234 bool EasyUnlockService::IsAllowed() { 245 bool EasyUnlockService::IsAllowed() {
235 if (shut_down_) 246 if (shut_down_)
236 return false; 247 return false;
237 248
238 if (CommandLine::ForCurrentProcess()->HasSwitch( 249 if (CommandLine::ForCurrentProcess()->HasSwitch(
239 proximity_auth::switches::kDisableEasyUnlock)) { 250 proximity_auth::switches::kDisableEasyUnlock)) {
240 return false; 251 return false;
241 } 252 }
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 return; 537 return;
527 extensions::ExtensionSystem* extension_system = 538 extensions::ExtensionSystem* extension_system =
528 extensions::ExtensionSystem::Get(profile_); 539 extensions::ExtensionSystem::Get(profile_);
529 extension_system->extension_service()->ReloadExtension( 540 extension_system->extension_service()->ReloadExtension(
530 extension_misc::kEasyUnlockAppId); 541 extension_misc::kEasyUnlockAppId);
531 NotifyUserUpdated(); 542 NotifyUserUpdated();
532 } 543 }
533 544
534 void EasyUnlockService::UpdateAppState() { 545 void EasyUnlockService::UpdateAppState() {
535 if (IsAllowed()) { 546 if (IsAllowed()) {
547 EnsureTpmKeyPresentIfNeeded();
536 LoadApp(); 548 LoadApp();
537 549
538 #if defined(OS_CHROMEOS) 550 #if defined(OS_CHROMEOS)
539 if (!power_monitor_) 551 if (!power_monitor_)
540 power_monitor_.reset(new PowerMonitor(this)); 552 power_monitor_.reset(new PowerMonitor(this));
541 #endif 553 #endif
542 } else { 554 } else {
543 bool bluetooth_waking_up = false; 555 bool bluetooth_waking_up = false;
544 #if defined(OS_CHROMEOS) 556 #if defined(OS_CHROMEOS)
545 // If the service is not allowed due to bluetooth not being detected just 557 // 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
663 } 675 }
664 #endif 676 #endif
665 677
666 void EasyUnlockService::PrepareForSuspend() { 678 void EasyUnlockService::PrepareForSuspend() {
667 DisableAppIfLoaded(); 679 DisableAppIfLoaded();
668 if (screenlock_state_handler_ && screenlock_state_handler_->IsActive()) { 680 if (screenlock_state_handler_ && screenlock_state_handler_->IsActive()) {
669 UpdateScreenlockState( 681 UpdateScreenlockState(
670 EasyUnlockScreenlockStateHandler::STATE_BLUETOOTH_CONNECTING); 682 EasyUnlockScreenlockStateHandler::STATE_BLUETOOTH_CONNECTING);
671 } 683 }
672 } 684 }
685
686 void EasyUnlockService::EnsureTpmKeyPresentIfNeeded() {
687 if (tpm_key_checked_ || GetType() != TYPE_REGULAR || GetUserEmail().empty())
688 return;
689
690 #if defined(OS_CHROMEOS)
691 // If this is called before the session is started, the chances are Chrome
692 // is restarting in order to apply user flags. Don't check TPM keys in this
693 // case.
694 if (!user_manager::UserManager::Get() ||
695 !user_manager::UserManager::Get()->IsSessionStarted())
696 return;
697
698 // TODO(tbarzic): Set check_private_key only if previous sign-in attempt
699 // failed.
700 EasyUnlockTpmKeyManagerFactory::GetInstance()->Get(profile_)
701 ->PrepareTpmKey(GetUserEmail(),
702 true /* check_private_key */,
703 base::Closure());
704 #endif // defined(OS_CHROMEOS)
705
706 tpm_key_checked_ = true;
707 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698