1 // SPDX-License-Identifier: CDDL-1.0 2 /* 3 * This file and its contents are supplied under the terms of the 4 * Common Development and Distribution License ("CDDL"), version 1.0. 5 * You may only use this file in accordance with the terms of version 6 * 1.0 of the CDDL. 7 * 8 * A full copy of the text of the CDDL should have accompanied this 9 * source. A copy of the CDDL is also available via the Internet at 10 * https://opensource.org/license/CDDL-1.0. 11 */ 12 13 /* 14 * Based on Edon-R implementation for SUPERCOP, based on NIST API. 15 * Copyright (c) 2009, 2010 Jørn Amundsen <jorn.amundsen@ntnu.no> 16 * Copyright (c) 2013 Saso Kiselkov, All rights reserved 17 * Copyright (c) 2022 Tino Reichardt <milky-zfs@mcmilk.de> 18 */ 19 20 #ifndef _SYS_EDONR_H_ 21 #define _SYS_EDONR_H_ 22 23 #ifdef __cplusplus 24 extern "C" { 25 #endif 26 27 #ifdef _KERNEL 28 #include <sys/types.h> 29 #else 30 #include <stdint.h> 31 #include <stdlib.h> 32 #endif 33 34 /* 35 * EdonR allows to call EdonRUpdate() consecutively only if the total length 36 * of stored unprocessed data and the new supplied data is less than or equal 37 * to the BLOCK_SIZE on which the compression functions operates. 38 * Otherwise an assertion failure is invoked. 39 */ 40 41 /* Specific algorithm definitions */ 42 #define EdonR512_DIGEST_SIZE 64 43 #define EdonR512_BLOCK_SIZE 128 44 #define EdonR512_BLOCK_BITSIZE 1024 45 46 typedef struct { 47 uint64_t DoublePipe[16]; 48 uint8_t LastPart[EdonR512_BLOCK_SIZE * 2]; 49 } EdonRData512; 50 51 typedef struct { 52 uint64_t bits_processed; 53 int unprocessed_bits; 54 union { 55 EdonRData512 p512[1]; 56 } pipe[1]; 57 } EdonRState; 58 59 void EdonRInit(EdonRState *state); 60 void EdonRUpdate(EdonRState *state, const uint8_t *data, size_t databitlen); 61 void EdonRFinal(EdonRState *state, uint8_t *hashval); 62 void EdonRHash(const uint8_t *data, size_t databitlen, uint8_t *hashval); 63 64 #ifdef __cplusplus 65 } 66 #endif 67 68 #endif /* _SYS_EDONR_H_ */ 69