Botan: Botan::Certificate_Store_Memory Class Reference

Botan 1.10.16

Public Member Functions | List of all members
Botan::Certificate_Store_Memory Class Reference

`#include <certstor.h>`

Inheritance diagram for Botan::Certificate_Store_Memory:

## Public Member Functions
void | add_certificate (const X509_Certificate &cert)
void | add_crl (const X509_CRL &crl)
| Certificate_Store_Memory ()
Certificate_Store * | clone () const
std::vector< X509_Certificate > | find_cert_by_subject_and_key_id (const X509_DN &subject_dn, const MemoryRegion< byte > &key_id) const
std::vector< X509_CRL > | find_crl_by_subject_and_key_id (const X509_DN &issuer_dn, const MemoryRegion< byte > &key_id) const

## Detailed Description

In Memory Certificate Store

Definition at line 56 of file certstor.h.

## Constructor & Destructor Documentation

## ◆ Certificate_Store_Memory()

Botan::Certificate_Store_Memory::Certificate_Store_Memory | ( |  | ) |
| inline

Definition at line 73 of file certstor.h.

Referenced by clone().

73 {}

## Member Function Documentation

## ◆ add_certificate()

void Botan::Certificate_Store_Memory::add_certificate | ( | const X509_Certificate & | cert | ) |
| virtual

Add a certificate; this may fail if the store is write-only

Implements Botan::Certificate_Store.

Definition at line 17 of file certstor.cpp.

18 {
19 for(size_t i = 0; i != certs.size(); ++i)
20 {
21 if(certs[i] == cert)
22 return;
23 }
24
25 certs.push_back(cert);
26 }

## ◆ add_crl()

void Botan::Certificate_Store_Memory::add_crl | ( | const X509_CRL & | crl | ) |
| virtual

Add a CRL; this may fail if the store is write-only

Implements Botan::Certificate_Store.

Definition at line 53 of file certstor.cpp.

References Botan::X509_CRL::issuer_dn(), and Botan::X509_CRL::this_update().

54 {
55 X509_DN crl_issuer = crl.issuer_dn();
56
57 for(size_t i = 0; i != crls.size(); ++i)
58 {
59 // Found an update of a previously existing one; replace it
60 if(crls[i].issuer_dn() == crl_issuer)
61 {
62 if(crls[i].this_update() < crl.this_update())
63 {
64 crls[i] = crl;
65 return;
66 }
67 }
68 }
69
70 // Totally new CRL, add to the list
71 crls.push_back(crl);
72 }

## ◆ clone()

Certificate_Store * Botan::Certificate_Store_Memory::clone | ( |  | ) | const
| virtual

Implements Botan::Certificate_Store.

Definition at line 12 of file certstor.cpp.

References Certificate_Store_Memory().

13 {
14 return new Certificate_Store_Memory(*this);
15 }
Botan::Certificate_Store_Memory::Certificate_Store_Memory
Certificate_Store_Memory()
Definition: certstor.h:73

## ◆ find_cert_by_subject_and_key_id()

std::vector< X509_Certificate > Botan::Certificate_Store_Memory::find_cert_by_subject_and_key_id | ( | const X509_DN & | subject_dn,
|  | const MemoryRegion< byte > & | key_id
| ) |  | const
| virtual

Subject DN and (optionally) key identifier

Implements Botan::Certificate_Store.

Definition at line 29 of file certstor.cpp.

References Botan::MemoryRegion< T >::size().

32 {
33 std::vector<X509_Certificate> result;
34
35 for(size_t i = 0; i != certs.size(); ++i)
36 {
37 // Only compare key ids if set in both call and in the cert
38 if(key_id.size())
39 {
40 MemoryVector<byte> skid = certs[i].subject_key_id();
41
42 if(skid.size() && skid != key_id) // no match
43 continue;
44 }
45
46 if(certs[i].subject_dn() == subject_dn)
47 result.push_back(certs[i]);
48 }
49
50 return result;
51 }
Botan::MemoryRegion::size
size_t size() const
Definition: secmem.h:29

## ◆ find_crl_by_subject_and_key_id()

std::vector< X509_CRL > Botan::Certificate_Store_Memory::find_crl_by_subject_and_key_id | ( | const X509_DN & | issuer_dn,
|  | const MemoryRegion< byte > & | key_id
| ) |  | const
| virtual

Find CRLs by the DN and key id of the issuer

Implements Botan::Certificate_Store.

Definition at line 75 of file certstor.cpp.

References Botan::MemoryRegion< T >::size().

78 {
79 std::vector<X509_CRL> result;
80
81 for(size_t i = 0; i != crls.size(); ++i)
82 {
83 // Only compare key ids if set in both call and in the CRL
84 if(key_id.size())
85 {
86 MemoryVector<byte> akid = crls[i].authority_key_id();
87
88 if(akid.size() && akid != key_id) // no match
89 continue;
90 }
91
92 if(crls[i].issuer_dn() == issuer_dn)
93 result.push_back(crls[i]);
94 }
95
96 return result;
97 }
Botan::MemoryRegion::size
size_t size() const
Definition: secmem.h:29

The documentation for this class was generated from the following files:

- src/cert/certstore/certstor.h
- src/cert/certstore/certstor.cpp