/ external / libecc / include / libecc / hash / sha3-512.h
sha3-512.h
 1  /*
 2   *  Copyright (C) 2017 - 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   *      Jean-Pierre FLORI <jean-pierre.flori@ssi.gouv.fr>
 8   *
 9   *  Contributors:
10   *      Nicolas VIVET <nicolas.vivet@ssi.gouv.fr>
11   *      Karim KHALFALLAH <karim.khalfallah@ssi.gouv.fr>
12   *
13   *  This software is licensed under a dual BSD and GPL v2 license.
14   *  See LICENSE file at the root folder of the project.
15   */
16  #include <libecc/lib_ecc_config.h>
17  #ifdef WITH_HASH_SHA3_512
18  
19  #ifndef __SHA3_512_H__
20  #define __SHA3_512_H__
21  
22  #include <libecc/words/words.h>
23  #include <libecc/utils/utils.h>
24  #include "sha3.h"
25  
26  #define SHA3_512_BLOCK_SIZE   72
27  #define SHA3_512_DIGEST_SIZE  64
28  #define SHA3_512_DIGEST_SIZE_BITS  512
29  
30  /* Compute max hash digest and block sizes */
31  #ifndef MAX_DIGEST_SIZE
32  #define MAX_DIGEST_SIZE	0
33  #endif
34  #if (MAX_DIGEST_SIZE < SHA3_512_DIGEST_SIZE)
35  #undef MAX_DIGEST_SIZE
36  #define MAX_DIGEST_SIZE SHA3_512_DIGEST_SIZE
37  #endif
38  
39  #ifndef MAX_DIGEST_SIZE_BITS
40  #define MAX_DIGEST_SIZE_BITS    0
41  #endif
42  #if (MAX_DIGEST_SIZE_BITS < SHA3_512_DIGEST_SIZE_BITS)
43  #undef MAX_DIGEST_SIZE_BITS
44  #define MAX_DIGEST_SIZE_BITS SHA3_512_DIGEST_SIZE_BITS
45  #endif
46  
47  #ifndef MAX_BLOCK_SIZE
48  #define MAX_BLOCK_SIZE  0
49  #endif
50  #if (MAX_BLOCK_SIZE < SHA3_512_BLOCK_SIZE)
51  #undef MAX_BLOCK_SIZE
52  #define MAX_BLOCK_SIZE SHA3_512_BLOCK_SIZE
53  #endif
54  
55  #define SHA3_512_HASH_MAGIC ((word_t)(0x9104729373982346ULL))
56  #define SHA3_512_HASH_CHECK_INITIALIZED(A, ret, err) \
57          MUST_HAVE((((void *)(A)) != NULL) && ((A)->magic == SHA3_512_HASH_MAGIC), ret, err)
58  
59  typedef sha3_context sha3_512_context;
60  
61  ATTRIBUTE_WARN_UNUSED_RET int sha3_512_init(sha3_512_context *ctx);
62  ATTRIBUTE_WARN_UNUSED_RET int sha3_512_update(sha3_512_context *ctx, const u8 *input, u32 ilen);
63  ATTRIBUTE_WARN_UNUSED_RET int sha3_512_final(sha3_512_context *ctx, u8 output[SHA3_512_DIGEST_SIZE]);
64  ATTRIBUTE_WARN_UNUSED_RET int sha3_512_scattered(const u8 **inputs, const u32 *ilens,
65  		       u8 output[SHA3_512_DIGEST_SIZE]);
66  ATTRIBUTE_WARN_UNUSED_RET int sha3_512(const u8 *input, u32 ilen, u8 output[SHA3_512_DIGEST_SIZE]);
67  
68  #endif /* __SHA3_512_H__ */
69  #endif /* WITH_HASH_SHA3_512 */