summaryrefslogtreecommitdiff
path: root/lib/tpm-v2.c
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2020-12-03 16:21:51 -0500
committerTom Rini <trini@konsulko.com>2020-12-03 16:21:51 -0500
commit5157ea526142ace7b0b19939b0d31ace4276cda7 (patch)
treec4d017c6ba1e3467f2e1ff96b29e93488b62668b /lib/tpm-v2.c
parenta2c832471115d382d6dd60697be5bc74d2636eea (diff)
parent3616b4f4b97411db8721ae38c0fb29e145f1aed6 (diff)
Merge tag 'efi-next' of https://gitlab.denx.de/u-boot/custodians/u-boot-efi into next
Pull request for UEFI sub-system for next This pull request adds: * eventlog support for TCG2_PROTOCOL * UEFI capusule updates It replace printf by log in efi_uclass.c
Diffstat (limited to 'lib/tpm-v2.c')
-rw-r--r--lib/tpm-v2.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/tpm-v2.c b/lib/tpm-v2.c
index 91759068cf0..1f3deb06e48 100644
--- a/lib/tpm-v2.c
+++ b/lib/tpm-v2.c
@@ -80,11 +80,12 @@ u32 tpm2_clear(struct udevice *dev, u32 handle, const char *pw,
return tpm_sendrecv_command(dev, command_v2, NULL, NULL);
}
-u32 tpm2_pcr_extend(struct udevice *dev, u32 index, const uint8_t *digest)
+u32 tpm2_pcr_extend(struct udevice *dev, u32 index, u32 algorithm,
+ const u8 *digest, u32 digest_len)
{
u8 command_v2[COMMAND_BUFFER_SIZE] = {
tpm_u16(TPM2_ST_SESSIONS), /* TAG */
- tpm_u32(33 + TPM2_DIGEST_LEN), /* Length */
+ tpm_u32(33 + digest_len), /* Length */
tpm_u32(TPM2_CC_PCR_EXTEND), /* Command code */
/* HANDLE */
@@ -99,7 +100,7 @@ u32 tpm2_pcr_extend(struct udevice *dev, u32 index, const uint8_t *digest)
tpm_u16(0), /* Size of <hmac/password> */
/* <hmac/password> (if any) */
tpm_u32(1), /* Count (number of hashes) */
- tpm_u16(TPM2_ALG_SHA256), /* Algorithm of the hash */
+ tpm_u16(algorithm), /* Algorithm of the hash */
/* STRING(digest) Digest */
};
unsigned int offset = 33;
@@ -110,8 +111,8 @@ u32 tpm2_pcr_extend(struct udevice *dev, u32 index, const uint8_t *digest)
* - the digest
*/
ret = pack_byte_string(command_v2, sizeof(command_v2), "s",
- offset, digest, TPM2_DIGEST_LEN);
- offset += TPM2_DIGEST_LEN;
+ offset, digest, digest_len);
+ offset += digest_len;
if (ret)
return TPM_LIB_ERROR;