135 size_t bytes_to_process,
138 if(bytes_to_process == 0) {
142 constexpr auto word_bytes = SpongeT::word_bytes;
143 const auto byte_rate = sponge.byte_rate();
144 auto& S = sponge.state();
145 auto& cursor = sponge._cursor();
148 const auto bytes_out_of_word_alignment =
static_cast<size_t>(cursor % word_bytes);
149 if(bytes_out_of_word_alignment > 0) {
150 const auto bytes_until_word_alignment = word_bytes - bytes_out_of_word_alignment;
151 const auto bytes_from_input = std::min(bytes_to_process, bytes_until_word_alignment);
154 S[cursor / word_bytes] = modifier_fn(S[cursor / word_bytes],
156 .offset = bytes_out_of_word_alignment,
157 .length = bytes_from_input,
159 cursor += bytes_from_input;
160 bytes_to_process -= bytes_from_input;
162 if(cursor == byte_rate) {
174 while(bytes_to_process >= word_bytes) {
177 while(bytes_to_process >= word_bytes && cursor < byte_rate) {
179 cursor += word_bytes;
180 bytes_to_process -= word_bytes;
183 if(cursor == byte_rate) {
193 if(bytes_to_process > 0) {
194 S[cursor / word_bytes] = modifier_fn(S[cursor / word_bytes],
197 .length = bytes_to_process,
199 cursor += bytes_to_process;