mirror of
https://github.com/stefanberger/libtpms
synced 2026-08-12 02:31:12 +00:00
Sync: Use clang-format 19.1.4 to reformat sources
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
This commit is contained in:
parent
02dad542a9
commit
d8b0639716
@ -1,63 +1,4 @@
|
||||
/********************************************************************************/
|
||||
/* */
|
||||
/* Authenticated Countdown Timer */
|
||||
/* Written by Ken Goldman */
|
||||
/* IBM Thomas J. Watson Research Center */
|
||||
/* $Id$ */
|
||||
/* */
|
||||
/* Licenses and Notices */
|
||||
/* */
|
||||
/* 1. Copyright Licenses: */
|
||||
/* */
|
||||
/* - Trusted Computing Group (TCG) grants to the user of the source code in */
|
||||
/* this specification (the "Source Code") a worldwide, irrevocable, */
|
||||
/* nonexclusive, royalty free, copyright license to reproduce, create */
|
||||
/* derivative works, distribute, display and perform the Source Code and */
|
||||
/* derivative works thereof, and to grant others the rights granted herein. */
|
||||
/* */
|
||||
/* - The TCG grants to the user of the other parts of the specification */
|
||||
/* (other than the Source Code) the rights to reproduce, distribute, */
|
||||
/* display, and perform the specification solely for the purpose of */
|
||||
/* developing products based on such documents. */
|
||||
/* */
|
||||
/* 2. Source Code Distribution Conditions: */
|
||||
/* */
|
||||
/* - Redistributions of Source Code must retain the above copyright licenses, */
|
||||
/* this list of conditions and the following disclaimers. */
|
||||
/* */
|
||||
/* - Redistributions in binary form must reproduce the above copyright */
|
||||
/* licenses, this list of conditions and the following disclaimers in the */
|
||||
/* documentation and/or other materials provided with the distribution. */
|
||||
/* */
|
||||
/* 3. Disclaimers: */
|
||||
/* */
|
||||
/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */
|
||||
/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */
|
||||
/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */
|
||||
/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */
|
||||
/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */
|
||||
/* information on specification licensing rights available through TCG */
|
||||
/* membership agreements. */
|
||||
/* */
|
||||
/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */
|
||||
/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */
|
||||
/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */
|
||||
/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */
|
||||
/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */
|
||||
/* */
|
||||
/* - Without limitation, TCG and its members and licensors disclaim all */
|
||||
/* liability, including liability for infringement of any proprietary */
|
||||
/* rights, relating to use of information in this specification and to the */
|
||||
/* implementation of this specification, and TCG disclaims all liability for */
|
||||
/* cost of procurement of substitute goods or services, lost profits, loss */
|
||||
/* of use, loss of data or any incidental, consequential, direct, indirect, */
|
||||
/* or special damages, whether under contract, tort, warranty or otherwise, */
|
||||
/* arising in any way out of use or reliance upon this specification or any */
|
||||
/* information herein. */
|
||||
/* */
|
||||
/* (c) Copyright IBM Corp. and others, 2019 */
|
||||
/* */
|
||||
/********************************************************************************/
|
||||
// SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
#ifndef _ACT_H_
|
||||
#define _ACT_H_
|
||||
@ -236,23 +177,23 @@
|
||||
# define TPM_RH_ACT_F (TPM_RH_ACT_0 + 0xF)
|
||||
#endif
|
||||
|
||||
#define FOR_EACH_ACT(op) \
|
||||
IF_ACT_0_IMPLEMENTED(op) \
|
||||
IF_ACT_1_IMPLEMENTED(op) \
|
||||
IF_ACT_2_IMPLEMENTED(op) \
|
||||
IF_ACT_3_IMPLEMENTED(op) \
|
||||
IF_ACT_4_IMPLEMENTED(op) \
|
||||
IF_ACT_5_IMPLEMENTED(op) \
|
||||
IF_ACT_6_IMPLEMENTED(op) \
|
||||
IF_ACT_7_IMPLEMENTED(op) \
|
||||
IF_ACT_8_IMPLEMENTED(op) \
|
||||
IF_ACT_9_IMPLEMENTED(op) \
|
||||
IF_ACT_A_IMPLEMENTED(op) \
|
||||
IF_ACT_B_IMPLEMENTED(op) \
|
||||
IF_ACT_C_IMPLEMENTED(op) \
|
||||
IF_ACT_D_IMPLEMENTED(op) \
|
||||
IF_ACT_E_IMPLEMENTED(op) \
|
||||
IF_ACT_F_IMPLEMENTED(op)
|
||||
#define FOR_EACH_ACT(op) \
|
||||
IF_ACT_0_IMPLEMENTED(op) \
|
||||
IF_ACT_1_IMPLEMENTED(op) \
|
||||
IF_ACT_2_IMPLEMENTED(op) \
|
||||
IF_ACT_3_IMPLEMENTED(op) \
|
||||
IF_ACT_4_IMPLEMENTED(op) \
|
||||
IF_ACT_5_IMPLEMENTED(op) \
|
||||
IF_ACT_6_IMPLEMENTED(op) \
|
||||
IF_ACT_7_IMPLEMENTED(op) \
|
||||
IF_ACT_8_IMPLEMENTED(op) \
|
||||
IF_ACT_9_IMPLEMENTED(op) \
|
||||
IF_ACT_A_IMPLEMENTED(op) \
|
||||
IF_ACT_B_IMPLEMENTED(op) \
|
||||
IF_ACT_C_IMPLEMENTED(op) \
|
||||
IF_ACT_D_IMPLEMENTED(op) \
|
||||
IF_ACT_E_IMPLEMENTED(op) \
|
||||
IF_ACT_F_IMPLEMENTED(op)
|
||||
|
||||
// This is the mask for ACT that are implemented
|
||||
//#define ACT_MASK(N) | (1 << 0x##N)
|
||||
|
||||
@ -1,62 +1,4 @@
|
||||
/********************************************************************************/
|
||||
/* */
|
||||
/* conversion functions that will convert TPM2B to/from internal format */
|
||||
/* 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
|
||||
|
||||
//** Introduction
|
||||
// This file contains the basic conversion functions that will convert TPM2B
|
||||
@ -99,9 +41,9 @@ LIB_EXPORT bigNum BnFromBytes(bigNum bn, const BYTE* bytes, NUMBYTES nBytes)
|
||||
pTo = (BYTE*)bn->d;
|
||||
for(; nBytes != 0; nBytes--)
|
||||
*pTo++ = *pFrom--;
|
||||
// For a little-endian machine, the conversion is a straight byte
|
||||
// reversal. For a big-endian machine, we have to put the words in
|
||||
// big-endian byte order
|
||||
// For a little-endian machine, the conversion is a straight byte
|
||||
// reversal. For a big-endian machine, we have to put the words in
|
||||
// big-endian byte order
|
||||
#if BIG_ENDIAN_TPM
|
||||
{
|
||||
crypt_word_t t;
|
||||
|
||||
@ -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
|
||||
|
||||
/*(Auto-generated)
|
||||
* Created by TpmStructures; Version 4.4 Mar 26, 2019
|
||||
@ -94,12 +36,12 @@
|
||||
# define TO_ECC_640(a, b, c, d, e, f, g, h, i, j) j, i, h, g, f, e, d, c, b, a
|
||||
|
||||
# define BN_MIN_ALLOC(bytes) \
|
||||
(BYTES_TO_CRYPT_WORDS(bytes) == 0) ? 1 : BYTES_TO_CRYPT_WORDS(bytes)
|
||||
# define ECC_CONST(NAME, bytes, initializer) \
|
||||
const struct \
|
||||
{ \
|
||||
crypt_uword_t allocate, size, d[BN_MIN_ALLOC(bytes)]; \
|
||||
} NAME = {BN_MIN_ALLOC(bytes), BYTES_TO_CRYPT_WORDS(bytes), {initializer}}
|
||||
(BYTES_TO_CRYPT_WORDS(bytes) == 0) ? 1 : BYTES_TO_CRYPT_WORDS(bytes)
|
||||
# define ECC_CONST(NAME, bytes, initializer) \
|
||||
const struct \
|
||||
{ \
|
||||
crypt_uword_t allocate, size, d[BN_MIN_ALLOC(bytes)]; \
|
||||
} NAME = {BN_MIN_ALLOC(bytes), BYTES_TO_CRYPT_WORDS(bytes), {initializer}}
|
||||
|
||||
// This file contains the raw data for ECC curve constants. The data is wrapped
|
||||
// in macros so this file can be included in other files that format the data in
|
||||
|
||||
@ -1,63 +1,4 @@
|
||||
/********************************************************************************/
|
||||
/* */
|
||||
/* Debug Helper */
|
||||
/* Written by Ken Goldman */
|
||||
/* IBM Thomas J. Watson Research Center */
|
||||
/* $Id: DebugHelpers.c 1658 2021-01-22 23:14:01Z kgoldman $ */
|
||||
/* */
|
||||
/* Licenses and Notices */
|
||||
/* */
|
||||
/* 1. Copyright Licenses: */
|
||||
/* */
|
||||
/* - Trusted Computing Group (TCG) grants to the user of the source code in */
|
||||
/* this specification (the "Source Code") a worldwide, irrevocable, */
|
||||
/* nonexclusive, royalty free, copyright license to reproduce, create */
|
||||
/* derivative works, distribute, display and perform the Source Code and */
|
||||
/* derivative works thereof, and to grant others the rights granted herein. */
|
||||
/* */
|
||||
/* - The TCG grants to the user of the other parts of the specification */
|
||||
/* (other than the Source Code) the rights to reproduce, distribute, */
|
||||
/* display, and perform the specification solely for the purpose of */
|
||||
/* developing products based on such documents. */
|
||||
/* */
|
||||
/* 2. Source Code Distribution Conditions: */
|
||||
/* */
|
||||
/* - Redistributions of Source Code must retain the above copyright licenses, */
|
||||
/* this list of conditions and the following disclaimers. */
|
||||
/* */
|
||||
/* - Redistributions in binary form must reproduce the above copyright */
|
||||
/* licenses, this list of conditions and the following disclaimers in the */
|
||||
/* documentation and/or other materials provided with the distribution. */
|
||||
/* */
|
||||
/* 3. Disclaimers: */
|
||||
/* */
|
||||
/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */
|
||||
/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */
|
||||
/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */
|
||||
/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */
|
||||
/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */
|
||||
/* information on specification licensing rights available through TCG */
|
||||
/* membership agreements. */
|
||||
/* */
|
||||
/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */
|
||||
/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */
|
||||
/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */
|
||||
/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */
|
||||
/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */
|
||||
/* */
|
||||
/* - Without limitation, TCG and its members and licensors disclaim all */
|
||||
/* liability, including liability for infringement of any proprietary */
|
||||
/* rights, relating to use of information in this specification and to the */
|
||||
/* implementation of this specification, and TCG disclaims all liability for */
|
||||
/* cost of procurement of substitute goods or services, lost profits, loss */
|
||||
/* of use, loss of data or any incidental, consequential, direct, indirect, */
|
||||
/* or special damages, whether under contract, tort, warranty or otherwise, */
|
||||
/* arising in any way out of use or reliance upon this specification or any */
|
||||
/* information herein. */
|
||||
/* */
|
||||
/* (c) Copyright IBM Corp. and others, 2019 - 2021 */
|
||||
/* */
|
||||
/********************************************************************************/
|
||||
// SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
//** Description
|
||||
//
|
||||
@ -79,7 +20,7 @@ const char* debugFileName = "DebugFile.txt";
|
||||
// This exists to allow use of the 'safe' version of fopen() with a MS runtime.
|
||||
static FILE* fileOpen(const char* fn, const char* mode)
|
||||
{
|
||||
FILE* f;
|
||||
FILE* f;
|
||||
# if defined _MSC_VER
|
||||
if(fopen_s(&f, fn, mode) != 0)
|
||||
f = NULL;
|
||||
@ -102,7 +43,7 @@ int DebugFileInit(void)
|
||||
//
|
||||
// Get current date and time.
|
||||
# if defined _MSC_VER
|
||||
char timeString[100];
|
||||
char timeString[100];
|
||||
ctime_s(timeString, (size_t)sizeof(timeString), &t);
|
||||
# else
|
||||
char* timeString;
|
||||
|
||||
@ -263,7 +263,7 @@
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#if(defined EMPTY_ASSERT) && (EMPTY_ASSERT != NO)
|
||||
#if (defined EMPTY_ASSERT) && (EMPTY_ASSERT != NO)
|
||||
# define pAssert(a) ((void)0)
|
||||
#else
|
||||
# define pAssert(a) \
|
||||
@ -349,7 +349,7 @@
|
||||
#include "MinMax.h"
|
||||
|
||||
#ifndef IsOdd
|
||||
# define IsOdd(a) (((a)&1) != 0)
|
||||
# define IsOdd(a) (((a) & 1) != 0)
|
||||
#endif
|
||||
|
||||
#ifndef BITS_TO_BYTES
|
||||
|
||||
@ -43,7 +43,7 @@ void HierarchyPreInstall_Init(void)
|
||||
gp.EPSeed.t.size = sizeof(gp.EPSeed.t.buffer);
|
||||
gp.SPSeed.t.size = sizeof(gp.SPSeed.t.buffer);
|
||||
gp.PPSeed.t.size = sizeof(gp.PPSeed.t.buffer);
|
||||
#if(defined USE_PLATFORM_EPS) && (USE_PLATFORM_EPS != NO)
|
||||
#if (defined USE_PLATFORM_EPS) && (USE_PLATFORM_EPS != NO)
|
||||
_plat__GetEPS(gp.EPSeed.t.size, gp.EPSeed.t.buffer);
|
||||
#else
|
||||
CryptRandomGenerate(gp.EPSeed.t.size, gp.EPSeed.t.buffer);
|
||||
|
||||
@ -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 the declaration and initialization macros for
|
||||
@ -87,58 +29,58 @@ typedef CRYPT_CURVE_BUF(curvebuft, MAX_ECC_KEY_BITS) Crypt_EccCurve;
|
||||
|
||||
// produces bare typedef ci_<typename>_t
|
||||
#define CRYPT_INT_TYPE(typename, bits) \
|
||||
typedef CRYPT_INT_BUF(ci_##typename##_buf_t, bits) ci_##typename##_t
|
||||
typedef CRYPT_INT_BUF(ci_##typename##_buf_t, bits) ci_##typename##_t
|
||||
|
||||
// produces allocated `Crypt_Int* varname` backed by a
|
||||
// stack buffer named `<varname>_buf`. Initialization at the discretion of the
|
||||
// ExtMath library.
|
||||
#define CRYPT_INT_VAR(varname, bits) \
|
||||
CRYPT_INT_BUF(ci_##varname##_buf_t, bits) varname##_buf; \
|
||||
Crypt_Int* varname = ExtMath_Initialize_Int((Crypt_Int*)&(varname##_buf), bits);
|
||||
#define CRYPT_INT_VAR(varname, bits) \
|
||||
CRYPT_INT_BUF(ci_##varname##_buf_t, bits) varname##_buf; \
|
||||
Crypt_Int* varname = ExtMath_Initialize_Int((Crypt_Int*)&(varname##_buf), bits);
|
||||
|
||||
// produces initialized `Crypt_Int* varname = (TPM2B) initializer` backed by a
|
||||
// stack buffer named `<varname>_buf`
|
||||
#define CRYPT_INT_INITIALIZED(varname, bits, initializer) \
|
||||
CRYPT_INT_BUF(cibuf##varname, bits) varname##_buf; \
|
||||
Crypt_Int* varname = \
|
||||
TpmMath_IntFrom2B(ExtMath_Initialize_Int((Crypt_Int*)&(varname##_buf), bits), \
|
||||
(TPM2B*)initializer);
|
||||
#define CRYPT_INT_INITIALIZED(varname, bits, initializer) \
|
||||
CRYPT_INT_BUF(cibuf##varname, bits) varname##_buf; \
|
||||
Crypt_Int* varname = TpmMath_IntFrom2B( \
|
||||
ExtMath_Initialize_Int((Crypt_Int*)&(varname##_buf), bits), \
|
||||
(TPM2B*)initializer);
|
||||
|
||||
// convenience variants of above:
|
||||
// largest supported integer
|
||||
#define CRYPT_INT_MAX(varname) CRYPT_INT_VAR(varname, LARGEST_NUMBER_BITS)
|
||||
|
||||
#define CRYPT_INT_MAX_INITIALIZED(name, initializer) \
|
||||
CRYPT_INT_INITIALIZED(name, LARGEST_NUMBER_BITS, initializer)
|
||||
CRYPT_INT_INITIALIZED(name, LARGEST_NUMBER_BITS, initializer)
|
||||
|
||||
// A single RADIX_BITS value.
|
||||
#define CRYPT_INT_WORD(name) CRYPT_INT_VAR(name, RADIX_BITS)
|
||||
|
||||
#define CRYPT_INT_WORD_INITIALIZED(varname, initializer) \
|
||||
CRYPT_INT_BUF(cibuf##varname, RADIX_BITS) varname##_buf; \
|
||||
Crypt_Int* varname = ExtMath_SetWord( \
|
||||
ExtMath_Initialize_Int((Crypt_Int*)&(varname##_buf), RADIX_BITS), \
|
||||
initializer);
|
||||
#define CRYPT_INT_WORD_INITIALIZED(varname, initializer) \
|
||||
CRYPT_INT_BUF(cibuf##varname, RADIX_BITS) varname##_buf; \
|
||||
Crypt_Int* varname = ExtMath_SetWord( \
|
||||
ExtMath_Initialize_Int((Crypt_Int*)&(varname##_buf), RADIX_BITS), \
|
||||
initializer);
|
||||
|
||||
// Crypt_EccCurve underlying types
|
||||
#define CRYPT_CURVE_INITIALIZED(varname, initializer) \
|
||||
CRYPT_CURVE_BUF(cv##varname, MAX_ECC_KEY_BITS) varname##_buf; \
|
||||
const Crypt_EccCurve* varname = \
|
||||
ExtEcc_CurveInitialize(&(varname##_buf), initializer)
|
||||
#define CRYPT_CURVE_INITIALIZED(varname, initializer) \
|
||||
CRYPT_CURVE_BUF(cv##varname, MAX_ECC_KEY_BITS) varname##_buf; \
|
||||
const Crypt_EccCurve* varname = \
|
||||
ExtEcc_CurveInitialize(&(varname##_buf), initializer)
|
||||
|
||||
/* no guarantee free will be called in the presence of longjmp */
|
||||
#define CRYPT_CURVE_FREE(varname) ExtEcc_CurveFree(varname)
|
||||
|
||||
// Crypt_Point underlying types
|
||||
#define CRYPT_POINT_VAR(varname) \
|
||||
CRYPT_POINT_BUF(cp_##varname##_buf_t, MAX_ECC_KEY_BITS) varname##_buf; \
|
||||
Crypt_Point* varname = \
|
||||
ExtEcc_Initialize_Point((Crypt_Point*)&(varname##_buf), MAX_ECC_KEY_BITS);
|
||||
#define CRYPT_POINT_VAR(varname) \
|
||||
CRYPT_POINT_BUF(cp_##varname##_buf_t, MAX_ECC_KEY_BITS) varname##_buf; \
|
||||
Crypt_Point* varname = \
|
||||
ExtEcc_Initialize_Point((Crypt_Point*)&(varname##_buf), MAX_ECC_KEY_BITS);
|
||||
|
||||
#define CRYPT_POINT_INITIALIZED(varname, initValue) \
|
||||
CRYPT_POINT_BUF(cp_##varname##_buf_t, MAX_ECC_KEY_BITS) varname##_buf; \
|
||||
Crypt_Point* varname = TpmEcc_PointFrom2B( \
|
||||
ExtEcc_Initialize_Point((Crypt_Point*)&(varname##_buf), MAX_ECC_KEY_BITS), \
|
||||
initValue);
|
||||
#define CRYPT_POINT_INITIALIZED(varname, initValue) \
|
||||
CRYPT_POINT_BUF(cp_##varname##_buf_t, MAX_ECC_KEY_BITS) varname##_buf; \
|
||||
Crypt_Point* varname = TpmEcc_PointFrom2B( \
|
||||
ExtEcc_Initialize_Point((Crypt_Point*)&(varname##_buf), MAX_ECC_KEY_BITS), \
|
||||
initValue);
|
||||
|
||||
#endif //MATH_LIBRARY_INTERFACE_TYPES_H
|
||||
|
||||
@ -107,19 +107,18 @@ NvWriteAccessChecks(
|
||||
// not allowed
|
||||
//
|
||||
TPM_RC
|
||||
NvReadOnlyModeChecks(
|
||||
TPMA_NV attributes // IN: the attributes of the index to check
|
||||
NvReadOnlyModeChecks(TPMA_NV attributes // IN: the attributes of the index to check
|
||||
)
|
||||
{
|
||||
|
||||
# if CC_ReadOnlyControl
|
||||
#if CC_ReadOnlyControl
|
||||
// When in Read-Only mode only allow the commands listed above on an
|
||||
// index with the ORDERLY and CLEAR_STCLEAR attributes set
|
||||
if(gc.readOnly &&
|
||||
!(IS_ATTRIBUTE(attributes, TPMA_NV, ORDERLY) &&
|
||||
IS_ATTRIBUTE(attributes, TPMA_NV, CLEAR_STCLEAR)))
|
||||
if(gc.readOnly
|
||||
&& !(IS_ATTRIBUTE(attributes, TPMA_NV, ORDERLY)
|
||||
&& IS_ATTRIBUTE(attributes, TPMA_NV, CLEAR_STCLEAR)))
|
||||
return TPM_RC_READ_ONLY;
|
||||
# endif // CC_ReadOnlyControl
|
||||
#endif // CC_ReadOnlyControl
|
||||
|
||||
return TPM_RC_SUCCESS;
|
||||
}
|
||||
@ -142,9 +141,8 @@ NvClearOrderly(void)
|
||||
// Return Type: BOOL
|
||||
// TRUE(1) 'index' is found
|
||||
// FALSE(0) 'index' is not found or not an NV index handle
|
||||
static BOOL GetIndexAttributesByHandle(
|
||||
TPM_HANDLE index, // IN: index handle
|
||||
TPMA_NV* attributes // OUT: index attributes
|
||||
static BOOL GetIndexAttributesByHandle(TPM_HANDLE index, // IN: index handle
|
||||
TPMA_NV* attributes // OUT: index attributes
|
||||
)
|
||||
{
|
||||
if(HandleGetType(index) == TPM_HT_NV_INDEX)
|
||||
@ -168,8 +166,8 @@ BOOL NvIsPinPassIndex(TPM_HANDLE index // IN: Handle to check
|
||||
)
|
||||
{
|
||||
TPMA_NV attributes;
|
||||
return GetIndexAttributesByHandle(index, &attributes) &&
|
||||
IsNvPinPassIndex(attributes);
|
||||
return GetIndexAttributesByHandle(index, &attributes)
|
||||
&& IsNvPinPassIndex(attributes);
|
||||
}
|
||||
|
||||
//*** NvIsPinCountedIndex()
|
||||
@ -182,8 +180,8 @@ BOOL NvIsPinCountedIndex(TPM_HANDLE index // IN: Handle to check
|
||||
)
|
||||
{
|
||||
TPMA_NV attributes;
|
||||
return GetIndexAttributesByHandle(index, &attributes) &&
|
||||
(IsNvPinPassIndex(attributes) || IsNvPinFailIndex(attributes));
|
||||
return GetIndexAttributesByHandle(index, &attributes)
|
||||
&& (IsNvPinPassIndex(attributes) || IsNvPinFailIndex(attributes));
|
||||
}
|
||||
|
||||
//*** NvGetIndexName()
|
||||
|
||||
@ -1,62 +1,4 @@
|
||||
/********************************************************************************/
|
||||
/* */
|
||||
/* PCR access and manipulation */
|
||||
/* 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
|
||||
|
||||
//** Introduction
|
||||
//
|
||||
@ -993,7 +935,7 @@ PCRAllocate(TPML_PCR_SELECTION* allocate, // IN: required allocation
|
||||
newAllocate.pcrSelections[i].sizeofSelect);
|
||||
|
||||
#else // if DRTM PCR is not required, indicate that the allocation is OK
|
||||
pcrDrtm = TRUE;
|
||||
pcrDrtm = TRUE;
|
||||
#endif
|
||||
|
||||
#if defined(HCRTM_PCR)
|
||||
|
||||
@ -1,63 +1,4 @@
|
||||
/********************************************************************************/
|
||||
/* */
|
||||
/* Platform Authenticated Countdown Timer */
|
||||
/* Written by Ken Goldman */
|
||||
/* IBM Thomas J. Watson Research Center */
|
||||
/* $Id: PlatformACT.h 1531 2019-11-21 23:54:38Z kgoldman $ */
|
||||
/* */
|
||||
/* Licenses and Notices */
|
||||
/* */
|
||||
/* 1. Copyright Licenses: */
|
||||
/* */
|
||||
/* - Trusted Computing Group (TCG) grants to the user of the source code in */
|
||||
/* this specification (the "Source Code") a worldwide, irrevocable, */
|
||||
/* nonexclusive, royalty free, copyright license to reproduce, create */
|
||||
/* derivative works, distribute, display and perform the Source Code and */
|
||||
/* derivative works thereof, and to grant others the rights granted herein. */
|
||||
/* */
|
||||
/* - The TCG grants to the user of the other parts of the specification */
|
||||
/* (other than the Source Code) the rights to reproduce, distribute, */
|
||||
/* display, and perform the specification solely for the purpose of */
|
||||
/* developing products based on such documents. */
|
||||
/* */
|
||||
/* 2. Source Code Distribution Conditions: */
|
||||
/* */
|
||||
/* - Redistributions of Source Code must retain the above copyright licenses, */
|
||||
/* this list of conditions and the following disclaimers. */
|
||||
/* */
|
||||
/* - Redistributions in binary form must reproduce the above copyright */
|
||||
/* licenses, this list of conditions and the following disclaimers in the */
|
||||
/* documentation and/or other materials provided with the distribution. */
|
||||
/* */
|
||||
/* 3. Disclaimers: */
|
||||
/* */
|
||||
/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */
|
||||
/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */
|
||||
/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */
|
||||
/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */
|
||||
/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */
|
||||
/* information on specification licensing rights available through TCG */
|
||||
/* membership agreements. */
|
||||
/* */
|
||||
/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */
|
||||
/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */
|
||||
/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */
|
||||
/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */
|
||||
/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */
|
||||
/* */
|
||||
/* - Without limitation, TCG and its members and licensors disclaim all */
|
||||
/* liability, including liability for infringement of any proprietary */
|
||||
/* rights, relating to use of information in this specification and to the */
|
||||
/* implementation of this specification, and TCG disclaims all liability for */
|
||||
/* cost of procurement of substitute goods or services, lost profits, loss */
|
||||
/* of use, loss of data or any incidental, consequential, direct, indirect, */
|
||||
/* or special damages, whether under contract, tort, warranty or otherwise, */
|
||||
/* arising in any way out of use or reliance upon this specification or any */
|
||||
/* information herein. */
|
||||
/* */
|
||||
/* (c) Copyright IBM Corp. and others, 2019. */
|
||||
/* */
|
||||
/********************************************************************************/
|
||||
// SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
// This file contains the definitions for the ACT macros and data types used in the
|
||||
// ACT implementation.
|
||||
@ -187,22 +128,22 @@ typedef struct ACT_DATA
|
||||
# define IF_ACT_F_IMPLEMENTED(op) op(F)
|
||||
#endif
|
||||
|
||||
#define FOR_EACH_ACT(op) \
|
||||
IF_ACT_0_IMPLEMENTED(op) \
|
||||
IF_ACT_1_IMPLEMENTED(op) \
|
||||
IF_ACT_2_IMPLEMENTED(op) \
|
||||
IF_ACT_3_IMPLEMENTED(op) \
|
||||
IF_ACT_4_IMPLEMENTED(op) \
|
||||
IF_ACT_5_IMPLEMENTED(op) \
|
||||
IF_ACT_6_IMPLEMENTED(op) \
|
||||
IF_ACT_7_IMPLEMENTED(op) \
|
||||
IF_ACT_8_IMPLEMENTED(op) \
|
||||
IF_ACT_9_IMPLEMENTED(op) \
|
||||
IF_ACT_A_IMPLEMENTED(op) \
|
||||
IF_ACT_B_IMPLEMENTED(op) \
|
||||
IF_ACT_C_IMPLEMENTED(op) \
|
||||
IF_ACT_D_IMPLEMENTED(op) \
|
||||
IF_ACT_E_IMPLEMENTED(op) \
|
||||
IF_ACT_F_IMPLEMENTED(op)
|
||||
#define FOR_EACH_ACT(op) \
|
||||
IF_ACT_0_IMPLEMENTED(op) \
|
||||
IF_ACT_1_IMPLEMENTED(op) \
|
||||
IF_ACT_2_IMPLEMENTED(op) \
|
||||
IF_ACT_3_IMPLEMENTED(op) \
|
||||
IF_ACT_4_IMPLEMENTED(op) \
|
||||
IF_ACT_5_IMPLEMENTED(op) \
|
||||
IF_ACT_6_IMPLEMENTED(op) \
|
||||
IF_ACT_7_IMPLEMENTED(op) \
|
||||
IF_ACT_8_IMPLEMENTED(op) \
|
||||
IF_ACT_9_IMPLEMENTED(op) \
|
||||
IF_ACT_A_IMPLEMENTED(op) \
|
||||
IF_ACT_B_IMPLEMENTED(op) \
|
||||
IF_ACT_C_IMPLEMENTED(op) \
|
||||
IF_ACT_D_IMPLEMENTED(op) \
|
||||
IF_ACT_E_IMPLEMENTED(op) \
|
||||
IF_ACT_F_IMPLEMENTED(op)
|
||||
|
||||
#endif // _PLATFORM_ACT_H_
|
||||
|
||||
@ -1,63 +1,4 @@
|
||||
/********************************************************************************/
|
||||
/* */
|
||||
/* Instance data for the Platform module. */
|
||||
/* Written by Ken Goldman */
|
||||
/* IBM Thomas J. Watson Research Center */
|
||||
/* $Id: PlatformData.h 1529 2019-11-21 23:29:01Z 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 - 2019. */
|
||||
/* */
|
||||
/********************************************************************************/
|
||||
// SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
// This file contains the instance data for the Platform module. It is collected
|
||||
// in this file so that the state of the module is easier to manage.
|
||||
@ -119,16 +60,17 @@ EXTERN unsigned char s_locality;
|
||||
// If this macro is defined, then a file is used as NV. If it is not defined,
|
||||
// then RAM is used to back NV memory. Comment out to use RAM.
|
||||
|
||||
#if(!defined VTPM) || ((VTPM != NO) && (VTPM != YES))
|
||||
#if (!defined VTPM) || ((VTPM != NO) && (VTPM != YES))
|
||||
# undef VTPM
|
||||
# define VTPM NO // Default: Either YES or NO libtpms: NO
|
||||
#endif
|
||||
|
||||
// For a simulation, use a file to back up the NV
|
||||
#if(!defined FILE_BACKED_NV) || ((FILE_BACKED_NV != NO) && (FILE_BACKED_NV != YES))
|
||||
#if (!defined FILE_BACKED_NV) || ((FILE_BACKED_NV != NO) && (FILE_BACKED_NV != YES))
|
||||
# undef FILE_BACKED_NV
|
||||
# define FILE_BACKED_NV (VTPM && YES) // Default: Either YES or NO
|
||||
#endif
|
||||
|
||||
#if !SIMULATION
|
||||
# undef FILE_BACKED_NV
|
||||
# define FILE_BACKED_NV YES // libtpms: write NvChip file if no callbacks are set
|
||||
|
||||
@ -123,7 +123,7 @@ TPM2_PolicyTransportSPDM(PolicyTransportSPDM_In* in // IN: input parameter list
|
||||
CryptHashEnd2B(&hashState, &session->u2.policyDigest.b);
|
||||
|
||||
// Update session context
|
||||
session->attributes.checkSecureChannel = SET;
|
||||
session->attributes.checkSecureChannel = SET;
|
||||
if(in->reqKeyName.t.size != 0)
|
||||
{
|
||||
session->attributes.checkReqKey = SET;
|
||||
|
||||
@ -20,7 +20,7 @@ TPM2_ReadOnlyControl(ReadOnlyControl_In* in // IN: input parameter list
|
||||
|
||||
// modify the read-only state
|
||||
gc.readOnly = in->state;
|
||||
|
||||
|
||||
// orderly state should be cleared because of the update to state clear data
|
||||
// This gets processed in ExecuteCommand() on the way out.
|
||||
g_clearOrderly = TRUE;
|
||||
|
||||
@ -2,9 +2,13 @@
|
||||
|
||||
#include "Tpm.h"
|
||||
|
||||
# if SEC_CHANNEL_SUPPORT
|
||||
// Dummy requester key name
|
||||
const TPM2B_NAME dummy_reqKeyName =
|
||||
#if SEC_CHANNEL_SUPPORT
|
||||
|
||||
// clang format turns this into one byte per line?! don't format this array.
|
||||
// clang-format off
|
||||
|
||||
// Dummy requester key name
|
||||
const TPM2B_NAME dummy_reqKeyName =
|
||||
{{
|
||||
0x0032, // size
|
||||
// name
|
||||
@ -13,28 +17,31 @@ const TPM2B_NAME dummy_reqKeyName =
|
||||
// digest
|
||||
0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11,
|
||||
0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11,
|
||||
0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11
|
||||
0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11
|
||||
}
|
||||
}};
|
||||
|
||||
// clang-format on
|
||||
|
||||
//*** GetTpmSpdmPubKey()
|
||||
// This function is used to get the dummy TPM SPDM public key
|
||||
void GetTpmSpdmPubKey(TPMT_PUBLIC* tpmPubKey)
|
||||
{
|
||||
tpmPubKey->type = TPM_ALG_ECC;
|
||||
tpmPubKey->type = TPM_ALG_ECC;
|
||||
tpmPubKey->nameAlg = TPM_ALG_SHA384;
|
||||
tpmPubKey->objectAttributes = 0x00050032; // fixedTPM | fixedParent | sensitiveDataOrigin | restricted | sign;
|
||||
tpmPubKey->authPolicy.t.size = 0;
|
||||
tpmPubKey->parameters.eccDetail.symmetric.algorithm = TPM_ALG_NULL;
|
||||
tpmPubKey->parameters.eccDetail.scheme.scheme = TPM_ALG_ECDSA;
|
||||
tpmPubKey->parameters.eccDetail.scheme.details.ecdsa.hashAlg = TPM_ALG_SHA384;
|
||||
tpmPubKey->parameters.eccDetail.curveID = TPM_ECC_NIST_P384;
|
||||
tpmPubKey->parameters.eccDetail.kdf.scheme = TPM_ALG_NULL;
|
||||
tpmPubKey->unique.ecc.x.t.size = 0x0030;
|
||||
tpmPubKey->unique.ecc.y.t.size = 0x0030;
|
||||
tpmPubKey->objectAttributes =
|
||||
0x00050032; // fixedTPM | fixedParent | sensitiveDataOrigin | restricted | sign;
|
||||
tpmPubKey->authPolicy.t.size = 0;
|
||||
tpmPubKey->parameters.eccDetail.symmetric.algorithm = TPM_ALG_NULL;
|
||||
tpmPubKey->parameters.eccDetail.scheme.scheme = TPM_ALG_ECDSA;
|
||||
tpmPubKey->parameters.eccDetail.scheme.details.ecdsa.hashAlg = TPM_ALG_SHA384;
|
||||
tpmPubKey->parameters.eccDetail.curveID = TPM_ECC_NIST_P384;
|
||||
tpmPubKey->parameters.eccDetail.kdf.scheme = TPM_ALG_NULL;
|
||||
tpmPubKey->unique.ecc.x.t.size = 0x0030;
|
||||
tpmPubKey->unique.ecc.y.t.size = 0x0030;
|
||||
// For the dummy key, use x and y buffer all zeros
|
||||
memset(tpmPubKey->unique.ecc.x.t.buffer, 0, tpmPubKey->unique.ecc.x.t.size);
|
||||
memset(tpmPubKey->unique.ecc.y.t.buffer, 0, tpmPubKey->unique.ecc.y.t.size);
|
||||
memset(tpmPubKey->unique.ecc.y.t.buffer, 0, tpmPubKey->unique.ecc.y.t.size);
|
||||
}
|
||||
|
||||
//*** SpdmCapGetTpmPubKeys()
|
||||
@ -43,66 +50,69 @@ void GetTpmSpdmPubKey(TPMT_PUBLIC* tpmPubKey)
|
||||
// NO no more properties to be reported
|
||||
TPMI_YES_NO
|
||||
SpdmCapGetTpmPubKeys(TPM_PUB_KEY spdmPubKey, // IN: the starting TPM property
|
||||
UINT32 count, // IN: maximum number of returned properties
|
||||
TPML_PUB_KEY* pubKeyList // OUT: property list
|
||||
UINT32 count, // IN: maximum number of returned properties
|
||||
TPML_PUB_KEY* pubKeyList // OUT: property list
|
||||
)
|
||||
{
|
||||
TPMI_YES_NO more = NO;
|
||||
|
||||
// This reference implementation does not implement SPDM functionality and returns a single dummy TPM SPDM public key
|
||||
pubKeyList->count = 1;
|
||||
GetTpmSpdmPubKey(&pubKeyList->pubKeys[0].publicArea);
|
||||
GetTpmSpdmPubKey(&pubKeyList->pubKeys[0].publicArea);
|
||||
pubKeyList->pubKeys[0].size = sizeof(TPMT_PUBLIC);
|
||||
|
||||
return more;
|
||||
}
|
||||
|
||||
//*** SpdmCapGetSessionInfo()
|
||||
// This function is used to get the SPDM session information for GetCapability.
|
||||
// This function is used to get the SPDM session information for GetCapability.
|
||||
// This list has only one element.
|
||||
// Return Type: TPMI_YES_NO
|
||||
// NO no more properties to be reported
|
||||
TPMI_YES_NO
|
||||
SpdmCapGetSessionInfo(TPML_SPDM_SESSION_INFO* spdmSessionInfoList // OUT: property list
|
||||
SpdmCapGetSessionInfo(
|
||||
TPML_SPDM_SESSION_INFO* spdmSessionInfoList // OUT: property list
|
||||
)
|
||||
{
|
||||
TPMI_YES_NO more = NO;
|
||||
|
||||
// This reference implementation does not implement SPDM messages
|
||||
// This function returns dummy SPDM session info
|
||||
TPMS_SPDM_SESSION_INFO* spdmSessionInfo = &spdmSessionInfoList->spdmSessionInfo[0];
|
||||
|
||||
if(IsSpdmSessionActive(&spdmSessionInfo->reqKeyName, &spdmSessionInfo->tpmKeyName))
|
||||
TPMS_SPDM_SESSION_INFO* spdmSessionInfo =
|
||||
&spdmSessionInfoList->spdmSessionInfo[0];
|
||||
|
||||
if(IsSpdmSessionActive(&spdmSessionInfo->reqKeyName,
|
||||
&spdmSessionInfo->tpmKeyName))
|
||||
spdmSessionInfoList->count = 1;
|
||||
else
|
||||
// If GetCapability is not sent within an SPDM session, an Empty List is returned
|
||||
// If GetCapability is not sent within an SPDM session, an Empty List is returned
|
||||
spdmSessionInfoList->count = 0;
|
||||
|
||||
return more;
|
||||
}
|
||||
|
||||
//*** IsSpdmSessionActive()
|
||||
// This function indicates whether an SPDM session is active and if so,
|
||||
// returns the requester and TPM key names associated with the SPDM session.
|
||||
// This function indicates whether an SPDM session is active and if so,
|
||||
// returns the requester and TPM key names associated with the SPDM session.
|
||||
// Return Type: BOOL
|
||||
// TRUE(1) SPDM session is active (TPM command is protected by an SPDM session)
|
||||
BOOL
|
||||
IsSpdmSessionActive(TPM2B_NAME* reqKeyName, // OUT: the requester key's name associated with the SPDM session
|
||||
TPM2B_NAME* tpmKeyName // OUT: the TPM key's name associated with the SPDM session
|
||||
BOOL IsSpdmSessionActive(
|
||||
TPM2B_NAME*
|
||||
reqKeyName, // OUT: the requester key's name associated with the SPDM session
|
||||
TPM2B_NAME*
|
||||
tpmKeyName // OUT: the TPM key's name associated with the SPDM session
|
||||
)
|
||||
{
|
||||
TPMT_PUBLIC tpmPubKey;
|
||||
|
||||
// This reference implementation does not implement SPDM messages
|
||||
// This function returns always TRUE and returns dummy requester and TPM key names
|
||||
MemoryCopy2B(&reqKeyName->b,
|
||||
&dummy_reqKeyName.b,
|
||||
sizeof(dummy_reqKeyName));
|
||||
MemoryCopy2B(&reqKeyName->b, &dummy_reqKeyName.b, sizeof(dummy_reqKeyName));
|
||||
|
||||
// Get TPM SPDM pub key and compute its name
|
||||
GetTpmSpdmPubKey(&tpmPubKey);
|
||||
GetTpmSpdmPubKey(&tpmPubKey);
|
||||
PublicMarshalAndComputeName(&tpmPubKey, tpmKeyName);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
# endif // SEC_CHANNEL_SUPPORT
|
||||
#endif // SEC_CHANNEL_SUPPORT
|
||||
|
||||
@ -1,62 +1,4 @@
|
||||
/********************************************************************************/
|
||||
/* */
|
||||
/* Process the Authorization Sessions */
|
||||
/* 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
|
||||
|
||||
//** Introduction
|
||||
// This file contains the subsystem that process the authorization sessions
|
||||
@ -71,9 +13,9 @@
|
||||
#include "Tpm.h"
|
||||
#include "ACT.h"
|
||||
#include "Marshal.h"
|
||||
# if SEC_CHANNEL_SUPPORT
|
||||
#include "SecChannel_fp.h"
|
||||
# endif // SEC_CHANNEL_SUPPORT
|
||||
#if SEC_CHANNEL_SUPPORT
|
||||
# include "SecChannel_fp.h"
|
||||
#endif // SEC_CHANNEL_SUPPORT
|
||||
|
||||
//
|
||||
//** Authorization Support Functions
|
||||
@ -751,19 +693,20 @@ BOOL CompareParametersHash(COMMAND* command, // IN: main parsing structure
|
||||
return MemoryEqual2B(&session->u1.pHash.b, &pHash.b);
|
||||
}
|
||||
|
||||
# if SEC_CHANNEL_SUPPORT
|
||||
#if SEC_CHANNEL_SUPPORT
|
||||
//*** CompareScKeyNameHash()
|
||||
// This function computes the secure channel key name hash (from the requester and/or TPM key
|
||||
// used to establish the secure channel session) and compares it to the scKeyNameHash in the
|
||||
// This function computes the secure channel key name hash (from the requester and/or TPM key
|
||||
// used to establish the secure channel session) and compares it to the scKeyNameHash in the
|
||||
// session data, returning true if they are equal.
|
||||
BOOL CompareScKeyNameHash(SESSION* session, // IN: session structure
|
||||
TPM2B_NAME* reqKeyName, // IN: requester secure channel key name
|
||||
TPM2B_NAME* tpmKeyName // IN: TPM secure channel key name
|
||||
BOOL CompareScKeyNameHash(
|
||||
SESSION* session, // IN: session structure
|
||||
TPM2B_NAME* reqKeyName, // IN: requester secure channel key name
|
||||
TPM2B_NAME* tpmKeyName // IN: TPM secure channel key name
|
||||
)
|
||||
{
|
||||
HASH_STATE hashState;
|
||||
TPM2B_DIGEST scKeyNameHash;
|
||||
UINT16 zeroSize = 0x0000;
|
||||
UINT16 zeroSize = 0x0000;
|
||||
|
||||
// Compute secure channel key name hash
|
||||
// scKeyNameHash = hash(reqKeyName.size || reqKeyName.name || tpmKeyName.size || tpmKeyName.name)
|
||||
@ -804,10 +747,11 @@ BOOL CompareScKeyNameHash(SESSION* session, // IN: session structure
|
||||
CryptHashEnd2B(&hashState, &scKeyNameHash.b);
|
||||
|
||||
// and compare
|
||||
return MemoryEqual(
|
||||
session->scKeyNameHash.t.buffer, scKeyNameHash.t.buffer, scKeyNameHash.t.size);
|
||||
return MemoryEqual(session->scKeyNameHash.t.buffer,
|
||||
scKeyNameHash.t.buffer,
|
||||
scKeyNameHash.t.size);
|
||||
}
|
||||
# endif // SEC_CHANNEL_SUPPORT
|
||||
#endif // SEC_CHANNEL_SUPPORT
|
||||
|
||||
//*** CheckPWAuthSession()
|
||||
// This function validates the authorization provided in a PWAP session. It
|
||||
@ -1179,25 +1123,26 @@ static TPM_RC CheckPolicyAuthSession(
|
||||
!= (session->attributes.nvWrittenState == SET))
|
||||
return TPM_RC_POLICY_FAIL;
|
||||
}
|
||||
# if SEC_CHANNEL_SUPPORT
|
||||
#if SEC_CHANNEL_SUPPORT
|
||||
if(session->attributes.checkSecureChannel)
|
||||
{
|
||||
TPM2B_NAME reqKeyName;
|
||||
TPM2B_NAME tpmKeyName;
|
||||
|
||||
// Check that the authorized TPM command is protected by an SPDM session and
|
||||
// Check that the authorized TPM command is protected by an SPDM session and
|
||||
// if so, get the names of the associated requester and TPM key
|
||||
if(!IsSpdmSessionActive(&reqKeyName, &tpmKeyName))
|
||||
return TPM_RC_CHANNEL;
|
||||
|
||||
// If required, check the requester or TPM secure channel key name by comparing scKeyNameHash
|
||||
if(session->attributes.checkReqKey == SET || session->attributes.checkTpmKey == SET)
|
||||
if(session->attributes.checkReqKey == SET
|
||||
|| session->attributes.checkTpmKey == SET)
|
||||
{
|
||||
if(!CompareScKeyNameHash(session, &reqKeyName, &tpmKeyName))
|
||||
return TPM_RC_CHANNEL_KEY;
|
||||
}
|
||||
}
|
||||
# endif // SEC_CHANNEL_SUPPORT
|
||||
#endif // SEC_CHANNEL_SUPPORT
|
||||
return TPM_RC_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@ -1,62 +1,4 @@
|
||||
/********************************************************************************/
|
||||
/* */
|
||||
/* This file contains extra TPM2B 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, 2016 - 2023 */
|
||||
/* */
|
||||
/********************************************************************************/
|
||||
// SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
//
|
||||
// This file contains extra TPM2B structures
|
||||
@ -81,16 +23,16 @@ 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 \
|
||||
{ \
|
||||
NUMBYTES size; \
|
||||
BYTE buffer[(bytes)]; \
|
||||
} t; \
|
||||
TPM2B b; \
|
||||
} TPM2B_##name
|
||||
#define TPM2B_TYPE(name, bytes) \
|
||||
typedef union \
|
||||
{ \
|
||||
struct \
|
||||
{ \
|
||||
NUMBYTES 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.
|
||||
|
||||
@ -1,62 +1,4 @@
|
||||
/********************************************************************************/
|
||||
/* */
|
||||
/* Algorithm Values from the TCG Algorithm Registry */
|
||||
/* 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, 2019 - 2024 */
|
||||
/* */
|
||||
/********************************************************************************/
|
||||
// SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
|
||||
// FILE GENERATED BY TpmExtractCode: DO NOT EDIT
|
||||
@ -122,14 +64,20 @@
|
||||
# define CURVE_448_KEY_SIZE 448
|
||||
|
||||
// Derived ECC Value
|
||||
# define ECC_CURVES \
|
||||
{ \
|
||||
TPM_ECC_NIST_P192, TPM_ECC_NIST_P224, TPM_ECC_NIST_P256, \
|
||||
TPM_ECC_NIST_P384, TPM_ECC_NIST_P521, TPM_ECC_BN_P256, \
|
||||
TPM_ECC_BN_P638, TPM_ECC_SM2_P256, TPM_ECC_BP_P256_R1, \
|
||||
TPM_ECC_BP_P384_R1, TPM_ECC_BP_P512_R1, TPM_ECC_CURVE_25519, \
|
||||
TPM_ECC_CURVE_448 \
|
||||
}
|
||||
# define ECC_CURVES \
|
||||
{TPM_ECC_NIST_P192, \
|
||||
TPM_ECC_NIST_P224, \
|
||||
TPM_ECC_NIST_P256, \
|
||||
TPM_ECC_NIST_P384, \
|
||||
TPM_ECC_NIST_P521, \
|
||||
TPM_ECC_BN_P256, \
|
||||
TPM_ECC_BN_P638, \
|
||||
TPM_ECC_SM2_P256, \
|
||||
TPM_ECC_BP_P256_R1, \
|
||||
TPM_ECC_BP_P384_R1, \
|
||||
TPM_ECC_BP_P512_R1, \
|
||||
TPM_ECC_CURVE_25519, \
|
||||
TPM_ECC_CURVE_448}
|
||||
|
||||
# define ECC_CURVE_COUNT \
|
||||
(ECC_NIST_P192 + ECC_NIST_P224 + ECC_NIST_P256 + ECC_NIST_P384 + ECC_NIST_P521 \
|
||||
|
||||
@ -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
|
||||
|
||||
// functions shared by multiple signature algorithms
|
||||
#include "Tpm.h"
|
||||
@ -64,7 +6,7 @@
|
||||
#include "TpmMath_Debug_fp.h"
|
||||
#include "TpmMath_Util_fp.h"
|
||||
|
||||
#if(ALG_ECC && (ALG_ECSCHNORR || ALG_ECDAA))
|
||||
#if (ALG_ECC && (ALG_ECSCHNORR || ALG_ECDAA))
|
||||
|
||||
//*** TpmEcc_SchnorrCalculateS()
|
||||
// This contains the Schnorr signature (S) computation. It is used by both ECDAA and
|
||||
|
||||
@ -1547,13 +1547,13 @@ typedef struct
|
||||
TPMA_ACT attributes;
|
||||
} TPMS_ACT_DATA;
|
||||
|
||||
# if SEC_CHANNEL_SUPPORT
|
||||
#if SEC_CHANNEL_SUPPORT
|
||||
typedef struct
|
||||
{ // (Part 2: Structures)
|
||||
TPM2B_NAME reqKeyName;
|
||||
TPM2B_NAME tpmKeyName;
|
||||
} TPMS_SPDM_SESSION_INFO;
|
||||
# endif // SEC_CHANNEL_SUPPORT
|
||||
#endif // SEC_CHANNEL_SUPPORT
|
||||
|
||||
typedef struct
|
||||
{ // (Part 2: Structures)
|
||||
@ -1633,13 +1633,13 @@ typedef struct
|
||||
TPMS_ACT_DATA actData[MAX_ACT_DATA];
|
||||
} TPML_ACT_DATA;
|
||||
|
||||
# if SEC_CHANNEL_SUPPORT
|
||||
#if SEC_CHANNEL_SUPPORT
|
||||
typedef struct
|
||||
{ // (Part 2: Structures)
|
||||
UINT32 count;
|
||||
TPMS_SPDM_SESSION_INFO spdmSessionInfo[MAX_SPDM_SESS_INFO];
|
||||
} TPML_SPDM_SESSION_INFO;
|
||||
# endif // SEC_CHANNEL_SUPPORT
|
||||
#endif // SEC_CHANNEL_SUPPORT
|
||||
|
||||
typedef struct
|
||||
{ // (Part 2: Structures)
|
||||
@ -2374,13 +2374,13 @@ typedef struct
|
||||
TPMT_PUBLIC publicArea;
|
||||
} TPM2B_PUBLIC;
|
||||
|
||||
# if SEC_CHANNEL_SUPPORT
|
||||
#if SEC_CHANNEL_SUPPORT
|
||||
typedef struct
|
||||
{ // (Part 2: Structures)
|
||||
UINT32 count;
|
||||
TPM2B_PUBLIC pubKeys[MAX_PUB_KEYS];
|
||||
} TPML_PUB_KEY;
|
||||
# endif // SEC_CHANNEL_SUPPORT
|
||||
#endif // SEC_CHANNEL_SUPPORT
|
||||
|
||||
typedef union
|
||||
{ // (Part 2: Structures)
|
||||
@ -2393,14 +2393,14 @@ typedef union
|
||||
TPML_TAGGED_TPM_PROPERTY tpmProperties;
|
||||
TPML_TAGGED_PCR_PROPERTY pcrProperties;
|
||||
#if ALG_ECC
|
||||
TPML_ECC_CURVE eccCurves;
|
||||
TPML_ECC_CURVE eccCurves;
|
||||
#endif // ALG_ECC
|
||||
TPML_TAGGED_POLICY authPolicies;
|
||||
TPML_ACT_DATA actData;
|
||||
# if SEC_CHANNEL_SUPPORT
|
||||
TPML_PUB_KEY pubKeys;
|
||||
TPML_SPDM_SESSION_INFO spdmSessionInfo;
|
||||
# endif // SEC_CHANNEL_SUPPORT
|
||||
TPML_TAGGED_POLICY authPolicies;
|
||||
TPML_ACT_DATA actData;
|
||||
#if SEC_CHANNEL_SUPPORT
|
||||
TPML_PUB_KEY pubKeys;
|
||||
TPML_SPDM_SESSION_INFO spdmSessionInfo;
|
||||
#endif // SEC_CHANNEL_SUPPORT
|
||||
} TPMU_CAPABILITIES;
|
||||
|
||||
typedef struct
|
||||
|
||||
@ -1,62 +1,4 @@
|
||||
/********************************************************************************/
|
||||
/* */
|
||||
/* For defining the internal BIGNUM structure */
|
||||
/* 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
|
||||
|
||||
//** Introduction
|
||||
|
||||
@ -93,12 +35,12 @@
|
||||
// specific format without too much difficulty. For the math performed using
|
||||
// these numbers, the value is always positive.
|
||||
#define BN_STRUCT_DEF(struct_type, count) \
|
||||
struct st_##struct_type##_t \
|
||||
{ \
|
||||
crypt_uword_t allocated; \
|
||||
crypt_uword_t size; \
|
||||
crypt_uword_t d[count + BN_PAD + BN_PAD + BN_PAD]; /* libtpms changed */ \
|
||||
}
|
||||
struct st_##struct_type##_t \
|
||||
{ \
|
||||
crypt_uword_t allocated; \
|
||||
crypt_uword_t size; \
|
||||
crypt_uword_t d[count + BN_PAD + BN_PAD + BN_PAD]; /* libtpms changed */ \
|
||||
}
|
||||
|
||||
typedef BN_STRUCT_DEF(bnroot, 1) bignum_t;
|
||||
|
||||
@ -129,7 +71,7 @@ extern const bignum_t BnConstZero;
|
||||
|
||||
// Test to see if a bignum_t is equal to a word type
|
||||
#define BnEqualWord(bn, word) \
|
||||
((BnGetSize(bn) == 1) && (BnGetWord(bn, 0) == (crypt_uword_t)word))
|
||||
((BnGetSize(bn) == 1) && (BnGetWord(bn, 0) == (crypt_uword_t)word))
|
||||
|
||||
// Determine if a bigNum is even. A zero is even. Although the
|
||||
// indication that a number is zero is that its size is zero,
|
||||
@ -143,24 +85,24 @@ extern const bignum_t BnConstZero;
|
||||
// This will call the initialization function for a defined bignum_t.
|
||||
// This sets the allocated and used fields and clears the words of 'n'.
|
||||
#define BN_INIT(name) \
|
||||
(bigNum) BnInit((bigNum) & (name), BYTES_TO_CRYPT_WORDS(sizeof(name.d)))
|
||||
(bigNum) BnInit((bigNum) & (name), BYTES_TO_CRYPT_WORDS(sizeof(name.d)))
|
||||
|
||||
#define CRYPT_WORDS(bytes) BYTES_TO_CRYPT_WORDS(bytes)
|
||||
#define MIN_ALLOC(bytes) (CRYPT_WORDS(bytes) < 1 ? 1 : CRYPT_WORDS(bytes))
|
||||
#define BN_CONST(name, bytes, initializer) \
|
||||
typedef const struct name##_type \
|
||||
{ \
|
||||
crypt_uword_t allocated; \
|
||||
crypt_uword_t size; \
|
||||
crypt_uword_t d[MIN_ALLOC(bytes)]; \
|
||||
} name##_type; \
|
||||
name##_type name = {MIN_ALLOC(bytes), CRYPT_WORDS(bytes), {initializer}};
|
||||
typedef const struct name##_type \
|
||||
{ \
|
||||
crypt_uword_t allocated; \
|
||||
crypt_uword_t size; \
|
||||
crypt_uword_t d[MIN_ALLOC(bytes)]; \
|
||||
} name##_type; \
|
||||
name##_type name = {MIN_ALLOC(bytes), CRYPT_WORDS(bytes), {initializer}};
|
||||
|
||||
#define BN_STRUCT_ALLOCATION(bits) (BITS_TO_CRYPT_WORDS(bits) + 1)
|
||||
|
||||
// Create a structure of the correct size.
|
||||
#define BN_STRUCT(struct_type, bits) \
|
||||
BN_STRUCT_DEF(struct_type, BN_STRUCT_ALLOCATION(bits))
|
||||
BN_STRUCT_DEF(struct_type, BN_STRUCT_ALLOCATION(bits))
|
||||
|
||||
// Define a bigNum type with a specific allocation
|
||||
#define BN_TYPE(name, bits) typedef BN_STRUCT(name, bits) bn_##name##_t
|
||||
@ -168,19 +110,19 @@ extern const bignum_t BnConstZero;
|
||||
// This creates a local bigNum variable of a specific size and
|
||||
// initializes it from a TPM2B input parameter.
|
||||
#define BN_INITIALIZED(name, bits, initializer) \
|
||||
BN_STRUCT(name, bits) name##_; \
|
||||
bigNum name = TpmMath_IntFrom2B(BN_INIT(name##_), (const TPM2B*)initializer)
|
||||
BN_STRUCT(name, bits) name##_; \
|
||||
bigNum name = TpmMath_IntFrom2B(BN_INIT(name##_), (const TPM2B*)initializer)
|
||||
|
||||
// Create a local variable that can hold a number with 'bits'
|
||||
#define BN_VAR(name, bits) \
|
||||
BN_STRUCT(name, bits) _##name; \
|
||||
bigNum name = BN_INIT(_##name)
|
||||
#define BN_VAR(name, bits) \
|
||||
BN_STRUCT(name, bits) _##name; \
|
||||
bigNum name = BN_INIT(_##name)
|
||||
|
||||
// Create a type that can hold the largest number defined by the
|
||||
// implementation.
|
||||
#define BN_MAX(name) BN_VAR(name, LARGEST_NUMBER_BITS)
|
||||
#define BN_MAX_INITIALIZED(name, initializer) \
|
||||
BN_INITIALIZED(name, LARGEST_NUMBER_BITS, initializer)
|
||||
BN_INITIALIZED(name, LARGEST_NUMBER_BITS, initializer)
|
||||
|
||||
// A word size value is useful
|
||||
#define BN_WORD(name) BN_VAR(name, RADIX_BITS)
|
||||
@ -188,9 +130,9 @@ extern const bignum_t BnConstZero;
|
||||
// This is used to create a word-size bigNum and initialize it with
|
||||
// an input parameter to a function.
|
||||
#define BN_WORD_INITIALIZED(name, initial) \
|
||||
BN_STRUCT(RADIX_BITS) name##_; \
|
||||
bigNum name = \
|
||||
BnInitializeWord((bigNum)&name##_, BN_STRUCT_ALLOCATION(RADIX_BITS), initial)
|
||||
BN_STRUCT(RADIX_BITS) name##_; \
|
||||
bigNum name = BnInitializeWord( \
|
||||
(bigNum) & name##_, BN_STRUCT_ALLOCATION(RADIX_BITS), initial)
|
||||
|
||||
// ECC-Specific Values
|
||||
|
||||
@ -223,14 +165,14 @@ typedef struct constant_point_t
|
||||
// therefore a pointer to bn_point_t (a coords).
|
||||
// so bigPoint->coords->x->size is the size of x, and
|
||||
// all 3 components are the same size.
|
||||
#define BN_POINT_BUF(typename, bits) \
|
||||
struct bnpt_st_##typename##_t \
|
||||
{ \
|
||||
bn_point_t coords; \
|
||||
BN_STRUCT(typename##_x, MAX_ECC_KEY_BITS) x; \
|
||||
BN_STRUCT(typename##_y, MAX_ECC_KEY_BITS) y; \
|
||||
BN_STRUCT(typename##_z, MAX_ECC_KEY_BITS) z; \
|
||||
}
|
||||
#define BN_POINT_BUF(typename, bits) \
|
||||
struct bnpt_st_##typename##_t \
|
||||
{ \
|
||||
bn_point_t coords; \
|
||||
BN_STRUCT(typename##_x, MAX_ECC_KEY_BITS) x; \
|
||||
BN_STRUCT(typename##_y, MAX_ECC_KEY_BITS) y; \
|
||||
BN_STRUCT(typename##_z, MAX_ECC_KEY_BITS) z; \
|
||||
}
|
||||
|
||||
typedef BN_POINT_BUF(fullpoint, MAX_ECC_KEY_BITS) bn_fullpoint_t;
|
||||
|
||||
@ -324,12 +266,12 @@ TPM_INLINE TPM_ECC_CURVE BnCurveGetCurveId(const TPMBN_ECC_CURVE_CONSTANTS* C)
|
||||
// Convert bytes in initializers
|
||||
// This is used for CryptEccData.c.
|
||||
#define BIG_ENDIAN_BYTES_TO_UINT32(a, b, c, d) \
|
||||
(((UINT32)(a) << 24) + ((UINT32)(b) << 16) + ((UINT32)(c) << 8) + ((UINT32)(d)))
|
||||
(((UINT32)(a) << 24) + ((UINT32)(b) << 16) + ((UINT32)(c) << 8) + ((UINT32)(d)))
|
||||
|
||||
#define BIG_ENDIAN_BYTES_TO_UINT64(a, b, c, d, e, f, g, h) \
|
||||
(((UINT64)(a) << 56) + ((UINT64)(b) << 48) + ((UINT64)(c) << 40) \
|
||||
+ ((UINT64)(d) << 32) + ((UINT64)(e) << 24) + ((UINT64)(f) << 16) \
|
||||
+ ((UINT64)(g) << 8) + ((UINT64)(h)))
|
||||
#define BIG_ENDIAN_BYTES_TO_UINT64(a, b, c, d, e, f, g, h) \
|
||||
(((UINT64)(a) << 56) + ((UINT64)(b) << 48) + ((UINT64)(c) << 40) \
|
||||
+ ((UINT64)(d) << 32) + ((UINT64)(e) << 24) + ((UINT64)(f) << 16) \
|
||||
+ ((UINT64)(g) << 8) + ((UINT64)(h)))
|
||||
|
||||
// These macros are used for data initialization of big number ECC constants
|
||||
// These two macros combine a macro for data definition with a macro for
|
||||
@ -344,17 +286,17 @@ TPM_INLINE TPM_ECC_CURVE BnCurveGetCurveId(const TPMBN_ECC_CURVE_CONSTANTS* C)
|
||||
#define MJOIN(a, b) a b
|
||||
|
||||
#if RADIX_BYTES == 64
|
||||
# define B8_TO_BN(a, b, c, d, e, f, g, h) \
|
||||
((((((((((((((((UINT64)a) << 8) | (UINT64)b) << 8) | (UINT64)c) << 8) \
|
||||
| (UINT64)d) \
|
||||
<< 8) \
|
||||
| (UINT64)e) \
|
||||
<< 8) \
|
||||
| (UINT64)f) \
|
||||
<< 8) \
|
||||
| (UINT64)g) \
|
||||
<< 8) \
|
||||
| (UINT64)h)
|
||||
# define B8_TO_BN(a, b, c, d, e, f, g, h) \
|
||||
((((((((((((((((UINT64)a) << 8) | (UINT64)b) << 8) | (UINT64)c) << 8) \
|
||||
| (UINT64)d) \
|
||||
<< 8) \
|
||||
| (UINT64)e) \
|
||||
<< 8) \
|
||||
| (UINT64)f) \
|
||||
<< 8) \
|
||||
| (UINT64)g) \
|
||||
<< 8) \
|
||||
| (UINT64)h)
|
||||
# define B1_TO_BN(a) B8_TO_BN(0, 0, 0, 0, 0, 0, 0, a)
|
||||
# define B2_TO_BN(a, b) B8_TO_BN(0, 0, 0, 0, 0, 0, a, b)
|
||||
# define B3_TO_BN(a, b, c) B8_TO_BN(0, 0, 0, 0, 0, a, b, c)
|
||||
@ -367,7 +309,7 @@ TPM_INLINE TPM_ECC_CURVE BnCurveGetCurveId(const TPMBN_ECC_CURVE_CONSTANTS* C)
|
||||
# define B2_TO_BN(a, b) B4_TO_BN(0, 0, a, b)
|
||||
# define B3_TO_BN(a, b, c) B4_TO_BN(0, a, b, c)
|
||||
# define B4_TO_BN(a, b, c, d) \
|
||||
(((((((UINT32)a << 8) | (UINT32)b) << 8) | (UINT32)c) << 8) | (UINT32)d)
|
||||
(((((((UINT32)a << 8) | (UINT32)b) << 8) | (UINT32)c) << 8) | (UINT32)d)
|
||||
# define B5_TO_BN(a, b, c, d, e) B4_TO_BN(b, c, d, e), B1_TO_BN(a)
|
||||
# define B6_TO_BN(a, b, c, d, e, f) B4_TO_BN(c, d, e, f), B2_TO_BN(a, b)
|
||||
# define B7_TO_BN(a, b, c, d, e, f, g) B4_TO_BN(d, e, f, g), B3_TO_BN(a, b, c)
|
||||
|
||||
@ -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
|
||||
//
|
||||
@ -139,46 +81,47 @@ typedef const BYTE* PCBYTE;
|
||||
|
||||
// Add data to the hash
|
||||
# define HASH_DATA_METHOD_DEF \
|
||||
void(HASH_DATA_METHOD)(PANY_HASH_STATE state, PCBYTE buffer, size_t size)
|
||||
void(HASH_DATA_METHOD)(PANY_HASH_STATE state, PCBYTE buffer, size_t size)
|
||||
# define HASH_DATA(hashState, dInSize, dIn) \
|
||||
((hashState)->def->method.data)(&(hashState)->state, dIn, dInSize)
|
||||
((hashState)->def->method.data)(&(hashState)->state, dIn, dInSize)
|
||||
|
||||
// Finalize the hash and get the digest
|
||||
# define HASH_END_METHOD_DEF \
|
||||
void(HASH_END_METHOD)(BYTE * buffer, PANY_HASH_STATE state)
|
||||
void(HASH_END_METHOD)(BYTE * buffer, PANY_HASH_STATE state)
|
||||
# define HASH_END(hashState, buffer) \
|
||||
((hashState)->def->method.end)(buffer, &(hashState)->state)
|
||||
((hashState)->def->method.end)(buffer, &(hashState)->state)
|
||||
|
||||
// Copy the hash context
|
||||
// Note: For import, export, and copy, memcpy() is used since there is no
|
||||
// reformatting necessary between the internal and external forms.
|
||||
# define HASH_STATE_COPY_METHOD_DEF \
|
||||
void(HASH_STATE_COPY_METHOD)( \
|
||||
PANY_HASH_STATE to, PCANY_HASH_STATE from, size_t size)
|
||||
# define HASH_STATE_COPY(hashStateOut, hashStateIn) \
|
||||
((hashStateIn)->def->method.copy)(&(hashStateOut)->state, \
|
||||
&(hashStateIn)->state, \
|
||||
(hashStateIn)->def->contextSize)
|
||||
void(HASH_STATE_COPY_METHOD)( \
|
||||
PANY_HASH_STATE to, PCANY_HASH_STATE from, size_t size)
|
||||
# define HASH_STATE_COPY(hashStateOut, hashStateIn) \
|
||||
((hashStateIn)->def->method.copy)(&(hashStateOut)->state, \
|
||||
&(hashStateIn)->state, \
|
||||
(hashStateIn)->def->contextSize)
|
||||
|
||||
// Copy (with reformatting when necessary) an internal hash structure to an
|
||||
// external blob
|
||||
# define HASH_STATE_EXPORT_METHOD_DEF \
|
||||
void(HASH_STATE_EXPORT_METHOD)(BYTE * to, PCANY_HASH_STATE from, size_t size)
|
||||
# define HASH_STATE_EXPORT(to, hashStateFrom) \
|
||||
((hashStateFrom)->def->method.copyOut)( \
|
||||
&(((BYTE*)(to))[offsetof(HASH_STATE, state)]), \
|
||||
&(hashStateFrom)->state, \
|
||||
(hashStateFrom)->def->contextSize)
|
||||
void(HASH_STATE_EXPORT_METHOD)(BYTE * to, PCANY_HASH_STATE from, size_t size)
|
||||
# define HASH_STATE_EXPORT(to, hashStateFrom) \
|
||||
((hashStateFrom)->def->method.copyOut)( \
|
||||
&(((BYTE*)(to))[offsetof(HASH_STATE, state)]), \
|
||||
&(hashStateFrom)->state, \
|
||||
(hashStateFrom)->def->contextSize)
|
||||
|
||||
// Copy from an external blob to an internal formate (with reformatting when
|
||||
// necessary
|
||||
# define HASH_STATE_IMPORT_METHOD_DEF \
|
||||
void(HASH_STATE_IMPORT_METHOD)(PANY_HASH_STATE to, const BYTE* from, size_t size)
|
||||
# define HASH_STATE_IMPORT(hashStateTo, from) \
|
||||
((hashStateTo)->def->method.copyIn)( \
|
||||
&(hashStateTo)->state, \
|
||||
&(((const BYTE*)(from))[offsetof(HASH_STATE, state)]), \
|
||||
(hashStateTo)->def->contextSize)
|
||||
void(HASH_STATE_IMPORT_METHOD)( \
|
||||
PANY_HASH_STATE to, const BYTE* from, size_t size)
|
||||
# define HASH_STATE_IMPORT(hashStateTo, from) \
|
||||
((hashStateTo)->def->method.copyIn)( \
|
||||
&(hashStateTo)->state, \
|
||||
&(((const BYTE*)(from))[offsetof(HASH_STATE, state)]), \
|
||||
(hashStateTo)->def->contextSize)
|
||||
|
||||
// Function aliases. The code in CryptHash.c uses the internal designation for the
|
||||
// functions. These need to be translated to the function names of the library.
|
||||
|
||||
@ -1,62 +1,4 @@
|
||||
/********************************************************************************/
|
||||
/* */
|
||||
/* Swap */
|
||||
/* 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
|
||||
|
||||
#ifndef _SWAP_H
|
||||
#define _SWAP_H
|
||||
@ -106,21 +48,21 @@
|
||||
// Disaggregate a UINT into a byte array
|
||||
|
||||
# define UINT8_TO_BYTE_ARRAY(i, b) \
|
||||
{ \
|
||||
*((uint8_t*)(b)) = (i); \
|
||||
}
|
||||
{ \
|
||||
*((uint8_t*)(b)) = (i); \
|
||||
}
|
||||
# define UINT16_TO_BYTE_ARRAY(i, b) \
|
||||
{ \
|
||||
*((uint16_t*)(b)) = (i); \
|
||||
}
|
||||
{ \
|
||||
*((uint16_t*)(b)) = (i); \
|
||||
}
|
||||
# define UINT32_TO_BYTE_ARRAY(i, b) \
|
||||
{ \
|
||||
*((uint32_t*)(b)) = (i); \
|
||||
}
|
||||
{ \
|
||||
*((uint32_t*)(b)) = (i); \
|
||||
}
|
||||
# define UINT64_TO_BYTE_ARRAY(i, b) \
|
||||
{ \
|
||||
*((uint64_t*)(b)) = (i); \
|
||||
}
|
||||
{ \
|
||||
*((uint64_t*)(b)) = (i); \
|
||||
}
|
||||
# else
|
||||
// the little endian macros for machines that allow unaligned memory access
|
||||
// the big-endian macros for machines that allow unaligned memory access
|
||||
@ -133,21 +75,21 @@
|
||||
// Disaggregate a UINT into a byte array
|
||||
|
||||
# define UINT8_TO_BYTE_ARRAY(i, b) \
|
||||
{ \
|
||||
*((uint8_t*)(b)) = (i); \
|
||||
}
|
||||
# define UINT16_TO_BYTE_ARRAY(i, b) \
|
||||
{ \
|
||||
*((uint16_t*)(b)) = REVERSE_ENDIAN_16(i); \
|
||||
}
|
||||
# define UINT32_TO_BYTE_ARRAY(i, b) \
|
||||
{ \
|
||||
*((uint32_t*)(b)) = REVERSE_ENDIAN_32(i); \
|
||||
}
|
||||
# define UINT64_TO_BYTE_ARRAY(i, b) \
|
||||
{ \
|
||||
*((uint64_t*)(b)) = REVERSE_ENDIAN_64(i); \
|
||||
}
|
||||
{ \
|
||||
*((uint8_t*)(b)) = (i); \
|
||||
}
|
||||
# define UINT16_TO_BYTE_ARRAY(i, b) \
|
||||
{ \
|
||||
*((uint16_t*)(b)) = REVERSE_ENDIAN_16(i); \
|
||||
}
|
||||
# define UINT32_TO_BYTE_ARRAY(i, b) \
|
||||
{ \
|
||||
*((uint32_t*)(b)) = REVERSE_ENDIAN_32(i); \
|
||||
}
|
||||
# define UINT64_TO_BYTE_ARRAY(i, b) \
|
||||
{ \
|
||||
*((uint64_t*)(b)) = REVERSE_ENDIAN_64(i); \
|
||||
}
|
||||
# endif // BIG_ENDIAN_TPM
|
||||
|
||||
#endif // AUTO_ALIGN == NO
|
||||
|
||||
Loading…
Reference in New Issue
Block a user