Botan 3.10.0
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 (Config config)
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 ()

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 25 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 28 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 27 of file sponge.h.

Constructor & Destructor Documentation

◆ Sponge()

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

Definition at line 38 of file sponge.h.

38 : m_S(config.initial_state), m_S_cursor(0), m_bit_rate(config.bit_rate) {
39 if(m_bit_rate % (sizeof(word) * 8) != 0 || m_bit_rate > words * sizeof(word) * 8) {
40 throw Botan::Invalid_Argument("Invalid sponge bit rate");
41 }
42 }
constexpr size_t bit_rate() const
Definition sponge.h:48

References bit_rate().

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 60 of file sponge.h.

60{ 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 52 of file sponge.h.

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

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 48 of file sponge.h.

48{ 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 54 of file sponge.h.

54{ return state_bytes() - byte_rate(); }
static constexpr size_t state_bytes()
Definition sponge.h:44
constexpr size_t byte_rate() const
Definition sponge.h:50

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 50 of file sponge.h.

50{ 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 58 of file sponge.h.

58{ return m_S_cursor; }

◆ reset_cursor()

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

Definition at line 63 of file sponge.h.

63{ 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 56 of file sponge.h.

56{ 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 46 of file sponge.h.

46{ 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 44 of file sponge.h.

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

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 30 of file sponge.h.

◆ 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 29 of file sponge.h.


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