summaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
authorlan1120 <lanming@huawei.com>2023-12-13 19:02:29 +0800
committerTomas Mraz <tomas@openssl.org>2024-01-16 11:29:34 +0100
commit2827145227a4ee352056e02b5908f19c7ca30074 (patch)
treee10c188a8d0e9068f3e0279a26eef3f450a8857a /crypto
parentf8b96e116cb8b78ddbb295c8eedf1bab4227c885 (diff)
Check whether the pubkey exists in ossl_ecx_key_dup
Signed-off-by: lan1120 <lanming@huawei.com> Reviewed-by: Shane Lontis <shane.lontis@oracle.com> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/22984) (cherry picked from commit aac531e5daa2edec5d47e702a7f115cf77fe07f9)
Diffstat (limited to 'crypto')
-rw-r--r--crypto/ec/ecx_backend.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/crypto/ec/ecx_backend.c b/crypto/ec/ecx_backend.c
index 943a6bb370..2afa5c7063 100644
--- a/crypto/ec/ecx_backend.c
+++ b/crypto/ec/ecx_backend.c
@@ -114,7 +114,7 @@ ECX_KEY *ossl_ecx_key_dup(const ECX_KEY *key, int selection)
return NULL;
ret->libctx = key->libctx;
- ret->haspubkey = key->haspubkey;
+ ret->haspubkey = 0;
ret->keylen = key->keylen;
ret->type = key->type;
@@ -127,8 +127,11 @@ ECX_KEY *ossl_ecx_key_dup(const ECX_KEY *key, int selection)
goto err;
}
- if ((selection & OSSL_KEYMGMT_SELECT_PUBLIC_KEY) != 0)
+ if ((selection & OSSL_KEYMGMT_SELECT_PUBLIC_KEY) != 0
+ && key->haspubkey == 1) {
memcpy(ret->pubkey, key->pubkey, sizeof(ret->pubkey));
+ ret->haspubkey = 1;
+ }
if ((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) != 0
&& key->privkey != NULL) {