10#include <botan/hash.h>
11#include <botan/internal/scan_name.h>
12#include <botan/exceptn.h>
14#if defined(BOTAN_HAS_HKDF)
15#include <botan/internal/hkdf.h>
18#if defined(BOTAN_HAS_KDF1)
19#include <botan/internal/kdf1.h>
22#if defined(BOTAN_HAS_KDF2)
23#include <botan/internal/kdf2.h>
26#if defined(BOTAN_HAS_KDF1_18033)
27#include <botan/internal/kdf1_iso18033.h>
30#if defined(BOTAN_HAS_TLS_V12_PRF)
31#include <botan/internal/prf_tls.h>
34#if defined(BOTAN_HAS_X942_PRF)
35#include <botan/internal/prf_x942.h>
38#if defined(BOTAN_HAS_SP800_108)
39#include <botan/internal/sp800_108.h>
42#if defined(BOTAN_HAS_SP800_56A)
43#include <botan/internal/sp800_56a.h>
46#if defined(BOTAN_HAS_SP800_56C)
47#include <botan/internal/sp800_56c.h>
54template<
typename KDF_Type>
56kdf_create_mac_or_hash(
const std::string& nm)
59 return std::make_unique<KDF_Type>(std::move(mac));
62 return std::make_unique<KDF_Type>(std::move(mac));
70 const std::string& provider)
74#if defined(BOTAN_HAS_HKDF)
77 if(provider.empty() || provider ==
"base")
79 return kdf_create_mac_or_hash<HKDF>(req.
arg(0));
85 if(provider.empty() || provider ==
"base")
87 return kdf_create_mac_or_hash<HKDF_Extract>(req.
arg(0));
93 if(provider.empty() || provider ==
"base")
95 return kdf_create_mac_or_hash<HKDF_Expand>(req.
arg(0));
100#if defined(BOTAN_HAS_KDF2)
103 if(provider.empty() || provider ==
"base")
106 return std::make_unique<KDF2>(std::move(
hash));
111#if defined(BOTAN_HAS_KDF1_18033)
114 if(provider.empty() || provider ==
"base")
117 return std::make_unique<KDF1_18033>(std::move(
hash));
122#if defined(BOTAN_HAS_KDF1)
125 if(provider.empty() || provider ==
"base")
128 return std::make_unique<KDF1>(std::move(
hash));
133#if defined(BOTAN_HAS_TLS_V12_PRF)
136 if(provider.empty() || provider ==
"base")
138 return kdf_create_mac_or_hash<TLS_12_PRF>(req.
arg(0));
143#if defined(BOTAN_HAS_X942_PRF)
146 if(provider.empty() || provider ==
"base")
148 return std::make_unique<X942_PRF>(req.
arg(0));
153#if defined(BOTAN_HAS_SP800_108)
156 if(provider.empty() || provider ==
"base")
158 return kdf_create_mac_or_hash<SP800_108_Counter>(req.
arg(0));
164 if(provider.empty() || provider ==
"base")
166 return kdf_create_mac_or_hash<SP800_108_Feedback>(req.
arg(0));
172 if(provider.empty() || provider ==
"base")
174 return kdf_create_mac_or_hash<SP800_108_Pipeline>(req.
arg(0));
179#if defined(BOTAN_HAS_SP800_56A)
183 return std::make_unique<SP800_56A_Hash>(std::move(
hash));
185 return std::make_unique<SP800_56A_HMAC>(std::move(mac));
189#if defined(BOTAN_HAS_SP800_56C)
192 std::unique_ptr<KDF> exp(kdf_create_mac_or_hash<SP800_108_Feedback>(req.
arg(0)));
196 return std::make_unique<SP800_56C>(std::move(mac), std::move(exp));
199 return std::make_unique<SP800_56C>(std::move(mac), std::move(exp));
213 const std::string& provider)
224 return probe_providers_of<KDF>(algo_spec);
#define BOTAN_UNUSED(...)
static std::unique_ptr< HashFunction > create(const std::string &algo_spec, const std::string &provider="")
static std::unique_ptr< KDF > create_or_throw(const std::string &algo_spec, const std::string &provider="")
static std::unique_ptr< KDF > create(const std::string &algo_spec, const std::string &provider="")
virtual void kdf(uint8_t key[], size_t key_len, const uint8_t secret[], size_t secret_len, const uint8_t salt[], size_t salt_len, const uint8_t label[], size_t label_len) const =0
static std::vector< std::string > providers(const std::string &algo_spec)
static std::unique_ptr< MessageAuthenticationCode > create(const std::string &algo_spec, const std::string &provider="")
std::string arg(size_t i) const
const std::string & algo_name() const