rev180: Add ALLOW_FORCE_FAILURE_MODE with 'NO' and use it

Set ALLOW_FORCE_FAILURE_MODE to 'NO' and used it in some places where
SIMULATION was used, which is also set to 'NO'.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
This commit is contained in:
Stefan Berger 2023-12-20 14:19:59 -05:00 committed by Stefan Berger
parent 831a9410ad
commit d7b2ff804f
5 changed files with 16 additions and 8 deletions

View File

@ -116,7 +116,7 @@ TPM_RC
CryptSelfTest(TPMI_YES_NO fullTest // IN: if full test is required
)
{
#if SIMULATION
#if ALLOW_FORCE_FAILURE_MODE
if(g_forceFailureMode)
FAIL(FATAL_ERROR_FORCED);
#endif

View File

@ -1468,7 +1468,7 @@ EXTERN UINT32 s_actionIoAllocation; // number of UIN64 allocated for the
// in which the failure occurred. This address value is not useful for anything
// other than helping the vendor to know in which file the failure occurred.
EXTERN BOOL g_inFailureMode; // Indicates that the TPM is in failure mode
# if SIMULATION
# if ALLOW_FORCE_FAILURE_MODE
EXTERN BOOL g_forceFailureMode; // flag to force failure mode during test
# endif

View File

@ -82,7 +82,8 @@ LIB_EXPORT void _TPM_Init(void)
memset(&go, 0xbb, sizeof(go));
}
#endif
#if SIMULATION
#if ALLOW_FORCE_FAILURE_MODE
// Clear the flag that forces failure on self-test
g_forceFailureMode = FALSE;
#endif

View File

@ -122,6 +122,16 @@
// Define this to run the function that checks the compatibility between the chosen big number math
// library and the TPM code. Not all ports use this.
////////////////////////////////////////////////////////////////
// TEST OPTIONS
////////////////////////////////////////////////////////////////
// The SIMULATION flag can enable test crypto behaviors and caching that
// significantly change the behavior of the code. This flag controls only the
// g_forceFailureMode flag in the TPM library while leaving the rest of the TPM
// behavior alone. Useful for testing when the full set of options controlled by
// SIMULATION may not be desired.
#define ALLOW_FORCE_FAILURE_MODE NO // libtpms: NO
#if !(defined LIBRARY_COMPATIBILITY_CHECK) \
|| (( LIBRARY_COMPATIBILITY_CHECK != NO) \
&& (LIBRARY_COMPATIBILITY_CHECK != YES))

View File

@ -178,19 +178,16 @@ static BOOL Unmarshal16(UINT16* target, BYTE** buffer, INT32* size)
}
//** Public Functions
#if 0 /* libtpms added */
//*** SetForceFailureMode()
// This function is called by the simulator to enable failure mode testing.
#if ALLOW_FORCE_FAILURE_MODE
LIB_EXPORT void SetForceFailureMode(void)
{
#if SIMULATION
g_forceFailureMode = TRUE;
#endif
return;
}
#endif /* libtpms added */
#endif // ALLOW_FORCE_FAILURE_MODE
/* libtpms added begin */
static void