9#include <botan/internal/ascon_perm.h>
11#include <botan/internal/buffer_stuffer.h>
12#include <botan/internal/rotate.h>
13#include <botan/internal/sponge_processing.h>
17void Ascon_p::absorb(std::span<const uint8_t> input, std::optional<uint8_t> permutation_rounds) {
18 const auto rounds = permutation_rounds.value_or(m_processing_rounds);
31 state_word ^= bounds.read_from(input_slicer);
32 bounds.write_into(output_stuffer, state_word);
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);
60 constexpr std::array<uint8_t,
state_bytes()> padding{0x01};
76 constexpr std::array<uint64_t, 16> round_constants = {
77 0x3c, 0x2d, 0x1e, 0x0f, 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87, 0x78, 0x69, 0x5a, 0x4b};
79 for(uint8_t i = 0; i < rounds; ++i) {
82 S[2] ^= round_constants[16 - rounds + i];
90 tmp[0] = ~tmp[0] & S[1];
91 tmp[1] = ~tmp[1] & S[2];
92 tmp[2] = ~tmp[2] & S[3];
93 tmp[3] = ~tmp[3] & S[4];
94 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)