From 8dbef010e7e6ecc07a9c8142cf26c8768fd55dc2 Mon Sep 17 00:00:00 2001 From: Shane Lontis Date: Tue, 22 Sep 2020 15:51:49 +1000 Subject: Fix ecx so that is uses a settable propertyquery Reviewed-by: Matt Caswell (Merged from https://github.com/openssl/openssl/pull/12944) --- crypto/ec/ecx_key.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'crypto/ec/ecx_key.c') diff --git a/crypto/ec/ecx_key.c b/crypto/ec/ecx_key.c index 46abd57a74..dd4b872ab0 100644 --- a/crypto/ec/ecx_key.c +++ b/crypto/ec/ecx_key.c @@ -10,7 +10,8 @@ #include #include "crypto/ecx.h" -ECX_KEY *ecx_key_new(OPENSSL_CTX *libctx, ECX_KEY_TYPE type, int haspubkey) +ECX_KEY *ecx_key_new(OPENSSL_CTX *libctx, ECX_KEY_TYPE type, int haspubkey, + const char *propq) { ECX_KEY *ret = OPENSSL_zalloc(sizeof(*ret)); @@ -36,14 +37,21 @@ ECX_KEY *ecx_key_new(OPENSSL_CTX *libctx, ECX_KEY_TYPE type, int haspubkey) ret->type = type; ret->references = 1; - ret->lock = CRYPTO_THREAD_lock_new(); - if (ret->lock == NULL) { + if (propq != NULL) { + ret->propq = OPENSSL_strdup(propq); ERR_raise(ERR_LIB_EC, ERR_R_MALLOC_FAILURE); - OPENSSL_free(ret); - return NULL; + if (ret->propq == NULL) + goto err; } + ret->lock = CRYPTO_THREAD_lock_new(); + if (ret->lock == NULL) + goto err; return ret; +err: + ERR_raise(ERR_LIB_EC, ERR_R_MALLOC_FAILURE); + OPENSSL_free(ret); + return NULL; } void ecx_key_free(ECX_KEY *key) @@ -59,6 +67,7 @@ void ecx_key_free(ECX_KEY *key) return; REF_ASSERT_ISNT(i < 0); + OPENSSL_free(key->propq); OPENSSL_secure_clear_free(key->privkey, key->keylen); CRYPTO_THREAD_lock_free(key->lock); OPENSSL_free(key); -- cgit v1.2.3