7#include <botan/psk_db.h>
9#include <botan/base64.h>
10#include <botan/block_cipher.h>
11#include <botan/exceptn.h>
13#include <botan/mem_ops.h>
14#include <botan/nist_keywrap.h>
30 m_hmac->set_key(master_key);
32 m_cipher->set_key(m_hmac->process(
"wrap"));
33 m_hmac->set_key(m_hmac->process(
"hmac"));
39 const std::set<std::string> encrypted_names =
kv_get_all();
41 std::set<std::string> names;
43 for(
const auto& enc_name : encrypted_names) {
49 names.insert(pt_name);
57 const std::vector<uint8_t> wrapped_name =
64 const std::vector<uint8_t> wrapped_name =
69 if(val_base64.empty()) {
75 auto wrap_cipher = m_cipher->new_object();
76 wrap_cipher->set_key(m_hmac->process(wrapped_name));
87 const std::vector<uint8_t> wrapped_name =
90 auto wrap_cipher = m_cipher->new_object();
91 wrap_cipher->set_key(m_hmac->process(wrapped_name));
static std::unique_ptr< BlockCipher > create_or_throw(std::string_view algo_spec, std::string_view provider="")
virtual void kv_set(std::string_view index, std::string_view value)=0
virtual void kv_del(std::string_view index)=0
virtual std::string kv_get(std::string_view index) const =0
secure_vector< uint8_t > get(std::string_view name) const override
Encrypted_PSK_Database(const secure_vector< uint8_t > &master_key)
std::set< std::string > list_names() const override
virtual std::set< std::string > kv_get_all() const =0
void remove(std::string_view name) override
~Encrypted_PSK_Database() override
void set(std::string_view name, const uint8_t psk[], size_t psk_len) override
static std::unique_ptr< MessageAuthenticationCode > create_or_throw(std::string_view algo_spec, std::string_view provider="")
void set_str(std::string_view name, std::string_view psk)
virtual void set(std::string_view name, const uint8_t psk[], size_t psk_len)=0
std::string get_str(std::string_view name) const
virtual secure_vector< uint8_t > get(std::string_view name) const =0
size_t base64_encode(char out[], const uint8_t in[], size_t input_length, size_t &input_consumed, bool final_inputs)
size_t base64_decode(uint8_t out[], const char in[], size_t input_length, size_t &input_consumed, bool final_inputs, bool ignore_ws)
std::vector< uint8_t > nist_key_wrap_padded(const uint8_t input[], size_t input_len, const BlockCipher &bc)
secure_vector< uint8_t > nist_key_unwrap_padded(const uint8_t input[], size_t input_len, const BlockCipher &bc)
const char * cast_uint8_ptr_to_char(const uint8_t *b)
std::vector< T, secure_allocator< T > > secure_vector
const uint8_t * cast_char_ptr_to_uint8(const char *s)