* 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 <openssl/core_numbers.h>
#include <openssl/err.h>
#include <openssl/pem.h>
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;
}
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;
}
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;
}
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[] = {