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

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 562 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 602
601 EasyUnlockPrivateGetSignInChallengeFunction:: 603 EasyUnlockPrivateGetSignInChallengeFunction::
602 ~EasyUnlockPrivateGetSignInChallengeFunction() { 604 ~EasyUnlockPrivateGetSignInChallengeFunction() {
603 } 605 }
604 606
605 bool EasyUnlockPrivateGetSignInChallengeFunction::RunAsync() { 607 bool EasyUnlockPrivateGetSignInChallengeFunction::RunAsync() {
606 scoped_ptr<easy_unlock_private::GetSignInChallenge::Params> params( 608 scoped_ptr<easy_unlock_private::GetSignInChallenge::Params> params(
607 easy_unlock_private::GetSignInChallenge::Params::Create(*args_)); 609 easy_unlock_private::GetSignInChallenge::Params::Create(*args_));
608 EXTENSION_FUNCTION_VALIDATE(params.get()); 610 EXTENSION_FUNCTION_VALIDATE(params.get());
609 611
612 #if defined(OS_CHROMEOS)
610 Profile* profile = Profile::FromBrowserContext(browser_context()); 613 Profile* profile = Profile::FromBrowserContext(browser_context());
611 const std::string challenge = 614 const std::string challenge =
612 EasyUnlockService::Get(profile)->GetChallenge(); 615 EasyUnlockService::Get(profile)->GetChallenge();
613 // TODO(tbarzic): Implement nonce signing. 616 if (!challenge.empty() && !params->nonce.empty()) {
614 OnDone(challenge, std::string() /* signed_nonce */); 617 EasyUnlockTpmKeyManager* key_manager =
618 EasyUnlockTpmKeyManagerFactory::GetInstance()->Get(profile);
619 if (!key_manager) {
620 SetError("No EasyUnlockTpmKeyManager.");
621 return false;
622 }
623 key_manager->SignUsingTpmKey(
624 EasyUnlockService::Get(profile)->GetUserEmail(),
625 params->nonce,
626 base::Bind(&EasyUnlockPrivateGetSignInChallengeFunction::OnDone,
627 this,
628 challenge));
629 } else {
630 OnDone(challenge, std::string());
631 }
615 return true; 632 return true;
633 #else // if !defined(OS_CHROMEOS)
634 SetError("Sign-in not supported.");
635 return false;
636 #endif // defined(OS_CHROMEOS)
616 } 637 }
617 638
618 void EasyUnlockPrivateGetSignInChallengeFunction::OnDone( 639 void EasyUnlockPrivateGetSignInChallengeFunction::OnDone(
619 const std::string& challenge, 640 const std::string& challenge,
620 const std::string& signed_nonce) { 641 const std::string& signed_nonce) {
621 results_ = easy_unlock_private::GetSignInChallenge::Results::Create( 642 results_ = easy_unlock_private::GetSignInChallenge::Results::Create(
622 challenge, signed_nonce); 643 challenge, signed_nonce);
623 SendResponse(true); 644 SendResponse(true);
624 } 645 }
625 646
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
689 // TODO(tengs): Find a way to get the profile picture for non-ChromeOS 710 // TODO(tengs): Find a way to get the profile picture for non-ChromeOS
690 // devices. 711 // devices.
691 results_ = easy_unlock_private::GetUserImage::Results::Create(""); 712 results_ = easy_unlock_private::GetUserImage::Results::Create("");
692 SetError("Not supported on non-ChromeOS platforms."); 713 SetError("Not supported on non-ChromeOS platforms.");
693 #endif 714 #endif
694 return true; 715 return true;
695 } 716 }
696 717
697 } // namespace api 718 } // namespace api
698 } // namespace extensions 719 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698