mirror of
https://github.com/stefanberger/libtpms
synced 2026-08-11 19:26:27 +00:00
Sync: Implemented debugging macros and enable with build switch
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
This commit is contained in:
parent
d94eb5644c
commit
ddc610eaa6
@ -556,6 +556,7 @@ noinst_HEADERS += \
|
||||
tpm2/TpmProfile_Misc.h \
|
||||
tpm2/Tpm.h \
|
||||
tpm2/TpmBigNum.h \
|
||||
tpm2/tpm_debug.h \
|
||||
tpm2/tpm_public.h \
|
||||
tpm2/tpm_to_platform_interface.h \
|
||||
tpm2/_TPM_Hash_Data_fp.h \
|
||||
|
||||
@ -9,6 +9,7 @@
|
||||
|
||||
//** Includes and Local
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <time.h>
|
||||
#include "Platform.h"
|
||||
|
||||
@ -86,3 +87,39 @@ void DebugDumpBuffer(int size, unsigned char* buf, const char* identifier)
|
||||
}
|
||||
|
||||
#endif // CERTIFYX509_DEBUG
|
||||
|
||||
#if ENABLE_TPM_DEBUG_PRINT
|
||||
|
||||
LIB_EXPORT void _plat_debug_print(const char* str)
|
||||
{
|
||||
printf("%s\n", str);
|
||||
}
|
||||
|
||||
LIB_EXPORT void _plat_debug_print_buffer(const void* buf, const size_t size)
|
||||
{
|
||||
NOT_REFERENCED(buf);
|
||||
NOT_REFERENCED(size);
|
||||
// not implemented
|
||||
}
|
||||
|
||||
LIB_EXPORT void _plat_debug_print_int32(const char* name, uint32_t value)
|
||||
{
|
||||
printf("%s=0x%04x\n", name, value);
|
||||
}
|
||||
|
||||
LIB_EXPORT void _plat_debug_print_int64(const char* name, uint64_t value)
|
||||
{
|
||||
printf("%s=0x%04x:%04x\n",
|
||||
name,
|
||||
(uint32_t)(value >> 32),
|
||||
(uint32_t)(value & 0xFFFFFFFF));
|
||||
}
|
||||
|
||||
LIB_EXPORT void _plat_debug_printf(const char* fmt, ...)
|
||||
{
|
||||
va_list params;
|
||||
va_start(params, fmt);
|
||||
vprintf(fmt, params);
|
||||
}
|
||||
|
||||
#endif // ENABLE_TPM_DEBUG_PRINT
|
||||
|
||||
@ -53,6 +53,17 @@
|
||||
// ones in the Simulator project.
|
||||
#define SIMULATION NO // libtpms: changed to NO
|
||||
|
||||
// ENABLE_TPM_DEBUG_PRINT enables arbitrary string printing.
|
||||
// enables the TPM_DEBUG_PRINT macro to route debugging strings
|
||||
// to the _plat_debug_out function
|
||||
#define ENABLE_TPM_DEBUG_PRINT (YES * SIMULATION)
|
||||
|
||||
// ENABLE_TPM_DEBUG_TRACE enables code tracing macros - depends on TPM_DEBUG_PRINT
|
||||
#define ENABLE_TPM_DEBUG_TRACE (NO * ENABLE_TPM_DEBUG_PRINT)
|
||||
|
||||
// ENABLE_CRYPTO_DEBUG enables printing of actual crypto values. This is entirely insecure.
|
||||
#define ENABLE_CRYPTO_DEBUG (YES * ENABLE_TPM_DEBUG_PRINT)
|
||||
|
||||
// The CRYPTO_LIB_REPORTING switch allows the TPM to report its
|
||||
// crypto library implementation, e.g., at simulation startup.
|
||||
#define CRYPTO_LIB_REPORTING NO // libtpms: NO
|
||||
|
||||
@ -1,62 +1,4 @@
|
||||
/********************************************************************************/
|
||||
/* */
|
||||
/* Failure Mode Handling */
|
||||
/* 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, 2016 - 2023 */
|
||||
/* */
|
||||
/********************************************************************************/
|
||||
// SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
//** Includes, Defines, and Types
|
||||
#define TPM_FAIL_C
|
||||
@ -334,7 +276,8 @@ void TpmFailureMode(uint32_t inRequestSize, // IN: command buffer size
|
||||
unsigned char** outResponse // OUT: response buffer
|
||||
)
|
||||
{
|
||||
UINT32 marshalSize;
|
||||
TPM_DEBUG_TRACE();
|
||||
UINT32 marshalSize; // final size of the response.
|
||||
UINT32 capability;
|
||||
HEADER header; // unmarshaled command header
|
||||
UINT32 pt; // unmarshaled property type
|
||||
@ -342,6 +285,8 @@ void TpmFailureMode(uint32_t inRequestSize, // IN: command buffer size
|
||||
UINT8* buffer = inRequest;
|
||||
INT32 size = inRequestSize;
|
||||
|
||||
//TPM_DEBUG_PRINT("In TpmFailureMode)");
|
||||
|
||||
// If there is no command buffer, then just return TPM_RC_FAILURE
|
||||
if(inRequestSize == 0 || inRequest == NULL)
|
||||
goto FailureModeReturn;
|
||||
@ -452,6 +397,7 @@ void TpmFailureMode(uint32_t inRequestSize, // IN: command buffer size
|
||||
marshalSize += MarshalUint32(pt, &buffer);
|
||||
break;
|
||||
default: // default for switch (cc)
|
||||
//TPM_DEBUG_PRINT(" goto FailureModeReturn from default");
|
||||
goto FailureModeReturn;
|
||||
}
|
||||
// Now do the header
|
||||
@ -468,7 +414,9 @@ void TpmFailureMode(uint32_t inRequestSize, // IN: command buffer size
|
||||
FailureModeReturn:
|
||||
buffer = response;
|
||||
marshalSize = MarshalUint16(TPM_ST_NO_SESSIONS, &buffer);
|
||||
//TPM_DEBUG_PRINT("FailureModeReturn:2");
|
||||
marshalSize += MarshalUint32(10, &buffer);
|
||||
//TPM_DEBUG_PRINT("FailureModeReturn:3");
|
||||
marshalSize += MarshalUint32(TPM_RC_FAILURE, &buffer);
|
||||
*outResponseSize = marshalSize;
|
||||
*outResponse = (unsigned char*)response;
|
||||
|
||||
@ -1,62 +1,4 @@
|
||||
/********************************************************************************/
|
||||
/* */
|
||||
/* */
|
||||
/* 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, 2023 */
|
||||
/* */
|
||||
/********************************************************************************/
|
||||
// SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
//** Introduction
|
||||
// This file contains debug utility functions to help testing Ecc.
|
||||
@ -99,6 +41,8 @@ static LIB_EXPORT BYTE FromHex(unsigned char c)
|
||||
return c - '0';
|
||||
else if(c >= 'A' && c <= 'F')
|
||||
return c - 'A';
|
||||
else if(c >= 'a' && c <= 'f')
|
||||
return c - 'a';
|
||||
|
||||
return 255;
|
||||
}
|
||||
|
||||
@ -1,63 +1,4 @@
|
||||
/********************************************************************************/
|
||||
/* */
|
||||
/* TPM Size Checks */
|
||||
/* Written by Ken Goldman */
|
||||
/* IBM Thomas J. Watson Research Center */
|
||||
/* $Id: TpmSizeChecks.c 1628 2020-05-27 19:35:29Z 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 - 2020 */
|
||||
/* */
|
||||
/********************************************************************************/
|
||||
// SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
//** Includes, Defines, and Types
|
||||
#include "Tpm.h"
|
||||
@ -135,17 +76,20 @@ BOOL TpmSizeChecks(void)
|
||||
}
|
||||
# endif // ALG_RSA
|
||||
# if TABLE_DRIVEN_MARSHAL
|
||||
printf("sizeof(MarshalData) = %zu\n", sizeof(MarshalData_st));
|
||||
TPM_DEBUG_PRINTF("sizeof(MarshalData) = %zu\n", sizeof(MarshalData_st));
|
||||
# endif
|
||||
|
||||
printf("Size of OBJECT = %zu\n", sizeof(OBJECT));
|
||||
printf("Size of components in TPMT_SENSITIVE = %zu\n",
|
||||
sizeof(TPMT_SENSITIVE));
|
||||
printf(" TPMI_ALG_PUBLIC %zu\n", sizeof(TPMI_ALG_PUBLIC));
|
||||
printf(" TPM2B_AUTH %zu\n", sizeof(TPM2B_AUTH));
|
||||
printf(" TPM2B_DIGEST %zu\n", sizeof(TPM2B_DIGEST));
|
||||
printf(" TPMU_SENSITIVE_COMPOSITE %zu\n",
|
||||
sizeof(TPMU_SENSITIVE_COMPOSITE));
|
||||
TPM_DEBUG_PRINTF("Size of OBJECT = %zu\n", sizeof(OBJECT));
|
||||
TPM_DEBUG_PRINTF("Size of components in TPMT_SENSITIVE = %zu\n",
|
||||
sizeof(TPMT_SENSITIVE));
|
||||
TPM_DEBUG_PRINTF(" TPMI_ALG_PUBLIC %zu\n",
|
||||
sizeof(TPMI_ALG_PUBLIC));
|
||||
TPM_DEBUG_PRINTF(" TPM2B_AUTH %zu\n",
|
||||
sizeof(TPM2B_AUTH));
|
||||
TPM_DEBUG_PRINTF(" TPM2B_DIGEST %zu\n",
|
||||
sizeof(TPM2B_DIGEST));
|
||||
TPM_DEBUG_PRINTF(" TPMU_SENSITIVE_COMPOSITE %zu\n",
|
||||
sizeof(TPMU_SENSITIVE_COMPOSITE));
|
||||
}
|
||||
// Make sure that the size of the context blob is large enough for the largest
|
||||
// context
|
||||
@ -175,16 +119,17 @@ BOOL TpmSizeChecks(void)
|
||||
|
||||
if(MAX_CONTEXT_SIZE < biggestContext)
|
||||
{
|
||||
printf("MAX_CONTEXT_SIZE needs to be increased to at least %d (%d)\n",
|
||||
biggestContext,
|
||||
MAX_CONTEXT_SIZE);
|
||||
TPM_DEBUG_PRINTF("MAX_CONTEXT_SIZE needs to be increased to at least %d "
|
||||
"(%d)\n",
|
||||
biggestContext,
|
||||
MAX_CONTEXT_SIZE);
|
||||
PASS = FALSE;
|
||||
}
|
||||
else if(MAX_CONTEXT_SIZE > biggestContext)
|
||||
{
|
||||
printf("MAX_CONTEXT_SIZE can be reduced to %d (%d)\n",
|
||||
biggestContext,
|
||||
MAX_CONTEXT_SIZE);
|
||||
TPM_DEBUG_PRINTF("MAX_CONTEXT_SIZE can be reduced to %d (%d)\n",
|
||||
biggestContext,
|
||||
MAX_CONTEXT_SIZE);
|
||||
}
|
||||
}
|
||||
{
|
||||
@ -201,12 +146,13 @@ BOOL TpmSizeChecks(void)
|
||||
SET_ATTRIBUTE(u.attributes, TPMA_OBJECT, fixedTPM);
|
||||
if(u.uint32Value != 2)
|
||||
{
|
||||
printf("The bit allocation in a TPMA_OBJECT is not as expected");
|
||||
TPM_DEBUG_PRINT("The bit allocation in a TPMA_OBJECT is not as "
|
||||
"expected");
|
||||
PASS = FALSE;
|
||||
}
|
||||
if(aSize != uSize) // comparison of two sizeof() values annoys compiler
|
||||
{
|
||||
printf("A TPMA_OBJECT is not the expected size.");
|
||||
TPM_DEBUG_PRINT("A TPMA_OBJECT is not the expected size.");
|
||||
PASS = FALSE;
|
||||
}
|
||||
}
|
||||
@ -222,7 +168,8 @@ BOOL TpmSizeChecks(void)
|
||||
FOR_EACH_ACT(CASE_ACT_NUMBER)
|
||||
if(!_plat__ACT_GetImplemented(act))
|
||||
{
|
||||
printf("TPM_RH_ACT_%1X is not implemented by platform\n", act);
|
||||
TPM_DEBUG_PRINTF(
|
||||
"TPM_RH_ACT_%1X is not implemented by platform\n", act);
|
||||
PASS = FALSE;
|
||||
}
|
||||
default:
|
||||
@ -237,7 +184,8 @@ BOOL TpmSizeChecks(void)
|
||||
int t = MAX_DIGEST_SIZE;
|
||||
if(t < 20)
|
||||
{
|
||||
printf("Check the MAX_DIGEST_SIZE computation (%d)", MAX_DIGEST_SIZE);
|
||||
TPM_DEBUG_PRINTF("Check the MAX_DIGEST_SIZE computation (%d)",
|
||||
MAX_DIGEST_SIZE);
|
||||
PASS = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,6 +18,7 @@ MUST_BE(NO == 0);
|
||||
// Debug Options
|
||||
MUST_BE_0_OR_1(DEBUG);
|
||||
MUST_BE_0_OR_1(SIMULATION);
|
||||
MUST_BE_0_OR_1(ENABLE_TPM_DEBUG_PRINT);
|
||||
MUST_BE_0_OR_1(DRBG_DEBUG_PRINT);
|
||||
MUST_BE_0_OR_1(CERTIFYX509_DEBUG);
|
||||
MUST_BE_0_OR_1(USE_DEBUG_RNG);
|
||||
@ -76,7 +77,7 @@ MUST_BE_0_OR_1(VENDOR_PERMANENT_AUTH_ENABLED);
|
||||
|
||||
#if !DEBUG
|
||||
# if USE_KEY_CACHE_FILE || USE_RSA_KEY_CACHE || DRBG_DEBUG_PRINT \
|
||||
|| CERTIFYX509_DEBUG || USE_DEBUG_RNG
|
||||
|| CERTIFYX509_DEBUG || USE_DEBUG_RNG || ENABLE_TPM_DEBUG_PRINT
|
||||
# error using insecure options not in DEBUG mode.
|
||||
# endif
|
||||
#endif
|
||||
|
||||
73
src/tpm2/tpm_debug.h
Normal file
73
src/tpm2/tpm_debug.h
Normal file
@ -0,0 +1,73 @@
|
||||
// SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
#ifndef _TPM_DEBUG_H_
|
||||
#define _TPM_DEBUG_H_
|
||||
|
||||
#include "tpm_to_platform_interface.h"
|
||||
|
||||
// Basic Debug Printing
|
||||
#if ENABLE_TPM_DEBUG_PRINT
|
||||
|
||||
# define TPM_DEBUG_PRINT(s) _plat_debug_print(s)
|
||||
# define TPM_DEBUG_PRINT_BUFFER(buf, size) _plat_debug_print_buffer(buf, size)
|
||||
# define TPM_DEBUG_PRINT_INT32(name, value) _plat_debug_print_int32(name, value)
|
||||
# define TPM_DEBUG_PRINT_INT64(name, value) _plat_debug_print_int64(name, value)
|
||||
// use the TPM_DEBUG_PRINTF versions only if there are extra arguments.
|
||||
// GCC doesn't support an empty variable list, use TPM_DEBUG_PRINT instead.
|
||||
# define TPM_DEBUG_PRINTF(s, ...) _plat_debug_printf(s, __VA_ARGS__)
|
||||
# define TPM_DEBUG_SNPRINTF(buf, bufsize, s, ...) \
|
||||
_plat_debug_snprintf(buf, bufsize, s, __VA_ARGS__)
|
||||
|
||||
#else
|
||||
|
||||
# define TPM_DEBUG_PRINT(s)
|
||||
# define TPM_DEBUG_PRINT_BUFFER(buf, size)
|
||||
# define TPM_DEBUG_PRINT_INT32(name, value)
|
||||
# define TPM_DEBUG_PRINT_INT64(name, value)
|
||||
# define TPM_DEBUG_PRINTF(s, ...)
|
||||
# define TPM_DEBUG_SNPRINTF(buf, bufsize, s, ...)
|
||||
|
||||
#endif // ENABLE_TPM_DEBUG_PRINT
|
||||
|
||||
// Verbose Code Path tracing
|
||||
#if ENABLE_TPM_DEBUG_TRACE && ENABLE_TPM_DEBUG_PRINT
|
||||
|
||||
# define TPM_DEBUG_TRACEX(extra) \
|
||||
TPM_DEBUG_PRINT(__func__); \
|
||||
TPM_DEBUG_PRINT(extra)
|
||||
|
||||
# define TPM_DEBUG_TRACE() TPM_DEBUG_PRINT(__func__)
|
||||
|
||||
#else
|
||||
|
||||
# define TPM_DEBUG_TRACEX(s)
|
||||
# define TPM_DEBUG_TRACE()
|
||||
|
||||
#endif // ENABLE_TPM_DEBUG_TRACE && ENABLE_TPM_DEBUG_PRINT
|
||||
|
||||
// Low Level Crypto Debugging
|
||||
#if ENABLE_TPM_DEBUG_PRINT && ENABLE_CRYPTO_DEBUG
|
||||
|
||||
// these functions are not declared here, but expect to be declared where these macros are consumed.
|
||||
# define TPM_DEBUG_PRINT_BIGNUM(name, value) _bnDebug_printBigNum(name, value);
|
||||
# define TPM_DEBUG_PRINT_BIGNUM_FULL(name, value) \
|
||||
_bnDebug_printBigNumFull(name, value);
|
||||
# define TPM_DEBUG_PRINT_BIGPOINT(name, value) _bnDebug_printBigPoint(name, value);
|
||||
# define TPM_DEBUG_PRINT_TPMS_ECC_POINT(name, value) \
|
||||
_bnDebug_printTPMS_ECC_POINT(name, value);
|
||||
# define TPM_DEBUG_PRINT_TPM2B(name, value, reverse) \
|
||||
_bnDebug_printTpm2B(name, value, reverse);
|
||||
|
||||
//#error SHOULD BE OFF
|
||||
|
||||
#else
|
||||
|
||||
# define TPM_DEBUG_PRINT_BIGNUM(name, value)
|
||||
# define TPM_DEBUG_PRINT_BIGNUM_FULL(name, value)
|
||||
# define TPM_DEBUG_PRINT_BIGPOINT(name, value)
|
||||
# define TPM_DEBUG_PRINT_TPMS_ECC_POINT(name, value)
|
||||
# define TPM_DEBUG_PRINT_TPM2B(name, value, reverse)
|
||||
|
||||
#endif
|
||||
|
||||
#endif //_TPM_DEBUG_H_
|
||||
@ -1,62 +1,4 @@
|
||||
/********************************************************************************/
|
||||
/* */
|
||||
/* */
|
||||
/* 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, 2023 */
|
||||
/* */
|
||||
/********************************************************************************/
|
||||
// SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
#include "TpmBuildSwitches.h"
|
||||
#include "TpmProfile.h"
|
||||
@ -67,3 +9,4 @@
|
||||
#include "MinMax.h"
|
||||
#include "tpm_radix.h"
|
||||
#include "TpmTypes.h"
|
||||
#include "tpm_debug.h"
|
||||
|
||||
@ -398,6 +398,18 @@ LIB_EXPORT int _plat__GetTpmFirmwareSecret(
|
||||
// return the TPM Type returned by TPM_PT_VENDOR_TPM_TYPE
|
||||
LIB_EXPORT uint32_t _plat__GetTpmType(void); // libtpms changed
|
||||
|
||||
#if ENABLE_TPM_DEBUG_PRINT
|
||||
|
||||
LIB_EXPORT void _plat_debug_print(const char* str);
|
||||
LIB_EXPORT void _plat_debug_print_buffer(const void* buf, const size_t size);
|
||||
LIB_EXPORT void _plat_debug_print_int32(const char* name, uint32_t value);
|
||||
LIB_EXPORT void _plat_debug_print_int64(const char* name, uint64_t value);
|
||||
LIB_EXPORT void _plat_debug_printf(const char* fmt, ...);
|
||||
LIB_EXPORT size_t _plat_debug_snprintf(
|
||||
char* buf, size_t bufSize, const char* fmt, ...);
|
||||
|
||||
#endif // ENABLE_TPM_DEBUG_PRINT
|
||||
|
||||
// platform PCR initialization functions
|
||||
#include "platform_pcr_fp.h"
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user