Skip to content

Commit 8a1da7a

Browse files
committed
Apply git-clang-format
1 parent a018af2 commit 8a1da7a

File tree

2 files changed

+81
-83
lines changed

2 files changed

+81
-83
lines changed

src/wh_client_she.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ int wh_Client_SheSecureBoot(whClientContext* c, uint8_t* bootloader,
156156
while (ret == 0 && bootloaderSent < bootloaderLen) {
157157
uint8_t* in;
158158
uint32_t justSent;
159-
uint32_t remaining;
159+
uint32_t remaining;
160160
static const uint32_t maxChunk =
161161
WOLFHSM_CFG_COMM_DATA_LEN - sizeof(*updateReq);
162162

@@ -171,7 +171,7 @@ int wh_Client_SheSecureBoot(whClientContext* c, uint8_t* bootloader,
171171
in = (uint8_t*)(updateReq + 1);
172172

173173
/* send what's left in the size available */
174-
remaining = bootloaderLen - bootloaderSent;
174+
remaining = bootloaderLen - bootloaderSent;
175175
updateReq->sz = (remaining > maxChunk) ? maxChunk : remaining;
176176

177177
justSent = updateReq->sz;

test/wh_test_she.c

Lines changed: 79 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,11 @@
7474
#endif
7575

7676
enum {
77-
REQ_SIZE = 32,
78-
RESP_SIZE = 64,
79-
BUFFER_SIZE = sizeof(whTransportMemCsr) + sizeof(whCommHeader) +
80-
WOLFHSM_CFG_COMM_DATA_LEN,
81-
};
77+
REQ_SIZE = 32,
78+
RESP_SIZE = 64,
79+
BUFFER_SIZE = sizeof(whTransportMemCsr) + sizeof(whCommHeader) +
80+
WOLFHSM_CFG_COMM_DATA_LEN,
81+
};
8282

8383
#define FLASH_RAM_SIZE (1024 * 1024) /* 1MB */
8484
#define FLASH_SECTOR_SIZE (128 * 1024) /* 128KB */
@@ -435,23 +435,22 @@ int whTest_SheClientConfig(whClientConfig* config)
435435
defined(WOLFHSM_CFG_ENABLE_SERVER)
436436
static int whTest_SheClientConfigBoundarySecureBoot(whClientConfig* config)
437437
{
438-
int ret = 0;
439-
WC_RNG rng[1];
440-
Cmac cmac[1];
441-
whClientContext client[1] = {0};
442-
uint8_t key[16] = {0};
443-
uint8_t zeros[WH_SHE_BOOT_MAC_PREFIX_LEN] = {0};
444-
uint8_t sheUid[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
445-
0x00, 0x00, 0x00, 0x00, 0x00, 0x01};
446-
uint8_t bootMacDigest[16] = {0};
447-
uint8_t sreg = 0;
448-
uint8_t bootloaderBoundary[
449-
WOLFHSM_CFG_COMM_DATA_LEN -
450-
sizeof(whMessageShe_SecureBootUpdateRequest)];
451-
uint32_t digestSz = sizeof(bootMacDigest);
452-
uint32_t bootloaderSz;
453-
uint32_t serverCommDataLen = WOLFHSM_CFG_COMM_DATA_LEN;
454-
uint32_t maxBoundaryUpdateChunk =
438+
int ret = 0;
439+
WC_RNG rng[1];
440+
Cmac cmac[1];
441+
whClientContext client[1] = {0};
442+
uint8_t key[16] = {0};
443+
uint8_t zeros[WH_SHE_BOOT_MAC_PREFIX_LEN] = {0};
444+
uint8_t sheUid[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
445+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01};
446+
uint8_t bootMacDigest[16] = {0};
447+
uint8_t sreg = 0;
448+
uint8_t bootloaderBoundary[WOLFHSM_CFG_COMM_DATA_LEN -
449+
sizeof(whMessageShe_SecureBootUpdateRequest)];
450+
uint32_t digestSz = sizeof(bootMacDigest);
451+
uint32_t bootloaderSz;
452+
uint32_t serverCommDataLen = WOLFHSM_CFG_COMM_DATA_LEN;
453+
uint32_t maxBoundaryUpdateChunk =
455454
WOLFHSM_CFG_COMM_DATA_LEN -
456455
sizeof(whMessageShe_SecureBootUpdateRequest);
457456
uint32_t outClientId = 0;
@@ -462,10 +461,11 @@ static int whTest_SheClientConfigBoundarySecureBoot(whClientConfig* config)
462461
}
463462

464463
WH_TEST_RETURN_ON_FAIL(wh_Client_Init(client, config));
465-
WH_TEST_RETURN_ON_FAIL(wh_Client_CommInit(client, &outClientId, &outServerId));
466-
WH_TEST_RETURN_ON_FAIL(wh_Client_CommInfo(client, NULL, NULL,
467-
&serverCommDataLen, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
468-
NULL, NULL, NULL, NULL));
464+
WH_TEST_RETURN_ON_FAIL(
465+
wh_Client_CommInit(client, &outClientId, &outServerId));
466+
WH_TEST_RETURN_ON_FAIL(wh_Client_CommInfo(
467+
client, NULL, NULL, &serverCommDataLen, NULL, NULL, NULL, NULL, NULL,
468+
NULL, NULL, NULL, NULL, NULL, NULL));
469469

470470
if (serverCommDataLen <= sizeof(whMessageShe_SecureBootUpdateRequest)) {
471471
WH_ERROR_PRINT("Invalid server cfg_comm_data_len %u\n",
@@ -508,8 +508,7 @@ static int whTest_SheClientConfigBoundarySecureBoot(whClientConfig* config)
508508
WH_ERROR_PRINT("Failed to wc_CmacUpdate %d\n", ret);
509509
goto exit_boundary;
510510
}
511-
if ((ret = wc_CmacUpdate(cmac, bootloaderBoundary,
512-
bootloaderSz)) != 0) {
511+
if ((ret = wc_CmacUpdate(cmac, bootloaderBoundary, bootloaderSz)) != 0) {
513512
WH_ERROR_PRINT("Failed to wc_CmacUpdate %d\n", ret);
514513
goto exit_boundary;
515514
}
@@ -616,7 +615,7 @@ int whTest_SheServerConfig(whServerConfig* config)
616615
typedef int (*whTestSheClientFn)(whClientConfig* config);
617616

618617
typedef struct {
619-
whClientConfig* clientConfig;
618+
whClientConfig* clientConfig;
620619
whTestSheClientFn clientFn;
621620
} whTestSheClientTaskCtx;
622621

@@ -639,15 +638,15 @@ static void* _whServerTask(void* cf)
639638

640639
#if defined(WOLFHSM_CFG_TEST_POSIX) && defined(WOLFHSM_CFG_ENABLE_CLIENT) && \
641640
defined(WOLFHSM_CFG_ENABLE_SERVER)
642-
static void _whClientServerThreadTest(whClientConfig* c_conf,
643-
whServerConfig* s_conf,
644-
whTestSheClientFn clientFn)
641+
static void _whClientServerThreadTest(whClientConfig* c_conf,
642+
whServerConfig* s_conf,
643+
whTestSheClientFn clientFn)
645644
{
646645
pthread_t cthread = {0};
647646
pthread_t sthread = {0};
648647
whTestSheClientTaskCtx cTaskCtx = {
649648
.clientConfig = c_conf,
650-
.clientFn = clientFn,
649+
.clientFn = clientFn,
651650
};
652651

653652
void* retval;
@@ -765,58 +764,58 @@ static int wh_ClientServer_MemThreadTest(whTestSheClientFn clientFn)
765764
#if defined(WOLFHSM_CFG_ENABLE_SERVER)
766765
static int wh_She_TestMasterEcuKeyFallback(void)
767766
{
768-
int ret = 0;
769-
whServerContext server[1] = {0};
770-
whNvmMetadata outMeta[1] = {0};
767+
int ret = 0;
768+
whServerContext server[1] = {0};
769+
whNvmMetadata outMeta[1] = {0};
771770
uint8_t keyBuf[WH_SHE_KEY_SZ] = {0};
772-
uint32_t keySz = sizeof(keyBuf);
773-
uint8_t zeros[WH_SHE_KEY_SZ] = {0};
771+
uint32_t keySz = sizeof(keyBuf);
772+
uint8_t zeros[WH_SHE_KEY_SZ] = {0};
774773
whKeyId masterEcuKeyId;
775774

776775
/* Transport (not used, but required for server init) */
777-
uint8_t reqBuf[BUFFER_SIZE] = {0};
778-
uint8_t respBuf[BUFFER_SIZE] = {0};
779-
whTransportMemConfig tmcf[1] = {{
780-
.req = (whTransportMemCsr*)reqBuf,
781-
.req_size = sizeof(reqBuf),
782-
.resp = (whTransportMemCsr*)respBuf,
783-
.resp_size = sizeof(respBuf),
776+
uint8_t reqBuf[BUFFER_SIZE] = {0};
777+
uint8_t respBuf[BUFFER_SIZE] = {0};
778+
whTransportMemConfig tmcf[1] = {{
779+
.req = (whTransportMemCsr*)reqBuf,
780+
.req_size = sizeof(reqBuf),
781+
.resp = (whTransportMemCsr*)respBuf,
782+
.resp_size = sizeof(respBuf),
784783
}};
785-
whTransportServerCb tscb[1] = {WH_TRANSPORT_MEM_SERVER_CB};
786-
whTransportMemServerContext tmsc[1] = {0};
784+
whTransportServerCb tscb[1] = {WH_TRANSPORT_MEM_SERVER_CB};
785+
whTransportMemServerContext tmsc[1] = {0};
787786
whCommServerConfig cs_conf[1] = {{
788-
.transport_cb = tscb,
789-
.transport_context = (void*)tmsc,
790-
.transport_config = (void*)tmcf,
791-
.server_id = 124,
787+
.transport_cb = tscb,
788+
.transport_context = (void*)tmsc,
789+
.transport_config = (void*)tmcf,
790+
.server_id = 124,
792791
}};
793792

794793
/* RamSim Flash state and configuration */
795-
uint8_t memory[FLASH_RAM_SIZE] = {0};
796-
whFlashRamsimCtx fc[1] = {0};
797-
whFlashRamsimCfg fc_conf[1] = {{
798-
.size = FLASH_RAM_SIZE,
799-
.sectorSize = FLASH_SECTOR_SIZE,
800-
.pageSize = FLASH_PAGE_SIZE,
801-
.erasedByte = ~(uint8_t)0,
802-
.memory = memory,
794+
uint8_t memory[FLASH_RAM_SIZE] = {0};
795+
whFlashRamsimCtx fc[1] = {0};
796+
whFlashRamsimCfg fc_conf[1] = {{
797+
.size = FLASH_RAM_SIZE,
798+
.sectorSize = FLASH_SECTOR_SIZE,
799+
.pageSize = FLASH_PAGE_SIZE,
800+
.erasedByte = ~(uint8_t)0,
801+
.memory = memory,
803802
}};
804-
const whFlashCb fcb[1] = {WH_FLASH_RAMSIM_CB};
803+
const whFlashCb fcb[1] = {WH_FLASH_RAMSIM_CB};
805804

806805
/* NVM */
807-
whNvmFlashConfig nf_conf[1] = {{
808-
.cb = fcb,
809-
.context = fc,
810-
.config = fc_conf,
806+
whNvmFlashConfig nf_conf[1] = {{
807+
.cb = fcb,
808+
.context = fc,
809+
.config = fc_conf,
811810
}};
812-
whNvmFlashContext nfc[1] = {0};
813-
whNvmCb nfcb[1] = {WH_NVM_FLASH_CB};
814-
whNvmConfig n_conf[1] = {{
815-
.cb = nfcb,
816-
.context = nfc,
817-
.config = nf_conf,
811+
whNvmFlashContext nfc[1] = {0};
812+
whNvmCb nfcb[1] = {WH_NVM_FLASH_CB};
813+
whNvmConfig n_conf[1] = {{
814+
.cb = nfcb,
815+
.context = nfc,
816+
.config = nf_conf,
818817
}};
819-
whNvmContext nvm[1] = {{0}};
818+
whNvmContext nvm[1] = {{0}};
820819

821820
/* Crypto context */
822821
whServerCryptoContext crypto[1] = {{
@@ -838,19 +837,17 @@ static int wh_She_TestMasterEcuKeyFallback(void)
838837
WH_TEST_RETURN_ON_FAIL(wolfCrypt_Init());
839838
WH_TEST_RETURN_ON_FAIL(wc_InitRng_ex(crypto->rng, NULL, crypto->devId));
840839
WH_TEST_RETURN_ON_FAIL(wh_Server_Init(server, s_conf));
841-
WH_TEST_RETURN_ON_FAIL(
842-
wh_Server_SetConnected(server, WH_COMM_CONNECTED));
840+
WH_TEST_RETURN_ON_FAIL(wh_Server_SetConnected(server, WH_COMM_CONNECTED));
843841

844-
masterEcuKeyId = WH_MAKE_KEYID(WH_KEYTYPE_SHE,
845-
server->comm->client_id,
846-
WH_SHE_MASTER_ECU_KEY_ID);
842+
masterEcuKeyId = WH_MAKE_KEYID(WH_KEYTYPE_SHE, server->comm->client_id,
843+
WH_SHE_MASTER_ECU_KEY_ID);
847844

848845
/* Fill keyBuf with non-zero to ensure it gets overwritten */
849846
memset(keyBuf, 0xFF, sizeof(keyBuf));
850847

851848
/* Read master ECU key when it has never been provisioned */
852-
ret = wh_Server_KeystoreReadKey(server, masterEcuKeyId, outMeta,
853-
keyBuf, &keySz);
849+
ret = wh_Server_KeystoreReadKey(server, masterEcuKeyId, outMeta, keyBuf,
850+
&keySz);
854851

855852
WH_TEST_ASSERT_RETURN(ret == 0);
856853
WH_TEST_ASSERT_RETURN(keySz == WH_SHE_KEY_SZ);
@@ -876,10 +873,11 @@ int whTest_She(void)
876873
WH_TEST_PRINT("Testing SHE: master ECU key fallback...\n");
877874
WH_TEST_RETURN_ON_FAIL(wh_She_TestMasterEcuKeyFallback());
878875
WH_TEST_PRINT("Testing SHE: (pthread) mem core flow...\n");
879-
WH_TEST_RETURN_ON_FAIL(wh_ClientServer_MemThreadTest(whTest_SheClientConfig));
880-
WH_TEST_PRINT("Testing SHE: (pthread) mem boundary secure boot...\n");
881876
WH_TEST_RETURN_ON_FAIL(
882-
wh_ClientServer_MemThreadTest(whTest_SheClientConfigBoundarySecureBoot));
877+
wh_ClientServer_MemThreadTest(whTest_SheClientConfig));
878+
WH_TEST_PRINT("Testing SHE: (pthread) mem boundary secure boot...\n");
879+
WH_TEST_RETURN_ON_FAIL(wh_ClientServer_MemThreadTest(
880+
whTest_SheClientConfigBoundarySecureBoot));
883881
return 0;
884882
}
885883
#endif

0 commit comments

Comments
 (0)