blob: f4acd4c2e315cd1f7a2b5433815589bfecce7b02 [file] [log] [blame]
Avi Drissman64595482022-09-14 20:52:291// Copyright 2013 The Chromium Authors
[email protected]057ad5f2013-12-20 19:00:572// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
bnc3698b0a02016-12-09 23:36:505#ifndef NET_CERT_NSS_CERT_DATABASE_CHROMEOS_H_
6#define NET_CERT_NSS_CERT_DATABASE_CHROMEOS_H_
[email protected]057ad5f2013-12-20 19:00:577
Avi Drissman41c4a412023-01-11 22:45:378#include "base/functional/callback.h"
[email protected]9e818932014-02-06 10:24:119#include "base/memory/weak_ptr.h"
[email protected]057ad5f2013-12-20 19:00:5710#include "crypto/scoped_nss_types.h"
[email protected]9e818932014-02-06 10:24:1111#include "net/base/net_export.h"
[email protected]057ad5f2013-12-20 19:00:5712#include "net/cert/nss_cert_database.h"
13#include "net/cert/nss_profile_filter_chromeos.h"
14
15namespace net {
16
17class NET_EXPORT NSSCertDatabaseChromeOS : public NSSCertDatabase {
18 public:
19 NSSCertDatabaseChromeOS(crypto::ScopedPK11Slot public_slot,
20 crypto::ScopedPK11Slot private_slot);
Peter Boström293b1342021-09-22 17:31:4321
22 NSSCertDatabaseChromeOS(const NSSCertDatabaseChromeOS&) = delete;
23 NSSCertDatabaseChromeOS& operator=(const NSSCertDatabaseChromeOS&) = delete;
24
dcheng8ccc40c2015-01-23 01:47:5625 ~NSSCertDatabaseChromeOS() override;
[email protected]057ad5f2013-12-20 19:00:5726
[email protected]442233d42014-08-02 07:37:2427 // |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]057ad5f2013-12-20 19:00:5731 // NSSCertDatabase implementation.
David Benjamin375809b2018-11-07 18:28:5632 void ListCerts(NSSCertDatabase::ListCertsCallback callback) override;
Omar Morsi37614772020-02-20 10:46:4733
34 // Uses NSSCertDatabase implementation and adds additional Chrome OS specific
35 // certificate information.
36 void ListCertsInfo(ListCertsInfoCallback callback) override;
37
Pavol Markof78c3742021-02-23 17:32:2938 crypto::ScopedPK11Slot GetSystemSlot() const override;
39
tfarinaa55b26892017-02-28 11:47:3040 void ListModules(std::vector<crypto::ScopedPK11Slot>* modules,
41 bool need_rw) const override;
Pavol Markof78c3742021-02-23 17:32:2942 bool SetCertTrust(CERTCertificate* cert,
43 CertType type,
44 TrustBits trust_bits) override;
[email protected]057ad5f2013-12-20 19:00:5745
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 Benjamin01bdea5a2019-10-10 18:57:0951 // Certificate listing implementation used by |ListCerts|.
[email protected]9e818932014-02-06 10:24:1152 // 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 Muellerebbb1532017-09-01 01:42:4555 static ScopedCERTCertificateList ListCertsImpl(
56 const NSSProfileFilterChromeOS& profile_filter);
[email protected]9e818932014-02-06 10:24:1157
Omar Morsi37614772020-02-20 10:46:4758 // 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]057ad5f2013-12-20 19:00:5768 NSSProfileFilterChromeOS profile_filter_;
[email protected]442233d42014-08-02 07:37:2469 crypto::ScopedPK11Slot system_slot_;
[email protected]057ad5f2013-12-20 19:00:5770};
71
72} // namespace net
73
bnc3698b0a02016-12-09 23:36:5074#endif // NET_CERT_NSS_CERT_DATABASE_CHROMEOS_H_