Avi Drissman | 6459548 | 2022-09-14 20:52:29 | [diff] [blame] | 1 | // Copyright 2013 The Chromium Authors |
[email protected] | 057ad5f | 2013-12-20 19:00:57 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. | ||||
4 | |||||
bnc | 3698b0a0 | 2016-12-09 23:36:50 | [diff] [blame] | 5 | #ifndef NET_CERT_NSS_CERT_DATABASE_CHROMEOS_H_ |
6 | #define NET_CERT_NSS_CERT_DATABASE_CHROMEOS_H_ | ||||
[email protected] | 057ad5f | 2013-12-20 19:00:57 | [diff] [blame] | 7 | |
Avi Drissman | 41c4a41 | 2023-01-11 22:45:37 | [diff] [blame^] | 8 | #include "base/functional/callback.h" |
[email protected] | 9e81893 | 2014-02-06 10:24:11 | [diff] [blame] | 9 | #include "base/memory/weak_ptr.h" |
[email protected] | 057ad5f | 2013-12-20 19:00:57 | [diff] [blame] | 10 | #include "crypto/scoped_nss_types.h" |
[email protected] | 9e81893 | 2014-02-06 10:24:11 | [diff] [blame] | 11 | #include "net/base/net_export.h" |
[email protected] | 057ad5f | 2013-12-20 19:00:57 | [diff] [blame] | 12 | #include "net/cert/nss_cert_database.h" |
13 | #include "net/cert/nss_profile_filter_chromeos.h" | ||||
14 | |||||
15 | namespace net { | ||||
16 | |||||
17 | class NET_EXPORT NSSCertDatabaseChromeOS : public NSSCertDatabase { | ||||
18 | public: | ||||
19 | NSSCertDatabaseChromeOS(crypto::ScopedPK11Slot public_slot, | ||||
20 | crypto::ScopedPK11Slot private_slot); | ||||
Peter Boström | 293b134 | 2021-09-22 17:31:43 | [diff] [blame] | 21 | |
22 | NSSCertDatabaseChromeOS(const NSSCertDatabaseChromeOS&) = delete; | ||||
23 | NSSCertDatabaseChromeOS& operator=(const NSSCertDatabaseChromeOS&) = delete; | ||||
24 | |||||
dcheng | 8ccc40c | 2015-01-23 01:47:56 | [diff] [blame] | 25 | ~NSSCertDatabaseChromeOS() override; |
[email protected] | 057ad5f | 2013-12-20 19:00:57 | [diff] [blame] | 26 | |
[email protected] | 442233d4 | 2014-08-02 07:37:24 | [diff] [blame] | 27 | // |system_slot| is the system TPM slot, which is only enabled for certain |
28 | // users. | ||||
29 | void SetSystemSlot(crypto::ScopedPK11Slot system_slot); | ||||
30 | |||||
[email protected] | 057ad5f | 2013-12-20 19:00:57 | [diff] [blame] | 31 | // NSSCertDatabase implementation. |
David Benjamin | 375809b | 2018-11-07 18:28:56 | [diff] [blame] | 32 | void ListCerts(NSSCertDatabase::ListCertsCallback callback) override; |
Omar Morsi | 3761477 | 2020-02-20 10:46:47 | [diff] [blame] | 33 | |
34 | // Uses NSSCertDatabase implementation and adds additional Chrome OS specific | ||||
35 | // certificate information. | ||||
36 | void ListCertsInfo(ListCertsInfoCallback callback) override; | ||||
37 | |||||
Pavol Marko | f78c374 | 2021-02-23 17:32:29 | [diff] [blame] | 38 | crypto::ScopedPK11Slot GetSystemSlot() const override; |
39 | |||||
tfarina | a55b2689 | 2017-02-28 11:47:30 | [diff] [blame] | 40 | void ListModules(std::vector<crypto::ScopedPK11Slot>* modules, |
41 | bool need_rw) const override; | ||||
Pavol Marko | f78c374 | 2021-02-23 17:32:29 | [diff] [blame] | 42 | bool SetCertTrust(CERTCertificate* cert, |
43 | CertType type, | ||||
44 | TrustBits trust_bits) override; | ||||
[email protected] | 057ad5f | 2013-12-20 19:00:57 | [diff] [blame] | 45 | |
46 | // TODO(mattm): handle trust setting, deletion, etc correctly when certs exist | ||||
47 | // in multiple slots. | ||||
48 | // TODO(mattm): handle trust setting correctly for certs in read-only slots. | ||||
49 | |||||
50 | private: | ||||
David Benjamin | 01bdea5a | 2019-10-10 18:57:09 | [diff] [blame] | 51 | // Certificate listing implementation used by |ListCerts|. |
[email protected] | 9e81893 | 2014-02-06 10:24:11 | [diff] [blame] | 52 | // The certificate list normally returned by NSSCertDatabase::ListCertsImpl |
53 | // is additionally filtered by |profile_filter|. | ||||
54 | // Static so it may safely be used on the worker thread. | ||||
Matt Mueller | ebbb153 | 2017-09-01 01:42:45 | [diff] [blame] | 55 | static ScopedCERTCertificateList ListCertsImpl( |
56 | const NSSProfileFilterChromeOS& profile_filter); | ||||
[email protected] | 9e81893 | 2014-02-06 10:24:11 | [diff] [blame] | 57 | |
Omar Morsi | 3761477 | 2020-02-20 10:46:47 | [diff] [blame] | 58 | // Certificate information listing implementation used by |ListCertsInfo|. |
59 | // The certificate list normally returned by | ||||
60 | // NSSCertDatabase::ListCertsInfoImpl is additionally filtered by | ||||
61 | // |profile_filter|. Also additional Chrome OS specific information is added. | ||||
62 | // Static so it may safely be used on the worker thread. | ||||
63 | static CertInfoList ListCertsInfoImpl( | ||||
64 | const NSSProfileFilterChromeOS& profile_filter, | ||||
65 | crypto::ScopedPK11Slot system_slot, | ||||
66 | bool add_certs_info); | ||||
67 | |||||
[email protected] | 057ad5f | 2013-12-20 19:00:57 | [diff] [blame] | 68 | NSSProfileFilterChromeOS profile_filter_; |
[email protected] | 442233d4 | 2014-08-02 07:37:24 | [diff] [blame] | 69 | crypto::ScopedPK11Slot system_slot_; |
[email protected] | 057ad5f | 2013-12-20 19:00:57 | [diff] [blame] | 70 | }; |
71 | |||||
72 | } // namespace net | ||||
73 | |||||
bnc | 3698b0a0 | 2016-12-09 23:36:50 | [diff] [blame] | 74 | #endif // NET_CERT_NSS_CERT_DATABASE_CHROMEOS_H_ |