aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorPhilip Tricca <philip.b.tricca@intel.com>2018-03-07 19:01:42 -0800
committerPhilip Tricca <philip.b.tricca@intel.com>2018-03-08 11:52:03 -0800
commit52b830d7fe303a138aefb39182343d4909e24c52 (patch)
tree24bed839be5da4139bc81affc7cbb1d4be7d8a82 /include
parent06dd0aa57fe2ef8d0c06f1db5269a09c99b6d899 (diff)
downloadtpm2-tss-52b830d7fe303a138aefb39182343d4909e24c52.tar.gz
headers: Expand TPM2B_TYPE1 and TPM2B_TYPE2 macros, get ride of tpmb.h
Another step closer to having headers similar to the spec. Signed-off-by: Philip Tricca <philip.b.tricca@intel.com>
Diffstat (limited to 'include')
-rw-r--r--include/sapi/tpm20.h1
-rw-r--r--include/sapi/tpmb.h47
-rw-r--r--include/sapi/tss2_tpm2_types.h131
3 files changed, 104 insertions, 75 deletions
diff --git a/include/sapi/tpm20.h b/include/sapi/tpm20.h
index 530d693b..10890556 100644
--- a/include/sapi/tpm20.h
+++ b/include/sapi/tpm20.h
@@ -36,7 +36,6 @@
#include <string.h>
#include "sapi/tss2_common.h"
-#include "sapi/tpmb.h"
#include "sapi/tss2_tpm2_types.h"
#include "sapi/tss2_tcti.h"
#include "sapi/tss2_sys.h"
diff --git a/include/sapi/tpmb.h b/include/sapi/tpmb.h
deleted file mode 100644
index bf2b46c1..00000000
--- a/include/sapi/tpmb.h
+++ /dev/null
@@ -1,47 +0,0 @@
-//**********************************************************************;
-// Copyright (c) 2015, Intel Corporation
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are met:
-//
-// 1. Redistributions of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// 2. Redistributions in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
-// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
-// THE POSSIBILITY OF SUCH DAMAGE.
-//**********************************************************************;
-
-#ifndef _TPMB_H
-#define _TPMB_H
-
-#ifndef TSS2_API_VERSION_1_2_1_108
-#error Version mismatch among TSS2 header files. \
- Do not include this file, #include <sapi/tpm20.h> instead.
-#endif /* TSS2_API_VERSION_1_2_1_108 */
-
-#define TPM2B_TYPE1(name, bytes, bufferName) \
- typedef struct { \
- UINT16 size; \
- BYTE bufferName[bytes]; \
- } TPM2B_##name
-
-#define TPM2B_TYPE2(name, type, bufferName) \
- typedef struct { \
- UINT16 size; \
- type bufferName; \
- } TPM2B_##name
-#endif
diff --git a/include/sapi/tss2_tpm2_types.h b/include/sapi/tss2_tpm2_types.h
index 54454110..8e40bbe8 100644
--- a/include/sapi/tss2_tpm2_types.h
+++ b/include/sapi/tss2_tpm2_types.h
@@ -35,7 +35,6 @@
#endif /* TSS2_API_VERSION_1_2_1_108 */
#include <stdint.h>
-#include "tpmb.h"
#define TPM2_MAX_COMMAND_SIZE 4096 /* maximum size of a command */
#define TPM2_MAX_RESPONSE_SIZE 4096 /* maximum size of a response */
@@ -901,10 +900,16 @@ typedef struct {
} TPMT_HA;
/* Definition of TPM2B_DIGEST Structure */
-TPM2B_TYPE1(DIGEST, sizeof(TPMU_HA), buffer);
+typedef struct {
+ UINT16 size;
+ BYTE buffer[sizeof(TPMU_HA)];
+} TPM2B_DIGEST;
/* Definition of TPM2B_DATA Structure */
-TPM2B_TYPE1(DATA, sizeof(TPMT_HA), buffer);
+typedef struct {
+ UINT16 size;
+ BYTE buffer[sizeof(TPMU_HA)];
+} TPM2B_DATA;
/* Definition of Types for TPM2B_NONCE */
typedef TPM2B_DIGEST TPM2B_NONCE; /* size limited to the same as the digest structure */
@@ -916,19 +921,31 @@ typedef TPM2B_DIGEST TPM2B_AUTH; /* size limited to the same as the digest stru
typedef TPM2B_DIGEST TPM2B_OPERAND; /* size limited to the same as the digest structure */
/* Definition of TPM2B_EVENT Structure */
-TPM2B_TYPE1(EVENT, 1024, buffer);
+typedef struct {
+ UINT16 size;
+ BYTE buffer[1024];
+} TPM2B_EVENT;
/* Definition of TPM2B_MAX_BUFFER Structure */
-TPM2B_TYPE1(MAX_BUFFER, TPM2_MAX_DIGEST_BUFFER, buffer);
+typedef struct {
+ UINT16 size;
+ BYTE buffer[TPM2_MAX_DIGEST_BUFFER];
+} TPM2B_MAX_BUFFER;
/* Definition of TPM2B_MAX_NV_BUFFER Structure */
-TPM2B_TYPE1(MAX_NV_BUFFER, TPM2_MAX_NV_BUFFER_SIZE, buffer);
+typedef struct {
+ UINT16 size;
+ BYTE buffer[TPM2_MAX_NV_BUFFER_SIZE];
+} TPM2B_MAX_NV_BUFFER;
/* Definition of Types for TPM2B_TIMEOUT */
typedef TPM2B_DIGEST TPM2B_TIMEOUT; /* size limited to the same as the digest structure */
/* Definition of TPM2B_IV Structure <INOUT> */
-TPM2B_TYPE1(IV, TPM2_MAX_SYM_BLOCK_SIZE, buffer);
+typedef struct {
+ UINT16 size;
+ BYTE buffer[TPM2_MAX_SYM_BLOCK_SIZE];
+} TPM2B_IV;
/* Definition of TPMU_NAME Union <> */
typedef union {
@@ -937,7 +954,10 @@ typedef union {
} TPMU_NAME;
/* Definition of TPM2B_NAME Structure */
-TPM2B_TYPE1(NAME, sizeof(TPMU_NAME), name);
+typedef struct {
+ UINT16 size;
+ BYTE name[sizeof(TPMU_NAME)];
+} TPM2B_NAME;
/* Definition of TPMS_PCR_SELECT Structure */
typedef struct {
@@ -1176,7 +1196,10 @@ typedef struct {
} TPMS_ATTEST;
/* Definition of TPM2B_ATTEST Structure <OUT> */
-TPM2B_TYPE1(ATTEST, sizeof(TPMS_ATTEST), attestationData);
+typedef struct {
+ UINT16 size;
+ BYTE attestationData[sizeof(TPMS_ATTEST)];
+} TPM2B_ATTEST;
/* Definition of TPMS_AUTH_COMMAND Structure <IN> */
typedef struct {
@@ -1234,7 +1257,10 @@ typedef struct {
} TPMT_SYM_DEF_OBJECT;
/* Definition of TPM2B_SYM_KEY Structure */
-TPM2B_TYPE1(SYM_KEY, TPM2_MAX_SYM_KEY_BYTES, buffer);
+typedef struct {
+ UINT16 size;
+ BYTE buffer[TPM2_MAX_SYM_KEY_BYTES];
+} TPM2B_SYM_KEY;
/* Definition of TPMS_SYMCIPHER_PARMS Structure */
typedef struct {
@@ -1242,7 +1268,10 @@ typedef struct {
} TPMS_SYMCIPHER_PARMS;
/* Definition of TPM2B_SENSITIVE_DATA Structure */
-TPM2B_TYPE1(SENSITIVE_DATA, TPM2_MAX_SYM_DATA, buffer);
+typedef struct {
+ UINT16 size;
+ BYTE buffer[TPM2_MAX_SYM_DATA];
+} TPM2B_SENSITIVE_DATA;
/* Definition of TPMS_SENSITIVE_CREATE Structure <IN> */
typedef struct {
@@ -1251,7 +1280,10 @@ typedef struct {
} TPMS_SENSITIVE_CREATE;
/* Definition of TPM2B_SENSITIVE_CREATE Structure <IN S> */
-TPM2B_TYPE2(SENSITIVE_CREATE, TPMS_SENSITIVE_CREATE, sensitive);
+typedef struct {
+ UINT16 size;
+ TPMS_SENSITIVE_CREATE sensitive;
+} TPM2B_SENSITIVE_CREATE;
/* Definition of TPMS_SCHEME_HASH Structure */
typedef struct {
@@ -1387,16 +1419,25 @@ typedef struct {
} TPMT_RSA_DECRYPT;
/* Definition of RSA TPM2B_PUBLIC_KEY_RSA Structure */
-TPM2B_TYPE1(PUBLIC_KEY_RSA, TPM2_MAX_RSA_KEY_BYTES, buffer);
+typedef struct {
+ UINT16 size;
+ BYTE buffer[TPM2_MAX_RSA_KEY_BYTES];
+} TPM2B_PUBLIC_KEY_RSA;
/* Definition of RSA TPM2_KEY_BITS TPMI_RSA_KEY_BITS Type */
typedef TPM2_KEY_BITS TPMI_RSA_KEY_BITS;
/* Definition of RSA TPM2B_PRIVATE_KEY_RSA Structure */
-TPM2B_TYPE1(PRIVATE_KEY_RSA, TPM2_MAX_RSA_KEY_BYTES/2, buffer);
+typedef struct {
+ UINT16 size;
+ BYTE buffer[TPM2_MAX_RSA_KEY_BYTES/2];
+} TPM2B_PRIVATE_KEY_RSA;
/* Definition of ECC TPM2B_ECC_PARAMETER Structure */
-TPM2B_TYPE1(ECC_PARAMETER, TPM2_MAX_ECC_KEY_BYTES, buffer);
+typedef struct {
+ UINT16 size;
+ BYTE buffer[TPM2_MAX_ECC_KEY_BYTES];
+} TPM2B_ECC_PARAMETER;
/* Definition of ECC TPMS_ECC_POINT Structure */
typedef struct {
@@ -1405,7 +1446,10 @@ typedef struct {
} TPMS_ECC_POINT;
/* Definition of ECC TPM2B_ECC_POINT Structure */
-TPM2B_TYPE2(ECC_POINT, TPMS_ECC_POINT, point);
+typedef struct {
+ UINT16 size;
+ TPMS_ECC_POINT point;
+} TPM2B_ECC_POINT;
/* Definition of TPM2_ALG_ID ECC TPMI_ALG_ECC_SCHEME Type */
typedef TPM2_ALG_ID TPMI_ALG_ECC_SCHEME;
@@ -1484,7 +1528,10 @@ typedef union {
} TPMU_ENCRYPTED_SECRET;
/* Definition of TPM2B_ENCRYPTED_SECRET Structure */
-TPM2B_TYPE1(ENCRYPTED_SECRET, sizeof(TPMU_ENCRYPTED_SECRET), secret);
+typedef struct {
+ UINT16 size;
+ BYTE secret[sizeof(TPMU_ENCRYPTED_SECRET)];
+} TPM2B_ENCRYPTED_SECRET;
/* Definition of TPM2_ALG_ID TPMI_ALG_PUBLIC Type */
typedef TPM2_ALG_ID TPMI_ALG_PUBLIC;
@@ -1550,13 +1597,22 @@ typedef struct {
} TPMT_PUBLIC;
/* Definition of TPM2B_PUBLIC Structure */
-TPM2B_TYPE2(PUBLIC, TPMT_PUBLIC, publicArea);
+typedef struct {
+ UINT16 size;
+ TPMT_PUBLIC publicArea;
+} TPM2B_PUBLIC;
/* Definition of TPM2B_TEMPLATE Structure */
-TPM2B_TYPE1(TEMPLATE, sizeof(TPMT_PUBLIC), buffer);
+typedef struct {
+ UINT16 size;
+ BYTE buffer[sizeof(TPMT_PUBLIC)];
+} TPM2B_TEMPLATE;
/* Definition of TPM2B_PRIVATE_VENDOR_SPECIFIC Structure<> */
-TPM2B_TYPE1(PRIVATE_VENDOR_SPECIFIC, TPM2_PRIVATE_VENDOR_SPECIFIC_BYTES, buffer);
+typedef struct {
+ UINT16 size;
+ BYTE buffer[TPM2_PRIVATE_VENDOR_SPECIFIC_BYTES];
+} TPM2B_PRIVATE_VENDOR_SPECIFIC;
/* Definition of TPMU_SENSITIVE_COMPOSITE Union <INOUT S> */
typedef union {
@@ -1576,7 +1632,10 @@ typedef struct {
} TPMT_SENSITIVE;
/* Definition of TPM2B_SENSITIVE Structure <INOUT> */
-TPM2B_TYPE2(SENSITIVE, TPMT_SENSITIVE, sensitiveArea);
+typedef struct {
+ UINT16 size;
+ TPMT_SENSITIVE sensitiveArea;
+} TPM2B_SENSITIVE;
/* Definition of _PRIVATE Structure <> */
typedef struct {
@@ -1586,7 +1645,10 @@ typedef struct {
} _PRIVATE;
/* Definition of TPM2B_PRIVATE Structure <INOUT S> */
-TPM2B_TYPE1(PRIVATE, sizeof(_PRIVATE), buffer);
+typedef struct {
+ UINT16 size;
+ BYTE buffer[sizeof(_PRIVATE)];
+} TPM2B_PRIVATE;
/* Definition of _ID_OBJECT Structure <> */
typedef struct {
@@ -1595,7 +1657,10 @@ typedef struct {
} _ID_OBJECT;
/* Definition of TPM2B_ID_OBJECT Structure <INOUT> */
-TPM2B_TYPE1(ID_OBJECT, sizeof(_ID_OBJECT), credential);
+typedef struct {
+ UINT16 size;
+ BYTE credential[sizeof(_ID_OBJECT)];
+} TPM2B_ID_OBJECT;
/* Definition of UINT32 TPM2_NV_INDEX Bits <> */
typedef uint32_t TPM2_NV_INDEX;
@@ -1658,10 +1723,16 @@ typedef struct {
} TPMS_NV_PUBLIC;
/* Definition of TPM2B_NV_PUBLIC Structure */
-TPM2B_TYPE2(NV_PUBLIC, TPMS_NV_PUBLIC, nvPublic);
+typedef struct {
+ UINT16 size;
+ TPMS_NV_PUBLIC nvPublic;
+} TPM2B_NV_PUBLIC;
/* Definition of TPM2B_CONTEXT_SENSITIVE Structure <INOUT> */
-TPM2B_TYPE1(CONTEXT_SENSITIVE, TPM2_MAX_CONTEXT_SIZE, buffer);
+typedef struct {
+ UINT16 size;
+ BYTE buffer[TPM2_MAX_CONTEXT_SIZE];
+} TPM2B_CONTEXT_SENSITIVE;
/* Definition of TPMS_CONTEXT_DATA Structure <INOUT S> */
typedef struct {
@@ -1670,7 +1741,10 @@ typedef struct {
} TPMS_CONTEXT_DATA;
/* Definition of TPM2B_CONTEXT_DATA Structure <INOUT> */
-TPM2B_TYPE1(CONTEXT_DATA, sizeof(TPMS_CONTEXT_DATA), buffer);
+typedef struct {
+ UINT16 size;
+ BYTE buffer[sizeof(TPMS_CONTEXT_DATA)];
+} TPM2B_CONTEXT_DATA;
/* Definition of TPMS_CONTEXT Structure */
typedef struct {
@@ -1692,7 +1766,10 @@ typedef struct {
} TPMS_CREATION_DATA;
/* Definition of TPM2B_CREATION_DATA Structure <OUT> */
-TPM2B_TYPE2(CREATION_DATA, TPMS_CREATION_DATA, creationData);
+typedef struct {
+ UINT16 size;
+ TPMS_CREATION_DATA creationData;
+} TPM2B_CREATION_DATA;
typedef UINT32 TPM_AT;