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 #define IMPLEMENT_LEGACY_EVP_MD_METH(nm, fn)                                   \
11*b077aed3SPierre Pronchery static int nm##_init(EVP_MD_CTX *ctx)                                          \
12*b077aed3SPierre Pronchery {                                                                              \
13*b077aed3SPierre Pronchery     return fn##_Init(EVP_MD_CTX_get0_md_data(ctx));                            \
14*b077aed3SPierre Pronchery }                                                                              \
15*b077aed3SPierre Pronchery static int nm##_update(EVP_MD_CTX *ctx, const void *data, size_t count)        \
16*b077aed3SPierre Pronchery {                                                                              \
17*b077aed3SPierre Pronchery     return fn##_Update(EVP_MD_CTX_get0_md_data(ctx), data, count);             \
18*b077aed3SPierre Pronchery }                                                                              \
19*b077aed3SPierre Pronchery static int nm##_final(EVP_MD_CTX *ctx, unsigned char *md)                      \
20*b077aed3SPierre Pronchery {                                                                              \
21*b077aed3SPierre Pronchery     return fn##_Final(md, EVP_MD_CTX_get0_md_data(ctx));                       \
22*b077aed3SPierre Pronchery }
23*b077aed3SPierre Pronchery 
24*b077aed3SPierre Pronchery #define IMPLEMENT_LEGACY_EVP_MD_METH_LC(nm, fn)                                \
25*b077aed3SPierre Pronchery static int nm##_init(EVP_MD_CTX *ctx)                                          \
26*b077aed3SPierre Pronchery {                                                                              \
27*b077aed3SPierre Pronchery     return fn##_init(EVP_MD_CTX_get0_md_data(ctx));                            \
28*b077aed3SPierre Pronchery }                                                                              \
29*b077aed3SPierre Pronchery static int nm##_update(EVP_MD_CTX *ctx, const void *data, size_t count)        \
30*b077aed3SPierre Pronchery {                                                                              \
31*b077aed3SPierre Pronchery     return fn##_update(EVP_MD_CTX_get0_md_data(ctx), data, count);             \
32*b077aed3SPierre Pronchery }                                                                              \
33*b077aed3SPierre Pronchery static int nm##_final(EVP_MD_CTX *ctx, unsigned char *md)                      \
34*b077aed3SPierre Pronchery {                                                                              \
35*b077aed3SPierre Pronchery     return fn##_final(md, EVP_MD_CTX_get0_md_data(ctx));                       \
36*b077aed3SPierre Pronchery }
37*b077aed3SPierre Pronchery 
38*b077aed3SPierre Pronchery 
39*b077aed3SPierre Pronchery #define LEGACY_EVP_MD_METH_TABLE(init, update, final, ctrl, blksz)             \
40*b077aed3SPierre Pronchery     init, update, final, NULL, NULL, blksz, 0, ctrl
41