From mboxrd@z Thu Jan 1 00:00:00 1970 From: Miquel Raynal Date: Thu, 8 Mar 2018 16:40:15 +0100 Subject: [U-Boot] [PATCH 12/18] tpm: rename the _extend() function to be _pcr_event() In-Reply-To: <20180308154021.25255-1-miquel.raynal@bootlin.com> References: <20180308154021.25255-1-miquel.raynal@bootlin.com> Message-ID: <20180308154021.25255-13-miquel.raynal@bootlin.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de The function currently called _extend() actually does what the specification defines as a _pcr_event(). Rename the function accordingly before implementing the actual _extend() command. Signed-off-by: Miquel Raynal --- cmd/tpm.c | 18 ++++++++++-------- cmd/tpm_test.c | 4 ++-- include/tpm.h | 4 ++-- lib/tpm.c | 2 +- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/cmd/tpm.c b/cmd/tpm.c index 32921e1a70..93dcd1a65c 100644 --- a/cmd/tpm.c +++ b/cmd/tpm.c @@ -324,8 +324,8 @@ static int do_tpm_nv_write_value(cmd_tbl_t *cmdtp, int flag, return report_return_code(rc); } -static int do_tpm_extend(cmd_tbl_t *cmdtp, int flag, - int argc, char * const argv[]) +static int do_tpm_pcr_event(cmd_tbl_t *cmdtp, int flag, + int argc, char * const argv[]) { uint8_t in_digest[TPM1_DIGEST_LENGTH]; uint8_t out_digest[TPM1_DIGEST_LENGTH]; @@ -333,13 +333,14 @@ static int do_tpm_extend(cmd_tbl_t *cmdtp, int flag, if (argc != 3) return CMD_RET_USAGE; + index = simple_strtoul(argv[1], NULL, 0); if (!parse_byte_string(argv[2], in_digest, NULL)) { printf("Couldn't parse byte string %s\n", argv[2]); return CMD_RET_FAILURE; } - rc = tpm_extend(index, in_digest, out_digest); + rc = tpm_pcr_event(index, in_digest, out_digest); if (!rc) { puts("PCR value after execution of the command:\n"); print_byte_string(out_digest, TPM1_DIGEST_LENGTH); @@ -887,8 +888,8 @@ static cmd_tbl_t tpm_commands[] = { do_tpm_nv_read_value, "", ""), U_BOOT_CMD_MKENT(nv_write_value, 0, 1, do_tpm_nv_write_value, "", ""), - U_BOOT_CMD_MKENT(extend, 0, 1, - do_tpm_extend, "", ""), + U_BOOT_CMD_MKENT(pcr_event, 0, 1, + do_tpm_pcr_event, "", ""), U_BOOT_CMD_MKENT(pcr_read, 0, 1, do_tpm_pcr_read, "", ""), U_BOOT_CMD_MKENT(tsc_physical_presence, 0, 1, @@ -1019,9 +1020,10 @@ U_BOOT_CMD(tpm, CONFIG_SYS_MAXARGS, 1, do_tpm, " - Read bytes of the public endorsement key to memory\n" " address \n" "Integrity Collection and Reporting Commands:\n" -" extend index digest_hex_string\n" -" - Add a new measurement to a PCR. Update PCR with the 20-bytes\n" -" \n" +" pcr_event \n" +" - Add a new measurement to a PCR. Update PCR with\n" +" . It must be a 20 byte digest for TPMv1 or a SHA256\n" +" digest of 32 bytes for TPMv2. Value of the PCR is given at \n" " pcr_read index addr count\n" " - Read bytes from PCR to memory address .\n" #ifdef CONFIG_TPM_AUTH_SESSIONS diff --git a/cmd/tpm_test.c b/cmd/tpm_test.c index da40dbc423..0bbbdab4ee 100644 --- a/cmd/tpm_test.c +++ b/cmd/tpm_test.c @@ -104,7 +104,7 @@ static int test_early_extend(void) tpm_init(); TPM_CHECK(tpm_startup(TPM_ST_CLEAR)); TPM_CHECK(tpm_continue_self_test()); - TPM_CHECK(tpm_extend(1, value_in, value_out)); + TPM_CHECK(tpm_pcr_event(1, value_in, value_out)); printf("done\n"); return 0; } @@ -439,7 +439,7 @@ static int test_timing(void) TTPM_CHECK(tpm_tsc_physical_presence(PRESENCE), 100); TTPM_CHECK(tpm_nv_write_value(INDEX0, (uint8_t *)&x, sizeof(x)), 100); TTPM_CHECK(tpm_nv_read_value(INDEX0, (uint8_t *)&x, sizeof(x)), 100); - TTPM_CHECK(tpm_extend(0, in, out), 200); + TTPM_CHECK(tpm_pcr_event(0, in, out), 200); TTPM_CHECK(tpm_set_global_lock(), 50); TTPM_CHECK(tpm_tsc_physical_presence(PHYS_PRESENCE), 100); printf("done\n"); diff --git a/include/tpm.h b/include/tpm.h index 2f17166662..a863ac6196 100644 --- a/include/tpm.h +++ b/include/tpm.h @@ -537,7 +537,7 @@ uint32_t tpm_nv_read_value(uint32_t index, void *data, uint32_t count); uint32_t tpm_nv_write_value(uint32_t index, const void *data, uint32_t length); /** - * Issue a TPM_Extend command. + * Issue a TPM_PCR_Event command. * * @param index index of the PCR * @param in_digest 160-bit value representing the event to be @@ -546,7 +546,7 @@ uint32_t tpm_nv_write_value(uint32_t index, const void *data, uint32_t length); * command * @return return code of the operation */ -uint32_t tpm_extend(uint32_t index, const void *in_digest, void *out_digest); +int tpm_pcr_event(u32 index, const void *in_digest, void *out_digest); /** * Issue a TPM_PCRRead command. diff --git a/lib/tpm.c b/lib/tpm.c index e5fb18308c..07e2490af2 100644 --- a/lib/tpm.c +++ b/lib/tpm.c @@ -493,7 +493,7 @@ uint32_t tpm_nv_write_value(uint32_t index, const void *data, uint32_t length) return 0; } -uint32_t tpm_extend(uint32_t index, const void *in_digest, void *out_digest) +int tpm_pcr_event(u32 index, const void *in_digest, void *out_digest) { const uint8_t command[34] = { 0x0, 0xc1, 0x0, 0x0, 0x0, 0x22, 0x0, 0x0, 0x0, 0x14, -- 2.14.1