Bob Beck | bc97b7a | 2023-04-18 08:35:15 -0600 | [diff] [blame] | 1 | // Copyright 2016 The Chromium Authors |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef BSSL_PKI_CERT_ISSUER_SOURCE_STATIC_H_ |
| 6 | #define BSSL_PKI_CERT_ISSUER_SOURCE_STATIC_H_ |
| 7 | |
Bob Beck | bc97b7a | 2023-04-18 08:35:15 -0600 | [diff] [blame] | 8 | #include <unordered_map> |
| 9 | |
Bob Beck | 3cd30cc | 2023-11-22 16:59:00 -0700 | [diff] [blame] | 10 | #include <openssl/base.h> |
Bob Beck | bc97b7a | 2023-04-18 08:35:15 -0600 | [diff] [blame] | 11 | |
| 12 | #include "cert_issuer_source.h" |
| 13 | |
| 14 | namespace bssl { |
| 15 | |
| 16 | // Synchronously returns issuers from a pre-supplied set. |
| 17 | class OPENSSL_EXPORT CertIssuerSourceStatic : public CertIssuerSource { |
| 18 | public: |
| 19 | CertIssuerSourceStatic(); |
| 20 | |
Bob Beck | 5c7a2a0 | 2023-11-20 17:28:21 -0700 | [diff] [blame] | 21 | CertIssuerSourceStatic(const CertIssuerSourceStatic &) = delete; |
| 22 | CertIssuerSourceStatic &operator=(const CertIssuerSourceStatic &) = delete; |
Bob Beck | bc97b7a | 2023-04-18 08:35:15 -0600 | [diff] [blame] | 23 | |
| 24 | ~CertIssuerSourceStatic() override; |
| 25 | |
| 26 | // Adds |cert| to the set of certificates that this CertIssuerSource will |
| 27 | // provide. |
| 28 | void AddCert(std::shared_ptr<const ParsedCertificate> cert); |
| 29 | |
| 30 | // Clears the set of certificates. |
| 31 | void Clear(); |
| 32 | |
| 33 | size_t size() const { return intermediates_.size(); } |
| 34 | |
| 35 | // CertIssuerSource implementation: |
Bob Beck | 5c7a2a0 | 2023-11-20 17:28:21 -0700 | [diff] [blame] | 36 | void SyncGetIssuersOf(const ParsedCertificate *cert, |
| 37 | ParsedCertificateList *issuers) override; |
| 38 | void AsyncGetIssuersOf(const ParsedCertificate *cert, |
| 39 | std::unique_ptr<Request> *out_req) override; |
Bob Beck | bc97b7a | 2023-04-18 08:35:15 -0600 | [diff] [blame] | 40 | |
| 41 | private: |
| 42 | // The certificates that the CertIssuerSourceStatic can return, keyed on the |
| 43 | // normalized subject value. |
| 44 | std::unordered_multimap<std::string_view, |
| 45 | std::shared_ptr<const ParsedCertificate>> |
| 46 | intermediates_; |
| 47 | }; |
| 48 | |
Bob Beck | 5c7a2a0 | 2023-11-20 17:28:21 -0700 | [diff] [blame] | 49 | } // namespace bssl |
Bob Beck | bc97b7a | 2023-04-18 08:35:15 -0600 | [diff] [blame] | 50 | |
| 51 | #endif // BSSL_PKI_CERT_ISSUER_SOURCE_STATIC_H_ |