tests: Remove checks for sizes of ppList and auditCommands

It is not necessary anymore to check for an increase of the sizes of the
PERSISTENT_DATA ppList and auditCommands fields since they are marshalled
with an array-size indicator.

Any previous version of libtpms should be able to resume a profile with
the ppList and auditCommands written with a later version. If later
versions have new commands, then those new commands must be added beyond
the current TPM_CC_FIRST. The ppList and auditCommands may be bigger
than before but can be truncated IFF new commands were added. These
new commands will not be usable with the older verison of libtpms based
on the StateFormatLevel then.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
This commit is contained in:
Stefan Berger 2026-03-05 09:35:32 -05:00
parent a620c161bf
commit 636af2caa8
2 changed files with 2 additions and 24 deletions

View File

@ -413,6 +413,8 @@ RuntimeCommandsCountEnabled(struct RuntimeCommands *RuntimeCommands)
TPM_CC commandCode;
UINT32 count = 0;
/* the following assert must never change */
MUST_BE(TPM_CC_FIRST == TPM_CC_NV_UndefineSpaceSpecial);
for (commandCode = TPM_CC_FIRST;
commandCode < sizeof(RuntimeCommands->enabledCommands) * 8;
commandCode++) {

View File

@ -8,30 +8,6 @@ extern BYTE s_indexOrderlyRam[RAM_INDEX_SPACE];
int main(void)
{
PERSISTENT_DATA pd;
/* Check size of ppList that expands with new commands */
/* was 14 when COMPRESSED_LISTS was enabled */
#define PD_PP_LIST_EXP_SIZE 17
if (sizeof(pd.ppList) != PD_PP_LIST_EXP_SIZE) {
fprintf(stderr,
"sizeof(PERSISTENT_DATA.ppList) does not have expected size "
"of %u bytes but %zu bytes\n",
PD_PP_LIST_EXP_SIZE, sizeof(pd.ppList));
return EXIT_FAILURE;
}
/* Check size of auditCommands that expands with new commands */
/* was 14 when COMPRESSED_LISTS was enabled */
#define PD_AUDIT_COMMANDS_EXP_SIZE 17
if (sizeof(pd.auditCommands) != PD_AUDIT_COMMANDS_EXP_SIZE) {
fprintf(stderr,
"sizeof(PERSISTENT_DATA.auditCommands) does not have expected size "
"of %u bytes but %zu bytes\n",
PD_AUDIT_COMMANDS_EXP_SIZE, sizeof(pd.auditCommands));
return EXIT_FAILURE;
}
/* ensure that the NVRAM offset of NV_USER_DYNAMIC is at the expected
location so that there's enough memory for re-constructing NVRAM
indices etc. into the NVRAM */