xref: /aosp_15_r20/external/cronet/third_party/boringssl/src/pki/cert_issuer_source_static.cc (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
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 #include "cert_issuer_source_static.h"
6 
7 namespace bssl {
8 
9 CertIssuerSourceStatic::CertIssuerSourceStatic() = default;
10 CertIssuerSourceStatic::~CertIssuerSourceStatic() = default;
11 
AddCert(std::shared_ptr<const ParsedCertificate> cert)12 void CertIssuerSourceStatic::AddCert(
13     std::shared_ptr<const ParsedCertificate> cert) {
14   intermediates_.insert(std::make_pair(
15       BytesAsStringView(cert->normalized_subject()), std::move(cert)));
16 }
17 
Clear()18 void CertIssuerSourceStatic::Clear() { intermediates_.clear(); }
19 
SyncGetIssuersOf(const ParsedCertificate * cert,ParsedCertificateList * issuers)20 void CertIssuerSourceStatic::SyncGetIssuersOf(const ParsedCertificate *cert,
21                                               ParsedCertificateList *issuers) {
22   auto range =
23       intermediates_.equal_range(BytesAsStringView(cert->normalized_issuer()));
24   for (auto it = range.first; it != range.second; ++it) {
25     issuers->push_back(it->second);
26   }
27 }
28 
AsyncGetIssuersOf(const ParsedCertificate * cert,std::unique_ptr<Request> * out_req)29 void CertIssuerSourceStatic::AsyncGetIssuersOf(
30     const ParsedCertificate *cert, std::unique_ptr<Request> *out_req) {
31   // CertIssuerSourceStatic never returns asynchronous results.
32   out_req->reset();
33 }
34 
35 }  // namespace bssl
36