Botan 3.5.0
Crypto and TLS for C&
|
#include <psk_db.h>
Public Member Functions | |
Encrypted_PSK_Database (const secure_vector< uint8_t > &master_key) | |
secure_vector< uint8_t > | get (std::string_view name) const override |
std::string | get_str (std::string_view name) const |
bool | is_encrypted () const override |
std::set< std::string > | list_names () const override |
void | remove (std::string_view name) override |
void | set (std::string_view name, const uint8_t psk[], size_t psk_len) override |
void | set_str (std::string_view name, std::string_view psk) |
template<typename Alloc > | |
void | set_vec (std::string_view name, const std::vector< uint8_t, Alloc > &psk) |
~Encrypted_PSK_Database () override | |
Protected Member Functions | |
virtual void | kv_del (std::string_view index)=0 |
virtual std::string | kv_get (std::string_view index) const =0 |
virtual std::set< std::string > | kv_get_all () const =0 |
virtual void | kv_set (std::string_view index, std::string_view value)=0 |
A mixin for an encrypted PSK database. Both keys and values are encrypted with NIST AES-256 key wrapping. Values are padded to obscure their length before encryption, allowing it to be used as a password vault.
Subclasses must implement the virtual calls to handle storing and getting raw (base64 encoded) values.
Botan::Encrypted_PSK_Database::Encrypted_PSK_Database | ( | const secure_vector< uint8_t > & | master_key | ) |
master_key | specifies the master key used to encrypt all keys and value. It can be of any length, but should be at least 256 bits. |
Subkeys for the cryptographic algorithms used are derived from this master key. No key stretching is performed; if encrypting a PSK database using a password, it is recommended to use PBKDF2 to derive the database master key.
Definition at line 27 of file psk_db.cpp.
References Botan::BlockCipher::create_or_throw(), and Botan::MessageAuthenticationCode::create_or_throw().
|
overridedefault |
|
overridevirtual |
Return the value associated with the specified
name | or otherwise throw an exception. |
Implements Botan::PSK_Database.
Definition at line 63 of file psk_db.cpp.
References Botan::base64_decode(), Botan::base64_encode(), Botan::cast_char_ptr_to_uint8(), kv_get(), name, Botan::nist_key_unwrap_padded(), and Botan::nist_key_wrap_padded().
|
inherited |
Get a PSK in the form of a string (eg if the PSK is a password)
Definition at line 18 of file psk_db.cpp.
References Botan::cast_uint8_ptr_to_char(), and Botan::PSK_Database::get().
|
inlineoverridevirtual |
Returns if the values in the PSK database are encrypted. If false, saved values are being stored in plaintext.
Implements Botan::PSK_Database.
Definition at line 102 of file psk_db.h.
|
protectedpure virtual |
Remove an index
Referenced by remove().
|
protectedpure virtual |
Get a value previously saved with set_raw_value. Should return an empty string if index is not found.
Referenced by get().
|
protectedpure virtual |
Return all indexes in the table.
Referenced by list_names().
|
protectedpure virtual |
Save a encrypted (name.value) pair to the database. Both will be base64 encoded strings.
Referenced by set().
|
overridevirtual |
Return the set of names for which get() will return a value.
Implements Botan::PSK_Database.
Definition at line 38 of file psk_db.cpp.
References Botan::base64_decode(), Botan::cast_uint8_ptr_to_char(), kv_get_all(), and Botan::nist_key_unwrap_padded().
|
overridevirtual |
Remove a PSK from the database
Implements Botan::PSK_Database.
Definition at line 56 of file psk_db.cpp.
References Botan::base64_encode(), Botan::cast_char_ptr_to_uint8(), kv_del(), name, and Botan::nist_key_wrap_padded().
|
overridevirtual |
Set a value that can later be accessed with get(). If name already exists in the database, the old value will be overwritten.
Implements Botan::PSK_Database.
Definition at line 81 of file psk_db.cpp.
References Botan::base64_encode(), Botan::cast_char_ptr_to_uint8(), kv_set(), name, and Botan::nist_key_wrap_padded().
|
inherited |
Definition at line 23 of file psk_db.cpp.
References Botan::cast_char_ptr_to_uint8(), and Botan::PSK_Database::set().
|
inlineinherited |