Botan  1.11.26
x509_ca.h
Go to the documentation of this file.
1 /*
2 * X.509 Certificate Authority
3 * (C) 1999-2008 Jack Lloyd
4 *
5 * Botan is released under the Simplified BSD License (see license.txt)
6 */
7 
8 #ifndef BOTAN_X509_CA_H__
9 #define BOTAN_X509_CA_H__
10 
11 #include <botan/x509cert.h>
12 #include <botan/x509_crl.h>
13 #include <botan/x509_ext.h>
14 #include <botan/pkcs10.h>
15 #include <botan/pubkey.h>
16 
17 namespace Botan {
18 
19 /**
20 * This class represents X.509 Certificate Authorities (CAs).
21 */
22 class BOTAN_DLL X509_CA
23  {
24  public:
25 
26  /**
27  * Sign a PKCS#10 Request.
28  * @param req the request to sign
29  * @param rng the rng to use
30  * @param not_before the starting time for the certificate
31  * @param not_after the expiration time for the certificate
32  * @return resulting certificate
33  */
36  const X509_Time& not_before,
37  const X509_Time& not_after);
38 
39  /**
40  * Get the certificate of this CA.
41  * @return CA certificate
42  */
43  X509_Certificate ca_certificate() const;
44 
45  /**
46  * Create a new and empty CRL for this CA.
47  * @param rng the random number generator to use
48  * @param next_update the time to set in next update in seconds
49  * as the offset from the current time
50  * @return new CRL
51  */
52  X509_CRL new_crl(RandomNumberGenerator& rng,
53  u32bit next_update = 0) const;
54 
55  /**
56  * Create a new CRL by with additional entries.
57  * @param last_crl the last CRL of this CA to add the new entries to
58  * @param new_entries contains the new CRL entries to be added to the CRL
59  * @param rng the random number generator to use
60  * @param next_update the time to set in next update in seconds
61  * as the offset from the current time
62  */
63  X509_CRL update_crl(const X509_CRL& last_crl,
64  const std::vector<CRL_Entry>& new_entries,
66  u32bit next_update = 0) const;
67 
68  /**
69  * Interface for creating new certificates
70  * @param signer a signing object
71  * @param rng a random number generator
72  * @param sig_algo the signature algorithm identifier
73  * @param pub_key the serialized public key
74  * @param not_before the start time of the certificate
75  * @param not_after the end time of the certificate
76  * @param issuer_dn the DN of the issuer
77  * @param subject_dn the DN of the subject
78  * @param extensions an optional list of certificate extensions
79  * @returns newly minted certificate
80  */
81  static X509_Certificate make_cert(PK_Signer* signer,
83  const AlgorithmIdentifier& sig_algo,
84  const std::vector<byte>& pub_key,
85  const X509_Time& not_before,
86  const X509_Time& not_after,
87  const X509_DN& issuer_dn,
88  const X509_DN& subject_dn,
89  const Extensions& extensions);
90 
91  /**
92  * Create a new CA object.
93  * @param ca_certificate the certificate of the CA
94  * @param key the private key of the CA
95  * @param hash_fn name of a hash function to use for signing
96  */
97  X509_CA(const X509_Certificate& ca_certificate,
98  const Private_Key& key,
99  const std::string& hash_fn);
100 
101  X509_CA(const X509_CA&) = delete;
102  X509_CA& operator=(const X509_CA&) = delete;
103 
104  ~X509_CA();
105  private:
106  X509_CRL make_crl(const std::vector<CRL_Entry>& entries,
107  u32bit crl_number, u32bit next_update,
108  RandomNumberGenerator& rng) const;
109 
110  AlgorithmIdentifier m_ca_sig_algo;
111  X509_Certificate m_cert;
112  PK_Signer* m_signer;
113  };
114 
115 /**
116 * Choose the default signature format for a certain public key signature
117 * scheme.
118 * @param key will be the key to choose a padding scheme for
119 * @param hash_fn is the desired hash function
120 * @param alg_id will be set to the chosen scheme
121 * @return A PK_Signer object for generating signatures
122 */
123 BOTAN_DLL PK_Signer* choose_sig_format(const Private_Key& key,
124  const std::string& hash_fn,
125  AlgorithmIdentifier& alg_id);
126 
127 }
128 
129 #endif
EAC1_1_CVC sign_request(EAC1_1_CVC const &signer_cert, Private_Key const &key, EAC1_1_Req const &signee, u32bit seqnr, u32bit seqnr_len, bool domestic, u32bit dvca_validity_months, u32bit ca_is_validity_months, RandomNumberGenerator &rng)
Definition: cvc_self.cpp:247
std::uint32_t u32bit
Definition: types.h:33
Definition: alg_id.cpp:13
PK_Signer * choose_sig_format(const Private_Key &key, const std::string &hash_fn, AlgorithmIdentifier &sig_algo)
Definition: x509_ca.cpp:221