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 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 // Destroys the global instance. | 51 // Destroys the global instance. |
52 static void Shutdown(); | 52 static void Shutdown(); |
53 | 53 |
54 // Gets the global instance. Initialize() must be called first. | 54 // Gets the global instance. Initialize() must be called first. |
55 static CertLoader* Get(); | 55 static CertLoader* Get(); |
56 | 56 |
57 // Returns true if the global instance has been initialized. | 57 // Returns true if the global instance has been initialized. |
58 static bool IsInitialized(); | 58 static bool IsInitialized(); |
59 | 59 |
60 // Returns the PKCS#11 attribute CKA_ID for a certificate as an upper-case | 60 // Returns the PKCS#11 attribute CKA_ID for a certificate as an upper-case |
61 // hex string, or the empty string if none is found. Note that the returned ID | 61 // hex string and sets |slot_id| to the id of the containing slot, or returns |
62 // should be used only to identify the cert in its slot. | 62 // an empty string and doesn't modify |slot_id| if the PKCS#11 id could not be |
63 // This should be used only for user certificates, assuming that only one | 63 // determined. |
64 // private slot is loaded for a user. | 64 static std::string GetPkcs11IdAndSlotForCert(const net::X509Certificate& cert, |
65 // TODO(tbarzic): Make this check cert slot id if we start loading | 65 int* slot_id); |
66 // certificates for secondary users. | |
67 static std::string GetPkcs11IdForCert(const net::X509Certificate& cert); | |
68 | 66 |
69 // Starts the CertLoader with the NSS cert database. | 67 // Starts the CertLoader with the NSS cert database. |
70 // The CertLoader will _not_ take the ownership of the database, but it | 68 // The CertLoader will _not_ take the ownership of the database, but it |
71 // expects it to stay alive at least until the shutdown starts on the main | 69 // expects it to stay alive at least until the shutdown starts on the main |
72 // thread. This assumes that |StartWithNSSDB| and other methods directly | 70 // thread. This assumes that |StartWithNSSDB| and other methods directly |
73 // using |database_| are not called during shutdown. | 71 // using |database_| are not called during shutdown. |
74 void StartWithNSSDB(net::NSSCertDatabase* database); | 72 void StartWithNSSDB(net::NSSCertDatabase* database); |
75 | 73 |
76 void AddObserver(CertLoader::Observer* observer); | 74 void AddObserver(CertLoader::Observer* observer); |
77 void RemoveObserver(CertLoader::Observer* observer); | 75 void RemoveObserver(CertLoader::Observer* observer); |
78 | 76 |
79 int TPMTokenSlotID() const; | |
80 bool IsHardwareBacked() const; | 77 bool IsHardwareBacked() const; |
81 | 78 |
82 // Whether the certificate is hardware backed. Returns false if the CertLoader | 79 // Whether the certificate is hardware backed. Returns false if the CertLoader |
83 // was not yet started (both |CertificatesLoading()| and | 80 // was not yet started (both |CertificatesLoading()| and |
84 // |certificates_loaded()| are false). | 81 // |certificates_loaded()| are false). |
85 bool IsCertificateHardwareBacked(const net::X509Certificate* cert) const; | 82 bool IsCertificateHardwareBacked(const net::X509Certificate* cert) const; |
86 | 83 |
87 // Returns true when the certificate list has been requested but not loaded. | 84 // Returns true when the certificate list has been requested but not loaded. |
88 bool CertificatesLoading() const; | 85 bool CertificatesLoading() const; |
89 | 86 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 base::ThreadChecker thread_checker_; | 131 base::ThreadChecker thread_checker_; |
135 | 132 |
136 base::WeakPtrFactory<CertLoader> weak_factory_; | 133 base::WeakPtrFactory<CertLoader> weak_factory_; |
137 | 134 |
138 DISALLOW_COPY_AND_ASSIGN(CertLoader); | 135 DISALLOW_COPY_AND_ASSIGN(CertLoader); |
139 }; | 136 }; |
140 | 137 |
141 } // namespace chromeos | 138 } // namespace chromeos |
142 | 139 |
143 #endif // CHROMEOS_CERT_LOADER_H_ | 140 #endif // CHROMEOS_CERT_LOADER_H_ |
OLD | NEW |