All of lore.kernel.org
 help / color / mirror / Atom feed
From: Roberto Sassu <roberto.sassu@huawei.com>
To: linux-security-module@vger.kernel.org
Subject: [PATCH v3 3/6] tpm: introduce tpm_pcr_bank_info structure with digest_size from TPM
Date: Wed, 21 Jun 2017 14:29:38 +0000	[thread overview]
Message-ID: <20170621142941.32674-4-roberto.sassu@huawei.com> (raw)
In-Reply-To: <20170621142941.32674-1-roberto.sassu@huawei.com>

This patch introduces the new structure tpm_pcr_bank_info to store
information regarding PCR banks. The next patch will replace the array of
TPM algorithms IDs with an array of the new structure.

tpm_pcr_bank_info contains the TPM algorithm ID, the digest size and,
optionally, the corresponding crypto ID, if a mapping exists. These
information will be used by IMA to calculate the digest of an event
and to provide measurements logs to userspace applications. The new
structure has been defined in include/linux/tpm.h, as it will be passed
to functions outside the TPM driver.

The purpose of this patch is to fix a serious issue in tpm2_pcr_extend():
if the mapping between a TPM algorithm and a crypto algorithm is not
defined, the PCR bank with the unknown algorithm is not extended.
This gives the opportunity to an attacker to reply to remote attestation
requests with a list of fake measurements. Instead, the digest size
is retrieved from the output buffer of a PCR read, without relying
on the crypto subsystem.

Signed-off-by: Roberto Sassu <roberto.sassu@huawei.com>
---
 drivers/char/tpm/tpm.h      | 11 -----------
 drivers/char/tpm/tpm2-cmd.c | 30 ++++++++++++++++++++++++++++++
 include/linux/tpm.h         | 19 +++++++++++++++++++
 3 files changed, 49 insertions(+), 11 deletions(-)

diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h
index 1df0521..62c600d 100644
--- a/drivers/char/tpm/tpm.h
+++ b/drivers/char/tpm/tpm.h
@@ -98,17 +98,6 @@ enum tpm2_return_codes {
 	TPM2_RC_REFERENCE_H0	= 0x0910,
 };
 
-enum tpm2_algorithms {
-	TPM2_ALG_ERROR		= 0x0000,
-	TPM2_ALG_SHA1		= 0x0004,
-	TPM2_ALG_KEYEDHASH	= 0x0008,
-	TPM2_ALG_SHA256		= 0x000B,
-	TPM2_ALG_SHA384		= 0x000C,
-	TPM2_ALG_SHA512		= 0x000D,
-	TPM2_ALG_NULL		= 0x0010,
-	TPM2_ALG_SM3_256	= 0x0012,
-};
-
 enum tpm2_command_codes {
 	TPM2_CC_FIRST		= 0x011F,
 	TPM2_CC_SELF_TEST	= 0x0143,
diff --git a/drivers/char/tpm/tpm2-cmd.c b/drivers/char/tpm/tpm2-cmd.c
index 6a9fe0d..74a68ea 100644
--- a/drivers/char/tpm/tpm2-cmd.c
+++ b/drivers/char/tpm/tpm2-cmd.c
@@ -992,6 +992,36 @@ int tpm2_probe(struct tpm_chip *chip)
 }
 EXPORT_SYMBOL_GPL(tpm2_probe);
 
+static int tpm2_init_pcr_bank_info(struct tpm_chip *chip, u16 alg_id,
+				   struct tpm_pcr_bank_info *active_bank)
+{
+	struct tpm_buf buf;
+	struct tpm2_pcr_read_out *pcrread_out;
+	int rc = 0;
+	int i;
+
+	active_bank->alg_id = alg_id;
+
+	rc = tpm2_pcr_read_tpm_buf(chip, 0, alg_id, &buf, NULL);
+	if (rc)
+		goto out;
+
+	pcrread_out = (struct tpm2_pcr_read_out *)&buf.data[TPM_HEADER_SIZE];
+
+	active_bank->digest_size = be16_to_cpu(pcrread_out->digest_size);
+	active_bank->crypto_id = HASH_ALGO__LAST;
+
+	for (i = 0; i < ARRAY_SIZE(tpm2_hash_map); i++) {
+		if (active_bank->alg_id != tpm2_hash_map[i].tpm_id)
+			continue;
+
+		active_bank->crypto_id = tpm2_hash_map[i].crypto_id;
+	}
+out:
+	tpm_buf_destroy(&buf);
+	return rc;
+}
+
 struct tpm2_pcr_selection {
 	__be16  hash_alg;
 	u8  size_of_select;
diff --git a/include/linux/tpm.h b/include/linux/tpm.h
index 5a090f5..ff06738 100644
--- a/include/linux/tpm.h
+++ b/include/linux/tpm.h
@@ -22,6 +22,8 @@
 #ifndef __LINUX_TPM_H__
 #define __LINUX_TPM_H__
 
+#include <crypto/hash_info.h>
+
 #define TPM_DIGEST_SIZE 20	/* Max TPM v1.2 PCR size */
 
 /*
@@ -37,6 +39,17 @@ enum TPM_OPS_FLAGS {
 	TPM_OPS_AUTO_STARTUP = BIT(0),
 };
 
+enum tpm2_algorithms {
+	TPM2_ALG_ERROR		= 0x0000,
+	TPM2_ALG_SHA1		= 0x0004,
+	TPM2_ALG_KEYEDHASH	= 0x0008,
+	TPM2_ALG_SHA256		= 0x000B,
+	TPM2_ALG_SHA384		= 0x000C,
+	TPM2_ALG_SHA512		= 0x000D,
+	TPM2_ALG_NULL		= 0x0010,
+	TPM2_ALG_SM3_256	= 0x0012,
+};
+
 struct tpm_class_ops {
 	unsigned int flags;
 	const u8 req_complete_mask;
@@ -52,6 +65,12 @@ struct tpm_class_ops {
 	void (*relinquish_locality)(struct tpm_chip *chip, int loc);
 };
 
+struct tpm_pcr_bank_info {
+	enum tpm2_algorithms alg_id;
+	enum hash_algo crypto_id;
+	u32 digest_size;
+};
+
 #if defined(CONFIG_TCG_TPM) || defined(CONFIG_TCG_TPM_MODULE)
 
 extern int tpm_is_tpm2(u32 chip_num);
-- 
2.9.3


WARNING: multiple messages have this Message-ID (diff)
From: Roberto Sassu <roberto.sassu@huawei.com>
To: <tpmdd-devel@lists.sourceforge.net>
Cc: <linux-ima-devel@lists.sourceforge.net>,
	<linux-security-module@vger.kernel.org>,
	<keyrings@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	Roberto Sassu <roberto.sassu@huawei.com>
Subject: [PATCH v3 3/6] tpm: introduce tpm_pcr_bank_info structure with digest_size from TPM
Date: Wed, 21 Jun 2017 16:29:38 +0200	[thread overview]
Message-ID: <20170621142941.32674-4-roberto.sassu@huawei.com> (raw)
In-Reply-To: <20170621142941.32674-1-roberto.sassu@huawei.com>

This patch introduces the new structure tpm_pcr_bank_info to store
information regarding PCR banks. The next patch will replace the array of
TPM algorithms IDs with an array of the new structure.

tpm_pcr_bank_info contains the TPM algorithm ID, the digest size and,
optionally, the corresponding crypto ID, if a mapping exists. These
information will be used by IMA to calculate the digest of an event
and to provide measurements logs to userspace applications. The new
structure has been defined in include/linux/tpm.h, as it will be passed
to functions outside the TPM driver.

The purpose of this patch is to fix a serious issue in tpm2_pcr_extend():
if the mapping between a TPM algorithm and a crypto algorithm is not
defined, the PCR bank with the unknown algorithm is not extended.
This gives the opportunity to an attacker to reply to remote attestation
requests with a list of fake measurements. Instead, the digest size
is retrieved from the output buffer of a PCR read, without relying
on the crypto subsystem.

Signed-off-by: Roberto Sassu <roberto.sassu@huawei.com>
---
 drivers/char/tpm/tpm.h      | 11 -----------
 drivers/char/tpm/tpm2-cmd.c | 30 ++++++++++++++++++++++++++++++
 include/linux/tpm.h         | 19 +++++++++++++++++++
 3 files changed, 49 insertions(+), 11 deletions(-)

diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h
index 1df0521..62c600d 100644
--- a/drivers/char/tpm/tpm.h
+++ b/drivers/char/tpm/tpm.h
@@ -98,17 +98,6 @@ enum tpm2_return_codes {
 	TPM2_RC_REFERENCE_H0	= 0x0910,
 };
 
-enum tpm2_algorithms {
-	TPM2_ALG_ERROR		= 0x0000,
-	TPM2_ALG_SHA1		= 0x0004,
-	TPM2_ALG_KEYEDHASH	= 0x0008,
-	TPM2_ALG_SHA256		= 0x000B,
-	TPM2_ALG_SHA384		= 0x000C,
-	TPM2_ALG_SHA512		= 0x000D,
-	TPM2_ALG_NULL		= 0x0010,
-	TPM2_ALG_SM3_256	= 0x0012,
-};
-
 enum tpm2_command_codes {
 	TPM2_CC_FIRST		= 0x011F,
 	TPM2_CC_SELF_TEST	= 0x0143,
diff --git a/drivers/char/tpm/tpm2-cmd.c b/drivers/char/tpm/tpm2-cmd.c
index 6a9fe0d..74a68ea 100644
--- a/drivers/char/tpm/tpm2-cmd.c
+++ b/drivers/char/tpm/tpm2-cmd.c
@@ -992,6 +992,36 @@ int tpm2_probe(struct tpm_chip *chip)
 }
 EXPORT_SYMBOL_GPL(tpm2_probe);
 
+static int tpm2_init_pcr_bank_info(struct tpm_chip *chip, u16 alg_id,
+				   struct tpm_pcr_bank_info *active_bank)
+{
+	struct tpm_buf buf;
+	struct tpm2_pcr_read_out *pcrread_out;
+	int rc = 0;
+	int i;
+
+	active_bank->alg_id = alg_id;
+
+	rc = tpm2_pcr_read_tpm_buf(chip, 0, alg_id, &buf, NULL);
+	if (rc)
+		goto out;
+
+	pcrread_out = (struct tpm2_pcr_read_out *)&buf.data[TPM_HEADER_SIZE];
+
+	active_bank->digest_size = be16_to_cpu(pcrread_out->digest_size);
+	active_bank->crypto_id = HASH_ALGO__LAST;
+
+	for (i = 0; i < ARRAY_SIZE(tpm2_hash_map); i++) {
+		if (active_bank->alg_id != tpm2_hash_map[i].tpm_id)
+			continue;
+
+		active_bank->crypto_id = tpm2_hash_map[i].crypto_id;
+	}
+out:
+	tpm_buf_destroy(&buf);
+	return rc;
+}
+
 struct tpm2_pcr_selection {
 	__be16  hash_alg;
 	u8  size_of_select;
diff --git a/include/linux/tpm.h b/include/linux/tpm.h
index 5a090f5..ff06738 100644
--- a/include/linux/tpm.h
+++ b/include/linux/tpm.h
@@ -22,6 +22,8 @@
 #ifndef __LINUX_TPM_H__
 #define __LINUX_TPM_H__
 
+#include <crypto/hash_info.h>
+
 #define TPM_DIGEST_SIZE 20	/* Max TPM v1.2 PCR size */
 
 /*
@@ -37,6 +39,17 @@ enum TPM_OPS_FLAGS {
 	TPM_OPS_AUTO_STARTUP = BIT(0),
 };
 
+enum tpm2_algorithms {
+	TPM2_ALG_ERROR		= 0x0000,
+	TPM2_ALG_SHA1		= 0x0004,
+	TPM2_ALG_KEYEDHASH	= 0x0008,
+	TPM2_ALG_SHA256		= 0x000B,
+	TPM2_ALG_SHA384		= 0x000C,
+	TPM2_ALG_SHA512		= 0x000D,
+	TPM2_ALG_NULL		= 0x0010,
+	TPM2_ALG_SM3_256	= 0x0012,
+};
+
 struct tpm_class_ops {
 	unsigned int flags;
 	const u8 req_complete_mask;
@@ -52,6 +65,12 @@ struct tpm_class_ops {
 	void (*relinquish_locality)(struct tpm_chip *chip, int loc);
 };
 
+struct tpm_pcr_bank_info {
+	enum tpm2_algorithms alg_id;
+	enum hash_algo crypto_id;
+	u32 digest_size;
+};
+
 #if defined(CONFIG_TCG_TPM) || defined(CONFIG_TCG_TPM_MODULE)
 
 extern int tpm_is_tpm2(u32 chip_num);
-- 
2.9.3

WARNING: multiple messages have this Message-ID (diff)
From: roberto.sassu@huawei.com (Roberto Sassu)
To: linux-security-module@vger.kernel.org
Subject: [PATCH v3 3/6] tpm: introduce tpm_pcr_bank_info structure with digest_size from TPM
Date: Wed, 21 Jun 2017 16:29:38 +0200	[thread overview]
Message-ID: <20170621142941.32674-4-roberto.sassu@huawei.com> (raw)
In-Reply-To: <20170621142941.32674-1-roberto.sassu@huawei.com>

This patch introduces the new structure tpm_pcr_bank_info to store
information regarding PCR banks. The next patch will replace the array of
TPM algorithms IDs with an array of the new structure.

tpm_pcr_bank_info contains the TPM algorithm ID, the digest size and,
optionally, the corresponding crypto ID, if a mapping exists. These
information will be used by IMA to calculate the digest of an event
and to provide measurements logs to userspace applications. The new
structure has been defined in include/linux/tpm.h, as it will be passed
to functions outside the TPM driver.

The purpose of this patch is to fix a serious issue in tpm2_pcr_extend():
if the mapping between a TPM algorithm and a crypto algorithm is not
defined, the PCR bank with the unknown algorithm is not extended.
This gives the opportunity to an attacker to reply to remote attestation
requests with a list of fake measurements. Instead, the digest size
is retrieved from the output buffer of a PCR read, without relying
on the crypto subsystem.

Signed-off-by: Roberto Sassu <roberto.sassu@huawei.com>
---
 drivers/char/tpm/tpm.h      | 11 -----------
 drivers/char/tpm/tpm2-cmd.c | 30 ++++++++++++++++++++++++++++++
 include/linux/tpm.h         | 19 +++++++++++++++++++
 3 files changed, 49 insertions(+), 11 deletions(-)

diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h
index 1df0521..62c600d 100644
--- a/drivers/char/tpm/tpm.h
+++ b/drivers/char/tpm/tpm.h
@@ -98,17 +98,6 @@ enum tpm2_return_codes {
 	TPM2_RC_REFERENCE_H0	= 0x0910,
 };
 
-enum tpm2_algorithms {
-	TPM2_ALG_ERROR		= 0x0000,
-	TPM2_ALG_SHA1		= 0x0004,
-	TPM2_ALG_KEYEDHASH	= 0x0008,
-	TPM2_ALG_SHA256		= 0x000B,
-	TPM2_ALG_SHA384		= 0x000C,
-	TPM2_ALG_SHA512		= 0x000D,
-	TPM2_ALG_NULL		= 0x0010,
-	TPM2_ALG_SM3_256	= 0x0012,
-};
-
 enum tpm2_command_codes {
 	TPM2_CC_FIRST		= 0x011F,
 	TPM2_CC_SELF_TEST	= 0x0143,
diff --git a/drivers/char/tpm/tpm2-cmd.c b/drivers/char/tpm/tpm2-cmd.c
index 6a9fe0d..74a68ea 100644
--- a/drivers/char/tpm/tpm2-cmd.c
+++ b/drivers/char/tpm/tpm2-cmd.c
@@ -992,6 +992,36 @@ int tpm2_probe(struct tpm_chip *chip)
 }
 EXPORT_SYMBOL_GPL(tpm2_probe);
 
+static int tpm2_init_pcr_bank_info(struct tpm_chip *chip, u16 alg_id,
+				   struct tpm_pcr_bank_info *active_bank)
+{
+	struct tpm_buf buf;
+	struct tpm2_pcr_read_out *pcrread_out;
+	int rc = 0;
+	int i;
+
+	active_bank->alg_id = alg_id;
+
+	rc = tpm2_pcr_read_tpm_buf(chip, 0, alg_id, &buf, NULL);
+	if (rc)
+		goto out;
+
+	pcrread_out = (struct tpm2_pcr_read_out *)&buf.data[TPM_HEADER_SIZE];
+
+	active_bank->digest_size = be16_to_cpu(pcrread_out->digest_size);
+	active_bank->crypto_id = HASH_ALGO__LAST;
+
+	for (i = 0; i < ARRAY_SIZE(tpm2_hash_map); i++) {
+		if (active_bank->alg_id != tpm2_hash_map[i].tpm_id)
+			continue;
+
+		active_bank->crypto_id = tpm2_hash_map[i].crypto_id;
+	}
+out:
+	tpm_buf_destroy(&buf);
+	return rc;
+}
+
 struct tpm2_pcr_selection {
 	__be16  hash_alg;
 	u8  size_of_select;
diff --git a/include/linux/tpm.h b/include/linux/tpm.h
index 5a090f5..ff06738 100644
--- a/include/linux/tpm.h
+++ b/include/linux/tpm.h
@@ -22,6 +22,8 @@
 #ifndef __LINUX_TPM_H__
 #define __LINUX_TPM_H__
 
+#include <crypto/hash_info.h>
+
 #define TPM_DIGEST_SIZE 20	/* Max TPM v1.2 PCR size */
 
 /*
@@ -37,6 +39,17 @@ enum TPM_OPS_FLAGS {
 	TPM_OPS_AUTO_STARTUP = BIT(0),
 };
 
+enum tpm2_algorithms {
+	TPM2_ALG_ERROR		= 0x0000,
+	TPM2_ALG_SHA1		= 0x0004,
+	TPM2_ALG_KEYEDHASH	= 0x0008,
+	TPM2_ALG_SHA256		= 0x000B,
+	TPM2_ALG_SHA384		= 0x000C,
+	TPM2_ALG_SHA512		= 0x000D,
+	TPM2_ALG_NULL		= 0x0010,
+	TPM2_ALG_SM3_256	= 0x0012,
+};
+
 struct tpm_class_ops {
 	unsigned int flags;
 	const u8 req_complete_mask;
@@ -52,6 +65,12 @@ struct tpm_class_ops {
 	void (*relinquish_locality)(struct tpm_chip *chip, int loc);
 };
 
+struct tpm_pcr_bank_info {
+	enum tpm2_algorithms alg_id;
+	enum hash_algo crypto_id;
+	u32 digest_size;
+};
+
 #if defined(CONFIG_TCG_TPM) || defined(CONFIG_TCG_TPM_MODULE)
 
 extern int tpm_is_tpm2(u32 chip_num);
-- 
2.9.3

--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

WARNING: multiple messages have this Message-ID (diff)
From: Roberto Sassu <roberto.sassu-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
To: tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
Cc: linux-ima-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org,
	linux-security-module-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	keyrings-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: [PATCH v3 3/6] tpm: introduce tpm_pcr_bank_info structure with digest_size from TPM
Date: Wed, 21 Jun 2017 16:29:38 +0200	[thread overview]
Message-ID: <20170621142941.32674-4-roberto.sassu@huawei.com> (raw)
In-Reply-To: <20170621142941.32674-1-roberto.sassu-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>

This patch introduces the new structure tpm_pcr_bank_info to store
information regarding PCR banks. The next patch will replace the array of
TPM algorithms IDs with an array of the new structure.

tpm_pcr_bank_info contains the TPM algorithm ID, the digest size and,
optionally, the corresponding crypto ID, if a mapping exists. These
information will be used by IMA to calculate the digest of an event
and to provide measurements logs to userspace applications. The new
structure has been defined in include/linux/tpm.h, as it will be passed
to functions outside the TPM driver.

The purpose of this patch is to fix a serious issue in tpm2_pcr_extend():
if the mapping between a TPM algorithm and a crypto algorithm is not
defined, the PCR bank with the unknown algorithm is not extended.
This gives the opportunity to an attacker to reply to remote attestation
requests with a list of fake measurements. Instead, the digest size
is retrieved from the output buffer of a PCR read, without relying
on the crypto subsystem.

Signed-off-by: Roberto Sassu <roberto.sassu-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
---
 drivers/char/tpm/tpm.h      | 11 -----------
 drivers/char/tpm/tpm2-cmd.c | 30 ++++++++++++++++++++++++++++++
 include/linux/tpm.h         | 19 +++++++++++++++++++
 3 files changed, 49 insertions(+), 11 deletions(-)

diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h
index 1df0521..62c600d 100644
--- a/drivers/char/tpm/tpm.h
+++ b/drivers/char/tpm/tpm.h
@@ -98,17 +98,6 @@ enum tpm2_return_codes {
 	TPM2_RC_REFERENCE_H0	= 0x0910,
 };
 
-enum tpm2_algorithms {
-	TPM2_ALG_ERROR		= 0x0000,
-	TPM2_ALG_SHA1		= 0x0004,
-	TPM2_ALG_KEYEDHASH	= 0x0008,
-	TPM2_ALG_SHA256		= 0x000B,
-	TPM2_ALG_SHA384		= 0x000C,
-	TPM2_ALG_SHA512		= 0x000D,
-	TPM2_ALG_NULL		= 0x0010,
-	TPM2_ALG_SM3_256	= 0x0012,
-};
-
 enum tpm2_command_codes {
 	TPM2_CC_FIRST		= 0x011F,
 	TPM2_CC_SELF_TEST	= 0x0143,
diff --git a/drivers/char/tpm/tpm2-cmd.c b/drivers/char/tpm/tpm2-cmd.c
index 6a9fe0d..74a68ea 100644
--- a/drivers/char/tpm/tpm2-cmd.c
+++ b/drivers/char/tpm/tpm2-cmd.c
@@ -992,6 +992,36 @@ int tpm2_probe(struct tpm_chip *chip)
 }
 EXPORT_SYMBOL_GPL(tpm2_probe);
 
+static int tpm2_init_pcr_bank_info(struct tpm_chip *chip, u16 alg_id,
+				   struct tpm_pcr_bank_info *active_bank)
+{
+	struct tpm_buf buf;
+	struct tpm2_pcr_read_out *pcrread_out;
+	int rc = 0;
+	int i;
+
+	active_bank->alg_id = alg_id;
+
+	rc = tpm2_pcr_read_tpm_buf(chip, 0, alg_id, &buf, NULL);
+	if (rc)
+		goto out;
+
+	pcrread_out = (struct tpm2_pcr_read_out *)&buf.data[TPM_HEADER_SIZE];
+
+	active_bank->digest_size = be16_to_cpu(pcrread_out->digest_size);
+	active_bank->crypto_id = HASH_ALGO__LAST;
+
+	for (i = 0; i < ARRAY_SIZE(tpm2_hash_map); i++) {
+		if (active_bank->alg_id != tpm2_hash_map[i].tpm_id)
+			continue;
+
+		active_bank->crypto_id = tpm2_hash_map[i].crypto_id;
+	}
+out:
+	tpm_buf_destroy(&buf);
+	return rc;
+}
+
 struct tpm2_pcr_selection {
 	__be16  hash_alg;
 	u8  size_of_select;
diff --git a/include/linux/tpm.h b/include/linux/tpm.h
index 5a090f5..ff06738 100644
--- a/include/linux/tpm.h
+++ b/include/linux/tpm.h
@@ -22,6 +22,8 @@
 #ifndef __LINUX_TPM_H__
 #define __LINUX_TPM_H__
 
+#include <crypto/hash_info.h>
+
 #define TPM_DIGEST_SIZE 20	/* Max TPM v1.2 PCR size */
 
 /*
@@ -37,6 +39,17 @@ enum TPM_OPS_FLAGS {
 	TPM_OPS_AUTO_STARTUP = BIT(0),
 };
 
+enum tpm2_algorithms {
+	TPM2_ALG_ERROR		= 0x0000,
+	TPM2_ALG_SHA1		= 0x0004,
+	TPM2_ALG_KEYEDHASH	= 0x0008,
+	TPM2_ALG_SHA256		= 0x000B,
+	TPM2_ALG_SHA384		= 0x000C,
+	TPM2_ALG_SHA512		= 0x000D,
+	TPM2_ALG_NULL		= 0x0010,
+	TPM2_ALG_SM3_256	= 0x0012,
+};
+
 struct tpm_class_ops {
 	unsigned int flags;
 	const u8 req_complete_mask;
@@ -52,6 +65,12 @@ struct tpm_class_ops {
 	void (*relinquish_locality)(struct tpm_chip *chip, int loc);
 };
 
+struct tpm_pcr_bank_info {
+	enum tpm2_algorithms alg_id;
+	enum hash_algo crypto_id;
+	u32 digest_size;
+};
+
 #if defined(CONFIG_TCG_TPM) || defined(CONFIG_TCG_TPM_MODULE)
 
 extern int tpm_is_tpm2(u32 chip_num);
-- 
2.9.3


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

  parent reply	other threads:[~2017-06-21 14:29 UTC|newest]

Thread overview: 104+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-21 14:29 [PATCH v3 0/6] Updated API for TPM 2.0 PCR extend Roberto Sassu
2017-06-21 14:29 ` Roberto Sassu
2017-06-21 14:29 ` Roberto Sassu
2017-06-21 14:29 ` Roberto Sassu
2017-06-21 14:29 ` [PATCH v3 1/6] tpm: use tpm_buf functions to perform a PCR read Roberto Sassu
2017-06-21 14:29   ` Roberto Sassu
2017-06-21 14:29   ` Roberto Sassu
2017-06-21 14:29   ` Roberto Sassu
2017-06-22 10:14   ` [tpmdd-devel] " Jarkko Sakkinen
2017-06-22 10:14     ` Jarkko Sakkinen
2017-06-22 10:14     ` Jarkko Sakkinen
2017-06-22 11:54     ` Roberto Sassu
2017-06-22 11:54       ` Roberto Sassu
2017-06-22 11:54       ` [tpmdd-devel] " Roberto Sassu
2017-06-22 11:54       ` Roberto Sassu
2017-06-23 10:56       ` Jarkko Sakkinen
2017-06-23 10:56         ` Jarkko Sakkinen
2017-06-23 10:56         ` Jarkko Sakkinen
2017-06-21 14:29 ` [PATCH v3 2/6] tpm: use tpm2_pcr_read_tpm_buf() in tpm2_do_selftest() Roberto Sassu
2017-06-21 14:29   ` Roberto Sassu
2017-06-21 14:29   ` Roberto Sassu
2017-06-21 14:29   ` Roberto Sassu
2017-06-23  9:55   ` [tpmdd-devel] " Jarkko Sakkinen
2017-06-23  9:55     ` Jarkko Sakkinen
2017-06-23  9:55     ` Jarkko Sakkinen
2017-06-23 10:22     ` Roberto Sassu
2017-06-23 10:22       ` Roberto Sassu
2017-06-23 10:22       ` Roberto Sassu
2017-06-23 10:22       ` Roberto Sassu
2017-06-21 14:29 ` Roberto Sassu [this message]
2017-06-21 14:29   ` [PATCH v3 3/6] tpm: introduce tpm_pcr_bank_info structure with digest_size from TPM Roberto Sassu
2017-06-21 14:29   ` Roberto Sassu
2017-06-21 14:29   ` Roberto Sassu
2017-06-23 10:26   ` Jarkko Sakkinen
2017-06-23 10:26     ` Jarkko Sakkinen
2017-06-23 10:26     ` Jarkko Sakkinen
2017-06-23 11:25     ` Roberto Sassu
2017-06-23 11:25       ` Roberto Sassu
2017-06-23 11:25       ` Roberto Sassu
2017-06-23 11:25       ` Roberto Sassu
2017-06-27 15:24   ` [tpmdd-devel] [PATCH v3 3/6] tpm: introduce tpm_pcr_bank_info structure with digest_size from TP Mimi Zohar
2017-06-27 15:24     ` [PATCH v3 3/6] tpm: introduce tpm_pcr_bank_info structure with digest_size from TPM Mimi Zohar
2017-06-27 15:24     ` [tpmdd-devel] " Mimi Zohar
2017-06-27 15:24     ` Mimi Zohar
2017-06-21 14:29 ` [PATCH v3 4/6] tpm: replace TPM algorithms IDs with tpm_pcr_bank_info structs in tpm_chip Roberto Sassu
2017-06-21 14:29   ` Roberto Sassu
2017-06-21 14:29   ` Roberto Sassu
2017-06-21 14:29   ` Roberto Sassu
2017-06-23 10:32   ` Jarkko Sakkinen
2017-06-23 10:32     ` Jarkko Sakkinen
2017-06-23 10:32     ` Jarkko Sakkinen
2017-06-21 14:29 ` [PATCH v3 5/6] tpm: introduce tpm_get_pcr_banks_info() Roberto Sassu
2017-06-21 14:29   ` Roberto Sassu
2017-06-21 14:29   ` Roberto Sassu
2017-06-21 14:29   ` Roberto Sassu
2017-06-23 10:35   ` Jarkko Sakkinen
2017-06-23 10:35     ` Jarkko Sakkinen
2017-06-23 10:35     ` Jarkko Sakkinen
2017-06-21 14:29 ` [PATCH v3 6/6] tpm: pass multiple digests to tpm_pcr_extend() Roberto Sassu
2017-06-21 14:29   ` Roberto Sassu
2017-06-21 14:29   ` Roberto Sassu
2017-06-21 14:29   ` Roberto Sassu
2017-06-23 10:37   ` [tpmdd-devel] " Jarkko Sakkinen
2017-06-23 10:37     ` Jarkko Sakkinen
2017-06-23 10:37     ` [tpmdd-devel] " Jarkko Sakkinen
2017-06-23 10:37     ` Jarkko Sakkinen
2017-06-24  9:03 ` [PATCH v3 0/6] Updated API for TPM 2.0 PCR extend Jarkko Sakkinen
2017-06-24  9:03   ` Jarkko Sakkinen
2017-06-24  9:03   ` Jarkko Sakkinen
2017-06-24  9:03   ` Jarkko Sakkinen
2017-06-26  6:58   ` Roberto Sassu
2017-06-26  6:58     ` Roberto Sassu
2017-06-26  6:58     ` Roberto Sassu
2017-06-26  6:58     ` Roberto Sassu
2017-06-26  7:21   ` Roberto Sassu
2017-06-26  7:21     ` Roberto Sassu
2017-06-26  7:21     ` Roberto Sassu
2017-06-26  7:21     ` Roberto Sassu
2017-06-28 17:10     ` Jarkko Sakkinen
2017-06-28 17:10       ` Jarkko Sakkinen
2017-06-28 17:10       ` Jarkko Sakkinen
2017-06-26 12:33   ` [Linux-ima-devel] " Mimi Zohar
2017-06-26 12:33     ` Mimi Zohar
2017-06-26 12:33     ` Mimi Zohar
2017-06-26 14:56     ` Roberto Sassu
2017-06-26 14:56       ` Roberto Sassu
2017-06-26 14:56       ` Roberto Sassu
2017-06-26 14:56       ` Roberto Sassu
2017-06-26 17:12       ` Mimi Zohar
2017-06-26 17:12         ` Mimi Zohar
2017-06-26 17:12         ` Mimi Zohar
2017-06-28 17:28     ` Jarkko Sakkinen
2017-06-28 17:28       ` Jarkko Sakkinen
2017-06-28 17:28       ` Jarkko Sakkinen
2017-06-28 22:28       ` Mimi Zohar
2017-06-28 22:28         ` Mimi Zohar
2017-06-28 22:28         ` Mimi Zohar
2017-07-05 15:18       ` [tpmdd-devel] " Ken Goldman
2017-07-05 15:18         ` Ken Goldman
2017-07-05 15:18         ` Ken Goldman
2017-07-05 15:18         ` Ken Goldman
2017-07-05 16:06         ` Mimi Zohar
2017-07-05 16:06           ` Mimi Zohar
2017-07-05 16:06           ` Mimi Zohar

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=20170621142941.32674-4-roberto.sassu@huawei.com \
    --to=roberto.sassu@huawei.com \
    --cc=linux-security-module@vger.kernel.org \
    /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 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.