mirror of
https://github.com/stefanberger/libtpms
synced 2026-08-11 19:26:27 +00:00
Sync: Sync minor changes in several files with upstream
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
This commit is contained in:
parent
f944381cd4
commit
7aca56fde2
@ -68,8 +68,13 @@
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
//** From Cancel.c
|
||||
#if ALLOW_FORCE_FAILURE_MODE
|
||||
// From Failure.c
|
||||
// allow simulator to force the TPM into failure mode.
|
||||
LIB_EXPORT void _plat__SetForceFailureMode();
|
||||
#endif
|
||||
|
||||
//** From Cancel.c
|
||||
// Set cancel flag.
|
||||
LIB_EXPORT void _plat__SetCancel(void);
|
||||
|
||||
|
||||
@ -80,7 +80,7 @@ bool PlatformServer(SOCKET s);
|
||||
//*** PlatformSvcRoutine()
|
||||
// This function is called to set up the socket interfaces to listen for
|
||||
// commands.
|
||||
int PlatformSvcRoutine(LPVOID port);
|
||||
DWORD WINAPI PlatformSvcRoutine(LPVOID port);
|
||||
|
||||
//*** PlatformSignalService()
|
||||
// This function starts a new thread waiting for platform signals.
|
||||
@ -88,13 +88,13 @@ int PlatformSvcRoutine(LPVOID port);
|
||||
// received.
|
||||
// If PickPorts is true, the server finds the next available port if the specified
|
||||
// port was unavailable.
|
||||
int PlatformSignalService(int *PortNumberPlatform);
|
||||
int PlatformSignalService(int PortNumber, bool PickPorts);
|
||||
|
||||
//*** RegularCommandService()
|
||||
// This function services regular commands.
|
||||
// If PickPorts is true, the server finds the next available port if the specified
|
||||
// port was unavailable.
|
||||
int RegularCommandService(int *PortNumber);
|
||||
int RegularCommandService(int PortNumber, bool PickPorts);
|
||||
|
||||
//*** StartTcpServer()
|
||||
// This is the main entry-point to the TCP server. The server listens on the port
|
||||
@ -103,8 +103,7 @@ int RegularCommandService(int *PortNumber);
|
||||
// port was unavailable.
|
||||
//
|
||||
// Note that there is no way to specify the network interface in this implementation.
|
||||
int StartTcpServer(int *PortNumber, int *PortNumberPlatform);
|
||||
|
||||
int StartTcpServer(int PortNumber, bool PickPorts);
|
||||
|
||||
//*** ReadBytes()
|
||||
// This function reads the indicated number of bytes ('NumBytes') into buffer
|
||||
|
||||
@ -126,7 +126,7 @@ void _rpc__Signal_PowerOff(void)
|
||||
void _rpc__ForceFailureMode(void)
|
||||
{
|
||||
#if SIMULATION
|
||||
SetForceFailureMode();
|
||||
_plat__SetForceFailureMode();
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
@ -79,10 +79,10 @@
|
||||
#define CAMELLIA_192 (YES * ALG_CAMELLIA) /* since libtpms v0.10 stateFormatLevel 4 */
|
||||
#define CAMELLIA_256 (YES * ALG_CAMELLIA)
|
||||
|
||||
#define ALG_TDES ALG_YES /* libtpms enabled */
|
||||
#define ALG_TDES ALG_YES /* libtpms added begin; enabled */
|
||||
|
||||
#define TDES_128 (ALG_TDES && YES)
|
||||
#define TDES_192 (ALG_TDES && YES)
|
||||
#define TDES_192 (ALG_TDES && YES) /* libtpms added end */
|
||||
|
||||
// must be yes if any above are yes.
|
||||
#define ALG_SYMCIPHER (ALG_AES || ALG_SM4 || ALG_CAMELLIA)
|
||||
@ -152,7 +152,7 @@
|
||||
#define ALG_SHA256 ALG_YES
|
||||
#define ALG_SHA256_192 ALG_NO
|
||||
#define ALG_SHA384 ALG_YES
|
||||
#define ALG_SHA512 ALG_YES
|
||||
#define ALG_SHA512 ALG_YES // libtpms: enabled
|
||||
|
||||
#define ALG_SHA3_256 ALG_NO
|
||||
#define ALG_SHA3_384 ALG_NO
|
||||
@ -271,6 +271,8 @@
|
||||
//***********************************************
|
||||
// Defines controlling secure channel functionality
|
||||
//***********************************************
|
||||
// This flag enables support for PolicyTransportSPDM.
|
||||
// See CC_PolicyTransportSPDM.
|
||||
#define SEC_CHANNEL_SUPPORT NO // libtpms: NO
|
||||
|
||||
#endif // _TPM_PROFILE_COMMON_H_
|
||||
|
||||
@ -1,5 +1,9 @@
|
||||
// SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
// This file defines any Vendor command IDs, and must also define the
|
||||
// VENDOR_COMMAND_ARRAY_COUNT which is consumed by the CoreLibrary.
|
||||
// This file is included inside TpmProfile_CommandList.h and therefore
|
||||
// has access to CC_YES and CC_NO for turning commands on and off.
|
||||
|
||||
#ifndef _TPM_PROFILE_COMMAND_LIST_H_
|
||||
# error This file should be included only within TpmProfile_CommandList.h
|
||||
|
||||
@ -58,40 +58,6 @@
|
||||
/* */
|
||||
/********************************************************************************/
|
||||
|
||||
/* Microsoft Reference Implementation for TPM 2.0
|
||||
*
|
||||
* The copyright in this software is being made available under the BSD License,
|
||||
* included below. This software may be subject to other third party and
|
||||
* contributor rights, including patent rights, and no such rights are granted
|
||||
* under this license.
|
||||
*
|
||||
* Copyright (c) Microsoft Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* BSD License
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
* of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ""AS IS""
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
// This file contains the ECC curve data. The data is contained in macros so this
|
||||
// file can be included in other format-specific header files that reformat the
|
||||
|
||||
@ -86,7 +86,7 @@ uint64_t ClockGetTime(clockid_t clk_id);
|
||||
// libtpms: added end
|
||||
|
||||
//** From DebugHelpers.c
|
||||
|
||||
|
||||
#if CERTIFYX509_DEBUG
|
||||
|
||||
#if 0 // libtpms: added
|
||||
|
||||
@ -117,9 +117,9 @@ typedef union
|
||||
#if HASH_ALIGNMENT == 8
|
||||
uint64_t align;
|
||||
#else
|
||||
#if defined(__x86_64__)
|
||||
#if defined(__x86_64__) // libtpms added begin
|
||||
# error Wrong HASH_ALIGNMENT
|
||||
#endif
|
||||
#endif // libtpms added end
|
||||
uint32_t align;
|
||||
#endif
|
||||
} ANY_HASH_STATE;
|
||||
|
||||
@ -83,11 +83,11 @@
|
||||
#else
|
||||
# define IF_IMPLEMENTED_CAMELLIA(op)
|
||||
#endif
|
||||
#if ALG_TDES
|
||||
#if ALG_TDES // libtpms added begin
|
||||
# define IF_IMPLEMENTED_TDES(op) op(TDES, tdes)
|
||||
#else
|
||||
# define IF_IMPLEMENTED_TDES(op)
|
||||
#endif
|
||||
#endif // libtpms added end
|
||||
|
||||
#define FOR_EACH_SYM(op) \
|
||||
IF_IMPLEMENTED_AES(op) \
|
||||
@ -112,9 +112,9 @@ typedef union tpmCryptKeySchedule_t {
|
||||
uint64_t alignment;
|
||||
#else
|
||||
uint32_t alignment;
|
||||
# if defined(__x86_64__)
|
||||
# if defined(__x86_64__) // libtpms added begin
|
||||
# error Bad SYMMETRIC_ALIGNMENT
|
||||
# endif
|
||||
# endif // libtpms added end
|
||||
#endif
|
||||
} tpmCryptKeySchedule_t;
|
||||
|
||||
|
||||
@ -58,11 +58,6 @@
|
||||
/* */
|
||||
/********************************************************************************/
|
||||
|
||||
/*(Auto-generated)
|
||||
* Created by TpmPrototypes; Version 3.0 July 18, 2017
|
||||
* Date: Apr 2, 2019 Time: 03:18:00PM
|
||||
*/
|
||||
|
||||
#ifndef _CRYPT_RSA_FP_H_
|
||||
#define _CRYPT_RSA_FP_H_
|
||||
|
||||
|
||||
@ -362,8 +362,6 @@
|
||||
goto Error; \
|
||||
} while(0)
|
||||
|
||||
#include "MinMax.h"
|
||||
|
||||
#ifndef IsOdd
|
||||
# define IsOdd(a) (((a) & 1) != 0)
|
||||
#endif
|
||||
|
||||
@ -993,6 +993,7 @@ typedef UINT32 TPMA_ALGORITHM;
|
||||
typedef UINT32 TPMA_OBJECT;
|
||||
#define TPMA_OBJECT_fixedTPM (TPMA_OBJECT)(1 << 1)
|
||||
#define TPMA_OBJECT_stClear (TPMA_OBJECT)(1 << 2)
|
||||
#define TPMA_OBJECT_fixedFirmware (TPMA_OBJECT)(1 << 3)
|
||||
#define TPMA_OBJECT_fixedParent (TPMA_OBJECT)(1 << 4)
|
||||
#define TPMA_OBJECT_sensitiveDataOrigin (TPMA_OBJECT)(1 << 5)
|
||||
#define TPMA_OBJECT_userWithAuth (TPMA_OBJECT)(1 << 6)
|
||||
@ -1778,7 +1779,7 @@ typedef struct
|
||||
TPM2B_AUTH hmac;
|
||||
} TPMS_AUTH_RESPONSE;
|
||||
|
||||
typedef TPM_KEY_BITS TPMI_TDES_KEY_BITS;
|
||||
typedef TPM_KEY_BITS TPMI_TDES_KEY_BITS; // libtpms added
|
||||
typedef TPM_KEY_BITS TPMI_AES_KEY_BITS; // (Part 2: Structures)
|
||||
typedef TPM_KEY_BITS TPMI_SM4_KEY_BITS; // (Part 2: Structures)
|
||||
typedef TPM_KEY_BITS TPMI_CAMELLIA_KEY_BITS; // (Part 2: Structures)
|
||||
|
||||
@ -95,4 +95,10 @@ MUST_BE_0_OR_1(VENDOR_PERMANENT_AUTH_ENABLED);
|
||||
# endif
|
||||
#endif
|
||||
|
||||
MUST_BE_0_OR_1(SEC_CHANNEL_SUPPORT);
|
||||
MUST_BE_0_OR_1(CC_PolicyTransportSPDM);
|
||||
#if SEC_CHANNEL_SUPPORT != CC_PolicyTransportSPDM
|
||||
# error SEC_CHANNEL_SUPPORT and CC_PolicyTransportSPDM must have the same value
|
||||
#endif
|
||||
|
||||
#endif // _VERIFY_CONFIGURATION_H
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
// SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
|
||||
#ifndef _TPM_DEBUG_H_
|
||||
#define _TPM_DEBUG_H_
|
||||
|
||||
|
||||
@ -45,4 +45,3 @@ TPM2_NV_ReadPublic2(NV_ReadPublic2_In* in, // IN: input parameter list
|
||||
}
|
||||
|
||||
#endif // CC_NV_ReadPublic2
|
||||
|
||||
|
||||
@ -45,7 +45,6 @@ BOOL CryptSymStartup(void)
|
||||
// Return Type: INT16
|
||||
// <= 0 cipher not supported
|
||||
// > 0 the cipher block size in bytes
|
||||
|
||||
LIB_EXPORT INT16 CryptGetSymmetricBlockSize(
|
||||
TPM_ALG_ID symmetricAlg, // IN: the symmetric algorithm
|
||||
UINT16 keySizeInBits // IN: the key size
|
||||
|
||||
@ -1369,7 +1369,6 @@ BOOL CryptIsAsymSignScheme(TPMI_ALG_PUBLIC publicType, // IN: Type of the
|
||||
# endif
|
||||
switch(scheme)
|
||||
{
|
||||
// Support for ECDSA is required for ECC
|
||||
case TPM_ALG_ECDSA:
|
||||
# if ALG_ECDAA // ECDAA is optional
|
||||
case TPM_ALG_ECDAA:
|
||||
|
||||
@ -136,7 +136,6 @@ TPM_RC TpmEcc_SignEcdaa(
|
||||
CryptDigestUpdate2B(&state, &digest->b);
|
||||
CryptHashEnd2B(&state, &T.b);
|
||||
TpmMath_IntFrom2B(bnT, &T.b);
|
||||
// libtpms: Note: T is NOT a concern for constant-timeness
|
||||
// Watch out for the name collisions in this call!!
|
||||
retVal = TpmEcc_SchnorrCalculateS(
|
||||
bnS,
|
||||
|
||||
@ -148,7 +148,6 @@ TPM_RC TpmEcc_SignEcSchnorr(
|
||||
SchnorrReduce(e, order);
|
||||
// Convert hash to number
|
||||
TpmMath_IntFrom2B(bnR, e);
|
||||
// libtpms: Note: e is NOT a concern for constant-timeness
|
||||
// Do the Schnorr computation
|
||||
retVal = TpmEcc_SchnorrCalculateS(
|
||||
bnS, bnK, bnR, bnD, ExtEcc_CurveGetOrder(ExtEcc_CurveGetCurveId(E)));
|
||||
|
||||
@ -643,7 +643,7 @@ SessionContextLoad(SESSION_BUF* session, // IN: session structure from saved co
|
||||
break;
|
||||
|
||||
// if no spot found, then this is an internal error
|
||||
pAssert(slotIndex < MAX_LOADED_SESSIONS);
|
||||
pAssert_RC(slotIndex < MAX_LOADED_SESSIONS);
|
||||
|
||||
// libtpms: besides the s_freeSessionSlots guard add another array index guard
|
||||
if (slotIndex >= MAX_LOADED_SESSIONS) { // libtpms added begin; cppcheck
|
||||
|
||||
@ -292,10 +292,7 @@ static BOOL TPMPropertyIsDefined(TPM_PT property, // IN: property
|
||||
case TPM_PT_TOTAL_COMMANDS:
|
||||
// total number of commands implemented in the TPM
|
||||
{
|
||||
#if COMPRESSED_LISTS // libtpms changed begin
|
||||
(*value) = RuntimeCommandsCountEnabled(&g_RuntimeProfile.RuntimeCommands); // libtpms changed: was COMMAND_COUNT
|
||||
#else
|
||||
COMMAND_INDEX commandIndex;
|
||||
COMMAND_INDEX commandIndex; // libtpms changed begin
|
||||
*value = 0;
|
||||
|
||||
// scan all implemented commands
|
||||
@ -304,17 +301,13 @@ static BOOL TPMPropertyIsDefined(TPM_PT property, // IN: property
|
||||
commandIndex = GetNextCommandIndex(commandIndex))
|
||||
{
|
||||
(*value)++; // count of all implemented
|
||||
}
|
||||
#endif // libtpms changed end
|
||||
} // libtpms changed end
|
||||
break;
|
||||
}
|
||||
case TPM_PT_LIBRARY_COMMANDS:
|
||||
// number of commands from the TPM library that are implemented
|
||||
{
|
||||
#if COMPRESSED_LISTS // libtpms changed begin
|
||||
*value = RuntimeCommandsCountEnabled(&g_RuntimeProfile.RuntimeCommands); // libtpms changed: was LIBRARY_COMMAND_ARRAY_SIZE
|
||||
#else
|
||||
COMMAND_INDEX commandIndex;
|
||||
COMMAND_INDEX commandIndex; // libtpms changed begin
|
||||
*value = 0;
|
||||
|
||||
// scan all implemented commands
|
||||
@ -323,8 +316,7 @@ static BOOL TPMPropertyIsDefined(TPM_PT property, // IN: property
|
||||
commandIndex = GetNextCommandIndex(commandIndex))
|
||||
{
|
||||
(*value)++;
|
||||
}
|
||||
#endif // libtpms changed end
|
||||
} // libtpms changed end
|
||||
break;
|
||||
}
|
||||
case TPM_PT_VENDOR_COMMANDS:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user