diff options
author | Miquel Raynal <miquel.raynal@bootlin.com> | 2018-05-15 11:57:15 +0200 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2018-05-25 20:12:57 -0400 |
commit | 6284be5a904ef808c939c3d926ee720d1b988264 (patch) | |
tree | 64d3c64632b6b8b069aafa45b34f23a4b49ae4ba /cmd | |
parent | bad8ff569d1d0a0eb20355845f27b4f6dad48b63 (diff) | |
download | u-boot-6284be5a904ef808c939c3d926ee720d1b988264.tar.gz |
tpm: add TPM2_PCR_Extend command support
Add support for the TPM2_PCR_Extend command.
Change the command file and the help accordingly.
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/tpm-v2.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/cmd/tpm-v2.c b/cmd/tpm-v2.c index 6f34987037..0a7a5c8074 100644 --- a/cmd/tpm-v2.c +++ b/cmd/tpm-v2.c @@ -7,6 +7,7 @@ #include <common.h> #include <dm.h> #include <log.h> +#include <mapmem.h> #include <tpm-common.h> #include <tpm-v2.h> #include "tpm-user-utils.h" @@ -74,12 +75,44 @@ static int do_tpm2_clear(cmd_tbl_t *cmdtp, int flag, int argc, return report_return_code(tpm2_clear(handle, pw, pw_sz)); } +static int do_tpm2_pcr_extend(cmd_tbl_t *cmdtp, int flag, int argc, + char * const argv[]) +{ + struct udevice *dev; + struct tpm_chip_priv *priv; + u32 index = simple_strtoul(argv[1], NULL, 0); + void *digest = map_sysmem(simple_strtoul(argv[2], NULL, 0), 0); + int ret; + u32 rc; + + if (argc != 3) + return CMD_RET_USAGE; + + ret = uclass_first_device_err(UCLASS_TPM, &dev); + if (ret) + return ret; + + priv = dev_get_uclass_priv(dev); + if (!priv) + return -EINVAL; + + if (index >= priv->pcr_count) + return -EINVAL; + + rc = tpm2_pcr_extend(index, digest); + + unmap_sysmem(digest); + + return report_return_code(rc); +} + static cmd_tbl_t tpm2_commands[] = { U_BOOT_CMD_MKENT(info, 0, 1, do_tpm_info, "", ""), U_BOOT_CMD_MKENT(init, 0, 1, do_tpm_init, "", ""), U_BOOT_CMD_MKENT(startup, 0, 1, do_tpm2_startup, "", ""), U_BOOT_CMD_MKENT(self_test, 0, 1, do_tpm2_self_test, "", ""), U_BOOT_CMD_MKENT(clear, 0, 1, do_tpm2_clear, "", ""), + U_BOOT_CMD_MKENT(pcr_extend, 0, 1, do_tpm2_pcr_extend, "", ""), }; cmd_tbl_t *get_tpm_commands(unsigned int *size) @@ -111,4 +144,8 @@ U_BOOT_CMD(tpm, CONFIG_SYS_MAXARGS, 1, do_tpm, "Issue a TPMv2.x command", " <hierarchy> is one of:\n" " * TPM2_RH_LOCKOUT\n" " * TPM2_RH_PLATFORM\n" +"pcr_extend <pcr> <digest_addr>\n" +" Extend PCR #<pcr> with digest at <digest_addr>.\n" +" <pcr>: index of the PCR\n" +" <digest_addr>: address of a 32-byte SHA256 digest\n" ); |