xref: /freebsd/crypto/libecc/include/libecc/hash/shake.h (revision f0865ec9906d5a18fa2a3b61381f22ce16e606ad)
1 /*
2  *  Copyright (C) 2021 - This file is part of libecc project
3  *
4  *  Authors:
5  *      Ryad BENADJILA <ryadbenadjila@gmail.com>
6  *      Arnaud EBALARD <arnaud.ebalard@ssi.gouv.fr>
7  *
8  *  This software is licensed under a dual BSD and GPL v2 license.
9  *  See LICENSE file at the root folder of the project.
10  */
11 #ifndef __SHAKE_H__
12 #define __SHAKE_H__
13 
14 #include <libecc/hash/keccak.h>
15 
16 typedef enum {
17 	SHAKE_LITTLE = 0,
18 	SHAKE_BIG = 1,
19 } shake_endianness;
20 /*
21  * Generic context for all SHAKE instances. Only difference is digest size
22  * value, initialized in init() call and used in finalize().
23  */
24 typedef struct shake_context_ {
25 	u8 shake_digest_size;
26 	u8 shake_block_size;
27 	shake_endianness shake_endian;
28 	/* Local index, useful for the absorbing phase */
29 	u64 shake_idx;
30 	/* Keccak's state, viewed as a bi-dimensional array */
31 	u64 shake_state[KECCAK_SLICES * KECCAK_SLICES];
32 	/* Initialization magic value */
33 	word_t magic;
34 } shake_context;
35 
36 
37 ATTRIBUTE_WARN_UNUSED_RET int _shake_init(shake_context *ctx, u8 digest_size, u8 block_size);
38 ATTRIBUTE_WARN_UNUSED_RET int _shake_update(shake_context *ctx, const u8 *buf, u32 buflen);
39 ATTRIBUTE_WARN_UNUSED_RET int _shake_finalize(shake_context *ctx, u8 *output);
40 
41 #endif /* __SHAKE_H__ */
42