X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=providers%2Fimplementations%2Fserializers%2Fserializer_dh_priv.c;fp=providers%2Fimplementations%2Fserializers%2Fserializer_dh_priv.c;h=c37eb40297e61d6228be2d43383e26dc38974490;hb=d40b42ab4c8a88740a2cc2a20c709fe869c4dd1e;hp=99d529b052f501eb28fd09659b1ff2dd155d90c7;hpb=827f04d5105e9bec0af214c42b8ad799fba5bb0d;p=oweals%2Fopenssl.git diff --git a/providers/implementations/serializers/serializer_dh_priv.c b/providers/implementations/serializers/serializer_dh_priv.c index 99d529b052..c37eb40297 100644 --- a/providers/implementations/serializers/serializer_dh_priv.c +++ b/providers/implementations/serializers/serializer_dh_priv.c @@ -22,6 +22,7 @@ #include #include "prov/bio.h" #include "prov/implementations.h" +#include "prov/provider_ctx.h" #include "serializer_local.h" static OSSL_OP_serializer_newctx_fn dh_priv_newctx; @@ -117,7 +118,8 @@ static int dh_priv_set_ctx_params(void *vctx, const OSSL_PARAM params[]) } /* Private key : DER */ -static int dh_priv_der_data(void *vctx, const OSSL_PARAM params[], BIO *out, +static int dh_priv_der_data(void *vctx, const OSSL_PARAM params[], + OSSL_CORE_BIO *out, OSSL_PASSPHRASE_CALLBACK *cb, void *cbarg) { struct dh_priv_ctx_st *ctx = vctx; @@ -138,11 +140,15 @@ static int dh_priv_der_data(void *vctx, const OSSL_PARAM params[], BIO *out, return ok; } -static int dh_priv_der(void *vctx, void *dh, BIO *out, +static int dh_priv_der(void *vctx, void *dh, OSSL_CORE_BIO *cout, OSSL_PASSPHRASE_CALLBACK *cb, void *cbarg) { struct dh_priv_ctx_st *ctx = vctx; int ret; + BIO *out = bio_new_from_core_bio(ctx->provctx, cout); + + if (out == NULL) + return 0; ctx->sc.cb = cb; ctx->sc.cbarg = cbarg; @@ -151,12 +157,14 @@ static int dh_priv_der(void *vctx, void *dh, BIO *out, ossl_prov_prepare_dh_params, ossl_prov_dh_priv_to_der, &ctx->sc); + BIO_free(out); return ret; } /* Private key : PEM */ -static int dh_pem_priv_data(void *vctx, const OSSL_PARAM params[], BIO *out, +static int dh_pem_priv_data(void *vctx, const OSSL_PARAM params[], + OSSL_CORE_BIO *out, OSSL_PASSPHRASE_CALLBACK *cb, void *cbarg) { struct dh_priv_ctx_st *ctx = vctx; @@ -177,11 +185,15 @@ static int dh_pem_priv_data(void *vctx, const OSSL_PARAM params[], BIO *out, return ok; } -static int dh_pem_priv(void *vctx, void *dh, BIO *out, +static int dh_pem_priv(void *vctx, void *dh, OSSL_CORE_BIO *cout, OSSL_PASSPHRASE_CALLBACK *cb, void *cbarg) { struct dh_priv_ctx_st *ctx = vctx; int ret; + BIO *out = bio_new_from_core_bio(ctx->provctx, cout); + + if (out == NULL) + return 0; ctx->sc.cb = cb; ctx->sc.cbarg = cbarg; @@ -190,6 +202,7 @@ static int dh_pem_priv(void *vctx, void *dh, BIO *out, ossl_prov_prepare_dh_params, ossl_prov_dh_priv_to_der, &ctx->sc); + BIO_free(out); return ret; } @@ -206,7 +219,8 @@ static void dh_print_freectx(void *ctx) { } -static int dh_priv_print_data(void *vctx, const OSSL_PARAM params[], BIO *out, +static int dh_priv_print_data(void *vctx, const OSSL_PARAM params[], + OSSL_CORE_BIO *out, OSSL_PASSPHRASE_CALLBACK *cb, void *cbarg) { struct dh_priv_ctx_st *ctx = vctx; @@ -227,10 +241,19 @@ static int dh_priv_print_data(void *vctx, const OSSL_PARAM params[], BIO *out, return ok; } -static int dh_priv_print(void *ctx, void *dh, BIO *out, +static int dh_priv_print(void *ctx, void *dh, OSSL_CORE_BIO *cout, OSSL_PASSPHRASE_CALLBACK *cb, void *cbarg) { - return ossl_prov_print_dh(out, dh, dh_print_priv); + BIO *out = bio_new_from_core_bio(ctx, cout); + int ret; + + if (out == NULL) + return 0; + + ret = ossl_prov_print_dh(out, dh, dh_print_priv); + BIO_free(out); + + return ret; } const OSSL_DISPATCH dh_priv_der_serializer_functions[] = {