1*f0865ec9SKyle Evans /*
2*f0865ec9SKyle Evans * Copyright (C) 2017 - This file is part of libecc project
3*f0865ec9SKyle Evans *
4*f0865ec9SKyle Evans * Authors:
5*f0865ec9SKyle Evans * Ryad BENADJILA <ryadbenadjila@gmail.com>
6*f0865ec9SKyle Evans * Arnaud EBALARD <arnaud.ebalard@ssi.gouv.fr>
7*f0865ec9SKyle Evans * Jean-Pierre FLORI <jean-pierre.flori@ssi.gouv.fr>
8*f0865ec9SKyle Evans *
9*f0865ec9SKyle Evans * Contributors:
10*f0865ec9SKyle Evans * Nicolas VIVET <nicolas.vivet@ssi.gouv.fr>
11*f0865ec9SKyle Evans * Karim KHALFALLAH <karim.khalfallah@ssi.gouv.fr>
12*f0865ec9SKyle Evans *
13*f0865ec9SKyle Evans * This software is licensed under a dual BSD and GPL v2 license.
14*f0865ec9SKyle Evans * See LICENSE file at the root folder of the project.
15*f0865ec9SKyle Evans */
16*f0865ec9SKyle Evans #include <libecc/hash/hash_algs.h>
17*f0865ec9SKyle Evans
18*f0865ec9SKyle Evans /*
19*f0865ec9SKyle Evans * Return the hash mapping entry 'hm' associated with given hash name
20*f0865ec9SKyle Evans * 'hash_name'. The function returns 0 on success, -1 on error. 'hm'
21*f0865ec9SKyle Evans * is only meaningful on success.
22*f0865ec9SKyle Evans */
get_hash_by_name(const char * hash_name,const hash_mapping ** hm)23*f0865ec9SKyle Evans ATTRIBUTE_WARN_UNUSED_RET int get_hash_by_name(const char *hash_name, const hash_mapping **hm)
24*f0865ec9SKyle Evans {
25*f0865ec9SKyle Evans const hash_mapping *_hm = NULL;
26*f0865ec9SKyle Evans int ret, check;
27*f0865ec9SKyle Evans u8 i;
28*f0865ec9SKyle Evans
29*f0865ec9SKyle Evans MUST_HAVE(((hash_name != NULL) && (hm != NULL)), ret, err);
30*f0865ec9SKyle Evans
31*f0865ec9SKyle Evans ret = -1;
32*f0865ec9SKyle Evans for (i = 0, _hm = &hash_maps[i]; _hm->type != UNKNOWN_HASH_ALG;
33*f0865ec9SKyle Evans _hm = &hash_maps[++i]) {
34*f0865ec9SKyle Evans const char *exp_name = (const char *)_hm->name;
35*f0865ec9SKyle Evans
36*f0865ec9SKyle Evans if ((!are_str_equal(hash_name, exp_name, &check)) && check) {
37*f0865ec9SKyle Evans (*hm) = _hm;
38*f0865ec9SKyle Evans ret = 0;
39*f0865ec9SKyle Evans break;
40*f0865ec9SKyle Evans }
41*f0865ec9SKyle Evans }
42*f0865ec9SKyle Evans
43*f0865ec9SKyle Evans err:
44*f0865ec9SKyle Evans return ret;
45*f0865ec9SKyle Evans }
46*f0865ec9SKyle Evans
47*f0865ec9SKyle Evans /*
48*f0865ec9SKyle Evans * Return the hash mapping entry 'hm' associated with given hash type value.
49*f0865ec9SKyle Evans * The function returns 0 on success, -1 on error. 'hm' is not meaningfull
50*f0865ec9SKyle Evans * on error.
51*f0865ec9SKyle Evans */
get_hash_by_type(hash_alg_type hash_type,const hash_mapping ** hm)52*f0865ec9SKyle Evans ATTRIBUTE_WARN_UNUSED_RET int get_hash_by_type(hash_alg_type hash_type, const hash_mapping **hm)
53*f0865ec9SKyle Evans {
54*f0865ec9SKyle Evans const hash_mapping *_hm = NULL;
55*f0865ec9SKyle Evans int ret;
56*f0865ec9SKyle Evans u8 i;
57*f0865ec9SKyle Evans
58*f0865ec9SKyle Evans MUST_HAVE((hm != NULL), ret, err);
59*f0865ec9SKyle Evans
60*f0865ec9SKyle Evans ret = -1;
61*f0865ec9SKyle Evans for (i = 0, _hm = &hash_maps[i]; _hm->type != UNKNOWN_HASH_ALG;
62*f0865ec9SKyle Evans _hm = &hash_maps[++i]) {
63*f0865ec9SKyle Evans if (_hm->type == hash_type) {
64*f0865ec9SKyle Evans (*hm) = _hm;
65*f0865ec9SKyle Evans ret = 0;
66*f0865ec9SKyle Evans break;
67*f0865ec9SKyle Evans }
68*f0865ec9SKyle Evans }
69*f0865ec9SKyle Evans
70*f0865ec9SKyle Evans err:
71*f0865ec9SKyle Evans return ret;
72*f0865ec9SKyle Evans }
73*f0865ec9SKyle Evans
74*f0865ec9SKyle Evans /*
75*f0865ec9SKyle Evans * Returns respectively in digest_size and block_size param the digest size
76*f0865ec9SKyle Evans * and block size for given hash function, if return value of the function is 0.
77*f0865ec9SKyle Evans * If return value is -1, then the hash algorithm is not known and output
78*f0865ec9SKyle Evans * parameters are not modified.
79*f0865ec9SKyle Evans */
get_hash_sizes(hash_alg_type hash_type,u8 * digest_size,u8 * block_size)80*f0865ec9SKyle Evans ATTRIBUTE_WARN_UNUSED_RET int get_hash_sizes(hash_alg_type hash_type, u8 *digest_size, u8 *block_size)
81*f0865ec9SKyle Evans {
82*f0865ec9SKyle Evans const hash_mapping *m;
83*f0865ec9SKyle Evans int ret;
84*f0865ec9SKyle Evans u8 i;
85*f0865ec9SKyle Evans
86*f0865ec9SKyle Evans ret = -1;
87*f0865ec9SKyle Evans for (i = 0, m = &hash_maps[i]; m->type != UNKNOWN_HASH_ALG;
88*f0865ec9SKyle Evans m = &hash_maps[++i]) {
89*f0865ec9SKyle Evans if (m->type == hash_type) {
90*f0865ec9SKyle Evans if (digest_size != NULL) {
91*f0865ec9SKyle Evans (*digest_size) = m->digest_size;
92*f0865ec9SKyle Evans }
93*f0865ec9SKyle Evans if (block_size != NULL) {
94*f0865ec9SKyle Evans (*block_size) = m->block_size;
95*f0865ec9SKyle Evans }
96*f0865ec9SKyle Evans ret = 0;
97*f0865ec9SKyle Evans break;
98*f0865ec9SKyle Evans }
99*f0865ec9SKyle Evans }
100*f0865ec9SKyle Evans
101*f0865ec9SKyle Evans return ret;
102*f0865ec9SKyle Evans }
103*f0865ec9SKyle Evans
104*f0865ec9SKyle Evans /*
105*f0865ec9SKyle Evans * Helper that sanity checks the provided hash mapping against our
106*f0865ec9SKyle Evans * constant ones. Returns 0 on success, -1 on error.
107*f0865ec9SKyle Evans */
hash_mapping_callbacks_sanity_check(const hash_mapping * h)108*f0865ec9SKyle Evans ATTRIBUTE_WARN_UNUSED_RET int hash_mapping_callbacks_sanity_check(const hash_mapping *h)
109*f0865ec9SKyle Evans {
110*f0865ec9SKyle Evans const hash_mapping *m;
111*f0865ec9SKyle Evans int ret = -1, check;
112*f0865ec9SKyle Evans u8 i;
113*f0865ec9SKyle Evans
114*f0865ec9SKyle Evans MUST_HAVE((h != NULL), ret, err);
115*f0865ec9SKyle Evans
116*f0865ec9SKyle Evans /* We just check is our mapping is indeed
117*f0865ec9SKyle Evans * one of the registered mappings.
118*f0865ec9SKyle Evans */
119*f0865ec9SKyle Evans for (i = 0, m = &hash_maps[i]; m->type != UNKNOWN_HASH_ALG;
120*f0865ec9SKyle Evans m = &hash_maps[++i]) {
121*f0865ec9SKyle Evans if (m->type == h->type) {
122*f0865ec9SKyle Evans if ((!are_str_equal_nlen(m->name, h->name, MAX_HASH_ALG_NAME_LEN, &check)) && (!check)){
123*f0865ec9SKyle Evans goto err;
124*f0865ec9SKyle Evans } else if (m->digest_size != h->digest_size) {
125*f0865ec9SKyle Evans goto err;
126*f0865ec9SKyle Evans } else if(m->block_size != h->block_size) {
127*f0865ec9SKyle Evans goto err;
128*f0865ec9SKyle Evans } else if(m->hfunc_init != h->hfunc_init) {
129*f0865ec9SKyle Evans goto err;
130*f0865ec9SKyle Evans } else if(m->hfunc_update != h->hfunc_update) {
131*f0865ec9SKyle Evans goto err;
132*f0865ec9SKyle Evans } else if(m->hfunc_finalize != h->hfunc_finalize) {
133*f0865ec9SKyle Evans goto err;
134*f0865ec9SKyle Evans } else if(m->hfunc_scattered != h->hfunc_scattered) {
135*f0865ec9SKyle Evans goto err;
136*f0865ec9SKyle Evans } else{
137*f0865ec9SKyle Evans ret = 0;
138*f0865ec9SKyle Evans }
139*f0865ec9SKyle Evans }
140*f0865ec9SKyle Evans }
141*f0865ec9SKyle Evans
142*f0865ec9SKyle Evans err:
143*f0865ec9SKyle Evans return ret;
144*f0865ec9SKyle Evans }
145*f0865ec9SKyle Evans
146*f0865ec9SKyle Evans /*****************************************/
147*f0865ec9SKyle Evans /* Trampolines to each specific function to
148*f0865ec9SKyle Evans * handle typing of our generic union structure.
149*f0865ec9SKyle Evans */
150*f0865ec9SKyle Evans #ifdef WITH_HASH_SHA224
_sha224_init(hash_context * hctx)151*f0865ec9SKyle Evans ATTRIBUTE_WARN_UNUSED_RET int _sha224_init(hash_context * hctx)
152*f0865ec9SKyle Evans {
153*f0865ec9SKyle Evans return sha224_init((sha224_context*)hctx);
154*f0865ec9SKyle Evans }
_sha224_update(hash_context * hctx,const unsigned char * chunk,u32 chunklen)155*f0865ec9SKyle Evans ATTRIBUTE_WARN_UNUSED_RET int _sha224_update(hash_context * hctx, const unsigned char *chunk, u32 chunklen)
156*f0865ec9SKyle Evans {
157*f0865ec9SKyle Evans return sha224_update((sha224_context*)hctx, chunk, chunklen);
158*f0865ec9SKyle Evans }
_sha224_final(hash_context * hctx,unsigned char * output)159*f0865ec9SKyle Evans ATTRIBUTE_WARN_UNUSED_RET int _sha224_final(hash_context * hctx, unsigned char *output)
160*f0865ec9SKyle Evans {
161*f0865ec9SKyle Evans return sha224_final((sha224_context*)hctx, output);
162*f0865ec9SKyle Evans }
163*f0865ec9SKyle Evans #endif
164*f0865ec9SKyle Evans #ifdef WITH_HASH_SHA256
_sha256_init(hash_context * hctx)165*f0865ec9SKyle Evans ATTRIBUTE_WARN_UNUSED_RET int _sha256_init(hash_context * hctx)
166*f0865ec9SKyle Evans {
167*f0865ec9SKyle Evans return sha256_init((sha256_context*)hctx);
168*f0865ec9SKyle Evans }
_sha256_update(hash_context * hctx,const unsigned char * chunk,u32 chunklen)169*f0865ec9SKyle Evans ATTRIBUTE_WARN_UNUSED_RET int _sha256_update(hash_context * hctx, const unsigned char *chunk, u32 chunklen)
170*f0865ec9SKyle Evans {
171*f0865ec9SKyle Evans return sha256_update((sha256_context*)hctx, chunk, chunklen);
172*f0865ec9SKyle Evans }
_sha256_final(hash_context * hctx,unsigned char * output)173*f0865ec9SKyle Evans ATTRIBUTE_WARN_UNUSED_RET int _sha256_final(hash_context * hctx, unsigned char *output)
174*f0865ec9SKyle Evans {
175*f0865ec9SKyle Evans return sha256_final((sha256_context*)hctx, output);
176*f0865ec9SKyle Evans }
177*f0865ec9SKyle Evans #endif
178*f0865ec9SKyle Evans #ifdef WITH_HASH_SHA384
_sha384_init(hash_context * hctx)179*f0865ec9SKyle Evans ATTRIBUTE_WARN_UNUSED_RET int _sha384_init(hash_context * hctx)
180*f0865ec9SKyle Evans {
181*f0865ec9SKyle Evans return sha384_init((sha384_context*)hctx);
182*f0865ec9SKyle Evans }
_sha384_update(hash_context * hctx,const unsigned char * chunk,u32 chunklen)183*f0865ec9SKyle Evans ATTRIBUTE_WARN_UNUSED_RET int _sha384_update(hash_context * hctx, const unsigned char *chunk, u32 chunklen)
184*f0865ec9SKyle Evans {
185*f0865ec9SKyle Evans return sha384_update((sha384_context*)hctx, chunk, chunklen);
186*f0865ec9SKyle Evans }
_sha384_final(hash_context * hctx,unsigned char * output)187*f0865ec9SKyle Evans ATTRIBUTE_WARN_UNUSED_RET int _sha384_final(hash_context * hctx, unsigned char *output)
188*f0865ec9SKyle Evans {
189*f0865ec9SKyle Evans return sha384_final((sha384_context*)hctx, output);
190*f0865ec9SKyle Evans }
191*f0865ec9SKyle Evans #endif
192*f0865ec9SKyle Evans #ifdef WITH_HASH_SHA512
_sha512_init(hash_context * hctx)193*f0865ec9SKyle Evans ATTRIBUTE_WARN_UNUSED_RET int _sha512_init(hash_context * hctx)
194*f0865ec9SKyle Evans {
195*f0865ec9SKyle Evans return sha512_init((sha512_context*)hctx);
196*f0865ec9SKyle Evans }
_sha512_update(hash_context * hctx,const unsigned char * chunk,u32 chunklen)197*f0865ec9SKyle Evans ATTRIBUTE_WARN_UNUSED_RET int _sha512_update(hash_context * hctx, const unsigned char *chunk, u32 chunklen)
198*f0865ec9SKyle Evans {
199*f0865ec9SKyle Evans return sha512_update((sha512_context*)hctx, chunk, chunklen);
200*f0865ec9SKyle Evans }
_sha512_final(hash_context * hctx,unsigned char * output)201*f0865ec9SKyle Evans ATTRIBUTE_WARN_UNUSED_RET int _sha512_final(hash_context * hctx, unsigned char *output)
202*f0865ec9SKyle Evans {
203*f0865ec9SKyle Evans return sha512_final((sha512_context*)hctx, output);
204*f0865ec9SKyle Evans }
205*f0865ec9SKyle Evans #endif
206*f0865ec9SKyle Evans #ifdef WITH_HASH_SHA512_224
_sha512_224_init(hash_context * hctx)207*f0865ec9SKyle Evans ATTRIBUTE_WARN_UNUSED_RET int _sha512_224_init(hash_context * hctx)
208*f0865ec9SKyle Evans {
209*f0865ec9SKyle Evans return sha512_224_init((sha512_224_context*)hctx);
210*f0865ec9SKyle Evans }
_sha512_224_update(hash_context * hctx,const unsigned char * chunk,u32 chunklen)211*f0865ec9SKyle Evans ATTRIBUTE_WARN_UNUSED_RET int _sha512_224_update(hash_context * hctx, const unsigned char *chunk, u32 chunklen)
212*f0865ec9SKyle Evans {
213*f0865ec9SKyle Evans return sha512_224_update((sha512_224_context*)hctx, chunk, chunklen);
214*f0865ec9SKyle Evans }
_sha512_224_final(hash_context * hctx,unsigned char * output)215*f0865ec9SKyle Evans ATTRIBUTE_WARN_UNUSED_RET int _sha512_224_final(hash_context * hctx, unsigned char *output)
216*f0865ec9SKyle Evans {
217*f0865ec9SKyle Evans return sha512_224_final((sha512_224_context*)hctx, output);
218*f0865ec9SKyle Evans }
219*f0865ec9SKyle Evans #endif
220*f0865ec9SKyle Evans #ifdef WITH_HASH_SHA512_256
_sha512_256_init(hash_context * hctx)221*f0865ec9SKyle Evans ATTRIBUTE_WARN_UNUSED_RET int _sha512_256_init(hash_context * hctx)
222*f0865ec9SKyle Evans {
223*f0865ec9SKyle Evans return sha512_256_init((sha512_256_context*)hctx);
224*f0865ec9SKyle Evans }
_sha512_256_update(hash_context * hctx,const unsigned char * chunk,u32 chunklen)225*f0865ec9SKyle Evans ATTRIBUTE_WARN_UNUSED_RET int _sha512_256_update(hash_context * hctx, const unsigned char *chunk, u32 chunklen)
226*f0865ec9SKyle Evans {
227*f0865ec9SKyle Evans return sha512_256_update((sha512_256_context*)hctx, chunk, chunklen);
228*f0865ec9SKyle Evans }
_sha512_256_final(hash_context * hctx,unsigned char * output)229*f0865ec9SKyle Evans ATTRIBUTE_WARN_UNUSED_RET int _sha512_256_final(hash_context * hctx, unsigned char *output)
230*f0865ec9SKyle Evans {
231*f0865ec9SKyle Evans return sha512_256_final((sha512_256_context*)hctx, output);
232*f0865ec9SKyle Evans }
233*f0865ec9SKyle Evans #endif
234*f0865ec9SKyle Evans #ifdef WITH_HASH_SHA3_224
_sha3_224_init(hash_context * hctx)235*f0865ec9SKyle Evans ATTRIBUTE_WARN_UNUSED_RET int _sha3_224_init(hash_context * hctx)
236*f0865ec9SKyle Evans {
237*f0865ec9SKyle Evans return sha3_224_init((sha3_224_context*)hctx);
238*f0865ec9SKyle Evans }
_sha3_224_update(hash_context * hctx,const unsigned char * chunk,u32 chunklen)239*f0865ec9SKyle Evans ATTRIBUTE_WARN_UNUSED_RET int _sha3_224_update(hash_context * hctx, const unsigned char *chunk, u32 chunklen)
240*f0865ec9SKyle Evans {
241*f0865ec9SKyle Evans return sha3_224_update((sha3_224_context*)hctx, chunk, chunklen);
242*f0865ec9SKyle Evans }
_sha3_224_final(hash_context * hctx,unsigned char * output)243*f0865ec9SKyle Evans ATTRIBUTE_WARN_UNUSED_RET int _sha3_224_final(hash_context * hctx, unsigned char *output)
244*f0865ec9SKyle Evans {
245*f0865ec9SKyle Evans return sha3_224_final((sha3_224_context*)hctx, output);
246*f0865ec9SKyle Evans }
247*f0865ec9SKyle Evans #endif
248*f0865ec9SKyle Evans #ifdef WITH_HASH_SHA3_256
_sha3_256_init(hash_context * hctx)249*f0865ec9SKyle Evans ATTRIBUTE_WARN_UNUSED_RET int _sha3_256_init(hash_context * hctx)
250*f0865ec9SKyle Evans {
251*f0865ec9SKyle Evans return sha3_256_init((sha3_256_context*)hctx);
252*f0865ec9SKyle Evans }
_sha3_256_update(hash_context * hctx,const unsigned char * chunk,u32 chunklen)253*f0865ec9SKyle Evans ATTRIBUTE_WARN_UNUSED_RET int _sha3_256_update(hash_context * hctx, const unsigned char *chunk, u32 chunklen)
254*f0865ec9SKyle Evans {
255*f0865ec9SKyle Evans return sha3_256_update((sha3_256_context*)hctx, chunk, chunklen);
256*f0865ec9SKyle Evans }
_sha3_256_final(hash_context * hctx,unsigned char * output)257*f0865ec9SKyle Evans ATTRIBUTE_WARN_UNUSED_RET int _sha3_256_final(hash_context * hctx, unsigned char *output)
258*f0865ec9SKyle Evans {
259*f0865ec9SKyle Evans return sha3_256_final((sha3_256_context*)hctx, output);
260*f0865ec9SKyle Evans }
261*f0865ec9SKyle Evans #endif
262*f0865ec9SKyle Evans #ifdef WITH_HASH_SHA3_384
_sha3_384_init(hash_context * hctx)263*f0865ec9SKyle Evans ATTRIBUTE_WARN_UNUSED_RET int _sha3_384_init(hash_context * hctx)
264*f0865ec9SKyle Evans {
265*f0865ec9SKyle Evans return sha3_384_init((sha3_384_context*)hctx);
266*f0865ec9SKyle Evans }
_sha3_384_update(hash_context * hctx,const unsigned char * chunk,u32 chunklen)267*f0865ec9SKyle Evans ATTRIBUTE_WARN_UNUSED_RET int _sha3_384_update(hash_context * hctx, const unsigned char *chunk, u32 chunklen)
268*f0865ec9SKyle Evans {
269*f0865ec9SKyle Evans return sha3_384_update((sha3_384_context*)hctx, chunk, chunklen);
270*f0865ec9SKyle Evans }
_sha3_384_final(hash_context * hctx,unsigned char * output)271*f0865ec9SKyle Evans ATTRIBUTE_WARN_UNUSED_RET int _sha3_384_final(hash_context * hctx, unsigned char *output)
272*f0865ec9SKyle Evans {
273*f0865ec9SKyle Evans return sha3_384_final((sha3_384_context*)hctx, output);
274*f0865ec9SKyle Evans }
275*f0865ec9SKyle Evans #endif
276*f0865ec9SKyle Evans #ifdef WITH_HASH_SHA3_512
_sha3_512_init(hash_context * hctx)277*f0865ec9SKyle Evans ATTRIBUTE_WARN_UNUSED_RET int _sha3_512_init(hash_context * hctx)
278*f0865ec9SKyle Evans {
279*f0865ec9SKyle Evans return sha3_512_init((sha3_512_context*)hctx);
280*f0865ec9SKyle Evans }
_sha3_512_update(hash_context * hctx,const unsigned char * chunk,u32 chunklen)281*f0865ec9SKyle Evans ATTRIBUTE_WARN_UNUSED_RET int _sha3_512_update(hash_context * hctx, const unsigned char *chunk, u32 chunklen)
282*f0865ec9SKyle Evans {
283*f0865ec9SKyle Evans return sha3_512_update((sha3_512_context*)hctx, chunk, chunklen);
284*f0865ec9SKyle Evans }
_sha3_512_final(hash_context * hctx,unsigned char * output)285*f0865ec9SKyle Evans ATTRIBUTE_WARN_UNUSED_RET int _sha3_512_final(hash_context * hctx, unsigned char *output)
286*f0865ec9SKyle Evans {
287*f0865ec9SKyle Evans return sha3_512_final((sha3_512_context*)hctx, output);
288*f0865ec9SKyle Evans }
289*f0865ec9SKyle Evans #endif
290*f0865ec9SKyle Evans #ifdef WITH_HASH_SM3
_sm3_init(hash_context * hctx)291*f0865ec9SKyle Evans ATTRIBUTE_WARN_UNUSED_RET int _sm3_init(hash_context * hctx)
292*f0865ec9SKyle Evans {
293*f0865ec9SKyle Evans return sm3_init((sm3_context*)hctx);
294*f0865ec9SKyle Evans }
_sm3_update(hash_context * hctx,const unsigned char * chunk,u32 chunklen)295*f0865ec9SKyle Evans ATTRIBUTE_WARN_UNUSED_RET int _sm3_update(hash_context * hctx, const unsigned char *chunk, u32 chunklen)
296*f0865ec9SKyle Evans {
297*f0865ec9SKyle Evans return sm3_update((sm3_context*)hctx, chunk, chunklen);
298*f0865ec9SKyle Evans }
_sm3_final(hash_context * hctx,unsigned char * output)299*f0865ec9SKyle Evans ATTRIBUTE_WARN_UNUSED_RET int _sm3_final(hash_context * hctx, unsigned char *output)
300*f0865ec9SKyle Evans {
301*f0865ec9SKyle Evans return sm3_final((sm3_context*)hctx, output);
302*f0865ec9SKyle Evans }
303*f0865ec9SKyle Evans #endif
304*f0865ec9SKyle Evans #ifdef WITH_HASH_SHAKE256
_shake256_init(hash_context * hctx)305*f0865ec9SKyle Evans ATTRIBUTE_WARN_UNUSED_RET int _shake256_init(hash_context * hctx)
306*f0865ec9SKyle Evans {
307*f0865ec9SKyle Evans return shake256_init((shake256_context*)hctx);
308*f0865ec9SKyle Evans }
_shake256_update(hash_context * hctx,const unsigned char * chunk,u32 chunklen)309*f0865ec9SKyle Evans ATTRIBUTE_WARN_UNUSED_RET int _shake256_update(hash_context * hctx, const unsigned char *chunk, u32 chunklen)
310*f0865ec9SKyle Evans {
311*f0865ec9SKyle Evans return shake256_update((shake256_context*)hctx, chunk, chunklen);
312*f0865ec9SKyle Evans }
_shake256_final(hash_context * hctx,unsigned char * output)313*f0865ec9SKyle Evans ATTRIBUTE_WARN_UNUSED_RET int _shake256_final(hash_context * hctx, unsigned char *output)
314*f0865ec9SKyle Evans {
315*f0865ec9SKyle Evans return shake256_final((shake256_context*)hctx, output);
316*f0865ec9SKyle Evans }
317*f0865ec9SKyle Evans #endif
318*f0865ec9SKyle Evans #ifdef WITH_HASH_STREEBOG256
_streebog256_init(hash_context * hctx)319*f0865ec9SKyle Evans ATTRIBUTE_WARN_UNUSED_RET int _streebog256_init(hash_context * hctx)
320*f0865ec9SKyle Evans {
321*f0865ec9SKyle Evans return streebog256_init((streebog256_context*)hctx);
322*f0865ec9SKyle Evans }
_streebog256_update(hash_context * hctx,const unsigned char * chunk,u32 chunklen)323*f0865ec9SKyle Evans ATTRIBUTE_WARN_UNUSED_RET int _streebog256_update(hash_context * hctx, const unsigned char *chunk, u32 chunklen)
324*f0865ec9SKyle Evans {
325*f0865ec9SKyle Evans return streebog256_update((streebog256_context*)hctx, chunk, chunklen);
326*f0865ec9SKyle Evans }
_streebog256_final(hash_context * hctx,unsigned char * output)327*f0865ec9SKyle Evans ATTRIBUTE_WARN_UNUSED_RET int _streebog256_final(hash_context * hctx, unsigned char *output)
328*f0865ec9SKyle Evans {
329*f0865ec9SKyle Evans return streebog256_final((streebog256_context*)hctx, output);
330*f0865ec9SKyle Evans }
331*f0865ec9SKyle Evans #endif
332*f0865ec9SKyle Evans #ifdef WITH_HASH_STREEBOG512
_streebog512_init(hash_context * hctx)333*f0865ec9SKyle Evans ATTRIBUTE_WARN_UNUSED_RET int _streebog512_init(hash_context * hctx)
334*f0865ec9SKyle Evans {
335*f0865ec9SKyle Evans return streebog512_init((streebog512_context*)hctx);
336*f0865ec9SKyle Evans }
_streebog512_update(hash_context * hctx,const unsigned char * chunk,u32 chunklen)337*f0865ec9SKyle Evans ATTRIBUTE_WARN_UNUSED_RET int _streebog512_update(hash_context * hctx, const unsigned char *chunk, u32 chunklen)
338*f0865ec9SKyle Evans {
339*f0865ec9SKyle Evans return streebog512_update((streebog512_context*)hctx, chunk, chunklen);
340*f0865ec9SKyle Evans }
_streebog512_final(hash_context * hctx,unsigned char * output)341*f0865ec9SKyle Evans ATTRIBUTE_WARN_UNUSED_RET int _streebog512_final(hash_context * hctx, unsigned char *output)
342*f0865ec9SKyle Evans {
343*f0865ec9SKyle Evans return streebog512_final((streebog512_context*)hctx, output);
344*f0865ec9SKyle Evans }
345*f0865ec9SKyle Evans #endif
346*f0865ec9SKyle Evans #ifdef WITH_HASH_RIPEMD160
_ripemd160_init(hash_context * hctx)347*f0865ec9SKyle Evans ATTRIBUTE_WARN_UNUSED_RET int _ripemd160_init(hash_context * hctx)
348*f0865ec9SKyle Evans {
349*f0865ec9SKyle Evans return ripemd160_init((ripemd160_context*)hctx);
350*f0865ec9SKyle Evans }
_ripemd160_update(hash_context * hctx,const unsigned char * chunk,u32 chunklen)351*f0865ec9SKyle Evans ATTRIBUTE_WARN_UNUSED_RET int _ripemd160_update(hash_context * hctx, const unsigned char *chunk, u32 chunklen)
352*f0865ec9SKyle Evans {
353*f0865ec9SKyle Evans return ripemd160_update((ripemd160_context*)hctx, chunk, chunklen);
354*f0865ec9SKyle Evans }
_ripemd160_final(hash_context * hctx,unsigned char * output)355*f0865ec9SKyle Evans ATTRIBUTE_WARN_UNUSED_RET int _ripemd160_final(hash_context * hctx, unsigned char *output)
356*f0865ec9SKyle Evans {
357*f0865ec9SKyle Evans return ripemd160_final((ripemd160_context*)hctx, output);
358*f0865ec9SKyle Evans }
359*f0865ec9SKyle Evans #endif
360*f0865ec9SKyle Evans #ifdef WITH_HASH_BELT_HASH
_belt_hash_init(hash_context * hctx)361*f0865ec9SKyle Evans ATTRIBUTE_WARN_UNUSED_RET int _belt_hash_init(hash_context * hctx)
362*f0865ec9SKyle Evans {
363*f0865ec9SKyle Evans return belt_hash_init((belt_hash_context*)hctx);
364*f0865ec9SKyle Evans }
_belt_hash_update(hash_context * hctx,const unsigned char * chunk,u32 chunklen)365*f0865ec9SKyle Evans ATTRIBUTE_WARN_UNUSED_RET int _belt_hash_update(hash_context * hctx, const unsigned char *chunk, u32 chunklen)
366*f0865ec9SKyle Evans {
367*f0865ec9SKyle Evans return belt_hash_update((belt_hash_context*)hctx, chunk, chunklen);
368*f0865ec9SKyle Evans }
_belt_hash_final(hash_context * hctx,unsigned char * output)369*f0865ec9SKyle Evans ATTRIBUTE_WARN_UNUSED_RET int _belt_hash_final(hash_context * hctx, unsigned char *output)
370*f0865ec9SKyle Evans {
371*f0865ec9SKyle Evans return belt_hash_final((belt_hash_context*)hctx, output);
372*f0865ec9SKyle Evans }
373*f0865ec9SKyle Evans #endif
374*f0865ec9SKyle Evans #ifdef WITH_HASH_BASH224
_bash224_init(hash_context * hctx)375*f0865ec9SKyle Evans ATTRIBUTE_WARN_UNUSED_RET int _bash224_init(hash_context * hctx)
376*f0865ec9SKyle Evans {
377*f0865ec9SKyle Evans return bash224_init((bash224_context*)hctx);
378*f0865ec9SKyle Evans }
_bash224_update(hash_context * hctx,const unsigned char * chunk,u32 chunklen)379*f0865ec9SKyle Evans ATTRIBUTE_WARN_UNUSED_RET int _bash224_update(hash_context * hctx, const unsigned char *chunk, u32 chunklen)
380*f0865ec9SKyle Evans {
381*f0865ec9SKyle Evans return bash224_update((bash224_context*)hctx, chunk, chunklen);
382*f0865ec9SKyle Evans }
_bash224_final(hash_context * hctx,unsigned char * output)383*f0865ec9SKyle Evans ATTRIBUTE_WARN_UNUSED_RET int _bash224_final(hash_context * hctx, unsigned char *output)
384*f0865ec9SKyle Evans {
385*f0865ec9SKyle Evans return bash224_final((bash224_context*)hctx, output);
386*f0865ec9SKyle Evans }
387*f0865ec9SKyle Evans #endif
388*f0865ec9SKyle Evans #ifdef WITH_HASH_BASH256
_bash256_init(hash_context * hctx)389*f0865ec9SKyle Evans ATTRIBUTE_WARN_UNUSED_RET int _bash256_init(hash_context * hctx)
390*f0865ec9SKyle Evans {
391*f0865ec9SKyle Evans return bash256_init((bash256_context*)hctx);
392*f0865ec9SKyle Evans }
_bash256_update(hash_context * hctx,const unsigned char * chunk,u32 chunklen)393*f0865ec9SKyle Evans ATTRIBUTE_WARN_UNUSED_RET int _bash256_update(hash_context * hctx, const unsigned char *chunk, u32 chunklen)
394*f0865ec9SKyle Evans {
395*f0865ec9SKyle Evans return bash256_update((bash256_context*)hctx, chunk, chunklen);
396*f0865ec9SKyle Evans }
_bash256_final(hash_context * hctx,unsigned char * output)397*f0865ec9SKyle Evans ATTRIBUTE_WARN_UNUSED_RET int _bash256_final(hash_context * hctx, unsigned char *output)
398*f0865ec9SKyle Evans {
399*f0865ec9SKyle Evans return bash256_final((bash256_context*)hctx, output);
400*f0865ec9SKyle Evans }
401*f0865ec9SKyle Evans #endif
402*f0865ec9SKyle Evans #ifdef WITH_HASH_BASH384
_bash384_init(hash_context * hctx)403*f0865ec9SKyle Evans ATTRIBUTE_WARN_UNUSED_RET int _bash384_init(hash_context * hctx)
404*f0865ec9SKyle Evans {
405*f0865ec9SKyle Evans return bash384_init((bash384_context*)hctx);
406*f0865ec9SKyle Evans }
_bash384_update(hash_context * hctx,const unsigned char * chunk,u32 chunklen)407*f0865ec9SKyle Evans ATTRIBUTE_WARN_UNUSED_RET int _bash384_update(hash_context * hctx, const unsigned char *chunk, u32 chunklen)
408*f0865ec9SKyle Evans {
409*f0865ec9SKyle Evans return bash384_update((bash384_context*)hctx, chunk, chunklen);
410*f0865ec9SKyle Evans }
_bash384_final(hash_context * hctx,unsigned char * output)411*f0865ec9SKyle Evans ATTRIBUTE_WARN_UNUSED_RET int _bash384_final(hash_context * hctx, unsigned char *output)
412*f0865ec9SKyle Evans {
413*f0865ec9SKyle Evans return bash384_final((bash384_context*)hctx, output);
414*f0865ec9SKyle Evans }
415*f0865ec9SKyle Evans #endif
416*f0865ec9SKyle Evans #ifdef WITH_HASH_BASH512
_bash512_init(hash_context * hctx)417*f0865ec9SKyle Evans ATTRIBUTE_WARN_UNUSED_RET int _bash512_init(hash_context * hctx)
418*f0865ec9SKyle Evans {
419*f0865ec9SKyle Evans return bash512_init((bash512_context*)hctx);
420*f0865ec9SKyle Evans }
_bash512_update(hash_context * hctx,const unsigned char * chunk,u32 chunklen)421*f0865ec9SKyle Evans ATTRIBUTE_WARN_UNUSED_RET int _bash512_update(hash_context * hctx, const unsigned char *chunk, u32 chunklen)
422*f0865ec9SKyle Evans {
423*f0865ec9SKyle Evans return bash512_update((bash512_context*)hctx, chunk, chunklen);
424*f0865ec9SKyle Evans }
_bash512_final(hash_context * hctx,unsigned char * output)425*f0865ec9SKyle Evans ATTRIBUTE_WARN_UNUSED_RET int _bash512_final(hash_context * hctx, unsigned char *output)
426*f0865ec9SKyle Evans {
427*f0865ec9SKyle Evans return bash512_final((bash512_context*)hctx, output);
428*f0865ec9SKyle Evans }
429*f0865ec9SKyle Evans #endif
430