8#include <botan/internal/kdf2.h>
10#include <botan/exceptn.h>
11#include <botan/internal/fmt.h>
16 return fmt(
"KDF2({})", m_hash->name());
20 return std::make_unique<KDF2>(m_hash->new_object());
25 const uint8_t secret[],
29 const uint8_t label[],
30 size_t label_len)
const {
35 const size_t blocks_required = key_len / m_hash->output_length();
37 if(blocks_required >= 0xFFFFFFFE) {
45 while(offset != key_len) {
46 m_hash->update(secret, secret_len);
47 m_hash->update_be(counter);
48 m_hash->update(label, label_len);
49 m_hash->update(salt, salt_len);
52 const size_t added = std::min(h.size(), key_len - offset);
53 copy_mem(&key[offset], h.data(), added);
#define BOTAN_ASSERT_NOMSG(expr)
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 override
std::unique_ptr< KDF > new_object() const override
std::string name() const override
std::string fmt(std::string_view format, const T &... args)
std::vector< T, secure_allocator< T > > secure_vector
constexpr void copy_mem(T *out, const T *in, size_t n)