xref: /illumos-gate/usr/src/uts/common/sys/edonr.h (revision 45818ee1)
1*45818ee1SMatthew Ahrens /*
2*45818ee1SMatthew Ahrens  * IDI,NTNU
3*45818ee1SMatthew Ahrens  *
4*45818ee1SMatthew Ahrens  * CDDL HEADER START
5*45818ee1SMatthew Ahrens  *
6*45818ee1SMatthew Ahrens  * The contents of this file are subject to the terms of the
7*45818ee1SMatthew Ahrens  * Common Development and Distribution License (the "License").
8*45818ee1SMatthew Ahrens  * You may not use this file except in compliance with the License.
9*45818ee1SMatthew Ahrens  *
10*45818ee1SMatthew Ahrens  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
11*45818ee1SMatthew Ahrens  * or http://opensource.org/licenses/CDDL-1.0.
12*45818ee1SMatthew Ahrens  * See the License for the specific language governing permissions
13*45818ee1SMatthew Ahrens  * and limitations under the License.
14*45818ee1SMatthew Ahrens  *
15*45818ee1SMatthew Ahrens  * When distributing Covered Code, include this CDDL HEADER in each
16*45818ee1SMatthew Ahrens  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
17*45818ee1SMatthew Ahrens  * If applicable, add the following below this CDDL HEADER, with the
18*45818ee1SMatthew Ahrens  * fields enclosed by brackets "[]" replaced with your own identifying
19*45818ee1SMatthew Ahrens  * information: Portions Copyright [yyyy] [name of copyright owner]
20*45818ee1SMatthew Ahrens  *
21*45818ee1SMatthew Ahrens  * CDDL HEADER END
22*45818ee1SMatthew Ahrens  *
23*45818ee1SMatthew Ahrens  * Copyright (C) 2009, 2010, Jorn Amundsen <jorn.amundsen@ntnu.no>
24*45818ee1SMatthew Ahrens  *
25*45818ee1SMatthew Ahrens  * Tweaked Edon-R implementation for SUPERCOP, based on NIST API.
26*45818ee1SMatthew Ahrens  *
27*45818ee1SMatthew Ahrens  * $Id: edonr.h 517 2013-02-17 20:34:39Z joern $
28*45818ee1SMatthew Ahrens  */
29*45818ee1SMatthew Ahrens /*
30*45818ee1SMatthew Ahrens  * Portions copyright (c) 2013, Saso Kiselkov, All rights reserved
31*45818ee1SMatthew Ahrens  */
32*45818ee1SMatthew Ahrens 
33*45818ee1SMatthew Ahrens #ifndef	_SYS_EDONR_H_
34*45818ee1SMatthew Ahrens #define	_SYS_EDONR_H_
35*45818ee1SMatthew Ahrens 
36*45818ee1SMatthew Ahrens #ifdef	__cplusplus
37*45818ee1SMatthew Ahrens extern "C" {
38*45818ee1SMatthew Ahrens #endif
39*45818ee1SMatthew Ahrens 
40*45818ee1SMatthew Ahrens #include <sys/types.h>
41*45818ee1SMatthew Ahrens 
42*45818ee1SMatthew Ahrens /*
43*45818ee1SMatthew Ahrens  * EdonR allows to call EdonRUpdate() consecutively only if the total length
44*45818ee1SMatthew Ahrens  * of stored unprocessed data and the new supplied data is less than or equal
45*45818ee1SMatthew Ahrens  * to the BLOCK_SIZE on which the compression functions operates.
46*45818ee1SMatthew Ahrens  * Otherwise an assertion failure is invoked.
47*45818ee1SMatthew Ahrens  */
48*45818ee1SMatthew Ahrens 
49*45818ee1SMatthew Ahrens /* Specific algorithm definitions */
50*45818ee1SMatthew Ahrens #define	EdonR224_DIGEST_SIZE	28
51*45818ee1SMatthew Ahrens #define	EdonR224_BLOCK_SIZE	64
52*45818ee1SMatthew Ahrens #define	EdonR256_DIGEST_SIZE	32
53*45818ee1SMatthew Ahrens #define	EdonR256_BLOCK_SIZE	64
54*45818ee1SMatthew Ahrens #define	EdonR384_DIGEST_SIZE	48
55*45818ee1SMatthew Ahrens #define	EdonR384_BLOCK_SIZE	128
56*45818ee1SMatthew Ahrens #define	EdonR512_DIGEST_SIZE	64
57*45818ee1SMatthew Ahrens #define	EdonR512_BLOCK_SIZE	128
58*45818ee1SMatthew Ahrens 
59*45818ee1SMatthew Ahrens #define	EdonR256_BLOCK_BITSIZE	512
60*45818ee1SMatthew Ahrens #define	EdonR512_BLOCK_BITSIZE	1024
61*45818ee1SMatthew Ahrens 
62*45818ee1SMatthew Ahrens typedef struct {
63*45818ee1SMatthew Ahrens 	uint32_t DoublePipe[16];
64*45818ee1SMatthew Ahrens 	uint8_t LastPart[EdonR256_BLOCK_SIZE * 2];
65*45818ee1SMatthew Ahrens } EdonRData256;
66*45818ee1SMatthew Ahrens typedef struct {
67*45818ee1SMatthew Ahrens 	uint64_t DoublePipe[16];
68*45818ee1SMatthew Ahrens 	uint8_t LastPart[EdonR512_BLOCK_SIZE * 2];
69*45818ee1SMatthew Ahrens } EdonRData512;
70*45818ee1SMatthew Ahrens 
71*45818ee1SMatthew Ahrens typedef struct {
72*45818ee1SMatthew Ahrens 	size_t hashbitlen;
73*45818ee1SMatthew Ahrens 
74*45818ee1SMatthew Ahrens 	/* + algorithm specific parameters */
75*45818ee1SMatthew Ahrens 	int unprocessed_bits;
76*45818ee1SMatthew Ahrens 	uint64_t bits_processed;
77*45818ee1SMatthew Ahrens 	union {
78*45818ee1SMatthew Ahrens 		EdonRData256 p256[1];
79*45818ee1SMatthew Ahrens 		EdonRData512 p512[1];
80*45818ee1SMatthew Ahrens 	} pipe[1];
81*45818ee1SMatthew Ahrens } EdonRState;
82*45818ee1SMatthew Ahrens 
83*45818ee1SMatthew Ahrens void EdonRInit(EdonRState *state, size_t hashbitlen);
84*45818ee1SMatthew Ahrens void EdonRUpdate(EdonRState *state, const uint8_t *data, size_t databitlen);
85*45818ee1SMatthew Ahrens void EdonRFinal(EdonRState *state, uint8_t *hashval);
86*45818ee1SMatthew Ahrens void EdonRHash(size_t hashbitlen, const uint8_t *data, size_t databitlen,
87*45818ee1SMatthew Ahrens     uint8_t *hashval);
88*45818ee1SMatthew Ahrens 
89*45818ee1SMatthew Ahrens #ifdef	__cplusplus
90*45818ee1SMatthew Ahrens }
91*45818ee1SMatthew Ahrens #endif
92*45818ee1SMatthew Ahrens 
93*45818ee1SMatthew Ahrens #endif	/* _SYS_EDONR_H_ */
94