diff options
author | Matt Caswell <matt@openssl.org> | 2020-06-18 09:26:22 +0100 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2020-07-16 14:21:07 +0200 |
commit | 865adf97c9b8271788ee7293ecde9e8a643a1c45 (patch) | |
tree | d4fe29fa8c0587aa4316dc550d57526559f6f6f3 /providers/implementations/kdfs | |
parent | 8dab4de53887639abc1152288fac76506beb87b3 (diff) |
Revert "The EVP_MAC functions have been renamed for consistency. The EVP_MAC_CTX_*"
The commit claimed to make things more consistent. In fact it makes it
less so. Revert back to the previous namig convention.
This reverts commit d9c2fd51e2e278bc3f7793a104ff7b4879f6d63a.
Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/12186)
Diffstat (limited to 'providers/implementations/kdfs')
-rw-r--r-- | providers/implementations/kdfs/kbkdf.c | 14 | ||||
-rw-r--r-- | providers/implementations/kdfs/sskdf.c | 16 | ||||
-rw-r--r-- | providers/implementations/kdfs/tls1_prf.c | 22 |
3 files changed, 26 insertions, 26 deletions
diff --git a/providers/implementations/kdfs/kbkdf.c b/providers/implementations/kdfs/kbkdf.c index 9cf18d84a2..d25da76d17 100644 --- a/providers/implementations/kdfs/kbkdf.c +++ b/providers/implementations/kdfs/kbkdf.c @@ -122,7 +122,7 @@ static void kbkdf_reset(void *vctx) KBKDF *ctx = (KBKDF *)vctx; void *provctx = ctx->provctx; - EVP_MAC_free_ctx(ctx->ctx_init); + EVP_MAC_CTX_free(ctx->ctx_init); OPENSSL_clear_free(ctx->context, ctx->context_len); OPENSSL_clear_free(ctx->label, ctx->label_len); OPENSSL_clear_free(ctx->ki, ctx->ki_len); @@ -151,7 +151,7 @@ static int derive(EVP_MAC_CTX *ctx_init, kbkdf_mode mode, unsigned char *iv, for (counter = 1; written < ko_len; counter++) { i = be32(counter); - ctx = EVP_MAC_dup_ctx(ctx_init); + ctx = EVP_MAC_CTX_dup(ctx_init); if (ctx == NULL) goto done; @@ -172,13 +172,13 @@ static int derive(EVP_MAC_CTX *ctx_init, kbkdf_mode mode, unsigned char *iv, written += h; k_i_len = h; - EVP_MAC_free_ctx(ctx); + EVP_MAC_CTX_free(ctx); ctx = NULL; } ret = 1; done: - EVP_MAC_free_ctx(ctx); + EVP_MAC_CTX_free(ctx); return ret; } @@ -247,9 +247,9 @@ static int kbkdf_set_ctx_params(void *vctx, const OSSL_PARAM params[]) NULL, NULL, libctx)) return 0; else if (ctx->ctx_init != NULL - && !EVP_MAC_is_a(EVP_MAC_get_ctx_mac(ctx->ctx_init), + && !EVP_MAC_is_a(EVP_MAC_CTX_mac(ctx->ctx_init), OSSL_MAC_NAME_HMAC) - && !EVP_MAC_is_a(EVP_MAC_get_ctx_mac(ctx->ctx_init), + && !EVP_MAC_is_a(EVP_MAC_CTX_mac(ctx->ctx_init), OSSL_MAC_NAME_CMAC)) { ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_MAC); return 0; @@ -288,7 +288,7 @@ static int kbkdf_set_ctx_params(void *vctx, const OSSL_PARAM params[]) ctx->ki, ctx->ki_len); mparams[1] = OSSL_PARAM_construct_end(); - if (!EVP_MAC_set_ctx_params(ctx->ctx_init, mparams) + if (!EVP_MAC_CTX_set_params(ctx->ctx_init, mparams) || !EVP_MAC_init(ctx->ctx_init)) return 0; } diff --git a/providers/implementations/kdfs/sskdf.c b/providers/implementations/kdfs/sskdf.c index 6d6e3295c8..5ef73644f0 100644 --- a/providers/implementations/kdfs/sskdf.c +++ b/providers/implementations/kdfs/sskdf.c @@ -168,7 +168,7 @@ static int kmac_init(EVP_MAC_CTX *ctx, const unsigned char *custom, (void *)custom, custom_len); params[1] = OSSL_PARAM_construct_end(); - if (!EVP_MAC_set_ctx_params(ctx, params)) + if (!EVP_MAC_CTX_set_params(ctx, params)) return 0; /* By default only do one iteration if kmac_out_len is not specified */ @@ -186,7 +186,7 @@ static int kmac_init(EVP_MAC_CTX *ctx, const unsigned char *custom, params[0] = OSSL_PARAM_construct_size_t(OSSL_MAC_PARAM_SIZE, &kmac_out_len); - if (EVP_MAC_set_ctx_params(ctx, params) <= 0) + if (EVP_MAC_CTX_set_params(ctx, params) <= 0) return 0; /* @@ -233,7 +233,7 @@ static int SSKDF_mac_kdm(EVP_MAC_CTX *ctx_init, (void *)salt, salt_len); *p = OSSL_PARAM_construct_end(); - if (!EVP_MAC_set_ctx_params(ctx_init, params)) + if (!EVP_MAC_CTX_set_params(ctx_init, params)) goto end; if (!kmac_init(ctx_init, kmac_custom, kmac_custom_len, kmac_out_len, @@ -256,7 +256,7 @@ static int SSKDF_mac_kdm(EVP_MAC_CTX *ctx_init, c[2] = (unsigned char)((counter >> 8) & 0xff); c[3] = (unsigned char)(counter & 0xff); - ctx = EVP_MAC_dup_ctx(ctx_init); + ctx = EVP_MAC_CTX_dup(ctx_init); if (!(ctx != NULL && EVP_MAC_update(ctx, c, sizeof(c)) && EVP_MAC_update(ctx, z, z_len) @@ -275,7 +275,7 @@ static int SSKDF_mac_kdm(EVP_MAC_CTX *ctx_init, memcpy(out, mac, len); break; } - EVP_MAC_free_ctx(ctx); + EVP_MAC_CTX_free(ctx); ctx = NULL; } ret = 1; @@ -285,7 +285,7 @@ end: else OPENSSL_cleanse(mac_buf, sizeof(mac_buf)); - EVP_MAC_free_ctx(ctx); + EVP_MAC_CTX_free(ctx); return ret; } @@ -304,7 +304,7 @@ static void sskdf_reset(void *vctx) KDF_SSKDF *ctx = (KDF_SSKDF *)vctx; void *provctx = ctx->provctx; - EVP_MAC_free_ctx(ctx->macctx); + EVP_MAC_CTX_free(ctx->macctx); ossl_prov_digest_reset(&ctx->digest); OPENSSL_clear_free(ctx->secret, ctx->secret_len); OPENSSL_clear_free(ctx->info, ctx->info_len); @@ -362,7 +362,7 @@ static int sskdf_derive(void *vctx, unsigned char *key, size_t keylen) const unsigned char *custom = NULL; size_t custom_len = 0; int default_salt_len; - EVP_MAC *mac = EVP_MAC_get_ctx_mac(ctx->macctx); + EVP_MAC *mac = EVP_MAC_CTX_mac(ctx->macctx); /* * TODO(3.0) investigate the necessity to have all these controls. diff --git a/providers/implementations/kdfs/tls1_prf.c b/providers/implementations/kdfs/tls1_prf.c index d90a1bd072..73437531f6 100644 --- a/providers/implementations/kdfs/tls1_prf.c +++ b/providers/implementations/kdfs/tls1_prf.c @@ -117,8 +117,8 @@ static void kdf_tls1_prf_reset(void *vctx) TLS1_PRF *ctx = (TLS1_PRF *)vctx; void *provctx = ctx->provctx; - EVP_MAC_free_ctx(ctx->P_hash); - EVP_MAC_free_ctx(ctx->P_sha1); + EVP_MAC_CTX_free(ctx->P_hash); + EVP_MAC_CTX_free(ctx->P_sha1); OPENSSL_clear_free(ctx->sec, ctx->seclen); OPENSSL_cleanse(ctx->seed, ctx->seedlen); memset(ctx, 0, sizeof(*ctx)); @@ -165,7 +165,7 @@ static int kdf_tls1_prf_set_ctx_params(void *vctx, const OSSL_PARAM params[]) NULL, SN_sha1, libctx)) return 0; } else { - EVP_MAC_free_ctx(ctx->P_sha1); + EVP_MAC_CTX_free(ctx->P_sha1); if (!ossl_prov_macctx_load_from_params(&ctx->P_hash, params, OSSL_MAC_NAME_HMAC, NULL, NULL, libctx)) @@ -282,7 +282,7 @@ static int tls1_prf_P_hash(EVP_MAC_CTX *ctx_init, *p++ = OSSL_PARAM_construct_octet_string(OSSL_MAC_PARAM_KEY, (void *)sec, sec_len); *p = OSSL_PARAM_construct_end(); - if (!EVP_MAC_set_ctx_params(ctx_init, params)) + if (!EVP_MAC_CTX_set_params(ctx_init, params)) goto err; if (!EVP_MAC_init(ctx_init)) goto err; @@ -290,7 +290,7 @@ static int tls1_prf_P_hash(EVP_MAC_CTX *ctx_init, if (chunk == 0) goto err; /* A(0) = seed */ - ctx_Ai = EVP_MAC_dup_ctx(ctx_init); + ctx_Ai = EVP_MAC_CTX_dup(ctx_init); if (ctx_Ai == NULL) goto err; if (seed != NULL && !EVP_MAC_update(ctx_Ai, seed, seed_len)) @@ -300,18 +300,18 @@ static int tls1_prf_P_hash(EVP_MAC_CTX *ctx_init, /* calc: A(i) = HMAC_<hash>(secret, A(i-1)) */ if (!EVP_MAC_final(ctx_Ai, Ai, &Ai_len, sizeof(Ai))) goto err; - EVP_MAC_free_ctx(ctx_Ai); + EVP_MAC_CTX_free(ctx_Ai); ctx_Ai = NULL; /* calc next chunk: HMAC_<hash>(secret, A(i) + seed) */ - ctx = EVP_MAC_dup_ctx(ctx_init); + ctx = EVP_MAC_CTX_dup(ctx_init); if (ctx == NULL) goto err; if (!EVP_MAC_update(ctx, Ai, Ai_len)) goto err; /* save state for calculating next A(i) value */ if (olen > chunk) { - ctx_Ai = EVP_MAC_dup_ctx(ctx); + ctx_Ai = EVP_MAC_CTX_dup(ctx); if (ctx_Ai == NULL) goto err; } @@ -326,15 +326,15 @@ static int tls1_prf_P_hash(EVP_MAC_CTX *ctx_init, } if (!EVP_MAC_final(ctx, out, NULL, olen)) goto err; - EVP_MAC_free_ctx(ctx); + EVP_MAC_CTX_free(ctx); ctx = NULL; out += chunk; olen -= chunk; } ret = 1; err: - EVP_MAC_free_ctx(ctx); - EVP_MAC_free_ctx(ctx_Ai); + EVP_MAC_CTX_free(ctx); + EVP_MAC_CTX_free(ctx_Ai); OPENSSL_cleanse(Ai, sizeof(Ai)); return ret; } |