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

Side by Side Diff: chromeos/network/cert_loader.h

Issue 15649018: Call crypto::InitializeTPMToken on the IO thread (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge Created 7 years, 6 months 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 | Annotate | Revision Log
OLDNEW
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_NETWORK_CERT_LOADER_H_ 5 #ifndef CHROMEOS_NETWORK_CERT_LOADER_H_
6 #define CHROMEOS_NETWORK_CERT_LOADER_H_ 6 #define CHROMEOS_NETWORK_CERT_LOADER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "base/observer_list_threadsafe.h" 13 #include "base/observer_list_threadsafe.h"
14 #include "base/threading/thread_checker.h" 14 #include "base/threading/thread_checker.h"
15 #include "chromeos/chromeos_export.h" 15 #include "chromeos/chromeos_export.h"
16 #include "chromeos/dbus/dbus_method_call_status.h" 16 #include "chromeos/dbus/dbus_method_call_status.h"
17 #include "chromeos/login/login_state.h" 17 #include "chromeos/login/login_state.h"
18 #include "chromeos/network/network_handler.h" 18 #include "chromeos/network/network_handler.h"
19 #include "net/cert/cert_database.h" 19 #include "net/cert/cert_database.h"
20 #include "net/cert/x509_certificate.h" 20 #include "net/cert/x509_certificate.h"
21 21
22 namespace base {
23 class SequencedTaskRunner;
24 }
25
22 namespace crypto { 26 namespace crypto {
23 class SymmetricKey; 27 class SymmetricKey;
24 } 28 }
25 29
26 namespace chromeos { 30 namespace chromeos {
27 31
28 // This class is responsible for initializing the TPM token and loading 32 // This class is responsible for initializing the TPM token and loading
29 // certificates once the TPM is initialized. It is expected to be constructed 33 // certificates once the TPM is initialized. It is expected to be constructed
30 // on the UI thread and public methods should all be called from the UI thread. 34 // on the UI thread and public methods should all be called from the UI thread.
31 // When certificates have been loaded (after login completes), or the cert 35 // When certificates have been loaded (after login completes), or the cert
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 const std::string& tpm_token_name() const { return tpm_token_name_; } 74 const std::string& tpm_token_name() const { return tpm_token_name_; }
71 const std::string& tpm_token_slot() const { return tpm_token_slot_; } 75 const std::string& tpm_token_slot() const { return tpm_token_slot_; }
72 const std::string& tpm_user_pin() const { return tpm_user_pin_; } 76 const std::string& tpm_user_pin() const { return tpm_user_pin_; }
73 77
74 // This will be empty until certificates_loaded() is true. 78 // This will be empty until certificates_loaded() is true.
75 const net::CertificateList& cert_list() const { return cert_list_; } 79 const net::CertificateList& cert_list() const { return cert_list_; }
76 80
77 private: 81 private:
78 friend class NetworkHandler; 82 friend class NetworkHandler;
79 CertLoader(); 83 CertLoader();
84 // |crypto_task_runner| is the task runner that any synchronous crypto calls
85 // should be made from. In Chrome this is the IO thread.
Ryan Sleevi 2013/06/06 23:03:41 Given that chromeos/ is only allowed to depend on
stevenjb 2013/06/07 02:37:47 This is still the chrome project codebase. We comm
Ryan Sleevi 2013/06/07 23:12:43 Sorry I wasn't clear here. Even though this is th
86 void Init(const scoped_refptr<base::SequencedTaskRunner>& crypto_task_runner);
80 87
81 void RequestCertificates(); 88 void RequestCertificates();
89 void CallOpenPersistentNSSDB();
82 90
83 // This is the cyclic chain of callbacks to initialize the TPM token and to 91 // This is the cyclic chain of callbacks to initialize the TPM token and to
84 // kick off the update of the certificate list. 92 // kick off the update of the certificate list.
85 void InitializeTokenAndLoadCertificates(); 93 void InitializeTokenAndLoadCertificates();
86 void RetryTokenInitializationLater(); 94 void RetryTokenInitializationLater();
87 void OnTpmIsEnabled(DBusMethodCallStatus call_status, 95 void OnTpmIsEnabled(DBusMethodCallStatus call_status,
88 bool tpm_is_enabled); 96 bool tpm_is_enabled);
89 void OnPkcs11IsTpmTokenReady(DBusMethodCallStatus call_status, 97 void OnPkcs11IsTpmTokenReady(DBusMethodCallStatus call_status,
90 bool is_tpm_token_ready); 98 bool is_tpm_token_ready);
91 void OnPkcs11GetTpmTokenInfo(DBusMethodCallStatus call_status, 99 void OnPkcs11GetTpmTokenInfo(DBusMethodCallStatus call_status,
92 const std::string& token_name, 100 const std::string& token_name,
93 const std::string& user_pin); 101 const std::string& user_pin);
102 void CallInitializeTPMToken();
94 void InitializeNSSForTPMToken(); 103 void InitializeNSSForTPMToken();
95 104
96 // These calls handle the updating of the certificate list after the TPM token 105 // These calls handle the updating of the certificate list after the TPM token
97 // was initialized. 106 // was initialized.
98 void StartLoadCertificates(); 107 void StartLoadCertificates();
99 void UpdateCertificates(net::CertificateList* cert_list); 108 void UpdateCertificates(net::CertificateList* cert_list);
100 109
101 void NotifyCertificatesLoaded(bool initial_load); 110 void NotifyCertificatesLoaded(bool initial_load);
102 111
103 // net::CertDatabase::Observer 112 // net::CertDatabase::Observer
(...skipping 12 matching lines...) Expand all
116 bool certificates_update_running_; 125 bool certificates_update_running_;
117 126
118 // The states are traversed in this order but some might get omitted or never 127 // The states are traversed in this order but some might get omitted or never
119 // be left. 128 // be left.
120 enum TPMTokenState { 129 enum TPMTokenState {
121 TPM_STATE_UNKNOWN, 130 TPM_STATE_UNKNOWN,
122 TPM_DISABLED, 131 TPM_DISABLED,
123 TPM_ENABLED, 132 TPM_ENABLED,
124 TPM_TOKEN_READY, 133 TPM_TOKEN_READY,
125 TPM_TOKEN_INFO_RECEIVED, 134 TPM_TOKEN_INFO_RECEIVED,
135 TPM_TOKEN_INITIALIZED,
126 TPM_TOKEN_NSS_INITIALIZED, 136 TPM_TOKEN_NSS_INITIALIZED,
127 }; 137 };
128 TPMTokenState tpm_token_state_; 138 TPMTokenState tpm_token_state_;
129 139
130 // The current request delay before the next attempt to initialize the 140 // The current request delay before the next attempt to initialize the
131 // TPM. Will be adapted after each attempt. 141 // TPM. Will be adapted after each attempt.
132 base::TimeDelta tpm_request_delay_; 142 base::TimeDelta tpm_request_delay_;
133 143
134 // Cached TPM token info. 144 // Cached TPM token info.
135 std::string tpm_token_name_; 145 std::string tpm_token_name_;
136 std::string tpm_token_slot_; 146 std::string tpm_token_slot_;
137 std::string tpm_user_pin_; 147 std::string tpm_user_pin_;
138 148
139 // Cached Certificates. 149 // Cached Certificates.
140 net::CertificateList cert_list_; 150 net::CertificateList cert_list_;
141 151
142 base::ThreadChecker thread_checker_; 152 base::ThreadChecker thread_checker_;
143 153
144 // This factory should be used only for callbacks during TPMToken 154 // This factory should be used only for callbacks during TPMToken
145 // initialization. 155 // initialization.
146 base::WeakPtrFactory<CertLoader> initialize_token_factory_; 156 base::WeakPtrFactory<CertLoader> initialize_token_factory_;
147 157
148 // This factory should be used only for callbacks during updating the 158 // This factory should be used only for callbacks during updating the
149 // certificate list. 159 // certificate list.
150 base::WeakPtrFactory<CertLoader> update_certificates_factory_; 160 base::WeakPtrFactory<CertLoader> update_certificates_factory_;
151 161
162 scoped_refptr<base::SequencedTaskRunner> main_task_runner_;
163 scoped_refptr<base::SequencedTaskRunner> crypto_task_runner_;
164
152 DISALLOW_COPY_AND_ASSIGN(CertLoader); 165 DISALLOW_COPY_AND_ASSIGN(CertLoader);
153 }; 166 };
154 167
155 } // namespace chromeos 168 } // namespace chromeos
156 169
157 #endif // CHROMEOS_NETWORK_CERT_LOADER_H_ 170 #endif // CHROMEOS_NETWORK_CERT_LOADER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698