diff options
author | Shane Lontis <shane.lontis@oracle.com> | 2021-05-14 13:08:42 +1000 |
---|---|---|
committer | Pauli <pauli@openssl.org> | 2021-05-24 10:12:18 +1000 |
commit | 7c14d0c1c0ece97f7406b4df466df6439146d6c6 (patch) | |
tree | 0df7120b66ec8b6cc4072492822fa071fd1288ef /crypto/evp/mac_lib.c | |
parent | c45df3302d20291ff1125f1aeb82fae1cdceaac8 (diff) |
Rename the field 'provctx and data' to 'algctx' inside some objects containing
pointers to provider size algorithm contexts.
Fixes #14284
The gettable_ctx_params methods were confusingly passing a 'provctx' and
a provider context which are completely different objects.
Some objects such as EVP_KDF used 'data' while others such as EVP_MD used 'provctx'.
For libcrypto this 'ctx' is an opaque ptr returned when a providers algorithm
implementation creates an internal context using a new_ctx() method.
Hence the new name 'algctx'.
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15275)
Diffstat (limited to 'crypto/evp/mac_lib.c')
-rw-r--r-- | crypto/evp/mac_lib.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/crypto/evp/mac_lib.c b/crypto/evp/mac_lib.c index 8a34df3757..eef37e882c 100644 --- a/crypto/evp/mac_lib.c +++ b/crypto/evp/mac_lib.c @@ -24,11 +24,11 @@ EVP_MAC_CTX *EVP_MAC_CTX_new(EVP_MAC *mac) EVP_MAC_CTX *ctx = OPENSSL_zalloc(sizeof(EVP_MAC_CTX)); if (ctx == NULL - || (ctx->data = mac->newctx(ossl_provider_ctx(mac->prov))) == NULL + || (ctx->algctx = mac->newctx(ossl_provider_ctx(mac->prov))) == NULL || !EVP_MAC_up_ref(mac)) { ERR_raise(ERR_LIB_EVP, ERR_R_MALLOC_FAILURE); if (ctx != NULL) - mac->freectx(ctx->data); + mac->freectx(ctx->algctx); OPENSSL_free(ctx); ctx = NULL; } else { @@ -41,8 +41,8 @@ void EVP_MAC_CTX_free(EVP_MAC_CTX *ctx) { if (ctx == NULL) return; - ctx->meth->freectx(ctx->data); - ctx->data = NULL; + ctx->meth->freectx(ctx->algctx); + ctx->algctx = NULL; /* refcnt-- */ EVP_MAC_free(ctx->meth); OPENSSL_free(ctx); @@ -52,7 +52,7 @@ EVP_MAC_CTX *EVP_MAC_CTX_dup(const EVP_MAC_CTX *src) { EVP_MAC_CTX *dst; - if (src->data == NULL) + if (src->algctx == NULL) return NULL; dst = OPENSSL_malloc(sizeof(*dst)); @@ -68,8 +68,8 @@ EVP_MAC_CTX *EVP_MAC_CTX_dup(const EVP_MAC_CTX *src) return NULL; } - dst->data = src->meth->dupctx(src->data); - if (dst->data == NULL) { + dst->algctx = src->meth->dupctx(src->algctx); + if (dst->algctx == NULL) { EVP_MAC_CTX_free(dst); return NULL; } @@ -86,12 +86,12 @@ size_t EVP_MAC_CTX_get_mac_size(EVP_MAC_CTX *ctx) { size_t sz = 0; - if (ctx->data != NULL) { + if (ctx->algctx != NULL) { OSSL_PARAM params[2] = { OSSL_PARAM_END, OSSL_PARAM_END }; params[0] = OSSL_PARAM_construct_size_t(OSSL_MAC_PARAM_SIZE, &sz); if (ctx->meth->get_ctx_params != NULL) { - if (ctx->meth->get_ctx_params(ctx->data, params)) + if (ctx->meth->get_ctx_params(ctx->algctx, params)) return sz; } else if (ctx->meth->get_params != NULL) { if (ctx->meth->get_params(params)) @@ -108,12 +108,12 @@ size_t EVP_MAC_CTX_get_mac_size(EVP_MAC_CTX *ctx) int EVP_MAC_init(EVP_MAC_CTX *ctx, const unsigned char *key, size_t keylen, const OSSL_PARAM params[]) { - return ctx->meth->init(ctx->data, key, keylen, params); + return ctx->meth->init(ctx->algctx, key, keylen, params); } int EVP_MAC_update(EVP_MAC_CTX *ctx, const unsigned char *data, size_t datalen) { - return ctx->meth->update(ctx->data, data, datalen); + return ctx->meth->update(ctx->algctx, data, datalen); } static int evp_mac_final(EVP_MAC_CTX *ctx, int xof, @@ -149,7 +149,7 @@ static int evp_mac_final(EVP_MAC_CTX *ctx, int xof, return 0; } } - res = ctx->meth->final(ctx->data, out, &l, outsize); + res = ctx->meth->final(ctx->algctx, out, &l, outsize); if (outl != NULL) *outl = l; return res; @@ -182,14 +182,14 @@ int EVP_MAC_get_params(EVP_MAC *mac, OSSL_PARAM params[]) int EVP_MAC_CTX_get_params(EVP_MAC_CTX *ctx, OSSL_PARAM params[]) { if (ctx->meth->get_ctx_params != NULL) - return ctx->meth->get_ctx_params(ctx->data, params); + return ctx->meth->get_ctx_params(ctx->algctx, params); return 1; } int EVP_MAC_CTX_set_params(EVP_MAC_CTX *ctx, const OSSL_PARAM params[]) { if (ctx->meth->set_ctx_params != NULL) - return ctx->meth->set_ctx_params(ctx->data, params); + return ctx->meth->set_ctx_params(ctx->algctx, params); return 1; } |