summaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
authorShane Lontis <shane.lontis@oracle.com>2021-04-08 12:05:14 +0200
committerTomas Mraz <tomas@openssl.org>2021-04-15 18:42:04 +0200
commita732a4c329144f0b4c60372d9b7106c6b88ddd9f (patch)
treef5dd1f0e6d8ebfb89a3ec536b94a8b1297148d6a /crypto
parentAdd OID for mdc2WithRSASignature and remove related TODO 3.0 (diff)
downloadopenssl-a732a4c329144f0b4c60372d9b7106c6b88ddd9f.tar.xz
openssl-a732a4c329144f0b4c60372d9b7106c6b88ddd9f.zip
Add EVP_PKEY_todata() and EVP_PKEY_export() functions.
Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14800)
Diffstat (limited to 'crypto')
-rw-r--r--crypto/evp/keymgmt_lib.c2
-rw-r--r--crypto/evp/pmeth_gn.c23
2 files changed, 25 insertions, 0 deletions
diff --git a/crypto/evp/keymgmt_lib.c b/crypto/evp/keymgmt_lib.c
index 80aea65e88..f196bc4d88 100644
--- a/crypto/evp/keymgmt_lib.c
+++ b/crypto/evp/keymgmt_lib.c
@@ -80,6 +80,8 @@ EVP_PKEY *evp_keymgmt_util_make_pkey(EVP_KEYMGMT *keymgmt, void *keydata)
int evp_keymgmt_util_export(const EVP_PKEY *pk, int selection,
OSSL_CALLBACK *export_cb, void *export_cbarg)
{
+ if (pk == NULL || export_cb == NULL)
+ return 0;
return evp_keymgmt_export(pk->keymgmt, pk->keydata, selection,
export_cb, export_cbarg);
}
diff --git a/crypto/evp/pmeth_gn.c b/crypto/evp/pmeth_gn.c
index 7383fbe072..e184db26a0 100644
--- a/crypto/evp/pmeth_gn.c
+++ b/crypto/evp/pmeth_gn.c
@@ -395,3 +395,26 @@ const OSSL_PARAM *EVP_PKEY_fromdata_settable(EVP_PKEY_CTX *ctx, int selection)
return evp_keymgmt_import_types(ctx->keymgmt, selection);
return NULL;
}
+
+static OSSL_CALLBACK ossl_pkey_todata_cb;
+
+static int ossl_pkey_todata_cb(const OSSL_PARAM params[], void *arg)
+{
+ OSSL_PARAM **ret = arg;
+
+ *ret = OSSL_PARAM_dup(params);
+ return 1;
+}
+
+int EVP_PKEY_todata(const EVP_PKEY *pkey, int selection, OSSL_PARAM **params)
+{
+ if (params == NULL)
+ return 0;
+ return EVP_PKEY_export(pkey, selection, ossl_pkey_todata_cb, params);
+}
+
+int EVP_PKEY_export(const EVP_PKEY *pkey, int selection,
+ OSSL_CALLBACK *export_cb, void *export_cbarg)
+{
+ return evp_keymgmt_util_export(pkey, selection, export_cb, export_cbarg);
+}