Botan 3.14.1
Crypto and TLS for C&
Botan::Sponge< words, word > Class Template Reference

#include <sponge.h>

Classes

struct  Config

Public Types

using state_t = std::array<word, words>
using word_t = word

Public Member Functions

size_t & _cursor ()
constexpr size_t bit_capacity () const
constexpr size_t bit_rate () const
constexpr size_t byte_capacity () const
constexpr size_t byte_rate () const
size_t cursor () const
constexpr Sponge & operator= (const Sponge &)=default
constexpr Sponge & operator= (Sponge &&)=default
constexpr Sponge (Config config)
constexpr Sponge (const Sponge &)=default
constexpr Sponge (Sponge &&)=default
constexpr auto & state ()

Static Public Member Functions

static constexpr size_t state_bits ()
static constexpr size_t state_bytes ()

Static Public Attributes

static constexpr size_t word_bits = word_bytes * 8
static constexpr size_t word_bytes = sizeof(word)

Protected Member Functions

void reset_cursor ()
constexpr ~Sponge ()

Detailed Description

template<size_t words, std::unsigned_integral word = uint64_t>
class Botan::Sponge< words, word >

A generic sponge construction with a fixed state size defined in terms of "words" of an unsigned integral type.

This is meant to be used as a base class for specific sponge constructions like Keccak or Ascon.

Definition at line 28 of file sponge.h.

Member Typedef Documentation

◆ state_t

template<size_t words, std::unsigned_integral word = uint64_t>
using Botan::Sponge< words, word >::state_t = std::array<word, words>

Definition at line 31 of file sponge.h.

◆ word_t

template<size_t words, std::unsigned_integral word = uint64_t>
using Botan::Sponge< words, word >::word_t = word

Definition at line 30 of file sponge.h.

Constructor & Destructor Documentation

◆ Sponge() [1/3]

template<size_t words, std::unsigned_integral word = uint64_t>
Botan::Sponge< words, word >::Sponge ( Config config)
inlineexplicitconstexpr

Definition at line 41 of file sponge.h.

41 : m_S(config.initial_state), m_S_cursor(0), m_bit_rate(config.bit_rate) {
42 BOTAN_ARG_CHECK(m_bit_rate > 0 && m_bit_rate % word_bits == 0 && m_bit_rate < words * word_bits,
43 "Invalid sponge bit rate");
44 }
#define BOTAN_ARG_CHECK(expr, msg)
Definition assert.h:33
constexpr size_t bit_rate() const
Definition sponge.h:55
static constexpr size_t word_bits
Definition sponge.h:33

References bit_rate(), BOTAN_ARG_CHECK, and word_bits.

Referenced by operator=(), operator=(), Sponge(), and Sponge().

◆ Sponge() [2/3]

template<size_t words, std::unsigned_integral word = uint64_t>
Botan::Sponge< words, word >::Sponge ( const Sponge< words, word > & )
constexprdefault

References Sponge().

◆ Sponge() [3/3]

template<size_t words, std::unsigned_integral word = uint64_t>
Botan::Sponge< words, word >::Sponge ( Sponge< words, word > && )
constexprdefault

References Sponge().

◆ ~Sponge()

template<size_t words, std::unsigned_integral word = uint64_t>
Botan::Sponge< words, word >::~Sponge ( )
inlineconstexprprotected

Definition at line 76 of file sponge.h.

76 {
79 }
80 }
void secure_scrub_memory(void *ptr, size_t n)
Definition mem_utils.cpp:24

References Botan::secure_scrub_memory().

Member Function Documentation

◆ _cursor()

template<size_t words, std::unsigned_integral word = uint64_t>
size_t & Botan::Sponge< words, word >::_cursor ( )
inline

Definition at line 67 of file sponge.h.

67{ return m_S_cursor; }

◆ bit_capacity()

template<size_t words, std::unsigned_integral word = uint64_t>
size_t Botan::Sponge< words, word >::bit_capacity ( ) const
inlineconstexpr

Definition at line 59 of file sponge.h.

59{ return state_bits() - bit_rate(); }
static constexpr size_t state_bits()
Definition sponge.h:53

References bit_rate(), and state_bits().

◆ bit_rate()

template<size_t words, std::unsigned_integral word = uint64_t>
size_t Botan::Sponge< words, word >::bit_rate ( ) const
inlineconstexpr

Definition at line 55 of file sponge.h.

55{ return m_bit_rate; }

Referenced by bit_capacity(), and Sponge().

◆ byte_capacity()

template<size_t words, std::unsigned_integral word = uint64_t>
size_t Botan::Sponge< words, word >::byte_capacity ( ) const
inlineconstexpr

Definition at line 61 of file sponge.h.

61{ return state_bytes() - byte_rate(); }
static constexpr size_t state_bytes()
Definition sponge.h:51
constexpr size_t byte_rate() const
Definition sponge.h:57

References byte_rate(), and state_bytes().

◆ byte_rate()

template<size_t words, std::unsigned_integral word = uint64_t>
size_t Botan::Sponge< words, word >::byte_rate ( ) const
inlineconstexpr

Definition at line 57 of file sponge.h.

57{ return m_bit_rate / 8; }

Referenced by byte_capacity().

◆ cursor()

template<size_t words, std::unsigned_integral word = uint64_t>
size_t Botan::Sponge< words, word >::cursor ( ) const
inline

Definition at line 65 of file sponge.h.

65{ return m_S_cursor; }

◆ operator=() [1/2]

template<size_t words, std::unsigned_integral word = uint64_t>
Sponge & Botan::Sponge< words, word >::operator= ( const Sponge< words, word > & )
constexprdefault

References Sponge().

◆ operator=() [2/2]

template<size_t words, std::unsigned_integral word = uint64_t>
Sponge & Botan::Sponge< words, word >::operator= ( Sponge< words, word > && )
constexprdefault

References Sponge().

◆ reset_cursor()

template<size_t words, std::unsigned_integral word = uint64_t>
void Botan::Sponge< words, word >::reset_cursor ( )
inlineprotected

Definition at line 70 of file sponge.h.

70{ m_S_cursor = 0; }

◆ state()

template<size_t words, std::unsigned_integral word = uint64_t>
auto & Botan::Sponge< words, word >::state ( )
inlineconstexpr

Definition at line 63 of file sponge.h.

63{ return m_S; }

◆ state_bits()

template<size_t words, std::unsigned_integral word = uint64_t>
constexpr size_t Botan::Sponge< words, word >::state_bits ( )
inlinestaticconstexpr

Definition at line 53 of file sponge.h.

53{ return state_bytes() * 8; }

References state_bytes().

Referenced by bit_capacity().

◆ state_bytes()

template<size_t words, std::unsigned_integral word = uint64_t>
constexpr size_t Botan::Sponge< words, word >::state_bytes ( )
inlinestaticconstexpr

Definition at line 51 of file sponge.h.

51{ return sizeof(state_t); }
std::array< word, words > state_t
Definition sponge.h:31

Referenced by byte_capacity(), and state_bits().

Member Data Documentation

◆ word_bits

template<size_t words, std::unsigned_integral word = uint64_t>
size_t Botan::Sponge< words, word >::word_bits = word_bytes * 8
staticconstexpr

Definition at line 33 of file sponge.h.

Referenced by Sponge().

◆ word_bytes

template<size_t words, std::unsigned_integral word = uint64_t>
size_t Botan::Sponge< words, word >::word_bytes = sizeof(word)
staticconstexpr

Definition at line 32 of file sponge.h.


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