Skip to content

Commit

Permalink
Fix padding issue in Ascon sponge mode of operation
Browse files Browse the repository at this point in the history
Signed-off-by: Anjan Roy <[email protected]>
  • Loading branch information
itzmeanjan committed Dec 3, 2024
1 parent becf099 commit 01dcae1
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions include/ascon/hashes/sponge.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,7 @@ absorb(ascon_perm::ascon_perm_t& state,
forceinline constexpr void
finalize(ascon_perm::ascon_perm_t& state, size_t& block_offset)
{
const size_t pad_bytes = RATE_BYTES - block_offset;
const size_t pad_bits = pad_bytes * std::numeric_limits<uint8_t>::digits;
const uint64_t pad_mask = 1ul << (pad_bits - 1ul);
const auto pad_mask = 0x01ul << (block_offset * std::numeric_limits<uint8_t>::digits);

state[0] ^= pad_mask;
state.permute<ASCON_PERM_NUM_ROUNDS>();
Expand Down

0 comments on commit 01dcae1

Please sign in to comment.