Skip to content

Commit

Permalink
add additional macro protection for DMA functions
Browse files Browse the repository at this point in the history
  • Loading branch information
bigbrett committed Nov 26, 2024
1 parent e6ea3ac commit ded9621
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/wh_client_cryptocb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit ded9621

Please sign in to comment.