From ded96219cc792b526c80dc91bfe889979016b974 Mon Sep 17 00:00:00 2001 From: Brett Nicholas <7547222+bigbrett@users.noreply.github.com> Date: Tue, 26 Nov 2024 09:52:07 -0800 Subject: [PATCH] add additional macro protection for DMA functions --- src/wh_client_cryptocb.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/wh_client_cryptocb.c b/src/wh_client_cryptocb.c index 74eddb7..70eea6b 100644 --- a/src/wh_client_cryptocb.c +++ b/src/wh_client_cryptocb.c @@ -778,10 +778,13 @@ static int _handlePqcSigKeyGen(whClientContext* ctx, wc_CryptoInfo* info, #ifdef HAVE_DILITHIUM case WC_PQC_SIG_TYPE_DILITHIUM: { int level = ((MlDsaKey*)key)->level; +#ifdef WOLFHSM_CFG_DMA if (useDma) { ret = wh_Client_MlDsaMakeExportKeyDma(ctx, level, key); } - else { + else +#endif /* WOLFHSM_CFG_DMA */ + { ret = wh_Client_MlDsaMakeExportKey(ctx, level, size, key); } } break; @@ -819,11 +822,14 @@ static int _handlePqcSign(whClientContext* ctx, wc_CryptoInfo* info, int useDma) switch (type) { #ifdef HAVE_DILITHIUM case WC_PQC_SIG_TYPE_DILITHIUM: +#ifdef WOLFHSM_CFG_DMA if (useDma) { ret = wh_Client_MlDsaSignDma(ctx, in, in_len, out, out_len, key); } - else { + else +#endif /* WOLFHSM_CFG_DMA */ + { ret = wh_Client_MlDsaSign(ctx, in, in_len, out, out_len, key); } break; @@ -863,11 +869,14 @@ static int _handlePqcVerify(whClientContext* ctx, wc_CryptoInfo* info, switch (type) { #ifdef HAVE_DILITHIUM case WC_PQC_SIG_TYPE_DILITHIUM: +#ifdef WOLFHSM_CFG_DMA if (useDma) { ret = wh_Client_MlDsaVerifyDma(ctx, sig, sig_len, msg, msg_len, res, key); } - else { + else +#endif /* WOLFHSM_CFG_DMA */ + { ret = wh_Client_MlDsaVerify(ctx, sig, sig_len, msg, msg_len, res, key); } @@ -905,11 +914,14 @@ static int _handlePqcSigCheckPrivKey(whClientContext* ctx, wc_CryptoInfo* info, switch (type) { #ifdef HAVE_DILITHIUM case WC_PQC_SIG_TYPE_DILITHIUM: +#ifdef WOLFHSM_CFG_DMA if (useDma) { ret = wh_Client_MlDsaCheckPrivKeyDma(ctx, key, pubKey, pubKeySz); } - else { + else +#endif /* WOLFHSM_CFG_DMA */ + { ret = wh_Client_MlDsaCheckPrivKey(ctx, key, pubKey, pubKeySz); } break;