/ external / libecc / include / libecc / hash / sha512-224.h
sha512-224.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_SHA512_224
18  
19  #ifndef __SHA512_224_H__
20  #define __SHA512_224_H__
21  
22  #include <libecc/words/words.h>
23  #include <libecc/utils/utils.h>
24  #include <libecc/hash/sha2.h>
25  #include <libecc/hash/sha512_core.h>
26  
27  #define SHA512_224_STATE_SIZE   SHA512_CORE_STATE_SIZE
28  #define SHA512_224_BLOCK_SIZE   SHA512_CORE_BLOCK_SIZE
29  #define SHA512_224_DIGEST_SIZE  28
30  #define SHA512_224_DIGEST_SIZE_BITS  224
31  
32  /* Compute max hash digest and block sizes */
33  #ifndef MAX_DIGEST_SIZE
34  #define MAX_DIGEST_SIZE 0
35  #endif
36  #if (MAX_DIGEST_SIZE < SHA512_224_DIGEST_SIZE)
37  #undef MAX_DIGEST_SIZE
38  #define MAX_DIGEST_SIZE SHA512_224_DIGEST_SIZE
39  #endif
40  
41  #ifndef MAX_DIGEST_SIZE_BITS
42  #define MAX_DIGEST_SIZE_BITS    0
43  #endif
44  #if (MAX_DIGEST_SIZE_BITS < SHA512_224_DIGEST_SIZE_BITS)
45  #undef MAX_DIGEST_SIZE_BITS
46  #define MAX_DIGEST_SIZE_BITS SHA512_224_DIGEST_SIZE_BITS
47  #endif
48  
49  #ifndef MAX_BLOCK_SIZE
50  #define MAX_BLOCK_SIZE	0
51  #endif
52  #if (MAX_BLOCK_SIZE < SHA512_224_BLOCK_SIZE)
53  #undef MAX_BLOCK_SIZE
54  #define MAX_BLOCK_SIZE SHA512_224_BLOCK_SIZE
55  #endif
56  
57  #define SHA512_224_HASH_MAGIC ((word_t)(0x12345a2b73932916ULL))
58  #define SHA512_224_HASH_CHECK_INITIALIZED(A, ret, err) \
59          MUST_HAVE((((void *)(A)) != NULL) && ((A)->magic == SHA512_224_HASH_MAGIC), ret, err)
60  
61  typedef sha512_core_context sha512_224_context;
62  
63  ATTRIBUTE_WARN_UNUSED_RET int sha512_224_init(sha512_224_context *ctx);
64  ATTRIBUTE_WARN_UNUSED_RET int sha512_224_update(sha512_224_context *ctx, const u8 *input, u32 ilen);
65  ATTRIBUTE_WARN_UNUSED_RET int sha512_224_final(sha512_224_context *ctx, u8 output[SHA512_224_DIGEST_SIZE]);
66  ATTRIBUTE_WARN_UNUSED_RET int sha512_224_scattered(const u8 **inputs, const u32 *ilens,
67  			 u8 output[SHA512_224_DIGEST_SIZE]);
68  ATTRIBUTE_WARN_UNUSED_RET int sha512_224(const u8 *input, u32 ilen, u8 output[SHA512_224_DIGEST_SIZE]);
69  
70  #endif /* __SHA512_224_H__ */
71  #endif /* WITH_HASH_SHA512_224 */