Botan: src/cert/certstore/certstor.h Source File

Botan 1.10.17

certstor.h
Go to the documentation of this file.
1 /*
2 * Certificate Store
3 * (C) 1999-2010 Jack Lloyd
4 *
5 * Distributed under the terms of the Botan license
6 */
7
8 #ifndef BOTAN_CERT_STORE_H__
9 #define BOTAN_CERT_STORE_H__
10
11 #include <botan/x509cert.h>
12 #include <botan/x509_crl.h>
13
14 namespace Botan {
15
16 /**
17 * Certificate Store Interface
18 */
19 class BOTAN_DLL Certificate_Store
20 {
21 public:
22 virtual ~Certificate_Store() {}
23
24 virtual Certificate_Store* clone() const = 0;
25
26 /**
27 * Add a certificate; this may fail if the store is write-only
28 */
29 virtual void add_certificate(const X509_Certificate& cert) = 0;
30
31 /**
32 * Add a CRL; this may fail if the store is write-only
33 */
34 virtual void add_crl(const X509_CRL& crl) = 0;
35
36 /**
37 * Subject DN and (optionally) key identifier
38 */
39 virtual std::vector<X509_Certificate>
40 find_cert_by_subject_and_key_id(
41 const X509_DN& subject_dn,
42 const MemoryRegion<byte>& key_id) const = 0;
43
44 /**
45 * Find CRLs by the DN and key id of the issuer
46 */
47 virtual std::vector<X509_CRL>
48 find_crl_by_subject_and_key_id(
49 const X509_DN& issuer_dn,
50 const MemoryRegion<byte>& key_id) const = 0;
51 };
52
53 /**
54 * In Memory Certificate Store
55 */
56 class BOTAN_DLL Certificate_Store_Memory : public Certificate_Store
57 {
58 public:
59 Certificate_Store* clone() const;
60
61 void add_certificate(const X509_Certificate& cert);
62
63 void add_crl(const X509_CRL& crl);
64
65 std::vector<X509_Certificate> find_cert_by_subject_and_key_id(
66 const X509_DN& subject_dn,
67 const MemoryRegion<byte>& key_id) const;
68
69 std::vector<X509_CRL> find_crl_by_subject_and_key_id(
70 const X509_DN& issuer_dn,
71 const MemoryRegion<byte>& key_id) const;
72
73 Certificate_Store_Memory() {}
74 private:
75 // TODO: Add indexing on the DN and key id to avoid linear search?
76 std::vector<X509_Certificate> certs;
77 std::vector<X509_CRL> crls;
78 };
79
80 // TODO: file-backed store
81
82 }
83
84 #endif
Botan::Certificate_Store_Memory::Certificate_Store_Memory
Certificate_Store_Memory()
Definition: certstor.h:73
Botan::X509_Certificate
Definition: x509cert.h:23
Botan::X509_DN
Definition: x509_dn.h:21
Botan::MemoryRegion< byte >
Botan
Definition: algo_base.h:14
Botan::Certificate_Store_Memory
Definition: certstor.h:56
Botan::X509_CRL
Definition: x509_crl.h:20
Botan::Certificate_Store
Definition: certstor.h:19
Botan::Certificate_Store::~Certificate_Store
virtual ~Certificate_Store()
Definition: certstor.h:22