1
0
mirror of https://git.code.sf.net/p/linux-ima/ima-evm-utils synced 2025-07-01 21:31:14 +02:00

Change PCR iterator from int to uint32_t

PCR numbers are naturally unsigned values.  Further, they are
32 bits, even on 64-bit machines. This change eliminates the
need for negative value and overflow tests.

The parameter name is changed from j and idx to pcr_handle, which is
more descriptive and is similar to the parameter name used in the TPM
2.0 specification.

Signed-off-by: Ken Goldman <kgoldman@us.ibm.com>
Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
This commit is contained in:
Ken Goldman
2021-08-03 16:40:07 -04:00
committed by Mimi Zohar
parent efacc1f396
commit e52fc1d330
4 changed files with 15 additions and 10 deletions

View File

@ -68,7 +68,7 @@ int tpm2_pcr_supported(void)
return 1;
}
int tpm2_pcr_read(const char *algo_name, int idx, uint8_t *hwpcr,
int tpm2_pcr_read(const char *algo_name, uint32_t pcr_handle, uint8_t *hwpcr,
int len, char **errmsg)
{
FILE *fp;
@ -76,8 +76,8 @@ int tpm2_pcr_read(const char *algo_name, int idx, uint8_t *hwpcr,
char cmd[PATH_MAX + 50];
int ret;
sprintf(cmd, "%s -halg %s -ha %d -ns 2> /dev/null",
path, algo_name, idx);
sprintf(cmd, "%s -halg %s -ha %u -ns 2> /dev/null",
path, algo_name, pcr_handle);
fp = popen(cmd, "r");
if (!fp) {
ret = asprintf(errmsg, "popen failed: %s", strerror(errno));