OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_EASY_UNLOCK_EASY_UNLOCK_CHALLENGE_WRAPPER_ H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_EASY_UNLOCK_EASY_UNLOCK_CHALLENGE_WRAPPER_ H_ |
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_EASY_UNLOCK_EASY_UNLOCK_CHALLENGE_WRAPPER_ H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_EASY_UNLOCK_EASY_UNLOCK_CHALLENGE_WRAPPER_ H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
13 #include "components/signin/core/account_id/account_id.h" | |
13 | 14 |
14 class EasyUnlockTpmKeyManager; | 15 class EasyUnlockTpmKeyManager; |
15 | 16 |
16 namespace chromeos { | 17 namespace chromeos { |
17 | 18 |
18 // Wraps a user challenge in a SecureMessage that can be verified by the remote | 19 // Wraps a user challenge in a SecureMessage that can be verified by the remote |
19 // device, containing the signature by the TPM of some unique data from the | 20 // device, containing the signature by the TPM of some unique data from the |
20 // secure channel between the two devices. | 21 // secure channel between the two devices. |
21 class EasyUnlockChallengeWrapper { | 22 class EasyUnlockChallengeWrapper { |
22 public: | 23 public: |
23 // Creates the instance: | 24 // Creates the instance: |
24 // |challenge|: The raw challenge to wrap. | 25 // |challenge|: The raw challenge to wrap. |
25 // |channel_binding_data|: Data unique to the current secure channel such that | 26 // |channel_binding_data|: Data unique to the current secure channel such that |
26 // we can bind with a TPM signature. | 27 // we can bind with a TPM signature. |
27 // |user_id|: The id of the user who owns both devices. | 28 // |account_id|: The id of the user who owns both devices. |
28 // |key_manager|: Responsible for signing some piece of data with the TPM. | 29 // |key_manager|: Responsible for signing some piece of data with the TPM. |
29 // Not owned and should outlive this instance. | 30 // Not owned and should outlive this instance. |
30 EasyUnlockChallengeWrapper(const std::string& challenge, | 31 EasyUnlockChallengeWrapper(const std::string& challenge, |
31 const std::string& channel_binding_data, | 32 const std::string& channel_binding_data, |
32 const std::string& user_id, | 33 const AccountId& account_id, |
33 EasyUnlockTpmKeyManager* key_manager); | 34 EasyUnlockTpmKeyManager* key_manager); |
34 virtual ~EasyUnlockChallengeWrapper(); | 35 virtual ~EasyUnlockChallengeWrapper(); |
35 | 36 |
36 // Wraps the challenge and invokes |callback| with the |wrapped_challenge| | 37 // Wraps the challenge and invokes |callback| with the |wrapped_challenge| |
37 // that will be send directly to the remote device. | 38 // that will be send directly to the remote device. |
38 typedef base::Callback<void(const std::string& wrapped_challenge)> | 39 typedef base::Callback<void(const std::string& wrapped_challenge)> |
39 WrappedChallengeCallback; | 40 WrappedChallengeCallback; |
40 void WrapChallenge(const WrappedChallengeCallback& callback); | 41 void WrapChallenge(const WrappedChallengeCallback& callback); |
41 | 42 |
42 protected: | 43 protected: |
43 // Signs |data_to_sign| with the TPM. |callback| will be invoked upon | 44 // Signs |data_to_sign| with the TPM. |callback| will be invoked upon |
44 // completion. Exposed for testing. | 45 // completion. Exposed for testing. |
45 virtual void SignUsingTpmKey( | 46 virtual void SignUsingTpmKey( |
46 const std::string& data_to_sign, | 47 const std::string& data_to_sign, |
47 const base::Callback<void(const std::string&)>& callback); | 48 const base::Callback<void(const std::string&)>& callback); |
48 | 49 |
49 private: | 50 private: |
50 // Called when the channel binding data is signed by the TPM and completes the | 51 // Called when the channel binding data is signed by the TPM and completes the |
51 // wrapping. | 52 // wrapping. |
52 void OnChannelBindingDataSigned(const std::string& signature_metadata, | 53 void OnChannelBindingDataSigned(const std::string& signature_metadata, |
53 const std::string& signature); | 54 const std::string& signature); |
54 | 55 |
55 // The raw challenge for the remote device. | 56 // The raw challenge for the remote device. |
56 const std::string challenge_; | 57 const std::string challenge_; |
57 | 58 |
58 // Data specific to the current secure channel to be signed by the TPM. | 59 // Data specific to the current secure channel to be signed by the TPM. |
59 const std::string channel_binding_data_; | 60 const std::string channel_binding_data_; |
60 | 61 |
61 // The id of the user who owns both devices. | 62 // The id of the user who owns both devices. |
62 const std::string user_id_; | 63 const AccountId account_id_; |
achuithb
2015/12/04 10:12:52
Should this be a const pointer or is a copy correc
Alexander Alekseev
2015/12/04 12:44:06
It is created as a copy of a temporary object. So
| |
63 | 64 |
64 // Responsible for signing data with the TPM. Not owned. | 65 // Responsible for signing data with the TPM. Not owned. |
65 EasyUnlockTpmKeyManager* key_manager_; | 66 EasyUnlockTpmKeyManager* key_manager_; |
66 | 67 |
67 // Called when wrapping completes. | 68 // Called when wrapping completes. |
68 WrappedChallengeCallback callback_; | 69 WrappedChallengeCallback callback_; |
69 | 70 |
70 base::WeakPtrFactory<EasyUnlockChallengeWrapper> weak_ptr_factory_; | 71 base::WeakPtrFactory<EasyUnlockChallengeWrapper> weak_ptr_factory_; |
71 | 72 |
72 DISALLOW_COPY_AND_ASSIGN(EasyUnlockChallengeWrapper); | 73 DISALLOW_COPY_AND_ASSIGN(EasyUnlockChallengeWrapper); |
73 }; | 74 }; |
74 | 75 |
75 } // namespace chromeos | 76 } // namespace chromeos |
76 | 77 |
77 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_EASY_UNLOCK_EASY_UNLOCK_CHALLENGE_WRAPP ER_H_ | 78 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_EASY_UNLOCK_EASY_UNLOCK_CHALLENGE_WRAPP ER_H_ |
OLD | NEW |