Skip to content

Commit 967cf55

Browse files
committed
Phase 1 cleanup: drop debug-era artifacts and Phase labels
- include/wolfboot/wcs_wolfhsm.h: remove WCS_WOLFHSM_MAX_REQ_SIZE / MAX_RSP_SIZE macros that hardcoded 1288U; the value is just WH_COMM_MTU and silently desyncs if WOLFHSM_CFG_COMM_DATA_LEN changes - src/wolfhsm_callable.c: use WH_COMM_MTU directly in size guards; replace bare 56 server_id with WCS_WOLFHSM_SERVER_ID; drop Phase 1b / Phase 3 comment, keep only the real-HW pageSize=8 invariant - test-app/wcs/wolfhsm_test.c: drop unused wolfboot/wcs_wolfhsm.h include; reword the Phase 1c exerciser header to a stable description m33mu still green (CommInit + RNG round-trip + BKPT 0x7f).
1 parent 1a47dd8 commit 967cf55

3 files changed

Lines changed: 9 additions & 22 deletions

File tree

include/wolfboot/wcs_wolfhsm.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,6 @@
1313

1414
#ifdef WOLFCRYPT_TZ_WOLFHSM
1515

16-
/* Match wolfHSM's WH_COMM_MTU; bridge buffers are sized to this. */
17-
#ifndef WCS_WOLFHSM_MAX_REQ_SIZE
18-
#define WCS_WOLFHSM_MAX_REQ_SIZE 1288U
19-
#endif
20-
21-
#ifndef WCS_WOLFHSM_MAX_RSP_SIZE
22-
#define WCS_WOLFHSM_MAX_RSP_SIZE 1288U
23-
#endif
24-
2516
int CSME_NSE_API wcs_wolfhsm_transmit(const uint8_t *cmd, uint32_t cmdSz,
2617
uint8_t *rsp, uint32_t *rspSz);
2718

src/wolfhsm_callable.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,15 @@ void *_sbrk(unsigned int incr)
3636
(uint32_t)(&_heap_size));
3737
}
3838

39-
/* Phase 1b uses a 32 KiB ramsim partition pair for the NVM backend; Phase 3
40-
* swaps this for a flash-backed adapter over wolfBoot's hal_flash_*.
41-
* pageSize must match WHFU_BYTES_PER_UNIT (8) — wolfHSM programs the flash
39+
/* pageSize must match WHFU_BYTES_PER_UNIT (8) — wolfHSM programs the flash
4240
* one unit at a time, so a larger pageSize causes the modulo check in
4341
* whFlashRamsim_Program to fail. */
4442
#define WCS_WOLFHSM_RAMSIM_SIZE (32U * 1024U)
4543
#define WCS_WOLFHSM_RAMSIM_SECTOR (8U * 1024U)
4644
#define WCS_WOLFHSM_RAMSIM_PAGE 8U
4745

46+
#define WCS_WOLFHSM_SERVER_ID 56U
47+
4848
static uint8_t g_ramsim_buf[WCS_WOLFHSM_RAMSIM_SIZE];
4949
static whFlashRamsimCtx g_ramsim_ctx;
5050
static whFlashRamsimCfg g_ramsim_cfg = {
@@ -78,7 +78,7 @@ static whCommServerConfig g_comm_cfg = {
7878
.transport_context = &g_srv_tx_ctx,
7979
.transport_cb = &whTransportNscServer_Cb,
8080
.transport_config = &g_srv_tx_cfg,
81-
.server_id = 56, /* server identifier; NS client uses client_id=1 */
81+
.server_id = WCS_WOLFHSM_SERVER_ID,
8282
};
8383
static whServerConfig g_server_cfg = {
8484
.comm_config = &g_comm_cfg,
@@ -129,10 +129,10 @@ int CSME_NSE_API wcs_wolfhsm_transmit(const uint8_t *cmd, uint32_t cmdSz,
129129
* only this local copy. The NS caller cannot mutate it under us. */
130130
rsp_capacity = *rspSz;
131131

132-
if (cmdSz == 0U || cmdSz > WCS_WOLFHSM_MAX_REQ_SIZE) {
132+
if (cmdSz == 0U || cmdSz > WH_COMM_MTU) {
133133
return WH_ERROR_BADARGS;
134134
}
135-
if (rsp_capacity == 0U || rsp_capacity > WCS_WOLFHSM_MAX_RSP_SIZE) {
135+
if (rsp_capacity == 0U || rsp_capacity > WH_COMM_MTU) {
136136
return WH_ERROR_BADARGS;
137137
}
138138
if (!g_wolfhsm_ready) {

test-app/wcs/wolfhsm_test.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
#include <stdio.h>
1212
#include <string.h>
1313

14-
#include "wolfboot/wcs_wolfhsm.h"
15-
1614
#include "wolfhsm/wh_client.h"
1715
#include "wolfhsm/wh_comm.h"
1816
#include "wolfhsm/wh_error.h"
@@ -59,11 +57,9 @@ static int wolfhsm_test_rng(void)
5957
return 0;
6058
}
6159

62-
/*
63-
* Phase 1c exerciser. Initializes the wolfHSM client (which auto-registers
64-
* the wolfCrypt cryptocb under WH_DEV_ID), runs the CommInit handshake, then
65-
* exercises a real crypto op (RNG) routed through the secure-side server.
66-
*/
60+
/* Initializes the wolfHSM client (auto-registers the wolfCrypt cryptocb
61+
* under WH_DEV_ID), runs the CommInit handshake, exercises one crypto
62+
* round-trip (RNG) through the secure-side server. */
6763
int cmd_wolfhsm_test(const char *args)
6864
{
6965
static const whTransportNscClientConfig nsc_cfg = { 0 };

0 commit comments

Comments
 (0)