Skip to content

Commit 05a80f6

Browse files
committed
Removal of manual func calls, internally handle func and LINE internally
1 parent 887a6f4 commit 05a80f6

File tree

8 files changed

+51
-10
lines changed

8 files changed

+51
-10
lines changed

examples/demo/client/wh_demo_client_crypto.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1471,7 +1471,7 @@ int wh_DemoClient_CryptoHkdfCacheInputKey(whClientContext* clientContext)
14711471
(uint32_t)strlen(keyLabel), ikm,
14721472
(uint32_t)sizeof(ikm), &keyIdIn);
14731473
if (ret != WH_ERROR_OK) {
1474-
printf("Failed to wh_Client_KeyCache %d\n", ret);
1474+
WOLFHSM_CFG_PRINTF("Failed to wh_Client_KeyCache %d\n", ret);
14751475
return ret;
14761476
}
14771477

@@ -1487,7 +1487,7 @@ int wh_DemoClient_CryptoHkdfCacheInputKey(whClientContext* clientContext)
14871487
(uint32_t)sizeof(salt), info, (uint32_t)sizeof(info), &keyIdOut,
14881488
WH_NVM_FLAGS_NONE, NULL, 0, (uint32_t)sizeof(okm));
14891489
if (ret != WH_ERROR_OK) {
1490-
printf("Failed to wh_Client_HkdfMakeCacheKey with cached input %d\n",
1490+
WOLFHSM_CFG_PRINTF("Failed to wh_Client_HkdfMakeCacheKey with cached input %d\n",
14911491
ret);
14921492
(void)wh_Client_KeyEvict(clientContext, keyIdIn);
14931493
return ret;

examples/posix/wh_posix_server/user_settings.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ extern "C" {
3535
/* #define WC_NO_ASYNC_THREADING */
3636

3737
/*
38-
#define DEBUG_CRYPTOCB
39-
#define DEBUG_CRYPTOCB_VERBOSE
38+
#define WOLFHSM_CFG_DEBUG
39+
#define WOLFHSM_CFG_DEBUG_VERBOSE
4040
*/
4141

4242
/** wolfHSM required settings for wolfCrypt */

src/wh_client_crypto.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4335,8 +4335,8 @@ static int _MlDsaMakeKey(whClientContext* ctx, int size, int level,
43354335
* scenarios */
43364336
if (ret >= 0) {
43374337
WH_DEBUG_CLIENT_VERBOSE(
4338-
"%s Res recv:keyid:%u, len:%u, ret:%d\n",
4339-
__func__, (unsigned int)res->keyId,
4338+
"Res recv:keyid:%u, len:%u, ret:%d\n",
4339+
(unsigned int)res->keyId,
43404340
(unsigned int)res->len, ret);
43414341
/* Key is cached on server or is ephemeral */
43424342
key_id = (whKeyId)(res->keyId);

src/wh_server_crypto.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4084,10 +4084,8 @@ static int _HandleMlDsaKeyGenDma(whServerContext* ctx, uint16_t magic,
40844084
if (WH_KEYID_ISERASED(keyId)) {
40854085
/* Generate a new id */
40864086
ret = wh_Server_KeystoreGetUniqueId(ctx, &keyId);
4087-
#ifdef WOLFHSM_CFG_DEBUG
4088-
WH_DEBUG_SERVER("%s UniqueId: keyId:%u, ret:%d\n",
4089-
__func__, keyId, ret);
4090-
#endif
4087+
WH_DEBUG_SERVER("UniqueId: keyId:%u, ret:%d\n",
4088+
keyId, ret);
40914089
if (ret != WH_ERROR_OK) {
40924090
/* Early return on unique ID generation failure
40934091
*/

test/wh_test_clientserver.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "wolfhsm/wh_settings.h"
2424

2525
#include "wh_test_common.h"
26+
#include "wh_test_clientserver.h"
2627
#include "wolfhsm/wh_error.h"
2728

2829
#include "wolfhsm/wh_comm.h"

wolfhsm/wh_client.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2433,6 +2433,21 @@ int wh_Client_CertVerifyAcertDmaRequest(whClientContext* c, const void* cert,
24332433
int wh_Client_CertVerifyAcertDmaResponse(whClientContext* c, int32_t* out_rc);
24342434

24352435
#if defined(WOLFHSM_CFG_DMA)
2436+
/**
2437+
* @brief Registers a DMA address allowlist for client-side validation
2438+
*
2439+
* This function allows the client to register an allowlist of valid DMA
2440+
* addresses. The allowlist will be checked during DMA operations to ensure
2441+
* addresses are within allowed ranges.
2442+
*
2443+
* @param[in] client Pointer to the client context.
2444+
* @param[in] allowlist Pointer to the DMA address allowlist structure.
2445+
* @return int Returns WH_ERROR_OK on success, or WH_ERROR_BADARGS if the
2446+
* arguments are invalid.
2447+
*/
2448+
int wh_Client_DmaRegisterAllowList(struct whClientContext_t* client,
2449+
const whDmaAddrAllowList* allowlist);
2450+
24362451
/**
24372452
* @brief Registers a custom client DMA callback
24382453
*

wolfhsm/wh_message_crypto.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -868,6 +868,15 @@ typedef struct {
868868
whMessageCrypto_DmaAddrStatus dmaAddrStatus;
869869
} whMessageCrypto_Sha2DmaResponse;
870870

871+
/* DMA buffer translation functions */
872+
int wh_MessageCrypto_TranslateDmaBuffer(uint16_t magic,
873+
const whMessageCrypto_DmaBuffer* src,
874+
whMessageCrypto_DmaBuffer* dest);
875+
876+
int wh_MessageCrypto_TranslateDmaAddrStatus(
877+
uint16_t magic, const whMessageCrypto_DmaAddrStatus* src,
878+
whMessageCrypto_DmaAddrStatus* dest);
879+
871880
/* SHA2 DMA translation functions */
872881
int wh_MessageCrypto_TranslateSha2DmaRequest(
873882
uint16_t magic, const whMessageCrypto_Sha2DmaRequest* src,

wolfhsm/wh_server_cert.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,24 @@ int wh_Server_CertVerify(whServerContext* server, const uint8_t* cert,
9292
uint32_t cert_len, whNvmId trustedRootNvmId,
9393
whCertFlags flags, whKeyId* inout_keyId);
9494

95+
#if defined(WOLFHSM_CFG_CERTIFICATE_MANAGER_ACERT)
96+
/**
97+
* @brief Verifies an attribute certificate against a trusted root certificate
98+
*
99+
* This function retrieves a trusted root certificate from NVM using the
100+
* specified NVM ID and verifies the provided attribute certificate against it.
101+
*
102+
* @param[in] server Pointer to the server context
103+
* @param[in] cert Pointer to the attribute certificate data to verify
104+
* @param[in] cert_len Length of the certificate data in bytes
105+
* @param[in] trustedRootNvmId NVM ID of the trusted root certificate to verify
106+
* against
107+
* @return int Returns 0 on success, or a negative error code on failure.
108+
*/
109+
int wh_Server_CertVerifyAcert(whServerContext* server, const uint8_t* cert,
110+
uint32_t cert_len, whNvmId trustedRootNvmId);
111+
#endif
112+
95113
/**
96114
* @brief Handle a certificate request and generate a response
97115
* @param server The server context

0 commit comments

Comments
 (0)