summaryrefslogtreecommitdiff
path: root/sha3.h
diff options
context:
space:
mode:
authorPaul Duncan <pabs@pablotron.org>2024-05-09 01:19:01 -0400
committerPaul Duncan <pabs@pablotron.org>2024-05-09 01:19:01 -0400
commit976ec83f90442bc4c8aaa04c55daedcc56b04473 (patch)
tree488ef1adf9dcca2e26f6477f0871dca4c7f68ca4 /sha3.h
parent531ce003d7f94a0adebe6a1eaebdbcf087d69bae (diff)
downloadsha3-976ec83f90442bc4c8aaa04c55daedcc56b04473.tar.bz2
sha3-976ec83f90442bc4c8aaa04c55daedcc56b04473.zip
sha3.[hc]: add sha3_xof12_t, refactor xor12 and turboshake functions to use it
Diffstat (limited to 'sha3.h')
-rw-r--r--sha3.h18
1 files changed, 17 insertions, 1 deletions
diff --git a/sha3.h b/sha3.h
index 66956e0..05589ad 100644
--- a/sha3.h
+++ b/sha3.h
@@ -1988,6 +1988,22 @@ void parallelhash256_xof_once(const parallelhash_params_t params, const uint8_t
*/
/**
+ * @brief Iterative [XOF][] context (all members are private) for XOFs
+ * with 12 round permutations.
+ * @ingroup turboshake
+ *
+ * @note Used internally by TurboSHAKE and KangarooTwelve.
+ *
+ * [xof]: https://en.wikipedia.org/wiki/Extendable-output_function
+ * "Extendable-Output Function (XOF)"
+ */
+typedef struct {
+ size_t num_bytes; /**< number of bytes absorbed */
+ sha3_state_t a; /**< internal state */
+ _Bool squeezing; /**< mode (absorbing or squeezing) */
+} sha3_xof12_t;
+
+/**
* @brief Absorb bytes into TurboSHAKE128 [XOF][], then squeeze bytes out.
* @ingroup turboshake
*
@@ -2091,7 +2107,7 @@ void turboshake256_custom(const uint8_t pad, const uint8_t *src, const size_t sr
* "Extendable-Output Function (XOF)"
*/
typedef struct {
- sha3_xof_t xof; /**< XOF context (private) */
+ sha3_xof12_t xof; /**< XOF context (private) */
uint8_t pad; /**< Padding byte (private) */
} turboshake_t;