Botan 3.14.1
Crypto and TLS for C&
hash_engine_keccak.h
Go to the documentation of this file.
1/*
2* (C) 2026 Jack Lloyd
3*
4* Botan is released under the Simplified BSD License (see license.txt)
5*/
6
7#ifndef BOTAN_HASH_ENGINE_KECCAK_H_
8#define BOTAN_HASH_ENGINE_KECCAK_H_
9
10#include <botan/internal/hash_engine.h>
11
12namespace Botan {
13
14/**
15* Create a multi-buffer Keccak (SHAKE-128/256, SHA-3) Hash_Engine
16*
17* Returns nullptr if the hash is not Keccak based, if the requested
18* provider does not match, or if no SIMD implementation is usable on
19* this CPU.
20*/
21std::unique_ptr<Hash_Engine> create_keccak_mb_engine(std::string_view hash_fn,
22 std::span<const uint8_t> common_prefix,
23 std::string_view provider);
24
25/*
26* Multi-buffer Keccak-f[1600] permutations
27*
28* The states buffer holds the 25 Keccak words for each lane, in
29* word-major order (all lanes of word 0, then all lanes of word 1, ...).
30*
31* The absorb variants keep the state in registers while absorbing and
32* permuting nblocks rate blocks. blocks[b * lanes + l] points to the
33* rate bytes of block b of lane l, which the kernel transposes into the
34* word-major lane order as it absorbs. At most KECCAK_MB_ABSORB_BLOCKS
35* blocks may be passed per call.
36*/
37
38inline constexpr size_t KECCAK_MB_ABSORB_BLOCKS = 8;
39
40#if defined(BOTAN_HAS_HASH_ENGINE_KECCAK_AVX2)
41void keccak_mb_permute_x4(uint64_t* states);
42void keccak_mb_absorb_x4(uint64_t* states, const uint8_t* const* blocks, size_t rate_words, size_t nblocks);
43#endif
44
45#if defined(BOTAN_HAS_HASH_ENGINE_KECCAK_AVX512)
46void keccak_mb_permute_x8(uint64_t* states);
47void keccak_mb_absorb_x8(uint64_t* states, const uint8_t* const* blocks, size_t rate_words, size_t nblocks);
48#endif
49
50} // namespace Botan
51
52#endif
BOTAN_FN_ISA_SIMD_8X64 void keccak_mb_absorb_x8(uint64_t *states, const uint8_t *const *blocks, size_t rate_words, size_t nblocks)
BOTAN_FN_ISA_SIMD_4X64 void keccak_mb_absorb_x4(uint64_t *states, const uint8_t *const *blocks, size_t rate_words, size_t nblocks)
std::unique_ptr< Hash_Engine > create_keccak_mb_engine(std::string_view hash_fn, std::span< const uint8_t > common_prefix, std::string_view provider)
constexpr size_t KECCAK_MB_ABSORB_BLOCKS
BOTAN_FN_ISA_SIMD_4X64 void keccak_mb_permute_x4(uint64_t *states)
BOTAN_FN_ISA_SIMD_8X64 void keccak_mb_permute_x8(uint64_t *states)