X-Git-Url: https://git.openssl.org/gitweb/?p=openssl.git;a=blobdiff_plain;f=providers%2Fimplementations%2Fserializers%2Fserializer_dh_pub.c;h=567a0f03eaf8a88ba479dc93900c99cb4ce8deb5;hp=73095c8fd1a0f6e81933b1103295a640fc8f6256;hb=8c555803476a2af366938161d1186a0d746910ea;hpb=045e51cbf49a0773f7d045180d9d8b8b73d70e90 diff --git a/providers/implementations/serializers/serializer_dh_pub.c b/providers/implementations/serializers/serializer_dh_pub.c index 73095c8fd1..567a0f03ea 100644 --- a/providers/implementations/serializers/serializer_dh_pub.c +++ b/providers/implementations/serializers/serializer_dh_pub.c @@ -7,6 +7,12 @@ * https://www.openssl.org/source/license.html */ +/* + * DH low level APIs are deprecated for public use, but still ok for + * internal use. + */ +#include "internal/deprecated.h" + #include #include #include @@ -45,15 +51,20 @@ static void dh_pub_freectx(void *ctx) static int dh_pub_der_data(void *ctx, const OSSL_PARAM params[], BIO *out, OSSL_PASSPHRASE_CALLBACK *cb, void *cbarg) { - OSSL_OP_keymgmt_importkey_fn *dh_importkey = - ossl_prov_get_dh_importkey(); + OSSL_OP_keymgmt_new_fn *dh_new = ossl_prov_get_keymgmt_dh_new(); + OSSL_OP_keymgmt_free_fn *dh_free = ossl_prov_get_keymgmt_dh_free(); + OSSL_OP_keymgmt_import_fn *dh_import = ossl_prov_get_keymgmt_dh_import(); int ok = 0; - if (dh_importkey != NULL) { - DH *dh = dh_importkey(ctx, params); /* ctx == provctx */ + if (dh_import != NULL) { + DH *dh; - ok = dh_pub_der(ctx, dh, out, cb, cbarg); - DH_free(dh); + /* ctx == provctx */ + if ((dh = dh_new(ctx)) != NULL + && dh_import(dh, OSSL_KEYMGMT_SELECT_KEYPAIR, params) + && dh_pub_der(ctx, dh, out, cb, cbarg)) + ok = 1; + dh_free(dh); } return ok; } @@ -70,15 +81,20 @@ static int dh_pub_der(void *ctx, void *dh, BIO *out, static int dh_pub_pem_data(void *ctx, const OSSL_PARAM params[], BIO *out, OSSL_PASSPHRASE_CALLBACK *cb, void *cbarg) { - OSSL_OP_keymgmt_importkey_fn *dh_importkey = - ossl_prov_get_dh_importkey(); + OSSL_OP_keymgmt_new_fn *dh_new = ossl_prov_get_keymgmt_dh_new(); + OSSL_OP_keymgmt_free_fn *dh_free = ossl_prov_get_keymgmt_dh_free(); + OSSL_OP_keymgmt_import_fn *dh_import = ossl_prov_get_keymgmt_dh_import(); int ok = 0; - if (dh_importkey != NULL) { - DH *dh = dh_importkey(ctx, params); /* ctx == provctx */ + if (dh_import != NULL) { + DH *dh; - ok = dh_pub_pem(ctx, dh, out, cb, cbarg); - DH_free(dh); + /* ctx == provctx */ + if ((dh = dh_new(ctx)) != NULL + && dh_import(dh, OSSL_KEYMGMT_SELECT_KEYPAIR, params) + && dh_pub_pem(ctx, dh, out, cb, cbarg)) + ok = 1; + dh_free(dh); } return ok; } @@ -95,15 +111,20 @@ static int dh_pub_pem(void *ctx, void *dh, BIO *out, static int dh_pub_print_data(void *ctx, const OSSL_PARAM params[], BIO *out, OSSL_PASSPHRASE_CALLBACK *cb, void *cbarg) { - OSSL_OP_keymgmt_importkey_fn *dh_importkey = - ossl_prov_get_dh_importkey(); + OSSL_OP_keymgmt_new_fn *dh_new = ossl_prov_get_keymgmt_dh_new(); + OSSL_OP_keymgmt_free_fn *dh_free = ossl_prov_get_keymgmt_dh_free(); + OSSL_OP_keymgmt_import_fn *dh_import = ossl_prov_get_keymgmt_dh_import(); int ok = 0; - if (dh_importkey != NULL) { - DH *dh = dh_importkey(ctx, params); /* ctx == provctx */ + if (dh_import != NULL) { + DH *dh; - ok = dh_pub_print(ctx, dh, out, cb, cbarg); - DH_free(dh); + /* ctx == provctx */ + if ((dh = dh_new(ctx)) != NULL + && dh_import(dh, OSSL_KEYMGMT_SELECT_KEYPAIR, params) + && dh_pub_print(ctx, dh, out, cb, cbarg)) + ok = 1; + dh_free(dh); } return ok; } @@ -111,7 +132,7 @@ static int dh_pub_print_data(void *ctx, const OSSL_PARAM params[], BIO *out, static int dh_pub_print(void *ctx, void *dh, BIO *out, OSSL_PASSPHRASE_CALLBACK *cb, void *cbarg) { - return ossl_prov_print_dh(out, dh, 0); + return ossl_prov_print_dh(out, dh, dh_print_pub); } const OSSL_DISPATCH dh_pub_der_serializer_functions[] = {