From 110bff618b5bd3c700f2f0a290612ca642672ce6 Mon Sep 17 00:00:00 2001 From: Pauli Date: Tue, 24 Mar 2020 14:58:57 +1000 Subject: Param builder: make the OSSL_PARAM_BLD APIs public. The catalyst for this is the difficult of passing BNs through the other OSSL_PARAM APIs. Reviewed-by: Nicola Tuveri (Merged from https://github.com/openssl/openssl/pull/11390) --- crypto/ec/ec_ameth.c | 16 ++++++++-------- crypto/ec/ecx_meth.c | 12 ++++++------ 2 files changed, 14 insertions(+), 14 deletions(-) (limited to 'crypto/ec') diff --git a/crypto/ec/ec_ameth.c b/crypto/ec/ec_ameth.c index f3812e46b5..85427cf456 100644 --- a/crypto/ec/ec_ameth.c +++ b/crypto/ec/ec_ameth.c @@ -23,7 +23,7 @@ #include "crypto/asn1.h" #include "crypto/evp.h" #include -#include "internal/param_build.h" +#include "openssl/param_build.h" #include "ec_local.h" #ifndef OPENSSL_NO_CMS @@ -611,7 +611,7 @@ int ecparams_to_params(const EC_KEY *eckey, OSSL_PARAM_BLD *tmpl) if ((curve_name = OBJ_nid2sn(curve_nid)) == NULL) return 0; - if (!ossl_param_bld_push_utf8_string(tmpl, OSSL_PKEY_PARAM_EC_NAME, curve_name, 0)) + if (!OSSL_PARAM_BLD_push_utf8_string(tmpl, OSSL_PKEY_PARAM_EC_NAME, curve_name, 0)) return 0; } @@ -645,7 +645,7 @@ int ec_pkey_export_to(const EVP_PKEY *from, void *to_keydata, if (EC_KEY_get_method(eckey) != EC_KEY_OpenSSL()) return 0; - ossl_param_bld_init(&tmpl); + OSSL_PARAM_BLD_init(&tmpl); /* export the domain parameters */ if (!ecparams_to_params(eckey, &tmpl)) @@ -660,7 +660,7 @@ int ec_pkey_export_to(const EVP_PKEY *from, void *to_keydata, if ((pub_key_buflen = EC_POINT_point2buf(ecg, pub_point, POINT_CONVERSION_COMPRESSED, &pub_key_buf, NULL)) == 0 - || !ossl_param_bld_push_octet_string(&tmpl, + || !OSSL_PARAM_BLD_push_octet_string(&tmpl, OSSL_PKEY_PARAM_PUB_KEY, pub_key_buf, pub_key_buflen)) @@ -711,7 +711,7 @@ int ec_pkey_export_to(const EVP_PKEY *from, void *to_keydata, goto err; sz = (ecbits + 7 ) / 8; - if (!ossl_param_bld_push_BN_pad(&tmpl, + if (!OSSL_PARAM_BLD_push_BN_pad(&tmpl, OSSL_PKEY_PARAM_PRIV_KEY, priv_key, sz)) goto err; @@ -726,20 +726,20 @@ int ec_pkey_export_to(const EVP_PKEY *from, void *to_keydata, (EC_KEY_get_flags(eckey) & EC_FLAG_COFACTOR_ECDH) ? 1 : 0; /* Export the ECDH_COFACTOR_MODE parameter */ - if (!ossl_param_bld_push_int(&tmpl, + if (!OSSL_PARAM_BLD_push_int(&tmpl, OSSL_PKEY_PARAM_USE_COFACTOR_ECDH, ecdh_cofactor_mode)) goto err; selection |= OSSL_KEYMGMT_SELECT_OTHER_PARAMETERS; } - params = ossl_param_bld_to_param(&tmpl); + params = OSSL_PARAM_BLD_to_param(&tmpl); /* We export, the provider imports */ rv = evp_keymgmt_import(to_keymgmt, to_keydata, selection, params); err: - ossl_param_bld_free(params); + OSSL_PARAM_BLD_free(params); OPENSSL_free(pub_key_buf); return rv; } diff --git a/crypto/ec/ecx_meth.c b/crypto/ec/ecx_meth.c index 97d1b13f5a..8a48b28f38 100644 --- a/crypto/ec/ecx_meth.c +++ b/crypto/ec/ecx_meth.c @@ -19,7 +19,7 @@ #include #include #include -#include "internal/param_build.h" +#include "openssl/param_build.h" #include "crypto/asn1.h" #include "crypto/evp.h" #include "crypto/ecx.h" @@ -414,29 +414,29 @@ static int ecx_pkey_export_to(const EVP_PKEY *from, void *to_keydata, int selection = 0; int rv = 0; - ossl_param_bld_init(&tmpl); + OSSL_PARAM_BLD_init(&tmpl); /* A key must at least have a public part */ - if (!ossl_param_bld_push_octet_string(&tmpl, OSSL_PKEY_PARAM_PUB_KEY, + if (!OSSL_PARAM_BLD_push_octet_string(&tmpl, OSSL_PKEY_PARAM_PUB_KEY, key->pubkey, key->keylen)) goto err; selection |= OSSL_KEYMGMT_SELECT_PUBLIC_KEY; if (key->privkey != NULL) { - if (!ossl_param_bld_push_octet_string(&tmpl, + if (!OSSL_PARAM_BLD_push_octet_string(&tmpl, OSSL_PKEY_PARAM_PRIV_KEY, key->privkey, key->keylen)) goto err; selection |= OSSL_KEYMGMT_SELECT_PRIVATE_KEY; } - params = ossl_param_bld_to_param(&tmpl); + params = OSSL_PARAM_BLD_to_param(&tmpl); /* We export, the provider imports */ rv = evp_keymgmt_import(to_keymgmt, to_keydata, selection, params); err: - ossl_param_bld_free(params); + OSSL_PARAM_BLD_free(params); return rv; } -- cgit v1.2.3