u-boot.lists.denx.de archive mirror
 help / color / mirror / Atom feed
From: Ilias Apalodimas <ilias.apalodimas@linaro.org>
To: u-boot@lists.denx.de
Subject: [PATCH 1/3] tpm: Add tpm2 headers for TCG2 eventlog support
Date: Fri, 27 Nov 2020 18:29:29 +0200	[thread overview]
Message-ID: <20201127162932.1965323-2-ilias.apalodimas@linaro.org> (raw)
In-Reply-To: <20201127162932.1965323-1-ilias.apalodimas@linaro.org>

A following patch introduces support for the EFI_TCG2_PROTOCOL
evenlog management.
Introduce the necessary tpm related headers

Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
---
 include/tpm-v2.h | 59 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 59 insertions(+)

diff --git a/include/tpm-v2.h b/include/tpm-v2.h
index d8c9feda28dc..9637f9be998e 100644
--- a/include/tpm-v2.h
+++ b/include/tpm-v2.h
@@ -18,6 +18,12 @@
 
 #define TPM2_DIGEST_LEN		32
 
+#define TPM2_SHA1_DIGEST_SIZE 20
+#define TPM2_SHA256_DIGEST_SIZE	32
+#define TPM2_SHA384_DIGEST_SIZE	48
+#define TPM2_SHA512_DIGEST_SIZE	64
+#define TPM2_SM3_256_DIGEST_SIZE 32
+
 #define TPM2_MAX_PCRS 32
 #define TPM2_PCR_SELECT_MAX ((TPM2_MAX_PCRS + 7) / 8)
 #define TPM2_MAX_CAP_BUFFER 1024
@@ -45,6 +51,15 @@
 #define TPM2_PT_MAX_COMMAND_SIZE	(u32)(TPM2_PT_FIXED + 30)
 #define TPM2_PT_MAX_RESPONSE_SIZE	(u32)(TPM2_PT_FIXED + 31)
 
+/* event types */
+#define EV_POST_CODE		((u32)0x00000001)
+#define EV_NO_ACTION		((u32)0x00000003)
+#define EV_SEPARATOR		((u32)0x00000004)
+#define EV_S_CRTM_CONTENTS	((u32)0x00000007)
+#define EV_S_CRTM_VERSION	((u32)0x00000008)
+#define EV_CPU_MICROCODE	((u32)0x00000009)
+#define EV_TABLE_OF_DEVICES	((u32)0x0000000B)
+
 /* TPMS_TAGGED_PROPERTY Structure */
 struct tpms_tagged_property {
 	u32 property;
@@ -86,6 +101,50 @@ struct tpms_capability_data {
 	union tpmu_capabilities data;
 } __packed;
 
+/* defined as TPM_SHA1_160_HASH_LEN in spec */
+struct tpm_digest {
+	u8 digest[TPM2_SHA1_DIGEST_SIZE];
+} __packed;
+
+/* SHA1 Event Log Entry Format */
+struct tcg_pcr_event {
+	u32 pcr_index;
+	u32 event_type;
+	struct tpm_digest digest;
+	u32 event_size;
+	u8 event[];
+} __packed;
+
+/* Definition of TPMU_HA Union */
+union tmpu_ha {
+	u8 sha1[TPM2_SHA1_DIGEST_SIZE];
+	u8 sha256[TPM2_SHA256_DIGEST_SIZE];
+	u8 sm3_256[TPM2_SM3_256_DIGEST_SIZE];
+	u8 sha384[TPM2_SHA384_DIGEST_SIZE];
+	u8 sha512[TPM2_SHA512_DIGEST_SIZE];
+} __packed;
+
+/* Definition of TPMT_HA Structure */
+struct tpmt_ha {
+	u16 hash_alg;
+	union tmpu_ha digest;
+} __packed;
+
+/* Definition of TPML_DIGEST_VALUES Structure */
+struct tpml_digest_values {
+	u32 count;
+	struct tpmt_ha digests[TPM2_NUM_PCR_BANKS];
+} __packed;
+
+/* Crypto Agile Log Entry Format */
+struct tcg_pcr_event2 {
+	u32 pcr_index;
+	u32 event_type;
+	struct tpml_digest_values digests;
+	u32 event_size;
+	u8 event[];
+} __packed;
+
 /**
  * TPM2 Structure Tags for command/response buffers.
  *
-- 
2.29.2

  reply	other threads:[~2020-11-27 16:29 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-27 16:29 [PATCH 0/3] extend EFI_TCG2_PROTOCOL support Ilias Apalodimas
2020-11-27 16:29 ` Ilias Apalodimas [this message]
2020-11-29  5:28   ` [PATCH 1/3] tpm: Add tpm2 headers for TCG2 eventlog support Heinrich Schuchardt
2020-11-29 13:22     ` Ilias Apalodimas
2020-11-27 16:29 ` [PATCH 2/3] efi_loader: Introduce eventlog support for TCG2_PROTOCOL Ilias Apalodimas
2020-11-29  6:02   ` Heinrich Schuchardt
2020-11-29 13:27     ` Ilias Apalodimas
2020-11-29 13:49       ` Heinrich Schuchardt
2020-11-29 14:02         ` Ilias Apalodimas
2020-11-27 16:29 ` [PATCH 3/3] cmd: efidebug: Add support for TCG2 final events table Ilias Apalodimas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201127162932.1965323-2-ilias.apalodimas@linaro.org \
    --to=ilias.apalodimas@linaro.org \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).