Botan 3.11.0
Crypto and TLS for C&
Botan::Ascon_p Class Referencefinal

#include <ascon_perm.h>

Inheritance diagram for Botan::Ascon_p:
Botan::Sponge< 5, uint64_t >

Classes

struct  Config

Public Types

using state_t
using word_t

Public Member Functions

size_t & _cursor ()
void absorb (std::span< const uint8_t > input, std::optional< uint8_t > permutation_rounds=std::nullopt)
consteval Ascon_p (Config config)
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
void finish ()
void initial_permute ()
void intermediate_finish ()
void percolate_in (std::span< uint8_t > data)
void percolate_out (std::span< uint8_t > data)
void permute ()
std::string provider () const
template<size_t offset, size_t count>
requires (offset + count <= state_bytes())
constexpr auto range_of_state ()
void squeeze (std::span< uint8_t > output)
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
static constexpr size_t word_bytes

Protected Member Functions

void reset_cursor ()

Detailed Description

Ascon_p as specified in NIST SP.800-232, Section 3

Definition at line 22 of file ascon_perm.h.

Member Typedef Documentation

◆ state_t

using Botan::Sponge< words, word >::state_t
inherited

Definition at line 29 of file sponge.h.

◆ word_t

using Botan::Sponge< words, word >::word_t
inherited

Definition at line 28 of file sponge.h.

Constructor & Destructor Documentation

◆ Ascon_p()

Botan::Ascon_p::Ascon_p ( Config config)
inlineexplicitconsteval

Definition at line 32 of file ascon_perm.h.

32 :
33 Sponge({config.bit_rate, config.initial_state}),
34 m_init_final_rounds(config.init_and_final_rounds),
35 m_processing_rounds(config.processing_rounds) {
36 BOTAN_ARG_CHECK(m_init_final_rounds > 0 && m_init_final_rounds <= 16,
37 "Invalid Ascon initialization/finalization rounds");
38
39 BOTAN_ARG_CHECK(m_processing_rounds > 0 && m_processing_rounds <= 16, "Invalid Ascon processing rounds");
40 }
#define BOTAN_ARG_CHECK(expr, msg)
Definition assert.h:33
constexpr Sponge(Config config)
Definition sponge.h:39

References Botan::Ascon_p::Config::bit_rate, Botan::Ascon_p::Config::initial_state, and Botan::Sponge< 5, uint64_t >::Sponge().

Member Function Documentation

◆ _cursor()

size_t & Botan::Sponge< words, word >::_cursor ( )
inlineinherited

Definition at line 59 of file sponge.h.

59{ return m_S_cursor; }

◆ absorb()

void Botan::Ascon_p::absorb ( std::span< const uint8_t > input,
std::optional< uint8_t > permutation_rounds = std::nullopt )

Definition at line 17 of file ascon_perm.cpp.

17 {
18 const auto rounds = permutation_rounds.value_or(m_processing_rounds);
19 absorb_into_sponge(*this, input, [this, rounds] { permute(rounds); });
20}
void absorb_into_sponge(SpongeT &sponge, std::span< const uint8_t > input, const detail::PermutationFn auto &permutation_fn)

References Botan::absorb_into_sponge(), and permute().

◆ bit_capacity()

size_t Botan::Sponge< words, word >::bit_capacity ( ) const
inlineconstexprinherited

Definition at line 51 of file sponge.h.

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

◆ bit_rate()

size_t Botan::Sponge< words, word >::bit_rate ( ) const
inlineconstexprinherited

Definition at line 47 of file sponge.h.

47{ return m_bit_rate; }

◆ byte_capacity()

size_t Botan::Sponge< words, word >::byte_capacity ( ) const
inlineconstexprinherited

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

◆ byte_rate()

size_t Botan::Sponge< words, word >::byte_rate ( ) const
inlineconstexprinherited

Definition at line 49 of file sponge.h.

49{ return m_bit_rate / 8; }

◆ cursor()

size_t Botan::Sponge< words, word >::cursor ( ) const
inlineinherited

Definition at line 57 of file sponge.h.

57{ return m_S_cursor; }

◆ finish()

void Botan::Ascon_p::finish ( )
inline

Definition at line 49 of file ascon_perm.h.

49{ finish(m_init_final_rounds); }

References finish().

Referenced by finish(), and intermediate_finish().

◆ initial_permute()

void Botan::Ascon_p::initial_permute ( )
inline

Definition at line 55 of file ascon_perm.h.

55{ permute(m_init_final_rounds); }

References permute().

◆ intermediate_finish()

void Botan::Ascon_p::intermediate_finish ( )
inline

Definition at line 51 of file ascon_perm.h.

51{ finish(m_processing_rounds); }

References finish().

◆ percolate_in()

void Botan::Ascon_p::percolate_in ( std::span< uint8_t > data)

Definition at line 26 of file ascon_perm.cpp.

26 {
27 BufferSlicer input_slicer(data);
28 BufferStuffer output_stuffer(data);
29
30 process_bytes_in_sponge(*this, data.size(), [&](uint64_t state_word, auto bounds) {
31 state_word ^= bounds.read_from(input_slicer);
32 bounds.write_into(output_stuffer, state_word);
33 return state_word;
34 });
35
36 BOTAN_ASSERT_NOMSG(input_slicer.empty());
37 BOTAN_ASSERT_NOMSG(output_stuffer.full());
38}
#define BOTAN_ASSERT_NOMSG(expr)
Definition assert.h:75
BOTAN_FORCE_INLINE void process_bytes_in_sponge(SpongeT &sponge, size_t bytes_to_process, const detail::PermutationFn auto &permutation_fn, const detail::ModifierFn< SpongeT > auto &modifier_fn)

References BOTAN_ASSERT_NOMSG, Botan::BufferSlicer::empty(), Botan::BufferStuffer::full(), and Botan::process_bytes_in_sponge().

◆ percolate_out()

void Botan::Ascon_p::percolate_out ( std::span< uint8_t > data)

Definition at line 40 of file ascon_perm.cpp.

40 {
41 BufferSlicer input_slicer(data);
42 BufferStuffer output_stuffer(data);
43
44 process_bytes_in_sponge(*this, data.size(), [&](uint64_t state_word, auto bounds) {
45 const auto input_word = bounds.read_from(input_slicer);
46 bounds.write_into(output_stuffer, state_word ^ input_word);
47 return bounds.masked_assignment(state_word, input_word);
48 });
49
50 BOTAN_ASSERT_NOMSG(input_slicer.empty());
51 BOTAN_ASSERT_NOMSG(output_stuffer.full());
52}

References BOTAN_ASSERT_NOMSG, Botan::BufferSlicer::empty(), Botan::BufferStuffer::full(), and Botan::process_bytes_in_sponge().

◆ permute()

void Botan::Ascon_p::permute ( )
inline

Definition at line 53 of file ascon_perm.h.

53{ permute(m_processing_rounds); }

References permute().

Referenced by absorb(), initial_permute(), and permute().

◆ provider()

std::string Botan::Ascon_p::provider ( ) const
inline

Definition at line 42 of file ascon_perm.h.

42{ return "base"; }

◆ range_of_state()

template<size_t offset, size_t count>
requires (offset + count <= state_bytes())
auto Botan::Ascon_p::range_of_state ( )
inlineconstexpr

Definition at line 59 of file ascon_perm.h.

59 {
60 return std::span{state()}.template subspan<offset, count>();
61 }
constexpr auto & state()
Definition sponge.h:55

References Botan::Sponge< 5, uint64_t >::state().

◆ reset_cursor()

void Botan::Sponge< words, word >::reset_cursor ( )
inlineprotectedinherited

Definition at line 62 of file sponge.h.

62{ m_S_cursor = 0; }

◆ squeeze()

void Botan::Ascon_p::squeeze ( std::span< uint8_t > output)

Definition at line 22 of file ascon_perm.cpp.

22 {
23 squeeze_from_sponge(*this, output);
24}
void squeeze_from_sponge(SpongeT &sponge, std::span< uint8_t > output, const detail::PermutationFn auto &permutation_fn)

References Botan::squeeze_from_sponge().

◆ state()

auto & Botan::Sponge< words, word >::state ( )
inlineconstexprinherited

Definition at line 55 of file sponge.h.

55{ return m_S; }

Referenced by Botan::Ascon_p::range_of_state().

◆ state_bits()

constexpr size_t Botan::Sponge< words, word >::state_bits ( )
inlinestaticconstexprinherited

Definition at line 45 of file sponge.h.

45{ return state_bytes() * 8; }

◆ state_bytes()

constexpr size_t Botan::Sponge< words, word >::state_bytes ( )
inlinestaticconstexprinherited

Definition at line 43 of file sponge.h.

43{ return sizeof(state_t); }

Member Data Documentation

◆ word_bits

size_t Botan::Sponge< words, word >::word_bits
staticconstexprinherited

Definition at line 31 of file sponge.h.

◆ word_bytes

size_t Botan::Sponge< words, word >::word_bytes
staticconstexprinherited

Definition at line 30 of file sponge.h.


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