xref: /freebsd/sys/contrib/openzfs/module/icp/algs/edonr/edonr.c (revision 2a58b312b62f908ec92311d1bd8536dbaeb8e55b)
1eda14cbcSMatt Macy /*
2eda14cbcSMatt Macy  * CDDL HEADER START
3eda14cbcSMatt Macy  *
4eda14cbcSMatt Macy  * The contents of this file are subject to the terms of the
5eda14cbcSMatt Macy  * Common Development and Distribution License (the "License").
6eda14cbcSMatt Macy  * You may not use this file except in compliance with the License.
7eda14cbcSMatt Macy  *
8eda14cbcSMatt Macy  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9eda14cbcSMatt Macy  * or http://opensource.org/licenses/CDDL-1.0.
10eda14cbcSMatt Macy  * See the License for the specific language governing permissions
11eda14cbcSMatt Macy  * and limitations under the License.
12eda14cbcSMatt Macy  *
13eda14cbcSMatt Macy  * When distributing Covered Code, include this CDDL HEADER in each
14eda14cbcSMatt Macy  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15eda14cbcSMatt Macy  * If applicable, add the following below this CDDL HEADER, with the
16eda14cbcSMatt Macy  * fields enclosed by brackets "[]" replaced with your own identifying
17eda14cbcSMatt Macy  * information: Portions Copyright [yyyy] [name of copyright owner]
18eda14cbcSMatt Macy  *
19eda14cbcSMatt Macy  * CDDL HEADER END
20eda14cbcSMatt Macy  */
21eda14cbcSMatt Macy 
22e92ffd9bSMartin Matuska /*
23*2a58b312SMartin Matuska  * Based on Edon-R implementation for SUPERCOP, based on NIST API.
24*2a58b312SMartin Matuska  * Copyright (c) 2009, 2010, Jørn Amundsen <jorn.amundsen@ntnu.no>
25*2a58b312SMartin Matuska  * Copyright (c) 2013 Saso Kiselkov, All rights reserved
26*2a58b312SMartin Matuska  * Copyright (c) 2023 Tino Reichardt <milky-zfs@mcmilk.de>
27e92ffd9bSMartin Matuska  */
28e92ffd9bSMartin Matuska 
29*2a58b312SMartin Matuska #include <sys/zfs_context.h>
30da5137abSMartin Matuska #include <sys/string.h>
31eda14cbcSMatt Macy #include <sys/edonr.h>
32eda14cbcSMatt Macy 
33*2a58b312SMartin Matuska /*
34*2a58b312SMartin Matuska  * We need 1196 byte stack for Q512() on i386
35*2a58b312SMartin Matuska  * - we define this pragma to make gcc happy
36*2a58b312SMartin Matuska  */
37*2a58b312SMartin Matuska #if defined(__GNUC__) && defined(_ILP32)
38*2a58b312SMartin Matuska #pragma GCC diagnostic ignored "-Wframe-larger-than="
39*2a58b312SMartin Matuska #endif
40eda14cbcSMatt Macy 
41*2a58b312SMartin Matuska /*
42*2a58b312SMartin Matuska  * Insert compiler memory barriers to reduce stack frame size.
43*2a58b312SMartin Matuska  */
44*2a58b312SMartin Matuska #define	MEMORY_BARRIER   asm volatile("" ::: "memory");
45*2a58b312SMartin Matuska 
46*2a58b312SMartin Matuska #if defined(_ZFS_BIG_ENDIAN)
47*2a58b312SMartin Matuska #define	ld_swap64(s, d) (d = __builtin_bswap64(*(s)))
48*2a58b312SMartin Matuska #define	st_swap64(s, d) (*(d) = __builtin_bswap64(s))
49*2a58b312SMartin Matuska #else
50*2a58b312SMartin Matuska #define	ld_swap64(s, d) (d = *(s))
51*2a58b312SMartin Matuska #define	st_swap64(s, d) (*(d) = s)
52*2a58b312SMartin Matuska #endif
53*2a58b312SMartin Matuska 
54eda14cbcSMatt Macy #define	hashState512(x)	((x)->pipe->p512)
55eda14cbcSMatt Macy 
56716fd348SMartin Matuska /* rotate shortcuts */
57eda14cbcSMatt Macy #define	rotl64(x, n)	(((x) << (n)) | ((x) >> (64 - (n))))
58eda14cbcSMatt Macy 
59eda14cbcSMatt Macy /* EdonR512 initial double chaining pipe */
60eda14cbcSMatt Macy static const uint64_t i512p2[16] = {
61eda14cbcSMatt Macy 	0x8081828384858687ull, 0x88898a8b8c8d8e8full,
62eda14cbcSMatt Macy 	0x9091929394959697ull, 0x98999a9b9c9d9e9full,
63eda14cbcSMatt Macy 	0xa0a1a2a3a4a5a6a7ull, 0xa8a9aaabacadaeafull,
64eda14cbcSMatt Macy 	0xb0b1b2b3b4b5b6b7ull, 0xb8b9babbbcbdbebfull,
65eda14cbcSMatt Macy 	0xc0c1c2c3c4c5c6c7ull, 0xc8c9cacbcccdcecfull,
66eda14cbcSMatt Macy 	0xd0d1d2d3d4d5d6d7ull, 0xd8d9dadbdcdddedfull,
67eda14cbcSMatt Macy 	0xe0e1e2e3e4e5e6e7ull, 0xe8e9eaebecedeeefull,
68eda14cbcSMatt Macy 	0xf0f1f2f3f4f5f6f7ull, 0xf8f9fafbfcfdfeffull
69eda14cbcSMatt Macy };
70eda14cbcSMatt Macy 
71*2a58b312SMartin Matuska #define	LS1_512(x0, x1, x2, x3, x4, x5, x6, x7)		\
72eda14cbcSMatt Macy {							\
73*2a58b312SMartin Matuska 	MEMORY_BARRIER					\
74*2a58b312SMartin Matuska 	z1 = x0 + x4, z2 = x1 + x7; z5 = z1 + z2;	\
75*2a58b312SMartin Matuska 	s0 = 0xaaaaaaaaaaaaaaaaull + z5 + x2;		\
76*2a58b312SMartin Matuska 	s1 = rotl64(z5 + x3, 5);			\
77*2a58b312SMartin Matuska 	s2 = rotl64(z5 + x6, 15); z3 = x2 + x3;		\
78*2a58b312SMartin Matuska 	s5 = rotl64(z1 + z3 + x5, 40); z4 = x5 + x6;	\
79*2a58b312SMartin Matuska 	s6 = rotl64(z2 + z4 + x0, 50); z6 = z3 + z4;	\
80*2a58b312SMartin Matuska 	s3 = rotl64(z6 + x7, 22);			\
81*2a58b312SMartin Matuska 	s4 = rotl64(z6 + x1, 31);			\
82*2a58b312SMartin Matuska 	s7 = rotl64(z6 + x4, 59);			\
83eda14cbcSMatt Macy }
84eda14cbcSMatt Macy 
85*2a58b312SMartin Matuska #define	LS2_512(y0, y1, y2, y3, y4, y5, y6, y7)		\
86eda14cbcSMatt Macy {							\
87*2a58b312SMartin Matuska 	z1 = y0 + y1, z2 = y2 + y5; z6 = z1 + z2;	\
88*2a58b312SMartin Matuska 	t0  = ~0xaaaaaaaaaaaaaaaaull + z6 + y7;		\
89*2a58b312SMartin Matuska 	t2 = rotl64(z6 + y3, 19);			\
90*2a58b312SMartin Matuska 	z3 = y3 + y4, z5 = z1 + z3;			\
91*2a58b312SMartin Matuska 	t1 = rotl64(z5 + y6, 10);			\
92*2a58b312SMartin Matuska 	t4 = rotl64(z5 + y5, 36);			\
93*2a58b312SMartin Matuska 	z4 = y6 + y7, z8 = z3 + z4;			\
94*2a58b312SMartin Matuska 	t3 = rotl64(z8 + y2, 29);			\
95*2a58b312SMartin Matuska 	t7 = rotl64(z8 + y0, 55); z7 = z2 + z4;		\
96*2a58b312SMartin Matuska 	t5 = rotl64(z7 + y4, 44);			\
97*2a58b312SMartin Matuska 	t6 = rotl64(z7 + y1, 48);			\
98eda14cbcSMatt Macy }
99eda14cbcSMatt Macy 
100*2a58b312SMartin Matuska #define	QEF_512(r0, r1, r2, r3, r4, r5, r6, r7)		\
101eda14cbcSMatt Macy {							\
102*2a58b312SMartin Matuska 	z1 = s0 ^ s4, z5 = t0 ^ t1;			\
103*2a58b312SMartin Matuska 	r0 = (z1 ^ s1) + (z5 ^ t5); z8 = t6 ^ t7;	\
104*2a58b312SMartin Matuska 	r1 = (z1 ^ s7) + (t2 ^ z8); z3 = s2 ^ s3;	\
105*2a58b312SMartin Matuska 	r7 = (z3 ^ s5) + (t4 ^ z8); z7 = t3 ^ t4;	\
106*2a58b312SMartin Matuska 	r3 = (z3 ^ s4) + (t0 ^ z7); z4 = s5 ^ s6;	\
107*2a58b312SMartin Matuska 	r5 = (s3 ^ z4) + (z7 ^ t6); z6 = t2 ^ t5;	\
108*2a58b312SMartin Matuska 	r6 = (s2 ^ z4) + (z6 ^ t7); z2 = s1 ^ s7;	\
109*2a58b312SMartin Matuska 	r4 = (s0 ^ z2) + (t1 ^ z6);			\
110*2a58b312SMartin Matuska 	r2 = (z2 ^ s6) + (z5 ^ t3);			\
111eda14cbcSMatt Macy }
112eda14cbcSMatt Macy 
113eda14cbcSMatt Macy static inline size_t
Q512(size_t bitlen,const uint64_t * data,uint64_t * p)114*2a58b312SMartin Matuska Q512(size_t bitlen, const uint64_t *data, uint64_t *p)
115eda14cbcSMatt Macy {
116eda14cbcSMatt Macy 	size_t bl;
117eda14cbcSMatt Macy 
118eda14cbcSMatt Macy 	for (bl = bitlen; bl >= EdonR512_BLOCK_BITSIZE;
119eda14cbcSMatt Macy 	    bl -= EdonR512_BLOCK_BITSIZE, data += 16) {
120*2a58b312SMartin Matuska 		uint64_t q0, q1, q2, q3, q4, q5, q6, q7;
121*2a58b312SMartin Matuska 		uint64_t p0, p1, p2, p3, p4, p5, p6, p7;
122*2a58b312SMartin Matuska 		uint64_t s0, s1, s2, s3, s4, s5, s6, s7;
123*2a58b312SMartin Matuska 		uint64_t t0, t1, t2, t3, t4, t5, t6, t7;
124*2a58b312SMartin Matuska 		uint64_t z1, z2, z3, z4, z5, z6, z7, z8;
125*2a58b312SMartin Matuska 
126*2a58b312SMartin Matuska #if defined(_ZFS_BIG_ENDIAN)
127*2a58b312SMartin Matuska 		uint64_t swp0, swp1, swp2, swp3, swp4, swp5, swp6, swp7,
128*2a58b312SMartin Matuska 		    swp8, swp9, swp10, swp11, swp12, swp13, swp14, swp15;
129eda14cbcSMatt Macy #define	d(j)	swp##j
130eda14cbcSMatt Macy #define	s64(j)	ld_swap64((uint64_t *)data+j, swp##j)
131eda14cbcSMatt Macy 		s64(0);
132eda14cbcSMatt Macy 		s64(1);
133eda14cbcSMatt Macy 		s64(2);
134eda14cbcSMatt Macy 		s64(3);
135eda14cbcSMatt Macy 		s64(4);
136eda14cbcSMatt Macy 		s64(5);
137eda14cbcSMatt Macy 		s64(6);
138eda14cbcSMatt Macy 		s64(7);
139*2a58b312SMartin Matuska 		s64(8);
140*2a58b312SMartin Matuska 		s64(9);
141*2a58b312SMartin Matuska 		s64(10);
142*2a58b312SMartin Matuska 		s64(11);
143*2a58b312SMartin Matuska 		s64(12);
144*2a58b312SMartin Matuska 		s64(13);
145*2a58b312SMartin Matuska 		s64(14);
146*2a58b312SMartin Matuska 		s64(15);
147*2a58b312SMartin Matuska #else
148*2a58b312SMartin Matuska #define	d(j)	data[j]
149eda14cbcSMatt Macy #endif
150eda14cbcSMatt Macy 
151*2a58b312SMartin Matuska 		/* First row of quasigroup e-transformations */
152*2a58b312SMartin Matuska 		LS1_512(d(15), d(14), d(13), d(12), d(11), d(10), d(9), d(8));
153*2a58b312SMartin Matuska 		LS2_512(d(0), d(1), d(2), d(3), d(4), d(5), d(6), d(7));
154*2a58b312SMartin Matuska 		QEF_512(p0, p1, p2, p3, p4, p5, p6, p7);
155*2a58b312SMartin Matuska 
156*2a58b312SMartin Matuska 		LS1_512(p0, p1, p2, p3, p4, p5, p6, p7);
157*2a58b312SMartin Matuska 		LS2_512(d(8), d(9), d(10), d(11), d(12), d(13), d(14), d(15));
158*2a58b312SMartin Matuska 		QEF_512(q0, q1, q2, q3, q4, q5, q6, q7);
159eda14cbcSMatt Macy 
160eda14cbcSMatt Macy 		/* Second row of quasigroup e-transformations */
161*2a58b312SMartin Matuska 		LS1_512(p[8], p[9], p[10], p[11], p[12], p[13], p[14], p[15]);
162*2a58b312SMartin Matuska 		LS2_512(p0, p1, p2, p3, p4, p5, p6, p7);
163*2a58b312SMartin Matuska 		QEF_512(p0, p1, p2, p3, p4, p5, p6, p7);
164eda14cbcSMatt Macy 
165*2a58b312SMartin Matuska 		LS1_512(p0, p1, p2, p3, p4, p5, p6, p7);
166*2a58b312SMartin Matuska 		LS2_512(q0, q1, q2, q3, q4, q5, q6, q7);
167*2a58b312SMartin Matuska 		QEF_512(q0, q1, q2, q3, q4, q5, q6, q7);
168eda14cbcSMatt Macy 
169eda14cbcSMatt Macy 		/* Third row of quasigroup e-transformations */
170*2a58b312SMartin Matuska 		LS1_512(p0, p1, p2, p3, p4, p5, p6, p7);
171*2a58b312SMartin Matuska 		LS2_512(p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7]);
172*2a58b312SMartin Matuska 		QEF_512(p0, p1, p2, p3, p4, p5, p6, p7);
173eda14cbcSMatt Macy 
174*2a58b312SMartin Matuska 		LS1_512(q0, q1, q2, q3, q4, q5, q6, q7);
175*2a58b312SMartin Matuska 		LS2_512(p0, p1, p2, p3, p4, p5, p6, p7);
176*2a58b312SMartin Matuska 		QEF_512(q0, q1, q2, q3, q4, q5, q6, q7);
177eda14cbcSMatt Macy 
178eda14cbcSMatt Macy 		/* Fourth row of quasigroup e-transformations */
179*2a58b312SMartin Matuska 		LS1_512(d(7), d(6), d(5), d(4), d(3), d(2), d(1), d(0));
180*2a58b312SMartin Matuska 		LS2_512(p0, p1, p2, p3, p4, p5, p6, p7);
181*2a58b312SMartin Matuska 		QEF_512(p0, p1, p2, p3, p4, p5, p6, p7);
182eda14cbcSMatt Macy 
183*2a58b312SMartin Matuska 		LS1_512(p0, p1, p2, p3, p4, p5, p6, p7);
184*2a58b312SMartin Matuska 		LS2_512(q0, q1, q2, q3, q4, q5, q6, q7);
185*2a58b312SMartin Matuska 		QEF_512(q0, q1, q2, q3, q4, q5, q6, q7);
186eda14cbcSMatt Macy 
187eda14cbcSMatt Macy 		/* Edon-R tweak on the original SHA-3 Edon-R submission. */
188eda14cbcSMatt Macy 		p[0] ^= d(8) ^ p0;
189eda14cbcSMatt Macy 		p[1] ^= d(9) ^ p1;
190eda14cbcSMatt Macy 		p[2] ^= d(10) ^ p2;
191eda14cbcSMatt Macy 		p[3] ^= d(11) ^ p3;
192eda14cbcSMatt Macy 		p[4] ^= d(12) ^ p4;
193eda14cbcSMatt Macy 		p[5] ^= d(13) ^ p5;
194eda14cbcSMatt Macy 		p[6] ^= d(14) ^ p6;
195eda14cbcSMatt Macy 		p[7] ^= d(15) ^ p7;
196eda14cbcSMatt Macy 		p[8] ^= d(0) ^ q0;
197eda14cbcSMatt Macy 		p[9] ^= d(1) ^ q1;
198eda14cbcSMatt Macy 		p[10] ^= d(2) ^ q2;
199eda14cbcSMatt Macy 		p[11] ^= d(3) ^ q3;
200eda14cbcSMatt Macy 		p[12] ^= d(4) ^ q4;
201eda14cbcSMatt Macy 		p[13] ^= d(5) ^ q5;
202eda14cbcSMatt Macy 		p[14] ^= d(6) ^ q6;
203eda14cbcSMatt Macy 		p[15] ^= d(7) ^ q7;
204eda14cbcSMatt Macy 	}
205eda14cbcSMatt Macy 
206*2a58b312SMartin Matuska #undef s64
207eda14cbcSMatt Macy #undef d
208eda14cbcSMatt Macy 	return (bitlen - bl);
209eda14cbcSMatt Macy }
210eda14cbcSMatt Macy 
211eda14cbcSMatt Macy void
EdonRInit(EdonRState * state)212*2a58b312SMartin Matuska EdonRInit(EdonRState *state)
213eda14cbcSMatt Macy {
214eda14cbcSMatt Macy 	state->bits_processed = 0;
215eda14cbcSMatt Macy 	state->unprocessed_bits = 0;
216*2a58b312SMartin Matuska 	memcpy(hashState512(state)->DoublePipe, i512p2, sizeof (i512p2));
217eda14cbcSMatt Macy }
218eda14cbcSMatt Macy 
219eda14cbcSMatt Macy void
EdonRUpdate(EdonRState * state,const uint8_t * data,size_t databitlen)220eda14cbcSMatt Macy EdonRUpdate(EdonRState *state, const uint8_t *data, size_t databitlen)
221eda14cbcSMatt Macy {
222eda14cbcSMatt Macy 	uint64_t *data64;
223eda14cbcSMatt Macy 	size_t bits_processed;
224eda14cbcSMatt Macy 
225eda14cbcSMatt Macy 	if (state->unprocessed_bits > 0) {
226eda14cbcSMatt Macy 		/* LastBytes = databitlen / 8 */
227eda14cbcSMatt Macy 		int LastBytes = (int)databitlen >> 3;
228eda14cbcSMatt Macy 
229eda14cbcSMatt Macy 		ASSERT(state->unprocessed_bits + databitlen <=
230eda14cbcSMatt Macy 		    EdonR512_BLOCK_SIZE * 8);
231eda14cbcSMatt Macy 
232da5137abSMartin Matuska 		memcpy(hashState512(state)->LastPart
233*2a58b312SMartin Matuska 		    + (state->unprocessed_bits >> 3), data, LastBytes);
234eda14cbcSMatt Macy 		state->unprocessed_bits += (int)databitlen;
235eda14cbcSMatt Macy 		databitlen = state->unprocessed_bits;
236eda14cbcSMatt Macy 		/* LINTED E_BAD_PTR_CAST_ALIGN */
237eda14cbcSMatt Macy 		data64 = (uint64_t *)hashState512(state)->LastPart;
238eda14cbcSMatt Macy 	} else
239eda14cbcSMatt Macy 		/* LINTED E_BAD_PTR_CAST_ALIGN */
240eda14cbcSMatt Macy 		data64 = (uint64_t *)data;
241eda14cbcSMatt Macy 
242eda14cbcSMatt Macy 	bits_processed = Q512(databitlen, data64,
243eda14cbcSMatt Macy 	    hashState512(state)->DoublePipe);
244eda14cbcSMatt Macy 	state->bits_processed += bits_processed;
245eda14cbcSMatt Macy 	databitlen -= bits_processed;
246eda14cbcSMatt Macy 	state->unprocessed_bits = (int)databitlen;
247eda14cbcSMatt Macy 	if (databitlen > 0) {
248eda14cbcSMatt Macy 		/* LastBytes = Ceil(databitlen / 8) */
249*2a58b312SMartin Matuska 		int LastBytes = ((~(((-(int)databitlen) >> 3) & 0x03ff)) + 1) \
250*2a58b312SMartin Matuska 		    & 0x03ff;
251eda14cbcSMatt Macy 
252eda14cbcSMatt Macy 		data64 += bits_processed >> 6;	/* byte size update */
253*2a58b312SMartin Matuska 		memmove(hashState512(state)->LastPart, data64, LastBytes);
254eda14cbcSMatt Macy 	}
255eda14cbcSMatt Macy }
256eda14cbcSMatt Macy 
257eda14cbcSMatt Macy void
EdonRFinal(EdonRState * state,uint8_t * hashval)258eda14cbcSMatt Macy EdonRFinal(EdonRState *state, uint8_t *hashval)
259eda14cbcSMatt Macy {
260eda14cbcSMatt Macy 	uint64_t *data64, num_bits;
261eda14cbcSMatt Macy 	size_t databitlen;
262eda14cbcSMatt Macy 	int LastByte, PadOnePosition;
263eda14cbcSMatt Macy 
264eda14cbcSMatt Macy 	num_bits = state->bits_processed + state->unprocessed_bits;
265eda14cbcSMatt Macy 	LastByte = (int)state->unprocessed_bits >> 3;
266eda14cbcSMatt Macy 	PadOnePosition = 7 - (state->unprocessed_bits & 0x07);
267eda14cbcSMatt Macy 	hashState512(state)->LastPart[LastByte] =
268*2a58b312SMartin Matuska 	    (hashState512(state)->LastPart[LastByte] \
269*2a58b312SMartin Matuska 	    & (0xff << (PadOnePosition + 1))) ^ (0x01 << PadOnePosition);
270eda14cbcSMatt Macy 	/* LINTED E_BAD_PTR_CAST_ALIGN */
271eda14cbcSMatt Macy 	data64 = (uint64_t *)hashState512(state)->LastPart;
272eda14cbcSMatt Macy 
273eda14cbcSMatt Macy 	if (state->unprocessed_bits < 960) {
274*2a58b312SMartin Matuska 		memset((hashState512(state)->LastPart) +
275*2a58b312SMartin Matuska 		    LastByte + 1, 0x00, EdonR512_BLOCK_SIZE - LastByte - 9);
276eda14cbcSMatt Macy 		databitlen = EdonR512_BLOCK_SIZE * 8;
277*2a58b312SMartin Matuska #if defined(_ZFS_BIG_ENDIAN)
278eda14cbcSMatt Macy 		st_swap64(num_bits, data64 + 15);
279eda14cbcSMatt Macy #else
280eda14cbcSMatt Macy 		data64[15] = num_bits;
281eda14cbcSMatt Macy #endif
282eda14cbcSMatt Macy 	} else {
283*2a58b312SMartin Matuska 		memset((hashState512(state)->LastPart) + LastByte + 1,
284*2a58b312SMartin Matuska 		    0x00, EdonR512_BLOCK_SIZE * 2 - LastByte - 9);
285eda14cbcSMatt Macy 		databitlen = EdonR512_BLOCK_SIZE * 16;
286*2a58b312SMartin Matuska #if defined(_ZFS_BIG_ENDIAN)
287eda14cbcSMatt Macy 		st_swap64(num_bits, data64 + 31);
288eda14cbcSMatt Macy #else
289eda14cbcSMatt Macy 		data64[31] = num_bits;
290eda14cbcSMatt Macy #endif
291eda14cbcSMatt Macy 	}
292eda14cbcSMatt Macy 
293eda14cbcSMatt Macy 	state->bits_processed += Q512(databitlen, data64,
294eda14cbcSMatt Macy 	    hashState512(state)->DoublePipe);
295eda14cbcSMatt Macy 
296*2a58b312SMartin Matuska #if defined(_ZFS_BIG_ENDIAN)
297*2a58b312SMartin Matuska 	data64 = (uint64_t *)hashval;
298eda14cbcSMatt Macy 	uint64_t *s64 = hashState512(state)->DoublePipe + 8;
299eda14cbcSMatt Macy 	int j;
300eda14cbcSMatt Macy 
301eda14cbcSMatt Macy 	for (j = 0; j < EdonR512_DIGEST_SIZE >> 3; j++)
302*2a58b312SMartin Matuska 		st_swap64(s64[j], data64 + j);
303eda14cbcSMatt Macy #else
304da5137abSMartin Matuska 	memcpy(hashval, hashState512(state)->DoublePipe + 8,
305eda14cbcSMatt Macy 	    EdonR512_DIGEST_SIZE);
306eda14cbcSMatt Macy #endif
307eda14cbcSMatt Macy }
308eda14cbcSMatt Macy 
309eda14cbcSMatt Macy void
EdonRHash(const uint8_t * data,size_t databitlen,uint8_t * hashval)310*2a58b312SMartin Matuska EdonRHash(const uint8_t *data, size_t databitlen, uint8_t *hashval)
311eda14cbcSMatt Macy {
312eda14cbcSMatt Macy 	EdonRState state;
313eda14cbcSMatt Macy 
314*2a58b312SMartin Matuska 	EdonRInit(&state);
315eda14cbcSMatt Macy 	EdonRUpdate(&state, data, databitlen);
316eda14cbcSMatt Macy 	EdonRFinal(&state, hashval);
317eda14cbcSMatt Macy }
318eda14cbcSMatt Macy 
319eda14cbcSMatt Macy #ifdef _KERNEL
320eda14cbcSMatt Macy EXPORT_SYMBOL(EdonRInit);
321eda14cbcSMatt Macy EXPORT_SYMBOL(EdonRUpdate);
322eda14cbcSMatt Macy EXPORT_SYMBOL(EdonRHash);
323eda14cbcSMatt Macy EXPORT_SYMBOL(EdonRFinal);
324eda14cbcSMatt Macy #endif
325