]> git.proxmox.com Git - libtpms.git/commitdiff
rev148: Rework USE_DA_USED
authorStefan Berger <stefanb@linux.vnet.ibm.com>
Wed, 11 Jul 2018 15:48:38 +0000 (11:48 -0400)
committerStefan Berger <stefanb@us.ibm.com>
Thu, 3 Jan 2019 18:15:44 +0000 (13:15 -0500)
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
src/tpm2/DA.c
src/tpm2/ExecCommand.c
src/tpm2/Global.c
src/tpm2/Global.h
src/tpm2/NVMarshal.c
src/tpm2/SessionProcess.c
src/tpm2/StartupCommands.c
src/tpm2/TpmBuildSwitches.h

index 1cab4567531d08761ce0b53a1e10f15b0cf123d5..d63740823535c3243445b2598ac2450d313219c5 100644 (file)
@@ -139,7 +139,7 @@ DAStartup(
        && gp.failedTries < gp.maxTries
        && !IS_ORDERLY(g_prevOrderlyState))
        {
-#ifdef USE_DA_USED
+#if USE_DA_USED
            gp.failedTries += g_daUsed;
            g_daUsed = FALSE;
 #else
index a68a49496d1367abb1769cd074713d468616c7c0..6dbb3ea5cf74cbefadda00dfee7572da85710517 100644 (file)
@@ -1,9 +1,9 @@
 /********************************************************************************/
 /*                                                                             */
-/*                                                     */
+/*                          ExecCommand                                        */
 /*                          Written by Ken Goldman                             */
 /*                    IBM Thomas J. Watson Research Center                     */
-/*            $Id: ExecCommand.c 809 2016-11-16 18:31:54Z kgoldman $                   */
+/*            $Id: ExecCommand.c 1259 2018-07-10 19:11:09Z kgoldman $          */
 /*                                                                             */
 /*  Licenses and Notices                                                       */
 /*                                                                             */
@@ -55,7 +55,7 @@
 /*    arising in any way out of use or reliance upon this specification or any         */
 /*    information herein.                                                      */
 /*                                                                             */
-/*  (c) Copyright IBM Corp. and others, 2016                                   */
+/*  (c) Copyright IBM Corp. and others, 2016 - 2018                            */
 /*                                                                             */
 /********************************************************************************/
 
@@ -280,7 +280,7 @@ ExecuteCommand(
     if(g_clearOrderly == TRUE
        && NV_IS_ORDERLY)
        {
-#ifdef USE_DA_USED
+#if USE_DA_USED
            gp.orderlyState = g_daUsed ? SU_DA_USED_VALUE : SU_NONE_VALUE;
 #else
            gp.orderlyState = SU_NONE_VALUE;
index 0579b4d7455649d9cda37899ff2e5a96d4f8fb96..8e2b173051844e16fc26f22e41ab26d9217065ce 100644 (file)
@@ -83,7 +83,7 @@ BOOL                 g_pcrReConfig;
 TPMI_DH_OBJECT       g_DRTMHandle;
 BOOL                 g_DrtmPreStartup;
 BOOL                 g_StartupLocality3;
-#ifdef USE_DA_USED
+#if USE_DA_USED
 BOOL                   g_daUsed;
 #endif
 BOOL                 g_powerWasLost;
index bb1561d12255176337e3fc8487be140d76a3d296..a7afa71e413c4c1a28beeee6948a2e0d76699732 100644 (file)
@@ -534,7 +534,7 @@ extern  BOOL            g_StartupLocality3;
 #define PRE_STARTUP_FLAG        0x8000
 #define STARTUP_LOCALITY_3   0x4000
 #define TPM_SU_STATE_MASK ~(PRE_STARTUP_FLAG | STARTUP_LOCALITY_3) // libtpms added
-#ifdef USE_DA_USED
+#if USE_DA_USED
 /*     5.10.10.15 g_daUsed */
 /* This location indicates if a DA-protected value is accessed during a boot cycle. If none has,
    then there is no need to increment failedTries on the next non-orderly startup. This bit is
index ca704bac85390b6eabc69a5ce32ff359ff8aca8b..3f6985aa6df201335b7dc619e17a9f457ece70d5 100644 (file)
@@ -2663,14 +2663,14 @@ VolatileState_Marshal(BYTE **buffer, INT32 *size)
     /* g_StartupLocality3: must write */
     written += BOOL_Marshal(&g_StartupLocality3, buffer, size); /* line 458 */
 
-#ifdef USE_DA_USED
+#if USE_DA_USED
     has_block = TRUE;
 #else
     has_block = FALSE;
 #endif
     written += BLOCK_SKIP_WRITE_PUSH(has_block, buffer, size);
 
-#ifdef USE_DA_USED
+#if USE_DA_USED
     /* g_daUsed: must write */
     written += BOOL_Marshal(&g_daUsed, buffer, size); /* line 484 */
 #endif
@@ -3012,7 +3012,7 @@ VolatileState_Unmarshal(BYTE **buffer, INT32 *size)
         rc = BOOL_Unmarshal(&g_StartupLocality3, buffer, size); /* line 458 */
     }
 
-#ifdef USE_DA_USED
+#if USE_DA_USED
     needs_block = TRUE;
 #else
     needs_block = FALSE;
@@ -3021,7 +3021,7 @@ VolatileState_Unmarshal(BYTE **buffer, INT32 *size)
         BLOCK_SKIP_READ(skip_da, needs_block, buffer, size,
                         "Volatile state", "g_daUsed");
     }
-#ifdef USE_DA_USED
+#if USE_DA_USED
     if (rc == TPM_RC_SUCCESS) {
         rc = BOOL_Unmarshal(&g_daUsed, buffer, size); /* line 484 */
     }
index b906f7bd448f6c1c02b4ac2c3e67ed6bba76ce4f..db53046753fa8ac6639ebd4ad69e76bef3e410bd 100644 (file)
@@ -1193,7 +1193,7 @@ CheckLockedOut(
            // ... or if the number of failed tries has been maxed out.
            if(gp.failedTries >= gp.maxTries)
                return TPM_RC_LOCKOUT;
-#ifdef USE_DA_USED
+#if USE_DA_USED
            // If the daUsed flag is not SET, then no DA validation until the
            // daUsed state is written to NV
            if(!g_daUsed)
index 5f9f0bc1873ceb684f07a7607f31b61b012d7da3..7b2e576ac682da14ba0eecb61a31d02e739944c6 100644 (file)
@@ -143,7 +143,7 @@ TPM2_Startup(
     if(g_DrtmPreStartup)
        locality = 0;
     g_StartupLocality3 = (locality == 3);
-#ifdef USE_DA_USED
+#if USE_DA_USED
     // If there was no orderly shutdown, then their might have been a write to
     // failedTries that didn't get recorded but only if g_daUsed was SET in the
     // shutdown state
index 7088de26317cd33911895c10a23e10f5e85f767a..023215f28089ffcc5e377bb23201de3dc7111019 100644 (file)
 #ifndef FIPS_COMPLIANT
 //#  define FIPS_COMPLIANT
 #endif
-/* Definition to allow alternate behavior for non-orderly startup. If there is a chance that the TPM
-   could not update failedTries */
-#ifndef USE_DA_USED
-#   define USE_DA_USED
+// Definition to allow alternate behavior for non-orderly startup. If there is a chance that the TPM
+// could not update failedTries
+#if !(defined USE_DA_USED) || ((USE_DA_USED != NO) && (USE_DA_USED != YES))
+#   undef   USE_DA_USED
+#   define  USE_DA_USED     YES         // Default: Either YES or NO
 #endif
 /* Define TABLE_DRIVEN_DISPATCH to use tables rather than case statements for command dispatch and
    handle unmarshaling */