These are top level definitions shared by both TPM 1 and 2 family chips. This includes core definitions like TPM localities, timeouts, and common crypto algorithm IDs.
Signed-off-by: Daniel P. Smith <[email protected]> Signed-off-by: Ross Philipson <[email protected]> --- drivers/char/tpm/tpm.h | 6 ---- include/linux/tpm.h | 44 ------------------------- include/linux/tpm2.h | 5 --- include/linux/tpm_common.h | 67 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 67 insertions(+), 55 deletions(-) diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h index faac3c7065bf..7d608b166bbf 100644 --- a/drivers/char/tpm/tpm.h +++ b/drivers/char/tpm/tpm.h @@ -50,12 +50,6 @@ enum tpm_addr { TPM_ADDR = 0x4E, }; -/* 128 bytes is an arbitrary cap. This could be as large as TPM_BUFSIZE - 18 - * bytes, but 128 is still a relatively large number of random bytes and - * anything much bigger causes users of struct tpm_cmd_t to start getting - * compiler warnings about stack frame size. */ -#define TPM_MAX_RNG_DATA 128 - #include "tpm1_structs.h" #include "tpm2_structs.h" diff --git a/include/linux/tpm.h b/include/linux/tpm.h index e77e3e2c1d9e..8a778bcc2dd5 100644 --- a/include/linux/tpm.h +++ b/include/linux/tpm.h @@ -29,47 +29,12 @@ #include "tpm1.h" #include "tpm2.h" -#define TPM_DIGEST_SIZE 20 /* Max TPM v1.2 PCR size */ -#define TPM_HEADER_SIZE 10 -#define TPM_BUFSIZE 4096 - -#define TPM2_PLATFORM_PCR 24 -#define TPM2_PCR_SELECT_MIN 3 -#define TPM2_MAX_DIGEST_SIZE SHA512_DIGEST_SIZE -#define TPM2_MAX_BANKS 4 - struct tpm_chip; struct trusted_key_payload; struct trusted_key_options; /* opaque structure, holds auth session parameters like the session key */ struct tpm2_auth; -/* if you add a new hash to this, increment TPM_MAX_HASHES below */ -enum tpm_algorithms { - TPM_ALG_ERROR = 0x0000, - TPM_ALG_SHA1 = 0x0004, - TPM_ALG_AES = 0x0006, - TPM_ALG_KEYEDHASH = 0x0008, - TPM_ALG_SHA256 = 0x000B, - TPM_ALG_SHA384 = 0x000C, - TPM_ALG_SHA512 = 0x000D, - TPM_ALG_NULL = 0x0010, - TPM_ALG_SM3_256 = 0x0012, - TPM_ALG_ECC = 0x0023, - TPM_ALG_CFB = 0x0043, -}; - -/* - * maximum number of hashing algorithms a TPM can have. This is - * basically a count of every hash in tpm_algorithms above - */ -#define TPM_MAX_HASHES 5 - -struct tpm_digest { - u16 alg_id; - u8 digest[TPM2_MAX_DIGEST_SIZE]; -} __packed; - struct tpm_bank_info { u16 alg_id; u16 digest_size; @@ -243,15 +208,6 @@ enum tpm_chip_flags { #define to_tpm_chip(d) container_of(d, struct tpm_chip, dev) -struct tpm_header { - __be16 tag; - __be32 length; - union { - __be32 ordinal; - __be32 return_code; - }; -} __packed; - enum tpm_buf_flags { /* TPM2B format: */ TPM_BUF_TPM2B = BIT(0), diff --git a/include/linux/tpm2.h b/include/linux/tpm2.h index f87489aea780..c2ece73a54c5 100644 --- a/include/linux/tpm2.h +++ b/include/linux/tpm2.h @@ -164,11 +164,6 @@ enum tpm2_session_attributes { TPM2_SA_AUDIT = BIT(7), }; -enum tpm2_pcr_select { - TPM2_PLATFORM_PCR = 24, - TPM2_PCR_SELECT_MIN = ((TPM2_PLATFORM_PCR + 7) / 8), -}; - enum tpm2_handle_types { TPM2_HT_HMAC_SESSION = 0x02000000, TPM2_HT_POLICY_SESSION = 0x03000000, diff --git a/include/linux/tpm_common.h b/include/linux/tpm_common.h index b8be669913dd..b5c6b2c1e517 100644 --- a/include/linux/tpm_common.h +++ b/include/linux/tpm_common.h @@ -19,4 +19,71 @@ #define TPM_MAX_ORDINAL 243 +#define TPM_DIGEST_SIZE 20 /* Max TPM v1.2 PCR size */ +#define TPM_HEADER_SIZE 10 +#define TPM_BUFSIZE 4096 + +#define TPM2_PLATFORM_PCR 24 +#define TPM2_PCR_SELECT_MIN 3 +#define TPM2_MAX_DIGEST_SIZE SHA512_DIGEST_SIZE +#define TPM2_MAX_BANKS 4 + +/* if you add a new hash to this, increment TPM_MAX_HASHES below */ +enum tpm_algorithms { + TPM_ALG_ERROR = 0x0000, + TPM_ALG_SHA1 = 0x0004, + TPM_ALG_AES = 0x0006, + TPM_ALG_KEYEDHASH = 0x0008, + TPM_ALG_SHA256 = 0x000B, + TPM_ALG_SHA384 = 0x000C, + TPM_ALG_SHA512 = 0x000D, + TPM_ALG_NULL = 0x0010, + TPM_ALG_SM3_256 = 0x0012, + TPM_ALG_ECC = 0x0023, + TPM_ALG_CFB = 0x0043, +}; + +/* + * The locality (0 - 4) for a TPM, as defined in section 3.2 of the + * Client Platform Profile Specification. + */ +enum tpm_localities { + TPM_LOCALITY_0 = 0, /* Static RTM */ + TPM_LOCALITY_1 = 1, /* Dynamic OS */ + TPM_LOCALITY_2 = 2, /* DRTM Environment */ + TPM_LOCALITY_3 = 3, /* Aux Components */ + TPM_LOCALITY_4 = 4, /* CPU DRTM Establishment */ + TPM_MAX_LOCALITY = TPM_LOCALITY_4 +}; + +/* + * 128 bytes is an arbitrary cap. This could be as large as TPM_BUFSIZE - 18 + * bytes, but 128 is still a relatively large number of random bytes and + * anything much bigger causes users of struct tpm_cmd_t to start getting + * compiler warnings about stack frame size. + */ +#define TPM_MAX_RNG_DATA 128 + +/* + * maximum number of hashing algorithms a TPM can have. This is + * basically a count of every hash in tpm_algorithms above + */ +#define TPM_MAX_HASHES 5 + +struct tpm_digest { + u16 alg_id; + u8 digest[TPM2_MAX_DIGEST_SIZE]; +} __packed; + +#define TPM_HEADER_SIZE 10 + +struct tpm_header { + __be16 tag; + __be32 length; + union { + __be32 ordinal; + __be32 return_code; + }; +} __packed; + #endif -- 2.43.7
