Botan 3.9.0
Crypto and TLS for C&
Botan::PSK_Database Class Referenceabstract

#include <psk_db.h>

Inheritance diagram for Botan::PSK_Database:
Botan::Encrypted_PSK_Database Botan::Encrypted_PSK_Database_SQL

Public Member Functions

virtual secure_vector< uint8_t > get (std::string_view name) const =0
std::string get_str (std::string_view name) const
virtual bool is_encrypted () const =0
virtual std::set< std::string > list_names () const =0
virtual void remove (std::string_view name)=0
virtual void set (std::string_view name, const uint8_t psk[], size_t psk_len)=0
void set_str (std::string_view name, std::string_view psk)
void set_vec (std::string_view name, std::span< const uint8_t > psk)
virtual ~PSK_Database ()=default

Detailed Description

This is an interface to a generic PSK (pre-shared key) database. It might be implemented as a plaintext storage or via some mechanism that encrypts the keys and/or values.

Definition at line 26 of file psk_db.h.

Constructor & Destructor Documentation

◆ ~PSK_Database()

virtual Botan::PSK_Database::~PSK_Database ( )
virtualdefault

Member Function Documentation

◆ get()

virtual secure_vector< uint8_t > Botan::PSK_Database::get ( std::string_view name) const
pure virtual
Returns
the value associated with the specified name or otherwise throw an exception.

Implemented in Botan::Encrypted_PSK_Database.

Referenced by get_str().

◆ get_str()

std::string Botan::PSK_Database::get_str ( std::string_view name) const

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.

18 {
19 return bytes_to_string(this->get(name));
20}
virtual secure_vector< uint8_t > get(std::string_view name) const =0
std::string bytes_to_string(std::span< const uint8_t > bytes)
Definition mem_utils.h:45

References Botan::bytes_to_string(), and get().

Referenced by is_encrypted().

◆ is_encrypted()

virtual bool Botan::PSK_Database::is_encrypted ( ) const
pure virtual
Returns
true if the values in the PSK database are encrypted. If false, saved values are being stored in plaintext.

Implemented in Botan::Encrypted_PSK_Database.

References get_str(), and set_str().

◆ list_names()

virtual std::set< std::string > Botan::PSK_Database::list_names ( ) const
pure virtual
Returns
the set of names for which get() will return a value.

Implemented in Botan::Encrypted_PSK_Database.

◆ remove()

virtual void Botan::PSK_Database::remove ( std::string_view name)
pure virtual

Remove the PSK with the given name from the database

Implemented in Botan::Encrypted_PSK_Database.

◆ set()

virtual void Botan::PSK_Database::set ( std::string_view name,
const uint8_t psk[],
size_t psk_len )
pure virtual

Set a value that can later be accessed with get(). If name already exists in the database, the old value will be overwritten.

Implemented in Botan::Encrypted_PSK_Database.

Referenced by set_str(), and set_vec().

◆ set_str()

void Botan::PSK_Database::set_str ( std::string_view name,
std::string_view psk )

Like set() but accepts the PSK as a string (eg for a password).

Definition at line 22 of file psk_db.cpp.

22 {
23 auto pskb = as_span_of_bytes(psk);
24 this->set(name, pskb.data(), pskb.size());
25}
virtual void set(std::string_view name, const uint8_t psk[], size_t psk_len)=0
std::span< const uint8_t > as_span_of_bytes(const char *s, size_t len)
Definition mem_utils.h:28

References Botan::as_span_of_bytes(), and set().

Referenced by is_encrypted().

◆ set_vec()

void Botan::PSK_Database::set_vec ( std::string_view name,
std::span< const uint8_t > psk )
inline

Like set() but accepting an arbitrary contiguous byte array.

Definition at line 69 of file psk_db.h.

69{ set(name, psk.data(), psk.size()); }

References set().


The documentation for this class was generated from the following files: