Remove bare scope blocks in spdm_ctrl.c and unit_tests.c

pull/458/head
Aidan Garske 2026-04-07 11:45:50 -07:00
parent 7dbb21e47d
commit 4d39d8b048
2 changed files with 43 additions and 48 deletions

View File

@ -224,8 +224,10 @@ static int ctrl_nations_status(WOLFTPM2_DEV* dev)
{
int rc;
int isConn;
int stsRc;
GetCapability_In capIn;
GetCapability_Out capOut;
WOLFSPDM_NATIONS_STATUS status;
printf("\n=== Nations SPDM Status ===\n");
@ -246,25 +248,20 @@ static int ctrl_nations_status(WOLFTPM2_DEV* dev)
}
/* 2. Try GET_STS_ vendor command (PSK mode only — may fail) */
{
WOLFSPDM_NATIONS_STATUS status;
int stsRc;
stsRc = wolfSPDM_GetVersion(dev->spdmCtx->spdmCtx);
stsRc = wolfSPDM_GetVersion(dev->spdmCtx->spdmCtx);
if (stsRc == 0) {
XMEMSET(&status, 0, sizeof(status));
stsRc = wolfTPM2_SpdmNationsGetStatus(dev, &status);
if (stsRc == 0) {
XMEMSET(&status, 0, sizeof(status));
stsRc = wolfTPM2_SpdmNationsGetStatus(dev, &status);
if (stsRc == 0) {
printf(" PSK: %s SPDM-Only: %s\n",
status.pskProvisioned ? "provisioned" : "not provisioned",
!status.spdmOnlyLocked ? "disabled" :
status.spdmOnlyPending ? "PENDING_DISABLE" : "ENABLED");
} else {
printf(" PSK Status: unknown (GET_STS failed)\n");
}
printf(" PSK: %s SPDM-Only: %s\n",
status.pskProvisioned ? "provisioned" : "not provisioned",
!status.spdmOnlyLocked ? "disabled" :
status.spdmOnlyPending ? "PENDING_DISABLE" : "ENABLED");
} else {
printf(" PSK Status: GET_VERSION failed\n");
printf(" PSK Status: unknown (GET_STS failed)\n");
}
} else {
printf(" PSK Status: GET_VERSION failed\n");
}
/* 3. Local session state */

View File

@ -967,6 +967,16 @@ static void test_wolfTPM2_SPDM_Functions(void)
{
int rc;
WOLFTPM2_DEV dev;
#ifdef WOLFSPDM_NUVOTON
WOLFSPDM_NUVOTON_STATUS nuvStatus;
#endif
#if defined(WOLFSPDM_NUVOTON) || defined(WOLFSPDM_NATIONS)
byte pubKey[256];
word32 pubKeySz;
#endif
#ifdef WOLFSPDM_NATIONS
WOLFSPDM_NATIONS_STATUS nStatus;
#endif
printf("Test TPM Wrapper:\tSPDM Functions:\t");
@ -1011,20 +1021,15 @@ static void test_wolfTPM2_SPDM_Functions(void)
AssertIntEQ(rc, BAD_FUNC_ARG);
rc = wolfTPM2_SpdmEnable(NULL);
AssertIntEQ(rc, BAD_FUNC_ARG);
{
WOLFSPDM_NUVOTON_STATUS status;
byte pubKey[256];
word32 pubKeySz = sizeof(pubKey);
rc = wolfTPM2_SpdmGetStatus(NULL, &status);
AssertIntEQ(rc, BAD_FUNC_ARG);
rc = wolfTPM2_SpdmGetStatus(&dev, NULL);
AssertIntEQ(rc, BAD_FUNC_ARG);
rc = wolfTPM2_SpdmGetPubKey(NULL, pubKey, &pubKeySz);
AssertIntEQ(rc, BAD_FUNC_ARG);
rc = wolfTPM2_SpdmSetOnlyMode(NULL, 0);
AssertIntEQ(rc, BAD_FUNC_ARG);
}
pubKeySz = sizeof(pubKey);
rc = wolfTPM2_SpdmGetStatus(NULL, &nuvStatus);
AssertIntEQ(rc, BAD_FUNC_ARG);
rc = wolfTPM2_SpdmGetStatus(&dev, NULL);
AssertIntEQ(rc, BAD_FUNC_ARG);
rc = wolfTPM2_SpdmGetPubKey(NULL, pubKey, &pubKeySz);
AssertIntEQ(rc, BAD_FUNC_ARG);
rc = wolfTPM2_SpdmSetOnlyMode(NULL, 0);
AssertIntEQ(rc, BAD_FUNC_ARG);
#endif /* WOLFSPDM_NUVOTON */
#ifdef WOLFSPDM_NATIONS
@ -1033,27 +1038,20 @@ static void test_wolfTPM2_SPDM_Functions(void)
AssertIntEQ(rc, BAD_FUNC_ARG);
rc = wolfTPM2_SpdmNationsIdentityKeySet(NULL, 0);
AssertIntEQ(rc, BAD_FUNC_ARG);
{
byte pubKey[256];
word32 pubKeySz = sizeof(pubKey);
rc = wolfTPM2_SpdmGetPubKey(NULL, pubKey, &pubKeySz);
AssertIntEQ(rc, BAD_FUNC_ARG);
}
pubKeySz = sizeof(pubKey);
rc = wolfTPM2_SpdmGetPubKey(NULL, pubKey, &pubKeySz);
AssertIntEQ(rc, BAD_FUNC_ARG);
/* Nations PSK wrapper parameter validation */
rc = wolfTPM2_SpdmConnectNationsPsk(NULL, NULL, 0, NULL, 0);
AssertIntEQ(rc, BAD_FUNC_ARG);
{
WOLFSPDM_NATIONS_STATUS nStatus;
rc = wolfTPM2_SpdmNationsGetStatus(NULL, &nStatus);
AssertIntEQ(rc, BAD_FUNC_ARG);
rc = wolfTPM2_SpdmNationsSetOnlyMode(NULL, 0);
AssertIntEQ(rc, BAD_FUNC_ARG);
rc = wolfTPM2_SpdmNationsPskSet(NULL, NULL, 0);
AssertIntEQ(rc, BAD_FUNC_ARG);
rc = wolfTPM2_SpdmNationsPskClear(NULL, NULL, 0);
AssertIntEQ(rc, BAD_FUNC_ARG);
}
rc = wolfTPM2_SpdmNationsGetStatus(NULL, &nStatus);
AssertIntEQ(rc, BAD_FUNC_ARG);
rc = wolfTPM2_SpdmNationsSetOnlyMode(NULL, 0);
AssertIntEQ(rc, BAD_FUNC_ARG);
rc = wolfTPM2_SpdmNationsPskSet(NULL, NULL, 0);
AssertIntEQ(rc, BAD_FUNC_ARG);
rc = wolfTPM2_SpdmNationsPskClear(NULL, NULL, 0);
AssertIntEQ(rc, BAD_FUNC_ARG);
#endif /* WOLFSPDM_NATIONS */
wolfTPM2_Cleanup(&dev);