diff --git a/0001-tpm2_getcap-fix-misspelling-of-TPM2_PT_HR_-constants.patch b/0001-tpm2_getcap-fix-misspelling-of-TPM2_PT_HR_-constants.patch new file mode 100644 index 0000000000000000000000000000000000000000..ea87be26819249d8b5382875d7887c423ec4986b --- /dev/null +++ b/0001-tpm2_getcap-fix-misspelling-of-TPM2_PT_HR_-constants.patch @@ -0,0 +1,104 @@ +From 7e9bb6c3a91a5da2792010f42df88ab9f80e8093 Mon Sep 17 00:00:00 2001 +From: Matthew Dempsky +Date: Tue, 27 Aug 2019 18:11:27 -0700 +Subject: [PATCH] tpm2_getcap: fix misspelling of TPM2_PT_HR_ constants + +tpm2-tss mispelled some of these constants as TPM2_PT_TPM2_HR_* +instead of just TPM2_PT_HR_*, and tpm2_getcap blindly followed suit. + +This commit switches tpm2_getcap to use the proper names, and to +define them locally if they're missing. Once tpm2-tools can assume a +fixed tpm2-tss, this workaround can be removed. + +Updates tpm2-software/tpm2-tss#1500. + +Signed-off-by: Matthew Dempsky +--- + tools/tpm2_getcap.c | 37 +++++++++++++++++++++++++------------ + 1 file changed, 25 insertions(+), 12 deletions(-) + +diff --git a/tools/tpm2_getcap.c b/tools/tpm2_getcap.c +index 9b15e3b..8b753dd 100644 +--- a/tools/tpm2_getcap.c ++++ b/tools/tpm2_getcap.c +@@ -38,6 +38,19 @@ + #include "tpm2_tool.h" + #include "tpm2_util.h" + ++/* ++ * Older versions of tpm2-tss misspelled these constants' names. ++ * See https://github.com/tpm2-software/tpm2-tss/issues/1500. ++ */ ++#ifndef TPM2_PT_HR_TRANSIENT_MIN ++#define TPM2_PT_HR_TRANSIENT_MIN ((TPM2_PT) (TPM2_PT_FIXED + 14)) ++#define TPM2_PT_HR_PERSISTENT_MIN ((TPM2_PT) (TPM2_PT_FIXED + 15)) ++#define TPM2_PT_HR_NV_INDEX ((TPM2_PT) (TPM2_PT_VAR + 2)) ++#define TPM2_PT_HR_TRANSIENT_AVAIL ((TPM2_PT) (TPM2_PT_VAR + 7)) ++#define TPM2_PT_HR_PERSISTENT ((TPM2_PT) (TPM2_PT_VAR + 8)) ++#define TPM2_PT_HR_PERSISTENT_AVAIL ((TPM2_PT) (TPM2_PT_VAR + 9)) ++#endif ++ + /* convenience macro to convert flags into "set" / "clear" strings */ + #define prop_str(val) val ? "set" : "clear" + /* number of eleents in the capability_map array */ +@@ -313,11 +313,11 @@ dump_tpm_properties_fixed (TPMS_TAGGED_PROPERTY properties[], + case TPM2_PT_INPUT_BUFFER: + tpm2_tool_output ("TPM2_PT_INPUT_BUFFER: 0x%08x\n", value); + break; +- case TPM2_PT_TPM2_HR_TRANSIENT_MIN: +- tpm2_tool_output ("TPM2_PT_TPM2_HR_TRANSIENT_MIN: 0x%08x\n", value); ++ case TPM2_PT_HR_TRANSIENT_MIN: ++ tpm2_tool_output ("TPM2_PT_HR_TRANSIENT_MIN: 0x%08x\n", value); + break; +- case TPM2_PT_TPM2_HR_PERSISTENT_MIN: +- tpm2_tool_output ("TPM2_PT_TPM2_HR_PERSISTENT_MIN: 0x%08x\n", value); ++ case TPM2_PT_HR_PERSISTENT_MIN: ++ tpm2_tool_output ("TPM2_PT_HR_PERSISTENT_MIN: 0x%08x\n", value); + break; + case TPM2_PT_HR_LOADED_MIN: + tpm2_tool_output ("TPM2_PT_HR_LOADED_MIN: 0x%08x\n", value); +@@ -428,8 +428,8 @@ dump_tpm_properties_var (TPMS_TAGGED_PROPERTY properties[], + case TPM2_PT_STARTUP_CLEAR: + dump_startup_clear_attrs ((TPMA_STARTUP_CLEAR)value); + break; +- case TPM2_PT_TPM2_HR_NV_INDEX: +- tpm2_tool_output ("TPM2_PT_TPM2_HR_NV_INDEX: 0x%08x\n", value); ++ case TPM2_PT_HR_NV_INDEX: ++ tpm2_tool_output ("TPM2_PT_HR_NV_INDEX: 0x%08x\n", value); + break; + case TPM2_PT_HR_LOADED: + tpm2_tool_output ("TPM2_PT_HR_LOADED: 0x%08x\n", value); +@@ -443,14 +443,14 @@ dump_tpm_properties_var (TPMS_TAGGED_PROPERTY properties[], + case TPM2_PT_HR_ACTIVE_AVAIL: + tpm2_tool_output ("TPM2_PT_HR_ACTIVE_AVAIL: 0x%08x\n", value); + break; +- case TPM2_PT_TPM2_HR_TRANSIENT_AVAIL: +- tpm2_tool_output ("TPM2_PT_TPM2_HR_TRANSIENT_AVAIL: 0x%08x\n", value); ++ case TPM2_PT_HR_TRANSIENT_AVAIL: ++ tpm2_tool_output ("TPM2_PT_HR_TRANSIENT_AVAIL: 0x%08x\n", value); + break; +- case TPM2_PT_TPM2_HR_PERSISTENT: +- tpm2_tool_output ("TPM2_PT_TPM2_HR_PERSISTENT: 0x%08x\n", value); ++ case TPM2_PT_HR_PERSISTENT: ++ tpm2_tool_output ("TPM2_PT_HR_PERSISTENT: 0x%08x\n", value); + break; +- case TPM2_PT_TPM2_HR_PERSISTENT_AVAIL: +- tpm2_tool_output ("TPM2_PT_TPM2_HR_PERSISTENT_AVAIL: 0x%08x\n", value); ++ case TPM2_PT_HR_PERSISTENT_AVAIL: ++ tpm2_tool_output ("TPM2_PT_HR_PERSISTENT_AVAIL: 0x%08x\n", value); + break; + case TPM2_PT_NV_COUNTERS: + tpm2_tool_output ("TPM2_PT_NV_COUNTERS: 0x%08x\n", value); +diff --git a/tools/tpm2_listpersistent.c b/tools/tpm2_listpersistent.c +index 45da1a4..d693e6c 100644 +--- a/tools/tpm2_listpersistent.c ++++ b/tools/tpm2_listpersistent.c +@@ -152,7 +152,7 @@ int tpm2_tool_onrun(TSS2_SYS_CONTEXT *sapi_context, tpm2_option_flags flags) { + + UINT32 property = tpm2_util_endian_swap_32(TPM2_HT_PERSISTENT); + rval = TSS2_RETRY_EXP(Tss2_Sys_GetCapability(sapi_context, 0, TPM2_CAP_HANDLES, +- property, TPM2_PT_TPM2_HR_PERSISTENT, &moreData, ++ property, TPM2_PT_HR_PERSISTENT, &moreData, + &capabilityData, 0)); + if(rval != TPM2_RC_SUCCESS) + { diff --git a/Revert-objectattrs-clear-before-or-ing-in-values.patch b/Revert-objectattrs-clear-before-or-ing-in-values.patch new file mode 100644 index 0000000000000000000000000000000000000000..de2f41ff1a2b6e32e0b0a546f35bff43cf6d40d0 --- /dev/null +++ b/Revert-objectattrs-clear-before-or-ing-in-values.patch @@ -0,0 +1,43 @@ +From 1f3451ee7b046a590b6dfc20b6af010166670ff7 Mon Sep 17 00:00:00 2001 +From: Javier Martinez Canillas +Date: Thu, 12 Jul 2018 19:50:26 +0200 +Subject: [PATCH 1/1] Revert "objectattrs: clear before or'ing in values" + +This reverts commit e103bbf5117b0b62b358fd15f18f848854fcb0ee. + +The tpm2-tools 3.1.0 release contains a backward incompatible change that +was introduced by commit e103bbf5117 ("objectattrs: clear before or'ing +in values"), that changed the way that object attributes were specified. + +Before there were a set of default attributes and the user could specify +additional attributes to be used, but after the mentioned commit the user +must specify all attributes. + +This is a user visible change that changes the tools semantics, so is not +a suitable change for a MINOR version number increment, according to the +Semantic Versioning document (https://semver.org) since it breaks rule 2: + +2.MINOR version when you add functionality in a backwards-compatible manner + +Fixes: #1097 + +Signed-off-by: Javier Martinez Canillas +--- + lib/tpm2_attr_util.c | 1 - + 1 file changed, 1 deletion(-) + +diff --git a/lib/tpm2_attr_util.c b/lib/tpm2_attr_util.c +index d461a744c0d..e43d03f9e0a 100644 +--- a/lib/tpm2_attr_util.c ++++ b/lib/tpm2_attr_util.c +@@ -501,7 +501,6 @@ bool tpm2_attr_util_nv_strtoattr(char *attribute_list, TPMA_NV *nvattrs) { + + bool tpm2_attr_util_obj_strtoattr(char *attribute_list, TPMA_OBJECT *objattrs) { + +- memset(objattrs, 0, sizeof(*objattrs)); + return common_strtoattr(attribute_list, objattrs, obj_attr_table, ARRAY_LEN(obj_attr_table)); + } + +-- +2.17.1 + diff --git a/tpm2-tools-3.1.1.tar.gz b/tpm2-tools-3.1.1.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..593814f2f1c971eac5adbf545df3ad89aed055a5 Binary files /dev/null and b/tpm2-tools-3.1.1.tar.gz differ diff --git a/tpm2-tools-5.0.tar.gz b/tpm2-tools-5.0.tar.gz deleted file mode 100644 index 80adb10cbab5557ea4e152a7efacfa1a1ec061fa..0000000000000000000000000000000000000000 Binary files a/tpm2-tools-5.0.tar.gz and /dev/null differ diff --git a/tpm2-tools.spec b/tpm2-tools.spec index 699961b1fd115875cdb959840d668854bcf5b54e..9b927af50c029afcc98a8b3a8addbd78195ff7dd 100644 --- a/tpm2-tools.spec +++ b/tpm2-tools.spec @@ -1,15 +1,18 @@ Name: tpm2-tools -Version: 5.0 -Release: 1 +Version: 3.1.1 +Release: 8 Summary: A TPM2.0 testing tool based on TPM2.0-TSS License: BSD URL: https://github.com/tpm2-software/tpm2-tools Source0: https://github.com/tpm2-software/tpm2-tools/releases/download/%{version}/%{name}-%{version}.tar.gz +Patch1: Revert-objectattrs-clear-before-or-ing-in-values.patch +Patch2: 0001-tpm2_getcap-fix-misspelling-of-TPM2_PT_HR_-constants.patch + BuildRequires: gcc-c++ libtool autoconf-archive pkgconfig(cmocka) pkgconfig(libcurl) pkgconfig(openssl) -BuildRequires: pkgconfig(tss2-mu) pkgconfig(tss2-sys) pkgconfig(tss2-esys) pkgconfig(uuid) git libgcrypt +BuildRequires: pkgconfig(tss2-mu) pkgconfig(tss2-sys) pkgconfig(tss2-esys) git libgcrypt BuildRequires: libgcrypt-devel gdb -Requires: tpm2-tss >= 2.3.1 +Requires: tpm2-tss >= 2.0.0-2 Obsoletes: tpm2-tools <= 2.1.1-2 %description @@ -45,19 +48,14 @@ make check %files %defattr(-,root,root) -%license doc/LICENSE +%license LICENSE %{_bindir}/* -%{_datadir}/bash-completion/completions/tpm2* -%{_datadir}/bash-completion/completions/tss2* %files help -%doc README.md doc/CHANGELOG.md +%doc README.md CHANGELOG.md %{_mandir}/*/* %changelog -* Fri Mar 19 2021 Hugel - 5.0-1 -- update to 5.0 - * Tue May 12 2020 wanghongzhe - 3.1.1-8 - bugfix for tpm2-tss upgrade