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
14namespace Botan {
15
16/**
17* Certificate Store Interface
18*/
19class 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>
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>
49 const X509_DN& issuer_dn,
50 const MemoryRegion<byte>& key_id) const = 0;
51 };
52
53/**
54* In Memory Certificate Store
55*/
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
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
void add_certificate(const X509_Certificate &cert)
Definition certstor.cpp:17
Certificate_Store * clone() const
Definition certstor.cpp:12
void add_crl(const X509_CRL &crl)
Definition certstor.cpp:53
std::vector< X509_Certificate > find_cert_by_subject_and_key_id(const X509_DN &subject_dn, const MemoryRegion< byte > &key_id) const
Definition certstor.cpp:29
std::vector< X509_CRL > find_crl_by_subject_and_key_id(const X509_DN &issuer_dn, const MemoryRegion< byte > &key_id) const
Definition certstor.cpp:75
virtual void add_certificate(const X509_Certificate &cert)=0
virtual Certificate_Store * clone() const =0
virtual std::vector< X509_CRL > find_crl_by_subject_and_key_id(const X509_DN &issuer_dn, const MemoryRegion< byte > &key_id) const =0
virtual void add_crl(const X509_CRL &crl)=0
virtual ~Certificate_Store()
Definition certstor.h:22
virtual std::vector< X509_Certificate > find_cert_by_subject_and_key_id(const X509_DN &subject_dn, const MemoryRegion< byte > &key_id) const =0