mirror of
https://git.code.sf.net/p/linux-ima/ima-evm-utils
synced 2025-07-12 02:00:42 +02:00
ima-evm-utils: Add support for Intel TSS2 for PCR reading
This patch makes it possible to use the Intel TSS2 for getting PCR values from the SHA1/SHA256 banks on a TPM2. It is somewhat naive as it doesn't use the multi-PCR selection that TSS2 is capable of, that is for a future patch. Signed-off-by: Patrick Uiterwijk <patrick@puiterwijk.org> [zohar@linux.ibm.com: added missing "stdint.h" in pcr_tsspcrread.c] Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
This commit is contained in:

committed by
Mimi Zohar

parent
e532fb65fd
commit
03f99ea6d0
32
src/utils.c
Normal file
32
src/utils.c
Normal file
@ -0,0 +1,32 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include "utils.h"
|
||||
|
||||
int hex_to_bin(char ch)
|
||||
{
|
||||
if ((ch >= '0') && (ch <= '9'))
|
||||
return ch - '0';
|
||||
ch = tolower(ch);
|
||||
if ((ch >= 'a') && (ch <= 'f'))
|
||||
return ch - 'a' + 10;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int hex2bin(void *dst, const char *src, size_t count)
|
||||
{
|
||||
int hi, lo;
|
||||
|
||||
while (count--) {
|
||||
if (*src == ' ')
|
||||
src++;
|
||||
|
||||
hi = hex_to_bin(*src++);
|
||||
lo = hex_to_bin(*src++);
|
||||
|
||||
if ((hi < 0) || (lo < 0))
|
||||
return -1;
|
||||
|
||||
*(uint8_t *)dst++ = (hi << 4) | lo;
|
||||
}
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user