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

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/field_trial.h" 10 #include "base/metrics/field_trial.h"
(...skipping 21 matching lines...) Expand all
32 #include "device/bluetooth/bluetooth_adapter.h" 32 #include "device/bluetooth/bluetooth_adapter.h"
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 "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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 base::WeakPtrFactory<PowerMonitor> weak_ptr_factory_; 192 base::WeakPtrFactory<PowerMonitor> weak_ptr_factory_;
190 193
191 DISALLOW_COPY_AND_ASSIGN(PowerMonitor); 194 DISALLOW_COPY_AND_ASSIGN(PowerMonitor);
192 }; 195 };
193 #endif 196 #endif
194 197
195 EasyUnlockService::EasyUnlockService(Profile* profile) 198 EasyUnlockService::EasyUnlockService(Profile* profile)
196 : profile_(profile), 199 : profile_(profile),
197 bluetooth_detector_(new BluetoothDetector(this)), 200 bluetooth_detector_(new BluetoothDetector(this)),
198 shut_down_(false), 201 shut_down_(false),
202 tpm_key_checked_(false),
199 weak_ptr_factory_(this) { 203 weak_ptr_factory_(this) {
200 extensions::ExtensionSystem::Get(profile_)->ready().Post( 204 extensions::ExtensionSystem::Get(profile_)->ready().Post(
201 FROM_HERE, 205 FROM_HERE,
202 base::Bind(&EasyUnlockService::Initialize, 206 base::Bind(&EasyUnlockService::Initialize,
203 weak_ptr_factory_.GetWeakPtr())); 207 weak_ptr_factory_.GetWeakPtr()));
204 } 208 }
205 209
206 EasyUnlockService::~EasyUnlockService() { 210 EasyUnlockService::~EasyUnlockService() {
207 } 211 }
208 212
(...skipping 14 matching lines...) Expand all
223 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); 227 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
224 registry->RegisterBooleanPref( 228 registry->RegisterBooleanPref(
225 prefs::kEasyUnlockProximityRequired, 229 prefs::kEasyUnlockProximityRequired,
226 false, 230 false,
227 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); 231 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
228 } 232 }
229 233
230 // static 234 // static
231 void EasyUnlockService::RegisterPrefs(PrefRegistrySimple* registry) { 235 void EasyUnlockService::RegisterPrefs(PrefRegistrySimple* registry) {
232 registry->RegisterDictionaryPref(prefs::kEasyUnlockHardlockState); 236 registry->RegisterDictionaryPref(prefs::kEasyUnlockHardlockState);
237 #if defined(OS_CHROMEOS)
238 EasyUnlockTpmKeyManager::RegisterLocalStatePrefs(registry);
239 #endif
233 } 240 }
234 241
235 // static 242 // static
236 void EasyUnlockService::ResetLocalStateForUser(const std::string& user_id) { 243 void EasyUnlockService::ResetLocalStateForUser(const std::string& user_id) {
237 DCHECK(!user_id.empty()); 244 DCHECK(!user_id.empty());
238 245
239 PrefService* local_state = GetLocalState(); 246 PrefService* local_state = GetLocalState();
240 if (!local_state) 247 if (!local_state)
241 return; 248 return;
242 249
243 DictionaryPrefUpdate update(local_state, prefs::kEasyUnlockHardlockState); 250 DictionaryPrefUpdate update(local_state, prefs::kEasyUnlockHardlockState);
244 update->RemoveWithoutPathExpansion(user_id, NULL); 251 update->RemoveWithoutPathExpansion(user_id, NULL);
252
253 #if defined(OS_CHROMEOS)
254 EasyUnlockTpmKeyManager::ResetLocalStateForUser(user_id);
255 #endif
245 } 256 }
246 257
247 bool EasyUnlockService::IsAllowed() { 258 bool EasyUnlockService::IsAllowed() {
248 if (shut_down_) 259 if (shut_down_)
249 return false; 260 return false;
250 261
251 if (!IsAllowedInternal()) 262 if (!IsAllowedInternal())
252 return false; 263 return false;
253 264
254 #if defined(OS_CHROMEOS) 265 #if defined(OS_CHROMEOS)
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 return; 536 return;
526 extensions::ExtensionSystem* extension_system = 537 extensions::ExtensionSystem* extension_system =
527 extensions::ExtensionSystem::Get(profile_); 538 extensions::ExtensionSystem::Get(profile_);
528 extension_system->extension_service()->ReloadExtension( 539 extension_system->extension_service()->ReloadExtension(
529 extension_misc::kEasyUnlockAppId); 540 extension_misc::kEasyUnlockAppId);
530 NotifyUserUpdated(); 541 NotifyUserUpdated();
531 } 542 }
532 543
533 void EasyUnlockService::UpdateAppState() { 544 void EasyUnlockService::UpdateAppState() {
534 if (IsAllowed()) { 545 if (IsAllowed()) {
546 EnsureTpmKeyPresentIfNeeded();
535 LoadApp(); 547 LoadApp();
536 548
537 #if defined(OS_CHROMEOS) 549 #if defined(OS_CHROMEOS)
538 if (!power_monitor_) 550 if (!power_monitor_)
539 power_monitor_.reset(new PowerMonitor(this)); 551 power_monitor_.reset(new PowerMonitor(this));
540 #endif 552 #endif
541 } else { 553 } else {
542 bool bluetooth_waking_up = false; 554 bool bluetooth_waking_up = false;
543 #if defined(OS_CHROMEOS) 555 #if defined(OS_CHROMEOS)
544 // If the service is not allowed due to bluetooth not being detected just 556 // 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
662 } 674 }
663 #endif 675 #endif
664 676
665 void EasyUnlockService::PrepareForSuspend() { 677 void EasyUnlockService::PrepareForSuspend() {
666 DisableAppIfLoaded(); 678 DisableAppIfLoaded();
667 if (screenlock_state_handler_ && screenlock_state_handler_->IsActive()) { 679 if (screenlock_state_handler_ && screenlock_state_handler_->IsActive()) {
668 UpdateScreenlockState( 680 UpdateScreenlockState(
669 EasyUnlockScreenlockStateHandler::STATE_BLUETOOTH_CONNECTING); 681 EasyUnlockScreenlockStateHandler::STATE_BLUETOOTH_CONNECTING);
670 } 682 }
671 } 683 }
684
685 void EasyUnlockService::EnsureTpmKeyPresentIfNeeded() {
686 if (tpm_key_checked_ || GetType() != TYPE_REGULAR || GetUserEmail().empty())
687 return;
688
689 #if defined(OS_CHROMEOS)
690 // If this is called before the session is started, the chances are Chrome
691 // is restarting in order to apply user flags. Don't check TPM keys in this
692 // case.
693 if (!user_manager::UserManager::Get() ||
694 !user_manager::UserManager::Get()->IsSessionStarted())
695 return;
696
697 // TODO(tbarzic): Set check_private_key only if previous sign-in attempt
698 // failed.
699 EasyUnlockTpmKeyManagerFactory::GetInstance()->Get(profile_)
700 ->PrepareTpmKey(GetUserEmail(),
701 true /* check_private_key */,
702 base::Closure());
703 #endif // defined(OS_CHROMEOS)
704
705 tpm_key_checked_ = true;
706 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698