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

Side by Side Diff: chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_api.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/extensions/api/easy_unlock_private/easy_unlock_private_ api.h" 5 #include "chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_ api.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
11 #include "base/memory/linked_ptr.h" 11 #include "base/memory/linked_ptr.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 #include "chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_ crypto_delegate.h" 14 #include "chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_ crypto_delegate.h"
15 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/browser/signin/easy_unlock_screenlock_state_handler.h" 16 #include "chrome/browser/signin/easy_unlock_screenlock_state_handler.h"
17 #include "chrome/browser/signin/easy_unlock_service.h" 17 #include "chrome/browser/signin/easy_unlock_service.h"
18 #include "chrome/browser/signin/screenlock_bridge.h" 18 #include "chrome/browser/signin/screenlock_bridge.h"
19 #include "chrome/common/extensions/api/easy_unlock_private.h" 19 #include "chrome/common/extensions/api/easy_unlock_private.h"
20 #include "chrome/grit/generated_resources.h" 20 #include "chrome/grit/generated_resources.h"
21 #include "components/proximity_auth/bluetooth_util.h" 21 #include "components/proximity_auth/bluetooth_util.h"
22 #include "content/public/browser/browser_thread.h" 22 #include "content/public/browser/browser_thread.h"
23 #include "extensions/browser/browser_context_keyed_api_factory.h" 23 #include "extensions/browser/browser_context_keyed_api_factory.h"
24 #include "ui/base/l10n/l10n_util.h" 24 #include "ui/base/l10n/l10n_util.h"
25 25
26 #if defined(OS_CHROMEOS) 26 #if defined(OS_CHROMEOS)
27 #include "chrome/browser/chromeos/chromeos_utils.h" 27 #include "chrome/browser/chromeos/chromeos_utils.h"
28 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_tpm_key_manager. h"
29 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_tpm_key_manager_ factory.h"
28 #include "chrome/browser/ui/webui/options/chromeos/user_image_source.h" 30 #include "chrome/browser/ui/webui/options/chromeos/user_image_source.h"
29 #include "components/user_manager/user.h" 31 #include "components/user_manager/user.h"
30 #include "components/user_manager/user_manager.h" 32 #include "components/user_manager/user_manager.h"
31 #endif 33 #endif
32 34
33 namespace extensions { 35 namespace extensions {
34 namespace api { 36 namespace api {
35 37
36 namespace { 38 namespace {
37 39
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 } 603 }
602 604
603 bool EasyUnlockPrivateGetSignInChallengeFunction::RunAsync() { 605 bool EasyUnlockPrivateGetSignInChallengeFunction::RunAsync() {
604 scoped_ptr<easy_unlock_private::GetSignInChallenge::Params> params( 606 scoped_ptr<easy_unlock_private::GetSignInChallenge::Params> params(
605 easy_unlock_private::GetSignInChallenge::Params::Create(*args_)); 607 easy_unlock_private::GetSignInChallenge::Params::Create(*args_));
606 EXTENSION_FUNCTION_VALIDATE(params.get()); 608 EXTENSION_FUNCTION_VALIDATE(params.get());
607 609
608 Profile* profile = Profile::FromBrowserContext(browser_context()); 610 Profile* profile = Profile::FromBrowserContext(browser_context());
609 const std::string challenge = 611 const std::string challenge =
610 EasyUnlockService::Get(profile)->GetChallenge(); 612 EasyUnlockService::Get(profile)->GetChallenge();
611 // TODO(tbarzic): Implement nonce signing. 613 if (!challenge.empty() && !params->nonce.empty()) {
612 OnDone(challenge, std::string() /* signed_nonce */); 614 EasyUnlockTpmKeyManager* key_manager =
615 EasyUnlockTpmKeyManagerFactory::GetInstance()->Get(profile);
616 if (!key_manager)
617 return false;
xiyuan 2014/12/02 23:15:58 nit: SetError('No EasyUnlockTpmKeyManager.') befor
tbarzic 2014/12/03 19:10:28 Done.
618 key_manager->SignUsingTpmKey(
619 EasyUnlockService::Get(profile)->GetUserEmail(),
620 params->nonce,
621 base::Bind(&EasyUnlockPrivateGetSignInChallengeFunction::OnDone,
622 this,
623 challenge));
624 } else {
625 OnDone(challenge, std::string());
626 }
613 return true; 627 return true;
614 } 628 }
615 629
616 void EasyUnlockPrivateGetSignInChallengeFunction::OnDone( 630 void EasyUnlockPrivateGetSignInChallengeFunction::OnDone(
617 const std::string& challenge, 631 const std::string& challenge,
618 const std::string& signed_nonce) { 632 const std::string& signed_nonce) {
619 results_ = easy_unlock_private::GetSignInChallenge::Results::Create( 633 results_ = easy_unlock_private::GetSignInChallenge::Results::Create(
620 challenge, signed_nonce); 634 challenge, signed_nonce);
621 SendResponse(true); 635 SendResponse(true);
622 } 636 }
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
687 // TODO(tengs): Find a way to get the profile picture for non-ChromeOS 701 // TODO(tengs): Find a way to get the profile picture for non-ChromeOS
688 // devices. 702 // devices.
689 results_ = easy_unlock_private::GetUserImage::Results::Create(""); 703 results_ = easy_unlock_private::GetUserImage::Results::Create("");
690 SetError("Not supported on non-ChromeOS platforms."); 704 SetError("Not supported on non-ChromeOS platforms.");
691 #endif 705 #endif
692 return true; 706 return true;
693 } 707 }
694 708
695 } // namespace api 709 } // namespace api
696 } // namespace extensions 710 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698