Botan 3.11.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 26 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 29 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 28 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 39 of file sponge.h.

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

References bit_rate(), BOTAN_ARG_CHECK, and word_bits.

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

59{ 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 51 of file sponge.h.

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

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

47{ 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 53 of file sponge.h.

53{ return state_bytes() - byte_rate(); }
static constexpr size_t state_bytes()
Definition sponge.h:43
constexpr size_t byte_rate() const
Definition sponge.h:49

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

49{ 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 57 of file sponge.h.

57{ 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 62 of file sponge.h.

62{ 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 55 of file sponge.h.

55{ 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 45 of file sponge.h.

45{ 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 43 of file sponge.h.

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

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


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