Some SlackBuild scripts for Slackware.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

111 lines
3.0 KiB

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