14#ifndef OPENVPN_CRYPTO_CRYPTOALGS_H
15#define OPENVPN_CRYPTO_CRYPTOALGS_H
45 return "[PRF undefined]";
49 return "TLS Keying Material Exporter [RFC5705]";
113 const unsigned int flags,
115 const unsigned int size,
195inline std::array<Alg, Type::SIZE>
algs = {
227 throw crypto_alg_index();
233 const Alg &alg_ref =
get_index(
static_cast<size_t>(type));
239 return get_index(
static_cast<size_t>(type));
244 std::size_t count = 0;
245 for (std::size_t i = 0; i <
algs.size(); ++i)
246 if (fn(
static_cast<Type>(i),
algs[i]))
253 for (
size_t i = 0; i <
algs.size(); ++i)
256 return static_cast<Type>(i);
261inline const char *
name(
const Type type,
const char *default_name =
nullptr)
263 if (type ==
NONE && default_name)
271 const Alg &alg =
get(type);
277 const Alg &alg =
get(type);
283 const Alg &alg =
get(type);
289 const Alg &alg =
get(type);
295 const Alg &alg =
get(type);
301 const Alg &alg =
get(type);
307 const Alg &alg =
get(type);
315 const Alg &alg =
get(type);
323 const Alg &alg =
get(type);
331 const Alg &alg =
get(type);
339 for (
auto &alg :
algs)
341 for (
auto &type : types)
342 algs.at(type).allow_dc(
true);
354template <
typename CRYPTO_API>
358 for (
auto &alg :
algs)
367 if (preferred && alg.
mode() !=
AEAD)
370 if (alg.
mode() ==
AEAD && !CRYPTO_API::CipherContextAEAD::is_supported(libctx, type))
382 && !CRYPTO_API::CipherContext::is_supported(libctx, type))
386 algs.at(type).allow_dc(
true);
400 const Alg &alg =
get(type);
size_t block_size() const
const char * name() const
uint64_t aead_usage_limit_
unsigned int flags() const
uint64_t aead_usage_limit() const
constexpr Alg(const char *name, const unsigned int flags, const Mode mode, const unsigned int size, const unsigned int iv_length, const unsigned int block_size, uint64_t aead_usage_limit)
size_t key_length() const
void allow_dc(bool allow)
#define OPENVPN_SIMPLE_EXCEPTION(C)
#define OPENVPN_EXCEPTION(C)
#define OPENVPN_THROW(exc, stuff)
size_t block_size(const Type type)
static constexpr uint64_t gcm_limit
void allow_dc_algs(const std::list< Type > types)
Type dc_cbc_cipher(const Type type)
const Alg & get(const Type type)
bool use_cipher_digest(const Type type)
bool defined(const Type type)
Mode mode(const Type type)
Type lookup(const std::string &name)
size_t key_length(const Type type)
std::array< Alg, Type::SIZE > algs
const Alg * get_ptr(const Type type)
Type legal_dc_digest(const Type type)
const char * name(const KeyDerivation kd)
Type dc_cbc_hash(const Type type)
void allow_default_dc_algs(SSLLib::Ctx libctx, bool preferred=false, bool legacy=false)
size_t iv_length(const Type type)
size_t size(const Type type)
std::size_t for_each(std::function< bool(Type, const Alg &)> fn)
Type legal_dc_cipher(const Type type)
uint64_t aead_usage_limit(const Type type)
const Alg & get_index(const size_t i)
int strcasecmp(const char *s1, const char *s2)