diff options
Diffstat (limited to 'providers/implementations/exchange/dh_exch.c')
-rw-r--r-- | providers/implementations/exchange/dh_exch.c | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/providers/implementations/exchange/dh_exch.c b/providers/implementations/exchange/dh_exch.c index 3c3bd4dd38..fad38ec93d 100644 --- a/providers/implementations/exchange/dh_exch.c +++ b/providers/implementations/exchange/dh_exch.c @@ -20,6 +20,7 @@ #include <openssl/dh.h> #include <openssl/err.h> #include <openssl/params.h> +#include "prov/providercommon.h" #include "prov/implementations.h" #include "prov/provider_ctx.h" #include "crypto/dh.h" @@ -77,8 +78,12 @@ typedef struct { static void *dh_newctx(void *provctx) { - PROV_DH_CTX *pdhctx = OPENSSL_zalloc(sizeof(PROV_DH_CTX)); + PROV_DH_CTX *pdhctx; + if (!ossl_prov_is_running()) + return NULL; + + pdhctx = OPENSSL_zalloc(sizeof(PROV_DH_CTX)); if (pdhctx == NULL) return NULL; pdhctx->libctx = PROV_LIBRARY_CONTEXT_OF(provctx); @@ -90,7 +95,10 @@ static int dh_init(void *vpdhctx, void *vdh) { PROV_DH_CTX *pdhctx = (PROV_DH_CTX *)vpdhctx; - if (pdhctx == NULL || vdh == NULL || !DH_up_ref(vdh)) + if (!ossl_prov_is_running() + || pdhctx == NULL + || vdh == NULL + || !DH_up_ref(vdh)) return 0; DH_free(pdhctx->dh); pdhctx->dh = vdh; @@ -102,7 +110,10 @@ static int dh_set_peer(void *vpdhctx, void *vdh) { PROV_DH_CTX *pdhctx = (PROV_DH_CTX *)vpdhctx; - if (pdhctx == NULL || vdh == NULL || !DH_up_ref(vdh)) + if (!ossl_prov_is_running() + || pdhctx == NULL + || vdh == NULL + || !DH_up_ref(vdh)) return 0; DH_free(pdhctx->dhpeer); pdhctx->dhpeer = vdh; @@ -189,6 +200,9 @@ static int dh_derive(void *vpdhctx, unsigned char *secret, { PROV_DH_CTX *pdhctx = (PROV_DH_CTX *)vpdhctx; + if (!ossl_prov_is_running()) + return 0; + switch (pdhctx->kdf_type) { case PROV_DH_KDF_NONE: return dh_plain_derive(pdhctx, secret, psecretlen, outlen); @@ -219,6 +233,9 @@ static void *dh_dupctx(void *vpdhctx) PROV_DH_CTX *srcctx = (PROV_DH_CTX *)vpdhctx; PROV_DH_CTX *dstctx; + if (!ossl_prov_is_running()) + return NULL; + dstctx = OPENSSL_zalloc(sizeof(*srcctx)); if (dstctx == NULL) return NULL; |