Botan 3.10.0
Crypto and TLS for C&
Botan::detail::PartialWordBounds< SpongeT > Class Template Referencefinal

#include <sponge_processing.h>

Public Member Functions

word_t masked_assignment (word_t state_word, word_t partial_input_word) const
word_t read_from (BufferSlicer &slicer) const
void write_into (BufferStuffer &stuffer, word_t partial_word) const

Public Attributes

size_t length
size_t offset

Detailed Description

template<SpongeLike SpongeT>
class Botan::detail::PartialWordBounds< SpongeT >

Represents the bounds of partial byte-oriented data within a word of the sponge state. Downstream algorithms can use this to conveniently modify the passed in partial state word with data written or read from an input or output byte buffer.

Definition at line 43 of file sponge_processing.h.

Member Function Documentation

◆ masked_assignment()

template<SpongeLike SpongeT>
word_t Botan::detail::PartialWordBounds< SpongeT >::masked_assignment ( word_t state_word,
word_t partial_input_word ) const
inline

Assigns the bits in 'partial_input_word' to their corresponding bits in 'state_word' at the specified '.offset' and '.length' while leaving all other bits in 'state_word' unchanged.

Definition at line 77 of file sponge_processing.h.

77 {
79 const auto mask = ((word_t(0) - 1) >> ((word_bytes - length) * 8)) << (offset * 8);
80 return (state_word & ~mask) | (partial_input_word & mask);
81 }
#define BOTAN_DEBUG_ASSERT(expr)
Definition assert.h:129

References BOTAN_DEBUG_ASSERT, length, and offset.

◆ read_from()

template<SpongeLike SpongeT>
word_t Botan::detail::PartialWordBounds< SpongeT >::read_from ( BufferSlicer & slicer) const
inline

Reads '.length' bytes from the provided slicer and places them within a word at the specified '.offset' in little-endian order.

Definition at line 57 of file sponge_processing.h.

57 {
59 slicer.copy_into(std::span{partial_word_bytes}.subspan(offset, length));
61 }
constexpr auto load_le(ParamTs &&... params)
Definition loadstor.h:495

References Botan::BufferSlicer::copy_into(), length, Botan::load_le(), and offset.

◆ write_into()

template<SpongeLike SpongeT>
void Botan::detail::PartialWordBounds< SpongeT >::write_into ( BufferStuffer & stuffer,
word_t partial_word ) const
inline

Writes '.length' bytes from the provided word at the specified '.offset' into the provided stuffer in little-endian order.

Definition at line 67 of file sponge_processing.h.

67 {
70 }
constexpr auto store_le(ParamTs &&... params)
Definition loadstor.h:736

References Botan::BufferStuffer::append(), length, offset, and Botan::store_le().

Member Data Documentation

◆ length

template<SpongeLike SpongeT>
size_t Botan::detail::PartialWordBounds< SpongeT >::length

Definition at line 46 of file sponge_processing.h.

Referenced by masked_assignment(), read_from(), and write_into().

◆ offset

template<SpongeLike SpongeT>
size_t Botan::detail::PartialWordBounds< SpongeT >::offset

Definition at line 45 of file sponge_processing.h.

Referenced by masked_assignment(), read_from(), and write_into().


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