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 #if defined(WITH_HASH_SHA512) || defined(WITH_HASH_SHA512_224) || defined(WITH_HASH_SHA512_256) 18 19 #ifndef __SHA512_CORE_H__ 20 #define __SHA512_CORE_H__ 21 22 #include <libecc/words/words.h> 23 #include <libecc/utils/utils.h> 24 #include <libecc/hash/sha2.h> 25 26 #define SHA512_CORE_STATE_SIZE 8 27 #define SHA512_CORE_BLOCK_SIZE 128 28 #define SHA512_CORE_DIGEST_SIZE 64 29 30 typedef struct { 31 /* Number of bytes processed on 128 bits */ 32 u64 sha512_total[2]; 33 /* Internal state */ 34 u64 sha512_state[SHA512_CORE_STATE_SIZE]; 35 /* Internal buffer to handle updates in a block */ 36 u8 sha512_buffer[SHA512_CORE_BLOCK_SIZE]; 37 /* Initialization magic value */ 38 word_t magic; 39 } sha512_core_context; 40 41 42 ATTRIBUTE_WARN_UNUSED_RET int sha512_core_update(sha512_core_context *ctx, const u8 *input, u32 ilen); 43 ATTRIBUTE_WARN_UNUSED_RET int sha512_core_final(sha512_core_context *ctx, u8 *output, u32 output_size); 44 45 #endif /* __SHA512_CORE_H__ */ 46 #endif /* WITH_HASH_SHA512 */ 47