8#ifndef BOTAN_KDF_BASE_H_
9#define BOTAN_KDF_BASE_H_
11#include <botan/concepts.h>
12#include <botan/exceptn.h>
13#include <botan/secmem.h>
34 static std::unique_ptr<KDF> create(std::string_view algo_spec, std::string_view provider =
"");
41 static std::unique_ptr<KDF> create_or_throw(std::string_view algo_spec, std::string_view provider =
"");
46 static std::vector<std::string> providers(std::string_view algo_spec);
51 virtual std::string
name()
const = 0;
64 virtual void kdf(uint8_t key[],
66 const uint8_t secret[],
70 const uint8_t label[],
71 size_t label_len)
const = 0;
84 template <concepts::resizable_
byte_buffer T = secure_vector<u
int8_t>>
86 const uint8_t secret[],
90 const uint8_t label[] =
nullptr,
91 size_t label_len = 0)
const {
93 kdf(key.data(), key.size(), secret, secret_len, salt, salt_len, label, label_len);
105 template <concepts::resizable_
byte_buffer T = secure_vector<u
int8_t>>
107 std::span<const uint8_t> secret,
108 std::string_view salt =
"",
109 std::string_view label =
"")
const {
110 return derive_key<T>(key_len,
127 template <concepts::resizable_
byte_buffer T = secure_vector<u
int8_t>>
129 std::span<const uint8_t> secret,
130 std::span<const uint8_t> salt,
131 std::span<const uint8_t> label)
const {
132 return derive_key<T>(
133 key_len, secret.data(), secret.size(), salt.data(), salt.size(), label.data(), label.size());
145 template <concepts::resizable_
byte_buffer T = secure_vector<u
int8_t>>
147 std::span<const uint8_t> secret,
148 const uint8_t salt[],
150 std::string_view label =
"")
const {
151 return derive_key<T>(
152 key_len, secret.data(), secret.size(), salt, salt_len,
cast_char_ptr_to_uint8(label.data()), label.size());
164 template <concepts::resizable_
byte_buffer T = secure_vector<u
int8_t>>
166 const uint8_t secret[],
168 std::string_view salt =
"",
169 std::string_view label =
"")
const {
170 return derive_key<T>(key_len,
187 KDF*
clone()
const {
return this->new_object().release(); }
202 return kdf.release();
204 if(algo_spec ==
"Raw")
virtual std::unique_ptr< KDF > new_object() const =0
T derive_key(size_t key_len, std::span< const uint8_t > secret, std::string_view salt="", std::string_view label="") const
static std::unique_ptr< KDF > create(std::string_view algo_spec, std::string_view 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
T derive_key(size_t key_len, const uint8_t secret[], size_t secret_len, std::string_view salt="", std::string_view label="") const
T derive_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[]=nullptr, size_t label_len=0) const
T derive_key(size_t key_len, std::span< const uint8_t > secret, const uint8_t salt[], size_t salt_len, std::string_view label="") const
virtual std::string name() const =0
T derive_key(size_t key_len, std::span< const uint8_t > secret, std::span< const uint8_t > salt, std::span< const uint8_t > label) const
#define BOTAN_PUBLIC_API(maj, min)
#define BOTAN_DEPRECATED(msg)
KDF * get_kdf(std::string_view algo_spec)
const uint8_t * cast_char_ptr_to_uint8(const char *s)