]> git.proxmox.com Git - libtpms.git/commitdiff
tpm2: ACT: Add data structures, defines, and un/marshalling code
authorStefan Berger <stefanb@linux.vnet.ibm.com>
Tue, 26 Nov 2019 14:33:15 +0000 (09:33 -0500)
committerStefan Berger <stefanb@us.ibm.com>
Tue, 14 Apr 2020 20:03:45 +0000 (16:03 -0400)
Disable ACT via the TpmProfile.h's RH_ACT_{0,1,A) settings of NO.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
24 files changed:
src/Makefile.am
src/tpm2/ACT.h [new file with mode: 0644]
src/tpm2/ACTCommands.c [new file with mode: 0644]
src/tpm2/ACT_SetTimeout_fp.h [new file with mode: 0644]
src/tpm2/ACT_spt_fp.h [new file with mode: 0644]
src/tpm2/Capabilities.h
src/tpm2/CommandAttributeData.h
src/tpm2/Global.h
src/tpm2/InternalRoutines.h
src/tpm2/Marshal.c
src/tpm2/Marshal_fp.h
src/tpm2/Platform.h
src/tpm2/PlatformACT.h [new file with mode: 0644]
src/tpm2/PlatformACT_fp.h [new file with mode: 0644]
src/tpm2/PlatformData.h
src/tpm2/Simulator_fp.h
src/tpm2/TpmAlgorithmDefines.h
src/tpm2/TpmProfile.h
src/tpm2/TpmSizeChecks.c
src/tpm2/TpmTcpProtocol.h
src/tpm2/TpmTypes.h
src/tpm2/Unmarshal.c
src/tpm2/Unmarshal_fp.h
src/tpm_tpm2_interface.c

index 0dcd3fa41560be7d6b3aba882f9d21513886f695..66b9c8c57b9d200cdf90789c5adbafdd42df330d 100644 (file)
@@ -182,6 +182,7 @@ libtpms_tpm2_la_CFLAGS += -DTPM_POSIX
 libtpms_tpm2_la_CFLAGS += -DTPM_LIBTPMS_CALLBACKS
 
 libtpms_tpm2_la_SOURCES = \
+       tpm2/ACTCommands.c \
        tpm2/AlgorithmCap.c \
        tpm2/AlgorithmTests.c \
        tpm2/AsymmetricCommands.c \
@@ -298,6 +299,9 @@ noinst_HEADERS += \
        tpm2/crypto/CryptSym_fp.h \
        tpm2/crypto/CryptTest.h \
        tpm2/crypto/CryptUtil_fp.h \
+       tpm2/ACT.h \
+       tpm2/ACT_spt_fp.h \
+       tpm2/ACT_SetTimeout_fp.h \
        tpm2/ActivateCredential_fp.h \
        tpm2/AlgorithmCap_fp.h \
        tpm2/AlgorithmTests_fp.h \
@@ -411,6 +415,8 @@ noinst_HEADERS += \
        tpm2/PCR_SetAuthPolicy_fp.h \
        tpm2/PCR_SetAuthValue_fp.h \
        tpm2/Platform.h \
+       tpm2/PlatformACT.h \
+       tpm2/PlatformACT_fp.h \
        tpm2/PlatformClock.h \
        tpm2/PlatformData.h \
        tpm2/Platform_fp.h \
diff --git a/src/tpm2/ACT.h b/src/tpm2/ACT.h
new file mode 100644 (file)
index 0000000..ec609af
--- /dev/null
@@ -0,0 +1,257 @@
+/********************************************************************************/
+/*                                                                             */
+/*                      Authenticated Countdown Timer                          */
+/*                          Written by Ken Goldman                             */
+/*                    IBM Thomas J. Watson Research Center                     */
+/*            $Id$             */
+/*                                                                             */
+/*  Licenses and Notices                                                       */
+/*                                                                             */
+/*  1. Copyright Licenses:                                                     */
+/*                                                                             */
+/*  - Trusted Computing Group (TCG) grants to the user of the source code in   */
+/*    this specification (the "Source Code") a worldwide, irrevocable,                 */
+/*    nonexclusive, royalty free, copyright license to reproduce, create       */
+/*    derivative works, distribute, display and perform the Source Code and    */
+/*    derivative works thereof, and to grant others the rights granted herein. */
+/*                                                                             */
+/*  - The TCG grants to the user of the other parts of the specification       */
+/*    (other than the Source Code) the rights to reproduce, distribute,        */
+/*    display, and perform the specification solely for the purpose of                 */
+/*    developing products based on such documents.                             */
+/*                                                                             */
+/*  2. Source Code Distribution Conditions:                                    */
+/*                                                                             */
+/*  - Redistributions of Source Code must retain the above copyright licenses,         */
+/*    this list of conditions and the following disclaimers.                   */
+/*                                                                             */
+/*  - Redistributions in binary form must reproduce the above copyright        */
+/*    licenses, this list of conditions        and the following disclaimers in the    */
+/*    documentation and/or other materials provided with the distribution.     */
+/*                                                                             */
+/*  3. Disclaimers:                                                            */
+/*                                                                             */
+/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF      */
+/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH      */
+/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)      */
+/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.                */
+/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for           */
+/*  information on specification licensing rights available through TCG        */
+/*  membership agreements.                                                     */
+/*                                                                             */
+/*  - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED        */
+/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR      */
+/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR             */
+/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY                 */
+/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.          */
+/*                                                                             */
+/*  - Without limitation, TCG and its members and licensors disclaim all       */
+/*    liability, including liability for infringement of any proprietary       */
+/*    rights, relating to use of information in this specification and to the  */
+/*    implementation of this specification, and TCG disclaims all liability for        */
+/*    cost of procurement of substitute goods or services, lost profits, loss  */
+/*    of use, loss of data or any incidental, consequential, direct, indirect,         */
+/*    or special damages, whether under contract, tort, warranty or otherwise,         */
+/*    arising in any way out of use or reliance upon this specification or any         */
+/*    information herein.                                                      */
+/*                                                                             */
+/*  (c) Copyright IBM Corp. and others, 2019                                   */
+/*                                                                             */
+/********************************************************************************/
+
+// 5.24        ACT.h
+
+#ifndef _ACT_H_
+#define _ACT_H_
+#include "TpmProfile.h"
+#if !(defined RH_ACT_0) || (RH_ACT_0 != YES)
+#   undef   RH_ACT_0
+#   define  RH_ACT_0 NO
+#   define IF_ACT_0_IMPLEMENTED(op)
+#else
+#   define IF_ACT_0_IMPLEMENTED(op) op(0)
+#endif
+#if !(defined RH_ACT_1) || (RH_ACT_1 != YES)
+#   undef   RH_ACT_1
+#   define  RH_ACT_1 NO
+#   define IF_ACT_1_IMPLEMENTED(op)
+#else
+#   define IF_ACT_1_IMPLEMENTED(op) op(1)
+#endif
+#if !(defined RH_ACT_2) || (RH_ACT_2 != YES)
+#   undef   RH_ACT_2
+#   define  RH_ACT_2 NO
+#   define IF_ACT_2_IMPLEMENTED(op)
+#else
+#   define IF_ACT_2_IMPLEMENTED(op) op(2)
+#endif
+#if !(defined RH_ACT_3) || (RH_ACT_3 != YES)
+#   undef   RH_ACT_3
+#   define  RH_ACT_3 NO
+#   define IF_ACT_3_IMPLEMENTED(op)
+#else
+#   define IF_ACT_3_IMPLEMENTED(op) op(3)
+#endif
+#if !(defined RH_ACT_4) || (RH_ACT_4 != YES)
+#   undef   RH_ACT_4
+#   define  RH_ACT_4 NO
+#   define IF_ACT_4_IMPLEMENTED(op)
+#else
+#   define IF_ACT_4_IMPLEMENTED(op) op(4)
+#endif
+#if !(defined RH_ACT_5) || (RH_ACT_5 != YES)
+#   undef   RH_ACT_5
+#   define  RH_ACT_5 NO
+#   define IF_ACT_5_IMPLEMENTED(op)
+#else
+#   define IF_ACT_5_IMPLEMENTED(op) op(5)
+#endif
+#if !(defined RH_ACT_6) || (RH_ACT_6 != YES)
+#   undef   RH_ACT_6
+#   define  RH_ACT_6 NO
+#   define IF_ACT_6_IMPLEMENTED(op)
+#else
+#   define IF_ACT_6_IMPLEMENTED(op) op(6)
+#endif
+#if !(defined RH_ACT_7) || (RH_ACT_7 != YES)
+#   undef   RH_ACT_7
+#   define  RH_ACT_7 NO
+#   define IF_ACT_7_IMPLEMENTED(op)
+#else
+#   define IF_ACT_7_IMPLEMENTED(op) op(7)
+#endif
+#if !(defined RH_ACT_8) || (RH_ACT_8 != YES)
+#   undef   RH_ACT_8
+#   define  RH_ACT_8 NO
+#   define IF_ACT_8_IMPLEMENTED(op)
+#else
+#   define IF_ACT_8_IMPLEMENTED(op) op(8)
+#endif
+#if !(defined RH_ACT_9) || (RH_ACT_9 != YES)
+#   undef   RH_ACT_9
+#   define  RH_ACT_9 NO
+#   define IF_ACT_9_IMPLEMENTED(op)
+#else
+#   define IF_ACT_9_IMPLEMENTED(op) op(9)
+#endif
+#if !(defined RH_ACT_A) || (RH_ACT_A != YES)
+#   undef   RH_ACT_A
+#   define  RH_ACT_A NO
+#   define IF_ACT_A_IMPLEMENTED(op)
+#else
+#   define IF_ACT_A_IMPLEMENTED(op) op(A)
+#endif
+#if !(defined RH_ACT_B) || (RH_ACT_B != YES)
+#   undef   RH_ACT_B
+#   define  RH_ACT_B NO
+#   define IF_ACT_B_IMPLEMENTED(op)
+#else
+#   define IF_ACT_B_IMPLEMENTED(op) op(B)
+#endif
+#if !(defined RH_ACT_C) || (RH_ACT_C != YES)
+#   undef   RH_ACT_C
+#   define  RH_ACT_C NO
+#   define IF_ACT_C_IMPLEMENTED(op)
+#else
+#   define IF_ACT_C_IMPLEMENTED(op) op(C)
+#endif
+#if !(defined RH_ACT_D) || (RH_ACT_D != YES)
+#   undef   RH_ACT_D
+#   define  RH_ACT_D NO
+#   define IF_ACT_D_IMPLEMENTED(op)
+#else
+#   define IF_ACT_D_IMPLEMENTED(op) op(D)
+#endif
+#if !(defined RH_ACT_E) || (RH_ACT_E != YES)
+#   undef   RH_ACT_E
+#   define  RH_ACT_E NO
+#   define IF_ACT_E_IMPLEMENTED(op)
+#else
+#   define IF_ACT_E_IMPLEMENTED(op) op(E)
+#endif
+#if !(defined RH_ACT_F) || (RH_ACT_F != YES)
+#   undef   RH_ACT_F
+#   define  RH_ACT_F NO
+#   define IF_ACT_F_IMPLEMENTED(op)
+#else
+#   define IF_ACT_F_IMPLEMENTED(op) op(F)
+#endif
+#ifndef TPM_RH_ACT_0
+#error Need numeric definition for TPM_RH_ACT_0
+#endif
+#ifndef TPM_RH_ACT_1
+#   define TPM_RH_ACT_1    (TPM_RH_ACT_0 + 1)
+#endif
+#ifndef TPM_RH_ACT_2
+#   define TPM_RH_ACT_2    (TPM_RH_ACT_0 + 2)
+#endif
+#ifndef TPM_RH_ACT_3
+#   define TPM_RH_ACT_3    (TPM_RH_ACT_0 + 3)
+#endif
+#ifndef TPM_RH_ACT_4
+#   define TPM_RH_ACT_4    (TPM_RH_ACT_0 + 4)
+#endif
+#ifndef TPM_RH_ACT_5
+#   define TPM_RH_ACT_5    (TPM_RH_ACT_0 + 5)
+#endif
+#ifndef TPM_RH_ACT_6
+#   define TPM_RH_ACT_6    (TPM_RH_ACT_0 + 6)
+#endif
+#ifndef TPM_RH_ACT_7
+#   define TPM_RH_ACT_7    (TPM_RH_ACT_0 + 7)
+#endif
+#ifndef TPM_RH_ACT_8
+#   define TPM_RH_ACT_8    (TPM_RH_ACT_0 + 8)
+#endif
+#ifndef TPM_RH_ACT_9
+#   define TPM_RH_ACT_9    (TPM_RH_ACT_0 + 9)
+#endif
+#ifndef TPM_RH_ACT_A
+#   define TPM_RH_ACT_A    (TPM_RH_ACT_0 + 0xA)
+#endif
+#ifndef TPM_RH_ACT_B
+#   define TPM_RH_ACT_B    (TPM_RH_ACT_0 + 0xB)
+#endif
+#ifndef TPM_RH_ACT_C
+#   define TPM_RH_ACT_C    (TPM_RH_ACT_0 + 0xC)
+#endif
+#ifndef TPM_RH_ACT_D
+#   define TPM_RH_ACT_D    (TPM_RH_ACT_0 + 0xD)
+#endif
+#ifndef TPM_RH_ACT_E
+#   define TPM_RH_ACT_E    (TPM_RH_ACT_0 + 0xE)
+#endif
+#ifndef TPM_RH_ACT_F
+#   define TPM_RH_ACT_F    (TPM_RH_ACT_0 + 0xF)
+#endif
+#define FOR_EACH_ACT(op)                                               \
+    IF_ACT_0_IMPLEMENTED(op)                                           \
+    IF_ACT_1_IMPLEMENTED(op)                                           \
+    IF_ACT_2_IMPLEMENTED(op)                                           \
+    IF_ACT_3_IMPLEMENTED(op)                                           \
+    IF_ACT_4_IMPLEMENTED(op)                                           \
+    IF_ACT_5_IMPLEMENTED(op)                                           \
+    IF_ACT_6_IMPLEMENTED(op)                                           \
+    IF_ACT_7_IMPLEMENTED(op)                                           \
+    IF_ACT_8_IMPLEMENTED(op)                                           \
+    IF_ACT_9_IMPLEMENTED(op)                                           \
+    IF_ACT_A_IMPLEMENTED(op)                                           \
+    IF_ACT_B_IMPLEMENTED(op)                                           \
+    IF_ACT_C_IMPLEMENTED(op)                                           \
+    IF_ACT_D_IMPLEMENTED(op)                                           \
+    IF_ACT_E_IMPLEMENTED(op)                                           \
+    IF_ACT_F_IMPLEMENTED(op)
+
+// This is the mask for ACT that are implemented
+
+//#define ACT_MASK(N)     | (1 << 0x##N)
+//#define ACT_IMPLEMENTED_MASK    (0 FOR_EACH_ACT(ACT_MASK))
+#define CASE_ACT_HANDLE(N)     case TPM_RH_ACT_##N:
+#define CASE_ACT_NUMBER(N)     case 0x##N:
+typedef struct ACT_STATE
+{
+    UINT32          remaining;
+    TPM_ALG_ID      hashAlg;
+    TPM2B_DIGEST    authPolicy;
+} ACT_STATE, *P_ACT_STATE;
+#endif // _ACT_H_
diff --git a/src/tpm2/ACTCommands.c b/src/tpm2/ACTCommands.c
new file mode 100644 (file)
index 0000000..7a66db7
--- /dev/null
@@ -0,0 +1,81 @@
+/********************************************************************************/
+/*                                                                             */
+/*             Authenticated COuntdown Timer Commands                          */
+/*                          Written by Ken Goldman                             */
+/*                    IBM Thomas J. Watson Research Center                     */
+/*            $Id$             */
+/*                                                                             */
+/*  Licenses and Notices                                                       */
+/*                                                                             */
+/*  1. Copyright Licenses:                                                     */
+/*                                                                             */
+/*  - Trusted Computing Group (TCG) grants to the user of the source code in   */
+/*    this specification (the "Source Code") a worldwide, irrevocable,                 */
+/*    nonexclusive, royalty free, copyright license to reproduce, create       */
+/*    derivative works, distribute, display and perform the Source Code and    */
+/*    derivative works thereof, and to grant others the rights granted herein. */
+/*                                                                             */
+/*  - The TCG grants to the user of the other parts of the specification       */
+/*    (other than the Source Code) the rights to reproduce, distribute,        */
+/*    display, and perform the specification solely for the purpose of                 */
+/*    developing products based on such documents.                             */
+/*                                                                             */
+/*  2. Source Code Distribution Conditions:                                    */
+/*                                                                             */
+/*  - Redistributions of Source Code must retain the above copyright licenses,         */
+/*    this list of conditions and the following disclaimers.                   */
+/*                                                                             */
+/*  - Redistributions in binary form must reproduce the above copyright        */
+/*    licenses, this list of conditions        and the following disclaimers in the    */
+/*    documentation and/or other materials provided with the distribution.     */
+/*                                                                             */
+/*  3. Disclaimers:                                                            */
+/*                                                                             */
+/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF      */
+/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH      */
+/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)      */
+/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.                */
+/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for           */
+/*  information on specification licensing rights available through TCG        */
+/*  membership agreements.                                                     */
+/*                                                                             */
+/*  - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED        */
+/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR      */
+/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR             */
+/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY                 */
+/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.          */
+/*                                                                             */
+/*  - Without limitation, TCG and its members and licensors disclaim all       */
+/*    liability, including liability for infringement of any proprietary       */
+/*    rights, relating to use of information in this specification and to the  */
+/*    implementation of this specification, and TCG disclaims all liability for        */
+/*    cost of procurement of substitute goods or services, lost profits, loss  */
+/*    of use, loss of data or any incidental, consequential, direct, indirect,         */
+/*    or special damages, whether under contract, tort, warranty or otherwise,         */
+/*    arising in any way out of use or reliance upon this specification or any         */
+/*    information herein.                                                      */
+/*                                                                             */
+/*  (c) Copyright IBM Corp. and others, 2019                                   */
+/*                                                                             */
+/********************************************************************************/
+
+#include "Tpm.h"
+#include "ACT_SetTimeout_fp.h"
+#if CC_ACT_SetTimeout  // Conditional expansion of this file
+
+/* Error Returns       Meaning */
+/* TPM_RC_RETRY        returned when an update for the selected ACT is already pending */
+/* TPM_RC_VALUE        attempt to disable signaling from an ACT that has not expired */
+TPM_RC
+TPM2_ACT_SetTimeout(
+                   ACT_SetTimeout_In      *in             // IN: input parameter list
+                   )
+{
+    // If 'startTimeout' is UINT32_MAX, then this is an attempt to disable the ACT
+    // and turn off the signaling for the ACT. This is only valid if the ACT
+    // is signaling.
+    if((in->startTimeout == UINT32_MAX) && !ActGetSignaled(in->actHandle))
+       return TPM_RC_VALUE + RC_ACT_SetTimeout_startTimeout;
+    return ActCounterUpdate(in->actHandle, in->startTimeout);
+}
+#endif // CC_ACT_SetTimeout
diff --git a/src/tpm2/ACT_SetTimeout_fp.h b/src/tpm2/ACT_SetTimeout_fp.h
new file mode 100644 (file)
index 0000000..8137538
--- /dev/null
@@ -0,0 +1,79 @@
+/********************************************************************************/\r
+/*                                                                             */\r
+/*                     TPM2_ACT_SetTimeout Header                              */\r
+/*                          Written by Ken Goldman                             */\r
+/*                    IBM Thomas J. Watson Research Center                     */\r
+/*            $Id$     */\r
+/*                                                                             */\r
+/*  Licenses and Notices                                                       */\r
+/*                                                                             */\r
+/*  1. Copyright Licenses:                                                     */\r
+/*                                                                             */\r
+/*  - Trusted Computing Group (TCG) grants to the user of the source code in   */\r
+/*    this specification (the "Source Code") a worldwide, irrevocable,                 */\r
+/*    nonexclusive, royalty free, copyright license to reproduce, create       */\r
+/*    derivative works, distribute, display and perform the Source Code and    */\r
+/*    derivative works thereof, and to grant others the rights granted herein. */\r
+/*                                                                             */\r
+/*  - The TCG grants to the user of the other parts of the specification       */\r
+/*    (other than the Source Code) the rights to reproduce, distribute,        */\r
+/*    display, and perform the specification solely for the purpose of                 */\r
+/*    developing products based on such documents.                             */\r
+/*                                                                             */\r
+/*  2. Source Code Distribution Conditions:                                    */\r
+/*                                                                             */\r
+/*  - Redistributions of Source Code must retain the above copyright licenses,         */\r
+/*    this list of conditions and the following disclaimers.                   */\r
+/*                                                                             */\r
+/*  - Redistributions in binary form must reproduce the above copyright        */\r
+/*    licenses, this list of conditions        and the following disclaimers in the    */\r
+/*    documentation and/or other materials provided with the distribution.     */\r
+/*                                                                             */\r
+/*  3. Disclaimers:                                                            */\r
+/*                                                                             */\r
+/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF      */\r
+/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH      */\r
+/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)      */\r
+/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.                */\r
+/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for           */\r
+/*  information on specification licensing rights available through TCG        */\r
+/*  membership agreements.                                                     */\r
+/*                                                                             */\r
+/*  - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED        */\r
+/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR      */\r
+/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR             */\r
+/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY                 */\r
+/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.          */\r
+/*                                                                             */\r
+/*  - Without limitation, TCG and its members and licensors disclaim all       */\r
+/*    liability, including liability for infringement of any proprietary       */\r
+/*    rights, relating to use of information in this specification and to the  */\r
+/*    implementation of this specification, and TCG disclaims all liability for        */\r
+/*    cost of procurement of substitute goods or services, lost profits, loss  */\r
+/*    of use, loss of data or any incidental, consequential, direct, indirect,         */\r
+/*    or special damages, whether under contract, tort, warranty or otherwise,         */\r
+/*    arising in any way out of use or reliance upon this specification or any         */\r
+/*    information herein.                                                      */\r
+/*                                                                             */\r
+/*  (c) Copyright IBM Corp. and others, 2019                                   */\r
+/*                                                                             */\r
+/********************************************************************************/\r
+\r
+#ifndef ACT_SETTIMEOUT_FP_H\r
+#define ACT_SETTIMEOUT_FP_H\r
+\r
+typedef struct {\r
+    TPMI_RH_ACT                actHandle;\r
+    UINT32             startTimeout;\r
+} ACT_SetTimeout_In;\r
+\r
+#define RC_ACT_SetTimeout_actHandle    (TPM_RC_H + TPM_RC_1)\r
+#define RC_ACT_SetTimeout_startTimeout         (TPM_RC_H + TPM_RC_2)\r
+\r
+TPM_RC\r
+TPM2_ACT_SetTimeout(\r
+                   ACT_SetTimeout_In      *in             // IN: input parameter list\r
+                   );\r
+\r
+\r
+#endif\r
diff --git a/src/tpm2/ACT_spt_fp.h b/src/tpm2/ACT_spt_fp.h
new file mode 100644 (file)
index 0000000..380e9fb
--- /dev/null
@@ -0,0 +1,95 @@
+/********************************************************************************/
+/*                                                                             */
+/*                      ACT Command Support                                    */
+/*                          Written by Ken Goldman                             */
+/*                    IBM Thomas J. Watson Research Center                     */
+/*            $Id$             */
+/*                                                                             */
+/*  Licenses and Notices                                                       */
+/*                                                                             */
+/*  1. Copyright Licenses:                                                     */
+/*                                                                             */
+/*  - Trusted Computing Group (TCG) grants to the user of the source code in   */
+/*    this specification (the "Source Code") a worldwide, irrevocable,                 */
+/*    nonexclusive, royalty free, copyright license to reproduce, create       */
+/*    derivative works, distribute, display and perform the Source Code and    */
+/*    derivative works thereof, and to grant others the rights granted herein. */
+/*                                                                             */
+/*  - The TCG grants to the user of the other parts of the specification       */
+/*    (other than the Source Code) the rights to reproduce, distribute,        */
+/*    display, and perform the specification solely for the purpose of                 */
+/*    developing products based on such documents.                             */
+/*                                                                             */
+/*  2. Source Code Distribution Conditions:                                    */
+/*                                                                             */
+/*  - Redistributions of Source Code must retain the above copyright licenses,         */
+/*    this list of conditions and the following disclaimers.                   */
+/*                                                                             */
+/*  - Redistributions in binary form must reproduce the above copyright        */
+/*    licenses, this list of conditions        and the following disclaimers in the    */
+/*    documentation and/or other materials provided with the distribution.     */
+/*                                                                             */
+/*  3. Disclaimers:                                                            */
+/*                                                                             */
+/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF      */
+/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH      */
+/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)      */
+/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.                */
+/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for           */
+/*  information on specification licensing rights available through TCG        */
+/*  membership agreements.                                                     */
+/*                                                                             */
+/*  - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED        */
+/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR      */
+/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR             */
+/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY                 */
+/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.          */
+/*                                                                             */
+/*  - Without limitation, TCG and its members and licensors disclaim all       */
+/*    liability, including liability for infringement of any proprietary       */
+/*    rights, relating to use of information in this specification and to the  */
+/*    implementation of this specification, and TCG disclaims all liability for        */
+/*    cost of procurement of substitute goods or services, lost profits, loss  */
+/*    of use, loss of data or any incidental, consequential, direct, indirect,         */
+/*    or special damages, whether under contract, tort, warranty or otherwise,         */
+/*    arising in any way out of use or reliance upon this specification or any         */
+/*    information herein.                                                      */
+/*                                                                             */
+/*  (c) Copyright IBM Corp. and others, 2019                                   */
+/*                                                                             */
+/********************************************************************************/
+
+#ifndef ACT_SPT_FP_H
+#define ACT_SPT_FP_H
+
+BOOL
+ActStartup(
+          STARTUP_TYPE        type
+          );
+BOOL
+ActGetSignaled(
+              TPM_RH              actHandle
+              );
+BOOL
+ActShutdown(
+           TPM_SU              state       //IN: the type of the shutdown.
+           );
+BOOL
+ActIsImplemented(
+                UINT32          act
+                );
+TPM_RC
+ActCounterUpdate(
+                TPM_RH          handle,         //IN: the handle of the act
+                UINT32          newValue        //IN: the value to set in the ACT
+                );
+TPMI_YES_NO
+ActGetCapabilityData(
+                    TPM_HANDLE       actHandle,     // IN: the handle for the starting ACT
+                    UINT32           maxCount,      // IN: maximum allowed return values
+                    TPML_ACT_DATA   *actList        // OUT: ACT data list
+                    );
+
+
+
+#endif
index 82ca5001776f4f17e89cec4dda3d067d4cc67c00..832187fe291f4f4d56e4e9915dfb213c4cf67f98 100644 (file)
@@ -3,7 +3,7 @@
 /*     Number of capability values that will fit into the largest data buffer  */
 /*                          Written by Ken Goldman                             */
 /*                    IBM Thomas J. Watson Research Center                     */
-/*            $Id: Capabilities.h 1490 2019-07-26 21:13:22Z kgoldman $         */
+/*            $Id: Capabilities.h 1519 2019-11-15 20:43:51Z 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, 2017                             */
+/*  (c) Copyright IBM Corp. and others, 2016 - 2019                            */
 /*                                                                             */
 /********************************************************************************/
 
@@ -70,6 +70,7 @@
 #define    MAX_PCR_PROPERTIES   (MAX_CAP_DATA / sizeof(TPMS_TAGGED_PCR_SELECT))
 #define    MAX_ECC_CURVES       (MAX_CAP_DATA / sizeof(TPM_ECC_CURVE))
 #define    MAX_TAGGED_POLICIES  (MAX_CAP_DATA / sizeof(TPMS_TAGGED_POLICY))
+#define    MAX_ACT_DATA                (MAX_CAP_DATA / sizeof(TPMS_ACT_DATA))
 #define    MAX_AC_CAPABILITIES  (MAX_CAP_DATA / sizeof(TPMS_AC_OUTPUT))
 
 #endif
index 74ec635a4b684792ded99dd981f86482124718a2..c911cd195f91968722feba96a62fb671303914dc 100644 (file)
@@ -3,7 +3,7 @@
 /*             Command code attribute array for GetCapability                  */
 /*                          Written by Ken Goldman                             */
 /*                    IBM Thomas J. Watson Research Center                     */
-/*            $Id: CommandAttributeData.h 1477 2019-06-10 19:45:40Z kgoldman $ */
+/*            $Id: CommandAttributeData.h 1519 2019-11-15 20:43:51Z 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 - 2018                            */
+/*  (c) Copyright IBM Corp. and others, 2016 - 2019                            */
 /*                                                                             */
 /********************************************************************************/
 
@@ -437,6 +437,9 @@ const TPMA_CC    s_ccAttr [] = {
 #if (PAD_LIST || CC_CertifyX509)
     TPMA_CC_INITIALIZER(0x0197, 0, 0, 0, 0, 2, 0, 0, 0),
 #endif
+#if (PAD_LIST || CC_ACT_SetTimeout)
+    TPMA_CC_INITIALIZER(0x0198, 0, 0, 0, 0, 1, 0, 0, 0),
+#endif
 #if (PAD_LIST  || CC_Vendor_TCG_Test)
     TPMA_CC_INITIALIZER(0x0000, 0, 0, 0, 0, 0, 0, 1, 0),
 #endif
@@ -926,6 +929,10 @@ const COMMAND_ATTRIBUTES    s_commandAttributes [] = {
     (COMMAND_ATTRIBUTES)(CC_CertifyX509                 *  // 0x0197
                         (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_ADMIN+HANDLE_2_USER+ENCRYPT_2)),
 #endif
+#if (PAD_LIST || CC_ACT_SetTimeout)
+    (COMMAND_ATTRIBUTES)(CC_ACT_SetTimeout              *  // 0x0198
+                        (IS_IMPLEMENTED+HANDLE_1_USER)),
+#endif
 #if (PAD_LIST  || CC_Vendor_TCG_Test)
     (COMMAND_ATTRIBUTES)(CC_Vendor_TCG_Test             *  // 0x0000
                         (IS_IMPLEMENTED+DECRYPT_2+ENCRYPT_2)),
index 73864810f05c0f71deb6a06bb58ca9fc704e438b..476d19476b44149510566eabda3f1c5e3828dd5e 100644 (file)
@@ -87,7 +87,9 @@ _NORMAL_WARNING_LEVEL_
 #include "CryptTest.h"
 #include "TpmError.h"
 #include "NV.h"
+#include "ACT.h"
 #include "Utils.h"                 // libtpms added
+
 //** Defines and Types
     
 //*** Size Types
@@ -1313,6 +1315,17 @@ EXTERN UINT32    s_failCode;            // the error code used
 EXTERN FailFunction    *LibFailCallback;
 #endif // TPM_FAIL_C
 
+//*****************************************************************************
+//*** From ACT_spt.c
+//*****************************************************************************
+// This value is used to indicate if an ACT has been updated since the last
+// TPM2_Startup() (one bit for each ACT). If the ACT is not updated
+// (TPM2_ACT_SetTimeout()) after a startup, then on each TPM2_Shutdown() the TPM will
+// save 1/2 of the current timer value. This prevents an attack on the ACT by saving
+// the counter and then running for a long period of time before doing a TPM Restart.
+// A quick TPM2_Shutdown() after each
+EXTERN UINT16                       s_ActUpdated;
+
 /* 5.9.16.9    From CommandCodeAttributes.c */
 
 extern  const  TPMA_CC               s_ccAttr[];
index 8515fd80d1968db20a6a6ce4df694b8131fc0157..a26eb8f64e253796f13442eec6bac69d1c10b0f5 100644 (file)
@@ -3,7 +3,7 @@
 /*                     Include Headers for Internal Routines                   */
 /*                          Written by Ken Goldman                             */
 /*                    IBM Thomas J. Watson Research Center                     */
-/*            $Id: InternalRoutines.h 1490 2019-07-26 21:13:22Z kgoldman $     */
+/*            $Id: InternalRoutines.h 1519 2019-11-15 20:43:51Z 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 - 2018                            */
+/*  (c) Copyright IBM Corp. and others, 2016 - 2019                            */
 /*                                                                             */
 /********************************************************************************/
 
@@ -79,6 +79,7 @@
 #include "NVReserved_fp.h"
 #include "NVDynamic_fp.h"
 #include "NV_spt_fp.h"
+#include "ACT_spt_fp.h"
 #include "PCR_fp.h"
 #include "DA_fp.h"
 #include "TpmFail_fp.h"
index 28406c7e2f13a048de5327d9ef0e369954896275..956f3ca1e9b21e6cf7d8d6e049f4d9699e898bd4 100644 (file)
@@ -3,7 +3,7 @@
 /*                       Parameter Marshaling                                  */
 /*                          Written by Ken Goldman                             */
 /*                    IBM Thomas J. Watson Research Center                     */
-/*            $Id: Marshal.c 1490 2019-07-26 21:13:22Z kgoldman $              */
+/*            $Id: Marshal.c 1519 2019-11-15 20:43:51Z 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 - 2018                            */
+/*  (c) Copyright IBM Corp. and others, 2016 - 2019                            */
 /*                                                                             */
 /********************************************************************************/
 
@@ -2233,3 +2233,40 @@ TPM2B_CREATION_DATA_Marshal(TPM2B_CREATION_DATA *source, BYTE **buffer, INT32 *s
     return written;
 }
 
+/* Table 225 - Definition of (UINT32) TPM_AT Constants */
+
+UINT16
+TPM_AT_Marshal(TPM_AT *source, BYTE **buffer, INT32 *size)
+{
+    UINT16 written = 0;
+    written += UINT32_Marshal(source, buffer, size);
+    return written;
+}
+
+/* Table 227 - Definition of TPMS_AC_OUTPUT Structure <OUT> */
+
+UINT16
+TPMS_AC_OUTPUT_Marshal(TPMS_AC_OUTPUT *source, BYTE **buffer, INT32 *size)
+{
+    UINT16 written = 0;
+
+    written += TPM_AT_Marshal(&source->tag, buffer, size);
+    written += UINT32_Marshal(&source->data, buffer, size);
+    return written;
+}
+
+/* Table 228 - Definition of TPML_AC_CAPABILITIES Structure <OUT> */
+
+UINT16
+TPML_AC_CAPABILITIES_Marshal(TPML_AC_CAPABILITIES *source, BYTE **buffer, INT32 *size)
+{
+    UINT16 written = 0;
+    UINT32 i;
+    
+    written += UINT32_Marshal(&source->count, buffer, size);
+    for (i = 0 ; i < source->count ; i++) {
+       written += TPMS_AC_OUTPUT_Marshal(&source->acCapabilities[i], buffer, size);
+    }
+    return written;
+}
+
index 08f3d4767981c4dec909866e1bad7839eb35c77b..f89651775cbef84839f03e90b2b811bce33844a9 100644 (file)
@@ -3,7 +3,7 @@
 /*                        Parameter Marshaling                                 */
 /*                          Written by Ken Goldman                             */
 /*                    IBM Thomas J. Watson Research Center                     */
-/*            $Id: Marshal_fp.h 1490 2019-07-26 21:13:22Z kgoldman $           */
+/*            $Id: Marshal_fp.h 1519 2019-11-15 20:43:51Z 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 - 2018                            */
+/*  (c) Copyright IBM Corp. and others, 2016 - 2019                            */
 /*                                                                             */
 /********************************************************************************/
 
@@ -378,6 +378,12 @@ extern "C" {
     TPMS_CREATION_DATA_Marshal(TPMS_CREATION_DATA *source, BYTE **buffer, INT32 *size);
     UINT16
     TPM2B_CREATION_DATA_Marshal(TPM2B_CREATION_DATA *source, BYTE **buffer, INT32 *size);
+    UINT16
+    TPM_AT_Marshal(TPM_AT *source, BYTE **buffer, INT32 *size);
+    UINT16
+    TPMS_AC_OUTPUT_Marshal(TPMS_AC_OUTPUT *source, BYTE **buffer, INT32 *size);
+    UINT16
+    TPML_AC_CAPABILITIES_Marshal(TPML_AC_CAPABILITIES *source, BYTE **buffer, INT32 *size);
 
 #ifdef __cplusplus
 }
index 3298992bf649ed3cc4cb1caae870620fd545af4e..126d0fed242a5f8ae8f1d4785d8e1b18dddb82b7 100644 (file)
@@ -3,7 +3,7 @@
 /*                                             */
 /*                          Written by Ken Goldman                             */
 /*                    IBM Thomas J. Watson Research Center                     */
-/*            $Id: Platform.h 1490 2019-07-26 21:13:22Z kgoldman $             */
+/*            $Id: Platform.h 1521 2019-11-15 21:00:47Z kgoldman $             */
 /*                                                                             */
 /*  Licenses and Notices                                                       */
 /*                                                                             */
@@ -68,6 +68,7 @@
 #include "TPMB.h"
 #include "MinMax.h"
 #include "TpmProfile.h"
+#include "PlatformACT.h"
 #include "PlatformClock.h"
 #include "PlatformData.h"
 #include "Platform_fp.h"
diff --git a/src/tpm2/PlatformACT.h b/src/tpm2/PlatformACT.h
new file mode 100644 (file)
index 0000000..e57b445
--- /dev/null
@@ -0,0 +1,210 @@
+/********************************************************************************/
+/*                                                                             */
+/*                     Platform Authenticated Countdown Timer                  */
+/*                          Written by Ken Goldman                             */
+/*                    IBM Thomas J. Watson Research Center                     */
+/*            $Id: PlatformACT.h 1531 2019-11-21 23:54:38Z kgoldman $          */
+/*                                                                             */
+/*  Licenses and Notices                                                       */
+/*                                                                             */
+/*  1. Copyright Licenses:                                                     */
+/*                                                                             */
+/*  - Trusted Computing Group (TCG) grants to the user of the source code in   */
+/*    this specification (the "Source Code") a worldwide, irrevocable,                 */
+/*    nonexclusive, royalty free, copyright license to reproduce, create       */
+/*    derivative works, distribute, display and perform the Source Code and    */
+/*    derivative works thereof, and to grant others the rights granted herein. */
+/*                                                                             */
+/*  - The TCG grants to the user of the other parts of the specification       */
+/*    (other than the Source Code) the rights to reproduce, distribute,        */
+/*    display, and perform the specification solely for the purpose of                 */
+/*    developing products based on such documents.                             */
+/*                                                                             */
+/*  2. Source Code Distribution Conditions:                                    */
+/*                                                                             */
+/*  - Redistributions of Source Code must retain the above copyright licenses,         */
+/*    this list of conditions and the following disclaimers.                   */
+/*                                                                             */
+/*  - Redistributions in binary form must reproduce the above copyright        */
+/*    licenses, this list of conditions        and the following disclaimers in the    */
+/*    documentation and/or other materials provided with the distribution.     */
+/*                                                                             */
+/*  3. Disclaimers:                                                            */
+/*                                                                             */
+/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF      */
+/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH      */
+/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)      */
+/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.                */
+/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for           */
+/*  information on specification licensing rights available through TCG        */
+/*  membership agreements.                                                     */
+/*                                                                             */
+/*  - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED        */
+/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR      */
+/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR             */
+/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY                 */
+/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.          */
+/*                                                                             */
+/*  - Without limitation, TCG and its members and licensors disclaim all       */
+/*    liability, including liability for infringement of any proprietary       */
+/*    rights, relating to use of information in this specification and to the  */
+/*    implementation of this specification, and TCG disclaims all liability for        */
+/*    cost of procurement of substitute goods or services, lost profits, loss  */
+/*    of use, loss of data or any incidental, consequential, direct, indirect,         */
+/*    or special damages, whether under contract, tort, warranty or otherwise,         */
+/*    arising in any way out of use or reliance upon this specification or any         */
+/*    information herein.                                                      */
+/*                                                                             */
+/*  (c) Copyright IBM Corp. and others, 2019.                                  */
+/*                                                                             */
+/********************************************************************************/
+
+/* C.15        PlatformACT.h */
+
+// This file contains the definitions for the ACT macros and data types used in the ACT
+// implementation.
+
+#ifndef PLATFORMACT_H
+#define PLATFORMACT_H
+
+typedef struct ACT_DATA
+{
+    uint32_t            remaining;
+    uint32_t            newValue;
+    uint8_t             signaled;
+    uint8_t             pending;
+    uint8_t             number;
+} ACT_DATA, *P_ACT_DATA;
+
+#if !(defined RH_ACT_0) || (RH_ACT_0 != YES)
+#   undef   RH_ACT_0
+#   define  RH_ACT_0 NO 
+#   define IF_ACT_0_IMPLEMENTED(op)
+#else
+#   define IF_ACT_0_IMPLEMENTED(op) op(0)
+#endif 
+#if !(defined RH_ACT_1) || (RH_ACT_1 != YES)
+#   undef   RH_ACT_1
+#   define  RH_ACT_1 NO 
+#   define IF_ACT_1_IMPLEMENTED(op)
+#else
+#   define IF_ACT_1_IMPLEMENTED(op) op(1)
+#endif 
+#if !(defined RH_ACT_2) || (RH_ACT_2 != YES)
+#   undef   RH_ACT_2
+#   define  RH_ACT_2 NO 
+#   define IF_ACT_2_IMPLEMENTED(op)
+#else
+#   define IF_ACT_2_IMPLEMENTED(op) op(2)
+#endif 
+#if !(defined RH_ACT_3) || (RH_ACT_3 != YES)
+#   undef   RH_ACT_3
+#   define  RH_ACT_3 NO 
+#   define IF_ACT_3_IMPLEMENTED(op)
+#else
+#   define IF_ACT_3_IMPLEMENTED(op) op(3)
+#endif 
+#if !(defined RH_ACT_4) || (RH_ACT_4 != YES)
+#   undef   RH_ACT_4
+#   define  RH_ACT_4 NO 
+#   define IF_ACT_4_IMPLEMENTED(op)
+#else
+#   define IF_ACT_4_IMPLEMENTED(op) op(4)
+#endif 
+#if !(defined RH_ACT_5) || (RH_ACT_5 != YES)
+#   undef   RH_ACT_5
+#   define  RH_ACT_5 NO 
+#   define IF_ACT_5_IMPLEMENTED(op)
+#else
+#   define IF_ACT_5_IMPLEMENTED(op) op(5)
+#endif 
+#if !(defined RH_ACT_6) || (RH_ACT_6 != YES)
+#   undef   RH_ACT_6
+#   define  RH_ACT_6 NO 
+#   define IF_ACT_6_IMPLEMENTED(op)
+#else
+#   define IF_ACT_6_IMPLEMENTED(op) op(6)
+#endif 
+#if !(defined RH_ACT_7) || (RH_ACT_7 != YES)
+#   undef   RH_ACT_7
+#   define  RH_ACT_7 NO 
+#   define IF_ACT_7_IMPLEMENTED(op)
+#else
+#   define IF_ACT_7_IMPLEMENTED(op) op(7)
+#endif 
+#if !(defined RH_ACT_8) || (RH_ACT_8 != YES)
+#   undef   RH_ACT_8
+#   define  RH_ACT_8 NO 
+#   define IF_ACT_8_IMPLEMENTED(op)
+#else
+#   define IF_ACT_8_IMPLEMENTED(op) op(8)
+#endif 
+#if !(defined RH_ACT_9) || (RH_ACT_9 != YES)
+#   undef   RH_ACT_9
+#   define  RH_ACT_9 NO 
+#   define IF_ACT_9_IMPLEMENTED(op)
+#else
+#   define IF_ACT_9_IMPLEMENTED(op) op(9)
+#endif 
+#if !(defined RH_ACT_A) || (RH_ACT_A != YES)
+#   undef   RH_ACT_A
+#   define  RH_ACT_A NO 
+#   define IF_ACT_A_IMPLEMENTED(op)
+#else
+#   define IF_ACT_A_IMPLEMENTED(op) op(A)
+#endif 
+#if !(defined RH_ACT_B) || (RH_ACT_B != YES)
+#   undef   RH_ACT_B
+#   define  RH_ACT_B NO 
+#   define IF_ACT_B_IMPLEMENTED(op)
+#else
+#   define IF_ACT_B_IMPLEMENTED(op) op(B)
+#endif 
+#if !(defined RH_ACT_C) || (RH_ACT_C != YES)
+#   undef   RH_ACT_C
+#   define  RH_ACT_C NO 
+#   define IF_ACT_C_IMPLEMENTED(op)
+#else
+#   define IF_ACT_C_IMPLEMENTED(op) op(C)
+#endif 
+#if !(defined RH_ACT_D) || (RH_ACT_D != YES)
+#   undef   RH_ACT_D
+#   define  RH_ACT_D NO 
+#   define IF_ACT_D_IMPLEMENTED(op)
+#else
+#   define IF_ACT_D_IMPLEMENTED(op) op(D)
+#endif 
+#if !(defined RH_ACT_E) || (RH_ACT_E != YES)
+#   undef   RH_ACT_E
+#   define  RH_ACT_E NO 
+#   define IF_ACT_E_IMPLEMENTED(op)
+#else
+#   define IF_ACT_E_IMPLEMENTED(op) op(E)
+#endif 
+#if !(defined RH_ACT_F) || (RH_ACT_F != YES)
+#   undef   RH_ACT_F
+#   define  RH_ACT_F NO 
+#   define IF_ACT_F_IMPLEMENTED(op)
+#else
+#   define IF_ACT_F_IMPLEMENTED(op) op(F)
+#endif
+
+#define FOR_EACH_ACT(op)                       \
+    IF_ACT_0_IMPLEMENTED(op)                   \
+    IF_ACT_1_IMPLEMENTED(op)                   \
+    IF_ACT_2_IMPLEMENTED(op)                   \
+    IF_ACT_3_IMPLEMENTED(op)                   \
+    IF_ACT_4_IMPLEMENTED(op)                   \
+    IF_ACT_5_IMPLEMENTED(op)                   \
+    IF_ACT_6_IMPLEMENTED(op)                   \
+    IF_ACT_7_IMPLEMENTED(op)                   \
+    IF_ACT_8_IMPLEMENTED(op)                   \
+    IF_ACT_9_IMPLEMENTED(op)                   \
+    IF_ACT_A_IMPLEMENTED(op)                   \
+    IF_ACT_B_IMPLEMENTED(op)                   \
+    IF_ACT_C_IMPLEMENTED(op)                   \
+    IF_ACT_D_IMPLEMENTED(op)                   \
+    IF_ACT_E_IMPLEMENTED(op)                   \
+    IF_ACT_F_IMPLEMENTED(op)
+
+#endif // _PLATFORM_ACT_H_
diff --git a/src/tpm2/PlatformACT_fp.h b/src/tpm2/PlatformACT_fp.h
new file mode 100644 (file)
index 0000000..5d2caf5
--- /dev/null
@@ -0,0 +1,104 @@
+/********************************************************************************/
+/*                                                                             */
+/*                     Platform Authenticated Countdown Timer                  */
+/*                          Written by Ken Goldman                             */
+/*                    IBM Thomas J. Watson Research Center                     */
+/*            $Id: PlatformACT_fp.h 1531 2019-11-21 23:54:38Z kgoldman $       */
+/*                                                                             */
+/*  Licenses and Notices                                                       */
+/*                                                                             */
+/*  1. Copyright Licenses:                                                     */
+/*                                                                             */
+/*  - Trusted Computing Group (TCG) grants to the user of the source code in   */
+/*    this specification (the "Source Code") a worldwide, irrevocable,                 */
+/*    nonexclusive, royalty free, copyright license to reproduce, create       */
+/*    derivative works, distribute, display and perform the Source Code and    */
+/*    derivative works thereof, and to grant others the rights granted herein. */
+/*                                                                             */
+/*  - The TCG grants to the user of the other parts of the specification       */
+/*    (other than the Source Code) the rights to reproduce, distribute,        */
+/*    display, and perform the specification solely for the purpose of                 */
+/*    developing products based on such documents.                             */
+/*                                                                             */
+/*  2. Source Code Distribution Conditions:                                    */
+/*                                                                             */
+/*  - Redistributions of Source Code must retain the above copyright licenses,         */
+/*    this list of conditions and the following disclaimers.                   */
+/*                                                                             */
+/*  - Redistributions in binary form must reproduce the above copyright        */
+/*    licenses, this list of conditions        and the following disclaimers in the    */
+/*    documentation and/or other materials provided with the distribution.     */
+/*                                                                             */
+/*  3. Disclaimers:                                                            */
+/*                                                                             */
+/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF      */
+/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH      */
+/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)      */
+/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.                */
+/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for           */
+/*  information on specification licensing rights available through TCG        */
+/*  membership agreements.                                                     */
+/*                                                                             */
+/*  - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED        */
+/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR      */
+/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR             */
+/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY                 */
+/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.          */
+/*                                                                             */
+/*  - Without limitation, TCG and its members and licensors disclaim all       */
+/*    liability, including liability for infringement of any proprietary       */
+/*    rights, relating to use of information in this specification and to the  */
+/*    implementation of this specification, and TCG disclaims all liability for        */
+/*    cost of procurement of substitute goods or services, lost profits, loss  */
+/*    of use, loss of data or any incidental, consequential, direct, indirect,         */
+/*    or special damages, whether under contract, tort, warranty or otherwise,         */
+/*    arising in any way out of use or reliance upon this specification or any         */
+/*    information herein.                                                      */
+/*                                                                             */
+/*  (c) Copyright IBM Corp. and others, 2019                                   */
+/*                                                                             */
+/********************************************************************************/
+
+#ifndef PLATFORMACT_FP_H
+#define PLATFORMACT_FP_H
+
+LIB_EXPORT int
+_plat__ACT_GetImplemented(
+                         uint32_t            act
+                         );
+LIB_EXPORT uint32_t
+_plat__ACT_GetRemaining(
+                       uint32_t            act             //IN: the ACT selector
+                       );
+LIB_EXPORT int
+_plat__ACT_GetSignaled(
+                      uint32_t            act         //IN: number of ACT to check
+                      );
+LIB_EXPORT void
+_plat__ACT_SetSignaled(
+                      uint32_t            act,
+                      int                 on
+                      );
+LIB_EXPORT int
+_plat__ACT_GetPending(
+                     uint32_t            act         //IN: number of ACT to check
+                     );
+LIB_EXPORT int
+_plat__ACT_UpdateCounter(
+                        uint32_t            act,        // IN: ACT to update
+                        uint32_t            newValue   // IN: the value to post
+                        );
+LIB_EXPORT void
+_plat__ACT_EnableTicks(
+                      int      enable
+                      );
+LIB_EXPORT void
+_plat__ACT_Tick(
+               void
+               );
+LIB_EXPORT int
+_plat__ACT_Initialize(
+                     void
+                     );
+
+#endif
index f378dece4ac3e0bd9e36d73fc50a5af1b79aa559..3555389bb1bbd6bcee14931ebce586156b2d1d55 100644 (file)
@@ -134,4 +134,9 @@ EXTERN BOOL     s_physicalPresence;
 EXTERN BOOL        s_powerLost;
 /* From Entropy.c */
 EXTERN uint32_t        lastEntropy;
+
+#define DEFINE_ACT(N)   EXTERN ACT_DATA ACT_##N;
+FOR_EACH_ACT(DEFINE_ACT)
+EXTERN int             actTicksAllowed;
+
 #endif // _PLATFORM_DATA_H_
index beaed2fb4730ae4064011cb0cd28bd3281a4970c..9923db06bdaea4ee992080b2e9372351004a42ff 100644 (file)
@@ -3,7 +3,7 @@
 /*                                                     */
 /*                          Written by Ken Goldman                             */
 /*                    IBM Thomas J. Watson Research Center                     */
-/*            $Id: Simulator_fp.h 1259 2018-07-10 19:11:09Z kgoldman $         */
+/*            $Id: Simulator_fp.h 1519 2019-11-15 20:43:51Z 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 - 2018                            */
+/*  (c) Copyright IBM Corp. and others, 2016 - 2019                            */
 /*                                                                             */
 /********************************************************************************/
 
@@ -186,6 +186,12 @@ void
 _rpc__RsaKeyCacheControl(
                         int              state
                         );
+/* D.4.2.15.   _rpc__ACT_GetSignaled() */
+BOOL
+_rpc__ACT_GetSignaled(
+                     UINT32 actHandle
+                     );
+
 /* D.2.3. From TPMCmds.c */
 /* D.2.3.1. main() */
 /* This is the main entry point for the simulator. */
index 581220fb15d4ddb61a3eb0fc37023f7c85b680f4..015a544dce592086fff790a5fd7bb2153f74ca00 100644 (file)
 #define MAX_TDES_BLOCK_SIZE_BYTES   TDES_MAX_BLOCK_SIZE
 // Additional values for benefit of code
 #define TPM_CC_FIRST                        0x0000011F
-#define TPM_CC_LAST                         0x00000197
+#define TPM_CC_LAST                         0x00000198
 #if COMPRESSED_LISTS
 #define ADD_FILL            0
 #else
                                          + (ADD_FILL || CC_AC_Send)                              /* 0x00000195 */ \
                                          + (ADD_FILL || CC_Policy_AC_SendSelect)                 /* 0x00000196 */ \
                                          + (ADD_FILL || CC_CertifyX509)                          /* 0x00000197 */ \
+                                         + (ADD_FILL || CC_ACT_SetTimeout)                       /* 0x00000198 */ \
                                          )
 
 #define VENDOR_COMMAND_ARRAY_SIZE   (0 + CC_Vendor_TCG_Test)
index 76bd369196daa0d08a91a93be0f6dc54070853db..5e0c969f221362c06dcefa08710414835f77fd16 100644 (file)
@@ -3,7 +3,7 @@
 /*     Constants Reflecting a Particular TPM Implementation (e.g. PC Client)   */
 /*                          Written by Ken Goldman                             */
 /*                    IBM Thomas J. Watson Research Center                     */
-/*            $Id: TpmProfile.h 1490 2019-07-26 21:13:22Z kgoldman $   */
+/*            $Id: TpmProfile.h 1529 2019-11-21 23:29:01Z kgoldman $           */
 /*                                                                             */
 /*  Licenses and Notices                                                       */
 /*                                                                             */
 #ifndef ECC_SM2_P256
 #define ECC_SM2_P256                    YES /* libtpms enabled */
 #endif
+
+/* Table 0:6 - Defines for Implemented ACT */
+
+#ifndef RH_ACT_0
+#define RH_ACT_0                        NO  /* libtpms: no */
+#endif
+#ifndef RH_ACT_1
+#define RH_ACT_1                        NO
+#endif
+#ifndef RH_ACT_A
+#define RH_ACT_A                        NO  /* libtpms: no */
+#endif
+
 // Table 0:7 - Defines for Implementation Values
 #ifndef FIELD_UPGRADE_IMPLEMENTED
 #define FIELD_UPGRADE_IMPLEMENTED       NO
 #define TDES_192                    (ALG_TDES && YES)
 #endif
 // Table 0:5 - Defines for Implemented Commands
+#ifndef CC_ACT_SetTimeout
+#define CC_ACT_SetTimeout                   CC_NO      /* libtpms: NO */
+#endif
 #ifndef CC_AC_GetCapability
 #define CC_AC_GetCapability                 CC_NO      /* kgold */
 #endif
index c9604d64df2acfc760704c5284fd7ec2a660a4ae..d244c0539da92c1017e3a949ae1599257daa5c87 100644 (file)
@@ -3,7 +3,7 @@
 /*                          TPM Size Checks                                    */
 /*                          Written by Ken Goldman                             */
 /*                    IBM Thomas J. Watson Research Center                     */
-/*            $Id: TpmSizeChecks.c 1519 2019-11-15 20:43:51Z kgoldman $                */
+/*            $Id: TpmSizeChecks.c 1529 2019-11-21 23:29:01Z kgoldman $                */
 /*                                                                             */
 /*  Licenses and Notices                                                       */
 /*                                                                             */
@@ -61,6 +61,7 @@
 
 //** Includes, Defines, and Types
 #include    "Tpm.h"
+#include    "PlatformACT_fp.h"         /* kgold */
 #include    "TpmSizeChecks_fp.h"
 #include    <stdio.h>
 #include    <assert.h>
index 0ca7ffb51d4157808a18d9a413121bc1045e43e0..2869c9a8004eea068dcff6770e9538b357f8f377 100644 (file)
@@ -3,7 +3,7 @@
 /*     TPM commands are communicated as BYTE streams on a TCP connection       */
 /*                          Written by Ken Goldman                             */
 /*                    IBM Thomas J. Watson Research Center                     */
-/*            $Id: TpmTcpProtocol.h 1490 2019-07-26 21:13:22Z kgoldman $               */
+/*            $Id: TpmTcpProtocol.h 1519 2019-11-15 20:43:51Z 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, 2017                             */
+/*  (c) Copyright IBM Corp. and others, 2016 - 2019                            */
 /*                                                                             */
 /********************************************************************************/
 
@@ -99,6 +99,7 @@
 #define TPM_SESSION_END             20
 #define TPM_STOP                    21
 #define TPM_GET_COMMAND_RESPONSE_SIZES  25
+#define TPM_ACT_GET_SIGNALED        26
 #define TPM_TEST_FAILURE_MODE       30
 
 // D.3.4.      Enumerations and Structures
@@ -110,6 +111,11 @@ enum TpmEndPointInfo
        tpmInRawMode = 0x04,
        tpmSupportsPP = 0x08
     };
+
+#ifdef _MSC_VER
+#   pragma warning(push, 3)
+#endif
+
 // Existing RPC interface type definitions retained so that the implementation
 // can be re-used
 typedef struct in_buffer
@@ -123,6 +129,9 @@ typedef struct out_buffer
     uint32_t         BufferSize;
     _OUTPUT_BUFFER   Buffer;
 } _OUT_BUFFER;
+#ifdef _MSC_VER
+#   pragma warning(pop)
+#endif
 #ifndef WIN32
 typedef unsigned long        DWORD;
 typedef void                *LPVOID;
index df8eab93094752c1d1ca585a9f4e1fa4534ce63d..faf996acfea354301d89512962012eb64ac1955b 100644 (file)
@@ -291,6 +291,7 @@ typedef UINT32                              TPM_CC;
 #define TPM_CC_AC_Send                      (TPM_CC)(0x00000195)
 #define TPM_CC_Policy_AC_SendSelect         (TPM_CC)(0x00000196)
 #define TPM_CC_CertifyX509                  (TPM_CC)(0x00000197)
+#define TPM_CC_ACT_SetTimeout               (TPM_CC)(0x00000198)
 #define CC_VEND                             0x20000000
 #define TPM_CC_Vendor_TCG_Test              (TPM_CC)(0x20000000)
 
@@ -562,7 +563,8 @@ typedef UINT32             TPM_CAP;
 #define TPM_CAP_PCR_PROPERTIES     (TPM_CAP)(0x00000007)
 #define TPM_CAP_ECC_CURVES         (TPM_CAP)(0x00000008)
 #define TPM_CAP_AUTH_POLICIES      (TPM_CAP)(0x00000009)
-#define TPM_CAP_LAST               (TPM_CAP)(0x00000009)
+#define TPM_CAP_ACT               (TPM_CAP)(0x0000000a)
+#define TPM_CAP_LAST               (TPM_CAP)(0x0000000a)
 #define TPM_CAP_VENDOR_PROPERTY    (TPM_CAP)(0x00000100)
 
 /* Table 2:23 - Definition of TPM_PT Constants */
@@ -1222,6 +1224,33 @@ typedef UINT32                                  TPMA_X509_KEY_USAGE;
      (digitalsignature << 31))
 #endif // USE_BIT_FIELD_STRUCTURES
 
+#define TYPE_OF_TPMA_ACT    UINT32
+#define TPMA_ACT_TO_UINT32(a)    (*((UINT32 *)&(a)))
+#define UINT32_TO_TPMA_ACT(a)    (*((TPMA_ACT *)&(a)))
+#define TPMA_ACT_TO_BYTE_ARRAY(i, a)                                   \
+    UINT32_TO_BYTE_ARRAY((TPMA_ACT_TO_UINT32(i)), (a))
+#define BYTE_ARRAY_TO_TPMA_ACT(i, a)                                   \
+    { UINT32 x = BYTE_ARRAY_TO_UINT32(a); i = UINT32_TO_TPMA_ACT(x); }
+#if USE_BIT_FIELD_STRUCTURES
+typedef struct TPMA_ACT {                           // Table 2:40
+    unsigned    signaled             : 1;
+    unsigned    preserveSignaled     : 1;
+    unsigned    Reserved_bits_at_2   : 30;
+} TPMA_ACT;                                         /* Bits */
+// This is the initializer for a TPMA_ACT structure
+#define TPMA_ACT_INITIALIZER(signaled, preservesignaled, bits_at_2)    \
+    {signaled, preservesignaled, bits_at_2}
+#else // USE_BIT_FIELD_STRUCTURES
+// This implements Table 2:40 TPMA_ACT using bit masking
+typedef UINT32                      TPMA_ACT;
+#define TYPE_OF_TPMA_ACT            UINT32
+#define TPMA_ACT_signaled           ((TPMA_ACT)1 << 0)
+#define TPMA_ACT_preserveSignaled   ((TPMA_ACT)1 << 1)
+// This is the initializer for a TPMA_ACT bit array.
+#define TPMA_ACT_INITIALIZER(signaled, preservesignaled, bits_at_2)    \
+    {(signaled << 0) + (preservesignaled << 1)}
+#endif // USE_BIT_FIELD_STRUCTURES
+
 /* Table 2:39 - Definition of TPMI_YES_NO Type  */
 typedef  BYTE               TPMI_YES_NO;
 /* Table 2:40 - Definition of TPMI_DH_OBJECT Type  */
@@ -1270,6 +1299,8 @@ typedef  TPM_HANDLE         TPMI_RH_LOCKOUT;
 typedef  TPM_HANDLE         TPMI_RH_NV_INDEX;
 /* Table 2:60 - Definition of TPMI_RH_AC Type  */
 typedef  TPM_HANDLE         TPMI_RH_AC;
+/* Table 2:65 - Definition of TPMI_RH_ACT Type  */
+typedef  TPM_HANDLE         TPMI_RH_ACT;
 /* Table 2:61 - Definition of TPMI_ALG_HASH Type  */
 typedef  TPM_ALG_ID         TPMI_ALG_HASH;
 /* Table 2:62 - Definition of TPMI_ALG_ASYM Type  */
@@ -1462,6 +1493,12 @@ typedef struct {
     TPM_HANDLE              handle;
     TPMT_HA                 policyHash;
 } TPMS_TAGGED_POLICY;
+/* Table 105 - Definition of TPMS_ACT_DATA Structure <OUT> */
+typedef struct {
+    TPM_HANDLE             handle;
+    UINT32                 timeout;
+    TPMA_ACT               attributes;
+} TPMS_ACT_DATA;
 /* Table 2:97 - Definition of TPML_CC Structure  */
 typedef struct {
     UINT32                  count;
@@ -1522,6 +1559,11 @@ typedef struct {
     UINT32                  count;
     TPMS_TAGGED_POLICY      policies[MAX_TAGGED_POLICIES];
 } TPML_TAGGED_POLICY;
+/* Table 2:118 - Definition of TPML_ACT_DATA Structure <OUT> */
+typedef struct {
+    UINT32             count;
+    TPMS_ACT_DATA      actData[MAX_ACT_DATA];
+} TPML_ACT_DATA;
 /* Table 2:110 - Definition of TPMU_CAPABILITIES Union  */
 typedef union {
     TPML_ALG_PROPERTY           algorithms;
@@ -1536,6 +1578,7 @@ typedef union {
     TPML_ECC_CURVE              eccCurves;
 #endif   // ALG_ECC
     TPML_TAGGED_POLICY          authPolicies;
+    TPML_ACT_DATA              actData;
 } TPMU_CAPABILITIES;
 /* Table 2:111 - Definition of TPMS_CAPABILITY_DATA Structure  */
 typedef struct {
index 9770cc2db3e33a44508ade261547f565259fcfa5..64f4353feb34347dd1115f75871d2a32ccb78d63 100644 (file)
@@ -3,7 +3,7 @@
 /*                          Parameter Unmarshaling                             */
 /*                          Written by Ken Goldman                             */
 /*                    IBM Thomas J. Watson Research Center                     */
-/*            $Id: Unmarshal.c 1490 2019-07-26 21:13:22Z kgoldman $            */
+/*            $Id: Unmarshal.c 1519 2019-11-15 20:43:51Z kgoldman $            */
 /*                                                                             */
 /* (c) Copyright IBM Corporation 2015 - 2018                                   */
 /*                                                                             */
@@ -1054,6 +1054,44 @@ TPMI_RH_NV_INDEX_Unmarshal(TPMI_RH_NV_INDEX *target, BYTE **buffer, INT32 *size)
     return rc;
 }
 
+/* Table 64 - Definition of (TPM_HANDLE) TPMI_RH_AC Type <IN> */
+
+TPM_RC
+TPMI_RH_AC_Unmarshal(TPMI_RH_AC *target, BYTE **buffer, INT32 *size)
+{
+    TPM_RC rc = TPM_RC_SUCCESS;
+
+    if (rc == TPM_RC_SUCCESS) {
+       rc = TPM_HANDLE_Unmarshal(target, buffer, size);  
+    }
+    if (rc == TPM_RC_SUCCESS) {
+       BOOL isNotAC = (*target < AC_FIRST) || (*target > AC_LAST);
+       if (isNotAC) {
+           rc = TPM_RC_VALUE;
+       }
+    }
+    return rc;
+}
+
+/* Table 65 - Definition of (TPM_HANDLE) TPMI_RH_ACT Type <IN> */
+
+TPM_RC
+TPMI_RH_ACT_Unmarshal( TPMI_RH_ACT *target, BYTE **buffer, INT32 *size)
+{
+    TPM_RC rc = TPM_RC_SUCCESS;
+
+    if (rc == TPM_RC_SUCCESS) {
+       rc = TPM_HANDLE_Unmarshal(target, buffer, size);  
+    }
+    if (rc == TPM_RC_SUCCESS) {
+       BOOL isNotACT = (*target < TPM_RH_ACT_0) || (*target > TPM_RH_ACT_F);
+       if (isNotACT) {
+           rc = TPM_RC_VALUE;
+       }
+    }
+    return rc;
+}
+
 /* Table 59 - Definition of (TPM_ALG_ID) TPMI_ALG_HASH Type  */
 
 TPM_RC
@@ -4249,3 +4287,15 @@ TPMS_CONTEXT_Unmarshal(TPMS_CONTEXT *target, BYTE **buffer, INT32 *size)
     return rc;
 }
 
+/* Table 225 - Definition of (UINT32) TPM_AT Constants */
+
+TPM_RC
+TPM_AT_Unmarshal(TPM_AT *target, BYTE **buffer, INT32 *size)
+{
+    TPM_RC rc = TPM_RC_SUCCESS;
+
+    if (rc == TPM_RC_SUCCESS) {
+       rc = UINT32_Unmarshal(target, buffer, size);  
+    }
+    return rc;
+}
index 895e07a7aab18be72526544471e2cf5c820ffd52..0aa688d664797c7bd847f2a63c7165d180214016 100644 (file)
@@ -1,9 +1,9 @@
 /********************************************************************************/
 /*                                                                             */
-/*                                                                             */
+/*                         Unmarshal Prototypes                                */
 /*                          Written by Ken Goldman                             */
 /*                    IBM Thomas J. Watson Research Center                     */
-/*            $Id: Unmarshal_fp.h 1476 2019-06-10 19:32:03Z kgoldman $         */
+/*            $Id: Unmarshal_fp.h 1526 2019-11-18 20:25:45Z 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, 2012-2018                              */
+/*  (c) Copyright IBM Corp. and others, 2012 - 2019                            */
 /*                                                                             */
 /********************************************************************************/
 
@@ -168,6 +168,10 @@ extern "C" {
     LIB_EXPORT TPM_RC
     TPMI_RH_NV_INDEX_Unmarshal(TPMI_RH_NV_INDEX *target, BYTE **buffer, INT32 *size);
     LIB_EXPORT TPM_RC
+    TPMI_RH_AC_Unmarshal(TPMI_RH_AC *target, BYTE **buffer, INT32 *size);
+    LIB_EXPORT TPM_RC
+    TPMI_RH_ACT_Unmarshal(TPMI_RH_ACT *target, BYTE **buffer, INT32 *size);
+    LIB_EXPORT TPM_RC
     TPMI_ALG_HASH_Unmarshal(TPMI_ALG_HASH *target, BYTE **buffer, INT32 *size, BOOL allowNull);
     LIB_EXPORT TPM_RC
     TPMI_ALG_SYM_Unmarshal(TPMI_ALG_SYM *target, BYTE **buffer, INT32 *size, BOOL allowNull);
@@ -459,6 +463,8 @@ extern "C" {
     TPM2B_CONTEXT_DATA_Unmarshal(TPM2B_CONTEXT_DATA *target, BYTE **buffer, INT32 *size);
     LIB_EXPORT TPM_RC
     TPMS_CONTEXT_Unmarshal(TPMS_CONTEXT *target, BYTE **buffer, INT32 *size);
+    LIB_EXPORT TPM_RC
+    TPM_AT_Unmarshal(TPM_AT *target, BYTE **buffer, INT32 *size);
     
 #ifdef __cplusplus
 }
index 6ece102100e4d0cea4d1c996d5b25b237ae7c256..47947ef85d5408c6eec04071c0df962b01994959 100644 (file)
@@ -56,6 +56,7 @@
 #include "tpm2/_TPM_Hash_Data_fp.h"
 #include "tpm2/_TPM_Init_fp.h"
 #include "tpm2/StateMarshal.h"
+#include "tpm2/PlatformACT.h"
 #include "tpm2/PlatformData.h"
 #include "tpm2/Volatile.h"