OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_CERT_LOADER_H_ | 5 #ifndef CHROMEOS_CERT_LOADER_H_ |
6 #define CHROMEOS_CERT_LOADER_H_ | 6 #define CHROMEOS_CERT_LOADER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 bool CertificatesLoading() const; | 93 bool CertificatesLoading() const; |
94 | 94 |
95 // Returns true if the TPM is available for hardware-backed certificates. | 95 // Returns true if the TPM is available for hardware-backed certificates. |
96 bool IsHardwareBacked() const; | 96 bool IsHardwareBacked() const; |
97 | 97 |
98 bool certificates_loaded() const { return certificates_loaded_; } | 98 bool certificates_loaded() const { return certificates_loaded_; } |
99 | 99 |
100 // TPM info is only valid once the TPM is available (IsHardwareBacked is | 100 // TPM info is only valid once the TPM is available (IsHardwareBacked is |
101 // true). Otherwise empty strings will be returned. | 101 // true). Otherwise empty strings will be returned. |
102 const std::string& tpm_token_name() const { return tpm_token_name_; } | 102 const std::string& tpm_token_name() const { return tpm_token_name_; } |
103 const std::string& tpm_token_slot() const { return tpm_token_slot_; } | 103 int tpm_token_slot_id() const { return tpm_token_slot_id_; } |
104 const std::string& tpm_user_pin() const { return tpm_user_pin_; } | 104 const std::string& tpm_user_pin() const { return tpm_user_pin_; } |
105 | 105 |
106 // This will be empty until certificates_loaded() is true. | 106 // This will be empty until certificates_loaded() is true. |
107 const net::CertificateList& cert_list() const { return cert_list_; } | 107 const net::CertificateList& cert_list() const { return cert_list_; } |
108 | 108 |
109 private: | 109 private: |
110 CertLoader(); | 110 CertLoader(); |
111 virtual ~CertLoader(); | 111 virtual ~CertLoader(); |
112 | 112 |
113 void MaybeRequestCertificates(); | 113 void MaybeRequestCertificates(); |
114 | 114 |
115 // This is the cyclic chain of callbacks to initialize the TPM token and to | 115 // This is the cyclic chain of callbacks to initialize the TPM token and to |
116 // kick off the update of the certificate list. | 116 // kick off the update of the certificate list. |
117 void InitializeTokenAndLoadCertificates(); | 117 void InitializeTokenAndLoadCertificates(); |
118 void RetryTokenInitializationLater(); | 118 void RetryTokenInitializationLater(); |
119 void OnPersistentNSSDBOpened(); | 119 void OnPersistentNSSDBOpened(); |
120 void OnTpmIsEnabled(DBusMethodCallStatus call_status, | 120 void OnTpmIsEnabled(DBusMethodCallStatus call_status, |
121 bool tpm_is_enabled); | 121 bool tpm_is_enabled); |
122 void OnPkcs11IsTpmTokenReady(DBusMethodCallStatus call_status, | 122 void OnPkcs11IsTpmTokenReady(DBusMethodCallStatus call_status, |
123 bool is_tpm_token_ready); | 123 bool is_tpm_token_ready); |
124 void OnPkcs11GetTpmTokenInfo(DBusMethodCallStatus call_status, | 124 void OnPkcs11GetTpmTokenInfo(DBusMethodCallStatus call_status, |
125 const std::string& token_name, | 125 const std::string& token_name, |
126 const std::string& user_pin, | 126 const std::string& user_pin, |
127 int token_slot); | 127 int token_slot_id); |
128 void OnTPMTokenInitialized(bool success); | 128 void OnTPMTokenInitialized(bool success); |
129 | 129 |
130 // These calls handle the updating of the certificate list after the TPM token | 130 // These calls handle the updating of the certificate list after the TPM token |
131 // was initialized. | 131 // was initialized. |
132 | 132 |
133 // Start certificate loading. Must be called at most once. | 133 // Start certificate loading. Must be called at most once. |
134 void StartLoadCertificates(); | 134 void StartLoadCertificates(); |
135 | 135 |
136 // Trigger a certificate load. If a certificate loading task is already in | 136 // Trigger a certificate load. If a certificate loading task is already in |
137 // progress, will start a reload once the current task finised. | 137 // progress, will start a reload once the current task finised. |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 TPM_TOKEN_INITIALIZED, | 171 TPM_TOKEN_INITIALIZED, |
172 }; | 172 }; |
173 TPMTokenState tpm_token_state_; | 173 TPMTokenState tpm_token_state_; |
174 | 174 |
175 // The current request delay before the next attempt to initialize the | 175 // The current request delay before the next attempt to initialize the |
176 // TPM. Will be adapted after each attempt. | 176 // TPM. Will be adapted after each attempt. |
177 base::TimeDelta tpm_request_delay_; | 177 base::TimeDelta tpm_request_delay_; |
178 | 178 |
179 // Cached TPM token info. | 179 // Cached TPM token info. |
180 std::string tpm_token_name_; | 180 std::string tpm_token_name_; |
181 std::string tpm_token_slot_; | 181 int tpm_token_slot_id_; |
182 std::string tpm_user_pin_; | 182 std::string tpm_user_pin_; |
183 | 183 |
184 // Cached Certificates. | 184 // Cached Certificates. |
185 net::CertificateList cert_list_; | 185 net::CertificateList cert_list_; |
186 | 186 |
187 base::ThreadChecker thread_checker_; | 187 base::ThreadChecker thread_checker_; |
188 | 188 |
189 // TaskRunner for crypto calls. | 189 // TaskRunner for crypto calls. |
190 scoped_refptr<base::SequencedTaskRunner> crypto_task_runner_; | 190 scoped_refptr<base::SequencedTaskRunner> crypto_task_runner_; |
191 | 191 |
192 // TaskRunner for other slow tasks. May be set in tests. | 192 // TaskRunner for other slow tasks. May be set in tests. |
193 scoped_refptr<base::TaskRunner> slow_task_runner_for_test_; | 193 scoped_refptr<base::TaskRunner> slow_task_runner_for_test_; |
194 | 194 |
195 // This factory should be used only for callbacks during TPMToken | 195 // This factory should be used only for callbacks during TPMToken |
196 // initialization. | 196 // initialization. |
197 base::WeakPtrFactory<CertLoader> initialize_token_factory_; | 197 base::WeakPtrFactory<CertLoader> initialize_token_factory_; |
198 | 198 |
199 // This factory should be used only for callbacks during updating the | 199 // This factory should be used only for callbacks during updating the |
200 // certificate list. | 200 // certificate list. |
201 base::WeakPtrFactory<CertLoader> update_certificates_factory_; | 201 base::WeakPtrFactory<CertLoader> update_certificates_factory_; |
202 | 202 |
203 DISALLOW_COPY_AND_ASSIGN(CertLoader); | 203 DISALLOW_COPY_AND_ASSIGN(CertLoader); |
204 }; | 204 }; |
205 | 205 |
206 } // namespace chromeos | 206 } // namespace chromeos |
207 | 207 |
208 #endif // CHROMEOS_CERT_LOADER_H_ | 208 #endif // CHROMEOS_CERT_LOADER_H_ |
OLD | NEW |