diff options
author | Claudio Carvalho <cclaudio@linux.ibm.com> | 2019-08-20 17:03:57 -0300 |
---|---|---|
committer | Ram Pai <linuxram@us.ibm.com> | 2020-11-03 12:52:36 -0500 |
commit | d27a0015d1af3897794c579ac6318ff91ced8e49 (patch) | |
tree | be04ff2ddec6cfb6d921b565acb481b8d7a214a7 | |
parent | ea846b63936f8b98bc2f6cce5c21b092fa80e4d3 (diff) | |
download | skiboot-d27a0015d1af3897794c579ac6318ff91ced8e49.zip skiboot-d27a0015d1af3897794c579ac6318ff91ced8e49.tar.gz skiboot-d27a0015d1af3897794c579ac6318ff91ced8e49.tar.bz2 |
libstb: Add UV TSS.
This imports the UV TSS implementation, which is a light version of the
TSS implemented by Ken Goldman.
This also imports the mbedtls source coude, although we may not need it
in skiboot for the TSS.
214 files changed, 57905 insertions, 26 deletions
diff --git a/core/init.c b/core/init.c index 6c2a489..9b74a77 100644 --- a/core/init.c +++ b/core/init.c @@ -46,6 +46,8 @@ #include <occ.h> #include <opal-dump.h> #include <ultravisor.h> +#include <libstb/crypto/include/uv-crypto.h> +#include <libstb/tss2/tpm_nv.h> enum proc_gen proc_gen; unsigned int pcie_max_link_speed; @@ -543,6 +545,7 @@ void __noreturn load_and_boot_kernel(bool is_reboot) load_initramfs(); + tpm_nv_init(); trustedboot_exit_boot_services(); start_ultravisor(); @@ -1163,7 +1166,11 @@ void __noreturn __nomcount main_cpu_entry(const void *fdt) /* Set the console level */ console_log_level(); + /* NX init */ + nx_init(); + /* Secure/Trusted Boot init. We look for /ibm,secureboot in DT */ + uv_crypto_init(); secureboot_init(); trustedboot_init(); @@ -1220,8 +1227,6 @@ void __noreturn __nomcount main_cpu_entry(const void *fdt) /* Virtual Accelerator Switchboard */ vas_init(); - /* NX init */ - nx_init(); /* Init In-Memory Collection related stuff (load the IMC dtb into memory) */ imc_init(); diff --git a/libstb/Makefile.inc b/libstb/Makefile.inc index 93e55bb..86383ee 100644 --- a/libstb/Makefile.inc +++ b/libstb/Makefile.inc @@ -4,18 +4,19 @@ LIBSTB_DIR = libstb SUBDIRS += $(LIBSTB_DIR) -LIBSTB_SRCS = container.c tpm_chip.c cvc.c secureboot.c trustedboot.c +LIBSTB_SRCS = container.c tpm_chip.c cvc.c secureboot.c trustedboot.c tpm2.c LIBSTB_OBJS = $(LIBSTB_SRCS:%.c=%.o) LIBSTB = $(LIBSTB_DIR)/built-in.a include $(SRC)/$(LIBSTB_DIR)/drivers/Makefile.inc include $(SRC)/$(LIBSTB_DIR)/tss/Makefile.inc include $(SRC)/$(LIBSTB_DIR)/crypto/Makefile.inc +include $(SRC)/$(LIBSTB_DIR)/tss2/Makefile.inc CPPFLAGS += -I$(SRC)/$(LIBSTB_DIR)/crypto/mbedtls/include CPPFLAGS += -I$(SRC)/$(LIBSTB_DIR)/crypto/include -$(LIBSTB): $(LIBSTB_OBJS:%=$(LIBSTB_DIR)/%) $(DRIVERS) $(TSS) $(CRYPTO) +$(LIBSTB): $(LIBSTB_OBJS:%=$(LIBSTB_DIR)/%) $(DRIVERS) $(TSS) $(CRYPTO) $(TSS2) libstb/create-container: libstb/create-container.c libstb/container-utils.c $(call Q, HOSTCC ,$(HOSTCC) $(HOSTCFLAGS) \ diff --git a/libstb/crypto/Makefile.inc b/libstb/crypto/Makefile.inc index 194859c..4596f14 100644 --- a/libstb/crypto/Makefile.inc +++ b/libstb/crypto/Makefile.inc @@ -17,8 +17,10 @@ MBEDTLS_CFLAGS += $(CPPFLAGS) $(MBEDTLS): @$(MAKE) -C $(SRC)/$(LIBSTB_DIR)/crypto/mbedtls/library/ CFLAGS="$(MBEDTLS_CFLAGS)" CC=$(CC) AR=$(AR) libmbedcrypto.a libmbedx509.a -include $(CRYPTO_DIR)/pkcs7/Makefile.inc - +CRYPTO_SRCS = uv-crypto.c +CRYPTO_OBJS = $(CRYPTO_SRCS:%.c=%.o) CRYPTO = $(CRYPTO_DIR)/built-in.a -$(CRYPTO): $(MBEDTLS) $(PKCS7) +include $(CRYPTO_DIR)/pkcs7/Makefile.inc + +$(CRYPTO): $(MBEDTLS) $(PKCS7) $(CRYPTO_OBJS:%=$(CRYPTO_DIR)/%) diff --git a/libstb/crypto/include/uv-crypto.h b/libstb/crypto/include/uv-crypto.h new file mode 100644 index 0000000..5d8b32a --- /dev/null +++ b/libstb/crypto/include/uv-crypto.h @@ -0,0 +1,33 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* + * UV Crypto + * + * Copyright 2019, IBM Corporation. + * + */ + +#ifndef SVM_UV_CRYPTO_H +#define SVM_UV_CRYPTO_H + +#include <stdint.h> +#include <mbedtls/hmac_drbg.h> + +/** + * @brief Generate random bytes. + * + * @param output Buffer to fill. + * @param output_len Length of the buffer. + * + * @return 0 on success, else 1 on failure. + */ +extern int uv_crypto_rand_bytes(unsigned char *output, size_t output_len); + +/** + * @brief Init crypto context + * + * @return 0 on success, else 1 on failure. + */ +extern int32_t uv_crypto_init(void); + +#endif /* SVM_UV_CRYPTO_H */ + diff --git a/libstb/crypto/mbedtls-config.h b/libstb/crypto/mbedtls-config.h index edf4acc..eb87d17 100644 --- a/libstb/crypto/mbedtls-config.h +++ b/libstb/crypto/mbedtls-config.h @@ -54,6 +54,7 @@ #define MBEDTLS_VERSION_FEATURES #define MBEDTLS_X509_CHECK_KEY_USAGE #define MBEDTLS_X509_CHECK_EXTENDED_KEY_USAGE +#define MBEDTLS_CIPHER_MODE_CFB /* mbed TLS modules */ #define MBEDTLS_AES_C diff --git a/libstb/crypto/mbedtls/library/md.c b/libstb/crypto/mbedtls/library/md.c index 303cdcb..8453536 100644 --- a/libstb/crypto/mbedtls/library/md.c +++ b/libstb/crypto/mbedtls/library/md.c @@ -161,6 +161,7 @@ const mbedtls_md_info_t *mbedtls_md_info_from_type( mbedtls_md_type_t md_type ) case MBEDTLS_MD_SHA224: return( &mbedtls_sha224_info ); case MBEDTLS_MD_SHA256: + printf("mbedtls_sha256_info\n"); return( &mbedtls_sha256_info ); #endif #if defined(MBEDTLS_SHA512_C) diff --git a/libstb/crypto/uv-crypto.c b/libstb/crypto/uv-crypto.c new file mode 100644 index 0000000..af8cd81 --- /dev/null +++ b/libstb/crypto/uv-crypto.c @@ -0,0 +1,126 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* + * UV Crypto + * + * Copyright 2019, IBM Corporation. + * + */ + +#include <lock.h> +#include <skiboot.h> +#include <stdlib.h> +#include <uv-crypto.h> + +static mbedtls_hmac_drbg_context uv_drbg_ctx; +static struct lock drbg_lock = LOCK_UNLOCKED; + + +#define PPC_DARN(t, l) stringify(.long 0x7c0005e6 |\ + (((t) & 0x1f) << 21) |\ + (((l) & 0x3) << 16)) + +#define DARN_ERR 0xFFFFFFFFFFFFFFFFul + +static uint64_t uv_crypto_darn_bytes(void) +{ + uint64_t rnum; + int i; + + prerror("%s begin\n", __func__); + /* + * Power ISA says 10 attemps should be sufficient for DARN + * to succeed. Try upto 64 times before giving up. + */ + for (i = 0; i < 64; i++) { + asm volatile(PPC_DARN(%0, 1) : "=r"(rnum)); + + if (rnum != DARN_ERR) { + break; + } + } + + prerror("%s: rnum %llx\n", __func__, rnum); + + if (rnum == DARN_ERR) { + /** @todo (andmike) Need policy if darn fails */ + abort(); + } + + prerror("%s end\n", __func__); + return rnum; +} + +static int32_t uv_crypto_seed_bytes(void *ctx __unused, unsigned char *buf, + size_t len) +{ + uint64_t rnum; + + prerror("%s: len=%zd\n", __func__, len); + + while (len > 0 ) { + size_t cp_len; + + rnum = uv_crypto_darn_bytes(); + assert(rnum != DARN_ERR); + + cp_len = (len < sizeof(rnum)) ? len : sizeof(rnum); + memcpy(buf, &rnum, cp_len); + + buf += cp_len; + len -= cp_len; + prerror("%s: len %zd\n", __func__, len); + } + + return 0; +} + +static int32_t uv_crypto_drbg_init(void) +{ + int32_t rc; + const mbedtls_md_info_t *md_info; + + prerror("mbedtls_hmac_drbg_init\n"); + mbedtls_hmac_drbg_init(&uv_drbg_ctx); + + prerror("mbedtls_md_info_from_type\n"); + md_info = mbedtls_md_info_from_type(MBEDTLS_MD_SHA256); + assert(md_info); + + prerror("mbedtls_hmac_drbg_seed\n"); + rc = mbedtls_hmac_drbg_seed(&uv_drbg_ctx, md_info, + uv_crypto_seed_bytes, NULL, NULL, 0); + prerror("mbedtls_hmac_drbg_seed rc=%d\n",rc); + if (rc) { + return rc; + } + + prerror("mbedtls_hmac_drbg_set_reseed_interval\n"); + mbedtls_hmac_drbg_set_reseed_interval(&uv_drbg_ctx, 1000); + + prerror("mbedtls_hmac_drbg_set_prediction_resistance\n"); + mbedtls_hmac_drbg_set_prediction_resistance(&uv_drbg_ctx, + MBEDTLS_HMAC_DRBG_PR_OFF); + + prerror("uv_crypto_drbg_init end\n"); + return rc; +} + +int32_t uv_crypto_init(void) +{ + int32_t rc; + + rc = uv_crypto_drbg_init(); + + return rc; +} + +int32_t uv_crypto_rand_bytes(unsigned char *output, size_t output_len) +{ + int32_t rc; + + lock(&drbg_lock); + rc = mbedtls_hmac_drbg_random(&uv_drbg_ctx, output, output_len); + unlock(&drbg_lock); + + return rc; +} diff --git a/libstb/drivers/tpm_i2c_nuvoton.c b/libstb/drivers/tpm_i2c_nuvoton.c index ef32b79..1df70d6 100644 --- a/libstb/drivers/tpm_i2c_nuvoton.c +++ b/libstb/drivers/tpm_i2c_nuvoton.c @@ -11,6 +11,8 @@ #include "tpm_i2c_nuvoton.h" #include <opal-api.h> +#include <libstb/tpm2.h> + //#define DBG(fmt, ...) prlog(PR_DEBUG, fmt, ##__VA_ARGS__) #define DBG(fmt, ...) @@ -418,6 +420,92 @@ error: return rc; } +static int tpm_send(struct tpm_dev *dev, const uint8_t *buf, uint32_t len) +{ + int rc = 0; + if (!dev || !buf) { + /** + * @fwts-label TPMDeviceNotInitialized + * @fwts-advice TPM device is not initialized. This indicates a + * bug in the tpm_transmit() caller + */ + prlog(PR_ERR, "TPM: tpm device or buf not initialized\n"); + return STB_ARG_ERROR; + } + tpm_device = dev; + DBG("**** %s: dev %#x/%#x buf %016llx len %zu ****\n", + __func__, dev->bus_id, dev->i2c_addr, *(uint64_t *) buf, len); + + DBG("step 1/5: set command ready\n"); + rc = tpm_set_command_ready(); + if (rc < 0) + goto out; + + DBG("step 2/5: write FIFO\n"); + rc = tpm_write_fifo((uint8_t*) buf, len); + if (rc < 0) + goto out; + + DBG("step 3/5: write sts.go\n"); + rc = tpm_status_write_byte(TPM_STS_GO); + if (rc < 0) { + /** + * @fwts-label TPMWriteGo + * @fwts-advice Either the tpm device or the tpm-i2c interface + * doesn't seem to be working properly. Check the return code + * (rc) for further details. + */ + prlog(PR_ERR, "NUVOTON: fail to write sts.go, rc=%d\n", rc); + rc = STB_DRIVER_ERROR; + goto out; + } +out: + DBG("**** tpm_send %s, rc=%d ****\n", + (rc) ? "ERROR" : "SUCCESS", rc); + return rc; +} + +static int tpm_receive(struct tpm_dev *dev, uint8_t *buf, uint32_t *len) +{ + int rc = 0; + if (!dev || !buf) { + /** + * @fwts-label TPMDeviceNotInitialized + * @fwts-advice TPM device is not initialized. This indicates a + * bug in the tpm_transmit() caller + */ + prlog(PR_ERR, "TPM: tpm device or buf not initialized\n"); + return STB_ARG_ERROR; + } + tpm_device = dev; + DBG("**** %s: dev %#x/%#x len %zu ****\n", + __func__, dev->bus_id, dev->i2c_addr, len); + + DBG("step 4/5: read FIFO\n"); + rc = tpm_read_fifo(buf, (size_t*) len); + if (rc < 0) + goto out; + + DBG("step 5/5: release tpm\n"); + rc = tpm_status_write_byte(TPM_STS_COMMAND_READY); + if (rc < 0) { + /** + * @fwts-label TPMReleaseTpm + * @fwts-advice Either the tpm device or the tpm-i2c interface + * doesn't seem to be working properly. Check the return code + * (rc) for further details. + */ + prlog(PR_ERR, "NUVOTON: fail to release tpm, rc=%d\n", rc); + rc = STB_DRIVER_ERROR; + } + +out: + DBG("**** tpm_receive %s, rc=%d ****\n", + (rc) ? "ERROR" : "SUCCESS", rc); + return rc; +} + + static int tpm_transmit(struct tpm_dev *dev, uint8_t* buf, size_t cmdlen, size_t* buflen) { @@ -432,7 +520,7 @@ static int tpm_transmit(struct tpm_dev *dev, uint8_t* buf, size_t cmdlen, return STB_ARG_ERROR; } tpm_device = dev; - DBG("**** %s: dev %#x/%#x buf %016llx cmdlen %zu" + printf("**** %s: dev %#x/%#x buf %016llx cmdlen %zu" " buflen %zu ****\n", __func__, dev->bus_id, dev->i2c_addr, *(uint64_t *) buf, cmdlen, *buflen); @@ -488,6 +576,8 @@ out: static struct tpm_driver tpm_i2c_nuvoton_driver = { .name = DRIVER_NAME, .transmit = tpm_transmit, + .send = tpm_send, + .receive = tpm_receive, }; static int nuvoton_tpm_quirk(void *data, struct i2c_request *req, int *rc) @@ -558,6 +648,8 @@ void tpm_i2c_nuvoton_probe(void) free(tpm_device); continue; } + + tpm2_register(tpm_device, &tpm_i2c_nuvoton_driver); bus = i2c_find_bus_by_id(tpm_device->bus_id); assert(bus->check_quirk == NULL); bus->check_quirk = nuvoton_tpm_quirk; diff --git a/libstb/tpm2.c b/libstb/tpm2.c new file mode 100644 index 0000000..0bda16f --- /dev/null +++ b/libstb/tpm2.c @@ -0,0 +1,38 @@ +/* Copyright 2013-2016 IBM Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <device.h> +#include <libstb/tpm2.h> + +static struct tpm_dev *tpm_device; +static struct tpm_driver *tpm_driver; + +void tpm2_register(struct tpm_dev *dev, struct tpm_driver *driver) +{ + tpm_device = dev; + tpm_driver = driver; +} + + +struct tpm_dev* tpm2_get_device(void) +{ + return tpm_device; +} + +struct tpm_driver* tpm2_get_driver(void) +{ + return tpm_driver; +} diff --git a/libstb/tpm2.h b/libstb/tpm2.h new file mode 100644 index 0000000..d7dd8f3 --- /dev/null +++ b/libstb/tpm2.h @@ -0,0 +1,49 @@ +/* Copyright 2013-2016 IBM Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __TPM2_H +#define __TPM2_H + +#include <device.h> + +struct tpm_dev { + + /* TPM bus id */ + int bus_id; + + /* TPM address in the bus */ + int i2c_addr; +}; + +struct tpm_driver { + + /* Driver name */ + const char* name; + + /* Transmit the TPM command stored in buf to the tpm device */ + int (*transmit)(struct tpm_dev *dev, uint8_t* buf, size_t cmdlen, + size_t *buflen); + + int (*send)(struct tpm_dev *dev, const uint8_t *buf, uint32_t len); + + int (*receive)(struct tpm_dev *dev, uint8_t *buf, uint32_t *len); +}; + +void tpm2_register(struct tpm_dev *dev, struct tpm_driver *driver); +struct tpm_dev* tpm2_get_device(void); +struct tpm_driver* tpm2_get_driver(void); + +#endif /* __TPM2_H */ diff --git a/libstb/tpm_chip.h b/libstb/tpm_chip.h index dede420..6a4a2e3 100644 --- a/libstb/tpm_chip.h +++ b/libstb/tpm_chip.h @@ -9,24 +9,7 @@ #include "tss/tpmLogMgr.H" #include "tss/trustedTypes.H" -struct tpm_dev { - - /* TPM bus id */ - int bus_id; - - /* TPM address in the bus */ - int i2c_addr; -}; - -struct tpm_driver { - - /* Driver name */ - const char* name; - - /* Transmit the TPM command stored in buf to the tpm device */ - int (*transmit)(struct tpm_dev *dev, uint8_t* buf, size_t cmdlen, - size_t *buflen); -}; +#include <libstb/tpm2.h> struct tpm_chip { diff --git a/libstb/tss2/CommandAttributeData.c b/libstb/tss2/CommandAttributeData.c new file mode 100644 index 0000000..10a4d5a --- /dev/null +++ b/libstb/tss2/CommandAttributeData.c @@ -0,0 +1,956 @@ +/********************************************************************************/ +/* */ +/* Command Attributes Table */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: CommandAttributeData.c 1257 2018-06-27 20:52:08Z 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, 2012-2018 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +// 9.3 CommandAttributeData.c + +#ifdef TPM_TPM12 +#include <ibmtss/tpmconstants12.h> +#endif + +#include "CommandAttributes.h" +#if defined COMPRESSED_LISTS +# define PAD_LIST 0 +#else +# define PAD_LIST 1 +#endif + +// This is the command code attribute array for GetCapability(). Both this array and +// s_commandAttributes provides command code attributes, but tuned for different purpose + +/* bitfield is: + + command index + reserved + nv + extensive + flushed + cHandles + rHandle + V + reserved, flags TPM 1.2 command +*/ + +#include "tssccattributes.h" + +const TPMA_CC_TSS s_ccAttr [] = { + +#if (PAD_LIST || CC_NV_UndefineSpaceSpecial) + {{0x011f, 0, 1, 0, 0, 2, 0, 0, 0}}, // TPM_CC_NV_UndefineSpaceSpecial +#endif +#if (PAD_LIST || CC_EvictControl) + {{0x0120, 0, 1, 0, 0, 2, 0, 0, 0}}, // TPM_CC_EvictControl +#endif +#if (PAD_LIST || CC_HierarchyControl) + {{0x0121, 0, 1, 1, 0, 1, 0, 0, 0}}, // TPM_CC_HierarchyControl +#endif +#if (PAD_LIST || CC_NV_UndefineSpace) + {{0x0122, 0, 1, 0, 0, 2, 0, 0, 0}}, // TPM_CC_NV_UndefineSpace +#endif +#if (PAD_LIST) + {{0x0123, 0, 0, 0, 0, 0, 0, 0, 0}}, // No command +#endif +#if (PAD_LIST || CC_ChangeEPS) + {{0x0124, 0, 1, 1, 0, 1, 0, 0, 0}}, // TPM_CC_ChangeEPS +#endif +#if (PAD_LIST || CC_ChangePPS) + {{0x0125, 0, 1, 1, 0, 1, 0, 0, 0}}, // TPM_CC_ChangePPS +#endif +#if (PAD_LIST || CC_Clear) + {{0x0126, 0, 1, 1, 0, 1, 0, 0, 0}}, // TPM_CC_Clear +#endif +#if (PAD_LIST || CC_ClearControl) + {{0x0127, 0, 1, 0, 0, 1, 0, 0, 0}}, // TPM_CC_ClearControl +#endif +#if (PAD_LIST || CC_ClockSet) + {{0x0128, 0, 1, 0, 0, 1, 0, 0, 0}}, // TPM_CC_ClockSet +#endif +#if (PAD_LIST || CC_HierarchyChangeAuth) + {{0x0129, 0, 1, 0, 0, 1, 0, 0, 0}}, // TPM_CC_HierarchyChangeAuth +#endif +#if (PAD_LIST || CC_NV_DefineSpace) + {{0x012a, 0, 1, 0, 0, 1, 0, 0, 0}}, // TPM_CC_NV_DefineSpace +#endif +#if (PAD_LIST || CC_PCR_Allocate) + {{0x012b, 0, 1, 0, 0, 1, 0, 0, 0}}, // TPM_CC_PCR_Allocate +#endif +#if (PAD_LIST || CC_PCR_SetAuthPolicy) + {{0x012c, 0, 1, 0, 0, 1, 0, 0, 0}}, // TPM_CC_PCR_SetAuthPolicy +#endif +#if (PAD_LIST || CC_PP_Commands) + {{0x012d, 0, 1, 0, 0, 1, 0, 0, 0}}, // TPM_CC_PP_Commands +#endif +#if (PAD_LIST || CC_SetPrimaryPolicy) + {{0x012e, 0, 1, 0, 0, 1, 0, 0, 0}}, // TPM_CC_SetPrimaryPolicy +#endif +#if (PAD_LIST || CC_FieldUpgradeStart) + {{0x012f, 0, 0, 0, 0, 2, 0, 0, 0}}, // TPM_CC_FieldUpgradeStart +#endif +#if (PAD_LIST || CC_ClockRateAdjust) + {{0x0130, 0, 0, 0, 0, 1, 0, 0, 0}}, // TPM_CC_ClockRateAdjust +#endif +#if (PAD_LIST || CC_CreatePrimary) + {{0x0131, 0, 0, 0, 0, 1, 1, 0, 0}}, // TPM_CC_CreatePrimary +#endif +#if (PAD_LIST || CC_NV_GlobalWriteLock) + {{0x0132, 0, 1, 0, 0, 1, 0, 0, 0}}, // TPM_CC_NV_GlobalWriteLock +#endif +#if (PAD_LIST || CC_GetCommandAuditDigest) + {{0x0133, 0, 1, 0, 0, 2, 0, 0, 0}}, // TPM_CC_GetCommandAuditDigest +#endif +#if (PAD_LIST || CC_NV_Increment) + {{0x0134, 0, 1, 0, 0, 2, 0, 0, 0}}, // TPM_CC_NV_Increment +#endif +#if (PAD_LIST || CC_NV_SetBits) + {{0x0135, 0, 1, 0, 0, 2, 0, 0, 0}}, // TPM_CC_NV_SetBits +#endif +#if (PAD_LIST || CC_NV_Extend) + {{0x0136, 0, 1, 0, 0, 2, 0, 0, 0}}, // TPM_CC_NV_Extend +#endif +#if (PAD_LIST || CC_NV_Write) + {{0x0137, 0, 1, 0, 0, 2, 0, 0, 0}}, // TPM_CC_NV_Write +#endif +#if (PAD_LIST || CC_NV_WriteLock) + {{0x0138, 0, 1, 0, 0, 2, 0, 0, 0}}, // TPM_CC_NV_WriteLock +#endif +#if (PAD_LIST || CC_DictionaryAttackLockReset) + {{0x0139, 0, 1, 0, 0, 1, 0, 0, 0}}, // TPM_CC_DictionaryAttackLockReset +#endif +#if (PAD_LIST || CC_DictionaryAttackParameters) + {{0x013a, 0, 1, 0, 0, 1, 0, 0, 0}}, // TPM_CC_DictionaryAttackParameters +#endif +#if (PAD_LIST || CC_NV_ChangeAuth) + {{0x013b, 0, 1, 0, 0, 1, 0, 0, 0}}, // TPM_CC_NV_ChangeAuth +#endif +#if (PAD_LIST || CC_PCR_Event) + {{0x013c, 0, 1, 0, 0, 1, 0, 0, 0}}, // TPM_CC_PCR_Event +#endif +#if (PAD_LIST || CC_PCR_Reset) + {{0x013d, 0, 1, 0, 0, 1, 0, 0, 0}}, // TPM_CC_PCR_Reset +#endif +#if (PAD_LIST || CC_SequenceComplete) + {{0x013e, 0, 0, 0, 1, 1, 0, 0, 0}}, // TPM_CC_SequenceComplete +#endif +#if (PAD_LIST || CC_SetAlgorithmSet) + {{0x013f, 0, 1, 0, 0, 1, 0, 0, 0}}, // TPM_CC_SetAlgorithmSet +#endif +#if (PAD_LIST || CC_SetCommandCodeAuditStatus) + {{0x0140, 0, 1, 0, 0, 1, 0, 0, 0}}, // TPM_CC_SetCommandCodeAuditStatus +#endif +#if (PAD_LIST || CC_FieldUpgradeData) + {{0x0141, 0, 1, 0, 0, 0, 0, 0, 0}}, // TPM_CC_FieldUpgradeData +#endif +#if (PAD_LIST || CC_IncrementalSelfTest) + {{0x0142, 0, 1, 0, 0, 0, 0, 0, 0}}, // TPM_CC_IncrementalSelfTest +#endif +#if (PAD_LIST || CC_SelfTest) + {{0x0143, 0, 1, 0, 0, 0, 0, 0, 0}}, // TPM_CC_SelfTest +#endif +#if (PAD_LIST || CC_Startup) + {{0x0144, 0, 1, 0, 0, 0, 0, 0, 0}}, // TPM_CC_Startup +#endif +#if (PAD_LIST || CC_Shutdown) + {{0x0145, 0, 1, 0, 0, 0, 0, 0, 0}}, // TPM_CC_Shutdown +#endif +#if (PAD_LIST || CC_StirRandom) + {{0x0146, 0, 1, 0, 0, 0, 0, 0, 0}}, // TPM_CC_StirRandom +#endif +#if (PAD_LIST || CC_ActivateCredential) + {{0x0147, 0, 0, 0, 0, 2, 0, 0, 0}}, // TPM_CC_ActivateCredential +#endif +#if (PAD_LIST || CC_Certify) + {{0x0148, 0, 0, 0, 0, 2, 0, 0, 0}}, // TPM_CC_Certify +#endif +#if (PAD_LIST || CC_PolicyNV) + {{0x0149, 0, 0, 0, 0, 3, 0, 0, 0}}, // TPM_CC_PolicyNV +#endif +#if (PAD_LIST || CC_CertifyCreation) + {{0x014a, 0, 0, 0, 0, 2, 0, 0, 0}}, // TPM_CC_CertifyCreation +#endif +#if (PAD_LIST || CC_Duplicate) + {{0x014b, 0, 0, 0, 0, 2, 0, 0, 0}}, // TPM_CC_Duplicate +#endif +#if (PAD_LIST || CC_GetTime) + {{0x014c, 0, 0, 0, 0, 2, 0, 0, 0}}, // TPM_CC_GetTime +#endif +#if (PAD_LIST || CC_GetSessionAuditDigest) + {{0x014d, 0, 0, 0, 0, 3, 0, 0, 0}}, // TPM_CC_GetSessionAuditDigest +#endif +#if (PAD_LIST || CC_NV_Read) + {{0x014e, 0, 0, 0, 0, 2, 0, 0, 0}}, // TPM_CC_NV_Read +#endif +#if (PAD_LIST || CC_NV_ReadLock) + {{0x014f, 0, 1, 0, 0, 2, 0, 0, 0}}, // TPM_CC_NV_ReadLock +#endif +#if (PAD_LIST || CC_ObjectChangeAuth) + {{0x0150, 0, 0, 0, 0, 2, 0, 0, 0}}, // TPM_CC_ObjectChangeAuth +#endif +#if (PAD_LIST || CC_PolicySecret) + {{0x0151, 0, 0, 0, 0, 2, 0, 0, 0}}, // TPM_CC_PolicySecret +#endif +#if (PAD_LIST || CC_Rewrap) + {{0x0152, 0, 0, 0, 0, 2, 0, 0, 0}}, // TPM_CC_Rewrap +#endif +#if (PAD_LIST || CC_Create) + {{0x0153, 0, 0, 0, 0, 1, 0, 0, 0}}, // TPM_CC_Create +#endif +#if (PAD_LIST || CC_ECDH_ZGen) + {{0x0154, 0, 0, 0, 0, 1, 0, 0, 0}}, // TPM_CC_ECDH_ZGen +#endif +#if (PAD_LIST || CC_HMAC) + {{0x0155, 0, 0, 0, 0, 1, 0, 0, 0}}, // TPM_CC_HMAC +#endif +#if (PAD_LIST || CC_Import) + {{0x0156, 0, 0, 0, 0, 1, 0, 0, 0}}, // TPM_CC_Import +#endif +#if (PAD_LIST || CC_Load) + {{0x0157, 0, 0, 0, 0, 1, 1, 0, 0}}, // TPM_CC_Load +#endif +#if (PAD_LIST || CC_Quote) + {{0x0158, 0, 0, 0, 0, 1, 0, 0, 0}}, // TPM_CC_Quote +#endif +#if (PAD_LIST || CC_RSA_Decrypt) + {{0x0159, 0, 0, 0, 0, 1, 0, 0, 0}}, // TPM_CC_RSA_Decrypt +#endif +#if (PAD_LIST) + {{0x015a, 0, 0, 0, 0, 0, 0, 0, 0}}, // No command +#endif +#if (PAD_LIST || CC_HMAC_Start) + {{0x015b, 0, 0, 0, 0, 1, 1, 0, 0}}, // TPM_CC_HMAC_Start +#endif +#if (PAD_LIST || CC_SequenceUpdate) + {{0x015c, 0, 0, 0, 0, 1, 0, 0, 0}}, // TPM_CC_SequenceUpdate +#endif +#if (PAD_LIST || CC_Sign) + {{0x015d, 0, 0, 0, 0, 1, 0, 0, 0}}, // TPM_CC_Sign +#endif +#if (PAD_LIST || CC_Unseal) + {{0x015e, 0, 0, 0, 0, 1, 0, 0, 0}}, // TPM_CC_Unseal +#endif +#if (PAD_LIST) + {{0x015f, 0, 0, 0, 0, 0, 0, 0, 0}}, // No command +#endif +#if (PAD_LIST || CC_PolicySigned) + {{0x0160, 0, 0, 0, 0, 2, 0, 0, 0}}, // TPM_CC_PolicySigned +#endif +#if (PAD_LIST || CC_ContextLoad) + {{0x0161, 0, 0, 0, 0, 0, 1, 0, 0}}, // TPM_CC_ContextLoad +#endif +#if (PAD_LIST || CC_ContextSave) + {{0x0162, 0, 0, 0, 0, 1, 0, 0, 0}}, // TPM_CC_ContextSave +#endif +#if (PAD_LIST || CC_ECDH_KeyGen) + {{0x0163, 0, 0, 0, 0, 1, 0, 0, 0}}, // TPM_CC_ECDH_KeyGen +#endif +#if (PAD_LIST || CC_EncryptDecrypt) + {{0x0164, 0, 0, 0, 0, 1, 0, 0, 0}}, // TPM_CC_EncryptDecrypt +#endif +#if (PAD_LIST || CC_FlushContext) + {{0x0165, 0, 0, 0, 0, 0, 0, 0, 0}}, // TPM_CC_FlushContext +#endif +#if (PAD_LIST) + {{0x0166, 0, 0, 0, 0, 0, 0, 0, 0}}, // No command +#endif +#if (PAD_LIST || CC_LoadExternal) + {{0x0167, 0, 0, 0, 0, 0, 1, 0, 0}}, // TPM_CC_LoadExternal +#endif +#if (PAD_LIST || CC_MakeCredential) + {{0x0168, 0, 0, 0, 0, 1, 0, 0, 0}}, // TPM_CC_MakeCredential +#endif +#if (PAD_LIST || CC_NV_ReadPublic) + {{0x0169, 0, 0, 0, 0, 1, 0, 0, 0}}, // TPM_CC_NV_ReadPublic +#endif +#if (PAD_LIST || CC_PolicyAuthorize) + {{0x016a, 0, 0, 0, 0, 1, 0, 0, 0}}, // TPM_CC_PolicyAuthorize +#endif +#if (PAD_LIST || CC_PolicyAuthValue) + {{0x016b, 0, 0, 0, 0, 1, 0, 0, 0}}, // TPM_CC_PolicyAuthValue +#endif +#if (PAD_LIST || CC_PolicyCommandCode) + {{0x016c, 0, 0, 0, 0, 1, 0, 0, 0}}, // TPM_CC_PolicyCommandCode +#endif +#if (PAD_LIST || CC_PolicyCounterTimer) + {{0x016d, 0, 0, 0, 0, 1, 0, 0, 0}}, // TPM_CC_PolicyCounterTimer +#endif +#if (PAD_LIST || CC_PolicyCpHash) + {{0x016e, 0, 0, 0, 0, 1, 0, 0, 0}}, // TPM_CC_PolicyCpHash +#endif +#if (PAD_LIST || CC_PolicyLocality) + {{0x016f, 0, 0, 0, 0, 1, 0, 0, 0}}, // TPM_CC_PolicyLocality +#endif +#if (PAD_LIST || CC_PolicyNameHash) + {{0x0170, 0, 0, 0, 0, 1, 0, 0, 0}}, // TPM_CC_PolicyNameHash +#endif +#if (PAD_LIST || CC_PolicyOR) + {{0x0171, 0, 0, 0, 0, 1, 0, 0, 0}}, // TPM_CC_PolicyOR +#endif +#if (PAD_LIST || CC_PolicyTicket) + {{0x0172, 0, 0, 0, 0, 1, 0, 0, 0}}, // TPM_CC_PolicyTicket +#endif +#if (PAD_LIST || CC_ReadPublic) + {{0x0173, 0, 0, 0, 0, 1, 0, 0, 0}}, // TPM_CC_ReadPublic +#endif +#if (PAD_LIST || CC_RSA_Encrypt) + {{0x0174, 0, 0, 0, 0, 1, 0, 0, 0}}, // TPM_CC_RSA_Encrypt +#endif +#if (PAD_LIST) + {{0x0175, 0, 0, 0, 0, 0, 0, 0, 0}}, // No command +#endif +#if (PAD_LIST || CC_StartAuthSession) + {{0x0176, 0, 0, 0, 0, 2, 1, 0, 0}}, // TPM_CC_StartAuthSession +#endif +#if (PAD_LIST || CC_VerifySignature) + {{0x0177, 0, 0, 0, 0, 1, 0, 0, 0}}, // TPM_CC_VerifySignature +#endif +#if (PAD_LIST || CC_ECC_Parameters) + {{0x0178, 0, 0, 0, 0, 0, 0, 0, 0}}, // TPM_CC_ECC_Parameters +#endif +#if (PAD_LIST || CC_FirmwareRead) + {{0x0179, 0, 0, 0, 0, 0, 0, 0, 0}}, // TPM_CC_FirmwareRead +#endif +#if (PAD_LIST || CC_GetCapability) + {{0x017a, 0, 0, 0, 0, 0, 0, 0, 0}}, // TPM_CC_GetCapability +#endif +#if (PAD_LIST || CC_GetRandom) + {{0x017b, 0, 0, 0, 0, 0, 0, 0, 0}}, // TPM_CC_GetRandom +#endif +#if (PAD_LIST || CC_GetTestResult) + {{0x017c, 0, 0, 0, 0, 0, 0, 0, 0}}, // TPM_CC_GetTestResult +#endif +#if (PAD_LIST || CC_Hash) + {{0x017d, 0, 0, 0, 0, 0, 0, 0, 0}}, // TPM_CC_Hash +#endif +#if (PAD_LIST || CC_PCR_Read) + {{0x017e, 0, 0, 0, 0, 0, 0, 0, 0}}, // TPM_CC_PCR_Read +#endif +#if (PAD_LIST || CC_PolicyPCR) + {{0x017f, 0, 0, 0, 0, 1, 0, 0, 0}}, // TPM_CC_PolicyPCR +#endif +#if (PAD_LIST || CC_PolicyRestart) + {{0x0180, 0, 0, 0, 0, 1, 0, 0, 0}}, // TPM_CC_PolicyRestart +#endif +#if (PAD_LIST || CC_ReadClock) + {{0x0181, 0, 0, 0, 0, 0, 0, 0, 0}}, // TPM_CC_ReadClock +#endif +#if (PAD_LIST || CC_PCR_Extend) + {{0x0182, 0, 1, 0, 0, 1, 0, 0, 0}}, // TPM_CC_PCR_Extend +#endif +#if (PAD_LIST || CC_PCR_SetAuthValue) + {{0x0183, 0, 0, 0, 0, 1, 0, 0, 0}}, // TPM_CC_PCR_SetAuthValue +#endif +#if (PAD_LIST || CC_NV_Certify) + {{0x0184, 0, 0, 0, 0, 3, 0, 0, 0}}, // TPM_CC_NV_Certify +#endif +#if (PAD_LIST || CC_EventSequenceComplete) + {{0x0185, 0, 1, 0, 1, 2, 0, 0, 0}}, // TPM_CC_EventSequenceComplete +#endif +#if (PAD_LIST || CC_HashSequenceStart) + {{0x0186, 0, 0, 0, 0, 0, 1, 0, 0}}, // TPM_CC_HashSequenceStart +#endif +#if (PAD_LIST || CC_PolicyPhysicalPresence) + {{0x0187, 0, 0, 0, 0, 1, 0, 0, 0}}, // TPM_CC_PolicyPhysicalPresence +#endif +#if (PAD_LIST || CC_PolicyDuplicationSelect) + {{0x0188, 0, 0, 0, 0, 1, 0, 0, 0}}, // TPM_CC_PolicyDuplicationSelect +#endif +#if (PAD_LIST || CC_PolicyGetDigest) + {{0x0189, 0, 0, 0, 0, 1, 0, 0, 0}}, // TPM_CC_PolicyGetDigest +#endif +#if (PAD_LIST || CC_TestParms) + {{0x018a, 0, 0, 0, 0, 0, 0, 0, 0}}, // TPM_CC_TestParms +#endif +#if (PAD_LIST || CC_Commit) + {{0x018b, 0, 0, 0, 0, 1, 0, 0, 0}}, // TPM_CC_Commit +#endif +#if (PAD_LIST || CC_PolicyPassword) + {{0x018c, 0, 0, 0, 0, 1, 0, 0, 0}}, // TPM_CC_PolicyPassword +#endif +#if (PAD_LIST || CC_ZGen_2Phase) + {{0x018d, 0, 0, 0, 0, 1, 0, 0, 0}}, // TPM_CC_ZGen_2Phase +#endif +#if (PAD_LIST || CC_EC_Ephemeral) + {{0x018e, 0, 0, 0, 0, 0, 0, 0, 0}}, // TPM_CC_EC_Ephemeral +#endif +#if (PAD_LIST || CC_PolicyNvWritten) + {{0x018f, 0, 0, 0, 0, 1, 0, 0, 0}}, // TPM_CC_PolicyNvWritten +#endif +#if (PAD_LIST || CC_PolicyTemplate) + {{0x0190, 0, 0, 0, 0, 1, 0, 0, 0}}, // TPM_CC_PolicyTemplate +#endif +#if (PAD_LIST || CC_CreateLoaded) + {{0x0191, 0, 0, 0, 0, 1, 1, 0, 0}}, // TPM_CC_CreateLoaded +#endif +#if (PAD_LIST || CC_PolicyAuthorizeNV) + {{0x0192, 0, 0, 0, 0, 3, 0, 0, 0}}, // TPM_CC_PolicyAuthorizeNV +#endif +#if (PAD_LIST || CC_EncryptDecrypt2) + {{0x0193, 0, 0, 0, 0, 1, 0, 0, 0}}, // TPM_CC_EncryptDecrypt2 +#endif + +#if (PAD_LIST || CC_Vendor_TCG_Test) + {{0x0000, 0, 0, 0, 0, 0, 0, 1, 0}}, // TPM_CC_Vendor_TCG_Test +#endif + +#if (PAD_LIST || CC_NTC2_PreConfig) + {{0x20000211, 0, 1, 0, 0, 0, 0, 1, 0}}, // TPM_CC_NTC2_PreConfig +#endif + +#if (PAD_LIST || CC_NTC2_LockPreConfig) + {{0x20000212, 0, 1, 0, 0, 0, 0, 1, 0}}, // TPM_CC_NTC2_LockPreConfig +#endif + +#if (PAD_LIST || CC_NTC2_GetConfig) + {{0x20000213, 0, 1, 0, 0, 0, 0, 1, 0}}, // TPM_CC_NTC2_GetConfig +#endif + + {{0x0000, 0, 0, 0, 0, 0, 0, 0, 0}}, // kg - terminator? +}; + +// This is the command code attribute structure. + +const COMMAND_ATTRIBUTES s_commandAttributes [] = { +#if (PAD_LIST || CC_NV_UndefineSpaceSpecial) + (COMMAND_ATTRIBUTES)(CC_NV_UndefineSpaceSpecial * // 0x011f + (IS_IMPLEMENTED+HANDLE_1_ADMIN+HANDLE_2_USER+PP_COMMAND)), +#endif +#if (PAD_LIST || CC_EvictControl) + (COMMAND_ATTRIBUTES)(CC_EvictControl * // 0x0120 + (IS_IMPLEMENTED+HANDLE_1_USER+PP_COMMAND)), +#endif +#if (PAD_LIST || CC_HierarchyControl) + (COMMAND_ATTRIBUTES)(CC_HierarchyControl * // 0x0121 + (IS_IMPLEMENTED+HANDLE_1_USER+PP_COMMAND)), +#endif +#if (PAD_LIST || CC_NV_UndefineSpace) + (COMMAND_ATTRIBUTES)(CC_NV_UndefineSpace * // 0x0122 + (IS_IMPLEMENTED+HANDLE_1_USER+PP_COMMAND)), +#endif +#if (PAD_LIST) + (COMMAND_ATTRIBUTES)(0), // 0x0123 +#endif +#if (PAD_LIST || CC_ChangeEPS) + (COMMAND_ATTRIBUTES)(CC_ChangeEPS * // 0x0124 + (IS_IMPLEMENTED+HANDLE_1_USER+PP_COMMAND)), +#endif +#if (PAD_LIST || CC_ChangePPS) + (COMMAND_ATTRIBUTES)(CC_ChangePPS * // 0x0125 + (IS_IMPLEMENTED+HANDLE_1_USER+PP_COMMAND)), +#endif +#if (PAD_LIST || CC_Clear) + (COMMAND_ATTRIBUTES)(CC_Clear * // 0x0126 + (IS_IMPLEMENTED+HANDLE_1_USER+PP_COMMAND)), +#endif +#if (PAD_LIST || CC_ClearControl) + (COMMAND_ATTRIBUTES)(CC_ClearControl * // 0x0127 + (IS_IMPLEMENTED+HANDLE_1_USER+PP_COMMAND)), +#endif +#if (PAD_LIST || CC_ClockSet) + (COMMAND_ATTRIBUTES)(CC_ClockSet * // 0x0128 + (IS_IMPLEMENTED+HANDLE_1_USER+PP_COMMAND)), +#endif +#if (PAD_LIST || CC_HierarchyChangeAuth) + (COMMAND_ATTRIBUTES)(CC_HierarchyChangeAuth * // 0x0129 + (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+PP_COMMAND)), +#endif +#if (PAD_LIST || CC_NV_DefineSpace) + (COMMAND_ATTRIBUTES)(CC_NV_DefineSpace * // 0x012a + (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+PP_COMMAND)), +#endif +#if (PAD_LIST || CC_PCR_Allocate) + (COMMAND_ATTRIBUTES)(CC_PCR_Allocate * // 0x012b + (IS_IMPLEMENTED+HANDLE_1_USER+PP_COMMAND)), +#endif +#if (PAD_LIST || CC_PCR_SetAuthPolicy) + (COMMAND_ATTRIBUTES)(CC_PCR_SetAuthPolicy * // 0x012c + (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+PP_COMMAND)), +#endif +#if (PAD_LIST || CC_PP_Commands) + (COMMAND_ATTRIBUTES)(CC_PP_Commands * // 0x012d + (IS_IMPLEMENTED+HANDLE_1_USER+PP_REQUIRED)), +#endif +#if (PAD_LIST || CC_SetPrimaryPolicy) + (COMMAND_ATTRIBUTES)(CC_SetPrimaryPolicy * // 0x012e + (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+PP_COMMAND)), +#endif +#if (PAD_LIST || CC_FieldUpgradeStart) + (COMMAND_ATTRIBUTES)(CC_FieldUpgradeStart * // 0x012f + (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_ADMIN+PP_COMMAND)), +#endif +#if (PAD_LIST || CC_ClockRateAdjust) + (COMMAND_ATTRIBUTES)(CC_ClockRateAdjust * // 0x0130 + (IS_IMPLEMENTED+HANDLE_1_USER+PP_COMMAND)), +#endif +#if (PAD_LIST || CC_CreatePrimary) + (COMMAND_ATTRIBUTES)(CC_CreatePrimary * // 0x0131 + (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+PP_COMMAND+ENCRYPT_2+R_HANDLE)), +#endif +#if (PAD_LIST || CC_NV_GlobalWriteLock) + (COMMAND_ATTRIBUTES)(CC_NV_GlobalWriteLock * // 0x0132 + (IS_IMPLEMENTED+HANDLE_1_USER+PP_COMMAND)), +#endif +#if (PAD_LIST || CC_GetCommandAuditDigest) + (COMMAND_ATTRIBUTES)(CC_GetCommandAuditDigest * // 0x0133 + (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+HANDLE_2_USER+ENCRYPT_2)), +#endif +#if (PAD_LIST || CC_NV_Increment) + (COMMAND_ATTRIBUTES)(CC_NV_Increment * // 0x0134 + (IS_IMPLEMENTED+HANDLE_1_USER)), +#endif +#if (PAD_LIST || CC_NV_SetBits) + (COMMAND_ATTRIBUTES)(CC_NV_SetBits * // 0x0135 + (IS_IMPLEMENTED+HANDLE_1_USER)), +#endif +#if (PAD_LIST || CC_NV_Extend) + (COMMAND_ATTRIBUTES)(CC_NV_Extend * // 0x0136 + (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER)), +#endif +#if (PAD_LIST || CC_NV_Write) + (COMMAND_ATTRIBUTES)(CC_NV_Write * // 0x0137 + (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER)), +#endif +#if (PAD_LIST || CC_NV_WriteLock) + (COMMAND_ATTRIBUTES)(CC_NV_WriteLock * // 0x0138 + (IS_IMPLEMENTED+HANDLE_1_USER)), +#endif +#if (PAD_LIST || CC_DictionaryAttackLockReset) + (COMMAND_ATTRIBUTES)(CC_DictionaryAttackLockReset * // 0x0139 + (IS_IMPLEMENTED+HANDLE_1_USER)), +#endif +#if (PAD_LIST || CC_DictionaryAttackParameters) + (COMMAND_ATTRIBUTES)(CC_DictionaryAttackParameters * // 0x013a + (IS_IMPLEMENTED+HANDLE_1_USER)), +#endif +#if (PAD_LIST || CC_NV_ChangeAuth) + (COMMAND_ATTRIBUTES)(CC_NV_ChangeAuth * // 0x013b + (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_ADMIN)), +#endif +#if (PAD_LIST || CC_PCR_Event) + (COMMAND_ATTRIBUTES)(CC_PCR_Event * // 0x013c + (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER)), +#endif +#if (PAD_LIST || CC_PCR_Reset) + (COMMAND_ATTRIBUTES)(CC_PCR_Reset * // 0x013d + (IS_IMPLEMENTED+HANDLE_1_USER)), +#endif +#if (PAD_LIST || CC_SequenceComplete) + (COMMAND_ATTRIBUTES)(CC_SequenceComplete * // 0x013e + (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+ENCRYPT_2)), +#endif +#if (PAD_LIST || CC_SetAlgorithmSet) + (COMMAND_ATTRIBUTES)(CC_SetAlgorithmSet * // 0x013f + (IS_IMPLEMENTED+HANDLE_1_USER)), +#endif +#if (PAD_LIST || CC_SetCommandCodeAuditStatus) + (COMMAND_ATTRIBUTES)(CC_SetCommandCodeAuditStatus * // 0x0140 + (IS_IMPLEMENTED+HANDLE_1_USER+PP_COMMAND)), +#endif +#if (PAD_LIST || CC_FieldUpgradeData) + (COMMAND_ATTRIBUTES)(CC_FieldUpgradeData * // 0x0141 + (IS_IMPLEMENTED+DECRYPT_2)), +#endif +#if (PAD_LIST || CC_IncrementalSelfTest) + (COMMAND_ATTRIBUTES)(CC_IncrementalSelfTest * // 0x0142 + (IS_IMPLEMENTED)), +#endif +#if (PAD_LIST || CC_SelfTest) + (COMMAND_ATTRIBUTES)(CC_SelfTest * // 0x0143 + (IS_IMPLEMENTED)), +#endif +#if (PAD_LIST || CC_Startup) + (COMMAND_ATTRIBUTES)(CC_Startup * // 0x0144 + (IS_IMPLEMENTED+NO_SESSIONS)), +#endif +#if (PAD_LIST || CC_Shutdown) + (COMMAND_ATTRIBUTES)(CC_Shutdown * // 0x0145 + (IS_IMPLEMENTED)), +#endif +#if (PAD_LIST || CC_StirRandom) + (COMMAND_ATTRIBUTES)(CC_StirRandom * // 0x0146 + (IS_IMPLEMENTED+DECRYPT_2)), +#endif +#if (PAD_LIST || CC_ActivateCredential) + (COMMAND_ATTRIBUTES)(CC_ActivateCredential * // 0x0147 + (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_ADMIN+HANDLE_2_USER+ENCRYPT_2)), +#endif +#if (PAD_LIST || CC_Certify) + (COMMAND_ATTRIBUTES)(CC_Certify * // 0x0148 + (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_ADMIN+HANDLE_2_USER+ENCRYPT_2)), +#endif +#if (PAD_LIST || CC_PolicyNV) + (COMMAND_ATTRIBUTES)(CC_PolicyNV * // 0x0149 + (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+ALLOW_TRIAL)), +#endif +#if (PAD_LIST || CC_CertifyCreation) + (COMMAND_ATTRIBUTES)(CC_CertifyCreation * // 0x014a + (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+ENCRYPT_2)), +#endif +#if (PAD_LIST || CC_Duplicate) + (COMMAND_ATTRIBUTES)(CC_Duplicate * // 0x014b + (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_DUP+ENCRYPT_2)), +#endif +#if (PAD_LIST || CC_GetTime) + (COMMAND_ATTRIBUTES)(CC_GetTime * // 0x014c + (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+HANDLE_2_USER+ENCRYPT_2)), +#endif +#if (PAD_LIST || CC_GetSessionAuditDigest) + (COMMAND_ATTRIBUTES)(CC_GetSessionAuditDigest * // 0x014d + (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+HANDLE_2_USER+ENCRYPT_2)), +#endif +#if (PAD_LIST || CC_NV_Read) + (COMMAND_ATTRIBUTES)(CC_NV_Read * // 0x014e + (IS_IMPLEMENTED+HANDLE_1_USER+ENCRYPT_2)), +#endif +#if (PAD_LIST || CC_NV_ReadLock) + (COMMAND_ATTRIBUTES)(CC_NV_ReadLock * // 0x014f + (IS_IMPLEMENTED+HANDLE_1_USER)), +#endif +#if (PAD_LIST || CC_ObjectChangeAuth) + (COMMAND_ATTRIBUTES)(CC_ObjectChangeAuth * // 0x0150 + (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_ADMIN+ENCRYPT_2)), +#endif +#if (PAD_LIST || CC_PolicySecret) + (COMMAND_ATTRIBUTES)(CC_PolicySecret * // 0x0151 + (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+ALLOW_TRIAL+ENCRYPT_2)), +#endif +#if (PAD_LIST || CC_Rewrap) + (COMMAND_ATTRIBUTES)(CC_Rewrap * // 0x0152 + (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+ENCRYPT_2)), +#endif +#if (PAD_LIST || CC_Create) + (COMMAND_ATTRIBUTES)(CC_Create * // 0x0153 + (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+ENCRYPT_2)), +#endif +#if (PAD_LIST || CC_ECDH_ZGen) + (COMMAND_ATTRIBUTES)(CC_ECDH_ZGen * // 0x0154 + (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+ENCRYPT_2)), +#endif +#if (PAD_LIST || CC_HMAC) + (COMMAND_ATTRIBUTES)(CC_HMAC * // 0x0155 + (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+ENCRYPT_2)), +#endif +#if (PAD_LIST || CC_Import) + (COMMAND_ATTRIBUTES)(CC_Import * // 0x0156 + (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+ENCRYPT_2)), +#endif +#if (PAD_LIST || CC_Load) + (COMMAND_ATTRIBUTES)(CC_Load * // 0x0157 + (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+ENCRYPT_2+R_HANDLE)), +#endif +#if (PAD_LIST || CC_Quote) + (COMMAND_ATTRIBUTES)(CC_Quote * // 0x0158 + (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+ENCRYPT_2)), +#endif +#if (PAD_LIST || CC_RSA_Decrypt) + (COMMAND_ATTRIBUTES)(CC_RSA_Decrypt * // 0x0159 + (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+ENCRYPT_2)), +#endif +#if (PAD_LIST) + (COMMAND_ATTRIBUTES)(0), // 0x015a +#endif +#if (PAD_LIST || CC_HMAC_Start) + (COMMAND_ATTRIBUTES)(CC_HMAC_Start * // 0x015b + (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+R_HANDLE)), +#endif +#if (PAD_LIST || CC_SequenceUpdate) + (COMMAND_ATTRIBUTES)(CC_SequenceUpdate * // 0x015c + (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER)), +#endif +#if (PAD_LIST || CC_Sign) + (COMMAND_ATTRIBUTES)(CC_Sign * // 0x015d + (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER)), +#endif +#if (PAD_LIST || CC_Unseal) + (COMMAND_ATTRIBUTES)(CC_Unseal * // 0x015e + (IS_IMPLEMENTED+HANDLE_1_USER+ENCRYPT_2)), +#endif +#if (PAD_LIST) + (COMMAND_ATTRIBUTES)(0), // 0x015f +#endif +#if (PAD_LIST || CC_PolicySigned) + (COMMAND_ATTRIBUTES)(CC_PolicySigned * // 0x0160 + (IS_IMPLEMENTED+DECRYPT_2+ALLOW_TRIAL+ENCRYPT_2)), +#endif +#if (PAD_LIST || CC_ContextLoad) + (COMMAND_ATTRIBUTES)(CC_ContextLoad * // 0x0161 + (IS_IMPLEMENTED+NO_SESSIONS+R_HANDLE)), +#endif +#if (PAD_LIST || CC_ContextSave) + (COMMAND_ATTRIBUTES)(CC_ContextSave * // 0x0162 + (IS_IMPLEMENTED+NO_SESSIONS)), +#endif +#if (PAD_LIST || CC_ECDH_KeyGen) + (COMMAND_ATTRIBUTES)(CC_ECDH_KeyGen * // 0x0163 + (IS_IMPLEMENTED+ENCRYPT_2)), +#endif +#if (PAD_LIST || CC_EncryptDecrypt) + (COMMAND_ATTRIBUTES)(CC_EncryptDecrypt * // 0x0164 + (IS_IMPLEMENTED+HANDLE_1_USER+ENCRYPT_2)), +#endif +#if (PAD_LIST || CC_FlushContext) + (COMMAND_ATTRIBUTES)(CC_FlushContext * // 0x0165 + (IS_IMPLEMENTED+NO_SESSIONS)), +#endif +#if (PAD_LIST) + (COMMAND_ATTRIBUTES)(0), // 0x0166 +#endif +#if (PAD_LIST || CC_LoadExternal) + (COMMAND_ATTRIBUTES)(CC_LoadExternal * // 0x0167 + (IS_IMPLEMENTED+DECRYPT_2+ENCRYPT_2+R_HANDLE)), +#endif +#if (PAD_LIST || CC_MakeCredential) + (COMMAND_ATTRIBUTES)(CC_MakeCredential * // 0x0168 + (IS_IMPLEMENTED+DECRYPT_2+ENCRYPT_2)), +#endif +#if (PAD_LIST || CC_NV_ReadPublic) + (COMMAND_ATTRIBUTES)(CC_NV_ReadPublic * // 0x0169 + (IS_IMPLEMENTED+ENCRYPT_2)), +#endif +#if (PAD_LIST || CC_PolicyAuthorize) + (COMMAND_ATTRIBUTES)(CC_PolicyAuthorize * // 0x016a + (IS_IMPLEMENTED+DECRYPT_2+ALLOW_TRIAL)), +#endif +#if (PAD_LIST || CC_PolicyAuthValue) + (COMMAND_ATTRIBUTES)(CC_PolicyAuthValue * // 0x016b + (IS_IMPLEMENTED+ALLOW_TRIAL)), +#endif +#if (PAD_LIST || CC_PolicyCommandCode) + (COMMAND_ATTRIBUTES)(CC_PolicyCommandCode * // 0x016c + (IS_IMPLEMENTED+ALLOW_TRIAL)), +#endif +#if (PAD_LIST || CC_PolicyCounterTimer) + (COMMAND_ATTRIBUTES)(CC_PolicyCounterTimer * // 0x016d + (IS_IMPLEMENTED+DECRYPT_2+ALLOW_TRIAL)), +#endif +#if (PAD_LIST || CC_PolicyCpHash) + (COMMAND_ATTRIBUTES)(CC_PolicyCpHash * // 0x016e + (IS_IMPLEMENTED+DECRYPT_2+ALLOW_TRIAL)), +#endif +#if (PAD_LIST || CC_PolicyLocality) + (COMMAND_ATTRIBUTES)(CC_PolicyLocality * // 0x016f + (IS_IMPLEMENTED+ALLOW_TRIAL)), +#endif +#if (PAD_LIST || CC_PolicyNameHash) + (COMMAND_ATTRIBUTES)(CC_PolicyNameHash * // 0x0170 + (IS_IMPLEMENTED+DECRYPT_2+ALLOW_TRIAL)), +#endif +#if (PAD_LIST || CC_PolicyOR) + (COMMAND_ATTRIBUTES)(CC_PolicyOR * // 0x0171 + (IS_IMPLEMENTED+ALLOW_TRIAL)), +#endif +#if (PAD_LIST || CC_PolicyTicket) + (COMMAND_ATTRIBUTES)(CC_PolicyTicket * // 0x0172 + (IS_IMPLEMENTED+DECRYPT_2+ALLOW_TRIAL)), +#endif +#if (PAD_LIST || CC_ReadPublic) + (COMMAND_ATTRIBUTES)(CC_ReadPublic * // 0x0173 + (IS_IMPLEMENTED+ENCRYPT_2)), +#endif +#if (PAD_LIST || CC_RSA_Encrypt) + (COMMAND_ATTRIBUTES)(CC_RSA_Encrypt * // 0x0174 + (IS_IMPLEMENTED+DECRYPT_2+ENCRYPT_2)), +#endif +#if (PAD_LIST) + (COMMAND_ATTRIBUTES)(0), // 0x0175 +#endif +#if (PAD_LIST || CC_StartAuthSession) + (COMMAND_ATTRIBUTES)(CC_StartAuthSession * // 0x0176 + (IS_IMPLEMENTED+DECRYPT_2+ENCRYPT_2+R_HANDLE)), +#endif +#if (PAD_LIST || CC_VerifySignature) + (COMMAND_ATTRIBUTES)(CC_VerifySignature * // 0x0177 + (IS_IMPLEMENTED+DECRYPT_2)), +#endif +#if (PAD_LIST || CC_ECC_Parameters) + (COMMAND_ATTRIBUTES)(CC_ECC_Parameters * // 0x0178 + (IS_IMPLEMENTED)), +#endif +#if (PAD_LIST || CC_FirmwareRead) + (COMMAND_ATTRIBUTES)(CC_FirmwareRead * // 0x0179 + (IS_IMPLEMENTED+ENCRYPT_2)), +#endif +#if (PAD_LIST || CC_GetCapability) + (COMMAND_ATTRIBUTES)(CC_GetCapability * // 0x017a + (IS_IMPLEMENTED)), +#endif +#if (PAD_LIST || CC_GetRandom) + (COMMAND_ATTRIBUTES)(CC_GetRandom * // 0x017b + (IS_IMPLEMENTED+ENCRYPT_2)), +#endif +#if (PAD_LIST || CC_GetTestResult) + (COMMAND_ATTRIBUTES)(CC_GetTestResult * // 0x017c + (IS_IMPLEMENTED+ENCRYPT_2)), +#endif +#if (PAD_LIST || CC_Hash) + (COMMAND_ATTRIBUTES)(CC_Hash * // 0x017d + (IS_IMPLEMENTED+DECRYPT_2+ENCRYPT_2)), +#endif +#if (PAD_LIST || CC_PCR_Read) + (COMMAND_ATTRIBUTES)(CC_PCR_Read * // 0x017e + (IS_IMPLEMENTED)), +#endif +#if (PAD_LIST || CC_PolicyPCR) + (COMMAND_ATTRIBUTES)(CC_PolicyPCR * // 0x017f + (IS_IMPLEMENTED+DECRYPT_2+ALLOW_TRIAL)), +#endif +#if (PAD_LIST || CC_PolicyRestart) + (COMMAND_ATTRIBUTES)(CC_PolicyRestart * // 0x0180 + (IS_IMPLEMENTED+ALLOW_TRIAL)), +#endif +#if (PAD_LIST || CC_ReadClock) + (COMMAND_ATTRIBUTES)(CC_ReadClock * // 0x0181 + (IS_IMPLEMENTED+NO_SESSIONS)), +#endif +#if (PAD_LIST || CC_PCR_Extend) + (COMMAND_ATTRIBUTES)(CC_PCR_Extend * // 0x0182 + (IS_IMPLEMENTED+HANDLE_1_USER)), +#endif +#if (PAD_LIST || CC_PCR_SetAuthValue) + (COMMAND_ATTRIBUTES)(CC_PCR_SetAuthValue * // 0x0183 + (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER)), +#endif +#if (PAD_LIST || CC_NV_Certify) + (COMMAND_ATTRIBUTES)(CC_NV_Certify * // 0x0184 + (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+HANDLE_2_USER+ENCRYPT_2)), +#endif +#if (PAD_LIST || CC_EventSequenceComplete) + (COMMAND_ATTRIBUTES)(CC_EventSequenceComplete * // 0x0185 + (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+HANDLE_2_USER)), +#endif +#if (PAD_LIST || CC_HashSequenceStart) + (COMMAND_ATTRIBUTES)(CC_HashSequenceStart * // 0x0186 + (IS_IMPLEMENTED+DECRYPT_2+R_HANDLE)), +#endif +#if (PAD_LIST || CC_PolicyPhysicalPresence) + (COMMAND_ATTRIBUTES)(CC_PolicyPhysicalPresence * // 0x0187 + (IS_IMPLEMENTED+ALLOW_TRIAL)), +#endif +#if (PAD_LIST || CC_PolicyDuplicationSelect) + (COMMAND_ATTRIBUTES)(CC_PolicyDuplicationSelect * // 0x0188 + (IS_IMPLEMENTED+DECRYPT_2+ALLOW_TRIAL)), +#endif +#if (PAD_LIST || CC_PolicyGetDigest) + (COMMAND_ATTRIBUTES)(CC_PolicyGetDigest * // 0x0189 + (IS_IMPLEMENTED+ALLOW_TRIAL+ENCRYPT_2)), +#endif +#if (PAD_LIST || CC_TestParms) + (COMMAND_ATTRIBUTES)(CC_TestParms * // 0x018a + (IS_IMPLEMENTED)), +#endif +#if (PAD_LIST || CC_Commit) + (COMMAND_ATTRIBUTES)(CC_Commit * // 0x018b + (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+ENCRYPT_2)), +#endif +#if (PAD_LIST || CC_PolicyPassword) + (COMMAND_ATTRIBUTES)(CC_PolicyPassword * // 0x018c + (IS_IMPLEMENTED+ALLOW_TRIAL)), +#endif +#if (PAD_LIST || CC_ZGen_2Phase) + (COMMAND_ATTRIBUTES)(CC_ZGen_2Phase * // 0x018d + (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+ENCRYPT_2)), +#endif +#if (PAD_LIST || CC_EC_Ephemeral) + (COMMAND_ATTRIBUTES)(CC_EC_Ephemeral * // 0x018e + (IS_IMPLEMENTED+ENCRYPT_2)), +#endif +#if (PAD_LIST || CC_PolicyNvWritten) + (COMMAND_ATTRIBUTES)(CC_PolicyNvWritten * // 0x018f + (IS_IMPLEMENTED+ALLOW_TRIAL)), +#endif +#if (PAD_LIST || CC_PolicyTemplate) + (COMMAND_ATTRIBUTES)(CC_PolicyTemplate * // 0x0190 + (IS_IMPLEMENTED+DECRYPT_2+ALLOW_TRIAL)), +#endif +#if (PAD_LIST || CC_CreateLoaded) + (COMMAND_ATTRIBUTES)(CC_CreateLoaded * // 0x0191 + (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+PP_COMMAND+ENCRYPT_2+R_HANDLE)), +#endif +#if (PAD_LIST || CC_PolicyAuthorizeNV) + (COMMAND_ATTRIBUTES)(CC_PolicyAuthorizeNV * // 0x0192 + (IS_IMPLEMENTED+HANDLE_1_USER+ALLOW_TRIAL)), +#endif +#if (PAD_LIST || CC_EncryptDecrypt2) + (COMMAND_ATTRIBUTES)(CC_EncryptDecrypt2 * // 0x0193 + (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+ENCRYPT_2)), +#endif + +#if (PAD_LIST || CC_Vendor_TCG_Test) + (COMMAND_ATTRIBUTES)(CC_Vendor_TCG_Test * // 0x0000 + (IS_IMPLEMENTED+DECRYPT_2+ENCRYPT_2)), +#endif + +#ifdef TPM_NUVOTON +#if (PAD_LIST || CC_NTC2_PreConfig) + (COMMAND_ATTRIBUTES)(CC_NTC2_PreConfig * // 0x20000211 + (IS_IMPLEMENTED+NO_SESSIONS)), +#endif +#if (PAD_LIST || CC_NTC2_LockPreConfig) + (COMMAND_ATTRIBUTES)(CC_NTC2_LockPreConfig * // 0x20000212 + (IS_IMPLEMENTED+NO_SESSIONS)), +#endif +#if (PAD_LIST || CC_NTC2_GetConfig) + (COMMAND_ATTRIBUTES)(CC_NTC2_GetConfig * // 0x20000213 + (IS_IMPLEMENTED+NO_SESSIONS)), +#endif +#endif + + 0 +}; diff --git a/libstb/tss2/CommandAttributes.h b/libstb/tss2/CommandAttributes.h new file mode 100644 index 0000000..94bd87a --- /dev/null +++ b/libstb/tss2/CommandAttributes.h @@ -0,0 +1,107 @@ +/********************************************************************************/ +/* */ +/* Command Attributes */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: CommandAttributes.h 1289 2018-07-30 16:31:47Z 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, 2012-2018 */ +/* */ +/********************************************************************************/ + +#ifndef COMMANDATTRIBUTES_H +#define COMMANDATTRIBUTES_H + +#include <ibmtss/TPM_Types.h> + +#define IS_IMPLEMENTED 0x0001 +#define HANDLE_1_USER 0x0002 +#define HANDLE_1_ADMIN 0x0004 +#define HANDLE_1_DUP 0x0008 +#define HANDLE_2_USER 0x0010 +#define PP_COMMAND 0x0020 +#define PP_REQUIRED 0x0040 +#define ALLOW_TRIAL 0x0080 +#define NO_SESSIONS 0x0100 +#define DECRYPT_2 0x0200 +#define DECRYPT_4 0x0400 +#define ENCRYPT_2 0x0800 +#define ENCRYPT_4 0x1000 +#define R_HANDLE 0x2000 + +typedef UINT32 COMMAND_ATTRIBUTES; + +typedef union { + struct { + uint32_t commandCode; + uint8_t reserved1; + uint8_t nv; + uint8_t extensive; + uint8_t flushed; + uint8_t cHandles; + uint8_t rHandle; + uint8_t V; + uint8_t tpm12Ordinal; /* kgold - was reserved, flags TPM 1.2 ordinal */ + }; + /* must be a union so the below 'bitfield' structure intiializer works */ + uint8_t dummy; +} TPMA_CC_TSS; + +extern const TPMA_CC_TSS s_ccAttr []; +#ifdef TPM_TPM12 +extern const TPMA_CC_TSS s_ccAttr12 []; +#endif + +extern const COMMAND_ATTRIBUTES s_commandAttributes []; + +#endif diff --git a/libstb/tss2/Commands.c b/libstb/tss2/Commands.c new file mode 100644 index 0000000..f520ad4 --- /dev/null +++ b/libstb/tss2/Commands.c @@ -0,0 +1,2261 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: Commands.c 1285 2018-07-27 18:33:41Z 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, 2012-2017 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#include "Commands_fp.h" +#include <ibmtss/Parameters.h> + +#include <ibmtss/Unmarshal_fp.h> + +COMMAND_PARAMETERS in; +RESPONSE_PARAMETERS out; + +/* + In_Unmarshal - shared by TPM and TSS +*/ + +TPM_RC +Startup_In_Unmarshal(Startup_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + handles = handles; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM_SU_Unmarshalu(&target->startupType, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_Startup_startupType; + } + } + return rc; +} +TPM_RC +Shutdown_In_Unmarshal(Shutdown_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + handles = handles; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM_SU_Unmarshalu(&target->shutdownType, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_Shutdown_shutdownType; + } + } + return rc; +} +TPM_RC +SelfTest_In_Unmarshal(SelfTest_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + handles = handles; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMI_YES_NO_Unmarshalu(&target->fullTest, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_SelfTest_fullTest; + } + } + return rc; +} +TPM_RC +IncrementalSelfTest_In_Unmarshal(IncrementalSelfTest_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + handles = handles; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPML_ALG_Unmarshalu(&target->toTest, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_IncrementalSelfTest_toTest; + } + } + return rc; +} +TPM_RC +StartAuthSession_In_Unmarshal(StartAuthSession_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + target->tpmKey = handles[0]; + target->bind = handles[1]; + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_NONCE_Unmarshalu(&target->nonceCaller, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_StartAuthSession_nonceCaller; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_ENCRYPTED_SECRET_Unmarshalu(&target->encryptedSalt, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_StartAuthSession_encryptedSalt; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM_SE_Unmarshalu(&target->sessionType, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_StartAuthSession_sessionType; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMT_SYM_DEF_Unmarshalu(&target->symmetric, buffer, size, YES); + if (rc != TPM_RC_SUCCESS) { + rc += RC_StartAuthSession_symmetric; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMI_ALG_HASH_Unmarshalu(&target->authHash, buffer, size, NO); + if (rc != TPM_RC_SUCCESS) { + rc += RC_StartAuthSession_authHash; + } + } + return rc; +} +TPM_RC +PolicyRestart_In_Unmarshal(PolicyRestart_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + buffer = buffer; + size = size; + + if (rc == TPM_RC_SUCCESS) { + target->sessionHandle = handles[0]; + } + return rc; +} +TPM_RC +Create_In_Unmarshal(Create_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + target->parentHandle = handles[0]; + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_SENSITIVE_CREATE_Unmarshalu(&target->inSensitive, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_Create_inSensitive; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_PUBLIC_Unmarshalu(&target->inPublic, buffer, size, NO); + if (rc != TPM_RC_SUCCESS) { + rc += RC_Create_inPublic; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_DATA_Unmarshalu(&target->outsideInfo, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_Create_outsideInfo; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPML_PCR_SELECTION_Unmarshalu(&target->creationPCR, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_Create_creationPCR; + } + } + return rc; +} +TPM_RC +Load_In_Unmarshal(Load_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + target->parentHandle = handles[0]; + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_PRIVATE_Unmarshalu(&target->inPrivate, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_Load_inPrivate; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_PUBLIC_Unmarshalu(&target->inPublic, buffer, size, NO); + if (rc != TPM_RC_SUCCESS) { + rc += RC_Load_inPublic; + } + } + return rc; +} +TPM_RC +LoadExternal_In_Unmarshal(LoadExternal_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + handles = handles; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_SENSITIVE_Unmarshalu(&target->inPrivate, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_LoadExternal_inPrivate; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_PUBLIC_Unmarshalu(&target->inPublic, buffer, size, YES); + if (rc != TPM_RC_SUCCESS) { + rc += RC_LoadExternal_inPublic; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMI_RH_HIERARCHY_Unmarshalu(&target->hierarchy, buffer, size, YES); + if (rc != TPM_RC_SUCCESS) { + rc += RC_LoadExternal_hierarchy; + } + } + return rc; +} + +TPM_RC +ReadPublic_In_Unmarshal(ReadPublic_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + buffer = buffer; + size = size; + + if (rc == TPM_RC_SUCCESS) { + target->objectHandle = handles[0]; + } + return rc; +} +TPM_RC +ActivateCredential_In_Unmarshal(ActivateCredential_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + target->activateHandle = handles[0]; + target->keyHandle = handles[1]; + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_ID_OBJECT_Unmarshalu(&target->credentialBlob, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_ActivateCredential_credentialBlob; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_ENCRYPTED_SECRET_Unmarshalu(&target->secret, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_ActivateCredential_secret; + } + } + return rc; +} +TPM_RC +MakeCredential_In_Unmarshal(MakeCredential_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + target->handle = handles[0]; + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_DIGEST_Unmarshalu(&target->credential, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_MakeCredential_credential; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_NAME_Unmarshalu(&target->objectName, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_MakeCredential_objectName; + } + } + return rc; +} +TPM_RC +Unseal_In_Unmarshal(Unseal_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + buffer = buffer; + size = size; + + if (rc == TPM_RC_SUCCESS) { + target->itemHandle = handles[0]; + } + return rc; +} +TPM_RC +ObjectChangeAuth_In_Unmarshal(ObjectChangeAuth_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + target->objectHandle = handles[0]; + target->parentHandle = handles[1]; + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_AUTH_Unmarshalu(&target->newAuth, buffer, size); + } + return rc; +} +TPM_RC +CreateLoaded_In_Unmarshal(CreateLoaded_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + target->parentHandle = handles[0]; + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_SENSITIVE_CREATE_Unmarshalu(&target->inSensitive, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_Create_inSensitive; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_TEMPLATE_Unmarshalu(&target->inPublic, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_CreateLoaded_inPublic; + } + } + return rc; +} +TPM_RC +Duplicate_In_Unmarshal(Duplicate_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + target->objectHandle = handles[0]; + target->newParentHandle = handles[1]; + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_DATA_Unmarshalu(&target->encryptionKeyIn, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_Duplicate_encryptionKeyIn; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMT_SYM_DEF_OBJECT_Unmarshalu(&target->symmetricAlg, buffer, size, YES); + if (rc != TPM_RC_SUCCESS) { + rc += RC_Duplicate_symmetricAlg; + } + } + return rc; +} +TPM_RC +Rewrap_In_Unmarshal(Rewrap_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + target->oldParent = handles[0]; + target->newParent = handles[1]; + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_PRIVATE_Unmarshalu(&target->inDuplicate, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_Rewrap_inDuplicate; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_NAME_Unmarshalu(&target->name, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_Rewrap_name; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_ENCRYPTED_SECRET_Unmarshalu(&target->inSymSeed, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_Rewrap_inSymSeed; + } + } + return rc; +} +TPM_RC +Import_In_Unmarshal(Import_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + target->parentHandle = handles[0]; + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_DATA_Unmarshalu(&target->encryptionKey, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_PUBLIC_Unmarshalu(&target->objectPublic, buffer, size, NO); + if (rc != TPM_RC_SUCCESS) { + rc += RC_Import_objectPublic; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_PRIVATE_Unmarshalu(&target->duplicate, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_Import_duplicate; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_ENCRYPTED_SECRET_Unmarshalu(&target->inSymSeed, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_Import_inSymSeed; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMT_SYM_DEF_OBJECT_Unmarshalu(&target->symmetricAlg, buffer, size, YES); + if (rc != TPM_RC_SUCCESS) { + rc += RC_Import_symmetricAlg; + } + } + return rc; +} +TPM_RC +RSA_Encrypt_In_Unmarshal(RSA_Encrypt_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + target->keyHandle = handles[0]; + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_PUBLIC_KEY_RSA_Unmarshalu(&target->message, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_RSA_Encrypt_message; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMT_RSA_DECRYPT_Unmarshalu(&target->inScheme, buffer, size, YES); + if (rc != TPM_RC_SUCCESS) { + rc += RC_RSA_Encrypt_inScheme; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_DATA_Unmarshalu(&target->label, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_RSA_Encrypt_label; + } + } + return rc; +} +TPM_RC +RSA_Decrypt_In_Unmarshal(RSA_Decrypt_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + target->keyHandle = handles[0]; + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_PUBLIC_KEY_RSA_Unmarshalu(&target->cipherText, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_RSA_Decrypt_cipherText; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMT_RSA_DECRYPT_Unmarshalu(&target->inScheme, buffer, size, YES); + if (rc != TPM_RC_SUCCESS) { + rc += RC_RSA_Decrypt_inScheme; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_DATA_Unmarshalu(&target->label, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_RSA_Decrypt_label; + } + } + return rc; +} +TPM_RC +ECDH_KeyGen_In_Unmarshal(ECDH_KeyGen_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + buffer = buffer; + size = size; + + if (rc == TPM_RC_SUCCESS) { + target->keyHandle = handles[0]; + } + return rc; +} +TPM_RC +ECDH_ZGen_In_Unmarshal(ECDH_ZGen_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + target->keyHandle = handles[0]; + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_ECC_POINT_Unmarshalu(&target->inPoint, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_ECDH_ZGen_inPoint; + } + } + return rc; +} +TPM_RC +ECC_Parameters_In_Unmarshal(ECC_Parameters_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + handles = handles; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMI_ECC_CURVE_Unmarshalu(&target->curveID, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_ECC_Parameters_curveID; + } + } + return rc; +} +TPM_RC +ZGen_2Phase_In_Unmarshal(ZGen_2Phase_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + target->keyA = handles[0]; + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_ECC_POINT_Unmarshalu(&target->inQsB, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_ZGen_2Phase_inQsB; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_ECC_POINT_Unmarshalu(&target->inQeB, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_ZGen_2Phase_inQeB; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMI_ECC_KEY_EXCHANGE_Unmarshalu(&target->inScheme, buffer, size, NO); + if (rc != TPM_RC_SUCCESS) { + rc += RC_ZGen_2Phase_inScheme; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_UINT16_Unmarshalu(&target->counter, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_ZGen_2Phase_counter; + } + } + return rc; +} +TPM_RC +EncryptDecrypt_In_Unmarshal(EncryptDecrypt_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + target->keyHandle = handles[0]; + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMI_YES_NO_Unmarshalu(&target->decrypt, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_EncryptDecrypt_decrypt; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMI_ALG_SYM_MODE_Unmarshalu(&target->mode, buffer, size, YES); + if (rc != TPM_RC_SUCCESS) { + rc += RC_EncryptDecrypt_mode; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_IV_Unmarshalu(&target->ivIn, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_EncryptDecrypt_ivIn; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_MAX_BUFFER_Unmarshalu(&target->inData, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_EncryptDecrypt_inData; + } + } + return rc; +} +TPM_RC +EncryptDecrypt2_In_Unmarshal(EncryptDecrypt2_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + target->keyHandle = handles[0]; + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_MAX_BUFFER_Unmarshalu(&target->inData, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_EncryptDecrypt2_inData; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMI_YES_NO_Unmarshalu(&target->decrypt, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_EncryptDecrypt2_decrypt; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMI_ALG_SYM_MODE_Unmarshalu(&target->mode, buffer, size, YES); + if (rc != TPM_RC_SUCCESS) { + rc += RC_EncryptDecrypt2_mode; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_IV_Unmarshalu(&target->ivIn, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_EncryptDecrypt2_ivIn; + } + } + return rc; +} +TPM_RC +Hash_In_Unmarshal(Hash_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + handles = handles; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_MAX_BUFFER_Unmarshalu(&target->data, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_Hash_data; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMI_ALG_HASH_Unmarshalu(&target->hashAlg, buffer, size, NO); + if (rc != TPM_RC_SUCCESS) { + rc += RC_Hash_hashAlg; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMI_RH_HIERARCHY_Unmarshalu(&target->hierarchy, buffer, size, YES); + if (rc != TPM_RC_SUCCESS) { + rc += RC_Hash_hierarchy; + } + } + return rc; +} +TPM_RC +HMAC_In_Unmarshal(HMAC_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + target->handle = handles[0]; + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_MAX_BUFFER_Unmarshalu(&target->buffer, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_HMAC_buffer; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMI_ALG_HASH_Unmarshalu(&target->hashAlg, buffer, size, YES); + if (rc != TPM_RC_SUCCESS) { + rc += RC_HMAC_hashAlg; + } + } + return rc; +} +TPM_RC +GetRandom_In_Unmarshal(GetRandom_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + handles = handles; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_UINT16_Unmarshalu(&target->bytesRequested, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_GetRandom_bytesRequested; + } + } + return rc; +} +TPM_RC +StirRandom_In_Unmarshal(StirRandom_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + handles = handles; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_SENSITIVE_DATA_Unmarshalu(&target->inData, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_StirRandom_inData; + } + } + return rc; +} +TPM_RC +HMAC_Start_In_Unmarshal(HMAC_Start_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + target->handle = handles[0]; + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_AUTH_Unmarshalu(&target->auth, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_HMAC_Start_auth; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMI_ALG_HASH_Unmarshalu(&target->hashAlg, buffer, size, YES); + if (rc != TPM_RC_SUCCESS) { + rc += RC_HMAC_Start_hashAlg; + } + } + return rc; +} +TPM_RC +HashSequenceStart_In_Unmarshal(HashSequenceStart_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + handles = handles; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_AUTH_Unmarshalu(&target->auth, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_HashSequenceStart_auth; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMI_ALG_HASH_Unmarshalu(&target->hashAlg, buffer, size, YES); + if (rc != TPM_RC_SUCCESS) { + rc += RC_HashSequenceStart_hashAlg; + } + } + return rc; +} +TPM_RC +SequenceUpdate_In_Unmarshal(SequenceUpdate_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + buffer = buffer; + size = size; + + if (rc == TPM_RC_SUCCESS) { + target->sequenceHandle = handles[0]; + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_MAX_BUFFER_Unmarshalu(&target->buffer, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_SequenceUpdate_buffer; + } + } + return rc; +} +TPM_RC +SequenceComplete_In_Unmarshal(SequenceComplete_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + target->sequenceHandle = handles[0]; + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_MAX_BUFFER_Unmarshalu(&target->buffer, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_SequenceComplete_buffer; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMI_RH_HIERARCHY_Unmarshalu(&target->hierarchy, buffer, size, YES); + if (rc != TPM_RC_SUCCESS) { + rc += RC_SequenceComplete_hierarchy; + } + } + return rc; +} +TPM_RC +EventSequenceComplete_In_Unmarshal(EventSequenceComplete_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + target->pcrHandle = handles[0]; + target->sequenceHandle = handles[1]; + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_MAX_BUFFER_Unmarshalu(&target->buffer, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_EventSequenceComplete_buffer; + } + } + return rc; +} +TPM_RC +Certify_In_Unmarshal(Certify_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + target->objectHandle = handles[0]; + target->signHandle = handles[1]; + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_DATA_Unmarshalu(&target->qualifyingData, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_Certify_qualifyingData; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMT_SIG_SCHEME_Unmarshalu(&target->inScheme, buffer, size, YES); + if (rc != TPM_RC_SUCCESS) { + rc += RC_Certify_inScheme; + } + } + return rc; +} +TPM_RC +CertifyCreation_In_Unmarshal(CertifyCreation_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + target->signHandle = handles[0]; + target->objectHandle = handles[1]; + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_DATA_Unmarshalu(&target->qualifyingData, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_CertifyCreation_creationHash; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_DIGEST_Unmarshalu(&target->creationHash, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_CertifyCreation_creationHash; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMT_SIG_SCHEME_Unmarshalu(&target->inScheme, buffer, size, YES); + if (rc != TPM_RC_SUCCESS) { + rc += RC_CertifyCreation_inScheme; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMT_TK_CREATION_Unmarshalu(&target->creationTicket, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_CertifyCreation_creationTicket; + } + } + return rc; +} +TPM_RC +Quote_In_Unmarshal(Quote_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + target->signHandle = handles[0]; + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_DATA_Unmarshalu(&target->qualifyingData, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_Quote_qualifyingData; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMT_SIG_SCHEME_Unmarshalu(&target->inScheme, buffer, size, YES); + if (rc != TPM_RC_SUCCESS) { + rc += RC_Quote_inScheme; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPML_PCR_SELECTION_Unmarshalu(&target->PCRselect, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_Quote_PCRselect; + } + } + return rc; +} +TPM_RC +GetSessionAuditDigest_In_Unmarshal(GetSessionAuditDigest_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + target->privacyAdminHandle = handles[0]; + target->signHandle = handles[1]; + target->sessionHandle = handles[2]; + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_DATA_Unmarshalu(&target->qualifyingData, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_GetSessionAuditDigest_qualifyingData; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMT_SIG_SCHEME_Unmarshalu(&target->inScheme, buffer, size, YES); + if (rc != TPM_RC_SUCCESS) { + rc += RC_GetSessionAuditDigest_inScheme; + } + } + return rc; +} +TPM_RC +GetCommandAuditDigest_In_Unmarshal(GetCommandAuditDigest_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + target->privacyHandle = handles[0]; + target->signHandle = handles[1]; + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_DATA_Unmarshalu(&target->qualifyingData, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_GetCommandAuditDigest_qualifyingData; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMT_SIG_SCHEME_Unmarshalu(&target->inScheme, buffer, size, YES); + if (rc != TPM_RC_SUCCESS) { + rc += RC_GetCommandAuditDigest_inScheme; + } + } + return rc; +} +TPM_RC +GetTime_In_Unmarshal(GetTime_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + target->privacyAdminHandle = handles[0]; + target->signHandle = handles[1]; + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_DATA_Unmarshalu(&target->qualifyingData, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_GetTime_qualifyingData; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMT_SIG_SCHEME_Unmarshalu(&target->inScheme, buffer, size, YES); + if (rc != TPM_RC_SUCCESS) { + rc += RC_GetTime_inScheme; + } + } + return rc; +} +TPM_RC +Commit_In_Unmarshal(Commit_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + target->signHandle = handles[0]; + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_ECC_POINT_Unmarshalu(&target->P1, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_Commit_P1; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_SENSITIVE_DATA_Unmarshalu(&target->s2, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_Commit_s2; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_ECC_PARAMETER_Unmarshalu(&target->y2, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_Commit_y2; + } + } + return rc; +} +TPM_RC +EC_Ephemeral_In_Unmarshal(EC_Ephemeral_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + handles = handles; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMI_ECC_CURVE_Unmarshalu(&target->curveID, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_EC_Ephemeral_curveID; + } + } + return rc; +} +TPM_RC +VerifySignature_In_Unmarshal(VerifySignature_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + target->keyHandle = handles[0]; + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_DIGEST_Unmarshalu(&target->digest, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_VerifySignature_digest; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMT_SIGNATURE_Unmarshalu(&target->signature, buffer, size, NO); + if (rc != TPM_RC_SUCCESS) { + rc += RC_VerifySignature_signature; + } + } + return rc; +} +TPM_RC +Sign_In_Unmarshal(Sign_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + target->keyHandle = handles[0]; + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_DIGEST_Unmarshalu(&target->digest, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_Sign_digest; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMT_SIG_SCHEME_Unmarshalu(&target->inScheme, buffer, size, YES); + if (rc != TPM_RC_SUCCESS) { + rc += RC_Sign_inScheme; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMT_TK_HASHCHECK_Unmarshalu(&target->validation, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_Sign_validation; + } + } + return rc; +} +TPM_RC +SetCommandCodeAuditStatus_In_Unmarshal(SetCommandCodeAuditStatus_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + target->auth = handles[0]; + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMI_ALG_HASH_Unmarshalu(&target->auditAlg, buffer, size, YES); + if (rc != TPM_RC_SUCCESS) { + rc += RC_SetCommandCodeAuditStatus_auditAlg; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPML_CC_Unmarshalu(&target->setList, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_SetCommandCodeAuditStatus_setList; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPML_CC_Unmarshalu(&target->clearList, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_SetCommandCodeAuditStatus_clearList; + } + } + return rc; +} +TPM_RC +PCR_Extend_In_Unmarshal(PCR_Extend_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + target->pcrHandle = handles[0]; + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPML_DIGEST_VALUES_Unmarshalu(&target->digests, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_PCR_Extend_digests; + } + } + return rc; +} +TPM_RC +PCR_Event_In_Unmarshal(PCR_Event_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + target->pcrHandle = handles[0]; + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_EVENT_Unmarshalu(&target->eventData, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_PCR_Event_eventData; + } + } + return rc; +} +TPM_RC +PCR_Read_In_Unmarshal(PCR_Read_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + handles = handles; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPML_PCR_SELECTION_Unmarshalu(&target->pcrSelectionIn, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_PCR_Read_pcrSelectionIn; + } + } + return rc; +} +TPM_RC +PCR_Allocate_In_Unmarshal(PCR_Allocate_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + target->authHandle = handles[0]; + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPML_PCR_SELECTION_Unmarshalu(&target->pcrAllocation, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_PCR_Allocate_pcrAllocation; + } + } + return rc; +} +TPM_RC +PCR_SetAuthPolicy_In_Unmarshal(PCR_SetAuthPolicy_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + target->authHandle = handles[0]; + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_DIGEST_Unmarshalu(&target->authPolicy, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_PCR_SetAuthPolicy_authPolicy; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMI_ALG_HASH_Unmarshalu(&target->hashAlg, buffer, size, YES); + if (rc != TPM_RC_SUCCESS) { + rc += RC_PCR_SetAuthPolicy_hashAlg; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMI_DH_PCR_Unmarshalu(&target->pcrNum, buffer, size, NO); + if (rc != TPM_RC_SUCCESS) { + rc += RC_PCR_SetAuthPolicy_pcrNum; + } + } + return rc; +} +TPM_RC +PCR_SetAuthValue_In_Unmarshal(PCR_SetAuthValue_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + target->pcrHandle = handles[0]; + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_DIGEST_Unmarshalu(&target->auth, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_PCR_SetAuthValue_auth; + } + } + return rc; +} +TPM_RC +PCR_Reset_In_Unmarshal(PCR_Reset_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + buffer = buffer; + size = size; + + if (rc == TPM_RC_SUCCESS) { + target->pcrHandle = handles[0]; + } + return rc; +} +TPM_RC +PolicySigned_In_Unmarshal(PolicySigned_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + target->authObject = handles[0]; + target->policySession = handles[1]; + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_NONCE_Unmarshalu(&target->nonceTPM, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_PolicySigned_nonceTPM; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_DIGEST_Unmarshalu(&target->cpHashA, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_PolicySigned_cpHashA; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_NONCE_Unmarshalu(&target->policyRef, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_PolicySigned_policyRef; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_INT32_Unmarshalu(&target->expiration, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_PolicySigned_expiration; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMT_SIGNATURE_Unmarshalu(&target->auth, buffer, size, NO); + if (rc != TPM_RC_SUCCESS) { + rc += RC_PolicySigned_auth; + } + } + return rc; +} +TPM_RC +PolicySecret_In_Unmarshal(PolicySecret_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + target->authHandle = handles[0]; + target->policySession = handles[1]; + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_NONCE_Unmarshalu(&target->nonceTPM, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_PolicySecret_nonceTPM; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_DIGEST_Unmarshalu(&target->cpHashA, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_PolicySecret_cpHashA; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_NONCE_Unmarshalu(&target->policyRef, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_PolicySecret_policyRef; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_INT32_Unmarshalu(&target->expiration, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_PolicySecret_expiration; + } + } + return rc; +} +TPM_RC +PolicyTicket_In_Unmarshal(PolicyTicket_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + target->policySession = handles[0]; + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_TIMEOUT_Unmarshalu(&target->timeout, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_PolicyTicket_timeout; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_DIGEST_Unmarshalu(&target->cpHashA, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_PolicyTicket_cpHashA; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_NONCE_Unmarshalu(&target->policyRef, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_PolicyTicket_policyRef; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_NAME_Unmarshalu(&target->authName, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_PolicyTicket_authName; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMT_TK_AUTH_Unmarshalu(&target->ticket, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_PolicyTicket_ticket; + } + } + return rc; +} +TPM_RC +PolicyOR_In_Unmarshal(PolicyOR_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + target->policySession = handles[0]; + } + if (rc == TPM_RC_SUCCESS) { + /* Policy OR requires at least two OR terms */ + rc = TSS_TPML_DIGEST_Unmarshalu(&target->pHashList, buffer, size, 2); + if (rc != TPM_RC_SUCCESS) { + rc += RC_PolicyOR_pHashList; + } + } + return rc; +} +TPM_RC +PolicyPCR_In_Unmarshal(PolicyPCR_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + target->policySession = handles[0]; + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_DIGEST_Unmarshalu(&target->pcrDigest, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_PolicyPCR_pcrDigest; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPML_PCR_SELECTION_Unmarshalu(&target->pcrs, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_PolicyPCR_pcrs; + } + } + return rc; +} +TPM_RC +PolicyLocality_In_Unmarshal(PolicyLocality_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + target->policySession = handles[0]; + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMA_LOCALITY_Unmarshalu(&target->locality, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_PolicyLocality_locality; + } + } + return rc; +} +TPM_RC +PolicyNV_In_Unmarshal(PolicyNV_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + target->authHandle = handles[0]; + target->nvIndex = handles[1]; + target->policySession = handles[2]; + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_OPERAND_Unmarshalu(&target->operandB, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_PolicyNV_operandB; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_UINT16_Unmarshalu(&target->offset, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_PolicyNV_offset; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM_EO_Unmarshalu(&target->operation, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_PolicyNV_operation; + } + } + return rc; +} +TPM_RC +PolicyAuthorizeNV_In_Unmarshal(PolicyAuthorizeNV_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + buffer = buffer; + size = size; + + if (rc == TPM_RC_SUCCESS) { + target->authHandle = handles[0]; + target->nvIndex = handles[1]; + target->policySession = handles[2]; + } + return rc; +} +TPM_RC +PolicyCounterTimer_In_Unmarshal(PolicyCounterTimer_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + target->policySession = handles[0]; + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_OPERAND_Unmarshalu(&target->operandB, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_PolicyCounterTimer_operandB; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_UINT16_Unmarshalu(&target->offset, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_PolicyCounterTimer_offset; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM_EO_Unmarshalu(&target->operation, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_PolicyCounterTimer_operation; + } + } + return rc; +} +TPM_RC +PolicyCommandCode_In_Unmarshal(PolicyCommandCode_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + target->policySession = handles[0]; + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM_CC_Unmarshalu(&target->code, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_PolicyCommandCode_code; + } + } + return rc; +} +TPM_RC +PolicyPhysicalPresence_In_Unmarshal(PolicyPhysicalPresence_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + buffer = buffer; + size = size; + + if (rc == TPM_RC_SUCCESS) { + target->policySession = handles[0]; + } + return rc; +} +TPM_RC +PolicyCpHash_In_Unmarshal(PolicyCpHash_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + target->policySession = handles[0]; + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_DIGEST_Unmarshalu(&target->cpHashA, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_PolicyCpHash_cpHashA; + } + } + return rc; +} +TPM_RC +PolicyNameHash_In_Unmarshal(PolicyNameHash_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + target->policySession = handles[0]; + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_DIGEST_Unmarshalu(&target->nameHash, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_PolicyNameHash_nameHash; + } + } + return rc; +} +TPM_RC +PolicyDuplicationSelect_In_Unmarshal(PolicyDuplicationSelect_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + target->policySession = handles[0]; + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_NAME_Unmarshalu(&target->objectName, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_PolicyDuplicationSelect_objectName; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_NAME_Unmarshalu(&target->newParentName, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_PolicyDuplicationSelect_newParentName; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMI_YES_NO_Unmarshalu(&target->includeObject, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_PolicyDuplicationSelect_includeObject; + } + } + return rc; +} +TPM_RC +PolicyAuthorize_In_Unmarshal(PolicyAuthorize_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + target->policySession = handles[0]; + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_DIGEST_Unmarshalu(&target->approvedPolicy, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_PolicyAuthorize_approvedPolicy; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_NONCE_Unmarshalu(&target->policyRef, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_PolicyAuthorize_policyRef; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_NAME_Unmarshalu(&target->keySign, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_PolicyAuthorize_keySign; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMT_TK_VERIFIED_Unmarshalu(&target->checkTicket, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_PolicyAuthorize_checkTicket; + } + } + return rc; +} +TPM_RC +PolicyAuthValue_In_Unmarshal(PolicyAuthValue_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + buffer = buffer; + size = size; + + if (rc == TPM_RC_SUCCESS) { + target->policySession = handles[0]; + } + return rc; +} +TPM_RC +PolicyPassword_In_Unmarshal(PolicyPassword_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + buffer = buffer; + size = size; + + if (rc == TPM_RC_SUCCESS) { + target->policySession = handles[0]; + } + return rc; +} +TPM_RC +PolicyGetDigest_In_Unmarshal(PolicyGetDigest_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + buffer = buffer; + size = size; + + if (rc == TPM_RC_SUCCESS) { + target->policySession = handles[0]; + } + return rc; +} +TPM_RC +PolicyNvWritten_In_Unmarshal(PolicyNvWritten_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + target->policySession = handles[0]; + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMI_YES_NO_Unmarshalu(&target->writtenSet, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_PolicyNvWritten_writtenSet; + } + } + return rc; +} +TPM_RC +PolicyTemplate_In_Unmarshal(PolicyTemplate_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + buffer = buffer; + size = size; + + if (rc == TPM_RC_SUCCESS) { + target->policySession = handles[0]; + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_DIGEST_Unmarshalu(&target->templateHash, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_PolicyTemplate_templateHash; + } + } + return rc; +} +TPM_RC +CreatePrimary_In_Unmarshal(CreatePrimary_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + target->primaryHandle = handles[0]; + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_SENSITIVE_CREATE_Unmarshalu(&target->inSensitive, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_CreatePrimary_inSensitive; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_PUBLIC_Unmarshalu(&target->inPublic, buffer, size, NO); + if (rc != TPM_RC_SUCCESS) { + rc += RC_CreatePrimary_inPublic; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_DATA_Unmarshalu(&target->outsideInfo, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_CreatePrimary_outsideInfo; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPML_PCR_SELECTION_Unmarshalu(&target->creationPCR, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_CreatePrimary_creationPCR; + } + } + return rc; +} +TPM_RC +HierarchyControl_In_Unmarshal(HierarchyControl_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + target->authHandle = handles[0]; + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMI_RH_ENABLES_Unmarshalu(&target->enable, buffer, size, NO); + if (rc != TPM_RC_SUCCESS) { + rc += RC_HierarchyControl_enable; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMI_YES_NO_Unmarshalu(&target->state, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_HierarchyControl_state; + } + } + return rc; +} +TPM_RC +SetPrimaryPolicy_In_Unmarshal(SetPrimaryPolicy_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + target->authHandle = handles[0]; + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_DIGEST_Unmarshalu(&target->authPolicy, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_SetPrimaryPolicy_authPolicy; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMI_ALG_HASH_Unmarshalu(&target->hashAlg, buffer, size, YES); + if (rc != TPM_RC_SUCCESS) { + rc += RC_SetPrimaryPolicy_hashAlg; + } + } + return rc; +} +TPM_RC +ChangePPS_In_Unmarshal(ChangePPS_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + buffer = buffer; + size = size; + + if (rc == TPM_RC_SUCCESS) { + target->authHandle = handles[0]; + } + return rc; +} +TPM_RC +ChangeEPS_In_Unmarshal(ChangeEPS_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + buffer = buffer; + size = size; + + if (rc == TPM_RC_SUCCESS) { + target->authHandle = handles[0]; + } + return rc; +} +TPM_RC +Clear_In_Unmarshal(Clear_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + buffer = buffer; + size = size; + + if (rc == TPM_RC_SUCCESS) { + target->authHandle = handles[0]; + } + return rc; +} +TPM_RC +ClearControl_In_Unmarshal(ClearControl_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + target->auth = handles[0]; + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMI_YES_NO_Unmarshalu(&target->disable, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_ClearControl_disable; + } + } + return rc; +} +TPM_RC +HierarchyChangeAuth_In_Unmarshal(HierarchyChangeAuth_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + target->authHandle = handles[0]; + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_AUTH_Unmarshalu(&target->newAuth, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_HierarchyChangeAuth_newAuth; + } + } + return rc; +} +TPM_RC +DictionaryAttackLockReset_In_Unmarshal(DictionaryAttackLockReset_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + buffer = buffer; + size = size; + + if (rc == TPM_RC_SUCCESS) { + target->lockHandle = handles[0]; + } + return rc; +} +TPM_RC +DictionaryAttackParameters_In_Unmarshal(DictionaryAttackParameters_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + target->lockHandle = handles[0]; + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_UINT32_Unmarshalu(&target->newMaxTries, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_DictionaryAttackParameters_newMaxTries; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_UINT32_Unmarshalu(&target->newRecoveryTime, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_DictionaryAttackParameters_newRecoveryTime; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_UINT32_Unmarshalu(&target->lockoutRecovery, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_DictionaryAttackParameters_lockoutRecovery; + } + } + return rc; +} +TPM_RC +PP_Commands_In_Unmarshal(PP_Commands_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + target->auth = handles[0]; + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPML_CC_Unmarshalu(&target->setList, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_PP_Commands_setList; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPML_CC_Unmarshalu(&target->clearList, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_PP_Commands_clearList; + } + } + return rc; +} +TPM_RC +SetAlgorithmSet_In_Unmarshal(SetAlgorithmSet_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + target->authHandle = handles[0]; + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_UINT32_Unmarshalu(&target->algorithmSet, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_SetAlgorithmSet_algorithmSet; + } + } + return rc; +} +TPM_RC +ContextSave_In_Unmarshal(ContextSave_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + buffer = buffer; + size = size; + + if (rc == TPM_RC_SUCCESS) { + target->saveHandle = handles[0]; + } + return rc; +} +TPM_RC +ContextLoad_In_Unmarshal(ContextLoad_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + handles = handles; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMS_CONTEXT_Unmarshalu(&target->context, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_ContextLoad_context; + } + } + return rc; +} +TPM_RC +FlushContext_In_Unmarshal(FlushContext_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + handles = handles; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMI_DH_CONTEXT_Unmarshalu(&target->flushHandle, buffer, size, NO); + if (rc != TPM_RC_SUCCESS) { + rc += RC_FlushContext_flushHandle; + } + } + return rc; +} +TPM_RC +EvictControl_In_Unmarshal(EvictControl_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + target->auth = handles[0]; + target->objectHandle = handles[1]; + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMI_DH_PERSISTENT_Unmarshalu(&target->persistentHandle, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_EvictControl_persistentHandle; + } + } + return rc; +} +TPM_RC +ClockSet_In_Unmarshal(ClockSet_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + target->auth = handles[0]; + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_UINT64_Unmarshalu(&target->newTime, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_ClockSet_newTime; + } + } + return rc; +} +TPM_RC +ClockRateAdjust_In_Unmarshal(ClockRateAdjust_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + target->auth = handles[0]; + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM_CLOCK_ADJUST_Unmarshalu(&target->rateAdjust, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_ClockRateAdjust_rateAdjust; + } + } + return rc; +} +TPM_RC +GetCapability_In_Unmarshal(GetCapability_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + handles = handles; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM_CAP_Unmarshalu(&target->capability, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_GetCapability_capability; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_UINT32_Unmarshalu(&target->property, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_GetCapability_property; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_UINT32_Unmarshalu(&target->propertyCount, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_GetCapability_propertyCount; + } + } + return rc; +} +TPM_RC +TestParms_In_Unmarshal(TestParms_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + handles = handles; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMT_PUBLIC_PARMS_Unmarshalu(&target->parameters, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_TestParms_parameters; + } + } + return rc; +} +TPM_RC +NV_DefineSpace_In_Unmarshal(NV_DefineSpace_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + target->authHandle = handles[0]; + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_AUTH_Unmarshalu(&target->auth, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_NV_DefineSpace_auth; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_NV_PUBLIC_Unmarshalu(&target->publicInfo, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_NV_DefineSpace_publicInfo; + } + } + return rc; +} +TPM_RC +NV_UndefineSpace_In_Unmarshal(NV_UndefineSpace_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + buffer = buffer; + size = size; + + if (rc == TPM_RC_SUCCESS) { + target->authHandle = handles[0]; + target->nvIndex = handles[1]; + } + return rc; +} +TPM_RC +NV_UndefineSpaceSpecial_In_Unmarshal(NV_UndefineSpaceSpecial_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + buffer = buffer; + size = size; + + if (rc == TPM_RC_SUCCESS) { + target->nvIndex = handles[0]; + target->platform = handles[1]; + } + return rc; +} +TPM_RC +NV_ReadPublic_In_Unmarshal(NV_ReadPublic_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + buffer = buffer; + size = size; + + if (rc == TPM_RC_SUCCESS) { + target->nvIndex = handles[0]; + } + return rc; +} +TPM_RC +NV_Write_In_Unmarshal(NV_Write_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + target->authHandle = handles[0]; + target->nvIndex = handles[1]; + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_MAX_NV_BUFFER_Unmarshalu(&target->data, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_NV_Write_data; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_UINT16_Unmarshalu(&target->offset, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_NV_Write_offset; + } + } + return rc; +} +TPM_RC +NV_Increment_In_Unmarshal(NV_Increment_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + buffer = buffer; + size = size; + + if (rc == TPM_RC_SUCCESS) { + target->authHandle = handles[0]; + target->nvIndex = handles[1]; + } + return rc; +} +TPM_RC +NV_Extend_In_Unmarshal(NV_Extend_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + target->authHandle = handles[0]; + target->nvIndex = handles[1]; + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_MAX_NV_BUFFER_Unmarshalu(&target->data, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_NV_Extend_data; + } + } + return rc; +} +TPM_RC +NV_SetBits_In_Unmarshal(NV_SetBits_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + target->authHandle = handles[0]; + target->nvIndex = handles[1]; + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_UINT64_Unmarshalu(&target->bits, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_NV_SetBits_bits; + } + } + return rc; +} +TPM_RC +NV_WriteLock_In_Unmarshal(NV_WriteLock_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + buffer = buffer; + size = size; + + if (rc == TPM_RC_SUCCESS) { + target->authHandle = handles[0]; + target->nvIndex = handles[1]; + } + return rc; +} +TPM_RC +NV_GlobalWriteLock_In_Unmarshal(NV_GlobalWriteLock_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + buffer = buffer; + size = size; + + if (rc == TPM_RC_SUCCESS) { + target->authHandle = handles[0]; + } + return rc; +} +TPM_RC +NV_Read_In_Unmarshal(NV_Read_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + target->authHandle = handles[0]; + target->nvIndex = handles[1]; + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_UINT16_Unmarshalu(&target->size, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_NV_Read_size; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_UINT16_Unmarshalu(&target->offset, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_NV_Read_offset; + } + } + return rc; +} +TPM_RC +NV_ReadLock_In_Unmarshal(NV_ReadLock_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + buffer = buffer; + size = size; + + if (rc == TPM_RC_SUCCESS) { + target->authHandle = handles[0]; + target->nvIndex = handles[1]; + } + return rc; +} +TPM_RC +NV_ChangeAuth_In_Unmarshal(NV_ChangeAuth_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + target->nvIndex = handles[0]; + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_AUTH_Unmarshalu(&target->newAuth, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_NV_ChangeAuth_newAuth; + } + } + return rc; +} +TPM_RC +NV_Certify_In_Unmarshal(NV_Certify_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + target->signHandle = handles[0]; + target->authHandle = handles[1]; + target->nvIndex = handles[2]; + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_DATA_Unmarshalu(&target->qualifyingData, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_NV_Certify_qualifyingData; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMT_SIG_SCHEME_Unmarshalu(&target->inScheme, buffer, size, YES); + if (rc != TPM_RC_SUCCESS) { + rc += RC_NV_Certify_inScheme; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_UINT16_Unmarshalu(&target->size, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_NV_Certify_size; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_UINT16_Unmarshalu(&target->offset, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_NV_Certify_offset; + } + } + return rc; +} diff --git a/libstb/tss2/Commands_fp.h b/libstb/tss2/Commands_fp.h new file mode 100644 index 0000000..ddb9e27 --- /dev/null +++ b/libstb/tss2/Commands_fp.h @@ -0,0 +1,499 @@ +/********************************************************************************/ +/* */ +/* Command and Response Marshal and Unmarshal */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: Commands_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2017 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef COMMANDS_FP_H +#define COMMANDS_FP_H + +#include <ibmtss/TPM_Types.h> + +#include <ibmtss/ActivateCredential_fp.h> +#include <ibmtss/CertifyCreation_fp.h> +#include <ibmtss/Certify_fp.h> +#include <ibmtss/ChangeEPS_fp.h> +#include <ibmtss/ChangePPS_fp.h> +#include <ibmtss/ClearControl_fp.h> +#include <ibmtss/Clear_fp.h> +#include <ibmtss/ClockRateAdjust_fp.h> +#include <ibmtss/ClockSet_fp.h> +#include <ibmtss/Commit_fp.h> +#include <ibmtss/ContextLoad_fp.h> +#include <ibmtss/ContextSave_fp.h> +#include <ibmtss/CreatePrimary_fp.h> +#include <ibmtss/Create_fp.h> +#include <ibmtss/CreateLoaded_fp.h> +#include <ibmtss/DictionaryAttackLockReset_fp.h> +#include <ibmtss/DictionaryAttackParameters_fp.h> +#include <ibmtss/Duplicate_fp.h> +#include <ibmtss/ECC_Parameters_fp.h> +#include <ibmtss/ECDH_KeyGen_fp.h> +#include <ibmtss/ECDH_ZGen_fp.h> +#include <ibmtss/EC_Ephemeral_fp.h> +#include <ibmtss/EncryptDecrypt_fp.h> +#include <ibmtss/EncryptDecrypt2_fp.h> +#include <ibmtss/EventSequenceComplete_fp.h> +#include <ibmtss/EvictControl_fp.h> +#include <ibmtss/FlushContext_fp.h> +#include <ibmtss/GetCapability_fp.h> +#include <ibmtss/GetCommandAuditDigest_fp.h> +#include <ibmtss/GetRandom_fp.h> +#include <ibmtss/GetSessionAuditDigest_fp.h> +#include <ibmtss/GetTestResult_fp.h> +#include <ibmtss/GetTime_fp.h> +#include <ibmtss/HMAC_Start_fp.h> +#include <ibmtss/HMAC_fp.h> +#include <ibmtss/HashSequenceStart_fp.h> +#include <ibmtss/Hash_fp.h> +#include <ibmtss/HierarchyChangeAuth_fp.h> +#include <ibmtss/HierarchyControl_fp.h> +#include <ibmtss/Import_fp.h> +#include <ibmtss/IncrementalSelfTest_fp.h> +#include <ibmtss/LoadExternal_fp.h> +#include <ibmtss/Load_fp.h> +#include <ibmtss/MakeCredential_fp.h> +#include <ibmtss/NV_Certify_fp.h> +#include <ibmtss/NV_ChangeAuth_fp.h> +#include <ibmtss/NV_DefineSpace_fp.h> +#include <ibmtss/NV_Extend_fp.h> +#include <ibmtss/NV_GlobalWriteLock_fp.h> +#include <ibmtss/NV_Increment_fp.h> +#include <ibmtss/NV_ReadLock_fp.h> +#include <ibmtss/NV_ReadPublic_fp.h> +#include <ibmtss/NV_Read_fp.h> +#include <ibmtss/NV_SetBits_fp.h> +#include <ibmtss/NV_UndefineSpaceSpecial_fp.h> +#include <ibmtss/NV_UndefineSpace_fp.h> +#include <ibmtss/NV_WriteLock_fp.h> +#include <ibmtss/NV_Write_fp.h> +#include <ibmtss/ObjectChangeAuth_fp.h> +#include <ibmtss/PCR_Allocate_fp.h> +#include <ibmtss/PCR_Event_fp.h> +#include <ibmtss/PCR_Extend_fp.h> +#include <ibmtss/PCR_Read_fp.h> +#include <ibmtss/PCR_Reset_fp.h> +#include <ibmtss/PCR_SetAuthPolicy_fp.h> +#include <ibmtss/PCR_SetAuthValue_fp.h> +#include <ibmtss/PP_Commands_fp.h> +#include <ibmtss/PolicyAuthValue_fp.h> +#include <ibmtss/PolicyAuthorize_fp.h> +#include <ibmtss/PolicyCommandCode_fp.h> +#include <ibmtss/PolicyCounterTimer_fp.h> +#include <ibmtss/PolicyCpHash_fp.h> +#include <ibmtss/PolicyDuplicationSelect_fp.h> +#include <ibmtss/PolicyGetDigest_fp.h> +#include <ibmtss/PolicyLocality_fp.h> +#include <ibmtss/PolicyAuthorizeNV_fp.h> +#include <ibmtss/PolicyNV_fp.h> +#include <ibmtss/PolicyNvWritten_fp.h> +#include <ibmtss/PolicyNameHash_fp.h> +#include <ibmtss/PolicyOR_fp.h> +#include <ibmtss/PolicyPCR_fp.h> +#include <ibmtss/PolicyPassword_fp.h> +#include <ibmtss/PolicyPhysicalPresence_fp.h> +#include <ibmtss/PolicyRestart_fp.h> +#include <ibmtss/PolicySecret_fp.h> +#include <ibmtss/PolicySigned_fp.h> +#include <ibmtss/PolicyTemplate_fp.h> +#include <ibmtss/PolicyTicket_fp.h> +#include <ibmtss/Quote_fp.h> +#include <ibmtss/RSA_Decrypt_fp.h> +#include <ibmtss/RSA_Encrypt_fp.h> +#include <ibmtss/ReadClock_fp.h> +#include <ibmtss/ReadPublic_fp.h> +#include <ibmtss/Rewrap_fp.h> +#include <ibmtss/SelfTest_fp.h> +#include <ibmtss/SequenceComplete_fp.h> +#include <ibmtss/SequenceUpdate_fp.h> +#include <ibmtss/SetAlgorithmSet_fp.h> +#include <ibmtss/SetCommandCodeAuditStatus_fp.h> +#include <ibmtss/SetPrimaryPolicy_fp.h> +#include <ibmtss/Shutdown_fp.h> +#include <ibmtss/Sign_fp.h> +#include <ibmtss/StartAuthSession_fp.h> +#include <ibmtss/Startup_fp.h> +#include <ibmtss/StirRandom_fp.h> +#include <ibmtss/TestParms_fp.h> +#include <ibmtss/Unseal_fp.h> +#include <ibmtss/VerifySignature_fp.h> +#include <ibmtss/ZGen_2Phase_fp.h> +#include <ibmtss/NTC_fp.h> + +TPM_RC +Startup_In_Unmarshal(Startup_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +TPM_RC +Shutdown_In_Unmarshal(Shutdown_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +TPM_RC +SelfTest_In_Unmarshal(SelfTest_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +TPM_RC +IncrementalSelfTest_In_Unmarshal(IncrementalSelfTest_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +UINT16 +IncrementalSelfTest_Out_Marshal(IncrementalSelfTest_Out *source, TPMI_ST_COMMAND_TAG tag, BYTE **buffer, uint32_t *size); +UINT16 +GetTestResult_Out_Marshal(GetTestResult_Out *source, TPMI_ST_COMMAND_TAG tag, BYTE **buffer, uint32_t *size); +TPM_RC +StartAuthSession_In_Unmarshal(StartAuthSession_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +UINT16 +StartAuthSession_Out_Marshal(StartAuthSession_Out *source, TPMI_ST_COMMAND_TAG tag, BYTE **buffer, uint32_t *size); +TPM_RC +PolicyRestart_In_Unmarshal(PolicyRestart_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +TPM_RC +Create_In_Unmarshal(Create_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +UINT16 +Create_Out_Marshal(Create_Out *source, TPMI_ST_COMMAND_TAG tag, BYTE **buffer, uint32_t *size); +TPM_RC +Load_In_Unmarshal(Load_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +UINT16 +Load_Out_Marshal(Load_Out *source, TPMI_ST_COMMAND_TAG tag, BYTE **buffer, uint32_t *size); +TPM_RC +LoadExternal_In_Unmarshal(LoadExternal_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +UINT16 +LoadExternal_Out_Marshal(LoadExternal_Out *source, TPMI_ST_COMMAND_TAG tag, BYTE **buffer, uint32_t *size); +TPM_RC +ReadPublic_In_Unmarshal(ReadPublic_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +UINT16 +ReadPublic_Out_Marshal(ReadPublic_Out *source, TPMI_ST_COMMAND_TAG tag, BYTE **buffer, uint32_t *size); +TPM_RC +ActivateCredential_In_Unmarshal(ActivateCredential_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +UINT16 +ActivateCredential_Out_Marshal(ActivateCredential_Out *source, TPMI_ST_COMMAND_TAG tag, BYTE **buffer, uint32_t *size); +TPM_RC +MakeCredential_In_Unmarshal(MakeCredential_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +UINT16 +MakeCredential_Out_Marshal(MakeCredential_Out *source, TPMI_ST_COMMAND_TAG tag, BYTE **buffer, uint32_t *size); +TPM_RC +Unseal_In_Unmarshal(Unseal_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +UINT16 +Unseal_Out_Marshal(Unseal_Out *source, TPMI_ST_COMMAND_TAG tag, BYTE **buffer, uint32_t *size); +TPM_RC +ObjectChangeAuth_In_Unmarshal(ObjectChangeAuth_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +UINT16 +ObjectChangeAuth_Out_Marshal(ObjectChangeAuth_Out *source, TPMI_ST_COMMAND_TAG tag, BYTE **buffer, uint32_t *size); +TPM_RC +CreateLoaded_In_Unmarshal(CreateLoaded_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +TPM_RC +Duplicate_In_Unmarshal(Duplicate_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +UINT16 +Duplicate_Out_Marshal(Duplicate_Out *source, TPMI_ST_COMMAND_TAG tag, BYTE **buffer, uint32_t *size); +TPM_RC +Rewrap_In_Unmarshal(Rewrap_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +UINT16 +Rewrap_Out_Marshal(Rewrap_Out *source, TPMI_ST_COMMAND_TAG tag, BYTE **buffer, uint32_t *size); +TPM_RC +Import_In_Unmarshal(Import_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +UINT16 +Import_Out_Marshal(Import_Out *source, TPMI_ST_COMMAND_TAG tag, BYTE **buffer, uint32_t *size); +TPM_RC +RSA_Encrypt_In_Unmarshal(RSA_Encrypt_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +UINT16 +RSA_Encrypt_Out_Marshal(RSA_Encrypt_Out *source, TPMI_ST_COMMAND_TAG tag, BYTE **buffer, uint32_t *size); +TPM_RC +RSA_Decrypt_In_Unmarshal(RSA_Decrypt_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +UINT16 +RSA_Decrypt_Out_Marshal(RSA_Decrypt_Out *source, TPMI_ST_COMMAND_TAG tag, BYTE **buffer, uint32_t *size); +TPM_RC +ECDH_KeyGen_In_Unmarshal(ECDH_KeyGen_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +UINT16 +ECDH_KeyGen_Out_Marshal(ECDH_KeyGen_Out *source, TPMI_ST_COMMAND_TAG tag, BYTE **buffer, uint32_t *size); +TPM_RC +ECDH_ZGen_In_Unmarshal(ECDH_ZGen_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +UINT16 +ECDH_ZGen_Out_Marshal(ECDH_ZGen_Out *source, TPMI_ST_COMMAND_TAG tag, BYTE **buffer, uint32_t *size); +TPM_RC +ECC_Parameters_In_Unmarshal(ECC_Parameters_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +UINT16 +ECC_Parameters_Out_Marshal(ECC_Parameters_Out *source, TPMI_ST_COMMAND_TAG tag, BYTE **buffer, uint32_t *size); +TPM_RC +ZGen_2Phase_In_Unmarshal(ZGen_2Phase_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +UINT16 +ZGen_2Phase_Out_Marshal(ZGen_2Phase_Out *source, TPMI_ST_COMMAND_TAG tag, BYTE **buffer, uint32_t *size); +TPM_RC +EncryptDecrypt_In_Unmarshal(EncryptDecrypt_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +UINT16 +EncryptDecrypt_Out_Marshal(EncryptDecrypt_Out *source, TPMI_ST_COMMAND_TAG tag, BYTE **buffer, uint32_t *size); +TPM_RC +EncryptDecrypt2_In_Unmarshal(EncryptDecrypt2_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +TPM_RC +Hash_In_Unmarshal(Hash_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +UINT16 +Hash_Out_Marshal(Hash_Out *source, TPMI_ST_COMMAND_TAG tag, BYTE **buffer, uint32_t *size); +TPM_RC +HMAC_In_Unmarshal(HMAC_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +UINT16 +HMAC_Out_Marshal(HMAC_Out *source, TPMI_ST_COMMAND_TAG tag, BYTE **buffer, uint32_t *size); +TPM_RC +GetRandom_In_Unmarshal(GetRandom_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +UINT16 +GetRandom_Out_Marshal(GetRandom_Out *source, TPMI_ST_COMMAND_TAG tag, BYTE **buffer, uint32_t *size); +TPM_RC +StirRandom_In_Unmarshal(StirRandom_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +TPM_RC +HMAC_Start_In_Unmarshal(HMAC_Start_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +UINT16 +HMAC_Start_Out_Marshal(HMAC_Start_Out *source, TPMI_ST_COMMAND_TAG tag, BYTE **buffer, uint32_t *size); +TPM_RC +HashSequenceStart_In_Unmarshal(HashSequenceStart_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +UINT16 +HashSequenceStart_Out_Marshal(HashSequenceStart_Out *source, TPMI_ST_COMMAND_TAG tag, BYTE **buffer, uint32_t *size); +TPM_RC +SequenceUpdate_In_Unmarshal(SequenceUpdate_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +TPM_RC +SequenceComplete_In_Unmarshal(SequenceComplete_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +UINT16 +SequenceComplete_Out_Marshal(SequenceComplete_Out *source, TPMI_ST_COMMAND_TAG tag, BYTE **buffer, uint32_t *size); +TPM_RC +EventSequenceComplete_In_Unmarshal(EventSequenceComplete_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +UINT16 +EventSequenceComplete_Out_Marshal(EventSequenceComplete_Out *source, TPMI_ST_COMMAND_TAG tag, BYTE **buffer, uint32_t *size); +TPM_RC +Certify_In_Unmarshal(Certify_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +UINT16 +Certify_Out_Marshal(Certify_Out *source, TPMI_ST_COMMAND_TAG tag, BYTE **buffer, uint32_t *size); +TPM_RC +CertifyCreation_In_Unmarshal(CertifyCreation_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +UINT16 +CertifyCreation_Out_Marshal(CertifyCreation_Out *source, TPMI_ST_COMMAND_TAG tag, BYTE **buffer, uint32_t *size); +TPM_RC +Quote_In_Unmarshal(Quote_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +UINT16 +Quote_Out_Marshal(Quote_Out *source, TPMI_ST_COMMAND_TAG tag, BYTE **buffer, uint32_t *size); +TPM_RC +GetSessionAuditDigest_In_Unmarshal(GetSessionAuditDigest_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +UINT16 +GetSessionAuditDigest_Out_Marshal(GetSessionAuditDigest_Out *source, TPMI_ST_COMMAND_TAG tag, BYTE **buffer, uint32_t *size); +TPM_RC +GetCommandAuditDigest_In_Unmarshal(GetCommandAuditDigest_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +UINT16 +GetCommandAuditDigest_Out_Marshal(GetCommandAuditDigest_Out *source, TPMI_ST_COMMAND_TAG tag, BYTE **buffer, uint32_t *size); +TPM_RC +GetTime_In_Unmarshal(GetTime_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +UINT16 +GetTime_Out_Marshal(GetTime_Out *source, TPMI_ST_COMMAND_TAG tag, BYTE **buffer, uint32_t *size); +TPM_RC +Commit_In_Unmarshal(Commit_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +UINT16 +Commit_Out_Marshal(Commit_Out *source, TPMI_ST_COMMAND_TAG tag, BYTE **buffer, uint32_t *size); +TPM_RC +EC_Ephemeral_In_Unmarshal(EC_Ephemeral_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +UINT16 +EC_Ephemeral_Out_Marshal(EC_Ephemeral_Out *source, TPMI_ST_COMMAND_TAG tag, BYTE **buffer, uint32_t *size); +TPM_RC +VerifySignature_In_Unmarshal(VerifySignature_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +UINT16 +VerifySignature_Out_Marshal(VerifySignature_Out *source, TPMI_ST_COMMAND_TAG tag, BYTE **buffer, uint32_t *size); +TPM_RC +Sign_In_Unmarshal(Sign_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +UINT16 +Sign_Out_Marshal(Sign_Out *source, TPMI_ST_COMMAND_TAG tag, BYTE **buffer, uint32_t *size); +TPM_RC +SetCommandCodeAuditStatus_In_Unmarshal(SetCommandCodeAuditStatus_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +TPM_RC +PCR_Extend_In_Unmarshal(PCR_Extend_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +TPM_RC +PCR_Event_In_Unmarshal(PCR_Event_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +UINT16 +PCR_Event_Out_Marshal(PCR_Event_Out *source, TPMI_ST_COMMAND_TAG tag, BYTE **buffer, uint32_t *size); +TPM_RC +PCR_Read_In_Unmarshal(PCR_Read_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +UINT16 +PCR_Read_Out_Marshal(PCR_Read_Out *source, TPMI_ST_COMMAND_TAG tag, BYTE **buffer, uint32_t *size); +TPM_RC +PCR_Allocate_In_Unmarshal(PCR_Allocate_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +UINT16 +PCR_Allocate_Out_Marshal(PCR_Allocate_Out *source, TPMI_ST_COMMAND_TAG tag, BYTE **buffer, uint32_t *size); +TPM_RC +PCR_SetAuthPolicy_In_Unmarshal(PCR_SetAuthPolicy_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +TPM_RC +PCR_SetAuthValue_In_Unmarshal(PCR_SetAuthValue_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +TPM_RC +PCR_Reset_In_Unmarshal(PCR_Reset_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +TPM_RC +PolicySigned_In_Unmarshal(PolicySigned_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +UINT16 +PolicySigned_Out_Marshal(PolicySigned_Out *source, TPMI_ST_COMMAND_TAG tag, BYTE **buffer, uint32_t *size); +TPM_RC +PolicySecret_In_Unmarshal(PolicySecret_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +UINT16 +PolicySecret_Out_Marshal(PolicySecret_Out *source, TPMI_ST_COMMAND_TAG tag, BYTE **buffer, uint32_t *size); +TPM_RC +PolicyTicket_In_Unmarshal(PolicyTicket_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +TPM_RC +PolicyOR_In_Unmarshal(PolicyOR_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +TPM_RC +PolicyPCR_In_Unmarshal(PolicyPCR_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +TPM_RC +PolicyLocality_In_Unmarshal(PolicyLocality_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +TPM_RC +PolicyNV_In_Unmarshal(PolicyNV_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +TPM_RC +PolicyAuthorizeNV_In_Unmarshal(PolicyAuthorizeNV_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +TPM_RC +PolicyCounterTimer_In_Unmarshal(PolicyCounterTimer_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +TPM_RC +PolicyCommandCode_In_Unmarshal(PolicyCommandCode_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +TPM_RC +PolicyPhysicalPresence_In_Unmarshal(PolicyPhysicalPresence_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +TPM_RC +PolicyCpHash_In_Unmarshal(PolicyCpHash_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +TPM_RC +PolicyNameHash_In_Unmarshal(PolicyNameHash_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +TPM_RC +PolicyDuplicationSelect_In_Unmarshal(PolicyDuplicationSelect_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +TPM_RC +PolicyAuthorize_In_Unmarshal(PolicyAuthorize_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +TPM_RC +PolicyAuthValue_In_Unmarshal(PolicyAuthValue_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +TPM_RC +PolicyPassword_In_Unmarshal(PolicyPassword_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +TPM_RC +PolicyGetDigest_In_Unmarshal(PolicyGetDigest_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +UINT16 +PolicyGetDigest_Out_Marshal(PolicyGetDigest_Out *source, TPMI_ST_COMMAND_TAG tag, BYTE **buffer, uint32_t *size); +TPM_RC +PolicyNvWritten_In_Unmarshal(PolicyNvWritten_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +TPM_RC +PolicyTemplate_In_Unmarshal(PolicyTemplate_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +TPM_RC +CreatePrimary_In_Unmarshal(CreatePrimary_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +UINT16 +CreatePrimary_Out_Marshal(CreatePrimary_Out *source, TPMI_ST_COMMAND_TAG tag, BYTE **buffer, uint32_t *size); +TPM_RC +HierarchyControl_In_Unmarshal(HierarchyControl_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +TPM_RC +SetPrimaryPolicy_In_Unmarshal(SetPrimaryPolicy_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +TPM_RC +ChangePPS_In_Unmarshal(ChangePPS_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +TPM_RC +ChangeEPS_In_Unmarshal(ChangeEPS_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +TPM_RC +Clear_In_Unmarshal(Clear_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +TPM_RC +ClearControl_In_Unmarshal(ClearControl_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +TPM_RC +HierarchyChangeAuth_In_Unmarshal(HierarchyChangeAuth_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +TPM_RC +DictionaryAttackLockReset_In_Unmarshal(DictionaryAttackLockReset_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +TPM_RC +DictionaryAttackParameters_In_Unmarshal(DictionaryAttackParameters_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +TPM_RC +PP_Commands_In_Unmarshal(PP_Commands_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +TPM_RC +SetAlgorithmSet_In_Unmarshal(SetAlgorithmSet_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +TPM_RC +ContextSave_In_Unmarshal(ContextSave_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +UINT16 +ContextSave_Out_Marshal(ContextSave_Out *source, TPMI_ST_COMMAND_TAG tag, BYTE **buffer, uint32_t *size); +TPM_RC +ContextLoad_In_Unmarshal(ContextLoad_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +UINT16 +ContextLoad_Out_Marshal(ContextLoad_Out *source, TPMI_ST_COMMAND_TAG tag, BYTE **buffer, uint32_t *size); +TPM_RC +FlushContext_In_Unmarshal(FlushContext_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +TPM_RC +EvictControl_In_Unmarshal(EvictControl_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +UINT16 +ReadClock_Out_Marshal(ReadClock_Out *source, TPMI_ST_COMMAND_TAG tag, BYTE **buffer, uint32_t *size); +TPM_RC +ClockSet_In_Unmarshal(ClockSet_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +TPM_RC +ClockRateAdjust_In_Unmarshal(ClockRateAdjust_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +TPM_RC +GetCapability_In_Unmarshal(GetCapability_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +UINT16 +GetCapability_Out_Marshal(GetCapability_Out *source, TPMI_ST_COMMAND_TAG tag, BYTE **buffer, uint32_t *size); +TPM_RC +TestParms_In_Unmarshal(TestParms_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +TPM_RC +NV_DefineSpace_In_Unmarshal(NV_DefineSpace_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +TPM_RC +NV_UndefineSpace_In_Unmarshal(NV_UndefineSpace_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +TPM_RC +NV_UndefineSpaceSpecial_In_Unmarshal(NV_UndefineSpaceSpecial_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +TPM_RC +NV_ReadPublic_In_Unmarshal(NV_ReadPublic_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +UINT16 +NV_ReadPublic_Out_Marshal(NV_ReadPublic_Out *source, TPMI_ST_COMMAND_TAG tag, BYTE **buffer, uint32_t *size); +TPM_RC +NV_Write_In_Unmarshal(NV_Write_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +TPM_RC +NV_Increment_In_Unmarshal(NV_Increment_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +TPM_RC +NV_Extend_In_Unmarshal(NV_Extend_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +TPM_RC +NV_SetBits_In_Unmarshal(NV_SetBits_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +TPM_RC +NV_WriteLock_In_Unmarshal(NV_WriteLock_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +TPM_RC +NV_GlobalWriteLock_In_Unmarshal(NV_GlobalWriteLock_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +TPM_RC +NV_Read_In_Unmarshal(NV_Read_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +UINT16 +NV_Read_Out_Marshal(NV_Read_Out *source, TPMI_ST_COMMAND_TAG tag, BYTE **buffer, uint32_t *size); +TPM_RC +NV_ReadLock_In_Unmarshal(NV_ReadLock_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +TPM_RC +NV_ChangeAuth_In_Unmarshal(NV_ChangeAuth_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +TPM_RC +NV_Certify_In_Unmarshal(NV_Certify_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); +UINT16 +NV_Certify_Out_Marshal(NV_Certify_Out *source, TPMI_ST_COMMAND_TAG tag, BYTE **buffer, uint32_t *size); + +#endif diff --git a/libstb/tss2/Makefile.inc b/libstb/tss2/Makefile.inc new file mode 100644 index 0000000..2a5be65 --- /dev/null +++ b/libstb/tss2/Makefile.inc @@ -0,0 +1,27 @@ +# -*-Makefile-*- + +TSS2_DIR = libstb/tss2 + +SUBDIRS += $(TSS2_DIR) + +CPPFLAGS += -I$(SRC)/$(TSS2_DIR) + +TSS2_SRCS = tss.c tss20.c tssauth.c tssauth20.c tssccattributes.c +TSS2_SRCS += tsscryptoh.c tsscryptombed.c tsscryptouv.c tssdevuv.c +TSS2_SRCS += tssmarshal.c tssprint.c tssprintcmd.c tssproperties.c +TSS2_SRCS += tssresponsecode.c tsstransmit.c tssutils.c tssntc.c +TSS2_SRCS += tssuv.c Commands.c CommandAttributeData.c Unmarshal.c +TSS2_SRCS += tssdevskiboot.c tssskiboot.c tpm_nv.c + +TSS2_OBJS = $(TSS2_SRCS:%.c=%.o) + +CFLAGS_$(TSS2_DIR)/ = -DTPM_POSIX -DTPM_TPM20 -DTPM_NOSOCKET -DTPM_NODEV +CFLAGS_$(TSS2_DIR)/ += -DTPM_TSS_NOECC -DTPM_TSS_NORSA -D__SKIBOOT__ +CFLAGS_$(TSS2_DIR)/ += -DTPM_TSS_NOFILE -DTPM_TSS_NOENV -DTPM_TSS_NOSCAN +CFLAGS_$(TSS2_DIR)/ += -DALG_SHA1=NO -Wstack-usage=4096 + +CFLAGS_SKIP_$(TSS2_DIR)/ = -Wsuggest-attribute=const + +TSS2 = $(TSS2_DIR)/built-in.a + +$(TSS2): $(TSS2_OBJS:%=$(TSS2_DIR)/%) diff --git a/libstb/tss2/Platform.h b/libstb/tss2/Platform.h new file mode 100644 index 0000000..9c5a594 --- /dev/null +++ b/libstb/tss2/Platform.h @@ -0,0 +1,361 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: Platform.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 122 */ + +// C.8 Platform.h + +#ifndef PLATFORM_H +#define PLATFORM_H + +// C.8.1. Includes and Defines + +#include <ibmtss/BaseTypes.h> +#include "stdint.h" +#include "TpmError.h" +#include <ibmtss/TpmBuildSwitches.h> + +// C.8.2. Power Functions +// C.8.2.1. _plat__Signal_PowerOn +// Signal power on This signal is simulate by a RPC call + +LIB_EXPORT int +_plat__Signal_PowerOn(void); + +// C.8.2.2. _plat__Signal_Reset +// Signal reset This signal is simulate by a RPC call + +LIB_EXPORT int +_plat__Signal_Reset(void); + +// C.8.2.3. _plat__WasPowerLost() +// Indicates if the power was lost before a _TPM__Init(). + +LIB_EXPORT BOOL +_plat__WasPowerLost(BOOL clear); + +// C.8.2.4. _plat__Signal_PowerOff() +// Signal power off This signal is simulate by a RPC call + +LIB_EXPORT void +_plat__Signal_PowerOff(void); + +// C.8.3. Physical Presence Functions +// C.8.3.1. _plat__PhysicalPresenceAsserted() +// Check if physical presence is signaled +// Return Value Meaning +// TRUE if physical presence is signaled +// FALSE if physical presence is not signaled + +LIB_EXPORT BOOL +_plat__PhysicalPresenceAsserted(void); + +// C.8.3.2. _plat__Signal_PhysicalPresenceOn +// Signal physical presence on This signal is simulate by a RPC call + +LIB_EXPORT void +_plat__Signal_PhysicalPresenceOn(void); + +// C.8.3.3. _plat__Signal_PhysicalPresenceOff() +// Signal physical presence off This signal is simulate by a RPC call + +LIB_EXPORT void +_plat__Signal_PhysicalPresenceOff(void); + +// C.8.4. Command Canceling Functions +// C.8.4.1. _plat__IsCanceled() +// Check if the cancel flag is set +// Return Value Meaning +// TRUE if cancel flag is set +// FALSE if cancel flag is not set + +LIB_EXPORT BOOL +_plat__IsCanceled(void); + +// C.8.4.2. _plat__SetCancel() +// Set cancel flag. + +LIB_EXPORT void +_plat__SetCancel(void); + +// C.8.4.3. _plat__ClearCancel() +// Clear cancel flag + +LIB_EXPORT void +_plat__ClearCancel( void); + +// C.8.5. NV memory functions +// C.8.5.1. _plat__NvErrors() + +// This function is used by the simulator to set the error flags in the NV subsystem to simulate an +// error in the NV loading process + +LIB_EXPORT void +_plat__NvErrors( + BOOL recoverable, + BOOL unrecoverable + ); + +// C.8.5.2. _plat__NVEnable() + +// Enable platform NV memory NV memory is automatically enabled at power on event. This function is +// mostly for TPM_Manufacture() to access NV memory without a power on event + +// Return Value Meaning +// 0 if success +// non-0 if fail + +LIB_EXPORT int +_plat__NVEnable( + void *platParameter // IN: platform specific parameters + ); + +// C.8.5.3. _plat__NVDisable() + +// Disable platform NV memory NV memory is automatically disabled at power off event. This function +// is mostly for TPM_Manufacture() to disable NV memory without a power off event + +LIB_EXPORT void +_plat__NVDisable(void); + +// C.8.5.4. _plat__IsNvAvailable() +// Check if NV is available +// Return Value Meaning +// 0 NV is available +// 1 NV is not available due to write failure +// 2 NV is not available due to rate limit + +LIB_EXPORT int +_plat__IsNvAvailable(void); + +// C.8.5.5. _plat__NvCommit() +// Update NV chip +// Return Value Meaning +// 0 NV write success +// non-0 NV write fail + +LIB_EXPORT int +_plat__NvCommit(void); + +// C.8.5.6. _plat__NvMemoryRead() +// Read a chunk of NV memory + +LIB_EXPORT void +_plat__NvMemoryRead( + unsigned int startOffset, // IN: read start + unsigned int size, // IN: size of bytes to read + void *data // OUT: data buffer + ); + +// C.8.5.7. _plat__NvIsDifferent() + +// This function checks to see if the NV is different from the test value. This is so that NV will +// not be written if it has not changed. + +// Return Value Meaning +// TRUE the NV location is different from the test value +// FALSE the NV location is the same as the test value + +LIB_EXPORT BOOL +_plat__NvIsDifferent( + unsigned int startOffset, // IN: read start + unsigned int size, // IN: size of bytes to compare + void *data // IN: data buffer + ); + +// C.8.5.8. _plat__NvMemoryWrite() + +// Write a chunk of NV memory + +LIB_EXPORT void +_plat__NvMemoryWrite( + unsigned int startOffset, // IN: read start + unsigned int size, // IN: size of bytes to read + void *data // OUT: data buffer + ); + +// C.8.5.9. _plat__NvMemoryClear() + +// Function is used to set a range of NV memory bytes to an implementation-dependent value. The +// value represents the errase state of the memory. + +LIB_EXPORT void +_plat__NvMemoryClear( + unsigned int start, // IN: clear start + unsigned int size // IN: number of bytes to be clear + ); + +// C.8.5.10. _plat__NvMemoryMove() + +// Move a chunk of NV memory from source to destination This function should ensure that if there +// overlap, the original data is copied before it is written + +LIB_EXPORT void +_plat__NvMemoryMove( + unsigned int sourceOffset, // IN: source offset + unsigned int destOffset, // IN: destination offset + unsigned int size // IN: size of data being moved + ); + +// C.8.5.11. _plat__SetNvAvail() + +// Set the current NV state to available. This function is for testing purposes only. It is not +// part of the platform NV logic + +LIB_EXPORT void +_plat__SetNvAvail(void); + +// C.8.5.12. _plat__ClearNvAvail() + +// Set the current NV state to unavailable. This function is for testing purposes only. It is not +// part of the platform NV logic + +LIB_EXPORT void +_plat__ClearNvAvail(void); + +// C.8.6. Locality Functions +// C.8.6.1. _plat__LocalityGet() +// Get the most recent command locality in locality value form + +LIB_EXPORT unsigned char +_plat__LocalityGet(void); + +// C.8.6.2. _plat__LocalitySet() +// Set the most recent command locality in locality value form + +LIB_EXPORT void +_plat__LocalitySet( + unsigned char locality + ); + +// C.8.7. Clock Constants and Functions +// Assume that the nominal divisor is 30000 + +#define CLOCK_NOMINAL 30000 + +// A 1% change in rate is 300 counts + +#define CLOCK_ADJUST_COARSE 300 + +// A .1 change in rate is 30 counts + +#define CLOCK_ADJUST_MEDIUM 30 + +// A minimum change in rate is 1 count + +#define CLOCK_ADJUST_FINE 1 + +// The clock tolerance is +/-15% (4500 counts) Allow some guard band (16.7%) + +#define CLOCK_ADJUST_LIMIT 5000 + +// C.8.7.1. _plat__ClockReset() + +// This function sets the current clock time as initial time. This function is called at a power on +// event to reset the clock + +LIB_EXPORT void +_plat__ClockReset(void); + +// C.8.7.2. _plat__ClockTimeFromStart() + +// Function returns the compensated time from the start of the command when +// _plat__ClockTimeFromStart() was called. + +LIB_EXPORT unsigned long long +_plat__ClockTimeFromStart(void); + +// C.8.7.3. _plat__ClockTimeElapsed() + +// Get the time elapsed from current to the last time the _plat__ClockTimeElapsed() is called. For +// the first _plat__ClockTimeElapsed() call after a power on event, this call report the elapsed +// time from power on to the current call + +LIB_EXPORT unsigned long long +_plat__ClockTimeElapsed(void); + +// C.8.7.4. _plat__ClockAdjustRate() +// Adjust the clock rate + +LIB_EXPORT void +_plat__ClockAdjustRate( + int adjust // IN: the adjust number. It could be + // positive or negative + ); + +// C.8.8. Single Function Files +// C.8.8.1. _plat__GetEntropy() + +// This function is used to get available hardware entropy. In a hardware implementation of this +// function, there would be no call to the system to get entropy. If the caller does not ask for any +// entropy, then this is a startup indication and firstValue should be reset. + +// Return Value Meaning +// < 0 hardware failure of the entropy generator, this is sticky +// >= 0 the returned amount of entropy (bytes) + +LIB_EXPORT int32_t +_plat__GetEntropy( + unsigned char *entropy, // output buffer + uint32_t amount // amount requested + ); + +#endif diff --git a/libstb/tss2/Unmarshal.c b/libstb/tss2/Unmarshal.c new file mode 100644 index 0000000..194d594 --- /dev/null +++ b/libstb/tss2/Unmarshal.c @@ -0,0 +1,5372 @@ +/********************************************************************************/ +/* */ +/* Parameter Unmarshaling */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* */ +/* (c) Copyright IBM Corporation 2015 - 2019 */ +/* */ +/* All rights reserved. */ +/* */ +/* Redistribution and use in source and binary forms, with or without */ +/* modification, are permitted provided that the following conditions are */ +/* met: */ +/* */ +/* Redistributions of source code must retain the above copyright notice, */ +/* this list of conditions and the following disclaimer. */ +/* */ +/* 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. */ +/* */ +/* Neither the names of the IBM Corporation nor the names of its */ +/* contributors may be used to endorse or promote products derived from */ +/* this software without specific prior written permission. */ +/* */ +/* 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. */ +/********************************************************************************/ + +#include <string.h> + +#include <ibmtss/Unmarshal_fp.h> + +/* The functions with the TSS_ prefix are preferred. They use an unsigned size. The functions + without the prefix are deprecated. */ + +/* The int and array functions are common to TPM 1.2 and TPM 2.0 */ + +TPM_RC +TSS_UINT8_Unmarshalu(UINT8 *target, BYTE **buffer, uint32_t *size) +{ + if (*size < sizeof(UINT8)) { + return TPM_RC_INSUFFICIENT; + } + *target = (*buffer)[0]; + *buffer += sizeof(UINT8); + *size -= sizeof(UINT8); + return TPM_RC_SUCCESS; +} + +TPM_RC +TSS_INT8_Unmarshalu(INT8 *target, BYTE **buffer, uint32_t *size) +{ + return TSS_UINT8_Unmarshalu((UINT8 *)target, buffer, size); +} + +TPM_RC +TSS_UINT16_Unmarshalu(uint16_t *target, BYTE **buffer, uint32_t *size) +{ + if (*size < sizeof(uint16_t)) { + return TPM_RC_INSUFFICIENT; + } + *target = ((uint16_t)((*buffer)[0]) << 8) | + ((uint16_t)((*buffer)[1]) << 0); + *buffer += sizeof(uint16_t); + *size -= sizeof(uint16_t); + return TPM_RC_SUCCESS; +} + +TPM_RC +TSS_UINT32_Unmarshalu(UINT32 *target, BYTE **buffer, uint32_t *size) +{ + if (*size < sizeof(uint32_t)) { + return TPM_RC_INSUFFICIENT; + } + *target = ((uint32_t)((*buffer)[0]) << 24) | + ((uint32_t)((*buffer)[1]) << 16) | + ((uint32_t)((*buffer)[2]) << 8) | + ((uint32_t)((*buffer)[3]) << 0); + *buffer += sizeof(uint32_t); + *size -= sizeof(uint32_t); + return TPM_RC_SUCCESS; +} + +TPM_RC +TSS_INT32_Unmarshalu(INT32 *target, BYTE **buffer, uint32_t *size) +{ + return TSS_UINT32_Unmarshalu((UINT32 *)target, buffer, size); +} + + +TPM_RC +TSS_UINT64_Unmarshalu(UINT64 *target, BYTE **buffer, uint32_t *size) +{ + if (*size < sizeof(UINT64)) { + return TPM_RC_INSUFFICIENT; + } + *target = ((UINT64)((*buffer)[0]) << 56) | + ((UINT64)((*buffer)[1]) << 48) | + ((UINT64)((*buffer)[2]) << 40) | + ((UINT64)((*buffer)[3]) << 32) | + ((UINT64)((*buffer)[4]) << 24) | + ((UINT64)((*buffer)[5]) << 16) | + ((UINT64)((*buffer)[6]) << 8) | + ((UINT64)((*buffer)[7]) << 0); + *buffer += sizeof(UINT64); + *size -= sizeof(UINT64); + return TPM_RC_SUCCESS; +} + +TPM_RC +TSS_Array_Unmarshalu(BYTE *targetBuffer, uint16_t targetSize, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (*size < targetSize) { + rc = TPM_RC_INSUFFICIENT; + } + else { + memcpy(targetBuffer, *buffer, targetSize); + *buffer += targetSize; + *size -= targetSize; + } + return rc; +} + +TPM_RC UINT8_Unmarshal(UINT8 *target, BYTE **buffer, INT32 *size) +{ + return TSS_UINT8_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC INT8_Unmarshal(INT8 *target, BYTE **buffer, INT32 *size) +{ + return TSS_INT8_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC UINT16_Unmarshal(UINT16 *target, BYTE **buffer, INT32 *size) +{ + return TSS_UINT16_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC UINT32_Unmarshal(UINT32 *target, BYTE **buffer, INT32 *size) +{ + return TSS_UINT32_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC INT32_Unmarshal(INT32 *target, BYTE **buffer, INT32 *size) +{ + return TSS_INT32_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC UINT64_Unmarshal(UINT64 *target, BYTE **buffer, INT32 *size) +{ + return TSS_UINT64_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC Array_Unmarshal(BYTE *targetBuffer, UINT16 targetSize, BYTE **buffer, INT32 *size) +{ + return TSS_Array_Unmarshalu(targetBuffer, targetSize, buffer, (uint32_t *)size); +} + +#ifdef TPM_TPM20 + +TPM_RC +TSS_TPM2B_Unmarshalu(TPM2B *target, uint16_t targetSize, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_UINT16_Unmarshalu(&target->size, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + if (target->size > targetSize) { + rc = TPM_RC_SIZE; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_Array_Unmarshalu(target->buffer, target->size, buffer, size); + } + return rc; +} + +/* Table 5 - Definition of Types for Documentation Clarity */ + +TPM_RC +TSS_TPM_KEY_BITS_Unmarshalu(TPM_KEY_BITS *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_UINT16_Unmarshalu(target, buffer, size); + } + return rc; +} + +/* Table 7 - Definition of (UINT32) TPM_GENERATED Constants <O> */ + +TPM_RC +TSS_TPM_GENERATED_Unmarshalu(TPM_GENERATED *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_UINT32_Unmarshalu(target, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + if (*target != TPM_GENERATED_VALUE) { + rc = TPM_RC_VALUE; + } + } + return rc; +} + +/* Table 9 - Definition of (UINT16) TPM_ALG_ID Constants <IN/OUT, S> */ + +TPM_RC +TSS_TPM_ALG_ID_Unmarshalu(TPM_ALG_ID *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_UINT16_Unmarshalu(target, buffer, size); + } + return rc; +} + +/* Table 10 - Definition of (UINT16) {ECC} TPM_ECC_CURVE Constants <IN/OUT, S> */ + +#ifdef TPM_ALG_ECC +TPM_RC +TSS_TPM_ECC_CURVE_Unmarshalu(TPM_ECC_CURVE *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_UINT16_Unmarshalu(target, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + switch (*target) { + case TPM_ECC_NONE: + case TPM_ECC_NIST_P192: + case TPM_ECC_NIST_P224: + case TPM_ECC_NIST_P256: + case TPM_ECC_NIST_P384: + case TPM_ECC_NIST_P521: + case TPM_ECC_BN_P256: + case TPM_ECC_BN_P638: + case TPM_ECC_SM2_P256: + break; + default: + rc = TPM_RC_CURVE; + } + } + return rc; +} +#endif + +/* Table 13 - Definition of (UINT32) TPM_CC Constants (Numeric Order) <IN/OUT, S> */ + +TPM_RC +TSS_TPM_CC_Unmarshalu(TPM_RC *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_UINT32_Unmarshalu(target, buffer, size); + } + return rc; +} + +/* Table 17 - Definition of (UINT32) TPM_RC Constants (Actions) <OUT> */ + +TPM_RC +TSS_TPM_RC_Unmarshalu(TPM_RC *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_UINT32_Unmarshalu(target, buffer, size); + } + return rc; +} + +/* Table 18 - Definition of (INT8) TPM_CLOCK_ADJUST Constants <IN> */ + +TPM_RC +TSS_TPM_CLOCK_ADJUST_Unmarshalu(TPM_CLOCK_ADJUST *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_INT8_Unmarshalu(target, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + switch (*target) { + case TPM_CLOCK_COARSE_SLOWER: + case TPM_CLOCK_MEDIUM_SLOWER: + case TPM_CLOCK_FINE_SLOWER: + case TPM_CLOCK_NO_CHANGE: + case TPM_CLOCK_FINE_FASTER: + case TPM_CLOCK_MEDIUM_FASTER: + case TPM_CLOCK_COARSE_FASTER: + break; + default: + rc = TPM_RC_VALUE; + } + } + return rc; +} + +/* Table 19 - Definition of (UINT16) TPM_EO Constants <IN/OUT> */ + +TPM_RC +TSS_TPM_EO_Unmarshalu(TPM_EO *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_UINT16_Unmarshalu(target, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + switch (*target) { + case TPM_EO_EQ: + case TPM_EO_NEQ: + case TPM_EO_SIGNED_GT: + case TPM_EO_UNSIGNED_GT: + case TPM_EO_SIGNED_LT: + case TPM_EO_UNSIGNED_LT: + case TPM_EO_SIGNED_GE: + case TPM_EO_UNSIGNED_GE: + case TPM_EO_SIGNED_LE: + case TPM_EO_UNSIGNED_LE: + case TPM_EO_BITSET: + case TPM_EO_BITCLEAR: + break; + default: + rc = TPM_RC_VALUE; + } + } + return rc; +} + +/* Table 20 - Definition of (UINT16) TPM_ST Constants <IN/OUT, S> */ + +TPM_RC +TSS_TPM_ST_Unmarshalu(TPM_ST *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_UINT16_Unmarshalu(target, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + switch (*target) { + case TPM_ST_RSP_COMMAND: + case TPM_ST_NULL: + case TPM_ST_NO_SESSIONS: + case TPM_ST_SESSIONS: + case TPM_ST_ATTEST_NV: + case TPM_ST_ATTEST_COMMAND_AUDIT: + case TPM_ST_ATTEST_SESSION_AUDIT: + case TPM_ST_ATTEST_CERTIFY: + case TPM_ST_ATTEST_QUOTE: + case TPM_ST_ATTEST_TIME: + case TPM_ST_ATTEST_CREATION: + case TPM_ST_CREATION: + case TPM_ST_VERIFIED: + case TPM_ST_AUTH_SECRET: + case TPM_ST_HASHCHECK: + case TPM_ST_AUTH_SIGNED: + break; + default: + rc = TPM_RC_VALUE; + } + } + return rc; +} + +/* Table 21 - Definition of (UINT16) TPM_SU Constants <IN> */ + +TPM_RC +TSS_TPM_SU_Unmarshalu(TPM_SU *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_UINT16_Unmarshalu(target, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + switch (*target) { + case TPM_SU_CLEAR: + case TPM_SU_STATE: + break; + default: + rc = TPM_RC_VALUE; + } + } + return rc; +} + +/* Table 22 - Definition of (UINT8) TPM_SE Constants <IN> */ + +TPM_RC +TSS_TPM_SE_Unmarshalu(TPM_SE *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_UINT8_Unmarshalu(target, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + switch (*target) { + case TPM_SE_HMAC: + case TPM_SE_POLICY: + case TPM_SE_TRIAL: + break; + default: + rc = TPM_RC_VALUE; + } + } + return rc; +} + +/* Table 23 - Definition of (UINT32) TPM_CAP Constants */ + +TPM_RC +TSS_TPM_CAP_Unmarshalu(TPM_CAP *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_UINT32_Unmarshalu(target, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + switch (*target) { + case TPM_CAP_ALGS: + case TPM_CAP_HANDLES: + case TPM_CAP_COMMANDS: + case TPM_CAP_PP_COMMANDS: + case TPM_CAP_AUDIT_COMMANDS: + case TPM_CAP_PCRS: + case TPM_CAP_TPM_PROPERTIES: + case TPM_CAP_PCR_PROPERTIES: + case TPM_CAP_ECC_CURVES: + case TPM_CAP_AUTH_POLICIES: + case TPM_CAP_VENDOR_PROPERTY: + break; + default: + rc = TPM_RC_VALUE; + } + } + return rc; +} + +/* Table 24 - Definition of (UINT32) TPM_PT Constants <IN/OUT, S> */ + +TPM_RC +TSS_TPM_PT_Unmarshalu(TPM_HANDLE *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_UINT32_Unmarshalu(target, buffer, size); + } + return rc; +} + +/* Table 25 - Definition of (UINT32) TPM_PT_PCR Constants <IN/OUT, S> */ + +TPM_RC +TSS_TPM_PT_PCR_Unmarshalu(TPM_PT_PCR *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_UINT32_Unmarshalu(target, buffer, size); + } + return rc; +} + +/* Table 27 - Definition of Types for Handles */ + +TPM_RC +TSS_TPM_HANDLE_Unmarshalu(TPM_HANDLE *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_UINT32_Unmarshalu(target, buffer, size); + } + return rc; +} + +/* Table 31 - Definition of (UINT32) TPMA_ALGORITHM Bits */ + +TPM_RC +TSS_TPMA_ALGORITHM_Unmarshalu(TPMA_ALGORITHM *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_UINT32_Unmarshalu(&target->val, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + if (target->val & TPMA_ALGORITHM_RESERVED) { + rc = TPM_RC_RESERVED_BITS; + } + } + return rc; +} + +/* Table 32 - Definition of (UINT32) TPMA_OBJECT Bits */ + +TPM_RC +TSS_TPMA_OBJECT_Unmarshalu(TPMA_OBJECT *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_UINT32_Unmarshalu(&target->val, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + if (target->val & TPMA_OBJECT_RESERVED) { + rc = TPM_RC_RESERVED_BITS; + } + } + return rc; +} + +/* Table 33 - Definition of (UINT8) TPMA_SESSION Bits <IN/OUT> */ + +TPM_RC +TSS_TPMA_SESSION_Unmarshalu(TPMA_SESSION *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_UINT8_Unmarshalu(&target->val, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + if (target->val & TPMA_SESSION_RESERVED) { + rc = TPM_RC_RESERVED_BITS; + } + } + return rc; +} + +/* Table 34 - Definition of (UINT8) TPMA_LOCALITY Bits <IN/OUT> */ + +TPM_RC +TSS_TPMA_LOCALITY_Unmarshalu(TPMA_LOCALITY *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_UINT8_Unmarshalu(&target->val, buffer, size); + } + return rc; +} + +/* Table 38 - Definition of (TPM_CC) TPMA_CC Bits <OUT> */ + +TPM_RC +TSS_TPMA_CC_Unmarshalu(TPMA_CC *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_UINT32_Unmarshalu(&target->val, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + if (target->val & TPMA_CC_RESERVED) { + rc = TPM_RC_RESERVED_BITS; + } + } + return rc; +} + +/* Table 39 - Definition of (BYTE) TPMI_YES_NO Type */ + +TPM_RC +TSS_TPMI_YES_NO_Unmarshalu(TPMI_YES_NO *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_UINT8_Unmarshalu(target, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + switch (*target) { + case NO: + case YES: + break; + default: + rc = TPM_RC_VALUE; + } + } + return rc; +} + +/* Table 40 - Definition of (TPM_HANDLE) TPMI_DH_OBJECT Type */ + +TPM_RC +TSS_TPMI_DH_OBJECT_Unmarshalu(TPMI_DH_OBJECT *target, BYTE **buffer, uint32_t *size, BOOL allowNull) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM_HANDLE_Unmarshalu(target, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + BOOL isNotTransient = (*target < TRANSIENT_FIRST) || (*target > TRANSIENT_LAST); + BOOL isNotPersistent = (*target < PERSISTENT_FIRST) || (*target > PERSISTENT_LAST); + BOOL isNotLegalNull = (*target != TPM_RH_NULL) || !allowNull; + if (isNotTransient && + isNotPersistent && + isNotLegalNull) { + rc = TPM_RC_VALUE; + } + } + return rc; +} + +/* Table 41 - Definition of (TPM_HANDLE) TPMI_DH_PERSISTENT Type */ + +TPM_RC +TSS_TPMI_DH_PERSISTENT_Unmarshalu(TPMI_DH_PERSISTENT *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM_HANDLE_Unmarshalu(target, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + BOOL isNotPersistent = (*target < PERSISTENT_FIRST) || (*target > PERSISTENT_LAST); + if (isNotPersistent) { + rc = TPM_RC_VALUE; + } + } + return rc; +} + +/* Table 42 - Definition of (TPM_HANDLE) TPMI_DH_ENTITY Type <IN> */ + +TPM_RC +TSS_TPMI_DH_ENTITY_Unmarshalu(TPMI_DH_ENTITY *target, BYTE **buffer, uint32_t *size, BOOL allowNull) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM_HANDLE_Unmarshalu(target, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + BOOL isNotOwner = *target != TPM_RH_OWNER; + BOOL isNotEndorsement = *target != TPM_RH_ENDORSEMENT; + BOOL isNotPlatform = *target != TPM_RH_PLATFORM; + BOOL isNotLockout = *target != TPM_RH_LOCKOUT; + BOOL isNotTransient = (*target < TRANSIENT_FIRST) || (*target > TRANSIENT_LAST); + BOOL isNotPersistent = (*target < PERSISTENT_FIRST) || (*target > PERSISTENT_LAST); + BOOL isNotNv = (*target < NV_INDEX_FIRST) || (*target > NV_INDEX_LAST); +#if PCR_FIRST != 0 + BOOL isNotPcr = (*target < PCR_FIRST) || (*target > PCR_LAST); +#else + BOOL isNotPcr = (*target > PCR_LAST); +#endif + BOOL isNotAuth = (*target < TPM_RH_AUTH_00) || (*target > TPM_RH_AUTH_FF); + BOOL isNotLegalNull = (*target != TPM_RH_NULL) || !allowNull; + if (isNotOwner && + isNotEndorsement && + isNotPlatform && + isNotLockout && + isNotTransient && + isNotPersistent && + isNotNv && + isNotPcr && + isNotAuth && + isNotLegalNull) { + rc = TPM_RC_VALUE; + } + } + return rc; +} + +/* Table 43 - Definition of (TPM_HANDLE) TPMI_DH_PCR Type <IN> */ + +TPM_RC +TSS_TPMI_DH_PCR_Unmarshalu(TPMI_DH_PCR *target, BYTE **buffer, uint32_t *size, BOOL allowNull) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM_HANDLE_Unmarshalu(target, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { +#if PCR_FIRST != 0 + BOOL isNotPcr = (*target < PCR_FIRST) || (*target > PCR_LAST); +#else + BOOL isNotPcr = (*target > PCR_LAST); +#endif + BOOL isNotLegalNull = (*target != TPM_RH_NULL) || !allowNull; + if (isNotPcr && + isNotLegalNull) { + rc = TPM_RC_VALUE; + } + } + return rc; +} + +/* Table 44 - Definition of (TPM_HANDLE) TPMI_SH_AUTH_SESSION Type <IN/OUT> */ + +TPM_RC +TSS_TPMI_SH_AUTH_SESSION_Unmarshalu(TPMI_SH_AUTH_SESSION *target, BYTE **buffer, uint32_t *size, BOOL allowPwd) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM_HANDLE_Unmarshalu(target, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + BOOL isNotHmacSession = (*target < HMAC_SESSION_FIRST ) || (*target > HMAC_SESSION_LAST); + BOOL isNotPolicySession = (*target < POLICY_SESSION_FIRST) || (*target > POLICY_SESSION_LAST); + BOOL isNotLegalPwd = (*target != TPM_RS_PW) || !allowPwd; + if (isNotHmacSession && + isNotPolicySession && + isNotLegalPwd) { + rc = TPM_RC_VALUE; + } + } + return rc; +} + +/* Table 45 - Definition of (TPM_HANDLE) TPMI_SH_HMAC Type <IN/OUT> */ + +TPM_RC +TSS_TPMI_SH_HMAC_Unmarshalu(TPMI_SH_HMAC *target, BYTE **buffer, uint32_t *size, BOOL allowNull) +{ + TPM_RC rc = TPM_RC_SUCCESS; + allowNull = allowNull; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM_HANDLE_Unmarshalu(target, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + BOOL isNotHmacSession = (*target < HMAC_SESSION_FIRST ) || (*target > HMAC_SESSION_LAST); + if (isNotHmacSession) { + rc = TPM_RC_VALUE; + } + } + return rc; +} + +/* Table 46 - Definition of (TPM_HANDLE) TPMI_SH_POLICY Type <IN/OUT> */ + +TPM_RC +TSS_TPMI_SH_POLICY_Unmarshalu(TPMI_SH_POLICY *target, BYTE **buffer, uint32_t *size, BOOL allowNull) +{ + TPM_RC rc = TPM_RC_SUCCESS; + allowNull = allowNull; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM_HANDLE_Unmarshalu(target, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + BOOL isNotPolicySession = (*target < POLICY_SESSION_FIRST) || (*target > POLICY_SESSION_LAST); + if (isNotPolicySession) { + rc = TPM_RC_VALUE; + } + } + return rc; +} + +/* Table 47 - Definition of (TPM_HANDLE) TPMI_DH_CONTEXT Type */ + +TPM_RC +TSS_TPMI_DH_CONTEXT_Unmarshalu(TPMI_DH_CONTEXT *target, BYTE **buffer, uint32_t *size, BOOL allowNull) +{ + TPM_RC rc = TPM_RC_SUCCESS; + allowNull = allowNull; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM_HANDLE_Unmarshalu(target, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + BOOL isNotHmacSession = (*target < HMAC_SESSION_FIRST ) || (*target > HMAC_SESSION_LAST); + BOOL isNotPolicySession = (*target < POLICY_SESSION_FIRST) || (*target > POLICY_SESSION_LAST); + BOOL isNotTransient = (*target < TRANSIENT_FIRST) || (*target > TRANSIENT_LAST); + if (isNotHmacSession && + isNotPolicySession && + isNotTransient) { + rc = TPM_RC_VALUE; + } + } + return rc; +} + +/* Table 49 - Definition of (TPM_HANDLE) TPMI_DH_SAVED Type */ + +TPM_RC +TSS_TPMI_DH_SAVED_Unmarshalu(TPMI_DH_SAVED *target, BYTE **buffer, uint32_t *size, BOOL allowNull) +{ + TPM_RC rc = TPM_RC_SUCCESS; + allowNull = allowNull; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM_HANDLE_Unmarshalu(target, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + BOOL isNotHmacSession = (*target < HMAC_SESSION_FIRST ) || (*target > HMAC_SESSION_LAST); + BOOL isNotPolicySession = (*target < POLICY_SESSION_FIRST) || (*target > POLICY_SESSION_LAST); + BOOL isNotTransient = (*target != 0x80000000); + BOOL isNotSequence = (*target != 0x80000001); + BOOL isNotTransientStClear = (*target != 0x80000002); + + if (isNotHmacSession && + isNotPolicySession && + isNotTransient && + isNotSequence && + isNotTransientStClear) { + rc = TPM_RC_VALUE; + } + } + return rc; +} + +/* Table 48 - Definition of (TPM_HANDLE) TPMI_RH_HIERARCHY Type */ + +TPM_RC +TSS_TPMI_RH_HIERARCHY_Unmarshalu(TPMI_RH_HIERARCHY *target, BYTE **buffer, uint32_t *size, BOOL allowNull) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM_HANDLE_Unmarshalu(target, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + switch (*target) { + case TPM_RH_OWNER: + case TPM_RH_PLATFORM: + case TPM_RH_ENDORSEMENT: + break; + case TPM_RH_NULL: + if (!allowNull) { + rc = TPM_RC_VALUE; + } + break; + default: + rc = TPM_RC_VALUE; + } + } + return rc; +} + +/* Table 49 - Definition of (TPM_HANDLE) TPMI_RH_ENABLES Type */ + +TPM_RC +TSS_TPMI_RH_ENABLES_Unmarshalu(TPMI_RH_ENABLES *target, BYTE **buffer, uint32_t *size, BOOL allowNull) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM_HANDLE_Unmarshalu(target, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + switch (*target) { + case TPM_RH_OWNER: + case TPM_RH_PLATFORM: + case TPM_RH_ENDORSEMENT: + case TPM_RH_PLATFORM_NV: + break; + case TPM_RH_NULL: + if (!allowNull) { + rc = TPM_RC_VALUE; + } + break; + default: + rc = TPM_RC_VALUE; + } + } + return rc; +} + +/* Table 50 - Definition of (TPM_HANDLE) TPMI_RH_HIERARCHY_AUTH Type <IN> */ + +TPM_RC +TSS_TPMI_RH_HIERARCHY_AUTH_Unmarshalu(TPMI_RH_HIERARCHY_AUTH *target, BYTE **buffer, uint32_t *size, BOOL allowNull) +{ + TPM_RC rc = TPM_RC_SUCCESS; + allowNull = allowNull; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM_HANDLE_Unmarshalu(target, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + switch (*target) { + case TPM_RH_OWNER: + case TPM_RH_PLATFORM: + case TPM_RH_ENDORSEMENT: + case TPM_RH_LOCKOUT: + break; + default: + rc = TPM_RC_VALUE; + } + } + return rc; +} + +/* Table 51 - Definition of (TPM_HANDLE) TPMI_RH_PLATFORM Type <IN> */ + +TPM_RC +TSS_TPMI_RH_PLATFORM_Unmarshalu(TPMI_RH_PLATFORM *target, BYTE **buffer, uint32_t *size, BOOL allowNull) +{ + TPM_RC rc = TPM_RC_SUCCESS; + allowNull = allowNull; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM_HANDLE_Unmarshalu(target, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + switch (*target) { + case TPM_RH_PLATFORM: + break; + default: + rc = TPM_RC_VALUE; + } + } + return rc; +} + +/* Table 53 - Definition of (TPM_HANDLE) TPMI_RH_ENDORSEMENT Type <IN> */ + +TPM_RC +TSS_TPMI_RH_ENDORSEMENT_Unmarshalu(TPMI_RH_ENDORSEMENT *target, BYTE **buffer, uint32_t *size, BOOL allowNull) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM_HANDLE_Unmarshalu(target, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + switch (*target) { + case TPM_RH_ENDORSEMENT: + break; + case TPM_RH_NULL: + if (!allowNull) { + rc = TPM_RC_VALUE; + } + break; + default: + rc = TPM_RC_VALUE; + } + } + return rc; +} + +/* Table 54 - Definition of (TPM_HANDLE) TPMI_RH_PROVISION Type <IN> */ + +TPM_RC +TSS_TPMI_RH_PROVISION_Unmarshalu(TPMI_RH_PROVISION *target, BYTE **buffer, uint32_t *size, BOOL allowNull) +{ + TPM_RC rc = TPM_RC_SUCCESS; + allowNull = allowNull; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM_HANDLE_Unmarshalu(target, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + switch (*target) { + case TPM_RH_OWNER: + case TPM_RH_PLATFORM: + break; + default: + rc = TPM_RC_VALUE; + } + } + return rc; +} + +/* Table 55 - Definition of (TPM_HANDLE) TPMI_RH_CLEAR Type <IN> */ + +TPM_RC +TSS_TPMI_RH_CLEAR_Unmarshalu(TPMI_RH_CLEAR *target, BYTE **buffer, uint32_t *size, BOOL allowNull) +{ + TPM_RC rc = TPM_RC_SUCCESS; + allowNull = allowNull; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM_HANDLE_Unmarshalu(target, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + switch (*target) { + case TPM_RH_LOCKOUT: + case TPM_RH_PLATFORM: + break; + default: + rc = TPM_RC_VALUE; + } + } + return rc; +} + +/* Table 56 - Definition of (TPM_HANDLE) TPMI_RH_NV_AUTH Type <IN> */ + +TPM_RC +TSS_TPMI_RH_NV_AUTH_Unmarshalu(TPMI_RH_NV_AUTH *target, BYTE **buffer, uint32_t *size, BOOL allowNull) +{ + TPM_RC rc = TPM_RC_SUCCESS; + allowNull = allowNull; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM_HANDLE_Unmarshalu(target, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + switch (*target) { + case TPM_RH_OWNER: + case TPM_RH_PLATFORM: + break; + default: + { + BOOL isNotNv = (*target < NV_INDEX_FIRST) || (*target > NV_INDEX_LAST); + if (isNotNv) { + rc = TPM_RC_VALUE; + } + } + } + } + return rc; +} + +/* Table 57 - Definition of (TPM_HANDLE) TPMI_RH_LOCKOUT Type <IN> */ + +TPM_RC +TSS_TPMI_RH_LOCKOUT_Unmarshalu(TPMI_RH_LOCKOUT *target, BYTE **buffer, uint32_t *size, BOOL allowNull) +{ + TPM_RC rc = TPM_RC_SUCCESS; + allowNull = allowNull; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM_HANDLE_Unmarshalu(target, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + switch (*target) { + case TPM_RH_LOCKOUT: + break; + default: + rc = TPM_RC_VALUE; + } + } + return rc; +} + +/* Table 58 - Definition of (TPM_HANDLE) TPMI_RH_NV_INDEX Type <IN/OUT> */ + +TPM_RC +TSS_TPMI_RH_NV_INDEX_Unmarshalu(TPMI_RH_NV_INDEX *target, BYTE **buffer, uint32_t *size, BOOL allowNull) +{ + TPM_RC rc = TPM_RC_SUCCESS; + allowNull = allowNull; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM_HANDLE_Unmarshalu(target, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + BOOL isNotNv = (*target < NV_INDEX_FIRST) || (*target > NV_INDEX_LAST); + if (isNotNv) { + rc = TPM_RC_VALUE; + } + } + return rc; +} + +/* Table 59 - Definition of (TPM_ALG_ID) TPMI_ALG_HASH Type */ + +TPM_RC +TSS_TPMI_ALG_HASH_Unmarshalu(TPMI_ALG_HASH *target, BYTE **buffer, uint32_t *size, BOOL allowNull) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM_ALG_ID_Unmarshalu(target, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + switch (*target) { +#ifdef TPM_ALG_SHA1 + case TPM_ALG_SHA1: +#endif +#ifdef TPM_ALG_SHA256 + case TPM_ALG_SHA256: +#endif +#ifdef TPM_ALG_SHA384 + case TPM_ALG_SHA384: +#endif +#ifdef TPM_ALG_SHA512 + case TPM_ALG_SHA512: +#endif +#ifdef TPM_ALG_SM3_256 + case TPM_ALG_SM3_256: +#endif + break; + case TPM_ALG_NULL: + if (!allowNull) { + rc = TPM_RC_HASH; + } + break; + default: + rc = TPM_RC_HASH; + } + } + return rc; +} + +/* Table 61 - Definition of (TPM_ALG_ID) TPMI_ALG_SYM Type */ + +TPM_RC +TSS_TPMI_ALG_SYM_Unmarshalu(TPMI_ALG_SYM *target, BYTE **buffer, uint32_t *size, BOOL allowNull) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM_ALG_ID_Unmarshalu(target, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + switch (*target) { +#ifdef TPM_ALG_AES + case TPM_ALG_AES: +#endif +#ifdef TPM_ALG_SM4 + case TPM_ALG_SM4: +#endif +#ifdef TPM_ALG_CAMELLIA + case TPM_ALG_CAMELLIA: +#endif +#ifdef TPM_ALG_XOR + case TPM_ALG_XOR: +#endif + break; + case TPM_ALG_NULL: + if (!allowNull) { + rc = TPM_RC_SYMMETRIC; + } + break; + default: + rc = TPM_RC_SYMMETRIC; + } + } + return rc; +} + +/* Table 62 - Definition of (TPM_ALG_ID) TPMI_ALG_SYM_OBJECT Type */ + +TPM_RC +TSS_TPMI_ALG_SYM_OBJECT_Unmarshalu(TPMI_ALG_SYM_OBJECT *target, BYTE **buffer, uint32_t *size, BOOL allowNull) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM_ALG_ID_Unmarshalu(target, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + switch (*target) { +#ifdef TPM_ALG_AES + case TPM_ALG_AES: +#endif +#ifdef TPM_ALG_SM4 + case TPM_ALG_SM4: +#endif +#ifdef TPM_ALG_CAMELLIA + case TPM_ALG_CAMELLIA: +#endif + break; + case TPM_ALG_NULL: + if (!allowNull) { + rc = TPM_RC_SYMMETRIC; + } + break; + default: + rc = TPM_RC_SYMMETRIC; + } + } + return rc; +} + +/* Table 63 - Definition of (TPM_ALG_ID) TPMI_ALG_SYM_MODE Type */ + +TPM_RC +TSS_TPMI_ALG_SYM_MODE_Unmarshalu(TPMI_ALG_SYM_MODE *target, BYTE **buffer, uint32_t *size, BOOL allowNull) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM_ALG_ID_Unmarshalu(target, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + switch (*target) { +#ifdef TPM_ALG_CTR + case TPM_ALG_CTR: +#endif +#ifdef TPM_ALG_OFB + case TPM_ALG_OFB: +#endif +#ifdef TPM_ALG_CBC + case TPM_ALG_CBC: +#endif +#ifdef TPM_ALG_CFB + case TPM_ALG_CFB: +#endif +#ifdef TPM_ALG_ECB + case TPM_ALG_ECB: +#endif + break; + case TPM_ALG_NULL: + if (!allowNull) { + rc = TPM_RC_MODE; + } + break; + default: + rc = TPM_RC_MODE; + } + } + return rc; +} + +/* Table 64 - Definition of (TPM_ALG_ID) TPMI_ALG_KDF Type */ + +TPM_RC +TSS_TPMI_ALG_KDF_Unmarshalu(TPMI_ALG_KDF *target, BYTE **buffer, uint32_t *size, BOOL allowNull) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM_ALG_ID_Unmarshalu(target, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + switch (*target) { +#ifdef TPM_ALG_MGF1 + case TPM_ALG_MGF1: +#endif +#ifdef TPM_ALG_KDF1_SP800_56A + case TPM_ALG_KDF1_SP800_56A: +#endif +#ifdef TPM_ALG_KDF2 + case TPM_ALG_KDF2: +#endif +#ifdef TPM_ALG_KDF1_SP800_108 + case TPM_ALG_KDF1_SP800_108: +#endif + break; + case TPM_ALG_NULL: + if (!allowNull) { + rc = TPM_RC_KDF; + } + break; + default: + rc = TPM_RC_KDF; + } + } + return rc; +} + +/* Table 65 - Definition of (TPM_ALG_ID) TPMI_ALG_SIG_SCHEME Type */ + +TPM_RC +TSS_TPMI_ALG_SIG_SCHEME_Unmarshalu(TPMI_ALG_SIG_SCHEME *target, BYTE **buffer, uint32_t *size, BOOL allowNull) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM_ALG_ID_Unmarshalu(target, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + switch (*target) { +#ifdef TPM_ALG_HMAC + case TPM_ALG_HMAC: +#endif +#ifdef TPM_ALG_RSASSA + case TPM_ALG_RSASSA: +#endif +#ifdef TPM_ALG_RSAPSS + case TPM_ALG_RSAPSS: +#endif +#ifdef TPM_ALG_ECDSA + case TPM_ALG_ECDSA: +#endif +#ifdef TPM_ALG_ECDAA + case TPM_ALG_ECDAA: +#endif +#ifdef TPM_ALG_SM2 + case TPM_ALG_SM2: +#endif +#ifdef TPM_ALG_ECSCHNORR + case TPM_ALG_ECSCHNORR: +#endif + break; + case TPM_ALG_NULL: + if (!allowNull) { + rc = TPM_RC_SCHEME; + } + break; + default: + rc = TPM_RC_SCHEME; + } + } + return rc; +} + +/* Table 66 - Definition of (TPM_ALG_ID) TPMI_ECC_KEY_EXCHANGE Type */ + +TPM_RC +TSS_TPMI_ECC_KEY_EXCHANGE_Unmarshalu(TPMI_ECC_KEY_EXCHANGE *target, BYTE **buffer, uint32_t *size, BOOL allowNull) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM_ALG_ID_Unmarshalu(target, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + switch (*target) { +#ifdef TPM_ALG_ECDH + case TPM_ALG_ECDH: +#endif +#ifdef TPM_ALG_ECMQV + case TPM_ALG_ECMQV: +#endif +#ifdef TPM_ALG_SM2 + case TPM_ALG_SM2: +#endif + break; + case TPM_ALG_NULL: + if (!allowNull) { + rc = TPM_RC_SCHEME; + } + break; + default: + rc = TPM_RC_SCHEME; + } + } + return rc; +} + + +/* Table 67 - Definition of (TPM_ST) TPMI_ST_COMMAND_TAG Type */ + +TPM_RC +TSS_TPMI_ST_COMMAND_TAG_Unmarshalu(TPMI_ST_COMMAND_TAG *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM_ST_Unmarshalu(target, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + switch (*target) { + case TPM_ST_NO_SESSIONS: + case TPM_ST_SESSIONS: + break; + default: + rc = TPM_RC_BAD_TAG; + } + } + return rc; +} + +/* Table 70 TPMI_ALG_MAC_SCHEME */ + +TPM_RC +TSS_TPMI_ALG_MAC_SCHEME_Unmarshalu(TPMI_ALG_MAC_SCHEME *target, BYTE **buffer, uint32_t *size, BOOL allowNull) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM_ALG_ID_Unmarshalu(target, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + switch (*target) { +#ifdef TPM_ALG_SHA1 + case TPM_ALG_SHA1: +#endif +#ifdef TPM_ALG_SHA256 + case TPM_ALG_SHA256: +#endif +#ifdef TPM_ALG_SHA384 + case TPM_ALG_SHA384: +#endif +#ifdef TPM_ALG_SHA512 + case TPM_ALG_SHA512: +#endif +#ifdef TPM_ALG_SM3_256 + case TPM_ALG_SM3_256: +#endif +#ifdef TPM_ALG_CMAC + case TPM_ALG_CMAC: +#endif + break; + case TPM_ALG_NULL: + if (!allowNull) { + rc = TPM_RC_SYMMETRIC; + } + break; + default: + rc = TPM_RC_SYMMETRIC; + } + } + return rc; +} + +/* Table 70 TPMI_ALG_CIPHER_MODE */ + +TPM_RC +TSS_TPMI_ALG_CIPHER_MODE_Unmarshalu(TPMI_ALG_CIPHER_MODE*target, BYTE **buffer, uint32_t *size, BOOL allowNull) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM_ALG_ID_Unmarshalu(target, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + switch (*target) { +#ifdef TPM_ALG_CTR + case TPM_ALG_CTR: +#endif +#ifdef TPM_ALG_OFB + case TPM_ALG_OFB: +#endif +#ifdef TPM_ALG_CBC + case TPM_ALG_CBC: +#endif +#ifdef TPM_ALG_CFB + case TPM_ALG_CFB: +#endif +#ifdef TPM_ALG_ECB + case TPM_ALG_ECB: +#endif + break; + case TPM_ALG_NULL: + if (!allowNull) { + rc = TPM_RC_MODE; + } + break; + default: + rc = TPM_RC_MODE; + } + } + return rc; +} + +/* Table 68 - Definition of TPMS_EMPTY Structure <IN/OUT> */ + +/* NOTE: Marked as const function in header */ + +TPM_RC +TSS_TPMS_EMPTY_Unmarshalu(TPMS_EMPTY *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + target = target; + buffer = buffer; + size = size; + return rc; +} + +/* Table 70 - Definition of TPMU_HA Union <IN/OUT, S> */ + +TPM_RC +TSS_TPMU_HA_Unmarshalu(TPMU_HA *target, BYTE **buffer, uint32_t *size, uint32_t selector) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + switch (selector) { +#ifdef TPM_ALG_SHA1 + case TPM_ALG_SHA1: + rc = TSS_Array_Unmarshalu(target->sha1, SHA1_DIGEST_SIZE, buffer, size); + break; +#endif +#ifdef TPM_ALG_SHA256 + case TPM_ALG_SHA256: + rc = TSS_Array_Unmarshalu(target->sha256, SHA256_DIGEST_SIZE, buffer, size); + break; +#endif +#ifdef TPM_ALG_SHA384 + case TPM_ALG_SHA384: + rc =TSS_Array_Unmarshalu(target->sha384, SHA384_DIGEST_SIZE, buffer, size); + break; +#endif +#ifdef TPM_ALG_SHA512 + case TPM_ALG_SHA512: + rc = TSS_Array_Unmarshalu(target->sha512, SHA512_DIGEST_SIZE, buffer, size); + break; +#endif +#ifdef TPM_ALG_SM3_256 + case TPM_ALG_SM3_256: + rc = TSS_Array_Unmarshalu(target->sm3_256, SM3_256_DIGEST_SIZE, buffer, size); + break; +#endif + case TPM_ALG_NULL: + break; + default: + rc = TPM_RC_SELECTOR; + } + return rc; +} + +/* Table 71 - Definition of TPMT_HA Structure <IN/OUT> */ + +TPM_RC +TSS_TPMT_HA_Unmarshalu(TPMT_HA *target, BYTE **buffer, uint32_t *size, BOOL allowNull) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMI_ALG_HASH_Unmarshalu(&target->hashAlg, buffer, size, allowNull); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMU_HA_Unmarshalu(&target->digest, buffer, size, target->hashAlg); + } + return rc; +} + +/* Table 72 - Definition of TPM2B_DIGEST Structure */ + +TPM_RC +TSS_TPM2B_DIGEST_Unmarshalu(TPM2B_DIGEST *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_Unmarshalu(&target->b, sizeof(target->t.buffer), buffer, size); + } + return rc; +} + +/* Table 73 - Definition of TPM2B_DATA Structure */ + +TPM_RC +TSS_TPM2B_DATA_Unmarshalu(TPM2B_DATA *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_Unmarshalu(&target->b, sizeof(target->t.buffer), buffer, size); + } + return rc; +} + +/* Table 74 - Definition of Types for TPM2B_NONCE */ + +TPM_RC +TSS_TPM2B_NONCE_Unmarshalu(TPM2B_NONCE *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_DIGEST_Unmarshalu(target, buffer, size); + } + return rc; +} + +/* Table 75 - Definition of Types for TPM2B_AUTH */ + +TPM_RC +TSS_TPM2B_AUTH_Unmarshalu(TPM2B_AUTH *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_DIGEST_Unmarshalu(target, buffer, size); + } + return rc; +} + +/* Table 76 - Definition of Types for TPM2B_OPERAND */ + +TPM_RC +TSS_TPM2B_OPERAND_Unmarshalu(TPM2B_OPERAND *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_DIGEST_Unmarshalu(target, buffer, size); + } + return rc; +} + +/* Table 77 - Definition of TPM2B_EVENT Structure */ + +TPM_RC +TSS_TPM2B_EVENT_Unmarshalu(TPM2B_EVENT *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_Unmarshalu(&target->b, sizeof(target->t.buffer), buffer, size); + } + return rc; +} + +/* Table 78 - Definition of TPM2B_MAX_BUFFER Structure */ + +TPM_RC +TSS_TPM2B_MAX_BUFFER_Unmarshalu(TPM2B_MAX_BUFFER *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_Unmarshalu(&target->b, sizeof(target->t.buffer), buffer, size); + } + return rc; +} + +/* Table 79 - Definition of TPM2B_MAX_NV_BUFFER Structure */ + +TPM_RC +TSS_TPM2B_MAX_NV_BUFFER_Unmarshalu(TPM2B_MAX_NV_BUFFER *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_Unmarshalu(&target->b, sizeof(target->t.buffer), buffer, size); + } + return rc; +} + +/* Table 80 - Definition of TPM2B_TIMEOUT Structure <IN/OUT> */ + +TPM_RC +TSS_TPM2B_TIMEOUT_Unmarshalu(TPM2B_TIMEOUT *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_DIGEST_Unmarshalu(target, buffer, size); + } + return rc; +} + +/* Table 81 - Definition of TPM2B_IV Structure <IN/OUT> */ + +TPM_RC +TSS_TPM2B_IV_Unmarshalu(TPM2B_IV *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_Unmarshalu(&target->b, sizeof(target->t.buffer), buffer, size); + } + return rc; +} + +/* Table 83 - Definition of TPM2B_NAME Structure */ + +TPM_RC +TSS_TPM2B_NAME_Unmarshalu(TPM2B_NAME *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_Unmarshalu(&target->b, sizeof(target->t.name), buffer, size); + } + return rc; +} + +/* Table 85 - Definition of TPMS_PCR_SELECTION Structure */ + +TPM_RC +TSS_TPMS_PCR_SELECTION_Unmarshalu(TPMS_PCR_SELECTION *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMI_ALG_HASH_Unmarshalu(&target->hash, buffer, size, NO); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_UINT8_Unmarshalu(&target->sizeofSelect, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + if (target->sizeofSelect > PCR_SELECT_MAX) { + rc = TPM_RC_VALUE; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_Array_Unmarshalu(target->pcrSelect, target->sizeofSelect, buffer, size); + } + return rc; +} + +/* Table 88 - Definition of TPMT_TK_CREATION Structure */ + +TPM_RC +TSS_TPMT_TK_CREATION_Unmarshalu(TPMT_TK_CREATION *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM_ST_Unmarshalu(&target->tag, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + if (target->tag != TPM_ST_CREATION) { + rc = TPM_RC_TAG; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMI_RH_HIERARCHY_Unmarshalu(&target->hierarchy, buffer, size, YES); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_DIGEST_Unmarshalu(&target->digest, buffer, size); + } + return rc; +} + +/* Table 89 - Definition of TPMT_TK_VERIFIED Structure */ + +TPM_RC +TSS_TPMT_TK_VERIFIED_Unmarshalu(TPMT_TK_VERIFIED *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM_ST_Unmarshalu(&target->tag, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + if (target->tag != TPM_ST_VERIFIED) { + rc = TPM_RC_TAG; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMI_RH_HIERARCHY_Unmarshalu(&target->hierarchy, buffer, size, YES); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_DIGEST_Unmarshalu(&target->digest, buffer, size); + } + return rc; +} + +/* Table 90 - Definition of TPMT_TK_AUTH Structure */ + +TPM_RC +TSS_TPMT_TK_AUTH_Unmarshalu(TPMT_TK_AUTH *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM_ST_Unmarshalu(&target->tag, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + if ((target->tag != TPM_ST_AUTH_SIGNED) && + (target->tag != TPM_ST_AUTH_SECRET)) { + rc = TPM_RC_TAG; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMI_RH_HIERARCHY_Unmarshalu(&target->hierarchy, buffer, size, YES); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_DIGEST_Unmarshalu(&target->digest, buffer, size); + } + return rc; +} + +/* Table 91 - Definition of TPMT_TK_HASHCHECK Structure */ + +TPM_RC +TSS_TPMT_TK_HASHCHECK_Unmarshalu(TPMT_TK_HASHCHECK *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM_ST_Unmarshalu(&target->tag, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + if (target->tag != TPM_ST_HASHCHECK) { + rc = TPM_RC_TAG; + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMI_RH_HIERARCHY_Unmarshalu(&target->hierarchy, buffer, size, YES); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_DIGEST_Unmarshalu(&target->digest, buffer, size); + } + return rc; +} + +/* Table 92 - Definition of TPMS_ALG_PROPERTY Structure <OUT> */ + +TPM_RC +TSS_TPMS_ALG_PROPERTY_Unmarshalu(TPMS_ALG_PROPERTY *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM_ALG_ID_Unmarshalu(&target->alg, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMA_ALGORITHM_Unmarshalu(&target->algProperties, buffer, size); + } + return rc; +} + +/* Table 93 - Definition of TPMS_TAGGED_PROPERTY Structure <OUT> */ + +TPM_RC +TSS_TPMS_TAGGED_PROPERTY_Unmarshalu(TPMS_TAGGED_PROPERTY *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM_PT_Unmarshalu(&target->property, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_UINT32_Unmarshalu(&target->value, buffer, size); + } + return rc; +} + +/* Table 94 - Definition of TPMS_TAGGED_PCR_SELECT Structure <OUT> */ + +TPM_RC +TSS_TPMS_TAGGED_PCR_SELECT_Unmarshalu(TPMS_TAGGED_PCR_SELECT *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM_PT_PCR_Unmarshalu(&target->tag, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_UINT8_Unmarshalu(&target->sizeofSelect, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_Array_Unmarshalu(target->pcrSelect, target->sizeofSelect, buffer, size); + } + return rc; +} + +/* Table 100 - Definition of TPMS_TAGGED_POLICY Structure <OUT> */ + +TPM_RC +TSS_TPMS_TAGGED_POLICY_Unmarshalu(TPMS_TAGGED_POLICY *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM_HANDLE_Unmarshalu(&target->handle, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMT_HA_Unmarshalu(&target->policyHash, buffer, size, YES); + } + return rc; +} + +/* Table 95 - Definition of TPML_CC Structure */ + +TPM_RC +TSS_TPML_CC_Unmarshalu(TPML_CC *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + uint32_t i; + if (rc == TPM_RC_SUCCESS) { + rc = TSS_UINT32_Unmarshalu(&target->count, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + if (target->count > MAX_CAP_CC) { + rc = TPM_RC_SIZE; + } + } + for (i = 0 ; (rc == TPM_RC_SUCCESS) && (i < target->count) ; i++) { + rc = TSS_TPM_CC_Unmarshalu(&target->commandCodes[i], buffer, size); + } + return rc; +} + +/* Table 96 - Definition of TPML_CCA Structure <OUT> */ + +TPM_RC +TSS_TPML_CCA_Unmarshalu(TPML_CCA *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + uint32_t i; + if (rc == TPM_RC_SUCCESS) { + rc = TSS_UINT32_Unmarshalu(&target->count, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + if (target->count > MAX_CAP_CC) { + rc = TPM_RC_SIZE; + } + } + for (i = 0 ; (rc == TPM_RC_SUCCESS) && (i < target->count) ; i++) { + rc = TSS_TPMA_CC_Unmarshalu(&target->commandAttributes[i], buffer, size); + } + return rc; +} + +/* Table 97 - Definition of TPML_ALG Structure */ + +TPM_RC +TSS_TPML_ALG_Unmarshalu(TPML_ALG *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + uint32_t i; + if (rc == TPM_RC_SUCCESS) { + rc = TSS_UINT32_Unmarshalu(&target->count, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + if (target->count > MAX_ALG_LIST_SIZE) { + rc = TPM_RC_SIZE; + } + } + for (i = 0 ; (rc == TPM_RC_SUCCESS) && (i < target->count) ; i++) { + rc = TSS_TPM_ALG_ID_Unmarshalu(&target->algorithms[i], buffer, size); + } + return rc; +} + +/* Table 98 - Definition of TPML_HANDLE Structure <OUT> */ + +TPM_RC +TSS_TPML_HANDLE_Unmarshalu(TPML_HANDLE *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + uint32_t i; + if (rc == TPM_RC_SUCCESS) { + rc = TSS_UINT32_Unmarshalu(&target->count, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + if (target->count > MAX_CAP_HANDLES) { + rc = TPM_RC_SIZE; + } + } + for (i = 0 ; (rc == TPM_RC_SUCCESS) && (i < target->count) ; i++) { + rc = TSS_TPM_HANDLE_Unmarshalu(&target->handle[i], buffer, size); + } + return rc; +} + +/* Table 99 - Definition of TPML_DIGEST Structure */ + +/* PolicyOr has a restriction of at least a count of two. This function is also used to unmarshal + PCR_Read, where a count of one is permitted. +*/ + +TPM_RC +TSS_TPML_DIGEST_Unmarshalu(TPML_DIGEST *target, BYTE **buffer, uint32_t *size, uint32_t minCount) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + uint32_t i; + if (rc == TPM_RC_SUCCESS) { + rc = TSS_UINT32_Unmarshalu(&target->count, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + if (target->count < minCount) { + rc = TPM_RC_SIZE; + } + } + if (rc == TPM_RC_SUCCESS) { + if (target->count > 8) { + rc = TPM_RC_SIZE; + } + } + for (i = 0 ; (rc == TPM_RC_SUCCESS) && (i < target->count) ; i++) { + rc = TSS_TPM2B_DIGEST_Unmarshalu(&target->digests[i], buffer, size); + } + return rc; +} + +/* Table 100 - Definition of TPML_DIGEST_VALUES Structure */ + +TPM_RC +TSS_TPML_DIGEST_VALUES_Unmarshalu(TPML_DIGEST_VALUES *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + uint32_t i; + if (rc == TPM_RC_SUCCESS) { + rc = TSS_UINT32_Unmarshalu(&target->count, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + if (target->count > HASH_COUNT) { + rc = TPM_RC_SIZE; + } + } + for (i = 0 ; (rc == TPM_RC_SUCCESS) && (i < target->count) ; i++) { + rc = TSS_TPMT_HA_Unmarshalu(&target->digests[i], buffer, size, NO); + } + return rc; +} + +/* Table 102 - Definition of TPML_PCR_SELECTION Structure */ + +TPM_RC +TSS_TPML_PCR_SELECTION_Unmarshalu(TPML_PCR_SELECTION *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + uint32_t i; + if (rc == TPM_RC_SUCCESS) { + rc = TSS_UINT32_Unmarshalu(&target->count, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + if (target->count > HASH_COUNT) { + rc = TPM_RC_SIZE; + } + } + for (i = 0 ; (rc == TPM_RC_SUCCESS) && (i < target->count) ; i++) { + rc = TSS_TPMS_PCR_SELECTION_Unmarshalu(&target->pcrSelections[i], buffer, size); + } + return rc; +} + +/* Table 103 - Definition of TPML_ALG_PROPERTY Structure <OUT> */ + +TPM_RC +TSS_TPML_ALG_PROPERTY_Unmarshalu(TPML_ALG_PROPERTY *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + uint32_t i; + if (rc == TPM_RC_SUCCESS) { + rc = TSS_UINT32_Unmarshalu(&target->count, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + if (target->count > MAX_CAP_ALGS) { + rc = TPM_RC_SIZE; + } + } + for (i = 0 ; (rc == TPM_RC_SUCCESS) && (i < target->count) ; i++) { + rc = TSS_TPMS_ALG_PROPERTY_Unmarshalu(&target->algProperties[i], buffer, size); + } + return rc; +} + +/* Table 104 - Definition of TPML_TAGGED_TPM_PROPERTY Structure <OUT> */ + +TPM_RC +TSS_TPML_TAGGED_TPM_PROPERTY_Unmarshalu(TPML_TAGGED_TPM_PROPERTY *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + uint32_t i; + if (rc == TPM_RC_SUCCESS) { + rc = TSS_UINT32_Unmarshalu(&target->count, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + if (target->count > MAX_TPM_PROPERTIES) { + rc = TPM_RC_SIZE; + } + } + for (i = 0 ; (rc == TPM_RC_SUCCESS) && (i < target->count) ; i++) { + rc = TSS_TPMS_TAGGED_PROPERTY_Unmarshalu(&target->tpmProperty[i], buffer, size); + } + return rc; +} + +/* Table 105 - Definition of TPML_TAGGED_PCR_PROPERTY Structure <OUT> */ + +TPM_RC +TSS_TPML_TAGGED_PCR_PROPERTY_Unmarshalu(TPML_TAGGED_PCR_PROPERTY *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + uint32_t i; + if (rc == TPM_RC_SUCCESS) { + rc = TSS_UINT32_Unmarshalu(&target->count, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + if (target->count > MAX_PCR_PROPERTIES) { + rc = TPM_RC_SIZE; + } + } + for (i = 0 ; (rc == TPM_RC_SUCCESS) && (i < target->count) ; i++) { + rc = TSS_TPMS_TAGGED_PCR_SELECT_Unmarshalu(&target->pcrProperty[i], buffer, size); + } + return rc; +} + +/* Table 106 - Definition of {ECC} TPML_ECC_CURVE Structure <OUT> */ + +TPM_RC +TSS_TPML_ECC_CURVE_Unmarshalu(TPML_ECC_CURVE *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + uint32_t i; + if (rc == TPM_RC_SUCCESS) { + rc = TSS_UINT32_Unmarshalu(&target->count, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + if (target->count > MAX_ECC_CURVES) { + rc = TPM_RC_SIZE; + } + } + for (i = 0 ; (rc == TPM_RC_SUCCESS) && (i < target->count) ; i++) { + rc = TSS_TPM_ECC_CURVE_Unmarshalu(&target->eccCurves[i], buffer, size); + } + return rc; +} + +/* Table 112 - Definition of TPML_TAGGED_POLICY Structure <OUT> */ + +TPM_RC +TSS_TPML_TAGGED_POLICY_Unmarshalu(TPML_TAGGED_POLICY *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + uint32_t i; + if (rc == TPM_RC_SUCCESS) { + rc = TSS_UINT32_Unmarshalu(&target->count, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + if (target->count > MAX_TAGGED_POLICIES) { + rc = TPM_RC_SIZE; + } + } + for (i = 0 ; (rc == TPM_RC_SUCCESS) && (i < target->count) ; i++) { + rc = TSS_TPMS_TAGGED_POLICY_Unmarshalu(&target->policies[i], buffer, size); + } + return rc; +} + +/* Table 107 - Definition of TPMU_CAPABILITIES Union <OUT> */ + +TPM_RC +TSS_TPMU_CAPABILITIES_Unmarshalu(TPMU_CAPABILITIES *target, BYTE **buffer, uint32_t *size, uint32_t selector) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + switch (selector) { + case TPM_CAP_ALGS: + rc = TSS_TPML_ALG_PROPERTY_Unmarshalu(&target->algorithms, buffer, size); + break; + case TPM_CAP_HANDLES: + rc = TSS_TPML_HANDLE_Unmarshalu(&target->handles, buffer, size); + break; + case TPM_CAP_COMMANDS: + rc = TSS_TPML_CCA_Unmarshalu(&target->command, buffer, size); + break; + case TPM_CAP_PP_COMMANDS: + rc = TSS_TPML_CC_Unmarshalu(&target->ppCommands, buffer, size); + break; + case TPM_CAP_AUDIT_COMMANDS: + rc = TSS_TPML_CC_Unmarshalu(&target->auditCommands, buffer, size); + break; + case TPM_CAP_PCRS: + rc = TSS_TPML_PCR_SELECTION_Unmarshalu(&target->assignedPCR, buffer, size); + break; + case TPM_CAP_TPM_PROPERTIES: + rc = TSS_TPML_TAGGED_TPM_PROPERTY_Unmarshalu(&target->tpmProperties, buffer, size); + break; + case TPM_CAP_PCR_PROPERTIES: + rc = TSS_TPML_TAGGED_PCR_PROPERTY_Unmarshalu(&target->pcrProperties, buffer, size); + break; + case TPM_CAP_ECC_CURVES: + rc = TSS_TPML_ECC_CURVE_Unmarshalu(&target->eccCurves, buffer, size); + break; + case TPM_CAP_AUTH_POLICIES: + rc = TSS_TPML_TAGGED_POLICY_Unmarshalu(&target->authPolicies, buffer, size); + break; + default: + rc = TPM_RC_SELECTOR; + } + return rc; +} + +/* Table 108 - Definition of TPMS_CAPABILITY_DATA Structure <OUT> */ + +TPM_RC +TSS_TPMS_CAPABILITY_DATA_Unmarshalu(TPMS_CAPABILITY_DATA *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM_CAP_Unmarshalu(&target->capability, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMU_CAPABILITIES_Unmarshalu(&target->data, buffer, size, target->capability); + } + return rc; +} + +/* Table 109 - Definition of TPMS_CLOCK_INFO Structure */ + +TPM_RC +TSS_TPMS_CLOCK_INFO_Unmarshalu(TPMS_CLOCK_INFO *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_UINT64_Unmarshalu(&target->clock, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_UINT32_Unmarshalu(&target->resetCount, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_UINT32_Unmarshalu(&target->restartCount, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMI_YES_NO_Unmarshalu(&target->safe, buffer, size); + } + return rc; +} + +/* Table 110 - Definition of TPMS_TIME_INFO Structure */ + +TPM_RC +TSS_TPMS_TIME_INFO_Unmarshalu(TPMS_TIME_INFO *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_UINT64_Unmarshalu(&target->time, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMS_CLOCK_INFO_Unmarshalu(&target->clockInfo, buffer, size); + } + return rc; +} + +/* Table 111 - Definition of TPMS_TIME_ATTEST_INFO Structure <OUT> */ + +TPM_RC +TSS_TPMS_TIME_ATTEST_INFO_Unmarshalu(TPMS_TIME_ATTEST_INFO *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMS_TIME_INFO_Unmarshalu(&target->time, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_UINT64_Unmarshalu(&target->firmwareVersion, buffer, size); + } + return rc; +} + +/* Table 112 - Definition of TPMS_CERTIFY_INFO Structure <OUT> */ + +TPM_RC +TSS_TPMS_CERTIFY_INFO_Unmarshalu(TPMS_CERTIFY_INFO *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_NAME_Unmarshalu(&target->name, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_NAME_Unmarshalu(&target->qualifiedName, buffer, size); + } + return rc; +} + +/* Table 113 - Definition of TPMS_QUOTE_INFO Structure <OUT> */ + +TPM_RC +TSS_TPMS_QUOTE_INFO_Unmarshalu(TPMS_QUOTE_INFO *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPML_PCR_SELECTION_Unmarshalu(&target->pcrSelect, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_DIGEST_Unmarshalu(&target->pcrDigest, buffer, size); + } + return rc; +} + +/* Table 114 - Definition of TPMS_COMMAND_AUDIT_INFO Structure <OUT> */ + +TPM_RC +TSS_TPMS_COMMAND_AUDIT_INFO_Unmarshalu(TPMS_COMMAND_AUDIT_INFO *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_UINT64_Unmarshalu(&target->auditCounter, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM_ALG_ID_Unmarshalu(&target->digestAlg, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_DIGEST_Unmarshalu(&target->auditDigest, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_DIGEST_Unmarshalu(&target->commandDigest, buffer, size); + } + return rc; +} + +/* Table 115 - Definition of TPMS_SESSION_AUDIT_INFO Structure <OUT> */ + +TPM_RC +TSS_TPMS_SESSION_AUDIT_INFO_Unmarshalu(TPMS_SESSION_AUDIT_INFO *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMI_YES_NO_Unmarshalu(&target->exclusiveSession, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_DIGEST_Unmarshalu(&target->sessionDigest, buffer, size); + } + return rc; +} + +/* Table 116 - Definition of TPMS_CREATION_INFO Structure <OUT> */ + +TPM_RC +TSS_TPMS_CREATION_INFO_Unmarshalu(TPMS_CREATION_INFO *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_NAME_Unmarshalu(&target->objectName, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_DIGEST_Unmarshalu(&target->creationHash, buffer, size); + } + return rc; +} + +/* Table 117 - Definition of TPMS_NV_CERTIFY_INFO Structure <OUT> */ + +TPM_RC +TSS_TPMS_NV_CERTIFY_INFO_Unmarshalu(TPMS_NV_CERTIFY_INFO *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_NAME_Unmarshalu(&target->indexName, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_UINT16_Unmarshalu(&target->offset, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_MAX_NV_BUFFER_Unmarshalu(&target->nvContents, buffer, size); + } + return rc; +} + +/* Table 118 - Definition of (TPM_ST) TPMI_ST_ATTEST Type <OUT> */ + +TPM_RC +TSS_TPMI_ST_ATTEST_Unmarshalu(TPMI_ST_ATTEST *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM_ST_Unmarshalu(target, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + switch (*target) { + case TPM_ST_ATTEST_CERTIFY: + case TPM_ST_ATTEST_CREATION: + case TPM_ST_ATTEST_QUOTE: + case TPM_ST_ATTEST_COMMAND_AUDIT: + case TPM_ST_ATTEST_SESSION_AUDIT: + case TPM_ST_ATTEST_TIME: + case TPM_ST_ATTEST_NV: + break; + default: + rc = TPM_RC_SELECTOR; + } + } + return rc; +} + +/* Table 119 - Definition of TPMU_ATTEST Union <OUT> */ + +TPM_RC +TSS_TPMU_ATTEST_Unmarshalu(TPMU_ATTEST *target, BYTE **buffer, uint32_t *size, uint32_t selector) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + switch (selector) { + case TPM_ST_ATTEST_CERTIFY: + rc = TSS_TPMS_CERTIFY_INFO_Unmarshalu(&target->certify, buffer, size); + break; + case TPM_ST_ATTEST_CREATION: + rc = TSS_TPMS_CREATION_INFO_Unmarshalu(&target->creation, buffer, size); + break; + case TPM_ST_ATTEST_QUOTE: + rc = TSS_TPMS_QUOTE_INFO_Unmarshalu(&target->quote, buffer, size); + break; + case TPM_ST_ATTEST_COMMAND_AUDIT: + rc = TSS_TPMS_COMMAND_AUDIT_INFO_Unmarshalu(&target->commandAudit, buffer, size); + break; + case TPM_ST_ATTEST_SESSION_AUDIT: + rc = TSS_TPMS_SESSION_AUDIT_INFO_Unmarshalu(&target->sessionAudit, buffer, size); + break; + case TPM_ST_ATTEST_TIME: + rc = TSS_TPMS_TIME_ATTEST_INFO_Unmarshalu(&target->time, buffer, size); + break; + case TPM_ST_ATTEST_NV: + rc = TSS_TPMS_NV_CERTIFY_INFO_Unmarshalu(&target->nv, buffer, size); + break; + default: + rc = TPM_RC_SELECTOR; + + } + return rc; +} + +/* Table 120 - Definition of TPMS_ATTEST Structure <OUT> */ + +TPM_RC +TSS_TPMS_ATTEST_Unmarshalu(TPMS_ATTEST *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM_GENERATED_Unmarshalu(&target->magic, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMI_ST_ATTEST_Unmarshalu(&target->type, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_NAME_Unmarshalu(&target->qualifiedSigner, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_DATA_Unmarshalu(&target->extraData, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMS_CLOCK_INFO_Unmarshalu(&target->clockInfo, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_UINT64_Unmarshalu(&target->firmwareVersion, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMU_ATTEST_Unmarshalu(&target->attested, buffer, size, target->type); + } + return rc; +} + +/* Table 121 - Definition of TPM2B_ATTEST Structure <OUT> */ + +TPM_RC +TSS_TPM2B_ATTEST_Unmarshalu(TPM2B_ATTEST *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_Unmarshalu(&target->b, sizeof(target->t.attestationData), buffer, size); + } + return rc; +} + +/* Table 123 - Definition of TPMS_AUTH_RESPONSE Structure <OUT> */ + +TPM_RC +TSS_TPMS_AUTH_RESPONSE_Unmarshalu(TPMS_AUTH_RESPONSE *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_NONCE_Unmarshalu(&target->nonce, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMA_SESSION_Unmarshalu(&target->sessionAttributes, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_AUTH_Unmarshalu(&target->hmac, buffer, size); + } + return rc; +} + +/* Table 124 - Definition of {!ALG.S} (TPM_KEY_BITS) TPMI_!ALG.S_KEY_BITS Type */ + +#ifdef TPM_ALG_AES +TPM_RC +TSS_TPMI_AES_KEY_BITS_Unmarshalu(TPMI_AES_KEY_BITS *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM_KEY_BITS_Unmarshalu(target, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + switch (*target) { + case 128: + case 256: + break; + default: + rc = TPM_RC_VALUE; + } + } + return rc; +} +#endif + +#ifdef TPM_ALG_CAMELLIA +TPM_RC +TSS_TPMI_CAMELLIA_KEY_BITS_Unmarshalu(TPMI_CAMELLIA_KEY_BITS *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM_KEY_BITS_Unmarshalu(target, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + switch (*target) { + case 128: + break; + default: + rc = TPM_RC_VALUE; + } + } + return rc; +} +#endif + +#ifdef TPM_ALG_SM4 +TPM_RC +TSS_TPMI_SM4_KEY_BITS_Unmarshalu(TPMI_SM4_KEY_BITS *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM_KEY_BITS_Unmarshalu(target, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + switch (*target) { + case 128: + break; + default: + rc = TPM_RC_VALUE; + } + } + return rc; +} +#endif + +/* Table 125 - Definition of TPMU_SYM_KEY_BITS Union */ + +TPM_RC +TSS_TPMU_SYM_KEY_BITS_Unmarshalu(TPMU_SYM_KEY_BITS *target, BYTE **buffer, uint32_t *size, uint32_t selector) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + switch (selector) { +#ifdef TPM_ALG_AES + case TPM_ALG_AES: + rc = TSS_TPMI_AES_KEY_BITS_Unmarshalu(&target->aes, buffer, size); + break; +#endif +#ifdef TPM_ALG_SM4 + case TPM_ALG_SM4: + rc = TSS_TPMI_SM4_KEY_BITS_Unmarshalu(&target->sm4, buffer, size); + break; +#endif +#ifdef TPM_ALG_CAMELLIA + case TPM_ALG_CAMELLIA: + rc = TSS_TPMI_CAMELLIA_KEY_BITS_Unmarshalu(&target->camellia, buffer, size); + break; +#endif +#ifdef TPM_ALG_XOR + case TPM_ALG_XOR: + rc = TSS_TPMI_ALG_HASH_Unmarshalu(&target->xorr, buffer, size, NO); + break; +#endif + case TPM_ALG_NULL: + break; + default: + rc = TPM_RC_SELECTOR; + } + return rc; +} + +/* Table 126 - Definition of TPMU_SYM_MODE Union */ + +TPM_RC +TSS_TPMU_SYM_MODE_Unmarshalu(TPMU_SYM_MODE *target, BYTE **buffer, uint32_t *size, uint32_t selector) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + switch (selector) { +#ifdef TPM_ALG_AES + case TPM_ALG_AES: + rc = TSS_TPMI_ALG_SYM_MODE_Unmarshalu(&target->aes, buffer, size, YES); + break; +#endif +#ifdef TPM_ALG_SM4 + case TPM_ALG_SM4: + rc = TSS_TPMI_ALG_SYM_MODE_Unmarshalu(&target->sm4, buffer, size, YES); + break; +#endif +#ifdef TPM_ALG_CAMELLIA + case TPM_ALG_CAMELLIA: + rc = TSS_TPMI_ALG_SYM_MODE_Unmarshalu(&target->camellia, buffer, size, YES); + break; +#endif + case TPM_ALG_XOR: + case TPM_ALG_NULL: + break; + default: + rc = TPM_RC_SELECTOR; + } + return rc; +} + +/* Table 128 - Definition of TPMT_SYM_DEF Structure */ + +TPM_RC +TSS_TPMT_SYM_DEF_Unmarshalu(TPMT_SYM_DEF *target, BYTE **buffer, uint32_t *size, BOOL allowNull) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMI_ALG_SYM_Unmarshalu(&target->algorithm, buffer, size, allowNull); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMU_SYM_KEY_BITS_Unmarshalu(&target->keyBits, buffer, size, target->algorithm); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMU_SYM_MODE_Unmarshalu(&target->mode, buffer, size, target->algorithm); + } + return rc; +} + +/* Table 129 - Definition of TPMT_SYM_DEF_OBJECT Structure */ + +TPM_RC +TSS_TPMT_SYM_DEF_OBJECT_Unmarshalu(TPMT_SYM_DEF_OBJECT *target, BYTE **buffer, uint32_t *size, BOOL allowNull) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMI_ALG_SYM_OBJECT_Unmarshalu(&target->algorithm, buffer, size, allowNull); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMU_SYM_KEY_BITS_Unmarshalu(&target->keyBits, buffer, size, target->algorithm); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMU_SYM_MODE_Unmarshalu(&target->mode, buffer, size, target->algorithm); + } + return rc; +} + +/* Table 130 - Definition of TPM2B_SYM_KEY Structure */ + +TPM_RC +TSS_TPM2B_SYM_KEY_Unmarshalu(TPM2B_SYM_KEY *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_Unmarshalu(&target->b, sizeof(target->t.buffer), buffer, size); + } + return rc; +} + +/* Table 131 - Definition of TPMS_SYMCIPHER_PARMS Structure */ + +TPM_RC +TSS_TPMS_SYMCIPHER_PARMS_Unmarshalu(TPMS_SYMCIPHER_PARMS *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMT_SYM_DEF_OBJECT_Unmarshalu(&target->sym, buffer, size, NO); + } + return rc; +} + +/* Table 132 - Definition of TPM2B_SENSITIVE_DATA Structure */ + +TPM_RC +TSS_TPM2B_SENSITIVE_DATA_Unmarshalu(TPM2B_SENSITIVE_DATA *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_Unmarshalu(&target->b, sizeof(target->t.buffer), buffer, size); + } + return rc; +} + +/* Table 133 - Definition of TPMS_SENSITIVE_CREATE Structure <IN> */ + +TPM_RC +TSS_TPMS_SENSITIVE_CREATE_Unmarshalu(TPMS_SENSITIVE_CREATE *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_AUTH_Unmarshalu(&target->userAuth, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_SENSITIVE_DATA_Unmarshalu(&target->data, buffer, size); + } + return rc; +} + +/* Table 134 - Definition of TPM2B_SENSITIVE_CREATE Structure <IN, S> */ + +TPM_RC +TSS_TPM2B_SENSITIVE_CREATE_Unmarshalu(TPM2B_SENSITIVE_CREATE *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + uint32_t startSize = 0; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_UINT16_Unmarshalu(&target->size, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + if (target->size == 0) { + rc = TPM_RC_SIZE; + } + } + if (rc == TPM_RC_SUCCESS) { + startSize = *size; + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMS_SENSITIVE_CREATE_Unmarshalu(&target->sensitive, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + if (target->size != startSize - *size) { + rc = TPM_RC_SIZE; + } + } + return rc; +} + +/* Table 135 - Definition of TPMS_SCHEME_HASH Structure */ + +TPM_RC +TSS_TPMS_SCHEME_HASH_Unmarshalu(TPMS_SCHEME_HASH *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMI_ALG_HASH_Unmarshalu(&target->hashAlg, buffer, size, NO); + } + return rc; +} + +/* Table 136 - Definition of {ECC} TPMS_SCHEME_ECDAA Structure */ + +TPM_RC +TSS_TPMS_SCHEME_ECDAA_Unmarshalu(TPMS_SCHEME_ECDAA *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMI_ALG_HASH_Unmarshalu(&target->hashAlg, buffer, size, NO); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_UINT16_Unmarshalu(&target->count, buffer, size); + } + return rc; +} + +/* Table 137 - Definition of (TPM_ALG_ID) TPMI_ALG_KEYEDHASH_SCHEME Type */ + +TPM_RC +TSS_TPMI_ALG_KEYEDHASH_SCHEME_Unmarshalu(TPMI_ALG_KEYEDHASH_SCHEME *target, BYTE **buffer, uint32_t *size, BOOL allowNull) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM_ALG_ID_Unmarshalu(target, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + switch (*target) { +#ifdef TPM_ALG_HMAC + case TPM_ALG_HMAC: +#endif +#ifdef TPM_ALG_XOR + case TPM_ALG_XOR: +#endif + break; + case TPM_ALG_NULL: + if (!allowNull) { + rc = TPM_RC_VALUE; + } + break; + default: + rc = TPM_RC_VALUE; + } + } + return rc; +} + +/* Table 138 - Definition of Types for HMAC_SIG_SCHEME */ + +TPM_RC +TSS_TPMS_SCHEME_HMAC_Unmarshalu(TPMS_SCHEME_HMAC *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMS_SCHEME_HASH_Unmarshalu(target, buffer, size); + } + return rc; +} + +/* Table 139 - Definition of TPMS_SCHEME_XOR Structure */ + +TPM_RC +TSS_TPMS_SCHEME_XOR_Unmarshalu(TPMS_SCHEME_XOR *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMI_ALG_HASH_Unmarshalu(&target->hashAlg, buffer, size, NO); /* as of rev 147 */ + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMI_ALG_KDF_Unmarshalu(&target->kdf, buffer, size, YES); + } + return rc; +} + +/* Table 140 - Definition of TPMU_SCHEME_KEYEDHASH Union <IN/OUT, S> */ + +TPM_RC +TSS_TPMU_SCHEME_KEYEDHASH_Unmarshalu(TPMU_SCHEME_KEYEDHASH *target, BYTE **buffer, uint32_t *size, uint32_t selector) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + switch (selector) { +#ifdef TPM_ALG_HMAC + case TPM_ALG_HMAC: + rc = TSS_TPMS_SCHEME_HMAC_Unmarshalu(&target->hmac, buffer, size); + break; +#endif +#ifdef TPM_ALG_XOR + case TPM_ALG_XOR: + rc = TSS_TPMS_SCHEME_XOR_Unmarshalu(&target->xorr, buffer, size); + break; +#endif + case TPM_ALG_NULL: + break; + default: + rc = TPM_RC_SELECTOR; + } + return rc; +} + +/* Table 141 - Definition of TPMT_KEYEDHASH_SCHEME Structure */ + +TPM_RC +TSS_TPMT_KEYEDHASH_SCHEME_Unmarshalu(TPMT_KEYEDHASH_SCHEME *target, BYTE **buffer, uint32_t *size, BOOL allowNull) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMI_ALG_KEYEDHASH_SCHEME_Unmarshalu(&target->scheme, buffer, size, allowNull); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMU_SCHEME_KEYEDHASH_Unmarshalu(&target->details, buffer, size, target->scheme); + } + return rc; +} + +/* Table 142 - Definition of {RSA} Types for RSA Signature Schemes */ + +TPM_RC +TSS_TPMS_SIG_SCHEME_RSAPSS_Unmarshalu(TPMS_SIG_SCHEME_RSAPSS *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMS_SCHEME_HASH_Unmarshalu(target, buffer, size); + } + return rc; +} + +/* Table 142 - Definition of {RSA} Types for RSA Signature Schemes */ + +TPM_RC +TSS_TPMS_SIG_SCHEME_RSASSA_Unmarshalu(TPMS_SIG_SCHEME_RSASSA *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMS_SCHEME_HASH_Unmarshalu(target, buffer, size); + } + return rc; +} + +/* Table 143 - Definition of {ECC} Types for ECC Signature Schemes */ + +TPM_RC +TSS_TPMS_SIG_SCHEME_ECDAA_Unmarshalu(TPMS_SIG_SCHEME_ECDAA *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMS_SCHEME_ECDAA_Unmarshalu(target, buffer, size); + } + return rc; +} + +/* Table 143 - Definition of {ECC} Types for ECC Signature Schemes */ + +TPM_RC +TSS_TPMS_SIG_SCHEME_ECDSA_Unmarshalu(TPMS_SIG_SCHEME_ECDSA *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMS_SCHEME_HASH_Unmarshalu(target, buffer, size); + } + return rc; +} + +/* Table 143 - Definition of {ECC} Types for ECC Signature Schemes */ + +TPM_RC +TSS_TPMS_SIG_SCHEME_ECSCHNORR_Unmarshalu(TPMS_SIG_SCHEME_ECSCHNORR *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMS_SCHEME_HASH_Unmarshalu(target, buffer, size); + } + return rc; +} + +/* Table 143 - Definition of {ECC} Types for ECC Signature Schemes */ + +TPM_RC +TSS_TPMS_SIG_SCHEME_SM2_Unmarshalu(TPMS_SIG_SCHEME_SM2 *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMS_SCHEME_HASH_Unmarshalu(target, buffer, size); + } + return rc; +} + +/* Table 144 - Definition of TPMU_SIG_SCHEME Union <IN/OUT, S> */ + +TPM_RC +TSS_TPMU_SIG_SCHEME_Unmarshalu(TPMU_SIG_SCHEME *target, BYTE **buffer, uint32_t *size, uint32_t selector) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + switch (selector) { +#ifdef TPM_ALG_RSASSA + case TPM_ALG_RSASSA: + rc = TSS_TPMS_SIG_SCHEME_RSASSA_Unmarshalu(&target->rsassa, buffer, size); + break; +#endif +#ifdef TPM_ALG_RSAPSS + case TPM_ALG_RSAPSS: + rc = TSS_TPMS_SIG_SCHEME_RSAPSS_Unmarshalu(&target->rsapss, buffer, size); + break; +#endif +#ifdef TPM_ALG_ECDSA + case TPM_ALG_ECDSA: + rc = TSS_TPMS_SIG_SCHEME_ECDSA_Unmarshalu(&target->ecdsa, buffer, size); + break; +#endif +#ifdef TPM_ALG_ECDAA + case TPM_ALG_ECDAA: + rc = TSS_TPMS_SIG_SCHEME_ECDAA_Unmarshalu(&target->ecdaa, buffer, size); + break; +#endif +#ifdef TPM_ALG_SM2 + case TPM_ALG_SM2: + rc = TSS_TPMS_SIG_SCHEME_SM2_Unmarshalu(&target->sm2, buffer, size); + break; +#endif +#ifdef TPM_ALG_ECSCHNORR + case TPM_ALG_ECSCHNORR: + rc = TSS_TPMS_SIG_SCHEME_ECSCHNORR_Unmarshalu(&target->ecSchnorr, buffer, size); + break; +#endif +#ifdef TPM_ALG_HMAC + case TPM_ALG_HMAC: + rc = TSS_TPMS_SCHEME_HMAC_Unmarshalu(&target->hmac, buffer, size); + break; +#endif + case TPM_ALG_NULL: + break; + default: + rc = TPM_RC_SELECTOR; + } + return rc; +} + +/* Table 145 - Definition of TPMT_SIG_SCHEME Structure */ + +TPM_RC +TSS_TPMT_SIG_SCHEME_Unmarshalu(TPMT_SIG_SCHEME *target, BYTE **buffer, uint32_t *size, BOOL allowNull) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMI_ALG_SIG_SCHEME_Unmarshalu(&target->scheme, buffer, size, allowNull); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMU_SIG_SCHEME_Unmarshalu(&target->details, buffer, size, target->scheme); + } + return rc; +} + +/* Table 146 - Definition of Types for {RSA} Encryption Schemes */ + +TPM_RC +TSS_TPMS_ENC_SCHEME_OAEP_Unmarshalu(TPMS_ENC_SCHEME_OAEP *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMS_SCHEME_HASH_Unmarshalu(target, buffer, size); + } + return rc; +} + +/* Table 146 - Definition of Types for {RSA} Encryption Schemes */ + +/* NOTE: Marked as const function in header */ + +TPM_RC +TSS_TPMS_ENC_SCHEME_RSAES_Unmarshalu(TPMS_ENC_SCHEME_RSAES *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMS_EMPTY_Unmarshalu(target, buffer, size); + } + return rc; +} + +/* Table 147 - Definition of Types for {ECC} ECC Key Exchange */ + +TPM_RC +TSS_TPMS_KEY_SCHEME_ECDH_Unmarshalu(TPMS_KEY_SCHEME_ECDH *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMS_SCHEME_HASH_Unmarshalu(target, buffer, size); + } + return rc; +} + +/* Table 147 - Definition of Types for {ECC} ECC Key Exchange */ + +TPM_RC +TSS_TPMS_KEY_SCHEME_ECMQV_Unmarshalu(TPMS_KEY_SCHEME_ECMQV *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMS_SCHEME_HASH_Unmarshalu(target, buffer, size); + } + return rc; +} + +/* Table 148 - Definition of Types for KDF Schemes, hash-based key- or mask-generation functions */ + +TPM_RC +TSS_TPMS_SCHEME_KDF1_SP800_108_Unmarshalu(TPMS_SCHEME_KDF1_SP800_108 *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMS_SCHEME_HASH_Unmarshalu(target, buffer, size); + } + return rc; +} + +/* Table 148 - Definition of Types for KDF Schemes, hash-based key- or mask-generation functions */ + +TPM_RC +TSS_TPMS_SCHEME_KDF1_SP800_56A_Unmarshalu(TPMS_SCHEME_KDF1_SP800_56A *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMS_SCHEME_HASH_Unmarshalu(target, buffer, size); + } + return rc; +} + +/* Table 148 - Definition of Types for KDF Schemes, hash-based key- or mask-generation functions */ + +TPM_RC +TSS_TPMS_SCHEME_KDF2_Unmarshalu(TPMS_SCHEME_KDF2 *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMS_SCHEME_HASH_Unmarshalu(target, buffer, size); + } + return rc; +} + +/* Table 148 - Definition of Types for KDF Schemes, hash-based key- or mask-generation functions */ + +TPM_RC +TSS_TPMS_SCHEME_MGF1_Unmarshalu(TPMS_SCHEME_MGF1 *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMS_SCHEME_HASH_Unmarshalu(target, buffer, size); + } + return rc; +} + +/* Table 149 - Definition of TPMU_KDF_SCHEME Union <IN/OUT, S> */ + +TPM_RC +TSS_TPMU_KDF_SCHEME_Unmarshalu(TPMU_KDF_SCHEME *target, BYTE **buffer, uint32_t *size, uint32_t selector) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + switch (selector) { +#ifdef TPM_ALG_MGF1 + case TPM_ALG_MGF1: + rc = TSS_TPMS_SCHEME_MGF1_Unmarshalu(&target->mgf1, buffer, size); + break; +#endif +#ifdef TPM_ALG_KDF1_SP800_56A + case TPM_ALG_KDF1_SP800_56A: + rc = TSS_TPMS_SCHEME_KDF1_SP800_56A_Unmarshalu(&target->kdf1_SP800_56a, buffer, size); + break; +#endif +#ifdef TPM_ALG_KDF2 + case TPM_ALG_KDF2: + rc = TSS_TPMS_SCHEME_KDF2_Unmarshalu(&target->kdf2, buffer, size); + break; +#endif +#ifdef TPM_ALG_KDF1_SP800_108 + case TPM_ALG_KDF1_SP800_108: + rc = TSS_TPMS_SCHEME_KDF1_SP800_108_Unmarshalu(&target->kdf1_sp800_108, buffer, size); + break; +#endif + case TPM_ALG_NULL: + break; + default: + rc = TPM_RC_SELECTOR; + } + return rc; +} + +/* Table 150 - Definition of TPMT_KDF_SCHEME Structure */ + +TPM_RC +TSS_TPMT_KDF_SCHEME_Unmarshalu(TPMT_KDF_SCHEME *target, BYTE **buffer, uint32_t *size, BOOL allowNull) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMI_ALG_KDF_Unmarshalu(&target->scheme, buffer, size, allowNull); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMU_KDF_SCHEME_Unmarshalu(&target->details, buffer, size, target->scheme); + } + return rc; +} + +/* Table 151 - Definition of (TPM_ALG_ID) TPMI_ALG_ASYM_SCHEME Type <> */ + +#if 0 +TPM_RC +TSS_TPMI_ALG_ASYM_SCHEME_Unmarshalu(TPMI_ALG_ASYM_SCHEME *target, BYTE **buffer, uint32_t *size, BOOL allowNull) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM_ALG_ID_Unmarshalu(target, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + switch (*target) { +#ifdef TPM_ALG_ECDH + case TPM_ALG_ECDH: +#endif +#ifdef TPM_ALG_ECMQV + case TPM_ALG_ECMQV: +#endif +#ifdef TPM_ALG_RSASSA + case TPM_ALG_RSASSA: +#endif +#ifdef TPM_ALG_RSAPSS + case TPM_ALG_RSAPSS: +#endif +#ifdef TPM_ALG_ECDSA + case TPM_ALG_ECDSA: +#endif +#ifdef TPM_ALG_ECDAA + case TPM_ALG_ECDAA: +#endif +#ifdef TPM_ALG_SM2 + case TPM_ALG_SM2: +#endif +#ifdef TPM_ALG_ECSCHNORR + case TPM_ALG_ECSCHNORR: +#endif +#ifdef TPM_ALG_RSAES + case TPM_ALG_RSAES: +#endif +#ifdef TPM_ALG_OAEP + case TPM_ALG_OAEP: +#endif + break; + case TPM_ALG_NULL: + if (!allowNull) { + rc = TPM_RC_VALUE; + } + break; + default: + rc = TPM_RC_VALUE; + } + } + return rc; +} +#endif + +/* Table 152 - Definition of TPMU_ASYM_SCHEME Union */ + +TPM_RC +TSS_TPMU_ASYM_SCHEME_Unmarshalu(TPMU_ASYM_SCHEME *target, BYTE **buffer, uint32_t *size, uint32_t selector) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + switch (selector) { +#ifdef TPM_ALG_ECDH + case TPM_ALG_ECDH: + rc = TSS_TPMS_KEY_SCHEME_ECDH_Unmarshalu(&target->ecdh, buffer, size); + break; +#endif +#ifdef TPM_ALG_ECMQV + case TPM_ALG_ECMQV: + rc = TSS_TPMS_KEY_SCHEME_ECMQV_Unmarshalu(&target->ecmqvh, buffer, size); + break; +#endif +#ifdef TPM_ALG_RSASSA + case TPM_ALG_RSASSA: + rc = TSS_TPMS_SIG_SCHEME_RSASSA_Unmarshalu(&target->rsassa, buffer, size); + break; +#endif +#ifdef TPM_ALG_RSAPSS + case TPM_ALG_RSAPSS: + rc = TSS_TPMS_SIG_SCHEME_RSAPSS_Unmarshalu(&target->rsapss, buffer, size); + break; +#endif +#ifdef TPM_ALG_ECDSA + case TPM_ALG_ECDSA: + rc = TSS_TPMS_SIG_SCHEME_ECDSA_Unmarshalu(&target->ecdsa, buffer, size); + break; +#endif +#ifdef TPM_ALG_ECDAA + case TPM_ALG_ECDAA: + rc = TSS_TPMS_SIG_SCHEME_ECDAA_Unmarshalu(&target->ecdaa, buffer, size); + break; +#endif +#ifdef TPM_ALG_SM2 + case TPM_ALG_SM2: + rc = TSS_TPMS_SIG_SCHEME_SM2_Unmarshalu(&target->sm2, buffer, size); + break; +#endif +#ifdef TPM_ALG_ECSCHNORR + case TPM_ALG_ECSCHNORR: + rc = TSS_TPMS_SIG_SCHEME_ECSCHNORR_Unmarshalu(&target->ecSchnorr, buffer, size); + break; +#endif +#ifdef TPM_ALG_RSAES + case TPM_ALG_RSAES: + rc = TSS_TPMS_ENC_SCHEME_RSAES_Unmarshalu(&target->rsaes, buffer, size); + break; +#endif +#ifdef TPM_ALG_OAEP + case TPM_ALG_OAEP: + rc = TSS_TPMS_ENC_SCHEME_OAEP_Unmarshalu(&target->oaep, buffer, size); + break; +#endif + case TPM_ALG_NULL: + break; + default: + rc = TPM_RC_SELECTOR; + } + return rc; +} + +/* Table 153 - Definition of TPMT_ASYM_SCHEME Structure <> */ + +#if 0 +TPM_RC +TSS_TPMT_ASYM_SCHEME_Unmarshalu(TPMT_ASYM_SCHEME *target, BYTE **buffer, uint32_t *size, BOOL allowNull) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMI_ALG_ASYM_SCHEME_Unmarshalu(&target->scheme, buffer, size, allowNull); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMU_ASYM_SCHEME_Unmarshalu(&target->details, buffer, size, target->scheme); + } + return rc; +} +#endif + +/* Table 154 - Definition of (TPM_ALG_ID) {RSA} TPMI_ALG_RSA_SCHEME Type */ + +TPM_RC +TSS_TPMI_ALG_RSA_SCHEME_Unmarshalu(TPMI_ALG_RSA_SCHEME *target, BYTE **buffer, uint32_t *size, BOOL allowNull) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM_ALG_ID_Unmarshalu(target, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + switch (*target) { +#ifdef TPM_ALG_RSASSA + case TPM_ALG_RSASSA: +#endif +#ifdef TPM_ALG_RSAPSS + case TPM_ALG_RSAPSS: +#endif +#ifdef TPM_ALG_RSAES + case TPM_ALG_RSAES: +#endif +#ifdef TPM_ALG_OAEP + case TPM_ALG_OAEP: +#endif + break; + case TPM_ALG_NULL: + if (!allowNull) { + rc = TPM_RC_VALUE; + } + break; + default: + rc = TPM_RC_VALUE; + } + } + return rc; +} + +/* Table 155 - Definition of {RSA} TPMT_RSA_SCHEME Structure */ + +TPM_RC +TSS_TPMT_RSA_SCHEME_Unmarshalu(TPMT_RSA_SCHEME *target, BYTE **buffer, uint32_t *size, BOOL allowNull) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMI_ALG_RSA_SCHEME_Unmarshalu(&target->scheme, buffer, size, allowNull); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMU_ASYM_SCHEME_Unmarshalu(&target->details, buffer, size, target->scheme); + } + return rc; +} + +/* Table 156 - Definition of (TPM_ALG_ID) {RSA} TPMI_ALG_RSA_DECRYPT Type */ + +TPM_RC +TSS_TPMI_ALG_RSA_DECRYPT_Unmarshalu(TPMI_ALG_RSA_DECRYPT *target, BYTE **buffer, uint32_t *size, BOOL allowNull) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM_ALG_ID_Unmarshalu(target, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + switch (*target) { +#ifdef TPM_ALG_RSAES + case TPM_ALG_RSAES: +#endif +#ifdef TPM_ALG_OAEP + case TPM_ALG_OAEP: +#endif + break; + case TPM_ALG_NULL: + if (!allowNull) { + rc = TPM_RC_VALUE; + } + break; + default: + rc = TPM_RC_VALUE; + } + } + return rc; +} + +/* Table 157 - Definition of {RSA} TPMT_RSA_DECRYPT Structure */ + +TPM_RC +TSS_TPMT_RSA_DECRYPT_Unmarshalu(TPMT_RSA_DECRYPT *target, BYTE **buffer, uint32_t *size, BOOL allowNull) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMI_ALG_RSA_DECRYPT_Unmarshalu(&target->scheme, buffer, size, allowNull); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMU_ASYM_SCHEME_Unmarshalu(&target->details, buffer, size, target->scheme); + } + return rc; +} + +/* Table 158 - Definition of {RSA} TPM2B_PUBLIC_KEY_RSA Structure */ + +TPM_RC +TSS_TPM2B_PUBLIC_KEY_RSA_Unmarshalu(TPM2B_PUBLIC_KEY_RSA *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_Unmarshalu(&target->b, sizeof(target->t.buffer), buffer, size); + } + return rc; +} + +/* Table 159 - Definition of {RSA} (TPM_KEY_BITS) TPMI_RSA_KEY_BITS Type */ + +TPM_RC +TSS_TPMI_RSA_KEY_BITS_Unmarshalu(TPMI_RSA_KEY_BITS *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM_KEY_BITS_Unmarshalu(target, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + switch (*target) { + case 1024: + case 2048: + break; + default: + rc = TPM_RC_VALUE; + } + } + return rc; +} + +/* Table 160 - Definition of {RSA} TPM2B_PRIVATE_KEY_RSA Structure */ + +TPM_RC +TSS_TPM2B_PRIVATE_KEY_RSA_Unmarshalu(TPM2B_PRIVATE_KEY_RSA *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_Unmarshalu(&target->b, sizeof(target->t.buffer), buffer, size); + } + return rc; +} + +/* Table 161 - Definition of {ECC} TPM2B_ECC_PARAMETER Structure */ + +TPM_RC +TSS_TPM2B_ECC_PARAMETER_Unmarshalu(TPM2B_ECC_PARAMETER *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_Unmarshalu(&target->b, sizeof(target->t.buffer), buffer, size); + } + return rc; +} + +/* Table 162 - Definition of {ECC} TPMS_ECC_POINT Structure */ + +TPM_RC +TSS_TPMS_ECC_POINT_Unmarshalu(TPMS_ECC_POINT *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_ECC_PARAMETER_Unmarshalu(&target->x, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_ECC_PARAMETER_Unmarshalu(&target->y, buffer, size); + } + return rc; +} + +/* Table 163 - Definition of {ECC} TPM2B_ECC_POINT Structure */ + +TPM_RC +TSS_TPM2B_ECC_POINT_Unmarshalu(TPM2B_ECC_POINT *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + uint32_t startSize = 0; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_UINT16_Unmarshalu(&target->size, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + if (target->size == 0) { + rc = TPM_RC_SIZE; + } + } + if (rc == TPM_RC_SUCCESS) { + startSize = *size; + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMS_ECC_POINT_Unmarshalu(&target->point, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + if (target->size != startSize - *size) { + rc = TPM_RC_SIZE; + } + } + return rc; +} + +/* Table 164 - Definition of (TPM_ALG_ID) {ECC} TPMI_ALG_ECC_SCHEME Type */ + +TPM_RC +TSS_TPMI_ALG_ECC_SCHEME_Unmarshalu(TPMI_ALG_ECC_SCHEME *target, BYTE **buffer, uint32_t *size, BOOL allowNull) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM_ALG_ID_Unmarshalu(target, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + switch (*target) { +#ifdef TPM_ALG_ECDSA + case TPM_ALG_ECDSA: +#endif +#ifdef TPM_ALG_SM2 + case TPM_ALG_SM2: +#endif +#ifdef TPM_ALG_ECDAA + case TPM_ALG_ECDAA: +#endif +#ifdef TPM_ALG_ECSCHNORR + case TPM_ALG_ECSCHNORR: +#endif +#ifdef TPM_ALG_ECDH + case TPM_ALG_ECDH: +#endif +#ifdef TPM_ALG_ECMQV + case TPM_ALG_ECMQV: +#endif + break; + case TPM_ALG_NULL: + if (!allowNull) { + rc = TPM_RC_SCHEME; + } + break; + default: + rc = TPM_RC_SCHEME; + } + } + return rc; +} + +/* Table 165 - Definition of {ECC} (TPM_ECC_CURVE) TPMI_ECC_CURVE Type */ + +TPM_RC +TSS_TPMI_ECC_CURVE_Unmarshalu(TPMI_ECC_CURVE *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM_ECC_CURVE_Unmarshalu(target, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + switch (*target) { + case TPM_ECC_BN_P256: + case TPM_ECC_NIST_P256: + case TPM_ECC_NIST_P384: + break; + default: + rc = TPM_RC_CURVE; + } + } + return rc; +} + +/* Table 166 - Definition of (TPMT_SIG_SCHEME) {ECC} TPMT_ECC_SCHEME Structure */ + +TPM_RC +TSS_TPMT_ECC_SCHEME_Unmarshalu(TPMT_ECC_SCHEME *target, BYTE **buffer, uint32_t *size, BOOL allowNull) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMI_ALG_ECC_SCHEME_Unmarshalu(&target->scheme, buffer, size, allowNull); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMU_ASYM_SCHEME_Unmarshalu(&target->details, buffer, size, target->scheme); + } + return rc; +} + +/* Table 167 - Definition of {ECC} TPMS_ALGORITHM_DETAIL_ECC Structure <OUT> */ + +TPM_RC +TSS_TPMS_ALGORITHM_DETAIL_ECC_Unmarshalu(TPMS_ALGORITHM_DETAIL_ECC *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM_ECC_CURVE_Unmarshalu(&target->curveID, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_UINT16_Unmarshalu(&target->keySize, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMT_KDF_SCHEME_Unmarshalu(&target->kdf, buffer, size, YES); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMT_ECC_SCHEME_Unmarshalu(&target->sign, buffer, size, YES); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_ECC_PARAMETER_Unmarshalu(&target->p, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_ECC_PARAMETER_Unmarshalu(&target->a, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_ECC_PARAMETER_Unmarshalu(&target->b, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_ECC_PARAMETER_Unmarshalu(&target->gX, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_ECC_PARAMETER_Unmarshalu(&target->gY, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_ECC_PARAMETER_Unmarshalu(&target->n, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_ECC_PARAMETER_Unmarshalu(&target->h, buffer, size); + } + return rc; +} + +/* Table 168 - Definition of {RSA} TPMS_SIGNATURE_RSA Structure */ + +TPM_RC +TSS_TPMS_SIGNATURE_RSA_Unmarshalu(TPMS_SIGNATURE_RSA *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMI_ALG_HASH_Unmarshalu(&target->hash, buffer, size, NO); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_PUBLIC_KEY_RSA_Unmarshalu(&target->sig, buffer, size); + } + return rc; +} + +/* Table 169 - Definition of Types for {RSA} Signature */ + +TPM_RC +TSS_TPMS_SIGNATURE_RSASSA_Unmarshalu(TPMS_SIGNATURE_RSASSA *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMS_SIGNATURE_RSA_Unmarshalu(target, buffer, size); + } + return rc; +} + +/* Table 169 - Definition of Types for {RSA} Signature */ + +TPM_RC +TSS_TPMS_SIGNATURE_RSAPSS_Unmarshalu(TPMS_SIGNATURE_RSAPSS *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMS_SIGNATURE_RSA_Unmarshalu(target, buffer, size); + } + return rc; +} + +/* Table 170 - Definition of {ECC} TPMS_SIGNATURE_ECC Structure */ + +TPM_RC +TSS_TPMS_SIGNATURE_ECC_Unmarshalu(TPMS_SIGNATURE_ECC *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMI_ALG_HASH_Unmarshalu(&target->hash, buffer, size, NO); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_ECC_PARAMETER_Unmarshalu(&target->signatureR, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_ECC_PARAMETER_Unmarshalu(&target->signatureS, buffer, size); + } + return rc; +} + +/* Table 171 - Definition of Types for {ECC} TPMS_SIGNATURE_ECC */ + +TPM_RC +TSS_TPMS_SIGNATURE_ECDSA_Unmarshalu(TPMS_SIGNATURE_ECDSA *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMS_SIGNATURE_ECC_Unmarshalu(target, buffer, size); + } + return rc; +} + +TPM_RC +TSS_TPMS_SIGNATURE_ECDAA_Unmarshalu(TPMS_SIGNATURE_ECDAA *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMS_SIGNATURE_ECC_Unmarshalu(target, buffer, size); + } + return rc; +} + +TPM_RC +TSS_TPMS_SIGNATURE_SM2_Unmarshalu(TPMS_SIGNATURE_SM2 *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMS_SIGNATURE_ECC_Unmarshalu(target, buffer, size); + } + return rc; +} + +TPM_RC +TSS_TPMS_SIGNATURE_ECSCHNORR_Unmarshalu(TPMS_SIGNATURE_ECSCHNORR *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMS_SIGNATURE_ECC_Unmarshalu(target, buffer, size); + } + return rc; +} + +/* Table 172 - Definition of TPMU_SIGNATURE Union <IN/OUT, S> */ + +TPM_RC +TSS_TPMU_SIGNATURE_Unmarshalu(TPMU_SIGNATURE *target, BYTE **buffer, uint32_t *size, uint32_t selector) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + switch (selector) { +#ifdef TPM_ALG_RSASSA + case TPM_ALG_RSASSA: + rc = TSS_TPMS_SIGNATURE_RSASSA_Unmarshalu(&target->rsassa, buffer, size); + break; +#endif +#ifdef TPM_ALG_RSAPSS + case TPM_ALG_RSAPSS: + rc = TSS_TPMS_SIGNATURE_RSAPSS_Unmarshalu(&target->rsapss, buffer, size); + break; +#endif +#ifdef TPM_ALG_ECDSA + case TPM_ALG_ECDSA: + rc = TSS_TPMS_SIGNATURE_ECDSA_Unmarshalu(&target->ecdsa, buffer, size); + break; +#endif +#ifdef TPM_ALG_ECDAA + case TPM_ALG_ECDAA: + rc = TSS_TPMS_SIGNATURE_ECDAA_Unmarshalu(&target->ecdaa, buffer, size); + break; +#endif +#ifdef TPM_ALG_SM2 + case TPM_ALG_SM2: + rc = TSS_TPMS_SIGNATURE_SM2_Unmarshalu(&target->sm2, buffer, size); + break; +#endif +#ifdef TPM_ALG_ECSCHNORR + case TPM_ALG_ECSCHNORR: + rc = TSS_TPMS_SIGNATURE_ECSCHNORR_Unmarshalu(&target->ecschnorr, buffer, size); + break; +#endif +#ifdef TPM_ALG_HMAC + case TPM_ALG_HMAC: + rc = TSS_TPMT_HA_Unmarshalu(&target->hmac, buffer, size, NO); + break; +#endif + case TPM_ALG_NULL: + break; + default: + rc = TPM_RC_SELECTOR; + } + return rc; +} + +/* Table 173 - Definition of TPMT_SIGNATURE Structure */ + +TPM_RC +TSS_TPMT_SIGNATURE_Unmarshalu(TPMT_SIGNATURE *target, BYTE **buffer, uint32_t *size, BOOL allowNull) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMI_ALG_SIG_SCHEME_Unmarshalu(&target->sigAlg, buffer, size, allowNull); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMU_SIGNATURE_Unmarshalu(&target->signature, buffer, size, target->sigAlg); + } + return rc; +} + +/* Table 175 - Definition of TPM2B_ENCRYPTED_SECRET Structure */ + +TPM_RC +TSS_TPM2B_ENCRYPTED_SECRET_Unmarshalu(TPM2B_ENCRYPTED_SECRET *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_Unmarshalu(&target->b, sizeof(target->t.secret), buffer, size); + } + return rc; +} + +/* Table 176 - Definition of (TPM_ALG_ID) TPMI_ALG_PUBLIC Type */ + +TPM_RC +TSS_TPMI_ALG_PUBLIC_Unmarshalu(TPMI_ALG_PUBLIC *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM_ALG_ID_Unmarshalu(target, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + switch (*target) { +#ifdef TPM_ALG_KEYEDHASH + case TPM_ALG_KEYEDHASH: +#endif +#ifdef TPM_ALG_RSA + case TPM_ALG_RSA: +#endif +#ifdef TPM_ALG_ECC + case TPM_ALG_ECC: +#endif +#ifdef TPM_ALG_SYMCIPHER + case TPM_ALG_SYMCIPHER: +#endif + break; + default: + rc = TPM_RC_TYPE; + } + } + return rc; +} + +/* Table 177 - Definition of TPMU_PUBLIC_ID Union <IN/OUT, S> */ + +TPM_RC +TSS_TPMU_PUBLIC_ID_Unmarshalu(TPMU_PUBLIC_ID *target, BYTE **buffer, uint32_t *size, uint32_t selector) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + switch (selector) { +#ifdef TPM_ALG_KEYEDHASH + case TPM_ALG_KEYEDHASH: + rc = TSS_TPM2B_DIGEST_Unmarshalu(&target->keyedHash, buffer, size); + break; +#endif +#ifdef TPM_ALG_SYMCIPHER + case TPM_ALG_SYMCIPHER: + rc = TSS_TPM2B_DIGEST_Unmarshalu(&target->sym, buffer, size); + break; +#endif +#ifdef TPM_ALG_RSA + case TPM_ALG_RSA: + rc = TSS_TPM2B_PUBLIC_KEY_RSA_Unmarshalu(&target->rsa, buffer, size); + break; +#endif +#ifdef TPM_ALG_ECC + case TPM_ALG_ECC: + rc = TSS_TPMS_ECC_POINT_Unmarshalu(&target->ecc, buffer, size); + break; +#endif + default: + rc = TPM_RC_SELECTOR; + } + return rc; +} + +/* Table 178 - Definition of TPMS_KEYEDHASH_PARMS Structure */ + +TPM_RC +TSS_TPMS_KEYEDHASH_PARMS_Unmarshalu(TPMS_KEYEDHASH_PARMS *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMT_KEYEDHASH_SCHEME_Unmarshalu(&target->scheme, buffer, size, YES); + } + return rc; +} + +/* Table 179 - Definition of TPMS_ASYM_PARMS Structure <> */ + +#if 0 +TPM_RC +TSS_TPMS_ASYM_PARMS_Unmarshalu(TPMS_ASYM_PARMS *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMT_SYM_DEF_OBJECT_Unmarshalu(&target->symmetric, buffer, size, YES); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMT_ASYM_SCHEME_Unmarshalu(&target->scheme, buffer, size, YES); + } + return rc; +} +#endif + +/* Table 180 - Definition of {RSA} TPMS_RSA_PARMS Structure */ + +TPM_RC +TSS_TPMS_RSA_PARMS_Unmarshalu(TPMS_RSA_PARMS *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMT_SYM_DEF_OBJECT_Unmarshalu(&target->symmetric, buffer, size, YES); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMT_RSA_SCHEME_Unmarshalu(&target->scheme, buffer, size, YES); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMI_RSA_KEY_BITS_Unmarshalu(&target->keyBits, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_UINT32_Unmarshalu(&target->exponent, buffer, size); + } + return rc; +} + +/* Table 181 - Definition of {ECC} TPMS_ECC_PARMS Structure */ + +TPM_RC +TSS_TPMS_ECC_PARMS_Unmarshalu(TPMS_ECC_PARMS *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMT_SYM_DEF_OBJECT_Unmarshalu(&target->symmetric, buffer, size, YES); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMT_ECC_SCHEME_Unmarshalu(&target->scheme, buffer, size, YES); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMI_ECC_CURVE_Unmarshalu(&target->curveID, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMT_KDF_SCHEME_Unmarshalu(&target->kdf, buffer, size, YES); + } + return rc; +} + +/* Table 182 - Definition of TPMU_PUBLIC_PARMS Union <IN/OUT, S> */ + +TPM_RC +TSS_TPMU_PUBLIC_PARMS_Unmarshalu(TPMU_PUBLIC_PARMS *target, BYTE **buffer, uint32_t *size, uint32_t selector) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + switch (selector) { +#ifdef TPM_ALG_KEYEDHASH + case TPM_ALG_KEYEDHASH: + rc = TSS_TPMS_KEYEDHASH_PARMS_Unmarshalu(&target->keyedHashDetail, buffer, size); + break; +#endif +#ifdef TPM_ALG_SYMCIPHER + case TPM_ALG_SYMCIPHER: + rc = TSS_TPMS_SYMCIPHER_PARMS_Unmarshalu(&target->symDetail, buffer, size); + break; +#endif +#ifdef TPM_ALG_RSA + case TPM_ALG_RSA: + rc = TSS_TPMS_RSA_PARMS_Unmarshalu(&target->rsaDetail, buffer, size); + break; +#endif +#ifdef TPM_ALG_ECC + case TPM_ALG_ECC: + rc = TSS_TPMS_ECC_PARMS_Unmarshalu(&target->eccDetail, buffer, size); + break; +#endif + default: + rc = TPM_RC_SELECTOR; + } + return rc; +} + +/* Table 183 - Definition of TPMT_PUBLIC_PARMS Structure */ + +TPM_RC +TSS_TPMT_PUBLIC_PARMS_Unmarshalu(TPMT_PUBLIC_PARMS *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMI_ALG_PUBLIC_Unmarshalu(&target->type, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMU_PUBLIC_PARMS_Unmarshalu(&target->parameters, buffer, size, target->type); + } + return rc; +} + +/* Table 184 - Definition of TPMT_PUBLIC Structure */ + +TPM_RC +TSS_TPMT_PUBLIC_Unmarshalu(TPMT_PUBLIC *target, BYTE **buffer, uint32_t *size, BOOL allowNull) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMI_ALG_PUBLIC_Unmarshalu(&target->type, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMI_ALG_HASH_Unmarshalu(&target->nameAlg, buffer, size, allowNull); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMA_OBJECT_Unmarshalu(&target->objectAttributes, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_DIGEST_Unmarshalu(&target->authPolicy, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMU_PUBLIC_PARMS_Unmarshalu(&target->parameters, buffer, size, target->type); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMU_PUBLIC_ID_Unmarshalu(&target->unique, buffer, size, target->type); + } + return rc; +} + +/* Table 185 - Definition of TPM2B_PUBLIC Structure */ + +TPM_RC +TSS_TPM2B_PUBLIC_Unmarshalu(TPM2B_PUBLIC *target, BYTE **buffer, uint32_t *size, BOOL allowNull) +{ + TPM_RC rc = TPM_RC_SUCCESS; + uint32_t startSize = 0; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_UINT16_Unmarshalu(&target->size, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + if (target->size == 0) { + rc = TPM_RC_SIZE; + } + } + if (rc == TPM_RC_SUCCESS) { + startSize = *size; + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMT_PUBLIC_Unmarshalu(&target->publicArea, buffer, size, allowNull); + } + if (rc == TPM_RC_SUCCESS) { + if (target->size != startSize - *size) { + rc = TPM_RC_SIZE; + } + } + return rc; +} + +/* Table 192 - Definition of TPM2B_TEMPLATE Structure */ + +TPM_RC +TSS_TPM2B_TEMPLATE_Unmarshalu(TPM2B_TEMPLATE *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_Unmarshalu(&target->b, sizeof(target->t.buffer), buffer, size); + } + return rc; +} + +/* Table 187 - Definition of TPMU_SENSITIVE_COMPOSITE Union <IN/OUT, S> */ + +TPM_RC +TSS_TPMU_SENSITIVE_COMPOSITE_Unmarshalu(TPMU_SENSITIVE_COMPOSITE *target, BYTE **buffer, uint32_t *size, uint32_t selector) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + switch (selector) { +#ifdef TPM_ALG_RSA + case TPM_ALG_RSA: + rc = TSS_TPM2B_PRIVATE_KEY_RSA_Unmarshalu(&target->rsa, buffer, size); + break; +#endif +#ifdef TPM_ALG_ECC + case TPM_ALG_ECC: + rc = TSS_TPM2B_ECC_PARAMETER_Unmarshalu(&target->ecc, buffer, size); + break; +#endif +#ifdef TPM_ALG_KEYEDHASH + case TPM_ALG_KEYEDHASH: + rc = TSS_TPM2B_SENSITIVE_DATA_Unmarshalu(&target->bits, buffer, size); + break; +#endif +#ifdef TPM_ALG_SYMCIPHER + case TPM_ALG_SYMCIPHER: + rc = TSS_TPM2B_SYM_KEY_Unmarshalu(&target->sym, buffer, size); + break; +#endif + default: + rc = TPM_RC_SELECTOR; + } + return rc; +} + +/* Table 188 - Definition of TPMT_SENSITIVE Structure */ + +TPM_RC +TSS_TPMT_SENSITIVE_Unmarshalu(TPMT_SENSITIVE *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMI_ALG_PUBLIC_Unmarshalu(&target->sensitiveType, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_AUTH_Unmarshalu(&target->authValue, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_DIGEST_Unmarshalu(&target->seedValue, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMU_SENSITIVE_COMPOSITE_Unmarshalu(&target->sensitive, buffer, size, target->sensitiveType); + } + return rc; +} + +/* Table 189 - Definition of TPM2B_SENSITIVE Structure <IN/OUT> */ + +TPM_RC +TSS_TPM2B_SENSITIVE_Unmarshalu(TPM2B_SENSITIVE *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + uint32_t startSize = 0; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_UINT16_Unmarshalu(&target->t.size, buffer, size); + } + if (target->t.size != 0) { + if (rc == TPM_RC_SUCCESS) { + startSize = *size; + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMT_SENSITIVE_Unmarshalu(&target->t.sensitiveArea, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + if (target->t.size != startSize - *size) { + rc = TPM_RC_SIZE; + } + } + } + return rc; +} + +/* Table 191 - Definition of TPM2B_PRIVATE Structure <IN/OUT, S> */ + +TPM_RC +TSS_TPM2B_PRIVATE_Unmarshalu(TPM2B_PRIVATE *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_Unmarshalu(&target->b, sizeof(target->t.buffer), buffer, size); + } + return rc; +} + +/* Table 193 - Definition of TPM2B_ID_OBJECT Structure <IN/OUT> */ + +TPM_RC +TSS_TPM2B_ID_OBJECT_Unmarshalu(TPM2B_ID_OBJECT *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_Unmarshalu(&target->b, sizeof(target->t.credential), buffer, size); + } + return rc; +} + +/* Table 196 - Definition of (UINT32) TPMA_NV Bits */ + +TPM_RC +TSS_TPMA_NV_Unmarshalu(TPMA_NV *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_UINT32_Unmarshalu(&target->val, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + if (target->val & TPMA_NV_RESERVED) { + rc = TPM_RC_RESERVED_BITS; + } + } + return rc; +} + +/* Table 197 - Definition of TPMS_NV_PUBLIC Structure */ + +TPM_RC +TSS_TPMS_NV_PUBLIC_Unmarshalu(TPMS_NV_PUBLIC *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMI_RH_NV_INDEX_Unmarshalu(&target->nvIndex, buffer, size, NO); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMI_ALG_HASH_Unmarshalu(&target->nameAlg, buffer, size, NO); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMA_NV_Unmarshalu(&target->attributes, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_DIGEST_Unmarshalu(&target->authPolicy, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_UINT16_Unmarshalu(&target->dataSize, buffer, size); + } + return rc; +} + +/* Table 198 - Definition of TPM2B_NV_PUBLIC Structure */ + +TPM_RC +TSS_TPM2B_NV_PUBLIC_Unmarshalu(TPM2B_NV_PUBLIC *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + uint32_t startSize = 0; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_UINT16_Unmarshalu(&target->size, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + if (target->size == 0) { + rc = TPM_RC_SIZE; + } + } + if (rc == TPM_RC_SUCCESS) { + startSize = *size; + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMS_NV_PUBLIC_Unmarshalu(&target->nvPublic, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + if (target->size != startSize - *size) { + rc = TPM_RC_SIZE; + } + } + return rc; +} + +/* Table 199 - Definition of TPM2B_CONTEXT_SENSITIVE Structure <IN/OUT> */ + +TPM_RC +TSS_TPM2B_CONTEXT_SENSITIVE_Unmarshalu(TPM2B_CONTEXT_SENSITIVE *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_Unmarshalu(&target->b, sizeof(target->t.buffer), buffer, size); + } + return rc; +} + +/* Table 200 - Definition of TPMS_CONTEXT_DATA Structure <IN/OUT, S> */ + +TPM_RC +TSS_TPMS_CONTEXT_DATA_Unmarshalu(TPMS_CONTEXT_DATA *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_DIGEST_Unmarshalu(&target->integrity, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_CONTEXT_SENSITIVE_Unmarshalu(&target->encrypted, buffer, size); + } + return rc; +} + +/* Table 201 - Definition of TPM2B_CONTEXT_DATA Structure <IN/OUT> */ + +TPM_RC +TSS_TPM2B_CONTEXT_DATA_Unmarshalu(TPM2B_CONTEXT_DATA *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_Unmarshalu(&target->b, sizeof(target->t.buffer), buffer, size); + } + return rc; +} + +/* Table 202 - Definition of TPMS_CONTEXT Structure */ + +TPM_RC +TSS_TPMS_CONTEXT_Unmarshalu(TPMS_CONTEXT *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_UINT64_Unmarshalu(&target->sequence, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMI_DH_SAVED_Unmarshalu(&target->savedHandle, buffer, size, NO); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMI_RH_HIERARCHY_Unmarshalu(&target->hierarchy, buffer, size, YES); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_CONTEXT_DATA_Unmarshalu(&target->contextBlob, buffer, size); + } + return rc; +} + +/* Table 204 - Definition of TPMS_CREATION_DATA Structure <OUT> */ + +TPM_RC +TSS_TPMS_CREATION_DATA_Unmarshalu(TPMS_CREATION_DATA *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPML_PCR_SELECTION_Unmarshalu(&target->pcrSelect, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_DIGEST_Unmarshalu(&target->pcrDigest, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMA_LOCALITY_Unmarshalu(&target->locality, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM_ALG_ID_Unmarshalu(&target->parentNameAlg, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_NAME_Unmarshalu(&target->parentName, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_NAME_Unmarshalu(&target->parentQualifiedName, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_DATA_Unmarshalu(&target->outsideInfo, buffer, size); + } + return rc; +} + +/* Table 205 - Definition of TPM2B_CREATION_DATA Structure <OUT> */ + +TPM_RC +TSS_TPM2B_CREATION_DATA_Unmarshalu(TPM2B_CREATION_DATA *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + uint32_t startSize = 0; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_UINT16_Unmarshalu(&target->size, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + if (target->size == 0) { + rc = TPM_RC_SIZE; + } + } + if (rc == TPM_RC_SUCCESS) { + startSize = *size; + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMS_CREATION_DATA_Unmarshalu(&target->creationData, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + if (target->size != startSize - *size) { + rc = TPM_RC_SIZE; + } + } + return rc; +} + +/* Deprecated functions that use a sized value for the size parameter. The recommended functions + use an unsigned value. + +*/ + +TPM_RC TPM2B_Unmarshal(TPM2B *target, UINT16 targetSize, BYTE **buffer, INT32 *size) +{ + return TSS_TPM2B_Unmarshalu(target, targetSize, buffer, (uint32_t *)size); +} + +TPM_RC TPM_KEY_BITS_Unmarshal(TPM_KEY_BITS *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPM_KEY_BITS_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPM_GENERATED_Unmarshal(TPM_GENERATED *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPM_GENERATED_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPM_ALG_ID_Unmarshal(TPM_ALG_ID *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPM_ALG_ID_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPM_ECC_CURVE_Unmarshal(TPM_ECC_CURVE *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPM_ECC_CURVE_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPM_CC_Unmarshal(TPM_RC *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPM_CC_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPM_RC_Unmarshal(TPM_RC *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPM_RC_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPM_CLOCK_ADJUST_Unmarshal(TPM_CLOCK_ADJUST *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPM_CLOCK_ADJUST_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPM_EO_Unmarshal(TPM_EO *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPM_EO_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPM_ST_Unmarshal(TPM_ST *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPM_ST_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPM_SU_Unmarshal(TPM_SU *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPM_SU_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPM_SE_Unmarshal(TPM_SE *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPM_SE_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPM_CAP_Unmarshal(TPM_CAP *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPM_CAP_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPM_PT_Unmarshal(TPM_HANDLE *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPM_PT_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPM_PT_PCR_Unmarshal(TPM_PT_PCR *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPM_PT_PCR_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPM_HANDLE_Unmarshal(TPM_HANDLE *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPM_HANDLE_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPMA_ALGORITHM_Unmarshal(TPMA_ALGORITHM *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPMA_ALGORITHM_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPMA_OBJECT_Unmarshal(TPMA_OBJECT *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPMA_OBJECT_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPMA_SESSION_Unmarshal(TPMA_SESSION *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPMA_SESSION_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPMA_LOCALITY_Unmarshal(TPMA_LOCALITY *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPMA_LOCALITY_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPMA_CC_Unmarshal(TPMA_CC *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPMA_CC_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPMI_YES_NO_Unmarshal(TPMI_YES_NO *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPMI_YES_NO_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPMI_DH_OBJECT_Unmarshal(TPMI_DH_OBJECT *target, BYTE **buffer, INT32 *size, BOOL allowNull) +{ + return TSS_TPMI_DH_OBJECT_Unmarshalu(target, buffer, (uint32_t *)size, allowNull); +} + +#if 0 +TPM_RC TPMI_DH_PARENT_Unmarshal(TPMI_DH_PARENT *target, BYTE **buffer, INT32 *size, BOOL allowNull) +{ + return TSS_TPMI_DH_PARENT_Unmarshalu(target, buffer, (uint32_t *)size, allowNull); +} +#endif + +TPM_RC TPMI_DH_PERSISTENT_Unmarshal(TPMI_DH_PERSISTENT *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPMI_DH_PERSISTENT_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPMI_DH_ENTITY_Unmarshal(TPMI_DH_ENTITY *target, BYTE **buffer, INT32 *size, BOOL allowNull) +{ + return TSS_TPMI_DH_ENTITY_Unmarshalu(target, buffer, (uint32_t *)size, allowNull); +} + +TPM_RC TPMI_DH_PCR_Unmarshal(TPMI_DH_PCR *target, BYTE **buffer, INT32 *size, BOOL allowNull) +{ + return TSS_TPMI_DH_PCR_Unmarshalu(target, buffer, (uint32_t *)size, allowNull); +} + +TPM_RC TPMI_SH_AUTH_SESSION_Unmarshal(TPMI_SH_AUTH_SESSION *target, BYTE **buffer, INT32 *size, BOOL allowPwd) +{ + return TSS_TPMI_SH_AUTH_SESSION_Unmarshalu(target, buffer, (uint32_t *)size, allowPwd); +} + +TPM_RC TPMI_SH_HMAC_Unmarshal(TPMI_SH_HMAC *target, BYTE **buffer, INT32 *size, BOOL allowNull) +{ + return TSS_TPMI_SH_HMAC_Unmarshalu(target, buffer, (uint32_t *)size, allowNull); +} + +TPM_RC TPMI_SH_POLICY_Unmarshal(TPMI_SH_POLICY *target, BYTE **buffer, INT32 *size, BOOL allowNull) +{ + return TSS_TPMI_SH_POLICY_Unmarshalu(target, buffer, (uint32_t *)size, allowNull); +} + +TPM_RC TPMI_DH_CONTEXT_Unmarshal(TPMI_DH_CONTEXT *target, BYTE **buffer, INT32 *size, BOOL allowNull) +{ + return TSS_TPMI_DH_CONTEXT_Unmarshalu(target, buffer, (uint32_t *)size, allowNull); +} + +TPM_RC TPMI_RH_HIERARCHY_Unmarshal(TPMI_RH_HIERARCHY *target, BYTE **buffer, INT32 *size, BOOL allowNull) +{ + return TSS_TPMI_RH_HIERARCHY_Unmarshalu(target, buffer, (uint32_t *)size, allowNull); +} + +TPM_RC TPMI_RH_ENABLES_Unmarshal(TPMI_RH_ENABLES *target, BYTE **buffer, INT32 *size, BOOL allowNull) +{ + return TSS_TPMI_RH_ENABLES_Unmarshalu(target, buffer, (uint32_t *)size, allowNull); +} + +TPM_RC TPMI_RH_HIERARCHY_AUTH_Unmarshal(TPMI_RH_HIERARCHY_AUTH *target, BYTE **buffer, INT32 *size, BOOL allowNull) +{ + return TSS_TPMI_RH_HIERARCHY_AUTH_Unmarshalu(target, buffer, (uint32_t *)size, allowNull); +} + +TPM_RC TPMI_RH_PLATFORM_Unmarshal(TPMI_RH_PLATFORM *target, BYTE **buffer, INT32 *size, BOOL allowNull) +{ + return TSS_TPMI_RH_PLATFORM_Unmarshalu(target, buffer, (uint32_t *)size, allowNull); +} + +TPM_RC TPMI_RH_ENDORSEMENT_Unmarshal(TPMI_RH_ENDORSEMENT *target, BYTE **buffer, INT32 *size, BOOL allowNull) +{ + return TSS_TPMI_RH_ENDORSEMENT_Unmarshalu(target, buffer, (uint32_t *)size, allowNull); +} + +TPM_RC TPMI_RH_PROVISION_Unmarshal(TPMI_RH_PROVISION *target, BYTE **buffer, INT32 *size, BOOL allowNull) +{ + return TSS_TPMI_RH_PROVISION_Unmarshalu(target, buffer, (uint32_t *)size, allowNull); +} + +TPM_RC TPMI_RH_CLEAR_Unmarshal(TPMI_RH_CLEAR *target, BYTE **buffer, INT32 *size, BOOL allowNull) +{ + return TSS_TPMI_RH_CLEAR_Unmarshalu(target, buffer, (uint32_t *)size, allowNull); +} + +TPM_RC TPMI_RH_NV_AUTH_Unmarshal(TPMI_RH_NV_AUTH *target, BYTE **buffer, INT32 *size, BOOL allowNull) +{ + return TSS_TPMI_RH_NV_AUTH_Unmarshalu(target, buffer, (uint32_t *)size, allowNull); +} + +TPM_RC TPMI_RH_LOCKOUT_Unmarshal(TPMI_RH_LOCKOUT *target, BYTE **buffer, INT32 *size, BOOL allowNull) +{ + return TSS_TPMI_RH_LOCKOUT_Unmarshalu(target, buffer, (uint32_t *)size, allowNull); +} + +TPM_RC TPMI_RH_NV_INDEX_Unmarshal(TPMI_RH_NV_INDEX *target, BYTE **buffer, INT32 *size, BOOL allowNull) +{ + return TSS_TPMI_RH_NV_INDEX_Unmarshalu(target, buffer, (uint32_t *)size, allowNull); +} + +TPM_RC TPMI_ALG_HASH_Unmarshal(TPMI_ALG_HASH *target, BYTE **buffer, INT32 *size, BOOL allowNull) +{ + return TSS_TPMI_ALG_HASH_Unmarshalu(target, buffer, (uint32_t *)size, allowNull); +} + +TPM_RC TPMI_ALG_SYM_Unmarshal(TPMI_ALG_SYM *target, BYTE **buffer, INT32 *size, BOOL allowNull) +{ + return TSS_TPMI_ALG_SYM_Unmarshalu(target, buffer, (uint32_t *)size, allowNull); +} + +TPM_RC TPMI_ALG_SYM_OBJECT_Unmarshal(TPMI_ALG_SYM_OBJECT *target, BYTE **buffer, INT32 *size, BOOL allowNull) +{ + return TSS_TPMI_ALG_SYM_OBJECT_Unmarshalu(target, buffer, (uint32_t *)size, allowNull); +} + +TPM_RC TPMI_ALG_SYM_MODE_Unmarshal(TPMI_ALG_SYM_MODE *target, BYTE **buffer, INT32 *size, BOOL allowNull) +{ + return TSS_TPMI_ALG_SYM_MODE_Unmarshalu(target, buffer, (uint32_t *)size, allowNull); +} + +TPM_RC TPMI_ALG_KDF_Unmarshal(TPMI_ALG_KDF *target, BYTE **buffer, INT32 *size, BOOL allowNull) +{ + return TSS_TPMI_ALG_KDF_Unmarshalu(target, buffer, (uint32_t *)size, allowNull); +} + +TPM_RC TPMI_ALG_SIG_SCHEME_Unmarshal(TPMI_ALG_SIG_SCHEME *target, BYTE **buffer, INT32 *size, BOOL allowNull) +{ + return TSS_TPMI_ALG_SIG_SCHEME_Unmarshalu(target, buffer, (uint32_t *)size, allowNull); +} + +TPM_RC TPMI_ECC_KEY_EXCHANGE_Unmarshal(TPMI_ECC_KEY_EXCHANGE *target, BYTE **buffer, INT32 *size, BOOL allowNull) +{ + return TSS_TPMI_ECC_KEY_EXCHANGE_Unmarshalu(target, buffer, (uint32_t *)size, allowNull); +} + +TPM_RC TPMI_ST_COMMAND_TAG_Unmarshal(TPMI_ST_COMMAND_TAG *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPMI_ST_COMMAND_TAG_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPMI_ALG_MAC_SCHEME_Unmarshal(TPMI_ALG_MAC_SCHEME *target, BYTE **buffer, INT32 *size, BOOL allowNull) +{ + return TSS_TPMI_ALG_MAC_SCHEME_Unmarshalu(target, buffer, (uint32_t *)size, allowNull); +} + +TPM_RC TPMI_ALG_CIPHER_MODE_Unmarshal(TPMI_ALG_CIPHER_MODE *target, BYTE **buffer, INT32 *size, BOOL allowNull) +{ + return TSS_TPMI_ALG_CIPHER_MODE_Unmarshalu(target, buffer, (uint32_t *)size, allowNull); +} + +/* NOTE: Marked as const function in header */ + +TPM_RC TPMS_EMPTY_Unmarshal(TPMS_EMPTY *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_EMPTY_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPMU_HA_Unmarshal(TPMU_HA *target, BYTE **buffer, INT32 *size, UINT32 selector) +{ + return TSS_TPMU_HA_Unmarshalu(target, buffer, (uint32_t *)size, selector); +} + +TPM_RC TPMT_HA_Unmarshal(TPMT_HA *target, BYTE **buffer, INT32 *size, BOOL allowNull) +{ + return TSS_TPMT_HA_Unmarshalu(target, buffer, (uint32_t *)size, allowNull); +} + +TPM_RC TPM2B_DIGEST_Unmarshal(TPM2B_DIGEST *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPM2B_DIGEST_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPM2B_DATA_Unmarshal(TPM2B_DATA *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPM2B_DATA_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPM2B_NONCE_Unmarshal(TPM2B_NONCE *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPM2B_NONCE_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPM2B_AUTH_Unmarshal(TPM2B_AUTH *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPM2B_AUTH_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPM2B_OPERAND_Unmarshal(TPM2B_OPERAND *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPM2B_OPERAND_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPM2B_EVENT_Unmarshal(TPM2B_EVENT *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPM2B_EVENT_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPM2B_MAX_BUFFER_Unmarshal(TPM2B_MAX_BUFFER *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPM2B_MAX_BUFFER_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPM2B_MAX_NV_BUFFER_Unmarshal(TPM2B_MAX_NV_BUFFER *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPM2B_MAX_NV_BUFFER_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPM2B_TIMEOUT_Unmarshal(TPM2B_TIMEOUT *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPM2B_TIMEOUT_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPM2B_IV_Unmarshal(TPM2B_IV *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPM2B_IV_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPM2B_NAME_Unmarshal(TPM2B_NAME *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPM2B_NAME_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPMS_PCR_SELECTION_Unmarshal(TPMS_PCR_SELECTION *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_PCR_SELECTION_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPMT_TK_CREATION_Unmarshal(TPMT_TK_CREATION *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPMT_TK_CREATION_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPMT_TK_VERIFIED_Unmarshal(TPMT_TK_VERIFIED *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPMT_TK_VERIFIED_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPMT_TK_AUTH_Unmarshal(TPMT_TK_AUTH *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPMT_TK_AUTH_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPMT_TK_HASHCHECK_Unmarshal(TPMT_TK_HASHCHECK *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPMT_TK_HASHCHECK_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPMS_ALG_PROPERTY_Unmarshal(TPMS_ALG_PROPERTY *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_ALG_PROPERTY_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPMS_TAGGED_PROPERTY_Unmarshal(TPMS_TAGGED_PROPERTY *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_TAGGED_PROPERTY_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPMS_TAGGED_PCR_SELECT_Unmarshal(TPMS_TAGGED_PCR_SELECT *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_TAGGED_PCR_SELECT_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPML_CC_Unmarshal(TPML_CC *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPML_CC_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPML_CCA_Unmarshal(TPML_CCA *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPML_CCA_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPML_ALG_Unmarshal(TPML_ALG *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPML_ALG_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPML_HANDLE_Unmarshal(TPML_HANDLE *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPML_HANDLE_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPML_DIGEST_Unmarshal(TPML_DIGEST *target, BYTE **buffer, INT32 *size,uint32_t minCount) +{ + return TSS_TPML_DIGEST_Unmarshalu(target, buffer, (uint32_t *)size, minCount); +} + +TPM_RC TPML_DIGEST_VALUES_Unmarshal(TPML_DIGEST_VALUES *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPML_DIGEST_VALUES_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPML_PCR_SELECTION_Unmarshal(TPML_PCR_SELECTION *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPML_PCR_SELECTION_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPML_ALG_PROPERTY_Unmarshal(TPML_ALG_PROPERTY *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPML_ALG_PROPERTY_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPML_TAGGED_TPM_PROPERTY_Unmarshal(TPML_TAGGED_TPM_PROPERTY *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPML_TAGGED_TPM_PROPERTY_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPML_TAGGED_PCR_PROPERTY_Unmarshal(TPML_TAGGED_PCR_PROPERTY *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPML_TAGGED_PCR_PROPERTY_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPML_ECC_CURVE_Unmarshal(TPML_ECC_CURVE *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPML_ECC_CURVE_Unmarshalu(target, buffer, (uint32_t *)size); +} + +#if 0 +TPM_RC TPML_TAGGED_POLICY_Unmarshal(TPML_TAGGED_POLICY *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPML_TAGGED_POLICY_Unmarshalu(target, buffer, (uint32_t *)size); +} +#endif + +TPM_RC TPMU_CAPABILITIES_Unmarshal(TPMU_CAPABILITIES *target, BYTE **buffer, INT32 *size, UINT32 selector) +{ + return TSS_TPMU_CAPABILITIES_Unmarshalu(target, buffer, (uint32_t *)size, selector); +} + +TPM_RC TPMS_CLOCK_INFO_Unmarshal(TPMS_CLOCK_INFO *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_CLOCK_INFO_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPMS_TIME_INFO_Unmarshal(TPMS_TIME_INFO *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_TIME_INFO_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPMS_TIME_ATTEST_INFO_Unmarshal(TPMS_TIME_ATTEST_INFO *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_TIME_ATTEST_INFO_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPMS_CERTIFY_INFO_Unmarshal(TPMS_CERTIFY_INFO *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_CERTIFY_INFO_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPMS_QUOTE_INFO_Unmarshal(TPMS_QUOTE_INFO *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_QUOTE_INFO_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPMS_COMMAND_AUDIT_INFO_Unmarshal(TPMS_COMMAND_AUDIT_INFO *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_COMMAND_AUDIT_INFO_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPMS_SESSION_AUDIT_INFO_Unmarshal(TPMS_SESSION_AUDIT_INFO *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_SESSION_AUDIT_INFO_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPMS_CREATION_INFO_Unmarshal(TPMS_CREATION_INFO *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_CREATION_INFO_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPMS_NV_CERTIFY_INFO_Unmarshal(TPMS_NV_CERTIFY_INFO *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_NV_CERTIFY_INFO_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPMI_ST_ATTEST_Unmarshal(TPMI_ST_ATTEST *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPMI_ST_ATTEST_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPMU_ATTEST_Unmarshal(TPMU_ATTEST *target, BYTE **buffer, INT32 *size, UINT32 selector) +{ + return TSS_TPMU_ATTEST_Unmarshalu(target, buffer, (uint32_t *)size, selector); +} + +TPM_RC TPMS_ATTEST_Unmarshal(TPMS_ATTEST *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_ATTEST_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPM2B_ATTEST_Unmarshal(TPM2B_ATTEST *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPM2B_ATTEST_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPMS_CAPABILITY_DATA_Unmarshal(TPMS_CAPABILITY_DATA *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_CAPABILITY_DATA_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPMS_AUTH_RESPONSE_Unmarshal(TPMS_AUTH_RESPONSE *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_AUTH_RESPONSE_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPMI_AES_KEY_BITS_Unmarshal(TPMI_AES_KEY_BITS *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPMI_AES_KEY_BITS_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPMU_SYM_KEY_BITS_Unmarshal(TPMU_SYM_KEY_BITS *target, BYTE **buffer, INT32 *size, UINT32 selector) +{ + return TSS_TPMU_SYM_KEY_BITS_Unmarshalu(target, buffer, (uint32_t *)size, selector); +} + +TPM_RC TPMU_SYM_MODE_Unmarshal(TPMU_SYM_MODE *target, BYTE **buffer, INT32 *size, UINT32 selector) +{ + return TSS_TPMU_SYM_MODE_Unmarshalu(target, buffer, (uint32_t *)size, selector); +} + +TPM_RC TPMT_SYM_DEF_Unmarshal(TPMT_SYM_DEF *target, BYTE **buffer, INT32 *size, BOOL allowNull) +{ + return TSS_TPMT_SYM_DEF_Unmarshalu(target, buffer, (uint32_t *)size, allowNull); +} + +TPM_RC TPMT_SYM_DEF_OBJECT_Unmarshal(TPMT_SYM_DEF_OBJECT *target, BYTE **buffer, INT32 *size, BOOL allowNull) +{ + return TSS_TPMT_SYM_DEF_OBJECT_Unmarshalu(target, buffer, (uint32_t *)size, allowNull); +} + +TPM_RC TPM2B_SYM_KEY_Unmarshal(TPM2B_SYM_KEY *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPM2B_SYM_KEY_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPMS_SYMCIPHER_PARMS_Unmarshal(TPMS_SYMCIPHER_PARMS *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_SYMCIPHER_PARMS_Unmarshalu(target, buffer, (uint32_t *)size); +} + +#if 0 +TPM_RC TPM2B_LABEL_Unmarshal(TPM2B_LABEL *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPM2B_LABEL_Unmarshalu(target, buffer, (uint32_t *)size); +} +#endif + +TPM_RC TPM2B_SENSITIVE_DATA_Unmarshal(TPM2B_SENSITIVE_DATA *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPM2B_SENSITIVE_DATA_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPMS_SENSITIVE_CREATE_Unmarshal(TPMS_SENSITIVE_CREATE *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_SENSITIVE_CREATE_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPM2B_SENSITIVE_CREATE_Unmarshal(TPM2B_SENSITIVE_CREATE *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPM2B_SENSITIVE_CREATE_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPMS_SCHEME_HASH_Unmarshal(TPMS_SCHEME_HASH *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_SCHEME_HASH_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPMS_SCHEME_ECDAA_Unmarshal(TPMS_SCHEME_ECDAA *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_SCHEME_ECDAA_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPMI_ALG_KEYEDHASH_SCHEME_Unmarshal(TPMI_ALG_KEYEDHASH_SCHEME *target, BYTE **buffer, INT32 *size, BOOL allowNull) +{ + return TSS_TPMI_ALG_KEYEDHASH_SCHEME_Unmarshalu(target, buffer, (uint32_t *)size, allowNull); +} + +TPM_RC TPMS_SCHEME_HMAC_Unmarshal(TPMS_SCHEME_HMAC *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_SCHEME_HMAC_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPMS_SCHEME_XOR_Unmarshal(TPMS_SCHEME_XOR *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_SCHEME_XOR_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPMU_SCHEME_KEYEDHASH_Unmarshal(TPMU_SCHEME_KEYEDHASH *target, BYTE **buffer, INT32 *size, UINT32 selector) +{ + return TSS_TPMU_SCHEME_KEYEDHASH_Unmarshalu(target, buffer, (uint32_t *)size, selector); +} + +TPM_RC TPMT_KEYEDHASH_SCHEME_Unmarshal(TPMT_KEYEDHASH_SCHEME *target, BYTE **buffer, INT32 *size, BOOL allowNull) +{ + return TSS_TPMT_KEYEDHASH_SCHEME_Unmarshalu(target, buffer, (uint32_t *)size, allowNull); +} + +TPM_RC TPMS_SIG_SCHEME_ECDAA_Unmarshal(TPMS_SIG_SCHEME_ECDAA *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_SIG_SCHEME_ECDAA_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPMS_SIG_SCHEME_ECDSA_Unmarshal(TPMS_SIG_SCHEME_ECDSA *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_SIG_SCHEME_ECDSA_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPMS_SIG_SCHEME_ECSCHNORR_Unmarshal(TPMS_SIG_SCHEME_ECSCHNORR *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_SIG_SCHEME_ECSCHNORR_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPMS_SIG_SCHEME_RSAPSS_Unmarshal(TPMS_SIG_SCHEME_RSAPSS *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_SIG_SCHEME_RSAPSS_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPMS_SIG_SCHEME_RSASSA_Unmarshal(TPMS_SIG_SCHEME_RSASSA *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_SIG_SCHEME_RSASSA_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPMS_SIG_SCHEME_SM2_Unmarshal(TPMS_SIG_SCHEME_SM2 *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_SIG_SCHEME_SM2_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPMU_SIG_SCHEME_Unmarshal(TPMU_SIG_SCHEME *target, BYTE **buffer, INT32 *size, UINT32 selector) +{ + return TSS_TPMU_SIG_SCHEME_Unmarshalu(target, buffer, (uint32_t *)size, selector); +} + +TPM_RC TPMT_SIG_SCHEME_Unmarshal(TPMT_SIG_SCHEME *target, BYTE **buffer, INT32 *size, BOOL allowNull) +{ + return TSS_TPMT_SIG_SCHEME_Unmarshalu(target, buffer, (uint32_t *)size, allowNull); +} + +TPM_RC TPMS_ENC_SCHEME_OAEP_Unmarshal(TPMS_ENC_SCHEME_OAEP *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_ENC_SCHEME_OAEP_Unmarshalu(target, buffer, (uint32_t *)size); +} + +/* NOTE: Marked as const function in header */ + +TPM_RC TPMS_ENC_SCHEME_RSAES_Unmarshal(TPMS_ENC_SCHEME_RSAES *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_ENC_SCHEME_RSAES_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPMS_KEY_SCHEME_ECDH_Unmarshal(TPMS_KEY_SCHEME_ECDH *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_KEY_SCHEME_ECDH_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPMS_KEY_SCHEME_ECMQV_Unmarshal(TPMS_KEY_SCHEME_ECMQV *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_KEY_SCHEME_ECMQV_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPMS_SCHEME_KDF1_SP800_108_Unmarshal(TPMS_SCHEME_KDF1_SP800_108 *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_SCHEME_KDF1_SP800_108_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPMS_SCHEME_KDF1_SP800_56A_Unmarshal(TPMS_SCHEME_KDF1_SP800_56A *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_SCHEME_KDF1_SP800_56A_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPMS_SCHEME_KDF2_Unmarshal(TPMS_SCHEME_KDF2 *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_SCHEME_KDF2_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPMS_SCHEME_MGF1_Unmarshal(TPMS_SCHEME_MGF1 *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_SCHEME_MGF1_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPMU_KDF_SCHEME_Unmarshal(TPMU_KDF_SCHEME *target, BYTE **buffer, INT32 *size, UINT32 selector) +{ + return TSS_TPMU_KDF_SCHEME_Unmarshalu(target, buffer, (uint32_t *)size, selector); +} + +TPM_RC TPMT_KDF_SCHEME_Unmarshal(TPMT_KDF_SCHEME *target, BYTE **buffer, INT32 *size, BOOL allowNull) +{ + return TSS_TPMT_KDF_SCHEME_Unmarshalu(target, buffer, (uint32_t *)size, allowNull); +} + +#if 0 +TPM_RC TPMI_ALG_ASYM_SCHEME_Unmarshal(TPMI_ALG_ASYM_SCHEME *target, BYTE **buffer, INT32 *size, BOOL allowNull) +{ + return TSS_TPMI_ALG_ASYM_SCHEME_Unmarshalu(target, buffer, (uint32_t *)size, allowNull); +} +#endif + +TPM_RC TPMU_ASYM_SCHEME_Unmarshal(TPMU_ASYM_SCHEME *target, BYTE **buffer, INT32 *size, UINT32 selector) +{ + return TSS_TPMU_ASYM_SCHEME_Unmarshalu(target, buffer, (uint32_t *)size, selector); +} + +#if 0 +TPM_RC TPMT_ASYM_SCHEME_Unmarshal(TPMT_ASYM_SCHEME *target, BYTE **buffer, INT32 *size, BOOL allowNull) +{ + return TSS_TPMT_ASYM_SCHEME_Unmarshalu(target, buffer, (uint32_t *)size, allowNull); +} +#endif + +TPM_RC TPMI_ALG_RSA_SCHEME_Unmarshal(TPMI_ALG_RSA_SCHEME *target, BYTE **buffer, INT32 *size, BOOL allowNull) +{ + return TSS_TPMI_ALG_RSA_SCHEME_Unmarshalu(target, buffer, (uint32_t *)size, allowNull); +} + +TPM_RC TPMT_RSA_SCHEME_Unmarshal(TPMT_RSA_SCHEME *target, BYTE **buffer, INT32 *size, BOOL allowNull) +{ + return TSS_TPMT_RSA_SCHEME_Unmarshalu(target, buffer, (uint32_t *)size, allowNull); +} + +TPM_RC TPMI_ALG_RSA_DECRYPT_Unmarshal(TPMI_ALG_RSA_DECRYPT *target, BYTE **buffer, INT32 *size, BOOL allowNull) +{ + return TSS_TPMI_ALG_RSA_DECRYPT_Unmarshalu(target, buffer, (uint32_t *)size, allowNull); +} + +TPM_RC TPMT_RSA_DECRYPT_Unmarshal(TPMT_RSA_DECRYPT *target, BYTE **buffer, INT32 *size, BOOL allowNull) +{ + return TSS_TPMT_RSA_DECRYPT_Unmarshalu(target, buffer, (uint32_t *)size, allowNull); +} + +TPM_RC TPM2B_PUBLIC_KEY_RSA_Unmarshal(TPM2B_PUBLIC_KEY_RSA *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPM2B_PUBLIC_KEY_RSA_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPMI_RSA_KEY_BITS_Unmarshal(TPMI_RSA_KEY_BITS *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPMI_RSA_KEY_BITS_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPM2B_PRIVATE_KEY_RSA_Unmarshal(TPM2B_PRIVATE_KEY_RSA *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPM2B_PRIVATE_KEY_RSA_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPM2B_ECC_PARAMETER_Unmarshal(TPM2B_ECC_PARAMETER *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPM2B_ECC_PARAMETER_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPMS_ECC_POINT_Unmarshal(TPMS_ECC_POINT *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_ECC_POINT_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPM2B_ECC_POINT_Unmarshal(TPM2B_ECC_POINT *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPM2B_ECC_POINT_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPMI_ALG_ECC_SCHEME_Unmarshal(TPMI_ALG_ECC_SCHEME *target, BYTE **buffer, INT32 *size, BOOL allowNull) +{ + return TSS_TPMI_ALG_ECC_SCHEME_Unmarshalu(target, buffer, (uint32_t *)size, allowNull); +} + +TPM_RC TPMI_ECC_CURVE_Unmarshal(TPMI_ECC_CURVE *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPMI_ECC_CURVE_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPMT_ECC_SCHEME_Unmarshal(TPMT_ECC_SCHEME *target, BYTE **buffer, INT32 *size, BOOL allowNull) +{ + return TSS_TPMT_ECC_SCHEME_Unmarshalu(target, buffer, (uint32_t *)size, allowNull); +} + +TPM_RC TPMS_ALGORITHM_DETAIL_ECC_Unmarshal(TPMS_ALGORITHM_DETAIL_ECC *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_ALGORITHM_DETAIL_ECC_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPMS_SIGNATURE_RSA_Unmarshal(TPMS_SIGNATURE_RSA *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_SIGNATURE_RSA_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPMS_SIGNATURE_RSASSA_Unmarshal(TPMS_SIGNATURE_RSASSA *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_SIGNATURE_RSASSA_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPMS_SIGNATURE_RSAPSS_Unmarshal(TPMS_SIGNATURE_RSAPSS *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_SIGNATURE_RSAPSS_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPMS_SIGNATURE_ECC_Unmarshal(TPMS_SIGNATURE_ECC *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_SIGNATURE_ECC_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPMS_SIGNATURE_ECDSA_Unmarshal(TPMS_SIGNATURE_ECDSA *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_SIGNATURE_ECDSA_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPMS_SIGNATURE_ECDAA_Unmarshal(TPMS_SIGNATURE_ECDAA *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_SIGNATURE_ECDAA_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPMS_SIGNATURE_SM2_Unmarshal(TPMS_SIGNATURE_SM2 *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_SIGNATURE_SM2_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPMS_SIGNATURE_ECSCHNORR_Unmarshal(TPMS_SIGNATURE_ECSCHNORR *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_SIGNATURE_ECSCHNORR_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPMU_SIGNATURE_Unmarshal(TPMU_SIGNATURE *target, BYTE **buffer, INT32 *size, UINT32 selector) +{ + return TSS_TPMU_SIGNATURE_Unmarshalu(target, buffer, (uint32_t *)size, selector); +} + +TPM_RC TPMT_SIGNATURE_Unmarshal(TPMT_SIGNATURE *target, BYTE **buffer, INT32 *size, BOOL allowNull) +{ + return TSS_TPMT_SIGNATURE_Unmarshalu(target, buffer, (uint32_t *)size, allowNull); +} + +TPM_RC TPM2B_ENCRYPTED_SECRET_Unmarshal(TPM2B_ENCRYPTED_SECRET *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPM2B_ENCRYPTED_SECRET_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPMI_ALG_PUBLIC_Unmarshal(TPMI_ALG_PUBLIC *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPMI_ALG_PUBLIC_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPMU_PUBLIC_ID_Unmarshal(TPMU_PUBLIC_ID *target, BYTE **buffer, INT32 *size, UINT32 selector) +{ + return TSS_TPMU_PUBLIC_ID_Unmarshalu(target, buffer, (uint32_t *)size, selector); +} + +TPM_RC TPMS_KEYEDHASH_PARMS_Unmarshal(TPMS_KEYEDHASH_PARMS *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_KEYEDHASH_PARMS_Unmarshalu(target, buffer, (uint32_t *)size); +} + +#if 0 +TPM_RC TPMS_ASYM_PARMS_Unmarshal(TPMS_ASYM_PARMS *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_ASYM_PARMS_Unmarshalu(target, buffer, (uint32_t *)size); +} +#endif + +TPM_RC TPMS_RSA_PARMS_Unmarshal(TPMS_RSA_PARMS *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_RSA_PARMS_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPMS_ECC_PARMS_Unmarshal(TPMS_ECC_PARMS *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_ECC_PARMS_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPMU_PUBLIC_PARMS_Unmarshal(TPMU_PUBLIC_PARMS *target, BYTE **buffer, INT32 *size, UINT32 selector) +{ + return TSS_TPMU_PUBLIC_PARMS_Unmarshalu(target, buffer, (uint32_t *)size, selector); +} + +TPM_RC TPMT_PUBLIC_PARMS_Unmarshal(TPMT_PUBLIC_PARMS *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPMT_PUBLIC_PARMS_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPMT_PUBLIC_Unmarshal(TPMT_PUBLIC *target, BYTE **buffer, INT32 *size, BOOL allowNull) +{ + return TSS_TPMT_PUBLIC_Unmarshalu(target, buffer, (uint32_t *)size, allowNull); +} + +TPM_RC TPM2B_PUBLIC_Unmarshal(TPM2B_PUBLIC *target, BYTE **buffer, INT32 *size, BOOL allowNull) +{ + return TSS_TPM2B_PUBLIC_Unmarshalu(target, buffer, (uint32_t *)size, allowNull); +} + +TPM_RC TPM2B_TEMPLATE_Unmarshal(TPM2B_TEMPLATE *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPM2B_TEMPLATE_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPMU_SENSITIVE_COMPOSITE_Unmarshal(TPMU_SENSITIVE_COMPOSITE *target, BYTE **buffer, INT32 *size, UINT32 selector) +{ + return TSS_TPMU_SENSITIVE_COMPOSITE_Unmarshalu(target, buffer, (uint32_t *)size, selector); +} + +TPM_RC TPMT_SENSITIVE_Unmarshal(TPMT_SENSITIVE *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPMT_SENSITIVE_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPM2B_SENSITIVE_Unmarshal(TPM2B_SENSITIVE *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPM2B_SENSITIVE_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPM2B_PRIVATE_Unmarshal(TPM2B_PRIVATE *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPM2B_PRIVATE_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPM2B_ID_OBJECT_Unmarshal(TPM2B_ID_OBJECT *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPM2B_ID_OBJECT_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPMA_NV_Unmarshal(TPMA_NV *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPMA_NV_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPMS_NV_PUBLIC_Unmarshal(TPMS_NV_PUBLIC *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_NV_PUBLIC_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPM2B_NV_PUBLIC_Unmarshal(TPM2B_NV_PUBLIC *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPM2B_NV_PUBLIC_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPM2B_CONTEXT_SENSITIVE_Unmarshal(TPM2B_CONTEXT_SENSITIVE *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPM2B_CONTEXT_SENSITIVE_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPMS_CONTEXT_DATA_Unmarshal(TPMS_CONTEXT_DATA *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_CONTEXT_DATA_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPM2B_CONTEXT_DATA_Unmarshal(TPM2B_CONTEXT_DATA *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPM2B_CONTEXT_DATA_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPMS_CONTEXT_Unmarshal(TPMS_CONTEXT *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_CONTEXT_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPMS_CREATION_DATA_Unmarshal(TPMS_CREATION_DATA *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_CREATION_DATA_Unmarshalu(target, buffer, (uint32_t *)size); +} + +TPM_RC TPM2B_CREATION_DATA_Unmarshal(TPM2B_CREATION_DATA *target, BYTE **buffer, INT32 *size) +{ + return TSS_TPM2B_CREATION_DATA_Unmarshalu(target, buffer, (uint32_t *)size); +} + + +#ifdef __cplusplus +} +#endif + + + +#endif /* TPM 2.0 */ diff --git a/libstb/tss2/ibmtss/ActivateCredential_fp.h b/libstb/tss2/ibmtss/ActivateCredential_fp.h new file mode 100644 index 0000000..e2b6083 --- /dev/null +++ b/libstb/tss2/ibmtss/ActivateCredential_fp.h @@ -0,0 +1,88 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: ActivateCredential_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef ACTIVATECREDENTIAL_FP_H +#define ACTIVATECREDENTIAL_FP_H + +typedef struct { + TPMI_DH_OBJECT activateHandle; + TPMI_DH_OBJECT keyHandle; + TPM2B_ID_OBJECT credentialBlob; + TPM2B_ENCRYPTED_SECRET secret; +} ActivateCredential_In; + +#define RC_ActivateCredential_activateHandle (TPM_RC_H + TPM_RC_1) +#define RC_ActivateCredential_keyHandle (TPM_RC_H + TPM_RC_2) +#define RC_ActivateCredential_credentialBlob (TPM_RC_P + TPM_RC_1) +#define RC_ActivateCredential_secret (TPM_RC_P + TPM_RC_2) + +typedef struct { + TPM2B_DIGEST certInfo; +} ActivateCredential_Out; + +TPM_RC +TPM2_ActivateCredential( + ActivateCredential_In *in, // IN: input parameter list + ActivateCredential_Out *out // OUT: output parameter list + ); +#endif diff --git a/libstb/tss2/ibmtss/ActivateIdentity_fp.h b/libstb/tss2/ibmtss/ActivateIdentity_fp.h new file mode 100644 index 0000000..6a2b63f --- /dev/null +++ b/libstb/tss2/ibmtss/ActivateIdentity_fp.h @@ -0,0 +1,64 @@ +/********************************************************************************/ +/* */ +/* TPM 1.2 ActivateIdentity */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: ActivateIdentity_fp.h 1257 2018-06-27 20:52:08Z kgoldman $ */ +/* */ +/* (c) Copyright IBM Corporation 2018. */ +/* */ +/* All rights reserved. */ +/* */ +/* Redistribution and use in source and binary forms, with or without */ +/* modification, are permitted provided that the following conditions are */ +/* met: */ +/* */ +/* Redistributions of source code must retain the above copyright notice, */ +/* this list of conditions and the following disclaimer. */ +/* */ +/* 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. */ +/* */ +/* Neither the names of the IBM Corporation nor the names of its */ +/* contributors may be used to endorse or promote products derived from */ +/* this software without specific prior written permission. */ +/* */ +/* 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 ACTIVATEIDENTITY_FP_H +#define ACTIVATEIDENTITY_FP_H + +#include <ibmtss/tpmtypes12.h> +#include <ibmtss/tpmstructures12.h> + +#include <ibmtss/Implementation.h> + +typedef struct { + TPM_KEY_HANDLE idKeyHandle; + UINT32 blobSize; + BYTE blob[MAX_RSA_KEY_BYTES]; +} ActivateIdentity_In; + +typedef struct { + TPM_SYMMETRIC_KEY symmetricKey; +} ActivateIdentity_Out; + +TPM_RC +TPM2_ActivateIdentity( + ActivateIdentity_In *in, // IN: input parameter buffer + ActivateIdentity_Out *out // OUT: output parameter buffer + ); + +#endif diff --git a/libstb/tss2/ibmtss/BaseTypes.h b/libstb/tss2/ibmtss/BaseTypes.h new file mode 100644 index 0000000..c87663c --- /dev/null +++ b/libstb/tss2/ibmtss/BaseTypes.h @@ -0,0 +1,85 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: BaseTypes.h 1257 2018-06-27 20:52:08Z 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, 2016 */ +/* */ +/********************************************************************************/ + +/* 5.2 BaseTypes.h */ + +#ifndef BASETYPES_H +#define BASETYPES_H + +#include <stdint.h> + +/* NULL definition */ + +#ifndef NULL +#define NULL (0) +#endif +typedef uint8_t UINT8; +typedef uint8_t BYTE; +typedef int8_t INT8; +typedef int BOOL; +typedef uint16_t UINT16; +typedef int16_t INT16; +typedef uint32_t UINT32; +typedef int32_t INT32; +typedef uint64_t UINT64; +typedef int64_t INT64; + +#endif diff --git a/libstb/tss2/ibmtss/CertifyCreation_fp.h b/libstb/tss2/ibmtss/CertifyCreation_fp.h new file mode 100644 index 0000000..98c336b --- /dev/null +++ b/libstb/tss2/ibmtss/CertifyCreation_fp.h @@ -0,0 +1,95 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: CertifyCreation_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef CERTIFYCREATION_FP_H +#define CERTIFYCREATION_FP_H + +typedef struct { + TPMI_DH_OBJECT signHandle; + TPMI_DH_OBJECT objectHandle; + TPM2B_DATA qualifyingData; + TPM2B_DIGEST creationHash; + TPMT_SIG_SCHEME inScheme; + TPMT_TK_CREATION creationTicket; +} CertifyCreation_In; + +#define RC_CertifyCreation_signHandle (TPM_RC_H + TPM_RC_1) +#define RC_CertifyCreation_objectHandle (TPM_RC_H + TPM_RC_2) +#define RC_CertifyCreation_qualifyingData (TPM_RC_P + TPM_RC_1) +#define RC_CertifyCreation_creationHash (TPM_RC_P + TPM_RC_2) +#define RC_CertifyCreation_inScheme (TPM_RC_P + TPM_RC_3) +#define RC_CertifyCreation_creationTicket (TPM_RC_P + TPM_RC_4) + +typedef struct { + TPM2B_ATTEST certifyInfo; + TPMT_SIGNATURE signature; +} CertifyCreation_Out; + +TPM_RC +TPM2_CertifyCreation( + CertifyCreation_In *in, // IN: input parameter list + CertifyCreation_Out *out // OUT: output parameter list + ); + + +#endif diff --git a/libstb/tss2/ibmtss/Certify_fp.h b/libstb/tss2/ibmtss/Certify_fp.h new file mode 100644 index 0000000..dc186e4 --- /dev/null +++ b/libstb/tss2/ibmtss/Certify_fp.h @@ -0,0 +1,93 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: Certify_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef CERTIFY_FP_H +#define CERTIFY_FP_H + +typedef struct { + TPMI_DH_OBJECT objectHandle; + TPMI_DH_OBJECT signHandle; + TPM2B_DATA qualifyingData; + TPMT_SIG_SCHEME inScheme; +} Certify_In; + +#define RC_Certify_objectHandle (TPM_RC_H + TPM_RC_1) +#define RC_Certify_signHandle (TPM_RC_H + TPM_RC_2) +#define RC_Certify_qualifyingData (TPM_RC_P + TPM_RC_1) +#define RC_Certify_inScheme (TPM_RC_P + TPM_RC_2) + +typedef struct { + TPM2B_ATTEST certifyInfo; + TPMT_SIGNATURE signature; +} Certify_Out; + + + +TPM_RC +TPM2_Certify( + Certify_In *in, // IN: input parameter list + Certify_Out *out // OUT: output parameter list + ); + + +#endif diff --git a/libstb/tss2/ibmtss/ChangeEPS_fp.h b/libstb/tss2/ibmtss/ChangeEPS_fp.h new file mode 100644 index 0000000..0854730 --- /dev/null +++ b/libstb/tss2/ibmtss/ChangeEPS_fp.h @@ -0,0 +1,79 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: ChangeEPS_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef CHANGEEPS_FP_H +#define CHANGEEPS_FP_H + +typedef struct { + TPMI_RH_PLATFORM authHandle; +} ChangeEPS_In; + +#define RC_ChangeEPS_authHandle (TPM_RC_H + TPM_RC_1) + +TPM_RC +TPM2_ChangeEPS( + ChangeEPS_In *in // IN: input parameter list + ); + + +#endif diff --git a/libstb/tss2/ibmtss/ChangePPS_fp.h b/libstb/tss2/ibmtss/ChangePPS_fp.h new file mode 100644 index 0000000..566cfe7 --- /dev/null +++ b/libstb/tss2/ibmtss/ChangePPS_fp.h @@ -0,0 +1,79 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: ChangePPS_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef CHANGEPPS_FP_H +#define CHANGEPPS_FP_H + +typedef struct { + TPMI_RH_PLATFORM authHandle; +} ChangePPS_In; + +#define RC_ChangePPS_authHandle (TPM_RC_P + TPM_RC_1) + +TPM_RC +TPM2_ChangePPS( + ChangePPS_In *in // IN: input parameter list + ); + + +#endif diff --git a/libstb/tss2/ibmtss/ClearControl_fp.h b/libstb/tss2/ibmtss/ClearControl_fp.h new file mode 100644 index 0000000..4ecd727 --- /dev/null +++ b/libstb/tss2/ibmtss/ClearControl_fp.h @@ -0,0 +1,79 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: ClearControl_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef CLEARCONTROL_FP_H +#define CLEARCONTROL_FP_H + +typedef struct { + TPMI_RH_CLEAR auth; + TPMI_YES_NO disable; +} ClearControl_In; + +#define RC_ClearControl_auth (TPM_RC_H + TPM_RC_1) +#define RC_ClearControl_disable (TPM_RC_P + TPM_RC_1) + +TPM_RC +TPM2_ClearControl( + ClearControl_In *in // IN: input parameter list + ); +#endif diff --git a/libstb/tss2/ibmtss/Clear_fp.h b/libstb/tss2/ibmtss/Clear_fp.h new file mode 100644 index 0000000..f12e6bc --- /dev/null +++ b/libstb/tss2/ibmtss/Clear_fp.h @@ -0,0 +1,78 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: Clear_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef CLEAR_FP_H +#define CLEAR_FP_H + +typedef struct { + TPMI_RH_CLEAR authHandle; +} Clear_In; + +#define RC_Clear_authHandle (TPM_RC_H + TPM_RC_1) + +TPM_RC +TPM2_Clear( + Clear_In *in // IN: input parameter list + ); + +#endif diff --git a/libstb/tss2/ibmtss/ClockRateAdjust_fp.h b/libstb/tss2/ibmtss/ClockRateAdjust_fp.h new file mode 100644 index 0000000..e66d153 --- /dev/null +++ b/libstb/tss2/ibmtss/ClockRateAdjust_fp.h @@ -0,0 +1,81 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: ClockRateAdjust_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef CLOCKRATEADJUST_FP_H +#define CLOCKRATEADJUST_FP_H + +typedef struct { + TPMI_RH_PROVISION auth; + TPM_CLOCK_ADJUST rateAdjust; +} ClockRateAdjust_In; + +#define RC_ClockRateAdjust_auth (TPM_RC_H + TPM_RC_1) +#define RC_ClockRateAdjust_rateAdjust (TPM_RC_P + TPM_RC_1) + + +TPM_RC +TPM2_ClockRateAdjust( + ClockRateAdjust_In *in // IN: input parameter list + ); + +#endif diff --git a/libstb/tss2/ibmtss/ClockSet_fp.h b/libstb/tss2/ibmtss/ClockSet_fp.h new file mode 100644 index 0000000..c62ea97 --- /dev/null +++ b/libstb/tss2/ibmtss/ClockSet_fp.h @@ -0,0 +1,81 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: ClockSet_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef CLOCKSET_FP_H +#define CLOCKSET_FP_H + +typedef struct { + TPMI_RH_PROVISION auth; + UINT64 newTime; +} ClockSet_In; + +#define RC_ClockSet_auth (TPM_RC_H + TPM_RC_1) +#define RC_ClockSet_newTime (TPM_RC_P + TPM_RC_1) + +TPM_RC +TPM2_ClockSet( + ClockSet_In *in // IN: input parameter list + ); + + +#endif diff --git a/libstb/tss2/ibmtss/Commit_fp.h b/libstb/tss2/ibmtss/Commit_fp.h new file mode 100644 index 0000000..653dd53 --- /dev/null +++ b/libstb/tss2/ibmtss/Commit_fp.h @@ -0,0 +1,94 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: Commit_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef COMMIT_FP_H +#define COMMIT_FP_H + +typedef struct { + TPMI_DH_OBJECT signHandle; + TPM2B_ECC_POINT P1; + TPM2B_SENSITIVE_DATA s2; + TPM2B_ECC_PARAMETER y2; +} Commit_In; + +#define RC_Commit_signHandle (TPM_RC_H + TPM_RC_1) +#define RC_Commit_P1 (TPM_RC_P + TPM_RC_1) +#define RC_Commit_s2 (TPM_RC_P + TPM_RC_2) +#define RC_Commit_y2 (TPM_RC_P + TPM_RC_3) + +typedef struct { + TPM2B_ECC_POINT K; + TPM2B_ECC_POINT L; + TPM2B_ECC_POINT E; + UINT16 counter; +} Commit_Out; + +TPM_RC +TPM2_Commit( + Commit_In *in, // IN: input parameter list + Commit_Out *out // OUT: output parameter list + ); + + + +#endif diff --git a/libstb/tss2/ibmtss/ContextLoad_fp.h b/libstb/tss2/ibmtss/ContextLoad_fp.h new file mode 100644 index 0000000..5742f7f --- /dev/null +++ b/libstb/tss2/ibmtss/ContextLoad_fp.h @@ -0,0 +1,84 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: ContextLoad_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef CONTEXTLOAD_FP_H +#define CONTEXTLOAD_FP_H + +typedef struct { + TPMS_CONTEXT context; +} ContextLoad_In; + +#define RC_ContextLoad_context (TPM_RC_P + TPM_RC_1) + +typedef struct { + TPMI_DH_CONTEXT loadedHandle; +} ContextLoad_Out; + +TPM_RC +TPM2_ContextLoad( + ContextLoad_In *in, // IN: input parameter list + ContextLoad_Out *out // OUT: output parameter list + ); + + +#endif diff --git a/libstb/tss2/ibmtss/ContextSave_fp.h b/libstb/tss2/ibmtss/ContextSave_fp.h new file mode 100644 index 0000000..bfb1711 --- /dev/null +++ b/libstb/tss2/ibmtss/ContextSave_fp.h @@ -0,0 +1,84 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: ContextSave_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef CONTEXTSAVE_FP_H +#define CONTEXTSAVE_FP_H + +typedef struct { + TPMI_DH_CONTEXT saveHandle; +} ContextSave_In; + +#define RC_ContextSave_saveHandle (TPM_RC_P + TPM_RC_1) + +typedef struct { + TPMS_CONTEXT context; +} ContextSave_Out; + +TPM_RC +TPM2_ContextSave( + ContextSave_In *in, // IN: input parameter list + ContextSave_Out *out // OUT: output parameter list + ); + + +#endif diff --git a/libstb/tss2/ibmtss/CreateEndorsementKeyPair_fp.h b/libstb/tss2/ibmtss/CreateEndorsementKeyPair_fp.h new file mode 100644 index 0000000..b120470 --- /dev/null +++ b/libstb/tss2/ibmtss/CreateEndorsementKeyPair_fp.h @@ -0,0 +1,64 @@ +/********************************************************************************/ +/* */ +/* TPM 1.2 CreateEndorsementKeyPair */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: CreateEndorsementKeyPair_fp.h 1257 2018-06-27 20:52:08Z kgoldman $ */ +/* */ +/* (c) Copyright IBM Corporation 2018. */ +/* */ +/* All rights reserved. */ +/* */ +/* Redistribution and use in source and binary forms, with or without */ +/* modification, are permitted provided that the following conditions are */ +/* met: */ +/* */ +/* Redistributions of source code must retain the above copyright notice, */ +/* this list of conditions and the following disclaimer. */ +/* */ +/* 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. */ +/* */ +/* Neither the names of the IBM Corporation nor the names of its */ +/* contributors may be used to endorse or promote products derived from */ +/* this software without specific prior written permission. */ +/* */ +/* 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 CREATEENDORSEMENTKEYPAIR_FP_H +#define CREATEENDORSEMENTKEYPAIR_FP_H + +#include <ibmtss/tpmtypes12.h> +#include <ibmtss/tpmstructures12.h> + +#include <ibmtss/Implementation.h> + +typedef struct { + TPM_NONCE antiReplay; + TPM_KEY_PARMS keyInfo; +} CreateEndorsementKeyPair_In; + +typedef struct { + TPM_PUBKEY pubEndorsementKey; + TPM_DIGEST checksum; +} CreateEndorsementKeyPair_Out; + +TPM_RC +TPM2_CreateEndorsementKeyPair( + CreateEndorsementKeyPair_In *in, // IN: input parameter buffer + CreateEndorsementKeyPair_Out *out // OUT: output parameter buffer + ); + +#endif diff --git a/libstb/tss2/ibmtss/CreateLoaded_fp.h b/libstb/tss2/ibmtss/CreateLoaded_fp.h new file mode 100644 index 0000000..a6792c1 --- /dev/null +++ b/libstb/tss2/ibmtss/CreateLoaded_fp.h @@ -0,0 +1,90 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: CreateLoaded_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +#ifndef CREATELOADED_FP_H +#define CREATELOADED_FP_H + +/* rev 136 */ + +typedef struct { + TPMI_DH_PARENT parentHandle; + TPM2B_SENSITIVE_CREATE inSensitive; + TPM2B_TEMPLATE inPublic; +} CreateLoaded_In; + +#define RC_CreateLoaded_parentHandle (TPM_RC_H + TPM_RC_1) +#define RC_CreateLoaded_inSensitive (TPM_RC_P + TPM_RC_1) +#define RC_CreateLoaded_inPublic (TPM_RC_P + TPM_RC_2) + +typedef struct { + TPM_HANDLE objectHandle; + TPM2B_PRIVATE outPrivate; + TPM2B_PUBLIC outPublic; + TPM2B_NAME name; +} CreateLoaded_Out; + +TPM_RC +TPM2_CreateLoaded( + CreateLoaded_In *in, // IN: input parameter list + CreateLoaded_Out *out // OUT: output parameter list + ); + +#endif diff --git a/libstb/tss2/ibmtss/CreatePrimary_fp.h b/libstb/tss2/ibmtss/CreatePrimary_fp.h new file mode 100644 index 0000000..958293b --- /dev/null +++ b/libstb/tss2/ibmtss/CreatePrimary_fp.h @@ -0,0 +1,96 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: CreatePrimary_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef CREATEPRIMARY_FP_H +#define CREATEPRIMARY_FP_H + +typedef struct { + TPMI_RH_HIERARCHY primaryHandle; + TPM2B_SENSITIVE_CREATE inSensitive; + TPM2B_PUBLIC inPublic; + TPM2B_DATA outsideInfo; + TPML_PCR_SELECTION creationPCR; +} CreatePrimary_In; + +#define RC_CreatePrimary_primaryHandle (TPM_RC_H + TPM_RC_1) +#define RC_CreatePrimary_inSensitive (TPM_RC_P + TPM_RC_1) +#define RC_CreatePrimary_inPublic (TPM_RC_P + TPM_RC_2) +#define RC_CreatePrimary_outsideInfo (TPM_RC_P + TPM_RC_3) +#define RC_CreatePrimary_creationPCR (TPM_RC_P + TPM_RC_4) + +typedef struct { + TPM_HANDLE objectHandle; + TPM2B_PUBLIC outPublic; + TPM2B_CREATION_DATA creationData; + TPM2B_DIGEST creationHash; + TPMT_TK_CREATION creationTicket; + TPM2B_NAME name; +} CreatePrimary_Out; + +TPM_RC +TPM2_CreatePrimary( + CreatePrimary_In *in, // IN: input parameter list + CreatePrimary_Out *out // OUT: output parameter list + ); + +#endif diff --git a/libstb/tss2/ibmtss/CreateWrapKey_fp.h b/libstb/tss2/ibmtss/CreateWrapKey_fp.h new file mode 100644 index 0000000..63634a9 --- /dev/null +++ b/libstb/tss2/ibmtss/CreateWrapKey_fp.h @@ -0,0 +1,65 @@ +/********************************************************************************/ +/* */ +/* TPM 1.2 CreateWrapKey */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: CreateWrapKey_fp.h 1257 2018-06-27 20:52:08Z kgoldman $ */ +/* */ +/* (c) Copyright IBM Corporation 2018. */ +/* */ +/* All rights reserved. */ +/* */ +/* Redistribution and use in source and binary forms, with or without */ +/* modification, are permitted provided that the following conditions are */ +/* met: */ +/* */ +/* Redistributions of source code must retain the above copyright notice, */ +/* this list of conditions and the following disclaimer. */ +/* */ +/* 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. */ +/* */ +/* Neither the names of the IBM Corporation nor the names of its */ +/* contributors may be used to endorse or promote products derived from */ +/* this software without specific prior written permission. */ +/* */ +/* 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 CREATEWRAPKEY_FP_H +#define CREATEWRAPKEY_FP_H + +#include <ibmtss/tpmtypes12.h> +#include <ibmtss/tpmstructures12.h> + +#include <ibmtss/Implementation.h> + +typedef struct { + TPM_KEY_HANDLE parentHandle; + TPM_ENCAUTH dataUsageAuth; + TPM_ENCAUTH dataMigrationAuth; + TPM_KEY12 keyInfo; +} CreateWrapKey_In; + +typedef struct { + TPM_KEY12 wrappedKey; +} CreateWrapKey_Out; + +TPM_RC +TPM2_CreateWrapKey( + CreateWrapKey_In *in, // IN: input parameter buffer + CreateWrapKey_Out *out // OUT: output parameter buffer + ); + +#endif diff --git a/libstb/tss2/ibmtss/Create_fp.h b/libstb/tss2/ibmtss/Create_fp.h new file mode 100644 index 0000000..fc32260 --- /dev/null +++ b/libstb/tss2/ibmtss/Create_fp.h @@ -0,0 +1,96 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: Create_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 137 */ + +#ifndef CREATE_FP_H +#define CREATE_FP_H + +typedef struct { + TPMI_DH_OBJECT parentHandle; + TPM2B_SENSITIVE_CREATE inSensitive; + TPM2B_PUBLIC inPublic; + TPM2B_DATA outsideInfo; + TPML_PCR_SELECTION creationPCR; +} Create_In; + +#define RC_Create_parentHandle (TPM_RC_H + TPM_RC_1) +#define RC_Create_inSensitive (TPM_RC_P + TPM_RC_1) +#define RC_Create_inPublic (TPM_RC_P + TPM_RC_2) +#define RC_Create_outsideInfo (TPM_RC_P + TPM_RC_3) +#define RC_Create_creationPCR (TPM_RC_P + TPM_RC_4) + +typedef struct { + TPM2B_PRIVATE outPrivate; + TPM2B_PUBLIC outPublic; + TPM2B_CREATION_DATA creationData; + TPM2B_DIGEST creationHash; + TPMT_TK_CREATION creationTicket; +} Create_Out; + +TPM_RC +TPM2_Create( + Create_In *in, // IN: input parameter list + Create_Out *out // OUT: output parameter list + ); + + +#endif diff --git a/libstb/tss2/ibmtss/DictionaryAttackLockReset_fp.h b/libstb/tss2/ibmtss/DictionaryAttackLockReset_fp.h new file mode 100644 index 0000000..6ef8ea2 --- /dev/null +++ b/libstb/tss2/ibmtss/DictionaryAttackLockReset_fp.h @@ -0,0 +1,79 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: DictionaryAttackLockReset_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef DICTIONARYATTACKLOCKRESET_FP_H +#define DICTIONARYATTACKLOCKRESET_FP_H + +typedef struct { + TPMI_RH_LOCKOUT lockHandle; +} DictionaryAttackLockReset_In; + +#define RC_DictionaryAttackLockReset_lockHandle (TPM_RC_H + TPM_RC_1) + +TPM_RC +TPM2_DictionaryAttackLockReset( + DictionaryAttackLockReset_In *in // IN: input parameter list + ); + + +#endif diff --git a/libstb/tss2/ibmtss/DictionaryAttackParameters_fp.h b/libstb/tss2/ibmtss/DictionaryAttackParameters_fp.h new file mode 100644 index 0000000..86903c3 --- /dev/null +++ b/libstb/tss2/ibmtss/DictionaryAttackParameters_fp.h @@ -0,0 +1,86 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: DictionaryAttackParameters_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef DICTIONARYATTACKPARAMETERS_FP_H +#define DICTIONARYATTACKPARAMETERS_FP_H + + +typedef struct { + TPMI_RH_LOCKOUT lockHandle; + UINT32 newMaxTries; + UINT32 newRecoveryTime; + UINT32 lockoutRecovery; +} DictionaryAttackParameters_In; + +#define RC_DictionaryAttackParameters_lockHandle (TPM_RC_H + TPM_RC_1) +#define RC_DictionaryAttackParameters_newMaxTries (TPM_RC_P + TPM_RC_1) +#define RC_DictionaryAttackParameters_newRecoveryTime (TPM_RC_P + TPM_RC_2) +#define RC_DictionaryAttackParameters_lockoutRecovery (TPM_RC_P + TPM_RC_3) + +TPM_RC +TPM2_DictionaryAttackParameters( + DictionaryAttackParameters_In *in // IN: input parameter list + ); + + +#endif diff --git a/libstb/tss2/ibmtss/Duplicate_fp.h b/libstb/tss2/ibmtss/Duplicate_fp.h new file mode 100644 index 0000000..97693be --- /dev/null +++ b/libstb/tss2/ibmtss/Duplicate_fp.h @@ -0,0 +1,91 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: Duplicate_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef DUPLICATE_FP_H +#define DUPLICATE_FP_H + +typedef struct { + TPMI_DH_OBJECT objectHandle; + TPMI_DH_OBJECT newParentHandle; + TPM2B_DATA encryptionKeyIn; + TPMT_SYM_DEF_OBJECT symmetricAlg; +} Duplicate_In; + +typedef struct { + TPM2B_DATA encryptionKeyOut; + TPM2B_PRIVATE duplicate; + TPM2B_ENCRYPTED_SECRET outSymSeed; +} Duplicate_Out; + +#define RC_Duplicate_objectHandle (TPM_RC_H + TPM_RC_1) +#define RC_Duplicate_newParentHandle (TPM_RC_H + TPM_RC_2) +#define RC_Duplicate_encryptionKeyIn (TPM_RC_P + TPM_RC_1) +#define RC_Duplicate_symmetricAlg (TPM_RC_P + TPM_RC_2) + +TPM_RC +TPM2_Duplicate( + Duplicate_In *in, // IN: input parameter list + Duplicate_Out *out // OUT: output parameter list + ); + +#endif diff --git a/libstb/tss2/ibmtss/ECC_Parameters_fp.h b/libstb/tss2/ibmtss/ECC_Parameters_fp.h new file mode 100644 index 0000000..18bc2a3 --- /dev/null +++ b/libstb/tss2/ibmtss/ECC_Parameters_fp.h @@ -0,0 +1,84 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: ECC_Parameters_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef ECC_PARAMETERS_FP_H +#define ECC_PARAMETERS_FP_H + +typedef struct { + TPMI_ECC_CURVE curveID; +} ECC_Parameters_In; + +#define RC_ECC_Parameters_curveID (TPM_RC_P + TPM_RC_1) + +typedef struct { + TPMS_ALGORITHM_DETAIL_ECC parameters; +} ECC_Parameters_Out; + +TPM_RC +TPM2_ECC_Parameters( + ECC_Parameters_In *in, // IN: input parameter list + ECC_Parameters_Out *out // OUT: output parameter list + ); + + +#endif diff --git a/libstb/tss2/ibmtss/ECDH_KeyGen_fp.h b/libstb/tss2/ibmtss/ECDH_KeyGen_fp.h new file mode 100644 index 0000000..9ff523f --- /dev/null +++ b/libstb/tss2/ibmtss/ECDH_KeyGen_fp.h @@ -0,0 +1,85 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: ECDH_KeyGen_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef ECDH_KEYGEN_FP_H +#define ECDH_KEYGEN_FP_H + +typedef struct { + TPMI_DH_OBJECT keyHandle; +} ECDH_KeyGen_In; + +#define RC_ECDH_KeyGen_keyHandle (TPM_RC_H + TPM_RC_1) + +typedef struct { + TPM2B_ECC_POINT zPoint; + TPM2B_ECC_POINT pubPoint; +} ECDH_KeyGen_Out; + +TPM_RC +TPM2_ECDH_KeyGen( + ECDH_KeyGen_In *in, // IN: input parameter list + ECDH_KeyGen_Out *out // OUT: output parameter list + ); + + +#endif diff --git a/libstb/tss2/ibmtss/ECDH_ZGen_fp.h b/libstb/tss2/ibmtss/ECDH_ZGen_fp.h new file mode 100644 index 0000000..f93fe15 --- /dev/null +++ b/libstb/tss2/ibmtss/ECDH_ZGen_fp.h @@ -0,0 +1,86 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: ECDH_ZGen_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef ECDH_ZGEN_FP_H +#define ECDH_ZGEN_FP_H + +typedef struct { + TPMI_DH_OBJECT keyHandle; + TPM2B_ECC_POINT inPoint; +} ECDH_ZGen_In; + +#define RC_ECDH_ZGen_keyHandle (TPM_RC_H + TPM_RC_1) +#define RC_ECDH_ZGen_inPoint (TPM_RC_P + TPM_RC_1) + +typedef struct { + TPM2B_ECC_POINT outPoint; +} ECDH_ZGen_Out; + +TPM_RC +TPM2_ECDH_ZGen( + ECDH_ZGen_In *in, // IN: input parameter list + ECDH_ZGen_Out *out // OUT: output parameter list + ); + + +#endif diff --git a/libstb/tss2/ibmtss/EC_Ephemeral_fp.h b/libstb/tss2/ibmtss/EC_Ephemeral_fp.h new file mode 100644 index 0000000..6797623 --- /dev/null +++ b/libstb/tss2/ibmtss/EC_Ephemeral_fp.h @@ -0,0 +1,84 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: EC_Ephemeral_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef EC_EPHEMERAL_FP_H +#define EC_EPHEMERAL_FP_H + +typedef struct { + TPMI_ECC_CURVE curveID; +} EC_Ephemeral_In; + +#define RC_EC_Ephemeral_curveID (TPM_RC_P + TPM_RC_1) + +typedef struct { + TPM2B_ECC_POINT Q; + UINT16 counter; +} EC_Ephemeral_Out; + +TPM_RC +TPM2_EC_Ephemeral( + EC_Ephemeral_In *in, // IN: input parameter list + EC_Ephemeral_Out *out // OUT: output parameter list + ); + +#endif diff --git a/libstb/tss2/ibmtss/EncryptDecrypt2_fp.h b/libstb/tss2/ibmtss/EncryptDecrypt2_fp.h new file mode 100644 index 0000000..cff3a64 --- /dev/null +++ b/libstb/tss2/ibmtss/EncryptDecrypt2_fp.h @@ -0,0 +1,93 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: EncryptDecrypt2_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015, 2016 */ +/* */ +/********************************************************************************/ + +/* rev 146*/ + +#ifndef ENCRYPTDECRYPT2_FP_H +#define ENCRYPTDECRYPT2_FP_H + +typedef struct { + TPMI_DH_OBJECT keyHandle; + TPM2B_MAX_BUFFER inData; + TPMI_YES_NO decrypt; + TPMI_ALG_CIPHER_MODE mode; + TPM2B_IV ivIn; +} EncryptDecrypt2_In; + +#define RC_EncryptDecrypt2_keyHandle (TPM_RC_H + TPM_RC_1) +#define RC_EncryptDecrypt2_inData (TPM_RC_P + TPM_RC_1) +#define RC_EncryptDecrypt2_decrypt (TPM_RC_P + TPM_RC_2) +#define RC_EncryptDecrypt2_mode (TPM_RC_P + TPM_RC_3) +#define RC_EncryptDecrypt2_ivIn (TPM_RC_P + TPM_RC_4) + +typedef struct { + TPM2B_MAX_BUFFER outData; + TPM2B_IV ivOut; +} EncryptDecrypt2_Out; + +TPM_RC +TPM2_EncryptDecrypt2( + EncryptDecrypt2_In *in, // IN: input parameter list + EncryptDecrypt2_Out *out // OUT: output parameter list + ); + + +#endif diff --git a/libstb/tss2/ibmtss/EncryptDecrypt_fp.h b/libstb/tss2/ibmtss/EncryptDecrypt_fp.h new file mode 100644 index 0000000..57b0872 --- /dev/null +++ b/libstb/tss2/ibmtss/EncryptDecrypt_fp.h @@ -0,0 +1,93 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: EncryptDecrypt_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 146 */ + +#ifndef ENCRYPTDECRYPT_FP_H +#define ENCRYPTDECRYPT_FP_H + +typedef struct { + TPMI_DH_OBJECT keyHandle; + TPMI_YES_NO decrypt; + TPMI_ALG_CIPHER_MODE mode; + TPM2B_IV ivIn; + TPM2B_MAX_BUFFER inData; +} EncryptDecrypt_In; + +#define RC_EncryptDecrypt_keyHandle (TPM_RC_H + TPM_RC_1) +#define RC_EncryptDecrypt_decrypt (TPM_RC_P + TPM_RC_1) +#define RC_EncryptDecrypt_mode (TPM_RC_P + TPM_RC_2) +#define RC_EncryptDecrypt_ivIn (TPM_RC_P + TPM_RC_3) +#define RC_EncryptDecrypt_inData (TPM_RC_P + TPM_RC_4) + +typedef struct { + TPM2B_MAX_BUFFER outData; + TPM2B_IV ivOut; +} EncryptDecrypt_Out; + +TPM_RC +TPM2_EncryptDecrypt( + EncryptDecrypt_In *in, // IN: input parameter list + EncryptDecrypt_Out *out // OUT: output parameter list + ); + + +#endif diff --git a/libstb/tss2/ibmtss/EventSequenceComplete_fp.h b/libstb/tss2/ibmtss/EventSequenceComplete_fp.h new file mode 100644 index 0000000..e58837e --- /dev/null +++ b/libstb/tss2/ibmtss/EventSequenceComplete_fp.h @@ -0,0 +1,88 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: EventSequenceComplete_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef EVENTSEQUENCECOMPLETE_FP_H +#define EVENTSEQUENCECOMPLETE_FP_H + +typedef struct { + TPMI_DH_PCR pcrHandle; + TPMI_DH_OBJECT sequenceHandle; + TPM2B_MAX_BUFFER buffer; +} EventSequenceComplete_In; + +#define RC_EventSequenceComplete_pcrHandle (TPM_RC_H + TPM_RC_1) +#define RC_EventSequenceComplete_sequenceHandle (TPM_RC_H + TPM_RC_2) +#define RC_EventSequenceComplete_buffer (TPM_RC_P + TPM_RC_1) + +typedef struct { + TPML_DIGEST_VALUES results; +} EventSequenceComplete_Out; + +TPM_RC +TPM2_EventSequenceComplete( + EventSequenceComplete_In *in, // IN: input parameter list + EventSequenceComplete_Out *out // OUT: output parameter list + ); + + +#endif diff --git a/libstb/tss2/ibmtss/EvictControl_fp.h b/libstb/tss2/ibmtss/EvictControl_fp.h new file mode 100644 index 0000000..1b31c49 --- /dev/null +++ b/libstb/tss2/ibmtss/EvictControl_fp.h @@ -0,0 +1,82 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: EvictControl_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef EVICTCONTROL_FP_H +#define EVICTCONTROL_FP_H + +typedef struct { + TPMI_RH_PROVISION auth; + TPMI_DH_OBJECT objectHandle; + TPMI_DH_PERSISTENT persistentHandle; +} EvictControl_In; + +#define RC_EvictControl_auth (TPM_RC_H + TPM_RC_1) +#define RC_EvictControl_objectHandle (TPM_RC_H + TPM_RC_2) +#define RC_EvictControl_persistentHandle (TPM_RC_P + TPM_RC_1) + +TPM_RC +TPM2_EvictControl( + EvictControl_In *in // IN: input parameter list + ); + +#endif diff --git a/libstb/tss2/ibmtss/Extend_fp.h b/libstb/tss2/ibmtss/Extend_fp.h new file mode 100644 index 0000000..b554f56 --- /dev/null +++ b/libstb/tss2/ibmtss/Extend_fp.h @@ -0,0 +1,64 @@ +/********************************************************************************/ +/* */ +/* TPM 1.2 Extend */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: Extend_fp.h 1257 2018-06-27 20:52:08Z kgoldman $ */ +/* */ +/* (c) Copyright IBM Corporation 2018. */ +/* */ +/* All rights reserved. */ +/* */ +/* Redistribution and use in source and binary forms, with or without */ +/* modification, are permitted provided that the following conditions are */ +/* met: */ +/* */ +/* Redistributions of source code must retain the above copyright notice, */ +/* this list of conditions and the following disclaimer. */ +/* */ +/* 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. */ +/* */ +/* Neither the names of the IBM Corporation nor the names of its */ +/* contributors may be used to endorse or promote products derived from */ +/* this software without specific prior written permission. */ +/* */ +/* 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 EXTEND_FP_H +#define EXTEND_FP_H + +#include <ibmtss/tpmtypes12.h> +#include <ibmtss/tpmstructures12.h> + +#include <ibmtss/Implementation.h> + +typedef struct { + + TPM_PCRINDEX pcrNum; + TPM_DIGEST inDigest; +} Extend_In; + +typedef struct { + TPM_PCRVALUE outDigest; +} Extend_Out; + +TPM_RC +TPM2_Extend( + Extend_In *in, // IN: input parameter buffer + Extend_Out *out // OUT: output parameter buffer + ); + +#endif diff --git a/libstb/tss2/ibmtss/FlushContext_fp.h b/libstb/tss2/ibmtss/FlushContext_fp.h new file mode 100644 index 0000000..97b22e5 --- /dev/null +++ b/libstb/tss2/ibmtss/FlushContext_fp.h @@ -0,0 +1,78 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: FlushContext_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef FLUSHCONTEXT_FP_H +#define FLUSHCONTEXT_FP_H + +typedef struct { + TPMI_DH_CONTEXT flushHandle; +} FlushContext_In; + +#define RC_FlushContext_flushHandle (TPM_RC_P + TPM_RC_1) + +TPM_RC +TPM2_FlushContext( + FlushContext_In *in // IN: input parameter list + ); + +#endif diff --git a/libstb/tss2/ibmtss/FlushSpecific_fp.h b/libstb/tss2/ibmtss/FlushSpecific_fp.h new file mode 100644 index 0000000..2ccd8feb --- /dev/null +++ b/libstb/tss2/ibmtss/FlushSpecific_fp.h @@ -0,0 +1,58 @@ +/********************************************************************************/ +/* */ +/* TPM 1.2 FlushSpecific */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: FlushSpecific_fp.h 1257 2018-06-27 20:52:08Z kgoldman $ */ +/* */ +/* (c) Copyright IBM Corporation 2018. */ +/* */ +/* All rights reserved. */ +/* */ +/* Redistribution and use in source and binary forms, with or without */ +/* modification, are permitted provided that the following conditions are */ +/* met: */ +/* */ +/* Redistributions of source code must retain the above copyright notice, */ +/* this list of conditions and the following disclaimer. */ +/* */ +/* 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. */ +/* */ +/* Neither the names of the IBM Corporation nor the names of its */ +/* contributors may be used to endorse or promote products derived from */ +/* this software without specific prior written permission. */ +/* */ +/* 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 FLUSHSPECIFIC_FP_H +#define FLUSHSPECIFIC_FP_H + +#include <ibmtss/tpmtypes12.h> +#include <ibmtss/tpmstructures12.h> + +#include <ibmtss/Implementation.h> + +typedef struct { + TPM_HANDLE handle; + TPM_RESOURCE_TYPE resourceType; +} FlushSpecific_In; + +TPM_RC +TPM2_FlushSpecific( + FlushSpecific_In *in // IN: input parameter buffer + ); + +#endif diff --git a/libstb/tss2/ibmtss/GetCapability12_fp.h b/libstb/tss2/ibmtss/GetCapability12_fp.h new file mode 100644 index 0000000..a1c47a0 --- /dev/null +++ b/libstb/tss2/ibmtss/GetCapability12_fp.h @@ -0,0 +1,65 @@ +/********************************************************************************/ +/* */ +/* Get Capability for TPM 1.2 */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* */ +/* (c) Copyright IBM Corporation 2018. */ +/* */ +/* All rights reserved. */ +/* */ +/* Redistribution and use in source and binary forms, with or without */ +/* modification, are permitted provided that the following conditions are */ +/* met: */ +/* */ +/* Redistributions of source code must retain the above copyright notice, */ +/* this list of conditions and the following disclaimer. */ +/* */ +/* 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. */ +/* */ +/* Neither the names of the IBM Corporation nor the names of its */ +/* contributors may be used to endorse or promote products derived from */ +/* this software without specific prior written permission. */ +/* */ +/* 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 GETCAPABILITY12_FP_H +#define GETCAPABILITY12_FP_H + +typedef struct { + TPM_CAPABILITY_AREA capArea; + UINT32 subCapSize; + uint8_t subCap[MAX_RESPONSE_SIZE]; +} GetCapability12_In; + +#define RC_GetCapability12_capArea (TPM_RC_P + TPM_RC_1) +#define RC_GetCapability12_subCapSize (TPM_RC_P + TPM_RC_2) +#define RC_GetCapability12_subcap (TPM_RC_P + TPM_RC_3) + +typedef struct { + UINT32 respSize; + uint8_t resp[MAX_RESPONSE_SIZE]; +} GetCapability12_Out; + + +TPM_RC +TPM2_GetCapability12( + GetCapability12_In *in, // IN: input parameter list + GetCapability12_Out *out // OUT: output parameter list + ); + + +#endif diff --git a/libstb/tss2/ibmtss/GetCapability_fp.h b/libstb/tss2/ibmtss/GetCapability_fp.h new file mode 100644 index 0000000..7257613 --- /dev/null +++ b/libstb/tss2/ibmtss/GetCapability_fp.h @@ -0,0 +1,90 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: GetCapability_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef GETCAPABILITY_FP_H +#define GETCAPABILITY_FP_H + +typedef struct { + TPM_CAP capability; + UINT32 property; + UINT32 propertyCount; +} GetCapability_In; + +#define RC_GetCapability_capability (TPM_RC_P + TPM_RC_1) +#define RC_GetCapability_property (TPM_RC_P + TPM_RC_2) +#define RC_GetCapability_propertyCount (TPM_RC_P + TPM_RC_3) + +typedef struct { + TPMI_YES_NO moreData; + TPMS_CAPABILITY_DATA capabilityData; +} GetCapability_Out; + + +TPM_RC +TPM2_GetCapability( + GetCapability_In *in, // IN: input parameter list + GetCapability_Out *out // OUT: output parameter list + ); + + +#endif diff --git a/libstb/tss2/ibmtss/GetCommandAuditDigest_fp.h b/libstb/tss2/ibmtss/GetCommandAuditDigest_fp.h new file mode 100644 index 0000000..71a5f15 --- /dev/null +++ b/libstb/tss2/ibmtss/GetCommandAuditDigest_fp.h @@ -0,0 +1,91 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: GetCommandAuditDigest_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef GETCOMMANDAUDITDIGEST_FP_H +#define GETCOMMANDAUDITDIGEST_FP_H + +typedef struct { + TPMI_RH_ENDORSEMENT privacyHandle; + TPMI_DH_OBJECT signHandle; + TPM2B_DATA qualifyingData; + TPMT_SIG_SCHEME inScheme; +} GetCommandAuditDigest_In; + +#define RC_GetCommandAuditDigest_privacyHandle (TPM_RC_H + TPM_RC_1) +#define RC_GetCommandAuditDigest_signHandle (TPM_RC_H + TPM_RC_2) +#define RC_GetCommandAuditDigest_qualifyingData (TPM_RC_P + TPM_RC_1) +#define RC_GetCommandAuditDigest_inScheme (TPM_RC_P + TPM_RC_2) + +typedef struct { + TPM2B_ATTEST auditInfo; + TPMT_SIGNATURE signature; +} GetCommandAuditDigest_Out; + +TPM_RC +TPM2_GetCommandAuditDigest( + GetCommandAuditDigest_In *in, // IN: input parameter list + GetCommandAuditDigest_Out *out // OUT: output parameter list + ); + + +#endif diff --git a/libstb/tss2/ibmtss/GetRandom_fp.h b/libstb/tss2/ibmtss/GetRandom_fp.h new file mode 100644 index 0000000..438da95 --- /dev/null +++ b/libstb/tss2/ibmtss/GetRandom_fp.h @@ -0,0 +1,84 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: GetRandom_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef GETRANDOM_FP_H +#define GETRANDOM_FP_H + +typedef struct { + UINT16 bytesRequested; +} GetRandom_In; + +#define RC_GetRandom_bytesRequested (TPM_RC_P + TPM_RC_1) + +typedef struct { + TPM2B_DIGEST randomBytes; +} GetRandom_Out; + +TPM_RC +TPM2_GetRandom( + GetRandom_In *in, // IN: input parameter list + GetRandom_Out *out // OUT: output parameter list + ); + + +#endif diff --git a/libstb/tss2/ibmtss/GetSessionAuditDigest_fp.h b/libstb/tss2/ibmtss/GetSessionAuditDigest_fp.h new file mode 100644 index 0000000..b49c8cd --- /dev/null +++ b/libstb/tss2/ibmtss/GetSessionAuditDigest_fp.h @@ -0,0 +1,93 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: GetSessionAuditDigest_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef GETSESSIONAUDITDIGEST_FP_H +#define GETSESSIONAUDITDIGEST_FP_H + +typedef struct { + TPMI_RH_ENDORSEMENT privacyAdminHandle; + TPMI_DH_OBJECT signHandle; + TPMI_SH_HMAC sessionHandle; + TPM2B_DATA qualifyingData; + TPMT_SIG_SCHEME inScheme; +} GetSessionAuditDigest_In; + +#define RC_GetSessionAuditDigest_privacyAdminHandle (TPM_RC_H + TPM_RC_1) +#define RC_GetSessionAuditDigest_signHandle (TPM_RC_H + TPM_RC_2) +#define RC_GetSessionAuditDigest_sessionHandle (TPM_RC_H + TPM_RC_3) +#define RC_GetSessionAuditDigest_qualifyingData (TPM_RC_P + TPM_RC_1) +#define RC_GetSessionAuditDigest_inScheme (TPM_RC_P + TPM_RC_2) + +typedef struct { + TPM2B_ATTEST auditInfo; + TPMT_SIGNATURE signature; +} GetSessionAuditDigest_Out; + +TPM_RC +TPM2_GetSessionAuditDigest( + GetSessionAuditDigest_In *in, // IN: input parameter list + GetSessionAuditDigest_Out *out // OUT: output parameter list + ); + + +#endif diff --git a/libstb/tss2/ibmtss/GetTestResult_fp.h b/libstb/tss2/ibmtss/GetTestResult_fp.h new file mode 100644 index 0000000..4c4c716 --- /dev/null +++ b/libstb/tss2/ibmtss/GetTestResult_fp.h @@ -0,0 +1,79 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: GetTestResult_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2016 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef GETTESTRESULT_FP_H +#define GETTESTRESULT_FP_H + +typedef struct{ + TPM2B_MAX_BUFFER outData; + TPM_RC testResult; +} GetTestResult_Out; + + + TPM_RC +TPM2_GetTestResult( + GetTestResult_Out *out // OUT: output parameter list + ); + + +#endif diff --git a/libstb/tss2/ibmtss/GetTime_fp.h b/libstb/tss2/ibmtss/GetTime_fp.h new file mode 100644 index 0000000..75c5e6c --- /dev/null +++ b/libstb/tss2/ibmtss/GetTime_fp.h @@ -0,0 +1,91 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: GetTime_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef GETTIME_FP_H +#define GETTIME_FP_H + +typedef struct { + TPMI_RH_ENDORSEMENT privacyAdminHandle; + TPMI_DH_OBJECT signHandle; + TPM2B_DATA qualifyingData; + TPMT_SIG_SCHEME inScheme; +} GetTime_In; + +#define RC_GetTime_privacyAdminHandle (TPM_RC_H + TPM_RC_1) +#define RC_GetTime_signHandle (TPM_RC_H + TPM_RC_2) +#define RC_GetTime_qualifyingData (TPM_RC_P + TPM_RC_1) +#define RC_GetTime_inScheme (TPM_RC_P + TPM_RC_2) + +typedef struct { + TPM2B_ATTEST timeInfo; + TPMT_SIGNATURE signature; +} GetTime_Out; + +TPM_RC +TPM2_GetTime( + GetTime_In *in, // IN: input parameter list + GetTime_Out *out // OUT: output parameter list + ); + + +#endif diff --git a/libstb/tss2/ibmtss/HMAC_Start_fp.h b/libstb/tss2/ibmtss/HMAC_Start_fp.h new file mode 100644 index 0000000..b27b2e5 --- /dev/null +++ b/libstb/tss2/ibmtss/HMAC_Start_fp.h @@ -0,0 +1,88 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: HMAC_Start_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef HMAC_START_FP_H +#define HMAC_START_FP_H + +typedef struct { + TPMI_DH_OBJECT handle; + TPM2B_AUTH auth; + TPMI_ALG_HASH hashAlg; +} HMAC_Start_In; + +typedef struct { + TPMI_DH_OBJECT sequenceHandle; +} HMAC_Start_Out; + +#define RC_HMAC_Start_handle (TPM_RC_H + TPM_RC_1) +#define RC_HMAC_Start_auth (TPM_RC_P + TPM_RC_1) +#define RC_HMAC_Start_hashAlg (TPM_RC_P + TPM_RC_2) + +TPM_RC +TPM2_HMAC_Start( + HMAC_Start_In *in, // IN: input parameter list + HMAC_Start_Out *out // OUT: output parameter list + ); + + +#endif diff --git a/libstb/tss2/ibmtss/HMAC_fp.h b/libstb/tss2/ibmtss/HMAC_fp.h new file mode 100644 index 0000000..aace922 --- /dev/null +++ b/libstb/tss2/ibmtss/HMAC_fp.h @@ -0,0 +1,88 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: HMAC_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef HMAC_FP_H +#define HMAC_FP_H + +typedef struct { + TPMI_DH_OBJECT handle; + TPM2B_MAX_BUFFER buffer; + TPMI_ALG_HASH hashAlg; +} HMAC_In; + +#define RC_HMAC_handle (TPM_RC_H + TPM_RC_1) +#define RC_HMAC_buffer (TPM_RC_P + TPM_RC_1) +#define RC_HMAC_hashAlg (TPM_RC_P + TPM_RC_2) + +typedef struct { + TPM2B_DIGEST outHMAC; +} HMAC_Out; + +TPM_RC +TPM2_HMAC( + HMAC_In *in, // IN: input parameter list + HMAC_Out *out // OUT: output parameter list + ); + + +#endif diff --git a/libstb/tss2/ibmtss/HashSequenceStart_fp.h b/libstb/tss2/ibmtss/HashSequenceStart_fp.h new file mode 100644 index 0000000..7a5bd11 --- /dev/null +++ b/libstb/tss2/ibmtss/HashSequenceStart_fp.h @@ -0,0 +1,88 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: HashSequenceStart_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef HASHSEQUENCESTART_FP_H +#define HASHSEQUENCESTART_FP_H + +typedef struct { + TPM2B_AUTH auth; + TPMI_ALG_HASH hashAlg; +} HashSequenceStart_In; + +#define RC_HashSequenceStart_auth (TPM_RC_P + TPM_RC_1) +#define RC_HashSequenceStart_hashAlg (TPM_RC_P + TPM_RC_2) + +typedef struct { + TPMI_DH_OBJECT sequenceHandle; +} HashSequenceStart_Out; + + + +TPM_RC +TPM2_HashSequenceStart( + HashSequenceStart_In *in, // IN: input parameter list + HashSequenceStart_Out *out // OUT: output parameter list + ); + + +#endif diff --git a/libstb/tss2/ibmtss/Hash_fp.h b/libstb/tss2/ibmtss/Hash_fp.h new file mode 100644 index 0000000..7e3a009 --- /dev/null +++ b/libstb/tss2/ibmtss/Hash_fp.h @@ -0,0 +1,89 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: Hash_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef HASH_FP_H +#define HASH_FP_H + +typedef struct { + TPM2B_MAX_BUFFER data; + TPMI_ALG_HASH hashAlg; + TPMI_RH_HIERARCHY hierarchy; +} Hash_In; + +#define RC_Hash_data (TPM_RC_P + TPM_RC_1) +#define RC_Hash_hashAlg (TPM_RC_P + TPM_RC_2) +#define RC_Hash_hierarchy (TPM_RC_P + TPM_RC_3) + +typedef struct { + TPM2B_DIGEST outHash; + TPMT_TK_HASHCHECK validation; +} Hash_Out; + +TPM_RC +TPM2_Hash( + Hash_In *in, // IN: input parameter list + Hash_Out *out // OUT: output parameter list + ); + + +#endif diff --git a/libstb/tss2/ibmtss/HierarchyChangeAuth_fp.h b/libstb/tss2/ibmtss/HierarchyChangeAuth_fp.h new file mode 100644 index 0000000..df6278a --- /dev/null +++ b/libstb/tss2/ibmtss/HierarchyChangeAuth_fp.h @@ -0,0 +1,80 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: HierarchyChangeAuth_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef HIERARCHYCHANGEAUTH_FP_H +#define HIERARCHYCHANGEAUTH_FP_H + +typedef struct { + TPMI_RH_HIERARCHY_AUTH authHandle; + TPM2B_AUTH newAuth; +} HierarchyChangeAuth_In; + +#define RC_HierarchyChangeAuth_authHandle (TPM_RC_H + TPM_RC_1) +#define RC_HierarchyChangeAuth_newAuth (TPM_RC_P + TPM_RC_2) + +TPM_RC +TPM2_HierarchyChangeAuth( + HierarchyChangeAuth_In *in // IN: input parameter list + ); + +#endif diff --git a/libstb/tss2/ibmtss/HierarchyControl_fp.h b/libstb/tss2/ibmtss/HierarchyControl_fp.h new file mode 100644 index 0000000..e774f6d --- /dev/null +++ b/libstb/tss2/ibmtss/HierarchyControl_fp.h @@ -0,0 +1,83 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: HierarchyControl_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef HIERARCHYCONTROL_FP_H +#define HIERARCHYCONTROL_FP_H + +typedef struct { + TPMI_RH_HIERARCHY authHandle; + TPMI_RH_ENABLES enable; + TPMI_YES_NO state; +} HierarchyControl_In; + +#define RC_HierarchyControl_authHandle (TPM_RC_H + TPM_RC_1) +#define RC_HierarchyControl_enable (TPM_RC_P + TPM_RC_1) +#define RC_HierarchyControl_state (TPM_RC_P + TPM_RC_2) + +TPM_RC +TPM2_HierarchyControl( + HierarchyControl_In *in // IN: input parameter list + ); + + +#endif diff --git a/libstb/tss2/ibmtss/Implementation.h b/libstb/tss2/ibmtss/Implementation.h new file mode 100644 index 0000000..83ac86a --- /dev/null +++ b/libstb/tss2/ibmtss/Implementation.h @@ -0,0 +1,1440 @@ +/********************************************************************************/ +/* */ +/* TSS Implementation Specific Constants */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* */ +/* 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, 2012-2019 */ +/* */ +/********************************************************************************/ + +/* #define TPM_TSS_SO_0 to get the libibmtss.so.0 values. Leave it undefined to get the new + libibmtss.so.1 values. + + The new values are required for a TPM with 4 or more hash algorithms. +*/ + +// A.2 Implementation.h + +#ifndef _IMPLEMENTATION_H_ +#define _IMPLEMENTATION_H_ + +#include <ibmtss/TpmBuildSwitches.h> +#include <ibmtss/BaseTypes.h> +#include <ibmtss/TPMB.h> + +/* Constants for TPM_Types.h structures. Changing these values is likely to break ABI + compatiblility.*/ + +// From Vendor-Specific: Table 4 - Defines for Key Size Constants + +#ifdef TPM_TSS_SO_0 +#define MAX_RSA_KEY_BYTES 256 +#else +#define MAX_RSA_KEY_BYTES 512 +#endif + +#ifdef TPM_TSS_SO_0 +#define MAX_ECC_KEY_BYTES 48 +#else +#define MAX_ECC_KEY_BYTES 128 +#endif + +/* This is the PC Client minimum value, and should be used for applications. */ +#define IMPLEMENTATION_PCR 24 + +#define MAX_HANDLE_NUM 3 /* the maximum number of handles in the handle + area */ +#define MAX_ACTIVE_SESSIONS 64 /* the number of simultaneously active sessions that + are supported by the TPM implementation */ +#define MAX_SESSION_NUM 3 /* this is the current maximum value */ + +#ifdef TPM_TSS_SO_0 +#define PCR_SELECT_MAX ((IMPLEMENTATION_PCR+7)/8) +#else +/* increased to 8 to handle up to 64 PCRs */ +#define PCR_SELECT_MAX 8 +#endif + +#ifdef TPM_TSS_SO_0 +#define MAX_CONTEXT_SIZE 2048 +#else +#define MAX_CONTEXT_SIZE 5120 +#endif + +#define MAX_DIGEST_BUFFER 2048 +#define MAX_NV_BUFFER_SIZE 2048 +#define MAX_CAP_BUFFER 2048 + +#ifdef TPM_TSS_SO_0 +#define MAX_ALG_LIST_SIZE 64 /* number of algorithms that can be in a list */ +#else +#define MAX_ALG_LIST_SIZE 128 /* number of algorithms that can be in a list */ +#endif + +#define MAX_COMMAND_SIZE 4096 /* maximum size of a command */ +#define MAX_RESPONSE_SIZE 4096 /* maximum size of a response */ + +#ifdef TPM_TSS_SO_0 +#define MAX_SYM_DATA 128 /* this is the maximum number of octets that + may be in a sealed blob. */ +#else +#define MAX_SYM_DATA 256 +#endif + +#ifdef TPM_TSS_SO_0 +/* For the TSS .so.0, the number of digest and PCR banks was originally dependent on the number of + supported hash algoriths, using common TPM / TSS code. */ +#define HASH_COUNT 3 +#else +/* For the TSS .so.1, the number was increased to support a SW TPM with 4 banks (unlikely for a HW + TPM) plus future expansion. */ +#define HASH_COUNT 16 +#endif + +/* value independent of supported hash algorithms */ +#define LABEL_MAX_BUFFER 48 +#if LABEL_MAX_BUFFER < 32 +#error "The size allowed for the label is not large enough for interoperability." +#endif + +/* hard code maximum independent of the algorithms actually supported */ +#define MAX_SYM_KEY_BYTES 32 +#define MAX_SYM_BLOCK_SIZE 16 + +#define RSA_DEFAULT_PUBLIC_EXPONENT 0x00010001 /* 2^^16 + 1 */ + +#undef TRUE +#undef FALSE + +// From TPM 2.0 Part 2: Table 4 - Defines for Logic Values + +#define TRUE 1 +#define FALSE 0 +#define YES 1 +#define NO 0 +#define SET 1 +#define CLEAR 0 + +// Change these definitions to turn all algorithms or commands ON or OFF. That is, to turn all +// algorithms on, set ALG_NO to YES. This is mostly useful as a debug feature. + +#define ALG_YES YES +#define ALG_NO NO +#define CC_YES YES +#define CC_NO NO + +// From Vendor-Specific: Table 2 - Defines for Implemented Algorithms + +#ifndef ALG_RSA +#define ALG_RSA ALG_YES +#endif +#ifndef ALG_SHA1 +#define ALG_SHA1 ALG_YES +#endif +#define ALG_HMAC ALG_YES +#ifndef ALG_TDES +#define ALG_TDES ALG_YES +#endif +#define ALG_AES ALG_YES +#define ALG_MGF1 ALG_YES +#define ALG_XOR ALG_YES +#define ALG_KEYEDHASH ALG_YES +#ifndef ALG_SHA256 +#define ALG_SHA256 ALG_YES +#endif +#ifndef ALG_SHA384 +#define ALG_SHA384 ALG_YES +#endif +#ifndef ALG_SHA512 +#define ALG_SHA512 ALG_YES +#endif +#define ALG_SHA3_256 ALG_NO +#define ALG_SHA3_384 ALG_NO +#define ALG_SHA3_512 ALG_NO +#define ALG_SM3_256 ALG_NO +#define ALG_SM4 ALG_NO +#define ALG_RSASSA (ALG_YES*ALG_RSA) +#define ALG_RSAES (ALG_YES*ALG_RSA) +#define ALG_RSAPSS (ALG_YES*ALG_RSA) +#define ALG_OAEP (ALG_YES*ALG_RSA) +#ifndef ALG_ECC +#define ALG_ECC ALG_YES +#endif +#define ALG_ECDH (ALG_YES*ALG_ECC) +#define ALG_ECDSA (ALG_YES*ALG_ECC) +#define ALG_ECDAA (ALG_YES*ALG_ECC) +#define ALG_SM2 (ALG_YES*ALG_ECC) +#define ALG_ECSCHNORR (ALG_YES*ALG_ECC) +#define ALG_ECMQV (ALG_NO*ALG_ECC) +#define ALG_SYMCIPHER ALG_YES +#define ALG_KDF1_SP800_56A (ALG_YES*ALG_ECC) +#define ALG_KDF2 ALG_NO +#define ALG_KDF1_SP800_108 ALG_YES +#define ALG_CTR ALG_YES +#define ALG_OFB ALG_YES +#define ALG_CBC ALG_YES +#define ALG_CFB ALG_YES +#define ALG_ECB ALG_YES + +// From Vendor-Specific: Table 6 - Defines for Implemented Commands + +#define CC_ActivateCredential CC_YES +#define CC_Certify CC_YES +#define CC_CertifyCreation CC_YES +#define CC_ChangeEPS CC_YES +#define CC_ChangePPS CC_YES +#define CC_Clear CC_YES +#define CC_ClearControl CC_YES +#define CC_ClockRateAdjust CC_YES +#define CC_ClockSet CC_YES +#define CC_Commit (CC_YES*ALG_ECC) +#define CC_ContextLoad CC_YES +#define CC_ContextSave CC_YES +#define CC_Create CC_YES +#define CC_CreatePrimary CC_YES +#define CC_DictionaryAttackLockReset CC_YES +#define CC_DictionaryAttackParameters CC_YES +#define CC_Duplicate CC_YES +#define CC_ECC_Parameters (CC_YES*ALG_ECC) +#define CC_ECDH_KeyGen (CC_YES*ALG_ECC) +#define CC_ECDH_ZGen (CC_YES*ALG_ECC) +#define CC_EncryptDecrypt CC_YES +#define CC_EventSequenceComplete CC_YES +#define CC_EvictControl CC_YES +#define CC_FieldUpgradeData CC_NO +#define CC_FieldUpgradeStart CC_NO +#define CC_FirmwareRead CC_NO +#define CC_FlushContext CC_YES +#define CC_GetCapability CC_YES +#define CC_GetCommandAuditDigest CC_YES +#define CC_GetRandom CC_YES +#define CC_GetSessionAuditDigest CC_YES +#define CC_GetTestResult CC_YES +#define CC_GetTime CC_YES +#define CC_Hash CC_YES +#define CC_HashSequenceStart CC_YES +#define CC_HierarchyChangeAuth CC_YES +#define CC_HierarchyControl CC_YES +#define CC_HMAC CC_YES +#define CC_HMAC_Start CC_YES +#define CC_Import CC_YES +#define CC_IncrementalSelfTest CC_YES +#define CC_Load CC_YES +#define CC_LoadExternal CC_YES +#define CC_MakeCredential CC_YES +#define CC_NV_Certify CC_YES +#define CC_NV_ChangeAuth CC_YES +#define CC_NV_DefineSpace CC_YES +#define CC_NV_Extend CC_YES +#define CC_NV_GlobalWriteLock CC_YES +#define CC_NV_Increment CC_YES +#define CC_NV_Read CC_YES +#define CC_NV_ReadLock CC_YES +#define CC_NV_ReadPublic CC_YES +#define CC_NV_SetBits CC_YES +#define CC_NV_UndefineSpace CC_YES +#define CC_NV_UndefineSpaceSpecial CC_YES +#define CC_NV_Write CC_YES +#define CC_NV_WriteLock CC_YES +#define CC_ObjectChangeAuth CC_YES +#define CC_PCR_Allocate CC_YES +#define CC_PCR_Event CC_YES +#define CC_PCR_Extend CC_YES +#define CC_PCR_Read CC_YES +#define CC_PCR_Reset CC_YES +#define CC_PCR_SetAuthPolicy CC_YES +#define CC_PCR_SetAuthValue CC_YES +#define CC_PolicyAuthorize CC_YES +#define CC_PolicyAuthorizeNV CC_YES +#define CC_PolicyAuthValue CC_YES +#define CC_PolicyCommandCode CC_YES +#define CC_PolicyCounterTimer CC_YES +#define CC_PolicyCpHash CC_YES +#define CC_PolicyDuplicationSelect CC_YES +#define CC_PolicyGetDigest CC_YES +#define CC_PolicyLocality CC_YES +#define CC_PolicyNameHash CC_YES +#define CC_PolicyNV CC_YES +#define CC_PolicyOR CC_YES +#define CC_PolicyPassword CC_YES +#define CC_PolicyPCR CC_YES +#define CC_PolicyPhysicalPresence CC_YES +#define CC_PolicyRestart CC_YES +#define CC_PolicySecret CC_YES +#define CC_PolicySigned CC_YES +#define CC_PolicyTicket CC_YES +#define CC_PP_Commands CC_YES +#define CC_Quote CC_YES +#define CC_ReadClock CC_YES +#define CC_ReadPublic CC_YES +#define CC_Rewrap CC_YES +#define CC_RSA_Decrypt (CC_YES*ALG_RSA) +#define CC_RSA_Encrypt (CC_YES*ALG_RSA) +#define CC_SelfTest CC_YES +#define CC_SequenceComplete CC_YES +#define CC_SequenceUpdate CC_YES +#define CC_SetAlgorithmSet CC_YES +#define CC_SetCommandCodeAuditStatus CC_YES +#define CC_SetPrimaryPolicy CC_YES +#define CC_Shutdown CC_YES +#define CC_Sign CC_YES +#define CC_StartAuthSession CC_YES +#define CC_Startup CC_YES +#define CC_StirRandom CC_YES +#define CC_TestParms CC_YES +#define CC_Unseal CC_YES +#define CC_VerifySignature CC_YES +#define CC_ZGen_2Phase (CC_YES*ALG_ECC) +#define CC_EC_Ephemeral (CC_YES*ALG_ECC) +#define CC_PolicyNvWritten CC_YES +#define CC_PolicyTemplate CC_YES +#define CC_CreateLoaded CC_YES +#define CC_PolicyAuthorizeNV CC_YES +#define CC_EncryptDecrypt2 CC_YES +#define CC_Vendor_TCG_Test CC_YES + +#define CC_NTC2_PreConfig CC_YES +#define CC_NTC2_LockPreConfig CC_YES +#define CC_NTC2_GetConfig CC_YES + +// From TCG Algorithm Registry: Table 2 - Definition of TPM_ALG_ID Constants + +#define ALG_ERROR_VALUE 0x0000 +#define TPM_ALG_ERROR (TPM_ALG_ID)(ALG_ERROR_VALUE) +#define ALG_RSA_VALUE 0x0001 +#if defined ALG_RSA && ALG_RSA == YES +#define TPM_ALG_RSA (TPM_ALG_ID)(ALG_RSA_VALUE) +#endif +#define ALG_TDES_VALUE 0x0003 +#if defined ALG_TDES && ALG_TDES == YES +#define TPM_ALG_TDES (TPM_ALG_ID)(ALG_TDES_VALUE) +#endif +#define ALG_SHA_VALUE 0x0004 +#if defined ALG_SHA && ALG_SHA == YES +#define TPM_ALG_SHA (TPM_ALG_ID)(ALG_SHA_VALUE) +#endif +#define ALG_SHA1_VALUE 0x0004 +#if defined ALG_SHA1 && ALG_SHA1 == YES +#define TPM_ALG_SHA1 (TPM_ALG_ID)(ALG_SHA1_VALUE) +#endif +#define ALG_HMAC_VALUE 0x0005 +#if defined ALG_HMAC && ALG_HMAC == YES +#define TPM_ALG_HMAC (TPM_ALG_ID)(ALG_HMAC_VALUE) +#endif +#define ALG_AES_VALUE 0x0006 +#if defined ALG_AES && ALG_AES == YES +#define TPM_ALG_AES (TPM_ALG_ID)(ALG_AES_VALUE) +#endif +#define ALG_MGF1_VALUE 0x0007 +#if defined ALG_MGF1 && ALG_MGF1 == YES +#define TPM_ALG_MGF1 (TPM_ALG_ID)(ALG_MGF1_VALUE) +#endif +#define ALG_KEYEDHASH_VALUE 0x0008 +#if defined ALG_KEYEDHASH && ALG_KEYEDHASH == YES +#define TPM_ALG_KEYEDHASH (TPM_ALG_ID)(ALG_KEYEDHASH_VALUE) +#endif +#define ALG_XOR_VALUE 0x000A +#if defined ALG_XOR && ALG_XOR == YES +#define TPM_ALG_XOR (TPM_ALG_ID)(ALG_XOR_VALUE) +#endif +#define ALG_SHA256_VALUE 0x000B +#if defined ALG_SHA256 && ALG_SHA256 == YES +#define TPM_ALG_SHA256 (TPM_ALG_ID)(ALG_SHA256_VALUE) +#endif +#define ALG_SHA384_VALUE 0x000C +#if defined ALG_SHA384 && ALG_SHA384 == YES +#define TPM_ALG_SHA384 (TPM_ALG_ID)(ALG_SHA384_VALUE) +#endif +#define ALG_SHA512_VALUE 0x000D +#if defined ALG_SHA512 && ALG_SHA512 == YES +#define TPM_ALG_SHA512 (TPM_ALG_ID)(ALG_SHA512_VALUE) +#endif +#define ALG_NULL_VALUE 0x0010 +#define TPM_ALG_NULL (TPM_ALG_ID)(ALG_NULL_VALUE) +#define ALG_SM3_256_VALUE 0x0012 +#if defined ALG_SM3_256 && ALG_SM3_256 == YES +#define TPM_ALG_SM3_256 (TPM_ALG_ID)(ALG_SM3_256_VALUE) +#endif +#define ALG_SM4_VALUE 0x0013 +#if defined ALG_SM4 && ALG_SM4 == YES +#define TPM_ALG_SM4 (TPM_ALG_ID)(ALG_SM4_VALUE) +#endif +#define ALG_RSASSA_VALUE 0x0014 +#if defined ALG_RSASSA && ALG_RSASSA == YES +#define TPM_ALG_RSASSA (TPM_ALG_ID)(ALG_RSASSA_VALUE) +#endif +#define ALG_RSAES_VALUE 0x0015 +#if defined ALG_RSAES && ALG_RSAES == YES +#define TPM_ALG_RSAES (TPM_ALG_ID)(ALG_RSAES_VALUE) +#endif +#define ALG_RSAPSS_VALUE 0x0016 +#if defined ALG_RSAPSS && ALG_RSAPSS == YES +#define TPM_ALG_RSAPSS (TPM_ALG_ID)(ALG_RSAPSS_VALUE) +#endif +#define ALG_OAEP_VALUE 0x0017 +#if defined ALG_OAEP && ALG_OAEP == YES +#define TPM_ALG_OAEP (TPM_ALG_ID)(ALG_OAEP_VALUE) +#endif +#define ALG_ECDSA_VALUE 0x0018 +#if defined ALG_ECDSA && ALG_ECDSA == YES +#define TPM_ALG_ECDSA (TPM_ALG_ID)(ALG_ECDSA_VALUE) +#endif +#define ALG_ECDH_VALUE 0x0019 +#if defined ALG_ECDH && ALG_ECDH == YES +#define TPM_ALG_ECDH (TPM_ALG_ID)(ALG_ECDH_VALUE) +#endif +#define ALG_ECDAA_VALUE 0x001A +#if defined ALG_ECDAA && ALG_ECDAA == YES +#define TPM_ALG_ECDAA (TPM_ALG_ID)(ALG_ECDAA_VALUE) +#endif +#define ALG_SM2_VALUE 0x001B +#if defined ALG_SM2 && ALG_SM2 == YES +#define TPM_ALG_SM2 (TPM_ALG_ID)(ALG_SM2_VALUE) +#endif +#define ALG_ECSCHNORR_VALUE 0x001C +#if defined ALG_ECSCHNORR && ALG_ECSCHNORR == YES +#define TPM_ALG_ECSCHNORR (TPM_ALG_ID)(ALG_ECSCHNORR_VALUE) +#endif +#define ALG_ECMQV_VALUE 0x001D +#if defined ALG_ECMQV && ALG_ECMQV == YES +#define TPM_ALG_ECMQV (TPM_ALG_ID)(ALG_ECMQV_VALUE) +#endif +#define ALG_KDF1_SP800_56A_VALUE 0x0020 +#if defined ALG_KDF1_SP800_56A && ALG_KDF1_SP800_56A == YES +#define TPM_ALG_KDF1_SP800_56A (TPM_ALG_ID)(ALG_KDF1_SP800_56A_VALUE) +#endif +#define ALG_KDF2_VALUE 0x0021 +#if defined ALG_KDF2 && ALG_KDF2 == YES +#define TPM_ALG_KDF2 (TPM_ALG_ID)(ALG_KDF2_VALUE) +#endif +#define ALG_KDF1_SP800_108_VALUE 0x0022 +#if defined ALG_KDF1_SP800_108 && ALG_KDF1_SP800_108 == YES +#define TPM_ALG_KDF1_SP800_108 (TPM_ALG_ID)(ALG_KDF1_SP800_108_VALUE) +#endif +#define ALG_ECC_VALUE 0x0023 +#if defined ALG_ECC && ALG_ECC == YES +#define TPM_ALG_ECC (TPM_ALG_ID)(ALG_ECC_VALUE) +#endif +#define ALG_SYMCIPHER_VALUE 0x0025 +#if defined ALG_SYMCIPHER && ALG_SYMCIPHER == YES +#define TPM_ALG_SYMCIPHER (TPM_ALG_ID)(ALG_SYMCIPHER_VALUE) +#endif +#define ALG_CAMELLIA_VALUE 0x0026 +#if defined ALG_CAMELLIA && ALG_CAMELLIA == YES +#define TPM_ALG_CAMELLIA (TPM_ALG_ID)(ALG_CAMELLIA_VALUE) +#endif +#define ALG_SHA3_256_VALUE 0x0027 +#if defined ALG_SHA3_256 && ALG_SHA3_256 == YES +#define TPM_ALGSHA3_256 (TPM_ALG_ID)(ALG_SHA3_256_VALUE) +#endif +#define ALG_SHA3_384_VALUE 0x0028 +#if defined ALG_SHA3_384 && ALG_SHA3_384 == YES +#define TPM_ALGSHA3_384 (TPM_ALG_ID)(ALG_SHA3_384_VALUE) +#endif +#define ALG_SHA3_512_VALUE 0x0029 +#if defined ALG_SHA3_512 && ALG_SHA3_512 == YES +#define TPM_ALGSHA3_512 (TPM_ALG_ID)(ALG_SHA3_512_VALUE) +#endif +#define ALG_CMAC_VALUE 0x003f +#if defined ALG_CMAC && ALG_CMAC == YES +#define TPM_ALG_CMAC (TPM_ALG_ID)(ALG_CMAC_VALUE) +#endif +#define ALG_CTR_VALUE 0x0040 +#if defined ALG_CTR && ALG_CTR == YES +#define TPM_ALG_CTR (TPM_ALG_ID)(ALG_CTR_VALUE) +#endif +#define ALG_OFB_VALUE 0x0041 +#if defined ALG_OFB && ALG_OFB == YES +#define TPM_ALG_OFB (TPM_ALG_ID)(ALG_OFB_VALUE) +#endif +#define ALG_CBC_VALUE 0x0042 +#if defined ALG_CBC && ALG_CBC == YES +#define TPM_ALG_CBC (TPM_ALG_ID)(ALG_CBC_VALUE) +#endif +#define ALG_CFB_VALUE 0x0043 +#if defined ALG_CFB && ALG_CFB == YES +#define TPM_ALG_CFB (TPM_ALG_ID)(ALG_CFB_VALUE) +#endif +#define ALG_ECB_VALUE 0x0044 +#if defined ALG_ECB && ALG_ECB == YES +#define TPM_ALG_ECB (TPM_ALG_ID)(ALG_ECB_VALUE) +#endif + +// From TCG Algorithm Registry: Table 3 - Definition of TPM_ECC_CURVE Constants + +#define TPM_ECC_NONE (TPM_ECC_CURVE)(0x0000) +#define TPM_ECC_NIST_P192 (TPM_ECC_CURVE)(0x0001) +#define TPM_ECC_NIST_P224 (TPM_ECC_CURVE)(0x0002) +#define TPM_ECC_NIST_P256 (TPM_ECC_CURVE)(0x0003) +#define TPM_ECC_NIST_P384 (TPM_ECC_CURVE)(0x0004) +#define TPM_ECC_NIST_P521 (TPM_ECC_CURVE)(0x0005) +#define TPM_ECC_BN_P256 (TPM_ECC_CURVE)(0x0010) +#define TPM_ECC_BN_P638 (TPM_ECC_CURVE)(0x0011) +#define TPM_ECC_SM2_P256 (TPM_ECC_CURVE)(0x0020) + +// From TCG Algorithm Registry: Table 12 - Defines for SHA1 Hash Values +#define SHA1_DIGEST_SIZE 20 +#define SHA1_BLOCK_SIZE 64 +#define SHA1_DER_SIZE 15 +#define SHA1_DER \ + 0x30,0x21,0x30,0x09,0x06,0x05,0x2B,0x0E,0x03,0x02,0x1A,0x05,0x00,0x04,0x14 + +// From TCG Algorithm Registry: Table 13 - Defines for SHA256 Hash Values +#define SHA256_DIGEST_SIZE 32 +#define SHA256_BLOCK_SIZE 64 +#define SHA256_DER_SIZE 19 +#define SHA256_DER \ + 0x30,0x31,0x30,0x0D,0x06,0x09,0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x01,0x05,0x00,0x04,0x20 + +// From TCG Algorithm Registry: Table 14 - Defines for SHA384 Hash Values +#define SHA384_DIGEST_SIZE 48 +#define SHA384_BLOCK_SIZE 128 +#define SHA384_DER_SIZE 19 +#define SHA384_DER \ + 0x30,0x41,0x30,0x0D,0x06,0x09,0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x02,0x05,0x00,0x04,0x30 + +// From TCG Algorithm Registry: Table 15 - Defines for SHA512 Hash Values +#define SHA512_DIGEST_SIZE 64 +#define SHA512_BLOCK_SIZE 128 +#define SHA512_DER_SIZE 19 +#define SHA512_DER \ + 0x30,0x51,0x30,0x0D,0x06,0x09,0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x03,0x05,0x00,0x04,0x40 + +// From TCG Algorithm Registry: Table 16 - Defines for SM3_256 Hash Values +#define SM3_256_DIGEST_SIZE 32 +#define SM3_256_BLOCK_SIZE 64 +#define SM3_256_DER_SIZE 18 +#define SM3_256_DER \ + 0x30,0x30,0x30,0x0C,0x06,0x08,0x2A,0x81,0x1C,0x81,0x45,0x01,0x83,0x11,0x05,0x00,0x04,0x20 + +// From TCG Algorithm Registry: Table 17 - Defines for AES Symmetric Cipher Algorithm Constants +#define AES_128_BLOCK_SIZE_BYTES 16 +#define AES_192_BLOCK_SIZE_BYTES 16 +#define AES_256_BLOCK_SIZE_BYTES 16 + +// From TCG Algorithm Registry: Table 18 - Defines for SM4 Symmetric Cipher Algorithm Constants +#define SM4_128_BLOCK_SIZE_BYTES 16 + +// From TCG Algorithm Registry: Table 19 - Defines for CAMELLIA Symmetric Cipher Algorithm Constants +#define CAMELLIA_128_BLOCK_SIZE_BYTES 16 +#define CAMELLIA_192_BLOCK_SIZE_BYTES 16 +#define CAMELLIA_256_BLOCK_SIZE_BYTES 16 + +// From TPM 2.0 Part 2: Table 12 - Definition of TPM_CC Constants + +typedef UINT32 TPM_CC; + +#define TPM_CC_FIRST 0x0000011f /* Compile variable. May decrease based on + implementation. */ + +#ifndef CC_NV_UndefineSpaceSpecial +# define CC_NV_UndefineSpaceSpecial NO +#endif +#if CC_NV_UndefineSpaceSpecial == YES +#define TPM_CC_NV_UndefineSpaceSpecial (TPM_CC)(0x0000011f) +#endif +#ifndef CC_EvictControl +# define CC_EvictControl NO +#endif +#if CC_EvictControl == YES +#define TPM_CC_EvictControl (TPM_CC)(0x00000120) +#endif +#ifndef CC_HierarchyControl +# define CC_HierarchyControl NO +#endif +#if CC_HierarchyControl == YES +#define TPM_CC_HierarchyControl (TPM_CC)(0x00000121) +#endif +#ifndef CC_NV_UndefineSpace +# define CC_NV_UndefineSpace NO +#endif +#if CC_NV_UndefineSpace == YES +#define TPM_CC_NV_UndefineSpace (TPM_CC)(0x00000122) +#endif +#ifndef CC_ChangeEPS +# define CC_ChangeEPS NO +#endif +#if CC_ChangeEPS == YES +#define TPM_CC_ChangeEPS (TPM_CC)(0x00000124) +#endif +#ifndef CC_ChangePPS +# define CC_ChangePPS NO +#endif +#if CC_ChangePPS == YES +#define TPM_CC_ChangePPS (TPM_CC)(0x00000125) +#endif +#ifndef CC_Clear +# define CC_Clear NO +#endif +#if CC_Clear == YES +#define TPM_CC_Clear (TPM_CC)(0x00000126) +#endif +#ifndef CC_ClearControl +# define CC_ClearControl NO +#endif +#if CC_ClearControl == YES +#define TPM_CC_ClearControl (TPM_CC)(0x00000127) +#endif +#ifndef CC_ClockSet +# define CC_ClockSet NO +#endif +#if CC_ClockSet == YES +#define TPM_CC_ClockSet (TPM_CC)(0x00000128) +#endif +#ifndef CC_HierarchyChangeAuth +# define CC_HierarchyChangeAuth NO +#endif +#if CC_HierarchyChangeAuth == YES +#define TPM_CC_HierarchyChangeAuth (TPM_CC)(0x00000129) +#endif +#ifndef CC_NV_DefineSpace +# define CC_NV_DefineSpace NO +#endif +#if CC_NV_DefineSpace == YES +#define TPM_CC_NV_DefineSpace (TPM_CC)(0x0000012a) +#endif +#ifndef CC_PCR_Allocate +# define CC_PCR_Allocate NO +#endif +#if CC_PCR_Allocate == YES +#define TPM_CC_PCR_Allocate (TPM_CC)(0x0000012b) +#endif +#ifndef CC_PCR_SetAuthPolicy +# define CC_PCR_SetAuthPolicy NO +#endif +#if CC_PCR_SetAuthPolicy == YES +#define TPM_CC_PCR_SetAuthPolicy (TPM_CC)(0x0000012c) +#endif +#ifndef CC_PP_Commands +# define CC_PP_Commands NO +#endif +#if CC_PP_Commands == YES +#define TPM_CC_PP_Commands (TPM_CC)(0x0000012d) +#endif +#ifndef CC_SetPrimaryPolicy +# define CC_SetPrimaryPolicy NO +#endif +#if CC_SetPrimaryPolicy == YES +#define TPM_CC_SetPrimaryPolicy (TPM_CC)(0x0000012e) +#endif +#ifndef CC_FieldUpgradeStart +# define CC_FieldUpgradeStart NO +#endif +#if CC_FieldUpgradeStart == YES +#define TPM_CC_FieldUpgradeStart (TPM_CC)(0x0000012f) +#endif +#ifndef CC_ClockRateAdjust +# define CC_ClockRateAdjust NO +#endif +#if CC_ClockRateAdjust == YES +#define TPM_CC_ClockRateAdjust (TPM_CC)(0x00000130) +#endif +#ifndef CC_CreatePrimary +# define CC_CreatePrimary NO +#endif +#if CC_CreatePrimary == YES +#define TPM_CC_CreatePrimary (TPM_CC)(0x00000131) +#endif +#ifndef CC_NV_GlobalWriteLock +# define CC_NV_GlobalWriteLock NO +#endif +#if CC_NV_GlobalWriteLock == YES +#define TPM_CC_NV_GlobalWriteLock (TPM_CC)(0x00000132) +#endif +#ifndef CC_GetCommandAuditDigest +# define CC_GetCommandAuditDigest NO +#endif +#if CC_GetCommandAuditDigest == YES +#define TPM_CC_GetCommandAuditDigest (TPM_CC)(0x00000133) +#endif +#ifndef CC_NV_Increment +# define CC_NV_Increment NO +#endif +#if CC_NV_Increment == YES +#define TPM_CC_NV_Increment (TPM_CC)(0x00000134) +#endif +#ifndef CC_NV_SetBits +# define CC_NV_SetBits NO +#endif +#if CC_NV_SetBits == YES +#define TPM_CC_NV_SetBits (TPM_CC)(0x00000135) +#endif +#ifndef CC_NV_Extend +# define CC_NV_Extend NO +#endif +#if CC_NV_Extend == YES +#define TPM_CC_NV_Extend (TPM_CC)(0x00000136) +#endif +#ifndef CC_NV_Write +# define CC_NV_Write NO +#endif +#if CC_NV_Write == YES +#define TPM_CC_NV_Write (TPM_CC)(0x00000137) +#endif +#ifndef CC_NV_WriteLock +# define CC_NV_WriteLock NO +#endif +#if CC_NV_WriteLock == YES +#define TPM_CC_NV_WriteLock (TPM_CC)(0x00000138) +#endif +#ifndef CC_DictionaryAttackLockReset +# define CC_DictionaryAttackLockReset NO +#endif +#if CC_DictionaryAttackLockReset == YES +#define TPM_CC_DictionaryAttackLockReset (TPM_CC)(0x00000139) +#endif +#ifndef CC_DictionaryAttackParameters +# define CC_DictionaryAttackParameters NO +#endif +#if CC_DictionaryAttackParameters == YES +#define TPM_CC_DictionaryAttackParameters (TPM_CC)(0x0000013a) +#endif +#ifndef CC_NV_ChangeAuth +# define CC_NV_ChangeAuth NO +#endif +#if CC_NV_ChangeAuth == YES +#define TPM_CC_NV_ChangeAuth (TPM_CC)(0x0000013b) +#endif +#ifndef CC_PCR_Event +# define CC_PCR_Event NO +#endif +#if CC_PCR_Event == YES +#define TPM_CC_PCR_Event (TPM_CC)(0x0000013c) +#endif +#ifndef CC_PCR_Reset +# define CC_PCR_Reset NO +#endif +#if CC_PCR_Reset == YES +#define TPM_CC_PCR_Reset (TPM_CC)(0x0000013d) +#endif +#ifndef CC_SequenceComplete +# define CC_SequenceComplete NO +#endif +#if CC_SequenceComplete == YES +#define TPM_CC_SequenceComplete (TPM_CC)(0x0000013e) +#endif +#ifndef CC_SetAlgorithmSet +# define CC_SetAlgorithmSet NO +#endif +#if CC_SetAlgorithmSet == YES +#define TPM_CC_SetAlgorithmSet (TPM_CC)(0x0000013f) +#endif +#ifndef CC_SetCommandCodeAuditStatus +# define CC_SetCommandCodeAuditStatus NO +#endif +#if CC_SetCommandCodeAuditStatus == YES +#define TPM_CC_SetCommandCodeAuditStatus (TPM_CC)(0x00000140) +#endif +#ifndef CC_FieldUpgradeData +# define CC_FieldUpgradeData NO +#endif +#if CC_FieldUpgradeData == YES +#define TPM_CC_FieldUpgradeData (TPM_CC)(0x00000141) +#endif +#ifndef CC_IncrementalSelfTest +# define CC_IncrementalSelfTest NO +#endif +#if CC_IncrementalSelfTest == YES +#define TPM_CC_IncrementalSelfTest (TPM_CC)(0x00000142) +#endif +#ifndef CC_SelfTest +# define CC_SelfTest NO +#endif +#if CC_SelfTest == YES +#define TPM_CC_SelfTest (TPM_CC)(0x00000143) +#endif +#ifndef CC_Startup +# define CC_Startup NO +#endif +#if CC_Startup == YES +#define TPM_CC_Startup (TPM_CC)(0x00000144) +#endif +#ifndef CC_Shutdown +# define CC_Shutdown NO +#endif +#if CC_Shutdown == YES +#define TPM_CC_Shutdown (TPM_CC)(0x00000145) +#endif +#ifndef CC_StirRandom +# define CC_StirRandom NO +#endif +#if CC_StirRandom == YES +#define TPM_CC_StirRandom (TPM_CC)(0x00000146) +#endif +#ifndef CC_ActivateCredential +# define CC_ActivateCredential NO +#endif +#if CC_ActivateCredential == YES +#define TPM_CC_ActivateCredential (TPM_CC)(0x00000147) +#endif +#ifndef CC_Certify +# define CC_Certify NO +#endif +#if CC_Certify == YES +#define TPM_CC_Certify (TPM_CC)(0x00000148) +#endif +#ifndef CC_PolicyNV +# define CC_PolicyNV NO +#endif +#if CC_PolicyNV == YES +#define TPM_CC_PolicyNV (TPM_CC)(0x00000149) +#endif +#ifndef CC_CertifyCreation +# define CC_CertifyCreation NO +#endif +#if CC_CertifyCreation == YES +#define TPM_CC_CertifyCreation (TPM_CC)(0x0000014a) +#endif +#ifndef CC_Duplicate +# define CC_Duplicate NO +#endif +#if CC_Duplicate == YES +#define TPM_CC_Duplicate (TPM_CC)(0x0000014b) +#endif +#ifndef CC_GetTime +# define CC_GetTime NO +#endif +#if CC_GetTime == YES +#define TPM_CC_GetTime (TPM_CC)(0x0000014c) +#endif +#ifndef CC_GetSessionAuditDigest +# define CC_GetSessionAuditDigest NO +#endif +#if CC_GetSessionAuditDigest == YES +#define TPM_CC_GetSessionAuditDigest (TPM_CC)(0x0000014d) +#endif +#ifndef CC_NV_Read +# define CC_NV_Read NO +#endif +#if CC_NV_Read == YES +#define TPM_CC_NV_Read (TPM_CC)(0x0000014e) +#endif +#ifndef CC_NV_ReadLock +# define CC_NV_ReadLock NO +#endif +#if CC_NV_ReadLock == YES +#define TPM_CC_NV_ReadLock (TPM_CC)(0x0000014f) +#endif +#ifndef CC_ObjectChangeAuth +# define CC_ObjectChangeAuth NO +#endif +#if CC_ObjectChangeAuth == YES +#define TPM_CC_ObjectChangeAuth (TPM_CC)(0x00000150) +#endif +#ifndef CC_PolicySecret +# define CC_PolicySecret NO +#endif +#if CC_PolicySecret == YES +#define TPM_CC_PolicySecret (TPM_CC)(0x00000151) +#endif +#ifndef CC_Rewrap +# define CC_Rewrap NO +#endif +#if CC_Rewrap == YES +#define TPM_CC_Rewrap (TPM_CC)(0x00000152) +#endif +#ifndef CC_Create +# define CC_Create NO +#endif +#if CC_Create == YES +#define TPM_CC_Create (TPM_CC)(0x00000153) +#endif +#ifndef CC_ECDH_ZGen +# define CC_ECDH_ZGen NO +#endif +#if CC_ECDH_ZGen == YES +#define TPM_CC_ECDH_ZGen (TPM_CC)(0x00000154) +#endif +#ifndef CC_HMAC +# define CC_HMAC NO +#endif +#if CC_HMAC == YES +#define TPM_CC_HMAC (TPM_CC)(0x00000155) +#endif +#ifndef CC_Import +# define CC_Import NO +#endif +#if CC_Import == YES +#define TPM_CC_Import (TPM_CC)(0x00000156) +#endif +#ifndef CC_Load +# define CC_Load NO +#endif +#if CC_Load == YES +#define TPM_CC_Load (TPM_CC)(0x00000157) +#endif +#ifndef CC_Quote +# define CC_Quote NO +#endif +#if CC_Quote == YES +#define TPM_CC_Quote (TPM_CC)(0x00000158) +#endif +#ifndef CC_RSA_Decrypt +# define CC_RSA_Decrypt NO +#endif +#if CC_RSA_Decrypt == YES +#define TPM_CC_RSA_Decrypt (TPM_CC)(0x00000159) +#endif +#ifndef CC_HMAC_Start +# define CC_HMAC_Start NO +#endif +#if CC_HMAC_Start == YES +#define TPM_CC_HMAC_Start (TPM_CC)(0x0000015b) +#endif +#ifndef CC_SequenceUpdate +# define CC_SequenceUpdate NO +#endif +#if CC_SequenceUpdate == YES +#define TPM_CC_SequenceUpdate (TPM_CC)(0x0000015c) +#endif +#ifndef CC_Sign +# define CC_Sign NO +#endif +#if CC_Sign == YES +#define TPM_CC_Sign (TPM_CC)(0x0000015d) +#endif +#ifndef CC_Unseal +# define CC_Unseal NO +#endif +#if CC_Unseal == YES +#define TPM_CC_Unseal (TPM_CC)(0x0000015e) +#endif +#ifndef CC_PolicySigned +# define CC_PolicySigned NO +#endif +#if CC_PolicySigned == YES +#define TPM_CC_PolicySigned (TPM_CC)(0x00000160) +#endif +#ifndef CC_ContextLoad +# define CC_ContextLoad NO +#endif +#if CC_ContextLoad == YES +#define TPM_CC_ContextLoad (TPM_CC)(0x00000161) +#endif +#ifndef CC_ContextSave +# define CC_ContextSave NO +#endif +#if CC_ContextSave == YES +#define TPM_CC_ContextSave (TPM_CC)(0x00000162) +#endif +#ifndef CC_ECDH_KeyGen +# define CC_ECDH_KeyGen NO +#endif +#if CC_ECDH_KeyGen == YES +#define TPM_CC_ECDH_KeyGen (TPM_CC)(0x00000163) +#endif +#ifndef CC_EncryptDecrypt +# define CC_EncryptDecrypt NO +#endif +#if CC_EncryptDecrypt == YES +#define TPM_CC_EncryptDecrypt (TPM_CC)(0x00000164) +#endif +#ifndef CC_FlushContext +# define CC_FlushContext NO +#endif +#if CC_FlushContext == YES +#define TPM_CC_FlushContext (TPM_CC)(0x00000165) +#endif +#ifndef CC_LoadExternal +# define CC_LoadExternal NO +#endif +#if CC_LoadExternal == YES +#define TPM_CC_LoadExternal (TPM_CC)(0x00000167) +#endif +#ifndef CC_MakeCredential +# define CC_MakeCredential NO +#endif +#if CC_MakeCredential == YES +#define TPM_CC_MakeCredential (TPM_CC)(0x00000168) +#endif +#ifndef CC_NV_ReadPublic +# define CC_NV_ReadPublic NO +#endif +#if CC_NV_ReadPublic == YES +#define TPM_CC_NV_ReadPublic (TPM_CC)(0x00000169) +#endif +#ifndef CC_PolicyAuthorize +# define CC_PolicyAuthorize NO +#endif +#if CC_PolicyAuthorize == YES +#define TPM_CC_PolicyAuthorize (TPM_CC)(0x0000016a) +#endif +#ifndef CC_PolicyAuthValue +# define CC_PolicyAuthValue NO +#endif +#if CC_PolicyAuthValue == YES +#define TPM_CC_PolicyAuthValue (TPM_CC)(0x0000016b) +#endif +#ifndef CC_PolicyCommandCode +# define CC_PolicyCommandCode NO +#endif +#if CC_PolicyCommandCode == YES +#define TPM_CC_PolicyCommandCode (TPM_CC)(0x0000016c) +#endif +#ifndef CC_PolicyCounterTimer +# define CC_PolicyCounterTimer NO +#endif +#if CC_PolicyCounterTimer == YES +#define TPM_CC_PolicyCounterTimer (TPM_CC)(0x0000016d) +#endif +#ifndef CC_PolicyCpHash +# define CC_PolicyCpHash NO +#endif +#if CC_PolicyCpHash == YES +#define TPM_CC_PolicyCpHash (TPM_CC)(0x0000016e) +#endif +#ifndef CC_PolicyLocality +# define CC_PolicyLocality NO +#endif +#if CC_PolicyLocality == YES +#define TPM_CC_PolicyLocality (TPM_CC)(0x0000016f) +#endif +#ifndef CC_PolicyNameHash +# define CC_PolicyNameHash NO +#endif +#if CC_PolicyNameHash == YES +#define TPM_CC_PolicyNameHash (TPM_CC)(0x00000170) +#endif +#ifndef CC_PolicyOR +# define CC_PolicyOR NO +#endif +#if CC_PolicyOR == YES +#define TPM_CC_PolicyOR (TPM_CC)(0x00000171) +#endif +#ifndef CC_PolicyTicket +# define CC_PolicyTicket NO +#endif +#if CC_PolicyTicket == YES +#define TPM_CC_PolicyTicket (TPM_CC)(0x00000172) +#endif +#ifndef CC_ReadPublic +# define CC_ReadPublic NO +#endif +#if CC_ReadPublic == YES +#define TPM_CC_ReadPublic (TPM_CC)(0x00000173) +#endif +#ifndef CC_RSA_Encrypt +# define CC_RSA_Encrypt NO +#endif +#if CC_RSA_Encrypt == YES +#define TPM_CC_RSA_Encrypt (TPM_CC)(0x00000174) +#endif +#ifndef CC_StartAuthSession +# define CC_StartAuthSession NO +#endif +#if CC_StartAuthSession == YES +#define TPM_CC_StartAuthSession (TPM_CC)(0x00000176) +#endif +#ifndef CC_VerifySignature +# define CC_VerifySignature NO +#endif +#if CC_VerifySignature == YES +#define TPM_CC_VerifySignature (TPM_CC)(0x00000177) +#endif +#ifndef CC_ECC_Parameters +# define CC_ECC_Parameters NO +#endif +#if CC_ECC_Parameters == YES +#define TPM_CC_ECC_Parameters (TPM_CC)(0x00000178) +#endif +#ifndef CC_FirmwareRead +# define CC_FirmwareRead NO +#endif +#if CC_FirmwareRead == YES +#define TPM_CC_FirmwareRead (TPM_CC)(0x00000179) +#endif +#ifndef CC_GetCapability +# define CC_GetCapability NO +#endif +#if CC_GetCapability == YES +#define TPM_CC_GetCapability (TPM_CC)(0x0000017a) +#endif +#ifndef CC_GetRandom +# define CC_GetRandom NO +#endif +#if CC_GetRandom == YES +#define TPM_CC_GetRandom (TPM_CC)(0x0000017b) +#endif +#ifndef CC_GetTestResult +# define CC_GetTestResult NO +#endif +#if CC_GetTestResult == YES +#define TPM_CC_GetTestResult (TPM_CC)(0x0000017c) +#endif +#ifndef CC_Hash +# define CC_Hash NO +#endif +#if CC_Hash == YES +#define TPM_CC_Hash (TPM_CC)(0x0000017d) +#endif +#ifndef CC_PCR_Read +# define CC_PCR_Read NO +#endif +#if CC_PCR_Read == YES +#define TPM_CC_PCR_Read (TPM_CC)(0x0000017e) +#endif +#ifndef CC_PolicyPCR +# define CC_PolicyPCR NO +#endif +#if CC_PolicyPCR == YES +#define TPM_CC_PolicyPCR (TPM_CC)(0x0000017f) +#endif +#ifndef CC_PolicyRestart +# define CC_PolicyRestart NO +#endif +#if CC_PolicyRestart == YES +#define TPM_CC_PolicyRestart (TPM_CC)(0x00000180) +#endif +#ifndef CC_ReadClock +# define CC_ReadClock NO +#endif +#if CC_ReadClock == YES +#define TPM_CC_ReadClock (TPM_CC)(0x00000181) +#endif +#ifndef CC_PCR_Extend +# define CC_PCR_Extend NO +#endif +#if CC_PCR_Extend == YES +#define TPM_CC_PCR_Extend (TPM_CC)(0x00000182) +#endif +#ifndef CC_PCR_SetAuthValue +# define CC_PCR_SetAuthValue NO +#endif +#if CC_PCR_SetAuthValue == YES +#define TPM_CC_PCR_SetAuthValue (TPM_CC)(0x00000183) +#endif +#ifndef CC_NV_Certify +# define CC_NV_Certify NO +#endif +#if CC_NV_Certify == YES +#define TPM_CC_NV_Certify (TPM_CC)(0x00000184) +#endif +#ifndef CC_EventSequenceComplete +# define CC_EventSequenceComplete NO +#endif +#if CC_EventSequenceComplete == YES +#define TPM_CC_EventSequenceComplete (TPM_CC)(0x00000185) +#endif +#ifndef CC_HashSequenceStart +# define CC_HashSequenceStart NO +#endif +#if CC_HashSequenceStart == YES +#define TPM_CC_HashSequenceStart (TPM_CC)(0x00000186) +#endif +#ifndef CC_PolicyPhysicalPresence +# define CC_PolicyPhysicalPresence NO +#endif +#if CC_PolicyPhysicalPresence == YES +#define TPM_CC_PolicyPhysicalPresence (TPM_CC)(0x00000187) +#endif +#ifndef CC_PolicyDuplicationSelect +# define CC_PolicyDuplicationSelect NO +#endif +#if CC_PolicyDuplicationSelect == YES +#define TPM_CC_PolicyDuplicationSelect (TPM_CC)(0x00000188) +#endif +#ifndef CC_PolicyGetDigest +# define CC_PolicyGetDigest NO +#endif +#if CC_PolicyGetDigest == YES +#define TPM_CC_PolicyGetDigest (TPM_CC)(0x00000189) +#endif +#ifndef CC_TestParms +# define CC_TestParms NO +#endif +#if CC_TestParms == YES +#define TPM_CC_TestParms (TPM_CC)(0x0000018a) +#endif +#ifndef CC_Commit +# define CC_Commit NO +#endif +#if CC_Commit == YES +#define TPM_CC_Commit (TPM_CC)(0x0000018b) +#endif +#ifndef CC_PolicyPassword +# define CC_PolicyPassword NO +#endif +#if CC_PolicyPassword == YES +#define TPM_CC_PolicyPassword (TPM_CC)(0x0000018c) +#endif +#ifndef CC_ZGen_2Phase +# define CC_ZGen_2Phase NO +#endif +#if CC_ZGen_2Phase == YES +#define TPM_CC_ZGen_2Phase (TPM_CC)(0x0000018d) +#endif +#ifndef CC_EC_Ephemeral +# define CC_EC_Ephemeral NO +#endif +#if CC_EC_Ephemeral == YES +#define TPM_CC_EC_Ephemeral (TPM_CC)(0x0000018e) +#endif +#ifndef CC_PolicyNvWritten +# define CC_PolicyNvWritten NO +#endif +#if CC_PolicyNvWritten == YES +#define TPM_CC_PolicyNvWritten (TPM_CC)(0x0000018f) +#endif +#ifndef CC_PolicyTemplate +# define CC_PolicyTemplate NO +#endif +#if CC_PolicyTemplate == YES +#define TPM_CC_PolicyTemplate (TPM_CC)(0x00000190) +#endif +#ifndef CC_CreateLoaded +# define CC_CreateLoaded NO +#endif +#if CC_CreateLoaded == YES +#define TPM_CC_CreateLoaded (TPM_CC)(0x00000191) +#endif +#ifndef CC_PolicyAuthorizeNV +# define CC_PolicyAuthorizeNV NO +#endif +#if CC_PolicyAuthorizeNV == YES +#define TPM_CC_PolicyAuthorizeNV (TPM_CC)(0x00000192) +#endif +#ifndef CC_EncryptDecrypt2 +# define CC_EncryptDecrypt2 NO +#endif +#if CC_EncryptDecrypt2 == YES +#define TPM_CC_EncryptDecrypt2 (TPM_CC)(0x00000193) +#endif + +#define TPM_CC_AC_GetCapability (TPM_CC)(0x00000194) +#define TPM_CC_AC_Send (TPM_CC)(0x00000195) +#define TPM_CC_Policy_AC_SendSelect (TPM_CC)(0x00000196) + +/* Compile variable. May increase based on implementation. */ +#define TPM_CC_LAST (TPM_CC)(0x00000196) + +#ifndef CC_Vendor_TCG_Test +# define CC_Vendor_TCG_Test NO +#endif +#if CC_Vendor_TCG_Test == YES +#define TPM_CC_Vendor_TCG_Test (TPM_CC)(0x20000000) +#endif + +#ifndef CC_NTC2_PreConfig +# define CC_NTC2_PreConfig NO +#endif +#if CC_NTC2_PreConfig == YES +#define NTC2_CC_PreConfig (TPM_CC)(0x20000211) +#endif +#ifndef CC_NTC2_LockPreConfig +# define CC_NTC2_LockPreConfig NO +#endif +#if CC_NTC2_LockPreConfig == YES +#define NTC2_CC_LockPreConfig (TPM_CC)(0x20000212) +#endif +#ifndef CC_NTC2_GetConfig +# define CC_NTC2_GetConfig NO +#endif +#if CC_NTC2_GetConfig == YES +#define NTC2_CC_GetConfig (TPM_CC)(0x20000213) +#endif + +#ifndef COMPRESSED_LISTS +#define ADD_FILL 1 +#else +#define ADD_FILL 0 +#endif + +// Size the array of library commands based on whether or not the array is packed (only defined +// commands) or dense (having entries for unimplemented commands) + +#define LIBRARY_COMMAND_ARRAY_SIZE (0 \ + + (ADD_FILL || CC_NV_UndefineSpaceSpecial) /* 0x0000011f */ \ + + (ADD_FILL || CC_EvictControl) /* 0x00000120 */ \ + + (ADD_FILL || CC_HierarchyControl) /* 0x00000121 */ \ + + (ADD_FILL || CC_NV_UndefineSpace) /* 0x00000122 */ \ + + ADD_FILL /* 0x00000123 */ \ + + (ADD_FILL || CC_ChangeEPS) /* 0x00000124 */ \ + + (ADD_FILL || CC_ChangePPS) /* 0x00000125 */ \ + + (ADD_FILL || CC_Clear) /* 0x00000126 */ \ + + (ADD_FILL || CC_ClearControl) /* 0x00000127 */ \ + + (ADD_FILL || CC_ClockSet) /* 0x00000128 */ \ + + (ADD_FILL || CC_HierarchyChangeAuth) /* 0x00000129 */ \ + + (ADD_FILL || CC_NV_DefineSpace) /* 0x0000012a */ \ + + (ADD_FILL || CC_PCR_Allocate) /* 0x0000012b */ \ + + (ADD_FILL || CC_PCR_SetAuthPolicy) /* 0x0000012c */ \ + + (ADD_FILL || CC_PP_Commands) /* 0x0000012d */ \ + + (ADD_FILL || CC_SetPrimaryPolicy) /* 0x0000012e */ \ + + (ADD_FILL || CC_FieldUpgradeStart) /* 0x0000012f */ \ + + (ADD_FILL || CC_ClockRateAdjust) /* 0x00000130 */ \ + + (ADD_FILL || CC_CreatePrimary) /* 0x00000131 */ \ + + (ADD_FILL || CC_NV_GlobalWriteLock) /* 0x00000132 */ \ + + (ADD_FILL || CC_GetCommandAuditDigest) /* 0x00000133 */ \ + + (ADD_FILL || CC_NV_Increment) /* 0x00000134 */ \ + + (ADD_FILL || CC_NV_SetBits) /* 0x00000135 */ \ + + (ADD_FILL || CC_NV_Extend) /* 0x00000136 */ \ + + (ADD_FILL || CC_NV_Write) /* 0x00000137 */ \ + + (ADD_FILL || CC_NV_WriteLock) /* 0x00000138 */ \ + + (ADD_FILL || CC_DictionaryAttackLockReset) /* 0x00000139 */ \ + + (ADD_FILL || CC_DictionaryAttackParameters) /* 0x0000013a */ \ + + (ADD_FILL || CC_NV_ChangeAuth) /* 0x0000013b */ \ + + (ADD_FILL || CC_PCR_Event) /* 0x0000013c */ \ + + (ADD_FILL || CC_PCR_Reset) /* 0x0000013d */ \ + + (ADD_FILL || CC_SequenceComplete) /* 0x0000013e */ \ + + (ADD_FILL || CC_SetAlgorithmSet) /* 0x0000013f */ \ + + (ADD_FILL || CC_SetCommandCodeAuditStatus) /* 0x00000140 */ \ + + (ADD_FILL || CC_FieldUpgradeData) /* 0x00000141 */ \ + + (ADD_FILL || CC_IncrementalSelfTest) /* 0x00000142 */ \ + + (ADD_FILL || CC_SelfTest) /* 0x00000143 */ \ + + (ADD_FILL || CC_Startup) /* 0x00000144 */ \ + + (ADD_FILL || CC_Shutdown) /* 0x00000145 */ \ + + (ADD_FILL || CC_StirRandom) /* 0x00000146 */ \ + + (ADD_FILL || CC_ActivateCredential) /* 0x00000147 */ \ + + (ADD_FILL || CC_Certify) /* 0x00000148 */ \ + + (ADD_FILL || CC_PolicyNV) /* 0x00000149 */ \ + + (ADD_FILL || CC_CertifyCreation) /* 0x0000014a */ \ + + (ADD_FILL || CC_Duplicate) /* 0x0000014b */ \ + + (ADD_FILL || CC_GetTime) /* 0x0000014c */ \ + + (ADD_FILL || CC_GetSessionAuditDigest) /* 0x0000014d */ \ + + (ADD_FILL || CC_NV_Read) /* 0x0000014e */ \ + + (ADD_FILL || CC_NV_ReadLock) /* 0x0000014f */ \ + + (ADD_FILL || CC_ObjectChangeAuth) /* 0x00000150 */ \ + + (ADD_FILL || CC_PolicySecret) /* 0x00000151 */ \ + + (ADD_FILL || CC_Rewrap) /* 0x00000152 */ \ + + (ADD_FILL || CC_Create) /* 0x00000153 */ \ + + (ADD_FILL || CC_ECDH_ZGen) /* 0x00000154 */ \ + + (ADD_FILL || CC_HMAC) /* 0x00000155 */ \ + + (ADD_FILL || CC_Import) /* 0x00000156 */ \ + + (ADD_FILL || CC_Load) /* 0x00000157 */ \ + + (ADD_FILL || CC_Quote) /* 0x00000158 */ \ + + (ADD_FILL || CC_RSA_Decrypt) /* 0x00000159 */ \ + + ADD_FILL /* 0x0000015a */ \ + + (ADD_FILL || CC_HMAC_Start) /* 0x0000015b */ \ + + (ADD_FILL || CC_SequenceUpdate) /* 0x0000015c */ \ + + (ADD_FILL || CC_Sign) /* 0x0000015d */ \ + + (ADD_FILL || CC_Unseal) /* 0x0000015e */ \ + + ADD_FILL /* 0x0000015f */ \ + + (ADD_FILL || CC_PolicySigned) /* 0x00000160 */ \ + + (ADD_FILL || CC_ContextLoad) /* 0x00000161 */ \ + + (ADD_FILL || CC_ContextSave) /* 0x00000162 */ \ + + (ADD_FILL || CC_ECDH_KeyGen) /* 0x00000163 */ \ + + (ADD_FILL || CC_EncryptDecrypt) /* 0x00000164 */ \ + + (ADD_FILL || CC_FlushContext) /* 0x00000165 */ \ + + ADD_FILL /* 0x00000166 */ \ + + (ADD_FILL || CC_LoadExternal) /* 0x00000167 */ \ + + (ADD_FILL || CC_MakeCredential) /* 0x00000168 */ \ + + (ADD_FILL || CC_NV_ReadPublic) /* 0x00000169 */ \ + + (ADD_FILL || CC_PolicyAuthorize) /* 0x0000016a */ \ + + (ADD_FILL || CC_PolicyAuthValue) /* 0x0000016b */ \ + + (ADD_FILL || CC_PolicyCommandCode) /* 0x0000016c */ \ + + (ADD_FILL || CC_PolicyCounterTimer) /* 0x0000016d */ \ + + (ADD_FILL || CC_PolicyCpHash) /* 0x0000016e */ \ + + (ADD_FILL || CC_PolicyLocality) /* 0x0000016f */ \ + + (ADD_FILL || CC_PolicyNameHash) /* 0x00000170 */ \ + + (ADD_FILL || CC_PolicyOR) /* 0x00000171 */ \ + + (ADD_FILL || CC_PolicyTicket) /* 0x00000172 */ \ + + (ADD_FILL || CC_ReadPublic) /* 0x00000173 */ \ + + (ADD_FILL || CC_RSA_Encrypt) /* 0x00000174 */ \ + + ADD_FILL /* 0x00000175 */ \ + + (ADD_FILL || CC_StartAuthSession) /* 0x00000176 */ \ + + (ADD_FILL || CC_VerifySignature) /* 0x00000177 */ \ + + (ADD_FILL || CC_ECC_Parameters) /* 0x00000178 */ \ + + (ADD_FILL || CC_FirmwareRead) /* 0x00000179 */ \ + + (ADD_FILL || CC_GetCapability) /* 0x0000017a */ \ + + (ADD_FILL || CC_GetRandom) /* 0x0000017b */ \ + + (ADD_FILL || CC_GetTestResult) /* 0x0000017c */ \ + + (ADD_FILL || CC_Hash) /* 0x0000017d */ \ + + (ADD_FILL || CC_PCR_Read) /* 0x0000017e */ \ + + (ADD_FILL || CC_PolicyPCR) /* 0x0000017f */ \ + + (ADD_FILL || CC_PolicyRestart) /* 0x00000180 */ \ + + (ADD_FILL || CC_ReadClock) /* 0x00000181 */ \ + + (ADD_FILL || CC_PCR_Extend) /* 0x00000182 */ \ + + (ADD_FILL || CC_PCR_SetAuthValue) /* 0x00000183 */ \ + + (ADD_FILL || CC_NV_Certify) /* 0x00000184 */ \ + + (ADD_FILL || CC_EventSequenceComplete) /* 0x00000185 */ \ + + (ADD_FILL || CC_HashSequenceStart) /* 0x00000186 */ \ + + (ADD_FILL || CC_PolicyPhysicalPresence) /* 0x00000187 */ \ + + (ADD_FILL || CC_PolicyDuplicationSelect) /* 0x00000188 */ \ + + (ADD_FILL || CC_PolicyGetDigest) /* 0x00000189 */ \ + + (ADD_FILL || CC_TestParms) /* 0x0000018a */ \ + + (ADD_FILL || CC_Commit) /* 0x0000018b */ \ + + (ADD_FILL || CC_PolicyPassword) /* 0x0000018c */ \ + + (ADD_FILL || CC_ZGen_2Phase) /* 0x0000018d */ \ + + (ADD_FILL || CC_EC_Ephemeral) /* 0x0000018e */ \ + + (ADD_FILL || CC_PolicyTemplate) /* 0x00000190 */ \ + + (ADD_FILL || CC_CreateLoaded) /* 0x00000191 */ \ + + (ADD_FILL || CC_PolicyAuthorizeNV) /* 0x00000192 */ \ + + (ADD_FILL || CC_EncryptDecrypt2) /* 0x00000193 */ \ + + (ADD_FILL || CC_PolicyNvWritten) /* 0x0000018f */ \ + ) + +#define VENDOR_COMMAND_ARRAY_SIZE ( 0 \ + + CC_Vendor_TCG_Test \ + + CC_NTC2_PreConfig \ + + CC_NTC2_LockPreConfig \ + + CC_NTC2_GetConfig \ + ) + +#define COMMAND_COUNT \ + (LIBRARY_COMMAND_ARRAY_SIZE + VENDOR_COMMAND_ARRAY_SIZE) + +// Following typedef is for some old code + +#ifndef ALG_CAMELLIA +# define ALG_CAMELLIA NO +#endif + +#ifndef ALG_SM4 +# define ALG_SM4 NO +#endif + +#ifndef ALG_AES +# define ALG_AES NO +#endif + +#endif // _IMPLEMENTATION_H_ diff --git a/libstb/tss2/ibmtss/Import_fp.h b/libstb/tss2/ibmtss/Import_fp.h new file mode 100644 index 0000000..ac46b0b --- /dev/null +++ b/libstb/tss2/ibmtss/Import_fp.h @@ -0,0 +1,93 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: Import_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef IMPORT_FP_H +#define IMPORT_FP_H + +typedef struct { + TPMI_DH_OBJECT parentHandle; + TPM2B_DATA encryptionKey; + TPM2B_PUBLIC objectPublic; + TPM2B_PRIVATE duplicate; + TPM2B_ENCRYPTED_SECRET inSymSeed; + TPMT_SYM_DEF_OBJECT symmetricAlg; +} Import_In; + +#define RC_Import_parentHandle (TPM_RC_H + TPM_RC_1) +#define RC_Import_encryptionKey (TPM_RC_P + TPM_RC_1) +#define RC_Import_objectPublic (TPM_RC_P + TPM_RC_2) +#define RC_Import_duplicate (TPM_RC_P + TPM_RC_3) +#define RC_Import_inSymSeed (TPM_RC_P + TPM_RC_4) +#define RC_Import_symmetricAlg (TPM_RC_P + TPM_RC_5) + +typedef struct { + TPM2B_PRIVATE outPrivate; +} Import_Out; + +TPM_RC +TPM2_Import( + Import_In *in, // IN: input parameter list + Import_Out *out // OUT: output parameter list + ); + +#endif diff --git a/libstb/tss2/ibmtss/IncrementalSelfTest_fp.h b/libstb/tss2/ibmtss/IncrementalSelfTest_fp.h new file mode 100644 index 0000000..a896973 --- /dev/null +++ b/libstb/tss2/ibmtss/IncrementalSelfTest_fp.h @@ -0,0 +1,84 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: IncrementalSelfTest_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef INCREMENTALSELFTEST_FP_H +#define INCREMENTALSELFTEST_FP_H + +typedef struct{ + TPML_ALG toTest; +} IncrementalSelfTest_In; + +typedef struct{ + TPML_ALG toDoList; +} IncrementalSelfTest_Out; + +#define RC_IncrementalSelfTest_toTest (TPM_RC_P + TPM_RC_1) + +TPM_RC +TPM2_IncrementalSelfTest( + IncrementalSelfTest_In *in, // IN: input parameter list + IncrementalSelfTest_Out *out // OUT: output parameter list + ); + + +#endif diff --git a/libstb/tss2/ibmtss/LoadExternal_fp.h b/libstb/tss2/ibmtss/LoadExternal_fp.h new file mode 100644 index 0000000..ba31b85 --- /dev/null +++ b/libstb/tss2/ibmtss/LoadExternal_fp.h @@ -0,0 +1,87 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: LoadExternal_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef LOADEXTERNAL_FP_H +#define LOADEXTERNAL_FP_H + +typedef struct { + TPM2B_SENSITIVE inPrivate; + TPM2B_PUBLIC inPublic; + TPMI_RH_HIERARCHY hierarchy; +} LoadExternal_In; + +#define RC_LoadExternal_inPrivate (TPM_RC_P + TPM_RC_1) +#define RC_LoadExternal_inPublic (TPM_RC_P + TPM_RC_2) +#define RC_LoadExternal_hierarchy (TPM_RC_P + TPM_RC_3) + +typedef struct { + TPM_HANDLE objectHandle; + TPM2B_NAME name; +} LoadExternal_Out; + +TPM_RC +TPM2_LoadExternal( + LoadExternal_In *in, // IN: input parameter list + LoadExternal_Out *out // OUT: output parameter list + ); +#endif diff --git a/libstb/tss2/ibmtss/LoadKey2_fp.h b/libstb/tss2/ibmtss/LoadKey2_fp.h new file mode 100644 index 0000000..b850ee8 --- /dev/null +++ b/libstb/tss2/ibmtss/LoadKey2_fp.h @@ -0,0 +1,66 @@ +/********************************************************************************/ +/* */ +/* TPM 1.2 Load Key 2 */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: LoadKey2_fp.h 1257 2018-06-27 20:52:08Z kgoldman $ */ +/* */ +/* (c) Copyright IBM Corporation 2018. */ +/* */ +/* All rights reserved. */ +/* */ +/* Redistribution and use in source and binary forms, with or without */ +/* modification, are permitted provided that the following conditions are */ +/* met: */ +/* */ +/* Redistributions of source code must retain the above copyright notice, */ +/* this list of conditions and the following disclaimer. */ +/* */ +/* 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. */ +/* */ +/* Neither the names of the IBM Corporation nor the names of its */ +/* contributors may be used to endorse or promote products derived from */ +/* this software without specific prior written permission. */ +/* */ +/* 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 LOADKEY2_FP_H +#define LOADKEY2_FP_H + +#include <ibmtss/tpmtypes12.h> +#include <ibmtss/tpmstructures12.h> + +#include <ibmtss/Implementation.h> + +typedef struct { + TPM_KEY_HANDLE parentHandle; + TPM_KEY12 inKey; +} LoadKey2_In; + +#define RC_LoadKey2_parentHandle (TPM_RC_H + TPM_RC_1) +#define RC_LoadKey2_inKey (TPM_RC_P + TPM_RC_1) + +typedef struct { + TPM_KEY_HANDLE inkeyHandle; +} LoadKey2_Out; + +TPM_RC +TPM2_Loadkey2( + LoadKey2_In *in, // IN: input parameter buffer + LoadKey2_Out *out // OUT: output parameter buffer + ); + +#endif diff --git a/libstb/tss2/ibmtss/Load_fp.h b/libstb/tss2/ibmtss/Load_fp.h new file mode 100644 index 0000000..20a7232 --- /dev/null +++ b/libstb/tss2/ibmtss/Load_fp.h @@ -0,0 +1,88 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: Load_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef LOAD_FP_H +#define LOAD_FP_H + +typedef struct { + TPMI_DH_OBJECT parentHandle; + TPM2B_PRIVATE inPrivate; + TPM2B_PUBLIC inPublic; +} Load_In; + +#define RC_Load_parentHandle (TPM_RC_H + TPM_RC_1) +#define RC_Load_inPrivate (TPM_RC_P + TPM_RC_1) +#define RC_Load_inPublic (TPM_RC_P + TPM_RC_2) + +typedef struct { + TPM_HANDLE objectHandle; + TPM2B_NAME name; +} Load_Out; + +TPM_RC +TPM2_Load( + Load_In *in, // IN: input parameter list + Load_Out *out // OUT: output parameter list + ); + +#endif diff --git a/libstb/tss2/ibmtss/MakeCredential_fp.h b/libstb/tss2/ibmtss/MakeCredential_fp.h new file mode 100644 index 0000000..d6e5fb3 --- /dev/null +++ b/libstb/tss2/ibmtss/MakeCredential_fp.h @@ -0,0 +1,89 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: MakeCredential_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef MAKECREDENTIAL_FP_H +#define MAKECREDENTIAL_FP_H + +typedef struct { + TPMI_DH_OBJECT handle; + TPM2B_DIGEST credential; + TPM2B_NAME objectName; +} MakeCredential_In; + +#define RC_MakeCredential_handle (TPM_RC_H + TPM_RC_1) +#define RC_MakeCredential_credential (TPM_RC_P + TPM_RC_1) +#define RC_MakeCredential_objectName (TPM_RC_P + TPM_RC_2) + + +typedef struct { + TPM2B_ID_OBJECT credentialBlob; + TPM2B_ENCRYPTED_SECRET secret; +} MakeCredential_Out; + +TPM_RC +TPM2_MakeCredential( + MakeCredential_In *in, // IN: input parameter list + MakeCredential_Out *out // OUT: output parameter list + ); + +#endif diff --git a/libstb/tss2/ibmtss/MakeIdentity_fp.h b/libstb/tss2/ibmtss/MakeIdentity_fp.h new file mode 100644 index 0000000..a10fdeb --- /dev/null +++ b/libstb/tss2/ibmtss/MakeIdentity_fp.h @@ -0,0 +1,66 @@ +/********************************************************************************/ +/* */ +/* TPM 1.2 MakeIdentity */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: MakeIdentity_fp.h 1257 2018-06-27 20:52:08Z kgoldman $ */ +/* */ +/* (c) Copyright IBM Corporation 2018. */ +/* */ +/* All rights reserved. */ +/* */ +/* Redistribution and use in source and binary forms, with or without */ +/* modification, are permitted provided that the following conditions are */ +/* met: */ +/* */ +/* Redistributions of source code must retain the above copyright notice, */ +/* this list of conditions and the following disclaimer. */ +/* */ +/* 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. */ +/* */ +/* Neither the names of the IBM Corporation nor the names of its */ +/* contributors may be used to endorse or promote products derived from */ +/* this software without specific prior written permission. */ +/* */ +/* 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 MAKEIDENTITY_FP_H +#define MAKEIDENTITY_FP_H + +#include <ibmtss/tpmtypes12.h> +#include <ibmtss/tpmstructures12.h> + +#include <ibmtss/Implementation.h> + +typedef struct { + TPM_ENCAUTH identityAuth; + TPM_CHOSENID_HASH labelPrivCADigest; + TPM_KEY12 idKeyParams; +} MakeIdentity_In; + +typedef struct { + TPM_KEY12 idKey; + UINT32 identityBindingSize; + BYTE identityBinding[MAX_RSA_KEY_BYTES]; +} MakeIdentity_Out; + +TPM_RC +TPM2_MakeIdentity( + MakeIdentity_In *in, // IN: input parameter buffer + MakeIdentity_Out *out // OUT: output parameter buffer + ); + +#endif diff --git a/libstb/tss2/ibmtss/NTC_fp.h b/libstb/tss2/ibmtss/NTC_fp.h new file mode 100644 index 0000000..b68feb2 --- /dev/null +++ b/libstb/tss2/ibmtss/NTC_fp.h @@ -0,0 +1,52 @@ +/********************************************************************************/ +/* */ +/* Nuvoton Commands */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* */ +/* (c) Copyright IBM Corporation 2017 */ +/* */ +/* All rights reserved. */ +/* */ +/* Redistribution and use in source and binary forms, with or without */ +/* modification, are permitted provided that the following conditions are */ +/* met: */ +/* */ +/* Redistributions of source code must retain the above copyright notice, */ +/* this list of conditions and the following disclaimer. */ +/* */ +/* 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. */ +/* */ +/* Neither the names of the IBM Corporation nor the names of its */ +/* contributors may be used to endorse or promote products derived from */ +/* this software without specific prior written permission. */ +/* */ +/* 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 NTC_FP_H +#define NTC_FP_H + +typedef struct { + NTC2_CFG_STRUCT preConfig; +} NTC2_PreConfig_In; + +typedef struct { + NTC2_CFG_STRUCT preConfig; +} NTC2_GetConfig_Out; + +#define RC_NTC2_PreConfig_preConfig (TPM_RC_P + TPM_RC_1) + +#endif diff --git a/libstb/tss2/ibmtss/NV_Certify_fp.h b/libstb/tss2/ibmtss/NV_Certify_fp.h new file mode 100644 index 0000000..d5f2913 --- /dev/null +++ b/libstb/tss2/ibmtss/NV_Certify_fp.h @@ -0,0 +1,98 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: NV_Certify_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef NV_CERTIFY_FP_H +#define NV_CERTIFY_FP_H + +typedef struct { + TPMI_DH_OBJECT signHandle; + TPMI_RH_NV_AUTH authHandle; + TPMI_RH_NV_INDEX nvIndex; + TPM2B_DATA qualifyingData; + TPMT_SIG_SCHEME inScheme; + UINT16 size; + UINT16 offset; +} NV_Certify_In; + +#define RC_NV_Certify_signHandle (TPM_RC_H + TPM_RC_1) +#define RC_NV_Certify_authHandle (TPM_RC_H + TPM_RC_2) +#define RC_NV_Certify_nvIndex (TPM_RC_H + TPM_RC_3) +#define RC_NV_Certify_qualifyingData (TPM_RC_P + TPM_RC_1) +#define RC_NV_Certify_inScheme (TPM_RC_P + TPM_RC_2) +#define RC_NV_Certify_size (TPM_RC_P + TPM_RC_3) +#define RC_NV_Certify_offset (TPM_RC_P + TPM_RC_4) + + +typedef struct { + TPM2B_ATTEST certifyInfo; + TPMT_SIGNATURE signature; +} NV_Certify_Out; + +TPM_RC +TPM2_NV_Certify( + NV_Certify_In *in, // IN: input parameter list + NV_Certify_Out *out // OUT: output parameter list + ); + + +#endif diff --git a/libstb/tss2/ibmtss/NV_ChangeAuth_fp.h b/libstb/tss2/ibmtss/NV_ChangeAuth_fp.h new file mode 100644 index 0000000..ed211bb --- /dev/null +++ b/libstb/tss2/ibmtss/NV_ChangeAuth_fp.h @@ -0,0 +1,81 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: NV_ChangeAuth_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef NV_CHANGEAUTH_FP_H +#define NV_CHANGEAUTH_FP_H + +typedef struct { + TPMI_RH_NV_INDEX nvIndex; + TPM2B_AUTH newAuth; +} NV_ChangeAuth_In; + +#define RC_NV_ChangeAuth_nvIndex (TPM_RC_H + TPM_RC_1) +#define RC_NV_ChangeAuth_newAuth (TPM_RC_P + TPM_RC_1) + +TPM_RC +TPM2_NV_ChangeAuth( + NV_ChangeAuth_In *in // IN: input parameter list + ); + + +#endif diff --git a/libstb/tss2/ibmtss/NV_DefineSpace12_fp.h b/libstb/tss2/ibmtss/NV_DefineSpace12_fp.h new file mode 100644 index 0000000..8d6bc64 --- /dev/null +++ b/libstb/tss2/ibmtss/NV_DefineSpace12_fp.h @@ -0,0 +1,52 @@ +/********************************************************************************/ +/* */ +/* TPM 1.2 NV_DefineSpace */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* */ +/* (c) Copyright IBM Corporation 2018. */ +/* */ +/* All rights reserved. */ +/* */ +/* Redistribution and use in source and binary forms, with or without */ +/* modification, are permitted provided that the following conditions are */ +/* met: */ +/* */ +/* Redistributions of source code must retain the above copyright notice, */ +/* this list of conditions and the following disclaimer. */ +/* */ +/* 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. */ +/* */ +/* Neither the names of the IBM Corporation nor the names of its */ +/* contributors may be used to endorse or promote products derived from */ +/* this software without specific prior written permission. */ +/* */ +/* 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 NVDEFINESPACE12_FP_H +#define NVDEFINESPACE12_FP_H + +typedef struct { + TPM_NV_DATA_PUBLIC pubInfo; + TPM_ENCAUTH encAuth; +} NV_DefineSpace12_In; + +TPM_RC +TPM_NV_DefineSpace12( + NV_DefineSpace12_In *in // IN: input parameter list + ); + +#endif diff --git a/libstb/tss2/ibmtss/NV_DefineSpace_fp.h b/libstb/tss2/ibmtss/NV_DefineSpace_fp.h new file mode 100644 index 0000000..1769931 --- /dev/null +++ b/libstb/tss2/ibmtss/NV_DefineSpace_fp.h @@ -0,0 +1,83 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: NV_DefineSpace_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef NV_DEFINESPACE_FP_H +#define NV_DEFINESPACE_FP_H + +typedef struct { + TPMI_RH_PROVISION authHandle; + TPM2B_AUTH auth; + TPM2B_NV_PUBLIC publicInfo; +} NV_DefineSpace_In; + +#define RC_NV_DefineSpace_authHandle (TPM_RC_H + TPM_RC_1) +#define RC_NV_DefineSpace_auth (TPM_RC_P + TPM_RC_1) +#define RC_NV_DefineSpace_publicInfo (TPM_RC_P + TPM_RC_2) + +TPM_RC +TPM2_NV_DefineSpace( + NV_DefineSpace_In *in // IN: input parameter list + ); + + +#endif diff --git a/libstb/tss2/ibmtss/NV_Extend_fp.h b/libstb/tss2/ibmtss/NV_Extend_fp.h new file mode 100644 index 0000000..7fc9cf2 --- /dev/null +++ b/libstb/tss2/ibmtss/NV_Extend_fp.h @@ -0,0 +1,83 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: NV_Extend_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef NV_EXTEND_FP_H +#define NV_EXTEND_FP_H + +typedef struct { + TPMI_RH_NV_AUTH authHandle; + TPMI_RH_NV_INDEX nvIndex; + TPM2B_MAX_NV_BUFFER data; +} NV_Extend_In; + +#define RC_NV_Extend_authHandle (TPM_RC_H + TPM_RC_1) +#define RC_NV_Extend_nvIndex (TPM_RC_H + TPM_RC_2) +#define RC_NV_Extend_data (TPM_RC_P + TPM_RC_1) + +TPM_RC +TPM2_NV_Extend( + NV_Extend_In *in // IN: input parameter list + ); + + +#endif diff --git a/libstb/tss2/ibmtss/NV_GlobalWriteLock_fp.h b/libstb/tss2/ibmtss/NV_GlobalWriteLock_fp.h new file mode 100644 index 0000000..20b6377 --- /dev/null +++ b/libstb/tss2/ibmtss/NV_GlobalWriteLock_fp.h @@ -0,0 +1,79 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: NV_GlobalWriteLock_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef NV_GLOBALWRITELOCK_FP_H +#define NV_GLOBALWRITELOCK_FP_H + +typedef struct { + TPMI_RH_PROVISION authHandle; +} NV_GlobalWriteLock_In; + +#define RC_NV_GlobalWriteLock_authHandle (TPM_RC_H + TPM_RC_1) + +TPM_RC +TPM2_NV_GlobalWriteLock( + NV_GlobalWriteLock_In *in // IN: input parameter list + ); + + +#endif diff --git a/libstb/tss2/ibmtss/NV_Increment_fp.h b/libstb/tss2/ibmtss/NV_Increment_fp.h new file mode 100644 index 0000000..e6529cf --- /dev/null +++ b/libstb/tss2/ibmtss/NV_Increment_fp.h @@ -0,0 +1,81 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: NV_Increment_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef NV_INCREMENT_FP_H +#define NV_INCREMENT_FP_H + +typedef struct { + TPMI_RH_NV_AUTH authHandle; + TPMI_RH_NV_INDEX nvIndex; +} NV_Increment_In;; + +#define RC_NV_Increment_authHandle (TPM_RC_H + TPM_RC_1) +#define RC_NV_Increment_nvIndex (TPM_RC_H + TPM_RC_2) + +TPM_RC +TPM2_NV_Increment( + NV_Increment_In *in // IN: input parameter list + ); + + +#endif diff --git a/libstb/tss2/ibmtss/NV_ReadLock_fp.h b/libstb/tss2/ibmtss/NV_ReadLock_fp.h new file mode 100644 index 0000000..9f92915 --- /dev/null +++ b/libstb/tss2/ibmtss/NV_ReadLock_fp.h @@ -0,0 +1,81 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: NV_ReadLock_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef NV_READLOCK_FP_H +#define NV_READLOCK_FP_H + +typedef struct { + TPMI_RH_NV_AUTH authHandle; + TPMI_RH_NV_INDEX nvIndex; +} NV_ReadLock_In; + +#define RC_NV_ReadLock_authHandle (TPM_RC_H + TPM_RC_1) +#define RC_NV_ReadLock_nvIndex (TPM_RC_H + TPM_RC_2) + +TPM_RC +TPM2_NV_ReadLock( + NV_ReadLock_In *in // IN: input parameter list + ); + + +#endif diff --git a/libstb/tss2/ibmtss/NV_ReadPublic_fp.h b/libstb/tss2/ibmtss/NV_ReadPublic_fp.h new file mode 100644 index 0000000..35137e7 --- /dev/null +++ b/libstb/tss2/ibmtss/NV_ReadPublic_fp.h @@ -0,0 +1,85 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: NV_ReadPublic_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef NV_READPUBLIC_FP_H +#define NV_READPUBLIC_FP_H + +typedef struct { + TPMI_RH_NV_INDEX nvIndex; +} NV_ReadPublic_In; + +#define RC_NV_ReadPublic_nvIndex (TPM_RC_P + TPM_RC_1) + +typedef struct { + TPM2B_NV_PUBLIC nvPublic; + TPM2B_NAME nvName; +} NV_ReadPublic_Out; + +TPM_RC +TPM2_NV_ReadPublic( + NV_ReadPublic_In *in, // IN: input parameter list + NV_ReadPublic_Out *out // OUT: output parameter list + ); + + +#endif diff --git a/libstb/tss2/ibmtss/NV_ReadValueAuth_fp.h b/libstb/tss2/ibmtss/NV_ReadValueAuth_fp.h new file mode 100644 index 0000000..df82da4 --- /dev/null +++ b/libstb/tss2/ibmtss/NV_ReadValueAuth_fp.h @@ -0,0 +1,65 @@ +/********************************************************************************/ +/* */ +/* TPM 1.2 NV_ReadValueAuth */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: NV_ReadValueAuth_fp.h 1257 2018-06-27 20:52:08Z kgoldman $ */ +/* */ +/* (c) Copyright IBM Corporation 2018. */ +/* */ +/* All rights reserved. */ +/* */ +/* Redistribution and use in source and binary forms, with or without */ +/* modification, are permitted provided that the following conditions are */ +/* met: */ +/* */ +/* Redistributions of source code must retain the above copyright notice, */ +/* this list of conditions and the following disclaimer. */ +/* */ +/* 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. */ +/* */ +/* Neither the names of the IBM Corporation nor the names of its */ +/* contributors may be used to endorse or promote products derived from */ +/* this software without specific prior written permission. */ +/* */ +/* 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 NVREADVALUEAUTH_FP_H +#define NVREADVALUEAUTH_FP_H + +#include <ibmtss/tpmtypes12.h> +#include <ibmtss/tpmstructures12.h> + +#include <ibmtss/Implementation.h> + +typedef struct { + TPM12_NV_INDEX nvIndex; + UINT32 offset; + UINT32 dataSize; +} NV_ReadValueAuth_In; + +typedef struct { + UINT32 dataSize; + BYTE data[MAX_NV_BUFFER_SIZE]; +} NV_ReadValueAuth_Out; + +TPM_RC +TPM2_NV_ReadValueAuth( + NV_ReadValueAuth_In *in, // IN: input parameter buffer + NV_ReadValueAuth_Out *out // OUT: output parameter buffer + ); + +#endif diff --git a/libstb/tss2/ibmtss/NV_ReadValue_fp.h b/libstb/tss2/ibmtss/NV_ReadValue_fp.h new file mode 100644 index 0000000..4aabffc --- /dev/null +++ b/libstb/tss2/ibmtss/NV_ReadValue_fp.h @@ -0,0 +1,65 @@ +/********************************************************************************/ +/* */ +/* TPM 1.2 NV_ReadValue */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: NV_ReadValue_fp.h 1257 2018-06-27 20:52:08Z kgoldman $ */ +/* */ +/* (c) Copyright IBM Corporation 2018. */ +/* */ +/* All rights reserved. */ +/* */ +/* Redistribution and use in source and binary forms, with or without */ +/* modification, are permitted provided that the following conditions are */ +/* met: */ +/* */ +/* Redistributions of source code must retain the above copyright notice, */ +/* this list of conditions and the following disclaimer. */ +/* */ +/* 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. */ +/* */ +/* Neither the names of the IBM Corporation nor the names of its */ +/* contributors may be used to endorse or promote products derived from */ +/* this software without specific prior written permission. */ +/* */ +/* 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 NVREADVALUE_FP_H +#define NVREADVALUE_FP_H + +#include <ibmtss/tpmtypes12.h> +#include <ibmtss/tpmstructures12.h> + +#include <ibmtss/Implementation.h> + +typedef struct { + TPM12_NV_INDEX nvIndex; + UINT32 offset; + UINT32 dataSize; +} NV_ReadValue_In; + +typedef struct { + UINT32 dataSize; + BYTE data[MAX_NV_BUFFER_SIZE]; +} NV_ReadValue_Out; + +TPM_RC +TPM2_NV_ReadValue( + NV_ReadValue_In *in, // IN: input parameter buffer + NV_ReadValue_Out *out // OUT: output parameter buffer + ); + +#endif diff --git a/libstb/tss2/ibmtss/NV_Read_fp.h b/libstb/tss2/ibmtss/NV_Read_fp.h new file mode 100644 index 0000000..636fe81 --- /dev/null +++ b/libstb/tss2/ibmtss/NV_Read_fp.h @@ -0,0 +1,89 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: NV_Read_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef NV_READ_FP_H +#define NV_READ_FP_H + +typedef struct { + TPMI_RH_NV_AUTH authHandle; + TPMI_RH_NV_INDEX nvIndex; + UINT16 size; + UINT16 offset; +} NV_Read_In; + +#define RC_NV_Read_authHandle (TPM_RC_H + TPM_RC_1) +#define RC_NV_Read_nvIndex (TPM_RC_H + TPM_RC_2) +#define RC_NV_Read_size (TPM_RC_P + TPM_RC_1) +#define RC_NV_Read_offset (TPM_RC_P + TPM_RC_2) + +typedef struct { + TPM2B_MAX_NV_BUFFER data; +} NV_Read_Out; + +TPM_RC +TPM2_NV_Read( + NV_Read_In *in, // IN: input parameter list + NV_Read_Out *out // OUT: output parameter list + ); + +#endif diff --git a/libstb/tss2/ibmtss/NV_SetBits_fp.h b/libstb/tss2/ibmtss/NV_SetBits_fp.h new file mode 100644 index 0000000..4b1c1a0 --- /dev/null +++ b/libstb/tss2/ibmtss/NV_SetBits_fp.h @@ -0,0 +1,83 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: NV_SetBits_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef NV_SETBITS_FP_H +#define NV_SETBITS_FP_H + +typedef struct { + TPMI_RH_NV_AUTH authHandle; + TPMI_RH_NV_INDEX nvIndex; + UINT64 bits; +} NV_SetBits_In; + +#define RC_NV_SetBits_authHandle (TPM_RC_H + TPM_RC_1) +#define RC_NV_SetBits_nvIndex (TPM_RC_H + TPM_RC_2) +#define RC_NV_SetBits_bits (TPM_RC_P + TPM_RC_1) + +TPM_RC +TPM2_NV_SetBits( + NV_SetBits_In *in // IN: input parameter list + ); + + +#endif diff --git a/libstb/tss2/ibmtss/NV_UndefineSpaceSpecial_fp.h b/libstb/tss2/ibmtss/NV_UndefineSpaceSpecial_fp.h new file mode 100644 index 0000000..f58713c --- /dev/null +++ b/libstb/tss2/ibmtss/NV_UndefineSpaceSpecial_fp.h @@ -0,0 +1,81 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: NV_UndefineSpaceSpecial_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef NV_UNDEFINESPACESPECIAL_FP_H +#define NV_UNDEFINESPACESPECIAL_FP_H + +typedef struct { + TPMI_RH_NV_INDEX nvIndex; + TPMI_RH_PLATFORM platform; +} NV_UndefineSpaceSpecial_In; + +#define RC_NV_UndefineSpaceSpecial_nvIndex (TPM_RC_H + TPM_RC_1) +#define RC_NV_UndefineSpaceSpecial_platform (TPM_RC_H + TPM_RC_2) + +TPM_RC +TPM2_NV_UndefineSpaceSpecial( + NV_UndefineSpaceSpecial_In *in // IN: input parameter list + ); + + +#endif diff --git a/libstb/tss2/ibmtss/NV_UndefineSpace_fp.h b/libstb/tss2/ibmtss/NV_UndefineSpace_fp.h new file mode 100644 index 0000000..6b9ca92 --- /dev/null +++ b/libstb/tss2/ibmtss/NV_UndefineSpace_fp.h @@ -0,0 +1,81 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: NV_UndefineSpace_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef NV_UNDEFINESPACE_FP_H +#define NV_UNDEFINESPACE_FP_H + +typedef struct { + TPMI_RH_PROVISION authHandle; + TPMI_RH_NV_INDEX nvIndex; +} NV_UndefineSpace_In; + +#define RC_NV_UndefineSpace_authHandle (TPM_RC_H + TPM_RC_1) +#define RC_NV_UndefineSpace_nvIndex (TPM_RC_H + TPM_RC_2) + +TPM_RC +TPM2_NV_UndefineSpace( + NV_UndefineSpace_In *in // IN: input parameter list + ); + + +#endif diff --git a/libstb/tss2/ibmtss/NV_WriteLock_fp.h b/libstb/tss2/ibmtss/NV_WriteLock_fp.h new file mode 100644 index 0000000..471e1c9 --- /dev/null +++ b/libstb/tss2/ibmtss/NV_WriteLock_fp.h @@ -0,0 +1,81 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: NV_WriteLock_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef NV_WRITELOCK_FP_H +#define NV_WRITELOCK_FP_H + +typedef struct { + TPMI_RH_NV_AUTH authHandle; + TPMI_RH_NV_INDEX nvIndex; +} NV_WriteLock_In; + +#define RC_NV_WriteLock_authHandle (TPM_RC_H + TPM_RC_1) +#define RC_NV_WriteLock_nvIndex (TPM_RC_H + TPM_RC_2) + +TPM_RC +TPM2_NV_WriteLock( + NV_WriteLock_In *in // IN: input parameter list + ); + + +#endif diff --git a/libstb/tss2/ibmtss/NV_WriteValueAuth_fp.h b/libstb/tss2/ibmtss/NV_WriteValueAuth_fp.h new file mode 100644 index 0000000..60b4bca --- /dev/null +++ b/libstb/tss2/ibmtss/NV_WriteValueAuth_fp.h @@ -0,0 +1,57 @@ +/********************************************************************************/ +/* */ +/* TPM 1.2 NV_WriteValueAuth */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: NV_WriteValueAuth_fp.h 1294 2018-08-09 19:08:34Z kgoldman $ */ +/* */ +/* (c) Copyright IBM Corporation 2018. */ +/* */ +/* All rights reserved. */ +/* */ +/* Redistribution and use in source and binary forms, with or without */ +/* modification, are permitted provided that the following conditions are */ +/* met: */ +/* */ +/* Redistributions of source code must retain the above copyright notice, */ +/* this list of conditions and the following disclaimer. */ +/* */ +/* 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. */ +/* */ +/* Neither the names of the IBM Corporation nor the names of its */ +/* contributors may be used to endorse or promote products derived from */ +/* this software without specific prior written permission. */ +/* */ +/* 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 NVWRITEVALUEAUTH_FP_H +#define NVWRITEVALUEAUTH_FP_H + +typedef struct { + TPM12_NV_INDEX nvIndex; + UINT32 offset; + UINT32 dataSize; + BYTE data[MAX_NV_BUFFER_SIZE]; +} NV_WriteValueAuth_In; + +TPM_RC +TPM_NV_WriteValueAuth( + NV_WriteValueAuth_In *in // IN: input parameter list + ); + + + +#endif diff --git a/libstb/tss2/ibmtss/NV_WriteValue_fp.h b/libstb/tss2/ibmtss/NV_WriteValue_fp.h new file mode 100644 index 0000000..489aa1d --- /dev/null +++ b/libstb/tss2/ibmtss/NV_WriteValue_fp.h @@ -0,0 +1,55 @@ +/********************************************************************************/ +/* */ +/* TPM 1.2 NV_WriteValue */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: NV_WriteValue_fp.h 1257 2018-06-27 20:52:08Z kgoldman $ */ +/* */ +/* (c) Copyright IBM Corporation 2018. */ +/* */ +/* All rights reserved. */ +/* */ +/* Redistribution and use in source and binary forms, with or without */ +/* modification, are permitted provided that the following conditions are */ +/* met: */ +/* */ +/* Redistributions of source code must retain the above copyright notice, */ +/* this list of conditions and the following disclaimer. */ +/* */ +/* 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. */ +/* */ +/* Neither the names of the IBM Corporation nor the names of its */ +/* contributors may be used to endorse or promote products derived from */ +/* this software without specific prior written permission. */ +/* */ +/* 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 NVWRITEVALUE_FP_H +#define NVWRITEVALUE_FP_H + +typedef struct { + TPM12_NV_INDEX nvIndex; + UINT32 offset; + UINT32 dataSize; + BYTE data[MAX_NV_BUFFER_SIZE]; +} NV_WriteValue_In; + +TPM_RC +TPM_NV_WriteValue( + NV_WriteValue_In *in // IN: input parameter list + ); + +#endif diff --git a/libstb/tss2/ibmtss/NV_Write_fp.h b/libstb/tss2/ibmtss/NV_Write_fp.h new file mode 100644 index 0000000..56b9a98 --- /dev/null +++ b/libstb/tss2/ibmtss/NV_Write_fp.h @@ -0,0 +1,85 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: NV_Write_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef NV_WRITE_FP_H +#define NV_WRITE_FP_H + +typedef struct { + TPMI_RH_NV_AUTH authHandle; + TPMI_RH_NV_INDEX nvIndex; + TPM2B_MAX_NV_BUFFER data; + UINT16 offset; +} NV_Write_In; + +#define RC_NV_Write_authHandle (TPM_RC_H + TPM_RC_1) +#define RC_NV_Write_nvIndex (TPM_RC_H + TPM_RC_2) +#define RC_NV_Write_data (TPM_RC_P + TPM_RC_1) +#define RC_NV_Write_offset (TPM_RC_P + TPM_RC_2) + +TPM_RC +TPM2_NV_Write( + NV_Write_In *in // IN: input parameter list + ); + + +#endif diff --git a/libstb/tss2/ibmtss/OIAP_fp.h b/libstb/tss2/ibmtss/OIAP_fp.h new file mode 100644 index 0000000..5334d42 --- /dev/null +++ b/libstb/tss2/ibmtss/OIAP_fp.h @@ -0,0 +1,78 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: OIAP_fp.h 1257 2018-06-27 20:52:08Z 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, 2018 */ +/* */ +/********************************************************************************/ + +#ifndef OIAP_FP_H +#define OIAP_FP_H + +#include <ibmtss/tpmtypes12.h> +#include <ibmtss/tpmstructures12.h> + +typedef struct { + TPM_AUTHHANDLE authHandle; + TPM_NONCE nonceEven; +} OIAP_Out; + +TPM_RC +TPM2_OIAP( + OIAP_Out *out // OUT: output parameter buffer + ); + +#endif diff --git a/libstb/tss2/ibmtss/OSAP_fp.h b/libstb/tss2/ibmtss/OSAP_fp.h new file mode 100644 index 0000000..f7f9546 --- /dev/null +++ b/libstb/tss2/ibmtss/OSAP_fp.h @@ -0,0 +1,60 @@ +/********************************************************************************/ +/* */ +/* TPM 1.2 OSAP */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* */ +/* (c) Copyright IBM Corporation 2018. */ +/* */ +/* All rights reserved. */ +/* */ +/* Redistribution and use in source and binary forms, with or without */ +/* modification, are permitted provided that the following conditions are */ +/* met: */ +/* */ +/* Redistributions of source code must retain the above copyright notice, */ +/* this list of conditions and the following disclaimer. */ +/* */ +/* 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. */ +/* */ +/* Neither the names of the IBM Corporation nor the names of its */ +/* contributors may be used to endorse or promote products derived from */ +/* this software without specific prior written permission. */ +/* */ +/* 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 OSAP_FP_H +#define OSAP_FP_H + +typedef struct { + TPM_ENTITY_TYPE entityType; + UINT32 entityValue; + TPM_NONCE nonceOddOSAP; +} OSAP_In; + +typedef struct { + TPM_AUTHHANDLE authHandle; + TPM_NONCE nonceEven; + TPM_NONCE nonceEvenOSAP; +} OSAP_Out; + +TPM_RC +TPM2_OSAP( + OSAP_In *in, // IN: input parameter buffer + OSAP_Out *out // OUT: output parameter buffer + ); + +#endif diff --git a/libstb/tss2/ibmtss/ObjectChangeAuth_fp.h b/libstb/tss2/ibmtss/ObjectChangeAuth_fp.h new file mode 100644 index 0000000..1987da4 --- /dev/null +++ b/libstb/tss2/ibmtss/ObjectChangeAuth_fp.h @@ -0,0 +1,89 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: ObjectChangeAuth_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef OBJECTCHANGEAUTH_FP_H +#define OBJECTCHANGEAUTH_FP_H + +typedef struct { + TPMI_DH_OBJECT objectHandle; + TPMI_DH_OBJECT parentHandle; + TPM2B_AUTH newAuth; +} ObjectChangeAuth_In; + +#define RC_ObjectChangeAuth_objectHandle (TPM_RC_H + TPM_RC_1) +#define RC_ObjectChangeAuth_parentHandle (TPM_RC_H + TPM_RC_2) +#define RC_ObjectChangeAuth_newAuth (TPM_RC_P + TPM_RC_1) + +typedef struct { + TPM2B_PRIVATE outPrivate; +} ObjectChangeAuth_Out; + + +TPM_RC +TPM2_ObjectChangeAuth( + ObjectChangeAuth_In *in, // IN: input parameter list + ObjectChangeAuth_Out *out // OUT: output parameter list + ); + + +#endif diff --git a/libstb/tss2/ibmtss/OwnerReadInternalPub_fp.h b/libstb/tss2/ibmtss/OwnerReadInternalPub_fp.h new file mode 100644 index 0000000..8e40a75 --- /dev/null +++ b/libstb/tss2/ibmtss/OwnerReadInternalPub_fp.h @@ -0,0 +1,62 @@ +/********************************************************************************/ +/* */ +/* TPM 1.2 OwnerReadInternalPub */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: OwnerReadInternalPub_fp.h 1257 2018-06-27 20:52:08Z kgoldman $ */ +/* */ +/* (c) Copyright IBM Corporation 2018. */ +/* */ +/* All rights reserved. */ +/* */ +/* Redistribution and use in source and binary forms, with or without */ +/* modification, are permitted provided that the following conditions are */ +/* met: */ +/* */ +/* Redistributions of source code must retain the above copyright notice, */ +/* this list of conditions and the following disclaimer. */ +/* */ +/* 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. */ +/* */ +/* Neither the names of the IBM Corporation nor the names of its */ +/* contributors may be used to endorse or promote products derived from */ +/* this software without specific prior written permission. */ +/* */ +/* 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 OWNERREADINTERNALPUB_FP_H +#define OWNERREADINTERNALPUB_FP_H + +#include <ibmtss/tpmtypes12.h> +#include <ibmtss/tpmstructures12.h> + +#include <ibmtss/Implementation.h> + +typedef struct { + TPM_KEY_HANDLE keyHandle; +} OwnerReadInternalPub_In; + +typedef struct { + TPM_PUBKEY publicPortion; +} OwnerReadInternalPub_Out; + +TPM_RC +TPM2_OwnerReadInternalPub( + OwnerReadInternalPub_In *in, // IN: input parameter buffer + OwnerReadInternalPub_Out *out // OUT: output parameter buffer + ); + +#endif diff --git a/libstb/tss2/ibmtss/OwnerSetDisable_fp.h b/libstb/tss2/ibmtss/OwnerSetDisable_fp.h new file mode 100644 index 0000000..2689662 --- /dev/null +++ b/libstb/tss2/ibmtss/OwnerSetDisable_fp.h @@ -0,0 +1,50 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: OwnerSetDisable_fp.h 1257 2018-06-27 20:52:08Z kgoldman $ */ +/* */ +/* (c) Copyright IBM Corporation 2018 */ +/* */ +/* All rights reserved. */ +/* */ +/* Redistribution and use in source and binary forms, with or without */ +/* modification, are permitted provided that the following conditions are */ +/* met: */ +/* */ +/* Redistributions of source code must retain the above copyright notice, */ +/* this list of conditions and the following disclaimer. */ +/* */ +/* 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. */ +/* */ +/* Neither the names of the IBM Corporation nor the names of its */ +/* contributors may be used to endorse or promote products derived from */ +/* this software without specific prior written permission. */ +/* */ +/* 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 OWNERSETDISABLE_FP_H +#define OWNERSETDISABLE_FP_H + +#include <ibmtss/tpmtypes12.h> + +typedef struct { + uint8_t disableState; +} OwnerSetDisable_In; + + +#endif diff --git a/libstb/tss2/ibmtss/PCR_Allocate_fp.h b/libstb/tss2/ibmtss/PCR_Allocate_fp.h new file mode 100644 index 0000000..509d7c0 --- /dev/null +++ b/libstb/tss2/ibmtss/PCR_Allocate_fp.h @@ -0,0 +1,89 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: PCR_Allocate_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef PCR_ALLOCATE_FP_H +#define PCR_ALLOCATE_FP_H + +typedef struct { + TPMI_RH_PLATFORM authHandle; + TPML_PCR_SELECTION pcrAllocation; +} PCR_Allocate_In; + +#define RC_PCR_Allocate_authHandle (TPM_RC_H + TPM_RC_1) +#define RC_PCR_Allocate_pcrAllocation (TPM_RC_P + TPM_RC_1) + +typedef struct { + TPMI_YES_NO allocationSuccess; + UINT32 maxPCR; + UINT32 sizeNeeded; + UINT32 sizeAvailable; +} PCR_Allocate_Out; + +TPM_RC +TPM2_PCR_Allocate( + PCR_Allocate_In *in, // IN: input parameter list + PCR_Allocate_Out *out // OUT: output parameter list + ); + + +#endif diff --git a/libstb/tss2/ibmtss/PCR_Event_fp.h b/libstb/tss2/ibmtss/PCR_Event_fp.h new file mode 100644 index 0000000..2ccb82a --- /dev/null +++ b/libstb/tss2/ibmtss/PCR_Event_fp.h @@ -0,0 +1,85 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: PCR_Event_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef PCR_EVENT_FP_H +#define PCR_EVENT_FP_H + +typedef struct { + TPMI_DH_PCR pcrHandle; + TPM2B_EVENT eventData; +} PCR_Event_In; + +#define RC_PCR_Event_pcrHandle (TPM_RC_H + TPM_RC_1) +#define RC_PCR_Event_eventData (TPM_RC_P + TPM_RC_1) + +typedef struct { + TPML_DIGEST_VALUES digests; +} PCR_Event_Out; + +TPM_RC +TPM2_PCR_Event( + PCR_Event_In *in, // IN: input parameter list + PCR_Event_Out *out // OUT: output parameter list + ); + +#endif diff --git a/libstb/tss2/ibmtss/PCR_Extend_fp.h b/libstb/tss2/ibmtss/PCR_Extend_fp.h new file mode 100644 index 0000000..fc201a8 --- /dev/null +++ b/libstb/tss2/ibmtss/PCR_Extend_fp.h @@ -0,0 +1,81 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: PCR_Extend_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef PCR_EXTEND_FP_H +#define PCR_EXTEND_FP_H + +typedef struct { + TPMI_DH_PCR pcrHandle; + TPML_DIGEST_VALUES digests; +} PCR_Extend_In; + +#define RC_PCR_Extend_pcrHandle (TPM_RC_H + TPM_RC_1) +#define RC_PCR_Extend_digests (TPM_RC_P + TPM_RC_1) + +TPM_RC +TPM2_PCR_Extend( + PCR_Extend_In *in // IN: input parameter list + ); + + +#endif diff --git a/libstb/tss2/ibmtss/PCR_Read_fp.h b/libstb/tss2/ibmtss/PCR_Read_fp.h new file mode 100644 index 0000000..4c38d3e --- /dev/null +++ b/libstb/tss2/ibmtss/PCR_Read_fp.h @@ -0,0 +1,85 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: PCR_Read_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef PCR_READ_FP_H +#define PCR_READ_FP_H + +typedef struct { + TPML_PCR_SELECTION pcrSelectionIn; +} PCR_Read_In; + +#define RC_PCR_Read_pcrSelectionIn (TPM_RC_P + TPM_RC_1) + +typedef struct { + UINT32 pcrUpdateCounter; + TPML_PCR_SELECTION pcrSelectionOut; + TPML_DIGEST pcrValues; +} PCR_Read_Out; + +TPM_RC +TPM2_PCR_Read( + PCR_Read_In *in, // IN: input parameter list + PCR_Read_Out *out // OUT: output parameter list + ); + +#endif diff --git a/libstb/tss2/ibmtss/PCR_Reset12_fp.h b/libstb/tss2/ibmtss/PCR_Reset12_fp.h new file mode 100644 index 0000000..995a1ba --- /dev/null +++ b/libstb/tss2/ibmtss/PCR_Reset12_fp.h @@ -0,0 +1,51 @@ +/********************************************************************************/ +/* */ +/* TPM 1.2 PCR_Reset */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* */ +/* (c) Copyright IBM Corporation 2018. */ +/* */ +/* All rights reserved. */ +/* */ +/* Redistribution and use in source and binary forms, with or without */ +/* modification, are permitted provided that the following conditions are */ +/* met: */ +/* */ +/* Redistributions of source code must retain the above copyright notice, */ +/* this list of conditions and the following disclaimer. */ +/* */ +/* 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. */ +/* */ +/* Neither the names of the IBM Corporation nor the names of its */ +/* contributors may be used to endorse or promote products derived from */ +/* this software without specific prior written permission. */ +/* */ +/* 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 PCRRESET12_FP_H +#define PCRRESET12_FP_H + +typedef struct { + TPM_PCR_SELECTION pcrSelection; +} PCR_Reset12_In; + +TPM_RC +TPM_PCR_Reset12( + PCR_Reset12_In *in // IN: input parameter list + ); + +#endif diff --git a/libstb/tss2/ibmtss/PCR_Reset_fp.h b/libstb/tss2/ibmtss/PCR_Reset_fp.h new file mode 100644 index 0000000..9825fc9 --- /dev/null +++ b/libstb/tss2/ibmtss/PCR_Reset_fp.h @@ -0,0 +1,78 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: PCR_Reset_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef PCR_RESET_FP_H +#define PCR_RESET_FP_H + +typedef struct { + TPMI_DH_PCR pcrHandle; +} PCR_Reset_In; + +#define RC_PCR_Reset__pcrHandle (TPM_RC_H + TPM_RC_1) + +TPM_RC +TPM2_PCR_Reset( + PCR_Reset_In *in // IN: input parameter list + ); + +#endif diff --git a/libstb/tss2/ibmtss/PCR_SetAuthPolicy_fp.h b/libstb/tss2/ibmtss/PCR_SetAuthPolicy_fp.h new file mode 100644 index 0000000..3146b5b --- /dev/null +++ b/libstb/tss2/ibmtss/PCR_SetAuthPolicy_fp.h @@ -0,0 +1,85 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: PCR_SetAuthPolicy_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef PCR_SETAUTHPOLICY_FP_H +#define PCR_SETAUTHPOLICY_FP_H + +typedef struct { + TPMI_RH_PLATFORM authHandle; + TPM2B_DIGEST authPolicy; + TPMI_ALG_HASH hashAlg; + TPMI_DH_PCR pcrNum; +} PCR_SetAuthPolicy_In; + +#define RC_PCR_SetAuthPolicy_authHandle (TPM_RC_H + TPM_RC_1) +#define RC_PCR_SetAuthPolicy_authPolicy (TPM_RC_P + TPM_RC_1) +#define RC_PCR_SetAuthPolicy_hashAlg (TPM_RC_P + TPM_RC_2) +#define RC_PCR_SetAuthPolicy_pcrNum (TPM_RC_P + TPM_RC_3) + +TPM_RC +TPM2_PCR_SetAuthPolicy( + PCR_SetAuthPolicy_In *in // IN: input parameter list + ); + + +#endif diff --git a/libstb/tss2/ibmtss/PCR_SetAuthValue_fp.h b/libstb/tss2/ibmtss/PCR_SetAuthValue_fp.h new file mode 100644 index 0000000..8351578 --- /dev/null +++ b/libstb/tss2/ibmtss/PCR_SetAuthValue_fp.h @@ -0,0 +1,81 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: PCR_SetAuthValue_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef PCR_SETAUTHVALUE_FP_H +#define PCR_SETAUTHVALUE_FP_H + +typedef struct { + TPMI_DH_PCR pcrHandle; + TPM2B_DIGEST auth; +} PCR_SetAuthValue_In; + +#define RC_PCR_SetAuthValue_pcrHandle (TPM_RC_H + TPM_RC_1) +#define RC_PCR_SetAuthValue_auth (TPM_RC_P + TPM_RC_1) + +TPM_RC +TPM2_PCR_SetAuthValue( + PCR_SetAuthValue_In *in // IN: input parameter list + ); + + +#endif diff --git a/libstb/tss2/ibmtss/PP_Commands_fp.h b/libstb/tss2/ibmtss/PP_Commands_fp.h new file mode 100644 index 0000000..f042b5a --- /dev/null +++ b/libstb/tss2/ibmtss/PP_Commands_fp.h @@ -0,0 +1,80 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: PP_Commands_fp.h 1257 2018-06-27 20:52:08Z 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, 2016 */ +/* */ +/********************************************************************************/ + +#ifndef PP_COMMANDS_FP_H +#define PP_COMMANDS_FP_H + +typedef struct { + TPMI_RH_PLATFORM auth; + TPML_CC setList; + TPML_CC clearList; +} PP_Commands_In; + +#define RC_PP_Commands_auth (TPM_RC_H + TPM_RC_1) +#define RC_PP_Commands_setList (TPM_RC_P + TPM_RC_1) +#define RC_PP_Commands_clearList (TPM_RC_P + TPM_RC_2) + +TPM_RC +TPM2_PP_Commands( + PP_Commands_In *in // IN: input parameter list + ); + +#endif diff --git a/libstb/tss2/ibmtss/Parameters.h b/libstb/tss2/ibmtss/Parameters.h new file mode 100644 index 0000000..00bf7c3 --- /dev/null +++ b/libstb/tss2/ibmtss/Parameters.h @@ -0,0 +1,397 @@ +/********************************************************************************/ +/* */ +/* Command and Response Parameter Structures */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* */ +/* 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, 2012-2019 */ +/* */ +/********************************************************************************/ + +/* TPM and TSS share thses structures */ + +#ifndef PARAMETERS_H +#define PARAMETERS_H + +#include "TPM_Types.h" + +#ifdef TPM_TPM20 +#include "ActivateCredential_fp.h" +#include "CertifyCreation_fp.h" +#include "Certify_fp.h" +#include "ChangeEPS_fp.h" +#include "ChangePPS_fp.h" +#include "ClearControl_fp.h" +#include "Clear_fp.h" +#include "ClockRateAdjust_fp.h" +#include "ClockSet_fp.h" +#include "Commit_fp.h" +#include "ContextLoad_fp.h" +#include "ContextSave_fp.h" +#include "CreatePrimary_fp.h" +#include "Create_fp.h" +#include "CreateLoaded_fp.h" +#include "DictionaryAttackLockReset_fp.h" +#include "DictionaryAttackParameters_fp.h" +#include "Duplicate_fp.h" +#include "ECC_Parameters_fp.h" +#include "ECDH_KeyGen_fp.h" +#include "ECDH_ZGen_fp.h" +#include "EC_Ephemeral_fp.h" +#include "EncryptDecrypt_fp.h" +#include "EncryptDecrypt2_fp.h" +#include "EventSequenceComplete_fp.h" +#include "EvictControl_fp.h" +#include "FlushContext_fp.h" +#include "GetCapability_fp.h" +#include "GetCommandAuditDigest_fp.h" +#include "GetRandom_fp.h" +#include "GetSessionAuditDigest_fp.h" +#include "GetTestResult_fp.h" +#include "GetTime_fp.h" +#include "HMAC_Start_fp.h" +#include "HMAC_fp.h" +#include "HashSequenceStart_fp.h" +#include "Hash_fp.h" +#include "HierarchyChangeAuth_fp.h" +#include "HierarchyControl_fp.h" +#include "Import_fp.h" +#include "IncrementalSelfTest_fp.h" +#include "LoadExternal_fp.h" +#include "Load_fp.h" +#include "MakeCredential_fp.h" +#include "NV_Certify_fp.h" +#include "NV_ChangeAuth_fp.h" +#include "NV_DefineSpace_fp.h" +#include "NV_Extend_fp.h" +#include "NV_GlobalWriteLock_fp.h" +#include "NV_Increment_fp.h" +#include "NV_ReadLock_fp.h" +#include "NV_ReadPublic_fp.h" +#include "NV_Read_fp.h" +#include "NV_SetBits_fp.h" +#include "NV_UndefineSpaceSpecial_fp.h" +#include "NV_UndefineSpace_fp.h" +#include "NV_WriteLock_fp.h" +#include "NV_Write_fp.h" +#include "ObjectChangeAuth_fp.h" +#include "PCR_Allocate_fp.h" +#include "PCR_Event_fp.h" +#include "PCR_Extend_fp.h" +#include "PCR_Read_fp.h" +#include "PCR_Reset_fp.h" +#include "PCR_SetAuthPolicy_fp.h" +#include "PCR_SetAuthValue_fp.h" +#include "PP_Commands_fp.h" +#include "PolicyAuthValue_fp.h" +#include "PolicyAuthorize_fp.h" +#include "PolicyCommandCode_fp.h" +#include "PolicyCounterTimer_fp.h" +#include "PolicyCpHash_fp.h" +#include "PolicyDuplicationSelect_fp.h" +#include "PolicyGetDigest_fp.h" +#include "PolicyLocality_fp.h" +#include "PolicyNV_fp.h" +#include "PolicyAuthorizeNV_fp.h" +#include "PolicyNvWritten_fp.h" +#include "PolicyNameHash_fp.h" +#include "PolicyOR_fp.h" +#include "PolicyPCR_fp.h" +#include "PolicyPassword_fp.h" +#include "PolicyPhysicalPresence_fp.h" +#include "PolicyRestart_fp.h" +#include "PolicySecret_fp.h" +#include "PolicySigned_fp.h" +#include "PolicyTemplate_fp.h" +#include "PolicyTicket_fp.h" +#include "Quote_fp.h" +#include "RSA_Decrypt_fp.h" +#include "RSA_Encrypt_fp.h" +#include "ReadClock_fp.h" +#include "ReadPublic_fp.h" +#include "Rewrap_fp.h" +#include "SelfTest_fp.h" +#include "SequenceComplete_fp.h" +#include "SequenceUpdate_fp.h" +#include "SetAlgorithmSet_fp.h" +#include "SetCommandCodeAuditStatus_fp.h" +#include "SetPrimaryPolicy_fp.h" +#include "Shutdown_fp.h" +#include "Sign_fp.h" +#include "StartAuthSession_fp.h" +#include "Startup_fp.h" +#include "StirRandom_fp.h" +#include "TestParms_fp.h" +#include "Unseal_fp.h" +#include "VerifySignature_fp.h" +#include "ZGen_2Phase_fp.h" +#include "NTC_fp.h" +#endif /* TPM20 */ + +#ifdef TPM_TPM12 +#include <ibmtss/Parameters12.h> +#endif + +/* these unions determine the maximum size of the structure */ + +typedef union { +#ifdef TPM_TPM20 + ActivateCredential_In ActivateCredential; + CertifyCreation_In CertifyCreation; + Certify_In Certify; + ChangeEPS_In ChangeEPS; + ChangePPS_In ChangePPS; + ClearControl_In ClearControl; + Clear_In Clear; + ClockRateAdjust_In ClockRateAdjust; + ClockSet_In ClockSet; + Commit_In Commit; + ContextLoad_In ContextLoad; + ContextSave_In ContextSave; + CreatePrimary_In CreatePrimary; + Create_In Create; + DictionaryAttackLockReset_In DictionaryAttackLockReset; + DictionaryAttackParameters_In DictionaryAttackParameters; + Duplicate_In Duplicate; + ECC_Parameters_In ECC_Parameters; + ECDH_KeyGen_In ECDH_KeyGen; + ECDH_ZGen_In ECDH_ZGen; + EC_Ephemeral_In EC_Ephemeral; + EncryptDecrypt_In EncryptDecrypt; + EventSequenceComplete_In EventSequenceComplete; + EvictControl_In EvictControl; + FlushContext_In FlushContext; + GetCapability_In GetCapability; + GetCommandAuditDigest_In GetCommandAuditDigest; + GetRandom_In GetRandom; + GetSessionAuditDigest_In GetSessionAuditDigest; + GetTime_In GetTime; + HMAC_In HMAC; + HMAC_Start_In HMAC_Start; + HashSequenceStart_In HashSequenceStart; + Hash_In Hash; + HierarchyChangeAuth_In HierarchyChangeAuth; + HierarchyControl_In HierarchyControl; + Import_In Import; + IncrementalSelfTest_In IncrementalSelfTest; + LoadExternal_In LoadExternal; + Load_In Load; + MakeCredential_In MakeCredential; + NV_Certify_In NV_Certify; + NV_ChangeAuth_In NV_ChangeAuth; + NV_DefineSpace_In NV_DefineSpace; + NV_Extend_In NV_Extend; + NV_GlobalWriteLock_In NV_GlobalWriteLock; + NV_Increment_In NV_Increment; + NV_ReadLock_In NV_ReadLock; + NV_ReadPublic_In NV_ReadPublic; + NV_Read_In NV_Read; + NV_SetBits_In NV_SetBits; + NV_UndefineSpaceSpecial_In NV_UndefineSpaceSpecial; + NV_UndefineSpace_In NV_UndefineSpace; + NV_WriteLock_In NV_WriteLock; + NV_Write_In NV_Write; + ObjectChangeAuth_In ObjectChangeAuth; + PCR_Allocate_In PCR_Allocate; + PCR_Event_In PCR_Event; + PCR_Extend_In PCR_Extend; + PCR_Read_In PCR_Read; + PCR_Reset_In PCR_Reset; + PCR_SetAuthPolicy_In PCR_SetAuthPolicy; + PCR_SetAuthValue_In PCR_SetAuthValue; + PP_Commands_In PP_Commands; + PolicyAuthValue_In PolicyAuthValue; + PolicyAuthorize_In PolicyAuthorize; + PolicyCommandCode_In PolicyCommandCode; + PolicyCounterTimer_In PolicyCounterTimer; + PolicyCpHash_In PolicyCpHash; + PolicyDuplicationSelect_In PolicyDuplicationSelect; + PolicyGetDigest_In PolicyGetDigest; + PolicyLocality_In PolicyLocality; + PolicyNV_In PolicyNV; + PolicyAuthorizeNV_In PolicyAuthorizeNV; + PolicyNameHash_In PolicyNameHash; + PolicyOR_In PolicyOR; + PolicyPCR_In PolicyPCR; + PolicyPassword_In PolicyPassword; + PolicyPhysicalPresence_In PolicyPhysicalPresence; + PolicyRestart_In PolicyRestart; + PolicySecret_In PolicySecret; + PolicySigned_In PolicySigned; + PolicyTicket_In PolicyTicket; + Quote_In Quote; + RSA_Decrypt_In RSA_Decrypt; + RSA_Encrypt_In RSA_Encrypt; + ReadPublic_In ReadPublic; + Rewrap_In Rewrap; + SelfTest_In SelfTest; + SequenceComplete_In SequenceComplete; + SequenceUpdate_In SequenceUpdate; + SetAlgorithmSet_In SetAlgorithmSet; + SetCommandCodeAuditStatus_In SetCommandCodeAuditStatus; + SetPrimaryPolicy_In SetPrimaryPolicy; + Shutdown_In Shutdown; + Sign_In Sign; + StartAuthSession_In StartAuthSession; + Startup_In Startup; + StirRandom_In StirRandom; + TestParms_In TestParms; + Unseal_In Unseal; + VerifySignature_In VerifySignature; + ZGen_2Phase_In ZGen_2Phase; +#endif /* TPM20 */ +#ifdef TPM_TPM12 + ActivateIdentity_In ActivateIdentity; + CreateWrapKey_In CreateWrapKey; + CreateEndorsementKeyPair_In CreateEndorsementKeyPair; + Extend_In Extend; + FlushSpecific_In FlushSpecific; + GetCapability12_In GetCapability12; + MakeIdentity_In MakeIdentity; + NV_DefineSpace12_In NV_DefineSpace12; + NV_ReadValue_In NV_ReadValue; + NV_ReadValueAuth_In NV_ReadValueAuth; + NV_WriteValue_In NV_WriteValue; + NV_WriteValueAuth_In NV_WriteValueAuth; + OSAP_In OSAP; + OwnerReadInternalPub_In OwnerReadInternalPub; + OwnerSetDisable_In OwnerSetDisable; + LoadKey2_In LoadKey2; + PcrRead12_In PcrRead12; + PCR_Reset12_In PCR_Reset12; + Quote2_In Quote2; + ReadPubek_In ReadPubek; + Sign12_In Sign12; + Startup12_In Startup12; + TakeOwnership_In TakeOwnership; +#endif /* TPM12 */ +} COMMAND_PARAMETERS; + +typedef union +{ +#ifdef TPM_TPM20 + ActivateCredential_Out ActivateCredential; + CertifyCreation_Out CertifyCreation; + Certify_Out Certify; + Commit_Out Commit; + ContextLoad_Out ContextLoad; + ContextSave_Out ContextSave; + CreatePrimary_Out CreatePrimary; + Create_Out Create; + Duplicate_Out Duplicate; + ECC_Parameters_Out ECC_Parameters; + ECDH_KeyGen_Out ECDH_KeyGen; + ECDH_ZGen_Out ECDH_ZGen; + EC_Ephemeral_Out EC_Ephemeral; + EncryptDecrypt_Out EncryptDecrypt; + EventSequenceComplete_Out EventSequenceComplete; + GetCapability_Out GetCapability; + GetCommandAuditDigest_Out GetCommandAuditDigest; + GetRandom_Out GetRandom; + GetSessionAuditDigest_Out GetSessionAuditDigest; + GetTestResult_Out GetTestResult; + GetTime_Out GetTime; + HMAC_Out HMAC; + HMAC_Start_Out HMAC_Start; + HashSequenceStart_Out HashSequenceStart; + Hash_Out Hash; + Import_Out Import; + IncrementalSelfTest_Out IncrementalSelfTest; + LoadExternal_Out LoadExternal; + Load_Out Load; + MakeCredential_Out MakeCredential; + NV_Certify_Out NV_Certify; + NV_ReadPublic_Out NV_ReadPublic; + NV_Read_Out NV_Read; + ObjectChangeAuth_Out ObjectChangeAuth; + PCR_Allocate_Out PCR_Allocate; + PCR_Event_Out PCR_Event; + PCR_Read_Out PCR_Read; + PolicyGetDigest_Out PolicyGetDigest; + PolicySecret_Out PolicySecret; + PolicySigned_Out PolicySigned; + Quote_Out Quote; + RSA_Decrypt_Out RSA_Decrypt; + RSA_Encrypt_Out RSA_Encrypt; + ReadClock_Out ReadClock; + ReadPublic_Out ReadPublic; + Rewrap_Out Rewrap; + SequenceComplete_Out SequenceComplete; + Sign_Out Sign; + StartAuthSession_Out StartAuthSession; + Unseal_Out Unseal; + VerifySignature_Out VerifySignature; + ZGen_2Phase_Out ZGen_2Phase; +#endif /* TPM20 */ +#ifdef TPM_TPM12 + ActivateIdentity_Out ActivateIdentity; + CreateWrapKey_Out CreateWrapKey; + CreateEndorsementKeyPair_Out CreateEndorsementKeyPair; + Extend_Out Extend; + GetCapability12_Out GetCapability12; + MakeIdentity_Out MakeIdentity; + NV_ReadValue_Out NV_ReadValue; + NV_ReadValueAuth_Out NV_ReadValueAuth; + OIAP_Out OIAP; + OSAP_Out OSAP; + OwnerReadInternalPub_Out OwnerReadInternalPub; + LoadKey2_Out LoadKey2; + PcrRead12_Out PcrRead12; + Quote2_Out Quote2; + ReadPubek_Out ReadPubek; + Sign12_Out Sign12; + TakeOwnership_Out TakeOwnership; +#endif /* TPM12 */ +} RESPONSE_PARAMETERS; + +#endif diff --git a/libstb/tss2/ibmtss/Parameters12.h b/libstb/tss2/ibmtss/Parameters12.h new file mode 100644 index 0000000..90c9fa8 --- /dev/null +++ b/libstb/tss2/ibmtss/Parameters12.h @@ -0,0 +1,68 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: Parameters12.h 1257 2018-06-27 20:52:08Z kgoldman $ */ +/* */ +/* (c) Copyright IBM Corporation 2018. */ +/* */ +/* All rights reserved. */ +/* */ +/* Redistribution and use in source and binary forms, with or without */ +/* modification, are permitted provided that the following conditions are */ +/* met: */ +/* */ +/* Redistributions of source code must retain the above copyright notice, */ +/* this list of conditions and the following disclaimer. */ +/* */ +/* 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. */ +/* */ +/* Neither the names of the IBM Corporation nor the names of its */ +/* contributors may be used to endorse or promote products derived from */ +/* this software without specific prior written permission. */ +/* */ +/* 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 PARAMETERS12_H +#define PARAMETERS12_H + +#include <ibmtss/ActivateIdentity_fp.h> +#include <ibmtss/CreateWrapKey_fp.h> +#include <ibmtss/CreateEndorsementKeyPair_fp.h> +#include <ibmtss/Extend_fp.h> +#include <ibmtss/FlushSpecific_fp.h> +#include <ibmtss/GetCapability12_fp.h> +#include <ibmtss/MakeIdentity_fp.h> +#include <ibmtss/NV_DefineSpace12_fp.h> +#include <ibmtss/NV_ReadValue_fp.h> +#include <ibmtss/NV_ReadValueAuth_fp.h> +#include <ibmtss/NV_WriteValue_fp.h> +#include <ibmtss/NV_WriteValueAuth_fp.h> +#include <ibmtss/OIAP_fp.h> +#include <ibmtss/OSAP_fp.h> +#include <ibmtss/OwnerReadInternalPub_fp.h> +#include <ibmtss/OwnerSetDisable_fp.h> +#include <ibmtss/LoadKey2_fp.h> +#include <ibmtss/PcrRead12_fp.h> +#include <ibmtss/PCR_Reset12_fp.h> +#include <ibmtss/Quote2_fp.h> +#include <ibmtss/ReadPubek_fp.h> +#include <ibmtss/Sign12_fp.h> +#include <ibmtss/Startup12_fp.h> +#include <ibmtss/TakeOwnership_fp.h> + +#endif diff --git a/libstb/tss2/ibmtss/PcrRead12_fp.h b/libstb/tss2/ibmtss/PcrRead12_fp.h new file mode 100644 index 0000000..dcb2278 --- /dev/null +++ b/libstb/tss2/ibmtss/PcrRead12_fp.h @@ -0,0 +1,56 @@ +/********************************************************************************/ +/* */ +/* TPM 1.2 PcrRead */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* */ +/* (c) Copyright IBM Corporation 2018. */ +/* */ +/* All rights reserved. */ +/* */ +/* Redistribution and use in source and binary forms, with or without */ +/* modification, are permitted provided that the following conditions are */ +/* met: */ +/* */ +/* Redistributions of source code must retain the above copyright notice, */ +/* this list of conditions and the following disclaimer. */ +/* */ +/* 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. */ +/* */ +/* Neither the names of the IBM Corporation nor the names of its */ +/* contributors may be used to endorse or promote products derived from */ +/* this software without specific prior written permission. */ +/* */ +/* 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 PCRREAD12_FP_H +#define PCRREAD12_FP_H + +typedef struct { + TPM_PCRINDEX pcrIndex; +} PcrRead12_In; + +typedef struct { + TPM_PCRVALUE outDigest; +} PcrRead12_Out; + +TPM_RC +TPM_PcrRead12( + PcrRead12_In *in, // IN: input parameter list + PcrRead12_Out *out // OUT: output parameter list + ); + +#endif diff --git a/libstb/tss2/ibmtss/PolicyAuthValue_fp.h b/libstb/tss2/ibmtss/PolicyAuthValue_fp.h new file mode 100644 index 0000000..c09a57b --- /dev/null +++ b/libstb/tss2/ibmtss/PolicyAuthValue_fp.h @@ -0,0 +1,79 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: PolicyAuthValue_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef POLICYAUTHVALUE_FP_H +#define POLICYAUTHVALUE_FP_H + +typedef struct { + TPMI_SH_POLICY policySession; +} PolicyAuthValue_In; + +#define RC_PolicyAuthValue_policySession (TPM_RC_H + TPM_RC_1) + +TPM_RC +TPM2_PolicyAuthValue( + PolicyAuthValue_In *in // IN: input parameter list + ); + + +#endif diff --git a/libstb/tss2/ibmtss/PolicyAuthorizeNV_fp.h b/libstb/tss2/ibmtss/PolicyAuthorizeNV_fp.h new file mode 100644 index 0000000..9b70b5c --- /dev/null +++ b/libstb/tss2/ibmtss/PolicyAuthorizeNV_fp.h @@ -0,0 +1,81 @@ +/********************************************************************************/ +/* */ +/* PolicyAuthorizeNV */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* */ +/* 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, 2012-2015, 2016 */ +/* */ +/********************************************************************************/ + +/* rev 136 */ + +#ifndef POLICYAUTHORIZENV_FP_H +#define POLICYAUTHORIZENV_FP_H + +typedef struct { + TPMI_RH_NV_AUTH authHandle; + TPMI_RH_NV_INDEX nvIndex; + TPMI_SH_POLICY policySession; +} PolicyAuthorizeNV_In; + +#define RC_PolicyAuthorizeNV_authHandle (TPM_RC_H + TPM_RC_1) +#define RC_PolicyAuthorizeNV_nvIndex (TPM_RC_H + TPM_RC_2) +#define RC_PolicyAuthorizeNV_policySession (TPM_RC_H + TPM_RC_3) + +TPM_RC +TPM2_PolicyAuthorizeNV( + PolicyAuthorizeNV_In *in // IN: input parameter list + ); + +#endif diff --git a/libstb/tss2/ibmtss/PolicyAuthorize_fp.h b/libstb/tss2/ibmtss/PolicyAuthorize_fp.h new file mode 100644 index 0000000..da1ddd7 --- /dev/null +++ b/libstb/tss2/ibmtss/PolicyAuthorize_fp.h @@ -0,0 +1,86 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: PolicyAuthorize_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef POLICYAUTHORIZE_FP_H +#define POLICYAUTHORIZE_FP_H + +typedef struct { + TPMI_SH_POLICY policySession; + TPM2B_DIGEST approvedPolicy; + TPM2B_NONCE policyRef; + TPM2B_NAME keySign; + TPMT_TK_VERIFIED checkTicket; +} PolicyAuthorize_In; + +#define RC_PolicyAuthorize_policySession (TPM_RC_H + TPM_RC_1) +#define RC_PolicyAuthorize_approvedPolicy (TPM_RC_P + TPM_RC_1) +#define RC_PolicyAuthorize_policyRef (TPM_RC_P + TPM_RC_2) +#define RC_PolicyAuthorize_keySign (TPM_RC_P + TPM_RC_3) +#define RC_PolicyAuthorize_checkTicket (TPM_RC_P + TPM_RC_4) + +TPM_RC +TPM2_PolicyAuthorize( + PolicyAuthorize_In *in // IN: input parameter list + ); + +#endif diff --git a/libstb/tss2/ibmtss/PolicyCommandCode_fp.h b/libstb/tss2/ibmtss/PolicyCommandCode_fp.h new file mode 100644 index 0000000..bc74c58 --- /dev/null +++ b/libstb/tss2/ibmtss/PolicyCommandCode_fp.h @@ -0,0 +1,80 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: PolicyCommandCode_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef POLICYCOMMANDCODE_FP_H +#define POLICYCOMMANDCODE_FP_H + +typedef struct { + TPMI_SH_POLICY policySession; + TPM_CC code; +} PolicyCommandCode_In; + +#define RC_PolicyCommandCode_policySession (TPM_RC_H + TPM_RC_1) +#define RC_PolicyCommandCode_code (TPM_RC_P + TPM_RC_1) + +TPM_RC +TPM2_PolicyCommandCode( + PolicyCommandCode_In *in // IN: input parameter list + ); + +#endif diff --git a/libstb/tss2/ibmtss/PolicyCounterTimer_fp.h b/libstb/tss2/ibmtss/PolicyCounterTimer_fp.h new file mode 100644 index 0000000..605de79 --- /dev/null +++ b/libstb/tss2/ibmtss/PolicyCounterTimer_fp.h @@ -0,0 +1,85 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: PolicyCounterTimer_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef POLICYCOUNTERTIMER_FP_H +#define POLICYCOUNTERTIMER_FP_H + +typedef struct { + TPMI_SH_POLICY policySession; + TPM2B_OPERAND operandB; + UINT16 offset; + TPM_EO operation; +} PolicyCounterTimer_In; + +#define RC_PolicyCounterTimer_policySession (TPM_RC_H + TPM_RC_1) +#define RC_PolicyCounterTimer_operandB (TPM_RC_P + TPM_RC_1) +#define RC_PolicyCounterTimer_offset (TPM_RC_P + TPM_RC_2) +#define RC_PolicyCounterTimer_operation (TPM_RC_P + TPM_RC_3) + +TPM_RC +TPM2_PolicyCounterTimer( + PolicyCounterTimer_In *in // IN: input parameter list + ); + + +#endif diff --git a/libstb/tss2/ibmtss/PolicyCpHash_fp.h b/libstb/tss2/ibmtss/PolicyCpHash_fp.h new file mode 100644 index 0000000..f239551 --- /dev/null +++ b/libstb/tss2/ibmtss/PolicyCpHash_fp.h @@ -0,0 +1,81 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: PolicyCpHash_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef POLICYCPHASH_FP_H +#define POLICYCPHASH_FP_H + +typedef struct { + TPMI_SH_POLICY policySession; + TPM2B_DIGEST cpHashA; +} PolicyCpHash_In; + +#define RC_PolicyCpHash_policySession (TPM_RC_H + TPM_RC_1) +#define RC_PolicyCpHash_cpHashA (TPM_RC_P + TPM_RC_1) + +TPM_RC +TPM2_PolicyCpHash( + PolicyCpHash_In *in // IN: input parameter list + ); + + +#endif diff --git a/libstb/tss2/ibmtss/PolicyDuplicationSelect_fp.h b/libstb/tss2/ibmtss/PolicyDuplicationSelect_fp.h new file mode 100644 index 0000000..12a5d33 --- /dev/null +++ b/libstb/tss2/ibmtss/PolicyDuplicationSelect_fp.h @@ -0,0 +1,85 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: PolicyDuplicationSelect_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef POLICYDUPLICATIONSELECT_FP_H +#define POLICYDUPLICATIONSELECT_FP_H + +typedef struct { + TPMI_SH_POLICY policySession; + TPM2B_NAME objectName; + TPM2B_NAME newParentName; + TPMI_YES_NO includeObject; +} PolicyDuplicationSelect_In; + +#define RC_PolicyDuplicationSelect_policySession (TPM_RC_H + TPM_RC_1) +#define RC_PolicyDuplicationSelect_objectName (TPM_RC_P + TPM_RC_1) +#define RC_PolicyDuplicationSelect_newParentName (TPM_RC_P + TPM_RC_2) +#define RC_PolicyDuplicationSelect_includeObject (TPM_RC_P + TPM_RC_3) + +TPM_RC +TPM2_PolicyDuplicationSelect( + PolicyDuplicationSelect_In *in // IN: input parameter list + ); + + +#endif diff --git a/libstb/tss2/ibmtss/PolicyGetDigest_fp.h b/libstb/tss2/ibmtss/PolicyGetDigest_fp.h new file mode 100644 index 0000000..0283ee1 --- /dev/null +++ b/libstb/tss2/ibmtss/PolicyGetDigest_fp.h @@ -0,0 +1,84 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: PolicyGetDigest_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef POLICYGETDIGEST_FP_H +#define POLICYGETDIGEST_FP_H + +typedef struct { + TPMI_SH_POLICY policySession; +} PolicyGetDigest_In; + +#define RC_PolicyGetDigest_policySession (TPM_RC_P + TPM_RC_1) + +typedef struct { + TPM2B_DIGEST policyDigest; +} PolicyGetDigest_Out; + +TPM_RC +TPM2_PolicyGetDigest( + PolicyGetDigest_In *in, // IN: input parameter list + PolicyGetDigest_Out *out // OUT: output parameter list + ); + + +#endif diff --git a/libstb/tss2/ibmtss/PolicyLocality_fp.h b/libstb/tss2/ibmtss/PolicyLocality_fp.h new file mode 100644 index 0000000..f41fa65 --- /dev/null +++ b/libstb/tss2/ibmtss/PolicyLocality_fp.h @@ -0,0 +1,81 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: PolicyLocality_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef POLICYLOCALITY_FP_H +#define POLICYLOCALITY_FP_H + +typedef struct { + TPMI_SH_POLICY policySession; + TPMA_LOCALITY locality; +} PolicyLocality_In; + +#define RC_PolicyLocality_policySession (TPM_RC_H + TPM_RC_1) +#define RC_PolicyLocality_locality (TPM_RC_P + TPM_RC_1) + +TPM_RC +TPM2_PolicyLocality( + PolicyLocality_In *in // IN: input parameter list + ); + + +#endif diff --git a/libstb/tss2/ibmtss/PolicyNV_fp.h b/libstb/tss2/ibmtss/PolicyNV_fp.h new file mode 100644 index 0000000..580eeff --- /dev/null +++ b/libstb/tss2/ibmtss/PolicyNV_fp.h @@ -0,0 +1,88 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: PolicyNV_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef POLICYNV_FP_H +#define POLICYNV_FP_H + +typedef struct { + TPMI_RH_NV_AUTH authHandle; + TPMI_RH_NV_INDEX nvIndex; + TPMI_SH_POLICY policySession; + TPM2B_OPERAND operandB; + UINT16 offset; + TPM_EO operation; +} PolicyNV_In; + +#define RC_PolicyNV_authHandle (TPM_RC_H + TPM_RC_1) +#define RC_PolicyNV_nvIndex (TPM_RC_H + TPM_RC_2) +#define RC_PolicyNV_policySession (TPM_RC_H + TPM_RC_3) +#define RC_PolicyNV_operandB (TPM_RC_P + TPM_RC_1) +#define RC_PolicyNV_offset (TPM_RC_P + TPM_RC_2) +#define RC_PolicyNV_operation (TPM_RC_P + TPM_RC_3) + +TPM_RC +TPM2_PolicyNV( + PolicyNV_In *in // IN: input parameter list + ); + +#endif diff --git a/libstb/tss2/ibmtss/PolicyNameHash_fp.h b/libstb/tss2/ibmtss/PolicyNameHash_fp.h new file mode 100644 index 0000000..39c73ee --- /dev/null +++ b/libstb/tss2/ibmtss/PolicyNameHash_fp.h @@ -0,0 +1,81 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: PolicyNameHash_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef POLICYNAMEHASH_FP_H +#define POLICYNAMEHASH_FP_H + +typedef struct { + TPMI_SH_POLICY policySession; + TPM2B_DIGEST nameHash; +} PolicyNameHash_In; + +#define RC_PolicyNameHash_policySession (TPM_RC_H + TPM_RC_1) +#define RC_PolicyNameHash_nameHash (TPM_RC_P + TPM_RC_1) + +TPM_RC +TPM2_PolicyNameHash( + PolicyNameHash_In *in // IN: input parameter list + ); + + +#endif diff --git a/libstb/tss2/ibmtss/PolicyNvWritten_fp.h b/libstb/tss2/ibmtss/PolicyNvWritten_fp.h new file mode 100644 index 0000000..afe514f --- /dev/null +++ b/libstb/tss2/ibmtss/PolicyNvWritten_fp.h @@ -0,0 +1,81 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: PolicyNvWritten_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef POLICYNVWRITTEN_FP_H +#define POLICYNVWRITTEN_FP_H + +typedef struct { + TPMI_SH_POLICY policySession; + TPMI_YES_NO writtenSet; +} PolicyNvWritten_In; + +#define RC_PolicyNvWritten_policySession (TPM_RC_H + TPM_RC_1) +#define RC_PolicyNvWritten_writtenSet (TPM_RC_P + TPM_RC_1) + +TPM_RC +TPM2_PolicyNvWritten( + PolicyNvWritten_In *in // IN: input parameter list + ); + + +#endif diff --git a/libstb/tss2/ibmtss/PolicyOR_fp.h b/libstb/tss2/ibmtss/PolicyOR_fp.h new file mode 100644 index 0000000..cc1024a --- /dev/null +++ b/libstb/tss2/ibmtss/PolicyOR_fp.h @@ -0,0 +1,81 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: PolicyOR_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef POLICYOR_FP_H +#define POLICYOR_FP_H + +typedef struct { + TPMI_SH_POLICY policySession; + TPML_DIGEST pHashList; +} PolicyOR_In; + +#define RC_PolicyOR_policySession (TPM_RC_H + TPM_RC_1) +#define RC_PolicyOR_pHashList (TPM_RC_P + TPM_RC_1) + +TPM_RC +TPM2_PolicyOR( + PolicyOR_In *in // IN: input parameter list + ); + + +#endif diff --git a/libstb/tss2/ibmtss/PolicyPCR_fp.h b/libstb/tss2/ibmtss/PolicyPCR_fp.h new file mode 100644 index 0000000..6d9f715 --- /dev/null +++ b/libstb/tss2/ibmtss/PolicyPCR_fp.h @@ -0,0 +1,82 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: PolicyPCR_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef POLICYPCR_FP_H +#define POLICYPCR_FP_H + +typedef struct { + TPMI_SH_POLICY policySession; + TPM2B_DIGEST pcrDigest; + TPML_PCR_SELECTION pcrs; +} PolicyPCR_In; + +#define RC_PolicyPCR_policySession (TPM_RC_H + TPM_RC_1) +#define RC_PolicyPCR_pcrDigest (TPM_RC_P + TPM_RC_1) +#define RC_PolicyPCR_pcrs (TPM_RC_P + TPM_RC_2) + +TPM_RC +TPM2_PolicyPCR( + PolicyPCR_In *in // IN: input parameter list + ); + +#endif diff --git a/libstb/tss2/ibmtss/PolicyPassword_fp.h b/libstb/tss2/ibmtss/PolicyPassword_fp.h new file mode 100644 index 0000000..033578b --- /dev/null +++ b/libstb/tss2/ibmtss/PolicyPassword_fp.h @@ -0,0 +1,79 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: PolicyPassword_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef POLICYPASSWORD_FP_H +#define POLICYPASSWORD_FP_H + +typedef struct { + TPMI_SH_POLICY policySession; +} PolicyPassword_In; + +#define RC_PolicyPassword_policySession (TPM_RC_H + TPM_RC_1) + +TPM_RC +TPM2_PolicyPassword( + PolicyPassword_In *in // IN: input parameter list + ); + + +#endif diff --git a/libstb/tss2/ibmtss/PolicyPhysicalPresence_fp.h b/libstb/tss2/ibmtss/PolicyPhysicalPresence_fp.h new file mode 100644 index 0000000..1386259 --- /dev/null +++ b/libstb/tss2/ibmtss/PolicyPhysicalPresence_fp.h @@ -0,0 +1,78 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: PolicyPhysicalPresence_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef POLICYPHYSICALPRESENCE_FP_H +#define POLICYPHYSICALPRESENCE_FP_H + +typedef struct { + TPMI_SH_POLICY policySession; +} PolicyPhysicalPresence_In; + +#define RC_PolicyPhysicalPresence_policySession (TPM_RC_H + TPM_RC_1) + +TPM_RC +TPM2_PolicyPhysicalPresence( + PolicyPhysicalPresence_In *in // IN: input parameter list + ); + +#endif diff --git a/libstb/tss2/ibmtss/PolicyRestart_fp.h b/libstb/tss2/ibmtss/PolicyRestart_fp.h new file mode 100644 index 0000000..615d87f --- /dev/null +++ b/libstb/tss2/ibmtss/PolicyRestart_fp.h @@ -0,0 +1,79 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: PolicyRestart_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef POLICYRESTART_FP_H +#define POLICYRESTART_FP_H + +typedef struct { + TPMI_SH_POLICY sessionHandle; +} PolicyRestart_In; + +#define RC_PolicyRestart_sessionHandle (TPM_RC_H + TPM_RC_1) + +TPM_RC +TPM2_PolicyRestart( + PolicyRestart_In *in // IN: input parameter list + ); + + +#endif diff --git a/libstb/tss2/ibmtss/PolicySecret_fp.h b/libstb/tss2/ibmtss/PolicySecret_fp.h new file mode 100644 index 0000000..f90378a --- /dev/null +++ b/libstb/tss2/ibmtss/PolicySecret_fp.h @@ -0,0 +1,95 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: PolicySecret_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 124 */ + +#ifndef POLICYSECRET_FP_H +#define POLICYSECRET_FP_H + +typedef struct { + TPMI_DH_ENTITY authHandle; + TPMI_SH_POLICY policySession; + TPM2B_NONCE nonceTPM; + TPM2B_DIGEST cpHashA; + TPM2B_NONCE policyRef; + INT32 expiration; +} PolicySecret_In; + +#define RC_PolicySecret_authHandle (TPM_RC_H + TPM_RC_1) +#define RC_PolicySecret_policySession (TPM_RC_H + TPM_RC_2) +#define RC_PolicySecret_nonceTPM (TPM_RC_P + TPM_RC_1) +#define RC_PolicySecret_cpHashA (TPM_RC_P + TPM_RC_2) +#define RC_PolicySecret_policyRef (TPM_RC_P + TPM_RC_3) +#define RC_PolicySecret_expiration (TPM_RC_P + TPM_RC_4) + +typedef struct { + TPM2B_TIMEOUT timeout; + TPMT_TK_AUTH policyTicket; +} PolicySecret_Out; + +TPM_RC +TPM2_PolicySecret( + PolicySecret_In *in, // IN: input parameter list + PolicySecret_Out *out // OUT: output parameter list + ); + + +#endif diff --git a/libstb/tss2/ibmtss/PolicySigned_fp.h b/libstb/tss2/ibmtss/PolicySigned_fp.h new file mode 100644 index 0000000..d51f7bc --- /dev/null +++ b/libstb/tss2/ibmtss/PolicySigned_fp.h @@ -0,0 +1,96 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: PolicySigned_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef POLICYSIGNED_FP_H +#define POLICYSIGNED_FP_H + +typedef struct { + TPMI_DH_OBJECT authObject; + TPMI_SH_POLICY policySession; + TPM2B_NONCE nonceTPM; + TPM2B_DIGEST cpHashA; + TPM2B_NONCE policyRef; + INT32 expiration; + TPMT_SIGNATURE auth; +} PolicySigned_In; + +#define RC_PolicySigned_authObject (TPM_RC_H + TPM_RC_1) +#define RC_PolicySigned_policySession (TPM_RC_H + TPM_RC_2) +#define RC_PolicySigned_nonceTPM (TPM_RC_P + TPM_RC_1) +#define RC_PolicySigned_cpHashA (TPM_RC_P + TPM_RC_2) +#define RC_PolicySigned_policyRef (TPM_RC_P + TPM_RC_3) +#define RC_PolicySigned_expiration (TPM_RC_P + TPM_RC_4) +#define RC_PolicySigned_auth (TPM_RC_P + TPM_RC_5) + +typedef struct { + TPM2B_TIMEOUT timeout; + TPMT_TK_AUTH policyTicket; +} PolicySigned_Out; + +TPM_RC +TPM2_PolicySigned( + PolicySigned_In *in, // IN: input parameter list + PolicySigned_Out *out // OUT: output parameter list + ); + +#endif diff --git a/libstb/tss2/ibmtss/PolicyTemplate_fp.h b/libstb/tss2/ibmtss/PolicyTemplate_fp.h new file mode 100644 index 0000000..23e40f4 --- /dev/null +++ b/libstb/tss2/ibmtss/PolicyTemplate_fp.h @@ -0,0 +1,81 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: PolicyTemplate_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015, 2016 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef POLICYTEMPLATE_FP_H +#define POLICYTEMPLATE_FP_H + +typedef struct { + TPMI_SH_POLICY policySession; + TPM2B_DIGEST templateHash; +} PolicyTemplate_In; + +#define RC_PolicyTemplate_policySession (TPM_RC_H + TPM_RC_1) +#define RC_PolicyTemplate_templateHash (TPM_RC_P + TPM_RC_1) + +TPM_RC +TPM2_PolicyTemplate( + PolicyTemplate_In *in // IN: input parameter list + ); + + +#endif diff --git a/libstb/tss2/ibmtss/PolicyTicket_fp.h b/libstb/tss2/ibmtss/PolicyTicket_fp.h new file mode 100644 index 0000000..7c680a0 --- /dev/null +++ b/libstb/tss2/ibmtss/PolicyTicket_fp.h @@ -0,0 +1,89 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: PolicyTicket_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef POLICYTICKET_FP_H +#define POLICYTICKET_FP_H + +typedef struct { + TPMI_SH_POLICY policySession; + TPM2B_TIMEOUT timeout; + TPM2B_DIGEST cpHashA; + TPM2B_NONCE policyRef; + TPM2B_NAME authName; + TPMT_TK_AUTH ticket; +} PolicyTicket_In; + +#define RC_PolicyTicket_policySession (TPM_RC_H + TPM_RC_1) +#define RC_PolicyTicket_timeout (TPM_RC_P + TPM_RC_1) +#define RC_PolicyTicket_cpHashA (TPM_RC_P + TPM_RC_2) +#define RC_PolicyTicket_policyRef (TPM_RC_P + TPM_RC_3) +#define RC_PolicyTicket_authName (TPM_RC_P + TPM_RC_4) +#define RC_PolicyTicket_ticket (TPM_RC_P + TPM_RC_5) + +TPM_RC +TPM2_PolicyTicket( + PolicyTicket_In *in // IN: input parameter list + ); + + +#endif diff --git a/libstb/tss2/ibmtss/Quote2_fp.h b/libstb/tss2/ibmtss/Quote2_fp.h new file mode 100644 index 0000000..6e1fc7f --- /dev/null +++ b/libstb/tss2/ibmtss/Quote2_fp.h @@ -0,0 +1,69 @@ +/********************************************************************************/ +/* */ +/* TPM 1.2 Quote2 */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: Quote2_fp.h 1257 2018-06-27 20:52:08Z kgoldman $ */ +/* */ +/* (c) Copyright IBM Corporation 2018. */ +/* */ +/* All rights reserved. */ +/* */ +/* Redistribution and use in source and binary forms, with or without */ +/* modification, are permitted provided that the following conditions are */ +/* met: */ +/* */ +/* Redistributions of source code must retain the above copyright notice, */ +/* this list of conditions and the following disclaimer. */ +/* */ +/* 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. */ +/* */ +/* Neither the names of the IBM Corporation nor the names of its */ +/* contributors may be used to endorse or promote products derived from */ +/* this software without specific prior written permission. */ +/* */ +/* 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 QUOTE2_FP_H +#define QUOTE2_FP_H + +#include <ibmtss/tpmtypes12.h> +#include <ibmtss/tpmstructures12.h> + +#include <ibmtss/Implementation.h> + +typedef struct { + TPM_KEY_HANDLE keyHandle; + TPM_NONCE externalData; + TPM_PCR_SELECTION targetPCR; + TPM_BOOL addVersion; +} Quote2_In; + +typedef struct { + TPM_PCR_INFO_SHORT pcrData; + UINT32 versionInfoSize; + TPM_CAP_VERSION_INFO versionInfo; + UINT32 sigSize; + BYTE sig[MAX_RSA_KEY_BYTES]; +} Quote2_Out; + +TPM_RC +TPM2_Quote2( + Quote2_In *in, // IN: input parameter buffer + Quote2_Out *out // OUT: output parameter buffer + ); + +#endif diff --git a/libstb/tss2/ibmtss/Quote_fp.h b/libstb/tss2/ibmtss/Quote_fp.h new file mode 100644 index 0000000..75fcaa7 --- /dev/null +++ b/libstb/tss2/ibmtss/Quote_fp.h @@ -0,0 +1,91 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: Quote_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef QUOTE_FP_H +#define QUOTE_FP_H + +typedef struct { + TPMI_DH_OBJECT signHandle; + TPM2B_DATA qualifyingData; + TPMT_SIG_SCHEME inScheme; + TPML_PCR_SELECTION PCRselect; +} Quote_In; + +#define RC_Quote_signHandle (TPM_RC_H + TPM_RC_1) +#define RC_Quote_qualifyingData (TPM_RC_P + TPM_RC_1) +#define RC_Quote_inScheme (TPM_RC_P + TPM_RC_2) +#define RC_Quote_PCRselect (TPM_RC_P + TPM_RC_3) + +typedef struct { + TPM2B_ATTEST quoted; + TPMT_SIGNATURE signature; +} Quote_Out; + +TPM_RC +TPM2_Quote( + Quote_In *in, // IN: input parameter list + Quote_Out *out // OUT: output parameter list + ); + + +#endif diff --git a/libstb/tss2/ibmtss/RSA_Decrypt_fp.h b/libstb/tss2/ibmtss/RSA_Decrypt_fp.h new file mode 100644 index 0000000..f2f53ff --- /dev/null +++ b/libstb/tss2/ibmtss/RSA_Decrypt_fp.h @@ -0,0 +1,90 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: RSA_Decrypt_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef RSA_DECRYPT_FP_H +#define RSA_DECRYPT_FP_H + +typedef struct { + TPMI_DH_OBJECT keyHandle; + TPM2B_PUBLIC_KEY_RSA cipherText; + TPMT_RSA_DECRYPT inScheme; + TPM2B_DATA label; +} RSA_Decrypt_In; + +#define RC_RSA_Decrypt_keyHandle (TPM_RC_H + TPM_RC_1) +#define RC_RSA_Decrypt_cipherText (TPM_RC_P + TPM_RC_1) +#define RC_RSA_Decrypt_inScheme (TPM_RC_P + TPM_RC_2) +#define RC_RSA_Decrypt_label (TPM_RC_P + TPM_RC_3) + +typedef struct { + TPM2B_PUBLIC_KEY_RSA message; +} RSA_Decrypt_Out; + +TPM_RC +TPM2_RSA_Decrypt( + RSA_Decrypt_In *in, // IN: input parameter list + RSA_Decrypt_Out *out // OUT: output parameter list + ); + + +#endif diff --git a/libstb/tss2/ibmtss/RSA_Encrypt_fp.h b/libstb/tss2/ibmtss/RSA_Encrypt_fp.h new file mode 100644 index 0000000..d7be590 --- /dev/null +++ b/libstb/tss2/ibmtss/RSA_Encrypt_fp.h @@ -0,0 +1,89 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: RSA_Encrypt_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef RSA_ENCRYPT_FP_H +#define RSA_ENCRYPT_FP_H + +typedef struct { + TPMI_DH_OBJECT keyHandle; + TPM2B_PUBLIC_KEY_RSA message; + TPMT_RSA_DECRYPT inScheme; + TPM2B_DATA label; +} RSA_Encrypt_In; + +#define RC_RSA_Encrypt_keyHandle (TPM_RC_H + TPM_RC_1) +#define RC_RSA_Encrypt_message (TPM_RC_P + TPM_RC_1) +#define RC_RSA_Encrypt_inScheme (TPM_RC_P + TPM_RC_2) +#define RC_RSA_Encrypt_label (TPM_RC_P + TPM_RC_3) + +typedef struct { + TPM2B_PUBLIC_KEY_RSA outData; +} RSA_Encrypt_Out; + +TPM_RC +TPM2_RSA_Encrypt( + RSA_Encrypt_In *in, // IN: input parameter list + RSA_Encrypt_Out *out // OUT: output parameter list + ); + +#endif diff --git a/libstb/tss2/ibmtss/ReadClock_fp.h b/libstb/tss2/ibmtss/ReadClock_fp.h new file mode 100644 index 0000000..b0d7a68 --- /dev/null +++ b/libstb/tss2/ibmtss/ReadClock_fp.h @@ -0,0 +1,77 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: ReadClock_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef READCLOCK_FP_H +#define READCLOCK_FP_H + +typedef struct { + TPMS_TIME_INFO currentTime; +} ReadClock_Out; + +TPM_RC +TPM2_ReadClock( + ReadClock_Out *out // OUT: output parameter list + ); + + +#endif diff --git a/libstb/tss2/ibmtss/ReadPubek_fp.h b/libstb/tss2/ibmtss/ReadPubek_fp.h new file mode 100644 index 0000000..d2bf327 --- /dev/null +++ b/libstb/tss2/ibmtss/ReadPubek_fp.h @@ -0,0 +1,63 @@ +/********************************************************************************/ +/* */ +/* TPM 1.2 ReadPubek */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: ReadPubek_fp.h 1257 2018-06-27 20:52:08Z kgoldman $ */ +/* */ +/* (c) Copyright IBM Corporation 2018. */ +/* */ +/* All rights reserved. */ +/* */ +/* Redistribution and use in source and binary forms, with or without */ +/* modification, are permitted provided that the following conditions are */ +/* met: */ +/* */ +/* Redistributions of source code must retain the above copyright notice, */ +/* this list of conditions and the following disclaimer. */ +/* */ +/* 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. */ +/* */ +/* Neither the names of the IBM Corporation nor the names of its */ +/* contributors may be used to endorse or promote products derived from */ +/* this software without specific prior written permission. */ +/* */ +/* 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 READPUBEK_FP_H +#define READPUBEK_FP_H + +#include <ibmtss/tpmtypes12.h> +#include <ibmtss/tpmstructures12.h> + +#include <ibmtss/Implementation.h> + +typedef struct { + TPM_NONCE antiReplay; +} ReadPubek_In; + +typedef struct { + TPM_PUBKEY pubEndorsementKey; + TPM_DIGEST checksum; +} ReadPubek_Out; + +TPM_RC +TPM2_ReadPubek( + ReadPubek_In *in, // IN: input parameter buffer + ReadPubek_Out *out // OUT: output parameter buffer + ); + +#endif diff --git a/libstb/tss2/ibmtss/ReadPublic_fp.h b/libstb/tss2/ibmtss/ReadPublic_fp.h new file mode 100644 index 0000000..ad3fc2c --- /dev/null +++ b/libstb/tss2/ibmtss/ReadPublic_fp.h @@ -0,0 +1,84 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: ReadPublic_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef READPUBLIC_FP_H +#define READPUBLIC_FP_H + +typedef struct { + TPMI_DH_OBJECT objectHandle; +} ReadPublic_In; + +#define RC_ReadPublic_objectHandle (TPM_RC_H + TPM_RC_1) + +typedef struct { + TPM2B_PUBLIC outPublic; + TPM2B_NAME name; + TPM2B_NAME qualifiedName; +} ReadPublic_Out; + +TPM_RC +TPM2_ReadPublic( + ReadPublic_In *in, // IN: input parameter list + ReadPublic_Out *out // OUT: output parameter list + ); +#endif diff --git a/libstb/tss2/ibmtss/Rewrap_fp.h b/libstb/tss2/ibmtss/Rewrap_fp.h new file mode 100644 index 0000000..83b4b62 --- /dev/null +++ b/libstb/tss2/ibmtss/Rewrap_fp.h @@ -0,0 +1,92 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: Rewrap_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef REWRAP_FP_H +#define REWRAP_FP_H + +typedef struct { + TPMI_DH_OBJECT oldParent; + TPMI_DH_OBJECT newParent; + TPM2B_PRIVATE inDuplicate; + TPM2B_NAME name; + TPM2B_ENCRYPTED_SECRET inSymSeed; +} Rewrap_In; + +#define RC_Rewrap_oldParent (TPM_RC_H + TPM_RC_1) +#define RC_Rewrap_newParent (TPM_RC_H + TPM_RC_2) +#define RC_Rewrap_inDuplicate (TPM_RC_P + TPM_RC_1) +#define RC_Rewrap_name (TPM_RC_P + TPM_RC_2) +#define RC_Rewrap_inSymSeed (TPM_RC_P + TPM_RC_3) + +typedef struct { + TPM2B_PRIVATE outDuplicate; + TPM2B_ENCRYPTED_SECRET outSymSeed; +} Rewrap_Out; + +TPM_RC +TPM2_Rewrap( + Rewrap_In *in, // IN: input parameter list + Rewrap_Out *out // OUT: output parameter list + ); + +#endif diff --git a/libstb/tss2/ibmtss/SelfTest_fp.h b/libstb/tss2/ibmtss/SelfTest_fp.h new file mode 100644 index 0000000..322baa0 --- /dev/null +++ b/libstb/tss2/ibmtss/SelfTest_fp.h @@ -0,0 +1,78 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: SelfTest_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef SELFTEST_FP_H +#define SELFTEST_FP_H + +typedef struct{ + TPMI_YES_NO fullTest; +} SelfTest_In; + +#define RC_SelfTest_fullTest (TPM_RC_P + TPM_RC_1) + +TPM_RC +TPM2_SelfTest( + SelfTest_In *in // IN: input parameter list + ); + +#endif diff --git a/libstb/tss2/ibmtss/SequenceComplete_fp.h b/libstb/tss2/ibmtss/SequenceComplete_fp.h new file mode 100644 index 0000000..9064c96 --- /dev/null +++ b/libstb/tss2/ibmtss/SequenceComplete_fp.h @@ -0,0 +1,92 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: SequenceComplete_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef SEQUENCECOMPLETE_FP_H +#define SEQUENCECOMPLETE_FP_H + +typedef struct { + TPMI_DH_OBJECT sequenceHandle; + TPM2B_MAX_BUFFER buffer; + TPMI_RH_HIERARCHY hierarchy; +} SequenceComplete_In; + +#define RC_SequenceComplete_sequenceHandle (TPM_RC_H + TPM_RC_1) +#define RC_SequenceComplete_buffer (TPM_RC_P + TPM_RC_1) +#define RC_SequenceComplete_hierarchy (TPM_RC_P + TPM_RC_2) + + +typedef struct { + TPM2B_DIGEST result; + TPMT_TK_HASHCHECK validation; +} SequenceComplete_Out; + + + +TPM_RC +TPM2_SequenceComplete( + SequenceComplete_In *in, // IN: input parameter list + SequenceComplete_Out *out // OUT: output parameter list + ); + + +#endif diff --git a/libstb/tss2/ibmtss/SequenceUpdate_fp.h b/libstb/tss2/ibmtss/SequenceUpdate_fp.h new file mode 100644 index 0000000..dd09417 --- /dev/null +++ b/libstb/tss2/ibmtss/SequenceUpdate_fp.h @@ -0,0 +1,82 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: SequenceUpdate_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef SEQUENCEUPDATE_FP_H +#define SEQUENCEUPDATE_FP_H + + +typedef struct { + TPMI_DH_OBJECT sequenceHandle; + TPM2B_MAX_BUFFER buffer; +} SequenceUpdate_In; + +#define RC_SequenceUpdate_sequenceHandle (TPM_RC_P + TPM_RC_1) +#define RC_SequenceUpdate_buffer (TPM_RC_P + TPM_RC_2) + +TPM_RC +TPM2_SequenceUpdate( + SequenceUpdate_In *in // IN: input parameter list + ); + + +#endif diff --git a/libstb/tss2/ibmtss/SetAlgorithmSet_fp.h b/libstb/tss2/ibmtss/SetAlgorithmSet_fp.h new file mode 100644 index 0000000..c352f4d --- /dev/null +++ b/libstb/tss2/ibmtss/SetAlgorithmSet_fp.h @@ -0,0 +1,81 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: SetAlgorithmSet_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef SETALGORITHMSET_FP_H +#define SETALGORITHMSET_FP_H + +typedef struct { + TPMI_RH_PLATFORM authHandle; + UINT32 algorithmSet; +} SetAlgorithmSet_In; + +#define RC_SetAlgorithmSet_authHandle (TPM_RC_H + TPM_RC_1) +#define RC_SetAlgorithmSet_algorithmSet (TPM_RC_P + TPM_RC_1) + +TPM_RC +TPM2_SetAlgorithmSet( + SetAlgorithmSet_In *in // IN: input parameter list + ); + + +#endif diff --git a/libstb/tss2/ibmtss/SetCommandCodeAuditStatus_fp.h b/libstb/tss2/ibmtss/SetCommandCodeAuditStatus_fp.h new file mode 100644 index 0000000..1ddb50f --- /dev/null +++ b/libstb/tss2/ibmtss/SetCommandCodeAuditStatus_fp.h @@ -0,0 +1,84 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: SetCommandCodeAuditStatus_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef SETCOMMANDCODEAUDITSTATUS_FP_H +#define SETCOMMANDCODEAUDITSTATUS_FP_H + +typedef struct { + TPMI_RH_PROVISION auth; + TPMI_ALG_HASH auditAlg; + TPML_CC setList; + TPML_CC clearList; +} SetCommandCodeAuditStatus_In; + +#define RC_SetCommandCodeAuditStatus_auth (TPM_RC_H + TPM_RC_1) +#define RC_SetCommandCodeAuditStatus_auditAlg (TPM_RC_P + TPM_RC_1) +#define RC_SetCommandCodeAuditStatus_setList (TPM_RC_P + TPM_RC_2) +#define RC_SetCommandCodeAuditStatus_clearList (TPM_RC_P + TPM_RC_3) + +TPM_RC +TPM2_SetCommandCodeAuditStatus( + SetCommandCodeAuditStatus_In *in // IN: input parameter list + ); + +#endif diff --git a/libstb/tss2/ibmtss/SetPrimaryPolicy_fp.h b/libstb/tss2/ibmtss/SetPrimaryPolicy_fp.h new file mode 100644 index 0000000..4e586c9 --- /dev/null +++ b/libstb/tss2/ibmtss/SetPrimaryPolicy_fp.h @@ -0,0 +1,82 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: SetPrimaryPolicy_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef SETPRIMARYPOLICY_FP_H +#define SETPRIMARYPOLICY_FP_H + +typedef struct { + TPMI_RH_HIERARCHY_AUTH authHandle; + TPM2B_DIGEST authPolicy; + TPMI_ALG_HASH hashAlg; +} SetPrimaryPolicy_In; + +#define RC_SetPrimaryPolicy_authHandle (TPM_RC_H + TPM_RC_1) +#define RC_SetPrimaryPolicy_authPolicy (TPM_RC_P + TPM_RC_1) +#define RC_SetPrimaryPolicy_hashAlg (TPM_RC_P + TPM_RC_2) + +TPM_RC +TPM2_SetPrimaryPolicy( + SetPrimaryPolicy_In *in // IN: input parameter list + ); + +#endif diff --git a/libstb/tss2/ibmtss/Shutdown_fp.h b/libstb/tss2/ibmtss/Shutdown_fp.h new file mode 100644 index 0000000..51c6bc3 --- /dev/null +++ b/libstb/tss2/ibmtss/Shutdown_fp.h @@ -0,0 +1,79 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: Shutdown_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef SHUTDOWN_FP_H +#define SHUTDOWN_FP_H + +typedef struct{ + TPM_SU shutdownType; +} Shutdown_In; + +#define RC_Shutdown_shutdownType (TPM_RC_P + TPM_RC_1) + +TPM_RC +TPM2_Shutdown( + Shutdown_In *in // IN: input parameter list + ); + + +#endif diff --git a/libstb/tss2/ibmtss/Sign12_fp.h b/libstb/tss2/ibmtss/Sign12_fp.h new file mode 100644 index 0000000..72cdd18 --- /dev/null +++ b/libstb/tss2/ibmtss/Sign12_fp.h @@ -0,0 +1,65 @@ +/********************************************************************************/ +/* */ +/* TPM 1.2 Sign12 */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: Sign12_fp.h 1257 2018-06-27 20:52:08Z kgoldman $ */ +/* */ +/* (c) Copyright IBM Corporation 2018. */ +/* */ +/* All rights reserved. */ +/* */ +/* Redistribution and use in source and binary forms, with or without */ +/* modification, are permitted provided that the following conditions are */ +/* met: */ +/* */ +/* Redistributions of source code must retain the above copyright notice, */ +/* this list of conditions and the following disclaimer. */ +/* */ +/* 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. */ +/* */ +/* Neither the names of the IBM Corporation nor the names of its */ +/* contributors may be used to endorse or promote products derived from */ +/* this software without specific prior written permission. */ +/* */ +/* 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 SIGN12_FP_H +#define SIGN12_FP_H + +#include <ibmtss/tpmtypes12.h> +#include <ibmtss/tpmstructures12.h> + +#include <ibmtss/Implementation.h> + +typedef struct { + TPM_KEY_HANDLE keyHandle; + UINT32 areaToSignSize; + BYTE areaToSign[MAX_COMMAND_SIZE]; +} Sign12_In; + +typedef struct { + UINT32 sigSize; + BYTE sig[MAX_RSA_KEY_BYTES]; +} Sign12_Out; + +TPM_RC +TPM2_Sign12( + Sign12_In *in, // IN: input parameter buffer + Sign12_Out *out // OUT: output parameter buffer + ); + +#endif diff --git a/libstb/tss2/ibmtss/Sign_fp.h b/libstb/tss2/ibmtss/Sign_fp.h new file mode 100644 index 0000000..41feb75 --- /dev/null +++ b/libstb/tss2/ibmtss/Sign_fp.h @@ -0,0 +1,89 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: Sign_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef SIGN_FP_H +#define SIGN_FP_H + +typedef struct { + TPMI_DH_OBJECT keyHandle; + TPM2B_DIGEST digest; + TPMT_SIG_SCHEME inScheme; + TPMT_TK_HASHCHECK validation; +} Sign_In; + +#define RC_Sign_keyHandle (TPM_RC_H + TPM_RC_1) +#define RC_Sign_digest (TPM_RC_P + TPM_RC_1) +#define RC_Sign_inScheme (TPM_RC_P + TPM_RC_2) +#define RC_Sign_validation (TPM_RC_P + TPM_RC_3) + +typedef struct { + TPMT_SIGNATURE signature; +} Sign_Out; + +TPM_RC +TPM2_Sign( + Sign_In *in, // IN: input parameter list + Sign_Out *out // OUT: output parameter list + ); + +#endif diff --git a/libstb/tss2/ibmtss/StartAuthSession_fp.h b/libstb/tss2/ibmtss/StartAuthSession_fp.h new file mode 100644 index 0000000..cc3bce9 --- /dev/null +++ b/libstb/tss2/ibmtss/StartAuthSession_fp.h @@ -0,0 +1,97 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: StartAuthSession_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef STARTAUTHSESSION_FP_H +#define STARTAUTHSESSION_FP_H + +typedef struct { + TPMI_DH_OBJECT tpmKey; + TPMI_DH_ENTITY bind; + TPM2B_NONCE nonceCaller; + TPM2B_ENCRYPTED_SECRET encryptedSalt; + TPM_SE sessionType; + TPMT_SYM_DEF symmetric; + TPMI_ALG_HASH authHash; +} StartAuthSession_In; + +typedef struct { + TPMI_SH_AUTH_SESSION sessionHandle; + TPM2B_NONCE nonceTPM; +} StartAuthSession_Out; + +#define RC_StartAuthSession_tpmKey (TPM_RC_H + TPM_RC_1) +#define RC_StartAuthSession_bind (TPM_RC_H + TPM_RC_2) +#define RC_StartAuthSession_nonceCaller (TPM_RC_P + TPM_RC_1) +#define RC_StartAuthSession_encryptedSalt (TPM_RC_P + TPM_RC_2) +#define RC_StartAuthSession_sessionType (TPM_RC_P + TPM_RC_3) +#define RC_StartAuthSession_symmetric (TPM_RC_P + TPM_RC_4) +#define RC_StartAuthSession_authHash (TPM_RC_P + TPM_RC_5) + +TPM_RC +TPM2_StartAuthSession( + StartAuthSession_In *in, // IN: input parameter buffer + StartAuthSession_Out *out // OUT: output parameter buffer + ); + + +#endif diff --git a/libstb/tss2/ibmtss/Startup12_fp.h b/libstb/tss2/ibmtss/Startup12_fp.h new file mode 100644 index 0000000..5a015da --- /dev/null +++ b/libstb/tss2/ibmtss/Startup12_fp.h @@ -0,0 +1,50 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: Startup12_fp.h 1257 2018-06-27 20:52:08Z kgoldman $ */ +/* */ +/* (c) Copyright IBM Corporation 2018 */ +/* */ +/* All rights reserved. */ +/* */ +/* Redistribution and use in source and binary forms, with or without */ +/* modification, are permitted provided that the following conditions are */ +/* met: */ +/* */ +/* Redistributions of source code must retain the above copyright notice, */ +/* this list of conditions and the following disclaimer. */ +/* */ +/* 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. */ +/* */ +/* Neither the names of the IBM Corporation nor the names of its */ +/* contributors may be used to endorse or promote products derived from */ +/* this software without specific prior written permission. */ +/* */ +/* 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 STARTUP12_FP_H +#define STARTUP12_FP_H + +#include <ibmtss/tpmtypes12.h> + +typedef struct { + TPM_STARTUP_TYPE startupType; +} Startup12_In; + + +#endif diff --git a/libstb/tss2/ibmtss/Startup_fp.h b/libstb/tss2/ibmtss/Startup_fp.h new file mode 100644 index 0000000..337232f --- /dev/null +++ b/libstb/tss2/ibmtss/Startup_fp.h @@ -0,0 +1,84 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: Startup_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef STARTUP_FP_H +#define STARTUP_FP_H + +void +_TPM_Init( + void + ); + + +typedef struct { + TPM_SU startupType; +} Startup_In; + +#define RC_Startup_startupType (TPM_RC_P + TPM_RC_1) + +TPM_RC +TPM2_Startup( + Startup_In *in // IN: input parameter list + ); + +#endif diff --git a/libstb/tss2/ibmtss/StirRandom_fp.h b/libstb/tss2/ibmtss/StirRandom_fp.h new file mode 100644 index 0000000..bbfc411 --- /dev/null +++ b/libstb/tss2/ibmtss/StirRandom_fp.h @@ -0,0 +1,78 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: StirRandom_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef STIRRANDOM_FP_H +#define STIRRANDOM_FP_H + +typedef struct { + TPM2B_SENSITIVE_DATA inData; +} StirRandom_In; + +#define RC_StirRandom_inData (TPM_RC_P + TPM_RC_1) + +TPM_RC +TPM2_StirRandom( + StirRandom_In *in // IN: input parameter list + ); + +#endif diff --git a/libstb/tss2/ibmtss/TPMB.h b/libstb/tss2/ibmtss/TPMB.h new file mode 100644 index 0000000..ff15390 --- /dev/null +++ b/libstb/tss2/ibmtss/TPMB.h @@ -0,0 +1,104 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: TPMB.h 1257 2018-06-27 20:52:08Z 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, 2016 */ +/* */ +/********************************************************************************/ + +#ifndef TPMB_H +#define TPMB_H + +/* 5.20 TPMB.h */ +/* This file contains extra TPM2B structures */ +#ifndef _TPMB_H +#define _TPMB_H +/* TPM2B Types */ +typedef struct { + UINT16 size; + BYTE buffer[1]; +} TPM2B, *P2B; +typedef const TPM2B *PC2B; +/* This macro helps avoid having to type in the structure in order to create a new TPM2B type that + is used in a function. */ +#define TPM2B_TYPE(name, bytes) \ + typedef union { \ + struct { \ + UINT16 size; \ + BYTE buffer[(bytes)]; \ + } t; \ + TPM2B b; \ + } TPM2B_##name +/* This macro defines a TPM2B with a constant character value. This macro sets the size of the + string to the size minus the terminating zero byte. This lets the user of the label add their + terminating 0. This method is chosen so that existing code that provides a label will continue to + work correctly. */ +#define TPM2B_STRING(name, value) \ + static const union { \ + struct { \ + UINT16 size; \ + BYTE buffer[sizeof(value)]; \ + } t; \ + TPM2B b; \ + } name##_ = {{sizeof(value), {value}}}; \ + const TPM2B *name = &name##_.b +/* Macro to to instance and initialize a TPM2B value */ +#define TPM2B_INIT(TYPE, name) \ + TPM2B_##TYPE name = {sizeof(name.t.buffer), {0}} +#define TPM2B_BYTE_VALUE(bytes) TPM2B_TYPE(bytes##_BYTE_VALUE, bytes) +#endif + +#endif diff --git a/libstb/tss2/ibmtss/TPM_Types.h b/libstb/tss2/ibmtss/TPM_Types.h new file mode 100644 index 0000000..f6b5224 --- /dev/null +++ b/libstb/tss2/ibmtss/TPM_Types.h @@ -0,0 +1,2813 @@ +/********************************************************************************/ +/* */ +/* Headers from Part 2 */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* */ +/* 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, 2012-2018 */ +/* */ +/********************************************************************************/ + +/* rev 124 */ + +#ifndef _TPM_TYPES_H +#define _TPM_TYPES_H + +#include <stdint.h> + +#include <ibmtss/Implementation.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/* + The C bit field is non-portable, but the TPM specification reference implementation uses them. + + These two macros attempt to define the TPM specification bit fields for little and big endian + machines. There is no guarantee that either will work with a specific compiler or tool chain. If + not, the developer must create a custom structure. + + TPM_BITFIELD_LE - little endian + TPM_BITFIELD_BE - big endian + + To access the structures as uint's for marshaling and unmarshaling, each bit field is a union with + an integral field called 'val'. + + Yes, I know that this uses anonymous structs, but the alternative yields another level of + deferencing, and will likely break more code. I hope your compiler supports this recent addition + to the standard. + + For portable code: + + If neither macro is defined, this header defines the structures as uint32_t. It defines constants + for the various bits, and can be used as: + + variable & CONSTANT (test for set) + !(variable & CONSTANT) (test for clear) + variable &= CONSTANT (to set) + variable |= ~CONSTANT (to clear) + + Although the portable structures are all uint32_t, some only use the least significant 8 bits and + are marshalled as a uint_8t. +*/ + +/* Table 3 - Definition of Base Types */ +/* In BaseTypes.h */ + +/* Table 4 - Defines for Logic Values */ +// In Table 39 (Yes, NO) +/* In bool.h (TRUE, FALSE) */ +#define SET 1 +#define CLEAR 0 + +/* Part 4 5.5 Capabilities.h */ + +#define MAX_CAP_DATA (MAX_CAP_BUFFER-sizeof(TPM_CAP)-sizeof(UINT32)) +#define MAX_CAP_ALGS (MAX_CAP_DATA/sizeof(TPMS_ALG_PROPERTY)) +#define MAX_CAP_HANDLES (MAX_CAP_DATA/sizeof(TPM_HANDLE)) +#define MAX_CAP_CC (MAX_CAP_DATA/sizeof(TPM_CC)) +#define MAX_TPM_PROPERTIES (MAX_CAP_DATA/sizeof(TPMS_TAGGED_PROPERTY)) +#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)) + +/* Table 5 - Definition of Types for Documentation Clarity */ + +typedef UINT32 TPM_ALGORITHM_ID; /* this is the 1.2 compatible form of the TPM_ALG_ID */ +typedef UINT32 TPM_MODIFIER_INDICATOR; +typedef UINT32 TPM_AUTHORIZATION_SIZE; /* the authorizationSize parameter in a command */ +typedef UINT32 TPM_PARAMETER_SIZE; /* the parameterSizeset parameter in a command */ +typedef UINT16 TPM_KEY_SIZE; /* a key size in octets */ +typedef UINT16 TPM_KEY_BITS; /* a key size in bits */ + +/* Table 6 - Definition of (UINT32) TPM_SPEC Constants <> */ + +typedef UINT32 TPM_SPEC; + +#define TPM_SPEC_FAMILY 0x322E3000 /* ASCII "2.0" with null terminator */ +#define TPM_SPEC_LEVEL 00 /* the level number for the specification */ +#define TPM_SPEC_VERSION 124 /* the version number of the spec (01.21 * 100) */ +#define TPM_SPEC_YEAR 2015 /* the year of the version */ +#define TPM_SPEC_DAY_OF_YEAR 191 /* the day of the year */ + + +/* Table 7 - Definition of (UINT32) TPM_GENERATED Constants <O> */ + +typedef UINT32 TPM_GENERATED; + +#define TPM_GENERATED_VALUE 0xff544347 /* 0xFF 'TCG' (FF 54 43 47) */ + +/* Table 9 - Definition of (UINT16) TPM_ALG_ID Constants <IN/OUT, S> */ + +typedef UINT16 TPM_ALG_ID; + +/* Table 10 - Definition of (UINT16) {ECC} TPM_ECC_CURVE Constants <IN/OUT, S> */ + +typedef UINT16 TPM_ECC_CURVE; + +/* Table 16 - Definition of (UINT32) TPM_RC Constants (Actions) <OUT> */ + +typedef UINT32 TPM_RC; + +#define TPM_RC_SUCCESS 0x000 +#define TPM_RC_BAD_TAG 0x01E /* defined for compatibility with TPM 1.2 */ + +#define RC_VER1 0x100 /* set for all format 0 response codes */ + +#define TPM_RC_INITIALIZE (RC_VER1 + 0x000) /* TPM not initialized by TPM2_Startup or already initialized */ +#define TPM_RC_FAILURE (RC_VER1 + 0x001) /* commands not being accepted because of a TPM failure */ +#define TPM_RC_SEQUENCE (RC_VER1 + 0x003) /* improper use of a sequence handle */ +#define TPM_RC_PRIVATE (RC_VER1 + 0x00B) /* not currently used */ +#define TPM_RC_HMAC (RC_VER1 + 0x019) /* not currently used */ +#define TPM_RC_DISABLED (RC_VER1 + 0x020) /* the command is disabled */ +#define TPM_RC_EXCLUSIVE (RC_VER1 + 0x021) /* command failed because audit sequence required exclusivity */ +#define TPM_RC_AUTH_TYPE (RC_VER1 + 0x024) /* authorization handle is not correct for command */ +#define TPM_RC_AUTH_MISSING (RC_VER1 + 0x025) /* command requires an authorization session + for handle and it is not present. */ +#define TPM_RC_POLICY (RC_VER1 + 0x026) /* policy failure in math Operation or an invalid authPolicy value */ +#define TPM_RC_PCR (RC_VER1 + 0x027) /* PCR check fail */ +#define TPM_RC_PCR_CHANGED (RC_VER1 + 0x028) /* PCR have changed since checked. */ +#define TPM_RC_UPGRADE (RC_VER1 + 0x02D) /* for all commands other than + TPM2_FieldUpgradeData(), this code + indicates that the TPM is in field + upgrade mode */ +#define TPM_RC_TOO_MANY_CONTEXTS (RC_VER1 + 0x02E) /* context ID counter is at maximum. */ +#define TPM_RC_AUTH_UNAVAILABLE (RC_VER1 + 0x02F) /* authValue or authPolicy is not available for selected entity. */ +#define TPM_RC_REBOOT (RC_VER1 + 0x030) /* a _TPM_Init and Startup(CLEAR) is + required before the TPM can resume + operation. */ +#define TPM_RC_UNBALANCED (RC_VER1 + 0x031) /* the protection algorithms (hash and + symmetric) are not reasonably balanced */ +#define TPM_RC_COMMAND_SIZE (RC_VER1 + 0x042) /* command commandSize value is inconsistent + with contents of the command buffer */ +#define TPM_RC_COMMAND_CODE (RC_VER1 + 0x043) /* command code not supported */ +#define TPM_RC_AUTHSIZE (RC_VER1 + 0x044) /* the value of authorizationSize is out of range */ +#define TPM_RC_AUTH_CONTEXT (RC_VER1 + 0x045) /* use of an authorization session with a + context command or another command that + cannot have an authorization session.*/ +#define TPM_RC_NV_RANGE (RC_VER1 + 0x046) /* NV offset+size is out of range. */ +#define TPM_RC_NV_SIZE (RC_VER1 + 0x047) /* Requested allocation size is larger than allowed. */ +#define TPM_RC_NV_LOCKED (RC_VER1 + 0x048) /* NV access locked. */ +#define TPM_RC_NV_AUTHORIZATION (RC_VER1 + 0x049) /* NV access authorization fails in command + actions (this failure does not affect + lockout.action) */ +#define TPM_RC_NV_UNINITIALIZED (RC_VER1 + 0x04A) /* an NV Index is used before being + initialized or the state saved by + TPM2_Shutdown(STATE) could not be + restored */ +#define TPM_RC_NV_SPACE (RC_VER1 + 0x04B) /* insufficient space for NV allocation */ +#define TPM_RC_NV_DEFINED (RC_VER1 + 0x04C) /* NV Index or persistent object already defined */ +#define TPM_RC_BAD_CONTEXT (RC_VER1 + 0x050) /* context in TPM2_ContextLoad() is not valid */ +#define TPM_RC_CPHASH (RC_VER1 + 0x051) /* cpHash value already set or not correct for use */ +#define TPM_RC_PARENT (RC_VER1 + 0x052) /* handle for parent is not a valid parent */ +#define TPM_RC_NEEDS_TEST (RC_VER1 + 0x053) /* some function needs testing. */ +#define TPM_RC_NO_RESULT (RC_VER1 + 0x054) /* returned when an internal function cannot + process a request due to an unspecified + problem. */ +#define TPM_RC_SENSITIVE (RC_VER1 + 0x055) /* the sensitive area did not unmarshal correctly after decryption */ +#define RC_MAX_FM0 (RC_VER1 + 0x07F) /* largest version 1 code that is not a warning */ + +/* The codes in this group may have a value added to them to indicate the handle, session, or + parameter to which they apply. */ + +#define RC_FMT1 0x080 /* This bit is SET in all format 1 response codes */ + +#define TPM_RC_ASYMMETRIC (RC_FMT1 + 0x001) /* asymmetric algorithm not supported or not correct */ +#define TPM_RC_ATTRIBUTES (RC_FMT1 + 0x002) /* inconsistent attributes */ +#define TPM_RC_HASH (RC_FMT1 + 0x003) /* hash algorithm not supported or not appropriate */ +#define TPM_RC_VALUE (RC_FMT1 + 0x004) /* value is out of range or is not correct for the context */ +#define TPM_RC_HIERARCHY (RC_FMT1 + 0x005) /* hierarchy is not enabled or is not correct for the use */ +#define TPM_RC_KEY_SIZE (RC_FMT1 + 0x007) /* key size is not supported */ +#define TPM_RC_MGF (RC_FMT1 + 0x008) /* mask generation function not supported */ +#define TPM_RC_MODE (RC_FMT1 + 0x009) /* mode of operation not supported */ +#define TPM_RC_TYPE (RC_FMT1 + 0x00A) /* the type of the value is not appropriate for the use */ +#define TPM_RC_HANDLE (RC_FMT1 + 0x00B) /* the handle is not correct for the use */ +#define TPM_RC_KDF (RC_FMT1 + 0x00C) /* unsupported key derivation function or + function not appropriate for use */ +#define TPM_RC_RANGE (RC_FMT1 + 0x00D) /* value was out of allowed range. */ +#define TPM_RC_AUTH_FAIL (RC_FMT1 + 0x00E) /* the authorization HMAC check failed and DA counter incremented */ +#define TPM_RC_NONCE (RC_FMT1 + 0x00F) /* invalid nonce size or nonce value mismatch */ +#define TPM_RC_PP (RC_FMT1 + 0x010) /* authorization requires assertion of PP */ +#define TPM_RC_SCHEME (RC_FMT1 + 0x012) /* unsupported or incompatible scheme */ +#define TPM_RC_SIZE (RC_FMT1 + 0x015) /* structure is the wrong size */ +#define TPM_RC_SYMMETRIC (RC_FMT1 + 0x016) /* unsupported symmetric algorithm or key + size, or not appropriate for instance */ +#define TPM_RC_TAG (RC_FMT1 + 0x017) /* incorrect structure tag */ +#define TPM_RC_SELECTOR (RC_FMT1 + 0x018) /* union selector is incorrect */ +#define TPM_RC_INSUFFICIENT (RC_FMT1 + 0x01A) /* the TPM was unable to unmarshal a value + because there were not enough octets in + the input buffer */ +#define TPM_RC_SIGNATURE (RC_FMT1 + 0x01B) /* the signature is not valid */ +#define TPM_RC_KEY (RC_FMT1 + 0x01C) /* key fields are not compatible with the selected use */ +#define TPM_RC_POLICY_FAIL (RC_FMT1 + 0x01D) /* a policy check failed */ +#define TPM_RC_INTEGRITY (RC_FMT1 + 0x01F) /* integrity check failed */ +#define TPM_RC_TICKET (RC_FMT1 + 0x020) /* invalid ticket */ +#define TPM_RC_RESERVED_BITS (RC_FMT1 + 0x021) /* reserved bits not set to zero as required */ +#define TPM_RC_BAD_AUTH (RC_FMT1 + 0x022) /* authorization failure without DA implications */ +#define TPM_RC_EXPIRED (RC_FMT1 + 0x023) /* the policy has expired */ +#define TPM_RC_POLICY_CC (RC_FMT1 + 0x024) /* the commandCode in the policy is not the + commandCode of the command */ +#define TPM_RC_BINDING (RC_FMT1 + 0x025) /* public and sensitive portions of an + object are not cryptographically bound */ +#define TPM_RC_CURVE (RC_FMT1 + 0x026) /* curve not supported */ +#define TPM_RC_ECC_POINT (RC_FMT1 + 0x027) /* point is not on the required curve. */ + +/* aliases for FMT1 commands when parameter number can be added */ + +#define TPM_RCS_VALUE TPM_RC_VALUE +#define TPM_RCS_TYPE TPM_RC_TYPE +#define TPM_RCS_HANDLE TPM_RC_HANDLE +#define TPM_RCS_SIZE TPM_RC_SIZE +#define TPM_RCS_ATTRIBUTES TPM_RC_ATTRIBUTES +#define TPM_RCS_NONCE TPM_RC_NONCE +#define TPM_RCS_SYMMETRIC TPM_RC_SYMMETRIC +#define TPM_RCS_MODE TPM_RC_MODE +#define TPM_RCS_SCHEME TPM_RC_SCHEME +#define TPM_RCS_KEY TPM_RC_KEY +#define TPM_RCS_ECC_POINT TPM_RC_ECC_POINT +#define TPM_RCS_HASH TPM_RC_HASH +#define TPM_RCS_HIERARCHY TPM_RC_HIERARCHY +#define TPM_RCS_TICKET TPM_RC_TICKET +#define TPM_RCS_RANGE TPM_RC_RANGE +#define TPM_RCS_INTEGRITY TPM_RC_INTEGRITY +#define TPM_RCS_POLICY_CC TPM_RC_POLICY_CC +#define TPM_RCS_EXPIRED TPM_RC_EXPIRED + +#define RC_WARN 0x900 /* set for warning response codes */ + +#define TPM_RC_CONTEXT_GAP (RC_WARN + 0x001) /* gap for context ID is too large */ +#define TPM_RC_OBJECT_MEMORY (RC_WARN + 0x002) /* out of memory for object contexts */ +#define TPM_RC_SESSION_MEMORY (RC_WARN + 0x003) /* out of memory for session contexts */ +#define TPM_RC_MEMORY (RC_WARN + 0x004) /* out of shared object/session memory or + need space for internal operations */ +#define TPM_RC_SESSION_HANDLES (RC_WARN + 0x005) /* out of session handles - a session must + be flushed before a new session may be + created */ +#define TPM_RC_OBJECT_HANDLES (RC_WARN + 0x006) /* out of object handles - the handle space + for objects is depleted and a reboot is + required */ +#define TPM_RC_LOCALITY (RC_WARN + 0x007) /* bad locality */ +#define TPM_RC_YIELDED (RC_WARN + 0x008) /* the TPM has suspended operation on the + command; forward progress was made and + the command may be retried. */ +#define TPM_RC_CANCELED (RC_WARN + 0x009) /* the command was canceled */ +#define TPM_RC_CANCELLED TPM_RC_CANCELED +#define TPM_RC_TESTING (RC_WARN + 0x00A) /* TPM is performing self-tests */ +#define TPM_RC_REFERENCE_H0 (RC_WARN + 0x010) /* the 1st handle in the handle area + references a transient object or session + that is not loaded */ +#define TPM_RC_REFERENCE_H1 (RC_WARN + 0x011) /* the 2nd handle in the handle area + references a transient object or session + that is not loaded */ +#define TPM_RC_REFERENCE_H2 (RC_WARN + 0x012) /* the 3rd handle in the handle area + references a transient object or session + that is not loaded */ +#define TPM_RC_REFERENCE_H3 (RC_WARN + 0x013) /* the 4th handle in the handle area + references a transient object or session + that is not loaded */ +#define TPM_RC_REFERENCE_H4 (RC_WARN + 0x014) /* the 5th handle in the handle area + references a transient object or session + that is not loaded */ +#define TPM_RC_REFERENCE_H5 (RC_WARN + 0x015) /* the 6th handle in the handle area + references a transient object or session + that is not loaded */ +#define TPM_RC_REFERENCE_H6 (RC_WARN + 0x016) /* the 7th handle in the handle area + references a transient object or session + that is not loaded */ +#define TPM_RC_REFERENCE_S0 (RC_WARN + 0x018) /* the 1st authorization session handle + references a session that is not + loaded */ +#define TPM_RC_REFERENCE_S1 (RC_WARN + 0x019) /* the 2nd authorization session handle + references a session that is not + loaded */ +#define TPM_RC_REFERENCE_S2 (RC_WARN + 0x01A) /* the 3rd authorization session handle + references a session that is not + loaded */ +#define TPM_RC_REFERENCE_S3 (RC_WARN + 0x01B) /* the 4th authorization session handle + references a session that is not + loaded */ +#define TPM_RC_REFERENCE_S4 (RC_WARN + 0x01C) /* the 5th session handle references a + session that is not loaded */ +#define TPM_RC_REFERENCE_S5 (RC_WARN + 0x01D) /* the 6th session handle references a session that is not loaded */ +#define TPM_RC_REFERENCE_S6 (RC_WARN + 0x01E) /* the 7th authorization session handle + references a session that is not + loaded */ +#define TPM_RC_NV_RATE (RC_WARN + 0x020) /* the TPM is rate-limiting accesses to prevent wearout of NV */ +#define TPM_RC_LOCKOUT (RC_WARN + 0x021) /* authorizations for objects subject to DA + protection are not allowed at this time + because the TPM is in DA lockout mode */ +#define TPM_RC_RETRY (RC_WARN + 0x022) /* the TPM was not able to start the command */ +#define TPM_RC_NV_UNAVAILABLE (RC_WARN + 0x023) /* the command may require writing of NV and + NV is not current accessible */ +#define TPM_RC_NOT_USED (RC_WARN + 0x07F) /* this value is reserved and shall not be returned by the TPM */ + +#define TPM_RC_H 0x000 /* add to a handle-related error */ +#define TPM_RC_P 0x040 /* add to a parameter-related error */ +#define TPM_RC_S 0x800 /* add to a session-related error */ +#define TPM_RC_1 0x100 /* add to a parameter-, handle-, or session-related error */ +#define TPM_RC_2 0x200 /* add to a parameter-, handle-, or session-related error */ +#define TPM_RC_3 0x300 /* add to a parameter-, handle-, or session-related error */ +#define TPM_RC_4 0x400 /* add to a parameter-, handle-, or session-related error */ +#define TPM_RC_5 0x500 /* add to a parameter-, handle-, or session-related error */ +#define TPM_RC_6 0x600 /* add to a parameter-, handle-, or session-related error */ +#define TPM_RC_7 0x700 /* add to a parameter-, handle-, or session-related error */ +#define TPM_RC_8 0x800 /* add to a parameter-related error */ +#define TPM_RC_9 0x900 /* add to a parameter-related error */ +#define TPM_RC_A 0xA00 /* add to a parameter-related error */ +#define TPM_RC_B 0xB00 /* add to a parameter-related error */ +#define TPM_RC_C 0xC00 /* add to a parameter-related error */ +#define TPM_RC_D 0xD00 /* add to a parameter-related error */ +#define TPM_RC_E 0xE00 /* add to a parameter-related error */ +#define TPM_RC_F 0xF00 /* add to a parameter-related error */ +#define TPM_RC_N_MASK 0xF00 /* number mask */ + +/* Table 17 - Definition of (INT8) TPM_CLOCK_ADJUST Constants <IN> */ + +typedef INT8 TPM_CLOCK_ADJUST; + +#define TPM_CLOCK_COARSE_SLOWER -3 /* Slow the Clock update rate by one coarse adjustment step. */ +#define TPM_CLOCK_MEDIUM_SLOWER -2 /* Slow the Clock update rate by one medium adjustment step. */ +#define TPM_CLOCK_FINE_SLOWER -1 /* Slow the Clock update rate by one fine adjustment step. */ +#define TPM_CLOCK_NO_CHANGE 0 /* No change to the Clock update rate. */ +#define TPM_CLOCK_FINE_FASTER 1 /* Speed the Clock update rate by one fine adjustment step. */ +#define TPM_CLOCK_MEDIUM_FASTER 2 /* Speed the Clock update rate by one medium adjustment step. */ +#define TPM_CLOCK_COARSE_FASTER 3 /* Speed the Clock update rate by one coarse adjustment step. */ + +/* Table 18 - Definition of (UINT16) TPM_EO Constants <IN/OUT> */ + +typedef UINT16 TPM_EO; + +#define TPM_EO_EQ 0x0000 /* A = B */ +#define TPM_EO_NEQ 0x0001 /* A != B */ +#define TPM_EO_SIGNED_GT 0x0002 /* A > B signed */ +#define TPM_EO_UNSIGNED_GT 0x0003 /* A > B unsigned */ +#define TPM_EO_SIGNED_LT 0x0004 /* A < B signed */ +#define TPM_EO_UNSIGNED_LT 0x0005 /* A < B unsigned */ +#define TPM_EO_SIGNED_GE 0x0006 /* A = B signed */ +#define TPM_EO_UNSIGNED_GE 0x0007 /* A = B unsigned */ +#define TPM_EO_SIGNED_LE 0x0008 /* A = B signed */ +#define TPM_EO_UNSIGNED_LE 0x0009 /* A = B unsigned */ +#define TPM_EO_BITSET 0x000A /* All bits SET in B are SET in A. ((A&B)=B) */ +#define TPM_EO_BITCLEAR 0x000B /* All bits SET in B are CLEAR in A. ((A&B)=0) */ + +/* Table 19 - Definition of (UINT16) TPM_ST Constants <IN/OUT, S> */ + +typedef UINT16 TPM_ST; + +#define TPM_ST_RSP_COMMAND 0x00C4 /* tag value for a response */ +#define TPM_ST_NULL 0X8000 /* no structure type specified */ +#define TPM_ST_NO_SESSIONS 0x8001 /* command/response has no attached sessions*/ +#define TPM_ST_SESSIONS 0x8002 /* command/response has one or more attached sessions*/ +#define TPM_ST_ATTEST_NV 0x8014 /* tag for an attestation structure */ +#define TPM_ST_ATTEST_COMMAND_AUDIT 0x8015 /* tag for an attestation structure */ +#define TPM_ST_ATTEST_SESSION_AUDIT 0x8016 /* tag for an attestation structure */ +#define TPM_ST_ATTEST_CERTIFY 0x8017 /* tag for an attestation structure */ +#define TPM_ST_ATTEST_QUOTE 0x8018 /* tag for an attestation structure */ +#define TPM_ST_ATTEST_TIME 0x8019 /* tag for an attestation structure */ +#define TPM_ST_ATTEST_CREATION 0x801A /* tag for an attestation structure */ +#define TPM_ST_CREATION 0x8021 /* tag for a ticket type */ +#define TPM_ST_VERIFIED 0x8022 /* tag for a ticket type */ +#define TPM_ST_AUTH_SECRET 0x8023 /* tag for a ticket type */ +#define TPM_ST_HASHCHECK 0x8024 /* tag for a ticket type */ +#define TPM_ST_AUTH_SIGNED 0x8025 /* tag for a ticket type */ +#define TPM_ST_FU_MANIFEST 0x8029 /* tag for a structure describing a Field Upgrade Policy */ + +/* Table 20 - Definition of (UINT16) TPM_SU Constants <IN> */ + +typedef UINT16 TPM_SU; + +#define TPM_SU_CLEAR 0x0000 /* on TPM2_Startup(), indicates that the TPM should perform TPM Reset or TPM Restart */ +#define TPM_SU_STATE 0x0001 /* on TPM2_Startup(), indicates that the TPM should restore the + state saved by TPM2_Shutdown(TPM_SU_STATE) */ +/* Table 21 - Definition of (UINT8) TPM_SE Constants <IN> */ + +typedef UINT8 TPM_SE; + +#define TPM_SE_HMAC 0x00 +#define TPM_SE_POLICY 0x01 +#define TPM_SE_TRIAL 0x03 + +/* Table 22 - Definition of (UINT32) TPM_CAP Constants */ + +typedef UINT32 TPM_CAP; + +#define TPM_CAP_FIRST 0x00000000 /* */ +#define TPM_CAP_ALGS 0x00000000 /* TPM_ALG_ID(1) TPML_ALG_PROPERTY */ +#define TPM_CAP_HANDLES 0x00000001 /* TPM_HANDLE TPML_HANDLE */ +#define TPM_CAP_COMMANDS 0x00000002 /* TPM_CC TPML_CCA */ +#define TPM_CAP_PP_COMMANDS 0x00000003 /* TPM_CC TPML_CC */ +#define TPM_CAP_AUDIT_COMMANDS 0x00000004 /* TPM_CC TPML_CC */ +#define TPM_CAP_PCRS 0x00000005 /* reserved TPML_PCR_SELECTION */ +#define TPM_CAP_TPM_PROPERTIES 0x00000006 /* TPM_PT TPML_TAGGED_TPM_PROPERTY */ +#define TPM_CAP_PCR_PROPERTIES 0x00000007 /* TPM_PT_PCR TPML_TAGGED_PCR_PROPERTY */ +#define TPM_CAP_ECC_CURVES 0x00000008 /* TPM_ECC_CURVE(1) TPML_ECC_CURVE */ +#define TPM_CAP_AUTH_POLICIES 0x00000009 /* TPML_TAGGED_POLICY */ +#define TPM_CAP_LAST 0x00000009 /* */ +#define TPM_CAP_VENDOR_PROPERTY 0x00000100 /* manufacturer specific manufacturer-specific values */ + +/* Table 23 - Definition of (UINT32) TPM_PT Constants <IN/OUT, S> */ + +typedef UINT32 TPM_PT; + +#define TPM_PT_NONE 0x00000000 /* indicates no property type */ +#define PT_GROUP 0x00000100 /* The number of properties in each group. */ +#define PT_FIXED (PT_GROUP * 1) /* the group of fixed properties returned as TPMS_TAGGED_PROPERTY */ + +/* The values in this group are only changed due to a firmware change in the TPM. */ + +#define TPM_PT_FAMILY_INDICATOR (PT_FIXED + 0) /* a 4-octet character string containing the + TPM Family value (TPM_SPEC_FAMILY) */ +#define TPM_PT_LEVEL (PT_FIXED + 1) /* the level of the specification */ +#define TPM_PT_REVISION (PT_FIXED + 2) /* the specification Revision times 100 */ +#define TPM_PT_DAY_OF_YEAR (PT_FIXED + 3) /* the specification day of year using TCG calendar */ +#define TPM_PT_YEAR (PT_FIXED + 4) /* the specification year using the CE */ +#define TPM_PT_MANUFACTURER (PT_FIXED + 5) /* the vendor ID unique to each TPM manufacturer */ +#define TPM_PT_VENDOR_STRING_1 (PT_FIXED + 6) /* the first four characters of the vendor ID string */ +#define TPM_PT_VENDOR_STRING_2 (PT_FIXED + 7) /* the second four characters of the vendor ID string */ +#define TPM_PT_VENDOR_STRING_3 (PT_FIXED + 8) /* the third four characters of the vendor ID string */ +#define TPM_PT_VENDOR_STRING_4 (PT_FIXED + 9) /* the fourth four characters of the vendor ID sting */ +#define TPM_PT_VENDOR_TPM_TYPE (PT_FIXED + 10) /* vendor-defined value indicating the TPM model */ +#define TPM_PT_FIRMWARE_VERSION_1 (PT_FIXED + 11) /* the most-significant 32 bits of a TPM + vendor-specific value indicating the + version number of the firmware */ +#define TPM_PT_FIRMWARE_VERSION_2 (PT_FIXED + 12) /* the least-significant 32 bits of a TPM + vendor-specific value indicating the + version number of the firmware */ +#define TPM_PT_INPUT_BUFFER (PT_FIXED + 13) /* the maximum size of a parameter + (typically, a TPM2B_MAX_BUFFER) */ +#define TPM_PT_HR_TRANSIENT_MIN (PT_FIXED + 14) /* the minimum number of transient objects + that can be held in TPM RAM */ +#define TPM_PT_HR_PERSISTENT_MIN (PT_FIXED + 15) /* the minimum number of persistent objects + that can be held in TPM NV memory */ +#define TPM_PT_HR_LOADED_MIN (PT_FIXED + 16) /* the minimum number of authorization + sessions that can be held in TPM RAM */ +#define TPM_PT_ACTIVE_SESSIONS_MAX (PT_FIXED + 17) /* the number of authorization sessions that + may be active at a time */ +#define TPM_PT_PCR_COUNT (PT_FIXED + 18) /* the number of PCR implemented */ +#define TPM_PT_PCR_SELECT_MIN (PT_FIXED + 19) /* the minimum number of octets in a + TPMS_PCR_SELECT.sizeOfSelect */ +#define TPM_PT_CONTEXT_GAP_MAX (PT_FIXED + 20) /* the maximum allowed difference (unsigned) + between the contextID values of two saved + session contexts */ +#define TPM_PT_NV_COUNTERS_MAX (PT_FIXED + 22) /* the maximum number of NV Indexes that are + allowed to have TPM_NV_COUNTER attribute SET */ +#define TPM_PT_NV_INDEX_MAX (PT_FIXED + 23) /* the maximum size of an NV Index data area */ +#define TPM_PT_MEMORY (PT_FIXED + 24) /* a TPMA_MEMORY indicating the memory + management method for the TPM */ +#define TPM_PT_CLOCK_UPDATE (PT_FIXED + 25) /* interval, in milliseconds, between + updates to the copy of + TPMS_CLOCK_INFO.clock in NV */ +#define TPM_PT_CONTEXT_HASH (PT_FIXED + 26) /* the algorithm used for the integrity HMAC + on saved contexts and for hashing the + fuData of TPM2_FirmwareRead() */ +#define TPM_PT_CONTEXT_SYM (PT_FIXED + 27) /* TPM_ALG_ID, the algorithm used for + encryption of saved contexts */ +#define TPM_PT_CONTEXT_SYM_SIZE (PT_FIXED + 28) /* TPM_KEY_BITS, the size of the key used + for encryption of saved contexts */ +#define TPM_PT_ORDERLY_COUNT (PT_FIXED + 29) /* the modulus - 1 of the count for NV + update of an orderly counter */ +#define TPM_PT_MAX_COMMAND_SIZE (PT_FIXED + 30) /* the maximum value for commandSize in a command */ +#define TPM_PT_MAX_RESPONSE_SIZE (PT_FIXED + 31) /* the maximum value for responseSize in a response */ +#define TPM_PT_MAX_DIGEST (PT_FIXED + 32) /* the maximum size of a digest that can be + produced by the TPM */ +#define TPM_PT_MAX_OBJECT_CONTEXT (PT_FIXED + 33) /* the maximum size of an object context + that will be returned by + TPM2_ContextSave */ +#define TPM_PT_MAX_SESSION_CONTEXT (PT_FIXED + 34) /* the maximum size of a session context + that will be returned by + TPM2_ContextSave */ +#define TPM_PT_PS_FAMILY_INDICATOR (PT_FIXED + 35) /* platform-specific family (a TPM_PS + value)(see Table 26) */ +#define TPM_PT_PS_LEVEL (PT_FIXED + 36) /* the level of the platform-specific specification */ +#define TPM_PT_PS_REVISION (PT_FIXED + 37) /* the specification Revision times 100 for + the platform-specific specification */ +#define TPM_PT_PS_DAY_OF_YEAR (PT_FIXED + 38) /* the platform-specific specification day + of year using TCG calendar */ +#define TPM_PT_PS_YEAR (PT_FIXED + 39) /* the platform-specific specification year + using the CE */ +#define TPM_PT_SPLIT_MAX (PT_FIXED + 40) /* the number of split signing operations + supported by the TPM */ +#define TPM_PT_TOTAL_COMMANDS (PT_FIXED + 41) /* total number of commands implemented in the TPM */ +#define TPM_PT_LIBRARY_COMMANDS (PT_FIXED + 42) /* number of commands from the TPM library + that are implemented */ +#define TPM_PT_VENDOR_COMMANDS (PT_FIXED + 43) /* number of vendor commands that are implemented */ +#define TPM_PT_NV_BUFFER_MAX (PT_FIXED + 44) /* the maximum data size in one NV write command */ +#define TPM_PT_MODES (PT_FIXED + 45) /* a TPMA_MODES value, indicating that the + TPM is designed for these modes. */ +#define TPM_PT_MAX_CAP_BUFFER (PT_FIXED + 46) /* the maximum size of a + TPMS_CAPABILITY_DATA structure returned + in TPM2_GetCapability(). */ +#define PT_VAR (PT_GROUP * 2) /* the group of variable properties returned + as TPMS_TAGGED_PROPERTY */ + +/* The properties in this group change because of a Protected Capability other than a firmware + update. The values are not necessarily persistent across all power transitions. */ + +#define TPM_PT_PERMANENT (PT_VAR + 0) /* TPMA_PERMANENT */ +#define TPM_PT_STARTUP_CLEAR (PT_VAR + 1) /* TPMA_STARTUP_CLEAR */ +#define TPM_PT_HR_NV_INDEX (PT_VAR + 2) /* the number of NV Indexes currently defined */ +#define TPM_PT_HR_LOADED (PT_VAR + 3) /* the number of authorization sessions + currently loaded into TPM RAM */ +#define TPM_PT_HR_LOADED_AVAIL (PT_VAR + 4) /* the number of additional authorization + sessions, of any type, that could be + loaded into TPM RAM */ +#define TPM_PT_HR_ACTIVE (PT_VAR + 5) /* the number of active authorization + sessions currently being tracked by the + TPM */ +#define TPM_PT_HR_ACTIVE_AVAIL (PT_VAR + 6) /* the number of additional authorization + sessions, of any type, that could be + created */ +#define TPM_PT_HR_TRANSIENT_AVAIL (PT_VAR + 7) /* estimate of the number of additional + transient objects that could be loaded + into TPM RAM */ +#define TPM_PT_HR_PERSISTENT (PT_VAR + 8) /* the number of persistent objects + currently loaded into TPM NV memory */ +#define TPM_PT_HR_PERSISTENT_AVAIL (PT_VAR + 9) /* the number of additional persistent + objects that could be loaded into NV + memory */ +#define TPM_PT_NV_COUNTERS (PT_VAR + 10) /* the number of defined NV Indexes that + have the NV TPM_NV_COUNTER attribute SET */ +#define TPM_PT_NV_COUNTERS_AVAIL (PT_VAR + 11) /* the number of additional NV Indexes that + can be defined with their TPM_NT of TPM_NV_COUNTER + and the TPM_NV_ORDERLY attribute SET */ +#define TPM_PT_ALGORITHM_SET (PT_VAR + 12) /* code that limits the algorithms that may + be used with the TPM */ +#define TPM_PT_LOADED_CURVES (PT_VAR + 13) /* the number of loaded ECC curves */ +#define TPM_PT_LOCKOUT_COUNTER (PT_VAR + 14) /* the current value of the lockout counter (failedTries) */ +#define TPM_PT_MAX_AUTH_FAIL (PT_VAR + 15) /* the number of authorization failures + before DA lockout is invoked */ +#define TPM_PT_LOCKOUT_INTERVAL (PT_VAR + 16) /* the number of seconds before the value + reported by TPM_PT_LOCKOUT_COUNTER is + decremented */ +#define TPM_PT_LOCKOUT_RECOVERY (PT_VAR + 17) /* the number of seconds after a lockoutAuth + failure before use of lockoutAuth may be + attempted again */ +#define TPM_PT_NV_WRITE_RECOVERY (PT_VAR + 18) /* number of milliseconds before the TPM + will accept another command that will + modify NV */ +#define TPM_PT_AUDIT_COUNTER_0 (PT_VAR + 19) /* the high-order 32 bits of the command audit counter */ +#define TPM_PT_AUDIT_COUNTER_1 (PT_VAR + 20) /* the low-order 32 bits of the command audit counter */ + +/* Table 24 - Definition of (UINT32) TPM_PT_PCR Constants <IN/OUT, S> */ + +typedef UINT32 TPM_PT_PCR; + +#define TPM_PT_PCR_FIRST 0x00000000 /* bottom of the range of TPM_PT_PCR properties */ +#define TPM_PT_PCR_SAVE 0x00000000 /* a SET bit in the TPMS_PCR_SELECT indicates that + the PCR is saved and restored by TPM_SU_STATE */ +#define TPM_PT_PCR_EXTEND_L0 0x00000001 /* a SET bit in the TPMS_PCR_SELECT indicates that + the PCR may be extended from locality 0 */ +#define TPM_PT_PCR_RESET_L0 0x00000002 /* a SET bit in the TPMS_PCR_SELECT indicates that + the PCR may be reset by TPM2_PCR_Reset() from + locality 0 */ +#define TPM_PT_PCR_EXTEND_L1 0x00000003 /* a SET bit in the TPMS_PCR_SELECT indicates that + the PCR may be extended from locality 1 */ +#define TPM_PT_PCR_RESET_L1 0x00000004 /* a SET bit in the TPMS_PCR_SELECT indicates that + the PCR may be reset by TPM2_PCR_Reset() from + locality 1 */ +#define TPM_PT_PCR_EXTEND_L2 0x00000005 /* a SET bit in the TPMS_PCR_SELECT indicates that + the PCR may be extended from locality 2 */ +#define TPM_PT_PCR_RESET_L2 0x00000006 /* a SET bit in the TPMS_PCR_SELECT indicates that + the PCR may be reset by TPM2_PCR_Reset() from + locality 2 */ +#define TPM_PT_PCR_EXTEND_L3 0x00000007 /* a SET bit in the TPMS_PCR_SELECT indicates that + the PCR may be extended from locality 3 */ +#define TPM_PT_PCR_RESET_L3 0x00000008 /* a SET bit in the TPMS_PCR_SELECT indicates that + the PCR may be reset by TPM2_PCR_Reset() from + locality 3 */ +#define TPM_PT_PCR_EXTEND_L4 0x00000009 /* a SET bit in the TPMS_PCR_SELECT indicates that + the PCR may be extended from locality 4 */ +#define TPM_PT_PCR_RESET_L4 0x0000000A /* a SET bit in the TPMS_PCR_SELECT indicates that + the PCR may be reset by TPM2_PCR_Reset() from + locality 4 */ +#define TPM_PT_PCR_NO_INCREMENT 0x00000011 /* a SET bit in the TPMS_PCR_SELECT indicates that + modifications to this PCR (reset or Extend) will + not increment the pcrUpdateCounter */ +#define TPM_PT_PCR_RESET_L4 0x0000000A /* a SET bit in the TPMS_PCR_SELECT indicates that + the PCR may be reset by TPM2_PCR_Reset() from + locality 4 */ +#define TPM_PT_PCR_DRTM_RESET 0x00000012 /* a SET bit in the TPMS_PCR_SELECT indicates that + the PCR is reset by a DRTM event */ +#define TPM_PT_PCR_POLICY 0x00000013 /* a SET bit in the TPMS_PCR_SELECT indicates that + the PCR is controlled by policy */ +#define TPM_PT_PCR_AUTH 0x00000014 /* a SET bit in the TPMS_PCR_SELECT indicates that + the PCR is controlled by an authorization + value */ +#define TPM_PT_PCR_LAST 0x00000014 /* top of the range of TPM_PT_PCR properties of the + implementation */ + +/* Table 25 - Definition of (UINT32) TPM_PS Constants <OUT> */ + +typedef UINT32 TPM_PS; + +#define TPM_PS_MAIN 0x00000000 /* not platform specific */ +#define TPM_PS_PC 0x00000001 /* PC Client */ +#define TPM_PS_PDA 0x00000002 /* PDA (includes all mobile devices that are not + specifically cell phones) */ +#define TPM_PS_CELL_PHONE 0x00000003 /* Cell Phone */ +#define TPM_PS_SERVER 0x00000004 /* Server WG */ +#define TPM_PS_PERIPHERAL 0x00000005 /* Peripheral WG */ +#define TPM_PS_TSS 0x00000006 /* TSS WG */ +#define TPM_PS_STORAGE 0x00000007 /* Storage WG */ +#define TPM_PS_AUTHENTICATION 0x00000008 /* Authentication WG */ +#define TPM_PS_EMBEDDED 0x00000009 /* Embedded WG */ +#define TPM_PS_HARDCOPY 0x0000000A /* Hardcopy WG */ +#define TPM_PS_INFRASTRUCTURE 0x0000000B /* Infrastructure WG */ +#define TPM_PS_VIRTUALIZATION 0x0000000C /* Virtualization WG */ +#define TPM_PS_TNC 0x0000000D /* Trusted Network Connect WG */ +#define TPM_PS_MULTI_TENANT 0x0000000E /* Multi-tenant WG */ +#define TPM_PS_TC 0x0000000F /* Technical Committee*/ + +/* Table 26 - Definition of Types for Handles */ + +typedef UINT32 TPM_HANDLE; /* Handles may refer to objects (keys or data blobs), authorization + sessions (HMAC and policy), NV Indexes, permanent TPM locations, + and PCR. */ + +/* Table 27 - Definition of (UINT8) TPM_HT Constants <S> */ + +typedef UINT8 TPM_HT; + +#define TPM_HT_PCR 0x00 /* PCR - consecutive numbers, starting at 0, that reference the PCR registers */ +#define TPM_HT_NV_INDEX 0x01 /* NV Index - assigned by the caller */ +#define TPM_HT_HMAC_SESSION 0x02 /* HMAC Authorization Session - assigned by the TPM when the session is created */ +#define TPM_HT_LOADED_SESSION 0x02 /* Loaded Authorization Session - used only in the context of TPM2_GetCapability */ +#define TPM_HT_POLICY_SESSION 0x03 /* Policy Authorization Session - assigned by the TPM when the session is created */ +#define TPM_HT_SAVED_SESSION 0x03 /* Saved Authorization Session - used only in the context of TPM2_GetCapability */ +#define TPM_HT_PERMANENT 0x40 /* Permanent Values - assigned by this specification in Table 27 */ +#define TPM_HT_TRANSIENT 0x80 /* Transient Objects - assigned by the TPM when an object is + loaded into transient-object memory or when a persistent + object is converted to a transient object */ +#define TPM_HT_PERSISTENT 0x81 /* Persistent Objects - assigned by the TPM when a loaded + transient object is made persistent */ + +/* Table 28 - Definition of (TPM_HANDLE) TPM_RH Constants <S> */ + +typedef TPM_HANDLE TPM_RH; + +#define TPM_RH_FIRST 0x40000000 /* R */ +#define TPM_RH_SRK 0x40000000 /* R not used1 */ +#define TPM_RH_OWNER 0x40000001 /* K, A, P handle references the Storage Primary + Seed (SPS), the ownerAuth, and the ownerPolicy */ +#define TPM_RH_REVOKE 0x40000002 /* R not used1 */ +#define TPM_RH_TRANSPORT 0x40000003 /* R not used1 */ +#define TPM_RH_OPERATOR 0x40000004 /* R not used1 */ +#define TPM_RH_ADMIN 0x40000005 /* R not used1 */ +#define TPM_RH_EK 0x40000006 /* R not used1 */ +#define TPM_RH_NULL 0x40000007 /* K, A, P a handle associated with the null + hierarchy, an EmptyAuth authValue, and an Empty + Policy authPolicy. */ +#define TPM_RH_UNASSIGNED 0x40000008 /* R value reserved to the TPM to indicate a handle + location that has not been initialized or + assigned */ +#define TPM_RS_PW 0x40000009 /* S authorization value used to indicate a password + authorization session */ +#define TPM_RH_LOCKOUT 0x4000000A /* A references the authorization associated with + the dictionary attack lockout reset */ +#define TPM_RH_ENDORSEMENT 0x4000000B /* K, A, P references the Endorsement Primary Seed + (EPS), endorsementAuth, and endorsementPolicy */ +#define TPM_RH_PLATFORM 0x4000000C /* K, A, P references the Platform Primary Seed + (PPS), platformAuth, and platformPolicy */ +#define TPM_RH_PLATFORM_NV 0x4000000D /* C for phEnableNV */ +#define TPM_RH_AUTH_00 0x40000010 /* A Start of a range of authorization values that + are vendor-specific. A TPM may support any of + the values in this range as are needed for + vendor-specific purposes. Disabled if ehEnable is CLEAR. */ +#define TPM_RH_AUTH_FF 0x4000010F /* A End of the range of vendor-specific + authorization values. */ +#define TPM_RH_LAST 0x4000010F /* R the top of the reserved handle area */ + +/* Table 29 - Definition of (TPM_HANDLE) TPM_HC Constants <S> */ + +#define HR_HANDLE_MASK 0x00FFFFFF /* to mask off the HR */ +#define HR_RANGE_MASK 0xFF000000 /* to mask off the variable part */ +#define HR_SHIFT 24 +#define HR_PCR (TPM_HT_PCR << HR_SHIFT) +#define HR_HMAC_SESSION (TPM_HT_HMAC_SESSION << HR_SHIFT) +#define HR_POLICY_SESSION (TPM_HT_POLICY_SESSION << HR_SHIFT) +#define HR_TRANSIENT (TPM_HT_TRANSIENT << HR_SHIFT) +#define HR_PERSISTENT (TPM_HT_PERSISTENT << HR_SHIFT) +#define HR_NV_INDEX (TPM_HT_NV_INDEX << HR_SHIFT) +#define HR_PERMANENT (TPM_HT_PERMANENT << HR_SHIFT) +#define PCR_FIRST (HR_PCR + 0) /* first PCR */ +#define PCR_LAST (HR_PCR | HR_HANDLE_MASK) /* last PCR in range */ +#define HMAC_SESSION_FIRST (HR_HMAC_SESSION + 0) /* first HMAC session */ +#define HMAC_SESSION_LAST (HMAC_SESSION_FIRST | HR_HANDLE_MASK) /* last HMAC session */ +#define LOADED_SESSION_FIRST HMAC_SESSION_FIRST /* used in GetCapability */ +#define LOADED_SESSION_LAST HMAC_SESSION_LAST /* used in GetCapability */ +#define POLICY_SESSION_FIRST (HR_POLICY_SESSION + 0) /* first policy session */ +#define POLICY_SESSION_LAST (POLICY_SESSION_FIRST | HR_HANDLE_MASK) /* last policy session */ +#define TRANSIENT_FIRST ((UINT32)(HR_TRANSIENT + 0)) /* first transient object */ +#define ACTIVE_SESSION_FIRST POLICY_SESSION_FIRST /* used in GetCapability */ +#define ACTIVE_SESSION_LAST POLICY_SESSION_LAST /* used in GetCapability */ +#define TRANSIENT_LAST ((UINT32)(TRANSIENT_FIRST | HR_HANDLE_MASK)) /* last transient object */ +#define PERSISTENT_FIRST ((UINT32)(HR_PERSISTENT + 0)) /* first persistent object */ +#define PERSISTENT_LAST ((UINT32)(PERSISTENT_FIRST | HR_HANDLE_MASK)) /* last persistent object */ +#define PLATFORM_PERSISTENT (PERSISTENT_FIRST + 0x00800000) /* first platform persistent object */ +#define NV_INDEX_FIRST (HR_NV_INDEX + 0) /* first allowed NV Index */ +#define NV_INDEX_LAST (NV_INDEX_FIRST | HR_HANDLE_MASK) /* last allowed NV Index */ +#define PERMANENT_FIRST TPM_RH_FIRST +#define PERMANENT_LAST TPM_RH_LAST + +/* Table 30 - Definition of (UINT32) TPMA_ALGORITHM Bits */ + +#if defined TPM_BITFIELD_LE + +typedef union { + struct { + unsigned int asymmetric : 1; /* 0 an asymmetric algorithm with public and private portions */ + unsigned int symmetric : 1; /* 1 a symmetric block cipher */ + unsigned int hash : 1; /* a hash algorithm */ + unsigned int object : 1; /* an algorithm that may be used as an object type */ + unsigned int Reserved1 : 4; /* 7:4 */ + unsigned int signing : 1; /* 8 a signing algorithm */ + unsigned int encrypting : 1; /* 9 an encryption/decryption algorithm */ + unsigned int method : 1; /* 10 a method such as a key derivative function (KDF) */ + unsigned int Reserved2 : 21; /* 31:11 */ + }; + UINT32 val; +} TPMA_ALGORITHM; + +#elif defined TPM_BITFIELD_BE + +typedef union { + struct { + unsigned int Reserved2 : 21; /* 31:11 */ + unsigned int method : 1; /* 10 a method such as a key derivative function (KDF) */ + unsigned int encrypting : 1; /* 9 an encryption/decryption algorithm */ + unsigned int signing : 1; /* 8 a signing algorithm */ + unsigned int Reserved1 : 4; /* 7:4 */ + unsigned int object : 1; /* an algorithm that may be used as an object type */ + unsigned int hash : 1; /* a hash algorithm */ + unsigned int symmetric : 1; /* 1 a symmetric block cipher */ + unsigned int asymmetric : 1; /* 0 an asymmetric algorithm with public and private portions */ + }; + UINT32 val; +} TPMA_ALGORITHM; + +#else + +typedef struct { + UINT32 val; +} TPMA_ALGORITHM; + +#endif + +#define TPMA_ALGORITHM_ASYMMETRIC 0x00000001 +#define TPMA_ALGORITHM_SYMMETRIC 0x00000002 +#define TPMA_ALGORITHM_HASH 0x00000004 +#define TPMA_ALGORITHM_OBJECT 0x00000008 +#define TPMA_ALGORITHM_RESERVED1 0x000000f0 +#define TPMA_ALGORITHM_SIGNING 0x00000100 +#define TPMA_ALGORITHM_ENCRYPTING 0x00000200 +#define TPMA_ALGORITHM_METHOD 0x00000400 +#define TPMA_ALGORITHM_RESERVED2 0xfffff800 + +#define TPMA_ALGORITHM_RESERVED ( \ + TPMA_ALGORITHM_RESERVED1 | \ + TPMA_ALGORITHM_RESERVED2 ) + +/* Table 31 - Definition of (UINT32) TPMA_OBJECT Bits */ + +#if defined TPM_BITFIELD_LE + +typedef union { + struct { + unsigned int Reserved1 : 1; /* 0 shall be zero */ + unsigned int fixedTPM : 1; /* 1 The hierarchy of the object, as indicated by its Qualified Name, may not change. */ + unsigned int stClear : 1; /* 2 Previously saved contexts of this object may not be loaded after Startup(CLEAR). */ + unsigned int Reserved2 : 1; /* 3 shall be zero */ + unsigned int fixedParent : 1; /* 4 The parent of the object may not change. */ + unsigned int sensitiveDataOrigin : 1; /* 5 the TPM generated all of the sensitive data other than the authValue. */ + unsigned int userWithAuth : 1; /* 6 HMAC session or with a password */ + unsigned int adminWithPolicy : 1; /* 7 policy session. */ + unsigned int Reserved3 : 2; /* 9:8 shall be zero */ + unsigned int noDA : 1; /* 10 The object is not subject to dictionary attack protections. */ + unsigned int encryptedDuplication : 1; /* 11 */ + unsigned int Reserved4 : 4; /* 15:12 shall be zero */ + unsigned int restricted : 1; /* 16 Key usage is restricted to manipulate structures of known format */ + unsigned int decrypt : 1; /* 17 The private portion of the key may be used to decrypt. */ + unsigned int sign : 1; /* 18 For a symmetric cipher object, the private + portion of the key may be used to encrypt. For + other objects, the private portion of the key may + be used to sign. */ + unsigned int Reserved5 : 13; /* 31:19 shall be zero */ + }; + UINT32 val; +} TPMA_OBJECT; + +#elif defined TPM_BITFIELD_BE + +typedef union { + struct { + unsigned int Reserved5 : 13; /* 31:19 shall be zero */ + unsigned int sign : 1; /* 18 For a symmetric cipher object, the private + portion of the key may be used to encrypt. For + other objects, the private portion of the key may + be used to sign. */ + unsigned int decrypt : 1; /* 17 The private portion of the key may be used to decrypt. */ + unsigned int restricted : 1; /* 16 Key usage is restricted to manipulate structures of known format */ + unsigned int Reserved4 : 4; /* 15:12 shall be zero */ + unsigned int encryptedDuplication : 1; /* 11 */ + unsigned int noDA : 1; /* 10 The object is not subject to dictionary attack protections. */ + unsigned int Reserved3 : 2; /* 9:8 shall be zero */ + unsigned int adminWithPolicy : 1; /* 7 policy session. */ + unsigned int userWithAuth : 1; /* 6 HMAC session or with a password */ + unsigned int sensitiveDataOrigin : 1; /* 5 the TPM generated all of the sensitive data other than the authValue. */ + unsigned int fixedParent : 1; /* 4 The parent of the object may not change. */ + unsigned int Reserved2 : 1; /* 3 shall be zero */ + unsigned int stClear : 1; /* 2 Previously saved contexts of this object may not be loaded after Startup(CLEAR). */ + unsigned int fixedTPM : 1; /* 1 The hierarchy of the object, as indicated by its Qualified Name, may not change. */ + unsigned int Reserved1 : 1; /* 0 shall be zero */ + }; + UINT32 val; +} TPMA_OBJECT; + +#else + +typedef struct { + UINT32 val; +} TPMA_OBJECT; + +#endif + +#define TPMA_OBJECT_RESERVED1 0x00000001 +#define TPMA_OBJECT_FIXEDTPM 0x00000002 +#define TPMA_OBJECT_STCLEAR 0x00000004 +#define TPMA_OBJECT_RESERVED2 0x00000008 +#define TPMA_OBJECT_FIXEDPARENT 0x00000010 +#define TPMA_OBJECT_SENSITIVEDATAORIGIN 0x00000020 +#define TPMA_OBJECT_USERWITHAUTH 0x00000040 +#define TPMA_OBJECT_ADMINWITHPOLICY 0x00000080 +#define TPMA_OBJECT_RESERVED3 0x00000300 +#define TPMA_OBJECT_NODA 0x00000400 +#define TPMA_OBJECT_ENCRYPTEDDUPLICATION 0x00000800 +#define TPMA_OBJECT_RESERVED4 0x0000f000 +#define TPMA_OBJECT_RESTRICTED 0x00010000 +#define TPMA_OBJECT_DECRYPT 0x00020000 +#define TPMA_OBJECT_SIGN 0x00040000 +#define TPMA_OBJECT_RESERVED5 0xfff80000 + +#define TPMA_OBJECT_RESERVED ( \ + TPMA_OBJECT_RESERVED1 | \ + TPMA_OBJECT_RESERVED2 | \ + TPMA_OBJECT_RESERVED3 | \ + TPMA_OBJECT_RESERVED4 | \ + TPMA_OBJECT_RESERVED5 ) + +/* Table 32 - Definition of (UINT8) TPMA_SESSION Bits <IN/OUT> */ + +#if defined TPM_BITFIELD_LE + +typedef union { + struct { + unsigned int continueSession : 1; /* 0 the session is to remain active after successful completion of the command */ + unsigned int auditExclusive : 1; /* 1 executed if the session is exclusive at the start of the command */ + unsigned int auditReset : 1; /* 2 audit digest of the session should be initialized */ + unsigned int Reserved : 2; /* 4:3 shall be CLEAR */ + unsigned int decrypt : 1; /* 5 first parameter in the command is symmetrically encrypted */ + unsigned int encrypt : 1; /* 6 TPM should use this session to encrypt the first parameter in the response */ + unsigned int audit : 1; /* 7 session is for audit */ + }; + UINT8 val; +} TPMA_SESSION; + +#elif defined TPM_BITFIELD_BE + +typedef union { + struct { + unsigned int audit : 1; /* 7 session is for audit */ + unsigned int encrypt : 1; /* 6 TPM should use this session to encrypt the first parameter in the response */ + unsigned int decrypt : 1; /* 5 first parameter in the command is symmetrically encrypted */ + unsigned int Reserved : 2; /* 4:3 shall be CLEAR */ + unsigned int auditReset : 1; /* 2 audit digest of the session should be initialized */ + unsigned int auditExclusive : 1; /* 1 executed if the session is exclusive at the start of the command */ + unsigned int continueSession : 1; /* 0 the session is to remain active after successful completion of the command */ + }; + UINT8 val; +} TPMA_SESSION; + +#else + +typedef struct { + UINT8 val; +} TPMA_SESSION; + +#endif + +#define TPMA_SESSION_CONTINUESESSION 0x01 +#define TPMA_SESSION_AUDITEXCLUSIVE 0x02 +#define TPMA_SESSION_AUDITRESET 0x04 +#define TPMA_SESSION_DECRYPT 0x20 +#define TPMA_SESSION_ENCRYPT 0x40 +#define TPMA_SESSION_AUDIT 0x80 + +#define TPMA_SESSION_RESERVED 0x18 + +/* Table 33 - Definition of (UINT8) TPMA_LOCALITY Bits <IN/OUT> */ + +#if defined TPM_BITFIELD_LE + +typedef union { + struct { + unsigned int TPM_LOC_ZERO : 1; /* 0 */ + unsigned int TPM_LOC_ONE : 1; /* 1 */ + unsigned int TPM_LOC_TWO : 1; /* 2 */ + unsigned int TPM_LOC_THREE : 1; /* 3 */ + unsigned int TPM_LOC_FOUR : 1; /* 4 */ + unsigned int Extended : 3; /* 7:5 */ + }; + UINT8 val; +} TPMA_LOCALITY; + +#elif defined TPM_BITFIELD_BE + +typedef union { + struct { + unsigned int Extended : 3; /* 7:5 */ + unsigned int TPM_LOC_FOUR : 1; /* 4 */ + unsigned int TPM_LOC_THREE : 1; /* 3 */ + unsigned int TPM_LOC_TWO : 1; /* 2 */ + unsigned int TPM_LOC_ONE : 1; /* 1 */ + unsigned int TPM_LOC_ZERO : 1; /* 0 */ + }; + UINT8 val; +} TPMA_LOCALITY; + +#else + +typedef struct { + UINT8 val; +} TPMA_LOCALITY; + +#endif + +#define TPMA_LOCALITY_ZERO 0x01 +#define TPMA_LOCALITY_ONE 0x02 +#define TPMA_LOCALITY_TWO 0x04 +#define TPMA_LOCALITY_THREE 0x08 +#define TPMA_LOCALITY_FOUR 0x10 +#define TPMA_LOCALITY_EXTENDED 0xe0 + +/* Table 34 - Definition of (UINT32) TPMA_PERMANENT Bits <OUT> */ + +#if defined TPM_BITFIELD_LE + +typedef union { + struct { + unsigned int ownerAuthSet : 1; /* 0 TPM2_HierarchyChangeAuth() with ownerAuth has been executed since the last TPM2_Clear(). */ + unsigned int endorsementAuthSet : 1; /* 1 TPM2_HierarchyChangeAuth() with endorsementAuth has been executed since the last TPM2_Clear(). */ + unsigned int lockoutAuthSet : 1; /* 2 TPM2_HierarchyChangeAuth() with lockoutAuth has been executed since the last TPM2_Clear(). */ + unsigned int Reserved1 : 5; /* 7:3 */ + unsigned int disableClear : 1; /* 8 TPM2_Clear() is disabled. */ + unsigned int inLockout : 1; /* 9 The TPM is in lockout and commands that require authorization + with other than Platform Authorization or Lockout Authorization will not succeed. */ + unsigned int tpmGeneratedEPS : 1; /* 10 The EPS was created by the TPM. */ + unsigned int Reserved2 : 21; /* 31:11 */ + }; + UINT32 val; +} TPMA_PERMANENT; + +#elif defined TPM_BITFIELD_BE + +typedef union { + struct { + unsigned int Reserved2 : 21; /* 31:11 */ + unsigned int tpmGeneratedEPS : 1; /* 10 The EPS was created by the TPM. */ + unsigned int inLockout : 1; /* 9 The TPM is in lockout and commands that require authorization with other than Platform Authorization will not succeed. */ + unsigned int disableClear : 1; /* 8 TPM2_Clear() is disabled. */ + unsigned int Reserved1 : 5; /* 7:3 */ + unsigned int lockoutAuthSet : 1; /* 2 TPM2_HierarchyChangeAuth() with lockoutAuth has been executed since the last TPM2_Clear(). */ + unsigned int endorsementAuthSet : 1; /* 1 TPM2_HierarchyChangeAuth() with endorsementAuth has been executed since the last TPM2_Clear(). */ + unsigned int ownerAuthSet : 1; /* 0 TPM2_HierarchyChangeAuth() with ownerAuth has been executed since the last TPM2_Clear(). */ + }; + UINT32 val; +} TPMA_PERMANENT; + +#else + +typedef struct { + UINT32 val; +} TPMA_PERMANENT; + +#endif + +#define TPMA_PERMANENT_OWNERAUTHSET 0x00000001 +#define TPMA_PERMANENT_ENDORSEMENTAUTHSET 0x00000002 +#define TPMA_PERMANENT_LOCKOUTAUTHSET 0x00000004 +#define TPMA_PERMANENT_RESERVED1 0x000000f8 +#define TPMA_PERMANENT_DISABLECLEAR 0x00000100 +#define TPMA_PERMANENT_INLOCKOUT 0x00000200 +#define TPMA_PERMANENT_TPMGENERATEDEPS 0x00000400 +#define TPMA_PERMANENT_RESERVED2 0xfffff800 + +/* Table 35 - Definition of (UINT32) TPMA_STARTUP_CLEAR Bits <OUT> */ + +#if defined TPM_BITFIELD_LE + +typedef union { + struct { + unsigned int phEnable : 1; /* 0 The platform hierarchy is enabled and platformAuth or platformPolicy may be used for authorization. */ + unsigned int shEnable : 1; /* 1 The Storage hierarchy is enabled and ownerAuth or ownerPolicy may be used for authorization. */ + unsigned int ehEnable : 1; /* 2 The EPS hierarchy is enabled and endorsementAuth may be used to authorize commands. */ + unsigned int phEnableNV : 1; /* 3 NV indices that have TPMA_PLATFORM_CREATE SET may be read or written. */ + unsigned int Reserved : 27; /* 30:4 shall be zero */ + unsigned int orderly : 1; /* 31 The TPM received a TPM2_Shutdown() and a matching TPM2_Startup(). */ + }; + UINT32 val; +} TPMA_STARTUP_CLEAR; + +#elif defined TPM_BITFIELD_BE + +typedef union { + struct { + unsigned int orderly : 1; /* 31 The TPM received a TPM2_Shutdown() and a matching TPM2_Startup(). */ + unsigned int Reserved : 27; /* 30:4 shall be zero */ + unsigned int phEnableNV : 1; /* 3 NV indices that have TPMA_PLATFORM_CREATE SET may be read or written. */ + unsigned int ehEnable : 1; /* 2 The EPS hierarchy is enabled and endorsementAuth may be used to authorize commands. */ + unsigned int shEnable : 1; /* 1 The Storage hierarchy is enabled and ownerAuth or ownerPolicy may be used for authorization. */ + unsigned int phEnable : 1; /* 0 The platform hierarchy is enabled and platformAuth or platformPolicy may be used for authorization. */ + }; + UINT32 val; +} TPMA_STARTUP_CLEAR; + +#else + +typedef struct { + UINT32 val; +} TPMA_STARTUP_CLEAR; + +#endif + +#define TPMA_STARTUP_CLEAR_PHENABLE 0x00000001 +#define TPMA_STARTUP_CLEAR_SHENABLE 0x00000002 +#define TPMA_STARTUP_CLEAR_EHENABLE 0x00000004 +#define TPMA_STARTUP_CLEAR_PHENABLENV 0x00000008 +#define TPMA_STARTUP_CLEAR_RESERVED 0x7ffffff0 +#define TPMA_STARTUP_CLEAR_ORDERLY 0x80000000 + +/* Table 36 - Definition of (UINT32) TPMA_MEMORY Bits <Out> */ + +#if defined TPM_BITFIELD_LE + +typedef union { + struct { + unsigned int sharedRAM : 1; /* 0 RAM memory used for authorization session contexts is shared with the memory used for transient objects */ + unsigned int sharedNV : 1; /* 1 indicates that the NV memory used for persistent objects is shared with the NV memory used for NV Index values */ + unsigned int objectCopiedToRam : 1; /* 2 indicates that the TPM copies persistent objects to a transient-object slot in RAM */ + unsigned int Reserved : 29; /* 31:3 shall be zero */ + }; + UINT32 val; +} TPMA_MEMORY; + +#elif defined TPM_BITFIELD_BE + +typedef union { + struct { + unsigned int Reserved : 29; /* 31:3 shall be zero */ + unsigned int objectCopiedToRam : 1; /* 2 indicates that the TPM copies persistent objects to a transient-object slot in RAM */ + unsigned int sharedNV : 1; /* 1 indicates that the NV memory used for persistent objects is shared with the NV memory used for NV Index values */ + unsigned int sharedRAM : 1; /* 0 RAM memory used for authorization session contexts is shared with the memory used for transient objects */ + }; + UINT32 val; +} TPMA_MEMORY; + +#else + +typedef struct { + UINT32 val; +} TPMA_MEMORY; + +#endif + +#define TPMA_MEMORY_SHAREDRAM 0x00000001 +#define TPMA_MEMORY_SHAREDNV 0x00000002 +#define TPMA_MEMORY_OBJECTCOPIEDTORAM 0x00000004 +#define TPMA_MEMORY_RESERVED 0xfffffff8 + +/* Table 37 - Definition of (TPM_CC) TPMA_CC Bits <OUT> */ + +#if defined TPM_BITFIELD_LE + +typedef union { + struct { + unsigned int commandIndex : 16; /* 15:0 indicates the command being selected */ + unsigned int Reserved : 6; /* 21:16 shall be zero */ + unsigned int nv : 1; /* 22 indicates that the command may write to NV */ + unsigned int extensive : 1; /* 23 This command could flush any number of loaded contexts. */ + unsigned int flushed : 1; /* 24 The context associated with any transient handle in the command will be flushed when this command completes. */ + unsigned int cHandles : 3; /* 27:25 indicates the number of the handles in the handle area for this command */ + unsigned int rHandle : 1; /* 28 indicates the presence of the handle area in the input */ + unsigned int V : 1; /* 29 indicates that the command is vendor-specific */ + unsigned int Res : 2; /* 31:30 allocated for software; shall be zero */ + }; + UINT32 val; +} TPMA_CC; + +#elif defined TPM_BITFIELD_BE + +typedef union { + struct { + unsigned int Res : 2; /* 31:30 allocated for software; shall be zero */ + unsigned int V : 1; /* 29 indicates that the command is vendor-specific */ + unsigned int rHandle : 1; /* 28 indicates the presence of the handle area in the input */ + unsigned int cHandles : 3; /* 27:25 indicates the number of the handles in the handle area for this command */ + unsigned int flushed : 1; /* 24 The context associated with any transient handle in the command will be flushed when this command completes. */ + unsigned int extensive : 1; /* 23 This command could flush any number of loaded contexts. */ + unsigned int nv : 1; /* 22 indicates that the command may write to NV */ + unsigned int Reserved : 6; /* 21:16 shall be zero */ + unsigned int commandIndex : 16; /* 15:0 indicates the command being selected */ + }; + UINT32 val; +} TPMA_CC; + +#else + +typedef union { + struct { + UINT32 val; + }; +} TPMA_CC; + +#endif + +#define TPMA_CC_COMMANDINDEX 0x0000ffff +#define TPMA_CC_RESERVED1 0x003f0000 +#define TPMA_CC_NV 0x00400000 +#define TPMA_CC_EXTENSIVE 0x00800000 +#define TPMA_CC_FLUSHED 0x01000000 +#define TPMA_CC_CHANDLES 0x0e000000 +#define TPMA_CC_RHANDLE 0x10000000 +#define TPMA_CC_V 0x20000000 +#define TPMA_CC_RES 0xc0000000 +#define TPMA_CC_RESERVED (0x003f0000 | 0xc0000000) + + /* Table 38 - Definition of (UINT32) TPMA_MODES Bits <Out> */ + +#if defined TPM_BITFIELD_LE + + typedef union { + struct { + unsigned int FIPS_140_2 : 1; /* 0 indicates that the TPM is designed to comply with all of the FIPS 140-2 requirements at Level 1 or higher */ + unsigned int Reserved : 31; /* 31:1 shall be zero */ + }; + UINT32 val; + } TPMA_MODES; + +#elif defined TPM_BITFIELD_BE + +typedef union { + struct { + unsigned int Reserved : 31; /* 31:1 shall be zero */ + unsigned int FIPS_140_2 : 1; /* 0 indicates that the TPM is designed to comply with all of the FIPS 140-2 requirements at Level 1 or higher */ + }; + UINT32 val; +} TPMA_MODES; + +#else + + typedef struct { + UINT32 val; + } TPMA_MODES; + +#endif + +#define TPMA_MODES_FIPS_140_2 0x00000001 + +/* Table 38 - Definition of (BYTE) TPMI_YES_NO Type */ + +typedef BYTE TPMI_YES_NO; + +#define NO 0 +#define YES 1 + +/* Table 39 - Definition of (TPM_HANDLE) TPMI_DH_OBJECT Type */ + +typedef TPM_HANDLE TPMI_DH_OBJECT; + +/* Table 41 - Definition of (TPM_HANDLE) TPMI_DH_PARENT Type */ + +typedef TPM_HANDLE TPMI_DH_PARENT; + +/* Table 40 - Definition of (TPM_HANDLE) TPMI_DH_PERSISTENT Type */ + +typedef TPM_HANDLE TPMI_DH_PERSISTENT; + +/* Table 41 - Definition of (TPM_HANDLE) TPMI_DH_ENTITY Type <IN> */ + +typedef TPM_HANDLE TPMI_DH_ENTITY; + +/* Table 42 - Definition of (TPM_HANDLE) TPMI_DH_PCR Type <IN> */ + +typedef TPM_HANDLE TPMI_DH_PCR; + +/* Table 43 - Definition of (TPM_HANDLE) TPMI_SH_AUTH_SESSION Type <IN/OUT> */ + +typedef TPM_HANDLE TPMI_SH_AUTH_SESSION; + +/* Table 44 - Definition of (TPM_HANDLE) TPMI_SH_HMAC Type <IN/OUT> */ + +typedef TPM_HANDLE TPMI_SH_HMAC; + +/* Table 45 - Definition of (TPM_HANDLE) TPMI_SH_POLICY Type <IN/OUT> */ + +typedef TPM_HANDLE TPMI_SH_POLICY; + +/* Table 46 - Definition of (TPM_HANDLE) TPMI_DH_CONTEXT Type */ + +typedef TPM_HANDLE TPMI_DH_CONTEXT; + +/* Table 49 - Definition of (TPM_HANDLE) TPMI_DH_SAVED Type */ + +typedef TPM_HANDLE TPMI_DH_SAVED; + +/* Table 47 - Definition of (TPM_HANDLE) TPMI_RH_HIERARCHY Type */ + +typedef TPM_HANDLE TPMI_RH_HIERARCHY; + +/* Table 48 - Definition of (TPM_HANDLE) TPMI_RH_ENABLES Type */ + +typedef TPM_HANDLE TPMI_RH_ENABLES; + +/* Table 49 - Definition of (TPM_HANDLE) TPMI_RH_HIERARCHY_AUTH Type <IN> */ + +typedef TPM_HANDLE TPMI_RH_HIERARCHY_AUTH; + +/* Table 50 - Definition of (TPM_HANDLE) TPMI_RH_PLATFORM Type <IN> */ + +typedef TPM_HANDLE TPMI_RH_PLATFORM; + +/* Table 51 - Definition of (TPM_HANDLE) TPMI_RH_OWNER Type <IN> */ + +typedef TPM_HANDLE TPMI_RH_OWNER; + +/* Table 52 - Definition of (TPM_HANDLE) TPMI_RH_ENDORSEMENT Type <IN> */ + +typedef TPM_HANDLE TPMI_RH_ENDORSEMENT; + +/* Table 53 - Definition of (TPM_HANDLE) TPMI_RH_PROVISION Type <IN> */ + +typedef TPM_HANDLE TPMI_RH_PROVISION; + +/* Table 54 - Definition of (TPM_HANDLE) TPMI_RH_CLEAR Type <IN> */ + +typedef TPM_HANDLE TPMI_RH_CLEAR; + +/* Table 55 - Definition of (TPM_HANDLE) TPMI_RH_NV_AUTH Type <IN> */ + +typedef TPM_HANDLE TPMI_RH_NV_AUTH; + +/* Table 56 - Definition of (TPM_HANDLE) TPMI_RH_LOCKOUT Type <IN> */ + +typedef TPM_HANDLE TPMI_RH_LOCKOUT; + +/* Table 57 - Definition of (TPM_HANDLE) TPMI_RH_NV_INDEX Type <IN/OUT> */ + +typedef TPM_HANDLE TPMI_RH_NV_INDEX; + +/* Table 58 - Definition of (TPM_ALG_ID) TPMI_ALG_HASH Type */ + +typedef TPM_ALG_ID TPMI_ALG_HASH; + +/* Table 59 - Definition of (TPM_ALG_ID) TPMI_ALG_ASYM Type */ + +typedef TPM_ALG_ID TPMI_ALG_ASYM; + +/* Table 60 - Definition of (TPM_ALG_ID) TPMI_ALG_SYM Type */ + +typedef TPM_ALG_ID TPMI_ALG_SYM; + +/* Table 61 - Definition of (TPM_ALG_ID) TPMI_ALG_SYM_OBJECT Type */ + +typedef TPM_ALG_ID TPMI_ALG_SYM_OBJECT; + +/* Table 62 - Definition of (TPM_ALG_ID) TPMI_ALG_SYM_MODE Type */ + +typedef TPM_ALG_ID TPMI_ALG_SYM_MODE; + +/* Table 63 - Definition of (TPM_ALG_ID) TPMI_ALG_KDF Type */ + +typedef TPM_ALG_ID TPMI_ALG_KDF; + +/* Table 64 - Definition of (TPM_ALG_ID) TPMI_ALG_SIG_SCHEME Type */ + +typedef TPM_ALG_ID TPMI_ALG_SIG_SCHEME; + +/* Table 65 - Definition of (TPM_ALG_ID) TPMI_ECC_KEY_EXCHANGE Type */ + +typedef TPM_ALG_ID TPMI_ECC_KEY_EXCHANGE; + +/* Table 66 - Definition of (TPM_ST) TPMI_ST_COMMAND_TAG Type */ + +typedef TPM_ST TPMI_ST_COMMAND_TAG; + +/* Table 71 - Definition of (TPM_ALG_ID) TPMI_ALG_MAC_SCHEME Type */ + +typedef TPM_ALG_ID TPMI_ALG_MAC_SCHEME; + +/* Table 72 - Definition of (TPM_ALG_ID) TPMI_ALG_CIPHER_MODE Type */ + +typedef TPM_ALG_ID TPMI_ALG_CIPHER_MODE; + +/* Table 67 - Definition of TPMS_EMPTY Structure <IN/OUT> */ + +typedef struct { + /* a structure with no member */ + BYTE empty[0]; +} TPMS_EMPTY; + +/* Table 68 - Definition of TPMS_ALGORITHM_DESCRIPTION Structure <OUT> */ +typedef struct { + TPM_ALG_ID alg; /* an algorithm */ + TPMA_ALGORITHM attributes; /* the attributes of the algorithm */ +} TPMS_ALGORITHM_DESCRIPTION; + +/* Table 69 - Definition of TPMU_HA Union <IN/OUT, S> */ + +typedef union { + BYTE sha1 [SHA1_DIGEST_SIZE]; /* TPM_ALG_SHA1 */ + BYTE sha256 [SHA256_DIGEST_SIZE]; /* TPM_ALG_SHA256 */ + BYTE sha384 [SHA384_DIGEST_SIZE]; /* TPM_ALG_SHA384 */ + BYTE sha512 [SHA512_DIGEST_SIZE]; /* TPM_ALG_SHA512 */ + BYTE sm3_256 [SM3_256_DIGEST_SIZE]; /* TPM_ALG_SM3_256 */ + BYTE tssmax [128]; /* to make union size larger */ + +} TPMU_HA; + +/* legacy, better to use (sizeof(TPMU_HA) */ + +#define MAX_DIGEST_SIZE (sizeof(TPMU_HA)) + +/* Table 70 - Definition of TPMT_HA Structure <IN/OUT> */ + +typedef struct { + TPMI_ALG_HASH hashAlg; /* selector of the hash contained in the digest that implies the size of the digest */ + TPMU_HA digest; /* the digest data */ +} TPMT_HA; + +/* Table 71 - Definition of TPM2B_DIGEST Structure */ + +typedef struct { + UINT16 size; + BYTE buffer[sizeof(TPMU_HA)]; +} DIGEST_2B; + +typedef union { + DIGEST_2B t; + TPM2B b; +} TPM2B_DIGEST; + +/* Table 72 - Definition of TPM2B_DATA Structure */ + +typedef struct { + UINT16 size; /* size in octets of the buffer field; may be 0 */ + BYTE buffer[sizeof(TPMT_HA)]; +} DATA_2B; + +typedef union { + DATA_2B t; + TPM2B b; +} TPM2B_DATA; + +/* Table 73 - Definition of Types for TPM2B_NONCE */ + +typedef TPM2B_DIGEST TPM2B_NONCE; /* size limited to the same as the digest structure */ + +/* Table 74 - Definition of Types for TPM2B_AUTH */ + +typedef TPM2B_DIGEST TPM2B_AUTH; /* size limited to the same as the digest structure */ + +/* This is not in Part 2, but the concatenation of two digests to create an HMAC key is used often + enough that it's worth putting in a central location. + + In Part 1 19.6.8 sessionKey Creation - authValue || salt. + In Part 1 19.6.5 HMAC Computation - sessionKey || authValue + + I think both could be TPMU_HA, but the TPM reference code seems to use TPMT_HA. +*/ + +typedef struct { + UINT16 size; + BYTE buffer[sizeof(TPMU_HA) + /* TPM2B_AUTH authValue */ + sizeof(TPMT_HA)]; /* salt */ +} KEY_2B; + +typedef union { + KEY_2B t; + TPM2B b; +} TPM2B_KEY; + +/* Table 75 - Definition of Types for TPM2B_OPERAND */ + +typedef TPM2B_DIGEST TPM2B_OPERAND; /* size limited to the same as the digest structure */ + +/* Table 76 - Definition of TPM2B_EVENT Structure */ + +typedef struct { + UINT16 size; /* size of the operand */ + BYTE buffer [1024]; /* the operand */ +} EVENT_2B; + +typedef union { + EVENT_2B t; + TPM2B b; +} TPM2B_EVENT; + +/* Table 77 - Definition of TPM2B_MAX_BUFFER Structure */ + +/* MAX_DIGEST_BUFFER is TPM-dependent but is required to be at least 1,024. */ + +typedef struct { + UINT16 size; /* size of the buffer */ + BYTE buffer [MAX_DIGEST_BUFFER]; /* the operand */ +} MAX_BUFFER_2B; + +typedef union { + MAX_BUFFER_2B t; + TPM2B b; +} TPM2B_MAX_BUFFER; + +/* Table 78 - Definition of TPM2B_MAX_NV_BUFFER Structure */ + +typedef struct { + UINT16 size; /* size of the buffer */ + BYTE buffer [MAX_NV_BUFFER_SIZE]; /* the operand */ +} MAX_NV_BUFFER_2B; + +typedef union { + MAX_NV_BUFFER_2B t; + TPM2B b; +} TPM2B_MAX_NV_BUFFER; + +/* Table 79 - Definition of TPM2B_TIMEOUT Structure <IN/OUT> */ + +typedef TPM2B_DIGEST TPM2B_TIMEOUT; /* size limited to the same as the digest structure */ + +/* Table 80 - Definition of TPM2B_IV Structure <IN/OUT> */ + +typedef struct { + UINT16 size; /* size of the IV value */ + BYTE buffer [MAX_SYM_BLOCK_SIZE]; /* the IV value */ +} IV_2B; + +typedef union { + IV_2B t; + TPM2B b; +} TPM2B_IV; + +/* Table 81 - Definition of TPMU_NAME Union <> */ + +typedef union { + TPMT_HA digest; /* when the Name is a digest */ + TPM_HANDLE handle; /* when the Name is a handle */ +} TPMU_NAME; + +/* Table 82 - Definition of TPM2B_NAME Structure */ + +typedef struct { + UINT16 size; /* size of the Name structure */ + BYTE name[sizeof(TPMU_NAME)]; /* the Name structure */ +} NAME_2B; + +typedef union { + NAME_2B t; + TPM2B b; +} TPM2B_NAME; + +/* Table 83 - Definition of TPMS_PCR_SELECT Structure */ + +typedef struct { + UINT8 sizeofSelect; /* the size in octets of the pcrSelect array */ + BYTE pcrSelect [PCR_SELECT_MAX]; /* the bit map of selected PCR */ +} TPMS_PCR_SELECT; + +/* Table 84 - Definition of TPMS_PCR_SELECTION Structure */ + +typedef struct { + TPMI_ALG_HASH hash; /* the hash algorithm associated with the selection */ + UINT8 sizeofSelect; /* the size in octets of the pcrSelect array */ + BYTE pcrSelect [PCR_SELECT_MAX]; /* the bit map of selected PCR */ +} TPMS_PCR_SELECTION; + +/* Table 87 - Definition of TPMT_TK_CREATION Structure */ + +typedef struct { + TPM_ST tag; /* ticket structure tag TPM_ST_CREATION */ + TPMI_RH_HIERARCHY hierarchy; /* the hierarchy containing name */ + TPM2B_DIGEST digest; /* This shall be the HMAC produced using a proof value of hierarchy. */ +} TPMT_TK_CREATION; + +/* Table 88 - Definition of TPMT_TK_VERIFIED Structure */ + +typedef struct { + TPM_ST tag; /* ticket structure tag TPM_ST_VERIFIED */ + TPMI_RH_HIERARCHY hierarchy; /* the hierarchy containing keyName */ + TPM2B_DIGEST digest; /* This shall be the HMAC produced using a proof value of hierarchy. */ +} TPMT_TK_VERIFIED; + +/* Table 89 - Definition of TPMT_TK_AUTH Structure */ + +typedef struct { + TPM_ST tag; /* ticket structure tag TPM_ST_AUTH_SIGNED, TPM_ST_AUTH_SECRET */ + TPMI_RH_HIERARCHY hierarchy; /* the hierarchy of the object used to produce the ticket */ + TPM2B_DIGEST digest; /* This shall be the HMAC produced using a proof value of hierarchy. */ +} TPMT_TK_AUTH; + +/* Table 90 - Definition of TPMT_TK_HASHCHECK Structure */ + +typedef struct { + TPM_ST tag; /* ticket structure tag TPM_ST_HASHCHECK */ + TPMI_RH_HIERARCHY hierarchy; /* the hierarchy */ + TPM2B_DIGEST digest; /* This shall be the HMAC produced using a proof value of hierarchy. */ +} TPMT_TK_HASHCHECK; + +/* Table 91 - Definition of TPMS_ALG_PROPERTY Structure <OUT> */ + +typedef struct { + TPM_ALG_ID alg; /* an algorithm identifier */ + TPMA_ALGORITHM algProperties; /* the attributes of the algorithm */ +} TPMS_ALG_PROPERTY; + +/* Table 92 - Definition of TPMS_TAGGED_PROPERTY Structure <OUT> */ + +typedef struct { + TPM_PT property; /* a property identifier */ + UINT32 value; /* the value of the property */ +} TPMS_TAGGED_PROPERTY; + +/* Table 93 - Definition of TPMS_TAGGED_PCR_SELECT Structure <OUT> */ + +typedef struct { + TPM_PT_PCR tag; /* the property identifier */ + UINT8 sizeofSelect; /* the size in octets of the pcrSelect array */ + BYTE pcrSelect [PCR_SELECT_MAX]; /* the bit map of PCR with the identified property */ +} TPMS_TAGGED_PCR_SELECT; + +/* Table 96 - Definition of TPMS_TAGGED_POLICY Structure */ + +typedef struct { + TPM_HANDLE handle; + TPMT_HA policyHash; +} TPMS_TAGGED_POLICY; + +/* Table 94 - Definition of TPML_CC Structure */ + +typedef struct { + UINT32 count; /* number of commands in the commandCode list; may be 0 */ + TPM_CC commandCodes[MAX_CAP_CC]; /* a list of command codes */ +} TPML_CC; + +/* Table 95 - Definition of TPML_CCA Structure <OUT> */ + +typedef struct { + UINT32 count; /* number of values in the commandAttributes list; may be 0 */ + TPMA_CC commandAttributes[MAX_CAP_CC]; /* a list of command codes attributes */ +} TPML_CCA; + +/* Table 96 - Definition of TPML_ALG Structure */ + +typedef struct { + UINT32 count; /* number of algorithms in the algorithms list; may be 0 */ + TPM_ALG_ID algorithms[MAX_ALG_LIST_SIZE]; /* a list of algorithm IDs */ +} TPML_ALG; + +/* Table 97 - Definition of TPML_HANDLE Structure <OUT> */ + +typedef struct { + UINT32 count; /* the number of handles in the list may have a value of 0 */ + TPM_HANDLE handle[MAX_CAP_HANDLES]; /* an array of handles */ +} TPML_HANDLE; + +/* Table 98 - Definition of TPML_DIGEST Structure */ + +typedef struct { + UINT32 count; /* number of digests in the list, minimum is two for TPM2_PolicyOR(). */ + TPM2B_DIGEST digests[8]; /* a list of digests */ +} TPML_DIGEST; + +/* Table 99 - Definition of TPML_DIGEST_VALUES Structure */ + +typedef struct { + UINT32 count; /* number of digests in the list */ + TPMT_HA digests[HASH_COUNT]; /* a list of tagged digests */ +} TPML_DIGEST_VALUES; + +/* Table 100 - Definition of TPM2B_DIGEST_VALUES Structure */ + +typedef struct { + UINT16 size; /* size of the operand buffer */ + BYTE buffer [sizeof(TPML_DIGEST_VALUES)]; /* the operand */ +} TPM2B_DIGEST_VALUES; + +/* Table 101 - Definition of TPML_PCR_SELECTION Structure */ + +typedef struct { + UINT32 count; /* number of selection structures A value of zero is allowed. */ + TPMS_PCR_SELECTION pcrSelections[HASH_COUNT]; /* list of selections */ +} TPML_PCR_SELECTION; + +/* Table 102 - Definition of TPML_ALG_PROPERTY Structure <OUT> */ + +typedef struct { + UINT32 count; /* number of algorithm properties structures A value of zero is allowed. */ + TPMS_ALG_PROPERTY algProperties[MAX_CAP_ALGS]; /* list of properties */ +} TPML_ALG_PROPERTY; + +/* Table 103 - Definition of TPML_TAGGED_TPM_PROPERTY Structure <OUT> */ + +typedef struct { + UINT32 count; /* number of properties A value of zero is allowed. */ + TPMS_TAGGED_PROPERTY tpmProperty[MAX_TPM_PROPERTIES]; /* an array of tagged properties */ +} TPML_TAGGED_TPM_PROPERTY; + +/* Table 104 - Definition of TPML_TAGGED_PCR_PROPERTY Structure <OUT> */ + +typedef struct { + UINT32 count; /* number of properties A value of zero is allowed. */ + TPMS_TAGGED_PCR_SELECT pcrProperty[MAX_PCR_PROPERTIES]; /* a tagged PCR selection */ +} TPML_TAGGED_PCR_PROPERTY; + +/* Table 105 - Definition of {ECC} TPML_ECC_CURVE Structure <OUT> */ + +typedef struct { + UINT32 count; /* number of curves A value of zero is allowed. */ + TPM_ECC_CURVE eccCurves[MAX_ECC_CURVES]; /* array of ECC curve identifiers */ +} TPML_ECC_CURVE ; + +/* Table 109 - Definition of TPML_TAGGED_POLICY Structure */ + +typedef struct { + UINT32 count; + TPMS_TAGGED_POLICY policies[MAX_TAGGED_POLICIES]; +} TPML_TAGGED_POLICY; + +/* Table 106 - Definition of TPMU_CAPABILITIES Union <OUT> */ + +typedef union { + TPML_ALG_PROPERTY algorithms; /* TPM_CAP_ALGS */ + TPML_HANDLE handles; /* TPM_CAP_HANDLES */ + TPML_CCA command; /* TPM_CAP_COMMANDS */ + TPML_CC ppCommands; /* TPM_CAP_PP_COMMANDS */ + TPML_CC auditCommands; /* TPM_CAP_AUDIT_COMMANDS */ + TPML_PCR_SELECTION assignedPCR; /* TPM_CAP_PCRS */ + TPML_TAGGED_TPM_PROPERTY tpmProperties; /* TPM_CAP_TPM_PROPERTIES */ + TPML_TAGGED_PCR_PROPERTY pcrProperties; /* TPM_CAP_PCR_PROPERTIES */ + TPML_ECC_CURVE eccCurves; /* TPM_CAP_ECC_CURVES */ + TPML_TAGGED_POLICY authPolicies; /* TPM_CAP_AUTH_POLICIES */ +} TPMU_CAPABILITIES; + +/* Table 107 - Definition of TPMS_CAPABILITY_DATA Structure <OUT> */ + +typedef struct { + TPM_CAP capability; /* the capability */ + TPMU_CAPABILITIES data; /* the capability data */ +} TPMS_CAPABILITY_DATA; + +/* Table 108 - Definition of TPMS_CLOCK_INFO Structure */ + +typedef struct { + UINT64 clock; /* time in milliseconds during which the TPM has been powered */ + UINT32 resetCount; /* number of occurrences of TPM Reset since the last TPM2_Clear() */ + UINT32 restartCount; /* number of times that TPM2_Shutdown() or _TPM_Hash_Start have + occurred since the last TPM Reset or TPM2_Clear(). */ + TPMI_YES_NO safe; /* no value of Clock greater than the current value of Clock has + been previously reported by the TPM */ +} TPMS_CLOCK_INFO; + +/* Table 109 - Definition of TPMS_TIME_INFO Structure */ + +typedef struct { + UINT64 time; /* time in milliseconds since the last _TPM_Init() or TPM2_Startup() */ + TPMS_CLOCK_INFO clockInfo; /* a structure containing the clock information */ +} TPMS_TIME_INFO; + +/* Table 110 - Definition of TPMS_TIME_ATTEST_INFO Structure <OUT> */ + +typedef struct { + TPMS_TIME_INFO time; /* the Time, clock, resetCount, restartCount, and + Safe indicator */ + UINT64 firmwareVersion; /* a TPM vendor-specific value indicating the + version number of the firmware */ +} TPMS_TIME_ATTEST_INFO; + +/* Table 111 - Definition of TPMS_CERTIFY_INFO Structure <OUT> */ + +typedef struct { + TPM2B_NAME name; /* Name of the certified object */ + TPM2B_NAME qualifiedName; /* Qualified Name of the certified object */ +} TPMS_CERTIFY_INFO; + +/* Table 112 - Definition of TPMS_QUOTE_INFO Structure <OUT> */ + +typedef struct { + TPML_PCR_SELECTION pcrSelect; /* information on algID, PCR selected and digest */ + TPM2B_DIGEST pcrDigest; /* digest of the selected PCR using the hash of the signing key */ +} TPMS_QUOTE_INFO; + +/* Table 113 - Definition of TPMS_COMMAND_AUDIT_INFO Structure <OUT> */ + +typedef struct { + UINT64 auditCounter; /* the monotonic audit counter */ + TPM_ALG_ID digestAlg; /* hash algorithm used for the command audit */ + TPM2B_DIGEST auditDigest; /* the current value of the audit digest */ + TPM2B_DIGEST commandDigest; /* digest of the command codes being audited using digestAlg */ +} TPMS_COMMAND_AUDIT_INFO; + +/* Table 114 - Definition of TPMS_SESSION_AUDIT_INFO Structure <OUT> */ + +typedef struct { + TPMI_YES_NO exclusiveSession; /* current exclusive status of the session */ + TPM2B_DIGEST sessionDigest; /* the current value of the session audit digest */ +} TPMS_SESSION_AUDIT_INFO; + +/* Table 115 - Definition of TPMS_CREATION_INFO Structure <OUT> */ + +typedef struct { + TPM2B_NAME objectName; /* Name of the object */ + TPM2B_DIGEST creationHash; /* creationHash */ +} TPMS_CREATION_INFO; + +/* Table 116 - Definition of TPMS_NV_CERTIFY_INFO Structure <OUT> */ + +typedef struct { + TPM2B_NAME indexName; /* Name of the NV Index */ + UINT16 offset; /* the offset parameter of TPM2_NV_Certify() */ + TPM2B_MAX_NV_BUFFER nvContents; /* contents of the NV Index */ +} TPMS_NV_CERTIFY_INFO; + +/* Table 117 - Definition of (TPM_ST) TPMI_ST_ATTEST Type <OUT> */ + +typedef TPM_ST TPMI_ST_ATTEST; + +/* Table 118 - Definition of TPMU_ATTEST Union <OUT> */ + +typedef union { + TPMS_CERTIFY_INFO certify; /* TPM_ST_ATTEST_CERTIFY */ + TPMS_CREATION_INFO creation; /* TPM_ST_ATTEST_CREATION */ + TPMS_QUOTE_INFO quote; /* TPM_ST_ATTEST_QUOTE */ + TPMS_COMMAND_AUDIT_INFO commandAudit; /* TPM_ST_ATTEST_COMMAND_AUDIT */ + TPMS_SESSION_AUDIT_INFO sessionAudit; /* TPM_ST_ATTEST_SESSION_AUDIT */ + TPMS_TIME_ATTEST_INFO time; /* TPM_ST_ATTEST_TIME */ + TPMS_NV_CERTIFY_INFO nv; /* TPM_ST_ATTEST_NV */ +} TPMU_ATTEST; + +/* Table 119 - Definition of TPMS_ATTEST Structure <OUT> */ + +typedef struct { + TPM_GENERATED magic; /* the indication that this structure was created by + a TPM (always TPM_GENERATED_VALUE) */ + TPMI_ST_ATTEST type; /* type of the attestation structure */ + TPM2B_NAME qualifiedSigner; /* Qualified Name of the signing key */ + TPM2B_DATA extraData; /* external information supplied by caller */ + TPMS_CLOCK_INFO clockInfo; /* Clock, resetCount, restartCount, and Safe */ + UINT64 firmwareVersion; /* TPM-vendor-specific value identifying the version + number of the firmware */ + TPMU_ATTEST attested; /* the type-specific attestation information */ +} TPMS_ATTEST; + +/* Table 120 - Definition of TPM2B_ATTEST Structure <OUT> */ + +typedef struct { + UINT16 size; /* size of the attestationData structure */ + BYTE attestationData[sizeof(TPMS_ATTEST)]; /* the signed structure */ +} ATTEST_2B; + +typedef union { + ATTEST_2B t; + TPM2B b; +} TPM2B_ATTEST; + +/* Table 121 - Definition of TPMS_AUTH_COMMAND Structure <IN> */ + +typedef struct { + TPMI_SH_AUTH_SESSION sessionHandle; /* the session handle */ + TPM2B_NONCE nonce; /* the session nonce, may be the Empty Buffer */ + TPMA_SESSION sessionAttributes; /* the session attributes */ + TPM2B_AUTH hmac; /* either an HMAC, a password, or an EmptyAuth */ +} TPMS_AUTH_COMMAND; + +/* Table 126 - Definition of TPMS_AUTH_RESPONSE Structure <OUT> */ + +typedef struct { + TPM2B_NONCE nonce; /* the session nonce, may be the Empty Buffer */ + TPMA_SESSION sessionAttributes; /* the session attributes */ + TPM2B_AUTH hmac; /* either an HMAC or an EmptyAuth */ +} TPMS_AUTH_RESPONSE; + +/* Table 127 - Definition of {AES} (TPM_KEY_BITS) TPMI_!ALG.S_KEY_BITS Type */ + +typedef TPM_KEY_BITS TPMI_TDES_KEY_BITS; +typedef TPM_KEY_BITS TPMI_AES_KEY_BITS; +typedef TPM_KEY_BITS TPMI_SM4_KEY_BITS; +typedef TPM_KEY_BITS TPMI_CAMELLIA_KEY_BITS; + +/* Table 128 - Definition of TPMU_SYM_KEY_BITS Union */ + +typedef union { +#ifdef TPM_ALG_TDES + TPMI_TDES_KEY_BITS tdes; /* TPM_ALG_TDES */ +#endif +#ifdef TPM_ALG_AES + TPMI_AES_KEY_BITS aes; /* TPM_ALG_AES */ +#endif +#ifdef TPM_ALG_SM4 + TPMI_SM4_KEY_BITS sm4; /* TPM_ALG_SM4 */ +#endif +#ifdef TPM_ALG_CAMELLIA + TPMI_CAMELLIA_KEY_BITS camellia; /* TPM_ALG_CAMELLIA */ +#endif +#ifdef TPM_ALG_XOR + TPMI_ALG_HASH xorr; /* TPM_ALG_XOR overload for using xor */ +#endif + TPM_KEY_BITS sym; /* when selector may be any of the symmetric block ciphers */ +} TPMU_SYM_KEY_BITS; + +/* Table 129 - Definition of TPMU_SYM_MODE Union */ + +typedef union { +#ifdef TPM_ALG_TDES + TPMI_ALG_SYM_MODE tdes; /* TPM_ALG_TDES */ +#endif +#ifdef TPM_ALG_AES + TPMI_ALG_SYM_MODE aes; /* TPM_ALG_AES */ +#endif +#ifdef TPM_ALG_SM4 + TPMI_ALG_SYM_MODE sm4; /* TPM_ALG_SM4 */ +#endif +#ifdef TPM_ALG_CAMELLIA + TPMI_ALG_SYM_MODE camellia; /* TPM_ALG_CAMELLIA */ +#endif + TPMI_ALG_SYM_MODE sym; /* when selector may be any of the symmetric block ciphers */ +} TPMU_SYM_MODE; + +/* Table 126 - xDefinition of TPMU_SYM_DETAILS Union */ + +/* Table 127 - Definition of TPMT_SYM_DEF Structure */ + +typedef struct { + TPMI_ALG_SYM algorithm; /* indicates a symmetric algorithm */ + TPMU_SYM_KEY_BITS keyBits; /* a supported key size */ + TPMU_SYM_MODE mode; /* the mode for the key */ +} TPMT_SYM_DEF; + +/* Table 128 - Definition of TPMT_SYM_DEF_OBJECT Structure */ + +typedef struct { + TPMI_ALG_SYM_OBJECT algorithm; /* selects a symmetric block cipher */ + TPMU_SYM_KEY_BITS keyBits; /* the key size */ + TPMU_SYM_MODE mode; /* default mode */ +} TPMT_SYM_DEF_OBJECT; + +/* Table 129 - Definition of TPM2B_SYM_KEY Structure */ + +typedef struct { + UINT16 size; /* size, in octets, of the buffer containing the key; may be zero */ + BYTE buffer [MAX_SYM_KEY_BYTES]; /* the key */ +} SYM_KEY_2B; + +typedef union { + SYM_KEY_2B t; + TPM2B b; +} TPM2B_SYM_KEY; + +/* Table 130 - Definition of TPMS_SYMCIPHER_PARMS Structure */ + +typedef struct { + TPMT_SYM_DEF_OBJECT sym; /* a symmetric block cipher */ +} TPMS_SYMCIPHER_PARMS; + +/* Table 135 - Definition of TPM2B_LABEL Structure */ + +typedef union { + struct { + UINT16 size; + BYTE buffer[LABEL_MAX_BUFFER]; + } t; + TPM2B b; +} TPM2B_LABEL; + +/* Table 135 - Definition of TPMS_DERIVE Structure */ + +typedef struct { + TPM2B_LABEL label; + TPM2B_LABEL context; +} TPMS_DERIVE; + +/* Table 131 - Definition of TPM2B_SENSITIVE_DATA Structure */ + +typedef struct { + UINT16 size; + BYTE buffer[MAX_SYM_DATA]; /* the keyed hash private data structure */ +} SENSITIVE_DATA_2B; + +typedef union { + SENSITIVE_DATA_2B t; + TPM2B b; +} TPM2B_SENSITIVE_DATA; + +/* Table 132 - Definition of TPMS_SENSITIVE_CREATE Structure <IN> */ + +typedef struct { + TPM2B_AUTH userAuth; /* the USER auth secret value */ + TPM2B_SENSITIVE_DATA data; /* data to be sealed */ +} TPMS_SENSITIVE_CREATE; + +/* Table 133 - Definition of TPM2B_SENSITIVE_CREATE Structure <IN, S> */ + +typedef struct { + UINT16 size; /* size of sensitive in octets (may not be zero) */ + TPMS_SENSITIVE_CREATE sensitive; /* data to be sealed or a symmetric key value. */ +} TPM2B_SENSITIVE_CREATE; + +/* Table 134 - Definition of TPMS_SCHEME_HASH Structure */ + +typedef struct { + TPMI_ALG_HASH hashAlg; /* the hash algorithm used to digest the message */ +} TPMS_SCHEME_HASH; + +/* Table 135 - Definition of {ECC} TPMS_SCHEME_ECDAA Structure */ + +typedef struct { + TPMI_ALG_HASH hashAlg; /* the hash algorithm used to digest the message */ + UINT16 count; /* the counter value that is used between TPM2_Commit() and the sign operation */ +} TPMS_SCHEME_ECDAA; + +/* Table 136 - Definition of (TPM_ALG_ID) TPMI_ALG_KEYEDHASH_SCHEME Type */ + +typedef TPM_ALG_ID TPMI_ALG_KEYEDHASH_SCHEME; + +/* Table 137 - Definition of Types for HMAC_SIG_SCHEME */ + +typedef TPMS_SCHEME_HASH TPMS_SCHEME_HMAC; + +/* Table 138 - Definition of TPMS_SCHEME_XOR Structure */ + +typedef struct { + TPMI_ALG_HASH hashAlg; /* the hash algorithm used to digest the message */ + TPMI_ALG_KDF kdf; /* the key derivation function */ +} TPMS_SCHEME_XOR; + +/* Table 139 - Definition of TPMU_SCHEME_KEYEDHASH Union <IN/OUT, S> */ + +typedef union { +#ifdef TPM_ALG_HMAC + TPMS_SCHEME_HMAC hmac; /* TPM_ALG_HMAC the "signing" scheme */ +#endif +#ifdef TPM_ALG_XOR + TPMS_SCHEME_XOR xorr; /* TPM_ALG_XOR the "obfuscation" scheme */ +#endif +} TPMU_SCHEME_KEYEDHASH; + +/* Table 140 - Definition of TPMT_KEYEDHASH_SCHEME Structure */ + +typedef struct { + TPMI_ALG_KEYEDHASH_SCHEME scheme; /* selects the scheme */ + TPMU_SCHEME_KEYEDHASH details; /* the scheme parameters */ +} TPMT_KEYEDHASH_SCHEME; + +/* Table 141 - Definition of {RSA} Types for RSA Signature Schemes */ + +typedef TPMS_SCHEME_HASH TPMS_SIG_SCHEME_RSASSA; +typedef TPMS_SCHEME_HASH TPMS_SIG_SCHEME_RSAPSS; + +/* Table 142 - Definition of {ECC} Types for ECC Signature Schemes */ + +typedef TPMS_SCHEME_HASH TPMS_SIG_SCHEME_ECDSA; +typedef TPMS_SCHEME_HASH TPMS_SIG_SCHEME_SM2; +typedef TPMS_SCHEME_HASH TPMS_SIG_SCHEME_ECSCHNORR; + +typedef TPMS_SCHEME_ECDAA TPMS_SIG_SCHEME_ECDAA; + +/* Table 143 - Definition of TPMU_SIG_SCHEME Union <IN/OUT, S> */ + +typedef union { +#ifdef TPM_ALG_RSASSA + TPMS_SIG_SCHEME_RSASSA rsassa; /* TPM_ALG_RSASSA the RSASSA-PKCS1v1_5 scheme */ +#endif +#ifdef TPM_ALG_RSAPSS + TPMS_SIG_SCHEME_RSAPSS rsapss; /* TPM_ALG_RSAPSS the RSASSA-PSS scheme */ +#endif +#ifdef TPM_ALG_ECDSA + TPMS_SIG_SCHEME_ECDSA ecdsa; /* TPM_ALG_ECDSA the ECDSA scheme */ +#endif +#ifdef TPM_ALG_ECDAA + TPMS_SIG_SCHEME_ECDAA ecdaa; /* TPM_ALG_ECDAA the ECDAA scheme */ +#endif +#ifdef TPM_ALG_SM2 + TPMS_SIG_SCHEME_SM2 sm2; /* TPM_ALG_SM2 ECDSA from SM2 */ +#endif +#ifdef TPM_ALG_ECSCHNORR + TPMS_SIG_SCHEME_ECSCHNORR ecSchnorr; /* TPM_ALG_ECSCHNORR the EC Schnorr */ +#endif +#ifdef TPM_ALG_HMAC + TPMS_SCHEME_HMAC hmac; /* TPM_ALG_HMAC the HMAC scheme */ +#endif + TPMS_SCHEME_HASH any; /* selector that allows access to digest for any signing scheme */ +} TPMU_SIG_SCHEME; + +/* Table 144 - Definition of TPMT_SIG_SCHEME Structure */ + +typedef struct { + TPMI_ALG_SIG_SCHEME scheme; /* scheme selector */ + TPMU_SIG_SCHEME details; /* scheme parameters */ +} TPMT_SIG_SCHEME; + +/* Table 145 - Definition of Types for {RSA} Encryption Schemes */ + +typedef TPMS_SCHEME_HASH TPMS_ENC_SCHEME_OAEP; /* schemes that only need a hash */ + +typedef TPMS_EMPTY TPMS_ENC_SCHEME_RSAES; /* schemes that need nothing */ + +/* Table 146 - Definition of Types for {ECC} ECC Key Exchange */ + +typedef TPMS_SCHEME_HASH TPMS_KEY_SCHEME_ECDH; /* schemes that only need a hash */ +typedef TPMS_SCHEME_HASH TPMS_KEY_SCHEME_ECMQV; /* schemes that only need a hash */ + +/* Table 147 - Definition of Types for KDF Schemes, hash-based key- or mask-generation functions */ + +typedef TPMS_SCHEME_HASH TPMS_SCHEME_MGF1; +typedef TPMS_SCHEME_HASH TPMS_SCHEME_KDF1_SP800_56A; +typedef TPMS_SCHEME_HASH TPMS_SCHEME_KDF2; +typedef TPMS_SCHEME_HASH TPMS_SCHEME_KDF1_SP800_108; + +/* Table 148 - Definition of TPMU_KDF_SCHEME Union <IN/OUT, S> */ + +typedef union { +#ifdef TPM_ALG_MGF1 + TPMS_SCHEME_MGF1 mgf1; /* TPM_ALG_MGF1 */ +#endif +#ifdef TPM_ALG_KDF1_SP800_56A + TPMS_SCHEME_KDF1_SP800_56A kdf1_SP800_56a; /* TPM_ALG_KDF1_SP800_56A */ +#endif +#ifdef TPM_ALG_KDF2 + TPMS_SCHEME_KDF2 kdf2; /* TPM_ALG_KDF2 */ +#endif +#ifdef TPM_ALG_KDF1_SP800_108 + TPMS_SCHEME_KDF1_SP800_108 kdf1_sp800_108; /* TPM_ALG_KDF1_SP800_108 */ +#endif +} TPMU_KDF_SCHEME; + +/* Table 149 - Definition of TPMT_KDF_SCHEME Structure */ + +typedef struct { + TPMI_ALG_KDF scheme; /* scheme selector */ + TPMU_KDF_SCHEME details; /* scheme parameters */ +} TPMT_KDF_SCHEME; + +/* Table 150 - Definition of (TPM_ALG_ID) TPMI_ALG_ASYM_SCHEME Type <> */ + +typedef TPM_ALG_ID TPMI_ALG_ASYM_SCHEME; + +/* Table 151 - Definition of TPMU_ASYM_SCHEME Union */ + +typedef union { +#ifdef TPM_ALG_ECDH + TPMS_KEY_SCHEME_ECDH ecdh; /* TPM_ALG_ECDH */ +#endif +#ifdef TPM_ALG_ECMQV + TPMS_KEY_SCHEME_ECMQV ecmqvh; /* TPM_ALG_ECMQV */ +#endif +#ifdef TPM_ALG_RSASSA + TPMS_SIG_SCHEME_RSASSA rsassa; /* TPM_ALG_RSASSA */ +#endif +#ifdef TPM_ALG_RSAPSS + TPMS_SIG_SCHEME_RSAPSS rsapss; /* TPM_ALG_RSAPSS */ +#endif +#ifdef TPM_ALG_ECDSA + TPMS_SIG_SCHEME_ECDSA ecdsa; /* TPM_ALG_ECDSA */ +#endif +#ifdef TPM_ALG_ECDAA + TPMS_SIG_SCHEME_ECDAA ecdaa; /* TPM_ALG_ECDAA */ +#endif +#ifdef TPM_ALG_SM2 + TPMS_SIG_SCHEME_SM2 sm2; /* TPM_ALG_SM2 */ +#endif +#ifdef TPM_ALG_ECSCHNORR + TPMS_SIG_SCHEME_ECSCHNORR ecSchnorr; /* TPM_ALG_ECSCHNORR */ +#endif +#ifdef TPM_ALG_RSAES + TPMS_ENC_SCHEME_RSAES rsaes; /* TPM_ALG_RSAES */ +#endif +#ifdef TPM_ALG_OAEP + TPMS_ENC_SCHEME_OAEP oaep; /* TPM_ALG_OAEP */ +#endif + TPMS_SCHEME_HASH anySig; +} TPMU_ASYM_SCHEME; + +/* Table 152 - Definition of TPMT_ASYM_SCHEME Structure <> */ + +typedef struct { + TPMI_ALG_ASYM_SCHEME scheme; /* scheme selector */ + TPMU_ASYM_SCHEME details; /* scheme parameters */ +} TPMT_ASYM_SCHEME; + +/* Table 153 - Definition of (TPM_ALG_ID) {RSA} TPMI_ALG_RSA_SCHEME Type */ + +typedef TPM_ALG_ID TPMI_ALG_RSA_SCHEME; + +/* Table 154 - Definition of {RSA} TPMT_RSA_SCHEME Structure */ + +typedef struct { + TPMI_ALG_RSA_SCHEME scheme; /* scheme selector */ + TPMU_ASYM_SCHEME details; /* scheme parameters */ +} TPMT_RSA_SCHEME; + +/* Table 155 - Definition of (TPM_ALG_ID) {RSA} TPMI_ALG_RSA_DECRYPT Type */ + +typedef TPM_ALG_ID TPMI_ALG_RSA_DECRYPT; + +/* Table 156 - Definition of {RSA} TPMT_RSA_DECRYPT Structure */ + +typedef struct { + TPMI_ALG_RSA_DECRYPT scheme; /* scheme selector */ + TPMU_ASYM_SCHEME details; /* scheme parameters */ +} TPMT_RSA_DECRYPT; + +/* Table 157 - Definition of {RSA} TPM2B_PUBLIC_KEY_RSA Structure */ + +typedef struct { + UINT16 size; /* size of the buffer */ + BYTE buffer[MAX_RSA_KEY_BYTES]; /* Value */ +} PUBLIC_KEY_RSA_2B; + +typedef union { + PUBLIC_KEY_RSA_2B t; + TPM2B b; +} TPM2B_PUBLIC_KEY_RSA; + +/* Table 158 - Definition of {RSA} (TPM_KEY_BITS) TPMI_RSA_KEY_BITS Type */ + +typedef TPM_KEY_BITS TPMI_RSA_KEY_BITS; + +/* Table 159 - Definition of {RSA} TPM2B_PRIVATE_KEY_RSA Structure */ + +typedef struct { + UINT16 size; + BYTE buffer[MAX_RSA_KEY_BYTES/2]; +} PRIVATE_KEY_RSA_2B; + +typedef union { + PRIVATE_KEY_RSA_2B t; + TPM2B b; +} TPM2B_PRIVATE_KEY_RSA; + +/* Table 160 - Definition of {ECC} TPM2B_ECC_PARAMETER Structure */ + +typedef struct { + UINT16 size; /* size of the buffer */ + BYTE buffer[MAX_ECC_KEY_BYTES]; /* the parameter data */ +} ECC_PARAMETER_2B; + +typedef union { + ECC_PARAMETER_2B t; + TPM2B b; +} TPM2B_ECC_PARAMETER; + +/* Table 161 - Definition of {ECC} TPMS_ECC_POINT Structure */ + +typedef struct { + TPM2B_ECC_PARAMETER x; /* X coordinate */ + TPM2B_ECC_PARAMETER y; /* Y coordinate */ +} TPMS_ECC_POINT; + +/* Table 162 - Definition of {ECC} TPM2B_ECC_POINT Structure */ + +typedef struct { + UINT16 size; /* size of the remainder of this structure */ + TPMS_ECC_POINT point; /* coordinates */ +} TPM2B_ECC_POINT; + +/* Table 163 - Definition of (TPM_ALG_ID) {ECC} TPMI_ALG_ECC_SCHEME Type */ + +typedef TPM_ALG_ID TPMI_ALG_ECC_SCHEME; + +/* Table 164 - Definition of {ECC} (TPM_ECC_CURVE) TPMI_ECC_CURVE Type */ + +typedef TPM_ECC_CURVE TPMI_ECC_CURVE; + +/* Table 165 - Definition of (TPMT_SIG_SCHEME) {ECC} TPMT_ECC_SCHEME Structure */ + +typedef struct { + TPMI_ALG_ECC_SCHEME scheme; /* scheme selector */ + TPMU_ASYM_SCHEME details; /* scheme parameters */ +} TPMT_ECC_SCHEME; + +/* Table 166 - Definition of {ECC} TPMS_ALGORITHM_DETAIL_ECC Structure <OUT> */ + +typedef struct { + TPM_ECC_CURVE curveID; /* identifier for the curve */ + UINT16 keySize; /* Size in bits of the key */ + TPMT_KDF_SCHEME kdf; /* If not TPM_ALG_NULL, the required KDF and hash algorithm + used in secret sharing operations */ + TPMT_ECC_SCHEME sign; /* If not TPM_ALG_NULL, this is the mandatory signature + scheme that is required to be used with this curve. */ + TPM2B_ECC_PARAMETER p; /* Fp (the modulus) */ + TPM2B_ECC_PARAMETER a; /* coefficient of the linear term in the curve equation */ + TPM2B_ECC_PARAMETER b; /* constant term for curve equation */ + TPM2B_ECC_PARAMETER gX; /* x coordinate of base point G */ + TPM2B_ECC_PARAMETER gY; /* y coordinate of base point G */ + TPM2B_ECC_PARAMETER n; /* order of G */ + TPM2B_ECC_PARAMETER h; /* cofactor (a size of zero indicates a cofactor of 1) */ +} TPMS_ALGORITHM_DETAIL_ECC; + +/* Table 167 - Definition of {RSA} TPMS_SIGNATURE_RSA Structure */ + +typedef struct { + TPMI_ALG_HASH hash; /* the hash algorithm used to digest the message TPM_ALG_NULL is not allowed. */ + TPM2B_PUBLIC_KEY_RSA sig; /* The signature is the size of a public key. */ +} TPMS_SIGNATURE_RSA; + +/* Table 168 - Definition of Types for {RSA} Signature */ + +typedef TPMS_SIGNATURE_RSA TPMS_SIGNATURE_RSASSA; +typedef TPMS_SIGNATURE_RSA TPMS_SIGNATURE_RSAPSS; + +/* Table 169 - Definition of {ECC} TPMS_SIGNATURE_ECC Structure */ + +typedef struct { + TPMI_ALG_HASH hash; /* the hash algorithm used in the signature process TPM_ALG_NULL is not allowed. */ + TPM2B_ECC_PARAMETER signatureR; + TPM2B_ECC_PARAMETER signatureS; +} TPMS_SIGNATURE_ECC; + +/* Table 170 - Definition of Types for {ECC} TPMS_SIGNATURE_ECC */ + +typedef TPMS_SIGNATURE_ECC TPMS_SIGNATURE_ECDSA; +typedef TPMS_SIGNATURE_ECC TPMS_SIGNATURE_ECDAA; +typedef TPMS_SIGNATURE_ECC TPMS_SIGNATURE_SM2; +typedef TPMS_SIGNATURE_ECC TPMS_SIGNATURE_ECSCHNORR; + +/* Table 171 - Definition of TPMU_SIGNATURE Union <IN/OUT, S> */ + +typedef union { +#ifdef TPM_ALG_RSASSA + TPMS_SIGNATURE_RSASSA rsassa; /* TPM_ALG_RSASSA */ +#endif +#ifdef TPM_ALG_RSAPSS + TPMS_SIGNATURE_RSAPSS rsapss; /* TPM_ALG_RSAPSS */ +#endif +#ifdef TPM_ALG_ECDSA + TPMS_SIGNATURE_ECDSA ecdsa; /* TPM_ALG_ECDSA */ +#endif +#ifdef TPM_ALG_ECDAA + TPMS_SIGNATURE_ECDSA ecdaa; /* TPM_ALG_ECDAA */ +#endif +#ifdef TPM_ALG_SM2 + TPMS_SIGNATURE_ECDSA sm2; /* TPM_ALG_SM2 */ +#endif +#ifdef TPM_ALG_ECSCHNORR + TPMS_SIGNATURE_ECDSA ecschnorr; /* TPM_ALG_ECSCHNORR */ +#endif +#ifdef TPM_ALG_HMAC + TPMT_HA hmac; /* TPM_ALG_HMAC */ +#endif + TPMS_SCHEME_HASH any; /* used to access the hash */ +} TPMU_SIGNATURE; + +/* Table 172 - Definition of TPMT_SIGNATURE Structure */ + +typedef struct { + TPMI_ALG_SIG_SCHEME sigAlg; /* selector of the algorithm used to construct the signature */ + TPMU_SIGNATURE signature; /* This shall be the actual signature information. */ +} TPMT_SIGNATURE; + +/* Table 173 - Definition of TPMU_ENCRYPTED_SECRET Union <S> */ + +typedef union { +#ifdef TPM_ALG_ECC + BYTE ecc[sizeof(TPMS_ECC_POINT)]; /* TPM_ALG_ECC */ +#endif +#ifdef TPM_ALG_RSA + BYTE rsa[MAX_RSA_KEY_BYTES]; /* TPM_ALG_RSA */ +#endif +#ifdef TPM_ALG_SYMCIPHER + BYTE symmetric[sizeof(TPM2B_DIGEST)]; /* TPM_ALG_SYMCIPHER */ +#endif +#ifdef TPM_ALG_KEYEDHASH + BYTE keyedHash[sizeof(TPM2B_DIGEST)]; /* TPM_ALG_KEYEDHASH */ +#endif +} TPMU_ENCRYPTED_SECRET; + +/* Table 174 - Definition of TPM2B_ENCRYPTED_SECRET Structure */ + +typedef struct { + UINT16 size; /* size of the secret value */ + BYTE secret[sizeof(TPMU_ENCRYPTED_SECRET)]; /* secret */ +} ENCRYPTED_SECRET_2B; + +typedef union { + ENCRYPTED_SECRET_2B t; + TPM2B b; +} TPM2B_ENCRYPTED_SECRET; + +/* Table 175 - Definition of (TPM_ALG_ID) TPMI_ALG_PUBLIC Type */ + +typedef TPM_ALG_ID TPMI_ALG_PUBLIC; + +/* Table 176 - Definition of TPMU_PUBLIC_ID Union <IN/OUT, S> */ + +typedef union { +#ifdef TPM_ALG_KEYEDHASH + TPM2B_DIGEST keyedHash; /* TPM_ALG_KEYEDHASH */ +#endif +#ifdef TPM_ALG_SYMCIPHER + TPM2B_DIGEST sym; /* TPM_ALG_SYMCIPHER */ +#endif +#ifdef TPM_ALG_RSA + TPM2B_PUBLIC_KEY_RSA rsa; /* TPM_ALG_RSA */ +#endif +#ifdef TPM_ALG_ECC + TPMS_ECC_POINT ecc; /* TPM_ALG_ECC */ +#endif + TPMS_DERIVE derive; /* only allowed for TPM2_CreateLoaded when + parentHandle is a Derivation Parent */ +} TPMU_PUBLIC_ID; + +/* Table 177 - Definition of TPMS_KEYEDHASH_PARMS Structure */ + +typedef struct { + TPMT_KEYEDHASH_SCHEME scheme; /* Indicates the signing method used for a keyedHash signing object */ +} TPMS_KEYEDHASH_PARMS; + +/* Table 178 - Definition of TPMS_ASYM_PARMS Structure <> */ + +typedef struct { + TPMT_SYM_DEF_OBJECT symmetric; /* the companion symmetric algorithm for a restricted decryption key */ + TPMT_ASYM_SCHEME scheme; /* for a key with the sign attribute SET, a valid signing scheme for the key type */ +} TPMS_ASYM_PARMS; + +/* Table 179 - Definition of {RSA} TPMS_RSA_PARMS Structure */ + +typedef struct { + TPMT_SYM_DEF_OBJECT symmetric; /* for a restricted decryption key, shall be set to a supported symmetric algorithm, key size, and mode. */ + TPMT_RSA_SCHEME scheme; /* for an unrestricted signing key, shall be either TPM_ALG_RSAPSS TPM_ALG_RSASSA or TPM_ALG_NULL */ + TPMI_RSA_KEY_BITS keyBits; /* number of bits in the public modulus */ + UINT32 exponent; /* the public exponent */ +} TPMS_RSA_PARMS; + +/* Table 180 - Definition of {ECC} TPMS_ECC_PARMS Structure */ + +typedef struct { + TPMT_SYM_DEF_OBJECT symmetric; /* for a restricted decryption key, shall be set to a supported symmetric algorithm, key size. and mode. */ + TPMT_ECC_SCHEME scheme; /* If the sign attribute of the key is SET, then this shall be a valid signing scheme. */ + TPMI_ECC_CURVE curveID; /* ECC curve ID */ + TPMT_KDF_SCHEME kdf; /* an optional key derivation scheme for generating a symmetric key from a Z value */ +} TPMS_ECC_PARMS; + +/* Table 181 - Definition of TPMU_PUBLIC_PARMS Union <IN/OUT, S> */ + +typedef union { +#ifdef TPM_ALG_KEYEDHASH + TPMS_KEYEDHASH_PARMS keyedHashDetail; /* TPM_ALG_KEYEDHASH */ +#endif +#ifdef TPM_ALG_SYMCIPHER + TPMS_SYMCIPHER_PARMS symDetail; /* TPM_ALG_SYMCIPHER */ +#endif +#ifdef TPM_ALG_RSA + TPMS_RSA_PARMS rsaDetail; /* TPM_ALG_RSA */ +#endif +#ifdef TPM_ALG_ECC + TPMS_ECC_PARMS eccDetail; /* TPM_ALG_ECC */ +#endif + TPMS_ASYM_PARMS asymDetail; /* common scheme structure for RSA and ECC keys */ +} TPMU_PUBLIC_PARMS; + +/* Table 182 - Definition of TPMT_PUBLIC_PARMS Structure */ + +typedef struct { + TPMI_ALG_PUBLIC type; /* the algorithm to be tested */ + TPMU_PUBLIC_PARMS parameters; /* the algorithm details */ +} TPMT_PUBLIC_PARMS; + +/* Table 183 - Definition of TPMT_PUBLIC Structure */ + +typedef struct { + TPMI_ALG_PUBLIC type; /* "algorithm" associated with this object */ + TPMI_ALG_HASH nameAlg; /* algorithm used for computing the Name of the object */ + TPMA_OBJECT objectAttributes; /* attributes that, along with type, determine the manipulations of this object */ + TPM2B_DIGEST authPolicy; /* optional policy for using this key */ + TPMU_PUBLIC_PARMS parameters; /* the algorithm or structure details */ + TPMU_PUBLIC_ID unique; /* the unique identifier of the structure */ +} TPMT_PUBLIC; + +/* Table 184 - Definition of TPM2B_PUBLIC Structure */ + +typedef struct { + UINT16 size; /* size of publicArea */ + TPMT_PUBLIC publicArea; /* the public area */ +} TPM2B_PUBLIC; + +/* Table 192 - Definition of TPM2B_TEMPLATE Structure */ + +typedef union { + struct { + UINT16 size; /* size of publicArea */ + BYTE buffer[sizeof(TPMT_PUBLIC)]; /* the public area */ + } t; + TPM2B b; +} TPM2B_TEMPLATE; + +/* Table 186 - Definition of TPMU_SENSITIVE_COMPOSITE Union <IN/OUT, S> */ + +typedef union { +#ifdef TPM_ALG_RSA + TPM2B_PRIVATE_KEY_RSA rsa; /* TPM_ALG_RSA a prime factor of the public key */ +#endif +#ifdef TPM_ALG_ECC + TPM2B_ECC_PARAMETER ecc; /* TPM_ALG_ECC the integer private key */ +#endif +#ifdef TPM_ALG_KEYEDHASH + TPM2B_SENSITIVE_DATA bits; /* TPM_ALG_KEYEDHASH the private data */ +#endif +#ifdef TPM_ALG_SYMCIPHER + TPM2B_SYM_KEY sym; /* TPM_ALG_SYMCIPHER the symmetric key */ +#endif +} TPMU_SENSITIVE_COMPOSITE; + +/* Table 187 - Definition of TPMT_SENSITIVE Structure */ + +typedef struct { + TPMI_ALG_PUBLIC sensitiveType; /* identifier for the sensitive area */ + TPM2B_AUTH authValue; /* user authorization data */ + TPM2B_DIGEST seedValue; /* for asymmetric key object, the optional protection seed; for other objects, the obfuscation value */ + TPMU_SENSITIVE_COMPOSITE sensitive; /* the type-specific private data */ +} TPMT_SENSITIVE; + +/* Table 188 - Definition of TPM2B_SENSITIVE Structure <IN/OUT> */ + +typedef struct { + UINT16 size; /* size of the private structure */ + TPMT_SENSITIVE sensitiveArea; /* an unencrypted sensitive area */ +} SENSITIVE_2B; + +typedef union { + SENSITIVE_2B t; + TPM2B b; +} TPM2B_SENSITIVE; + +/* Table 189 - Definition of _PRIVATE Structure <> */ + +typedef struct { + TPM2B_DIGEST integrityOuter; + TPM2B_DIGEST integrityInner; /* could also be a TPM2B_IV */ + TPM2B_SENSITIVE sensitive; /* the sensitive area */ +} _PRIVATE; + +/* Table 190 - Definition of TPM2B_PRIVATE Structure <IN/OUT, S> */ + +typedef struct { + UINT16 size; /* size of the private structure */ + BYTE buffer[sizeof(_PRIVATE)]; /* an encrypted private area */ +} PRIVATE_2B; + +typedef union { + PRIVATE_2B t; + TPM2B b; +} TPM2B_PRIVATE; + +/* Table 191 - Definition of _ID_OBJECT Structure <> */ + +typedef struct { + TPM2B_DIGEST integrityHMAC; /* HMAC using the nameAlg of the storage key on the target TPM */ + TPM2B_DIGEST encIdentity; /* credential protector information returned if name matches the referenced object */ +} _ID_OBJECT; + +/* Table 192 - Definition of TPM2B_ID_OBJECT Structure <IN/OUT> */ + +typedef struct { + UINT16 size; /* size of the credential structure */ + BYTE credential[sizeof(_ID_OBJECT)]; /* an encrypted credential area */ +} ID_OBJECT_2B; + +typedef union { + ID_OBJECT_2B t; + TPM2B b; +} TPM2B_ID_OBJECT; + +/* Table 193 - Definition of (UINT32) TPM_NV_INDEX Bits <> */ + +#if defined TPM_BITFIELD_LE + +typedef union { + struct { + unsigned int index : 24; /* 23:0 The Index of the NV location */ + unsigned int RH_NV : 8; /* 31:24 constant value of TPM_HT_NV_INDEX indicating the NV Index range */ + }; + UINT32 val; +} TPM_NV_INDEX; + +#elif defined TPM_BITFIELD_BE + +typedef union { + struct { + unsigned int RH_NV : 8; /* 31:24 constant value of TPM_HT_NV_INDEX indicating the NV Index range */ + unsigned int index : 24; /* 23:0 The Index of the NV location */ + }; + UINT32 val; +} TPM_NV_INDEX; + +#else + +typedef struct { + UINT32 val; +} TPM_NV_INDEX; + +#endif + +#define TPM_NV_INDEX_INDEX 0x00ffffff +#define TPM_NV_INDEX_RH_NV 0xff000000 + +/* Table 194 - Definition of TPM_NT Constants */ + +#define TPM_NT_ORDINARY 0x0 /* Ordinary - contains data that is opaque to the TPM that can only be modified using TPM2_NV_Write(). */ +#define TPM_NT_COUNTER 0x1 /* Counter - contains an 8-octet value that is to be used as a + counter and can only be modified with TPM2_NV_Increment() */ +#define TPM_NT_BITS 0x2 /* Bit Field - contains an 8-octet value to be used as a bit field + and can only be modified with TPM2_NV_SetBits(). */ +#define TPM_NT_EXTEND 0x4 /* Extend - contains a digest-sized value used like a PCR. The Index + can only be modified using TPM2_NV_Extend(). The extend will use + the nameAlg of the Index. */ +#define TPM_NT_PIN_FAIL 0x8 /* PIN Fail - contains a PIN limit and a PIN count that increments on a PIN authorization failure */ +#define TPM_NT_PIN_PASS 0x9 /* PIN Pass - contains a PIN limit and a PIN count that increments on a PIN authorization success */ + +/* Table 204 - Definition of TPMS_NV_PIN_COUNTER_PARAMETERS Structure */ + +typedef struct { + uint32_t pinCount; /* This counter shows the current number of successful authValue + authorization attempts to access a TPM_NT_PIN_PASS index or the current + number of unsuccessful authValue authorization attempts to access a + TPM_NT_PIN_FAIL index. */ + uint32_t pinLimit; /* This threshold is the value of pinCount at which the authValue + authorization of the host TPM_NT_PIN_PASS or TPM_NT_PIN_FAIL index is + locked out. */ +} TPMS_NV_PIN_COUNTER_PARAMETERS; + +/* Table 205 - Definition of (UINT32) TPMA_NV Bits */ + +#if defined TPM_BITFIELD_LE + +typedef union { + struct { + unsigned int TPMA_NV_PPWRITE : 1; /* 0 The Index data can be written if Platform Authorization is provided. */ + unsigned int TPMA_NV_OWNERWRITE : 1; /* 1 The Index data can be written if Owner Authorization is provided. */ + unsigned int TPMA_NV_AUTHWRITE : 1; /* 2 Authorizations to change the Index contents that require USER role may be provided with an HMAC session or password. */ + unsigned int TPMA_NV_POLICYWRITE : 1; /* 3 Authorizations to change the Index contents that require USER role may be provided with a policy session. */ + unsigned int TPM_NT : 4; /* 7:4 The type of the index */ + unsigned int Reserved1 : 2; /* 9:8 shall be zero reserved for future use */ + unsigned int TPMA_NV_POLICY_DELETE : 1; /* 10 Index may not be deleted unless the authPolicy is satisfied. */ + unsigned int TPMA_NV_WRITELOCKED : 1; /* 11 Index cannot be written. */ + unsigned int TPMA_NV_WRITEALL : 1; /* 12 A partial write of the Index data is not allowed. The write size shall match the defined space size. */ + unsigned int TPMA_NV_WRITEDEFINE : 1; /* 13 TPM2_NV_WriteLock() may be used to prevent further writes to this location. */ + unsigned int TPMA_NV_WRITE_STCLEAR : 1; /* 14 TPM2_NV_WriteLock() may be used to prevent further writes to this location until the next TPM Reset or TPM Restart. */ + unsigned int TPMA_NV_GLOBALLOCK : 1; /* 15 If TPM2_NV_GlobalLock() is successful, then further writes are not permitted until the next TPM Reset or TPM Restart. */ + unsigned int TPMA_NV_PPREAD : 1; /* 16 The Index data can be read if Platform Authorization is provided. */ + unsigned int TPMA_NV_OWNERREAD : 1; /* 17 The Index data can be read if Owner Authorization is provided. */ + unsigned int TPMA_NV_AUTHREAD : 1; /* 18 The Index data may be read if the authValue is provided. */ + unsigned int TPMA_NV_POLICYREAD : 1; /* 19 The Index data may be read if the authPolicy is satisfied. */ + unsigned int Reserved2 : 5; /* 24:20 shall be zero reserved for future use */ + unsigned int TPMA_NV_NO_DA : 1; /* 25 Authorization failures of the Index do not affect the DA logic */ + unsigned int TPMA_NV_ORDERLY : 1; /* 26 NV Index state is only required to be saved when the TPM performs an orderly shutdown */ + unsigned int TPMA_NV_CLEAR_STCLEAR : 1; /* 27 TPMA_NV_WRITTEN for the Index is CLEAR by TPM Reset or TPM Restart. */ + unsigned int TPMA_NV_READLOCKED : 1; /* 28 Reads of the Index are blocked until the next TPM Reset or TPM Restart. */ + unsigned int TPMA_NV_WRITTEN : 1; /* 29 Index has been written. */ + unsigned int TPMA_NV_PLATFORMCREATE : 1; /* 30 This Index may be undefined with Platform Authorization but not with Owner Authorization. */ + unsigned int TPMA_NV_READ_STCLEAR : 1; /* 31 TPM2_NV_ReadLock() may be used to SET TPMA_NV_READLOCKED for this Index. */ + }; + UINT32 val; +} TPMA_NV; + +#elif defined TPM_BITFIELD_BE + +typedef union { + struct { + unsigned int TPMA_NV_READ_STCLEAR : 1; /* 31 TPM2_NV_ReadLock() may be used to SET TPMA_NV_READLOCKED for this Index. */ + unsigned int TPMA_NV_PLATFORMCREATE : 1; /* 30 This Index may be undefined with Platform Authorization but not with Owner Authorization. */ + unsigned int TPMA_NV_WRITTEN : 1; /* 29 Index has been written. */ + unsigned int TPMA_NV_READLOCKED : 1; /* 28 Reads of the Index are blocked until the next TPM Reset or TPM Restart. */ + unsigned int TPMA_NV_CLEAR_STCLEAR : 1; /* 27 TPMA_NV_WRITTEN for the Index is CLEAR by TPM Reset or TPM Restart. */ + unsigned int TPMA_NV_ORDERLY : 1; /* 26 NV Index state is only required to be saved when the TPM performs an orderly shutdown */ + unsigned int TPMA_NV_NO_DA : 1; /* 25 Authorization failures of the Index do not affect the DA logic */ + unsigned int Reserved2 : 5; /* 24:20 shall be zero reserved for future use */ + unsigned int TPMA_NV_POLICYREAD : 1; /* 19 The Index data may be read if the authPolicy is satisfied. */ + unsigned int TPMA_NV_AUTHREAD : 1; /* 18 The Index data may be read if the authValue is provided. */ + unsigned int TPMA_NV_OWNERREAD : 1; /* 17 The Index data can be read if Owner Authorization is provided. */ + unsigned int TPMA_NV_PPREAD : 1; /* 16 The Index data can be read if Platform Authorization is provided. */ + unsigned int TPMA_NV_GLOBALLOCK : 1; /* 15 If TPM2_NV_GlobalLock() is successful, then further writes are not permitted until the next TPM Reset or TPM Restart. */ + unsigned int TPMA_NV_WRITE_STCLEAR : 1; /* 14 TPM2_NV_WriteLock() may be used to prevent further writes to this location until the next TPM Reset or TPM Restart. */ + unsigned int TPMA_NV_WRITEDEFINE : 1; /* 13 TPM2_NV_WriteLock() may be used to prevent further writes to this location. */ + unsigned int TPMA_NV_WRITEALL : 1; /* 12 A partial write of the Index data is not allowed. The write size shall match the defined space size. */ + unsigned int TPMA_NV_WRITELOCKED : 1; /* 11 Index cannot be written. */ + unsigned int TPMA_NV_POLICY_DELETE : 1; /* 10 Index may not be deleted unless the authPolicy is satisfied. */ + unsigned int Reserved1 : 2; /* 9:8 shall be zero reserved for future use */ + unsigned int TPM_NT : 4; /* 7:4 The type of the index */ + unsigned int TPMA_NV_POLICYWRITE : 1; /* 3 Authorizations to change the Index contents that require USER role may be provided with a policy session. */ + unsigned int TPMA_NV_AUTHWRITE : 1; /* 2 Authorizations to change the Index contents that require USER role may be provided with an HMAC session or password. */ + unsigned int TPMA_NV_OWNERWRITE : 1; /* 1 The Index data can be written if Owner Authorization is provided. */ + unsigned int TPMA_NV_PPWRITE : 1; /* 0 The Index data can be written if Platform Authorization is provided. */ + }; + UINT32 val; +} TPMA_NV; + +#else + +typedef struct { + UINT32 val; +} TPMA_NV; + +#endif + +#define TPMA_NVA_PPWRITE 0x00000001 +#define TPMA_NVA_OWNERWRITE 0x00000002 +#define TPMA_NVA_AUTHWRITE 0x00000004 +#define TPMA_NVA_POLICYWRITE 0x00000008 +#define TPMA_NVA_ORDINARY 0x00000000 +#define TPMA_NVA_COUNTER 0x00000010 +#define TPMA_NVA_BITS 0x00000020 +#define TPMA_NVA_EXTEND 0x00000040 +#define TPMA_NVA_PIN_FAIL 0x00000080 +#define TPMA_NVA_PIN_PASS 0x00000090 +#define TPMA_NVA_RESERVED1 0x00000300 +#define TPMA_NVA_POLICY_DELETE 0x00000400 +#define TPMA_NVA_WRITELOCKED 0x00000800 +#define TPMA_NVA_WRITEALL 0x00001000 +#define TPMA_NVA_WRITEDEFINE 0x00002000 +#define TPMA_NVA_WRITE_STCLEAR 0x00004000 +#define TPMA_NVA_GLOBALLOCK 0x00008000 +#define TPMA_NVA_PPREAD 0x00010000 +#define TPMA_NVA_OWNERREAD 0x00020000 +#define TPMA_NVA_AUTHREAD 0x00040000 +#define TPMA_NVA_POLICYREAD 0x00080000 +#define TPMA_NVA_RESERVED2 0x01f00000 +#define TPMA_NVA_NO_DA 0x02000000 +#define TPMA_NVA_ORDERLY 0x04000000 +#define TPMA_NVA_CLEAR_STCLEAR 0x08000000 +#define TPMA_NVA_READLOCKED 0x10000000 +#define TPMA_NVA_WRITTEN 0x20000000 +#define TPMA_NVA_PLATFORMCREATE 0x40000000 +#define TPMA_NVA_READ_STCLEAR 0x80000000 + +#define TPMA_NVA_TPM_NT_MASK 0x000000f0 +#define TPMA_NV_RESERVED (TPMA_NVA_RESERVED1 | TPMA_NVA_RESERVED2) + +/* Table 197 - Definition of TPMS_NV_PUBLIC Structure */ + +typedef struct { + TPMI_RH_NV_INDEX nvIndex; /* the handle of the data area */ + TPMI_ALG_HASH nameAlg; /* hash algorithm used to compute the name of the Index and used for the authPolicy */ + TPMA_NV attributes; /* the Index attributes */ + TPM2B_DIGEST authPolicy; /* optional access policy for the Index */ + UINT16 dataSize; /* the size of the data area */ +} TPMS_NV_PUBLIC; + +/* Table 198 - Definition of TPM2B_NV_PUBLIC Structure */ + +typedef struct { + UINT16 size; /* size of nvPublic */ + TPMS_NV_PUBLIC nvPublic; /* the public area */ +} TPM2B_NV_PUBLIC; + +/* Table 199 - Definition of TPM2B_CONTEXT_SENSITIVE Structure <IN/OUT> */ + +typedef struct { + UINT16 size; + BYTE buffer[MAX_CONTEXT_SIZE]; /* the sensitive data */ +} CONTEXT_SENSITIVE_2B; + +typedef union { + CONTEXT_SENSITIVE_2B t; + TPM2B b; +} TPM2B_CONTEXT_SENSITIVE; + +/* Table 200 - Definition of TPMS_CONTEXT_DATA Structure <IN/OUT, S> */ + +typedef struct { + TPM2B_DIGEST integrity; /* the integrity value */ + TPM2B_CONTEXT_SENSITIVE encrypted; /* the sensitive area */ +} TPMS_CONTEXT_DATA; + +/* Table 201 - Definition of TPM2B_CONTEXT_DATA Structure <IN/OUT> */ + +typedef struct { + UINT16 size; + BYTE buffer[sizeof(TPMS_CONTEXT_DATA)]; +} CONTEXT_DATA_2B; + +typedef union { + CONTEXT_DATA_2B t; + TPM2B b; +} TPM2B_CONTEXT_DATA; + +/* Table 202 - Definition of TPMS_CONTEXT Structure */ + +typedef struct { + UINT64 sequence; /* the sequence number of the context */ + TPMI_DH_SAVED savedHandle; /* a handle indicating if the context is a session, object or sequence object */ + TPMI_RH_HIERARCHY hierarchy; /* the hierarchy of the context */ + TPM2B_CONTEXT_DATA contextBlob; /* the context data and integrity HMAC */ +} TPMS_CONTEXT; + +/* Table 203 - Context Handle Values */ + +#define TPM_CONTEXT_HANDLE_HMAC 0x02000000 /* an HMAC session context */ +#define TPM_CONTEXT_HANDLE_POLICY_SESSION 0x03000000 /* a policy session context */ +#define TPM_CONTEXT_HANDLE_TRANSIENT 0x80000000 /* an ordinary transient object */ +#define TPM_CONTEXT_HANDLE_SEQUENCE 0x80000001 /* a sequence object */ +#define TPM_CONTEXT_HANDLE_STCLEAR 0x80000002 /* a transient object with the stClear attribute SET */ + +/* Table 204 - Definition of TPMS_CREATION_DATA Structure <OUT> */ + +typedef struct { + TPML_PCR_SELECTION pcrSelect; /* list indicating the PCR included in pcrDigest */ + TPM2B_DIGEST pcrDigest; /* digest of the selected PCR using nameAlg of the object for which this structure is being created */ + TPMA_LOCALITY locality; /* the locality at which the object was created */ + TPM_ALG_ID parentNameAlg; /* nameAlg of the parent */ + TPM2B_NAME parentName; /* Name of the parent at time of creation */ + TPM2B_NAME parentQualifiedName; /* Qualified Name of the parent at the time of creation */ + TPM2B_DATA outsideInfo; /* association with additional information added by the key creator */ +} TPMS_CREATION_DATA; + +/* Table 205 - Definition of TPM2B_CREATION_DATA Structure <OUT> */ + +typedef struct { + UINT16 size; /* size of the creation data */ + TPMS_CREATION_DATA creationData; +} TPM2B_CREATION_DATA; + +typedef struct tdNTC2_CFG_STRUCT { + uint8_t i2cLoc1_2; + uint8_t i2cLoc3_4; + uint8_t AltCfg; + uint8_t Direction; + uint8_t PullUp; + uint8_t PushPull; + uint8_t CFG_A; + uint8_t CFG_B; + uint8_t CFG_C; + uint8_t CFG_D; + uint8_t CFG_E; + uint8_t CFG_F; + uint8_t CFG_G; + uint8_t CFG_H; + uint8_t CFG_I; + uint8_t CFG_J; + uint8_t IsValid; /* Must be AAh */ + uint8_t IsLocked; /* Ignored on NTC2_PreConfig, NTC2_GetConfig returns AAh once configuration + is locked. */ +} NTC2_CFG_STRUCT; + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libstb/tss2/ibmtss/TakeOwnership_fp.h b/libstb/tss2/ibmtss/TakeOwnership_fp.h new file mode 100644 index 0000000..091b7bf --- /dev/null +++ b/libstb/tss2/ibmtss/TakeOwnership_fp.h @@ -0,0 +1,67 @@ +/********************************************************************************/ +/* */ +/* TPM 1.2 TakeOwnership */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: TakeOwnership_fp.h 1257 2018-06-27 20:52:08Z kgoldman $ */ +/* */ +/* (c) Copyright IBM Corporation 2018. */ +/* */ +/* All rights reserved. */ +/* */ +/* Redistribution and use in source and binary forms, with or without */ +/* modification, are permitted provided that the following conditions are */ +/* met: */ +/* */ +/* Redistributions of source code must retain the above copyright notice, */ +/* this list of conditions and the following disclaimer. */ +/* */ +/* 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. */ +/* */ +/* Neither the names of the IBM Corporation nor the names of its */ +/* contributors may be used to endorse or promote products derived from */ +/* this software without specific prior written permission. */ +/* */ +/* 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 TAKEOWNERSHIP_FP_H +#define TAKEOWNERSHIP_FP_H + +#include <ibmtss/tpmtypes12.h> +#include <ibmtss/tpmstructures12.h> + +#include <ibmtss/Implementation.h> + +typedef struct { + TPM_PROTOCOL_ID protocolID; + uint32_t encOwnerAuthSize; + uint8_t encOwnerAuth[MAX_RSA_KEY_BYTES]; + uint32_t encSrkAuthSize; + uint8_t encSrkAuth[MAX_RSA_KEY_BYTES]; + TPM_KEY12 srkParams; +} TakeOwnership_In; + +typedef struct { + TPM_KEY12 srkPub; +} TakeOwnership_Out; + +TPM_RC +TPM2_TakeOwnership( + TakeOwnership_In *in, // IN: input parameter buffer + TakeOwnership_Out *out // OUT: output parameter buffer + ); + +#endif diff --git a/libstb/tss2/ibmtss/TestParms_fp.h b/libstb/tss2/ibmtss/TestParms_fp.h new file mode 100644 index 0000000..1d0ca4d --- /dev/null +++ b/libstb/tss2/ibmtss/TestParms_fp.h @@ -0,0 +1,79 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: TestParms_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef TESTPARMS_FP_H +#define TESTPARMS_FP_H + +typedef struct { + TPMT_PUBLIC_PARMS parameters; +} TestParms_In; + +#define RC_TestParms_parameters (TPM_RC_P + TPM_RC_1) + +TPM_RC +TPM2_TestParms( + TestParms_In *in // IN: input parameter list + ); + + +#endif diff --git a/libstb/tss2/ibmtss/TpmBuildSwitches.h b/libstb/tss2/ibmtss/TpmBuildSwitches.h new file mode 100644 index 0000000..e61d9ed --- /dev/null +++ b/libstb/tss2/ibmtss/TpmBuildSwitches.h @@ -0,0 +1,87 @@ +/********************************************************************************/ +/* */ +/* TSS Compiler Build Switches */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: TpmBuildSwitches.h 1294 2018-08-09 19:08:34Z 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, 2012-2018 */ +/* */ +/********************************************************************************/ + +// 5.12 TpmBuildSwitches.h + +// This file contains the build switches. + +#ifndef _TPM_BUILD_SWITCHES_H +#define _TPM_BUILD_SWITCHES_H + +// Switch added to support packed lists that leave out space associated with unimplemented +// commands. Comment this out to use linear lists. NOTE: if vendor specific commands are present, +// the associated list is always in compressed form. +#define COMPRESSED_LISTS + +#ifdef _MSC_VER +// This macro is used to handle LIB_EXPORT of function and variable names in lieu of a .def +// file. Visual Studio requires that functions be explicity exported and imported. +# define LIB_EXPORT __declspec(dllexport) // VS compatible version +#endif + +// The following definitions are used if they have not already been defined. The defaults for these +// settings are compatible with ISO/IEC 9899:2011 (E) + +#ifndef LIB_EXPORT +# define LIB_EXPORT +#endif + +#endif // _TPM_BUILD_SWITCHES_H diff --git a/libstb/tss2/ibmtss/Unmarshal12_fp.h b/libstb/tss2/ibmtss/Unmarshal12_fp.h new file mode 100644 index 0000000..60149e0 --- /dev/null +++ b/libstb/tss2/ibmtss/Unmarshal12_fp.h @@ -0,0 +1,94 @@ +/********************************************************************************/ +/* */ +/* Parameter Unmarshaling */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: Unmarshal12_fp.h 1285 2018-07-27 18:33:41Z kgoldman $ */ +/* */ +/* (c) Copyright IBM Corporation 2018 */ +/* */ +/* All rights reserved. */ +/* */ +/* Redistribution and use in source and binary forms, with or without */ +/* modification, are permitted provided that the following conditions are */ +/* met: */ +/* */ +/* Redistributions of source code must retain the above copyright notice, */ +/* this list of conditions and the following disclaimer. */ +/* */ +/* 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. */ +/* */ +/* Neither the names of the IBM Corporation nor the names of its */ +/* contributors may be used to endorse or promote products derived from */ +/* this software without specific prior written permission. */ +/* */ +/* 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 UNMARSHAL12_FP_H +#define UNMARSHAL12_FP_H + +#include "TPM_Types.h" +#include "tpmtypes12.h" +#include <ibmtss/tpmstructures12.h> + +#ifdef __cplusplus +extern "C" { +#endif + + TPM_RC + TSS_TPM_STARTUP_TYPE_Unmarshalu(TPM_STARTUP_TYPE *target, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_TPM_VERSION_Unmarshalu(TPM_VERSION *target, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_TPM_TAG_Unmarshalu(TPM_TAG *target, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_TPM_PCR_SELECTION_Unmarshalu(TPM_PCR_SELECTION *target, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_TPM4B_TPM_PCR_INFO_LONG_Unmarshalu(TPM_PCR_INFO_LONG *target, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_TPM_PCR_INFO_LONG_Unmarshalu(TPM_PCR_INFO_LONG *target, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_TPM_PCR_INFO_SHORT_Unmarshalu(TPM_PCR_INFO_SHORT *target, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_TPM_SYMMETRIC_KEY_Unmarshalu(TPM_SYMMETRIC_KEY *target, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_TPM_RSA_KEY_PARMS_Unmarshalu(TPM_RSA_KEY_PARMS *target, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_TPMU_PARMS_Unmarshalu(TPMU_PARMS *target, BYTE **buffer, uint32_t *size, uint32_t selector); + TPM_RC + TSS_TPM4B_TPMU_PARMS_Unmarshalu(TPMU_PARMS *target, BYTE **buffer, uint32_t *size, uint32_t selector); + TPM_RC + TSS_TPM_KEY_PARMS_Unmarshalu(TPM_KEY_PARMS *target, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_TPM_KEY12_Unmarshalu(TPM_KEY12 *target, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_TPM_STORE_PUBKEY_Unmarshalu(TPM_STORE_PUBKEY *target, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_TPM_PUBKEY_Unmarshalu(TPM_PUBKEY *target, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_TPM_NV_ATTRIBUTES_Unmarshalu(TPM_NV_ATTRIBUTES *target, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_TPM_NV_DATA_PUBLIC_Unmarshalu(TPM_NV_DATA_PUBLIC *target, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_TPM_CAP_VERSION_INFO_Unmarshalu(TPM_CAP_VERSION_INFO *target, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_TPM_DA_INFO_Unmarshalu(TPM_DA_INFO *target, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_TPM_DA_INFO_LIMITED_Unmarshalu(TPM_DA_INFO_LIMITED *target, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_TPM_DA_ACTION_TYPE_Unmarshalu(TPM_DA_ACTION_TYPE *target, BYTE **buffer, uint32_t *size); + +#endif diff --git a/libstb/tss2/ibmtss/Unmarshal_fp.h b/libstb/tss2/ibmtss/Unmarshal_fp.h new file mode 100644 index 0000000..6f8a293 --- /dev/null +++ b/libstb/tss2/ibmtss/Unmarshal_fp.h @@ -0,0 +1,694 @@ +/********************************************************************************/ +/* */ +/* Unmarshal Functions */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* */ +/* 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, 2012-2019 */ +/* */ +/********************************************************************************/ + +/* The functions with the TSS_ prefix are preferred. They use an unsigned size. The functions + without the prefix are deprecated. */ + +#ifndef UNMARSHAL_FP_H +#define UNMARSHAL_FP_H + +#include "TPM_Types.h" + +#ifdef __cplusplus +extern "C" { +#endif + + LIB_EXPORT TPM_RC + TSS_UINT8_Unmarshalu(UINT8 *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_INT8_Unmarshalu(INT8 *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_UINT16_Unmarshalu(UINT16 *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_UINT32_Unmarshalu(UINT32 *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_INT32_Unmarshalu(INT32 *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_UINT64_Unmarshalu(UINT64 *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_Array_Unmarshalu(BYTE *targetBuffer, UINT16 targetSize, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPM2B_Unmarshalu(TPM2B *target, UINT16 targetSize, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPM_KEY_BITS_Unmarshalu(TPM_KEY_BITS *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPM_GENERATED_Unmarshalu(TPM_GENERATED *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPM_ALG_ID_Unmarshalu(TPM_ALG_ID *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPM_ECC_CURVE_Unmarshalu(TPM_ECC_CURVE *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPM_CC_Unmarshalu(TPM_RC *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPM_RC_Unmarshalu(TPM_RC *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPM_CLOCK_ADJUST_Unmarshalu(TPM_CLOCK_ADJUST *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPM_EO_Unmarshalu(TPM_EO *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPM_ST_Unmarshalu(TPM_ST *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPM_SU_Unmarshalu(TPM_SU *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPM_SE_Unmarshalu(TPM_SE *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPM_CAP_Unmarshalu(TPM_CAP *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPM_PT_Unmarshalu(TPM_HANDLE *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPM_PT_PCR_Unmarshalu(TPM_PT_PCR *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPM_HANDLE_Unmarshalu(TPM_HANDLE *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMA_ALGORITHM_Unmarshalu(TPMA_ALGORITHM *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMA_OBJECT_Unmarshalu(TPMA_OBJECT *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMA_SESSION_Unmarshalu(TPMA_SESSION *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMA_LOCALITY_Unmarshalu(TPMA_LOCALITY *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMA_CC_Unmarshalu(TPMA_CC *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMI_YES_NO_Unmarshalu(TPMI_YES_NO *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMI_DH_OBJECT_Unmarshalu(TPMI_DH_OBJECT *target, BYTE **buffer, uint32_t *size, BOOL allowNull); + LIB_EXPORT TPM_RC + TSS_TPMI_DH_PARENT_Unmarshalu(TPMI_DH_PARENT *target, BYTE **buffer, uint32_t *size, BOOL allowNull); + LIB_EXPORT TPM_RC + TSS_TPMI_DH_PERSISTENT_Unmarshalu(TPMI_DH_PERSISTENT *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMI_DH_ENTITY_Unmarshalu(TPMI_DH_ENTITY *target, BYTE **buffer, uint32_t *size, BOOL allowNull); + LIB_EXPORT TPM_RC + TSS_TPMI_DH_PCR_Unmarshalu(TPMI_DH_PCR *target, BYTE **buffer, uint32_t *size, BOOL allowNull); + LIB_EXPORT TPM_RC + TSS_TPMI_SH_AUTH_SESSION_Unmarshalu(TPMI_SH_AUTH_SESSION *target, BYTE **buffer, uint32_t *size, BOOL allowPwd); + LIB_EXPORT TPM_RC + TSS_TPMI_SH_HMAC_Unmarshalu(TPMI_SH_HMAC *target, BYTE **buffer, uint32_t *size, BOOL allowNull); + LIB_EXPORT TPM_RC + TSS_TPMI_SH_POLICY_Unmarshalu(TPMI_SH_POLICY *target, BYTE **buffer, uint32_t *size, BOOL allowNull); + LIB_EXPORT TPM_RC + TSS_TPMI_DH_CONTEXT_Unmarshalu(TPMI_DH_CONTEXT *target, BYTE **buffer, uint32_t *size, BOOL allowNull); + LIB_EXPORT TPM_RC + TSS_TPMI_DH_SAVED_Unmarshalu(TPMI_DH_SAVED *target, BYTE **buffer, uint32_t *size, BOOL allowNull); + LIB_EXPORT TPM_RC + TSS_TPMI_RH_HIERARCHY_Unmarshalu(TPMI_RH_HIERARCHY *target, BYTE **buffer, uint32_t *size, BOOL allowNull); + LIB_EXPORT TPM_RC + TSS_TPMI_RH_ENABLES_Unmarshalu(TPMI_RH_ENABLES *target, BYTE **buffer, uint32_t *size, BOOL allowNull); + LIB_EXPORT TPM_RC + TSS_TPMI_RH_HIERARCHY_AUTH_Unmarshalu(TPMI_RH_HIERARCHY_AUTH *target, BYTE **buffer, uint32_t *size, BOOL allowNull); + LIB_EXPORT TPM_RC + TSS_TPMI_RH_PLATFORM_Unmarshalu(TPMI_RH_PLATFORM *target, BYTE **buffer, uint32_t *size, BOOL allowNull); + LIB_EXPORT TPM_RC + TSS_TPMI_RH_ENDORSEMENT_Unmarshalu(TPMI_RH_ENDORSEMENT *target, BYTE **buffer, uint32_t *size, BOOL allowNull); + LIB_EXPORT TPM_RC + TSS_TPMI_RH_PROVISION_Unmarshalu(TPMI_RH_PROVISION *target, BYTE **buffer, uint32_t *size, BOOL allowNull); + LIB_EXPORT TPM_RC + TSS_TPMI_RH_CLEAR_Unmarshalu(TPMI_RH_CLEAR *target, BYTE **buffer, uint32_t *size, BOOL allowNull); + LIB_EXPORT TPM_RC + TSS_TPMI_RH_NV_AUTH_Unmarshalu(TPMI_RH_NV_AUTH *target, BYTE **buffer, uint32_t *size, BOOL allowNull); + LIB_EXPORT TPM_RC + TSS_TPMI_RH_LOCKOUT_Unmarshalu(TPMI_RH_LOCKOUT *target, BYTE **buffer, uint32_t *size, BOOL allowNull); + LIB_EXPORT TPM_RC + TSS_TPMI_RH_NV_INDEX_Unmarshalu(TPMI_RH_NV_INDEX *target, BYTE **buffer, uint32_t *size, BOOL allowNull); + LIB_EXPORT TPM_RC + TSS_TPMI_ALG_HASH_Unmarshalu(TPMI_ALG_HASH *target, BYTE **buffer, uint32_t *size, BOOL allowNull); + LIB_EXPORT TPM_RC + TSS_TPMI_ALG_SYM_Unmarshalu(TPMI_ALG_SYM *target, BYTE **buffer, uint32_t *size, BOOL allowNull); + LIB_EXPORT TPM_RC + TSS_TPMI_ALG_SYM_OBJECT_Unmarshalu(TPMI_ALG_SYM_OBJECT *target, BYTE **buffer, uint32_t *size, BOOL allowNull); + LIB_EXPORT TPM_RC + TSS_TPMI_ALG_SYM_MODE_Unmarshalu(TPMI_ALG_SYM_MODE *target, BYTE **buffer, uint32_t *size, BOOL allowNull); + LIB_EXPORT TPM_RC + TSS_TPMI_ALG_KDF_Unmarshalu(TPMI_ALG_KDF *target, BYTE **buffer, uint32_t *size, BOOL allowNull); + LIB_EXPORT TPM_RC + TSS_TPMI_ALG_SIG_SCHEME_Unmarshalu(TPMI_ALG_SIG_SCHEME *target, BYTE **buffer, uint32_t *size, BOOL allowNull); + LIB_EXPORT TPM_RC + TSS_TPMI_ECC_KEY_EXCHANGE_Unmarshalu(TPMI_ECC_KEY_EXCHANGE *target, BYTE **buffer, uint32_t *size, BOOL allowNull); + LIB_EXPORT TPM_RC + TSS_TPMI_ST_COMMAND_TAG_Unmarshalu(TPMI_ST_COMMAND_TAG *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMI_ALG_MAC_SCHEME_Unmarshalu(TPMI_ALG_MAC_SCHEME *target, BYTE **buffer, uint32_t *size, BOOL allowNull); + LIB_EXPORT TPM_RC + TSS_TPMI_ALG_CIPHER_MODE_Unmarshalu(TPMI_ALG_CIPHER_MODE *target, BYTE **buffer, uint32_t *size, BOOL allowNull); + LIB_EXPORT TPM_RC + TSS_TPMS_EMPTY_Unmarshalu(TPMS_EMPTY *target, BYTE **buffer, uint32_t *size) +#ifdef __ULTRAVISOR__ + __attribute__ ((const)) +#endif + ; + LIB_EXPORT TPM_RC + TSS_TPMU_HA_Unmarshalu(TPMU_HA *target, BYTE **buffer, uint32_t *size, UINT32 selector); + LIB_EXPORT TPM_RC + TSS_TPMT_HA_Unmarshalu(TPMT_HA *target, BYTE **buffer, uint32_t *size, BOOL allowNull); + LIB_EXPORT TPM_RC + TSS_TPM2B_DIGEST_Unmarshalu(TPM2B_DIGEST *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPM2B_DATA_Unmarshalu(TPM2B_DATA *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPM2B_NONCE_Unmarshalu(TPM2B_NONCE *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPM2B_AUTH_Unmarshalu(TPM2B_AUTH *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPM2B_OPERAND_Unmarshalu(TPM2B_OPERAND *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPM2B_EVENT_Unmarshalu(TPM2B_EVENT *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPM2B_MAX_BUFFER_Unmarshalu(TPM2B_MAX_BUFFER *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPM2B_MAX_NV_BUFFER_Unmarshalu(TPM2B_MAX_NV_BUFFER *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPM2B_TIMEOUT_Unmarshalu(TPM2B_TIMEOUT *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPM2B_IV_Unmarshalu(TPM2B_IV *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPM2B_NAME_Unmarshalu(TPM2B_NAME *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_PCR_SELECTION_Unmarshalu(TPMS_PCR_SELECTION *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMT_TK_CREATION_Unmarshalu(TPMT_TK_CREATION *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMT_TK_VERIFIED_Unmarshalu(TPMT_TK_VERIFIED *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMT_TK_AUTH_Unmarshalu(TPMT_TK_AUTH *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMT_TK_HASHCHECK_Unmarshalu(TPMT_TK_HASHCHECK *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_ALG_PROPERTY_Unmarshalu(TPMS_ALG_PROPERTY *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_TAGGED_PROPERTY_Unmarshalu(TPMS_TAGGED_PROPERTY *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_TAGGED_PCR_SELECT_Unmarshalu(TPMS_TAGGED_PCR_SELECT *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPML_CC_Unmarshalu(TPML_CC *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_TAGGED_POLICY_Unmarshalu(TPMS_TAGGED_POLICY *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPML_CCA_Unmarshalu(TPML_CCA *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPML_ALG_Unmarshalu(TPML_ALG *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPML_HANDLE_Unmarshalu(TPML_HANDLE *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPML_DIGEST_Unmarshalu(TPML_DIGEST *target, BYTE **buffer, uint32_t *size ,uint32_t minCount); + LIB_EXPORT TPM_RC + TSS_TPML_DIGEST_VALUES_Unmarshalu(TPML_DIGEST_VALUES *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPML_PCR_SELECTION_Unmarshalu(TPML_PCR_SELECTION *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPML_ALG_PROPERTY_Unmarshalu(TPML_ALG_PROPERTY *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPML_TAGGED_TPM_PROPERTY_Unmarshalu(TPML_TAGGED_TPM_PROPERTY *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPML_TAGGED_PCR_PROPERTY_Unmarshalu(TPML_TAGGED_PCR_PROPERTY *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPML_ECC_CURVE_Unmarshalu(TPML_ECC_CURVE *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPML_TAGGED_POLICY_Unmarshalu(TPML_TAGGED_POLICY *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMU_CAPABILITIES_Unmarshalu(TPMU_CAPABILITIES *target, BYTE **buffer, uint32_t *size, UINT32 selector); + LIB_EXPORT TPM_RC + TSS_TPMS_CLOCK_INFO_Unmarshalu(TPMS_CLOCK_INFO *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_TIME_INFO_Unmarshalu(TPMS_TIME_INFO *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_TIME_ATTEST_INFO_Unmarshalu(TPMS_TIME_ATTEST_INFO *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_CERTIFY_INFO_Unmarshalu(TPMS_CERTIFY_INFO *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_QUOTE_INFO_Unmarshalu(TPMS_QUOTE_INFO *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_COMMAND_AUDIT_INFO_Unmarshalu(TPMS_COMMAND_AUDIT_INFO *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_SESSION_AUDIT_INFO_Unmarshalu(TPMS_SESSION_AUDIT_INFO *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_CREATION_INFO_Unmarshalu(TPMS_CREATION_INFO *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_NV_CERTIFY_INFO_Unmarshalu(TPMS_NV_CERTIFY_INFO *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMI_ST_ATTEST_Unmarshalu(TPMI_ST_ATTEST *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMU_ATTEST_Unmarshalu(TPMU_ATTEST *target, BYTE **buffer, uint32_t *size, UINT32 selector); + LIB_EXPORT TPM_RC + TSS_TPMS_ATTEST_Unmarshalu(TPMS_ATTEST *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPM2B_ATTEST_Unmarshalu(TPM2B_ATTEST *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_CAPABILITY_DATA_Unmarshalu(TPMS_CAPABILITY_DATA *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_AUTH_RESPONSE_Unmarshalu(TPMS_AUTH_RESPONSE *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMI_AES_KEY_BITS_Unmarshalu(TPMI_AES_KEY_BITS *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMU_SYM_KEY_BITS_Unmarshalu(TPMU_SYM_KEY_BITS *target, BYTE **buffer, uint32_t *size, UINT32 selector); + LIB_EXPORT TPM_RC + TSS_TPMU_SYM_MODE_Unmarshalu(TPMU_SYM_MODE *target, BYTE **buffer, uint32_t *size, UINT32 selector); + LIB_EXPORT TPM_RC + TSS_TPMT_SYM_DEF_Unmarshalu(TPMT_SYM_DEF *target, BYTE **buffer, uint32_t *size, BOOL allowNull); + LIB_EXPORT TPM_RC + TSS_TPMT_SYM_DEF_OBJECT_Unmarshalu(TPMT_SYM_DEF_OBJECT *target, BYTE **buffer, uint32_t *size, BOOL allowNull); + LIB_EXPORT TPM_RC + TSS_TPM2B_SYM_KEY_Unmarshalu(TPM2B_SYM_KEY *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_SYMCIPHER_PARMS_Unmarshalu(TPMS_SYMCIPHER_PARMS *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPM2B_LABEL_Unmarshalu(TPM2B_LABEL *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPM2B_SENSITIVE_DATA_Unmarshalu(TPM2B_SENSITIVE_DATA *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_SENSITIVE_CREATE_Unmarshalu(TPMS_SENSITIVE_CREATE *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPM2B_SENSITIVE_CREATE_Unmarshalu(TPM2B_SENSITIVE_CREATE *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_SCHEME_HASH_Unmarshalu(TPMS_SCHEME_HASH *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_SCHEME_ECDAA_Unmarshalu(TPMS_SCHEME_ECDAA *target, BYTE **buffer, uint32_t *size) ; + LIB_EXPORT TPM_RC + TSS_TPMI_ALG_KEYEDHASH_SCHEME_Unmarshalu(TPMI_ALG_KEYEDHASH_SCHEME *target, BYTE **buffer, uint32_t *size, BOOL allowNull); + LIB_EXPORT TPM_RC + TSS_TPMS_SCHEME_HMAC_Unmarshalu(TPMS_SCHEME_HMAC *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_SCHEME_XOR_Unmarshalu(TPMS_SCHEME_XOR *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMU_SCHEME_KEYEDHASH_Unmarshalu(TPMU_SCHEME_KEYEDHASH *target, BYTE **buffer, uint32_t *size, UINT32 selector); + LIB_EXPORT TPM_RC + TSS_TPMT_KEYEDHASH_SCHEME_Unmarshalu(TPMT_KEYEDHASH_SCHEME *target, BYTE **buffer, uint32_t *size, BOOL allowNull); + LIB_EXPORT TPM_RC + TSS_TPMS_SIG_SCHEME_ECDAA_Unmarshalu(TPMS_SIG_SCHEME_ECDAA *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_SIG_SCHEME_ECDSA_Unmarshalu(TPMS_SIG_SCHEME_ECDSA *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_SIG_SCHEME_ECSCHNORR_Unmarshalu(TPMS_SIG_SCHEME_ECSCHNORR *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_SIG_SCHEME_RSAPSS_Unmarshalu(TPMS_SIG_SCHEME_RSAPSS *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_SIG_SCHEME_RSASSA_Unmarshalu(TPMS_SIG_SCHEME_RSASSA *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_SIG_SCHEME_SM2_Unmarshalu(TPMS_SIG_SCHEME_SM2 *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMU_SIG_SCHEME_Unmarshalu(TPMU_SIG_SCHEME *target, BYTE **buffer, uint32_t *size, UINT32 selector); + LIB_EXPORT TPM_RC + TSS_TPMT_SIG_SCHEME_Unmarshalu(TPMT_SIG_SCHEME *target, BYTE **buffer, uint32_t *size, BOOL allowNull); + LIB_EXPORT TPM_RC + TSS_TPMS_ENC_SCHEME_OAEP_Unmarshalu(TPMS_ENC_SCHEME_OAEP *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_ENC_SCHEME_RSAES_Unmarshalu(TPMS_ENC_SCHEME_RSAES *target, BYTE **buffer, uint32_t *size) +#ifdef __ULTRAVISOR__ + __attribute__ ((const)) +#endif + ; + LIB_EXPORT TPM_RC + TSS_TPMS_KEY_SCHEME_ECDH_Unmarshalu(TPMS_KEY_SCHEME_ECDH *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_KEY_SCHEME_ECMQV_Unmarshalu(TPMS_KEY_SCHEME_ECMQV *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_SCHEME_KDF1_SP800_108_Unmarshalu(TPMS_SCHEME_KDF1_SP800_108 *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_SCHEME_KDF1_SP800_56A_Unmarshalu(TPMS_SCHEME_KDF1_SP800_56A *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_SCHEME_KDF2_Unmarshalu(TPMS_SCHEME_KDF2 *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_SCHEME_MGF1_Unmarshalu(TPMS_SCHEME_MGF1 *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMU_KDF_SCHEME_Unmarshalu(TPMU_KDF_SCHEME *target, BYTE **buffer, uint32_t *size, UINT32 selector); + LIB_EXPORT TPM_RC + TSS_TPMT_KDF_SCHEME_Unmarshalu(TPMT_KDF_SCHEME *target, BYTE **buffer, uint32_t *size, BOOL allowNull); + LIB_EXPORT TPM_RC + TSS_TPMI_ALG_ASYM_SCHEME_Unmarshalu(TPMI_ALG_ASYM_SCHEME *target, BYTE **buffer, uint32_t *size, BOOL allowNull); + LIB_EXPORT TPM_RC + TSS_TPMU_ASYM_SCHEME_Unmarshalu(TPMU_ASYM_SCHEME *target, BYTE **buffer, uint32_t *size, UINT32 selector); + LIB_EXPORT TPM_RC + TSS_TPMT_ASYM_SCHEME_Unmarshalu(TPMT_ASYM_SCHEME *target, BYTE **buffer, uint32_t *size, BOOL allowNull); + LIB_EXPORT TPM_RC + TSS_TPMI_ALG_RSA_SCHEME_Unmarshalu(TPMI_ALG_RSA_SCHEME *target, BYTE **buffer, uint32_t *size, BOOL allowNull); + LIB_EXPORT TPM_RC + TSS_TPMT_RSA_SCHEME_Unmarshalu(TPMT_RSA_SCHEME *target, BYTE **buffer, uint32_t *size, BOOL allowNull); + LIB_EXPORT TPM_RC + TSS_TPMI_ALG_RSA_DECRYPT_Unmarshalu(TPMI_ALG_RSA_DECRYPT *target, BYTE **buffer, uint32_t *size, BOOL allowNull); + LIB_EXPORT TPM_RC + TSS_TPMT_RSA_DECRYPT_Unmarshalu(TPMT_RSA_DECRYPT *target, BYTE **buffer, uint32_t *size, BOOL allowNull); + LIB_EXPORT TPM_RC + TSS_TPM2B_PUBLIC_KEY_RSA_Unmarshalu(TPM2B_PUBLIC_KEY_RSA *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMI_RSA_KEY_BITS_Unmarshalu(TPMI_RSA_KEY_BITS *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPM2B_PRIVATE_KEY_RSA_Unmarshalu(TPM2B_PRIVATE_KEY_RSA *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPM2B_ECC_PARAMETER_Unmarshalu(TPM2B_ECC_PARAMETER *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_ECC_POINT_Unmarshalu(TPMS_ECC_POINT *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPM2B_ECC_POINT_Unmarshalu(TPM2B_ECC_POINT *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMI_ALG_ECC_SCHEME_Unmarshalu(TPMI_ALG_ECC_SCHEME *target, BYTE **buffer, uint32_t *size, BOOL allowNull); + LIB_EXPORT TPM_RC + TSS_TPMI_ECC_CURVE_Unmarshalu(TPMI_ECC_CURVE *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMT_ECC_SCHEME_Unmarshalu(TPMT_ECC_SCHEME *target, BYTE **buffer, uint32_t *size, BOOL allowNull); + LIB_EXPORT TPM_RC + TSS_TPMS_ALGORITHM_DETAIL_ECC_Unmarshalu(TPMS_ALGORITHM_DETAIL_ECC *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_SIGNATURE_RSA_Unmarshalu(TPMS_SIGNATURE_RSA *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_SIGNATURE_RSASSA_Unmarshalu(TPMS_SIGNATURE_RSASSA *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_SIGNATURE_RSAPSS_Unmarshalu(TPMS_SIGNATURE_RSAPSS *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_SIGNATURE_ECC_Unmarshalu(TPMS_SIGNATURE_ECC *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_SIGNATURE_ECDSA_Unmarshalu(TPMS_SIGNATURE_ECDSA *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_SIGNATURE_ECDAA_Unmarshalu(TPMS_SIGNATURE_ECDAA *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_SIGNATURE_SM2_Unmarshalu(TPMS_SIGNATURE_SM2 *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_SIGNATURE_ECSCHNORR_Unmarshalu(TPMS_SIGNATURE_ECSCHNORR *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMU_SIGNATURE_Unmarshalu(TPMU_SIGNATURE *target, BYTE **buffer, uint32_t *size, UINT32 selector); + LIB_EXPORT TPM_RC + TSS_TPMT_SIGNATURE_Unmarshalu(TPMT_SIGNATURE *target, BYTE **buffer, uint32_t *size, BOOL allowNull); + LIB_EXPORT TPM_RC + TSS_TPM2B_ENCRYPTED_SECRET_Unmarshalu(TPM2B_ENCRYPTED_SECRET *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMI_ALG_PUBLIC_Unmarshalu(TPMI_ALG_PUBLIC *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMU_PUBLIC_ID_Unmarshalu(TPMU_PUBLIC_ID *target, BYTE **buffer, uint32_t *size, UINT32 selector); + LIB_EXPORT TPM_RC + TSS_TPMS_KEYEDHASH_PARMS_Unmarshalu(TPMS_KEYEDHASH_PARMS *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_ASYM_PARMS_Unmarshalu(TPMS_ASYM_PARMS *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_RSA_PARMS_Unmarshalu(TPMS_RSA_PARMS *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_ECC_PARMS_Unmarshalu(TPMS_ECC_PARMS *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMU_PUBLIC_PARMS_Unmarshalu(TPMU_PUBLIC_PARMS *target, BYTE **buffer, uint32_t *size, UINT32 selector); + LIB_EXPORT TPM_RC + TSS_TPMT_PUBLIC_PARMS_Unmarshalu(TPMT_PUBLIC_PARMS *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMT_PUBLIC_Unmarshalu(TPMT_PUBLIC *target, BYTE **buffer, uint32_t *size, BOOL allowNull); + LIB_EXPORT TPM_RC + TSS_TPM2B_PUBLIC_Unmarshalu(TPM2B_PUBLIC *target, BYTE **buffer, uint32_t *size, BOOL allowNull); + LIB_EXPORT TPM_RC + TSS_TPM2B_TEMPLATE_Unmarshalu(TPM2B_TEMPLATE *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMU_SENSITIVE_COMPOSITE_Unmarshalu(TPMU_SENSITIVE_COMPOSITE *target, BYTE **buffer, uint32_t *size, UINT32 selector); + LIB_EXPORT TPM_RC + TSS_TPMT_SENSITIVE_Unmarshalu(TPMT_SENSITIVE *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPM2B_SENSITIVE_Unmarshalu(TPM2B_SENSITIVE *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPM2B_PRIVATE_Unmarshalu(TPM2B_PRIVATE *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPM2B_ID_OBJECT_Unmarshalu(TPM2B_ID_OBJECT *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMA_NV_Unmarshalu(TPMA_NV *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_NV_PUBLIC_Unmarshalu(TPMS_NV_PUBLIC *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPM2B_NV_PUBLIC_Unmarshalu(TPM2B_NV_PUBLIC *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPM2B_CONTEXT_SENSITIVE_Unmarshalu(TPM2B_CONTEXT_SENSITIVE *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_CONTEXT_DATA_Unmarshalu(TPMS_CONTEXT_DATA *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPM2B_CONTEXT_DATA_Unmarshalu(TPM2B_CONTEXT_DATA *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_CONTEXT_Unmarshalu(TPMS_CONTEXT *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_CREATION_DATA_Unmarshalu(TPMS_CREATION_DATA *target, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPM2B_CREATION_DATA_Unmarshalu(TPM2B_CREATION_DATA *target, BYTE **buffer, uint32_t *size); + + /* These functions are deprecated. They were adapted from the TPM side, but the signed size + caused static analysis tool warnings. */ + + TPM_RC UINT8_Unmarshal(UINT8 *target, BYTE **buffer, INT32 *size); + TPM_RC INT8_Unmarshal(INT8 *target, BYTE **buffer, INT32 *size); + TPM_RC UINT16_Unmarshal(UINT16 *target, BYTE **buffer, INT32 *size); + TPM_RC UINT32_Unmarshal(UINT32 *target, BYTE **buffer, INT32 *size); + TPM_RC INT32_Unmarshal(INT32 *target, BYTE **buffer, INT32 *size); + TPM_RC UINT64_Unmarshal(UINT64 *target, BYTE **buffer, INT32 *size); + TPM_RC Array_Unmarshal(BYTE *targetBuffer, UINT16 targetSize, BYTE **buffer, INT32 *size); + TPM_RC TPM2B_Unmarshal(TPM2B *target, UINT16 targetSize, BYTE **buffer, INT32 *size); + TPM_RC TPM_KEY_BITS_Unmarshal(TPM_KEY_BITS *target, BYTE **buffer, INT32 *size); + TPM_RC TPM_GENERATED_Unmarshal(TPM_GENERATED *target, BYTE **buffer, INT32 *size); + TPM_RC TPM_ALG_ID_Unmarshal(TPM_ALG_ID *target, BYTE **buffer, INT32 *size); + TPM_RC TPM_ECC_CURVE_Unmarshal(TPM_ECC_CURVE *target, BYTE **buffer, INT32 *size); + TPM_RC TPM_CC_Unmarshal(TPM_RC *target, BYTE **buffer, INT32 *size); + TPM_RC TPM_RC_Unmarshal(TPM_RC *target, BYTE **buffer, INT32 *size); + TPM_RC TPM_CLOCK_ADJUST_Unmarshal(TPM_CLOCK_ADJUST *target, BYTE **buffer, INT32 *size); + TPM_RC TPM_EO_Unmarshal(TPM_EO *target, BYTE **buffer, INT32 *size); + TPM_RC TPM_ST_Unmarshal(TPM_ST *target, BYTE **buffer, INT32 *size); + TPM_RC TPM_SU_Unmarshal(TPM_SU *target, BYTE **buffer, INT32 *size); + TPM_RC TPM_SE_Unmarshal(TPM_SE *target, BYTE **buffer, INT32 *size); + TPM_RC TPM_CAP_Unmarshal(TPM_CAP *target, BYTE **buffer, INT32 *size); + TPM_RC TPM_PT_Unmarshal(TPM_HANDLE *target, BYTE **buffer, INT32 *size); + TPM_RC TPM_PT_PCR_Unmarshal(TPM_PT_PCR *target, BYTE **buffer, INT32 *size); + TPM_RC TPM_HANDLE_Unmarshal(TPM_HANDLE *target, BYTE **buffer, INT32 *size); + TPM_RC TPMA_ALGORITHM_Unmarshal(TPMA_ALGORITHM *target, BYTE **buffer, INT32 *size); + TPM_RC TPMA_OBJECT_Unmarshal(TPMA_OBJECT *target, BYTE **buffer, INT32 *size); + TPM_RC TPMA_SESSION_Unmarshal(TPMA_SESSION *target, BYTE **buffer, INT32 *size); + TPM_RC TPMA_LOCALITY_Unmarshal(TPMA_LOCALITY *target, BYTE **buffer, INT32 *size); + TPM_RC TPMA_CC_Unmarshal(TPMA_CC *target, BYTE **buffer, INT32 *size); + TPM_RC TPMI_YES_NO_Unmarshal(TPMI_YES_NO *target, BYTE **buffer, INT32 *size); + TPM_RC TPMI_DH_OBJECT_Unmarshal(TPMI_DH_OBJECT *target, BYTE **buffer, INT32 *size, BOOL allowNull); + TPM_RC TPMI_DH_PARENT_Unmarshal(TPMI_DH_PARENT *target, BYTE **buffer, INT32 *size, BOOL allowNull); + TPM_RC TPMI_DH_PERSISTENT_Unmarshal(TPMI_DH_PERSISTENT *target, BYTE **buffer, INT32 *size); + TPM_RC TPMI_DH_ENTITY_Unmarshal(TPMI_DH_ENTITY *target, BYTE **buffer, INT32 *size, BOOL allowNull); + TPM_RC TPMI_DH_PCR_Unmarshal(TPMI_DH_PCR *target, BYTE **buffer, INT32 *size, BOOL allowNull); + TPM_RC TPMI_SH_AUTH_SESSION_Unmarshal(TPMI_SH_AUTH_SESSION *target, BYTE **buffer, INT32 *size, BOOL allowPwd); + TPM_RC TPMI_SH_HMAC_Unmarshal(TPMI_SH_HMAC *target, BYTE **buffer, INT32 *size, BOOL allowNull); + TPM_RC TPMI_SH_POLICY_Unmarshal(TPMI_SH_POLICY *target, BYTE **buffer, INT32 *size, BOOL allowNull); + TPM_RC TPMI_DH_CONTEXT_Unmarshal(TPMI_DH_CONTEXT *target, BYTE **buffer, INT32 *size, BOOL allowNull); + TPM_RC TPMI_RH_HIERARCHY_Unmarshal(TPMI_RH_HIERARCHY *target, BYTE **buffer, INT32 *size, BOOL allowNull); + TPM_RC TPMI_RH_ENABLES_Unmarshal(TPMI_RH_ENABLES *target, BYTE **buffer, INT32 *size, BOOL allowNull); + TPM_RC TPMI_RH_HIERARCHY_AUTH_Unmarshal(TPMI_RH_HIERARCHY_AUTH *target, BYTE **buffer, INT32 *size, BOOL allowNull); + TPM_RC TPMI_RH_PLATFORM_Unmarshal(TPMI_RH_PLATFORM *target, BYTE **buffer, INT32 *size, BOOL allowNull); + TPM_RC TPMI_RH_ENDORSEMENT_Unmarshal(TPMI_RH_ENDORSEMENT *target, BYTE **buffer, INT32 *size, BOOL allowNull); + TPM_RC TPMI_RH_PROVISION_Unmarshal(TPMI_RH_PROVISION *target, BYTE **buffer, INT32 *size, BOOL allowNull); + TPM_RC TPMI_RH_CLEAR_Unmarshal(TPMI_RH_CLEAR *target, BYTE **buffer, INT32 *size, BOOL allowNull); + TPM_RC TPMI_RH_NV_AUTH_Unmarshal(TPMI_RH_NV_AUTH *target, BYTE **buffer, INT32 *size, BOOL allowNull); + TPM_RC TPMI_RH_LOCKOUT_Unmarshal(TPMI_RH_LOCKOUT *target, BYTE **buffer, INT32 *size, BOOL allowNull); + TPM_RC TPMI_RH_NV_INDEX_Unmarshal(TPMI_RH_NV_INDEX *target, BYTE **buffer, INT32 *size, BOOL allowNull); + TPM_RC TPMI_ALG_HASH_Unmarshal(TPMI_ALG_HASH *target, BYTE **buffer, INT32 *size, BOOL allowNull); + TPM_RC TPMI_ALG_SYM_Unmarshal(TPMI_ALG_SYM *target, BYTE **buffer, INT32 *size, BOOL allowNull); + TPM_RC TPMI_ALG_SYM_OBJECT_Unmarshal(TPMI_ALG_SYM_OBJECT *target, BYTE **buffer, INT32 *size, BOOL allowNull); + TPM_RC TPMI_ALG_SYM_MODE_Unmarshal(TPMI_ALG_SYM_MODE *target, BYTE **buffer, INT32 *size, BOOL allowNull); + TPM_RC TPMI_ALG_KDF_Unmarshal(TPMI_ALG_KDF *target, BYTE **buffer, INT32 *size, BOOL allowNull); + TPM_RC TPMI_ALG_SIG_SCHEME_Unmarshal(TPMI_ALG_SIG_SCHEME *target, BYTE **buffer, INT32 *size, BOOL allowNull); + TPM_RC TPMI_ECC_KEY_EXCHANGE_Unmarshal(TPMI_ECC_KEY_EXCHANGE *target, BYTE **buffer, INT32 *size, BOOL allowNull); + TPM_RC TPMI_ST_COMMAND_TAG_Unmarshal(TPMI_ST_COMMAND_TAG *target, BYTE **buffer, INT32 *size); + TPM_RC TPMI_ALG_MAC_SCHEME_Unmarshal(TPMI_ALG_MAC_SCHEME *target, BYTE **buffer, INT32 *size, BOOL allowNull); + TPM_RC TPMI_ALG_CIPHER_MODE_Unmarshal(TPMI_ALG_CIPHER_MODE *target, BYTE **buffer, INT32 *size, BOOL allowNull); + TPM_RC TPMS_EMPTY_Unmarshal(TPMS_EMPTY *target, BYTE **buffer, INT32 *size) +#ifdef __ULTRAVISOR__ + __attribute__ ((const)) +#endif + ; + TPM_RC TPMU_HA_Unmarshal(TPMU_HA *target, BYTE **buffer, INT32 *size, UINT32 selector); + TPM_RC TPMT_HA_Unmarshal(TPMT_HA *target, BYTE **buffer, INT32 *size, BOOL allowNull); + TPM_RC TPM2B_DIGEST_Unmarshal(TPM2B_DIGEST *target, BYTE **buffer, INT32 *size); + TPM_RC TPM2B_DATA_Unmarshal(TPM2B_DATA *target, BYTE **buffer, INT32 *size); + TPM_RC TPM2B_NONCE_Unmarshal(TPM2B_NONCE *target, BYTE **buffer, INT32 *size); + TPM_RC TPM2B_AUTH_Unmarshal(TPM2B_AUTH *target, BYTE **buffer, INT32 *size); + TPM_RC TPM2B_OPERAND_Unmarshal(TPM2B_OPERAND *target, BYTE **buffer, INT32 *size); + TPM_RC TPM2B_EVENT_Unmarshal(TPM2B_EVENT *target, BYTE **buffer, INT32 *size); + TPM_RC TPM2B_MAX_BUFFER_Unmarshal(TPM2B_MAX_BUFFER *target, BYTE **buffer, INT32 *size); + TPM_RC TPM2B_MAX_NV_BUFFER_Unmarshal(TPM2B_MAX_NV_BUFFER *target, BYTE **buffer, INT32 *size); + TPM_RC TPM2B_TIMEOUT_Unmarshal(TPM2B_TIMEOUT *target, BYTE **buffer, INT32 *size); + TPM_RC TPM2B_IV_Unmarshal(TPM2B_IV *target, BYTE **buffer, INT32 *size); + TPM_RC TPM2B_NAME_Unmarshal(TPM2B_NAME *target, BYTE **buffer, INT32 *size); + TPM_RC TPMS_PCR_SELECTION_Unmarshal(TPMS_PCR_SELECTION *target, BYTE **buffer, INT32 *size); + TPM_RC TPMT_TK_CREATION_Unmarshal(TPMT_TK_CREATION *target, BYTE **buffer, INT32 *size); + TPM_RC TPMT_TK_VERIFIED_Unmarshal(TPMT_TK_VERIFIED *target, BYTE **buffer, INT32 *size); + TPM_RC TPMT_TK_AUTH_Unmarshal(TPMT_TK_AUTH *target, BYTE **buffer, INT32 *size); + TPM_RC TPMT_TK_HASHCHECK_Unmarshal(TPMT_TK_HASHCHECK *target, BYTE **buffer, INT32 *size); + TPM_RC TPMS_ALG_PROPERTY_Unmarshal(TPMS_ALG_PROPERTY *target, BYTE **buffer, INT32 *size); + TPM_RC TPMS_TAGGED_PROPERTY_Unmarshal(TPMS_TAGGED_PROPERTY *target, BYTE **buffer, INT32 *size); + TPM_RC TPMS_TAGGED_PCR_SELECT_Unmarshal(TPMS_TAGGED_PCR_SELECT *target, BYTE **buffer, INT32 *size); + TPM_RC TPML_CC_Unmarshal(TPML_CC *target, BYTE **buffer, INT32 *size); + TPM_RC TPMS_TAGGED_POLICY_Unmarshal(TPMS_TAGGED_POLICY *target, BYTE **buffer, INT32 *size); + TPM_RC TPML_CCA_Unmarshal(TPML_CCA *target, BYTE **buffer, INT32 *size); + TPM_RC TPML_ALG_Unmarshal(TPML_ALG *target, BYTE **buffer, INT32 *size); + TPM_RC TPML_HANDLE_Unmarshal(TPML_HANDLE *target, BYTE **buffer, INT32 *size); + TPM_RC TPML_DIGEST_Unmarshal(TPML_DIGEST *target, BYTE **buffer, INT32 *size,uint32_t minCount); + TPM_RC TPML_DIGEST_VALUES_Unmarshal(TPML_DIGEST_VALUES *target, BYTE **buffer, INT32 *size); + TPM_RC TPML_PCR_SELECTION_Unmarshal(TPML_PCR_SELECTION *target, BYTE **buffer, INT32 *size); + TPM_RC TPML_ALG_PROPERTY_Unmarshal(TPML_ALG_PROPERTY *target, BYTE **buffer, INT32 *size); + TPM_RC TPML_TAGGED_TPM_PROPERTY_Unmarshal(TPML_TAGGED_TPM_PROPERTY *target, BYTE **buffer, INT32 *size); + TPM_RC TPML_TAGGED_PCR_PROPERTY_Unmarshal(TPML_TAGGED_PCR_PROPERTY *target, BYTE **buffer, INT32 *size); + TPM_RC TPML_ECC_CURVE_Unmarshal(TPML_ECC_CURVE *target, BYTE **buffer, INT32 *size); + TPM_RC TPML_TAGGED_POLICY_Unmarshal(TPML_TAGGED_POLICY *target, BYTE **buffer, INT32 *size); + TPM_RC TPMU_CAPABILITIES_Unmarshal(TPMU_CAPABILITIES *target, BYTE **buffer, INT32 *size, UINT32 selector); + TPM_RC TPMS_CLOCK_INFO_Unmarshal(TPMS_CLOCK_INFO *target, BYTE **buffer, INT32 *size); + TPM_RC TPMS_TIME_INFO_Unmarshal(TPMS_TIME_INFO *target, BYTE **buffer, INT32 *size); + TPM_RC TPMS_TIME_ATTEST_INFO_Unmarshal(TPMS_TIME_ATTEST_INFO *target, BYTE **buffer, INT32 *size); + TPM_RC TPMS_CERTIFY_INFO_Unmarshal(TPMS_CERTIFY_INFO *target, BYTE **buffer, INT32 *size); + TPM_RC TPMS_QUOTE_INFO_Unmarshal(TPMS_QUOTE_INFO *target, BYTE **buffer, INT32 *size); + TPM_RC TPMS_COMMAND_AUDIT_INFO_Unmarshal(TPMS_COMMAND_AUDIT_INFO *target, BYTE **buffer, INT32 *size); + TPM_RC TPMS_SESSION_AUDIT_INFO_Unmarshal(TPMS_SESSION_AUDIT_INFO *target, BYTE **buffer, INT32 *size); + TPM_RC TPMS_CREATION_INFO_Unmarshal(TPMS_CREATION_INFO *target, BYTE **buffer, INT32 *size); + TPM_RC TPMS_NV_CERTIFY_INFO_Unmarshal(TPMS_NV_CERTIFY_INFO *target, BYTE **buffer, INT32 *size); + TPM_RC TPMI_ST_ATTEST_Unmarshal(TPMI_ST_ATTEST *target, BYTE **buffer, INT32 *size); + TPM_RC TPMU_ATTEST_Unmarshal(TPMU_ATTEST *target, BYTE **buffer, INT32 *size, UINT32 selector); + TPM_RC TPMS_ATTEST_Unmarshal(TPMS_ATTEST *target, BYTE **buffer, INT32 *size); + TPM_RC TPM2B_ATTEST_Unmarshal(TPM2B_ATTEST *target, BYTE **buffer, INT32 *size); + TPM_RC TPMS_CAPABILITY_DATA_Unmarshal(TPMS_CAPABILITY_DATA *target, BYTE **buffer, INT32 *size); + TPM_RC TPMS_AUTH_RESPONSE_Unmarshal(TPMS_AUTH_RESPONSE *target, BYTE **buffer, INT32 *size); + TPM_RC TPMI_AES_KEY_BITS_Unmarshal(TPMI_AES_KEY_BITS *target, BYTE **buffer, INT32 *size); + TPM_RC TPMU_SYM_KEY_BITS_Unmarshal(TPMU_SYM_KEY_BITS *target, BYTE **buffer, INT32 *size, UINT32 selector); + TPM_RC TPMU_SYM_MODE_Unmarshal(TPMU_SYM_MODE *target, BYTE **buffer, INT32 *size, UINT32 selector); + TPM_RC TPMT_SYM_DEF_Unmarshal(TPMT_SYM_DEF *target, BYTE **buffer, INT32 *size, BOOL allowNull); + TPM_RC TPMT_SYM_DEF_OBJECT_Unmarshal(TPMT_SYM_DEF_OBJECT *target, BYTE **buffer, INT32 *size, BOOL allowNull); + TPM_RC TPM2B_SYM_KEY_Unmarshal(TPM2B_SYM_KEY *target, BYTE **buffer, INT32 *size); + TPM_RC TPMS_SYMCIPHER_PARMS_Unmarshal(TPMS_SYMCIPHER_PARMS *target, BYTE **buffer, INT32 *size); + TPM_RC TPM2B_LABEL_Unmarshal(TPM2B_LABEL *target, BYTE **buffer, INT32 *size); + TPM_RC TPM2B_SENSITIVE_DATA_Unmarshal(TPM2B_SENSITIVE_DATA *target, BYTE **buffer, INT32 *size); + TPM_RC TPMS_SENSITIVE_CREATE_Unmarshal(TPMS_SENSITIVE_CREATE *target, BYTE **buffer, INT32 *size); + TPM_RC TPM2B_SENSITIVE_CREATE_Unmarshal(TPM2B_SENSITIVE_CREATE *target, BYTE **buffer, INT32 *size); + TPM_RC TPMS_SCHEME_HASH_Unmarshal(TPMS_SCHEME_HASH *target, BYTE **buffer, INT32 *size); + TPM_RC TPMS_SCHEME_ECDAA_Unmarshal(TPMS_SCHEME_ECDAA *target, BYTE **buffer, INT32 *size) ; + TPM_RC TPMI_ALG_KEYEDHASH_SCHEME_Unmarshal(TPMI_ALG_KEYEDHASH_SCHEME *target, BYTE **buffer, INT32 *size, BOOL allowNull); + TPM_RC TPMS_SCHEME_HMAC_Unmarshal(TPMS_SCHEME_HMAC *target, BYTE **buffer, INT32 *size); + TPM_RC TPMS_SCHEME_XOR_Unmarshal(TPMS_SCHEME_XOR *target, BYTE **buffer, INT32 *size); + TPM_RC TPMU_SCHEME_KEYEDHASH_Unmarshal(TPMU_SCHEME_KEYEDHASH *target, BYTE **buffer, INT32 *size, UINT32 selector); + TPM_RC TPMT_KEYEDHASH_SCHEME_Unmarshal(TPMT_KEYEDHASH_SCHEME *target, BYTE **buffer, INT32 *size, BOOL allowNull); + TPM_RC TPMS_SIG_SCHEME_ECDAA_Unmarshal(TPMS_SIG_SCHEME_ECDAA *target, BYTE **buffer, INT32 *size); + TPM_RC TPMS_SIG_SCHEME_ECDSA_Unmarshal(TPMS_SIG_SCHEME_ECDSA *target, BYTE **buffer, INT32 *size); + TPM_RC TPMS_SIG_SCHEME_ECSCHNORR_Unmarshal(TPMS_SIG_SCHEME_ECSCHNORR *target, BYTE **buffer, INT32 *size); + TPM_RC TPMS_SIG_SCHEME_RSAPSS_Unmarshal(TPMS_SIG_SCHEME_RSAPSS *target, BYTE **buffer, INT32 *size); + TPM_RC TPMS_SIG_SCHEME_RSASSA_Unmarshal(TPMS_SIG_SCHEME_RSASSA *target, BYTE **buffer, INT32 *size); + TPM_RC TPMS_SIG_SCHEME_SM2_Unmarshal(TPMS_SIG_SCHEME_SM2 *target, BYTE **buffer, INT32 *size); + TPM_RC TPMU_SIG_SCHEME_Unmarshal(TPMU_SIG_SCHEME *target, BYTE **buffer, INT32 *size, UINT32 selector); + TPM_RC TPMT_SIG_SCHEME_Unmarshal(TPMT_SIG_SCHEME *target, BYTE **buffer, INT32 *size, BOOL allowNull); + TPM_RC TPMS_ENC_SCHEME_OAEP_Unmarshal(TPMS_ENC_SCHEME_OAEP *target, BYTE **buffer, INT32 *size); + TPM_RC TPMS_ENC_SCHEME_RSAES_Unmarshal(TPMS_ENC_SCHEME_RSAES *target, BYTE **buffer, INT32 *size) +#ifdef __ULTRAVISOR__ + __attribute__ ((const)) +#endif + ; + TPM_RC TPMS_KEY_SCHEME_ECDH_Unmarshal(TPMS_KEY_SCHEME_ECDH *target, BYTE **buffer, INT32 *size); + TPM_RC TPMS_KEY_SCHEME_ECMQV_Unmarshal(TPMS_KEY_SCHEME_ECMQV *target, BYTE **buffer, INT32 *size); + TPM_RC TPMS_SCHEME_KDF1_SP800_108_Unmarshal(TPMS_SCHEME_KDF1_SP800_108 *target, BYTE **buffer, INT32 *size); + TPM_RC TPMS_SCHEME_KDF1_SP800_56A_Unmarshal(TPMS_SCHEME_KDF1_SP800_56A *target, BYTE **buffer, INT32 *size); + TPM_RC TPMS_SCHEME_KDF2_Unmarshal(TPMS_SCHEME_KDF2 *target, BYTE **buffer, INT32 *size); + TPM_RC TPMS_SCHEME_MGF1_Unmarshal(TPMS_SCHEME_MGF1 *target, BYTE **buffer, INT32 *size); + TPM_RC TPMU_KDF_SCHEME_Unmarshal(TPMU_KDF_SCHEME *target, BYTE **buffer, INT32 *size, UINT32 selector); + TPM_RC TPMT_KDF_SCHEME_Unmarshal(TPMT_KDF_SCHEME *target, BYTE **buffer, INT32 *size, BOOL allowNull); + TPM_RC TPMI_ALG_ASYM_SCHEME_Unmarshal(TPMI_ALG_ASYM_SCHEME *target, BYTE **buffer, INT32 *size, BOOL allowNull); + TPM_RC TPMU_ASYM_SCHEME_Unmarshal(TPMU_ASYM_SCHEME *target, BYTE **buffer, INT32 *size, UINT32 selector); + TPM_RC TPMT_ASYM_SCHEME_Unmarshal(TPMT_ASYM_SCHEME *target, BYTE **buffer, INT32 *size, BOOL allowNull); + TPM_RC TPMI_ALG_RSA_SCHEME_Unmarshal(TPMI_ALG_RSA_SCHEME *target, BYTE **buffer, INT32 *size, BOOL allowNull); + TPM_RC TPMT_RSA_SCHEME_Unmarshal(TPMT_RSA_SCHEME *target, BYTE **buffer, INT32 *size, BOOL allowNull); + TPM_RC TPMI_ALG_RSA_DECRYPT_Unmarshal(TPMI_ALG_RSA_DECRYPT *target, BYTE **buffer, INT32 *size, BOOL allowNull); + TPM_RC TPMT_RSA_DECRYPT_Unmarshal(TPMT_RSA_DECRYPT *target, BYTE **buffer, INT32 *size, BOOL allowNull); + TPM_RC TPM2B_PUBLIC_KEY_RSA_Unmarshal(TPM2B_PUBLIC_KEY_RSA *target, BYTE **buffer, INT32 *size); + TPM_RC TPMI_RSA_KEY_BITS_Unmarshal(TPMI_RSA_KEY_BITS *target, BYTE **buffer, INT32 *size); + TPM_RC TPM2B_PRIVATE_KEY_RSA_Unmarshal(TPM2B_PRIVATE_KEY_RSA *target, BYTE **buffer, INT32 *size); + TPM_RC TPM2B_ECC_PARAMETER_Unmarshal(TPM2B_ECC_PARAMETER *target, BYTE **buffer, INT32 *size); + TPM_RC TPMS_ECC_POINT_Unmarshal(TPMS_ECC_POINT *target, BYTE **buffer, INT32 *size); + TPM_RC TPM2B_ECC_POINT_Unmarshal(TPM2B_ECC_POINT *target, BYTE **buffer, INT32 *size); + TPM_RC TPMI_ALG_ECC_SCHEME_Unmarshal(TPMI_ALG_ECC_SCHEME *target, BYTE **buffer, INT32 *size, BOOL allowNull); + TPM_RC TPMI_ECC_CURVE_Unmarshal(TPMI_ECC_CURVE *target, BYTE **buffer, INT32 *size); + TPM_RC TPMT_ECC_SCHEME_Unmarshal(TPMT_ECC_SCHEME *target, BYTE **buffer, INT32 *size, BOOL allowNull); + TPM_RC TPMS_ALGORITHM_DETAIL_ECC_Unmarshal(TPMS_ALGORITHM_DETAIL_ECC *target, BYTE **buffer, INT32 *size); + TPM_RC TPMS_SIGNATURE_RSA_Unmarshal(TPMS_SIGNATURE_RSA *target, BYTE **buffer, INT32 *size); + TPM_RC TPMS_SIGNATURE_RSASSA_Unmarshal(TPMS_SIGNATURE_RSASSA *target, BYTE **buffer, INT32 *size); + TPM_RC TPMS_SIGNATURE_RSAPSS_Unmarshal(TPMS_SIGNATURE_RSAPSS *target, BYTE **buffer, INT32 *size); + TPM_RC TPMS_SIGNATURE_ECC_Unmarshal(TPMS_SIGNATURE_ECC *target, BYTE **buffer, INT32 *size); + TPM_RC TPMS_SIGNATURE_ECDSA_Unmarshal(TPMS_SIGNATURE_ECDSA *target, BYTE **buffer, INT32 *size); + TPM_RC TPMS_SIGNATURE_ECDAA_Unmarshal(TPMS_SIGNATURE_ECDAA *target, BYTE **buffer, INT32 *size); + TPM_RC TPMS_SIGNATURE_SM2_Unmarshal(TPMS_SIGNATURE_SM2 *target, BYTE **buffer, INT32 *size); + TPM_RC TPMS_SIGNATURE_ECSCHNORR_Unmarshal(TPMS_SIGNATURE_ECSCHNORR *target, BYTE **buffer, INT32 *size); + TPM_RC TPMU_SIGNATURE_Unmarshal(TPMU_SIGNATURE *target, BYTE **buffer, INT32 *size, UINT32 selector); + TPM_RC TPMT_SIGNATURE_Unmarshal(TPMT_SIGNATURE *target, BYTE **buffer, INT32 *size, BOOL allowNull); + TPM_RC TPM2B_ENCRYPTED_SECRET_Unmarshal(TPM2B_ENCRYPTED_SECRET *target, BYTE **buffer, INT32 *size); + TPM_RC TPMI_ALG_PUBLIC_Unmarshal(TPMI_ALG_PUBLIC *target, BYTE **buffer, INT32 *size); + TPM_RC TPMU_PUBLIC_ID_Unmarshal(TPMU_PUBLIC_ID *target, BYTE **buffer, INT32 *size, UINT32 selector); + TPM_RC TPMS_KEYEDHASH_PARMS_Unmarshal(TPMS_KEYEDHASH_PARMS *target, BYTE **buffer, INT32 *size); + TPM_RC TPMS_ASYM_PARMS_Unmarshal(TPMS_ASYM_PARMS *target, BYTE **buffer, INT32 *size); + TPM_RC TPMS_RSA_PARMS_Unmarshal(TPMS_RSA_PARMS *target, BYTE **buffer, INT32 *size); + TPM_RC TPMS_ECC_PARMS_Unmarshal(TPMS_ECC_PARMS *target, BYTE **buffer, INT32 *size); + TPM_RC TPMU_PUBLIC_PARMS_Unmarshal(TPMU_PUBLIC_PARMS *target, BYTE **buffer, INT32 *size, UINT32 selector); + TPM_RC TPMT_PUBLIC_PARMS_Unmarshal(TPMT_PUBLIC_PARMS *target, BYTE **buffer, INT32 *size); + TPM_RC TPMT_PUBLIC_Unmarshal(TPMT_PUBLIC *target, BYTE **buffer, INT32 *size, BOOL allowNull); + TPM_RC TPM2B_PUBLIC_Unmarshal(TPM2B_PUBLIC *target, BYTE **buffer, INT32 *size, BOOL allowNull); + TPM_RC TPM2B_TEMPLATE_Unmarshal(TPM2B_TEMPLATE *target, BYTE **buffer, INT32 *size); + TPM_RC TPMU_SENSITIVE_COMPOSITE_Unmarshal(TPMU_SENSITIVE_COMPOSITE *target, BYTE **buffer, INT32 *size, UINT32 selector); + TPM_RC TPMT_SENSITIVE_Unmarshal(TPMT_SENSITIVE *target, BYTE **buffer, INT32 *size); + TPM_RC TPM2B_SENSITIVE_Unmarshal(TPM2B_SENSITIVE *target, BYTE **buffer, INT32 *size); + TPM_RC TPM2B_PRIVATE_Unmarshal(TPM2B_PRIVATE *target, BYTE **buffer, INT32 *size); + TPM_RC TPM2B_ID_OBJECT_Unmarshal(TPM2B_ID_OBJECT *target, BYTE **buffer, INT32 *size); + TPM_RC TPMA_NV_Unmarshal(TPMA_NV *target, BYTE **buffer, INT32 *size); + TPM_RC TPMS_NV_PUBLIC_Unmarshal(TPMS_NV_PUBLIC *target, BYTE **buffer, INT32 *size); + TPM_RC TPM2B_NV_PUBLIC_Unmarshal(TPM2B_NV_PUBLIC *target, BYTE **buffer, INT32 *size); + TPM_RC TPM2B_CONTEXT_SENSITIVE_Unmarshal(TPM2B_CONTEXT_SENSITIVE *target, BYTE **buffer, INT32 *size); + TPM_RC TPMS_CONTEXT_DATA_Unmarshal(TPMS_CONTEXT_DATA *target, BYTE **buffer, INT32 *size); + TPM_RC TPM2B_CONTEXT_DATA_Unmarshal(TPM2B_CONTEXT_DATA *target, BYTE **buffer, INT32 *size); + TPM_RC TPMS_CONTEXT_Unmarshal(TPMS_CONTEXT *target, BYTE **buffer, INT32 *size); + TPM_RC TPMS_CREATION_DATA_Unmarshal(TPMS_CREATION_DATA *target, BYTE **buffer, INT32 *size); + TPM_RC TPM2B_CREATION_DATA_Unmarshal(TPM2B_CREATION_DATA *target, BYTE **buffer, INT32 *size); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libstb/tss2/ibmtss/Unseal_fp.h b/libstb/tss2/ibmtss/Unseal_fp.h new file mode 100644 index 0000000..87c720e --- /dev/null +++ b/libstb/tss2/ibmtss/Unseal_fp.h @@ -0,0 +1,83 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: Unseal_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef UNSEAL_FP_H +#define UNSEAL_FP_H + +typedef struct { + TPMI_DH_OBJECT itemHandle; +} Unseal_In; + +#define RC_Unseal_itemHandle (TPM_RC_H + TPM_RC_1) + +typedef struct { + TPM2B_SENSITIVE_DATA outData; +} Unseal_Out; + +TPM_RC +TPM2_Unseal( + Unseal_In *in, + Unseal_Out *out + ); + +#endif diff --git a/libstb/tss2/ibmtss/VerifySignature_fp.h b/libstb/tss2/ibmtss/VerifySignature_fp.h new file mode 100644 index 0000000..19f36a2 --- /dev/null +++ b/libstb/tss2/ibmtss/VerifySignature_fp.h @@ -0,0 +1,88 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: VerifySignature_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef VERIFYSIGNATURE_FP_H +#define VERIFYSIGNATURE_FP_H + +typedef struct { + TPMI_DH_OBJECT keyHandle; + TPM2B_DIGEST digest; + TPMT_SIGNATURE signature; +} VerifySignature_In; + +#define RC_VerifySignature_keyHandle (TPM_RC_H + TPM_RC_1) +#define RC_VerifySignature_digest (TPM_RC_P + TPM_RC_1) +#define RC_VerifySignature_signature (TPM_RC_P + TPM_RC_2) + +typedef struct { + TPMT_TK_VERIFIED validation; +} VerifySignature_Out; + +TPM_RC +TPM2_VerifySignature( + VerifySignature_In *in, // IN: input parameter list + VerifySignature_Out *out // OUT: output parameter list + ); + + +#endif diff --git a/libstb/tss2/ibmtss/ZGen_2Phase_fp.h b/libstb/tss2/ibmtss/ZGen_2Phase_fp.h new file mode 100644 index 0000000..efbf082 --- /dev/null +++ b/libstb/tss2/ibmtss/ZGen_2Phase_fp.h @@ -0,0 +1,93 @@ +/********************************************************************************/ +/* */ +/* */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: ZGen_2Phase_fp.h 1257 2018-06-27 20:52:08Z 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, 2012-2015 */ +/* */ +/********************************************************************************/ + +/* rev 119 */ + +#ifndef ZGEN_2PHASE_FP_H +#define ZGEN_2PHASE_FP_H + +typedef struct { + TPMI_DH_OBJECT keyA; + TPM2B_ECC_POINT inQsB; + TPM2B_ECC_POINT inQeB; + TPMI_ECC_KEY_EXCHANGE inScheme; + UINT16 counter; +} ZGen_2Phase_In; + +#define RC_ZGen_2Phase_keyA (TPM_RC_H + TPM_RC_1) +#define RC_ZGen_2Phase_inQsB (TPM_RC_P + TPM_RC_1) +#define RC_ZGen_2Phase_inQeB (TPM_RC_P + TPM_RC_2) +#define RC_ZGen_2Phase_inScheme (TPM_RC_P + TPM_RC_3) +#define RC_ZGen_2Phase_counter (TPM_RC_P + TPM_RC_4) + +typedef struct { + TPM2B_ECC_POINT outZ1; + TPM2B_ECC_POINT outZ2; +} ZGen_2Phase_Out; + +TPM_RC +TPM2_ZGen_2Phase( + ZGen_2Phase_In *in, // IN: input parameter list + ZGen_2Phase_Out *out // OUT: output parameter list + ); + + +#endif diff --git a/libstb/tss2/ibmtss/tpmconstants12.h b/libstb/tss2/ibmtss/tpmconstants12.h new file mode 100644 index 0000000..6da0edd --- /dev/null +++ b/libstb/tss2/ibmtss/tpmconstants12.h @@ -0,0 +1,1721 @@ +/********************************************************************************/ +/* */ +/* TPM 1.2 Constants */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* */ +/* (c) Copyright IBM Corporation 2006, 2010. */ +/* */ +/* All rights reserved. */ +/* */ +/* Redistribution and use in source and binary forms, with or without */ +/* modification, are permitted provided that the following conditions are */ +/* met: */ +/* */ +/* Redistributions of source code must retain the above copyright notice, */ +/* this list of conditions and the following disclaimer. */ +/* */ +/* 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. */ +/* */ +/* Neither the names of the IBM Corporation nor the names of its */ +/* contributors may be used to endorse or promote products derived from */ +/* this software without specific prior written permission. */ +/* */ +/* 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 TPMCONSTANTS12_H +#define TPMCONSTANTS12_H + +#include <stdint.h> + +/* + NOTE implementation Specific +*/ + +/* + version, revision, specLevel, errataRev +*/ + +/* current for released specification revision 103 */ + +#define TPM_REVISION_MAX 9999 +#ifndef TPM_REVISION +#define TPM_REVISION TPM_REVISION_MAX +#endif + +// #if (TPM_REVISION >= 116) + +// #define TPM_SPEC_LEVEL 0x0002 /* uint16_t The level of ordinals supported */ +// #define TPM_ERRATA_REV 0x03 /* specification errata level */ + +// #elif (TPM_REVISION >= 103) + +// #define TPM_SPEC_LEVEL 0x0002 /* uint16_t The level of ordinals supported */ +// #define TPM_ERRATA_REV 0x02 /* specification errata level */ + +// #elif (TPM_REVISION >= 94) + +// #define TPM_SPEC_LEVEL 0x0002 /* uint16_t The level of ordinals supported */ +// #define TPM_ERRATA_REV 0x01 /* specification errata level */ + +// #elif (TPM_REVISION >= 85) + +// #define TPM_SPEC_LEVEL 0x0002 /* uint16_t The level of ordinals supported */ +// #define TPM_ERRATA_REV 0x00 /* specification errata level */ + +// #else + +// #define TPM_SPEC_LEVEL 0x0001 /* uint16_t The level of ordinals supported */ +// #define TPM_ERRATA_REV 0x00 /* specification errata level */ + +// #endif + +/* IBM specific */ + +#if 0 /* at one time vendorID was the PCI vendor ID, this is the IBM code */ +#define TPM_VENDOR_ID "\x00\x00\x10\x14" /* BYTE[4], the vendor ID, obtained from the TCG, + typically PCI vendor ID */ +#endif + + +#ifdef TPM_VENDOR + +#define TPM_VENDOR_ID "WEC" /* 4 bytes, as of rev 99 vendorID and TPM_CAP_PROP_MANUFACTURER + return the same value */ +#define TPM_MANUFACTURER "WEC" /* 4 characters, assigned by TCG, typically stock ticker symbol */ + +#else + +#define TPM_VENDOR_ID "IBM" /* 4 bytes, as of rev 99 vendorID and TPM_CAP_PROP_MANUFACTURER + return the same value */ +#define TPM_MANUFACTURER "IBM" /* 4 characters, assigned by TCG, typically stock ticker symbol */ + +#endif + +/* Timeouts in microseconds. These are for the platform specific interface (e.g. the LPC bus + registers in the PC Client TPM). They are most likely not applicable to a software TPM. */ +#define TPM_TIMEOUT_A 1000000 +#define TPM_TIMEOUT_B 1000000 +#define TPM_TIMEOUT_C 1000000 +#define TPM_TIMEOUT_D 1000000 + +/* dictionary attack mitigation */ + +#define TPM_LOCKOUT_THRESHOLD 5 /* successive failures to trigger lockout, must be greater + than 0 */ + +/* Denotes the duration value in microseconds of the duration of the three classes of commands: + Small, Medium and Long. The command types are in the Part 2 Ordinal Table. Essentially: + + Long - creating an RSA key pair + Medium - using an RSA key + Short - anything else +*/ + +#ifndef TPM_SMALL_DURATION +#define TPM_SMALL_DURATION 2000000 +#endif + +#ifndef TPM_MEDIUM_DURATION +#define TPM_MEDIUM_DURATION 5000000 +#endif + +#ifndef TPM_LONG_DURATION +#define TPM_LONG_DURATION 60000000 +#endif + +/* startup effects */ + +#define TPM_STARTUP_EFFECTS_VALUE \ +(TPM_STARTUP_EFFECTS_ST_ANY_RT_KEY | /* key resources init by TPM_Startup(ST_ANY) */ \ + TPM_STARTUP_EFFECTS_ST_STATE_RT_HASH | /* hash resources are init by TPM_Startup(ST_STATE) */ \ + TPM_STARTUP_EFFECTS_ST_CLEAR_AUDITDIGEST) /* auditDigest nulled on TPM_Startup(ST_CLEAR) */ + +/* + TPM buffer limits +*/ + +/* This value is used to limit memory allocation to prevent resource overload. */ + +#ifndef TPM_ALLOC_MAX +#define TPM_ALLOC_MAX 0x10000 /* 64k bytes */ +#endif + +/* This is the increment by which the TPM_STORE_BUFFER grows. A larger number saves realloc's. A + smaller number saves memory. + + TPM_ALLOC_MAX must be a multiple of this value. +*/ + +#define TPM_STORE_BUFFER_INCREMENT (TPM_ALLOC_MAX / 64) + +/* This is the maximum value of the TPM input and output packet buffer. It should be large enough + to accommodate the largest TPM command or response, currently about 1200 bytes. It should be + small enough to accommodate whatever software is driving the TPM. + + NOTE: Some commands are somewhat open ended, and related to this parmater. E.g., The input size + for the TPM_SHA1Init. The output size for TPM_GetRandom. + + It is returned by TPM_GetCapability -> TPM_CAP_PROP_INPUT_BUFFER +*/ + +#ifndef TPM_BUFFER_MAX +#define TPM_BUFFER_MAX 0x1000 /* 4k bytes */ +#endif + +/* Random number generator */ + +/* maximum bytes in one TPM_GetRandom() call + + Use maximum input buffer size minus tag, paramSize, returnCode, randomBytesSize. +*/ + +#define TPM_RANDOM_MAX (TPM_BUFFER_MAX \ + - sizeof(TPM_TAG) - sizeof(uint32_t) \ + - sizeof(TPM_RESULT) - sizeof(uint32_t)) + +/* Maximum number of bytes that can be sent to TPM_SHA1Update. Must be a multiple of 64 bytes. + + Use maximum input buffer size minus tag, paramSize, ordinal, numBytes. +*/ + +#define TPM_SHA1_MAXNUMBYTES (TPM_BUFFER_MAX - 64) + +/* extra audit status bits for TSC commands outside the normal ordinal range */ +#define TSC_PHYS_PRES_AUDIT 0x01 +#define TSC_RESET_ESTAB_AUDIT 0x02 + +#ifdef TPM_VTPM +/* ordinals for virtual TPM instance handling */ +/* NOTE must be contiguous, see TPM_PERMANENT_DATA -> instanceOrdinalAuditStatus */ +#define TPM_InstanceOrdinals_Start1 0x20000000 +#define TPM_InstanceOrdinals_End1 0x20000020 +#define TPM_InstanceOrdinals_Start2 0x20000020 +#define TPM_InstanceOrdinals_End2 0x20000040 + +#define TPM_ORD_CreateInstance 0x20000001 +#define TPM_ORD_DeleteInstance 0x20000002 +#define TPM_ORD_LockInstance 0x20000003 +#define TPM_ORD_GetInstanceData 0x20000004 +#define TPM_ORD_SetInstanceData 0x20000005 +#define TPM_ORD_GetInstanceKey 0x20000009 +#define TPM_ORD_SetInstanceKey 0x2000000a +#define TPM_ORD_TransportInstance 0x2000000b +#define TPM_ORD_SetupInstance 0x2000000c +#define TPM_ORD_UnlockInstance 0x2000000e +#define TPM_ORD_ReportEnvironment 0x2000000f +#define TPM_ORD_QuotePubEK 0x20000010 + +/* actionMask for TPM_SetupInstance (bit mask) */ + +#define TPM_INSTANCE_ACTIVATE 0x00000001 +#define TPM_INSTANCE_ENABLE 0x00000002 +#define TPM_INSTANCE_STARTUP 0x00000004 +#define TPM_INSTANCE_INIT 0x00000008 + +#define TPM_INSTANCE_ACTION_MASK 0xfffffff0 /* ~ OR of all above bits */ + +/* creationMask for TPM_CreateInstance (bit mask) */ + +#define TPM_INSTANCE_PRIVILEGED 0x00000001 +#define TPM_INSTANCE_NO_MIGRATE 0x00000002 +#define TPM_INSTANCE_CREATION_MASK 0xfffffffc /* ~ OR of all above bits */ + +/* TPM_CAP_MFR capabilities */ + +#define TPM_CAP_PROP_MAX_INSTANCES 0x00000001 +#define TPM_CAP_INSTANCE_HANDLE 0x00000002 +#define TPM_CAP_INSTANCE_PARENT 0x00000003 +#define TPM_CAP_INSTANCE_CHILDREN 0x00000004 +#define TPM_CAP_CREATION_MASK 0x00000005 +#define TPM_CAP_SETUP_PCRLIST 0x00000006 +#define TPM_CAP_NUMBER_PCR_MEAS 0x00000008 +#define TPM_CAP_PCR_MEASUREMENTS 0x00000009 +#define TPM_CAP_PCR_SELECTIONS 0x0000000a + +/* TPM_SET_VENDOR Subcap */ + +#define TPM_SETCAP_LOG_PCR_SELECTION 0x00000001 +#define TPM_SETCAP_SUBSCRIBE_PCR_SELECTION 0x00000002 +#define TPM_SETCAP_LOG_LOG_LENGTH_MAX 0x00000003 + +/* VTPM Structure Tags */ + +#define TPM_TAG_LOG_ENTRIES 0x8003 + +#endif /* TPM_VTPM */ + +/* TPM_CAP_MFR capabilities */ +#define TPM_CAP_PROCESS_ID 0x00000020 + +#ifdef TPM_VENDOR + +#define WEC_ORD_PreConfig 0x2000000e +#define WEC_ORD_LockPreConfig 0x2000000f +#define WEC_ORD_GetTPMStatus 0x20000021 + +#endif /* TPM_VENDOR */ + +/* define a value for an illegal instance handle */ + +#define TPM_ILLEGAL_INSTANCE_HANDLE 0xffffffff + +/* + NOTE End Implementation Specific +*/ + +/* 3. Structure Tags rev 105 + + There have been some indications that knowing what structure is in use would be valuable + information in each structure. This new tag will be in each new structure that the TPM defines. + + The upper nibble of the value designates the purview of the structure tag. 0 is used for TPM + structures, 1 for platforms, and 2-F are reserved. +*/ + +/* 3.1 TPM_STRUCTURE_TAG */ + +/* Structure */ +#define TPM_TAG_CONTEXTBLOB 0x0001 /* TPM_CONTEXT_BLOB */ +#define TPM_TAG_CONTEXT_SENSITIVE 0x0002 /* TPM_CONTEXT_SENSITIVE */ +#define TPM_TAG_CONTEXTPOINTER 0x0003 /* TPM_CONTEXT_POINTER */ +#define TPM_TAG_CONTEXTLIST 0x0004 /* TPM_CONTEXT_LIST */ +#define TPM_TAG_SIGNINFO 0x0005 /* TPM_SIGN_INFO */ +#define TPM_TAG_PCR_INFO_LONG 0x0006 /* TPM_PCR_INFO_LONG */ +#define TPM_TAG_PERSISTENT_FLAGS 0x0007 /* TPM_PERSISTENT_FLAGS (deprecated 1.1 struct) */ +#define TPM_TAG_VOLATILE_FLAGS 0x0008 /* TPM_VOLATILE_FLAGS (deprecated 1.1 struct) */ +#define TPM_TAG_PERSISTENT_DATA 0x0009 /* TPM_PERSISTENT_DATA (deprecated 1.1 struct) */ +#define TPM_TAG_VOLATILE_DATA 0x000A /* TPM_VOLATILE_DATA (deprecated 1.1 struct) */ +#define TPM_TAG_SV_DATA 0x000B /* TPM_SV_DATA */ +#define TPM_TAG_EK_BLOB 0x000C /* TPM_EK_BLOB */ +#define TPM_TAG_EK_BLOB_AUTH 0x000D /* TPM_EK_BLOB_AUTH */ +#define TPM_TAG_COUNTER_VALUE 0x000E /* TPM_COUNTER_VALUE */ +#define TPM_TAG_TRANSPORT_INTERNAL 0x000F /* TPM_TRANSPORT_INTERNAL */ +#define TPM_TAG_TRANSPORT_LOG_IN 0x0010 /* TPM_TRANSPORT_LOG_IN */ +#define TPM_TAG_TRANSPORT_LOG_OUT 0x0011 /* TPM_TRANSPORT_LOG_OUT */ +#define TPM_TAG_AUDIT_EVENT_IN 0x0012 /* TPM_AUDIT_EVENT_IN */ +#define TPM_TAG_AUDIT_EVENT_OUT 0X0013 /* TPM_AUDIT_EVENT_OUT */ +#define TPM_TAG_CURRENT_TICKS 0x0014 /* TPM_CURRENT_TICKS */ +#define TPM_TAG_KEY 0x0015 /* TPM_KEY */ +#define TPM_TAG_STORED_DATA12 0x0016 /* TPM_STORED_DATA12 */ +#define TPM_TAG_NV_ATTRIBUTES 0x0017 /* TPM_NV_ATTRIBUTES */ +#define TPM_TAG_NV_DATA_PUBLIC 0x0018 /* TPM_NV_DATA_PUBLIC */ +#define TPM_TAG_NV_DATA_SENSITIVE 0x0019 /* TPM_NV_DATA_SENSITIVE */ +#define TPM_TAG_DELEGATIONS 0x001A /* TPM DELEGATIONS */ +#define TPM_TAG_DELEGATE_PUBLIC 0x001B /* TPM_DELEGATE_PUBLIC */ +#define TPM_TAG_DELEGATE_TABLE_ROW 0x001C /* TPM_DELEGATE_TABLE_ROW */ +#define TPM_TAG_TRANSPORT_AUTH 0x001D /* TPM_TRANSPORT_AUTH */ +#define TPM_TAG_TRANSPORT_PUBLIC 0X001E /* TPM_TRANSPORT_PUBLIC */ +#define TPM_TAG_PERMANENT_FLAGS 0X001F /* TPM_PERMANENT_FLAGS */ +#define TPM_TAG_STCLEAR_FLAGS 0X0020 /* TPM_STCLEAR_FLAGS */ +#define TPM_TAG_STANY_FLAGS 0X0021 /* TPM_STANY_FLAGS */ +#define TPM_TAG_PERMANENT_DATA 0X0022 /* TPM_PERMANENT_DATA */ +#define TPM_TAG_STCLEAR_DATA 0X0023 /* TPM_STCLEAR_DATA */ +#define TPM_TAG_STANY_DATA 0X0024 /* TPM_STANY_DATA */ +#define TPM_TAG_FAMILY_TABLE_ENTRY 0X0025 /* TPM_FAMILY_TABLE_ENTRY */ +#define TPM_TAG_DELEGATE_SENSITIVE 0X0026 /* TPM_DELEGATE_SENSITIVE */ +#define TPM_TAG_DELG_KEY_BLOB 0X0027 /* TPM_DELG_KEY_BLOB */ +#define TPM_TAG_KEY12 0x0028 /* TPM_KEY12 */ +#define TPM_TAG_CERTIFY_INFO2 0X0029 /* TPM_CERTIFY_INFO2 */ +#define TPM_TAG_DELEGATE_OWNER_BLOB 0X002A /* TPM_DELEGATE_OWNER_BLOB */ +#define TPM_TAG_EK_BLOB_ACTIVATE 0X002B /* TPM_EK_BLOB_ACTIVATE */ +#define TPM_TAG_DAA_BLOB 0X002C /* TPM_DAA_BLOB */ +#define TPM_TAG_DAA_CONTEXT 0X002D /* TPM_DAA_CONTEXT */ +#define TPM_TAG_DAA_ENFORCE 0X002E /* TPM_DAA_ENFORCE */ +#define TPM_TAG_DAA_ISSUER 0X002F /* TPM_DAA_ISSUER */ +#define TPM_TAG_CAP_VERSION_INFO 0X0030 /* TPM_CAP_VERSION_INFO */ +#define TPM_TAG_DAA_SENSITIVE 0X0031 /* TPM_DAA_SENSITIVE */ +#define TPM_TAG_DAA_TPM 0X0032 /* TPM_DAA_TPM */ +#define TPM_TAG_CMK_MIGAUTH 0X0033 /* TPM_CMK_MIGAUTH */ +#define TPM_TAG_CMK_SIGTICKET 0X0034 /* TPM_CMK_SIGTICKET */ +#define TPM_TAG_CMK_MA_APPROVAL 0X0035 /* TPM_CMK_MA_APPROVAL */ +#define TPM_TAG_QUOTE_INFO2 0X0036 /* TPM_QUOTE_INFO2 */ +#define TPM_TAG_DA_INFO 0x0037 /* TPM_DA_INFO */ +#define TPM_TAG_DA_INFO_LIMITED 0x0038 /* TPM_DA_INFO_LIMITED */ +#define TPM_TAG_DA_ACTION_TYPE 0x0039 /* TPM_DA_ACTION_TYPE */ + +/* + SW TPM Tags +*/ + +/* + These tags are used to describe the format of serialized TPM non-volatile state +*/ + +/* These describe the overall format */ + +/* V1 state is the sequence permanent data, permanent flags, owner evict keys, NV defined space */ + +#define TPM_TAG_NVSTATE_V1 0x0001 /* svn revision 4078 */ + +/* These tags describe the TPM_PERMANENT_DATA format */ + +/* For the first release, use the standard TPM_TAG_PERMANENT_DATA tag. Since this tag is never + visible outside the TPM, the tag value can be changed if the format changes. +*/ + +/* These tags describe the TPM_PERMANENT_FLAGS format */ + +/* The TPM_PERMANENT_FLAGS structure changed from rev 94 to 103. Unfortunately, the standard TPM + tag did not change. Define distinguishing values here. +*/ + +#define TPM_TAG_NVSTATE_PF94 0x0001 +#define TPM_TAG_NVSTATE_PF103 0x0002 + +/* This tag describes the owner evict key format */ + +#define TPM_TAG_NVSTATE_OE_V1 0x0001 + +/* This tag describes the NV defined space format */ + +#define TPM_TAG_NVSTATE_NV_V1 0x0001 + +/* V2 added the NV public optimization */ + +#define TPM_TAG_NVSTATE_NV_V2 0x0002 + +/* + These tags are used to describe the format of serialized TPM volatile state +*/ + +/* These describe the overall format */ + +/* V1 state is the sequence TPM Parameters, TPM_STCLEAR_FLAGS, TPM_STANY_FLAGS, TPM_STCLEAR_DATA, + TPM_STANY_DATA, TPM_KEY_HANDLE_ENTRY, SHA1 context(s), TPM_TRANSHANDLE, testState, NV volatile + flags */ + +#define TPM_TAG_VSTATE_V1 0x0001 + +/* This tag defines the TPM Parameters format */ + +#define TPM_TAG_TPM_PARAMETERS_V1 0x0001 + +/* This tag defines the TPM_STCLEAR_FLAGS format */ + +/* V1 is the TCG standard returned by the getcap. It's unlikely that this will change */ + +#define TPM_TAG_STCLEAR_FLAGS_V1 0x0001 + +/* These tags describe the TPM_STANY_FLAGS format */ + +/* For the first release, use the standard TPM_TAG_STANY_FLAGS tag. Since this tag is never visible + outside the TPM, the tag value can be changed if the format changes. +*/ + +/* This tag defines the TPM_STCLEAR_DATA format */ + +/* V2 deleted the ordinalResponse, responseCount */ + +#define TPM_TAG_STCLEAR_DATA_V2 0X0024 + +/* These tags describe the TPM_STANY_DATA format */ + +/* For the first release, use the standard TPM_TAG_STANY_DATA tag. Since this tag is never visible + outside the TPM, the tag value can be changed if the format changes. +*/ + +/* This tag defines the key handle entries format */ + +#define TPM_TAG_KEY_HANDLE_ENTRIES_V1 0x0001 + +/* This tag defines the SHA-1 context format */ + +#define TPM_TAG_SHA1CONTEXT_OSSL_V1 0x0001 /* for openssl */ + +#define TPM_TAG_SHA1CONTEXT_FREEBL_V1 0x0101 /* for freebl */ + +/* This tag defines the NV index entries volatile format */ + +#define TPM_TAG_NV_INDEX_ENTRIES_VOLATILE_V1 0x0001 + +/* 4. Types + */ + +/* 4.1 TPM_RESOURCE_TYPE rev 87 */ + +#define TPM_RT_KEY 0x00000001 /* The handle is a key handle and is the result of a LoadKey + type operation */ + +#define TPM_RT_AUTH 0x00000002 /* The handle is an authorization handle. Auth handles come from + TPM_OIAP, TPM_OSAP and TPM_DSAP */ + +#define TPM_RT_HASH 0X00000003 /* Reserved for hashes */ + +#define TPM_RT_TRANS 0x00000004 /* The handle is for a transport session. Transport handles come + from TPM_EstablishTransport */ + +#define TPM_RT_CONTEXT 0x00000005 /* Resource wrapped and held outside the TPM using the context + save/restore commands */ + +#define TPM_RT_COUNTER 0x00000006 /* Reserved for counters */ + +#define TPM_RT_DELEGATE 0x00000007 /* The handle is for a delegate row. These are the internal rows + held in NV storage by the TPM */ + +#define TPM_RT_DAA_TPM 0x00000008 /* The value is a DAA TPM specific blob */ + +#define TPM_RT_DAA_V0 0x00000009 /* The value is a DAA V0 parameter */ + +#define TPM_RT_DAA_V1 0x0000000A /* The value is a DAA V1 parameter */ + +/* 4.2 TPM_PAYLOAD_TYPE rev 87 + + This structure specifies the type of payload in various messages. +*/ + +#define TPM_PT_ASYM 0x01 /* The entity is an asymmetric key */ +#define TPM_PT_BIND 0x02 /* The entity is bound data */ +#define TPM_PT_MIGRATE 0x03 /* The entity is a migration blob */ +#define TPM_PT_MAINT 0x04 /* The entity is a maintenance blob */ +#define TPM_PT_SEAL 0x05 /* The entity is sealed data */ +#define TPM_PT_MIGRATE_RESTRICTED 0x06 /* The entity is a restricted-migration asymmetric key */ +#define TPM_PT_MIGRATE_EXTERNAL 0x07 /* The entity is a external migratable key */ +#define TPM_PT_CMK_MIGRATE 0x08 /* The entity is a CMK migratable blob */ +/* 0x09 - 0x7F Reserved for future use by TPM */ +/* 0x80 - 0xFF Vendor specific payloads */ + +/* 4.3 TPM_ENTITY_TYPE rev 100 + + This specifies the types of entity that are supported by the TPM. + + The LSB is used to indicate the entity type. The MSB is used to indicate the ADIP + encryption scheme when applicable. + + For compatibility with TPM 1.1, this mapping is maintained: + + 0x0001 specifies a keyHandle entity with XOR encryption + 0x0002 specifies an owner entity with XOR encryption + 0x0003 specifies some data entity with XOR encryption + 0x0004 specifies the SRK entity with XOR encryption + 0x0005 specifies a key entity with XOR encryption + + When the entity is not being used for ADIP encryption, the MSB MUST be 0x00. +*/ + +/* TPM_ENTITY_TYPE LSB Values (entity type) */ + +#define TPM_ET_KEYHANDLE 0x01 /* The entity is a keyHandle or key */ +#define TPM_ET_OWNER 0x02 /*0x40000001 The entity is the TPM Owner */ +#define TPM_ET_DATA 0x03 /* The entity is some data */ +#define TPM_ET_SRK 0x04 /*0x40000000 The entity is the SRK */ +#define TPM_ET_KEY 0x05 /* The entity is a key or keyHandle */ +#define TPM_ET_REVOKE 0x06 /*0x40000002 The entity is the RevokeTrust value */ +#define TPM_ET_DEL_OWNER_BLOB 0x07 /* The entity is a delegate owner blob */ +#define TPM_ET_DEL_ROW 0x08 /* The entity is a delegate row */ +#define TPM_ET_DEL_KEY_BLOB 0x09 /* The entity is a delegate key blob */ +#define TPM_ET_COUNTER 0x0A /* The entity is a counter */ +#define TPM_ET_NV 0x0B /* The entity is a NV index */ +#define TPM_ET_OPERATOR 0x0C /* The entity is the operator */ +#define TPM_ET_RESERVED_HANDLE 0x40 /* Reserved. This value avoids collisions with the handle + MSB setting.*/ + +/* TPM_ENTITY_TYPE MSB Values (ADIP encryption scheme) */ + +#define TPM_ET_XOR 0x00 /* XOR */ +#define TPM_ET_AES128_CTR 0x06 /* AES 128 bits in CTR mode */ + +/* 4.4 Handles rev 88 + + Handles provides pointers to TPM internal resources. Handles should provide the ability to locate + a value without collision. + + 1. The TPM MAY order and set a handle to any value the TPM determines is appropriate + + 2. The handle value SHALL provide assurance that collisions SHOULD not occur in 2^24 handles + + 4.4.1 Reserved Key Handles + + The reserved key handles. These values specify specific keys or specific actions for the TPM. +*/ + +/* 4.4.1 Reserved Key Handles rev 87 + + The reserved key handles. These values specify specific keys or specific actions for the TPM. + + TPM_KH_TRANSPORT indicates to TPM_EstablishTransport that there is no encryption key, and that + the "secret" wrapped parameters are actually passed unencrypted. +*/ + +#define TPM_KH_SRK 0x40000000 /* The handle points to the SRK */ +#define TPM_KH_OWNER 0x40000001 /* The handle points to the TPM Owner */ +#define TPM_KH_REVOKE 0x40000002 /* The handle points to the RevokeTrust value */ +#define TPM_KH_TRANSPORT 0x40000003 /* The handle points to the TPM_EstablishTransport static + authorization */ +#define TPM_KH_OPERATOR 0x40000004 /* The handle points to the Operator auth */ +#define TPM_KH_ADMIN 0x40000005 /* The handle points to the delegation administration + auth */ +#define TPM_KH_EK 0x40000006 /* The handle points to the PUBEK, only usable with + TPM_OwnerReadInternalPub */ + +/* 4.5 TPM_STARTUP_TYPE rev 87 + + To specify what type of startup is occurring. +*/ + +#define TPM_ST_CLEAR 0x0001 /* The TPM is starting up from a clean state */ +#define TPM_ST_STATE 0x0002 /* The TPM is starting up from a saved state */ +#define TPM_ST_DEACTIVATED 0x0003 /* The TPM is to startup and set the deactivated flag to + TRUE */ + +/* 4.6 TPM_STARTUP_EFFECTS rev 101 + + This structure lists for the various resources and sessions on a TPM the affect that TPM_Startup + has on the values. + + There are three ST_STATE options for keys (restore all, restore non-volatile, or restore none) + and two ST_CLEAR options (restore non-volatile or restore none). As bit 4 was insufficient to + describe the possibilities, it is deprecated. Software should use TPM_CAP_KEY_HANDLE to + determine which keys are loaded after TPM_Startup. + + 31-9 No information and MUST be FALSE + + 8 TPM_RT_DAA_TPM resources are initialized by TPM_Startup(ST_STATE) + 7 TPM_Startup has no effect on auditDigest + 6 auditDigest is set to all zeros on TPM_Startup(ST_CLEAR) but not on other types of TPM_Startup + 5 auditDigest is set to all zeros on TPM_Startup(any) + 4 TPM_RT_KEY Deprecated, as the meaning was subject to interpretation. (Was:TPM_RT_KEY resources + are initialized by TPM_Startup(ST_ANY)) + 3 TPM_RT_AUTH resources are initialized by TPM_Startup(ST_STATE) + 2 TPM_RT_HASH resources are initialized by TPM_Startup(ST_STATE) + 1 TPM_RT_TRANS resources are initialized by TPM_Startup(ST_STATE) + 0 TPM_RT_CONTEXT session (but not key) resources are initialized by TPM_Startup(ST_STATE) +*/ + + +#define TPM_STARTUP_EFFECTS_ST_STATE_RT_DAA 0x00000100 /* bit 8 */ +#define TPM_STARTUP_EFFECTS_STARTUP_NO_AUDITDIGEST 0x00000080 /* bit 7 */ +#define TPM_STARTUP_EFFECTS_ST_CLEAR_AUDITDIGEST 0x00000040 /* bit 6 */ +#define TPM_STARTUP_EFFECTS_STARTUP_AUDITDIGEST 0x00000020 /* bit 5 */ +#define TPM_STARTUP_EFFECTS_ST_ANY_RT_KEY 0x00000010 /* bit 4 */ +#define TPM_STARTUP_EFFECTS_ST_STATE_RT_AUTH 0x00000008 /* bit 3 */ +#define TPM_STARTUP_EFFECTS_ST_STATE_RT_HASH 0x00000004 /* bit 2 */ +#define TPM_STARTUP_EFFECTS_ST_STATE_RT_TRANS 0x00000002 /* bit 1 */ +#define TPM_STARTUP_EFFECTS_ST_STATE_RT_CONTEXT 0x00000001 /* bit 0 */ + +/* 4.7 TPM_PROTOCOL_ID rev 87 + + This value identifies the protocol in use. +*/ + +#define TPM_PID_NONE 0x0000 /* kgold - added */ +#define TPM_PID_OIAP 0x0001 /* The OIAP protocol. */ +#define TPM_PID_OSAP 0x0002 /* The OSAP protocol. */ +#define TPM_PID_ADIP 0x0003 /* The ADIP protocol. */ +#define TPM_PID_ADCP 0X0004 /* The ADCP protocol. */ +#define TPM_PID_OWNER 0X0005 /* The protocol for taking ownership of a TPM. */ +#define TPM_PID_DSAP 0x0006 /* The DSAP protocol */ +#define TPM_PID_TRANSPORT 0x0007 /*The transport protocol */ + +/* 4.8 TPM_ALGORITHM_ID rev 99 + + This table defines the types of algorithms that may be supported by the TPM. + + The TPM MUST support the algorithms TPM_ALG_RSA, TPM_ALG_SHA, TPM_ALG_HMAC, and TPM_ALG_MGF1 +*/ + +//#define TPM_ALG_RSA 0x00000001 /* The RSA algorithm. */ +/* #define TPM_ALG_DES 0x00000002 (was the DES algorithm) */ +/* #define TPM_ALG_3DES 0X00000003 (was the 3DES algorithm in EDE mode) */ +#define TPM_ALG_SHA 0x00000004 /* The SHA1 algorithm */ +//#define TPM_ALG_HMAC 0x00000005 /* The RFC 2104 HMAC algorithm */ +#define TPM_ALG_AES128 0x00000006 /* The AES algorithm, key size 128 */ +//#define TPM_ALG_MGF1 0x00000007 /* The XOR algorithm using MGF1 to create a string the size +//of the encrypted block */ +#define TPM_ALG_AES192 0x00000008 /* AES, key size 192 */ +#define TPM_ALG_AES256 0x00000009 /* AES, key size 256 */ +//#define TPM_ALG_XOR 0x0000000A /* XOR using the rolling nonces */ + +/* 4.9 TPM_PHYSICAL_PRESENCE rev 87 + +*/ + +#define TPM_PHYSICAL_PRESENCE_HW_DISABLE 0x0200 /* Sets the physicalPresenceHWEnable to FALSE + */ +#define TPM_PHYSICAL_PRESENCE_CMD_DISABLE 0x0100 /* Sets the physicalPresenceCMDEnable to + FALSE */ +#define TPM_PHYSICAL_PRESENCE_LIFETIME_LOCK 0x0080 /* Sets the physicalPresenceLifetimeLock to + TRUE */ +#define TPM_PHYSICAL_PRESENCE_HW_ENABLE 0x0040 /* Sets the physicalPresenceHWEnable to TRUE + */ +#define TPM_PHYSICAL_PRESENCE_CMD_ENABLE 0x0020 /* Sets the physicalPresenceCMDEnable to TRUE + */ +#define TPM_PHYSICAL_PRESENCE_NOTPRESENT 0x0010 /* Sets PhysicalPresence = FALSE */ +#define TPM_PHYSICAL_PRESENCE_PRESENT 0x0008 /* Sets PhysicalPresence = TRUE */ +#define TPM_PHYSICAL_PRESENCE_LOCK 0x0004 /* Sets PhysicalPresenceLock = TRUE */ + +#define TPM_PHYSICAL_PRESENCE_MASK 0xfc03 /* ~ OR of all above bits */ + +/* 4.10 TPM_MIGRATE_SCHEME rev 103 + + The scheme indicates how the StartMigrate command should handle the migration of the encrypted + blob. +*/ + +#define TPM_MS_MIGRATE 0x0001 /* A public key that can be used with all TPM + migration commands other than 'ReWrap' mode. */ +#define TPM_MS_REWRAP 0x0002 /* A public key that can be used for the ReWrap mode + of TPM_CreateMigrationBlob. */ +#define TPM_MS_MAINT 0x0003 /* A public key that can be used for the Maintenance + commands */ +#define TPM_MS_RESTRICT_MIGRATE 0x0004 /* The key is to be migrated to a Migration + Authority. */ +#define TPM_MS_RESTRICT_APPROVE 0x0005 /* The key is to be migrated to an entity approved by + a Migration Authority using double wrapping */ + +/* 4.11 TPM_EK_TYPE rev 87 + + This structure indicates what type of information that the EK is dealing with. +*/ + +#define TPM_EK_TYPE_ACTIVATE 0x0001 /* The blob MUST be TPM_EK_BLOB_ACTIVATE */ +#define TPM_EK_TYPE_AUTH 0x0002 /* The blob MUST be TPM_EK_BLOB_AUTH */ + +/* 4.12 TPM_PLATFORM_SPECIFIC rev 87 + + This enumerated type indicates the platform specific spec that the information relates to. +*/ + +#define TPM_PS_PC_11 0x0001 /* PC Specific version 1.1 */ +#define TPM_PS_PC_12 0x0002 /* PC Specific version 1.2 */ +#define TPM_PS_PDA_12 0x0003 /* PDA Specific version 1.2 */ +#define TPM_PS_Server_12 0x0004 /* Server Specific version 1.2 */ +#define TPM_PS_Mobile_12 0x0005 /* Mobil Specific version 1.2 */ + +/* 5.8 TPM_KEY_USAGE rev 101 + + This table defines the types of keys that are possible. Each value defines for what operation + the key can be used. Most key usages can be CMKs. See 4.2, TPM_PAYLOAD_TYPE. + + Each key has a setting defining the encryption and signature scheme to use. The selection of a + key usage value limits the choices of encryption and signature schemes. +*/ + +#define TPM_KEY_UNINITIALIZED 0x0000 /* NOTE: Added. This seems like a good place to indicate + that a TPM_KEY structure has not been initialized */ + +#define TPM_KEY_SIGNING 0x0010 /* This SHALL indicate a signing key. The [private] key + SHALL be used for signing operations, only. This means + that it MUST be a leaf of the Protected Storage key + hierarchy. */ + +#define TPM_KEY_STORAGE 0x0011 /* This SHALL indicate a storage key. The key SHALL be used + to wrap and unwrap other keys in the Protected Storage + hierarchy */ + +#define TPM_KEY_IDENTITY 0x0012 /* This SHALL indicate an identity key. The key SHALL be + used for operations that require a TPM identity, only. */ + +#define TPM_KEY_AUTHCHANGE 0X0013 /* This SHALL indicate an ephemeral key that is in use + during the ChangeAuthAsym process, only. */ + +#define TPM_KEY_BIND 0x0014 /* This SHALL indicate a key that can be used for TPM_Bind + and TPM_Unbind operations only. */ + +#define TPM_KEY_LEGACY 0x0015 /* This SHALL indicate a key that can perform signing and + binding operations. The key MAY be used for both signing + and binding operations. The TPM_KEY_LEGACY key type is to + allow for use by applications where both signing and + encryption operations occur with the same key. */ + +#define TPM_KEY_MIGRATE 0x0016 /* This SHALL indicate a key in use for TPM_MigrateKey */ + +/* 5.8.1 TPM_ENC_SCHEME Mandatory Key Usage Schemes rev 99 + + The TPM MUST check that the encryption scheme defined for use with the key is a valid scheme for + the key type, as follows: +*/ + +#define TPM_ES_NONE 0x0001 +#define TPM_ES_RSAESPKCSv15 0x0002 +#define TPM_ES_RSAESOAEP_SHA1_MGF1 0x0003 +#define TPM_ES_SYM_CTR 0x0004 +#define TPM_ES_SYM_OFB 0x0005 + +/* 5.8.1 TPM_SIG_SCHEME Mandatory Key Usage Schemes rev 99 + + The TPM MUST check that the signature scheme defined for use with the key is a valid scheme for + the key type, as follows: +*/ + +#define TPM_SS_NONE 0x0001 +#define TPM_SS_RSASSAPKCS1v15_SHA1 0x0002 +#define TPM_SS_RSASSAPKCS1v15_DER 0x0003 +#define TPM_SS_RSASSAPKCS1v15_INFO 0x0004 + +/* 5.9 TPM_AUTH_DATA_USAGE rev 110 + + The indication to the TPM when authorization sessions for an entity are required. Future + versions may allow for more complex decisions regarding AuthData checking. +*/ + +#define TPM_AUTH_NEVER 0x00 /* This SHALL indicate that usage of the key without + authorization is permitted. */ + +#define TPM_AUTH_ALWAYS 0x01 /* This SHALL indicate that on each usage of the key the + authorization MUST be performed. */ + +#define TPM_NO_READ_PUBKEY_AUTH 0x03 /* This SHALL indicate that on commands that require the TPM to + use the the key, the authorization MUST be performed. For + commands that cause the TPM to read the public portion of the + key, but not to use the key (e.g. TPM_GetPubKey), the + authorization may be omitted. */ + +/* 5.10 TPM_KEY_FLAGS rev 110 + + This table defines the meanings of the bits in a TPM_KEY_FLAGS structure, used in + TPM_STORE_ASYMKEY and TPM_CERTIFY_INFO. + + The value of TPM_KEY_FLAGS MUST be decomposed into individual mask values. The presence of a mask + value SHALL have the effect described in the above table + + On input, all undefined bits MUST be zero. The TPM MUST return an error if any undefined bit is + set. On output, the TPM MUST set all undefined bits to zero. +*/ + +#define TPM_KEY_FLAGS_MASK 0x0000001f + +#define TPM_REDIRECTION 0x00000001 /* This mask value SHALL indicate the use of redirected + output. */ + +#define TPM_MIGRATABLE 0x00000002 /* This mask value SHALL indicate that the key is + migratable. */ + +#define TPM_ISVOLATILE 0x00000004 /* This mask value SHALL indicate that the key MUST be + unloaded upon execution of the + TPM_Startup(ST_Clear). This does not indicate that a + non-volatile key will remain loaded across + TPM_Startup(ST_Clear) events. */ + +#define TPM_PCRIGNOREDONREAD 0x00000008 /* When TRUE the TPM MUST NOT check digestAtRelease or + localityAtRelease for commands that read the public + portion of the key (e.g., TPM_GetPubKey) and MAY NOT + check digestAtRelease or localityAtRelease for + commands that use the public portion of the key + (e.g. TPM_Seal) + + When FALSE the TPM MUST check digestAtRelease and + localityAtRelease for commands that read or use the + public portion of the key */ + +#define TPM_MIGRATEAUTHORITY 0x00000010 /* When set indicates that the key is under control of a + migration authority. The TPM MUST only allow the + creation of a key with this flag in + TPM_MA_CreateKey */ + +/* 5.17 TPM_CMK_DELEGATE values rev 89 + + The bits of TPM_CMK_DELEGATE are flags that determine how the TPM responds to delegated requests + to manipulate a certified-migration-key, a loaded key with payload type TPM_PT_MIGRATE_RESTRICTED + or TPM_PT_MIGRATE_EXTERNAL.. + + 26:0 reserved MUST be 0 + + The default value of TPM_CMK_Delegate is zero (0) +*/ + +#define TPM_CMK_DELEGATE_SIGNING 0x80000000 /* When set to 1, this bit SHALL indicate that a + delegated command may manipulate a CMK of + TPM_KEY_USAGE == TPM_KEY_SIGNING */ +#define TPM_CMK_DELEGATE_STORAGE 0x40000000 /* When set to 1, this bit SHALL indicate that a + delegated command may manipulate a CMK of + TPM_KEY_USAGE == TPM_KEY_STORAGE */ +#define TPM_CMK_DELEGATE_BIND 0x20000000 /* When set to 1, this bit SHALL indicate that a + delegated command may manipulate a CMK of + TPM_KEY_USAGE == TPM_KEY_BIND */ +#define TPM_CMK_DELEGATE_LEGACY 0x10000000 /* When set to 1, this bit SHALL indicate that a + delegated command may manipulate a CMK of + TPM_KEY_USAGE == TPM_KEY_LEGACY */ +#define TPM_CMK_DELEGATE_MIGRATE 0x08000000 /* When set to 1, this bit SHALL indicate that a + delegated command may manipulate a CMK of + TPM_KEY_USAGE == TPM_KEY_MIGRATE */ + +/* 6. TPM_TAG (Command and Response Tags) rev 100 + + These tags indicate to the TPM the construction of the command either as input or as output. The + AUTH indicates that there are one or more AuthData values that follow the command + parameters. +*/ + +#define TPM_TAG_RQU_COMMAND 0x00C1 /* A command with no authentication. */ +#define TPM_TAG_RQU_AUTH1_COMMAND 0x00C2 /* An authenticated command with one authentication + handle */ +#define TPM_TAG_RQU_AUTH2_COMMAND 0x00C3 /* An authenticated command with two authentication + handles */ +#define TPM_TAG_RSP_COMMAND 0x00C4 /* A response from a command with no authentication + */ +#define TPM_TAG_RSP_AUTH1_COMMAND 0x00C5 /* An authenticated response with one authentication + handle */ +#define TPM_TAG_RSP_AUTH2_COMMAND 0x00C6 /* An authenticated response with two authentication + handles */ + +/* TIS 7.2 PCR Attributes + +*/ + +#define TPM_DEBUG_PCR 16 +#define TPM_LOCALITY_4_PCR 17 +#define TPM_LOCALITY_3_PCR 18 +#define TPM_LOCALITY_2_PCR 19 +#define TPM_LOCALITY_1_PCR 20 + +/* 10.9 TPM_KEY_CONTROL rev 87 + + Attributes that can control various aspects of key usage and manipulation. + + Allows for controlling of the key when loaded and how to handle TPM_Startup issues. +*/ + +#define TPM_KEY_CONTROL_OWNER_EVICT 0x00000001 /* Owner controls when the key is evicted + from the TPM. When set the TPM MUST + preserve key the key across all TPM_Init + invocations. */ + +/* 13.1.1 TPM_TRANSPORT_ATTRIBUTES Definitions */ + +#define TPM_TRANSPORT_ENCRYPT 0x00000001 /* The session will provide encryption using + the internal encryption algorithm */ +#define TPM_TRANSPORT_LOG 0x00000002 /* The session will provide a log of all + operations that occur in the session */ +#define TPM_TRANSPORT_EXCLUSIVE 0X00000004 /* The transport session is exclusive and + any command executed outside the + transport session causes the invalidation + of the session */ + +/* 21.1 TPM_CAPABILITY_AREA rev 115 + + To identify a capability to be queried. +*/ + +#define TPM_CAP_ORD 0x00000001 /* Boolean value. TRUE indicates that the TPM supports + the ordinal. FALSE indicates that the TPM does not + support the ordinal. Unimplemented optional ordinals + and unused (unassigned) ordinals return FALSE. */ +#define TPM_CAP_ALG 0x00000002 /* Boolean value. TRUE means that the TPM supports the + asymmetric algorithm for TPM_Sign, TPM_Seal, + TPM_UnSeal and TPM_UnBind and related commands. FALSE + indicates that the asymmetric algorithm is not + supported for these types of commands. The TPM MAY + return TRUE or FALSE for other than asymmetric + algoroithms that it supports. Unassigned and + unsupported algorithm IDs return FALSE.*/ + +#define TPM_CAP_PID 0x00000003 /* Boolean value. TRUE indicates that the TPM supports + the protocol, FALSE indicates that the TPM does not + support the protocol. */ +#define TPM_CAP_FLAG 0x00000004 /* Return the TPM_PERMANENT_FLAGS structure or Return the + TPM_STCLEAR_FLAGS structure */ +#define TPM_CAP_PROPERTY 0x00000005 /* See following table for the subcaps */ +#define TPM_CAP_VERSION 0x00000006 /* TPM_STRUCT_VER structure. The Major and Minor must + indicate 1.1. The firmware revision MUST indicate + 0.0 */ +#define TPM_CAP_KEY_HANDLE 0x00000007 /* A TPM_KEY_HANDLE_LIST structure that enumerates all + key handles loaded on the TPM. */ +#define TPM_CAP_CHECK_LOADED 0x00000008 /* A Boolean value. TRUE indicates that the TPM has + enough memory available to load a key of the type + specified by TPM_KEY_PARMS. FALSE indicates that the + TPM does not have enough memory. */ +#define TPM_CAP_SYM_MODE 0x00000009 /* Subcap TPM_SYM_MODE + A Boolean value. TRUE indicates that the TPM supports + the TPM_SYM_MODE, FALSE indicates the TPM does not + support the mode. */ +#define TPM_CAP_KEY_STATUS 0x0000000C /* Boolean value of ownerEvict. The handle MUST point to + a valid key handle.*/ +#define TPM_CAP_NV_LIST 0x0000000D /* A list of TPM_NV_INDEX values that are currently + allocated NV storage through TPM_NV_DefineSpace. */ +#define TPM_CAP_MFR 0x00000010 /* Manufacturer specific. The manufacturer may provide + any additional information regarding the TPM and the + TPM state but MUST not expose any sensitive + information. */ +#define TPM_CAP_NV_INDEX 0x00000011 /* A TPM_NV_DATA_PUBLIC structure that indicates the + values for the TPM_NV_INDEX. Returns TPM_BADINDEX if + the index is not in the TPM_CAP_NV_LIST list. */ +#define TPM_CAP_TRANS_ALG 0x00000012 /* Boolean value. TRUE means that the TPM supports the + algorithm for TPM_EstablishTransport, + TPM_ExecuteTransport and + TPM_ReleaseTransportSigned. FALSE indicates that for + these three commands the algorithm is not supported." + */ +#define TPM_CAP_HANDLE 0x00000014 /* A TPM_KEY_HANDLE_LIST structure that enumerates all + handles currently loaded in the TPM for the given + resource type. */ +#define TPM_CAP_TRANS_ES 0x00000015 /* Boolean value. TRUE means the TPM supports the + encryption scheme in a transport session for at least + one algorithm.. */ +#define TPM_CAP_AUTH_ENCRYPT 0x00000017 /* Boolean value. TRUE indicates that the TPM supports + the encryption algorithm in OSAP encryption of + AuthData values */ +#define TPM_CAP_SELECT_SIZE 0x00000018 /* Boolean value. TRUE indicates that the TPM supports + the size for the given version. For instance a request + could ask for version 1.1 size 2 and the TPM would + indicate TRUE. For 1.1 size 3 the TPM would indicate + FALSE. For 1.2 size 3 the TPM would indicate TRUE. */ +#define TPM_CAP_DA_LOGIC 0x00000019 /* (OPTIONAL) + A TPM_DA_INFO or TPM_DA_INFO_LIMITED structure that + returns data according to the selected entity type + (e.g., TPM_ET_KEYHANDLE, TPM_ET_OWNER, TPM_ET_SRK, + TPM_ET_COUNTER, TPM_ET_OPERATOR, etc.). If the + implemented dictionary attack logic does not support + different secret types, the entity type can be + ignored. */ +#define TPM_CAP_VERSION_VAL 0x0000001A /* TPM_CAP_VERSION_INFO structure. The TPM fills in the + structure and returns the information indicating what + the TPM currently supports. */ + +#define TPM_CAP_FLAG_PERMANENT 0x00000108 /* Return the TPM_PERMANENT_FLAGS structure */ +#define TPM_CAP_FLAG_VOLATILE 0x00000109 /* Return the TPM_STCLEAR_FLAGS structure */ + +/* 21.2 CAP_PROPERTY Subcap values for CAP_PROPERTY rev 105 + + The TPM_CAP_PROPERTY capability has numerous subcap values. The definition for all subcap values + occurs in this table. + + TPM_CAP_PROP_MANUFACTURER returns a vendor ID unique to each manufacturer. The same value is + returned as the TPM_CAP_VERSION_INFO -> tpmVendorID. A company abbreviation such as a null + terminated stock ticker is a typical choice. However, there is no requirement that the value + contain printable characters. The document "TCG Vendor Naming" lists the vendor ID values. + + TPM_CAP_PROP_MAX_xxxSESS is a constant. At TPM_Startup(ST_CLEAR) TPM_CAP_PROP_xxxSESS == + TPM_CAP_PROP_MAX_xxxSESS. As sessions are created on the TPM, TPM_CAP_PROP_xxxSESS decreases + toward zero. As sessions are terminated, TPM_CAP_PROP_xxxSESS increases toward + TPM_CAP_PROP_MAX_xxxSESS. + + There is a similar relationship between the constants TPM_CAP_PROP_MAX_COUNTERS and + TPM_CAP_PROP_MAX_CONTEXT and the varying TPM_CAP_PROP_COUNTERS and TPM_CAP_PROP_CONTEXT. + + In one typical implementation where authorization and transport sessions reside in separate + pools, TPM_CAP_PROP_SESSIONS will be the sum of TPM_CAP_PROP_AUTHSESS and TPM_CAP_PROP_TRANSESS. + In another typical implementation where authorization and transport sessions share the same pool, + TPM_CAP_PROP_SESSIONS, TPM_CAP_PROP_AUTHSESS, and TPM_CAP_PROP_TRANSESS will all be equal. +*/ + +#define TPM_CAP_PROP_PCR 0x00000101 /* uint32_t value. Returns the number of PCR + registers supported by the TPM */ +#define TPM_CAP_PROP_DIR 0x00000102 /* uint32_t. Deprecated. Returns the number of + DIR, which is now fixed at 1 */ +#define TPM_CAP_PROP_MANUFACTURER 0x00000103 /* uint32_t value. Returns the vendor ID + unique to each TPM manufacturer. */ +#define TPM_CAP_PROP_KEYS 0x00000104 /* uint32_t value. Returns the number of 2048- + bit RSA keys that can be loaded. This may + vary with time and circumstances. */ +#define TPM_CAP_PROP_MIN_COUNTER 0x00000107 /* uint32_t. The minimum amount of time in + 10ths of a second that must pass between + invocations of incrementing the monotonic + counter. */ +#define TPM_CAP_PROP_AUTHSESS 0x0000010A /* uint32_t. The number of available + authorization sessions. This may vary with + time and circumstances. */ +#define TPM_CAP_PROP_TRANSESS 0x0000010B /* uint32_t. The number of available transport + sessions. This may vary with time and + circumstances. */ +#define TPM_CAP_PROP_COUNTERS 0x0000010C /* uint32_t. The number of available monotonic + counters. This may vary with time and + circumstances. */ +#define TPM_CAP_PROP_MAX_AUTHSESS 0x0000010D /* uint32_t. The maximum number of loaded + authorization sessions the TPM supports */ +#define TPM_CAP_PROP_MAX_TRANSESS 0x0000010E /* uint32_t. The maximum number of loaded + transport sessions the TPM supports. */ +#define TPM_CAP_PROP_MAX_COUNTERS 0x0000010F /* uint32_t. The maximum number of monotonic + counters under control of TPM_CreateCounter + */ +#define TPM_CAP_PROP_MAX_KEYS 0x00000110 /* uint32_t. The maximum number of 2048 RSA + keys that the TPM can support. The number + does not include the EK or SRK. */ +#define TPM_CAP_PROP_OWNER 0x00000111 /* BOOL. A value of TRUE indicates that the + TPM has successfully installed an owner. */ +#define TPM_CAP_PROP_CONTEXT 0x00000112 /* uint32_t. The number of available saved + session slots. This may vary with time and + circumstances. */ +#define TPM_CAP_PROP_MAX_CONTEXT 0x00000113 /* uint32_t. The maximum number of saved + session slots. */ +#define TPM_CAP_PROP_FAMILYROWS 0x00000114 /* uint32_t. The maximum number of rows in the + family table */ +#define TPM_CAP_PROP_TIS_TIMEOUT 0x00000115 /* A 4 element array of uint32_t values each + denoting the timeout value in microseconds + for the following in this order: + + TIMEOUT_A, TIMEOUT_B, TIMEOUT_C, TIMEOUT_D + + Where these timeouts are to be used is + determined by the platform specific TPM + Interface Specification. */ +#define TPM_CAP_PROP_STARTUP_EFFECT 0x00000116 /* The TPM_STARTUP_EFFECTS structure */ +#define TPM_CAP_PROP_DELEGATE_ROW 0x00000117 /* uint32_t. The maximum size of the delegate + table in rows. */ +#define TPM_CAP_PROP_MAX_DAASESS 0x00000119 /* uint32_t. The maximum number of loaded DAA + sessions (join or sign) that the TPM + supports */ +#define TPM_CAP_PROP_DAASESS 0x0000011A /* uint32_t. The number of available DAA + sessions. This may vary with time and + circumstances */ +#define TPM_CAP_PROP_CONTEXT_DIST 0x0000011B /* uint32_t. The maximum distance between + context count values. This MUST be at least + 2^16-1. */ +#define TPM_CAP_PROP_DAA_INTERRUPT 0x0000011C /* BOOL. A value of TRUE indicates that the + TPM will accept ANY command while executing + a DAA Join or Sign. + + A value of FALSE indicates that the TPM + will invalidate the DAA Join or Sign upon + the receipt of any command other than the + next join/sign in the session or a + TPM_SaveContext */ +#define TPM_CAP_PROP_SESSIONS 0X0000011D /* uint32_t. The number of available sessions + from the pool. This MAY vary with time and + circumstances. Pool sessions include + authorization and transport sessions. */ +#define TPM_CAP_PROP_MAX_SESSIONS 0x0000011E /* uint32_t. The maximum number of sessions + the TPM supports. */ +#define TPM_CAP_PROP_CMK_RESTRICTION 0x0000011F /* uint32_t TPM_Permanent_Data -> + restrictDelegate + */ +#define TPM_CAP_PROP_DURATION 0x00000120 /* A 3 element array of uint32_t values each + denoting the duration value in microseconds + of the duration of the three classes of + commands: Small, Medium and Long in the + following in this order: SMALL_DURATION, + MEDIUM_DURATION, LONG_DURATION */ +#define TPM_CAP_PROP_ACTIVE_COUNTER 0x00000122 /* TPM_COUNT_ID. The id of the current + counter. 0xff..ff if no counter is active + */ +#define TPM_CAP_PROP_MAX_NV_AVAILABLE 0x00000123 /*uint32_t. Deprecated. The maximum number + of NV space that can be allocated, MAY + vary with time and circumstances. This + capability was not implemented + consistently, and is replaced by + TPM_NV_INDEX_TRIAL. */ +#define TPM_CAP_PROP_INPUT_BUFFER 0x00000124 /* uint32_t. The maximum size of the TPM + input buffer or output buffer in + bytes. */ + +/* 21.4 Set_Capability Values rev 107 + */ + +#define TPM_SET_PERM_FLAGS 0x00000001 /* The ability to set a value is field specific and + a review of the structure will disclose the + ability and requirements to set a value */ +#define TPM_SET_PERM_DATA 0x00000002 /* The ability to set a value is field specific and + a review of the structure will disclose the + ability and requirements to set a value */ +#define TPM_SET_STCLEAR_FLAGS 0x00000003 /* The ability to set a value is field specific and + a review of the structure will disclose the + ability and requirements to set a value */ +#define TPM_SET_STCLEAR_DATA 0x00000004 /* The ability to set a value is field specific and + a review of the structure will disclose the + ability and requirements to set a value */ +#define TPM_SET_STANY_FLAGS 0x00000005 /* The ability to set a value is field specific and + a review of the structure will disclose the + ability and requirements to set a value */ +#define TPM_SET_STANY_DATA 0x00000006 /* The ability to set a value is field specific and + a review of the structure will disclose the + ability and requirements to set a value */ +#define TPM_SET_VENDOR 0x00000007 /* This area allows the vendor to set specific areas + in the TPM according to the normal shielded + location requirements */ + +/* Set Capability sub caps */ + +/* TPM_PERMANENT_FLAGS */ + +#define TPM_PF_DISABLE 1 +#define TPM_PF_OWNERSHIP 2 +#define TPM_PF_DEACTIVATED 3 +#define TPM_PF_READPUBEK 4 +#define TPM_PF_DISABLEOWNERCLEAR 5 +#define TPM_PF_ALLOWMAINTENANCE 6 +#define TPM_PF_PHYSICALPRESENCELIFETIMELOCK 7 +#define TPM_PF_PHYSICALPRESENCEHWENABLE 8 +#define TPM_PF_PHYSICALPRESENCECMDENABLE 9 +#define TPM_PF_CEKPUSED 10 +#define TPM_PF_TPMPOST 11 +#define TPM_PF_TPMPOSTLOCK 12 +#define TPM_PF_FIPS 13 +#define TPM_PF_OPERATOR 14 +#define TPM_PF_ENABLEREVOKEEK 15 +#define TPM_PF_NV_LOCKED 16 +#define TPM_PF_READSRKPUB 17 +#define TPM_PF_TPMESTABLISHED 18 +#define TPM_PF_MAINTENANCEDONE 19 +#define TPM_PF_DISABLEFULLDALOGICINFO 20 + +/* TPM_STCLEAR_FLAGS */ + +#define TPM_SF_DEACTIVATED 1 +#define TPM_SF_DISABLEFORCECLEAR 2 +#define TPM_SF_PHYSICALPRESENCE 3 +#define TPM_SF_PHYSICALPRESENCELOCK 4 +#define TPM_SF_BGLOBALLOCK 5 + +/* TPM_STANY_FLAGS */ + +#define TPM_AF_POSTINITIALISE 1 +#define TPM_AF_LOCALITYMODIFIER 2 +#define TPM_AF_TRANSPORTEXCLUSIVE 3 +#define TPM_AF_TOSPRESENT 4 + +/* TPM_PERMANENT_DATA */ + +#define TPM_PD_REVMAJOR 1 +#define TPM_PD_REVMINOR 2 +#define TPM_PD_TPMPROOF 3 +#define TPM_PD_OWNERAUTH 4 +#define TPM_PD_OPERATORAUTH 5 +#define TPM_PD_MANUMAINTPUB 6 +#define TPM_PD_ENDORSEMENTKEY 7 +#define TPM_PD_SRK 8 +#define TPM_PD_DELEGATEKEY 9 +#define TPM_PD_CONTEXTKEY 10 +#define TPM_PD_AUDITMONOTONICCOUNTER 11 +#define TPM_PD_MONOTONICCOUNTER 12 +#define TPM_PD_PCRATTRIB 13 +#define TPM_PD_ORDINALAUDITSTATUS 14 +#define TPM_PD_AUTHDIR 15 +#define TPM_PD_RNGSTATE 16 +#define TPM_PD_FAMILYTABLE 17 +#define TPM_DELEGATETABLE 18 +#define TPM_PD_EKRESET 19 +#define TPM_PD_LASTFAMILYID 21 +#define TPM_PD_NOOWNERNVWRITE 22 +#define TPM_PD_RESTRICTDELEGATE 23 +#define TPM_PD_TPMDAASEED 24 +#define TPM_PD_DAAPROOF 25 + +/* TPM_STCLEAR_DATA */ + +#define TPM_SD_CONTEXTNONCEKEY 1 +#define TPM_SD_COUNTID 2 +#define TPM_SD_OWNERREFERENCE 3 +#define TPM_SD_DISABLERESETLOCK 4 +#define TPM_SD_PCR 5 +#define TPM_SD_DEFERREDPHYSICALPRESENCE 6 + +/* TPM_STCLEAR_DATA -> deferredPhysicalPresence bits */ + +#define TPM_DPP_UNOWNED_FIELD_UPGRADE 0x00000001 /* bit 0 TPM_FieldUpgrade */ + +/* TPM_STANY_DATA */ + +#define TPM_AD_CONTEXTNONCESESSION 1 +#define TPM_AD_AUDITDIGEST 2 +#define TPM_AD_CURRENTTICKS 3 +#define TPM_AD_CONTEXTCOUNT 4 +#define TPM_AD_CONTEXTLIST 5 +#define TPM_AD_SESSIONS 6 + +/* 17. Ordinals rev 110 + + Ordinals are 32 bit values of type TPM_COMMAND_CODE. The upper byte contains values that serve + as flag indicators, the next byte contains values indicating what committee designated the + ordinal, and the final two bytes contain the Command Ordinal Index. + + 3 2 1 + 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + |P|C|V| Reserved| Purview | Command Ordinal Index | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + + Where: + + P is Protected/Unprotected command. When 0 the command is a Protected command, when 1 the + command is an Unprotected command. + + C is Non-Connection/Connection related command. When 0 this command passes through to either the + protected (TPM) or unprotected (TSS) components. + + V is TPM/Vendor command. When 0 the command is TPM defined, when 1 the command is vendor + defined. + + All reserved area bits are set to 0. +*/ + +/* The following masks are created to allow for the quick definition of the commands */ + +#define TPM_PROTECTED_COMMAND 0x00000000 /* TPM protected command, specified in main specification + */ +#define TPM_UNPROTECTED_COMMAND 0x80000000 /* TSS command, specified in the TSS specification */ +#define TPM_CONNECTION_COMMAND 0x40000000 /* TSC command, protected connection commands are + specified in the main specification Unprotected + connection commands are specified in the TSS */ +#define TPM_VENDOR_COMMAND 0x20000000 /* Command that is vendor specific for a given TPM or + TSS. */ + + +/* The following Purviews have been defined: */ + +#define TPM_MAIN 0x00 /* Command is from the main specification */ +#define TPM_PC 0x01 /* Command is specific to the PC */ +#define TPM_PDA 0x02 /* Command is specific to a PDA */ +#define TPM_CELL_PHONE 0x03 /* Command is specific to a cell phone */ +#define TPM_SERVER 0x04 /* Command is specific to servers */ +#define TPM_PERIPHERAL 0x05 /* Command is specific to peripherals */ +//#define TPM_TSS 0x06 /* Command is specific to TSS */ + +/* Combinations for the main specification would be: */ + +#define TPM_PROTECTED_ORDINAL (TPM_PROTECTED_COMMAND | TPM_MAIN) +#define TPM_UNPROTECTED_ORDINAL (TPM_UNPROTECTED_COMMAND | TPM_MAIN) +#define TPM_CONNECTION_ORDINAL (TPM_CONNECTION_COMMAND | TPM_MAIN) + +/* Command ordinals */ + +#define TPM_ORD_ActivateIdentity 0x0000007A +#define TPM_ORD_AuthorizeMigrationKey 0x0000002B +#define TPM_ORD_CertifyKey 0x00000032 +#define TPM_ORD_CertifyKey2 0x00000033 +#define TPM_ORD_CertifySelfTest 0x00000052 +#define TPM_ORD_ChangeAuth 0x0000000C +#define TPM_ORD_ChangeAuthAsymFinish 0x0000000F +#define TPM_ORD_ChangeAuthAsymStart 0x0000000E +#define TPM_ORD_ChangeAuthOwner 0x00000010 +#define TPM_ORD_CMK_ApproveMA 0x0000001D +#define TPM_ORD_CMK_ConvertMigration 0x00000024 +#define TPM_ORD_CMK_CreateBlob 0x0000001B +#define TPM_ORD_CMK_CreateKey 0x00000013 +#define TPM_ORD_CMK_CreateTicket 0x00000012 +#define TPM_ORD_CMK_SetRestrictions 0x0000001C +#define TPM_ORD_ContinueSelfTest 0x00000053 +#define TPM_ORD_ConvertMigrationBlob 0x0000002A +#define TPM_ORD_CreateCounter 0x000000DC +#define TPM_ORD_CreateEndorsementKeyPair 0x00000078 +#define TPM_ORD_CreateMaintenanceArchive 0x0000002C +#define TPM_ORD_CreateMigrationBlob 0x00000028 +#define TPM_ORD_CreateRevocableEK 0x0000007F +#define TPM_ORD_CreateWrapKey 0x0000001F +#define TPM_ORD_DAA_Join 0x00000029 +#define TPM_ORD_DAA_Sign 0x00000031 +#define TPM_ORD_Delegate_CreateKeyDelegation 0x000000D4 +#define TPM_ORD_Delegate_CreateOwnerDelegation 0x000000D5 +#define TPM_ORD_Delegate_LoadOwnerDelegation 0x000000D8 +#define TPM_ORD_Delegate_Manage 0x000000D2 +#define TPM_ORD_Delegate_ReadTable 0x000000DB +#define TPM_ORD_Delegate_UpdateVerification 0x000000D1 +#define TPM_ORD_Delegate_VerifyDelegation 0x000000D6 +#define TPM_ORD_DirRead 0x0000001A +#define TPM_ORD_DirWriteAuth 0x00000019 +#define TPM_ORD_DisableForceClear 0x0000005E +#define TPM_ORD_DisableOwnerClear 0x0000005C +#define TPM_ORD_DisablePubekRead 0x0000007E +#define TPM_ORD_DSAP 0x00000011 +#define TPM_ORD_EstablishTransport 0x000000E6 +#define TPM_ORD_EvictKey 0x00000022 +#define TPM_ORD_ExecuteTransport 0x000000E7 +#define TPM_ORD_Extend 0x00000014 +#define TPM_ORD_FieldUpgrade 0x000000AA +#define TPM_ORD_FlushSpecific 0x000000BA +#define TPM_ORD_ForceClear 0x0000005D +#define TPM_ORD_GetAuditDigest 0x00000085 +#define TPM_ORD_GetAuditDigestSigned 0x00000086 +#define TPM_ORD_GetAuditEvent 0x00000082 +#define TPM_ORD_GetAuditEventSigned 0x00000083 +#define TPM_ORD_GetCapability 0x00000065 +#define TPM_ORD_GetCapabilityOwner 0x00000066 +#define TPM_ORD_GetCapabilitySigned 0x00000064 +#define TPM_ORD_GetOrdinalAuditStatus 0x0000008C +#define TPM_ORD_GetPubKey 0x00000021 +#define TPM_ORD_GetRandom 0x00000046 +#define TPM_ORD_GetTestResult 0x00000054 +#define TPM_ORD_GetTicks 0x000000F1 +#define TPM_ORD_IncrementCounter 0x000000DD +#define TPM_ORD_Init 0x00000097 +#define TPM_ORD_KeyControlOwner 0x00000023 +#define TPM_ORD_KillMaintenanceFeature 0x0000002E +#define TPM_ORD_LoadAuthContext 0x000000B7 +#define TPM_ORD_LoadContext 0x000000B9 +#define TPM_ORD_LoadKey 0x00000020 +#define TPM_ORD_LoadKey2 0x00000041 +#define TPM_ORD_LoadKeyContext 0x000000B5 +#define TPM_ORD_LoadMaintenanceArchive 0x0000002D +#define TPM_ORD_LoadManuMaintPub 0x0000002F +#define TPM_ORD_MakeIdentity 0x00000079 +#define TPM_ORD_MigrateKey 0x00000025 +#define TPM_ORD_NV_DefineSpace 0x000000CC +#define TPM_ORD_NV_ReadValue 0x000000CF +#define TPM_ORD_NV_ReadValueAuth 0x000000D0 +#define TPM_ORD_NV_WriteValue 0x000000CD +#define TPM_ORD_NV_WriteValueAuth 0x000000CE +#define TPM_ORD_OIAP 0x0000000A +#define TPM_ORD_OSAP 0x0000000B +#define TPM_ORD_OwnerClear 0x0000005B +#define TPM_ORD_OwnerReadInternalPub 0x00000081 +#define TPM_ORD_OwnerReadPubek 0x0000007D +#define TPM_ORD_OwnerSetDisable 0x0000006E +#define TPM_ORD_PCR_Reset 0x000000C8 +#define TPM_ORD_PcrRead 0x00000015 +#define TPM_ORD_PhysicalDisable 0x00000070 +#define TPM_ORD_PhysicalEnable 0x0000006F +#define TPM_ORD_PhysicalSetDeactivated 0x00000072 +#define TPM_ORD_Quote 0x00000016 +#define TPM_ORD_Quote2 0x0000003E +#define TPM_ORD_ReadCounter 0x000000DE +#define TPM_ORD_ReadManuMaintPub 0x00000030 +#define TPM_ORD_ReadPubek 0x0000007C +#define TPM_ORD_ReleaseCounter 0x000000DF +#define TPM_ORD_ReleaseCounterOwner 0x000000E0 +#define TPM_ORD_ReleaseTransportSigned 0x000000E8 +#define TPM_ORD_Reset 0x0000005A +#define TPM_ORD_ResetLockValue 0x00000040 +#define TPM_ORD_RevokeTrust 0x00000080 +#define TPM_ORD_SaveAuthContext 0x000000B6 +#define TPM_ORD_SaveContext 0x000000B8 +#define TPM_ORD_SaveKeyContext 0x000000B4 +#define TPM_ORD_SaveState 0x00000098 +#define TPM_ORD_Seal 0x00000017 +#define TPM_ORD_Sealx 0x0000003D +#define TPM_ORD_SelfTestFull 0x00000050 +#define TPM_ORD_SetCapability 0x0000003F +#define TPM_ORD_SetOperatorAuth 0x00000074 +#define TPM_ORD_SetOrdinalAuditStatus 0x0000008D +#define TPM_ORD_SetOwnerInstall 0x00000071 +#define TPM_ORD_SetOwnerPointer 0x00000075 +#define TPM_ORD_SetRedirection 0x0000009A +#define TPM_ORD_SetTempDeactivated 0x00000073 +#define TPM_ORD_SHA1Complete 0x000000A2 +#define TPM_ORD_SHA1CompleteExtend 0x000000A3 +#define TPM_ORD_SHA1Start 0x000000A0 +#define TPM_ORD_SHA1Update 0x000000A1 +#define TPM_ORD_Sign 0x0000003C +#define TPM_ORD_Startup 0x00000099 +#define TPM_ORD_StirRandom 0x00000047 +#define TPM_ORD_TakeOwnership 0x0000000D +#define TPM_ORD_Terminate_Handle 0x00000096 +#define TPM_ORD_TickStampBlob 0x000000F2 +#define TPM_ORD_UnBind 0x0000001E +#define TPM_ORD_Unseal 0x00000018 + +#define TSC_ORD_PhysicalPresence 0x4000000A +#define TSC_ORD_ResetEstablishmentBit 0x4000000B + +/* 19. NV storage structures */ + +/* 19.1 TPM_NV_INDEX rev 110 + + The index provides the handle to identify the area of storage. The reserved bits allow for a + segregation of the index name space to avoid name collisions. + + The TPM may check the resvd bits for zero. Thus, applications should set the bits to zero. + + The TCG defines the space where the high order bits (T, P, U) are 0. The other spaces are + controlled by the indicated entity. + + T is the TPM manufacturer reserved bit. 0 indicates a TCG defined value. 1 indicates a TPM + manufacturer specific value. + + P is the platform manufacturer reserved bit. 0 indicates a TCG defined value. 1 indicates that + the index is controlled by the platform manufacturer. + + U is for the platform user. 0 indicates a TCG defined value. 1 indicates that the index is + controlled by the platform user. + + The TPM_NV_INDEX is a 32-bit value. + 3 2 1 + 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + |T|P|U|D| resvd | Purview | Index | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + + Where: + + 1. The TPM MAY return an error if the reserved area bits are not set to 0. + + 2. The TPM MUST accept all values for T, P, and U + + 3. D indicates defined. 1 indicates that the index is permanently defined and that any + TPM_NV_DefineSpace operation will fail after nvLocked is set TRUE. + + a. TCG reserved areas MAY have D set to 0 or 1 + + 4. Purview is the value used to indicate the platform specific area. This value is the + same as used for command ordinals. + + a. The TPM MUST reject purview values that the TPM cannot support. This means that an + index value for a PDA MUST be rejected by a TPM designed to work only on the PC Client. +*/ + +#define TPM_NV_INDEX_T_BIT 0x80000000 +#define TPM_NV_INDEX_P_BIT 0x40000000 +#define TPM_NV_INDEX_U_BIT 0x20000000 +#define TPM_NV_INDEX_D_BIT 0x10000000 +/* added kgold */ +#define TPM_NV_INDEX_RESVD 0x0f000000 +#define TPM_NV_INDEX_PURVIEW_BIT 16 +#define TPM_NV_INDEX_PURVIEW_MASK 0x00ff0000 + +/* 19.1.1 Required TPM_NV_INDEX values rev 97 + + The required index values must be found on each TPM regardless of platform. These areas are + always present and do not require a TPM_DefineSpace command to allocate. + + A platform specific specification may add additional required index values for the platform. + + The TPM MUST reserve the space as indicated for the required index values +*/ + +#define TPM_NV_INDEX_LOCK 0xFFFFFFFF /* This value turns on the NV authorization + protections. Once executed all NV areas use the + protections as defined. This value never resets. + + Attempting to execute TPM_NV_DefineSpace on this value + with non-zero size MAY result in a TPM_BADINDEX + response. + */ + +#define TPM_NV_INDEX0 0x00000000 /* This value allows for the setting of the bGlobalLock + flag, which is only reset on TPM_Startup(ST_Clear) + + Attempting to execute TPM_NV_WriteValue with a size other + than zero MAY result in the TPM_BADINDEX error code. + */ + +#define TPM_NV_INDEX_DIR 0x10000001 /* Size MUST be 20. This index points to the deprecated DIR + command area from 1.1. The TPM MUST map this reserved + space to be the area operated on by the 1.1 DIR commands. + */ + +/* 19.1.2 Reserved Index values rev 116 + + The reserved values are defined to avoid index collisions. These values are not in each and every + TPM. + + 1. The reserved index values are to avoid index value collisions. + 2. These index values require a TPM_DefineSpace to have the area for the index allocated + 3. A platform specific specification MAY indicate that reserved values are required. + 4. The reserved index values MAY have their D bit set by the TPM vendor to permanently +*/ + +#define TPM_NV_INDEX_TPM 0x0000Fxxx /* Reserved for TPM use */ +#define TPM_NV_INDEX_EKCert 0x1000F000 /* The Endorsement credential */ + +#define TPM_NV_INDEX_TPM_CC 0x0000F001 /* The TPM Conformance credential */ +#define TPM_NV_INDEX_PlatformCert 0x0000F002 /* The platform credential */ +#define TPM_NV_INDEX_Platform_CC 0x0000F003 /* The Platform conformance credential */ +#define TPM_NV_INDEX_TRIAL 0x0000F004 /* To try TPM_NV_DefineSpace without + actually allocating NV space */ + +#if 0 +#define TPM_NV_INDEX_PC 0x0001xxxx /* Reserved for PC Client use */ +#define TPM_NV_INDEX_GPIO_xx 0x000116xx /* Reserved for GPIO pins */ +#define TPM_NV_INDEX_PDA 0x0002xxxx /* Reserved for PDA use */ +#define TPM_NV_INDEX_MOBILE 0x0003xxxx /* Reserved for mobile use */ +#define TPM_NV_INDEX_SERVER 0x0004xxxx /* Reserved for Server use */ +#define TPM_NV_INDEX_PERIPHERAL 0x0005xxxx /* Reserved for peripheral use */ +#define TPM_NV_INDEX_TSS 0x0006xxxx /* Reserved for TSS use */ +#define TPM_NV_INDEX_GROUP_RESV 0x00xxxxxx /* Reserved for TCG WG use */ +#endif + +#define TPM_NV_INDEX_GPIO_00 0x00011600 /* GPIO-Express-00 */ + +#define TPM_NV_INDEX_GPIO_START 0x00011600 /* Reserved for GPIO pins */ +#define TPM_NV_INDEX_GPIO_END 0x000116ff /* Reserved for GPIO pins */ + +/* 19.2 TPM_NV_ATTRIBUTES rev 99 + + The attributes TPM_NV_PER_AUTHREAD and TPM_NV_PER_OWNERREAD cannot both be set to TRUE. + Similarly, the attributes TPM_NV_PER_AUTHWRITE and TPM_NV_PER_OWNERWRITE cannot both be set to + TRUE. +*/ + +#define TPM_NV_PER_READ_STCLEAR 0x80000000 /* 31: The value can be read until locked by a + read with a data size of 0. It can only be + unlocked by TPM_Startup(ST_Clear) or a + successful write. Lock held for each area in + bReadSTClear. */ +/* #define 30:19 Reserved */ +#define TPM_NV_PER_AUTHREAD 0x00040000 /* 18: The value requires authorization to read + */ +#define TPM_NV_PER_OWNERREAD 0x00020000 /* 17: The value requires TPM Owner authorization + to read. */ +#define TPM_NV_PER_PPREAD 0x00010000 /* 16: The value requires physical presence to + read */ +#define TPM_NV_PER_GLOBALLOCK 0x00008000 /* 15: The value is writable until a write to + index 0 is successful. The lock of this + attribute is reset by + TPM_Startup(ST_CLEAR). Lock held by SF -> + bGlobalLock */ +#define TPM_NV_PER_WRITE_STCLEAR 0x00004000 /* 14: The value is writable until a write to + the specified index with a datasize of 0 is + successful. The lock of this attribute is + reset by TPM_Startup(ST_CLEAR). Lock held for + each area in bWriteSTClear. */ +#define TPM_NV_PER_WRITEDEFINE 0x00002000 /* 13: Lock set by writing to the index with a + datasize of 0. Lock held for each area in + bWriteDefine. This is a persistent lock. */ +#define TPM_NV_PER_WRITEALL 0x00001000 /* 12: The value must be written in a single + operation */ +/* #define 11:3 Reserved for write additions */ +#define TPM_NV_PER_AUTHWRITE 0x00000004 /* 2: The value requires authorization to write + */ +#define TPM_NV_PER_OWNERWRITE 0x00000002 /* 1: The value requires TPM Owner authorization + to write */ +#define TPM_NV_PER_PPWRITE 0x00000001 /* 0: The value requires physical presence to + write */ + +/* 20.2.1 Owner Permission Settings rev 87 */ + +/* Per1 bits */ + +#define TPM_DELEGATE_PER1_MASK 0xffffffff /* mask of legal bits */ +#define TPM_DELEGATE_KeyControlOwner 31 +#define TPM_DELEGATE_SetOrdinalAuditStatus 30 +#define TPM_DELEGATE_DirWriteAuth 29 +#define TPM_DELEGATE_CMK_ApproveMA 28 +#define TPM_DELEGATE_NV_WriteValue 27 +#define TPM_DELEGATE_CMK_CreateTicket 26 +#define TPM_DELEGATE_NV_ReadValue 25 +#define TPM_DELEGATE_Delegate_LoadOwnerDelegation 24 +#define TPM_DELEGATE_DAA_Join 23 +#define TPM_DELEGATE_AuthorizeMigrationKey 22 +#define TPM_DELEGATE_CreateMaintenanceArchive 21 +#define TPM_DELEGATE_LoadMaintenanceArchive 20 +#define TPM_DELEGATE_KillMaintenanceFeature 19 +#define TPM_DELEGATE_OwnerReadInternalPub 18 +#define TPM_DELEGATE_ResetLockValue 17 +#define TPM_DELEGATE_OwnerClear 16 +#define TPM_DELEGATE_DisableOwnerClear 15 +#define TPM_DELEGATE_NV_DefineSpace 14 +#define TPM_DELEGATE_OwnerSetDisable 13 +#define TPM_DELEGATE_SetCapability 12 +#define TPM_DELEGATE_MakeIdentity 11 +#define TPM_DELEGATE_ActivateIdentity 10 +#define TPM_DELEGATE_OwnerReadPubek 9 +#define TPM_DELEGATE_DisablePubekRead 8 +#define TPM_DELEGATE_SetRedirection 7 +#define TPM_DELEGATE_FieldUpgrade 6 +#define TPM_DELEGATE_Delegate_UpdateVerification 5 +#define TPM_DELEGATE_CreateCounter 4 +#define TPM_DELEGATE_ReleaseCounterOwner 3 +#define TPM_DELEGATE_Delegate_Manage 2 +#define TPM_DELEGATE_Delegate_CreateOwnerDelegation 1 +#define TPM_DELEGATE_DAA_Sign 0 + +/* Per2 bits */ +#define TPM_DELEGATE_PER2_MASK 0x00000000 /* mask of legal bits */ +/* All reserved */ + +/* 20.2.3 Key Permission settings rev 85 */ + +/* Per1 bits */ + +#define TPM_KEY_DELEGATE_PER1_MASK 0x1fffffff /* mask of legal bits */ +#define TPM_KEY_DELEGATE_CMK_ConvertMigration 28 +#define TPM_KEY_DELEGATE_TickStampBlob 27 +#define TPM_KEY_DELEGATE_ChangeAuthAsymStart 26 +#define TPM_KEY_DELEGATE_ChangeAuthAsymFinish 25 +#define TPM_KEY_DELEGATE_CMK_CreateKey 24 +#define TPM_KEY_DELEGATE_MigrateKey 23 +#define TPM_KEY_DELEGATE_LoadKey2 22 +#define TPM_KEY_DELEGATE_EstablishTransport 21 +#define TPM_KEY_DELEGATE_ReleaseTransportSigned 20 +#define TPM_KEY_DELEGATE_Quote2 19 +#define TPM_KEY_DELEGATE_Sealx 18 +#define TPM_KEY_DELEGATE_MakeIdentity 17 +#define TPM_KEY_DELEGATE_ActivateIdentity 16 +#define TPM_KEY_DELEGATE_GetAuditDigestSigned 15 +#define TPM_KEY_DELEGATE_Sign 14 +#define TPM_KEY_DELEGATE_CertifyKey2 13 +#define TPM_KEY_DELEGATE_CertifyKey 12 +#define TPM_KEY_DELEGATE_CreateWrapKey 11 +#define TPM_KEY_DELEGATE_CMK_CreateBlob 10 +#define TPM_KEY_DELEGATE_CreateMigrationBlob 9 +#define TPM_KEY_DELEGATE_ConvertMigrationBlob 8 +#define TPM_KEY_DELEGATE_Delegate_CreateKeyDelegation 7 +#define TPM_KEY_DELEGATE_ChangeAuth 6 +#define TPM_KEY_DELEGATE_GetPubKey 5 +#define TPM_KEY_DELEGATE_UnBind 4 +#define TPM_KEY_DELEGATE_Quote 3 +#define TPM_KEY_DELEGATE_Unseal 2 +#define TPM_KEY_DELEGATE_Seal 1 +#define TPM_KEY_DELEGATE_LoadKey 0 + +/* Per2 bits */ +#define TPM_KEY_DELEGATE_PER2_MASK 0x00000000 /* mask of legal bits */ +/* All reserved */ + +/* 20.3 TPM_FAMILY_FLAGS rev 87 + + These flags indicate the operational state of the delegation and family table. These flags + are additions to TPM_PERMANENT_FLAGS and are not stand alone values. +*/ + +#define TPM_DELEGATE_ADMIN_LOCK 0x00000002 /* TRUE: Some TPM_Delegate_XXX commands are locked and + return TPM_DELEGATE_LOCK + + FALSE: TPM_Delegate_XXX commands are available + + Default is FALSE */ +#define TPM_FAMFLAG_ENABLED 0x00000001 /* When TRUE the table is enabled. The default value is + FALSE. */ + +/* 20.14 TPM_FAMILY_OPERATION Values rev 87 + + These are the opFlag values used by TPM_Delegate_Manage. +*/ + +#define TPM_FAMILY_CREATE 0x00000001 /* Create a new family */ +#define TPM_FAMILY_ENABLE 0x00000002 /* Set or reset the enable flag for this family. */ +#define TPM_FAMILY_ADMIN 0x00000003 /* Prevent administration of this family. */ +#define TPM_FAMILY_INVALIDATE 0x00000004 /* Invalidate a specific family row. */ + +/* 21.9 TPM_DA_STATE rev 100 + + TPM_DA_STATE enumerates the possible states of the dictionary attack mitigation logic. +*/ + +#define TPM_DA_STATE_INACTIVE 0x00 /* The dictionary attack mitigation logic is currently + inactive */ +#define TPM_DA_STATE_ACTIVE 0x01 /* The dictionary attack mitigation logic is + active. TPM_DA_ACTION_TYPE (21.10) is in progress. */ + +/* 21.10 TPM_DA_ACTION_TYPE rev 100 + */ + +/* 31-4 Reserved No information and MUST be FALSE */ + +#define TPM_DA_ACTION_FAILURE_MODE 0x00000008 /* bit 3: The TPM is in failure mode. */ +#define TPM_DA_ACTION_DEACTIVATE 0x00000004 /* bit 2: The TPM is in the deactivated state. */ +#define TPM_DA_ACTION_DISABLE 0x00000002 /* bit 1: The TPM is in the disabled state. */ +#define TPM_DA_ACTION_TIMEOUT 0x00000001 /* bit 0: The TPM will be in a locked state for + TPM_DA_INFO -> actionDependValue seconds. This + value is dynamic, depending on the time the + lock has been active. */ + +/* 22. DAA Structures rev 91 + + All byte and bit areas are byte arrays treated as large integers +*/ + +#define DAA_SIZE_r0 43 +#define DAA_SIZE_r1 43 +#define DAA_SIZE_r2 128 +#define DAA_SIZE_r3 168 +#define DAA_SIZE_r4 219 +#define DAA_SIZE_NT 20 +#define DAA_SIZE_v0 128 +#define DAA_SIZE_v1 192 +#define DAA_SIZE_NE 256 +#define DAA_SIZE_w 256 +#define DAA_SIZE_issuerModulus 256 + +/* check that DAA_SIZE_issuerModulus will fit in DAA_scratch */ +#if (DAA_SIZE_issuerModulus != 256) +#error "DAA_SIZE_issuerModulus must be 256" +#endif + +/* 22.2 Constant definitions rev 91 */ + +#define DAA_power0 104 +#define DAA_power1 1024 + +#endif diff --git a/libstb/tss2/ibmtss/tpmstructures12.h b/libstb/tss2/ibmtss/tpmstructures12.h new file mode 100644 index 0000000..bbf01db --- /dev/null +++ b/libstb/tss2/ibmtss/tpmstructures12.h @@ -0,0 +1,2482 @@ +/********************************************************************************/ +/* */ +/* TPM 1.2 Structures */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* */ +/* (c) Copyright IBM Corporation 2018. */ +/* */ +/* All rights reserved. */ +/* */ +/* Redistribution and use in source and binary forms, with or without */ +/* modification, are permitted provided that the following conditions are */ +/* met: */ +/* */ +/* Redistributions of source code must retain the above copyright notice, */ +/* this list of conditions and the following disclaimer. */ +/* */ +/* 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. */ +/* */ +/* Neither the names of the IBM Corporation nor the names of its */ +/* contributors may be used to endorse or promote products derived from */ +/* this software without specific prior written permission. */ +/* */ +/* 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 TPMSTRUCTURES12_H +#define TPMSTRUCTURES12_H + +#include <limits.h> +#include "tpmconstants12.h" +#include "tpmtypes12.h" + +/* Sanity check on build macros are centralized here, since any TPM will use this header */ + +#if !defined (TPM_POSIX) && !defined (TPM_WINDOWS) +#error "Must define either TPM_POSIX or TPM_WINDOWS" +#endif + +#define TPM_REVISION_MAX 9999 +#ifndef TPM_REVISION +#define TPM_REVISION TPM_REVISION_MAX +#endif + +/* 5.1 TPM_STRUCT_VER rev 100 + + This indicates the version of the structure or TPM. + + Version 1.2 deprecates the use of this structure in all other structures. The structure is not + deprecated as many of the structures that contain this structure are not deprecated. +*/ + +typedef struct tdTPM_STRUCT_VER { + BYTE major; /* This SHALL indicate the major version of the structure. MUST be 0x01 */ + BYTE minor; /* This SHALL indicate the minor version of the structure. MUST be 0x01 */ + BYTE revMajor; /* This MUST be 0x00 on output, ignored on input */ + BYTE revMinor; /* This MUST be 0x00 on output, ignored on input */ +} TPM_STRUCT_VER; + +/* 5.2 TPM_VERSION_BYTE rev 87 + + Allocating a byte for the version information is wasteful of space. The current allocation does + not provide sufficient resolution to indicate completely the version of the TPM. To allow for + backwards compatibility the size of the structure does not change from 1.1. + + To enable minor version, or revision, numbers with 2-digit resolution, the byte representing a + version splits into two BDC encoded nibbles. The ordering of the low and high order provides + backwards compatibility with existing numbering. + + An example of an implementation of this is; a version of 1.23 would have the value 2 in bit + positions 3-0 and the value 3 in bit positions 7-4. + + TPM_VERSION_BYTE is a byte. The byte is broken up according to the following rule + + 7-4 leastSigVer Least significant nibble of the minor version. MUST be values within the range of + 0000-1001 + 3-0 mostSigVer Most significant nibble of the minor version. MUST be values within the range of + 0000-1001 +*/ + +/* 5.3 TPM_VERSION rev 116 + + This structure provides information relative the version of the TPM. This structure should only + be in use by TPM_GetCapability to provide the information relative to the TPM. +*/ + +typedef struct tdTPM_VERSION { + TPM_VERSION_BYTE major; /* This SHALL indicate the major version of the TPM, mostSigVer MUST + be 0x1, leastSigVer MUST be 0x0 */ + TPM_VERSION_BYTE minor; /* This SHALL indicate the minor version of the TPM, mostSigVer MUST + be 0x1 or 0x2, leastSigVer MUST be 0x0 */ + BYTE revMajor; /* This SHALL be the value of the TPM_PERMANENT_DATA -> revMajor */ + BYTE revMinor; /* This SHALL be the value of the TPM_PERMANENT_DATA -> revMinor */ +} TPM_VERSION; + +/* 5.4 TPM_DIGEST rev 111 + + The digest value reports the result of a hash operation. + + In version 1 the hash algorithm is SHA-1 with a resulting hash result being 20 bytes or 160 bits. + + It is understood that algorithm agility is lost due to fixing the hash at 20 bytes and on + SHA-1. The reason for fixing is due to the internal use of the digest. It is the authorization + values, it provides the secrets for the HMAC and the size of 20 bytes determines the values that + can be stored and encrypted. For this reason, the size is fixed and any changes to this value + require a new version of the specification. + + The digestSize parameter MUST indicate the block size of the algorithm and MUST be 20 or greater. + + For all TPM v1 hash operations, the hash algorithm MUST be SHA-1 and the digestSize parameter is + therefore equal to 20. +*/ + +#define TPM_DIGEST_SIZE 20 +typedef BYTE TPM_DIGEST[TPM_DIGEST_SIZE]; + +/* Redefinitions */ + +typedef TPM_DIGEST TPM_CHOSENID_HASH; /* This SHALL be the digest of the chosen identityLabel and + privacyCA for a new TPM identity.*/ + +typedef TPM_DIGEST TPM_COMPOSITE_HASH; /* This SHALL be the hash of a list of PCR indexes and PCR + values that a key or data is bound to. */ + +typedef TPM_DIGEST TPM_DIRVALUE; /* This SHALL be the value of a DIR register */ + +typedef TPM_DIGEST TPM_HMAC; /* This shall be the output of the HMAC algorithm */ + +typedef TPM_DIGEST TPM_PCRVALUE; /* The value inside of the PCR */ + +typedef TPM_DIGEST TPM_AUDITDIGEST; /* This SHALL be the value of the current internal audit + state */ + +/* 5.5 TPM_NONCE rev 99 + + A nonce is a random value that provides protection from replay and other attacks. Many of the + commands and protocols in the specification require a nonce. This structure provides a consistent + view of what a nonce is. +*/ + +#define TPM_NONCE_SIZE 20 +typedef BYTE TPM_NONCE[TPM_NONCE_SIZE]; + +typedef TPM_NONCE TPM_DAA_TPM_SEED; /* This SHALL be a random value generated by a TPM + immediately after the EK is installed in that TPM, + whenever an EK is installed in that TPM */ +typedef TPM_NONCE TPM_DAA_CONTEXT_SEED; /* This SHALL be a random value */ + +/* 5.6 TPM_AUTHDATA rev 87 + + The authorization data is the information that is saved or passed to provide proof of ownership + of an entity. For version 1 this area is always 20 bytes. +*/ + +#define TPM_AUTHDATA_SIZE 20 +typedef BYTE TPM_AUTHDATA[TPM_AUTHDATA_SIZE]; + +#define TPM_SECRET_SIZE 20 +typedef BYTE TPM_SECRET[TPM_SECRET_SIZE]; + +typedef TPM_AUTHDATA TPM_ENCAUTH; /* A cipher text (encrypted) version of authorization data. The + encryption mechanism depends on the context. */ + +#if 0 /* FIXME */ +/* 5.11 TPM_CHANGEAUTH_VALIDATE rev 87 + + This structure provides an area that will stores the new authorization data and the challenger's + nonce. +*/ + +typedef struct tdTPM_CHANGEAUTH_VALIDATE { + TPM_SECRET newAuthSecret; /* This SHALL be the new authorization data for the target entity */ + TPM_NONCE n1; /* This SHOULD be a nonce, to enable the caller to verify that the + target TPM is on-line. */ +} TPM_CHANGEAUTH_VALIDATE; + +#endif + + +/* PCR */ + +/* NOTE: The TPM requires and the code assumes a multiple of CHAR_BIT (8). 48 registers (6 bytes) + may be a bad number, as it makes TPM_PCR_INFO and TPM_PCR_INFO_LONG indistinguishable in the + first two bytes. */ + +#define TPM_NUM_PCR 24 /* Use PC Client specification values */ + +#if (CHAR_BIT != 8) +#error "CHAR_BIT must be 8" +#endif + +#if ((TPM_NUM_PCR % 8) != 0) +#error "TPM_NUM_PCR must be a multiple of 8" +#endif + +#define TPM_DEBUG_PCR 16 + +/* 8.1 TPM_PCR_SELECTION rev 110 + + This structure provides a standard method of specifying a list of PCR registers. +*/ + +typedef struct tdTPM_PCR_SELECTION { + uint16_t sizeOfSelect; /* The size in bytes of the pcrSelect structure */ + BYTE pcrSelect[TPM_NUM_PCR/CHAR_BIT]; /* This SHALL be a bit map that indicates if a PCR + is active or not */ +} TPM_PCR_SELECTION; + +#if 0 +/* 8.2 TPM_PCR_COMPOSITE rev 97 + + The composite structure provides the index and value of the PCR register to be used when creating + the value that SEALS an entity to the composite. +*/ + +typedef struct tdTPM_PCR_COMPOSITE { + TPM_PCR_SELECTION select; /* This SHALL be the indication of which PCR values are active */ +#if 0 + uint32_t valueSize; /* This SHALL be the size of the pcrValue field (not the number of + PCR's) */ + TPM_PCRVALUE *pcrValue; /* This SHALL be an array of TPM_PCRVALUE structures. The values + come in the order specified by the select parameter and are + concatenated into a single blob */ +#endif + TPM_SIZED_BUFFER pcrValue; +} TPM_PCR_COMPOSITE; + +/* 8.3 TPM_PCR_INFO rev 87 + + The TPM_PCR_INFO structure contains the information related to the wrapping of a key or the + sealing of data, to a set of PCRs. +*/ + +typedef struct tdTPM_PCR_INFO { + TPM_PCR_SELECTION pcrSelection; /* This SHALL be the selection of PCRs to which the + data or key is bound. */ + TPM_COMPOSITE_HASH digestAtRelease; /* This SHALL be the digest of the PCR indices and + PCR values to verify when revealing Sealed Data + or using a key that was wrapped to PCRs. NOTE: + This is passed in by the host, and used as + authorization to use the key */ + TPM_COMPOSITE_HASH digestAtCreation; /* This SHALL be the composite digest value of the + PCR values, at the time when the sealing is + performed. NOTE: This is generated at key + creation, but is just informative to the host, + not used for authorization */ +} TPM_PCR_INFO; + +#endif + +/* 8.6 TPM_LOCALITY_SELECTION rev 87 + + When used with localityAtCreation only one bit is set and it corresponds to the locality of the + command creating the structure. + + When used with localityAtRelease the bits indicate which localities CAN perform the release. +*/ + +typedef BYTE TPM_LOCALITY_SELECTION; + +#define TPM_LOC_FOUR 0x10 /* Locality 4 */ +#define TPM_LOC_THREE 0x08 /* Locality 3 */ +#define TPM_LOC_TWO 0x04 /* Locality 2 */ +#define TPM_LOC_ONE 0x02 /* Locality 1 */ +#define TPM_LOC_ZERO 0x01 /* Locality 0. This is the same as the legacy interface. */ + +#define TPM_LOC_ALL 0x1f /* kgold - added all localities */ +#define TPM_LOC_MAX 4 /* kgold - maximum value for TPM_MODIFIER_INDICATOR */ + +/* 8.4 TPM_PCR_INFO_LONG rev 109 + + The TPM_PCR_INFO structure contains the information related to the wrapping of a key or the + sealing of data, to a set of PCRs. + + The LONG version includes information necessary to properly define the configuration that creates + the blob using the PCR selection. +*/ + +/* Marshaled TPM_PCR_INFO_LONG */ + +typedef struct tdTPM_PCR_INFO_LONG { + TPM_STRUCTURE_TAG tag; /* This SHALL be TPM_TAG_PCR_INFO_LONG */ + TPM_LOCALITY_SELECTION localityAtCreation; /* This SHALL be the locality modifier of the + function that creates the PCR info structure */ + TPM_LOCALITY_SELECTION localityAtRelease; /* This SHALL be the locality modifier required to + reveal Sealed Data or use a key that was wrapped + to PCRs */ + TPM_PCR_SELECTION creationPCRSelection; /* This SHALL be the selection of PCRs active when + the blob is created */ + TPM_PCR_SELECTION releasePCRSelection; /* This SHALL be the selection of PCRs to which the + data or key is bound. */ + TPM_COMPOSITE_HASH digestAtCreation; /* This SHALL be the composite digest value of the + PCR values, at the time when the sealing is + performed. */ + TPM_COMPOSITE_HASH digestAtRelease; /* This SHALL be the digest of the PCR indices and + PCR values to verify when revealing Sealed Data + or using a key that was wrapped to PCRs. */ +} TPM_PCR_INFO_LONG; + +#if 0 +typedef struct { + UINT32 PCRInfoSize; + TPM_PCR_INFO_LONG PCRInfo; +} TPM4B_TPM_PCR_INFO_LONG; + +#endif + +/* 8.5 TPM_PCR_INFO_SHORT rev 87 + + This structure is for defining a digest at release when the only information that is necessary is + the release configuration. +*/ + +typedef struct tdTPM_PCR_INFO_SHORT { + TPM_PCR_SELECTION pcrSelection; /* This SHALL be the selection of PCRs that specifies the + digestAtRelease */ + TPM_LOCALITY_SELECTION localityAtRelease; /* This SHALL be the locality modifier required to + release the information. This value must not be + zero (0). */ + TPM_COMPOSITE_HASH digestAtRelease; /* This SHALL be the digest of the PCR indices and + PCR values to verify when revealing auth data */ +} TPM_PCR_INFO_SHORT; + +#if 0 +/* 8.8 TPM_PCR_ATTRIBUTES rev 107 + + These attributes are available on a per PCR basis. + + The TPM is not required to maintain this structure internally to the TPM. + + When a challenger evaluates a PCR an understanding of this structure is vital to the proper + understanding of the platform configuration. As this structure is static for all platforms of the + same type the structure does not need to be reported with each quote. +*/ + +typedef struct tdTPM_PCR_ATTRIBUTES { + TPM_BOOL pcrReset; /* A value of TRUE SHALL indicate that the PCR register can be reset + using the TPM_PCR_RESET command. */ + TPM_LOCALITY_SELECTION pcrExtendLocal; /* An indication of which localities can perform + extends on the PCR. */ + TPM_LOCALITY_SELECTION pcrResetLocal; /* An indication of which localities can reset the + PCR */ +} TPM_PCR_ATTRIBUTES; + +/* + 9. Storage Structures +*/ + +/* 9.1 TPM_STORED_DATA rev 87 + + The definition of this structure is necessary to ensure the enforcement of security properties. + + This structure is in use by the TPM_Seal and TPM_Unseal commands to identify the PCR index and + values that must be present to properly unseal the data. + + This structure only provides 1.1 data store and uses PCR_INFO + + 1. This structure is created during the TPM_Seal process. The confidential data is encrypted + using a nonmigratable key. When the TPM_Unseal decrypts this structure the TPM_Unseal uses the + public information in the structure to validate the current configuration and release the + decrypted data + + 2. When sealInfoSize is not 0 sealInfo MUST be TPM_PCR_INFO +*/ + +typedef struct tdTPM_STORED_DATA { + TPM_STRUCT_VER ver; /* This MUST be 1.1.0.0 */ + TPM_SIZED_BUFFER sealInfo; +#if 0 + uint32_t sealInfoSize; /* Size of the sealInfo parameter */ + BYTE* sealInfo; /* This SHALL be a structure of type TPM_PCR_INFO or a 0 length + array if the data is not bound to PCRs. */ +#endif + TPM_SIZED_BUFFER encData; +#if 0 + uint32_t encDataSize; /* This SHALL be the size of the encData parameter */ + BYTE* encData; /* This shall be an encrypted TPM_SEALED_DATA structure containing + the confidential part of the data. */ +#endif + /* NOTE: kgold - Added this structure, a cache of PCRInfo when not NULL */ + TPM_PCR_INFO *tpm_seal_info; +} TPM_STORED_DATA; + + +/* 9.2 TPM_STORED_DATA12 rev 101 + + The definition of this structure is necessary to ensure the enforcement of security properties. + This structure is in use by the TPM_Seal and TPM_Unseal commands to identify the PCR index and + values that must be present to properly unseal the data. + + 1. This structure is created during the TPM_Seal process. The confidential data is encrypted + using a nonmigratable key. When the TPM_Unseal decrypts this structure the TPM_Unseal uses the + public information in the structure to validate the current configuration and release the + decrypted data. + + 2. If sealInfoSize is not 0 then sealInfo MUST be TPM_PCR_INFO_LONG +*/ + +typedef struct tdTPM_STORED_DATA12 { + TPM_STRUCTURE_TAG tag; /* This SHALL be TPM_TAG_STORED_DATA12 */ + TPM_ENTITY_TYPE et; /* The type of blob */ + TPM_SIZED_BUFFER sealInfo; +#if 0 + uint32_t sealInfoSize; /* Size of the sealInfo parameter */ + BYTE* sealInfo; /* This SHALL be a structure of type TPM_PCR_INFO_LONG or a 0 length + array if the data is not bound to PCRs. */ +#endif + TPM_SIZED_BUFFER encData; +#if 0 + uint32_t encDataSize; /* This SHALL be the size of the encData parameter */ + BYTE* encData; /* This shall be an encrypted TPM_SEALED_DATA structure containing + the confidential part of the data. */ +#endif + /* NOTE: kgold - Added this structure, a cache of PCRInfo when not NULL */ + TPM_PCR_INFO_LONG *tpm_seal_info_long; +} TPM_STORED_DATA12; + +/* 9.3 TPM_SEALED_DATA rev 87 + + This structure contains confidential information related to sealed data, including the data + itself. + + 1. To tie the TPM_STORED_DATA structure to the TPM_SEALED_DATA structure this structure contains + a digest of the containing TPM_STORED_DATA structure. + + 2. The digest calculation does not include the encDataSize and encData parameters. +*/ + +typedef struct tdTPM_SEALED_DATA { + TPM_PAYLOAD_TYPE payload; /* This SHALL indicate the payload type of TPM_PT_SEAL */ + TPM_SECRET authData; /* This SHALL be the authorization data for this value */ + TPM_SECRET tpmProof; /* This SHALL be a copy of TPM_PERMANENT_FLAGS -> tpmProof */ + TPM_DIGEST storedDigest; /* This SHALL be a digest of the TPM_STORED_DATA structure, + excluding the fields TPM_STORED_DATA -> encDataSize and + TPM_STORED_DATA -> encData. */ + TPM_SIZED_BUFFER data; /* This SHALL be the data to be sealed */ +#if 0 + uint32_t dataSize; /* This SHALL be the size of the data parameter */ + BYTE* data; /* This SHALL be the data to be sealed */ +#endif +} TPM_SEALED_DATA; + +#endif + + +/* 9.4 TPM_SYMMETRIC_KEY rev 87 + + This structure describes a symmetric key, used during the process "Collating a Request for a + Trusted Platform Module Identity". +*/ + +typedef struct tdTPM_SYMMETRIC_KEY { + TPM_ALGORITHM_ID algId; /* This SHALL be the algorithm identifier of the symmetric key. */ + TPM_ENC_SCHEME encScheme; /* This SHALL fully identify the manner in which the key will be + used for encryption operations. */ + uint16_t size; /* This SHALL be the size of the data parameter in bytes */ + BYTE data[MAX_SYM_KEY_BYTES]; /* This SHALL be the symmetric key data */ +} TPM_SYMMETRIC_KEY; + +#if 0 + +/* 9.5 TPM_BOUND_DATA rev 87 + + This structure is defined because it is used by a TPM_UnBind command in a consistency check. + + The intent of TCG is to promote "best practice" heuristics for the use of keys: a signing key + shouldn't be used for storage, and so on. These heuristics are used because of the potential + threats that arise when the same key is used in different ways. The heuristics minimize the + number of ways in which a given key can be used. + + One such heuristic is that a key of type TPM_KEY_BIND, and no other type of key, should always be + used to create the blob that is unwrapped by TPM_UnBind. Binding is not a TPM function, so the + only choice is to perform a check for the correct payload type when a blob is unwrapped by a key + of type TPM_KEY_BIND. This requires the blob to have internal structure. + + Even though payloadData has variable size, TPM_BOUND_DATA deliberately does not include the size + of payloadData. This is to maximise the size of payloadData that can be encrypted when + TPM_BOUND_DATA is encrypted in a single block. When using TPM-UnBind to obtain payloadData, the + size of payloadData is deduced as a natural result of the (RSA) decryption process. + + 1. This structure MUST be used for creating data when (wrapping with a key of type TPM_KEY_BIND) + or (wrapping using the encryption algorithm TPM_ES_RSAESOAEP_SHA1_MGF1). If it is not, the + TPM_UnBind command will fail. +*/ + +typedef struct tdTPM_BOUND_DATA { + TPM_STRUCT_VER ver; /* This MUST be 1.1.0.0 */ + TPM_PAYLOAD_TYPE payload; /* This SHALL be the value TPM_PT_BIND */ + uint32_t payloadDataSize; /* NOTE: added, not part of serialization */ + BYTE *payloadData; /* The bound data */ +} TPM_BOUND_DATA; + +#endif + +/* + 10. TPM_KEY Complex +*/ + +/* 10.1.1 TPM_RSA_KEY_PARMS rev 87 + + This structure describes the parameters of an RSA key. +*/ + +typedef struct tdTPM_RSA_KEY_PARMS { + uint32_t keyLength; /* This specifies the size of the RSA key in bits */ + uint32_t numPrimes; /* This specifies the number of prime factors used by this RSA key. */ + uint32_t exponentSize; /* This SHALL be the size of the exponent. If the key is using the + the default public exponent then the exponentSize MUST be 0. */ + uint8_t exponent[4]; /* The public exponent of this key */ +} TPM_RSA_KEY_PARMS; + +/* 10.1.2 TPM_SYMMETRIC_KEY_PARMS rev 87 + + This structure describes the parameters for symmetric algorithms +*/ + +typedef struct tdTPM_SYMMETRIC_KEY_PARMS { + uint32_t keyLength; /* This SHALL indicate the length of the key in bits */ + uint32_t blockSize; /* This SHALL indicate the block size of the algorithm*/ + TPM2B_IV iv; /* The initialization vector */ +} TPM_SYMMETRIC_KEY_PARMS; + +/* 10.1 TPM_KEY_PARMS rev 87 + + This provides a standard mechanism to define the parameters used to generate a key pair, and to + store the parts of a key shared between the public and private key parts. +*/ + +typedef union { + TPM_RSA_KEY_PARMS rsaParms; + TPM_SYMMETRIC_KEY_PARMS symParms; +} TPMU_PARMS; + +/* Marshaled TPMU_PARMS */ + +#if 0 +typedef struct { + UINT32 parmSize; + TPMU_PARMS parms; +} TPM4B_PARMS; +#endif + +typedef struct { + TPM_ALGORITHM_ID algorithmID; /* This SHALL be the key algorithm in use */ + TPM_ENC_SCHEME encScheme; /* This SHALL be the encryption scheme that the key uses to encrypt + information */ + TPM_SIG_SCHEME sigScheme; /* This SHALL be the signature scheme that the key uses to perform + digital signatures */ + TPMU_PARMS parms; +} TPM_KEY_PARMS; + +#if 0 + +/* 10.7 TPM_STORE_PRIVKEY rev 87 + + This structure can be used in conjunction with a corresponding TPM_PUBKEY to construct a private + key which can be unambiguously used. +*/ + +#if 0 +typedef struct tdTPM_STORE_PRIVKEY { + uint32_t keyLength; /* This SHALL be the length of the key field. */ + BYTE* key; /* This SHALL be a structure interpreted according to the algorithm Id in + the corresponding TPM_KEY structure. */ +} TPM_STORE_PRIVKEY; +#endif + +/* NOTE: Hard coded for RSA keys. This will change if other algorithms are supported */ + +typedef struct tdTPM_STORE_PRIVKEY { + TPM_SIZED_BUFFER d_key; /* private key */ + TPM_SIZED_BUFFER p_key; /* private prime factor */ + TPM_SIZED_BUFFER q_key; /* private prime factor */ +} TPM_STORE_PRIVKEY; + +/* 10.6 TPM_STORE_ASYMKEY rev 87 + + The TPM_STORE_ASYMKEY structure provides the area to identify the confidential information + related to a key. This will include the private key factors for an asymmetric key. + + The structure is designed so that encryption of a TPM_STORE_ASYMKEY structure containing a 2048 + bit RSA key can be done in one operation if the encrypting key is 2048 bits. + + Using typical RSA notation the structure would include P, and when loading the key include the + unencrypted P*Q which would be used to recover the Q value. + + To accommodate the future use of multiple prime RSA keys the specification of additional prime + factors is an optional capability. + + This structure provides the basis of defining the protection of the private key. Changes in this + structure MUST be reflected in the TPM_MIGRATE_ASYMKEY structure (section 10.8). +*/ + +typedef struct tdTPM_STORE_ASYMKEY { + TPM_PAYLOAD_TYPE payload; /* This SHALL set to TPM_PT_ASYM to indicate an asymmetric + key. If used in TPM_CMK_ConvertMigration the value SHALL + be TPM_PT_MIGRATE_EXTERNAL. If used in TPM_CMK_CreateKey + the value SHALL be TPM_PT_MIGRATE_RESTRICTED */ + TPM_SECRET usageAuth; /* This SHALL be the authorization data necessary to + authorize the use of this value */ + TPM_SECRET migrationAuth; /* This SHALL be the migration authorization data for a + migratable key, or the TPM secret value tpmProof for a + non-migratable key created by the TPM. + + If the TPM sets this parameter to the value tpmProof, + then the TPM_KEY.keyFlags.migratable of the corresponding + TPM_KEY structure MUST be set to 0. + + If this parameter is set to the migration authorization + data for the key in parameter PrivKey, then the + TPM_KEY.keyFlags.migratable of the corresponding TPM_KEY + structure SHOULD be set to 1. */ + TPM_DIGEST pubDataDigest; /* This SHALL be the digest of the corresponding TPM_KEY + structure, excluding the fields TPM_KEY.encSize and + TPM_KEY.encData. + + When TPM_KEY -> pcrInfoSize is 0 then the digest + calculation has no input from the pcrInfo field. The + pcrInfoSize field MUST always be part of the digest + calculation. + */ + TPM_STORE_PRIVKEY privKey; /* This SHALL be the private key data. The privKey can be a + variable length which allows for differences in the key + format. The maximum size of the area would be 151 + bytes. */ +} TPM_STORE_ASYMKEY; + +/* 10.8 TPM_MIGRATE_ASYMKEY rev 87 + + The TPM_MIGRATE_ASYMKEY structure provides the area to identify the private key factors of a + asymmetric key while the key is migrating between TPM's. + + This structure provides the basis of defining the protection of the private key. + + k1k2 - 132 privkey.key (128 + 4) + k1 - 20, OAEP seed + k2 - 112, partPrivKey + TPM_STORE_PRIVKEY 4 partPrivKey.keyLength + 108 partPrivKey.key (128 - 20) +*/ + +typedef struct tdTPM_MIGRATE_ASYMKEY { + TPM_PAYLOAD_TYPE payload; /* This SHALL set to TPM_PT_MIGRATE or TPM_PT_CMK_MIGRATE to + indicate an migrating asymmetric key or TPM_PT_MAINT to indicate + a maintenance key. */ + TPM_SECRET usageAuth; /* This SHALL be a copy of the usageAuth from the TPM_STORE_ASYMKEY + structure. */ + TPM_DIGEST pubDataDigest; /* This SHALL be a copy of the pubDataDigest from the + TPM_STORE_ASYMKEY structure. */ +#if 0 + uint32_t partPrivKeyLen; /* This SHALL be the size of the partPrivKey field */ + BYTE *partPrivKey; /* This SHALL be the k2 area as described in TPM_CreateMigrationBlob + */ +#endif + TPM_SIZED_BUFFER partPrivKey; +} TPM_MIGRATE_ASYMKEY; + +#endif + +/* 10.4 TPM_STORE_PUBKEY + + This structure can be used in conjunction with a corresponding TPM_KEY_PARMS to 1382 construct a + public key which can be unambiguously used. +*/ + +typedef struct tdTPM_STORE_PUBKEY { + UINT32 keyLength; /* This SHALL be the length of the key field. */ + BYTE key[MAX_RSA_KEY_BYTES]; /* This SHALL be a structure interpreted according to the + algorithm Id in the corresponding TPM_KEY_PARMS + structure. */ +} TPM_STORE_PUBKEY; + +/* 10.3 TPM_KEY12 rev 87 + + This provides the same functionality as TPM_KEY but uses the new PCR_INFO_LONG structures and the + new structure tagging. In all other aspects this is the same structure. +*/ + +typedef struct tdTPM_KEY12 { + TPM_STRUCTURE_TAG tag; /* MUST be TPM_TAG_KEY12 */ + uint16_t fill; /* MUST be 0x0000 */ + TPM_KEY_USAGE keyUsage; /* This SHALL be the TPM key usage that determines the operations + permitted with this key */ + TPM_KEY_FLAGS keyFlags; /* This SHALL be the indication of migration, redirection etc. */ + TPM_AUTH_DATA_USAGE authDataUsage; /* This SHALL Indicate the conditions where it is required + that authorization be presented. */ + TPM_KEY_PARMS algorithmParms; /* This SHALL be the information regarding the algorithm for + this key */ + TPM_PCR_INFO_LONG PCRInfo; + TPM_STORE_PUBKEY pubKey; /* This SHALL be the public portion of the key */ + TPM_STORE_PUBKEY encData; /* This SHALL be an encrypted TPM_STORE_ASYMKEY structure + TPM_MIGRATE_ASYMKEY structure */ +} TPM_KEY12; + +/* 10.5 TPM_PUBKEY rev 99 + + The TPM_PUBKEY structure contains the public portion of an asymmetric key pair. It contains all + the information necessary for its unambiguous usage. It is possible to construct this structure + from a TPM_KEY, using the algorithmParms and pubKey fields. + + The pubKey member of this structure shall contain the public key for a specific algorithm. +*/ + +typedef struct tdTPM_PUBKEY { + TPM_KEY_PARMS algorithmParms; /* This SHALL be the information regarding this key */ + TPM_STORE_PUBKEY pubKey; /* This SHALL be the public key information */ +} TPM_PUBKEY; + +#if 0 + +/* 5.b. The TPM must support a minimum of 2 key slots. */ + +#define TPM_KEY_HANDLES 16 /* entries in global TPM_KEY_HANDLE_ENTRY array */ + +/* TPM_GetCapability uses a uint_16 for the number of key slots */ + +#if (TPM_KEY_HANDLES > 0xffff) +#error "TPM_KEY_HANDLES must be less than 0x10000" +#endif + +/* The TPM does not have to support any minumum number of owner evict keys. Adjust this value to + match the amount of NV space available. An owner evict key consumes about 512 bytes. + + A value greater than (TPM_KEY_HANDLES - 2) is useless, as the TPM reserves 2 key slots for + non-owner evict keys to avoid blocking. +*/ + +#define TPM_OWNER_EVICT_KEY_HANDLES 2 +#if (TPM_OWNER_EVICT_KEY_HANDLES > (TPM_KEY_HANDLES - 2)) +#error "TPM_OWNER_EVICT_KEY_HANDLES too large for TPM_KEY_HANDLES" +#endif + +/* This is the version used by the TPM implementation. It is part of the global TPM state */ + +/* kgold: Added TPM_KEY member. There needs to be a mapping between a key handle + and the pointer to TPM_KEY objects, and this seems to be the right place for it. */ + +typedef struct tdTPM_KEY_HANDLE_ENTRY { + TPM_KEY_HANDLE handle; /* Handles for a key currently loaded in the TPM */ + TPM_KEY *key; /* Pointer to the key object */ + TPM_BOOL parentPCRStatus; /* TRUE if parent of this key uses PCR's */ + TPM_KEY_CONTROL keyControl; /* Attributes that can control various aspects of key usage and + manipulation. */ +} TPM_KEY_HANDLE_ENTRY; + +/* 5.12 TPM_MIGRATIONKEYAUTH rev 87 + + This structure provides the proof that the associated public key has TPM Owner authorization to + be a migration key. +*/ + +typedef struct tdTPM_MIGRATIONKEYAUTH { + TPM_PUBKEY migrationKey; /* This SHALL be the public key of the migration facility */ + TPM_MIGRATE_SCHEME migrationScheme; /* This shall be the type of migration operation.*/ + TPM_DIGEST digest; /* This SHALL be the digest value of the concatenation of + migration key, migration scheme and tpmProof */ +} TPM_MIGRATIONKEYAUTH; + +/* 5.13 TPM_COUNTER_VALUE rev 87 + + This structure returns the counter value. For interoperability, the value size should be 4 bytes. +*/ + +#define TPM_COUNTER_LABEL_SIZE 4 +#define TPM_COUNT_ID_NULL 0xffffffff /* unused value TPM_CAP_PROP_ACTIVE_COUNTER expects this + value if no counter is active */ +#define TPM_COUNT_ID_ILLEGAL 0xfffffffe /* after releasing an active counter */ + +typedef struct tdTPM_COUNTER_VALUE { +#ifdef TPM_USE_TAG_IN_STRUCTURE + TPM_STRUCTURE_TAG tag; /* TPM_TAG_COUNTER_VALUE */ +#endif + BYTE label[TPM_COUNTER_LABEL_SIZE]; /* The label for the counter */ + TPM_ACTUAL_COUNT counter; /* The 32-bit counter value. */ + /* NOTE: Added. TPMWG email says the specification structure is the public part, but these are + vendor specific private members. */ + TPM_SECRET authData; /* Authorization secret for counter */ + TPM_BOOL valid; + TPM_DIGEST digest; /* for OSAP comparison */ +} TPM_COUNTER_VALUE; + +/* 5.14 TPM_SIGN_INFO Structure rev 102 + + This is an addition in 1.2 and is the structure signed for certain commands (e.g., + TPM_ReleaseTransportSigned). Some commands have a structure specific to that command (e.g., + TPM_Quote uses TPM_QUOTE_INFO) and do not use TPM_SIGN_INFO. + + TPM_Sign uses this structure when the signature scheme is TPM_SS_RSASSAPKCS1v15_INFO. +*/ + +#define TPM_SIGN_INFO_FIXED_SIZE 4 + +typedef struct tdTPM_SIGN_INFO { +#ifdef TPM_USE_TAG_IN_STRUCTURE + TPM_STRUCTURE_TAG tag; /* TPM_TAG_SIGNINFO */ +#endif + BYTE fixed[TPM_SIGN_INFO_FIXED_SIZE]; /* The ASCII text that identifies what function was + performing the signing operation*/ + TPM_NONCE replay; /* Nonce provided by caller to prevent replay attacks */ +#if 0 + uint32_t dataLen; /* The length of the data area */ + BYTE* data; /* The data that is being signed */ +#endif + TPM_SIZED_BUFFER data; /* The data that is being signed */ +} TPM_SIGN_INFO; + +/* 5.15 TPM_MSA_COMPOSITE Structure rev 87 + + TPM_MSA_COMPOSITE contains an arbitrary number of digests of public keys belonging to Migration + Authorities. An instance of TPM_MSA_COMPOSITE is incorporated into the migrationAuth value of a + certified-migration-key (CMK), and any of the Migration Authorities specified in that instance is + able to approve the migration of that certified-migration-key. + + TPMs MUST support TPM_MSA_COMPOSITE structures with MSAlist of four (4) or less, and MAY support + larger values of MSAlist. +*/ + +typedef struct tdTPM_MSA_COMPOSITE { + uint32_t MSAlist; /* The number of migAuthDigests. MSAlist MUST be one (1) or + greater. */ + TPM_DIGEST *migAuthDigest; /* An arbitrary number of digests of public keys belonging + to Migration Authorities. */ +} TPM_MSA_COMPOSITE; + +/* 5.16 TPM_CMK_AUTH + + The signed digest of TPM_CMK_AUTH is a ticket to prove that the entity with public key + "migrationAuthority" has approved the public key "destination Key" as a migration destination for + the key with public key "sourceKey". + + Normally the digest of TPM_CMK_AUTH is signed by the private key corresponding to + "migrationAuthority". + + To reduce data size, TPM_CMK_AUTH contains just the digests of "migrationAuthority", + "destinationKey" and "sourceKey". +*/ + +typedef struct tdTPM_CMK_AUTH { + TPM_DIGEST migrationAuthorityDigest; /* The digest of the public key of a Migration + Authority */ + TPM_DIGEST destinationKeyDigest; /* The digest of a TPM_PUBKEY structure that is an + approved destination key for the private key + associated with "sourceKey"*/ + TPM_DIGEST sourceKeyDigest; /* The digest of a TPM_PUBKEY structure whose + corresponding private key is approved by the + Migration Authority to be migrated as a child to + the destinationKey. */ +} TPM_CMK_AUTH; + +#endif + +/* 5.18 TPM_SELECT_SIZE rev 87 + + This structure provides the indication for the version and sizeOfSelect structure in GetCapability +*/ + +typedef struct tdTPM_SELECT_SIZE { + BYTE major; /* This SHALL indicate the major version of the TPM. This MUST be 0x01 */ + BYTE minor; /* This SHALL indicate the minor version of the TPM. This MAY be 0x01 or + 0x02 */ + uint16_t reqSize; /* This SHALL indicate the value for a sizeOfSelect field in the + TPM_SELECTION structure */ +} TPM_SELECT_SIZE; + +#if 0 + +/* 5.19 TPM_CMK_MIGAUTH rev 89 + + Structure to keep track of the CMK migration authorization +*/ + +typedef struct tdTPM_CMK_MIGAUTH { +#ifdef TPM_USE_TAG_IN_STRUCTURE + TPM_STRUCTURE_TAG tag; /* Set to TPM_TAG_CMK_MIGAUTH */ +#endif + TPM_DIGEST msaDigest; /* The digest of a TPM_MSA_COMPOSITE structure containing the + migration authority public key and parameters. */ + TPM_DIGEST pubKeyDigest; /* The hash of the associated public key */ +} TPM_CMK_MIGAUTH; + +/* 5.20 TPM_CMK_SIGTICKET rev 87 + + Structure to keep track of the CMK migration authorization +*/ + +typedef struct tdTPM_CMK_SIGTICKET { +#ifdef TPM_USE_TAG_IN_STRUCTURE + TPM_STRUCTURE_TAG tag; /* Set to TPM_TAG_CMK_SIGTICKET */ +#endif + TPM_DIGEST verKeyDigest; /* The hash of a TPM_PUBKEY structure containing the public key and + parameters of the key that can verify the ticket */ + TPM_DIGEST signedData; /* The ticket data */ +} TPM_CMK_SIGTICKET; + +/* 5.21 TPM_CMK_MA_APPROVAL rev 87 + + Structure to keep track of the CMK migration authorization +*/ + +typedef struct tdTPM_CMK_MA_APPROVAL { +#ifdef TPM_USE_TAG_IN_STRUCTURE + TPM_STRUCTURE_TAG tag; /* Set to TPM_TAG_CMK_MA_APPROVAL */ +#endif + TPM_DIGEST migrationAuthorityDigest; /* The hash of a TPM_MSA_COMPOSITE structure + containing the hash of one or more migration + authority public keys and parameters. */ +} TPM_CMK_MA_APPROVAL; + +/* 20.2 Delegate Definitions rev 101 + + The delegations are in a 64-bit field. Each bit describes a capability that the TPM Owner can + delegate to a trusted process by setting that bit. Each delegation bit setting is independent of + any other delegation bit setting in a row. + + If a TPM command is not listed in the following table, then the TPM Owner cannot delegate that + capability to a trusted process. For the TPM commands that are listed in the following table, if + the bit associated with a TPM command is set to zero in the row of the table that identifies a + trusted process, then that process has not been delegated to use that TPM command. + + The minimum granularity for delegation is at the ordinal level. It is not possible to delegate an + option of an ordinal. This implies that if the options present a difficulty and there is a need + to separate the delegations then there needs to be a split into two separate ordinals. +*/ + +#define TPM_DEL_OWNER_BITS 0x00000001 +#define TPM_DEL_KEY_BITS 0x00000002 + +typedef struct tdTPM_DELEGATIONS { +#ifdef TPM_USE_TAG_IN_STRUCTURE + TPM_STRUCTURE_TAG tag; /* This SHALL be TPM_TAG_DELEGATIONS */ +#endif + uint32_t delegateType; /* Owner or key */ + uint32_t per1; /* The first block of permissions */ + uint32_t per2; /* The second block of permissions */ +} TPM_DELEGATIONS; + +/* 20.4 TPM_FAMILY_LABEL rev 85 + + Used in the family table to hold a one-byte numeric value (sequence number) that software can map + to a string of bytes that can be displayed or used by applications. + + This is not sensitive data. +*/ + +#if 0 +typedef struct tdTPM_FAMILY_LABEL { + BYTE label; /* A sequence number that software can map to a string of bytes that can be + displayed or used by the applications. This MUST not contain sensitive + information. */ +} TPM_FAMILY_LABEL; +#endif + +typedef BYTE TPM_FAMILY_LABEL; /* NOTE: No need for a structure here */ + +/* 20.5 TPM_FAMILY_TABLE_ENTRY rev 101 + + The family table entry is an individual row in the family table. There are no sensitive values in + a family table entry. + + Each family table entry contains values to facilitate table management: the familyID sequence + number value that associates a family table row with one or more delegate table rows, a + verification sequence number value that identifies when rows in the delegate table were last + verified, and BYTE family label value that software can map to an ASCII text description of the + entity using the family table entry +*/ + +typedef struct tdTPM_FAMILY_TABLE_ENTRY { +#ifdef TPM_USE_TAG_IN_STRUCTURE + TPM_STRUCTURE_TAG tag; /* This SHALL be TPM_TAG_FAMILY_TABLE_ENTRY */ +#endif + TPM_FAMILY_LABEL familyLabel; /* A sequence number that software can map to a string of + bytes that can be displayed of used by the applications. + This MUST not contain sensitive informations. */ + TPM_FAMILY_ID familyID; /* The family ID in use to tie values together. This is not + a sensitive value. */ + TPM_FAMILY_VERIFICATION verificationCount; /* The value inserted into delegation rows to + indicate that they are the current generation of + rows. Used to identify when a row in the delegate + table was last verified. This is not a sensitive + value. */ + TPM_FAMILY_FLAGS flags; /* See section on TPM_FAMILY_FLAGS. */ + /* NOTE Added */ + TPM_BOOL valid; +} TPM_FAMILY_TABLE_ENTRY; + +/* 20.6 TPM_FAMILY_TABLE rev 87 + + The family table is stored in a TPM shielded location. There are no confidential values in the + family table. The family table contains a minimum of 8 rows. +*/ + +#define TPM_NUM_FAMILY_TABLE_ENTRY_MIN 8 + +typedef struct tdTPM_FAMILY_TABLE { + TPM_FAMILY_TABLE_ENTRY famTableRow[TPM_NUM_FAMILY_TABLE_ENTRY_MIN]; +} TPM_FAMILY_TABLE; + +/* 20.7 TPM_DELEGATE_LABEL rev 87 + + Used in both the delegate table and the family table to hold a string of bytes that can be + displayed or used by applications. This is not sensitive data. +*/ + +#if 0 +typedef struct tdTPM_DELEGATE_LABEL { + BYTE label; /* A byte that can be displayed or used by the applications. This MUST not + contain sensitive information. */ +} TPM_DELEGATE_LABEL; +#endif + +typedef BYTE TPM_DELEGATE_LABEL; /* NOTE: No need for structure */ + +/* 20.8 TPM_DELEGATE_PUBLIC rev 101 + + The information of a delegate row that is public and does not have any sensitive information. + + PCR_INFO_SHORT is appropriate here as the command to create this is done using owner + authorization, hence the owner authorized the command and the delegation. There is no need to + validate what configuration was controlling the platform during the blob creation. +*/ + +typedef struct tdTPM_DELEGATE_PUBLIC { +#ifdef TPM_USE_TAG_IN_STRUCTURE + TPM_STRUCTURE_TAG tag; /* This SHALL be TPM_TAG_DELEGATE_PUBLIC */ +#endif + TPM_DELEGATE_LABEL rowLabel; /* This SHALL be the label for the row. It + MUST not contain any sensitive information. */ + TPM_PCR_INFO_SHORT pcrInfo; /* This SHALL be the designation of the process that can use + the permission. This is a not sensitive + value. PCR_SELECTION may be NULL. + + If selected the pcrInfo MUST be checked on each use of + the delegation. Use of the delegation is where the + delegation is passed as an authorization handle. */ + TPM_DELEGATIONS permissions; /* This SHALL be the permissions that are allowed to the + indicated process. This is not a sensitive value. */ + TPM_FAMILY_ID familyID; /* This SHALL be the family ID that identifies which family + the row belongs to. This is not a sensitive value. */ + TPM_FAMILY_VERIFICATION verificationCount; /* A copy of verificationCount from the associated + family table. This is not a sensitive value. */ +} TPM_DELEGATE_PUBLIC; + + +/* 20.9 TPM_DELEGATE_TABLE_ROW rev 101 + + A row of the delegate table. +*/ + +typedef struct tdTPM_DELEGATE_TABLE_ROW { +#ifdef TPM_USE_TAG_IN_STRUCTURE + TPM_STRUCTURE_TAG tag; /* This SHALL be TPM_TAG_DELEGATE_TABLE_ROW */ +#endif + TPM_DELEGATE_PUBLIC pub; /* This SHALL be the public information for a table row. */ + TPM_SECRET authValue; /* This SHALL be the authorization value that can use the + permissions. This is a sensitive value. */ + /* NOTE Added */ + TPM_BOOL valid; +} TPM_DELEGATE_TABLE_ROW; + +/* 20.10 TPM_DELEGATE_TABLE rev 87 + + This is the delegate table. The table contains a minimum of 2 rows. + + This will be an entry in the TPM_PERMANENT_DATA structure. +*/ + +#define TPM_NUM_DELEGATE_TABLE_ENTRY_MIN 2 + +typedef struct tdTPM_DELEGATE_TABLE { + TPM_DELEGATE_TABLE_ROW delRow[TPM_NUM_DELEGATE_TABLE_ENTRY_MIN]; /* The array of delegations */ +} TPM_DELEGATE_TABLE; + +/* 20.11 TPM_DELEGATE_SENSITIVE rev 115 + + The TPM_DELEGATE_SENSITIVE structure is the area of a delegate blob that contains sensitive + information. + + This structure is normative for loading unencrypted blobs before there is an owner. It is + informative for TPM_CreateOwnerDelegation and TPM_LoadOwnerDelegation after there is an owner and + encrypted blobs are used, since the structure is under complete control of the TPM. +*/ + +typedef struct tdTPM_DELEGATE_SENSITIVE { +#ifdef TPM_USE_TAG_IN_STRUCTURE + TPM_STRUCTURE_TAG tag; /* This MUST be TPM_TAG_DELEGATE_SENSITIVE */ +#endif + TPM_SECRET authValue; /* AuthData value */ +} TPM_DELEGATE_SENSITIVE; + +/* 20.12 TPM_DELEGATE_OWNER_BLOB rev 87 + + This data structure contains all the information necessary to externally store a set of owner + delegation rights that can subsequently be loaded or used by this TPM. + + The encryption mechanism for the sensitive area is a TPM choice. The TPM may use asymmetric + encryption and the SRK for the key. The TPM may use symmetric encryption and a secret key known + only to the TPM. +*/ + +typedef struct tdTPM_DELEGATE_OWNER_BLOB { +#ifdef TPM_USE_TAG_IN_STRUCTURE + TPM_STRUCTURE_TAG tag; /* This MUST be TPM_TAG_DELG_OWNER_BLOB */ +#endif + TPM_DELEGATE_PUBLIC pub; /* The public information for this blob */ + TPM_DIGEST integrityDigest; /* The HMAC to guarantee the integrity of the entire structure */ + TPM_SIZED_BUFFER additionalArea; /* An area that the TPM can add to the blob which MUST NOT + contain any sensitive information. This would include any + IV material for symmetric encryption */ + TPM_SIZED_BUFFER sensitiveArea; /* The area that contains the encrypted + TPM_DELEGATE_SENSITIVE */ +} TPM_DELEGATE_OWNER_BLOB; + +/* 20.13 TPM_DELEGATE_KEY_BLOB rev 87 + + A structure identical to TPM_DELEGATE_OWNER_BLOB but which stores delegation information for user + keys. As compared to TPM_DELEGATE_OWNER_BLOB, it adds a hash of the corresponding public key + value to the public information. +*/ + +typedef struct tdTPM_DELEGATE_KEY_BLOB { +#ifdef TPM_USE_TAG_IN_STRUCTURE + TPM_STRUCTURE_TAG tag; /* This MUST be TPM_TAG_DELG_KEY_BLOB */ +#endif + TPM_DELEGATE_PUBLIC pub; /* The public information for this blob */ + TPM_DIGEST integrityDigest; /* The HMAC to guarantee the integrity of the entire + structure */ + TPM_DIGEST pubKeyDigest; /* The digest, that uniquely identifies the key for which + this usage delegation applies. */ + TPM_SIZED_BUFFER additionalArea; /* An area that the TPM can add to the blob which MUST NOT + contain any sensitive information. This would include any + IV material for symmetric encryption */ + TPM_SIZED_BUFFER sensitiveArea; /* The area that contains the encrypted + TPM_DELEGATE_SENSITIVE */ +} TPM_DELEGATE_KEY_BLOB; + +/* 15.1 TPM_CURRENT_TICKS rev 110 + + This structure holds the current number of time ticks in the TPM. The value is the number of time + ticks from the start of the current session. Session start is a variable function that is + platform dependent. Some platforms may have batteries or other power sources and keep the TPM + clock session across TPM initialization sessions. + + The <tickRate> element of the TPM_CURRENT_TICKS structure provides the number of microseconds per + tick. The platform manufacturer must satisfy input clock requirements set by the TPM vendor to + ensure the accuracy of the tickRate. + + No external entity may ever set the current number of time ticks held in TPM_CURRENT_TICKS. This + value is always reset to 0 when a new clock session starts and increments under control of the + TPM. + + Maintaining the relationship between the number of ticks counted by the TPM and some real world + clock is a task for external software. +*/ + +/* This is not a true UINT64, but a special structure to hold currentTicks */ + +typedef struct tdTPM_UINT64 { + uint32_t sec; + uint32_t usec; +} TPM_UINT64; + +typedef struct tdTPM_CURRENT_TICKS { +#ifdef TPM_USE_TAG_IN_STRUCTURE + TPM_STRUCTURE_TAG tag; /* TPM_TAG_CURRENT_TICKS */ +#endif + TPM_UINT64 currentTicks; /* The number of ticks since the start of this tick session */ + /* upper is seconds, lower is useconds */ + uint16_t tickRate; /* The number of microseconds per tick. The maximum resolution of + the TPM tick counter is thus 1 microsecond. The minimum + resolution SHOULD be 1 millisecond. */ + TPM_NONCE tickNonce; /* TPM_NONCE tickNonce The nonce created by the TPM when resetting + the currentTicks to 0. This indicates the beginning of a time + session. This value MUST be valid before the first use of + TPM_CURRENT_TICKS. The value can be set at TPM_Startup or just + prior to first use. */ + /* NOTE Added */ + TPM_UINT64 initialTime; /* Time from TPM_GetTimeOfDay() */ +} TPM_CURRENT_TICKS; + +/* + 13. Transport Structures +*/ + +/* 13.1 TPM _TRANSPORT_PUBLIC rev 87 + + The public information relative to a transport session +*/ + +typedef struct tdTPM_TRANSPORT_PUBLIC { +#ifdef TPM_USE_TAG_IN_STRUCTURE + TPM_STRUCTURE_TAG tag; /* TPM_TAG_TRANSPORT_PUBLIC */ +#endif + TPM_TRANSPORT_ATTRIBUTES transAttributes; /* The attributes of this session */ + TPM_ALGORITHM_ID algId; /* This SHALL be the algorithm identifier of the + symmetric key. */ + TPM_ENC_SCHEME encScheme; /* This SHALL fully identify the manner in which the + key will be used for encryption operations. */ +} TPM_TRANSPORT_PUBLIC; + +/* 13.2 TPM_TRANSPORT_INTERNAL rev 88 + + The internal information regarding transport session +*/ + +#define TPM_MIN_TRANS_SESSIONS 3 + +typedef struct tdTPM_TRANSPORT_INTERNAL { +#ifdef TPM_USE_TAG_IN_STRUCTURE + TPM_STRUCTURE_TAG tag; /* TPM_TAG_TRANSPORT_INTERNAL */ +#endif + TPM_AUTHDATA authData; /* The shared secret for this session */ + TPM_TRANSPORT_PUBLIC transPublic; /* The public information of this session */ + TPM_TRANSHANDLE transHandle; /* The handle for this session */ + TPM_NONCE transNonceEven; /* The even nonce for the rolling protocol */ + TPM_DIGEST transDigest; /* The log of transport events */ + /* added kgold */ + TPM_BOOL valid; /* entry is valid */ +} TPM_TRANSPORT_INTERNAL; + +/* 13.3 TPM_TRANSPORT_LOG_IN rev 87 + + The logging of transport commands occurs in two steps, before execution with the input + parameters and after execution with the output parameters. + + This structure is in use for input log calculations. +*/ + +typedef struct tdTPM_TRANSPORT_LOG_IN { +#ifdef TPM_USE_TAG_IN_STRUCTURE + TPM_STRUCTURE_TAG tag; /* TPM_TAG_TRANSPORT_LOG_IN */ +#endif + TPM_DIGEST parameters; /* The actual parameters contained in the digest are subject to the + rules of the command using this structure. To find the exact + calculation refer to the actions in the command using this + structure. */ + TPM_DIGEST pubKeyHash; /* The hash of any keys in the transport command */ +} TPM_TRANSPORT_LOG_IN; + +/* 13.4 TPM_TRANSPORT_LOG_OUT rev 88 + + The logging of transport commands occurs in two steps, before execution with the input parameters + and after execution with the output parameters. + + This structure is in use for output log calculations. + + This structure is in use for the INPUT logging during releaseTransport. +*/ + +typedef struct tdTPM_TRANSPORT_LOG_OUT { +#ifdef TPM_USE_TAG_IN_STRUCTURE + TPM_STRUCTURE_TAG tag; /* TPM_TAG_TRANSPORT_LOG_OUT */ +#endif + TPM_CURRENT_TICKS currentTicks; /* The current tick count. This SHALL be the value of the + current TPM tick counter. */ + TPM_DIGEST parameters; /* The actual parameters contained in the digest are subject + to the rules of the command using this structure. To find + the exact calculation refer to the actions in the command + using this structure. */ + TPM_MODIFIER_INDICATOR locality; /* The locality that called TPM_ExecuteTransport */ +} TPM_TRANSPORT_LOG_OUT; + +/* 13.5 TPM_TRANSPORT_AUTH structure rev 87 + + This structure provides the validation for the encrypted AuthData value. +*/ + +typedef struct tdTPM_TRANSPORT_AUTH { +#ifdef TPM_USE_TAG_IN_STRUCTURE + TPM_STRUCTURE_TAG tag; /* TPM_TAG_TRANSPORT_AUTH */ +#endif + TPM_AUTHDATA authData; /* The AuthData value */ +} TPM_TRANSPORT_AUTH; + +/* 22.3 TPM_DAA_ISSUER rev 91 + + This structure is the abstract representation of non-secret settings controlling a DAA + context. The structure is required when loading public DAA data into a TPM. TPM_DAA_ISSUER + parameters are normally held outside the TPM as plain text data, and loaded into a TPM when a DAA + session is required. A TPM_DAA_ISSUER structure contains no integrity check: the TPM_DAA_ISSUER + structure at time of JOIN is indirectly verified by the issuer during the JOIN process, and a + digest of the verified TPM_DAA_ISSUER structure is held inside the TPM_DAA_TPM structure created + by the JOIN process. Parameters DAA_digest_X are digests of public DAA_generic_X parameters, and + used to verify that the correct value of DAA_generic_X has been loaded. DAA_generic_q is stored + in its native form to reduce command complexity. +*/ + +typedef struct tdTPM_DAA_ISSUER { +#ifdef TPM_USE_TAG_IN_STRUCTURE + TPM_STRUCTURE_TAG tag; /* MUST be TPM_TAG_DAA_ISSUER */ +#endif + TPM_DIGEST DAA_digest_R0; /* A digest of the parameter "R0", which is not secret and may be + common to many TPMs. */ + TPM_DIGEST DAA_digest_R1; /* A digest of the parameter "R1", which is not secret and may be + common to many TPMs. */ + TPM_DIGEST DAA_digest_S0; /* A digest of the parameter "S0", which is not secret and may be + common to many TPMs. */ + TPM_DIGEST DAA_digest_S1; /* A digest of the parameter "S1", which is not secret and may be + common to many TPMs. */ + TPM_DIGEST DAA_digest_n; /* A digest of the parameter "n", which is not secret and may be + common to many TPMs. */ + TPM_DIGEST DAA_digest_gamma; /* A digest of the parameter "gamma", which is not secret + and may be common to many TPMs. */ + BYTE DAA_generic_q[26]; /* The parameter q, which is not secret and may be common to + many TPMs. Note that q is slightly larger than a digest, + but is stored in its native form to simplify the + TPM_DAA_join command. Otherwise, JOIN requires 3 input + parameters. */ +} TPM_DAA_ISSUER; + +/* 22.4 TPM_DAA_TPM rev 91 + + This structure is the abstract representation of TPM specific parameters used during a DAA + context. TPM-specific DAA parameters may be stored outside the TPM, and hence this + structure is needed to save private DAA data from a TPM, or load private DAA data into a + TPM. + + If a TPM_DAA_TPM structure is stored outside the TPM, it is stored in a confidential format that + can be interpreted only by the TPM created it. This is to ensure that secret parameters are + rendered confidential, and that both secret and non-secret data in TPM_DAA_TPM form a + self-consistent set. + + TPM_DAA_TPM includes a digest of the public DAA parameters that were used during creation of the + TPM_DAA_TPM structure. This is needed to verify that a TPM_DAA_TPM is being used with the public + DAA parameters used to create the TPM_DAA_TPM structure. Parameters DAA_digest_v0 and + DAA_digest_v1 are digests of public DAA_private_v0 and DAA_private_v1 parameters, and used to + verify that the correct private parameters have been loaded. + + Parameter DAA_count is stored in its native form, because it is smaller than a digest, and is + required to enforce consistency. +*/ + +typedef struct tdTPM_DAA_TPM { +#ifdef TPM_USE_TAG_IN_STRUCTURE + TPM_STRUCTURE_TAG tag; /* MUST be TPM_TAG_DAA_TPM */ +#endif + TPM_DIGEST DAA_digestIssuer; /* A digest of a TPM_DAA_ISSUER structure that contains the + parameters used to generate this TPM_DAA_TPM + structure. */ + TPM_DIGEST DAA_digest_v0; /* A digest of the parameter "v0", which is secret and specific to + this TPM. "v0" is generated during a JOIN phase. */ + TPM_DIGEST DAA_digest_v1; /* A digest of the parameter "v1", which is secret and specific to + this TPM. "v1" is generated during a JOIN phase. */ + TPM_DIGEST DAA_rekey; /* A digest related to the rekeying process, which is not secret but + is specific to this TPM, and must be consistent across JOIN/SIGN + sessions. "rekey" is generated during a JOIN phase. */ + uint32_t DAA_count; /* The parameter "count", which is not secret but must be consistent + across JOIN/SIGN sessions. "count" is an input to the TPM from + the host system. */ +} TPM_DAA_TPM; + +/* 22.5 TPM_DAA_CONTEXT rev 91 + + TPM_DAA_CONTEXT structure is created and used inside a TPM, and never leaves the TPM. This + entire section is informative as the TPM does not expose this structure. TPM_DAA_CONTEXT + includes a digest of the public and private DAA parameters that were used during creation of the + TPM_DAA_CONTEXT structure. This is needed to verify that a TPM_DAA_CONTEXT is being used with the + public and private DAA parameters used to create the TPM_DAA_CONTEXT structure. +*/ + +typedef struct tdTPM_DAA_CONTEXT { +#ifdef TPM_USE_TAG_IN_STRUCTURE + TPM_STRUCTURE_TAG tag; /* MUST be TPM_TAG_DAA_CONTEXT */ +#endif + TPM_DIGEST DAA_digestContext; /* A digest of parameters used to generate this + structure. The parameters vary, depending on whether the + session is a JOIN session or a SIGN session. */ + TPM_DIGEST DAA_digest; /* A running digest of certain parameters generated during DAA + computation; operationally the same as a PCR (which holds a + running digest of integrity metrics). */ + TPM_DAA_CONTEXT_SEED DAA_contextSeed; /* The seed used to generate other DAA + session parameters */ + BYTE DAA_scratch[256]; /* Memory used to hold different parameters at different + times of DAA computation, but only one parameter at a + time. The maximum size of this field is 256 bytes */ + BYTE DAA_stage; /* A counter, indicating the stage of DAA computation that was most + recently completed. The value of the counter is zero if the TPM + currently contains no DAA context. + + When set to zero (0) the TPM MUST clear all other fields in this + structure. + + The TPM MUST set DAA_stage to 0 on TPM_Startup(ANY) */ + TPM_BOOL DAA_scratch_null; +} TPM_DAA_CONTEXT; + +/* 22.6 TPM_DAA_JOINDATA rev 91 + + This structure is the abstract representation of data that exists only during a specific JOIN + session. +*/ + +typedef struct tdTPM_DAA_JOINDATA { + BYTE DAA_join_u0[128]; /* A TPM-specific secret "u0", used during the JOIN phase, + and discarded afterwards. */ + BYTE DAA_join_u1[138]; /* A TPM-specific secret "u1", used during the JOIN phase, + and discarded afterwards. */ + TPM_DIGEST DAA_digest_n0; /* A digest of the parameter "n0", which is an RSA public key with + exponent 2^16 +1 */ +} TPM_DAA_JOINDATA; + +/* DAA Session structure + +*/ + +#define TPM_MIN_DAA_SESSIONS 2 + +typedef struct tdTPM_DAA_SESSION_DATA { + TPM_DAA_ISSUER DAA_issuerSettings; /* A set of DAA issuer parameters controlling a DAA + session. (non-secret) */ + TPM_DAA_TPM DAA_tpmSpecific; /* A set of DAA parameters associated with a + specific TPM. (secret) */ + TPM_DAA_CONTEXT DAA_session; /* A set of DAA parameters associated with a DAA + session. (secret) */ + TPM_DAA_JOINDATA DAA_joinSession; /* A set of DAA parameters used only during the JOIN + phase of a DAA session, and generated by the + TPM. (secret) */ + /* added kgold */ + TPM_HANDLE daaHandle; /* DAA session handle */ + TPM_BOOL valid; /* array entry is valid */ + /* FIXME should have handle type Join or Sign */ +} TPM_DAA_SESSION_DATA; + +/* 22.8 TPM_DAA_BLOB rev 98 + + The structure passed during the join process +*/ + +typedef struct tdTPM_DAA_BLOB { +#ifdef TPM_USE_TAG_IN_STRUCTURE + TPM_STRUCTURE_TAG tag; /* MUST be TPM_TAG_DAA_BLOB */ +#endif + TPM_RESOURCE_TYPE resourceType; /* The resource type: enc(DAA_tpmSpecific) or enc(v0) or + enc(v1) */ + BYTE label[16]; /* Label for identification of the blob. Free format + area. */ + TPM_DIGEST blobIntegrity; /* The integrity of the entire blob including the sensitive + area. This is a HMAC calculation with the entire + structure (including sensitiveData) being the hash and + daaProof is the secret */ + TPM_SIZED_BUFFER additionalData; /* Additional information set by the TPM that helps define + and reload the context. The information held in this area + MUST NOT expose any information held in shielded + locations. This should include any IV for symmetric + encryption */ + TPM_SIZED_BUFFER sensitiveData; /* A TPM_DAA_SENSITIVE structure */ +#if 0 + uint32_t additionalSize; + [size_is(additionalSize)] BYTE* additionalData; + uint32_t sensitiveSize; + [size_is(sensitiveSize)] BYTE* sensitiveData; +#endif +} TPM_DAA_BLOB; + +/* 22.9 TPM_DAA_SENSITIVE rev 91 + + The encrypted area for the DAA parameters +*/ + +typedef struct tdTPM_DAA_SENSITIVE { +#ifdef TPM_USE_TAG_IN_STRUCTURE + TPM_STRUCTURE_TAG tag; /* MUST be TPM_TAG_DAA_SENSITIVE */ +#endif + TPM_SIZED_BUFFER internalData; /* DAA_tpmSpecific or DAA_private_v0 or DAA_private_v1 */ +#if 0 + uint32_t internalSize; + [size_is(internalSize)] BYTE* internalData; +#endif +} TPM_DAA_SENSITIVE; + +#endif + +/* 7.1 TPM_PERMANENT_FLAGS rev 110 + + These flags maintain state information for the TPM. The values are not affected by any + TPM_Startup command. + + The flag history includes: + + Rev 62 specLevel 1 errataRev 0: 15 BOOLs + Rev 85 specLevel 2 errataRev 0: 19 BOOLs + Added: nvLocked, readSRKPub, tpmEstablished, maintenanceDone + Rev 94 specLevel 2 errataRev 1: 19 BOOLs + Rev 103 specLevel 2 errataRev 2: 20 BOOLs + Added: disableFullDALogicInfo +*/ + +typedef struct tdTPM_PERMANENT_FLAGS { + TPM_STRUCTURE_TAG tag; /* TPM_TAG_PERMANENT_FLAGS */ + TPM_BOOL disable; /* disable The state of the disable flag. The default state is TRUE + */ + TPM_BOOL ownership; /* The ability to install an owner. The default state is TRUE. */ + TPM_BOOL deactivated; /* The state of the inactive flag. The default state is TRUE. */ + TPM_BOOL readPubek; /* The ability to read the PUBEK without owner authorization. The + default state is TRUE. + + set TRUE on owner clear + set FALSE on take owner, disablePubekRead + */ + TPM_BOOL disableOwnerClear; /* Whether the owner authorized clear commands are active. The + default state is FALSE. */ + TPM_BOOL allowMaintenance; /* Whether the TPM Owner may create a maintenance archive. The + default state is TRUE. */ + TPM_BOOL physicalPresenceLifetimeLock; /* This bit can only be set to TRUE; it cannot be set to + FALSE except during the manufacturing process. + + FALSE: The state of either physicalPresenceHWEnable or + physicalPresenceCMDEnable MAY be changed. (DEFAULT) + + TRUE: The state of either physicalPresenceHWEnable or + physicalPresenceCMDEnable MUST NOT be changed for the + life of the TPM. */ + TPM_BOOL physicalPresenceHWEnable; /* FALSE: Disable the hardware signal indicating physical + presence. (DEFAULT) + + TRUE: Enables the hardware signal indicating physical + presence. */ + TPM_BOOL physicalPresenceCMDEnable; /* FALSE: Disable the command indicating physical + presence. (DEFAULT) + + TRUE: Enables the command indicating physical + presence. */ + TPM_BOOL CEKPUsed; /* TRUE: The PRIVEK and PUBEK were created using + TPM_CreateEndorsementKeyPair. + + FALSE: The PRIVEK and PUBEK were created using a manufacturer's + process. NOTE: This flag has no default value as the key pair + MUST be created by one or the other mechanism. */ + TPM_BOOL TPMpost; /* TRUE: After TPM_Startup, if there is a call to + TPM_ContinueSelfTest the TPM MUST execute the actions of + TPM_SelfTestFull + + FALSE: After TPM_Startup, if there is a call to + TPM_ContinueSelfTest the TPM MUST execute TPM_ContinueSelfTest + + If the TPM supports the implicit invocation of + TPM_ContinueSelftTest upon the use of an untested resource, the + TPM MUST use the TPMPost flag to call either TPM_ContinueSelfTest + or TPM_SelfTestFull + + The TPM manufacturer sets this bit during TPM manufacturing and + the bit is unchangeable after shipping the TPM + + The default state is FALSE */ + TPM_BOOL TPMpostLock; /* With the clarification of TPMPost TPMpostLock is now + unnecessary. + This flag is now deprecated */ + TPM_BOOL FIPS; /* TRUE: This TPM operates in FIPS mode + FALSE: This TPM does NOT operate in FIPS mode */ + TPM_BOOL tpmOperator; /* TRUE: The operator authorization value is valid + FALSE: the operator authorization value is not set */ + TPM_BOOL enableRevokeEK; /* TRUE: The TPM_RevokeTrust command is active + FALSE: the TPM RevokeTrust command is disabled */ + TPM_BOOL nvLocked; /* TRUE: All NV area authorization checks are active + FALSE: No NV area checks are performed, except for maxNVWrites. + FALSE is the default value */ + TPM_BOOL readSRKPub; /* TRUE: GetPubKey will return the SRK pub key + FALSE: GetPubKey will not return the SRK pub key + Default SHOULD be FALSE */ + TPM_BOOL tpmEstablished; /* TRUE: TPM_HASH_START has been executed at some time + FALSE: TPM_HASH_START has not been executed at any time + Default is FALSE - resets using TPM_ResetEstablishmentBit */ + TPM_BOOL maintenanceDone; /* TRUE: A maintenance archive has been created for the current + SRK */ + TPM_BOOL disableFullDALogicInfo; /* TRUE: The full dictionary attack TPM_GetCapability info is + deactivated. The returned structure is TPM_DA_INFO_LIMITED. + FALSE: The full dictionary attack TPM_GetCapability info is + activated. The returned structure is TPM_DA_INFO. + Default is FALSE. + */ + /* NOTE: Cannot add vendor specific flags here, since TPM_GetCapability() returns the serialized + structure */ +} TPM_PERMANENT_FLAGS; + +/* 7.2 TPM_STCLEAR_FLAGS rev 109 + + These flags maintain state that is reset on each TPM_Startup(ST_Clear) command. The values are + not affected by TPM_Startup(ST_State) commands. +*/ + +typedef struct tdTPM_STCLEAR_FLAGS { + TPM_STRUCTURE_TAG tag; /* TPM_TAG_STCLEAR_FLAGS */ + TPM_BOOL deactivated; /* Prevents the operation of most capabilities. There is no + default state. It is initialized by TPM_Startup to the + same value as TPM_PERMANENT_FLAGS -> + deactivated. TPM_SetTempDeactivated sets it to TRUE. */ + TPM_BOOL disableForceClear; /* Prevents the operation of TPM_ForceClear when TRUE. The + default state is FALSE. TPM_DisableForceClear sets it to + TRUE. */ + TPM_BOOL physicalPresence; /* Command assertion of physical presence. The default state + is FALSE. This flag is affected by the + TSC_PhysicalPresence command but not by the hardware + signal. */ + TPM_BOOL physicalPresenceLock; /* Indicates whether changes to the TPM_STCLEAR_FLAGS -> + physicalPresence flag are permitted. + TPM_Startup(ST_CLEAR) sets PhysicalPresenceLock to its + default state of FALSE (allow changes to the + physicalPresence flag). When TRUE, the physicalPresence + flag is FALSE. TSC_PhysicalPresence can change the state + of physicalPresenceLock. */ + TPM_BOOL bGlobalLock; /* Set to FALSE on each TPM_Startup(ST_CLEAR). Set to TRUE + when a write to NV_Index =0 is successful */ + /* NOTE: Cannot add vendor specific flags here, since TPM_GetCapability() returns the serialized + structure */ +} TPM_STCLEAR_FLAGS; + +#if 0 + + +/* 7.3 TPM_STANY_FLAGS rev 87 + + These flags reset on any TPM_Startup command. +*/ + +typedef struct tdTPM_STANY_FLAGS { +#ifdef TPM_USE_TAG_IN_STRUCTURE + TPM_STRUCTURE_TAG tag; /* TPM_TAG_STANY_FLAGS */ +#endif + TPM_BOOL postInitialise; /* Prevents the operation of most capabilities. There is no default + state. It is initialized by TPM_Init to TRUE. TPM_Startup sets it + to FALSE. */ + TPM_MODIFIER_INDICATOR localityModifier; /*This SHALL indicate for each command the presence of + a locality modifier for the command. It MUST be set + to NULL after the TPM executes each command. */ +#if 0 + TPM_BOOL transportExclusive; /* Defaults to FALSE. TRUE when there is an exclusive transport + session active. Execution of ANY command other than + TPM_ExecuteTransport or TPM_ReleaseTransportSigned MUST + invalidate the exclusive transport session. + */ +#endif + TPM_TRANSHANDLE transportExclusive; /* Defaults to 0x00000000, Set to the handle when an + exclusive transport session is active */ + TPM_BOOL TOSPresent; /* Defaults to FALSE + Set to TRUE on TPM_HASH_START + set to FALSE using setCapability */ + /* NOTE: Added kgold */ + TPM_BOOL stateSaved; /* Defaults to FALSE + Set to TRUE on TPM_SaveState + Set to FALSE on any other ordinal + + This is an optimization flag, so the file need not be deleted if + it does not exist. + */ +} TPM_STANY_FLAGS; + +/* 7.4 TPM_PERMANENT_DATA rev 105 + + This structure contains the data fields that are permanently held in the TPM and not affected by + TPM_Startup(any). + + Many of these fields contain highly confidential and privacy sensitive material. The TPM must + maintain the protections around these fields. +*/ + +#define TPM_MIN_COUNTERS 4 /* the minimum number of counters is 4 */ +#define TPM_DELEGATE_KEY TPM_KEY +#define TPM_MAX_NV_WRITE_NOOWNER 64 + +/* Although the ordinal is 32 bits, only the lower 8 bits seem to be used. So for now, define an + array of 256/8 bytes for ordinalAuditStatus - kgold */ + +#define TPM_ORDINALS_MAX 256 /* assumes a multiple of CHAR_BIT */ +#define TPM_AUTHDIR_SIZE 1 /* Number of DIR registers */ + +#ifdef TPM_VTPM + +/* Substructure of TPM_PERMANENT_DATA for VTPM instance data + + */ + +typedef struct tdTPM_PERMANENT_INSTANCE_DATA { + uint32_t creationMask; /* creationMask from TPM_CreateInstance */ + TPM_INSTANCE_HANDLE parentHandle; /* instance handle of this instance's parent instance */ + TPM_SIZED_BUFFER childHandles; /* instance handle list of this instance's children */ + TPM_NONCE migrationNonce; /* Controls state import using TPM_SetInstanceData */ + TPM_DIGEST migrationDigest; /* Digest of all migrated data structures */ + TPM_BOOL sourceLock; /* Lock instance before export migration */ + TPM_BOOL destinationLock; /* Lock instance before import migration */ + +} TPM_PERMANENT_INSTANCE_DATA; + +#endif /* TPM_VTPM */ + +#ifdef TPM_VENDOR + +/* + WEC_CFG_STRUCT +*/ + +/* Winbond preconfiguration */ + +typedef struct tdTPM_WEC_CFG_STRUCT { + BYTE lowBaseAddress; /* reserved - keep FFh value */ + BYTE highBaseAddress; /* reserved - keep FFh value */ + BYTE altCfg; /* GPIO alternate configuration */ + BYTE direction; /* direction (input/output) of GPIO pins */ + BYTE pullUp; /* pull-up of GPIO input pins */ + BYTE pushPull; /* push-pull of open drain of GPIO output pins */ + BYTE cfg_a; /* hardware physical presence, 32 khz clock */ + BYTE cfg_b; /* reserved - keep FFh value */ + BYTE cfg_c; /* reserved - keep FFh value */ + BYTE cfg_d; /* reserved - keep FFh value */ + BYTE cfg_e; /* reserved - keep FFh value */ + BYTE cfg_f; /* software binding */ + BYTE cfg_g; /* tplPost flagm N_FAILS and WEC_GetTpmStatus */ + BYTE cfg_h; /* LpcSelfTest and FIPS flags */ + BYTE cfg_i; /* reserved - keep FFh value */ + BYTE cfg_j; /* reserved - keep FFh value */ +} TPM_WEC_CFG_STRUCT; + +#endif /*TPM_VENDOR */ + + +typedef struct tdTPM_PERMANENT_DATA { +#ifdef TPM_USE_TAG_IN_STRUCTURE + TPM_STRUCTURE_TAG tag; /* TPM_TAG_PERMANENT_DATA */ +#endif + BYTE revMajor; /* This is the TPM major revision indicator. This SHALL be set by + the TPME, only. The default value is manufacturer-specific. */ + BYTE revMinor; /* This is the TPM minor revision indicator. This SHALL be set by + the TPME, only. The default value is manufacturer-specific. */ + TPM_SECRET tpmProof; /* This is a random number that each TPM maintains to validate blobs + in the SEAL and other processes. The default value is + manufacturer-specific. */ + TPM_NONCE EKReset; /* Nonce held by TPM to validate TPM_RevokeTrust. This value is set + as the next 20 bytes from the TPM RNG when the EK is set + (was fipsReset - kgold) */ + TPM_SECRET ownerAuth; /* This is the TPM-Owner's authorization data. The default value is + manufacturer-specific. */ + TPM_SECRET operatorAuth; /* The value that allows the execution of the SetTempDeactivated + command */ + TPM_DIRVALUE authDIR; /* The array of TPM Owner authorized DIR. Points to the same + location as the NV index value. (kgold - was array of 1) */ +#ifndef TPM_NOMAINTENANCE + TPM_PUBKEY manuMaintPub; /* This is the manufacturer's public key to use in the maintenance + operations. The default value is manufacturer-specific. */ +#endif + TPM_KEY endorsementKey; /* This is the TPM's endorsement key pair. */ + TPM_KEY srk; /* This is the TPM's StorageRootKey. */ + TPM_SYMMETRIC_KEY_TOKEN contextKey; /* This is the key in use to perform context saves. The key + may be symmetric or asymmetric. The key size is + predicated by the algorithm in use. */ + TPM_SYMMETRIC_KEY_TOKEN delegateKey; /* This key encrypts delegate rows that are stored + outside the TPM. */ + TPM_COUNTER_VALUE auditMonotonicCounter; /* This SHALL be the audit monotonic counter for the + TPM. This value starts at 0 and increments + according to the rules of auditing */ + TPM_COUNTER_VALUE monotonicCounter[TPM_MIN_COUNTERS]; /* This SHALL be the monotonic + counters for the TPM. The + individual counters start and + increment according to the rules + of monotonic counters. */ + TPM_PCR_ATTRIBUTES pcrAttrib[TPM_NUM_PCR]; /* The attributes for all of the PCR registers + supported by the TPM. */ + BYTE ordinalAuditStatus[TPM_ORDINALS_MAX/CHAR_BIT]; /* Table indicating which ordinals are being + audited. */ +#if 0 + /* kgold - The xcrypto RNG is good enough that this is not needed */ + BYTE* rngState; /* State information describing the random number + generator. */ +#endif + TPM_FAMILY_TABLE familyTable; /* The family table in use for delegations */ + TPM_DELEGATE_TABLE delegateTable; /* The delegate table */ + uint32_t lastFamilyID; /* A value that sets the high water mark for family ID's. Set to 0 + during TPM manufacturing and never reset. */ + uint32_t noOwnerNVWrite; /* The count of NV writes that have occurred when there is no TPM + Owner. + + This value starts at 0 in manufacturing and after each + TPM_OwnerClear. If the value exceeds 64 the TPM returns + TPM_MAXNVWRITES to any command attempting to manipulate the NV + storage. */ + TPM_CMK_DELEGATE restrictDelegate; /* The settings that allow for the delegation and + use on CMK keys. Default value is false. */ + TPM_DAA_TPM_SEED tpmDAASeed; /* This SHALL be a random value generated after generation + of the EK. + + tpmDAASeed does not change during TPM Owner changes. If + the EK is removed (RevokeTrust) then the TPM MUST + invalidate the tpmDAASeed. The owner can force a change + in the value through TPM_SetCapability. + + (linked to daaProof) */ + TPM_NONCE daaProof; /* This is a random number that each TPM maintains to validate blobs + in the DAA processes. The default value is manufacturer-specific. + + The value is not changed when the owner is changed. It is + changed when the EK changes. The owner can force a change in the + value through TPM_SetCapability. */ + unsigned char *daaBlobKey; /* This is the key in use to perform DAA encryption and decryption. + The key may be symmetric or asymmetric. The key size is + predicated by the algorithm in use. + + This value MUST be changed when daaProof changes. + + This key MUST NOT be a copy of the EK or SRK. + + (linked to daaProof) */ + /* NOTE: added kgold */ + TPM_BOOL ownerInstalled; /* TRUE: The TPM has an owner installed. + FALSE: The TPM has no owner installed. (default) */ + BYTE tscOrdinalAuditStatus; /* extra byte to track TSC ordinals */ +#ifdef TPM_VTPM /* VTPM specific ordinals */ + uint32_t instanceOrdinalAuditStatus1; /* extra longs to track vendor specific ordinals */ + uint32_t instanceOrdinalAuditStatus2; +#endif + TPM_BOOL allowLoadMaintPub; /* TRUE allows the TPM_LoadManuMaintPub command */ + +#ifdef TPM_VTPM + TPM_PERMANENT_INSTANCE_DATA instanceData; /* substructure for VTPM instance data */ +#endif +#ifdef TPM_VENDOR + TPM_WEC_CFG_STRUCT wecPreConfig; /* Winbond preconfiguration data */ + TPM_BOOL preConfigSet; /* TRUE if the structure has been set through + WEC_PreConfig */ +#endif +} TPM_PERMANENT_DATA; + +#define TPM_MIN_AUTH_SESSIONS 3 + +/* NOTE: Vendor specific */ + +typedef struct tdTPM_AUTH_SESSION_DATA { + /* vendor specific */ + TPM_AUTHHANDLE handle; /* Handle for a session */ + TPM_PROTOCOL_ID protocolID; /* TPM_PID_OIAP, TPM_PID_OSAP, TPM_PID_DSAP */ + TPM_ENT_TYPE entityTypeByte; /* The type of entity in use (TPM_ET_SRK, TPM_ET_OWNER, + TPM_ET_KEYHANDLE ... */ + TPM_ADIP_ENC_SCHEME adipEncScheme; /* ADIP encryption scheme */ + TPM_NONCE nonceEven; /* OIAP, OSAP, DSAP */ + TPM_SECRET sharedSecret; /* OSAP */ + TPM_DIGEST entityDigest; /* OSAP tracks which entity established the OSAP session */ + TPM_DELEGATE_PUBLIC pub; /* DSAP */ + TPM_BOOL valid; /* added kgold: array entry is valid */ +} TPM_AUTH_SESSION_DATA; + +#ifdef TPM_VTPM +/* 3.3.2 TPM_PCR_LIST + + TPM_PCR_LIST is a structure saved by TPM_SetupInstance and returned by TPM_GetCapability. +*/ + +typedef struct tdTPM_PCR_LIST { + TPM_PCRINDEX pcrIndex; /* Index to a PCR register */ + TPM_DIGEST inDigest; /* The digest representing the event to be recorded. */ + BYTE eventID; /* Identifier for measurements */ +#if 0 + uint32_t nameSize; /* The size of the name area */ + BYTE* name; /* Name of an initial measurement */ +#endif + TPM_SIZED_BUFFER name; +} TPM_PCR_LIST; + +/* TPM_PCR_LIST_TIMESTAMP + + TPM_PCR_LIST_TIMESTAMP is a structure saved by the TPM when logging PCR extensions and returned + by TPM_GetCapability. +*/ + +typedef struct tdTPM_PCR_LIST_TIMESTAMP { + TPM_COMMAND_CODE ordinal; /* The ordinal that altered the PCR */ + TPM_PCRINDEX pcrIndex; /* Index to a PCR register */ + TPM_DIGEST digest; /* The digest representing the recorded PCR Extension */ + uint32_t timestamp_hi; /* time of the log entry */ + uint32_t timestamp_lo; +} TPM_PCR_LIST_TIMESTAMP; + +/* TPM_PCR_LIST_TIMESTAMP_INST + + TPM_PCR_LIST_TIMESTAMP_INST is a structure created by the TPM when notifying clients of PCR + extensions. +*/ + +typedef struct tdTPM_PCR_LIST_TIMESTAMP_INST { + TPM_INSTANCE_HANDLE instance; /* instance handle */ + TPM_COMMAND_CODE ordinal; /* The ordinal that altered the PCR */ + TPM_PCRINDEX pcrIndex; /* Index to a PCR register */ + TPM_DIGEST digest; /* The digest representing the recorded PCR Extensions. */ + uint32_t timestamp_hi; /* time of the log entry */ + uint32_t timestamp_lo; +} TPM_PCR_LIST_TIMESTAMP_INST; + +/* Added for virtual TPM support */ + +typedef struct tdTPM_VTPM_INSTANCE { + TPM_SYMMETRIC_KEY_TOKEN instanceEncKey; /* symmetric key to encrypt instance migration + blobs */ + TPM_SECRET instanceHmacKey; /* secret used to MAC instance migration blobs */ + TPM_SIZED_BUFFER pcrList; /* PCR lists from TPM_SetupInstance */ + TPM_PCR_SELECTION logPCRSelection; /* Indices of PCRs that should be saved for logging */ + TPM_PCR_SELECTION subscribePCRSelection; /* Indices of PCRs that should be reported to a + subscriber */ + uint32_t logLengthMax; /* Upper limit on the length of the buffer (number of + measurements) used for logging of measurements */ + uint32_t logLength; /* number of measurements in the log */ + TPM_BOOL logOverflow; /* pcrMeasurementLog has overflowed */ + uint32_t subscribeSequenceNumber; /* count of measurements sent to subscriber */ +} TPM_VTPM_INSTANCE; + +#endif /* TPM_VTPM */ + +/* 3. contextList MUST support a minimum of 16 entries, it MAY support more. */ +#define TPM_MIN_SESSION_LIST 16 + +/* 7.5 TPM_STCLEAR_DATA rev 101 + + This is an informative structure and not normative. It is purely for convenience of writing the + spec. + + Most of the data in this structure resets on TPM_Startup(ST_Clear). A TPM may implement rules + that provide longer-term persistence for the data. The TPM reflects how it handles the data in + various TPM_GetCapability fields including startup effects. +*/ + +typedef struct tdTPM_STCLEAR_DATA { +#ifdef TPM_USE_TAG_IN_STRUCTURE + TPM_STRUCTURE_TAG tag; /* TPM_TAG_STCLEAR_DATA */ +#endif + TPM_NONCE contextNonceKey; /* This is the nonce in use to properly identify saved key context + blobs This SHALL be set to all zeros on each TPM_Startup + (ST_Clear). + */ + TPM_COUNT_ID countID; /* This is the handle for the current monotonic counter. This SHALL + be set to zero on each TPM_Startup(ST_Clear). */ + uint32_t ownerReference; /* Points to where to obtain the owner secret in OIAP and OSAP + commands. This allows a TSS to manage 1.1 applications on a 1.2 + TPM where delegation is in operation. */ + TPM_BOOL disableResetLock; /* Disables TPM_ResetLockValue upon authorization failure. + The value remains TRUE for the timeout period. + + Default is FALSE. + + The value is in the STCLEAR_DATA structure as the + implementation of this flag is TPM vendor specific. */ + TPM_PCRVALUE PCRS[TPM_NUM_PCR]; /* Platform configuration registers */ +#if (TPM_REVISION >= 103) /* added for rev 103 */ + uint32_t deferredPhysicalPresence; /* The value can save the assertion of physicalPresence. + Individual bits indicate to its ordinal that + physicalPresence was previously asserted when the + software state is such that it can no longer be asserted. + Set to zero on each TPM_Startup(ST_Clear). */ +#endif + /* NOTE: Added for dictionary attack mitigation */ + uint32_t authFailCount; /* number of authorization failures without a TPM_ResetLockValue */ + uint32_t authFailTime; /* time of threshold failure in seconds */ + /* NOTE: Moved from TPM_STANY_DATA. Saving this state is optional. This implementation + does. */ + TPM_AUTH_SESSION_DATA authSessions[TPM_MIN_AUTH_SESSIONS]; /* List of current + sessions. Sessions can be OSAP, + OIAP, DSAP and Transport */ + /* NOTE: Added for transport */ + TPM_TRANSPORT_INTERNAL transSessions[TPM_MIN_TRANS_SESSIONS]; + /* 22.7 TPM_STANY_DATA Additions (for DAA) - moved to TPM_STCLEAR_DATA for startup state */ + TPM_DAA_SESSION_DATA daaSessions[TPM_MIN_DAA_SESSIONS]; + /* 1. The group of contextNonceSession, contextCount, contextList MUST reset at the same + time. */ + TPM_NONCE contextNonceSession; /* This is the nonce in use to properly identify saved + session context blobs. This MUST be set to all zeros on + each TPM_Startup (ST_Clear). The nonce MAY be set to + null on TPM_Startup( any). */ + uint32_t contextCount; /* This is the counter to avoid session context blob replay + attacks. This MUST be set to 0 on each TPM_Startup + (ST_Clear). The value MAY be set to 0 on TPM_Startup + (any). */ + uint32_t contextList[TPM_MIN_SESSION_LIST]; /* This is the list of outstanding session blobs. + All elements of this array MUST be set to 0 on + each TPM_Startup (ST_Clear). The values MAY be + set to 0 on TPM_Startup (any). */ + /* NOTE Added auditDigest effect, saved with ST_STATE */ + TPM_DIGEST auditDigest; /* This is the extended value that is the audit log. This + SHALL be set to all zeros at the start of each audit + session. */ + /* NOTE Storage for the ordinal response */ + TPM_STORE_BUFFER ordinalResponse; /* outgoing response buffer for this ordinal */ + uint32_t responseCount; /* increments after each response */ +} TPM_STCLEAR_DATA; + +/* 7.6 TPM_STANY_DATA rev 87 + + This is an informative structure and not normative. It is purely for convenience of writing the + spec. + + Most of the data in this structure resets on TPM_Startup(ST_State). A TPM may implement rules + that provide longer-term persistence for the data. The TPM reflects how it handles the data in + various getcapability fields including startup effects. +*/ + +typedef struct tdTPM_STANY_DATA { +#ifdef TPM_USE_TAG_IN_STRUCTURE + TPM_STRUCTURE_TAG tag; /* TPM_TAG_STANY_DATA */ +#endif + TPM_CURRENT_TICKS currentTicks; /* This is the current tick counter. This is reset to 0 + according to the rules when the TPM can tick. See the + section on the tick counter for details. */ +} TPM_STANY_DATA; + +/* 11. Signed Structures */ + +/* 11.1 TPM_CERTIFY_INFO rev 101 + + When the TPM certifies a key, it must provide a signature with a TPM identity key on information + that describes that key. This structure provides the mechanism to do so. + + Key usage and keyFlags must have their upper byte set to zero to avoid collisions with the other + signature headers. +*/ + +typedef struct tdTPM_CERTIFY_INFO { + TPM_STRUCT_VER version; /* This MUST be 1.1.0.0 */ + TPM_KEY_USAGE keyUsage; /* This SHALL be the same value that would be set in a + TPM_KEY representation of the key to be certified. The + upper byte MUST be zero */ + TPM_KEY_FLAGS keyFlags; /* This SHALL be set to the same value as the corresponding + parameter in the TPM_KEY structure that describes the + public key that is being certified. The upper byte MUST + be zero */ + TPM_AUTH_DATA_USAGE authDataUsage; /* This SHALL be the same value that would be set in a + TPM_KEY representation of the key to be certified */ + TPM_KEY_PARMS algorithmParms; /* This SHALL be the same value that would be set in a + TPM_KEY representation of the key to be certified */ + TPM_DIGEST pubkeyDigest; /* This SHALL be a digest of the value TPM_KEY -> pubKey -> + key in a TPM_KEY representation of the key to be + certified */ + TPM_NONCE data; /* This SHALL be externally provided data. */ + TPM_BOOL parentPCRStatus; /* This SHALL indicate if any parent key was wrapped to a + PCR */ + TPM_SIZED_BUFFER pcrInfo; /* */ +#if 0 + uint32_t PCRInfoSize; /* This SHALL be the size of the pcrInfo parameter. A value + of zero indicates that the key is not wrapped to a PCR */ + BYTE* PCRInfo; /* This SHALL be the TPM_PCR_INFO structure. */ +#endif + /* NOTE: kgold - Added this structure, a cache of PCRInfo when not NULL */ + TPM_PCR_INFO *tpm_pcr_info; +} TPM_CERTIFY_INFO; + +/* 11.2 TPM_CERTIFY_INFO2 rev 101 + + When the TPM certifies a key, it must provide a signature with a TPM identity key on information + that describes that key. This structure provides the mechanism to do so. + + Key usage and keyFlags must have their upper byte set to zero to avoid collisions with the other + signature headers. +*/ + +typedef struct tdTPM_CERTIFY_INFO2 { +#ifdef TPM_USE_TAG_IN_STRUCTURE + TPM_STRUCTURE_TAG tag; /* MUST be TPM_TAG_CERTIFY_INFO2 */ +#endif + BYTE fill; /* MUST be 0x00 */ + TPM_PAYLOAD_TYPE payloadType; /* This SHALL be the same value that would be set in a + TPM_KEY representation of the key to be certified */ + TPM_KEY_USAGE keyUsage; /* This SHALL be the same value that would be set in a + TPM_KEY representation of the key to be certified. The + upper byte MUST be zero */ + TPM_KEY_FLAGS keyFlags; /* This SHALL be set to the same value as the corresponding + parameter in the TPM_KEY structure that describes the + public key that is being certified. The upper byte MUST + be zero. */ + TPM_AUTH_DATA_USAGE authDataUsage; /* This SHALL be the same value that would be set in a + TPM_KEY representation of the key to be certified */ + TPM_KEY_PARMS algorithmParms; /* This SHALL be the same value that would be set in a + TPM_KEY representation of the key to be certified */ + TPM_DIGEST pubkeyDigest; /* This SHALL be a digest of the value TPM_KEY -> pubKey -> + key in a TPM_KEY representation of the key to be + certified */ + TPM_NONCE data; /* This SHALL be externally provided data. */ + TPM_BOOL parentPCRStatus; /* This SHALL indicate if any parent key was wrapped to a + PCR */ +#if 0 + uint32_t PCRInfoSize; /* This SHALL be the size of the pcrInfo parameter. A value + of zero indicates that the key is not wrapped to a PCR */ + BYTE* PCRInfo; /* This SHALL be the TPM_PCR_INFO_SHORT structure. */ +#endif + TPM_SIZED_BUFFER pcrInfo; +#if 0 + uint32_t migrationAuthoritySize; /* This SHALL be the size of migrationAuthority */ + BYTE *migrationAuthority; /* If the key to be certified has [payload == + TPM_PT_MIGRATE_RESTRICTED or payload + ==TPM_PT_MIGRATE_EXTERNAL], migrationAuthority is the + digest of the TPM_MSA_COMPOSITE and has TYPE == + TPM_DIGEST. Otherwise it is NULL. */ +#endif + TPM_SIZED_BUFFER migrationAuthority; + /* NOTE: kgold - Added this structure, a cache of PCRInfo when not NULL */ + TPM_PCR_INFO_SHORT *tpm_pcr_info_short; +} TPM_CERTIFY_INFO2; + +/* 11.3 TPM_QUOTE_INFO rev 87 + + This structure provides the mechanism for the TPM to quote the current values of a list of PCRs. +*/ + +typedef struct tdTPM_QUOTE_INFO { + TPM_STRUCT_VER version; /* This MUST be 1.1.0.0 */ + BYTE fixed[4]; /* This SHALL always be the string 'QUOT' */ + TPM_COMPOSITE_HASH digestValue; /* This SHALL be the result of the composite hash algorithm + using the current values of the requested PCR indices. */ + TPM_NONCE externalData; /* 160 bits of externally supplied data */ +} TPM_QUOTE_INFO; + +#endif + +/* 11.4 TPM_QUOTE_INFO2 rev 87 + + This structure provides the mechanism for the TPM to quote the current values of a list of PCRs. +*/ + +typedef struct tdTPM_QUOTE_INFO2 { + TPM_STRUCTURE_TAG tag; /* This SHALL be TPM_TAG_QUOTE_INFO2 */ + BYTE fixed[4]; /* This SHALL always be the string 'QUT2' */ + TPM_NONCE externalData; /* 160 bits of externally supplied data */ + TPM_PCR_INFO_SHORT infoShort; /* */ +} TPM_QUOTE_INFO2; + +/* 12.1 TPM_EK_BLOB rev 87 + + This structure provides a wrapper to each type of structure that will be in use when the + endorsement key is in use. +*/ + +typedef struct tdTPM_EK_BLOB { + TPM_STRUCTURE_TAG tag; /* TPM_TAG_EK_BLOB */ + TPM_EK_TYPE ekType; /* This SHALL be set to reflect the type of blob in use */ + uint32_t blobSize; /* The size of the blob field */ + BYTE blob[MAX_COMMAND_SIZE]; /* The blob of information depending on the type */ +} TPM_EK_BLOB; + +/* 12.2 TPM_EK_BLOB_ACTIVATE rev 87 + + This structure contains the symmetric key to encrypt the identity credential. This structure + always is contained in a TPM_EK_BLOB. +*/ + +typedef struct tdTPM_EK_BLOB_ACTIVATE { + TPM_STRUCTURE_TAG tag; /* TPM_TAG_EK_BLOB_ACTIVATE */ + TPM_SYMMETRIC_KEY sessionKey; /* This SHALL be the session key used by the CA to encrypt + the TPM_IDENTITY_CREDENTIAL */ + TPM_DIGEST idDigest; /* This SHALL be the digest of the TPM identity public key + that is being certified by the CA */ + TPM_PCR_INFO_SHORT pcrInfo; /* This SHALL indicate the PCR's and localities */ +} TPM_EK_BLOB_ACTIVATE; + +#if 0 + +/* 12.3 TPM_EK_BLOB_AUTH rev 87 + + This structure contains the symmetric key to encrypt the identity credential. This structure + always is contained in a TPM_EK_BLOB. +*/ + +typedef struct tdTPM_EK_BLOB_AUTH { +#ifdef TPM_USE_TAG_IN_STRUCTURE + TPM_STRUCTURE_TAG tag; /* TPM_TAG_EK_BLOB_AUTH */ +#endif + TPM_SECRET authValue; /* This SHALL be the authorization value */ +} TPM_EK_BLOB_AUTH; + +/* 12.5 TPM_IDENTITY_CONTENTS rev 87 + + TPM_MakeIdentity uses this structure and the signature of this structure goes to a privacy CA + during the certification process. +*/ + +typedef struct tdTPM_IDENTITY_CONTENTS { + TPM_STRUCT_VER ver; /* This MUST be 1.1.0.0 */ + uint32_t ordinal; /* This SHALL be the ordinal of the TPM_MakeIdentity + command. */ + TPM_CHOSENID_HASH labelPrivCADigest; /* This SHALL be the result of hashing the chosen + identityLabel and privacyCA for the new TPM + identity */ + TPM_PUBKEY identityPubKey; /* This SHALL be the public key structure of the identity + key */ +} TPM_IDENTITY_CONTENTS; + +/* 12.8 TPM_ASYM_CA_CONTENTS rev 87 + + This structure contains the symmetric key to encrypt the identity credential. +*/ + +typedef struct tdTPM_ASYM_CA_CONTENTS { + TPM_SYMMETRIC_KEY sessionKey; /* This SHALL be the session key used by the CA to encrypt + the TPM_IDENTITY_CREDENTIAL */ + TPM_DIGEST idDigest; /* This SHALL be the digest of the TPM_PUBKEY of the key + that is being certified by the CA */ +} TPM_ASYM_CA_CONTENTS; + +/* + 14. Audit Structures +*/ + +/* 14.1 TPM_AUDIT_EVENT_IN rev 87 + + This structure provides the auditing of the command upon receipt of the command. It provides the + information regarding the input parameters. +*/ + +typedef struct tdTPM_AUDIT_EVENT_IN { +#ifdef TPM_USE_TAG_IN_STRUCTURE + TPM_STRUCTURE_TAG tag; /* TPM_TAG_AUDIT_EVENT_IN */ +#endif + TPM_DIGEST inputParms; /* Digest value according to the HMAC digest rules of the + "above the line" parameters (i.e. the first HMAC digest + calculation). When there are no HMAC rules, the input + digest includes all parameters including and after the + ordinal. */ + TPM_COUNTER_VALUE auditCount; /* The current value of the audit monotonic counter */ +} TPM_AUDIT_EVENT_IN; + +/* 14.2 TPM_AUDIT_EVENT_OUT rev 87 + + This structure reports the results of the command execution. It includes the return code and the + output parameters. +*/ + +typedef struct tdTPM_AUDIT_EVENT_OUT { +#ifdef TPM_USE_TAG_IN_STRUCTURE + TPM_STRUCTURE_TAG tag; /* TPM_TAG_AUDIT_EVENT_OUT */ +#endif + TPM_DIGEST outputParms; /* Digest value according to the HMAC digest rules of the + "above the line" parameters (i.e. the first HMAC digest + calculation). When there are no HMAC rules, the output + digest includes the return code, the ordinal, and all + parameters after the return code. */ + TPM_COUNTER_VALUE auditCount; /* The current value of the audit monotonic counter */ +} TPM_AUDIT_EVENT_OUT; + +/* + 18. Context structures +*/ + +/* 18.1 TPM_CONTEXT_BLOB rev 102 + + This is the header for the wrapped context. The blob contains all information necessary to reload + the context back into the TPM. + + The additional data is used by the TPM manufacturer to save information that will assist in the + reloading of the context. This area must not contain any shielded data. For instance, the field + could contain some size information that allows the TPM more efficient loads of the context. The + additional area could not contain one of the primes for a RSA key. + + To ensure integrity of the blob when using symmetric encryption the TPM vendor could use some + valid cipher chaining mechanism. To ensure the integrity without depending on correct + implementation, the TPM_CONTEXT_BLOB structure uses a HMAC of the entire structure using tpmProof + as the secret value. + + Since both additionalData and sensitiveData are informative, any or all of additionalData + could be moved to sensitiveData. +*/ + +#define TPM_CONTEXT_LABEL_SIZE 16 + +typedef struct tdTPM_CONTEXT_BLOB { +#ifdef TPM_USE_TAG_IN_STRUCTURE + TPM_STRUCTURE_TAG tag; /* MUST be TPM_TAG_CONTEXTBLOB */ +#endif + TPM_RESOURCE_TYPE resourceType; /* The resource type */ + TPM_HANDLE handle; /* Previous handle of the resource */ + BYTE label[TPM_CONTEXT_LABEL_SIZE]; /* Label for identification of the blob. Free format + area. */ + uint32_t contextCount; /* MUST be TPM_STANY_DATA -> contextCount when creating the + structure. This value is ignored for context blobs that + reference a key. */ + TPM_DIGEST integrityDigest; /* The integrity of the entire blob including the sensitive + area. This is a HMAC calculation with the entire + structure (including sensitiveData) being the hash and + tpmProof is the secret */ +#if 0 + uint32_t additionalSize; + [size_is(additionalSize)] BYTE* additionalData; + uint32_t sensitiveSize; + [size_is(sensitiveSize)] BYTE* sensitiveData; +#endif + TPM_SIZED_BUFFER additionalData; /* Additional information set by the TPM that helps define + and reload the context. The information held in this area + MUST NOT expose any information held in shielded + locations. This should include any IV for symmetric + encryption */ + TPM_SIZED_BUFFER sensitiveData; /* The normal information for the resource that can be + exported */ +} TPM_CONTEXT_BLOB; + +/* 18.2 TPM_CONTEXT_SENSITIVE rev 87 + + The internal areas that the TPM needs to encrypt and store off the TPM. + + This is an informative structure and the TPM can implement in any manner they wish. +*/ + +typedef struct tdTPM_CONTEXT_SENSITIVE { +#ifdef TPM_USE_TAG_IN_STRUCTURE + TPM_STRUCTURE_TAG tag; /* MUST be TPM_TAG_CONTEXT_SENSITIVE */ +#endif + TPM_NONCE contextNonce; /* On context blobs other than keys this MUST be + TPM_STANY_DATA - > contextNonceSession For keys the value + is TPM_STCLEAR_DATA -> contextNonceKey */ +#if 0 + uint32_t internalSize; + [size_is(internalSize)] BYTE* internalData; +#endif + TPM_SIZED_BUFFER internalData; /* The internal data area */ +} TPM_CONTEXT_SENSITIVE; + +#endif + +/* 19.2 TPM_NV_ATTRIBUTES rev 99 + + This structure allows the TPM to keep track of the data and permissions to manipulate the area. +*/ + +typedef struct tdTPM_NV_ATTRIBUTES { + TPM_STRUCTURE_TAG tag; /* TPM_TAG_NV_ATTRIBUTES */ + uint32_t attributes; /* The attribute area */ +} TPM_NV_ATTRIBUTES; + +/* 19.3 TPM_NV_DATA_PUBLIC rev 110 + + This structure represents the public description and controls on the NV area. + + bReadSTClear and bWriteSTClear are volatile, in that they are set FALSE at TPM_Startup(ST_Clear). + bWriteDefine is persistent, in that it remains TRUE through startup. + + A pcrSelect of 0 indicates that the digestAsRelease is not checked. In this case, the TPM is not + required to consume NVRAM space to store the digest, although it may do so. When + TPM_GetCapability (TPM_CAP_NV_INDEX) returns the structure, a TPM that does not store the digest + can return zero. A TPM that does store the digest may return either the digest or zero. +*/ + +typedef struct tdTPM_NV_DATA_PUBLIC { + TPM_STRUCTURE_TAG tag; /* This SHALL be TPM_TAG_NV_DATA_PUBLIC */ + TPM12_NV_INDEX nvIndex; /* The index of the data area */ + TPM_PCR_INFO_SHORT pcrInfoRead; /* The PCR selection that allows reading of the area */ + TPM_PCR_INFO_SHORT pcrInfoWrite; /* The PCR selection that allows writing of the area */ + TPM_NV_ATTRIBUTES permission; /* The permissions for manipulating the area */ + TPM_BOOL bReadSTClear; /* Set to FALSE on each TPM_Startup(ST_Clear) and set to + TRUE after a ReadValuexxx with datasize of 0 */ + TPM_BOOL bWriteSTClear; /* Set to FALSE on each TPM_Startup(ST_CLEAR) and set to + TRUE after a WriteValuexxx with a datasize of 0. */ + TPM_BOOL bWriteDefine; /* Set to FALSE after TPM_NV_DefineSpace and set to TRUE + after a successful WriteValuexxx with a datasize of 0 */ + uint32_t dataSize; /* The size of the data area in bytes */ +} TPM_NV_DATA_PUBLIC; + +#if 0 + +/* 19.4 TPM_NV_DATA_SENSITIVE rev 101 + + This is an internal structure that the TPM uses to keep the actual NV data and the controls + regarding the area. +*/ + +typedef struct tdTPM_NV_DATA_SENSITIVE { +#ifdef TPM_USE_TAG_IN_STRUCTURE + TPM_STRUCTURE_TAG tag; /* This SHALL be TPM_TAG_NV_DATA_SENSITIVE */ +#endif + TPM_NV_DATA_PUBLIC pubInfo; /* The public information regarding this area */ + TPM_AUTHDATA authValue; /* The authorization value to manipulate the value */ + BYTE *data; /* The data area. This MUST not contain any sensitive information as + the TPM does not provide any confidentiality on the data. */ + /* NOTE Added kg */ + TPM_DIGEST digest; /* for OSAP comparison */ +} TPM_NV_DATA_SENSITIVE; + +typedef struct tdTPM_NV_INDEX_ENTRIES { + uint32_t nvIndexCount; /* number of entries */ + TPM_NV_DATA_SENSITIVE *tpm_nvindex_entry; /* array of TPM_NV_DATA_SENSITIVE */ +} TPM_NV_INDEX_ENTRIES; + +/* TPM_NV_DATA_ST + + This is a cache of the the NV defined space volatile flags, used during error rollback +*/ + +typedef struct tdTPM_NV_DATA_ST { + TPM12_NV_INDEX nvIndex; /* The index of the data area */ + TPM_BOOL bReadSTClear; + TPM_BOOL bWriteSTClear; +} TPM_NV_DATA_ST; + +#endif + +/* + 21. Capability areas +*/ + +/* 21.6 TPM_CAP_VERSION_INFO rev 99 + + This structure is an output from a TPM_GetCapability -> TPM_CAP_VERSION_VAL request. TPM returns + the current version and revision of the TPM. + + The specLevel and errataRev are defined in the document "Specification and File Naming + Conventions" + + The tpmVendorID is a value unique to each vendor. It is defined in the document "TCG Vendor + Naming". + + The vendor specific area allows the TPM vendor to provide support for vendor options. The TPM + vendor may define the area to the TPM vendor's needs. +*/ + +typedef struct tdTPM_CAP_VERSION_INFO { + TPM_STRUCTURE_TAG tag; /* MUST be TPM_TAG_CAP_VERSION_INFO */ + TPM_VERSION version; /* The version and revision */ + uint16_t specLevel; /* A number indicating the level of ordinals supported */ + BYTE errataRev; /* A number indicating the errata version of the specification */ + BYTE tpmVendorID[4]; /* The vendor ID unique to each TPM manufacturer. */ + uint16_t vendorSpecificSize; /* The size of the vendor specific area */ + BYTE vendorSpecific[MAX_COMMAND_SIZE]; /* Vendor specific information */ +} TPM_CAP_VERSION_INFO; + +/* 21.10 TPM_DA_ACTION_TYPE rev 100 + + This structure indicates the action taken when the dictionary attack mitigation logic is active, + when TPM_DA_STATE is TPM_DA_STATE_ACTIVE. +*/ + +typedef struct tdTPM_DA_ACTION_TYPE { + TPM_STRUCTURE_TAG tag; /* MUST be TPM_TAG_DA_ACTION_TYPE */ + uint32_t actions; /* The action taken when TPM_DA_STATE is TPM_DA_STATE_ACTIVE. */ +} TPM_DA_ACTION_TYPE; + +/* 21.7 TPM_DA_INFO rev 100 + + This structure is an output from a TPM_GetCapability -> TPM_CAP_DA_LOGIC request if + TPM_PERMANENT_FLAGS -> disableFullDALogicInfo is FALSE. + + It returns static information describing the TPM response to authorization failures that might + indicate a dictionary attack and dynamic information regarding the current state of the + dictionary attack mitigation logic. +*/ + +typedef struct tdTPM_DA_INFO { + TPM_STRUCTURE_TAG tag; /* MUST be TPM_TAG_DA_INFO */ + TPM_DA_STATE state; /* Dynamic. The actual state of the dictionary attack mitigation + logic. See 21.9. */ + uint16_t currentCount; /* Dynamic. The actual count of the authorization failure counter + for the selected entity type */ + uint16_t thresholdCount; /* Static. Dictionary attack mitigation threshold count for the + selected entity type */ + TPM_DA_ACTION_TYPE actionAtThreshold; /* Static Action of the TPM when currentCount passes + thresholdCount. See 21.10. */ + uint32_t actionDependValue; /* Dynamic. Action being taken when the dictionary attack + mitigation logic is active. E.g., when actionAtThreshold is + TPM_DA_ACTION_TIMEOUT, this is the lockout time remaining in + seconds. */ + uint32_t vendorDataSize; + uint8_t vendorData[2048]; /* Vendor specific data field */ +} TPM_DA_INFO; + +/* 21.8 TPM_DA_INFO_LIMITED rev 100 + + This structure is an output from a TPM_GetCapability -> TPM_CAP_DA_LOGIC request if + TPM_PERMANENT_FLAGS -> disableFullDALogicInfo is TRUE. + + It returns static information describing the TPM response to authorization failures that might + indicate a dictionary attack and dynamic information regarding the current state of the + dictionary attack mitigation logic. This structure omits information that might aid an attacker. +*/ + +typedef struct tdTPM_DA_INFO_LIMITED { + TPM_STRUCTURE_TAG tag; /* MUST be TPM_TAG_DA_INFO_LIMITED */ + TPM_DA_STATE state; /* Dynamic. The actual state of the dictionary attack mitigation + logic. See 21.9. */ + TPM_DA_ACTION_TYPE actionAtThreshold; /* Static Action of the TPM when currentCount passes + thresholdCount. See 21.10. */ + uint32_t vendorDataSize; + uint8_t vendorData[2048]; /* Vendor specific data field */ +} TPM_DA_INFO_LIMITED; + +#endif diff --git a/libstb/tss2/ibmtss/tpmtypes12.h b/libstb/tss2/ibmtss/tpmtypes12.h new file mode 100644 index 0000000..0b1ed08 --- /dev/null +++ b/libstb/tss2/ibmtss/tpmtypes12.h @@ -0,0 +1,148 @@ +/********************************************************************************/ +/* */ +/* TPM Types */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: tpmtypes12.h 1257 2018-06-27 20:52:08Z kgoldman $ */ +/* */ +/* (c) Copyright IBM Corporation 2006, 2018. */ +/* */ +/* All rights reserved. */ +/* */ +/* Redistribution and use in source and binary forms, with or without */ +/* modification, are permitted provided that the following conditions are */ +/* met: */ +/* */ +/* Redistributions of source code must retain the above copyright notice, */ +/* this list of conditions and the following disclaimer. */ +/* */ +/* 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. */ +/* */ +/* Neither the names of the IBM Corporation nor the names of its */ +/* contributors may be used to endorse or promote products derived from */ +/* this software without specific prior written permission. */ +/* */ +/* 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 TPMTYPES12_H +#define TPMTYPES12_H + +#include <stdint.h> + +#ifdef TPM_WINDOWS +#include <winsock2.h> +#include <windows.h> +#endif +#if defined (TPM_POSIX) || defined (TPM_SYSTEM_P) +#include <netinet/in.h> /* for byte order conversions */ +#endif + +#include <ibmtss/BaseTypes.h> + +/* 2.2.1 Basic data types rev 87 */ +//typedef unsigned char BYTE; /* Basic byte used to transmit all character fields. */ +typedef unsigned char TPM_BOOL; /* TRUE/FALSE field. TRUE = 0x01, FALSE = 0x00 Use TPM_BOOL + because MS VC++ defines BOOL on Windows */ + +/* 2.2.2 Boolean types rev 107 */ + +#undef TRUE +#define TRUE 0x01 /* Assertion */ +#undef FALSE +#define FALSE 0x00 /* Contradiction */ + +/* 2.2.3 Helper redefinitions rev 101 + + The following definitions are to make the definitions more explicit and easier to read. + + NOTE: They cannot be changed without breaking the serialization. +*/ + +typedef BYTE TPM_AUTH_DATA_USAGE; /* Indicates the conditions where it is required that + authorization be presented. */ +typedef BYTE TPM_PAYLOAD_TYPE; /* The information as to what the payload is in an encrypted + structure */ +typedef BYTE TPM_VERSION_BYTE; /* The version info breakdown */ +typedef BYTE TPM_DA_STATE; /* The state of the dictionary attack mitigation logic */ + +/* added kgold */ +typedef BYTE TPM_ENT_TYPE; /* LSB of TPM_ENTITY_TYPE */ +typedef BYTE TPM_ADIP_ENC_SCHEME; /* MSB of TPM_ENTITY_TYPE */ + +typedef uint16_t TPM_PROTOCOL_ID; /* The protocol in use. */ +typedef uint16_t TPM_STARTUP_TYPE; /* Indicates the start state. */ +typedef uint16_t TPM_ENC_SCHEME; /* The definition of the encryption scheme. */ +typedef uint16_t TPM_SIG_SCHEME; /* The definition of the signature scheme. */ +typedef uint16_t TPM_MIGRATE_SCHEME; /* The definition of the migration scheme */ +typedef uint16_t TPM_PHYSICAL_PRESENCE; /* Sets the state of the physical presence mechanism. */ +typedef uint16_t TPM_ENTITY_TYPE; /* Indicates the types of entity that are supported by the + TPM. */ +typedef uint16_t TPM_KEY_USAGE; /* Indicates the permitted usage of the key. */ +typedef uint16_t TPM_EK_TYPE; /* The type of asymmetric encrypted structure in use by the + endorsement key */ +typedef uint16_t TPM_STRUCTURE_TAG; /* The tag for the structure */ +typedef uint16_t TPM_PLATFORM_SPECIFIC; /* The platform specific spec to which the information + relates to */ +typedef uint32_t TPM_COMMAND_CODE; /* The command ordinal. */ +typedef uint32_t TPM_CAPABILITY_AREA; /* Identifies a TPM capability area. */ +typedef uint32_t TPM_KEY_FLAGS; /* Indicates information regarding a key. */ +//typedef uint32_t TPM_ALGORITHM_ID; /* Indicates the type of algorithm. */ +//typedef uint32_t TPM_MODIFIER_INDICATOR; /* The locality modifier */ +typedef uint32_t TPM_ACTUAL_COUNT; /* The actual number of a counter. */ +typedef uint32_t TPM_TRANSPORT_ATTRIBUTES; /* Attributes that define what options are in use + for a transport session */ +typedef uint32_t TPM_AUTHHANDLE; /* Handle to an authorization session */ +typedef uint32_t TPM_DIRINDEX; /* Index to a DIR register */ +typedef uint32_t TPM_KEY_HANDLE; /* The area where a key is held assigned by the TPM. */ +typedef uint32_t TPM_PCRINDEX; /* Index to a PCR register */ +typedef uint32_t TPM_RESULT; /* The return code from a function */ +typedef uint32_t TPM_RESOURCE_TYPE; /* The types of resources that a TPM may have using internal + resources */ +typedef uint32_t TPM_KEY_CONTROL; /* Allows for controlling of the key when loaded and how to + handle TPM_Startup issues */ +typedef uint32_t TPM12_NV_INDEX; /* The index into the NV storage area */ +typedef uint32_t TPM_FAMILY_ID; /* The family ID. Families ID's are automatically assigned a + sequence number by the TPM. A trusted process can set the + FamilyID value in an individual row to zero, which + invalidates that row. The family ID resets to zero on + each change of TPM Owner. */ +typedef uint32_t TPM_FAMILY_VERIFICATION; /* A value used as a label for the most recent + verification of this family. Set to zero when not + in use. */ +typedef uint32_t TPM_STARTUP_EFFECTS; /* How the TPM handles var */ +typedef uint32_t TPM_SYM_MODE; /* The mode of a symmetric encryption */ +typedef uint32_t TPM_FAMILY_FLAGS; /* The family flags */ +typedef uint32_t TPM_DELEGATE_INDEX; /* The index value for the delegate NV table */ +typedef uint32_t TPM_CMK_DELEGATE; /* The restrictions placed on delegation of CMK + commands */ +typedef uint32_t TPM_COUNT_ID; /* The ID value of a monotonic counter */ +typedef uint32_t TPM_REDIT_COMMAND; /* A command to execute */ +typedef uint32_t TPM_TRANSHANDLE; /* A transport session handle */ +//typedef uint32_t TPM_HANDLE; /* A generic handle could be key, transport etc. */ +typedef uint32_t TPM_FAMILY_OPERATION; /* What operation is happening */ +#ifdef TPM_VTPM +typedef uint32_t TPM_INSTANCE_HANDLE; /* Handle to a virtual TPM instance */ +typedef uint32_t TPM_CREATION_MASK; /* TPM_CreateInstance creation mask */ +#endif + +/* Not in specification */ + +typedef uint16_t TPM_TAG; /* The command and response tags */ + +typedef unsigned char * TPM_SYMMETRIC_KEY_TOKEN; /* abstract symmetric key token */ +typedef unsigned char * TPM_BIGNUM; /* abstract bignum */ + +#endif diff --git a/libstb/tss2/ibmtss/tss.h b/libstb/tss2/ibmtss/tss.h new file mode 100644 index 0000000..911d050 --- /dev/null +++ b/libstb/tss2/ibmtss/tss.h @@ -0,0 +1,114 @@ +/********************************************************************************/ +/* */ +/* TSS Primary API */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* */ +/* (c) Copyright IBM Corporation 2015 - 2019. */ +/* */ +/* All rights reserved. */ +/* */ +/* Redistribution and use in source and binary forms, with or without */ +/* modification, are permitted provided that the following conditions are */ +/* met: */ +/* */ +/* Redistributions of source code must retain the above copyright notice, */ +/* this list of conditions and the following disclaimer. */ +/* */ +/* 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. */ +/* */ +/* Neither the names of the IBM Corporation nor the names of its */ +/* contributors may be used to endorse or promote products derived from */ +/* this software without specific prior written permission. */ +/* */ +/* 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 TSS_H +#define TSS_H + +#include <ibmtss/TPM_Types.h> +#include <ibmtss/Parameters.h> +#ifdef TPM_TPM12 +#include <ibmtss/Parameters12.h> +#endif + +/* include this as a convenience to applications */ +#include <ibmtss/tsserror.h> +#include <ibmtss/tssprint.h> + +typedef struct TSS_CONTEXT TSS_CONTEXT; + +#define TPM_TRACE_LEVEL 1 +#define TPM_DATA_DIR 2 +#define TPM_COMMAND_PORT 3 +#define TPM_PLATFORM_PORT 4 +#define TPM_SERVER_NAME 5 +#define TPM_INTERFACE_TYPE 6 +#define TPM_DEVICE 7 +#define TPM_ENCRYPT_SESSIONS 8 +#define TPM_SERVER_TYPE 9 + +#ifdef __cplusplus +extern "C" { +#endif + + /* extra parameters as required */ + + /* TPM 2.0 */ + + typedef struct { + const char *bindPassword; + TPM2B_DIGEST salt; + } StartAuthSession_Extra; + + typedef union { + StartAuthSession_Extra StartAuthSession; + } EXTRA_PARAMETERS; + + /* TPM 1.2 */ + + typedef struct { + const char *usagePassword; + } OSAP_Extra; + + typedef union { + OSAP_Extra OSAP; + } EXTRA12_PARAMETERS; + + LIB_EXPORT + TPM_RC TSS_Create(TSS_CONTEXT **tssContext); + + LIB_EXPORT + TPM_RC TSS_Delete(TSS_CONTEXT *tssContext); + + LIB_EXPORT + TPM_RC TSS_Execute(TSS_CONTEXT *tssContext, + RESPONSE_PARAMETERS *out, + COMMAND_PARAMETERS *in, + EXTRA_PARAMETERS *extra, + TPM_CC commandCode, + ...); + + LIB_EXPORT + TPM_RC TSS_SetProperty(TSS_CONTEXT *tssContext, + int property, + const char *value); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libstb/tss2/ibmtss/tsscrypto.h b/libstb/tss2/ibmtss/tsscrypto.h new file mode 100644 index 0000000..89ea24e --- /dev/null +++ b/libstb/tss2/ibmtss/tsscrypto.h @@ -0,0 +1,157 @@ +/********************************************************************************/ +/* */ +/* TSS Library Dependent Crypto Support */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: tsscrypto.h 1257 2018-06-27 20:52:08Z kgoldman $ */ +/* */ +/* (c) Copyright IBM Corporation 2015, 2018. */ +/* */ +/* All rights reserved. */ +/* */ +/* Redistribution and use in source and binary forms, with or without */ +/* modification, are permitted provided that the following conditions are */ +/* met: */ +/* */ +/* Redistributions of source code must retain the above copyright notice, */ +/* this list of conditions and the following disclaimer. */ +/* */ +/* 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. */ +/* */ +/* Neither the names of the IBM Corporation nor the names of its */ +/* contributors may be used to endorse or promote products derived from */ +/* this software without specific prior written permission. */ +/* */ +/* 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. */ +/********************************************************************************/ + +/* This is a semi-public header. The API should be stable, but is less guaranteed. + + It is useful for applications that need some basic crypto functions. +*/ + +#ifndef TSSCRYPTO_H +#define TSSCRYPTO_H + +#include <stdint.h> +#include <stdio.h> + +#ifndef TPM_TSS_NORSA +#include <openssl/rsa.h> +#endif +#ifndef TPM_TSS_NOECC +#include <openssl/ec.h> +#endif + +#include <ibmtss/tss.h> + +/* ECC salt */ + +#ifndef TPM_TSS_NOECC +typedef struct +{ + EC_GROUP *G; + BN_CTX *ctx; +} CURVE_DATA; +#endif /* TPM_TSS_NOECC */ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef TSS_CRYPTO_INIT + LIB_EXPORT + TPM_RC TSS_Crypto_Init(void); +#endif + + LIB_EXPORT + TPM_RC TSS_Hash_Generate_valist(TPMT_HA *digest, + va_list ap); + LIB_EXPORT + TPM_RC TSS_HMAC_Generate_valist(TPMT_HA *digest, + const TPM2B_KEY *hmacKey, + va_list ap); + LIB_EXPORT void TSS_XOR(unsigned char *out, + const unsigned char *in1, + const unsigned char *in2, + size_t length); + LIB_EXPORT + TPM_RC TSS_RandBytes(unsigned char *buffer, uint32_t size); + + LIB_EXPORT + TPM_RC TSS_RSA_padding_add_PKCS1_OAEP(unsigned char *em, uint32_t emLen, + const unsigned char *from, uint32_t fLen, + const unsigned char *p, + int plen, + TPMI_ALG_HASH halg); +#ifndef TPM_TSS_NORSA + LIB_EXPORT + TPM_RC TSS_RSAPublicEncrypt(unsigned char* encrypt_data, + size_t encrypt_data_size, + const unsigned char *decrypt_data, + size_t decrypt_data_size, + unsigned char *narr, + uint32_t nbytes, + unsigned char *earr, + uint32_t ebytes, + unsigned char *p, + int pl, + TPMI_ALG_HASH halg); + LIB_EXPORT + TPM_RC TSS_RSAGeneratePublicToken(RSA **rsa_pub_key, /* freed by caller */ + const unsigned char *narr, /* public modulus */ + uint32_t nbytes, + const unsigned char *earr, /* public exponent */ + uint32_t ebytes); + +#endif +#ifndef TPM_TSS_NOECC + TPM_RC TSS_ECC_Salt(TPM2B_DIGEST *salt, + TPM2B_ENCRYPTED_SECRET *encryptedSalt, + TPMT_PUBLIC *publicArea); + +#endif + TPM_RC TSS_AES_GetEncKeySize(size_t *tssSessionEncKeySize); + TPM_RC TSS_AES_GetDecKeySize(size_t *tssSessionDecKeySize); + TPM_RC TSS_AES_KeyGenerate(void *tssSessionEncKey, + void *tssSessionDecKey); + TPM_RC TSS_AES_Encrypt(void *tssSessionEncKey, + unsigned char **encrypt_data, + uint32_t *encrypt_length, + const unsigned char *decrypt_data, + uint32_t decrypt_length); + TPM_RC TSS_AES_Decrypt(void *tssSessionDecKey, + unsigned char **decrypt_data, + uint32_t *decrypt_length, + const unsigned char *encrypt_data, + uint32_t encrypt_length); + TPM_RC TSS_AES_EncryptCFB(uint8_t *dOut, + uint32_t keySizeInBits, + uint8_t *key, + uint8_t *iv, + uint32_t dInSize, + uint8_t *dIn); + TPM_RC TSS_AES_DecryptCFB(uint8_t *dOut, + uint32_t keySizeInBits, + uint8_t *key, + uint8_t *iv, + uint32_t dInSize, + uint8_t *dIn); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libstb/tss2/ibmtss/tsscryptoh.h b/libstb/tss2/ibmtss/tsscryptoh.h new file mode 100644 index 0000000..b6fdf0a --- /dev/null +++ b/libstb/tss2/ibmtss/tsscryptoh.h @@ -0,0 +1,107 @@ +/********************************************************************************/ +/* */ +/* TSS Library Independent Crypto Support */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* */ +/* (c) Copyright IBM Corporation 2015 - 2019. */ +/* */ +/* All rights reserved. */ +/* */ +/* Redistribution and use in source and binary forms, with or without */ +/* modification, are permitted provided that the following conditions are */ +/* met: */ +/* */ +/* Redistributions of source code must retain the above copyright notice, */ +/* this list of conditions and the following disclaimer. */ +/* */ +/* 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. */ +/* */ +/* Neither the names of the IBM Corporation nor the names of its */ +/* contributors may be used to endorse or promote products derived from */ +/* this software without specific prior written permission. */ +/* */ +/* 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. */ +/********************************************************************************/ + +/* This is a semi-public header. The API should be stable, but is less guaranteed. + + It is useful for applications that need some basic crypto functions. +*/ + +#ifndef TSSCRYPTOH_H +#define TSSCRYPTOH_H + +#ifdef __cplusplus +extern "C" { +#endif + + LIB_EXPORT + uint16_t TSS_GetDigestSize(TPM_ALG_ID hashAlg) +#ifdef __ULTRAVISOR__ + __attribute__ ((const)) +#endif + ; + + LIB_EXPORT + uint16_t TSS_GetDigestBlockSize(TPM_ALG_ID hashAlg) +#ifdef __ULTRAVISOR__ + __attribute__ ((const)) +#endif + ; + + LIB_EXPORT + TPM_RC TSS_Hash_Generate(TPMT_HA *digest, + ...); + + LIB_EXPORT + TPM_RC TSS_HMAC_Generate(TPMT_HA *digest, + const TPM2B_KEY *hmacKey, + ...); + LIB_EXPORT + TPM_RC TSS_HMAC_Verify(TPMT_HA *expect, + const TPM2B_KEY *hmacKey, + UINT32 sizeInBytes, + ...); + LIB_EXPORT + TPM_RC TSS_KDFA(uint8_t *keyStream, + TPM_ALG_ID hashAlg, + const TPM2B *key, + const char *label, + const TPM2B *contextU, + const TPM2B *contextV, + uint32_t sizeInBits); + + LIB_EXPORT + TPM_RC TSS_KDFE(uint8_t *keyStream, + TPM_ALG_ID hashAlg, + const TPM2B *key, + const char *label, + const TPM2B *contextU, + const TPM2B *contextV, + uint32_t sizeInBits); + + uint16_t TSS_Sym_GetBlockSize(TPM_ALG_ID symmetricAlg, + uint16_t keySizeInBits) +#ifdef __ULTRAVISOR__ + __attribute__ ((const)) +#endif + ; + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libstb/tss2/ibmtss/tsserror.h b/libstb/tss2/ibmtss/tsserror.h new file mode 100644 index 0000000..72aceb4 --- /dev/null +++ b/libstb/tss2/ibmtss/tsserror.h @@ -0,0 +1,114 @@ +/********************************************************************************/ +/* */ +/* TSS Error Codes */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: tsserror.h 1257 2018-06-27 20:52:08Z kgoldman $ */ +/* */ +/* (c) Copyright IBM Corporation 2015, 2017. */ +/* */ +/* All rights reserved. */ +/* */ +/* Redistribution and use in source and binary forms, with or without */ +/* modification, are permitted provided that the following conditions are */ +/* met: */ +/* */ +/* Redistributions of source code must retain the above copyright notice, */ +/* this list of conditions and the following disclaimer. */ +/* */ +/* 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. */ +/* */ +/* Neither the names of the IBM Corporation nor the names of its */ +/* contributors may be used to endorse or promote products derived from */ +/* this software without specific prior written permission. */ +/* */ +/* 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. */ +/********************************************************************************/ + +/* This is a public header. That defines TSS error codes. + + tss.h includes it for convenience. +*/ + +#ifndef TSSERROR_H +#define TSSERROR_H + +/* the base for these errors is 11 << 16 = 000bxxxx */ + +#define TSS_RC_OUT_OF_MEMORY 0x000b0001 /* Out of memory,(malloc failed) */ +#define TSS_RC_ALLOC_INPUT 0x000b0002 /* The input to an allocation is not NULL */ +#define TSS_RC_MALLOC_SIZE 0x000b0003 /* The malloc size is too large or zero */ +#define TSS_RC_INSUFFICIENT_BUFFER 0x000b0004 /* A buffer was insufficient for a copy */ +#define TSS_RC_BAD_PROPERTY 0x000b0005 /* The property parameter is out of range */ +#define TSS_RC_BAD_PROPERTY_VALUE 0x000b0006 /* The property value is invalid */ +#define TSS_RC_INSUPPORTED_INTERFACE 0x000b0007 /* The TPM interface type is not supported */ +#define TSS_RC_NO_CONNECTION 0x000b0008 /* Failure connecting to lower layer */ +#define TSS_RC_BAD_CONNECTION 0x000b0009 /* Failure communicating with lower layer */ +#define TSS_RC_MALFORMED_RESPONSE 0x000b000a /* A response packet was fundamentally malformed */ +#define TSS_RC_NULL_PARAMETER 0x000b000b /* A required parameter was NULL */ +#define TSS_RC_NOT_IMPLEMENTED 0x000b000c /* TSS function is not implemented */ +#define TSS_RC_FILE_OPEN 0x000b0010 /* The file could not be opened */ +#define TSS_RC_FILE_SEEK 0x000b0011 /* A file seek failed */ +#define TSS_RC_FILE_FTELL 0x000b0012 /* A file ftell failed */ +#define TSS_RC_FILE_READ 0x000b0013 /* A file read failed */ +#define TSS_RC_FILE_CLOSE 0x000b0014 /* A file close failed */ +#define TSS_RC_FILE_WRITE 0x000b0015 /* A file write failed */ +#define TSS_RC_FILE_REMOVE 0x000b0016 /* A file remove failed */ +#define TSS_RC_RNG_FAILURE 0x000b0020 /* Random number generator failed */ +#define TSS_RC_BAD_PWAP_NONCE 0x000b0030 /* Bad PWAP response nonce */ +#define TSS_RC_BAD_PWAP_ATTRIBUTES 0x000b0031 /* Bad PWAP response attributes */ +#define TSS_RC_BAD_PWAP_HMAC 0x000b0032 /* Bad PWAP response HMAC */ +#define TSS_RC_NAME_NOT_IMPLEMENTED 0x000b0040 /* Name calculation not implemented for handle type */ +#define TSS_RC_MALFORMED_NV_PUBLIC 0x000b0041 /* The NV public structure does not match the name */ +#define TSS_RC_NAME_FILENAME 0x000b0042 /* The name filename function has inconsistent arguments */ +#define TSS_RC_MALFORMED_PUBLIC 0x000b0043 /* The public structure does not match the name */ +#define TSS_RC_DECRYPT_SESSIONS 0x000b0050 /* More than one command decrypt session */ +#define TSS_RC_ENCRYPT_SESSIONS 0x000b0051 /* More than one response encrypt session */ +#define TSS_RC_NO_DECRYPT_PARAMETER 0x000b0052 /* Command has no decrypt parameter */ +#define TSS_RC_NO_ENCRYPT_PARAMETER 0x000b0053 /* Response has no encrypt parameter */ +#define TSS_RC_BAD_DECRYPT_ALGORITHM 0x000b0054 /* Session had an unimplemented decrypt symmetric algorithm */ +#define TSS_RC_BAD_ENCRYPT_ALGORITHM 0x000b0055 /* Session had an unimplemented encrypt symmetric algorithm */ +#define TSS_RC_AES_ENCRYPT_FAILURE 0x000b0056 /* AES encryption failed */ +#define TSS_RC_AES_DECRYPT_FAILURE 0x000b0057 /* AES decryption failed */ +#define TSS_RC_BAD_ENCRYPT_SIZE 0x000b0058 /* Parameter encryption size mismatch */ +#define TSS_RC_AES_KEYGEN_FAILURE 0x000b0059 /* AES key generation failed */ +#define TSS_RC_SESSION_NUMBER 0x000b005a /* session number out of range */ +#define TSS_RC_BAD_SALT_KEY 0x000b0060 /* tpmKey is unsuitable for salt */ +#define TSS_RC_KDFA_FAILED 0x000b0070 /* KDFa function failed */ +#define TSS_RC_HMAC 0x000b0071 /* An HMAC calculation failed */ +#define TSS_RC_HMAC_SIZE 0x000b0072 /* Response HMAC is the wrong size */ +#define TSS_RC_HMAC_VERIFY 0x000b0073 /* HMAC does not verify */ +#define TSS_RC_BAD_HASH_ALGORITHM 0x000b0074 /* Unimplemented hash algorithm */ +#define TSS_RC_HASH 0x000b0075 /* A hash calculation failed */ +#define TSS_RC_RSA_KEY_CONVERT 0x000b0076 /* RSA key conversion failed */ +#define TSS_RC_RSA_PADDING 0x000b0077 /* RSA add padding failed */ +#define TSS_RC_RSA_ENCRYPT 0x000b0078 /* RSA public encrypt failed */ +#define TSS_RC_BIGNUM 0x000b0079 /* BIGNUM operation failed */ +#define TSS_RC_RSA_SIGNATURE 0x000b007a /* RSA signature is bad */ +#define TSS_RC_EC_SIGNATURE 0x000b007b /* EC signature is bad */ +#define TSS_RC_EC_KEY_CONVERT 0x000b007c /* EC key conversion failed */ +#define TSS_RC_BAD_SIGNATURE_ALGORITHM 0x000b007d /* Unimplemented signature algorithm */ +#define TSS_RC_X509_ERROR 0x000b007e /* X509 parse error */ +#define TSS_RC_COMMAND_UNIMPLEMENTED 0x000b0080 /* Unimplemented command */ +#define TSS_RC_IN_PARAMETER 0x000b0081 /* Bad in parameter to TSS_Execute */ +#define TSS_RC_OUT_PARAMETER 0x000b0082 /* Bad out parameter to TSS_Execute */ +#define TSS_RC_BAD_HANDLE_NUMBER 0x000b0083 /* Bad handle number for this command */ +#define TSS_RC_KDFE_FAILED 0x000b0084 /* KDFe function failed */ +#define TSS_RC_EC_EPHEMERAL_FAILURE 0x000b0085 /* Failed while making or using EC ephemeral key */ +#define TSS_RC_FAIL 0x000b0086 /* TSS internal failure */ +#define TSS_RC_NO_SESSION_SLOT 0x000b0090 /* TSS context has no session slot for handle */ +#define TSS_RC_NO_OBJECTPUBLIC_SLOT 0x000b0091 /* TSS context has no object public slot for handle */ +#define TSS_RC_NO_NVPUBLIC_SLOT 0x000b0092 /* TSS context has no NV public slot for handle */ +#endif diff --git a/libstb/tss2/ibmtss/tsserror12.h b/libstb/tss2/ibmtss/tsserror12.h new file mode 100644 index 0000000..a27e5f0 --- /dev/null +++ b/libstb/tss2/ibmtss/tsserror12.h @@ -0,0 +1,248 @@ +/********************************************************************************/ +/* */ +/* TPM 1.2 Error Response */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* */ +/* (c) Copyright IBM Corporation 2006, 2010. */ +/* */ +/* All rights reserved. */ +/* */ +/* Redistribution and use in source and binary forms, with or without */ +/* modification, are permitted provided that the following conditions are */ +/* met: */ +/* */ +/* Redistributions of source code must retain the above copyright notice, */ +/* this list of conditions and the following disclaimer. */ +/* */ +/* 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. */ +/* */ +/* Neither the names of the IBM Corporation nor the names of its */ +/* contributors may be used to endorse or promote products derived from */ +/* this software without specific prior written permission. */ +/* */ +/* 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 TPM_ERROR_H +#define TPM_ERROR_H + +/* 16. Return codes rev 99 + + The TPM has five types of return code. One indicates successful operation and four indicate + failure. TPM_SUCCESS (00000000) indicates successful execution. The failure reports are: + TPM defined fatal errors (00000001 to 000003FF), vendor defined fatal errors (00000400 to + 000007FF), TPM defined non-fatal errors (00000800 to 00000BFF), and vendor defined + non-fatal errors (00000C00 to 00000FFF). + + The range of vendor defined non-fatal errors was determined by the TSS-WG, which defined + XXXX YCCC with XXXX as OS specific and Y defining the TSS SW stack layer (0: TPM layer) + + All failure cases return only a non-authenticated fixed set of information. This is because + the failure may have been due to authentication or other factors, and there is no possibility + of producing an authenticated response. + + Fatal errors also terminate any authorization sessions. This is a result of returning only the + error code, as there is no way to return the nonces necessary to maintain an authorization + session. Non-fatal errors do not terminate authorization sessions. + + The return code MUST use the following base. The return code MAY be TCG defined or vendor + defined. */ + +#define TPM_BASE 0x0 /* The start of TPM return codes */ +#define TPM_SUCCESS TPM_BASE /* Successful completion of the operation */ +#define TPM_VENDOR_ERROR TPM_Vendor_Specific32 /* Mask to indicate that the error code is + vendor specific for vendor specific + commands. */ +#define TPM_NON_FATAL 0x00000800 /* Mask to indicate that the error code is a non-fatal + failure. */ + +/* TPM-defined fatal error codes */ + +#define TPM_AUTHFAIL TPM_BASE + 1 /* Authentication failed */ +#define TPM_BADINDEX TPM_BASE + 2 /* The index to a PCR, DIR or other register is + incorrect */ +#define TPM_BAD_PARAMETER TPM_BASE + 3 /* One or more parameter is bad */ +#define TPM_AUDITFAILURE TPM_BASE + 4 /* An operation completed successfully but the auditing + of that operation failed. */ +#define TPM_CLEAR_DISABLED TPM_BASE + 5 /* The clear disable flag is set and all clear + operations now require physical access */ +#define TPM_DEACTIVATED TPM_BASE + 6 /* The TPM is deactivated */ +#define TPM_DISABLED TPM_BASE + 7 /* The TPM is disabled */ +#define TPM_DISABLED_CMD TPM_BASE + 8 /* The target command has been disabled */ +#define TPM_FAIL TPM_BASE + 9 /* The operation failed */ +#define TPM_BAD_ORDINAL TPM_BASE + 10 /* The ordinal was unknown or inconsistent */ +#define TPM_INSTALL_DISABLED TPM_BASE + 11 /* The ability to install an owner is disabled */ +#define TPM_INVALID_KEYHANDLE TPM_BASE + 12 /* The key handle presented was invalid */ +#define TPM_KEYNOTFOUND TPM_BASE + 13 /* The target key was not found */ +#define TPM_INAPPROPRIATE_ENC TPM_BASE + 14 /* Unacceptable encryption scheme */ +#define TPM_MIGRATEFAIL TPM_BASE + 15 /* Migration authorization failed */ +#define TPM_INVALID_PCR_INFO TPM_BASE + 16 /* PCR information could not be interpreted */ +#define TPM_NOSPACE TPM_BASE + 17 /* No room to load key. */ +#define TPM_NOSRK TPM_BASE + 18 /* There is no SRK set */ +#define TPM_NOTSEALED_BLOB TPM_BASE + 19 /* An encrypted blob is invalid or was not created by + this TPM */ +#define TPM_OWNER_SET TPM_BASE + 20 /* There is already an Owner */ +#define TPM_RESOURCES TPM_BASE + 21 /* The TPM has insufficient internal resources to + perform the requested action. */ +#define TPM_SHORTRANDOM TPM_BASE + 22 /* A random string was too short */ +#define TPM_SIZE TPM_BASE + 23 /* The TPM does not have the space to perform the + operation. */ +#define TPM_WRONGPCRVAL TPM_BASE + 24 /* The named PCR value does not match the current PCR + value. */ +#define TPM_BAD_PARAM_SIZE TPM_BASE + 25 /* The paramSize argument to the command has the + incorrect value */ +#define TPM_SHA_THREAD TPM_BASE + 26 /* There is no existing SHA-1 thread. */ +#define TPM_SHA_ERROR TPM_BASE + 27 /* The calculation is unable to proceed because the + existing SHA-1 thread has already encountered an + error. */ +#define TPM_FAILEDSELFTEST TPM_BASE + 28 /* Self-test has failed and the TPM has shutdown. */ +#define TPM_AUTH2FAIL TPM_BASE + 29 /* The authorization for the second key in a 2 key + function failed authorization */ +#define TPM_BADTAG TPM_BASE + 30 /* The tag value sent to for a command is invalid */ +#define TPM_IOERROR TPM_BASE + 31 /* An IO error occurred transmitting information to + the TPM */ +#define TPM_ENCRYPT_ERROR TPM_BASE + 32 /* The encryption process had a problem. */ +#define TPM_DECRYPT_ERROR TPM_BASE + 33 /* The decryption process did not complete. */ +#define TPM_INVALID_AUTHHANDLE TPM_BASE + 34 /* An invalid handle was used. */ +#define TPM_NO_ENDORSEMENT TPM_BASE + 35 /* The TPM does not a EK installed */ +#define TPM_INVALID_KEYUSAGE TPM_BASE + 36 /* The usage of a key is not allowed */ +#define TPM_WRONG_ENTITYTYPE TPM_BASE + 37 /* The submitted entity type is not allowed */ +#define TPM_INVALID_POSTINIT TPM_BASE + 38 /* The command was received in the wrong sequence + relative to TPM_Init and a subsequent TPM_Startup + */ +#define TPM_INAPPROPRIATE_SIG TPM_BASE + 39 /* Signed data cannot include additional DER + information */ +#define TPM_BAD_KEY_PROPERTY TPM_BASE + 40 /* The key properties in TPM_KEY_PARMs are not + supported by this TPM */ +#define TPM_BAD_MIGRATION TPM_BASE + 41 /* The migration properties of this key are incorrect. + */ +#define TPM_BAD_SCHEME TPM_BASE + 42 /* The signature or encryption scheme for this key is + incorrect or not permitted in this situation. */ +#define TPM_BAD_DATASIZE TPM_BASE + 43 /* The size of the data (or blob) parameter is bad or + inconsistent with the referenced key */ +#define TPM_BAD_MODE TPM_BASE + 44 /* A mode parameter is bad, such as capArea or + subCapArea for TPM_GetCapability, physicalPresence + parameter for TPM_PhysicalPresence, or + migrationType for TPM_CreateMigrationBlob. */ +#define TPM_BAD_PRESENCE TPM_BASE + 45 /* Either the physicalPresence or physicalPresenceLock + bits have the wrong value */ +#define TPM_BAD_VERSION TPM_BASE + 46 /* The TPM cannot perform this version of the + capability */ +#define TPM_NO_WRAP_TRANSPORT TPM_BASE + 47 /* The TPM does not allow for wrapped transport + sessions */ +#define TPM_AUDITFAIL_UNSUCCESSFUL TPM_BASE + 48 /* TPM audit construction failed and the + underlying command was returning a failure + code also */ +#define TPM_AUDITFAIL_SUCCESSFUL TPM_BASE + 49 /* TPM audit construction failed and the underlying + command was returning success */ +#define TPM_NOTRESETABLE TPM_BASE + 50 /* Attempt to reset a PCR register that does not have + the resettable attribute */ +#define TPM_NOTLOCAL TPM_BASE + 51 /* Attempt to reset a PCR register that requires + locality and locality modifier not part of command + transport */ +#define TPM_BAD_TYPE TPM_BASE + 52 /* Make identity blob not properly typed */ +#define TPM_INVALID_RESOURCE TPM_BASE + 53 /* When saving context identified resource type does + not match actual resource */ +#define TPM_NOTFIPS TPM_BASE + 54 /* The TPM is attempting to execute a command only + available when in FIPS mode */ +#define TPM_INVALID_FAMILY TPM_BASE + 55 /* The command is attempting to use an invalid family + ID */ +#define TPM_NO_NV_PERMISSION TPM_BASE + 56 /* The permission to manipulate the NV storage is not + available */ +#define TPM_REQUIRES_SIGN TPM_BASE + 57 /* The operation requires a signed command */ +#define TPM_KEY_NOTSUPPORTED TPM_BASE + 58 /* Wrong operation to load an NV key */ +#define TPM_AUTH_CONFLICT TPM_BASE + 59 /* NV_LoadKey blob requires both owner and blob + authorization */ +#define TPM_AREA_LOCKED TPM_BASE + 60 /* The NV area is locked and not writable */ +#define TPM_BAD_LOCALITY TPM_BASE + 61 /* The locality is incorrect for the attempted + operation */ +#define TPM_READ_ONLY TPM_BASE + 62 /* The NV area is read only and can't be written to + */ +#define TPM_PER_NOWRITE TPM_BASE + 63 /* There is no protection on the write to the NV area + */ +#define TPM_FAMILYCOUNT TPM_BASE + 64 /* The family count value does not match */ +#define TPM_WRITE_LOCKED TPM_BASE + 65 /* The NV area has already been written to */ +#define TPM_BAD_ATTRIBUTES TPM_BASE + 66 /* The NV area attributes conflict */ +#define TPM_INVALID_STRUCTURE TPM_BASE + 67 /* The structure tag and version are invalid or + inconsistent */ +#define TPM_KEY_OWNER_CONTROL TPM_BASE + 68 /* The key is under control of the TPM Owner and can + only be evicted by the TPM Owner. */ +#define TPM_BAD_COUNTER TPM_BASE + 69 /* The counter handle is incorrect */ +#define TPM_NOT_FULLWRITE TPM_BASE + 70 /* The write is not a complete write of the area */ +#define TPM_CONTEXT_GAP TPM_BASE + 71 /* The gap between saved context counts is too large + */ +#define TPM_MAXNVWRITES TPM_BASE + 72 /* The maximum number of NV writes without an owner + has been exceeded */ +#define TPM_NOOPERATOR TPM_BASE + 73 /* No operator authorization value is set */ +#define TPM_RESOURCEMISSING TPM_BASE + 74 /* The resource pointed to by context is not loaded + */ +#define TPM_DELEGATE_LOCK TPM_BASE + 75 /* The delegate administration is locked */ +#define TPM_DELEGATE_FAMILY TPM_BASE + 76 /* Attempt to manage a family other then the delegated + family */ +#define TPM_DELEGATE_ADMIN TPM_BASE + 77 /* Delegation table management not enabled */ +#define TPM_TRANSPORT_NOTEXCLUSIVE TPM_BASE + 78 /* There was a command executed outside of an + exclusive transport session */ +#define TPM_OWNER_CONTROL TPM_BASE + 79 /* Attempt to context save a owner evict controlled + key */ +#define TPM_DAA_RESOURCES TPM_BASE + 80 /* The DAA command has no resources available to + execute the command */ +#define TPM_DAA_INPUT_DATA0 TPM_BASE + 81 /* The consistency check on DAA parameter inputData0 + has failed. */ +#define TPM_DAA_INPUT_DATA1 TPM_BASE + 82 /* The consistency check on DAA parameter inputData1 + has failed. */ +#define TPM_DAA_ISSUER_SETTINGS TPM_BASE + 83 /* The consistency check on DAA_issuerSettings has + failed. */ +#define TPM_DAA_TPM_SETTINGS TPM_BASE + 84 /* The consistency check on DAA_tpmSpecific has + failed. */ +#define TPM_DAA_STAGE TPM_BASE + 85 /* The atomic process indicated by the submitted DAA + command is not the expected process. */ +#define TPM_DAA_ISSUER_VALIDITY TPM_BASE + 86 /* The issuer's validity check has detected an + inconsistency */ +#define TPM_DAA_WRONG_W TPM_BASE + 87 /* The consistency check on w has failed. */ +#define TPM_BAD_HANDLE TPM_BASE + 88 /* The handle is incorrect */ +#define TPM_BAD_DELEGATE TPM_BASE + 89 /* Delegation is not correct */ +#define TPM_BADCONTEXT TPM_BASE + 90 /* The context blob is invalid */ +#define TPM_TOOMANYCONTEXTS TPM_BASE + 91 /* Too many contexts held by the TPM */ +#define TPM_MA_TICKET_SIGNATURE TPM_BASE + 92 /* Migration authority signature validation failure + */ +#define TPM_MA_DESTINATION TPM_BASE + 93 /* Migration destination not authenticated */ +#define TPM_MA_SOURCE TPM_BASE + 94 /* Migration source incorrect */ +#define TPM_MA_AUTHORITY TPM_BASE + 95 /* Incorrect migration authority */ +#define TPM_PERMANENTEK TPM_BASE + 97 /* Attempt to revoke the EK and the EK is not revocable */ +#define TPM_BAD_SIGNATURE TPM_BASE + 98 /* Bad signature of CMK ticket */ +#define TPM_NOCONTEXTSPACE TPM_BASE + 99 /* There is no room in the context list for additional + contexts */ + +/* As error codes are added here, they should also be added to lib/miscfunc.c */ + +/* TPM-defined non-fatal errors */ + +#define TPM_RETRY TPM_BASE + TPM_NON_FATAL /* The TPM is too busy to respond to the + command immediately, but the command + could be submitted at a later time */ +#define TPM_NEEDS_SELFTEST TPM_BASE + TPM_NON_FATAL + 1 /* TPM_ContinueSelfTest has has not + been run*/ +#define TPM_DOING_SELFTEST TPM_BASE + TPM_NON_FATAL + 2 /* The TPM is currently executing the + actions of TPM_ContinueSelfTest + because the ordinal required + resources that have not been + tested. */ +#define TPM_DEFEND_LOCK_RUNNING TPM_BASE + TPM_NON_FATAL + 3 + /* The TPM is defending against dictionary + attacks and is in some time-out + period. */ + +#endif diff --git a/libstb/tss2/ibmtss/tssfile.h b/libstb/tss2/ibmtss/tssfile.h new file mode 100644 index 0000000..3e73114 --- /dev/null +++ b/libstb/tss2/ibmtss/tssfile.h @@ -0,0 +1,95 @@ +/********************************************************************************/ +/* */ +/* TSS and Application File Utilities */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: tssfile.h 1324 2018-08-31 16:36:12Z kgoldman $ */ +/* */ +/* (c) Copyright IBM Corporation 2015, 2018. */ +/* */ +/* All rights reserved. */ +/* */ +/* Redistribution and use in source and binary forms, with or without */ +/* modification, are permitted provided that the following conditions are */ +/* met: */ +/* */ +/* Redistributions of source code must retain the above copyright notice, */ +/* this list of conditions and the following disclaimer. */ +/* */ +/* 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. */ +/* */ +/* Neither the names of the IBM Corporation nor the names of its */ +/* contributors may be used to endorse or promote products derived from */ +/* this software without specific prior written permission. */ +/* */ +/* 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. */ +/********************************************************************************/ + +/* This is a semi-public header. The API is subject to change. + + It is useful rapid application development, and as sample code. It is risky for production code. + +*/ + +#ifndef TSSFILE_H +#define TSSFILE_H + +#include <stdio.h> + +#include <ibmtss/TPM_Types.h> +#include <ibmtss/tssutils.h> + +#ifdef __cplusplus +extern "C" { +#endif + + LIB_EXPORT + int TSS_File_Open(FILE **file, + const char *filename, + const char* mode); + LIB_EXPORT + TPM_RC TSS_File_ReadBinaryFile(unsigned char **data, + size_t *length, + const char *filename); + LIB_EXPORT + TPM_RC TSS_File_WriteBinaryFile(const unsigned char *data, + size_t length, + const char *filename); + + LIB_EXPORT + TPM_RC TSS_File_ReadStructure(void *structure, + UnmarshalFunction_t unmarshalFunction, + const char *filename); + LIB_EXPORT + TPM_RC TSS_File_ReadStructureFlag(void *structure, + UnmarshalFunctionFlag_t unmarshalFunction, + BOOL allowNull, + const char *filename); + LIB_EXPORT + TPM_RC TSS_File_WriteStructure(void *structure, + MarshalFunction_t marshalFunction, + const char *filename); + LIB_EXPORT + TPM_RC TSS_File_Read2B(TPM2B *tpm2b, + uint16_t targetSize, + const char *filename); + LIB_EXPORT + TPM_RC TSS_File_DeleteFile(const char *filename); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libstb/tss2/ibmtss/tssmarshal.h b/libstb/tss2/ibmtss/tssmarshal.h new file mode 100644 index 0000000..aa8ee75 --- /dev/null +++ b/libstb/tss2/ibmtss/tssmarshal.h @@ -0,0 +1,1619 @@ +/********************************************************************************/ +/* */ +/* TSS Marshal and Unmarshal */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* */ +/* (c) Copyright IBM Corporation 2015 - 2019. */ +/* */ +/* All rights reserved. */ +/* */ +/* Redistribution and use in source and binary forms, with or without */ +/* modification, are permitted provided that the following conditions are */ +/* met: */ +/* */ +/* Redistributions of source code must retain the above copyright notice, */ +/* this list of conditions and the following disclaimer. */ +/* */ +/* 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. */ +/* */ +/* Neither the names of the IBM Corporation nor the names of its */ +/* contributors may be used to endorse or promote products derived from */ +/* this software without specific prior written permission. */ +/* */ +/* 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. */ +/********************************************************************************/ + +/* This is a semi-public header. The API should be stable, but is less guaranteed. + + It is useful for applications that have to marshal / unmarshal + structures for file save / load. +*/ + +#ifndef TSSMARSHAL_H +#define TSSMARSHAL_H + +#include "BaseTypes.h" +#include <ibmtss/TPM_Types.h> + +#include "ActivateCredential_fp.h" +#include "CertifyCreation_fp.h" +#include "Certify_fp.h" +#include "ChangeEPS_fp.h" +#include "ChangePPS_fp.h" +#include "ClearControl_fp.h" +#include "Clear_fp.h" +#include "ClockRateAdjust_fp.h" +#include "ClockSet_fp.h" +#include "Commit_fp.h" +#include "Commit_fp.h" +#include "ContextLoad_fp.h" +#include "ContextSave_fp.h" +#include "CreatePrimary_fp.h" +#include "Create_fp.h" +#include "CreateLoaded_fp.h" +#include "DictionaryAttackLockReset_fp.h" +#include "DictionaryAttackParameters_fp.h" +#include "Duplicate_fp.h" +#include "ECC_Parameters_fp.h" +#include "ECDH_KeyGen_fp.h" +#include "ECDH_ZGen_fp.h" +#include "EC_Ephemeral_fp.h" +#include "EncryptDecrypt_fp.h" +#include "EncryptDecrypt2_fp.h" +#include "EventSequenceComplete_fp.h" +#include "EvictControl_fp.h" +#include "FlushContext_fp.h" +#include "GetCapability_fp.h" +#include "GetCommandAuditDigest_fp.h" +#include "GetRandom_fp.h" +#include "GetSessionAuditDigest_fp.h" +#include "GetTestResult_fp.h" +#include "GetTime_fp.h" +#include "HMAC_Start_fp.h" +#include "HMAC_fp.h" +#include "HashSequenceStart_fp.h" +#include "Hash_fp.h" +#include "HierarchyChangeAuth_fp.h" +#include "HierarchyControl_fp.h" +#include "Import_fp.h" +#include "IncrementalSelfTest_fp.h" +#include "LoadExternal_fp.h" +#include "Load_fp.h" +#include "MakeCredential_fp.h" +#include "NV_Certify_fp.h" +#include "NV_ChangeAuth_fp.h" +#include "NV_DefineSpace_fp.h" +#include "NV_Extend_fp.h" +#include "NV_GlobalWriteLock_fp.h" +#include "NV_Increment_fp.h" +#include "NV_ReadLock_fp.h" +#include "NV_ReadPublic_fp.h" +#include "NV_Read_fp.h" +#include "NV_SetBits_fp.h" +#include "NV_UndefineSpaceSpecial_fp.h" +#include "NV_UndefineSpace_fp.h" +#include "NV_WriteLock_fp.h" +#include "NV_Write_fp.h" +#include "ObjectChangeAuth_fp.h" +#include "PCR_Allocate_fp.h" +#include "PCR_Event_fp.h" +#include "PCR_Extend_fp.h" +#include "PCR_Read_fp.h" +#include "PCR_Reset_fp.h" +#include "PCR_SetAuthPolicy_fp.h" +#include "PCR_SetAuthValue_fp.h" +#include "PP_Commands_fp.h" +#include "PolicyAuthValue_fp.h" +#include "PolicyAuthorize_fp.h" +#include "PolicyAuthorizeNV_fp.h" +#include "PolicyCommandCode_fp.h" +#include "PolicyCounterTimer_fp.h" +#include "PolicyCpHash_fp.h" +#include "PolicyDuplicationSelect_fp.h" +#include "PolicyGetDigest_fp.h" +#include "PolicyLocality_fp.h" +#include "PolicyNV_fp.h" +#include "PolicyAuthorizeNV_fp.h" +#include "PolicyNvWritten_fp.h" +#include "PolicyNameHash_fp.h" +#include "PolicyOR_fp.h" +#include "PolicyPCR_fp.h" +#include "PolicyPassword_fp.h" +#include "PolicyPhysicalPresence_fp.h" +#include "PolicyRestart_fp.h" +#include "PolicySecret_fp.h" +#include "PolicySigned_fp.h" +#include "PolicyTemplate_fp.h" +#include "PolicyTicket_fp.h" +#include "Quote_fp.h" +#include "RSA_Decrypt_fp.h" +#include "RSA_Encrypt_fp.h" +#include "ReadClock_fp.h" +#include "ReadPublic_fp.h" +#include "Rewrap_fp.h" +#include "SelfTest_fp.h" +#include "SequenceComplete_fp.h" +#include "SequenceUpdate_fp.h" +#include "SetAlgorithmSet_fp.h" +#include "SetCommandCodeAuditStatus_fp.h" +#include "SetPrimaryPolicy_fp.h" +#include "Shutdown_fp.h" +#include "Sign_fp.h" +#include "StartAuthSession_fp.h" +#include "Startup_fp.h" +#include "StirRandom_fp.h" +#include "TestParms_fp.h" +#include "Unseal_fp.h" +#include "VerifySignature_fp.h" +#include "ZGen_2Phase_fp.h" + +#ifdef __cplusplus +extern "C" { +#endif + + /* Recommended functions */ + + TPM_RC + TSS_Startup_In_Marshalu(const Startup_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_Shutdown_In_Marshalu(const Shutdown_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_SelfTest_In_Marshalu(const SelfTest_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_IncrementalSelfTest_In_Marshalu(const IncrementalSelfTest_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_StartAuthSession_In_Marshalu(const StartAuthSession_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_PolicyRestart_In_Marshalu(const PolicyRestart_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_Create_In_Marshalu(const Create_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_Load_In_Marshalu(const Load_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_LoadExternal_In_Marshalu(const LoadExternal_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_ReadPublic_In_Marshalu(const ReadPublic_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_ActivateCredential_In_Marshalu(const ActivateCredential_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_MakeCredential_In_Marshalu(const MakeCredential_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_Unseal_In_Marshalu(const Unseal_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_ObjectChangeAuth_In_Marshalu(const ObjectChangeAuth_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_CreateLoaded_In_Marshalu(const CreateLoaded_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_Duplicate_In_Marshalu(const Duplicate_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_Rewrap_In_Marshalu(const Rewrap_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_Import_In_Marshalu(const Import_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_RSA_Encrypt_In_Marshalu(const RSA_Encrypt_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_RSA_Decrypt_In_Marshalu(const RSA_Decrypt_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_ECDH_KeyGen_In_Marshalu(const ECDH_KeyGen_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_ECDH_ZGen_In_Marshalu(const ECDH_ZGen_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_ECC_Parameters_In_Marshalu(const ECC_Parameters_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_ZGen_2Phase_In_Marshalu(const ZGen_2Phase_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_EncryptDecrypt_In_Marshalu(const EncryptDecrypt_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_EncryptDecrypt2_In_Marshalu(const EncryptDecrypt2_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_Hash_In_Marshalu(const Hash_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_HMAC_In_Marshalu(const HMAC_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_GetRandom_In_Marshalu(const GetRandom_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_StirRandom_In_Marshalu(const StirRandom_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_HMAC_Start_In_Marshalu(const HMAC_Start_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_HashSequenceStart_In_Marshalu(const HashSequenceStart_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_SequenceUpdate_In_Marshalu(const SequenceUpdate_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_SequenceComplete_In_Marshalu(const SequenceComplete_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_EventSequenceComplete_In_Marshalu(const EventSequenceComplete_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_Certify_In_Marshalu(const Certify_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_CertifyCreation_In_Marshalu(const CertifyCreation_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_Quote_In_Marshalu(const Quote_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_GetSessionAuditDigest_In_Marshalu(const GetSessionAuditDigest_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_GetCommandAuditDigest_In_Marshalu(const GetCommandAuditDigest_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_GetTime_In_Marshalu(const GetTime_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_Commit_In_Marshalu(const Commit_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_EC_Ephemeral_In_Marshalu(const EC_Ephemeral_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_VerifySignature_In_Marshalu(const VerifySignature_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_Sign_In_Marshalu(const Sign_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_SetCommandCodeAuditStatus_In_Marshalu(const SetCommandCodeAuditStatus_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_PCR_Extend_In_Marshalu(const PCR_Extend_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_PCR_Event_In_Marshalu(const PCR_Event_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_PCR_Read_In_Marshalu(const PCR_Read_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_PCR_Allocate_In_Marshalu(const PCR_Allocate_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_PCR_SetAuthPolicy_In_Marshalu(const PCR_SetAuthPolicy_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_PCR_SetAuthValue_In_Marshalu(const PCR_SetAuthValue_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_PCR_Reset_In_Marshalu(const PCR_Reset_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_PolicySigned_In_Marshalu(const PolicySigned_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_PolicySecret_In_Marshalu(const PolicySecret_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_PolicyTicket_In_Marshalu(const PolicyTicket_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_PolicyOR_In_Marshalu(const PolicyOR_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_PolicyPCR_In_Marshalu(const PolicyPCR_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_PolicyLocality_In_Marshalu(const PolicyLocality_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_PolicyNV_In_Marshalu(const PolicyNV_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_PolicyAuthorizeNV_In_Marshalu(const PolicyAuthorizeNV_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_PolicyCounterTimer_In_Marshalu(const PolicyCounterTimer_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_PolicyCommandCode_In_Marshalu(const PolicyCommandCode_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_PolicyPhysicalPresence_In_Marshalu(const PolicyPhysicalPresence_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_PolicyCpHash_In_Marshalu(const PolicyCpHash_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_PolicyNameHash_In_Marshalu(const PolicyNameHash_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_PolicyDuplicationSelect_In_Marshalu(const PolicyDuplicationSelect_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_PolicyAuthorize_In_Marshalu(const PolicyAuthorize_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_PolicyAuthValue_In_Marshalu(const PolicyAuthValue_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_PolicyPassword_In_Marshalu(const PolicyPassword_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_PolicyGetDigest_In_Marshalu(const PolicyGetDigest_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_PolicyNvWritten_In_Marshalu(const PolicyNvWritten_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_PolicyTemplate_In_Marshalu(const PolicyTemplate_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_CreatePrimary_In_Marshalu(const CreatePrimary_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_HierarchyControl_In_Marshalu(const HierarchyControl_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_SetPrimaryPolicy_In_Marshalu(const SetPrimaryPolicy_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_ChangePPS_In_Marshalu(const ChangePPS_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_ChangeEPS_In_Marshalu(const ChangeEPS_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_Clear_In_Marshalu(const Clear_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_ClearControl_In_Marshalu(const ClearControl_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_HierarchyChangeAuth_In_Marshalu(const HierarchyChangeAuth_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_DictionaryAttackLockReset_In_Marshalu(const DictionaryAttackLockReset_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_DictionaryAttackParameters_In_Marshalu(const DictionaryAttackParameters_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_PP_Commands_In_Marshalu(const PP_Commands_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_SetAlgorithmSet_In_Marshalu(const SetAlgorithmSet_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_ContextSave_In_Marshalu(const ContextSave_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_ContextLoad_In_Marshalu(const ContextLoad_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_FlushContext_In_Marshalu(const FlushContext_In *source, UINT16 *written, BYTE **buffer, uint32_t *size) ; + TPM_RC + TSS_EvictControl_In_Marshalu(const EvictControl_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_ClockSet_In_Marshalu(const ClockSet_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_ClockRateAdjust_In_Marshalu(const ClockRateAdjust_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_GetCapability_In_Marshalu(const GetCapability_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_TestParms_In_Marshalu(const TestParms_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_NV_DefineSpace_In_Marshalu(const NV_DefineSpace_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_NV_UndefineSpace_In_Marshalu(const NV_UndefineSpace_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_NV_UndefineSpaceSpecial_In_Marshalu(const NV_UndefineSpaceSpecial_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_NV_ReadPublic_In_Marshalu(const NV_ReadPublic_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_NV_Write_In_Marshalu(const NV_Write_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_NV_Increment_In_Marshalu(const NV_Increment_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_NV_Extend_In_Marshalu(const NV_Extend_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_NV_SetBits_In_Marshalu(const NV_SetBits_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_NV_WriteLock_In_Marshalu(const NV_WriteLock_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_NV_GlobalWriteLock_In_Marshalu(const NV_GlobalWriteLock_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_NV_Read_In_Marshalu(const NV_Read_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_NV_ReadLock_In_Marshalu(const NV_ReadLock_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_NV_ChangeAuth_In_Marshalu(const NV_ChangeAuth_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_NV_Certify_In_Marshalu(const NV_Certify_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + + /* Deprecated functions */ + + TPM_RC + TSS_Startup_In_Marshal(const Startup_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_Shutdown_In_Marshal(const Shutdown_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_SelfTest_In_Marshal(const SelfTest_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_IncrementalSelfTest_In_Marshal(const IncrementalSelfTest_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_StartAuthSession_In_Marshal(const StartAuthSession_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_PolicyRestart_In_Marshal(const PolicyRestart_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_Create_In_Marshal(const Create_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_Load_In_Marshal(const Load_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_LoadExternal_In_Marshal(const LoadExternal_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_ReadPublic_In_Marshal(const ReadPublic_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_ActivateCredential_In_Marshal(const ActivateCredential_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_MakeCredential_In_Marshal(const MakeCredential_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_Unseal_In_Marshal(const Unseal_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_ObjectChangeAuth_In_Marshal(const ObjectChangeAuth_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_CreateLoaded_In_Marshal(const CreateLoaded_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_Duplicate_In_Marshal(const Duplicate_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_Rewrap_In_Marshal(const Rewrap_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_Import_In_Marshal(const Import_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_RSA_Encrypt_In_Marshal(const RSA_Encrypt_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_RSA_Decrypt_In_Marshal(const RSA_Decrypt_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_ECDH_KeyGen_In_Marshal(const ECDH_KeyGen_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_ECDH_ZGen_In_Marshal(const ECDH_ZGen_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_ECC_Parameters_In_Marshal(const ECC_Parameters_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_ZGen_2Phase_In_Marshal(const ZGen_2Phase_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_EncryptDecrypt_In_Marshal(const EncryptDecrypt_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_EncryptDecrypt2_In_Marshal(const EncryptDecrypt2_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_Hash_In_Marshal(const Hash_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_HMAC_In_Marshal(const HMAC_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_GetRandom_In_Marshal(const GetRandom_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_StirRandom_In_Marshal(const StirRandom_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_HMAC_Start_In_Marshal(const HMAC_Start_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_HashSequenceStart_In_Marshal(const HashSequenceStart_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_SequenceUpdate_In_Marshal(const SequenceUpdate_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_SequenceComplete_In_Marshal(const SequenceComplete_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_EventSequenceComplete_In_Marshal(const EventSequenceComplete_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_Certify_In_Marshal(const Certify_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_CertifyCreation_In_Marshal(const CertifyCreation_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_Quote_In_Marshal(const Quote_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_GetSessionAuditDigest_In_Marshal(const GetSessionAuditDigest_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_GetCommandAuditDigest_In_Marshal(const GetCommandAuditDigest_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_GetTime_In_Marshal(const GetTime_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_Commit_In_Marshal(const Commit_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_EC_Ephemeral_In_Marshal(const EC_Ephemeral_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_VerifySignature_In_Marshal(const VerifySignature_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_Sign_In_Marshal(const Sign_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_SetCommandCodeAuditStatus_In_Marshal(const SetCommandCodeAuditStatus_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_PCR_Extend_In_Marshal(const PCR_Extend_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_PCR_Event_In_Marshal(const PCR_Event_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_PCR_Read_In_Marshal(const PCR_Read_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_PCR_Allocate_In_Marshal(const PCR_Allocate_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_PCR_SetAuthPolicy_In_Marshal(const PCR_SetAuthPolicy_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_PCR_SetAuthValue_In_Marshal(const PCR_SetAuthValue_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_PCR_Reset_In_Marshal(const PCR_Reset_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_PolicySigned_In_Marshal(const PolicySigned_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_PolicySecret_In_Marshal(const PolicySecret_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_PolicyTicket_In_Marshal(const PolicyTicket_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_PolicyOR_In_Marshal(const PolicyOR_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_PolicyPCR_In_Marshal(const PolicyPCR_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_PolicyLocality_In_Marshal(const PolicyLocality_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_PolicyNV_In_Marshal(const PolicyNV_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_PolicyAuthorizeNV_In_Marshal(const PolicyAuthorizeNV_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_PolicyCounterTimer_In_Marshal(const PolicyCounterTimer_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_PolicyCommandCode_In_Marshal(const PolicyCommandCode_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_PolicyPhysicalPresence_In_Marshal(const PolicyPhysicalPresence_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_PolicyCpHash_In_Marshal(const PolicyCpHash_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_PolicyNameHash_In_Marshal(const PolicyNameHash_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_PolicyDuplicationSelect_In_Marshal(const PolicyDuplicationSelect_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_PolicyAuthorize_In_Marshal(const PolicyAuthorize_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_PolicyAuthValue_In_Marshal(const PolicyAuthValue_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_PolicyPassword_In_Marshal(const PolicyPassword_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_PolicyGetDigest_In_Marshal(const PolicyGetDigest_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_PolicyNvWritten_In_Marshal(const PolicyNvWritten_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_PolicyTemplate_In_Marshal(const PolicyTemplate_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_CreatePrimary_In_Marshal(const CreatePrimary_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_HierarchyControl_In_Marshal(const HierarchyControl_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_SetPrimaryPolicy_In_Marshal(const SetPrimaryPolicy_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_ChangePPS_In_Marshal(const ChangePPS_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_ChangeEPS_In_Marshal(const ChangeEPS_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_Clear_In_Marshal(const Clear_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_ClearControl_In_Marshal(const ClearControl_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_HierarchyChangeAuth_In_Marshal(const HierarchyChangeAuth_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_DictionaryAttackLockReset_In_Marshal(const DictionaryAttackLockReset_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_DictionaryAttackParameters_In_Marshal(const DictionaryAttackParameters_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_PP_Commands_In_Marshal(const PP_Commands_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_SetAlgorithmSet_In_Marshal(const SetAlgorithmSet_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_ContextSave_In_Marshal(const ContextSave_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_ContextLoad_In_Marshal(const ContextLoad_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_FlushContext_In_Marshal(const FlushContext_In *source, UINT16 *written, BYTE **buffer, INT32 *size) ; + TPM_RC + TSS_EvictControl_In_Marshal(const EvictControl_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_ClockSet_In_Marshal(const ClockSet_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_ClockRateAdjust_In_Marshal(const ClockRateAdjust_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_GetCapability_In_Marshal(const GetCapability_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_TestParms_In_Marshal(const TestParms_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_NV_DefineSpace_In_Marshal(const NV_DefineSpace_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_NV_UndefineSpace_In_Marshal(const NV_UndefineSpace_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_NV_UndefineSpaceSpecial_In_Marshal(const NV_UndefineSpaceSpecial_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_NV_ReadPublic_In_Marshal(const NV_ReadPublic_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_NV_Write_In_Marshal(const NV_Write_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_NV_Increment_In_Marshal(const NV_Increment_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_NV_Extend_In_Marshal(const NV_Extend_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_NV_SetBits_In_Marshal(const NV_SetBits_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_NV_WriteLock_In_Marshal(const NV_WriteLock_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_NV_GlobalWriteLock_In_Marshal(const NV_GlobalWriteLock_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_NV_Read_In_Marshal(const NV_Read_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_NV_ReadLock_In_Marshal(const NV_ReadLock_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_NV_ChangeAuth_In_Marshal(const NV_ChangeAuth_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + TPM_RC + TSS_NV_Certify_In_Marshal(const NV_Certify_In *source, UINT16 *written, BYTE **buffer, INT32 *size); + + /* Recommended functions */ + + TPM_RC + TSS_IncrementalSelfTest_Out_Unmarshalu(IncrementalSelfTest_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_GetTestResult_Out_Unmarshalu(GetTestResult_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_StartAuthSession_Out_Unmarshalu(StartAuthSession_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_Create_Out_Unmarshalu(Create_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_Load_Out_Unmarshalu(Load_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_LoadExternal_Out_Unmarshalu(LoadExternal_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_ReadPublic_Out_Unmarshalu(ReadPublic_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_ActivateCredential_Out_Unmarshalu(ActivateCredential_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_MakeCredential_Out_Unmarshalu(MakeCredential_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_Unseal_Out_Unmarshalu(Unseal_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_ObjectChangeAuth_Out_Unmarshalu(ObjectChangeAuth_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_CreateLoaded_Out_Unmarshalu(CreateLoaded_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_Duplicate_Out_Unmarshalu(Duplicate_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_Rewrap_Out_Unmarshalu(Rewrap_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_Import_Out_Unmarshalu(Import_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_RSA_Encrypt_Out_Unmarshalu(RSA_Encrypt_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_RSA_Decrypt_Out_Unmarshalu(RSA_Decrypt_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_ECDH_KeyGen_Out_Unmarshalu(ECDH_KeyGen_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_ECDH_ZGen_Out_Unmarshalu(ECDH_ZGen_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_ECC_Parameters_Out_Unmarshalu(ECC_Parameters_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_ZGen_2Phase_Out_Unmarshalu(ZGen_2Phase_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_EncryptDecrypt_Out_Unmarshalu(EncryptDecrypt_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_EncryptDecrypt2_Out_Unmarshalu(EncryptDecrypt2_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_Hash_Out_Unmarshalu(Hash_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_HMAC_Out_Unmarshalu(HMAC_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_GetRandom_Out_Unmarshalu(GetRandom_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_HMAC_Start_Out_Unmarshalu(HMAC_Start_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_HashSequenceStart_Out_Unmarshalu(HashSequenceStart_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_SequenceComplete_Out_Unmarshalu(SequenceComplete_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_EventSequenceComplete_Out_Unmarshalu(EventSequenceComplete_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_Certify_Out_Unmarshalu(Certify_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_CertifyCreation_Out_Unmarshalu(CertifyCreation_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_Quote_Out_Unmarshalu(Quote_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_GetSessionAuditDigest_Out_Unmarshalu(GetSessionAuditDigest_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_GetCommandAuditDigest_Out_Unmarshalu(GetCommandAuditDigest_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_GetTime_Out_Unmarshalu(GetTime_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_Commit_Out_Unmarshalu(Commit_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_EC_Ephemeral_Out_Unmarshalu(EC_Ephemeral_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_VerifySignature_Out_Unmarshalu(VerifySignature_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_Sign_Out_Unmarshalu(Sign_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_PCR_Event_Out_Unmarshalu(PCR_Event_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_PCR_Read_Out_Unmarshalu(PCR_Read_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_PCR_Allocate_Out_Unmarshalu(PCR_Allocate_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_PolicySigned_Out_Unmarshalu(PolicySigned_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_PolicySecret_Out_Unmarshalu(PolicySecret_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_PolicyGetDigest_Out_Unmarshalu(PolicyGetDigest_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_CreatePrimary_Out_Unmarshalu(CreatePrimary_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_ContextSave_Out_Unmarshalu(ContextSave_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_ContextLoad_Out_Unmarshalu(ContextLoad_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_ReadClock_Out_Unmarshalu(ReadClock_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_GetCapability_Out_Unmarshalu(GetCapability_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_NV_ReadPublic_Out_Unmarshalu(NV_ReadPublic_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_NV_Read_Out_Unmarshalu(NV_Read_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_NV_Certify_Out_Unmarshalu(NV_Certify_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size); + + /* Deprecated functions */ + + TPM_RC + TSS_IncrementalSelfTest_Out_Unmarshal(IncrementalSelfTest_Out *target, TPM_ST tag, BYTE **buffer, INT32 *size); + TPM_RC + TSS_GetTestResult_Out_Unmarshal(GetTestResult_Out *target, TPM_ST tag, BYTE **buffer, INT32 *size); + TPM_RC + TSS_StartAuthSession_Out_Unmarshal(StartAuthSession_Out *target, TPM_ST tag, BYTE **buffer, INT32 *size); + TPM_RC + TSS_Create_Out_Unmarshal(Create_Out *target, TPM_ST tag, BYTE **buffer, INT32 *size); + TPM_RC + TSS_Load_Out_Unmarshal(Load_Out *target, TPM_ST tag, BYTE **buffer, INT32 *size); + TPM_RC + TSS_LoadExternal_Out_Unmarshal(LoadExternal_Out *target, TPM_ST tag, BYTE **buffer, INT32 *size); + TPM_RC + TSS_ReadPublic_Out_Unmarshal(ReadPublic_Out *target, TPM_ST tag, BYTE **buffer, INT32 *size); + TPM_RC + TSS_ActivateCredential_Out_Unmarshal(ActivateCredential_Out *target, TPM_ST tag, BYTE **buffer, INT32 *size); + TPM_RC + TSS_MakeCredential_Out_Unmarshal(MakeCredential_Out *target, TPM_ST tag, BYTE **buffer, INT32 *size); + TPM_RC + TSS_Unseal_Out_Unmarshal(Unseal_Out *target, TPM_ST tag, BYTE **buffer, INT32 *size); + TPM_RC + TSS_ObjectChangeAuth_Out_Unmarshal(ObjectChangeAuth_Out *target, TPM_ST tag, BYTE **buffer, INT32 *size); + TPM_RC + TSS_CreateLoaded_Out_Unmarshal(CreateLoaded_Out *target, TPM_ST tag, BYTE **buffer, INT32 *size); + TPM_RC + TSS_Duplicate_Out_Unmarshal(Duplicate_Out *target, TPM_ST tag, BYTE **buffer, INT32 *size); + TPM_RC + TSS_Rewrap_Out_Unmarshal(Rewrap_Out *target, TPM_ST tag, BYTE **buffer, INT32 *size); + TPM_RC + TSS_Import_Out_Unmarshal(Import_Out *target, TPM_ST tag, BYTE **buffer, INT32 *size); + TPM_RC + TSS_RSA_Encrypt_Out_Unmarshal(RSA_Encrypt_Out *target, TPM_ST tag, BYTE **buffer, INT32 *size); + TPM_RC + TSS_RSA_Decrypt_Out_Unmarshal(RSA_Decrypt_Out *target, TPM_ST tag, BYTE **buffer, INT32 *size); + TPM_RC + TSS_ECDH_KeyGen_Out_Unmarshal(ECDH_KeyGen_Out *target, TPM_ST tag, BYTE **buffer, INT32 *size); + TPM_RC + TSS_ECDH_ZGen_Out_Unmarshal(ECDH_ZGen_Out *target, TPM_ST tag, BYTE **buffer, INT32 *size); + TPM_RC + TSS_ECC_Parameters_Out_Unmarshal(ECC_Parameters_Out *target, TPM_ST tag, BYTE **buffer, INT32 *size); + TPM_RC + TSS_ZGen_2Phase_Out_Unmarshal(ZGen_2Phase_Out *target, TPM_ST tag, BYTE **buffer, INT32 *size); + TPM_RC + TSS_EncryptDecrypt_Out_Unmarshal(EncryptDecrypt_Out *target, TPM_ST tag, BYTE **buffer, INT32 *size); + TPM_RC + TSS_EncryptDecrypt2_Out_Unmarshal(EncryptDecrypt2_Out *target, TPM_ST tag, BYTE **buffer, INT32 *size); + TPM_RC + TSS_Hash_Out_Unmarshal(Hash_Out *target, TPM_ST tag, BYTE **buffer, INT32 *size); + TPM_RC + TSS_HMAC_Out_Unmarshal(HMAC_Out *target, TPM_ST tag, BYTE **buffer, INT32 *size); + TPM_RC + TSS_GetRandom_Out_Unmarshal(GetRandom_Out *target, TPM_ST tag, BYTE **buffer, INT32 *size); + TPM_RC + TSS_HMAC_Start_Out_Unmarshal(HMAC_Start_Out *target, TPM_ST tag, BYTE **buffer, INT32 *size); + TPM_RC + TSS_HashSequenceStart_Out_Unmarshal(HashSequenceStart_Out *target, TPM_ST tag, BYTE **buffer, INT32 *size); + TPM_RC + TSS_SequenceComplete_Out_Unmarshal(SequenceComplete_Out *target, TPM_ST tag, BYTE **buffer, INT32 *size); + TPM_RC + TSS_EventSequenceComplete_Out_Unmarshal(EventSequenceComplete_Out *target, TPM_ST tag, BYTE **buffer, INT32 *size); + TPM_RC + TSS_Certify_Out_Unmarshal(Certify_Out *target, TPM_ST tag, BYTE **buffer, INT32 *size); + TPM_RC + TSS_CertifyCreation_Out_Unmarshal(CertifyCreation_Out *target, TPM_ST tag, BYTE **buffer, INT32 *size); + TPM_RC + TSS_Quote_Out_Unmarshal(Quote_Out *target, TPM_ST tag, BYTE **buffer, INT32 *size); + TPM_RC + TSS_GetSessionAuditDigest_Out_Unmarshal(GetSessionAuditDigest_Out *target, TPM_ST tag, BYTE **buffer, INT32 *size); + TPM_RC + TSS_GetCommandAuditDigest_Out_Unmarshal(GetCommandAuditDigest_Out *target, TPM_ST tag, BYTE **buffer, INT32 *size); + TPM_RC + TSS_GetTime_Out_Unmarshal(GetTime_Out *target, TPM_ST tag, BYTE **buffer, INT32 *size); + TPM_RC + TSS_Commit_Out_Unmarshal(Commit_Out *target, TPM_ST tag, BYTE **buffer, INT32 *size); + TPM_RC + TSS_EC_Ephemeral_Out_Unmarshal(EC_Ephemeral_Out *target, TPM_ST tag, BYTE **buffer, INT32 *size); + TPM_RC + TSS_VerifySignature_Out_Unmarshal(VerifySignature_Out *target, TPM_ST tag, BYTE **buffer, INT32 *size); + TPM_RC + TSS_Sign_Out_Unmarshal(Sign_Out *target, TPM_ST tag, BYTE **buffer, INT32 *size); + TPM_RC + TSS_PCR_Event_Out_Unmarshal(PCR_Event_Out *target, TPM_ST tag, BYTE **buffer, INT32 *size); + TPM_RC + TSS_PCR_Read_Out_Unmarshal(PCR_Read_Out *target, TPM_ST tag, BYTE **buffer, INT32 *size); + TPM_RC + TSS_PCR_Allocate_Out_Unmarshal(PCR_Allocate_Out *target, TPM_ST tag, BYTE **buffer, INT32 *size); + TPM_RC + TSS_PolicySigned_Out_Unmarshal(PolicySigned_Out *target, TPM_ST tag, BYTE **buffer, INT32 *size); + TPM_RC + TSS_PolicySecret_Out_Unmarshal(PolicySecret_Out *target, TPM_ST tag, BYTE **buffer, INT32 *size); + TPM_RC + TSS_PolicyGetDigest_Out_Unmarshal(PolicyGetDigest_Out *target, TPM_ST tag, BYTE **buffer, INT32 *size); + TPM_RC + TSS_CreatePrimary_Out_Unmarshal(CreatePrimary_Out *target, TPM_ST tag, BYTE **buffer, INT32 *size); + TPM_RC + TSS_ContextSave_Out_Unmarshal(ContextSave_Out *target, TPM_ST tag, BYTE **buffer, INT32 *size); + TPM_RC + TSS_ContextLoad_Out_Unmarshal(ContextLoad_Out *target, TPM_ST tag, BYTE **buffer, INT32 *size); + TPM_RC + TSS_ReadClock_Out_Unmarshal(ReadClock_Out *target, TPM_ST tag, BYTE **buffer, INT32 *size); + TPM_RC + TSS_GetCapability_Out_Unmarshal(GetCapability_Out *target, TPM_ST tag, BYTE **buffer, INT32 *size); + TPM_RC + TSS_NV_ReadPublic_Out_Unmarshal(NV_ReadPublic_Out *target, TPM_ST tag, BYTE **buffer, INT32 *size); + TPM_RC + TSS_NV_Read_Out_Unmarshal(NV_Read_Out *target, TPM_ST tag, BYTE **buffer, INT32 *size); + TPM_RC + TSS_NV_Certify_Out_Unmarshal(NV_Certify_Out *target, TPM_ST tag, BYTE **buffer, INT32 *size); + + /* Recommended functions */ + + LIB_EXPORT TPM_RC + TSS_UINT8_Marshalu(const UINT8 *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_INT8_Marshalu(const INT8 *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_UINT16_Marshalu(const UINT16 *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_UINT32_Marshalu(const uint32_t *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_INT32_Marshalu(const INT32 *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_UINT64_Marshalu(const UINT64 *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_Array_Marshalu(const BYTE *source, UINT16 sourceSize, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPM2B_Marshalu(const TPM2B *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPM_KEY_BITS_Marshalu(const TPM_KEY_BITS *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPM_GENERATED_Marshalu(const TPM_GENERATED *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPM_ALG_ID_Marshalu(const TPM_ALG_ID *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPM_ECC_CURVE_Marshalu(const TPM_ECC_CURVE *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPM_RC_Marshalu(const TPM_RC *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPM_CLOCK_ADJUST_Marshalu(const TPM_CLOCK_ADJUST *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPM_EO_Marshalu(const TPM_EO *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPM_ST_Marshalu(const TPM_ST *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPM_SU_Marshalu(const TPM_ST *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPM_SE_Marshalu(const TPM_SE *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPM_CAP_Marshalu(const TPM_CAP *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPM_PT_Marshalu(const TPM_PT *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPM_PT_PCR_Marshalu(const TPM_PT_PCR *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPM_HANDLE_Marshalu(const TPM_HANDLE *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMA_ALGORITHM_Marshalu(const TPMA_ALGORITHM *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMA_OBJECT_Marshalu(const TPMA_OBJECT *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMA_SESSION_Marshalu(const TPMA_SESSION *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMA_LOCALITY_Marshalu(const TPMA_LOCALITY *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPM_CC_Marshalu(const TPM_CC *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMA_CC_Marshalu(const TPMA_CC *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMI_YES_NO_Marshalu(const TPMI_YES_NO *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMI_DH_OBJECT_Marshalu(const TPMI_DH_OBJECT *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMI_DH_PERSISTENT_Marshalu(const TPMI_DH_PERSISTENT *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMI_DH_ENTITY_Marshalu(const TPMI_DH_ENTITY *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMI_DH_PCR_Marshalu(const TPMI_DH_PCR *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMI_SH_AUTH_SESSION_Marshalu(const TPMI_SH_AUTH_SESSION *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMI_SH_HMAC_Marshalu(const TPMI_SH_HMAC *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMI_SH_POLICY_Marshalu(const TPMI_SH_POLICY*source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMI_DH_CONTEXT_Marshalu(const TPMI_DH_CONTEXT *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMI_DH_SAVED_Marshalu(const TPMI_DH_SAVED *source, uint16_t *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMI_RH_HIERARCHY_Marshalu(const TPMI_RH_HIERARCHY *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMI_RH_ENABLES_Marshalu(const TPMI_RH_ENABLES *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMI_RH_HIERARCHY_AUTH_Marshalu(const TPMI_RH_HIERARCHY_AUTH *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMI_RH_PLATFORM_Marshalu(const TPMI_RH_PLATFORM *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMI_RH_ENDORSEMENT_Marshalu(const TPMI_RH_ENDORSEMENT *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMI_RH_PROVISION_Marshalu(const TPMI_RH_PROVISION *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMI_RH_CLEAR_Marshalu(const TPMI_RH_CLEAR *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMI_RH_NV_AUTH_Marshalu(const TPMI_RH_NV_AUTH *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMI_RH_LOCKOUT_Marshalu(const TPMI_RH_LOCKOUT *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMI_RH_NV_INDEX_Marshalu(const TPMI_RH_NV_INDEX *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMI_ALG_HASH_Marshalu(const TPMI_ALG_HASH *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMI_ALG_SYM_Marshalu(const TPMI_ALG_SYM *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMI_ALG_SYM_OBJECT_Marshalu(const TPMI_ALG_SYM_OBJECT *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMI_ALG_SYM_MODE_Marshalu(const TPMI_ALG_SYM_MODE *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMI_ALG_KDF_Marshalu(const TPMI_ALG_KDF *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMI_ALG_SIG_SCHEME_Marshalu(const TPMI_ALG_SIG_SCHEME *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMI_ECC_KEY_EXCHANGE_Marshalu(const TPMI_ECC_KEY_EXCHANGE *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMI_ST_COMMAND_TAG_Marshalu(const TPMI_ST_COMMAND_TAG *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMI_ALG_MAC_SCHEME_Marshalu(const TPMI_ALG_MAC_SCHEME *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMI_ALG_CIPHER_MODE_Marshalu(const TPMI_ALG_CIPHER_MODE *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMU_HA_Marshalu(const TPMU_HA *source, UINT16 *written, BYTE **buffer, uint32_t *size, uint32_t selector); + LIB_EXPORT TPM_RC + TSS_TPMT_HA_Marshalu(const TPMT_HA *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPM2B_DIGEST_Marshalu(const TPM2B_DIGEST *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPM2B_DATA_Marshalu(const TPM2B_DATA *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPM2B_NONCE_Marshalu(const TPM2B_NONCE *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPM2B_AUTH_Marshalu(const TPM2B_AUTH *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPM2B_OPERAND_Marshalu(const TPM2B_OPERAND *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPM2B_EVENT_Marshalu(const TPM2B_EVENT *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPM2B_MAX_BUFFER_Marshalu(const TPM2B_MAX_BUFFER *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPM2B_MAX_NV_BUFFER_Marshalu(const TPM2B_MAX_NV_BUFFER *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPM2B_TIMEOUT_Marshalu(const TPM2B_TIMEOUT *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPM2B_IV_Marshalu(const TPM2B_IV *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPM2B_NAME_Marshalu(const TPM2B_NAME *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_PCR_SELECTION_Marshalu(const TPMS_PCR_SELECTION *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMT_TK_CREATION_Marshalu(const TPMT_TK_CREATION *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMT_TK_VERIFIED_Marshalu(const TPMT_TK_VERIFIED *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMT_TK_AUTH_Marshalu(const TPMT_TK_AUTH *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMT_TK_HASHCHECK_Marshalu(const TPMT_TK_HASHCHECK *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_ALG_PROPERTY_Marshalu(const TPMS_ALG_PROPERTY *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_TAGGED_PROPERTY_Marshalu(const TPMS_TAGGED_PROPERTY *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_TAGGED_PCR_SELECT_Marshalu(const TPMS_TAGGED_PCR_SELECT *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPML_CC_Marshalu(const TPML_CC *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPML_CCA_Marshalu(const TPML_CCA *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPML_ALG_Marshalu(const TPML_ALG *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPML_HANDLE_Marshalu(const TPML_HANDLE *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPML_DIGEST_Marshalu(const TPML_DIGEST *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPML_DIGEST_VALUES_Marshalu(const TPML_DIGEST_VALUES *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPML_PCR_SELECTION_Marshalu(const TPML_PCR_SELECTION *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPML_ALG_PROPERTY_Marshalu(const TPML_ALG_PROPERTY *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPML_TAGGED_TPM_PROPERTY_Marshalu(const TPML_TAGGED_TPM_PROPERTY *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPML_TAGGED_PCR_PROPERTY_Marshalu(const TPML_TAGGED_PCR_PROPERTY *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPML_ECC_CURVE_Marshalu(const TPML_ECC_CURVE *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMU_CAPABILITIES_Marshalu(const TPMU_CAPABILITIES *source, UINT16 *written, BYTE **buffer, uint32_t *size, uint32_t selector); + LIB_EXPORT TPM_RC + TSS_TPMS_CAPABILITY_DATA_Marshalu(const TPMS_CAPABILITY_DATA *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_CLOCK_INFO_Marshalu(const TPMS_CLOCK_INFO *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_TIME_INFO_Marshalu(const TPMS_TIME_INFO *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_TIME_ATTEST_INFO_Marshalu(const TPMS_TIME_ATTEST_INFO *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_CERTIFY_INFO_Marshalu(const TPMS_CERTIFY_INFO *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_QUOTE_INFO_Marshalu(const TPMS_QUOTE_INFO *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_COMMAND_AUDIT_INFO_Marshalu(const TPMS_COMMAND_AUDIT_INFO *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_SESSION_AUDIT_INFO_Marshalu(const TPMS_SESSION_AUDIT_INFO *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_CREATION_INFO_Marshalu(const TPMS_CREATION_INFO *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_NV_CERTIFY_INFO_Marshalu(const TPMS_NV_CERTIFY_INFO *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMI_ST_ATTEST_Marshalu(const TPMI_ST_ATTEST *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMU_ATTEST_Marshalu(const TPMU_ATTEST *source, UINT16 *written, BYTE **buffer, uint32_t *size, uint32_t selector); + LIB_EXPORT TPM_RC + TSS_TPMS_ATTEST_Marshalu(const TPMS_ATTEST *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPM2B_ATTEST_Marshalu(const TPM2B_ATTEST *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_AUTH_COMMAND_Marshalu(const TPMS_AUTH_COMMAND *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMI_AES_KEY_BITS_Marshalu(const TPMI_AES_KEY_BITS *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMU_SYM_KEY_BITS_Marshalu(const TPMU_SYM_KEY_BITS *source, UINT16 *written, BYTE **buffer, uint32_t *size, uint32_t selector); + LIB_EXPORT TPM_RC + TSS_TPMU_SYM_MODE_Marshalu(const TPMU_SYM_MODE *source, UINT16 *written, BYTE **buffer, uint32_t *size, uint32_t selector); + LIB_EXPORT TPM_RC + TSS_TPMT_SYM_DEF_Marshalu(const TPMT_SYM_DEF *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMT_SYM_DEF_OBJECT_Marshalu(const TPMT_SYM_DEF_OBJECT *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPM2B_SYM_KEY_Marshalu(const TPM2B_SYM_KEY *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPM2B_LABEL_Marshalu(const TPM2B_LABEL *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_DERIVE_Marshalu(const TPMS_DERIVE *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_SYMCIPHER_PARMS_Marshalu(const TPMS_SYMCIPHER_PARMS *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPM2B_SENSITIVE_DATA_Marshalu(const TPM2B_SENSITIVE_DATA *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_SENSITIVE_CREATE_Marshalu(const TPMS_SENSITIVE_CREATE *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPM2B_SENSITIVE_CREATE_Marshalu(const TPM2B_SENSITIVE_CREATE *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_SCHEME_HASH_Marshalu(const TPMS_SCHEME_HASH *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_SCHEME_ECDAA_Marshalu(const TPMS_SCHEME_ECDAA *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMI_ALG_KEYEDHASH_SCHEME_Marshalu(const TPMI_ALG_KEYEDHASH_SCHEME *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_SCHEME_HMAC_Marshalu(const TPMS_SCHEME_HMAC *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_SCHEME_XOR_Marshalu(const TPMS_SCHEME_XOR *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMU_SCHEME_KEYEDHASH_Marshalu(const TPMU_SCHEME_KEYEDHASH *source, UINT16 *written, BYTE **buffer, uint32_t *size, uint32_t selector); + LIB_EXPORT TPM_RC + TSS_TPMT_KEYEDHASH_SCHEME_Marshalu(const TPMT_KEYEDHASH_SCHEME *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_SIG_SCHEME_RSASSA_Marshalu(const TPMS_SIG_SCHEME_RSASSA *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_SIG_SCHEME_RSAPSS_Marshalu(const TPMS_SIG_SCHEME_RSAPSS *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_SIG_SCHEME_ECDSA_Marshalu(const TPMS_SIG_SCHEME_ECDSA *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_SIG_SCHEME_SM2_Marshalu(const TPMS_SIG_SCHEME_SM2 *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_SIG_SCHEME_ECSCHNORR_Marshalu(const TPMS_SIG_SCHEME_ECSCHNORR *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_SIG_SCHEME_ECDAA_Marshalu(const TPMS_SIG_SCHEME_ECDAA *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMU_SIG_SCHEME_Marshalu(const TPMU_SIG_SCHEME *source, UINT16 *written, BYTE **buffer, uint32_t *size, uint32_t selector); + LIB_EXPORT TPM_RC + TSS_TPMT_SIG_SCHEME_Marshalu(const TPMT_SIG_SCHEME *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_ENC_SCHEME_OAEP_Marshalu(const TPMS_ENC_SCHEME_OAEP *source, UINT16 *written, BYTE **buffer, uint32_t *size) +#ifdef __ULTRAVISOR__ + __attribute__ ((const)) +#endif + ; + LIB_EXPORT TPM_RC + TSS_TPMS_ENC_SCHEME_RSAES_Marshalu(const TPMS_ENC_SCHEME_RSAES *source, UINT16 *written, BYTE **buffer, uint32_t *size) +#ifdef __ULTRAVISOR__ + __attribute__ ((const)) +#endif + ; + LIB_EXPORT TPM_RC + TSS_TPMS_KEY_SCHEME_ECDH_Marshalu(const TPMS_KEY_SCHEME_ECDH *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_KEY_SCHEME_ECMQV_Marshalu(const TPMS_KEY_SCHEME_ECMQV *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_SCHEME_MGF1_Marshalu(const TPMS_SCHEME_MGF1 *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_SCHEME_KDF1_SP800_56A_Marshalu(const TPMS_SCHEME_KDF1_SP800_56A *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_SCHEME_KDF2_Marshalu(const TPMS_SCHEME_KDF2 *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_SCHEME_KDF1_SP800_108_Marshalu(const TPMS_SCHEME_KDF1_SP800_108 *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMU_KDF_SCHEME_Marshalu(const TPMU_KDF_SCHEME *source, UINT16 *written, BYTE **buffer, uint32_t *size, uint32_t selector); + LIB_EXPORT TPM_RC + TSS_TPMT_KDF_SCHEME_Marshalu(const TPMT_KDF_SCHEME *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMU_ASYM_SCHEME_Marshalu(const TPMU_ASYM_SCHEME *source, UINT16 *written, BYTE **buffer, uint32_t *size, uint32_t selector); + LIB_EXPORT TPM_RC + TSS_TPMI_ALG_RSA_SCHEME_Marshalu(const TPMI_ALG_RSA_SCHEME *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMT_RSA_SCHEME_Marshalu(const TPMT_RSA_SCHEME *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMI_ALG_RSA_DECRYPT_Marshalu(const TPMI_ALG_RSA_DECRYPT *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMT_RSA_DECRYPT_Marshalu(const TPMT_RSA_DECRYPT *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPM2B_PUBLIC_KEY_RSA_Marshalu(const TPM2B_PUBLIC_KEY_RSA *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMI_RSA_KEY_BITS_Marshalu(const TPMI_RSA_KEY_BITS *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPM2B_PRIVATE_KEY_RSA_Marshalu(const TPM2B_PRIVATE_KEY_RSA *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPM2B_ECC_PARAMETER_Marshalu(const TPM2B_ECC_PARAMETER *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_ECC_POINT_Marshalu(const TPMS_ECC_POINT *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPM2B_ECC_POINT_Marshalu(const TPM2B_ECC_POINT *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMI_ALG_ECC_SCHEME_Marshalu(const TPMI_ALG_ECC_SCHEME *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMI_ECC_CURVE_Marshalu(const TPMI_ECC_CURVE *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMT_ECC_SCHEME_Marshalu(const TPMT_ECC_SCHEME *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_ALGORITHM_DETAIL_ECC_Marshalu(const TPMS_ALGORITHM_DETAIL_ECC *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_SIGNATURE_RSA_Marshalu(const TPMS_SIGNATURE_RSA *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_SIGNATURE_RSASSA_Marshalu(const TPMS_SIGNATURE_RSASSA *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_SIGNATURE_RSAPSS_Marshalu(const TPMS_SIGNATURE_RSAPSS *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_SIGNATURE_ECC_Marshalu(const TPMS_SIGNATURE_ECC *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_SIGNATURE_ECDSA_Marshalu(const TPMS_SIGNATURE_ECDSA *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_SIGNATURE_ECDAA_Marshalu(const TPMS_SIGNATURE_ECDAA *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_SIGNATURE_SM2_Marshalu(const TPMS_SIGNATURE_SM2 *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_SIGNATURE_ECSCHNORR_Marshalu(const TPMS_SIGNATURE_ECSCHNORR *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMU_SIGNATURE_Marshalu(const TPMU_SIGNATURE *source, UINT16 *written, BYTE **buffer, uint32_t *size, uint32_t selector); + LIB_EXPORT TPM_RC + TSS_TPMT_SIGNATURE_Marshalu(const TPMT_SIGNATURE *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPM2B_ENCRYPTED_SECRET_Marshalu(const TPM2B_ENCRYPTED_SECRET *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMI_ALG_PUBLIC_Marshalu(const TPMI_ALG_PUBLIC *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMU_PUBLIC_ID_Marshalu(const TPMU_PUBLIC_ID *source, UINT16 *written, BYTE **buffer, uint32_t *size, uint32_t selector); + LIB_EXPORT TPM_RC + TSS_TPMS_KEYEDHASH_PARMS_Marshalu(const TPMS_KEYEDHASH_PARMS *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_RSA_PARMS_Marshalu(const TPMS_RSA_PARMS *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_ECC_PARMS_Marshalu(const TPMS_ECC_PARMS *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMU_PUBLIC_PARMS_Marshalu(const TPMU_PUBLIC_PARMS *source, UINT16 *written, BYTE **buffer, uint32_t *size, uint32_t selector); + LIB_EXPORT TPM_RC + TSS_TPMT_PUBLIC_PARMS_Marshalu(const TPMT_PUBLIC_PARMS *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMT_PUBLIC_Marshalu(const TPMT_PUBLIC *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMT_PUBLIC_D_Marshalu(const TPMT_PUBLIC *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPM2B_PUBLIC_Marshalu(const TPM2B_PUBLIC *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPM2B_TEMPLATE_Marshalu(const TPM2B_TEMPLATE *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMU_SENSITIVE_COMPOSITE_Marshalu(const TPMU_SENSITIVE_COMPOSITE *source, UINT16 *written, BYTE **buffer, uint32_t *size, uint32_t selector); + LIB_EXPORT TPM_RC + TSS_TPMT_SENSITIVE_Marshalu(const TPMT_SENSITIVE *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPM2B_SENSITIVE_Marshalu(const TPM2B_SENSITIVE *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPM2B_PRIVATE_Marshalu(const TPM2B_PRIVATE *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPM2B_ID_OBJECT_Marshalu(const TPM2B_ID_OBJECT *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMA_NV_Marshalu(const TPMA_NV *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_NV_PUBLIC_Marshalu(const TPMS_NV_PUBLIC *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPM2B_NV_PUBLIC_Marshalu(const TPM2B_NV_PUBLIC *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPM2B_CONTEXT_SENSITIVE_Marshalu(const TPM2B_CONTEXT_SENSITIVE *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPM2B_CONTEXT_DATA_Marshalu(const TPM2B_CONTEXT_DATA *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_CONTEXT_Marshalu(const TPMS_CONTEXT *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPMS_CREATION_DATA_Marshalu(const TPMS_CREATION_DATA *source, UINT16 *written, BYTE **buffer, uint32_t *size); + LIB_EXPORT TPM_RC + TSS_TPM2B_CREATION_DATA_Marshalu(const TPM2B_CREATION_DATA *source, UINT16 *written, BYTE **buffer, uint32_t *size); + + /* Deprecated functions */ + + LIB_EXPORT TPM_RC + TSS_UINT8_Marshal(const UINT8 *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_INT8_Marshal(const INT8 *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_UINT16_Marshal(const UINT16 *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_UINT32_Marshal(const UINT32 *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_INT32_Marshal(const INT32 *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_UINT64_Marshal(const UINT64 *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_Array_Marshal(const BYTE *source, UINT16 sourceSize, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPM2B_Marshal(const TPM2B *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPM_KEY_BITS_Marshal(const TPM_KEY_BITS *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPM_GENERATED_Marshal(const TPM_GENERATED *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPM_ALG_ID_Marshal(const TPM_ALG_ID *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPM_ECC_CURVE_Marshal(const TPM_ECC_CURVE *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPM_RC_Marshal(const TPM_RC *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPM_CLOCK_ADJUST_Marshal(const TPM_CLOCK_ADJUST *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPM_EO_Marshal(const TPM_EO *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPM_ST_Marshal(const TPM_ST *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPM_SU_Marshal(const TPM_ST *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPM_SE_Marshal(const TPM_SE *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPM_CAP_Marshal(const TPM_CAP *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPM_PT_Marshal(const TPM_PT *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPM_PT_PCR_Marshal(const TPM_PT_PCR *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPM_HANDLE_Marshal(const TPM_HANDLE *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMA_ALGORITHM_Marshal(const TPMA_ALGORITHM *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMA_OBJECT_Marshal(const TPMA_OBJECT *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMA_SESSION_Marshal(const TPMA_SESSION *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMA_LOCALITY_Marshal(const TPMA_LOCALITY *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPM_CC_Marshal(const TPM_CC *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMA_CC_Marshal(const TPMA_CC *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMI_YES_NO_Marshal(const TPMI_YES_NO *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMI_DH_OBJECT_Marshal(const TPMI_DH_OBJECT *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMI_DH_PERSISTENT_Marshal(const TPMI_DH_PERSISTENT *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMI_DH_ENTITY_Marshal(const TPMI_DH_ENTITY *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMI_DH_PCR_Marshal(const TPMI_DH_PCR *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMI_SH_AUTH_SESSION_Marshal(const TPMI_SH_AUTH_SESSION *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMI_SH_HMAC_Marshal(const TPMI_SH_HMAC *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMI_SH_POLICY_Marshal(const TPMI_SH_POLICY*source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMI_DH_CONTEXT_Marshal(const TPMI_DH_CONTEXT *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMI_RH_HIERARCHY_Marshal(const TPMI_RH_HIERARCHY *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMI_RH_ENABLES_Marshal(const TPMI_RH_ENABLES *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMI_RH_HIERARCHY_AUTH_Marshal(const TPMI_RH_HIERARCHY_AUTH *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMI_RH_PLATFORM_Marshal(const TPMI_RH_PLATFORM *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMI_RH_ENDORSEMENT_Marshal(const TPMI_RH_ENDORSEMENT *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMI_RH_PROVISION_Marshal(const TPMI_RH_PROVISION *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMI_RH_CLEAR_Marshal(const TPMI_RH_CLEAR *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMI_RH_NV_AUTH_Marshal(const TPMI_RH_NV_AUTH *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMI_RH_LOCKOUT_Marshal(const TPMI_RH_LOCKOUT *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMI_RH_NV_INDEX_Marshal(const TPMI_RH_NV_INDEX *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMI_ALG_HASH_Marshal(const TPMI_ALG_HASH *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMI_ALG_SYM_Marshal(const TPMI_ALG_SYM *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMI_ALG_SYM_OBJECT_Marshal(const TPMI_ALG_SYM_OBJECT *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMI_ALG_SYM_MODE_Marshal(const TPMI_ALG_SYM_MODE *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMI_ALG_KDF_Marshal(const TPMI_ALG_KDF *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMI_ALG_SIG_SCHEME_Marshal(const TPMI_ALG_SIG_SCHEME *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMI_ECC_KEY_EXCHANGE_Marshal(const TPMI_ECC_KEY_EXCHANGE *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMI_ST_COMMAND_TAG_Marshal(const TPMI_ST_COMMAND_TAG *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMI_ALG_MAC_SCHEME_Marshal(const TPMI_ALG_MAC_SCHEME *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMI_ALG_CIPHER_MODE_Marshal(const TPMI_ALG_CIPHER_MODE *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMU_HA_Marshal(const TPMU_HA *source, UINT16 *written, BYTE **buffer, INT32 *size, UINT32 selector); + LIB_EXPORT TPM_RC + TSS_TPMT_HA_Marshal(const TPMT_HA *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPM2B_DIGEST_Marshal(const TPM2B_DIGEST *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPM2B_DATA_Marshal(const TPM2B_DATA *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPM2B_NONCE_Marshal(const TPM2B_NONCE *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPM2B_AUTH_Marshal(const TPM2B_AUTH *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPM2B_OPERAND_Marshal(const TPM2B_OPERAND *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPM2B_EVENT_Marshal(const TPM2B_EVENT *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPM2B_MAX_BUFFER_Marshal(const TPM2B_MAX_BUFFER *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPM2B_MAX_NV_BUFFER_Marshal(const TPM2B_MAX_NV_BUFFER *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPM2B_TIMEOUT_Marshal(const TPM2B_TIMEOUT *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPM2B_IV_Marshal(const TPM2B_IV *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPM2B_NAME_Marshal(const TPM2B_NAME *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMS_PCR_SELECTION_Marshal(const TPMS_PCR_SELECTION *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMT_TK_CREATION_Marshal(const TPMT_TK_CREATION *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMT_TK_VERIFIED_Marshal(const TPMT_TK_VERIFIED *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMT_TK_AUTH_Marshal(const TPMT_TK_AUTH *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMT_TK_HASHCHECK_Marshal(const TPMT_TK_HASHCHECK *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMS_ALG_PROPERTY_Marshal(const TPMS_ALG_PROPERTY *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMS_TAGGED_PROPERTY_Marshal(const TPMS_TAGGED_PROPERTY *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMS_TAGGED_PCR_SELECT_Marshal(const TPMS_TAGGED_PCR_SELECT *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPML_CC_Marshal(const TPML_CC *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPML_CCA_Marshal(const TPML_CCA *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPML_ALG_Marshal(const TPML_ALG *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPML_HANDLE_Marshal(const TPML_HANDLE *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPML_DIGEST_Marshal(const TPML_DIGEST *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPML_DIGEST_VALUES_Marshal(const TPML_DIGEST_VALUES *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPML_PCR_SELECTION_Marshal(const TPML_PCR_SELECTION *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPML_ALG_PROPERTY_Marshal(const TPML_ALG_PROPERTY *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPML_TAGGED_TPM_PROPERTY_Marshal(const TPML_TAGGED_TPM_PROPERTY *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPML_TAGGED_PCR_PROPERTY_Marshal(const TPML_TAGGED_PCR_PROPERTY *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPML_ECC_CURVE_Marshal(const TPML_ECC_CURVE *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMU_CAPABILITIES_Marshal(const TPMU_CAPABILITIES *source, UINT16 *written, BYTE **buffer, INT32 *size, UINT32 selector); + LIB_EXPORT TPM_RC + TSS_TPMS_CAPABILITY_DATA_Marshal(const TPMS_CAPABILITY_DATA *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMS_CLOCK_INFO_Marshal(const TPMS_CLOCK_INFO *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMS_TIME_INFO_Marshal(const TPMS_TIME_INFO *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMS_TIME_ATTEST_INFO_Marshal(const TPMS_TIME_ATTEST_INFO *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMS_CERTIFY_INFO_Marshal(const TPMS_CERTIFY_INFO *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMS_QUOTE_INFO_Marshal(const TPMS_QUOTE_INFO *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMS_COMMAND_AUDIT_INFO_Marshal(const TPMS_COMMAND_AUDIT_INFO *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMS_SESSION_AUDIT_INFO_Marshal(const TPMS_SESSION_AUDIT_INFO *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMS_CREATION_INFO_Marshal(const TPMS_CREATION_INFO *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMS_NV_CERTIFY_INFO_Marshal(const TPMS_NV_CERTIFY_INFO *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMI_ST_ATTEST_Marshal(const TPMI_ST_ATTEST *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMU_ATTEST_Marshal(const TPMU_ATTEST *source, UINT16 *written, BYTE **buffer, INT32 *size, UINT32 selector); + LIB_EXPORT TPM_RC + TSS_TPMS_ATTEST_Marshal(const TPMS_ATTEST *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPM2B_ATTEST_Marshal(const TPM2B_ATTEST *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMS_AUTH_COMMAND_Marshal(const TPMS_AUTH_COMMAND *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMI_AES_KEY_BITS_Marshal(const TPMI_AES_KEY_BITS *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMU_SYM_KEY_BITS_Marshal(const TPMU_SYM_KEY_BITS *source, UINT16 *written, BYTE **buffer, INT32 *size, UINT32 selector); + LIB_EXPORT TPM_RC + TSS_TPMU_SYM_MODE_Marshal(const TPMU_SYM_MODE *source, UINT16 *written, BYTE **buffer, INT32 *size, UINT32 selector); + LIB_EXPORT TPM_RC + TSS_TPMT_SYM_DEF_Marshal(const TPMT_SYM_DEF *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMT_SYM_DEF_OBJECT_Marshal(const TPMT_SYM_DEF_OBJECT *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPM2B_SYM_KEY_Marshal(const TPM2B_SYM_KEY *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPM2B_LABEL_Marshal(const TPM2B_LABEL *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMS_DERIVE_Marshal(const TPMS_DERIVE *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMS_SYMCIPHER_PARMS_Marshal(const TPMS_SYMCIPHER_PARMS *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPM2B_SENSITIVE_DATA_Marshal(const TPM2B_SENSITIVE_DATA *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMS_SENSITIVE_CREATE_Marshal(const TPMS_SENSITIVE_CREATE *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPM2B_SENSITIVE_CREATE_Marshal(const TPM2B_SENSITIVE_CREATE *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMS_SCHEME_HASH_Marshal(const TPMS_SCHEME_HASH *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMS_SCHEME_ECDAA_Marshal(const TPMS_SCHEME_ECDAA *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMI_ALG_KEYEDHASH_SCHEME_Marshal(const TPMI_ALG_KEYEDHASH_SCHEME *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMS_SCHEME_HMAC_Marshal(const TPMS_SCHEME_HMAC *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMS_SCHEME_XOR_Marshal(const TPMS_SCHEME_XOR *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMU_SCHEME_KEYEDHASH_Marshal(const TPMU_SCHEME_KEYEDHASH *source, UINT16 *written, BYTE **buffer, INT32 *size, UINT32 selector); + LIB_EXPORT TPM_RC + TSS_TPMT_KEYEDHASH_SCHEME_Marshal(const TPMT_KEYEDHASH_SCHEME *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMS_SIG_SCHEME_RSASSA_Marshal(const TPMS_SIG_SCHEME_RSASSA *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMS_SIG_SCHEME_RSAPSS_Marshal(const TPMS_SIG_SCHEME_RSAPSS *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMS_SIG_SCHEME_ECDSA_Marshal(const TPMS_SIG_SCHEME_ECDSA *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMS_SIG_SCHEME_SM2_Marshal(const TPMS_SIG_SCHEME_SM2 *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMS_SIG_SCHEME_ECSCHNORR_Marshal(const TPMS_SIG_SCHEME_ECSCHNORR *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMS_SIG_SCHEME_ECDAA_Marshal(const TPMS_SIG_SCHEME_ECDAA *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMU_SIG_SCHEME_Marshal(const TPMU_SIG_SCHEME *source, UINT16 *written, BYTE **buffer, INT32 *size, UINT32 selector); + LIB_EXPORT TPM_RC + TSS_TPMT_SIG_SCHEME_Marshal(const TPMT_SIG_SCHEME *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMS_ENC_SCHEME_OAEP_Marshal(const TPMS_ENC_SCHEME_OAEP *source, UINT16 *written, BYTE **buffer, INT32 *size) +#ifdef __ULTRAVISOR__ + __attribute__ ((const)) +#endif + ; + LIB_EXPORT TPM_RC + TSS_TPMS_ENC_SCHEME_RSAES_Marshal(const TPMS_ENC_SCHEME_RSAES *source, UINT16 *written, BYTE **buffer, INT32 *size) +#ifdef __ULTRAVISOR__ + __attribute__ ((const)) +#endif + ; + LIB_EXPORT TPM_RC + TSS_TPMS_KEY_SCHEME_ECDH_Marshal(const TPMS_KEY_SCHEME_ECDH *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMS_KEY_SCHEME_ECMQV_Marshal(const TPMS_KEY_SCHEME_ECMQV *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMS_SCHEME_MGF1_Marshal(const TPMS_SCHEME_MGF1 *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMS_SCHEME_KDF1_SP800_56A_Marshal(const TPMS_SCHEME_KDF1_SP800_56A *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMS_SCHEME_KDF2_Marshal(const TPMS_SCHEME_KDF2 *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMS_SCHEME_KDF1_SP800_108_Marshal(const TPMS_SCHEME_KDF1_SP800_108 *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMU_KDF_SCHEME_Marshal(const TPMU_KDF_SCHEME *source, UINT16 *written, BYTE **buffer, INT32 *size, UINT32 selector); + LIB_EXPORT TPM_RC + TSS_TPMT_KDF_SCHEME_Marshal(const TPMT_KDF_SCHEME *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMU_ASYM_SCHEME_Marshal(const TPMU_ASYM_SCHEME *source, UINT16 *written, BYTE **buffer, INT32 *size, UINT32 selector); + LIB_EXPORT TPM_RC + TSS_TPMI_ALG_RSA_SCHEME_Marshal(const TPMI_ALG_RSA_SCHEME *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMT_RSA_SCHEME_Marshal(const TPMT_RSA_SCHEME *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMI_ALG_RSA_DECRYPT_Marshal(const TPMI_ALG_RSA_DECRYPT *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMT_RSA_DECRYPT_Marshal(const TPMT_RSA_DECRYPT *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPM2B_PUBLIC_KEY_RSA_Marshal(const TPM2B_PUBLIC_KEY_RSA *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMI_RSA_KEY_BITS_Marshal(const TPMI_RSA_KEY_BITS *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPM2B_PRIVATE_KEY_RSA_Marshal(const TPM2B_PRIVATE_KEY_RSA *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPM2B_ECC_PARAMETER_Marshal(const TPM2B_ECC_PARAMETER *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMS_ECC_POINT_Marshal(const TPMS_ECC_POINT *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPM2B_ECC_POINT_Marshal(const TPM2B_ECC_POINT *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMI_ALG_ECC_SCHEME_Marshal(const TPMI_ALG_ECC_SCHEME *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMI_ECC_CURVE_Marshal(const TPMI_ECC_CURVE *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMT_ECC_SCHEME_Marshal(const TPMT_ECC_SCHEME *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMS_ALGORITHM_DETAIL_ECC_Marshal(const TPMS_ALGORITHM_DETAIL_ECC *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMS_SIGNATURE_RSA_Marshal(const TPMS_SIGNATURE_RSA *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMS_SIGNATURE_RSASSA_Marshal(const TPMS_SIGNATURE_RSASSA *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMS_SIGNATURE_RSAPSS_Marshal(const TPMS_SIGNATURE_RSAPSS *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMS_SIGNATURE_ECC_Marshal(const TPMS_SIGNATURE_ECC *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMS_SIGNATURE_ECDSA_Marshal(const TPMS_SIGNATURE_ECDSA *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMS_SIGNATURE_ECDAA_Marshal(const TPMS_SIGNATURE_ECDAA *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMS_SIGNATURE_SM2_Marshal(const TPMS_SIGNATURE_SM2 *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMS_SIGNATURE_ECSCHNORR_Marshal(const TPMS_SIGNATURE_ECSCHNORR *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMU_SIGNATURE_Marshal(const TPMU_SIGNATURE *source, UINT16 *written, BYTE **buffer, INT32 *size, UINT32 selector); + LIB_EXPORT TPM_RC + TSS_TPMT_SIGNATURE_Marshal(const TPMT_SIGNATURE *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPM2B_ENCRYPTED_SECRET_Marshal(const TPM2B_ENCRYPTED_SECRET *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMI_ALG_PUBLIC_Marshal(const TPMI_ALG_PUBLIC *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMU_PUBLIC_ID_Marshal(const TPMU_PUBLIC_ID *source, UINT16 *written, BYTE **buffer, INT32 *size, UINT32 selector); + LIB_EXPORT TPM_RC + TSS_TPMS_KEYEDHASH_PARMS_Marshal(const TPMS_KEYEDHASH_PARMS *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMS_RSA_PARMS_Marshal(const TPMS_RSA_PARMS *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMS_ECC_PARMS_Marshal(const TPMS_ECC_PARMS *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMU_PUBLIC_PARMS_Marshal(const TPMU_PUBLIC_PARMS *source, UINT16 *written, BYTE **buffer, INT32 *size, UINT32 selector); + LIB_EXPORT TPM_RC + TSS_TPMT_PUBLIC_PARMS_Marshal(const TPMT_PUBLIC_PARMS *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMT_PUBLIC_Marshal(const TPMT_PUBLIC *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMT_PUBLIC_D_Marshal(const TPMT_PUBLIC *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPM2B_PUBLIC_Marshal(const TPM2B_PUBLIC *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPM2B_TEMPLATE_Marshal(const TPM2B_TEMPLATE *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMU_SENSITIVE_COMPOSITE_Marshal(const TPMU_SENSITIVE_COMPOSITE *source, UINT16 *written, BYTE **buffer, INT32 *size, UINT32 selector); + LIB_EXPORT TPM_RC + TSS_TPMT_SENSITIVE_Marshal(const TPMT_SENSITIVE *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPM2B_SENSITIVE_Marshal(const TPM2B_SENSITIVE *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPM2B_PRIVATE_Marshal(const TPM2B_PRIVATE *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPM2B_ID_OBJECT_Marshal(const TPM2B_ID_OBJECT *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMA_NV_Marshal(const TPMA_NV *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMS_NV_PUBLIC_Marshal(const TPMS_NV_PUBLIC *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPM2B_NV_PUBLIC_Marshal(const TPM2B_NV_PUBLIC *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPM2B_CONTEXT_SENSITIVE_Marshal(const TPM2B_CONTEXT_SENSITIVE *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPM2B_CONTEXT_DATA_Marshal(const TPM2B_CONTEXT_DATA *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMS_CONTEXT_Marshal(const TPMS_CONTEXT *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPMS_CREATION_DATA_Marshal(const TPMS_CREATION_DATA *source, UINT16 *written, BYTE **buffer, INT32 *size); + LIB_EXPORT TPM_RC + TSS_TPM2B_CREATION_DATA_Marshal(const TPM2B_CREATION_DATA *source, UINT16 *written, BYTE **buffer, INT32 *size); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libstb/tss2/ibmtss/tssmarshal12.h b/libstb/tss2/ibmtss/tssmarshal12.h new file mode 100644 index 0000000..b2f21d4 --- /dev/null +++ b/libstb/tss2/ibmtss/tssmarshal12.h @@ -0,0 +1,192 @@ +/********************************************************************************/ +/* */ +/* TSS Marshal and Unmarshal */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: tssmarshal12.h 1286 2018-07-27 19:20:16Z kgoldman $ */ +/* */ +/* (c) Copyright IBM Corporation 2018. */ +/* */ +/* All rights reserved. */ +/* */ +/* Redistribution and use in source and binary forms, with or without */ +/* modification, are permitted provided that the following conditions are */ +/* met: */ +/* */ +/* Redistributions of source code must retain the above copyright notice, */ +/* this list of conditions and the following disclaimer. */ +/* */ +/* 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. */ +/* */ +/* Neither the names of the IBM Corporation nor the names of its */ +/* contributors may be used to endorse or promote products derived from */ +/* this software without specific prior written permission. */ +/* */ +/* 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. */ +/********************************************************************************/ + +/* This is a semi-public header. The API should be stable, but is less guaranteed. + + It is useful for applications that have to marshal / unmarshal + structures for file save / load. +*/ + +#ifndef TSSMARSHAL12_H +#define TSSMARSHAL12_H + +#include "BaseTypes.h" +#include <ibmtss/TPM_Types.h> + +#include <ibmtss/Parameters12.h> +#include <ibmtss/tpmstructures12.h> + +#ifdef __cplusplus +extern "C" { +#endif + + TPM_RC + TSS_ActivateIdentity_In_Marshalu(const ActivateIdentity_In *source, uint16_t *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_CreateEndorsementKeyPair_In_Marshalu(const CreateEndorsementKeyPair_In *source, uint16_t *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_CreateWrapKey_In_Marshalu(const CreateWrapKey_In *source, uint16_t *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_Extend_In_Marshalu(const Extend_In *source, uint16_t *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_FlushSpecific_In_Marshalu(const FlushSpecific_In *source, uint16_t *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_GetCapability12_In_Marshalu(const GetCapability12_In *source, uint16_t *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_LoadKey2_In_Marshalu(const LoadKey2_In *source, uint16_t *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_MakeIdentity_In_Marshalu(const MakeIdentity_In *source, uint16_t *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_NV_DefineSpace12_In_Marshalu(const NV_DefineSpace12_In *source, uint16_t *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_NV_ReadValueAuth_In_Marshalu(const NV_ReadValueAuth_In *source, uint16_t *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_NV_ReadValue_In_Marshalu(const NV_ReadValue_In *source, uint16_t *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_NV_WriteValue_In_Marshalu(const NV_WriteValue_In *source, uint16_t *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_NV_WriteValueAuth_In_Marshalu(const NV_WriteValueAuth_In *source, uint16_t *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_OwnerReadInternalPub_In_Marshalu(const OwnerReadInternalPub_In *source, uint16_t *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_OwnerSetDisable_In_Marshalu(const OwnerSetDisable_In *source, uint16_t *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_OSAP_In_Marshalu(const OSAP_In *source, uint16_t *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_PcrRead12_In_Marshalu(const PcrRead12_In *source, uint16_t *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_PCR_Reset12_In_Marshalu(const PCR_Reset12_In *source, uint16_t *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_Quote2_In_Marshalu(const Quote2_In *source, uint16_t *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_ReadPubek_In_Marshalu(const ReadPubek_In *source, uint16_t *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_Sign12_In_Marshalu(const Sign12_In *source, uint16_t *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_Startup12_In_Marshalu(const Startup12_In *source, UINT16 *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_TakeOwnership_In_Marshalu(const TakeOwnership_In *source, uint16_t *written, BYTE **buffer, uint32_t *size); + + TPM_RC + TSS_ActivateIdentity_Out_Unmarshalu(ActivateIdentity_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_CreateEndorsementKeyPair_Out_Unmarshalu(CreateEndorsementKeyPair_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_CreateWrapKey_Out_Unmarshalu(CreateWrapKey_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_Extend_Out_Unmarshalu(Extend_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_GetCapability12_Out_Unmarshalu(GetCapability12_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_LoadKey2_Out_Unmarshalu(LoadKey2_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_MakeIdentity_Out_Unmarshalu(MakeIdentity_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_NV_ReadValueAuth_Out_Unmarshalu(NV_ReadValueAuth_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_NV_ReadValue_Out_Unmarshalu(NV_ReadValue_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_OIAP_Out_Unmarshalu(OIAP_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_OSAP_Out_Unmarshalu(OSAP_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_OwnerReadInternalPub_Out_Unmarshalu(OwnerReadInternalPub_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_PcrRead12_Out_Unmarshalu(PcrRead12_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_Quote2_Out_Unmarshalu(Quote2_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_ReadPubek_Out_Unmarshalu(ReadPubek_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_Sign12_Out_Unmarshalu(Sign12_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_TakeOwnership_Out_Unmarshalu(TakeOwnership_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size); + + TPM_RC + TSS_TPM_STARTUP_TYPE_Marshalu(const TPM_STARTUP_TYPE *source, uint16_t *written, BYTE **buffer, uint32_t *size); + + TPM_RC + TSS_TPM_VERSION_Marshalu(const TPM_VERSION*source, uint16_t *written, BYTE **buffer, uint32_t *size); + + TPM_RC + TSS_TPM_PCR_SELECTION_Marshalu(const TPM_PCR_SELECTION *source, uint16_t *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_TPM_PCR_INFO_SHORT_Marshalu(const TPM_PCR_INFO_SHORT *source, uint16_t *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_TPM4B_TPM_PCR_INFO_LONG_Marshalu(const TPM_PCR_INFO_LONG *source, uint16_t *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_TPM_PCR_INFO_LONG_Marshalu(const TPM_PCR_INFO_LONG *source, uint16_t *written, BYTE **buffer, uint32_t *size); + + TPM_RC + TSS_TPM_SYMMETRIC_KEY_Marshalu(const TPM_SYMMETRIC_KEY *source, uint16_t *written, BYTE **buffer, uint32_t *size); + + TPM_RC + TSS_TPM_RSA_KEY_PARMS_Marshalu(const TPM_RSA_KEY_PARMS *source, uint16_t *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_TPMU_PARMS_Marshalu(const TPMU_PARMS *source, uint16_t *written, BYTE **buffer, uint32_t *size, uint32_t selector); + TPM_RC + TSS_TPM4B_TPMU_PARMS_Marshalu(const TPMU_PARMS *source, uint16_t *written, BYTE **buffer, uint32_t *size, uint32_t selector); + TPM_RC + TSS_TPM_KEY_PARMS_Marshalu(const TPM_KEY_PARMS *source, uint16_t *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_TPM_STORE_PUBKEY_Marshalu(const TPM_STORE_PUBKEY *source, uint16_t *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_TPM_KEY12_PUBKEY_Marshalu(const TPM_KEY12 *source, uint16_t *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_TPM_PUBKEY_Marshalu(const TPM_PUBKEY *source, uint16_t *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_TPM_KEY12_Marshalu(const TPM_KEY12 *source, uint16_t *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_TPM_QUOTE_INFO2_Marshalu(const TPM_QUOTE_INFO2 *source, uint16_t *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_TPM_EK_BLOB_Marshalu(const TPM_EK_BLOB *source, uint16_t *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_TPM_EK_BLOB_ACTIVATE_Marshalu(const TPM_EK_BLOB_ACTIVATE *source, uint16_t *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_TPM_NV_ATTRIBUTES_Marshalu(const TPM_NV_ATTRIBUTES *source, uint16_t *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_TPM_NV_DATA_PUBLIC_Marshalu(const TPM_NV_DATA_PUBLIC *source, uint16_t *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_TPM_CAP_VERSION_INFO_Marshalu(const TPM_CAP_VERSION_INFO *source, uint16_t *written, BYTE **buffer, uint32_t *size); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libstb/tss2/ibmtss/tssprint.h b/libstb/tss2/ibmtss/tssprint.h new file mode 100644 index 0000000..d471998 --- /dev/null +++ b/libstb/tss2/ibmtss/tssprint.h @@ -0,0 +1,294 @@ +/********************************************************************************/ +/* */ +/* Structure Print Utilities */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* */ +/* (c) Copyright IBM Corporation 2015, 2018. */ +/* */ +/* All rights reserved. */ +/* */ +/* Redistribution and use in source and binary forms, with or without */ +/* modification, are permitted provided that the following conditions are */ +/* met: */ +/* */ +/* Redistributions of source code must retain the above copyright notice, */ +/* this list of conditions and the following disclaimer. */ +/* */ +/* 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. */ +/* */ +/* Neither the names of the IBM Corporation nor the names of its */ +/* contributors may be used to endorse or promote products derived from */ +/* this software without specific prior written permission. */ +/* */ +/* 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. */ +/********************************************************************************/ + +/* This is a semi-public header. The API is not guaranteed to be stable, and the format of the + output is subject to change + + It is useful for application debug. +*/ + +#ifndef TSSPRINT_H +#define TSSPRINT_H + +#include <stdint.h> +#include <stdio.h> + +#include <ibmtss/TPM_Types.h> + +#define LOGLEVEL_INFO 6 /* LOGLEVEL_INFO prints a concise output */ +#define LOGLEVEL_DEBUG 7 /* LOGLEVEL_DEBUG prints a verbose output */ + +#ifdef __cplusplus +extern "C" { +#endif + +#if 0 + #ifdef TPM_TSS_NO_PRINT + + /* return code to eliminate "statement has no effect" compiler warning */ + extern int tssSwallowRc; + /* function prototype to match the printf prototype */ + int TSS_SwallowPrintf(const char *format, ...) +#ifdef __ULTRAVISOR__ + __attribute__ ((const)) +#endif +; + /* macro to compile out printf */ + #ifdef printf + #undef printf + #endif +#define printf tssSwallowRc = 0 && TSS_SwallowPrintf + + #endif +#endif + LIB_EXPORT + uint32_t TSS_Array_Scan(unsigned char **data, size_t *len, const char *string); + LIB_EXPORT + void TSS_PrintAll(const char *string, const unsigned char* buff, uint32_t length); + LIB_EXPORT + void TSS_PrintAlli(const char *string, unsigned int indent, + const unsigned char* buff, uint32_t length); + LIB_EXPORT + void TSS_PrintAllLogLevel(uint32_t log_level, const char *string, unsigned int indent, + const unsigned char* buff, uint32_t length); + LIB_EXPORT + void TSS_TPM2B_Print(const char *string, unsigned int indent, TPM2B *source); + LIB_EXPORT + void TSS_TPM_ALG_ID_Print(const char *string, TPM_ALG_ID source, unsigned int indent); + LIB_EXPORT + void TSS_TPM_ECC_CURVE_Print(const char *string, TPM_ECC_CURVE source, unsigned int indent); + LIB_EXPORT + void TSS_TPMS_TAGGED_POLICY_Print(TPMS_TAGGED_POLICY *source, unsigned int indent); + LIB_EXPORT + void TSS_TPM_CC_Print(const char *string, TPM_CC source, unsigned int indent); + LIB_EXPORT + void TSS_TPM_TPMA_ALGORITHM_Print(TPMA_ALGORITHM source, unsigned int indent); + LIB_EXPORT + void TSS_TPM_CLOCK_ADJUST_Print(const char *string, TPM_CLOCK_ADJUST source, unsigned int indent); + LIB_EXPORT + void TSS_TPM_EO_Print(const char *string, TPM_EO source, unsigned int indent); + LIB_EXPORT + void TSS_TPM_ST_Print(const char *string, TPM_ST source, unsigned int indent); + LIB_EXPORT + void TSS_TPM_SU_Print(const char *string, TPM_SU source, unsigned int indent); + LIB_EXPORT + void TSS_TPM_SE_Print(const char *string, TPM_SE source, unsigned int indent); + LIB_EXPORT + void TSS_TPM_CAP_Print(const char *string, TPM_CAP source, unsigned int indent); + LIB_EXPORT + void TSS_TPM_HANDLE_Print(const char *string, TPM_HANDLE source, unsigned int indent); + LIB_EXPORT + void TSS_TPM_TPMA_ALGORITHM_Print(TPMA_ALGORITHM source, unsigned int indent); + LIB_EXPORT + void TSS_TPMA_OBJECT_Print(const char *string, TPMA_OBJECT source, unsigned int indent); + LIB_EXPORT + void TSS_TPMA_LOCALITY_Print(TPMA_LOCALITY source, unsigned int indent); + LIB_EXPORT + void TSS_TPMA_SESSION_Print(TPMA_SESSION source, unsigned int indent); + LIB_EXPORT + void TSS_TPMA_PERMANENT_Print(TPMA_PERMANENT source, unsigned int indent); + LIB_EXPORT + void TSS_TPMA_STARTUP_CLEAR_Print(TPMA_STARTUP_CLEAR source, unsigned int indent); + LIB_EXPORT + void TSS_TPMA_MEMORY_Print(TPMA_MEMORY source, unsigned int indent); + LIB_EXPORT + void TSS_TPMA_MODES_Print(TPMA_MODES source, unsigned int indent); + LIB_EXPORT + void TSS_TPMI_YES_NO_Print(const char *string, TPMI_YES_NO source, unsigned int indent); + LIB_EXPORT + void TSS_TPMU_HA_Print(TPMU_HA *source, uint32_t selector, unsigned int indent); + LIB_EXPORT + void TSS_TPMT_HA_Print(TPMT_HA *source, unsigned int indent); + LIB_EXPORT + void TSS_TPMS_PCR_SELECT_Print(TPMS_PCR_SELECT *source, unsigned int indent); + LIB_EXPORT + void TSS_TPMS_PCR_SELECTION_Print(TPMS_PCR_SELECTION *source, unsigned int indent); + LIB_EXPORT + void TSS_TPML_PCR_SELECTION_Print(TPML_PCR_SELECTION *source, unsigned int indent); + LIB_EXPORT + void TSS_TPMT_TK_CREATION_Print(TPMT_TK_CREATION *source, unsigned int indent); + LIB_EXPORT + void TSS_TPMT_TK_VERIFIED_Print(TPMT_TK_VERIFIED *source, unsigned int indent); + LIB_EXPORT + void TSS_TPMT_TK_AUTH_Print(TPMT_TK_AUTH *source, unsigned int indent); + LIB_EXPORT + void TSS_TPMT_TK_HASHCHECK_Print(TPMT_TK_HASHCHECK *source, unsigned int indent); + LIB_EXPORT + void TSS_TPML_CC_Print(TPML_CC *source, unsigned int indent); + LIB_EXPORT + void TSS_TPML_ALG_Print(TPML_ALG *source, unsigned int indent); + LIB_EXPORT + void TSS_TPML_DIGEST_Print(TPML_DIGEST *source, unsigned int indent); + LIB_EXPORT + void TSS_TPML_DIGEST_VALUES_Print(TPML_DIGEST_VALUES *source, unsigned int indent); + LIB_EXPORT + void TSS_TPMS_CLOCK_INFO_Print(TPMS_CLOCK_INFO *source, unsigned int indent); + LIB_EXPORT + void TSS_TPMS_TIME_INFO_Print(TPMS_TIME_INFO *source, unsigned int indent); + LIB_EXPORT + void TSS_TPMS_TIME_ATTEST_INFO_Print(TPMS_TIME_ATTEST_INFO *source, unsigned int indent); + LIB_EXPORT + void TSS_TPMS_CERTIFY_INFO_Print(TPMS_CERTIFY_INFO *source, unsigned int indent); + LIB_EXPORT + void TSS_TPMS_QUOTE_INFO_Print(TPMS_QUOTE_INFO *source, unsigned int indent); + LIB_EXPORT + void TSS_TPMS_COMMAND_AUDIT_INFO_Print(TPMS_COMMAND_AUDIT_INFO *source, unsigned int indent); + LIB_EXPORT + void TSS_TPMS_SESSION_AUDIT_INFO_Print(TPMS_SESSION_AUDIT_INFO *source, unsigned int indent); + LIB_EXPORT + void TSS_TPMS_CREATION_INFO_Print(TPMS_CREATION_INFO *source, unsigned int indent); + LIB_EXPORT + void TSS_TPMS_NV_CERTIFY_INFO_Print(TPMS_NV_CERTIFY_INFO *source, unsigned int indent); + LIB_EXPORT + void TSS_TPMI_ST_ATTEST_Print(const char *string, TPMI_ST_ATTEST selector, unsigned int indent); + LIB_EXPORT + void TSS_TPMU_ATTEST_Print(TPMU_ATTEST *source, TPMI_ST_ATTEST selector, unsigned int indent); + LIB_EXPORT + void TSS_TPMS_ATTEST_Print(TPMS_ATTEST *source, unsigned int indent); + LIB_EXPORT + void TSS_TPM2B_ATTEST_Print(TPM2B_ATTEST *source, unsigned int indent); + LIB_EXPORT + void TSS_TPMS_AUTH_COMMAND_Print(TPMS_AUTH_COMMAND *source, unsigned int indent); + LIB_EXPORT + void TSS_TPMS_AUTH_RESPONSE_Print(TPMS_AUTH_RESPONSE *source, unsigned int indent); + LIB_EXPORT + void TSS_TPMU_SYM_KEY_BITS_Print(TPMU_SYM_KEY_BITS *source, TPMI_ALG_SYM selector, unsigned int indent); + LIB_EXPORT + void TSS_TPM_KEY_BITS_Print(TPM_KEY_BITS source, unsigned int indent); + LIB_EXPORT + void TSS_TPMT_SYM_DEF_Print(TPMT_SYM_DEF *source, unsigned int indent); + LIB_EXPORT + void TSS_TPMT_SYM_DEF_OBJECT_Print(TPMT_SYM_DEF_OBJECT *source, unsigned int indent); + LIB_EXPORT + void TSS_TPMS_DERIVE_Print(TPMS_DERIVE *source, unsigned int indent); + LIB_EXPORT + void TSS_TPMS_SENSITIVE_CREATE_Print(TPMS_SENSITIVE_CREATE *source, unsigned int indent); + LIB_EXPORT + void TSS_TPM2B_SENSITIVE_CREATE_Print(const char *string, TPM2B_SENSITIVE_CREATE *source, unsigned int indent); + LIB_EXPORT + void TSS_TPMS_SCHEME_ECDAA_Print(TPMS_SCHEME_ECDAA *source, unsigned int indent); + LIB_EXPORT + void TSS_TPMS_SCHEME_XOR_Print(TPMS_SCHEME_XOR *source, unsigned int indent); + LIB_EXPORT + void TSS_TPMU_SCHEME_KEYEDHASH_Print(TPMU_SCHEME_KEYEDHASH *source, TPMI_ALG_KEYEDHASH_SCHEME selector, unsigned int indent); + LIB_EXPORT + void TSS_TPMT_KEYEDHASH_SCHEME_Print(TPMT_KEYEDHASH_SCHEME *source, unsigned int indent); + LIB_EXPORT + void TSS_TPMU_SIG_SCHEME_Print(TPMU_SIG_SCHEME *source, TPMI_ALG_SIG_SCHEME selector, unsigned int indent); + LIB_EXPORT + void TSS_TPMT_SIG_SCHEME_Print(TPMT_SIG_SCHEME *source, unsigned int indent); + LIB_EXPORT + void TSS_TPMT_KDF_SCHEME_Print(TPMT_KDF_SCHEME *source, unsigned int indent); + LIB_EXPORT + void TSS_TPMU_ASYM_SCHEME_Print(TPMU_ASYM_SCHEME *source, TPMI_ALG_ASYM_SCHEME selector, unsigned int indent); + LIB_EXPORT + void TSS_TPMT_ASYM_SCHEME_Print(TPMT_ASYM_SCHEME *source, unsigned int indent); + LIB_EXPORT + void TSS_TPMT_RSA_SCHEME_Print(TPMT_RSA_SCHEME *source, unsigned int indent); + LIB_EXPORT + void TSS_TPMT_RSA_DECRYPT_Print(TPMT_RSA_DECRYPT *source, unsigned int indent); + LIB_EXPORT + void TSS_TPMI_RSA_KEY_BITS_Print(TPMI_RSA_KEY_BITS source, unsigned int indent); + LIB_EXPORT + void TSS_TPMS_ECC_POINT_Print(TPMS_ECC_POINT *source, unsigned int indent); + LIB_EXPORT + void TSS_TPM2B_ECC_POINT_Print(const char *string, TPM2B_ECC_POINT *source, unsigned int indent); + LIB_EXPORT + void TSS_TPMI_ECC_CURVE_Print(const char *string, TPMI_ECC_CURVE source, unsigned int indent); + LIB_EXPORT + void TSS_TPMT_ECC_SCHEME_Print(TPMT_ECC_SCHEME *source, unsigned int indent); + LIB_EXPORT + void TSS_TPMS_ALGORITHM_DETAIL_ECC_Print(TPMS_ALGORITHM_DETAIL_ECC *source, unsigned int indent); + LIB_EXPORT + void TSS_TPMS_SIGNATURE_RSA_Print(TPMS_SIGNATURE_RSA *source, unsigned int indent); + LIB_EXPORT + void TSS_TPMS_SIGNATURE_RSASSA_Print(TPMS_SIGNATURE_RSASSA *source, unsigned int indent); + LIB_EXPORT + void TSS_TPMS_SIGNATURE_ECC_Print(TPMS_SIGNATURE_ECC *source, unsigned int indent); + LIB_EXPORT + void TSS_TPMU_SIGNATURE_Print(TPMU_SIGNATURE *source, TPMI_ALG_SIG_SCHEME selector, unsigned int indent); + LIB_EXPORT + void TSS_TPMT_SIGNATURE_Print(TPMT_SIGNATURE *source, unsigned int indent); + LIB_EXPORT + void TSS_TPMU_PUBLIC_ID_Print(TPMU_PUBLIC_ID *source, TPMI_ALG_PUBLIC selector, unsigned int indent); + LIB_EXPORT + void TSS_TPMI_ALG_PUBLIC_Print(const char *string, TPMI_ALG_PUBLIC source, unsigned int indent); + LIB_EXPORT + void TSS_TPMS_ECC_PARMS_Print(TPMS_ECC_PARMS *source, unsigned int indent); + LIB_EXPORT + void TSS_TPMS_RSA_PARMS_Print(TPMS_RSA_PARMS *source, unsigned int indent); + LIB_EXPORT + void TSS_TPMS_KEYEDHASH_PARMS_Print(TPMS_KEYEDHASH_PARMS *source, unsigned int indent); + LIB_EXPORT + void TSS_TPMS_ASYM_PARMS_Print(TPMS_ASYM_PARMS *source, unsigned int indent); + LIB_EXPORT + void TSS_TPMU_PUBLIC_PARMS_Print(TPMU_PUBLIC_PARMS *source, UINT32 selector, unsigned int indent); + LIB_EXPORT + void TSS_TPMT_PUBLIC_PARMS_Print(TPMT_PUBLIC_PARMS *source, unsigned int indent); + LIB_EXPORT + void TSS_TPMT_PUBLIC_Print(TPMT_PUBLIC *source, unsigned int indent); + LIB_EXPORT + void TSS_TPM2B_PUBLIC_Print(const char *string, TPM2B_PUBLIC *source, unsigned int indent); + LIB_EXPORT + void TSS_TPMU_SENSITIVE_COMPOSITE_Print(TPMU_SENSITIVE_COMPOSITE *source, uint32_t selector, unsigned int indent); + LIB_EXPORT + void TSS_TPMT_SENSITIVE_Print(TPMT_SENSITIVE *source, unsigned int indent); + LIB_EXPORT + void TSS_TPM2B_SENSITIVE_Print(TPM2B_SENSITIVE *source, unsigned int indent); + LIB_EXPORT + void TSS_TPMS_NV_PIN_COUNTER_PARAMETERS_Print(TPMS_NV_PIN_COUNTER_PARAMETERS *source, unsigned int indent); + LIB_EXPORT + void TSS_TPMA_NV_Print(TPMA_NV source, unsigned int indent); + LIB_EXPORT + void TSS_TPMS_NV_PUBLIC_Print(TPMS_NV_PUBLIC *source, unsigned int indent); + LIB_EXPORT + void TSS_TPM2B_NV_PUBLIC_Print(TPM2B_NV_PUBLIC *source, unsigned int indent); + LIB_EXPORT + void TSS_TPMS_CONTEXT_DATA_Print(TPMS_CONTEXT_DATA *source, unsigned int indent); + LIB_EXPORT + void TSS_TPMS_CONTEXT_Print(TPMS_CONTEXT *source, unsigned int indent); + LIB_EXPORT + void TSS_TPMS_CREATION_DATA_Print(TPMS_CREATION_DATA *source, unsigned int indent); + LIB_EXPORT + void TSS_TPM2B_CREATION_DATA_Print(TPM2B_CREATION_DATA *source, unsigned int indent); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libstb/tss2/ibmtss/tssprintcmd.h b/libstb/tss2/ibmtss/tssprintcmd.h new file mode 100644 index 0000000..db619b9 --- /dev/null +++ b/libstb/tss2/ibmtss/tssprintcmd.h @@ -0,0 +1,173 @@ +/********************************************************************************/ +/* */ +/* Structure Print Utilities */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: tssprintcmd.h 1257 2018-06-27 20:52:08Z kgoldman $ */ +/* */ +/* (c) Copyright IBM Corporation 2015, 2018. */ +/* */ +/* All rights reserved. */ +/* */ +/* Redistribution and use in source and binary forms, with or without */ +/* modification, are permitted provided that the following conditions are */ +/* met: */ +/* */ +/* Redistributions of source code must retain the above copyright notice, */ +/* this list of conditions and the following disclaimer. */ +/* */ +/* 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. */ +/* */ +/* Neither the names of the IBM Corporation nor the names of its */ +/* contributors may be used to endorse or promote products derived from */ +/* this software without specific prior written permission. */ +/* */ +/* 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. */ +/********************************************************************************/ + +/* This is a semi-public header. The API is not guaranteed to be stable, and the format of the + output is subject to change + + It is useful for application debug. +*/ + +#ifndef TSSPRINTCMD_H +#define TSSPRINTCMD_H + +#include <ibmtss/tss.h> + +#include <stdint.h> +#include <stdio.h> + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef TPM_TPM20 + void ActivateCredential_In_Print(ActivateCredential_In *in, unsigned int indent); + void CertifyCreation_In_Print(CertifyCreation_In *in, unsigned int indent); + void Certify_In_Print(Certify_In *in, unsigned int indent); + void ChangeEPS_In_Print(ChangeEPS_In *in, unsigned int indent); + void ChangePPS_In_Print(ChangePPS_In *in, unsigned int indent); + void ClearControl_In_Print(ClearControl_In *in, unsigned int indent); + void Clear_In_Print(Clear_In *in, unsigned int indent); + void ClockRateAdjust_In_Print(ClockRateAdjust_In *in, unsigned int indent); + void ClockSet_In_Print(ClockSet_In *in, unsigned int indent); + void Commit_In_Print(Commit_In *in, unsigned int indent); + void ContextLoad_In_Print(ContextLoad_In *in, unsigned int indent); + void ContextSave_In_Print(ContextSave_In *in, unsigned int indent); + void Create_In_Print(Create_In *in, unsigned int indent); + void CreateLoaded_In_Print(CreateLoaded_In *in, unsigned int indent); + void CreatePrimary_In_Print(CreatePrimary_In *in, unsigned int indent); + void DictionaryAttackLockReset_In_Print(DictionaryAttackLockReset_In *in, unsigned int indent); + void DictionaryAttackParameters_In_Print(DictionaryAttackParameters_In *in, unsigned int indent); + void Duplicate_In_Print(Duplicate_In *in, unsigned int indent); + void ECC_Parameters_In_Print(ECC_Parameters_In *in, unsigned int indent); + void ECDH_KeyGen_In_Print(ECDH_KeyGen_In *in, unsigned int indent); + void ECDH_ZGen_In_Print(ECDH_ZGen_In *in, unsigned int indent); + void EC_Ephemeral_In_Print(EC_Ephemeral_In *in, unsigned int indent); + void EncryptDecrypt_In_Print(EncryptDecrypt_In *in, unsigned int indent); + void EncryptDecrypt2_In_Print(EncryptDecrypt2_In *in, unsigned int indent); + void EventSequenceComplete_In_Print(EventSequenceComplete_In *in, unsigned int indent); + void EvictControl_In_Print(EvictControl_In *in, unsigned int indent); + void FlushContext_In_Print(FlushContext_In *in, unsigned int indent); + void GetCapability_In_Print(GetCapability_In *in, unsigned int indent); + void GetCommandAuditDigest_In_Print(GetCommandAuditDigest_In *in, unsigned int indent); + void GetRandom_In_Print(GetRandom_In *in, unsigned int indent); + void GetSessionAuditDigest_In_Print(GetSessionAuditDigest_In *in, unsigned int indent); + void GetTime_In_Print(GetTime_In *in, unsigned int indent); + void HMAC_Start_In_Print(HMAC_Start_In *in, unsigned int indent); + void HMAC_In_Print(HMAC_In *in, unsigned int indent); + void HashSequenceStart_In_Print(HashSequenceStart_In *in, unsigned int indent); + void Hash_In_Print(Hash_In *in, unsigned int indent); + void HierarchyChangeAuth_In_Print(HierarchyChangeAuth_In *in, unsigned int indent); + void HierarchyControl_In_Print(HierarchyControl_In *in, unsigned int indent); + void Import_In_Print(Import_In *in, unsigned int indent); + void IncrementalSelfTest_In_Print(IncrementalSelfTest_In *in, unsigned int indent); + void LoadExternal_In_Print(LoadExternal_In *in, unsigned int indent); + void Load_In_Print(Load_In *in, unsigned int indent); + void MakeCredential_In_Print(MakeCredential_In *in, unsigned int indent); + void NTC2_PreConfig_In_Print(NTC2_PreConfig_In *in, unsigned int indent); + void NV_Certify_In_Print(NV_Certify_In *in, unsigned int indent); + void NV_ChangeAuth_In_Print(NV_ChangeAuth_In *in, unsigned int indent); + void NV_DefineSpace_In_Print(NV_DefineSpace_In *in, unsigned int indent); + void NV_Extend_In_Print(NV_Extend_In *in, unsigned int indent); + void NV_GlobalWriteLock_In_Print(NV_GlobalWriteLock_In *in, unsigned int indent); + void NV_Increment_In_Print(NV_Increment_In *in, unsigned int indent); + void NV_ReadLock_In_Print(NV_ReadLock_In *in, unsigned int indent); + void NV_ReadPublic_In_Print(NV_ReadPublic_In *in, unsigned int indent); + void NV_Read_In_Print(NV_Read_In *in, unsigned int indent); + void NV_SetBits_In_Print(NV_SetBits_In *in, unsigned int indent); + void NV_UndefineSpaceSpecial_In_Print(NV_UndefineSpaceSpecial_In *in, unsigned int indent); + void NV_UndefineSpace_In_Print(NV_UndefineSpace_In *in, unsigned int indent); + void NV_WriteLock_In_Print(NV_WriteLock_In *in, unsigned int indent); + void NV_Write_In_Print(NV_Write_In *in, unsigned int indent); + void ObjectChangeAuth_In_Print(ObjectChangeAuth_In *in, unsigned int indent); + void PCR_Allocate_In_Print(PCR_Allocate_In *in, unsigned int indent); + void PCR_Event_In_Print(PCR_Event_In *in, unsigned int indent); + void PCR_Extend_In_Print(PCR_Extend_In *in, unsigned int indent); + void PCR_Read_In_Print(PCR_Read_In *in, unsigned int indent); + void PCR_Reset_In_Print(PCR_Reset_In *in, unsigned int indent); + void PCR_SetAuthPolicy_In_Print(PCR_SetAuthPolicy_In *in, unsigned int indent); + void PCR_SetAuthValue_In_Print(PCR_SetAuthValue_In *in, unsigned int indent); + void PP_Commands_In_Print(PP_Commands_In *in, unsigned int indent); + void PolicyAuthValue_In_Print(PolicyAuthValue_In *in, unsigned int indent); + void PolicyAuthorizeNV_In_Print(PolicyAuthorizeNV_In *in, unsigned int indent); + void PolicyAuthorize_In_Print(PolicyAuthorize_In *in, unsigned int indent); + void PolicyCommandCode_In_Print(PolicyCommandCode_In *in, unsigned int indent); + void PolicyCounterTimer_In_Print(PolicyCounterTimer_In *in, unsigned int indent); + void PolicyCpHash_In_Print(PolicyCpHash_In *in, unsigned int indent); + void PolicyDuplicationSelect_In_Print(PolicyDuplicationSelect_In *in, unsigned int indent); + void PolicyGetDigest_In_Print(PolicyGetDigest_In *in, unsigned int indent); + void PolicyLocality_In_Print(PolicyLocality_In *in, unsigned int indent); + void PolicyNV_In_Print(PolicyNV_In *in, unsigned int indent); + void PolicyNameHash_In_Print(PolicyNameHash_In *in, unsigned int indent); + void PolicyNvWritten_In_Print(PolicyNvWritten_In *in, unsigned int indent); + void PolicyOR_In_Print(PolicyOR_In *in, unsigned int indent); + void PolicyPCR_In_Print(PolicyPCR_In *in, unsigned int indent); + void PolicyPassword_In_Print(PolicyPassword_In *in, unsigned int indent); + void PolicyPhysicalPresence_In_Print(PolicyPhysicalPresence_In *in, unsigned int indent); + void PolicyRestart_In_Print(PolicyRestart_In *in, unsigned int indent); + void PolicySecret_In_Print(PolicySecret_In *in, unsigned int indent); + void PolicySigned_In_Print(PolicySigned_In *in, unsigned int indent); + void PolicyTemplate_In_Print(PolicyTemplate_In *in, unsigned int indent); + void PolicyTicket_In_Print(PolicyTicket_In *in, unsigned int indent); + void Quote_In_Print(Quote_In *in, unsigned int indent); + void RSA_Decrypt_In_Print(RSA_Decrypt_In *in, unsigned int indent); + void RSA_Encrypt_In_Print(RSA_Encrypt_In *in, unsigned int indent); + void ReadPublic_In_Print(ReadPublic_In *in, unsigned int indent); + void Rewrap_In_Print(Rewrap_In *in, unsigned int indent); + void SelfTest_In_Print(SelfTest_In *in, unsigned int indent); + void SequenceComplete_In_Print(SequenceComplete_In *in, unsigned int indent); + void SequenceUpdate_In_Print(SequenceUpdate_In *in, unsigned int indent); + void SetAlgorithmSet_In_Print(SetAlgorithmSet_In *in, unsigned int indent); + void SetCommandCodeAuditStatus_In_Print(SetCommandCodeAuditStatus_In *in, unsigned int indent); + void SetPrimaryPolicy_In_Print(SetPrimaryPolicy_In *in, unsigned int indent); + void Shutdown_In_Print(Shutdown_In *in, unsigned int indent); + void Sign_In_Print(Sign_In *in, unsigned int indent); + void StartAuthSession_In_Print(StartAuthSession_In *in, unsigned int indent); + void Startup_In_Print(Startup_In *in, unsigned int indent); + void StirRandom_In_Print(StirRandom_In *in, unsigned int indent); + void TestParms_In_Print(TestParms_In *in, unsigned int indent); + void Unseal_In_Print(Unseal_In *in, unsigned int indent); + void VerifySignature_In_Print(VerifySignature_In *in, unsigned int indent); + void ZGen_2Phase_In_Print(ZGen_2Phase_In *in, unsigned int indent); +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libstb/tss2/ibmtss/tssresponsecode.h b/libstb/tss2/ibmtss/tssresponsecode.h new file mode 100644 index 0000000..ae85604 --- /dev/null +++ b/libstb/tss2/ibmtss/tssresponsecode.h @@ -0,0 +1,62 @@ +/********************************************************************************/ +/* */ +/* TSS Response Code Printer */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: tssresponsecode.h 1257 2018-06-27 20:52:08Z kgoldman $ */ +/* */ +/* (c) Copyright IBM Corporation 2015, 2018. */ +/* */ +/* All rights reserved. */ +/* */ +/* Redistribution and use in source and binary forms, with or without */ +/* modification, are permitted provided that the following conditions are */ +/* met: */ +/* */ +/* Redistributions of source code must retain the above copyright notice, */ +/* this list of conditions and the following disclaimer. */ +/* */ +/* 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. */ +/* */ +/* Neither the names of the IBM Corporation nor the names of its */ +/* contributors may be used to endorse or promote products derived from */ +/* this software without specific prior written permission. */ +/* */ +/* 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. */ +/********************************************************************************/ + +/* This is a semi-public header. The API likely to be stable, but the format and text output are + subject to change + + It is useful for application debug. +*/ + +#ifndef TSSRESPONSECODE_H +#define TSSRESPONSECODE_H + +#include <ibmtss/TPM_Types.h> + +#ifdef __cplusplus +extern "C" { +#endif + + LIB_EXPORT + void TSS_ResponseCode_toString(const char **msg, const char **submsg, const char **num, TPM_RC rc); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libstb/tss2/ibmtss/tsstransmit.h b/libstb/tss2/ibmtss/tsstransmit.h new file mode 100644 index 0000000..8e12d64 --- /dev/null +++ b/libstb/tss2/ibmtss/tsstransmit.h @@ -0,0 +1,76 @@ +/********************************************************************************/ +/* */ +/* TSS Transmit */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: tsstransmit.h 1257 2018-06-27 20:52:08Z kgoldman $ */ +/* */ +/* (c) Copyright IBM Corporation 2015, 2017, 2018 */ +/* */ +/* All rights reserved. */ +/* */ +/* Redistribution and use in source and binary forms, with or without */ +/* modification, are permitted provided that the following conditions are */ +/* met: */ +/* */ +/* Redistributions of source code must retain the above copyright notice, */ +/* this list of conditions and the following disclaimer. */ +/* */ +/* 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. */ +/* */ +/* Neither the names of the IBM Corporation nor the names of its */ +/* contributors may be used to endorse or promote products derived from */ +/* this software without specific prior written permission. */ +/* */ +/* 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 TSSTRANSMIT_H +#define TSSTRANSMIT_H + +#include <stdint.h> + +#include <ibmtss/tss.h> + +/* copy of TpmTcpProtocol.h. These are only used with the SW TPM. */ +#define TPM_SIGNAL_POWER_ON 1 +#define TPM_SIGNAL_POWER_OFF 2 +#define TPM_SIGNAL_NV_ON 11 + +/* copy of TpmTcpProtocol.h. These are only used with the SW TPM, but they may be used with a + respurce manager in the future. */ +#define TPM_SEND_COMMAND 8 +#define TPM_SESSION_END 20 + +#ifdef __cplusplus +extern "C" { +#endif + LIB_EXPORT TPM_RC + TSS_TransmitPlatform(TSS_CONTEXT *tssContext, + uint32_t command, const char *message); + LIB_EXPORT TPM_RC + TSS_Transmit(TSS_CONTEXT *tssContext, + uint8_t *responseBuffer, uint32_t *read, + const uint8_t *commandBuffer, uint32_t written, + const char *message); + + LIB_EXPORT TPM_RC + TSS_Close(TSS_CONTEXT *tssContext); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libstb/tss2/ibmtss/tssutils.h b/libstb/tss2/ibmtss/tssutils.h new file mode 100644 index 0000000..11711de --- /dev/null +++ b/libstb/tss2/ibmtss/tssutils.h @@ -0,0 +1,98 @@ +/********************************************************************************/ +/* */ +/* TSS and Application Utilities */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: tssutils.h 1324 2018-08-31 16:36:12Z kgoldman $ */ +/* */ +/* (c) Copyright IBM Corporation 2015, 2018. */ +/* */ +/* All rights reserved. */ +/* */ +/* Redistribution and use in source and binary forms, with or without */ +/* modification, are permitted provided that the following conditions are */ +/* met: */ +/* */ +/* Redistributions of source code must retain the above copyright notice, */ +/* this list of conditions and the following disclaimer. */ +/* */ +/* 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. */ +/* */ +/* Neither the names of the IBM Corporation nor the names of its */ +/* contributors may be used to endorse or promote products derived from */ +/* this software without specific prior written permission. */ +/* */ +/* 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. */ +/********************************************************************************/ + +/* This is a semi-public header. The API is subject to change. + + It is useful rapid application development, and as sample code. It is risky for production code. + +*/ + +#ifndef TSSUTILS_H +#define TSSUTILS_H + +#include <stdio.h> + +#include <ibmtss/TPM_Types.h> + +#ifdef __cplusplus +extern "C" { +#endif + + typedef TPM_RC (*UnmarshalFunction_t)(void *target, uint8_t **buffer, uint32_t *size); + typedef TPM_RC (*UnmarshalFunctionFlag_t)(void *target, uint8_t **buffer, uint32_t *size, BOOL allowNull); + typedef TPM_RC (*MarshalFunction_t)(void *source, uint16_t *written, uint8_t **buffer, uint32_t *size); + + LIB_EXPORT + TPM_RC TSS_Malloc(unsigned char **buffer, uint32_t size); + LIB_EXPORT + TPM_RC TSS_Realloc(unsigned char **buffer, uint32_t size); + + LIB_EXPORT + TPM_RC TSS_Structure_Marshal(uint8_t **buffer, + uint16_t *written, + void *structure, + MarshalFunction_t marshalFunction); + + LIB_EXPORT + TPM_RC TSS_TPM2B_Copy(TPM2B *target, TPM2B *source, uint16_t targetSize); + + LIB_EXPORT + TPM_RC TSS_TPM2B_Append(TPM2B *target, TPM2B *source, uint16_t targetSize); + + LIB_EXPORT + TPM_RC TSS_TPM2B_Create(TPM2B *target, uint8_t *buffer, uint16_t size, uint16_t targetSize); + + LIB_EXPORT + TPM_RC TSS_TPM2B_CreateUint32(TPM2B *target, uint32_t source, uint16_t targetSize); + + LIB_EXPORT + TPM_RC TSS_TPM2B_StringCopy(TPM2B *target, const char *source, uint16_t targetSize); + + LIB_EXPORT + BOOL TSS_TPM2B_Compare(TPM2B *expect, TPM2B *actual); + +#ifdef __cplusplus +} +#endif + +#ifndef TPM_TSS_NOFILE +#include <ibmtss/tssfile.h> +#endif + +#endif diff --git a/libstb/tss2/libtss.c b/libstb/tss2/libtss.c new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/libstb/tss2/libtss.c diff --git a/libstb/tss2/libtss.h b/libstb/tss2/libtss.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/libstb/tss2/libtss.h diff --git a/libstb/tss2/netinet/in.h b/libstb/tss2/netinet/in.h new file mode 100644 index 0000000..ecb8a00 --- /dev/null +++ b/libstb/tss2/netinet/in.h @@ -0,0 +1,13 @@ +#ifndef _NETINIT_IN_H +#define _NETINIT_IN_H + +//#pragma message "Implment in.h functions \n" + +#include <include/types.h> + +#define htonl(x) cpu_to_be32(x) +#define ntohl(x) be32_to_cpu(x) +#define htons(x) cpu_to_be16(x) +#define ntohs(x) be16_to_cpu(x) + +#endif /* _NETINIT_IN_H */ diff --git a/libstb/tss2/tpm_nv.c b/libstb/tss2/tpm_nv.c new file mode 100644 index 0000000..02b97bc --- /dev/null +++ b/libstb/tss2/tpm_nv.c @@ -0,0 +1,44 @@ +#include "tssskiboot.h" +#include <libstb/tpm2.h> +#include "tpm_nv.h" +#include <skiboot.h> + +int tpm_nv_init(void) +{ + TSS_CONTEXT *ctx; + NV_ReadPublic_In in; + NV_ReadPublic_Out out; + TPM_RC rc; + + prlog(PR_INFO, "%s begin\n", __func__); + rc = TSS_Create(&ctx); + if (rc) { + prlog(PR_INFO, "%s: TSS_Create failed rc=%d\n", __func__, rc); + return rc; + } + + TSS_SetProperty(NULL, TPM_TRACE_LEVEL, "2"); + + ctx->tpm_device = tpm2_get_device(); + ctx->tpm_driver = tpm2_get_driver(); + ctx->tssInterfaceType = "skiboot"; + + in.nvIndex = 0x01c10190; + + rc = TSS_NV_ReadPublic(ctx, &in, &out); + if (rc) { + prlog(PR_INFO, "%s: TSS_NV_ReadPublic failed rc=%d\n", __func__, rc); + goto out; + } + prlog(PR_INFO, "nvreadpublic: name algorithm %04x\n", out.nvPublic.nvPublic.nameAlg); + prlog(PR_INFO, "nvreadpublic: data size %u\n", out.nvPublic.nvPublic.dataSize); + prlog(PR_INFO, "nvreadpublic: attributes %08x\n", out.nvPublic.nvPublic.attributes.val); + TSS_TPMA_NV_Print(out.nvPublic.nvPublic.attributes, 0); + +out: + rc = TSS_Delete(ctx); + if (rc) + return -1; + + return 0; +} diff --git a/libstb/tss2/tpm_nv.h b/libstb/tss2/tpm_nv.h new file mode 100644 index 0000000..3652bcb --- /dev/null +++ b/libstb/tss2/tpm_nv.h @@ -0,0 +1,7 @@ + +#ifndef TPM_NV_H +#define TPM_NV_H + +int tpm_nv_init(void); + +#endif diff --git a/libstb/tss2/tss.c b/libstb/tss2/tss.c new file mode 100644 index 0000000..768af44 --- /dev/null +++ b/libstb/tss2/tss.c @@ -0,0 +1,279 @@ +/********************************************************************************/ +/* */ +/* TSS Primary API */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* */ +/* (c) Copyright IBM Corporation 2015 - 2018. */ +/* */ +/* All rights reserved. */ +/* */ +/* Redistribution and use in source and binary forms, with or without */ +/* modification, are permitted provided that the following conditions are */ +/* met: */ +/* */ +/* Redistributions of source code must retain the above copyright notice, */ +/* this list of conditions and the following disclaimer. */ +/* */ +/* 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. */ +/* */ +/* Neither the names of the IBM Corporation nor the names of its */ +/* contributors may be used to endorse or promote products derived from */ +/* this software without specific prior written permission. */ +/* */ +/* 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. */ +/********************************************************************************/ + +#include <stdlib.h> +#include <string.h> +#include <stdarg.h> +#include <errno.h> + +#ifdef TPM_POSIX +#include <netinet/in.h> +#endif +#ifdef TPM_WINDOWS +#include <winsock2.h> +#endif + +#include <ibmtss/tss.h> +#include "tssproperties.h" +#include <ibmtss/tsstransmit.h> +#include <ibmtss/tssutils.h> +#include <ibmtss/tssresponsecode.h> +#include <ibmtss/tssmarshal.h> +#include <ibmtss/Unmarshal_fp.h> +#ifndef TPM_TSS_NOCRYPTO +#include <ibmtss/tsscrypto.h> +#include <ibmtss/tsscryptoh.h> +#endif +#include <ibmtss/tssprintcmd.h> +#ifdef TPM_TPM20 +#include "tss20.h" +#endif +#ifdef TPM_TPM12 +#include "tss12.h" +#endif + +/* local prototypes */ + +static TPM_RC TSS_Context_Init(TSS_CONTEXT *tssContext); + +extern int tssVerbose; +extern int tssVverbose; +extern int tssFirstCall; + +/* TSS_Create() creates and initializes the TSS Context. It does NOT open a connection to the + TPM.*/ + +TPM_RC TSS_Create(TSS_CONTEXT **tssContext) +{ + TPM_RC rc = 0; + + /* allocate the high level TSS structure */ + if (rc == 0) { + /* set to NULL for backward compatibility, caller may not have set tssContext to NULL before + the call */ + *tssContext = NULL; + rc = TSS_Malloc((unsigned char **)tssContext, sizeof(TSS_CONTEXT)); + } + /* initialize the high level TSS structure */ + if (rc == 0) { + rc = TSS_Context_Init(*tssContext); + /* the likely cause of a failure is a bad environment variable */ + if (rc != 0) { + if (tssVerbose) printf("TSS_Create: TSS_Context_Init() failed\n"); + free(*tssContext); + *tssContext = NULL; + } + } + /* allocate and initialize the lower layer TSS context */ + if (rc == 0) { + rc = TSS_AuthCreate(&((*tssContext)->tssAuthContext)); + } + return rc; +} + +/* TSS_Context_Init() on first call is used for any global library initialization. + + On every call, it initializes the TSS context. +*/ + +static TPM_RC TSS_Context_Init(TSS_CONTEXT *tssContext) +{ + TPM_RC rc = 0; +#ifndef TPM_TSS_NOCRYPTO +#ifndef TPM_TSS_NOFILE + size_t tssSessionEncKeySize; + size_t tssSessionDecKeySize; +#endif +#endif + /* at the first call to the TSS, initialize global variables */ + if (tssFirstCall) { /* tssFirstCall is a library global */ +#ifdef TSS_CRYPTO_INIT + /* crypto module initializations, crypto library specific */ + if (rc == 0) { + rc = TSS_Crypto_Init(); + } +#endif + /* TSS properties that are global, not per TSS context */ + if (rc == 0) { + rc = TSS_GlobalProperties_Init(); + } + tssFirstCall = FALSE; + } + /* TSS properties that are per context */ + if (rc == 0) { + rc = TSS_Properties_Init(tssContext); + } +#ifndef TPM_TSS_NOCRYPTO +#ifndef TPM_TSS_NOFILE + /* crypto library dependent code to allocate the session state encryption and decryption keys. + They are probably always the same size, but it's safer not to assume that. */ + if (rc == 0) { + rc = TSS_AES_GetEncKeySize(&tssSessionEncKeySize); + } + if (rc == 0) { + rc = TSS_AES_GetDecKeySize(&tssSessionDecKeySize); + } + if (rc == 0) { + rc = TSS_Malloc((uint8_t **)&tssContext->tssSessionEncKey, tssSessionEncKeySize); + } + if (rc == 0) { + rc = TSS_Malloc((uint8_t **)&tssContext->tssSessionDecKey, tssSessionDecKeySize); + } + /* build the session encryption and decryption keys */ + if (rc == 0) { + rc = TSS_AES_KeyGenerate(tssContext->tssSessionEncKey, + tssContext->tssSessionDecKey); + } +#endif +#endif + return rc; +} + +/* TSS_Delete() closes an open TPM connection, then free the TSS context memory. + */ + +TPM_RC TSS_Delete(TSS_CONTEXT *tssContext) +{ + TPM_RC rc = 0; + + if (tssContext != NULL) { + TSS_AuthDelete(tssContext->tssAuthContext); +#ifdef TPM_TSS_NOFILE + { + size_t i; + for (i = 0 ; i < (sizeof(tssContext->sessions) / sizeof(TSS_SESSIONS)) ; i++) { + tssContext->sessions[i].sessionHandle = TPM_RH_NULL; + /* erase any secrets */ + memset(tssContext->sessions[i].sessionData, + 0, tssContext->sessions[i].sessionDataLength); + free(tssContext->sessions[i].sessionData); + tssContext->sessions[i].sessionData = NULL; + tssContext->sessions[i].sessionDataLength = 0; + } + } +#endif +#ifndef TPM_TSS_NOCRYPTO +#ifndef TPM_TSS_NOFILE + free(tssContext->tssSessionEncKey); + free(tssContext->tssSessionDecKey); +#endif +#endif + rc = TSS_Close(tssContext); + free(tssContext); + } + return rc; +} + +/* TSS_Execute() performs the complete command / response process. + + It sends the command specified by commandCode and the parameters 'in', returning the response + parameters 'out'. + + ... varargs are + + TPMI_SH_AUTH_SESSION sessionHandle, + const char *password, + unsigned int sessionAttributes + + Terminates with TPM_RH_NULL, NULL, 0 + + Processes up to MAX_SESSION_NUM sessions. +*/ + +TPM_RC TSS_Execute(TSS_CONTEXT *tssContext, + RESPONSE_PARAMETERS *out, + COMMAND_PARAMETERS *in, + EXTRA_PARAMETERS *extra, + TPM_CC commandCode, + ...) +{ + TPM_RC rc = 0; + va_list ap; + int tpm20Command; + int tpm12Command; + if (rc == 0) { + tpm20Command = (((commandCode >= TPM_CC_FIRST) && (commandCode <=TPM_CC_LAST)) || /* base */ + ((commandCode >= 0x20000000) && (commandCode <= 0x2000ffff))); /* vendor */ + tpm12Command = ((commandCode <= 0x000000ff) || /* base */ + ((commandCode >= 0x40000000) && (commandCode <= 0x4000ffff))); /* TSC */ + if (!tpm20Command && !tpm12Command) { + if (tssVerbose) printf("TSS_Execute: commandCode %08x unsupported\n", + commandCode); + rc = TSS_RC_COMMAND_UNIMPLEMENTED; + + } + if (tpm20Command && tpm12Command) { + if (tssVerbose) printf("TSS_Execute: commandCode %08x is both TPM 1.2 and TPM 2.0\n", + commandCode); + rc = TSS_RC_FAIL; + } + } + if (rc == 0) { + va_start(ap, commandCode); + if (tpm20Command) { +#ifdef TPM_TPM20 + tssContext->tpm12Command = FALSE; + rc = TSS_Execute20(tssContext, + out, + in, + (EXTRA_PARAMETERS *)extra, + commandCode, + ap); +#else + if (tssVerbose) printf("TSS_Execute: commandCode is TPM 1.2, TSS is TPM 2.0 only\n"); + rc = TSS_RC_COMMAND_UNIMPLEMENTED; +#endif + } + if (tpm12Command) { +#ifdef TPM_TPM12 + tssContext->tpm12Command = TRUE; + rc = TSS_Execute12(tssContext, + out, + in, + (EXTRA12_PARAMETERS *)extra, + commandCode, + ap); +#else + if (tssVerbose) printf("TSS_Execute: commandCode is TPM 2.0, TSS is TPM 1.2 only\n"); + rc = TSS_RC_COMMAND_UNIMPLEMENTED; +#endif + } + va_end(ap); + } + return rc; +} diff --git a/libstb/tss2/tss20.c b/libstb/tss2/tss20.c new file mode 100644 index 0000000..02c0409 --- /dev/null +++ b/libstb/tss2/tss20.c @@ -0,0 +1,4866 @@ +/********************************************************************************/ +/* */ +/* TSS Primary API for TPM 2.0 */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* */ +/* (c) Copyright IBM Corporation 2018 - 2019 */ +/* */ +/* All rights reserved. */ +/* */ +/* Redistribution and use in source and binary forms, with or without */ +/* modification, are permitted provided that the following conditions are */ +/* met: */ +/* */ +/* Redistributions of source code must retain the above copyright notice, */ +/* this list of conditions and the following disclaimer. */ +/* */ +/* 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. */ +/* */ +/* Neither the names of the IBM Corporation nor the names of its */ +/* contributors may be used to endorse or promote products derived from */ +/* this software without specific prior written permission. */ +/* */ +/* 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. */ +/********************************************************************************/ + +#include <stdlib.h> +#include <string.h> +#include <stdarg.h> +#include <errno.h> + +#ifdef TPM_POSIX +#include <netinet/in.h> +#endif +#ifdef TPM_WINDOWS +#include <winsock2.h> +#endif + +#include "tssauth.h" +#include "tssauth20.h" +#include <ibmtss/tss.h> +#include "tssproperties.h" +#include <ibmtss/tsstransmit.h> +#include <ibmtss/tssutils.h> +#include <ibmtss/tssresponsecode.h> +#include <ibmtss/tssmarshal.h> +#include <ibmtss/Unmarshal_fp.h> +#include "tssccattributes.h" +#ifndef TPM_TSS_NOCRYPTO +#include <ibmtss/tsscrypto.h> +#include <ibmtss/tsscryptoh.h> +#endif +#include <ibmtss/tssprintcmd.h> +#include "tss20.h" + +/* Files: + + h01xxxxxx.bin - NV index name + h02xxxxxx.bin - hmac session context + h03xxxxxx.bin - policy session context + h80xxxxxx.bin - transient object name + + cxxxx...xxxx.bin - context blob name +*/ + +/* NOTE Synchronize with + + TSS_HmacSession_InitContext + TSS_HmacSession_Unmarshal + TSS_HmacSession_Marshal +*/ + +struct TSS_HMAC_CONTEXT { + TPMI_SH_AUTH_SESSION sessionHandle; /* the session handle */ + TPMI_ALG_HASH authHashAlg; /* hash algorithm to use for the session */ +#ifndef TPM_TSS_NOCRYPTO + uint32_t sizeInBytes; /* hash algorithm mapped to size */ +#endif /* TPM_TSS_NOCRYPTO */ + TPMT_SYM_DEF symmetric; /* the algorithm and key size for parameter + encryption */ + TPMI_DH_ENTITY bind; /* bind handle */ + TPM2B_NAME bindName; /* Name corresponding to the the bind + handle */ + TPM2B_AUTH bindAuthValue; /* password corresponding to the bind + handle */ +#ifndef TPM_TSS_NOCRYPTO + TPM2B_NONCE nonceTPM; /* from TPM in response */ + TPM2B_NONCE nonceCaller; /* from caller in command */ + TPM2B_DIGEST sessionKey; /* from KDFa at session creation */ +#endif /* TPM_TSS_NOCRYPTO */ + TPM_SE sessionType; /* HMAC (0), policy (1), or trial policy */ + uint8_t isPasswordNeeded; /* flag set by policy password */ + uint8_t isAuthValueNeeded; /* flag set by policy authvalue */ + /* Items below this line are for the lifetime of one command. They are not saved and loaded. */ + TPM2B_KEY hmacKey; /* HMAC key calculated for each command */ +#ifndef TPM_TSS_NOCRYPTO + TPM2B_KEY sessionValue; /* KDFa secret for parameter encryption */ +#endif /* TPM_TSS_NOCRYPTO */ +} TSS_HMAC_CONTEXT; + +/* functions for command pre- and post- processing */ + +typedef TPM_RC (*TSS_PreProcessFunction_t)(TSS_CONTEXT *tssContext, + COMMAND_PARAMETERS *in, + EXTRA_PARAMETERS *extra); +typedef TPM_RC (*TSS_ChangeAuthFunction_t)(TSS_CONTEXT *tssContext, + struct TSS_HMAC_CONTEXT *session, + size_t handleNumber, + COMMAND_PARAMETERS *in); +typedef TPM_RC (*TSS_PostProcessFunction_t)(TSS_CONTEXT *tssContext, + COMMAND_PARAMETERS *in, + RESPONSE_PARAMETERS *out, + EXTRA_PARAMETERS *extra); + +static TPM_RC TSS_PR_StartAuthSession(TSS_CONTEXT *tssContext, + StartAuthSession_In *in, + StartAuthSession_Extra *extra); +static TPM_RC TSS_PR_NV_DefineSpace(TSS_CONTEXT *tssContext, + NV_DefineSpace_In *in, + void *extra); + +static TPM_RC TSS_CA_HierarchyChangeAuth(TSS_CONTEXT *tssContext, + struct TSS_HMAC_CONTEXT *session, + size_t handleNumber, + HierarchyChangeAuth_In *in); +static TPM_RC TSS_CA_NV_UndefineSpaceSpecial(TSS_CONTEXT *tssContext, + struct TSS_HMAC_CONTEXT *session, + size_t handleNumber, + NV_UndefineSpaceSpecial_In *in); +static TPM_RC TSS_CA_NV_ChangeAuth(TSS_CONTEXT *tssContext, + struct TSS_HMAC_CONTEXT *session, + size_t handleNumber, + NV_ChangeAuth_In *in); + + +static TPM_RC TSS_PO_StartAuthSession(TSS_CONTEXT *tssContext, + StartAuthSession_In *in, + StartAuthSession_Out *out, + StartAuthSession_Extra *extra); +static TPM_RC TSS_PO_ContextSave(TSS_CONTEXT *tssContext, + ContextSave_In *in, + ContextSave_Out *out, + void *extra); +static TPM_RC TSS_PO_ContextLoad(TSS_CONTEXT *tssContext, + ContextLoad_In *in, + ContextLoad_Out *out, + void *extra); +static TPM_RC TSS_PO_FlushContext(TSS_CONTEXT *tssContext, + FlushContext_In *in, + void *out, + void *extra); +static TPM_RC TSS_PO_EvictControl(TSS_CONTEXT *tssContext, + EvictControl_In *in, + void *out, + void *extra); +static TPM_RC TSS_PO_Load(TSS_CONTEXT *tssContext, + Load_In *in, + Load_Out *out, + void *extra); +static TPM_RC TSS_PO_LoadExternal(TSS_CONTEXT *tssContext, + LoadExternal_In *in, + LoadExternal_Out *out, + void *extra); +static TPM_RC TSS_PO_ReadPublic(TSS_CONTEXT *tssContext, + ReadPublic_In *in, + ReadPublic_Out *out, + void *extra); +static TPM_RC TSS_PO_CreateLoaded(TSS_CONTEXT *tssContext, + CreateLoaded_In *in, + CreateLoaded_Out *out, + void *extra); +static TPM_RC TSS_PO_HMAC_Start(TSS_CONTEXT *tssContext, + HMAC_Start_In *in, + HMAC_Start_Out *out, + void *extra); +static TPM_RC TSS_PO_HashSequenceStart(TSS_CONTEXT *tssContext, + HashSequenceStart_In *in, + HashSequenceStart_Out *out, + void *extra); +static TPM_RC TSS_PO_SequenceComplete(TSS_CONTEXT *tssContext, + SequenceComplete_In *in, + SequenceComplete_Out *out, + void *extra); +static TPM_RC TSS_PO_EventSequenceComplete(TSS_CONTEXT *tssContext, + EventSequenceComplete_In *in, + EventSequenceComplete_Out *out, + void *extra); +static TPM_RC TSS_PO_PolicyAuthValue(TSS_CONTEXT *tssContext, + PolicyAuthValue_In *in, + void *out, + void *extra); +static TPM_RC TSS_PO_PolicyPassword(TSS_CONTEXT *tssContext, + PolicyPassword_In *in, + void *out, + void *extra); +static TPM_RC TSS_PO_CreatePrimary(TSS_CONTEXT *tssContext, + CreatePrimary_In *in, + CreatePrimary_Out *out, + void *extra); +static TPM_RC TSS_PO_NV_DefineSpace(TSS_CONTEXT *tssContext, + NV_DefineSpace_In *in, + void *out, + void *extra); +static TPM_RC TSS_PO_NV_ReadPublic(TSS_CONTEXT *tssContext, + NV_ReadPublic_In *in, + NV_ReadPublic_Out *out, + void *extra); +static TPM_RC TSS_PO_NV_UndefineSpace(TSS_CONTEXT *tssContext, + NV_UndefineSpace_In *in, + void *out, + void *extra); +static TPM_RC TSS_PO_NV_UndefineSpaceSpecial(TSS_CONTEXT *tssContext, + NV_UndefineSpaceSpecial_In *in, + void *out, + void *extra); +static TPM_RC TSS_PO_NV_Write(TSS_CONTEXT *tssContext, + NV_Write_In *in, + void *out, + void *extra); +static TPM_RC TSS_PO_NV_WriteLock(TSS_CONTEXT *tssContext, + NV_WriteLock_In *in, + void *out, + void *extra); +static TPM_RC TSS_PO_NV_ReadLock(TSS_CONTEXT *tssContext, + NV_ReadLock_In *in, + void *out, + void *extra); + +typedef struct TSS_TABLE { + TPM_CC commandCode; + TSS_PreProcessFunction_t preProcessFunction; + TSS_ChangeAuthFunction_t changeAuthFunction; + TSS_PostProcessFunction_t postProcessFunction; +} TSS_TABLE; + +/* This table indexes from the command to pre- and post- processing functions. A missing entry is + not an error, and indicates a command with no functions. */ + +static const TSS_TABLE tssTable [] = { + + {TPM_CC_Startup, NULL, NULL, NULL}, + {TPM_CC_Shutdown, NULL, NULL, NULL}, + {TPM_CC_SelfTest, NULL, NULL, NULL}, + {TPM_CC_IncrementalSelfTest, NULL, NULL, NULL}, + {TPM_CC_GetTestResult, NULL, NULL, NULL}, + {TPM_CC_StartAuthSession, (TSS_PreProcessFunction_t)TSS_PR_StartAuthSession, NULL, (TSS_PostProcessFunction_t)TSS_PO_StartAuthSession}, + {TPM_CC_PolicyRestart, NULL, NULL, NULL}, + {TPM_CC_Create, NULL, NULL, NULL}, + {TPM_CC_Load, NULL, NULL, (TSS_PostProcessFunction_t)TSS_PO_Load}, + {TPM_CC_LoadExternal, NULL, NULL, (TSS_PostProcessFunction_t)TSS_PO_LoadExternal}, + {TPM_CC_ReadPublic, NULL, NULL, (TSS_PostProcessFunction_t)TSS_PO_ReadPublic}, + {TPM_CC_ActivateCredential, NULL, NULL, NULL}, + {TPM_CC_MakeCredential, NULL, NULL, NULL}, + {TPM_CC_Unseal, NULL, NULL, NULL}, + {TPM_CC_ObjectChangeAuth, NULL, NULL, NULL}, + {TPM_CC_CreateLoaded, NULL, NULL, (TSS_PostProcessFunction_t)TSS_PO_CreateLoaded}, + {TPM_CC_Duplicate, NULL, NULL, NULL}, + {TPM_CC_Rewrap, NULL, NULL, NULL}, + {TPM_CC_Import, NULL, NULL, NULL}, + {TPM_CC_RSA_Encrypt, NULL, NULL, NULL}, + {TPM_CC_RSA_Decrypt, NULL, NULL, NULL}, + {TPM_CC_ECDH_KeyGen, NULL, NULL, NULL}, + {TPM_CC_ECDH_ZGen, NULL, NULL, NULL}, + {TPM_CC_ECC_Parameters, NULL, NULL, NULL}, + {TPM_CC_ZGen_2Phase, NULL, NULL, NULL}, + {TPM_CC_EncryptDecrypt, NULL, NULL, NULL}, + {TPM_CC_EncryptDecrypt2, NULL, NULL, NULL}, + {TPM_CC_Hash, NULL, NULL, NULL}, + {TPM_CC_HMAC, NULL, NULL, NULL}, + {TPM_CC_GetRandom, NULL, NULL, NULL}, + {TPM_CC_StirRandom, NULL, NULL, NULL}, + {TPM_CC_HMAC_Start, NULL, NULL, (TSS_PostProcessFunction_t)TSS_PO_HMAC_Start}, + {TPM_CC_HashSequenceStart, NULL, NULL, (TSS_PostProcessFunction_t)TSS_PO_HashSequenceStart}, + {TPM_CC_SequenceUpdate, NULL, NULL, NULL}, + {TPM_CC_SequenceComplete, NULL,NULL, (TSS_PostProcessFunction_t)TSS_PO_SequenceComplete}, + {TPM_CC_EventSequenceComplete, NULL, NULL, (TSS_PostProcessFunction_t)TSS_PO_EventSequenceComplete}, + {TPM_CC_Certify, NULL, NULL, NULL}, + {TPM_CC_CertifyCreation, NULL, NULL, NULL}, + {TPM_CC_Quote, NULL, NULL, NULL}, + {TPM_CC_GetSessionAuditDigest, NULL, NULL, NULL}, + {TPM_CC_GetCommandAuditDigest, NULL, NULL, NULL}, + {TPM_CC_GetTime, NULL, NULL, NULL}, + {TPM_CC_Commit, NULL, NULL, NULL}, + {TPM_CC_EC_Ephemeral, NULL, NULL, NULL}, + {TPM_CC_VerifySignature, NULL, NULL, NULL}, + {TPM_CC_Sign, NULL, NULL, NULL}, + {TPM_CC_SetCommandCodeAuditStatus, NULL, NULL, NULL}, + {TPM_CC_PCR_Extend, NULL, NULL, NULL}, + {TPM_CC_PCR_Event, NULL, NULL, NULL}, + {TPM_CC_PCR_Read, NULL, NULL, NULL}, + {TPM_CC_PCR_Allocate, NULL, NULL, NULL}, + {TPM_CC_PCR_SetAuthPolicy, NULL, NULL, NULL}, + {TPM_CC_PCR_SetAuthValue, NULL, NULL, NULL}, + {TPM_CC_PCR_Reset, NULL, NULL, NULL}, + {TPM_CC_PolicySigned, NULL, NULL, NULL}, + {TPM_CC_PolicySecret, NULL, NULL, NULL}, + {TPM_CC_PolicyTicket, NULL, NULL, NULL}, + {TPM_CC_PolicyOR, NULL, NULL, NULL}, + {TPM_CC_PolicyPCR, NULL, NULL, NULL}, + {TPM_CC_PolicyLocality, NULL, NULL, NULL}, + {TPM_CC_PolicyNV, NULL, NULL, NULL}, + {TPM_CC_PolicyAuthorizeNV, NULL, NULL, NULL}, + {TPM_CC_PolicyCounterTimer, NULL, NULL, NULL}, + {TPM_CC_PolicyCommandCode, NULL, NULL, NULL}, + {TPM_CC_PolicyPhysicalPresence, NULL, NULL, NULL}, + {TPM_CC_PolicyCpHash, NULL, NULL, NULL}, + {TPM_CC_PolicyNameHash, NULL, NULL, NULL}, + {TPM_CC_PolicyDuplicationSelect, NULL, NULL, NULL}, + {TPM_CC_PolicyAuthorize, NULL, NULL, NULL}, + {TPM_CC_PolicyAuthValue, NULL, NULL, (TSS_PostProcessFunction_t)TSS_PO_PolicyAuthValue}, + {TPM_CC_PolicyPassword, NULL, NULL, (TSS_PostProcessFunction_t)TSS_PO_PolicyPassword}, + {TPM_CC_PolicyGetDigest, NULL, NULL, NULL}, + {TPM_CC_PolicyNvWritten, NULL, NULL, NULL}, + {TPM_CC_PolicyTemplate, NULL, NULL, NULL}, + {TPM_CC_CreatePrimary, NULL, NULL, (TSS_PostProcessFunction_t)TSS_PO_CreatePrimary}, + {TPM_CC_HierarchyControl, NULL, NULL, NULL}, + {TPM_CC_SetPrimaryPolicy, NULL, NULL, NULL}, + {TPM_CC_ChangePPS, NULL, NULL, NULL}, + {TPM_CC_ChangeEPS, NULL, NULL, NULL}, + {TPM_CC_Clear, NULL, NULL, NULL}, + {TPM_CC_ClearControl, NULL, NULL, NULL}, + {TPM_CC_HierarchyChangeAuth, NULL, (TSS_ChangeAuthFunction_t)TSS_CA_HierarchyChangeAuth, NULL}, + {TPM_CC_DictionaryAttackLockReset, NULL, NULL, NULL}, + {TPM_CC_DictionaryAttackParameters, NULL, NULL, NULL}, + {TPM_CC_PP_Commands, NULL, NULL, NULL}, + {TPM_CC_SetAlgorithmSet, NULL, NULL, NULL}, + {TPM_CC_ContextSave, NULL, NULL, (TSS_PostProcessFunction_t)TSS_PO_ContextSave}, + {TPM_CC_ContextLoad, NULL, NULL, (TSS_PostProcessFunction_t)TSS_PO_ContextLoad}, + {TPM_CC_FlushContext, NULL, NULL, (TSS_PostProcessFunction_t)TSS_PO_FlushContext}, + {TPM_CC_EvictControl, NULL, NULL, (TSS_PostProcessFunction_t)TSS_PO_EvictControl}, + {TPM_CC_ReadClock, NULL, NULL, NULL}, + {TPM_CC_ClockSet, NULL, NULL, NULL}, + {TPM_CC_ClockRateAdjust, NULL, NULL, NULL}, + {TPM_CC_GetCapability, NULL, NULL, NULL}, + {TPM_CC_TestParms, NULL, NULL, NULL}, + {TPM_CC_NV_DefineSpace, (TSS_PreProcessFunction_t)TSS_PR_NV_DefineSpace, NULL, (TSS_PostProcessFunction_t)TSS_PO_NV_DefineSpace}, + {TPM_CC_NV_UndefineSpace, NULL, NULL, (TSS_PostProcessFunction_t)TSS_PO_NV_UndefineSpace}, + {TPM_CC_NV_UndefineSpaceSpecial, NULL, (TSS_ChangeAuthFunction_t)TSS_CA_NV_UndefineSpaceSpecial, (TSS_PostProcessFunction_t)TSS_PO_NV_UndefineSpaceSpecial}, + {TPM_CC_NV_ReadPublic, NULL, NULL, (TSS_PostProcessFunction_t)TSS_PO_NV_ReadPublic}, + {TPM_CC_NV_Write, NULL, NULL, (TSS_PostProcessFunction_t)TSS_PO_NV_Write}, + {TPM_CC_NV_Increment, NULL, NULL, (TSS_PostProcessFunction_t)TSS_PO_NV_Write}, + {TPM_CC_NV_Extend, NULL, NULL, (TSS_PostProcessFunction_t)TSS_PO_NV_Write}, + {TPM_CC_NV_SetBits, NULL, NULL, (TSS_PostProcessFunction_t)TSS_PO_NV_Write}, + {TPM_CC_NV_WriteLock, NULL, NULL, (TSS_PostProcessFunction_t)TSS_PO_NV_WriteLock}, + {TPM_CC_NV_GlobalWriteLock, NULL, NULL, NULL}, + {TPM_CC_NV_Read, NULL, NULL, NULL}, + {TPM_CC_NV_ReadLock, NULL, NULL, (TSS_PostProcessFunction_t)TSS_PO_NV_ReadLock}, + {TPM_CC_NV_ChangeAuth, NULL, (TSS_ChangeAuthFunction_t)TSS_CA_NV_ChangeAuth, NULL}, + {TPM_CC_NV_Certify, NULL, NULL, NULL} +}; + +#ifndef TPM_TSS_NO_PRINT + +typedef void (*TSS_InPrintFunction_t)(COMMAND_PARAMETERS *in, unsigned int indent); + +typedef struct TSS_PRINT_TABLE { + TPM_CC commandCode; + TSS_InPrintFunction_t inPrintFunction; +} TSS_PRINT_TABLE; + +/* This table indexes from the command to print functions. A missing entry is + not an error, and indicates a command with no function. */ + +static const TSS_PRINT_TABLE tssPrintTable [] = { + + {TPM_CC_Startup, (TSS_InPrintFunction_t)Startup_In_Print}, + {TPM_CC_Shutdown, (TSS_InPrintFunction_t)Shutdown_In_Print}, + {TPM_CC_SelfTest, (TSS_InPrintFunction_t)SelfTest_In_Print}, + {TPM_CC_IncrementalSelfTest, (TSS_InPrintFunction_t)IncrementalSelfTest_In_Print}, + {TPM_CC_GetTestResult, NULL}, + {TPM_CC_StartAuthSession, (TSS_InPrintFunction_t)StartAuthSession_In_Print}, + {TPM_CC_PolicyRestart, (TSS_InPrintFunction_t)PolicyRestart_In_Print}, + {TPM_CC_Create,(TSS_InPrintFunction_t)Create_In_Print}, + {TPM_CC_Load, (TSS_InPrintFunction_t)Load_In_Print}, + {TPM_CC_LoadExternal, (TSS_InPrintFunction_t)LoadExternal_In_Print}, + {TPM_CC_ReadPublic, (TSS_InPrintFunction_t)ReadPublic_In_Print}, + {TPM_CC_ActivateCredential, (TSS_InPrintFunction_t)ActivateCredential_In_Print}, + {TPM_CC_MakeCredential, (TSS_InPrintFunction_t)MakeCredential_In_Print}, + {TPM_CC_Unseal, (TSS_InPrintFunction_t)Unseal_In_Print}, + {TPM_CC_ObjectChangeAuth, (TSS_InPrintFunction_t)ObjectChangeAuth_In_Print}, + {TPM_CC_CreateLoaded, (TSS_InPrintFunction_t)CreateLoaded_In_Print}, + {TPM_CC_Duplicate, (TSS_InPrintFunction_t)Duplicate_In_Print}, + {TPM_CC_Rewrap, (TSS_InPrintFunction_t)Rewrap_In_Print}, + {TPM_CC_Import, (TSS_InPrintFunction_t)Import_In_Print}, + {TPM_CC_RSA_Encrypt, (TSS_InPrintFunction_t)RSA_Encrypt_In_Print}, + {TPM_CC_RSA_Decrypt, (TSS_InPrintFunction_t)RSA_Decrypt_In_Print}, + {TPM_CC_ECDH_KeyGen, (TSS_InPrintFunction_t)ECDH_KeyGen_In_Print}, + {TPM_CC_ECDH_ZGen, (TSS_InPrintFunction_t)ECDH_ZGen_In_Print}, + {TPM_CC_ECC_Parameters, (TSS_InPrintFunction_t)ECC_Parameters_In_Print}, + {TPM_CC_ZGen_2Phase, (TSS_InPrintFunction_t)ZGen_2Phase_In_Print}, + {TPM_CC_EncryptDecrypt, (TSS_InPrintFunction_t)EncryptDecrypt_In_Print}, + {TPM_CC_EncryptDecrypt2, (TSS_InPrintFunction_t)EncryptDecrypt2_In_Print}, + {TPM_CC_Hash, (TSS_InPrintFunction_t)Hash_In_Print}, + {TPM_CC_HMAC, (TSS_InPrintFunction_t)HMAC_In_Print}, + {TPM_CC_GetRandom, (TSS_InPrintFunction_t)GetRandom_In_Print}, + {TPM_CC_StirRandom, (TSS_InPrintFunction_t)StirRandom_In_Print}, + {TPM_CC_HMAC_Start, (TSS_InPrintFunction_t)HMAC_Start_In_Print}, + {TPM_CC_HashSequenceStart, (TSS_InPrintFunction_t)HashSequenceStart_In_Print}, + {TPM_CC_SequenceUpdate, (TSS_InPrintFunction_t)SequenceUpdate_In_Print}, + {TPM_CC_SequenceComplete, (TSS_InPrintFunction_t)SequenceComplete_In_Print}, + {TPM_CC_EventSequenceComplete, (TSS_InPrintFunction_t)EventSequenceComplete_In_Print}, + {TPM_CC_Certify, (TSS_InPrintFunction_t)Certify_In_Print}, + {TPM_CC_CertifyCreation, (TSS_InPrintFunction_t)CertifyCreation_In_Print}, + {TPM_CC_Quote, (TSS_InPrintFunction_t)Quote_In_Print}, + {TPM_CC_GetSessionAuditDigest, (TSS_InPrintFunction_t)GetSessionAuditDigest_In_Print}, + {TPM_CC_GetCommandAuditDigest, (TSS_InPrintFunction_t)GetCommandAuditDigest_In_Print}, + {TPM_CC_GetTime, (TSS_InPrintFunction_t)GetTime_In_Print}, + {TPM_CC_Commit, (TSS_InPrintFunction_t)Commit_In_Print}, + {TPM_CC_EC_Ephemeral, (TSS_InPrintFunction_t)EC_Ephemeral_In_Print}, + {TPM_CC_VerifySignature, (TSS_InPrintFunction_t)VerifySignature_In_Print}, + {TPM_CC_Sign, (TSS_InPrintFunction_t)Sign_In_Print}, + {TPM_CC_SetCommandCodeAuditStatus, (TSS_InPrintFunction_t)SetCommandCodeAuditStatus_In_Print}, + {TPM_CC_PCR_Extend, (TSS_InPrintFunction_t)PCR_Extend_In_Print}, + {TPM_CC_PCR_Event, (TSS_InPrintFunction_t)PCR_Event_In_Print}, + {TPM_CC_PCR_Read, (TSS_InPrintFunction_t)PCR_Read_In_Print}, + {TPM_CC_PCR_Allocate, (TSS_InPrintFunction_t)PCR_Allocate_In_Print}, + {TPM_CC_PCR_SetAuthPolicy, (TSS_InPrintFunction_t)PCR_SetAuthPolicy_In_Print}, + {TPM_CC_PCR_SetAuthValue, (TSS_InPrintFunction_t)PCR_SetAuthValue_In_Print}, + {TPM_CC_PCR_Reset, (TSS_InPrintFunction_t)PCR_Reset_In_Print}, + {TPM_CC_PolicySigned, (TSS_InPrintFunction_t)PolicySigned_In_Print}, + {TPM_CC_PolicySecret, (TSS_InPrintFunction_t)PolicySecret_In_Print}, + {TPM_CC_PolicyTicket, (TSS_InPrintFunction_t)PolicyTicket_In_Print}, + {TPM_CC_PolicyOR, (TSS_InPrintFunction_t)PolicyOR_In_Print}, + {TPM_CC_PolicyPCR, (TSS_InPrintFunction_t)PolicyPCR_In_Print}, + {TPM_CC_PolicyLocality, (TSS_InPrintFunction_t)PolicyLocality_In_Print}, + {TPM_CC_PolicyNV, (TSS_InPrintFunction_t)PolicyNV_In_Print}, + {TPM_CC_PolicyAuthorizeNV, (TSS_InPrintFunction_t)PolicyAuthorizeNV_In_Print}, + {TPM_CC_PolicyCounterTimer, (TSS_InPrintFunction_t)PolicyCounterTimer_In_Print}, + {TPM_CC_PolicyCommandCode, (TSS_InPrintFunction_t)PolicyCommandCode_In_Print}, + {TPM_CC_PolicyPhysicalPresence, (TSS_InPrintFunction_t)PolicyPhysicalPresence_In_Print}, + {TPM_CC_PolicyCpHash, (TSS_InPrintFunction_t)PolicyCpHash_In_Print}, + {TPM_CC_PolicyNameHash, (TSS_InPrintFunction_t)PolicyNameHash_In_Print}, + {TPM_CC_PolicyDuplicationSelect, (TSS_InPrintFunction_t)PolicyDuplicationSelect_In_Print}, + {TPM_CC_PolicyAuthorize, (TSS_InPrintFunction_t)PolicyAuthorize_In_Print}, + {TPM_CC_PolicyAuthValue, (TSS_InPrintFunction_t)PolicyAuthValue_In_Print}, + {TPM_CC_PolicyPassword, (TSS_InPrintFunction_t)PolicyPassword_In_Print}, + {TPM_CC_PolicyGetDigest, (TSS_InPrintFunction_t)PolicyGetDigest_In_Print}, + {TPM_CC_PolicyNvWritten, (TSS_InPrintFunction_t)PolicyNvWritten_In_Print}, + {TPM_CC_PolicyTemplate, (TSS_InPrintFunction_t)PolicyTemplate_In_Print}, + {TPM_CC_CreatePrimary, (TSS_InPrintFunction_t)CreatePrimary_In_Print}, + {TPM_CC_HierarchyControl, (TSS_InPrintFunction_t)HierarchyControl_In_Print}, + {TPM_CC_SetPrimaryPolicy, (TSS_InPrintFunction_t)SetPrimaryPolicy_In_Print}, + {TPM_CC_ChangePPS, (TSS_InPrintFunction_t)ChangePPS_In_Print}, + {TPM_CC_ChangeEPS, (TSS_InPrintFunction_t)ChangeEPS_In_Print}, + {TPM_CC_Clear, (TSS_InPrintFunction_t)Clear_In_Print}, + {TPM_CC_ClearControl, (TSS_InPrintFunction_t)ClearControl_In_Print}, + {TPM_CC_HierarchyChangeAuth, (TSS_InPrintFunction_t)HierarchyChangeAuth_In_Print}, + {TPM_CC_DictionaryAttackLockReset, (TSS_InPrintFunction_t)DictionaryAttackLockReset_In_Print}, + {TPM_CC_DictionaryAttackParameters, (TSS_InPrintFunction_t)DictionaryAttackParameters_In_Print}, + {TPM_CC_PP_Commands, (TSS_InPrintFunction_t)PP_Commands_In_Print}, + {TPM_CC_SetAlgorithmSet, (TSS_InPrintFunction_t)SetAlgorithmSet_In_Print}, + {TPM_CC_ContextSave, (TSS_InPrintFunction_t)ContextSave_In_Print}, + {TPM_CC_ContextLoad, (TSS_InPrintFunction_t)ContextLoad_In_Print}, + {TPM_CC_FlushContext, (TSS_InPrintFunction_t)FlushContext_In_Print}, + {TPM_CC_EvictControl, (TSS_InPrintFunction_t)EvictControl_In_Print}, + {TPM_CC_ReadClock, (TSS_InPrintFunction_t)NULL}, + {TPM_CC_ClockSet, (TSS_InPrintFunction_t)ClockSet_In_Print}, + {TPM_CC_ClockRateAdjust, (TSS_InPrintFunction_t)ClockRateAdjust_In_Print}, + {TPM_CC_GetCapability, (TSS_InPrintFunction_t)GetCapability_In_Print}, + {TPM_CC_TestParms, (TSS_InPrintFunction_t)TestParms_In_Print}, + {TPM_CC_NV_DefineSpace, (TSS_InPrintFunction_t)NV_DefineSpace_In_Print}, + {TPM_CC_NV_UndefineSpace, (TSS_InPrintFunction_t)NV_UndefineSpace_In_Print}, + {TPM_CC_NV_UndefineSpaceSpecial, (TSS_InPrintFunction_t)NV_UndefineSpaceSpecial_In_Print}, + {TPM_CC_NV_ReadPublic, (TSS_InPrintFunction_t)NV_ReadPublic_In_Print}, + {TPM_CC_NV_Write, (TSS_InPrintFunction_t)NV_Write_In_Print}, + {TPM_CC_NV_Increment, (TSS_InPrintFunction_t)NV_Increment_In_Print}, + {TPM_CC_NV_Extend, (TSS_InPrintFunction_t)NV_Extend_In_Print}, + {TPM_CC_NV_SetBits, (TSS_InPrintFunction_t)NV_SetBits_In_Print}, + {TPM_CC_NV_WriteLock, (TSS_InPrintFunction_t)NV_WriteLock_In_Print}, + {TPM_CC_NV_GlobalWriteLock, (TSS_InPrintFunction_t)NV_GlobalWriteLock_In_Print}, + {TPM_CC_NV_Read, (TSS_InPrintFunction_t)NV_Read_In_Print}, + {TPM_CC_NV_ReadLock, (TSS_InPrintFunction_t)NV_ReadLock_In_Print}, + {TPM_CC_NV_ChangeAuth, (TSS_InPrintFunction_t)NV_ChangeAuth_In_Print}, + {TPM_CC_NV_Certify, (TSS_InPrintFunction_t)NV_Certify_In_Print} +}; + +#endif /* TPM_TSS_NO_PRINT */ + +/* local prototypes */ + +static TPM_RC TSS_Execute_valist(TSS_CONTEXT *tssContext, + COMMAND_PARAMETERS *in, + va_list ap); + + +static TPM_RC TSS_PwapSession_Set(TPMS_AUTH_COMMAND *authCommand, + const char *password); +static TPM_RC TSS_PwapSession_Verify(TPMS_AUTH_RESPONSE *authResponse); + +static TPM_RC TSS_HmacSession_GetContext(struct TSS_HMAC_CONTEXT **session); +static void TSS_HmacSession_InitContext(struct TSS_HMAC_CONTEXT *session); +static void TSS_HmacSession_FreeContext(struct TSS_HMAC_CONTEXT *session); + +#ifndef TPM_TSS_NOCRYPTO +static TPM_RC TSS_HmacSession_SetSessionKey(TSS_CONTEXT *tssContext, + struct TSS_HMAC_CONTEXT *session, + TPM2B_DIGEST *salt, + TPMI_DH_ENTITY bind, + TPM2B_AUTH *bindAuthValue); +static TPM_RC TSS_HmacSession_SetNonceCaller(struct TSS_HMAC_CONTEXT *session, + TPMS_AUTH_COMMAND *authC); +static TPM_RC TSS_HmacSession_SetHmacKey(TSS_CONTEXT *tssContext, + struct TSS_HMAC_CONTEXT *session, + size_t handleNumber, + const char *password); +#endif /* TPM_TSS_NOCRYPTO */ +static TPM_RC TSS_HmacSession_SetHMAC(TSS_AUTH_CONTEXT *tssAuthContext, + struct TSS_HMAC_CONTEXT *session[], + TPMS_AUTH_COMMAND *authCommand[], + TPMI_SH_AUTH_SESSION sessionHandle[], + unsigned int sessionAttributes[], + const char *password[], + TPM2B_NAME *name0, + TPM2B_NAME *name1, + TPM2B_NAME *name2); +#ifndef TPM_TSS_NOCRYPTO +static TPM_RC TSS_HmacSession_Verify(TSS_AUTH_CONTEXT *tssAuthContext, + struct TSS_HMAC_CONTEXT *session, + TPMS_AUTH_RESPONSE *authResponse); +#endif /* TPM_TSS_NOCRYPTO */ +static TPM_RC TSS_HmacSession_Continue(TSS_CONTEXT *tssContext, + struct TSS_HMAC_CONTEXT *session, + TPMS_AUTH_RESPONSE *authR); + + +static TPM_RC TSS_HmacSession_SaveSession(TSS_CONTEXT *tssContext, + struct TSS_HMAC_CONTEXT *session); +static TPM_RC TSS_HmacSession_LoadSession(TSS_CONTEXT *tssContext, + struct TSS_HMAC_CONTEXT *session, + TPMI_SH_AUTH_SESSION sessionHandle); +#ifdef TPM_TSS_NOFILE +static TPM_RC TSS_HmacSession_SaveData(TSS_CONTEXT *tssContext, + TPMI_SH_AUTH_SESSION sessionHandle, + uint32_t outLength, + uint8_t *outBuffer); +static TPM_RC TSS_HmacSession_LoadData(TSS_CONTEXT *tssContext, + uint32_t *inLength, uint8_t **inData, + TPMI_SH_AUTH_SESSION sessionHandle); +static TPM_RC TSS_HmacSession_DeleteData(TSS_CONTEXT *tssContext, + TPMI_SH_AUTH_SESSION sessionHandle); +static TPM_RC TSS_HmacSession_GetSlotForHandle(TSS_CONTEXT *tssContext, + size_t *slotIndex, + TPMI_SH_AUTH_SESSION sessionHandle); +#endif +static TPM_RC TSS_HmacSession_Marshal(struct TSS_HMAC_CONTEXT *source, + uint16_t *written, uint8_t **buffer, uint32_t *size); +static TPM_RC TSS_HmacSession_Unmarshal(struct TSS_HMAC_CONTEXT *target, + uint8_t **buffer, uint32_t *size); + +static TPM_RC TSS_Name_GetAllNames(TSS_CONTEXT *tssContext, + TPM2B_NAME **names); +static TPM_RC TSS_Name_GetName(TSS_CONTEXT *tssContext, + TPM2B_NAME *name, + TPM_HANDLE handle); +static TPM_RC TSS_Name_Store(TSS_CONTEXT *tssContext, + TPM2B_NAME *name, + TPM_HANDLE handle, + const char *string); +static TPM_RC TSS_Name_Load(TSS_CONTEXT *tssContext, + TPM2B_NAME *name, + TPM_HANDLE handle, + const char *string); +static TPM_RC TSS_Name_Copy(TSS_CONTEXT *tssContext, + TPM_HANDLE outHandle, + const char *outString, + TPM_HANDLE inHandle, + const char *inString); +static TPM_RC TSS_Public_Store(TSS_CONTEXT *tssContext, + TPM2B_PUBLIC *public, + TPM_HANDLE handle, + const char *string); +static TPM_RC TSS_Public_Load(TSS_CONTEXT *tssContext, + TPM2B_PUBLIC *public, + TPM_HANDLE handle, + const char *string); +static TPM_RC TSS_Public_Copy(TSS_CONTEXT *tssContext, + TPM_HANDLE outHandle, + const char *outString, + TPM_HANDLE inHandle, + const char *inString); +#ifdef TPM_TSS_NOFILE +static TPM_RC TSS_ObjectPublic_GetSlotForHandle(TSS_CONTEXT *tssContext, + size_t *slotIndex, + TPM_HANDLE handle); +static TPM_RC TSS_ObjectPublic_DeleteData(TSS_CONTEXT *tssContext, TPM_HANDLE handle); +#endif +static TPM_RC TSS_DeleteHandle(TSS_CONTEXT *tssContext, + TPM_HANDLE handle); +static TPM_RC TSS_ObjectPublic_GetName(TPM2B_NAME *name, + TPMT_PUBLIC *tpmtPublic); + +#ifndef TPM_TSS_NOCRYPTO +static TPM_RC TSS_NVPublic_Store(TSS_CONTEXT *tssContext, + TPMS_NV_PUBLIC *nvPublic, + TPMI_RH_NV_INDEX handle); +static TPM_RC TSS_NVPublic_Load(TSS_CONTEXT *tssContext, + TPMS_NV_PUBLIC *nvPublic, + TPMI_RH_NV_INDEX handle); +#endif +static TPM_RC TSS_NVPublic_Delete(TSS_CONTEXT *tssContext, + TPMI_RH_NV_INDEX nvIndex); +#ifdef TPM_TSS_NOFILE +static TPM_RC TSS_NvPublic_GetSlotForHandle(TSS_CONTEXT *tssContext, + size_t *slotIndex, + TPMI_RH_NV_INDEX nvIndex); +#endif + +static TPM_RC TSS_Command_Decrypt(TSS_AUTH_CONTEXT *tssAuthContext, + struct TSS_HMAC_CONTEXT *session[], + TPMI_SH_AUTH_SESSION sessionHandle[], + unsigned int sessionAttributes[]); +#ifndef TPM_TSS_NOCRYPTO +static TPM_RC TSS_Command_DecryptXor(TSS_AUTH_CONTEXT *tssAuthContext, + struct TSS_HMAC_CONTEXT *session); +static TPM_RC TSS_Command_DecryptAes(TSS_AUTH_CONTEXT *tssAuthContext, + struct TSS_HMAC_CONTEXT *session); + +#endif /* TPM_TSS_NOCRYPTO */ +static TPM_RC TSS_Response_Encrypt(TSS_AUTH_CONTEXT *tssAuthContext, + struct TSS_HMAC_CONTEXT *session[], + TPMI_SH_AUTH_SESSION sessionHandle[], + unsigned int sessionAttributes[]); +#ifndef TPM_TSS_NOCRYPTO +static TPM_RC TSS_Response_EncryptXor(TSS_AUTH_CONTEXT *tssAuthContext, + struct TSS_HMAC_CONTEXT *session); +static TPM_RC TSS_Response_EncryptAes(TSS_AUTH_CONTEXT *tssAuthContext, + struct TSS_HMAC_CONTEXT *session); + +static TPM_RC TSS_Command_ChangeAuthProcessor(TSS_CONTEXT *tssContext, + struct TSS_HMAC_CONTEXT *session, + size_t handleNumber, + COMMAND_PARAMETERS *in); +#endif /* TPM_TSS_NOCRYPTO */ + +static TPM_RC TSS_Command_PreProcessor(TSS_CONTEXT *tssContext, + TPM_CC commandCode, + COMMAND_PARAMETERS *in, + EXTRA_PARAMETERS *extra); +static TPM_RC TSS_Response_PostProcessor(TSS_CONTEXT *tssContext, + COMMAND_PARAMETERS *in, + RESPONSE_PARAMETERS *out, + EXTRA_PARAMETERS *extra); + +static TPM_RC TSS_Sessions_GetDecryptSession(unsigned int *isDecrypt, + unsigned int *decryptSession, + TPMI_SH_AUTH_SESSION sessionHandle[], + unsigned int sessionAttributes[]); +static TPM_RC TSS_Sessions_GetEncryptSession(unsigned int *isEncrypt, + unsigned int *encryptSession, + TPMI_SH_AUTH_SESSION sessionHandle[], + unsigned int sessionAttributes[]); + +#ifndef TPM_TSS_NOFILE +static TPM_RC TSS_HashToString(char *str, uint8_t *digest); +#endif +#ifndef TPM_TSS_NOCRYPTO +#ifndef TPM_TSS_NORSA +static TPM_RC TSS_RSA_Salt(TPM2B_DIGEST *salt, + TPM2B_ENCRYPTED_SECRET *encryptedSalt, + TPMT_PUBLIC *publicArea); +#endif /* TPM_TSS_NORSA */ +#endif /* TPM_TSS_NOCRYPTO */ +extern int tssVerbose; +extern int tssVverbose; +extern int tssFirstCall; + + +TPM_RC TSS_Execute20(TSS_CONTEXT *tssContext, + RESPONSE_PARAMETERS *out, + COMMAND_PARAMETERS *in, + EXTRA_PARAMETERS *extra, + TPM_CC commandCode, + va_list ap) +{ + TPM_RC rc = 0; + /* create a TSS authorization context */ + if (rc == 0) { + TSS_InitAuthContext(tssContext->tssAuthContext); + } + /* handle any command specific command pre-processing */ + if (rc == 0) { + rc = TSS_Command_PreProcessor(tssContext, + commandCode, + in, + extra); + } + /* marshal input parameters */ + if (rc == 0) { + if (tssVverbose) printf("TSS_Execute20: Command %08x marshal\n", commandCode); + rc = TSS_Marshal(tssContext->tssAuthContext, + in, + commandCode); + } + /* execute the command */ + if (rc == 0) { + rc = TSS_Execute_valist(tssContext, in, ap); + } + /* unmarshal the response parameters */ + if (rc == 0) { + if (tssVverbose) printf("TSS_Execute20: Command %08x unmarshal\n", commandCode); + rc = TSS_Unmarshal(tssContext->tssAuthContext, out); + } + /* handle any command specific response post-processing */ + if (rc == 0) { + if (tssVverbose) printf("TSS_Execute20: Command %08x post processor\n", commandCode); + rc = TSS_Response_PostProcessor(tssContext, + in, + out, + extra); + } + return rc; +} + +/* TSS_Execute_valist() transmits the marshaled command and receives the marshaled response. + + varargs are TPMI_SH_AUTH_SESSION sessionHandle, const char *password, unsigned int + sessionAttributes + + Terminates with sessionHandle TPM_RH_NULL + + Processes up to MAX_SESSION_NUM sessions. It handles HMAC generation and command and response + parameter encryption. It loads each session context, rolls nonces, and saves or deletes the + session context. +*/ + +static TPM_RC TSS_Execute_valist(TSS_CONTEXT *tssContext, + COMMAND_PARAMETERS *in, + va_list ap) +{ + TPM_RC rc = 0; + int done; + int haveNames = FALSE; /* names are common to all HMAC sessions */ + size_t i = 0; + + /* the vararg parameters */ + TPMI_SH_AUTH_SESSION sessionHandle[MAX_SESSION_NUM]; + const char *password[MAX_SESSION_NUM]; + unsigned int sessionAttributes[MAX_SESSION_NUM]; + + /* structures filled in */ + TPMS_AUTH_COMMAND *authCommand[MAX_SESSION_NUM]; + TPMS_AUTH_RESPONSE *authResponse[MAX_SESSION_NUM]; + + /* pointer to the above structures as used */ + TPMS_AUTH_COMMAND *authC[MAX_SESSION_NUM]; + TPMS_AUTH_RESPONSE *authR[MAX_SESSION_NUM]; + + /* TSS sessions */ + struct TSS_HMAC_CONTEXT *session[MAX_SESSION_NUM]; + TPM2B_NAME *names[MAX_SESSION_NUM]; + /* Step 1: initialization */ + if (tssVverbose) printf("TSS_Execute_valist: Step 1: initialization\n"); + for (i = 0 ; (rc == 0) && (i < MAX_SESSION_NUM) ; i++) { + authCommand[i] = NULL; /* for safe free */ + authResponse[i] = NULL; /* for safe free */ + authC[i] = NULL; /* array of TPMS_AUTH_COMMAND structures, NULL for + TSS_SetCmdAuths */ + authR[i] = NULL; /* array of TPMS_AUTH_RESPONSE structures, NULL for + TSS_GetRspAuths */ + session[i] = NULL; /* for free, used for HMAC and encrypt/decrypt sessions */ + names[i] = NULL; /* for safe free */ + /* the varargs list inputs */ + sessionHandle[i] = TPM_RH_NULL; + password[i] = NULL; + sessionAttributes[i] = 0; + if (rc == 0) { + rc = TSS_Malloc((unsigned char **)&authCommand[i], /* freed @1 */ + sizeof(TPMS_AUTH_COMMAND)); + } + if (rc == 0) { + rc = TSS_Malloc((unsigned char **)&authResponse[i], /* freed @2 */ + sizeof(TPMS_AUTH_RESPONSE)); + } + if (rc == 0) { + rc = TSS_Malloc((unsigned char **)&names[i], /* freed @3 */ + sizeof(TPM2B_NAME)); + } + if (rc == 0) { + names[i]->b.size = 0; /* to ignore unused names in cpHash calculation */ + } + } + /* Step 2: gather the command authorizations + + Process PWAP immediately + For HMAC, get the session context + */ + done = FALSE; + for (i = 0 ; (rc == 0) && !done && (i < MAX_SESSION_NUM) ; i++) { + sessionHandle[i] = va_arg(ap, TPMI_SH_AUTH_SESSION); /* first vararg is the session + handle */ + password[i]= va_arg(ap, const char *); /* second vararg is the password */ + sessionAttributes[i] = va_arg(ap, unsigned int); /* third argument is + sessionAttributes */ + sessionAttributes[i] &= 0xff; /* is uint8_t */ + + if (sessionHandle[i] != TPM_RH_NULL) { /* varargs termination value */ + + if (tssVverbose) printf("TSS_Execute_valist: Step 2: authorization %u\n", + (unsigned int)i); + if (tssVverbose) printf("TSS_Execute_valist: session %u handle %08x\n", + (unsigned int)i, sessionHandle[i]); + /* make used, non-NULL for command and response varargs */ + authC[i] = authCommand[i]; + authR[i] = authResponse[i]; + + /* if password session, populate authC with password, etc. immediately */ + if (sessionHandle[i] == TPM_RS_PW) { + rc = TSS_PwapSession_Set(authC[i], password[i]); + } + /* if HMAC or encrypt/decrypt session */ + else { + /* if there is at least one HMAC session, get the names corresponding to the + handles */ + if ((rc == 0) && !haveNames) { + rc = TSS_Name_GetAllNames(tssContext, names); + haveNames = TRUE; /* get only once, minor optimization */ + } + /* initialize a TSS HMAC session */ + if (rc == 0) { + rc = TSS_HmacSession_GetContext(&session[i]); + } + /* load the session created by startauthsession */ + if (rc == 0) { + rc = TSS_HmacSession_LoadSession(tssContext, session[i], sessionHandle[i]); + } + } + } + else { + done = TRUE; + } + } + /* Step 3: Roll nonceCaller, save in the session context for the response */ + for (i = 0 ; (rc == 0) && (i < MAX_SESSION_NUM) && (sessionHandle[i] != TPM_RH_NULL) ; i++) { + if (sessionHandle[i] != TPM_RS_PW) { /* no nonce for password sessions */ + if (tssVverbose) + printf("TSS_Execute_valist: Step 3: nonceCaller %08x\n", sessionHandle[i]); +#ifndef TPM_TSS_NOCRYPTO + rc = TSS_HmacSession_SetNonceCaller(session[i], authC[i]); +#else + authC[i]->nonce.b.size = 16; + memset(&authC[i]->nonce.b.buffer, 0, 16); +#endif /* TPM_TSS_NOCRYPTO */ + } + } + +#ifndef TPM_TSS_NOCRYPTO + /* Step 4: Calculate the HMAC key */ + for (i = 0 ; (rc == 0) && (i < MAX_SESSION_NUM) && (sessionHandle[i] != TPM_RH_NULL) ; i++) { + if (sessionHandle[i] != TPM_RS_PW) { /* no HMAC key for password sessions */ + if (tssVverbose) printf("TSS_Execute_valist: Step 4: Session %u HMAC key for %08x\n", + (unsigned int)i, sessionHandle[i]); + rc = TSS_HmacSession_SetHmacKey(tssContext, session[i], i, password[i]); + } + } +#endif /* TPM_TSS_NOCRYPTO */ + /* Step 5: command parameter encryption */ + if (rc == 0) { + if (tssVverbose) printf("TSS_Execute_valist: Step 5: command encrypt\n"); + rc = TSS_Command_Decrypt(tssContext->tssAuthContext, + session, + sessionHandle, + sessionAttributes); + } + /* Step 6: for each HMAC session, calculate cpHash, calculate the HMAC, and set it in + TPMS_AUTH_COMMAND */ + if (rc == 0) { + if (tssVverbose) printf("TSS_Execute_valist: Step 6 calculate HMACs\n"); + rc = TSS_HmacSession_SetHMAC(tssContext->tssAuthContext, /* TSS auth context */ + session, /* TSS session contexts */ + authC, /* output: command authorizations */ + sessionHandle, /* list of session handles for the command */ + sessionAttributes, /* attributes for this command */ + password, /* for plaintext password sessions */ + names[0], /* Name */ + names[1], /* Name */ + names[2]); /* Name */ + } + /* Step 7: set the command authorizations in the TSS command stream */ + if (rc == 0) { + if (tssVverbose) printf("TSS_Execute_valist: Step 7 set command authorizations\n"); + rc = TSS_SetCmdAuths(tssContext->tssAuthContext, + authC[0], + authC[1], + authC[2], + NULL); + } + /* Step 8: process the command. Normally returns the TPM response code. */ + if (rc == 0) { + if (tssVverbose) printf("TSS_Execute_valist: Step 8: process the command\n"); + rc = TSS_AuthExecute(tssContext); + } + /* Step 9: get the response authorizations from the TSS response stream */ + if (rc == 0) { + if (tssVverbose) printf("TSS_Execute_valist: Step 9 get response authorizations\n"); + rc = TSS_GetRspAuths(tssContext->tssAuthContext, + authR[0], + authR[1], + authR[2], + NULL); + } + /* Step 10: process the response authorizations, validate the HMAC */ + for (i = 0 ; (rc == 0) && (i < MAX_SESSION_NUM) && (sessionHandle[i] != TPM_RH_NULL) ; i++) { + if (tssVverbose) + printf("TSS_Execute_valist: Step 10: process response authorization %08x\n", + sessionHandle[i]); + if (sessionHandle[i] == TPM_RS_PW) { + rc = TSS_PwapSession_Verify(authR[i]); + } + /* HMAC session */ + else { +#ifndef TPM_TSS_NOCRYPTO + /* save nonceTPM in the session context */ + if (rc == 0) { + rc = TSS_TPM2B_Copy(&session[i]->nonceTPM.b, &authR[i]->nonce.b, sizeof(TPMU_HA)); + } +#endif /* TPM_TSS_NOCRYPTO */ + /* the HMAC key is already part of the TSS session context. For policy sessions with + policy password, the response hmac is empty. */ + if ((session[i]->sessionType == TPM_SE_HMAC) || + ((session[i]->sessionType == TPM_SE_POLICY) && (session[i]->isAuthValueNeeded))) { +#ifndef TPM_TSS_NOCRYPTO + if (rc == 0) { + rc = TSS_Command_ChangeAuthProcessor(tssContext, session[i], i, in); + } + if (rc == 0) { + rc = TSS_HmacSession_Verify(tssContext->tssAuthContext, /* authorization + context */ + session[i], /* TSS session context */ + authR[i]); /* input: response authorization */ + } +#else + in = in; + if (tssVerbose) + printf("TSS_Execute_valist: " + "Error, HMAC verify with no crypto not implemented\n"); + rc = TSS_RC_NOT_IMPLEMENTED; +#endif /* TPM_TSS_NOCRYPTO */ + } + } + } + /* Step 11: process the audit flag */ + for (i = 0 ; (rc == 0) && (i < MAX_SESSION_NUM) && (sessionHandle[i] != TPM_RH_NULL) ; i++) { + if ((sessionHandle[i] != TPM_RS_PW) && + (session[i]->bind != TPM_RH_NULL) && + (authR[i]->sessionAttributes.val & TPMA_SESSION_AUDIT)) { + if (tssVverbose) printf("TSS_Execute_valist: Step 11: process bind audit flag %08x\n", + sessionHandle[i]); + /* if bind audit session, bind value is lost and further use requires authValue */ + session[i]->bind = TPM_RH_NULL; + } + } + /* Step 12: process the response continue flag */ + for (i = 0 ; (rc == 0) && (i < MAX_SESSION_NUM) && (sessionHandle[i] != TPM_RH_NULL) ; i++) { + if (sessionHandle[i] != TPM_RS_PW) { + if (tssVverbose) printf("TSS_Execute_valist: Step 12: process continue flag %08x\n", + sessionHandle[i]); + rc = TSS_HmacSession_Continue(tssContext, session[i], authR[i]); + } + } + /* Step 13: response parameter decryption */ + if (rc == 0) { + if (tssVverbose) printf("TSS_Execute_valist: Step 13: response decryption\n"); + rc = TSS_Response_Encrypt(tssContext->tssAuthContext, + session, + sessionHandle, + sessionAttributes); + } + /* cleanup */ + for (i = 0 ; i < MAX_SESSION_NUM ; i++) { + TSS_HmacSession_FreeContext(session[i]); + free(authCommand[i]); /* @1 */ + free(authResponse[i]); /* @2 */ + free(names[i]); /* @3 */ + } + return rc; +} + +/* + PWAP - Password Session +*/ + +/* TSS_PwapSession_Set() sets all members of the TPMS_AUTH_COMMAND structure for a PWAP session. + */ + +static TPM_RC TSS_PwapSession_Set(TPMS_AUTH_COMMAND *authCommand, + const char *password) +{ + TPM_RC rc = 0; + + if (rc == 0) { + authCommand->sessionHandle = TPM_RS_PW; + authCommand->nonce.t.size = 0; + authCommand->sessionAttributes.val = 0; + } + if (password != NULL) { + rc = TSS_TPM2B_StringCopy(&authCommand->hmac.b, + password, sizeof(authCommand->hmac.t.buffer)); + } + else { + authCommand->hmac.t.size = 0; + } + return rc; +} + +/* TSS_PwapSession_Verify() verifies the PWAP session response. */ + +static TPM_RC TSS_PwapSession_Verify(TPMS_AUTH_RESPONSE *authResponse) +{ + TPM_RC rc = 0; + + if (rc == 0) { + if (authResponse->nonce.t.size != 0) { + if (tssVerbose) printf("TSS_PwapSession_Verify: nonce size %u not zero\n", + authResponse->nonce.t.size); + rc = TSS_RC_BAD_PWAP_NONCE; + } + } + if (rc == 0) { + if (authResponse->sessionAttributes.val != TPMA_SESSION_CONTINUESESSION) { + if (tssVerbose) printf("TSS_PwapSession_Verify: continue %02x not set\n", + authResponse->sessionAttributes.val); + rc = TSS_RC_BAD_PWAP_ATTRIBUTES; + } + } + if (rc == 0) { + if (authResponse->hmac.t.size != 0) { + if (tssVerbose) printf("TSS_PwapSession_Verify: HMAC size %u not zero\n", + authResponse->hmac.t.size); + rc = TSS_RC_BAD_PWAP_HMAC; + } + } + return rc; +} + +/* + HMAC Session +*/ + +static TPM_RC TSS_HmacSession_GetContext(struct TSS_HMAC_CONTEXT **session) +{ + TPM_RC rc = 0; + + if (rc == 0) { + rc = TSS_Malloc((uint8_t **)session, sizeof(TSS_HMAC_CONTEXT)); + } + if (rc == 0) { + TSS_HmacSession_InitContext(*session); + } + return rc; +} + +static void TSS_HmacSession_InitContext(struct TSS_HMAC_CONTEXT *session) +{ + session->sessionHandle = TPM_RH_NULL; + session->authHashAlg = TPM_ALG_NULL; +#ifndef TPM_TSS_NOCRYPTO + session->sizeInBytes = 0; +#endif + session->symmetric.algorithm = TPM_ALG_NULL; + session->bind = TPM_RH_NULL; + session->bindName.b.size = 0; + session->bindAuthValue.t.size = 0; +#ifndef TPM_TSS_NOCRYPTO + memset(session->nonceTPM.t.buffer, 0, sizeof(TPMU_HA)); + session->nonceTPM.b.size = 0; + memset(session->nonceCaller.t.buffer, 0, sizeof(TPMU_HA)); + session->nonceCaller.b.size = 0; + memset(session->sessionKey.t.buffer, 0, sizeof(TPMU_HA)); + session->sessionKey.b.size = 0; +#endif + session->sessionType = 0; + session->isPasswordNeeded = FALSE; + session->isAuthValueNeeded = FALSE; + memset(session->hmacKey.t.buffer, 0, sizeof(TPMU_HA) + sizeof(TPMU_HA)); + session->hmacKey.b.size = 0; +#ifndef TPM_TSS_NOCRYPTO + memset(session->sessionValue.t.buffer, 0, sizeof(TPMU_HA) + sizeof(TPMU_HA)); + session->sessionValue.b.size = 0; +#endif +} + +void TSS_HmacSession_FreeContext(struct TSS_HMAC_CONTEXT *session) +{ + if (session != NULL) { + TSS_HmacSession_InitContext(session); + free(session); + } + return; +} + +/* TSS_HmacSession_SetSessionKey() is called by the StartAuthSession post processor to calculate and + store the session key + + 19.6.8 sessionKey Creation +*/ + +#ifndef TPM_TSS_NOCRYPTO + +static TPM_RC TSS_HmacSession_SetSessionKey(TSS_CONTEXT *tssContext, + struct TSS_HMAC_CONTEXT *session, + TPM2B_DIGEST *salt, + TPMI_DH_ENTITY bind, + TPM2B_AUTH *bindAuthValue) +{ + TPM_RC rc = 0; + TPM2B_KEY key; /* HMAC key for the KDFa */ + + if (rc == 0) { + /* save the bind handle, non-null indicates a bound session */ + session->bind = bind; + /* if bind, save the bind Name in the session context. The handle might change, but the + name will not */ + if ((rc == 0) && (bind != TPM_RH_NULL)) { + rc = TSS_Name_GetName(tssContext, &session->bindName, bind); + } + } + if (rc == 0) { + if ((bind != TPM_RH_NULL) || + (salt->b.size != 0)) { + + /* session key is bindAuthValue || salt */ + /* copy bindAuthValue. This is set during the post processor to either the supplied + bind password or Empty */ + if (rc == 0) { + rc = TSS_TPM2B_Copy(&key.b, &bindAuthValue->b, sizeof(TPMU_HA) + sizeof(TPMT_HA)); + } + /* copy salt. This is set during the postprocessor to either the salt from the + preprocessor or empty. */ + if (rc == 0) { + rc = TSS_TPM2B_Append(&key.b, &salt->b, sizeof(TPMU_HA) + sizeof(TPMT_HA)); + } + if (rc == 0) { + if (tssVverbose) TSS_PrintAll("TSS_HmacSession_SetSessionKey: KDFa HMAC key", + key.b.buffer, key.b.size); + } + /* KDFa for the session key */ + if (rc == 0) { + rc = TSS_KDFA(session->sessionKey.b.buffer, + session->authHashAlg, + &key.b, + "ATH", + &session->nonceTPM.b, + &session->nonceCaller.b, + session->sizeInBytes * 8); + } + if (rc == 0) { + session->sessionKey.b.size = session->sizeInBytes; + if (tssVverbose) + TSS_PrintAll("TSS_HmacSession_SetSessionKey: Session key", + session->sessionKey.b.buffer, session->sessionKey.b.size); + } + } + else { + session->sessionKey.b.size = 0; + } + } + return rc; +} + +#endif /* TPM_TSS_NOCRYPTO */ + +/* TSS_HmacSession_SaveSession() saves a session in two cases: + + The initial session from startauthsession + The updated session a TPM response +*/ + + +static TPM_RC TSS_HmacSession_SaveSession(TSS_CONTEXT *tssContext, + struct TSS_HMAC_CONTEXT *session) +{ + TPM_RC rc = 0; + uint8_t *buffer = NULL; /* marshaled TSS_HMAC_CONTEXT */ + uint16_t written = 0; +#ifndef TPM_TSS_NOFILE + char sessionFilename[TPM_DATA_DIR_PATH_LENGTH]; + uint8_t *outBuffer = NULL; + uint32_t outLength; +#endif + + if (tssVverbose) printf("TSS_HmacSession_SaveSession: handle %08x\n", session->sessionHandle); + if (rc == 0) { + rc = TSS_Structure_Marshal(&buffer, /* freed @1 */ + &written, + session, + (MarshalFunction_t)TSS_HmacSession_Marshal); + } +#ifndef TPM_TSS_NOFILE + if (rc == 0) { + /* if the flag is set, encrypt the session state before store */ + if (tssContext->tssEncryptSessions) { + rc = TSS_AES_Encrypt(tssContext->tssSessionEncKey, + &outBuffer, /* output, freed @2 */ + &outLength, /* output */ + buffer, /* input */ + written); /* input */ + } + /* else store the session state in plaintext */ + else { + outBuffer = buffer; + outLength = written; + } + } + /* save the session in a hard coded file name hxxxxxxxx.bin where xxxxxxxx is the session + handle */ + if (rc == 0) { + sprintf(sessionFilename, "%s/h%08x.bin", + tssContext->tssDataDirectory, session->sessionHandle); + } + if (rc == 0) { + rc = TSS_File_WriteBinaryFile(outBuffer, + outLength, + sessionFilename); + } + if (tssContext->tssEncryptSessions) { + free(outBuffer); /* @2 */ + } +#else /* no file support, save to context */ + if (rc == 0) { + rc = TSS_HmacSession_SaveData(tssContext, + session->sessionHandle, + written, buffer); + } +#endif + free(buffer); /* @1 */ + return rc; +} + +/* TSS_HmacSession_LoadSession() loads an existing HMAC session context saved by: + + startauthsession + an update after a TPM response +*/ + +static TPM_RC TSS_HmacSession_LoadSession(TSS_CONTEXT *tssContext, + struct TSS_HMAC_CONTEXT *session, + TPMI_SH_AUTH_SESSION sessionHandle) +{ + TPM_RC rc = 0; + uint8_t *buffer = NULL; + uint8_t *buffer1 = NULL; +#ifndef TPM_TSS_NOFILE + size_t length = 0; + char sessionFilename[TPM_DATA_DIR_PATH_LENGTH]; +#endif + unsigned char *inData = NULL; /* output */ + uint32_t inLength; /* output */ + + if (tssVverbose) printf("TSS_HmacSession_LoadSession: handle %08x\n", sessionHandle); +#ifndef TPM_TSS_NOFILE + /* load the session from a hard coded file name hxxxxxxxx.bin where xxxxxxxx is the session + handle */ + if (rc == 0) { + sprintf(sessionFilename, "%s/h%08x.bin", tssContext->tssDataDirectory, sessionHandle); + rc = TSS_File_ReadBinaryFile(&buffer, /* freed @1 */ + &length, + sessionFilename); + } + if (rc == 0) { + /* if the flag is set, decrypt the session state before unmarshal */ + if (tssContext->tssEncryptSessions) { + rc = TSS_AES_Decrypt(tssContext->tssSessionDecKey, + &inData, /* output, freed @2 */ + &inLength, /* output */ + buffer, /* input */ + length); /* input */ + } + /* else the session was loaded in plaintext */ + else { + inData = buffer; + inLength = length; + } + } +#else /* no file support, load from context */ + if (rc == 0) { + rc = TSS_HmacSession_LoadData(tssContext, + &inLength, &inData, + sessionHandle); + } +#endif + if (rc == 0) { + uint32_t ilength = inLength; + buffer1 = inData; + rc = TSS_HmacSession_Unmarshal(session, &buffer1, &ilength); + } +#ifndef TPM_TSS_NOFILE + if (tssContext->tssEncryptSessions) { + free(inData); /* @2 */ + } +#endif + free(buffer); /* @1 */ + return rc; +} + +#ifdef TPM_TSS_NOFILE + +static TPM_RC TSS_HmacSession_SaveData(TSS_CONTEXT *tssContext, + TPMI_SH_AUTH_SESSION sessionHandle, + uint32_t outLength, + uint8_t *outBuffer) +{ + TPM_RC rc = 0; + size_t slotIndex; + + /* if this handle is already used, overwrite the slot */ + if (rc == 0) { + rc = TSS_HmacSession_GetSlotForHandle(tssContext, &slotIndex, sessionHandle); + if (rc != 0) { + rc = TSS_HmacSession_GetSlotForHandle(tssContext, &slotIndex, TPM_RH_NULL); + if (rc == 0) { + tssContext->sessions[slotIndex].sessionHandle = sessionHandle; + } + else { + if (tssVerbose) + printf("TSS_HmacSession_SaveData: Error, no slot available for handle %08x\n", + sessionHandle); + } + } + } + /* reallocate memory and adjust the size */ + if (rc == 0) { + rc = TSS_Realloc(&tssContext->sessions[slotIndex].sessionData, outLength); + } + if (rc == 0) { + tssContext->sessions[slotIndex].sessionDataLength = outLength; + memcpy(tssContext->sessions[slotIndex].sessionData, outBuffer, outLength); + } + return rc; +} + +static TPM_RC TSS_HmacSession_LoadData(TSS_CONTEXT *tssContext, + uint32_t *inLength, uint8_t **inData, + TPMI_SH_AUTH_SESSION sessionHandle) +{ + TPM_RC rc = 0; + size_t slotIndex; + + if (rc == 0) { + rc = TSS_HmacSession_GetSlotForHandle(tssContext, &slotIndex, sessionHandle); + if (rc != 0) { + if (tssVerbose) + printf("TSS_HmacSession_LoadData: Error, no slot found for handle %08x\n", + sessionHandle); + } + } + if (rc == 0) { + *inLength = tssContext->sessions[slotIndex].sessionDataLength; + *inData = tssContext->sessions[slotIndex].sessionData; + } + return rc; +} + +static TPM_RC TSS_HmacSession_DeleteData(TSS_CONTEXT *tssContext, + TPMI_SH_AUTH_SESSION sessionHandle) +{ + TPM_RC rc = 0; + size_t slotIndex; + + if (rc == 0) { + rc = TSS_HmacSession_GetSlotForHandle(tssContext, &slotIndex, sessionHandle); + if (rc != 0) { + if (tssVerbose) + printf("TSS_HmacSession_DeleteData: Error, no slot found for handle %08x\n", + sessionHandle); + } + } + if (rc == 0) { + tssContext->sessions[slotIndex].sessionHandle = TPM_RH_NULL; + /* erase any secrets */ + memset(tssContext->sessions[slotIndex].sessionData, 0, + tssContext->sessions[slotIndex].sessionDataLength); + free(tssContext->sessions[slotIndex].sessionData); + tssContext->sessions[slotIndex].sessionData = NULL; + tssContext->sessions[slotIndex].sessionDataLength = 0; + } + return rc; +} + +/* TSS_HmacSession_GetSlotForHandle() finds the session slot corresponding to the session handle. + + Returns non-zero if no slot is found. +*/ + +static TPM_RC TSS_HmacSession_GetSlotForHandle(TSS_CONTEXT *tssContext, + size_t *slotIndex, + TPMI_SH_AUTH_SESSION sessionHandle) +{ + size_t i; + + /* search all slots for handle */ + for (i = 0 ; i < (sizeof(tssContext->sessions) / sizeof(TSS_SESSIONS)) ; i++) { + if (tssContext->sessions[i].sessionHandle == sessionHandle) { + *slotIndex = i; + return 0; + } + } + return TSS_RC_NO_SESSION_SLOT; +} + +#endif + +static TPM_RC TSS_HmacSession_Marshal(struct TSS_HMAC_CONTEXT *source, + uint16_t *written, + uint8_t **buffer, + uint32_t *size) +{ + TPM_RC rc = 0; + + if (rc == 0) { + rc = TSS_TPMI_SH_AUTH_SESSION_Marshalu(&source->sessionHandle, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMI_ALG_HASH_Marshalu(&source->authHashAlg, written, buffer, size); + } +#ifndef TPM_TSS_NOCRYPTO + if (rc == 0) { + rc = TSS_UINT32_Marshalu(&source->sizeInBytes, written, buffer, size); + } +#endif + if (rc == 0) { + rc = TSS_TPMT_SYM_DEF_Marshalu(&source->symmetric, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMI_DH_ENTITY_Marshalu(&source->bind, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_NAME_Marshalu(&source->bindName, written, buffer, size); + } +#ifdef TPM_WINDOWS + /* FIXME Why does a VS release build need a printf here? */ + if (tssVverbose) printf(""); +#endif + if (rc == 0) { + rc = TSS_TPM2B_AUTH_Marshalu(&source->bindAuthValue, written, buffer, size); + } +#ifndef TPM_TSS_NOCRYPTO + if (rc == 0) { + rc = TSS_TPM2B_NONCE_Marshalu(&source->nonceTPM, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_NONCE_Marshalu(&source->nonceCaller, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_DIGEST_Marshalu(&source->sessionKey, written, buffer, size); + } +#endif + if (rc == 0) { + rc = TSS_TPM_SE_Marshalu(&source->sessionType, written, buffer, size); + } + if (rc == 0) { + rc = TSS_UINT8_Marshalu(&source->isPasswordNeeded, written, buffer, size); + } + if (rc == 0) { + rc = TSS_UINT8_Marshalu(&source->isAuthValueNeeded, written, buffer, size); + } + return rc; +} + +static TPM_RC TSS_HmacSession_Unmarshal(struct TSS_HMAC_CONTEXT *target, + uint8_t **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + + if (rc == 0) { + rc = TSS_TPMI_SH_AUTH_SESSION_Unmarshalu(&target->sessionHandle, buffer, size, NO); + } + if (rc == 0) { + rc = TSS_TPMI_ALG_HASH_Unmarshalu(&target->authHashAlg, buffer, size, NO); + } +#ifndef TPM_TSS_NOCRYPTO + if (rc == 0) { + rc = TSS_UINT32_Unmarshalu(&target->sizeInBytes, buffer, size); + } +#endif + if (rc == 0) { + rc = TSS_TPMT_SYM_DEF_Unmarshalu(&target->symmetric, buffer, size, YES); + } + if (rc == 0) { + rc = TSS_TPMI_DH_ENTITY_Unmarshalu(&target->bind, buffer, size, YES); + } + if (rc == 0) { + rc = TSS_TPM2B_NAME_Unmarshalu(&target->bindName, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_AUTH_Unmarshalu(&target->bindAuthValue, buffer, size); + } +#ifndef TPM_TSS_NOCRYPTO + if (rc == 0) { + rc = TSS_TPM2B_NONCE_Unmarshalu(&target->nonceTPM, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_NONCE_Unmarshalu(&target->nonceCaller, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_DIGEST_Unmarshalu(&target->sessionKey, buffer, size); + } +#endif + if (rc == 0) { + rc = TSS_TPM_SE_Unmarshalu(&target->sessionType, buffer, size); + } + if (rc == 0) { + rc = TSS_UINT8_Unmarshalu(&target->isPasswordNeeded, buffer, size); + } + if (rc == 0) { + rc = TSS_UINT8_Unmarshalu(&target->isAuthValueNeeded, buffer, size); + } + return rc; +} + +/* + Name handling +*/ + +/* TSS_Name_GetAllNames() files in the names array based on the handles marshaled into the TSS + context command stream. */ + +static TPM_RC TSS_Name_GetAllNames(TSS_CONTEXT *tssContext, + TPM2B_NAME **names) +{ + TPM_RC rc = 0; + size_t i; + size_t commandHandleCount; /* number of handles in the command stream */ + TPM_HANDLE commandHandle; + + /* get the number of handles in the command stream */ + if (rc == 0) { + rc = TSS_GetCommandHandleCount(tssContext->tssAuthContext, &commandHandleCount); + if (tssVverbose) printf("TSS_Name_GetAllNames: commandHandleCount %u\n", (unsigned int)commandHandleCount); + } + for (i = 0 ; (rc == 0) && (i < commandHandleCount) ; i++) { + /* get a handle from the command stream */ + if (rc == 0) { + rc = TSS_GetCommandHandle(tssContext->tssAuthContext, + &commandHandle, + i); + } + /* get the Name corresponding to the handle */ + if (rc == 0) { + if (tssVverbose) printf("TSS_Name_GetAllNames: commandHandle %u %08x\n", + (unsigned int)i, commandHandle); + rc = TSS_Name_GetName(tssContext, names[i], commandHandle); + } + } + return rc; +} + +/* TSS_Name_GetName() gets the Name associated with the handle */ + +static TPM_RC TSS_Name_GetName(TSS_CONTEXT *tssContext, + TPM2B_NAME *name, + TPM_HANDLE handle) +{ + TPM_RC rc = 0; + TPM_HT handleType; + + if (tssVverbose) printf("TSS_Name_GetName: Handle %08x\n", handle); + handleType = (TPM_HT) ((handle & HR_RANGE_MASK) >> HR_SHIFT); + + /* Table 3 - Equations for Computing Entity Names */ + switch (handleType) { + /* for these, the Name is simply the handle value */ + case TPM_HT_PCR: + case TPM_HT_HMAC_SESSION: + case TPM_HT_POLICY_SESSION: + case TPM_HT_PERMANENT: + rc = TSS_TPM2B_CreateUint32(&name->b, handle, sizeof(name->t.name)); + break; + /* for NV, the Names was calculated at NV read public */ + case TPM_HT_NV_INDEX: + /* for objects, the Name was returned at creation or load */ + case TPM_HT_TRANSIENT: + case TPM_HT_PERSISTENT: + rc = TSS_Name_Load(tssContext, name, handle, NULL); + break; + default: + if (tssVerbose) printf("TSS_Name_GetName: not implemented for handle %08x\n", handle); + rc = TSS_RC_NAME_NOT_IMPLEMENTED; + break; + } + if (rc == 0) { + if (tssVverbose) + TSS_PrintAll("TSS_Name_GetName: ", + name->t.name, name->t.size); + } + + return rc; +} + +/* TSS_Name_Store() stores the 'name' parameter in a file. + + If handle is not 0, the handle is used as the file name. + + If 'string' is not NULL, the string is used as the file name. +*/ + +#ifndef TPM_TSS_NOFILE + +static TPM_RC TSS_Name_Store(TSS_CONTEXT *tssContext, + TPM2B_NAME *name, + TPM_HANDLE handle, + const char *string) +{ + TPM_RC rc = 0; + char nameFilename[TPM_DATA_DIR_PATH_LENGTH]; + + if (rc == 0) { + if (string == NULL) { + if (handle != 0) { + sprintf(nameFilename, "%s/h%08x.bin", tssContext->tssDataDirectory, handle); + } + else { + if (tssVerbose) printf("TSS_Name_Store: handle and string are both null"); + rc = TSS_RC_NAME_FILENAME; + } + } + else { + if (handle == 0) { + sprintf(nameFilename, "%s/h%s.bin", tssContext->tssDataDirectory, string); + } + else { + if (tssVerbose) printf("TSS_Name_Store: handle and string are both not null"); + rc = TSS_RC_NAME_FILENAME; + } + } + } + if (rc == 0) { + if (tssVverbose) printf("TSS_Name_Store: File %s\n", nameFilename); + rc = TSS_File_WriteBinaryFile(name->b.buffer, name->b.size, nameFilename); + } + return rc; +} + +#endif + +/* TSS_Name_Load() loads the 'name' from a file. + + If handle is not 0, the handle is used as the file name. + + If 'string' is not NULL, the string is used as the file name. +*/ + +#ifndef TPM_TSS_NOFILE + +static TPM_RC TSS_Name_Load(TSS_CONTEXT *tssContext, + TPM2B_NAME *name, + TPM_HANDLE handle, + const char *string) +{ + TPM_RC rc = 0; + char nameFilename[TPM_DATA_DIR_PATH_LENGTH]; + + if (rc == 0) { + if (string == NULL) { + if (handle != 0) { + sprintf(nameFilename, "%s/h%08x.bin", tssContext->tssDataDirectory, handle); + } + else { + if (tssVerbose) printf("TSS_Name_Load: handle and string are both null\n"); + rc = TSS_RC_NAME_FILENAME; + } + } + else { + if (handle == 0) { + sprintf(nameFilename, "%s/h%s.bin", tssContext->tssDataDirectory, string); + } + else { + if (tssVerbose) printf("TSS_Name_Load: handle and string are both not null\n"); + rc = TSS_RC_NAME_FILENAME; + } + } + } + if (rc == 0) { + if (tssVverbose) printf("TSS_Name_Load: File %s\n", nameFilename); + rc = TSS_File_Read2B(&name->b, + sizeof(name->t.name), + nameFilename); + } + return rc; +} + +#endif + +/* TSS_Name_Store() stores the 'name' parameter the TSS context. + +*/ + +#ifdef TPM_TSS_NOFILE + +static TPM_RC TSS_Name_Store(TSS_CONTEXT *tssContext, + TPM2B_NAME *name, + TPM_HANDLE handle, + const char *string) +{ + TPM_RC rc = 0; + TPM_HT handleType; + size_t slotIndex; + + if (tssVverbose) printf("TSS_Name_Store: Handle %08x\n", handle); + handleType = (TPM_HT) ((handle & HR_RANGE_MASK) >> HR_SHIFT); + + switch (handleType) { + case TPM_HT_NV_INDEX: + /* for NV, the Name was returned at creation */ + rc = TSS_NvPublic_GetSlotForHandle(tssContext, &slotIndex, handle); + if (rc != 0) { + rc = TSS_NvPublic_GetSlotForHandle(tssContext, &slotIndex, TPM_RH_NULL); + if (rc == 0) { + tssContext->nvPublic[slotIndex].nvIndex = handle; + } + else { + if (tssVerbose) + printf("TSS_Name_Store: Error, no slot available for handle %08x\n", handle); + } + } + if (rc == 0) { + tssContext->nvPublic[slotIndex].name = *name; + } + break; + case TPM_HT_TRANSIENT: + case TPM_HT_PERSISTENT: + if (rc == 0) { + if (string == NULL) { + if (handle != 0) { + /* if this handle is already used, overwrite the slot */ + rc = TSS_ObjectPublic_GetSlotForHandle(tssContext, &slotIndex, handle); + if (rc != 0) { + rc = TSS_ObjectPublic_GetSlotForHandle(tssContext, &slotIndex, TPM_RH_NULL); + if (rc == 0) { + tssContext->objectPublic[slotIndex].objectHandle = handle; + } + else { + if (tssVerbose) + printf("TSS_Name_Store: " + "Error, no slot available for handle %08x\n", + handle); + } + } + } + else { + if (tssVerbose) printf("TSS_Name_Store: handle and string are both null"); + rc = TSS_RC_NAME_FILENAME; + } + } + else { + if (handle == 0) { + if (tssVerbose) printf("TSS_Name_Store: string unimplemented"); + rc = TSS_RC_NAME_FILENAME; + } + else { + if (tssVerbose) printf("TSS_Name_Store: handle and string are both not null"); + rc = TSS_RC_NAME_FILENAME; + } + } + } + if (rc == 0) { + tssContext->objectPublic[slotIndex].name = *name; + } + break; + default: + if (tssVerbose) printf("TSS_Name_Store: handle type %02x unimplemented", handleType); + rc = TSS_RC_NAME_FILENAME; + } + return rc; +} + +#endif + +/* TSS_Name_Load() loads the 'name' from the TSS context. + +*/ + +#ifdef TPM_TSS_NOFILE + +static TPM_RC TSS_Name_Load(TSS_CONTEXT *tssContext, + TPM2B_NAME *name, + TPM_HANDLE handle, + const char *string) +{ + TPM_RC rc = 0; + TPM_HT handleType; + size_t slotIndex; + + string = string; + + if (tssVverbose) printf("TSS_Name_Load: Handle %08x\n", handle); + handleType = (TPM_HT) ((handle & HR_RANGE_MASK) >> HR_SHIFT); + + switch (handleType) { + case TPM_HT_NV_INDEX: + rc = TSS_NvPublic_GetSlotForHandle(tssContext, &slotIndex, handle); + if (rc != 0) { + if (tssVerbose) + printf("TSS_Name_Load: Error, no slot found for handle %08x\n", handle); + } + if (rc == 0) { + *name = tssContext->nvPublic[slotIndex].name; + } + break; + case TPM_HT_TRANSIENT: + case TPM_HT_PERSISTENT: + rc = TSS_ObjectPublic_GetSlotForHandle(tssContext, &slotIndex, handle); + if (rc != 0) { + if (tssVerbose) + printf("TSS_Name_Load: Error, no slot found for handle %08x\n", handle); + } + if (rc == 0) { + *name = tssContext->objectPublic[slotIndex].name; + } + break; + default: + if (tssVerbose) printf("TSS_Name_Load: handle type %02x unimplemented", handleType); + rc = TSS_RC_NAME_FILENAME; + + } + return rc; +} + +#endif + +/* TSS_Name_Copy() copies the name from either inHandle or inString to either outHandle or + outString */ + +static TPM_RC TSS_Name_Copy(TSS_CONTEXT *tssContext, + TPM_HANDLE outHandle, + const char *outString, + TPM_HANDLE inHandle, + const char *inString) +{ + TPM_RC rc = 0; + TPM2B_NAME name; + + if (rc == 0) { + rc = TSS_Name_Load(tssContext, &name, inHandle, inString); + } + if (rc == 0) { + rc = TSS_Name_Store(tssContext, &name, outHandle, outString); + } + return rc; +} + +/* TSS_Public_Store() stores the 'public' parameter in a file. + + If handle is not 0, the handle is used as the file name. + + If 'string' is not NULL, the string is used as the file name. +*/ + +#ifndef TPM_TSS_NOFILE + +static TPM_RC TSS_Public_Store(TSS_CONTEXT *tssContext, + TPM2B_PUBLIC *public, + TPM_HANDLE handle, + const char *string) +{ + TPM_RC rc = 0; + char publicFilename[TPM_DATA_DIR_PATH_LENGTH]; + + if (rc == 0) { + if (string == NULL) { + if (handle != 0) { /* store by handle */ + sprintf(publicFilename, "%s/hp%08x.bin", tssContext->tssDataDirectory, handle); + } + else { + if (tssVerbose) printf("TSS_Public_Store: handle and string are both null"); + rc = TSS_RC_NAME_FILENAME; + } + } + else { + if (handle == 0) { /* store by string */ + sprintf(publicFilename, "%s/hp%s.bin", tssContext->tssDataDirectory, string); + } + else { + if (tssVerbose) printf("TSS_Public_Store: handle and string are both not null"); + rc = TSS_RC_NAME_FILENAME; + } + } + } + if (rc == 0) { + if (tssVverbose) printf("TSS_Public_Store: File %s\n", publicFilename); + rc = TSS_File_WriteStructure(public, + (MarshalFunction_t)TSS_TPM2B_PUBLIC_Marshal, + publicFilename); + } + return rc; +} + +#endif + +/* TSS_Public_Load() loads the 'public' parameter from a file. + + If handle is not 0, the handle is used as the file name. + + If 'string' is not NULL, the string is used as the file name. +*/ + +#ifndef TPM_TSS_NOFILE + +static TPM_RC TSS_Public_Load(TSS_CONTEXT *tssContext, + TPM2B_PUBLIC *public, + TPM_HANDLE handle, + const char *string) +{ + TPM_RC rc = 0; + char publicFilename[TPM_DATA_DIR_PATH_LENGTH]; + + if (rc == 0) { + if (string == NULL) { + if (handle != 0) { + sprintf(publicFilename, "%s/hp%08x.bin", tssContext->tssDataDirectory, handle); + } + else { + if (tssVerbose) printf("TSS_Public_Load: handle and string are both null\n"); + rc = TSS_RC_NAME_FILENAME; + } + } + else { + if (handle == 0) { + sprintf(publicFilename, "%s/hp%s.bin", tssContext->tssDataDirectory, string); + } + else { + if (tssVerbose) printf("TSS_Public_Load: handle and string are both not null\n"); + rc = TSS_RC_NAME_FILENAME; + } + } + } + if (rc == 0) { + if (tssVverbose) printf("TSS_Public_Load: File %s\n", publicFilename); + rc = TSS_File_ReadStructureFlag(public, + (UnmarshalFunctionFlag_t)TSS_TPM2B_PUBLIC_Unmarshalu, + TRUE, /* NULL permitted */ + publicFilename); + } + return rc; +} + +#endif /* TPM_TSS_NOFILE */ + +/* TSS_Public_Copy() copies the TPM2B_PUBLIC from either inHandle or inString to either outHandle or + outString */ + +static TPM_RC TSS_Public_Copy(TSS_CONTEXT *tssContext, + TPM_HANDLE outHandle, + const char *outString, + TPM_HANDLE inHandle, + const char *inString) +{ + TPM_RC rc = 0; + TPM2B_PUBLIC public; + + if (rc == 0) { + rc = TSS_Public_Load(tssContext, &public, inHandle, inString); + } + if (rc == 0) { + rc = TSS_Public_Store(tssContext, &public, outHandle, outString); + } + return rc; +} + +/* TSS_Public_Store() stores the 'public' parameter in the TSS context. + */ + +#ifdef TPM_TSS_NOFILE + +static TPM_RC TSS_Public_Store(TSS_CONTEXT *tssContext, + TPM2B_PUBLIC *public, + TPM_HANDLE handle, + const char *string) +{ + TPM_RC rc = 0; + size_t slotIndex; + + if (rc == 0) { + if (string == NULL) { + if (handle != 0) { + /* if this handle is already used, overwrite the slot */ + rc = TSS_ObjectPublic_GetSlotForHandle(tssContext, &slotIndex, handle); + if (rc != 0) { + rc = TSS_ObjectPublic_GetSlotForHandle(tssContext, &slotIndex, TPM_RH_NULL); + if (rc == 0) { + tssContext->objectPublic[slotIndex].objectHandle = handle; + } + else { + if (tssVerbose) + printf("TSS_Public_Store: Error, no slot available for handle %08x\n", + handle); + } + } + } + else { + if (tssVerbose) printf("TSS_Public_Store: handle and string are both null"); + rc = TSS_RC_NAME_FILENAME; + } + } + else { + if (handle == 0) { + if (tssVerbose) printf("TSS_Public_Store: string not implemented yet"); + rc = TSS_RC_NAME_FILENAME; + } + else { + if (tssVerbose) printf("TSS_Public_Store: handle and string are both not null"); + rc = TSS_RC_NAME_FILENAME; + } + } + } + if (rc == 0) { + tssContext->objectPublic[slotIndex].objectPublic = *public; + } + return rc; +} + +#endif + +/* TSS_Public_Load() loaded the object public from the TSS context. + + */ + +#ifdef TPM_TSS_NOFILE + +static TPM_RC TSS_Public_Load(TSS_CONTEXT *tssContext, + TPM2B_PUBLIC *public, + TPM_HANDLE handle, + const char *string) +{ + TPM_RC rc = 0; + size_t slotIndex; + + if (rc == 0) { + if (string == NULL) { + if (handle != 0) { + rc = TSS_ObjectPublic_GetSlotForHandle(tssContext, &slotIndex, handle); + if (rc != 0) { + if (tssVerbose) + printf("TSS_Public_Load: Error, no slot found for handle %08x\n", + handle); + } + } + else { + if (tssVerbose) printf("TSS_Public_Load: handle and string are both null\n"); + rc = TSS_RC_NAME_FILENAME; + } + } + else { + if (handle == 0) { + if (tssVerbose) printf("TSS_Public_Load: string not implemented yet"); + rc = TSS_RC_NAME_FILENAME; + } + else { + if (tssVerbose) printf("TSS_Public_Load: handle and string are both not null\n"); + rc = TSS_RC_NAME_FILENAME; + } + } + } + if (rc == 0) { + *public = tssContext->objectPublic[slotIndex].objectPublic; + } + return rc; +} + +#endif /* TPM_TSS_NOFILE */ + +#ifdef TPM_TSS_NOFILE + +/* TSS_ObjectPublic_GetSlotForHandle() finds the object public slot corresponding to the handle. + + Returns non-zero if no slot is found. +*/ + +static TPM_RC TSS_ObjectPublic_GetSlotForHandle(TSS_CONTEXT *tssContext, + size_t *slotIndex, + TPM_HANDLE handle) +{ + size_t i; + + /* search all slots for handle */ + for (i = 0 ; i < (sizeof(tssContext->sessions) / sizeof(TSS_SESSIONS)) ; i++) { + if (tssContext->objectPublic[i].objectHandle == handle) { + *slotIndex = i; + return 0; + } + } + return TSS_RC_NO_OBJECTPUBLIC_SLOT; +} + +#endif + +#ifdef TPM_TSS_NOFILE + +static TPM_RC TSS_ObjectPublic_DeleteData(TSS_CONTEXT *tssContext, TPM_HANDLE handle) +{ + TPM_RC rc = 0; + size_t slotIndex; + + if (rc == 0) { + rc = TSS_ObjectPublic_GetSlotForHandle(tssContext, &slotIndex, handle); + if (rc != 0) { + if (tssVerbose) + printf("TSS_ObjectPublic_DeleteData: Error, no slot found for handle %08x\n", + handle); + } + } + if (rc == 0) { + tssContext->objectPublic[slotIndex].objectHandle = TPM_RH_NULL; + } + return rc; +} + +#endif + + +/* TSS_DeleteHandle() removes retained state stored by the TSS for a handle + */ + +static TPM_RC TSS_DeleteHandle(TSS_CONTEXT *tssContext, + TPM_HANDLE handle) +{ + TPM_RC rc = 0; + TPM_HT handleType; +#ifndef TPM_TSS_NOFILE + char filename[TPM_DATA_DIR_PATH_LENGTH]; +#endif + + handleType = (TPM_HT) ((handle & HR_RANGE_MASK) >> HR_SHIFT); +#ifndef TPM_TSS_NOFILE + /* delete the Name */ + if (rc == 0) { + sprintf(filename, "%s/h%08x.bin", tssContext->tssDataDirectory, handle); + if (tssVverbose) printf("TSS_DeleteHandle: delete Name file %s\n", filename); + rc = TSS_File_DeleteFile(filename); + } + /* delete the public if it exists */ + if (rc == 0) { + if ((handleType == TPM_HT_TRANSIENT) || + (handleType == TPM_HT_PERSISTENT)) { + sprintf(filename, "%s/hp%08x.bin", tssContext->tssDataDirectory, handle); + if (tssVverbose) printf("TSS_DeleteHandle: delete public file %s\n", filename); + TSS_File_DeleteFile(filename); + } + } +#else + /* sessions persist in the context and can be deleted */ + if (rc == 0) { + switch (handleType) { + case TPM_HT_NV_INDEX: + rc = TSS_RC_NOT_IMPLEMENTED; + break; + case TPM_HT_HMAC_SESSION: + case TPM_HT_POLICY_SESSION: + if (tssVverbose) printf("TSS_DeleteHandle: delete session state %08x\n", handle); + rc = TSS_HmacSession_DeleteData(tssContext, handle); + break; + case TPM_HT_TRANSIENT: + case TPM_HT_PERSISTENT: + rc = TSS_ObjectPublic_DeleteData(tssContext, handle); + break; + } + } +#endif + return rc; +} + +/* TSS_ObjectPublic_GetName() calculates the Name from the TPMT_PUBLIC. The Name provides security, + because the Name returned from the TPM2_ReadPublic cannot be trusted. +*/ + +static TPM_RC TSS_ObjectPublic_GetName(TPM2B_NAME *name, + TPMT_PUBLIC *tpmtPublic) +{ + TPM_RC rc = 0; + +#ifndef TPM_TSS_NOCRYPTO + uint16_t written = 0; + TPMT_HA digest; + uint32_t sizeInBytes = 0; + uint8_t *buffer = NULL; + + if (rc == 0) { + rc = TSS_Malloc(&buffer, MAX_RESPONSE_SIZE); /* freed @1 */ + } + /* marshal the TPMT_PUBLIC */ + if (rc == 0) { + uint32_t size = MAX_RESPONSE_SIZE; + uint8_t *buffer1 = buffer; + rc = TSS_TPMT_PUBLIC_Marshalu(tpmtPublic, &written, &buffer1, &size); + } + /* hash the public area */ + if (rc == 0) { + sizeInBytes = TSS_GetDigestSize(tpmtPublic->nameAlg); + digest.hashAlg = tpmtPublic->nameAlg; /* Name digest algorithm */ + /* generate the TPMT_HA */ + rc = TSS_Hash_Generate(&digest, + written, buffer, + 0, NULL); + } + if (rc == 0) { + TPMI_ALG_HASH nameAlgNbo; + /* copy the digest */ + memcpy(name->t.name + sizeof(TPMI_ALG_HASH), (uint8_t *)&digest.digest, sizeInBytes); + /* copy the hash algorithm */ + nameAlgNbo = htons(tpmtPublic->nameAlg); + memcpy(name->t.name, (uint8_t *)&nameAlgNbo, sizeof(TPMI_ALG_HASH)); + /* set the size */ + name->t.size = sizeInBytes + sizeof(TPMI_ALG_HASH); + free(buffer); /* @1 */ + } +#else + tpmtPublic = tpmtPublic; + name->t.size = 0; +#endif + return rc; +} + +/* TSS_NVPublic_Store() stores the NV public data in a file. + + */ + +#ifndef TPM_TSS_NOFILE +#ifndef TPM_TSS_NOCRYPTO + +static TPM_RC TSS_NVPublic_Store(TSS_CONTEXT *tssContext, + TPMS_NV_PUBLIC *nvPublic, + TPMI_RH_NV_INDEX nvIndex) +{ + TPM_RC rc = 0; + char nvpFilename[TPM_DATA_DIR_PATH_LENGTH]; + + if (rc == 0) { + sprintf(nvpFilename, "%s/nvp%08x.bin", tssContext->tssDataDirectory, nvIndex); + rc = TSS_File_WriteStructure(nvPublic, + (MarshalFunction_t)TSS_TPMS_NV_PUBLIC_Marshal, + nvpFilename); + } + return rc; +} + +#endif +#endif + +/* TSS_NVPublic_Load() loads the NV public from a file. + + */ + +#ifndef TPM_TSS_NOFILE +#ifndef TPM_TSS_NOCRYPTO + +static TPM_RC TSS_NVPublic_Load(TSS_CONTEXT *tssContext, + TPMS_NV_PUBLIC *nvPublic, + TPMI_RH_NV_INDEX nvIndex) +{ + TPM_RC rc = 0; + char nvpFilename[TPM_DATA_DIR_PATH_LENGTH]; + + if (rc == 0) { + sprintf(nvpFilename, "%s/nvp%08x.bin", tssContext->tssDataDirectory, nvIndex); + rc = TSS_File_ReadStructure(nvPublic, + (UnmarshalFunction_t)TSS_TPMS_NV_PUBLIC_Unmarshalu, + nvpFilename); + } + return rc; +} + +#endif +#endif + +#ifndef TPM_TSS_NOFILE + +static TPM_RC TSS_NVPublic_Delete(TSS_CONTEXT *tssContext, + TPMI_RH_NV_INDEX nvIndex) +{ + TPM_RC rc = 0; + char nvpFilename[TPM_DATA_DIR_PATH_LENGTH]; + + if (rc == 0) { + sprintf(nvpFilename, "%s/nvp%08x.bin", tssContext->tssDataDirectory, nvIndex); + rc = TSS_File_DeleteFile(nvpFilename); + return rc; + } + return rc; +} + +#endif + +#ifdef TPM_TSS_NOFILE +#ifndef TPM_TSS_NOCRYPTO + +/* TSS_NVPublic_Store() stores the NV public data in a file. + + */ + +static TPM_RC TSS_NVPublic_Store(TSS_CONTEXT *tssContext, + TPMS_NV_PUBLIC *nvPublic, + TPMI_RH_NV_INDEX nvIndex) +{ + TPM_RC rc = 0; + size_t slotIndex; + + if (rc == 0) { + rc = TSS_NvPublic_GetSlotForHandle(tssContext, &slotIndex, nvIndex); + if (rc != 0) { + rc = TSS_NvPublic_GetSlotForHandle(tssContext, &slotIndex, TPM_RH_NULL); + if (rc == 0) { + tssContext->nvPublic[slotIndex].nvIndex = nvIndex; + } + else { + if (tssVerbose) + printf("TSS_NVPublic_Store: Error, no slot available for handle %08x\n", + nvIndex); + } + } + } + if (rc == 0) { + tssContext->nvPublic[slotIndex].nvPublic = *nvPublic; + } + return rc; +} + +#endif +#endif + +#ifdef TPM_TSS_NOFILE +#ifndef TPM_TSS_NOCRYPTO + +/* TSS_NVPublic_Load() loads the NV public from a file. + + */ + +static TPM_RC TSS_NVPublic_Load(TSS_CONTEXT *tssContext, + TPMS_NV_PUBLIC *nvPublic, + TPMI_RH_NV_INDEX nvIndex) +{ + TPM_RC rc = 0; + size_t slotIndex; + + if (rc == 0) { + rc = TSS_NvPublic_GetSlotForHandle(tssContext, &slotIndex, nvIndex); + if (rc != 0) { + if (tssVerbose) + printf("TSS_NVPublic_Load: Error, no slot found for handle %08x\n", + nvIndex); + } + } + if (rc == 0) { + *nvPublic = tssContext->nvPublic[slotIndex].nvPublic; + } + return rc; +} + +#endif +#endif + +#ifdef TPM_TSS_NOFILE + +static TPM_RC TSS_NVPublic_Delete(TSS_CONTEXT *tssContext, + TPMI_RH_NV_INDEX nvIndex) +{ + TPM_RC rc = 0; + size_t slotIndex; + + if (rc == 0) { + rc = TSS_NvPublic_GetSlotForHandle(tssContext, &slotIndex, nvIndex); + if (rc != 0) { + if (tssVerbose) + printf("TSS_NVPublic_Delete: Error, no slot found for handle %08x\n", + nvIndex); + } + } + if (rc == 0) { + tssContext->nvPublic[slotIndex].nvIndex = TPM_RH_NULL; + } + return rc; +} + +#endif + +#ifdef TPM_TSS_NOFILE + +/* TSS_NvPublic_GetSlotForHandle() finds the object public slot corresponding to the handle. + + Returns non-zero if no slot is found. +*/ + +static TPM_RC TSS_NvPublic_GetSlotForHandle(TSS_CONTEXT *tssContext, + size_t *slotIndex, + TPMI_RH_NV_INDEX nvIndex) +{ + size_t i; + + /* search all slots for handle */ + for (i = 0 ; i < (sizeof(tssContext->nvPublic) / sizeof(TSS_NVPUBLIC)) ; i++) { + if (tssContext->nvPublic[i].nvIndex == nvIndex) { + *slotIndex = i; + return 0; + } + } + return TSS_RC_NO_NVPUBLIC_SLOT; +} + +#endif + +/* TSS_NVPublic_GetName() calculates the Name from the TPMS_NV_PUBLIC. The Name provides security, + because the Name returned from the TPM2_NV_ReadPublic cannot be trusted. +*/ + +#ifndef TPM_TSS_NOCRYPTO + +static TPM_RC TSS_NVPublic_GetName(TPM2B_NAME *name, + TPMS_NV_PUBLIC *nvPublic) +{ + TPM_RC rc = 0; + + uint16_t written = 0; + TPMT_HA digest; + uint32_t sizeInBytes = 0; + uint8_t *buffer = NULL; + + if (rc == 0) { + rc = TSS_Malloc(&buffer, MAX_RESPONSE_SIZE); /* freed @1 */ + } + /* marshal the TPMS_NV_PUBLIC */ + if (rc == 0) { + uint32_t size = MAX_RESPONSE_SIZE; + uint8_t *buffer1 = buffer; + rc = TSS_TPMS_NV_PUBLIC_Marshalu(nvPublic, &written, &buffer1, &size); + } + /* hash the public area */ + if (rc == 0) { + sizeInBytes = TSS_GetDigestSize(nvPublic->nameAlg); + digest.hashAlg = nvPublic->nameAlg; /* Name digest algorithm */ + /* generate the TPMT_HA */ + rc = TSS_Hash_Generate(&digest, + written, buffer, + 0, NULL); + } + if (rc == 0) { + TPMI_ALG_HASH nameAlgNbo; + /* copy the digest */ + memcpy(name->t.name + sizeof(TPMI_ALG_HASH), (uint8_t *)&digest.digest, sizeInBytes); + /* copy the hash algorithm */ + nameAlgNbo = htons(nvPublic->nameAlg); + memcpy(name->t.name, (uint8_t *)&nameAlgNbo, sizeof(TPMI_ALG_HASH)); + /* set the size */ + name->t.size = sizeInBytes + sizeof(TPMI_ALG_HASH); + } + free(buffer); /* @1 */ + return rc; +} + +#endif + +#ifndef TPM_TSS_NOCRYPTO + +static TPM_RC TSS_HmacSession_SetNonceCaller(struct TSS_HMAC_CONTEXT *session, + TPMS_AUTH_COMMAND *authC) +{ + TPM_RC rc = 0; + + /* generate a new nonceCaller */ + if (rc == 0) { + session->nonceCaller.b.size = session->sizeInBytes; + rc = TSS_RandBytes(session->nonceCaller.t.buffer, session->sizeInBytes); + } + /* nonceCaller for the command */ + if (rc == 0) { + rc = TSS_TPM2B_Copy(&authC->nonce.b, &session->nonceCaller.b, sizeof(TPMU_HA)); + } + return rc; +} + +#endif /* TPM_TSS_NOCRYPTO */ + +#ifndef TPM_TSS_NOCRYPTO + +/* TSS_HmacSession_SetHmacKey() calculates the session HMAC key. + + handleNumber is index into the session area. The first sessions, the authorization sessions, + have a corresponding handle in the command handle. +*/ + +static TPM_RC TSS_HmacSession_SetHmacKey(TSS_CONTEXT *tssContext, + struct TSS_HMAC_CONTEXT *session, + size_t handleNumber, /* index into the handle area */ + const char *password) +{ + TPM_RC rc = 0; + TPM_HANDLE commandHandle; /* from handle area, for bound session */ + TPM2B_NAME name; + TPM2B_AUTH authValue; + int bindMatch = FALSE; + int done = FALSE; /* done with authorization sessions */ + + /* + authHMAC = HMAC sessionAlg ((sessionKey || authValue), + (pHash || nonceNewer || nonceOlder + { || nonceTPMdecrypt } { || nonceTPMencrypt } + || sessionAttributes)) + */ + /* HMAC key is sessionKey || authValue */ + /* copy the session key to HMAC key */ + if (rc == 0) { + if (tssVverbose) TSS_PrintAll("TSS_HmacSession_SetHmacKey: sessionKey", + session->sessionKey.b.buffer, session->sessionKey.b.size); + rc = TSS_TPM2B_Copy(&session->hmacKey.b, + &session->sessionKey.b, sizeof(TPMU_HA) + sizeof(TPMT_HA)); + } + /* copy the session key to sessionValue */ + if (rc == 0) { + rc = TSS_TPM2B_Copy(&session->sessionValue.b, + &session->sessionKey.b, sizeof(TPMU_HA) + sizeof(TPMT_HA)); + } + if (rc == 0) { + if (tssVverbose) + TSS_PrintAll("TSS_HmacSession_SetHmacKey: preliminary sessionValue", + session->sessionValue.b.buffer, session->sessionValue.b.size); + } + /* This value is an EmptyAuth if the HMAC is being computed to authorize an action on the + object to which the session is bound. + */ + /* The first sessions are authorization sessions. They can have a bind entity. All others can + be encrypt or decrypt sessions, but the authValue is not included in the session key. + */ + if (rc == 0) { + AUTH_ROLE authRole = TSS_GetAuthRole(tssContext->tssAuthContext, handleNumber); + if (authRole == AUTH_NONE) { + if (tssVverbose) printf("TSS_HmacSession_SetHmacKey: Done, not auth session\n"); + done = TRUE; /* not an authorization session, could be audit or + encrypt/decrypt */ + } + } + /* If not an authorization session, there is no authValue to append to the HMAC key or encrypt + sessionValue, regardless of the binding. Below is for auth sessions. */ + if (!done) { + /* First, if there was a bind handle, check if the name matches. Else bindMatch remains + FALSE. */ + if (session->bind != TPM_RH_NULL) { + /* get the handle for this session */ + if (tssVverbose) + printf("TSS_HmacSession_SetHmacKey: Processing bind handle %08x\n", session->bind); + if (rc == 0) { + rc = TSS_GetCommandHandle(tssContext->tssAuthContext, + &commandHandle, + handleNumber); + } + /* get the Name corresponding to the handle */ + if (rc == 0) { + if (tssVverbose) + printf("TSS_HmacSession_SetHmacKey: commandHandle %08x bindHandle %08x\n", + commandHandle, session->bind); + rc = TSS_Name_GetName(tssContext, &name, commandHandle); + } + /* compare the authorized object name to the bind object name */ + if (rc == 0) { + bindMatch = TSS_TPM2B_Compare(&name.b, &session->bindName.b); + if (tssVverbose) printf("TSS_HmacSession_SetHmacKey: bind match %u\n", bindMatch); + } + } + /* Second, append password to session key for HMAC key if required */ + + /* When performing an HMAC for authorization, the HMAC key is normally the concatenation of + the entity's authValue to the sessions sessionKey (created at + TPM2_StartAuthSession(). However, if the authorization is for the entity to + which the session is bound, the authValue is not included in the HMAC key. When + a policy requires that an HMAC be computed, it is always concatenated. + */ + if ((rc == 0) && + /* append if HMAC session and not bind match */ + (((session->sessionType == TPM_SE_HMAC) && !bindMatch) || + /* append if policy and policy authvalue */ + ((session->sessionType == TPM_SE_POLICY) && session->isAuthValueNeeded)) && + (password != NULL) /* if password is NULL, nothing to append. */ + + ) { + + if (tssVverbose) + printf("TSS_HmacSession_SetHmacKey: Appending authValue to HMAC key\n"); + /* convert the password to an authvalue */ + if (rc == 0) { + rc = TSS_TPM2B_StringCopy(&authValue.b, password, sizeof(authValue.t.buffer)); + } + /* append the authvalue to the session key to create the hmac key */ + if (rc == 0) { + rc = TSS_TPM2B_Append(&session->hmacKey.b, &authValue.b, + sizeof(TPMU_HA) + sizeof(TPMT_HA)); + } + } + /* Third, append password to session key for sessionValue + + If a session is also being used for authorization, sessionValue (see 21.2 and 21.3) is + sessionKey || authValue. The binding of the session is ignored. If the session is not + being used for authorization, sessionValue is sessionKey. + */ + /* NOTE This step occurs even if there is a bind match. That is, the password is effectively + appended twice. */ + if (rc == 0) { + /* if not bind, sessionValue is sessionKey || authValue (same as HMAC key) */ + if (!bindMatch) { + if (tssVverbose) + printf("TSS_HmacSession_SetHmacKey: " + "No bind, appending authValue to sessionValue\n"); + /* convert the password to an authvalue */ + if (rc == 0) { + rc = TSS_TPM2B_StringCopy(&authValue.b, password, sizeof(authValue.t.buffer)); + } + if (rc == 0) { + rc = TSS_TPM2B_Append(&session->sessionValue.b, &authValue.b, + sizeof(TPMU_HA) + sizeof(TPMT_HA)); + } + } + /* if bind, sessionValue is sessionKey || bindAuthValue */ + else { + if (tssVverbose) + printf("TSS_HmacSession_SetHmacKey: " + "Bind, appending bind authValue to sessionValue\n"); + if (rc == 0) { + rc = TSS_TPM2B_Append(&session->sessionValue.b, &session->bindAuthValue.b, + sizeof(TPMU_HA) + sizeof(TPMT_HA)); + } + } + if (rc == 0) { + if (tssVverbose) + TSS_PrintAll("TSS_HmacSession_SetHmacKey: bindAuthValue", + session->bindAuthValue.b.buffer, session->bindAuthValue.b.size); + } + } + } + if (rc == 0) { + if (tssVverbose) + TSS_PrintAll("TSS_HmacSession_SetHmacKey: hmacKey", + session->hmacKey.b.buffer, session->hmacKey.b.size); + if (tssVverbose) + TSS_PrintAll("TSS_HmacSession_SetHmacKey: sessionValue", + session->sessionValue.b.buffer, session->sessionValue.b.size); + } + return rc; +} + +#endif /* TPM_TSS_NOCRYPTO */ + +/* TSS_HmacSession_SetHMAC() is used for a command. It sets all the values in one + TPMS_AUTH_COMMAND, ready for marshaling into the command packet. + + - gets cpBuffer + - generates cpHash + - generates the HMAC + - copies the result into authCommand + + Unused names must have size 0. + + The HMAC key is already in the session structure. +*/ + +static TPM_RC TSS_HmacSession_SetHMAC(TSS_AUTH_CONTEXT *tssAuthContext, /* authorization context */ + struct TSS_HMAC_CONTEXT *session[], + TPMS_AUTH_COMMAND *authCommand[], /* output: command + authorization */ + TPMI_SH_AUTH_SESSION sessionHandle[], /* session handles in + command */ + unsigned int sessionAttributes[], /* attributes for this + command */ + const char *password[], + TPM2B_NAME *name0, /* up to 3 names */ + TPM2B_NAME *name1, /* unused names have length 0 */ + TPM2B_NAME *name2) +{ + TPM_RC rc = 0; + unsigned int i = 0; +#ifndef TPM_TSS_NOCRYPTO + TPMT_HA cpHash; + TPMT_HA hmac; + TPM2B_NONCE nonceTPMDecrypt; + TPM2B_NONCE nonceTPMEncrypt; + cpHash.hashAlg = TPM_ALG_NULL; /* for cpHash calculation optimization */ +#endif /* TPM_TSS_NOCRYPTO */ + + + for (i = 0 ; (rc == 0) && (i < MAX_SESSION_NUM) && (sessionHandle[i] != TPM_RH_NULL) ; i++) { + uint8_t sessionAttr8; + if (tssVverbose) printf("TSS_HmacSession_SetHMAC: Step 6 session %08x\n", sessionHandle[i]); + /* password sessions were serviced in step 2. */ + if (sessionHandle[i] == TPM_RS_PW) { + continue; + } + if (tssVverbose) printf("TSS_HmacSession_SetHMAC: sessionType %02x\n", + session[i]->sessionType); + if (tssVverbose) printf("TSS_HmacSession_SetHMAC: isPasswordNeeded %02x\n", + session[i]->isPasswordNeeded); + if (tssVverbose) printf("TSS_HmacSession_SetHMAC: isAuthValueNeeded %02x\n", + session[i]->isAuthValueNeeded); + /* sessionHandle */ + authCommand[i]->sessionHandle = session[i]->sessionHandle; + /* attributes come from command */ + sessionAttr8 = (uint8_t)sessionAttributes[i]; + authCommand[i]->sessionAttributes.val = sessionAttr8; + + /* policy session with policy password handled below, no hmac. isPasswordNeeded is never + true for an HMAC session, so don't need to test session type here. */ + if (!(session[i]->isPasswordNeeded)) { + /* HMAC session */ + if ((session[i]->sessionType == TPM_SE_HMAC) || + /* policy session with TPM2_PolicyAuthValue */ + ((session[i]->sessionType == TPM_SE_POLICY) && (session[i]->isAuthValueNeeded)) || + /* salted session */ + (session[i]->hmacKey.t.size != 0) + ) { + /* needs HMAC */ +#ifndef TPM_TSS_NOCRYPTO + if (tssVverbose) printf("TSS_HmacSession_SetHMAC: calculate HMAC\n"); + /* calculate cpHash. Performance optimization: If there is more than one session, + and the hash algorithm is the same, use the previously calculated version. */ + if ((rc == 0) && (cpHash.hashAlg != session[i]->authHashAlg)) { + uint32_t cpBufferSize; + uint8_t *cpBuffer; + TPM_CC commandCode; + TPM_CC commandCodeNbo; + + rc = TSS_GetCpBuffer(tssAuthContext, + &cpBufferSize, + &cpBuffer); + if (tssVverbose) TSS_PrintAll("TSS_HmacSession_SetHMAC: cpBuffer", + cpBuffer, cpBufferSize); + cpHash.hashAlg = session[i]->authHashAlg; + + /* cpHash = hash(commandCode [ || authName1 */ + /* [ || authName2 */ + /* [ || authName3 ]]] */ + /* [ || parameters]) */ + /* A cpHash can contain just a commandCode only if the lone session is */ + /* an audit session. */ + + commandCode = TSS_GetCommandCode(tssAuthContext); + commandCodeNbo = htonl(commandCode); + rc = TSS_Hash_Generate(&cpHash, /* largest size of a digest */ + sizeof(TPM_CC), &commandCodeNbo, + name0->b.size, &name0->b.buffer, + name1->b.size, &name1->b.buffer, + name2->b.size, &name2->b.buffer, + cpBufferSize, cpBuffer, + 0, NULL); + } + if (i == 0) { + unsigned int isDecrypt = 0; /* count number of sessions with decrypt + set */ + unsigned int decryptSession = 0; /* which one is decrypt */ + unsigned int isEncrypt = 0; /* count number of sessions with decrypt + set */ + unsigned int encryptSession = 0; /* which one is decrypt */ + nonceTPMDecrypt.t.size = 0; + nonceTPMEncrypt.t.size = 0; + /* if a different session is being used for parameter decryption, then the + nonceTPM for that session is included in the HMAC of the first authorization + session */ + if (rc == 0) { + rc = TSS_Sessions_GetDecryptSession(&isDecrypt, + &decryptSession, + sessionHandle, + sessionAttributes); + } + if ((rc == 0) && isDecrypt && (decryptSession != 0)) { + rc = TSS_TPM2B_Copy(&nonceTPMDecrypt.b, + &session[decryptSession]->nonceTPM.b, sizeof(TPMU_HA)); + } + /* if a different session is being used for parameter encryption, then the + nonceTPM for that session is included in the HMAC of the first authorization + session */ + if (rc == 0) { + rc = TSS_Sessions_GetEncryptSession(&isEncrypt, + &encryptSession, + sessionHandle, + sessionAttributes); + } + /* Don't include the same nonce twice */ + if ((rc == 0) && isEncrypt && (encryptSession != 0)) { + if (!isDecrypt || (encryptSession != decryptSession)) { + rc = TSS_TPM2B_Copy(&nonceTPMEncrypt.b, + &session[encryptSession]->nonceTPM.b, + sizeof(TPMU_HA)); + } + } + } + /* for other than the first session, those nonces are not used */ + else { + nonceTPMDecrypt.t.size = 0; + nonceTPMEncrypt.t.size = 0; + } + /* */ + if (rc == 0) { + hmac.hashAlg = session[i]->authHashAlg; + rc = TSS_HMAC_Generate(&hmac, /* output hmac */ + &session[i]->hmacKey, /* input key */ + session[i]->sizeInBytes, (uint8_t *)&cpHash.digest, + /* new is nonceCaller */ + session[i]->nonceCaller.b.size, + &session[i]->nonceCaller.b.buffer, + /* old is previous nonceTPM */ + session[i]->nonceTPM.b.size, + &session[i]->nonceTPM.b.buffer, + /* nonceTPMDecrypt */ + nonceTPMDecrypt.b.size, nonceTPMDecrypt.b.buffer, + /* nonceTPMEncrypt */ + nonceTPMEncrypt.b.size, nonceTPMEncrypt.b.buffer, + /* 1 byte, no endian conversion */ + sizeof(uint8_t), &sessionAttr8, + 0, NULL); + if (tssVverbose) { + TSS_PrintAll("TSS_HmacSession_SetHMAC: HMAC key", + session[i]->hmacKey.t.buffer, session[i]->hmacKey.t.size); + TSS_PrintAll("TSS_HmacSession_SetHMAC: cpHash", + (uint8_t *)&cpHash.digest, session[i]->sizeInBytes); + TSS_PrintAll("TSS_HmacSession_Set: nonceCaller", + session[i]->nonceCaller.b.buffer, + session[i]->nonceCaller.b.size); + TSS_PrintAll("TSS_HmacSession_SetHMAC: nonceTPM", + session[i]->nonceTPM.b.buffer, session[i]->nonceTPM.b.size); + TSS_PrintAll("TSS_HmacSession_SetHMAC: nonceTPMDecrypt", + nonceTPMDecrypt.b.buffer, nonceTPMDecrypt.b.size); + TSS_PrintAll("TSS_HmacSession_SetHMAC: nonceTPMEncrypt", + nonceTPMEncrypt.b.buffer, nonceTPMEncrypt.b.size); + TSS_PrintAll("TSS_HmacSession_SetHMAC: sessionAttributes", + &sessionAttr8, sizeof(uint8_t)); + TSS_PrintAll("TSS_HmacSession_SetHMAC: HMAC", + (uint8_t *)&hmac.digest, session[i]->sizeInBytes); + } + } + /* copy HMAC into authCommand TPM2B_AUTH hmac */ + if (rc == 0) { + rc = TSS_TPM2B_Create(&authCommand[i]->hmac.b, + (uint8_t *)&hmac.digest, + session[i]->sizeInBytes, + sizeof(authCommand[i]->hmac.t.buffer)); + } +#else + tssAuthContext = tssAuthContext; + name0 = name0; + name1 = name1; + name2 = name2; + if (tssVerbose) + printf("TSS_HmacSession_SetHMAC: Error, with no crypto not implemented\n"); + rc = TSS_RC_NOT_IMPLEMENTED; +#endif /* TPM_TSS_NOCRYPTO */ + } + /* not HMAC, not policy requiring password or hmac */ + else { + authCommand[i]->hmac.b.size = 0; + } + } + /* For a policy session that contains TPM2_PolicyPassword(), the password takes precedence + and must be present in hmac. */ + else { /* isPasswordNeeded true */ + if (tssVverbose) printf("TSS_HmacSession_SetHMAC: use password\n"); + /* nonce has already been set */ + rc = TSS_TPM2B_StringCopy(&authCommand[i]->hmac.b, + password[i], sizeof(authCommand[i]->hmac.t.buffer)); + } + } + return rc; +} + + +#ifndef TPM_TSS_NOCRYPTO + +/* TSS_HmacSession_Verify() is used for a response. It uses the values in TPMS_AUTH_RESPONSE to + validate the response HMAC +*/ + +static TPM_RC TSS_HmacSession_Verify(TSS_AUTH_CONTEXT *tssAuthContext, /* authorization context */ + struct TSS_HMAC_CONTEXT *session, /* TSS session context */ + TPMS_AUTH_RESPONSE *authResponse) /* input: response authorization */ +{ + TPM_RC rc = 0; + uint32_t rpBufferSize; + uint8_t *rpBuffer; + TPMT_HA rpHash; + TPMT_HA actualHmac; + + /* get the rpBuffer */ + if (rc == 0) { + rc = TSS_GetRpBuffer(tssAuthContext, &rpBufferSize, &rpBuffer); + if (tssVverbose) TSS_PrintAll("TSS_HmacSession_Verify: rpBuffer", + rpBuffer, rpBufferSize); + } + /* calculate rpHash */ + if (rc == 0) { + TPM_CC commandCode; + TPM_CC commandCodeNbo; + rpHash.hashAlg = session->authHashAlg; + + commandCode = TSS_GetCommandCode(tssAuthContext); + commandCodeNbo = htonl(commandCode); + + /* rpHash = HsessionAlg (responseCode || commandCode {|| parameters }) */ + rc = TSS_Hash_Generate(&rpHash, /* largest size of a digest */ + sizeof(TPM_RC), &rc, /* RC is always 0, no need to endian + convert */ + sizeof(TPM_CC), &commandCodeNbo, + rpBufferSize, rpBuffer, + 0, NULL); + } + /* construct the actual HMAC as TPMT_HA */ + if (rc == 0) { + actualHmac.hashAlg = session->authHashAlg; + if (authResponse->hmac.t.size != session->sizeInBytes) { + if (tssVerbose) + printf("TSS_HmacSession_Verify: HMAC size %u inconsistent with algorithm %u\n", + authResponse->hmac.t.size, session->sizeInBytes); + rc = TSS_RC_HMAC_SIZE; + } + } + if (rc == 0) { + memcpy((uint8_t *)&actualHmac.digest, &authResponse->hmac.t.buffer, + authResponse->hmac.t.size); + } + /* verify the HMAC */ + if (rc == 0) { + if (tssVverbose) { + TSS_PrintAll("TSS_HmacSession_Verify: HMAC key", + session->hmacKey.t.buffer, session->hmacKey.t.size); + TSS_PrintAll("TSS_HmacSession_Verify: rpHash", + (uint8_t *)&rpHash.digest, session->sizeInBytes); + TSS_PrintAll("TSS_HmacSession_Verify: nonceTPM", + session->nonceTPM.b.buffer, session->nonceTPM.b.size); + TSS_PrintAll("TSS_HmacSession_Verify: nonceCaller", + session->nonceCaller.b.buffer, session->nonceCaller.b.size); + TSS_PrintAll("TSS_HmacSession_Verify: sessionAttributes", + &authResponse->sessionAttributes.val, sizeof(uint8_t)); + TSS_PrintAll("TSS_HmacSession_Verify: response HMAC", + (uint8_t *)&authResponse->hmac.t.buffer, session->sizeInBytes); + } + rc = TSS_HMAC_Verify(&actualHmac, /* input response hmac */ + &session->hmacKey, /* input HMAC key */ + session->sizeInBytes, + /* rpHash */ + session->sizeInBytes, (uint8_t *)&rpHash.digest, + /* new is nonceTPM */ + session->nonceTPM.b.size, &session->nonceTPM.b.buffer, + /* old is nonceCaller */ + session->nonceCaller.b.size, &session->nonceCaller.b.buffer, + /* 1 byte, no endian conversion */ + sizeof(uint8_t), &authResponse->sessionAttributes.val, + 0, NULL); + } + return rc; +} + +#endif /* TPM_TSS_NOCRYPTO */ + +/* TSS_HmacSession_Continue() handles the response continueSession flag. It either saves the + updated session or deletes the session state. */ + +static TPM_RC TSS_HmacSession_Continue(TSS_CONTEXT *tssContext, + struct TSS_HMAC_CONTEXT *session, + TPMS_AUTH_RESPONSE *authR) +{ + TPM_RC rc = 0; + + if (rc == 0) { + /* if continue set */ + if (authR->sessionAttributes.val & TPMA_SESSION_CONTINUESESSION) { + /* clear the policy flags in preparation for the next use */ + session->isPasswordNeeded = FALSE; + session->isAuthValueNeeded = FALSE; + /* save the session */ + rc = TSS_HmacSession_SaveSession(tssContext, session); + } + else { /* continue clear */ + /* delete the session state */ + rc = TSS_DeleteHandle(tssContext, session->sessionHandle); + } + } + return rc; +} + +/* TSS_Sessions_GetDecryptSession() searches for a command decrypt session. If found, returns + isDecrypt TRUE, and the session number in decryptSession. + +*/ + +static TPM_RC TSS_Sessions_GetDecryptSession(unsigned int *isDecrypt, + unsigned int *decryptSession, + TPMI_SH_AUTH_SESSION sessionHandle[], + unsigned int sessionAttributes[]) +{ + TPM_RC rc = 0; + unsigned int i = 0; + + /* count the number of command decrypt sessions */ + *isDecrypt = 0; /* number of sessions with decrypt set */ + for (i = 0 ; (rc == 0) && (i < MAX_SESSION_NUM) && + (sessionHandle[i] != TPM_RH_NULL) && + (sessionHandle[i] != TPM_RS_PW) ; + i++) { + if (sessionAttributes[i] & TPMA_SESSION_DECRYPT) { + (*isDecrypt)++; /* count number of decrypt sessions */ + *decryptSession = i; /* record which one it was */ + } + } + /* how many decrypt sessions were found */ + if (rc == 0) { + if (tssVverbose) printf("TSS_Sessions_GetDecryptSession: Found %u decrypt sessions at %u\n", + *isDecrypt, *decryptSession); + if (*isDecrypt > 1) { + if (tssVerbose) + printf("TSS_Sessions_GetDecryptSession: Error, found %u decrypt sessions\n", + *isDecrypt); + rc = TSS_RC_DECRYPT_SESSIONS; + } + } + return rc; +} + +/* TSS_Sessions_GetEncryptSession() searches for a response encrypt session. If found, returns + isEncrypt TRUE, and the session number in encryptSession. + +*/ + +static TPM_RC TSS_Sessions_GetEncryptSession(unsigned int *isEncrypt, + unsigned int *encryptSession, + TPMI_SH_AUTH_SESSION sessionHandle[], + unsigned int sessionAttributes[]) +{ + TPM_RC rc = 0; + unsigned int i = 0; + + /* count the number of command encrypt sessions */ + *isEncrypt = 0; /* number of sessions with encrypt set */ + for (i = 0 ; (rc == 0) && (i < MAX_SESSION_NUM) && + (sessionHandle[i] != TPM_RH_NULL) && + (sessionHandle[i] != TPM_RS_PW) ; + i++) { + if (sessionAttributes[i] & TPMA_SESSION_ENCRYPT) { + (*isEncrypt)++; /* count number of encrypt sessions */ + *encryptSession = i; /* record which one it was */ + } + } + /* how many encrypt sessions were found */ + if (rc == 0) { + if (tssVverbose) printf("TSS_Sessions_GetEncryptSession: Found %u encrypt sessions at %u\n", + *isEncrypt, *encryptSession); + if (*isEncrypt > 1) { + if (tssVerbose) + printf("TSS_Sessions_GetEncryptSession: Error, found %u encrypt sessions\n", + *isEncrypt); + rc = TSS_RC_ENCRYPT_SESSIONS; + } + } + return rc; +} + +/* TSS_Command_Decrypt() determines whether any sessions are command decrypt sessions. If so, it + encrypts the first command parameter. + + It does common error checking, then calls algorithm specific functions. + +*/ + +static TPM_RC TSS_Command_Decrypt(TSS_AUTH_CONTEXT *tssAuthContext, + struct TSS_HMAC_CONTEXT *session[], + TPMI_SH_AUTH_SESSION sessionHandle[], + unsigned int sessionAttributes[]) +{ + TPM_RC rc = 0; + unsigned int isDecrypt = 0; /* count number of sessions with decrypt set */ + unsigned int decryptSession = 0; /* which session is decrypt */ + + /* determine if there is a decrypt session */ + if (rc == 0) { + rc = TSS_Sessions_GetDecryptSession(&isDecrypt, + &decryptSession, + sessionHandle, + sessionAttributes); + } +#ifndef TPM_TSS_NOCRYPTO + { + COMMAND_INDEX tpmCommandIndex; /* index into TPM table */ + TPM_CC commandCode; + int decryptSize; /* size of TPM2B size, 2 if there is a TPM2B, 0 if + not */ + uint32_t paramSize; /* size of the parameter to encrypt */ + uint8_t *decryptParamBuffer; + /* can the command parameter be encrypted */ + if ((rc == 0) && isDecrypt) { + /* get the commandCode, stored in TSS during marshal */ + commandCode = TSS_GetCommandCode(tssAuthContext); + /* get the index into the TPM command attributes table */ + tpmCommandIndex = CommandCodeToCommandIndex(commandCode); + /* can this be a decrypt command (this is size of TPM2B size, not size of parameter) */ + decryptSize = getDecryptSize(tpmCommandIndex); + if (decryptSize != 2) { /* only handle TPM2B */ + printf("TSS_Command_Decrypt: Error, command cannot be encrypted\n"); + rc = TSS_RC_NO_DECRYPT_PARAMETER; + } + } + /* get the TPM2B parameter to encrypt */ + if ((rc == 0) && isDecrypt) { + rc = TSS_GetCommandDecryptParam(tssAuthContext, ¶mSize, &decryptParamBuffer); + } + /* if the size of the parameter to encrypt is zero, nothing to encrypt */ + if ((rc == 0) && isDecrypt) { + if (paramSize == 0) { + isDecrypt = FALSE; /* none, done with this function */ + } + } + /* error checking complete, do the encryption */ + if ((rc == 0) && isDecrypt) { + switch (session[decryptSession]->symmetric.algorithm) { + case TPM_ALG_XOR: + rc = TSS_Command_DecryptXor(tssAuthContext, session[decryptSession]); + break; + case TPM_ALG_AES: + rc = TSS_Command_DecryptAes(tssAuthContext, session[decryptSession]); + break; + default: + if (tssVerbose) printf("TSS_Command_Decrypt: Error, algorithm %04x not implemented\n", + session[decryptSession]->symmetric.algorithm); + rc = TSS_RC_BAD_DECRYPT_ALGORITHM; + break; + } + } + } +#else + tssAuthContext = tssAuthContext; + session = session; + if ((rc == 0) && isDecrypt) { + if (tssVerbose) + printf("TSS_Command_Decrypt: Error, with no crypto not implemented\n"); + rc = TSS_RC_NOT_IMPLEMENTED; + } +#endif + return rc; +} + +#ifndef TPM_TSS_NOCRYPTO + +/* NOTE: if AES also works, do in place encryption */ + +static TPM_RC TSS_Command_DecryptXor(TSS_AUTH_CONTEXT *tssAuthContext, + struct TSS_HMAC_CONTEXT *session) +{ + TPM_RC rc = 0; + unsigned int i; + uint32_t paramSize; + uint8_t *decryptParamBuffer; + uint8_t *mask = NULL; + uint8_t *encryptParamBuffer = NULL; + + /* get the TPM2B parameter to encrypt */ + if (rc == 0) { + rc = TSS_GetCommandDecryptParam(tssAuthContext, ¶mSize, &decryptParamBuffer); + } + if (rc == 0) { + if (tssVverbose) TSS_PrintAll("TSS_Command_DecryptXor: decrypt in", + decryptParamBuffer, paramSize); + } + if (rc == 0) { + rc = TSS_Malloc(&mask, paramSize); + } + if (rc == 0) { + rc = TSS_Malloc(&encryptParamBuffer, paramSize); + } + /* generate the XOR pad */ + /* 21.2 XOR Parameter Obfuscation + + XOR(parameter, hashAlg, sessionValue, nonceNewer, nonceOlder) + + parameter a variable sized buffer containing the parameter to be obfuscated + hashAlg the hash algorithm associated with the session + sessionValue the session-specific HMAC key + nonceNewer for commands, this will be nonceCaller and for responses it will be nonceTPM + nonceOlder for commands, this will be nonceTPM and for responses it will be nonceCaller + + 11.4.6.3 XOR Obfuscation + + XOR(data, hashAlg, key, contextU, contextV) + + mask = KDFa (hashAlg, key, "XOR", contextU, contextV, data.size * 8) + */ + /* KDFa for the XOR mask */ + if (rc == 0) { + if (tssVverbose) printf("TSS_Command_DecryptXor: hashAlg %04x\n", session->authHashAlg); + if (tssVverbose) printf("TSS_Command_DecryptXor: sizeInBits %04x\n", paramSize * 8); + if (tssVverbose) + TSS_PrintAll("TSS_Command_DecryptXor: sessionKey", + session->sessionKey.b.buffer, session->sessionKey.b.size); + if (tssVverbose) + TSS_PrintAll("TSS_Command_DecryptXor: sessionValue", + session->sessionValue.b.buffer, session->sessionValue.b.size); + rc = TSS_KDFA(mask, + session->authHashAlg, + &session->sessionValue.b, + "XOR", + &session->nonceCaller.b, + &session->nonceTPM.b, + paramSize * 8); + } + if (rc == 0) { + if (tssVverbose) TSS_PrintAll("TSS_Command_DecryptXor: mask", + mask, paramSize); + } + /* XOR */ + for (i = 0 ; (rc == 0) && (i < paramSize ) ; i++) { + encryptParamBuffer[i] = decryptParamBuffer[i] ^ mask[i]; + } + if (rc == 0) { + rc = TSS_SetCommandDecryptParam(tssAuthContext, paramSize, encryptParamBuffer); + } + if (rc == 0) { + if (tssVverbose) TSS_PrintAll("TSS_Command_DecryptXor: encrypt out", + encryptParamBuffer, paramSize); + } + free(mask); + free(encryptParamBuffer); + return rc; +} + +#endif /* TPM_TSS_NOCRYPTO */ + +#ifndef TPM_TSS_NOCRYPTO + +/* NOTE: if AES also works, do in place encryption */ + +static TPM_RC TSS_Command_DecryptAes(TSS_AUTH_CONTEXT *tssAuthContext, + struct TSS_HMAC_CONTEXT *session) +{ + TPM_RC rc = 0; + uint32_t paramSize; + uint8_t *decryptParamBuffer; + uint8_t *encryptParamBuffer = NULL; + TPM2B_IV iv; + uint32_t kdfaBits; + uint16_t keySizeinBytes; + uint8_t symParmString[MAX_SYM_KEY_BYTES + MAX_SYM_BLOCK_SIZE]; /* AES key + IV */ + + /* get the TPM2B parameter to encrypt */ + if (rc == 0) { + rc = TSS_GetCommandDecryptParam(tssAuthContext, ¶mSize, &decryptParamBuffer); + } + if (rc == 0) { + if (tssVverbose) TSS_PrintAll("TSS_Command_DecryptAes: decrypt in", + decryptParamBuffer, paramSize); + } + if (rc == 0) { + rc = TSS_Malloc(&encryptParamBuffer, paramSize); /* free @1 */ + } + /* generate the encryption key and IV */ + /* 21.3 CFB Mode Parameter Encryption + + KDFa (hashAlg, sessionValue, "CFB", nonceNewer, nonceOlder, bits) (34) + + hashAlg the hash algorithm associated with the session + sessionValue the session-specific HMAC key + "CFB" label to differentiate use of KDFa() (see 4.2) + nonceNewer nonceCaller for a command and nonceTPM for a response + nonceOlder nonceTPM for a command and nonceCaller for a response + bits the number of bits required for the symmetric key plus an IV + */ + if (rc == 0) { + iv.t.size = TSS_Sym_GetBlockSize(session->symmetric.algorithm, + session->symmetric.keyBits.aes); + /* generate random values for both the AES key and the IV */ + kdfaBits = session->symmetric.keyBits.aes + (iv.t.size * 8); + + if (tssVverbose) printf("TSS_Command_DecryptAes: hashAlg %04x\n", + session->authHashAlg); + if (tssVverbose) printf("TSS_Command_DecryptAes: AES key bits %u\n", + session->symmetric.keyBits.aes); + if (tssVverbose) printf("TSS_Command_DecryptAes: kdfaBits %04x\n", + kdfaBits); + if (tssVverbose) TSS_PrintAll("TSS_Command_DecryptAes: session key", + session->sessionKey.b.buffer, session->sessionKey.b.size); + + rc = TSS_KDFA(&symParmString[0], + session->authHashAlg, + &session->sessionValue.b, + "CFB", + &session->nonceCaller.b, + &session->nonceTPM.b, + kdfaBits); + } + /* copy the latter part of the kdf output to the IV */ + if (rc == 0) { + keySizeinBytes = session->symmetric.keyBits.aes / 8; + memcpy(iv.t.buffer, &symParmString[keySizeinBytes], iv.t.size); + if (tssVverbose) TSS_PrintAll("TSS_Command_DecryptAes: IV", + iv.t.buffer, iv.t.size); + } + /* AES CFB encrypt the command */ + if (rc == 0) { + TPM_RC crc; + crc = TSS_AES_EncryptCFB(encryptParamBuffer, /* output */ + session->symmetric.keyBits.aes, /* 128 */ + symParmString, /* key */ + iv.t.buffer, /* IV */ + paramSize, /* length */ + (uint8_t *)decryptParamBuffer); /* input */ + if (crc != 0) { + if (tssVerbose) printf("TSS_Command_DecryptAes: AES encrypt failed\n"); + rc = TSS_RC_AES_ENCRYPT_FAILURE; + } + } + if (rc == 0) { + if (tssVverbose) TSS_PrintAll("TSS_Command_DecryptAes: encrypt out", + encryptParamBuffer, paramSize); + } + if (rc == 0) { + rc = TSS_SetCommandDecryptParam(tssAuthContext, paramSize, encryptParamBuffer); + } + free(encryptParamBuffer); /* @1 */ + return rc; +} + +#endif /* TPM_TSS_NOCRYPTO */ + +static TPM_RC TSS_Response_Encrypt(TSS_AUTH_CONTEXT *tssAuthContext, + struct TSS_HMAC_CONTEXT *session[], + TPMI_SH_AUTH_SESSION sessionHandle[], + unsigned int sessionAttributes[]) +{ + TPM_RC rc = 0; + unsigned int isEncrypt = 0; /* count number of sessions with decrypt set */ + unsigned int encryptSession = 0; /* which one is decrypt */ + + /* determine if there is an encrypt session */ + if (rc == 0) { + rc = TSS_Sessions_GetEncryptSession(&isEncrypt, + &encryptSession, + sessionHandle, + sessionAttributes); + } +#ifndef TPM_TSS_NOCRYPTO + { + COMMAND_INDEX tpmCommandIndex; /* index into TPM table */ + TPM_CC commandCode; + int encryptSize; /* size of TPM2B size, 2 if there is a TPM2B, 0 if + not */ + uint32_t paramSize; /* size of the parameter to decrypt */ + uint8_t *encryptParamBuffer; + /* can the response parameter be decrypted */ + if ((rc == 0) && isEncrypt) { + /* get the commandCode, stored in TSS during marshal */ + commandCode = TSS_GetCommandCode(tssAuthContext); + /* get the index into the TPM command attributes table */ + tpmCommandIndex = CommandCodeToCommandIndex(commandCode); + /* can this be a decrypt command */ + encryptSize = getEncryptSize(tpmCommandIndex); + if (encryptSize == 0) { + if (tssVerbose) printf("TSS_Response_Encrypt: Error, response cannot be encrypted\n"); + rc = TSS_RC_NO_ENCRYPT_PARAMETER; + } + } + /* get the TPM2B parameter to decrypt */ + if ((rc == 0) && isEncrypt) { + rc = TSS_GetResponseEncryptParam(tssAuthContext, ¶mSize, &encryptParamBuffer); + } + /* if the size of the parameter to decrypt is zero, nothing to decrypt */ + if ((rc == 0) && isEncrypt) { + if (paramSize == 0) { + isEncrypt = FALSE; /* none, done with this function */ + } + } + /* error checking complete, do the decryption */ + if ((rc == 0) && isEncrypt) { + switch (session[encryptSession]->symmetric.algorithm) { + case TPM_ALG_XOR: + rc = TSS_Response_EncryptXor(tssAuthContext, session[encryptSession]); + break; + case TPM_ALG_AES: + rc = TSS_Response_EncryptAes(tssAuthContext, session[encryptSession]); + break; + default: + if (tssVerbose) printf("TSS_Response_Encrypt: Error, algorithm %04x not implemented\n", + session[encryptSession]->symmetric.algorithm); + rc = TSS_RC_BAD_ENCRYPT_ALGORITHM; + break; + } + } + } +#else + tssAuthContext = tssAuthContext; + session = session; + if ((rc == 0) && isEncrypt) { + if (tssVerbose) + printf("TSS_Response_Encrypt: Error, with no crypto not implemented\n"); + rc = TSS_RC_NOT_IMPLEMENTED; + } +#endif + return rc; +} + +#ifndef TPM_TSS_NOCRYPTO + +/* NOTE: if CFB also works, do in place decryption */ + +static TPM_RC TSS_Response_EncryptXor(TSS_AUTH_CONTEXT *tssAuthContext, + struct TSS_HMAC_CONTEXT *session) +{ + TPM_RC rc = 0; + unsigned int i; + uint32_t paramSize; + uint8_t *encryptParamBuffer; + uint8_t *mask = NULL; + uint8_t *decryptParamBuffer = NULL; + + /* get the TPM2B parameter to decrypt */ + if (rc == 0) { + rc = TSS_GetResponseEncryptParam(tssAuthContext, + ¶mSize, &encryptParamBuffer); + } + if (rc == 0) { + if (tssVverbose) TSS_PrintAll("TSS_Response_EncryptXor: encrypt in", + encryptParamBuffer, paramSize); + } + if (rc == 0) { + rc = TSS_Malloc(&mask, paramSize); /* freed @1 */ + } + if (rc == 0) { + rc = TSS_Malloc(&decryptParamBuffer, paramSize); /* freed @2 */ + } + /* generate the XOR pad */ + /* 21.2 XOR Parameter Obfuscation + + XOR(parameter, hashAlg, sessionValue, nonceNewer, nonceOlder) + + parameter a variable sized buffer containing the parameter to be obfuscated + hashAlg the hash algorithm associated with the session + sessionValue the session-specific HMAC key + nonceNewer for commands, this will be nonceCaller and for responses it will be nonceTPM + nonceOlder for commands, this will be nonceTPM and for responses it will be nonceCaller + + + 11.4.6.3 XOR Obfuscation + + XOR(data, hashAlg, key, contextU, contextV) + + mask = KDFa (hashAlg, key, "XOR", contextU, contextV, data.size * 8) + */ + /* KDFa for the XOR mask */ + if (rc == 0) { + if (tssVverbose) printf("TSS_Response_EncryptXor: hashAlg %04x\n", session->authHashAlg); + if (tssVverbose) printf("TSS_Response_EncryptXor: sizeInBits %04x\n", paramSize * 8); + if (tssVverbose) TSS_PrintAll("TSS_Response_EncryptXor: session key", + session->sessionKey.b.buffer, session->sessionKey.b.size); + rc = TSS_KDFA(mask, + session->authHashAlg, + &session->sessionValue.b, + "XOR", + &session->nonceTPM.b, + &session->nonceCaller.b, + paramSize * 8); + } + if (rc == 0) { + if (tssVverbose) TSS_PrintAll("TSS_Response_EncryptXor: mask", + mask, paramSize); + } + /* XOR */ + for (i = 0 ; (rc == 0) && (i < paramSize ) ; i++) { + decryptParamBuffer[i] = encryptParamBuffer[i] ^ mask[i]; + } + if (rc == 0) { + if (tssVverbose) TSS_PrintAll("TSS_Response_EncryptXor: decrypt out", + decryptParamBuffer, paramSize); + } + if (rc == 0) { + rc = TSS_SetResponseDecryptParam(tssAuthContext, + paramSize, decryptParamBuffer); + } + free(mask); /* @1 */ + free(decryptParamBuffer); /* @2 */ + return rc; +} + +#endif /* TPM_TSS_NOCRYPTO */ + +#ifndef TPM_TSS_NOCRYPTO + +/* NOTE: if CFB also works, do in place decryption */ + +static TPM_RC TSS_Response_EncryptAes(TSS_AUTH_CONTEXT *tssAuthContext, + struct TSS_HMAC_CONTEXT *session) +{ + TPM_RC rc = 0; + uint32_t paramSize; + uint8_t *encryptParamBuffer; + uint8_t *decryptParamBuffer = NULL; + TPM2B_IV iv; + uint32_t kdfaBits; + uint16_t keySizeinBytes; + uint8_t symParmString[MAX_SYM_KEY_BYTES + MAX_SYM_BLOCK_SIZE]; /* AES key + IV */ + + /* get the TPM2B parameter to decrypt */ + if (rc == 0) { + rc = TSS_GetResponseEncryptParam(tssAuthContext, + ¶mSize, &encryptParamBuffer); + } + if (rc == 0) { + if (tssVverbose) TSS_PrintAll("TSS_Response_EncryptAes: encrypt in", + encryptParamBuffer, paramSize); + } + if (rc == 0) { + rc = TSS_Malloc(&decryptParamBuffer, paramSize); /* freed @1 */ + } + /* generate the encryption key and IV */ + /* 21.3 CFB Mode Parameter Encryption + + KDFa (hashAlg, sessionValue, "CFB", nonceNewer, nonceOlder, bits) (34) + */ + if (rc == 0) { + + iv.t.size = TSS_Sym_GetBlockSize(session->symmetric.algorithm, + session->symmetric.keyBits.aes); + /* generate random values for both the AES key and the IV */ + kdfaBits = session->symmetric.keyBits.aes + (iv.t.size * 8); + + if (tssVverbose) printf("TSS_Response_EncryptAes: hashAlg %04x\n", + session->authHashAlg); + if (tssVverbose) printf("TSS_Response_EncryptAes: AES key bits %u\n", + session->symmetric.keyBits.aes); + if (tssVverbose) printf("TSS_Response_EncryptAes: kdfaBits %04x\n", + kdfaBits); + if (tssVverbose) TSS_PrintAll("TSS_Response_EncryptAes: session key", + session->sessionKey.b.buffer, session->sessionKey.b.size); + + rc = TSS_KDFA(&symParmString[0], + session->authHashAlg, + &session->sessionValue.b, + "CFB", + &session->nonceTPM.b, + &session->nonceCaller.b, + kdfaBits); + } + /* copy the latter part of the kdf output to the IV */ + if (rc == 0) { + keySizeinBytes = session->symmetric.keyBits.aes / 8; + memcpy(iv.t.buffer, &symParmString[keySizeinBytes], iv.t.size); + if (tssVverbose) TSS_PrintAll("TSS_Response_EncryptAes: IV", + iv.t.buffer, iv.t.size); + } + /* AES CFB decrypt the response */ + if (rc == 0) { + TPM_RC crc; + crc = TSS_AES_DecryptCFB(decryptParamBuffer, /* output */ + session->symmetric.keyBits.aes, /* 128 */ + symParmString, /* key */ + iv.t.buffer, /* IV */ + paramSize, /* length */ + (uint8_t *)encryptParamBuffer); /* input */ + if (crc != 0) { + if (tssVerbose) printf("TSS_Response_EncryptAes: AES decrypt failed\n"); + rc = TSS_RC_AES_DECRYPT_FAILURE; + } + } + if (rc == 0) { + if (tssVverbose) TSS_PrintAll("TSS_Response_EncryptAes: decrypt out", + decryptParamBuffer, paramSize); + } + if (rc == 0) { + rc = TSS_SetResponseDecryptParam(tssAuthContext, + paramSize, decryptParamBuffer); + } + free(decryptParamBuffer); /* @1 */ + return rc; +} + +#endif /* TPM_TSS_NOCRYPTO */ + +/* + Command Change Authorization Processor +*/ + +#ifndef TPM_TSS_NOCRYPTO + +static TPM_RC TSS_Command_ChangeAuthProcessor(TSS_CONTEXT *tssContext, + struct TSS_HMAC_CONTEXT *session, + size_t handleNumber, + COMMAND_PARAMETERS *in) +{ + TPM_RC rc = 0; + size_t index; + int found; + TSS_ChangeAuthFunction_t changeAuthFunction = NULL; + + TPM_CC commandCode = TSS_GetCommandCode(tssContext->tssAuthContext); + + /* search the table for a change authorization processing function */ + if (rc == 0) { + found = FALSE; + for (index = 0 ; (index < (sizeof(tssTable) / sizeof(TSS_TABLE))) && !found ; index++) { + if (tssTable[index].commandCode == commandCode) { + found = TRUE; + break; /* don't increment index if found */ + } + } + } + /* found false means there is no change authorization function. This permits the table to be + smaller if desired. */ + if ((rc == 0) && found) { + changeAuthFunction = tssTable[index].changeAuthFunction; + /* there could also be an entry that is currently NULL, nothing to do */ + if (changeAuthFunction == NULL) { + found = FALSE; + } + } + /* call the processing function */ + if ((rc == 0) && found) { + rc = changeAuthFunction(tssContext, session, handleNumber, in); + } + return rc; +} + +#endif /* TPM_TSS_NOCRYPTO */ + +static TPM_RC TSS_CA_HierarchyChangeAuth(TSS_CONTEXT *tssContext, + struct TSS_HMAC_CONTEXT *session, + size_t handleNumber, + HierarchyChangeAuth_In *in) +{ + TPM_RC rc = 0; + char *password = NULL; + + if (tssVverbose) printf("TSS_CA_HierarchyChangeAuth\n"); + if (in->newAuth.t.size == 0) { + password = NULL; + } + else { + if (rc == 0) { + rc = TSS_Malloc((uint8_t **)&password, /* freed @1 */ + in->newAuth.t.size + 1); + } + if (rc == 0) { + /* copy the password */ + memcpy(password, in->newAuth.t.buffer, in->newAuth.t.size); + password[in->newAuth.t.size] = '\0'; /* nul terminate string */ + } + } +#ifndef TPM_TSS_NOCRYPTO + if (rc == 0) { + rc = TSS_HmacSession_SetHmacKey(tssContext, + session, + handleNumber, + password); + } +#else + tssContext = tssContext; + session = session; + handleNumber = handleNumber; +#endif /* TPM_TSS_NOCRYPTO */ + free(password); /* @1 */ + return rc; +} + +static TPM_RC TSS_CA_NV_ChangeAuth(TSS_CONTEXT *tssContext, + struct TSS_HMAC_CONTEXT *session, + size_t handleNumber, + NV_ChangeAuth_In *in) +{ + TPM_RC rc = 0; + char *password = NULL; + + if (tssVverbose) printf("TSS_CA_NV_ChangeAuth\n"); + if (in->newAuth.t.size == 0) { + password = NULL; + } + else { + if (rc == 0) { + rc = TSS_Malloc((uint8_t **)&password, /* freed @1 */ + in->newAuth.t.size + 1); + } + if (rc == 0) { + /* copy the password */ + memcpy(password, in->newAuth.t.buffer, in->newAuth.t.size); + password[in->newAuth.t.size] = '\0'; /* nul terminate string */ + } + } +#ifndef TPM_TSS_NOCRYPTO + if (rc == 0) { + rc = TSS_HmacSession_SetHmacKey(tssContext, + session, + handleNumber, + password); + } +#else + tssContext = tssContext; + session = session; + handleNumber = handleNumber; +#endif /* TPM_TSS_NOCRYPTO */ + free(password); /* @1 */ + return rc; +} + +static TPM_RC TSS_CA_NV_UndefineSpaceSpecial(TSS_CONTEXT *tssContext, + struct TSS_HMAC_CONTEXT *session, + size_t handleNumber, + NV_UndefineSpaceSpecial_In *in) +{ + TPM_RC rc = 0; + + in = in; + if (tssVverbose) printf("TSS_CA_NV_UndefineSpaceSpecial\n"); +#ifndef TPM_TSS_NOCRYPTO + if (rc == 0) { + /* the nvIndex authorization, the zeroth authorization, has special handling */ + if (handleNumber == 0) { + /* the Empty Buffer is used as the authValue when generating the response HMAC */ + rc = TSS_HmacSession_SetHmacKey(tssContext, + session, + handleNumber, + NULL); /* password */ + } + } +#else + tssContext = tssContext; + session = session; + handleNumber = handleNumber; +#endif /* TPM_TSS_NOCRYPTO */ + return rc; +} + +/* + Command Pre-Processor +*/ + +static TPM_RC TSS_Command_PreProcessor(TSS_CONTEXT *tssContext, + TPM_CC commandCode, + COMMAND_PARAMETERS *in, + EXTRA_PARAMETERS *extra) +{ + TPM_RC rc = 0; + size_t index; + int found; + TSS_PreProcessFunction_t preProcessFunction = NULL; + /* search the table for a pre-processing function */ + if (rc == 0) { + found = FALSE; + for (index = 0 ; (index < (sizeof(tssTable) / sizeof(TSS_TABLE))) && !found ; index++) { + if (tssTable[index].commandCode == commandCode) { + found = TRUE; + break; /* don't increment index if found */ + } + } + } + /* found false means there is no pre-processing function. This permits the table to be smaller + if desired. */ + if ((rc == 0) && found) { + preProcessFunction = tssTable[index].preProcessFunction; + /* call the pre processing function if there is one */ + if (preProcessFunction != NULL) { + rc = preProcessFunction(tssContext, in, extra); + } + } +#ifndef TPM_TSS_NO_PRINT + if ((rc == 0) && tssVverbose) { + found = FALSE; + for (index = 0 ; + (index < (sizeof(tssPrintTable) / sizeof(TSS_PRINT_TABLE))) && !found ; + index++) { + if (tssPrintTable[index].commandCode == commandCode) { + found = TRUE; + break; /* don't increment index if found */ + } + } + } + /* found false means there is no print function. This permits the table to be smaller + if desired. */ + if ((rc == 0) && tssVverbose && found) { + TSS_InPrintFunction_t inPrintFunction = tssPrintTable[index].inPrintFunction; + /* call the pre processing function if there is one */ + if (inPrintFunction != NULL) { + printf("TSS_Command_PreProcessor: Input parameters\n"); + inPrintFunction(in, 8); /* hard code indent 8 */ + } + } +#endif /* TPM_TSS_NO_PRINT */ + return rc; +} + +/* + Command specific pre processing functions +*/ + +/* TSS_PR_StartAuthSession handles StartAuthSession pre processing. + + If the salt key in->tpmKey is not NULL and an RSA key, the preprocessor supplies the encrypted + salt. It passes the unencrypted salt to the post processor for session key processing. + + An input salt (encrypted or unencrypted) is ignored. + + Returns an error if the key is not an RSA key. +*/ + +static TPM_RC TSS_PR_StartAuthSession(TSS_CONTEXT *tssContext, + StartAuthSession_In *in, + StartAuthSession_Extra *extra) +{ + TPM_RC rc = 0; + + if (tssVverbose) printf("TSS_PR_StartAuthSession\n"); + + /* if (tssVverbose) StartAuthSession_In_Print(in, 8); */ + +#ifndef TPM_TSS_NOCRYPTO + /* generate nonceCaller */ + if (rc == 0) { + /* the size is determined by the session hash algorithm */ + in->nonceCaller.t.size = TSS_GetDigestSize(in->authHash); + if (in->nonceCaller.t.size == 0) { + if (tssVerbose) printf("TSS_PR_StartAuthSession: hash algorithm %04x not implemented\n", + in->authHash); + rc = TSS_RC_BAD_HASH_ALGORITHM; + } + } + if (rc == 0) { + rc = TSS_RandBytes((unsigned char *)&in->nonceCaller.t.buffer, in->nonceCaller.t.size); + } +#else + in->nonceCaller.t.size = 16; + memset(&in->nonceCaller.t.buffer, 0, 16); +#endif /* TPM_TSS_NOCRYPTO */ + /* initialize to handle unsalted session */ + in->encryptedSalt.t.size = 0; + if (extra != NULL) { /* extra NULL is handled at the port processor */ + extra->salt.t.size = 0; + } + /* if the caller requests a salted session */ + if (in->tpmKey != TPM_RH_NULL) { +#ifndef TPM_TSS_NOCRYPTO + TPM2B_PUBLIC bPublic; + + if (rc == 0) { + if (extra == NULL) { + if (tssVerbose) + printf("TSS_PR_StartAuthSession: salt session requires extra parameter\n"); + rc = TSS_RC_NULL_PARAMETER; + } + } + /* get the tpmKey public key */ + if (rc == 0) { + rc = TSS_Public_Load(tssContext, &bPublic, in->tpmKey, NULL); + } + /* generate the salt and encrypted salt based on the asymmetric key type */ + if (rc == 0) { + switch (bPublic.publicArea.type) { +#ifndef TPM_TSS_NOECC + case TPM_ALG_ECC: + rc = TSS_ECC_Salt(&extra->salt, + &in->encryptedSalt, + &bPublic.publicArea); + break; +#endif /* TPM_TSS_NOECC */ +#ifndef TPM_TSS_NORSA + case TPM_ALG_RSA: + rc = TSS_RSA_Salt(&extra->salt, + &in->encryptedSalt, + &bPublic.publicArea); + break; +#endif /* TPM_TSS_NORSA */ + default: + if (tssVerbose) + printf("TSS_PR_StartAuthSession: public key type %04x not supported\n", + bPublic.publicArea.type); + rc = TSS_RC_BAD_SALT_KEY; + } + } +#else + tssContext = tssContext; + rc = TSS_RC_NOT_IMPLEMENTED; +#endif /* TPM_TSS_NOCRYPTO */ + } + return rc; +} + +#ifndef TPM_TSS_NOCRYPTO +#ifndef TPM_TSS_NORSA + +/* TSS_RSA_Salt() returns both the plaintext and excrypted salt, based on the salt key bPublic. */ + +static TPM_RC TSS_RSA_Salt(TPM2B_DIGEST *salt, + TPM2B_ENCRYPTED_SECRET *encryptedSalt, + TPMT_PUBLIC *publicArea) +{ + TPM_RC rc = 0; + + if (rc == 0) { + { + /* error conditions when true */ + int b1 = publicArea->type != TPM_ALG_RSA; + int b2 = publicArea->objectAttributes.val & TPMA_OBJECT_SIGN; + int b3 = !(publicArea->objectAttributes.val & TPMA_OBJECT_DECRYPT); + int b4 = publicArea->parameters.rsaDetail.keyBits != 2048; + int b5 = (publicArea->parameters.rsaDetail.exponent != 0) && + /* some HW TPMs return 010001 for the RSA EK with the default IWG template */ + (publicArea->parameters.rsaDetail.exponent != RSA_DEFAULT_PUBLIC_EXPONENT); + /* TSS support checks */ + if (b1 || b2 || b3 || b4 || b5) { + if (tssVerbose) + printf("TSS_RSA_Salt: public key attributes not supported\n"); + rc = TSS_RC_BAD_SALT_KEY; + } + } + } + if (rc == 0) { + if (tssVverbose) TSS_PrintAll("TSS_RSA_Salt: public key", + publicArea->unique.rsa.t.buffer, + publicArea->unique.rsa.t.size); + } + /* generate a salt */ + if (rc == 0) { + /* The size of the secret value is limited to the size of the digest produced by the + nameAlg of the object that is associated with the public key used for OAEP + encryption. */ + salt->t.size = TSS_GetDigestSize(publicArea->nameAlg); + if (tssVverbose) printf("TSS_RSA_Salt: " + "Hash algorithm %04x Salt size %u\n", + publicArea->nameAlg, salt->t.size); + /* place the salt in extra so that it can be retrieved by post processor */ + rc = TSS_RandBytes((uint8_t *)&salt->t.buffer, salt->t.size); + } + /* In TPM2_StartAuthSession(), when tpmKey is an RSA key, the secret value (salt) is + encrypted using OAEP as described in B.4. The string "SECRET" (see 4.5) is used as + the L value and the nameAlg of the encrypting key is used for the hash algorithm. The + data value in OAEP-encrypted blob (salt) is used to compute sessionKey. */ + if (rc == 0) { + if (tssVverbose) TSS_PrintAll("TSS_RSA_Salt: salt", + (uint8_t *)&salt->t.buffer, + salt->t.size); + } + /* encrypt the salt */ + if (rc == 0) { + /* public exponent */ + unsigned char earr[3] = {0x01, 0x00, 0x01}; + /* encrypt the salt with the tpmKey public key */ + rc = TSS_RSAPublicEncrypt((uint8_t *)&encryptedSalt->t.secret, /* encrypted data */ + publicArea->unique.rsa.t.size, /* size of encrypted data buffer */ + (uint8_t *)&salt->t.buffer, /* decrypted data */ + salt->t.size, + publicArea->unique.rsa.t.buffer, /* public modulus */ + publicArea->unique.rsa.t.size, + earr, /* public exponent */ + sizeof(earr), + (unsigned char *)"SECRET", /* encoding parameter */ + sizeof("SECRET"), + publicArea->nameAlg); + } + if (rc == 0) { + encryptedSalt->t.size = publicArea->unique.rsa.t.size; + if (tssVverbose) TSS_PrintAll("TSS_RSA_Salt: RSA encrypted salt", + encryptedSalt->t.secret, + encryptedSalt->t.size); + } + return rc; +} + +#endif /* TPM_TSS_NORSA */ +#endif /* TPM_TSS_NOCRYPTO */ + +static TPM_RC TSS_PR_NV_DefineSpace(TSS_CONTEXT *tssContext, + NV_DefineSpace_In *in, + void *extra) +{ + TPM_RC rc = 0; + tssContext = tssContext; + extra = extra; + + if (tssVverbose) printf("TSS_PR_NV_DefineSpace\n"); + /* Test that TPMA_NVA_POLICY_DELETE is only set when a policy is also set. Otherwise, the index + cannot ever be deleted, even with Platform Authorization. If the application really wants to + do this, set the policy to one that cannot be satisfied, e.g., all 0xff's. */ + if (rc == 0) { + if (in->publicInfo.nvPublic.attributes.val & TPMA_NVA_POLICY_DELETE) { + if (in->publicInfo.nvPublic.authPolicy.b.size == 0) { + if (tssVverbose) printf("TSS_PR_NV_DefineSpace POLICY_DELETE requires a policy\n"); + rc = TSS_RC_IN_PARAMETER; + } + } + } + return rc; +} + +/* + Response Post Processor +*/ + +/* TSS_Response_PostProcessor() handles any response specific post processing + */ + +static TPM_RC TSS_Response_PostProcessor(TSS_CONTEXT *tssContext, + COMMAND_PARAMETERS *in, + RESPONSE_PARAMETERS *out, + EXTRA_PARAMETERS *extra) +{ + TPM_RC rc = 0; + size_t index; + int found; + TSS_PostProcessFunction_t postProcessFunction = NULL; + + /* search the table for a post processing function */ + if (rc == 0) { + TPM_CC commandCode = TSS_GetCommandCode(tssContext->tssAuthContext); + found = FALSE; + for (index = 0 ; (index < (sizeof(tssTable) / sizeof(TSS_TABLE))) && !found ; index++) { + if (tssTable[index].commandCode == commandCode) { + found = TRUE; + break; /* don't increment index if found */ + } + } + } + /* found false means there is no post processing function. This permits the table to be smaller + if desired. */ + if ((rc == 0) && found) { + postProcessFunction = tssTable[index].postProcessFunction; + /* there could also be an entry that it currently NULL, nothing to do */ + if (postProcessFunction == NULL) { + found = FALSE; + } + } + /* call the function */ + if ((rc == 0) && found) { + rc = postProcessFunction(tssContext, in, out, extra); + } + return rc; +} + +/* + Command specific post processing functions +*/ + +/* TSS_PO_StartAuthSession handles StartAuthSession post processing. It: + + creates a TSS HMAC session + + saves the session handle, hash algorithm, and symmetric algorithm, nonceCaller and nonceTPM + + It calculates the session key and saves it + + Finally, it marshals the session and stores it +*/ + +static TPM_RC TSS_PO_StartAuthSession(TSS_CONTEXT *tssContext, + StartAuthSession_In *in, + StartAuthSession_Out *out, + StartAuthSession_Extra *extra) +{ + TPM_RC rc = 0; + struct TSS_HMAC_CONTEXT *session = NULL; + TPM2B_DIGEST salt; + + if (tssVverbose) printf("TSS_PO_StartAuthSession\n"); + /* allocate a TSS_HMAC_CONTEXT session context */ + if (rc == 0) { + rc = TSS_HmacSession_GetContext(&session); + } + if (rc == 0) { + session->sessionHandle = out->sessionHandle; + session->authHashAlg = in->authHash; +#ifndef TPM_TSS_NOCRYPTO + session->sizeInBytes = TSS_GetDigestSize(session->authHashAlg); +#endif + session->symmetric = in->symmetric; + session->sessionType = in->sessionType; + } + /* if not a bind session or if no bind password was supplied */ + if (rc == 0) { + if ((extra == NULL) || (in->bind == TPM_RH_NULL) || (extra->bindPassword == NULL)) { + session->bindAuthValue.b.size = 0; + } + else { + rc = TSS_TPM2B_StringCopy(&session->bindAuthValue.b, + extra->bindPassword, sizeof(session->bindAuthValue.t.buffer)); + } + } + if (rc == 0) { + /* if the caller did not supply extra, the salt must be empty */ + if (extra == NULL) { + salt.b.size = 0; + } + /* if the caller supplied extra, the preprocessor sets salt to empty (unsalted) or the + plaintext salt value */ + else { + rc = TSS_TPM2B_Copy(&salt.b, &extra->salt.b, sizeof(TPMT_HA)); + } + } +#ifndef TPM_TSS_NOCRYPTO + if (rc == 0) { + rc = TSS_TPM2B_Copy(&session->nonceTPM.b, &out->nonceTPM.b, sizeof(TPMT_HA)); + } + if (rc == 0) { + rc = TSS_TPM2B_Copy(&session->nonceCaller.b, &in->nonceCaller.b, sizeof(TPMT_HA)); + } + if (rc == 0) { + rc = TSS_HmacSession_SetSessionKey(tssContext, session, + &salt, + in->bind, &session->bindAuthValue); + } +#endif /* TPM_TSS_NOCRYPTO */ + if (rc == 0) { + rc = TSS_HmacSession_SaveSession(tssContext, session); + } + TSS_HmacSession_FreeContext(session); + return rc; +} + +/* TSS_PO_ContextSave() saves the name of an object in a filename that is a hash of the contextBlob. + + This permits the name to be found during ContextLoad. +*/ + +static TPM_RC TSS_PO_ContextSave(TSS_CONTEXT *tssContext, + ContextSave_In *in, + ContextSave_Out *out, + void *extra) +{ + TPM_RC rc = 0; +#ifndef TPM_TSS_NOFILE + TPMT_HA cpHash; /* largest size of a digest */ + char string[65]; /* sha256 hash * 2 + 1 */ + TPM_HT handleType; + int done = FALSE; +#endif + + in = in; + extra = extra; + +#ifndef TPM_TSS_NOFILE + if (tssVverbose) printf("TSS_PO_ContextSave: handle %08x\n", in->saveHandle); + /* only for objects and sequence objects, not sessions */ + if (rc == 0) { + handleType = (TPM_HT) ((in->saveHandle & HR_RANGE_MASK) >> HR_SHIFT); + if (handleType != TPM_HT_TRANSIENT) { + done = TRUE; + } + } + if ((rc == 0) && !done) { + cpHash.hashAlg = TPM_ALG_SHA256; /* arbitrary choice */ + rc = TSS_Hash_Generate(&cpHash, + out->context.contextBlob.b.size, out->context.contextBlob.b.buffer, + 0, NULL); + } + /* convert a hash of the context blob to a string */ + if ((rc == 0) && !done) { + rc = TSS_HashToString(string, cpHash.digest.sha256); + } + if ((rc == 0) && !done) { + rc = TSS_Name_Copy(tssContext, + 0, string, /* to context */ + in->saveHandle, NULL); /* from handle */ + } + /* get the public key of the object being context saved */ + /* save the public key under the context */ + if ((rc == 0) && !done) { + rc = TSS_Public_Copy(tssContext, + 0, + string, + in->saveHandle, + NULL); + } +#else + tssContext = tssContext; + out = out; +#endif + return rc; +} + +static TPM_RC TSS_PO_ContextLoad(TSS_CONTEXT *tssContext, + ContextLoad_In *in, + ContextLoad_Out *out, + void *extra) +{ + TPM_RC rc = 0; +#ifndef TPM_TSS_NOFILE + TPMT_HA cpHash; /* largest size of a digest */ + char string[65]; /* sha256 hash * 2 + 1 */ + TPM_HT handleType; + int done = FALSE; +#endif + + out = out; + extra = extra; + +#ifndef TPM_TSS_NOFILE + if (tssVverbose) printf("TSS_PO_ContextLoad: handle %08x\n", out->loadedHandle); + /* only for objects and sequence objects, not sessions */ + if (rc == 0) { + handleType = (TPM_HT) ((out->loadedHandle & HR_RANGE_MASK) >> HR_SHIFT); + if (handleType != TPM_HT_TRANSIENT) { + done = TRUE; + } + } + if ((rc == 0) && !done) { + cpHash.hashAlg = TPM_ALG_SHA256; /* arbitrary choice */ + rc = TSS_Hash_Generate(&cpHash, + in->context.contextBlob.b.size, in->context.contextBlob.b.buffer, + 0, NULL); + } + /* convert a hash of the context blob to a string */ + if ((rc == 0) && !done) { + rc = TSS_HashToString(string, cpHash.digest.sha256); + } + /* get the Name of the object being context loaded */ + /* write the name with the loaded context's handle */ + if ((rc == 0) && !done) { + rc = TSS_Name_Copy(tssContext, + out->loadedHandle, NULL, /* to handle */ + 0, string); /* from context */ + } + /* get the public key of the object being context loaded */ + /* write the public key with the loaded context's handle */ + if ((rc == 0) && !done) { + rc = TSS_Public_Copy(tssContext, + out->loadedHandle, + NULL, + 0, + string); + } +#else + tssContext = tssContext; + in = in; +#endif + return rc; +} + +/* TSS_HashToString() converts a SHA-256 binary hash (really any 32-byte value) to a string + + string must be 65 bytes: 32*2 + 1 + + NOTE: Hard coded to SHA256 +*/ + +#ifndef TPM_TSS_NOFILE + +static TPM_RC TSS_HashToString(char *str, uint8_t *digest) +{ + size_t i; + + for (i = 0 ; i < SHA256_DIGEST_SIZE ; i++) { + sprintf(str +(i*2), "%02x", digest[i]); + } + if (tssVverbose) printf("TSS_HashToString: %s\n", str); + return 0; +} + +#endif + +/* TSS_PO_FlushContext() removes persistent state associated with the handle */ + +static TPM_RC TSS_PO_FlushContext(TSS_CONTEXT *tssContext, + FlushContext_In *in, + void *out, + void *extra) +{ + TPM_RC rc = 0; + + out = out; + extra = extra; + if (tssVverbose) printf("TSS_PO_FlushContext: flushHandle %08x\n", in->flushHandle); + if (rc == 0) { + rc = TSS_DeleteHandle(tssContext, in->flushHandle); + } + return rc; +} + +/* TSS_PO_EvictControl() removes persistent state associated with the handle */ + +static TPM_RC TSS_PO_EvictControl(TSS_CONTEXT *tssContext, + EvictControl_In *in, + void *out, + void *extra) +{ + TPM_RC rc = 0; + + out = out; + extra = extra; + + if (tssVverbose) printf("TSS_PO_EvictControl: object %08x persistent %08x\n", + in->objectHandle, in->persistentHandle); + /* if it successfully made a persistent copy */ + if (in->objectHandle != in->persistentHandle) { + /* TPM2B_PUBLIC bPublic; */ + if (rc == 0) { + rc = TSS_Name_Copy(tssContext, + in->persistentHandle, NULL, /* to persistent handle */ + in->objectHandle, NULL); /* from transient handle */ + } + /* get the transient object public key */ + /* copy it to the persistent object public key */ + if (rc == 0) { + rc = TSS_Public_Copy(tssContext, + in->persistentHandle, + NULL, + in->objectHandle, + NULL); + } + } + /* if it successfully evicted the persistent object */ + else { + if (rc == 0) { + rc = TSS_DeleteHandle(tssContext, in->persistentHandle); + } + } + return rc; +} + +/* TSS_PO_Load() saves the Name returned for the loaded object. It saves the TPM2B_PUBLIC */ + +static TPM_RC TSS_PO_Load(TSS_CONTEXT *tssContext, + Load_In *in, + Load_Out *out, + void *extra) +{ + TPM_RC rc = 0; + + in = in; + extra = extra; + if (tssVverbose) printf("TSS_PO_Load: handle %08x\n", out->objectHandle); + /* use handle as file name */ + if (rc == 0) { + rc = TSS_Name_Store(tssContext, &out->name, out->objectHandle, NULL); + } + if (rc == 0) { + rc = TSS_Public_Store(tssContext, &in->inPublic, out->objectHandle, NULL); + } + return rc; +} + +/* TSS_PO_LoadExternal() saves the Name returned for the loaded object */ + +static TPM_RC TSS_PO_LoadExternal(TSS_CONTEXT *tssContext, + LoadExternal_In *in, + LoadExternal_Out *out, + void *extra) +{ + TPM_RC rc = 0; + + in = in; + extra = extra; + if (tssVverbose) printf("TSS_PO_LoadExternal: handle %08x\n", out->objectHandle); + /* use handle as file name */ + if (rc == 0) { + rc = TSS_Name_Store(tssContext, &out->name, out->objectHandle, NULL); + } + if (rc == 0) { + rc = TSS_Public_Store(tssContext, &in->inPublic, out->objectHandle, NULL); + } + return rc; +} + +/* TSS_PO_ReadPublic() saves the Name returned for the loaded object */ + +static TPM_RC TSS_PO_ReadPublic(TSS_CONTEXT *tssContext, + ReadPublic_In *in, + ReadPublic_Out *out, + void *extra) +{ + TPM_RC rc = 0; + + in = in; + extra = extra; + if (tssVverbose) printf("TSS_PO_ReadPublic: handle %08x\n", in->objectHandle); + /* validate the Name against the public area */ + /* Name = nameAlg || HnameAlg (handle->publicArea) + where + nameAlg algorithm used to compute Name + HnameAlg hash using the nameAlg parameter in the object associated with handle + publicArea contents of the TPMT_PUBLIC associated with handle + */ + { + TPM2B_NAME name; + if (rc == 0) { + rc = TSS_ObjectPublic_GetName(&name, &out->outPublic.publicArea); + } + if (rc == 0) { + if (name.t.size != out->name.t.size) { + if (tssVerbose) + printf("TSS_PO_ReadPublic: TPMT_PUBLIC does not match TPM2B_NAME\n"); + rc = TSS_RC_MALFORMED_PUBLIC; + } + else { + int irc; + irc = memcmp(name.t.name, out->name.t.name, out->name.t.size); + if (irc != 0) { + if (tssVerbose) + printf("TSS_PO_ReadPublic: TPMT_PUBLIC does not match TPM2B_NAME\n"); + rc = TSS_RC_MALFORMED_PUBLIC; + } + } + } + } + /* use handle as file name */ + if (rc == 0) { + rc = TSS_Name_Store(tssContext, &out->name, in->objectHandle, NULL); + } + if (rc == 0) { + rc = TSS_Public_Store(tssContext, &out->outPublic, in->objectHandle, NULL); + } + return rc; +} + +/* TSS_PO_Load() saves the Name returned for the loaded object. It saves the TPM2B_PUBLIC */ + +static TPM_RC TSS_PO_CreateLoaded(TSS_CONTEXT *tssContext, + CreateLoaded_In *in, + CreateLoaded_Out *out, + void *extra) +{ + TPM_RC rc = 0; + + in = in; + extra = extra; + if (tssVverbose) printf("TSS_PO_CreateLoaded: handle %08x\n", out->objectHandle); + /* use handle as file name */ + if (rc == 0) { + rc = TSS_Name_Store(tssContext, &out->name, out->objectHandle, NULL); + } + if (rc == 0) { + rc = TSS_Public_Store(tssContext, &out->outPublic, out->objectHandle, NULL); + } + return rc; +} + +/* TSS_PO_HashSequenceStart() saves the Name returned for the started sequence object */ + +static TPM_RC TSS_PO_HashSequenceStart(TSS_CONTEXT *tssContext, + HashSequenceStart_In *in, + HashSequenceStart_Out *out, + void *extra) +{ + TPM_RC rc = 0; + TPM2B_NAME name; + + in = in; + extra = extra; + + if (tssVverbose) printf("TSS_PO_HashSequenceStart\n"); + /* Part 1 Table 3 The Name of a sequence object is an Empty Buffer */ + if (rc == 0) { + name.b.size = 0; + /* use handle as file name */ + rc = TSS_Name_Store(tssContext, &name, out->sequenceHandle, NULL); + } + return rc; +} + + +/* TSS_PO_HMAC_Start() saves the Name returned for the started sequence object */ + +static TPM_RC TSS_PO_HMAC_Start(TSS_CONTEXT *tssContext, + HMAC_Start_In *in, + HMAC_Start_Out *out, + void *extra) +{ + TPM_RC rc = 0; + TPM2B_NAME name; + + in = in; + extra = extra; + + if (tssVverbose) printf("TSS_PO_HMAC_Start\n"); + /* Part 1 Table 3 The Name of a sequence object is an Empty Buffer */ + if (rc == 0) { + name.b.size = 0; + /* use handle as file name */ + rc = TSS_Name_Store(tssContext, &name, out->sequenceHandle, NULL); + } + return rc; +} + +static TPM_RC TSS_PO_SequenceComplete(TSS_CONTEXT *tssContext, + SequenceComplete_In *in, + SequenceComplete_Out *out, + void *extra) +{ + TPM_RC rc = 0; + + out = out; + extra = extra; + + if (tssVverbose) printf("TSS_PO_SequenceComplete: sequenceHandle %08x\n", in->sequenceHandle); + if (rc == 0) { + rc = TSS_DeleteHandle(tssContext, in->sequenceHandle); + } + return rc; +} +static TPM_RC TSS_PO_EventSequenceComplete(TSS_CONTEXT *tssContext, + EventSequenceComplete_In *in, + EventSequenceComplete_Out *out, + void *extra) +{ + TPM_RC rc = 0; + out = out; + extra = extra; + if (tssVverbose) + printf("TSS_PO_EventSequenceComplete: sequenceHandle %08x\n", in->sequenceHandle); + if (rc == 0) { + rc = TSS_DeleteHandle(tssContext, in->sequenceHandle); + } + return rc; +} + +static TPM_RC TSS_PO_PolicyAuthValue(TSS_CONTEXT *tssContext, + PolicyAuthValue_In *in, + void *out, + void *extra) +{ + TPM_RC rc = 0; + struct TSS_HMAC_CONTEXT *session = NULL; + + out = out; + extra = extra; + if (tssVverbose) printf("TSS_PO_PolicyAuthValue\n"); + if (rc == 0) { + rc = TSS_Malloc((unsigned char **)&session, sizeof(TSS_HMAC_CONTEXT)); /* freed @1 */ + } + if (rc == 0) { + rc = TSS_HmacSession_LoadSession(tssContext, session, in->policySession); + } + if (rc == 0) { + session->isPasswordNeeded = FALSE; + session->isAuthValueNeeded = TRUE; + rc = TSS_HmacSession_SaveSession(tssContext, session); + } + free(session); /* @1 */ + return rc; +} + +static TPM_RC TSS_PO_PolicyPassword(TSS_CONTEXT *tssContext, + PolicyPassword_In *in, + void *out, + void *extra) +{ + TPM_RC rc = 0; + struct TSS_HMAC_CONTEXT *session = NULL; + + out = out; + extra = extra; + if (tssVverbose) printf("TSS_PO_PolicyPassword\n"); + if (rc == 0) { + rc = TSS_Malloc((unsigned char **)&session, sizeof(TSS_HMAC_CONTEXT)); /* freed @1 */ + } + if (rc == 0) { + rc = TSS_HmacSession_LoadSession(tssContext, session, in->policySession); + } + if (rc == 0) { + session->isPasswordNeeded = TRUE; + session->isAuthValueNeeded = FALSE; + rc = TSS_HmacSession_SaveSession(tssContext, session); + } + free(session); /* @1 */ + return rc; +} + +static TPM_RC TSS_PO_CreatePrimary(TSS_CONTEXT *tssContext, + CreatePrimary_In *in, + CreatePrimary_Out *out, + void *extra) +{ + TPM_RC rc = 0; + + in = in; + extra = extra; + if (tssVverbose) printf("TSS_PO_CreatePrimary: handle %08x\n", out->objectHandle); + /* use handle as file name */ + if (rc == 0) { + rc = TSS_Name_Store(tssContext, &out->name, out->objectHandle, NULL); + } + if (rc == 0) { + rc = TSS_Public_Store(tssContext, &out->outPublic, out->objectHandle, NULL); + } + return rc; +} + +static TPM_RC TSS_PO_NV_DefineSpace(TSS_CONTEXT *tssContext, + NV_DefineSpace_In *in, + void *out, + void *extra) +{ + TPM_RC rc = 0; + + if (tssVverbose) printf("TSS_PO_NV_DefineSpace\n"); +#ifndef TPM_TSS_NOCRYPTO + { + TPM2B_NAME name; + /* calculate the Name from the input public area */ + /* Name = nameAlg || HnameAlg (handle->nvPublicArea) + where + nameAlg algorithm used to compute Name + HnameAlg hash using the nameAlg parameter in the NV Index location associated with handle + nvPublicArea contents of the TPMS_NV_PUBLIC associated with handle + */ + /* calculate the Name from the input TPMS_NV_PUBLIC */ + if (rc == 0) { + rc = TSS_NVPublic_GetName(&name, &in->publicInfo.nvPublic); + } + /* use handle as file name */ + if (rc == 0) { + rc = TSS_Name_Store(tssContext, &name, in->publicInfo.nvPublic.nvIndex, NULL); + } + if (rc == 0) { + rc = TSS_NVPublic_Store(tssContext, &in->publicInfo.nvPublic, + in->publicInfo.nvPublic.nvIndex); + } + } +#else + tssContext = tssContext; + in = in; +#endif + out = out; + extra = extra; + return rc; +} + + +static TPM_RC TSS_PO_NV_ReadPublic(TSS_CONTEXT *tssContext, + NV_ReadPublic_In *in, + NV_ReadPublic_Out *out, + void *extra) +{ + TPM_RC rc = 0; + + if (tssVverbose) printf("TSS_PO_NV_ReadPublic\n"); + + /* validate the Name against the public area */ + /* Name = nameAlg || HnameAlg (handle->nvPublicArea) + where + nameAlg algorithm used to compute Name + HnameAlg hash using the nameAlg parameter in the NV Index location associated with handle + nvPublicArea contents of the TPMS_NV_PUBLIC associated with handle + */ +#ifndef TPM_TSS_NOCRYPTO + { + TPM2B_NAME name; + /* calculate the Name from the TPMS_NV_PUBLIC */ + if (rc == 0) { + rc = TSS_NVPublic_GetName(&name, &out->nvPublic.nvPublic); + } + if (rc == 0) { + if (name.t.size != out->nvName.t.size) { + if (tssVerbose) + printf("TSS_PO_NV_ReadPublic: TPMT_NV_PUBLIC does not match TPM2B_NAME\n"); + rc = TSS_RC_MALFORMED_NV_PUBLIC; + } + else { + int irc; + irc = memcmp(name.t.name, out->nvName.t.name, out->nvName.t.size); + if (irc != 0) { + if (tssVerbose) + printf("TSS_PO_NV_ReadPublic: TPMT_NV_PUBLIC does not match TPM2B_NAME\n"); + rc = TSS_RC_MALFORMED_NV_PUBLIC; + } + } + } + /* use handle as file name */ + if (rc == 0) { + rc = TSS_Name_Store(tssContext, &out->nvName, in->nvIndex, NULL); + } + if (rc == 0) { + rc = TSS_NVPublic_Store(tssContext, &out->nvPublic.nvPublic, in->nvIndex); + } + } +#else + tssContext = tssContext; + in = in; + out = out; +#endif + extra = extra; + return rc; +} + +static TPM_RC TSS_PO_NV_UndefineSpace(TSS_CONTEXT *tssContext, + NV_UndefineSpace_In *in, + void *out, + void *extra) +{ + TPM_RC rc = 0; + + out = out; + extra = extra; + if (tssVverbose) printf("TSS_PO_NV_UndefineSpace\n"); +#ifndef TPM_TSS_NOCRYPTO + /* Don't check return code. */ + TSS_DeleteHandle(tssContext, in->nvIndex); + TSS_NVPublic_Delete(tssContext, in->nvIndex); +#else + tssContext = tssContext; + in = in; +#endif + return rc; +} + +static TPM_RC TSS_PO_NV_UndefineSpaceSpecial(TSS_CONTEXT *tssContext, + NV_UndefineSpaceSpecial_In *in, + void *out, + void *extra) +{ + TPM_RC rc = 0; + + out = out; + extra = extra; + if (tssVverbose) printf("TSS_PO_NV_UndefineSpaceSpecial\n"); + /* Don't check return code. The name will only exist if NV_ReadPublic has been issued */ + TSS_DeleteHandle(tssContext, in->nvIndex); + TSS_NVPublic_Delete(tssContext, in->nvIndex); + return rc; +} + +/* TSS_PO_NV_Write() handles the Name and NVPublic update for the 4 NV write commands: write, + increment, extend, and setbits */ + +static TPM_RC TSS_PO_NV_Write(TSS_CONTEXT *tssContext, + NV_Write_In *in, + void *out, + void *extra) +{ + TPM_RC rc = 0; + + if (tssVverbose) printf("TSS_PO_NV_Write, Increment, Extend, SetBits:\n"); + +#ifndef TPM_TSS_NOCRYPTO + { + TPMS_NV_PUBLIC nvPublic; + TPM2B_NAME name; /* new name */ + + if (rc == 0) { + rc = TSS_NVPublic_Load(tssContext, &nvPublic, in->nvIndex); + } + /* if the previous store had written clear */ + if (!(nvPublic.attributes.val & TPMA_NVA_WRITTEN)) { + if (rc == 0) { + /* set the written bit */ + nvPublic.attributes.val |= TPMA_NVA_WRITTEN; + /* save the TPMS_NV_PUBLIC */ + rc = TSS_NVPublic_Store(tssContext, &nvPublic, in->nvIndex); + } + /* calculate the name */ + if (rc == 0) { + rc = TSS_NVPublic_GetName(&name, &nvPublic); + } + /* save the name */ + if (rc == 0) { + /* use handle as file name */ + rc = TSS_Name_Store(tssContext, &name, in->nvIndex, NULL); + } + /* if there is a failure. delete the name and NVPublic */ + if (rc != 0) { + TSS_DeleteHandle(tssContext, in->nvIndex); + TSS_NVPublic_Delete(tssContext, in->nvIndex); + } + } + } +#else + tssContext = tssContext; + in = in; +#endif + out = out; + extra = extra; + return rc; +} + +/* TSS_PO_NV_WriteLock() handles the Name and NVPublic update for the write lock command */ + +static TPM_RC TSS_PO_NV_WriteLock(TSS_CONTEXT *tssContext, + NV_WriteLock_In *in, + void *out, + void *extra) +{ + TPM_RC rc = 0; + + if (tssVverbose) printf("TSS_PO_NV_WriteLock:\n"); + +#ifndef TPM_TSS_NOCRYPTO + { + TPMS_NV_PUBLIC nvPublic; + TPM2B_NAME name; /* new name */ + + if (rc == 0) { + rc = TSS_NVPublic_Load(tssContext, &nvPublic, in->nvIndex); + } + /* if the previous store had write lock clear */ + if (!(nvPublic.attributes.val & TPMA_NVA_WRITELOCKED)) { + if (rc == 0) { + /* set the write lock bit */ + nvPublic.attributes.val |= TPMA_NVA_WRITELOCKED; + /* save the TPMS_NV_PUBLIC */ + rc = TSS_NVPublic_Store(tssContext, &nvPublic, in->nvIndex); + } + /* calculate the name */ + if (rc == 0) { + rc = TSS_NVPublic_GetName(&name, &nvPublic); + } + /* save the name */ + if (rc == 0) { + /* use handle as file name */ + rc = TSS_Name_Store(tssContext, &name, in->nvIndex, NULL); + } + /* if there is a failure. delete the name and NVPublic */ + if (rc != 0) { + TSS_DeleteHandle(tssContext, in->nvIndex); + TSS_NVPublic_Delete(tssContext, in->nvIndex); + } + } + } +#else + tssContext = tssContext; + in = in; +#endif + out = out; + extra = extra; + return rc; +} + +/* TSS_PO_NV_WriteLock() handles the Name and NVPublic update for the read lock command */ + +static TPM_RC TSS_PO_NV_ReadLock(TSS_CONTEXT *tssContext, + NV_ReadLock_In *in, + void *out, + void *extra) +{ + TPM_RC rc = 0; + + if (tssVverbose) printf("TSS_PO_NV_ReadLock:"); + +#ifndef TPM_TSS_NOCRYPTO + { + TPMS_NV_PUBLIC nvPublic; + TPM2B_NAME name; /* new name */ + + if (rc == 0) { + rc = TSS_NVPublic_Load(tssContext, &nvPublic, in->nvIndex); + } + /* if the previous store had read lock clear */ + if (!(nvPublic.attributes.val & TPMA_NVA_READLOCKED)) { + if (rc == 0) { + /* set the read lock bit */ + nvPublic.attributes.val |= TPMA_NVA_READLOCKED; + /* save the TPMS_NV_PUBLIC */ + rc = TSS_NVPublic_Store(tssContext, &nvPublic, in->nvIndex); + } + /* calculate the name */ + if (rc == 0) { + rc = TSS_NVPublic_GetName(&name, &nvPublic); + } + /* save the name */ + if (rc == 0) { + /* use handle as file name */ + rc = TSS_Name_Store(tssContext, &name, in->nvIndex, NULL); + } + /* if there is a failure. delete the name and NVPublic */ + if (rc != 0) { + TSS_DeleteHandle(tssContext, in->nvIndex); + TSS_NVPublic_Delete(tssContext, in->nvIndex); + } + } + } +#else + tssContext = tssContext; + in = in; +#endif + out = out; + extra = extra; + return rc; +} diff --git a/libstb/tss2/tss20.h b/libstb/tss2/tss20.h new file mode 100644 index 0000000..2e3e2b0 --- /dev/null +++ b/libstb/tss2/tss20.h @@ -0,0 +1,58 @@ +/********************************************************************************/ +/* */ +/* TSS TPM 2.0 API */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id:tss.h 656 2016-06-28 16:49:29Z kgoldman $ */ +/* */ +/* (c) Copyright IBM Corporation 2015. */ +/* */ +/* All rights reserved. */ +/* */ +/* Redistribution and use in source and binary forms, with or without */ +/* modification, are permitted provided that the following conditions are */ +/* met: */ +/* */ +/* Redistributions of source code must retain the above copyright notice, */ +/* this list of conditions and the following disclaimer. */ +/* */ +/* 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. */ +/* */ +/* Neither the names of the IBM Corporation nor the names of its */ +/* contributors may be used to endorse or promote products derived from */ +/* this software without specific prior written permission. */ +/* */ +/* 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 TSS20_H +#define TSS20_H + +#ifdef __cplusplus +extern "C" { +#endif + + TPM_RC TSS_Execute20(TSS_CONTEXT *tssContext, + RESPONSE_PARAMETERS *out, + COMMAND_PARAMETERS *in, + EXTRA_PARAMETERS *extra, + TPM_CC commandCode, + va_list ap); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libstb/tss2/tssauth.c b/libstb/tss2/tssauth.c new file mode 100644 index 0000000..0999ca6 --- /dev/null +++ b/libstb/tss2/tssauth.c @@ -0,0 +1,165 @@ +/********************************************************************************/ +/* */ +/* Common TPM 1.2 and TPM 2.0 TSS Authorization */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: tssauth.c 1294 2018-08-09 19:08:34Z kgoldman $ */ +/* */ +/* (c) Copyright IBM Corporation 2015, 2018. */ +/* */ +/* All rights reserved. */ +/* */ +/* Redistribution and use in source and binary forms, with or without */ +/* modification, are permitted provided that the following conditions are */ +/* met: */ +/* */ +/* Redistributions of source code must retain the above copyright notice, */ +/* this list of conditions and the following disclaimer. */ +/* */ +/* 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. */ +/* */ +/* Neither the names of the IBM Corporation nor the names of its */ +/* contributors may be used to endorse or promote products derived from */ +/* this software without specific prior written permission. */ +/* */ +/* 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. */ +/********************************************************************************/ + +/* This layer handles command and response packet authorization parameters. */ + +#include <stdio.h> +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include <stdarg.h> + +#ifdef TPM_POSIX +#include <netinet/in.h> +#endif +#ifdef TPM_WINDOWS +#include <winsock2.h> +#endif + +#include <ibmtss/tsserror.h> +#include <ibmtss/tssprint.h> +#include <ibmtss/tssutils.h> +#include <ibmtss/tssmarshal.h> +#include <ibmtss/Unmarshal_fp.h> +#include <ibmtss/tsstransmit.h> +#include "tssproperties.h" +#include <ibmtss/tssresponsecode.h> + +#include "tssauth.h" + +extern int tssVerbose; +extern int tssVverbose; + +/* TSS_AuthCreate() allocates and initializes a TSS_AUTH_CONTEXT */ + +TPM_RC TSS_AuthCreate(TSS_AUTH_CONTEXT **tssAuthContext) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_Malloc((uint8_t **)tssAuthContext, sizeof(TSS_AUTH_CONTEXT)); + } + if (rc == 0) { + TSS_InitAuthContext(*tssAuthContext); + } + return rc; +} + +/* TSS_InitAuthContext() sets initial values for an allocated TSS_AUTH_CONTEXT */ + +void TSS_InitAuthContext(TSS_AUTH_CONTEXT *tssAuthContext) +{ + memset(tssAuthContext->commandBuffer, 0, sizeof(tssAuthContext->commandBuffer)); + memset(tssAuthContext->responseBuffer, 0, sizeof(tssAuthContext->responseBuffer)); + tssAuthContext->commandText = NULL; + tssAuthContext->commandCode = 0; + tssAuthContext->responseCode = 0; + tssAuthContext->commandHandleCount = 0; + tssAuthContext->responseHandleCount = 0; + tssAuthContext->authCount = 0; + tssAuthContext->commandSize = 0; + tssAuthContext->cpBufferSize = 0; + tssAuthContext->cpBuffer = NULL; +#ifdef __SKIBOOT__ + tssAuthContext->responseSize = sizeof(tssAuthContext->responseBuffer); +#else + tssAuthContext->responseSize = 0; +#endif + tssAuthContext->marshalInFunction = NULL; + tssAuthContext->unmarshalOutFunction = NULL; + tssAuthContext->unmarshalInFunction = NULL; +#ifdef TPM_TPM12 + tssAuthContext->sessionNumber = 0xffff; /* no encrypt sessions */ + tssAuthContext->encAuthOffset0 = 0; + tssAuthContext->encAuthOffset1 = 0; +#endif + return; +} + +/* TSS_AuthDelete() re-initializes and then frees an allocated TSS_AUTH_CONTEXT */ + +TPM_RC TSS_AuthDelete(TSS_AUTH_CONTEXT *tssAuthContext) +{ + if (tssAuthContext != NULL) { + TSS_InitAuthContext(tssAuthContext); + free(tssAuthContext); + } + return 0; +} + +TPM_CC TSS_GetCommandCode(TSS_AUTH_CONTEXT *tssAuthContext) +{ + TPM_CC commandCode = tssAuthContext->commandCode; + return commandCode; +} + +TPM_RC TSS_GetCpBuffer(TSS_AUTH_CONTEXT *tssAuthContext, + uint32_t *cpBufferSize, + uint8_t **cpBuffer) +{ + *cpBufferSize = tssAuthContext->cpBufferSize; + *cpBuffer = tssAuthContext->cpBuffer; + return 0; +} + +/* TSS_GetCommandHandleCount() returns the number of handles in the command area */ + +TPM_RC TSS_GetCommandHandleCount(TSS_AUTH_CONTEXT *tssAuthContext, + size_t *commandHandleCount) +{ + *commandHandleCount = tssAuthContext->commandHandleCount; + return 0; +} + +TPM_RC TSS_AuthExecute(TSS_CONTEXT *tssContext) +{ + TPM_RC rc = 0; + if (tssVverbose) printf("TSS_AuthExecute: Executing %s IF %s\n", + tssContext->tssAuthContext->commandText, + tssContext->tssInterfaceType); + /* transmit the command and receive the response. Normally returns the TPM response code. */ + if (rc == 0) { + rc = TSS_Transmit(tssContext, + tssContext->tssAuthContext->responseBuffer, + &tssContext->tssAuthContext->responseSize, + tssContext->tssAuthContext->commandBuffer, + tssContext->tssAuthContext->commandSize, + tssContext->tssAuthContext->commandText); + } + return rc; +} diff --git a/libstb/tss2/tssauth.h b/libstb/tss2/tssauth.h new file mode 100644 index 0000000..f7dfb31 --- /dev/null +++ b/libstb/tss2/tssauth.h @@ -0,0 +1,102 @@ +/********************************************************************************/ +/* */ +/* TSS Authorization */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: tssauth.h 1257 2018-06-27 20:52:08Z kgoldman $ */ +/* */ +/* (c) Copyright IBM Corporation 2015, 2017. */ +/* */ +/* All rights reserved. */ +/* */ +/* Redistribution and use in source and binary forms, with or without */ +/* modification, are permitted provided that the following conditions are */ +/* met: */ +/* */ +/* Redistributions of source code must retain the above copyright notice, */ +/* this list of conditions and the following disclaimer. */ +/* */ +/* 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. */ +/* */ +/* Neither the names of the IBM Corporation nor the names of its */ +/* contributors may be used to endorse or promote products derived from */ +/* this software without specific prior written permission. */ +/* */ +/* 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. */ +/********************************************************************************/ + +/* This is not a public header. It should not be used by applications. */ + +#ifndef TSS_AUTH_H +#define TSS_AUTH_H + +#include <ibmtss/tss.h> +#include "tssccattributes.h" + +/* Generic functions to marshal and unmarshal Part 3 ordinal command and response parameters */ + +typedef TPM_RC (*MarshalInFunction_t)(COMMAND_PARAMETERS *source, + uint16_t *written, BYTE **buffer, uint32_t *size); +typedef TPM_RC (*UnmarshalOutFunction_t)(RESPONSE_PARAMETERS *target, + TPM_ST tag, BYTE **buffer, uint32_t *size); +typedef TPM_RC (*UnmarshalInFunction_t)(COMMAND_PARAMETERS *target, + BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); + +/* The context for the entire command processor. Update TSS_InitAuthContext() when changing + this structure */ + +typedef struct TSS_AUTH_CONTEXT { + uint8_t commandBuffer [MAX_COMMAND_SIZE]; + uint8_t responseBuffer [MAX_RESPONSE_SIZE]; + const char *commandText; + COMMAND_INDEX tpmCommandIndex; /* index into attributes table */ + TPM_CC commandCode; + TPM_RC responseCode; + size_t commandHandleCount; + uint32_t responseHandleCount; + uint16_t authCount; /* authorizations in command */ + uint16_t commandSize; + uint32_t cpBufferSize; + uint8_t *cpBuffer; + uint32_t responseSize; + MarshalInFunction_t marshalInFunction; + UnmarshalOutFunction_t unmarshalOutFunction; + UnmarshalInFunction_t unmarshalInFunction; +#ifdef TPM_TPM12 + uint16_t sessionNumber; /* session used for ADIP, zero based */ + int16_t encAuthOffset0; /* offset to first TPM_ENCAUTH parameter */ + int16_t encAuthOffset1; /* offset to second TPM_ENCAUTH parameter if not NULL */ +#endif +} TSS_AUTH_CONTEXT; + +TPM_RC TSS_AuthCreate(TSS_AUTH_CONTEXT **tssAuthContext); + +void TSS_InitAuthContext(TSS_AUTH_CONTEXT *tssAuthContext); + +TPM_RC TSS_AuthDelete(TSS_AUTH_CONTEXT *tssAuthContext); + +TPM_CC TSS_GetCommandCode(TSS_AUTH_CONTEXT *tssAuthContext); + +TPM_RC TSS_GetCpBuffer(TSS_AUTH_CONTEXT *tssAuthContext, + uint32_t *cpBufferSize, + uint8_t **cpBuffer); + + +TPM_RC TSS_GetCommandHandleCount(TSS_AUTH_CONTEXT *tssAuthContext, + size_t *commandHandleCount); + +TPM_RC TSS_AuthExecute(TSS_CONTEXT *tssContext); + +#endif diff --git a/libstb/tss2/tssauth20.c b/libstb/tss2/tssauth20.c new file mode 100644 index 0000000..4619960 --- /dev/null +++ b/libstb/tss2/tssauth20.c @@ -0,0 +1,1280 @@ +/********************************************************************************/ +/* */ +/* TPM 2.0 TSS Authorization */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* */ +/* (c) Copyright IBM Corporation 2015 - 2019. */ +/* */ +/* All rights reserved. */ +/* */ +/* Redistribution and use in source and binary forms, with or without */ +/* modification, are permitted provided that the following conditions are */ +/* met: */ +/* */ +/* Redistributions of source code must retain the above copyright notice, */ +/* this list of conditions and the following disclaimer. */ +/* */ +/* 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. */ +/* */ +/* Neither the names of the IBM Corporation nor the names of its */ +/* contributors may be used to endorse or promote products derived from */ +/* this software without specific prior written permission. */ +/* */ +/* 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. */ +/********************************************************************************/ + +/* This layer handles command and response packet authorization parameters. */ + +#include <stdio.h> +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include <stdarg.h> + +#ifdef TPM_POSIX +#include <netinet/in.h> +#endif +#ifdef TPM_WINDOWS +#include <winsock2.h> +#endif + +#include <ibmtss/tsserror.h> +#include <ibmtss/tssprint.h> +#include <ibmtss/tssutils.h> +#include <ibmtss/tssmarshal.h> +#include <ibmtss/Unmarshal_fp.h> +#include <ibmtss/tsstransmit.h> +#include "tssproperties.h" +#include <ibmtss/tssresponsecode.h> + +#include "tssntc.h" +#include "tssauth.h" +#include "tssauth20.h" + +extern int tssVerbose; +extern int tssVverbose; + +typedef struct MARSHAL_TABLE { + TPM_CC commandCode; + const char *commandText; + MarshalInFunction_t marshalInFunction; /* marshal input command */ + UnmarshalOutFunction_t unmarshalOutFunction; /* unmarshal output response */ + UnmarshalInFunction_t unmarshalInFunction; /* unmarshal input command for parameter + checking */ +} MARSHAL_TABLE; + +static const MARSHAL_TABLE marshalTable [] = { + + {TPM_CC_Startup, "TPM2_Startup", + (MarshalInFunction_t)TSS_Startup_In_Marshalu, + NULL, + (UnmarshalInFunction_t)Startup_In_Unmarshal}, + + {TPM_CC_Shutdown, "TPM2_Shutdown", + (MarshalInFunction_t)TSS_Shutdown_In_Marshalu, + NULL, + (UnmarshalInFunction_t)Shutdown_In_Unmarshal}, + + {TPM_CC_SelfTest, "TPM2_SelfTest", + (MarshalInFunction_t)TSS_SelfTest_In_Marshalu, + NULL, + (UnmarshalInFunction_t)SelfTest_In_Unmarshal}, + + {TPM_CC_IncrementalSelfTest, "TPM2_IncrementalSelfTest", + (MarshalInFunction_t)TSS_IncrementalSelfTest_In_Marshalu, + (UnmarshalOutFunction_t)TSS_IncrementalSelfTest_Out_Unmarshalu, + (UnmarshalInFunction_t)IncrementalSelfTest_In_Unmarshal}, + + {TPM_CC_GetTestResult, "TPM2_GetTestResult", + NULL, + (UnmarshalOutFunction_t)TSS_GetTestResult_Out_Unmarshalu, + NULL}, + + {TPM_CC_StartAuthSession, "TPM2_StartAuthSession", + (MarshalInFunction_t)TSS_StartAuthSession_In_Marshalu, + (UnmarshalOutFunction_t)TSS_StartAuthSession_Out_Unmarshalu, + (UnmarshalInFunction_t)StartAuthSession_In_Unmarshal}, + + {TPM_CC_PolicyRestart, "TPM2_PolicyRestart", + (MarshalInFunction_t)TSS_PolicyRestart_In_Marshalu, + NULL, + (UnmarshalInFunction_t)PolicyRestart_In_Unmarshal}, + + {TPM_CC_Create, "TPM2_Create", + (MarshalInFunction_t)TSS_Create_In_Marshalu, + (UnmarshalOutFunction_t)TSS_Create_Out_Unmarshalu, + (UnmarshalInFunction_t)Create_In_Unmarshal}, + + {TPM_CC_Load, "TPM2_Load", + (MarshalInFunction_t)TSS_Load_In_Marshalu, + (UnmarshalOutFunction_t)TSS_Load_Out_Unmarshalu, + (UnmarshalInFunction_t)Load_In_Unmarshal}, + + {TPM_CC_LoadExternal, "TPM2_LoadExternal", + (MarshalInFunction_t)TSS_LoadExternal_In_Marshalu, + (UnmarshalOutFunction_t)TSS_LoadExternal_Out_Unmarshalu, + (UnmarshalInFunction_t)LoadExternal_In_Unmarshal}, + + {TPM_CC_ReadPublic, "TPM2_ReadPublic", + (MarshalInFunction_t)TSS_ReadPublic_In_Marshalu, + (UnmarshalOutFunction_t)TSS_ReadPublic_Out_Unmarshalu, + (UnmarshalInFunction_t)ReadPublic_In_Unmarshal}, + + {TPM_CC_ActivateCredential, "TPM2_ActivateCredential", + (MarshalInFunction_t)TSS_ActivateCredential_In_Marshalu, + (UnmarshalOutFunction_t)TSS_ActivateCredential_Out_Unmarshalu, + (UnmarshalInFunction_t)ActivateCredential_In_Unmarshal}, + + {TPM_CC_MakeCredential, "TPM2_MakeCredential", + (MarshalInFunction_t)TSS_MakeCredential_In_Marshalu, + (UnmarshalOutFunction_t)TSS_MakeCredential_Out_Unmarshalu, + (UnmarshalInFunction_t)MakeCredential_In_Unmarshal}, + + {TPM_CC_Unseal, "TPM2_Unseal", + (MarshalInFunction_t)TSS_Unseal_In_Marshalu, + (UnmarshalOutFunction_t)TSS_Unseal_Out_Unmarshalu, + (UnmarshalInFunction_t)Unseal_In_Unmarshal}, + + {TPM_CC_ObjectChangeAuth, "TPM2_ObjectChangeAuth", + (MarshalInFunction_t)TSS_ObjectChangeAuth_In_Marshalu, + (UnmarshalOutFunction_t)TSS_ObjectChangeAuth_Out_Unmarshalu, + (UnmarshalInFunction_t)ObjectChangeAuth_In_Unmarshal}, + + {TPM_CC_CreateLoaded, "TPM2_CreateLoaded", + (MarshalInFunction_t)TSS_CreateLoaded_In_Marshalu, + (UnmarshalOutFunction_t)TSS_CreateLoaded_Out_Unmarshalu, + (UnmarshalInFunction_t)CreateLoaded_In_Unmarshal}, + + {TPM_CC_Duplicate, "TPM2_Duplicate", + (MarshalInFunction_t)TSS_Duplicate_In_Marshalu, + (UnmarshalOutFunction_t)TSS_Duplicate_Out_Unmarshalu, + (UnmarshalInFunction_t)Duplicate_In_Unmarshal}, + + {TPM_CC_Rewrap, "TPM2_Rewrap", + (MarshalInFunction_t)TSS_Rewrap_In_Marshalu, + (UnmarshalOutFunction_t)TSS_Rewrap_Out_Unmarshalu, + (UnmarshalInFunction_t)Rewrap_In_Unmarshal}, + + {TPM_CC_Import, "TPM2_Import", + (MarshalInFunction_t)TSS_Import_In_Marshalu, + (UnmarshalOutFunction_t)TSS_Import_Out_Unmarshalu, + (UnmarshalInFunction_t)Import_In_Unmarshal}, + + {TPM_CC_RSA_Encrypt, "TPM2_RSA_Encrypt", + (MarshalInFunction_t)TSS_RSA_Encrypt_In_Marshalu, + (UnmarshalOutFunction_t)TSS_RSA_Encrypt_Out_Unmarshalu, + (UnmarshalInFunction_t)RSA_Encrypt_In_Unmarshal}, + + {TPM_CC_RSA_Decrypt, "TPM2_RSA_Decrypt", + (MarshalInFunction_t)TSS_RSA_Decrypt_In_Marshalu, + (UnmarshalOutFunction_t)TSS_RSA_Decrypt_Out_Unmarshalu, + (UnmarshalInFunction_t)RSA_Decrypt_In_Unmarshal}, + + {TPM_CC_ECDH_KeyGen, "TPM2_ECDH_KeyGen", + (MarshalInFunction_t)TSS_ECDH_KeyGen_In_Marshalu, + (UnmarshalOutFunction_t)TSS_ECDH_KeyGen_Out_Unmarshalu, + (UnmarshalInFunction_t)ECDH_KeyGen_In_Unmarshal}, + + {TPM_CC_ECDH_ZGen, "TPM2_ECDH_ZGen", + (MarshalInFunction_t)TSS_ECDH_ZGen_In_Marshalu, + (UnmarshalOutFunction_t)TSS_ECDH_ZGen_Out_Unmarshalu, + (UnmarshalInFunction_t)ECDH_ZGen_In_Unmarshal}, + + {TPM_CC_ECC_Parameters, "TPM2_ECC_Parameters", + (MarshalInFunction_t)TSS_ECC_Parameters_In_Marshalu, + (UnmarshalOutFunction_t)TSS_ECC_Parameters_Out_Unmarshalu, + (UnmarshalInFunction_t)ECC_Parameters_In_Unmarshal}, + + {TPM_CC_ZGen_2Phase, "TPM2_ZGen_2Phase", + (MarshalInFunction_t)TSS_ZGen_2Phase_In_Marshalu, + (UnmarshalOutFunction_t)TSS_ZGen_2Phase_Out_Unmarshalu, + (UnmarshalInFunction_t)ZGen_2Phase_In_Unmarshal}, + + {TPM_CC_EncryptDecrypt, "TPM2_EncryptDecrypt", + (MarshalInFunction_t)TSS_EncryptDecrypt_In_Marshalu, + (UnmarshalOutFunction_t)TSS_EncryptDecrypt_Out_Unmarshalu, + (UnmarshalInFunction_t)EncryptDecrypt_In_Unmarshal}, + + {TPM_CC_EncryptDecrypt2, "TPM2_EncryptDecrypt2", + (MarshalInFunction_t)TSS_EncryptDecrypt2_In_Marshalu, + (UnmarshalOutFunction_t)TSS_EncryptDecrypt2_Out_Unmarshalu, + (UnmarshalInFunction_t)EncryptDecrypt2_In_Unmarshal}, + + {TPM_CC_Hash, "TPM2_Hash", + (MarshalInFunction_t)TSS_Hash_In_Marshalu, + (UnmarshalOutFunction_t)TSS_Hash_Out_Unmarshalu, + (UnmarshalInFunction_t)Hash_In_Unmarshal}, + + {TPM_CC_HMAC, "TPM2_HMAC", + (MarshalInFunction_t)TSS_HMAC_In_Marshalu, + (UnmarshalOutFunction_t)TSS_HMAC_Out_Unmarshalu, + (UnmarshalInFunction_t)HMAC_In_Unmarshal}, + + {TPM_CC_GetRandom, "TPM2_GetRandom", + (MarshalInFunction_t)TSS_GetRandom_In_Marshalu, + (UnmarshalOutFunction_t)TSS_GetRandom_Out_Unmarshalu, + (UnmarshalInFunction_t)GetRandom_In_Unmarshal}, + + {TPM_CC_StirRandom, "TPM2_StirRandom", + (MarshalInFunction_t)TSS_StirRandom_In_Marshalu, + NULL, + (UnmarshalInFunction_t)StirRandom_In_Unmarshal}, + + {TPM_CC_HMAC_Start, "TPM2_HMAC_Start", + (MarshalInFunction_t)TSS_HMAC_Start_In_Marshalu, + (UnmarshalOutFunction_t)TSS_HMAC_Start_Out_Unmarshalu, + (UnmarshalInFunction_t)HMAC_Start_In_Unmarshal}, + + {TPM_CC_HashSequenceStart, "TPM2_HashSequenceStart", + (MarshalInFunction_t)TSS_HashSequenceStart_In_Marshalu, + (UnmarshalOutFunction_t)TSS_HashSequenceStart_Out_Unmarshalu, + (UnmarshalInFunction_t)HashSequenceStart_In_Unmarshal}, + + {TPM_CC_SequenceUpdate, "TPM2_SequenceUpdate", + (MarshalInFunction_t)TSS_SequenceUpdate_In_Marshalu, + NULL, + (UnmarshalInFunction_t)SequenceUpdate_In_Unmarshal}, + + {TPM_CC_SequenceComplete, "TPM2_SequenceComplete", + (MarshalInFunction_t)TSS_SequenceComplete_In_Marshalu, + (UnmarshalOutFunction_t)TSS_SequenceComplete_Out_Unmarshalu, + (UnmarshalInFunction_t)SequenceComplete_In_Unmarshal}, + + {TPM_CC_EventSequenceComplete, "TPM2_EventSequenceComplete", + (MarshalInFunction_t)TSS_EventSequenceComplete_In_Marshalu, + (UnmarshalOutFunction_t)TSS_EventSequenceComplete_Out_Unmarshalu, + (UnmarshalInFunction_t)EventSequenceComplete_In_Unmarshal}, + + {TPM_CC_Certify, "TPM2_Certify", + (MarshalInFunction_t)TSS_Certify_In_Marshalu, + (UnmarshalOutFunction_t)TSS_Certify_Out_Unmarshalu, + (UnmarshalInFunction_t)Certify_In_Unmarshal}, + + {TPM_CC_CertifyCreation, "TPM2_CertifyCreation", + (MarshalInFunction_t)TSS_CertifyCreation_In_Marshalu, + (UnmarshalOutFunction_t)TSS_CertifyCreation_Out_Unmarshalu, + (UnmarshalInFunction_t)CertifyCreation_In_Unmarshal}, + + {TPM_CC_Quote, "TPM2_Quote", + (MarshalInFunction_t)TSS_Quote_In_Marshalu, + (UnmarshalOutFunction_t)TSS_Quote_Out_Unmarshalu, + (UnmarshalInFunction_t)Quote_In_Unmarshal}, + + {TPM_CC_GetSessionAuditDigest, "TPM2_GetSessionAuditDigest", + (MarshalInFunction_t)TSS_GetSessionAuditDigest_In_Marshalu, + (UnmarshalOutFunction_t)TSS_GetSessionAuditDigest_Out_Unmarshalu, + (UnmarshalInFunction_t)GetSessionAuditDigest_In_Unmarshal}, + + {TPM_CC_GetCommandAuditDigest, "TPM2_GetCommandAuditDigest", + (MarshalInFunction_t)TSS_GetCommandAuditDigest_In_Marshalu, + (UnmarshalOutFunction_t)TSS_GetCommandAuditDigest_Out_Unmarshalu, + (UnmarshalInFunction_t)GetCommandAuditDigest_In_Unmarshal}, + + {TPM_CC_GetTime, "TPM2_GetTime", + (MarshalInFunction_t)TSS_GetTime_In_Marshalu, + (UnmarshalOutFunction_t)TSS_GetTime_Out_Unmarshalu, + (UnmarshalInFunction_t)GetTime_In_Unmarshal}, + + {TPM_CC_Commit, "TPM2_Commit", + (MarshalInFunction_t)TSS_Commit_In_Marshalu, + (UnmarshalOutFunction_t)TSS_Commit_Out_Unmarshalu, + (UnmarshalInFunction_t)Commit_In_Unmarshal}, + + {TPM_CC_EC_Ephemeral, "TPM2_EC_Ephemeral", + (MarshalInFunction_t)TSS_EC_Ephemeral_In_Marshalu, + (UnmarshalOutFunction_t)TSS_EC_Ephemeral_Out_Unmarshalu, + (UnmarshalInFunction_t)EC_Ephemeral_In_Unmarshal}, + + {TPM_CC_VerifySignature, "TPM2_VerifySignature", + (MarshalInFunction_t)TSS_VerifySignature_In_Marshalu, + (UnmarshalOutFunction_t)TSS_VerifySignature_Out_Unmarshalu, + (UnmarshalInFunction_t)VerifySignature_In_Unmarshal}, + + {TPM_CC_Sign, "TPM2_Sign", + (MarshalInFunction_t)TSS_Sign_In_Marshalu, + (UnmarshalOutFunction_t)TSS_Sign_Out_Unmarshalu, + (UnmarshalInFunction_t)Sign_In_Unmarshal}, + + {TPM_CC_SetCommandCodeAuditStatus, "TPM2_SetCommandCodeAuditStatus", + (MarshalInFunction_t)TSS_SetCommandCodeAuditStatus_In_Marshalu, + NULL, + (UnmarshalInFunction_t)SetCommandCodeAuditStatus_In_Unmarshal}, + + {TPM_CC_PCR_Extend, "TPM2_PCR_Extend", + (MarshalInFunction_t)TSS_PCR_Extend_In_Marshalu, + NULL, + (UnmarshalInFunction_t)PCR_Extend_In_Unmarshal}, + + {TPM_CC_PCR_Event, "TPM2_PCR_Event", + (MarshalInFunction_t)TSS_PCR_Event_In_Marshalu, + (UnmarshalOutFunction_t)TSS_PCR_Event_Out_Unmarshalu, + (UnmarshalInFunction_t)PCR_Event_In_Unmarshal}, + + {TPM_CC_PCR_Read, "TPM2_PCR_Read", + (MarshalInFunction_t)TSS_PCR_Read_In_Marshalu, + (UnmarshalOutFunction_t)TSS_PCR_Read_Out_Unmarshalu, + (UnmarshalInFunction_t)PCR_Read_In_Unmarshal}, + + {TPM_CC_PCR_Allocate, "TPM2_PCR_Allocate", + (MarshalInFunction_t)TSS_PCR_Allocate_In_Marshalu, + (UnmarshalOutFunction_t)TSS_PCR_Allocate_Out_Unmarshalu, + (UnmarshalInFunction_t)PCR_Allocate_In_Unmarshal}, + + {TPM_CC_PCR_SetAuthPolicy, "TPM2_PCR_SetAuthPolicy", + (MarshalInFunction_t)TSS_PCR_SetAuthPolicy_In_Marshalu, + NULL, + (UnmarshalInFunction_t)PCR_SetAuthPolicy_In_Unmarshal}, + + {TPM_CC_PCR_SetAuthValue, "TPM2_PCR_SetAuthValue", + (MarshalInFunction_t)TSS_PCR_SetAuthValue_In_Marshalu, + NULL, + (UnmarshalInFunction_t)PCR_SetAuthValue_In_Unmarshal}, + + {TPM_CC_PCR_Reset, "TPM2_PCR_Reset", + (MarshalInFunction_t)TSS_PCR_Reset_In_Marshalu, + NULL, + (UnmarshalInFunction_t)PCR_Reset_In_Unmarshal}, + + {TPM_CC_PolicySigned, "TPM2_PolicySigned", + (MarshalInFunction_t)TSS_PolicySigned_In_Marshalu, + (UnmarshalOutFunction_t)TSS_PolicySigned_Out_Unmarshalu, + (UnmarshalInFunction_t)PolicySigned_In_Unmarshal}, + + {TPM_CC_PolicySecret, "TPM2_PolicySecret", + (MarshalInFunction_t)TSS_PolicySecret_In_Marshalu, + (UnmarshalOutFunction_t)TSS_PolicySecret_Out_Unmarshalu, + (UnmarshalInFunction_t)PolicySecret_In_Unmarshal}, + + {TPM_CC_PolicyTicket, "TPM2_PolicyTicket", + (MarshalInFunction_t)TSS_PolicyTicket_In_Marshalu, + NULL, + (UnmarshalInFunction_t)PolicyTicket_In_Unmarshal}, + + {TPM_CC_PolicyOR, "TPM2_PolicyOR", + (MarshalInFunction_t)TSS_PolicyOR_In_Marshalu, + NULL, + (UnmarshalInFunction_t)PolicyOR_In_Unmarshal}, + + {TPM_CC_PolicyPCR, "TPM2_PolicyPCR", + (MarshalInFunction_t)TSS_PolicyPCR_In_Marshalu, + NULL, + (UnmarshalInFunction_t)PolicyPCR_In_Unmarshal}, + + {TPM_CC_PolicyLocality, "TPM2_PolicyLocality", + (MarshalInFunction_t)TSS_PolicyLocality_In_Marshalu, + NULL, + (UnmarshalInFunction_t)PolicyLocality_In_Unmarshal}, + + {TPM_CC_PolicyNV, "TPM2_PolicyNV", + (MarshalInFunction_t)TSS_PolicyNV_In_Marshalu, + NULL, + (UnmarshalInFunction_t)PolicyNV_In_Unmarshal}, + + {TPM_CC_PolicyAuthorizeNV, "TPM2_PolicyAuthorizeNV", + (MarshalInFunction_t)TSS_PolicyAuthorizeNV_In_Marshalu, + NULL, + (UnmarshalInFunction_t)PolicyAuthorizeNV_In_Unmarshal}, + + {TPM_CC_PolicyCounterTimer, "TPM2_PolicyCounterTimer", + (MarshalInFunction_t)TSS_PolicyCounterTimer_In_Marshalu, + NULL, + (UnmarshalInFunction_t)PolicyCounterTimer_In_Unmarshal}, + + {TPM_CC_PolicyCommandCode, "TPM2_PolicyCommandCode", + (MarshalInFunction_t)TSS_PolicyCommandCode_In_Marshalu, + NULL, + (UnmarshalInFunction_t)PolicyCommandCode_In_Unmarshal}, + + {TPM_CC_PolicyPhysicalPresence, "TPM2_PolicyPhysicalPresence", + (MarshalInFunction_t)TSS_PolicyPhysicalPresence_In_Marshalu, + NULL, + (UnmarshalInFunction_t)PolicyPhysicalPresence_In_Unmarshal}, + + {TPM_CC_PolicyCpHash, "TPM2_PolicyCpHash", + (MarshalInFunction_t)TSS_PolicyCpHash_In_Marshalu, + NULL, + (UnmarshalInFunction_t)PolicyCpHash_In_Unmarshal}, + + {TPM_CC_PolicyNameHash, "TPM2_PolicyNameHash", + (MarshalInFunction_t)TSS_PolicyNameHash_In_Marshalu, + NULL, + (UnmarshalInFunction_t)PolicyNameHash_In_Unmarshal}, + + {TPM_CC_PolicyDuplicationSelect, "TPM2_PolicyDuplicationSelect", + (MarshalInFunction_t)TSS_PolicyDuplicationSelect_In_Marshalu, + NULL, + (UnmarshalInFunction_t)PolicyDuplicationSelect_In_Unmarshal}, + + {TPM_CC_PolicyAuthorize, "TPM2_PolicyAuthorize", + (MarshalInFunction_t)TSS_PolicyAuthorize_In_Marshalu, + NULL, + (UnmarshalInFunction_t)PolicyAuthorize_In_Unmarshal}, + + {TPM_CC_PolicyAuthValue, "TPM2_PolicyAuthValue", + (MarshalInFunction_t)TSS_PolicyAuthValue_In_Marshalu, + NULL, + (UnmarshalInFunction_t)PolicyAuthValue_In_Unmarshal}, + + {TPM_CC_PolicyPassword, "TPM2_PolicyPassword", + (MarshalInFunction_t)TSS_PolicyPassword_In_Marshalu, + NULL, + (UnmarshalInFunction_t)PolicyPassword_In_Unmarshal}, + + {TPM_CC_PolicyGetDigest, "TPM2_PolicyGetDigest", + (MarshalInFunction_t)TSS_PolicyGetDigest_In_Marshalu, + (UnmarshalOutFunction_t)TSS_PolicyGetDigest_Out_Unmarshalu, + (UnmarshalInFunction_t)PolicyGetDigest_In_Unmarshal}, + + {TPM_CC_PolicyNvWritten, "TPM2_PolicyNvWritten", + (MarshalInFunction_t)TSS_PolicyNvWritten_In_Marshalu, + NULL, + (UnmarshalInFunction_t)PolicyNvWritten_In_Unmarshal}, + + {TPM_CC_PolicyTemplate, "TPM2_PolicyTemplate", + (MarshalInFunction_t)TSS_PolicyTemplate_In_Marshalu, + NULL, + (UnmarshalInFunction_t)PolicyTemplate_In_Unmarshal}, + + {TPM_CC_CreatePrimary, "TPM2_CreatePrimary", + (MarshalInFunction_t)TSS_CreatePrimary_In_Marshalu, + (UnmarshalOutFunction_t)TSS_CreatePrimary_Out_Unmarshalu, + (UnmarshalInFunction_t)CreatePrimary_In_Unmarshal}, + + {TPM_CC_HierarchyControl, "TPM2_HierarchyControl", + (MarshalInFunction_t)TSS_HierarchyControl_In_Marshalu, + NULL, + (UnmarshalInFunction_t)HierarchyControl_In_Unmarshal}, + + {TPM_CC_SetPrimaryPolicy, "TPM2_SetPrimaryPolicy", + (MarshalInFunction_t)TSS_SetPrimaryPolicy_In_Marshalu, + NULL, + (UnmarshalInFunction_t)SetPrimaryPolicy_In_Unmarshal}, + + {TPM_CC_ChangePPS, "TPM2_ChangePPS", + (MarshalInFunction_t)TSS_ChangePPS_In_Marshalu, + NULL, + (UnmarshalInFunction_t)ChangePPS_In_Unmarshal}, + + {TPM_CC_ChangeEPS, "TPM2_ChangeEPS", + (MarshalInFunction_t)TSS_ChangeEPS_In_Marshalu, + NULL, + (UnmarshalInFunction_t)ChangeEPS_In_Unmarshal}, + + {TPM_CC_Clear, "TPM2_Clear", + (MarshalInFunction_t)TSS_Clear_In_Marshalu, + NULL, + (UnmarshalInFunction_t)Clear_In_Unmarshal}, + + {TPM_CC_ClearControl, "TPM2_ClearControl", + (MarshalInFunction_t)TSS_ClearControl_In_Marshalu, + NULL, + (UnmarshalInFunction_t)ClearControl_In_Unmarshal}, + + {TPM_CC_HierarchyChangeAuth, "TPM2_HierarchyChangeAuth", + (MarshalInFunction_t)TSS_HierarchyChangeAuth_In_Marshalu, + NULL, + (UnmarshalInFunction_t)HierarchyChangeAuth_In_Unmarshal}, + + {TPM_CC_DictionaryAttackLockReset, "TPM2_DictionaryAttackLockReset", + (MarshalInFunction_t)TSS_DictionaryAttackLockReset_In_Marshalu, + NULL, + (UnmarshalInFunction_t)DictionaryAttackLockReset_In_Unmarshal}, + + {TPM_CC_DictionaryAttackParameters, "TPM2_DictionaryAttackParameters", + (MarshalInFunction_t)TSS_DictionaryAttackParameters_In_Marshalu, + NULL, + (UnmarshalInFunction_t)DictionaryAttackParameters_In_Unmarshal}, + + {TPM_CC_PP_Commands, "TPM2_PP_Commands", + (MarshalInFunction_t)TSS_PP_Commands_In_Marshalu, + NULL, + (UnmarshalInFunction_t)PP_Commands_In_Unmarshal}, + + {TPM_CC_SetAlgorithmSet, "TPM2_SetAlgorithmSet", + (MarshalInFunction_t)TSS_SetAlgorithmSet_In_Marshalu, + NULL, + (UnmarshalInFunction_t)SetAlgorithmSet_In_Unmarshal}, + + {TPM_CC_ContextSave, "TPM2_ContextSave", + (MarshalInFunction_t)TSS_ContextSave_In_Marshalu, + (UnmarshalOutFunction_t)TSS_ContextSave_Out_Unmarshalu, + (UnmarshalInFunction_t)ContextSave_In_Unmarshal}, + + {TPM_CC_ContextLoad, "TPM2_ContextLoad", + (MarshalInFunction_t)TSS_ContextLoad_In_Marshalu, + (UnmarshalOutFunction_t)TSS_ContextLoad_Out_Unmarshalu, + (UnmarshalInFunction_t)ContextLoad_In_Unmarshal}, + + {TPM_CC_FlushContext, "TPM2_FlushContext", + (MarshalInFunction_t)TSS_FlushContext_In_Marshalu, + NULL, + (UnmarshalInFunction_t)FlushContext_In_Unmarshal}, + + {TPM_CC_EvictControl, "TPM2_EvictControl", + (MarshalInFunction_t)TSS_EvictControl_In_Marshalu, + NULL, + (UnmarshalInFunction_t)EvictControl_In_Unmarshal}, + + {TPM_CC_ReadClock, "TPM2_ReadClock", + NULL, + (UnmarshalOutFunction_t)TSS_ReadClock_Out_Unmarshalu, + NULL}, + + {TPM_CC_ClockSet, "TPM2_ClockSet", + (MarshalInFunction_t)TSS_ClockSet_In_Marshalu, + NULL, + (UnmarshalInFunction_t)ClockSet_In_Unmarshal}, + + {TPM_CC_ClockRateAdjust, "TPM2_ClockRateAdjust", + (MarshalInFunction_t)TSS_ClockRateAdjust_In_Marshalu, + NULL, + (UnmarshalInFunction_t)ClockRateAdjust_In_Unmarshal}, + + {TPM_CC_GetCapability, "TPM2_GetCapability", + (MarshalInFunction_t)TSS_GetCapability_In_Marshalu, + (UnmarshalOutFunction_t)TSS_GetCapability_Out_Unmarshalu, + (UnmarshalInFunction_t)GetCapability_In_Unmarshal}, + + {TPM_CC_TestParms, "TPM2_TestParms", + (MarshalInFunction_t)TSS_TestParms_In_Marshalu, + NULL, + (UnmarshalInFunction_t)TestParms_In_Unmarshal}, + + {TPM_CC_NV_DefineSpace, "TPM2_NV_DefineSpace", + (MarshalInFunction_t)TSS_NV_DefineSpace_In_Marshalu, + NULL, + (UnmarshalInFunction_t)NV_DefineSpace_In_Unmarshal}, + + {TPM_CC_NV_UndefineSpace, "TPM2_NV_UndefineSpace", + (MarshalInFunction_t)TSS_NV_UndefineSpace_In_Marshalu, + NULL, + (UnmarshalInFunction_t)NV_UndefineSpace_In_Unmarshal}, + + {TPM_CC_NV_UndefineSpaceSpecial, "TPM2_NV_UndefineSpaceSpecial", + (MarshalInFunction_t)TSS_NV_UndefineSpaceSpecial_In_Marshalu, + NULL, + (UnmarshalInFunction_t)NV_UndefineSpaceSpecial_In_Unmarshal}, + + {TPM_CC_NV_ReadPublic, "TPM2_NV_ReadPublic", + (MarshalInFunction_t)TSS_NV_ReadPublic_In_Marshalu, + (UnmarshalOutFunction_t)TSS_NV_ReadPublic_Out_Unmarshalu, + (UnmarshalInFunction_t)NV_ReadPublic_In_Unmarshal}, + + {TPM_CC_NV_Write, "TPM2_NV_Write", + (MarshalInFunction_t)TSS_NV_Write_In_Marshalu, + NULL, + (UnmarshalInFunction_t)NV_Write_In_Unmarshal}, + + {TPM_CC_NV_Increment, "TPM2_NV_Increment", + (MarshalInFunction_t)TSS_NV_Increment_In_Marshalu, + NULL, + (UnmarshalInFunction_t)NV_Increment_In_Unmarshal}, + + {TPM_CC_NV_Extend, "TPM2_NV_Extend", + (MarshalInFunction_t)TSS_NV_Extend_In_Marshalu, + NULL, + (UnmarshalInFunction_t)NV_Extend_In_Unmarshal}, + + {TPM_CC_NV_SetBits, "TPM2_NV_SetBits", + (MarshalInFunction_t)TSS_NV_SetBits_In_Marshalu, + NULL, + (UnmarshalInFunction_t)NV_SetBits_In_Unmarshal}, + + {TPM_CC_NV_WriteLock, "TPM2_NV_WriteLock", + (MarshalInFunction_t)TSS_NV_WriteLock_In_Marshalu, + NULL, + (UnmarshalInFunction_t)NV_WriteLock_In_Unmarshal}, + + {TPM_CC_NV_GlobalWriteLock, "TPM2_NV_GlobalWriteLock", + (MarshalInFunction_t)TSS_NV_GlobalWriteLock_In_Marshalu, + NULL, + (UnmarshalInFunction_t)NV_GlobalWriteLock_In_Unmarshal}, + + {TPM_CC_NV_Read, "TPM2_NV_Read", + (MarshalInFunction_t)TSS_NV_Read_In_Marshalu, + (UnmarshalOutFunction_t)TSS_NV_Read_Out_Unmarshalu, + (UnmarshalInFunction_t)NV_Read_In_Unmarshal}, + + {TPM_CC_NV_ReadLock, "TPM2_NV_ReadLock", + (MarshalInFunction_t)TSS_NV_ReadLock_In_Marshalu, + NULL, + (UnmarshalInFunction_t)NV_ReadLock_In_Unmarshal}, + + {TPM_CC_NV_ChangeAuth, "TPM2_NV_ChangeAuth", + (MarshalInFunction_t)TSS_NV_ChangeAuth_In_Marshalu, + NULL, + (UnmarshalInFunction_t)NV_ChangeAuth_In_Unmarshal}, + + {TPM_CC_NV_Certify, "TPM2_NV_Certify", + (MarshalInFunction_t)TSS_NV_Certify_In_Marshalu, + (UnmarshalOutFunction_t)TSS_NV_Certify_Out_Unmarshalu, + (UnmarshalInFunction_t)NV_Certify_In_Unmarshal}, +#ifdef TPM_TPM20 + {NTC2_CC_PreConfig,"NTC2_CC_PreConfig", + (MarshalInFunction_t)TSS_NTC2_PreConfig_In_Marshalu, + NULL, + (UnmarshalInFunction_t)TSS_NTC2_PreConfig_In_Unmarshalu}, + + {NTC2_CC_LockPreConfig,"NTC2_CC_LockPreConfig", + NULL, + NULL, + NULL}, + + {NTC2_CC_GetConfig,"NTC2_CC_GetConfig", + NULL, + (UnmarshalOutFunction_t)TSS_NTC2_GetConfig_Out_Unmarshalu, + NULL} +#endif +}; + +/* TSS_MarshalTable_Process() indexes into the command marshal table, and saves the marshal and + unmarshal functions */ + +static TPM_RC TSS_MarshalTable_Process(TSS_AUTH_CONTEXT *tssAuthContext, + TPM_CC commandCode) +{ + TPM_RC rc = 0; + size_t index; + int found = FALSE; + + /* get the command index in the dispatch table */ + for (index = 0 ; index < (sizeof(marshalTable) / sizeof(MARSHAL_TABLE)) ; (index)++) { + if (marshalTable[index].commandCode == commandCode) { + found = TRUE; + break; + } + } + if (found) { + tssAuthContext->commandCode = commandCode; + tssAuthContext->commandText = marshalTable[index].commandText; + tssAuthContext->marshalInFunction = marshalTable[index].marshalInFunction; + tssAuthContext->unmarshalOutFunction = marshalTable[index].unmarshalOutFunction; + tssAuthContext->unmarshalInFunction = marshalTable[index].unmarshalInFunction; + } + else { + if (tssVerbose) printf("TSS_MarshalTable_Process: " + "commandCode %08x not found in marshal table\n", + commandCode); + rc = TSS_RC_COMMAND_UNIMPLEMENTED; + } + return rc; +} + +/* TSS_Marshal() marshals the input parameters into the TSS Authorization context. + + It also sets other member of the context in preparation for the rest of the sequence. +*/ + +TPM_RC TSS_Marshal(TSS_AUTH_CONTEXT *tssAuthContext, + COMMAND_PARAMETERS *in, + TPM_CC commandCode) +{ + TPM_RC rc = 0; + TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS; /* default until sessions are added */ + uint8_t *buffer; /* for marshaling */ + uint8_t *bufferu; /* for test unmarshaling */ + uint32_t size; + + /* index from command code to table and save items for this command */ + if (rc == 0) { + rc = TSS_MarshalTable_Process(tssAuthContext, commandCode); + } + /* get the number of command and response handles from the TPM table */ + if (rc == 0) { + tssAuthContext->tpmCommandIndex = CommandCodeToCommandIndex(commandCode); + if (tssAuthContext->tpmCommandIndex == UNIMPLEMENTED_COMMAND_INDEX) { + if (tssVerbose) printf("TSS_Marshal: " + "commandCode %08x not found in command attributes table\n", + commandCode); + rc = TSS_RC_COMMAND_UNIMPLEMENTED; + } + } + if (rc == 0) { + tssAuthContext->commandHandleCount = + getCommandHandleCount(tssAuthContext->tpmCommandIndex); + tssAuthContext->responseHandleCount = + getresponseHandleCount(tssAuthContext->tpmCommandIndex); + } + if (rc == 0) { + /* make a copy of the command buffer and size since the marshal functions move them */ + buffer = tssAuthContext->commandBuffer; + size = sizeof(tssAuthContext->commandBuffer); + /* marshal header, preliminary tag and command size */ + rc = TSS_TPMI_ST_COMMAND_TAG_Marshalu(&tag, &tssAuthContext->commandSize, &buffer, &size); + } + if (rc == 0) { + uint32_t commandSize = tssAuthContext->commandSize; + rc = TSS_UINT32_Marshalu(&commandSize, &tssAuthContext->commandSize, &buffer, &size); + } + if (rc == 0) { + rc = TSS_TPM_CC_Marshalu(&commandCode, &tssAuthContext->commandSize, &buffer, &size); + } + if (rc == 0) { + /* save pointer to marshaled data for test unmarshal */ + bufferu = buffer + + tssAuthContext->commandHandleCount * sizeof(TPM_HANDLE); + /* if there is a marshal function */ + if (tssAuthContext->marshalInFunction != NULL) { + /* if there is a structure to marshal */ + if (in != NULL) { + rc = tssAuthContext->marshalInFunction(in, &tssAuthContext->commandSize, + &buffer, &size); + } + /* caller error, no structure supplied to marshal */ + else { + if (tssVerbose) + printf("TSS_Marshal: Command %08x requires command parameter structure\n", + commandCode); + rc = TSS_RC_IN_PARAMETER; + } + } + /* if there is no marshal function */ + else { + /* caller error, supplied structure but there is no marshal function */ + if (in != NULL) { + if (tssVerbose) + printf("TSS_Marshal: Command %08x does not take command parameter structure\n", + commandCode); + rc = TSS_RC_IN_PARAMETER; + } + /* no marshal function and no command parameter structure is OK */ + } + } + /* unmarshal to validate the input parameters */ + if ((rc == 0) && (tssAuthContext->unmarshalInFunction != NULL)) { + COMMAND_PARAMETERS *target = NULL; + TPM_HANDLE handles[MAX_HANDLE_NUM]; + if (rc == 0) { + rc = TSS_Malloc((unsigned char **)&target, + sizeof(COMMAND_PARAMETERS)); /* freed @1 */ + } + if (rc == 0) { + size = sizeof(tssAuthContext->commandBuffer) - + (tssAuthContext->commandHandleCount * sizeof(TPM_HANDLE)); + rc = tssAuthContext->unmarshalInFunction(target, &bufferu, &size, handles); + if ((rc != 0) && tssVerbose) { + printf("TSS_Marshal: Invalid command parameter\n"); + } + } + free(target); /* @1 */ + } + /* back fill the correct commandSize */ + if (rc == 0) { + uint16_t written; /* dummy */ + uint32_t commandSize = tssAuthContext->commandSize; + buffer = tssAuthContext->commandBuffer + sizeof(TPMI_ST_COMMAND_TAG); + TSS_UINT32_Marshalu(&commandSize, &written, &buffer, NULL); + } + /* record the interim cpBuffer and cpBufferSize before adding authorizations */ + if (rc == 0) { + uint32_t notCpBufferSize; + + /* cpBuffer does not include the header and handles */ + notCpBufferSize = sizeof(TPMI_ST_COMMAND_TAG) + sizeof (uint32_t) + sizeof(TPM_CC) + + (sizeof(TPM_HANDLE) * tssAuthContext->commandHandleCount); + + tssAuthContext->cpBuffer = tssAuthContext->commandBuffer + notCpBufferSize; + tssAuthContext->cpBufferSize = tssAuthContext->commandSize - notCpBufferSize; + } + return rc; +} + +/* TSS_Unmarshal() unmarshals the response parameter. + + It returns an error if either there is no unmarshal function and out is not NULL or if there is + an unmarshal function and out is not NULL. + + If there is no unmarshal function and out is NULL, the function is a noop. +*/ + +TPM_RC TSS_Unmarshal(TSS_AUTH_CONTEXT *tssAuthContext, + RESPONSE_PARAMETERS *out) +{ + TPM_RC rc = 0; + TPM_ST tag; + uint8_t *buffer; + uint32_t size; + + /* if there is an unmarshal function */ + if (tssAuthContext->unmarshalOutFunction != NULL) { + /* if there is a structure to unmarshal */ + if (out != NULL) { + if (rc == 0) { + /* get the response tag, determines whether there is a response parameterSize to + unmarshal */ + buffer = tssAuthContext->responseBuffer; + size = tssAuthContext->responseSize; + rc = TSS_TPM_ST_Unmarshalu(&tag, &buffer, &size); + } + if (rc == 0) { + /* move the buffer and size past the header */ + buffer = tssAuthContext->responseBuffer + + sizeof(TPM_ST) + sizeof(uint32_t) + sizeof(TPM_RC); + size = tssAuthContext->responseSize - + (sizeof(TPM_ST) + sizeof(uint32_t) + sizeof(TPM_RC)); + rc = tssAuthContext->unmarshalOutFunction(out, tag, &buffer, &size); + } + } + /* caller error, no structure supplied to unmarshal */ + else { + if (tssVerbose) + printf("TSS_Unmarshal: Command %08x requires response parameter structure\n", + tssAuthContext->commandCode); + rc = TSS_RC_OUT_PARAMETER; + } + } + /* if there is no unmarshal function */ + else { + /* caller error, structure supplied but no unmarshal function */ + if (out != NULL) { + if (tssVerbose) + printf("TSS_Unmarshal: Command %08x does not take response parameter structure\n", + tssAuthContext->commandCode); + rc = TSS_RC_OUT_PARAMETER; + } + /* no unmarshal function and no response parameter structure is OK */ + } + return rc; +} + +/* TSS_SetCmdAuths() adds a list of TPMS_AUTH_COMMAND structures to the command buffer. + + The arguments are a NULL terminated list of TPMS_AUTH_COMMAND * structures. + */ + +TPM_RC TSS_SetCmdAuths(TSS_AUTH_CONTEXT *tssAuthContext, ...) +{ + TPM_RC rc = 0; + va_list ap; + uint16_t authorizationSize; /* does not include 4 bytes of size */ + TPMS_AUTH_COMMAND *authCommand = NULL; + int done; + uint32_t cpBufferSize; + uint8_t *cpBuffer; + uint8_t *buffer; + + /* calculate size of authorization area */ + done = FALSE; + authorizationSize = 0; + va_start(ap, tssAuthContext); + while ((rc == 0) && !done){ + authCommand = va_arg(ap, TPMS_AUTH_COMMAND *); + if (authCommand != NULL) { + rc = TSS_TPMS_AUTH_COMMAND_Marshalu(authCommand, &authorizationSize, NULL, NULL); + } + else { + done = TRUE; + } + } + va_end(ap); + /* command called with authorizations */ + if (authorizationSize != 0) { + /* back fill the tag TPM_ST_SESSIONS */ + if (rc == 0) { + uint16_t written = 0; /* dummy */ + TPMI_ST_COMMAND_TAG tag = TPM_ST_SESSIONS; + buffer = tssAuthContext->commandBuffer; + TSS_TPMI_ST_COMMAND_TAG_Marshalu(&tag, &written, &buffer, NULL); + } + /* get cpBuffer, command parameters */ + if (rc == 0) { + rc = TSS_GetCpBuffer(tssAuthContext, &cpBufferSize, &cpBuffer); + } + /* new authorization area range check, will cpBuffer move overflow */ + if (rc == 0) { + if (cpBuffer + + cpBufferSize + + sizeof (uint32_t) + /* authorizationSize */ + authorizationSize /* authorization area */ + > tssAuthContext->commandBuffer + sizeof(tssAuthContext->commandBuffer)) { + + if (tssVerbose) + printf("TSS_SetCmdAuths: Command authorizations overflow command buffer\n"); + rc = TSS_RC_INSUFFICIENT_BUFFER; + } + } + /* move the cpBuffer to make space for the authorization area and its size */ + if (rc == 0) { + memmove(cpBuffer + sizeof (uint32_t) + authorizationSize, /* to here */ + cpBuffer, /* from here */ + cpBufferSize); + } + /* marshal the authorizationSize area, where cpBuffer was before move */ + if (rc == 0) { + uint32_t authorizationSize32 = authorizationSize; + uint16_t written; /* dummy */ + TSS_UINT32_Marshalu(&authorizationSize32, &written, &cpBuffer, NULL); + } + /* marshal the command authorization areas */ + done = FALSE; + authorizationSize = 0; + va_start(ap, tssAuthContext); + while ((rc == 0) && !done){ + authCommand = va_arg(ap, TPMS_AUTH_COMMAND *); + if (authCommand != NULL) { + rc = TSS_TPMS_AUTH_COMMAND_Marshalu(authCommand, &authorizationSize, &cpBuffer, NULL); + tssAuthContext->authCount++; /* count the number of authorizations for the + response */ + } + else { + done = TRUE; + } + } + va_end(ap); + if (rc == 0) { + uint16_t written; /* dummy */ + uint32_t commandSize; + /* mark cpBuffer new location, size doesn't change */ + tssAuthContext->cpBuffer += sizeof (uint32_t) + authorizationSize; + /* record command stream used size */ + tssAuthContext->commandSize += sizeof (uint32_t) + authorizationSize; + /* back fill the correct commandSize */ + buffer = tssAuthContext->commandBuffer + sizeof(TPMI_ST_COMMAND_TAG); + commandSize = tssAuthContext->commandSize; + TSS_UINT32_Marshalu(&commandSize, &written, &buffer, NULL); + } + } + return rc; +} + +/* TSS_GetRspAuths() unmarshals a response buffer into a NULL terminated list of TPMS_AUTH_RESPONSE + structures. This should not be called if the TPM returned a non-success response code. + + Returns an error if the number of response auths requested is not equal to the number of command + auths, including zero. + + If the response tag is not TPM_ST_SESSIONS, the function is a noop (except for error checking). + */ + +TPM_RC TSS_GetRspAuths(TSS_AUTH_CONTEXT *tssAuthContext, ...) +{ + TPM_RC rc = 0; + va_list ap; + TPMS_AUTH_RESPONSE *authResponse = NULL; + uint32_t size; + uint8_t *buffer; + TPM_ST tag; + int done; + uint16_t authCount = 0; /* authorizations in response */ + uint32_t parameterSize; + + /* unmarshal the response tag */ + if (rc == 0) { + size = tssAuthContext->responseSize; + buffer = tssAuthContext->responseBuffer; + rc = TSS_TPM_ST_Unmarshalu(&tag, &buffer, &size); + } + /* check that the tag indicates that there are sessions */ + if ((rc == 0) && (tag == TPM_ST_SESSIONS)) { + /* offset the buffer past the header and handles, and get the response parameterSize */ + if (rc == 0) { + uint32_t offsetSize = sizeof(TPM_ST) + + sizeof (uint32_t) + sizeof(TPM_RC) + + (sizeof(TPM_HANDLE) * tssAuthContext->responseHandleCount); + buffer = tssAuthContext->responseBuffer + offsetSize; + size = tssAuthContext->responseSize - offsetSize; + rc = TSS_UINT32_Unmarshalu(¶meterSize, &buffer, &size); + } + if (rc == 0) { + if (parameterSize > (uint32_t)size) { + if (tssVerbose) printf("TSS_GetRspAuths: Invalid response parameterSize %u\n", + parameterSize); + rc = TSS_RC_MALFORMED_RESPONSE; + } + } + if (rc == 0) { + /* index past the response parameters to the authorization area */ + buffer += parameterSize; + size -= parameterSize; + } + /* unmarshal the response authorization area */ + done = FALSE; + va_start(ap, tssAuthContext); + while ((rc == 0) && !done){ + authResponse = va_arg(ap, TPMS_AUTH_RESPONSE *); + if (authResponse != NULL) { + rc = TSS_TPMS_AUTH_RESPONSE_Unmarshalu(authResponse, &buffer, &size); + authCount++; + } + else { + done = TRUE; + } + } + va_end(ap); + /* check for extra bytes at the end of the response */ + if (rc == 0) { + if (size != 0) { + if (tssVerbose) + printf("TSS_GetRspAuths: Extra bytes at the end of response authorizations\n"); + rc = TSS_RC_MALFORMED_RESPONSE; + } + } + } + /* check that the same number was requested as were sent in the command. Check for zero if not + TPM_ST_SESSIONS */ + if (rc == 0) { + if (tssAuthContext->authCount != authCount) { + if (tssVerbose) + printf("TSS_GetRspAuths: " + "Response authorizations requested does not equal number in command\n"); + rc = TSS_RC_MALFORMED_RESPONSE; + } + } + return rc; +} + +/* TSS_GetCommandDecryptParam() returns the size and pointer to the first marshaled TPM2B */ + +TPM_RC TSS_GetCommandDecryptParam(TSS_AUTH_CONTEXT *tssAuthContext, + uint32_t *decryptParamSize, + uint8_t **decryptParamBuffer) +{ + TPM_RC rc = 0; + /* the first parameter is the TPM2B */ + uint32_t cpBufferSize; + uint8_t *cpBuffer; + + if (rc == 0) { + rc = TSS_GetCpBuffer(tssAuthContext, &cpBufferSize, &cpBuffer); + } + /* extract contents of the first TPM2B */ + if (rc == 0) { + *decryptParamSize = ntohs(*(uint16_t *)cpBuffer); + *decryptParamBuffer = cpBuffer + sizeof(uint16_t); + } + /* sanity range check */ + if (rc == 0) { + if (((*decryptParamBuffer + *decryptParamSize) > + (tssAuthContext->commandBuffer + tssAuthContext->commandSize)) || + ((*decryptParamSize + sizeof(uint16_t) > tssAuthContext->cpBufferSize))) { + if (tssVerbose) printf("TSS_GetCommandDecryptParam: Malformed decrypt parameter " + "size %u cpBufferSize %u commandSize %u\n", + *decryptParamSize, tssAuthContext->cpBufferSize, + tssAuthContext->commandSize); + rc = TSS_RC_BAD_ENCRYPT_SIZE; + } + } + return rc; +} + +TPM_RC TSS_SetCommandDecryptParam(TSS_AUTH_CONTEXT *tssAuthContext, + uint32_t encryptParamSize, + uint8_t *encryptParamBuffer) +{ + TPM_RC rc = 0; + /* the first parameter is the TPM2B */ + uint32_t decryptParamSize; + uint8_t *decryptParamBuffer; + + if (rc == 0) { + rc = TSS_GetCommandDecryptParam(tssAuthContext, + &decryptParamSize, + &decryptParamBuffer); + } + /* the encrypt data overwrites the already marshaled data */ + if (rc == 0) { + if (decryptParamSize != encryptParamSize) { + if (tssVerbose) + printf("TSS_SetCommandDecryptParam: Different encrypt and decrypt size\n"); + rc = TSS_RC_BAD_ENCRYPT_SIZE; + } + } + /* skip the 2B size, copy the data */ + if (rc == 0) { + memcpy(decryptParamBuffer, encryptParamBuffer, encryptParamSize); + } + return rc; +} + +/* TSS_GetAuthRole() returns AUTH_NONE if the handle in the handle area cannot be an authorization + handle. */ + +AUTH_ROLE TSS_GetAuthRole(TSS_AUTH_CONTEXT *tssAuthContext, + size_t handleIndex) +{ + AUTH_ROLE authRole; + authRole = getCommandAuthRole(tssAuthContext->tpmCommandIndex, handleIndex); + return authRole; +} + +/* TSS_GetCommandHandle() gets the command handle at the index. Index is a zero based count, not a + byte count. + + Returns 0 if the index exceeds the number of handles. +*/ + +TPM_RC TSS_GetCommandHandle(TSS_AUTH_CONTEXT *tssAuthContext, + TPM_HANDLE *commandHandle, + size_t index) +{ + TPM_RC rc = 0; + uint8_t *buffer; + uint32_t size; + + + if (rc == 0) { + if (index >= tssAuthContext->commandHandleCount) { + if (tssVerbose) printf("TSS_GetCommandHandle: index %u too large for command\n", + (unsigned int)index); + rc = TSS_RC_BAD_HANDLE_NUMBER; + } + } + if (rc == 0) { + /* index into the command handle */ + buffer = tssAuthContext->commandBuffer + + sizeof(TPMI_ST_COMMAND_TAG) + sizeof (uint32_t) + sizeof(TPM_CC) + + (sizeof(TPM_HANDLE) * index); + size = sizeof(TPM_HANDLE); + rc = TSS_TPM_HANDLE_Unmarshalu(commandHandle, &buffer, &size); + } + return rc; +} + +/* TSS_GetRpBuffer() returns a pointer to the response parameter area. + + NOTE could move to execute so it only has to be done once. +*/ + +TPM_RC TSS_GetRpBuffer(TSS_AUTH_CONTEXT *tssAuthContext, + uint32_t *rpBufferSize, + uint8_t **rpBuffer) +{ + TPM_RC rc = 0; + TPM_ST tag; /* response tag */ + uint32_t offsetSize; /* to beginning of parameter area */ + uint32_t size; /* tmp for unmarshal */ + uint8_t *buffer; /* tmp for unmarshal */ + uint32_t parameterSize; /* response parameter (if sessions) */ + + /* unmarshal the response tag */ + if (rc == 0) { + /* offset to parameterSize or parameters */ + offsetSize = sizeof(TPM_ST) + sizeof (uint32_t) + sizeof(TPM_RC) + + (sizeof(TPM_HANDLE) * tssAuthContext->responseHandleCount); + + size = tssAuthContext->responseSize; + buffer = tssAuthContext->responseBuffer; + rc = TSS_TPM_ST_Unmarshalu(&tag, &buffer, &size); /* does value checking */ + } + /* no sessions -> no parameterSize */ + if (tag == TPM_ST_NO_SESSIONS) { + if (rc == 0) { + if (offsetSize > tssAuthContext->responseSize) { + if (tssVerbose) + printf("TSS_GetRpBuffer: offset %u past response buffer %u\n", + offsetSize, tssAuthContext->responseSize); + rc = TSS_RC_MALFORMED_RESPONSE; + } + } + if (rc == 0) { /* subtract now safe from above range check */ + *rpBufferSize = tssAuthContext->responseSize - offsetSize; + *rpBuffer = tssAuthContext->responseBuffer + offsetSize; + } + } + /* sessions -> parameterSize */ + else { + if (rc == 0) { + if ((offsetSize + sizeof(uint32_t)) > tssAuthContext->responseSize) { + if (tssVerbose) + printf("TSS_GetRpBuffer: offset %u past response buffer %u\n", + offsetSize, tssAuthContext->responseSize); + rc = TSS_RC_MALFORMED_RESPONSE; + } + } + if (rc == 0) { + size = tssAuthContext->responseSize - offsetSize; + buffer = tssAuthContext->responseBuffer + offsetSize; + rc = TSS_UINT32_Unmarshalu(¶meterSize, &buffer, &size); + } + if (rc == 0) { + offsetSize += sizeof(uint32_t); + *rpBufferSize = parameterSize; + *rpBuffer = tssAuthContext->responseBuffer + offsetSize; + } + } + return rc; +} + +/* TSS_GetResponseEncryptParam() returns the first TPM2B in the response area. + + The caller should ensure that the first response parameter is a TPM2B. +*/ + +TPM_RC TSS_GetResponseEncryptParam(TSS_AUTH_CONTEXT *tssAuthContext, + uint32_t *encryptParamSize, + uint8_t **encryptParamBuffer) +{ + TPM_RC rc = 0; + /* the first parameter is the TPM2B */ + uint32_t rpBufferSize; + uint8_t *rpBuffer; + + if (rc == 0) { + rc = TSS_GetRpBuffer(tssAuthContext, &rpBufferSize, &rpBuffer); + } + /* extract contents of the first TPM2B */ + if (rc == 0) { + *encryptParamSize = ntohs(*(uint16_t *)rpBuffer); + *encryptParamBuffer = rpBuffer + sizeof(uint16_t); + } + /* sanity range check */ + if (rc == 0) { + if (((*encryptParamBuffer + *encryptParamSize) > + (tssAuthContext->responseBuffer + tssAuthContext->responseSize)) || + ((*encryptParamSize + sizeof(uint16_t) > rpBufferSize))) { + if (tssVerbose) printf("TSS_GetResponseEncryptParam: Malformed encrypt parameter " + "size %u rpBufferSize %u responseSize %u\n", + *encryptParamSize, rpBufferSize, + tssAuthContext->responseSize); + rc = TSS_RC_MALFORMED_RESPONSE; + } + } + return rc; +} + +/* TSS_SetResponseDecryptParam() copies the decryptParamBuffer into the first TPM2B in the response + area. + + The caller should ensure that the first response parameter is a TPM2B. +*/ + +TPM_RC TSS_SetResponseDecryptParam(TSS_AUTH_CONTEXT *tssAuthContext, + uint32_t decryptParamSize, + uint8_t *decryptParamBuffer) +{ + TPM_RC rc = 0; + /* the first parameter is the TPM2B */ + uint32_t encryptParamSize; + uint8_t *encryptParamBuffer; + + if (rc == 0) { + rc = TSS_GetResponseEncryptParam(tssAuthContext, + &encryptParamSize, + &encryptParamBuffer); + } + /* the decrypt data overwrites the already marshaled data */ + if (rc == 0) { + if (decryptParamSize != encryptParamSize) { + if (tssVerbose) + printf("TSS_SetCommandDecryptParam: Different encrypt and decrypt size\n"); + rc = TSS_RC_BAD_ENCRYPT_SIZE; + } + } + /* skip the 2B size, copy the data */ + if (rc == 0) { + memcpy(encryptParamBuffer, decryptParamBuffer, decryptParamSize); + } + return rc; +} diff --git a/libstb/tss2/tssauth20.h b/libstb/tss2/tssauth20.h new file mode 100644 index 0000000..52b8403 --- /dev/null +++ b/libstb/tss2/tssauth20.h @@ -0,0 +1,86 @@ +/********************************************************************************/ +/* */ +/* TSS Authorization */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: tssauth20.h 1257 2018-06-27 20:52:08Z kgoldman $ */ +/* */ +/* (c) Copyright IBM Corporation 2018. */ +/* */ +/* All rights reserved. */ +/* */ +/* Redistribution and use in source and binary forms, with or without */ +/* modification, are permitted provided that the following conditions are */ +/* met: */ +/* */ +/* Redistributions of source code must retain the above copyright notice, */ +/* this list of conditions and the following disclaimer. */ +/* */ +/* 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. */ +/* */ +/* Neither the names of the IBM Corporation nor the names of its */ +/* contributors may be used to endorse or promote products derived from */ +/* this software without specific prior written permission. */ +/* */ +/* 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. */ +/********************************************************************************/ + +/* This is not a public header. It should not be used by applications. */ + +#ifndef TSS_AUTH20_H +#define TSS_AUTH20_H + +#include <ibmtss/tss.h> +#include "tssccattributes.h" + +TPM_RC TSS_Marshal(TSS_AUTH_CONTEXT *tssAuthContext, + COMMAND_PARAMETERS *in, + TPM_CC commandCode); + +TPM_RC TSS_Unmarshal(TSS_AUTH_CONTEXT *tssAuthContext, + RESPONSE_PARAMETERS *out); + +TPM_RC TSS_SetCmdAuths(TSS_AUTH_CONTEXT *tssAuthContext, ...); + +TPM_RC TSS_GetRspAuths(TSS_AUTH_CONTEXT *tssAuthContext, ...); + +TPM_RC TSS_GetCommandDecryptParam(TSS_AUTH_CONTEXT *tssAuthContext, + uint32_t *decryptParamSize, + uint8_t **decryptParamBuffer); + +TPM_RC TSS_SetCommandDecryptParam(TSS_AUTH_CONTEXT *tssAuthContext, + uint32_t encryptParamSize, + uint8_t *encryptParamBuffer); + +AUTH_ROLE TSS_GetAuthRole(TSS_AUTH_CONTEXT *tssAuthContext, + size_t handleIndex); + +TPM_RC TSS_GetCommandHandle(TSS_AUTH_CONTEXT *tssAuthContext, + TPM_HANDLE *commandHandle, + size_t index); + +TPM_RC TSS_GetRpBuffer(TSS_AUTH_CONTEXT *tssAuthContext, + uint32_t *rpBufferSize, + uint8_t **rpBuffer); + +TPM_RC TSS_GetResponseEncryptParam(TSS_AUTH_CONTEXT *tssAuthContext, + uint32_t *encryptParamSize, + uint8_t **encryptParamBuffer); + +TPM_RC TSS_SetResponseDecryptParam(TSS_AUTH_CONTEXT *tssAuthContext, + uint32_t decryptParamSize, + uint8_t *decryptParamBuffer); + +#endif diff --git a/libstb/tss2/tssccattributes.c b/libstb/tss2/tssccattributes.c new file mode 100644 index 0000000..a175687 --- /dev/null +++ b/libstb/tss2/tssccattributes.c @@ -0,0 +1,150 @@ +/********************************************************************************/ +/* */ +/* Command Code Attributes */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* */ +/* (c) Copyright IBM Corporation 2015 - 2019. */ +/* */ +/* All rights reserved. */ +/* */ +/* Redistribution and use in source and binary forms, with or without */ +/* modification, are permitted provided that the following conditions are */ +/* met: */ +/* */ +/* Redistributions of source code must retain the above copyright notice, */ +/* this list of conditions and the following disclaimer. */ +/* */ +/* 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. */ +/* */ +/* Neither the names of the IBM Corporation nor the names of its */ +/* contributors may be used to endorse or promote products derived from */ +/* this software without specific prior written permission. */ +/* */ +/* 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. */ +/********************************************************************************/ + +/* NOTE: This is a replica of CommandAttributeData.c, but endian independent. It must be kept in + sync with the TPM reference implementation. + +*/ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <inttypes.h> + +#include "tssccattributes.h" + +/* CommandCodeToCommandIndex() returns the index into the s_ccAttr table for the commandCode. + Returns UNIMPLEMENTED_COMMAND_INDEX if the command is unimplemented. +*/ + +/* NOTE: Marked as const function in header declaration */ + +COMMAND_INDEX CommandCodeToCommandIndex(TPM_CC commandCode) +{ + COMMAND_INDEX i; + + /* s_ccAttr has terminating 0x0000 command code and V */ + for (i = 0 ; (s_ccAttr[i].commandCode != 0) || (s_ccAttr[i].V != 0) ; i++) { + if (s_ccAttr[i].commandCode == commandCode) { + return i; + } + } + return UNIMPLEMENTED_COMMAND_INDEX; +} + +/* getCommandHandleCount() returns the number of command parameter handles */ + +/* NOTE: Marked as const function in header declaration */ + +uint32_t getCommandHandleCount(COMMAND_INDEX index) +{ + return s_ccAttr[index].cHandles; +} + +/* getresponseHandleCount() returns the number of command parameter handles */ + +/* NOTE: Marked as const function in header declaration */ + +uint32_t getresponseHandleCount(COMMAND_INDEX index) +{ + return s_ccAttr[index].rHandle; +} + +/* getDecryptSize() returns 0 if the command does not support command parameter encryption, 2 if the + command does support command parameter encryption and the size is a uint16_t. There is an unused + provision for a 4 for a uint32_t size. */ + +/* NOTE: Marked as const function in header declaration */ + +int getDecryptSize(COMMAND_INDEX commandIndex) +{ + COMMAND_ATTRIBUTES ca = s_commandAttributes[commandIndex]; + + if(ca & DECRYPT_2) + return 2; + if(ca & DECRYPT_4) + return 4; + return 0; +} + +/* getEecryptSize() returns 0 if the response does not support response parameter encryption, 2 if + the command does support response parameter encryption and the size is a uint16_t. There is an + unused provision for a 4 for a uint32_t size. */ + +/* NOTE: Marked as const function in header declaration */ + +int getEncryptSize(COMMAND_INDEX commandIndex) +{ + COMMAND_ATTRIBUTES ca = s_commandAttributes[commandIndex]; + if(ca & ENCRYPT_2) + return 2; + if(ca & ENCRYPT_4) + return 4; + return 0; +} + +/* getCommandAuthRole() returns the authorization role for the handle: user, admin, or dup. + + */ + +/* NOTE: Marked as const function in header declaration */ + +AUTH_ROLE getCommandAuthRole( + COMMAND_INDEX commandIndex, // IN: command index + size_t handleIndex // IN: handle index (zero based) + ) +{ + if(0 == handleIndex ) + { + // Any auth role set? + COMMAND_ATTRIBUTES properties = s_commandAttributes[commandIndex]; + + if(properties & HANDLE_1_USER) + return AUTH_USER; + if(properties & HANDLE_1_ADMIN) + return AUTH_ADMIN; + if(properties & HANDLE_1_DUP) + return AUTH_DUP; + } + else if (1 == handleIndex) + { + if(s_commandAttributes[commandIndex] & HANDLE_2_USER) + return AUTH_USER; + } + return AUTH_NONE; +} diff --git a/libstb/tss2/tssccattributes.h b/libstb/tss2/tssccattributes.h new file mode 100644 index 0000000..d975b91 --- /dev/null +++ b/libstb/tss2/tssccattributes.h @@ -0,0 +1,90 @@ +/********************************************************************************/ +/* */ +/* Command Code Attributes */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* */ +/* (c) Copyright IBM Corporation 2015 - 2019. */ +/* */ +/* All rights reserved. */ +/* */ +/* Redistribution and use in source and binary forms, with or without */ +/* modification, are permitted provided that the following conditions are */ +/* met: */ +/* */ +/* Redistributions of source code must retain the above copyright notice, */ +/* this list of conditions and the following disclaimer. */ +/* */ +/* 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. */ +/* */ +/* Neither the names of the IBM Corporation nor the names of its */ +/* contributors may be used to endorse or promote products derived from */ +/* this software without specific prior written permission. */ +/* */ +/* 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 TSSCCATTRIBUTES_H +#define TSSCCATTRIBUTES_H + +#include <stdio.h> + +#include <ibmtss/TPM_Types.h> +#include "CommandAttributes.h" + +typedef uint16_t COMMAND_INDEX; + +/* From Global.h */ +typedef UINT32 AUTH_ROLE; +#define AUTH_NONE ((AUTH_ROLE)(0)) +#define AUTH_USER ((AUTH_ROLE)(1)) +#define AUTH_ADMIN ((AUTH_ROLE)(2)) +#define AUTH_DUP ((AUTH_ROLE)(3)) + +#define UNIMPLEMENTED_COMMAND_INDEX ((COMMAND_INDEX)(~0)) + +COMMAND_INDEX CommandCodeToCommandIndex(TPM_CC commandCode) +#ifdef __ULTRAVISOR__ +__attribute__ ((const)) +#endif + ; +uint32_t getCommandHandleCount(COMMAND_INDEX index) +#ifdef __ULTRAVISOR__ + __attribute__ ((const)) +#endif + ; +uint32_t getresponseHandleCount(COMMAND_INDEX index) +#ifdef __ULTRAVISOR__ + __attribute__ ((const)) +#endif + ; +int getDecryptSize(COMMAND_INDEX commandIndex) +#ifdef __ULTRAVISOR__ + __attribute__ ((const)) +#endif + ; +int getEncryptSize(COMMAND_INDEX commandIndex) +#ifdef __ULTRAVISOR__ + __attribute__ ((const)) +#endif + ; +AUTH_ROLE getCommandAuthRole(COMMAND_INDEX commandIndex, + size_t handleIndex) +#ifdef __ULTRAVISOR__ + __attribute__ ((const)) +#endif + ; + +#endif diff --git a/libstb/tss2/tsscryptoh.c b/libstb/tss2/tsscryptoh.c new file mode 100644 index 0000000..28d2779 --- /dev/null +++ b/libstb/tss2/tsscryptoh.c @@ -0,0 +1,631 @@ +/********************************************************************************/ +/* */ +/* TSS Library Independent Crypto Support */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* */ +/* (c) Copyright IBM Corporation 2015 - 2019. */ +/* */ +/* All rights reserved. */ +/* */ +/* Redistribution and use in source and binary forms, with or without */ +/* modification, are permitted provided that the following conditions are */ +/* met: */ +/* */ +/* Redistributions of source code must retain the above copyright notice, */ +/* this list of conditions and the following disclaimer. */ +/* */ +/* 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. */ +/* */ +/* Neither the names of the IBM Corporation nor the names of its */ +/* contributors may be used to endorse or promote products derived from */ +/* this software without specific prior written permission. */ +/* */ +/* 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. */ +/********************************************************************************/ + +#include <string.h> +#include <stdio.h> +#include <stdlib.h> +#include <stdarg.h> + +#ifdef TPM_POSIX +#include <netinet/in.h> +#endif +#ifdef TPM_WINDOWS +#include <winsock2.h> +#endif + +#include <ibmtss/tssresponsecode.h> +#include <ibmtss/tssutils.h> +#include <ibmtss/tssprint.h> +#include <ibmtss/tsserror.h> + +#include <ibmtss/tsscryptoh.h> +#include <ibmtss/tsscrypto.h> + +extern int tssVverbose; +extern int tssVerbose; + +/* local prototypes */ + +static TPM_RC TSS_MGF1(unsigned char *mask, + uint32_t maskLen, + const unsigned char *mgfSeed, + uint16_t mgfSeedlen, + TPMI_ALG_HASH halg); + +/* TSS_HMAC_Generate() can be called directly to HMAC a list of streams. + + The ... arguments are a message list of the form + int length, unsigned char *buffer + terminated by a 0 length +*/ + +/* On call, digest->hashAlg is the desired hash algorithm */ + +TPM_RC TSS_HMAC_Generate(TPMT_HA *digest, /* largest size of a digest */ + const TPM2B_KEY *hmacKey, + ...) +{ + TPM_RC rc = 0; + va_list ap; + + va_start(ap, hmacKey); + rc = TSS_HMAC_Generate_valist(digest, hmacKey, ap); + va_end(ap); + return rc; +} + +/* TSS_HMAC_Verify() can be called directly to check the HMAC of a list of streams. + + The ... arguments are a list of the form + int length, unsigned char *buffer + terminated by a 0 length + +*/ + +TPM_RC TSS_HMAC_Verify(TPMT_HA *expect, + const TPM2B_KEY *hmacKey, + uint32_t sizeInBytes, + ...) +{ + TPM_RC rc = 0; + int irc; + va_list ap; + TPMT_HA actual; + + actual.hashAlg = expect->hashAlg; /* algorithm for the HMAC calculation */ + va_start(ap, sizeInBytes); + if (rc == 0) { + rc = TSS_HMAC_Generate_valist(&actual, hmacKey, ap); + } + if (rc == 0) { + irc = memcmp((uint8_t *)&expect->digest, &actual.digest, sizeInBytes); + if (irc != 0) { + TSS_PrintAll("TSS_HMAC_Verify: calculated HMAC", + (uint8_t *)&actual.digest, sizeInBytes); + rc = TSS_RC_HMAC_VERIFY; + } + } + va_end(ap); + return rc; +} + +/* TSS_KDFA() 11.4.9 Key Derivation Function + + As defined in SP800-108, the inner loop for building the key stream is: + + K(i) = HMAC (KI , [i]2 || Label || 00 || Context || [L]2) +*/ + +TPM_RC TSS_KDFA(uint8_t *keyStream, /* OUT: key buffer */ + TPM_ALG_ID hashAlg, /* IN: hash algorithm used in HMAC */ + const TPM2B *key, /* IN: HMAC key */ + const char *label, /* IN: KDFa label, NUL terminated */ + const TPM2B *contextU, /* IN: context U */ + const TPM2B *contextV, /* IN: context V */ + uint32_t sizeInBits) /* IN: size of generated key in bits */ + +{ + TPM_RC rc = 0; + uint32_t bytes = ((sizeInBits + 7) / 8); /* bytes left to produce */ + uint8_t *stream; + uint32_t sizeInBitsNbo = htonl(sizeInBits); /* KDFa L2 */ + uint16_t bytesThisPass; /* in one HMAC operation */ + uint32_t counter; /* counter value */ + uint32_t counterNbo; /* counter in big endian */ + TPMT_HA hmac; /* hmac result for this pass */ + + + if (rc == 0) { + hmac.hashAlg = hashAlg; /* for TSS_HMAC_Generate() */ + bytesThisPass = TSS_GetDigestSize(hashAlg); /* start with hashAlg sized chunks */ + if (bytesThisPass == 0) { + if (tssVerbose) printf("TSS_KDFA: KDFa failed\n"); + rc = TSS_RC_KDFA_FAILED; + } + } + /* Generate required bytes */ + for (stream = keyStream, counter = 1 ; /* beginning of stream, KDFa counter starts at 1 */ + (rc == 0) && bytes > 0 ; /* bytes left to produce */ + stream += bytesThisPass, bytes -= bytesThisPass, counter++) { + + /* last pass, can be less than hashAlg sized chunks */ + if (bytes < bytesThisPass) { + bytesThisPass = bytes; + } + counterNbo = htonl(counter); /* counter for this pass in BE format */ + + rc = TSS_HMAC_Generate(&hmac, /* largest size of an HMAC */ + (const TPM2B_KEY *)key, + sizeof(uint32_t), &counterNbo, /* KDFa i2 counter */ + strlen(label) + 1, label, /* KDFa label, use NUL as the KDFa + 00 byte */ + contextU->size, contextU->buffer, /* KDFa Context */ + contextV->size, contextV->buffer, /* KDFa Context */ + sizeof(uint32_t), &sizeInBitsNbo, /* KDFa L2 */ + 0, NULL); + memcpy(stream, &hmac.digest.tssmax, bytesThisPass); + } + return rc; +} + +/* TSS_KDFE() 11.4.9.3 Key Derivation Function for ECDH + + Digest = Hash(counter || Z || Use || PartyUInfo || PartyVInfo || bits ) + + where + + counter is initialized to 1 and incremented for each iteration + + Z is the X-coordinate of the product of a public (TPM) ECC key and + a different private ECC key + + Use is a NULL-terminated string that indicates the use of the key + ("DUPLICATE", "IDENTITY", "SECRET", etc) + + PartyUInfo is the X-coordinate of the public point of an ephemeral key + + PartyVInfo is the X-coordinate of the public point of the TPM key + + bits is a 32-bit value indicating the number of bits to be returned +*/ + +TPM_RC TSS_KDFE(uint8_t *keyStream, /* OUT: key buffer */ + TPM_ALG_ID hashAlg, /* IN: hash algorithm used */ + const TPM2B *key, /* IN: Z */ + const char *label, /* IN: KDFe label, NUL terminated */ + const TPM2B *contextU, /* IN: context U */ + const TPM2B *contextV, /* IN: context V */ + uint32_t sizeInBits) /* IN: size of generated key in bits */ + +{ + TPM_RC rc = 0; + uint32_t bytes = ((sizeInBits + 7) / 8); /* bytes left to produce */ + uint8_t *stream; + uint16_t bytesThisPass; /* in one Hash operation */ + uint32_t counter; /* counter value */ + uint32_t counterNbo; /* counter in big endian */ + TPMT_HA digest; /* result for this pass */ + + if (rc == 0) { + digest.hashAlg = hashAlg; /* for TSS_Hash_Generate() */ + bytesThisPass = TSS_GetDigestSize(hashAlg); /* start with hashAlg sized chunks */ + if (bytesThisPass == 0) { + if (tssVerbose) printf("TSS_KDFE: KDFe failed\n"); + rc = TSS_RC_KDFE_FAILED; + } + } + /* Generate required bytes */ + for (stream = keyStream, counter = 1 ; /* beginning of stream, KDFe counter starts at 1 */ + (rc == 0) && bytes > 0 ; /* bytes left to produce */ + stream += bytesThisPass, bytes -= bytesThisPass, counter++) { + /* last pass, can be less than hashAlg sized chunks */ + if (bytes < bytesThisPass) { + bytesThisPass = bytes; + } + counterNbo = htonl(counter); /* counter for this pass in BE format */ + + rc = TSS_Hash_Generate(&digest, /* largest size of a digest */ + sizeof(uint32_t), &counterNbo, /* KDFe i2 counter */ + key->size, key->buffer, + strlen(label) + 1, label, /* KDFe label, use NUL as the KDFe + 00 byte */ + contextU->size, contextU->buffer, /* KDFe Context */ + contextV->size, contextV->buffer, /* KDFe Context */ + 0, NULL); + memcpy(stream, &digest.digest.tssmax, bytesThisPass); + } + return rc; +} + +/* On call, digest->hashAlg is the desired hash algorithm + + ... is a list of int length, unsigned char *buffer pairs. + + length 0 is ignored, buffer NULL terminates list. +*/ + +TPM_RC TSS_Hash_Generate(TPMT_HA *digest, /* largest size of a digest */ + ...) +{ + TPM_RC rc = 0; + va_list ap; + va_start(ap, digest); + rc = TSS_Hash_Generate_valist(digest, ap); + va_end(ap); + return rc; +} + +/* TSS_GetDigestSize() returns the digest size in bytes based on the hash algorithm. + + Returns 0 for an unknown algorithm. +*/ + +/* NOTE: Marked as const function in header */ + +uint16_t TSS_GetDigestSize(TPM_ALG_ID hashAlg) +{ + uint16_t size; + + switch (hashAlg) { +#ifdef TPM_ALG_SHA1 + case TPM_ALG_SHA1: + size = SHA1_DIGEST_SIZE; + break; +#endif +#ifdef TPM_ALG_SHA256 + case TPM_ALG_SHA256: + size = SHA256_DIGEST_SIZE; + break; +#endif +#ifdef TPM_ALG_SHA384 + case TPM_ALG_SHA384: + size = SHA384_DIGEST_SIZE; + break; +#endif +#ifdef TPM_ALG_SHA512 + case TPM_ALG_SHA512: + size = SHA512_DIGEST_SIZE; + break; +#endif +#if 0 + case TPM_ALG_SM3_256: + size = SM3_256_DIGEST_SIZE; + break; +#endif + default: + size = 0; + } + return size; +} + +/* TSS_GetDigestBlockSize() returns the digest block size in bytes based on the hash algorithm. + + Returns 0 for an unknown algorithm. +*/ + +/* NOTE: Marked as const function in header */ + +uint16_t TSS_GetDigestBlockSize(TPM_ALG_ID hashAlg) +{ + uint16_t size; + + switch (hashAlg) { +#ifdef TPM_ALG_SHA1 + case TPM_ALG_SHA1: + size = SHA1_BLOCK_SIZE; + break; +#endif +#ifdef TPM_ALG_SHA256 + case TPM_ALG_SHA256: + size = SHA256_BLOCK_SIZE; + break; +#endif +#ifdef TPM_ALG_SHA384 + case TPM_ALG_SHA384: + size = SHA384_BLOCK_SIZE; + break; +#endif +#ifdef TPM_ALG_SHA512 + case TPM_ALG_SHA512: + size = SHA512_BLOCK_SIZE; + break; +#endif +#if 0 + case TPM_ALG_SM3_256: + size = SM3_256_BLOCK_SIZE; + break; +#endif + default: + size = 0; + } + return size; +} + +/* TPM_MGF1() generates an MGF1 'array' of length 'arrayLen' from 'seed' of length 'seedlen' + + The openSSL DLL doesn't export MGF1 in Windows or Linux 1.0.0, so this version is created from + scratch. + + Algorithm and comments (not the code) from: + + PKCS #1: RSA Cryptography Specifications Version 2.1 B.2.1 MGF1 + + Prototype designed to be compatible with openSSL + + MGF1 is a Mask Generation Function based on a hash function. + + MGF1 (mgfSeed, maskLen) + + Options: + + Hash hash function (hLen denotes the length in octets of the hash + function output) + + Input: + + mgfSeed seed from which mask is generated, an octet string + maskLen intended length in octets of the mask, at most 2^32(hLen) + + Output: + mask mask, an octet string of length l; or "mask too long" + + Error: "mask too long' +*/ + +static TPM_RC TSS_MGF1(unsigned char *mask, + uint32_t maskLen, + const unsigned char *mgfSeed, + uint16_t mgfSeedlen, + TPMI_ALG_HASH halg) +{ + TPM_RC rc = 0; + unsigned char counter[4]; /* 4 octets */ + uint32_t count; /* counter as an integral type */ + uint32_t outLen; + TPMT_HA digest; + uint16_t digestSize = TSS_GetDigestSize(halg); + + digest.hashAlg = halg; + +#if 0 + if (rc == 0) { + /* this is possible with arrayLen on a 64 bit architecture, comment to quiet beam */ + if ((maskLen / TPM_DIGEST_SIZE) > 0xffffffff) { /* constant condition */ + if (tssVerbose) + printf("TSS_MGF1: Error (fatal), Output length too large for 32 bit counter\n"); + rc = TPM_FAIL; /* should never occur */ + } + } +#endif + /* 1.If l > 2^32(hLen), output "mask too long" and stop. */ + /* NOTE Checked by caller */ + /* 2. Let T be the empty octet string. */ + /* 3. For counter from 0 to [masklen/hLen] - 1, do the following: */ + for (count = 0, outLen = 0 ; (rc == 0) && (outLen < maskLen) ; count++) { + /* a. Convert counter to an octet string C of length 4 octets - see Section 4.1 */ + /* C = I2OSP(counter, 4) NOTE Basically big endian */ + uint32_t count_n = htonl(count); + memcpy(counter, &count_n, 4); + /* b.Concatenate the hash of the seed mgfSeed and C to the octet string T: */ + /* T = T || Hash (mgfSeed || C) */ + /* If the entire digest is needed for the mask */ + if ((outLen + digestSize) < maskLen) { + rc = TSS_Hash_Generate(&digest, + mgfSeedlen, mgfSeed, + 4, counter, + 0, NULL); + memcpy(mask + outLen, &digest.digest, digestSize); + outLen += digestSize; + } + /* if the mask is not modulo TPM_DIGEST_SIZE, only part of the final digest is needed */ + else { + /* hash to a temporary digest variable */ + rc = TSS_Hash_Generate(&digest, + mgfSeedlen, mgfSeed, + 4, counter, + 0, NULL); + /* copy what's needed */ + memcpy(mask + outLen, &digest.digest, maskLen - outLen); + outLen = maskLen; /* outLen = outLen + maskLen - outLen */ + } + } + /* 4.Output the leading l octets of T as the octet string mask. */ + return rc; +} + +/* + OAEP Padding +*/ + +/* TSS_RSA_padding_add_PKCS1_OAEP() is a variation of the the openSSL function + + int RSA_padding_add_PKCS1_OAEP(unsigned char *to, int tlen, + unsigned char *f, int fl, unsigned char *p, int pl); + + It is used because the openssl function is hard coded to SHA1. + + This function was independently written from the PKCS1 specification "9.1.1.1 Encoding + Operation" and PKCS#1 v2.2, intended to be unencumbered by any license. + + + | <- emLen -> | + + | lHash | PS | 01 | Message | + + SHA flen + + | db | + | dbMask | + | seed | + + SHA + + | seedMask | + | 00 | maskSeed | maskedDB | +*/ + +TPM_RC TSS_RSA_padding_add_PKCS1_OAEP(unsigned char *em, uint32_t emLen, + const unsigned char *from, uint32_t fLen, + const unsigned char *p, + int plen, + TPMI_ALG_HASH halg) +{ + TPM_RC rc = 0; + TPMT_HA lHash; + unsigned char *db = NULL; /* compiler false positive */ + + unsigned char *dbMask = NULL; /* freed @1 */ + unsigned char *seed = NULL; /* freed @2 */ + unsigned char *maskedDb; + unsigned char *seedMask = NULL; /* compiler false positive */ + unsigned char *maskedSeed; + + uint16_t hlen = TSS_GetDigestSize(halg); + + /* 1.a. If the length of L is greater than the input limitation for */ + /* the hash function (2^61-1 octets for SHA-1) then output "parameter */ + /* string too long" and stop. */ + if (rc == 0) { + if (plen > 0xffff) { + if (tssVerbose) printf("TSS_RSA_padding_add_PKCS1_OAEP: Error, " + "label %u too long\n", plen); + rc = TSS_RC_RSA_PADDING; + } + } + /* 1.b. If ||M|| > emLen-2hLen-1 then output "message too long" and stop. */ + if (rc == 0) { + if (emLen < ((2 * hlen) + 2 + fLen)) { + if (tssVerbose) printf("TSS_RSA_padding_add_PKCS1_OAEP: Error, " + "message length %u too large for encoded length %u\n", + fLen, emLen); + rc = TSS_RC_RSA_PADDING; + } + } + /* 2.a. Let lHash = Hash(L), an octet string of length hLen. */ + if (rc == 0) { + lHash.hashAlg = halg; + rc = TSS_Hash_Generate(&lHash, + plen, p, + 0, NULL); + } + if (rc == 0) { + /* 2.b. Generate an octet string PS consisting of emLen-||M||-2hLen-2 zero octets. The + length of PS may be 0. */ + /* 2.c. Concatenate lHash, PS, a single octet of 0x01 the message M, to form a data block DB + as: DB = lHash || PS || 01 || M */ + /* NOTE Since db is eventually maskedDb, part of em, create directly in em */ + db = em + hlen + 1; + memcpy(db, &lHash.digest, hlen); /* lHash */ + /* PSlen = emlen - flen - (2 * hlen) - 2 */ + memset(db + hlen, 0, /* PS */ + emLen - fLen - (2 * hlen) - 2); + /* position of 0x01 in db is + hlen + PSlen = + hlen + emlen - flen - (2 * hlen) - 2 = + emlen - hlen - flen - 2 */ + db[emLen - fLen - hlen - 2] = 0x01; + memcpy(db + emLen - fLen - hlen - 1, from, fLen); /* M */ + } + /* 2.d. Generate a random octet string seed of length hLen. */ + if (rc == 0) { + rc = TSS_Malloc(&seed, hlen); + } + if (rc == 0) { + rc = TSS_RandBytes(seed, hlen); + } + if (rc == 0) { + rc = TSS_Malloc(&dbMask, emLen - hlen - 1); + } + if (rc == 0) { + /* 2.e. Let dbMask = MGF(seed, emLen-hLen-1). */ + rc = TSS_MGF1(dbMask, emLen - hlen -1, /* dbLen */ + seed, hlen, + halg); + } + if (rc == 0) { + /* 2.f. Let maskedDB = DB xor dbMask. */ + /* NOTE Since maskedDB is eventually em, XOR directly to em */ + maskedDb = em + hlen + 1; + TSS_XOR(maskedDb, db, dbMask, emLen - hlen -1); + /* 2.g. Let seedMask = MGF(maskedDB, hLen). */ + /* NOTE Since seedMask is eventually em, create directly to em */ + seedMask = em + 1; + rc = TSS_MGF1(seedMask, hlen, + maskedDb, emLen - hlen - 1, + halg); + } + if (rc == 0) { + /* 2.h. Let maskedSeed = seed xor seedMask. */ + /* NOTE Since maskedSeed is eventually em, create directly to em */ + maskedSeed = em + 1; + TSS_XOR(maskedSeed, seed, seedMask, hlen); + /* 2.i. 0x00, maskedSeed, and maskedDb to form EM */ + /* NOTE Created directly in em */ + } + free(dbMask); /* @1 */ + free(seed); /* @2 */ + return rc; +} + +/* TPM_XOR XOR's 'in1' and 'in2' of 'length', putting the result in 'out' + + */ + +void TSS_XOR(unsigned char *out, + const unsigned char *in1, + const unsigned char *in2, + size_t length) +{ + size_t i; + + for (i = 0 ; i < length ; i++) { + out[i] = in1[i] ^ in2[i]; + } + return; +} + +/* + AES +*/ + +#define TSS_AES_KEY_BITS 128 + +/* TSS_Sym_GetBlockSize() returns the block size for the symmetric algorithm. Returns 0 on for an + unknown algorithm. +*/ + +/* NOTE: Marked as const function in header */ + +uint16_t TSS_Sym_GetBlockSize(TPM_ALG_ID symmetricAlg, + uint16_t keySizeInBits) +{ + keySizeInBits = keySizeInBits; + + switch (symmetricAlg) { +#ifdef TPM_ALG_AES + case TPM_ALG_AES: +#endif +#ifdef TPM_ALG_SM4 /* Both AES and SM4 use the same block size */ + case TPM_ALG_SM4: +#endif + return 16; + default: + return 0; + } + return 0; +} diff --git a/libstb/tss2/tsscryptombed.c b/libstb/tss2/tsscryptombed.c new file mode 100644 index 0000000..e9efc5d --- /dev/null +++ b/libstb/tss2/tsscryptombed.c @@ -0,0 +1,1448 @@ +/********************************************************************************/ +/* */ +/* TSS Library Dependent Crypto Support */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* ECC Salt functions written by Bill Martin */ +/* */ +/* (c) Copyright IBM Corporation 2019. */ +/* */ +/* All rights reserved. */ +/* */ +/* Redistribution and use in source and binary forms, with or without */ +/* modification, are permitted provided that the following conditions are */ +/* met: */ +/* */ +/* Redistributions of source code must retain the above copyright notice, */ +/* this list of conditions and the following disclaimer. */ +/* */ +/* 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. */ +/* */ +/* Neither the names of the IBM Corporation nor the names of its */ +/* contributors may be used to endorse or promote products derived from */ +/* this software without specific prior written permission. */ +/* */ +/* 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. */ +/********************************************************************************/ + +/* Interface to mbedtls crypto library */ + +#include <string.h> +#include <stdio.h> +#include <stdlib.h> + +#ifdef TPM_POSIX +#include <netinet/in.h> +#endif +#ifdef TPM_WINDOWS +#include <winsock2.h> +#endif + +#ifndef TPM_TSS_NORSA +#include <libstb/crypto/mbedtls/include/mbedtls/rsa.h> +#endif +#include <libstb/crypto/mbedtls/include/mbedtls/md.h> +#ifdef TPM_ALG_SHA1 +#include <libstb/crypto/mbedtls/include/mbedtls/sha1.h> +#endif +#include <libstb/crypto/mbedtls/include/mbedtls/sha256.h> +#include <libstb/crypto/mbedtls/include/mbedtls/sha512.h> +#include <libstb/crypto/mbedtls/include/mbedtls/aes.h> + +/* if no RSA and no ECC, don't need any asymmetric support */ +#ifdef TPM_TSS_NORSA +#ifdef TPM_TSS_NOECC +#define TPM_TSS_NOASYM +#endif +#endif + +#ifndef TPM_TSS_NOASYM +#include <libstb/crypto/mbedtls/include/mbedtls/pk.h> +#endif + +#include <ibmtss/tssresponsecode.h> +#include <ibmtss/tssutils.h> +#include <ibmtss/tssprint.h> +#include <ibmtss/tsserror.h> + +#include <ibmtss/tsscryptoh.h> +#include <ibmtss/tsscrypto.h> + +extern int tssVverbose; +extern int tssVerbose; + +/* local prototypes */ + +static void TSS_Error(int irc); +static TPM_RC TSS_Hash_GetMd(mbedtls_md_type_t *mdType, + TPMI_ALG_HASH hashAlg); +#ifndef TPM_TSS_NORSA +static TPM_RC TSS_RsaNew(void **rsaKey); +#endif + +/* + Initialization +*/ + + +#ifndef TPM_TSS_NOASYM +static TPM_RC TSS_PkContextNew(mbedtls_pk_context **ctx); +#endif + +/* TSS_PkContextNew() allocates and initializes a mbedtls_pk_context */ + +#ifndef TPM_TSS_NOASYM + +static TPM_RC TSS_PkContextNew(mbedtls_pk_context **ctx) /* freed by caller */ +{ + TPM_RC rc = 0; + + /* sanity check for the free */ + if (rc == 0) { + if (*ctx != NULL) { + if (tssVerbose) printf("TSS_PkContextNew: Error (fatal), token %p should be NULL\n", + *ctx); + rc = TSS_RC_ALLOC_INPUT; + } + } + /* allocate the mbedtls_pk_context */ + if (rc == 0) { + rc = TSS_Malloc((unsigned char **)ctx, sizeof(mbedtls_pk_context)); + } + /* initialize but do not set up the context */ + if (rc == 0) { + mbedtls_pk_init(*ctx); + } + return rc; +} +#endif /* TPM_TSS_NOASYM */ + +/* Error trace */ + +static void TSS_Error(int irc) +{ + int src = 0 - irc; + if (tssVerbose) printf("mbedtls error -%04x\n", src); + return; +} + +/* + Digests +*/ + +/* TSS_Hash_GetMd() maps from a TCG hash algorithm to am mbedtls_md_type_t */ + +static TPM_RC TSS_Hash_GetMd(mbedtls_md_type_t *mdType, + TPMI_ALG_HASH hashAlg) +{ + TPM_RC rc = 0; + + if (rc == 0) { + switch (hashAlg) { +#ifdef TPM_ALG_SHA1 + case TPM_ALG_SHA1: + *mdType = MBEDTLS_MD_SHA1; + break; +#endif +#ifdef TPM_ALG_SHA256 + case TPM_ALG_SHA256: + *mdType = MBEDTLS_MD_SHA256; + break; +#endif +#ifdef TPM_ALG_SHA384 + case TPM_ALG_SHA384: + *mdType = MBEDTLS_MD_SHA384; + break; +#endif +#ifdef TPM_ALG_SHA512 + case TPM_ALG_SHA512: + *mdType = MBEDTLS_MD_SHA512; + break; +#endif + default: + rc = TSS_RC_BAD_HASH_ALGORITHM; + } + } + return rc; +} + +/* On call, digest->hashAlg is the desired hash algorithm + + length 0 is ignored, buffer NULL terminates list. +*/ + +TPM_RC TSS_HMAC_Generate_valist(TPMT_HA *digest, /* largest size of a digest */ + const TPM2B_KEY *hmacKey, + va_list ap) +{ + TPM_RC rc = 0; + int irc = 0; + int done = FALSE; + mbedtls_md_context_t ctx; + mbedtls_md_type_t mdType; + const mbedtls_md_info_t *mdInfo = NULL; + int length; + uint8_t *buffer; + + mbedtls_md_init(&ctx); /* initialize the context */ + /* map from TPM digest algorithm to mbedtls type */ + if (rc == 0) { + rc = TSS_Hash_GetMd(&mdType, digest->hashAlg); + } + if (rc == 0) { + mdInfo = mbedtls_md_info_from_type(mdType); + if (mdInfo == NULL) { + rc = TSS_RC_HMAC; + } + } + if (rc == 0) { + irc = mbedtls_md_setup(&ctx, /* freed @1 */ + mdInfo, + 1); /* flag, hmac used */ + if (irc != 0) { + TSS_Error(irc); + rc = TSS_RC_HMAC; + } + } + if (rc == 0) { + irc = mbedtls_md_hmac_starts(&ctx, + hmacKey->b.buffer, hmacKey->b.size); /* HMAC key */ + if (irc != 0) { + TSS_Error(irc); + rc = TSS_RC_HMAC; + } + } + while ((rc == 0) && !done) { + length = va_arg(ap, int); /* first vararg is the length */ + buffer = va_arg(ap, unsigned char *); /* second vararg is the array */ + if (buffer != NULL) { /* loop until a NULL buffer terminates */ + if (length < 0) { + if (tssVerbose) printf("TSS_HMAC_Generate: Length is negative\n"); + rc = TSS_RC_HMAC; + } + else { + irc = mbedtls_md_hmac_update(&ctx, buffer, length); + if (irc != 0) { + TSS_Error(irc); + if (tssVerbose) printf("TSS_HMAC_Generate: HMAC_Update failed\n"); + rc = TSS_RC_HMAC; + } + } + } + else { + done = TRUE; + } + } + + if (rc == 0) { + irc = mbedtls_md_hmac_finish(&ctx, (uint8_t *)&digest->digest); + if (irc != 0) { + TSS_Error(irc); + rc = TSS_RC_HMAC; + } + } + mbedtls_md_free(&ctx); /* @1 */ + return rc; +} + +/* + valist is int length, unsigned char *buffer pairs + + length 0 is ignored, buffer NULL terminates list. +*/ + +TPM_RC TSS_Hash_Generate_valist(TPMT_HA *digest, /* largest size of a digest */ + va_list ap) +{ + TPM_RC rc = 0; + int irc = 0; + int done = FALSE; + mbedtls_md_context_t ctx; + mbedtls_md_type_t mdType; + const mbedtls_md_info_t *mdInfo = NULL; + int length; + uint8_t *buffer; + + mbedtls_md_init(&ctx); /* initialize the context */ + /* map from TPM digest algorithm to mbedtls type */ + if (rc == 0) { + rc = TSS_Hash_GetMd(&mdType, digest->hashAlg); + } + if (rc == 0) { + mdInfo = mbedtls_md_info_from_type(mdType); + if (mdInfo == NULL) { + if (tssVerbose) printf("TSS_Hash_Generate: Hash algorithm not found\n"); + rc = TSS_RC_HASH; + } + } + if (rc == 0) { + irc = mbedtls_md_setup(&ctx, /* freed @1 */ + mdInfo, + 0); /* flag, hash used */ + if (irc != 0) { + TSS_Error(irc); + if (tssVerbose) printf("TSS_Hash_Generate: mbedtls_md_setup failed\n"); + rc = TSS_RC_HASH; + } + } + if (rc == 0) { + irc = mbedtls_md_starts(&ctx); + if (irc != 0) { + TSS_Error(irc); + if (tssVerbose) printf("TSS_Hash_Generate: mbedtls_md_starts failed\n"); + rc = TSS_RC_HASH; + } + } + while ((rc == 0) && !done) { + length = va_arg(ap, int); /* first vararg is the length */ + buffer = va_arg(ap, unsigned char *); /* second vararg is the array */ + if (buffer != NULL) { /* loop until a NULL buffer terminates */ + if (length < 0) { + if (tssVerbose) printf("TSS_Hash_Generate: Length is negative\n"); + rc = TSS_RC_HASH; + } + else { + /* if (tssVverbose) TSS_PrintAll("TSS_Hash_Generate:", buffer, length); */ + if (length != 0) { + irc = mbedtls_md_update(&ctx, buffer, length); + if (irc != 0) { + TSS_Error(irc); + rc = TSS_RC_HASH; + } + } + } + } + else { + done = TRUE; + } + } + if (rc == 0) { + irc = mbedtls_md_finish(&ctx, (uint8_t *)&digest->digest); + if (irc != 0) { + TSS_Error(irc); + rc = TSS_RC_HASH; + } + } + mbedtls_md_free(&ctx); /* @1 */ + return rc; +} + +/* + RSA functions +*/ + +#ifndef TPM_TSS_NORSA + +/* NOTE: For mbedtls, TSS_RsaNew() and TSS_RsaFree() are not symmetrical. + + TSS_RsaNew() allocates the inner mbedtls_rsa_context structure. TSS_RsaNew() should not have + been public for OpenSSL, and is tetained but deprecated. It is private for mbedtls. + + TSS_RsaFree(), which is public because it frees the TSS_RSAGeneratePublicTokenI() result, frees + the outer mbedtls_pk_context structure. +*/ + + +/* TSS_RsaNew() allocates an mbedtls RSA key token. + + This abstracts the crypto library specific allocation. + + For mbedtls, rsaKey is a mbedtls_rsa_context structure. +*/ + +TPM_RC TSS_RsaNew(void **rsaKey) +{ + TPM_RC rc = 0; + + /* sanity check for the free */ + if (rc == 0) { + if (*rsaKey != NULL) { + if (tssVerbose) printf("TSS_RsaNew: Error (fatal), token %p should be NULL\n", + *rsaKey); + rc = TSS_RC_ALLOC_INPUT; + } + } + /* construct the private key object */ + if (rc == 0) { + rc = TSS_Malloc((unsigned char **)rsaKey, sizeof(mbedtls_rsa_context)); + } + if (rc == 0) { + mbedtls_rsa_init(*rsaKey, MBEDTLS_RSA_PKCS_V15, 0); + } + return rc; +} + +/* TSS_RsaFree() frees an mbedtls_pk_context RSA key token. + + For compatibility with other crypto libraries, this is the outer wrapper, not the inner RSA + structure. + + This abstracts the crypto library specific free. +*/ + +void TSS_RsaFree(void *rsaKey) +{ + mbedtls_pk_free(rsaKey); + free(rsaKey); + return; +} + +/* TSS_RSAGeneratePublicTokenI() generates an mbedtls_pk_context RSA public key token from n and e + + Free rsa_pub_key using TSS_RsaFree(); +*/ + +TPM_RC TSS_RSAGeneratePublicTokenI(void **rsa_pub_key, /* freed by caller */ + const unsigned char *narr, /* public modulus */ + uint32_t nbytes, + const unsigned char *earr, /* public exponent */ + uint32_t ebytes) +{ + TPM_RC rc = 0; + int irc; + mbedtls_rsa_context *rsaCtx = NULL; + const mbedtls_pk_info_t *pkInfo = NULL; + + /* allocate and initialize the mbedtls_pk_context public key token */ + if (rc == 0) { + rc = TSS_PkContextNew((mbedtls_pk_context **)rsa_pub_key); /* freed by caller */ + } + /* allocate and initialize the inner mbedtls_rsa_context */ + if (rc == 0) { + rc = TSS_RsaNew((void **)&rsaCtx); /* freed @1 contexts freed with wrapper */ + } + if (rc == 0) { + irc = mbedtls_rsa_import_raw(rsaCtx, + narr, nbytes, + NULL, 0, /* p */ + NULL, 0, /* q */ + NULL, 0, /* d */ + earr, ebytes); + if (irc != 0) { + TSS_Error(irc); + rc = TSS_RC_RSA_KEY_CONVERT; + } + } + if (rc == 0) { + irc = mbedtls_rsa_complete(rsaCtx); + if (irc != 0) { + TSS_Error(irc); + rc = TSS_RC_RSA_KEY_CONVERT; + } + } + if (rc == 0) { + irc = mbedtls_rsa_check_pubkey(rsaCtx); + if (irc != 0) { + TSS_Error(irc); + rc = TSS_RC_RSA_KEY_CONVERT; + } + } + /* build the mbedtls_pk_context from the mbedtls_rsa_context */ + if (rc == 0) { + pkInfo = mbedtls_pk_info_from_type(MBEDTLS_PK_RSA); + if (pkInfo == NULL) { + if (tssVerbose) printf("TSS_RSAGeneratePublicTokenI: " + "Error in mbedtls_pk_info_from_type()\n"); + rc = TSS_RC_RSA_KEY_CONVERT; + } + } + /* set the metadata */ + if (rc == 0) { + irc = mbedtls_pk_setup(*rsa_pub_key, pkInfo); + if (irc != 0) { + TSS_Error(irc); + if (tssVerbose) printf("TSS_RSAGeneratePublicTokenI: Error in mbedtls_pk_setup()\n"); + rc = TSS_RC_RSA_KEY_CONVERT; + } + } + /* copy the key data */ + if (rc == 0) { + mbedtls_pk_context *pkCtx = (mbedtls_pk_context *)*rsa_pub_key; + mbedtls_rsa_context *rsaPkCtx = mbedtls_pk_rsa(*pkCtx); + memcpy(rsaPkCtx, rsaCtx, sizeof(mbedtls_rsa_context)); + } + free(rsaCtx); + return rc; +} + +/* TSS_RSAPublicEncrypt() pads 'decrypt_data' to 'encrypt_data_size' and encrypts using the public + key 'n, e'. +*/ + +TPM_RC TSS_RSAPublicEncrypt(unsigned char *encrypt_data, /* encrypted data */ + size_t encrypt_data_size, /* size of encrypted data buffer */ + const unsigned char *decrypt_data, /* decrypted data */ + size_t decrypt_data_size, + unsigned char *narr, /* public modulus */ + uint32_t nbytes, + unsigned char *earr, /* public exponent */ + uint32_t ebytes, + unsigned char *p, /* encoding parameter */ + int pl, + TPMI_ALG_HASH halg) /* OAEP hash algorithm */ +{ + TPM_RC rc = 0; + int irc; + mbedtls_pk_context *pkCtx = NULL; + unsigned char *padded_data = NULL; + + if (tssVverbose) printf(" TSS_RSAPublicEncrypt: Input data size %lu\n", + (unsigned long)decrypt_data_size); + /* intermediate buffer for the decrypted but still padded data */ + if (rc == 0) { + rc = TSS_Malloc(&padded_data, encrypt_data_size); /* freed @2 */ + } + /* construct the mbedtls_pk_context public key */ + if (rc == 0) { + rc = TSS_RSAGeneratePublicTokenI((void **)&pkCtx, /* freed @1 */ + narr, /* public modulus */ + nbytes, + earr, /* public exponent */ + ebytes); + } + if (rc == 0) { + padded_data[0] = 0x00; + rc = TSS_RSA_padding_add_PKCS1_OAEP(padded_data, /* to */ + encrypt_data_size, /* to length */ + decrypt_data, /* from */ + decrypt_data_size, /* from length */ + p, /* encoding parameter */ + pl, /* encoding parameter length */ + halg); /* OAEP hash algorithm */ + } + if (rc == 0) { + mbedtls_rsa_context *rsaCtx = NULL; + if (tssVverbose) + printf(" TSS_RSAPublicEncrypt: Padded data size %lu\n", + (unsigned long)encrypt_data_size); + if (tssVverbose) TSS_PrintAll(" TPM_RSAPublicEncrypt: Padded data", padded_data, + encrypt_data_size); + /* encrypt with public key. Must pad first and then encrypt because the encrypt + call cannot specify an encoding parameter */ + /* returns the size of the encrypted data. On error, -1 is returned */ + rsaCtx = mbedtls_pk_rsa(*pkCtx); /* get inner RSA key */ + irc = mbedtls_rsa_public(rsaCtx, /* key */ + padded_data, /* from - the clear text data */ + encrypt_data); /* the padded and encrypted data */ + if (irc != 0) { + TSS_Error(irc); + if (tssVerbose) printf("TSS_RSAPublicEncrypt: Error in mbedtls_rsa_public()\n"); + rc = TSS_RC_RSA_ENCRYPT; + } + } + if (rc == 0) { + if (tssVverbose) printf(" TSS_RSAPublicEncrypt: RSA_public_encrypt() success\n"); + } + TSS_RsaFree(pkCtx); /* @1 */ + free(padded_data); /* @2 */ + return rc; +} + +#endif /* TPM_TSS_NORSA */ + +#ifndef TPM_TSS_NOECC +#if 0 /* Not implemented for mbedtls */ + +/* TSS_GeneratePlatformEphemeralKey sets the EC parameters to NIST P256 for generating the ephemeral + key. Some OpenSSL versions do not come with NIST p256. */ + +static TPM_RC TSS_ECC_GeneratePlatformEphemeralKey(CURVE_DATA *eCurveData, EC_KEY *myecc) +{ + TPM_RC rc = 0; + BIGNUM *p = NULL; + BIGNUM *a = NULL; + BIGNUM *b = NULL; + BIGNUM *x = NULL; + BIGNUM *y = NULL; + BIGNUM *z = NULL; + EC_POINT *G = NULL; /* generator */ + + /* ---------------------------------------------------------- * + * Set the EC parameters to NISTp256. Openssl versions might * + * not have NISTP256 as a possible parameter so we make it * + * possible by setting the curve ourselves. * + * ---------------------------------------------------------- */ + + /* NIST P256 from FIPS 186-3 */ + if (rc == 0) { + if (tssVverbose) printf("TSS_ECC_GeneratePlatformEphemeralKey: Converting p\n"); + rc = TSS_BN_hex2bn(&p, /* freed @1 */ + "FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF"); + } + if (rc == 0) { + if (tssVverbose) printf("TSS_ECC_GeneratePlatformEphemeralKey: Converting a\n"); + rc = TSS_BN_hex2bn(&a, /* freed @2 */ + "FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFC"); + } + if (rc == 0) { + if (tssVverbose) printf("TSS_ECC_GeneratePlatformEphemeralKey: Converting b\n"); + rc = TSS_BN_hex2bn(&b, /* freed @3 */ + "5AC635D8AA3A93E7B3EBBD55769886BC651D06B0CC53B0F63BCE3C3E27D2604B"); + } + if (rc == 0) { + if (tssVverbose) printf("TSS_ECC_GeneratePlatformEphemeralKey: New group\n"); + eCurveData->G = EC_GROUP_new(EC_GFp_mont_method()); /* freed @4 */ + if (eCurveData->G == NULL) { + if (tssVerbose) printf("TSS_ECC_GeneratePlatformEphemeralKey: " + "Error creating new group\n"); + rc = TSS_RC_EC_EPHEMERAL_FAILURE; + } + } + if (rc == 0) { + if (tssVverbose) printf("TSS_ECC_GeneratePlatformEphemeralKey: Set the curve prime\n"); + if (EC_GROUP_set_curve_GFp(eCurveData->G, p, a, b, eCurveData->ctx) == 0) { + if (tssVerbose) printf("TSS_ECC_GeneratePlatformEphemeralKey: " + "Error seting curve prime\n"); + rc = TSS_RC_EC_EPHEMERAL_FAILURE; + } + } + if (rc == 0) { + G = EC_POINT_new(eCurveData->G); /* freed @5 */ + if (G == NULL ){ + if (tssVerbose) printf("TSS_ECC_GeneratePlatformEphemeralKey: EC_POINT_new failed\n"); + rc = TSS_RC_OUT_OF_MEMORY; + } + } + if (rc == 0) { + rc = TSS_BN_hex2bn(&x, /* freed @6 */ + "6B17D1F2E12C4247F8BCE6E563A440F277037D812DEB33A0F4A13945D898C296"); + } + if (rc == 0) { + rc = TSS_BN_hex2bn(&y, /* freed @7 */ + "4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5"); + } + if (rc == 0) { + if (EC_POINT_set_affine_coordinates_GFp(eCurveData->G, G, x, y, eCurveData->ctx) == 0) { + if (tssVerbose) printf("TSS_ECC_GeneratePlatformEphemeralKey: Error, " + "Cannot create TPM public point from coordinates\n"); + rc = TSS_RC_EC_EPHEMERAL_FAILURE; + } + } + /* sanity check to see if point is on the curve */ + if (rc == 0) { + if (EC_POINT_is_on_curve(eCurveData->G, G, eCurveData->ctx) == 0) { + if (tssVerbose) printf("TSS_ECC_GeneratePlatformEphemeralKey: Error, " + "Point not on curve\n"); + rc = TSS_RC_EC_EPHEMERAL_FAILURE; + } + } + if (rc == 0) { + rc = TSS_BN_hex2bn(&z, /* freed @8 */ + "FFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E84F3B9CAC2FC632551"); + } + if (rc == 0) { + if (EC_GROUP_set_generator(eCurveData->G, G, z, BN_value_one()) == 0) { + if (tssVerbose) printf("TSS_ECC_GeneratePlatformEphemeralKey: Error, " + "EC_GROUP_set_generator()\n"); + rc = TSS_RC_EC_EPHEMERAL_FAILURE; + } + } + if (rc == 0) { + if (EC_GROUP_check(eCurveData->G, eCurveData->ctx) == 0) { + if (tssVerbose) printf("TSS_ECC_GeneratePlatformEphemeralKey: Error, " + "EC_GROUP_check()\n"); + rc = TSS_RC_EC_EPHEMERAL_FAILURE; + } + } + if (rc == 0) { + if (EC_KEY_set_group(myecc, eCurveData->G) == 0) { + if (tssVerbose) printf("TSS_ECC_GeneratePlatformEphemeralKey: Error, " + "EC_KEY_set_group()\n"); + rc = TSS_RC_EC_EPHEMERAL_FAILURE; + } + } + if (rc == 0) { +#if 0 + if (tssVverbose) printf("TSS_ECC_GeneratePlatformEphemeralKey: " + "Address of eCurveData->G is %p\n", eCurveData->G); + if (tssVverbose) printf("TSS_ECC_GeneratePlatformEphemeralKey: " + "Address of eCurveData->CTX is %p\n", eCurveData->ctx); +#endif + if (tssVverbose) printf("TSS_ECC_GeneratePlatformEphemeralKey: " + "Set group for key\n"); + } + /* Create the public/private EC key pair here */ + if (rc == 0) { + if (EC_KEY_generate_key(myecc) == 0) { + if (tssVerbose) printf("TSS_ECC_GeneratePlatformEphemeralKey: " + "Error generating the ECC key.\n"); + rc = TSS_RC_EC_EPHEMERAL_FAILURE; + } + } + if (rc == 0) { + if (!EC_KEY_check_key(myecc)) { + if (tssVerbose) printf("TSS_ECC_GeneratePlatformEphemeralKey: " + "Error on EC_KEY_check_key()\n"); + rc = TSS_RC_EC_EPHEMERAL_FAILURE; + } + } + if (p != NULL) BN_clear_free(p); /* @1 */ + if (a != NULL) BN_clear_free(a); /* @2 */ + if (b != NULL) BN_clear_free(b); /* @3 */ + if (rc != 0) { + EC_GROUP_free(eCurveData->G); /* @4 */ + EC_POINT_free(G); /* @5 */ + } + if (x != NULL) BN_clear_free(x); /* @6 */ + if (y != NULL) BN_clear_free(y); /* @7 */ + if (z != NULL) BN_clear_free(z); /* @8 */ + + /* don't free the key info. This curve was constructed out of parameters, not of the openssl + library */ + /* EC_KEY_free(myecc) */ + /* EC_POINT_free(G); */ + return rc; +} + +#endif + +/* TSS_ECC_Salt() returns both the plaintext and excrypted salt, based on the salt key bPublic. + + This is currently hard coded to the TPM_ECC_NIST_P256 curve. +*/ + +TPM_RC TSS_ECC_Salt(TPM2B_DIGEST *salt, + TPM2B_ENCRYPTED_SECRET *encryptedSalt, + TPMT_PUBLIC *publicArea) +{ + TPM_RC rc = 0; + salt = salt; + encryptedSalt = encryptedSalt; + publicArea = publicArea; + if (tssVerbose) printf("TSS_ECC_Salt: Unimplemented for mbedtls library\n"); + rc = TSS_RC_COMMAND_UNIMPLEMENTED; +#if 0 + EC_KEY *myecc = NULL; /* ephemeral key */ + const BIGNUM *d_caller; /* ephemeral private key */ + const EC_POINT *callerPointPub; /* ephemeral public key */ + EC_POINT *tpmPointPub = NULL; + BIGNUM *p_tpmX = NULL; + BIGNUM *bigY = NULL; + BIGNUM *zBn = NULL; + EC_POINT *rPoint = NULL; + BIGNUM *thepoint = NULL; + BIGNUM *sharedX = NULL; + BIGNUM *yBn = NULL; + uint32_t sizeInBytes; + uint32_t sizeInBits; + uint8_t *sharedXBin = NULL; + unsigned int lengthSharedXBin; + BIGNUM *p_caller_Xbn = NULL; + BIGNUM *p_caller_Ybn = NULL; + uint8_t *p_caller_Xbin = NULL; + uint8_t *p_caller_Ybin = NULL; + uint8_t *p_tpmXbin = NULL; + unsigned int length_p_caller_Xbin; + unsigned int length_p_caller_Ybin; + unsigned int length_p_tpmXbin; + TPM2B_ECC_PARAMETER sharedX_For_KDFE; + TPM2B_ECC_PARAMETER p_caller_X_For_KDFE; + TPM2B_ECC_PARAMETER p_tpmX_For_KDFE; + CURVE_DATA eCurveData; + + eCurveData.ctx = NULL; /* for free */ + eCurveData.G = NULL; /* this is initialized in TSS_ECC_GeneratePlatformEphemeralKey() at + EC_GROUP_new() but gcc -O3 emits a warning that it's + uninitialized. */ + /* only NIST P256 is currently supported */ + if (rc == 0) { + if ((publicArea->parameters.eccDetail.curveID != TPM_ECC_NIST_P256)) { + if (tssVerbose) + printf("TSS_ECC_Salt: ECC curve ID %04x not supported\n", + publicArea->parameters.eccDetail.curveID); + rc = TSS_RC_BAD_SALT_KEY; + } + } + if (rc == 0) { + myecc = EC_KEY_new(); /* freed @1 */ + if (myecc == NULL) { + if (tssVerbose) printf("TSS_ECC_Salt: EC_KEY_new failed\n"); + rc = TSS_RC_OUT_OF_MEMORY; + } + } + if (rc == 0) { + eCurveData.ctx = BN_CTX_new(); /* freed @16 */ + if (eCurveData.ctx == NULL) { + if (tssVerbose) printf("TSS_ECC_Salt: BN_CTX_new failed\n"); + rc = TSS_RC_OUT_OF_MEMORY; + } + } + /* Generate the TSS EC ephemeral key pair outside the TPM for the salt. The public part of this + key is actually the 'encrypted' salt. */ + if (rc == 0) { + if (tssVverbose) printf("TSS_ECC_Salt: " + "Calling TSS_ECC_GeneratePlatformEphemeralKey\n"); + rc = TSS_ECC_GeneratePlatformEphemeralKey(&eCurveData, myecc); + } + if (rc == 0) { + d_caller = EC_KEY_get0_private_key(myecc); /* ephemeral private key */ + callerPointPub = EC_KEY_get0_public_key(myecc); /* ephemeral public key */ + } + /* validate that the public point is on the NIST P-256 curve */ + if (rc == 0) { + if (EC_POINT_is_on_curve(eCurveData.G, callerPointPub, eCurveData.ctx) == 0) { + if (tssVerbose) printf("TSS_ECC_Salt: " + "Generated point not on curve\n"); + rc = TSS_RC_EC_EPHEMERAL_FAILURE; + } + } + if (rc == 0) { + /* let d_caller be private scalar and P_caller be public point */ + /* p_tpm is public point. p_tpmX is to be X-coordinate and p_tpmY the + Y-coordinate */ + + /* Allocate the space for P_tpm */ + tpmPointPub = EC_POINT_new(eCurveData.G); /* freed @2 */ + if (tpmPointPub == NULL) { + if (tssVerbose) printf("TSS_ECC_Salt: EC_POINT_new failed\n"); + rc = TSS_RC_OUT_OF_MEMORY; + } + } + /* grab the public point x and y using the parameters passed in */ + if (rc == 0) { + if (tssVverbose) printf("TSS_ECC_Salt: " + "Salt key sizes are X: %d and Y: %d\n", + publicArea->unique.ecc.x.t.size, + publicArea->unique.ecc.y.t.size); + p_tpmX = BN_bin2bn((const unsigned char *)&publicArea->unique.ecc.x.t.buffer, + publicArea->unique.ecc.x.t.size, NULL); /* freed @3 */ + if (p_tpmX == NULL) { + if (tssVerbose) printf("TSS_ECC_Salt: BN_bin2bn p_tpmX failed\n"); + rc = TSS_RC_OUT_OF_MEMORY; + } + } + if (rc == 0) { + bigY = BN_bin2bn((const unsigned char*)&publicArea->unique.ecc.y.t.buffer, + publicArea->unique.ecc.y.t.size, bigY); /* freed @15 */ + if (bigY == NULL) { + if (tssVerbose) printf("TSS_ECC_Salt: BN_bin2bn bigY failed\n"); + rc = TSS_RC_OUT_OF_MEMORY; + } + } + if (rc == 0) { + if (tssVverbose) printf("TSS_ECC_Salt: " + "Salt public key X %s\n", BN_bn2hex(p_tpmX)); + if (tssVverbose) printf("TSS_ECC_Salt: " + "Salt public key Y %s\n", BN_bn2hex(bigY)); + } + /* Create the openssl form of the TPM salt public key as EC_POINT using coordinates */ + if (rc == 0) { + if (EC_POINT_set_affine_coordinates_GFp + (eCurveData.G, tpmPointPub, p_tpmX, bigY, eCurveData.ctx) == 0) { + if (tssVerbose) printf("TSS_ECC_Salt: " + "Cannot create TPM public point from coordinates\n"); + rc = TSS_RC_EC_EPHEMERAL_FAILURE; + } + } + /* RFC 2440 Named curve prime256v1 */ + if (rc == 0) { + rc = TSS_BN_hex2bn(&zBn, /* freed @4 */ + "FFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E84F3B9CAC2FC632551"); + } + /* add the generator z to the group we are constructing */ + if (rc == 0) { + if (EC_GROUP_set_generator(eCurveData.G, tpmPointPub, zBn, BN_value_one()) == 0) { + if(tssVerbose) printf ("TSS_ECC_Salt: " + "Error EC_GROUP_set_generator()\n"); + rc = TSS_RC_EC_EPHEMERAL_FAILURE; + } + } + /* Check for validity of our group */ + if (rc == 0) { + if (EC_GROUP_check(eCurveData.G, eCurveData.ctx) == 0) { + if (tssVerbose) printf("TSS_ECC_Salt: " + "ec_group_check() failed\n"); + rc = TSS_RC_EC_EPHEMERAL_FAILURE; + } + } + /* Check to see if what we think is the TPM point is on the curve */ + if (rc == 0) { + if (EC_POINT_is_on_curve(eCurveData.G, tpmPointPub, eCurveData.ctx) == 0) { + if (tssVerbose) printf("TSS_ECC_Salt: Error, " + "Point not on curve\n"); + rc = TSS_RC_EC_EPHEMERAL_FAILURE; + } + else { + if (tssVverbose) printf("TSS_ECC_Salt: " + "Validated that TPM EC point is on curve\n"); + } + } + if (rc == 0) { + rPoint = EC_POINT_new(eCurveData.G); + if (rPoint == NULL) { + if (tssVerbose) printf("TSS_ECC_Salt: " + "Cannot create rPoint\n"); + rc = TSS_RC_EC_EPHEMERAL_FAILURE; + } + } + /* Point multiply the TPM public point by the ephemeral scalar. This will produce the + point from which we get the shared X coordinate, which we keep for use in KDFE. The + TPM will calculate the same X. */ + if (rc == 0) { + if (EC_POINT_mul(eCurveData.G, rPoint, NULL, tpmPointPub, + d_caller, eCurveData.ctx) == 0) { + if (tssVerbose) printf("TSS_ECC_Salt: " + "EC_POINT_mul failed\n") ; + rc = TSS_RC_EC_EPHEMERAL_FAILURE; + } + else { + if (tssVverbose) printf("TSS_ECC_Salt: " + "EC_POINT_mul() succeeded\n"); + } + } + /* Check to see if calculated point is on the curve, just for extra sanity */ + if (rc == 0) { + if (EC_POINT_is_on_curve(eCurveData.G, rPoint, eCurveData.ctx) == 0) { + if (tssVerbose) printf("TSS_ECC_Salt: Error," + "Point r is not on curve\n"); + rc = TSS_RC_EC_EPHEMERAL_FAILURE; + } + else { + if (tssVverbose) printf("TSS_ECC_Salt: " + "Point calculated by EC_POINT_mul() is on the curve\n"); + } + } + if (rc == 0) { + thepoint = EC_POINT_point2bn(eCurveData.G, rPoint, POINT_CONVERSION_UNCOMPRESSED, + NULL, eCurveData.ctx); /* freed @6 */ + if (thepoint == NULL) { + if (tssVerbose) printf("TSS_ECC_Salt: " + "EC_POINT_point2bn thepoint failed\n"); + rc = TSS_RC_OUT_OF_MEMORY; + } + } + /* get sharedX */ + if (rc == 0) { + rc = TSS_BN_new(&sharedX); /* freed @7 */ + } + if (rc == 0) { + rc = TSS_BN_new(&yBn); /* freed @8 */ + } + if (rc == 0) { + if (EC_POINT_get_affine_coordinates_GFp(eCurveData.G, rPoint, + sharedX, yBn, eCurveData.ctx) == 0) { + if (tssVerbose) printf("TSS_ECC_Salt: " + "EC_POINT_get_affine_coordinates_GFp() failed\n"); + rc = TSS_RC_EC_EPHEMERAL_FAILURE; + } + } + if (rc == 0) { + sizeInBytes = TSS_GetDigestSize(publicArea->nameAlg); + sizeInBits = sizeInBytes * 8; + rc = TSS_Malloc(&sharedXBin, BN_num_bytes(sharedX)); /* freed @9 */ + } + if (rc == 0) { + lengthSharedXBin = (unsigned int)BN_bn2bin(sharedX, sharedXBin); + if (tssVverbose) TSS_PrintAll("TSS_ECC_Salt: sharedXBin", + sharedXBin, + lengthSharedXBin); + } + /* encrypted salt is just the ephemeral public key */ + if (rc == 0) { + rc = TSS_BN_new(&p_caller_Xbn); /* freed 10 */ + } + if (rc == 0) { + rc = TSS_BN_new(&p_caller_Ybn); /* freed @11 */ + } + if (rc == 0) { + if (tssVverbose) printf("TSS_ECC_Salt: " + "Allocated space for ephemeral BIGNUM X, Y\n"); + } + /* Get the X-coordinate and Y-Coordinate */ + if (rc == 0) { + if (EC_POINT_get_affine_coordinates_GFp(eCurveData.G, callerPointPub, + p_caller_Xbn, p_caller_Ybn, + eCurveData.ctx) == 0) { + if (tssVerbose) printf("TSS_ECC_Salt: " + "EC_POINT_get_affine_coordinates_GFp() failed\n"); + rc = TSS_RC_EC_EPHEMERAL_FAILURE; + } + else { + if (tssVverbose) printf("TSS_ECC_Salt: " + "Retrieved X and Y coordinates from ephemeral public\n"); + } + } + if (rc == 0) { + rc = TSS_Malloc(&p_caller_Xbin, BN_num_bytes(p_caller_Xbn)); /* freed @12 */ + } + if (rc == 0) { + rc = TSS_Malloc(&p_caller_Ybin , BN_num_bytes(p_caller_Ybn)); /* freed @13 */ + } + if (rc == 0) { + if (tssVverbose) printf("TSS_ECC_Salt: " + "Allocated space for ephemeral binary X and y\n"); + } + if (rc == 0) { + rc = TSS_Malloc(&p_tpmXbin, BN_num_bytes(p_tpmX)); /* freed @14 */ + } + if (rc == 0) { + length_p_tpmXbin = (unsigned int)BN_bn2bin(p_tpmX, p_tpmXbin); + if (tssVverbose) TSS_PrintAll("TSS_ECC_Salt: p_tpmXbin ", + p_tpmXbin, + length_p_tpmXbin); + length_p_caller_Xbin = (unsigned int)BN_bn2bin(p_caller_Xbn, p_caller_Xbin); + if (tssVverbose) TSS_PrintAll("TSS_ECC_Salt: p_caller_Xbin", + p_caller_Xbin, + length_p_caller_Xbin); + length_p_caller_Ybin = (unsigned int)BN_bn2bin(p_caller_Ybn, p_caller_Ybin); + if (tssVverbose) TSS_PrintAll("TSS_ECC_Salt: p_caller_Ybin", + p_caller_Ybin, + length_p_caller_Ybin); + } + /* in->encryptedSalt TPM2B_ENCRYPTED_SECRET is a size and TPMU_ENCRYPTED_SECRET secret. + TPMU_ENCRYPTED_SECRET is a TPMS_ECC_POINT + TPMS_ECC_POINT has two TPMB_ECC_PARAMETER, x and y + */ + if (rc == 0) { + /* TPMS_ECC_POINT 256/8 is a hard coded value for NIST P256, the only curve + currently supported */ + uint8_t *secret = encryptedSalt->t.secret; /* TPMU_ENCRYPTED_SECRET pointer for + clarity */ + /* TPM2B_ENCRYPTED_SECRET size */ + encryptedSalt->t.size = sizeof(uint16_t) + (256/8) + sizeof(uint16_t) + (256/8); + /* leading zeros, because some points may be less than 32 bytes */ + memset(secret, 0, sizeof(TPMU_ENCRYPTED_SECRET)); + /* TPMB_ECC_PARAMETER X point */ + *(uint16_t *)(secret) = htons(256/8); + memcpy(secret + + sizeof(uint16_t) + (256/8) - length_p_caller_Xbin, + p_caller_Xbin, length_p_caller_Xbin); + /* TPMB_ECC_PARAMETER Y point */ + *(uint16_t *)(secret + sizeof(uint16_t) + (256/8)) = htons(256/8); + memcpy(secret + + sizeof(uint16_t) + (256/8) + + sizeof(uint16_t) + (256/8) - length_p_caller_Ybin, + p_caller_Ybin, length_p_caller_Ybin); + } + if (rc == 0) { + if (tssVverbose) TSS_PrintAll("TSS_ECC_Salt: ECC encrypted salt", + encryptedSalt->t.secret, + encryptedSalt->t.size); + } + /* TPM2B_ECC_PARAMETER sharedX_For_KDFE */ + if (rc == 0) { + if (lengthSharedXBin > 32) { + if (tssVerbose) printf("TSS_ECC_Salt: " + "lengthSharedXBin %u too large\n", + lengthSharedXBin); + rc = TSS_RC_EC_EPHEMERAL_FAILURE; + } + } + if (rc == 0) { + sharedX_For_KDFE.t.size = 32; + memset(sharedX_For_KDFE.t.buffer, 0, sizeof(sharedX_For_KDFE.t.buffer)); + memcpy(sharedX_For_KDFE.t.buffer + 32 - lengthSharedXBin, + sharedXBin, lengthSharedXBin); + if (tssVverbose) TSS_PrintAll("TSS_ECC_Salt: sharedX_For_KDFE", + sharedX_For_KDFE.t.buffer, + sharedX_For_KDFE.t.size); + } + /* TPM2B_ECC_PARAMETER p_caller_X_For_KDFE */ + if (rc == 0) { + if (length_p_caller_Xbin > 32) { + if (tssVerbose) printf("TSS_ECC_Salt: " + "length_p_caller_Xbin %u too large\n", + length_p_caller_Xbin); + rc = TSS_RC_EC_EPHEMERAL_FAILURE; + } + } + if (rc == 0) { + p_caller_X_For_KDFE.t.size = 32; + memset(p_caller_X_For_KDFE.t.buffer, 0, sizeof(p_caller_X_For_KDFE.t.buffer)); + memcpy(p_caller_X_For_KDFE.t.buffer + 32 - length_p_caller_Xbin, + p_caller_Xbin, length_p_caller_Xbin); + if (tssVverbose) TSS_PrintAll("TSS_ECC_Salt: p_caller_X_For_KDFE", + p_caller_X_For_KDFE.t.buffer, + p_caller_X_For_KDFE.t.size); + } + /* p_tpmX_For_KDFE */ + if (rc == 0) { + if (length_p_tpmXbin > 32) { + if (tssVerbose) printf("TSS_ECC_Salt: " + "length_p_tpmXbin %u too large\n", + length_p_tpmXbin); + rc = TSS_RC_EC_EPHEMERAL_FAILURE; + } + } + if (rc == 0) { + p_tpmX_For_KDFE .t.size = 32; + memset(p_tpmX_For_KDFE.t.buffer, 0, sizeof(p_tpmX_For_KDFE.t.buffer)); + memcpy(p_tpmX_For_KDFE.t.buffer + 32 - length_p_tpmXbin, + p_tpmXbin, length_p_tpmXbin); + if (tssVverbose) TSS_PrintAll("TSS_ECC_Salt: p_tpmX_For_KDFE", + p_tpmX_For_KDFE.t.buffer, + p_tpmX_For_KDFE.t.size); + } + if (rc == 0) { + if (tssVverbose) printf("TSS_ECC_Salt: " + "Calling TSS_KDFE\n"); + /* TPM2B_DIGEST salt size is the largest supported digest algorithm. + This has already been validated when unmarshaling the Name hash algorithm. + */ + /* salt = KDFe(tpmKey_NameAlg, sharedX, "SECRET", P_caller, P_tpm, + tpmKey_NameAlgSizeBits) */ + salt->t.size = sizeInBytes; + rc = TSS_KDFE((uint8_t *)&salt->t.buffer, /* KDFe output */ + publicArea->nameAlg, /* hash algorithm */ + &sharedX_For_KDFE.b, /* Z (key) */ + "SECRET", /* KDFe label */ + &p_caller_X_For_KDFE.b, /* context U */ + &p_tpmX_For_KDFE.b, /* context V */ + sizeInBits); /* required size of key in bits */ + } + if (rc == 0) { + if (tssVverbose) TSS_PrintAll("TSS_ECC_Salt: salt", + (uint8_t *)&salt->t.buffer, + salt->t.size); + } + /* cleanup */ + if (myecc != NULL) EC_KEY_free(myecc); /* @1 */ + if (tpmPointPub != NULL) EC_POINT_free(tpmPointPub); /* @2 */ + if (p_tpmX != NULL) BN_clear_free(p_tpmX); /* @3 */ + if (zBn != NULL) BN_clear_free(zBn); /* @4 */ + if (rPoint != NULL) EC_POINT_free(rPoint); /* @5 */ + if (thepoint != NULL) BN_clear_free(thepoint); /* @6 */ + if (sharedX != NULL) BN_clear_free(sharedX); /* @7 */ + if (yBn != NULL) BN_clear_free(yBn); /* @8 */ + free(sharedXBin); /* @9 */ + if (p_caller_Xbn != NULL) BN_clear_free(p_caller_Xbn); /* @10 */ + if (p_caller_Ybn != NULL) BN_clear_free(p_caller_Ybn); /* @11 */ + free(p_caller_Xbin); /* @12 */ + free(p_caller_Ybin); /* @13 */ + free(p_tpmXbin); /* @14 */ + if (bigY != NULL) BN_clear_free(bigY); /* @15 */ + if (eCurveData.ctx != NULL) BN_CTX_free(eCurveData.ctx); /* @16 */ +#endif /* 0 */ + return rc; +} + +#endif /* TPM_TSS_NOECC */ + +/* + AES +*/ + +TPM_RC TSS_AES_GetEncKeySize(size_t *tssSessionEncKeySize) +{ + *tssSessionEncKeySize = sizeof(mbedtls_aes_context); + return 0; +} +TPM_RC TSS_AES_GetDecKeySize(size_t *tssSessionDecKeySize) +{ + *tssSessionDecKeySize = sizeof(mbedtls_aes_context); + return 0; +} + +#define TSS_AES_KEY_BITS 128 + +#ifndef TPM_TSS_NOCRYPTO +#ifndef TPM_TSS_NOFILE + +TPM_RC TSS_AES_KeyGenerate(void *tssSessionEncKey, + void *tssSessionDecKey) +{ + TPM_RC rc = 0; + int irc; + unsigned char userKey[AES_128_BLOCK_SIZE_BYTES]; + const char *envKeyString = NULL; + unsigned char *envKeyBin = NULL; + size_t envKeyBinLen; + + if (rc == 0) { + envKeyString = getenv("TPM_SESSION_ENCKEY"); + } + if (envKeyString == NULL) { + /* If the env variable TPM_SESSION_ENCKEY is not set, generate a random key for this + TSS_CONTEXT */ + if (rc == 0) { + rc = TSS_RandBytes(userKey, AES_128_BLOCK_SIZE_BYTES); + } + } + /* The env variable TPM_SESSION_ENCKEY can set a (typically constant) encryption key. This is + useful for scripting, where the env variable is set to a random seed at the beginning of the + script. */ + else { + /* hexascii to binary */ + if (rc == 0) { + rc = TSS_Array_Scan(&envKeyBin, /* freed @1 */ + &envKeyBinLen, envKeyString); + } + /* range check */ + if (rc == 0) { + if (envKeyBinLen != AES_128_BLOCK_SIZE_BYTES) { + if (tssVerbose) + printf("TSS_AES_KeyGenerate: Error, env variable length %lu not %lu\n", + (unsigned long)envKeyBinLen, (unsigned long)sizeof(userKey)); + rc = TSS_RC_BAD_PROPERTY_VALUE; + } + } + /* copy the binary to the common userKey for use below */ + if (rc == 0) { + memcpy(userKey, envKeyBin, envKeyBinLen); + } + } + /* translate to an mbedtls key token */ + if (rc == 0) { + mbedtls_aes_init(tssSessionEncKey); + irc = mbedtls_aes_setkey_enc(tssSessionEncKey, userKey, TSS_AES_KEY_BITS); + if (irc != 0) { + TSS_Error(irc); + if (tssVerbose) + printf("TSS_AES_KeyGenerate: Error setting mbedtls AES encryption key\n"); + rc = TSS_RC_AES_KEYGEN_FAILURE; + } + } + if (rc == 0) { + mbedtls_aes_init(tssSessionDecKey); + irc = mbedtls_aes_setkey_dec(tssSessionDecKey, userKey, TSS_AES_KEY_BITS); + if (irc != 0) { + TSS_Error(irc); + if (tssVerbose) { + printf("TSS_AES_KeyGenerate: Error setting mbedtls AES decryption key\n"); + } + rc = TSS_RC_AES_KEYGEN_FAILURE; + } + } + free(envKeyBin); /* @1 */ + return rc; +} + +#endif +#endif + +/* TSS_AES_Encrypt() is AES non-portable code to encrypt 'decrypt_data' to 'encrypt_data' using CBC. + This function uses the session encryption key for encrypting session state. + + The stream is padded as per PKCS#7 / RFC2630 + + 'encrypt_data' must be free by the caller +*/ + +#ifndef TPM_TSS_NOFILE + +TPM_RC TSS_AES_Encrypt(void *tssSessionEncKey, + unsigned char **encrypt_data, /* output, caller frees */ + uint32_t *encrypt_length, /* output */ + const unsigned char *decrypt_data, /* input */ + uint32_t decrypt_length) /* input */ +{ + TPM_RC rc = 0; + int irc; + uint32_t pad_length; + unsigned char *decrypt_data_pad; + unsigned char ivec[AES_128_BLOCK_SIZE_BYTES]; /* initial chaining vector */ + + decrypt_data_pad = NULL; /* freed @1 */ + if (rc == 0) { + /* calculate the pad length and padded data length */ + pad_length = AES_128_BLOCK_SIZE_BYTES - (decrypt_length % AES_128_BLOCK_SIZE_BYTES); + *encrypt_length = decrypt_length + pad_length; + /* allocate memory for the encrypted response */ + rc = TSS_Malloc(encrypt_data, *encrypt_length); + } + /* allocate memory for the padded decrypted data */ + if (rc == 0) { + rc = TSS_Malloc(&decrypt_data_pad, *encrypt_length); + } + /* pad the decrypted clear text data */ + if (rc == 0) { + /* unpadded original data */ + memcpy(decrypt_data_pad, decrypt_data, decrypt_length); + /* last gets pad = pad length */ + memset(decrypt_data_pad + decrypt_length, pad_length, pad_length); + /* set the IV */ + memset(ivec, 0, sizeof(ivec)); + /* encrypt the padded input to the output */ + irc = mbedtls_aes_crypt_cbc(tssSessionEncKey, + MBEDTLS_AES_ENCRYPT, + *encrypt_length, + ivec, + decrypt_data_pad, + *encrypt_data); + if (irc != 0) { + TSS_Error(irc); + if (tssVerbose) printf("TSS_AES_Encrypt: Encryption failure -%04x\n", -irc); + rc = TSS_RC_AES_ENCRYPT_FAILURE; + } + } + free(decrypt_data_pad); /* @1 */ + return rc; +} + +#endif /* TPM_TSS_NOFILE */ + +/* TSS_AES_Decrypt() is AES non-portable code to decrypt 'encrypt_data' to 'decrypt_data' using CBC. + This function uses the session encryption key for decrypting session state. + + The stream must be padded as per PKCS#7 / RFC2630 + + decrypt_data must be free by the caller +*/ + +#ifndef TPM_TSS_NOFILE + +TPM_RC TSS_AES_Decrypt(void *tssSessionDecKey, + unsigned char **decrypt_data, /* output, caller frees */ + uint32_t *decrypt_length, /* output */ + const unsigned char *encrypt_data, /* input */ + uint32_t encrypt_length) /* input */ +{ + TPM_RC rc = 0; + int irc; + uint32_t pad_length; + uint32_t i; + unsigned char *pad_data; + unsigned char ivec[AES_128_BLOCK_SIZE_BYTES]; /* initial chaining vector */ + + /* sanity check encrypted length */ + if (rc == 0) { + if (encrypt_length < AES_128_BLOCK_SIZE_BYTES) { + if (tssVerbose) printf("TSS_AES_Decrypt: Error, bad length %u\n", + encrypt_length); + rc = TSS_RC_AES_DECRYPT_FAILURE; + } + } + /* allocate memory for the padded decrypted data */ + if (rc == 0) { + rc = TSS_Malloc(decrypt_data, encrypt_length); + } + /* decrypt the input to the padded output */ + if (rc == 0) { + /* set the IV */ + memset(ivec, 0, sizeof(ivec)); + /* decrypt the padded input to the output */ + irc = mbedtls_aes_crypt_cbc(tssSessionDecKey, + MBEDTLS_AES_DECRYPT, + encrypt_length, + ivec, + encrypt_data, + *decrypt_data); + } + /* get the pad length */ + if (rc == 0) { + /* get the pad length from the last byte */ + pad_length = (uint32_t)*(*decrypt_data + encrypt_length - 1); + /* sanity check the pad length */ + if ((pad_length == 0) || + (pad_length > AES_128_BLOCK_SIZE_BYTES)) { + if (tssVerbose) printf("TSS_AES_Decrypt: Error, illegal pad length\n"); + rc = TSS_RC_AES_DECRYPT_FAILURE; + } + } + if (rc == 0) { + /* get the unpadded length */ + *decrypt_length = encrypt_length - pad_length; + /* pad starting point */ + pad_data = *decrypt_data + *decrypt_length; + /* sanity check the pad */ + for (i = 0 ; (rc == 0) && (i < pad_length) ; i++, pad_data++) { + if (*pad_data != pad_length) { + if (tssVerbose) printf("TSS_AES_Decrypt: Error, bad pad %02x at index %u\n", + *pad_data, i); + rc = TSS_RC_AES_DECRYPT_FAILURE; + } + } + } + return rc; +} + +#endif /* TPM_TSS_NOFILE */ + +/* TSS_AES_EncryptCFB() is the unpadded AES used for command parameter encryption. + + The input and output are the same length. +*/ + +TPM_RC TSS_AES_EncryptCFB(uint8_t *dOut, /* OUT: the encrypted data */ + uint32_t keySizeInBits, /* IN: key size in bits */ + uint8_t *key, /* IN: key buffer */ + uint8_t *iv, /* IN/OUT: IV for decryption */ + uint32_t dInSize, /* IN: data size */ + uint8_t *dIn) /* IN: data buffer */ +{ + TPM_RC rc = 0; + int irc; + mbedtls_aes_context aes_ctx; + + mbedtls_aes_init(&aes_ctx); + if (rc == 0) { + irc = mbedtls_aes_setkey_enc(&aes_ctx, key, keySizeInBits); /* freed @1 */ + if (irc != 0) { + TSS_Error(irc); + rc = TSS_RC_AES_KEYGEN_FAILURE; + } + } + if (rc == 0) { + size_t iv_off = 0; + irc = mbedtls_aes_crypt_cfb128(&aes_ctx, + MBEDTLS_AES_ENCRYPT, + dInSize, + &iv_off, + iv, + dIn, + dOut); + if (irc != 0) { + TSS_Error(irc); + if (tssVerbose) printf("TSS_AES_EncryptCFB: Encryption failure -%04x\n", -irc); + rc = TSS_RC_AES_ENCRYPT_FAILURE; + } + } + mbedtls_aes_free(&aes_ctx); /* @1 */ + return rc; +} + +/* TSS_AES_DecryptCFB() is the unpadded AES used for response parameter decryption. + + The input and output are the same length. +*/ + +TPM_RC TSS_AES_DecryptCFB(uint8_t *dOut, /* OUT: the decrypted data */ + uint32_t keySizeInBits, /* IN: key size in bits */ + uint8_t *key, /* IN: key buffer */ + uint8_t *iv, /* IN/OUT: IV for decryption. */ + uint32_t dInSize, /* IN: data size */ + uint8_t *dIn) /* IN: data buffer */ +{ + TPM_RC rc = 0; + int irc; + mbedtls_aes_context aes_ctx; + + if (tssVverbose) TSS_PrintAll("TSS_AES_DecryptCFB:", key, keySizeInBits/8); + mbedtls_aes_init(&aes_ctx); + if (rc == 0) { + irc = mbedtls_aes_setkey_enc(&aes_ctx, key, keySizeInBits); /* freed @1 */ + if (irc != 0) { + TSS_Error(irc); + rc = TSS_RC_AES_KEYGEN_FAILURE; + } + } + if (rc == 0) { + size_t iv_off = 0; + irc = mbedtls_aes_crypt_cfb128(&aes_ctx, + MBEDTLS_AES_DECRYPT, + dInSize, + &iv_off, + iv, + dIn, + dOut); + if (irc != 0) { + TSS_Error(irc); + if (tssVerbose) printf("TSS_AES_DecryptCFB: Decryption failure -%04x\n", -irc); + rc = TSS_RC_AES_DECRYPT_FAILURE; + } + } + mbedtls_aes_free(&aes_ctx); /* @1 */ + return rc; +} diff --git a/libstb/tss2/tsscryptouv.c b/libstb/tss2/tsscryptouv.c new file mode 100644 index 0000000..c33cfd1 --- /dev/null +++ b/libstb/tss2/tsscryptouv.c @@ -0,0 +1,67 @@ +/********************************************************************************/ +/* */ +/* TSS Library Dependent Crypto Support */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* ECC Salt functions written by Bill Martin */ +/* */ +/* (c) Copyright IBM Corporation 2015, 2018. */ +/* */ +/* All rights reserved. */ +/* */ +/* Redistribution and use in source and binary forms, with or without */ +/* modification, are permitted provided that the following conditions are */ +/* met: */ +/* */ +/* Redistributions of source code must retain the above copyright notice, */ +/* this list of conditions and the following disclaimer. */ +/* */ +/* 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. */ +/* */ +/* Neither the names of the IBM Corporation nor the names of its */ +/* contributors may be used to endorse or promote products derived from */ +/* this software without specific prior written permission. */ +/* */ +/* 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. */ +/********************************************************************************/ + +/* Interface to OpenSSL version 1.0 or 1.1 crypto library */ + +#include <string.h> +#include <stdio.h> +#include <stdlib.h> + +#ifdef TPM_POSIX +#include <netinet/in.h> +#endif + +#include <libstb/crypto/include/uv-crypto.h> + +#include <ibmtss/tssresponsecode.h> +#include <ibmtss/tssutils.h> +#include <ibmtss/tssprint.h> +#include <ibmtss/tsserror.h> + +#include <ibmtss/tsscryptoh.h> +#include <ibmtss/tsscrypto.h> + +extern int tssVverbose; +extern int tssVerbose; + +TPM_RC TSS_RandBytes(unsigned char *buffer, uint32_t size) +{ + return uv_crypto_rand_bytes(buffer, size); /* output random */ +} + diff --git a/libstb/tss2/tssdev.h b/libstb/tss2/tssdev.h new file mode 100644 index 0000000..efe00b1 --- /dev/null +++ b/libstb/tss2/tssdev.h @@ -0,0 +1,61 @@ +/********************************************************************************/ +/* */ +/* Linux Device Transmit and Receive Utilities */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: tssdev.h 1015 2017-06-07 13:16:34Z kgoldman $ */ +/* */ +/* (c) Copyright IBM Corporation 2015. */ +/* */ +/* All rights reserved. */ +/* */ +/* Redistribution and use in source and binary forms, with or without */ +/* modification, are permitted provided that the following conditions are */ +/* met: */ +/* */ +/* Redistributions of source code must retain the above copyright notice, */ +/* this list of conditions and the following disclaimer. */ +/* */ +/* 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. */ +/* */ +/* Neither the names of the IBM Corporation nor the names of its */ +/* contributors may be used to endorse or promote products derived from */ +/* this software without specific prior written permission. */ +/* */ +/* 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. */ +/********************************************************************************/ + +/* This is not a public header. It should not be used by applications. */ + +#ifndef TSSDEV_H +#define TSSDEV_H + +#include <stdint.h> + +#ifdef __cplusplus +extern "C" { +#endif + + TPM_RC TSS_Dev_Transmit(TSS_CONTEXT *tssContext, + uint8_t *responseBuffer, uint32_t *read, + const uint8_t *commandBuffer, uint32_t written, + const char *message); + TPM_RC TSS_Dev_Close(TSS_CONTEXT *tssContext); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libstb/tss2/tssdevskiboot.c b/libstb/tss2/tssdevskiboot.c new file mode 100644 index 0000000..394270a --- /dev/null +++ b/libstb/tss2/tssdevskiboot.c @@ -0,0 +1,135 @@ +/********************************************************************************/ +/* */ +/* Skiboot Transmit and Receive Utilities */ +/* */ +/* (c) Copyright IBM Corporation 2019. */ +/* */ +/* All rights reserved. */ +/* */ +/* Redistribution and use in source and binary forms, with or without */ +/* modification, are permitted provided that the following conditions are */ +/* met: */ +/* */ +/* Redistributions of source code must retain the above copyright notice, */ +/* this list of conditions and the following disclaimer. */ +/* */ +/* 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. */ +/* */ +/* Neither the names of the IBM Corporation nor the names of its */ +/* contributors may be used to endorse or promote products derived from */ +/* this software without specific prior written permission. */ +/* */ +/* 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. */ +/********************************************************************************/ + + +#ifdef __SKIBOOT__ + +#undef DEBUG +#define pr_fmt(fmt) "TSS-DEV-SKIBOOT: " fmt + +#include <ibmtss/tssresponsecode.h> +#include <ibmtss/tsserror.h> +#include <ibmtss/tssprint.h> +#include "tssproperties.h" + +#include <libstb/tpm2.h> +#include <skiboot.h> +#include "tssdevskiboot.h" + +extern int tssVerbose; + +TPM_RC TSS_Skiboot_Transmit(TSS_CONTEXT *tssContext, + uint8_t *responseBuffer, uint32_t *read, + const uint8_t *commandBuffer, uint32_t written, + const char *message) +{ + TPM_RC rc; + struct tpm_dev *tpm_device; + struct tpm_driver *tpm_driver; + size_t size; + +// devuv_dprintf("%s: Enter\n", __func__); + /* open on first transmit */ +// if (tssContext->tssFirstTransmit) { +// rc = TSS_Dev_UV_Open(tssContext); +// if (rc) { +// goto out; +// } +// } + + if (tssVerbose) { + printf("%s: %s\n", __func__, message); + TSS_PrintAll("TSS_Skiboot_Send", commandBuffer, written); + } + + if (!tssContext->tpm_device || !tssContext->tpm_driver) { + printf("%s: tpm device/driver not set\n", __func__); + return TSS_RC_NO_CONNECTION; + } + + tssContext->tssFirstTransmit = FALSE; + tpm_device = tssContext->tpm_device; + tpm_driver = tssContext->tpm_driver; + + memcpy(responseBuffer, commandBuffer, written); + size = *read; + rc = tpm_driver->transmit(tpm_device, responseBuffer, written, &size); + *read = size; + + if (tssVerbose) + TSS_PrintAll("TSS_Skiboot_Receive", responseBuffer, *read); + +#if 0 + printf("%s: sending to tpm...\n", __func__); + rc = tpm_driver->send(tpm_device, commandBuffer, written); + printf("%s: sent to tpm, rc=%x written %d\n", __func__, rc, written); + + if (rc) { + prlog(PR_INFO, "send error %d", rc); + return TSS_RC_BAD_CONNECTION; + } + + printf("%s: receiving data from the tpm...read %d\n", __func__, *read); + rc = tpm_driver->receive(tpm_device, responseBuffer, read); + printf("%s: received data from the tpm, rc = %d, read %d\n", __func__, + rc, *read); +#endif + if (rc) { + printf("%s: receive error %d\n", __func__, rc); + return TSS_RC_BAD_CONNECTION; + } + + if (*read < (sizeof(TPM_ST) + 2*sizeof(uint32_t))) { + prlog(PR_INFO, "received %d bytes < header\n", *read); + return TSS_RC_MALFORMED_RESPONSE; + } + + /* Now we need to get the actual return code from the response buffer + * and delivery it to the upper layers + */ + rc = be32_to_cpu(*(uint32_t *)(responseBuffer + sizeof(TPM_ST)+ sizeof(uint32_t))); + return rc; +} + +/* +TPM_RC TSS_Dev_UV_Close(TSS_CONTEXT *tssContext) +{ + devuv_dprintf("%s: Closing %s\n", __func__, tssContext->tssDevice); + svm_tss_tpm_close(tssContext->uv_ctx); + return 0; +} +*/ +#endif /* __SKIBOOT__ */ diff --git a/libstb/tss2/tssdevskiboot.h b/libstb/tss2/tssdevskiboot.h new file mode 100644 index 0000000..cfa3a8c --- /dev/null +++ b/libstb/tss2/tssdevskiboot.h @@ -0,0 +1,52 @@ +/********************************************************************************/ +/* */ +/* Skiboot Dev Interface */ +/* */ +/* (c) Copyright IBM Corporation 2019. */ +/* */ +/* All rights reserved. */ +/* */ +/* Redistribution and use in source and binary forms, with or without */ +/* modification, are permitted provided that the following conditions are */ +/* met: */ +/* */ +/* Redistributions of source code must retain the above copyright notice, */ +/* this list of conditions and the following disclaimer. */ +/* */ +/* 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. */ +/* */ +/* Neither the names of the IBM Corporation nor the names of its */ +/* contributors may be used to endorse or promote products derived from */ +/* this software without specific prior written permission. */ +/* */ +/* 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. */ +/********************************************************************************/ + +/* This is not a public header. It should not be used by applications. */ + +#ifdef __SKIBOOT__ + +#ifndef TSSDEVSKIBOOT_H +#define TSSDEVSKIBOOT_H + +#include <stdint.h> + +TPM_RC TSS_Skiboot_Transmit(TSS_CONTEXT *tssContext, + uint8_t *responseBuffer, uint32_t *read, + const uint8_t *commandBuffer, uint32_t written, + const char *message); + +#endif /* TSSDEVSKIBOOT_H */ +#endif /* __SKIBOOT__ */ diff --git a/libstb/tss2/tssdevuv.c b/libstb/tss2/tssdevuv.c new file mode 100644 index 0000000..aeaf5b0 --- /dev/null +++ b/libstb/tss2/tssdevuv.c @@ -0,0 +1,219 @@ +/********************************************************************************/ +/* */ +/* UV Transmit and Receive Utilities */ +/* */ +/* (c) Copyright IBM Corporation 2019. */ +/* */ +/* All rights reserved. */ +/* */ +/* Redistribution and use in source and binary forms, with or without */ +/* modification, are permitted provided that the following conditions are */ +/* met: */ +/* */ +/* Redistributions of source code must retain the above copyright notice, */ +/* this list of conditions and the following disclaimer. */ +/* */ +/* 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. */ +/* */ +/* Neither the names of the IBM Corporation nor the names of its */ +/* contributors may be used to endorse or promote products derived from */ +/* this software without specific prior written permission. */ +/* */ +/* 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. */ +/********************************************************************************/ + + +#ifdef __ULTRAVISOR__ + +#undef DEBUG +#define pr_fmt(fmt) "TSS-DEV-UV: " fmt + +#include <svm/svm-tss.h> + +#include <ibmtss/tssresponsecode.h> +#include <ibmtss/tsserror.h> +#include <ibmtss/tssprint.h> +#include "tssproperties.h" + +#include "tssdevuv.h" +#include "tssuv.h" + +#define DEBUG +#ifdef DEBUG +#define devuv_dprintf(fmt...) do { printf(fmt); } while(0) +#else +#define devuv_dprintf(fmt...) do { } while(0) +#endif + +/* TSS_Dev_UV_Open() updates state for open */ + +static uint32_t TSS_Dev_UV_Open(TSS_CONTEXT *tssContext) +{ + uint32_t rc; + + devuv_dprintf("%s: Opening %s\n", __func__, tssContext->tssDevice); + /** @todo (andmike) Add to tssContext for tracking open, close */ + rc = svm_tss_tpm_open(tssContext->uv_ctx); + if (rc) { + devuv_dprintf("%s: Error opening %s\n", __func__, tssContext->tssDevice); + rc = TSS_RC_NO_CONNECTION; + } + + return rc; +} + +/* TSS_Dev_Send_Cmd() sends the TPM command buffer. + + Returns an error if the device write fails. +*/ + +static uint32_t TSS_Dev_UV_Send_Cmd(TSS_CONTEXT *tssContext, + const uint8_t *buffer, uint16_t length, + const char *message) +{ + uint32_t rc = 0; + ssize_t bytes; + + devuv_dprintf("%s: Enter\n", __func__); + if (message != NULL) { + devuv_dprintf("%s: %s\n", __func__, message); + } + + bytes = svm_tss_tpm_write(tssContext->uv_ctx, buffer, length); + if (bytes < 0) { + devuv_dprintf("%s: write error %ld\n", + __func__, bytes); + rc = TSS_RC_BAD_CONNECTION; + } + + return rc; +} + +/* TSS_Dev_Recv_Cmd() reads a response buffer. 'buffer' must be at least + MAX_RESPONSE_SIZE bytes. + + Returns TPM packet error code. + + Validates that the packet length and the packet responseSize match +*/ + +static uint32_t TSS_Dev_UV_Recv_Cmd(TSS_CONTEXT *tssContext, + uint8_t *buffer, uint32_t *length) +{ + uint32_t rc; + ssize_t bytes; + uint32_t responseSize; + uint32_t responseCode; + + devuv_dprintf("%s: Enter\n", __func__); + bytes = svm_tss_tpm_read(tssContext->uv_ctx, buffer, MAX_RESPONSE_SIZE); + if (bytes <= 0) { + rc = TSS_RC_BAD_CONNECTION; + if (bytes < 0) { + devuv_dprintf("%s: read error %ld\n", + __func__, bytes); + } + goto out; + } + + /* verify that there is at least a tag, responseSize, and responseCode */ + + if ((unsigned int)bytes < (sizeof(TPM_ST) + sizeof(uint32_t) + sizeof(uint32_t))) { + devuv_dprintf("%s: read bytes %ld < header\n", __func__, bytes); + rc = TSS_RC_MALFORMED_RESPONSE; + goto out; + } + + /* get responseSize from the packet */ + + responseSize = be32_to_cpu(*(uint32_t *)(buffer + sizeof(TPM_ST))); + /* sanity check against the length actually received, the return code */ + if ((uint32_t)bytes != responseSize) { + devuv_dprintf("%s: read bytes %u != responseSize %u\n", __func__, + (uint32_t)bytes, responseSize); + devuv_dprintf("%s: buffer %x %x %x %x %x %x %x %x %x %x\n", __func__, + buffer[0], + buffer[1], + buffer[2], + buffer[3], + buffer[4], + buffer[5], + buffer[6], + buffer[7], + buffer[8], + buffer[9]); + rc = TSS_RC_BAD_CONNECTION; + goto out; + } + + /* read the TPM return code from the packet */ + + responseCode = be32_to_cpu(*(uint32_t *)(buffer + sizeof(TPM_ST)+ sizeof(uint32_t))); + rc = responseCode; + *length = responseSize; + +out: + devuv_dprintf("%s: rc %08x\n", __func__, rc); + return rc; +} + +/* TSS_Dev_Transmit() transmits the command and receives the response. + + Can return device transmit and receive packet errors, but normally returns + the TPM response code. +*/ + +TPM_RC TSS_Dev_UV_Transmit(TSS_CONTEXT *tssContext, + uint8_t *responseBuffer, uint32_t *read, + const uint8_t *commandBuffer, uint32_t written, + const char *message) +{ + TPM_RC rc; + + devuv_dprintf("%s: Enter\n", __func__); + /* open on first transmit */ + if (tssContext->tssFirstTransmit) { + rc = TSS_Dev_UV_Open(tssContext); + if (rc) { + goto out; + } + } + + tssContext->tssFirstTransmit = FALSE; + + /* send the command. Error if the device send fails. */ + rc = TSS_Dev_UV_Send_Cmd(tssContext, commandBuffer, written, message); + if (rc) { + goto out; + } + + /* receive the response. Returns errors, malformed response errors. + Else returns the TPM response code. */ + + rc = TSS_Dev_UV_Recv_Cmd(tssContext, responseBuffer, read); + +out: + return rc; +} + + +TPM_RC TSS_Dev_UV_Close(TSS_CONTEXT *tssContext) +{ + devuv_dprintf("%s: Closing %s\n", __func__, tssContext->tssDevice); + svm_tss_tpm_close(tssContext->uv_ctx); + return 0; +} + +#endif /* TPM_POSIX */ diff --git a/libstb/tss2/tssdevuv.h b/libstb/tss2/tssdevuv.h new file mode 100644 index 0000000..4374d99 --- /dev/null +++ b/libstb/tss2/tssdevuv.h @@ -0,0 +1,58 @@ +/********************************************************************************/ +/* */ +/* UV Interface */ +/* */ +/* (c) Copyright IBM Corporation 2019. */ +/* */ +/* All rights reserved. */ +/* */ +/* Redistribution and use in source and binary forms, with or without */ +/* modification, are permitted provided that the following conditions are */ +/* met: */ +/* */ +/* Redistributions of source code must retain the above copyright notice, */ +/* this list of conditions and the following disclaimer. */ +/* */ +/* 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. */ +/* */ +/* Neither the names of the IBM Corporation nor the names of its */ +/* contributors may be used to endorse or promote products derived from */ +/* this software without specific prior written permission. */ +/* */ +/* 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. */ +/********************************************************************************/ + +/* This is not a public header. It should not be used by applications. */ + +#ifndef TSSDEVUV_H +#define TSSDEVUV_H + +#include <stdint.h> + +#ifdef __cplusplus +extern "C" { +#endif + + TPM_RC TSS_Dev_UV_Transmit(TSS_CONTEXT *tssContext, + uint8_t *responseBuffer, uint32_t *read, + const uint8_t *commandBuffer, uint32_t written, + const char *message); + TPM_RC TSS_Dev_UV_Close(TSS_CONTEXT *tssContext); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libstb/tss2/tssmarshal.c b/libstb/tss2/tssmarshal.c new file mode 100644 index 0000000..ba6f194 --- /dev/null +++ b/libstb/tss2/tssmarshal.c @@ -0,0 +1,7713 @@ +/********************************************************************************/ +/* */ +/* TSS Marshal and Unmarshal */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: tssmarshal.c 1303 2018-08-20 16:49:52Z kgoldman $ */ +/* */ +/* (c) Copyright IBM Corporation 2015, 2018. */ +/* */ +/* All rights reserved. */ +/* */ +/* Redistribution and use in source and binary forms, with or without */ +/* modification, are permitted provided that the following conditions are */ +/* met: */ +/* */ +/* Redistributions of source code must retain the above copyright notice, */ +/* this list of conditions and the following disclaimer. */ +/* */ +/* 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. */ +/* */ +/* Neither the names of the IBM Corporation nor the names of its */ +/* contributors may be used to endorse or promote products derived from */ +/* this software without specific prior written permission. */ +/* */ +/* 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. */ +/********************************************************************************/ + +#include <string.h> + +#include <ibmtss/tssmarshal.h> +#include <ibmtss/tsserror.h> +#include <ibmtss/tssprint.h> +#include <ibmtss/Unmarshal_fp.h> + +/* This file holds: + + --------------------------------------- + + Recommended functions - with an unsigned size + + * Primary marshal functions TSS_primary_Marshalu + * Primary unmarshal functions TSS_primary_Unmarshalu in Unmarshal.c + * TPM 2.0 structure marshal functions TSS_structure_Marshalu + * TPM 2.0 structure unmarshal functions TSS_structure_Unmarshalu in Unmarshal.c + * TPM 2.0 command marshal functions TSS_command_In_Marshalu + TPM 2.0 command unmarshal functions command_In_Unmarshal + * TPM 2.0 response unmarshal functions TSS_response_Out_Unmarshalu + + --------------------------------------- + + Deprecated functions - with a signed size + + * Primary marshal functions TSS_primary_Marshal + * Primary unmarshal functions primary_Unmarshal in Unmarshal.c + * TPM 2.0 structure marshal functions TSS_structure_Marshal + * TPM 2.0 structure unmarshal functions structure_Unmarshal in Unmarshal.c + * TPM 2.0 command marshal functions TSS_command_In_Marshal + * TPM 2.0 response unmarshal functions TSS_response_Out_Unmarshal + + * are exposed in /tss2/ +*/ + +/* The marshaling function prototype pattern is: + + Return: + + An extra return code, TSS_RC_INSUFFICIENT_BUFFER, indicates that the supplied buffer size is too + small. The TPM functions assert. + + 'source' is the structure to be marshaled. + 'written' is the __additional__ number of bytes written. + 'buffer' is the buffer written. + ' size' is the remaining size of the buffer. + + If 'buffer' is NULL, 'written' is updated but no marshaling is performed. This is used in a two + pass pattern, where the first pass returns the size of the buffer to be malloc'ed. + + If 'size' is NULL, the source is marshaled without a size check. The caller must ensure that + the buffer is sufficient, often due to a malloc after the first pass. */ + +/* Marshal functions shared by TPM 1.2 and TPM 2.0 */ + +/* The functions with the _Marshalu suffix are preferred. They use an unsigned size. The functions + with _Marshalu are deprecated. */ + +TPM_RC +TSS_UINT8_Marshalu(const UINT8 *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (buffer != NULL) { /* if buffer is NULL, don't marshal, just return written */ + /* if size is NULL, ignore it, else check sufficient */ + if ((size == NULL) || (*size >= sizeof(UINT8))) { + /* marshal, move the buffer */ + (*buffer)[0] = *source; + *buffer += sizeof(UINT8); + /* is size was supplied, update it */ + if (size != NULL) { + *size -= sizeof(UINT8); + } + } + else { + rc = TSS_RC_INSUFFICIENT_BUFFER; + } + } + *written += sizeof(UINT8); + return rc; +} + +TPM_RC +TSS_INT8_Marshalu(const INT8 *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + rc = TSS_UINT8_Marshalu((const UINT8 *)source, written, buffer, size); + return rc; +} + +TPM_RC +TSS_UINT16_Marshalu(const UINT16 *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (buffer != NULL) { + if ((size == NULL) || (*size >= sizeof(uint16_t))) { + + (*buffer)[0] = (BYTE)((*source >> 8) & 0xff); + (*buffer)[1] = (BYTE)((*source >> 0) & 0xff); + *buffer += sizeof(uint16_t); + + if (size != NULL) { + *size -= sizeof(uint16_t); + } + } + else { + rc = TSS_RC_INSUFFICIENT_BUFFER; + } + } + *written += sizeof(uint16_t); + return rc; +} + +TPM_RC +TSS_UINT32_Marshalu(const UINT32 *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (buffer != NULL) { + if ((size == NULL) || (*size >= sizeof(uint32_t))) { + + (*buffer)[0] = (BYTE)((*source >> 24) & 0xff); + (*buffer)[1] = (BYTE)((*source >> 16) & 0xff); + (*buffer)[2] = (BYTE)((*source >> 8) & 0xff); + (*buffer)[3] = (BYTE)((*source >> 0) & 0xff); + *buffer += sizeof(uint32_t); + + if (size != NULL) { + *size -= sizeof(uint32_t); + } + } + else { + rc = TSS_RC_INSUFFICIENT_BUFFER; + } + } + *written += sizeof(uint32_t); + return rc; +} + +TPM_RC +TSS_INT32_Marshalu(const INT32 *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + rc = TSS_UINT32_Marshalu((const UINT32 *)source, written, buffer, size); + return rc; +} + +TPM_RC +TSS_UINT64_Marshalu(const UINT64 *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (buffer != NULL) { + if ((size == NULL) || (*size >= sizeof(UINT64))) { + + (*buffer)[0] = (BYTE)((*source >> 56) & 0xff); + (*buffer)[1] = (BYTE)((*source >> 48) & 0xff); + (*buffer)[2] = (BYTE)((*source >> 40) & 0xff); + (*buffer)[3] = (BYTE)((*source >> 32) & 0xff); + (*buffer)[4] = (BYTE)((*source >> 24) & 0xff); + (*buffer)[5] = (BYTE)((*source >> 16) & 0xff); + (*buffer)[6] = (BYTE)((*source >> 8) & 0xff); + (*buffer)[7] = (BYTE)((*source >> 0) & 0xff); + *buffer += sizeof(UINT64); + + if (size != NULL) { + *size -= sizeof(UINT64); + } + } + else { + rc = TSS_RC_INSUFFICIENT_BUFFER; + } + } + *written += sizeof(UINT64); + return rc; +} + +TPM_RC +TSS_Array_Marshalu(const BYTE *source, uint16_t sourceSize, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (buffer != NULL) { + if ((size == NULL) || (*size >= sourceSize)) { + memcpy(*buffer, source, sourceSize); + + *buffer += sourceSize; + + if (size != NULL) { + *size -= sourceSize; + } + } + else { + rc = TSS_RC_INSUFFICIENT_BUFFER; + } + } + *written += sourceSize; + return rc; +} + + +#ifdef TPM_TPM20 + +/* + TPM 2.0 Command parameter marshaling +*/ + +TPM_RC +TSS_Startup_In_Marshalu(const Startup_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPM_SU_Marshalu(&source->startupType, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_Shutdown_In_Marshalu(const Shutdown_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPM_SU_Marshalu(&source->shutdownType, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_SelfTest_In_Marshalu(const SelfTest_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_YES_NO_Marshalu(&source->fullTest, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_IncrementalSelfTest_In_Marshalu(const IncrementalSelfTest_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPML_ALG_Marshalu(&source->toTest, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_StartAuthSession_In_Marshalu(const StartAuthSession_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_DH_OBJECT_Marshalu(&source->tpmKey, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMI_DH_ENTITY_Marshalu(&source->bind, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_NONCE_Marshalu(&source->nonceCaller, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_ENCRYPTED_SECRET_Marshalu(&source->encryptedSalt, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM_SE_Marshalu(&source->sessionType, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMT_SYM_DEF_Marshalu(&source->symmetric, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMI_ALG_HASH_Marshalu(&source->authHash, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_PolicyRestart_In_Marshalu(const PolicyRestart_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_SH_POLICY_Marshalu(&source->sessionHandle, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_Create_In_Marshalu(const Create_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_DH_OBJECT_Marshalu(&source->parentHandle, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_SENSITIVE_CREATE_Marshalu(&source->inSensitive, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_PUBLIC_Marshalu(&source->inPublic, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_DATA_Marshalu(&source->outsideInfo, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPML_PCR_SELECTION_Marshalu(&source->creationPCR, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_Load_In_Marshalu(const Load_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_DH_OBJECT_Marshalu(&source->parentHandle, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_PRIVATE_Marshalu(&source->inPrivate, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_PUBLIC_Marshalu(&source->inPublic, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_LoadExternal_In_Marshalu(const LoadExternal_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + /* optional parameter, use size as flag */ + if (source->inPrivate.b.size == 0) { /* not present */ + uint16_t zero = 0; + rc = TSS_UINT16_Marshalu(&zero, written, buffer, size); + } + else { + rc = TSS_TPM2B_SENSITIVE_Marshalu(&source->inPrivate, written, buffer, size); + } + } + if (rc == 0) { + rc = TSS_TPM2B_PUBLIC_Marshalu(&source->inPublic, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMI_RH_HIERARCHY_Marshalu(&source->hierarchy, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_ReadPublic_In_Marshalu(const ReadPublic_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_DH_OBJECT_Marshalu(&source->objectHandle, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_ActivateCredential_In_Marshalu(const ActivateCredential_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_DH_OBJECT_Marshalu(&source->activateHandle, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMI_DH_OBJECT_Marshalu(&source->keyHandle, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_ID_OBJECT_Marshalu(&source->credentialBlob, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_ENCRYPTED_SECRET_Marshalu(&source->secret, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_MakeCredential_In_Marshalu(const MakeCredential_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_DH_OBJECT_Marshalu(&source->handle, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_DIGEST_Marshalu(&source->credential, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_NAME_Marshalu(&source->objectName, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_Unseal_In_Marshalu(const Unseal_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_DH_OBJECT_Marshalu(&source->itemHandle, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_ObjectChangeAuth_In_Marshalu(const ObjectChangeAuth_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_DH_OBJECT_Marshalu(&source->objectHandle, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMI_DH_OBJECT_Marshalu(&source->parentHandle, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_AUTH_Marshalu(&source->newAuth, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_CreateLoaded_In_Marshalu(const CreateLoaded_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_DH_OBJECT_Marshalu(&source->parentHandle, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_SENSITIVE_CREATE_Marshalu(&source->inSensitive, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_TEMPLATE_Marshalu(&source->inPublic, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_Duplicate_In_Marshalu(const Duplicate_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_DH_OBJECT_Marshalu(&source->objectHandle, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMI_DH_OBJECT_Marshalu(&source->newParentHandle, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_DATA_Marshalu(&source->encryptionKeyIn, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMT_SYM_DEF_OBJECT_Marshalu(&source->symmetricAlg, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_Rewrap_In_Marshalu(const Rewrap_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_DH_OBJECT_Marshalu(&source->oldParent, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMI_DH_OBJECT_Marshalu(&source->newParent, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_PRIVATE_Marshalu(&source->inDuplicate, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_NAME_Marshalu(&source->name, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_ENCRYPTED_SECRET_Marshalu(&source->inSymSeed, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_Import_In_Marshalu(const Import_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_DH_OBJECT_Marshalu(&source->parentHandle, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_DATA_Marshalu(&source->encryptionKey, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_PUBLIC_Marshalu(&source->objectPublic, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_PRIVATE_Marshalu(&source->duplicate, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_ENCRYPTED_SECRET_Marshalu(&source->inSymSeed, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMT_SYM_DEF_OBJECT_Marshalu(&source->symmetricAlg, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_RSA_Encrypt_In_Marshalu(const RSA_Encrypt_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_DH_OBJECT_Marshalu(&source->keyHandle, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_PUBLIC_KEY_RSA_Marshalu(&source->message, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMT_RSA_DECRYPT_Marshalu(&source->inScheme, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_DATA_Marshalu(&source->label, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_RSA_Decrypt_In_Marshalu(const RSA_Decrypt_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_DH_OBJECT_Marshalu(&source->keyHandle, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_PUBLIC_KEY_RSA_Marshalu(&source->cipherText, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMT_RSA_DECRYPT_Marshalu(&source->inScheme, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_DATA_Marshalu(&source->label, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_ECDH_KeyGen_In_Marshalu(const ECDH_KeyGen_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_DH_OBJECT_Marshalu(&source->keyHandle, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_ECDH_ZGen_In_Marshalu(const ECDH_ZGen_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_DH_OBJECT_Marshalu(&source->keyHandle, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_ECC_POINT_Marshalu(&source->inPoint, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_ECC_Parameters_In_Marshalu(const ECC_Parameters_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_ECC_CURVE_Marshalu(&source->curveID, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_ZGen_2Phase_In_Marshalu(const ZGen_2Phase_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_DH_OBJECT_Marshalu(&source->keyA, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_ECC_POINT_Marshalu(&source->inQsB, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_ECC_POINT_Marshalu(&source->inQeB, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMI_ECC_KEY_EXCHANGE_Marshalu(&source->inScheme, written, buffer, size); + } + if (rc == 0) { + rc = TSS_UINT16_Marshalu(&source->counter, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_EncryptDecrypt_In_Marshalu(const EncryptDecrypt_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_DH_OBJECT_Marshalu(&source->keyHandle, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMI_YES_NO_Marshalu(&source->decrypt, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMI_ALG_CIPHER_MODE_Marshalu(&source->mode, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_IV_Marshalu(&source->ivIn, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_MAX_BUFFER_Marshalu(&source->inData, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_EncryptDecrypt2_In_Marshalu(const EncryptDecrypt2_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_DH_OBJECT_Marshalu(&source->keyHandle, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_MAX_BUFFER_Marshalu(&source->inData, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMI_YES_NO_Marshalu(&source->decrypt, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMI_ALG_CIPHER_MODE_Marshalu(&source->mode, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_IV_Marshalu(&source->ivIn, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_Hash_In_Marshalu(const Hash_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPM2B_MAX_BUFFER_Marshalu(&source->data, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMI_ALG_HASH_Marshalu(&source->hashAlg, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMI_RH_HIERARCHY_Marshalu(&source->hierarchy, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_HMAC_In_Marshalu(const HMAC_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_DH_OBJECT_Marshalu(&source->handle, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_MAX_BUFFER_Marshalu(&source->buffer, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMI_ALG_HASH_Marshalu(&source->hashAlg, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_GetRandom_In_Marshalu(const GetRandom_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_UINT16_Marshalu(&source->bytesRequested, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_StirRandom_In_Marshalu(const StirRandom_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPM2B_SENSITIVE_DATA_Marshalu(&source->inData, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_HMAC_Start_In_Marshalu(const HMAC_Start_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_DH_OBJECT_Marshalu(&source->handle, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_AUTH_Marshalu(&source->auth, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMI_ALG_HASH_Marshalu(&source->hashAlg, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_HashSequenceStart_In_Marshalu(const HashSequenceStart_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPM2B_AUTH_Marshalu(&source->auth, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMI_ALG_HASH_Marshalu(&source->hashAlg, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_SequenceUpdate_In_Marshalu(const SequenceUpdate_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_DH_OBJECT_Marshalu(&source->sequenceHandle, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_MAX_BUFFER_Marshalu(&source->buffer, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_SequenceComplete_In_Marshalu(const SequenceComplete_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_DH_OBJECT_Marshalu(&source->sequenceHandle, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_MAX_BUFFER_Marshalu(&source->buffer, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMI_RH_HIERARCHY_Marshalu(&source->hierarchy, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_EventSequenceComplete_In_Marshalu(const EventSequenceComplete_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_DH_PCR_Marshalu(&source->pcrHandle, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMI_DH_OBJECT_Marshalu(&source->sequenceHandle, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_MAX_BUFFER_Marshalu(&source->buffer, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_Certify_In_Marshalu(const Certify_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_DH_OBJECT_Marshalu(&source->objectHandle, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMI_DH_OBJECT_Marshalu(&source->signHandle, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_DATA_Marshalu(&source->qualifyingData, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMT_SIG_SCHEME_Marshalu(&source->inScheme, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_CertifyCreation_In_Marshalu(const CertifyCreation_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_DH_OBJECT_Marshalu(&source->signHandle, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMI_DH_OBJECT_Marshalu(&source->objectHandle, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_DATA_Marshalu(&source->qualifyingData, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_DIGEST_Marshalu(&source->creationHash, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMT_SIG_SCHEME_Marshalu(&source->inScheme, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMT_TK_CREATION_Marshalu(&source->creationTicket, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_Quote_In_Marshalu(const Quote_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_DH_OBJECT_Marshalu(&source->signHandle, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_DATA_Marshalu(&source->qualifyingData, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMT_SIG_SCHEME_Marshalu(&source->inScheme, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPML_PCR_SELECTION_Marshalu(&source->PCRselect, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_GetSessionAuditDigest_In_Marshalu(const GetSessionAuditDigest_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_RH_ENDORSEMENT_Marshalu(&source->privacyAdminHandle, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMI_DH_OBJECT_Marshalu(&source->signHandle, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMI_SH_HMAC_Marshalu(&source->sessionHandle, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_DATA_Marshalu(&source->qualifyingData, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMT_SIG_SCHEME_Marshalu(&source->inScheme, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_GetCommandAuditDigest_In_Marshalu(const GetCommandAuditDigest_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_RH_ENDORSEMENT_Marshalu(&source->privacyHandle, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMI_DH_OBJECT_Marshalu(&source->signHandle, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_DATA_Marshalu(&source->qualifyingData, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMT_SIG_SCHEME_Marshalu(&source->inScheme, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_GetTime_In_Marshalu(const GetTime_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_RH_ENDORSEMENT_Marshalu(&source->privacyAdminHandle, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMI_DH_OBJECT_Marshalu(&source->signHandle, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_DATA_Marshalu(&source->qualifyingData, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMT_SIG_SCHEME_Marshalu(&source->inScheme, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_Commit_In_Marshalu(const Commit_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_DH_OBJECT_Marshalu(&source->signHandle, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_ECC_POINT_Marshalu(&source->P1, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_SENSITIVE_DATA_Marshalu(&source->s2, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_ECC_PARAMETER_Marshalu(&source->y2, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_EC_Ephemeral_In_Marshalu(const EC_Ephemeral_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_ECC_CURVE_Marshalu(&source->curveID, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_VerifySignature_In_Marshalu(const VerifySignature_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_DH_OBJECT_Marshalu(&source->keyHandle, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_DIGEST_Marshalu(&source->digest, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMT_SIGNATURE_Marshalu(&source->signature, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_Sign_In_Marshalu(const Sign_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_DH_OBJECT_Marshalu(&source->keyHandle, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_DIGEST_Marshalu(&source->digest, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMT_SIG_SCHEME_Marshalu(&source->inScheme, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMT_TK_HASHCHECK_Marshalu(&source->validation, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_SetCommandCodeAuditStatus_In_Marshalu(const SetCommandCodeAuditStatus_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_RH_PROVISION_Marshalu(&source->auth, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMI_ALG_HASH_Marshalu(&source->auditAlg, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPML_CC_Marshalu(&source->setList, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPML_CC_Marshalu(&source->clearList, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_PCR_Extend_In_Marshalu(const PCR_Extend_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_DH_PCR_Marshalu(&source->pcrHandle, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPML_DIGEST_VALUES_Marshalu(&source->digests, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_PCR_Event_In_Marshalu(const PCR_Event_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_DH_PCR_Marshalu(&source->pcrHandle, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_EVENT_Marshalu(&source->eventData, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_PCR_Read_In_Marshalu(const PCR_Read_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPML_PCR_SELECTION_Marshalu(&source->pcrSelectionIn, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_PCR_Allocate_In_Marshalu(const PCR_Allocate_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_RH_PLATFORM_Marshalu(&source->authHandle, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPML_PCR_SELECTION_Marshalu(&source->pcrAllocation, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_PCR_SetAuthPolicy_In_Marshalu(const PCR_SetAuthPolicy_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_RH_PLATFORM_Marshalu(&source->authHandle, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_DIGEST_Marshalu(&source->authPolicy, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMI_ALG_HASH_Marshalu(&source->hashAlg, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMI_DH_PCR_Marshalu(&source->pcrNum, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_PCR_SetAuthValue_In_Marshalu(const PCR_SetAuthValue_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_DH_PCR_Marshalu(&source->pcrHandle, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_DIGEST_Marshalu(&source->auth, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_PCR_Reset_In_Marshalu(const PCR_Reset_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_DH_PCR_Marshalu(&source->pcrHandle, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_PolicySigned_In_Marshalu(const PolicySigned_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_DH_OBJECT_Marshalu(&source->authObject, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMI_SH_POLICY_Marshalu(&source->policySession, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_NONCE_Marshalu(&source->nonceTPM, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_DIGEST_Marshalu(&source->cpHashA, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_NONCE_Marshalu(&source->policyRef, written, buffer, size); + } + if (rc == 0) { + rc = TSS_INT32_Marshalu(&source->expiration, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMT_SIGNATURE_Marshalu(&source->auth, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_PolicySecret_In_Marshalu(const PolicySecret_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_DH_ENTITY_Marshalu(&source->authHandle, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMI_SH_POLICY_Marshalu(&source->policySession, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_NONCE_Marshalu(&source->nonceTPM, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_DIGEST_Marshalu(&source->cpHashA, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_NONCE_Marshalu(&source->policyRef, written, buffer, size); + } + if (rc == 0) { + rc = TSS_INT32_Marshalu(&source->expiration, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_PolicyTicket_In_Marshalu(const PolicyTicket_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_SH_POLICY_Marshalu(&source->policySession, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_TIMEOUT_Marshalu(&source->timeout, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_DIGEST_Marshalu(&source->cpHashA, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_NONCE_Marshalu(&source->policyRef, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_NAME_Marshalu(&source->authName, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMT_TK_AUTH_Marshalu(&source->ticket, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_PolicyOR_In_Marshalu(const PolicyOR_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_SH_POLICY_Marshalu(&source->policySession, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPML_DIGEST_Marshalu(&source->pHashList, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_PolicyPCR_In_Marshalu(const PolicyPCR_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_SH_POLICY_Marshalu(&source->policySession, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_DIGEST_Marshalu(&source->pcrDigest, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPML_PCR_SELECTION_Marshalu(&source->pcrs, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_PolicyLocality_In_Marshalu(const PolicyLocality_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_SH_POLICY_Marshalu(&source->policySession, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMA_LOCALITY_Marshalu(&source->locality, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_PolicyNV_In_Marshalu(const PolicyNV_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_RH_NV_AUTH_Marshalu(&source->authHandle, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMI_RH_NV_INDEX_Marshalu(&source->nvIndex, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMI_SH_POLICY_Marshalu(&source->policySession, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_OPERAND_Marshalu(&source->operandB, written, buffer, size); + } + if (rc == 0) { + rc = TSS_UINT16_Marshalu(&source->offset, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM_EO_Marshalu(&source->operation, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_PolicyCounterTimer_In_Marshalu(const PolicyCounterTimer_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_SH_POLICY_Marshalu(&source->policySession, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_OPERAND_Marshalu(&source->operandB, written, buffer, size); + } + if (rc == 0) { + rc = TSS_UINT16_Marshalu(&source->offset, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM_EO_Marshalu(&source->operation, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_PolicyCommandCode_In_Marshalu(const PolicyCommandCode_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_SH_POLICY_Marshalu(&source->policySession, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM_CC_Marshalu(&source->code, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_PolicyPhysicalPresence_In_Marshalu(const PolicyPhysicalPresence_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_SH_POLICY_Marshalu(&source->policySession, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_PolicyCpHash_In_Marshalu(const PolicyCpHash_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_SH_POLICY_Marshalu(&source->policySession, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_DIGEST_Marshalu(&source->cpHashA, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_PolicyNameHash_In_Marshalu(const PolicyNameHash_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_SH_POLICY_Marshalu(&source->policySession, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_DIGEST_Marshalu(&source->nameHash, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_PolicyDuplicationSelect_In_Marshalu(const PolicyDuplicationSelect_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_SH_POLICY_Marshalu(&source->policySession, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_NAME_Marshalu(&source->objectName, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_NAME_Marshalu(&source->newParentName, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMI_YES_NO_Marshalu(&source->includeObject, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_PolicyAuthorize_In_Marshalu(const PolicyAuthorize_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_SH_POLICY_Marshalu(&source->policySession, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_DIGEST_Marshalu(&source->approvedPolicy, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_NONCE_Marshalu(&source->policyRef, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_NAME_Marshalu(&source->keySign, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMT_TK_VERIFIED_Marshalu(&source->checkTicket, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_PolicyAuthValue_In_Marshalu(const PolicyAuthValue_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_SH_POLICY_Marshalu(&source->policySession, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_PolicyPassword_In_Marshalu(const PolicyPassword_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_SH_POLICY_Marshalu(&source->policySession, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_PolicyGetDigest_In_Marshalu(const PolicyGetDigest_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_SH_POLICY_Marshalu(&source->policySession, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_PolicyNvWritten_In_Marshalu(const PolicyNvWritten_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_SH_POLICY_Marshalu(&source->policySession, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMI_YES_NO_Marshalu(&source->writtenSet, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_PolicyTemplate_In_Marshalu(const PolicyTemplate_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_SH_POLICY_Marshalu(&source->policySession, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_DIGEST_Marshalu(&source->templateHash, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_PolicyAuthorizeNV_In_Marshalu(const PolicyAuthorizeNV_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_RH_NV_AUTH_Marshalu(&source->authHandle, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMI_RH_NV_INDEX_Marshalu(&source->nvIndex, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMI_SH_POLICY_Marshalu(&source->policySession, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_CreatePrimary_In_Marshalu(const CreatePrimary_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_RH_HIERARCHY_Marshalu(&source->primaryHandle, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_SENSITIVE_CREATE_Marshalu(&source->inSensitive, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_PUBLIC_Marshalu(&source->inPublic, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_DATA_Marshalu(&source->outsideInfo, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPML_PCR_SELECTION_Marshalu(&source->creationPCR, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_HierarchyControl_In_Marshalu(const HierarchyControl_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_RH_HIERARCHY_Marshalu(&source->authHandle, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMI_RH_ENABLES_Marshalu(&source->enable, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMI_YES_NO_Marshalu(&source->state, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_SetPrimaryPolicy_In_Marshalu(const SetPrimaryPolicy_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_RH_HIERARCHY_AUTH_Marshalu(&source->authHandle, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_DIGEST_Marshalu(&source->authPolicy, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMI_ALG_HASH_Marshalu(&source->hashAlg, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_ChangePPS_In_Marshalu(const ChangePPS_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_RH_PLATFORM_Marshalu(&source->authHandle, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_ChangeEPS_In_Marshalu(const ChangeEPS_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_RH_PLATFORM_Marshalu(&source->authHandle, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_Clear_In_Marshalu(const Clear_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_RH_CLEAR_Marshalu(&source->authHandle, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_ClearControl_In_Marshalu(const ClearControl_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_RH_CLEAR_Marshalu(&source->auth, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMI_YES_NO_Marshalu(&source->disable, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_HierarchyChangeAuth_In_Marshalu(const HierarchyChangeAuth_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_RH_HIERARCHY_AUTH_Marshalu(&source->authHandle, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_AUTH_Marshalu(&source->newAuth, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_DictionaryAttackLockReset_In_Marshalu(const DictionaryAttackLockReset_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_RH_LOCKOUT_Marshalu(&source->lockHandle, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_DictionaryAttackParameters_In_Marshalu(const DictionaryAttackParameters_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_RH_LOCKOUT_Marshalu(&source->lockHandle, written, buffer, size); + } + if (rc == 0) { + rc = TSS_UINT32_Marshalu(&source->newMaxTries, written, buffer, size); + } + if (rc == 0) { + rc = TSS_UINT32_Marshalu(&source->newRecoveryTime, written, buffer, size); + } + if (rc == 0) { + rc = TSS_UINT32_Marshalu(&source->lockoutRecovery, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_PP_Commands_In_Marshalu(const PP_Commands_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_RH_PLATFORM_Marshalu(&source->auth, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPML_CC_Marshalu(&source->setList, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPML_CC_Marshalu(&source->clearList, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_SetAlgorithmSet_In_Marshalu(const SetAlgorithmSet_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_RH_PLATFORM_Marshalu(&source->authHandle, written, buffer, size); + } + if (rc == 0) { + rc = TSS_UINT32_Marshalu(&source->algorithmSet, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_ContextSave_In_Marshalu(const ContextSave_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_DH_CONTEXT_Marshalu(&source->saveHandle, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_ContextLoad_In_Marshalu(const ContextLoad_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMS_CONTEXT_Marshalu(&source->context, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_FlushContext_In_Marshalu(const FlushContext_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_DH_CONTEXT_Marshalu(&source->flushHandle, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_EvictControl_In_Marshalu(const EvictControl_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_RH_PROVISION_Marshalu(&source->auth, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMI_DH_OBJECT_Marshalu(&source->objectHandle, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMI_DH_PERSISTENT_Marshalu(&source->persistentHandle, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_ClockSet_In_Marshalu(const ClockSet_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_RH_PROVISION_Marshalu(&source->auth, written, buffer, size); + } + if (rc == 0) { + rc = TSS_UINT64_Marshalu(&source->newTime, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_ClockRateAdjust_In_Marshalu(const ClockRateAdjust_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_RH_PROVISION_Marshalu(&source->auth, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM_CLOCK_ADJUST_Marshalu(&source->rateAdjust, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_GetCapability_In_Marshalu(const GetCapability_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPM_CAP_Marshalu(&source->capability, written, buffer, size); + } + if (rc == 0) { + rc = TSS_UINT32_Marshalu(&source->property, written, buffer, size); + } + if (rc == 0) { + rc = TSS_UINT32_Marshalu(&source->propertyCount, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_TestParms_In_Marshalu(const TestParms_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMT_PUBLIC_PARMS_Marshalu(&source->parameters, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_NV_DefineSpace_In_Marshalu(const NV_DefineSpace_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_RH_PROVISION_Marshalu(&source->authHandle, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_AUTH_Marshalu(&source->auth, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_NV_PUBLIC_Marshalu(&source->publicInfo, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_NV_UndefineSpace_In_Marshalu(const NV_UndefineSpace_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_RH_PROVISION_Marshalu(&source->authHandle, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMI_RH_NV_INDEX_Marshalu(&source->nvIndex, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_NV_UndefineSpaceSpecial_In_Marshalu(const NV_UndefineSpaceSpecial_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_RH_NV_INDEX_Marshalu(&source->nvIndex, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMI_RH_PLATFORM_Marshalu(&source->platform, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_NV_ReadPublic_In_Marshalu(const NV_ReadPublic_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_RH_NV_INDEX_Marshalu(&source->nvIndex, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_NV_Write_In_Marshalu(const NV_Write_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_RH_NV_AUTH_Marshalu(&source->authHandle, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMI_RH_NV_INDEX_Marshalu(&source->nvIndex, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_MAX_NV_BUFFER_Marshalu(&source->data, written, buffer, size); + } + if (rc == 0) { + rc = TSS_UINT16_Marshalu(&source->offset, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_NV_Increment_In_Marshalu(const NV_Increment_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_RH_NV_AUTH_Marshalu(&source->authHandle, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMI_RH_NV_INDEX_Marshalu(&source->nvIndex, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_NV_Extend_In_Marshalu(const NV_Extend_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_RH_NV_AUTH_Marshalu(&source->authHandle, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMI_RH_NV_INDEX_Marshalu(&source->nvIndex, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_MAX_NV_BUFFER_Marshalu(&source->data, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_NV_SetBits_In_Marshalu(const NV_SetBits_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_RH_NV_AUTH_Marshalu(&source->authHandle, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMI_RH_NV_INDEX_Marshalu(&source->nvIndex, written, buffer, size); + } + if (rc == 0) { + rc = TSS_UINT64_Marshalu(&source->bits, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_NV_WriteLock_In_Marshalu(const NV_WriteLock_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_RH_NV_AUTH_Marshalu(&source->authHandle, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMI_RH_NV_INDEX_Marshalu(&source->nvIndex, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_NV_GlobalWriteLock_In_Marshalu(const NV_GlobalWriteLock_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_RH_PROVISION_Marshalu(&source->authHandle, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_NV_Read_In_Marshalu(const NV_Read_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_RH_NV_AUTH_Marshalu(&source->authHandle, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMI_RH_NV_INDEX_Marshalu(&source->nvIndex, written, buffer, size); + } + if (rc == 0) { + rc = TSS_UINT16_Marshalu(&source->size, written, buffer, size); + } + if (rc == 0) { + rc = TSS_UINT16_Marshalu(&source->offset, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_NV_ReadLock_In_Marshalu(const NV_ReadLock_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_RH_NV_AUTH_Marshalu(&source->authHandle, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMI_RH_NV_INDEX_Marshalu(&source->nvIndex, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_NV_ChangeAuth_In_Marshalu(const NV_ChangeAuth_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_RH_NV_INDEX_Marshalu(&source->nvIndex, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_AUTH_Marshalu(&source->newAuth, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_NV_Certify_In_Marshalu(const NV_Certify_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_DH_OBJECT_Marshalu(&source->signHandle, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMI_RH_NV_AUTH_Marshalu(&source->authHandle, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMI_RH_NV_INDEX_Marshalu(&source->nvIndex, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_DATA_Marshalu(&source->qualifyingData, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMT_SIG_SCHEME_Marshalu(&source->inScheme, written, buffer, size); + } + if (rc == 0) { + rc = TSS_UINT16_Marshalu(&source->size, written, buffer, size); + } + if (rc == 0) { + rc = TSS_UINT16_Marshalu(&source->offset, written, buffer, size); + } + return rc; +} + +/* + TPM 2.0 Response parameter unmarshaling +*/ + +TPM_RC +TSS_IncrementalSelfTest_Out_Unmarshalu(IncrementalSelfTest_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + uint32_t parameterSize = 0; + if (rc == TPM_RC_SUCCESS) { + if (tag == TPM_ST_SESSIONS) { + rc = TSS_UINT32_Unmarshalu(¶meterSize, buffer, size); + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPML_ALG_Unmarshalu(&target->toDoList, buffer, size); + } + return rc; +} +TPM_RC +TSS_GetTestResult_Out_Unmarshalu(GetTestResult_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + uint32_t parameterSize; + if (rc == TPM_RC_SUCCESS) { + if (tag == TPM_ST_SESSIONS) { + rc = TSS_UINT32_Unmarshalu(¶meterSize, buffer, size); + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_MAX_BUFFER_Unmarshalu(&target->outData, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM_RC_Unmarshalu(&target->testResult, buffer, size); + } + return rc; +} +TPM_RC +TSS_StartAuthSession_Out_Unmarshalu(StartAuthSession_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + uint32_t parameterSize = 0; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMI_SH_AUTH_SESSION_Unmarshalu(&target->sessionHandle, buffer, size, NO); + } + if (rc == TPM_RC_SUCCESS) { + if (tag == TPM_ST_SESSIONS) { + rc = TSS_UINT32_Unmarshalu(¶meterSize, buffer, size); + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_NONCE_Unmarshalu(&target->nonceTPM, buffer, size); + } + return rc; +} +TPM_RC +TSS_Create_Out_Unmarshalu(Create_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + uint32_t parameterSize = 0; + + if (rc == TPM_RC_SUCCESS) { + if (tag == TPM_ST_SESSIONS) { + rc = TSS_UINT32_Unmarshalu(¶meterSize, buffer, size); + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_PRIVATE_Unmarshalu(&target->outPrivate, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_PUBLIC_Unmarshalu(&target->outPublic, buffer, size, NO); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_CREATION_DATA_Unmarshalu(&target->creationData, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_DIGEST_Unmarshalu(&target->creationHash, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMT_TK_CREATION_Unmarshalu(&target->creationTicket, buffer, size); + } + return rc; +} +TPM_RC +TSS_Load_Out_Unmarshalu(Load_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + uint32_t parameterSize = 0; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM_HANDLE_Unmarshalu(&target->objectHandle, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + if (tag == TPM_ST_SESSIONS) { + rc = TSS_UINT32_Unmarshalu(¶meterSize, buffer, size); + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_NAME_Unmarshalu(&target->name, buffer, size); + } + return rc; +} +TPM_RC +TSS_LoadExternal_Out_Unmarshalu(LoadExternal_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + uint32_t parameterSize = 0; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM_HANDLE_Unmarshalu(&target->objectHandle, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + if (tag == TPM_ST_SESSIONS) { + rc = TSS_UINT32_Unmarshalu(¶meterSize, buffer, size); + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_NAME_Unmarshalu(&target->name, buffer, size); + } + return rc; +} +TPM_RC +TSS_ReadPublic_Out_Unmarshalu(ReadPublic_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + uint32_t parameterSize = 0; + + if (rc == TPM_RC_SUCCESS) { + if (tag == TPM_ST_SESSIONS) { + rc = TSS_UINT32_Unmarshalu(¶meterSize, buffer, size); + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_PUBLIC_Unmarshalu(&target->outPublic, buffer, size, NO); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_NAME_Unmarshalu(&target->name, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_NAME_Unmarshalu(&target->qualifiedName, buffer, size); + } + return rc; +} +TPM_RC +TSS_ActivateCredential_Out_Unmarshalu(ActivateCredential_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + uint32_t parameterSize = 0; + + if (rc == TPM_RC_SUCCESS) { + if (tag == TPM_ST_SESSIONS) { + rc = TSS_UINT32_Unmarshalu(¶meterSize, buffer, size); + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_DIGEST_Unmarshalu(&target->certInfo, buffer, size); + } + return rc; +} +TPM_RC +TSS_MakeCredential_Out_Unmarshalu(MakeCredential_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + uint32_t parameterSize = 0; + + if (rc == TPM_RC_SUCCESS) { + if (tag == TPM_ST_SESSIONS) { + rc = TSS_UINT32_Unmarshalu(¶meterSize, buffer, size); + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_ID_OBJECT_Unmarshalu(&target->credentialBlob, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_ENCRYPTED_SECRET_Unmarshalu(&target->secret, buffer, size); + } + return rc; +} +TPM_RC +TSS_Unseal_Out_Unmarshalu(Unseal_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + uint32_t parameterSize = 0; + if (rc == TPM_RC_SUCCESS) { + if (tag == TPM_ST_SESSIONS) { + rc = TSS_UINT32_Unmarshalu(¶meterSize, buffer, size); + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_SENSITIVE_DATA_Unmarshalu(&target->outData, buffer, size); + } + return rc; +} +TPM_RC +TSS_ObjectChangeAuth_Out_Unmarshalu(ObjectChangeAuth_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + uint32_t parameterSize = 0; + if (rc == TPM_RC_SUCCESS) { + if (tag == TPM_ST_SESSIONS) { + rc = TSS_UINT32_Unmarshalu(¶meterSize, buffer, size); + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_PRIVATE_Unmarshalu(&target->outPrivate, buffer, size); + } + return rc; +} +TPM_RC +TSS_CreateLoaded_Out_Unmarshalu(CreateLoaded_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + uint32_t parameterSize = 0; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM_HANDLE_Unmarshalu(&target->objectHandle, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + if (tag == TPM_ST_SESSIONS) { + rc = TSS_UINT32_Unmarshalu(¶meterSize, buffer, size); + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_PRIVATE_Unmarshalu(&target->outPrivate, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_PUBLIC_Unmarshalu(&target->outPublic, buffer, size, NO); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_NAME_Unmarshalu(&target->name, buffer, size); + } + return rc; +} +TPM_RC +TSS_Duplicate_Out_Unmarshalu(Duplicate_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + uint32_t parameterSize = 0; + if (rc == TPM_RC_SUCCESS) { + if (tag == TPM_ST_SESSIONS) { + rc = TSS_UINT32_Unmarshalu(¶meterSize, buffer, size); + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_DATA_Unmarshalu(&target->encryptionKeyOut, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_PRIVATE_Unmarshalu(&target->duplicate, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_ENCRYPTED_SECRET_Unmarshalu(&target->outSymSeed, buffer, size); + } + return rc; +} +TPM_RC +TSS_Rewrap_Out_Unmarshalu(Rewrap_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + uint32_t parameterSize = 0; + if (rc == TPM_RC_SUCCESS) { + if (tag == TPM_ST_SESSIONS) { + rc = TSS_UINT32_Unmarshalu(¶meterSize, buffer, size); + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_PRIVATE_Unmarshalu(&target->outDuplicate, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_ENCRYPTED_SECRET_Unmarshalu(&target->outSymSeed, buffer, size); + } + return rc; +} +TPM_RC +TSS_Import_Out_Unmarshalu(Import_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + uint32_t parameterSize = 0; + if (rc == TPM_RC_SUCCESS) { + if (tag == TPM_ST_SESSIONS) { + rc = TSS_UINT32_Unmarshalu(¶meterSize, buffer, size); + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_PRIVATE_Unmarshalu(&target->outPrivate, buffer, size); + } + return rc; +} +TPM_RC +TSS_RSA_Encrypt_Out_Unmarshalu(RSA_Encrypt_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + uint32_t parameterSize = 0; + if (rc == TPM_RC_SUCCESS) { + if (tag == TPM_ST_SESSIONS) { + rc = TSS_UINT32_Unmarshalu(¶meterSize, buffer, size); + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_PUBLIC_KEY_RSA_Unmarshalu(&target->outData, buffer, size); + } + return rc; +} +TPM_RC +TSS_RSA_Decrypt_Out_Unmarshalu(RSA_Decrypt_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + uint32_t parameterSize = 0; + if (rc == TPM_RC_SUCCESS) { + if (tag == TPM_ST_SESSIONS) { + rc = TSS_UINT32_Unmarshalu(¶meterSize, buffer, size); + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_PUBLIC_KEY_RSA_Unmarshalu(&target->message, buffer, size); + } + return rc; +} +TPM_RC +TSS_ECDH_KeyGen_Out_Unmarshalu(ECDH_KeyGen_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + uint32_t parameterSize = 0; + if (rc == TPM_RC_SUCCESS) { + if (tag == TPM_ST_SESSIONS) { + rc = TSS_UINT32_Unmarshalu(¶meterSize, buffer, size); + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_ECC_POINT_Unmarshalu(&target->zPoint, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_ECC_POINT_Unmarshalu(&target->pubPoint, buffer, size); + } + return rc; +} +TPM_RC +TSS_ECDH_ZGen_Out_Unmarshalu(ECDH_ZGen_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + uint32_t parameterSize = 0; + if (rc == TPM_RC_SUCCESS) { + if (tag == TPM_ST_SESSIONS) { + rc = TSS_UINT32_Unmarshalu(¶meterSize, buffer, size); + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_ECC_POINT_Unmarshalu(&target->outPoint, buffer, size); + } + return rc; +} +TPM_RC +TSS_ECC_Parameters_Out_Unmarshalu(ECC_Parameters_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + uint32_t parameterSize = 0; + if (rc == TPM_RC_SUCCESS) { + if (tag == TPM_ST_SESSIONS) { + rc = TSS_UINT32_Unmarshalu(¶meterSize, buffer, size); + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMS_ALGORITHM_DETAIL_ECC_Unmarshalu(&target->parameters, buffer, size); + } + return rc; +} +TPM_RC +TSS_ZGen_2Phase_Out_Unmarshalu(ZGen_2Phase_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + uint32_t parameterSize = 0; + if (rc == TPM_RC_SUCCESS) { + if (tag == TPM_ST_SESSIONS) { + rc = TSS_UINT32_Unmarshalu(¶meterSize, buffer, size); + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_ECC_POINT_Unmarshalu(&target->outZ1, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_ECC_POINT_Unmarshalu(&target->outZ2, buffer, size); + } + return rc; +} +TPM_RC +TSS_EncryptDecrypt_Out_Unmarshalu(EncryptDecrypt_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + uint32_t parameterSize = 0; + if (rc == TPM_RC_SUCCESS) { + if (tag == TPM_ST_SESSIONS) { + rc = TSS_UINT32_Unmarshalu(¶meterSize, buffer, size); + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_MAX_BUFFER_Unmarshalu(&target->outData, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_IV_Unmarshalu(&target->ivOut, buffer, size); + } + return rc; +} +TPM_RC +TSS_EncryptDecrypt2_Out_Unmarshalu(EncryptDecrypt2_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size) +{ + return TSS_EncryptDecrypt_Out_Unmarshalu((EncryptDecrypt_Out *)target, tag, buffer, size); +} +TPM_RC +TSS_Hash_Out_Unmarshalu(Hash_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + uint32_t parameterSize = 0; + if (rc == TPM_RC_SUCCESS) { + if (tag == TPM_ST_SESSIONS) { + rc = TSS_UINT32_Unmarshalu(¶meterSize, buffer, size); + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_DIGEST_Unmarshalu(&target->outHash, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMT_TK_HASHCHECK_Unmarshalu(&target->validation, buffer, size); + } + return rc; +} +TPM_RC +TSS_HMAC_Out_Unmarshalu(HMAC_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + uint32_t parameterSize = 0; + if (rc == TPM_RC_SUCCESS) { + if (tag == TPM_ST_SESSIONS) { + rc = TSS_UINT32_Unmarshalu(¶meterSize, buffer, size); + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_DIGEST_Unmarshalu(&target->outHMAC, buffer, size); + } + return rc; +} +TPM_RC +TSS_GetRandom_Out_Unmarshalu(GetRandom_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + uint32_t parameterSize = 0; + if (rc == TPM_RC_SUCCESS) { + if (tag == TPM_ST_SESSIONS) { + rc = TSS_UINT32_Unmarshalu(¶meterSize, buffer, size); + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_DIGEST_Unmarshalu(&target->randomBytes, buffer, size); + } + return rc; +} +TPM_RC +TSS_HMAC_Start_Out_Unmarshalu(HMAC_Start_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + uint32_t parameterSize = 0; + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMI_DH_OBJECT_Unmarshalu(&target->sequenceHandle, buffer, size, NO); + } + if (rc == TPM_RC_SUCCESS) { + if (tag == TPM_ST_SESSIONS) { + rc = TSS_UINT32_Unmarshalu(¶meterSize, buffer, size); + } + } + return rc; +} +TPM_RC +TSS_HashSequenceStart_Out_Unmarshalu(HashSequenceStart_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + uint32_t parameterSize = 0; + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMI_DH_OBJECT_Unmarshalu(&target->sequenceHandle, buffer, size, NO); + } + if (rc == TPM_RC_SUCCESS) { + if (tag == TPM_ST_SESSIONS) { + rc = TSS_UINT32_Unmarshalu(¶meterSize, buffer, size); + } + } + return rc; +} +TPM_RC +TSS_SequenceComplete_Out_Unmarshalu(SequenceComplete_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + uint32_t parameterSize = 0; + if (rc == TPM_RC_SUCCESS) { + if (tag == TPM_ST_SESSIONS) { + rc = TSS_UINT32_Unmarshalu(¶meterSize, buffer, size); + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_DIGEST_Unmarshalu(&target->result, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMT_TK_HASHCHECK_Unmarshalu(&target->validation, buffer, size); + } + return rc; +} +TPM_RC +TSS_EventSequenceComplete_Out_Unmarshalu(EventSequenceComplete_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + uint32_t parameterSize = 0; + if (rc == TPM_RC_SUCCESS) { + if (tag == TPM_ST_SESSIONS) { + rc = TSS_UINT32_Unmarshalu(¶meterSize, buffer, size); + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPML_DIGEST_VALUES_Unmarshalu(&target->results, buffer, size); + } + return rc; +} +TPM_RC +TSS_Certify_Out_Unmarshalu(Certify_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + uint32_t parameterSize = 0; + if (rc == TPM_RC_SUCCESS) { + if (tag == TPM_ST_SESSIONS) { + rc = TSS_UINT32_Unmarshalu(¶meterSize, buffer, size); + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_ATTEST_Unmarshalu(&target->certifyInfo, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMT_SIGNATURE_Unmarshalu(&target->signature, buffer, size, YES); + } + return rc; +} +TPM_RC +TSS_CertifyCreation_Out_Unmarshalu(CertifyCreation_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + uint32_t parameterSize = 0; + if (rc == TPM_RC_SUCCESS) { + if (tag == TPM_ST_SESSIONS) { + rc = TSS_UINT32_Unmarshalu(¶meterSize, buffer, size); + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_ATTEST_Unmarshalu(&target->certifyInfo, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMT_SIGNATURE_Unmarshalu(&target->signature, buffer, size, YES); + } + return rc; +} +TPM_RC +TSS_Quote_Out_Unmarshalu(Quote_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + uint32_t parameterSize = 0; + if (rc == TPM_RC_SUCCESS) { + if (tag == TPM_ST_SESSIONS) { + rc = TSS_UINT32_Unmarshalu(¶meterSize, buffer, size); + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_ATTEST_Unmarshalu(&target->quoted, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMT_SIGNATURE_Unmarshalu(&target->signature, buffer, size, YES); + } + return rc; +} +TPM_RC +TSS_GetSessionAuditDigest_Out_Unmarshalu(GetSessionAuditDigest_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + uint32_t parameterSize = 0; + if (rc == TPM_RC_SUCCESS) { + if (tag == TPM_ST_SESSIONS) { + rc = TSS_UINT32_Unmarshalu(¶meterSize, buffer, size); + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_ATTEST_Unmarshalu(&target->auditInfo, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMT_SIGNATURE_Unmarshalu(&target->signature, buffer, size, YES); + } + return rc; +} +TPM_RC +TSS_GetCommandAuditDigest_Out_Unmarshalu(GetCommandAuditDigest_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + uint32_t parameterSize = 0; + if (rc == TPM_RC_SUCCESS) { + if (tag == TPM_ST_SESSIONS) { + rc = TSS_UINT32_Unmarshalu(¶meterSize, buffer, size); + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_ATTEST_Unmarshalu(&target->auditInfo, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMT_SIGNATURE_Unmarshalu(&target->signature, buffer, size, YES); + } + return rc; +} +TPM_RC +TSS_GetTime_Out_Unmarshalu(GetTime_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + uint32_t parameterSize = 0; + if (rc == TPM_RC_SUCCESS) { + if (tag == TPM_ST_SESSIONS) { + rc = TSS_UINT32_Unmarshalu(¶meterSize, buffer, size); + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_ATTEST_Unmarshalu(&target->timeInfo, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMT_SIGNATURE_Unmarshalu(&target->signature, buffer, size, YES); + } + return rc; +} +TPM_RC +TSS_Commit_Out_Unmarshalu(Commit_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + uint32_t parameterSize = 0; + if (rc == TPM_RC_SUCCESS) { + if (tag == TPM_ST_SESSIONS) { + rc = TSS_UINT32_Unmarshalu(¶meterSize, buffer, size); + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_ECC_POINT_Unmarshalu(&target->K, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_ECC_POINT_Unmarshalu(&target->L, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_ECC_POINT_Unmarshalu(&target->E, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_UINT16_Unmarshalu(&target->counter, buffer, size); + } + return rc; +} +TPM_RC +TSS_EC_Ephemeral_Out_Unmarshalu(EC_Ephemeral_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + uint32_t parameterSize = 0; + if (rc == TPM_RC_SUCCESS) { + if (tag == TPM_ST_SESSIONS) { + rc = TSS_UINT32_Unmarshalu(¶meterSize, buffer, size); + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_ECC_POINT_Unmarshalu(&target->Q, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_UINT16_Unmarshalu(&target->counter, buffer, size); + } + return rc; +} +TPM_RC +TSS_VerifySignature_Out_Unmarshalu(VerifySignature_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + uint32_t parameterSize = 0; + if (rc == TPM_RC_SUCCESS) { + if (tag == TPM_ST_SESSIONS) { + rc = TSS_UINT32_Unmarshalu(¶meterSize, buffer, size); + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMT_TK_VERIFIED_Unmarshalu(&target->validation, buffer, size); + } + return rc; +} +TPM_RC +TSS_Sign_Out_Unmarshalu(Sign_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + uint32_t parameterSize = 0; + if (rc == TPM_RC_SUCCESS) { + if (tag == TPM_ST_SESSIONS) { + rc = TSS_UINT32_Unmarshalu(¶meterSize, buffer, size); + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMT_SIGNATURE_Unmarshalu(&target->signature, buffer, size, NO); + } + return rc; +} +TPM_RC +TSS_PCR_Event_Out_Unmarshalu(PCR_Event_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + uint32_t parameterSize = 0; + if (rc == TPM_RC_SUCCESS) { + if (tag == TPM_ST_SESSIONS) { + rc = TSS_UINT32_Unmarshalu(¶meterSize, buffer, size); + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPML_DIGEST_VALUES_Unmarshalu(&target->digests, buffer, size); + } + return rc; +} +TPM_RC +TSS_PCR_Read_Out_Unmarshalu(PCR_Read_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + uint32_t parameterSize = 0; + if (rc == TPM_RC_SUCCESS) { + if (tag == TPM_ST_SESSIONS) { + rc = TSS_UINT32_Unmarshalu(¶meterSize, buffer, size); + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_UINT32_Unmarshalu(&target->pcrUpdateCounter, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPML_PCR_SELECTION_Unmarshalu(&target->pcrSelectionOut, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPML_DIGEST_Unmarshalu(&target->pcrValues, buffer, size, 0); + } + return rc; +} +TPM_RC +TSS_PCR_Allocate_Out_Unmarshalu(PCR_Allocate_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + uint32_t parameterSize = 0; + if (rc == TPM_RC_SUCCESS) { + if (tag == TPM_ST_SESSIONS) { + rc = TSS_UINT32_Unmarshalu(¶meterSize, buffer, size); + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMI_YES_NO_Unmarshalu(&target->allocationSuccess, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_UINT32_Unmarshalu(&target->maxPCR, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_UINT32_Unmarshalu(&target->sizeNeeded, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_UINT32_Unmarshalu(&target->sizeAvailable, buffer, size); + } + return rc; +} +TPM_RC +TSS_PolicySigned_Out_Unmarshalu(PolicySigned_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + uint32_t parameterSize = 0; + if (rc == TPM_RC_SUCCESS) { + if (tag == TPM_ST_SESSIONS) { + rc = TSS_UINT32_Unmarshalu(¶meterSize, buffer, size); + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_TIMEOUT_Unmarshalu(&target->timeout, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMT_TK_AUTH_Unmarshalu(&target->policyTicket, buffer, size); + } + return rc; +} +TPM_RC +TSS_PolicySecret_Out_Unmarshalu(PolicySecret_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + uint32_t parameterSize = 0; + if (rc == TPM_RC_SUCCESS) { + if (tag == TPM_ST_SESSIONS) { + rc = TSS_UINT32_Unmarshalu(¶meterSize, buffer, size); + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_TIMEOUT_Unmarshalu(&target->timeout, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMT_TK_AUTH_Unmarshalu(&target->policyTicket, buffer, size); + } + return rc; +} +TPM_RC +TSS_PolicyGetDigest_Out_Unmarshalu(PolicyGetDigest_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + uint32_t parameterSize = 0; + if (rc == TPM_RC_SUCCESS) { + if (tag == TPM_ST_SESSIONS) { + rc = TSS_UINT32_Unmarshalu(¶meterSize, buffer, size); + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_DIGEST_Unmarshalu(&target->policyDigest, buffer, size); + } + return rc; +} +TPM_RC +TSS_CreatePrimary_Out_Unmarshalu(CreatePrimary_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + uint32_t parameterSize = 0; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM_HANDLE_Unmarshalu(&target->objectHandle, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + if (tag == TPM_ST_SESSIONS) { + rc = TSS_UINT32_Unmarshalu(¶meterSize, buffer, size); + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_PUBLIC_Unmarshalu(&target->outPublic, buffer, size, NO); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_CREATION_DATA_Unmarshalu(&target->creationData, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_DIGEST_Unmarshalu(&target->creationHash, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMT_TK_CREATION_Unmarshalu(&target->creationTicket, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_NAME_Unmarshalu(&target->name, buffer, size); + } + return rc; +} +TPM_RC +TSS_ContextSave_Out_Unmarshalu(ContextSave_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + uint32_t parameterSize = 0; + if (rc == TPM_RC_SUCCESS) { + if (tag == TPM_ST_SESSIONS) { + rc = TSS_UINT32_Unmarshalu(¶meterSize, buffer, size); + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMS_CONTEXT_Unmarshalu(&target->context, buffer, size); + } + return rc; +} +TPM_RC +TSS_ContextLoad_Out_Unmarshalu(ContextLoad_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + uint32_t parameterSize = 0; + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMI_DH_CONTEXT_Unmarshalu(&target->loadedHandle, buffer, size, NO); + } + if (rc == TPM_RC_SUCCESS) { + if (tag == TPM_ST_SESSIONS) { + rc = TSS_UINT32_Unmarshalu(¶meterSize, buffer, size); + } + } + return rc; +} +TPM_RC +TSS_ReadClock_Out_Unmarshalu(ReadClock_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + uint32_t parameterSize = 0; + if (rc == TPM_RC_SUCCESS) { + if (tag == TPM_ST_SESSIONS) { + rc = TSS_UINT32_Unmarshalu(¶meterSize, buffer, size); + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMS_TIME_INFO_Unmarshalu(&target->currentTime, buffer, size); + } + return rc; +} +TPM_RC +TSS_GetCapability_Out_Unmarshalu(GetCapability_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + uint32_t parameterSize = 0; + + if (rc == TPM_RC_SUCCESS) { + if (tag == TPM_ST_SESSIONS) { + rc = TSS_UINT32_Unmarshalu(¶meterSize, buffer, size); + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMI_YES_NO_Unmarshalu(&target->moreData, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMS_CAPABILITY_DATA_Unmarshalu(&target->capabilityData, buffer, size); + } + return rc; +} +TPM_RC +TSS_NV_ReadPublic_Out_Unmarshalu(NV_ReadPublic_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + uint32_t parameterSize = 0; + if (rc == TPM_RC_SUCCESS) { + if (tag == TPM_ST_SESSIONS) { + rc = TSS_UINT32_Unmarshalu(¶meterSize, buffer, size); + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_NV_PUBLIC_Unmarshalu(&target->nvPublic, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_NAME_Unmarshalu(&target->nvName, buffer, size); + } + return rc; +} +TPM_RC +TSS_NV_Read_Out_Unmarshalu(NV_Read_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + uint32_t parameterSize = 0; + if (rc == TPM_RC_SUCCESS) { + if (tag == TPM_ST_SESSIONS) { + rc = TSS_UINT32_Unmarshalu(¶meterSize, buffer, size); + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_MAX_NV_BUFFER_Unmarshalu(&target->data, buffer, size); + } + return rc; +} +TPM_RC +TSS_NV_Certify_Out_Unmarshalu(NV_Certify_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + uint32_t parameterSize = 0; + if (rc == TPM_RC_SUCCESS) { + if (tag == TPM_ST_SESSIONS) { + rc = TSS_UINT32_Unmarshalu(¶meterSize, buffer, size); + } + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPM2B_ATTEST_Unmarshalu(&target->certifyInfo, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = TSS_TPMT_SIGNATURE_Unmarshalu(&target->signature, buffer, size, YES); + } + return rc; +} + +/* + TPM 2.0 Structure marshaling +*/ + +TPM_RC +TSS_TPM2B_Marshalu(const TPM2B *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_UINT16_Marshalu(&(source->size), written, buffer, size); + } + if (rc == 0) { + rc = TSS_Array_Marshalu(source->buffer, source->size, written, buffer, size); + } + return rc; +} + +/* Table 5 - Definition of Types for Documentation Clarity */ + +TPM_RC +TSS_TPM_KEY_BITS_Marshalu(const TPM_KEY_BITS *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_UINT16_Marshalu(source, written, buffer, size); + } + return rc; +} + +/* Table 7 - Definition of (UINT32) TPM_GENERATED Constants <O> */ + +TPM_RC +TSS_TPM_GENERATED_Marshalu(const TPM_GENERATED *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_UINT32_Marshalu(source, written, buffer, size); + } + return rc; +} + +/* Table 9 - Definition of (UINT16) TPM_ALG_ID Constants <IN/OUT, S> */ + +TPM_RC +TSS_TPM_ALG_ID_Marshalu(const TPM_ALG_ID *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_UINT16_Marshalu(source, written, buffer, size); + } + return rc; +} + +/* Table 10 - Definition of (uint16_t) {ECC} TPM_ECC_CURVE Constants <IN/OUT, S> */ + +#ifdef TPM_ALG_ECC +TPM_RC +TSS_TPM_ECC_CURVE_Marshalu(const TPM_ECC_CURVE *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_UINT16_Marshalu(source, written, buffer, size); + } + return rc; +} +#endif + +/* Table 17 - Definition of (UINT32) TPM_RC Constants (Actions) <OUT> */ + +TPM_RC +TSS_TPM_RC_Marshalu(const TPM_RC *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_UINT32_Marshalu(source, written, buffer, size); + } + return rc; +} + +/* Table 18 - Definition of (INT8) TPM_CLOCK_ADJUST Constants <IN> */ + +TPM_RC +TSS_TPM_CLOCK_ADJUST_Marshalu(const TPM_CLOCK_ADJUST *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_INT8_Marshalu(source, written, buffer, size); + } + return rc; +} + +/* Table 19 - Definition of (UINT16) TPM_EO Constants <IN/OUT> */ + +TPM_RC +TSS_TPM_EO_Marshalu(const TPM_EO *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_UINT16_Marshalu(source, written, buffer, size); + } + return rc; +} + +/* Table 20 - Definition of (UINT16) TPM_ST Constants <IN/OUT, S> */ + +TPM_RC +TSS_TPM_ST_Marshalu(const TPM_ST *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_UINT16_Marshalu(source, written, buffer, size); + } + return rc; +} + +/* Table 21 - Definition of (UINT16) TPM_SU Constants <IN> */ + +TPM_RC +TSS_TPM_SU_Marshalu(const TPM_ST *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_UINT16_Marshalu(source, written, buffer, size); + } + return rc; +} + +/* Table 22 - Definition of (UINT8) TPM_SE Constants <IN> */ + +TPM_RC +TSS_TPM_SE_Marshalu(const TPM_SE *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_UINT8_Marshalu(source, written, buffer, size); + } + return rc; +} + +/* Table 23 - Definition of (UINT32) TPM_CAP Constants */ + +TPM_RC +TSS_TPM_CAP_Marshalu(const TPM_CAP *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_UINT32_Marshalu(source, written, buffer, size); + } + return rc; +} + +/* Table 24 - Definition of (UINT32) TPM_PT Constants <IN/OUT, S> */ + +TPM_RC +TSS_TPM_PT_Marshalu(const TPM_PT *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_UINT32_Marshalu(source, written, buffer, size); + } + return rc; +} + +/* Table 25 - Definition of (UINT32) TPM_PT_PCR Constants <IN/OUT, S> */ + +TPM_RC +TSS_TPM_PT_PCR_Marshalu(const TPM_PT_PCR *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_UINT32_Marshalu(source, written, buffer, size); + } + return rc; +} + +/* Table 27 - Definition of Types for Handles */ + +TPM_RC +TSS_TPM_HANDLE_Marshalu(const TPM_HANDLE *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_UINT32_Marshalu(source, written, buffer, size); + } + return rc; +} + +/* Table 31 - Definition of (UINT32) TPMA_ALGORITHM Bits */ + +TPM_RC +TSS_TPMA_ALGORITHM_Marshalu(const TPMA_ALGORITHM *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_UINT32_Marshalu(&source->val, written, buffer, size); + } + return rc; +} + +/* Table 32 - Definition of (UINT32) TPMA_OBJECT Bits */ + +TPM_RC +TSS_TPMA_OBJECT_Marshalu(const TPMA_OBJECT *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_UINT32_Marshalu(&source->val, written, buffer, size); + } + return rc; +} + +/* Table 33 - Definition of (UINT8) TPMA_SESSION Bits <IN/OUT> */ + +TPM_RC +TSS_TPMA_SESSION_Marshalu(const TPMA_SESSION *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_UINT8_Marshalu(&source->val, written, buffer, size); + } + return rc; +} + +/* Table 34 - Definition of (UINT8) TPMA_LOCALITY Bits <IN/OUT> */ + +TPM_RC +TSS_TPMA_LOCALITY_Marshalu(const TPMA_LOCALITY *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_UINT8_Marshalu(&source->val, written, buffer, size); + } + return rc; +} + +/* Table 38 - Definition of (TPM_CC) TPMA_CC Bits <OUT> */ + +TPM_RC +TSS_TPM_CC_Marshalu(const TPM_CC *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_UINT32_Marshalu(source, written, buffer, size); + } + return rc; +} + +/* Table 38 - Definition of (TPM_CC) TPMA_CC Bits <OUT> */ + +TPM_RC +TSS_TPMA_CC_Marshalu(const TPMA_CC *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_UINT32_Marshalu(&source->val, written, buffer, size); + } + return rc; +} + +/* Table 39 - Definition of (BYTE) TPMI_YES_NO Type */ + +TPM_RC +TSS_TPMI_YES_NO_Marshalu(const TPMI_YES_NO *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_UINT8_Marshalu(source, written, buffer, size); + } + return rc; +} + +/* Table 40 - Definition of (TPM_HANDLE) TPMI_DH_OBJECT Type */ + +TPM_RC +TSS_TPMI_DH_OBJECT_Marshalu(const TPMI_DH_OBJECT *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPM_HANDLE_Marshalu(source, written, buffer, size); + } + return rc; +} + +/* Table 41 - Definition of (TPM_HANDLE) TPMI_DH_PERSISTENT Type */ + +TPM_RC +TSS_TPMI_DH_PERSISTENT_Marshalu(const TPMI_DH_PERSISTENT *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPM_HANDLE_Marshalu(source, written, buffer, size); + } + return rc; +} + +/* Table 42 - Definition of (TPM_HANDLE) TPMI_DH_ENTITY Type <IN> */ + +TPM_RC +TSS_TPMI_DH_ENTITY_Marshalu(const TPMI_DH_ENTITY *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPM_HANDLE_Marshalu(source, written, buffer, size); + } + return rc; +} + +/* Table 43 - Definition of (TPM_HANDLE) TPMI_DH_PCR Type <IN> */ + +TPM_RC +TSS_TPMI_DH_PCR_Marshalu(const TPMI_DH_PCR *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPM_HANDLE_Marshalu(source, written, buffer, size); + } + return rc; +} + +/* Table 44 - Definition of (TPM_HANDLE) TPMI_SH_AUTH_SESSION Type <IN/OUT> */ + +TPM_RC +TSS_TPMI_SH_AUTH_SESSION_Marshalu(const TPMI_SH_AUTH_SESSION *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPM_HANDLE_Marshalu(source, written, buffer, size); + } + return rc; +} + +/* Table 45 - Definition of (TPM_HANDLE) TPMI_SH_HMAC Type <IN/OUT> */ + +TPM_RC +TSS_TPMI_SH_HMAC_Marshalu(const TPMI_SH_HMAC *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPM_HANDLE_Marshalu(source, written, buffer, size); + } + return rc; +} + +/* Table 46 - Definition of (TPM_HANDLE) TPMI_SH_POLICY Type <IN/OUT> */ + +TPM_RC +TSS_TPMI_SH_POLICY_Marshalu(const TPMI_SH_POLICY*source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPM_HANDLE_Marshalu(source, written, buffer, size); + } + return rc; +} + +/* Table 47 - Definition of (TPM_HANDLE) TPMI_DH_CONTEXT Type */ + +TPM_RC +TSS_TPMI_DH_CONTEXT_Marshalu(const TPMI_DH_CONTEXT *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPM_HANDLE_Marshalu(source, written, buffer, size); + } + return rc; +} + +/* Table 49 - Definition of (TPM_HANDLE) TPMI_DH_SAVED Type */ + +TPM_RC +TSS_TPMI_DH_SAVED_Marshalu(const TPMI_DH_SAVED *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPM_HANDLE_Marshalu(source, written, buffer, size); + } + return rc; +} + +/* Table 48 - Definition of (TPM_HANDLE) TPMI_RH_HIERARCHY Type */ + +TPM_RC +TSS_TPMI_RH_HIERARCHY_Marshalu(const TPMI_RH_HIERARCHY *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPM_HANDLE_Marshalu(source, written, buffer, size); + } + return rc; +} + +/* Table 49 - Definition of (TPM_HANDLE) TPMI_RH_ENABLES Type */ + +TPM_RC +TSS_TPMI_RH_ENABLES_Marshalu(const TPMI_RH_ENABLES *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPM_HANDLE_Marshalu(source, written, buffer, size); + } + return rc; +} + +/* Table 50 - Definition of (TPM_HANDLE) TPMI_RH_HIERARCHY_AUTH Type <IN> */ + +TPM_RC +TSS_TPMI_RH_HIERARCHY_AUTH_Marshalu(const TPMI_RH_HIERARCHY_AUTH *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPM_HANDLE_Marshalu(source, written, buffer, size); + } + return rc; +} + +/* Table 51 - Definition of (TPM_HANDLE) TPMI_RH_PLATFORM Type <IN> */ + +TPM_RC +TSS_TPMI_RH_PLATFORM_Marshalu(const TPMI_RH_PLATFORM *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPM_HANDLE_Marshalu(source, written, buffer, size); + } + return rc; +} + +/* Table 53 - Definition of (TPM_HANDLE) TPMI_RH_ENDORSEMENT Type <IN> */ + +TPM_RC +TSS_TPMI_RH_ENDORSEMENT_Marshalu(const TPMI_RH_ENDORSEMENT *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPM_HANDLE_Marshalu(source, written, buffer, size); + } + return rc; +} + +/* Table 54 - Definition of (TPM_HANDLE) TPMI_RH_PROVISION Type <IN> */ + +TPM_RC +TSS_TPMI_RH_PROVISION_Marshalu(const TPMI_RH_PROVISION *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPM_HANDLE_Marshalu(source, written, buffer, size); + } + return rc; +} + +/* Table 55 - Definition of (TPM_HANDLE) TPMI_RH_CLEAR Type <IN> */ + +TPM_RC +TSS_TPMI_RH_CLEAR_Marshalu(const TPMI_RH_CLEAR *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPM_HANDLE_Marshalu(source, written, buffer, size); + } + return rc; +} + +/* Table 56 - Definition of (TPM_HANDLE) TPMI_RH_NV_AUTH Type <IN> */ + +TPM_RC +TSS_TPMI_RH_NV_AUTH_Marshalu(const TPMI_RH_NV_AUTH *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPM_HANDLE_Marshalu(source, written, buffer, size); + } + return rc; +} + +/* Table 57 - Definition of (TPM_HANDLE) TPMI_RH_LOCKOUT Type <IN> */ + +TPM_RC +TSS_TPMI_RH_LOCKOUT_Marshalu(const TPMI_RH_LOCKOUT *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPM_HANDLE_Marshalu(source, written, buffer, size); + } + return rc; +} + +/* Table 58 - Definition of (TPM_HANDLE) TPMI_RH_NV_INDEX Type <IN/OUT> */ + +TPM_RC +TSS_TPMI_RH_NV_INDEX_Marshalu(const TPMI_RH_NV_INDEX *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPM_HANDLE_Marshalu(source, written, buffer, size); + } + return rc; +} + +/* Table 59 - Definition of (TPM_ALG_ID) TPMI_ALG_HASH Type */ + +TPM_RC +TSS_TPMI_ALG_HASH_Marshalu(const TPMI_ALG_HASH *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPM_ALG_ID_Marshalu(source, written, buffer, size); + } + return rc; +} + +/* Table 61 - Definition of (TPM_ALG_ID) TPMI_ALG_SYM Type */ + +TPM_RC +TSS_TPMI_ALG_SYM_Marshalu(const TPMI_ALG_SYM *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPM_ALG_ID_Marshalu(source, written, buffer, size); + } + return rc; +} + +/* Table 62 - Definition of (TPM_ALG_ID) TPMI_ALG_SYM_OBJECT Type */ + +TPM_RC +TSS_TPMI_ALG_SYM_OBJECT_Marshalu(const TPMI_ALG_SYM_OBJECT *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPM_ALG_ID_Marshalu(source, written, buffer, size); + } + return rc; +} + +/* Table 63 - Definition of (TPM_ALG_ID) TPMI_ALG_SYM_MODE Type */ + +TPM_RC +TSS_TPMI_ALG_SYM_MODE_Marshalu(const TPMI_ALG_SYM_MODE *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPM_ALG_ID_Marshalu(source, written, buffer, size); + } + return rc; +} + +/* Table 64 - Definition of (TPM_ALG_ID) TPMI_ALG_KDF Type */ + +TPM_RC +TSS_TPMI_ALG_KDF_Marshalu(const TPMI_ALG_KDF *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPM_ALG_ID_Marshalu(source, written, buffer, size); + } + return rc; +} + +/* Table 65 - Definition of (TPM_ALG_ID) TPMI_ALG_SIG_SCHEME Type */ + +TPM_RC +TSS_TPMI_ALG_SIG_SCHEME_Marshalu(const TPMI_ALG_SIG_SCHEME *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPM_ALG_ID_Marshalu(source, written, buffer, size); + } + return rc; +} + +/* Table 66 - Definition of (TPM_ALG_ID) TPMI_ECC_KEY_EXCHANGE Type */ + +TPM_RC +TSS_TPMI_ECC_KEY_EXCHANGE_Marshalu(const TPMI_ECC_KEY_EXCHANGE *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPM_ALG_ID_Marshalu(source, written, buffer, size); + } + return rc; +} + +/* Table 67 - Definition of (TPM_ST) TPMI_ST_COMMAND_TAG Type */ + +TPM_RC +TSS_TPMI_ST_COMMAND_TAG_Marshalu(const TPMI_ST_COMMAND_TAG *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPM_ST_Marshalu(source, written, buffer, size); + } + return rc; +} + +/* Table 71 - Definition of (TPM_ALG_ID) TPMI_ALG_MAC_SCHEME Type */ + +TPM_RC +TSS_TPMI_ALG_MAC_SCHEME_Marshalu(const TPMI_ALG_MAC_SCHEME *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPM_ALG_ID_Marshalu(source, written, buffer, size); + } + return rc; +} + +/* Table 72 - Definition of (TPM_ALG_ID) TPMI_ALG_CIPHER_MODE Type */ + +TPM_RC +TSS_TPMI_ALG_CIPHER_MODE_Marshalu(const TPMI_ALG_CIPHER_MODE *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPM_ALG_ID_Marshalu(source, written, buffer, size); + } + return rc; +} + +/* Table 70 - Definition of TPMU_HA Union <IN/OUT, S> */ + +TPM_RC +TSS_TPMU_HA_Marshalu(const TPMU_HA *source, uint16_t *written, BYTE **buffer, uint32_t *size, uint32_t selector) +{ + TPM_RC rc = 0; + + switch (selector) { +#ifdef TPM_ALG_SHA1 + case TPM_ALG_SHA1: + if (rc == 0) { + rc = TSS_Array_Marshalu(&source->sha1[0], SHA1_DIGEST_SIZE, written, buffer, size); + } + break; +#endif +#ifdef TPM_ALG_SHA256 + case TPM_ALG_SHA256: + if (rc == 0) { + rc = TSS_Array_Marshalu(&source->sha256[0], SHA256_DIGEST_SIZE, written, buffer, size); + } + break; +#endif +#ifdef TPM_ALG_SHA384 + case TPM_ALG_SHA384: + if (rc == 0) { + rc = TSS_Array_Marshalu(&source->sha384[0], SHA384_DIGEST_SIZE, written, buffer, size); + } + break; +#endif +#ifdef TPM_ALG_SHA512 + case TPM_ALG_SHA512: + if (rc == 0) { + rc = TSS_Array_Marshalu(&source->sha512[0], SHA512_DIGEST_SIZE, written, buffer, size); + } + break; +#endif +#ifdef TPM_ALG_SM3_256 + case TPM_ALG_SM3_256: + if (rc == 0) { + rc = TSS_Array_Marshalu(&source->sm3_256[0], SM3_256_DIGEST_SIZE, written, buffer, size); + } + break; +#endif + case TPM_ALG_NULL: + break; + default: + rc = TPM_RC_SELECTOR; + } + return rc; +} + +/* Table 71 - Definition of TPMT_HA Structure <IN/OUT> */ + +TPM_RC +TSS_TPMT_HA_Marshalu(const TPMT_HA *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_ALG_HASH_Marshalu(&source->hashAlg, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMU_HA_Marshalu(&source->digest, written, buffer, size, source->hashAlg); + } + return rc; +} + +/* Table 72 - Definition of TPM2B_DIGEST Structure */ + +TPM_RC +TSS_TPM2B_DIGEST_Marshalu(const TPM2B_DIGEST *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPM2B_Marshalu(&source->b, written, buffer, size); + } + return rc; +} + +/* Table 73 - Definition of TPM2B_DATA Structure */ + +TPM_RC +TSS_TPM2B_DATA_Marshalu(const TPM2B_DATA *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPM2B_Marshalu(&source->b, written, buffer, size); + } + return rc; +} + +/* Table 74 - Definition of Types for TPM2B_NONCE */ + +TPM_RC +TSS_TPM2B_NONCE_Marshalu(const TPM2B_NONCE *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPM2B_DIGEST_Marshalu(source, written, buffer, size); + } + return rc; +} + +/* Table 75 - Definition of Types for TPM2B_AUTH */ + +TPM_RC +TSS_TPM2B_AUTH_Marshalu(const TPM2B_AUTH *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPM2B_DIGEST_Marshalu(source, written, buffer, size); + } + return rc; +} + +/* Table 76 - Definition of Types for TPM2B_OPERAND */ + +TPM_RC +TSS_TPM2B_OPERAND_Marshalu(const TPM2B_OPERAND *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPM2B_DIGEST_Marshalu(source, written, buffer, size); + } + return rc; +} + +/* Table 77 - Definition of TPM2B_EVENT Structure */ + +TPM_RC +TSS_TPM2B_EVENT_Marshalu(const TPM2B_EVENT *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPM2B_Marshalu(&source->b, written, buffer, size); + } + return rc; +} + +/* Table 78 - Definition of TPM2B_MAX_BUFFER Structure */ + +TPM_RC +TSS_TPM2B_MAX_BUFFER_Marshalu(const TPM2B_MAX_BUFFER *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPM2B_Marshalu(&source->b, written, buffer, size); + } + return rc; +} + +/* Table 79 - Definition of TPM2B_MAX_NV_BUFFER Structure */ + +TPM_RC +TSS_TPM2B_MAX_NV_BUFFER_Marshalu(const TPM2B_MAX_NV_BUFFER *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPM2B_Marshalu(&source->b, written, buffer, size); + } + return rc; +} + +/* Table 80 - Definition of TPM2B_TIMEOUT Structure <IN/OUT> */ + +TPM_RC +TSS_TPM2B_TIMEOUT_Marshalu(const TPM2B_TIMEOUT *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPM2B_DIGEST_Marshalu(source, written, buffer, size); + } + return rc; +} + +/* Table 81 - Definition of TPM2B_IV Structure <IN/OUT> */ + +TPM_RC +TSS_TPM2B_IV_Marshalu(const TPM2B_IV *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPM2B_Marshalu(&source->b, written, buffer, size); + } + return rc; +} + +/* Table 83 - Definition of TPM2B_NAME Structure */ + +TPM_RC +TSS_TPM2B_NAME_Marshalu(const TPM2B_NAME *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPM2B_Marshalu(&source->b, written, buffer, size); + } + return rc; +} + +/* Table 85 - Definition of TPMS_PCR_SELECTION Structure */ + +TPM_RC +TSS_TPMS_PCR_SELECTION_Marshalu(const TPMS_PCR_SELECTION *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + + if (rc == 0) { + rc = TSS_TPMI_ALG_HASH_Marshalu(&source->hash, written, buffer, size); + } + if (rc == 0) { + rc = TSS_UINT8_Marshalu(&source->sizeofSelect, written, buffer, size); + } + if (rc == 0) { + rc = TSS_Array_Marshalu(&source->pcrSelect[0], source->sizeofSelect, written, buffer, size); + } + return rc; +} + +/* Table 88 - Definition of TPMT_TK_CREATION Structure */ + +TPM_RC +TSS_TPMT_TK_CREATION_Marshalu(const TPMT_TK_CREATION *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPM_ST_Marshalu(&source->tag, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMI_RH_HIERARCHY_Marshalu(&source->hierarchy, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_DIGEST_Marshalu(&source->digest, written, buffer, size); + } + return rc; +} + +/* Table 89 - Definition of TPMT_TK_VERIFIED Structure */ + +TPM_RC +TSS_TPMT_TK_VERIFIED_Marshalu(const TPMT_TK_VERIFIED *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPM_ST_Marshalu(&source->tag, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMI_RH_HIERARCHY_Marshalu(&source->hierarchy, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_DIGEST_Marshalu(&source->digest, written, buffer, size); + } + return rc; +} + +/* Table 90 - Definition of TPMT_TK_AUTH Structure */ + +TPM_RC +TSS_TPMT_TK_AUTH_Marshalu(const TPMT_TK_AUTH *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPM_ST_Marshalu(&source->tag, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMI_RH_HIERARCHY_Marshalu(&source->hierarchy, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_DIGEST_Marshalu(&source->digest, written, buffer, size); + } + return rc; +} + +/* Table 91 - Definition of TPMT_TK_HASHCHECK Structure */ + +TPM_RC +TSS_TPMT_TK_HASHCHECK_Marshalu(const TPMT_TK_HASHCHECK *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPM_ST_Marshalu(&source->tag, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMI_RH_HIERARCHY_Marshalu(&source->hierarchy, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_DIGEST_Marshalu(&source->digest, written, buffer, size); + } + return rc; +} + +/* Table 92 - Definition of TPMS_ALG_PROPERTY Structure <OUT> */ + +TPM_RC +TSS_TPMS_ALG_PROPERTY_Marshalu(const TPMS_ALG_PROPERTY *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPM_ALG_ID_Marshalu(&source->alg, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMA_ALGORITHM_Marshalu(&source->algProperties, written, buffer, size); + } + return rc; +} + +/* Table 93 - Definition of TPMS_TAGGED_PROPERTY Structure <OUT> */ + +TPM_RC +TSS_TPMS_TAGGED_PROPERTY_Marshalu(const TPMS_TAGGED_PROPERTY *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPM_PT_Marshalu(&source->property, written, buffer, size); + } + if (rc == 0) { + rc = TSS_UINT32_Marshalu(&source->value, written, buffer, size); + } + return rc; +} + +/* Table 94 - Definition of TPMS_TAGGED_PCR_SELECT Structure <OUT> */ + +TPM_RC +TSS_TPMS_TAGGED_PCR_SELECT_Marshalu(const TPMS_TAGGED_PCR_SELECT *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPM_PT_PCR_Marshalu(&source->tag, written, buffer, size); + } + if (rc == 0) { + rc = TSS_UINT8_Marshalu(&source->sizeofSelect, written, buffer, size); + } + if (rc == 0) { + rc = TSS_Array_Marshalu(&source->pcrSelect[0], source->sizeofSelect, written, buffer, size); + } + return rc; +} + +/* Table 95 - Definition of TPML_CC Structure */ + +TPM_RC +TSS_TPML_CC_Marshalu(const TPML_CC *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + uint32_t i; + + if (rc == 0) { + rc = TSS_UINT32_Marshalu(&source->count, written, buffer, size); + } + for (i = 0 ; i < source->count ; i++) { + if (rc == 0) { + rc = TSS_TPM_CC_Marshalu(&source->commandCodes[i], written, buffer, size); + } + } + return rc; +} + +/* Table 96 - Definition of TPML_CCA Structure <OUT> */ + +TPM_RC +TSS_TPML_CCA_Marshalu(const TPML_CCA *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + uint32_t i; + + if (rc == 0) { + rc = TSS_UINT32_Marshalu(&source->count, written, buffer, size); + } + for (i = 0 ; i < source->count ; i++) { + if (rc == 0) { + rc = TSS_TPMA_CC_Marshalu(&source->commandAttributes[i], written, buffer, size); + } + } + return rc; +} + +/* Table 97 - Definition of TPML_ALG Structure */ + +TPM_RC +TSS_TPML_ALG_Marshalu(const TPML_ALG *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + uint32_t i; + + if (rc == 0) { + rc = TSS_UINT32_Marshalu(&source->count, written, buffer, size); + } + for (i = 0 ; i < source->count ; i++) { + if (rc == 0) { + rc = TSS_TPM_ALG_ID_Marshalu(&source->algorithms[i], written, buffer, size); + } + } + return rc; +} + +/* Table 98 - Definition of TPML_HANDLE Structure <OUT> */ + +TPM_RC +TSS_TPML_HANDLE_Marshalu(const TPML_HANDLE *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + uint32_t i; + + if (rc == 0) { + rc = TSS_UINT32_Marshalu(&source->count, written, buffer, size); + } + for (i = 0 ; i < source->count ; i++) { + if (rc == 0) { + rc = TSS_TPM_HANDLE_Marshalu(&source->handle[i], written, buffer, size); + } + } + return rc; +} + +/* Table 99 - Definition of TPML_DIGEST Structure */ + +TPM_RC +TSS_TPML_DIGEST_Marshalu(const TPML_DIGEST *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + uint32_t i; + + if (rc == 0) { + rc = TSS_UINT32_Marshalu(&source->count, written, buffer, size); + } + for (i = 0 ; i < source->count ; i++) { + if (rc == 0) { + rc = TSS_TPM2B_DIGEST_Marshalu(&source->digests[i], written, buffer, size); + } + } + return rc; +} + +/* Table 100 - Definition of TPML_DIGEST_VALUES Structure */ + +TPM_RC +TSS_TPML_DIGEST_VALUES_Marshalu(const TPML_DIGEST_VALUES *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + uint32_t i; + + if (rc == 0) { + rc = TSS_UINT32_Marshalu(&source->count, written, buffer, size); + } + for (i = 0 ; i < source->count ; i++) { + if (rc == 0) { + rc = TSS_TPMT_HA_Marshalu(&source->digests[i], written, buffer, size); + } + } + return rc; +} + +/* Table 102 - Definition of TPML_PCR_SELECTION Structure */ + +TPM_RC +TSS_TPML_PCR_SELECTION_Marshalu(const TPML_PCR_SELECTION *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + uint32_t i; + + if (rc == 0) { + rc = TSS_UINT32_Marshalu(&source->count, written, buffer, size); + } + for (i = 0 ; i < source->count ; i++) { + if (rc == 0) { + rc = TSS_TPMS_PCR_SELECTION_Marshalu(&source->pcrSelections[i], written, buffer, size); + } + } + return rc; +} + +/* Table 103 - Definition of TPML_ALG_PROPERTY Structure <OUT> */ + +TPM_RC +TSS_TPML_ALG_PROPERTY_Marshalu(const TPML_ALG_PROPERTY *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + uint32_t i; + + if (rc == 0) { + rc = TSS_UINT32_Marshalu(&source->count, written, buffer, size); + } + for (i = 0 ; i < source->count ; i++) { + if (rc == 0) { + rc = TSS_TPMS_ALG_PROPERTY_Marshalu(&source->algProperties[i], written, buffer, size); + } + } + return rc; +} + +/* Table 104 - Definition of TPML_TAGGED_TPM_PROPERTY Structure <OUT> */ + +TPM_RC +TSS_TPML_TAGGED_TPM_PROPERTY_Marshalu(const TPML_TAGGED_TPM_PROPERTY *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + uint32_t i; + + if (rc == 0) { + rc = TSS_UINT32_Marshalu(&source->count, written, buffer, size); + } + for (i = 0 ; i < source->count ; i++) { + if (rc == 0) { + rc = TSS_TPMS_TAGGED_PROPERTY_Marshalu(&source->tpmProperty[i], written, buffer, size); + } + } + return rc; +} + +/* Table 105 - Definition of TPML_TAGGED_PCR_PROPERTY Structure <OUT> */ + +TPM_RC +TSS_TPML_TAGGED_PCR_PROPERTY_Marshalu(const TPML_TAGGED_PCR_PROPERTY *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + uint32_t i; + + if (rc == 0) { + rc = TSS_UINT32_Marshalu(&source->count, written, buffer, size); + } + for (i = 0 ; i < source->count ; i++) { + if (rc == 0) { + rc = TSS_TPMS_TAGGED_PCR_SELECT_Marshalu(&source->pcrProperty[i], written, buffer, size); + } + } + return rc; +} + +/* Table 106 - Definition of {ECC} TPML_ECC_CURVE Structure <OUT> */ + +TPM_RC +TSS_TPML_ECC_CURVE_Marshalu(const TPML_ECC_CURVE *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + uint32_t i; + + if (rc == 0) { + rc = TSS_UINT32_Marshalu(&source->count, written, buffer, size); + } + for (i = 0 ; i < source->count ; i++) { + if (rc == 0) { + rc = TSS_TPM_ECC_CURVE_Marshalu(&source->eccCurves[i], written, buffer, size); + } + } + return rc; +} + +/* Table 107 - Definition of TPMU_CAPABILITIES Union <OUT> */ + +TPM_RC +TSS_TPMU_CAPABILITIES_Marshalu(const TPMU_CAPABILITIES *source, uint16_t *written, BYTE **buffer, uint32_t *size, uint32_t selector) +{ + TPM_RC rc = 0; + switch (selector) { + case TPM_CAP_ALGS: + if (rc == 0) { + rc = TSS_TPML_ALG_PROPERTY_Marshalu(&source->algorithms, written, buffer, size); + } + break; + case TPM_CAP_HANDLES: + if (rc == 0) { + rc = TSS_TPML_HANDLE_Marshalu(&source->handles, written, buffer, size); + } + break; + case TPM_CAP_COMMANDS: + if (rc == 0) { + rc = TSS_TPML_CCA_Marshalu(&source->command, written, buffer, size); + } + break; + case TPM_CAP_PP_COMMANDS: + if (rc == 0) { + rc = TSS_TPML_CC_Marshalu(&source->ppCommands, written, buffer, size); + } + break; + case TPM_CAP_AUDIT_COMMANDS: + if (rc == 0) { + rc = TSS_TPML_CC_Marshalu(&source->auditCommands, written, buffer, size); + } + break; + case TPM_CAP_PCRS: + if (rc == 0) { + rc = TSS_TPML_PCR_SELECTION_Marshalu(&source->assignedPCR, written, buffer, size); + } + break; + case TPM_CAP_TPM_PROPERTIES: + if (rc == 0) { + rc = TSS_TPML_TAGGED_TPM_PROPERTY_Marshalu(&source->tpmProperties, written, buffer, size); + } + break; + case TPM_CAP_PCR_PROPERTIES: + if (rc == 0) { + rc = TSS_TPML_TAGGED_PCR_PROPERTY_Marshalu(&source->pcrProperties, written, buffer, size); + } + break; + case TPM_CAP_ECC_CURVES: + if (rc == 0) { + rc = TSS_TPML_ECC_CURVE_Marshalu(&source->eccCurves, written, buffer, size); + } + break; + default: + rc = TPM_RC_SELECTOR; + } + return rc; +} + +/* Table 108 - Definition of TPMS_CAPABILITY_DATA Structure <OUT> */ + +TPM_RC +TSS_TPMS_CAPABILITY_DATA_Marshalu(const TPMS_CAPABILITY_DATA *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPM_CAP_Marshalu(&source->capability, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMU_CAPABILITIES_Marshalu(&source->data, written, buffer, size, source->capability); + } + return rc; +} + +/* Table 109 - Definition of TPMS_CLOCK_INFO Structure */ + +TPM_RC +TSS_TPMS_CLOCK_INFO_Marshalu(const TPMS_CLOCK_INFO *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_UINT64_Marshalu(&source->clock, written, buffer, size); + } + if (rc == 0) { + rc = TSS_UINT32_Marshalu(&source->resetCount, written, buffer, size); + } + if (rc == 0) { + rc = TSS_UINT32_Marshalu(&source->restartCount, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMI_YES_NO_Marshalu(&source->safe, written, buffer, size); + } + return rc; +} + +/* Table 110 - Definition of TPMS_TIME_INFO Structure */ + +TPM_RC +TSS_TPMS_TIME_INFO_Marshalu(const TPMS_TIME_INFO *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_UINT64_Marshalu(&source->time, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMS_CLOCK_INFO_Marshalu(&source->clockInfo, written, buffer, size); + } + return rc; +} + +/* Table 111 - Definition of TPMS_TIME_ATTEST_INFO Structure <OUT> */ + +TPM_RC +TSS_TPMS_TIME_ATTEST_INFO_Marshalu(const TPMS_TIME_ATTEST_INFO *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMS_TIME_INFO_Marshalu(&source->time, written, buffer, size); + } + if (rc == 0) { + rc = TSS_UINT64_Marshalu(&source->firmwareVersion, written, buffer, size); + } + return rc; +} + +/* Table 112 - Definition of TPMS_CERTIFY_INFO Structure <OUT> */ + +TPM_RC +TSS_TPMS_CERTIFY_INFO_Marshalu(const TPMS_CERTIFY_INFO *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPM2B_NAME_Marshalu(&source->name, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_NAME_Marshalu(&source->qualifiedName, written, buffer, size); + } + return rc; +} + +/* Table 113 - Definition of TPMS_QUOTE_INFO Structure <OUT> */ + +TPM_RC +TSS_TPMS_QUOTE_INFO_Marshalu(const TPMS_QUOTE_INFO *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPML_PCR_SELECTION_Marshalu(&source->pcrSelect, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_DIGEST_Marshalu(&source->pcrDigest, written, buffer, size); + } + return rc; +} + +/* Table 114 - Definition of TPMS_COMMAND_AUDIT_INFO Structure <OUT> */ + +TPM_RC +TSS_TPMS_COMMAND_AUDIT_INFO_Marshalu(const TPMS_COMMAND_AUDIT_INFO *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_UINT64_Marshalu(&source->auditCounter, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM_ALG_ID_Marshalu(&source->digestAlg, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_DIGEST_Marshalu(&source->auditDigest, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_DIGEST_Marshalu(&source->commandDigest, written, buffer, size); + } + return rc; +} + +/* Table 115 - Definition of TPMS_SESSION_AUDIT_INFO Structure <OUT> */ + +TPM_RC +TSS_TPMS_SESSION_AUDIT_INFO_Marshalu(const TPMS_SESSION_AUDIT_INFO *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_YES_NO_Marshalu(&source->exclusiveSession, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_DIGEST_Marshalu(&source->sessionDigest, written, buffer, size); + } + return rc; +} + +/* Table 116 - Definition of TPMS_CREATION_INFO Structure <OUT> */ + +TPM_RC +TSS_TPMS_CREATION_INFO_Marshalu(const TPMS_CREATION_INFO *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPM2B_NAME_Marshalu(&source->objectName, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_DIGEST_Marshalu(&source->creationHash, written, buffer, size); + } + return rc; +} + +/* Table 117 - Definition of TPMS_NV_CERTIFY_INFO Structure <OUT> */ + +TPM_RC +TSS_TPMS_NV_CERTIFY_INFO_Marshalu(const TPMS_NV_CERTIFY_INFO *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPM2B_NAME_Marshalu(&source->indexName, written, buffer, size); + } + if (rc == 0) { + rc = TSS_UINT16_Marshalu(&source->offset, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_MAX_NV_BUFFER_Marshalu(&source->nvContents, written, buffer, size); + } + return rc; +} + +/* Table 118 - Definition of (TPM_ST) TPMI_ST_ATTEST Type <OUT> */ + +TPM_RC +TSS_TPMI_ST_ATTEST_Marshalu(const TPMI_ST_ATTEST *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPM_ST_Marshalu(source, written, buffer, size); + } + return rc; +} + +/* Table 119 - Definition of TPMU_ATTEST Union <OUT> */ + +TPM_RC +TSS_TPMU_ATTEST_Marshalu(const TPMU_ATTEST *source, uint16_t *written, BYTE **buffer, uint32_t *size, uint32_t selector) +{ + TPM_RC rc = 0; + switch (selector) { + case TPM_ST_ATTEST_CERTIFY: + if (rc == 0) { + rc = TSS_TPMS_CERTIFY_INFO_Marshalu(&source->certify, written, buffer, size); + } + break; + case TPM_ST_ATTEST_CREATION: + if (rc == 0) { + rc = TSS_TPMS_CREATION_INFO_Marshalu(&source->creation, written, buffer, size); + } + break; + case TPM_ST_ATTEST_QUOTE: + if (rc == 0) { + rc = TSS_TPMS_QUOTE_INFO_Marshalu(&source->quote, written, buffer, size); + } + break; + case TPM_ST_ATTEST_COMMAND_AUDIT: + if (rc == 0) { + rc = TSS_TPMS_COMMAND_AUDIT_INFO_Marshalu(&source->commandAudit, written, buffer, size); + } + break; + case TPM_ST_ATTEST_SESSION_AUDIT: + if (rc == 0) { + rc = TSS_TPMS_SESSION_AUDIT_INFO_Marshalu(&source->sessionAudit, written, buffer, size); + } + break; + case TPM_ST_ATTEST_TIME: + if (rc == 0) { + rc = TSS_TPMS_TIME_ATTEST_INFO_Marshalu(&source->time, written, buffer, size); + } + break; + case TPM_ST_ATTEST_NV: + if (rc == 0) { + rc = TSS_TPMS_NV_CERTIFY_INFO_Marshalu(&source->nv, written, buffer, size); + } + break; + default: + rc = TPM_RC_SELECTOR; + } + return rc; +} + +/* Table 120 - Definition of TPMS_ATTEST Structure <OUT> */ + +TPM_RC +TSS_TPMS_ATTEST_Marshalu(const TPMS_ATTEST *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPM_GENERATED_Marshalu(&source->magic, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMI_ST_ATTEST_Marshalu(&source->type, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_NAME_Marshalu(&source->qualifiedSigner, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_DATA_Marshalu(&source->extraData, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMS_CLOCK_INFO_Marshalu(&source->clockInfo, written, buffer, size); + } + if (rc == 0) { + rc = TSS_UINT64_Marshalu(&source->firmwareVersion, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMU_ATTEST_Marshalu(&source->attested, written, buffer, size,source->type); + } + return rc; +} + +/* Table 121 - Definition of TPM2B_ATTEST Structure <OUT> */ + +TPM_RC +TSS_TPM2B_ATTEST_Marshalu(const TPM2B_ATTEST *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPM2B_Marshalu(&source->b, written, buffer, size); + } + return rc; +} + +/* Table 122 - Definition of TPMS_AUTH_COMMAND Structure <IN> */ + +TPM_RC +TSS_TPMS_AUTH_COMMAND_Marshalu(const TPMS_AUTH_COMMAND *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_SH_AUTH_SESSION_Marshalu(&source->sessionHandle, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_NONCE_Marshalu(&source->nonce, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMA_SESSION_Marshalu(&source->sessionAttributes, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_AUTH_Marshalu(&source->hmac, written, buffer, size); + } + return rc; +} + +/* Table 124 - Definition of {AES} (TPM_KEY_BITS) TPMI_!ALG.S_KEY_BITS Type */ + +TPM_RC +TSS_TPMI_AES_KEY_BITS_Marshalu(const TPMI_AES_KEY_BITS *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPM_KEY_BITS_Marshalu(source, written, buffer, size); + } + return rc; +} + +/* Table 125 - Definition of TPMU_SYM_KEY_BITS Union */ + +TPM_RC +TSS_TPMU_SYM_KEY_BITS_Marshalu(const TPMU_SYM_KEY_BITS *source, uint16_t *written, BYTE **buffer, uint32_t *size, uint32_t selector) +{ + TPM_RC rc = 0; + switch(selector) { +#ifdef TPM_ALG_AES + case TPM_ALG_AES: + if (rc == 0) { + rc = TSS_TPMI_AES_KEY_BITS_Marshalu(&source->aes, written, buffer, size); + } + break; +#endif +#ifdef TPM_ALG_SM4 + case TPM_ALG_SM4: + if (rc == 0) { + rc = TSS_TPMI_SM4_KEY_BITS_Marshalu(&source->sm4, written, buffer, size); + } + break; +#endif +#ifdef TPM_ALG_CAMELLIA + case TPM_ALG_CAMELLIA: + if (rc == 0) { + rc = TSS_TPMI_CAMELLIA_KEY_BITS_Marshalu(&source->camellia, written, buffer, size); + } + break; +#endif +#ifdef TPM_ALG_XOR + case TPM_ALG_XOR: + if (rc == 0) { + rc = TSS_TPMI_ALG_HASH_Marshalu(&source->xorr, written, buffer, size); + } + break; +#endif + case TPM_ALG_NULL: + break; + default: + return rc; + } + return rc; +} + +/* Table 126 - Definition of TPMU_SYM_MODE Union */ + +TPM_RC +TSS_TPMU_SYM_MODE_Marshalu(const TPMU_SYM_MODE *source, uint16_t *written, BYTE **buffer, uint32_t *size, uint32_t selector) +{ + TPM_RC rc = 0; + switch (selector) { +#ifdef TPM_ALG_AES + case TPM_ALG_AES: + if (rc == 0) { + rc = TSS_TPMI_ALG_SYM_MODE_Marshalu(&source->aes, written, buffer, size); + } + break; +#endif +#ifdef TPM_ALG_SM4 + case TPM_ALG_SM4: + if (rc == 0) { + rc = TSS_TPMI_ALG_SYM_MODE_Marshalu(&source->sm4, written, buffer, size); + } + break; +#endif +#ifdef TPM_ALG_CAMELLIA + case TPM_ALG_CAMELLIA: + if (rc == 0) { + rc = TSS_TPMI_ALG_SYM_MODE_Marshalu(&source->camellia, written, buffer, size); + } + break; +#endif +#ifdef TPM_ALG_XOR + case TPM_ALG_XOR: +#endif + case TPM_ALG_NULL: + break; + default: + rc = TPM_RC_SELECTOR; + } + return rc; +} + +/* Table 128 - Definition of TPMT_SYM_DEF Structure */ + +TPM_RC +TSS_TPMT_SYM_DEF_Marshalu(const TPMT_SYM_DEF *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_ALG_SYM_Marshalu(&source->algorithm, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMU_SYM_KEY_BITS_Marshalu(&source->keyBits, written, buffer, size, source->algorithm); + } + if (rc == 0) { + rc = TSS_TPMU_SYM_MODE_Marshalu(&source->mode, written, buffer, size, source->algorithm); + } + return rc; +} + +/* Table 129 - Definition of TPMT_SYM_DEF_OBJECT Structure */ + +TPM_RC +TSS_TPMT_SYM_DEF_OBJECT_Marshalu(const TPMT_SYM_DEF_OBJECT *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_ALG_SYM_OBJECT_Marshalu(&source->algorithm, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMU_SYM_KEY_BITS_Marshalu(&source->keyBits, written, buffer, size, source->algorithm); + } + if (rc == 0) { + rc = TSS_TPMU_SYM_MODE_Marshalu(&source->mode, written, buffer, size, source->algorithm); + } + return rc; +} + +/* Table 130 - Definition of TPM2B_SYM_KEY Structure */ + +TPM_RC +TSS_TPM2B_SYM_KEY_Marshalu(const TPM2B_SYM_KEY *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPM2B_Marshalu(&source->b, written, buffer, size); + } + return rc; +} + +/* Table 134 - Definition of TPM2B_LABEL Structure */ + +TPM_RC +TSS_TPM2B_LABEL_Marshalu(const TPM2B_LABEL *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPM2B_Marshalu(&source->b, written, buffer, size); + } + return rc; +} + +/* Table 139 - Definition of TPMS_DERIVE Structure */ + +TPM_RC +TSS_TPMS_DERIVE_Marshalu(const TPMS_DERIVE *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPM2B_LABEL_Marshalu(&source->label, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_LABEL_Marshalu(&source->context, written, buffer, size); + } + return rc; +} + +/* Table 131 - Definition of TPMS_SYMCIPHER_PARMS Structure */ + +TPM_RC +TSS_TPMS_SYMCIPHER_PARMS_Marshalu(const TPMS_SYMCIPHER_PARMS *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMT_SYM_DEF_OBJECT_Marshalu(&source->sym, written, buffer, size); + } + return rc; +} + +/* Table 132 - Definition of TPM2B_SENSITIVE_DATA Structure */ + +TPM_RC +TSS_TPM2B_SENSITIVE_DATA_Marshalu(const TPM2B_SENSITIVE_DATA *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPM2B_Marshalu(&source->b, written, buffer, size); + } + return rc; +} + +/* Table 133 - Definition of TPMS_SENSITIVE_CREATE Structure <IN> */ + +TPM_RC +TSS_TPMS_SENSITIVE_CREATE_Marshalu(const TPMS_SENSITIVE_CREATE *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPM2B_AUTH_Marshalu(&source->userAuth, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_SENSITIVE_DATA_Marshalu(&source->data, written, buffer, size); + } + return rc; +} + +/* Table 134 - Definition of TPM2B_SENSITIVE_CREATE Structure <IN, S> */ + +TPM_RC +TSS_TPM2B_SENSITIVE_CREATE_Marshalu(const TPM2B_SENSITIVE_CREATE *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + uint16_t sizeWritten = 0; /* of structure */ + BYTE *sizePtr; + + if (buffer != NULL) { + sizePtr = *buffer; + *buffer += sizeof(uint16_t); + } + if (rc == 0) { + rc = TSS_TPMS_SENSITIVE_CREATE_Marshalu(&source->sensitive, &sizeWritten, buffer, size); + } + if (rc == 0) { + *written += sizeWritten; + if (buffer != NULL) { + rc = TSS_UINT16_Marshalu(&sizeWritten, written, &sizePtr, size); /* backfill 2B size */ + } + else { + *written += sizeof(uint16_t); + } + } + return rc; +} + +/* Table 135 - Definition of TPMS_SCHEME_HASH Structure */ + +TPM_RC +TSS_TPMS_SCHEME_HASH_Marshalu(const TPMS_SCHEME_HASH *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_ALG_HASH_Marshalu(&source->hashAlg, written, buffer, size); + } + return rc; +} + +/* Table 136 - Definition of {ECC} TPMS_SCHEME_ECDAA Structure */ + +TPM_RC +TSS_TPMS_SCHEME_ECDAA_Marshalu(const TPMS_SCHEME_ECDAA *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_ALG_HASH_Marshalu(&source->hashAlg, written, buffer, size); + } + if (rc == 0) { + rc = TSS_UINT16_Marshalu(&source->count, written, buffer, size); + } + return rc; +} + +/* Table 137 - Definition of (TPM_ALG_ID) TPMI_ALG_KEYEDHASH_SCHEME Type */ + +TPM_RC +TSS_TPMI_ALG_KEYEDHASH_SCHEME_Marshalu(const TPMI_ALG_KEYEDHASH_SCHEME *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPM_ALG_ID_Marshalu(source, written, buffer, size); + } + return rc; +} + +/* Table 138 - Definition of Types for HMAC_SIG_SCHEME */ + +TPM_RC +TSS_TPMS_SCHEME_HMAC_Marshalu(const TPMS_SCHEME_HMAC *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMS_SCHEME_HASH_Marshalu(source, written, buffer, size); + } + return rc; +} + +/* Table 139 - Definition of TPMS_SCHEME_XOR Structure */ + +TPM_RC +TSS_TPMS_SCHEME_XOR_Marshalu(const TPMS_SCHEME_XOR *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_ALG_HASH_Marshalu(&source->hashAlg, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMI_ALG_KDF_Marshalu(&source->kdf, written, buffer, size); + } + return rc; +} + +/* Table 140 - Definition of TPMU_SCHEME_KEYEDHASH Union <IN/OUT, S> */ + +TPM_RC +TSS_TPMU_SCHEME_KEYEDHASH_Marshalu(const TPMU_SCHEME_KEYEDHASH *source, uint16_t *written, BYTE **buffer, uint32_t *size, uint32_t selector) +{ + TPM_RC rc = 0; + switch (selector) { +#ifdef TPM_ALG_HMAC + case TPM_ALG_HMAC: + if (rc == 0) { + rc = TSS_TPMS_SCHEME_HMAC_Marshalu(&source->hmac, written, buffer, size); + } + break; +#endif +#ifdef TPM_ALG_XOR + case TPM_ALG_XOR: + if (rc == 0) { + rc = TSS_TPMS_SCHEME_XOR_Marshalu(&source->xorr, written, buffer, size); + } + break; +#endif + case TPM_ALG_NULL: + break; + default: + rc = TPM_RC_SELECTOR; + } + return rc; +} + +/* Table 141 - Definition of TPMT_KEYEDHASH_SCHEME Structure */ + +TPM_RC +TSS_TPMT_KEYEDHASH_SCHEME_Marshalu(const TPMT_KEYEDHASH_SCHEME *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_ALG_KEYEDHASH_SCHEME_Marshalu(&source->scheme, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMU_SCHEME_KEYEDHASH_Marshalu(&source->details, written, buffer, size, source->scheme); + } + return rc; +} + +/* Table 142 - Definition of {RSA} Types for RSA Signature Schemes */ + +TPM_RC +TSS_TPMS_SIG_SCHEME_RSASSA_Marshalu(const TPMS_SIG_SCHEME_RSASSA *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMS_SCHEME_HASH_Marshalu(source, written, buffer, size); + } + return rc; +} + +TPM_RC +TSS_TPMS_SIG_SCHEME_RSAPSS_Marshalu(const TPMS_SIG_SCHEME_RSAPSS *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMS_SCHEME_HASH_Marshalu(source, written, buffer, size); + } + return rc; +} + +/* Table 143 - Definition of {ECC} Types for ECC Signature Schemes */ + +TPM_RC +TSS_TPMS_SIG_SCHEME_ECDSA_Marshalu(const TPMS_SIG_SCHEME_ECDSA *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMS_SCHEME_HASH_Marshalu(source, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_TPMS_SIG_SCHEME_SM2_Marshalu(const TPMS_SIG_SCHEME_SM2 *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMS_SCHEME_HASH_Marshalu(source, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_TPMS_SIG_SCHEME_ECSCHNORR_Marshalu(const TPMS_SIG_SCHEME_ECSCHNORR *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMS_SCHEME_HASH_Marshalu(source, written, buffer, size); + } + return rc; +} + +/* Table 143 - Definition of {ECC} Types for ECC Signature Schemes */ + +TPM_RC +TSS_TPMS_SIG_SCHEME_ECDAA_Marshalu(const TPMS_SIG_SCHEME_ECDAA *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMS_SCHEME_ECDAA_Marshalu(source, written, buffer, size); + } + return rc; +} + +/* Table 144 - Definition of TPMU_SIG_SCHEME Union <IN/OUT, S> */ + +TPM_RC +TSS_TPMU_SIG_SCHEME_Marshalu(const TPMU_SIG_SCHEME *source, uint16_t *written, BYTE **buffer, uint32_t *size, uint32_t selector) +{ + TPM_RC rc = 0; + switch (selector) { +#ifdef TPM_ALG_RSASSA + case TPM_ALG_RSASSA: + if (rc == 0) { + rc = TSS_TPMS_SIG_SCHEME_RSASSA_Marshalu(&source->rsassa, written, buffer, size); + } + break; +#endif +#ifdef TPM_ALG_RSAPSS + case TPM_ALG_RSAPSS: + if (rc == 0) { + rc = TSS_TPMS_SIG_SCHEME_RSAPSS_Marshalu(&source->rsapss, written, buffer, size); + } + break; +#endif +#ifdef TPM_ALG_ECDSA + case TPM_ALG_ECDSA: + if (rc == 0) { + rc = TSS_TPMS_SIG_SCHEME_ECDSA_Marshalu(&source->ecdsa, written, buffer, size); + } + break; +#endif +#ifdef TPM_ALG_ECDAA + case TPM_ALG_ECDAA: + if (rc == 0) { + rc = TSS_TPMS_SIG_SCHEME_ECDAA_Marshalu(&source->ecdaa, written, buffer, size); + } + break; +#endif +#ifdef TPM_ALG_SM2 + case TPM_ALG_SM2: + if (rc == 0) { + rc = TSS_TPMS_SIG_SCHEME_SM2_Marshalu(&source->sm2, written, buffer, size); + } + break; +#endif +#ifdef TPM_ALG_ECSCHNORR + case TPM_ALG_ECSCHNORR: + if (rc == 0) { + rc = TSS_TPMS_SIG_SCHEME_ECSCHNORR_Marshalu(&source->ecSchnorr, written, buffer, size); + } + break; +#endif +#ifdef TPM_ALG_HMAC + case TPM_ALG_HMAC: + if (rc == 0) { + rc = TSS_TPMS_SCHEME_HMAC_Marshalu(&source->hmac, written, buffer, size); + } + break; +#endif + case TPM_ALG_NULL: + break; + default: + rc = TPM_RC_SELECTOR; + } + return rc; +} + +/* Table 145 - Definition of TPMT_SIG_SCHEME Structure */ + +TPM_RC +TSS_TPMT_SIG_SCHEME_Marshalu(const TPMT_SIG_SCHEME *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_ALG_SIG_SCHEME_Marshalu(&source->scheme, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMU_SIG_SCHEME_Marshalu(&source->details, written, buffer, size,source->scheme); + } + return rc; +} + +/* Table 146 - Definition of Types for {RSA} Encryption Schemes */ + +/* NOTE: Marked as const function in header */ + +TPM_RC +TSS_TPMS_ENC_SCHEME_OAEP_Marshalu(const TPMS_ENC_SCHEME_OAEP *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMS_SCHEME_HASH_Marshalu(source, written, buffer, size); + } + return rc; +} + +/* Table 146 - Definition of Types for {RSA} Encryption Schemes */ + +/* NOTE: Marked as const function in header */ + +TPM_RC +TSS_TPMS_ENC_SCHEME_RSAES_Marshalu(const TPMS_ENC_SCHEME_RSAES *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + source = source; + written = written; + buffer = buffer; + size = size; + return 0; +} + +/* Table 147 - Definition of Types for {ECC} ECC Key Exchange */ + +TPM_RC +TSS_TPMS_KEY_SCHEME_ECDH_Marshalu(const TPMS_KEY_SCHEME_ECDH *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMS_SCHEME_HASH_Marshalu(source, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_TPMS_KEY_SCHEME_ECMQV_Marshalu(const TPMS_KEY_SCHEME_ECMQV *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMS_SCHEME_HASH_Marshalu(source, written, buffer, size); + } + return rc; +} + +/* Table 148 - Definition of Types for KDF Schemes, hash-based key- or mask-generation functions */ + +TPM_RC +TSS_TPMS_SCHEME_MGF1_Marshalu(const TPMS_SCHEME_MGF1 *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMS_SCHEME_HASH_Marshalu(source, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_TPMS_SCHEME_KDF1_SP800_56A_Marshalu(const TPMS_SCHEME_KDF1_SP800_56A *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMS_SCHEME_HASH_Marshalu(source, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_TPMS_SCHEME_KDF2_Marshalu(const TPMS_SCHEME_KDF2 *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMS_SCHEME_HASH_Marshalu(source, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_TPMS_SCHEME_KDF1_SP800_108_Marshalu(const TPMS_SCHEME_KDF1_SP800_108 *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMS_SCHEME_HASH_Marshalu(source, written, buffer, size); + } + return rc; +} + +/* Table 149 - Definition of TPMU_KDF_SCHEME Union <IN/OUT, S> */ + +TPM_RC +TSS_TPMU_KDF_SCHEME_Marshalu(const TPMU_KDF_SCHEME *source, uint16_t *written, BYTE **buffer, uint32_t *size, uint32_t selector) +{ + TPM_RC rc = 0; + switch (selector) { +#ifdef TPM_ALG_MGF1 + case TPM_ALG_MGF1: + if (rc == 0) { + rc = TSS_TPMS_SCHEME_MGF1_Marshalu(&source->mgf1, written, buffer, size); + } + break; +#endif +#ifdef TPM_ALG_KDF1_SP800_56A + case TPM_ALG_KDF1_SP800_56A: + if (rc == 0) { + rc = TSS_TPMS_SCHEME_KDF1_SP800_56A_Marshalu(&source->kdf1_SP800_56a, written, buffer, size); + } + break; +#endif +#ifdef TPM_ALG_KDF2 + case TPM_ALG_KDF2: + if (rc == 0) { + rc = TSS_TPMS_SCHEME_KDF2_Marshalu(&source->kdf2, written, buffer, size); + } + break; +#endif +#ifdef TPM_ALG_KDF1_SP800_108 + case TPM_ALG_KDF1_SP800_108: + if (rc == 0) { + rc = TSS_TPMS_SCHEME_KDF1_SP800_108_Marshalu(&source->kdf1_sp800_108, written, buffer, size); + } + break; +#endif + case TPM_ALG_NULL: + break; + default: + rc = TPM_RC_SELECTOR; + } + return rc; +} +/* Table 150 - Definition of TPMT_KDF_SCHEME Structure */ + +TPM_RC +TSS_TPMT_KDF_SCHEME_Marshalu(const TPMT_KDF_SCHEME *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_ALG_KDF_Marshalu(&source->scheme, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMU_KDF_SCHEME_Marshalu(&source->details, written, buffer, size, source->scheme); + } + return rc; +} + +/* Table 152 - Definition of TPMU_ASYM_SCHEME Union */ + +TPM_RC +TSS_TPMU_ASYM_SCHEME_Marshalu(const TPMU_ASYM_SCHEME *source, uint16_t *written, BYTE **buffer, uint32_t *size, uint32_t selector) +{ + TPM_RC rc = 0; + switch (selector) { +#ifdef TPM_ALG_ECDH + case TPM_ALG_ECDH: + if (rc == 0) { + rc = TSS_TPMS_KEY_SCHEME_ECDH_Marshalu(&source->ecdh, written, buffer, size); + } + break; +#endif +#ifdef TPM_ALG_ECMQV + case TPM_ALG_ECMQV: + if (rc == 0) { + rc = TSS_TPMS_KEY_SCHEME_ECMQV_Marshalu(&source->ecmqvh, written, buffer, size); + } + break; +#endif +#ifdef TPM_ALG_RSASSA + case TPM_ALG_RSASSA: + if (rc == 0) { + rc = TSS_TPMS_SIG_SCHEME_RSASSA_Marshalu(&source->rsassa, written, buffer, size); + } + break; +#endif +#ifdef TPM_ALG_RSAPSS + case TPM_ALG_RSAPSS: + if (rc == 0) { + rc = TSS_TPMS_SIG_SCHEME_RSAPSS_Marshalu(&source->rsapss, written, buffer, size); + } + break; +#endif +#ifdef TPM_ALG_ECDSA + case TPM_ALG_ECDSA: + if (rc == 0) { + rc = TSS_TPMS_SIG_SCHEME_ECDSA_Marshalu(&source->ecdsa, written, buffer, size); + } + break; +#endif +#ifdef TPM_ALG_ECDAA + case TPM_ALG_ECDAA: + if (rc == 0) { + rc = TSS_TPMS_SIG_SCHEME_ECDAA_Marshalu(&source->ecdaa, written, buffer, size); + } + break; +#endif +#ifdef TPM_ALG_SM2 + case TPM_ALG_SM2: + if (rc == 0) { + rc = TSS_TPMS_SIG_SCHEME_SM2_Marshalu(&source->sm2, written, buffer, size); + } + break; +#endif +#ifdef TPM_ALG_ECSCHNORR + case TPM_ALG_ECSCHNORR: + if (rc == 0) { + rc = TSS_TPMS_SIG_SCHEME_ECSCHNORR_Marshalu(&source->ecSchnorr, written, buffer, size); + } + break; +#endif +#ifdef TPM_ALG_RSAES + case TPM_ALG_RSAES: + if (rc == 0) { + rc = TSS_TPMS_ENC_SCHEME_RSAES_Marshalu(&source->rsaes, written, buffer, size); + } + break; +#endif +#ifdef TPM_ALG_OAEP + case TPM_ALG_OAEP: + if (rc == 0) { + rc = TSS_TPMS_ENC_SCHEME_OAEP_Marshalu(&source->oaep, written, buffer, size); + } + break; +#endif + case TPM_ALG_NULL: + break; + default: + rc = TPM_RC_SELECTOR; + } + return rc; +} + +/* Table 154 - Definition of (TPM_ALG_ID) {RSA} TPMI_ALG_RSA_SCHEME Type */ + +TPM_RC +TSS_TPMI_ALG_RSA_SCHEME_Marshalu(const TPMI_ALG_RSA_SCHEME *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPM_ALG_ID_Marshalu(source, written, buffer, size); + } + return rc; +} + +/* Table 155 - Definition of {RSA} TPMT_RSA_SCHEME Structure */ + +TPM_RC +TSS_TPMT_RSA_SCHEME_Marshalu(const TPMT_RSA_SCHEME *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_ALG_RSA_SCHEME_Marshalu(&source->scheme, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMU_ASYM_SCHEME_Marshalu(&source->details, written, buffer, size, source->scheme); + } + return rc; +} + +/* Table 156 - Definition of (TPM_ALG_ID) {RSA} TPMI_ALG_RSA_DECRYPT Type */ + +TPM_RC +TSS_TPMI_ALG_RSA_DECRYPT_Marshalu(const TPMI_ALG_RSA_DECRYPT *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPM_ALG_ID_Marshalu(source, written, buffer, size); + } + return rc; +} + +/* Table 157 - Definition of {RSA} TPMT_RSA_DECRYPT Structure */ + +TPM_RC +TSS_TPMT_RSA_DECRYPT_Marshalu(const TPMT_RSA_DECRYPT *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_ALG_RSA_DECRYPT_Marshalu(&source->scheme, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMU_ASYM_SCHEME_Marshalu(&source->details, written, buffer, size, source->scheme); + } + return rc; +} + +/* Table 158 - Definition of {RSA} TPM2B_PUBLIC_KEY_RSA Structure */ + +TPM_RC +TSS_TPM2B_PUBLIC_KEY_RSA_Marshalu(const TPM2B_PUBLIC_KEY_RSA *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPM2B_Marshalu(&source->b, written, buffer, size); + } + return rc; +} + +/* Table 159 - Definition of {RSA} (TPM_KEY_BITS) TPMI_RSA_KEY_BITS Type */ + +TPM_RC +TSS_TPMI_RSA_KEY_BITS_Marshalu(const TPMI_RSA_KEY_BITS *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPM_KEY_BITS_Marshalu(source, written, buffer, size); + } + return rc; +} + +/* Table 160 - Definition of {RSA} TPM2B_PRIVATE_KEY_RSA Structure */ + +TPM_RC +TSS_TPM2B_PRIVATE_KEY_RSA_Marshalu(const TPM2B_PRIVATE_KEY_RSA *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPM2B_Marshalu(&source->b, written, buffer, size); + } + return rc; +} + +/* Table 161 - Definition of {ECC} TPM2B_ECC_PARAMETER Structure */ + +TPM_RC +TSS_TPM2B_ECC_PARAMETER_Marshalu(const TPM2B_ECC_PARAMETER *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPM2B_Marshalu(&source->b, written, buffer, size); + } + return rc; +} + +/* Table 162 - Definition of {ECC} TPMS_ECC_POINT Structure */ + +TPM_RC +TSS_TPMS_ECC_POINT_Marshalu(const TPMS_ECC_POINT *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPM2B_ECC_PARAMETER_Marshalu(&source->x, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_ECC_PARAMETER_Marshalu(&source->y, written, buffer, size); + } + return rc; +} + +/* Table 163 - Definition of {ECC} TPM2B_ECC_POINT Structure */ + +TPM_RC +TSS_TPM2B_ECC_POINT_Marshalu(const TPM2B_ECC_POINT *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + uint16_t sizeWritten = 0; /* of structure */ + BYTE *sizePtr; + + if (buffer != NULL) { + sizePtr = *buffer; + *buffer += sizeof(uint16_t); + } + if (rc == 0) { + rc = TSS_TPMS_ECC_POINT_Marshalu(&source->point, &sizeWritten, buffer, size); + } + if (rc == 0) { + *written += sizeWritten; + if (buffer != NULL) { + rc = TSS_UINT16_Marshalu(&sizeWritten, written, &sizePtr, size); + } + else { + *written += sizeof(uint16_t); + } + } + return rc; +} + +/* Table 164 - Definition of (TPM_ALG_ID) {ECC} TPMI_ALG_ECC_SCHEME Type */ + +TPM_RC +TSS_TPMI_ALG_ECC_SCHEME_Marshalu(const TPMI_ALG_ECC_SCHEME *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPM_ALG_ID_Marshalu(source, written, buffer, size); + } + return rc; +} + +/* Table 165 - Definition of {ECC} (TPM_ECC_CURVE) TPMI_ECC_CURVE Type */ + +TPM_RC +TSS_TPMI_ECC_CURVE_Marshalu(const TPMI_ECC_CURVE *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPM_ECC_CURVE_Marshalu(source, written, buffer, size); + } + return rc; +} + +/* Table 166 - Definition of (TPMT_SIG_SCHEME) {ECC} TPMT_ECC_SCHEME Structure */ + +TPM_RC +TSS_TPMT_ECC_SCHEME_Marshalu(const TPMT_ECC_SCHEME *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_ALG_ECC_SCHEME_Marshalu(&source->scheme, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMU_ASYM_SCHEME_Marshalu(&source->details, written, buffer, size, source->scheme); + } + return rc; +} + +/* Table 167 - Definition of {ECC} TPMS_ALGORITHM_DETAIL_ECC Structure <OUT> */ + +TPM_RC +TSS_TPMS_ALGORITHM_DETAIL_ECC_Marshalu(const TPMS_ALGORITHM_DETAIL_ECC *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPM_ECC_CURVE_Marshalu(&source->curveID, written, buffer, size); + } + if (rc == 0) { + rc = TSS_UINT16_Marshalu(&source->keySize, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMT_KDF_SCHEME_Marshalu(&source->kdf, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMT_ECC_SCHEME_Marshalu(&source->sign, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_ECC_PARAMETER_Marshalu(&source->p, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_ECC_PARAMETER_Marshalu(&source->a, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_ECC_PARAMETER_Marshalu(&source->b, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_ECC_PARAMETER_Marshalu(&source->gX, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_ECC_PARAMETER_Marshalu(&source->gY, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_ECC_PARAMETER_Marshalu(&source->n, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_ECC_PARAMETER_Marshalu(&source->h, written, buffer, size); + } + return rc; +} + +/* Table 168 - Definition of {RSA} TPMS_SIGNATURE_RSA Structure */ + +TPM_RC +TSS_TPMS_SIGNATURE_RSA_Marshalu(const TPMS_SIGNATURE_RSA *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_ALG_HASH_Marshalu(&source->hash, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_PUBLIC_KEY_RSA_Marshalu(&source->sig, written, buffer, size); + } + return rc; +} + +/* Table 169 - Definition of Types for {RSA} Signature */ + +TPM_RC +TSS_TPMS_SIGNATURE_RSASSA_Marshalu(const TPMS_SIGNATURE_RSASSA *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMS_SIGNATURE_RSA_Marshalu(source, written, buffer, size); + } + return rc; +} +TPM_RC +TSS_TPMS_SIGNATURE_RSAPSS_Marshalu(const TPMS_SIGNATURE_RSAPSS *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMS_SIGNATURE_RSA_Marshalu(source, written, buffer, size); + } + return rc; +} + +/* Table 170 - Definition of {ECC} TPMS_SIGNATURE_ECC Structure */ + +TPM_RC +TSS_TPMS_SIGNATURE_ECC_Marshalu(const TPMS_SIGNATURE_ECC *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_ALG_HASH_Marshalu(&source->hash, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_ECC_PARAMETER_Marshalu(&source->signatureR, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_ECC_PARAMETER_Marshalu(&source->signatureS, written, buffer, size); + } + return rc; +} + +/* Table 171 - Definition of Types for {ECC} TPMS_SIGNATURE_ECC */ + +TPM_RC +TSS_TPMS_SIGNATURE_ECDSA_Marshalu(const TPMS_SIGNATURE_ECDSA *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMS_SIGNATURE_ECC_Marshalu(source, written, buffer, size); + } + return rc; +} + +TPM_RC +TSS_TPMS_SIGNATURE_ECDAA_Marshalu(const TPMS_SIGNATURE_ECDAA *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMS_SIGNATURE_ECC_Marshalu(source, written, buffer, size); + } + return rc; +} + +TPM_RC +TSS_TPMS_SIGNATURE_SM2_Marshalu(const TPMS_SIGNATURE_SM2 *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMS_SIGNATURE_ECC_Marshalu(source, written, buffer, size); + } + return rc; +} + +TPM_RC +TSS_TPMS_SIGNATURE_ECSCHNORR_Marshalu(const TPMS_SIGNATURE_ECSCHNORR *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMS_SIGNATURE_ECC_Marshalu(source, written, buffer, size); + } + return rc; +} + +/* Table 172 - Definition of TPMU_SIGNATURE Union <IN/OUT, S> */ + +TPM_RC +TSS_TPMU_SIGNATURE_Marshalu(const TPMU_SIGNATURE *source, uint16_t *written, BYTE **buffer, uint32_t *size, uint32_t selector) +{ + TPM_RC rc = 0; + switch (selector) { +#ifdef TPM_ALG_RSASSA + case TPM_ALG_RSASSA: + if (rc == 0) { + rc = TSS_TPMS_SIGNATURE_RSASSA_Marshalu(&source->rsassa, written, buffer, size); + } + break; +#endif +#ifdef TPM_ALG_RSAPSS + case TPM_ALG_RSAPSS: + if (rc == 0) { + rc = TSS_TPMS_SIGNATURE_RSAPSS_Marshalu(&source->rsapss, written, buffer, size); + } + break; +#endif +#ifdef TPM_ALG_ECDSA + case TPM_ALG_ECDSA: + if (rc == 0) { + rc = TSS_TPMS_SIGNATURE_ECDSA_Marshalu(&source->ecdsa, written, buffer, size); + } + break; +#endif +#ifdef TPM_ALG_ECDAA + case TPM_ALG_ECDAA: + if (rc == 0) { + rc = TSS_TPMS_SIGNATURE_ECDSA_Marshalu(&source->ecdaa, written, buffer, size); + } + break; +#endif +#ifdef TPM_ALG_SM2 + case TPM_ALG_SM2: + if (rc == 0) { + rc = TSS_TPMS_SIGNATURE_ECDSA_Marshalu(&source->sm2, written, buffer, size); + } + break; +#endif +#ifdef TPM_ALG_ECSCHNORR + case TPM_ALG_ECSCHNORR: + if (rc == 0) { + rc = TSS_TPMS_SIGNATURE_ECDSA_Marshalu(&source->ecschnorr, written, buffer, size); + } + break; +#endif +#ifdef TPM_ALG_HMAC + case TPM_ALG_HMAC: + if (rc == 0) { + rc = TSS_TPMT_HA_Marshalu(&source->hmac, written, buffer, size); + } + break; +#endif + case TPM_ALG_NULL: + break; + default: + rc = TPM_RC_SELECTOR; + } + return rc; +} + +/* Table 173 - Definition of TPMT_SIGNATURE Structure */ + +TPM_RC +TSS_TPMT_SIGNATURE_Marshalu(const TPMT_SIGNATURE *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_ALG_SIG_SCHEME_Marshalu(&source->sigAlg, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMU_SIGNATURE_Marshalu(&source->signature, written, buffer, size, source->sigAlg); + } + return rc; +} + +/* Table 175 - Definition of TPM2B_ENCRYPTED_SECRET Structure */ + +TPM_RC +TSS_TPM2B_ENCRYPTED_SECRET_Marshalu(const TPM2B_ENCRYPTED_SECRET *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPM2B_Marshalu(&source->b, written, buffer, size); + } + return rc; +} + +/* Table 176 - Definition of (TPM_ALG_ID) TPMI_ALG_PUBLIC Type */ + +TPM_RC +TSS_TPMI_ALG_PUBLIC_Marshalu(const TPMI_ALG_PUBLIC *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPM_ALG_ID_Marshalu(source, written, buffer, size); + } + return rc; +} + +/* Table 177 - Definition of TPMU_PUBLIC_ID Union <IN/OUT, S> */ + +TPM_RC +TSS_TPMU_PUBLIC_ID_Marshalu(const TPMU_PUBLIC_ID *source, uint16_t *written, BYTE **buffer, uint32_t *size, uint32_t selector) +{ + TPM_RC rc = 0; + switch (selector) { +#ifdef TPM_ALG_KEYEDHASH + case TPM_ALG_KEYEDHASH: + if (rc == 0) { + rc = TSS_TPM2B_DIGEST_Marshalu(&source->keyedHash, written, buffer, size); + } + break; +#endif +#ifdef TPM_ALG_SYMCIPHER + case TPM_ALG_SYMCIPHER: + if (rc == 0) { + rc = TSS_TPM2B_DIGEST_Marshalu(&source->sym, written, buffer, size); + } + break; +#endif +#ifdef TPM_ALG_RSA + case TPM_ALG_RSA: + if (rc == 0) { + rc = TSS_TPM2B_PUBLIC_KEY_RSA_Marshalu(&source->rsa, written, buffer, size); + } + break; +#endif +#ifdef TPM_ALG_ECC + case TPM_ALG_ECC: + if (rc == 0) { + rc = TSS_TPMS_ECC_POINT_Marshalu(&source->ecc, written, buffer, size); + } + break; +#endif + default: + rc = TPM_RC_SELECTOR; + } + return rc; +} + +/* Table 178 - Definition of TPMS_KEYEDHASH_PARMS Structure */ + +TPM_RC +TSS_TPMS_KEYEDHASH_PARMS_Marshalu(const TPMS_KEYEDHASH_PARMS *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMT_KEYEDHASH_SCHEME_Marshalu(&source->scheme, written, buffer, size); + } + return rc; +} + +/* Table 180 - Definition of {RSA} TPMS_RSA_PARMS Structure */ + +TPM_RC +TSS_TPMS_RSA_PARMS_Marshalu(const TPMS_RSA_PARMS *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMT_SYM_DEF_OBJECT_Marshalu(&source->symmetric, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMT_RSA_SCHEME_Marshalu(&source->scheme, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMI_RSA_KEY_BITS_Marshalu(&source->keyBits, written, buffer, size); + } + if (rc == 0) { + rc = TSS_UINT32_Marshalu(&source->exponent, written, buffer, size); + } + return rc; +} +/* Table 181 - Definition of {ECC} TPMS_ECC_PARMS Structure */ + +TPM_RC +TSS_TPMS_ECC_PARMS_Marshalu(const TPMS_ECC_PARMS *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMT_SYM_DEF_OBJECT_Marshalu(&source->symmetric, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMT_ECC_SCHEME_Marshalu(&source->scheme, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMI_ECC_CURVE_Marshalu(&source->curveID, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMT_KDF_SCHEME_Marshalu(&source->kdf, written, buffer, size); + } + return rc; +} + +/* Table 182 - Definition of TPMU_PUBLIC_PARMS Union <IN/OUT, S> */ + +TPM_RC +TSS_TPMU_PUBLIC_PARMS_Marshalu(const TPMU_PUBLIC_PARMS *source, uint16_t *written, BYTE **buffer, uint32_t *size, uint32_t selector) +{ + TPM_RC rc = 0; + switch (selector) { +#ifdef TPM_ALG_KEYEDHASH + case TPM_ALG_KEYEDHASH: + if (rc == 0) { + rc = TSS_TPMS_KEYEDHASH_PARMS_Marshalu(&source->keyedHashDetail, written, buffer, size); + } + break; +#endif +#ifdef TPM_ALG_SYMCIPHER + case TPM_ALG_SYMCIPHER: + if (rc == 0) { + rc = TSS_TPMS_SYMCIPHER_PARMS_Marshalu(&source->symDetail, written, buffer, size); + } + break; +#endif +#ifdef TPM_ALG_RSA + case TPM_ALG_RSA: + if (rc == 0) { + rc = TSS_TPMS_RSA_PARMS_Marshalu(&source->rsaDetail, written, buffer, size); + } + break; +#endif +#ifdef TPM_ALG_ECC + case TPM_ALG_ECC: + if (rc == 0) { + rc = TSS_TPMS_ECC_PARMS_Marshalu(&source->eccDetail, written, buffer, size); + } + break; +#endif + default: + rc = TPM_RC_SELECTOR; + } + return rc; +} + +/* Table 183 - Definition of TPMT_PUBLIC_PARMS Structure */ + +TPM_RC +TSS_TPMT_PUBLIC_PARMS_Marshalu(const TPMT_PUBLIC_PARMS *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_ALG_PUBLIC_Marshalu(&source->type, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMU_PUBLIC_PARMS_Marshalu(&source->parameters, written, buffer, size, source->type); + } + return rc; +} + +/* Table 184 - Definition of TPMT_PUBLIC Structure */ + +TPM_RC +TSS_TPMT_PUBLIC_Marshalu(const TPMT_PUBLIC *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_ALG_PUBLIC_Marshalu(&source->type, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMI_ALG_HASH_Marshalu(&source->nameAlg, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMA_OBJECT_Marshalu(&source->objectAttributes, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_DIGEST_Marshalu(&source->authPolicy, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMU_PUBLIC_PARMS_Marshalu(&source->parameters, written, buffer, size, source->type); + } + if (rc == 0) { + rc = TSS_TPMU_PUBLIC_ID_Marshalu(&source->unique, written, buffer, size, source->type); + } + return rc; +} + +/* Table 184 - Definition of TPMT_PUBLIC Structure - special marshaling for derived object template */ + +TPM_RC +TSS_TPMT_PUBLIC_D_Marshalu(const TPMT_PUBLIC *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_ALG_PUBLIC_Marshalu(&source->type, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMI_ALG_HASH_Marshalu(&source->nameAlg, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMA_OBJECT_Marshalu(&source->objectAttributes, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_DIGEST_Marshalu(&source->authPolicy, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMU_PUBLIC_PARMS_Marshalu(&source->parameters, written, buffer, size, source->type); + } + /* if derived from a derivation parent, marshal a TPMS_DERIVE structure */ + if (rc == 0) { + rc = TSS_TPMS_DERIVE_Marshalu(&source->unique.derive, written, buffer, size); + } + return rc; +} + +/* Table 185 - Definition of TPM2B_PUBLIC Structure */ + +TPM_RC +TSS_TPM2B_PUBLIC_Marshalu(const TPM2B_PUBLIC *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + uint16_t sizeWritten = 0; /* of structure */ + BYTE *sizePtr; + + if (buffer != NULL) { + sizePtr = *buffer; + *buffer += sizeof(uint16_t); + } + if (rc == 0) { + rc = TSS_TPMT_PUBLIC_Marshalu(&source->publicArea, &sizeWritten, buffer, size); + } + if (rc == 0) { + *written += sizeWritten; + if (buffer != NULL) { + rc = TSS_UINT16_Marshalu(&sizeWritten, written, &sizePtr, size); + } + else { + *written += sizeof(uint16_t); + } + } + return rc; +} + +TPM_RC +TSS_TPM2B_TEMPLATE_Marshalu(const TPM2B_TEMPLATE *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPM2B_Marshalu(&source->b, written, buffer, size); + } + return rc; +} + +/* Table 187 - Definition of TPMU_SENSITIVE_COMPOSITE Union <IN/OUT, S> */ + +TPM_RC +TSS_TPMU_SENSITIVE_COMPOSITE_Marshalu(const TPMU_SENSITIVE_COMPOSITE *source, uint16_t *written, BYTE **buffer, uint32_t *size, uint32_t selector) +{ + TPM_RC rc = 0; + switch (selector) { +#ifdef TPM_ALG_RSA + case TPM_ALG_RSA: + if (rc == 0) { + rc = TSS_TPM2B_PRIVATE_KEY_RSA_Marshalu(&source->rsa, written, buffer, size); + } + break; +#endif +#ifdef TPM_ALG_ECC + case TPM_ALG_ECC: + if (rc == 0) { + rc = TSS_TPM2B_ECC_PARAMETER_Marshalu(&source->ecc, written, buffer, size); + } + break; +#endif +#ifdef TPM_ALG_KEYEDHASH + case TPM_ALG_KEYEDHASH: + if (rc == 0) { + rc = TSS_TPM2B_SENSITIVE_DATA_Marshalu(&source->bits, written, buffer, size); + } + break; +#endif +#ifdef TPM_ALG_SYMCIPHER + case TPM_ALG_SYMCIPHER: + if (rc == 0) { + rc = TSS_TPM2B_SYM_KEY_Marshalu(&source->sym, written, buffer, size); + } + break; +#endif + default: + rc = TPM_RC_SELECTOR; + } + return rc; +} + +/* Table 188 - Definition of TPMT_SENSITIVE Structure */ + +TPM_RC +TSS_TPMT_SENSITIVE_Marshalu(const TPMT_SENSITIVE *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_ALG_PUBLIC_Marshalu(&source->sensitiveType, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_AUTH_Marshalu(&source->authValue, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_DIGEST_Marshalu(&source->seedValue, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMU_SENSITIVE_COMPOSITE_Marshalu(&source->sensitive, written, buffer, size, source->sensitiveType); + } + return rc; +} + +/* Table 189 - Definition of TPM2B_SENSITIVE Structure <IN/OUT> */ + +TPM_RC +TSS_TPM2B_SENSITIVE_Marshalu(const TPM2B_SENSITIVE *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + uint16_t sizeWritten = 0; /* of structure */ + BYTE *sizePtr; + + if (buffer != NULL) { + sizePtr = *buffer; + *buffer += sizeof(uint16_t); + } + if (rc == 0) { + rc = TSS_TPMT_SENSITIVE_Marshalu(&source->t.sensitiveArea, &sizeWritten, buffer, size); + } + if (rc == 0) { + *written += sizeWritten; + if (buffer != NULL) { + rc = TSS_UINT16_Marshalu(&sizeWritten, written, &sizePtr, size); + } + else { + *written += sizeof(uint16_t); + } + } + return rc; +} + +/* Table 191 - Definition of TPM2B_PRIVATE Structure <IN/OUT, S> */ + +TPM_RC +TSS_TPM2B_PRIVATE_Marshalu(const TPM2B_PRIVATE *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPM2B_Marshalu(&source->b, written, buffer, size); + } + return rc; +} + +/* Table 193 - Definition of TPM2B_ID_OBJECT Structure <IN/OUT> */ + +TPM_RC +TSS_TPM2B_ID_OBJECT_Marshalu(const TPM2B_ID_OBJECT *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPM2B_Marshalu(&source->b, written, buffer, size); + } + return rc; +} + +/* Table 196 - Definition of (UINT32) TPMA_NV Bits */ + +TPM_RC +TSS_TPMA_NV_Marshalu(const TPMA_NV *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_UINT32_Marshalu(&source->val, written, buffer, size); + } + return rc; +} + +/* Table 197 - Definition of TPMS_NV_PUBLIC Structure */ + +TPM_RC +TSS_TPMS_NV_PUBLIC_Marshalu(const TPMS_NV_PUBLIC *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPMI_RH_NV_INDEX_Marshalu(&source->nvIndex, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMI_ALG_HASH_Marshalu(&source->nameAlg, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMA_NV_Marshalu(&source->attributes, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_DIGEST_Marshalu(&source->authPolicy, written, buffer, size); + } + if (rc == 0) { + rc = TSS_UINT16_Marshalu(&source->dataSize, written, buffer, size); + } + return rc; +} + +/* Table 198 - Definition of TPM2B_NV_PUBLIC Structure */ + +TPM_RC +TSS_TPM2B_NV_PUBLIC_Marshalu(const TPM2B_NV_PUBLIC *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + uint16_t sizeWritten = 0; /* of structure */ + BYTE *sizePtr; + + if (buffer != NULL) { + sizePtr = *buffer; + *buffer += sizeof(uint16_t); + } + if (rc == 0) { + rc = TSS_TPMS_NV_PUBLIC_Marshalu(&source->nvPublic, &sizeWritten, buffer, size); + } + if (rc == 0) { + *written += sizeWritten; + if (buffer != NULL) { + rc = TSS_UINT16_Marshalu(&sizeWritten, written, &sizePtr, size); + } + else { + *written += sizeof(uint16_t); + } + } + return rc; +} + +/* Table 199 - Definition of TPM2B_CONTEXT_SENSITIVE Structure <IN/OUT> */ + +TPM_RC +TSS_TPM2B_CONTEXT_SENSITIVE_Marshalu(const TPM2B_CONTEXT_SENSITIVE *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPM2B_Marshalu(&source->b, written, buffer, size); + } + return rc; +} + +/* Table 201 - Definition of TPM2B_CONTEXT_DATA Structure <IN/OUT> */ + +TPM_RC +TSS_TPM2B_CONTEXT_DATA_Marshalu(const TPM2B_CONTEXT_DATA *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPM2B_Marshalu(&source->b, written, buffer, size); + } + return rc; +} + +/* Table 202 - Definition of TPMS_CONTEXT Structure */ + +TPM_RC +TSS_TPMS_CONTEXT_Marshalu(const TPMS_CONTEXT *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_UINT64_Marshalu(&source->sequence, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMI_DH_SAVED_Marshalu(&source->savedHandle, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMI_RH_HIERARCHY_Marshalu(&source->hierarchy, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_CONTEXT_DATA_Marshalu(&source->contextBlob, written, buffer, size); + } + return rc; +} + +/* Table 204 - Definition of TPMS_CREATION_DATA Structure <OUT> */ + +TPM_RC +TSS_TPMS_CREATION_DATA_Marshalu(const TPMS_CREATION_DATA *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_TPML_PCR_SELECTION_Marshalu(&source->pcrSelect, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_DIGEST_Marshalu(&source->pcrDigest, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPMA_LOCALITY_Marshalu(&source->locality, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM_ALG_ID_Marshalu(&source->parentNameAlg, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_NAME_Marshalu(&source->parentName, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_NAME_Marshalu(&source->parentQualifiedName, written, buffer, size); + } + if (rc == 0) { + rc = TSS_TPM2B_DATA_Marshalu(&source->outsideInfo, written, buffer, size); + } + return rc; +} + +/* Table 205 - Definition of TPM2B_CREATION_DATA Structure <OUT> */ + +TPM_RC +TSS_TPM2B_CREATION_DATA_Marshalu(const TPM2B_CREATION_DATA *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + uint16_t sizeWritten = 0; /* of structure */ + BYTE *sizePtr; + + if (buffer != NULL) { + sizePtr = *buffer; + *buffer += sizeof(uint16_t); + } + if (rc == 0) { + rc = TSS_TPMS_CREATION_DATA_Marshalu(&source->creationData, &sizeWritten, buffer, size); + } + if (rc == 0) { + *written += sizeWritten; + if (buffer != NULL) { + rc = TSS_UINT16_Marshalu(&sizeWritten, written, &sizePtr, size); + } + else { + *written += sizeof(uint16_t); + } + } + return rc; +} + +/* Deprecated functions that use a sized value for the size parameter. The recommended functions + use an unsigned value. + +*/ + +TPM_RC +TSS_UINT8_Marshal(const UINT8 *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_UINT8_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_INT8_Marshal(const INT8 *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_INT8_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_UINT16_Marshal(const UINT16 *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_UINT16_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_UINT32_Marshal(const UINT32 *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_UINT32_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_INT32_Marshal(const INT32 *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_INT32_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_UINT64_Marshal(const UINT64 *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_UINT64_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_Array_Marshal(const BYTE *source, uint16_t sourceSize, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_Array_Marshalu(source, sourceSize, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPM2B_Marshal(const TPM2B *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPM2B_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPM_KEY_BITS_Marshal(const TPM_KEY_BITS *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPM_KEY_BITS_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPM_GENERATED_Marshal(const TPM_GENERATED *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPM_GENERATED_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPM_ALG_ID_Marshal(const TPM_ALG_ID *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPM_ALG_ID_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPM_ECC_CURVE_Marshal(const TPM_ECC_CURVE *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPM_ECC_CURVE_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPM_RC_Marshal(const TPM_RC *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPM_RC_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPM_CLOCK_ADJUST_Marshal(const TPM_CLOCK_ADJUST *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPM_CLOCK_ADJUST_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPM_EO_Marshal(const TPM_EO *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPM_EO_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPM_ST_Marshal(const TPM_ST *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPM_ST_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPM_SU_Marshal(const TPM_ST *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPM_SU_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPM_SE_Marshal(const TPM_SE *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPM_SE_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPM_CAP_Marshal(const TPM_CAP *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPM_CAP_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPM_PT_Marshal(const TPM_PT *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPM_PT_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPM_PT_PCR_Marshal(const TPM_PT_PCR *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPM_PT_PCR_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPM_HANDLE_Marshal(const TPM_HANDLE *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPM_HANDLE_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMA_ALGORITHM_Marshal(const TPMA_ALGORITHM *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMA_ALGORITHM_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMA_OBJECT_Marshal(const TPMA_OBJECT *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMA_OBJECT_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMA_SESSION_Marshal(const TPMA_SESSION *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMA_SESSION_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMA_LOCALITY_Marshal(const TPMA_LOCALITY *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMA_LOCALITY_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPM_CC_Marshal(const TPM_CC *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPM_CC_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMA_CC_Marshal(const TPMA_CC *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMA_CC_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMI_YES_NO_Marshal(const TPMI_YES_NO *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMI_YES_NO_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMI_DH_OBJECT_Marshal(const TPMI_DH_OBJECT *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMI_DH_OBJECT_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMI_DH_PERSISTENT_Marshal(const TPMI_DH_PERSISTENT *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMI_DH_PERSISTENT_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMI_DH_ENTITY_Marshal(const TPMI_DH_ENTITY *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMI_DH_ENTITY_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMI_DH_PCR_Marshal(const TPMI_DH_PCR *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMI_DH_PCR_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMI_SH_AUTH_SESSION_Marshal(const TPMI_SH_AUTH_SESSION *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMI_SH_AUTH_SESSION_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMI_SH_HMAC_Marshal(const TPMI_SH_HMAC *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMI_SH_HMAC_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMI_SH_POLICY_Marshal(const TPMI_SH_POLICY*source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMI_SH_POLICY_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMI_DH_CONTEXT_Marshal(const TPMI_DH_CONTEXT *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMI_DH_CONTEXT_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMI_RH_HIERARCHY_Marshal(const TPMI_RH_HIERARCHY *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMI_RH_HIERARCHY_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMI_RH_ENABLES_Marshal(const TPMI_RH_ENABLES *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMI_RH_ENABLES_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMI_RH_HIERARCHY_AUTH_Marshal(const TPMI_RH_HIERARCHY_AUTH *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMI_RH_HIERARCHY_AUTH_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMI_RH_PLATFORM_Marshal(const TPMI_RH_PLATFORM *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMI_RH_PLATFORM_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMI_RH_ENDORSEMENT_Marshal(const TPMI_RH_ENDORSEMENT *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMI_RH_ENDORSEMENT_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMI_RH_PROVISION_Marshal(const TPMI_RH_PROVISION *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMI_RH_PROVISION_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMI_RH_CLEAR_Marshal(const TPMI_RH_CLEAR *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMI_RH_CLEAR_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMI_RH_NV_AUTH_Marshal(const TPMI_RH_NV_AUTH *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMI_RH_NV_AUTH_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMI_RH_LOCKOUT_Marshal(const TPMI_RH_LOCKOUT *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMI_RH_LOCKOUT_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMI_RH_NV_INDEX_Marshal(const TPMI_RH_NV_INDEX *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMI_RH_NV_INDEX_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMI_ALG_HASH_Marshal(const TPMI_ALG_HASH *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMI_ALG_HASH_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMI_ALG_SYM_Marshal(const TPMI_ALG_SYM *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMI_ALG_SYM_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMI_ALG_SYM_OBJECT_Marshal(const TPMI_ALG_SYM_OBJECT *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMI_ALG_SYM_OBJECT_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMI_ALG_SYM_MODE_Marshal(const TPMI_ALG_SYM_MODE *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMI_ALG_SYM_MODE_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMI_ALG_KDF_Marshal(const TPMI_ALG_KDF *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMI_ALG_KDF_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMI_ALG_SIG_SCHEME_Marshal(const TPMI_ALG_SIG_SCHEME *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMI_ALG_SIG_SCHEME_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMI_ECC_KEY_EXCHANGE_Marshal(const TPMI_ECC_KEY_EXCHANGE *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMI_ECC_KEY_EXCHANGE_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMI_ST_COMMAND_TAG_Marshal(const TPMI_ST_COMMAND_TAG *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMI_ST_COMMAND_TAG_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMI_ALG_MAC_SCHEME_Marshal(const TPMI_ALG_MAC_SCHEME *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMI_ALG_MAC_SCHEME_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMI_ALG_CIPHER_MODE_Marshal(const TPMI_ALG_CIPHER_MODE *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMI_ALG_CIPHER_MODE_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMU_HA_Marshal(const TPMU_HA *source, UINT16 *written, BYTE **buffer, INT32 *size, UINT32 selector) +{ + return TSS_TPMU_HA_Marshalu(source, written, buffer, (uint32_t *)size, selector); +} +TPM_RC +TSS_TPMT_HA_Marshal(const TPMT_HA *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMT_HA_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPM2B_DIGEST_Marshal(const TPM2B_DIGEST *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPM2B_DIGEST_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPM2B_DATA_Marshal(const TPM2B_DATA *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPM2B_DATA_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPM2B_NONCE_Marshal(const TPM2B_NONCE *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPM2B_NONCE_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPM2B_AUTH_Marshal(const TPM2B_AUTH *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPM2B_AUTH_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPM2B_OPERAND_Marshal(const TPM2B_OPERAND *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPM2B_OPERAND_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPM2B_EVENT_Marshal(const TPM2B_EVENT *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPM2B_EVENT_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPM2B_MAX_BUFFER_Marshal(const TPM2B_MAX_BUFFER *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPM2B_MAX_BUFFER_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPM2B_MAX_NV_BUFFER_Marshal(const TPM2B_MAX_NV_BUFFER *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPM2B_MAX_NV_BUFFER_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPM2B_TIMEOUT_Marshal(const TPM2B_TIMEOUT *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPM2B_TIMEOUT_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPM2B_IV_Marshal(const TPM2B_IV *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPM2B_IV_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPM2B_NAME_Marshal(const TPM2B_NAME *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPM2B_NAME_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMS_PCR_SELECTION_Marshal(const TPMS_PCR_SELECTION *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_PCR_SELECTION_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMT_TK_CREATION_Marshal(const TPMT_TK_CREATION *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMT_TK_CREATION_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMT_TK_VERIFIED_Marshal(const TPMT_TK_VERIFIED *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMT_TK_VERIFIED_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMT_TK_AUTH_Marshal(const TPMT_TK_AUTH *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMT_TK_AUTH_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMT_TK_HASHCHECK_Marshal(const TPMT_TK_HASHCHECK *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMT_TK_HASHCHECK_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMS_ALG_PROPERTY_Marshal(const TPMS_ALG_PROPERTY *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_ALG_PROPERTY_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMS_TAGGED_PROPERTY_Marshal(const TPMS_TAGGED_PROPERTY *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_TAGGED_PROPERTY_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMS_TAGGED_PCR_SELECT_Marshal(const TPMS_TAGGED_PCR_SELECT *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_TAGGED_PCR_SELECT_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPML_CC_Marshal(const TPML_CC *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPML_CC_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPML_CCA_Marshal(const TPML_CCA *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPML_CCA_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPML_ALG_Marshal(const TPML_ALG *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPML_ALG_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPML_HANDLE_Marshal(const TPML_HANDLE *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPML_HANDLE_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPML_DIGEST_Marshal(const TPML_DIGEST *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPML_DIGEST_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPML_DIGEST_VALUES_Marshal(const TPML_DIGEST_VALUES *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPML_DIGEST_VALUES_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPML_PCR_SELECTION_Marshal(const TPML_PCR_SELECTION *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPML_PCR_SELECTION_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPML_ALG_PROPERTY_Marshal(const TPML_ALG_PROPERTY *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPML_ALG_PROPERTY_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPML_TAGGED_TPM_PROPERTY_Marshal(const TPML_TAGGED_TPM_PROPERTY *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPML_TAGGED_TPM_PROPERTY_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPML_TAGGED_PCR_PROPERTY_Marshal(const TPML_TAGGED_PCR_PROPERTY *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPML_TAGGED_PCR_PROPERTY_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPML_ECC_CURVE_Marshal(const TPML_ECC_CURVE *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPML_ECC_CURVE_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMU_CAPABILITIES_Marshal(const TPMU_CAPABILITIES *source, UINT16 *written, BYTE **buffer, INT32 *size, UINT32 selector) +{ + return TSS_TPMU_CAPABILITIES_Marshalu(source, written, buffer, (uint32_t *)size, selector); +} +TPM_RC +TSS_TPMS_CAPABILITY_DATA_Marshal(const TPMS_CAPABILITY_DATA *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_CAPABILITY_DATA_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMS_CLOCK_INFO_Marshal(const TPMS_CLOCK_INFO *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_CLOCK_INFO_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMS_TIME_INFO_Marshal(const TPMS_TIME_INFO *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_TIME_INFO_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMS_TIME_ATTEST_INFO_Marshal(const TPMS_TIME_ATTEST_INFO *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_TIME_ATTEST_INFO_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMS_CERTIFY_INFO_Marshal(const TPMS_CERTIFY_INFO *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_CERTIFY_INFO_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMS_QUOTE_INFO_Marshal(const TPMS_QUOTE_INFO *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_QUOTE_INFO_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMS_COMMAND_AUDIT_INFO_Marshal(const TPMS_COMMAND_AUDIT_INFO *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_COMMAND_AUDIT_INFO_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMS_SESSION_AUDIT_INFO_Marshal(const TPMS_SESSION_AUDIT_INFO *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_SESSION_AUDIT_INFO_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMS_CREATION_INFO_Marshal(const TPMS_CREATION_INFO *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_CREATION_INFO_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMS_NV_CERTIFY_INFO_Marshal(const TPMS_NV_CERTIFY_INFO *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_NV_CERTIFY_INFO_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMI_ST_ATTEST_Marshal(const TPMI_ST_ATTEST *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMI_ST_ATTEST_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMU_ATTEST_Marshal(const TPMU_ATTEST *source, UINT16 *written, BYTE **buffer, INT32 *size, UINT32 selector) +{ + return TSS_TPMU_ATTEST_Marshalu(source, written, buffer, (uint32_t *)size, selector); +} +TPM_RC +TSS_TPMS_ATTEST_Marshal(const TPMS_ATTEST *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_ATTEST_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPM2B_ATTEST_Marshal(const TPM2B_ATTEST *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPM2B_ATTEST_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMS_AUTH_COMMAND_Marshal(const TPMS_AUTH_COMMAND *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_AUTH_COMMAND_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMI_AES_KEY_BITS_Marshal(const TPMI_AES_KEY_BITS *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMI_AES_KEY_BITS_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMU_SYM_KEY_BITS_Marshal(const TPMU_SYM_KEY_BITS *source, UINT16 *written, BYTE **buffer, INT32 *size, UINT32 selector) +{ + return TSS_TPMU_SYM_KEY_BITS_Marshalu(source, written, buffer, (uint32_t *)size, selector); +} +TPM_RC +TSS_TPMU_SYM_MODE_Marshal(const TPMU_SYM_MODE *source, UINT16 *written, BYTE **buffer, INT32 *size, UINT32 selector) +{ + return TSS_TPMU_SYM_MODE_Marshalu(source, written, buffer, (uint32_t *)size, selector); +} +TPM_RC +TSS_TPMT_SYM_DEF_Marshal(const TPMT_SYM_DEF *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMT_SYM_DEF_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMT_SYM_DEF_OBJECT_Marshal(const TPMT_SYM_DEF_OBJECT *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMT_SYM_DEF_OBJECT_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPM2B_SYM_KEY_Marshal(const TPM2B_SYM_KEY *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPM2B_SYM_KEY_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPM2B_LABEL_Marshal(const TPM2B_LABEL *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPM2B_LABEL_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMS_DERIVE_Marshal(const TPMS_DERIVE *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_DERIVE_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMS_SYMCIPHER_PARMS_Marshal(const TPMS_SYMCIPHER_PARMS *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_SYMCIPHER_PARMS_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPM2B_SENSITIVE_DATA_Marshal(const TPM2B_SENSITIVE_DATA *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPM2B_SENSITIVE_DATA_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMS_SENSITIVE_CREATE_Marshal(const TPMS_SENSITIVE_CREATE *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_SENSITIVE_CREATE_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPM2B_SENSITIVE_CREATE_Marshal(const TPM2B_SENSITIVE_CREATE *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPM2B_SENSITIVE_CREATE_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMS_SCHEME_HASH_Marshal(const TPMS_SCHEME_HASH *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_SCHEME_HASH_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMS_SCHEME_ECDAA_Marshal(const TPMS_SCHEME_ECDAA *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_SCHEME_ECDAA_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMI_ALG_KEYEDHASH_SCHEME_Marshal(const TPMI_ALG_KEYEDHASH_SCHEME *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMI_ALG_KEYEDHASH_SCHEME_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMS_SCHEME_HMAC_Marshal(const TPMS_SCHEME_HMAC *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_SCHEME_HMAC_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMS_SCHEME_XOR_Marshal(const TPMS_SCHEME_XOR *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_SCHEME_XOR_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMU_SCHEME_KEYEDHASH_Marshal(const TPMU_SCHEME_KEYEDHASH *source, UINT16 *written, BYTE **buffer, INT32 *size, UINT32 selector) +{ + return TSS_TPMU_SCHEME_KEYEDHASH_Marshalu(source, written, buffer, (uint32_t *)size, selector); +} +TPM_RC +TSS_TPMT_KEYEDHASH_SCHEME_Marshal(const TPMT_KEYEDHASH_SCHEME *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMT_KEYEDHASH_SCHEME_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMS_SIG_SCHEME_RSASSA_Marshal(const TPMS_SIG_SCHEME_RSASSA *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_SIG_SCHEME_RSASSA_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMS_SIG_SCHEME_RSAPSS_Marshal(const TPMS_SIG_SCHEME_RSAPSS *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_SIG_SCHEME_RSAPSS_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMS_SIG_SCHEME_ECDSA_Marshal(const TPMS_SIG_SCHEME_ECDSA *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_SIG_SCHEME_ECDSA_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMS_SIG_SCHEME_SM2_Marshal(const TPMS_SIG_SCHEME_SM2 *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_SIG_SCHEME_SM2_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMS_SIG_SCHEME_ECSCHNORR_Marshal(const TPMS_SIG_SCHEME_ECSCHNORR *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_SIG_SCHEME_ECSCHNORR_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMS_SIG_SCHEME_ECDAA_Marshal(const TPMS_SIG_SCHEME_ECDAA *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_SIG_SCHEME_ECDAA_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMU_SIG_SCHEME_Marshal(const TPMU_SIG_SCHEME *source, UINT16 *written, BYTE **buffer, INT32 *size, UINT32 selector) +{ + return TSS_TPMU_SIG_SCHEME_Marshalu(source, written, buffer, (uint32_t *)size, selector); +} +TPM_RC +TSS_TPMT_SIG_SCHEME_Marshal(const TPMT_SIG_SCHEME *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMT_SIG_SCHEME_Marshalu(source, written, buffer, (uint32_t *)size); +} + +/* NOTE: Marked as const function in header */ + +TPM_RC +TSS_TPMS_ENC_SCHEME_OAEP_Marshal(const TPMS_ENC_SCHEME_OAEP *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_ENC_SCHEME_OAEP_Marshalu(source, written, buffer, (uint32_t *)size); +} + +/* NOTE: Marked as const function in header */ + +TPM_RC +TSS_TPMS_ENC_SCHEME_RSAES_Marshal(const TPMS_ENC_SCHEME_RSAES *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_ENC_SCHEME_RSAES_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMS_KEY_SCHEME_ECDH_Marshal(const TPMS_KEY_SCHEME_ECDH *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_KEY_SCHEME_ECDH_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMS_KEY_SCHEME_ECMQV_Marshal(const TPMS_KEY_SCHEME_ECMQV *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_KEY_SCHEME_ECMQV_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMS_SCHEME_MGF1_Marshal(const TPMS_SCHEME_MGF1 *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_SCHEME_MGF1_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMS_SCHEME_KDF1_SP800_56A_Marshal(const TPMS_SCHEME_KDF1_SP800_56A *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_SCHEME_KDF1_SP800_56A_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMS_SCHEME_KDF2_Marshal(const TPMS_SCHEME_KDF2 *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_SCHEME_KDF2_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMS_SCHEME_KDF1_SP800_108_Marshal(const TPMS_SCHEME_KDF1_SP800_108 *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_SCHEME_KDF1_SP800_108_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMU_KDF_SCHEME_Marshal(const TPMU_KDF_SCHEME *source, UINT16 *written, BYTE **buffer, INT32 *size, UINT32 selector) +{ + return TSS_TPMU_KDF_SCHEME_Marshalu(source, written, buffer, (uint32_t *)size, selector); +} +TPM_RC +TSS_TPMT_KDF_SCHEME_Marshal(const TPMT_KDF_SCHEME *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMT_KDF_SCHEME_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMU_ASYM_SCHEME_Marshal(const TPMU_ASYM_SCHEME *source, UINT16 *written, BYTE **buffer, INT32 *size, UINT32 selector) +{ + return TSS_TPMU_ASYM_SCHEME_Marshalu(source, written, buffer, (uint32_t *)size, selector); +} +TPM_RC +TSS_TPMI_ALG_RSA_SCHEME_Marshal(const TPMI_ALG_RSA_SCHEME *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMI_ALG_RSA_SCHEME_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMT_RSA_SCHEME_Marshal(const TPMT_RSA_SCHEME *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMT_RSA_SCHEME_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMI_ALG_RSA_DECRYPT_Marshal(const TPMI_ALG_RSA_DECRYPT *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMI_ALG_RSA_DECRYPT_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMT_RSA_DECRYPT_Marshal(const TPMT_RSA_DECRYPT *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMT_RSA_DECRYPT_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPM2B_PUBLIC_KEY_RSA_Marshal(const TPM2B_PUBLIC_KEY_RSA *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPM2B_PUBLIC_KEY_RSA_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMI_RSA_KEY_BITS_Marshal(const TPMI_RSA_KEY_BITS *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMI_RSA_KEY_BITS_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPM2B_PRIVATE_KEY_RSA_Marshal(const TPM2B_PRIVATE_KEY_RSA *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPM2B_PRIVATE_KEY_RSA_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPM2B_ECC_PARAMETER_Marshal(const TPM2B_ECC_PARAMETER *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPM2B_ECC_PARAMETER_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMS_ECC_POINT_Marshal(const TPMS_ECC_POINT *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_ECC_POINT_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPM2B_ECC_POINT_Marshal(const TPM2B_ECC_POINT *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPM2B_ECC_POINT_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMI_ALG_ECC_SCHEME_Marshal(const TPMI_ALG_ECC_SCHEME *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMI_ALG_ECC_SCHEME_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMI_ECC_CURVE_Marshal(const TPMI_ECC_CURVE *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMI_ECC_CURVE_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMT_ECC_SCHEME_Marshal(const TPMT_ECC_SCHEME *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMT_ECC_SCHEME_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMS_ALGORITHM_DETAIL_ECC_Marshal(const TPMS_ALGORITHM_DETAIL_ECC *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_ALGORITHM_DETAIL_ECC_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMS_SIGNATURE_RSA_Marshal(const TPMS_SIGNATURE_RSA *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_SIGNATURE_RSA_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMS_SIGNATURE_RSASSA_Marshal(const TPMS_SIGNATURE_RSASSA *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_SIGNATURE_RSASSA_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMS_SIGNATURE_RSAPSS_Marshal(const TPMS_SIGNATURE_RSAPSS *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_SIGNATURE_RSAPSS_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMS_SIGNATURE_ECC_Marshal(const TPMS_SIGNATURE_ECC *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_SIGNATURE_ECC_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMS_SIGNATURE_ECDSA_Marshal(const TPMS_SIGNATURE_ECDSA *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_SIGNATURE_ECDSA_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMS_SIGNATURE_ECDAA_Marshal(const TPMS_SIGNATURE_ECDAA *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_SIGNATURE_ECDAA_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMS_SIGNATURE_SM2_Marshal(const TPMS_SIGNATURE_SM2 *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_SIGNATURE_SM2_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMS_SIGNATURE_ECSCHNORR_Marshal(const TPMS_SIGNATURE_ECSCHNORR *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_SIGNATURE_ECSCHNORR_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMU_SIGNATURE_Marshal(const TPMU_SIGNATURE *source, UINT16 *written, BYTE **buffer, INT32 *size, UINT32 selector) +{ + return TSS_TPMU_SIGNATURE_Marshalu(source, written, buffer, (uint32_t *)size, selector); +} +TPM_RC +TSS_TPMT_SIGNATURE_Marshal(const TPMT_SIGNATURE *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMT_SIGNATURE_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPM2B_ENCRYPTED_SECRET_Marshal(const TPM2B_ENCRYPTED_SECRET *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPM2B_ENCRYPTED_SECRET_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMI_ALG_PUBLIC_Marshal(const TPMI_ALG_PUBLIC *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMI_ALG_PUBLIC_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMU_PUBLIC_ID_Marshal(const TPMU_PUBLIC_ID *source, UINT16 *written, BYTE **buffer, INT32 *size, UINT32 selector) +{ + return TSS_TPMU_PUBLIC_ID_Marshalu(source, written, buffer, (uint32_t *)size, selector); +} +TPM_RC +TSS_TPMS_KEYEDHASH_PARMS_Marshal(const TPMS_KEYEDHASH_PARMS *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_KEYEDHASH_PARMS_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMS_RSA_PARMS_Marshal(const TPMS_RSA_PARMS *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_RSA_PARMS_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMS_ECC_PARMS_Marshal(const TPMS_ECC_PARMS *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_ECC_PARMS_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMU_PUBLIC_PARMS_Marshal(const TPMU_PUBLIC_PARMS *source, UINT16 *written, BYTE **buffer, INT32 *size, UINT32 selector) +{ + return TSS_TPMU_PUBLIC_PARMS_Marshalu(source, written, buffer, (uint32_t *)size, selector); +} +TPM_RC +TSS_TPMT_PUBLIC_PARMS_Marshal(const TPMT_PUBLIC_PARMS *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMT_PUBLIC_PARMS_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMT_PUBLIC_Marshal(const TPMT_PUBLIC *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMT_PUBLIC_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMT_PUBLIC_D_Marshal(const TPMT_PUBLIC *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMT_PUBLIC_D_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPM2B_PUBLIC_Marshal(const TPM2B_PUBLIC *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPM2B_PUBLIC_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPM2B_TEMPLATE_Marshal(const TPM2B_TEMPLATE *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPM2B_TEMPLATE_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMU_SENSITIVE_COMPOSITE_Marshal(const TPMU_SENSITIVE_COMPOSITE *source, UINT16 *written, BYTE **buffer, INT32 *size, UINT32 selector) +{ + return TSS_TPMU_SENSITIVE_COMPOSITE_Marshalu(source, written, buffer, (uint32_t *)size, selector); +} +TPM_RC +TSS_TPMT_SENSITIVE_Marshal(const TPMT_SENSITIVE *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMT_SENSITIVE_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPM2B_SENSITIVE_Marshal(const TPM2B_SENSITIVE *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPM2B_SENSITIVE_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPM2B_PRIVATE_Marshal(const TPM2B_PRIVATE *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPM2B_PRIVATE_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPM2B_ID_OBJECT_Marshal(const TPM2B_ID_OBJECT *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPM2B_ID_OBJECT_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMA_NV_Marshal(const TPMA_NV *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMA_NV_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMS_NV_PUBLIC_Marshal(const TPMS_NV_PUBLIC *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_NV_PUBLIC_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPM2B_NV_PUBLIC_Marshal(const TPM2B_NV_PUBLIC *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPM2B_NV_PUBLIC_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPM2B_CONTEXT_SENSITIVE_Marshal(const TPM2B_CONTEXT_SENSITIVE *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPM2B_CONTEXT_SENSITIVE_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPM2B_CONTEXT_DATA_Marshal(const TPM2B_CONTEXT_DATA *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPM2B_CONTEXT_DATA_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMS_CONTEXT_Marshal(const TPMS_CONTEXT *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_CONTEXT_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPMS_CREATION_DATA_Marshal(const TPMS_CREATION_DATA *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPMS_CREATION_DATA_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TPM2B_CREATION_DATA_Marshal(const TPM2B_CREATION_DATA *source, UINT16 *written, BYTE **buffer, INT32 *size) +{ + return TSS_TPM2B_CREATION_DATA_Marshalu(source, written, buffer, (uint32_t *)size); +} + + + +TPM_RC +TSS_Startup_In_Marshal(const Startup_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_Startup_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_Shutdown_In_Marshal(const Shutdown_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_Shutdown_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_SelfTest_In_Marshal(const SelfTest_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_SelfTest_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_IncrementalSelfTest_In_Marshal(const IncrementalSelfTest_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_IncrementalSelfTest_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_StartAuthSession_In_Marshal(const StartAuthSession_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_StartAuthSession_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_PolicyRestart_In_Marshal(const PolicyRestart_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_PolicyRestart_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_Create_In_Marshal(const Create_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_Create_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_Load_In_Marshal(const Load_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_Load_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_LoadExternal_In_Marshal(const LoadExternal_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_LoadExternal_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_ReadPublic_In_Marshal(const ReadPublic_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_ReadPublic_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_ActivateCredential_In_Marshal(const ActivateCredential_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_ActivateCredential_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_MakeCredential_In_Marshal(const MakeCredential_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_MakeCredential_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_Unseal_In_Marshal(const Unseal_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_Unseal_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_ObjectChangeAuth_In_Marshal(const ObjectChangeAuth_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_ObjectChangeAuth_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_CreateLoaded_In_Marshal(const CreateLoaded_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_CreateLoaded_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_Duplicate_In_Marshal(const Duplicate_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_Duplicate_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_Rewrap_In_Marshal(const Rewrap_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_Rewrap_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_Import_In_Marshal(const Import_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_Import_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_RSA_Encrypt_In_Marshal(const RSA_Encrypt_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_RSA_Encrypt_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_RSA_Decrypt_In_Marshal(const RSA_Decrypt_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_RSA_Decrypt_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_ECDH_KeyGen_In_Marshal(const ECDH_KeyGen_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_ECDH_KeyGen_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_ECDH_ZGen_In_Marshal(const ECDH_ZGen_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_ECDH_ZGen_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_ECC_Parameters_In_Marshal(const ECC_Parameters_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_ECC_Parameters_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_ZGen_2Phase_In_Marshal(const ZGen_2Phase_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_ZGen_2Phase_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_EncryptDecrypt_In_Marshal(const EncryptDecrypt_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_EncryptDecrypt_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_EncryptDecrypt2_In_Marshal(const EncryptDecrypt2_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_EncryptDecrypt2_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_Hash_In_Marshal(const Hash_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_Hash_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_HMAC_In_Marshal(const HMAC_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_HMAC_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_GetRandom_In_Marshal(const GetRandom_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_GetRandom_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_StirRandom_In_Marshal(const StirRandom_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_StirRandom_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_HMAC_Start_In_Marshal(const HMAC_Start_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_HMAC_Start_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_HashSequenceStart_In_Marshal(const HashSequenceStart_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_HashSequenceStart_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_SequenceUpdate_In_Marshal(const SequenceUpdate_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_SequenceUpdate_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_SequenceComplete_In_Marshal(const SequenceComplete_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_SequenceComplete_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_EventSequenceComplete_In_Marshal(const EventSequenceComplete_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_EventSequenceComplete_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_Certify_In_Marshal(const Certify_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_Certify_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_CertifyCreation_In_Marshal(const CertifyCreation_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_CertifyCreation_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_Quote_In_Marshal(const Quote_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_Quote_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_GetSessionAuditDigest_In_Marshal(const GetSessionAuditDigest_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_GetSessionAuditDigest_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_GetCommandAuditDigest_In_Marshal(const GetCommandAuditDigest_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_GetCommandAuditDigest_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_GetTime_In_Marshal(const GetTime_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_GetTime_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_Commit_In_Marshal(const Commit_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_Commit_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_EC_Ephemeral_In_Marshal(const EC_Ephemeral_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_EC_Ephemeral_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_VerifySignature_In_Marshal(const VerifySignature_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_VerifySignature_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_Sign_In_Marshal(const Sign_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_Sign_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_SetCommandCodeAuditStatus_In_Marshal(const SetCommandCodeAuditStatus_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_SetCommandCodeAuditStatus_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_PCR_Extend_In_Marshal(const PCR_Extend_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_PCR_Extend_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_PCR_Event_In_Marshal(const PCR_Event_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_PCR_Event_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_PCR_Read_In_Marshal(const PCR_Read_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_PCR_Read_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_PCR_Allocate_In_Marshal(const PCR_Allocate_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_PCR_Allocate_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_PCR_SetAuthPolicy_In_Marshal(const PCR_SetAuthPolicy_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_PCR_SetAuthPolicy_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_PCR_SetAuthValue_In_Marshal(const PCR_SetAuthValue_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_PCR_SetAuthValue_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_PCR_Reset_In_Marshal(const PCR_Reset_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_PCR_Reset_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_PolicySigned_In_Marshal(const PolicySigned_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_PolicySigned_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_PolicySecret_In_Marshal(const PolicySecret_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_PolicySecret_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_PolicyTicket_In_Marshal(const PolicyTicket_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_PolicyTicket_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_PolicyOR_In_Marshal(const PolicyOR_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_PolicyOR_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_PolicyPCR_In_Marshal(const PolicyPCR_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_PolicyPCR_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_PolicyLocality_In_Marshal(const PolicyLocality_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_PolicyLocality_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_PolicyNV_In_Marshal(const PolicyNV_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_PolicyNV_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_PolicyCounterTimer_In_Marshal(const PolicyCounterTimer_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_PolicyCounterTimer_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_PolicyCommandCode_In_Marshal(const PolicyCommandCode_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_PolicyCommandCode_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_PolicyPhysicalPresence_In_Marshal(const PolicyPhysicalPresence_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_PolicyPhysicalPresence_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_PolicyCpHash_In_Marshal(const PolicyCpHash_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_PolicyCpHash_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_PolicyNameHash_In_Marshal(const PolicyNameHash_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_PolicyNameHash_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_PolicyDuplicationSelect_In_Marshal(const PolicyDuplicationSelect_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_PolicyDuplicationSelect_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_PolicyAuthorize_In_Marshal(const PolicyAuthorize_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_PolicyAuthorize_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_PolicyAuthValue_In_Marshal(const PolicyAuthValue_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_PolicyAuthValue_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_PolicyPassword_In_Marshal(const PolicyPassword_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_PolicyPassword_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_PolicyGetDigest_In_Marshal(const PolicyGetDigest_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_PolicyGetDigest_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_PolicyNvWritten_In_Marshal(const PolicyNvWritten_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_PolicyNvWritten_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_PolicyTemplate_In_Marshal(const PolicyTemplate_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_PolicyTemplate_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_PolicyAuthorizeNV_In_Marshal(const PolicyAuthorizeNV_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_PolicyAuthorizeNV_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_CreatePrimary_In_Marshal(const CreatePrimary_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_CreatePrimary_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_HierarchyControl_In_Marshal(const HierarchyControl_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_HierarchyControl_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_SetPrimaryPolicy_In_Marshal(const SetPrimaryPolicy_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_SetPrimaryPolicy_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_ChangePPS_In_Marshal(const ChangePPS_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_ChangePPS_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_ChangeEPS_In_Marshal(const ChangeEPS_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_ChangeEPS_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_Clear_In_Marshal(const Clear_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_Clear_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_ClearControl_In_Marshal(const ClearControl_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_ClearControl_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_HierarchyChangeAuth_In_Marshal(const HierarchyChangeAuth_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_HierarchyChangeAuth_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_DictionaryAttackLockReset_In_Marshal(const DictionaryAttackLockReset_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_DictionaryAttackLockReset_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_DictionaryAttackParameters_In_Marshal(const DictionaryAttackParameters_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_DictionaryAttackParameters_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_PP_Commands_In_Marshal(const PP_Commands_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_PP_Commands_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_SetAlgorithmSet_In_Marshal(const SetAlgorithmSet_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_SetAlgorithmSet_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_ContextSave_In_Marshal(const ContextSave_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_ContextSave_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_ContextLoad_In_Marshal(const ContextLoad_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_ContextLoad_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_FlushContext_In_Marshal(const FlushContext_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_FlushContext_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_EvictControl_In_Marshal(const EvictControl_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_EvictControl_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_ClockSet_In_Marshal(const ClockSet_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_ClockSet_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_ClockRateAdjust_In_Marshal(const ClockRateAdjust_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_ClockRateAdjust_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_GetCapability_In_Marshal(const GetCapability_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_GetCapability_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_TestParms_In_Marshal(const TestParms_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_TestParms_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_NV_DefineSpace_In_Marshal(const NV_DefineSpace_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_NV_DefineSpace_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_NV_UndefineSpace_In_Marshal(const NV_UndefineSpace_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_NV_UndefineSpace_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_NV_UndefineSpaceSpecial_In_Marshal(const NV_UndefineSpaceSpecial_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_NV_UndefineSpaceSpecial_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_NV_ReadPublic_In_Marshal(const NV_ReadPublic_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_NV_ReadPublic_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_NV_Write_In_Marshal(const NV_Write_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_NV_Write_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_NV_Increment_In_Marshal(const NV_Increment_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_NV_Increment_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_NV_Extend_In_Marshal(const NV_Extend_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_NV_Extend_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_NV_SetBits_In_Marshal(const NV_SetBits_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_NV_SetBits_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_NV_WriteLock_In_Marshal(const NV_WriteLock_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_NV_WriteLock_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_NV_GlobalWriteLock_In_Marshal(const NV_GlobalWriteLock_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_NV_GlobalWriteLock_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_NV_Read_In_Marshal(const NV_Read_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_NV_Read_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_NV_ReadLock_In_Marshal(const NV_ReadLock_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_NV_ReadLock_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_NV_ChangeAuth_In_Marshal(const NV_ChangeAuth_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_NV_ChangeAuth_In_Marshalu(source, written, buffer, (uint32_t *)size); +} +TPM_RC +TSS_NV_Certify_In_Marshal(const NV_Certify_In *source, uint16_t *written, BYTE **buffer, int32_t *size) +{ + return TSS_NV_Certify_In_Marshalu(source, written, buffer, (uint32_t *)size); +} + + + +TPM_RC +TSS_IncrementalSelfTest_Out_Unmarshal(IncrementalSelfTest_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size) +{ + return TSS_IncrementalSelfTest_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size); +} +TPM_RC +TSS_GetTestResult_Out_Unmarshal(GetTestResult_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size) +{ + return TSS_GetTestResult_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size); +} +TPM_RC +TSS_StartAuthSession_Out_Unmarshal(StartAuthSession_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size) +{ + return TSS_StartAuthSession_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size); +} +TPM_RC +TSS_Create_Out_Unmarshal(Create_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size) +{ + return TSS_Create_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size); +} +TPM_RC +TSS_Load_Out_Unmarshal(Load_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size) +{ + return TSS_Load_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size); +} +TPM_RC +TSS_LoadExternal_Out_Unmarshal(LoadExternal_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size) +{ + return TSS_LoadExternal_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size); +} +TPM_RC +TSS_ReadPublic_Out_Unmarshal(ReadPublic_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size) +{ + return TSS_ReadPublic_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size); +} +TPM_RC +TSS_ActivateCredential_Out_Unmarshal(ActivateCredential_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size) +{ + return TSS_ActivateCredential_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size); +} +TPM_RC +TSS_MakeCredential_Out_Unmarshal(MakeCredential_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size) +{ + return TSS_MakeCredential_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size); +} +TPM_RC +TSS_Unseal_Out_Unmarshal(Unseal_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size) +{ + return TSS_Unseal_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size); +} +TPM_RC +TSS_ObjectChangeAuth_Out_Unmarshal(ObjectChangeAuth_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size) +{ + return TSS_ObjectChangeAuth_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size); +} +TPM_RC +TSS_CreateLoaded_Out_Unmarshal(CreateLoaded_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size) +{ + return TSS_CreateLoaded_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size); +} +TPM_RC +TSS_Duplicate_Out_Unmarshal(Duplicate_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size) +{ + return TSS_Duplicate_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size); +} +TPM_RC +TSS_Rewrap_Out_Unmarshal(Rewrap_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size) +{ + return TSS_Rewrap_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size); +} +TPM_RC +TSS_Import_Out_Unmarshal(Import_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size) +{ + return TSS_Import_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size); +} +TPM_RC +TSS_RSA_Encrypt_Out_Unmarshal(RSA_Encrypt_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size) +{ + return TSS_RSA_Encrypt_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size); +} +TPM_RC +TSS_RSA_Decrypt_Out_Unmarshal(RSA_Decrypt_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size) +{ + return TSS_RSA_Decrypt_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size); +} +TPM_RC +TSS_ECDH_KeyGen_Out_Unmarshal(ECDH_KeyGen_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size) +{ + return TSS_ECDH_KeyGen_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size); +} +TPM_RC +TSS_ECDH_ZGen_Out_Unmarshal(ECDH_ZGen_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size) +{ + return TSS_ECDH_ZGen_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size); +} +TPM_RC +TSS_ECC_Parameters_Out_Unmarshal(ECC_Parameters_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size) +{ + return TSS_ECC_Parameters_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size); +} +TPM_RC +TSS_ZGen_2Phase_Out_Unmarshal(ZGen_2Phase_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size) +{ + return TSS_ZGen_2Phase_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size); +} +TPM_RC +TSS_EncryptDecrypt_Out_Unmarshal(EncryptDecrypt_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size) +{ + return TSS_EncryptDecrypt_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size); +} +TPM_RC +TSS_EncryptDecrypt2_Out_Unmarshal(EncryptDecrypt2_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size) +{ + return TSS_EncryptDecrypt2_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size); +} +TPM_RC +TSS_Hash_Out_Unmarshal(Hash_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size) +{ + return TSS_Hash_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size); +} +TPM_RC +TSS_HMAC_Out_Unmarshal(HMAC_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size) +{ + return TSS_HMAC_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size); +} +TPM_RC +TSS_GetRandom_Out_Unmarshal(GetRandom_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size) +{ + return TSS_GetRandom_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size); +} +TPM_RC +TSS_HMAC_Start_Out_Unmarshal(HMAC_Start_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size) +{ + return TSS_HMAC_Start_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size); +} +TPM_RC +TSS_HashSequenceStart_Out_Unmarshal(HashSequenceStart_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size) +{ + return TSS_HashSequenceStart_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size); +} +TPM_RC +TSS_SequenceComplete_Out_Unmarshal(SequenceComplete_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size) +{ + return TSS_SequenceComplete_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size); +} +TPM_RC +TSS_EventSequenceComplete_Out_Unmarshal(EventSequenceComplete_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size) +{ + return TSS_EventSequenceComplete_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size); +} +TPM_RC +TSS_Certify_Out_Unmarshal(Certify_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size) +{ + return TSS_Certify_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size); +} +TPM_RC +TSS_CertifyCreation_Out_Unmarshal(CertifyCreation_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size) +{ + return TSS_CertifyCreation_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size); +} +TPM_RC +TSS_Quote_Out_Unmarshal(Quote_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size) +{ + return TSS_Quote_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size); +} +TPM_RC +TSS_GetSessionAuditDigest_Out_Unmarshal(GetSessionAuditDigest_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size) +{ + return TSS_GetSessionAuditDigest_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size); +} +TPM_RC +TSS_GetCommandAuditDigest_Out_Unmarshal(GetCommandAuditDigest_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size) +{ + return TSS_GetCommandAuditDigest_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size); +} +TPM_RC +TSS_GetTime_Out_Unmarshal(GetTime_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size) +{ + return TSS_GetTime_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size); +} +TPM_RC +TSS_Commit_Out_Unmarshal(Commit_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size) +{ + return TSS_Commit_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size); +} +TPM_RC +TSS_EC_Ephemeral_Out_Unmarshal(EC_Ephemeral_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size) +{ + return TSS_EC_Ephemeral_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size); +} +TPM_RC +TSS_VerifySignature_Out_Unmarshal(VerifySignature_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size) +{ + return TSS_VerifySignature_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size); +} +TPM_RC +TSS_Sign_Out_Unmarshal(Sign_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size) +{ + return TSS_Sign_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size); +} +TPM_RC +TSS_PCR_Event_Out_Unmarshal(PCR_Event_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size) +{ + return TSS_PCR_Event_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size); +} +TPM_RC +TSS_PCR_Read_Out_Unmarshal(PCR_Read_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size) +{ + return TSS_PCR_Read_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size); +} +TPM_RC +TSS_PCR_Allocate_Out_Unmarshal(PCR_Allocate_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size) +{ + return TSS_PCR_Allocate_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size); +} +TPM_RC +TSS_PolicySigned_Out_Unmarshal(PolicySigned_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size) +{ + return TSS_PolicySigned_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size); +} +TPM_RC +TSS_PolicySecret_Out_Unmarshal(PolicySecret_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size) +{ + return TSS_PolicySecret_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size); +} +TPM_RC +TSS_PolicyGetDigest_Out_Unmarshal(PolicyGetDigest_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size) +{ + return TSS_PolicyGetDigest_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size); +} +TPM_RC +TSS_CreatePrimary_Out_Unmarshal(CreatePrimary_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size) +{ + return TSS_CreatePrimary_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size); +} +TPM_RC +TSS_ContextSave_Out_Unmarshal(ContextSave_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size) +{ + return TSS_ContextSave_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size); +} +TPM_RC +TSS_ContextLoad_Out_Unmarshal(ContextLoad_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size) +{ + return TSS_ContextLoad_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size); +} +TPM_RC +TSS_ReadClock_Out_Unmarshal(ReadClock_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size) +{ + return TSS_ReadClock_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size); +} +TPM_RC +TSS_GetCapability_Out_Unmarshal(GetCapability_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size) +{ + return TSS_GetCapability_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size); +} +TPM_RC +TSS_NV_ReadPublic_Out_Unmarshal(NV_ReadPublic_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size) +{ + return TSS_NV_ReadPublic_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size); +} +TPM_RC +TSS_NV_Read_Out_Unmarshal(NV_Read_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size) +{ + return TSS_NV_Read_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size); +} +TPM_RC +TSS_NV_Certify_Out_Unmarshal(NV_Certify_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size) +{ + return TSS_NV_Certify_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size); +} + + +#endif /* TPM 2.0 */ diff --git a/libstb/tss2/tssntc.c b/libstb/tss2/tssntc.c new file mode 100644 index 0000000..6e4b210 --- /dev/null +++ b/libstb/tss2/tssntc.c @@ -0,0 +1,128 @@ +/********************************************************************************/ +/* */ +/* TPM2 Nuvoton Proprietary Commands */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: tssntc.c 1285 2018-07-27 18:33:41Z kgoldman $ */ +/* */ +/* (c) Copyright IBM Corporation 2015, 2017 */ +/* */ +/* All rights reserved. */ +/* */ +/* Redistribution and use in source and binary forms, with or without */ +/* modification, are permitted provided that the following conditions are */ +/* met: */ +/* */ +/* Redistributions of source code must retain the above copyright notice, */ +/* this list of conditions and the following disclaimer. */ +/* */ +/* 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. */ +/* */ +/* Neither the names of the IBM Corporation nor the names of its */ +/* contributors may be used to endorse or promote products derived from */ +/* this software without specific prior written permission. */ +/* */ +/* 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. */ +/********************************************************************************/ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include <ibmtss/Unmarshal_fp.h> +#include <ibmtss/tssmarshal.h> +#include <ibmtss/tssprint.h> +#include "tssntc.h" + +/* Marshal and Unmarshal Functions */ + +TPM_RC +TSS_NTC2_CFG_STRUCT_Unmarshalu(NTC2_CFG_STRUCT *target, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + + /* assumes that the NTC2_CFG_STRUCT structure are all uint8_t so that there are no endian + issues */ + if (rc == TPM_RC_SUCCESS) { + rc = TSS_Array_Unmarshalu((BYTE *)target, sizeof(NTC2_CFG_STRUCT), buffer, size); + } + return rc; +} + +TPM_RC +TSS_NTC2_CFG_STRUCT_Marshal(NTC2_CFG_STRUCT *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_Array_Marshalu((BYTE *)source, sizeof(NTC2_CFG_STRUCT), written, buffer, size); + } + return rc; +} + +TPM_RC +TSS_NTC2_PreConfig_In_Unmarshalu(NTC2_PreConfig_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]) +{ + TPM_RC rc = TPM_RC_SUCCESS; + handles = handles; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_NTC2_CFG_STRUCT_Unmarshalu(&target->preConfig, buffer, size); + if (rc != TPM_RC_SUCCESS) { + rc += RC_NTC2_PreConfig_preConfig; + } + } + return rc; +} + +TPM_RC +TSS_NTC2_PreConfig_In_Marshalu(NTC2_PreConfig_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = 0; + if (rc == 0) { + rc = TSS_NTC2_CFG_STRUCT_Marshal(&source->preConfig, written, buffer, size); + } + return rc; +} + +TPM_RC +TSS_NTC2_GetConfig_Out_Unmarshalu(NTC2_GetConfig_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size) +{ + TPM_RC rc = TPM_RC_SUCCESS; + tag = tag; + + if (rc == TPM_RC_SUCCESS) { + rc = TSS_NTC2_CFG_STRUCT_Unmarshalu(&target->preConfig, buffer, size); + } + return rc; +} + +/* These functions are deprecated. They were adapted from the TPM side, but the signed size + caused static analysis tool warnings. */ + +TPM_RC +NTC2_CFG_STRUCT_Unmarshal(NTC2_CFG_STRUCT *target, BYTE **buffer, INT32 *size) +{ + return TSS_NTC2_CFG_STRUCT_Unmarshalu(target, buffer, (uint32_t *)size); +} +TPM_RC +NTC2_PreConfig_In_Unmarshal(NTC2_PreConfig_In *target, BYTE **buffer, INT32 *size, TPM_HANDLE handles[]) +{ + return TSS_NTC2_PreConfig_In_Unmarshalu(target, buffer, (uint32_t *)size, handles); +} +TPM_RC +TSS_NTC2_GetConfig_Out_Unmarshal(NTC2_GetConfig_Out *target, TPM_ST tag, BYTE **buffer, INT32 *size) +{ + return TSS_NTC2_GetConfig_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size); +} diff --git a/libstb/tss2/tssntc.h b/libstb/tss2/tssntc.h new file mode 100644 index 0000000..e5f1a7b --- /dev/null +++ b/libstb/tss2/tssntc.h @@ -0,0 +1,81 @@ +/********************************************************************************/ +/* */ +/* Nuvoton Command Common Routines */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: tssntc.h 1285 2018-07-27 18:33:41Z kgoldman $ */ +/* */ +/* (c) Copyright IBM Corporation 2015 - 2018 */ +/* */ +/* All rights reserved. */ +/* */ +/* Redistribution and use in source and binary forms, with or without */ +/* modification, are permitted provided that the following conditions are */ +/* met: */ +/* */ +/* Redistributions of source code must retain the above copyright notice, */ +/* this list of conditions and the following disclaimer. */ +/* */ +/* 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. */ +/* */ +/* Neither the names of the IBM Corporation nor the names of its */ +/* contributors may be used to endorse or promote products derived from */ +/* this software without specific prior written permission. */ +/* */ +/* 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 TSSNTC2_H +#define TSSNTC2_H + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <stdint.h> + +#include <ibmtss/TPM_Types.h> +#include "Commands_fp.h" + +#ifdef __cplusplus +extern "C" { +#endif + + TPM_RC + TSS_NTC2_CFG_STRUCT_Unmarshalu(NTC2_CFG_STRUCT *target, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_NTC2_CFG_STRUCT_Marshal(NTC2_CFG_STRUCT *source, uint16_t *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_NTC2_PreConfig_In_Unmarshalu(NTC2_PreConfig_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[]); + TPM_RC + TSS_NTC2_PreConfig_In_Marshalu(NTC2_PreConfig_In *source, uint16_t *written, BYTE **buffer, uint32_t *size); + TPM_RC + TSS_NTC2_GetConfig_Out_Unmarshalu(NTC2_GetConfig_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size); + + /* These functions are deprecated. They were adapted from the TPM side, but the signed size + caused static analysis tool warnings. */ + + TPM_RC + NTC2_CFG_STRUCT_Unmarshal(NTC2_CFG_STRUCT *target, BYTE **buffer, INT32 *size); + TPM_RC + NTC2_PreConfig_In_Unmarshal(NTC2_PreConfig_In *target, BYTE **buffer, INT32 *size, TPM_HANDLE handles[]); + TPM_RC + TSS_NTC2_GetConfig_Out_Unmarshal(NTC2_GetConfig_Out *target, TPM_ST tag, BYTE **buffer, INT32 *size); + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libstb/tss2/tssprint.c b/libstb/tss2/tssprint.c new file mode 100644 index 0000000..5d1fbdb --- /dev/null +++ b/libstb/tss2/tssprint.c @@ -0,0 +1,2339 @@ +/********************************************************************************/ +/* */ +/* Structure Print and Scan Utilities */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* */ +/* (c) Copyright IBM Corporation 2015, 2018. */ +/* */ +/* All rights reserved. */ +/* */ +/* Redistribution and use in source and binary forms, with or without */ +/* modification, are permitted provided that the following conditions are */ +/* met: */ +/* */ +/* Redistributions of source code must retain the above copyright notice, */ +/* this list of conditions and the following disclaimer. */ +/* */ +/* 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. */ +/* */ +/* Neither the names of the IBM Corporation nor the names of its */ +/* contributors may be used to endorse or promote products derived from */ +/* this software without specific prior written permission. */ +/* */ +/* 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. */ +/********************************************************************************/ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <inttypes.h> + +#include <ibmtss/Unmarshal_fp.h> +#include <ibmtss/tsserror.h> +#include <ibmtss/tssutils.h> + +#include <ibmtss/tssprint.h> + +extern int tssVerbose; + +#ifdef TPM_TSS_NO_PRINT + +/* false to compile out printf */ +int tssSwallowRc = 0; +/* function prototype to match the printf prototype */ +int TSS_SwallowPrintf(const char *format, ...) +{ + format = format; + return 0; +} + +#endif + +#ifndef TPM_TSS_NOSCAN + +/* TSS_Array_Scan() converts a string to a binary array */ + +uint32_t TSS_Array_Scan(unsigned char **data, /* output binary, freed by caller */ + size_t *len, + const char *string) /* input string */ +{ + uint32_t rc = 0; + size_t strLength; + + if (rc == 0) { + strLength = strlen(string); + if ((strLength %2) != 0) { + if (tssVerbose) printf("TSS_Array_Scan: Error, string length %lu is not even\n", + (unsigned long)strLength); + rc = TSS_RC_BAD_PROPERTY_VALUE; + } + } + if (rc == 0) { + *len = strLength / 2; /* safe because already tested for even number of bytes */ + rc = TSS_Malloc(data, (*len) + 8); + } + if (rc == 0) { + unsigned int i; + for (i = 0 ; i < *len ; i++) { + unsigned int tmpint; + int irc = sscanf(string + (2*i), "%2x", &tmpint); + *((*data)+i) = tmpint; + if (irc != 1) { + if (tssVerbose) printf("TSS_Array_Scan: invalid hexascii\n"); + rc = TSS_RC_BAD_PROPERTY_VALUE; + } + } + } + return rc; +} + +#endif + +/* TSS_PrintAll() prints 'string', the length, and then the entire byte array + */ + +void TSS_PrintAll(const char *string, const unsigned char* buff, uint32_t length) +{ + TSS_PrintAlli(string, 1, buff, length); +} + +/* TSS_PrintAlli() prints 'string', the length, and then the entire byte array + + Each line indented 'indent' spaces. +*/ + +void TSS_PrintAlli(const char *string, unsigned int indent, const unsigned char* buff, uint32_t length) +{ + TSS_PrintAllLogLevel(LOGLEVEL_DEBUG, string, indent, buff, length); +} + +/* TSS_PrintAllLogLevel() prints based on loglevel the 'string', the length, and then the entire + byte array + + loglevel LOGLEVEL_DEBUG prints the length and prints the array with a newline every 16 bytes. + otherwise prints no length and prints the array with no newlines. + +*/ + +void TSS_PrintAllLogLevel(uint32_t loglevel, const char *string, unsigned int __unused indent, + const unsigned char* buff, uint32_t length) +{ + uint32_t i; + uint8_t pr_buf[64]; + uint8_t *b = pr_buf, *eb = &pr_buf[64]; + + if (buff != NULL) { + if (loglevel == LOGLEVEL_DEBUG) { +// printf("%*s" "%s length %u\n" "%*s", indent, "", string, length, indent, ""); + printf("%s length %u\n", string, length); + } + else { +// printf("%*s" "%s" "%*s", indent, "", string, indent, ""); + printf("%s", string); + } + for (i = 0 ; i < length ; i++) { + b += snprintf(b, eb-b, "%.2x ", buff[i]); + if (!((i+1) % 16)) { + printf("%s\n", pr_buf); + b = pr_buf; + } + } + if (b != pr_buf) { + printf("%s\n", pr_buf); + } + } + else { +// printf("%*s" "%s null\n", indent, "", string); + printf("%s null\n", string); + } + return; +} + +#ifdef TPM_TPM20 + +void TSS_TPM2B_Print(const char *string, unsigned int indent, TPM2B *source) +{ + TSS_PrintAlli(string, indent, source->buffer, source->size); + return; +} + +/* Table 9 - Definition of (UINT16) TPM_ALG_ID Constants <IN/OUT, S> */ + +void TSS_TPM_ALG_ID_Print(const char *string, TPM_ALG_ID source, unsigned int __unused indent) +{ +// printf("%*s", indent, ""); + switch (source) { + case ALG_RSA_VALUE: + printf("%s TPM_ALG_RSA\n", string); + break; + case ALG_TDES_VALUE: + printf("%s TPM_ALG_TDES\n", string); + break; + case ALG_SHA1_VALUE: + printf("%s TPM_ALG_SHA1\n", string); + break; + case ALG_HMAC_VALUE: + printf("%s TPM_ALG_HMAC\n", string); + break; + case ALG_AES_VALUE: + printf("%s TPM_ALG_AES\n", string); + break; + case ALG_MGF1_VALUE: + printf("%s TPM_ALG_MGF1\n", string); + break; + case ALG_KEYEDHASH_VALUE: + printf("%s TPM_ALG_KEYEDHASH\n", string); + break; + case ALG_XOR_VALUE: + printf("%s TPM_ALG_XOR\n", string); + break; + case ALG_SHA256_VALUE: + printf("%s TPM_ALG_SHA256\n", string); + break; + case ALG_SHA384_VALUE: + printf("%s TPM_ALG_SHA384\n", string); + break; + case ALG_SHA512_VALUE: + printf("%s TPM_ALG_SHA512\n", string); + break; + case ALG_NULL_VALUE: + printf("%s TPM_ALG_NULL\n", string); + break; + case ALG_SM3_256_VALUE: + printf("%s TPM_ALG_SM3_256\n", string); + break; + case ALG_SM4_VALUE: + printf("%s TPM_ALG_SM4\n", string); + break; + case ALG_RSASSA_VALUE: + printf("%s TPM_ALG_RSASSA\n", string); + break; + case ALG_RSAES_VALUE: + printf("%s TPM_ALG_RSAES\n", string); + break; + case ALG_RSAPSS_VALUE: + printf("%s TPM_ALG_RSAPSS\n", string); + break; + case ALG_OAEP_VALUE: + printf("%s TPM_ALG_OAEP\n", string); + break; + case ALG_ECDSA_VALUE: + printf("%s TPM_ALG_ECDSA\n", string); + break; + case ALG_ECDH_VALUE: + printf("%s TPM_ALG_ECDH\n", string); + break; + case ALG_ECDAA_VALUE: + printf("%s TPM_ALG_ECDAA\n", string); + break; + case ALG_SM2_VALUE: + printf("%s TPM_ALG_SM2\n", string); + break; + case ALG_ECSCHNORR_VALUE: + printf("%s TPM_ALG_ECSCHNORR\n", string); + break; + case ALG_ECMQV_VALUE: + printf("%s TPM_ALG_ECMQV\n", string); + break; + case ALG_KDF1_SP800_56A_VALUE: + printf("%s TPM_ALG_KDF1_SP800_56A\n", string); + break; + case ALG_KDF2_VALUE: + printf("%s TPM_ALG_KDF2\n", string); + break; + case ALG_KDF1_SP800_108_VALUE: + printf("%s TPM_ALG_KDF1_SP800_108\n", string); + break; + case ALG_ECC_VALUE: + printf("%s TPM_ALG_ECC\n", string); + break; + case ALG_SYMCIPHER_VALUE: + printf("%s TPM_ALG_SYMCIPHER\n", string); + break; + case ALG_CAMELLIA_VALUE: + printf("%s TPM_ALG_CAMELLIA\n", string); + break; + case ALG_SHA3_256_VALUE: + printf("%s TPM_ALG_SHA3_256\n", string); + break; + case ALG_SHA3_384_VALUE: + printf("%s TPM_ALG_SHA3_384\n", string); + break; + case ALG_SHA3_512_VALUE: + printf("%s TPM_ALG_SHA3_512\n", string); + break; + case ALG_CMAC_VALUE: + printf("%s TPM_ALG_CMAC\n", string); + break; + case ALG_CTR_VALUE: + printf("%s TPM_ALG_CTR\n", string); + break; + case ALG_OFB_VALUE: + printf("%s TPM_ALG_OFB\n", string); + break; + case ALG_CBC_VALUE: + printf("%s TPM_ALG_CBC\n", string); + break; + case ALG_CFB_VALUE: + printf("%s TPM_ALG_CFB\n", string); + break; + case ALG_ECB_VALUE: + printf("%s TPM_ALG_ECB\n", string); + break; + default: + printf("%s TPM_ALG_ID value %04hx unknown\n", string, source); + } + return; +} + +/* Table 10 - Definition of (UINT16) {ECC} TPM_ECC_CURVE Constants <IN/OUT, S> */ + +void TSS_TPM_ECC_CURVE_Print(const char *string, TPM_ECC_CURVE source, unsigned int indent) +{ + printf("%*s", indent, ""); + switch (source) { + case TPM_ECC_NONE: + printf("%s TPM_ECC_NONE\n", string); + break; + case TPM_ECC_NIST_P192: + printf("%s TPM_ECC_NIST_P192\n", string); + break; + case TPM_ECC_NIST_P224: + printf("%s TPM_ECC_NIST_P224\n", string); + break; + case TPM_ECC_NIST_P256: + printf("%s TPM_ECC_NIST_P256\n", string); + break; + case TPM_ECC_NIST_P384: + printf("%s TPM_ECC_NIST_P384\n", string); + break; + case TPM_ECC_NIST_P521: + printf("%s TPM_ECC_NIST_P521\n", string); + break; + case TPM_ECC_BN_P256: + printf("%s TPM_ECC_BN_P256\n", string); + break; + case TPM_ECC_BN_P638: + printf("%s TPM_ECC_BN_P638\n", string); + break; + case TPM_ECC_SM2_P256: + printf("%s TPM_ECC_SM2_P256\n", string); + break; + default: + printf("%s TPM_ECC_CURVE value %04hx unknown\n", string, source); + } + return; +} + +/* Table 100 - Definition of TPMS_TAGGED_POLICY Structure <OUT> */ + +void TSS_TPMS_TAGGED_POLICY_Print(TPMS_TAGGED_POLICY *source, unsigned int indent) +{ + TSS_TPM_HANDLE_Print("handle", source->handle, indent); + TSS_TPMT_HA_Print(&source->policyHash, indent); + return; +} + +/* Table 12 - Definition of (UINT32) TPM_CC Constants (Numeric Order) <IN/OUT, S> */ + +void TSS_TPM_CC_Print(const char *string, TPM_CC source, unsigned int indent) +{ + printf("%*s", indent, ""); + switch (source) { + case TPM_CC_NV_UndefineSpaceSpecial: + printf("%s TPM_CC_NV_UndefineSpaceSpecial\n", string); + break; + case TPM_CC_EvictControl: + printf("%s TPM_CC_EvictControl\n", string); + break; + case TPM_CC_HierarchyControl: + printf("%s TPM_CC_HierarchyControl\n", string); + break; + case TPM_CC_NV_UndefineSpace: + printf("%s TPM_CC_NV_UndefineSpace\n", string); + break; + case TPM_CC_ChangeEPS: + printf("%s TPM_CC_ChangeEPS\n", string); + break; + case TPM_CC_ChangePPS: + printf("%s TPM_CC_ChangePPS\n", string); + break; + case TPM_CC_Clear: + printf("%s TPM_CC_Clear\n", string); + break; + case TPM_CC_ClearControl: + printf("%s TPM_CC_ClearControl\n", string); + break; + case TPM_CC_ClockSet: + printf("%s TPM_CC_ClockSet\n", string); + break; + case TPM_CC_HierarchyChangeAuth: + printf("%s TPM_CC_HierarchyChangeAuth\n", string); + break; + case TPM_CC_NV_DefineSpace: + printf("%s TPM_CC_NV_DefineSpace\n", string); + break; + case TPM_CC_PCR_Allocate: + printf("%s TPM_CC_PCR_Allocate\n", string); + break; + case TPM_CC_PCR_SetAuthPolicy: + printf("%s TPM_CC_PCR_SetAuthPolicy\n", string); + break; + case TPM_CC_PP_Commands: + printf("%s TPM_CC_PP_Commands\n", string); + break; + case TPM_CC_SetPrimaryPolicy: + printf("%s TPM_CC_SetPrimaryPolicy\n", string); + break; +#if 0 + case TPM_CC_FieldUpgradeStart: + printf("%s TPM_CC_FieldUpgradeStart\n", string); + break; +#endif + case TPM_CC_ClockRateAdjust: + printf("%s TPM_CC_ClockRateAdjust\n", string); + break; + case TPM_CC_CreatePrimary: + printf("%s TPM_CC_CreatePrimary\n", string); + break; + case TPM_CC_NV_GlobalWriteLock: + printf("%s TPM_CC_NV_GlobalWriteLock\n", string); + break; + case TPM_CC_GetCommandAuditDigest: + printf("%s TPM_CC_GetCommandAuditDigest\n", string); + break; + case TPM_CC_NV_Increment: + printf("%s TPM_CC_NV_Increment\n", string); + break; + case TPM_CC_NV_SetBits: + printf("%s TPM_CC_NV_SetBits\n", string); + break; + case TPM_CC_NV_Extend: + printf("%s TPM_CC_NV_Extend\n", string); + break; + case TPM_CC_NV_Write: + printf("%s TPM_CC_NV_Write\n", string); + break; + case TPM_CC_NV_WriteLock: + printf("%s TPM_CC_NV_WriteLock\n", string); + break; + case TPM_CC_DictionaryAttackLockReset: + printf("%s TPM_CC_DictionaryAttackLockReset\n", string); + break; + case TPM_CC_DictionaryAttackParameters: + printf("%s TPM_CC_DictionaryAttackParameters\n", string); + break; + case TPM_CC_NV_ChangeAuth: + printf("%s TPM_CC_NV_ChangeAuth\n", string); + break; + case TPM_CC_PCR_Event: + printf("%s TPM_CC_PCR_Event\n", string); + break; + case TPM_CC_PCR_Reset: + printf("%s TPM_CC_PCR_Reset\n", string); + break; + case TPM_CC_SequenceComplete: + printf("%s TPM_CC_SequenceComplete\n", string); + break; + case TPM_CC_SetAlgorithmSet: + printf("%s TPM_CC_SetAlgorithmSet\n", string); + break; + case TPM_CC_SetCommandCodeAuditStatus: + printf("%s TPM_CC_SetCommandCodeAuditStatus\n", string); + break; +#if 0 + case TPM_CC_FieldUpgradeData: + printf("%s TPM_CC_FieldUpgradeData\n", string); + break; +#endif + case TPM_CC_IncrementalSelfTest: + printf("%s TPM_CC_IncrementalSelfTest\n", string); + break; + case TPM_CC_SelfTest: + printf("%s TPM_CC_SelfTest\n", string); + break; + case TPM_CC_Startup: + printf("%s TPM_CC_Startup\n", string); + break; + case TPM_CC_Shutdown: + printf("%s TPM_CC_Shutdown\n", string); + break; + case TPM_CC_StirRandom: + printf("%s TPM_CC_StirRandom\n", string); + break; + case TPM_CC_ActivateCredential: + printf("%s TPM_CC_ActivateCredential\n", string); + break; + case TPM_CC_Certify: + printf("%s TPM_CC_Certify\n", string); + break; + case TPM_CC_PolicyNV: + printf("%s TPM_CC_PolicyNV\n", string); + break; + case TPM_CC_CertifyCreation: + printf("%s TPM_CC_CertifyCreation\n", string); + break; + case TPM_CC_Duplicate: + printf("%s TPM_CC_Duplicate\n", string); + break; + case TPM_CC_GetTime: + printf("%s TPM_CC_GetTime\n", string); + break; + case TPM_CC_GetSessionAuditDigest: + printf("%s TPM_CC_GetSessionAuditDigest\n", string); + break; + case TPM_CC_NV_Read: + printf("%s TPM_CC_NV_Read\n", string); + break; + case TPM_CC_NV_ReadLock: + printf("%s TPM_CC_NV_ReadLock\n", string); + break; + case TPM_CC_ObjectChangeAuth: + printf("%s TPM_CC_ObjectChangeAuth\n", string); + break; + case TPM_CC_PolicySecret: + printf("%s TPM_CC_PolicySecret\n", string); + break; + case TPM_CC_Rewrap: + printf("%s TPM_CC_Rewrap\n", string); + break; + case TPM_CC_Create: + printf("%s TPM_CC_Create\n", string); + break; + case TPM_CC_ECDH_ZGen: + printf("%s TPM_CC_ECDH_ZGen\n", string); + break; + case TPM_CC_HMAC: + printf("%s TPM_CC_HMAC\n", string); + break; +#if 0 + case TPM_CC_MAC: + printf("%s TPM_CC_MAC\n", string); + break; +#endif + case TPM_CC_Import: + printf("%s TPM_CC_Import\n", string); + break; + case TPM_CC_Load: + printf("%s TPM_CC_Load\n", string); + break; + case TPM_CC_Quote: + printf("%s TPM_CC_Quote\n", string); + break; + case TPM_CC_RSA_Decrypt: + printf("%s TPM_CC_RSA_Decrypt\n", string); + break; + case TPM_CC_HMAC_Start: + printf("%s TPM_CC_HMAC_Start\n", string); + break; +#if 0 + case TPM_CC_MAC_Start: + printf("%s TPM_CC_MAC_Start\n", string); + break; +#endif + case TPM_CC_SequenceUpdate: + printf("%s TPM_CC_SequenceUpdate\n", string); + break; + case TPM_CC_Sign: + printf("%s TPM_CC_Sign\n", string); + break; + case TPM_CC_Unseal: + printf("%s TPM_CC_Unseal\n", string); + break; + case TPM_CC_PolicySigned: + printf("%s TPM_CC_PolicySigned\n", string); + break; + case TPM_CC_ContextLoad: + printf("%s TPM_CC_ContextLoad\n", string); + break; + case TPM_CC_ContextSave: + printf("%s TPM_CC_ContextSave\n", string); + break; + case TPM_CC_ECDH_KeyGen: + printf("%s TPM_CC_ECDH_KeyGen\n", string); + break; + case TPM_CC_EncryptDecrypt: + printf("%s TPM_CC_EncryptDecrypt\n", string); + break; + case TPM_CC_FlushContext: + printf("%s TPM_CC_FlushContext\n", string); + break; + case TPM_CC_LoadExternal: + printf("%s TPM_CC_LoadExternal\n", string); + break; + case TPM_CC_MakeCredential: + printf("%s TPM_CC_MakeCredential\n", string); + break; + case TPM_CC_NV_ReadPublic: + printf("%s TPM_CC_NV_ReadPublic\n", string); + break; + case TPM_CC_PolicyAuthorize: + printf("%s TPM_CC_PolicyAuthorize\n", string); + break; + case TPM_CC_PolicyAuthValue: + printf("%s TPM_CC_PolicyAuthValue\n", string); + break; + case TPM_CC_PolicyCommandCode: + printf("%s TPM_CC_PolicyCommandCode\n", string); + break; + case TPM_CC_PolicyCounterTimer: + printf("%s TPM_CC_PolicyCounterTimer\n", string); + break; + case TPM_CC_PolicyCpHash: + printf("%s TPM_CC_PolicyCpHash\n", string); + break; + case TPM_CC_PolicyLocality: + printf("%s TPM_CC_PolicyLocality\n", string); + break; + case TPM_CC_PolicyNameHash: + printf("%s TPM_CC_PolicyNameHash\n", string); + break; + case TPM_CC_PolicyOR: + printf("%s TPM_CC_PolicyOR\n", string); + break; + case TPM_CC_PolicyTicket: + printf("%s TPM_CC_PolicyTicket\n", string); + break; + case TPM_CC_ReadPublic: + printf("%s TPM_CC_ReadPublic\n", string); + break; + case TPM_CC_RSA_Encrypt: + printf("%s TPM_CC_RSA_Encrypt\n", string); + break; + case TPM_CC_StartAuthSession: + printf("%s TPM_CC_StartAuthSession\n", string); + break; + case TPM_CC_VerifySignature: + printf("%s TPM_CC_VerifySignature\n", string); + break; + case TPM_CC_ECC_Parameters: + printf("%s TPM_CC_ECC_Parameters\n", string); + break; +#if 0 + case TPM_CC_FirmwareRead: + printf("%s TPM_CC_FirmwareRead\n", string); + break; +#endif + case TPM_CC_GetCapability: + printf("%s TPM_CC_GetCapability\n", string); + break; + case TPM_CC_GetRandom: + printf("%s TPM_CC_GetRandom\n", string); + break; + case TPM_CC_GetTestResult: + printf("%s TPM_CC_GetTestResult\n", string); + break; + case TPM_CC_Hash: + printf("%s TPM_CC_Hash\n", string); + break; + case TPM_CC_PCR_Read: + printf("%s TPM_CC_PCR_Read\n", string); + break; + case TPM_CC_PolicyPCR: + printf("%s TPM_CC_PolicyPCR\n", string); + break; + case TPM_CC_PolicyRestart: + printf("%s TPM_CC_PolicyRestart\n", string); + break; + case TPM_CC_ReadClock: + printf("%s TPM_CC_ReadClock\n", string); + break; + case TPM_CC_PCR_Extend: + printf("%s TPM_CC_PCR_Extend\n", string); + break; + case TPM_CC_PCR_SetAuthValue: + printf("%s TPM_CC_PCR_SetAuthValue\n", string); + break; + case TPM_CC_NV_Certify: + printf("%s TPM_CC_NV_Certify\n", string); + break; + case TPM_CC_EventSequenceComplete: + printf("%s TPM_CC_EventSequenceComplete\n", string); + break; + case TPM_CC_HashSequenceStart: + printf("%s TPM_CC_HashSequenceStart\n", string); + break; + case TPM_CC_PolicyPhysicalPresence: + printf("%s TPM_CC_PolicyPhysicalPresence\n", string); + break; + case TPM_CC_PolicyDuplicationSelect: + printf("%s TPM_CC_PolicyDuplicationSelect\n", string); + break; + case TPM_CC_PolicyGetDigest: + printf("%s TPM_CC_PolicyGetDigest\n", string); + break; + case TPM_CC_TestParms: + printf("%s TPM_CC_TestParms\n", string); + break; + case TPM_CC_Commit: + printf("%s TPM_CC_Commit\n", string); + break; + case TPM_CC_PolicyPassword: + printf("%s TPM_CC_PolicyPassword\n", string); + break; + case TPM_CC_ZGen_2Phase: + printf("%s TPM_CC_ZGen_2Phase\n", string); + break; + case TPM_CC_EC_Ephemeral: + printf("%s TPM_CC_EC_Ephemeral\n", string); + break; + case TPM_CC_PolicyNvWritten: + printf("%s TPM_CC_PolicyNvWritten\n", string); + break; + case TPM_CC_PolicyTemplate: + printf("%s TPM_CC_PolicyTemplate\n", string); + break; + case TPM_CC_CreateLoaded: + printf("%s TPM_CC_CreateLoaded\n", string); + break; + case TPM_CC_PolicyAuthorizeNV: + printf("%s TPM_CC_PolicyAuthorizeNV\n", string); + break; + case TPM_CC_EncryptDecrypt2: + printf("%s TPM_CC_EncryptDecrypt2\n", string); + break; +#if 0 + case TPM_CC_AC_GetCapability: + printf("%s TPM_CC_AC_GetCapability\n", string); + break; + case TPM_CC_AC_Send: + printf("%s TPM_CC_AC_Send\n", string); + break; + case TPM_CC_Policy_AC_SendSelect: + printf("%s TPM_CC_Policy_AC_SendSelect\n", string); + break; +#endif + default: + printf("%s TPM_CC value %08x unknown\n", string, source); + } + return; +} + +/* Table 17 - Definition of (INT8) TPM_CLOCK_ADJUST Constants <IN> */ + +void TSS_TPM_CLOCK_ADJUST_Print(const char *string, TPM_CLOCK_ADJUST source, unsigned int indent) +{ + printf("%*s", indent, ""); + switch (source) { + case TPM_CLOCK_COARSE_SLOWER: + printf("%s TPM_CLOCK_COARSE_SLOWER\n", string); + break; + case TPM_CLOCK_MEDIUM_SLOWER: + printf("%s TPM_CLOCK_MEDIUM_SLOWER\n", string); + break; + case TPM_CLOCK_FINE_SLOWER: + printf("%s TPM_CLOCK_FINE_SLOWER\n", string); + break; + case TPM_CLOCK_NO_CHANGE: + printf("%s TPM_CLOCK_NO_CHANGE\n", string); + break; + case TPM_CLOCK_FINE_FASTER: + printf("%s TPM_CLOCK_FINE_FASTER\n", string); + break; + case TPM_CLOCK_MEDIUM_FASTER: + printf("%s TPM_CLOCK_MEDIUM_FASTER\n", string); + break; + case TPM_CLOCK_COARSE_FASTER: + printf("%s TPM_CLOCK_COARSE_FASTER\n", string); + break; + default: + printf("%s TPM_CLOCK_ADJUST value %d unknown\n", string, source); + } + return; +} + +/* Table 18 - Definition of (UINT16) TPM_EO Constants <IN/OUT> */ + +void TSS_TPM_EO_Print(const char *string, TPM_EO source, unsigned int indent) +{ + printf("%*s", indent, ""); + switch (source) { + case TPM_EO_EQ: + printf("%s TPM_EO_EQ\n", string); + break; + case TPM_EO_NEQ: + printf("%s TPM_EO_NEQ\n", string); + break; + case TPM_EO_SIGNED_GT: + printf("%s TPM_EO_SIGNED_GT\n", string); + break; + case TPM_EO_UNSIGNED_GT: + printf("%s TPM_EO_UNSIGNED_GT\n", string); + break; + case TPM_EO_SIGNED_LT: + printf("%s TPM_EO_SIGNED_LT\n", string); + break; + case TPM_EO_UNSIGNED_LT: + printf("%s TPM_EO_UNSIGNED_LT\n", string); + break; + case TPM_EO_SIGNED_GE: + printf("%s TPM_EO_SIGNED_GE\n", string); + break; + case TPM_EO_UNSIGNED_GE: + printf("%s TPM_EO_UNSIGNED_GE\n", string); + break; + case TPM_EO_SIGNED_LE: + printf("%s TPM_EO_SIGNED_LE\n", string); + break; + case TPM_EO_UNSIGNED_LE: + printf("%s TPM_EO_UNSIGNED_LE\n", string); + break; + case TPM_EO_BITSET: + printf("%s TPM_EO_BITSET\n", string); + break; + case TPM_EO_BITCLEAR: + printf("%s TPM_EO_BITCLEAR\n", string); + break; + default: + printf("%s TPM_EO value %04hx unknown\n", string, source); + } + return; +} + +/* Table 19 - Definition of (UINT16) TPM_ST Constants <IN/OUT, S> */ + +void TSS_TPM_ST_Print(const char *string, TPM_ST source, unsigned int indent) +{ + printf("%*s", indent, ""); + switch (source) { + case TPM_ST_RSP_COMMAND: + printf("%s TPM_ST_RSP_COMMAND\n", string); + break; + case TPM_ST_NULL: + printf("%s TPM_ST_NULL\n", string); + break; + case TPM_ST_NO_SESSIONS: + printf("%s TPM_ST_NO_SESSIONS\n", string); + break; + case TPM_ST_SESSIONS: + printf("%s TPM_ST_SESSIONS\n", string); + break; + case TPM_ST_ATTEST_NV: + printf("%s TPM_ST_ATTEST_NV\n", string); + break; + case TPM_ST_ATTEST_COMMAND_AUDIT: + printf("%s TPM_ST_ATTEST_COMMAND_AUDIT\n", string); + break; + case TPM_ST_ATTEST_SESSION_AUDIT: + printf("%s TPM_ST_ATTEST_SESSION_AUDIT\n", string); + break; + case TPM_ST_ATTEST_CERTIFY: + printf("%s TPM_ST_ATTEST_CERTIFY\n", string); + break; + case TPM_ST_ATTEST_QUOTE: + printf("%s TPM_ST_ATTEST_QUOTE\n", string); + break; + case TPM_ST_ATTEST_TIME: + printf("%s TPM_ST_ATTEST_TIME\n", string); + break; + case TPM_ST_ATTEST_CREATION: + printf("%s TPM_ST_ATTEST_CREATION\n", string); + break; + case TPM_ST_CREATION: + printf("%s TPM_ST_CREATION\n", string); + break; + case TPM_ST_VERIFIED: + printf("%s TPM_ST_VERIFIED\n", string); + break; + case TPM_ST_AUTH_SECRET: + printf("%s TPM_ST_AUTH_SECRET\n", string); + break; + case TPM_ST_HASHCHECK: + printf("%s TPM_ST_HASHCHECK\n", string); + break; + case TPM_ST_AUTH_SIGNED: + printf("%s TPM_ST_AUTH_SIGNED\n", string); + break; + default: + printf("%s TPM_ST value %04hx unknown\n", string, source); + } + return; +} + +/* Table 20 - Definition of (UINT16) TPM_SU Constants <IN> */ + +void TSS_TPM_SU_Print(const char *string, TPM_SU source, unsigned int indent) +{ + printf("%*s", indent, ""); + switch (source) { + case TPM_SU_CLEAR: + printf("%s TPM_SU_CLEAR\n", string); + break; + case TPM_SU_STATE: + printf("%s TPM_SU_STATE\n", string); + break; + default: + printf("%s TPM_SU value %04hx unknown\n", string, source); + } + return; +} + +/* Table 21 - Definition of (UINT8) TPM_SE Constants <IN> */ + +void TSS_TPM_SE_Print(const char *string, TPM_SE source, unsigned int __unused indent) +{ +// printf("%*s", indent, ""); + switch (source) { + case TPM_SE_HMAC: + printf("%s TPM_SE_HMAC\n", string); + break; + case TPM_SE_POLICY: + printf("%s TPM_SE_POLICY\n", string); + break; + case TPM_SE_TRIAL: + printf("%s TPM_SE_TRIAL\n", string); + break; + default: + printf("%s TPM_SE value %02x unknown\n", string, source); + } + return; +} + +/* Table 22 - Definition of (UINT32) TPM_CAP Constants */ + +void TSS_TPM_CAP_Print(const char *string, TPM_CAP source, unsigned int indent) +{ + printf("%*s", indent, ""); + switch (source) { + case TPM_CAP_ALGS: + printf("%s TPM_CAP_ALGS\n", string); + break; + case TPM_CAP_HANDLES: + printf("%s TPM_CAP_HANDLES\n", string); + break; + case TPM_CAP_COMMANDS: + printf("%s TPM_CAP_COMMANDS\n", string); + break; + case TPM_CAP_PP_COMMANDS: + printf("%s TPM_CAP_PP_COMMANDS\n", string); + break; + case TPM_CAP_AUDIT_COMMANDS: + printf("%s TPM_CAP_AUDIT_COMMANDS\n", string); + break; + case TPM_CAP_PCRS: + printf("%s TPM_CAP_PCRS\n", string); + break; + case TPM_CAP_TPM_PROPERTIES: + printf("%s TPM_CAP_TPM_PROPERTIES\n", string); + break; + case TPM_CAP_PCR_PROPERTIES: + printf("%s TPM_CAP_PCR_PROPERTIES\n", string); + break; + case TPM_CAP_ECC_CURVES: + printf("%s TPM_CAP_ECC_CURVES\n", string); + break; + case TPM_CAP_AUTH_POLICIES: + printf("%s TPM_CAP_AUTH_POLICIES\n", string); + break; + case TPM_CAP_VENDOR_PROPERTY: + printf("%s TPM_CAP_VENDOR_PROPERTY\n", string); + break; + default: + printf("%s TPM_CAP value %08x unknown\n", string, source); + } + return; +} + +/* Table 26 - Definition of Types for Handles */ + +void TSS_TPM_HANDLE_Print(const char *string, TPM_HANDLE source, unsigned int __unused indent) +{ + // printf("%*s", indent, ""); + switch (source) { + case TPM_RH_SRK: + printf("%s TPM_RH_SRK\n", string); + break; + case TPM_RH_OWNER: + printf("%s TPM_RH_OWNER\n", string); + break; + case TPM_RH_REVOKE: + printf("%s TPM_RH_REVOKE\n", string); + break; + case TPM_RH_TRANSPORT: + printf("%s TPM_RH_TRANSPORT\n", string); + break; + case TPM_RH_OPERATOR: + printf("%s TPM_RH_OPERATOR\n", string); + break; + case TPM_RH_ADMIN: + printf("%s TPM_RH_ADMIN\n", string); + break; + case TPM_RH_EK: + printf("%s TPM_RH_EK\n", string); + break; + case TPM_RH_NULL: + printf("%s TPM_RH_NULL\n", string); + break; + case TPM_RH_UNASSIGNED: + printf("%s TPM_RH_UNASSIGNED\n", string); + break; + case TPM_RS_PW: + printf("%s TPM_RS_PW\n", string); + break; + case TPM_RH_LOCKOUT: + printf("%s TPM_RH_LOCKOUT\n", string); + break; + case TPM_RH_ENDORSEMENT: + printf("%s TPM_RH_ENDORSEMENT\n", string); + break; + case TPM_RH_PLATFORM: + printf("%s TPM_RH_PLATFORM\n", string); + break; + case TPM_RH_PLATFORM_NV: + printf("%s TPM_RH_PLATFORM_NV\n", string); + break; + default: + printf("%s TPM_HANDLE %08x\n", string, source); + } + return; +} + +/* Table 30 - Definition of (UINT32) TPMA_ALGORITHM Bits */ + +void TSS_TPM_TPMA_ALGORITHM_Print(TPMA_ALGORITHM source, unsigned int indent) +{ + if (source.val & TPMA_ALGORITHM_ASYMMETRIC) printf("%*s" "TPMA_ALGORITHM: asymmetric\n", indent, ""); + if (source.val & TPMA_ALGORITHM_SYMMETRIC) printf("%*s" "TPMA_ALGORITHM: symmetric\n", indent, ""); + if (source.val & TPMA_ALGORITHM_HASH) printf("%*s" "TPMA_ALGORITHM: hash\n", indent, ""); + if (source.val & TPMA_ALGORITHM_OBJECT) printf("%*s" "TPMA_ALGORITHM: object\n", indent, ""); + if (source.val & TPMA_ALGORITHM_SIGNING) printf("%*s" "TPMA_ALGORITHM: signing\n", indent, ""); + if (source.val & TPMA_ALGORITHM_ENCRYPTING) printf("%*s" "TPMA_ALGORITHM: encrypting\n", indent, ""); + if (source.val & TPMA_ALGORITHM_METHOD) printf("%*s" "TPMA_ALGORITHM: method\n", indent, ""); + return; +} + +/* Table 31 - Definition of (UINT32) TPMA_OBJECT Bits */ + +void TSS_TPMA_OBJECT_Print(const char *string, TPMA_OBJECT source, unsigned int indent) +{ + if (source.val & TPMA_OBJECT_FIXEDTPM) printf("%*s%s: fixedTpm\n", indent, "", string); + if (source.val & TPMA_OBJECT_STCLEAR) printf("%*s%s: stClear\n", indent, "", string); + if (source.val & TPMA_OBJECT_FIXEDPARENT) printf("%*s%s: fixedParent\n", indent, "", string); + if (source.val & TPMA_OBJECT_SENSITIVEDATAORIGIN) printf("%*s%s: sensitiveDataOrigin\n", indent, "", string); + if (source.val & TPMA_OBJECT_USERWITHAUTH) printf("%*s%s: userWithAuth\n", indent, "", string); + if (source.val & TPMA_OBJECT_ADMINWITHPOLICY) printf("%*s%s: adminWithPolicy\n", indent, "", string); + if (source.val & TPMA_OBJECT_NODA) printf("%*s%s: noDA\n", indent, "", string); + if (source.val & TPMA_OBJECT_ENCRYPTEDDUPLICATION) printf("%*s%s: encryptedDuplication\n", indent, "", string); + if (source.val & TPMA_OBJECT_RESTRICTED) printf("%*s%s: restricted\n", indent, "", string); + if (source.val & TPMA_OBJECT_DECRYPT) printf("%*s%s: decrypt\n", indent, "", string); + if (source.val & TPMA_OBJECT_SIGN) printf("%*s%s: sign\n", indent, "", string); + return; +} + +/* Table 32 - Definition of (UINT8) TPMA_SESSION Bits <IN/OUT> */ + +void TSS_TPMA_SESSION_Print(TPMA_SESSION source, unsigned int indent) +{ + + if (source.val & TPMA_SESSION_CONTINUESESSION) printf("%*s" "TPMA_SESSION: continue\n", indent, ""); + if (source.val & TPMA_SESSION_AUDITEXCLUSIVE) printf("%*s" "TPMA_SESSION: auditexclusive\n", indent, ""); + if (source.val & TPMA_SESSION_AUDITRESET) printf("%*s" "TPMA_SESSION: auditreset\n", indent, ""); + if (source.val & TPMA_SESSION_DECRYPT) printf("%*s" "TPMA_SESSION: decrypt\n", indent, ""); + if (source.val & TPMA_SESSION_ENCRYPT) printf("%*s" "TPMA_SESSION: encrypt\n", indent, ""); + if (source.val & TPMA_SESSION_AUDIT) printf("%*s" "TPMA_SESSION: audit\n", indent, ""); + return; +} + +/* Table 33 - Definition of (UINT8) TPMA_LOCALITY Bits <IN/OUT> */ + +void TSS_TPMA_LOCALITY_Print(TPMA_LOCALITY source, unsigned int indent) +{ + if (source.val & TPMA_LOCALITY_ZERO) printf("%*s" "TPMA_LOCALITY: zero\n", indent, ""); + if (source.val & TPMA_LOCALITY_ONE) printf("%*s" "TPMA_LOCALITY: one\n", indent, ""); + if (source.val & TPMA_LOCALITY_TWO) printf("%*s" "TPMA_LOCALITY: two\n", indent, ""); + if (source.val & TPMA_LOCALITY_THREE) printf("%*s" "TPMA_LOCALITY: three\n", indent, ""); + if (source.val & TPMA_LOCALITY_FOUR) printf("%*s" "TPMA_LOCALITY: four\n", indent, ""); + if (source.val & TPMA_LOCALITY_EXTENDED) printf("%*s" "TPMA_LOCALITY: extended\n", indent, ""); + return; +} + +/* Table 34 - Definition of (UINT32) TPMA_PERMANENT Bits <OUT> */ + +void TSS_TPMA_PERMANENT_Print(TPMA_PERMANENT source, unsigned int indent) +{ + printf("%*s" "TPMA_PERMANENT: ownerAuthSet %s\n", indent, "", + (source.val & TPMA_PERMANENT_OWNERAUTHSET) ? "yes" : "no"); + printf("%*s" "TPMA_PERMANENT: endorsementAuthSet %s\n", indent, "", + (source.val & TPMA_PERMANENT_ENDORSEMENTAUTHSET) ? "yes" : "no"); + printf("%*s" "TPMA_PERMANENT: lockoutAuthSet %s\n", indent, "", + (source.val & TPMA_PERMANENT_LOCKOUTAUTHSET) ? "yes" : "no"); + printf("%*s" "TPMA_PERMANENT: disableClear %s\n", indent, "", + (source.val & TPMA_PERMANENT_DISABLECLEAR) ? "yes" : "no"); + printf("%*s" "TPMA_PERMANENT: inLockout %s\n", indent, "", + (source.val & TPMA_PERMANENT_INLOCKOUT) ? "yes" : "no"); + printf("%*s" "TPMA_PERMANENT: tpmGeneratedEPS %s\n", indent, "", + (source.val & TPMA_PERMANENT_TPMGENERATEDEPS) ? "yes" : "no"); + return; +} + +/* Table 35 - Definition of (UINT32) TPMA_STARTUP_CLEAR Bits <OUT> */ + +void TSS_TPMA_STARTUP_CLEAR_Print(TPMA_STARTUP_CLEAR source, unsigned int indent) +{ + printf("%*s" "TPMA_STARTUP_CLEAR: phEnable %s\n", indent, "", + (source.val & TPMA_STARTUP_CLEAR_PHENABLE) ? "yes" : "no"); + printf("%*s" "TPMA_STARTUP_CLEAR: shEnable %s\n", indent, "", + (source.val & TPMA_STARTUP_CLEAR_SHENABLE) ? "yes" : "no"); + printf("%*s" "TPMA_STARTUP_CLEAR: ehEnable %s\n", indent, "", + (source.val & TPMA_STARTUP_CLEAR_EHENABLE) ? "yes" : "no"); + printf("%*s" "TPMA_STARTUP_CLEAR: phEnableNV %s\n", indent, "", + (source.val & TPMA_STARTUP_CLEAR_PHENABLENV) ? "yes" : "no"); + printf("%*s" "TPMA_STARTUP_CLEAR: orderly %s\n", indent, "", + (source.val & TPMA_STARTUP_CLEAR_ORDERLY) ? "yes" : "no"); + return; +} + +/* Table 36 - Definition of (UINT32) TPMA_MEMORY Bits <Out> */ + +void TSS_TPMA_MEMORY_Print(TPMA_MEMORY source, unsigned int indent) +{ + printf("%*s" "TPMA_MEMORY: sharedRAM %s\n", indent, "", + (source.val & TPMA_MEMORY_SHAREDRAM) ? "yes" : "no"); + printf("%*s" "TPMA_MEMORY: sharedNV %s\n", indent, "", + (source.val & TPMA_MEMORY_SHAREDNV) ? "yes" : "no"); + printf("%*s" "TPMA_MEMORY: objectCopiedToRam %s\n", indent, "", + (source.val & TPMA_MEMORY_OBJECTCOPIEDTORAM) ? "yes" : "no"); + return; +} + +/* Table 38 - Definition of (UINT32) TPMA_MODES Bits <Out> */ + +void TSS_TPMA_MODES_Print(TPMA_MODES source, unsigned int indent) +{ + printf("%*s" "TPMA_MODES: TPMA_MODES_FIPS_140_2 %s\n", indent, "", + (source.val & TPMA_MODES_FIPS_140_2) ? "yes" : "no"); + return; +} + +/* Table 39 - Definition of (BYTE) TPMI_YES_NO Type */ + +void TSS_TPMI_YES_NO_Print(const char *string, TPMI_YES_NO source, unsigned int indent) +{ + printf("%*s", indent, ""); + switch (source) { + case NO: + printf("%s no\n", string); + break; + case YES: + printf("%s yes\n", string); + break; + default: + printf("%s TPMI_YES_NO %02x unknown\n", string, source); + } + return; +} + +/* Table 75 - Definition of TPMU_HA Union <IN/OUT, S> */ + + +void TSS_TPMU_HA_Print(TPMU_HA *source, uint32_t selector, unsigned int indent) +{ + switch (selector) { +#ifdef TPM_ALG_SHA1 + case TPM_ALG_SHA1: + TSS_PrintAlli("sha1", indent, source->sha1, SHA1_DIGEST_SIZE); + break; +#endif +#ifdef TPM_ALG_SHA256 + case TPM_ALG_SHA256: + TSS_PrintAlli("sha256", indent, source->sha256, SHA256_DIGEST_SIZE); + break; +#endif +#ifdef TPM_ALG_SHA384 + case TPM_ALG_SHA384: + TSS_PrintAlli("sha384", indent, source->sha384, SHA384_DIGEST_SIZE); + break; +#endif +#ifdef TPM_ALG_SHA512 + case TPM_ALG_SHA512: + TSS_PrintAlli("sha512", indent, source->sha512, SHA512_DIGEST_SIZE); + break; +#endif +#ifdef TPM_ALG_SM3_256 + case TPM_ALG_SM3_256: + TSS_PrintAlli("sm3_256", indent, source->sm3_256, SM3_256_DIGEST_SIZE); + break; +#endif + case TPM_ALG_NULL: + break; + default: + printf("%*s" "TPMU_HA: selection %08x not implemented\n", indent, "", selector); + } + return; +} + +/* Table 76 - Definition of TPMT_HA Structure <IN/OUT> */ + +void TSS_TPMT_HA_Print(TPMT_HA *source, unsigned int indent) +{ + TSS_TPM_ALG_ID_Print("hashAlg", source->hashAlg, indent+2); + TSS_TPMU_HA_Print(&source->digest, source->hashAlg, indent+2); + return; +} + +/* Table 89 - Definition of TPMS_PCR_SELECT Structure */ + +void TSS_TPMS_PCR_SELECT_Print(TPMS_PCR_SELECT *source, unsigned int indent) +{ + printf("%*s" "TSS_TPMS_PCR_SELECT sizeofSelect %u\n", indent, "", source->sizeofSelect); + TSS_PrintAlli("pcrSelect", indent, source->pcrSelect, source->sizeofSelect); + return; +} + +/* Table 90 - Definition of TPMS_PCR_SELECTION Structure */ + +void TSS_TPMS_PCR_SELECTION_Print(TPMS_PCR_SELECTION *source, unsigned int indent) +{ + TSS_TPM_ALG_ID_Print("hash", source->hash, indent+2); + TSS_PrintAlli("TPMS_PCR_SELECTION", indent+2, + source->pcrSelect, + source->sizeofSelect); + return; +} + +/* Table 93 - Definition of TPMT_TK_CREATION Structure */ + +void TSS_TPMT_TK_CREATION_Print(TPMT_TK_CREATION *source, unsigned int indent) +{ + TSS_TPM_ST_Print("tag", source->tag, indent); + TSS_TPM_HANDLE_Print("hierarchy", source->hierarchy, indent); + TSS_TPM2B_Print("TPMT_TK_CREATION digest", indent, &source->digest.b); + return; +} + +/* Table 94 - Definition of TPMT_TK_VERIFIED Structure */ + +void TSS_TPMT_TK_VERIFIED_Print(TPMT_TK_VERIFIED *source, unsigned int indent) +{ + TSS_TPM_ST_Print("tag", source->tag, indent); + TSS_TPM_HANDLE_Print("hierarchy", source->hierarchy, indent); + TSS_TPM2B_Print("TPMT_TK_VERIFIED digest", indent, &source->digest.b); + return; +} + +/* Table 95 - Definition of TPMT_TK_AUTH Structure */ + +void TSS_TPMT_TK_AUTH_Print(TPMT_TK_AUTH *source, unsigned int indent) +{ + TSS_TPM_ST_Print("tag", source->tag, indent); + TSS_TPM_HANDLE_Print("hierarchy", source->hierarchy, indent); + TSS_TPM2B_Print("TPMT_TK_AUTH digest", indent, &source->digest.b); + return; +} + +/* Table 96 - Definition of TPMT_TK_HASHCHECK Structure */ + +void TSS_TPMT_TK_HASHCHECK_Print(TPMT_TK_HASHCHECK *source, unsigned int indent) +{ + TSS_TPM_ST_Print("tag", source->tag, indent); + TSS_TPM_HANDLE_Print("hierarchy", source->hierarchy, indent); + TSS_TPM2B_Print("TPMT_TK_AUTH digest", indent, &source->digest.b); + return; +} + +/* Table 101 - Definition of TPML_CC Structure */ + +void TSS_TPML_CC_Print(TPML_CC *source, unsigned int indent) +{ + uint32_t i; + printf("%*s" "TPML_CC count %u\n", indent, "", source->count); + for (i = 0 ; (i < source->count) ; i++) { + TSS_TPM_CC_Print("commandCode", source->commandCodes[i], indent); + } + return; +} + +/* Table 102 - Definition of TPML_PCR_SELECTION Structure */ + +void TSS_TPML_PCR_SELECTION_Print(TPML_PCR_SELECTION *source, unsigned int indent) +{ + uint32_t i; + printf("%*s" "TPML_PCR_SELECTION count %u\n", indent, "", source->count); + for (i = 0 ; (i < source->count) ; i++) { + TSS_TPMS_PCR_SELECTION_Print(&source->pcrSelections[i], indent); + } + return; +} + +/* Table 103 - Definition of TPML_ALG Structure */ + +void TSS_TPML_ALG_Print(TPML_ALG *source, unsigned int indent) +{ + uint32_t i; + printf("%*s" "TPML_ALG count %u\n", indent, "", source->count); + for (i = 0 ; (i < source->count) ; i++) { + TSS_TPM_ALG_ID_Print("algorithms", source->algorithms[i], indent); + } + return; +} + +/* Table 105 - Definition of TPML_DIGEST Structure */ + +void TSS_TPML_DIGEST_Print(TPML_DIGEST *source, unsigned int indent) +{ + uint32_t i; + printf("%*s" "TPML_DIGEST count %u\n", indent, "", source->count); + for (i = 0 ; (i < source->count) ; i++) { + TSS_TPM2B_Print("TPML_DIGEST digest", indent, &source->digests[i].b); + } + return; +} + +/* Table 106 - Definition of TPML_DIGEST_VALUES Structure */ + +void TSS_TPML_DIGEST_VALUES_Print(TPML_DIGEST_VALUES *source, unsigned int indent) +{ + uint32_t i; + printf("%*s" "TPML_DIGEST_VALUES count %u\n", indent, "", source->count); + for (i = 0 ; (i < source->count) ; i++) { + TSS_TPMT_HA_Print(&source->digests[i], indent); + } + return; +} + +/* Table 115 - Definition of TPMS_CLOCK_INFO Structure */ + +void TSS_TPMS_CLOCK_INFO_Print(TPMS_CLOCK_INFO *source, unsigned int indent) +{ + printf("%*s" "TPMS_CLOCK_INFO clock %"PRIu64"\n", indent, "", source->clock); + printf("%*s" "TPMS_CLOCK_INFO resetCount %u\n", indent, "", source->resetCount); + printf("%*s" "TPMS_CLOCK_INFO restartCount %u\n", indent, "", source->restartCount); + printf("%*s" "TPMS_CLOCK_INFO safe %x\n", indent, "", source->safe); + return; +} + +/* Table 116 - Definition of TPMS_TIME_INFO Structure */ + +void TSS_TPMS_TIME_INFO_Print(TPMS_TIME_INFO *source, unsigned int indent) +{ + uint64_t days; + uint64_t hours; + uint64_t minutes; + uint64_t seconds; + printf("%*s" "TPMS_TIME_INFO time %"PRIu64" msec", indent, "", source->time); + days = source->time/(1000 * 60 * 60 * 24); + hours = (source->time % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60); + minutes = (source->time % (1000 * 60 * 60)) / (1000 * 60); + seconds = (source->time % (1000 * 60)) / (1000); + printf(" - %"PRIu64" days %"PRIu64" hours %"PRIu64" minutes %"PRIu64" seconds\n", + days, hours, minutes, seconds); + TSS_TPMS_CLOCK_INFO_Print(&source->clockInfo, indent+2); + return; +} + +/* Table 117 - Definition of TPMS_TIME_ATTEST_INFO Structure <OUT> */ + +void TSS_TPMS_TIME_ATTEST_INFO_Print(TPMS_TIME_ATTEST_INFO *source, unsigned int indent) +{ + TSS_TPMS_TIME_INFO_Print(&source->time, indent+2); + printf("%*s" "TPMS_TIME_ATTEST_INFO firmwareVersion %"PRIu64"\n", indent, "", source->firmwareVersion); + return; +} + +/* Table 118 - Definition of TPMS_CERTIFY_INFO Structure <OUT> */ + +void TSS_TPMS_CERTIFY_INFO_Print(TPMS_CERTIFY_INFO *source, unsigned int indent) +{ + TSS_TPM2B_Print("TPMS_CERTIFY_INFO name", indent, &source->name.b); + TSS_TPM2B_Print("TPMS_CERTIFY_INFO qualifiedName", indent, &source->qualifiedName.b); + return; +} + +/* Table 119 - Definition of TPMS_QUOTE_INFO Structure <OUT> */ + +void TSS_TPMS_QUOTE_INFO_Print(TPMS_QUOTE_INFO *source, unsigned int indent) +{ + TSS_TPML_PCR_SELECTION_Print(&source->pcrSelect, indent+2); + TSS_TPM2B_Print("TPMS_QUOTE_INFO pcrDigest", indent+2, &source->pcrDigest.b); + return; +} + +/* Table 120 - Definition of TPMS_COMMAND_AUDIT_INFO Structure <OUT> */ + +void TSS_TPMS_COMMAND_AUDIT_INFO_Print(TPMS_COMMAND_AUDIT_INFO *source, unsigned int indent) +{ + printf("%*s" "TPMS_COMMAND_AUDIT_INFO auditCounter %"PRIu64"\n", indent, "", source->auditCounter); + TSS_TPM_ALG_ID_Print("digestAlg", source->digestAlg, indent); + TSS_TPM2B_Print("TPMS_COMMAND_AUDIT_INFO auditDigest", indent, &source->auditDigest.b); + TSS_TPM2B_Print("TPMS_COMMAND_AUDIT_INFO commandDigest", indent, &source->commandDigest.b); + return; +} + +/* Table 121 - Definition of TPMS_SESSION_AUDIT_INFO Structure */ + +void TSS_TPMS_SESSION_AUDIT_INFO_Print(TPMS_SESSION_AUDIT_INFO *source, unsigned int indent) +{ + printf("%*s" "TPMS_SESSION_AUDIT_INFO exclusiveSession %d\n", indent, "", + source->exclusiveSession); + TSS_TPM2B_Print("TPMS_SESSION_AUDIT_INFO sessionDigest", indent, &source->sessionDigest.b); + return; +} + +/* Table 122 - Definition of TPMS_CREATION_INFO Structure <OUT> */ + +void TSS_TPMS_CREATION_INFO_Print(TPMS_CREATION_INFO *source, unsigned int indent) +{ + TSS_TPM2B_Print("TPMS_CREATION_INFO objectName", indent, &source->objectName.b); + TSS_TPM2B_Print("TPMS_CREATION_INFO creationHash", indent, &source->creationHash.b); + return; +} + +/* Table 123 - Definition of TPMS_NV_CERTIFY_INFO Structure */ + +void TSS_TPMS_NV_CERTIFY_INFO_Print(TPMS_NV_CERTIFY_INFO *source, unsigned int indent) +{ + TSS_TPM2B_Print("TPMS_NV_CERTIFY_INFO indexName", indent, &source->indexName.b); + printf("%*s" "TPMS_NV_CERTIFY_INFO offset %d\n", indent, "", source->offset); + TSS_TPM2B_Print("TPMS_NV_CERTIFY_INFO nvContents", indent, &source->nvContents.b); + return; +} + +/* Table 124 - Definition of (TPM_ST) TPMI_ST_ATTEST Type <OUT> */ + +void TSS_TPMI_ST_ATTEST_Print(const char *string, TPMI_ST_ATTEST selector, unsigned int indent) +{ + printf("%*s", indent, ""); + switch (selector) { + case TPM_ST_ATTEST_CERTIFY: + printf("%s TPM_ST_ATTEST_CERTIFY\n", string); + break; + case TPM_ST_ATTEST_CREATION: + printf("%s TPM_ST_ATTEST_CREATION\n", string); + break; + case TPM_ST_ATTEST_QUOTE: + printf("%s TPM_ST_ATTEST_QUOTE\n", string); + break; + case TPM_ST_ATTEST_COMMAND_AUDIT: + printf("%s TPM_ST_ATTEST_COMMAND_AUDIT\n", string); + break; + case TPM_ST_ATTEST_SESSION_AUDIT: + printf("%s TPM_ST_ATTEST_SESSION_AUDIT\n", string); + break; + case TPM_ST_ATTEST_TIME: + printf("%s TPM_ST_ATTEST_TIME\n", string); + break; + case TPM_ST_ATTEST_NV: + printf("%s TPM_ST_ATTEST_NV\n", string); + break; + default: + printf("%s TPMI_ST_ATTEST_Print: selection %04hx not implemented\n", string, selector); + } + return; +} + +/* Table 125 - Definition of TPMU_ATTEST Union <OUT> */ + +void TSS_TPMU_ATTEST_Print(TPMU_ATTEST *source, TPMI_ST_ATTEST selector, unsigned int indent) +{ + switch (selector) { + case TPM_ST_ATTEST_CERTIFY: + TSS_TPMS_CERTIFY_INFO_Print(&source->certify, indent+2); + break; + case TPM_ST_ATTEST_CREATION: + TSS_TPMS_CREATION_INFO_Print(&source->creation, indent+2); + break; + case TPM_ST_ATTEST_QUOTE: + TSS_TPMS_QUOTE_INFO_Print(&source->quote, indent+2); + break; + case TPM_ST_ATTEST_COMMAND_AUDIT: + TSS_TPMS_COMMAND_AUDIT_INFO_Print(&source->commandAudit, indent+2); + break; + case TPM_ST_ATTEST_SESSION_AUDIT: + TSS_TPMS_SESSION_AUDIT_INFO_Print(&source->sessionAudit, indent+2); + break; + case TPM_ST_ATTEST_TIME: + TSS_TPMS_TIME_ATTEST_INFO_Print(&source->time, indent+2); + break; + case TPM_ST_ATTEST_NV: + TSS_TPMS_NV_CERTIFY_INFO_Print(&source->nv, indent+2); + break; + default: + printf("%*s" "TPMU_ATTEST selection %04hx not implemented\n", indent, "", selector); + } + return; +} + +/* Table 126 - Definition of TPMS_ATTEST Structure <OUT> */ + +void TSS_TPMS_ATTEST_Print(TPMS_ATTEST *source, unsigned int indent) +{ + printf("%*s" "TPMS_ATTEST magic %08x\n", indent+2, "", source->magic); + TSS_TPMI_ST_ATTEST_Print("type", source->type, indent+2); + TSS_TPM2B_Print("TPMS_ATTEST qualifiedSigner", indent+2, &source->qualifiedSigner.b); + TSS_TPM2B_Print("TPMS_ATTEST extraData", indent+2, &source->extraData.b); + TSS_TPMS_CLOCK_INFO_Print(&source->clockInfo, indent+2); + printf("%*s" "TPMS_ATTEST firmwareVersion %"PRIu64"\n", indent+2, "", source->firmwareVersion); + TSS_TPMU_ATTEST_Print(&source->attested, source->type, indent+2); + return; +} + +/* Table 127 - Definition of TPM2B_ATTEST Structure <OUT> */ + +void TSS_TPM2B_ATTEST_Print(TPM2B_ATTEST *source, unsigned int indent) +{ + TPM_RC rc = 0; + TPMS_ATTEST *attests = NULL; + uint32_t size; + uint8_t *buffer = NULL; + + if (rc == 0) { + rc = TSS_Malloc((unsigned char **)&attests, sizeof(TPMS_ATTEST)); /* freed @1 */ + } + /* unmarshal the TPMS_ATTEST from the TPM2B_ATTEST */ + if (rc == 0) { + buffer = source->t.attestationData; + size = source->t.size; + rc = TSS_TPMS_ATTEST_Unmarshalu(attests, &buffer, &size); + } + if (rc == 0) { + TSS_TPMS_ATTEST_Print(attests, indent+2); + } + else { + printf("%*s" "TPMS_ATTEST_Unmarshal failed\n", indent, ""); + } + free(attests); /* @1 */ + return; +} + +/* Table 128 - Definition of TPMS_AUTH_COMMAND Structure <IN> */ + +void TSS_TPMS_AUTH_COMMAND_Print(TPMS_AUTH_COMMAND *source, unsigned int indent) +{ + TSS_TPM_HANDLE_Print("sessionHandle", source->sessionHandle, indent); + TSS_TPM2B_Print("TPMS_AUTH_COMMAND nonce", indent, &source->nonce.b); + TSS_TPMA_SESSION_Print(source->sessionAttributes, indent); + TSS_TPM2B_Print("TPMS_AUTH_COMMAND hmac", indent, &source->hmac.b); + return; +} + +/* Table 129 - Definition of TPMS_AUTH_RESPONSE Structure <OUT> */ + +void TSS_TPMS_AUTH_RESPONSE_Print(TPMS_AUTH_RESPONSE *source, unsigned int indent) +{ + TSS_PrintAlli("TPMS_AUTH_RESPONSE nonce", indent, + source->nonce.t.buffer, + source->nonce.t.size); + TSS_TPMA_SESSION_Print(source->sessionAttributes, indent); + TSS_TPM2B_Print("TPMS_AUTH_RESPONSE hmac", indent, &source->hmac.b); + return; +} + +/* Table 130 - Definition of {!ALG.S} (TPM_KEY_BITS) TPMI_!ALG.S_KEY_BITS Type */ + +void TSS_TPM_KEY_BITS_Print(TPM_KEY_BITS source, unsigned int __unused indent) +{ +// printf("%*s" "TPM_KEY_BITS %u\n", indent, "", source); + printf("TPM_KEY_BITS %u\n", source); + return; +} + +/* Table 131 - Definition of TPMU_SYM_KEY_BITS Union */ + +void TSS_TPMU_SYM_KEY_BITS_Print(TPMU_SYM_KEY_BITS *source, TPMI_ALG_SYM selector, unsigned int indent) +{ + switch (selector) { +#ifdef TPM_ALG_AES + case TPM_ALG_AES: + TSS_TPM_KEY_BITS_Print(source->aes, indent); + break; +#endif +#ifdef TPM_ALG_SM4 + case TPM_ALG_SM4: + TSS_TPM_KEY_BITS_Print(source->sm4, indent); + break; +#endif +#ifdef TPM_ALG_CAMELLIA + case TPM_ALG_CAMELLIA: + TSS_TPM_KEY_BITS_Print(source->camellia, indent); + break; +#endif +#ifdef TPM_ALG_XOR + case TPM_ALG_XOR: + TSS_TPM_ALG_ID_Print("xorr", source->xorr, indent); + break; +#endif + default: + printf("%*s" "TPMI_ALG_SYM value %04hx unknown\n", indent, "", selector); + } + + return; +} + +/* Table 134 - Definition of TPMT_SYM_DEF Structure */ + +void TSS_TPMT_SYM_DEF_Print(TPMT_SYM_DEF *source, unsigned int indent) +{ + TSS_TPM_ALG_ID_Print("algorithm", source->algorithm, indent); + TSS_TPMU_SYM_KEY_BITS_Print(&source->keyBits, source->algorithm, indent); + TSS_TPM_ALG_ID_Print("mode", source->mode.sym, indent); + return; +} + +/* Table 135 - Definition of TPMT_SYM_DEF_OBJECT Structure */ + +void TSS_TPMT_SYM_DEF_OBJECT_Print(TPMT_SYM_DEF_OBJECT *source, unsigned int indent) +{ + TSS_TPM_ALG_ID_Print("algorithm", source->algorithm, indent+2); + if (source->algorithm != TPM_ALG_NULL) { + printf("%*s" "keyBits: %u\n", indent+2, "", source->keyBits.sym); + TSS_TPM_ALG_ID_Print("mode", source->mode.sym, indent+2); + } + return; +} + +/* Table 139 - Definition of TPMS_DERIVE Structure */ + +void TSS_TPMS_DERIVE_Print(TPMS_DERIVE *source, unsigned int indent) +{ + TSS_TPM2B_Print("TPMS_DERIVE label", indent, &source->label.b); + TSS_TPM2B_Print("TPMS_DERIVE context", indent, &source->context.b); + return; +} + +/* Table 143 - Definition of TPMS_SENSITIVE_CREATE Structure <IN> */ + +void TSS_TPMS_SENSITIVE_CREATE_Print(TPMS_SENSITIVE_CREATE *source, unsigned int indent) +{ + TSS_TPM2B_Print("userAuth", indent, &source->userAuth.b); + TSS_TPM2B_Print("data", indent, &source->data.b); + return; +} + +/* Table 144 - Definition of TPM2B_SENSITIVE_CREATE Structure <IN, S> */ + +void TSS_TPM2B_SENSITIVE_CREATE_Print(const char *string, TPM2B_SENSITIVE_CREATE *source, unsigned int indent) +{ + printf("%*s" "%s\n", indent, "", string); + TSS_TPMS_SENSITIVE_CREATE_Print(&source->sensitive, indent+2); + return; +} + +/* Table 146 - Definition of {ECC} TPMS_SCHEME_ECDAA Structure */ + +void TSS_TPMS_SCHEME_ECDAA_Print(TPMS_SCHEME_ECDAA *source, unsigned int indent) +{ + TSS_TPM_ALG_ID_Print("hashAlg", source->hashAlg, indent+2); + printf("%*s" "TPMS_SCHEME_ECDAA count %u\n", indent+2, "", source->count); + return; +} + +/* Table 149 - Definition of TPMS_SCHEME_XOR Structure */ + +void TSS_TPMS_SCHEME_XOR_Print(TPMS_SCHEME_XOR *source, unsigned int indent) +{ + TSS_TPM_ALG_ID_Print("hashAlg", source->hashAlg, indent+2); + TSS_TPM_ALG_ID_Print("kdf", source->kdf, indent+2); + return; +} + +/* Table 150 - Definition of TPMU_SCHEME_KEYEDHASH Union <IN/OUT, S> */ + +void TSS_TPMU_SCHEME_KEYEDHASH_Print(TPMU_SCHEME_KEYEDHASH *source, TPMI_ALG_KEYEDHASH_SCHEME selector, + unsigned int indent) +{ + switch (selector) { +#ifdef TPM_ALG_HMAC + case TPM_ALG_HMAC: + TSS_TPM_ALG_ID_Print("hmac", source->hmac.hashAlg, indent+2); + break; +#endif +#ifdef TPM_ALG_XOR + case TPM_ALG_XOR: + TSS_TPMS_SCHEME_XOR_Print(&source->xorr, indent+2); + break; +#endif + default: + printf("%*s" "TPMU_SCHEME_KEYEDHASH selection %04hx not implemented\n", indent, "", selector); + } + return; +} + +/* Table 151 - Definition of TPMT_KEYEDHASH_SCHEME Structure */ + +void TSS_TPMT_KEYEDHASH_SCHEME_Print(TPMT_KEYEDHASH_SCHEME *source, unsigned int indent) +{ + TSS_TPM_ALG_ID_Print("scheme", source->scheme, indent+2); + if (source->scheme != TPM_ALG_NULL) { + TSS_TPMU_SCHEME_KEYEDHASH_Print(&source->details, source->scheme, indent+2); + } + return; +} + +/* Table 154 - Definition of TPMU_SIG_SCHEME Union <IN/OUT, S> */ + +void TSS_TPMU_SIG_SCHEME_Print(TPMU_SIG_SCHEME *source, TPMI_ALG_SIG_SCHEME selector, unsigned int indent) +{ + switch (selector) { +#ifdef TPM_ALG_RSASSA + case TPM_ALG_RSASSA: + TSS_TPM_ALG_ID_Print("rsassa", source->rsassa.hashAlg, indent+2); + break; +#endif +#ifdef TPM_ALG_RSAPSS + case TPM_ALG_RSAPSS: + TSS_TPM_ALG_ID_Print("rsapss", source->rsapss.hashAlg, indent+2); + break; +#endif +#ifdef TPM_ALG_ECDSA + case TPM_ALG_ECDSA: + TSS_TPM_ALG_ID_Print("ecdsa", source->ecdsa.hashAlg, indent+2); + break; +#endif +#ifdef TPM_ALG_ECDAA + case TPM_ALG_ECDAA: + TSS_TPMS_SCHEME_ECDAA_Print(&source->ecdaa, indent+2); + break; +#endif +#ifdef TPM_ALG_SM2 + case TPM_ALG_SM2: + TSS_TPM_ALG_ID_Print("sm2", source->sm2.hashAlg, indent+2); + break; +#endif +#ifdef TPM_ALG_ECSCHNORR + case TPM_ALG_ECSCHNORR: + TSS_TPM_ALG_ID_Print("ecSchnorr", source->ecSchnorr.hashAlg, indent+2); + break; +#endif +#ifdef TPM_ALG_HMAC + case TPM_ALG_HMAC: + TSS_TPM_ALG_ID_Print("hmac", source->hmac.hashAlg, indent+2); + break; +#endif + default: + printf("%*s" "TPMU_SIG_SCHEME selection %04hx not implemented\n", indent, "", selector); + } + return; +} + +/* Table " Definition", 155 - Definition of TPMT_SIG_SCHEME Structure */ + +void TSS_TPMT_SIG_SCHEME_Print(TPMT_SIG_SCHEME *source, unsigned int indent) +{ + TSS_TPM_ALG_ID_Print("scheme", source->scheme, indent+2); + if (source->scheme != TPM_ALG_NULL) { + TSS_TPMU_SIG_SCHEME_Print(&source->details, source->scheme, indent+2); + } + return; +} + +/* Table 160 - Definition of TPMT_KDF_SCHEME Structure */ + +void TSS_TPMT_KDF_SCHEME_Print(TPMT_KDF_SCHEME *source, unsigned int indent) +{ + TSS_TPM_ALG_ID_Print("scheme", source->scheme, indent+2); + if (source->scheme != TPM_ALG_NULL) { + TSS_TPM_ALG_ID_Print("details", source->details.mgf1.hashAlg, indent+2); + } + return; +} + +/* Table 162 - Definition of TPMU_ASYM_SCHEME Union */ + +void TSS_TPMU_ASYM_SCHEME_Print(TPMU_ASYM_SCHEME *source, TPMI_ALG_ASYM_SCHEME selector, unsigned int indent) +{ + switch (selector) { +#ifdef TPM_ALG_ECDH + case TPM_ALG_ECDH: + TSS_TPM_ALG_ID_Print("ecdh", source->ecdh.hashAlg, indent+2); + break; +#endif +#ifdef TPM_ALG_ECMQV + case TPM_ALG_ECMQV: + TSS_TPM_ALG_ID_Print("ecmqvh", source->ecmqvh.hashAlg, indent+2); + break; +#endif +#ifdef TPM_ALG_RSASSA + case TPM_ALG_RSASSA: + TSS_TPM_ALG_ID_Print("rsassa", source->rsassa.hashAlg, indent+2); + break; +#endif +#ifdef TPM_ALG_RSAPSS + case TPM_ALG_RSAPSS: + TSS_TPM_ALG_ID_Print("rsapss", source->rsapss.hashAlg, indent+2); + break; +#endif +#ifdef TPM_ALG_ECDSA + case TPM_ALG_ECDSA: + TSS_TPM_ALG_ID_Print("ecdsa", source->ecdsa.hashAlg, indent+2); + break; +#endif +#ifdef TPM_ALG_ECDAA + case TPM_ALG_ECDAA: + TSS_TPMS_SCHEME_ECDAA_Print(&source->ecdaa, indent+2); + break; +#endif +#ifdef TPM_ALG_SM2 + case TPM_ALG_SM2: + TSS_TPM_ALG_ID_Print("sm2", source->sm2.hashAlg, indent+2); + break; +#endif +#ifdef TPM_ALG_ECSCHNORR + case TPM_ALG_ECSCHNORR: + TSS_TPM_ALG_ID_Print("ecSchnorr", source->ecSchnorr.hashAlg, indent+2); + break; +#endif +#ifdef TPM_ALG_RSAES + case TPM_ALG_RSAES: + break; +#endif +#ifdef TPM_ALG_OAEP + case TPM_ALG_OAEP: + TSS_TPM_ALG_ID_Print("oaep", source->oaep.hashAlg, indent+2); + break; +#endif + default: + printf("%*s" "TPMU_ASYM_SCHEME selection %04hx not implemented\n", indent, "", selector); + } + return; +} + +/* Table 163 - Definition of TPMT_ASYM_SCHEME Structure <> */ + +void TSS_TPMT_ASYM_SCHEME_Print(TPMT_ASYM_SCHEME *source, unsigned int indent) +{ + TSS_TPM_ALG_ID_Print("scheme", source->scheme, indent+2); + if (source->scheme != TPM_ALG_NULL) { + TSS_TPMU_ASYM_SCHEME_Print(&source->details, source->scheme, indent+2); + } + return; +} + +/* Table 165 - Definition of {RSA} TPMT_RSA_SCHEME Structure */ + +void TSS_TPMT_RSA_SCHEME_Print(TPMT_RSA_SCHEME *source, unsigned int indent) +{ + TSS_TPM_ALG_ID_Print("scheme", source->scheme, indent); + if (source->scheme != TPM_ALG_NULL) { + TSS_TPM_ALG_ID_Print("details", source->details.anySig.hashAlg, indent+2); + } + return; +} + +/* Table 167 - Definition of {RSA} TPMT_RSA_DECRYPT Structure */ + +void TSS_TPMT_RSA_DECRYPT_Print(TPMT_RSA_DECRYPT *source, unsigned int indent) +{ + TSS_TPM_ALG_ID_Print("scheme", source->scheme, indent+2); + if (source->scheme != TPM_ALG_NULL) { + TSS_TPMU_ASYM_SCHEME_Print(&source->details, source->scheme, indent+2); + } + return; +} + +/* Table 169 - Definition of {RSA} (TPM_KEY_BITS) TPMI_RSA_KEY_BITS Type */ + +void TSS_TPMI_RSA_KEY_BITS_Print(TPMI_RSA_KEY_BITS source, unsigned int indent) +{ + printf("%*s" "TPM_KEY_BITS keyBits: %u\n", indent, "", source); + return; +} + +/* Table 172 - Definition of {ECC} TPMS_ECC_POINT Structure */ + +void TSS_TPMS_ECC_POINT_Print(TPMS_ECC_POINT *source, unsigned int indent) +{ + TSS_TPM2B_Print("TPMS_ECC_POINT x", indent+2, &source->x.b); + TSS_TPM2B_Print("TPMS_ECC_POINT y", indent+2, &source->y.b); + return; +} + +/* Table 173 - Definition of {ECC} TPM2B_ECC_POINT Structure */ + +void TSS_TPM2B_ECC_POINT_Print(const char *string, TPM2B_ECC_POINT *source, unsigned int indent) +{ + printf("%*s" "%s\n", indent, "", string); + TSS_TPMS_ECC_POINT_Print(&source->point, indent); + return; +} + +/* Table 175 - Definition of {ECC} (TPM_ECC_CURVE) TPMI_ECC_CURVE Type */ + +void TSS_TPMI_ECC_CURVE_Print(const char *string, TPMI_ECC_CURVE source, unsigned int indent) +{ + printf("%*s", indent, ""); + switch (source) { + case TPM_ECC_BN_P256: + printf("%s TPM_ECC_BN_P256\n", string); + break; + case TPM_ECC_NIST_P256: + printf("%s TPM_ECC_NIST_P256\n", string); + break; + case TPM_ECC_NIST_P384: + printf("%s TPM_ECC_NIST_P384\n", string); + break; + default: + printf("%s TPMI_ECC_CURVE %04hx unknown\n", string, source); + } + return; +} + +/* Table 176 - Definition of (TPMT_SIG_SCHEME) {ECC} TPMT_ECC_SCHEME Structure */ + +void TSS_TPMT_ECC_SCHEME_Print(TPMT_ECC_SCHEME *source, unsigned int indent) +{ + TSS_TPM_ALG_ID_Print("scheme", source->scheme, indent+2); + if (source->scheme != TPM_ALG_NULL) { + TSS_TPM_ALG_ID_Print("details", source->details.anySig.hashAlg, indent+2); + } + return; +} + +/* Table 177 - Definition of {ECC} TPMS_ALGORITHM_DETAIL_ECC Structure <OUT> */ + +void TSS_TPMS_ALGORITHM_DETAIL_ECC_Print(TPMS_ALGORITHM_DETAIL_ECC *source, unsigned int indent) +{ + TSS_TPM_ECC_CURVE_Print("curveID", source->curveID, indent+2); + printf("%*s" "TPMS_ALGORITHM_DETAIL_ECC keySize %u\n", indent+2, "", source->keySize); + TSS_TPMT_KDF_SCHEME_Print(&source->kdf, indent+2); + TSS_TPMT_ECC_SCHEME_Print(&source->sign, indent+2); + TSS_TPM2B_Print("TPMS_ALGORITHM_DETAIL_ECC p", indent, &source->p.b); + TSS_TPM2B_Print("TPMS_ALGORITHM_DETAIL_ECC a", indent, &source->a.b); + TSS_TPM2B_Print("TPMS_ALGORITHM_DETAIL_ECC b", indent, &source->b.b); + TSS_TPM2B_Print("TPMS_ALGORITHM_DETAIL_ECC gX", indent, &source->gX.b); + TSS_TPM2B_Print("TPMS_ALGORITHM_DETAIL_ECC gY", indent, &source->gY.b); + TSS_TPM2B_Print("TPMS_ALGORITHM_DETAIL_ECC n", indent, &source->n.b); + TSS_TPM2B_Print("TPMS_ALGORITHM_DETAIL_ECC h", indent, &source->h.b); + return; +} + +/* Table 178 - Definition of {RSA} TPMS_SIGNATURE_RSA Structure */ + +void TSS_TPMS_SIGNATURE_RSA_Print(TPMS_SIGNATURE_RSA *source, unsigned int indent) +{ + TSS_TPM_ALG_ID_Print("hash", source->hash, indent+2); + TSS_TPM2B_Print("TPMS_SIGNATURE_RSA sig", indent+2, &source->sig.b); + return; +} + +/* Table 179 - Definition of Types for {RSA} Signature */ + +void TSS_TPMS_SIGNATURE_RSASSA_Print(TPMS_SIGNATURE_RSASSA *source, unsigned int indent) +{ + TSS_TPMS_SIGNATURE_RSA_Print(source, indent+2); + return; +} + +/* Table 180 - Definition of {ECC} TPMS_SIGNATURE_ECC Structure */ + +void TSS_TPMS_SIGNATURE_ECC_Print(TPMS_SIGNATURE_ECC *source, unsigned int indent) +{ + TSS_TPM_ALG_ID_Print("hash", source->hash, indent); + TSS_TPM2B_Print("TPMS_SIGNATURE_ECC signatureR", indent, &source->signatureR.b); + TSS_TPM2B_Print("TPMS_SIGNATURE_ECC signatureS", indent, &source->signatureS.b); + return; +} + +/* Table 182 - Definition of TPMU_SIGNATURE Union <IN/OUT, S> */ + +void TSS_TPMU_SIGNATURE_Print(TPMU_SIGNATURE *source, TPMI_ALG_SIG_SCHEME selector, unsigned int indent) +{ + switch (selector) { +#ifdef TPM_ALG_RSASSA + case TPM_ALG_RSASSA: + TSS_TPMS_SIGNATURE_RSA_Print(&source->rsassa, indent+2); + break; +#endif +#ifdef TPM_ALG_RSAPSS + case TPM_ALG_RSAPSS: + TSS_TPMS_SIGNATURE_RSA_Print(&source->rsapss, indent+2); + break; +#endif +#ifdef TPM_ALG_ECDSA + case TPM_ALG_ECDSA: + TSS_TPMS_SIGNATURE_ECC_Print(&source->ecdsa, indent+2); + break; +#endif +#ifdef TPM_ALG_ECDAA + case TPM_ALG_ECDAA: + TSS_TPMS_SIGNATURE_ECC_Print(&source->ecdaa, indent+2); + break; +#endif +#ifdef TPM_ALG_SM2 + case TPM_ALG_SM2: + TSS_TPMS_SIGNATURE_ECC_Print(&source->sm2, indent+2); + break; +#endif +#ifdef TPM_ALG_ECSCHNORR + case TPM_ALG_ECSCHNORR: + TSS_TPMS_SIGNATURE_ECC_Print(&source->ecschnorr, indent+2); + break; +#endif +#ifdef TPM_ALG_HMAC + case TPM_ALG_HMAC: + TSS_TPMT_HA_Print(&source->hmac, indent+2); + break; +#endif + default: + printf("%*s" "TPMU_SIGNATURE selection %04hx not implemented\n", indent, "", selector); + + } +} + +/* Table 183 - Definition of TPMT_SIGNATURE Structure */ + +void TSS_TPMT_SIGNATURE_Print(TPMT_SIGNATURE *source, unsigned int indent) +{ + TSS_TPM_ALG_ID_Print("sigAlg", source->sigAlg, indent+2); + if (source->sigAlg != TPM_ALG_NULL) { + TSS_TPMU_SIGNATURE_Print(&source->signature, source->sigAlg, indent); + } + return; +} + +/* Table 186 - Definition of (TPM_ALG_ID) TPMI_ALG_PUBLIC Type */ + +void TSS_TPMI_ALG_PUBLIC_Print(const char *string, TPMI_ALG_PUBLIC source, unsigned int indent) +{ + printf("%*s", indent, ""); + switch (source) { +#ifdef TPM_ALG_KEYEDHASH + case TPM_ALG_KEYEDHASH: + printf("%s TPM_ALG_KEYEDHASH\n", string); + break; +#endif +#ifdef TPM_ALG_RSA + case TPM_ALG_RSA: + printf("%s TPM_ALG_RSA\n", string); + break; +#endif +#ifdef TPM_ALG_ECC + case TPM_ALG_ECC: + printf("%s TPM_ALG_ECC\n", string); + break; +#endif +#ifdef TPM_ALG_SYMCIPHER + case TPM_ALG_SYMCIPHER: + printf("%s TPM_ALG_SYMCIPHER\n", string); + break; +#endif + default: + printf("%s selection %04hx not implemented\n", string, source); + } + return; +} + +/* Table 187 - Definition of TPMU_PUBLIC_ID Union <IN/OUT, S> */ + +void TSS_TPMU_PUBLIC_ID_Print(TPMU_PUBLIC_ID *source, TPMI_ALG_PUBLIC selector, unsigned int indent) +{ + switch (selector) { +#ifdef TPM_ALG_KEYEDHASH + case TPM_ALG_KEYEDHASH: + TSS_TPM2B_Print("TPM_ALG_KEYEDHASH keyedHash", indent, &source->keyedHash.b); + break; +#endif +#ifdef TPM_ALG_SYMCIPHER + case TPM_ALG_SYMCIPHER: + TSS_TPM2B_Print("TPM_ALG_SYMCIPHER sym", indent, &source->sym.b); + break; +#endif +#ifdef TPM_ALG_RSA + case TPM_ALG_RSA: + TSS_TPM2B_Print("TPM_ALG_RSA rsa", indent, &source->rsa.b); + break; +#endif +#ifdef TPM_ALG_ECC + case TPM_ALG_ECC: + TSS_TPM2B_Print("TPM_ALG_ECC x", indent, &source->ecc.x.b); + TSS_TPM2B_Print("TPM_ALG_ECC y", indent, &source->ecc.y.b); + break; +#endif + default: + printf("%*s" "TPMU_PUBLIC_ID_Print: selection %04hx not implemented\n", indent, "", selector); + } + return; +} + +/* Table 188 - Definition of TPMS_KEYEDHASH_PARMS Structure */ + +void TSS_TPMS_KEYEDHASH_PARMS_Print(TPMS_KEYEDHASH_PARMS *source, unsigned int indent) +{ + TSS_TPMT_KEYEDHASH_SCHEME_Print(&source->scheme, indent); + return; +} + +/* Table 189 - Definition of TPMS_ASYM_PARMS Structure <> */ + +void TSS_TPMS_ASYM_PARMS_Print(TPMS_ASYM_PARMS *source, unsigned int indent) +{ + TSS_TPMT_SYM_DEF_OBJECT_Print(&source->symmetric, indent+2); + TSS_TPMT_ASYM_SCHEME_Print(&source->scheme, indent+2); + return; +} + +/* Table 190 - Definition of {RSA} TPMS_RSA_PARMS Structure */ + +void TSS_TPMS_RSA_PARMS_Print(TPMS_RSA_PARMS *source, unsigned int indent) +{ + TSS_TPMT_SYM_DEF_OBJECT_Print(&source->symmetric, indent); + TSS_TPMT_RSA_SCHEME_Print(&source->scheme, indent); + TSS_TPMI_RSA_KEY_BITS_Print(source->keyBits, indent); + printf("%*s" "TPMS_RSA_PARMS exponent %08x\n", indent, "", source->exponent); + return; +} + +/* Table 191 - Definition of {ECC} TPMS_ECC_PARMS Structure */ + +void TSS_TPMS_ECC_PARMS_Print(TPMS_ECC_PARMS *source, unsigned int indent) +{ + TSS_TPMT_SYM_DEF_OBJECT_Print(&source->symmetric, indent); + TSS_TPMT_ECC_SCHEME_Print(&source->scheme, indent); + TSS_TPMI_ECC_CURVE_Print("curveID", source->curveID, indent); + TSS_TPMT_KDF_SCHEME_Print(&source->kdf, indent); + return; +} + +/* Table 192 - Definition of TPMU_PUBLIC_PARMS Union <IN/OUT, S> */ + +void TSS_TPMU_PUBLIC_PARMS_Print(TPMU_PUBLIC_PARMS *source, uint32_t selector, unsigned int indent) +{ + switch (selector) { + case TPM_ALG_KEYEDHASH: + printf("%*s" "TPMU_PUBLIC_PARMS keyedHashDetail\n", indent, ""); + TSS_TPMS_KEYEDHASH_PARMS_Print(&source->keyedHashDetail, indent); + break; +#if 0 + case TPM_ALG_SYMCIPHER: + printf("%*s" "TPMU_PUBLIC_PARMS symDetail\n", indent, ""); + TSS_TPMS_SYMCIPHER_PARMS_Print(&source->symDetail, indent); + break; +#endif +#ifdef TPM_ALG_RSA + case TPM_ALG_RSA: + printf("%*s" "TPMU_PUBLIC_PARMS rsaDetail\n", indent, ""); + TSS_TPMS_RSA_PARMS_Print(&source->rsaDetail, indent); + break; +#endif +#ifdef TPM_ALG_ECC + case TPM_ALG_ECC: + printf("%*s" "TPMU_PUBLIC_PARMS eccDetail\n", indent, ""); + TSS_TPMS_ECC_PARMS_Print(&source->eccDetail, indent); + break; +#endif + default: + printf("%*s" "TPMU_PUBLIC_PARMS: selector %04x not implemented\n", indent, "", selector); + } + return; +} + +/* Table 193 - Definition of TPMT_PUBLIC_PARMS Structure */ + +void TSS_TPMT_PUBLIC_PARMS_Print(TPMT_PUBLIC_PARMS *source, unsigned int indent) +{ + TSS_TPM_ALG_ID_Print("type", source->type, indent); + TSS_TPMU_PUBLIC_PARMS_Print(&source->parameters, source->type, indent); + return; +} +/* Table 194 - Definition of TPMT_PUBLIC Structure */ + +void TSS_TPMT_PUBLIC_Print(TPMT_PUBLIC *source, unsigned int indent) +{ + TSS_TPMI_ALG_PUBLIC_Print("type", source->type, indent); + TSS_TPM_ALG_ID_Print("nameAlg", source->nameAlg, indent); + TSS_TPMA_OBJECT_Print("objectAttributes", source->objectAttributes, indent); + TSS_TPM2B_Print("authPolicy", indent, &source->authPolicy.b); + TSS_TPMU_PUBLIC_PARMS_Print(&source->parameters, source->type, indent); + TSS_TPMU_PUBLIC_ID_Print(&source->unique, source->type, indent); + return; +} + +/* Table 195 - Definition of TPM2B_PUBLIC Structure */ + +void TSS_TPM2B_PUBLIC_Print(const char *string, TPM2B_PUBLIC *source, unsigned int indent) +{ + printf("%*s" "%s\n", indent, "", string); + TSS_TPMT_PUBLIC_Print(&source->publicArea, indent+2); + return; +} + +/* Table 198 - Definition of TPMU_SENSITIVE_COMPOSITE Union <IN/OUT, S> */ + +void TSS_TPMU_SENSITIVE_COMPOSITE_Print(TPMU_SENSITIVE_COMPOSITE *source, uint32_t selector, unsigned int indent) +{ + switch (selector) { +#ifdef TPM_ALG_RSA + case TPM_ALG_RSA: + TSS_TPM2B_Print("TPMU_SENSITIVE_COMPOSITE rsa", indent+2, &source->rsa.b); + break; +#endif +#ifdef TPM_ALG_ECC + case TPM_ALG_ECC: + TSS_TPM2B_Print("TPMU_SENSITIVE_COMPOSITE ecc", indent+2, &source->ecc.b); + break; +#endif +#ifdef TPM_ALG_KEYEDHASH + case TPM_ALG_KEYEDHASH: + TSS_TPM2B_Print("TPMU_SENSITIVE_COMPOSITE bits", indent+2, &source->bits.b); + break; +#endif +#ifdef TPM_ALG_SYMCIPHER + case TPM_ALG_SYMCIPHER: + TSS_TPM2B_Print("TPMU_SENSITIVE_COMPOSITE sym", indent+2, &source->sym.b); + break; +#endif + default: + printf("%*s" "TPMU_SENSITIVE_COMPOSITE: selection %08x not implemented \n", indent+2, "", selector); + } + return; +} + +/* Table 199 - Definition of TPMT_SENSITIVE Structure */ + +void TSS_TPMT_SENSITIVE_Print(TPMT_SENSITIVE *source, unsigned int indent) +{ + TSS_TPM_ALG_ID_Print("sensitiveType", source->sensitiveType, indent+2); + TSS_TPM2B_Print("TPMT_SENSITIVE authValue", indent+2, &source->authValue.b); + TSS_TPM2B_Print("TPMT_SENSITIVE seedValue", indent+2, &source->seedValue.b); + return; +} + +/* Table 200 - Definition of TPM2B_SENSITIVE Structure <IN/OUT> */ + +void TSS_TPM2B_SENSITIVE_Print(TPM2B_SENSITIVE *source, unsigned int indent) +{ + printf("%*s" "TPM2B_SENSITIVE size %u\n", indent+2, "", source->t.size); + TSS_TPMT_SENSITIVE_Print(&source->t.sensitiveArea, indent+2); + return; +} + +/* Table 207 - Definition of TPMS_NV_PIN_COUNTER_PARAMETERS Structure */ + +void TSS_TPMS_NV_PIN_COUNTER_PARAMETERS_Print(TPMS_NV_PIN_COUNTER_PARAMETERS *source, unsigned int indent) +{ + printf("%*s" "pinCount %u\n", indent+2, "", source->pinCount); + printf("%*s" "pinLimit %u\n", indent+2, "", source->pinLimit); + return; +} + +/* Table 208 - Definition of (UINT32) TPMA_NV Bits */ + +void TSS_TPMA_NV_Print(TPMA_NV source, unsigned int indent) +{ + uint32_t nvType; + + if (source.val & TPMA_NVA_PPWRITE) printf("%*s" "TPMA_NV_PPWRITE\n", indent, ""); + if (source.val & TPMA_NVA_OWNERWRITE) printf("%*s" "TPMA_NV_OWNERWRITE\n", indent, ""); + if (source.val & TPMA_NVA_AUTHWRITE) printf("%*s" "TPMA_NV_AUTHWRITE\n", indent, ""); + if (source.val & TPMA_NVA_POLICYWRITE) printf("%*s" "TPMA_NV_POLICYWRITE\n", indent, ""); + + nvType = (source.val & TPMA_NVA_TPM_NT_MASK) >> 4; + switch (nvType) { + case TPM_NT_ORDINARY: + printf("%*s" "TPM_NT_ORDINARY\n", indent, ""); + break; + case TPM_NT_COUNTER: + printf("%*s" "TPM_NT_COUNTER\n", indent, ""); + break; + case TPM_NT_BITS: + printf("%*s" "TPM_NT_COUNTER\n", indent, ""); + break; + case TPM_NT_EXTEND: + printf("%*s" "TPM_NT_EXTEND\n", indent, ""); + break; + case TPM_NT_PIN_FAIL: + printf("%*s" "TPM_NT_PIN_FAIL\n", indent, ""); + break; + case TPM_NT_PIN_PASS: + printf("%*s" "TPM_NT_PIN_PASS\n", indent, ""); + break; + default: + printf("%*s %02x" "TPMA_NV type unknown\n", indent, "", nvType); + } + + if (source.val & TPMA_NVA_POLICY_DELETE) printf("%*s" "TPMA_NV_POLICY_DELETE\n", indent, ""); + if (source.val & TPMA_NVA_WRITELOCKED) printf("%*s" "TPMA_NV_WRITELOCKED\n", indent, ""); + if (source.val & TPMA_NVA_WRITEALL) printf("%*s" "TPMA_NV_WRITEALL\n", indent, ""); + if (source.val & TPMA_NVA_WRITEDEFINE) printf("%*s" "TPMA_NV_WRITEDEFINE\n", indent, ""); + if (source.val & TPMA_NVA_WRITE_STCLEAR) printf("%*s" "TPMA_NV_WRITE_STCLEAR\n", indent, ""); + if (source.val & TPMA_NVA_GLOBALLOCK) printf("%*s" "TPMA_NV_GLOBALLOCK\n", indent, ""); + if (source.val & TPMA_NVA_PPREAD) printf("%*s" "TPMA_NV_PPREAD\n", indent, ""); + if (source.val & TPMA_NVA_OWNERREAD) printf("%*s" "TPMA_NV_OWNERREAD\n", indent, ""); + if (source.val & TPMA_NVA_AUTHREAD) printf("%*s" "TPMA_NV_AUTHREAD\n", indent, ""); + if (source.val & TPMA_NVA_POLICYREAD) printf("%*s" "TPMA_NV_POLICYREAD\n", indent, ""); + if (source.val & TPMA_NVA_NO_DA) printf("%*s" "TPMA_NV_NO_DA\n", indent, ""); + if (source.val & TPMA_NVA_ORDERLY) printf("%*s" "TPMA_NV_ORDERLY\n", indent, ""); + if (source.val & TPMA_NVA_CLEAR_STCLEAR) printf("%*s" "TPMA_NV_CLEAR_STCLEAR\n", indent, ""); + if (source.val & TPMA_NVA_READLOCKED) printf("%*s" "TPMA_NV_READLOCKED\n", indent, ""); + if (source.val & TPMA_NVA_WRITTEN) printf("%*s" "TPMA_NV_WRITTEN\n", indent, ""); + if (source.val & TPMA_NVA_PLATFORMCREATE) printf("%*s" "TPMA_NV_PLATFORMCREATE\n", indent, ""); + if (source.val & TPMA_NVA_READ_STCLEAR) printf("%*s" "TPMA_NV_READ_STCLEAR\n", indent, ""); + return; +} + +/* Table 209 - Definition of TPMS_NV_PUBLIC Structure */ + +void TSS_TPMS_NV_PUBLIC_Print(TPMS_NV_PUBLIC *source, unsigned int indent) +{ + printf("%*s" "TPMS_NV_PUBLIC nvIndex %08x\n", indent+2, "", source->nvIndex); + TSS_TPM_ALG_ID_Print("nameAlg", source->nameAlg, indent+2); + TSS_TPMA_NV_Print(source->attributes, indent+2); + TSS_TPM2B_Print("TPMS_NV_PUBLIC authPolicy", indent+2, &source->authPolicy.b); + printf("%*s" "TPMS_NV_PUBLIC dataSize %u\n", indent+2, "", source->dataSize); + return; +} + +/* Table 210 - Definition of TPM2B_NV_PUBLIC Structure */ + +void TSS_TPM2B_NV_PUBLIC_Print(TPM2B_NV_PUBLIC *source, unsigned int indent) +{ + TSS_TPMS_NV_PUBLIC_Print(&source->nvPublic, indent+2); + return; +} + +/* Table 212 - Definition of TPMS_CONTEXT_DATA Structure <IN/OUT, S> */ + +void TSS_TPMS_CONTEXT_DATA_Print(TPMS_CONTEXT_DATA *source, unsigned int indent) +{ + TSS_TPM2B_Print("TPMS_CONTEXT_DATA integrity", indent+2, &source->integrity.b); + TSS_TPM2B_Print("TPMS_CONTEXT_DATA encrypted", indent+2, &source->encrypted.b); + return; +} + +/* Table 214 - Definition of TPMS_CONTEXT Structure */ + +void TSS_TPMS_CONTEXT_Print(TPMS_CONTEXT *source, unsigned int indent) +{ + printf("%*s" "TPMS_CONTEXT sequence %"PRIu64"\n", indent+2, "", source->sequence); + TSS_TPM_HANDLE_Print("savedHandle", source->savedHandle, indent+2); + TSS_TPM_HANDLE_Print("hierarchy", source->hierarchy, indent+2); + TSS_TPM2B_Print("TPMS_CONTEXT contextBlob", indent+2, &source->contextBlob.b); + return; +} + +/* Table 216 - Definition of TPMS_CREATION_DATA Structure <OUT> */ + +void TSS_TPMS_CREATION_DATA_Print(TPMS_CREATION_DATA *source, unsigned int indent) +{ + TSS_TPML_PCR_SELECTION_Print(&source->pcrSelect, indent+2); + TSS_TPM2B_Print("TPMS_CREATION_DATA pcrDigest", indent+2, &source->pcrDigest.b); + TSS_TPMA_LOCALITY_Print(source->locality, indent+2); + TSS_TPM_ALG_ID_Print("parentNameAlg", source->parentNameAlg, indent+2); + TSS_TPM2B_Print("TPMS_CREATION_DATA parentName", indent+2, &source->parentName.b); + TSS_TPM2B_Print("TPMS_CREATION_DATA parentQualifiedName", indent+2, &source->parentQualifiedName.b); + TSS_TPM2B_Print("TPMS_CREATION_DATA outsideInfo", indent+2, &source->outsideInfo.b); +return; +} + +/* Table 217 - Definition of TPM2B_CREATION_DATA Structure <OUT> */ + +void TSS_TPM2B_CREATION_DATA_Print(TPM2B_CREATION_DATA *source, unsigned int indent) +{ + printf("%*s" "TPM2B_CREATION_DATA size %u\n", indent+2, "", source->size); + TSS_TPMS_CREATION_DATA_Print(&source->creationData, indent+2); + return; +} + +#endif /* TPM_TPM20 */ diff --git a/libstb/tss2/tssprintcmd.c b/libstb/tss2/tssprintcmd.c new file mode 100644 index 0000000..b4ca522 --- /dev/null +++ b/libstb/tss2/tssprintcmd.c @@ -0,0 +1,909 @@ +/********************************************************************************/ +/* */ +/* Command Print Utilities */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: tssprintcmd.c 1257 2018-06-27 20:52:08Z kgoldman $ */ +/* */ +/* (c) Copyright IBM Corporation 2018. */ +/* */ +/* All rights reserved. */ +/* */ +/* Redistribution and use in source and binary forms, with or without */ +/* modification, are permitted provided that the following conditions are */ +/* met: */ +/* */ +/* Redistributions of source code must retain the above copyright notice, */ +/* this list of conditions and the following disclaimer. */ +/* */ +/* 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. */ +/* */ +/* Neither the names of the IBM Corporation nor the names of its */ +/* contributors may be used to endorse or promote products derived from */ +/* this software without specific prior written permission. */ +/* */ +/* 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. */ +/********************************************************************************/ + +#include <stdint.h> +#include <stdio.h> +#include <inttypes.h> + +#include <ibmtss/tssprintcmd.h> + +void ActivateCredential_In_Print(ActivateCredential_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_ActivateCredential\n", indent, ""); + TSS_TPM_HANDLE_Print("activateHandle", in->activateHandle, indent); + TSS_TPM_HANDLE_Print("keyHandle", in->keyHandle, indent); + TSS_TPM2B_Print("credentialBlob", indent, &in->credentialBlob.b); + TSS_TPM2B_Print("TPM2B_ENCRYPTED_SECRET secret", indent, &in->secret.b); + return; +} +void CertifyCreation_In_Print(CertifyCreation_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_CertifyCreation\n", indent, ""); + TSS_TPM_HANDLE_Print("signHandle", in->signHandle, indent); + TSS_TPM_HANDLE_Print("objectHandle", in->objectHandle, indent); + TSS_TPM2B_Print("qualifyingData", indent, &in->qualifyingData.b); + TSS_TPM2B_Print("creationHash", indent, &in->creationHash.b); + printf("%*s" "inScheme\n", indent, ""); + TSS_TPMT_SIG_SCHEME_Print(&in->inScheme, indent); + printf("%*s" "creationTicket\n", indent, ""); + TSS_TPMT_TK_CREATION_Print(&in->creationTicket, indent+2); + return; +} +void Certify_In_Print(Certify_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_Certify\n", indent, ""); + TSS_TPM_HANDLE_Print("objectHandle", in->objectHandle, indent); + TSS_TPM_HANDLE_Print("signHandle", in->signHandle, indent); + TSS_TPM2B_Print("qualifyingData", indent, &in->qualifyingData.b); + printf("%*s" "inScheme\n", indent, ""); + TSS_TPMT_SIG_SCHEME_Print(&in->inScheme, indent); + return; +} +void ChangeEPS_In_Print(ChangeEPS_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_ChangeEPS\n", indent, ""); + TSS_TPM_HANDLE_Print("authHandle", in->authHandle, indent); + return; +} +void ChangePPS_In_Print(ChangePPS_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_ChangePPS\n", indent, ""); + TSS_TPM_HANDLE_Print("authHandle", in->authHandle, indent); + return; +} +void ClearControl_In_Print(ClearControl_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_ClearControl\n", indent, ""); + TSS_TPM_HANDLE_Print("auth", in->auth, indent); + TSS_TPMI_YES_NO_Print("disable", in->disable, indent); + return; +} +void Clear_In_Print(Clear_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_Clear\n", indent, ""); + TSS_TPM_HANDLE_Print("authHandle", in->authHandle, indent); + return; +} +void ClockRateAdjust_In_Print(ClockRateAdjust_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_ClockRateAdjust\n", indent, ""); + TSS_TPM_HANDLE_Print("auth", in->auth, indent); + TSS_TPM_CLOCK_ADJUST_Print("rateAdjust", in->rateAdjust, indent); + return; +} +void ClockSet_In_Print(ClockSet_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_ClockSet\n", indent, ""); + TSS_TPM_HANDLE_Print("auth", in->auth, indent); + printf("%*s" "newTime %"PRIu64"\n", indent, "", in->newTime); + return; +} +void Commit_In_Print(Commit_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_Commit\n", indent, ""); + TSS_TPM_HANDLE_Print("signHandle", in->signHandle, indent); + TSS_TPM2B_ECC_POINT_Print("P1", &in->P1, indent); + TSS_TPM2B_Print("s2", indent, &in->s2.b); + TSS_TPM2B_Print("y2", indent, &in->y2.b); + return; +} +void ContextLoad_In_Print(ContextLoad_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_ContextLoad\n", indent, ""); + TSS_TPMS_CONTEXT_Print(&in->context, indent); + return; +} +void ContextSave_In_Print(ContextSave_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_ContextSave\n", indent, ""); + TSS_TPM_HANDLE_Print("saveHandle", in->saveHandle, indent); + return; +} +void Create_In_Print(Create_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_Create\n", indent, ""); + TSS_TPM_HANDLE_Print("parentHandle", in->parentHandle, indent); + TSS_TPM2B_SENSITIVE_CREATE_Print("inSensitive", &in->inSensitive, indent); + TSS_TPM2B_PUBLIC_Print("inPublic", &in->inPublic, indent); + TSS_TPM2B_Print("outsideInfo", indent, &in->outsideInfo.b); + TSS_TPML_PCR_SELECTION_Print(&in->creationPCR, indent); + return; +} +void CreateLoaded_In_Print(CreateLoaded_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_CreateLoaded\n", indent, ""); + TSS_TPM_HANDLE_Print("parentHandle", in->parentHandle, indent); + TSS_TPM2B_SENSITIVE_CREATE_Print("inSensitive", &in->inSensitive, indent); + TSS_TPM2B_Print("inPublic", indent, &in->inPublic.b); + return; +} +void CreatePrimary_In_Print(CreatePrimary_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_CreatePrimary\n", indent, ""); + TSS_TPM_HANDLE_Print("primaryHandle", in->primaryHandle, indent); + TSS_TPM2B_SENSITIVE_CREATE_Print("inSensitive", &in->inSensitive, indent); + TSS_TPM2B_PUBLIC_Print("inPublic", &in->inPublic, indent); + TSS_TPM2B_Print("outsideInfo", indent, &in->outsideInfo.b); + TSS_TPML_PCR_SELECTION_Print(&in->creationPCR, indent); + return; +} +void DictionaryAttackLockReset_In_Print(DictionaryAttackLockReset_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_DictionaryAttackLockReset\n", indent, ""); + TSS_TPM_HANDLE_Print("lockHandle", in->lockHandle, indent); + return; +} +void DictionaryAttackParameters_In_Print(DictionaryAttackParameters_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_DictionaryAttackParameters\n", indent, ""); + TSS_TPM_HANDLE_Print("lockHandle", in->lockHandle, indent); + printf("%*s" "newMaxTries %u\n", indent, "", in->newMaxTries); + printf("%*s" "newRecoveryTime %u\n", indent, "", in->newRecoveryTime); + printf("%*s" "lockoutRecovery %u\n", indent, "", in->lockoutRecovery); + return; +} +void Duplicate_In_Print(Duplicate_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_Duplicate\n", indent, ""); + TSS_TPM_HANDLE_Print("objectHandle", in->objectHandle, indent); + TSS_TPM_HANDLE_Print("newParentHandle", in->newParentHandle, indent); + TSS_TPM2B_Print("encryptionKeyIn", indent, &in->encryptionKeyIn.b); + printf("%*s" "symmetricAlg\n", indent, ""); + TSS_TPMT_SYM_DEF_OBJECT_Print(&in->symmetricAlg, indent); + return; +} +void ECC_Parameters_In_Print(ECC_Parameters_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_ECC_Parameters\n", indent, ""); + TSS_TPMI_ECC_CURVE_Print("curveID", in->curveID, indent); + return; +} +void ECDH_KeyGen_In_Print(ECDH_KeyGen_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_ECDH_KeyGen\n", indent, ""); + TSS_TPM_HANDLE_Print("keyHandle", in->keyHandle, indent); + return; +} +void ECDH_ZGen_In_Print(ECDH_ZGen_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_ECDH_ZGen\n", indent, ""); + TSS_TPM_HANDLE_Print("keyHandle", in->keyHandle, indent); + TSS_TPM2B_ECC_POINT_Print("inPoint", &in->inPoint, indent); + return; +} +void EC_Ephemeral_In_Print(EC_Ephemeral_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_EC_Ephemeral\n", indent, ""); + TSS_TPMI_ECC_CURVE_Print("curveID", in->curveID, indent); + return; +} +void EncryptDecrypt_In_Print(EncryptDecrypt_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_EncryptDecrypt\n", indent, ""); + TSS_TPM_HANDLE_Print("keyHandle", in->keyHandle, indent); + TSS_TPMI_YES_NO_Print("decrypt", in->decrypt, indent); + TSS_TPM_ALG_ID_Print("mode", in->mode, indent); + TSS_TPM2B_Print("ivIn", indent, &in->ivIn.b); + TSS_TPM2B_Print("inData", indent, &in->inData.b); + return; +} +void EncryptDecrypt2_In_Print(EncryptDecrypt2_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_EncryptDecrypt2\n", indent, ""); + TSS_TPM_HANDLE_Print("keyHandle", in->keyHandle, indent); + TSS_TPM2B_Print("inData", indent, &in->inData.b); + TSS_TPMI_YES_NO_Print("decrypt", in->decrypt, indent); + TSS_TPM_ALG_ID_Print("mode", in->mode, indent); + TSS_TPM2B_Print("ivIn", indent, &in->ivIn.b); + return; +} +void EventSequenceComplete_In_Print(EventSequenceComplete_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_EventSequenceComplete\n", indent, ""); + TSS_TPM_HANDLE_Print("pcrHandle", in->pcrHandle, indent); + TSS_TPM_HANDLE_Print("sequenceHandle", in->sequenceHandle, indent); + TSS_TPM2B_Print("buffer", indent, &in->buffer.b); + return; +} +void EvictControl_In_Print(EvictControl_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_EvictControl\n", indent, ""); + TSS_TPM_HANDLE_Print("auth", in->auth, indent); + TSS_TPM_HANDLE_Print("objectHandle", in->objectHandle, indent); + TSS_TPM_HANDLE_Print("persistentHandle", in->persistentHandle, indent); + return; +} +void FlushContext_In_Print(FlushContext_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_FlushContext\n", indent, ""); + TSS_TPM_HANDLE_Print("flushHandle", in->flushHandle, indent); + return; +} +void GetCapability_In_Print(GetCapability_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_GetCapability\n", indent, ""); + TSS_TPM_CAP_Print("capability", in->capability, indent); + printf("%*s" "property %08x\n", indent, "", in->property); + printf("%*s" "propertyCount %u\n", indent, "", in->propertyCount); + return; +} +void GetCommandAuditDigest_In_Print(GetCommandAuditDigest_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_GetCommandAuditDigest\n", indent, ""); + TSS_TPM_HANDLE_Print("privacyHandle", in->privacyHandle, indent); + TSS_TPM_HANDLE_Print("signHandle", in->signHandle, indent); + TSS_TPM2B_Print("qualifyingData", indent, &in->qualifyingData.b); + printf("%*s" "inScheme\n", indent, ""); + TSS_TPMT_SIG_SCHEME_Print(&in->inScheme, indent); + return; +} +void GetRandom_In_Print(GetRandom_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_GetRandom\n", indent, ""); + printf("%*s" "bytesRequested %u\n", indent, "", in->bytesRequested); + return; +} +void GetSessionAuditDigest_In_Print(GetSessionAuditDigest_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_GetSessionAuditDigest\n", indent, ""); + TSS_TPM_HANDLE_Print("privacyAdminHandle", in->privacyAdminHandle, indent); + TSS_TPM_HANDLE_Print("signHandle", in->signHandle, indent); + TSS_TPM_HANDLE_Print("sessionHandle", in->sessionHandle, indent); + TSS_TPM2B_Print("qualifyingData", indent, &in->qualifyingData.b); + printf("%*s" "inScheme\n", indent, ""); + TSS_TPMT_SIG_SCHEME_Print(&in->inScheme, indent); + return; +} +void GetTime_In_Print(GetTime_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_GetTime\n", indent, ""); + TSS_TPM_HANDLE_Print("privacyAdminHandle", in->privacyAdminHandle, indent); + TSS_TPM_HANDLE_Print("signHandle", in->signHandle, indent); + TSS_TPM2B_Print("qualifyingData", indent, &in->qualifyingData.b); + printf("%*s" "inScheme\n", indent, ""); + TSS_TPMT_SIG_SCHEME_Print(&in->inScheme, indent); + return; +} +void HMAC_Start_In_Print(HMAC_Start_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_HMAC_Start\n", indent, ""); + TSS_TPM_HANDLE_Print("handle", in->handle, indent); + TSS_TPM2B_Print("auth", indent, &in->auth.b); + TSS_TPM_ALG_ID_Print("hashAlg", in->hashAlg, indent); + return; +} +void HMAC_In_Print(HMAC_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_HMAC\n", indent, ""); + TSS_TPM_HANDLE_Print("handle", in->handle, indent); + TSS_TPM2B_Print("buffer", indent, &in->buffer.b); + TSS_TPM_ALG_ID_Print("hashAlg", in->hashAlg, indent); + return; +} +void HashSequenceStart_In_Print(HashSequenceStart_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_HashSequenceStart\n", indent, ""); + TSS_TPM2B_Print("auth", indent, &in->auth.b); + TSS_TPM_ALG_ID_Print("hashAlg", in->hashAlg, indent); + return; +} +void Hash_In_Print(Hash_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_Hash\n", indent, ""); + TSS_TPM2B_Print("data", indent, &in->data.b); + TSS_TPM_ALG_ID_Print("hashAlg", in->hashAlg, indent); + TSS_TPM_HANDLE_Print("hierarchy", in->hierarchy, indent); + return; +} +void HierarchyChangeAuth_In_Print(HierarchyChangeAuth_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_HierarchyChangeAuth\n", indent, ""); + TSS_TPM_HANDLE_Print("authHandle", in->authHandle, indent); + TSS_TPM2B_Print("newAuth", indent, &in->newAuth.b); + return; +} +void HierarchyControl_In_Print(HierarchyControl_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_HierarchyControl\n", indent, ""); + TSS_TPM_HANDLE_Print("authHandle", in->authHandle, indent); + TSS_TPM_HANDLE_Print("enable", in->enable, indent); + TSS_TPMI_YES_NO_Print("state", in->state, indent); + return; +} +void Import_In_Print(Import_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_Import\n", indent, ""); + TSS_TPM_HANDLE_Print("parentHandle", in->parentHandle, indent); + TSS_TPM2B_Print("encryptionKey", indent, &in->encryptionKey.b); + TSS_TPM2B_PUBLIC_Print("objectPublic", &in->objectPublic, indent); + TSS_TPM2B_Print("duplicate", indent, &in->duplicate.b); + TSS_TPM2B_Print("inSymSeed", indent, &in->inSymSeed.b); + printf("%*s" "symmetricAlg\n", indent, ""); + TSS_TPMT_SYM_DEF_OBJECT_Print(&in->symmetricAlg, indent); + return; +} +void IncrementalSelfTest_In_Print(IncrementalSelfTest_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_IncrementalSelfTest\n", indent, ""); + TSS_TPML_ALG_Print(&in->toTest, indent); + return; +} +void LoadExternal_In_Print(LoadExternal_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_LoadExternal\n", indent, ""); + TSS_TPMT_SENSITIVE_Print(&in->inPrivate.t.sensitiveArea, indent); + TSS_TPM2B_PUBLIC_Print("inPublic", &in->inPublic, indent); + TSS_TPM_HANDLE_Print("hierarchy", in->hierarchy, indent); + return; +} +void Load_In_Print(Load_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_Load\n", indent, ""); + TSS_TPM_HANDLE_Print("parentHandle", in->parentHandle, indent); + TSS_TPM2B_Print("inPrivate", indent, &in->inPrivate.b); + TSS_TPM2B_PUBLIC_Print("inPublic", &in->inPublic, indent); + return; +} +void MakeCredential_In_Print(MakeCredential_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_MakeCredential\n", indent, ""); + TSS_TPM_HANDLE_Print("handle", in->handle, indent); + TSS_TPM2B_Print("credential", indent, &in->credential.b); + TSS_TPM2B_Print("objectName", indent, &in->objectName.b); + return; +} +#if 0 +void NTC2_PreConfig_In_Print(NTC2_PreConfig_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_NTC2_PreConfig\n", indent, ""); + NTC2_CFG_STRUCT preConfig; + return; +} +#endif +void NV_Certify_In_Print(NV_Certify_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_NV_Certify\n", indent, ""); + TSS_TPM_HANDLE_Print("signHandle", in->signHandle, indent); + TSS_TPM_HANDLE_Print("authHandle", in->authHandle, indent); + TSS_TPM_HANDLE_Print("nvIndex", in->nvIndex, indent); + TSS_TPM2B_Print("qualifyingData", indent, &in->qualifyingData.b); + printf("%*s" "inScheme\n", indent, ""); + TSS_TPMT_SIG_SCHEME_Print(&in->inScheme, indent); + printf("%*s" "size %u\n", indent, "", in->size); + printf("%*s" "offset %u\n", indent, "", in->offset); + return; +} +void NV_ChangeAuth_In_Print(NV_ChangeAuth_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_NV_ChangeAuth\n", indent, ""); + TSS_TPM_HANDLE_Print("nvIndex", in->nvIndex, indent); + TSS_TPM2B_Print("newAuth", indent, &in->newAuth.b); + return; +} +void NV_DefineSpace_In_Print(NV_DefineSpace_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_NV_DefineSpace\n", indent, ""); + TSS_TPM_HANDLE_Print("authHandle", in->authHandle, indent); + TSS_TPM2B_Print("auth", indent, &in->auth.b); + printf("%*s" "publicInfo\n", indent, ""); + TSS_TPM2B_NV_PUBLIC_Print(&in->publicInfo, indent); + return; +} +void NV_Extend_In_Print(NV_Extend_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_NV_Extend\n", indent, ""); + TSS_TPM_HANDLE_Print("authHandle", in->authHandle, indent); + TSS_TPM_HANDLE_Print("nvIndex", in->nvIndex, indent); + TSS_TPM2B_Print("data", indent, &in->data.b); + return; +} +void NV_GlobalWriteLock_In_Print(NV_GlobalWriteLock_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_NV_GlobalWriteLock\n", indent, ""); + TSS_TPM_HANDLE_Print("authHandle", in->authHandle, indent); + return; +} +void NV_Increment_In_Print(NV_Increment_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_NV_Increment\n", indent, ""); + TSS_TPM_HANDLE_Print("authHandle", in->authHandle, indent); + TSS_TPM_HANDLE_Print("nvIndex", in->nvIndex, indent); + return; +} +void NV_ReadLock_In_Print(NV_ReadLock_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_NV_ReadLock\n", indent, ""); + TSS_TPM_HANDLE_Print("authHandle", in->authHandle, indent); + TSS_TPM_HANDLE_Print("nvIndex", in->nvIndex, indent); + return; +} +void NV_ReadPublic_In_Print(NV_ReadPublic_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_NV_ReadPublic\n", indent, ""); + TSS_TPM_HANDLE_Print("nvIndex", in->nvIndex, indent); + return; +} +void NV_Read_In_Print(NV_Read_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_NV_Read\n", indent, ""); + TSS_TPM_HANDLE_Print("authHandle", in->authHandle, indent); + TSS_TPM_HANDLE_Print("nvIndex", in->nvIndex, indent); + printf("%*s" "size %u\n", indent, "", in->size); + printf("%*s" "offset %u\n", indent, "", in->offset); + return; +} +void NV_SetBits_In_Print(NV_SetBits_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_NV_SetBits\n", indent, ""); + TSS_TPM_HANDLE_Print("authHandle", in->authHandle, indent); + TSS_TPM_HANDLE_Print("nvIndex", in->nvIndex, indent); + printf("%*s" "bits %"PRIx64"\n", indent, "", in->bits); + return; +} +void NV_UndefineSpaceSpecial_In_Print(NV_UndefineSpaceSpecial_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_NV_UndefineSpaceSpecial\n", indent, ""); + TSS_TPM_HANDLE_Print("nvIndex", in->nvIndex, indent); + TSS_TPM_HANDLE_Print("platform", in->platform, indent); + return; +} +void NV_UndefineSpace_In_Print(NV_UndefineSpace_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_NV_UndefineSpace\n", indent, ""); + TSS_TPM_HANDLE_Print("authHandle", in->authHandle, indent); + TSS_TPM_HANDLE_Print("nvIndex", in->nvIndex, indent); + return; +} +void NV_WriteLock_In_Print(NV_WriteLock_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_NV_WriteLock\n", indent, ""); + TSS_TPM_HANDLE_Print("authHandle", in->authHandle, indent); + TSS_TPM_HANDLE_Print("nvIndex", in->nvIndex, indent); + return; +} +void NV_Write_In_Print(NV_Write_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_NV_Write\n", indent, ""); + TSS_TPM_HANDLE_Print("authHandle", in->authHandle, indent); + TSS_TPM_HANDLE_Print("nvIndex", in->nvIndex, indent); + TSS_TPM2B_Print("data", indent, &in->data.b); + printf("%*s" "offset %u\n", indent, "", in->offset); + return; +} +void ObjectChangeAuth_In_Print(ObjectChangeAuth_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_ObjectChangeAuth\n", indent, ""); + TSS_TPM_HANDLE_Print("objectHandle", in->objectHandle, indent); + TSS_TPM_HANDLE_Print("parentHandle", in->parentHandle, indent); + TSS_TPM2B_Print("newAuth", indent, &in->newAuth.b); + return; +} +void PCR_Allocate_In_Print(PCR_Allocate_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_PCR_Allocate\n", indent, ""); + TSS_TPM_HANDLE_Print("authHandle", in->authHandle, indent); + TSS_TPML_PCR_SELECTION_Print(&in->pcrAllocation, indent); + return; +} +void PCR_Event_In_Print(PCR_Event_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_PCR_Event\n", indent, ""); + TSS_TPM_HANDLE_Print("pcrHandle", in->pcrHandle, indent); + TSS_TPM2B_Print("eventData", indent, &in->eventData.b); + return; +} +void PCR_Extend_In_Print(PCR_Extend_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_PCR_Extend\n", indent, ""); + TSS_TPM_HANDLE_Print("pcrHandle", in->pcrHandle, indent); + TSS_TPML_DIGEST_VALUES_Print(&in->digests, indent); + return; +} +void PCR_Read_In_Print(PCR_Read_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_PCR_Read\n", indent, ""); + TSS_TPML_PCR_SELECTION_Print(&in->pcrSelectionIn, indent); + return; +} +void PCR_Reset_In_Print(PCR_Reset_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_PCR_Reset\n", indent, ""); + TSS_TPM_HANDLE_Print("pcrHandle", in->pcrHandle, indent); + return; +} +void PCR_SetAuthPolicy_In_Print(PCR_SetAuthPolicy_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_PCR_SetAuthPolicy\n", indent, ""); + TSS_TPM_HANDLE_Print("authHandle", in->authHandle, indent); + TSS_TPM2B_Print("authPolicy", indent, &in->authPolicy.b); + TSS_TPM_ALG_ID_Print("hashAlg", in->hashAlg, indent); + TSS_TPM_HANDLE_Print("pcrNum", in->pcrNum, indent); + return; +} +void PCR_SetAuthValue_In_Print(PCR_SetAuthValue_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_PCR_SetAuthValue\n", indent, ""); + TSS_TPM_HANDLE_Print("pcrHandle", in->pcrHandle, indent); + TSS_TPM2B_Print("auth", indent, &in->auth.b); + return; +} +void PP_Commands_In_Print(PP_Commands_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_PP_Commands\n", indent, ""); + TSS_TPM_HANDLE_Print("auth", in->auth, indent); + TSS_TPML_CC_Print(&in->setList, indent); + TSS_TPML_CC_Print(&in->clearList, indent); + return; +} +void PolicyAuthValue_In_Print(PolicyAuthValue_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_PolicyAuthValue\n", indent, ""); + TSS_TPM_HANDLE_Print("policySession", in->policySession, indent); + return; +} +void PolicyAuthorizeNV_In_Print(PolicyAuthorizeNV_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_PolicyAuthorizeNV\n", indent, ""); + TSS_TPM_HANDLE_Print("authHandle", in->authHandle, indent); + TSS_TPM_HANDLE_Print("nvIndex", in->nvIndex, indent); + TSS_TPM_HANDLE_Print("policySession", in->policySession, indent); + return; +} +void PolicyAuthorize_In_Print(PolicyAuthorize_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_PolicyAuthorize\n", indent, ""); + TSS_TPM_HANDLE_Print("policySession", in->policySession, indent); + TSS_TPM2B_Print("approvedPolicy", indent, &in->approvedPolicy.b); + TSS_TPM2B_Print("policyRef", indent, &in->policyRef.b); + TSS_TPM2B_Print("keySign", indent, &in->keySign.b); + printf("%*s" "checkTicket\n", indent, ""); + TSS_TPMT_TK_VERIFIED_Print(&in->checkTicket, indent+2); + return; +} +void PolicyCommandCode_In_Print(PolicyCommandCode_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_PolicyCommandCode\n", indent, ""); + TSS_TPM_HANDLE_Print("policySession", in->policySession, indent); + TSS_TPM_CC_Print("code", in->code, indent); + return; +} +void PolicyCounterTimer_In_Print(PolicyCounterTimer_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_PolicyCounterTimer\n", indent, ""); + TSS_TPM_HANDLE_Print("policySession", in->policySession, indent); + TSS_TPM2B_Print("operandB", indent, &in->operandB.b); + printf("%*s" "offset %u\n", indent, "", in->offset); + TSS_TPM_EO_Print("operation", in->operation, indent); + return; +} +void PolicyCpHash_In_Print(PolicyCpHash_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_PolicyCpHash\n", indent, ""); + TSS_TPM_HANDLE_Print("policySession", in->policySession, indent); + TSS_TPM2B_Print("cpHashA", indent, &in->cpHashA.b); + return; +} +void PolicyDuplicationSelect_In_Print(PolicyDuplicationSelect_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_PolicyDuplicationSelect\n", indent, ""); + TSS_TPM_HANDLE_Print("policySession", in->policySession, indent); + TSS_TPM2B_Print("objectName", indent, &in->objectName.b); + TSS_TPM2B_Print("newParentName", indent, &in->newParentName.b); + TSS_TPMI_YES_NO_Print("includeObject", in->includeObject, indent); + return; +} +void PolicyGetDigest_In_Print(PolicyGetDigest_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_PolicyGetDigest\n", indent, ""); + TSS_TPM_HANDLE_Print("policySession", in->policySession, indent); + return; +} +void PolicyLocality_In_Print(PolicyLocality_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_PolicyLocality\n", indent, ""); + TSS_TPM_HANDLE_Print("policySession", in->policySession, indent); + TSS_TPMA_LOCALITY_Print(in->locality, indent); + return; +} +void PolicyNV_In_Print(PolicyNV_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_PolicyNV\n", indent, ""); + TSS_TPM_HANDLE_Print("authHandle", in->authHandle, indent); + TSS_TPM_HANDLE_Print("nvIndex", in->nvIndex, indent); + TSS_TPM_HANDLE_Print("policySession", in->policySession, indent); + TSS_TPM2B_Print("operandB", indent, &in->operandB.b); + printf("%*s" "offset %u\n", indent, "", in->offset); + TSS_TPM_EO_Print("operation", in->operation, indent); + return; +} +void PolicyNameHash_In_Print(PolicyNameHash_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_PolicyNameHash\n", indent, ""); + TSS_TPM_HANDLE_Print("policySession", in->policySession, indent); + TSS_TPM2B_Print("nameHash", indent, &in->nameHash.b); + return; +} +void PolicyNvWritten_In_Print(PolicyNvWritten_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_PolicyNvWritten\n", indent, ""); + TSS_TPM_HANDLE_Print("policySession", in->policySession, indent); + TSS_TPMI_YES_NO_Print("writtenSet", in->writtenSet, indent); + return; +} +void PolicyOR_In_Print(PolicyOR_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_PolicyOR\n", indent, ""); + TSS_TPM_HANDLE_Print("policySession", in->policySession, indent); + printf("%*s" "pHashList\n", indent, ""); + TSS_TPML_DIGEST_Print(&in->pHashList, indent+2); + return; +} +void PolicyPCR_In_Print(PolicyPCR_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_PolicyPCR\n", indent, ""); + TSS_TPM_HANDLE_Print("policySession", in->policySession, indent); + TSS_TPM2B_Print("pcrDigest", indent, &in->pcrDigest.b); + TSS_TPML_PCR_SELECTION_Print(&in->pcrs, indent); + return; +} +void PolicyPassword_In_Print(PolicyPassword_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_PolicyPassword\n", indent, ""); + TSS_TPM_HANDLE_Print("policySession", in->policySession, indent); + return; +} +void PolicyPhysicalPresence_In_Print(PolicyPhysicalPresence_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_PolicyPhysicalPresence\n", indent, ""); + TSS_TPM_HANDLE_Print("policySession", in->policySession, indent); + return; +} +void PolicyRestart_In_Print(PolicyRestart_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_PolicyRestart\n", indent, ""); + TSS_TPM_HANDLE_Print("sessionHandle", in->sessionHandle, indent); + return; +} +void PolicySecret_In_Print(PolicySecret_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_PolicySecret\n", indent, ""); + TSS_TPM_HANDLE_Print("authHandle", in->authHandle, indent); + TSS_TPM_HANDLE_Print("policySession", in->policySession, indent); + TSS_TPM2B_Print("nonceTPM", indent, &in->nonceTPM.b); + TSS_TPM2B_Print("cpHashA", indent, &in->cpHashA.b); + TSS_TPM2B_Print("policyRef", indent, &in->policyRef.b); + printf("%*s" "expiration %d\n", indent, "", in->expiration); + return; +} +void PolicySigned_In_Print(PolicySigned_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_PolicySigned\n", indent, ""); + TSS_TPM_HANDLE_Print("authObject", in->authObject, indent); + TSS_TPM_HANDLE_Print("policySession", in->policySession, indent); + TSS_TPM2B_Print("nonceTPM", indent, &in->nonceTPM.b); + TSS_TPM2B_Print("cpHashA", indent, &in->cpHashA.b); + TSS_TPM2B_Print("policyRef", indent, &in->policyRef.b); + printf("%*s" "expiration %d\n", indent, "", in->expiration); + printf("%*s" "auth\n", indent, ""); + TSS_TPMT_SIGNATURE_Print(&in->auth, indent+2); + return; +} +void PolicyTemplate_In_Print(PolicyTemplate_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_PolicyTemplate\n", indent, ""); + TSS_TPM_HANDLE_Print("policySession", in->policySession, indent); + TSS_TPM2B_Print("templateHash", indent, &in->templateHash.b); + return; +} +void PolicyTicket_In_Print(PolicyTicket_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_PolicyTicket\n", indent, ""); + TSS_TPM_HANDLE_Print("policySession", in->policySession, indent); + TSS_TPM2B_Print("timeout", indent, &in->timeout.b); + TSS_TPM2B_Print("cpHashA", indent, &in->cpHashA.b); + TSS_TPM2B_Print("policyRef", indent, &in->policyRef.b); + TSS_TPM2B_Print("authName", indent, &in->authName.b); + printf("%*s" "ticket\n", indent, ""); + TSS_TPMT_TK_AUTH_Print(&in->ticket, indent+2); + return; +} +void Quote_In_Print(Quote_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_Quote\n", indent, ""); + TSS_TPM_HANDLE_Print("signHandle", in->signHandle, indent); + TSS_TPM2B_Print("qualifyingData", indent, &in->qualifyingData.b); + printf("%*s" "inScheme\n", indent, ""); + TSS_TPMT_SIG_SCHEME_Print(&in->inScheme, indent); + TSS_TPML_PCR_SELECTION_Print(&in->PCRselect, indent); + return; +} +void RSA_Decrypt_In_Print(RSA_Decrypt_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_RSA_Decrypt\n", indent, ""); + TSS_TPM_HANDLE_Print("keyHandle", in->keyHandle, indent); + TSS_TPM2B_Print("cipherText", indent, &in->cipherText.b); + printf("%*s" "inScheme\n", indent, ""); + TSS_TPMT_RSA_DECRYPT_Print(&in->inScheme, indent); + TSS_TPM2B_Print("label", indent, &in->label.b); + return; +} +void RSA_Encrypt_In_Print(RSA_Encrypt_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_RSA_Encrypt\n", indent, ""); + TSS_TPM_HANDLE_Print("keyHandle", in->keyHandle, indent); + TSS_TPM2B_Print("message", indent, &in->message.b); + printf("%*s" "inScheme\n", indent, ""); + TSS_TPMT_RSA_DECRYPT_Print(&in->inScheme, indent); + TSS_TPM2B_Print("label", indent, &in->label.b); + return; +} +void ReadPublic_In_Print(ReadPublic_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_ReadPublic\n", indent, ""); + TSS_TPM_HANDLE_Print("objectHandle", in->objectHandle, indent); + return; +} +void Rewrap_In_Print(Rewrap_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_Rewrap\n", indent, ""); + TSS_TPM_HANDLE_Print("oldParent", in->oldParent, indent); + TSS_TPM_HANDLE_Print("newParent", in->newParent, indent); + TSS_TPM2B_Print("inDuplicate", indent, &in->inDuplicate.b); + TSS_TPM2B_Print("name", indent, &in->name.b); + TSS_TPM2B_Print("inSymSeed", indent, &in->inSymSeed.b); + return; +} +void SelfTest_In_Print(SelfTest_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_SelfTest\n", indent, ""); + TSS_TPMI_YES_NO_Print("fullTest", in->fullTest, indent); + return; +} +void SequenceComplete_In_Print(SequenceComplete_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_SequenceComplete\n", indent, ""); + TSS_TPM_HANDLE_Print("sequenceHandle", in->sequenceHandle, indent); + TSS_TPM2B_Print("buffer", indent, &in->buffer.b); + TSS_TPM_HANDLE_Print("hierarchy", in->hierarchy, indent); + return; +} +void SequenceUpdate_In_Print(SequenceUpdate_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_SequenceUpdate\n", indent, ""); + TSS_TPM_HANDLE_Print("sequenceHandle", in->sequenceHandle, indent); + TSS_TPM2B_Print("buffer", indent, &in->buffer.b); + return; +} +void SetAlgorithmSet_In_Print(SetAlgorithmSet_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_SetAlgorithmSet\n", indent, ""); + TSS_TPM_HANDLE_Print("authHandle", in->authHandle, indent); + printf("%*s" "algorithmSet %08x\n", indent, "", in->algorithmSet); + return; +} +void SetCommandCodeAuditStatus_In_Print(SetCommandCodeAuditStatus_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_SetCommandCodeAuditStatus\n", indent, ""); + TSS_TPM_HANDLE_Print("auth", in->auth, indent); + TSS_TPM_ALG_ID_Print("auditAlg", in->auditAlg, indent); + TSS_TPML_CC_Print(&in->setList, indent); + TSS_TPML_CC_Print(&in->clearList, indent); + return; +} +void SetPrimaryPolicy_In_Print(SetPrimaryPolicy_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_SetPrimaryPolicy\n", indent, ""); + TSS_TPM_HANDLE_Print("authHandle", in->authHandle, indent); + TSS_TPM2B_Print("authPolicy", indent, &in->authPolicy.b); + TSS_TPM_ALG_ID_Print("hashAlg", in->hashAlg, indent); + return; +} +void Shutdown_In_Print(Shutdown_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_Shutdown\n", indent, ""); + TSS_TPM_SU_Print("shutdownType", in->shutdownType, indent); + return; +} +void Sign_In_Print(Sign_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_Sign\n", indent, ""); + TSS_TPM_HANDLE_Print("keyHandle", in->keyHandle, indent); + TSS_TPM2B_Print("digest", indent, &in->digest.b); + printf("%*s" "inScheme\n", indent, ""); + TSS_TPMT_SIG_SCHEME_Print(&in->inScheme, indent); + printf("%*s" "validation\n", indent, ""); + TSS_TPMT_TK_HASHCHECK_Print(&in->validation, indent+2); + return; +} +void StartAuthSession_In_Print(StartAuthSession_In *in, unsigned int indent) +{ +// printf("%*s" "TPM2_StartAuthSession\n", indent, ""); + printf("TPM2_StartAuthSession\n"); + TSS_TPM_HANDLE_Print("tpmKey", in->tpmKey, indent); + TSS_TPM_HANDLE_Print("bind", in->bind, indent); + TSS_TPM2B_Print("nonceCaller", indent, &in->nonceCaller.b); + TSS_TPM2B_Print("encryptedSalt", indent, &in->encryptedSalt.b); + TSS_TPM_SE_Print("sessionType", in->sessionType, indent); + TSS_TPMT_SYM_DEF_Print(&in->symmetric, indent); + TSS_TPM_ALG_ID_Print("authHash", in->authHash, indent); + return; +} +void Startup_In_Print(Startup_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_Startup\n", indent, ""); + TSS_TPM_SU_Print("startupType", in->startupType, indent); + return; +} +void StirRandom_In_Print(StirRandom_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_StirRandom\n", indent, ""); + TSS_TPM2B_Print("inData", indent, &in->inData.b); + return; +} +void TestParms_In_Print(TestParms_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_TestParms\n", indent, ""); + TSS_TPMT_PUBLIC_PARMS_Print(&in->parameters, indent); + return; +} +void Unseal_In_Print(Unseal_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_Unseal\n", indent, ""); + TSS_TPM_HANDLE_Print("itemHandle", in->itemHandle, indent); + return; +} +void VerifySignature_In_Print(VerifySignature_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_VerifySignature\n", indent, ""); + TSS_TPM_HANDLE_Print("keyHandle", in->keyHandle, indent); + TSS_TPM2B_Print("digest", indent, &in->digest.b); + printf("%*s" "signature\n", indent, ""); + TSS_TPMT_SIGNATURE_Print(&in->signature, indent); + return; +} +void ZGen_2Phase_In_Print(ZGen_2Phase_In *in, unsigned int indent) +{ + printf("%*s" "TPM2_ZGen_2Phase\n", indent, ""); + TSS_TPM_HANDLE_Print("keyA", in->keyA, indent); + TSS_TPM2B_ECC_POINT_Print("inQsB", &in->inQsB, indent); + TSS_TPM2B_ECC_POINT_Print("inQsB", &in->inQeB, indent); + TSS_TPM_ALG_ID_Print("inScheme", in->inScheme, indent); + printf("%*s" "counter %u\n", indent, "", in->counter); + return; +} diff --git a/libstb/tss2/tssproperties.c b/libstb/tss2/tssproperties.c new file mode 100644 index 0000000..bae4712 --- /dev/null +++ b/libstb/tss2/tssproperties.c @@ -0,0 +1,535 @@ +/********************************************************************************/ +/* */ +/* TSS Configuration Properties */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* */ +/* (c) Copyright IBM Corporation 2015 - 2019. */ +/* */ +/* All rights reserved. */ +/* */ +/* Redistribution and use in source and binary forms, with or without */ +/* modification, are permitted provided that the following conditions are */ +/* met: */ +/* */ +/* Redistributions of source code must retain the above copyright notice, */ +/* this list of conditions and the following disclaimer. */ +/* */ +/* 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. */ +/* */ +/* Neither the names of the IBM Corporation nor the names of its */ +/* contributors may be used to endorse or promote products derived from */ +/* this software without specific prior written permission. */ +/* */ +/* 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. */ +/********************************************************************************/ + +#include <stdlib.h> +#include <string.h> +#include <stdarg.h> +#include <errno.h> +#include <stdio.h> +#include <stdlib.h> + +#include <ibmtss/tss.h> +#include <ibmtss/tsstransmit.h> +#ifndef TPM_TSS_NOCRYPTO +#include <ibmtss/tsscrypto.h> +#endif +#include <ibmtss/tssprint.h> + +#include "tssproperties.h" + +/* For systems where there are no environment variables, GETENV returns NULL. This simulates the + situation when an environment variable is not set, causing the compiled in default to be used. */ +#ifndef TPM_TSS_NOENV +#define GETENV(x) getenv(x) +#else +#define GETENV(x) NULL +#endif + +/* local prototypes */ + +static TPM_RC TSS_SetTraceLevel(const char *value); +static TPM_RC TSS_SetDataDirectory(TSS_CONTEXT *tssContext, const char *value); +static TPM_RC TSS_SetCommandPort(TSS_CONTEXT *tssContext, const char *value); +static TPM_RC TSS_SetPlatformPort(TSS_CONTEXT *tssContext, const char *value); +static TPM_RC TSS_SetServerName(TSS_CONTEXT *tssContext, const char *value); +static TPM_RC TSS_SetServerType(TSS_CONTEXT *tssContext, const char *value); +static TPM_RC TSS_SetInterfaceType(TSS_CONTEXT *tssContext, const char *value); +static TPM_RC TSS_SetDevice(TSS_CONTEXT *tssContext, const char *value); +static TPM_RC TSS_SetEncryptSessions(TSS_CONTEXT *tssContext, const char *value); + +/* globals for the library */ + +/* tracing is global to avoid passing the context into every function call */ +int tssVerbose = 1; /* initial value so TSS_Properties_Init errors emit message */ +int tssVverbose = 1; + +/* This is a total hack to ensure that the global verbose flags are only set once. It's used by the + two entry points to the TSS, TSS_Create() and TSS_SetProperty() */ + +int tssFirstCall = TRUE; + +/* defaults for global settings */ + +#ifndef TPM_TRACE_LEVEL_DEFAULT +#define TPM_TRACE_LEVEL_DEFAULT "0" +#endif + +#ifndef TPM_COMMAND_PORT_DEFAULT +#define TPM_COMMAND_PORT_DEFAULT "2321" /* default for MS simulator */ +#endif + +#ifndef TPM_PLATFORM_PORT_DEFAULT +#define TPM_PLATFORM_PORT_DEFAULT "2322" /* default for MS simulator */ +#endif + +#ifndef TPM_SERVER_NAME_DEFAULT +#define TPM_SERVER_NAME_DEFAULT "localhost" /* default to local machine */ +#endif + +#ifndef TPM_SERVER_TYPE_DEFAULT +#define TPM_SERVER_TYPE_DEFAULT "mssim" /* default to MS simulator format */ +#endif + +#ifndef TPM_DATA_DIR_DEFAULT +#define TPM_DATA_DIR_DEFAULT "." /* default to current working directory */ +#endif + +#ifndef TPM_INTERFACE_TYPE_DEFAULT +#ifndef TPM_NOSOCKET +#define TPM_INTERFACE_TYPE_DEFAULT "socsim" /* default to MS simulator interface */ +#else +#define TPM_INTERFACE_TYPE_DEFAULT "dev" /* if no sockets, default to device driver */ +#endif +#endif + +#ifndef TPM_DEVICE_DEFAULT +#ifdef TPM_POSIX +#define TPM_DEVICE_DEFAULT "/dev/tpm0" /* default to Linux device driver */ +#endif +#ifdef TPM_WINDOWS +#define TPM_DEVICE_DEFAULT "tddl.dll" /* default to Windows TPM interface dll */ +#endif +#endif + +#ifndef TPM_ENCRYPT_SESSIONS_DEFAULT +#define TPM_ENCRYPT_SESSIONS_DEFAULT "1" +#endif + +/* TSS_GlobalProperties_Init() sets the global verbose trace flags at the first entry points to the + TSS */ + +TPM_RC TSS_GlobalProperties_Init(void) +{ + TPM_RC rc = 0; + const char *value; + + /* trace level is global, tssContext can be null */ + if (rc == 0) { + value = GETENV("TPM_TRACE_LEVEL"); + rc = TSS_SetTraceLevel(value); + } + return rc; +} + + +/* TSS_Properties_Init() sets the initial TSS_CONTEXT properties based on either the environment + variables (if set) or the defaults (if not). +*/ + +TPM_RC TSS_Properties_Init(TSS_CONTEXT *tssContext) +{ + TPM_RC rc = 0; + const char *value; + + if (rc == 0) { + tssContext->tssAuthContext = NULL; + tssContext->tssFirstTransmit = TRUE; /* connection not opened */ + tssContext->tpm12Command = FALSE; +#ifdef TPM_WINDOWS + tssContext->sock_fd = INVALID_SOCKET; +#endif +#ifdef TPM_POSIX +#ifndef TPM_NOSOCKET + tssContext->sock_fd = -1; +#endif /* TPM_NOSOCKET */ +#endif + tssContext->dev_fd = -1; +#ifdef TPM_WINDOWS +#ifdef TPM_WINDOWS_TBSI +#endif +#endif +#ifndef TPM_TSS_NOCRYPTO +#ifndef TPM_TSS_NOFILE + tssContext->tssSessionEncKey = NULL; + tssContext->tssSessionDecKey = NULL; +#endif +#endif + } + /* for a minimal TSS with no file support */ +#ifdef TPM_TSS_NOFILE + { + size_t i; + for (i = 0 ; i < (sizeof(tssContext->sessions) / sizeof(TSS_SESSIONS)) ; i++) { + tssContext->sessions[i].sessionHandle = TPM_RH_NULL; + tssContext->sessions[i].sessionData = NULL; + tssContext->sessions[i].sessionDataLength = 0; + } + for (i = 0 ; i < (sizeof(tssContext->objectPublic) / sizeof(TSS_OBJECT_PUBLIC)) ; i++) { + tssContext->objectPublic[i].objectHandle = TPM_RH_NULL; + } + for (i = 0 ; i < (sizeof(tssContext->nvPublic) / sizeof(TSS_NVPUBLIC)) ; i++) { + tssContext->nvPublic[i].nvIndex = TPM_RH_NULL; + } + } +#endif + /* data directory */ + if (rc == 0) { + value = GETENV("TPM_DATA_DIR"); + rc = TSS_SetDataDirectory(tssContext, value); + } + /* flag whether session state should be encrypted */ + if (rc == 0) { + value = GETENV("TPM_ENCRYPT_SESSIONS"); + rc = TSS_SetEncryptSessions(tssContext, value); + } + /* TPM socket command port */ + if (rc == 0) { + value = GETENV("TPM_COMMAND_PORT"); + rc = TSS_SetCommandPort(tssContext, value); + } + /* TPM simulator socket platform port */ + if (rc == 0) { + value = GETENV("TPM_PLATFORM_PORT"); + rc = TSS_SetPlatformPort(tssContext, value); + } + /* TPM socket host name */ + if (rc == 0) { + value = GETENV("TPM_SERVER_NAME"); + rc = TSS_SetServerName(tssContext, value); + } + /* TPM socket server type */ + if (rc == 0) { + value = GETENV("TPM_SERVER_TYPE"); + rc = TSS_SetServerType(tssContext, value); + } + /* TPM interface type */ + if (rc == 0) { + value = GETENV("TPM_INTERFACE_TYPE"); + rc = TSS_SetInterfaceType(tssContext, value); + } + /* TPM device within the interface type */ + if (rc == 0) { + value = GETENV("TPM_DEVICE"); + rc = TSS_SetDevice(tssContext, value); + } + return rc; +} + +/* TSS_SetProperty() sets the property to the value. + + The format of the property and value the same as that of the environment variable. + + A NULL value sets the property to the default. +*/ + +TPM_RC TSS_SetProperty(TSS_CONTEXT *tssContext, + int property, + const char *value) +{ + TPM_RC rc = 0; + + /* at the first call to the TSS, initialize global variables */ + if (tssFirstCall) { +#ifdef TSS_CRYPTO_INIT + /* crypto module initializations */ + if (rc == 0) { + rc = TSS_Crypto_Init(); + } +#endif + if (rc == 0) { + rc = TSS_GlobalProperties_Init(); + } + tssFirstCall = FALSE; + } + if (rc == 0) { + switch (property) { + case TPM_TRACE_LEVEL: + rc = TSS_SetTraceLevel(value); + break; + case TPM_DATA_DIR: + rc = TSS_SetDataDirectory(tssContext, value); + break; + case TPM_COMMAND_PORT: + rc = TSS_SetCommandPort(tssContext, value); + break; + case TPM_PLATFORM_PORT: + rc = TSS_SetPlatformPort(tssContext, value); + break; + case TPM_SERVER_NAME: + rc = TSS_SetServerName(tssContext, value); + break; + case TPM_SERVER_TYPE: + rc = TSS_SetServerType(tssContext, value); + break; + case TPM_INTERFACE_TYPE: + rc = TSS_SetInterfaceType(tssContext, value); + break; + case TPM_DEVICE: + rc = TSS_SetDevice(tssContext, value); + break; + case TPM_ENCRYPT_SESSIONS: + rc = TSS_SetEncryptSessions(tssContext, value); + break; + default: + rc = TSS_RC_BAD_PROPERTY; + } + } + return rc; +} + +/* TSS_SetTraceLevel() sets the trace level. + + 0: no printing + 1: error printing + 2: trace printing +*/ + +static TPM_RC TSS_SetTraceLevel(const char *value) +{ + TPM_RC rc = 0; + int irc = 0; + int level; + + if (rc == 0) { + if (value == NULL) { + value = TPM_TRACE_LEVEL_DEFAULT; + } + } +#if !defined(__ULTRAVISOR__) && !defined(__SKIBOOT__) + if (rc == 0) { + irc = sscanf(value, "%u", &level); + if (irc != 1) { + if (tssVerbose) printf("TSS_SetTraceLevel: Error, value invalid\n"); + rc = TSS_RC_BAD_PROPERTY_VALUE; + } + } +#else /* disable tracing within the ultravisor, which doesn't implement sscanf() anyway */ + irc = irc; + level = 2; +#endif + if (rc == 0) { + switch (level) { + case 0: + tssVerbose = FALSE; + tssVverbose = FALSE; + break; + case 1: + tssVerbose = TRUE; + tssVverbose = FALSE; + break; + default: + tssVerbose = TRUE; + tssVverbose = TRUE; + break; + } + } + return rc; +} + +static TPM_RC TSS_SetDataDirectory(TSS_CONTEXT *tssContext, const char *value) +{ + TPM_RC rc = 0; + + if (rc == 0) { + if (value == NULL) { + value = TPM_DATA_DIR_DEFAULT; + } + } + if (rc == 0) { + tssContext->tssDataDirectory = value; + /* appended to this is 17 characters /cccnnnnnnnn.bin[nul], add a bit of margin for future + prefixes */ + if (strlen(value) > (TPM_DATA_DIR_PATH_LENGTH - 24)) { + if (tssVerbose) printf("TSS_SetDataDirectory: Error, value too long\n"); + rc = TSS_RC_BAD_PROPERTY_VALUE; + } + } + return rc; +} + +static TPM_RC TSS_SetCommandPort(TSS_CONTEXT *tssContext, const char *value) +{ + TPM_RC rc = 0; + int irc = 0; + + /* close an open connection before changing property */ + if (rc == 0) { + rc = TSS_Close(tssContext); + } + if (rc == 0) { + if (value == NULL) { + value = TPM_COMMAND_PORT_DEFAULT; + } + } +#if !defined(__ULTRAVISOR__) && !defined(__SKIBOOT__) + if (rc == 0) { + irc = sscanf(value, "%hu", &tssContext->tssCommandPort); + if (irc != 1) { + if (tssVerbose) printf("TSS_SetCommandPort: Error, value invalid\n"); + rc = TSS_RC_BAD_PROPERTY_VALUE; + } + } +#else /* disable within the ultravisor, which doesn't implement sscanf() anyway. It's a don't + care because the ultravisor does not use sockets. */ + tssContext->tssCommandPort = 0; + irc = irc; +#endif + return rc; +} + +static TPM_RC TSS_SetPlatformPort(TSS_CONTEXT *tssContext, const char *value) +{ + TPM_RC rc = 0; + int irc = 0; + + /* close an open connection before changing property */ + if (rc == 0) { + rc = TSS_Close(tssContext); + } + if (rc == 0) { + if (value == NULL) { + value = TPM_PLATFORM_PORT_DEFAULT; + } + } +#if !defined(__ULTRAVISOR__) && !defined(__SKIBOOT__) + if (rc == 0) { + irc = sscanf(value, "%hu", &tssContext->tssPlatformPort); + if (irc != 1) { + if (tssVerbose) printf("TSS_SetPlatformPort: Error, , value invalid\n"); + rc = TSS_RC_BAD_PROPERTY_VALUE; + } + } +#else /* disable within the ultravisor, which doesn't implement sscanf() anyway. It's a don't + care because the ultravisor does not use sockets. */ + tssContext->tssPlatformPort = 0; + irc = irc; +#endif + return rc; +} + +static TPM_RC TSS_SetServerName(TSS_CONTEXT *tssContext, const char *value) +{ + TPM_RC rc = 0; + + /* close an open connection before changing property */ + if (rc == 0) { + rc = TSS_Close(tssContext); + } + if (rc == 0) { + if (value == NULL) { + value = TPM_SERVER_NAME_DEFAULT; + } + } + if (rc == 0) { + tssContext->tssServerName = value; + } + return rc; +} + +static TPM_RC TSS_SetServerType(TSS_CONTEXT *tssContext, const char *value) +{ + TPM_RC rc = 0; + + /* close an open connection before changing property */ + if (rc == 0) { + rc = TSS_Close(tssContext); + } + if (rc == 0) { + if (value == NULL) { + value = TPM_SERVER_TYPE_DEFAULT; + } + } + if (rc == 0) { + tssContext->tssServerType = value; + } + return rc; +} + +static TPM_RC TSS_SetInterfaceType(TSS_CONTEXT *tssContext, const char *value) +{ + TPM_RC rc = 0; + + /* close an open connection before changing property */ + if (rc == 0) { + rc = TSS_Close(tssContext); + } + if (rc == 0) { + if (value == NULL) { + value = TPM_INTERFACE_TYPE_DEFAULT; + } + } + if (rc == 0) { + tssContext->tssInterfaceType = value; + } + return rc; +} + +static TPM_RC TSS_SetDevice(TSS_CONTEXT *tssContext, const char *value) +{ + TPM_RC rc = 0; + + /* close an open connection before changing property */ + if (rc == 0) { + rc = TSS_Close(tssContext); + } + if (rc == 0) { + if (value == NULL) { + value = TPM_DEVICE_DEFAULT; + } + } + if (rc == 0) { + tssContext->tssDevice = value; + } + return rc; +} + +static TPM_RC TSS_SetEncryptSessions(TSS_CONTEXT *tssContext, const char *value) +{ + TPM_RC rc = 0; + int irc = 0; + + if (rc == 0) { + if (value == NULL) { + value = TPM_ENCRYPT_SESSIONS_DEFAULT; + } + } +#if !defined(__ULTRAVISOR__) && !defined(__SKIBOOT__) + if (rc == 0) { + irc = sscanf(value, "%u", &tssContext->tssEncryptSessions); + if (irc != 1) { + if (tssVerbose) printf("TSS_SetEncryptSessions: Error, value invalid\n"); + rc = TSS_RC_BAD_PROPERTY_VALUE; + } + } +#else /* disable within the ultravisor, which doesn't implement sscanf() anyway. It's a don't + care because the ultravisor does not use files. */ + tssContext->tssEncryptSessions = TRUE; + irc = irc; +#endif + return rc; +} diff --git a/libstb/tss2/tssproperties.h b/libstb/tss2/tssproperties.h new file mode 100644 index 0000000..8e94f4d --- /dev/null +++ b/libstb/tss2/tssproperties.h @@ -0,0 +1,193 @@ +/********************************************************************************/ +/* */ +/* TSS Configuration Properties */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: tssproperties.h 1257 2018-06-27 20:52:08Z kgoldman $ */ +/* */ +/* (c) Copyright IBM Corporation 2015. */ +/* */ +/* All rights reserved. */ +/* */ +/* Redistribution and use in source and binary forms, with or without */ +/* modification, are permitted provided that the following conditions are */ +/* met: */ +/* */ +/* Redistributions of source code must retain the above copyright notice, */ +/* this list of conditions and the following disclaimer. */ +/* */ +/* 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. */ +/* */ +/* Neither the names of the IBM Corporation nor the names of its */ +/* contributors may be used to endorse or promote products derived from */ +/* this software without specific prior written permission. */ +/* */ +/* 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. */ +/********************************************************************************/ + +/* This is an internal TSS file, subject to change. Applications should not include it. */ + +#ifndef TSSPROPERTIES_H +#define TSSPROPERTIES_H + +#include <ibmtss/TPM_Types.h> + +#ifdef TPM_WINDOWS + +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#endif + +#include <winsock2.h> +#include <windows.h> +#include <specstrings.h> + +#ifdef __SKIBOOT__ +#include <libstb/tpm2.h> +#endif + +#ifdef TPM_WINDOWS_TBSI +/* Windows 7 */ +#if defined TPM_WINDOWS_TBSI_WIN7 +#include <c:/progra~1/Micros~2/Windows/v7.1/include/tbs.h> +/* Windows 8, 10 */ +#elif defined TPM_WINDOWS_TBSI_WIN8 +#include <tbs.h> +#else +#error "Must define either TPM_WINDOWS_TBSI_WIN7 or TPM_WINDOWS_TBSI_WIN8" +#endif +#endif + +typedef SOCKET TSS_SOCKET_FD; +#endif /* TPM_WINDOWS */ + +#ifdef TPM_POSIX +#ifndef TPM_NOSOCKET +typedef int TSS_SOCKET_FD; +#endif /* TPM_NOSOCKET */ +#endif /* TPM_POSIX */ + +/* There doesn't seem to be a portable Unix MAXPATHLEN variable, so pick a large number. The + directory length will be (currently) 17 bytes smaller. */ +#define TPM_DATA_DIR_PATH_LENGTH 256 + +#ifdef __cplusplus +extern "C" { +#endif + +#include <ibmtss/tss.h> +#include "tssauth.h" + + /* Structure to hold session data within the context */ + + typedef struct TSS_SESSIONS { + TPMI_SH_AUTH_SESSION sessionHandle; + uint8_t *sessionData; + uint16_t sessionDataLength; + } TSS_SESSIONS; + + /* Structure to hold transient or persistent object data within the context */ + + typedef struct TSS_OBJECT_PUBLIC { + TPM_HANDLE objectHandle; + TPM2B_NAME name; + TPM2B_PUBLIC objectPublic; + } TSS_OBJECT_PUBLIC; + + /* Structure to hold NV index data within the context */ + + typedef struct TSS_NVPUBLIC { + TPMI_RH_NV_INDEX nvIndex; + TPM2B_NAME name; + TPMS_NV_PUBLIC nvPublic; + } TSS_NVPUBLIC; + + /* Context for TSS global parameters. + + NOTE: Keep this in sync with TSS_Properties_Init() and TSS_Delete() */ + + struct TSS_CONTEXT { + + TSS_AUTH_CONTEXT *tssAuthContext; + + /* directory for persistant storage */ + const char *tssDataDirectory; + + /* encrypt saved session state */ + int tssEncryptSessions; + + /* saved session encryption key. This seems to port to openssl 1.0 and 1.1, but will have to + become a malloced void * for other crypto libraries. */ +#ifndef TPM_TSS_NOCRYPTO + void *tssSessionEncKey; + void *tssSessionDecKey; +#endif + /* a minimal TSS with no file support stores the sessions, objects, and NV metadata in a + structure. Scripting will not work, and persistent objects will not work, but a single + application will otherwise work. */ +#ifdef TPM_TSS_NOFILE + TSS_SESSIONS sessions[MAX_ACTIVE_SESSIONS]; + TSS_OBJECT_PUBLIC objectPublic[64]; + TSS_NVPUBLIC nvPublic[64]; +#endif + /* ports, host name, server (packet) type for socket interface */ + short tssCommandPort; + short tssPlatformPort; + const char *tssServerName; + const char *tssServerType; + + /* interface type */ + const char *tssInterfaceType; + + /* device driver interface */ + const char *tssDevice; + + /* TRUE for the first time through, indicates that interface open must occur */ + int tssFirstTransmit; + int tpm12Command; /* TRUE for TPM 1.2 command */ + + /* socket file descriptor */ +#ifndef TPM_NOSOCKET + TSS_SOCKET_FD sock_fd; +#endif /* TPM_NOSOCKET */ + + /* Linux device file descriptor */ + int dev_fd; + + /* Windows device driver handle */ +#ifdef TPM_WINDOWS +#ifdef TPM_WINDOWS_TBSI + TBS_HCONTEXT hContext; +#endif +#endif +#ifdef __ULTRAVISOR__ + void *uv_ctx; +#endif +#ifdef __SKIBOOT__ + struct tpm_dev *tpm_device; + struct tpm_driver *tpm_driver; +#endif + }; + + TPM_RC TSS_GlobalProperties_Init(void); + TPM_RC TSS_Properties_Init(TSS_CONTEXT *tssContext); + +#ifdef __cplusplus +} +#endif + + + +#endif diff --git a/libstb/tss2/tssresponsecode.c b/libstb/tss2/tssresponsecode.c new file mode 100644 index 0000000..d49d4dd --- /dev/null +++ b/libstb/tss2/tssresponsecode.c @@ -0,0 +1,521 @@ +/********************************************************************************/ +/* */ +/* TPM2 Response Code Printer */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: tssresponsecode.c 1257 2018-06-27 20:52:08Z kgoldman $ */ +/* */ +/* (c) Copyright IBM Corporation 2015, 2017. */ +/* */ +/* All rights reserved. */ +/* */ +/* Redistribution and use in source and binary forms, with or without */ +/* modification, are permitted provided that the following conditions are */ +/* met: */ +/* */ +/* Redistributions of source code must retain the above copyright notice, */ +/* this list of conditions and the following disclaimer. */ +/* */ +/* 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. */ +/* */ +/* Neither the names of the IBM Corporation nor the names of its */ +/* contributors may be used to endorse or promote products derived from */ +/* this software without specific prior written permission. */ +/* */ +/* 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. */ +/********************************************************************************/ + +#include <stdint.h> +#include <stdlib.h> + +#include <ibmtss/tssresponsecode.h> +#include <ibmtss/tsserror.h> +#ifdef TPM_TPM12 +#include <ibmtss/tsserror12.h> +#endif +#include <ibmtss/tssprint.h> + +/* The intended usage is: + + const char *msg; + const char *submsg; + const char *num; + + TSS_ResponseCode_toString(&msg, &submsg, &num, rc); + + printf("%s%s%s\n", msg, submsg, num); +*/ + +/* 39.4 Response Code Details */ + +/* tables to map response code to text */ + +typedef struct { + TPM_RC rc; + const char *text; +} RC_TABLE; + +#ifdef TPM_TPM12 +const RC_TABLE tpm12Table [] = { + + {TPM_AUTHFAIL, "TPM 1.2 TPM_AUTHFAIL - Authentication failed"}, + {TPM_BADINDEX, "TPM 1.2 TPM_BADINDEX - The index to a PCR, DIR or other register is incorrect"}, + {TPM_BAD_PARAMETER, "TPM 1.2 TPM_BAD_PARAMETER - One or more parameter is bad"}, + {TPM_AUDITFAILURE, "TPM 1.2 TPM_AUDITFAILURE - An operation completed successfully but the auditing of that operation failed. "}, + {TPM_CLEAR_DISABLED, "TPM 1.2 TPM_CLEAR_DISABLED - The clear disable flag is set and all clear operations now require physical access"}, + {TPM_DEACTIVATED, "TPM 1.2 TPM_DEACTIVATED - The TPM is deactivated"}, + {TPM_DISABLED, "TPM 1.2 TPM_DISABLED - The TPM is disabled"}, + {TPM_DISABLED_CMD, "TPM 1.2 TPM_DISABLED_CMD - The target command has been disabled"}, + {TPM_FAIL, "TPM 1.2 TPM_FAIL - The operation failed"}, + {TPM_BAD_ORDINAL, "TPM 1.2 TPM_BAD_ORDINAL - The ordinal was unknown or inconsistent"}, + {TPM_INSTALL_DISABLED, "TPM 1.2 TPM_INSTALL_DISABLED - The ability to install an owner is disabled"}, + {TPM_INVALID_KEYHANDLE, "TPM 1.2 TPM_INVALID_KEYHANDLE - The key handle presented was invalid"}, + {TPM_KEYNOTFOUND, "TPM 1.2 TPM_KEYNOTFOUND - The target key was not found"}, + {TPM_INAPPROPRIATE_ENC, "TPM 1.2 TPM_INAPPROPRIATE_ENC - Unacceptable encryption scheme"}, + {TPM_MIGRATEFAIL, "TPM 1.2 TPM_MIGRATEFAIL - Migration authorization failed"}, + {TPM_INVALID_PCR_INFO, "TPM 1.2 TPM_INVALID_PCR_INFO - PCR information could not be interpreted"}, + {TPM_NOSPACE, "TPM 1.2 TPM_NOSPACE - No room to load key. "}, + {TPM_NOSRK, "TPM 1.2 TPM_NOSRK - There is no SRK set"}, + {TPM_NOTSEALED_BLOB, "TPM 1.2 TPM_NOTSEALED_BLOB - An encrypted blob is invalid or was not created by this TPM"}, + {TPM_OWNER_SET, "TPM 1.2 TPM_OWNER_SET - There is already an Owner"}, + {TPM_RESOURCES, "TPM 1.2 TPM_RESOURCES - The TPM has insufficient internal resources to perform the requested action. "}, + {TPM_SHORTRANDOM, "TPM 1.2 TPM_SHORTRANDOM - A random string was too short"}, + {TPM_SIZE, "TPM 1.2 TPM_SIZE - The TPM does not have the space to perform the operation."}, + {TPM_WRONGPCRVAL, "TPM 1.2 TPM_WRONGPCRVAL - The named PCR value does not match the current PCR value."}, + {TPM_BAD_PARAM_SIZE, "TPM 1.2 TPM_BAD_PARAM_SIZE - The paramSize argument to the command has the incorrect value"}, + {TPM_SHA_THREAD, "TPM 1.2 TPM_SHA_THREAD - There is no existing SHA-1 thread. "}, + {TPM_SHA_ERROR, "TPM 1.2 TPM_SHA_ERROR - The calculation is unable to proceed because the existing SHA-1 thread has already encountered an error. "}, + {TPM_FAILEDSELFTEST, "TPM 1.2 TPM_FAILEDSELFTEST - Self-test has failed and the TPM has shutdown. "}, + {TPM_AUTH2FAIL, "TPM 1.2 TPM_AUTH2FAIL - The authorization for the second key in a 2 key function failed authorization"}, + {TPM_BADTAG, "TPM 1.2 TPM_BADTAG - The tag value sent to the TPM for a command is invalid"}, + {TPM_IOERROR, "TPM 1.2 TPM_IOERROR - An IO error occurred transmitting information to the TPM"}, + {TPM_ENCRYPT_ERROR, "TPM 1.2 TPM_ENCRYPT_ERROR - The encryption process had a problem. "}, + {TPM_DECRYPT_ERROR, "TPM 1.2 TPM_DECRYPT_ERROR - The decryption process did not complete. "}, + {TPM_INVALID_AUTHHANDLE, "TPM 1.2 TPM_INVALID_AUTHHANDLE - An invalid handle was used. "}, + {TPM_NO_ENDORSEMENT, "TPM 1.2 TPM_NO_ENDORSEMENT - The TPM does not a EK installed"}, + {TPM_INVALID_KEYUSAGE, "TPM 1.2 TPM_INVALID_KEYUSAGE - The usage of a key is not allowed"}, + {TPM_WRONG_ENTITYTYPE, "TPM 1.2 TPM_WRONG_ENTITYTYPE - The submitted entity type is not allowed"}, + {TPM_INVALID_POSTINIT, "TPM 1.2 TPM_INVALID_POSTINIT - The command was received in the wrong sequence relative to TPM_Init and a subsequent TPM_Startup"}, + {TPM_INAPPROPRIATE_SIG, "TPM 1.2 TPM_INAPPROPRIATE_SIG - Signed data cannot include additional DER information"}, + {TPM_BAD_KEY_PROPERTY, "TPM 1.2 TPM_BAD_KEY_PROPERTY - The key properties in TPM_KEY_PARMs are not supported by this TPM"}, + {TPM_BAD_MIGRATION, "TPM 1.2 TPM_BAD_MIGRATION - The migration properties of this key are incorrect."}, + {TPM_BAD_SCHEME, "TPM 1.2 TPM_BAD_SCHEME - The signature or encryption scheme for this key is incorrect or not permitted in this situation. "}, + {TPM_BAD_DATASIZE, "TPM 1.2 TPM_BAD_DATASIZE - The size of the data (or blob) parameter is bad or inconsistent with the referenced key"}, + {TPM_BAD_MODE, "TPM 1.2 TPM_BAD_MODE - A mode parameter is bad, such as capArea or subCapArea for TPM_GetCapability, physicalPresence parameter for TPM_PhysicalPresence, or migrationType for TPM_CreateMigrationBlob. "}, + {TPM_BAD_PRESENCE, "TPM 1.2 TPM_BAD_PRESENCE- Either the physicalPresence or physicalPresenceLock bits have the wrong value"}, + {TPM_BAD_VERSION, "TPM 1.2 TPM_BAD_VERSION - The TPM cannot perform this version of the capability"}, + {TPM_NO_WRAP_TRANSPORT, "TPM 1.2 TPM_NO_WRAP_TRANSPORT - The TPM does not allow for wrapped transport sessions"}, + {TPM_AUDITFAIL_UNSUCCESSFUL, "TPM 1.2 TPM_AUDITFAIL_UNSUCCESSFUL - TPM audit construction failed and the underlying command was returning a failure also"}, + {TPM_AUDITFAIL_SUCCESSFUL, "TPM 1.2 TPM_AUDITFAIL_SUCCESSFUL - TPM audit construction failed and the underlying command was returning success"}, + {TPM_NOTRESETABLE, "TPM 1.2 TPM_NOTRESETABLE - Attempt to reset a PCR register that does not have the resettable attribute"}, + {TPM_NOTLOCAL, "TPM 1.2 TPM_NOTLOCAL - Attempt to reset a PCR register that requires locality and locality modifier not part of command transport"}, + {TPM_BAD_TYPE, "TPM 1.2 TPM_BAD_TYPE - Make identity blob not properly typed"}, + {TPM_INVALID_RESOURCE, "TPM 1.2 TPM_INVALID_RESOURCE - When saving context identified resource type does not match actual resource"}, + {TPM_NOTFIPS, "TPM 1.2 TPM_NOTFIPS - The TPM is attempting to execute a command only available when in FIPS mode"}, + {TPM_INVALID_FAMILY, "TPM 1.2 TPM_INVALID_FAMILY - The command is attempting to use an invalid family ID"}, + {TPM_NO_NV_PERMISSION, "TPM 1.2 TPM_NO_NV_PERMISSION - The permission to manipulate the NV storage is not available"}, + {TPM_REQUIRES_SIGN, "TPM 1.2 TPM_REQUIRES_SIGN - The operation requires a signed command"}, + {TPM_KEY_NOTSUPPORTED, "TPM 1.2 TPM_KEY_NOTSUPPORTED - Wrong operation to load an NV key"}, + {TPM_AUTH_CONFLICT, "TPM 1.2 TPM_AUTH_CONFLICT - NV_DefineSpace requires both owner and blob authorization"}, + {TPM_AREA_LOCKED, "TPM 1.2 TPM_AREA_LOCKED - The NV area is locked and not writable"}, + {TPM_BAD_LOCALITY, "TPM 1.2 TPM_BAD_LOCALITY - The locality is incorrect for the attempted operation"}, + {TPM_READ_ONLY, "TPM 1.2 TPM_READ_ONLY - The NV area is read only and can't be written to "}, + {TPM_PER_NOWRITE, "TPM 1.2 TPM_PER_NOWRITE - There is no protection on the write to the NV area "}, + {TPM_FAMILYCOUNT, "TPM 1.2 TPM_FAMILYCOUNT - The family count value does not match"}, + {TPM_WRITE_LOCKED, "TPM 1.2 TPM_WRITE_LOCKED - The NV area has already been written to"}, + {TPM_BAD_ATTRIBUTES, "TPM 1.2 TPM_BAD_ATTRIBUTES - The NV area attributes conflict"}, + {TPM_INVALID_STRUCTURE, "TPM 1.2 TPM_INVALID_STRUCTURE - The structure tag and version are invalid or inconsistent"}, + {TPM_KEY_OWNER_CONTROL, "TPM 1.2 TPM_KEY_OWNER_CONTROL - The key is under control of the TPM Owner and can only be evicted by the TPM Owner. "}, + {TPM_BAD_COUNTER, "TPM 1.2 TPM_BAD_COUNTER - The counter handle is incorrect"}, + {TPM_NOT_FULLWRITE, "TPM 1.2 TPM_NOT_FULLWRITE - The write is not a complete write of the area"}, + {TPM_CONTEXT_GAP, "TPM 1.2 TPM_CONTEXT_GAP - The gap between saved context counts is too large "}, + {TPM_MAXNVWRITES, "TPM 1.2 TPM_MAXNVWRITES - The maximum number of NV writes without an owner has been exceeded"}, + {TPM_NOOPERATOR, "TPM 1.2 TPM_NOOPERATOR - No operator authorization value is set"}, + {TPM_RESOURCEMISSING, "TPM 1.2 TPM_RESOURCEMISSING - The resource pointed to by context is not loaded "}, + {TPM_DELEGATE_LOCK, "TPM 1.2 TPM_DELEGATE_LOCK - The delegate administration is locked"}, + {TPM_DELEGATE_FAMILY, "TPM 1.2 TPM_DELEGATE_FAMILY - Attempt to manage a family other then the delegated family"}, + {TPM_DELEGATE_ADMIN, "TPM 1.2 TPM_DELEGATE_ADMIN - Delegation table management not enabled"}, + {TPM_TRANSPORT_NOTEXCLUSIVE, "TPM 1.2 TPM_TRANSPORT_NOTEXCLUSIVE - There was a command executed outside of an exclusive transport session"}, + {TPM_OWNER_CONTROL, "TPM 1.2 TPM_OWNER_CONTROL - Attempt to context save a owner evict controlled key"}, + {TPM_DAA_RESOURCES, "TPM 1.2 TPM_DAA_RESOURCES - The DAA command has no resources available to execute the command"}, + {TPM_DAA_INPUT_DATA0, "TPM 1.2 TPM_DAA_INPUT_DATA0 - The consistency check on DAA parameter inputData0 has failed."}, + {TPM_DAA_INPUT_DATA1, "TPM 1.2 TPM_DAA_INPUT_DATA1 - The consistency check on DAA parameter inputData1 has failed."}, + {TPM_DAA_ISSUER_SETTINGS, "TPM 1.2 TPM_DAA_ISSUER_SETTINGS - The consistency check on DAA_issuerSettings has failed."}, + {TPM_DAA_TPM_SETTINGS, "TPM 1.2 TPM_DAA_TPM_SETTINGS - The consistency check on DAA_tpmSpecific has failed."}, + {TPM_DAA_STAGE, "TPM 1.2 TPM_DAA_STAGE - The atomic process indicated by the submitted DAA command is not the expected process."}, + {TPM_DAA_ISSUER_VALIDITY, "TPM 1.2 TPM_DAA_ISSUER_VALIDITY - The issuer's validity check has detected an inconsistency"}, + {TPM_DAA_WRONG_W, "TPM 1.2 TPM_DAA_WRONG_W - The consistency check on w has failed."}, + {TPM_BAD_HANDLE, "TPM 1.2 TPM_BAD_HANDLE - The handle is incorrect"}, + {TPM_BAD_DELEGATE, "TPM 1.2 TPM_BAD_DELEGATE - Delegation is not correct"}, + {TPM_BADCONTEXT, "TPM 1.2 TPM_BADCONTEXT - The context blob is invalid"}, + {TPM_TOOMANYCONTEXTS, "TPM 1.2 TPM_TOOMANYCONTEXTS - Too many contexts held by the TPM"}, + {TPM_MA_TICKET_SIGNATURE, "TPM 1.2 TPM_MA_TICKET_SIGNATURE - Migration authority signature validation failure "}, + {TPM_MA_DESTINATION, "TPM 1.2 TPM_MA_DESTINATION - Migration destination not authenticated"}, + {TPM_MA_SOURCE, "TPM 1.2 TPM_MA_SOURCE - Migration source incorrect"}, + {TPM_MA_AUTHORITY, "TPM 1.2 TPM_MA_AUTHORITY - Incorrect migration authority"}, + {TPM_PERMANENTEK, "TPM 1.2 TPM_PERMANENTEK - Attempt to revoke the EK and the EK is not revocable"}, + {TPM_BAD_SIGNATURE, "TPM 1.2 TPM_BAD_SIGNATURE - Bad signature of CMK ticket "}, + {TPM_NOCONTEXTSPACE, "TPM 1.2 TPM_NOCONTEXTSPACE - There is no room in the context list for additional contexts"}, + {TPM_RETRY, "TPM 1.2 TPM_RETRY - The TPM is too busy to respond to the command immediately, but the command could be submitted at a later time"}, + {TPM_NEEDS_SELFTEST, "TPM 1.2 TPM_NEEDS_SELFTEST - TPM_ContinueSelfTest has has not been run"}, + {TPM_DOING_SELFTEST, "TPM 1.2 TPM_DOING_SELFTEST - The TPM is currently executing the actions of TPM_ContinueSelfTest because the ordinal required resources that have not been tested."}, + {TPM_DEFEND_LOCK_RUNNING, "TPM 1.2 TPM_DEFEND_LOCK_RUNNING - The TPM is defending against dictionary attacks and is in some time-out period."}, + +}; +#endif + +static const char *TSS_ResponseCode_RcToText(const RC_TABLE *table, size_t tableSize, TPM_RC rc); +static const char *TSS_ResponseCode_NumberToText(unsigned int num); + +const RC_TABLE ver1Table [] = { + {TPM_RC_INITIALIZE, "TPM_RC_INITIALIZE - TPM not initialized by TPM2_Startup or already initialized"}, + {TPM_RC_FAILURE, "TPM_RC_FAILURE - commands not being accepted because of a TPM failure"}, + {TPM_RC_SEQUENCE, "TPM_RC_SEQUENCE - improper use of a sequence handle"}, + {TPM_RC_PRIVATE, "TPM_RC_PRIVATE - not currently used"}, + {TPM_RC_HMAC, "TPM_RC_HMAC - HMAC failure"}, + {TPM_RC_DISABLED, "TPM_RC_DISABLED - the command is disabled"}, + {TPM_RC_EXCLUSIVE, "TPM_RC_EXCLUSIVE - command failed because audit sequence required exclusivity"}, + {TPM_RC_AUTH_TYPE, "TPM_RC_AUTH_TYPE - authorization handle is not correct for command"}, + {TPM_RC_AUTH_MISSING, "TPM_RC_AUTH_MISSING - command requires an authorization session"}, + {TPM_RC_POLICY, "TPM_RC_POLICY - policy failure in math operation or an invalid authPolicy value"}, + {TPM_RC_PCR, "TPM_RC_PCR - PCR check fail"}, + {TPM_RC_PCR_CHANGED, "TPM_RC_PCR_CHANGED - PCR have changed since checked."}, + {TPM_RC_UPGRADE, "TPM_RC_UPGRADE - TPM is in field upgrade mode"}, + {TPM_RC_TOO_MANY_CONTEXTS, "TPM_RC_TOO_MANY_CONTEXTS - context ID counter is at maximum."}, + {TPM_RC_AUTH_UNAVAILABLE, "TPM_RC_AUTH_UNAVAILABLE - authValue or authPolicy is not available for selected entity."}, + {TPM_RC_REBOOT, "TPM_RC_REBOOT - a _TPM_Init and Startup(CLEAR) is required"}, + {TPM_RC_UNBALANCED, "TPM_RC_UNBALANCED - the protection algorithms (hash and symmetric) are not reasonably balanced"}, + {TPM_RC_COMMAND_SIZE, "TPM_RC_COMMAND_SIZE - command commandSize value is inconsistent with contents of the command buffer"}, + {TPM_RC_COMMAND_CODE, "TPM_RC_COMMAND_CODE - command code not supported"}, + {TPM_RC_AUTHSIZE, "TPM_RC_AUTHSIZE - the value of authorizationSize is out of range"}, + {TPM_RC_AUTH_CONTEXT, "TPM_RC_AUTH_CONTEXT - use of an authorization session with a command that cannot have an authorization session"}, + {TPM_RC_NV_RANGE, "TPM_RC_NV_RANGE - NV offset+size is out of range."}, + {TPM_RC_NV_SIZE, "TPM_RC_NV_SIZE - Requested allocation size is larger than allowed."}, + {TPM_RC_NV_LOCKED, "TPM_RC_NV_LOCKED - NV access locked."}, + {TPM_RC_NV_AUTHORIZATION, "TPM_RC_NV_AUTHORIZATION - NV access authorization fails"}, + {TPM_RC_NV_UNINITIALIZED, "TPM_RC_NV_UNINITIALIZED - an NV Index is used before being initialized"}, + {TPM_RC_NV_SPACE, "TPM_RC_NV_SPACE - insufficient space for NV allocation"}, + {TPM_RC_NV_DEFINED, "TPM_RC_NV_DEFINED - NV Index or persistent object already defined"}, + {TPM_RC_BAD_CONTEXT, "TPM_RC_BAD_CONTEXT - context in TPM2_ContextLoad() is not valid"}, + {TPM_RC_CPHASH, "TPM_RC_CPHASH - cpHash value already set or not correct for use"}, + {TPM_RC_PARENT, "TPM_RC_PARENT - handle for parent is not a valid parent"}, + {TPM_RC_NEEDS_TEST, "TPM_RC_NEEDS_TEST - some function needs testing."}, + {TPM_RC_NO_RESULT, "TPM_RC_NO_RESULT - internal function cannot process a request due to an unspecified problem."}, + {TPM_RC_SENSITIVE, "TPM_RC_SENSITIVE - the sensitive area did not unmarshal correctly after decryption"}, +}; + +/* RC_FMT1 response code to text */ + +const RC_TABLE fmt1Table [] = { + {TPM_RC_ASYMMETRIC, "TPM_RC_ASYMMETRIC - asymmetric algorithm not supported or not correct"}, + {TPM_RC_ATTRIBUTES, "TPM_RC_ATTRIBUTES - inconsistent attributes"}, + {TPM_RC_HASH, "TPM_RC_HASH - hash algorithm not supported or not appropriate"}, + {TPM_RC_VALUE, "TPM_RC_VALUE - value is out of range or is not correct for the context"}, + {TPM_RC_HIERARCHY, "TPM_RC_HIERARCHY - hierarchy is not enabled or is not correct for the use"}, + {TPM_RC_KEY_SIZE, "TPM_RC_KEY_SIZE - key size is not supported"}, + {TPM_RC_MGF, "TPM_RC_MGF - mask generation function not supported"}, + {TPM_RC_MODE, "TPM_RC_MODE - mode of operation not supported"}, + {TPM_RC_TYPE, "TPM_RC_TYPE - the type of the value is not appropriate for the use"}, + {TPM_RC_HANDLE, "TPM_RC_HANDLE - the handle is not correct for the use"}, + {TPM_RC_KDF, "TPM_RC_KDF - unsupported key derivation function or function not appropriate for use"}, + {TPM_RC_RANGE, "TPM_RC_RANGE - value was out of allowed range."}, + {TPM_RC_AUTH_FAIL, "TPM_RC_AUTH_FAIL - the authorization HMAC check failed and DA counter incremented"}, + {TPM_RC_NONCE, "TPM_RC_NONCE - invalid nonce size or nonce value mismatch"}, + {TPM_RC_PP, "TPM_RC_PP - authorization requires assertion of PP"}, + {TPM_RC_SCHEME, "TPM_RC_SCHEME - unsupported or incompatible scheme"}, + {TPM_RC_SIZE, "TPM_RC_SIZE - structure is the wrong size"}, + {TPM_RC_SYMMETRIC, "TPM_RC_SYMMETRIC - unsupported symmetric algorithm or key size, or not appropriate for instance"}, + {TPM_RC_TAG, "TPM_RC_TAG - incorrect structure tag"}, + {TPM_RC_SELECTOR, "TPM_RC_SELECTOR - union selector is incorrect"}, + {TPM_RC_INSUFFICIENT, "TPM_RC_INSUFFICIENT - the TPM was unable to unmarshal a value because there were not enough octets in the input buffer"}, + {TPM_RC_SIGNATURE, "TPM_RC_SIGNATURE - the signature is not valid"}, + {TPM_RC_KEY, "TPM_RC_KEY - key fields are not compatible with the selected use"}, + {TPM_RC_POLICY_FAIL, "TPM_RC_POLICY_FAIL - a policy check failed"}, + {TPM_RC_INTEGRITY, "TPM_RC_INTEGRITY - integrity check failed"}, + {TPM_RC_TICKET, "TPM_RC_TICKET - invalid ticket"}, + {TPM_RC_RESERVED_BITS, "TPM_RC_RESERVED_BITS - reserved bits not set to zero as required"}, + {TPM_RC_BAD_AUTH, "TPM_RC_BAD_AUTH - authorization failure without DA implications"}, + {TPM_RC_EXPIRED, "TPM_RC_EXPIRED - the policy has expired"}, + {TPM_RC_POLICY_CC, "TPM_RC_POLICY_CC - the commandCode in the policy is not the commandCode of the command"}, + {TPM_RC_BINDING, "TPM_RC_BINDING - public and sensitive portions of an object are not cryptographically bound"}, + {TPM_RC_CURVE, "TPM_RC_CURVE - curve not supported "}, + {TPM_RC_ECC_POINT, "TPM_RC_ECC_POINT - point is not on the required curve."}, +}; + +/* RC_WARN response code to text */ + +const RC_TABLE warnTable [] = { + {TPM_RC_CONTEXT_GAP, "TPM_RC_CONTEXT_GAP - gap for context ID is too large"}, + {TPM_RC_OBJECT_MEMORY, "TPM_RC_OBJECT_MEMORY - out of memory for object contexts"}, + {TPM_RC_SESSION_MEMORY, "TPM_RC_SESSION_MEMORY - out of memory for session contexts"}, + {TPM_RC_MEMORY, "TPM_RC_MEMORY - out of shared object/session memory or need space for internal operations"}, + {TPM_RC_SESSION_HANDLES, "TPM_RC_SESSION_HANDLES - out of session handles - a session must be flushed before a new session may be created"}, + {TPM_RC_OBJECT_HANDLES, "TPM_RC_OBJECT_HANDLES - out of object handles - the handle space for objects is depleted and a reboot is required"}, + {TPM_RC_LOCALITY, "TPM_RC_LOCALITY - bad locality"}, + {TPM_RC_YIELDED, "TPM_RC_YIELDED - the TPM has suspended operation on the command; forward progress was made and the command may be retried."}, + {TPM_RC_CANCELED, "TPM_RC_CANCELED - the command was canceled"}, + {TPM_RC_TESTING, "TPM_RC_TESTING - TPM is performing self-tests"}, + {TPM_RC_REFERENCE_H0, "TPM_RC_REFERENCE_H0 - the 1st handle in the handle area references a transient object or session that is not loaded"}, + {TPM_RC_REFERENCE_H1, "TPM_RC_REFERENCE_H1 - the 2nd handle in the handle area references a transient object or session that is not loaded"}, + {TPM_RC_REFERENCE_H2, "TPM_RC_REFERENCE_H2 - the 3rd handle in the handle area references a transient object or session that is not loaded"}, + {TPM_RC_REFERENCE_H3, "TPM_RC_REFERENCE_H3 - the 4th handle in the handle area references a transient object or session that is not loaded"}, + {TPM_RC_REFERENCE_H4, "TPM_RC_REFERENCE_H4 - the 5th handle in the handle area references a transient object or session that is not loaded"}, + {TPM_RC_REFERENCE_H5, "TPM_RC_REFERENCE_H5 - the 6th handle in the handle area references a transient object or session that is not loaded"}, + {TPM_RC_REFERENCE_H6, "TPM_RC_REFERENCE_H6 - the 7th handle in the handle area references a transient object or session that is not loaded"}, + {TPM_RC_REFERENCE_S0, "TPM_RC_REFERENCE_S0 - the 1st authorization session handle references a session that is not loaded"}, + {TPM_RC_REFERENCE_S1, "TPM_RC_REFERENCE_S1 - the 2nd authorization session handle references a session that is not loaded"}, + {TPM_RC_REFERENCE_S2, "TPM_RC_REFERENCE_S2 - the 3rd authorization session handle references a session that is not loaded"}, + {TPM_RC_REFERENCE_S3, "TPM_RC_REFERENCE_S3 - the 4th authorization session handle references a session that is not loaded"}, + {TPM_RC_REFERENCE_S4, "TPM_RC_REFERENCE_S4 - the 5th session handle references a session that is not loaded"}, + {TPM_RC_REFERENCE_S5, "TPM_RC_REFERENCE_S5 - the 6th session handle references a session that is not loaded"}, + {TPM_RC_REFERENCE_S6, "TPM_RC_REFERENCE_S6 - the 7th authorization session handle references a session that is not loaded"}, + {TPM_RC_NV_RATE, "TPM_RC_NV_RATE - the TPM is rate-limiting accesses to prevent wearout of NV"}, + {TPM_RC_LOCKOUT, "TPM_RC_LOCKOUT - authorizations for objects subject to DA protection are not allowed at this time because the TPM is in DA lockout mode"}, + {TPM_RC_RETRY, "TPM_RC_RETRY - the TPM was not able to start the command"}, + {TPM_RC_NV_UNAVAILABLE, "the command may require writing of NV and NV is not current accessible"}, + {TPM_RC_NOT_USED, "TPM_RC_NOT_USED - this value is reserved and shall not be returned by the TPM"}, +}; + +/* parameter and handle number to text */ + +const char *num_table [] = { + "unspecified", + "1", + "2", + "3", + "4", + "5", + "6", + "7", + "8", + "9", + "10", + "11", + "12", + "13", + "14", + "15" +}; + +/* from tsserror.h */ + +const RC_TABLE tssTable [] = { + {TSS_RC_OUT_OF_MEMORY, "TSS_RC_OUT_OF_MEMORY - Out of memory (malloc failed)"}, + {TSS_RC_ALLOC_INPUT, "TSS_RC_ALLOC_INPUT - The input to an allocation is not NULL"}, + {TSS_RC_MALLOC_SIZE, "TSS_RC_MALLOC_SIZE - The malloc size is too large or zero"}, + {TSS_RC_INSUFFICIENT_BUFFER, "TSS_RC_INSUFFICIENT_BUFFER - A buffer was insufficient for a copy"}, + {TSS_RC_BAD_PROPERTY, "TSS_RC_BAD_PROPERTY - The property parameter is out of range"}, + {TSS_RC_BAD_PROPERTY_VALUE, "TSS_RC_BAD_PROPERTY_VALUE - The property value is invalid"}, + {TSS_RC_INSUPPORTED_INTERFACE, "TSS_RC_INSUPPORTED_INTERFACE - The TPM interface type is not supported"}, + {TSS_RC_NO_CONNECTION, "TSS_RC_NO_CONNECTION - Failure connecting to lower layer"}, + {TSS_RC_BAD_CONNECTION, "TSS_RC_BAD_CONNECTION - Failure communicating with lower layer"}, + {TSS_RC_MALFORMED_RESPONSE, "TSS_RC_MALFORMED_RESPONSE - A response packet was fundamentally malformed"}, + {TSS_RC_NULL_PARAMETER, "TSS_RC_NULL_PARAMETER - A required parameter was NULL"}, + {TSS_RC_NOT_IMPLEMENTED, "TSS_RC_NOT_IMPLEMENTED - TSS function is not implemented"}, + {TSS_RC_FILE_OPEN, "TSS_RC_FILE_OPEN - The file could not be opened"}, + {TSS_RC_FILE_SEEK, "TSS_RC_FILE_SEEK - A file seek failed"}, + {TSS_RC_FILE_FTELL, "TSS_RC_FILE_FTELL - A file ftell failed"}, + {TSS_RC_FILE_READ, "TSS_RC_FILE_READ - A file read failed"}, + {TSS_RC_FILE_CLOSE, "TSS_RC_FILE_CLOSE - A file close failed"}, + {TSS_RC_FILE_WRITE, "TSS_RC_FILE_WRITE - A file write failed"}, + {TSS_RC_FILE_REMOVE, "TSS_RC_FILE_REMOVE - A file remove failed"}, + {TSS_RC_RNG_FAILURE, "TSS_RC_RNG_FAILURE - The random number generator failed"}, + {TSS_RC_BAD_PWAP_NONCE, "TSS_RC_BAD_PWAP_NONCE - Bad PWAP response nonce"}, + {TSS_RC_BAD_PWAP_ATTRIBUTES, "TSS_RC_BAD_PWAP_ATTRIBUTES - Bad PWAP response attributes"}, + {TSS_RC_BAD_PWAP_HMAC, "TSS_RC_BAD_PWAP_HMAC - Bad PWAP response HMAC"}, + {TSS_RC_NAME_NOT_IMPLEMENTED, "TSS_RC_NAME_NOT_IMPLEMENTED - name calculation not implemented for handle type"}, + {TSS_RC_MALFORMED_NV_PUBLIC, "TSS_RC_MALFORMED_NV_PUBLIC - The NV public structure does not match the name"}, + {TSS_RC_NAME_FILENAME, "TSS_RC_NAME_FILENAME - The name filename function has inconsistent arguments"}, + {TSS_RC_DECRYPT_SESSIONS, "TSS_RC_DECRYPT_SESSIONS - More than one command decrypt session"}, + {TSS_RC_ENCRYPT_SESSIONS, "TSS_RC_ENCRYPT_SESSIONS - More than one response encrypt session"}, + {TSS_RC_NO_DECRYPT_PARAMETER, "TSS_RC_NO_DECRYPT_PARAMETER - Command has no decrypt parameter"}, + {TSS_RC_NO_ENCRYPT_PARAMETER, "TSS_RC_NO_ENCRYPT_PARAMETER - Respnse has no encrypt parameter"}, + {TSS_RC_BAD_DECRYPT_ALGORITHM, "TSS_RC_BAD_DECRYPT_ALGORITHM - Session had an unimplemented decrypt symmetric algorithm"}, + {TSS_RC_BAD_ENCRYPT_ALGORITHM, "TSS_RC_BAD_ENCRYPT_ALGORITHM - Session had an unimplemented encrypt symmetric algorithm"}, + {TSS_RC_AES_ENCRYPT_FAILURE, "TSS_RC_AES_ENCRYPT_FAILURE - AES encryption failed"}, + {TSS_RC_AES_DECRYPT_FAILURE, "TSS_RC_AES_DECRYPT_FAILURE - AES decryption failed\n" + "\tIf using command line utilities, set env variable TPM_ENCRYPT_SESSIONS to 0\n" + "\tor see TSS manual for more options"}, + {TSS_RC_BAD_ENCRYPT_SIZE, "TSS_RC_BAD_ENCRYPT_SIZE - Parameter encryption size mismatch"}, + {TSS_RC_AES_KEYGEN_FAILURE, "TSS_RC_AES_KEYGEN_FAILURE - AES key generation failed"}, + {TSS_RC_SESSION_NUMBER, "TSS_RC_SESSION_NUMBER - session number out of range"}, + {TSS_RC_BAD_SALT_KEY, "TSS_RC_BAD_SALT_KEY - Key is unsuitable for salt"}, + {TSS_RC_KDFA_FAILED, "TSS_RC_KDFA_FAILED - KDFa function failed"}, + {TSS_RC_HMAC, "TSS_RC_HMAC - An HMAC calculation failed"}, + {TSS_RC_HMAC_SIZE, "TSS_RC_HMAC_SIZE - nse HMAC is the wrong size"}, + {TSS_RC_HMAC_VERIFY, "TSS_RC_HMAC_VERIFY - MAC does not verify"}, + {TSS_RC_BAD_HASH_ALGORITHM, "TSS_RC_BAD_HASH_ALGORITHM - Unimplemented hash algorithm"}, + {TSS_RC_HASH, "TSS_RC_HASH - A hash calculation failed"}, + {TSS_RC_RSA_KEY_CONVERT, "TSS_RC_RSA_KEY_CONVERT - RSA key conversion failed"}, + {TSS_RC_RSA_PADDING, "TSS_RC_RSA_PADDING - RSA add padding failed"}, + {TSS_RC_RSA_ENCRYPT, "TSS_RC_RSA_ENCRYPT - RSA public encrypt failed"}, + {TSS_RC_BIGNUM, "TSS_RC_BIGNUM - NUM operation failed"}, + {TSS_RC_RSA_SIGNATURE, "TSS_RC_RSA_SIGNATURE - RSA signature is bad"}, + {TSS_RC_EC_SIGNATURE, "TSS_RC_EC_SIGNATURE - EC signature is bad"}, + {TSS_RC_EC_KEY_CONVERT, "TSS_RC_EC_KEY_CONVERT - EC key conversion failed"}, + {TSS_RC_X509_ERROR, "TSS_RC_X509_ERROR - X509 parse error"}, + {TSS_RC_BAD_SIGNATURE_ALGORITHM, "TSS_RC_BAD_SIGNATURE_ALGORITHM - Unimplemented signature algorithm"}, + {TSS_RC_COMMAND_UNIMPLEMENTED, "TSS_RC_COMMAND_UNIMPLEMENTED - Unimplemented command"}, + {TSS_RC_IN_PARAMETER, "TSS_RC_IN_PARAMETER - Bad in parameter to TSS_Execute"}, + {TSS_RC_OUT_PARAMETER, "TSS_RC_OUT_PARAMETER - Bad out parameter to TSS_Execute"}, + {TSS_RC_BAD_HANDLE_NUMBER, "TSS_RC_BAD_HANDLE_NUMBER - Bad handle number for this command"}, + {TSS_RC_KDFE_FAILED, "TSS_RC_KDFE_FAILED - KDFe function failed"}, + {TSS_RC_EC_EPHEMERAL_FAILURE, "TSS_RC_EC_EPHEMERAL_FAILURE - Failed while making or using EC ephemeral key"}, + {TSS_RC_FAIL, "TSS_RC_FAIL - TSS internal failure"}, + {TSS_RC_NO_SESSION_SLOT, "TSS_RC_NO_SESSION_SLOT - TSS context has no session slot for handle"}, + {TSS_RC_NO_OBJECTPUBLIC_SLOT, "TSS_RC_NO_OBJECTPUBLIC_SLOT - TSS context has no object public slot for handle"}, + {TSS_RC_NO_NVPUBLIC_SLOT, "TSS_RC_NO_NVPUBLIC_SLOT -TSS context has no NV public slot for handle"} +}; + +#define BITS1108 0xf00 +#define BITS1108SHIFT 8 + +#define BITS1008 0x700 +#define BITS1008SHIFT 8 + +#define BITS0600 0x07f +#define BITS0500 0x03f + +#define BITS87 0x180 +#define BIT11 0x800 +#define BIT10 0x400 +#define BIT7 0x080 +#define BIT6 0x040 + +#define TSSMASK 0x00ff0000 /* 23:16 */ + +/* Test cases + + TPM 1.2 001 + TPM param 1c1 + TPM handle 181 + TPM session 981 + TSS b0001 +*/ + +/* TSS namespace starts with bit 16 */ +#define TSS_RC_LEVEL_SHIFT 16 + +/* TSS error level name space */ +#define TSS_ERROR_LEVEL (11 << TSS_RC_LEVEL_SHIFT ) + +/* Figure 26 - Response Code Evaluation */ + +void TSS_ResponseCode_toString(const char **msg, const char **submsg, const char **num, TPM_RC rc) +{ + *submsg = ""; /* sometimes no sub-message */ + *num = ""; /* sometime no number */ + + if (rc == 0) { + *msg = "TPM_RC_SUCCESS"; + } + /* if TSS 11 << 16 */ + else if ((rc & TSSMASK) == TSS_ERROR_LEVEL) { + *msg = TSS_ResponseCode_RcToText(tssTable, sizeof(tssTable) / sizeof(RC_TABLE), rc); + } + /* if bits 8:7 are 00 */ + else if ((rc & BITS87) == 0) { + /* TPM 1.2 x000 0xxx xxxx */ +#ifdef TPM_TPM12 + *msg = TSS_ResponseCode_RcToText(tpm12Table, sizeof(tpm12Table) / sizeof(RC_TABLE), rc); +#else + *msg = "TPM 1.2 response code"; +#endif + } + /* if bits 8:7 are not 00 */ + else { + /* if bit 7 is 0 */ + if ((rc & BIT7) == 0) { + /* if bit 10 is 1 */ + if ((rc & BIT10) != 0) { + /* vendor defined x101 0xxx xxxx */ + *msg = "TPM2 vendor defined response code"; + } + /* if bit 10 is 0 */ + else { + /* if bit 11 is 1 */ + if ((rc & BIT11) != 0) { + /* warning 1001 0xxx xxxx RC_WARN */ + *msg = TSS_ResponseCode_RcToText(warnTable, + sizeof(warnTable) / sizeof(RC_TABLE), + rc & (BITS0600 | RC_WARN)); + } + /* if bit 11 is 0 */ + else { + /* error 0001 0xxx xxxx RC_VER1 */ + *msg = TSS_ResponseCode_RcToText(ver1Table, + sizeof(ver1Table) / sizeof(RC_TABLE), + rc & (BITS0600 | RC_VER1)); + } + } + } + /* if bit 7 is 1 RC_FMT1 */ + else { + /* if bit 6 is 1 */ + if ((rc & BIT6) != 0) { + /* error xxxx 11xx xxxx */ + *msg = TSS_ResponseCode_RcToText(fmt1Table, + sizeof(fmt1Table) / sizeof(RC_TABLE), + rc & (BITS0500 | RC_FMT1)); + *submsg = " Parameter number "; + *num = TSS_ResponseCode_NumberToText((rc & BITS1108) >> BITS1108SHIFT); + } + /* if bit 6 is 0 */ + else { + /* if bit 11 is 1 */ + if ((rc & BIT11) != 0) { + /* error 1xxx 10xx xxxx */ + *msg = TSS_ResponseCode_RcToText(fmt1Table, + sizeof(fmt1Table) / sizeof(RC_TABLE), + rc & (BITS0500 | RC_FMT1)); + *submsg = " Session number "; + *num = TSS_ResponseCode_NumberToText((rc & BITS1008) >> BITS1008SHIFT); + } + /* if bit 11 is 0 */ + else { + /* error 0xxx 10xx xxxx */ + *msg = TSS_ResponseCode_RcToText(fmt1Table, + sizeof(fmt1Table) / sizeof(RC_TABLE), + rc & (BITS0500 | RC_FMT1)); + *submsg = " Handle number "; + *num = TSS_ResponseCode_NumberToText((rc & BITS1008) >> BITS1008SHIFT); + } + } + } + } + return; +} + +static const char *TSS_ResponseCode_RcToText(const RC_TABLE *table, size_t tableSize, TPM_RC rc) +{ + size_t i; + + for (i = 0 ; i < tableSize ; i++) { + if (table[i].rc == rc) { + return table[i].text; + } + } + return "response code unknown"; +} + +static const char *TSS_ResponseCode_NumberToText(unsigned int num) +{ + if (num < (sizeof(num_table) / sizeof(const char *))) { + return num_table[num]; + } + else { + return "out of bounds"; + } +} diff --git a/libstb/tss2/tssskiboot.c b/libstb/tss2/tssskiboot.c new file mode 100644 index 0000000..20f1569 --- /dev/null +++ b/libstb/tss2/tssskiboot.c @@ -0,0 +1,104 @@ +/********************************************************************************/ +/* */ +/* Skiboot Support Interface */ +/* */ +/* (c) Copyright IBM Corporation 2019 */ +/* */ +/* All rights reserved. */ +/* */ +/* Redistribution and use in source and binary forms, with or without */ +/* modification, are permitted provided that the following conditions are */ +/* met: */ +/* */ +/* Redistributions of source code must retain the above copyright notice, */ +/* this list of conditions and the following disclaimer. */ +/* */ +/* 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. */ +/* */ +/* Neither the names of the IBM Corporation nor the names of its */ +/* contributors may be used to endorse or promote products derived from */ +/* this software without specific prior written permission. */ +/* */ +/* 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. */ +/********************************************************************************/ + +#ifdef __SKIBOOT__ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <stdint.h> + +#include <ibmtss/tss.h> +#include <ibmtss/tssfile.h> +#include <ibmtss/tssmarshal.h> +#include <ibmtss/tssresponsecode.h> +#include <ibmtss/Startup_fp.h> +#include <ibmtss/tssprint.h> +#include "tssproperties.h" + +#include "tssskiboot.h" + +static void traceError(const char *command, TPM_RC rc) +{ + const char *msg; + const char *submsg; + const char *num; + printf("%s: failed, rc %08x\n", command, rc); + TSS_ResponseCode_toString(&msg, &submsg, &num, rc); + printf("%s%s%s\n", msg, submsg, num); +} + +/** + * @brief readpublic fills the TSS context object slot with the + * wrapping key public part. The Name is required for + * the HMAC calculation. + * + */ +TPM_RC TSS_NV_ReadPublic(TSS_CONTEXT *ctx, NV_ReadPublic_In *in, + NV_ReadPublic_Out *out) +{ + TPM_RC rc; + + printf("%s: nvIndex %x\n", __func__, in->nvIndex); + + rc = TSS_Execute(ctx, + (RESPONSE_PARAMETERS *) out, + (COMMAND_PARAMETERS *) in, + NULL, + TPM_CC_NV_ReadPublic, + TPM_RH_NULL, NULL, 0); + + if (rc == 0) { + printf("%s: name algorithm %04x\n", __func__, + out->nvPublic.nvPublic.nameAlg); + printf("%s: data size %u\n", __func__, + out->nvPublic.nvPublic.dataSize); + printf("%s: attributes %08x\n", __func__, + out->nvPublic.nvPublic.attributes.val); + TSS_TPMA_NV_Print(out->nvPublic.nvPublic.attributes, 0); + TSS_PrintAll("TSS_NV_ReadPublic: policy", + out->nvPublic.nvPublic.authPolicy.t.buffer, + out->nvPublic.nvPublic.authPolicy.t.size); + TSS_PrintAll("TSS_NV_ReadPublic: name", + out->nvName.t.name, out->nvName.t.size); + } else { + traceError("TSS_NV_ReadPublic", rc); + } + + return rc; +} + +#endif /* __SKIBOOT__ */ diff --git a/libstb/tss2/tssskiboot.h b/libstb/tss2/tssskiboot.h new file mode 100644 index 0000000..785c3de --- /dev/null +++ b/libstb/tss2/tssskiboot.h @@ -0,0 +1,50 @@ +/********************************************************************************/ +/* */ +/* SKIBOOT Interface */ +/* */ +/* (c) Copyright IBM Corporation 2019. */ +/* */ +/* All rights reserved. */ +/* */ +/* Redistribution and use in source and binary forms, with or without */ +/* modification, are permitted provided that the following conditions are */ +/* met: */ +/* */ +/* Redistributions of source code must retain the above copyright notice, */ +/* this list of conditions and the following disclaimer. */ +/* */ +/* 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. */ +/* */ +/* Neither the names of the IBM Corporation nor the names of its */ +/* contributors may be used to endorse or promote products derived from */ +/* this software without specific prior written permission. */ +/* */ +/* 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. */ +/********************************************************************************/ +#ifdef __SKIBOOT__ + +#ifndef TSSSKIBOOT_H +#define TSSSKIBOOT_H + +#include <ibmtss/tss.h> +#include <ibmtss/tssresponsecode.h> +#include <ibmtss/tssmarshal.h> +#include "tssproperties.h" + +TPM_RC TSS_NV_ReadPublic(TSS_CONTEXT *ctx, NV_ReadPublic_In *in, + NV_ReadPublic_Out *out); + +#endif /* TSSSKIBOOT_H */ +#endif /* __SKIBOOT__ */ diff --git a/libstb/tss2/tsstbsi.h b/libstb/tss2/tsstbsi.h new file mode 100644 index 0000000..335ecbc --- /dev/null +++ b/libstb/tss2/tsstbsi.h @@ -0,0 +1,61 @@ +/********************************************************************************/ +/* */ +/* Windows Device Transmit and Receive Utilities */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: tsstbsi.h 1015 2017-06-07 13:16:34Z kgoldman $ */ +/* */ +/* (c) Copyright IBM Corporation 2015. */ +/* */ +/* All rights reserved. */ +/* */ +/* Redistribution and use in source and binary forms, with or without */ +/* modification, are permitted provided that the following conditions are */ +/* met: */ +/* */ +/* Redistributions of source code must retain the above copyright notice, */ +/* this list of conditions and the following disclaimer. */ +/* */ +/* 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. */ +/* */ +/* Neither the names of the IBM Corporation nor the names of its */ +/* contributors may be used to endorse or promote products derived from */ +/* this software without specific prior written permission. */ +/* */ +/* 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. */ +/********************************************************************************/ + +/* This is not a public header. It should not be used by applications. */ + +#ifndef TSSDEV_H +#define TSSDEV_H + +#include <stdint.h> + +#ifdef __cplusplus +extern "C" { +#endif + + TPM_RC TSS_Tbsi_Transmit(TSS_CONTEXT *tssContext, + uint8_t *responseBuffer, uint32_t *read, + const uint8_t *commandBuffer, uint32_t written, + const char *message); + TPM_RC TSS_Tbsi_Close(TSS_CONTEXT *tssContext); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libstb/tss2/tsstransmit.c b/libstb/tss2/tsstransmit.c new file mode 100644 index 0000000..ac5536b --- /dev/null +++ b/libstb/tss2/tsstransmit.c @@ -0,0 +1,239 @@ +/********************************************************************************/ +/* */ +/* Transmit and Receive Utility */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: tsstransmit.c 1257 2018-06-27 20:52:08Z kgoldman $ */ +/* */ +/* (c) Copyright IBM Corporation 2015, 2017. */ +/* */ +/* All rights reserved. */ +/* */ +/* Redistribution and use in source and binary forms, with or without */ +/* modification, are permitted provided that the following conditions are */ +/* met: */ +/* */ +/* Redistributions of source code must retain the above copyright notice, */ +/* this list of conditions and the following disclaimer. */ +/* */ +/* 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. */ +/* */ +/* Neither the names of the IBM Corporation nor the names of its */ +/* contributors may be used to endorse or promote products derived from */ +/* this software without specific prior written permission. */ +/* */ +/* 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. */ +/********************************************************************************/ + +/* This file contains the interface that is not platform or interface specific + */ + +#include <string.h> +#include <stdio.h> + +#include "tssproperties.h" +#ifndef TPM_NOSOCKET +#include "tsssocket.h" +#endif +#include <ibmtss/tsserror.h> +#include <ibmtss/tssprint.h> + +#ifdef TPM_POSIX +#include "tssdev.h" +#endif + +#ifdef __ULTRAVISOR__ +#include "tssdevuv.h" +#endif + +#ifdef __SKIBOOT__ +#include "tssdevskiboot.h" +#endif + +#ifdef TPM_WINDOWS +#ifdef TPM_WINDOWS_TBSI +#include "tsstbsi.h" +#endif +#endif + +#include <ibmtss/tsstransmit.h> + +extern int tssVverbose; +extern int tssVerbose; + +/* local prototypes */ + +/* TSS_TransmitPlatform() transmits an administrative out of band command to the TPM. + + Supported by the simulator, not the TPM device. +*/ + +TPM_RC TSS_TransmitPlatform(TSS_CONTEXT *tssContext, uint32_t command, const char *message) +{ + TPM_RC rc = 0; + +#ifndef TPM_NOSOCKET + if ((strcmp(tssContext->tssInterfaceType, "socsim") == 0)) { + rc = TSS_Socket_TransmitPlatform(tssContext, command, message); + } + else +#else + command = command; + message = message; +#endif + if ((strcmp(tssContext->tssInterfaceType, "dev") == 0)) { + if (tssVerbose) printf("TSS_TransmitPlatform: device %s unsupported\n", + tssContext->tssInterfaceType); + rc = TSS_RC_INSUPPORTED_INTERFACE; + } + else { + if (tssVerbose) printf("TSS_TransmitPlatform: device %s unsupported\n", + tssContext->tssInterfaceType); + rc = TSS_RC_INSUPPORTED_INTERFACE; + } + return rc; +} + +/* TSS_Transmit() transmits a TPM command packet and receives a response. + +*/ + +TPM_RC TSS_Transmit(TSS_CONTEXT *tssContext, uint8_t *responseBuffer + __attribute__((unused)), uint32_t *read + __attribute__((unused)), const uint8_t *commandBuffer + __attribute__((unused)), uint32_t written + __attribute__((unused)), const char *message + __attribute__((unused))) +{ + TPM_RC rc = 0; + + if ((strcmp(tssContext->tssInterfaceType, "socsim") == 0)) { +#ifndef TPM_NOSOCKET + rc = TSS_Socket_Transmit(tssContext, + responseBuffer, read, + commandBuffer, written, + message); +#else + rc = TSS_RC_INSUPPORTED_INTERFACE; +#endif + } else if ((strcmp(tssContext->tssInterfaceType, "dev") == 0)) { +#ifndef TPM_NODEV +#ifdef TPM_POSIX /* transmit through Linux device driver */ + rc = TSS_Dev_Transmit(tssContext, + responseBuffer, read, + commandBuffer, written, + message); +#endif +#endif + +#ifdef TPM_WINDOWS /* transmit through Windows TBSI */ +#ifdef TPM_WINDOWS_TBSI + rc = TSS_Tbsi_Transmit(tssContext, + responseBuffer, read, + commandBuffer, written, + message); +#else + if (tssVerbose) printf("TSS_Transmit: device %s unsupported\n", + tssContext->tssInterfaceType); + rc = TSS_RC_INSUPPORTED_INTERFACE; +#endif +#endif + } else if ((strcmp(tssContext->tssInterfaceType, "uv") == 0)) { +#ifdef __ULTRAVISOR__ /* transmit through Ultravisor */ + rc = TSS_Dev_UV_Transmit(tssContext, + responseBuffer, read, + commandBuffer, written, + message); +#else + if (tssVerbose) printf("TSS_Transmit: device %s unsupported\n", + tssContext->tssInterfaceType); + rc = TSS_RC_INSUPPORTED_INTERFACE; +#endif + } else if (strcmp(tssContext->tssInterfaceType, "skiboot") == 0) { +#ifdef __SKIBOOT__ /* transmit through Skiboot */ + rc = TSS_Skiboot_Transmit(tssContext, responseBuffer, read, + commandBuffer, written, message); +#else + if (tssVerbose) + printf("TSS_Transmit: device %s unsupported\n", + tssContext->tssInterfaceType); + rc = TSS_RC_INSUPPORTED_INTERFACE; +#endif + } else { + if (tssVerbose) { + printf("TSS_Transmit: device %s unsupported\n", + tssContext->tssInterfaceType); + } + + rc = TSS_RC_INSUPPORTED_INTERFACE; + } + return rc; +} + +/* TSS_Close() closes the connection to the TPM */ + +TPM_RC TSS_Close(TSS_CONTEXT *tssContext) +{ + TPM_RC rc = 0; + + /* only close if there was an open */ + if (!tssContext->tssFirstTransmit) { +#ifndef TPM_NOSOCKET + if ((strcmp(tssContext->tssInterfaceType, "socsim") == 0)) { + rc = TSS_Socket_Close(tssContext); + } + else +#endif + if ((strcmp(tssContext->tssInterfaceType, "dev") == 0)) { +#ifndef TPM_NODEV +#ifdef TPM_POSIX /* transmit through Linux device driver */ + rc = TSS_Dev_Close(tssContext); +#endif +#endif + +#ifdef TPM_WINDOWS /* transmit through Windows TBSI */ +#ifdef TPM_WINDOWS_TBSI + rc = TSS_Tbsi_Close(tssContext); +#else + if (tssVerbose) printf("TSS_Transmit: device %s unsupported\n", + tssContext->tssInterfaceType); + rc = TSS_RC_INSUPPORTED_INTERFACE; +#endif +#endif + } else if ((strcmp(tssContext->tssInterfaceType, "uv") == 0)) { +#ifdef __ULTRAVISOR__ /* transmit through Ultravisor */ + rc = TSS_Dev_UV_Close(tssContext); +#else + if (tssVerbose) printf("TSS_Transmit: device %s unsupported\n", + tssContext->tssInterfaceType); + rc = TSS_RC_INSUPPORTED_INTERFACE; +#endif + } else if ((strcmp(tssContext->tssInterfaceType, "skiboot") == 0)) { +#ifdef __SKIBOOT__ /* transmit through Skiboot */ + rc = 0; +#else + if (tssVerbose) printf("TSS_Transmit: device %s unsupported\n", + tssContext->tssInterfaceType); + rc = TSS_RC_INSUPPORTED_INTERFACE; +#endif + } else { + if (tssVerbose) printf("TSS_Transmit: device %s unsupported\n", + tssContext->tssInterfaceType); + rc = TSS_RC_INSUPPORTED_INTERFACE; + } + tssContext->tssFirstTransmit = TRUE; + } + return rc; +} diff --git a/libstb/tss2/tssutils.c b/libstb/tss2/tssutils.c new file mode 100644 index 0000000..21ba81e --- /dev/null +++ b/libstb/tss2/tssutils.c @@ -0,0 +1,319 @@ +/********************************************************************************/ +/* */ +/* TSS and Application Utilities */ +/* Written by Ken Goldman */ +/* IBM Thomas J. Watson Research Center */ +/* $Id: tssutils.c 1294 2018-08-09 19:08:34Z kgoldman $ */ +/* */ +/* (c) Copyright IBM Corporation 2015 - 2018 */ +/* */ +/* All rights reserved. */ +/* */ +/* Redistribution and use in source and binary forms, with or without */ +/* modification, are permitted provided that the following conditions are */ +/* met: */ +/* */ +/* Redistributions of source code must retain the above copyright notice, */ +/* this list of conditions and the following disclaimer. */ +/* */ +/* 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. */ +/* */ +/* Neither the names of the IBM Corporation nor the names of its */ +/* contributors may be used to endorse or promote products derived from */ +/* this software without specific prior written permission. */ +/* */ +/* 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. */ +/********************************************************************************/ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <errno.h> + +#ifdef TPM_POSIX +#include <netinet/in.h> +#endif +#ifdef TPM_WINDOWS +#include <winsock2.h> +#endif + +#include <ibmtss/tssutils.h> +#include <ibmtss/tssresponsecode.h> +#include <ibmtss/tsserror.h> +#include <ibmtss/tssprint.h> + +/* the TSS context must be larger when files are not used, since TSS object and NV state is held in + the volatile context. The major factor is the number of TSS_OBJECT_PUBLIC slots. See + tssproperties.c */ +#ifdef TPM_TSS_NOFILE +#define TSS_ALLOC_MAX 0x12000 /* 73k bytes */ +#else +#define TSS_ALLOC_MAX 0x10000 /* 64k bytes */ +#endif + +extern int tssVerbose; +extern int tssVverbose; + +/* TSS_Malloc() is a general purpose wrapper around malloc() + */ + +TPM_RC TSS_Malloc(unsigned char **buffer, uint32_t size) +{ + TPM_RC rc = 0; + + /* assertion test. The coding style requires that all allocated pointers are initialized to + NULL. A non-NULL value indicates either a missing initialization or a pointer reuse (a + memory leak). */ + if (rc == 0) { + if (*buffer != NULL) { + if (tssVerbose) + printf("TSS_Malloc: Error (fatal), *buffer %p should be NULL before malloc\n", + *buffer); + rc = TSS_RC_ALLOC_INPUT; + } + } + /* verify that the size is not "too large" */ + if (rc == 0) { + if (size > TSS_ALLOC_MAX) { + if (tssVerbose) printf("TSS_Malloc: Error, size %u greater than maximum allowed\n", + size); + rc = TSS_RC_MALLOC_SIZE; + } + } + /* verify that the size is not 0, this would be implementation defined and should never occur */ + if (rc == 0) { + if (size == 0) { + if (tssVerbose) printf("TSS_Malloc: Error (fatal), size is zero\n"); + rc = TSS_RC_MALLOC_SIZE; + } + } + if (rc == 0) { + *buffer = malloc(size); + if (*buffer == NULL) { + if (tssVerbose) printf("TSS_Malloc: Error allocating %u bytes\n", size); + rc = TSS_RC_OUT_OF_MEMORY; + } + } + return rc; +} + +TPM_RC TSS_Realloc(unsigned char **buffer, uint32_t size) +{ + TPM_RC rc = 0; + unsigned char *tmpptr = NULL; + + /* verify that the size is not "too large" */ + if (rc == 0) { + if (size > TSS_ALLOC_MAX) { + if (tssVerbose) printf("TSS_Realloc: Error, size %u greater than maximum allowed\n", + size); + rc = TSS_RC_MALLOC_SIZE; + } + } + /* verify that the size is not 0, this should never occur */ + if (rc == 0) { + if (size == 0) { + if (tssVerbose) printf("TSS_Malloc: Error (fatal), size is zero\n"); + rc = TSS_RC_MALLOC_SIZE; + } + } + if (rc == 0) { + tmpptr = realloc(*buffer, size); + if (tmpptr == NULL) { + if (tssVerbose) printf("TSS_Realloc: Error reallocating %u bytes\n", size); + rc = TSS_RC_OUT_OF_MEMORY; + } + } + if (rc == 0) { + *buffer = tmpptr; + } + return rc; +} + + +/* TSS_Structure_Marshal() is a general purpose "marshal a structure" function. + + It marshals the structure using "marshalFunction", and returns the malloc'ed stream. + +*/ + +TPM_RC TSS_Structure_Marshal(uint8_t **buffer, /* freed by caller */ + uint16_t *written, + void *structure, + MarshalFunction_t marshalFunction) +{ + TPM_RC rc = 0; + uint8_t *buffer1 = NULL; /* for marshaling, moves pointer */ + + /* marshal once to calculates the byte length */ + if (rc == 0) { + *written = 0; + rc = marshalFunction(structure, written, NULL, NULL); + } + if (rc == 0) { + rc = TSS_Malloc(buffer, *written); + } + if (rc == 0) { + buffer1 = *buffer; + *written = 0; + rc = marshalFunction(structure, written, &buffer1, NULL); + } + return rc; +} + +/* TSS_TPM2B_Copy() copies source to target if the source fits the target size */ + +TPM_RC TSS_TPM2B_Copy(TPM2B *target, TPM2B *source, uint16_t targetSize) +{ + TPM_RC rc = 0; + + if (rc == 0) { + if (source->size > targetSize) { + if (tssVerbose) printf("TSS_TPM2B_Copy: size %u greater than target %u\n", + source->size, targetSize); + rc = TSS_RC_INSUFFICIENT_BUFFER; + } + } + if (rc == 0) { + memmove(target->buffer, source->buffer, source->size); + target->size = source->size; + } + return rc; +} + +/* TSS_TPM2B_Append() appends the source TPM2B to the target TPM2B. + + It checks that the source fits the target size. The target size is the total size, not the size + remaining. +*/ + +TPM_RC TSS_TPM2B_Append(TPM2B *target, TPM2B *source, uint16_t targetSize) +{ + TPM_RC rc = 0; + + if (rc == 0) { + if (target->size + source->size > targetSize) { + if (tssVerbose) printf("TSS_TPM2B_Append: size %u greater than target %u\n", + target->size + source->size, targetSize); + rc = TSS_RC_INSUFFICIENT_BUFFER; + } + } + if (rc == 0) { + memmove(target->buffer + target->size, source->buffer, source->size); + target->size += source->size; + } + return rc; +} + +/* TSS_TPM2B_Create() copies the buffer of 'size' into target, checking targetSize */ + +TPM_RC TSS_TPM2B_Create(TPM2B *target, uint8_t *buffer, uint16_t size, uint16_t targetSize) +{ + TPM_RC rc = 0; + + if (rc == 0) { + if (size > targetSize) { + if (tssVerbose) printf("TSS_TPM2B_Create: size %u greater than target %u\n", + size, targetSize); + rc = TSS_RC_INSUFFICIENT_BUFFER; + } + } + if (rc == 0) { + target->size = size; + memmove(target->buffer, buffer, size); + } + return rc; +} + +/* TSS_TPM2B_CreateUint32() creates a TPM2B from a uint32_t, typically a permanent handle */ + +TPM_RC TSS_TPM2B_CreateUint32(TPM2B *target, uint32_t source, uint16_t targetSize) +{ + TPM_RC rc = 0; + + if (rc == 0) { + if (sizeof(uint32_t) > targetSize) { + if (tssVerbose) printf("TSS_TPM2B_CreateUint32: size %u greater than target %u\n", + (unsigned int)sizeof(uint32_t), targetSize); + rc = TSS_RC_INSUFFICIENT_BUFFER; + } + } + if (rc == 0) { + uint32_t sourceNbo = htonl(source); + memmove(target->buffer, (uint8_t *)&sourceNbo, sizeof(uint32_t)); + target->size = sizeof(uint32_t); + } + return rc; +} + +/* TSS_TPM2B_StringCopy() copies a NUL terminated string (omitting the NUL) from source to target. + + It checks that the string will fit in targetSize. + + If source is NULL, creates a TPM2B of size 0. +*/ + +TPM_RC TSS_TPM2B_StringCopy(TPM2B *target, const char *source, uint16_t targetSize) +{ + TPM_RC rc = 0; + size_t length; + uint16_t length16 = 0; + + if (source != NULL) { + if (rc == 0) { + length = strlen(source); + if (length > 0xffff) { /* overflow TPM2B uint16_t */ + if (tssVerbose) printf("TSS_TPM2B_StringCopy: size %u greater than 0xffff\n", + (unsigned int)length); + rc = TSS_RC_INSUFFICIENT_BUFFER; + } + } + if (rc == 0) { + length16 = (uint16_t )length; /* cast safe after range test */ + if (length16 > targetSize) { + if (tssVerbose) printf("TSS_TPM2B_StringCopy: size %u greater than target %u\n", + length16, targetSize); + rc = TSS_RC_INSUFFICIENT_BUFFER; + } + } + if (rc == 0) { + target->size = length16; + memcpy(target->buffer, source, length); + } + } + else { + target->size = 0; + } + return rc; +} + +int TSS_TPM2B_Compare(TPM2B *expect, TPM2B *actual) +{ + int irc; + int match = YES; + + if (match == YES) { + if (expect->size != actual->size) { + match = NO; + } + } + if (match == YES) { + irc = memcmp(expect->buffer, actual->buffer, expect->size); + if (irc != 0) { + match = NO; + } + } + return match; +} diff --git a/libstb/tss2/tssuv.c b/libstb/tss2/tssuv.c new file mode 100644 index 0000000..97bdc37 --- /dev/null +++ b/libstb/tss2/tssuv.c @@ -0,0 +1,624 @@ +/********************************************************************************/ +/* */ +/* Ultravisor Support Interface */ +/* */ +/* (c) Copyright IBM Corporation 2019 */ +/* */ +/* All rights reserved. */ +/* */ +/* Redistribution and use in source and binary forms, with or without */ +/* modification, are permitted provided that the following conditions are */ +/* met: */ +/* */ +/* Redistributions of source code must retain the above copyright notice, */ +/* this list of conditions and the following disclaimer. */ +/* */ +/* 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. */ +/* */ +/* Neither the names of the IBM Corporation nor the names of its */ +/* contributors may be used to endorse or promote products derived from */ +/* this software without specific prior written permission. */ +/* */ +/* 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. */ +/********************************************************************************/ + +#ifdef __ULTRAVISOR__ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <stdint.h> + +#include <ibmtss/tss.h> +#include <ibmtss/tssfile.h> +#include <ibmtss/tssmarshal.h> +#include <ibmtss/tssresponsecode.h> +#include <ibmtss/Startup_fp.h> +#include "tssproperties.h" + +#include "tssuv.h" + +// PEF policyccdecrypt-auth +unsigned char pefpolicies_policyccdecrypt_auth_bin[] = { + 0x8d, 0xbd, 0x2a, 0xa1, 0x0f, 0x70, 0x1b, 0x1e, 0xda, 0x23, 0x0f, 0xa8, + 0xa3, 0x88, 0x03, 0xd3, 0x42, 0xf3, 0xb4, 0x8c, 0x2f, 0xfc, 0xbe, 0xd5, + 0x6c, 0x04, 0x67, 0x4c, 0x79, 0xdf, 0xf0, 0x0f +}; +unsigned int pefpolicies_policyccdecrypt_auth_bin_len = 32; + +// PEF axonepolicyb +unsigned char pefpolicies_axonepolicyb_bin[] = { + 0xfc, 0x02, 0xa3, 0x69, 0x58, 0xb0, 0x3f, 0xce, 0x29, 0x71, 0xa3, 0xb0, + 0x54, 0xb5, 0xad, 0xcc, 0x9d, 0x76, 0x3f, 0x54, 0xc9, 0x7f, 0x15, 0x83, + 0x7b, 0xc3, 0x71, 0x86, 0x65, 0x0f, 0xc4, 0xd3 +}; +unsigned int pefpolicies_axonepolicyb_bin_len = 32; + +TPMI_DH_OBJECT tss_uv_keyHandle = 0x81800000; + +#if 0 // Do not need this anymore? post ken readpublic update. +// h81800000.bin +unsigned char __h81800000_bin[] = { + 0x00, 0x0b, 0xf6, 0x53, 0xa9, 0xe0, 0xb0, 0x0f, 0x97, 0x76, 0x82, 0xa8, + 0x5e, 0xfb, 0xca, 0x3f, 0x59, 0x3d, 0x28, 0x3a, 0x1f, 0x10, 0xb5, 0x96, + 0xa6, 0x5e, 0x79, 0xf3, 0x45, 0x07, 0xa3, 0x6d, 0xe8, 0xe1 +}; +unsigned int __h81800000_bin_len = 34; +#endif + +/** @todo (andmike) Pub bin to be passed in from OPAL */ +unsigned char pefpolicies_o1pub_bin[] = { + 0x01, 0x38, 0x00, 0x01, 0x00, 0x0b, 0x00, 0x02, 0x0c, 0x20, 0x00, 0x20, + 0x63, 0x73, 0xdf, 0x8b, 0x9d, 0x61, 0xac, 0x6b, 0x5d, 0xd9, 0xac, 0x19, + 0x14, 0x63, 0x76, 0xb6, 0x64, 0x77, 0x58, 0x66, 0xde, 0x15, 0xd1, 0xc2, + 0x91, 0xef, 0x92, 0x6f, 0x55, 0xeb, 0x73, 0x20, 0x00, 0x10, 0x00, 0x17, + 0x00, 0x0b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0xc2, 0xf2, + 0x16, 0x20, 0x00, 0x01, 0x2c, 0xa1, 0xea, 0x99, 0x76, 0x44, 0x49, 0xe7, + 0x6b, 0xd6, 0xb6, 0x28, 0x51, 0x34, 0xc5, 0x2e, 0xa7, 0x4e, 0x0e, 0x7c, + 0x1b, 0x30, 0x03, 0xca, 0x7a, 0x0b, 0xe0, 0x8d, 0x7e, 0x44, 0x8e, 0x03, + 0x5e, 0x16, 0xdc, 0x79, 0xf1, 0x3a, 0x86, 0x2f, 0x66, 0xbc, 0xa0, 0x2d, + 0xb6, 0x5c, 0x73, 0x12, 0x6c, 0x00, 0xfa, 0xa7, 0xfa, 0x99, 0xb8, 0x9b, + 0xfe, 0x84, 0xf2, 0x9d, 0x0e, 0x98, 0xa9, 0x14, 0x74, 0x7d, 0x1d, 0x37, + 0x6c, 0x37, 0x31, 0xd0, 0x7a, 0xdf, 0x2b, 0xd4, 0x79, 0x96, 0xc4, 0xea, + 0xe2, 0x1b, 0x23, 0x6f, 0x20, 0x76, 0x9d, 0x02, 0xb5, 0xa9, 0xf8, 0xb8, + 0x92, 0x92, 0x1c, 0x45, 0x8d, 0xb2, 0x92, 0x7e, 0xb7, 0x23, 0x91, 0xeb, + 0x6d, 0x63, 0xfa, 0xea, 0x74, 0xea, 0x62, 0x0b, 0x6f, 0x25, 0x31, 0x3f, + 0x82, 0x8b, 0xf3, 0x42, 0x26, 0x32, 0xec, 0x5d, 0xfc, 0x66, 0x09, 0x06, + 0x21, 0xa0, 0xcf, 0x16, 0xd5, 0x36, 0x8f, 0x59, 0x09, 0x10, 0x21, 0xed, + 0x5b, 0xa7, 0x57, 0x04, 0x9a, 0x2d, 0xbd, 0x70, 0xc1, 0x9e, 0x67, 0x71, + 0xb3, 0x20, 0x1c, 0x8c, 0xa4, 0x8d, 0x56, 0x98, 0x8c, 0x35, 0xfc, 0x57, + 0x37, 0x7a, 0x3a, 0x30, 0xea, 0x79, 0xfd, 0x62, 0xae, 0xfe, 0x50, 0xb8, + 0xd2, 0x82, 0x7a, 0xe4, 0x5c, 0x8b, 0xd5, 0xfe, 0xf3, 0x21, 0x81, 0x9b, + 0x3f, 0xc2, 0x1f, 0x70, 0x0d, 0xe9, 0x84, 0xf1, 0x6e, 0xe4, 0xd8, 0x38, + 0x6f, 0xa6, 0x02, 0x45, 0x1c, 0xc3, 0x10, 0xf6, 0x32, 0x36, 0x2d, 0x92, + 0x81, 0x3e, 0x3c, 0xc5, 0x79, 0x80, 0x71, 0xf9, 0x58, 0xc2, 0xa9, 0x37, + 0xb2, 0xa0, 0xf4, 0x39, 0xbd, 0x92, 0x7f, 0xd5, 0x03, 0x86, 0xc3, 0x54, + 0x85, 0xec, 0x21, 0x80, 0x46, 0x0f, 0xb5, 0x55, 0x78, 0x69, 0x8c, 0x4e, + 0x2d, 0xe9 +}; + +unsigned int pefpolicies_o1pub_bin_len = 314; + +// /* TPM2B Types */ +// typedef struct { +// UINT16 size; +// BYTE buffer[1]; +// } TPM2B, *P2B; + +///* Table 71 - Definition of TPM2B_DIGEST Structure */ +// +// typedef struct { +// UINT16 size; +// BYTE buffer[sizeof(TPMU_HA)]; +// } DIGEST_2B; +// +// typedef union { +// DIGEST_2B t; +// TPM2B b; +// } TPM2B_DIGEST; + +// +// typedef struct { +// UINT32 count; /* number of digests in the list, mini mum is two for TPM2_PolicyOR(). */ +// TPM2B_DIGEST digests[8]; /* a list of digests */ +// } TPML_DIGEST; +// + +TPML_DIGEST tss_uv_tpml_hashlist; + +static void traceError(const char *command, TPM_RC rc) +{ + const char *msg; + const char *submsg; + const char *num; + printf("%s: failed, rc %08x\n", command, rc); + TSS_ResponseCode_toString(&msg, &submsg, &num, rc); + printf("%s%s%s\n", msg, submsg, num); +} + +/** + * @brief readpublic fills the TSS context object slot with the + * wrapping key public part. The Name is required for + * the HMAC calculation. + * + */ +static TPM_RC TSS_UV_ReadPublic(TSS_CONTEXT *tssContext, + const TPMI_DH_OBJECT keyHandle) +{ + TPM_RC rc; + ReadPublic_In *readPublicIn; + ReadPublic_Out *readPublicOut; + uint8_t *outPublicBuffer; + uint16_t outPublicWritten; + + readPublicIn = NULL; + readPublicOut = NULL; + outPublicBuffer = NULL; + + rc = TSS_Malloc((unsigned char **)&readPublicIn, + sizeof(*readPublicIn)); + if (rc) { + traceError("readPublicIn malloc", rc); + goto out; + } + + rc = TSS_Malloc((unsigned char **)&readPublicOut, + sizeof(*readPublicOut)); + if (rc) { + traceError("readPublicOut malloc", rc); + goto readpublic_free; + } + + readPublicIn->objectHandle = keyHandle; + + rc = TSS_Execute(tssContext, + (RESPONSE_PARAMETERS *)readPublicOut, + (COMMAND_PARAMETERS *)readPublicIn, + NULL, + TPM_CC_ReadPublic, + TPM_RH_NULL, NULL, 0); + if (rc) { + goto readpublic_free; + } + + /* marshal the wrapping key public part for the compare */ + rc = TSS_Structure_Marshal(&outPublicBuffer, + &outPublicWritten, + &readPublicOut->outPublic, + (MarshalFunction_t)TSS_TPM2B_PUBLIC_Marshalu); + if (rc) { + goto public_buffer_free; + } + + if (outPublicWritten != pefpolicies_o1pub_bin_len) { + rc = 1; + goto public_buffer_free; + } + + rc = memcmp(outPublicBuffer, pefpolicies_o1pub_bin, + pefpolicies_o1pub_bin_len); + +public_buffer_free: + free(outPublicBuffer); +readpublic_free: + free(readPublicOut); + free(readPublicIn); +out: + return rc; +} + +static void TSS_UV_Init_Decrypt_Hashlist(TPML_DIGEST *hashlist) +{ + TPM2B *tpm2b; + uint16_t targetSize; + + hashlist->count = 2; + + /* PEF policyccdecrypt-auth */ + tpm2b = &hashlist->digests[0].b; + targetSize = sizeof(hashlist->digests[0].t.buffer); + TSS_TPM2B_Create(tpm2b, pefpolicies_policyccdecrypt_auth_bin, + (uint16_t)pefpolicies_policyccdecrypt_auth_bin_len, + targetSize); + + /* PEF axonepolicyb */ + tpm2b = &hashlist->digests[1].b; + targetSize = sizeof(hashlist->digests[1].t.buffer); + TSS_TPM2B_Create(tpm2b, pefpolicies_axonepolicyb_bin, + (uint16_t)pefpolicies_axonepolicyb_bin_len, + targetSize); +} + +static TPM_RC TSS_UV_Policy_AuthValue_In(TSS_CONTEXT *tssContext, + TPMI_SH_AUTH_SESSION sessionHandle) +{ + TPM_RC rc; + PolicyAuthValue_In policyAuthValueIn; + + policyAuthValueIn.policySession = sessionHandle; + rc = TSS_Execute(tssContext, + NULL, + (COMMAND_PARAMETERS *)&policyAuthValueIn, + NULL, + TPM_CC_PolicyAuthValue, + TPM_RH_NULL, NULL, 0); + + return rc; +} + +static TPM_RC TSS_UV_Policy_Or_In(TSS_CONTEXT *tssContext, + TPMI_SH_AUTH_SESSION sessionHandle) +{ + TPM_RC rc; + TPML_DIGEST *pHashList = &tss_uv_tpml_hashlist; + PolicyOR_In *policyORIn; + + TSS_UV_Init_Decrypt_Hashlist(pHashList); + + policyORIn = NULL; + + rc = TSS_Malloc((unsigned char **)&policyORIn, sizeof(*policyORIn)); + if (rc) { + traceError("policyORIn malloc", rc); + goto out; + } + + policyORIn->policySession = sessionHandle; + policyORIn->pHashList = *pHashList; + rc = TSS_Execute(tssContext, + NULL, + (COMMAND_PARAMETERS *)policyORIn, + NULL, + TPM_CC_PolicyOR, + TPM_RH_NULL, NULL, 0); + + free(policyORIn); + +out: + return rc; +} + +static TPM_RC TSS_UV_Policy_RSA_Decrypt(TSS_CONTEXT *tssContext, + TPMI_SH_AUTH_SESSION sessionHandle) +{ + TPM_RC rc; + PolicyCommandCode_In policyCommandCodeIn; + + policyCommandCodeIn.policySession = sessionHandle; + policyCommandCodeIn.code = TPM_CC_RSA_Decrypt; + rc = TSS_Execute(tssContext, + NULL, + (COMMAND_PARAMETERS *)&policyCommandCodeIn, + NULL, + TPM_CC_PolicyCommandCode, + TPM_RH_NULL, NULL, 0); + + return rc; +} + +static TPM_RC TSS_UV_Start_Auth_Session(TSS_CONTEXT *tssContext, + TPMI_SH_AUTH_SESSION *sessionHandle) +{ + TPM_RC rc; + StartAuthSession_In *startAuthSessionIn; + StartAuthSession_Out *startAuthSessionOut; + StartAuthSession_Extra *startAuthSessionExtra; + + startAuthSessionIn = NULL; + startAuthSessionOut = NULL; + startAuthSessionExtra = NULL; + + rc = TSS_Malloc((unsigned char **)&startAuthSessionIn, sizeof(*startAuthSessionIn)); + if (rc) { + traceError("startAuthSessionIn malloc", rc); + goto out; + } + + rc = TSS_Malloc((unsigned char **)&startAuthSessionOut, sizeof(*startAuthSessionOut)); + if (rc) { + traceError("startAuthSessionOut malloc", rc); + goto auth_session_free; + } + + rc = TSS_Malloc((unsigned char **)&startAuthSessionExtra, sizeof(*startAuthSessionExtra)); + if (rc) { + traceError("startAuthSessionExtra malloc", rc); + goto auth_session_free; + } + + startAuthSessionIn->sessionType = TPM_SE_POLICY; + startAuthSessionIn->tpmKey = TPM_RH_NULL; + startAuthSessionIn->bind = TPM_RH_NULL; + startAuthSessionIn->encryptedSalt.b.size = 0; /* (not required) */ + startAuthSessionIn->nonceCaller.t.size = 0; /* (not required) */ + startAuthSessionIn->symmetric.algorithm = TPM_ALG_AES; + startAuthSessionIn->authHash = TPM_ALG_SHA256; + startAuthSessionIn->symmetric.keyBits.aes = 128; + startAuthSessionIn->symmetric.mode.aes = TPM_ALG_CFB; + startAuthSessionExtra->bindPassword = NULL; /* (not required) */ + rc = TSS_Execute(tssContext, + (RESPONSE_PARAMETERS *)startAuthSessionOut, + (COMMAND_PARAMETERS *)startAuthSessionIn, + (EXTRA_PARAMETERS *)startAuthSessionExtra, + TPM_CC_StartAuthSession, + TPM_RH_NULL, NULL, 0); + if (rc) { + goto auth_session_free; + } + + *sessionHandle = startAuthSessionOut->sessionHandle; + +auth_session_free: + free(startAuthSessionIn); + free(startAuthSessionOut); + free(startAuthSessionExtra); +out: + return rc; +} + +#if 0 +static TPM_RC TSS_NvPublic_GetSlotForHandle(TSS_CONTEXT *tssContext, + size_t *slotIndex, + TPMI_RH_NV_INDEX nvIndex) +{ + size_t i; + + /* search all slots for handle */ + for (i = 0 ; i < (sizeof(tssContext->nvPublic) / sizeof(TSS_NVPUBLIC)) ; i++) { + if (tssContext->nvPublic[i].nvIndex == nvIndex) { + *slotIndex = i; + return 0; + } + } + return TSS_RC_NO_NVPUBLIC_SLOT; +} +#endif + +#if 0 +static TPM_RC TSS_ObjectPublic_GetSlotForHandle(TSS_CONTEXT *tssContext, + size_t *slotIndex, + TPM_HANDLE handle) +{ + size_t i; + + /* search all slots for handle */ + for (i = 0 ; i < (sizeof(tssContext->sessions) / sizeof(TSS_SESSIONS)) ; i++) { + if (tssContext->objectPublic[i].objectHandle == handle) { + *slotIndex = i; + return 0; + } + } + return TSS_RC_NO_OBJECTPUBLIC_SLOT; +} +#endif + +#if 0 +static TPM_RC TSS_Name_Store(TSS_CONTEXT *tssContext, + TPM2B_NAME *name, + TPM_HANDLE handle, + const char *string) +{ + TPM_RC rc = 0; + TPM_HT handleType; + size_t slotIndex; + + printf("TSS_Name_Store: Handle %08x\n", handle); + handleType = (TPM_HT) ((handle & HR_RANGE_MASK) >> HR_SHIFT); + + switch (handleType) { + case TPM_HT_NV_INDEX: + /* for NV, the Name was returned at creation */ + rc = TSS_NvPublic_GetSlotForHandle(tssContext, &slotIndex, handle); + if (rc != 0) { + rc = TSS_NvPublic_GetSlotForHandle(tssContext, &slotIndex, TPM_RH_NULL); + if (rc == 0) { + tssContext->nvPublic[slotIndex].nvIndex = handle; + } + else { + printf("TSS_Name_Store: Error, no slot available for handle %08x\n", handle); + } + } + if (rc == 0) { + tssContext->nvPublic[slotIndex].name = *name; + } + break; + case TPM_HT_TRANSIENT: + case TPM_HT_PERSISTENT: + if (rc == 0) { + if (string == NULL) { + if (handle != 0) { + /* if this handle is already used, overwrite the slot */ + rc = TSS_ObjectPublic_GetSlotForHandle(tssContext, &slotIndex, handle); + if (rc != 0) { + rc = TSS_ObjectPublic_GetSlotForHandle(tssContext, &slotIndex, TPM_RH_NULL); + if (rc == 0) { + tssContext->objectPublic[slotIndex].objectHandle = handle; + } + else { + printf("TSS_Name_Store: " + "Error, no slot available for handle %08x\n", + handle); + } + } + } + else { + printf("TSS_Name_Store: handle and string are both null"); + rc = TSS_RC_NAME_FILENAME; + } + } + else { + if (handle == 0) { + printf("TSS_Name_Store: string unimplemented"); + rc = TSS_RC_NAME_FILENAME; + } + else { + printf("TSS_Name_Store: handle and string are both not null"); + rc = TSS_RC_NAME_FILENAME; + } + } + } + if (rc == 0) { + tssContext->objectPublic[slotIndex].name = *name; + } + break; + default: + printf("TSS_Name_Store: handle type %02x unimplemented", handleType); + rc = TSS_RC_NAME_FILENAME; + } + return rc; +} +#endif + +/* + TSS_UV_Decrypt() + + The policies contain 3 terms: + + Policy A should be a constant + Policy B should be a constant based on the NV index attributes + Policy C is calculated using the duplication authority public key + + @ uvContext input, uv context + @ keyPassword input, pointer to nul terminated string password + @ decLength output, pointer to decrypted data length + @ decBuffer output, pointer to decrypted data + @ encLength input, encrypted data length + @ encBuffer input, encrypted data + TBD Items below: + @ keyHandle input, TPM decryption key persistent handle, perhaps #define constant + @ pHashList input, pointer to a TPML_DIGEST containing the policy OR terms +*/ + +TPM_RC TSS_UV_Decrypt(void *uvContext, const char *keyPassword, + uint16_t *decLength, uint8_t *decBuffer, + uint16_t encLength, const uint8_t *encBuffer) +{ + TPM_RC rc, _rc; + TSS_CONTEXT *tssContext; + TPMI_SH_AUTH_SESSION sessionHandle; + TPMI_DH_OBJECT keyHandle = tss_uv_keyHandle; + RSA_Decrypt_In *rsa_DecryptIn; + RSA_Decrypt_Out *rsa_DecryptOut; + + printf("%s: Enter pwd %s\n", __func__, keyPassword); + + /* Start a TSS context */ + rc = TSS_Create(&tssContext); + if (rc) { + return rc; + } + + /* Set uv_ctx and interface type*/ + tssContext->uv_ctx = uvContext; + tssContext->tssInterfaceType = "uv"; + + rc = TSS_UV_ReadPublic(tssContext, keyHandle); + if (rc) { + traceError("readpublic", rc); + goto out; + } + + /* start the policy session */ + rc = TSS_UV_Start_Auth_Session(tssContext, &sessionHandle); + if (rc) { + traceError("startauthsession", rc); + goto out; + } + + /* Policy Command Code RSA Decrypt */ + rc = TSS_UV_Policy_RSA_Decrypt(tssContext, sessionHandle); + if (rc) { + traceError("policycommandcode", rc); + goto out; + } + + /* policy authvalue */ + rc = TSS_UV_Policy_AuthValue_In(tssContext, sessionHandle); + if (rc) { + traceError("policyAuthValueIn", rc); + goto out; + } + + /* policy or */ + rc = TSS_UV_Policy_Or_In(tssContext, sessionHandle); + if (rc) { + traceError("policyor", rc); + goto out; + } + + /* decrypt the encrypted secret */ + rsa_DecryptIn = NULL; + rsa_DecryptOut = NULL; + + rc = TSS_Malloc((unsigned char **)&rsa_DecryptIn, sizeof(*rsa_DecryptIn)); + if (rc) { + traceError("rsa_DecryptIn malloc", rc); + goto out; + } + + rc = TSS_Malloc((unsigned char **)&rsa_DecryptOut, sizeof(*rsa_DecryptOut)); + if (rc) { + traceError("rsa_DecryptOut malloc", rc); + goto rsa_decrypt_in_free; + } + + rsa_DecryptIn->keyHandle = keyHandle; + rsa_DecryptIn->cipherText.t.size = (uint16_t)encLength; /* cast safe, range tested above */ + memcpy(rsa_DecryptIn->cipherText.t.buffer, encBuffer, encLength); + rsa_DecryptIn->inScheme.scheme = TPM_ALG_NULL; + rsa_DecryptIn->label.t.size = 0; + rc = TSS_Execute(tssContext, + (RESPONSE_PARAMETERS *)rsa_DecryptOut, + (COMMAND_PARAMETERS *)rsa_DecryptIn, + NULL, + TPM_CC_RSA_Decrypt, + sessionHandle, keyPassword, TPMA_SESSION_ENCRYPT, + TPM_RH_NULL, NULL, 0); + if (rc) { + traceError("rsa_decrypt", rc); + goto rsa_decrypt_out_free; + } + + /* Open code TSS_Structure_Marshal as malloc not needed on pre-allocated buffer */ + /* marshal once to calculates the byte length */ + *decLength = 0; + rc = TSS_TPM2B_PUBLIC_KEY_RSA_Marshal(&rsa_DecryptOut->message, + decLength, NULL, NULL); + if (rc == 0) { + uint8_t *buffer1 = decBuffer; /* for marshaling, moves pointer */ + *decLength = 0; + rc = TSS_TPM2B_PUBLIC_KEY_RSA_Marshal(&rsa_DecryptOut->message, + decLength, &buffer1, NULL); + /* Adjust for return data containing length information */ + buffer1 = decBuffer + sizeof(uint16_t); + *decLength = *decLength - sizeof(uint16_t); + memmove(decBuffer, buffer1, *decLength); + } + + +rsa_decrypt_out_free: + free(rsa_DecryptOut); +rsa_decrypt_in_free: + free(rsa_DecryptIn); +out: + _rc = TSS_Delete(tssContext); + if (rc == 0) { + rc = _rc; + } + + return rc; +} + +#endif /* __ULTRAVISOR__ */ diff --git a/libstb/tss2/tssuv.h b/libstb/tss2/tssuv.h new file mode 100644 index 0000000..5f11dc8 --- /dev/null +++ b/libstb/tss2/tssuv.h @@ -0,0 +1,48 @@ +/********************************************************************************/ +/* */ +/* UV Interface */ +/* */ +/* (c) Copyright IBM Corporation 2019. */ +/* */ +/* All rights reserved. */ +/* */ +/* Redistribution and use in source and binary forms, with or without */ +/* modification, are permitted provided that the following conditions are */ +/* met: */ +/* */ +/* Redistributions of source code must retain the above copyright notice, */ +/* this list of conditions and the following disclaimer. */ +/* */ +/* 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. */ +/* */ +/* Neither the names of the IBM Corporation nor the names of its */ +/* contributors may be used to endorse or promote products derived from */ +/* this software without specific prior written permission. */ +/* */ +/* 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 TSSUV_H +#define TSSUV_H + +#include <stddef.h> +#include <stdint.h> +#include <assert.h> + +extern uint32_t TSS_UV_Decrypt(void *uvContext, const char *keyPassword, + uint16_t *decLength, uint8_t *decBuffer, + uint16_t encLength, const uint8_t *encBuffer); + +#endif |