aboutsummaryrefslogtreecommitdiff
path: root/include/tpm-v2.h
diff options
context:
space:
mode:
authorIlias Apalodimas <ilias.apalodimas@linaro.org>2020-11-30 11:47:39 +0200
committerHeinrich Schuchardt <xypron.glpk@gmx.de>2020-12-03 21:22:40 +0100
commit8e0b0871b82db0511440208b101ecf488858e915 (patch)
tree30973c008a5b16b954bf51180299a62f77eb138e /include/tpm-v2.h
parente926136bb29cb9dda00f1b8960db963b6e97124b (diff)
downloadu-boot-8e0b0871b82db0511440208b101ecf488858e915.zip
u-boot-8e0b0871b82db0511440208b101ecf488858e915.tar.gz
u-boot-8e0b0871b82db0511440208b101ecf488858e915.tar.bz2
tpm: Add tpm2 headers for TCG2 eventlog support
A following patch introduces support for the EFI_TCG2_PROTOCOL eventlog management. Introduce the necessary tpm related headers Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Diffstat (limited to 'include/tpm-v2.h')
-rw-r--r--include/tpm-v2.h82
1 files changed, 82 insertions, 0 deletions
diff --git a/include/tpm-v2.h b/include/tpm-v2.h
index f1826ff..fab6b86 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;
@@ -87,6 +102,73 @@ struct tpms_capability_data {
} __packed;
/**
+ * SHA1 Event Log Entry Format
+ *
+ * @pcr_index: PCRIndex event extended to
+ * @event_type: Type of event (see EFI specs)
+ * @digest: Value extended into PCR index
+ * @event_size: Size of event
+ * @event: Event data
+ */
+struct tcg_pcr_event {
+ u32 pcr_index;
+ u32 event_type;
+ u8 digest[TPM2_SHA1_DIGEST_SIZE];
+ 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
+ *
+ * @hash_alg: Hash algorithm defined in enum tpm2_algorithms
+ * @digest: Digest value for a given algorithm
+ */
+struct tpmt_ha {
+ u16 hash_alg;
+ union tmpu_ha digest;
+} __packed;
+
+/**
+ * Definition of TPML_DIGEST_VALUES Structure
+ *
+ * @count: Number of algorithms supported by hardware
+ * @digests: struct for algorithm id and hash value
+ */
+struct tpml_digest_values {
+ u32 count;
+ struct tpmt_ha digests[TPM2_NUM_PCR_BANKS];
+} __packed;
+
+/**
+ * Crypto Agile Log Entry Format
+ *
+ * @pcr_index: PCRIndex event extended to
+ * @event_type: Type of event
+ * @digests: List of digestsextended to PCR index
+ * @event_size: Size of the event data
+ * @event: Event data
+ */
+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.
*
* @TPM2_ST_NO_SESSIONS: the command does not need an authentication.