summaryrefslogtreecommitdiffstats
path: root/crypto/ec
diff options
context:
space:
mode:
authorTomas Mraz <tomas@openssl.org>2021-03-03 09:44:25 +0100
committerTomas Mraz <tomas@openssl.org>2021-03-04 14:15:01 +0100
commit8c631cfaa1f812ed990053c1b0c73f3a3f369aca (patch)
tree94279164446b2255d374d315ae9bfc138e6eb899 /crypto/ec
parent2ad5bbe3205264cbcdd25f50a0c5167a7136ce88 (diff)
ecx_set_priv_key: Try to obtain libctx from the pkey's keymgmt
We can try to do that although for legacy keys the keymgmt will not be set. This function will disappear with legacy support removed. Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14404)
Diffstat (limited to 'crypto/ec')
-rw-r--r--crypto/ec/ecx_meth.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/crypto/ec/ecx_meth.c b/crypto/ec/ecx_meth.c
index 54415d86db..fac1ba7270 100644
--- a/crypto/ec/ecx_meth.c
+++ b/crypto/ec/ecx_meth.c
@@ -14,12 +14,13 @@
#include "internal/deprecated.h"
#include <stdio.h>
-#include "internal/cryptlib.h"
#include <openssl/x509.h>
#include <openssl/ec.h>
#include <openssl/rand.h>
#include <openssl/core_names.h>
-#include "openssl/param_build.h"
+#include <openssl/param_build.h>
+#include "internal/cryptlib.h"
+#include "internal/provider.h"
#include "crypto/asn1.h"
#include "crypto/evp.h"
#include "crypto/ecx.h"
@@ -334,14 +335,24 @@ static int ecd_ctrl(EVP_PKEY *pkey, int op, long arg1, void *arg2)
static int ecx_set_priv_key(EVP_PKEY *pkey, const unsigned char *priv,
size_t len)
{
+ OSSL_LIB_CTX *libctx = NULL;
+
+ if (pkey->keymgmt != NULL)
+ libctx = ossl_provider_libctx(EVP_KEYMGMT_provider(pkey->keymgmt));
+
return ecx_key_op(pkey, pkey->ameth->pkey_id, NULL, priv, len,
- KEY_OP_PRIVATE, NULL, NULL);
+ KEY_OP_PRIVATE, libctx, NULL);
}
static int ecx_set_pub_key(EVP_PKEY *pkey, const unsigned char *pub, size_t len)
{
+ OSSL_LIB_CTX *libctx = NULL;
+
+ if (pkey->keymgmt != NULL)
+ libctx = ossl_provider_libctx(EVP_KEYMGMT_provider(pkey->keymgmt));
+
return ecx_key_op(pkey, pkey->ameth->pkey_id, NULL, pub, len,
- KEY_OP_PUBLIC, NULL, NULL);
+ KEY_OP_PUBLIC, libctx, NULL);
}
static int ecx_get_priv_key(const EVP_PKEY *pkey, unsigned char *priv,