Browse Source

l/tpm2-tss: Patched to silence expected error messages.

current-20191101
Damien Goutte-Gattat 4 months ago
parent
commit
054e3aefd5
2 changed files with 115 additions and 1 deletions
  1. +111
    -0
      l/tpm2-tss/tpm2-tss-2.4.1-silence-expected-errors.patch
  2. +4
    -1
      l/tpm2-tss/tpm2-tss.SlackBuild

+ 111
- 0
l/tpm2-tss/tpm2-tss-2.4.1-silence-expected-errors.patch View File

@@ -0,0 +1,111 @@
commit 6eb5a49a1f55325accb46b51e775857a3ea6ec57
Author: William Roberts <william.c.roberts@intel.com>
Date: Thu Mar 19 19:10:50 2020 -0500

Esys_TestParams: silence expected errors
The TestParams code is used to test paramters against the TPM to
understand if a specific algorithm and scheme is supported. Thus,
certain errors are expected. The expected errors are:
1. From any layer
2. Are Format 1 errors
3. Are P1 or Parameter 1 errors
4 are one of:
- RC_CURVE
- RC_VALUE
- RC_ASSYMETRIC
- RC_KEY_SIZE
Fixes: #1573
Signed-off-by: William Roberts <william.c.roberts@intel.com>

diff --git a/src/tss2-esys/api/Esys_TestParms.c b/src/tss2-esys/api/Esys_TestParms.c
index e64521e9..9b5bffa8 100644
--- a/src/tss2-esys/api/Esys_TestParms.c
+++ b/src/tss2-esys/api/Esys_TestParms.c
@@ -92,9 +92,11 @@ Esys_TestParms(
/* Restore the timeout value to the original value */
esysContext->timeout = timeouttmp;
- return_if_error(r, "Esys Finish");
+ if (!tss2_is_expected_error(r)) {
+ return_if_error(r, "Esys Finish");
+ }
- return TSS2_RC_SUCCESS;
+ return r;
}
/** Asynchronous function for TPM2_TestParms
@@ -266,7 +268,9 @@ Esys_TestParms_Finish(
}
/* The following is the "regular error" handling. */
if (iesys_tpm_error(r)) {
- LOG_WARNING("Received TPM Error");
+ if (!tss2_is_expected_error(r)) {
+ LOG_WARNING("Received TPM Error");
+ }
esysContext->state = _ESYS_STATE_INIT;
return r;
} else if (r != TSS2_RC_SUCCESS) {
diff --git a/src/util/aux_util.h b/src/util/aux_util.h
index 3f9eb841..35deca87 100644
--- a/src/util/aux_util.h
+++ b/src/util/aux_util.h
@@ -6,6 +6,9 @@
#ifndef AUX_UTIL_H
#define AUX_UTIL_H
+#include <stdbool.h>
+
+#include "tss2_tpm2_types.h"
#ifdef __cplusplus
extern "C" {
#endif
@@ -84,6 +87,45 @@ extern "C" {
r_max = r; \
}
+static inline TSS2_RC
+tss2_fmt_p1_error_to_rc(UINT16 err)
+{
+ return TPM2_RC_1+TPM2_RC_P+err;
+}
+
+static inline bool
+tss2_is_expected_error(TSS2_RC rc)
+{
+ /* Success is always expected */
+ if (rc == TSS2_RC_SUCCESS) {
+ return true;
+ }
+
+ /*
+ * drop the layer, any part of the TSS stack can gripe about this error
+ * if it wants too.
+ */
+ rc &= ~TSS2_RC_LAYER_MASK;
+
+ /*
+ * Format 1, parameter 1 errors plus the below RC's
+ * contain everything we care about:
+ * - TPM2_RC_CURVE
+ * - TPM2_RC_HASH
+ * - TPM2_RC_ASYMMETRIC
+ * - TPM2_RC_KEY_SIZE
+ */
+ if (rc == tss2_fmt_p1_error_to_rc(TPM2_RC_CURVE)
+ || rc == tss2_fmt_p1_error_to_rc(TPM2_RC_VALUE)
+ || rc == tss2_fmt_p1_error_to_rc(TPM2_RC_HASH)
+ || rc == tss2_fmt_p1_error_to_rc(TPM2_RC_ASYMMETRIC)
+ || rc == tss2_fmt_p1_error_to_rc(TPM2_RC_KEY_SIZE)) {
+ return true;
+ }
+
+ return false;
+}
+
#ifdef __cplusplus
} /* extern "C" */
#endif

+ 4
- 1
l/tpm2-tss/tpm2-tss.SlackBuild View File

@@ -33,7 +33,7 @@ WGET=${WGET:-https://github.com/tpm2-software/tpm2-tss/releases/download/$VERSIO

# Build infos
NAMEPKG=${NAMEPKG:-tpm2-tss}
BUILD=${BUILD:-1GGD}
BUILD=${BUILD:-2GGD}
ARCH=${ARCH:-$(uname -m | sed 's/^i.86$/i486/;s/^arm.*/arm/')}
JOBS=${JOBS:-1}
EXT=${EXT:-txz}
@@ -84,6 +84,9 @@ cd $TMP
echo "Building $ARCHIVE..."
tar xf $CWD/$ARCHIVE
cd $NAME
# Silence expected errors about unsupported algorithms
# <https://github.com/tpm2-software/tpm2-tss/issues/1573>
patch -p 1 < $CWD/tpm2-tss-2.4.1-silence-expected-errors.patch
CFLAGS=$CPUOPT \
CXXFLAGS=$CPUOPT \
./configure \


Loading…
Cancel
Save