From 679020dd70612389b95ef3afb57335961bde14e3 Mon Sep 17 00:00:00 2001 From: David Garske Date: Wed, 23 Jul 2025 13:19:51 -0700 Subject: [PATCH] Fix `WOLFTPM2_USE_SW_ECDHE`. --- src/tpm2_cryptocb.c | 8 ++++++-- wolftpm/tpm2_wrap.h | 2 -- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/tpm2_cryptocb.c b/src/tpm2_cryptocb.c index a5ae3ac4..ec97117c 100644 --- a/src/tpm2_cryptocb.c +++ b/src/tpm2_cryptocb.c @@ -180,11 +180,15 @@ int wolfTPM2_CryptoDevCb(int devId, wc_CryptoInfo* info, void* ctx) int curve_id; WOLFTPM2_KEY* key; + #ifdef WOLFTPM2_USE_SW_ECDHE + if (tlsCtx->ecdhKey == NULL) { + return exit_rc; + } + #endif + if ( tlsCtx->eccKey == NULL && tlsCtx->ecdsaKey == NULL - #ifndef WOLFTPM2_USE_SW_ECDHE && tlsCtx->ecdhKey == NULL - #endif ) { #ifdef DEBUG_WOLFTPM printf("No crypto callback key pointer set!\n"); diff --git a/wolftpm/tpm2_wrap.h b/wolftpm/tpm2_wrap.h index fc3cf3af..19a45598 100644 --- a/wolftpm/tpm2_wrap.h +++ b/wolftpm/tpm2_wrap.h @@ -3347,9 +3347,7 @@ typedef struct TpmCryptoDevCtx { #ifdef HAVE_ECC WOLFTPM2_KEY* eccKey; /* ECDSA - public only */ WOLFTPM2_KEYBLOB* ecdsaKey; /* ECDSA - retain encrypted private portion from keygen */ - #ifndef WOLFTPM2_USE_SW_ECDHE WOLFTPM2_KEY* ecdhKey; /* ECDH */ - #endif #endif WOLFTPM2_KEY* storageKey; #ifdef WOLFTPM_USE_SYMMETRIC