From abb8f678231d2af34b51bf1cb7fd853e123cefee Mon Sep 17 00:00:00 2001 From: Paul Duncan Date: Tue, 5 Sep 2023 21:18:49 -0400 Subject: sha3.[hc]: add turboshake{128,256}_custom() --- sha3.h | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'sha3.h') diff --git a/sha3.h b/sha3.h index 6ca8922..4f1ce06 100644 --- a/sha3.h +++ b/sha3.h @@ -1155,6 +1155,22 @@ void parallelhash256_xof_once(const parallelhash_params_t params, const uint8_t */ void turboshake128(const uint8_t *src, const size_t src_len, uint8_t *dst, const size_t dst_len); +/** + * Initialize internal TurboSHAKE128 context with custom padding byte + * `pad`, absorb `src_len` bytes of input from in source buffer `src`, + * then squeeze `dst_len` bytes of output into destination buffer `dst`. + * + * Note: The padding byte value must be in the range [0x01, 0x7F] and + * can be used for domain separation. + * + * @param[in] pad Padding byte. + * @param[in] src Source buffer. + * @param[in] src_len Source buffer length, in bytes. + * @param[out] dst Destination buffer. + * @param[in] dst_len Destination buffer length, in bytes. + */ +void turboshake128_custom(const uint8_t pad, const uint8_t *src, const size_t src_len, uint8_t *dst, const size_t dst_len); + /** * Initialize internal TurboSHAKE256 context, absorb `src_len` bytes of * input from in source buffer `src`, then squeeze `dst_len` bytes of output @@ -1167,6 +1183,22 @@ void turboshake128(const uint8_t *src, const size_t src_len, uint8_t *dst, const */ void turboshake256(const uint8_t *src, const size_t src_len, uint8_t *dst, const size_t dst_len); +/** + * Initialize internal TurboSHAKE256 context with custom padding byte + * `pad`, absorb `src_len` bytes of input from in source buffer `src`, + * then squeeze `dst_len` bytes of output into destination buffer `dst`. + * + * Note: The padding byte value must be in the range [0x01, 0x7F] and + * can be used for domain separation. + * + * @param[in] pad Padding byte. + * @param[in] src Source buffer. + * @param[in] src_len Source buffer length, in bytes. + * @param[out] dst Destination buffer. + * @param[in] dst_len Destination buffer length, in bytes. + */ +void turboshake256_custom(const uint8_t pad, const uint8_t *src, const size_t src_len, uint8_t *dst, const size_t dst_len); + // TurboShake XOF context. typedef struct { sha3_xof_t xof; -- cgit v1.2.3