Skip to content

Commit d9c2fd5

Browse files
committed
The EVP_MAC functions have been renamed for consistency. The EVP_MAC_CTX_*
functions are now EVP_MAC functions, usually with ctx in their names. Before 3.0 is released, the names are mutable and this prevents more inconsistencies being introduced. There are no functional or code changes. Just the renaming and a little reformatting. Reviewed-by: Richard Levitte <[email protected]> (Merged from openssl#11997)
1 parent 765d04c commit d9c2fd5

36 files changed

+226
-207
lines changed

CHANGES.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -361,8 +361,8 @@ OpenSSL 3.0
361361
and HMAC_CTX_get_md.
362362

363363
Use of these low level functions has been informally discouraged for a long
364-
time. Instead applications should use L<EVP_MAC_CTX_new(3)>,
365-
L<EVP_MAC_CTX_free(3)>, L<EVP_MAC_init(3)>, L<EVP_MAC_update(3)>
364+
time. Instead applications should use L<EVP_MAC_new_ctx(3)>,
365+
L<EVP_MAC_free_ctx(3)>, L<EVP_MAC_init(3)>, L<EVP_MAC_update(3)>
366366
and L<EVP_MAC_final(3)>.
367367

368368
*Paul Dale*
@@ -385,8 +385,8 @@ OpenSSL 3.0
385385
CMAC_CTX_copy, CMAC_Init, CMAC_Update, CMAC_Final and CMAC_resume.
386386

387387
Use of these low level functions has been informally discouraged for a long
388-
time. Instead applications should use L<EVP_MAC_CTX_new(3)>,
389-
L<EVP_MAC_CTX_free(3)>, L<EVP_MAC_init(3)>, L<EVP_MAC_update(3)>
388+
time. Instead applications should use L<EVP_MAC_new_ctx(3)>,
389+
L<EVP_MAC_free_ctx(3)>, L<EVP_MAC_init(3)>, L<EVP_MAC_update(3)>
390390
and L<EVP_MAC_final(3)>.
391391

392392
*Paul Dale*

apps/fipsinstall.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ int fipsinstall_main(int argc, char **argv)
366366
goto end;
367367
}
368368

369-
ctx = EVP_MAC_CTX_new(mac);
369+
ctx = EVP_MAC_new_ctx(mac);
370370
if (ctx == NULL) {
371371
BIO_printf(bio_err, "Unable to create MAC CTX for module check\n");
372372
goto end;
@@ -380,7 +380,7 @@ int fipsinstall_main(int argc, char **argv)
380380
if (params == NULL)
381381
goto end;
382382

383-
if (!EVP_MAC_CTX_set_params(ctx, params)) {
383+
if (!EVP_MAC_set_ctx_params(ctx, params)) {
384384
BIO_printf(bio_err, "MAC parameter error\n");
385385
ERR_print_errors(bio_err);
386386
ok = 0;
@@ -390,7 +390,7 @@ int fipsinstall_main(int argc, char **argv)
390390
goto end;
391391
}
392392

393-
ctx2 = EVP_MAC_CTX_dup(ctx);
393+
ctx2 = EVP_MAC_dup_ctx(ctx);
394394
if (ctx2 == NULL) {
395395
BIO_printf(bio_err, "Unable to create MAC CTX for install indicator\n");
396396
goto end;
@@ -450,8 +450,8 @@ int fipsinstall_main(int argc, char **argv)
450450
BIO_free(module_bio);
451451
sk_OPENSSL_STRING_free(opts);
452452
EVP_MAC_free(mac);
453-
EVP_MAC_CTX_free(ctx2);
454-
EVP_MAC_CTX_free(ctx);
453+
EVP_MAC_free_ctx(ctx2);
454+
EVP_MAC_free_ctx(ctx);
455455
OPENSSL_free(read_buffer);
456456
free_config_and_unload(conf);
457457
return ret;

apps/lib/s_cb.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -787,7 +787,7 @@ int generate_cookie_callback(SSL *ssl, unsigned char *cookie,
787787
BIO_printf(bio_err, "HMAC not found\n");
788788
goto end;
789789
}
790-
ctx = EVP_MAC_CTX_new(hmac);
790+
ctx = EVP_MAC_new_ctx(hmac);
791791
if (ctx == NULL) {
792792
BIO_printf(bio_err, "HMAC context allocation failed\n");
793793
goto end;
@@ -796,7 +796,7 @@ int generate_cookie_callback(SSL *ssl, unsigned char *cookie,
796796
*p++ = OSSL_PARAM_construct_octet_string(OSSL_MAC_PARAM_KEY, cookie_secret,
797797
COOKIE_SECRET_LENGTH);
798798
*p = OSSL_PARAM_construct_end();
799-
if (!EVP_MAC_CTX_set_params(ctx, params)) {
799+
if (!EVP_MAC_set_ctx_params(ctx, params)) {
800800
BIO_printf(bio_err, "HMAC context parameter setting failed\n");
801801
goto end;
802802
}

apps/mac.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ int mac_main(int argc, char **argv)
114114
goto opthelp;
115115
}
116116

117-
ctx = EVP_MAC_CTX_new(mac);
117+
ctx = EVP_MAC_new_ctx(mac);
118118
if (ctx == NULL)
119119
goto err;
120120

@@ -126,7 +126,7 @@ int mac_main(int argc, char **argv)
126126
if (params == NULL)
127127
goto err;
128128

129-
if (!EVP_MAC_CTX_set_params(ctx, params)) {
129+
if (!EVP_MAC_set_ctx_params(ctx, params)) {
130130
BIO_printf(bio_err, "MAC parameter error\n");
131131
ERR_print_errors(bio_err);
132132
ok = 0;
@@ -199,7 +199,7 @@ int mac_main(int argc, char **argv)
199199
sk_OPENSSL_STRING_free(opts);
200200
BIO_free(in);
201201
BIO_free(out);
202-
EVP_MAC_CTX_free(ctx);
202+
EVP_MAC_free_ctx(ctx);
203203
EVP_MAC_free(mac);
204204
return ret;
205205
}

crypto/cmac/cm_ameth.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ static int cmac_size(const EVP_PKEY *pkey)
3131
static void cmac_key_free(EVP_PKEY *pkey)
3232
{
3333
EVP_MAC_CTX *cmctx = EVP_PKEY_get0(pkey);
34-
EVP_MAC *mac = cmctx == NULL ? NULL : EVP_MAC_CTX_mac(cmctx);
34+
EVP_MAC *mac = cmctx == NULL ? NULL : EVP_MAC_get_ctx_mac(cmctx);
3535

36-
EVP_MAC_CTX_free(cmctx);
36+
EVP_MAC_free_ctx(cmctx);
3737
EVP_MAC_free(mac);
3838
}
3939

crypto/crmf/crmf_pbm.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,8 @@ int OSSL_CRMF_pbm_new(const OSSL_CRMF_PBMPARAMETER *pbmp,
202202
macparams[1] = OSSL_PARAM_construct_octet_string(OSSL_MAC_PARAM_KEY,
203203
basekey, bklen);
204204
if ((mac = EVP_MAC_fetch(NULL, "HMAC", NULL)) == NULL
205-
|| (mctx = EVP_MAC_CTX_new(mac)) == NULL
206-
|| !EVP_MAC_CTX_set_params(mctx, macparams)
205+
|| (mctx = EVP_MAC_new_ctx(mac)) == NULL
206+
|| !EVP_MAC_set_ctx_params(mctx, macparams)
207207
|| !EVP_MAC_init(mctx)
208208
|| !EVP_MAC_update(mctx, msg, msglen)
209209
|| !EVP_MAC_final(mctx, mac_res, outlen, EVP_MAX_MD_SIZE))
@@ -214,7 +214,7 @@ int OSSL_CRMF_pbm_new(const OSSL_CRMF_PBMPARAMETER *pbmp,
214214
err:
215215
/* cleanup */
216216
OPENSSL_cleanse(basekey, bklen);
217-
EVP_MAC_CTX_free(mctx);
217+
EVP_MAC_free_ctx(mctx);
218218
EVP_MAC_free(mac);
219219
EVP_MD_CTX_free(ctx);
220220

crypto/err/openssl.txt

-2
Original file line numberDiff line numberDiff line change
@@ -845,8 +845,6 @@ EVP_F_EVP_KEYEXCH_FETCH:245:EVP_KEYEXCH_fetch
845845
EVP_F_EVP_KEYEXCH_FROM_DISPATCH:244:evp_keyexch_from_dispatch
846846
EVP_F_EVP_MAC_CTRL:209:EVP_MAC_ctrl
847847
EVP_F_EVP_MAC_CTRL_STR:210:EVP_MAC_ctrl_str
848-
EVP_F_EVP_MAC_CTX_DUP:211:EVP_MAC_CTX_dup
849-
EVP_F_EVP_MAC_CTX_NEW:213:EVP_MAC_CTX_new
850848
EVP_F_EVP_MAC_INIT:212:EVP_MAC_init
851849
EVP_F_EVP_MD_BLOCK_SIZE:232:EVP_MD_block_size
852850
EVP_F_EVP_MD_CTX_COPY_EX:110:EVP_MD_CTX_copy_ex

crypto/evp/mac_lib.c

+10-10
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@
1919
#include "internal/provider.h"
2020
#include "evp_local.h"
2121

22-
EVP_MAC_CTX *EVP_MAC_CTX_new(EVP_MAC *mac)
22+
EVP_MAC_CTX *EVP_MAC_new_ctx(EVP_MAC *mac)
2323
{
2424
EVP_MAC_CTX *ctx = OPENSSL_zalloc(sizeof(EVP_MAC_CTX));
2525

2626
if (ctx == NULL
2727
|| (ctx->data = mac->newctx(ossl_provider_ctx(mac->prov))) == NULL
2828
|| !EVP_MAC_up_ref(mac)) {
29-
EVPerr(EVP_F_EVP_MAC_CTX_NEW, ERR_R_MALLOC_FAILURE);
29+
EVPerr(0, ERR_R_MALLOC_FAILURE);
3030
if (ctx != NULL)
3131
mac->freectx(ctx->data);
3232
OPENSSL_free(ctx);
@@ -37,7 +37,7 @@ EVP_MAC_CTX *EVP_MAC_CTX_new(EVP_MAC *mac)
3737
return ctx;
3838
}
3939

40-
void EVP_MAC_CTX_free(EVP_MAC_CTX *ctx)
40+
void EVP_MAC_free_ctx(EVP_MAC_CTX *ctx)
4141
{
4242
if (ctx != NULL) {
4343
ctx->meth->freectx(ctx->data);
@@ -48,7 +48,7 @@ void EVP_MAC_CTX_free(EVP_MAC_CTX *ctx)
4848
OPENSSL_free(ctx);
4949
}
5050

51-
EVP_MAC_CTX *EVP_MAC_CTX_dup(const EVP_MAC_CTX *src)
51+
EVP_MAC_CTX *EVP_MAC_dup_ctx(const EVP_MAC_CTX *src)
5252
{
5353
EVP_MAC_CTX *dst;
5454

@@ -57,27 +57,27 @@ EVP_MAC_CTX *EVP_MAC_CTX_dup(const EVP_MAC_CTX *src)
5757

5858
dst = OPENSSL_malloc(sizeof(*dst));
5959
if (dst == NULL) {
60-
EVPerr(EVP_F_EVP_MAC_CTX_DUP, ERR_R_MALLOC_FAILURE);
60+
EVPerr(0, ERR_R_MALLOC_FAILURE);
6161
return NULL;
6262
}
6363

6464
*dst = *src;
6565
if (!EVP_MAC_up_ref(dst->meth)) {
66-
EVPerr(EVP_F_EVP_MAC_CTX_DUP, ERR_R_MALLOC_FAILURE);
66+
EVPerr(0, ERR_R_MALLOC_FAILURE);
6767
OPENSSL_free(dst);
6868
return NULL;
6969
}
7070

7171
dst->data = src->meth->dupctx(src->data);
7272
if (dst->data == NULL) {
73-
EVP_MAC_CTX_free(dst);
73+
EVP_MAC_free_ctx(dst);
7474
return NULL;
7575
}
7676

7777
return dst;
7878
}
7979

80-
EVP_MAC *EVP_MAC_CTX_mac(EVP_MAC_CTX *ctx)
80+
EVP_MAC *EVP_MAC_get_ctx_mac(EVP_MAC_CTX *ctx)
8181
{
8282
return ctx->meth;
8383
}
@@ -144,14 +144,14 @@ int EVP_MAC_get_params(EVP_MAC *mac, OSSL_PARAM params[])
144144
return 1;
145145
}
146146

147-
int EVP_MAC_CTX_get_params(EVP_MAC_CTX *ctx, OSSL_PARAM params[])
147+
int EVP_MAC_get_ctx_params(EVP_MAC_CTX *ctx, OSSL_PARAM params[])
148148
{
149149
if (ctx->meth->get_ctx_params != NULL)
150150
return ctx->meth->get_ctx_params(ctx->data, params);
151151
return 1;
152152
}
153153

154-
int EVP_MAC_CTX_set_params(EVP_MAC_CTX *ctx, const OSSL_PARAM params[])
154+
int EVP_MAC_set_ctx_params(EVP_MAC_CTX *ctx, const OSSL_PARAM params[])
155155
{
156156
if (ctx->meth->set_ctx_params != NULL)
157157
return ctx->meth->set_ctx_params(ctx->data, params);

crypto/evp/p_lib.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@ EVP_PKEY *EVP_PKEY_new_CMAC_key(ENGINE *e, const unsigned char *priv,
595595
prov == NULL ? NULL : ossl_provider_library_context(prov);
596596
EVP_PKEY *ret = EVP_PKEY_new();
597597
EVP_MAC *cmac = EVP_MAC_fetch(libctx, OSSL_MAC_NAME_CMAC, NULL);
598-
EVP_MAC_CTX *cmctx = cmac != NULL ? EVP_MAC_CTX_new(cmac) : NULL;
598+
EVP_MAC_CTX *cmctx = cmac != NULL ? EVP_MAC_new_ctx(cmac) : NULL;
599599
OSSL_PARAM params[4];
600600
size_t paramsn = 0;
601601

@@ -620,7 +620,7 @@ EVP_PKEY *EVP_PKEY_new_CMAC_key(ENGINE *e, const unsigned char *priv,
620620
(char *)priv, len);
621621
params[paramsn] = OSSL_PARAM_construct_end();
622622

623-
if (!EVP_MAC_CTX_set_params(cmctx, params)) {
623+
if (!EVP_MAC_set_ctx_params(cmctx, params)) {
624624
EVPerr(EVP_F_EVP_PKEY_NEW_CMAC_KEY, EVP_R_KEY_SETUP_FAILED);
625625
goto err;
626626
}
@@ -630,7 +630,7 @@ EVP_PKEY *EVP_PKEY_new_CMAC_key(ENGINE *e, const unsigned char *priv,
630630

631631
err:
632632
EVP_PKEY_free(ret);
633-
EVP_MAC_CTX_free(cmctx);
633+
EVP_MAC_free_ctx(cmctx);
634634
EVP_MAC_free(cmac);
635635
return NULL;
636636
# else

0 commit comments

Comments
 (0)