All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3 v2] tpm: Change response length of tpm2_get_capability()
@ 2020-11-05 21:58 Ilias Apalodimas
  2020-11-05 21:58 ` [PATCH 2/3 v2] tpm: Add some headers from the spec Ilias Apalodimas
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Ilias Apalodimas @ 2020-11-05 21:58 UTC (permalink / raw)
  To: u-boot

For implementing the EFI_TCG2_PROTOCOL we need the count field returned by
the TPM when reading capabilities via tpm2_get_capability().

Adjust the implementation of the 'tpm2 get_capability' command accordingly.

Suggested-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
---
Changes since v1:
- Unconditionally get the extra 4 bytes on the response and account for them
  in do_tpm_get_capability()
 cmd/tpm-v2.c | 4 ++--
 lib/tpm-v2.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/cmd/tpm-v2.c b/cmd/tpm-v2.c
index e6742656f578..5fa4788a72de 100644
--- a/cmd/tpm-v2.c
+++ b/cmd/tpm-v2.c
@@ -191,10 +191,10 @@ static int do_tpm_get_capability(struct cmd_tbl *cmdtp, int flag, int argc,
 	for (i = 0; i < count; i++) {
 		printf("Property 0x");
 		for (j = 0; j < 4; j++)
-			printf("%02x", data[(i * 8) + j]);
+			printf("%02x", data[(i * 8) + j + sizeof(u32)]);
 		printf(": 0x");
 		for (j = 4; j < 8; j++)
-			printf("%02x", data[(i * 8) + j]);
+			printf("%02x", data[(i * 8) + j + sizeof(u32)]);
 		printf("\n");
 	}
 
diff --git a/lib/tpm-v2.c b/lib/tpm-v2.c
index a4c352e3ef75..91759068cf03 100644
--- a/lib/tpm-v2.c
+++ b/lib/tpm-v2.c
@@ -184,10 +184,10 @@ u32 tpm2_get_capability(struct udevice *dev, u32 capability, u32 property,
 	/*
 	 * In the response buffer, the properties are located after the:
 	 * tag (u16), response size (u32), response code (u32),
-	 * YES/NO flag (u8), TPM_CAP (u32) and TPMU_CAPABILITIES (u32).
+	 * YES/NO flag (u8), TPM_CAP (u32).
 	 */
 	properties_off = sizeof(u16) + sizeof(u32) + sizeof(u32) +
-			 sizeof(u8) + sizeof(u32) + sizeof(u32);
+			 sizeof(u8) + sizeof(u32);
 	memcpy(buf, &response[properties_off], response_len - properties_off);
 
 	return 0;
-- 
2.29.2

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2020-11-11 14:32 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-11-05 21:58 [PATCH 1/3 v2] tpm: Change response length of tpm2_get_capability() Ilias Apalodimas
2020-11-05 21:58 ` [PATCH 2/3 v2] tpm: Add some headers from the spec Ilias Apalodimas
2020-11-07 20:33   ` Heinrich Schuchardt
2020-11-08 13:58     ` Ilias Apalodimas
2020-11-09 20:31       ` Ilias Apalodimas
2020-11-05 21:58 ` [PATCH 3/3 v2] efi: Add basic EFI_TCG2_PROTOCOL support Ilias Apalodimas
2020-11-07 21:08   ` Heinrich Schuchardt
2020-11-08 13:55     ` Ilias Apalodimas
2020-11-11 14:32 ` [PATCH 1/3 v2] tpm: Change response length of tpm2_get_capability() Simon Glass

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.