Replace OSSL_PARAM_BLD_free_params() with OSSL_PARAM_free().

Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/14785)
This commit is contained in:
Shane Lontis 2021-04-07 13:45:19 +10:00
parent 884314cab7
commit 3f883c7c83
30 changed files with 63 additions and 74 deletions

View File

@ -396,7 +396,7 @@ static EVP_PKEY *dsa_to_dh(EVP_PKEY *dh)
err:
EVP_PKEY_CTX_free(ctx);
OSSL_PARAM_BLD_free_params(params);
OSSL_PARAM_free(params);
OSSL_PARAM_BLD_free(tmpl);
BN_free(bn_p);
BN_free(bn_q);

View File

@ -267,7 +267,7 @@ EVP_PKEY *get_dsa(int dsa_bits)
params) <= 0)
pkey = NULL;
err:
OSSL_PARAM_BLD_free_params(params);
OSSL_PARAM_free(params);
OSSL_PARAM_BLD_free(tmpl);
BN_free(priv_key);
BN_free(pub_key);

View File

@ -497,7 +497,7 @@ static int dh_pkey_export_to(const EVP_PKEY *from, void *to_keydata,
/* We export, the provider imports */
rv = evp_keymgmt_import(to_keymgmt, to_keydata, selection, params);
OSSL_PARAM_BLD_free_params(params);
OSSL_PARAM_free(params);
err:
OSSL_PARAM_BLD_free(tmpl);
return rv;

View File

@ -474,7 +474,7 @@ static int dsa_pkey_export_to(const EVP_PKEY *from, void *to_keydata,
/* We export, the provider imports */
rv = evp_keymgmt_import(to_keymgmt, to_keydata, selection, params);
OSSL_PARAM_BLD_free_params(params);
OSSL_PARAM_free(params);
err:
OSSL_PARAM_BLD_free(tmpl);
return rv;

View File

@ -611,7 +611,7 @@ int ec_pkey_export_to(const EVP_PKEY *from, void *to_keydata,
err:
OSSL_PARAM_BLD_free(tmpl);
OSSL_PARAM_BLD_free_params(params);
OSSL_PARAM_free(params);
OPENSSL_free(pub_key_buf);
OPENSSL_free(gen_buf);
BN_CTX_end(bnctx);

View File

@ -379,7 +379,7 @@ static int ecx_pkey_export_to(const EVP_PKEY *from, void *to_keydata,
err:
OSSL_PARAM_BLD_free(tmpl);
OSSL_PARAM_BLD_free_params(params);
OSSL_PARAM_free(params);
return rv;
}

View File

@ -377,8 +377,3 @@ OSSL_PARAM *OSSL_PARAM_BLD_to_param(OSSL_PARAM_BLD *bld)
free_all_params(bld);
return params;
}
void OSSL_PARAM_BLD_free_params(OSSL_PARAM *params)
{
OSSL_PARAM_free(params);
}

View File

@ -781,7 +781,7 @@ static int rsa_int_export_to(const EVP_PKEY *from, int rsa_type,
rv = evp_keymgmt_import(to_keymgmt, to_keydata, selection, params);
err:
OSSL_PARAM_BLD_free_params(params);
OSSL_PARAM_free(params);
OSSL_PARAM_BLD_free(tmpl);
return rv;
}

View File

@ -337,7 +337,7 @@ int OSSL_STORE_find(OSSL_STORE_CTX *ctx, const OSSL_STORE_SEARCH *search)
params = OSSL_PARAM_BLD_to_param(bld);
ret = ctx->fetched_loader->p_set_ctx_params(ctx->loader_ctx,
params);
OSSL_PARAM_BLD_free_params(params);
OSSL_PARAM_free(params);
}
OSSL_PARAM_BLD_free(bld);
OPENSSL_free(name_der);

View File

@ -198,7 +198,7 @@ TODO Write a set of cookbook documents and link to them.
EVP_PKEY_free(pkey);
EVP_PKEY_CTX_free(ctx);
OSSL_PARAM_BLD_free_params(params);
OSSL_PARAM_free(params);
OSSL_PARAM_BLD_free(param_bld);
BN_free(priv);

View File

@ -3,7 +3,7 @@
=head1 NAME
OSSL_PARAM_BLD, OSSL_PARAM_BLD_new, OSSL_PARAM_BLD_to_param,
OSSL_PARAM_BLD_free_params, OSSL_PARAM_BLD_free, OSSL_PARAM_BLD_push_int,
OSSL_PARAM_BLD_free, OSSL_PARAM_BLD_push_int,
OSSL_PARAM_BLD_push_uint, OSSL_PARAM_BLD_push_long,
OSSL_PARAM_BLD_push_ulong, OSSL_PARAM_BLD_push_int32,
OSSL_PARAM_BLD_push_uint32, OSSL_PARAM_BLD_push_int64,
@ -24,7 +24,6 @@ OSSL_PARAM_BLD_push_octet_string, OSSL_PARAM_BLD_push_octet_ptr
OSSL_PARAM_BLD *OSSL_PARAM_BLD_new(void);
OSSL_PARAM *OSSL_PARAM_BLD_to_param(OSSL_PARAM_BLD *bld);
void OSSL_PARAM_BLD_free_params(OSSL_PARAM *params);
void OSSL_PARAM_BLD_free(OSSL_PARAM_BLD *bld);
int OSSL_PARAM_BLD_push_TYPE(OSSL_PARAM_BLD *bld, const char *key, TYPE val);
@ -58,12 +57,9 @@ OSSL_PARAM_BLD_free() deallocates the memory allocates by OSSL_PARAM_BLD_new().
OSSL_PARAM_BLD_to_param() converts a built up OSSL_PARAM_BLD structure
I<bld> into an allocated OSSL_PARAM array.
The OSSL_PARAM array and all associated storage must be freed by calling
OSSL_PARAM_BLD_free_params() with the functions return value.
OSSL_PARAM_free() with the functions return value.
OSSL_PARAM_BLD_free() can safely be called any time after this function is.
OSSL_PARAM_BLD_free_params() deallocates the memory allocated by
OSSL_PARAM_BLD_to_param().
=begin comment
POD is pretty good at recognising function names and making them appropriately
@ -155,7 +151,7 @@ private key.
OSSL_PARAM_BLD_free(bld);
/* Use params */
...
OSSL_PARAM_BLD_free_params(params);
OSSL_PARAM_free(params);
=head2 Example 2
@ -173,11 +169,11 @@ public key.
OSSL_PARAM_BLD_free(bld);
/* Use params */
...
OSSL_PARAM_BLD_free_params(params);
OSSL_PARAM_free(params);
=head1 SEE ALSO
L<OSSL_PARAM_int(3)>, L<OSSL_PARAM(3)>
L<OSSL_PARAM_int(3)>, L<OSSL_PARAM(3)>, L<OSSL_PARAM_free(3)>
=head1 HISTORY

View File

@ -22,7 +22,6 @@ extern "C" {
OSSL_PARAM_BLD *OSSL_PARAM_BLD_new(void);
OSSL_PARAM *OSSL_PARAM_BLD_to_param(OSSL_PARAM_BLD *bld);
void OSSL_PARAM_BLD_free(OSSL_PARAM_BLD *bld);
void OSSL_PARAM_BLD_free_params(OSSL_PARAM *params);
int OSSL_PARAM_BLD_push_int(OSSL_PARAM_BLD *bld, const char *key, int val);
int OSSL_PARAM_BLD_push_uint(OSSL_PARAM_BLD *bld, const char *key,

View File

@ -233,7 +233,7 @@ err:
EVP_KDF_free(kdf);
EVP_KDF_CTX_free(ctx);
BN_CTX_free(bnctx);
OSSL_PARAM_BLD_free_params(params);
OSSL_PARAM_free(params);
OSSL_PARAM_BLD_free(bld);
OSSL_SELF_TEST_onend(st, ret);
return ret;
@ -420,8 +420,8 @@ err:
EVP_PKEY_free(peerkey);
EVP_PKEY_CTX_free(kactx);
EVP_PKEY_CTX_free(dctx);
OSSL_PARAM_BLD_free_params(params_peer);
OSSL_PARAM_BLD_free_params(params);
OSSL_PARAM_free(params_peer);
OSSL_PARAM_free(params);
OSSL_PARAM_BLD_free(bld);
OSSL_SELF_TEST_onend(st, ret);
return ret;
@ -505,8 +505,8 @@ err:
EVP_PKEY_free(pkey);
EVP_PKEY_CTX_free(kctx);
EVP_PKEY_CTX_free(sctx);
OSSL_PARAM_BLD_free_params(params);
OSSL_PARAM_BLD_free_params(params_sig);
OSSL_PARAM_free(params);
OSSL_PARAM_free(params_sig);
OSSL_PARAM_BLD_free(bld);
OSSL_SELF_TEST_onend(st, ret);
return ret;
@ -591,9 +591,9 @@ err:
EVP_PKEY_free(key);
EVP_PKEY_CTX_free(encctx);
EVP_PKEY_CTX_free(keyctx);
OSSL_PARAM_BLD_free_params(keyparams);
OSSL_PARAM_free(keyparams);
OSSL_PARAM_BLD_free(keybld);
OSSL_PARAM_BLD_free_params(initparams);
OSSL_PARAM_free(initparams);
OSSL_PARAM_BLD_free(initbld);
OSSL_SELF_TEST_onend(st, ret);
return ret;

View File

@ -212,7 +212,7 @@ static int dh_export(void *keydata, int selection, OSSL_CALLBACK *param_cb,
goto err;
}
ok = param_cb(params, cbarg);
OSSL_PARAM_BLD_free_params(params);
OSSL_PARAM_free(params);
err:
OSSL_PARAM_BLD_free(tmpl);
return ok;

View File

@ -208,7 +208,7 @@ static int dsa_export(void *keydata, int selection, OSSL_CALLBACK *param_cb,
goto err;;
ok = param_cb(params, cbarg);
OSSL_PARAM_BLD_free_params(params);
OSSL_PARAM_free(params);
err:
OSSL_PARAM_BLD_free(tmpl);
return ok;

View File

@ -489,7 +489,7 @@ int ec_export(void *keydata, int selection, OSSL_CALLBACK *param_cb,
if (ok && (params = OSSL_PARAM_BLD_to_param(tmpl)) != NULL)
ok = param_cb(params, cbarg);
end:
OSSL_PARAM_BLD_free_params(params);
OSSL_PARAM_free(params);
OSSL_PARAM_BLD_free(tmpl);
OPENSSL_free(pub_key);
OPENSSL_free(genbuf);
@ -1158,7 +1158,7 @@ build:
ret = 1;
err:
OSSL_PARAM_BLD_free_params(params);
OSSL_PARAM_free(params);
OSSL_PARAM_BLD_free(bld);
return ret;
}

View File

@ -236,7 +236,7 @@ static int ecx_export(void *keydata, int selection, OSSL_CALLBACK *param_cb,
goto err;
ret = param_cb(params, cbarg);
OSSL_PARAM_BLD_free_params(params);
OSSL_PARAM_free(params);
err:
OSSL_PARAM_BLD_free(tmpl);
return ret;

View File

@ -291,7 +291,7 @@ static int mac_export(void *keydata, int selection, OSSL_CALLBACK *param_cb,
goto err;
ret = param_cb(params, cbarg);
OSSL_PARAM_BLD_free_params(params);
OSSL_PARAM_free(params);
err:
OSSL_PARAM_BLD_free(tmpl);
return ret;

View File

@ -207,7 +207,7 @@ static int rsa_export(void *keydata, int selection,
goto err;
ok = param_callback(params, cbarg);
OSSL_PARAM_BLD_free_params(params);
OSSL_PARAM_free(params);
err:
OSSL_PARAM_BLD_free(tmpl);
return ok;

View File

@ -2104,7 +2104,7 @@ static int tls_process_ske_dhe(SSL *s, PACKET *pkt, EVP_PKEY **pkey)
err:
OSSL_PARAM_BLD_free(tmpl);
OSSL_PARAM_BLD_free_params(params);
OSSL_PARAM_free(params);
EVP_PKEY_free(peer_tmp);
EVP_PKEY_CTX_free(pctx);
BN_free(p);

View File

@ -2916,7 +2916,7 @@ EVP_PKEY *ssl_get_auto_dh(SSL *s)
goto err;
err:
OSSL_PARAM_BLD_free_params(params);
OSSL_PARAM_free(params);
OSSL_PARAM_BLD_free(tmpl);
EVP_PKEY_CTX_free(pctx);
BN_free(p);

View File

@ -176,7 +176,7 @@ static int ecdsa_create_pkey(EVP_PKEY **pkey, const char *curve_name,
ret = 1;
err:
OSSL_PARAM_BLD_free_params(params);
OSSL_PARAM_free(params);
OSSL_PARAM_BLD_free(bld);
EVP_PKEY_CTX_free(ctx);
return ret;
@ -517,7 +517,7 @@ static int dsa_create_pkey(EVP_PKEY **pkey,
ret = 1;
err:
OSSL_PARAM_BLD_free_params(params);
OSSL_PARAM_free(params);
OSSL_PARAM_BLD_free(bld);
EVP_PKEY_CTX_free(ctx);
return ret;
@ -939,7 +939,7 @@ static int dh_create_pkey(EVP_PKEY **pkey, const char *group_name,
ret = 1;
err:
OSSL_PARAM_BLD_free_params(params);
OSSL_PARAM_free(params);
OSSL_PARAM_BLD_free(bld);
EVP_PKEY_CTX_free(ctx);
return ret;
@ -1062,7 +1062,7 @@ static int rsa_create_pkey(EVP_PKEY **pkey,
ret = 1;
err:
OSSL_PARAM_BLD_free_params(params);
OSSL_PARAM_free(params);
OSSL_PARAM_BLD_free(bld);
EVP_PKEY_CTX_free(ctx);
return ret;
@ -1170,7 +1170,7 @@ err:
OPENSSL_free(d);
EVP_PKEY_free(pkey);
EVP_PKEY_CTX_free(ctx);
OSSL_PARAM_BLD_free_params(params);
OSSL_PARAM_free(params);
OSSL_PARAM_BLD_free(bld);
return ret;
}

View File

@ -2549,7 +2549,7 @@ err:
BN_free(a_out);
BN_free(b_out);
BN_free(p_out);
OSSL_PARAM_BLD_free_params(params);
OSSL_PARAM_free(params);
OSSL_PARAM_BLD_free(bld);
EVP_PKEY_free(pkeyparam);
EVP_PKEY_CTX_free(pctx);
@ -2896,8 +2896,8 @@ static int custom_params_test(int id)
BN_CTX_end(ctx);
BN_CTX_free(ctx);
OSSL_PARAM_BLD_free(param_bld);
OSSL_PARAM_BLD_free_params(params1);
OSSL_PARAM_BLD_free_params(params2);
OSSL_PARAM_free(params1);
OSSL_PARAM_free(params2);
EC_POINT_free(Q1);
EC_POINT_free(Q2);
EC_POINT_free(G2);

View File

@ -1332,13 +1332,13 @@ int setup_tests(void)
void cleanup_tests(void)
{
#ifndef OPENSSL_NO_EC
OSSL_PARAM_BLD_free_params(ec_explicit_prime_params_nc);
OSSL_PARAM_BLD_free_params(ec_explicit_prime_params_explicit);
OSSL_PARAM_free(ec_explicit_prime_params_nc);
OSSL_PARAM_free(ec_explicit_prime_params_explicit);
OSSL_PARAM_BLD_free(bld_prime_nc);
OSSL_PARAM_BLD_free(bld_prime);
# ifndef OPENSSL_NO_EC2M
OSSL_PARAM_BLD_free_params(ec_explicit_tri_params_nc);
OSSL_PARAM_BLD_free_params(ec_explicit_tri_params_explicit);
OSSL_PARAM_free(ec_explicit_tri_params_nc);
OSSL_PARAM_free(ec_explicit_tri_params_explicit);
OSSL_PARAM_BLD_free(bld_tri_nc);
OSSL_PARAM_BLD_free(bld_tri);
# endif

View File

@ -574,7 +574,7 @@ static int test_EVP_PKEY_ffc_priv_pub(char *keytype)
if (!test_fromdata(keytype, params))
goto err;
OSSL_PARAM_BLD_free_params(params);
OSSL_PARAM_free(params);
OSSL_PARAM_BLD_free(bld);
/* Test priv and !pub */
@ -590,7 +590,7 @@ static int test_EVP_PKEY_ffc_priv_pub(char *keytype)
if (!test_fromdata(keytype, params))
goto err;
OSSL_PARAM_BLD_free_params(params);
OSSL_PARAM_free(params);
OSSL_PARAM_BLD_free(bld);
/* Test !priv and pub */
@ -606,7 +606,7 @@ static int test_EVP_PKEY_ffc_priv_pub(char *keytype)
if (!test_fromdata(keytype, params))
goto err;
OSSL_PARAM_BLD_free_params(params);
OSSL_PARAM_free(params);
OSSL_PARAM_BLD_free(bld);
/* Test priv and pub */
@ -627,7 +627,7 @@ static int test_EVP_PKEY_ffc_priv_pub(char *keytype)
ret = 1;
err:
OSSL_PARAM_BLD_free_params(params);
OSSL_PARAM_free(params);
OSSL_PARAM_BLD_free(bld);
BN_free(p);
BN_free(q);
@ -683,7 +683,7 @@ static int test_EC_priv_pub(void)
if (!test_fromdata("EC", params))
goto err;
OSSL_PARAM_BLD_free_params(params);
OSSL_PARAM_free(params);
OSSL_PARAM_BLD_free(bld);
/* Test priv and !pub */
@ -699,7 +699,7 @@ static int test_EC_priv_pub(void)
if (!test_fromdata("EC", params))
goto err;
OSSL_PARAM_BLD_free_params(params);
OSSL_PARAM_free(params);
OSSL_PARAM_BLD_free(bld);
/* Test !priv and pub */
@ -716,7 +716,7 @@ static int test_EC_priv_pub(void)
if (!test_fromdata("EC", params))
goto err;
OSSL_PARAM_BLD_free_params(params);
OSSL_PARAM_free(params);
OSSL_PARAM_BLD_free(bld);
/* Test priv and pub */
@ -738,7 +738,7 @@ static int test_EC_priv_pub(void)
ret = 1;
err:
OSSL_PARAM_BLD_free_params(params);
OSSL_PARAM_free(params);
OSSL_PARAM_BLD_free(bld);
BN_free(priv);
@ -2083,7 +2083,7 @@ static int test_DSA_get_set_params(void)
err:
EVP_PKEY_free(pkey);
EVP_PKEY_CTX_free(pctx);
OSSL_PARAM_BLD_free_params(params);
OSSL_PARAM_free(params);
OSSL_PARAM_BLD_free(bld);
BN_free(p);
BN_free(q);
@ -2144,7 +2144,7 @@ static int test_RSA_get_set_params(void)
err:
EVP_PKEY_free(pkey);
EVP_PKEY_CTX_free(pctx);
OSSL_PARAM_BLD_free_params(params);
OSSL_PARAM_free(params);
OSSL_PARAM_BLD_free(bld);
BN_free(n);
BN_free(e);

View File

@ -446,7 +446,7 @@ static int test_evp_pkey_get_bn_param_large(void)
EVP_PKEY_free(pk);
EVP_PKEY_CTX_free(key_ctx);
EVP_PKEY_CTX_free(ctx);
OSSL_PARAM_BLD_free_params(fromdata_params);
OSSL_PARAM_free(fromdata_params);
OSSL_PARAM_BLD_free(bld);
return ret;
}
@ -627,7 +627,7 @@ err:
EVP_PKEY_free(pk);
EVP_PKEY_CTX_free(ctx);
EVP_PKEY_CTX_free(key_ctx);
OSSL_PARAM_BLD_free_params(fromdata_params);
OSSL_PARAM_free(fromdata_params);
OSSL_PARAM_BLD_free(bld);
return ret;
@ -801,7 +801,7 @@ err:
EVP_PKEY_free(pk);
EVP_PKEY_CTX_free(ctx);
EVP_PKEY_CTX_free(key_ctx);
OSSL_PARAM_BLD_free_params(fromdata_params);
OSSL_PARAM_free(fromdata_params);
OSSL_PARAM_BLD_free(bld);
return ret;
@ -1200,7 +1200,7 @@ static int test_fromdata_ec(void)
err:
BN_free(bn_priv);
BN_free(ec_priv_bn);
OSSL_PARAM_BLD_free_params(fromdata_params);
OSSL_PARAM_free(fromdata_params);
OSSL_PARAM_BLD_free(bld);
EVP_PKEY_free(pk);
EVP_PKEY_free(copy_pk);
@ -1519,7 +1519,7 @@ static int test_fromdata_dsa_fips186_4(void)
}
err:
OSSL_PARAM_BLD_free_params(fromdata_params);
OSSL_PARAM_free(fromdata_params);
OSSL_PARAM_BLD_free(bld);
BN_free(p);
BN_free(q);

View File

@ -40,7 +40,7 @@ static EVP_PKEY *get_dh_from_pg_bn(OSSL_LIB_CTX *libctx, const char *type,
err:
EVP_PKEY_CTX_free(pctx);
OSSL_PARAM_BLD_free_params(params);
OSSL_PARAM_free(params);
OSSL_PARAM_BLD_free(tmpl);
return dhpkey;
}

View File

@ -130,7 +130,7 @@ err:
OPENSSL_free(p1);
if (params != params_blt)
OPENSSL_free(params);
OSSL_PARAM_BLD_free_params(params_blt);
OSSL_PARAM_free(params_blt);
OSSL_PARAM_BLD_free(bld);
OPENSSL_free(utf);
BN_free(bn);
@ -265,7 +265,7 @@ err:
OSSL_PARAM_free(p1);
if (params != params_blt)
OSSL_PARAM_free(params);
OSSL_PARAM_BLD_free_params(params_blt);
OSSL_PARAM_free(params_blt);
OSSL_PARAM_BLD_free(bld);
OPENSSL_secure_free(data1);
OPENSSL_secure_free(data2);
@ -300,7 +300,7 @@ static int builder_limit_test(void)
goto err;
/* Verify that the build, cleared the builder structure */
OSSL_PARAM_BLD_free_params(params);
OSSL_PARAM_free(params);
params = NULL;
if (!TEST_true(OSSL_PARAM_BLD_push_int(bld, "g", 2))
@ -312,7 +312,7 @@ static int builder_limit_test(void)
goto err;
res = 1;
err:
OSSL_PARAM_BLD_free_params(params);
OSSL_PARAM_free(params);
OSSL_PARAM_BLD_free(bld);
return res;
}

View File

@ -8302,7 +8302,7 @@ static EVP_PKEY *get_tmp_dh_params(void)
BN_free(p);
EVP_PKEY_CTX_free(pctx);
OSSL_PARAM_BLD_free(tmpl);
OSSL_PARAM_BLD_free_params(params);
OSSL_PARAM_free(params);
}
if (tmp_dh_params != NULL && !EVP_PKEY_up_ref(tmp_dh_params))

View File

@ -4956,7 +4956,6 @@ NCONF_new_ex ? 3_0_0 EXIST::FUNCTION:
CONF_modules_load_file_ex ? 3_0_0 EXIST::FUNCTION:
OSSL_LIB_CTX_load_config ? 3_0_0 EXIST::FUNCTION:
OSSL_PARAM_BLD_to_param ? 3_0_0 EXIST::FUNCTION:
OSSL_PARAM_BLD_free_params ? 3_0_0 EXIST::FUNCTION:
OSSL_PARAM_BLD_push_int ? 3_0_0 EXIST::FUNCTION:
OSSL_PARAM_BLD_push_uint ? 3_0_0 EXIST::FUNCTION:
OSSL_PARAM_BLD_push_long ? 3_0_0 EXIST::FUNCTION: