9#include <botan/internal/ascon_perm.h>
11#include <botan/internal/loadstor.h>
12#include <botan/internal/rotate.h>
13#include <botan/internal/sponge_processing.h>
14#include <botan/internal/stl_util.h>
18void Ascon_p::absorb(std::span<const uint8_t> input, std::optional<uint8_t> permutation_rounds) {
19 const auto rounds = permutation_rounds.value_or(m_processing_rounds);
32 state_word ^= bounds.read_from(input_slicer);
33 bounds.write_into(output_stuffer, state_word);
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);
61 constexpr std::array<uint8_t,
state_bytes()> padding{0x01};
77 constexpr std::array<uint64_t, 16> round_constants = {
78 0x3c, 0x2d, 0x1e, 0x0f, 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87, 0x78, 0x69, 0x5a, 0x4b};
80 for(uint8_t i = 0; i < rounds; ++i) {
83 S[2] ^= round_constants[16 - rounds + i];
91 tmp[0] = ~tmp[0] & S[1];
92 tmp[1] = ~tmp[1] & S[2];
93 tmp[2] = ~tmp[2] & S[3];
94 tmp[3] = ~tmp[3] & S[4];
95 tmp[4] = ~tmp[4] & S[0];
#define BOTAN_ASSERT_NOMSG(expr)
#define BOTAN_DEBUG_ASSERT(expr)
void squeeze(std::span< uint8_t > output)
void absorb(std::span< const uint8_t > input, std::optional< uint8_t > permutation_rounds=std::nullopt)
void percolate_in(std::span< uint8_t > data)
void percolate_out(std::span< uint8_t > data)
Helper class to ease in-place marshalling of concatenated fixed-length values.
constexpr bool full() const
static constexpr size_t state_bytes()
constexpr size_t byte_rate() const
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)
BOTAN_FORCE_INLINE constexpr T rotr(T input)
void squeeze_from_sponge(SpongeT &sponge, std::span< uint8_t > output, const detail::PermutationFn auto &permutation_fn)
void absorb_into_sponge(SpongeT &sponge, std::span< const uint8_t > input, const detail::PermutationFn auto &permutation_fn)