1*b077aed3SPierre Pronchery /*
2*b077aed3SPierre Pronchery * Copyright 2019-2021 The OpenSSL Project Authors. All Rights Reserved.
3*b077aed3SPierre Pronchery *
4*b077aed3SPierre Pronchery * Licensed under the Apache License 2.0 (the "License"). You may not use
5*b077aed3SPierre Pronchery * this file except in compliance with the License. You can obtain a copy
6*b077aed3SPierre Pronchery * in the file LICENSE in the source distribution or at
7*b077aed3SPierre Pronchery * https://www.openssl.org/source/license.html
8*b077aed3SPierre Pronchery */
9*b077aed3SPierre Pronchery
10*b077aed3SPierre Pronchery #include <string.h>
11*b077aed3SPierre Pronchery #include <openssl/core_names.h>
12*b077aed3SPierre Pronchery #include <openssl/crypto.h>
13*b077aed3SPierre Pronchery #include <openssl/evp.h>
14*b077aed3SPierre Pronchery #include <openssl/params.h>
15*b077aed3SPierre Pronchery #include <openssl/err.h>
16*b077aed3SPierre Pronchery #include <openssl/proverr.h>
17*b077aed3SPierre Pronchery #include "internal/sha3.h"
18*b077aed3SPierre Pronchery #include "prov/digestcommon.h"
19*b077aed3SPierre Pronchery #include "prov/implementations.h"
20*b077aed3SPierre Pronchery
21*b077aed3SPierre Pronchery #define SHA3_FLAGS PROV_DIGEST_FLAG_ALGID_ABSENT
22*b077aed3SPierre Pronchery #define SHAKE_FLAGS PROV_DIGEST_FLAG_XOF
23*b077aed3SPierre Pronchery #define KMAC_FLAGS PROV_DIGEST_FLAG_XOF
24*b077aed3SPierre Pronchery
25*b077aed3SPierre Pronchery /*
26*b077aed3SPierre Pronchery * Forward declaration of any unique methods implemented here. This is not strictly
27*b077aed3SPierre Pronchery * necessary for the compiler, but provides an assurance that the signatures
28*b077aed3SPierre Pronchery * of the functions in the dispatch table are correct.
29*b077aed3SPierre Pronchery */
30*b077aed3SPierre Pronchery static OSSL_FUNC_digest_init_fn keccak_init;
31*b077aed3SPierre Pronchery static OSSL_FUNC_digest_init_fn keccak_init_params;
32*b077aed3SPierre Pronchery static OSSL_FUNC_digest_update_fn keccak_update;
33*b077aed3SPierre Pronchery static OSSL_FUNC_digest_final_fn keccak_final;
34*b077aed3SPierre Pronchery static OSSL_FUNC_digest_freectx_fn keccak_freectx;
35*b077aed3SPierre Pronchery static OSSL_FUNC_digest_dupctx_fn keccak_dupctx;
36*b077aed3SPierre Pronchery static OSSL_FUNC_digest_set_ctx_params_fn shake_set_ctx_params;
37*b077aed3SPierre Pronchery static OSSL_FUNC_digest_settable_ctx_params_fn shake_settable_ctx_params;
38*b077aed3SPierre Pronchery static sha3_absorb_fn generic_sha3_absorb;
39*b077aed3SPierre Pronchery static sha3_final_fn generic_sha3_final;
40*b077aed3SPierre Pronchery
41*b077aed3SPierre Pronchery #if defined(OPENSSL_CPUID_OBJ) && defined(__s390__) && defined(KECCAK1600_ASM)
42*b077aed3SPierre Pronchery /*
43*b077aed3SPierre Pronchery * IBM S390X support
44*b077aed3SPierre Pronchery */
45*b077aed3SPierre Pronchery # include "s390x_arch.h"
46*b077aed3SPierre Pronchery # define S390_SHA3 1
47*b077aed3SPierre Pronchery # define S390_SHA3_CAPABLE(name) \
48*b077aed3SPierre Pronchery ((OPENSSL_s390xcap_P.kimd[0] & S390X_CAPBIT(S390X_##name)) && \
49*b077aed3SPierre Pronchery (OPENSSL_s390xcap_P.klmd[0] & S390X_CAPBIT(S390X_##name)))
50*b077aed3SPierre Pronchery
51*b077aed3SPierre Pronchery #endif
52*b077aed3SPierre Pronchery
keccak_init(void * vctx,ossl_unused const OSSL_PARAM params[])53*b077aed3SPierre Pronchery static int keccak_init(void *vctx, ossl_unused const OSSL_PARAM params[])
54*b077aed3SPierre Pronchery {
55*b077aed3SPierre Pronchery if (!ossl_prov_is_running())
56*b077aed3SPierre Pronchery return 0;
57*b077aed3SPierre Pronchery /* The newctx() handles most of the ctx fixed setup. */
58*b077aed3SPierre Pronchery ossl_sha3_reset((KECCAK1600_CTX *)vctx);
59*b077aed3SPierre Pronchery return 1;
60*b077aed3SPierre Pronchery }
61*b077aed3SPierre Pronchery
keccak_init_params(void * vctx,const OSSL_PARAM params[])62*b077aed3SPierre Pronchery static int keccak_init_params(void *vctx, const OSSL_PARAM params[])
63*b077aed3SPierre Pronchery {
64*b077aed3SPierre Pronchery return keccak_init(vctx, NULL)
65*b077aed3SPierre Pronchery && shake_set_ctx_params(vctx, params);
66*b077aed3SPierre Pronchery }
67*b077aed3SPierre Pronchery
keccak_update(void * vctx,const unsigned char * inp,size_t len)68*b077aed3SPierre Pronchery static int keccak_update(void *vctx, const unsigned char *inp, size_t len)
69*b077aed3SPierre Pronchery {
70*b077aed3SPierre Pronchery KECCAK1600_CTX *ctx = vctx;
71*b077aed3SPierre Pronchery const size_t bsz = ctx->block_size;
72*b077aed3SPierre Pronchery size_t num, rem;
73*b077aed3SPierre Pronchery
74*b077aed3SPierre Pronchery if (len == 0)
75*b077aed3SPierre Pronchery return 1;
76*b077aed3SPierre Pronchery
77*b077aed3SPierre Pronchery /* Is there anything in the buffer already ? */
78*b077aed3SPierre Pronchery if ((num = ctx->bufsz) != 0) {
79*b077aed3SPierre Pronchery /* Calculate how much space is left in the buffer */
80*b077aed3SPierre Pronchery rem = bsz - num;
81*b077aed3SPierre Pronchery /* If the new input does not fill the buffer then just add it */
82*b077aed3SPierre Pronchery if (len < rem) {
83*b077aed3SPierre Pronchery memcpy(ctx->buf + num, inp, len);
84*b077aed3SPierre Pronchery ctx->bufsz += len;
85*b077aed3SPierre Pronchery return 1;
86*b077aed3SPierre Pronchery }
87*b077aed3SPierre Pronchery /* otherwise fill up the buffer and absorb the buffer */
88*b077aed3SPierre Pronchery memcpy(ctx->buf + num, inp, rem);
89*b077aed3SPierre Pronchery /* Update the input pointer */
90*b077aed3SPierre Pronchery inp += rem;
91*b077aed3SPierre Pronchery len -= rem;
92*b077aed3SPierre Pronchery ctx->meth.absorb(ctx, ctx->buf, bsz);
93*b077aed3SPierre Pronchery ctx->bufsz = 0;
94*b077aed3SPierre Pronchery }
95*b077aed3SPierre Pronchery /* Absorb the input - rem = leftover part of the input < blocksize) */
96*b077aed3SPierre Pronchery rem = ctx->meth.absorb(ctx, inp, len);
97*b077aed3SPierre Pronchery /* Copy the leftover bit of the input into the buffer */
98*b077aed3SPierre Pronchery if (rem) {
99*b077aed3SPierre Pronchery memcpy(ctx->buf, inp + len - rem, rem);
100*b077aed3SPierre Pronchery ctx->bufsz = rem;
101*b077aed3SPierre Pronchery }
102*b077aed3SPierre Pronchery return 1;
103*b077aed3SPierre Pronchery }
104*b077aed3SPierre Pronchery
keccak_final(void * vctx,unsigned char * out,size_t * outl,size_t outsz)105*b077aed3SPierre Pronchery static int keccak_final(void *vctx, unsigned char *out, size_t *outl,
106*b077aed3SPierre Pronchery size_t outsz)
107*b077aed3SPierre Pronchery {
108*b077aed3SPierre Pronchery int ret = 1;
109*b077aed3SPierre Pronchery KECCAK1600_CTX *ctx = vctx;
110*b077aed3SPierre Pronchery
111*b077aed3SPierre Pronchery if (!ossl_prov_is_running())
112*b077aed3SPierre Pronchery return 0;
113*b077aed3SPierre Pronchery if (outsz > 0)
114*b077aed3SPierre Pronchery ret = ctx->meth.final(out, ctx);
115*b077aed3SPierre Pronchery
116*b077aed3SPierre Pronchery *outl = ctx->md_size;
117*b077aed3SPierre Pronchery return ret;
118*b077aed3SPierre Pronchery }
119*b077aed3SPierre Pronchery
120*b077aed3SPierre Pronchery /*-
121*b077aed3SPierre Pronchery * Generic software version of the absorb() and final().
122*b077aed3SPierre Pronchery */
generic_sha3_absorb(void * vctx,const void * inp,size_t len)123*b077aed3SPierre Pronchery static size_t generic_sha3_absorb(void *vctx, const void *inp, size_t len)
124*b077aed3SPierre Pronchery {
125*b077aed3SPierre Pronchery KECCAK1600_CTX *ctx = vctx;
126*b077aed3SPierre Pronchery
127*b077aed3SPierre Pronchery return SHA3_absorb(ctx->A, inp, len, ctx->block_size);
128*b077aed3SPierre Pronchery }
129*b077aed3SPierre Pronchery
generic_sha3_final(unsigned char * md,void * vctx)130*b077aed3SPierre Pronchery static int generic_sha3_final(unsigned char *md, void *vctx)
131*b077aed3SPierre Pronchery {
132*b077aed3SPierre Pronchery return ossl_sha3_final(md, (KECCAK1600_CTX *)vctx);
133*b077aed3SPierre Pronchery }
134*b077aed3SPierre Pronchery
135*b077aed3SPierre Pronchery static PROV_SHA3_METHOD sha3_generic_md =
136*b077aed3SPierre Pronchery {
137*b077aed3SPierre Pronchery generic_sha3_absorb,
138*b077aed3SPierre Pronchery generic_sha3_final
139*b077aed3SPierre Pronchery };
140*b077aed3SPierre Pronchery
141*b077aed3SPierre Pronchery #if defined(S390_SHA3)
142*b077aed3SPierre Pronchery
143*b077aed3SPierre Pronchery static sha3_absorb_fn s390x_sha3_absorb;
144*b077aed3SPierre Pronchery static sha3_final_fn s390x_sha3_final;
145*b077aed3SPierre Pronchery static sha3_final_fn s390x_shake_final;
146*b077aed3SPierre Pronchery
147*b077aed3SPierre Pronchery /*-
148*b077aed3SPierre Pronchery * The platform specific parts of the absorb() and final() for S390X.
149*b077aed3SPierre Pronchery */
s390x_sha3_absorb(void * vctx,const void * inp,size_t len)150*b077aed3SPierre Pronchery static size_t s390x_sha3_absorb(void *vctx, const void *inp, size_t len)
151*b077aed3SPierre Pronchery {
152*b077aed3SPierre Pronchery KECCAK1600_CTX *ctx = vctx;
153*b077aed3SPierre Pronchery size_t rem = len % ctx->block_size;
154*b077aed3SPierre Pronchery
155*b077aed3SPierre Pronchery s390x_kimd(inp, len - rem, ctx->pad, ctx->A);
156*b077aed3SPierre Pronchery return rem;
157*b077aed3SPierre Pronchery }
158*b077aed3SPierre Pronchery
s390x_sha3_final(unsigned char * md,void * vctx)159*b077aed3SPierre Pronchery static int s390x_sha3_final(unsigned char *md, void *vctx)
160*b077aed3SPierre Pronchery {
161*b077aed3SPierre Pronchery KECCAK1600_CTX *ctx = vctx;
162*b077aed3SPierre Pronchery
163*b077aed3SPierre Pronchery if (!ossl_prov_is_running())
164*b077aed3SPierre Pronchery return 0;
165*b077aed3SPierre Pronchery s390x_klmd(ctx->buf, ctx->bufsz, NULL, 0, ctx->pad, ctx->A);
166*b077aed3SPierre Pronchery memcpy(md, ctx->A, ctx->md_size);
167*b077aed3SPierre Pronchery return 1;
168*b077aed3SPierre Pronchery }
169*b077aed3SPierre Pronchery
s390x_shake_final(unsigned char * md,void * vctx)170*b077aed3SPierre Pronchery static int s390x_shake_final(unsigned char *md, void *vctx)
171*b077aed3SPierre Pronchery {
172*b077aed3SPierre Pronchery KECCAK1600_CTX *ctx = vctx;
173*b077aed3SPierre Pronchery
174*b077aed3SPierre Pronchery if (!ossl_prov_is_running())
175*b077aed3SPierre Pronchery return 0;
176*b077aed3SPierre Pronchery s390x_klmd(ctx->buf, ctx->bufsz, md, ctx->md_size, ctx->pad, ctx->A);
177*b077aed3SPierre Pronchery return 1;
178*b077aed3SPierre Pronchery }
179*b077aed3SPierre Pronchery
180*b077aed3SPierre Pronchery static PROV_SHA3_METHOD sha3_s390x_md =
181*b077aed3SPierre Pronchery {
182*b077aed3SPierre Pronchery s390x_sha3_absorb,
183*b077aed3SPierre Pronchery s390x_sha3_final
184*b077aed3SPierre Pronchery };
185*b077aed3SPierre Pronchery
186*b077aed3SPierre Pronchery static PROV_SHA3_METHOD shake_s390x_md =
187*b077aed3SPierre Pronchery {
188*b077aed3SPierre Pronchery s390x_sha3_absorb,
189*b077aed3SPierre Pronchery s390x_shake_final
190*b077aed3SPierre Pronchery };
191*b077aed3SPierre Pronchery
192*b077aed3SPierre Pronchery # define SHA3_SET_MD(uname, typ) \
193*b077aed3SPierre Pronchery if (S390_SHA3_CAPABLE(uname)) { \
194*b077aed3SPierre Pronchery ctx->pad = S390X_##uname; \
195*b077aed3SPierre Pronchery ctx->meth = typ##_s390x_md; \
196*b077aed3SPierre Pronchery } else { \
197*b077aed3SPierre Pronchery ctx->meth = sha3_generic_md; \
198*b077aed3SPierre Pronchery }
199*b077aed3SPierre Pronchery #else
200*b077aed3SPierre Pronchery # define SHA3_SET_MD(uname, typ) ctx->meth = sha3_generic_md;
201*b077aed3SPierre Pronchery #endif /* S390_SHA3 */
202*b077aed3SPierre Pronchery
203*b077aed3SPierre Pronchery #define SHA3_newctx(typ, uname, name, bitlen, pad) \
204*b077aed3SPierre Pronchery static OSSL_FUNC_digest_newctx_fn name##_newctx; \
205*b077aed3SPierre Pronchery static void *name##_newctx(void *provctx) \
206*b077aed3SPierre Pronchery { \
207*b077aed3SPierre Pronchery KECCAK1600_CTX *ctx = ossl_prov_is_running() ? OPENSSL_zalloc(sizeof(*ctx)) \
208*b077aed3SPierre Pronchery : NULL; \
209*b077aed3SPierre Pronchery \
210*b077aed3SPierre Pronchery if (ctx == NULL) \
211*b077aed3SPierre Pronchery return NULL; \
212*b077aed3SPierre Pronchery ossl_sha3_init(ctx, pad, bitlen); \
213*b077aed3SPierre Pronchery SHA3_SET_MD(uname, typ) \
214*b077aed3SPierre Pronchery return ctx; \
215*b077aed3SPierre Pronchery }
216*b077aed3SPierre Pronchery
217*b077aed3SPierre Pronchery #define KMAC_newctx(uname, bitlen, pad) \
218*b077aed3SPierre Pronchery static OSSL_FUNC_digest_newctx_fn uname##_newctx; \
219*b077aed3SPierre Pronchery static void *uname##_newctx(void *provctx) \
220*b077aed3SPierre Pronchery { \
221*b077aed3SPierre Pronchery KECCAK1600_CTX *ctx = ossl_prov_is_running() ? OPENSSL_zalloc(sizeof(*ctx)) \
222*b077aed3SPierre Pronchery : NULL; \
223*b077aed3SPierre Pronchery \
224*b077aed3SPierre Pronchery if (ctx == NULL) \
225*b077aed3SPierre Pronchery return NULL; \
226*b077aed3SPierre Pronchery ossl_keccak_kmac_init(ctx, pad, bitlen); \
227*b077aed3SPierre Pronchery ctx->meth = sha3_generic_md; \
228*b077aed3SPierre Pronchery return ctx; \
229*b077aed3SPierre Pronchery }
230*b077aed3SPierre Pronchery
231*b077aed3SPierre Pronchery #define PROV_FUNC_SHA3_DIGEST_COMMON(name, bitlen, blksize, dgstsize, flags) \
232*b077aed3SPierre Pronchery PROV_FUNC_DIGEST_GET_PARAM(name, blksize, dgstsize, flags) \
233*b077aed3SPierre Pronchery const OSSL_DISPATCH ossl_##name##_functions[] = { \
234*b077aed3SPierre Pronchery { OSSL_FUNC_DIGEST_NEWCTX, (void (*)(void))name##_newctx }, \
235*b077aed3SPierre Pronchery { OSSL_FUNC_DIGEST_UPDATE, (void (*)(void))keccak_update }, \
236*b077aed3SPierre Pronchery { OSSL_FUNC_DIGEST_FINAL, (void (*)(void))keccak_final }, \
237*b077aed3SPierre Pronchery { OSSL_FUNC_DIGEST_FREECTX, (void (*)(void))keccak_freectx }, \
238*b077aed3SPierre Pronchery { OSSL_FUNC_DIGEST_DUPCTX, (void (*)(void))keccak_dupctx }, \
239*b077aed3SPierre Pronchery PROV_DISPATCH_FUNC_DIGEST_GET_PARAMS(name)
240*b077aed3SPierre Pronchery
241*b077aed3SPierre Pronchery #define PROV_FUNC_SHA3_DIGEST(name, bitlen, blksize, dgstsize, flags) \
242*b077aed3SPierre Pronchery PROV_FUNC_SHA3_DIGEST_COMMON(name, bitlen, blksize, dgstsize, flags), \
243*b077aed3SPierre Pronchery { OSSL_FUNC_DIGEST_INIT, (void (*)(void))keccak_init }, \
244*b077aed3SPierre Pronchery PROV_DISPATCH_FUNC_DIGEST_CONSTRUCT_END
245*b077aed3SPierre Pronchery
246*b077aed3SPierre Pronchery #define PROV_FUNC_SHAKE_DIGEST(name, bitlen, blksize, dgstsize, flags) \
247*b077aed3SPierre Pronchery PROV_FUNC_SHA3_DIGEST_COMMON(name, bitlen, blksize, dgstsize, flags), \
248*b077aed3SPierre Pronchery { OSSL_FUNC_DIGEST_INIT, (void (*)(void))keccak_init_params }, \
249*b077aed3SPierre Pronchery { OSSL_FUNC_DIGEST_SET_CTX_PARAMS, (void (*)(void))shake_set_ctx_params }, \
250*b077aed3SPierre Pronchery { OSSL_FUNC_DIGEST_SETTABLE_CTX_PARAMS, \
251*b077aed3SPierre Pronchery (void (*)(void))shake_settable_ctx_params }, \
252*b077aed3SPierre Pronchery PROV_DISPATCH_FUNC_DIGEST_CONSTRUCT_END
253*b077aed3SPierre Pronchery
keccak_freectx(void * vctx)254*b077aed3SPierre Pronchery static void keccak_freectx(void *vctx)
255*b077aed3SPierre Pronchery {
256*b077aed3SPierre Pronchery KECCAK1600_CTX *ctx = (KECCAK1600_CTX *)vctx;
257*b077aed3SPierre Pronchery
258*b077aed3SPierre Pronchery OPENSSL_clear_free(ctx, sizeof(*ctx));
259*b077aed3SPierre Pronchery }
260*b077aed3SPierre Pronchery
keccak_dupctx(void * ctx)261*b077aed3SPierre Pronchery static void *keccak_dupctx(void *ctx)
262*b077aed3SPierre Pronchery {
263*b077aed3SPierre Pronchery KECCAK1600_CTX *in = (KECCAK1600_CTX *)ctx;
264*b077aed3SPierre Pronchery KECCAK1600_CTX *ret = ossl_prov_is_running() ? OPENSSL_malloc(sizeof(*ret))
265*b077aed3SPierre Pronchery : NULL;
266*b077aed3SPierre Pronchery
267*b077aed3SPierre Pronchery if (ret != NULL)
268*b077aed3SPierre Pronchery *ret = *in;
269*b077aed3SPierre Pronchery return ret;
270*b077aed3SPierre Pronchery }
271*b077aed3SPierre Pronchery
272*b077aed3SPierre Pronchery static const OSSL_PARAM known_shake_settable_ctx_params[] = {
273*b077aed3SPierre Pronchery {OSSL_DIGEST_PARAM_XOFLEN, OSSL_PARAM_UNSIGNED_INTEGER, NULL, 0, 0},
274*b077aed3SPierre Pronchery OSSL_PARAM_END
275*b077aed3SPierre Pronchery };
shake_settable_ctx_params(ossl_unused void * ctx,ossl_unused void * provctx)276*b077aed3SPierre Pronchery static const OSSL_PARAM *shake_settable_ctx_params(ossl_unused void *ctx,
277*b077aed3SPierre Pronchery ossl_unused void *provctx)
278*b077aed3SPierre Pronchery {
279*b077aed3SPierre Pronchery return known_shake_settable_ctx_params;
280*b077aed3SPierre Pronchery }
281*b077aed3SPierre Pronchery
shake_set_ctx_params(void * vctx,const OSSL_PARAM params[])282*b077aed3SPierre Pronchery static int shake_set_ctx_params(void *vctx, const OSSL_PARAM params[])
283*b077aed3SPierre Pronchery {
284*b077aed3SPierre Pronchery const OSSL_PARAM *p;
285*b077aed3SPierre Pronchery KECCAK1600_CTX *ctx = (KECCAK1600_CTX *)vctx;
286*b077aed3SPierre Pronchery
287*b077aed3SPierre Pronchery if (ctx == NULL)
288*b077aed3SPierre Pronchery return 0;
289*b077aed3SPierre Pronchery if (params == NULL)
290*b077aed3SPierre Pronchery return 1;
291*b077aed3SPierre Pronchery
292*b077aed3SPierre Pronchery p = OSSL_PARAM_locate_const(params, OSSL_DIGEST_PARAM_XOFLEN);
293*b077aed3SPierre Pronchery if (p != NULL && !OSSL_PARAM_get_size_t(p, &ctx->md_size)) {
294*b077aed3SPierre Pronchery ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_GET_PARAMETER);
295*b077aed3SPierre Pronchery return 0;
296*b077aed3SPierre Pronchery }
297*b077aed3SPierre Pronchery return 1;
298*b077aed3SPierre Pronchery }
299*b077aed3SPierre Pronchery
300*b077aed3SPierre Pronchery #define IMPLEMENT_SHA3_functions(bitlen) \
301*b077aed3SPierre Pronchery SHA3_newctx(sha3, SHA3_##bitlen, sha3_##bitlen, bitlen, '\x06') \
302*b077aed3SPierre Pronchery PROV_FUNC_SHA3_DIGEST(sha3_##bitlen, bitlen, \
303*b077aed3SPierre Pronchery SHA3_BLOCKSIZE(bitlen), SHA3_MDSIZE(bitlen), \
304*b077aed3SPierre Pronchery SHA3_FLAGS)
305*b077aed3SPierre Pronchery
306*b077aed3SPierre Pronchery #define IMPLEMENT_SHAKE_functions(bitlen) \
307*b077aed3SPierre Pronchery SHA3_newctx(shake, SHAKE_##bitlen, shake_##bitlen, bitlen, '\x1f') \
308*b077aed3SPierre Pronchery PROV_FUNC_SHAKE_DIGEST(shake_##bitlen, bitlen, \
309*b077aed3SPierre Pronchery SHA3_BLOCKSIZE(bitlen), SHA3_MDSIZE(bitlen), \
310*b077aed3SPierre Pronchery SHAKE_FLAGS)
311*b077aed3SPierre Pronchery #define IMPLEMENT_KMAC_functions(bitlen) \
312*b077aed3SPierre Pronchery KMAC_newctx(keccak_kmac_##bitlen, bitlen, '\x04') \
313*b077aed3SPierre Pronchery PROV_FUNC_SHAKE_DIGEST(keccak_kmac_##bitlen, bitlen, \
314*b077aed3SPierre Pronchery SHA3_BLOCKSIZE(bitlen), KMAC_MDSIZE(bitlen), \
315*b077aed3SPierre Pronchery KMAC_FLAGS)
316*b077aed3SPierre Pronchery
317*b077aed3SPierre Pronchery /* ossl_sha3_224_functions */
318*b077aed3SPierre Pronchery IMPLEMENT_SHA3_functions(224)
319*b077aed3SPierre Pronchery /* ossl_sha3_256_functions */
320*b077aed3SPierre Pronchery IMPLEMENT_SHA3_functions(256)
321*b077aed3SPierre Pronchery /* ossl_sha3_384_functions */
322*b077aed3SPierre Pronchery IMPLEMENT_SHA3_functions(384)
323*b077aed3SPierre Pronchery /* ossl_sha3_512_functions */
324*b077aed3SPierre Pronchery IMPLEMENT_SHA3_functions(512)
325*b077aed3SPierre Pronchery /* ossl_shake_128_functions */
326*b077aed3SPierre Pronchery IMPLEMENT_SHAKE_functions(128)
327*b077aed3SPierre Pronchery /* ossl_shake_256_functions */
328*b077aed3SPierre Pronchery IMPLEMENT_SHAKE_functions(256)
329*b077aed3SPierre Pronchery /* ossl_keccak_kmac_128_functions */
330*b077aed3SPierre Pronchery IMPLEMENT_KMAC_functions(128)
331*b077aed3SPierre Pronchery /* ossl_keccak_kmac_256_functions */
332*b077aed3SPierre Pronchery IMPLEMENT_KMAC_functions(256)
333