Botan 3.7.1
Crypto and TLS for C&
pkix_enums.h
Go to the documentation of this file.
1/*
2* (C) 2013,2023 Jack Lloyd
3*
4* Botan is released under the Simplified BSD License (see license.txt)
5*/
6
7#ifndef BOTAN_X509_PKIX_ENUMS_H_
8#define BOTAN_X509_PKIX_ENUMS_H_
9
10#include <botan/types.h>
11#include <string>
12
13namespace Botan {
14
15class Public_Key;
16
17/**
18* Certificate validation status code
19*/
21 OK = 0,
23
24 // Revocation status
29
30 // Warnings
38
39 // Errors
41
47
48 // Time problems
56
57 // Chain generation problems
63
64 // Validation errors
70
71 // Revocation errors
75
76 // Other problems
87
88 // Hard failures
95};
96
97/**
98* Convert a status code to a human readable diagnostic message
99* @param code the certifcate status
100* @return string literal constant, or nullptr if code unknown
101*/
103
104/**
105* X.509v3 Key Constraints.
106* If updating update copy in ffi.h
107*/
109 public:
110 enum Bits : uint32_t {
111 None = 0,
113 NonRepudiation = 1 << 14,
116 KeyAgreement = 1 << 11,
117 KeyCertSign = 1 << 10,
118 CrlSign = 1 << 9,
119 EncipherOnly = 1 << 8,
120 DecipherOnly = 1 << 7,
121
122 // Deprecated SHOUTING_CASE names for Key_Constraints
123 // will be removed in a future major release
134 };
135
136 Key_Constraints(const Key_Constraints& other) = default;
138 Key_Constraints& operator=(const Key_Constraints& other) = default;
140
141 Key_Constraints(Key_Constraints::Bits bits) : m_value(bits) {}
142
143 explicit Key_Constraints(uint32_t bits) : m_value(bits) {}
144
145 Key_Constraints() : m_value(0) {}
146
147 /**
148 * Return typical constraints for a CA certificate, namely
149 * KeyCertSign and CrlSign
150 */
154
155 bool operator==(const Key_Constraints&) const = default;
156
157 void operator|=(Key_Constraints::Bits other) { m_value |= other; }
158
159 // Return true if all bits in mask are set
160 bool includes(Key_Constraints::Bits other) const { return (m_value & other) == other; }
161
162 bool includes(Key_Constraints other) const { return (m_value & other.m_value) == other.m_value; }
163
164 // Return true if any of the bits provided are set
165 bool includes_any(auto&&... bits) const { return (m_value & (bits | ...)) > 0; }
166
167 bool empty() const { return m_value == 0; }
168
169 uint32_t value() const { return m_value; }
170
171 std::string to_string() const;
172
173 /**
174 * Check that key constraints are permitted for a specific public key.
175 * @param key the public key on which the constraints shall be enforced on
176 * @return false if the constraints are not permitted for this key
177 */
178 bool compatible_with(const Public_Key& key) const;
179
180 private:
181 uint32_t m_value;
182};
183
184/**
185* X.509v2 CRL Reason Code.
186*/
199
200} // namespace Botan
201
202#endif
#define BOTAN_PUBLIC_API(maj, min)
Definition api.h:19
#define BOTAN_DEPRECATED(msg)
Definition api.h:59
static Key_Constraints ca_constraints()
Definition pkix_enums.h:151
bool includes(Key_Constraints other) const
Definition pkix_enums.h:162
void operator|=(Key_Constraints::Bits other)
Definition pkix_enums.h:157
bool operator==(const Key_Constraints &) const =default
Key_Constraints(uint32_t bits)
Definition pkix_enums.h:143
Key_Constraints(Key_Constraints &&other)=default
bool includes(Key_Constraints::Bits other) const
Definition pkix_enums.h:160
uint32_t value() const
Definition pkix_enums.h:169
Key_Constraints(const Key_Constraints &other)=default
bool includes_any(auto &&... bits) const
Definition pkix_enums.h:165
Key_Constraints & operator=(Key_Constraints &&other)=default
Key_Constraints & operator=(const Key_Constraints &other)=default
Key_Constraints(Key_Constraints::Bits bits)
Definition pkix_enums.h:141
std::string to_string(ErrorType type)
Convert an ErrorType to string.
Definition exceptn.cpp:13
Certificate_Status_Code
Definition pkix_enums.h:20