OLD | NEW |
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 #ifndef CHROMEOS_TPM_TPM_TOKEN_LOADER_H_ | 5 #ifndef CHROMEOS_TPM_TPM_TOKEN_LOADER_H_ |
6 #define CHROMEOS_TPM_TPM_TOKEN_LOADER_H_ | 6 #define CHROMEOS_TPM_TPM_TOKEN_LOADER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 // Returns true if the global instance has been initialized. | 59 // Returns true if the global instance has been initialized. |
60 static bool IsInitialized(); | 60 static bool IsInitialized(); |
61 | 61 |
62 // |crypto_task_runner| is the task runner that any synchronous crypto calls | 62 // |crypto_task_runner| is the task runner that any synchronous crypto calls |
63 // should be made from, e.g. in Chrome this is the IO thread. Must be called | 63 // should be made from, e.g. in Chrome this is the IO thread. Must be called |
64 // after the thread is started. When called, this will attempt to start TPM | 64 // after the thread is started. When called, this will attempt to start TPM |
65 // token loading. | 65 // token loading. |
66 void SetCryptoTaskRunner( | 66 void SetCryptoTaskRunner( |
67 const scoped_refptr<base::SequencedTaskRunner>& crypto_task_runner); | 67 const scoped_refptr<base::SequencedTaskRunner>& crypto_task_runner); |
68 | 68 |
| 69 // Starts loading TPM system token, if not yet started. It should be called |
| 70 // if the system token has to be loaded before a user logs in. By default (if |
| 71 // |EnsureStarted| is not called) system token loading will start when the |
| 72 // login state changes to LOGGED_IN_ACTIVE. |
| 73 void EnsureStarted(); |
| 74 |
69 // Checks if the TPM token is enabled. If the state is unknown, |callback| | 75 // Checks if the TPM token is enabled. If the state is unknown, |callback| |
70 // will be called back once the TPM state is known. | 76 // will be called back once the TPM state is known. |
71 TPMTokenStatus IsTPMTokenEnabled(const TPMReadyCallback& callback); | 77 TPMTokenStatus IsTPMTokenEnabled(const TPMReadyCallback& callback); |
72 | 78 |
73 std::string tpm_user_pin() const { return tpm_user_pin_; } | 79 std::string tpm_user_pin() const { return tpm_user_pin_; } |
74 | 80 |
75 private: | 81 private: |
76 explicit TPMTokenLoader(bool for_test); | 82 explicit TPMTokenLoader(bool for_test); |
77 ~TPMTokenLoader() override; | 83 ~TPMTokenLoader() override; |
78 | 84 |
(...skipping 30 matching lines...) Expand all Loading... |
109 TPM_TOKEN_INITIALIZED, | 115 TPM_TOKEN_INITIALIZED, |
110 }; | 116 }; |
111 TPMTokenState tpm_token_state_; | 117 TPMTokenState tpm_token_state_; |
112 | 118 |
113 scoped_ptr<TPMTokenInfoGetter> tpm_token_info_getter_; | 119 scoped_ptr<TPMTokenInfoGetter> tpm_token_info_getter_; |
114 | 120 |
115 // Cached TPM token info. | 121 // Cached TPM token info. |
116 int tpm_token_slot_id_; | 122 int tpm_token_slot_id_; |
117 std::string tpm_user_pin_; | 123 std::string tpm_user_pin_; |
118 | 124 |
| 125 // Whether TPM system token loading may be started before user log in. |
| 126 // This will be true iff |EnsureStarted| was called. |
| 127 bool can_start_before_login_; |
| 128 |
119 base::ThreadChecker thread_checker_; | 129 base::ThreadChecker thread_checker_; |
120 | 130 |
121 // TaskRunner for crypto calls. | 131 // TaskRunner for crypto calls. |
122 scoped_refptr<base::SequencedTaskRunner> crypto_task_runner_; | 132 scoped_refptr<base::SequencedTaskRunner> crypto_task_runner_; |
123 | 133 |
124 base::WeakPtrFactory<TPMTokenLoader> weak_factory_; | 134 base::WeakPtrFactory<TPMTokenLoader> weak_factory_; |
125 | 135 |
126 DISALLOW_COPY_AND_ASSIGN(TPMTokenLoader); | 136 DISALLOW_COPY_AND_ASSIGN(TPMTokenLoader); |
127 }; | 137 }; |
128 | 138 |
129 } // namespace chromeos | 139 } // namespace chromeos |
130 | 140 |
131 #endif // CHROMEOS_TPM_TPM_TOKEN_LOADER_H_ | 141 #endif // CHROMEOS_TPM_TPM_TOKEN_LOADER_H_ |
OLD | NEW |