Botan 3.10.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 28 of file sponge.h.

◆ word_t

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

Definition at line 27 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 if(m_init_final_rounds > 16) {
37 throw Botan::Invalid_Argument("Invalid Ascon initialization/finalization rounds");
38 }
39
40 if(m_processing_rounds > 16) {
41 throw Botan::Invalid_Argument("Invalid Ascon processing rounds");
42 }
43 }
constexpr Sponge(Config config)
Definition sponge.h:38

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

60{ 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 18 of file ascon_perm.cpp.

18 {
19 const auto rounds = permutation_rounds.value_or(m_processing_rounds);
20 absorb_into_sponge(*this, input, [this, rounds] { permute(rounds); });
21}
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 52 of file sponge.h.

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

◆ bit_rate()

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

Definition at line 48 of file sponge.h.

48{ return m_bit_rate; }

◆ byte_capacity()

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

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

◆ byte_rate()

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

Definition at line 50 of file sponge.h.

50{ return m_bit_rate / 8; }

◆ cursor()

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

Definition at line 58 of file sponge.h.

58{ return m_S_cursor; }

◆ finish()

void Botan::Ascon_p::finish ( )
inline

Definition at line 52 of file ascon_perm.h.

52{ 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 58 of file ascon_perm.h.

58{ permute(m_init_final_rounds); }

References permute().

◆ intermediate_finish()

void Botan::Ascon_p::intermediate_finish ( )
inline

Definition at line 54 of file ascon_perm.h.

54{ finish(m_processing_rounds); }

References finish().

◆ percolate_in()

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

Definition at line 27 of file ascon_perm.cpp.

27 {
28 BufferSlicer input_slicer(data);
29 BufferStuffer output_stuffer(data);
30
31 process_bytes_in_sponge(*this, data.size(), [&](uint64_t state_word, auto bounds) {
32 state_word ^= bounds.read_from(input_slicer);
33 bounds.write_into(output_stuffer, state_word);
34 return state_word;
35 });
36
37 BOTAN_ASSERT_NOMSG(input_slicer.empty());
38 BOTAN_ASSERT_NOMSG(output_stuffer.full());
39}
#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 41 of file ascon_perm.cpp.

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

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 56 of file ascon_perm.h.

56{ 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 45 of file ascon_perm.h.

45{ 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 62 of file ascon_perm.h.

62 {
63 return std::span{state()}.template subspan<offset, count>();
64 }
constexpr auto & state()
Definition sponge.h:56

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

◆ reset_cursor()

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

Definition at line 63 of file sponge.h.

63{ m_S_cursor = 0; }

◆ squeeze()

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

Definition at line 23 of file ascon_perm.cpp.

23 {
24 squeeze_from_sponge(*this, output);
25}
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 56 of file sponge.h.

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

46{ return state_bytes() * 8; }

◆ state_bytes()

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

Definition at line 44 of file sponge.h.

44{ return sizeof(state_t); }

Member Data Documentation

◆ word_bits

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

Definition at line 30 of file sponge.h.

◆ word_bytes

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

Definition at line 29 of file sponge.h.


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