diff --git a/LICENSE b/LICENSE index a32c52c47..f08e9ad0a 100644 --- a/LICENSE +++ b/LICENSE @@ -35,7 +35,48 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -For the TPM 2 code the following license and notices apply: + +For TPM 2 code that does not explicitly state a license, the following +license and notices apply: + + +TCG Reference Implementation for TPM 2.0 +This code is informative. + +The copyright in this software is being made available under the BSD License, +included below. + +Copyright 2010-2022 Microsoft Corporation +Copyright 2022-2025 Trusted Computing Group and its contributors + +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. + + +For other TPM 2 code the following license and notices apply: Licenses and Notices diff --git a/configure.ac b/configure.ac index 565415b48..6334cf144 100644 --- a/configure.ac +++ b/configure.ac @@ -11,7 +11,7 @@ AC_CONFIG_HEADERS([config.h]) AC_CONFIG_MACRO_DIR([m4]) AC_CANONICAL_TARGET -AM_INIT_AUTOMAKE([foreign 1.6 subdir-objects]) +AM_INIT_AUTOMAKE([foreign 1.9 subdir-objects tar-pax]) AM_SILENT_RULES([yes]) LIBTPMS_VER_MAJOR=`echo $PACKAGE_VERSION | awk -F. '{print $1}'` diff --git a/scripts/meld-all b/scripts/meld-all index 3aae682b6..dcfbc3eb7 100755 --- a/scripts/meld-all +++ b/scripts/meld-all @@ -5,6 +5,27 @@ SKIP_FILES="(Marshal.c|Marshal_fp.h)" NO_MELD_FLAG=$((1<<0)) +help() +{ + cat <<_EOF_ +Usage: TCG_TPM_HOME=... $1 [options] TPM2-directory + +The following options are available: + +--no-meld,--diff-only : Only display diffs between files; the first two lines + are related to the license and are ignore for the diff. +--help : Display this help screen and exit. + +The environmet variable TCG_TPM_HOME must be set and point to +the TCG TPM2 git checkout. + +Example: + +TCG_TPM_HOME=\$HOME/TPM $1 --diff-only src/tpm2 + +_EOF_ +} + main() { local opts f fname upstream flags @@ -65,7 +86,9 @@ main() continue fi - upstream=$(find "${TCG_TPM_HOME}" | grep -E "/${fname}\$") + fn=${f:${#1}} + upstream="${TCG_TPM_HOME}/${fn}" + #echo "$upstream" if [ -n "${upstream}" ]; then # find first empty line presumably after license @@ -74,14 +97,18 @@ main() if [ $((flags & NO_MELD_FLAG)) -eq 0 ]; then meld "${upstrean}" "${f}" else - echo "Something wrong with file $f" + echo "Something is wrong with file $f" fi fi line=$((line+1)) if [ $((flags & NO_MELD_FLAG)) -ne 0 ]; then echo "============================================================================" - echo "${f}" - diff --ignore-trailing-space <(sed -n "${line},\$p" < "${f}") "${upstream}" + if [ ! -f "${upstream}" ]; then + echo "${f}: file does not exist upstream" + else + echo "${f}" + diff --ignore-trailing-space <(sed -n "${line},\$p" < "${f}") "${upstream}" + fi fi if ! diff --ignore-trailing-space <(sed -n "${line},\$p" < "${f}") "${upstream}" &>/dev/null; then if [ $((flags & NO_MELD_FLAG)) -eq 0 ]; then diff --git a/scripts/meld-commit b/scripts/meld-commit new file mode 100755 index 000000000..8528d236b --- /dev/null +++ b/scripts/meld-commit @@ -0,0 +1,43 @@ +#!/usr/bin/env bash + +SKIP_FILES="(CMakeLists.txt|.cmake|CMakePresets.json|Makefile.am|configure.ac)$" + +if [ ! -d "$1" ]; then + echo "$1 is not a directory" + exit 1 +fi + +COMMIT="$2" +if [ -z "$2" ]; then + echo "2nd parameter must be a commit id. Not given, so assuming 'HEAD'" + COMMIT="HEAD" +fi + +if [ -z "${TCG_TPM_HOME}" ]; then + echo "TCG_TPM_HOME must be set to the TCG TPM repo checkout." + exit 1 +fi + +if [ ! -d "${TCG_TPM_HOME}" ]; then + echo "TCG_TPM_HOME must point to a directory." + exit 1 +fi + +set -x +LIBTPMS_ROOT="$PWD" + +pushd "${TCG_TPM_HOME}" >/dev/null || exit 1 + +git checkout "${COMMIT}" || exit 1 + +for fname in $(git diff-tree --no-commit-id --name-only "${COMMIT}" -r); do + if [[ $(basename "${fname}") =~ ${SKIP_FILES} ]]; then + continue + fi + mkdir -p "$(dirname "${LIBTPMS_ROOT}/${1}/${fname}")" + touch "${LIBTPMS_ROOT}/${1}/${fname}" + meld "${fname}" "${LIBTPMS_ROOT}/${1}/${fname}" + if [ $(stat -c%s "${LIBTPMS_ROOT}/${1}/${fname}") -eq 0 ]; then + rm -f "${LIBTPMS_ROOT}/${1}/${fname}" + fi +done diff --git a/src/Makefile.am b/src/Makefile.am index cfabb746b..338751182 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -186,108 +186,135 @@ libtpms_tpm2_la_CFLAGS += -D_POSIX_ libtpms_tpm2_la_CFLAGS += -DTPM_POSIX libtpms_tpm2_la_SOURCES = \ - tpm2/ACT_spt.c \ tpm2/ACTCommands.c \ - tpm2/AlgorithmCap.c \ - tpm2/AlgorithmTests.c \ tpm2/AsymmetricCommands.c \ tpm2/AttestationCommands.c \ - tpm2/Attest_spt.c \ tpm2/AuditCommands.c \ - tpm2/Bits.c \ - tpm2/BnEccConstants.c \ - tpm2/BnConvert.c \ - tpm2/BnMath.c \ - tpm2/BnMemory.c \ - tpm2/Cancel.c \ tpm2/CapabilityCommands.c \ - tpm2/Clock.c \ tpm2/ClockCommands.c \ - tpm2/CommandAudit.c \ - tpm2/CommandCodeAttributes.c \ - tpm2/CommandDispatcher.c \ tpm2/ContextCommands.c \ - tpm2/Context_spt.c \ - tpm2/CryptEccData.c \ - tpm2/CryptSelfTest.c \ - tpm2/CryptUtil.c \ - tpm2/DA.c \ - tpm2/DebugHelpers.c \ tpm2/DictionaryCommands.c \ tpm2/DuplicationCommands.c \ tpm2/EACommands.c \ - tpm2/EncryptDecrypt_spt.c \ - tpm2/Entity.c \ - tpm2/Entropy.c \ tpm2/EphemeralCommands.c \ - tpm2/ExecCommand.c \ - tpm2/ExtraData.c \ - tpm2/Global.c \ - tpm2/Handle.c \ tpm2/HashCommands.c \ - tpm2/Hierarchy.c \ tpm2/HierarchyCommands.c \ tpm2/IntegrityCommands.c \ - tpm2/IoBuffers.c \ - tpm2/Locality.c \ - tpm2/LocalityPlat.c \ tpm2/ManagementCommands.c \ - tpm2/Manufacture.c \ - tpm2/Marshal.c \ - tpm2/MathOnByteBuffers.c \ - tpm2/Memory.c \ tpm2/NVCommands.c \ - tpm2/NvDynamic.c \ - tpm2/NVMem.c \ - tpm2/NvReserved.c \ - tpm2/NV_spt.c \ - tpm2/Object.c \ tpm2/ObjectCommands.c \ - tpm2/Object_spt.c \ - tpm2/PCR.c \ - tpm2/PlatformACT.c \ - tpm2/PlatformData.c \ - tpm2/PlatformPcr.c \ - tpm2/Policy_spt.c \ - tpm2/Power.c \ - tpm2/PowerPlat.c \ - tpm2/PP.c \ - tpm2/PPPlat.c \ - tpm2/PrimeData.c \ - tpm2/PropertyCap.c \ tpm2/RandomCommands.c \ - tpm2/Response.c \ - tpm2/ResponseCodeProcessing.c \ - tpm2/RunCommand.c \ - tpm2/Session.c \ tpm2/SessionCommands.c \ - tpm2/SessionProcess.c \ tpm2/SigningCommands.c \ tpm2/StartupCommands.c \ tpm2/SymmetricCommands.c \ tpm2/TestingCommands.c \ - tpm2/Ticket.c \ - tpm2/Time.c \ - tpm2/TpmASN1.c \ - tpm2/TpmBigNumThunks.c \ - tpm2/TpmEcc_Signature_ECDAA.c \ - tpm2/TpmEcc_Signature_ECDSA.c \ - tpm2/TpmEcc_Signature_Schnorr.c \ - tpm2/TpmEcc_Signature_SM2.c \ - tpm2/TpmEcc_Signature_Util.c \ - tpm2/TpmEcc_Util.c \ - tpm2/TpmMath_Debug.c \ - tpm2/TpmMath_Util.c \ - tpm2/TpmSizeChecks.c \ - tpm2/TPMCmdp.c \ - tpm2/TpmFail.c \ - tpm2/Unique.c \ + tpm2/TPMCmd/Platform/src/Cancel.c \ + tpm2/TPMCmd/Platform/src/Clock.c \ + tpm2/TPMCmd/Platform/src/DebugHelpers.c \ + tpm2/TPMCmd/Platform/src/Entropy.c \ + tpm2/TPMCmd/Platform/src/ExtraData.c \ + tpm2/TPMCmd/Platform/src/Failure.c \ + tpm2/TPMCmd/Platform/src/Init.c \ + tpm2/TPMCmd/Platform/src/LocalityPlat.c \ + tpm2/TPMCmd/Platform/src/NVMem.c \ + tpm2/TPMCmd/Platform/src/NVVirtual.c \ + tpm2/TPMCmd/Platform/src/PlatformACT.c \ + tpm2/TPMCmd/Platform/src/PlatformData.c \ + tpm2/TPMCmd/Platform/src/PlatformPcr.c \ + tpm2/TPMCmd/Platform/src/PowerPlat.c \ + tpm2/TPMCmd/Platform/src/PPPlat.c \ + tpm2/TPMCmd/Platform/src/RunCommand.c \ + tpm2/TPMCmd/Platform/src/SelfTest.c \ + tpm2/TPMCmd/Platform/src/Unique.c \ + tpm2/TPMCmd/Platform/src/VendorInfo.c \ + tpm2/TPMCmd/Simulator/src/TPMCmdp.c \ + tpm2/TPMCmd/tpm/cryptolibs/EccRef/TpmEcc_Signature_ECDSA.c \ + tpm2/TPMCmd/tpm/cryptolibs/RsaRef/PrimeData.c \ + tpm2/TPMCmd/tpm/cryptolibs/TpmBigNum/BnConvert.c \ + tpm2/TPMCmd/tpm/cryptolibs/TpmBigNum/BnEccConstants.c \ + tpm2/TPMCmd/tpm/cryptolibs/TpmBigNum/BnMath.c \ + tpm2/TPMCmd/tpm/cryptolibs/TpmBigNum/BnMemory.c \ + tpm2/TPMCmd/tpm/cryptolibs/TpmBigNum/TpmBigNumThunks.c \ + tpm2/TPMCmd/tpm/src/command/Attestation/Attest_spt.c \ + tpm2/TPMCmd/tpm/src/command/Attestation/Quote.c \ + tpm2/TPMCmd/tpm/src/command/ClockTimer/ACT_spt.c \ + tpm2/TPMCmd/tpm/src/command/Context/Context_spt.c \ + tpm2/TPMCmd/tpm/src/command/Duplication/Duplicate.c \ + tpm2/TPMCmd/tpm/src/command/Duplication/Import.c \ + tpm2/TPMCmd/tpm/src/command/EA/PolicyAuthorize.c \ + tpm2/TPMCmd/tpm/src/command/EA/PolicyAuthorizeNV.c \ + tpm2/TPMCmd/tpm/src/command/EA/PolicyPCR.c \ + tpm2/TPMCmd/tpm/src/command/EA/PolicySecret.c \ + tpm2/TPMCmd/tpm/src/command/EA/PolicySigned.c \ + tpm2/TPMCmd/tpm/src/command/EA/Policy_spt.c \ + tpm2/TPMCmd/tpm/src/command/EA/PolicyTicket.c \ + tpm2/TPMCmd/tpm/src/command/EA/PolicyTransportSPDM.c \ + tpm2/TPMCmd/tpm/src/command/Hierarchy/CreatePrimary.c \ + tpm2/TPMCmd/tpm/src/command/Hierarchy/ReadOnlyControl.c \ + tpm2/TPMCmd/tpm/src/command/NVStorage/NV_Read.c \ + tpm2/TPMCmd/tpm/src/command/NVStorage/NV_ReadPublic2.c \ + tpm2/TPMCmd/tpm/src/command/NVStorage/NV_ReadPublic.c \ + tpm2/TPMCmd/tpm/src/command/NVStorage/NV_spt.c \ + tpm2/TPMCmd/tpm/src/command/Object/Create.c \ + tpm2/TPMCmd/tpm/src/command/Object/CreateLoaded.c \ + tpm2/TPMCmd/tpm/src/command/Object/MakeCredential.c \ + tpm2/TPMCmd/tpm/src/command/Object/ObjectChangeAuth.c \ + tpm2/TPMCmd/tpm/src/command/Object/Object_spt.c \ + tpm2/TPMCmd/tpm/src/command/PCR/PCR_Read.c \ + tpm2/TPMCmd/tpm/src/command/Symmetric/EncryptDecrypt_spt.c \ + tpm2/TPMCmd/tpm/src/crypt/AlgorithmTests.c \ + tpm2/TPMCmd/tpm/src/crypt/CryptEccData.c \ + tpm2/TPMCmd/tpm/src/crypt/CryptSelfTest.c \ + tpm2/TPMCmd/tpm/src/crypt/CryptUtil.c \ + tpm2/TPMCmd/tpm/src/crypt/ecc/TpmEcc_Signature_ECDAA.c \ + tpm2/TPMCmd/tpm/src/crypt/ecc/TpmEcc_Signature_Schnorr.c \ + tpm2/TPMCmd/tpm/src/crypt/ecc/TpmEcc_Signature_SM2.c \ + tpm2/TPMCmd/tpm/src/crypt/ecc/TpmEcc_Signature_Util.c \ + tpm2/TPMCmd/tpm/src/crypt/ecc/TpmEcc_Util.c \ + tpm2/TPMCmd/tpm/src/crypt/math/TpmMath_Debug.c \ + tpm2/TPMCmd/tpm/src/crypt/math/TpmMath_Util.c \ + tpm2/TPMCmd/tpm/src/crypt/Ticket.c \ + tpm2/TPMCmd/tpm/src/events/_TPM_Init.c \ + tpm2/TPMCmd/tpm/src/main/CommandDispatcher.c \ + tpm2/TPMCmd/tpm/src/main/ExecCommand.c \ + tpm2/TPMCmd/tpm/src/main/SessionProcess.c \ + tpm2/TPMCmd/tpm/src/subsystem/CommandAudit.c \ + tpm2/TPMCmd/tpm/src/subsystem/DA.c \ + tpm2/TPMCmd/tpm/src/subsystem/Hierarchy.c \ + tpm2/TPMCmd/tpm/src/subsystem/NvDynamic.c \ + tpm2/TPMCmd/tpm/src/subsystem/NvReserved.c \ + tpm2/TPMCmd/tpm/src/subsystem/Object.c \ + tpm2/TPMCmd/tpm/src/subsystem/PCR.c \ + tpm2/TPMCmd/tpm/src/subsystem/PP.c \ + tpm2/TPMCmd/tpm/src/subsystem/Session.c \ + tpm2/TPMCmd/tpm/src/subsystem/Time.c \ + tpm2/TPMCmd/tpm/src/support/AlgorithmCap.c \ + tpm2/TPMCmd/tpm/src/support/Bits.c \ + tpm2/TPMCmd/tpm/src/support/CommandCodeAttributes.c \ + tpm2/TPMCmd/tpm/src/support/Entity.c \ + tpm2/TPMCmd/tpm/src/support/Global.c \ + tpm2/TPMCmd/tpm/src/support/Handle.c \ + tpm2/TPMCmd/tpm/src/support/IoBuffers.c \ + tpm2/TPMCmd/tpm/src/support/Locality.c \ + tpm2/TPMCmd/tpm/src/support/Manufacture.c \ + tpm2/TPMCmd/tpm/src/support/Marshal.c \ + tpm2/TPMCmd/tpm/src/support/MathOnByteBuffers.c \ + tpm2/TPMCmd/tpm/src/support/Memory.c \ + tpm2/TPMCmd/tpm/src/support/Power.c \ + tpm2/TPMCmd/tpm/src/support/PropertyCap.c \ + tpm2/TPMCmd/tpm/src/support/Response.c \ + tpm2/TPMCmd/tpm/src/support/ResponseCodeProcessing.c \ + tpm2/TPMCmd/tpm/src/support/SecChannel.c \ + tpm2/TPMCmd/tpm/src/support/TpmFail.c \ + tpm2/TPMCmd/tpm/src/support/TpmSizeChecks.c \ + tpm2/TPMCmd/tpm/src/X509/TpmASN1.c \ + tpm2/TPMCmd/tpm/src/X509/X509_ECC.c \ + tpm2/TPMCmd/tpm/src/X509/X509_RSA.c \ + tpm2/TPMCmd/tpm/src/X509/X509_spt.c \ + tpm2/TPMCmd/TpmConfiguration/TpmVendorCommandHandlers/Vendor_TCG_Test.c \ tpm2/Unmarshal.c \ - tpm2/VendorInfo.c \ - tpm2/Vendor_TCG_Test.c \ - tpm2/X509_ECC.c \ - tpm2/X509_RSA.c \ - tpm2/X509_spt.c \ + \ tpm_tpm2_interface.c \ tpm_tpm2_tis.c \ \ @@ -304,271 +331,278 @@ libtpms_tpm2_la_SOURCES = \ noinst_HEADERS += \ compiler.h \ - tpm2/crypto/CryptCmac_fp.h \ - tpm2/crypto/CryptDes_fp.h \ - tpm2/crypto/CryptEcc.h \ - tpm2/crypto/CryptEccCrypt_fp.h \ - tpm2/crypto/CryptEccKeyExchange_fp.h \ - tpm2/crypto/CryptEccMain_fp.h \ - tpm2/crypto/CryptEccSignature_fp.h \ - tpm2/crypto/CryptHash_fp.h \ - tpm2/crypto/CryptHash.h \ - tpm2/crypto/CryptPrime_fp.h \ - tpm2/crypto/CryptPrimeSieve_fp.h \ - tpm2/crypto/CryptRand_fp.h \ - tpm2/crypto/CryptRand.h \ - tpm2/crypto/CryptRsa_fp.h \ - tpm2/crypto/CryptRsa.h \ - tpm2/crypto/CryptSelfTest_fp.h \ - tpm2/crypto/CryptSmac_fp.h \ - tpm2/crypto/CryptSym.h \ - tpm2/crypto/CryptSym_fp.h \ - tpm2/crypto/CryptTest.h \ - tpm2/crypto/CryptUtil_fp.h \ - tpm2/crypto/ECC_Decrypt_fp.h \ - tpm2/crypto/ECC_Encrypt_fp.h \ - tpm2/ACT.h \ - tpm2/ACT_spt_fp.h \ - tpm2/ACT_SetTimeout_fp.h \ - tpm2/ActivateCredential_fp.h \ - tpm2/AlgorithmCap_fp.h \ - tpm2/AlgorithmTests_fp.h \ - tpm2/Attest_spt_fp.h \ - tpm2/BaseTypes.h \ - tpm2/Bits_fp.h \ - tpm2/BnEccConstants.c \ - tpm2/BnSupport_Interface.h \ - tpm2/BnUtil_fp.h \ - tpm2/Capabilities.h \ - tpm2/CertifyCreation_fp.h \ - tpm2/CertifyX509_fp.h \ - tpm2/Certify_fp.h \ - tpm2/ChangeEPS_fp.h \ - tpm2/ChangePPS_fp.h \ - tpm2/ClearControl_fp.h \ - tpm2/Clear_fp.h \ - tpm2/ClockRateAdjust_fp.h \ - tpm2/ClockSet_fp.h \ - tpm2/CommandAttributeData.h \ - tpm2/CommandAttributes.h \ - tpm2/CommandAudit_fp.h \ - tpm2/CommandCodeAttributes_fp.h \ - tpm2/CommandDispatchData.h \ - tpm2/CommandDispatcher_fp.h \ - tpm2/Commit_fp.h \ - tpm2/CompilerDependencies.h \ - tpm2/CompilerDependencies_gcc.h \ - tpm2/CompilerDependencies_msvc.h \ - tpm2/ContextLoad_fp.h \ - tpm2/ContextSave_fp.h \ - tpm2/Context_spt_fp.h \ - tpm2/Create_fp.h \ - tpm2/CreateLoaded_fp.h \ - tpm2/CreatePrimary_fp.h \ - tpm2/CryptoInterface.h \ - tpm2/CryptSelfTest_fp.h \ - tpm2/DA_fp.h \ - tpm2/DebugHelpers_fp.h \ - tpm2/DictionaryAttackLockReset_fp.h \ - tpm2/DictionaryAttackParameters_fp.h \ - tpm2/Duplicate_fp.h \ - tpm2/EccConstantData.inl \ - tpm2/EccTestData.h \ - tpm2/ECC_Parameters_fp.h \ - tpm2/ECDH_KeyGen_fp.h \ - tpm2/ECDH_ZGen_fp.h \ - tpm2/EC_Ephemeral_fp.h \ - tpm2/EncryptDecrypt2_fp.h \ - tpm2/EncryptDecrypt_fp.h \ - tpm2/EncryptDecrypt_spt_fp.h \ - tpm2/endian_swap.h \ - tpm2/Entity_fp.h \ - tpm2/EventSequenceComplete_fp.h \ - tpm2/EvictControl_fp.h \ - tpm2/ExecCommand_fp.h \ - tpm2/FlushContext_fp.h \ - tpm2/GetCapability_fp.h \ - tpm2/GetCommandAuditDigest_fp.h \ - tpm2/GetRandom_fp.h \ - tpm2/GetSessionAuditDigest_fp.h \ - tpm2/GetTestResult_fp.h \ - tpm2/GetTime_fp.h \ - tpm2/Global.h \ - tpm2/GpMacros.h \ - tpm2/Handle_fp.h \ - tpm2/Hash_fp.h \ - tpm2/HashSequenceStart_fp.h \ - tpm2/HashTestData.h \ - tpm2/HierarchyChangeAuth_fp.h \ - tpm2/HierarchyControl_fp.h \ - tpm2/Hierarchy_fp.h \ - tpm2/HMAC_fp.h \ - tpm2/HMAC_Start_fp.h \ - tpm2/Import_fp.h \ - tpm2/IncrementalSelfTest_fp.h \ - tpm2/InternalRoutines.h \ - tpm2/IoBuffers_fp.h \ - tpm2/KdfTestData.h \ - tpm2/LoadExternal_fp.h \ - tpm2/Load_fp.h \ - tpm2/Locality_fp.h \ - tpm2/MAC_fp.h \ - tpm2/MAC_Start_fp.h \ - tpm2/MakeCredential_fp.h \ - tpm2/Manufacture_fp.h \ - tpm2/Marshal.h \ - tpm2/Marshal_fp.h \ - tpm2/MathLibraryInterface.h \ - tpm2/MathLibraryInterfaceTypes.h \ - tpm2/MathOnByteBuffers_fp.h \ - tpm2/Memory_fp.h \ - tpm2/MinMax.h \ - tpm2/NV_Certify_fp.h \ - tpm2/NV_ChangeAuth_fp.h \ - tpm2/NV_DefineSpace_fp.h \ - tpm2/NV_DefineSpace2_fp.h \ - tpm2/NvDynamic_fp.h \ - tpm2/NV_Extend_fp.h \ - tpm2/NV_GlobalWriteLock_fp.h \ - tpm2/NV.h \ - tpm2/NV_Increment_fp.h \ - tpm2/NV_Read_fp.h \ - tpm2/NV_ReadLock_fp.h \ - tpm2/NV_ReadPublic_fp.h \ - tpm2/NV_ReadPublic2_fp.h \ - tpm2/NvReserved_fp.h \ - tpm2/NV_SetBits_fp.h \ - tpm2/NV_spt_fp.h \ - tpm2/NV_UndefineSpace_fp.h \ - tpm2/NV_UndefineSpaceSpecial_fp.h \ - tpm2/NV_Write_fp.h \ - tpm2/NV_WriteLock_fp.h \ - tpm2/OIDs.h \ - tpm2/ObjectChangeAuth_fp.h \ - tpm2/Object_fp.h \ - tpm2/Object_spt_fp.h \ - tpm2/pcrstruct.h \ - tpm2/PCR_Allocate_fp.h \ - tpm2/PCR_Event_fp.h \ - tpm2/PCR_Extend_fp.h \ - tpm2/PCR_fp.h \ - tpm2/PCR_Read_fp.h \ - tpm2/PCR_Reset_fp.h \ - tpm2/PCR_SetAuthPolicy_fp.h \ - tpm2/PCR_SetAuthValue_fp.h \ - tpm2/Platform.h \ - tpm2/PlatformACT.h \ - tpm2/PlatformACT_fp.h \ - tpm2/PlatformClock.h \ - tpm2/PlatformData.h \ - tpm2/platform_public_interface.h \ - tpm2/platform_pcr_fp.h \ - tpm2/platform_to_tpm_interface.h \ - tpm2/Platform_fp.h \ - tpm2/PolicyAuthorize_fp.h \ - tpm2/PolicyAuthorizeNV_fp.h \ - tpm2/PolicyAuthValue_fp.h \ - tpm2/PolicyCapability_fp.h \ - tpm2/PolicyCommandCode_fp.h \ - tpm2/PolicyCounterTimer_fp.h \ - tpm2/PolicyCpHash_fp.h \ - tpm2/PolicyDuplicationSelect_fp.h \ - tpm2/PolicyGetDigest_fp.h \ - tpm2/PolicyLocality_fp.h \ - tpm2/PolicyNameHash_fp.h \ - tpm2/PolicyNV_fp.h \ - tpm2/PolicyNvWritten_fp.h \ - tpm2/PolicyOR_fp.h \ - tpm2/PolicyParameters_fp.h \ - tpm2/PolicyPassword_fp.h \ - tpm2/PolicyPCR_fp.h \ - tpm2/PolicyPhysicalPresence_fp.h \ - tpm2/PolicyRestart_fp.h \ - tpm2/PolicySecret_fp.h \ - tpm2/PolicySigned_fp.h \ - tpm2/Policy_spt_fp.h \ - tpm2/PolicyTemplate_fp.h \ - tpm2/PolicyTicket_fp.h \ - tpm2/Power_fp.h \ - tpm2/PP_Commands_fp.h \ - tpm2/PP_fp.h \ - tpm2/PRNG_TestVectors.h \ - tpm2/PropertyCap_fp.h \ - tpm2/Quote_fp.h \ - tpm2/ReadClock_fp.h \ - tpm2/ReadPublic_fp.h \ - tpm2/ResponseCodeProcessing_fp.h \ - tpm2/Response_fp.h \ - tpm2/Rewrap_fp.h \ - tpm2/RsaTestData.h \ - tpm2/RSA_Decrypt_fp.h \ - tpm2/RSA_Encrypt_fp.h \ - tpm2/SelfTest.h \ - tpm2/SelfTest_fp.h \ - tpm2/SequenceComplete_fp.h \ - tpm2/SequenceUpdate_fp.h \ - tpm2/Session_fp.h \ - tpm2/SessionProcess_fp.h \ - tpm2/SetAlgorithmSet_fp.h \ - tpm2/SetCapability_fp.h \ - tpm2/SetCommandCodeAuditStatus_fp.h \ - tpm2/SetPrimaryPolicy_fp.h \ - tpm2/Shutdown_fp.h \ - tpm2/Sign_fp.h \ - tpm2/simulatorPrivate.h \ - tpm2/simulator_sysheaders.h \ - tpm2/Simulator_fp.h \ - tpm2/StartAuthSession_fp.h \ - tpm2/Startup_fp.h \ - tpm2/StirRandom_fp.h \ - tpm2/SymmetricTest.h \ - tpm2/SymmetricTestData.h \ - tpm2/TcpServerPosix_fp.h \ - tpm2/TestParms_fp.h \ - tpm2/Ticket_fp.h \ - tpm2/Time_fp.h \ - tpm2/TPMB.h \ - tpm2/TpmAlgorithmDefines.h \ - tpm2/TpmASN1.h \ - tpm2/TpmASN1_fp.h \ - tpm2/TpmBuildSwitches.h \ - tpm2/TpmEcc_Signature_ECDAA_fp.h \ - tpm2/TpmEcc_Signature_ECDSA_fp.h \ - tpm2/TpmEcc_Signature_Schnorr_fp.h \ - tpm2/TpmEcc_Signature_SM2_fp.h \ - tpm2/TpmEcc_Signature_Util_fp.h \ - tpm2/TpmFail_fp.h \ - tpm2/TpmMath_Debug_fp.h \ - tpm2/TpmMath_Util_fp.h \ - tpm2/TpmProfile.h \ - tpm2/TpmProfile_CommandList.h \ - tpm2/TpmProfile_Common.h \ - tpm2/TpmProfile_ErrorCodes.h \ - tpm2/TpmProfile_Misc.h \ - tpm2/Tpm.h \ - tpm2/TpmBigNum.h \ - tpm2/tpm_public.h \ - tpm2/tpm_to_platform_interface.h \ - tpm2/_TPM_Hash_Data_fp.h \ - tpm2/_TPM_Hash_End_fp.h \ - tpm2/_TPM_Hash_Start_fp.h \ - tpm2/_TPM_Init_fp.h \ - tpm2/TpmCalculatedAttributes.h \ - tpm2/TpmEcc_Util_fp.h \ - tpm2/TpmSizeChecks_fp.h \ - tpm2/TpmTcpProtocol.h \ - tpm2/TpmTypes.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/CryptCmac_fp.h \ + tpm2/CryptDes_fp.h \ + tpm2/TPMCmd/Platform/include/PlatformACT.h \ + tpm2/TPMCmd/Platform/include/PlatformClock.h \ + tpm2/TPMCmd/Platform/include/PlatformData.h \ + tpm2/TPMCmd/Platform/include/Platform.h \ + tpm2/TPMCmd/Platform/include/PlatformInternal.h \ + tpm2/TPMCmd/Platform/include/prototypes/platform_public_interface.h \ + tpm2/TPMCmd/Simulator/include/prototypes/Simulator_fp.h \ + tpm2/TPMCmd/Simulator/include/TpmTcpProtocol.h \ + tpm2/TPMCmd/Simulator/src/simulatorPrivate.h \ + tpm2/TPMCmd/Simulator/src/simulator_sysheaders.h \ + tpm2/TPMCmd/TpmConfiguration/TpmConfiguration/TpmBuildSwitches.h \ + tpm2/TPMCmd/TpmConfiguration/TpmConfiguration/TpmProfile_CommandList.h \ + tpm2/TPMCmd/TpmConfiguration/TpmConfiguration/TpmProfile_Common.h \ + tpm2/TPMCmd/TpmConfiguration/TpmConfiguration/TpmProfile_ErrorCodes.h \ + tpm2/TPMCmd/TpmConfiguration/TpmConfiguration/TpmProfile.h \ + tpm2/TPMCmd/TpmConfiguration/TpmConfiguration/TpmProfile_Misc.h \ + tpm2/TPMCmd/TpmConfiguration/TpmConfiguration/VendorCommands/CommandAttributeData_s_ccAttr.inl \ + tpm2/TPMCmd/TpmConfiguration/TpmConfiguration/VendorCommands/CommandAttributeData_s_commandAttributes.inl \ + tpm2/TPMCmd/TpmConfiguration/TpmConfiguration/VendorCommands/CommandDispatchData_CommandStructures.inl \ + tpm2/TPMCmd/TpmConfiguration/TpmConfiguration/VendorCommands/CommandDispatchData_s_CommandDataArray.inl \ + tpm2/TPMCmd/TpmConfiguration/TpmConfiguration/VendorCommands/prototypes/Vendor_TCG_Test_fp.h \ + tpm2/TPMCmd/TpmConfiguration/TpmConfiguration/VendorCommands/VendorCommandList.h \ + tpm2/TPMCmd/tpm/cryptolibs/common/include/CryptoInterface.h \ + tpm2/TPMCmd/tpm/cryptolibs/common/include/EccConstantData.inl \ + tpm2/TPMCmd/tpm/cryptolibs/common/include/MathLibraryInterface.h \ + tpm2/TPMCmd/tpm/cryptolibs/common/include/MathLibraryInterfaceTypes.h \ + tpm2/TPMCmd/tpm/cryptolibs/TpmBigNum/BnEccConstants.c \ + tpm2/TPMCmd/tpm/cryptolibs/TpmBigNum/include/BnSupport_Interface.h \ + tpm2/TPMCmd/tpm/cryptolibs/TpmBigNum/include/BnUtil_fp.h \ + tpm2/TPMCmd/tpm/cryptolibs/TpmBigNum/TpmBigNum.h \ + tpm2/TPMCmd/tpm/include/platform_interface/pcrstruct.h \ + tpm2/TPMCmd/tpm/include/platform_interface/platform_to_tpm_interface.h \ + tpm2/TPMCmd/tpm/include/platform_interface/prototypes/ExecCommand_fp.h \ + tpm2/TPMCmd/tpm/include/platform_interface/prototypes/Manufacture_fp.h \ + tpm2/TPMCmd/tpm/include/platform_interface/prototypes/platform_failure_mode_fp.h \ + tpm2/TPMCmd/tpm/include/platform_interface/prototypes/platform_init_fp.h \ + tpm2/TPMCmd/tpm/include/platform_interface/prototypes/platform_pcr_fp.h \ + tpm2/TPMCmd/tpm/include/platform_interface/prototypes/platform_virtual_nv_fp.h \ + tpm2/TPMCmd/tpm/include/platform_interface/prototypes/_TPM_Hash_Data_fp.h \ + tpm2/TPMCmd/tpm/include/platform_interface/prototypes/_TPM_Hash_End_fp.h \ + tpm2/TPMCmd/tpm/include/platform_interface/prototypes/_TPM_Hash_Start_fp.h \ + tpm2/TPMCmd/tpm/include/platform_interface/prototypes/_TPM_Init_fp.h \ + tpm2/TPMCmd/tpm/include/platform_interface/tpm_to_platform_interface.h \ + tpm2/TPMCmd/tpm/include/private/CommandAttributeData.h \ + tpm2/TPMCmd/tpm/include/private/CommandAttributes.h \ + tpm2/TPMCmd/tpm/include/private/CommandDispatchData.h \ + tpm2/TPMCmd/tpm/include/private/CryptEcc.h \ + tpm2/TPMCmd/tpm/include/private/CryptHash.h \ + tpm2/TPMCmd/tpm/include/private/CryptRand.h \ + tpm2/TPMCmd/tpm/include/private/CryptRsa.h \ + tpm2/TPMCmd/tpm/include/private/CryptSym.h \ + tpm2/TPMCmd/tpm/include/private/CryptTest.h \ + tpm2/TPMCmd/tpm/include/private/EccTestData.h \ + tpm2/TPMCmd/tpm/include/private/Global.h \ + tpm2/TPMCmd/tpm/include/private/HashTestData.h \ + tpm2/TPMCmd/tpm/include/private/InternalRoutines.h \ + tpm2/TPMCmd/tpm/include/private/KdfTestData.h \ + tpm2/TPMCmd/tpm/include/private/Marshal.h \ + tpm2/TPMCmd/tpm/include/private/NV.h \ + tpm2/TPMCmd/tpm/include/private/OIDs.h \ + tpm2/TPMCmd/tpm/include/private/PRNG_TestVectors.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/ActivateCredential_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/ACT_SetTimeout_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/ACT_spt_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/AlgorithmCap_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/AlgorithmTests_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/Attest_spt_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/Bits_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/CertifyCreation_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/Certify_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/CertifyX509_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/ChangeEPS_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/ChangePPS_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/ClearControl_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/Clear_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/ClockRateAdjust_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/ClockSet_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/CommandAudit_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/CommandCodeAttributes_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/CommandDispatcher_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/Commit_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/ContextLoad_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/ContextSave_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/Context_spt_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/Create_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/CreateLoaded_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/CreatePrimary_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/CryptEccCrypt_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/CryptEccKeyExchange_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/CryptEccMain_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/CryptEccSignature_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/CryptHash_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/CryptPrime_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/CryptPrimeSieve_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/CryptRand_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/CryptRsa_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/CryptSelfTest_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/CryptSmac_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/CryptSym_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/CryptUtil_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/DA_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/DictionaryAttackLockReset_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/DictionaryAttackParameters_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/ECC_Decrypt_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/ECC_Encrypt_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/Duplicate_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/ECC_Parameters_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/ECDH_KeyGen_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/ECDH_ZGen_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/EC_Ephemeral_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/EncryptDecrypt2_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/EncryptDecrypt_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/EncryptDecrypt_spt_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/Entity_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/EventSequenceComplete_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/EvictControl_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/FlushContext_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/GetCapability_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/GetCommandAuditDigest_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/GetRandom_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/GetSessionAuditDigest_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/GetTestResult_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/GetTime_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/Handle_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/Hash_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/HashSequenceStart_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/HierarchyChangeAuth_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/HierarchyControl_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/Hierarchy_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/HMAC_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/HMAC_Start_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/Import_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/IncrementalSelfTest_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/IoBuffers_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/LoadExternal_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/Load_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/Locality_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/MAC_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/MAC_Start_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/MakeCredential_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/Marshal_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/MathOnByteBuffers_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/Memory_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/NV_Certify_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/NV_ChangeAuth_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/NV_DefineSpace2_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/NV_DefineSpace_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/NvDynamic_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/NV_Extend_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/NV_GlobalWriteLock_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/NV_Increment_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/NV_Read_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/NV_ReadLock_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/NV_ReadPublic2_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/NV_ReadPublic_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/NvReserved_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/NV_SetBits_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/NV_spt_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/NV_UndefineSpace_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/NV_UndefineSpaceSpecial_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/NV_Write_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/NV_WriteLock_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/ObjectChangeAuth_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/Object_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/Object_spt_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/PCR_Allocate_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/PCR_Event_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/PCR_Extend_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/PCR_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/PCR_Read_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/PCR_Reset_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/PCR_SetAuthPolicy_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/PCR_SetAuthValue_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/PolicyAuthorize_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/PolicyAuthorizeNV_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/PolicyAuthValue_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/PolicyCapability_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/PolicyCommandCode_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/PolicyCounterTimer_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/PolicyCpHash_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/PolicyDuplicationSelect_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/PolicyGetDigest_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/PolicyLocality_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/PolicyNameHash_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/PolicyNV_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/PolicyNvWritten_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/PolicyOR_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/PolicyParameters_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/PolicyPassword_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/PolicyPCR_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/PolicyPhysicalPresence_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/PolicyRestart_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/PolicySecret_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/PolicySigned_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/Policy_spt_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/PolicyTemplate_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/PolicyTicket_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/PolicyTransportSPDM_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/Power_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/PP_Commands_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/PP_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/PropertyCap_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/Quote_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/ReadClock_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/ReadOnlyControl_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/ReadPublic_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/ResponseCodeProcessing_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/Response_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/Rewrap_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/RSA_Decrypt_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/RSA_Encrypt_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/SecChannel_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/SelfTest_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/SequenceComplete_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/SequenceUpdate_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/Session_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/SessionProcess_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/SetAlgorithmSet_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/SetCapability_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/SetCommandCodeAuditStatus_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/SetPrimaryPolicy_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/Shutdown_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/Sign_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/StartAuthSession_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/Startup_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/StirRandom_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/TestParms_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/Ticket_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/Time_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/TpmASN1_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/TpmEcc_Signature_ECDAA_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/TpmEcc_Signature_ECDSA_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/TpmEcc_Signature_Schnorr_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/TpmEcc_Signature_SM2_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/TpmEcc_Signature_Util_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/TpmEcc_Util_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/TpmMath_Debug_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/TpmMath_Util_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/TpmSizeChecks_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/Unseal_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/VerifySignature_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/X509_ECC_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/X509_RSA_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/X509_spt_fp.h \ + tpm2/TPMCmd/tpm/include/private/prototypes/ZGen_2Phase_fp.h \ + tpm2/TPMCmd/tpm/include/private/RsaTestData.h \ + tpm2/TPMCmd/tpm/include/private/SelfTest.h \ + tpm2/TPMCmd/tpm/include/private/SymmetricTestData.h \ + tpm2/TPMCmd/tpm/include/private/SymmetricTest.h \ + tpm2/TPMCmd/tpm/include/private/TpmASN1.h \ + tpm2/TPMCmd/tpm/include/private/Tpm.h \ + tpm2/TPMCmd/tpm/include/private/X509.h \ + tpm2/TPMCmd/tpm/include/tpm_public/ACT.h \ + tpm2/TPMCmd/tpm/include/tpm_public/BaseTypes.h \ + tpm2/TPMCmd/tpm/include/tpm_public/Capabilities.h \ + tpm2/TPMCmd/tpm/include/tpm_public/CompilerDependencies_gcc.h \ + tpm2/TPMCmd/tpm/include/tpm_public/CompilerDependencies.h \ + tpm2/TPMCmd/tpm/include/tpm_public/CompilerDependencies_msvc.h \ + tpm2/TPMCmd/tpm/include/tpm_public/endian_swap.h \ + tpm2/TPMCmd/tpm/include/tpm_public/GpMacros.h \ + tpm2/TPMCmd/tpm/include/tpm_public/MinMax.h \ + tpm2/TPMCmd/tpm/include/tpm_public/prototypes/TpmFail_fp.h \ + tpm2/TPMCmd/tpm/include/tpm_public/TpmAlgorithmDefines.h \ + tpm2/TPMCmd/tpm/include/tpm_public/TPMB.h \ + tpm2/TPMCmd/tpm/include/tpm_public/TpmCalculatedAttributes.h \ + tpm2/TPMCmd/tpm/include/tpm_public/tpm_debug.h \ + tpm2/TPMCmd/tpm/include/tpm_public/tpm_public.h \ + tpm2/TPMCmd/tpm/include/tpm_public/TpmTypes.h \ + tpm2/TPMCmd/tpm/include/tpm_public/VerifyConfiguration.h \ tpm2/Unmarshal_fp.h \ - tpm2/Unseal_fp.h \ - tpm2/VendorInfo.h \ - tpm2/Vendor_TCG_Test_fp.h \ - tpm2/VerifyConfiguration.h \ - tpm2/VerifySignature_fp.h \ - tpm2/X509.h \ - tpm2/X509_ECC_fp.h \ - tpm2/X509_RSA_fp.h \ - tpm2/X509_spt_fp.h \ - tpm2/ZGen_2Phase_fp.h \ \ tpm2/BackwardsCompatibility.h \ tpm2/BackwardsCompatibilityBitArray.h \ @@ -586,49 +620,61 @@ noinst_HEADERS += \ if LIBTPMS_USE_OPENSSL libtpms_tpm2_la_SOURCES += \ - tpm2/crypto/openssl/BnToOsslMath.c \ - tpm2/crypto/openssl/CryptCmac.c \ - tpm2/crypto/openssl/CryptDes.c \ - tpm2/crypto/openssl/CryptEccCrypt.c \ - tpm2/crypto/openssl/CryptEccKeyExchange.c \ - tpm2/crypto/openssl/CryptEccMain.c \ - tpm2/crypto/openssl/CryptEccSignature.c \ - tpm2/crypto/openssl/CryptHash.c \ - tpm2/crypto/openssl/CryptPrime.c \ - tpm2/crypto/openssl/CryptPrimeSieve.c \ - tpm2/crypto/openssl/CryptRand.c \ - tpm2/crypto/openssl/CryptRsa.c \ - tpm2/crypto/openssl/CryptSmac.c \ - tpm2/crypto/openssl/CryptSym.c \ - tpm2/crypto/openssl/ExpDCache.c \ - tpm2/crypto/openssl/Helpers.c \ - tpm2/crypto/openssl/TpmToOsslDesSupport.c \ - tpm2/crypto/openssl/TpmToOsslSupport.c + tpm2/TPMCmd/tpm/cryptolibs/Ossl/BnToOsslMath.c \ + tpm2/TPMCmd/tpm/src/crypt/CryptCmac.c \ + tpm2/TPMCmd/tpm/src/crypt/CryptDes.c \ + tpm2/TPMCmd/tpm/src/crypt/CryptEccCrypt.c \ + tpm2/TPMCmd/tpm/src/crypt/CryptEccKeyExchange.c \ + tpm2/TPMCmd/tpm/src/crypt/CryptEccMain.c \ + tpm2/TPMCmd/tpm/src/crypt/CryptEccSignature.c \ + tpm2/TPMCmd/tpm/src/crypt/CryptHash.c \ + tpm2/TPMCmd/tpm/src/crypt/CryptPrime.c \ + tpm2/TPMCmd/tpm/src/crypt/CryptPrimeSieve.c \ + tpm2/TPMCmd/tpm/src/crypt/CryptRand.c \ + tpm2/TPMCmd/tpm/src/crypt/CryptRsa.c \ + tpm2/TPMCmd/tpm/src/crypt/CryptSmac.c \ + tpm2/TPMCmd/tpm/src/crypt/CryptSym.c \ + tpm2/TPMCmd/tpm/cryptolibs/Ossl/ExpDCache.c \ + tpm2/TPMCmd/tpm/cryptolibs/Ossl/Helpers.c \ + tpm2/TPMCmd/tpm/cryptolibs/Ossl/TpmToOsslDesSupport.c \ + tpm2/TPMCmd/tpm/cryptolibs/Ossl/TpmToOsslSupport.c noinst_HEADERS += \ - tpm2/crypto/openssl/BnOssl.h \ - tpm2/crypto/openssl/BnToOsslMath_fp.h \ - tpm2/crypto/openssl/BnToOsslMath.h \ - tpm2/crypto/openssl/ConsttimeUtils.h \ - tpm2/crypto/openssl/BnConvert_fp.h \ - tpm2/crypto/openssl/BnMath_fp.h \ - tpm2/crypto/openssl/BnMemory_fp.h \ - tpm2/crypto/openssl/BnValues.h \ - tpm2/crypto/openssl/ExpDCache_fp.h \ - tpm2/crypto/openssl/Helpers_fp.h \ - tpm2/crypto/openssl/LibSupport.h \ - tpm2/crypto/openssl/TpmToTpmBigNumMath.h \ - tpm2/crypto/openssl/TpmToOsslDesSupport_fp.h \ - tpm2/crypto/openssl/TpmToOsslHash.h \ - tpm2/crypto/openssl/TpmToOsslSupport_fp.h \ - tpm2/crypto/openssl/TpmToOsslSym.h \ - tpm2/crypto/openssl/tpm_radix.h + tpm2/TPMCmd/tpm/cryptolibs/Ossl/include/BnOssl.h \ + tpm2/TPMCmd/tpm/cryptolibs/Ossl/include/Ossl/BnToOsslMath_fp.h \ + tpm2/TPMCmd/tpm/cryptolibs/TpmBigNum/include/BnConvert_fp.h \ + tpm2/TPMCmd/tpm/cryptolibs/TpmBigNum/include/BnMath_fp.h \ + tpm2/TPMCmd/tpm/cryptolibs/TpmBigNum/include/BnMemory_fp.h \ + tpm2/TPMCmd/tpm/cryptolibs/TpmBigNum/include/BnValues.h \ + tpm2/TPMCmd/tpm/cryptolibs/Ossl/include/Ossl/BnToOsslMath.h \ + tpm2/TPMCmd/tpm/cryptolibs/Ossl/include/Ossl/ExpDCache_fp.h \ + tpm2/TPMCmd/tpm/cryptolibs/Ossl/include/Ossl/Helpers_fp.h \ + tpm2/TPMCmd/tpm/cryptolibs/Ossl/include/Ossl/TpmToOsslDesSupport_fp.h \ + tpm2/TPMCmd/tpm/cryptolibs/Ossl/include/Ossl/TpmToOsslHash.h \ + tpm2/TPMCmd/tpm/cryptolibs/Ossl/include/Ossl/TpmToOsslSupport_fp.h \ + tpm2/TPMCmd/tpm/cryptolibs/Ossl/include/Ossl/TpmToOsslSym.h \ + tpm2/TPMCmd/tpm/cryptolibs/Ossl/include/Ossl/TpmToOsslSymTDES.h \ + tpm2/TPMCmd/tpm/cryptolibs/TpmBigNum/include/TpmBigNum/TpmToTpmBigNumMath.h \ + tpm2/TPMCmd/tpm/include/private/LibSupport.h \ + tpm2/TPMCmd/tpm/include/tpm_public/tpm_radix.h libtpms_tpm2_la_CFLAGS += \ -I $(srcdir)/tpm2 \ - -I $(srcdir)/tpm2/crypto \ - -I $(srcdir)/tpm2/crypto/openssl - + -I $(srcdir)/tpm2/crypto/openssl \ + -I $(srcdir)/tpm2/TPMCmd/Platform/include/ \ + -I $(srcdir)/tpm2/TPMCmd/Simulator/include/ \ + -I $(srcdir)/tpm2/TPMCmd/Simulator/include/prototypes \ + -I $(srcdir)/tpm2/TPMCmd/TpmConfiguration \ + -I $(srcdir)/tpm2/TPMCmd/tpm/include/ \ + -I $(srcdir)/tpm2/TPMCmd/tpm/include/private \ + -I $(srcdir)/tpm2/TPMCmd/tpm/include/private/prototypes/ \ + -I $(srcdir)/tpm2/TPMCmd/tpm/cryptolibs/common/include/ \ + -I $(srcdir)/tpm2/TPMCmd/tpm/cryptolibs/TpmBigNum/include/ \ + -I $(srcdir)/tpm2/TPMCmd/tpm/cryptolibs/TpmBigNum/include/TpmBigNum/ \ + -I $(srcdir)/tpm2/TPMCmd/tpm/cryptolibs/ \ + -I $(srcdir)/tpm2/TPMCmd/tpm/cryptolibs/Ossl/ \ + -I $(srcdir)/tpm2/TPMCmd/tpm/cryptolibs/Ossl/include \ + -I $(srcdir)/tpm2/TPMCmd/tpm/cryptolibs/Ossl/include/Ossl/ libtpms_tpm2_la_LIBADD += -lcrypto diff --git a/src/tpm2/ACT_SetTimeout_fp.h b/src/tpm2/ACT_SetTimeout_fp.h deleted file mode 100644 index af84262fb..000000000 --- a/src/tpm2/ACT_SetTimeout_fp.h +++ /dev/null @@ -1,86 +0,0 @@ -/********************************************************************************/ -/* */ -/* TPM2_ACT_SetTimeout Header */ -/* 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 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_ACT_SetTimeout // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_ACT_SETTIMEOUT_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_ACT_SETTIMEOUT_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_RH_ACT actHandle; - UINT32 startTimeout; -} ACT_SetTimeout_In; - -// Response code modifiers -# define RC_ACT_SetTimeout_actHandle (TPM_RC_H + TPM_RC_1) -# define RC_ACT_SetTimeout_startTimeout (TPM_RC_P + TPM_RC_1) - -// Function prototype -TPM_RC -TPM2_ACT_SetTimeout(ACT_SetTimeout_In* in); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_ACT_SETTIMEOUT_FP_H_ -#endif // CC_ACT_SetTimeout diff --git a/src/tpm2/ACT_spt_fp.h b/src/tpm2/ACT_spt_fp.h deleted file mode 100644 index 368bb4cd3..000000000 --- a/src/tpm2/ACT_spt_fp.h +++ /dev/null @@ -1,112 +0,0 @@ -/********************************************************************************/ -/* */ -/* ACT Command Support */ -/* 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 - 2023 */ -/* */ -/********************************************************************************/ - -/*(Auto-generated) - * Created by TpmPrototypes 1.00 - * Date: Oct 24, 2019 Time: 10:38:43AM - */ - -#ifndef _ACT_SPT_FP_H_ -#define _ACT_SPT_FP_H_ - -//*** ActStartup() -// This function is called by TPM2_Startup() to initialize the ACT counter values. -BOOL ActStartup(STARTUP_TYPE type); - -//*** ActGetSignaled() -// This function returns the state of the signaled flag associated with an ACT. -BOOL ActGetSignaled(TPM_RH actHandle); - -//***ActShutdown() -// This function saves the current state of the counters -BOOL ActShutdown(TPM_SU state //IN: the type of the shutdown. -); - -//*** ActIsImplemented() -// This function determines if an ACT is implemented in both the TPM and the platform -// code. -BOOL ActIsImplemented(UINT32 act); - -//***ActCounterUpdate() -// This function updates the ACT counter. If the counter already has a pending update, -// it returns TPM_RC_RETRY so that the update can be tried again later. -TPM_RC -ActCounterUpdate(TPM_RH handle, //IN: the handle of the act - UINT32 newValue //IN: the value to set in the ACT -); - -//*** ActGetCapabilityData() -// This function returns the list of ACT data -// Return Type: TPMI_YES_NO -// YES if more ACT data is available -// NO if no more ACT data to -TPMI_YES_NO -ActGetCapabilityData(TPM_HANDLE actHandle, // IN: the handle for the starting ACT - UINT32 maxCount, // IN: maximum allowed return values - TPML_ACT_DATA* actList // OUT: ACT data list -); - -//*** ActGetOneCapability() -// This function returns an ACT's capability, if present. -BOOL ActGetOneCapability(TPM_HANDLE actHandle, // IN: the handle for the ACT - TPMS_ACT_DATA* actData // OUT: ACT data -); - -#endif // _ACT_SPT_FP_H_ diff --git a/src/tpm2/ActivateCredential_fp.h b/src/tpm2/ActivateCredential_fp.h deleted file mode 100644 index 0083e2e72..000000000 --- a/src/tpm2/ActivateCredential_fp.h +++ /dev/null @@ -1,96 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: ActivateCredential_fp.h 809 2016-11-16 18:31:54Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_ActivateCredential // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_ACTIVATECREDENTIAL_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_ACTIVATECREDENTIAL_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_DH_OBJECT activateHandle; - TPMI_DH_OBJECT keyHandle; - TPM2B_ID_OBJECT credentialBlob; - TPM2B_ENCRYPTED_SECRET secret; -} ActivateCredential_In; - -// Output structure definition -typedef struct -{ - TPM2B_DIGEST certInfo; -} ActivateCredential_Out; - -// Response code modifiers -# define RC_ActivateCredential_activateHandle (TPM_RC_H + TPM_RC_1) -# define RC_ActivateCredential_keyHandle (TPM_RC_H + TPM_RC_2) -# define RC_ActivateCredential_credentialBlob (TPM_RC_P + TPM_RC_1) -# define RC_ActivateCredential_secret (TPM_RC_P + TPM_RC_2) - -// Function prototype -TPM_RC -TPM2_ActivateCredential(ActivateCredential_In* in, ActivateCredential_Out* out); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_ACTIVATECREDENTIAL_FP_H_ -#endif // CC_ActivateCredential diff --git a/src/tpm2/AlgorithmCap_fp.h b/src/tpm2/AlgorithmCap_fp.h deleted file mode 100644 index b37ad4a0a..000000000 --- a/src/tpm2/AlgorithmCap_fp.h +++ /dev/null @@ -1,97 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* 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 */ -/* */ -/********************************************************************************/ - -/*(Auto-generated) - * Created by TpmPrototypes; Version 3.0 July 18, 2017 - * Date: Mar 28, 2019 Time: 08:25:19PM - */ - -#ifndef _ALGORITHM_CAP_FP_H_ -#define _ALGORITHM_CAP_FP_H_ - -//** AlgorithmCapGetImplemented() -// This function is used by TPM2_GetCapability() to return a list of the -// implemented algorithms. -// -// Return Type: TPMI_YES_NO -// YES more algorithms to report -// NO no more algorithms to report -TPMI_YES_NO -AlgorithmCapGetImplemented(TPM_ALG_ID algID, // IN: the starting algorithm ID - UINT32 count, // IN: count of returned algorithms - TPML_ALG_PROPERTY* algList // OUT: algorithm list -); - -//** AlgorithmCapGetOneImplemented() -// This function returns whether a single algorithm was implemented, along -// with its properties (if implemented). -BOOL AlgorithmCapGetOneImplemented( - TPM_ALG_ID algID, // IN: the algorithm ID - TPMS_ALG_PROPERTY* algProperty // OUT: algorithm properties -); - -//** AlgorithmGetImplementedVector() -// This function returns the bit vector of the implemented algorithms. -LIB_EXPORT -void AlgorithmGetImplementedVector( - ALGORITHM_VECTOR* implemented // OUT: the implemented bits are SET -); - -#endif // _ALGORITHM_CAP_FP_H_ diff --git a/src/tpm2/AlgorithmTests_fp.h b/src/tpm2/AlgorithmTests_fp.h deleted file mode 100644 index 5e76d3735..000000000 --- a/src/tpm2/AlgorithmTests_fp.h +++ /dev/null @@ -1,95 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* 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 - 2024 */ -/* */ -/********************************************************************************/ - -/*(Auto-generated) - * Created by TpmPrototypes; Version 3.0 July 18, 2017 - * Date: Mar 4, 2020 Time: 02:36:44PM - */ - -#ifndef _ALGORITHM_TESTS_FP_H_ -#define _ALGORITHM_TESTS_FP_H_ - -#if ENABLE_SELF_TESTS - -//*** TestAlgorithm() -// Dispatches to the correct test function for the algorithm or gets a list of -// testable algorithms. -// -// If 'toTest' is not NULL, then the test decisions are based on the algorithm -// selections in 'toTest'. Otherwise, 'g_toTest' is used. When bits are clear in -// 'g_toTest' they will also be cleared 'toTest'. -// -// If there doesn't happen to be a test for the algorithm, its associated bit is -// quietly cleared. -// -// If 'alg' is zero (TPM_ALG_ERROR), then the toTest vector is cleared of any bits -// for which there is no test (i.e. no tests are actually run but the vector is -// cleared). -// -// Note: 'toTest' will only ever have bits set for implemented algorithms but 'alg' -// can be anything. -// Return Type: TPM_RC -// TPM_RC_CANCELED test was canceled -LIB_EXPORT -TPM_RC -TestAlgorithm(TPM_ALG_ID alg, ALGORITHM_VECTOR* toTest); -#endif // ENABLE_SELF_TESTS - -#endif // _ALGORITHM_TESTS_FP_H_ diff --git a/src/tpm2/AsymmetricCommands.c b/src/tpm2/AsymmetricCommands.c index 8eea24b0c..5e66e643b 100644 --- a/src/tpm2/AsymmetricCommands.c +++ b/src/tpm2/AsymmetricCommands.c @@ -72,6 +72,8 @@ TPM2_RSA_Encrypt( TPMT_RSA_DECRYPT *scheme; // Input Validation rsaKey = HandleToObject(in->keyHandle); + pAssert_RC(rsaKey != NULL); + // selected key must be an RSA key if(rsaKey->publicArea.type != TPM_ALG_RSA) return TPM_RCS_KEY + RC_RSA_Encrypt_keyHandle; @@ -108,6 +110,8 @@ TPM2_RSA_Decrypt( TPMT_RSA_DECRYPT *scheme; // Input Validation rsaKey = HandleToObject(in->keyHandle); + pAssert_RC(rsaKey != NULL); + // The selected key must be an RSA key if(rsaKey->publicArea.type != TPM_ALG_RSA) return TPM_RCS_KEY + RC_RSA_Decrypt_keyHandle; @@ -151,6 +155,8 @@ TPM2_ECDH_KeyGen( TPM_RC result; // Input Validation eccKey = HandleToObject(in->keyHandle); + pAssert_RC(eccKey != NULL); + // Referenced key must be an ECC key if(eccKey->publicArea.type != TPM_ALG_ECC) return TPM_RCS_KEY + RC_ECDH_KeyGen_keyHandle; @@ -195,6 +201,8 @@ TPM2_ECDH_ZGen( OBJECT *eccKey; // Input Validation eccKey = HandleToObject(in->keyHandle); + pAssert_RC(eccKey != NULL); + // Selected key must be a non-restricted, decrypt ECC key if(eccKey->publicArea.type != TPM_ALG_ECC) return TPM_RCS_KEY + RC_ECDH_ZGen_keyHandle; @@ -256,6 +264,8 @@ TPM2_ZGen_2Phase( // Input Validation eccKey = HandleToObject(in->keyA); + pAssert_RC(eccKey != NULL); + // keyA must be an ECC key if(eccKey->publicArea.type != TPM_ALG_ECC) return TPM_RCS_KEY + RC_ZGen_2Phase_keyA; @@ -312,7 +322,9 @@ TPM2_ECC_Encrypt( ECC_Encrypt_Out *out // OUT: output parameter list ) { - OBJECT *pubKey = HandleToObject(in->keyHandle); + OBJECT* pubKey = HandleToObject(in->keyHandle); + pAssert_RC(pubKey != NULL); + // Parameter validation if (pubKey->publicArea.type != TPM_ALG_ECC) return TPM_RC_KEY + RC_ECC_Encrypt_keyHandle; @@ -335,7 +347,9 @@ TPM2_ECC_Decrypt( ECC_Decrypt_Out *out // OUT: output parameter list ) { - OBJECT *key = HandleToObject(in->keyHandle); + OBJECT* key = HandleToObject(in->keyHandle); + pAssert_RC(key != NULL); + // Parameter validation // Must be the correct type of key with correct attributes if (key->publicArea.type != TPM_ALG_ECC) diff --git a/src/tpm2/Attest_spt_fp.h b/src/tpm2/Attest_spt_fp.h deleted file mode 100644 index fbb4a538d..000000000 --- a/src/tpm2/Attest_spt_fp.h +++ /dev/null @@ -1,111 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: Attest_spt_fp.h 1490 2019-07-26 21:13:22Z 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 */ -/* */ -/********************************************************************************/ - -/*(Auto-generated) - * Created by TpmPrototypes; Version 3.0 July 18, 2017 - * Date: Mar 28, 2019 Time: 08:25:18PM - */ - -#ifndef _ATTEST_SPT_FP_H_ -#define _ATTEST_SPT_FP_H_ - -//***FillInAttestInfo() -// Fill in common fields of TPMS_ATTEST structure. -void FillInAttestInfo( - TPMI_DH_OBJECT signHandle, // IN: handle of signing object - TPMT_SIG_SCHEME* scheme, // IN/OUT: scheme to be used for signing - TPM2B_DATA* data, // IN: qualifying data - TPMS_ATTEST* attest // OUT: attest structure -); - -//***SignAttestInfo() -// Sign a TPMS_ATTEST structure. If signHandle is TPM_RH_NULL, a null signature -// is returned. -// -// Return Type: TPM_RC -// TPM_RC_ATTRIBUTES 'signHandle' references not a signing key -// TPM_RC_SCHEME 'scheme' is not compatible with 'signHandle' type -// TPM_RC_VALUE digest generated for the given 'scheme' is greater than -// the modulus of 'signHandle' (for an RSA key); -// invalid commit status or failed to generate "r" value -// (for an ECC key) -TPM_RC -SignAttestInfo(OBJECT* signKey, // IN: sign object - TPMT_SIG_SCHEME* scheme, // IN: sign scheme - TPMS_ATTEST* certifyInfo, // IN: the data to be signed - TPM2B_DATA* qualifyingData, // IN: extra data for the signing - // process - TPM2B_ATTEST* attest, // OUT: marshaled attest blob to be - // signed - TPMT_SIGNATURE* signature // OUT: signature -); - -//*** IsSigningObject() -// Checks to see if the object is OK for signing. This is here rather than in -// Object_spt.c because all the attestation commands use this file but not -// Object_spt.c. -// Return Type: BOOL -// TRUE(1) object may sign -// FALSE(0) object may not sign -BOOL IsSigningObject(OBJECT* object // IN: -); - -#endif // _ATTEST_SPT_FP_H_ diff --git a/src/tpm2/AttestationCommands.c b/src/tpm2/AttestationCommands.c index 78943448e..a78cfedac 100644 --- a/src/tpm2/AttestationCommands.c +++ b/src/tpm2/AttestationCommands.c @@ -1,4 +1,3 @@ - /********************************************************************************/ /* */ /* Attestation Commands */ @@ -87,6 +86,7 @@ TPM2_Certify( certifyInfo.type = TPM_ST_ATTEST_CERTIFY; // NOTE: the certified object is not allowed to be TPM_ALG_NULL so // 'certifiedObject' will never be NULL + pAssert_RC(certifiedObject != NULL); // should have been filtered earlier. certifyInfo.attested.certify.name = certifiedObject->name; // When using an anonymous signing scheme, need to set the qualified Name to the @@ -123,6 +123,8 @@ TPM2_CertifyCreation( return TPM_RCS_KEY + RC_CertifyCreation_signHandle; if(!CryptSelectSignScheme(signObject, &in->inScheme)) return TPM_RCS_SCHEME + RC_CertifyCreation_inScheme; + + pAssert_RC(certified != NULL); // CertifyCreation specific input validation // Re-compute ticket TicketComputeCreation(in->creationTicket.hierarchy, &certified->name, @@ -151,50 +153,6 @@ TPM2_CertifyCreation( #endif // CC_CertifyCreation #include "Tpm.h" #include "Attest_spt_fp.h" -#include "Quote_fp.h" -#if CC_Quote // Conditional expansion of this file -TPM_RC -TPM2_Quote( - Quote_In *in, // IN: input parameter list - Quote_Out *out // OUT: output parameter list - ) -{ - TPMI_ALG_HASH hashAlg; - TPMS_ATTEST quoted; - OBJECT *signObject = HandleToObject(in->signHandle); - // Input Validation - if(!IsSigningObject(signObject)) - return TPM_RCS_KEY + RC_Quote_signHandle; - if(!CryptSelectSignScheme(signObject, &in->inScheme)) - return TPM_RCS_SCHEME + RC_Quote_inScheme; - // Command Output - // Filling in attest information - // Common fields - // FillInAttestInfo may return TPM_RC_SCHEME or TPM_RC_KEY - FillInAttestInfo(in->signHandle, &in->inScheme, &in->qualifyingData, "ed); - // Quote specific fields - // Attestation type - quoted.type = TPM_ST_ATTEST_QUOTE; - // Get hash algorithm in sign scheme. This hash algorithm is used to - // compute PCR digest. If there is no algorithm, then the PCR cannot - // be digested and this command returns TPM_RC_SCHEME - hashAlg = in->inScheme.details.any.hashAlg; - if(hashAlg == TPM_ALG_NULL) - return TPM_RCS_SCHEME + RC_Quote_inScheme; - // Compute PCR digest - PCRComputeCurrentDigest(hashAlg, &in->PCRselect, - "ed.attested.quote.pcrDigest); - // Copy PCR select. "PCRselect" is modified in PCRComputeCurrentDigest - // function - quoted.attested.quote.pcrSelect = in->PCRselect; - // Sign attestation structure. A NULL signature will be returned if - // signObject is NULL. - return SignAttestInfo(signObject, &in->inScheme, "ed, &in->qualifyingData, - &out->quoted, &out->signature); -} -#endif // CC_Quote -#include "Tpm.h" -#include "Attest_spt_fp.h" #include "GetSessionAuditDigest_fp.h" #if CC_GetSessionAuditDigest // Conditional expansion of this file TPM_RC @@ -203,9 +161,10 @@ TPM2_GetSessionAuditDigest( GetSessionAuditDigest_Out *out // OUT: output parameter list ) { - SESSION *session = SessionGet(in->sessionHandle); - TPMS_ATTEST auditInfo; - OBJECT *signObject = HandleToObject(in->signHandle); + SESSION* session = SessionGet(in->sessionHandle); + pAssert_RC(session); + TPMS_ATTEST auditInfo; + OBJECT* signObject = HandleToObject(in->signHandle); // Input Validation if(!IsSigningObject(signObject)) return TPM_RCS_KEY + RC_GetSessionAuditDigest_signHandle; @@ -338,6 +297,8 @@ TPM2_CertifyX509( INT16 length; // length for a tagged element ASN1UnmarshalContext ctx; ASN1MarshalContext ctxOut; + pAssert_RC(object != NULL); + // certTBS holds an array of pointers and lengths. Each entry references the // corresponding value in a TBSCertificate structure. For example, the 1th // element references the version number diff --git a/src/tpm2/BackwardsCompatibility.h b/src/tpm2/BackwardsCompatibility.h index b2a6a9e5a..0f7e6a1f6 100644 --- a/src/tpm2/BackwardsCompatibility.h +++ b/src/tpm2/BackwardsCompatibility.h @@ -1,40 +1,6 @@ -/********************************************************************************/ -/* */ -/* Backwards compatibility related stuff */ -/* Written by Stefan Berger */ -/* IBM Thomas J. Watson Research Center */ -/* */ -/* (c) Copyright IBM Corporation 2017,2018. */ -/* */ -/* All rights reserved. */ -/* */ -/* Redistribution and use in source and binary forms, with or without */ -/* modification, are permitted provided that the following conditions are */ -/* met: */ -/* */ -/* Redistributions of source code must retain the above copyright notice, */ -/* this list of conditions and the following disclaimer. */ -/* */ -/* Redistributions in binary form must reproduce the above copyright */ -/* notice, this list of conditions and the following disclaimer in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* Neither the names of the IBM Corporation nor the names of its */ -/* contributors may be used to endorse or promote products derived from */ -/* this software without specific prior written permission. */ -/* */ -/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */ -/* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */ -/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR */ -/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */ -/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */ -/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */ -/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, */ -/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY */ -/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */ -/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE */ -/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause + +// (c) Copyright IBM Corporation 2017,2018. #ifndef BACKWARDS_COMPATIBILITY_H #define BACKWARDS_COMPATIBILITY_H diff --git a/src/tpm2/BackwardsCompatibilityBitArray.c b/src/tpm2/BackwardsCompatibilityBitArray.c index 0809db693..fa7db9eb1 100644 --- a/src/tpm2/BackwardsCompatibilityBitArray.c +++ b/src/tpm2/BackwardsCompatibilityBitArray.c @@ -1,40 +1,6 @@ -/********************************************************************************/ -/* */ -/* Backwards compatibility support related to command code arrays */ -/* Written by Stefan Berger */ -/* IBM Thomas J. Watson Research Center */ -/* */ -/* (c) Copyright IBM Corporation 2023. */ -/* */ -/* All rights reserved. */ -/* */ -/* Redistribution and use in source and binary forms, with or without */ -/* modification, are permitted provided that the following conditions are */ -/* met: */ -/* */ -/* Redistributions of source code must retain the above copyright notice, */ -/* this list of conditions and the following disclaimer. */ -/* */ -/* Redistributions in binary form must reproduce the above copyright */ -/* notice, this list of conditions and the following disclaimer in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* Neither the names of the IBM Corporation nor the names of its */ -/* contributors may be used to endorse or promote products derived from */ -/* this software without specific prior written permission. */ -/* */ -/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */ -/* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */ -/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR */ -/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */ -/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */ -/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */ -/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, */ -/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY */ -/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */ -/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE */ -/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause + +// (c) Copyright IBM Corporation 2023. #include diff --git a/src/tpm2/BackwardsCompatibilityBitArray.h b/src/tpm2/BackwardsCompatibilityBitArray.h index 0d5002ee5..55e00aa38 100644 --- a/src/tpm2/BackwardsCompatibilityBitArray.h +++ b/src/tpm2/BackwardsCompatibilityBitArray.h @@ -1,46 +1,12 @@ -/********************************************************************************/ -/* */ -/* Backwards compatibility support related to command code arrays */ -/* Written by Stefan Berger */ -/* IBM Thomas J. Watson Research Center */ -/* */ -/* (c) Copyright IBM Corporation 2023. */ -/* */ -/* All rights reserved. */ -/* */ -/* Redistribution and use in source and binary forms, with or without */ -/* modification, are permitted provided that the following conditions are */ -/* met: */ -/* */ -/* Redistributions of source code must retain the above copyright notice, */ -/* this list of conditions and the following disclaimer. */ -/* */ -/* Redistributions in binary form must reproduce the above copyright */ -/* notice, this list of conditions and the following disclaimer in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* Neither the names of the IBM Corporation nor the names of its */ -/* contributors may be used to endorse or promote products derived from */ -/* this software without specific prior written permission. */ -/* */ -/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */ -/* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */ -/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR */ -/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */ -/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */ -/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */ -/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, */ -/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY */ -/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */ -/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE */ -/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause + +// (c) Copyright IBM Corporation 2023. #ifndef BACKWARDS_COMPATIBILITY_BIT_ARRAY_H #define BACKWARDS_COMPATIBILITY_BIT_ARRAY_H #include "Tpm.h" -#include "TpmTypes.h" +#include TPM_RC ConvertFromCompressedBitArray(BYTE *inAuditCommands, diff --git a/src/tpm2/BackwardsCompatibilityObject.c b/src/tpm2/BackwardsCompatibilityObject.c index 14531bf3c..32bfd0aff 100644 --- a/src/tpm2/BackwardsCompatibilityObject.c +++ b/src/tpm2/BackwardsCompatibilityObject.c @@ -1,40 +1,6 @@ -/********************************************************************************/ -/* */ -/* Backwards compatibility stuff related to OBJECT */ -/* Written by Stefan Berger */ -/* IBM Thomas J. Watson Research Center */ -/* */ -/* (c) Copyright IBM Corporation 2017,2018. */ -/* */ -/* All rights reserved. */ -/* */ -/* Redistribution and use in source and binary forms, with or without */ -/* modification, are permitted provided that the following conditions are */ -/* met: */ -/* */ -/* Redistributions of source code must retain the above copyright notice, */ -/* this list of conditions and the following disclaimer. */ -/* */ -/* Redistributions in binary form must reproduce the above copyright */ -/* notice, this list of conditions and the following disclaimer in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* Neither the names of the IBM Corporation nor the names of its */ -/* contributors may be used to endorse or promote products derived from */ -/* this software without specific prior written permission. */ -/* */ -/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */ -/* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */ -/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR */ -/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */ -/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */ -/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */ -/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, */ -/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY */ -/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */ -/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE */ -/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause + +// (c) Copyright IBM Corporation 2017,2018. #include diff --git a/src/tpm2/BackwardsCompatibilityObject.h b/src/tpm2/BackwardsCompatibilityObject.h index 098d7746f..88e94770f 100644 --- a/src/tpm2/BackwardsCompatibilityObject.h +++ b/src/tpm2/BackwardsCompatibilityObject.h @@ -1,40 +1,6 @@ -/********************************************************************************/ -/* */ -/* Backwards compatibility stuff related to OBJECT */ -/* Written by Stefan Berger */ -/* IBM Thomas J. Watson Research Center */ -/* */ -/* (c) Copyright IBM Corporation 2017,2018. */ -/* */ -/* All rights reserved. */ -/* */ -/* Redistribution and use in source and binary forms, with or without */ -/* modification, are permitted provided that the following conditions are */ -/* met: */ -/* */ -/* Redistributions of source code must retain the above copyright notice, */ -/* this list of conditions and the following disclaimer. */ -/* */ -/* Redistributions in binary form must reproduce the above copyright */ -/* notice, this list of conditions and the following disclaimer in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* Neither the names of the IBM Corporation nor the names of its */ -/* contributors may be used to endorse or promote products derived from */ -/* this software without specific prior written permission. */ -/* */ -/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */ -/* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */ -/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR */ -/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */ -/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */ -/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */ -/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, */ -/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY */ -/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */ -/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE */ -/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause + +// (c) Copyright IBM Corporation 2017,2018. #ifndef BACKWARDS_COMPATIBILITY_OBJECT_H #define BACKWARDS_COMPATIBILITY_OBJECT_H diff --git a/src/tpm2/BaseTypes.h b/src/tpm2/BaseTypes.h deleted file mode 100644 index 43615ab5a..000000000 --- a/src/tpm2/BaseTypes.h +++ /dev/null @@ -1,84 +0,0 @@ -/********************************************************************************/ -/* */ -/* Basic Typedefs */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: BaseTypes.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, 2016 - 2019 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#ifndef _TPM_INCLUDE_PUBLIC_BASETYPES_H_ -#define _TPM_INCLUDE_PUBLIC_BASETYPES_H_ - -// NULL definition -#ifndef NULL -# define NULL (0) -#endif // NULL - -typedef uint8_t UINT8; -typedef uint8_t BYTE; -typedef int8_t INT8; -typedef int BOOL; -typedef uint16_t UINT16; -typedef int16_t INT16; -typedef uint32_t UINT32; -typedef int32_t INT32; -typedef uint64_t UINT64; -typedef int64_t INT64; - -#endif // _TPM_INCLUDE_PUBLIC_BASETYPES_H_ diff --git a/src/tpm2/Bits.c b/src/tpm2/Bits.c deleted file mode 100644 index 47bfeff31..000000000 --- a/src/tpm2/Bits.c +++ /dev/null @@ -1,112 +0,0 @@ -/********************************************************************************/ -/* */ -/* Bit Manipulation Routines */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: Bits.c 1490 2019-07-26 21:13:22Z 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 - 2018 */ -/* */ -/********************************************************************************/ - -//** Introduction -// This file contains bit manipulation routines. They operate on bit arrays. -// -// The 0th bit in the array is the right-most bit in the 0th octet in -// the array. -// -// NOTE: If pAssert() is defined, the functions will assert if the indicated bit -// number is outside of the range of 'bArray'. How the assert is handled is -// implementation dependent. - -//** Includes - -#include "Tpm.h" - -//** Functions - -//*** TestBit() -// This function is used to check the setting of a bit in an array of bits. -// Return Type: BOOL -// TRUE(1) bit is set -// FALSE(0) bit is not set -BOOL TestBit(unsigned int bitNum, // IN: number of the bit in 'bArray' - BYTE* bArray, // IN: array containing the bits - unsigned int bytesInArray // IN: size in bytes of 'bArray' -) -{ - pAssert(bytesInArray > (bitNum >> 3)); - return ((bArray[bitNum >> 3] & (1 << (bitNum & 7))) != 0); -} - -//*** SetBit() -// This function will set the indicated bit in 'bArray'. -void SetBit(unsigned int bitNum, // IN: number of the bit in 'bArray' - BYTE* bArray, // IN: array containing the bits - unsigned int bytesInArray // IN: size in bytes of 'bArray' -) -{ - pAssert(bytesInArray > (bitNum >> 3)); - bArray[bitNum >> 3] |= (1 << (bitNum & 7)); -} - -//*** ClearBit() -// This function will clear the indicated bit in 'bArray'. -void ClearBit(unsigned int bitNum, // IN: number of the bit in 'bArray'. - BYTE* bArray, // IN: array containing the bits - unsigned int bytesInArray // IN: size in bytes of 'bArray' -) -{ - pAssert(bytesInArray > (bitNum >> 3)); - bArray[bitNum >> 3] &= ~(1 << (bitNum & 7)); -} diff --git a/src/tpm2/Bits_fp.h b/src/tpm2/Bits_fp.h deleted file mode 100644 index 2b4810e97..000000000 --- a/src/tpm2/Bits_fp.h +++ /dev/null @@ -1,94 +0,0 @@ -/********************************************************************************/ -/* */ -/* Bit Handling */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: Bits_fp.h 803 2016-11-15 20:19:26Z 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 - 2018 */ -/* */ -/********************************************************************************/ - -/*(Auto-generated) - * Created by TpmPrototypes; Version 3.0 July 18, 2017 - * Date: Mar 28, 2019 Time: 08:25:19PM - */ - -#ifndef _BITS_FP_H_ -#define _BITS_FP_H_ - -//*** TestBit() -// This function is used to check the setting of a bit in an array of bits. -// Return Type: BOOL -// TRUE(1) bit is set -// FALSE(0) bit is not set -BOOL TestBit(unsigned int bitNum, // IN: number of the bit in 'bArray' - BYTE* bArray, // IN: array containing the bits - unsigned int bytesInArray // IN: size in bytes of 'bArray' -); - -//*** SetBit() -// This function will set the indicated bit in 'bArray'. -void SetBit(unsigned int bitNum, // IN: number of the bit in 'bArray' - BYTE* bArray, // IN: array containing the bits - unsigned int bytesInArray // IN: size in bytes of 'bArray' -); - -//*** ClearBit() -// This function will clear the indicated bit in 'bArray'. -void ClearBit(unsigned int bitNum, // IN: number of the bit in 'bArray'. - BYTE* bArray, // IN: array containing the bits - unsigned int bytesInArray // IN: size in bytes of 'bArray' -); - -#endif // _BITS_FP_H_ diff --git a/src/tpm2/BnUtil_fp.h b/src/tpm2/BnUtil_fp.h deleted file mode 100644 index 832010ef2..000000000 --- a/src/tpm2/BnUtil_fp.h +++ /dev/null @@ -1,66 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* 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 */ -/* */ -/********************************************************************************/ - -//** Introduction -// Utility functions to support TpmBigNum library -#ifndef _BNUTIL_FP_H_ -#define _BNUTIL_FP_H_ - -#endif // _BNUTIL_FP_H_ diff --git a/src/tpm2/Cancel.c b/src/tpm2/Cancel.c deleted file mode 100644 index 0d0359fe1..000000000 --- a/src/tpm2/Cancel.c +++ /dev/null @@ -1,97 +0,0 @@ -/********************************************************************************/ -/* */ -/* Simulates the cancel pins on the TPM. */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: Cancel.c 1490 2019-07-26 21:13:22Z 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 */ -/* */ -/********************************************************************************/ - -//** Description -// -// This module simulates the cancel pins on the TPM. -// -//** Includes, Typedefs, Structures, and Defines -#include "Platform.h" - -//** Functions - -//***_plat__IsCanceled() -// Check if the cancel flag is set -// Return Type: int -// TRUE(1) if cancel flag is set -// FALSE(0) if cancel flag is not set -LIB_EXPORT int _plat__IsCanceled(void) -{ - // return cancel flag - return s_isCanceled; -} - -//***_plat__SetCancel() - -// Set cancel flag. -LIB_EXPORT void _plat__SetCancel(void) -{ - s_isCanceled = TRUE; - return; -} - -//***_plat__ClearCancel() -// Clear cancel flag -LIB_EXPORT void _plat__ClearCancel(void) -{ - s_isCanceled = FALSE; - return; -} diff --git a/src/tpm2/Capabilities.h b/src/tpm2/Capabilities.h deleted file mode 100644 index 572f40fea..000000000 --- a/src/tpm2/Capabilities.h +++ /dev/null @@ -1,76 +0,0 @@ -/********************************************************************************/ -/* */ -/* Number of capability values that will fit into the largest data buffer */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: Capabilities.h 1519 2019-11-15 20:43:51Z 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 */ -/* */ -/********************************************************************************/ - -#ifndef _CAPABILITIES_H -#define _CAPABILITIES_H - -#define MAX_CAP_DATA (MAX_CAP_BUFFER - sizeof(TPM_CAP) - sizeof(UINT32)) -#define MAX_CAP_ALGS (MAX_CAP_DATA / sizeof(TPMS_ALG_PROPERTY)) -#define MAX_CAP_HANDLES (MAX_CAP_DATA / sizeof(TPM_HANDLE)) -#define MAX_CAP_CC (MAX_CAP_DATA / sizeof(TPM_CC)) -#define MAX_TPM_PROPERTIES (MAX_CAP_DATA / sizeof(TPMS_TAGGED_PROPERTY)) -#define MAX_PCR_PROPERTIES (MAX_CAP_DATA / sizeof(TPMS_TAGGED_PCR_SELECT)) -#define MAX_ECC_CURVES (MAX_CAP_DATA / sizeof(TPM_ECC_CURVE)) -#define MAX_TAGGED_POLICIES (MAX_CAP_DATA / sizeof(TPMS_TAGGED_POLICY)) -#define MAX_ACT_DATA (MAX_CAP_DATA / sizeof(TPMS_ACT_DATA)) -#define MAX_AC_CAPABILITIES (MAX_CAP_DATA / sizeof(TPMS_AC_OUTPUT)) - -#endif diff --git a/src/tpm2/CapabilityCommands.c b/src/tpm2/CapabilityCommands.c index 0ea86ea27..a4af06655 100644 --- a/src/tpm2/CapabilityCommands.c +++ b/src/tpm2/CapabilityCommands.c @@ -187,6 +187,21 @@ TPM2_GetCapability( in->propertyCount, &data->actData); break; +# if SEC_CHANNEL_SUPPORT + case TPM_CAP_PUB_KEYS: + // This reference implementation supports only a single TPM SPDM public key + if((TPM_PUB_KEY)in->property != TPM_PUB_KEY_TPM_SPDM_00) + return TPM_RCS_VALUE + RC_GetCapability_property; + out->moreData = SpdmCapGetTpmPubKeys( + (TPM_PUB_KEY)in->property, in->propertyCount, &data->pubKeys); + break; + case TPM_CAP_SPDM_SESSION_INFO: + // Input property must be 0 + if(in->property != 0) + return TPM_RCS_VALUE + RC_GetCapability_property; + out->moreData = SpdmCapGetSessionInfo(&data->spdmSessionInfo); + break; +# endif // SEC_CHANNEL_SUPPORT case TPM_CAP_VENDOR_PROPERTY: // vendor property is not implemented default: diff --git a/src/tpm2/CertifyCreation_fp.h b/src/tpm2/CertifyCreation_fp.h deleted file mode 100644 index 12093c8aa..000000000 --- a/src/tpm2/CertifyCreation_fp.h +++ /dev/null @@ -1,101 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: CertifyCreation_fp.h 809 2016-11-16 18:31:54Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_CertifyCreation // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_CERTIFYCREATION_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_CERTIFYCREATION_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_DH_OBJECT signHandle; - TPMI_DH_OBJECT objectHandle; - TPM2B_DATA qualifyingData; - TPM2B_DIGEST creationHash; - TPMT_SIG_SCHEME inScheme; - TPMT_TK_CREATION creationTicket; -} CertifyCreation_In; - -// Output structure definition -typedef struct -{ - TPM2B_ATTEST certifyInfo; - TPMT_SIGNATURE signature; -} CertifyCreation_Out; - -// Response code modifiers -# define RC_CertifyCreation_signHandle (TPM_RC_H + TPM_RC_1) -# define RC_CertifyCreation_objectHandle (TPM_RC_H + TPM_RC_2) -# define RC_CertifyCreation_qualifyingData (TPM_RC_P + TPM_RC_1) -# define RC_CertifyCreation_creationHash (TPM_RC_P + TPM_RC_2) -# define RC_CertifyCreation_inScheme (TPM_RC_P + TPM_RC_3) -# define RC_CertifyCreation_creationTicket (TPM_RC_P + TPM_RC_4) - -// Function prototype -TPM_RC -TPM2_CertifyCreation(CertifyCreation_In* in, CertifyCreation_Out* out); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_CERTIFYCREATION_FP_H_ -#endif // CC_CertifyCreation diff --git a/src/tpm2/CertifyX509_fp.h b/src/tpm2/CertifyX509_fp.h deleted file mode 100644 index 2a74407c1..000000000 --- a/src/tpm2/CertifyX509_fp.h +++ /dev/null @@ -1,100 +0,0 @@ -/********************************************************************************/ -/* */ -/* TPM2_CertifyX509 Command Header */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: CertifyX509_fp.h 1519 2019-11-15 20:43:51Z 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 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_CertifyX509 // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_CERTIFYX509_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_CERTIFYX509_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_DH_OBJECT objectHandle; - TPMI_DH_OBJECT signHandle; - TPM2B_DATA reserved; - TPMT_SIG_SCHEME inScheme; - TPM2B_MAX_BUFFER partialCertificate; -} CertifyX509_In; - -// Output structure definition -typedef struct -{ - TPM2B_MAX_BUFFER addedToCertificate; - TPM2B_DIGEST tbsDigest; - TPMT_SIGNATURE signature; -} CertifyX509_Out; - -// Response code modifiers -# define RC_CertifyX509_objectHandle (TPM_RC_H + TPM_RC_1) -# define RC_CertifyX509_signHandle (TPM_RC_H + TPM_RC_2) -# define RC_CertifyX509_reserved (TPM_RC_P + TPM_RC_1) -# define RC_CertifyX509_inScheme (TPM_RC_P + TPM_RC_2) -# define RC_CertifyX509_partialCertificate (TPM_RC_P + TPM_RC_3) - -// Function prototype -TPM_RC -TPM2_CertifyX509(CertifyX509_In* in, CertifyX509_Out* out); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_CERTIFYX509_FP_H_ -#endif // CC_CertifyX509 diff --git a/src/tpm2/Certify_fp.h b/src/tpm2/Certify_fp.h deleted file mode 100644 index 2549b05f5..000000000 --- a/src/tpm2/Certify_fp.h +++ /dev/null @@ -1,97 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: Certify_fp.h 809 2016-11-16 18:31:54Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_Certify // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_CERTIFY_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_CERTIFY_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_DH_OBJECT objectHandle; - TPMI_DH_OBJECT signHandle; - TPM2B_DATA qualifyingData; - TPMT_SIG_SCHEME inScheme; -} Certify_In; - -// Output structure definition -typedef struct -{ - TPM2B_ATTEST certifyInfo; - TPMT_SIGNATURE signature; -} Certify_Out; - -// Response code modifiers -# define RC_Certify_objectHandle (TPM_RC_H + TPM_RC_1) -# define RC_Certify_signHandle (TPM_RC_H + TPM_RC_2) -# define RC_Certify_qualifyingData (TPM_RC_P + TPM_RC_1) -# define RC_Certify_inScheme (TPM_RC_P + TPM_RC_2) - -// Function prototype -TPM_RC -TPM2_Certify(Certify_In* in, Certify_Out* out); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_CERTIFY_FP_H_ -#endif // CC_Certify diff --git a/src/tpm2/ChangeEPS_fp.h b/src/tpm2/ChangeEPS_fp.h deleted file mode 100644 index 51cdda33e..000000000 --- a/src/tpm2/ChangeEPS_fp.h +++ /dev/null @@ -1,84 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: ChangeEPS_fp.h 809 2016-11-16 18:31:54Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_ChangeEPS // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_CHANGEEPS_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_CHANGEEPS_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_RH_PLATFORM authHandle; -} ChangeEPS_In; - -// Response code modifiers -# define RC_ChangeEPS_authHandle (TPM_RC_H + TPM_RC_1) - -// Function prototype -TPM_RC -TPM2_ChangeEPS(ChangeEPS_In* in); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_CHANGEEPS_FP_H_ -#endif // CC_ChangeEPS diff --git a/src/tpm2/ChangePPS_fp.h b/src/tpm2/ChangePPS_fp.h deleted file mode 100644 index db60e3ee6..000000000 --- a/src/tpm2/ChangePPS_fp.h +++ /dev/null @@ -1,84 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: ChangePPS_fp.h 809 2016-11-16 18:31:54Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_ChangePPS // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_CHANGEPPS_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_CHANGEPPS_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_RH_PLATFORM authHandle; -} ChangePPS_In; - -// Response code modifiers -# define RC_ChangePPS_authHandle (TPM_RC_H + TPM_RC_1) - -// Function prototype -TPM_RC -TPM2_ChangePPS(ChangePPS_In* in); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_CHANGEPPS_FP_H_ -#endif // CC_ChangePPS diff --git a/src/tpm2/ClearControl_fp.h b/src/tpm2/ClearControl_fp.h deleted file mode 100644 index a993b8879..000000000 --- a/src/tpm2/ClearControl_fp.h +++ /dev/null @@ -1,86 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: ClearControl_fp.h 1521 2019-11-15 21:00:47Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_ClearControl // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_CLEARCONTROL_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_CLEARCONTROL_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_RH_CLEAR auth; - TPMI_YES_NO disable; -} ClearControl_In; - -// Response code modifiers -# define RC_ClearControl_auth (TPM_RC_H + TPM_RC_1) -# define RC_ClearControl_disable (TPM_RC_P + TPM_RC_1) - -// Function prototype -TPM_RC -TPM2_ClearControl(ClearControl_In* in); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_CLEARCONTROL_FP_H_ -#endif // CC_ClearControl diff --git a/src/tpm2/Clear_fp.h b/src/tpm2/Clear_fp.h deleted file mode 100644 index 2cd97355c..000000000 --- a/src/tpm2/Clear_fp.h +++ /dev/null @@ -1,84 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: Clear_fp.h 809 2016-11-16 18:31:54Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_Clear // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_CLEAR_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_CLEAR_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_RH_CLEAR authHandle; -} Clear_In; - -// Response code modifiers -# define RC_Clear_authHandle (TPM_RC_H + TPM_RC_1) - -// Function prototype -TPM_RC -TPM2_Clear(Clear_In* in); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_CLEAR_FP_H_ -#endif // CC_Clear diff --git a/src/tpm2/ClockRateAdjust_fp.h b/src/tpm2/ClockRateAdjust_fp.h deleted file mode 100644 index 4d4317c7a..000000000 --- a/src/tpm2/ClockRateAdjust_fp.h +++ /dev/null @@ -1,86 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: ClockRateAdjust_fp.h 809 2016-11-16 18:31:54Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_ClockRateAdjust // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_CLOCKRATEADJUST_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_CLOCKRATEADJUST_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_RH_PROVISION auth; - TPM_CLOCK_ADJUST rateAdjust; -} ClockRateAdjust_In; - -// Response code modifiers -# define RC_ClockRateAdjust_auth (TPM_RC_H + TPM_RC_1) -# define RC_ClockRateAdjust_rateAdjust (TPM_RC_P + TPM_RC_1) - -// Function prototype -TPM_RC -TPM2_ClockRateAdjust(ClockRateAdjust_In* in); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_CLOCKRATEADJUST_FP_H_ -#endif // CC_ClockRateAdjust diff --git a/src/tpm2/ClockSet_fp.h b/src/tpm2/ClockSet_fp.h deleted file mode 100644 index 73bc52171..000000000 --- a/src/tpm2/ClockSet_fp.h +++ /dev/null @@ -1,86 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: ClockSet_fp.h 809 2016-11-16 18:31:54Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_ClockSet // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_CLOCKSET_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_CLOCKSET_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_RH_PROVISION auth; - UINT64 newTime; -} ClockSet_In; - -// Response code modifiers -# define RC_ClockSet_auth (TPM_RC_H + TPM_RC_1) -# define RC_ClockSet_newTime (TPM_RC_P + TPM_RC_1) - -// Function prototype -TPM_RC -TPM2_ClockSet(ClockSet_In* in); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_CLOCKSET_FP_H_ -#endif // CC_ClockSet diff --git a/src/tpm2/CommandAttributes.h b/src/tpm2/CommandAttributes.h deleted file mode 100644 index 71973a95b..000000000 --- a/src/tpm2/CommandAttributes.h +++ /dev/null @@ -1,94 +0,0 @@ -/********************************************************************************/ -/* */ -/* Command Attributes */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: CommandAttributes.h 1594 2020-03-26 22:15:48Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2016 - 2020 */ -/* */ -/********************************************************************************/ - -/*(Auto-generated) - * Created by TpmStructures; Version 4.4 Mar 26, 2019 - * Date: Aug 30, 2019 Time: 02:11:52PM - */ - -// The attributes defined in this file are produced by the parser that -// creates the structure definitions from Part 3. The attributes are defined -// in that parser and should track the attributes being tested in -// CommandCodeAttributes.c. Generally, when an attribute is added to this list, -// new code will be needed in CommandCodeAttributes.c to test it. - -#ifndef COMMAND_ATTRIBUTES_H -#define COMMAND_ATTRIBUTES_H - -typedef UINT16 COMMAND_ATTRIBUTES; -#define NOT_IMPLEMENTED (COMMAND_ATTRIBUTES)(0) -#define ENCRYPT_2 ((COMMAND_ATTRIBUTES)1 << 0) -#define ENCRYPT_4 ((COMMAND_ATTRIBUTES)1 << 1) -#define DECRYPT_2 ((COMMAND_ATTRIBUTES)1 << 2) -#define DECRYPT_4 ((COMMAND_ATTRIBUTES)1 << 3) -#define HANDLE_1_USER ((COMMAND_ATTRIBUTES)1 << 4) -#define HANDLE_1_ADMIN ((COMMAND_ATTRIBUTES)1 << 5) -#define HANDLE_1_DUP ((COMMAND_ATTRIBUTES)1 << 6) -#define HANDLE_2_USER ((COMMAND_ATTRIBUTES)1 << 7) -#define PP_COMMAND ((COMMAND_ATTRIBUTES)1 << 8) -#define IS_IMPLEMENTED ((COMMAND_ATTRIBUTES)1 << 9) -#define NO_SESSIONS ((COMMAND_ATTRIBUTES)1 << 10) -#define NV_COMMAND ((COMMAND_ATTRIBUTES)1 << 11) -#define PP_REQUIRED ((COMMAND_ATTRIBUTES)1 << 12) -#define R_HANDLE ((COMMAND_ATTRIBUTES)1 << 13) -#define ALLOW_TRIAL ((COMMAND_ATTRIBUTES)1 << 14) - -#endif // COMMAND_ATTRIBUTES_H diff --git a/src/tpm2/CommandDispatcher_fp.h b/src/tpm2/CommandDispatcher_fp.h deleted file mode 100644 index 9eec0666c..000000000 --- a/src/tpm2/CommandDispatcher_fp.h +++ /dev/null @@ -1,81 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: CommandDispatcher_fp.h 1490 2019-07-26 21:13:22Z 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 */ -/* */ -/********************************************************************************/ - -/*(Auto-generated) - * Created by TpmPrototypes; Version 3.0 July 18, 2017 - * Date: Mar 7, 2020 Time: 07:06:44PM - */ - -#ifndef _COMMAND_DISPATCHER_FP_H_ -#define _COMMAND_DISPATCHER_FP_H_ - -//** ParseHandleBuffer() -// This is the table-driven version of the handle buffer unmarshaling code -TPM_RC -ParseHandleBuffer(COMMAND* command); - -//** CommandDispatcher() -// Function to unmarshal the command parameters, call the selected action code, and -// marshal the response parameters. -TPM_RC -CommandDispatcher(COMMAND* command); - -#endif // _COMMAND_DISPATCHER_FP_H_ diff --git a/src/tpm2/Commit_fp.h b/src/tpm2/Commit_fp.h deleted file mode 100644 index bafb37bf8..000000000 --- a/src/tpm2/Commit_fp.h +++ /dev/null @@ -1,99 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: Commit_fp.h 809 2016-11-16 18:31:54Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_Commit // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_COMMIT_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_COMMIT_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_DH_OBJECT signHandle; - TPM2B_ECC_POINT P1; - TPM2B_SENSITIVE_DATA s2; - TPM2B_ECC_PARAMETER y2; -} Commit_In; - -// Output structure definition -typedef struct -{ - TPM2B_ECC_POINT K; - TPM2B_ECC_POINT L; - TPM2B_ECC_POINT E; - UINT16 counter; -} Commit_Out; - -// Response code modifiers -# define RC_Commit_signHandle (TPM_RC_H + TPM_RC_1) -# define RC_Commit_P1 (TPM_RC_P + TPM_RC_1) -# define RC_Commit_s2 (TPM_RC_P + TPM_RC_2) -# define RC_Commit_y2 (TPM_RC_P + TPM_RC_3) - -// Function prototype -TPM_RC -TPM2_Commit(Commit_In* in, Commit_Out* out); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_COMMIT_FP_H_ -#endif // CC_Commit diff --git a/src/tpm2/CompilerDependencies.h b/src/tpm2/CompilerDependencies.h deleted file mode 100644 index 1171f4a07..000000000 --- a/src/tpm2/CompilerDependencies.h +++ /dev/null @@ -1,114 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* 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 */ -/* */ -/********************************************************************************/ - -// This file contains the build switches. This contains switches for multiple -// versions of the crypto-library so some may not apply to your environment. -// - -#ifndef _COMPILER_DEPENDENCIES_H_ -#define _COMPILER_DEPENDENCIES_H_ - -#if defined(__GNUC__) -# include "CompilerDependencies_gcc.h" -#elif defined(_MSC_VER) -# include "CompilerDependencies_msvc.h" -#else -# error unexpected -#endif - -#include - -// Things that are not defined should be defined as NULL - -#ifndef NORETURN -# define NORETURN -#endif -#ifndef LIB_EXPORT -# define LIB_EXPORT -#endif -#ifndef LIB_IMPORT -# define LIB_IMPORT -#endif -#ifndef _REDUCE_WARNING_LEVEL_ -# define _REDUCE_WARNING_LEVEL_(n) -#endif -#ifndef _NORMAL_WARNING_LEVEL_ -# define _NORMAL_WARNING_LEVEL_ -#endif -#ifndef NOT_REFERENCED -# define NOT_REFERENCED(x) (x = x) -#endif - -#ifdef _POSIX_ -typedef int SOCKET; -#endif - -#if !defined(TPM_STATIC_ASSERT) || !defined(COMPILER_CHECKS) -# error Expect definitions of COMPILER_CHECKS and TPM_STATIC_ASSERT -#elif COMPILER_CHECKS -// pre static_assert static_assert -# define MUST_BE(e) TPM_STATIC_ASSERT(e) - -#else -// intentionally disabled, fine. -# define MUST_BE(e) -#endif - -#endif // _COMPILER_DEPENDENCIES_H_ diff --git a/src/tpm2/CompilerDependencies_gcc.h b/src/tpm2/CompilerDependencies_gcc.h deleted file mode 100644 index e08ae1316..000000000 --- a/src/tpm2/CompilerDependencies_gcc.h +++ /dev/null @@ -1,123 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* 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 */ -/* */ -/********************************************************************************/ - -// This file contains compiler specific switches. -// These definitions are for the GCC compiler -// - -#ifndef _COMPILER_DEPENDENCIES_GCC_H_ -#define _COMPILER_DEPENDENCIES_GCC_H_ - -#if !defined(__GNUC__) -# error CompilerDependencies_gcc.h included for wrong compiler -#endif - -// don't warn on unused local typedefs, they are used as a -// cross-compiler static_assert -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-local-typedefs" -#pragma GCC diagnostic pop - -#undef _MSC_VER -#undef WIN32 - -#ifndef WINAPI -# define WINAPI -#endif -#ifndef __pragma -# define __pragma(x) -#endif - /* libtpms added begin */ -#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2) -# define REVERSE_ENDIAN_16(_Number) __builtin_bswap16(_Number) -# define REVERSE_ENDIAN_32(_Number) __builtin_bswap32(_Number) -# define REVERSE_ENDIAN_64(_Number) __builtin_bswap64(_Number) -#else -# if defined __linux__ || defined __CYGWIN__ -# include -# define REVERSE_ENDIAN_16(_Number) bswap_16(_Number) -# define REVERSE_ENDIAN_32(_Number) bswap_32(_Number) -# define REVERSE_ENDIAN_64(_Number) bswap_64(_Number) -# elif defined __OpenBSD__ -# include -# define REVERSE_ENDIAN_16(_Number) swap16(_Number) -# define REVERSE_ENDIAN_32(_Number) swap32(_Number) -# define REVERSE_ENDIAN_64(_Number) swap64(_Number) -# elif defined __APPLE__ -# include -# define REVERSE_ENDIAN_16(_Number) _OSSwapInt16(_Number) -# define REVERSE_ENDIAN_32(_Number) _OSSwapInt32(_Number) -# define REVERSE_ENDIAN_64(_Number) _OSSwapInt64(_Number) -# elif defined __FreeBSD__ -# include -# define REVERSE_ENDIAN_16(_Number) bswap16(_Number) -# define REVERSE_ENDIAN_32(_Number) bswap32(_Number) -# define REVERSE_ENDIAN_64(_Number) bswap64(_Number) -# else -# error Unsupported OS -# endif -#endif - /* libtpms added end */ - -#define NORETURN __attribute__((noreturn)) - -#define TPM_INLINE inline __attribute__((always_inline)) -#define TPM_STATIC_ASSERT(e) _Static_assert(e, "static assert") -#endif // _COMPILER_DEPENDENCIES_H_ diff --git a/src/tpm2/CompilerDependencies_msvc.h b/src/tpm2/CompilerDependencies_msvc.h deleted file mode 100644 index 04f637c2c..000000000 --- a/src/tpm2/CompilerDependencies_msvc.h +++ /dev/null @@ -1,125 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* 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 */ -/* */ -/********************************************************************************/ - -// This file contains compiler specific switches. -// These definitions are for the Microsoft compiler -// - -#ifndef _COMPILER_DEPENDENCIES_MSVC_H_ -#define _COMPILER_DEPENDENCIES_MSVC_H_ - -#if !defined(_MSC_VER) -# error CompilerDependencies_msvc.h included for wrong compiler -#endif - -// Endian conversion for aligned structures -#define REVERSE_ENDIAN_16(_Number) _byteswap_ushort(_Number) -#define REVERSE_ENDIAN_32(_Number) _byteswap_ulong(_Number) -#define REVERSE_ENDIAN_64(_Number) _byteswap_uint64(_Number) - -// Avoid compiler warning for in line of stdio (or not) -//#define _NO_CRT_STDIO_INLINE - -// This macro is used to handle LIB_EXPORT of function and variable names in lieu -// of a .def file. Visual Studio requires that functions be explicitly exported and -// imported. -#ifdef TPM_AS_DLL -# define LIB_EXPORT __declspec(dllexport) // VS compatible version -# define LIB_IMPORT __declspec(dllimport) -#else -// building static libraries -# define LIB_EXPORT -# define LIB_IMPORT -#endif - -#define TPM_INLINE inline - -// This is defined to indicate a function that does not return. Microsoft compilers -// do not support the _Noretrun function parameter. -#define NORETURN __declspec(noreturn) -#if _MSC_VER >= 1400 // SAL processing when needed -# include -#endif - -// # ifdef _WIN64 -// # define _INTPTR 2 -// # else -// # define _INTPTR 1 -// # endif - -#define NOT_REFERENCED(x) (x) - -// Lower the compiler error warning for system include -// files. They tend not to be that clean and there is no -// reason to sort through all the spurious errors that they -// generate when the normal error level is set to /Wall -#define _REDUCE_WARNING_LEVEL_(n) __pragma(warning(push, n)) -// Restore the compiler warning level -#define _NORMAL_WARNING_LEVEL_ __pragma(warning(pop)) -#include - -#ifdef TPM_STATIC_ASSERT -# error TPM_STATIC_ASSERT already defined -#endif - -// MSVC: failure results in error C2118: negative subscript error -#define TPM_STATIC_ASSERT(e) typedef char __C_ASSERT__[(e) ? 1 : -1] - -#endif // _COMPILER_DEPENDENCIES_MSVC_H_ diff --git a/src/tpm2/ContextCommands.c b/src/tpm2/ContextCommands.c index 70f9e9d95..613bc0435 100644 --- a/src/tpm2/ContextCommands.c +++ b/src/tpm2/ContextCommands.c @@ -151,8 +151,8 @@ TPM2_ContextSave(ContextSave_In* in, // IN: input parameter list out->context.contextBlob.t.size = integritySize + fingerprintSize + objectSize; // Make sure things fit - pAssert(out->context.contextBlob.t.size - <= sizeof(out->context.contextBlob.t.buffer)); + pAssert_RC(out->context.contextBlob.t.size + <= sizeof(out->context.contextBlob.t.buffer)); // Copy the whole internal OBJECT structure to context blob MemoryCopy(outObject, objbuf, objectSize); // libtpms changed // Increment object context ID @@ -195,15 +195,15 @@ TPM2_ContextSave(ContextSave_In* in, // IN: input parameter list integritySize + fingerprintSize + sizeof(*session); // Make sure things fit - pAssert(out->context.contextBlob.t.size - < sizeof(out->context.contextBlob.t.buffer)); + pAssert_RC(out->context.contextBlob.t.size + < sizeof(out->context.contextBlob.t.buffer)); // Copy the whole internal SESSION structure to context blob. // Save space for fingerprint at the beginning of the buffer // This is done before anything else so that the actual context // can be reclaimed after this call - pAssert(sizeof(*session) <= sizeof(out->context.contextBlob.t.buffer) - - integritySize - fingerprintSize); + pAssert_RC(sizeof(*session) <= sizeof(out->context.contextBlob.t.buffer) + - integritySize - fingerprintSize); MemoryCopy( out->context.contextBlob.t.buffer + integritySize + fingerprintSize, session, @@ -233,8 +233,8 @@ TPM2_ContextSave(ContextSave_In* in, // IN: input parameter list // Save fingerprint at the beginning of encrypted area of context blob. // Reserve the integrity space - pAssert(sizeof(out->context.sequence) - <= sizeof(out->context.contextBlob.t.buffer) - integritySize); + pAssert_RC(sizeof(out->context.sequence) + <= sizeof(out->context.contextBlob.t.buffer) - integritySize); MemoryCopy(out->context.contextBlob.t.buffer + integritySize, &out->context.sequence, sizeof(out->context.sequence)); @@ -459,7 +459,8 @@ TPM2_FlushContext( if(!IsObjectPresent(in->flushHandle)) return TPM_RCS_HANDLE + RC_FlushContext_flushHandle; // Flush object - FlushObject(in->flushHandle); + if(!FlushObject(in->flushHandle)) + return TPM_RC_FAILURE; break; case TPM_HT_HMAC_SESSION: case TPM_HT_POLICY_SESSION: @@ -515,6 +516,7 @@ TPM2_EvictControl(EvictControl_In* in // IN: input parameter list // Get internal object pointer evictObject = HandleToObject(in->objectHandle); + pAssert_RC(evictObject != NULL); // Objects in a firmware-limited or SVN-limited hierarchy cannot be made // persistent. diff --git a/src/tpm2/ContextLoad_fp.h b/src/tpm2/ContextLoad_fp.h deleted file mode 100644 index ec49cd6dc..000000000 --- a/src/tpm2/ContextLoad_fp.h +++ /dev/null @@ -1,90 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: ContextLoad_fp.h 809 2016-11-16 18:31:54Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_ContextLoad // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_CONTEXTLOAD_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_CONTEXTLOAD_FP_H_ - -// Input structure definition -typedef struct -{ - TPMS_CONTEXT context; -} ContextLoad_In; - -// Output structure definition -typedef struct -{ - TPMI_DH_CONTEXT loadedHandle; -} ContextLoad_Out; - -// Response code modifiers -# define RC_ContextLoad_context (TPM_RC_P + TPM_RC_1) - -// Function prototype -TPM_RC -TPM2_ContextLoad(ContextLoad_In* in, ContextLoad_Out* out); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_CONTEXTLOAD_FP_H_ -#endif // CC_ContextLoad diff --git a/src/tpm2/ContextSave_fp.h b/src/tpm2/ContextSave_fp.h deleted file mode 100644 index 1f6dc2ec6..000000000 --- a/src/tpm2/ContextSave_fp.h +++ /dev/null @@ -1,90 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: ContextSave_fp.h 809 2016-11-16 18:31:54Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_ContextSave // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_CONTEXTSAVE_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_CONTEXTSAVE_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_DH_CONTEXT saveHandle; -} ContextSave_In; - -// Output structure definition -typedef struct -{ - TPMS_CONTEXT context; -} ContextSave_Out; - -// Response code modifiers -# define RC_ContextSave_saveHandle (TPM_RC_H + TPM_RC_1) - -// Function prototype -TPM_RC -TPM2_ContextSave(ContextSave_In* in, ContextSave_Out* out); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_CONTEXTSAVE_FP_H_ -#endif // CC_ContextSave diff --git a/src/tpm2/CreateLoaded_fp.h b/src/tpm2/CreateLoaded_fp.h deleted file mode 100644 index 0198c5bad..000000000 --- a/src/tpm2/CreateLoaded_fp.h +++ /dev/null @@ -1,97 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: CreateLoaded_fp.h 1600 2020-03-30 22:08: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, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_CreateLoaded // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_CREATELOADED_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_CREATELOADED_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_DH_PARENT parentHandle; - TPM2B_SENSITIVE_CREATE inSensitive; - TPM2B_TEMPLATE inPublic; -} CreateLoaded_In; - -// Output structure definition -typedef struct -{ - TPM_HANDLE objectHandle; - TPM2B_PRIVATE outPrivate; - TPM2B_PUBLIC outPublic; - TPM2B_NAME name; -} CreateLoaded_Out; - -// Response code modifiers -# define RC_CreateLoaded_parentHandle (TPM_RC_H + TPM_RC_1) -# define RC_CreateLoaded_inSensitive (TPM_RC_P + TPM_RC_1) -# define RC_CreateLoaded_inPublic (TPM_RC_P + TPM_RC_2) - -// Function prototype -TPM_RC -TPM2_CreateLoaded(CreateLoaded_In* in, CreateLoaded_Out* out); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_CREATELOADED_FP_H_ -#endif // CC_CreateLoaded diff --git a/src/tpm2/CreatePrimary_fp.h b/src/tpm2/CreatePrimary_fp.h deleted file mode 100644 index 6fcf801a3..000000000 --- a/src/tpm2/CreatePrimary_fp.h +++ /dev/null @@ -1,103 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: CreatePrimary_fp.h 809 2016-11-16 18:31:54Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_CreatePrimary // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_CREATEPRIMARY_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_CREATEPRIMARY_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_RH_HIERARCHY primaryHandle; - TPM2B_SENSITIVE_CREATE inSensitive; - TPM2B_PUBLIC inPublic; - TPM2B_DATA outsideInfo; - TPML_PCR_SELECTION creationPCR; -} CreatePrimary_In; - -// Output structure definition -typedef struct -{ - TPM_HANDLE objectHandle; - TPM2B_PUBLIC outPublic; - TPM2B_CREATION_DATA creationData; - TPM2B_DIGEST creationHash; - TPMT_TK_CREATION creationTicket; - TPM2B_NAME name; -} CreatePrimary_Out; - -// Response code modifiers -# define RC_CreatePrimary_primaryHandle (TPM_RC_H + TPM_RC_1) -# define RC_CreatePrimary_inSensitive (TPM_RC_P + TPM_RC_1) -# define RC_CreatePrimary_inPublic (TPM_RC_P + TPM_RC_2) -# define RC_CreatePrimary_outsideInfo (TPM_RC_P + TPM_RC_3) -# define RC_CreatePrimary_creationPCR (TPM_RC_P + TPM_RC_4) - -// Function prototype -TPM_RC -TPM2_CreatePrimary(CreatePrimary_In* in, CreatePrimary_Out* out); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_CREATEPRIMARY_FP_H_ -#endif // CC_CreatePrimary diff --git a/src/tpm2/Create_fp.h b/src/tpm2/Create_fp.h deleted file mode 100644 index 6e509166a..000000000 --- a/src/tpm2/Create_fp.h +++ /dev/null @@ -1,102 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: Create_fp.h 1521 2019-11-15 21:00:47Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_Create // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_CREATE_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_CREATE_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_DH_OBJECT parentHandle; - TPM2B_SENSITIVE_CREATE inSensitive; - TPM2B_PUBLIC inPublic; - TPM2B_DATA outsideInfo; - TPML_PCR_SELECTION creationPCR; -} Create_In; - -// Output structure definition -typedef struct -{ - TPM2B_PRIVATE outPrivate; - TPM2B_PUBLIC outPublic; - TPM2B_CREATION_DATA creationData; - TPM2B_DIGEST creationHash; - TPMT_TK_CREATION creationTicket; -} Create_Out; - -// Response code modifiers -# define RC_Create_parentHandle (TPM_RC_H + TPM_RC_1) -# define RC_Create_inSensitive (TPM_RC_P + TPM_RC_1) -# define RC_Create_inPublic (TPM_RC_P + TPM_RC_2) -# define RC_Create_outsideInfo (TPM_RC_P + TPM_RC_3) -# define RC_Create_creationPCR (TPM_RC_P + TPM_RC_4) - -// Function prototype -TPM_RC -TPM2_Create(Create_In* in, Create_Out* out); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_CREATE_FP_H_ -#endif // CC_Create diff --git a/src/tpm2/crypto/CryptDes_fp.h b/src/tpm2/CryptDes_fp.h similarity index 100% rename from src/tpm2/crypto/CryptDes_fp.h rename to src/tpm2/CryptDes_fp.h diff --git a/src/tpm2/CryptEccData.c b/src/tpm2/CryptEccData.c deleted file mode 100644 index 658f7da0f..000000000 --- a/src/tpm2/CryptEccData.c +++ /dev/null @@ -1,154 +0,0 @@ -/********************************************************************************/ -/* */ -/* ECC curve data */ -/* 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, 2018 - 2023 */ -/* */ -/********************************************************************************/ - -/*(Auto-generated) - * Created by TpmStructures; Version 4.4 Mar 26, 2019 - * Date: Aug 30, 2019 Time: 02:11:52PM - */ - -#include "Tpm.h" -#include "OIDs.h" - -#if ALG_ECC - -// This file contains the TPM Specific ECC curve metadata and pointers to the ecc-lib specific -// constant structure. -// The CURVE_NAME macro is used to remove the name string from normal builds, but leaves the -// string available in the initialization lists for potenial use during debugging by changing this -// macro (and the structure declaration) -# define CURVE_NAME(N) - -# define comma -const TPM_ECC_CURVE_METADATA eccCurves[] = { -# if ECC_NIST_P192 - comma{TPM_ECC_NIST_P192, - 192, - {TPM_ALG_KDF1_SP800_56A, {{TPM_ALG_SHA256}}}, - {TPM_ALG_NULL, {{TPM_ALG_NULL}}}, - OID_ECC_NIST_P192 CURVE_NAME("NIST_P192")} -# undef comma -# define comma , -# endif // ECC_NIST_P192 -# if ECC_NIST_P224 - comma{TPM_ECC_NIST_P224, - 224, - {TPM_ALG_KDF1_SP800_56A, {{TPM_ALG_SHA256}}}, - {TPM_ALG_NULL, {{TPM_ALG_NULL}}}, - OID_ECC_NIST_P224 CURVE_NAME("NIST_P224")} -# undef comma -# define comma , -# endif // ECC_NIST_P224 -# if ECC_NIST_P256 - comma{TPM_ECC_NIST_P256, - 256, - {TPM_ALG_KDF1_SP800_56A, {{TPM_ALG_SHA256}}}, - {TPM_ALG_NULL, {{TPM_ALG_NULL}}}, - OID_ECC_NIST_P256 CURVE_NAME("NIST_P256")} -# undef comma -# define comma , -# endif // ECC_NIST_P256 -# if ECC_NIST_P384 - comma{TPM_ECC_NIST_P384, - 384, - {TPM_ALG_KDF1_SP800_56A, {{TPM_ALG_SHA384}}}, - {TPM_ALG_NULL, {{TPM_ALG_NULL}}}, - OID_ECC_NIST_P384 CURVE_NAME("NIST_P384")} -# undef comma -# define comma , -# endif // ECC_NIST_P384 -# if ECC_NIST_P521 - comma{TPM_ECC_NIST_P521, - 521, - {TPM_ALG_KDF1_SP800_56A, {{TPM_ALG_SHA512}}}, - {TPM_ALG_NULL, {{TPM_ALG_NULL}}}, - OID_ECC_NIST_P521 CURVE_NAME("NIST_P521")} -# undef comma -# define comma , -# endif // ECC_NIST_P521 -# if ECC_BN_P256 - comma{TPM_ECC_BN_P256, - 256, - {TPM_ALG_NULL, {{TPM_ALG_NULL}}}, - {TPM_ALG_NULL, {{TPM_ALG_NULL}}}, - OID_ECC_BN_P256 CURVE_NAME("BN_P256")} -# undef comma -# define comma , -# endif // ECC_BN_P256 -# if ECC_BN_P638 - comma{TPM_ECC_BN_P638, - 638, - {TPM_ALG_NULL, {{TPM_ALG_NULL}}}, - {TPM_ALG_NULL, {{TPM_ALG_NULL}}}, - OID_ECC_BN_P638 CURVE_NAME("BN_P638")} -# undef comma -# define comma , -# endif // ECC_BN_P638 -# if ECC_SM2_P256 - comma{TPM_ECC_SM2_P256, - 256, - {TPM_ALG_KDF1_SP800_56A, {{TPM_ALG_SM3_256}}}, - {TPM_ALG_NULL, {{TPM_ALG_NULL}}}, - OID_ECC_SM2_P256 CURVE_NAME("SM2_P256")} -# undef comma -# define comma , -# endif // ECC_SM2_P256 -}; - -#endif // TPM_ALG_ECC diff --git a/src/tpm2/CryptSelfTest_fp.h b/src/tpm2/CryptSelfTest_fp.h deleted file mode 100644 index e91df04b2..000000000 --- a/src/tpm2/CryptSelfTest_fp.h +++ /dev/null @@ -1,127 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: CryptSelfTest_fp.h 1490 2019-07-26 21:13:22Z 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 */ -/* */ -/********************************************************************************/ - -/*(Auto-generated) - * Created by TpmPrototypes; Version 3.0 July 18, 2017 - * Date: Mar 4, 2020 Time: 02:36:44PM - */ - -#ifndef _CRYPT_SELF_TEST_FP_H_ -#define _CRYPT_SELF_TEST_FP_H_ - -//*** CryptSelfTest() -// This function is called to start/complete a full self-test. -// If 'fullTest' is NO, then only the untested algorithms will be run. If -// 'fullTest' is YES, then 'g_untestedDecryptionAlgorithms' is reinitialized and then -// all tests are run. -// This implementation of the reference design does not support processing outside -// the framework of a TPM command. As a consequence, this command does not -// complete until all tests are done. Since this can take a long time, the TPM -// will check after each test to see if the command is canceled. If so, then the -// TPM will returned TPM_RC_CANCELLED. To continue with the self-tests, call -// TPM2_SelfTest(fullTest == No) and the TPM will complete the testing. -// Return Type: TPM_RC -// TPM_RC_CANCELED if the command is canceled -LIB_EXPORT -TPM_RC -CryptSelfTest(TPMI_YES_NO fullTest // IN: if full test is required -); - -//*** CryptIncrementalSelfTest() -// This function is used to perform an incremental self-test. This implementation -// will perform the toTest values before returning. That is, it assumes that the -// TPM cannot perform background tasks between commands. -// -// This command may be canceled. If it is, then there is no return result. -// However, this command can be run again and the incremental progress will not -// be lost. -// Return Type: TPM_RC -// TPM_RC_CANCELED processing of this command was canceled -// TPM_RC_TESTING if toTest list is not empty -// TPM_RC_VALUE an algorithm in the toTest list is not implemented -TPM_RC -CryptIncrementalSelfTest(TPML_ALG* toTest, // IN: list of algorithms to be tested - TPML_ALG* toDoList // OUT: list of algorithms needing test -); - -//*** CryptInitializeToTest() -// This function will initialize the data structures for testing all the -// algorithms. This should not be called unless CryptAlgsSetImplemented() has -// been called -void CryptInitializeToTest(void); - -//*** CryptTestAlgorithm() -// Only point of contact with the actual self tests. If a self-test fails, there -// is no return and the TPM goes into failure mode. -// The call to TestAlgorithm uses an algorithm selector and a bit vector. When the -// test is run, the corresponding bit in 'toTest' and in 'g_toTest' is CLEAR. If -// 'toTest' is NULL, then only the bit in 'g_toTest' is CLEAR. -// There is a special case for the call to TestAlgorithm(). When 'alg' is -// ALG_ERROR, TestAlgorithm() will CLEAR any bit in 'toTest' for which it has -// no test. This allows the knowledge about which algorithms have test to be -// accessed through the interface that provides the test. -// Return Type: TPM_RC -// TPM_RC_CANCELED test was canceled -LIB_EXPORT -TPM_RC -CryptTestAlgorithm(TPM_ALG_ID alg, ALGORITHM_VECTOR* toTest); - -#endif // _CRYPT_SELF_TEST_FP_H_ diff --git a/src/tpm2/CryptoInterface.h b/src/tpm2/CryptoInterface.h deleted file mode 100644 index 0550c7474..000000000 --- a/src/tpm2/CryptoInterface.h +++ /dev/null @@ -1,66 +0,0 @@ -/********************************************************************************/ -/* */ -/* CryptoInterface header file */ -/* Written by Stefan Berger */ -/* IBM Thomas J. Watson Research Center */ -/* */ -/* (c) Copyright IBM Corporation 2017,2018. */ -/* */ -/* All rights reserved. */ -/* */ -/* Redistribution and use in source and binary forms, with or without */ -/* modification, are permitted provided that the following conditions are */ -/* met: */ -/* */ -/* Redistributions of source code must retain the above copyright notice, */ -/* this list of conditions and the following disclaimer. */ -/* */ -/* Redistributions in binary form must reproduce the above copyright */ -/* notice, this list of conditions and the following disclaimer in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* Neither the names of the IBM Corporation nor the names of its */ -/* contributors may be used to endorse or promote products derived from */ -/* this software without specific prior written permission. */ -/* */ -/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */ -/* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */ -/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR */ -/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */ -/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */ -/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */ -/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, */ -/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY */ -/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */ -/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE */ -/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/********************************************************************************/ - -//** Introduction -// -// This file contains prototypes that are common to all TPM crypto interfaces. -// -#ifndef CRYPTO_INTERFACE_H -#define CRYPTO_INTERFACE_H - -#include "TpmBuildSwitches.h" - -#if SIMULATION && CRYPTO_LIB_REPORTING - -typedef struct crypto_impl_description -{ - // The name of the crypto library, ASCII encoded. - char name[32]; - // The version of the crypto library, ASCII encoded. - char version[32]; -} _CRYPTO_IMPL_DESCRIPTION; - -// When building the simulator, the plugged-in crypto libraries can report its -// version information by implementing these interfaces. -void _crypto_GetSymImpl(_CRYPTO_IMPL_DESCRIPTION* result); -void _crypto_GetHashImpl(_CRYPTO_IMPL_DESCRIPTION* result); -void _crypto_GetMathImpl(_CRYPTO_IMPL_DESCRIPTION* result); - -#endif // SIMULATION && CRYPTO_LIB_REPORTING - -#endif // CRYPTO_INTERFACE_H diff --git a/src/tpm2/DA_fp.h b/src/tpm2/DA_fp.h deleted file mode 100644 index 68c7c4441..000000000 --- a/src/tpm2/DA_fp.h +++ /dev/null @@ -1,105 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: DA_fp.h 1490 2019-07-26 21:13:22Z 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 */ -/* */ -/********************************************************************************/ - -/*(Auto-generated) - * Created by TpmPrototypes; Version 3.0 July 18, 2017 - * Date: Apr 2, 2019 Time: 04:23:27PM - */ - -#ifndef _DA_FP_H_ -#define _DA_FP_H_ - -//*** DAPreInstall_Init() -// This function initializes the DA parameters to their manufacturer-default -// values. The default values are determined by a platform-specific specification. -// -// This function should not be called outside of a manufacturing or simulation -// environment. -// -// The DA parameters will be restored to these initial values by TPM2_Clear(). -void DAPreInstall_Init(void); - -//*** DAStartup() -// This function is called by TPM2_Startup() to initialize the DA parameters. -// In the case of Startup(CLEAR), use of lockoutAuth will be enabled if the -// lockout recovery time is 0. Otherwise, lockoutAuth will not be enabled until -// the TPM has been continuously powered for the lockoutRecovery time. -// -// This function requires that NV be available and not rate limiting. -BOOL DAStartup(STARTUP_TYPE type // IN: startup type -); - -//*** DARegisterFailure() -// This function is called when a authorization failure occurs on an entity -// that is subject to dictionary-attack protection. When a DA failure is -// triggered, register the failure by resetting the relevant self-healing -// timer to the current time. -void DARegisterFailure(TPM_HANDLE handle // IN: handle for failure -); - -//*** DASelfHeal() -// This function is called to check if sufficient time has passed to allow -// decrement of failedTries or to re-enable use of lockoutAuth. -// -// This function should be called when the time interval is updated. -void DASelfHeal(void); - -#endif // _DA_FP_H_ diff --git a/src/tpm2/DebugHelpers.c b/src/tpm2/DebugHelpers.c deleted file mode 100644 index b17f3cba1..000000000 --- a/src/tpm2/DebugHelpers.c +++ /dev/null @@ -1,147 +0,0 @@ -/********************************************************************************/ -/* */ -/* 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 */ -/* */ -/********************************************************************************/ - -//** Description -// -// This file contains the NV read and write access methods. This implementation -// uses RAM/file and does not manage the RAM/file as NV blocks. -// The implementation may become more sophisticated over time. -// - -//** Includes and Local -#include -#include -#include "Platform.h" - -#if CERTIFYX509_DEBUG - -const char* debugFileName = "DebugFile.txt"; - -//*** fileOpen() -// 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; -# if defined _MSC_VER - if(fopen_s(&f, fn, mode) != 0) - f = NULL; -# else - f = fopen(fn, mode); -# endif - return f; -} - -//*** DebugFileInit() -// This function initializes the file containing the debug data with the time of the -// file creation. -// Return Type: int -// 0 success -// != 0 error -int DebugFileInit(void) -{ - FILE* f = NULL; - time_t t = time(NULL); -// -// Get current date and time. -# if defined _MSC_VER - char timeString[100]; - ctime_s(timeString, (size_t)sizeof(timeString), &t); -# else - char* timeString; - timeString = ctime(&t); -# endif - // Try to open the debug file - f = fileOpen(debugFileName, "w"); - if(f) - { - // Initialize the contents with the time. - fprintf(f, "%s\n", timeString); - fclose(f); - return 0; - } - return -1; -} - -//*** DebugDumpBuffer() -void DebugDumpBuffer(int size, unsigned char* buf, const char* identifier) -{ - int i; - // - FILE* f = fileOpen(debugFileName, "a"); - if(!f) - return; - if(identifier) - fprintf(f, "%s\n", identifier); - if(buf) - { - for(i = 0; i < size; i++) - { - if(((i % 16) == 0) && (i)) - fprintf(f, "\n"); - fprintf(f, " %02X", buf[i]); - } - if((size % 16) != 0) - fprintf(f, "\n"); - } - fclose(f); -} - -#endif // CERTIFYX509_DEBUG diff --git a/src/tpm2/DebugHelpers_fp.h b/src/tpm2/DebugHelpers_fp.h deleted file mode 100644 index 6e74cd449..000000000 --- a/src/tpm2/DebugHelpers_fp.h +++ /dev/null @@ -1,83 +0,0 @@ -/********************************************************************************/ -/* */ -/* Debug Helper */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: DebugHelpers_fp.h 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 */ -/* */ -/********************************************************************************/ -#ifndef DEBUGHELPERS_FP_H -#define DEBUGHELPERS_FP_H - -int -DebugFileInit( - void - ); -void -DebugFileClose( - void - ); -void -DebugDumpBuffer( - int size, - unsigned char *buf, - const char *identifier - ); - - - - - -#endif diff --git a/src/tpm2/DictionaryAttackLockReset_fp.h b/src/tpm2/DictionaryAttackLockReset_fp.h deleted file mode 100644 index 571114c62..000000000 --- a/src/tpm2/DictionaryAttackLockReset_fp.h +++ /dev/null @@ -1,84 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: DictionaryAttackLockReset_fp.h 809 2016-11-16 18:31:54Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_DictionaryAttackLockReset // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_DICTIONARYATTACKLOCKRESET_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_DICTIONARYATTACKLOCKRESET_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_RH_LOCKOUT lockHandle; -} DictionaryAttackLockReset_In; - -// Response code modifiers -# define RC_DictionaryAttackLockReset_lockHandle (TPM_RC_H + TPM_RC_1) - -// Function prototype -TPM_RC -TPM2_DictionaryAttackLockReset(DictionaryAttackLockReset_In* in); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_DICTIONARYATTACKLOCKRESET_FP_H_ -#endif // CC_DictionaryAttackLockReset diff --git a/src/tpm2/DictionaryAttackParameters_fp.h b/src/tpm2/DictionaryAttackParameters_fp.h deleted file mode 100644 index cdf7c165b..000000000 --- a/src/tpm2/DictionaryAttackParameters_fp.h +++ /dev/null @@ -1,90 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: DictionaryAttackParameters_fp.h 1521 2019-11-15 21:00:47Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_DictionaryAttackParameters // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_DICTIONARYATTACKPARAMETERS_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_DICTIONARYATTACKPARAMETERS_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_RH_LOCKOUT lockHandle; - UINT32 newMaxTries; - UINT32 newRecoveryTime; - UINT32 lockoutRecovery; -} DictionaryAttackParameters_In; - -// Response code modifiers -# define RC_DictionaryAttackParameters_lockHandle (TPM_RC_H + TPM_RC_1) -# define RC_DictionaryAttackParameters_newMaxTries (TPM_RC_P + TPM_RC_1) -# define RC_DictionaryAttackParameters_newRecoveryTime (TPM_RC_P + TPM_RC_2) -# define RC_DictionaryAttackParameters_lockoutRecovery (TPM_RC_P + TPM_RC_3) - -// Function prototype -TPM_RC -TPM2_DictionaryAttackParameters(DictionaryAttackParameters_In* in); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_DICTIONARYATTACKPARAMETERS_FP_H_ -#endif // CC_DictionaryAttackParameters diff --git a/src/tpm2/Duplicate_fp.h b/src/tpm2/Duplicate_fp.h deleted file mode 100644 index 72d4539a8..000000000 --- a/src/tpm2/Duplicate_fp.h +++ /dev/null @@ -1,98 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: Duplicate_fp.h 809 2016-11-16 18:31:54Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_Duplicate // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_DUPLICATE_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_DUPLICATE_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_DH_OBJECT objectHandle; - TPMI_DH_OBJECT newParentHandle; - TPM2B_DATA encryptionKeyIn; - TPMT_SYM_DEF_OBJECT symmetricAlg; -} Duplicate_In; - -// Output structure definition -typedef struct -{ - TPM2B_DATA encryptionKeyOut; - TPM2B_PRIVATE duplicate; - TPM2B_ENCRYPTED_SECRET outSymSeed; -} Duplicate_Out; - -// Response code modifiers -# define RC_Duplicate_objectHandle (TPM_RC_H + TPM_RC_1) -# define RC_Duplicate_newParentHandle (TPM_RC_H + TPM_RC_2) -# define RC_Duplicate_encryptionKeyIn (TPM_RC_P + TPM_RC_1) -# define RC_Duplicate_symmetricAlg (TPM_RC_P + TPM_RC_2) - -// Function prototype -TPM_RC -TPM2_Duplicate(Duplicate_In* in, Duplicate_Out* out); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_DUPLICATE_FP_H_ -#endif // CC_Duplicate diff --git a/src/tpm2/DuplicationCommands.c b/src/tpm2/DuplicationCommands.c index 9e88d3418..e45ec96f8 100644 --- a/src/tpm2/DuplicationCommands.c +++ b/src/tpm2/DuplicationCommands.c @@ -59,93 +59,6 @@ /* */ /********************************************************************************/ -#include "Tpm.h" -#include "Duplicate_fp.h" -#if CC_Duplicate // Conditional expansion of this file -#include "Object_spt_fp.h" -TPM_RC -TPM2_Duplicate( - Duplicate_In *in, // IN: input parameter list - Duplicate_Out *out // OUT: output parameter list - ) -{ - TPM_RC result = TPM_RC_SUCCESS; - TPMT_SENSITIVE sensitive; - UINT16 innerKeySize = 0; // encrypt key size for inner wrap - OBJECT *object; - OBJECT *newParent; - TPM2B_DATA data; - // Input Validation - // Get duplicate object pointer - object = HandleToObject(in->objectHandle); - // Get new parent - newParent = HandleToObject(in->newParentHandle); - // duplicate key must have fixParent bit CLEAR. - if(IS_ATTRIBUTE(object->publicArea.objectAttributes, TPMA_OBJECT, fixedParent)) - return TPM_RCS_ATTRIBUTES + RC_Duplicate_objectHandle; - // Do not duplicate object with NULL nameAlg - if(object->publicArea.nameAlg == TPM_ALG_NULL) - return TPM_RCS_TYPE + RC_Duplicate_objectHandle; - // new parent key must be a storage object or TPM_RH_NULL - if(in->newParentHandle != TPM_RH_NULL - && !ObjectIsStorage(in->newParentHandle)) - return TPM_RCS_TYPE + RC_Duplicate_newParentHandle; - // If the duplicated object has encryptedDuplication SET, then there must be - // an inner wrapper and the new parent may not be TPM_RH_NULL - if(IS_ATTRIBUTE(object->publicArea.objectAttributes, TPMA_OBJECT, - encryptedDuplication)) - { - if(in->symmetricAlg.algorithm == TPM_ALG_NULL) - return TPM_RCS_SYMMETRIC + RC_Duplicate_symmetricAlg; - if(in->newParentHandle == TPM_RH_NULL) - return TPM_RCS_HIERARCHY + RC_Duplicate_newParentHandle; - } - if(in->symmetricAlg.algorithm == TPM_ALG_NULL) - { - // if algorithm is TPM_ALG_NULL, input key size must be 0 - if(in->encryptionKeyIn.t.size != 0) - return TPM_RCS_SIZE + RC_Duplicate_encryptionKeyIn; - } - else - { - // Get inner wrap key size - innerKeySize = in->symmetricAlg.keyBits.sym; - // If provided the input symmetric key must match the size of the algorithm - if(in->encryptionKeyIn.t.size != 0 - && in->encryptionKeyIn.t.size != (innerKeySize + 7) / 8) - return TPM_RCS_SIZE + RC_Duplicate_encryptionKeyIn; - } - // Command Output - if(in->newParentHandle != TPM_RH_NULL) - { - // Make encrypt key and its associated secret structure. A TPM_RC_KEY - // error may be returned at this point - out->outSymSeed.t.size = sizeof(out->outSymSeed.t.secret); - result = CryptSecretEncrypt(newParent, DUPLICATE_STRING, &data, - &out->outSymSeed); - if(result != TPM_RC_SUCCESS) - return result; - } - else - { - // Do not apply outer wrapper - data.t.size = 0; - out->outSymSeed.t.size = 0; - } - // Copy sensitive area - sensitive = object->sensitive; - // Prepare output private data from sensitive. - // Note: If there is no encryption key, one will be provided by - // SensitiveToDuplicate(). This is why the assignment of encryptionKeyIn to - // encryptionKeyOut will work properly and is not conditional. - SensitiveToDuplicate(&sensitive, &object->name.b, newParent, - object->publicArea.nameAlg, &data.b, - &in->symmetricAlg, &in->encryptionKeyIn, - &out->duplicate); - out->encryptionKeyOut = in->encryptionKeyIn; - return TPM_RC_SUCCESS; -} -#endif // CC_Duplicate #include "Tpm.h" #include "Rewrap_fp.h" #if CC_Rewrap // Conditional expansion of this file @@ -172,6 +85,8 @@ TPM2_Rewrap( // old parent key must be a storage object if(!ObjectIsStorage(in->oldParent)) return TPM_RCS_TYPE + RC_Rewrap_oldParent; + + pAssert_RC(oldParent != NULL); // Decrypt input secret data via asymmetric decryption. A // TPM_RC_VALUE, TPM_RC_KEY or unmarshal errors may be returned at this // point @@ -190,7 +105,7 @@ TPM2_Rewrap( hashSize = sizeof(UINT16) + CryptHashGetDigestSize(oldParent->publicArea.nameAlg); privateBlob.t.size = in->inDuplicate.t.size - hashSize; - pAssert(privateBlob.t.size <= sizeof(privateBlob.t.buffer)); + pAssert_RC(privateBlob.t.size <= sizeof(privateBlob.t.buffer)); MemoryCopy(privateBlob.t.buffer, in->inDuplicate.t.buffer + hashSize, privateBlob.t.size); } @@ -203,9 +118,13 @@ TPM2_Rewrap( { OBJECT *newParent; newParent = HandleToObject(in->newParent); + // New parent must be a storage object if(!ObjectIsStorage(in->newParent)) return TPM_RCS_TYPE + RC_Rewrap_newParent; + + pAssert_RC(newParent != NULL); + // Make new encrypt key and its associated secret structure. A // TPM_RC_VALUE error may be returned at this point if RSA algorithm is // enabled in TPM @@ -221,7 +140,7 @@ TPM2_Rewrap( // Note: this is mostly only an issue if there was no outer wrapper on // 'inDuplicate'. It could be as large as a TPM2B_PRIVATE buffer. If we add // a digest for an outer wrapper, it won't fit anymore. - if((privateBlob.t.size + hashSize) > sizeof(out->outDuplicate.t.buffer)) + if((size_t)(privateBlob.t.size + hashSize) > sizeof(out->outDuplicate.t.buffer)) return TPM_RCS_VALUE + RC_Rewrap_inDuplicate; // Command output out->outDuplicate.t.size = privateBlob.t.size; @@ -246,107 +165,3 @@ TPM2_Rewrap( return TPM_RC_SUCCESS; } #endif // CC_Rewrap -#include "Tpm.h" -#include "Import_fp.h" -#if CC_Import // Conditional expansion of this file -#include "Object_spt_fp.h" -TPM_RC -TPM2_Import( - Import_In *in, // IN: input parameter list - Import_Out *out // OUT: output parameter list - ) -{ - TPM_RC result = TPM_RC_SUCCESS; - OBJECT *parentObject; - TPM2B_DATA data; // symmetric key - TPMT_SENSITIVE sensitive; - TPM2B_NAME name; - TPMA_OBJECT attributes; - UINT16 innerKeySize = 0; // encrypt key size for inner - // wrapper - // Input Validation - // to save typing - attributes = in->objectPublic.publicArea.objectAttributes; - // FixedTPM and fixedParent must be CLEAR - if(IS_ATTRIBUTE(attributes, TPMA_OBJECT, fixedTPM) - || IS_ATTRIBUTE(attributes, TPMA_OBJECT, fixedParent)) - return TPM_RCS_ATTRIBUTES + RC_Import_objectPublic; - // Get parent pointer - parentObject = HandleToObject(in->parentHandle); - if(!ObjectIsParent(parentObject)) - return TPM_RCS_TYPE + RC_Import_parentHandle; - if(in->symmetricAlg.algorithm != TPM_ALG_NULL) - { - // Get inner wrap key size - innerKeySize = in->symmetricAlg.keyBits.sym; - // Input symmetric key must match the size of algorithm. - if(in->encryptionKey.t.size != (innerKeySize + 7) / 8) - return TPM_RCS_SIZE + RC_Import_encryptionKey; - } - else - { - // If input symmetric algorithm is NULL, input symmetric key size must - // be 0 as well - if(in->encryptionKey.t.size != 0) - return TPM_RCS_SIZE + RC_Import_encryptionKey; - // If encryptedDuplication is SET, then the object must have an inner - // wrapper - if(IS_ATTRIBUTE(attributes, TPMA_OBJECT, encryptedDuplication)) - return TPM_RCS_ATTRIBUTES + RC_Import_encryptionKey; - } - // See if there is an outer wrapper - if(in->inSymSeed.t.size != 0) - { - // in->inParentHandle is a parent, but in order to decrypt an outer wrapper, - // it must be able to do key exchange and a symmetric key can't do that. - if(parentObject->publicArea.type == TPM_ALG_SYMCIPHER) - return TPM_RCS_TYPE + RC_Import_parentHandle; - // Decrypt input secret data via asymmetric decryption. TPM_RC_ATTRIBUTES, - // TPM_RC_ECC_POINT, TPM_RC_INSUFFICIENT, TPM_RC_KEY, TPM_RC_NO_RESULT, - // TPM_RC_SIZE, TPM_RC_VALUE may be returned at this point - result = CryptSecretDecrypt(parentObject, NULL, DUPLICATE_STRING, - &in->inSymSeed, &data); - pAssert(result != TPM_RC_BINDING); - if(result != TPM_RC_SUCCESS) - return RcSafeAddToResult(result, RC_Import_inSymSeed); - } - else - { - // If encrytpedDuplication is set, then the object must have an outer - // wrapper - if(IS_ATTRIBUTE(attributes, TPMA_OBJECT, encryptedDuplication)) - return TPM_RCS_ATTRIBUTES + RC_Import_inSymSeed; - data.t.size = 0; - } - // Compute name of object - PublicMarshalAndComputeName(&(in->objectPublic.publicArea), &name); - if(name.t.size == 0) - return TPM_RCS_HASH + RC_Import_objectPublic; - // Retrieve sensitive from private. - // TPM_RC_INSUFFICIENT, TPM_RC_INTEGRITY, TPM_RC_SIZE may be returned here. - result = DuplicateToSensitive(&in->duplicate.b, &name.b, parentObject, - in->objectPublic.publicArea.nameAlg, - &data.b, &in->symmetricAlg, - &in->encryptionKey.b, &sensitive); - if(result != TPM_RC_SUCCESS) - return RcSafeAddToResult(result, RC_Import_duplicate); - // If the parent of this object has fixedTPM SET, then validate this - // object as if it were being loaded so that validation can be skipped - // when it is actually loaded. - if(IS_ATTRIBUTE(parentObject->publicArea.objectAttributes, TPMA_OBJECT, fixedTPM)) - { - result = ObjectLoad(NULL, NULL, &in->objectPublic.publicArea, - &sensitive, RC_Import_objectPublic, RC_Import_duplicate, - NULL); - } - // Command output - if(result == TPM_RC_SUCCESS) - { - // Prepare output private data from sensitive - SensitiveToPrivate(&sensitive, &name, parentObject, - in->objectPublic.publicArea.nameAlg, - &out->outPrivate); - } - return result; -} -#endif // CC_Import diff --git a/src/tpm2/EACommands.c b/src/tpm2/EACommands.c index 44eb88cf8..588a4c7f8 100644 --- a/src/tpm2/EACommands.c +++ b/src/tpm2/EACommands.c @@ -58,375 +58,6 @@ /* */ /********************************************************************************/ -#include "Tpm.h" -#include "Policy_spt_fp.h" -#include "PolicySigned_fp.h" -#include "RuntimeProfile_fp.h" - -#if CC_PolicySigned // Conditional expansion of this file - -/*(See part 3 specification) -// Include an asymmetrically signed authorization to the policy evaluation -*/ -// Return Type: TPM_RC -// TPM_RC_CPHASH cpHash was previously set to a different value -// TPM_RC_EXPIRED 'expiration' indicates a time in the past or -// 'expiration' is non-zero but no nonceTPM is present -// TPM_RC_NONCE 'nonceTPM' is not the nonce associated with the -// 'policySession' -// TPM_RC_SCHEME the signing scheme of 'auth' is not supported by the -// TPM -// TPM_RC_SIGNATURE the signature is not genuine -// TPM_RC_SIZE input cpHash has wrong size -TPM_RC -TPM2_PolicySigned(PolicySigned_In* in, // IN: input parameter list - PolicySigned_Out* out // OUT: output parameter list - ) -{ - TPM_RC result = TPM_RC_SUCCESS; - SESSION* session; - TPM2B_NAME entityName; - TPM2B_DIGEST authHash; - HASH_STATE hashState; - UINT64 authTimeout = 0; - // Input Validation - // Set up local pointers - session = SessionGet(in->policySession); // the session structure - - // Only do input validation if this is not a trial policy session - if(session->attributes.isTrialPolicy == CLEAR) - { - authTimeout = ComputeAuthTimeout(session, in->expiration, &in->nonceTPM); - - result = PolicyParameterChecks(session, - authTimeout, - &in->cpHashA, - &in->nonceTPM, - RC_PolicySigned_nonceTPM, - RC_PolicySigned_cpHashA, - RC_PolicySigned_expiration); - if(result != TPM_RC_SUCCESS) - return result; - // Re-compute the digest being signed - /*(See part 3 specification) - // The digest is computed as: - // aHash := hash ( nonceTPM | expiration | cpHashA | policyRef) - // where: - // hash() the hash associated with the signed authorization - // nonceTPM the nonceTPM value from the TPM2_StartAuthSession . - // response If the authorization is not limited to this - // session, the size of this value is zero. - // expiration time limit on authorization set by authorizing object. - // This 32-bit value is set to zero if the expiration - // time is not being set. - // cpHashA hash of the command parameters for the command being - // approved using the hash algorithm of the PSAP session. - // Set to NULLauth if the authorization is not limited - // to a specific command. - // policyRef hash of an opaque value determined by the authorizing - // object. Set to the NULLdigest if no hash is present. - */ - // Start hash - authHash.t.size = CryptHashStart(&hashState, CryptGetSignHashAlg(&in->auth)); - // If there is no digest size, then we don't have a verification function - // for this algorithm (e.g. TPM_ALG_ECDAA) so indicate that it is a - // bad scheme. - if(authHash.t.size == 0) - return TPM_RCS_SCHEME + RC_PolicySigned_auth; - - // nonceTPM - CryptDigestUpdate2B(&hashState, &in->nonceTPM.b); - - // expiration - CryptDigestUpdateInt(&hashState, sizeof(UINT32), in->expiration); - - // cpHashA - CryptDigestUpdate2B(&hashState, &in->cpHashA.b); - - // policyRef - CryptDigestUpdate2B(&hashState, &in->policyRef.b); - - // Complete digest - CryptHashEnd2B(&hashState, &authHash.b); - - // Validate Signature. A TPM_RC_SCHEME, TPM_RC_HANDLE or TPM_RC_SIGNATURE - // error may be returned at this point - result = CryptValidateSignature(in->authObject, &authHash, &in->auth); - if(result != TPM_RC_SUCCESS) - return RcSafeAddToResult(result, RC_PolicySigned_auth); - } - // Internal Data Update - // Update policy with input policyRef and name of authorization key - // These values are updated even if the session is a trial session - PolicyContextUpdate(TPM_CC_PolicySigned, - EntityGetName(in->authObject, &entityName), - &in->policyRef, - &in->cpHashA, - authTimeout, - session); - // Command Output - // Create ticket and timeout buffer if in->expiration < 0 and this is not - // a trial session. - // NOTE: PolicyParameterChecks() makes sure that nonceTPM is present - // when expiration is non-zero. - if(in->expiration < 0 && session->attributes.isTrialPolicy == CLEAR) - { - BOOL expiresOnReset = (in->nonceTPM.t.size == 0); - // Compute policy ticket - authTimeout &= ~EXPIRATION_BIT; - - result = TicketComputeAuth(TPM_ST_AUTH_SIGNED, - EntityGetHierarchy(in->authObject), - authTimeout, - expiresOnReset, - &in->cpHashA, - &in->policyRef, - &entityName, - &out->policyTicket); - if(result != TPM_RC_SUCCESS) - return result; - - // Generate timeout buffer. The format of output timeout buffer is - // TPM-specific. - // Note: In this implementation, the timeout buffer value is computed after - // the ticket is produced so, when the ticket is checked, the expiration - // flag needs to be extracted before the ticket is checked. - // In the Windows compatible version, the least-significant bit of the - // timeout value is used as a flag to indicate if the authorization expires - // on reset. The flag is the MSb. - out->timeout.t.size = sizeof(authTimeout); - if(expiresOnReset) - authTimeout |= EXPIRATION_BIT; - UINT64_TO_BYTE_ARRAY(authTimeout, out->timeout.t.buffer); - } - else - { - // Generate a null ticket. - // timeout buffer is null - out->timeout.t.size = 0; - - // authorization ticket is null - out->policyTicket.tag = TPM_ST_AUTH_SIGNED; - out->policyTicket.hierarchy = TPM_RH_NULL; - out->policyTicket.digest.t.size = 0; - } - return TPM_RC_SUCCESS; -} - -#endif // CC_PolicySigned - - -#include "Tpm.h" -#include "PolicySecret_fp.h" - -#if CC_PolicySecret // Conditional expansion of this file - -# include "Policy_spt_fp.h" -# include "NV_spt_fp.h" - -/*(See part 3 specification) -// Add a secret-based authorization to the policy evaluation -*/ -// Return Type: TPM_RC -// TPM_RC_CPHASH cpHash for policy was previously set to a -// value that is not the same as 'cpHashA' -// TPM_RC_EXPIRED 'expiration' indicates a time in the past -// TPM_RC_NONCE 'nonceTPM' does not match the nonce associated -// with 'policySession' -// TPM_RC_SIZE 'cpHashA' is not the size of a digest for the -// hash associated with 'policySession' -TPM_RC -TPM2_PolicySecret(PolicySecret_In* in, // IN: input parameter list - PolicySecret_Out* out // OUT: output parameter list - ) -{ - TPM_RC result; - SESSION* session; - TPM2B_NAME entityName; - UINT64 authTimeout = 0; - // Input Validation - // Get pointer to the session structure - session = SessionGet(in->policySession); - - //Only do input validation if this is not a trial policy session - if(session->attributes.isTrialPolicy == CLEAR) - { - authTimeout = ComputeAuthTimeout(session, in->expiration, &in->nonceTPM); - - result = PolicyParameterChecks(session, - authTimeout, - &in->cpHashA, - &in->nonceTPM, - RC_PolicySecret_nonceTPM, - RC_PolicySecret_cpHashA, - RC_PolicySecret_expiration); - if(result != TPM_RC_SUCCESS) - return result; - } - // Internal Data Update - // Update policy context with input policyRef and name of authorizing key - // This value is computed even for trial sessions. Possibly update the cpHash - PolicyContextUpdate(TPM_CC_PolicySecret, - EntityGetName(in->authHandle, &entityName), - &in->policyRef, - &in->cpHashA, - authTimeout, - session); - // Command Output - // Create ticket and timeout buffer if in->expiration < 0 and this is not - // a trial session. - // NOTE: PolicyParameterChecks() makes sure that nonceTPM is present - // when expiration is non-zero. - if(in->expiration < 0 && session->attributes.isTrialPolicy == CLEAR - && !NvIsPinPassIndex(in->authHandle)) - { - BOOL expiresOnReset = (in->nonceTPM.t.size == 0); - // Compute policy ticket - authTimeout &= ~EXPIRATION_BIT; - result = TicketComputeAuth(TPM_ST_AUTH_SECRET, - EntityGetHierarchy(in->authHandle), - authTimeout, - expiresOnReset, - &in->cpHashA, - &in->policyRef, - &entityName, - &out->policyTicket); - if(result != TPM_RC_SUCCESS) - return result; - - // Generate timeout buffer. The format of output timeout buffer is - // TPM-specific. - // Note: In this implementation, the timeout buffer value is computed after - // the ticket is produced so, when the ticket is checked, the expiration - // flag needs to be extracted before the ticket is checked. - out->timeout.t.size = sizeof(authTimeout); - // In the Windows compatible version, the least-significant bit of the - // timeout value is used as a flag to indicate if the authorization expires - // on reset. The flag is the MSb. - if(expiresOnReset) - authTimeout |= EXPIRATION_BIT; - UINT64_TO_BYTE_ARRAY(authTimeout, out->timeout.t.buffer); - } - else - { - // timeout buffer is null - out->timeout.t.size = 0; - - // authorization ticket is null - out->policyTicket.tag = TPM_ST_AUTH_SECRET; - out->policyTicket.hierarchy = TPM_RH_NULL; - out->policyTicket.digest.t.size = 0; - } - return TPM_RC_SUCCESS; -} - -#endif // CC_PolicySecret - -#include "Tpm.h" -#include "PolicyTicket_fp.h" - -#if CC_PolicyTicket // Conditional expansion of this file - -# include "Policy_spt_fp.h" - -/*(See part 3 specification) -// Include ticket to the policy evaluation -*/ -// Return Type: TPM_RC -// TPM_RC_CPHASH policy's cpHash was previously set to a different -// value -// TPM_RC_EXPIRED 'timeout' value in the ticket is in the past and the -// ticket has expired -// TPM_RC_SIZE 'timeout' or 'cpHash' has invalid size for the -// TPM_RC_TICKET 'ticket' is not valid -TPM_RC -TPM2_PolicyTicket(PolicyTicket_In* in // IN: input parameter list - ) -{ - TPM_RC result; - SESSION* session; - UINT64 authTimeout; - TPMT_TK_AUTH ticketToCompare; - TPM_CC commandCode = TPM_CC_PolicySecret; - BOOL expiresOnReset; - // Input Validation - - // Get pointer to the session structure - session = SessionGet(in->policySession); - - // NOTE: A trial policy session is not allowed to use this command. - // A ticket is used in place of a previously given authorization. Since - // a trial policy doesn't actually authenticate, the validated - // ticket is not necessary and, in place of using a ticket, one - // should use the intended authorization for which the ticket - // would be a substitute. - if(session->attributes.isTrialPolicy) - return TPM_RCS_ATTRIBUTES + RC_PolicyTicket_policySession; - // Restore timeout data. The format of timeout buffer is TPM-specific. - // In this implementation, the most significant bit of the timeout value is - // used as the flag to indicate that the ticket expires on TPM Reset or - // TPM Restart. The flag has to be removed before the parameters and ticket - // are checked. - if(in->timeout.t.size != sizeof(UINT64)) - return TPM_RCS_SIZE + RC_PolicyTicket_timeout; - authTimeout = BYTE_ARRAY_TO_UINT64(in->timeout.t.buffer); - - // extract the flag - expiresOnReset = (authTimeout & EXPIRATION_BIT) != 0; - authTimeout &= ~EXPIRATION_BIT; - - // Do the normal checks on the cpHashA and timeout values - result = PolicyParameterChecks(session, - authTimeout, - &in->cpHashA, - NULL, // no nonce - 0, // no bad nonce return - RC_PolicyTicket_cpHashA, - RC_PolicyTicket_timeout); - if(result != TPM_RC_SUCCESS) - return result; - // Validate Ticket - // Re-generate policy ticket by input parameters - result = TicketComputeAuth(in->ticket.tag, - in->ticket.hierarchy, - authTimeout, - expiresOnReset, - &in->cpHashA, - &in->policyRef, - &in->authName, - &ticketToCompare); - if(result != TPM_RC_SUCCESS) - return result; - - // Compare generated digest with input ticket digest - if(!MemoryEqual2B(&in->ticket.digest.b, &ticketToCompare.digest.b)) - return TPM_RCS_TICKET + RC_PolicyTicket_ticket; - - // Internal Data Update - - // Is this ticket to take the place of a TPM2_PolicySigned() or - // a TPM2_PolicySecret()? - if(in->ticket.tag == TPM_ST_AUTH_SIGNED) - commandCode = TPM_CC_PolicySigned; - else if(in->ticket.tag == TPM_ST_AUTH_SECRET) - commandCode = TPM_CC_PolicySecret; - else - // There could only be two possible tag values. Any other value should - // be caught by the ticket validation process. - FAIL(FATAL_ERROR_INTERNAL); - - // Update policy context - PolicyContextUpdate(commandCode, - &in->authName, - &in->policyRef, - &in->cpHashA, - authTimeout, - session); - - return TPM_RC_SUCCESS; -} - -#endif // CC_PolicyTicket #include "Tpm.h" #include "PolicyOR_fp.h" @@ -451,6 +82,7 @@ TPM2_PolicyOR(PolicyOR_In* in // IN: input parameter list // Get pointer to the session structure session = SessionGet(in->policySession); + pAssert_RC(session); // Compare and Update Internal Session policy if match for(i = 0; i < in->pHashList.count; i++) @@ -493,97 +125,6 @@ TPM2_PolicyOR(PolicyOR_In* in // IN: input parameter list #endif // CC_PolicyOR -#include "Tpm.h" - -#if CC_PolicyPCR // Conditional expansion of this file - -# include "PolicyPCR_fp.h" -# include "Marshal.h" - -/*(See part 3 specification) -// Add a PCR gate for a policy session -*/ -// Return Type: TPM_RC -// TPM_RC_VALUE if provided, 'pcrDigest' does not match the -// current PCR settings -// TPM_RC_PCR_CHANGED a previous TPM2_PolicyPCR() set -// pcrCounter and it has changed -TPM_RC -TPM2_PolicyPCR(PolicyPCR_In* in // IN: input parameter list - ) -{ - SESSION* session; - TPM2B_DIGEST pcrDigest; - BYTE pcrs[sizeof(TPML_PCR_SELECTION)]; - UINT32 pcrSize; - BYTE* buffer; - TPM_CC commandCode = TPM_CC_PolicyPCR; - HASH_STATE hashState; - // Input Validation - - // Get pointer to the session structure - session = SessionGet(in->policySession); - - // Compute current PCR digest - PCRComputeCurrentDigest(session->authHashAlg, &in->pcrs, &pcrDigest); - - // Do validation for non trial session - if(session->attributes.isTrialPolicy == CLEAR) - { - // Make sure that this is not going to invalidate a previous PCR check - if(session->pcrCounter != 0 && session->pcrCounter != gr.pcrCounter) - return TPM_RC_PCR_CHANGED; - - // If the caller specified the PCR digest and it does not - // match the current PCR settings, return an error.. - if(in->pcrDigest.t.size != 0) - { - if(!MemoryEqual2B(&in->pcrDigest.b, &pcrDigest.b)) - return TPM_RCS_VALUE + RC_PolicyPCR_pcrDigest; - } - } - else - { - // For trial session, just use the input PCR digest if one provided - // Note: It can't be too big because it is a TPM2B_DIGEST and the size - // would have been checked during unmarshaling - if(in->pcrDigest.t.size != 0) - pcrDigest = in->pcrDigest; - } - // Internal Data Update - // Update policy hash - // policyDigestnew = hash( policyDigestold || TPM_CC_PolicyPCR - // || PCRS || pcrDigest) - // Start hash - CryptHashStart(&hashState, session->authHashAlg); - - // add old digest - CryptDigestUpdate2B(&hashState, &session->u2.policyDigest.b); - - // add commandCode - CryptDigestUpdateInt(&hashState, sizeof(TPM_CC), commandCode); - - // add PCRS - buffer = pcrs; - pcrSize = TPML_PCR_SELECTION_Marshal(&in->pcrs, &buffer, NULL); - CryptDigestUpdate(&hashState, pcrSize, pcrs); - - // add PCR digest - CryptDigestUpdate2B(&hashState, &pcrDigest.b); - - // complete the hash and get the results - CryptHashEnd2B(&hashState, &session->u2.policyDigest.b); - - // update pcrCounter in session context for non trial session - if(session->attributes.isTrialPolicy == CLEAR) - { - session->pcrCounter = gr.pcrCounter; - } - - return TPM_RC_SUCCESS; -} - -#endif // CC_PolicyPCR #include "Tpm.h" #include "PolicyPhysicalPresence_fp.h" @@ -606,6 +147,7 @@ TPM2_PolicyPhysicalPresence(PolicyPhysicalPresence_In* in // IN: input paramete // Get pointer to the session structure session = SessionGet(in->policySession); + pAssert_RC(session); // Update policy hash // policyDigestnew = hash(policyDigestold || TPM_CC_PolicyPhysicalPresence) @@ -655,6 +197,7 @@ TPM2_PolicyLocality(PolicyLocality_In* in // IN: input parameter list // Get pointer to the session structure session = SessionGet(in->policySession); + pAssert_RC(session); // Get new locality setting in canonical form marshalBuffer[0] = 0; // Code analysis says that this is not initialized @@ -769,6 +312,7 @@ TPM2_PolicyNV(PolicyNV_In* in // IN: input parameter list // Get pointer to the session structure session = SessionGet(in->policySession); + pAssert_RC(session); //If this is a trial policy, skip all validations and the operation if(session->attributes.isTrialPolicy == CLEAR) @@ -882,6 +426,7 @@ TPM2_PolicyCounterTimer(PolicyCounterTimer_In* in // IN: input parameter list return TPM_RCS_RANGE; // Get pointer to the session structure session = SessionGet(in->policySession); + pAssert_RC(session); //If this is a trial policy, skip the check to see if the condition is met. if(session->attributes.isTrialPolicy == CLEAR) @@ -963,6 +508,7 @@ TPM2_PolicyCommandCode(PolicyCommandCode_In* in // IN: input parameter list // Get pointer to the session structure session = SessionGet(in->policySession); + pAssert_RC(session); if(session->commandCode != 0 && session->commandCode != in->code) return TPM_RCS_VALUE + RC_PolicyCommandCode_code; @@ -1021,6 +567,7 @@ TPM2_PolicyCpHash(PolicyCpHash_In* in // IN: input parameter list // Get pointer to the session structure session = SessionGet(in->policySession); + pAssert_RC(session); // A valid cpHash must have the same size as session hash digest // NOTE: the size of the digest can't be zero because TPM_ALG_NULL @@ -1087,6 +634,7 @@ TPM2_PolicyNameHash(PolicyNameHash_In* in // IN: input parameter list // Get pointer to the session structure session = SessionGet(in->policySession); + pAssert_RC(session); // A valid nameHash must have the same size as session hash digest // Since the authHashAlg for a session cannot be TPM_ALG_NULL, the digest size @@ -1152,6 +700,7 @@ TPM2_PolicyDuplicationSelect( // Get pointer to the session structure session = SessionGet(in->policySession); + pAssert_RC(session); // nameHash in session context must be empty if(session->u1.nameHash.t.size != 0) @@ -1210,104 +759,6 @@ TPM2_PolicyDuplicationSelect( #endif // CC_PolicyDuplicationSelect -#include "Tpm.h" -#include "PolicyAuthorize_fp.h" - -#if CC_PolicyAuthorize // Conditional expansion of this file - -# include "Policy_spt_fp.h" - -/*(See part 3 specification) -// Change policy by a signature from authority -*/ -// Return Type: TPM_RC -// TPM_RC_HASH hash algorithm in 'keyName' is not supported -// TPM_RC_SIZE 'keyName' is not the correct size for its hash algorithm -// TPM_RC_VALUE the current policyDigest of 'policySession' does not -// match 'approvedPolicy'; or 'checkTicket' doesn't match -// the provided values -TPM_RC -TPM2_PolicyAuthorize(PolicyAuthorize_In* in // IN: input parameter list - ) -{ - TPM_RC result = TPM_RC_SUCCESS; - SESSION* session; - TPM2B_DIGEST authHash; - HASH_STATE hashState; - TPMT_TK_VERIFIED ticket; - TPM_ALG_ID hashAlg; - UINT16 digestSize; - // Input Validation - - // Get pointer to the session structure - session = SessionGet(in->policySession); - - if(in->keySign.t.size < 2) - { - return TPM_RCS_SIZE + RC_PolicyAuthorize_keySign; - } - - // Extract from the Name of the key, the algorithm used to compute its Name - hashAlg = BYTE_ARRAY_TO_UINT16(in->keySign.t.name); - - // 'keySign' parameter needs to use a supported hash algorithm, otherwise - // can't tell how large the digest should be - if(!CryptHashIsValidAlg(hashAlg, FALSE)) - return TPM_RCS_HASH + RC_PolicyAuthorize_keySign; - - digestSize = CryptHashGetDigestSize(hashAlg); - if(digestSize != (in->keySign.t.size - 2)) - return TPM_RCS_SIZE + RC_PolicyAuthorize_keySign; - - //If this is a trial policy, skip all validations - if(session->attributes.isTrialPolicy == CLEAR) - { - // Check that "approvedPolicy" matches the current value of the - // policyDigest in policy session - if(!MemoryEqual2B(&session->u2.policyDigest.b, &in->approvedPolicy.b)) - return TPM_RCS_VALUE + RC_PolicyAuthorize_approvedPolicy; - - // Validate ticket TPMT_TK_VERIFIED - // Compute aHash. The authorizing object sign a digest - // aHash := hash(approvedPolicy || policyRef). - // Start hash - authHash.t.size = CryptHashStart(&hashState, hashAlg); - - // add approvedPolicy - CryptDigestUpdate2B(&hashState, &in->approvedPolicy.b); - - // add policyRef - CryptDigestUpdate2B(&hashState, &in->policyRef.b); - - // complete hash - CryptHashEnd2B(&hashState, &authHash.b); - - // re-compute TPMT_TK_VERIFIED - result = TicketComputeVerified(in->checkTicket.hierarchy, &authHash, - &in->keySign, &ticket); - if(result != TPM_RC_SUCCESS) - return result; - - // Compare ticket digest. If not match, return error - if(!MemoryEqual2B(&in->checkTicket.digest.b, &ticket.digest.b)) - return TPM_RCS_VALUE + RC_PolicyAuthorize_checkTicket; - } - - // Internal Data Update - - // Set policyDigest to zero digest - PolicyDigestClear(session); - - // Update policyDigest - PolicyContextUpdate( - TPM_CC_PolicyAuthorize, &in->keySign, &in->policyRef, NULL, 0, session); - - return TPM_RC_SUCCESS; -} - -#endif // CC_PolicyAuthorize - - #include "Tpm.h" #include "PolicyAuthValue_fp.h" @@ -1330,6 +781,7 @@ TPM2_PolicyAuthValue(PolicyAuthValue_In* in // IN: input parameter list // Get pointer to the session structure session = SessionGet(in->policySession); + pAssert_RC(session); // Update policy hash // policyDigestnew = hash(policyDigestold || TPM_CC_PolicyAuthValue) @@ -1377,6 +829,7 @@ TPM2_PolicyPassword(PolicyPassword_In* in // IN: input parameter list // Get pointer to the session structure session = SessionGet(in->policySession); + pAssert_RC(session); // Update policy hash // policyDigestnew = hash(policyDigestold || TPM_CC_PolicyAuthValue) @@ -1415,6 +868,8 @@ TPM2_PolicyGetDigest( // Command Output // Get pointer to the session structure session = SessionGet(in->policySession); + pAssert_RC(session); + out->policyDigest = session->u2.policyDigest; return TPM_RC_SUCCESS; } @@ -1441,6 +896,7 @@ TPM2_PolicyNvWritten(PolicyNvWritten_In* in // IN: input parameter list // Get pointer to the session structure session = SessionGet(in->policySession); + pAssert_RC(session); // If already set is this a duplicate (the same setting)? If it // is a conflicting setting, it is an error @@ -1504,6 +960,7 @@ TPM2_PolicyTemplate(PolicyTemplate_In* in // IN: input parameter list // Get pointer to the session structure session = SessionGet(in->policySession); + pAssert_RC(session); // error if the templateHash in session context is not empty and is not the // same as the input or is not a template @@ -1544,95 +1001,6 @@ TPM2_PolicyTemplate(PolicyTemplate_In* in // IN: input parameter list #endif // CC_PolicyTemplate -#include "Tpm.h" - -#if CC_PolicyAuthorizeNV // Conditional expansion of this file - -# include "PolicyAuthorizeNV_fp.h" -# include "Policy_spt_fp.h" -# include "Marshal.h" - -/*(See part 3 specification) -// Change policy by a signature from authority -*/ -// Return Type: TPM_RC -// TPM_RC_HASH hash algorithm in 'keyName' is not supported or is not -// the same as the hash algorithm of the policy session -// TPM_RC_SIZE 'keyName' is not the correct size for its hash algorithm -// TPM_RC_VALUE the current policyDigest of 'policySession' does not -// match 'approvedPolicy'; or 'checkTicket' doesn't match -// the provided values -TPM_RC -TPM2_PolicyAuthorizeNV(PolicyAuthorizeNV_In* in) -{ - SESSION* session; - TPM_RC result; - NV_REF locator; - NV_INDEX* nvIndex = NvGetIndexInfo(in->nvIndex, &locator); - TPM2B_NAME name; - TPMT_HA policyInNv = { - .hashAlg = 0, // libpms added: Coverity - }; - BYTE nvTemp[sizeof(TPMT_HA)]; - BYTE* buffer = nvTemp; - INT32 size; - // Input Validation - // Get pointer to the session structure - session = SessionGet(in->policySession); - - // Skip checks if this is a trial policy - if(!session->attributes.isTrialPolicy) - { - // Check the authorizations for reading - // Common read access checks. NvReadAccessChecks() returns - // TPM_RC_NV_AUTHORIZATION, TPM_RC_NV_LOCKED, or TPM_RC_NV_UNINITIALIZED - // error may be returned at this point - result = NvReadAccessChecks( - in->authHandle, in->nvIndex, nvIndex->publicArea.attributes); - if(result != TPM_RC_SUCCESS) - return result; - - // Read the contents of the index into a temp buffer - size = MIN(nvIndex->publicArea.dataSize, sizeof(TPMT_HA)); - NvGetIndexData(nvIndex, locator, 0, (UINT16)size, nvTemp); - - // Unmarshal the contents of the buffer into the internal format of a - // TPMT_HA so that the hash and digest elements can be accessed from the - // structure rather than the byte array that is in the Index (written by - // user of the Index). - result = TPMT_HA_Unmarshal(&policyInNv, &buffer, &size, FALSE); - if(result != TPM_RC_SUCCESS) - return result; - - // Verify that the hash is the same - if(policyInNv.hashAlg != session->authHashAlg) - return TPM_RC_HASH; - - // See if the contents of the digest in the Index matches the value - // in the policy - if(!MemoryEqual(&policyInNv.digest, - &session->u2.policyDigest.t.buffer, - session->u2.policyDigest.t.size)) - return TPM_RC_VALUE; - } - - // Internal Data Update - - // Set policyDigest to zero digest - PolicyDigestClear(session); - - // Update policyDigest - PolicyContextUpdate(TPM_CC_PolicyAuthorizeNV, - EntityGetName(in->nvIndex, &name), - NULL, - NULL, - 0, - session); - - return TPM_RC_SUCCESS; -} - -#endif // CC_PolicyAuthorizeNV #include "Tpm.h" #include "PolicyCapability_fp.h" @@ -1695,6 +1063,7 @@ TPM2_PolicyCapability(PolicyCapability_In* in // IN: input parameter list // Get pointer to the session structure session = SessionGet(in->policySession); + pAssert_RC(session); if(session->attributes.isTrialPolicy == CLEAR) { @@ -1932,6 +1301,7 @@ TPM2_PolicyParameters(PolicyParameters_In* in // IN: input parameter list // Get pointer to the session structure session = SessionGet(in->policySession); + pAssert_RC(session); // A valid pHash must have the same size as session hash digest // Since the authHashAlg for a session cannot be TPM_ALG_NULL, the digest size diff --git a/src/tpm2/ECC_Parameters_fp.h b/src/tpm2/ECC_Parameters_fp.h deleted file mode 100644 index 1314bd9e3..000000000 --- a/src/tpm2/ECC_Parameters_fp.h +++ /dev/null @@ -1,90 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: ECC_Parameters_fp.h 809 2016-11-16 18:31:54Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_ECC_Parameters // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_ECC_PARAMETERS_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_ECC_PARAMETERS_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_ECC_CURVE curveID; -} ECC_Parameters_In; - -// Output structure definition -typedef struct -{ - TPMS_ALGORITHM_DETAIL_ECC parameters; -} ECC_Parameters_Out; - -// Response code modifiers -# define RC_ECC_Parameters_curveID (TPM_RC_P + TPM_RC_1) - -// Function prototype -TPM_RC -TPM2_ECC_Parameters(ECC_Parameters_In* in, ECC_Parameters_Out* out); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_ECC_PARAMETERS_FP_H_ -#endif // CC_ECC_Parameters diff --git a/src/tpm2/ECDH_KeyGen_fp.h b/src/tpm2/ECDH_KeyGen_fp.h deleted file mode 100644 index 1ec59874e..000000000 --- a/src/tpm2/ECDH_KeyGen_fp.h +++ /dev/null @@ -1,91 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: ECDH_KeyGen_fp.h 809 2016-11-16 18:31:54Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_ECDH_KeyGen // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_ECDH_KEYGEN_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_ECDH_KEYGEN_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_DH_OBJECT keyHandle; -} ECDH_KeyGen_In; - -// Output structure definition -typedef struct -{ - TPM2B_ECC_POINT zPoint; - TPM2B_ECC_POINT pubPoint; -} ECDH_KeyGen_Out; - -// Response code modifiers -# define RC_ECDH_KeyGen_keyHandle (TPM_RC_H + TPM_RC_1) - -// Function prototype -TPM_RC -TPM2_ECDH_KeyGen(ECDH_KeyGen_In* in, ECDH_KeyGen_Out* out); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_ECDH_KEYGEN_FP_H_ -#endif // CC_ECDH_KeyGen diff --git a/src/tpm2/ECDH_ZGen_fp.h b/src/tpm2/ECDH_ZGen_fp.h deleted file mode 100644 index c7af17adb..000000000 --- a/src/tpm2/ECDH_ZGen_fp.h +++ /dev/null @@ -1,92 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: ECDH_ZGen_fp.h 809 2016-11-16 18:31:54Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_ECDH_ZGen // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_ECDH_ZGEN_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_ECDH_ZGEN_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_DH_OBJECT keyHandle; - TPM2B_ECC_POINT inPoint; -} ECDH_ZGen_In; - -// Output structure definition -typedef struct -{ - TPM2B_ECC_POINT outPoint; -} ECDH_ZGen_Out; - -// Response code modifiers -# define RC_ECDH_ZGen_keyHandle (TPM_RC_H + TPM_RC_1) -# define RC_ECDH_ZGen_inPoint (TPM_RC_P + TPM_RC_1) - -// Function prototype -TPM_RC -TPM2_ECDH_ZGen(ECDH_ZGen_In* in, ECDH_ZGen_Out* out); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_ECDH_ZGEN_FP_H_ -#endif // CC_ECDH_ZGen diff --git a/src/tpm2/EC_Ephemeral_fp.h b/src/tpm2/EC_Ephemeral_fp.h deleted file mode 100644 index dc004fab4..000000000 --- a/src/tpm2/EC_Ephemeral_fp.h +++ /dev/null @@ -1,91 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: EC_Ephemeral_fp.h 1521 2019-11-15 21:00:47Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_EC_Ephemeral // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_EC_EPHEMERAL_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_EC_EPHEMERAL_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_ECC_CURVE curveID; -} EC_Ephemeral_In; - -// Output structure definition -typedef struct -{ - TPM2B_ECC_POINT Q; - UINT16 counter; -} EC_Ephemeral_Out; - -// Response code modifiers -# define RC_EC_Ephemeral_curveID (TPM_RC_P + TPM_RC_1) - -// Function prototype -TPM_RC -TPM2_EC_Ephemeral(EC_Ephemeral_In* in, EC_Ephemeral_Out* out); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_EC_EPHEMERAL_FP_H_ -#endif // CC_EC_Ephemeral diff --git a/src/tpm2/EncryptDecrypt2_fp.h b/src/tpm2/EncryptDecrypt2_fp.h deleted file mode 100644 index 71fb7df66..000000000 --- a/src/tpm2/EncryptDecrypt2_fp.h +++ /dev/null @@ -1,99 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: EncryptDecrypt2_fp.h 1047 2017-07-20 18:27:34Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015, 2016 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_EncryptDecrypt2 // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_ENCRYPTDECRYPT2_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_ENCRYPTDECRYPT2_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_DH_OBJECT keyHandle; - TPM2B_MAX_BUFFER inData; - TPMI_YES_NO decrypt; - TPMI_ALG_CIPHER_MODE mode; - TPM2B_IV ivIn; -} EncryptDecrypt2_In; - -// Output structure definition -typedef struct -{ - TPM2B_MAX_BUFFER outData; - TPM2B_IV ivOut; -} EncryptDecrypt2_Out; - -// Response code modifiers -# define RC_EncryptDecrypt2_keyHandle (TPM_RC_H + TPM_RC_1) -# define RC_EncryptDecrypt2_inData (TPM_RC_P + TPM_RC_1) -# define RC_EncryptDecrypt2_decrypt (TPM_RC_P + TPM_RC_2) -# define RC_EncryptDecrypt2_mode (TPM_RC_P + TPM_RC_3) -# define RC_EncryptDecrypt2_ivIn (TPM_RC_P + TPM_RC_4) - -// Function prototype -TPM_RC -TPM2_EncryptDecrypt2(EncryptDecrypt2_In* in, EncryptDecrypt2_Out* out); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_ENCRYPTDECRYPT2_FP_H_ -#endif // CC_EncryptDecrypt2 diff --git a/src/tpm2/EncryptDecrypt_fp.h b/src/tpm2/EncryptDecrypt_fp.h deleted file mode 100644 index 37cf77342..000000000 --- a/src/tpm2/EncryptDecrypt_fp.h +++ /dev/null @@ -1,99 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: EncryptDecrypt_fp.h 1521 2019-11-15 21:00:47Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_EncryptDecrypt // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_ENCRYPTDECRYPT_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_ENCRYPTDECRYPT_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_DH_OBJECT keyHandle; - TPMI_YES_NO decrypt; - TPMI_ALG_CIPHER_MODE mode; - TPM2B_IV ivIn; - TPM2B_MAX_BUFFER inData; -} EncryptDecrypt_In; - -// Output structure definition -typedef struct -{ - TPM2B_MAX_BUFFER outData; - TPM2B_IV ivOut; -} EncryptDecrypt_Out; - -// Response code modifiers -# define RC_EncryptDecrypt_keyHandle (TPM_RC_H + TPM_RC_1) -# define RC_EncryptDecrypt_decrypt (TPM_RC_P + TPM_RC_1) -# define RC_EncryptDecrypt_mode (TPM_RC_P + TPM_RC_2) -# define RC_EncryptDecrypt_ivIn (TPM_RC_P + TPM_RC_3) -# define RC_EncryptDecrypt_inData (TPM_RC_P + TPM_RC_4) - -// Function prototype -TPM_RC -TPM2_EncryptDecrypt(EncryptDecrypt_In* in, EncryptDecrypt_Out* out); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_ENCRYPTDECRYPT_FP_H_ -#endif // CC_EncryptDecrypt diff --git a/src/tpm2/EncryptDecrypt_spt_fp.h b/src/tpm2/EncryptDecrypt_spt_fp.h deleted file mode 100644 index bca20b703..000000000 --- a/src/tpm2/EncryptDecrypt_spt_fp.h +++ /dev/null @@ -1,89 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: EncryptDecrypt_spt_fp.h 809 2016-11-16 18:31:54Z 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 */ -/* */ -/********************************************************************************/ - -/*(Auto-generated) - * Created by TpmPrototypes; Version 3.0 July 18, 2017 - * Date: Mar 28, 2019 Time: 08:25:18PM - */ - -#ifndef _ENCRYPT_DECRYPT_SPT_FP_H_ -#define _ENCRYPT_DECRYPT_SPT_FP_H_ - -#if CC_EncryptDecrypt2 - -// Return Type: TPM_RC -// TPM_RC_KEY is not a symmetric decryption key with both -// public and private portions loaded -// TPM_RC_SIZE 'IvIn' size is incompatible with the block cipher mode; -// or 'inData' size is not an even multiple of the block -// size for CBC or ECB mode -// TPM_RC_VALUE 'keyHandle' is restricted and the argument 'mode' does -// not match the key's mode -TPM_RC -EncryptDecryptShared(TPMI_DH_OBJECT keyHandleIn, - TPMI_YES_NO decryptIn, - TPMI_ALG_SYM_MODE modeIn, - TPM2B_IV* ivIn, - TPM2B_MAX_BUFFER* inData, - EncryptDecrypt_Out* out); -#endif // CC_EncryptDecrypt - -#endif // _ENCRYPT_DECRYPT_SPT_FP_H_ diff --git a/src/tpm2/Entity_fp.h b/src/tpm2/Entity_fp.h deleted file mode 100644 index e93f9c207..000000000 --- a/src/tpm2/Entity_fp.h +++ /dev/null @@ -1,129 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: Entity_fp.h 1490 2019-07-26 21:13:22Z 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 */ -/* */ -/********************************************************************************/ - -/*(Auto-generated) - * Created by TpmPrototypes; Version 3.0 July 18, 2017 - * Date: Mar 7, 2020 Time: 07:19:36PM - */ - -#ifndef _ENTITY_FP_H_ -#define _ENTITY_FP_H_ - -//** Functions -//*** EntityGetLoadStatus() -// This function will check that all the handles access loaded entities. -// Return Type: TPM_RC -// TPM_RC_HANDLE handle type does not match -// TPM_RC_REFERENCE_Hx entity is not present -// TPM_RC_HIERARCHY entity belongs to a disabled hierarchy -// TPM_RC_OBJECT_MEMORY handle is an evict object but there is no -// space to load it to RAM -TPM_RC -EntityGetLoadStatus(COMMAND* command // IN/OUT: command parsing structure -); - -//*** EntityGetAuthValue() -// This function is used to access the 'authValue' associated with a handle. -// This function assumes that the handle references an entity that is accessible -// and the handle is not for a persistent objects. That is EntityGetLoadStatus() -// should have been called. Also, the accessibility of the authValue should have -// been verified by IsAuthValueAvailable(). -// -// This function copies the authorization value of the entity to 'auth'. -// Return Type: UINT16 -// count number of bytes in the authValue with 0's stripped -UINT16 -EntityGetAuthValue(TPMI_DH_ENTITY handle, // IN: handle of entity - TPM2B_AUTH* auth // OUT: authValue of the entity -); - -//*** EntityGetAuthPolicy() -// This function is used to access the 'authPolicy' associated with a handle. -// This function assumes that the handle references an entity that is accessible -// and the handle is not for a persistent objects. That is EntityGetLoadStatus() -// should have been called. Also, the accessibility of the authPolicy should have -// been verified by IsAuthPolicyAvailable(). -// -// This function copies the authorization policy of the entity to 'authPolicy'. -// -// The return value is the hash algorithm for the policy. -TPMI_ALG_HASH -EntityGetAuthPolicy(TPMI_DH_ENTITY handle, // IN: handle of entity - TPM2B_DIGEST* authPolicy // OUT: authPolicy of the entity -); - -//*** EntityGetName() -// This function returns the Name associated with a handle. -TPM2B_NAME* EntityGetName(TPMI_DH_ENTITY handle, // IN: handle of entity - TPM2B_NAME* name // OUT: name of entity -); - -//*** EntityGetHierarchy() -// This function returns the hierarchy handle associated with an entity. -// a) A handle that is a hierarchy handle is associated with itself. -// b) An NV index belongs to TPM_RH_PLATFORM if TPMA_NV_PLATFORMCREATE, -// is SET, otherwise it belongs to TPM_RH_OWNER -// c) An object handle belongs to its hierarchy. -TPMI_RH_HIERARCHY -EntityGetHierarchy(TPMI_DH_ENTITY handle // IN :handle of entity -); - -#endif // _ENTITY_FP_H_ diff --git a/src/tpm2/EphemeralCommands.c b/src/tpm2/EphemeralCommands.c index 84f98704c..9b0db4dea 100644 --- a/src/tpm2/EphemeralCommands.c +++ b/src/tpm2/EphemeralCommands.c @@ -100,6 +100,7 @@ TPM2_Commit(Commit_In* in, // IN: input parameter list return TPM_RC_TYPE; // libtpms added end eccKey = HandleToObject(in->signHandle); + pAssert_RC(eccKey != NULL); parms = &eccKey->publicArea.parameters.eccDetail; // Input key must be an ECC key diff --git a/src/tpm2/EventSequenceComplete_fp.h b/src/tpm2/EventSequenceComplete_fp.h deleted file mode 100644 index 6ca9ef9d5..000000000 --- a/src/tpm2/EventSequenceComplete_fp.h +++ /dev/null @@ -1,95 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: EventSequenceComplete_fp.h 809 2016-11-16 18:31:54Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_EventSequenceComplete // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_EVENTSEQUENCECOMPLETE_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_EVENTSEQUENCECOMPLETE_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_DH_PCR pcrHandle; - TPMI_DH_OBJECT sequenceHandle; - TPM2B_MAX_BUFFER buffer; -} EventSequenceComplete_In; - -// Output structure definition -typedef struct -{ - TPML_DIGEST_VALUES results; -} EventSequenceComplete_Out; - -// Response code modifiers -# define RC_EventSequenceComplete_pcrHandle (TPM_RC_H + TPM_RC_1) -# define RC_EventSequenceComplete_sequenceHandle (TPM_RC_H + TPM_RC_2) -# define RC_EventSequenceComplete_buffer (TPM_RC_P + TPM_RC_1) - -// Function prototype -TPM_RC -TPM2_EventSequenceComplete(EventSequenceComplete_In* in, - EventSequenceComplete_Out* out); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_EVENTSEQUENCECOMPLETE_FP_H_ -#endif // CC_EventSequenceComplete diff --git a/src/tpm2/EvictControl_fp.h b/src/tpm2/EvictControl_fp.h deleted file mode 100644 index 57b9a91ec..000000000 --- a/src/tpm2/EvictControl_fp.h +++ /dev/null @@ -1,88 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: EvictControl_fp.h 1521 2019-11-15 21:00:47Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_EvictControl // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_EVICTCONTROL_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_EVICTCONTROL_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_RH_PROVISION auth; - TPMI_DH_OBJECT objectHandle; - TPMI_DH_PERSISTENT persistentHandle; -} EvictControl_In; - -// Response code modifiers -# define RC_EvictControl_auth (TPM_RC_H + TPM_RC_1) -# define RC_EvictControl_objectHandle (TPM_RC_H + TPM_RC_2) -# define RC_EvictControl_persistentHandle (TPM_RC_P + TPM_RC_1) - -// Function prototype -TPM_RC -TPM2_EvictControl(EvictControl_In* in); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_EVICTCONTROL_FP_H_ -#endif // CC_EvictControl diff --git a/src/tpm2/ExecCommand_fp.h b/src/tpm2/ExecCommand_fp.h deleted file mode 100644 index c2d25d6eb..000000000 --- a/src/tpm2/ExecCommand_fp.h +++ /dev/null @@ -1,114 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: ExecCommand_fp.h 1490 2019-07-26 21:13:22Z 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 */ -/* */ -/********************************************************************************/ - -/*(Auto-generated) - * Created by TpmPrototypes; Version 3.0 July 18, 2017 - * Date: Mar 28, 2019 Time: 08:25:19PM - */ - -#ifndef _EXEC_COMMAND_FP_H_ -#define _EXEC_COMMAND_FP_H_ - -//** ExecuteCommand() -// -// The function performs the following steps. -// -// a) Parses the command header from input buffer. -// b) Calls ParseHandleBuffer() to parse the handle area of the command. -// c) Validates that each of the handles references a loaded entity. -// d) Calls ParseSessionBuffer () to: -// 1) unmarshal and parse the session area; -// 2) check the authorizations; and -// 3) when necessary, decrypt a parameter. -// e) Calls CommandDispatcher() to: -// 1) unmarshal the command parameters from the command buffer; -// 2) call the routine that performs the command actions; and -// 3) marshal the responses into the response buffer. -// f) If any error occurs in any of the steps above create the error response -// and return. -// g) Calls BuildResponseSession() to: -// 1) when necessary, encrypt a parameter -// 2) build the response authorization sessions -// 3) update the audit sessions and nonces -// h) Calls BuildResponseHeader() to complete the construction of the response. -// -// 'responseSize' is set by the caller to the maximum number of bytes available in -// the output buffer. ExecuteCommand will adjust the value and return the number -// of bytes placed in the buffer. -// -// 'response' is also set by the caller to indicate the buffer into which -// ExecuteCommand is to place the response. -// -// 'request' and 'response' may point to the same buffer -// -// Note: As of February, 2016, the failure processing has been moved to the -// platform-specific code. When the TPM code encounters an unrecoverable failure, it -// will SET g_inFailureMode and call _plat__Fail(). That function should not return -// but may call ExecuteCommand(). -// -LIB_EXPORT void ExecuteCommand( - uint32_t requestSize, // IN: command buffer size - unsigned char* request, // IN: command buffer - uint32_t* responseSize, // IN/OUT: response buffer size - unsigned char** response // IN/OUT: response buffer -); - -#endif // _EXEC_COMMAND_FP_H_ diff --git a/src/tpm2/ExtraData.c b/src/tpm2/ExtraData.c deleted file mode 100644 index 7e8da7605..000000000 --- a/src/tpm2/ExtraData.c +++ /dev/null @@ -1,90 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* 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 */ -/* */ -/********************************************************************************/ - -//** Description -// -// This file contains routines that are called by the core library to allow the -// platform to use the Core storage structures for small amounts of related data. -// -// In this implementation, the buffers are all just set to 0xFF - -//** Includes and Data Definitions -#include -#include -#include -#include "Platform.h" - -//** _plat__GetPlatformManufactureData - -// This function allows the platform to provide a small amount of data to be -// stored as part of the TPM's PERSISTENT_DATA structure during manufacture. Of -// course the platform can store data separately as well, but this allows a -// simple platform implementation to store a few bytes of data without -// implementing a multi-layer storage system. This function is called on -// manufacture and CLEAR. The buffer will contain the last value provided -// to the Core library. -LIB_EXPORT void _plat__GetPlatformManufactureData(uint8_t* pPlatformPersistentData, - uint32_t bufferSize) -{ - if(bufferSize != 0) - { - memset((void*)pPlatformPersistentData, 0xFF, bufferSize); - } -} diff --git a/src/tpm2/FlushContext_fp.h b/src/tpm2/FlushContext_fp.h deleted file mode 100644 index 015b1e775..000000000 --- a/src/tpm2/FlushContext_fp.h +++ /dev/null @@ -1,84 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: FlushContext_fp.h 1521 2019-11-15 21:00:47Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_FlushContext // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_FLUSHCONTEXT_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_FLUSHCONTEXT_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_DH_CONTEXT flushHandle; -} FlushContext_In; - -// Response code modifiers -# define RC_FlushContext_flushHandle (TPM_RC_P + TPM_RC_1) - -// Function prototype -TPM_RC -TPM2_FlushContext(FlushContext_In* in); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_FLUSHCONTEXT_FP_H_ -#endif // CC_FlushContext diff --git a/src/tpm2/GetCapability_fp.h b/src/tpm2/GetCapability_fp.h deleted file mode 100644 index 01f9fb2a8..000000000 --- a/src/tpm2/GetCapability_fp.h +++ /dev/null @@ -1,95 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: GetCapability_fp.h 809 2016-11-16 18:31:54Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_GetCapability // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_GETCAPABILITY_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_GETCAPABILITY_FP_H_ - -// Input structure definition -typedef struct -{ - TPM_CAP capability; - UINT32 property; - UINT32 propertyCount; -} GetCapability_In; - -// Output structure definition -typedef struct -{ - TPMI_YES_NO moreData; - TPMS_CAPABILITY_DATA capabilityData; -} GetCapability_Out; - -// Response code modifiers -# define RC_GetCapability_capability (TPM_RC_P + TPM_RC_1) -# define RC_GetCapability_property (TPM_RC_P + TPM_RC_2) -# define RC_GetCapability_propertyCount (TPM_RC_P + TPM_RC_3) - -// Function prototype -TPM_RC -TPM2_GetCapability(GetCapability_In* in, GetCapability_Out* out); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_GETCAPABILITY_FP_H_ -#endif // CC_GetCapability diff --git a/src/tpm2/GetCommandAuditDigest_fp.h b/src/tpm2/GetCommandAuditDigest_fp.h deleted file mode 100644 index cd95554e1..000000000 --- a/src/tpm2/GetCommandAuditDigest_fp.h +++ /dev/null @@ -1,98 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: GetCommandAuditDigest_fp.h 809 2016-11-16 18:31:54Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_GetCommandAuditDigest // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_GETCOMMANDAUDITDIGEST_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_GETCOMMANDAUDITDIGEST_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_RH_ENDORSEMENT privacyHandle; - TPMI_DH_OBJECT signHandle; - TPM2B_DATA qualifyingData; - TPMT_SIG_SCHEME inScheme; -} GetCommandAuditDigest_In; - -// Output structure definition -typedef struct -{ - TPM2B_ATTEST auditInfo; - TPMT_SIGNATURE signature; -} GetCommandAuditDigest_Out; - -// Response code modifiers -# define RC_GetCommandAuditDigest_privacyHandle (TPM_RC_H + TPM_RC_1) -# define RC_GetCommandAuditDigest_signHandle (TPM_RC_H + TPM_RC_2) -# define RC_GetCommandAuditDigest_qualifyingData (TPM_RC_P + TPM_RC_1) -# define RC_GetCommandAuditDigest_inScheme (TPM_RC_P + TPM_RC_2) - -// Function prototype -TPM_RC -TPM2_GetCommandAuditDigest(GetCommandAuditDigest_In* in, - GetCommandAuditDigest_Out* out); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_GETCOMMANDAUDITDIGEST_FP_H_ -#endif // CC_GetCommandAuditDigest diff --git a/src/tpm2/GetRandom_fp.h b/src/tpm2/GetRandom_fp.h deleted file mode 100644 index bf72c5383..000000000 --- a/src/tpm2/GetRandom_fp.h +++ /dev/null @@ -1,90 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: GetRandom_fp.h 809 2016-11-16 18:31:54Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_GetRandom // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_GETRANDOM_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_GETRANDOM_FP_H_ - -// Input structure definition -typedef struct -{ - UINT16 bytesRequested; -} GetRandom_In; - -// Output structure definition -typedef struct -{ - TPM2B_DIGEST randomBytes; -} GetRandom_Out; - -// Response code modifiers -# define RC_GetRandom_bytesRequested (TPM_RC_P + TPM_RC_1) - -// Function prototype -TPM_RC -TPM2_GetRandom(GetRandom_In* in, GetRandom_Out* out); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_GETRANDOM_FP_H_ -#endif // CC_GetRandom diff --git a/src/tpm2/GetSessionAuditDigest_fp.h b/src/tpm2/GetSessionAuditDigest_fp.h deleted file mode 100644 index 9264b1c0d..000000000 --- a/src/tpm2/GetSessionAuditDigest_fp.h +++ /dev/null @@ -1,100 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: GetSessionAuditDigest_fp.h 809 2016-11-16 18:31:54Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_GetSessionAuditDigest // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_GETSESSIONAUDITDIGEST_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_GETSESSIONAUDITDIGEST_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_RH_ENDORSEMENT privacyAdminHandle; - TPMI_DH_OBJECT signHandle; - TPMI_SH_HMAC sessionHandle; - TPM2B_DATA qualifyingData; - TPMT_SIG_SCHEME inScheme; -} GetSessionAuditDigest_In; - -// Output structure definition -typedef struct -{ - TPM2B_ATTEST auditInfo; - TPMT_SIGNATURE signature; -} GetSessionAuditDigest_Out; - -// Response code modifiers -# define RC_GetSessionAuditDigest_privacyAdminHandle (TPM_RC_H + TPM_RC_1) -# define RC_GetSessionAuditDigest_signHandle (TPM_RC_H + TPM_RC_2) -# define RC_GetSessionAuditDigest_sessionHandle (TPM_RC_H + TPM_RC_3) -# define RC_GetSessionAuditDigest_qualifyingData (TPM_RC_P + TPM_RC_1) -# define RC_GetSessionAuditDigest_inScheme (TPM_RC_P + TPM_RC_2) - -// Function prototype -TPM_RC -TPM2_GetSessionAuditDigest(GetSessionAuditDigest_In* in, - GetSessionAuditDigest_Out* out); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_GETSESSIONAUDITDIGEST_FP_H_ -#endif // CC_GetSessionAuditDigest diff --git a/src/tpm2/GetTestResult_fp.h b/src/tpm2/GetTestResult_fp.h deleted file mode 100644 index d82cb792d..000000000 --- a/src/tpm2/GetTestResult_fp.h +++ /dev/null @@ -1,82 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: GetTestResult_fp.h 1521 2019-11-15 21:00:47Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2016 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_GetTestResult // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_GETTESTRESULT_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_GETTESTRESULT_FP_H_ - -// Output structure definition -typedef struct -{ - TPM2B_MAX_BUFFER outData; - TPM_RC testResult; -} GetTestResult_Out; - -// Function prototype -TPM_RC -TPM2_GetTestResult(GetTestResult_Out* out); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_GETTESTRESULT_FP_H_ -#endif // CC_GetTestResult diff --git a/src/tpm2/GetTime_fp.h b/src/tpm2/GetTime_fp.h deleted file mode 100644 index 2d3ec13e1..000000000 --- a/src/tpm2/GetTime_fp.h +++ /dev/null @@ -1,97 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: GetTime_fp.h 809 2016-11-16 18:31:54Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_GetTime // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_GETTIME_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_GETTIME_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_RH_ENDORSEMENT privacyAdminHandle; - TPMI_DH_OBJECT signHandle; - TPM2B_DATA qualifyingData; - TPMT_SIG_SCHEME inScheme; -} GetTime_In; - -// Output structure definition -typedef struct -{ - TPM2B_ATTEST timeInfo; - TPMT_SIGNATURE signature; -} GetTime_Out; - -// Response code modifiers -# define RC_GetTime_privacyAdminHandle (TPM_RC_H + TPM_RC_1) -# define RC_GetTime_signHandle (TPM_RC_H + TPM_RC_2) -# define RC_GetTime_qualifyingData (TPM_RC_P + TPM_RC_1) -# define RC_GetTime_inScheme (TPM_RC_P + TPM_RC_2) - -// Function prototype -TPM_RC -TPM2_GetTime(GetTime_In* in, GetTime_Out* out); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_GETTIME_FP_H_ -#endif // CC_GetTime diff --git a/src/tpm2/HMAC_Start_fp.h b/src/tpm2/HMAC_Start_fp.h deleted file mode 100644 index 687200c8a..000000000 --- a/src/tpm2/HMAC_Start_fp.h +++ /dev/null @@ -1,94 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: HMAC_Start_fp.h 809 2016-11-16 18:31:54Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_HMAC_Start // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_HMAC_START_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_HMAC_START_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_DH_OBJECT handle; - TPM2B_AUTH auth; - TPMI_ALG_HASH hashAlg; -} HMAC_Start_In; - -// Output structure definition -typedef struct -{ - TPMI_DH_OBJECT sequenceHandle; -} HMAC_Start_Out; - -// Response code modifiers -# define RC_HMAC_Start_handle (TPM_RC_H + TPM_RC_1) -# define RC_HMAC_Start_auth (TPM_RC_P + TPM_RC_1) -# define RC_HMAC_Start_hashAlg (TPM_RC_P + TPM_RC_2) - -// Function prototype -TPM_RC -TPM2_HMAC_Start(HMAC_Start_In* in, HMAC_Start_Out* out); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_HMAC_START_FP_H_ -#endif // CC_HMAC_Start diff --git a/src/tpm2/HMAC_fp.h b/src/tpm2/HMAC_fp.h deleted file mode 100644 index e483005eb..000000000 --- a/src/tpm2/HMAC_fp.h +++ /dev/null @@ -1,94 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: HMAC_fp.h 1521 2019-11-15 21:00:47Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_HMAC // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_HMAC_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_HMAC_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_DH_OBJECT handle; - TPM2B_MAX_BUFFER buffer; - TPMI_ALG_HASH hashAlg; -} HMAC_In; - -// Output structure definition -typedef struct -{ - TPM2B_DIGEST outHMAC; -} HMAC_Out; - -// Response code modifiers -# define RC_HMAC_handle (TPM_RC_H + TPM_RC_1) -# define RC_HMAC_buffer (TPM_RC_P + TPM_RC_1) -# define RC_HMAC_hashAlg (TPM_RC_P + TPM_RC_2) - -// Function prototype -TPM_RC -TPM2_HMAC(HMAC_In* in, HMAC_Out* out); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_HMAC_FP_H_ -#endif // CC_HMAC diff --git a/src/tpm2/Handle_fp.h b/src/tpm2/Handle_fp.h deleted file mode 100644 index a746a4756..000000000 --- a/src/tpm2/Handle_fp.h +++ /dev/null @@ -1,120 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* 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 */ -/* */ -/********************************************************************************/ - -/*(Auto-generated) - * Created by TpmPrototypes; Version 3.0 July 18, 2017 - * Date: Mar 28, 2019 Time: 08:25:19PM - */ - -#ifndef _HANDLE_FP_H_ -#define _HANDLE_FP_H_ - -//*** HandleGetType() -// This function returns the type of a handle which is the MSO of the handle. -TPM_HT -HandleGetType(TPM_HANDLE handle // IN: a handle to be checked -); - -//*** NextPermanentHandle() -// This function returns the permanent handle that is equal to the input value or -// is the next higher value. If there is no handle with the input value and there -// is no next higher value, it returns 0: -TPM_HANDLE -NextPermanentHandle(TPM_HANDLE inHandle // IN: the handle to check -); - -//*** PermanentCapGetHandles() -// This function returns a list of the permanent handles of PCR, started from -// 'handle'. If 'handle' is larger than the largest permanent handle, an empty list -// will be returned with 'more' set to NO. -// Return Type: TPMI_YES_NO -// YES if there are more handles available -// NO all the available handles has been returned -TPMI_YES_NO -PermanentCapGetHandles(TPM_HANDLE handle, // IN: start handle - UINT32 count, // IN: count of returned handles - TPML_HANDLE* handleList // OUT: list of handle -); - -//*** PermanentCapGetOneHandle() -// This function returns whether a permanent handle exists. -BOOL PermanentCapGetOneHandle(TPM_HANDLE handle // IN: handle -); - -//*** PermanentHandleGetPolicy() -// This function returns a list of the permanent handles of PCR, started from -// 'handle'. If 'handle' is larger than the largest permanent handle, an empty list -// will be returned with 'more' set to NO. -// Return Type: TPMI_YES_NO -// YES if there are more handles available -// NO all the available handles has been returned -TPMI_YES_NO -PermanentHandleGetPolicy(TPM_HANDLE handle, // IN: start handle - UINT32 count, // IN: max count of returned handles - TPML_TAGGED_POLICY* policyList // OUT: list of handle -); - -//*** PermanentHandleGetOnePolicy() -// This function returns a permanent handle's policy, if present. -BOOL PermanentHandleGetOnePolicy(TPM_HANDLE handle, // IN: handle - TPMS_TAGGED_POLICY* policy // OUT: tagged policy -); - -#endif // _HANDLE_FP_H_ diff --git a/src/tpm2/HashCommands.c b/src/tpm2/HashCommands.c index 44cb5bd2f..d2144b27b 100644 --- a/src/tpm2/HashCommands.c +++ b/src/tpm2/HashCommands.c @@ -74,7 +74,11 @@ TPM2_HMAC_Start( // Input Validation // Get HMAC key object and public area pointers keyObject = HandleToObject(in->handle); + pAssert_RC(keyObject != NULL); + publicArea = &keyObject->publicArea; + pAssert_RC(publicArea != NULL); + // Make sure that the key is an HMAC key if(publicArea->type != TPM_ALG_KEYEDHASH) return TPM_RCS_TYPE + RC_HMAC_Start_handle; @@ -130,7 +134,10 @@ TPM2_MAC_Start( // Input Validation // Get HMAC key object and public area pointers keyObject = HandleToObject(in->handle); + pAssert_RC(keyObject != NULL); publicArea = &keyObject->publicArea; + pAssert_RC(publicArea != NULL); + // Make sure that the key can do what is required result = CryptSelectMac(publicArea, &in->inScheme); // If the key is not able to do a MAC, indicate that the handle selects an @@ -192,6 +199,8 @@ TPM2_SequenceUpdate( // Check that referenced object is a sequence object. if(!ObjectIsSequence(object)) return TPM_RCS_MODE + RC_SequenceUpdate_sequenceHandle; + + pAssert_RC(object != NULL); // Internal Data Update if(object->attributes.eventSeq == SET) { @@ -247,6 +256,8 @@ TPM2_SequenceComplete( // Input validation // Get hash object pointer hashObject = (HASH_OBJECT *)HandleToObject(in->sequenceHandle); + pAssert_RC(hashObject != NULL); + // input handle must be a hash or HMAC sequence object. if(hashObject->attributes.hashSeq == CLEAR && hashObject->attributes.hmacSeq == CLEAR) @@ -332,6 +343,8 @@ TPM2_EventSequenceComplete( // Input validation // get the event sequence object pointer hashObject = (HASH_OBJECT *)HandleToObject(in->sequenceHandle); + pAssert_RC(hashObject != NULL); + // input handle must reference an event sequence object if(hashObject->attributes.eventSeq != SET) return TPM_RCS_MODE + RC_EventSequenceComplete_sequenceHandle; diff --git a/src/tpm2/HashSequenceStart_fp.h b/src/tpm2/HashSequenceStart_fp.h deleted file mode 100644 index fc3fbfed6..000000000 --- a/src/tpm2/HashSequenceStart_fp.h +++ /dev/null @@ -1,92 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: HashSequenceStart_fp.h 809 2016-11-16 18:31:54Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_HashSequenceStart // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_HASHSEQUENCESTART_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_HASHSEQUENCESTART_FP_H_ - -// Input structure definition -typedef struct -{ - TPM2B_AUTH auth; - TPMI_ALG_HASH hashAlg; -} HashSequenceStart_In; - -// Output structure definition -typedef struct -{ - TPMI_DH_OBJECT sequenceHandle; -} HashSequenceStart_Out; - -// Response code modifiers -# define RC_HashSequenceStart_auth (TPM_RC_P + TPM_RC_1) -# define RC_HashSequenceStart_hashAlg (TPM_RC_P + TPM_RC_2) - -// Function prototype -TPM_RC -TPM2_HashSequenceStart(HashSequenceStart_In* in, HashSequenceStart_Out* out); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_HASHSEQUENCESTART_FP_H_ -#endif // CC_HashSequenceStart diff --git a/src/tpm2/Hash_fp.h b/src/tpm2/Hash_fp.h deleted file mode 100644 index a1a7bd82f..000000000 --- a/src/tpm2/Hash_fp.h +++ /dev/null @@ -1,95 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: Hash_fp.h 1521 2019-11-15 21:00:47Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_Hash // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_HASH_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_HASH_FP_H_ - -// Input structure definition -typedef struct -{ - TPM2B_MAX_BUFFER data; - TPMI_ALG_HASH hashAlg; - TPMI_RH_HIERARCHY hierarchy; -} Hash_In; - -// Output structure definition -typedef struct -{ - TPM2B_DIGEST outHash; - TPMT_TK_HASHCHECK validation; -} Hash_Out; - -// Response code modifiers -# define RC_Hash_data (TPM_RC_P + TPM_RC_1) -# define RC_Hash_hashAlg (TPM_RC_P + TPM_RC_2) -# define RC_Hash_hierarchy (TPM_RC_P + TPM_RC_3) - -// Function prototype -TPM_RC -TPM2_Hash(Hash_In* in, Hash_Out* out); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_HASH_FP_H_ -#endif // CC_Hash diff --git a/src/tpm2/HierarchyChangeAuth_fp.h b/src/tpm2/HierarchyChangeAuth_fp.h deleted file mode 100644 index 4c615c613..000000000 --- a/src/tpm2/HierarchyChangeAuth_fp.h +++ /dev/null @@ -1,86 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: HierarchyChangeAuth_fp.h 809 2016-11-16 18:31:54Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_HierarchyChangeAuth // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_HIERARCHYCHANGEAUTH_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_HIERARCHYCHANGEAUTH_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_RH_HIERARCHY_AUTH authHandle; - TPM2B_AUTH newAuth; -} HierarchyChangeAuth_In; - -// Response code modifiers -# define RC_HierarchyChangeAuth_authHandle (TPM_RC_H + TPM_RC_1) -# define RC_HierarchyChangeAuth_newAuth (TPM_RC_P + TPM_RC_1) - -// Function prototype -TPM_RC -TPM2_HierarchyChangeAuth(HierarchyChangeAuth_In* in); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_HIERARCHYCHANGEAUTH_FP_H_ -#endif // CC_HierarchyChangeAuth diff --git a/src/tpm2/HierarchyCommands.c b/src/tpm2/HierarchyCommands.c index e68eab467..2cbeb5fcd 100644 --- a/src/tpm2/HierarchyCommands.c +++ b/src/tpm2/HierarchyCommands.c @@ -58,102 +58,6 @@ /* */ /********************************************************************************/ -#include "Tpm.h" -#include "CreatePrimary_fp.h" -#if CC_CreatePrimary // Conditional expansion of this file -TPM_RC -TPM2_CreatePrimary( - CreatePrimary_In *in, // IN: input parameter list - CreatePrimary_Out *out // OUT: output parameter list - ) -{ - TPM_RC result = TPM_RC_SUCCESS; - TPMT_PUBLIC *publicArea; - DRBG_STATE rand; - OBJECT *newObject; - TPM2B_NAME name; - TPM2B_SEED primary_seed; - // Input Validation - // Will need a place to put the result - newObject = FindEmptyObjectSlot(&out->objectHandle); - if(newObject == NULL) - return TPM_RC_OBJECT_MEMORY; - // Get the address of the public area in the new object - // (this is just to save typing) - publicArea = &newObject->publicArea; - - *publicArea = in->inPublic.publicArea; - - // Check attributes in input public area. CreateChecks() checks the things that - // are unique to creation and then validates the attributes and values that are - // common to create and load. - result = CreateChecks( - NULL, in->primaryHandle, publicArea, in->inSensitive.sensitive.data.t.size); - if(result != TPM_RC_SUCCESS) - return RcSafeAddToResult(result, RC_CreatePrimary_inPublic); - // Validate the sensitive area values - if(!AdjustAuthSize(&in->inSensitive.sensitive.userAuth, publicArea->nameAlg)) - return TPM_RCS_SIZE + RC_CreatePrimary_inSensitive; - // Command output - // Compute the name using out->name as a scratch area (this is not the value - // that ultimately will be returned, then instantiate the state that will be - // used as a random number generator during the object creation. - // The caller does not know the seed values so the actual name does not have - // to be over the input, it can be over the unmarshaled structure. - - result = HierarchyGetPrimarySeed(in->primaryHandle, &primary_seed); - if(result != TPM_RC_SUCCESS) - return result; - - result = - DRBG_InstantiateSeeded(&rand, - &primary_seed.b, - PRIMARY_OBJECT_CREATION, - (TPM2B*)PublicMarshalAndComputeName(publicArea, &name), - &in->inSensitive.sensitive.data.b, - HierarchyGetPrimarySeedCompatLevel(in->primaryHandle)); // libtpms added - MemorySet(primary_seed.b.buffer, 0, primary_seed.b.size); - - if(result == TPM_RC_SUCCESS) - { - newObject->attributes.primary = SET; - if(HierarchyNormalizeHandle(in->primaryHandle) == TPM_RH_ENDORSEMENT) - newObject->attributes.epsHierarchy = SET; - - // Create the primary object. - result = CryptCreateObject( - newObject, &in->inSensitive.sensitive, (RAND_STATE*)&rand); - DRBG_Uninstantiate(&rand); - } - if(result != TPM_RC_SUCCESS) - return result; - - // Set the publicArea and name from the computed values - out->outPublic.publicArea = newObject->publicArea; - out->name = newObject->name; - - // Fill in creation data - FillInCreationData(in->primaryHandle, - publicArea->nameAlg, - &in->creationPCR, - &in->outsideInfo, - &out->creationData, - &out->creationHash); - - // Compute creation ticket - result = TicketComputeCreation(EntityGetHierarchy(in->primaryHandle), - &out->name, - &out->creationHash, - &out->creationTicket); - if(result != TPM_RC_SUCCESS) - return result; - - // Set the remaining attributes for a loaded object - ObjectSetLoadedAttributes(newObject, in->primaryHandle, - HierarchyGetPrimarySeedCompatLevel(in->primaryHandle)); // libtpms added - return result; -} -#endif // CC_CreatePrimary #include "Tpm.h" #include "HierarchyControl_fp.h" #if CC_HierarchyControl // Conditional expansion of this file diff --git a/src/tpm2/HierarchyControl_fp.h b/src/tpm2/HierarchyControl_fp.h deleted file mode 100644 index 469a5a02f..000000000 --- a/src/tpm2/HierarchyControl_fp.h +++ /dev/null @@ -1,88 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: HierarchyControl_fp.h 809 2016-11-16 18:31:54Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_HierarchyControl // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_HIERARCHYCONTROL_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_HIERARCHYCONTROL_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_RH_BASE_HIERARCHY authHandle; - TPMI_RH_ENABLES enable; - TPMI_YES_NO state; -} HierarchyControl_In; - -// Response code modifiers -# define RC_HierarchyControl_authHandle (TPM_RC_H + TPM_RC_1) -# define RC_HierarchyControl_enable (TPM_RC_P + TPM_RC_1) -# define RC_HierarchyControl_state (TPM_RC_P + TPM_RC_2) - -// Function prototype -TPM_RC -TPM2_HierarchyControl(HierarchyControl_In* in); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_HIERARCHYCONTROL_FP_H_ -#endif // CC_HierarchyControl diff --git a/src/tpm2/Import_fp.h b/src/tpm2/Import_fp.h deleted file mode 100644 index 67d1e9829..000000000 --- a/src/tpm2/Import_fp.h +++ /dev/null @@ -1,100 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: Import_fp.h 809 2016-11-16 18:31:54Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_Import // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_IMPORT_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_IMPORT_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_DH_OBJECT parentHandle; - TPM2B_DATA encryptionKey; - TPM2B_PUBLIC objectPublic; - TPM2B_PRIVATE duplicate; - TPM2B_ENCRYPTED_SECRET inSymSeed; - TPMT_SYM_DEF_OBJECT symmetricAlg; -} Import_In; - -// Output structure definition -typedef struct -{ - TPM2B_PRIVATE outPrivate; -} Import_Out; - -// Response code modifiers -# define RC_Import_parentHandle (TPM_RC_H + TPM_RC_1) -# define RC_Import_encryptionKey (TPM_RC_P + TPM_RC_1) -# define RC_Import_objectPublic (TPM_RC_P + TPM_RC_2) -# define RC_Import_duplicate (TPM_RC_P + TPM_RC_3) -# define RC_Import_inSymSeed (TPM_RC_P + TPM_RC_4) -# define RC_Import_symmetricAlg (TPM_RC_P + TPM_RC_5) - -// Function prototype -TPM_RC -TPM2_Import(Import_In* in, Import_Out* out); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_IMPORT_FP_H_ -#endif // CC_Import diff --git a/src/tpm2/IncrementalSelfTest_fp.h b/src/tpm2/IncrementalSelfTest_fp.h deleted file mode 100644 index 4cecbb0d1..000000000 --- a/src/tpm2/IncrementalSelfTest_fp.h +++ /dev/null @@ -1,90 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: IncrementalSelfTest_fp.h 809 2016-11-16 18:31:54Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_IncrementalSelfTest // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_INCREMENTALSELFTEST_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_INCREMENTALSELFTEST_FP_H_ - -// Input structure definition -typedef struct -{ - TPML_ALG toTest; -} IncrementalSelfTest_In; - -// Output structure definition -typedef struct -{ - TPML_ALG toDoList; -} IncrementalSelfTest_Out; - -// Response code modifiers -# define RC_IncrementalSelfTest_toTest (TPM_RC_P + TPM_RC_1) - -// Function prototype -TPM_RC -TPM2_IncrementalSelfTest(IncrementalSelfTest_In* in, IncrementalSelfTest_Out* out); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_INCREMENTALSELFTEST_FP_H_ -#endif // CC_IncrementalSelfTest diff --git a/src/tpm2/IntegrityCommands.c b/src/tpm2/IntegrityCommands.c index f3b6d13b1..a5e100c85 100644 --- a/src/tpm2/IntegrityCommands.c +++ b/src/tpm2/IntegrityCommands.c @@ -140,23 +140,6 @@ TPM2_PCR_Event( } #endif // CC_PCR_Event #include "Tpm.h" -#include "PCR_Read_fp.h" -#if CC_PCR_Read // Conditional expansion of this file -TPM_RC -TPM2_PCR_Read( - PCR_Read_In *in, // IN: input parameter list - PCR_Read_Out *out // OUT: output parameter list - ) -{ - // Command Output - // Call PCR read function. input pcrSelectionIn parameter could be changed - // to reflect the actual PCR being returned - PCRRead(&in->pcrSelectionIn, &out->pcrValues, &out->pcrUpdateCounter); - out->pcrSelectionOut = in->pcrSelectionIn; - return TPM_RC_SUCCESS; -} -#endif // CC_PCR_Read -#include "Tpm.h" #include "PCR_Allocate_fp.h" #if CC_PCR_Allocate // Conditional expansion of this file TPM_RC @@ -272,19 +255,19 @@ TPM2_PCR_Reset( #include "Tpm.h" /* This function is called to process a _TPM_Hash_Start() indication. */ -LIB_EXPORT void -_TPM_Hash_Start( - void - ) +LIB_EXPORT BOOL _TPM_Hash_Start(void) { TPM_RC result; TPMI_DH_OBJECT handle; // If a DRTM sequence object exists, free it up if(g_DRTMHandle != TPM_RH_UNASSIGNED) - { - FlushObject(g_DRTMHandle); - g_DRTMHandle = TPM_RH_UNASSIGNED; - } + { + // ensure g_DRTMHandle is cleared + // and Flush sequence object + TPMI_DH_OBJECT oldHandle = g_DRTMHandle; + g_DRTMHandle = TPM_RH_UNASSIGNED; + VERIFY(FlushObject(oldHandle), FATAL_ERROR_INTERNAL, FALSE); + } // Create an event sequence object and store the handle in global // g_DRTMHandle. A TPM_RC_OBJECT_MEMORY error may be returned at this point // The NULL value for the first parameter will cause the sequence structure to @@ -312,23 +295,21 @@ _TPM_Hash_Start( // then there's a big problem pAssert(handle < TRANSIENT_LAST); // Free the slot - FlushObject(handle); + VERIFY(FlushObject(handle), FATAL_ERROR_INTERNAL, FALSE); // Try to create an event sequence object again. This time, we must // succeed. result = ObjectCreateEventSequence(NULL, &g_DRTMHandle); if(result != TPM_RC_SUCCESS) FAIL(FATAL_ERROR_INTERNAL); } - return; + return TRUE; } #include "Tpm.h" /* This function is called to process a _TPM_Hash_Data() indication. */ -LIB_EXPORT void -_TPM_Hash_Data( - uint32_t dataSize, // IN: size of data to be extend - unsigned char *data // IN: data buffer - ) +LIB_EXPORT BOOL _TPM_Hash_Data(uint32_t dataSize, // IN: size of data to be extend + unsigned char* data // IN: data buffer +) { UINT32 i; HASH_OBJECT *hashObject; @@ -338,9 +319,16 @@ _TPM_Hash_Data( // was not called so this function returns without doing // anything. if(g_DRTMHandle == TPM_RH_UNASSIGNED) - return; + { + // do not enter failure mode because this is an ordering issue that + // can be triggered by a BIOS issue, not an internal failure. + return FALSE; + } + hashObject = (HASH_OBJECT *)HandleToObject(g_DRTMHandle); + pAssert_BOOL(hashObject != NULL); pAssert(hashObject->attributes.eventSeq); + // For each of the implemented hash algorithms, update the digest with the // data provided. for(i = 0; i < HASH_COUNT; i++) @@ -351,15 +339,12 @@ _TPM_Hash_Data( // Update sequence object CryptDigestUpdate(&hashObject->state.hashState[i], dataSize, data); } - return; + return TRUE; } #include "Tpm.h" /* This function is called to process a _TPM_Hash_End() indication. */ -LIB_EXPORT void -_TPM_Hash_End( - void - ) +LIB_EXPORT BOOL _TPM_Hash_End(void) { UINT32 i; TPM2B_DIGEST digest; @@ -369,9 +354,17 @@ _TPM_Hash_End( // been called, _TPM_Hash_End was previously called, or some other command // was executed and the sequence was aborted. if(g_DRTMHandle == TPM_RH_UNASSIGNED) - return; + { + // do not enter failure mode because this is an ordering issue that + // can be triggered by a BIOS issue, not an internal failure. + return FALSE; + } + // Get DRTM sequence object hashObject = (HASH_OBJECT *)HandleToObject(g_DRTMHandle); + pAssert_BOOL(hashObject != NULL); + pAssert_BOOL(hashObject->attributes.eventSeq); + // Is this _TPM_Hash_End after Startup or before if(TPMIsStarted()) { @@ -404,8 +397,10 @@ _TPM_Hash_End( PcrDrtm(pcrHandle, hash, &digest); } } - // Flush sequence object. - FlushObject(g_DRTMHandle); - g_DRTMHandle = TPM_RH_UNASSIGNED; - return; + + // ensure g_DRTMHandle is cleared + // and Flush sequence object + TPMI_DH_OBJECT oldHandle = g_DRTMHandle; + g_DRTMHandle = TPM_RH_UNASSIGNED; + return FlushObject(oldHandle); } diff --git a/src/tpm2/InternalRoutines.h b/src/tpm2/InternalRoutines.h deleted file mode 100644 index 1b598b808..000000000 --- a/src/tpm2/InternalRoutines.h +++ /dev/null @@ -1,156 +0,0 @@ -/********************************************************************************/ -/* */ -/* Include Headers for Internal Routines */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: InternalRoutines.h 1594 2020-03-26 22:15:48Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2016 - 2020 */ -/* */ -/********************************************************************************/ - -#ifndef INTERNAL_ROUTINES_H -#define INTERNAL_ROUTINES_H - -#if !defined _LIB_SUPPORT_H_ && !defined _TPM_H_ -# error "Should not be called" -#endif - -// DRTM functions -#include "_TPM_Hash_Start_fp.h" -#include "_TPM_Hash_Data_fp.h" -#include "_TPM_Hash_End_fp.h" - -// Internal subsystem functions -#include "Object_fp.h" -#include "Context_spt_fp.h" -#include "Object_spt_fp.h" -#include "Entity_fp.h" -#include "Session_fp.h" -#include "Hierarchy_fp.h" -#include "NvReserved_fp.h" -#include "NvDynamic_fp.h" -#include "NV_spt_fp.h" -#include "ACT_spt_fp.h" -#include "PCR_fp.h" -#include "DA_fp.h" -#include "TpmFail_fp.h" -#include "SessionProcess_fp.h" - -// Internal support functions -#include "CommandCodeAttributes_fp.h" -#include "Marshal_fp.h" -#include "Time_fp.h" -#include "Locality_fp.h" -#include "PP_fp.h" -#include "CommandAudit_fp.h" -#include "Manufacture_fp.h" -#include "Handle_fp.h" -#include "Power_fp.h" -#include "Response_fp.h" -#include "CommandDispatcher_fp.h" - -#if CC_AC_Send -# include "AC_spt_fp.h" -#endif // CC_AC_Send - -// Miscellaneous -#include "Bits_fp.h" -#include "AlgorithmCap_fp.h" -#include "PropertyCap_fp.h" -#include "IoBuffers_fp.h" -#include "Memory_fp.h" -#include "ResponseCodeProcessing_fp.h" -/* Internal cryptographic functions */ -#include "BnConvert_fp.h" -#include "BnMath_fp.h" -#include "BnMemory_fp.h" -#include "Ticket_fp.h" -#include "CryptUtil_fp.h" -#include "CryptHash_fp.h" -#include "CryptSym_fp.h" -#include "CryptDes_fp.h" -#include "CryptPrime_fp.h" -#include "CryptRand_fp.h" -#include "CryptSelfTest_fp.h" -#include "MathOnByteBuffers_fp.h" -#include "CryptSym_fp.h" -#include "AlgorithmTests_fp.h" - -#if ALG_RSA -# include "CryptRsa_fp.h" -# include "CryptPrimeSieve_fp.h" -#endif - -#if ALG_ECC -# include "CryptEccMain_fp.h" -# include "CryptEccSignature_fp.h" -# include "CryptEccKeyExchange_fp.h" -# include "CryptEccCrypt_fp.h" -#endif - -#if CC_MAC || CC_MAC_Start -# include "CryptSmac_fp.h" -# if ALG_CMAC -# include "CryptCmac_fp.h" -# endif -#endif -// Asymmetric Support library Interface -// TODO_RENAME_INC_FOLDER: needs a component prefix -#include "MathLibraryInterface.h" - -// Linkage to platform functions -// TODO_RENAME_INC_FOLDER:platform_interface refers to the TPM_CoreLib platform interface -#include "tpm_to_platform_interface.h" - -#endif diff --git a/src/tpm2/IoBuffers.c b/src/tpm2/IoBuffers.c deleted file mode 100644 index f9de0ef0a..000000000 --- a/src/tpm2/IoBuffers.c +++ /dev/null @@ -1,139 +0,0 @@ -/********************************************************************************/ -/* */ -/* I/O Buffers */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: IoBuffers.c 1311 2018-08-23 21:39:29Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2016 - 2018 */ -/* */ -/********************************************************************************/ - - -//** Includes and Data Definitions - -// This definition allows this module to "see" the values that are private -// to this module but kept in Global.c for ease of state migration. -#define IO_BUFFER_C -#include "Tpm.h" -#include "IoBuffers_fp.h" - -//** Buffers and Functions - -// These buffers are set aside to hold command and response values. In this -// implementation, it is not guaranteed that the code will stop accessing -// the s_actionInputBuffer before starting to put values in the -// s_actionOutputBuffer so different buffers are required. -// - -//*** MemoryIoBufferAllocationReset() -// This function is used to reset the allocation of buffers. -void MemoryIoBufferAllocationReset(void) -{ - s_actionIoAllocation = 0; -} - -//*** MemoryIoBufferZero() -// Function zeros the action I/O buffer at the end of a command. Calling this is -// not mandatory for proper functionality. -void MemoryIoBufferZero(void) -{ - memset(s_actionIoBuffer, 0, s_actionIoAllocation); -} - -//*** MemoryGetInBuffer() -// This function returns the address of the buffer into which the -// command parameters will be unmarshaled in preparation for calling -// the command actions. -BYTE* MemoryGetInBuffer(UINT32 size // Size, in bytes, required for the input - // unmarshaling -) -{ - pAssert(size <= sizeof(s_actionIoBuffer)); -// In this implementation, a static buffer is set aside for the command action -// buffers. The buffer is shared between input and output. This is because -// there is no need to allocate for the worst case input and worst case output -// at the same time. -// Round size up -#define UoM (sizeof(s_actionIoBuffer[0])) - size = (size + (UoM - 1)) & (UINT32_MAX - (UoM - 1)); - memset(s_actionIoBuffer, 0, size); - s_actionIoAllocation = size; - return (BYTE*)&s_actionIoBuffer[0]; -} - -//*** MemoryGetOutBuffer() -// This function returns the address of the buffer into which the command -// action code places its output values. -BYTE* MemoryGetOutBuffer(UINT32 size // required size of the buffer -) -{ - BYTE* retVal = (BYTE*)(&s_actionIoBuffer[s_actionIoAllocation / UoM]); - pAssert((size + s_actionIoAllocation) < (sizeof(s_actionIoBuffer))); - // In this implementation, a static buffer is set aside for the command action - // output buffer. - memset(retVal, 0, size); - s_actionIoAllocation += size; - return retVal; -} - -//*** IsLabelProperlyFormatted() -// This function checks that a label is a null-terminated string. -// NOTE: this function is here because there was no better place for it. -// Return Type: BOOL -// TRUE(1) string is null terminated -// FALSE(0) string is not null terminated -BOOL IsLabelProperlyFormatted(TPM2B* x) -{ - return (((x)->size == 0) || ((x)->buffer[(x)->size - 1] == 0)); -} diff --git a/src/tpm2/IoBuffers_fp.h b/src/tpm2/IoBuffers_fp.h deleted file mode 100644 index 90e26b852..000000000 --- a/src/tpm2/IoBuffers_fp.h +++ /dev/null @@ -1,101 +0,0 @@ -/********************************************************************************/ -/* */ -/* I/O Buffers */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: IoBuffers_fp.h 1259 2018-07-10 19:11:09Z 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 - 2018 */ -/* */ -/********************************************************************************/ - -/*(Auto-generated) - * Created by TpmPrototypes; Version 3.0 July 18, 2017 - * Date: Mar 28, 2019 Time: 08:25:19PM - */ - -#ifndef _IO_BUFFERS_FP_H_ -#define _IO_BUFFERS_FP_H_ - -//*** MemoryIoBufferAllocationReset() -// This function is used to reset the allocation of buffers. -void MemoryIoBufferAllocationReset(void); - -//*** MemoryIoBufferZero() -// Function zeros the action I/O buffer at the end of a command. Calling this is -// not mandatory for proper functionality. -void MemoryIoBufferZero(void); - -//*** MemoryGetInBuffer() -// This function returns the address of the buffer into which the -// command parameters will be unmarshaled in preparation for calling -// the command actions. -BYTE* MemoryGetInBuffer(UINT32 size // Size, in bytes, required for the input - // unmarshaling -); - -//*** MemoryGetOutBuffer() -// This function returns the address of the buffer into which the command -// action code places its output values. -BYTE* MemoryGetOutBuffer(UINT32 size // required size of the buffer -); - -//*** IsLabelProperlyFormatted() -// This function checks that a label is a null-terminated string. -// NOTE: this function is here because there was no better place for it. -// Return Type: BOOL -// TRUE(1) string is null terminated -// FALSE(0) string is not null terminated -BOOL IsLabelProperlyFormatted(TPM2B* x); - -#endif // _IO_BUFFERS_FP_H_ diff --git a/src/tpm2/KdfTestData.h b/src/tpm2/KdfTestData.h deleted file mode 100644 index a632fd759..000000000 --- a/src/tpm2/KdfTestData.h +++ /dev/null @@ -1,125 +0,0 @@ -/********************************************************************************/ -/* */ -/* Hash Test Vectors */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: KdfTestData.h 1311 2018-08-23 21:39:29Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2016 - 2018 */ -/* */ -/********************************************************************************/ - - -// -// Hash Test Vectors -// - -#define TEST_KDF_KEY_SIZE 20 - -TPM2B_TYPE(KDF_TEST_KEY, TEST_KDF_KEY_SIZE); -TPM2B_KDF_TEST_KEY c_kdfTestKeyIn = { - {TEST_KDF_KEY_SIZE, - {0x27, 0x1F, 0xA0, 0x8B, 0xBD, 0xC5, 0x06, 0x0E, 0xC3, 0xDF, - 0xA9, 0x28, 0xFF, 0x9B, 0x73, 0x12, 0x3A, 0x12, 0xDA, 0x0C}}}; - -TPM2B_TYPE(KDF_TEST_LABEL, 17); -TPM2B_KDF_TEST_LABEL c_kdfTestLabel = {{17, - {0x4B, - 0x44, - 0x46, - 0x53, - 0x45, - 0x4C, - 0x46, - 0x54, - 0x45, - 0x53, - 0x54, - 0x4C, - 0x41, - 0x42, - 0x45, - 0x4C, - 0x00}}}; - -TPM2B_TYPE(KDF_TEST_CONTEXT, 8); -TPM2B_KDF_TEST_CONTEXT c_kdfTestContextU = { - {8, {0xCE, 0x24, 0x4F, 0x39, 0x5D, 0xCA, 0x73, 0x91}}}; - -TPM2B_KDF_TEST_CONTEXT c_kdfTestContextV = { - {8, {0xDA, 0x50, 0x40, 0x31, 0xDD, 0xF1, 0x2E, 0x83}}}; - -#if ALG_SHA512 == ALG_YES -TPM2B_KDF_TEST_KEY c_kdfTestKeyOut = { - {20, {0x8b, 0xe2, 0xc1, 0xb8, 0x5b, 0x78, 0x56, 0x9b, 0x9f, 0xa7, - 0x59, 0xf5, 0x85, 0x7c, 0x56, 0xd6, 0x84, 0x81, 0x0f, 0xd3}}}; -# define KDF_TEST_ALG TPM_ALG_SHA512 - -#elif ALG_SHA384 == ALG_YES -TPM2B_KDF_TEST_KEY c_kdfTestKeyOut = { - {20, {0x1d, 0xce, 0x70, 0xc9, 0x11, 0x3e, 0xb2, 0xdb, 0xa4, 0x7b, - 0xd9, 0xcf, 0xc7, 0x2b, 0xf4, 0x6f, 0x45, 0xb0, 0x93, 0x12}}}; -# define KDF_TEST_ALG TPM_ALG_SHA384 - -#elif ALG_SHA256 == ALG_YES -TPM2B_KDF_TEST_KEY c_kdfTestKeyOut = { - {20, {0xbb, 0x02, 0x59, 0xe1, 0xc8, 0xba, 0x60, 0x7e, 0x6a, 0x2c, - 0xd7, 0x04, 0xb6, 0x9a, 0x90, 0x2e, 0x9a, 0xde, 0x84, 0xc4}}}; -# define KDF_TEST_ALG TPM_ALG_SHA256 - -#elif ALG_SHA1 == ALG_YES -TPM2B_KDF_TEST_KEY c_kdfTestKeyOut = { - {20, {0x55, 0xb5, 0xa7, 0x18, 0x4a, 0xa0, 0x74, 0x23, 0xc4, 0x7d, - 0xae, 0x76, 0x6c, 0x26, 0xa2, 0x37, 0x7d, 0x7c, 0xf8, 0x51}}}; -# define KDF_TEST_ALG TPM_ALG_SHA1 -#endif diff --git a/src/tpm2/LibtpmsCallbacks.c b/src/tpm2/LibtpmsCallbacks.c index 5d2214792..ea7444344 100644 --- a/src/tpm2/LibtpmsCallbacks.c +++ b/src/tpm2/LibtpmsCallbacks.c @@ -1,40 +1,6 @@ -/********************************************************************************/ -/* */ -/* Libtpms Callbacks */ -/* Written by Stefan Berger */ -/* IBM Thomas J. Watson Research Center */ -/* */ -/* (c) Copyright IBM Corporation 2018. */ -/* */ -/* All rights reserved. */ -/* */ -/* Redistribution and use in source and binary forms, with or without */ -/* modification, are permitted provided that the following conditions are */ -/* met: */ -/* */ -/* Redistributions of source code must retain the above copyright notice, */ -/* this list of conditions and the following disclaimer. */ -/* */ -/* Redistributions in binary form must reproduce the above copyright */ -/* notice, this list of conditions and the following disclaimer in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* Neither the names of the IBM Corporation nor the names of its */ -/* contributors may be used to endorse or promote products derived from */ -/* this software without specific prior written permission. */ -/* */ -/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */ -/* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */ -/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR */ -/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */ -/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */ -/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */ -/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, */ -/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY */ -/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */ -/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE */ -/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause + +// (c) Copyright IBM Corporation 2018. #include #include diff --git a/src/tpm2/LibtpmsCallbacks.h b/src/tpm2/LibtpmsCallbacks.h index e262b9d65..d4c05a0ee 100644 --- a/src/tpm2/LibtpmsCallbacks.h +++ b/src/tpm2/LibtpmsCallbacks.h @@ -1,40 +1,6 @@ -/********************************************************************************/ -/* */ -/* Libtpms Callbacks */ -/* Written by Stefan Berger */ -/* IBM Thomas J. Watson Research Center */ -/* */ -/* (c) Copyright IBM Corporation 2018. */ -/* */ -/* All rights reserved. */ -/* */ -/* Redistribution and use in source and binary forms, with or without */ -/* modification, are permitted provided that the following conditions are */ -/* met: */ -/* */ -/* Redistributions of source code must retain the above copyright notice, */ -/* this list of conditions and the following disclaimer. */ -/* */ -/* Redistributions in binary form must reproduce the above copyright */ -/* notice, this list of conditions and the following disclaimer in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* Neither the names of the IBM Corporation nor the names of its */ -/* contributors may be used to endorse or promote products derived from */ -/* this software without specific prior written permission. */ -/* */ -/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */ -/* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */ -/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR */ -/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */ -/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */ -/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */ -/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, */ -/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY */ -/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */ -/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE */ -/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause + +// (c) Copyright IBM Corporation 2018. #ifndef LIBTPMS_CALLBACKS_H #define LIBTPMS_CALLBACKS_H diff --git a/src/tpm2/LoadExternal_fp.h b/src/tpm2/LoadExternal_fp.h deleted file mode 100644 index ee7c2a152..000000000 --- a/src/tpm2/LoadExternal_fp.h +++ /dev/null @@ -1,95 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: LoadExternal_fp.h 1521 2019-11-15 21:00:47Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_LoadExternal // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_LOADEXTERNAL_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_LOADEXTERNAL_FP_H_ - -// Input structure definition -typedef struct -{ - TPM2B_SENSITIVE inPrivate; - TPM2B_PUBLIC inPublic; - TPMI_RH_HIERARCHY hierarchy; -} LoadExternal_In; - -// Output structure definition -typedef struct -{ - TPM_HANDLE objectHandle; - TPM2B_NAME name; -} LoadExternal_Out; - -// Response code modifiers -# define RC_LoadExternal_inPrivate (TPM_RC_P + TPM_RC_1) -# define RC_LoadExternal_inPublic (TPM_RC_P + TPM_RC_2) -# define RC_LoadExternal_hierarchy (TPM_RC_P + TPM_RC_3) - -// Function prototype -TPM_RC -TPM2_LoadExternal(LoadExternal_In* in, LoadExternal_Out* out); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_LOADEXTERNAL_FP_H_ -#endif // CC_LoadExternal diff --git a/src/tpm2/Load_fp.h b/src/tpm2/Load_fp.h deleted file mode 100644 index 304b30625..000000000 --- a/src/tpm2/Load_fp.h +++ /dev/null @@ -1,95 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: Load_fp.h 1521 2019-11-15 21:00:47Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_Load // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_LOAD_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_LOAD_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_DH_OBJECT parentHandle; - TPM2B_PRIVATE inPrivate; - TPM2B_PUBLIC inPublic; -} Load_In; - -// Output structure definition -typedef struct -{ - TPM_HANDLE objectHandle; - TPM2B_NAME name; -} Load_Out; - -// Response code modifiers -# define RC_Load_parentHandle (TPM_RC_H + TPM_RC_1) -# define RC_Load_inPrivate (TPM_RC_P + TPM_RC_1) -# define RC_Load_inPublic (TPM_RC_P + TPM_RC_2) - -// Function prototype -TPM_RC -TPM2_Load(Load_In* in, Load_Out* out); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_LOAD_FP_H_ -#endif // CC_Load diff --git a/src/tpm2/Locality.c b/src/tpm2/Locality.c deleted file mode 100644 index f9cf23548..000000000 --- a/src/tpm2/Locality.c +++ /dev/null @@ -1,101 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: Locality.c 1490 2019-07-26 21:13:22Z 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, 2017 */ -/* */ -/********************************************************************************/ - -//** Includes -#include "Tpm.h" - -//** LocalityGetAttributes() -// This function will convert a locality expressed as an integer into -// TPMA_LOCALITY form. -// -// The function returns the locality attribute. -TPMA_LOCALITY -LocalityGetAttributes(UINT8 locality // IN: locality value -) -{ - TPMA_LOCALITY locality_attributes; - BYTE* localityAsByte = (BYTE*)&locality_attributes; - - MemorySet(&locality_attributes, 0, sizeof(TPMA_LOCALITY)); - switch(locality) - { - case 0: - SET_ATTRIBUTE(locality_attributes, TPMA_LOCALITY, TPM_LOC_ZERO); - break; - case 1: - SET_ATTRIBUTE(locality_attributes, TPMA_LOCALITY, TPM_LOC_ONE); - break; - case 2: - SET_ATTRIBUTE(locality_attributes, TPMA_LOCALITY, TPM_LOC_TWO); - break; - case 3: - SET_ATTRIBUTE(locality_attributes, TPMA_LOCALITY, TPM_LOC_THREE); - break; - case 4: - SET_ATTRIBUTE(locality_attributes, TPMA_LOCALITY, TPM_LOC_FOUR); - break; - default: - pAssert(locality > 31); - *localityAsByte = locality; - break; - } - return locality_attributes; -} diff --git a/src/tpm2/LocalityPlat.c b/src/tpm2/LocalityPlat.c deleted file mode 100644 index cf297d1d9..000000000 --- a/src/tpm2/LocalityPlat.c +++ /dev/null @@ -1,84 +0,0 @@ -/********************************************************************************/ -/* */ -/* Platform Locality Support */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: LocalityPlat.c 1490 2019-07-26 21:13:22Z 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 */ -/* */ -/********************************************************************************/ - -//** Includes -#include "Platform.h" - -//** Functions - -//***_plat__LocalityGet() -// Get the most recent command locality in locality value form. -// This is an integer value for locality and not a locality structure -// The locality can be 0-4 or 32-255. 5-31 is not allowed. -LIB_EXPORT unsigned char _plat__LocalityGet(void) -{ - return s_locality; -} - -//***_plat__LocalitySet() -// Set the most recent command locality in locality value form -LIB_EXPORT void _plat__LocalitySet(unsigned char locality) -{ - if(locality > 4 && locality < 32) - locality = 0; - s_locality = locality; - return; -} diff --git a/src/tpm2/Locality_fp.h b/src/tpm2/Locality_fp.h deleted file mode 100644 index b0a3056c4..000000000 --- a/src/tpm2/Locality_fp.h +++ /dev/null @@ -1,79 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: Locality_fp.h 1490 2019-07-26 21:13:22Z 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 */ -/* */ -/********************************************************************************/ - -/*(Auto-generated) - * Created by TpmPrototypes; Version 3.0 July 18, 2017 - * Date: Mar 28, 2019 Time: 08:25:19PM - */ - -#ifndef _LOCALITY_FP_H_ -#define _LOCALITY_FP_H_ - -//** LocalityGetAttributes() -// This function will convert a locality expressed as an integer into -// TPMA_LOCALITY form. -// -// The function returns the locality attribute. -TPMA_LOCALITY -LocalityGetAttributes(UINT8 locality // IN: locality value -); - -#endif // _LOCALITY_FP_H_ diff --git a/src/tpm2/MAC_Start_fp.h b/src/tpm2/MAC_Start_fp.h deleted file mode 100644 index 5d4879a36..000000000 --- a/src/tpm2/MAC_Start_fp.h +++ /dev/null @@ -1,94 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: MAC_Start_fp.h 1047 2017-07-20 18:27:34Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2017 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_MAC_Start // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_MAC_START_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_MAC_START_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_DH_OBJECT handle; - TPM2B_AUTH auth; - TPMI_ALG_MAC_SCHEME inScheme; -} MAC_Start_In; - -// Output structure definition -typedef struct -{ - TPMI_DH_OBJECT sequenceHandle; -} MAC_Start_Out; - -// Response code modifiers -# define RC_MAC_Start_handle (TPM_RC_H + TPM_RC_1) -# define RC_MAC_Start_auth (TPM_RC_P + TPM_RC_1) -# define RC_MAC_Start_inScheme (TPM_RC_P + TPM_RC_2) - -// Function prototype -TPM_RC -TPM2_MAC_Start(MAC_Start_In* in, MAC_Start_Out* out); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_MAC_START_FP_H_ -#endif // CC_MAC_Start diff --git a/src/tpm2/MAC_fp.h b/src/tpm2/MAC_fp.h deleted file mode 100644 index 588a6e225..000000000 --- a/src/tpm2/MAC_fp.h +++ /dev/null @@ -1,94 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: MAC_fp.h 1259 2018-07-10 19:11:09Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2018 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_MAC // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_MAC_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_MAC_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_DH_OBJECT handle; - TPM2B_MAX_BUFFER buffer; - TPMI_ALG_MAC_SCHEME inScheme; -} MAC_In; - -// Output structure definition -typedef struct -{ - TPM2B_DIGEST outMAC; -} MAC_Out; - -// Response code modifiers -# define RC_MAC_handle (TPM_RC_H + TPM_RC_1) -# define RC_MAC_buffer (TPM_RC_P + TPM_RC_1) -# define RC_MAC_inScheme (TPM_RC_P + TPM_RC_2) - -// Function prototype -TPM_RC -TPM2_MAC(MAC_In* in, MAC_Out* out); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_MAC_FP_H_ -#endif // CC_MAC diff --git a/src/tpm2/MakeCredential_fp.h b/src/tpm2/MakeCredential_fp.h deleted file mode 100644 index 4ba7b0af1..000000000 --- a/src/tpm2/MakeCredential_fp.h +++ /dev/null @@ -1,95 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: MakeCredential_fp.h 809 2016-11-16 18:31:54Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_MakeCredential // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_MAKECREDENTIAL_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_MAKECREDENTIAL_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_DH_OBJECT handle; - TPM2B_DIGEST credential; - TPM2B_NAME objectName; -} MakeCredential_In; - -// Output structure definition -typedef struct -{ - TPM2B_ID_OBJECT credentialBlob; - TPM2B_ENCRYPTED_SECRET secret; -} MakeCredential_Out; - -// Response code modifiers -# define RC_MakeCredential_handle (TPM_RC_H + TPM_RC_1) -# define RC_MakeCredential_credential (TPM_RC_P + TPM_RC_1) -# define RC_MakeCredential_objectName (TPM_RC_P + TPM_RC_2) - -// Function prototype -TPM_RC -TPM2_MakeCredential(MakeCredential_In* in, MakeCredential_Out* out); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_MAKECREDENTIAL_FP_H_ -#endif // CC_MakeCredential diff --git a/src/tpm2/Manufacture_fp.h b/src/tpm2/Manufacture_fp.h deleted file mode 100644 index 835ab9e96..000000000 --- a/src/tpm2/Manufacture_fp.h +++ /dev/null @@ -1,109 +0,0 @@ -/********************************************************************************/ -/* */ -/* Performs the manufacturing of the TPM */ -/* 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 */ -/* */ -/********************************************************************************/ - - -#ifndef _MANUFACTURE_FP_H_ -#define _MANUFACTURE_FP_H_ - -//*** TPM_Manufacture() -// This function initializes the TPM values in preparation for the TPM's first -// use. This function will fail if previously called. The TPM can be re-manufactured -// by calling TPM_Teardown() first and then calling this function again. -// NV must be enabled first (typically with NvPowerOn() via _TPM_Init) -// -// return type: int -// -2 NV System not available -// -1 FAILURE - System is incorrectly compiled. -// 0 success -// 1 manufacturing process previously performed -// returns -#define MANUF_NV_NOT_READY (-2) -#define MANUF_INVALID_CONFIG (-1) -#define MANUF_OK 0 -#define MANUF_ALREADY_DONE 1 -// params -#define MANUF_FIRST_TIME 1 -#define MANUF_REMANUFACTURE 0 -LIB_EXPORT int TPM_Manufacture( - int firstTime, // IN: indicates if this is the first call from - // main() - const char *profile // libtpms added -); - -//*** TPM_TearDown() -// This function prepares the TPM for re-manufacture. It should not be implemented -// in anything other than a simulated TPM. -// -// In this implementation, all that is needs is to stop the cryptographic units -// and set a flag to indicate that the TPM can be re-manufactured. This should -// be all that is necessary to start the manufacturing process again. -// Return Type: int -// 0 success -// 1 TPM not previously manufactured -#define TEARDOWN_OK 0 -#define TEARDOWN_NOTHINGDONE 1 -LIB_EXPORT int TPM_TearDown(void); - -//*** TpmEndSimulation() -// This function is called at the end of the simulation run. It is used to provoke -// printing of any statistics that might be needed. -LIB_EXPORT void TpmEndSimulation(void); - -#endif // _MANUFACTURE_FP_H_ diff --git a/src/tpm2/MathLibraryInterfaceTypes.h b/src/tpm2/MathLibraryInterfaceTypes.h deleted file mode 100644 index ba4c00bbe..000000000 --- a/src/tpm2/MathLibraryInterfaceTypes.h +++ /dev/null @@ -1,144 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* 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 */ -/* */ -/********************************************************************************/ - -//** Introduction -// This file contains the declaration and initialization macros for -// low-level cryptographic buffer types. This requires the underlying -// Crypto library to have already defined the CRYPT_INT_BUF family of -// macros. See tpm_crypto_lib.md for details. - -#ifndef MATH_LIBRARY_INTERFACE_TYPES_H -#define MATH_LIBRARY_INTERFACE_TYPES_H - -#ifndef CRYPT_INT_BUF -# error CRYPT_INT_BUF must be defined before including this file. -#endif -#ifndef CRYPT_POINT_BUF -# error CRYPT_POINT_BUF must be defined before including this file. -#endif -#ifndef CRYPT_CURVE_BUF -# error CRYPT_CURVE_BUF must be defined before including this file. -#endif - -// Crypt_Int underlying types Crypt_Int is an abstract type that is used as a -// pointer. The underlying math library is expected to be able to find the -// actual allocated size for a given Crypt_Int object given a pointer to it, and -// therefore we typedef here to a size 1 (smallest possible). -typedef CRYPT_INT_BUF(one, 1) Crypt_Int; -typedef CRYPT_POINT_BUF(pointone, 1) Crypt_Point; -typedef CRYPT_CURVE_BUF(curvebuft, MAX_ECC_KEY_BITS) Crypt_EccCurve; - -// produces bare typedef ci__t -#define CRYPT_INT_TYPE(typename, bits) \ - typedef CRYPT_INT_BUF(ci_##typename##_buf_t, bits) ci_##typename##_t - -// produces allocated `Crypt_Int* varname` backed by a -// stack buffer named `_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); - -// produces initialized `Crypt_Int* varname = (TPM2B) initializer` backed by a -// stack buffer named `_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); - -// 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) - -// 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); - -// 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) - -/* 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_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 diff --git a/src/tpm2/MinMax.h b/src/tpm2/MinMax.h deleted file mode 100644 index e7e693f71..000000000 --- a/src/tpm2/MinMax.h +++ /dev/null @@ -1,76 +0,0 @@ -/********************************************************************************/ -/* */ -/* Min Max Macros */ -/* 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 - 2023 */ -/* */ -/********************************************************************************/ - - -#ifndef _MIN_MAX_H_ -#define _MIN_MAX_H_ - -#ifndef MAX -# define MAX(a, b) ((a) > (b) ? (a) : (b)) -#endif -#ifndef MIN -# define MIN(a, b) ((a) < (b) ? (a) : (b)) -#endif - -#ifndef SIZEOF_MEMBER -# define SIZEOF_MEMBER(type, member) sizeof(((type*)0)->member) -#endif - -#endif // _MIN_MAX_H_ diff --git a/src/tpm2/NV.h b/src/tpm2/NV.h deleted file mode 100644 index 9efa08e8d..000000000 --- a/src/tpm2/NV.h +++ /dev/null @@ -1,177 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: NV.h 1490 2019-07-26 21:13:22Z 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 */ -/* */ -/********************************************************************************/ - -//** Index Type Definitions - -// These definitions allow the same code to be used pre and post 1.21. The main -// action is to redefine the index type values from the bit values. -// Use TPM_NT_ORDINARY to indicate if the TPM_NT type is defined - -#ifndef _NV_H_ -#define _NV_H_ - -#ifdef TPM_NT_ORDINARY -// If TPM_NT_ORDINARY is defined, then the TPM_NT field is present in a TPMA_NV -# define GET_TPM_NT(attributes) GET_ATTRIBUTE(attributes, TPMA_NV, TPM_NT) -#else -// If TPM_NT_ORDINARY is not defined, then need to synthesize it from the -// attributes -# define GetNv_TPM_NV(attributes) \ - (IS_ATTRIBUTE(attributes, TPMA_NV, COUNTER) \ - + (IS_ATTRIBUTE(attributes, TPMA_NV, BITS) << 1) \ - + (IS_ATTRIBUTE(attributes, TPMA_NV, EXTEND) << 2)) -# define TPM_NT_ORDINARY (0) -# define TPM_NT_COUNTER (1) -# define TPM_NT_BITS (2) -# define TPM_NT_EXTEND (4) -#endif - -//** Attribute Macros -// These macros are used to isolate the differences in the way that the index type -// changed in version 1.21 of the specification -#define IsNvOrdinaryIndex(attributes) (GET_TPM_NT(attributes) == TPM_NT_ORDINARY) - -#define IsNvCounterIndex(attributes) (GET_TPM_NT(attributes) == TPM_NT_COUNTER) - -#define IsNvBitsIndex(attributes) (GET_TPM_NT(attributes) == TPM_NT_BITS) - -#define IsNvExtendIndex(attributes) (GET_TPM_NT(attributes) == TPM_NT_EXTEND) - -#ifdef TPM_NT_PIN_PASS -# define IsNvPinPassIndex(attributes) (GET_TPM_NT(attributes) == TPM_NT_PIN_PASS) -#endif - -#ifdef TPM_NT_PIN_FAIL -# define IsNvPinFailIndex(attributes) (GET_TPM_NT(attributes) == TPM_NT_PIN_FAIL) -#endif - -typedef struct -{ - UINT32 size; - TPM_HANDLE handle; -} NV_ENTRY_HEADER; - -#define NV_EVICT_OBJECT_SIZE (sizeof(UINT32) + sizeof(TPM_HANDLE) + sizeof(OBJECT)) - -#define NV_INDEX_COUNTER_SIZE (sizeof(UINT32) + sizeof(NV_INDEX) + sizeof(UINT64)) - -#define NV_RAM_INDEX_COUNTER_SIZE (sizeof(NV_RAM_HEADER) + sizeof(UINT64)) - -typedef struct -{ - UINT32 size; - TPM_HANDLE handle; - TPMA_NV attributes; -} NV_RAM_HEADER; - -// Defines the end-of-list marker for NV. The list terminator is -// a UINT32 of zero, followed by the current value of s_maxCounter which is a -// 64-bit value. The structure is defined as an array of 3 UINT32 values so that -// there is no padding between the UINT32 list end marker and the UINT64 maxCounter -// value. -typedef UINT32 NV_LIST_TERMINATOR[3]; - -//** Orderly RAM Values -// The following defines are for accessing orderly RAM values. - -// This is the initialize for the RAM reference iterator. -#define NV_RAM_REF_INIT 0 -// This is the starting address of the RAM space used for orderly data -#define RAM_ORDERLY_START (&s_indexOrderlyRam[0]) -// This is the offset within NV that is used to save the orderly data on an -// orderly shutdown. -#define NV_ORDERLY_START (NV_INDEX_RAM_DATA) -// This is the end of the orderly RAM space. It is actually the first byte after the -// last byte of orderly RAM data -#define RAM_ORDERLY_END (RAM_ORDERLY_START + sizeof(s_indexOrderlyRam)) -// This is the end of the orderly space in NV memory. As with RAM_ORDERLY_END, it is -// actually the offset of the first byte after the end of the NV orderly data. -#define NV_ORDERLY_END (NV_ORDERLY_START + sizeof(s_indexOrderlyRam)) - -// Macro to check that an orderly RAM address is with range. -#define ORDERLY_RAM_ADDRESS_OK(start, offset) \ - ((start >= RAM_ORDERLY_START) && ((start + offset - 1) < RAM_ORDERLY_END)) - -#define RETURN_IF_NV_IS_NOT_AVAILABLE \ - { \ - if(g_NvStatus != TPM_RC_SUCCESS) \ - return g_NvStatus; \ - } - -// Routinely have to clear the orderly flag and fail if the -// NV is not available so that it can be cleared. -#define RETURN_IF_ORDERLY \ - { \ - if(NvClearOrderly() != TPM_RC_SUCCESS) \ - return g_NvStatus; \ - } - -#define NV_IS_AVAILABLE (g_NvStatus == TPM_RC_SUCCESS) - -#define IS_ORDERLY(value) (value < SU_DA_USED_VALUE) - -#define NV_IS_ORDERLY (IS_ORDERLY(gp.orderlyState)) - -// Macro to set the NV UPDATE_TYPE. This deals with the fact that the update is -// possibly a combination of UT_NV and UT_ORDERLY. -#define SET_NV_UPDATE(type) g_updateNV |= (type) - -#endif // _NV_H_ diff --git a/src/tpm2/NVCommands.c b/src/tpm2/NVCommands.c index 528924a44..720c4852e 100644 --- a/src/tpm2/NVCommands.c +++ b/src/tpm2/NVCommands.c @@ -152,24 +152,6 @@ TPM2_NV_UndefineSpaceSpecial( } #endif // CC_NV_UndefineSpaceSpecial #include "Tpm.h" -#include "NV_ReadPublic_fp.h" -#if CC_NV_ReadPublic // Conditional expansion of this file -TPM_RC -TPM2_NV_ReadPublic( - NV_ReadPublic_In *in, // IN: input parameter list - NV_ReadPublic_Out *out // OUT: output parameter list - ) -{ - NV_INDEX *nvIndex = NvGetIndexInfo(in->nvIndex, NULL); - // Command Output - // Copy index public data to output - out->nvPublic.nvPublic = nvIndex->publicArea; - // Compute NV name - NvGetIndexName(nvIndex, &out->nvName); - return TPM_RC_SUCCESS; -} -#endif // CC_NV_ReadPublic -#include "Tpm.h" #include "NV_Write_fp.h" #if CC_NV_Write // Conditional expansion of this file TPM_RC @@ -181,6 +163,12 @@ TPM2_NV_Write( TPMA_NV attributes = nvIndex->publicArea.attributes; TPM_RC result; // Input Validation + + // Common Read-Only mode check. May return TPM_RC_READ_ONLY + result = NvReadOnlyModeChecks(attributes); + if(result != TPM_RC_SUCCESS) + return result; + // Common access checks, NvWriteAccessCheck() may return TPM_RC_NV_AUTHORIZATION // or TPM_RC_NV_LOCKED result = NvWriteAccessChecks(in->authHandle, @@ -281,6 +269,12 @@ TPM2_NV_Extend( TPM2B_DIGEST newDigest; HASH_STATE hashState; // Input Validation + + // Common Read-Only mode check. May return TPM_RC_READ_ONLY + result = NvReadOnlyModeChecks(nvIndex->publicArea.attributes); + if(result != TPM_RC_SUCCESS) + return result; + // Common access checks, NvWriteAccessCheck() may return TPM_RC_NV_AUTHORIZATION // or TPM_RC_NV_LOCKED result = NvWriteAccessChecks(in->authHandle, @@ -330,6 +324,12 @@ TPM2_NV_SetBits( UINT64 oldValue; UINT64 newValue; // Input Validation + + // Common Read-Only mode check. May return TPM_RC_READ_ONLY + result = NvReadOnlyModeChecks(nvIndex->publicArea.attributes); + if(result != TPM_RC_SUCCESS) + return result; + // Common access checks, NvWriteAccessCheck() may return TPM_RC_NV_AUTHORIZATION // or TPM_RC_NV_LOCKED result = NvWriteAccessChecks(in->authHandle, @@ -365,6 +365,12 @@ TPM2_NV_WriteLock( NV_INDEX *nvIndex = NvGetIndexInfo(in->nvIndex, &locator); TPMA_NV nvAttributes = nvIndex->publicArea.attributes; // Input Validation: + + // Common Read-Only mode check. May return TPM_RC_READ_ONLY + result = NvReadOnlyModeChecks(nvIndex->publicArea.attributes); + if(result != TPM_RC_SUCCESS) + return result; + // Common access checks, NvWriteAccessCheck() may return TPM_RC_NV_AUTHORIZATION // or TPM_RC_NV_LOCKED result = NvWriteAccessChecks(in->authHandle, in->nvIndex, nvAttributes); @@ -407,49 +413,6 @@ TPM2_NV_GlobalWriteLock( } #endif // CC_NV_GlobalWriteLock #include "Tpm.h" -#include "NV_Read_fp.h" -#if CC_NV_Read // Conditional expansion of this file -/* TPM_RC_NV_AUTHORIZATION the authorization was valid but the authorizing entity (authHandle) is - not allowed to read from the Index referenced by nvIndex */ -/* TPM_RC_NV_LOCKED the Index referenced by nvIndex is read locked */ -/* TPM_RC_NV_RANGE read range defined by size and offset is outside the range of the Index - referenced by nvIndex */ -/* TPM_RC_NV_UNINITIALIZED the Index referenced by nvIndex has not been initialized (written) */ -/* TPM_RC_VALUE the read size is larger than the MAX_NV_BUFFER_SIZE */ -TPM_RC -TPM2_NV_Read( - NV_Read_In *in, // IN: input parameter list - NV_Read_Out *out // OUT: output parameter list - ) -{ - NV_REF locator; - NV_INDEX *nvIndex = NvGetIndexInfo(in->nvIndex, &locator); - TPM_RC result; - // Input Validation - // Common read access checks. NvReadAccessChecks() may return - // TPM_RC_NV_AUTHORIZATION, TPM_RC_NV_LOCKED, or TPM_RC_NV_UNINITIALIZED - result = NvReadAccessChecks(in->authHandle, in->nvIndex, - nvIndex->publicArea.attributes); - if(result != TPM_RC_SUCCESS) - return result; - // Make sure the data will fit the return buffer - if(in->size > MAX_NV_BUFFER_SIZE) - return TPM_RCS_VALUE + RC_NV_Read_size; - // Verify that the offset is not too large - if(in->offset > nvIndex->publicArea.dataSize) - return TPM_RCS_VALUE + RC_NV_Read_offset; - // Make sure that the selection is within the range of the Index - if(in->size > (nvIndex->publicArea.dataSize - in->offset)) - return TPM_RC_NV_RANGE; - // Command Output - // Set the return size - out->data.t.size = in->size; - // Perform the read - NvGetIndexData(nvIndex, locator, in->offset, in->size, out->data.t.buffer); - return TPM_RC_SUCCESS; -} -#endif // CC_NV_Read -#include "Tpm.h" #include "NV_ReadLock_fp.h" #if CC_NV_ReadLock // Conditional expansion of this file TPM_RC @@ -464,6 +427,12 @@ TPM2_NV_ReadLock( NV_INDEX *nvIndex = NvGetIndexInfo(in->nvIndex, &locator); TPMA_NV nvAttributes = nvIndex->publicArea.attributes; // Input Validation + + // Common Read-Only mode check. May return TPM_RC_READ_ONLY + result = NvReadOnlyModeChecks(nvIndex->publicArea.attributes); + if(result != TPM_RC_SUCCESS) + return result; + // Common read access checks. NvReadAccessChecks() may return // TPM_RC_NV_AUTHORIZATION, TPM_RC_NV_LOCKED, or TPM_RC_NV_UNINITIALIZED result = NvReadAccessChecks(in->authHandle, @@ -592,43 +561,6 @@ TPM2_NV_Certify( } #endif // CC_NV_Certify -#include "Tpm.h" -#include "NV_ReadPublic2_fp.h" - -#if CC_NV_ReadPublic2 // Conditional expansion of this file - -/*(See part 3 specification) -// Read the public information of a NV index -*/ -TPM_RC -TPM2_NV_ReadPublic2(NV_ReadPublic2_In* in, // IN: input parameter list - NV_ReadPublic2_Out* out // OUT: output parameter list - ) -{ - TPM_RC result; - NV_INDEX* nvIndex; - - nvIndex = NvGetIndexInfo(in->nvIndex, NULL); - - // Command Output - - // The reference code stores its NV indices in the legacy form, because - // it doesn't support any extended attributes. - // Translate the legacy form to the general form. - result = NvPublic2FromNvPublic(&nvIndex->publicArea, &out->nvPublic.nvPublic2); - if(result != TPM_RC_SUCCESS) - { - return RcSafeAddToResult(result, RC_NV_ReadPublic2_nvIndex); - } - - // Compute NV name - NvGetIndexName(nvIndex, &out->nvName); - - return TPM_RC_SUCCESS; -} - -#endif // CC_NV_ReadPublic2 - #include "Tpm.h" #include "NV_DefineSpace2_fp.h" diff --git a/src/tpm2/NVMarshal.c b/src/tpm2/NVMarshal.c index 1356c2597..1a275e536 100644 --- a/src/tpm2/NVMarshal.c +++ b/src/tpm2/NVMarshal.c @@ -1,40 +1,6 @@ -/********************************************************************************/ -/* */ -/* Marshalling and unmarshalling of state */ -/* Written by Stefan Berger */ -/* IBM Thomas J. Watson Research Center */ -/* */ -/* (c) Copyright IBM Corporation 2017,2018. */ -/* */ -/* All rights reserved. */ -/* */ -/* Redistribution and use in source and binary forms, with or without */ -/* modification, are permitted provided that the following conditions are */ -/* met: */ -/* */ -/* Redistributions of source code must retain the above copyright notice, */ -/* this list of conditions and the following disclaimer. */ -/* */ -/* Redistributions in binary form must reproduce the above copyright */ -/* notice, this list of conditions and the following disclaimer in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* Neither the names of the IBM Corporation nor the names of its */ -/* contributors may be used to endorse or promote products derived from */ -/* this software without specific prior written permission. */ -/* */ -/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */ -/* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */ -/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR */ -/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */ -/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */ -/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */ -/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, */ -/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY */ -/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */ -/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE */ -/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause + +// (c) Copyright IBM Corporation 2017,2018. #include #include @@ -56,6 +22,7 @@ #include "Simulator_fp.h" #include "BackwardsCompatibilityBitArray.h" #include "BackwardsCompatibilityObject.h" +#include #define TPM_HAVE_TPM2_DECLARATIONS #include "tpm_library_intern.h" @@ -142,7 +109,7 @@ static void block_skip_write_pop(block_skip_t *bs, INT32 *size) { UINT16 skip; unsigned i = --bs->idx; - pAssert((int)bs->idx >= 0); + pAssert_VOID_OK((int)bs->idx >= 0); skip = bs->pos[i].size - *size - sizeof(UINT16); UINT16_Marshal(&skip, &bs->pos[i].buffer, &bs->pos[i].size); } @@ -2928,6 +2895,8 @@ VolatileState_Marshal(BYTE **buffer, INT32 *size, struct RuntimeProfile *Runtime TPM2B_AUTH unused = { .b.size = 0, }; + BOOL inFailureMode; + UINT32 failFunction, failLine, failCode; written = NV_HEADER_Marshal(buffer, size, VOLATILE_STATE_VERSION, VOLATILE_STATE_MAGIC, @@ -3172,7 +3141,8 @@ VolatileState_Marshal(BYTE **buffer, INT32 *size, struct RuntimeProfile *Runtime /* s_actionInputBuffer: skip; only used during a single command */ /* s_actionOutputBuffer: skip; only used during a single command */ #endif - written += BOOL_Marshal(&g_inFailureMode, buffer, size); /* line 1078 */ + inFailureMode = _plat__InFailureMode(); + written += BOOL_Marshal(&inFailureMode, buffer, size); /* line 1078 */ /* TPM established bit */ tpmEst = _rpc__Signal_GetTPMEstablished(); @@ -3187,9 +3157,12 @@ VolatileState_Marshal(BYTE **buffer, INT32 *size, struct RuntimeProfile *Runtime written += BLOCK_SKIP_WRITE_PUSH(has_block, buffer, size); #if defined TPM_FAIL_C || defined GLOBAL_C || 1 - written += UINT32_Marshal(&s_failFunction, buffer, size); - written += UINT32_Marshal(&s_failLine, buffer, size); - written += UINT32_Marshal(&s_failCode, buffer, size); + failFunction = _plat__GetFailureLocation(); + written += UINT32_Marshal(&failFunction, buffer, size); + failLine = _plat__GetFailureLine(); + written += UINT32_Marshal(&failLine, buffer, size); + failCode = _plat__GetFailureCode(); + written += UINT32_Marshal(&failCode, buffer, size); #else # error Unsupport #define value(s) #endif // TPM_FAIL_C @@ -3347,6 +3320,7 @@ VolatileState_Unmarshal(BYTE **buffer, INT32 *size) TPM2B_AUTH unused = { .b.size = 0, }; + UINT32 failFunction, failLine, failCode; if (rc == TPM_RC_SUCCESS) { rc = NV_HEADER_Unmarshal(&hdr, buffer, size, @@ -3675,7 +3649,9 @@ VolatileState_Unmarshal(BYTE **buffer, INT32 *size) skip_session: if (rc == TPM_RC_SUCCESS) { - rc = BOOL_Unmarshal(&g_inFailureMode, buffer, size); /* line 1078 */ + BOOL inFailureMode = FALSE; + rc = BOOL_Unmarshal(&inFailureMode, buffer, size); /* line 1078 */ + _plat__SetInFailureMode(inFailureMode); } /* TPM established bit */ @@ -3704,13 +3680,16 @@ VolatileState_Unmarshal(BYTE **buffer, INT32 *size) #if defined TPM_FAIL_C || defined GLOBAL_C || 1 /* appended in v2 */ if (rc == TPM_RC_SUCCESS) { - rc = UINT32_Unmarshal(&s_failFunction, buffer, size); + rc = UINT32_Unmarshal(&failFunction, buffer, size); + } + if (rc == TPM_RC_SUCCESS) { + rc = UINT32_Unmarshal(&failLine, buffer, size); } if (rc == TPM_RC_SUCCESS) { - rc = UINT32_Unmarshal(&s_failLine, buffer, size); + rc = UINT32_Unmarshal(&failCode, buffer, size); } if (rc == TPM_RC_SUCCESS) { - rc = UINT32_Unmarshal(&s_failCode, buffer, size); + _plat__SetFailureModeParameters(NULL, failLine, failCode); } #else # error Unsupport #define value(s) diff --git a/src/tpm2/NVMarshal.h b/src/tpm2/NVMarshal.h index 7b06e40ac..43a14b365 100644 --- a/src/tpm2/NVMarshal.h +++ b/src/tpm2/NVMarshal.h @@ -1,40 +1,6 @@ -/********************************************************************************/ -/* */ -/* Marshalling and unmarshalling of state */ -/* Written by Stefan Berger */ -/* IBM Thomas J. Watson Research Center */ -/* */ -/* (c) Copyright IBM Corporation 2017,2018. */ -/* */ -/* All rights reserved. */ -/* */ -/* Redistribution and use in source and binary forms, with or without */ -/* modification, are permitted provided that the following conditions are */ -/* met: */ -/* */ -/* Redistributions of source code must retain the above copyright notice, */ -/* this list of conditions and the following disclaimer. */ -/* */ -/* Redistributions in binary form must reproduce the above copyright */ -/* notice, this list of conditions and the following disclaimer in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* Neither the names of the IBM Corporation nor the names of its */ -/* contributors may be used to endorse or promote products derived from */ -/* this software without specific prior written permission. */ -/* */ -/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */ -/* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */ -/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR */ -/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */ -/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */ -/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */ -/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, */ -/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY */ -/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */ -/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE */ -/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause + +// (c) Copyright IBM Corporation 2017,2018. #ifndef NVMARSHAL_H #define NVMARSHAL_H @@ -42,7 +8,7 @@ #include #include "Tpm.h" -#include "TpmTypes.h" +#include "tpm_public/TpmTypes.h" #include "RuntimeProfile_fp.h" #define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0])) diff --git a/src/tpm2/NV_Certify_fp.h b/src/tpm2/NV_Certify_fp.h deleted file mode 100644 index 99028f37a..000000000 --- a/src/tpm2/NV_Certify_fp.h +++ /dev/null @@ -1,103 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: NV_Certify_fp.h 809 2016-11-16 18:31:54Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_NV_Certify // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_CERTIFY_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_CERTIFY_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_DH_OBJECT signHandle; - TPMI_RH_NV_AUTH authHandle; - TPMI_RH_NV_INDEX nvIndex; - TPM2B_DATA qualifyingData; - TPMT_SIG_SCHEME inScheme; - UINT16 size; - UINT16 offset; -} NV_Certify_In; - -// Output structure definition -typedef struct -{ - TPM2B_ATTEST certifyInfo; - TPMT_SIGNATURE signature; -} NV_Certify_Out; - -// Response code modifiers -# define RC_NV_Certify_signHandle (TPM_RC_H + TPM_RC_1) -# define RC_NV_Certify_authHandle (TPM_RC_H + TPM_RC_2) -# define RC_NV_Certify_nvIndex (TPM_RC_H + TPM_RC_3) -# define RC_NV_Certify_qualifyingData (TPM_RC_P + TPM_RC_1) -# define RC_NV_Certify_inScheme (TPM_RC_P + TPM_RC_2) -# define RC_NV_Certify_size (TPM_RC_P + TPM_RC_3) -# define RC_NV_Certify_offset (TPM_RC_P + TPM_RC_4) - -// Function prototype -TPM_RC -TPM2_NV_Certify(NV_Certify_In* in, NV_Certify_Out* out); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_CERTIFY_FP_H_ -#endif // CC_NV_Certify diff --git a/src/tpm2/NV_ChangeAuth_fp.h b/src/tpm2/NV_ChangeAuth_fp.h deleted file mode 100644 index 4b3bd7f78..000000000 --- a/src/tpm2/NV_ChangeAuth_fp.h +++ /dev/null @@ -1,86 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: NV_ChangeAuth_fp.h 809 2016-11-16 18:31:54Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_NV_ChangeAuth // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_CHANGEAUTH_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_CHANGEAUTH_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_RH_NV_INDEX nvIndex; - TPM2B_AUTH newAuth; -} NV_ChangeAuth_In; - -// Response code modifiers -# define RC_NV_ChangeAuth_nvIndex (TPM_RC_H + TPM_RC_1) -# define RC_NV_ChangeAuth_newAuth (TPM_RC_P + TPM_RC_1) - -// Function prototype -TPM_RC -TPM2_NV_ChangeAuth(NV_ChangeAuth_In* in); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_CHANGEAUTH_FP_H_ -#endif // CC_NV_ChangeAuth diff --git a/src/tpm2/NV_DefineSpace2_fp.h b/src/tpm2/NV_DefineSpace2_fp.h deleted file mode 100644 index 428313d91..000000000 --- a/src/tpm2/NV_DefineSpace2_fp.h +++ /dev/null @@ -1,87 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* 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 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_NV_DefineSpace2 // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_DEFINESPACE2_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_DEFINESPACE2_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_RH_PROVISION authHandle; - TPM2B_AUTH auth; - TPM2B_NV_PUBLIC_2 publicInfo; -} NV_DefineSpace2_In; - -// Response code modifiers -# define RC_NV_DefineSpace2_authHandle (TPM_RC_H + TPM_RC_1) -# define RC_NV_DefineSpace2_auth (TPM_RC_P + TPM_RC_1) -# define RC_NV_DefineSpace2_publicInfo (TPM_RC_P + TPM_RC_2) - -// Function prototype -TPM_RC -TPM2_NV_DefineSpace2(NV_DefineSpace2_In* in); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_DEFINESPACE2_FP_H_ -#endif // CC_NV_DefineSpace2 diff --git a/src/tpm2/NV_DefineSpace_fp.h b/src/tpm2/NV_DefineSpace_fp.h deleted file mode 100644 index 9c15f1840..000000000 --- a/src/tpm2/NV_DefineSpace_fp.h +++ /dev/null @@ -1,88 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: NV_DefineSpace_fp.h 809 2016-11-16 18:31:54Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_NV_DefineSpace // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_DEFINESPACE_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_DEFINESPACE_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_RH_PROVISION authHandle; - TPM2B_AUTH auth; - TPM2B_NV_PUBLIC publicInfo; -} NV_DefineSpace_In; - -// Response code modifiers -# define RC_NV_DefineSpace_authHandle (TPM_RC_H + TPM_RC_1) -# define RC_NV_DefineSpace_auth (TPM_RC_P + TPM_RC_1) -# define RC_NV_DefineSpace_publicInfo (TPM_RC_P + TPM_RC_2) - -// Function prototype -TPM_RC -TPM2_NV_DefineSpace(NV_DefineSpace_In* in); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_DEFINESPACE_FP_H_ -#endif // CC_NV_DefineSpace diff --git a/src/tpm2/NV_Extend_fp.h b/src/tpm2/NV_Extend_fp.h deleted file mode 100644 index aadebaea2..000000000 --- a/src/tpm2/NV_Extend_fp.h +++ /dev/null @@ -1,88 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: NV_Extend_fp.h 809 2016-11-16 18:31:54Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_NV_Extend // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_EXTEND_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_EXTEND_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_RH_NV_AUTH authHandle; - TPMI_RH_NV_INDEX nvIndex; - TPM2B_MAX_NV_BUFFER data; -} NV_Extend_In; - -// Response code modifiers -# define RC_NV_Extend_authHandle (TPM_RC_H + TPM_RC_1) -# define RC_NV_Extend_nvIndex (TPM_RC_H + TPM_RC_2) -# define RC_NV_Extend_data (TPM_RC_P + TPM_RC_1) - -// Function prototype -TPM_RC -TPM2_NV_Extend(NV_Extend_In* in); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_EXTEND_FP_H_ -#endif // CC_NV_Extend diff --git a/src/tpm2/NV_GlobalWriteLock_fp.h b/src/tpm2/NV_GlobalWriteLock_fp.h deleted file mode 100644 index 0cb04bb57..000000000 --- a/src/tpm2/NV_GlobalWriteLock_fp.h +++ /dev/null @@ -1,84 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: NV_GlobalWriteLock_fp.h 809 2016-11-16 18:31:54Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_NV_GlobalWriteLock // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_GLOBALWRITELOCK_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_GLOBALWRITELOCK_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_RH_PROVISION authHandle; -} NV_GlobalWriteLock_In; - -// Response code modifiers -# define RC_NV_GlobalWriteLock_authHandle (TPM_RC_H + TPM_RC_1) - -// Function prototype -TPM_RC -TPM2_NV_GlobalWriteLock(NV_GlobalWriteLock_In* in); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_GLOBALWRITELOCK_FP_H_ -#endif // CC_NV_GlobalWriteLock diff --git a/src/tpm2/NV_Increment_fp.h b/src/tpm2/NV_Increment_fp.h deleted file mode 100644 index 84414e01f..000000000 --- a/src/tpm2/NV_Increment_fp.h +++ /dev/null @@ -1,86 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: NV_Increment_fp.h 1521 2019-11-15 21:00:47Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_NV_Increment // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_INCREMENT_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_INCREMENT_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_RH_NV_AUTH authHandle; - TPMI_RH_NV_INDEX nvIndex; -} NV_Increment_In; - -// Response code modifiers -# define RC_NV_Increment_authHandle (TPM_RC_H + TPM_RC_1) -# define RC_NV_Increment_nvIndex (TPM_RC_H + TPM_RC_2) - -// Function prototype -TPM_RC -TPM2_NV_Increment(NV_Increment_In* in); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_INCREMENT_FP_H_ -#endif // CC_NV_Increment diff --git a/src/tpm2/NV_ReadLock_fp.h b/src/tpm2/NV_ReadLock_fp.h deleted file mode 100644 index 93df04f61..000000000 --- a/src/tpm2/NV_ReadLock_fp.h +++ /dev/null @@ -1,86 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: NV_ReadLock_fp.h 809 2016-11-16 18:31:54Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_NV_ReadLock // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_READLOCK_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_READLOCK_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_RH_NV_AUTH authHandle; - TPMI_RH_NV_INDEX nvIndex; -} NV_ReadLock_In; - -// Response code modifiers -# define RC_NV_ReadLock_authHandle (TPM_RC_H + TPM_RC_1) -# define RC_NV_ReadLock_nvIndex (TPM_RC_H + TPM_RC_2) - -// Function prototype -TPM_RC -TPM2_NV_ReadLock(NV_ReadLock_In* in); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_READLOCK_FP_H_ -#endif // CC_NV_ReadLock diff --git a/src/tpm2/NV_ReadPublic2_fp.h b/src/tpm2/NV_ReadPublic2_fp.h deleted file mode 100644 index df1d43f49..000000000 --- a/src/tpm2/NV_ReadPublic2_fp.h +++ /dev/null @@ -1,90 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2023 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_NV_ReadPublic2 // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_READPUBLIC2_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_READPUBLIC2_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_RH_NV_INDEX nvIndex; -} NV_ReadPublic2_In; - -// Output structure definition -typedef struct -{ - TPM2B_NV_PUBLIC_2 nvPublic; - TPM2B_NAME nvName; -} NV_ReadPublic2_Out; - -// Response code modifiers -# define RC_NV_ReadPublic2_nvIndex (TPM_RC_H + TPM_RC_1) - -// Function prototype -TPM_RC -TPM2_NV_ReadPublic2(NV_ReadPublic2_In* in, NV_ReadPublic2_Out* out); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_READPUBLIC2_FP_H_ -#endif // CC_NV_ReadPublic2 diff --git a/src/tpm2/NV_ReadPublic_fp.h b/src/tpm2/NV_ReadPublic_fp.h deleted file mode 100644 index 1dad1440c..000000000 --- a/src/tpm2/NV_ReadPublic_fp.h +++ /dev/null @@ -1,91 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: NV_ReadPublic_fp.h 809 2016-11-16 18:31:54Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_NV_ReadPublic // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_READPUBLIC_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_READPUBLIC_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_RH_NV_INDEX nvIndex; -} NV_ReadPublic_In; - -// Output structure definition -typedef struct -{ - TPM2B_NV_PUBLIC nvPublic; - TPM2B_NAME nvName; -} NV_ReadPublic_Out; - -// Response code modifiers -# define RC_NV_ReadPublic_nvIndex (TPM_RC_H + TPM_RC_1) - -// Function prototype -TPM_RC -TPM2_NV_ReadPublic(NV_ReadPublic_In* in, NV_ReadPublic_Out* out); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_READPUBLIC_FP_H_ -#endif // CC_NV_ReadPublic diff --git a/src/tpm2/NV_Read_fp.h b/src/tpm2/NV_Read_fp.h deleted file mode 100644 index 154ad83e8..000000000 --- a/src/tpm2/NV_Read_fp.h +++ /dev/null @@ -1,96 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: NV_Read_fp.h 809 2016-11-16 18:31:54Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_NV_Read // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_READ_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_READ_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_RH_NV_AUTH authHandle; - TPMI_RH_NV_INDEX nvIndex; - UINT16 size; - UINT16 offset; -} NV_Read_In; - -// Output structure definition -typedef struct -{ - TPM2B_MAX_NV_BUFFER data; -} NV_Read_Out; - -// Response code modifiers -# define RC_NV_Read_authHandle (TPM_RC_H + TPM_RC_1) -# define RC_NV_Read_nvIndex (TPM_RC_H + TPM_RC_2) -# define RC_NV_Read_size (TPM_RC_P + TPM_RC_1) -# define RC_NV_Read_offset (TPM_RC_P + TPM_RC_2) - -// Function prototype -TPM_RC -TPM2_NV_Read(NV_Read_In* in, NV_Read_Out* out); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_READ_FP_H_ -#endif // CC_NV_Read diff --git a/src/tpm2/NV_SetBits_fp.h b/src/tpm2/NV_SetBits_fp.h deleted file mode 100644 index 50263a45f..000000000 --- a/src/tpm2/NV_SetBits_fp.h +++ /dev/null @@ -1,88 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: NV_SetBits_fp.h 809 2016-11-16 18:31:54Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_NV_SetBits // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_SETBITS_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_SETBITS_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_RH_NV_AUTH authHandle; - TPMI_RH_NV_INDEX nvIndex; - UINT64 bits; -} NV_SetBits_In; - -// Response code modifiers -# define RC_NV_SetBits_authHandle (TPM_RC_H + TPM_RC_1) -# define RC_NV_SetBits_nvIndex (TPM_RC_H + TPM_RC_2) -# define RC_NV_SetBits_bits (TPM_RC_P + TPM_RC_1) - -// Function prototype -TPM_RC -TPM2_NV_SetBits(NV_SetBits_In* in); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_SETBITS_FP_H_ -#endif // CC_NV_SetBits diff --git a/src/tpm2/NV_UndefineSpaceSpecial_fp.h b/src/tpm2/NV_UndefineSpaceSpecial_fp.h deleted file mode 100644 index 5409f7ccb..000000000 --- a/src/tpm2/NV_UndefineSpaceSpecial_fp.h +++ /dev/null @@ -1,86 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: NV_UndefineSpaceSpecial_fp.h 809 2016-11-16 18:31:54Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_NV_UndefineSpaceSpecial // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_UNDEFINESPACESPECIAL_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_UNDEFINESPACESPECIAL_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_RH_NV_DEFINED_INDEX nvIndex; - TPMI_RH_PLATFORM platform; -} NV_UndefineSpaceSpecial_In; - -// Response code modifiers -# define RC_NV_UndefineSpaceSpecial_nvIndex (TPM_RC_H + TPM_RC_1) -# define RC_NV_UndefineSpaceSpecial_platform (TPM_RC_H + TPM_RC_2) - -// Function prototype -TPM_RC -TPM2_NV_UndefineSpaceSpecial(NV_UndefineSpaceSpecial_In* in); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_UNDEFINESPACESPECIAL_FP_H_ -#endif // CC_NV_UndefineSpaceSpecial diff --git a/src/tpm2/NV_UndefineSpace_fp.h b/src/tpm2/NV_UndefineSpace_fp.h deleted file mode 100644 index 52d09b1cc..000000000 --- a/src/tpm2/NV_UndefineSpace_fp.h +++ /dev/null @@ -1,86 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: NV_UndefineSpace_fp.h 809 2016-11-16 18:31:54Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_NV_UndefineSpace // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_UNDEFINESPACE_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_UNDEFINESPACE_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_RH_PROVISION authHandle; - TPMI_RH_NV_DEFINED_INDEX nvIndex; -} NV_UndefineSpace_In; - -// Response code modifiers -# define RC_NV_UndefineSpace_authHandle (TPM_RC_H + TPM_RC_1) -# define RC_NV_UndefineSpace_nvIndex (TPM_RC_H + TPM_RC_2) - -// Function prototype -TPM_RC -TPM2_NV_UndefineSpace(NV_UndefineSpace_In* in); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_UNDEFINESPACE_FP_H_ -#endif // CC_NV_UndefineSpace diff --git a/src/tpm2/NV_WriteLock_fp.h b/src/tpm2/NV_WriteLock_fp.h deleted file mode 100644 index 68a8d344e..000000000 --- a/src/tpm2/NV_WriteLock_fp.h +++ /dev/null @@ -1,86 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: NV_WriteLock_fp.h 1521 2019-11-15 21:00:47Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_NV_WriteLock // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_WRITELOCK_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_WRITELOCK_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_RH_NV_AUTH authHandle; - TPMI_RH_NV_INDEX nvIndex; -} NV_WriteLock_In; - -// Response code modifiers -# define RC_NV_WriteLock_authHandle (TPM_RC_H + TPM_RC_1) -# define RC_NV_WriteLock_nvIndex (TPM_RC_H + TPM_RC_2) - -// Function prototype -TPM_RC -TPM2_NV_WriteLock(NV_WriteLock_In* in); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_WRITELOCK_FP_H_ -#endif // CC_NV_WriteLock diff --git a/src/tpm2/NV_Write_fp.h b/src/tpm2/NV_Write_fp.h deleted file mode 100644 index de0b76f3d..000000000 --- a/src/tpm2/NV_Write_fp.h +++ /dev/null @@ -1,90 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: NV_Write_fp.h 809 2016-11-16 18:31:54Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_NV_Write // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_WRITE_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_WRITE_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_RH_NV_AUTH authHandle; - TPMI_RH_NV_INDEX nvIndex; - TPM2B_MAX_NV_BUFFER data; - UINT16 offset; -} NV_Write_In; - -// Response code modifiers -# define RC_NV_Write_authHandle (TPM_RC_H + TPM_RC_1) -# define RC_NV_Write_nvIndex (TPM_RC_H + TPM_RC_2) -# define RC_NV_Write_data (TPM_RC_P + TPM_RC_1) -# define RC_NV_Write_offset (TPM_RC_P + TPM_RC_2) - -// Function prototype -TPM_RC -TPM2_NV_Write(NV_Write_In* in); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_WRITE_FP_H_ -#endif // CC_NV_Write diff --git a/src/tpm2/NvReserved_fp.h b/src/tpm2/NvReserved_fp.h deleted file mode 100644 index e2e1cf310..000000000 --- a/src/tpm2/NvReserved_fp.h +++ /dev/null @@ -1,137 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: NVReserved_fp.h 1476 2019-06-10 19:32:03Z 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 */ -/* */ -/********************************************************************************/ - -/*(Auto-generated) - * Created by TpmPrototypes; Version 3.0 July 18, 2017 - * Date: Apr 2, 2019 Time: 04:23:27PM - */ - -#ifndef _NV_RESERVED_FP_H_ -#define _NV_RESERVED_FP_H_ - -#include "NVMarshal.h" /* libtpms added */ - -//*** NvCheckState() -// Function to check the NV state by accessing the platform-specific function -// to get the NV state. The result state is registered in s_NvIsAvailable -// that will be reported by NvIsAvailable. -// -// This function is called at the beginning of ExecuteCommand before any potential -// check of g_NvStatus. -void NvCheckState(void); - -//*** NvCommit -// This is a wrapper for the platform function to commit pending NV writes. -BOOL NvCommit(void); - -//*** NvPowerOn() -// This function is called at _TPM_Init to initialize the NV environment. -// Return Type: BOOL -// TRUE(1) all NV was initialized -// FALSE(0) the NV containing saved state had an error and -// TPM2_Startup(CLEAR) is required -BOOL NvPowerOn(void); - -//*** NvManufacture() -// This function initializes the NV system at pre-install time. -// -// This function should only be called in a manufacturing environment or in a -// simulation. -// -// The layout of NV memory space is an implementation choice. -void NvManufacture(void); - -//*** NvRead() -// This function is used to move reserved data from NV memory to RAM. -void NvRead(void* outBuffer, // OUT: buffer to receive data - UINT32 nvOffset, // IN: offset in NV of value - UINT32 size // IN: size of the value to read -); - -//*** NvWrite() -// This function is used to post reserved data for writing to NV memory. Before -// the TPM completes the operation, the value will be written. -BOOL NvWrite(UINT32 nvOffset, // IN: location in NV to receive data - UINT32 size, // IN: size of the data to move - void* inBuffer // IN: location containing data to write -); - -//*** NvUpdatePersistent() -// This function is used to update a value in the PERSISTENT_DATA structure and -// commits the value to NV. -void NvUpdatePersistent( - UINT32 offset, // IN: location in PERMANENT_DATA to be updated - UINT32 size, // IN: size of the value - void* buffer // IN: the new data -); - -//*** NvClearPersistent() -// This function is used to clear a persistent data entry and commit it to NV -void NvClearPersistent(UINT32 offset, // IN: the offset in the PERMANENT_DATA - // structure to be cleared (zeroed) - UINT32 size // IN: number of bytes to clear -); - -//*** NvReadPersistent() -// This function reads persistent data to the RAM copy of the 'gp' structure. -void NvReadPersistent(void); - -#endif // _NV_RESERVED_FP_H_ diff --git a/src/tpm2/ObjectChangeAuth_fp.h b/src/tpm2/ObjectChangeAuth_fp.h deleted file mode 100644 index f9deff382..000000000 --- a/src/tpm2/ObjectChangeAuth_fp.h +++ /dev/null @@ -1,94 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: ObjectChangeAuth_fp.h 809 2016-11-16 18:31:54Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_ObjectChangeAuth // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_OBJECTCHANGEAUTH_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_OBJECTCHANGEAUTH_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_DH_OBJECT objectHandle; - TPMI_DH_OBJECT parentHandle; - TPM2B_AUTH newAuth; -} ObjectChangeAuth_In; - -// Output structure definition -typedef struct -{ - TPM2B_PRIVATE outPrivate; -} ObjectChangeAuth_Out; - -// Response code modifiers -# define RC_ObjectChangeAuth_objectHandle (TPM_RC_H + TPM_RC_1) -# define RC_ObjectChangeAuth_parentHandle (TPM_RC_H + TPM_RC_2) -# define RC_ObjectChangeAuth_newAuth (TPM_RC_P + TPM_RC_1) - -// Function prototype -TPM_RC -TPM2_ObjectChangeAuth(ObjectChangeAuth_In* in, ObjectChangeAuth_Out* out); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_OBJECTCHANGEAUTH_FP_H_ -#endif // CC_ObjectChangeAuth diff --git a/src/tpm2/ObjectCommands.c b/src/tpm2/ObjectCommands.c index 6abfbacce..972ad441d 100644 --- a/src/tpm2/ObjectCommands.c +++ b/src/tpm2/ObjectCommands.c @@ -58,138 +58,6 @@ /* */ /********************************************************************************/ -#include "Tpm.h" -#include "Object_spt_fp.h" -#include "Create_fp.h" - -#if CC_Create // Conditional expansion of this file - -/*(See part 3 specification) -// Create a regular object -*/ -// Return Type: TPM_RC -// TPM_RC_ATTRIBUTES 'sensitiveDataOrigin' is CLEAR when 'sensitive.data' -// is an Empty Buffer, or is SET when 'sensitive.data' is -// not empty; -// 'fixedTPM', 'fixedParent', or 'encryptedDuplication' -// attributes are inconsistent between themselves or with -// those of the parent object; -// inconsistent 'restricted', 'decrypt' and 'sign' -// attributes; -// attempt to inject sensitive data for an asymmetric -// key; -// TPM_RC_HASH non-duplicable storage key and its parent have -// different name algorithm -// TPM_RC_KDF incorrect KDF specified for decrypting keyed hash -// object -// TPM_RC_KEY invalid key size values in an asymmetric key public -// area or a provided symmetric key has a value that is -// not allowed -// TPM_RC_KEY_SIZE key size in public area for symmetric key differs from -// the size in the sensitive creation area; may also be -// returned if the TPM does not allow the key size to be -// used for a Storage Key -// TPM_RC_OBJECT_MEMORY a free slot is not available as scratch memory for -// object creation -// TPM_RC_RANGE the exponent value of an RSA key is not supported. -// TPM_RC_SCHEME inconsistent attributes 'decrypt', 'sign', or -// 'restricted' and key's scheme ID; or hash algorithm is -// inconsistent with the scheme ID for keyed hash object -// TPM_RC_SIZE size of public authPolicy or sensitive authValue does -// not match digest size of the name algorithm -// sensitive data size for the keyed hash object is -// larger than is allowed for the scheme -// TPM_RC_SYMMETRIC a storage key with no symmetric algorithm specified; -// or non-storage key with symmetric algorithm different -// from TPM_ALG_NULL -// TPM_RC_TYPE unknown object type; -// 'parentHandle' does not reference a restricted -// decryption key in the storage hierarchy with both -// public and sensitive portion loaded -// TPM_RC_VALUE exponent is not prime or could not find a prime using -// the provided parameters for an RSA key; -// unsupported name algorithm for an ECC key -// TPM_RC_OBJECT_MEMORY there is no free slot for the object -TPM_RC -TPM2_Create(Create_In* in, // IN: input parameter list - Create_Out* out // OUT: output parameter list - ) -{ - TPM_RC result = TPM_RC_SUCCESS; - OBJECT* parentObject; - OBJECT* newObject; - TPMT_PUBLIC* publicArea; - // Input Validation - parentObject = HandleToObject(in->parentHandle); - pAssert(parentObject != NULL); - - // Does parent have the proper attributes? - if(!ObjectIsParent(parentObject)) - return TPM_RCS_TYPE + RC_Create_parentHandle; - - // Get a slot for the creation - newObject = FindEmptyObjectSlot(NULL); - if(newObject == NULL) - return TPM_RC_OBJECT_MEMORY; - // If the TPM2B_PUBLIC was passed as a structure, marshal it into is canonical - // form for processing - - // to save typing. - publicArea = &newObject->publicArea; - - // Copy the input structure to the allocated structure - *publicArea = in->inPublic.publicArea; - - // Check attributes in input public area. CreateChecks() checks the things that - // are unique to creation and then validates the attributes and values that are - // common to create and load. - result = CreateChecks(parentObject, - /* primaryHierarchy = */ 0, - publicArea, - in->inSensitive.sensitive.data.t.size); - if(result != TPM_RC_SUCCESS) - return RcSafeAddToResult(result, RC_Create_inPublic); - // Clean up the authValue if necessary - if(!AdjustAuthSize(&in->inSensitive.sensitive.userAuth, publicArea->nameAlg)) - return TPM_RCS_SIZE + RC_Create_inSensitive; - - // Command Output - // Create the object using the default TPM random-number generator - result = CryptCreateObject(newObject, &in->inSensitive.sensitive, NULL); - if(result != TPM_RC_SUCCESS) - return result; - // Fill in creation data - FillInCreationData(in->parentHandle, - publicArea->nameAlg, - &in->creationPCR, - &in->outsideInfo, - &out->creationData, - &out->creationHash); - - // Compute creation ticket - result = TicketComputeCreation(EntityGetHierarchy(in->parentHandle), - &newObject->name, - &out->creationHash, - &out->creationTicket); - if(result != TPM_RC_SUCCESS) - return result; - - // Prepare output private data from sensitive - SensitiveToPrivate(&newObject->sensitive, - &newObject->name, - parentObject, - publicArea->nameAlg, - &out->outPrivate); - - newObject->hierarchy = parentObject->hierarchy; - - // Finish by copying the remaining return values - out->outPublic.publicArea = newObject->publicArea; - return TPM_RC_SUCCESS; -} - -#endif // CC_Create - #include "Tpm.h" #include "Load_fp.h" #if CC_Load // Conditional expansion of this file @@ -238,7 +106,7 @@ TPM2_Load( if(in->inPrivate.t.size == 0) return TPM_RCS_SIZE + RC_Load_inPrivate; parentObject = HandleToObject(in->parentHandle); - pAssert(parentObject != NULL); + pAssert_RC(parentObject != NULL); // Is the object that is being used as the parent actually a parent. if(!ObjectIsParent(parentObject)) return TPM_RCS_TYPE + RC_Load_parentHandle; @@ -343,6 +211,11 @@ TPM2_ReadPublic( // Can not read public area of a sequence object if(ObjectIsSequence(object)) return TPM_RC_SEQUENCE; + + // deliberately after ObjectIsSequence in case ObjectInSequence decides a + // null object is a non-fatal error + pAssert_RC(object != NULL); + // Command Output out->outPublic.publicArea = object->publicArea; out->name = object->name; @@ -386,6 +259,10 @@ TPM2_ActivateCredential( return TPM_RC_FAILURE; return RcSafeAddToResult(result, RC_ActivateCredential_secret); } + // this assertion is deliberately late, after other validation has happened + // soas to not change existing behavior of the function + pAssert_RC(activateObject != NULL); + // Retrieve secret data. A TPM_RC_INTEGRITY error or unmarshal // errors may be returned at this point result = CredentialToSecret(&in->credentialBlob.b, @@ -399,44 +276,6 @@ TPM2_ActivateCredential( } #endif // CC_ActivateCredential #include "Tpm.h" -#include "MakeCredential_fp.h" -#if CC_MakeCredential // Conditional expansion of this file -#include "Object_spt_fp.h" -TPM_RC -TPM2_MakeCredential( - MakeCredential_In *in, // IN: input parameter list - MakeCredential_Out *out // OUT: output parameter list - ) -{ - TPM_RC result = TPM_RC_SUCCESS; - OBJECT *object; - TPM2B_DATA data; - // Input Validation - // Get object pointer - object = HandleToObject(in->handle); - // input key must be an asymmetric, restricted decryption key - // NOTE: Needs to be restricted to have a symmetric value. - if(!CryptIsAsymAlgorithm(object->publicArea.type) - || !IS_ATTRIBUTE(object->publicArea.objectAttributes, TPMA_OBJECT, decrypt) - || !IS_ATTRIBUTE(object->publicArea.objectAttributes, TPMA_OBJECT, restricted)) - return TPM_RCS_TYPE + RC_MakeCredential_handle; - // The credential information may not be larger than the digest size used for - // the Name of the key associated with handle. - if(in->credential.t.size > CryptHashGetDigestSize(object->publicArea.nameAlg)) - return TPM_RCS_SIZE + RC_MakeCredential_credential; - // Command Output - // Make encrypt key and its associated secret structure. - out->secret.t.size = sizeof(out->secret.t.secret); - result = CryptSecretEncrypt(object, IDENTITY_STRING, &data, &out->secret); - if(result != TPM_RC_SUCCESS) - return result; - // Prepare output credential data from secret - SecretToCredential(&in->credential, &in->objectName.b, &data.b, - object, &out->credentialBlob); - return TPM_RC_SUCCESS; -} -#endif // CC_MakeCredential -#include "Tpm.h" #include "Unseal_fp.h" #if CC_Unseal // Conditional expansion of this file TPM_RC @@ -449,6 +288,8 @@ TPM2_Unseal( // Input Validation // Get pointer to loaded object object = HandleToObject(in->itemHandle); + pAssert_RC(object != NULL); + // Input handle must be a data object if(object->publicArea.type != TPM_ALG_KEYEDHASH) return TPM_RCS_TYPE + RC_Unseal_itemHandle; @@ -462,260 +303,4 @@ TPM2_Unseal( return TPM_RC_SUCCESS; } #endif // CC_Unseal -#include "Tpm.h" -#include "ObjectChangeAuth_fp.h" -#if CC_ObjectChangeAuth // Conditional expansion of this file -#include "Object_spt_fp.h" -TPM_RC -TPM2_ObjectChangeAuth( - ObjectChangeAuth_In *in, // IN: input parameter list - ObjectChangeAuth_Out *out // OUT: output parameter list - ) -{ - TPMT_SENSITIVE sensitive; - OBJECT *object = HandleToObject(in->objectHandle); - TPM2B_NAME QNCompare; - // Input Validation - // Can not change authorization on sequence object - if(ObjectIsSequence(object)) - return TPM_RCS_TYPE + RC_ObjectChangeAuth_objectHandle; - // Make sure that the authorization value is consistent with the nameAlg - if(!AdjustAuthSize(&in->newAuth, object->publicArea.nameAlg)) - return TPM_RCS_SIZE + RC_ObjectChangeAuth_newAuth; - // Parent handle should be the parent of object handle. In this - // implementation we verify this by checking the QN of object. Other - // implementation may choose different method to verify this attribute. - ComputeQualifiedName(in->parentHandle, - object->publicArea.nameAlg, - &object->name, &QNCompare); - if(!MemoryEqual2B(&object->qualifiedName.b, &QNCompare.b)) - return TPM_RCS_TYPE + RC_ObjectChangeAuth_parentHandle; - // Command Output - // Prepare the sensitive area with the new authorization value - sensitive = object->sensitive; - sensitive.authValue = in->newAuth; - // Protect the sensitive area - SensitiveToPrivate(&sensitive, &object->name, HandleToObject(in->parentHandle), - object->publicArea.nameAlg, - &out->outPrivate); - return TPM_RC_SUCCESS; -} -#endif // CC_ObjectChangeAuth - -#include "Tpm.h" -#include "CreateLoaded_fp.h" - -#if CC_CreateLoaded // Conditional expansion of this file - -/*(See part 3 of specification) - * Create and load any type of key, including a temporary key. - * The input template is a marshaled public area rather than an unmarshaled one as - * used in Create and CreatePrimary. This is so that the label and context that - * could be in the template can be processed without changing the formats for the - * calls to Create and CreatePrimary. - */ -// Return Type: TPM_RC -// TPM_RC_ATTRIBUTES 'sensitiveDataOrigin' is CLEAR when 'sensitive.data' -// is an Empty Buffer; -// 'fixedTPM', 'fixedParent', or 'encryptedDuplication' -// attributes are inconsistent between themselves or with -// those of the parent object; -// inconsistent 'restricted', 'decrypt' and 'sign' -// attributes; -// attempt to inject sensitive data for an asymmetric -// key; -// attempt to create a symmetric cipher key that is not -// a decryption key -// TPM_RC_FW_LIMITED The requested hierarchy is FW-limited, but the TPM -// does not support FW-limited objects or the TPM failed -// to derive the Firmware Secret. -// TPM_RC_SVN_LIMITED The requested hierarchy is SVN-limited, but the TPM -// does not support SVN-limited objects or the TPM failed -// to derive the Firmware SVN Secret for the requested -// SVN. -// TPM_RC_KDF incorrect KDF specified for decrypting keyed hash -// object -// TPM_RC_KEY the value of a provided symmetric key is not allowed -// TPM_RC_OBJECT_MEMORY there is no free slot for the object -// TPM_RC_SCHEME inconsistent attributes 'decrypt', 'sign', -// 'restricted' and key's scheme ID; or hash algorithm is -// inconsistent with the scheme ID for keyed hash object -// TPM_RC_SIZE size of public authorization policy or sensitive -// authorization value does not match digest size of the -// name algorithm sensitive data size for the keyed hash -// object is larger than is allowed for the scheme -// TPM_RC_SYMMETRIC a storage key with no symmetric algorithm specified; -// or non-storage key with symmetric algorithm different -// from TPM_ALG_NULL -// TPM_RC_TYPE cannot create the object of the indicated type -// (usually only occurs if trying to derive an RSA key). -TPM_RC -TPM2_CreateLoaded(CreateLoaded_In* in, // IN: input parameter list - CreateLoaded_Out* out // OUT: output parameter list - ) -{ - TPM_RC result = TPM_RC_SUCCESS; - OBJECT* parent = HandleToObject(in->parentHandle); - OBJECT* newObject; - BOOL derivation; - TPMT_PUBLIC* publicArea; - RAND_STATE randState; - RAND_STATE* rand = &randState; - TPMS_DERIVE labelContext; - SEED_COMPAT_LEVEL seedCompatLevel = RuntimeProfileGetSeedCompatLevel(); // libtpms added - - // Input Validation - - // How the public area is unmarshaled is determined by the parent, so - // see if parent is a derivation parent - derivation = (parent != NULL && parent->attributes.derivation); - - // If the parent is an object, then make sure that it is either a parent or - // derivation parent - if(parent != NULL && !parent->attributes.isParent && !derivation) - return TPM_RCS_TYPE + RC_CreateLoaded_parentHandle; - - // Get a spot in which to create the newObject - newObject = FindEmptyObjectSlot(&out->objectHandle); - if(newObject == NULL) - return TPM_RC_OBJECT_MEMORY; - - // Do this to save typing - publicArea = &newObject->publicArea; - - // Unmarshal the template into the object space. TPM2_Create() and - // TPM2_CreatePrimary() have the publicArea unmarshaled by CommandDispatcher. - // This command is different because of an unfortunate property of the - // unique field of an ECC key. It is a structure rather than a single TPM2B. If - // if had been a TPM2B, then the label and context could be within a TPM2B and - // unmarshaled like other public areas. Since it is not, this command needs its - // on template that is a TPM2B that is unmarshaled as a BYTE array with a - // its own unmarshal function. - result = UnmarshalToPublic(publicArea, &in->inPublic, derivation, &labelContext); - if(result != TPM_RC_SUCCESS) - return result + RC_CreateLoaded_inPublic; - - // Validate that the authorization size is appropriate - if(!AdjustAuthSize(&in->inSensitive.sensitive.userAuth, publicArea->nameAlg)) - return TPM_RCS_SIZE + RC_CreateLoaded_inSensitive; - - // Command output - if(derivation) - { - TPMT_KEYEDHASH_SCHEME* scheme; - scheme = &parent->publicArea.parameters.keyedHashDetail.scheme; - - // SP800-108 is the only KDF supported by this implementation and there is - // no default hash algorithm. - pAssert(scheme->details.xor.hashAlg != TPM_ALG_NULL - && scheme->details.xor.kdf == TPM_ALG_KDF1_SP800_108); - // Don't derive RSA keys - if(publicArea->type == TPM_ALG_RSA) - return TPM_RCS_TYPE + RC_CreateLoaded_inPublic; - if(publicArea->type == TPM_ALG_ECC && // libtpms added begin - RuntimeProfileRequiresAttributeFlags(&g_RuntimeProfile, - RUNTIME_ATTRIBUTE_NO_ECC_KEY_DERIVATION)) - return TPM_RCS_TYPE + RC_CreateLoaded_inPublic; // libtpms added end - // sensitiveDataOrigin has to be CLEAR in a derived object. Since this - // is specific to a derived object, it is checked here. - if(IS_ATTRIBUTE( - publicArea->objectAttributes, TPMA_OBJECT, sensitiveDataOrigin)) - return TPM_RCS_ATTRIBUTES; - // Check the rest of the attributes - result = PublicAttributesValidation(parent, 0, publicArea); - if(result != TPM_RC_SUCCESS) - return RcSafeAddToResult(result, RC_CreateLoaded_inPublic); - // Process the template and sensitive areas to get the actual 'label' and - // 'context' values to be used for this derivation. - result = SetLabelAndContext(&labelContext, &in->inSensitive.sensitive.data); - if(result != TPM_RC_SUCCESS) - return result; - // Set up the KDF for object generation - DRBG_InstantiateSeededKdf((KDF_STATE*)rand, - scheme->details.xor.hashAlg, - scheme->details.xor.kdf, - &parent->sensitive.sensitive.bits.b, - &labelContext.label.b, - &labelContext.context.b, - TPM_MAX_DERIVATION_BITS); - // Clear the sensitive size so that the creation functions will not try - // to use this value. - in->inSensitive.sensitive.data.t.size = 0; - seedCompatLevel = parent->seedCompatLevel; // libtpms added - } - else - { - // Check attributes in input public area. CreateChecks() checks the things - // that are unique to creation and then validates the attributes and values - // that are common to create and load. - result = CreateChecks(parent, - (parent == NULL) ? in->parentHandle : 0, - publicArea, - in->inSensitive.sensitive.data.t.size); - - if(result != TPM_RC_SUCCESS) - return RcSafeAddToResult(result, RC_CreateLoaded_inPublic); - // Creating a primary object - if(parent == NULL) - { - TPM2B_NAME name; - TPM2B_SEED primary_seed; - - newObject->attributes.primary = SET; - if(HierarchyNormalizeHandle(in->parentHandle) == TPM_RH_ENDORSEMENT) - newObject->attributes.epsHierarchy = SET; - seedCompatLevel = HierarchyGetPrimarySeedCompatLevel(in->parentHandle); // libtpms added - // If so, use the primary seed and the digest of the template - // to seed the DRBG - - result = HierarchyGetPrimarySeed(in->parentHandle, &primary_seed); - if(result != TPM_RC_SUCCESS) - return result; - - // If so, use the primary seed and the digest of the template - // to seed the DRBG - result = DRBG_InstantiateSeeded( - (DRBG_STATE*)rand, - &primary_seed.b, - PRIMARY_OBJECT_CREATION, - (TPM2B*)PublicMarshalAndComputeName(publicArea, &name), - &in->inSensitive.sensitive.data.b, - seedCompatLevel); // libtpms added - MemorySet(primary_seed.b.buffer, 0, primary_seed.b.size); - - if(result != TPM_RC_SUCCESS) - return result; - } - else - { - // This is an ordinary object so use the normal random number generator - rand = NULL; - } - } - // Internal data update - // Create the object - result = CryptCreateObject(newObject, &in->inSensitive.sensitive, rand); - DRBG_Uninstantiate((DRBG_STATE*)rand); - if(result != TPM_RC_SUCCESS) - return result; - // if this is not a Primary key and not a derived key, then return the sensitive - // area - if(parent != NULL && !derivation) - // Prepare output private data from sensitive - SensitiveToPrivate(&newObject->sensitive, - &newObject->name, - parent, - newObject->publicArea.nameAlg, - &out->outPrivate); - else - out->outPrivate.t.size = 0; - // Set the remaining return values - out->outPublic.publicArea = newObject->publicArea; - out->name = newObject->name; - // Set the remaining attributes for a loaded object - ObjectSetLoadedAttributes(newObject, in->parentHandle, - seedCompatLevel); // libtpms added - return result; -} -#endif // CC_CreateLoaded diff --git a/src/tpm2/PCR_Allocate_fp.h b/src/tpm2/PCR_Allocate_fp.h deleted file mode 100644 index dab75c6e5..000000000 --- a/src/tpm2/PCR_Allocate_fp.h +++ /dev/null @@ -1,95 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: PCR_Allocate_fp.h 1521 2019-11-15 21:00:47Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_PCR_Allocate // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_PCR_ALLOCATE_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_PCR_ALLOCATE_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_RH_PLATFORM authHandle; - TPML_PCR_SELECTION pcrAllocation; -} PCR_Allocate_In; - -// Output structure definition -typedef struct -{ - TPMI_YES_NO allocationSuccess; - UINT32 maxPCR; - UINT32 sizeNeeded; - UINT32 sizeAvailable; -} PCR_Allocate_Out; - -// Response code modifiers -# define RC_PCR_Allocate_authHandle (TPM_RC_H + TPM_RC_1) -# define RC_PCR_Allocate_pcrAllocation (TPM_RC_P + TPM_RC_1) - -// Function prototype -TPM_RC -TPM2_PCR_Allocate(PCR_Allocate_In* in, PCR_Allocate_Out* out); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_PCR_ALLOCATE_FP_H_ -#endif // CC_PCR_Allocate diff --git a/src/tpm2/PCR_Event_fp.h b/src/tpm2/PCR_Event_fp.h deleted file mode 100644 index 130fbb8c3..000000000 --- a/src/tpm2/PCR_Event_fp.h +++ /dev/null @@ -1,92 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: PCR_Event_fp.h 809 2016-11-16 18:31:54Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_PCR_Event // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_PCR_EVENT_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_PCR_EVENT_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_DH_PCR pcrHandle; - TPM2B_EVENT eventData; -} PCR_Event_In; - -// Output structure definition -typedef struct -{ - TPML_DIGEST_VALUES digests; -} PCR_Event_Out; - -// Response code modifiers -# define RC_PCR_Event_pcrHandle (TPM_RC_H + TPM_RC_1) -# define RC_PCR_Event_eventData (TPM_RC_P + TPM_RC_1) - -// Function prototype -TPM_RC -TPM2_PCR_Event(PCR_Event_In* in, PCR_Event_Out* out); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_PCR_EVENT_FP_H_ -#endif // CC_PCR_Event diff --git a/src/tpm2/PCR_Extend_fp.h b/src/tpm2/PCR_Extend_fp.h deleted file mode 100644 index 0b38058cd..000000000 --- a/src/tpm2/PCR_Extend_fp.h +++ /dev/null @@ -1,86 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: PCR_Extend_fp.h 809 2016-11-16 18:31:54Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_PCR_Extend // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_PCR_EXTEND_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_PCR_EXTEND_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_DH_PCR pcrHandle; - TPML_DIGEST_VALUES digests; -} PCR_Extend_In; - -// Response code modifiers -# define RC_PCR_Extend_pcrHandle (TPM_RC_H + TPM_RC_1) -# define RC_PCR_Extend_digests (TPM_RC_P + TPM_RC_1) - -// Function prototype -TPM_RC -TPM2_PCR_Extend(PCR_Extend_In* in); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_PCR_EXTEND_FP_H_ -#endif // CC_PCR_Extend diff --git a/src/tpm2/PCR_Read_fp.h b/src/tpm2/PCR_Read_fp.h deleted file mode 100644 index ac94cc9f4..000000000 --- a/src/tpm2/PCR_Read_fp.h +++ /dev/null @@ -1,92 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: PCR_Read_fp.h 809 2016-11-16 18:31:54Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_PCR_Read // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_PCR_READ_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_PCR_READ_FP_H_ - -// Input structure definition -typedef struct -{ - TPML_PCR_SELECTION pcrSelectionIn; -} PCR_Read_In; - -// Output structure definition -typedef struct -{ - UINT32 pcrUpdateCounter; - TPML_PCR_SELECTION pcrSelectionOut; - TPML_DIGEST pcrValues; -} PCR_Read_Out; - -// Response code modifiers -# define RC_PCR_Read_pcrSelectionIn (TPM_RC_P + TPM_RC_1) - -// Function prototype -TPM_RC -TPM2_PCR_Read(PCR_Read_In* in, PCR_Read_Out* out); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_PCR_READ_FP_H_ -#endif // CC_PCR_Read diff --git a/src/tpm2/PCR_Reset_fp.h b/src/tpm2/PCR_Reset_fp.h deleted file mode 100644 index e7c581eae..000000000 --- a/src/tpm2/PCR_Reset_fp.h +++ /dev/null @@ -1,84 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: PCR_Reset_fp.h 809 2016-11-16 18:31:54Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_PCR_Reset // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_PCR_RESET_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_PCR_RESET_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_DH_PCR pcrHandle; -} PCR_Reset_In; - -// Response code modifiers -# define RC_PCR_Reset_pcrHandle (TPM_RC_H + TPM_RC_1) - -// Function prototype -TPM_RC -TPM2_PCR_Reset(PCR_Reset_In* in); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_PCR_RESET_FP_H_ -#endif // CC_PCR_Reset diff --git a/src/tpm2/PCR_SetAuthPolicy_fp.h b/src/tpm2/PCR_SetAuthPolicy_fp.h deleted file mode 100644 index 8c1b43bb5..000000000 --- a/src/tpm2/PCR_SetAuthPolicy_fp.h +++ /dev/null @@ -1,90 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: PCR_SetAuthPolicy_fp.h 809 2016-11-16 18:31:54Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_PCR_SetAuthPolicy // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_PCR_SETAUTHPOLICY_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_PCR_SETAUTHPOLICY_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_RH_PLATFORM authHandle; - TPM2B_DIGEST authPolicy; - TPMI_ALG_HASH hashAlg; - TPMI_DH_PCR pcrNum; -} PCR_SetAuthPolicy_In; - -// Response code modifiers -# define RC_PCR_SetAuthPolicy_authHandle (TPM_RC_H + TPM_RC_1) -# define RC_PCR_SetAuthPolicy_authPolicy (TPM_RC_P + TPM_RC_1) -# define RC_PCR_SetAuthPolicy_hashAlg (TPM_RC_P + TPM_RC_2) -# define RC_PCR_SetAuthPolicy_pcrNum (TPM_RC_P + TPM_RC_3) - -// Function prototype -TPM_RC -TPM2_PCR_SetAuthPolicy(PCR_SetAuthPolicy_In* in); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_PCR_SETAUTHPOLICY_FP_H_ -#endif // CC_PCR_SetAuthPolicy diff --git a/src/tpm2/PCR_SetAuthValue_fp.h b/src/tpm2/PCR_SetAuthValue_fp.h deleted file mode 100644 index 00073ad32..000000000 --- a/src/tpm2/PCR_SetAuthValue_fp.h +++ /dev/null @@ -1,86 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: PCR_SetAuthValue_fp.h 809 2016-11-16 18:31:54Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_PCR_SetAuthValue // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_PCR_SETAUTHVALUE_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_PCR_SETAUTHVALUE_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_DH_PCR pcrHandle; - TPM2B_DIGEST auth; -} PCR_SetAuthValue_In; - -// Response code modifiers -# define RC_PCR_SetAuthValue_pcrHandle (TPM_RC_H + TPM_RC_1) -# define RC_PCR_SetAuthValue_auth (TPM_RC_P + TPM_RC_1) - -// Function prototype -TPM_RC -TPM2_PCR_SetAuthValue(PCR_SetAuthValue_In* in); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_PCR_SETAUTHVALUE_FP_H_ -#endif // CC_PCR_SetAuthValue diff --git a/src/tpm2/PPPlat.c b/src/tpm2/PPPlat.c deleted file mode 100644 index 3354cbfd4..000000000 --- a/src/tpm2/PPPlat.c +++ /dev/null @@ -1,107 +0,0 @@ -/********************************************************************************/ -/* */ -/* Simulates the Physical Present Interface */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: PPPlat.c 1490 2019-07-26 21:13:22Z 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 */ -/* */ -/********************************************************************************/ - -//** Description - -// This module simulates the physical presence interface pins on the TPM. - -//** Includes -#include "Platform.h" -#include "LibtpmsCallbacks.h" /* libtpms added */ - -//** Functions - -//***_plat__PhysicalPresenceAsserted() -// Check if physical presence is signaled -// Return Type: int -// TRUE(1) if physical presence is signaled -// FALSE(0) if physical presence is not signaled -LIB_EXPORT int _plat__PhysicalPresenceAsserted(void) -{ -#ifdef TPM_LIBTPMS_CALLBACKS - BOOL pp; - int ret = libtpms_plat__PhysicalPresenceAsserted(&pp); - - if (ret != LIBTPMS_CALLBACK_FALLTHROUGH) - return pp; -#endif /* TPM_LIBTPMS_CALLBACKS */ - // Do not know how to check physical presence without real hardware. - // so always return TRUE; - return s_physicalPresence; -} - -#if 0 /* libtpms added */ -//***_plat__Signal_PhysicalPresenceOn() -// Signal physical presence on -LIB_EXPORT void _plat__Signal_PhysicalPresenceOn(void) -{ - s_physicalPresence = TRUE; - return; -} - -//***_plat__Signal_PhysicalPresenceOff() -// Signal physical presence off -LIB_EXPORT void _plat__Signal_PhysicalPresenceOff(void) -{ - s_physicalPresence = FALSE; - return; -} -#endif /* libtpms added */ diff --git a/src/tpm2/PP_Commands_fp.h b/src/tpm2/PP_Commands_fp.h deleted file mode 100644 index 1af15abc2..000000000 --- a/src/tpm2/PP_Commands_fp.h +++ /dev/null @@ -1,88 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: PP_Commands_fp.h 1521 2019-11-15 21:00:47Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2016 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_PP_Commands // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_PP_COMMANDS_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_PP_COMMANDS_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_RH_PLATFORM auth; - TPML_CC setList; - TPML_CC clearList; -} PP_Commands_In; - -// Response code modifiers -# define RC_PP_Commands_auth (TPM_RC_H + TPM_RC_1) -# define RC_PP_Commands_setList (TPM_RC_P + TPM_RC_1) -# define RC_PP_Commands_clearList (TPM_RC_P + TPM_RC_2) - -// Function prototype -TPM_RC -TPM2_PP_Commands(PP_Commands_In* in); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_PP_COMMANDS_FP_H_ -#endif // CC_PP_Commands diff --git a/src/tpm2/PP_fp.h b/src/tpm2/PP_fp.h deleted file mode 100644 index df7daf540..000000000 --- a/src/tpm2/PP_fp.h +++ /dev/null @@ -1,119 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* 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 */ -/* */ -/********************************************************************************/ - -/*(Auto-generated) - * Created by TpmPrototypes; Version 3.0 July 18, 2017 - * Date: Mar 28, 2019 Time: 08:25:19PM - */ - -#ifndef _PP_FP_H_ -#define _PP_FP_H_ - -//*** PhysicalPresencePreInstall_Init() -// This function is used to initialize the array of commands that always require -// confirmation with physical presence. The array is an array of bits that -// has a correspondence with the command code. -// -// This command should only ever be executable in a manufacturing setting or in -// a simulation. -// -// When set, these cannot be cleared. -// -void PhysicalPresencePreInstall_Init(void); - -//*** PhysicalPresenceCommandSet() -// This function is used to set the indicator that a command requires -// PP confirmation. -void PhysicalPresenceCommandSet(TPM_CC commandCode // IN: command code -); - -//*** PhysicalPresenceCommandClear() -// This function is used to clear the indicator that a command requires PP -// confirmation. -void PhysicalPresenceCommandClear(TPM_CC commandCode // IN: command code -); - -//*** PhysicalPresenceIsRequired() -// This function indicates if PP confirmation is required for a command. -// Return Type: BOOL -// TRUE(1) physical presence is required -// FALSE(0) physical presence is not required -BOOL PhysicalPresenceIsRequired(COMMAND_INDEX commandIndex // IN: command index -); - -//*** PhysicalPresenceCapGetCCList() -// This function returns a list of commands that require PP confirmation. The -// list starts from the first implemented command that has a command code that -// the same or greater than 'commandCode'. -// Return Type: TPMI_YES_NO -// YES if there are more command codes available -// NO all the available command codes have been returned -TPMI_YES_NO -PhysicalPresenceCapGetCCList(TPM_CC commandCode, // IN: start command code - UINT32 count, // IN: count of returned TPM_CC - TPML_CC* commandList // OUT: list of TPM_CC -); - -//*** PhysicalPresenceCapGetOneCC() -// This function returns true if the command requires Physical Presence. -BOOL PhysicalPresenceCapGetOneCC(TPM_CC commandCode // IN: command code -); - -#endif // _PP_FP_H_ diff --git a/src/tpm2/PRNG_TestVectors.h b/src/tpm2/PRNG_TestVectors.h deleted file mode 100644 index 3ed24ab03..000000000 --- a/src/tpm2/PRNG_TestVectors.h +++ /dev/null @@ -1,158 +0,0 @@ -/********************************************************************************/ -/* */ -/* PRNG Test Vectors */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: PRNG_TestVectors.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 */ -/* */ -/********************************************************************************/ - -#ifndef _MSBN_DRBG_TEST_VECTORS_H -#define _MSBN_DRBG_TEST_VECTORS_H - -//#if DRBG_ALGORITHM == TPM_ALG_AES && DRBG_KEY_BITS == 256 -#if DRBG_KEY_SIZE_BITS == 256 - -/*(NIST test vector) -[AES-256 no df] -[PredictionResistance = False] -[EntropyInputLen = 384] -[NonceLen = 128] -[PersonalizationStringLen = 0] -[AdditionalInputLen = 0] - -COUNT = 0 -EntropyInput = 0d15aa80 b16c3a10 906cfedb 795dae0b 5b81041c 5c5bfacb - 373d4440 d9120f7e 3d6cf909 86cf52d8 5d3e947d 8c061f91 -Nonce = 06caef5f b538e08e 1f3b0452 03f8f4b2 -PersonalizationString = -AdditionalInput = - INTERMEDIATE Key = be5df629 34cc1230 166a6773 345bbd6b - 4c8869cf 8aec1c3b 1aa98bca 37cacf61 - INTERMEDIATE V = 3182dd1e 7638ec70 014e93bd 813e524c - INTERMEDIATE ReturnedBits = 28e0ebb8 21016650 8c8f65f2 207bd0a3 -EntropyInputReseed = 6ee793a3 3955d72a d12fd80a 8a3fcf95 ed3b4dac 5795fe25 - cf869f7c 27573bbc 56f1acae 13a65042 b340093c 464a7a22 -AdditionalInputReseed = -AdditionalInput = -ReturnedBits = 946f5182 d54510b9 461248f5 71ca06c9 -*/ - -// Entropy is the size of the state. The state is the size of the key -// plus the IV. The IV is a block. If Key = 256 and Block = 128 then State = 384 -# define DRBG_TEST_INITIATE_ENTROPY \ - 0x0d, 0x15, 0xaa, 0x80, 0xb1, 0x6c, 0x3a, 0x10, 0x90, 0x6c, 0xfe, 0xdb, 0x79, \ - 0x5d, 0xae, 0x0b, 0x5b, 0x81, 0x04, 0x1c, 0x5c, 0x5b, 0xfa, 0xcb, 0x37, \ - 0x3d, 0x44, 0x40, 0xd9, 0x12, 0x0f, 0x7e, 0x3d, 0x6c, 0xf9, 0x09, 0x86, \ - 0xcf, 0x52, 0xd8, 0x5d, 0x3e, 0x94, 0x7d, 0x8c, 0x06, 0x1f, 0x91 - -# define DRBG_TEST_RESEED_ENTROPY \ - 0x6e, 0xe7, 0x93, 0xa3, 0x39, 0x55, 0xd7, 0x2a, 0xd1, 0x2f, 0xd8, 0x0a, 0x8a, \ - 0x3f, 0xcf, 0x95, 0xed, 0x3b, 0x4d, 0xac, 0x57, 0x95, 0xfe, 0x25, 0xcf, \ - 0x86, 0x9f, 0x7c, 0x27, 0x57, 0x3b, 0xbc, 0x56, 0xf1, 0xac, 0xae, 0x13, \ - 0xa6, 0x50, 0x42, 0xb3, 0x40, 0x09, 0x3c, 0x46, 0x4a, 0x7a, 0x22 - -# define DRBG_TEST_GENERATED_INTERM \ - 0x28, 0xe0, 0xeb, 0xb8, 0x21, 0x01, 0x66, 0x50, 0x8c, 0x8f, 0x65, 0xf2, 0x20, \ - 0x7b, 0xd0, 0xa3 - -# define DRBG_TEST_GENERATED \ - 0x94, 0x6f, 0x51, 0x82, 0xd5, 0x45, 0x10, 0xb9, 0x46, 0x12, 0x48, 0xf5, 0x71, \ - 0xca, 0x06, 0xc9 -#elif DRBG_KEY_SIZE_BITS == 128 -/*(NIST test vector) -[AES-128 no df] -[PredictionResistance = False] -[EntropyInputLen = 256] -[NonceLen = 64] -[PersonalizationStringLen = 0] -[AdditionalInputLen = 0] - -COUNT = 0 -EntropyInput = 8fc11bdb5aabb7e093b61428e0907303cb459f3b600dad870955f22da80a44f8 -Nonce = be1f73885ddd15aa -PersonalizationString = -AdditionalInput = - INTERMEDIATE Key = b134ecc836df6dbd624900af118dd7e6 - INTERMEDIATE V = 01bb09e86dabd75c9f26dbf6f9531368 - INTERMEDIATE ReturnedBits = dc3cf6bf5bd341135f2c6811a1071c87 -EntropyInputReseed = - 0cd53cd5eccd5a10d7ea266111259b05574fc6ddd8bed8bd72378cf82f1dba2a -AdditionalInputReseed = -AdditionalInput = -ReturnedBits = b61850decfd7106d44769a8e6e8c1ad4 -*/ - -# define DRBG_TEST_INITIATE_ENTROPY \ - 0x8f, 0xc1, 0x1b, 0xdb, 0x5a, 0xab, 0xb7, 0xe0, 0x93, 0xb6, 0x14, 0x28, 0xe0, \ - 0x90, 0x73, 0x03, 0xcb, 0x45, 0x9f, 0x3b, 0x60, 0x0d, 0xad, 0x87, 0x09, \ - 0x55, 0xf2, 0x2d, 0xa8, 0x0a, 0x44, 0xf8 - -# define DRBG_TEST_RESEED_ENTROPY \ - 0x0c, 0xd5, 0x3c, 0xd5, 0xec, 0xcd, 0x5a, 0x10, 0xd7, 0xea, 0x26, 0x61, 0x11, \ - 0x25, 0x9b, 0x05, 0x57, 0x4f, 0xc6, 0xdd, 0xd8, 0xbe, 0xd8, 0xbd, 0x72, \ - 0x37, 0x8c, 0xf8, 0x2f, 0x1d, 0xba, 0x2a - -# define DRBG_TEST_GENERATED_INTERM \ - 0xdc, 0x3c, 0xf6, 0xbf, 0x5b, 0xd3, 0x41, 0x13, 0x5f, 0x2c, 0x68, 0x11, 0xa1, \ - 0x07, 0x1c, 0x87 - -# define DRBG_TEST_GENERATED \ - 0xb6, 0x18, 0x50, 0xde, 0xcf, 0xd7, 0x10, 0x6d, 0x44, 0x76, 0x9a, 0x8e, 0x6e, \ - 0x8c, 0x1a, 0xd4 - -#endif - -#endif // _MSBN_DRBG_TEST_VECTORS_H diff --git a/src/tpm2/Platform.h b/src/tpm2/Platform.h deleted file mode 100644 index cffc4ff2e..000000000 --- a/src/tpm2/Platform.h +++ /dev/null @@ -1,81 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* 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 - 2023 */ -/* */ -/********************************************************************************/ - - -#ifndef _PLATFORM_H_ -#define _PLATFORM_H_ - -#include "TpmBuildSwitches.h" -#include "TpmProfile.h" -#include "BaseTypes.h" -#include "TPMB.h" -#include "MinMax.h" -#include "PlatformACT.h" -#include "PlatformClock.h" -#include "PlatformData.h" -#include "platform_public_interface.h" -#include "tpm_to_platform_interface.h" -#include "platform_to_tpm_interface.h" -#define GLOBAL_C -#define NV_C -#include "pcrstruct.h" -#include "platform_pcr_fp.h" - -#endif // _PLATFORM_H_ diff --git a/src/tpm2/PlatformACT.h b/src/tpm2/PlatformACT.h deleted file mode 100644 index 8ffd0ba91..000000000 --- a/src/tpm2/PlatformACT.h +++ /dev/null @@ -1,208 +0,0 @@ -/********************************************************************************/ -/* */ -/* 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. */ -/* */ -/********************************************************************************/ - -// This file contains the definitions for the ACT macros and data types used in the -// ACT implementation. - -#ifndef _PLATFORM_ACT_H_ -#define _PLATFORM_ACT_H_ - -typedef struct ACT_DATA -{ - uint32_t remaining; - uint32_t newValue; - uint8_t signaled; - uint8_t pending; - uint8_t number; -} ACT_DATA, *P_ACT_DATA; - -#if !(defined RH_ACT_0) || (RH_ACT_0 != YES) -# undef RH_ACT_0 -# define RH_ACT_0 NO -# define IF_ACT_0_IMPLEMENTED(op) -#else -# define IF_ACT_0_IMPLEMENTED(op) op(0) -#endif -#if !(defined RH_ACT_1) || (RH_ACT_1 != YES) -# undef RH_ACT_1 -# define RH_ACT_1 NO -# define IF_ACT_1_IMPLEMENTED(op) -#else -# define IF_ACT_1_IMPLEMENTED(op) op(1) -#endif -#if !(defined RH_ACT_2) || (RH_ACT_2 != YES) -# undef RH_ACT_2 -# define RH_ACT_2 NO -# define IF_ACT_2_IMPLEMENTED(op) -#else -# define IF_ACT_2_IMPLEMENTED(op) op(2) -#endif -#if !(defined RH_ACT_3) || (RH_ACT_3 != YES) -# undef RH_ACT_3 -# define RH_ACT_3 NO -# define IF_ACT_3_IMPLEMENTED(op) -#else -# define IF_ACT_3_IMPLEMENTED(op) op(3) -#endif -#if !(defined RH_ACT_4) || (RH_ACT_4 != YES) -# undef RH_ACT_4 -# define RH_ACT_4 NO -# define IF_ACT_4_IMPLEMENTED(op) -#else -# define IF_ACT_4_IMPLEMENTED(op) op(4) -#endif -#if !(defined RH_ACT_5) || (RH_ACT_5 != YES) -# undef RH_ACT_5 -# define RH_ACT_5 NO -# define IF_ACT_5_IMPLEMENTED(op) -#else -# define IF_ACT_5_IMPLEMENTED(op) op(5) -#endif -#if !(defined RH_ACT_6) || (RH_ACT_6 != YES) -# undef RH_ACT_6 -# define RH_ACT_6 NO -# define IF_ACT_6_IMPLEMENTED(op) -#else -# define IF_ACT_6_IMPLEMENTED(op) op(6) -#endif -#if !(defined RH_ACT_7) || (RH_ACT_7 != YES) -# undef RH_ACT_7 -# define RH_ACT_7 NO -# define IF_ACT_7_IMPLEMENTED(op) -#else -# define IF_ACT_7_IMPLEMENTED(op) op(7) -#endif -#if !(defined RH_ACT_8) || (RH_ACT_8 != YES) -# undef RH_ACT_8 -# define RH_ACT_8 NO -# define IF_ACT_8_IMPLEMENTED(op) -#else -# define IF_ACT_8_IMPLEMENTED(op) op(8) -#endif -#if !(defined RH_ACT_9) || (RH_ACT_9 != YES) -# undef RH_ACT_9 -# define RH_ACT_9 NO -# define IF_ACT_9_IMPLEMENTED(op) -#else -# define IF_ACT_9_IMPLEMENTED(op) op(9) -#endif -#if !(defined RH_ACT_A) || (RH_ACT_A != YES) -# undef RH_ACT_A -# define RH_ACT_A NO -# define IF_ACT_A_IMPLEMENTED(op) -#else -# define IF_ACT_A_IMPLEMENTED(op) op(A) -#endif -#if !(defined RH_ACT_B) || (RH_ACT_B != YES) -# undef RH_ACT_B -# define RH_ACT_B NO -# define IF_ACT_B_IMPLEMENTED(op) -#else -# define IF_ACT_B_IMPLEMENTED(op) op(B) -#endif -#if !(defined RH_ACT_C) || (RH_ACT_C != YES) -# undef RH_ACT_C -# define RH_ACT_C NO -# define IF_ACT_C_IMPLEMENTED(op) -#else -# define IF_ACT_C_IMPLEMENTED(op) op(C) -#endif -#if !(defined RH_ACT_D) || (RH_ACT_D != YES) -# undef RH_ACT_D -# define RH_ACT_D NO -# define IF_ACT_D_IMPLEMENTED(op) -#else -# define IF_ACT_D_IMPLEMENTED(op) op(D) -#endif -#if !(defined RH_ACT_E) || (RH_ACT_E != YES) -# undef RH_ACT_E -# define RH_ACT_E NO -# define IF_ACT_E_IMPLEMENTED(op) -#else -# define IF_ACT_E_IMPLEMENTED(op) op(E) -#endif -#if !(defined RH_ACT_F) || (RH_ACT_F != YES) -# undef RH_ACT_F -# define RH_ACT_F NO -# define IF_ACT_F_IMPLEMENTED(op) -#else -# 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) - -#endif // _PLATFORM_ACT_H_ diff --git a/src/tpm2/PlatformACT_fp.h b/src/tpm2/PlatformACT_fp.h deleted file mode 100644 index 5d2caf517..000000000 --- a/src/tpm2/PlatformACT_fp.h +++ /dev/null @@ -1,104 +0,0 @@ -/********************************************************************************/ -/* */ -/* Platform Authenticated Countdown Timer */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: PlatformACT_fp.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 */ -/* */ -/********************************************************************************/ - -#ifndef PLATFORMACT_FP_H -#define PLATFORMACT_FP_H - -LIB_EXPORT int -_plat__ACT_GetImplemented( - uint32_t act - ); -LIB_EXPORT uint32_t -_plat__ACT_GetRemaining( - uint32_t act //IN: the ACT selector - ); -LIB_EXPORT int -_plat__ACT_GetSignaled( - uint32_t act //IN: number of ACT to check - ); -LIB_EXPORT void -_plat__ACT_SetSignaled( - uint32_t act, - int on - ); -LIB_EXPORT int -_plat__ACT_GetPending( - uint32_t act //IN: number of ACT to check - ); -LIB_EXPORT int -_plat__ACT_UpdateCounter( - uint32_t act, // IN: ACT to update - uint32_t newValue // IN: the value to post - ); -LIB_EXPORT void -_plat__ACT_EnableTicks( - int enable - ); -LIB_EXPORT void -_plat__ACT_Tick( - void - ); -LIB_EXPORT int -_plat__ACT_Initialize( - void - ); - -#endif diff --git a/src/tpm2/PlatformClock.h b/src/tpm2/PlatformClock.h deleted file mode 100644 index 306aeb8c7..000000000 --- a/src/tpm2/PlatformClock.h +++ /dev/null @@ -1,77 +0,0 @@ -/********************************************************************************/ -/* */ -/* Platform Clock . */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: PlatformClock.h 1594 2020-03-26 22:15:48Z 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 - 2020 */ -/* */ -/********************************************************************************/ - -// 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. - -#ifndef _PLATFORM_CLOCK_H_ -#define _PLATFORM_CLOCK_H_ - -#ifndef _ARM_ -# ifdef _MSC_VER -# include -# include -# else -# include -# endif -#endif - -#endif // _PLATFORM_CLOCK_H_ diff --git a/src/tpm2/PlatformData.c b/src/tpm2/PlatformData.c deleted file mode 100644 index f02a53672..000000000 --- a/src/tpm2/PlatformData.c +++ /dev/null @@ -1,68 +0,0 @@ -/********************************************************************************/ -/* */ -/* TPM variables that are not stack allocated */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: PlatformData.c 1519 2019-11-15 20:43:51Z 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 */ -/* */ -/********************************************************************************/ - -//** Description -// This file will instance the TPM variables that are not stack allocated. The -// descriptions for these variables are in Global.h for this project. - -//** Includes -#define _PLATFORM_DATA_C_ -#include "Platform.h" diff --git a/src/tpm2/PlatformData.h b/src/tpm2/PlatformData.h deleted file mode 100644 index a53d79012..000000000 --- a/src/tpm2/PlatformData.h +++ /dev/null @@ -1,159 +0,0 @@ -/********************************************************************************/ -/* */ -/* 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. */ -/* */ -/********************************************************************************/ - -// 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. - -#ifndef _PLATFORM_DATA_H_ -#define _PLATFORM_DATA_H_ - -#ifndef EXTERN -# ifdef _PLATFORM_DATA_C_ -# define EXTERN -# else -# define EXTERN extern -# endif // _PLATFORM_DATA_C_ -#endif // EXTERN - -// From Cancel.c -// Cancel flag. It is initialized as FALSE, which indicate the command is not -// being canceled -EXTERN int s_isCanceled; - -#ifndef HARDWARE_CLOCK -typedef uint64_t clock64_t; -// This is the value returned the last time that the system clock was read. This -// is only relevant for a simulator or virtual TPM. -EXTERN clock64_t s_realTimePrevious; - -// These values are used to try to synthesize a long lived version of clock(). -EXTERN clock64_t s_lastSystemTime; -EXTERN clock64_t s_lastReportedTime; - -// This is the rate adjusted value that is the equivalent of what would be read from -// a hardware register that produced rate adjusted time. -EXTERN clock64_t s_tpmTime; -/* libtpms added begin */ -EXTERN int64_t s_hostMonotonicAdjustTime; -EXTERN uint64_t s_suspendedElapsedTime; -/* libtpms added end */ -#endif // HARDWARE_CLOCK - -// This value indicates that the timer was reset -EXTERN int s_timerReset; -// This value indicates that the timer was stopped. It causes a clock discontinuity. -EXTERN int s_timerStopped; - -// This variable records the time when _plat__TimerReset is called. This mechanism -// allow us to subtract the time when TPM is power off from the total -// time reported by clock() function -EXTERN uint64_t s_initClock; - -// This variable records the timer adjustment factor. -EXTERN unsigned int s_adjustRate; - -// For LocalityPlat.c -// Locality of current command -EXTERN unsigned char s_locality; - -// For NVMem.c -// Choose if the NV memory should be backed by RAM or by file. -// 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)) -# 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)) -# 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 -#else -#error Do not define SIMULATION for libtpms! -#endif // SIMULATION - -EXTERN unsigned char s_NV[NV_MEMORY_SIZE]; -EXTERN int s_NvIsAvailable; -EXTERN int s_NV_unrecoverable; -EXTERN int s_NV_recoverable; - -// For PPPlat.c -// Physical presence. It is initialized to FALSE -EXTERN int s_physicalPresence; - -// From Power -EXTERN int s_powerLost; - -// For Entropy.c -EXTERN uint32_t lastEntropy; - -#define DEFINE_ACT(N) EXTERN ACT_DATA ACT_##N; -FOR_EACH_ACT(DEFINE_ACT) - -EXTERN int actTicksAllowed; - -#endif // _PLATFORM_DATA_H_ diff --git a/src/tpm2/Platform_fp.h b/src/tpm2/Platform_fp.h deleted file mode 100644 index 71c4cff38..000000000 --- a/src/tpm2/Platform_fp.h +++ /dev/null @@ -1,61 +0,0 @@ -/********************************************************************************/ -/* */ -/* NV read and write access methods */ -/* 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 */ -/* */ -/********************************************************************************/ - -#include "platform_public_interface.h" // libtpms added diff --git a/src/tpm2/PolicyAuthValue_fp.h b/src/tpm2/PolicyAuthValue_fp.h deleted file mode 100644 index 81993b369..000000000 --- a/src/tpm2/PolicyAuthValue_fp.h +++ /dev/null @@ -1,84 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: PolicyAuthValue_fp.h 809 2016-11-16 18:31:54Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_PolicyAuthValue // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYAUTHVALUE_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYAUTHVALUE_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_SH_POLICY policySession; -} PolicyAuthValue_In; - -// Response code modifiers -# define RC_PolicyAuthValue_policySession (TPM_RC_H + TPM_RC_1) - -// Function prototype -TPM_RC -TPM2_PolicyAuthValue(PolicyAuthValue_In* in); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYAUTHVALUE_FP_H_ -#endif // CC_PolicyAuthValue diff --git a/src/tpm2/PolicyAuthorizeNV_fp.h b/src/tpm2/PolicyAuthorizeNV_fp.h deleted file mode 100644 index f1b71629b..000000000 --- a/src/tpm2/PolicyAuthorizeNV_fp.h +++ /dev/null @@ -1,88 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: PolicyAuthorizeNV_fp.h 809 2016-11-16 18:31:54Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015, 2016 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_PolicyAuthorizeNV // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYAUTHORIZENV_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYAUTHORIZENV_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_RH_NV_AUTH authHandle; - TPMI_RH_NV_INDEX nvIndex; - TPMI_SH_POLICY policySession; -} PolicyAuthorizeNV_In; - -// Response code modifiers -# define RC_PolicyAuthorizeNV_authHandle (TPM_RC_H + TPM_RC_1) -# define RC_PolicyAuthorizeNV_nvIndex (TPM_RC_H + TPM_RC_2) -# define RC_PolicyAuthorizeNV_policySession (TPM_RC_H + TPM_RC_3) - -// Function prototype -TPM_RC -TPM2_PolicyAuthorizeNV(PolicyAuthorizeNV_In* in); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYAUTHORIZENV_FP_H_ -#endif // CC_PolicyAuthorizeNV diff --git a/src/tpm2/PolicyAuthorize_fp.h b/src/tpm2/PolicyAuthorize_fp.h deleted file mode 100644 index ed8fd4528..000000000 --- a/src/tpm2/PolicyAuthorize_fp.h +++ /dev/null @@ -1,92 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: PolicyAuthorize_fp.h 809 2016-11-16 18:31:54Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_PolicyAuthorize // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYAUTHORIZE_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYAUTHORIZE_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_SH_POLICY policySession; - TPM2B_DIGEST approvedPolicy; - TPM2B_NONCE policyRef; - TPM2B_NAME keySign; - TPMT_TK_VERIFIED checkTicket; -} PolicyAuthorize_In; - -// Response code modifiers -# define RC_PolicyAuthorize_policySession (TPM_RC_H + TPM_RC_1) -# define RC_PolicyAuthorize_approvedPolicy (TPM_RC_P + TPM_RC_1) -# define RC_PolicyAuthorize_policyRef (TPM_RC_P + TPM_RC_2) -# define RC_PolicyAuthorize_keySign (TPM_RC_P + TPM_RC_3) -# define RC_PolicyAuthorize_checkTicket (TPM_RC_P + TPM_RC_4) - -// Function prototype -TPM_RC -TPM2_PolicyAuthorize(PolicyAuthorize_In* in); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYAUTHORIZE_FP_H_ -#endif // CC_PolicyAuthorize diff --git a/src/tpm2/PolicyCapability_fp.h b/src/tpm2/PolicyCapability_fp.h deleted file mode 100644 index a1581568c..000000000 --- a/src/tpm2/PolicyCapability_fp.h +++ /dev/null @@ -1,93 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* 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 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_PolicyCapability // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYCAPABILITY_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYCAPABILITY_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_SH_POLICY policySession; - TPM2B_OPERAND operandB; - UINT16 offset; - TPM_EO operation; - TPM_CAP capability; - UINT32 property; -} PolicyCapability_In; - -// Response code modifiers -# define RC_PolicyCapability_policySession (TPM_RC_H + TPM_RC_1) -# define RC_PolicyCapability_operandB (TPM_RC_P + TPM_RC_1) -# define RC_PolicyCapability_offset (TPM_RC_P + TPM_RC_2) -# define RC_PolicyCapability_operation (TPM_RC_P + TPM_RC_3) -# define RC_PolicyCapability_capability (TPM_RC_P + TPM_RC_4) -# define RC_PolicyCapability_property (TPM_RC_P + TPM_RC_5) - -// Function prototype -TPM_RC -TPM2_PolicyCapability(PolicyCapability_In* in); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYCAPABILITY_FP_H_ -#endif // CC_PolicyCapability diff --git a/src/tpm2/PolicyCommandCode_fp.h b/src/tpm2/PolicyCommandCode_fp.h deleted file mode 100644 index b83057a1e..000000000 --- a/src/tpm2/PolicyCommandCode_fp.h +++ /dev/null @@ -1,86 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: PolicyCommandCode_fp.h 809 2016-11-16 18:31:54Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_PolicyCommandCode // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYCOMMANDCODE_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYCOMMANDCODE_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_SH_POLICY policySession; - TPM_CC code; -} PolicyCommandCode_In; - -// Response code modifiers -# define RC_PolicyCommandCode_policySession (TPM_RC_H + TPM_RC_1) -# define RC_PolicyCommandCode_code (TPM_RC_P + TPM_RC_1) - -// Function prototype -TPM_RC -TPM2_PolicyCommandCode(PolicyCommandCode_In* in); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYCOMMANDCODE_FP_H_ -#endif // CC_PolicyCommandCode diff --git a/src/tpm2/PolicyCounterTimer_fp.h b/src/tpm2/PolicyCounterTimer_fp.h deleted file mode 100644 index 8f1b0fcd8..000000000 --- a/src/tpm2/PolicyCounterTimer_fp.h +++ /dev/null @@ -1,90 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: PolicyCounterTimer_fp.h 809 2016-11-16 18:31:54Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_PolicyCounterTimer // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYCOUNTERTIMER_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYCOUNTERTIMER_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_SH_POLICY policySession; - TPM2B_OPERAND operandB; - UINT16 offset; - TPM_EO operation; -} PolicyCounterTimer_In; - -// Response code modifiers -# define RC_PolicyCounterTimer_policySession (TPM_RC_H + TPM_RC_1) -# define RC_PolicyCounterTimer_operandB (TPM_RC_P + TPM_RC_1) -# define RC_PolicyCounterTimer_offset (TPM_RC_P + TPM_RC_2) -# define RC_PolicyCounterTimer_operation (TPM_RC_P + TPM_RC_3) - -// Function prototype -TPM_RC -TPM2_PolicyCounterTimer(PolicyCounterTimer_In* in); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYCOUNTERTIMER_FP_H_ -#endif // CC_PolicyCounterTimer diff --git a/src/tpm2/PolicyCpHash_fp.h b/src/tpm2/PolicyCpHash_fp.h deleted file mode 100644 index 4ae2a1ae2..000000000 --- a/src/tpm2/PolicyCpHash_fp.h +++ /dev/null @@ -1,86 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: PolicyCpHash_fp.h 1521 2019-11-15 21:00:47Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_PolicyCpHash // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYCPHASH_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYCPHASH_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_SH_POLICY policySession; - TPM2B_DIGEST cpHashA; -} PolicyCpHash_In; - -// Response code modifiers -# define RC_PolicyCpHash_policySession (TPM_RC_H + TPM_RC_1) -# define RC_PolicyCpHash_cpHashA (TPM_RC_P + TPM_RC_1) - -// Function prototype -TPM_RC -TPM2_PolicyCpHash(PolicyCpHash_In* in); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYCPHASH_FP_H_ -#endif // CC_PolicyCpHash diff --git a/src/tpm2/PolicyDuplicationSelect_fp.h b/src/tpm2/PolicyDuplicationSelect_fp.h deleted file mode 100644 index 5dd4a9e35..000000000 --- a/src/tpm2/PolicyDuplicationSelect_fp.h +++ /dev/null @@ -1,90 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: PolicyDuplicationSelect_fp.h 809 2016-11-16 18:31:54Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_PolicyDuplicationSelect // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYDUPLICATIONSELECT_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYDUPLICATIONSELECT_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_SH_POLICY policySession; - TPM2B_NAME objectName; - TPM2B_NAME newParentName; - TPMI_YES_NO includeObject; -} PolicyDuplicationSelect_In; - -// Response code modifiers -# define RC_PolicyDuplicationSelect_policySession (TPM_RC_H + TPM_RC_1) -# define RC_PolicyDuplicationSelect_objectName (TPM_RC_P + TPM_RC_1) -# define RC_PolicyDuplicationSelect_newParentName (TPM_RC_P + TPM_RC_2) -# define RC_PolicyDuplicationSelect_includeObject (TPM_RC_P + TPM_RC_3) - -// Function prototype -TPM_RC -TPM2_PolicyDuplicationSelect(PolicyDuplicationSelect_In* in); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYDUPLICATIONSELECT_FP_H_ -#endif // CC_PolicyDuplicationSelect diff --git a/src/tpm2/PolicyGetDigest_fp.h b/src/tpm2/PolicyGetDigest_fp.h deleted file mode 100644 index 341d7e25c..000000000 --- a/src/tpm2/PolicyGetDigest_fp.h +++ /dev/null @@ -1,90 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: PolicyGetDigest_fp.h 809 2016-11-16 18:31:54Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_PolicyGetDigest // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYGETDIGEST_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYGETDIGEST_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_SH_POLICY policySession; -} PolicyGetDigest_In; - -// Output structure definition -typedef struct -{ - TPM2B_DIGEST policyDigest; -} PolicyGetDigest_Out; - -// Response code modifiers -# define RC_PolicyGetDigest_policySession (TPM_RC_H + TPM_RC_1) - -// Function prototype -TPM_RC -TPM2_PolicyGetDigest(PolicyGetDigest_In* in, PolicyGetDigest_Out* out); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYGETDIGEST_FP_H_ -#endif // CC_PolicyGetDigest diff --git a/src/tpm2/PolicyLocality_fp.h b/src/tpm2/PolicyLocality_fp.h deleted file mode 100644 index 20426c3ae..000000000 --- a/src/tpm2/PolicyLocality_fp.h +++ /dev/null @@ -1,86 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: PolicyLocality_fp.h 809 2016-11-16 18:31:54Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_PolicyLocality // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYLOCALITY_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYLOCALITY_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_SH_POLICY policySession; - TPMA_LOCALITY locality; -} PolicyLocality_In; - -// Response code modifiers -# define RC_PolicyLocality_policySession (TPM_RC_H + TPM_RC_1) -# define RC_PolicyLocality_locality (TPM_RC_P + TPM_RC_1) - -// Function prototype -TPM_RC -TPM2_PolicyLocality(PolicyLocality_In* in); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYLOCALITY_FP_H_ -#endif // CC_PolicyLocality diff --git a/src/tpm2/PolicyNV_fp.h b/src/tpm2/PolicyNV_fp.h deleted file mode 100644 index ad3f56356..000000000 --- a/src/tpm2/PolicyNV_fp.h +++ /dev/null @@ -1,94 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: PolicyNV_fp.h 809 2016-11-16 18:31:54Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_PolicyNV // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYNV_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYNV_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_RH_NV_AUTH authHandle; - TPMI_RH_NV_INDEX nvIndex; - TPMI_SH_POLICY policySession; - TPM2B_OPERAND operandB; - UINT16 offset; - TPM_EO operation; -} PolicyNV_In; - -// Response code modifiers -# define RC_PolicyNV_authHandle (TPM_RC_H + TPM_RC_1) -# define RC_PolicyNV_nvIndex (TPM_RC_H + TPM_RC_2) -# define RC_PolicyNV_policySession (TPM_RC_H + TPM_RC_3) -# define RC_PolicyNV_operandB (TPM_RC_P + TPM_RC_1) -# define RC_PolicyNV_offset (TPM_RC_P + TPM_RC_2) -# define RC_PolicyNV_operation (TPM_RC_P + TPM_RC_3) - -// Function prototype -TPM_RC -TPM2_PolicyNV(PolicyNV_In* in); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYNV_FP_H_ -#endif // CC_PolicyNV diff --git a/src/tpm2/PolicyNameHash_fp.h b/src/tpm2/PolicyNameHash_fp.h deleted file mode 100644 index e12be208e..000000000 --- a/src/tpm2/PolicyNameHash_fp.h +++ /dev/null @@ -1,86 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: PolicyNameHash_fp.h 809 2016-11-16 18:31:54Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_PolicyNameHash // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYNAMEHASH_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYNAMEHASH_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_SH_POLICY policySession; - TPM2B_DIGEST nameHash; -} PolicyNameHash_In; - -// Response code modifiers -# define RC_PolicyNameHash_policySession (TPM_RC_H + TPM_RC_1) -# define RC_PolicyNameHash_nameHash (TPM_RC_P + TPM_RC_1) - -// Function prototype -TPM_RC -TPM2_PolicyNameHash(PolicyNameHash_In* in); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYNAMEHASH_FP_H_ -#endif // CC_PolicyNameHash diff --git a/src/tpm2/PolicyNvWritten_fp.h b/src/tpm2/PolicyNvWritten_fp.h deleted file mode 100644 index d0d54e55b..000000000 --- a/src/tpm2/PolicyNvWritten_fp.h +++ /dev/null @@ -1,86 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: PolicyNvWritten_fp.h 809 2016-11-16 18:31:54Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_PolicyNvWritten // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYNVWRITTEN_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYNVWRITTEN_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_SH_POLICY policySession; - TPMI_YES_NO writtenSet; -} PolicyNvWritten_In; - -// Response code modifiers -# define RC_PolicyNvWritten_policySession (TPM_RC_H + TPM_RC_1) -# define RC_PolicyNvWritten_writtenSet (TPM_RC_P + TPM_RC_1) - -// Function prototype -TPM_RC -TPM2_PolicyNvWritten(PolicyNvWritten_In* in); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYNVWRITTEN_FP_H_ -#endif // CC_PolicyNvWritten diff --git a/src/tpm2/PolicyOR_fp.h b/src/tpm2/PolicyOR_fp.h deleted file mode 100644 index 1eb6dc7b2..000000000 --- a/src/tpm2/PolicyOR_fp.h +++ /dev/null @@ -1,86 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: PolicyOR_fp.h 809 2016-11-16 18:31:54Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_PolicyOR // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYOR_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYOR_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_SH_POLICY policySession; - TPML_DIGEST pHashList; -} PolicyOR_In; - -// Response code modifiers -# define RC_PolicyOR_policySession (TPM_RC_H + TPM_RC_1) -# define RC_PolicyOR_pHashList (TPM_RC_P + TPM_RC_1) - -// Function prototype -TPM_RC -TPM2_PolicyOR(PolicyOR_In* in); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYOR_FP_H_ -#endif // CC_PolicyOR diff --git a/src/tpm2/PolicyPCR_fp.h b/src/tpm2/PolicyPCR_fp.h deleted file mode 100644 index ab6f14df7..000000000 --- a/src/tpm2/PolicyPCR_fp.h +++ /dev/null @@ -1,88 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: PolicyPCR_fp.h 809 2016-11-16 18:31:54Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_PolicyPCR // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYPCR_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYPCR_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_SH_POLICY policySession; - TPM2B_DIGEST pcrDigest; - TPML_PCR_SELECTION pcrs; -} PolicyPCR_In; - -// Response code modifiers -# define RC_PolicyPCR_policySession (TPM_RC_H + TPM_RC_1) -# define RC_PolicyPCR_pcrDigest (TPM_RC_P + TPM_RC_1) -# define RC_PolicyPCR_pcrs (TPM_RC_P + TPM_RC_2) - -// Function prototype -TPM_RC -TPM2_PolicyPCR(PolicyPCR_In* in); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYPCR_FP_H_ -#endif // CC_PolicyPCR diff --git a/src/tpm2/PolicyParameters_fp.h b/src/tpm2/PolicyParameters_fp.h deleted file mode 100644 index 0fc77e5ad..000000000 --- a/src/tpm2/PolicyParameters_fp.h +++ /dev/null @@ -1,85 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* 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 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_PolicyParameters // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYPARAMETERS_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYPARAMETERS_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_SH_POLICY policySession; - TPM2B_DIGEST pHash; -} PolicyParameters_In; - -// Response code modifiers -# define RC_PolicyParameters_policySession (TPM_RC_H + TPM_RC_1) -# define RC_PolicyParameters_pHash (TPM_RC_P + TPM_RC_1) - -// Function prototype -TPM_RC -TPM2_PolicyParameters(PolicyParameters_In* in); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYPARAMETERS_FP_H_ -#endif // CC_PolicyParameters diff --git a/src/tpm2/PolicyPassword_fp.h b/src/tpm2/PolicyPassword_fp.h deleted file mode 100644 index 35f1e5ba4..000000000 --- a/src/tpm2/PolicyPassword_fp.h +++ /dev/null @@ -1,84 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: PolicyPassword_fp.h 809 2016-11-16 18:31:54Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_PolicyPassword // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYPASSWORD_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYPASSWORD_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_SH_POLICY policySession; -} PolicyPassword_In; - -// Response code modifiers -# define RC_PolicyPassword_policySession (TPM_RC_H + TPM_RC_1) - -// Function prototype -TPM_RC -TPM2_PolicyPassword(PolicyPassword_In* in); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYPASSWORD_FP_H_ -#endif // CC_PolicyPassword diff --git a/src/tpm2/PolicyPhysicalPresence_fp.h b/src/tpm2/PolicyPhysicalPresence_fp.h deleted file mode 100644 index 57973f260..000000000 --- a/src/tpm2/PolicyPhysicalPresence_fp.h +++ /dev/null @@ -1,84 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: PolicyPhysicalPresence_fp.h 809 2016-11-16 18:31:54Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_PolicyPhysicalPresence // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYPHYSICALPRESENCE_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYPHYSICALPRESENCE_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_SH_POLICY policySession; -} PolicyPhysicalPresence_In; - -// Response code modifiers -# define RC_PolicyPhysicalPresence_policySession (TPM_RC_H + TPM_RC_1) - -// Function prototype -TPM_RC -TPM2_PolicyPhysicalPresence(PolicyPhysicalPresence_In* in); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYPHYSICALPRESENCE_FP_H_ -#endif // CC_PolicyPhysicalPresence diff --git a/src/tpm2/PolicyRestart_fp.h b/src/tpm2/PolicyRestart_fp.h deleted file mode 100644 index 0bf8ae81a..000000000 --- a/src/tpm2/PolicyRestart_fp.h +++ /dev/null @@ -1,84 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: PolicyRestart_fp.h 809 2016-11-16 18:31:54Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_PolicyRestart // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYRESTART_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYRESTART_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_SH_POLICY sessionHandle; -} PolicyRestart_In; - -// Response code modifiers -# define RC_PolicyRestart_sessionHandle (TPM_RC_H + TPM_RC_1) - -// Function prototype -TPM_RC -TPM2_PolicyRestart(PolicyRestart_In* in); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYRESTART_FP_H_ -#endif // CC_PolicyRestart diff --git a/src/tpm2/PolicySecret_fp.h b/src/tpm2/PolicySecret_fp.h deleted file mode 100644 index 87bde53ca..000000000 --- a/src/tpm2/PolicySecret_fp.h +++ /dev/null @@ -1,101 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: PolicySecret_fp.h 1521 2019-11-15 21:00:47Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_PolicySecret // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYSECRET_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYSECRET_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_DH_ENTITY authHandle; - TPMI_SH_POLICY policySession; - TPM2B_NONCE nonceTPM; - TPM2B_DIGEST cpHashA; - TPM2B_NONCE policyRef; - INT32 expiration; -} PolicySecret_In; - -// Output structure definition -typedef struct -{ - TPM2B_TIMEOUT timeout; - TPMT_TK_AUTH policyTicket; -} PolicySecret_Out; - -// Response code modifiers -# define RC_PolicySecret_authHandle (TPM_RC_H + TPM_RC_1) -# define RC_PolicySecret_policySession (TPM_RC_H + TPM_RC_2) -# define RC_PolicySecret_nonceTPM (TPM_RC_P + TPM_RC_1) -# define RC_PolicySecret_cpHashA (TPM_RC_P + TPM_RC_2) -# define RC_PolicySecret_policyRef (TPM_RC_P + TPM_RC_3) -# define RC_PolicySecret_expiration (TPM_RC_P + TPM_RC_4) - -// Function prototype -TPM_RC -TPM2_PolicySecret(PolicySecret_In* in, PolicySecret_Out* out); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYSECRET_FP_H_ -#endif // CC_PolicySecret diff --git a/src/tpm2/PolicySigned_fp.h b/src/tpm2/PolicySigned_fp.h deleted file mode 100644 index faae23db6..000000000 --- a/src/tpm2/PolicySigned_fp.h +++ /dev/null @@ -1,103 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: PolicySigned_fp.h 1521 2019-11-15 21:00:47Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_PolicySigned // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYSIGNED_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYSIGNED_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_DH_OBJECT authObject; - TPMI_SH_POLICY policySession; - TPM2B_NONCE nonceTPM; - TPM2B_DIGEST cpHashA; - TPM2B_NONCE policyRef; - INT32 expiration; - TPMT_SIGNATURE auth; -} PolicySigned_In; - -// Output structure definition -typedef struct -{ - TPM2B_TIMEOUT timeout; - TPMT_TK_AUTH policyTicket; -} PolicySigned_Out; - -// Response code modifiers -# define RC_PolicySigned_authObject (TPM_RC_H + TPM_RC_1) -# define RC_PolicySigned_policySession (TPM_RC_H + TPM_RC_2) -# define RC_PolicySigned_nonceTPM (TPM_RC_P + TPM_RC_1) -# define RC_PolicySigned_cpHashA (TPM_RC_P + TPM_RC_2) -# define RC_PolicySigned_policyRef (TPM_RC_P + TPM_RC_3) -# define RC_PolicySigned_expiration (TPM_RC_P + TPM_RC_4) -# define RC_PolicySigned_auth (TPM_RC_P + TPM_RC_5) - -// Function prototype -TPM_RC -TPM2_PolicySigned(PolicySigned_In* in, PolicySigned_Out* out); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYSIGNED_FP_H_ -#endif // CC_PolicySigned diff --git a/src/tpm2/PolicyTemplate_fp.h b/src/tpm2/PolicyTemplate_fp.h deleted file mode 100644 index 372cc43fe..000000000 --- a/src/tpm2/PolicyTemplate_fp.h +++ /dev/null @@ -1,86 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: PolicyTemplate_fp.h 809 2016-11-16 18:31:54Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015, 2016 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_PolicyTemplate // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYTEMPLATE_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYTEMPLATE_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_SH_POLICY policySession; - TPM2B_DIGEST templateHash; -} PolicyTemplate_In; - -// Response code modifiers -# define RC_PolicyTemplate_policySession (TPM_RC_H + TPM_RC_1) -# define RC_PolicyTemplate_templateHash (TPM_RC_P + TPM_RC_1) - -// Function prototype -TPM_RC -TPM2_PolicyTemplate(PolicyTemplate_In* in); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYTEMPLATE_FP_H_ -#endif // CC_PolicyTemplate diff --git a/src/tpm2/PolicyTicket_fp.h b/src/tpm2/PolicyTicket_fp.h deleted file mode 100644 index d591ca1ba..000000000 --- a/src/tpm2/PolicyTicket_fp.h +++ /dev/null @@ -1,94 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: PolicyTicket_fp.h 1521 2019-11-15 21:00:47Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_PolicyTicket // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYTICKET_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYTICKET_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_SH_POLICY policySession; - TPM2B_TIMEOUT timeout; - TPM2B_DIGEST cpHashA; - TPM2B_NONCE policyRef; - TPM2B_NAME authName; - TPMT_TK_AUTH ticket; -} PolicyTicket_In; - -// Response code modifiers -# define RC_PolicyTicket_policySession (TPM_RC_H + TPM_RC_1) -# define RC_PolicyTicket_timeout (TPM_RC_P + TPM_RC_1) -# define RC_PolicyTicket_cpHashA (TPM_RC_P + TPM_RC_2) -# define RC_PolicyTicket_policyRef (TPM_RC_P + TPM_RC_3) -# define RC_PolicyTicket_authName (TPM_RC_P + TPM_RC_4) -# define RC_PolicyTicket_ticket (TPM_RC_P + TPM_RC_5) - -// Function prototype -TPM_RC -TPM2_PolicyTicket(PolicyTicket_In* in); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYTICKET_FP_H_ -#endif // CC_PolicyTicket diff --git a/src/tpm2/Policy_spt_fp.h b/src/tpm2/Policy_spt_fp.h deleted file mode 100644 index 7ae827ab9..000000000 --- a/src/tpm2/Policy_spt_fp.h +++ /dev/null @@ -1,119 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: Policy_spt_fp.h 1490 2019-07-26 21:13:22Z 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 */ -/* */ -/********************************************************************************/ - -/*(Auto-generated) - * Created by TpmPrototypes; Version 3.0 July 18, 2017 - * Date: Mar 4, 2020 Time: 02:36:44PM - */ - -#ifndef _POLICY_SPT_FP_H_ -#define _POLICY_SPT_FP_H_ - -//** Functions -//*** PolicyParameterChecks() -// This function validates the common parameters of TPM2_PolicySiged() -// and TPM2_PolicySecret(). The common parameters are 'nonceTPM', -// 'expiration', and 'cpHashA'. -TPM_RC -PolicyParameterChecks(SESSION* session, - UINT64 authTimeout, - TPM2B_DIGEST* cpHashA, - TPM2B_NONCE* nonce, - TPM_RC blameNonce, - TPM_RC blameCpHash, - TPM_RC blameExpiration); - -//*** PolicyContextUpdate() -// Update policy hash -// Update the policyDigest in policy session by extending policyRef and -// objectName to it. This will also update the cpHash if it is present. -// -// Return Type: void -void PolicyContextUpdate( - TPM_CC commandCode, // IN: command code - TPM2B_NAME* name, // IN: name of entity - TPM2B_NONCE* ref, // IN: the reference data - TPM2B_DIGEST* cpHash, // IN: the cpHash (optional) - UINT64 policyTimeout, // IN: the timeout value for the policy - SESSION* session // IN/OUT: policy session to be updated -); - -//*** ComputeAuthTimeout() -// This function is used to determine what the authorization timeout value for -// the session should be. -UINT64 -ComputeAuthTimeout(SESSION* session, // IN: the session containing the time - // values - INT32 expiration, // IN: either the number of seconds from - // the start of the session or the - // time in g_timer; - TPM2B_NONCE* nonce // IN: indicator of the time base -); - -//*** PolicyDigestClear() -// Function to reset the policyDigest of a session -void PolicyDigestClear(SESSION* session); - -//*** PolicySptCheckCondition() -// Checks to see if the condition in the policy is satisfied. -BOOL PolicySptCheckCondition(TPM_EO operation, BYTE* opA, BYTE* opB, UINT16 size); - -#endif // _POLICY_SPT_FP_H_ diff --git a/src/tpm2/Power.c b/src/tpm2/Power.c deleted file mode 100644 index 5c313ea8d..000000000 --- a/src/tpm2/Power.c +++ /dev/null @@ -1,100 +0,0 @@ -/********************************************************************************/ -/* */ -/* Simulated Power State Transitions of the TPM */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: Power.c 1490 2019-07-26 21:13:22Z 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 */ -/* */ -/********************************************************************************/ - -//** Description - -// This file contains functions that receive the simulated power state -// transitions of the TPM. - -//** Includes and Data Definitions -#define POWER_C -#include "Tpm.h" - -//** Functions - -//*** TPMInit() -// This function is used to process a power on event. -void TPMInit(void) -{ - // Set state as not initialized. This means that Startup is required - g_initialized = FALSE; - return; -} - -//*** TPMRegisterStartup() -// This function registers the fact that the TPM has been initialized -// (a TPM2_Startup() has completed successfully). -BOOL TPMRegisterStartup(void) -{ - g_initialized = TRUE; - return TRUE; -} - -//*** TPMIsStarted() -// Indicates if the TPM has been initialized (a TPM2_Startup() has completed -// successfully after a _TPM_Init). -// Return Type: BOOL -// TRUE(1) TPM has been initialized -// FALSE(0) TPM has not been initialized -BOOL TPMIsStarted(void) -{ - return g_initialized; -} diff --git a/src/tpm2/PowerPlat.c b/src/tpm2/PowerPlat.c deleted file mode 100644 index c9b4a098c..000000000 --- a/src/tpm2/PowerPlat.c +++ /dev/null @@ -1,131 +0,0 @@ -/********************************************************************************/ -/* */ -/* Platform Power Support */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: PowerPlat.c 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 */ -/* */ -/********************************************************************************/ - -//** Includes and Function Prototypes - -#include "Platform.h" - -//** Functions - -//***_plat__Signal_PowerOn() -// Signal platform power on -LIB_EXPORT int _plat__Signal_PowerOn(void) -{ - // Reset the timer - _plat__TimerReset(); - - // Need to indicate that we lost power - s_powerLost = TRUE; - - return 0; -} - -//*** _plat__WasPowerLost() -// Test whether power was lost before a _TPM_Init. -// -// This function will clear the "hardware" indication of power loss before return. -// This means that there can only be one spot in the TPM code where this value -// gets read. This method is used here as it is the most difficult to manage in the -// TPM code and, if the hardware actually works this way, it is hard to make it -// look like anything else. So, the burden is placed on the TPM code rather than the -// platform code -// Return Type: int -// TRUE(1) power was lost -// FALSE(0) power was not lost -LIB_EXPORT int _plat__WasPowerLost(void) -{ - int retVal = s_powerLost; - s_powerLost = FALSE; - return retVal; -} - -//*** _plat_Signal_Reset() -// This a TPM reset without a power loss. -LIB_EXPORT int _plat__Signal_Reset(void) -{ - // Initialize locality - s_locality = 0; - - // Command cancel - s_isCanceled = FALSE; - - _TPM_Init(); - - // if we are doing reset but did not have a power failure, then we should - // not need to reload NV ... - - return 0; -} - -//***_plat__Signal_PowerOff() -// Signal platform power off -LIB_EXPORT void _plat__Signal_PowerOff(void) -{ - // Prepare NV memory for power off - _plat__NVDisable((void*)FALSE, 0); - -#if ACT_SUPPORT - // Disable tick ACT tick processing - _plat__ACT_EnableTicks(FALSE); -#endif - - return; -} diff --git a/src/tpm2/Power_fp.h b/src/tpm2/Power_fp.h deleted file mode 100644 index e19a5f2c7..000000000 --- a/src/tpm2/Power_fp.h +++ /dev/null @@ -1,87 +0,0 @@ -/********************************************************************************/ -/* */ -/* Functions That Receive the Simulated Power State Transitions of the TPM */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: Power_fp.h 1490 2019-07-26 21:13:22Z 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 */ -/* */ -/********************************************************************************/ - -/*(Auto-generated) - * Created by TpmPrototypes; Version 3.0 July 18, 2017 - * Date: Apr 2, 2019 Time: 11:00:49AM - */ - -#ifndef _POWER_FP_H_ -#define _POWER_FP_H_ - -//*** TPMInit() -// This function is used to process a power on event. -void TPMInit(void); - -//*** TPMRegisterStartup() -// This function registers the fact that the TPM has been initialized -// (a TPM2_Startup() has completed successfully). -BOOL TPMRegisterStartup(void); - -//*** TPMIsStarted() -// Indicates if the TPM has been initialized (a TPM2_Startup() has completed -// successfully after a _TPM_Init). -// Return Type: BOOL -// TRUE(1) TPM has been initialized -// FALSE(0) TPM has not been initialized -BOOL TPMIsStarted(void); - -#endif // _POWER_FP_H_ diff --git a/src/tpm2/PropertyCap_fp.h b/src/tpm2/PropertyCap_fp.h deleted file mode 100644 index 7a012f6c3..000000000 --- a/src/tpm2/PropertyCap_fp.h +++ /dev/null @@ -1,90 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* 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 */ -/* */ -/********************************************************************************/ - -/*(Auto-generated) - * Created by TpmPrototypes; Version 3.0 July 18, 2017 - * Date: Mar 28, 2019 Time: 08:25:19PM - */ - -#ifndef _PROPERTY_CAP_FP_H_ -#define _PROPERTY_CAP_FP_H_ - -//*** TPMCapGetProperties() -// This function is used to get the TPM_PT values. The search of properties will -// start at 'property' and continue until 'propertyList' has as many values as -// will fit, or the last property has been reported, or the list has as many -// values as requested in 'count'. -// Return Type: TPMI_YES_NO -// YES more properties are available -// NO no more properties to be reported -TPMI_YES_NO -TPMCapGetProperties(TPM_PT property, // IN: the starting TPM property - UINT32 count, // IN: maximum number of returned - // properties - TPML_TAGGED_TPM_PROPERTY* propertyList // OUT: property list -); - -//*** TPMCapGetOneProperty() -// This function returns a single TPM property, if present. -BOOL TPMCapGetOneProperty(TPM_PT pt, // IN: the TPM property - TPMS_TAGGED_PROPERTY* property // OUT: tagged property -); - -#endif // _PROPERTY_CAP_FP_H_ diff --git a/src/tpm2/Quote_fp.h b/src/tpm2/Quote_fp.h deleted file mode 100644 index 991a529da..000000000 --- a/src/tpm2/Quote_fp.h +++ /dev/null @@ -1,97 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: Quote_fp.h 809 2016-11-16 18:31:54Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_Quote // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_QUOTE_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_QUOTE_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_DH_OBJECT signHandle; - TPM2B_DATA qualifyingData; - TPMT_SIG_SCHEME inScheme; - TPML_PCR_SELECTION PCRselect; -} Quote_In; - -// Output structure definition -typedef struct -{ - TPM2B_ATTEST quoted; - TPMT_SIGNATURE signature; -} Quote_Out; - -// Response code modifiers -# define RC_Quote_signHandle (TPM_RC_H + TPM_RC_1) -# define RC_Quote_qualifyingData (TPM_RC_P + TPM_RC_1) -# define RC_Quote_inScheme (TPM_RC_P + TPM_RC_2) -# define RC_Quote_PCRselect (TPM_RC_P + TPM_RC_3) - -// Function prototype -TPM_RC -TPM2_Quote(Quote_In* in, Quote_Out* out); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_QUOTE_FP_H_ -#endif // CC_Quote diff --git a/src/tpm2/RSA_Decrypt_fp.h b/src/tpm2/RSA_Decrypt_fp.h deleted file mode 100644 index 52bd5b7e8..000000000 --- a/src/tpm2/RSA_Decrypt_fp.h +++ /dev/null @@ -1,96 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: RSA_Decrypt_fp.h 809 2016-11-16 18:31:54Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_RSA_Decrypt // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_RSA_DECRYPT_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_RSA_DECRYPT_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_DH_OBJECT keyHandle; - TPM2B_PUBLIC_KEY_RSA cipherText; - TPMT_RSA_DECRYPT inScheme; - TPM2B_DATA label; -} RSA_Decrypt_In; - -// Output structure definition -typedef struct -{ - TPM2B_PUBLIC_KEY_RSA message; -} RSA_Decrypt_Out; - -// Response code modifiers -# define RC_RSA_Decrypt_keyHandle (TPM_RC_H + TPM_RC_1) -# define RC_RSA_Decrypt_cipherText (TPM_RC_P + TPM_RC_1) -# define RC_RSA_Decrypt_inScheme (TPM_RC_P + TPM_RC_2) -# define RC_RSA_Decrypt_label (TPM_RC_P + TPM_RC_3) - -// Function prototype -TPM_RC -TPM2_RSA_Decrypt(RSA_Decrypt_In* in, RSA_Decrypt_Out* out); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_RSA_DECRYPT_FP_H_ -#endif // CC_RSA_Decrypt diff --git a/src/tpm2/RSA_Encrypt_fp.h b/src/tpm2/RSA_Encrypt_fp.h deleted file mode 100644 index ace0c11c9..000000000 --- a/src/tpm2/RSA_Encrypt_fp.h +++ /dev/null @@ -1,96 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: RSA_Encrypt_fp.h 809 2016-11-16 18:31:54Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_RSA_Encrypt // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_RSA_ENCRYPT_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_RSA_ENCRYPT_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_DH_OBJECT keyHandle; - TPM2B_PUBLIC_KEY_RSA message; - TPMT_RSA_DECRYPT inScheme; - TPM2B_DATA label; -} RSA_Encrypt_In; - -// Output structure definition -typedef struct -{ - TPM2B_PUBLIC_KEY_RSA outData; -} RSA_Encrypt_Out; - -// Response code modifiers -# define RC_RSA_Encrypt_keyHandle (TPM_RC_H + TPM_RC_1) -# define RC_RSA_Encrypt_message (TPM_RC_P + TPM_RC_1) -# define RC_RSA_Encrypt_inScheme (TPM_RC_P + TPM_RC_2) -# define RC_RSA_Encrypt_label (TPM_RC_P + TPM_RC_3) - -// Function prototype -TPM_RC -TPM2_RSA_Encrypt(RSA_Encrypt_In* in, RSA_Encrypt_Out* out); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_RSA_ENCRYPT_FP_H_ -#endif // CC_RSA_Encrypt diff --git a/src/tpm2/ReadClock_fp.h b/src/tpm2/ReadClock_fp.h deleted file mode 100644 index a6c6f0afd..000000000 --- a/src/tpm2/ReadClock_fp.h +++ /dev/null @@ -1,81 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: ReadClock_fp.h 809 2016-11-16 18:31:54Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_ReadClock // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_READCLOCK_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_READCLOCK_FP_H_ - -// Output structure definition -typedef struct -{ - TPMS_TIME_INFO currentTime; -} ReadClock_Out; - -// Function prototype -TPM_RC -TPM2_ReadClock(ReadClock_Out* out); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_READCLOCK_FP_H_ -#endif // CC_ReadClock diff --git a/src/tpm2/ReadPublic_fp.h b/src/tpm2/ReadPublic_fp.h deleted file mode 100644 index 4b95ebdfd..000000000 --- a/src/tpm2/ReadPublic_fp.h +++ /dev/null @@ -1,92 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: ReadPublic_fp.h 809 2016-11-16 18:31:54Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_ReadPublic // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_READPUBLIC_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_READPUBLIC_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_DH_OBJECT objectHandle; -} ReadPublic_In; - -// Output structure definition -typedef struct -{ - TPM2B_PUBLIC outPublic; - TPM2B_NAME name; - TPM2B_NAME qualifiedName; -} ReadPublic_Out; - -// Response code modifiers -# define RC_ReadPublic_objectHandle (TPM_RC_H + TPM_RC_1) - -// Function prototype -TPM_RC -TPM2_ReadPublic(ReadPublic_In* in, ReadPublic_Out* out); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_READPUBLIC_FP_H_ -#endif // CC_ReadPublic diff --git a/src/tpm2/Response.c b/src/tpm2/Response.c deleted file mode 100644 index a7f67ba46..000000000 --- a/src/tpm2/Response.c +++ /dev/null @@ -1,107 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: Response.c 1259 2018-07-10 19:11:09Z 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 - 2018 */ -/* */ -/********************************************************************************/ - -//** Description -// This file contains the common code for building a response header, including -// setting the size of the structure. 'command' may be NULL if result is -// not TPM_RC_SUCCESS. - -//** Includes and Defines -#include "Tpm.h" -#include "Marshal.h" - -//** BuildResponseHeader() -// Adds the response header to the response. It will update command->parameterSize -// to indicate the total size of the response. -void BuildResponseHeader(COMMAND* command, // IN: main control structure - BYTE* buffer, // OUT: the output buffer - TPM_RC result // IN: the response code -) -{ - TPM_ST tag; - UINT32 size; - - if(result != TPM_RC_SUCCESS) - { - tag = TPM_ST_NO_SESSIONS; - size = 10; - } - else - { - tag = command->tag; - // Compute the overall size of the response - size = STD_RESPONSE_HEADER + command->handleNum * sizeof(TPM_HANDLE); - size += command->parameterSize; - size += (command->tag == TPM_ST_SESSIONS) ? command->authSize + sizeof(UINT32) - : 0; - } - TPM_ST_Marshal(&tag, &buffer, NULL); - UINT32_Marshal(&size, &buffer, NULL); - TPM_RC_Marshal(&result, &buffer, NULL); - if(result == TPM_RC_SUCCESS) - { - if(command->handleNum > 0) - TPM_HANDLE_Marshal(&command->handles[0], &buffer, NULL); - if(tag == TPM_ST_SESSIONS) - UINT32_Marshal((UINT32*)&command->parameterSize, &buffer, NULL); - } - command->parameterSize = size; -} diff --git a/src/tpm2/ResponseCodeProcessing.c b/src/tpm2/ResponseCodeProcessing.c deleted file mode 100644 index c8a704052..000000000 --- a/src/tpm2/ResponseCodeProcessing.c +++ /dev/null @@ -1,79 +0,0 @@ -/********************************************************************************/ -/* */ -/* Miscellaneous Functions For Processing Response Codes */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: ResponseCodeProcessing.c 1259 2018-07-10 19:11:09Z 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 - 2018 */ -/* */ -/********************************************************************************/ - -//** Description -// This file contains the miscellaneous functions for processing response codes. -// NOTE: Currently, there is only one. - -//** Includes and Defines -#include "Tpm.h" - -//** RcSafeAddToResult() -// Adds a modifier to a response code as long as the response code allows a modifier -// and no modifier has already been added. -TPM_RC -RcSafeAddToResult(TPM_RC responseCode, TPM_RC modifier) -{ - if((responseCode & RC_FMT1) && !(responseCode & 0xf40)) - return responseCode + modifier; - else - return responseCode; -} diff --git a/src/tpm2/ResponseCodeProcessing_fp.h b/src/tpm2/ResponseCodeProcessing_fp.h deleted file mode 100644 index 1f97c20be..000000000 --- a/src/tpm2/ResponseCodeProcessing_fp.h +++ /dev/null @@ -1,76 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: ResponseCodeProcessing_fp.h 809 2016-11-16 18:31:54Z 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 */ -/* */ -/********************************************************************************/ - -/*(Auto-generated) - * Created by TpmPrototypes; Version 3.0 July 18, 2017 - * Date: Mar 28, 2019 Time: 08:25:19PM - */ - -#ifndef _RESPONSE_CODE_PROCESSING_FP_H_ -#define _RESPONSE_CODE_PROCESSING_FP_H_ - -//** RcSafeAddToResult() -// Adds a modifier to a response code as long as the response code allows a modifier -// and no modifier has already been added. -TPM_RC -RcSafeAddToResult(TPM_RC responseCode, TPM_RC modifier); - -#endif // _RESPONSE_CODE_PROCESSING_FP_H_ diff --git a/src/tpm2/Response_fp.h b/src/tpm2/Response_fp.h deleted file mode 100644 index 77e75a792..000000000 --- a/src/tpm2/Response_fp.h +++ /dev/null @@ -1,78 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: Response_fp.h 809 2016-11-16 18:31:54Z 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 */ -/* */ -/********************************************************************************/ - -/*(Auto-generated) - * Created by TpmPrototypes; Version 3.0 July 18, 2017 - * Date: Mar 28, 2019 Time: 08:25:19PM - */ - -#ifndef _RESPONSE_FP_H_ -#define _RESPONSE_FP_H_ - -//** BuildResponseHeader() -// Adds the response header to the response. It will update command->parameterSize -// to indicate the total size of the response. -void BuildResponseHeader(COMMAND* command, // IN: main control structure - BYTE* buffer, // OUT: the output buffer - TPM_RC result // IN: the response code -); - -#endif // _RESPONSE_FP_H_ diff --git a/src/tpm2/Rewrap_fp.h b/src/tpm2/Rewrap_fp.h deleted file mode 100644 index 201e67852..000000000 --- a/src/tpm2/Rewrap_fp.h +++ /dev/null @@ -1,99 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: Rewrap_fp.h 809 2016-11-16 18:31:54Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_Rewrap // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_REWRAP_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_REWRAP_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_DH_OBJECT oldParent; - TPMI_DH_OBJECT newParent; - TPM2B_PRIVATE inDuplicate; - TPM2B_NAME name; - TPM2B_ENCRYPTED_SECRET inSymSeed; -} Rewrap_In; - -// Output structure definition -typedef struct -{ - TPM2B_PRIVATE outDuplicate; - TPM2B_ENCRYPTED_SECRET outSymSeed; -} Rewrap_Out; - -// Response code modifiers -# define RC_Rewrap_oldParent (TPM_RC_H + TPM_RC_1) -# define RC_Rewrap_newParent (TPM_RC_H + TPM_RC_2) -# define RC_Rewrap_inDuplicate (TPM_RC_P + TPM_RC_1) -# define RC_Rewrap_name (TPM_RC_P + TPM_RC_2) -# define RC_Rewrap_inSymSeed (TPM_RC_P + TPM_RC_3) - -// Function prototype -TPM_RC -TPM2_Rewrap(Rewrap_In* in, Rewrap_Out* out); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_REWRAP_FP_H_ -#endif // CC_Rewrap diff --git a/src/tpm2/RunCommand.c b/src/tpm2/RunCommand.c deleted file mode 100644 index 77709ff23..000000000 --- a/src/tpm2/RunCommand.c +++ /dev/null @@ -1,141 +0,0 @@ -/********************************************************************************/ -/* */ -/* Platform specific entry and fail processing */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: RunCommand.c 1476 2019-06-10 19:32:03Z 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 */ -/* */ -/********************************************************************************/ - -//**Introduction -// This module provides the platform specific entry and fail processing. The -// _plat__RunCommand() function is used to call to ExecuteCommand() in the TPM code. -// This function does whatever processing is necessary to set up the platform -// in anticipation of the call to the TPM including settup for error processing. -// -// The _plat__Fail() function is called when there is a failure in the TPM. The TPM -// code will have set the flag to indicate that the TPM is in failure mode. -// This call will then recursively call ExecuteCommand in order to build the -// failure mode response. When ExecuteCommand() returns to _plat__Fail(), the -// platform will do some platform specif operation to return to the environment in -// which the TPM is executing. For a simulator, setjmp/longjmp is used. For an OS, -// a system exit to the OS would be appropriate. - -//** Includes and locals -#include "Platform.h" -#include -#include -#include - -jmp_buf s_jumpBuffer; - -// The following extern globals are copied here from Global.h to avoid including all of Tpm.h here. -// TODO: Improve the interface by which these values are shared. -extern BOOL g_inFailureMode; // Indicates that the TPM is in failure mode -#if ALLOW_FORCE_FAILURE_MODE -extern BOOL g_forceFailureMode; // flag to force failure mode during test -#endif -#if FAIL_TRACE -// The name of the function that triggered failure mode. -extern const char* s_failFunctionName; -#endif // FAIL_TRACE -extern UINT32 s_failFunction; -extern UINT32 s_failLine; -extern UINT32 s_failCode; - -//** Functions - -//***_plat__RunCommand() -// This version of RunCommand will set up a jum_buf and call ExecuteCommand(). If -// the command executes without failing, it will return and RunCommand will return. -// If there is a failure in the command, then _plat__Fail() is called and it will -// longjump back to RunCommand which will call ExecuteCommand again. However, this -// time, the TPM will be in failure mode so ExecuteCommand will simply build -// a failure response and return. -LIB_EXPORT void _plat__RunCommand( - uint32_t requestSize, // IN: command buffer size - unsigned char* request, // IN: command buffer - uint32_t* responseSize, // IN/OUT: response buffer size - unsigned char** response // IN/OUT: response buffer -) -{ - setjmp(s_jumpBuffer); - ExecuteCommand(requestSize, request, responseSize, response); -} - -//***_plat__Fail() -// This is the platform depended failure exit for the TPM. -LIB_EXPORT NORETURN void _plat__Fail(void) -{ - -#if ALLOW_FORCE_FAILURE_MODE - // The simulator asserts during unexpected (i.e., un-forced) failure modes. - if(!g_forceFailureMode) - { - fprintf(stderr, "Unexpected failure mode (code %d) in ", s_failCode); -# if FAIL_TRACE - fprintf(stderr, "function '%s' (line %d)\n", s_failFunctionName, s_failLine); -# else // FAIL_TRACE - fprintf(stderr, "location code 0x%0x\n", s_locationCode); -# endif // FAIL_TRACE - assert(FALSE); - } - - // Clear the forced-failure mode flag for next time. - g_forceFailureMode = FALSE; -#endif // ALLOW_FORCE_FAILURE_MODE - - longjmp(&s_jumpBuffer[0], 1); -} diff --git a/src/tpm2/RuntimeAlgorithm.c b/src/tpm2/RuntimeAlgorithm.c index 0bec7bbdf..af8fcfb9f 100644 --- a/src/tpm2/RuntimeAlgorithm.c +++ b/src/tpm2/RuntimeAlgorithm.c @@ -1,43 +1,6 @@ -/********************************************************************************/ -/* */ -/* Algorithm Runtime Disablement */ -/* Written by Stefan Berger */ -/* IBM Thomas J. Watson Research Center */ -/* */ -/* Licenses and Notices */ -/* */ -/* (c) Copyright IBM Corporation, 2022 */ -/* */ -/* All rights reserved. */ -/* */ -/* Redistribution and use in source and binary forms, with or without */ -/* modification, are permitted provided that the following conditions are */ -/* met: */ -/* */ -/* Redistributions of source code must retain the above copyright notice, */ -/* this list of conditions and the following disclaimer. */ -/* */ -/* Redistributions in binary form must reproduce the above copyright */ -/* notice, this list of conditions and the following disclaimer in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* Neither the names of the IBM Corporation nor the names of its */ -/* contributors may be used to endorse or promote products derived from */ -/* this software without specific prior written permission. */ -/* */ -/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */ -/* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */ -/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR */ -/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */ -/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */ -/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */ -/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, */ -/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY */ -/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */ -/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE */ -/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause + +// (c) Copyright IBM Corporation, 2022 #define _GNU_SOURCE #include @@ -45,7 +8,7 @@ #include "Tpm.h" #include "NVMarshal.h" -#include "GpMacros.h" +#include "tpm_public/GpMacros.h" #include "tpm_library_intern.h" #define ALGO_SEPARATOR_C ',' diff --git a/src/tpm2/RuntimeAlgorithm_fp.h b/src/tpm2/RuntimeAlgorithm_fp.h index 4cbece99b..9f3226bcb 100644 --- a/src/tpm2/RuntimeAlgorithm_fp.h +++ b/src/tpm2/RuntimeAlgorithm_fp.h @@ -1,43 +1,6 @@ -/********************************************************************************/ -/* */ -/* Algorithm Runtime Disablement */ -/* Written by Stefan Berger */ -/* IBM Thomas J. Watson Research Center */ -/* */ -/* Licenses and Notices */ -/* */ -/* (c) Copyright IBM Corporation, 2022 */ -/* */ -/* All rights reserved. */ -/* */ -/* Redistribution and use in source and binary forms, with or without */ -/* modification, are permitted provided that the following conditions are */ -/* met: */ -/* */ -/* Redistributions of source code must retain the above copyright notice, */ -/* this list of conditions and the following disclaimer. */ -/* */ -/* Redistributions in binary form must reproduce the above copyright */ -/* notice, this list of conditions and the following disclaimer in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* Neither the names of the IBM Corporation nor the names of its */ -/* contributors may be used to endorse or promote products derived from */ -/* this software without specific prior written permission. */ -/* */ -/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */ -/* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */ -/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR */ -/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */ -/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */ -/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */ -/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, */ -/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY */ -/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */ -/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE */ -/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause + +// (c) Copyright IBM Corporation, 2022 #ifndef RUNTIME_ALGORITHM_H #define RUNTIME_ALGORITHM_H diff --git a/src/tpm2/RuntimeAttributes.c b/src/tpm2/RuntimeAttributes.c index e2e5b8ad1..529cb6d2b 100644 --- a/src/tpm2/RuntimeAttributes.c +++ b/src/tpm2/RuntimeAttributes.c @@ -1,43 +1,6 @@ -/********************************************************************************/ -/* */ -/* Runtime Attributes */ -/* Written by Stefan Berger */ -/* IBM Thomas J. Watson Research Center */ -/* */ -/* Licenses and Notices */ -/* */ -/* (c) Copyright IBM Corporation, 2023 */ -/* */ -/* All rights reserved. */ -/* */ -/* Redistribution and use in source and binary forms, with or without */ -/* modification, are permitted provided that the following conditions are */ -/* met: */ -/* */ -/* Redistributions of source code must retain the above copyright notice, */ -/* this list of conditions and the following disclaimer. */ -/* */ -/* Redistributions in binary form must reproduce the above copyright */ -/* notice, this list of conditions and the following disclaimer in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* Neither the names of the IBM Corporation nor the names of its */ -/* contributors may be used to endorse or promote products derived from */ -/* this software without specific prior written permission. */ -/* */ -/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */ -/* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */ -/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR */ -/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */ -/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */ -/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */ -/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, */ -/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY */ -/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */ -/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE */ -/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause + +// (c) Copyright IBM Corporation, 2023 #define _GNU_SOURCE #include diff --git a/src/tpm2/RuntimeAttributes_fp.h b/src/tpm2/RuntimeAttributes_fp.h index b61b090ec..436ba3189 100644 --- a/src/tpm2/RuntimeAttributes_fp.h +++ b/src/tpm2/RuntimeAttributes_fp.h @@ -1,43 +1,6 @@ -/********************************************************************************/ -/* */ -/* Runtime Attributes */ -/* Written by Stefan Berger */ -/* IBM Thomas J. Watson Research Center */ -/* */ -/* Licenses and Notices */ -/* */ -/* (c) Copyright IBM Corporation, 2022 */ -/* */ -/* All rights reserved. */ -/* */ -/* Redistribution and use in source and binary forms, with or without */ -/* modification, are permitted provided that the following conditions are */ -/* met: */ -/* */ -/* Redistributions of source code must retain the above copyright notice, */ -/* this list of conditions and the following disclaimer. */ -/* */ -/* Redistributions in binary form must reproduce the above copyright */ -/* notice, this list of conditions and the following disclaimer in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* Neither the names of the IBM Corporation nor the names of its */ -/* contributors may be used to endorse or promote products derived from */ -/* this software without specific prior written permission. */ -/* */ -/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */ -/* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */ -/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR */ -/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */ -/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */ -/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */ -/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, */ -/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY */ -/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */ -/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE */ -/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause + +// (c) Copyright IBM Corporation, 2022 #ifndef RUNTIME_ATTRIBUTES_H #define RUNTIME_ATTRIBUTES_H diff --git a/src/tpm2/RuntimeCommands.c b/src/tpm2/RuntimeCommands.c index 6e2b01747..799b511e6 100644 --- a/src/tpm2/RuntimeCommands.c +++ b/src/tpm2/RuntimeCommands.c @@ -1,43 +1,6 @@ -/********************************************************************************/ -/* */ -/* TPM 2 Commands Runtime Disablement */ -/* Written by Stefan Berger */ -/* IBM Thomas J. Watson Research Center */ -/* */ -/* Licenses and Notices */ -/* */ -/* (c) Copyright IBM Corporation, 2022 */ -/* */ -/* All rights reserved. */ -/* */ -/* Redistribution and use in source and binary forms, with or without */ -/* modification, are permitted provided that the following conditions are */ -/* met: */ -/* */ -/* Redistributions of source code must retain the above copyright notice, */ -/* this list of conditions and the following disclaimer. */ -/* */ -/* Redistributions in binary form must reproduce the above copyright */ -/* notice, this list of conditions and the following disclaimer in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* Neither the names of the IBM Corporation nor the names of its */ -/* contributors may be used to endorse or promote products derived from */ -/* this software without specific prior written permission. */ -/* */ -/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */ -/* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */ -/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR */ -/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */ -/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */ -/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */ -/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, */ -/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY */ -/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */ -/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE */ -/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause + +// (c) Copyright IBM Corporation, 2022 #define _GNU_SOURCE #include @@ -191,10 +154,12 @@ static const struct { COMMAND(NV_DefineSpace2, true, 0), // not supported COMMAND(NV_ReadPublic2, true, 0), // not supported COMMAND(SetCapability, true, 0), // not supported + COMMAND(ReadOnlyControl, true, 0), // not supported + COMMAND(PolicyTransportSPDM, true, 0), // not supported /* all new commands added here MUST have CAN_BE_DISABLE = true */ #undef COMMAND }; -MUST_BE(TPM_CC_LAST == TPM_CC_SetCapability); /* force update of above list when new commands added */ +MUST_BE(TPM_CC_LAST == TPM_CC_PolicyTransportSPDM); /* force update of above list when new commands added */ static void RuntimeCommandsEnableAllCommands(struct RuntimeCommands *RuntimeCommands, diff --git a/src/tpm2/RuntimeCommands_fp.h b/src/tpm2/RuntimeCommands_fp.h index 520f1ce47..3a5a681b2 100644 --- a/src/tpm2/RuntimeCommands_fp.h +++ b/src/tpm2/RuntimeCommands_fp.h @@ -1,43 +1,6 @@ -/********************************************************************************/ -/* */ -/* TPM 2 Commands Runtime Disablement */ -/* Written by Stefan Berger */ -/* IBM Thomas J. Watson Research Center */ -/* */ -/* Licenses and Notices */ -/* */ -/* (c) Copyright IBM Corporation, 2022 */ -/* */ -/* All rights reserved. */ -/* */ -/* Redistribution and use in source and binary forms, with or without */ -/* modification, are permitted provided that the following conditions are */ -/* met: */ -/* */ -/* Redistributions of source code must retain the above copyright notice, */ -/* this list of conditions and the following disclaimer. */ -/* */ -/* Redistributions in binary form must reproduce the above copyright */ -/* notice, this list of conditions and the following disclaimer in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* Neither the names of the IBM Corporation nor the names of its */ -/* contributors may be used to endorse or promote products derived from */ -/* this software without specific prior written permission. */ -/* */ -/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */ -/* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */ -/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR */ -/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */ -/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */ -/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */ -/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, */ -/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY */ -/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */ -/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE */ -/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause + +// (c) Copyright IBM Corporation, 2022 #ifndef RUNTIME_COMMANDS_H #define RUNTIME_COMMANDS_H diff --git a/src/tpm2/RuntimeProfile.c b/src/tpm2/RuntimeProfile.c index ffd95c38c..b4909e7fe 100644 --- a/src/tpm2/RuntimeProfile.c +++ b/src/tpm2/RuntimeProfile.c @@ -1,43 +1,6 @@ -/********************************************************************************/ -/* */ -/* Runtime Profile */ -/* Written by Stefan Berger */ -/* IBM Thomas J. Watson Research Center */ -/* */ -/* Licenses and Notices */ -/* */ -/* (c) Copyright IBM Corporation, 2022 */ -/* */ -/* All rights reserved. */ -/* */ -/* Redistribution and use in source and binary forms, with or without */ -/* modification, are permitted provided that the following conditions are */ -/* met: */ -/* */ -/* Redistributions of source code must retain the above copyright notice, */ -/* this list of conditions and the following disclaimer. */ -/* */ -/* Redistributions in binary form must reproduce the above copyright */ -/* notice, this list of conditions and the following disclaimer in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* Neither the names of the IBM Corporation nor the names of its */ -/* contributors may be used to endorse or promote products derived from */ -/* this software without specific prior written permission. */ -/* */ -/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */ -/* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */ -/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR */ -/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */ -/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */ -/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */ -/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, */ -/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY */ -/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */ -/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE */ -/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause + +// (c) Copyright IBM Corporation, 2022 #define _GNU_SOURCE #include diff --git a/src/tpm2/RuntimeProfile_fp.h b/src/tpm2/RuntimeProfile_fp.h index ae3ac28ca..62694ac2d 100644 --- a/src/tpm2/RuntimeProfile_fp.h +++ b/src/tpm2/RuntimeProfile_fp.h @@ -1,43 +1,6 @@ -/********************************************************************************/ -/* */ -/* Runtime Profile */ -/* Written by Stefan Berger */ -/* IBM Thomas J. Watson Research Center */ -/* */ -/* Licenses and Notices */ -/* */ -/* (c) Copyright IBM Corporation, 2022 */ -/* */ -/* All rights reserved. */ -/* */ -/* Redistribution and use in source and binary forms, with or without */ -/* modification, are permitted provided that the following conditions are */ -/* met: */ -/* */ -/* Redistributions of source code must retain the above copyright notice, */ -/* this list of conditions and the following disclaimer. */ -/* */ -/* Redistributions in binary form must reproduce the above copyright */ -/* notice, this list of conditions and the following disclaimer in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* Neither the names of the IBM Corporation nor the names of its */ -/* contributors may be used to endorse or promote products derived from */ -/* this software without specific prior written permission. */ -/* */ -/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */ -/* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */ -/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR */ -/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */ -/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */ -/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */ -/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, */ -/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY */ -/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */ -/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE */ -/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause + +// (c) Copyright IBM Corporation, 2022 #ifndef RUNTIME_PROFILE_H #define RUNTIME_PROFILE_H diff --git a/src/tpm2/SelfTest.h b/src/tpm2/SelfTest.h deleted file mode 100644 index 2a833b00d..000000000 --- a/src/tpm2/SelfTest.h +++ /dev/null @@ -1,131 +0,0 @@ -/********************************************************************************/ -/* */ -/* Structure definitions for the self-test */ -/* 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 */ -/* */ -/********************************************************************************/ - -//** Introduction -// This file contains the structure definitions for the self-test. It also contains -// macros for use when the self-test is implemented. -#ifndef _SELF_TEST_H_ -#define _SELF_TEST_H_ - -//** Defines - -// Was typing this a lot -#define SELF_TEST_FAILURE FAIL(FATAL_ERROR_SELF_TEST) - -// Use the definition of key sizes to set algorithm values for key size. -#define AES_ENTRIES (AES_128 + AES_192 + AES_256) -#define SM4_ENTRIES (SM4_128) -#define CAMELLIA_ENTRIES (CAMELLIA_128 + CAMELLIA_192 + CAMELLIA_256) -#define TDES_ENTRIES (TDES_128 * 2 + TDES_192 * 2) /* libtpms changed */ - -#define NUM_SYMS (AES_ENTRIES + SM4_ENTRIES + CAMELLIA_ENTRIES + TDES_ENTRIES) // libtpmss added TDES_ENTRIES - -typedef UINT32 SYM_INDEX; - -// These two defines deal with the fact that the TPM_ALG_ID table does not delimit -// the symmetric mode values with a SYM_MODE_FIRST and SYM_MODE_LAST -#define SYM_MODE_FIRST ALG_CTR_VALUE -#define SYM_MODE_LAST ALG_ECB_VALUE - -#define NUM_SYM_MODES (SYM_MODE_LAST - SYM_MODE_FIRST + 1) - -// Define a type to hold a bit vector for the modes. -#if NUM_SYM_MODES <= 0 -# error "No symmetric modes implemented" -#elif NUM_SYM_MODES <= 8 -typedef BYTE SYM_MODES; -#elif NUM_SYM_MODES <= 16 -typedef UINT16 SYM_MODES; -#elif NUM_SYM_MODES <= 32 -typedef UINT32 SYM_MODES; -#else -# error "Too many symmetric modes" -#endif - -typedef struct SYMMETRIC_TEST_VECTOR -{ - const TPM_ALG_ID alg; // the algorithm - const UINT16 keyBits; // bits in the key - const BYTE* key; // The test key - const UINT32 ivSize; // block size of the algorithm - const UINT32 dataInOutSize; // size to encrypt/decrypt - const BYTE* dataIn; // data to encrypt - const BYTE* dataOut[NUM_SYM_MODES]; // data to decrypt -} SYMMETRIC_TEST_VECTOR; - -#if ALG_SHA512 -# define DEFAULT_TEST_HASH ALG_SHA512_VALUE -# define DEFAULT_TEST_DIGEST_SIZE SHA512_DIGEST_SIZE -# define DEFAULT_TEST_HASH_BLOCK_SIZE SHA512_BLOCK_SIZE -#elif ALG_SHA384 -# define DEFAULT_TEST_HASH ALG_SHA384_VALUE -# define DEFAULT_TEST_DIGEST_SIZE SHA384_DIGEST_SIZE -# define DEFAULT_TEST_HASH_BLOCK_SIZE SHA384_BLOCK_SIZE -#elif ALG_SHA256 -# define DEFAULT_TEST_HASH ALG_SHA256_VALUE -# define DEFAULT_TEST_DIGEST_SIZE SHA256_DIGEST_SIZE -# define DEFAULT_TEST_HASH_BLOCK_SIZE SHA256_BLOCK_SIZE -#elif ALG_SHA1 -# define DEFAULT_TEST_HASH ALG_SHA1_VALUE -# define DEFAULT_TEST_DIGEST_SIZE SHA1_DIGEST_SIZE -# define DEFAULT_TEST_HASH_BLOCK_SIZE SHA1_BLOCK_SIZE -#endif - -#endif // _SELF_TEST_H_ diff --git a/src/tpm2/SelfTest_fp.h b/src/tpm2/SelfTest_fp.h deleted file mode 100644 index e1ba1a5ac..000000000 --- a/src/tpm2/SelfTest_fp.h +++ /dev/null @@ -1,84 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: SelfTest_fp.h 809 2016-11-16 18:31:54Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_SelfTest // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_SELFTEST_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_SELFTEST_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_YES_NO fullTest; -} SelfTest_In; - -// Response code modifiers -# define RC_SelfTest_fullTest (TPM_RC_P + TPM_RC_1) - -// Function prototype -TPM_RC -TPM2_SelfTest(SelfTest_In* in); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_SELFTEST_FP_H_ -#endif // CC_SelfTest diff --git a/src/tpm2/SequenceComplete_fp.h b/src/tpm2/SequenceComplete_fp.h deleted file mode 100644 index 574db088a..000000000 --- a/src/tpm2/SequenceComplete_fp.h +++ /dev/null @@ -1,95 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: SequenceComplete_fp.h 809 2016-11-16 18:31:54Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_SequenceComplete // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_SEQUENCECOMPLETE_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_SEQUENCECOMPLETE_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_DH_OBJECT sequenceHandle; - TPM2B_MAX_BUFFER buffer; - TPMI_RH_HIERARCHY hierarchy; -} SequenceComplete_In; - -// Output structure definition -typedef struct -{ - TPM2B_DIGEST result; - TPMT_TK_HASHCHECK validation; -} SequenceComplete_Out; - -// Response code modifiers -# define RC_SequenceComplete_sequenceHandle (TPM_RC_H + TPM_RC_1) -# define RC_SequenceComplete_buffer (TPM_RC_P + TPM_RC_1) -# define RC_SequenceComplete_hierarchy (TPM_RC_P + TPM_RC_2) - -// Function prototype -TPM_RC -TPM2_SequenceComplete(SequenceComplete_In* in, SequenceComplete_Out* out); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_SEQUENCECOMPLETE_FP_H_ -#endif // CC_SequenceComplete diff --git a/src/tpm2/SequenceUpdate_fp.h b/src/tpm2/SequenceUpdate_fp.h deleted file mode 100644 index 1bcc0ba15..000000000 --- a/src/tpm2/SequenceUpdate_fp.h +++ /dev/null @@ -1,86 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: SequenceUpdate_fp.h 809 2016-11-16 18:31:54Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_SequenceUpdate // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_SEQUENCEUPDATE_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_SEQUENCEUPDATE_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_DH_OBJECT sequenceHandle; - TPM2B_MAX_BUFFER buffer; -} SequenceUpdate_In; - -// Response code modifiers -# define RC_SequenceUpdate_sequenceHandle (TPM_RC_H + TPM_RC_1) -# define RC_SequenceUpdate_buffer (TPM_RC_P + TPM_RC_1) - -// Function prototype -TPM_RC -TPM2_SequenceUpdate(SequenceUpdate_In* in); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_SEQUENCEUPDATE_FP_H_ -#endif // CC_SequenceUpdate diff --git a/src/tpm2/SessionCommands.c b/src/tpm2/SessionCommands.c index d2f3f96c7..a5ed0cb16 100644 --- a/src/tpm2/SessionCommands.c +++ b/src/tpm2/SessionCommands.c @@ -82,6 +82,7 @@ TPM2_StartAuthSession( { // Get pointer to loaded decrypt key tpmKey = HandleToObject(in->tpmKey); + pAssert_RC(tpmKey != NULL); // key must be asymmetric with its sensitive area loaded. Since this // command does not require authorization, the presence of the sensitive // area was not already checked as it is with most other commands that @@ -118,6 +119,8 @@ TPM2_StartAuthSession( case TPM_HT_TRANSIENT: { OBJECT *object = HandleToObject(in->bind); + pAssert_RC(object != NULL); + // If the bind handle references a transient object, make sure that we // can get to the authorization value. Also, make sure that the object // has a proper Name (nameAlg != TPM_ALG_NULL). If it doesn't, then @@ -168,8 +171,12 @@ TPM2_PolicyRestart( PolicyRestart_In *in // IN: input parameter list ) { + SESSION* session = SessionGet(in->sessionHandle); + pAssert_RC(session != NULL); + // Initialize policy session data - SessionResetPolicyData(SessionGet(in->sessionHandle)); + SessionResetPolicyData(session); + return TPM_RC_SUCCESS; } #endif // CC_PolicyRestart diff --git a/src/tpm2/SessionProcess_fp.h b/src/tpm2/SessionProcess_fp.h deleted file mode 100644 index 398adb6db..000000000 --- a/src/tpm2/SessionProcess_fp.h +++ /dev/null @@ -1,143 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* 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 */ -/* */ -/********************************************************************************/ - -/*(Auto-generated) - * Created by TpmPrototypes; Version 3.0 July 18, 2017 - * Date: Mar 7, 2020 Time: 07:17:48PM - */ - -#ifndef _SESSION_PROCESS_FP_H_ -#define _SESSION_PROCESS_FP_H_ - -//*** IsDAExempted() -// This function indicates if a handle is exempted from DA logic. -// A handle is exempted if it is: -// a) a primary seed handle; -// b) an object with noDA bit SET; -// c) an NV Index with TPMA_NV_NO_DA bit SET; or -// d) a PCR handle. -// -// Return Type: BOOL -// TRUE(1) handle is exempted from DA logic -// FALSE(0) handle is not exempted from DA logic -BOOL IsDAExempted(TPM_HANDLE handle // IN: entity handle -); - -//*** ClearCpRpHashes() -void ClearCpRpHashes(COMMAND* command); - -//*** CompareNameHash() -// This function computes the name hash and compares it to the nameHash in the -// session data, returning true if they are equal. -BOOL CompareNameHash(COMMAND* command, // IN: main parsing structure - SESSION* session // IN: session structure with nameHash -); - -//*** CompareParametersHash() -// This function computes the parameters hash and compares it to the pHash in -// the session data, returning true if they are equal. -BOOL CompareParametersHash(COMMAND* command, // IN: main parsing structure - SESSION* session // IN: session structure with pHash -); - -//*** ParseSessionBuffer() -// This function is the entry function for command session processing. -// It iterates sessions in session area and reports if the required authorization -// has been properly provided. It also processes audit session and passes the -// information of encryption sessions to parameter encryption module. -// -// Return Type: TPM_RC -// various parsing failure or authorization failure -// -TPM_RC -ParseSessionBuffer(COMMAND* command // IN: the structure that contains -); - -//*** CheckAuthNoSession() -// Function to process a command with no session associated. -// The function makes sure all the handles in the command require no authorization. -// -// Return Type: TPM_RC -// TPM_RC_AUTH_MISSING failure - one or more handles require -// authorization -TPM_RC -CheckAuthNoSession(COMMAND* command // IN: command parsing structure -); - -//*** BuildResponseSession() -// Function to build Session buffer in a response. The authorization data is added -// to the end of command->responseBuffer. The size of the authorization area is -// accumulated in command->authSize. -// When this is called, command->responseBuffer is pointing at the next location -// in the response buffer to be filled. This is where the authorization sessions -// will go, if any. command->parameterSize is the number of bytes that have been -// marshaled as parameters in the output buffer. -TPM_RC -BuildResponseSession(COMMAND* command // IN: structure that has relevant command - // information -); - -//*** SessionRemoveAssociationToHandle() -// This function deals with the case where an entity associated with an authorization -// is deleted during command processing. The primary use of this is to support -// UndefineSpaceSpecial(). -void SessionRemoveAssociationToHandle(TPM_HANDLE handle); - -#endif // _SESSION_PROCESS_FP_H_ diff --git a/src/tpm2/SetAlgorithmSet_fp.h b/src/tpm2/SetAlgorithmSet_fp.h deleted file mode 100644 index a11b8a43c..000000000 --- a/src/tpm2/SetAlgorithmSet_fp.h +++ /dev/null @@ -1,87 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: SetAlgorithmSet_fp.h 809 2016-11-16 18:31:54Z 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 PURPO -SE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_SetAlgorithmSet // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_SETALGORITHMSET_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_SETALGORITHMSET_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_RH_PLATFORM authHandle; - UINT32 algorithmSet; -} SetAlgorithmSet_In; - -// Response code modifiers -# define RC_SetAlgorithmSet_authHandle (TPM_RC_H + TPM_RC_1) -# define RC_SetAlgorithmSet_algorithmSet (TPM_RC_P + TPM_RC_1) - -// Function prototype -TPM_RC -TPM2_SetAlgorithmSet(SetAlgorithmSet_In* in); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_SETALGORITHMSET_FP_H_ -#endif // CC_SetAlgorithmSet diff --git a/src/tpm2/SetCapability_fp.h b/src/tpm2/SetCapability_fp.h deleted file mode 100644 index 8821053be..000000000 --- a/src/tpm2/SetCapability_fp.h +++ /dev/null @@ -1,82 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* 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 */ -/* */ -/********************************************************************************/ - - -#if CC_SetCapability // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_SETCAPABILITY_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_SETCAPABILITY_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_RH_HIERARCHY authHandle; - TPM2B_SET_CAPABILITY_DATA setCapabilityData; -} SetCapability_In; - -// Response code modifiers -# define SetCapability_authHandle (TPM_RC_H + TPM_RC_1) -# define SetCapability_setCapabilityData (TPM_RC_P + TPM_RC_1) - -// Function prototype -TPM_RC TPM2_SetCapability(SetCapability_In* in); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_SETCAPABILITY_FP_H_ -#endif // CC_SetCapability diff --git a/src/tpm2/SetCommandCodeAuditStatus_fp.h b/src/tpm2/SetCommandCodeAuditStatus_fp.h deleted file mode 100644 index aaa94c46b..000000000 --- a/src/tpm2/SetCommandCodeAuditStatus_fp.h +++ /dev/null @@ -1,90 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: SetCommandCodeAuditStatus_fp.h 809 2016-11-16 18:31:54Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_SetCommandCodeAuditStatus // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_SETCOMMANDCODEAUDITSTATUS_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_SETCOMMANDCODEAUDITSTATUS_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_RH_PROVISION auth; - TPMI_ALG_HASH auditAlg; - TPML_CC setList; - TPML_CC clearList; -} SetCommandCodeAuditStatus_In; - -// Response code modifiers -# define RC_SetCommandCodeAuditStatus_auth (TPM_RC_H + TPM_RC_1) -# define RC_SetCommandCodeAuditStatus_auditAlg (TPM_RC_P + TPM_RC_1) -# define RC_SetCommandCodeAuditStatus_setList (TPM_RC_P + TPM_RC_2) -# define RC_SetCommandCodeAuditStatus_clearList (TPM_RC_P + TPM_RC_3) - -// Function prototype -TPM_RC -TPM2_SetCommandCodeAuditStatus(SetCommandCodeAuditStatus_In* in); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_SETCOMMANDCODEAUDITSTATUS_FP_H_ -#endif // CC_SetCommandCodeAuditStatus diff --git a/src/tpm2/SetPrimaryPolicy_fp.h b/src/tpm2/SetPrimaryPolicy_fp.h deleted file mode 100644 index 05ec3331b..000000000 --- a/src/tpm2/SetPrimaryPolicy_fp.h +++ /dev/null @@ -1,88 +0,0 @@ -/********************************************************************************/ -/* */ -/* TPM2_SetPrimaryPolicy Command Header */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: SetPrimaryPolicy_fp.h 1521 2019-11-15 21:00:47Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012 - 2019 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_SetPrimaryPolicy // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_SETPRIMARYPOLICY_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_SETPRIMARYPOLICY_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_RH_HIERARCHY_POLICY authHandle; - TPM2B_DIGEST authPolicy; - TPMI_ALG_HASH hashAlg; -} SetPrimaryPolicy_In; - -// Response code modifiers -# define RC_SetPrimaryPolicy_authHandle (TPM_RC_H + TPM_RC_1) -# define RC_SetPrimaryPolicy_authPolicy (TPM_RC_P + TPM_RC_1) -# define RC_SetPrimaryPolicy_hashAlg (TPM_RC_P + TPM_RC_2) - -// Function prototype -TPM_RC -TPM2_SetPrimaryPolicy(SetPrimaryPolicy_In* in); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_SETPRIMARYPOLICY_FP_H_ -#endif // CC_SetPrimaryPolicy diff --git a/src/tpm2/Shutdown_fp.h b/src/tpm2/Shutdown_fp.h deleted file mode 100644 index ed04e5ce2..000000000 --- a/src/tpm2/Shutdown_fp.h +++ /dev/null @@ -1,84 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: Shutdown_fp.h 809 2016-11-16 18:31:54Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_Shutdown // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_SHUTDOWN_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_SHUTDOWN_FP_H_ - -// Input structure definition -typedef struct -{ - TPM_SU shutdownType; -} Shutdown_In; - -// Response code modifiers -# define RC_Shutdown_shutdownType (TPM_RC_P + TPM_RC_1) - -// Function prototype -TPM_RC -TPM2_Shutdown(Shutdown_In* in); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_SHUTDOWN_FP_H_ -#endif // CC_Shutdown diff --git a/src/tpm2/Sign_fp.h b/src/tpm2/Sign_fp.h deleted file mode 100644 index 35fc8c900..000000000 --- a/src/tpm2/Sign_fp.h +++ /dev/null @@ -1,96 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: Sign_fp.h 1521 2019-11-15 21:00:47Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_Sign // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_SIGN_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_SIGN_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_DH_OBJECT keyHandle; - TPM2B_DIGEST digest; - TPMT_SIG_SCHEME inScheme; - TPMT_TK_HASHCHECK validation; -} Sign_In; - -// Output structure definition -typedef struct -{ - TPMT_SIGNATURE signature; -} Sign_Out; - -// Response code modifiers -# define RC_Sign_keyHandle (TPM_RC_H + TPM_RC_1) -# define RC_Sign_digest (TPM_RC_P + TPM_RC_1) -# define RC_Sign_inScheme (TPM_RC_P + TPM_RC_2) -# define RC_Sign_validation (TPM_RC_P + TPM_RC_3) - -// Function prototype -TPM_RC -TPM2_Sign(Sign_In* in, Sign_Out* out); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_SIGN_FP_H_ -#endif // CC_Sign diff --git a/src/tpm2/StartAuthSession_fp.h b/src/tpm2/StartAuthSession_fp.h deleted file mode 100644 index bcf530783..000000000 --- a/src/tpm2/StartAuthSession_fp.h +++ /dev/null @@ -1,103 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: StartAuthSession_fp.h 809 2016-11-16 18:31:54Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_StartAuthSession // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_STARTAUTHSESSION_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_STARTAUTHSESSION_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_DH_OBJECT tpmKey; - TPMI_DH_ENTITY bind; - TPM2B_NONCE nonceCaller; - TPM2B_ENCRYPTED_SECRET encryptedSalt; - TPM_SE sessionType; - TPMT_SYM_DEF symmetric; - TPMI_ALG_HASH authHash; -} StartAuthSession_In; - -// Output structure definition -typedef struct -{ - TPMI_SH_AUTH_SESSION sessionHandle; - TPM2B_NONCE nonceTPM; -} StartAuthSession_Out; - -// Response code modifiers -# define RC_StartAuthSession_tpmKey (TPM_RC_H + TPM_RC_1) -# define RC_StartAuthSession_bind (TPM_RC_H + TPM_RC_2) -# define RC_StartAuthSession_nonceCaller (TPM_RC_P + TPM_RC_1) -# define RC_StartAuthSession_encryptedSalt (TPM_RC_P + TPM_RC_2) -# define RC_StartAuthSession_sessionType (TPM_RC_P + TPM_RC_3) -# define RC_StartAuthSession_symmetric (TPM_RC_P + TPM_RC_4) -# define RC_StartAuthSession_authHash (TPM_RC_P + TPM_RC_5) - -// Function prototype -TPM_RC -TPM2_StartAuthSession(StartAuthSession_In* in, StartAuthSession_Out* out); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_STARTAUTHSESSION_FP_H_ -#endif // CC_StartAuthSession diff --git a/src/tpm2/StartupCommands.c b/src/tpm2/StartupCommands.c index ac06d0ba3..5babfad79 100644 --- a/src/tpm2/StartupCommands.c +++ b/src/tpm2/StartupCommands.c @@ -58,75 +58,6 @@ /* */ /********************************************************************************/ - -#include "Tpm.h" -// TODO_RENAME_INC_FOLDER:platform_interface refers to the TPM_CoreLib platform interface -#include "_TPM_Init_fp.h" -#include "StateMarshal.h" /* libtpms added */ - -// This function is used to process a _TPM_Init indication. -LIB_EXPORT void _TPM_Init(void) -{ - BOOL restored = FALSE; /* libtpms added */ - g_powerWasLost = g_powerWasLost | _plat__WasPowerLost(); - -#if SIMULATION && DEBUG - // If power was lost and this was a simulation, put canary in RAM used by NV - // so that uninitialized memory can be detected more easily - if(g_powerWasLost) - { - memset(&gc, 0xbb, sizeof(gc)); - memset(&gr, 0xbb, sizeof(gr)); - memset(&gp, 0xbb, sizeof(gp)); - memset(&go, 0xbb, sizeof(go)); - } -#endif - -#if ALLOW_FORCE_FAILURE_MODE - // Clear the flag that forces failure on self-test - g_forceFailureMode = FALSE; -#endif - - // Disable the tick processing -#if ACT_SUPPORT || 1 // libtpms: changed - _plat__ACT_EnableTicks(FALSE); -#endif - - // Set initialization state - TPMInit(); - - // Set g_DRTMHandle as unassigned - g_DRTMHandle = TPM_RH_UNASSIGNED; - - // No H-CRTM, yet. - g_DrtmPreStartup = FALSE; - - // Initialize the NvEnvironment. - g_nvOk = NvPowerOn(); - - // Initialize cryptographic functions - g_inFailureMode |= (g_nvOk == FALSE) || (CryptInit() == FALSE); // libtpms changed - if(!g_inFailureMode) - { - // Load the persistent data - NvReadPersistent(); - - // Load the orderly data (clock and DRBG state). - // If this is not done here, things break - NvRead(&go, NV_ORDERLY_DATA, sizeof(go)); - - // Start clock. Need to do this after NV has been restored. - TimePowerOn(); - - /* libtpms added begin */ - VolatileLoad(&restored); - if (restored) - NVShadowRestore(); - /* libtpms added end */ - } - return; -} - #include "Tpm.h" #include "Startup_fp.h" #if CC_Startup // Conditional expansion of this file diff --git a/src/tpm2/Startup_fp.h b/src/tpm2/Startup_fp.h deleted file mode 100644 index 0699022d9..000000000 --- a/src/tpm2/Startup_fp.h +++ /dev/null @@ -1,84 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: Startup_fp.h 1521 2019-11-15 21:00:47Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_Startup // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_STARTUP_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_STARTUP_FP_H_ - -// Input structure definition -typedef struct -{ - TPM_SU startupType; -} Startup_In; - -// Response code modifiers -# define RC_Startup_startupType (TPM_RC_P + TPM_RC_1) - -// Function prototype -TPM_RC -TPM2_Startup(Startup_In* in); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_STARTUP_FP_H_ -#endif // CC_Startup diff --git a/src/tpm2/StateMarshal.c b/src/tpm2/StateMarshal.c index fbb26620d..a902257ff 100644 --- a/src/tpm2/StateMarshal.c +++ b/src/tpm2/StateMarshal.c @@ -1,40 +1,6 @@ -/********************************************************************************/ -/* */ -/* Marshalling and unmarshalling of state */ -/* Written by Stefan Berger */ -/* IBM Thomas J. Watson Research Center */ -/* */ -/* (c) Copyright IBM Corporation 2017,2018. */ -/* */ -/* All rights reserved. */ -/* */ -/* Redistribution and use in source and binary forms, with or without */ -/* modification, are permitted provided that the following conditions are */ -/* met: */ -/* */ -/* Redistributions of source code must retain the above copyright notice, */ -/* this list of conditions and the following disclaimer. */ -/* */ -/* Redistributions in binary form must reproduce the above copyright */ -/* notice, this list of conditions and the following disclaimer in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* Neither the names of the IBM Corporation nor the names of its */ -/* contributors may be used to endorse or promote products derived from */ -/* this software without specific prior written permission. */ -/* */ -/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */ -/* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */ -/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR */ -/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */ -/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */ -/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */ -/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, */ -/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY */ -/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */ -/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE */ -/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause + +// (c) Copyright IBM Corporation 2017,2018. #include @@ -96,3 +62,4 @@ VolatileLoad(BOOL *restored) return rc; } + diff --git a/src/tpm2/StateMarshal.h b/src/tpm2/StateMarshal.h index 6fc6d1464..ae3ceccbe 100644 --- a/src/tpm2/StateMarshal.h +++ b/src/tpm2/StateMarshal.h @@ -1,46 +1,12 @@ -/********************************************************************************/ -/* */ -/* Marshalling and unmarshalling of state */ -/* Written by Stefan Berger */ -/* IBM Thomas J. Watson Research Center */ -/* */ -/* (c) Copyright IBM Corporation 2017,2018. */ -/* */ -/* All rights reserved. */ -/* */ -/* Redistribution and use in source and binary forms, with or without */ -/* modification, are permitted provided that the following conditions are */ -/* met: */ -/* */ -/* Redistributions of source code must retain the above copyright notice, */ -/* this list of conditions and the following disclaimer. */ -/* */ -/* Redistributions in binary form must reproduce the above copyright */ -/* notice, this list of conditions and the following disclaimer in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* Neither the names of the IBM Corporation nor the names of its */ -/* contributors may be used to endorse or promote products derived from */ -/* this software without specific prior written permission. */ -/* */ -/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */ -/* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */ -/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR */ -/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */ -/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */ -/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */ -/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, */ -/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY */ -/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */ -/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE */ -/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause + +// (c) Copyright IBM Corporation 2017,2018. #ifndef STATE_MARSHAL_H #define STATE_MARSHAL_H #include "Tpm.h" -#include "TpmTypes.h" +#include /* * we keep these in a separate file to avoid symbol clashes when diff --git a/src/tpm2/StirRandom_fp.h b/src/tpm2/StirRandom_fp.h deleted file mode 100644 index a05139d82..000000000 --- a/src/tpm2/StirRandom_fp.h +++ /dev/null @@ -1,84 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: StirRandom_fp.h 809 2016-11-16 18:31:54Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_StirRandom // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_STIRRANDOM_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_STIRRANDOM_FP_H_ - -// Input structure definition -typedef struct -{ - TPM2B_SENSITIVE_DATA inData; -} StirRandom_In; - -// Response code modifiers -# define RC_StirRandom_inData (TPM_RC_P + TPM_RC_1) - -// Function prototype -TPM_RC -TPM2_StirRandom(StirRandom_In* in); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_STIRRANDOM_FP_H_ -#endif // CC_StirRandom diff --git a/src/tpm2/SymmetricCommands.c b/src/tpm2/SymmetricCommands.c index dadf41ccc..ba702c03c 100644 --- a/src/tpm2/SymmetricCommands.c +++ b/src/tpm2/SymmetricCommands.c @@ -86,6 +86,7 @@ TPM2_EncryptDecrypt( TPMA_OBJECT attributes; // Input Validation symKey = HandleToObject(in->keyHandle); + pAssert_RC(symKey != NULL); mode = symKey->publicArea.parameters.symDetail.sym.mode.sym; attributes = symKey->publicArea.objectAttributes; // The input key should be a symmetric key @@ -258,6 +259,7 @@ TPM2_HMAC( // Input Validation // Get HMAC key object and public area pointers hmacObject = HandleToObject(in->handle); + pAssert_RC(hmacObject != NULL); publicArea = &hmacObject->publicArea; // Make sure that the key is an HMAC key if(publicArea->type != TPM_ALG_KEYEDHASH) @@ -318,6 +320,7 @@ TPM2_MAC( // Input Validation // Get MAC key object and public area pointers keyObject = HandleToObject(in->handle); + pAssert_RC(keyObject != NULL); publicArea = &keyObject->publicArea; // If the key is not able to do a MAC, indicate that the handle selects an // object that can't do a MAC diff --git a/src/tpm2/TPMB.h b/src/tpm2/TPMB.h deleted file mode 100644 index 28ac3f812..000000000 --- a/src/tpm2/TPMB.h +++ /dev/null @@ -1,106 +0,0 @@ -/********************************************************************************/ -/* */ -/* 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 */ -/* */ -/********************************************************************************/ - -// -// This file contains extra TPM2B structures -// - -#ifndef _TPMB_H -#define _TPMB_H - -//*** Size Types -// These types are used to differentiate the two different size values used. -// -// NUMBYTES is used when a size is a number of bytes (usually a TPM2B) -typedef UINT16 NUMBYTES; - -// TPM2B Types -typedef struct -{ - NUMBYTES size; - BYTE buffer[1]; -} TPM2B, *P2B; -typedef const TPM2B* PC2B; - -// This macro helps avoid having to type in the structure in order to create -// a new TPM2B type that is used in a function. -#define TPM2B_TYPE(name, bytes) \ - typedef union \ - { \ - struct \ - { \ - 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. -// This lets the user of the label add their terminating 0. This method -// is chosen so that existing code that provides a label will continue -// to work correctly. - -// Macro to instance and initialize a TPM2B value -#define TPM2B_INIT(TYPE, name) TPM2B_##TYPE name = {sizeof(name.t.buffer), {0}} - -#define TPM2B_BYTE_VALUE(bytes) TPM2B_TYPE(bytes##_BYTE_VALUE, bytes) - -#endif diff --git a/src/tpm2/TPMCmd/Platform/include/Platform.h b/src/tpm2/TPMCmd/Platform/include/Platform.h new file mode 100644 index 000000000..c6d0f11b0 --- /dev/null +++ b/src/tpm2/TPMCmd/Platform/include/Platform.h @@ -0,0 +1,28 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +#ifndef _PLATFORM_H_ +#define _PLATFORM_H_ + +#include +#include +// TODO_RENAME_INC_FOLDER: public refers to the TPM_CoreLib public headers +#include +#include +#include + +#include "PlatformACT.h" +#include "PlatformClock.h" +#include "PlatformData.h" +#include "prototypes/platform_public_interface.h" +// TODO_RENAME_INC_FOLDER:platform_interface refers to the TPM_CoreLib platform interface +#include +#include +#include "PlatformInternal.h" + +#define GLOBAL_C +#define NV_C +#include +#include + +#endif // _PLATFORM_H_ diff --git a/src/tpm2/TPMCmd/Platform/include/PlatformACT.h b/src/tpm2/TPMCmd/Platform/include/PlatformACT.h new file mode 100644 index 000000000..86f1fc3e2 --- /dev/null +++ b/src/tpm2/TPMCmd/Platform/include/PlatformACT.h @@ -0,0 +1,149 @@ +// SPDX-License-Identifier: BSD-2-Clause + +// This file contains the definitions for the ACT macros and data types used in the +// ACT implementation. + +#ifndef _PLATFORM_ACT_H_ +#define _PLATFORM_ACT_H_ + +typedef struct ACT_DATA +{ + uint32_t remaining; + uint32_t newValue; + uint8_t signaled; + uint8_t pending; + uint8_t number; +} ACT_DATA, *P_ACT_DATA; + +#if !(defined RH_ACT_0) || (RH_ACT_0 != YES) +# undef RH_ACT_0 +# define RH_ACT_0 NO +# define IF_ACT_0_IMPLEMENTED(op) +#else +# define IF_ACT_0_IMPLEMENTED(op) op(0) +#endif +#if !(defined RH_ACT_1) || (RH_ACT_1 != YES) +# undef RH_ACT_1 +# define RH_ACT_1 NO +# define IF_ACT_1_IMPLEMENTED(op) +#else +# define IF_ACT_1_IMPLEMENTED(op) op(1) +#endif +#if !(defined RH_ACT_2) || (RH_ACT_2 != YES) +# undef RH_ACT_2 +# define RH_ACT_2 NO +# define IF_ACT_2_IMPLEMENTED(op) +#else +# define IF_ACT_2_IMPLEMENTED(op) op(2) +#endif +#if !(defined RH_ACT_3) || (RH_ACT_3 != YES) +# undef RH_ACT_3 +# define RH_ACT_3 NO +# define IF_ACT_3_IMPLEMENTED(op) +#else +# define IF_ACT_3_IMPLEMENTED(op) op(3) +#endif +#if !(defined RH_ACT_4) || (RH_ACT_4 != YES) +# undef RH_ACT_4 +# define RH_ACT_4 NO +# define IF_ACT_4_IMPLEMENTED(op) +#else +# define IF_ACT_4_IMPLEMENTED(op) op(4) +#endif +#if !(defined RH_ACT_5) || (RH_ACT_5 != YES) +# undef RH_ACT_5 +# define RH_ACT_5 NO +# define IF_ACT_5_IMPLEMENTED(op) +#else +# define IF_ACT_5_IMPLEMENTED(op) op(5) +#endif +#if !(defined RH_ACT_6) || (RH_ACT_6 != YES) +# undef RH_ACT_6 +# define RH_ACT_6 NO +# define IF_ACT_6_IMPLEMENTED(op) +#else +# define IF_ACT_6_IMPLEMENTED(op) op(6) +#endif +#if !(defined RH_ACT_7) || (RH_ACT_7 != YES) +# undef RH_ACT_7 +# define RH_ACT_7 NO +# define IF_ACT_7_IMPLEMENTED(op) +#else +# define IF_ACT_7_IMPLEMENTED(op) op(7) +#endif +#if !(defined RH_ACT_8) || (RH_ACT_8 != YES) +# undef RH_ACT_8 +# define RH_ACT_8 NO +# define IF_ACT_8_IMPLEMENTED(op) +#else +# define IF_ACT_8_IMPLEMENTED(op) op(8) +#endif +#if !(defined RH_ACT_9) || (RH_ACT_9 != YES) +# undef RH_ACT_9 +# define RH_ACT_9 NO +# define IF_ACT_9_IMPLEMENTED(op) +#else +# define IF_ACT_9_IMPLEMENTED(op) op(9) +#endif +#if !(defined RH_ACT_A) || (RH_ACT_A != YES) +# undef RH_ACT_A +# define RH_ACT_A NO +# define IF_ACT_A_IMPLEMENTED(op) +#else +# define IF_ACT_A_IMPLEMENTED(op) op(A) +#endif +#if !(defined RH_ACT_B) || (RH_ACT_B != YES) +# undef RH_ACT_B +# define RH_ACT_B NO +# define IF_ACT_B_IMPLEMENTED(op) +#else +# define IF_ACT_B_IMPLEMENTED(op) op(B) +#endif +#if !(defined RH_ACT_C) || (RH_ACT_C != YES) +# undef RH_ACT_C +# define RH_ACT_C NO +# define IF_ACT_C_IMPLEMENTED(op) +#else +# define IF_ACT_C_IMPLEMENTED(op) op(C) +#endif +#if !(defined RH_ACT_D) || (RH_ACT_D != YES) +# undef RH_ACT_D +# define RH_ACT_D NO +# define IF_ACT_D_IMPLEMENTED(op) +#else +# define IF_ACT_D_IMPLEMENTED(op) op(D) +#endif +#if !(defined RH_ACT_E) || (RH_ACT_E != YES) +# undef RH_ACT_E +# define RH_ACT_E NO +# define IF_ACT_E_IMPLEMENTED(op) +#else +# define IF_ACT_E_IMPLEMENTED(op) op(E) +#endif +#if !(defined RH_ACT_F) || (RH_ACT_F != YES) +# undef RH_ACT_F +# define RH_ACT_F NO +# define IF_ACT_F_IMPLEMENTED(op) +#else +# 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) + +#endif // _PLATFORM_ACT_H_ diff --git a/src/tpm2/TPMCmd/Platform/include/PlatformClock.h b/src/tpm2/TPMCmd/Platform/include/PlatformClock.h new file mode 100644 index 000000000..075a572b4 --- /dev/null +++ b/src/tpm2/TPMCmd/Platform/include/PlatformClock.h @@ -0,0 +1,18 @@ +// 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. + +#ifndef _PLATFORM_CLOCK_H_ +#define _PLATFORM_CLOCK_H_ + +#ifndef _ARM_ +# ifdef _MSC_VER +# include +# include +# else +# include +# endif +#endif + +#endif // _PLATFORM_CLOCK_H_ diff --git a/src/tpm2/TPMCmd/Platform/include/PlatformData.h b/src/tpm2/TPMCmd/Platform/include/PlatformData.h new file mode 100644 index 000000000..7990f420b --- /dev/null +++ b/src/tpm2/TPMCmd/Platform/include/PlatformData.h @@ -0,0 +1,103 @@ +// 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. + +#ifndef _PLATFORM_DATA_H_ +#define _PLATFORM_DATA_H_ + +#ifdef _PLATFORM_DATA_C_ +// instantiate the data below. +# undef EXTERN +# define EXTERN +#else +# ifndef EXTERN +# define EXTERN extern +# endif // EXTERN +#endif // _PLATFORM_DATA_C_ + +// From Cancel.c +// Cancel flag. It is initialized as FALSE, which indicate the command is not +// being canceled +EXTERN int s_isCanceled; + +#ifndef HARDWARE_CLOCK +typedef uint64_t clock64_t; +// This is the value returned the last time that the system clock was read. This +// is only relevant for a simulator or virtual TPM. +EXTERN clock64_t s_realTimePrevious; + +// These values are used to try to synthesize a long lived version of clock(). +EXTERN clock64_t s_lastSystemTime; +EXTERN clock64_t s_lastReportedTime; + +// This is the rate adjusted value that is the equivalent of what would be read from +// a hardware register that produced rate adjusted time. +EXTERN clock64_t s_tpmTime; +/* libtpms added begin */ +EXTERN int64_t s_hostMonotonicAdjustTime; +EXTERN uint64_t s_suspendedElapsedTime; +/* libtpms added end */ +#endif // HARDWARE_CLOCK + +// This value indicates that the timer was reset +EXTERN int s_timerReset; +// This value indicates that the timer was stopped. It causes a clock discontinuity. +EXTERN int s_timerStopped; + +// This variable records the time when _plat__TimerReset is called. This mechanism +// allow us to subtract the time when TPM is power off from the total +// time reported by clock() function +EXTERN uint64_t s_initClock; + +// This variable records the timer adjustment factor. +EXTERN unsigned int s_adjustRate; + +// For LocalityPlat.c +// Locality of current command +EXTERN unsigned char s_locality; + +// For NVMem.c +// Choose if the NV memory should be backed by RAM or by file. +// 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)) +# 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)) +# 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 +#else +#error Do not define SIMULATION for libtpms! +#endif // SIMULATION + +EXTERN unsigned char s_NV[NV_MEMORY_SIZE]; +EXTERN int s_NvIsAvailable; +EXTERN int s_NV_unrecoverable; +EXTERN int s_NV_recoverable; + +// For PPPlat.c +// Physical presence. It is initialized to FALSE +EXTERN int s_physicalPresence; + +// From Power +EXTERN int s_powerLost; + +// For Entropy.c +EXTERN uint32_t lastEntropy; + +#define DEFINE_ACT(N) EXTERN ACT_DATA ACT_##N; +FOR_EACH_ACT(DEFINE_ACT) + +EXTERN int actTicksAllowed; + +#endif // _PLATFORM_DATA_H_ diff --git a/src/tpm2/TPMCmd/Platform/include/PlatformInternal.h b/src/tpm2/TPMCmd/Platform/include/PlatformInternal.h new file mode 100644 index 000000000..c3503eff5 --- /dev/null +++ b/src/tpm2/TPMCmd/Platform/include/PlatformInternal.h @@ -0,0 +1,11 @@ +// SPDX-License-Identifier: BSD-2-Clause + +// Private platform internal functions + +#if ALLOW_FORCE_FAILURE_MODE +// From Failure.c +// allow simulator to force the TPM into failure mode. +BOOL _plat_internal_IsForceFailureMode(); +#endif + +void _plat_internal_resetFailureData(void); diff --git a/src/tpm2/platform_public_interface.h b/src/tpm2/TPMCmd/Platform/include/prototypes/platform_public_interface.h similarity index 60% rename from src/tpm2/platform_public_interface.h rename to src/tpm2/TPMCmd/Platform/include/prototypes/platform_public_interface.h index 94fc5d443..818ead952 100644 --- a/src/tpm2/platform_public_interface.h +++ b/src/tpm2/TPMCmd/Platform/include/prototypes/platform_public_interface.h @@ -1,62 +1,4 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2023 */ -/* */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause // This file contains the interface into the platform layer from external callers. @@ -68,8 +10,13 @@ #include -//** 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); diff --git a/src/tpm2/TPMCmd/Platform/src/Cancel.c b/src/tpm2/TPMCmd/Platform/src/Cancel.c new file mode 100644 index 000000000..005a6e59b --- /dev/null +++ b/src/tpm2/TPMCmd/Platform/src/Cancel.c @@ -0,0 +1,38 @@ +// SPDX-License-Identifier: BSD-2-Clause + +//** Description +// +// This module simulates the cancel pins on the TPM. +// +//** Includes, Typedefs, Structures, and Defines +#include "Platform.h" + +//** Functions + +//***_plat__IsCanceled() +// Check if the cancel flag is set +// Return Type: int +// TRUE(1) if cancel flag is set +// FALSE(0) if cancel flag is not set +LIB_EXPORT int _plat__IsCanceled(void) +{ + // return cancel flag + return s_isCanceled; +} + +//***_plat__SetCancel() + +// Set cancel flag. +LIB_EXPORT void _plat__SetCancel(void) +{ + s_isCanceled = TRUE; + return; +} + +//***_plat__ClearCancel() +// Clear cancel flag +LIB_EXPORT void _plat__ClearCancel(void) +{ + s_isCanceled = FALSE; + return; +} diff --git a/src/tpm2/Clock.c b/src/tpm2/TPMCmd/Platform/src/Clock.c similarity index 76% rename from src/tpm2/Clock.c rename to src/tpm2/TPMCmd/Platform/src/Clock.c index 734922873..ec7c2b075 100644 --- a/src/tpm2/Clock.c +++ b/src/tpm2/TPMCmd/Platform/src/Clock.c @@ -1,62 +1,4 @@ -/********************************************************************************/ -/* */ -/* Used by the simulator to mimic a hardware clock */ -/* 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 //** Description // @@ -340,9 +282,12 @@ LIB_EXPORT void _plat__ClockRateAdjust(_plat__ClockAdjustStep adjust) } if(s_adjustRate > (CLOCK_NOMINAL + CLOCK_ADJUST_LIMIT)) + { s_adjustRate = CLOCK_NOMINAL + CLOCK_ADJUST_LIMIT; + } + if(s_adjustRate < (CLOCK_NOMINAL - CLOCK_ADJUST_LIMIT)) + { s_adjustRate = CLOCK_NOMINAL - CLOCK_ADJUST_LIMIT; - - return; + } } diff --git a/src/tpm2/TPMCmd/Platform/src/DebugHelpers.c b/src/tpm2/TPMCmd/Platform/src/DebugHelpers.c new file mode 100644 index 000000000..1d2e2a08b --- /dev/null +++ b/src/tpm2/TPMCmd/Platform/src/DebugHelpers.c @@ -0,0 +1,125 @@ +// SPDX-License-Identifier: BSD-2-Clause + +//** Description +// +// This file contains the NV read and write access methods. This implementation +// uses RAM/file and does not manage the RAM/file as NV blocks. +// The implementation may become more sophisticated over time. +// + +//** Includes and Local +#include +#include +#include +#include "Platform.h" + +#if CERTIFYX509_DEBUG + +const char* debugFileName = "DebugFile.txt"; + +//*** fileOpen() +// 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; +# if defined _MSC_VER + if(fopen_s(&f, fn, mode) != 0) + f = NULL; +# else + f = fopen(fn, mode); +# endif + return f; +} + +//*** DebugFileInit() +// This function initializes the file containing the debug data with the time of the +// file creation. +// Return Type: int +// 0 success +// != 0 error +int DebugFileInit(void) +{ + FILE* f = NULL; + time_t t = time(NULL); +// +// Get current date and time. +# if defined _MSC_VER + char timeString[100]; + ctime_s(timeString, (size_t)sizeof(timeString), &t); +# else + char* timeString; + timeString = ctime(&t); +# endif + // Try to open the debug file + f = fileOpen(debugFileName, "w"); + if(f) + { + // Initialize the contents with the time. + fprintf(f, "%s\n", timeString); + fclose(f); + return 0; + } + return -1; +} + +//*** DebugDumpBuffer() +void DebugDumpBuffer(int size, unsigned char* buf, const char* identifier) +{ + int i; + // + FILE* f = fileOpen(debugFileName, "a"); + if(!f) + return; + if(identifier) + fprintf(f, "%s\n", identifier); + if(buf) + { + for(i = 0; i < size; i++) + { + if(((i % 16) == 0) && (i)) + fprintf(f, "\n"); + fprintf(f, " %02X", buf[i]); + } + if((size % 16) != 0) + fprintf(f, "\n"); + } + fclose(f); +} + +#endif // CERTIFYX509_DEBUG + +#if ENABLE_TPM_DEBUG_PRINT + +LIB_EXPORT void _plat_debug_print(const char* str) +{ + printf("%s\n", str); +} + +LIB_EXPORT void _plat_debug_print_buffer(const void* buf, const size_t size) +{ + NOT_REFERENCED(buf); + NOT_REFERENCED(size); + // not implemented +} + +LIB_EXPORT void _plat_debug_print_int32(const char* name, uint32_t value) +{ + printf("%s=0x%04x\n", name, value); +} + +LIB_EXPORT void _plat_debug_print_int64(const char* name, uint64_t value) +{ + printf("%s=0x%04x:%04x\n", + name, + (uint32_t)(value >> 32), + (uint32_t)(value & 0xFFFFFFFF)); +} + +LIB_EXPORT void _plat_debug_printf(const char* fmt, ...) +{ + va_list params; + va_start(params, fmt); + vprintf(fmt, params); +} + +#endif // ENABLE_TPM_DEBUG_PRINT diff --git a/src/tpm2/Entropy.c b/src/tpm2/TPMCmd/Platform/src/Entropy.c similarity index 57% rename from src/tpm2/Entropy.c rename to src/tpm2/TPMCmd/Platform/src/Entropy.c index 7a0c4b122..01e8fb5ea 100644 --- a/src/tpm2/Entropy.c +++ b/src/tpm2/TPMCmd/Platform/src/Entropy.c @@ -1,63 +1,4 @@ -/********************************************************************************/ -/* */ -/* Entropy */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: Entropy.c 1661 2021-03-18 19:00:58Z 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 //** Includes and Local Values diff --git a/src/tpm2/TPMCmd/Platform/src/ExtraData.c b/src/tpm2/TPMCmd/Platform/src/ExtraData.c new file mode 100644 index 000000000..80f3d87da --- /dev/null +++ b/src/tpm2/TPMCmd/Platform/src/ExtraData.c @@ -0,0 +1,32 @@ +// SPDX-License-Identifier: BSD-2-Clause + +//** Description +// +// This file contains routines that are called by the core library to allow the +// platform to use the Core storage structures for small amounts of related data. +// +// In this implementation, the buffers are all just set to 0xFF + +//** Includes and Data Definitions +#include +#include +#include +#include "Platform.h" + +//** _plat__GetPlatformManufactureData + +// This function allows the platform to provide a small amount of data to be +// stored as part of the TPM's PERSISTENT_DATA structure during manufacture. Of +// course the platform can store data separately as well, but this allows a +// simple platform implementation to store a few bytes of data without +// implementing a multi-layer storage system. This function is called on +// manufacture and CLEAR. The buffer will contain the last value provided +// to the Core library. +LIB_EXPORT void _plat__GetPlatformManufactureData(uint8_t* pPlatformPersistentData, + uint32_t bufferSize) +{ + if(bufferSize != 0) + { + memset((void*)pPlatformPersistentData, 0xFF, bufferSize); + } +} diff --git a/src/tpm2/TPMCmd/Platform/src/Failure.c b/src/tpm2/TPMCmd/Platform/src/Failure.c new file mode 100644 index 000000000..78e62c594 --- /dev/null +++ b/src/tpm2/TPMCmd/Platform/src/Failure.c @@ -0,0 +1,156 @@ +// SPDX-License-Identifier: BSD-2-Clause + +//** Includes and locals +#include "Platform.h" +#include +#include +#include + +#if LONGJMP_SUPPORTED +// in RunCommand.c +extern jmp_buf s_FailureModeJumpBuffer; +#endif + +#if ALLOW_FORCE_FAILURE_MODE +static BOOL s_forceFailureMode; // flag to force failure mode during test +BOOL _plat_internal_IsForceFailureMode() +{ + return s_forceFailureMode; +} +LIB_EXPORT void _plat__SetForceFailureMode() +{ + s_forceFailureMode = TRUE; +} +#endif + +#if FAIL_TRACE +// The name of the function that triggered failure mode. +static const char* s_failFunctionName; +// The line in the file at which the error was signaled. +static uint32_t s_failLine; +#endif // FAIL_TRACE + +// A numeric indicator of the location that triggered failure mode. +static uint64_t s_failureLocation; +// the reason for the failure. +static uint32_t s_failCode; +static BOOL s_IsInFailureMode = FALSE; + +void _plat_internal_resetFailureData() +{ +#if ALLOW_FORCE_FAILURE_MODE + s_forceFailureMode = FALSE; +#endif + +#if FAIL_TRACE + // The name of the function that triggered failure mode. + s_failFunctionName = NULL; + // The line in the file at which the error was signaled. + s_failLine = 0; +#endif // FAIL_TRACE + + // A numeric indicator of the location that triggered failure mode. + s_failureLocation = 0; + // the reason for the failure. + s_failCode = 0; + s_IsInFailureMode = FALSE; +} + +// Indicates to the TPM Library that a failure has occurred. +// This is REQURIED to return true after any call to _plat__Fail. +// It MAY return true for any other reason the platform deems appropriate. +LIB_EXPORT BOOL _plat__InFailureMode() +{ + return s_IsInFailureMode; +} + +LIB_EXPORT void _plat__SetInFailureMode(BOOL inFailureMode) // libtpms added begin +{ + s_IsInFailureMode = inFailureMode; +} + +LIB_EXPORT void _plat__SetFailureModeParameters( +#if FAIL_TRACE + const char* function, + int line, +#endif + int failureCode) +{ + s_failCode = failureCode; + s_failureLocation = 0; +#if FAIL_TRACE + s_failFunctionName = function; + s_failLine = line; +#endif +} // libtpms added end + +//***_plat__Fail() +// A function for the TPM to call the platform to indicate the +// TPM code has detected a failure. +LIB_EXPORT NORETURN_IF_LONGJMP void _plat__Fail( +#if FAIL_TRACE + const char* function, + int line, +#endif + uint64_t locationCode, + int failureCode) +{ +#if ALLOW_FORCE_FAILURE_MODE + // The simulator asserts during unexpected (i.e. un-forced) failure mode + // to allow debugging. + if(!_plat_internal_IsForceFailureMode()) + { + fprintf(stderr, "Unexpected failure mode (code %d) in ", s_failCode); + uint32_t failureLocation_low = (uint32_t)(_plat__GetFailureLocation()); + uint32_t failureLocation_hi = (uint32_t)(_plat__GetFailureLocation() >> 32); + fprintf( + stderr, "Location: %08x:%08x", failureLocation_hi, failureLocation_low); + +# if FAIL_TRACE + fprintf(stderr, "function '%s' (line %d)\n", s_failFunctionName, s_failLine); +# endif // FAIL_TRACE + assert(FALSE); + } +#endif + + // don't update if we are already in failure mode. + if(!_plat__InFailureMode()) + { + s_IsInFailureMode = TRUE; + s_failCode = failureCode; + s_failureLocation = locationCode; +#if FAIL_TRACE + s_failFunctionName = function; + s_failLine = line; +#endif +#if ALLOW_FORCE_FAILURE_MODE + s_forceFailureMode = FALSE; +#endif + } + +#if LONGJMP_SUPPORTED + longjmp(&s_FailureModeJumpBuffer[0], 1); +#endif +} + +LIB_EXPORT UINT32 _plat__GetFailureCode() +{ + return s_failCode; +} + +LIB_EXPORT uint64_t _plat__GetFailureLocation() +{ + return s_failureLocation; +} + +#if FAIL_TRACE +LIB_EXPORT const char* _plat__GetFailureFunctionName() +{ + return s_failFunctionName; +} + +LIB_EXPORT uint32_t _plat__GetFailureLine() +{ + return s_failLine; +} +#endif diff --git a/src/tpm2/TPMCmd/Platform/src/Init.c b/src/tpm2/TPMCmd/Platform/src/Init.c new file mode 100644 index 000000000..9fd6dd1bf --- /dev/null +++ b/src/tpm2/TPMCmd/Platform/src/Init.c @@ -0,0 +1,17 @@ +// SPDX-License-Identifier: BSD-2-Clause + +#include "Platform.h" + +// Notification at very start of TPM_Init(); +LIB_EXPORT void _plat__StartTpmInit(void) +{ + // call platform reset functions, that have no TPM dependencies + // needs the failure change + // _plat_internal_resetFailureData(); +} + +LIB_EXPORT void _plat__EndOkTpmInit(void) +{ + // call platform reset functions that depend on previous TPM initialization + // (none in this implementation) +} diff --git a/src/tpm2/TPMCmd/Platform/src/LocalityPlat.c b/src/tpm2/TPMCmd/Platform/src/LocalityPlat.c new file mode 100644 index 000000000..e6fc14a72 --- /dev/null +++ b/src/tpm2/TPMCmd/Platform/src/LocalityPlat.c @@ -0,0 +1,25 @@ +// SPDX-License-Identifier: BSD-2-Clause + +//** Includes +#include "Platform.h" + +//** Functions + +//***_plat__LocalityGet() +// Get the most recent command locality in locality value form. +// This is an integer value for locality and not a locality structure +// The locality can be 0-4 or 32-255. 5-31 is not allowed. +LIB_EXPORT unsigned char _plat__LocalityGet(void) +{ + return s_locality; +} + +//***_plat__LocalitySet() +// Set the most recent command locality in locality value form +LIB_EXPORT void _plat__LocalitySet(unsigned char locality) +{ + if(locality > 4 && locality < 32) + locality = 0; + s_locality = locality; + return; +} diff --git a/src/tpm2/NVMem.c b/src/tpm2/TPMCmd/Platform/src/NVMem.c similarity index 80% rename from src/tpm2/NVMem.c rename to src/tpm2/TPMCmd/Platform/src/NVMem.c index 20362f5f1..94e909ca3 100644 --- a/src/tpm2/NVMem.c +++ b/src/tpm2/TPMCmd/Platform/src/NVMem.c @@ -1,62 +1,4 @@ -/********************************************************************************/ -/* */ -/* NV read and write access methods */ -/* 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 - 2024 */ -/* */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause //** Description // @@ -151,7 +93,7 @@ static long NvFileSize(int leaveAt) { case SEEK_SET: filePos = 0; - /* fall through */ + /* fall through */ case SEEK_CUR: assert(fseek(s_NvFile, filePos, SEEK_SET) == 0); // libtpms: added assert break; @@ -276,7 +218,7 @@ _plat__NVEnable_NVChipFile( } //***_plat__NVDisable() -// Disable NV memory +// Disable NV memory, and potentially delete it. LIB_EXPORT void _plat__NVDisable( void* platParameter, // platform specific parameter size_t paramSize // size of parameter. If size == 0, then @@ -285,9 +227,8 @@ LIB_EXPORT void _plat__NVDisable( ) { NOT_REFERENCED(paramSize); // to keep compiler quiet - int delete = ((intptr_t)platParameter != 0) - ? TRUE - : FALSE; // IN: If TRUE (!=0), delete the NV contents. + // IN: If TRUE (!=0), delete the NV contents. + int delete = ((intptr_t)platParameter != 0) ? TRUE : FALSE; #ifdef TPM_LIBTPMS_CALLBACKS int ret = libtpms_plat__NVDisable(); diff --git a/src/tpm2/TPMCmd/Platform/src/NVVirtual.c b/src/tpm2/TPMCmd/Platform/src/NVVirtual.c new file mode 100644 index 000000000..83fc47b36 --- /dev/null +++ b/src/tpm2/TPMCmd/Platform/src/NVVirtual.c @@ -0,0 +1,70 @@ +// SPDX-License-Identifier: BSD-2-Clause + +#include "Platform.h" +#include +#include +#include + +// NV Index handles for EKICA and EK Certificates. +#define RSA_2048_EK_CERT_HANDLE (0x01c00002) +#define ECC_P256_EK_CERT_HANDLE (0x01c0000a) +#define ECC_EK_ICA_HANDLE (0x01c00100) + +LIB_EXPORT TPM_RC _plat__NvVirtual_PopulateNvIndexInfo( + TPM_HANDLE handle, // IN: handle for the index + TPMS_NV_PUBLIC* publicArea, // INOUT: The public area structure to be modified. + TPM2B_AUTH* authValue // INOUT: The auth value structure to be modified. +) +{ + NOT_REFERENCED(handle); + NOT_REFERENCED(publicArea); + NOT_REFERENCED(authValue); + return TPM_RC_NO_RESULT; +} + +LIB_EXPORT TPM_RC _plat__NvVirtual_Read( + NV_Read_In* in, // IN: input parameter list + NV_Read_Out* out // OUT: output parameter list +) +{ + NOT_REFERENCED(in); + NOT_REFERENCED(out); + return TPM_RC_NO_RESULT; +} + +LIB_EXPORT TPM_RC _plat__NvVirtual_ReadPublic( + NV_ReadPublic_In* in, // IN: input parameter list + NV_ReadPublic_Out* out // OUT: output parameter list +) +{ + NOT_REFERENCED(in); + NOT_REFERENCED(out); + return TPM_RC_NO_RESULT; +} + +LIB_EXPORT TPMI_YES_NO _plat__NvVirtual_CapGetIndex( + TPMI_DH_OBJECT handle, // IN: start handle + UINT32 count, // IN: max number of returned handles + TPML_HANDLE* handleList // OUT: list of handle +) +{ + NOT_REFERENCED(handle); + NOT_REFERENCED(count); + NOT_REFERENCED(handleList); + return NO; +} + +LIB_EXPORT BOOL _plat__NvOperationAcceptsVirtualHandles(TPM_CC commandCode) +{ + NOT_REFERENCED(commandCode); + return FALSE; +} + +LIB_EXPORT BOOL _plat__IsNvVirtualIndex(TPM_HANDLE handle) +{ + NOT_REFERENCED(handle); + // might be something like this: + // (handle == ECC_P256_EK_CERT_HANDLE || handle == RSA_2048_EK_CERT_HANDLE + // || handle == ECC_EK_ICA_HANDLE); + return FALSE; +} diff --git a/src/tpm2/TPMCmd/Platform/src/PPPlat.c b/src/tpm2/TPMCmd/Platform/src/PPPlat.c new file mode 100644 index 000000000..f547afe35 --- /dev/null +++ b/src/tpm2/TPMCmd/Platform/src/PPPlat.c @@ -0,0 +1,48 @@ +// SPDX-License-Identifier: BSD-2-Clause + +//** Description + +// This module simulates the physical presence interface pins on the TPM. + +//** Includes +#include "Platform.h" +#include "LibtpmsCallbacks.h" /* libtpms added */ + +//** Functions + +//***_plat__PhysicalPresenceAsserted() +// Check if physical presence is signaled +// Return Type: int +// TRUE(1) if physical presence is signaled +// FALSE(0) if physical presence is not signaled +LIB_EXPORT int _plat__PhysicalPresenceAsserted(void) +{ +#ifdef TPM_LIBTPMS_CALLBACKS + BOOL pp; + int ret = libtpms_plat__PhysicalPresenceAsserted(&pp); + + if (ret != LIBTPMS_CALLBACK_FALLTHROUGH) + return pp; +#endif /* TPM_LIBTPMS_CALLBACKS */ + // Do not know how to check physical presence without real hardware. + // so always return TRUE; + return s_physicalPresence; +} + +#if 0 /* libtpms added */ +//***_plat__Signal_PhysicalPresenceOn() +// Signal physical presence on +LIB_EXPORT void _plat__Signal_PhysicalPresenceOn(void) +{ + s_physicalPresence = TRUE; + return; +} + +//***_plat__Signal_PhysicalPresenceOff() +// Signal physical presence off +LIB_EXPORT void _plat__Signal_PhysicalPresenceOff(void) +{ + s_physicalPresence = FALSE; + return; +} +#endif /* libtpms added */ diff --git a/src/tpm2/PlatformACT.c b/src/tpm2/TPMCmd/Platform/src/PlatformACT.c similarity index 70% rename from src/tpm2/PlatformACT.c rename to src/tpm2/TPMCmd/Platform/src/PlatformACT.c index dde2026fc..32223098e 100644 --- a/src/tpm2/PlatformACT.c +++ b/src/tpm2/TPMCmd/Platform/src/PlatformACT.c @@ -1,63 +1,4 @@ -/********************************************************************************/ -/* */ -/* Platform Authenticated Countdown Timer */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: PlatformACT.c 1594 2020-03-26 22:15:48Z 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 - 2020 */ -/* */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause //** Includes #include "Platform.h" diff --git a/src/tpm2/TPMCmd/Platform/src/PlatformData.c b/src/tpm2/TPMCmd/Platform/src/PlatformData.c new file mode 100644 index 000000000..68c0f03a3 --- /dev/null +++ b/src/tpm2/TPMCmd/Platform/src/PlatformData.c @@ -0,0 +1,9 @@ +// SPDX-License-Identifier: BSD-2-Clause + +//** Description +// This file will instance the TPM variables that are not stack allocated. The +// descriptions for these variables are in Global.h for this project. + +//** Includes +#define _PLATFORM_DATA_C_ +#include "Platform.h" diff --git a/src/tpm2/PlatformPcr.c b/src/tpm2/TPMCmd/Platform/src/PlatformPcr.c similarity index 64% rename from src/tpm2/PlatformPcr.c rename to src/tpm2/TPMCmd/Platform/src/PlatformPcr.c index 9c52b4b7b..670425444 100644 --- a/src/tpm2/PlatformPcr.c +++ b/src/tpm2/TPMCmd/Platform/src/PlatformPcr.c @@ -1,67 +1,9 @@ -/********************************************************************************/ -/* */ -/* */ -/* 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 // PCR platform interface functions #include "Platform.h" -#include "TpmAlgorithmDefines.h" +#include // use this as a convenient lookup for hash size for PCRs. UINT16 CryptHashGetDigestSize(TPM_ALG_ID hashAlg // IN: hash algorithm to look up @@ -169,7 +111,7 @@ PCR_Attributes _platPcr__GetPcrInitializationAttributes(UINT32 pcrNumber) BOOL _platPcr_IsPcrBankDefaultActive(TPM_ALG_ID pcrAlg) { // brute force search is fast enough for a small array. - for(size_t i = 0; i < ARRAYSIZE(DefaultActivePcrBanks); i++) // libtpms changed + for(size_t i = 0; i < ARRAYSIZE(DefaultActivePcrBanks); i++) { if(DefaultActivePcrBanks[i] == pcrAlg) { diff --git a/src/tpm2/TPMCmd/Platform/src/PowerPlat.c b/src/tpm2/TPMCmd/Platform/src/PowerPlat.c new file mode 100644 index 000000000..088343ece --- /dev/null +++ b/src/tpm2/TPMCmd/Platform/src/PowerPlat.c @@ -0,0 +1,72 @@ +// SPDX-License-Identifier: BSD-2-Clause + +//** Includes and Function Prototypes + +#include "Platform.h" + +//** Functions + +//***_plat__Signal_PowerOn() +// Signal platform power on +LIB_EXPORT int _plat__Signal_PowerOn(void) +{ + // Reset the timer + _plat__TimerReset(); + + // Need to indicate that we lost power + s_powerLost = TRUE; + + return 0; +} + +//*** _plat__WasPowerLost() +// Test whether power was lost before a _TPM_Init. +// +// This function will clear the "hardware" indication of power loss before return. +// This means that there can only be one spot in the TPM code where this value +// gets read. This method is used here as it is the most difficult to manage in the +// TPM code and, if the hardware actually works this way, it is hard to make it +// look like anything else. So, the burden is placed on the TPM code rather than the +// platform code +// Return Type: int +// TRUE(1) power was lost +// FALSE(0) power was not lost +LIB_EXPORT int _plat__WasPowerLost(void) +{ + int retVal = s_powerLost; + s_powerLost = FALSE; + return retVal; +} + +//*** _plat_Signal_Reset() +// This a TPM reset without a power loss. +LIB_EXPORT int _plat__Signal_Reset(void) +{ + // Initialize locality + s_locality = 0; + + // Command cancel + s_isCanceled = FALSE; + + _TPM_Init(); + + // if we are doing reset but did not have a power failure, then we should + // not need to reload NV ... + + return 0; +} + +//***_plat__Signal_PowerOff() +// Signal platform power off +LIB_EXPORT void _plat__Signal_PowerOff(void) +{ + // Prepare NV memory for power off + _plat__NVDisable((void*)FALSE, 0); + +#if ACT_SUPPORT + // Disable tick ACT tick processing + _plat__ACT_EnableTicks(FALSE); +#endif + + return; +} diff --git a/src/tpm2/TPMCmd/Platform/src/RunCommand.c b/src/tpm2/TPMCmd/Platform/src/RunCommand.c new file mode 100644 index 000000000..560a1ec63 --- /dev/null +++ b/src/tpm2/TPMCmd/Platform/src/RunCommand.c @@ -0,0 +1,55 @@ +// SPDX-License-Identifier: BSD-2-Clause + +//**Introduction +// This module provides the platform specific entry and fail processing. The +// _plat__RunCommand() function is used to call to ExecuteCommand() in the TPM code. +// This function does whatever processing is necessary to set up the platform +// in anticipation of the call to the TPM including settup for error processing. +// +// The _plat__Fail() function is called when there is a failure in the TPM. The TPM +// code will have set the flag to indicate that the TPM is in failure mode. +// This call will then recursively call ExecuteCommand in order to build the +// failure mode response. When ExecuteCommand() returns to _plat__Fail(), the +// platform will do some platform specific operation to return to the environment in +// which the TPM is executing. For a simulator, setjmp/longjmp is used. For an OS, +// a system exit to the OS would be appropriate. + +//** Includes and locals +#include "Platform.h" +#include +#include +#include + +#if LONGJMP_SUPPORTED +jmp_buf s_FailureModeJumpBuffer; +#endif + +//** Functions + +//***_plat__RunCommand() +// This version of RunCommand will set up a jum_buf and call ExecuteCommand(). If +// the command executes without failing, it will return and RunCommand will return. +// If there is a failure in the command, then _plat__Fail() is called and it will +// longjump back to RunCommand which will call ExecuteCommand again. However, this +// time, the TPM will be in failure mode so ExecuteCommand will simply build +// a failure response and return. +LIB_EXPORT void _plat__RunCommand( + uint32_t requestSize, // IN: command buffer size + unsigned char* request, // IN: command buffer + uint32_t* responseSize, // IN/OUT: response buffer size + unsigned char** response // IN/OUT: response buffer +) +{ +#if LONGJMP_SUPPORTED + setjmp(s_FailureModeJumpBuffer); +#endif + +#if ALLOW_FORCE_FAILURE_MODE + if(_plat_internal_IsForceFailureMode()) + { + _plat__Fail(__FUNCTION__, __LINE__, 0xFFFFFFFFFFFFFFFF, FATAL_ERROR_FORCED); + } +#endif + + ExecuteCommand(requestSize, request, responseSize, response); +} diff --git a/src/tpm2/TPMCmd/Platform/src/SelfTest.c b/src/tpm2/TPMCmd/Platform/src/SelfTest.c new file mode 100644 index 000000000..1b47c4402 --- /dev/null +++ b/src/tpm2/TPMCmd/Platform/src/SelfTest.c @@ -0,0 +1,16 @@ +// SPDX-License-Identifier: BSD-2-Clause + +#include "Platform.h" +#include +#include + +LIB_EXPORT void _plat_GetEnabledSelfTest( + uint8_t fullTest, // IN: full test or not + uint8_t* pToTestVector, // INOUT: initialized byte array of tracked tests + size_t toTestVectorSize // IN: size of the byte array in bytes +) +{ + (void)fullTest; + (void)pToTestVector; + (void)toTestVectorSize; +} diff --git a/src/tpm2/TPMCmd/Platform/src/Unique.c b/src/tpm2/TPMCmd/Platform/src/Unique.c new file mode 100644 index 000000000..71871762c --- /dev/null +++ b/src/tpm2/TPMCmd/Platform/src/Unique.c @@ -0,0 +1,50 @@ +// SPDX-License-Identifier: BSD-2-Clause + +//** Introduction +// In some implementations of the TPM, the hardware can provide a secret +// value to the TPM. This secret value is statistically unique to the +// instance of the TPM. Typical uses of this value are to provide +// personalization to the random number generation and as a shared secret +// between the TPM and the manufacturer. + +//** Includes +#include "Platform.h" + +#if VENDOR_PERMANENT_AUTH_ENABLED == YES + +const char notReallyUnique[] = "This is not really a unique value. A real " + "unique value should" + " be generated by the platform."; + +//** _plat__GetUnique() +// This function is used to access the platform-specific vendor unique values. +// This function places the unique value in the provided buffer ('b') +// and returns the number of bytes transferred. The function will not +// copy more data than 'bSize'. +// NOTE: If a platform unique value has unequal distribution of uniqueness +// and 'bSize' is smaller than the size of the unique value, the 'bSize' +// portion with the most uniqueness should be returned. +// +// 'which' indicates the unique value to return: +// 0 = RESERVED, do not use +// 1 = the VENDOR_PERMANENT_AUTH_HANDLE authorization value for this device +LIB_EXPORT uint32_t _plat__GetUnique(uint32_t which, // which vendor value to return? + uint32_t bSize, // size of the buffer + unsigned char* b // output buffer +) +{ + const char* from = notReallyUnique; + uint32_t retVal = 0; + + if(which == 1) + { + const size_t uSize = + sizeof(notReallyUnique) <= bSize ? sizeof(notReallyUnique) : bSize; + MemoryCopy(b, notReallyUnique, uSize); + } + // else fall through to default 0 + + return retVal; +} + +#endif diff --git a/src/tpm2/VendorInfo.c b/src/tpm2/TPMCmd/Platform/src/VendorInfo.c similarity index 57% rename from src/tpm2/VendorInfo.c rename to src/tpm2/TPMCmd/Platform/src/VendorInfo.c index b73722b91..972bfd44c 100644 --- a/src/tpm2/VendorInfo.c +++ b/src/tpm2/TPMCmd/Platform/src/VendorInfo.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 // Provide vendor-specific version and identifiers to core TPM library for @@ -207,7 +149,30 @@ LIB_EXPORT int _plat__GetTpmFirmwareSecret( #endif // FW_LIMITED_SUPPORT // return the TPM Type returned by TPM_PT_VENDOR_TPM_TYPE -LIB_EXPORT uint32_t _plat__GetTpmType() +LIB_EXPORT uint32_t _plat__GetVendorTpmType() { return 1; // just the value the reference code has returned in the past. } + +LIB_EXPORT void _plat_GetSpecCapabilityValue(SPEC_CAPABILITY_VALUE* returnData) +{ + // clang-format off + // this is on the title page of part1 of the TPM spec + returnData->tpmSpecLevel = 0; + // these come from part2 of the TPM spec + returnData->tpmSpecVersion = 183; // libtpms changed + returnData->tpmSpecYear = 2024; // libtpms changed + returnData->tpmSpecDayOfYear = 25; // libtpms changed + // these come from the PC CLient Platform TPM Profile Specification + returnData->platformFamily = 1; + returnData->platfromLevel = 0; + // The platform spec version is recorded such that 0x00000101 means version 1.01 + // Note this differs from some TPM/TCG specifications, but matches the behavior of Windows. + // more recent TCG specs have discontinued using this field, but Windows displays it, so we + // retain it using the historical encoding. + returnData->platformRevision = 0x106; // libtpms changed + returnData->platformYear = 2024; // libtpms changed + returnData->platformDayOfYear = 25; // libtpms changed + // clang-format on + return; +} diff --git a/src/tpm2/TPMCmd/Simulator/include/TpmTcpProtocol.h b/src/tpm2/TPMCmd/Simulator/include/TpmTcpProtocol.h new file mode 100644 index 000000000..6aa499e93 --- /dev/null +++ b/src/tpm2/TPMCmd/Simulator/include/TpmTcpProtocol.h @@ -0,0 +1,115 @@ +// SPDX-License-Identifier: BSD-2-Clause + +//** Introduction + +// TPM commands are communicated as uint8_t streams on a TCP connection. The TPM +// command protocol is enveloped with the interface protocol described in this +// file. The command is indicated by a uint32 with one of the values below. Most +// commands take no parameters return no TPM errors. In these cases the TPM +// interface protocol acknowledges that command processing is completed by returning +// a uint32=0. The command TPM_SIGNAL_HASH_DATA takes a uint32-prepended variable +// length byte array and the interface protocol acknowledges command completion +// with a uint32=0. Most TPM commands are enveloped using the TPM_SEND_COMMAND +// interface command. The parameters are as indicated below. The interface layer +// also appends a UIN32=0 to the TPM response for regularity. + +//** Typedefs and Defines +#ifndef TCP_TPM_PROTOCOL_H +#define TCP_TPM_PROTOCOL_H + +//** TPM Commands. +// All commands acknowledge processing by returning a uint32 == 0 except where noted +#define TPM_SIGNAL_POWER_ON 1 +#define TPM_SIGNAL_POWER_OFF 2 +#define TPM_SIGNAL_PHYS_PRES_ON 3 +#define TPM_SIGNAL_PHYS_PRES_OFF 4 +#define TPM_SIGNAL_HASH_START 5 +#define TPM_SIGNAL_HASH_DATA 6 +// {uint32_t BufferSize, uint8_t[BufferSize] Buffer} +#define TPM_SIGNAL_HASH_END 7 +#define TPM_SEND_COMMAND 8 +// {uint8_t Locality, uint32_t InBufferSize, uint8_t[InBufferSize] InBuffer} -> +// {uint32_t OutBufferSize, uint8_t[OutBufferSize] OutBuffer} + +#define TPM_SIGNAL_CANCEL_ON 9 +#define TPM_SIGNAL_CANCEL_OFF 10 +#define TPM_SIGNAL_NV_ON 11 +#define TPM_SIGNAL_NV_OFF 12 +#define TPM_SIGNAL_KEY_CACHE_ON 13 +#define TPM_SIGNAL_KEY_CACHE_OFF 14 + +#define TPM_REMOTE_HANDSHAKE 15 +#define TPM_SET_ALTERNATIVE_RESULT 16 + +#define TPM_SIGNAL_RESET 17 +#define TPM_SIGNAL_RESTART 18 + +#define TPM_SESSION_END 20 +#define TPM_STOP 21 + +#define TPM_GET_COMMAND_RESPONSE_SIZES 25 + +#define TPM_ACT_GET_SIGNALED 26 + +#define TPM_TEST_FAILURE_MODE 30 + +#define TPM_SET_FW_HASH 35 +#define TPM_SET_FW_SVN 36 + +//** Enumerations and Structures +enum TpmEndPointInfo +{ + tpmPlatformAvailable = 0x01, + tpmUsesTbs = 0x02, + tpmInRawMode = 0x04, + tpmSupportsPP = 0x08, + + // Valid only with PlatformAvailable set. + // System and TPM power control signals (SignalPowerOn/Off) are not supported. + NoPowerCtl = 0x10, + + // Valid only with tpmPlatformAvailable set. + // TPM locality cannot be changed. + NoLocalityCtl = 0x20, + + // Valid only with tpmPlatformAvailable set. + // NV control signals (SignalNvOn/Off) are not supported. + NoNvCtl = 0x40, + + // indicates that no force failure mode is available in the protocol + NoForceFailure = 0x80, + + // indicates Locality 4 Hash indications are not supported + NoHashDataCtl = 0x100 +}; + +#ifdef _MSC_VER +# pragma warning(push, 3) +#endif + +// Existing RPC interface type definitions retained so that the implementation +// can be re-used +typedef struct in_buffer +{ + unsigned long BufferSize; + unsigned char* Buffer; +} _IN_BUFFER; + +typedef unsigned char* _OUTPUT_BUFFER; + +typedef struct out_buffer +{ + uint32_t BufferSize; + _OUTPUT_BUFFER Buffer; +} _OUT_BUFFER; + +#ifdef _MSC_VER +# pragma warning(pop) +#endif + +#ifndef WIN32 +typedef unsigned long DWORD; +typedef void* LPVOID; +#endif + +#endif diff --git a/src/tpm2/Simulator_fp.h b/src/tpm2/TPMCmd/Simulator/include/prototypes/Simulator_fp.h similarity index 64% rename from src/tpm2/Simulator_fp.h rename to src/tpm2/TPMCmd/Simulator/include/prototypes/Simulator_fp.h index f48191589..d76b4c08b 100644 --- a/src/tpm2/Simulator_fp.h +++ b/src/tpm2/TPMCmd/Simulator/include/prototypes/Simulator_fp.h @@ -1,62 +1,4 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2016 - 2023 */ -/* */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause /*(Auto-generated) * Created by TpmPrototypes; Version 3.0 July 18, 2017 @@ -80,7 +22,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 +30,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 +45,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 diff --git a/src/tpm2/TPMCmdp.c b/src/tpm2/TPMCmd/Simulator/src/TPMCmdp.c similarity index 68% rename from src/tpm2/TPMCmdp.c rename to src/tpm2/TPMCmd/Simulator/src/TPMCmdp.c index 83dc6fcc0..32a6a9dd4 100644 --- a/src/tpm2/TPMCmdp.c +++ b/src/tpm2/TPMCmd/Simulator/src/TPMCmdp.c @@ -1,62 +1,4 @@ -/********************************************************************************/ -/* */ -/* Process the commands */ -/* 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 //** Description // This file contains the functions that process the commands received on the @@ -126,7 +68,7 @@ void _rpc__Signal_PowerOff(void) void _rpc__ForceFailureMode(void) { #if SIMULATION - SetForceFailureMode(); + _plat__SetForceFailureMode(); #endif return; } diff --git a/src/tpm2/TPMCmd/Simulator/src/simulatorPrivate.h b/src/tpm2/TPMCmd/Simulator/src/simulatorPrivate.h new file mode 100644 index 000000000..1eded505a --- /dev/null +++ b/src/tpm2/TPMCmd/Simulator/src/simulatorPrivate.h @@ -0,0 +1,23 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// common headers for simulator implementation files + +#ifndef SIMULATOR_PRIVATE_H +#define SIMULATOR_PRIVATE_H + +//** Includes, Locals, Defines and Function Prototypes +#include + +#include "simulator_sysheaders.h" + +// TODO_RENAME_INC_FOLDER:prototypes refers to the platform library +#include +// TODO_RENAME_INC_FOLDER:platform_interface refers to the TPM_CoreLib platform interface +#include +#include + +#include "TpmTcpProtocol.h" +#include "Simulator_fp.h" + +#endif // SIMULATOR_PRIVATE_H diff --git a/src/tpm2/TPMCmd/Simulator/src/simulator_sysheaders.h b/src/tpm2/TPMCmd/Simulator/src/simulator_sysheaders.h new file mode 100644 index 000000000..0d9e45993 --- /dev/null +++ b/src/tpm2/TPMCmd/Simulator/src/simulator_sysheaders.h @@ -0,0 +1,48 @@ +// SPDX-License-Identifier: BSD-2-Clause + +// system headers for the simulator, both Windows and Linux + +#ifndef _SIMULATOR_SYSHEADERS_H_ +#define _SIMULATOR_SYSHEADERS_H_ +// include the system headers silencing warnings that occur with /Wall +#include +#include +#include +#include +#include +#include + +#ifdef _MSC_VER +# pragma warning(push, 3) +// C4668 is supposed to be level 4, but this is still necessary to suppress the +// error. We don't want to suppress it globally because the same error can +// happen in the TPM code and it shouldn't be ignored in those cases because it +// generally means a configuration header is missing. +// +// X is not defined as a preprocessor macro, assuming 0 for #if +# pragma warning(disable : 4668) +# include +# include +# pragma warning(pop) +typedef int socklen_t; +#elif defined(__unix__) || defined(__APPLE__) +# include +# include +# include +# include +# include +# include +// simulate certain windows APIs +# define ZeroMemory(ptr, sz) (memset((ptr), 0, (sz))) +# define closesocket(x) close(x) +# define INVALID_SOCKET (-1) +# define SOCKET_ERROR (-1) +# define WSAGetLastError() (errno) +# define WSAEADDRINUSE EADDRINUSE +# define INT_PTR intptr_t +typedef int SOCKET; +# define _strcmpi strcasecmp +#else +# error "Unsupported platform." +#endif // _MSC_VER +#endif // _SIMULATOR_SYSHEADERS_H_ diff --git a/src/tpm2/TpmBuildSwitches.h b/src/tpm2/TPMCmd/TpmConfiguration/TpmConfiguration/TpmBuildSwitches.h similarity index 63% rename from src/tpm2/TpmBuildSwitches.h rename to src/tpm2/TPMCmd/TpmConfiguration/TpmConfiguration/TpmBuildSwitches.h index 033383fe7..e7ca46708 100644 --- a/src/tpm2/TpmBuildSwitches.h +++ b/src/tpm2/TPMCmd/TpmConfiguration/TpmConfiguration/TpmBuildSwitches.h @@ -1,62 +1,5 @@ -/********************************************************************************/ -/* */ -/* Build Switches */ -/* 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 the build switches. This contains switches for multiple // versions of the crypto-library so some may not apply to your environment. @@ -110,6 +53,17 @@ // ones in the Simulator project. #define SIMULATION NO // libtpms: changed to NO +// ENABLE_TPM_DEBUG_PRINT enables arbitrary string printing. +// enables the TPM_DEBUG_PRINT macro to route debugging strings +// to the _plat_debug_out function +#define ENABLE_TPM_DEBUG_PRINT (YES * SIMULATION) + +// ENABLE_TPM_DEBUG_TRACE enables code tracing macros - depends on TPM_DEBUG_PRINT +#define ENABLE_TPM_DEBUG_TRACE (NO * ENABLE_TPM_DEBUG_PRINT) + +// ENABLE_CRYPTO_DEBUG enables printing of actual crypto values. This is entirely insecure. +#define ENABLE_CRYPTO_DEBUG (YES * ENABLE_TPM_DEBUG_PRINT) + // The CRYPTO_LIB_REPORTING switch allows the TPM to report its // crypto library implementation, e.g., at simulation startup. #define CRYPTO_LIB_REPORTING NO // libtpms: NO @@ -147,9 +101,9 @@ //////////////////////////////////////////////////////////////// // The SIMULATION flag can enable test crypto behaviors and caching that // significantly change the behavior of the code. This flag controls only the -// g_forceFailureMode flag in the TPM library while leaving the rest of the TPM -// behavior alone. Useful for testing when the full set of options controlled by -// SIMULATION may not be desired. +// ability of the platform library to force failure mode while leaving the rest +// of the TPM behavior alone. Useful for testing when the full set of options +// controlled by SIMULATION may not be desired. #define ALLOW_FORCE_FAILURE_MODE NO // libtpms: NO //////////////////////////////////////////////////////////////// @@ -202,37 +156,18 @@ //////////////////////////////////////////////////////////////// // Implementation alternatives - don't change external behavior //////////////////////////////////////////////////////////////// - -// Define TABLE_DRIVEN_DISPATCH to use tables rather than case statements -// for command dispatch and handle unmarshaling -#define TABLE_DRIVEN_DISPATCH YES +// does the target system have longjmp support, AND we want to use it? +#define LONGJMP_SUPPORTED YES // libtpms: YES // This define is used to enable the new table-driven marshaling code. #define TABLE_DRIVEN_MARSHAL NO -// This switch allows use of #defines in place of pass-through marshaling or -// unmarshaling code. A pass-through function just calls another function to do -// the required function and does no parameter checking of its own. The -// table-driven dispatcher calls directly to the lowest level -// marshaling/unmarshaling code and by-passes any pass-through functions. -#define USE_MARSHALING_DEFINES YES - // Switch added to support packed lists that leave out space associated with // unimplemented commands. Comment this out to use linear lists. // Note: if vendor specific commands are present, the associated list is always // in compressed form. #define COMPRESSED_LISTS NO /* libtpms: change in v0.10 */ -// This define is used to eliminate the use of bit-fields. It can be enabled for big- -// or little-endian machines. For big-endian architectures that numbers bits in -// registers from left to right (MSb0) this must be enabled. Little-endian machines -// number from right to left with the least significant bit having assigned a bit -// number of 0. These are LSb0 machines (they are also little-endian so they are also -// least-significant byte 0 (LSB0) machines. Big-endian (MSB0) machines may number in -// either direction (MSb0 or LSb0). For an MSB0+MSb0 machine this value is required to -// be 'NO' -#define USE_BIT_FIELD_STRUCTURES NO - // Enable the generation of RSA primes using a sieve. #define RSA_KEY_SIEVE YES @@ -265,6 +200,6 @@ #define FAIL_TRACE YES // TODO_RENAME_INC_FOLDER: public refers to the TPM_CoreLib public headers -#include "CompilerDependencies.h" +#include #endif // _TPM_BUILD_SWITCHES_H_ diff --git a/src/tpm2/TPMCmd/TpmConfiguration/TpmConfiguration/TpmProfile.h b/src/tpm2/TPMCmd/TpmConfiguration/TpmConfiguration/TpmProfile.h new file mode 100644 index 000000000..5271f812c --- /dev/null +++ b/src/tpm2/TPMCmd/TpmConfiguration/TpmConfiguration/TpmProfile.h @@ -0,0 +1,32 @@ +// SPDX-License-Identifier: BSD-2-Clause + +// FOR LIBTPMS: DO NOT EDIT THIS or INCLUDED FILES! +// ANY MODIFICATION WILL LEAD TO AN UNSUPPORTED CONFIGURATION + +// The primary configuration file that collects all configuration options for a +// TPM build. +#ifndef _TPM_PROFILE_H_ +#define _TPM_PROFILE_H_ + +#include +#include +#include +#include +#include + +// libtpms: added begin +#ifndef HASH_LIB +#define HASH_LIB Ossl +#endif +#ifndef SYM_LIB +#define SYM_LIB Ossl +#endif +#ifndef MATH_LIB +#define MATH_LIB TpmBigNum +#endif +#ifndef BN_MATH_LIB +#define BN_MATH_LIB Ossl +#endif +// libtpms: added end + +#endif // _TPM_PROFILE_H_ diff --git a/src/tpm2/TpmProfile_CommandList.h b/src/tpm2/TPMCmd/TpmConfiguration/TpmConfiguration/TpmProfile_CommandList.h similarity index 66% rename from src/tpm2/TpmProfile_CommandList.h rename to src/tpm2/TPMCmd/TpmConfiguration/TpmConfiguration/TpmProfile_CommandList.h index ec9ce200c..259e4432e 100644 --- a/src/tpm2/TpmProfile_CommandList.h +++ b/src/tpm2/TPMCmd/TpmConfiguration/TpmConfiguration/TpmProfile_CommandList.h @@ -1,62 +1,4 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2023 */ -/* */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause // this file defines the desired command list that should be built into the @@ -72,31 +14,34 @@ # error CC_YES and CC_NO should be defined by the command line file, not before #endif +// Change these definitions to turn all commands ON or OFF. That is, to turn all +// commands on, set CC_NO to YES. This is intended as a debug feature. #define CC_YES YES #define CC_NO NO -// +// do not format automatically - the comments confuse clang-format. +// clang-format off + // Defines for Implemented Commands -// // Commands that are defined in the spec, but not implemented for various // reasons: // The TPM reference implementation does not implement attached-component // features, and the Compliance test suite has no test cases. -#define CC_AC_GetCapability CC_NO -#define CC_AC_Send CC_NO +#define CC_AC_GetCapability CC_NO +#define CC_AC_Send CC_NO // The TPM reference implementation does not implement firmware upgrade. -#define CC_FieldUpgradeData CC_NO -#define CC_FieldUpgradeStart CC_NO -#define CC_FirmwareRead CC_NO +#define CC_FieldUpgradeData CC_NO +#define CC_FieldUpgradeStart CC_NO +#define CC_FirmwareRead CC_NO // A prototype of CertifyX509 is provided here for informative purposes only. // While all of the TPM reference implementation is provided "AS IS" without any // warranty, the current design and implementation of CertifyX509 are considered // to be especially unsuitable for product use. -#define CC_CertifyX509 CC_YES +#define CC_CertifyX509 CC_YES // Normal commands: @@ -215,11 +160,16 @@ #define CC_StirRandom CC_YES #define CC_TestParms CC_YES #define CC_Unseal CC_YES -#define CC_Vendor_TCG_Test CC_NO /* libtpms: NO */ #define CC_VerifySignature CC_YES #define CC_ZGen_2Phase (CC_YES && ALG_ECC) #define CC_NV_DefineSpace2 CC_NO /* libtpms: NO */ #define CC_NV_ReadPublic2 CC_NO /* libtpms: NO */ #define CC_SetCapability CC_NO /* libtpms: NO */ +#define CC_ReadOnlyControl CC_NO /* libtpms: NO */ +#define CC_PolicyTransportSPDM CC_NO /* libtpms: NO */ + +// clang-format on + +#include #endif // _TPM_PROFILE_COMMAND_LIST_H_ diff --git a/src/tpm2/TpmProfile_Common.h b/src/tpm2/TPMCmd/TpmConfiguration/TpmConfiguration/TpmProfile_Common.h similarity index 75% rename from src/tpm2/TpmProfile_Common.h rename to src/tpm2/TPMCmd/TpmConfiguration/TpmConfiguration/TpmProfile_Common.h index ac295b7bc..9bf1c1292 100644 --- a/src/tpm2/TpmProfile_Common.h +++ b/src/tpm2/TPMCmd/TpmConfiguration/TpmConfiguration/TpmProfile_Common.h @@ -1,62 +1,4 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2023 */ -/* */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause // clang-format off @@ -114,9 +56,6 @@ #define BIG_ENDIAN_TPM NO #endif #define LITTLE_ENDIAN_TPM !BIG_ENDIAN_TPM -// Does the processor put the most-significant bit at bit position 0? -#define MOST_SIGNIFICANT_BIT_0 NO -#define LEAST_SIGNIFICANT_BIT_0 !MOST_SIGNIFICANT_BIT_0 // Does processor support Auto align? #define AUTO_ALIGN NO @@ -140,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) @@ -213,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 @@ -277,6 +216,8 @@ #endif // libtpms added end +// number of vendor properties, must currently be 1. +#define MAX_VENDOR_PROPERTY (1) //*********************************************** // Enable VENDOR_PERMANENT_AUTH_HANDLE? @@ -327,4 +268,11 @@ #define EXTERNAL_NV NO #define PERMANENT_NV NO // libtpms: added +//*********************************************** +// 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_ diff --git a/src/tpm2/TPMCmd/TpmConfiguration/TpmConfiguration/TpmProfile_ErrorCodes.h b/src/tpm2/TPMCmd/TpmConfiguration/TpmConfiguration/TpmProfile_ErrorCodes.h new file mode 100644 index 000000000..eedfa0ee2 --- /dev/null +++ b/src/tpm2/TPMCmd/TpmConfiguration/TpmConfiguration/TpmProfile_ErrorCodes.h @@ -0,0 +1,57 @@ +// SPDX-License-Identifier: BSD-2-Clause + +//** Introduction +// This file defines error codes used in failure macros in the TPM Core Library. +// This file is part of TpmConfiguration because the Platform library can add error +// codes of it's own, and ultimately the specific error codes are a vendor decision +// because TPM2_GetTestResult returns manufacturer-defined data in failure mode. +// The only thing in this file that must be consistent with a vendor's implementation +// are the _names_ of error codes used by the core library. Even the values can +// change and are only a suggestion. + +#ifndef _TPMPROFILE_ERRORCODES_H +#define _TPMPROFILE_ERRORCODES_H + +// turn off clang-format because alignment doesn't persist across comments +// with current settings +// clang-format off + +#define FATAL_ERROR_ALLOCATION (1) +#define FATAL_ERROR_DIVIDE_ZERO (2) +#define FATAL_ERROR_INTERNAL (3) +#define FATAL_ERROR_PARAMETER (4) +#define FATAL_ERROR_ENTROPY (5) +#define FATAL_ERROR_SELF_TEST (6) +#define FATAL_ERROR_CRYPTO (7) +#define FATAL_ERROR_NV_UNRECOVERABLE (8) + +// indicates that the TPM has been re-manufactured after an +// unrecoverable NV error +#define FATAL_ERROR_REMANUFACTURED (9) +#define FATAL_ERROR_DRBG (10) +#define FATAL_ERROR_MOVE_SIZE (11) +#define FATAL_ERROR_COUNTER_OVERFLOW (12) +#define FATAL_ERROR_SUBTRACT (13) +#define FATAL_ERROR_MATHLIBRARY (14) +// end of codes defined through v1.52 + +// leave space for numbers that may have been used by vendors or platforms. +// Ultimately this file and these ranges are only a suggestion because +// TPM2_GetTestResult returns manufacturer-defined data in failure mode. +// Reserve 15-499 +#define FATAL_ERROR_RESERVED_START (15) +#define FATAL_ERROR_RESERVED_END (499) + +// Additional error codes defined by TPM library: +#define FATAL_ERROR_ASSERT (500) +#define FATAL_ERROR_NV_INIT (501) +#define FATAL_ERROR_CRYPTO_INIT (502) +#define FATAL_ERROR_NO_INIT (503) + +// Platform library violated interface contract. +#define FATAL_ERROR_PLATFORM (600) + +// Test/Simulator errors 1000+ +#define FATAL_ERROR_FORCED (1000) + +#endif // _TPMPROFILE_ERRORCODES_H diff --git a/src/tpm2/TPMCmd/TpmConfiguration/TpmConfiguration/TpmProfile_Misc.h b/src/tpm2/TPMCmd/TpmConfiguration/TpmConfiguration/TpmProfile_Misc.h new file mode 100644 index 000000000..044e63afc --- /dev/null +++ b/src/tpm2/TPMCmd/TpmConfiguration/TpmConfiguration/TpmProfile_Misc.h @@ -0,0 +1,76 @@ +// SPDX-License-Identifier: BSD-2-Clause + +// Misc profile settings that don't currently have a better home. +// These are rarely changed, but available for vendor customization. + +#ifndef _TPM_PROFILE_MISC_H_ +#define _TPM_PROFILE_MISC_H_ + +// YES & NO defined by TpmBuildSwitches.h +#if(YES != 1 || NO != 0) +# error YES or NO incorrectly set +#endif + +// clang-format off +// clang-format off to preserve horizontal spacing +#define IMPLEMENTATION_PCR 24 +#define PLATFORM_PCR 24 +#define DRTM_PCR 17 +#define HCRTM_PCR 0 +#define NUM_LOCALITIES 5 +#define MAX_HANDLE_NUM 3 +#define MAX_ACTIVE_SESSIONS 64 +#define MAX_LOADED_SESSIONS 3 +#define MAX_SESSION_NUM 3 +#define MAX_LOADED_OBJECTS 3 +#define MIN_EVICT_OBJECTS 7 /* libtpms: for PC client */ +#define NUM_POLICY_PCR_GROUP 1 +#define NUM_AUTHVALUE_PCR_GROUP 1 +//#define MAX_CONTEXT_SIZE 2168 +#define MAX_CONTEXT_SIZE 2680 /* libtpms: changed for RSA-3072 */ +#define MAX_DIGEST_BUFFER 1024 +#define MAX_NV_INDEX_SIZE 2048 +#define MAX_NV_BUFFER_SIZE 1024 +#define MAX_CAP_BUFFER 1024 +/* libtmps: 65 OBJECTs in USER NVRAM expanded by 704 bytes due to size + * increase of OBJECT from 2048 bit RSA keys to 3072 bit by 704 bytes*/ +#define NV_MEMORY_SIZE (128 * 1024 + 65 * 704) /* libtpms changed */ +#define MIN_COUNTER_INDICES 8 +#define NUM_STATIC_PCR 16 +#define MAX_ALG_LIST_SIZE 64 +#define PRIMARY_SEED_SIZE 64 /* libtpms: 64 per define USE_SPEC_COMPLIANT_PROOFS */ +#define CONTEXT_ENCRYPT_ALGORITHM AES +#define NV_CLOCK_UPDATE_INTERVAL 12 /* libtpms: keep old value */ +#define NUM_POLICY_PCR 1 + +#define ORDERLY_BITS 8 +#define MAX_SYM_DATA 128 +#define MAX_RNG_ENTROPY_SIZE 64 +#define RAM_INDEX_SPACE 512 +#define ENABLE_PCR_NO_INCREMENT YES + +#define SIZE_OF_X509_SERIAL_NUMBER 20 + +// amount of space the platform can provide in PERSISTENT_DATA during +// manufacture +#define PERSISTENT_DATA_PLATFORM_SPACE 0 /* libtpms: changed from '16' */ + +// structure padding space for these structures. Used if a +// particular configuration needs them to be aligned to a +// specific size +#define ORDERLY_DATA_PADDING 0 +#define STATE_CLEAR_DATA_PADDING 0 +#define STATE_RESET_DATA_PADDING 0 + +// configuration values that may vary by SIMULATION/DEBUG +#if SIMULATION && DEBUG +// This forces the use of a smaller context slot size. This reduction reduces the +// range of the epoch allowing the tester to force the epoch to occur faster than +// the normal production size +# define CONTEXT_SLOT UINT8 +# error SIMULATION & DEBUG is not supported /* libtpms: added */ +#else +# define CONTEXT_SLOT UINT16 /* libtpms: changed from UINT8 in v0.9.0 */ +#endif + +#endif // _TPM_PROFILE_MISC_H_ diff --git a/src/tpm2/TPMCmd/TpmConfiguration/TpmConfiguration/VendorCommands/CommandAttributeData_s_ccAttr.inl b/src/tpm2/TPMCmd/TpmConfiguration/TpmConfiguration/VendorCommands/CommandAttributeData_s_ccAttr.inl new file mode 100644 index 000000000..53ef01d17 --- /dev/null +++ b/src/tpm2/TPMCmd/TpmConfiguration/TpmConfiguration/VendorCommands/CommandAttributeData_s_ccAttr.inl @@ -0,0 +1,18 @@ +// SPDX-License-Identifier: BSD-2-Clause + +// This file contains an inlined portion of the s_ccAttr array definition +// for vendor commands. +// +// IMPORTANT: This file is included in the middle of an array initializer +// therefore it must not contain anything other than comments and exactly one TPMA_CC +// entry per vendor command. See the private Tpm header CommandAttributeData.h for +// more info. +// (This is why the file has the .INL extension, it's not a normal header. +// +#ifndef _COMMAND_CODE_ATTRIBUTES_ +# error This file should be included only within CommandAttributeData.h +#endif +#if (PAD_LIST || CC_Vendor_TCG_Test) +// TPM_CC_Vendor_TCG_Test +TPMA_CC_INITIALIZER(0x0000, 0, 0, 0, 0, 0, 0, 1, 0), +#endif diff --git a/src/tpm2/TPMCmd/TpmConfiguration/TpmConfiguration/VendorCommands/CommandAttributeData_s_commandAttributes.inl b/src/tpm2/TPMCmd/TpmConfiguration/TpmConfiguration/VendorCommands/CommandAttributeData_s_commandAttributes.inl new file mode 100644 index 000000000..a7d532f65 --- /dev/null +++ b/src/tpm2/TPMCmd/TpmConfiguration/TpmConfiguration/VendorCommands/CommandAttributeData_s_commandAttributes.inl @@ -0,0 +1,18 @@ +// SPDX-License-Identifier: BSD-2-Clause + +// This file contains an inlined portion of the s_commandAttributes array +// definition for vendor commands. +// +// IMPORTANT: This file is included in the middle of an array initializer +// therefore it must not contain anything other than comments and exactly one +// COMMAND_ATTRIBUTES entry per vendor command. See the private Tpm header +// CommandAttributeData.h for more info. (This is why the file has the .INL +// extension, it's not a normal header. +// +#ifndef _COMMAND_CODE_ATTRIBUTES_ +# error This file should be included only within CommandAttributeData.h +#endif +#if (PAD_LIST || CC_Vendor_TCG_Test) +(COMMAND_ATTRIBUTES)(CC_Vendor_TCG_Test* // 0x0000 + (DECRYPT_2 + ENCRYPT_2)), +#endif diff --git a/src/tpm2/TPMCmd/TpmConfiguration/TpmConfiguration/VendorCommands/CommandDispatchData_CommandStructures.inl b/src/tpm2/TPMCmd/TpmConfiguration/TpmConfiguration/VendorCommands/CommandDispatchData_CommandStructures.inl new file mode 100644 index 000000000..0435a751f --- /dev/null +++ b/src/tpm2/TPMCmd/TpmConfiguration/TpmConfiguration/VendorCommands/CommandDispatchData_CommandStructures.inl @@ -0,0 +1,43 @@ +// SPDX-License-Identifier: BSD-2-Clause + +// This file contains an inlined portion of the s_ccAttr array definition +// for vendor commands. +// +// IMPORTANT: This file is included in the middle of an array initializer +// therefore it must not contain anything other than comments and exactly one TPMA_CC +// entry per vendor command. See the private Tpm header CommandAttributeData.h for +// more info. +// (This is why the file has the .INL extension, it's not a normal header. +// +#ifndef _COMMAND_TABLE_DISPATCH_ +#error This file should only be included inside CommandDispatchData.h when table dispatching is turned on. +#endif + +#if CC_Vendor_TCG_Test +# include "TpmConfiguration/VendorCommands/prototypes/Vendor_TCG_Test_fp.h" + +typedef TPM_RC(Vendor_TCG_Test_Entry)(Vendor_TCG_Test_In* in, + Vendor_TCG_Test_Out* out); + +typedef const struct +{ + Vendor_TCG_Test_Entry* entry; + UINT16 inSize; + UINT16 outSize; + UINT16 offsetOfTypes; + BYTE types[4]; +} Vendor_TCG_Test_COMMAND_DESCRIPTOR_t; + +Vendor_TCG_Test_COMMAND_DESCRIPTOR_t _Vendor_TCG_TestData = { + /* entry */ &TPM2_Vendor_TCG_Test, + /* inSize */ (UINT16)(sizeof(Vendor_TCG_Test_In)), + /* outSize */ (UINT16)(sizeof(Vendor_TCG_Test_Out)), + /* offsetOfTypes */ offsetof(Vendor_TCG_Test_COMMAND_DESCRIPTOR_t, types), + /* offsets */ // No parameter offsets + /* types */ + {TPM2B_DATA_P_UNMARSHAL, END_OF_LIST, TPM2B_DATA_P_MARSHAL, END_OF_LIST}}; + +# define _Vendor_TCG_TestDataAddress (&_Vendor_TCG_TestData) +#else +# define _Vendor_TCG_TestDataAddress 0 +#endif // CC_Vendor_TCG_Test diff --git a/src/tpm2/TPMCmd/TpmConfiguration/TpmConfiguration/VendorCommands/CommandDispatchData_s_CommandDataArray.inl b/src/tpm2/TPMCmd/TpmConfiguration/TpmConfiguration/VendorCommands/CommandDispatchData_s_CommandDataArray.inl new file mode 100644 index 000000000..ca7650a7d --- /dev/null +++ b/src/tpm2/TPMCmd/TpmConfiguration/TpmConfiguration/VendorCommands/CommandDispatchData_s_CommandDataArray.inl @@ -0,0 +1,17 @@ +// SPDX-License-Identifier: BSD-2-Clause + +// This file contains an inlined portion of the s_ccAttr array definition +// for vendor commands. +// +// IMPORTANT: This file is included in the middle of an array initializer +// therefore it must not contain anything other than comments and exactly one TPMA_CC +// entry per vendor command. See the private Tpm header CommandAttributeData.h for +// more info. +// (This is why the file has the .INL extension, it's not a normal header. +// +#ifndef _COMMAND_TABLE_DISPATCH_ +#error This file should only be included inside CommandDispatchData.h when table dispatching is turned on. +#endif +#if (PAD_LIST || CC_Vendor_TCG_Test) +(COMMAND_DESCRIPTOR_t*)_Vendor_TCG_TestDataAddress, +#endif // CC_Vendor_TCG_Test diff --git a/src/tpm2/TPMCmd/TpmConfiguration/TpmConfiguration/VendorCommands/VendorCommandList.h b/src/tpm2/TPMCmd/TpmConfiguration/TpmConfiguration/VendorCommands/VendorCommandList.h new file mode 100644 index 000000000..15cd8708b --- /dev/null +++ b/src/tpm2/TPMCmd/TpmConfiguration/TpmConfiguration/VendorCommands/VendorCommandList.h @@ -0,0 +1,22 @@ +// 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 +#endif + +#define CC_Vendor_TCG_Test CC_NO /* libtpms: NO */ + +#define VENDOR_COMMAND_ARRAY_COUNT (CC_Vendor_TCG_Test) + +// actually define vendor command IDs here +#if CC_Vendor_TCG_Test == YES +# define TPM_CC_Vendor_TCG_Test (TPM_CC)(CC_VEND | 0x0000) +#else +// nothing +#endif +// and command attributes must be defined in TpmProfile_CommandList_AttributeData.inl diff --git a/src/tpm2/TPMCmd/TpmConfiguration/TpmConfiguration/VendorCommands/prototypes/Vendor_TCG_Test_fp.h b/src/tpm2/TPMCmd/TpmConfiguration/TpmConfiguration/VendorCommands/prototypes/Vendor_TCG_Test_fp.h new file mode 100644 index 000000000..a269a64fa --- /dev/null +++ b/src/tpm2/TPMCmd/TpmConfiguration/TpmConfiguration/VendorCommands/prototypes/Vendor_TCG_Test_fp.h @@ -0,0 +1,29 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +#if CC_Vendor_TCG_Test // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_VENDOR_TCG_TEST_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_VENDOR_TCG_TEST_FP_H_ + +// Input structure definition +typedef struct +{ + TPM2B_DATA inputData; +} Vendor_TCG_Test_In; + +// Output structure definition +typedef struct +{ + TPM2B_DATA outputData; +} Vendor_TCG_Test_Out; + +// Response code modifiers +# define RC_Vendor_TCG_Test_inputData (TPM_RC_P + TPM_RC_1) + +// Function prototype +TPM_RC +TPM2_Vendor_TCG_Test(Vendor_TCG_Test_In* in, Vendor_TCG_Test_Out* out); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_VENDOR_TCG_TEST_FP_H_ +#endif // CC_Vendor_TCG_Test diff --git a/src/tpm2/TPMCmd/TpmConfiguration/TpmVendorCommandHandlers/Vendor_TCG_Test.c b/src/tpm2/TPMCmd/TpmConfiguration/TpmVendorCommandHandlers/Vendor_TCG_Test.c new file mode 100644 index 000000000..bc3678bba --- /dev/null +++ b/src/tpm2/TPMCmd/TpmConfiguration/TpmVendorCommandHandlers/Vendor_TCG_Test.c @@ -0,0 +1,19 @@ +// SPDX-License-Identifier: BSD-2-Clause + +#include + +#if CC_Vendor_TCG_Test // Conditional expansion of this file + +# include +# include + +TPM_RC +TPM2_Vendor_TCG_Test(Vendor_TCG_Test_In* in, // IN: input parameter list + Vendor_TCG_Test_Out* out // OUT: output parameter list +) +{ + out->outputData = in->inputData; + return TPM_RC_SUCCESS; +} + +#endif // CC_Vendor_TCG_Test diff --git a/src/tpm2/TpmEcc_Signature_ECDSA.c b/src/tpm2/TPMCmd/tpm/cryptolibs/EccRef/TpmEcc_Signature_ECDSA.c similarity index 76% rename from src/tpm2/TpmEcc_Signature_ECDSA.c rename to src/tpm2/TPMCmd/tpm/cryptolibs/EccRef/TpmEcc_Signature_ECDSA.c index 5a6fe14d7..e8cf55b2f 100644 --- a/src/tpm2/TpmEcc_Signature_ECDSA.c +++ b/src/tpm2/TPMCmd/tpm/cryptolibs/EccRef/TpmEcc_Signature_ECDSA.c @@ -1,68 +1,10 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2023 */ -/* */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause #include "Tpm.h" #include "TpmEcc_Signature_ECDSA_fp.h" #include "TpmMath_Debug_fp.h" #include "TpmMath_Util_fp.h" -#include "BnToOsslMath_fp.h" +#include "BnToOsslMath_fp.h" // libtpms added #if ALG_ECC && ALG_ECDSA //*** TpmEcc_AdjustEcdsaDigest() diff --git a/src/tpm2/crypto/openssl/BnToOsslMath.c b/src/tpm2/TPMCmd/tpm/cryptolibs/Ossl/BnToOsslMath.c similarity index 85% rename from src/tpm2/crypto/openssl/BnToOsslMath.c rename to src/tpm2/TPMCmd/tpm/cryptolibs/Ossl/BnToOsslMath.c index d305f3063..a71c8dc3b 100644 --- a/src/tpm2/crypto/openssl/BnToOsslMath.c +++ b/src/tpm2/TPMCmd/tpm/cryptolibs/Ossl/BnToOsslMath.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 // The functions in this file provide the low-level interface between the TPM code @@ -84,7 +26,7 @@ #include "BnOssl.h" #ifdef MATH_LIB_OSSL -# include "BnToOsslMath_fp.h" +# include //** Functions @@ -163,7 +105,7 @@ BIGNUM* BigInitialized(BIGNUM* toInit, bigConst initializer) # define BIGNUM_PRINT(label, bn, eol) # define DEBUG_PRINT(x) # else -# define DEBUG_PRINT(x) printf("%s", x) +# define DEBUG_PRINT(x) TPM_DEBUG_PRINTF("%s", x) # define BIGNUM_PRINT(label, bn, eol) BIGNUM_print((label), (bn), (eol)) //*** BIGNUM_print() @@ -174,14 +116,19 @@ static void BIGNUM_print(const char* label, const BIGNUM* a, BOOL eol) int notZero = FALSE; if(label != NULL) - printf("%s", label); + { + DEBUG_PRINT("%s", label); + } + if(a == NULL) { - printf("NULL"); + DEBUG_PRINT("NULL"); goto done; } if(a->neg) - printf("-"); + { + DEBUG_PRINT("-"); + } for(i = a->top, d = &a->d[i - 1]; i > 0; i--) { int j; @@ -191,14 +138,20 @@ static void BIGNUM_print(const char* label, const BIGNUM* a, BOOL eol) BYTE b = (BYTE)((l >> j) & 0xFF); notZero = notZero || (b != 0); if(notZero) - printf("%02x", b); + { + DEBUG_PRINT("%02x", b); + } } if(!notZero) - printf("0"); + { + DEBUG_PRINT("0"); + } } done: if(eol) - printf("\n"); + { + DEBUG_PRINT("\n"); + } return; } # endif @@ -213,7 +166,9 @@ static BIGNUM* BnNewVariable(BN_CTX* CTX) // This check is intended to protect against calling this function without // having initialized the CTX. if((CTX == NULL) || ((new = BN_CTX_get(CTX)) == NULL)) - FAIL(FATAL_ERROR_ALLOCATION); + { + FAIL_NULL(FATAL_ERROR_ALLOCATION); + } return new; } @@ -406,7 +361,6 @@ LIB_EXPORT BOOL BnModExp(bigNum result, // OUT: the result OSSL_LEAVE(); return OK; } -# endif // ALG_RSA //*** BnModInverse() // Modular multiplicative inverse @@ -433,6 +387,7 @@ LIB_EXPORT BOOL BnModInverse(bigNum result, bigConst number, bigConst modulus) OSSL_LEAVE(); return OK; } +# endif // ALG_RSA # if ALG_ECC diff --git a/src/tpm2/crypto/openssl/ExpDCache.c b/src/tpm2/TPMCmd/tpm/cryptolibs/Ossl/ExpDCache.c similarity index 65% rename from src/tpm2/crypto/openssl/ExpDCache.c rename to src/tpm2/TPMCmd/tpm/cryptolibs/Ossl/ExpDCache.c index 8e6a8d279..f995e4aa6 100644 --- a/src/tpm2/crypto/openssl/ExpDCache.c +++ b/src/tpm2/TPMCmd/tpm/cryptolibs/Ossl/ExpDCache.c @@ -1,43 +1,6 @@ -/********************************************************************************/ -/* */ -/* Private Exponent D cache functions */ -/* Written by Stefan Berger */ -/* IBM Thomas J. Watson Research Center */ -/* */ -/* Licenses and Notices */ -/* */ -/* (c) Copyright IBM Corporation, 2021-2025 */ -/* */ -/* All rights reserved. */ -/* */ -/* Redistribution and use in source and binary forms, with or without */ -/* modification, are permitted provided that the following conditions are */ -/* met: */ -/* */ -/* Redistributions of source code must retain the above copyright notice, */ -/* this list of conditions and the following disclaimer. */ -/* */ -/* Redistributions in binary form must reproduce the above copyright */ -/* notice, this list of conditions and the following disclaimer in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* Neither the names of the IBM Corporation nor the names of its */ -/* contributors may be used to endorse or promote products derived from */ -/* this software without specific prior written permission. */ -/* */ -/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */ -/* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */ -/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR */ -/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */ -/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */ -/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */ -/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, */ -/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY */ -/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */ -/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE */ -/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause + +// (c) Copyright IBM Corporation, 2021-2025 #include "Tpm.h" #include "ExpDCache_fp.h" diff --git a/src/tpm2/crypto/openssl/Helpers.c b/src/tpm2/TPMCmd/tpm/cryptolibs/Ossl/Helpers.c similarity index 93% rename from src/tpm2/crypto/openssl/Helpers.c rename to src/tpm2/TPMCmd/tpm/cryptolibs/Ossl/Helpers.c index b4eeb3d9e..a637abfb6 100644 --- a/src/tpm2/crypto/openssl/Helpers.c +++ b/src/tpm2/TPMCmd/tpm/cryptolibs/Ossl/Helpers.c @@ -1,43 +1,6 @@ -/********************************************************************************/ -/* */ -/* OpenSSL helper functions */ -/* Written by Stefan Berger */ -/* IBM Thomas J. Watson Research Center */ -/* */ -/* Licenses and Notices */ -/* */ -/* (c) Copyright IBM Corporation, 2019-2025 */ -/* */ -/* All rights reserved. */ -/* */ -/* Redistribution and use in source and binary forms, with or without */ -/* modification, are permitted provided that the following conditions are */ -/* met: */ -/* */ -/* Redistributions of source code must retain the above copyright notice, */ -/* this list of conditions and the following disclaimer. */ -/* */ -/* Redistributions in binary form must reproduce the above copyright */ -/* notice, this list of conditions and the following disclaimer in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* Neither the names of the IBM Corporation nor the names of its */ -/* contributors may be used to endorse or promote products derived from */ -/* this software without specific prior written permission. */ -/* */ -/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */ -/* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */ -/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR */ -/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */ -/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */ -/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */ -/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, */ -/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY */ -/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */ -/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE */ -/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause + +// (c) Copyright IBM Corporation, 2019-2025 #include "Tpm.h" #include "ExpDCache_fp.h" diff --git a/src/tpm2/crypto/openssl/TpmToOsslDesSupport.c b/src/tpm2/TPMCmd/tpm/cryptolibs/Ossl/TpmToOsslDesSupport.c similarity index 100% rename from src/tpm2/crypto/openssl/TpmToOsslDesSupport.c rename to src/tpm2/TPMCmd/tpm/cryptolibs/Ossl/TpmToOsslDesSupport.c diff --git a/src/tpm2/TPMCmd/tpm/cryptolibs/Ossl/TpmToOsslSupport.c b/src/tpm2/TPMCmd/tpm/cryptolibs/Ossl/TpmToOsslSupport.c new file mode 100644 index 000000000..8e0be9c54 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/cryptolibs/Ossl/TpmToOsslSupport.c @@ -0,0 +1,114 @@ +// SPDX-License-Identifier: BSD-2-Clause + +//** Introduction +// +// The functions in this file are used for initialization of the interface to the +// OpenSSL library. + +//** Defines and Includes + +#include "BnOssl.h" +#include +#include +#include +#include +#include + +#if CRYPTO_LIB_REPORTING + +//*** OsslGetVersion() +// Report the version of OpenSSL. +void OsslGetVersion(_CRYPTO_IMPL_DESCRIPTION* result) +{ + snprintf(result->name, sizeof(result->name), "OpenSSL"); +# if defined(OPENSSL_VERSION_STR) + snprintf(result->version, sizeof(result->version), "%s", OPENSSL_VERSION_STR); +# else + // decode the hex version string according to the rules described in opensslv.h + snprintf(result->version, + sizeof(result->version), + "%d.%d.%d%c", + (unsigned char)((OPENSSL_VERSION_NUMBER >> 28) & 0x0f), + (unsigned char)((OPENSSL_VERSION_NUMBER >> 20) & 0xff), + (unsigned char)((OPENSSL_VERSION_NUMBER >> 12) & 0xff), + (char)((OPENSSL_VERSION_NUMBER >> 4) & 0xff) - 1 + 'a'); +# endif //OPENSSL_VERSION_STR +} + +#endif //CRYPTO_LIB_REPORTING + +#if defined(HASH_LIB_OSSL) || defined(MATH_LIB_OSSL) || defined(SYM_LIB_OSSL) +// Used to pass the pointers to the correct sub-keys +typedef const BYTE* desKeyPointers[3]; + +//*** BnSupportLibInit() +// This does any initialization required by the support library. +LIB_EXPORT int BnSupportLibInit(void) +{ + return TRUE; +} + +//*** OsslContextEnter() +// This function is used to initialize an OpenSSL context at the start of a function +// that will call to an OpenSSL math function. +BN_CTX* OsslContextEnter(void) +{ + BN_CTX* CTX = BN_CTX_new(); + // + return OsslPushContext(CTX); +} + +//*** OsslContextLeave() +// This is the companion function to OsslContextEnter(). +void OsslContextLeave(BN_CTX* CTX) +{ + OsslPopContext(CTX); + BN_CTX_free(CTX); +} + +//*** OsslPushContext() +// This function is used to create a frame in a context. All values allocated within +// this context after the frame is started will be automatically freed when the +// context (OsslPopContext() +BN_CTX* OsslPushContext(BN_CTX* CTX) +{ + if(CTX == NULL) + FAIL(FATAL_ERROR_ALLOCATION); + BN_CTX_start(CTX); + return CTX; +} + +//*** OsslPopContext() +// This is the companion function to OsslPushContext(). +void OsslPopContext(BN_CTX* CTX) +{ + // BN_CTX_end can't be called with NULL. It will blow up. + if(CTX != NULL) + BN_CTX_end(CTX); +} + +# if CRYPTO_LIB_REPORTING + +# if defined(SYM_LIB_OSSL) && SIMULATION && CRYPTO_LIB_REPORTING +//*** _crypto_GetSymImpl() +// Report the version of OpenSSL being used for symmetric crypto. +void _crypto_GetSymImpl(_CRYPTO_IMPL_DESCRIPTION* result) +{ + OsslGetVersion(result); +} +# else +# error huh? +# endif // defined(SYM_LIB_OSSL) && SIMULATION + +# if defined(HASH_LIB_OSSL) && SIMULATION && CRYPTO_LIB_REPORTING +//*** _crypto_GetHashImpl() +// Report the version of OpenSSL being used for hashing. +void _crypto_GetHashImpl(_CRYPTO_IMPL_DESCRIPTION* result) +{ + OsslGetVersion(result); +} +# endif // defined(HASH_LIB_OSSL) && SIMULATION + +# endif // CRYPTO_LIB_REPORTING + +#endif // HASH_LIB_OSSL || MATH_LIB_OSSL || SYM_LIB_OSSL diff --git a/src/tpm2/TPMCmd/tpm/cryptolibs/Ossl/include/BnOssl.h b/src/tpm2/TPMCmd/tpm/cryptolibs/Ossl/include/BnOssl.h new file mode 100644 index 000000000..b856eb120 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/cryptolibs/Ossl/include/BnOssl.h @@ -0,0 +1,28 @@ +// SPDX-License-Identifier: BSD-2-Clause + +//** Introduction +// This file contains the headers necessary to build the Open SSL support for +// the TpmBigNum library. +#ifndef _BNOSSL_H_ +#define _BNOSSL_H_ +// TODO_RENAME_INC_FOLDER: public refers to the TPM_CoreLib public headers +#include +#include +#include +// TODO_RENAME_INC_FOLDER: these refer to TpmBigNum protected headers +#include +#include +#include +#include +#include + +#if CRYPTO_LIB_REPORTING +# include + +//*** OsslGetVersion() +// Report the current version of OpenSSL. +void OsslGetVersion(_CRYPTO_IMPL_DESCRIPTION* result); + +#endif // CRYPTO_LIB_REPORTING + +#endif // _BNOSSL_H_ diff --git a/src/tpm2/crypto/openssl/BnToOsslMath.h b/src/tpm2/TPMCmd/tpm/cryptolibs/Ossl/include/Ossl/BnToOsslMath.h similarity index 53% rename from src/tpm2/crypto/openssl/BnToOsslMath.h rename to src/tpm2/TPMCmd/tpm/cryptolibs/Ossl/include/Ossl/BnToOsslMath.h index ccfd02af9..142695ec1 100644 --- a/src/tpm2/crypto/openssl/BnToOsslMath.h +++ b/src/tpm2/TPMCmd/tpm/cryptolibs/Ossl/include/Ossl/BnToOsslMath.h @@ -1,62 +1,4 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2023 */ -/* */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause //** Introduction // This file contains OpenSSL specific functions called by TpmBigNum library to provide @@ -72,7 +14,7 @@ # error this OpenSSL Interface expects to be used from TpmBigNum #endif -#include "BnValues.h" +#include #include #include #include @@ -149,7 +91,7 @@ TPM_INLINE const TPMBN_ECC_CURVE_CONSTANTS* AccessCurveConstants( return E->C; } -#include "TpmToOsslSupport_fp.h" +#include // Start and end a context within which the OpenSSL memory management works #define OSSL_ENTER() BN_CTX* CTX = OsslContextEnter() diff --git a/src/tpm2/TPMCmd/tpm/cryptolibs/Ossl/include/Ossl/BnToOsslMath_fp.h b/src/tpm2/TPMCmd/tpm/cryptolibs/Ossl/include/Ossl/BnToOsslMath_fp.h new file mode 100644 index 000000000..87e0f88d2 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/cryptolibs/Ossl/include/Ossl/BnToOsslMath_fp.h @@ -0,0 +1,36 @@ +// SPDX-License-Identifier: BSD-2-Clause + +/*(Auto-generated) + * Created by TpmPrototypes; Version 3.0 July 18, 2017 + * Date: Oct 24, 2019 Time: 11:37:07AM + */ + +#ifndef _BN_TO_OSSL_MATH_FP_H_ +#define _BN_TO_OSSL_MATH_FP_H_ + +#ifdef MATH_LIB_OSSL + +//*** OsslToTpmBn() +// This function converts an OpenSSL BIGNUM to a TPM bigNum. In this implementation +// it is assumed that OpenSSL uses a different control structure but the same data +// layout -- an array of native-endian words in little-endian order. +// Return Type: BOOL +// TRUE(1) success +// FALSE(0) failure because value will not fit or OpenSSL variable doesn't +// exist +BOOL OsslToTpmBn(bigNum bn, const BIGNUM* osslBn); // libtpms changed + +//*** BigInitialized() +// This function initializes an OSSL BIGNUM from a TPM bigConst. Do not use this for +// values that are passed to OpenSLL when they are not declared as const in the +// function prototype. Instead, use BnNewVariable(). +BIGNUM* BigInitialized(BIGNUM* toInit, bigConst initializer); +#endif // MATHLIB OSSL + +// libtpms added begin +EC_POINT *EcPointInitialized(pointConst initializer, + const bigCurveData* E + ); +// libtpms added end + +#endif // _TPM_TO_OSSL_MATH_FP_H_ diff --git a/src/tpm2/TPMCmd/tpm/cryptolibs/Ossl/include/Ossl/ExpDCache_fp.h b/src/tpm2/TPMCmd/tpm/cryptolibs/Ossl/include/Ossl/ExpDCache_fp.h new file mode 100644 index 000000000..69f946a04 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/cryptolibs/Ossl/include/Ossl/ExpDCache_fp.h @@ -0,0 +1,19 @@ +// SPDX-License-Identifier: BSD-2-Clause + +// (c) Copyright IBM Corporation, 2021-2025 + +#ifndef DCACHE_FP_H +#define DCACHE_FP_H + +#include + +BIGNUM *ExpDCacheFind(const BIGNUM *P, const BIGNUM *N, const BIGNUM *E, + BIGNUM **Q); + +void ExpDCacheAdd(const BIGNUM *P, const BIGNUM *N, const BIGNUM *E, + const BIGNUM *Q, const BIGNUM *D); + +void ExpDCacheFree(void); + +#endif /* DCACHE_FP_H */ + diff --git a/src/tpm2/crypto/openssl/Helpers_fp.h b/src/tpm2/TPMCmd/tpm/cryptolibs/Ossl/include/Ossl/Helpers_fp.h similarity index 53% rename from src/tpm2/crypto/openssl/Helpers_fp.h rename to src/tpm2/TPMCmd/tpm/cryptolibs/Ossl/include/Ossl/Helpers_fp.h index 7cc86169a..37abfd9c9 100644 --- a/src/tpm2/crypto/openssl/Helpers_fp.h +++ b/src/tpm2/TPMCmd/tpm/cryptolibs/Ossl/include/Ossl/Helpers_fp.h @@ -1,49 +1,11 @@ -/********************************************************************************/ -/* */ -/* OpenSSL helper functions */ -/* Written by Stefan Berger */ -/* IBM Thomas J. Watson Research Center */ -/* */ -/* Licenses and Notices */ -/* */ -/* (c) Copyright IBM Corporation, 2019-2025 */ -/* */ -/* All rights reserved. */ -/* */ -/* Redistribution and use in source and binary forms, with or without */ -/* modification, are permitted provided that the following conditions are */ -/* met: */ -/* */ -/* Redistributions of source code must retain the above copyright notice, */ -/* this list of conditions and the following disclaimer. */ -/* */ -/* Redistributions in binary form must reproduce the above copyright */ -/* notice, this list of conditions and the following disclaimer in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* Neither the names of the IBM Corporation nor the names of its */ -/* contributors may be used to endorse or promote products derived from */ -/* this software without specific prior written permission. */ -/* */ -/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */ -/* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */ -/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR */ -/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */ -/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */ -/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */ -/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, */ -/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY */ -/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */ -/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE */ -/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause +// (c) Copyright IBM Corporation, 2019-2025 #ifndef HELPERS_FP_H #define HELPERS_FP_H -#include "TpmTypes.h" +#include "tpm_public/TpmTypes.h" #include diff --git a/src/tpm2/crypto/openssl/TpmToOsslDesSupport_fp.h b/src/tpm2/TPMCmd/tpm/cryptolibs/Ossl/include/Ossl/TpmToOsslDesSupport_fp.h similarity index 100% rename from src/tpm2/crypto/openssl/TpmToOsslDesSupport_fp.h rename to src/tpm2/TPMCmd/tpm/cryptolibs/Ossl/include/Ossl/TpmToOsslDesSupport_fp.h diff --git a/src/tpm2/crypto/openssl/TpmToOsslHash.h b/src/tpm2/TPMCmd/tpm/cryptolibs/Ossl/include/Ossl/TpmToOsslHash.h similarity index 52% rename from src/tpm2/crypto/openssl/TpmToOsslHash.h rename to src/tpm2/TPMCmd/tpm/cryptolibs/Ossl/include/Ossl/TpmToOsslHash.h index 5fc0aaf78..c38b06e16 100644 --- a/src/tpm2/crypto/openssl/TpmToOsslHash.h +++ b/src/tpm2/TPMCmd/tpm/cryptolibs/Ossl/include/Ossl/TpmToOsslHash.h @@ -1,62 +1,4 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2023 */ -/* */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause //** 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. diff --git a/src/tpm2/TPMCmd/tpm/cryptolibs/Ossl/include/Ossl/TpmToOsslSupport_fp.h b/src/tpm2/TPMCmd/tpm/cryptolibs/Ossl/include/Ossl/TpmToOsslSupport_fp.h new file mode 100644 index 000000000..84bfcc7bc --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/cryptolibs/Ossl/include/Ossl/TpmToOsslSupport_fp.h @@ -0,0 +1,37 @@ +// SPDX-License-Identifier: BSD-2-Clause + +/*(Auto-generated) + * Created by TpmPrototypes; Version 3.0 July 18, 2017 + * Date: Mar 28, 2019 Time: 08:25:19PM + */ + +#ifndef _TPM_TO_OSSL_SUPPORT_FP_H_ +#define _TPM_TO_OSSL_SUPPORT_FP_H_ + +#if defined(HASH_LIB_OSSL) || defined(MATH_LIB_OSSL) || defined(SYM_LIB_OSSL) + +//*** BnSupportLibInit() +// This does any initialization required by the support library. +LIB_EXPORT int BnSupportLibInit(void); + +//*** OsslContextEnter() +// This function is used to initialize an OpenSSL context at the start of a function +// that will call to an OpenSSL math function. +BN_CTX* OsslContextEnter(void); + +//*** OsslContextLeave() +// This is the companion function to OsslContextEnter(). +void OsslContextLeave(BN_CTX* CTX); + +//*** OsslPushContext() +// This function is used to create a frame in a context. All values allocated within +// this context after the frame is started will be automatically freed when the +// context (OsslPopContext() +BN_CTX* OsslPushContext(BN_CTX* CTX); + +//*** OsslPopContext() +// This is the companion function to OsslPushContext(). +void OsslPopContext(BN_CTX* CTX); +#endif // HASH_LIB_OSSL || MATH_LIB_OSSL || SYM_LIB_OSSL + +#endif // _TPM_TO_OSSL_SUPPORT_FP_H_ diff --git a/src/tpm2/TPMCmd/tpm/cryptolibs/Ossl/include/Ossl/TpmToOsslSym.h b/src/tpm2/TPMCmd/tpm/cryptolibs/Ossl/include/Ossl/TpmToOsslSym.h new file mode 100644 index 000000000..90d434a41 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/cryptolibs/Ossl/include/Ossl/TpmToOsslSym.h @@ -0,0 +1,128 @@ +// SPDX-License-Identifier: BSD-2-Clause + +//** Introduction +// +// This header file is used to 'splice' the OpenSSL library into the TPM code. +// +// The support required of a library are a hash module, a block cipher module and +// portions of a big number library. + +// All of the library-dependent headers should have the same guard to that only the +// first one gets defined. +#ifndef SYM_LIB_DEFINED +#define SYM_LIB_DEFINED + +#define SYM_LIB_OSSL + +#include + +#if ALG_SM4 +# if defined(OPENSSL_NO_SM4) || OPENSSL_VERSION_NUMBER < 0x10101010L +# error "Current version of OpenSSL doesn't support SM4" +# elif OPENSSL_VERSION_NUMBER >= 0x10200000L +# include +# else +// OpenSSL 1.1.1 keeps smX.h headers in the include/crypto directory, +// and they do not get installed as part of the libssl package + +# define SM4_KEY_SCHEDULE 32 + +typedef struct SM4_KEY_st +{ + uint32_t rk[SM4_KEY_SCHEDULE]; +} SM4_KEY; + +int SM4_set_key(const uint8_t* key, SM4_KEY* ks); +void SM4_encrypt(const uint8_t* in, uint8_t* out, const SM4_KEY* ks); +void SM4_decrypt(const uint8_t* in, uint8_t* out, const SM4_KEY* ks); +# endif // OpenSSL < 1.2 +#endif // ALG_SM4 + +#if ALG_CAMELLIA +# include +#endif + +#include +#include + +//*************************************************************** +//** Links to the OpenSSL symmetric algorithms. +//*************************************************************** + +// The Crypt functions that call the block encryption function use the parameters +// in the order: +// 1) keySchedule +// 2) in buffer +// 3) out buffer +// Since open SSL uses the order in encryptoCall_t above, need to swizzle the +// values to the order required by the library. +#define SWIZZLE(keySchedule, in, out) \ + (const BYTE*)(in), (BYTE*)(out), (void*)(keySchedule) + +// Define the order of parameters to the library functions that do block encryption +// and decryption. +typedef void (*TpmCryptSetSymKeyCall_t)(const BYTE* in, BYTE* out, void* keySchedule); + +#define SYM_ALIGNMENT 4 /* libtpms: keep old value */ + +//*************************************************************** +//** Links to the OpenSSL AES code +//*************************************************************** +// Macros to set up the encryption/decryption key schedules +// +// AES: +#define TpmCryptSetEncryptKeyAES(key, keySizeInBits, schedule) \ + AES_set_encrypt_key((key), (keySizeInBits), (tpmKeyScheduleAES*)(schedule)) +#define TpmCryptSetDecryptKeyAES(key, keySizeInBits, schedule) \ + AES_set_decrypt_key((key), (keySizeInBits), (tpmKeyScheduleAES*)(schedule)) + +// Macros to alias encryption calls to specific algorithms. This should be used +// sparingly. Currently, only used by CryptSym.c and CryptRand.c +// +// When using these calls, to call the AES block encryption code, the caller +// should use: +// TpmCryptEncryptAES(SWIZZLE(keySchedule, in, out)); +#define TpmCryptEncryptAES AES_encrypt +#define TpmCryptDecryptAES AES_decrypt +#define tpmKeyScheduleAES AES_KEY + +#include "TpmToOsslSymTDES.h" // libtpms added + +//*************************************************************** +//** Links to the OpenSSL SM4 code +//*************************************************************** +// Macros to set up the encryption/decryption key schedules +#define TpmCryptSetEncryptKeySM4(key, keySizeInBits, schedule) \ + SM4_set_key((key), (tpmKeyScheduleSM4*)(schedule)) +#define TpmCryptSetDecryptKeySM4(key, keySizeInBits, schedule) \ + SM4_set_key((key), (tpmKeyScheduleSM4*)(schedule)) + +// Macros to alias encryption calls to specific algorithms. This should be used +// sparingly. +#define TpmCryptEncryptSM4 SM4_encrypt +#define TpmCryptDecryptSM4 SM4_decrypt +#define tpmKeyScheduleSM4 SM4_KEY + +//*************************************************************** +//** Links to the OpenSSL CAMELLIA code +//*************************************************************** +// Macros to set up the encryption/decryption key schedules +#define TpmCryptSetEncryptKeyCAMELLIA(key, keySizeInBits, schedule) \ + Camellia_set_key((key), (keySizeInBits), (tpmKeyScheduleCAMELLIA*)(schedule)) +#define TpmCryptSetDecryptKeyCAMELLIA(key, keySizeInBits, schedule) \ + Camellia_set_key((key), (keySizeInBits), (tpmKeyScheduleCAMELLIA*)(schedule)) + +// Macros to alias encryption calls to specific algorithms. This should be used +// sparingly. +#define TpmCryptEncryptCAMELLIA Camellia_encrypt +#define TpmCryptDecryptCAMELLIA Camellia_decrypt +#define tpmKeyScheduleCAMELLIA CAMELLIA_KEY + +// Forward reference + +typedef union tpmCryptKeySchedule_t tpmCryptKeySchedule_t; + +// This definition would change if there were something to report +#define SymLibSimulationEnd() + +#endif // SYM_LIB_DEFINED diff --git a/src/tpm2/Marshal.h b/src/tpm2/TPMCmd/tpm/cryptolibs/Ossl/include/Ossl/TpmToOsslSymTDES.h similarity index 81% rename from src/tpm2/Marshal.h rename to src/tpm2/TPMCmd/tpm/cryptolibs/Ossl/include/Ossl/TpmToOsslSymTDES.h index 65bd1e5b2..5d4abe5f1 100644 --- a/src/tpm2/Marshal.h +++ b/src/tpm2/TPMCmd/tpm/cryptolibs/Ossl/include/Ossl/TpmToOsslSymTDES.h @@ -1,6 +1,6 @@ /********************************************************************************/ /* */ -/* */ +/* Splice the OpenSSL() library into the TPM code. */ /* Written by Ken Goldman */ /* IBM Thomas J. Watson Research Center */ /* */ @@ -54,27 +54,27 @@ /* arising in any way out of use or reliance upon this specification or any */ /* information herein. */ /* */ -/* (c) Copyright IBM Corp. and others, 2023 */ +/* (c) Copyright IBM Corp. and others, 2016 - 2026 */ /* */ /********************************************************************************/ +#ifndef TPMTOOSSLSYMTDES_H +#define TPMTOOSSLSYMTDES_H -//** Introduction -// This file is used to provide the things needed by a module that uses the marshaling -// functions. It handles the variations between the marshaling choices (procedural or -// table-driven). +#include -#if TABLE_DRIVEN_MARSHAL +#define TpmCryptSetEncryptKeyTDES(key, keySizeInBits, schedule) \ + TDES_set_encrypt_key((key), (keySizeInBits), (tpmKeyScheduleTDES *)(schedule)) +#define TpmCryptSetDecryptKeyTDES(key, keySizeInBits, schedule) \ + TDES_set_encrypt_key((key), (keySizeInBits), (tpmKeyScheduleTDES *)(schedule)) -# include "TableMarshalTypes.h" +#define TpmCryptEncryptTDES TDES_encrypt +#define TpmCryptDecryptTDES TDES_decrypt +#define tpmKeyScheduleTDES DES_key_schedule -# include "TableMarshalDefines.h" - -# include "TableDrivenMarshal_fp.h" - -#else +#if ALG_TDES +# include "TpmToOsslDesSupport_fp.h" +#endif -# include "Marshal_fp.h" -# include "Unmarshal_fp.h" // libtpms added +#endif /* TPMTOOSSLSYMTDES_H */ -#endif diff --git a/src/tpm2/PrimeData.c b/src/tpm2/TPMCmd/tpm/cryptolibs/RsaRef/PrimeData.c similarity index 89% rename from src/tpm2/PrimeData.c rename to src/tpm2/TPMCmd/tpm/cryptolibs/RsaRef/PrimeData.c index 0b5f5ca2c..3993a8b97 100644 --- a/src/tpm2/PrimeData.c +++ b/src/tpm2/TPMCmd/tpm/cryptolibs/RsaRef/PrimeData.c @@ -1,62 +1,4 @@ -/********************************************************************************/ -/* */ -/* Product of all of the Primes up to 1000 */ -/* 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 #include "Tpm.h" diff --git a/src/tpm2/BnConvert.c b/src/tpm2/TPMCmd/tpm/cryptolibs/TpmBigNum/BnConvert.c similarity index 65% rename from src/tpm2/BnConvert.c rename to src/tpm2/TPMCmd/tpm/cryptolibs/TpmBigNum/BnConvert.c index e2bfd3056..7d2d5eefd 100644 --- a/src/tpm2/BnConvert.c +++ b/src/tpm2/TPMCmd/tpm/cryptolibs/TpmBigNum/BnConvert.c @@ -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; diff --git a/src/tpm2/BnEccConstants.c b/src/tpm2/TPMCmd/tpm/cryptolibs/TpmBigNum/BnEccConstants.c similarity index 67% rename from src/tpm2/BnEccConstants.c rename to src/tpm2/TPMCmd/tpm/cryptolibs/TpmBigNum/BnEccConstants.c index b473d4da9..3d4b5e738 100644 --- a/src/tpm2/BnEccConstants.c +++ b/src/tpm2/TPMCmd/tpm/cryptolibs/TpmBigNum/BnEccConstants.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 /*(Auto-generated) * Created by TpmStructures; Version 4.4 Mar 26, 2019 @@ -65,7 +7,7 @@ #include "TpmBigNum.h" //#include "Tpm.h" // TODO_RENAME_INC_FOLDER:private refers to the TPM_CoreLib private headers -#include "OIDs.h" +#include #if ALG_ECC @@ -94,17 +36,17 @@ # 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 // a memory format desired by the user. This file itself is never used alone. -# include "EccConstantData.inl" +# include // now define the TPMBN_ECC_CURVE_CONSTANTS objects for the known curves diff --git a/src/tpm2/BnMath.c b/src/tpm2/TPMCmd/tpm/cryptolibs/TpmBigNum/BnMath.c similarity index 83% rename from src/tpm2/BnMath.c rename to src/tpm2/TPMCmd/tpm/cryptolibs/TpmBigNum/BnMath.c index 34690c251..bfd917007 100644 --- a/src/tpm2/BnMath.c +++ b/src/tpm2/TPMCmd/tpm/cryptolibs/TpmBigNum/BnMath.c @@ -1,62 +1,4 @@ -/********************************************************************************/ -/* */ -/* Simple Operations on Big Numbers */ -/* 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 // The simulator code uses the canonical form whenever possible in order to make @@ -89,7 +31,6 @@ #include "Tpm.h" // libtpms: for CryptRand.h #include "TpmMath_Util_fp.h" // libtpms: added #include "TpmBigNum.h" -extern BOOL g_inFailureMode; // can't use global.h because we can't use tpm.h // A constant value of zero as a stand in for NULL bigNum values const bignum_t BnConstZero = {1, 0, {0}}; diff --git a/src/tpm2/BnMemory.c b/src/tpm2/TPMCmd/tpm/cryptolibs/TpmBigNum/BnMemory.c similarity index 52% rename from src/tpm2/BnMemory.c rename to src/tpm2/TPMCmd/tpm/cryptolibs/TpmBigNum/BnMemory.c index 280327778..2b8c7785a 100644 --- a/src/tpm2/BnMemory.c +++ b/src/tpm2/TPMCmd/tpm/cryptolibs/TpmBigNum/BnMemory.c @@ -1,63 +1,4 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: BnMemory.c 1262 2018-07-11 21:03:43Z 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 */ -/* */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause //** Introduction // This file contains the memory setup functions used by the bigNum functions diff --git a/src/tpm2/TPMCmd/tpm/cryptolibs/TpmBigNum/TpmBigNum.h b/src/tpm2/TPMCmd/tpm/cryptolibs/TpmBigNum/TpmBigNum.h new file mode 100644 index 000000000..3b64d20f7 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/cryptolibs/TpmBigNum/TpmBigNum.h @@ -0,0 +1,19 @@ +// SPDX-License-Identifier: BSD-2-Clause + +//** Introduction +// This file contains the headers necessary to build the tpm big num library. +// TODO_RENAME_INC_FOLDER: public refers to the TPM_CoreLib public headers +#include +#include +// TODO_RENAME_INC_FOLDER: private refers to the TPM_CoreLib private(protected) headers +#include +#include // required for TpmFail_fp.h +#include +#include // requires capabilities & GpMacros +#include +#include "BnSupport_Interface.h" +#include "BnConvert_fp.h" +#include "BnMemory_fp.h" +#include "BnMath_fp.h" +#include "BnUtil_fp.h" +#include diff --git a/src/tpm2/TpmBigNumThunks.c b/src/tpm2/TPMCmd/tpm/cryptolibs/TpmBigNum/TpmBigNumThunks.c similarity index 82% rename from src/tpm2/TpmBigNumThunks.c rename to src/tpm2/TPMCmd/tpm/cryptolibs/TpmBigNum/TpmBigNumThunks.c index f27254e36..add3b897c 100644 --- a/src/tpm2/TpmBigNumThunks.c +++ b/src/tpm2/TPMCmd/tpm/cryptolibs/TpmBigNum/TpmBigNumThunks.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 // This file contains BN Thunks between the MathInterfaceLibrary types and the diff --git a/src/tpm2/crypto/openssl/BnConvert_fp.h b/src/tpm2/TPMCmd/tpm/cryptolibs/TpmBigNum/include/BnConvert_fp.h similarity index 50% rename from src/tpm2/crypto/openssl/BnConvert_fp.h rename to src/tpm2/TPMCmd/tpm/cryptolibs/TpmBigNum/include/BnConvert_fp.h index db8108463..b0321a1cd 100644 --- a/src/tpm2/crypto/openssl/BnConvert_fp.h +++ b/src/tpm2/TPMCmd/tpm/cryptolibs/TpmBigNum/include/BnConvert_fp.h @@ -1,62 +1,4 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2016 - 2023 */ -/* */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause /*(Auto-generated) * Created by TpmPrototypes; Version 3.0 July 18, 2017 diff --git a/src/tpm2/crypto/openssl/BnMath_fp.h b/src/tpm2/TPMCmd/tpm/cryptolibs/TpmBigNum/include/BnMath_fp.h similarity index 56% rename from src/tpm2/crypto/openssl/BnMath_fp.h rename to src/tpm2/TPMCmd/tpm/cryptolibs/TpmBigNum/include/BnMath_fp.h index 0f6609af1..87e6cac2d 100644 --- a/src/tpm2/crypto/openssl/BnMath_fp.h +++ b/src/tpm2/TPMCmd/tpm/cryptolibs/TpmBigNum/include/BnMath_fp.h @@ -1,62 +1,4 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2016 - 2023 */ -/* */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause /*(Auto-generated) * Created by TpmPrototypes; Version 3.0 July 18, 2017 diff --git a/src/tpm2/TPMCmd/tpm/cryptolibs/TpmBigNum/include/BnMemory_fp.h b/src/tpm2/TPMCmd/tpm/cryptolibs/TpmBigNum/include/BnMemory_fp.h new file mode 100644 index 000000000..e4414aa83 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/cryptolibs/TpmBigNum/include/BnMemory_fp.h @@ -0,0 +1,62 @@ +// SPDX-License-Identifier: BSD-2-Clause + +/*(Auto-generated) + * Created by TpmPrototypes; Version 3.0 July 18, 2017 + * Date: Mar 28, 2019 Time: 08:25:18PM + */ + +#ifndef _BN_MEMORY_FP_H_ +#define _BN_MEMORY_FP_H_ + +//*** BnSetTop() +// This function is used when the size of a bignum_t is changed. It +// makes sure that the unused words are set to zero and that any significant +// words of zeros are eliminated from the used size indicator. +LIB_EXPORT bigNum BnSetTop(bigNum bn, // IN/OUT: number to clean + crypt_uword_t top // IN: the new top +); + +#if 0 /* libtpms added */ +//*** BnClearTop() +// This function will make sure that all unused words are zero. +LIB_EXPORT bigNum BnClearTop(bigNum bn); +#endif /* libtpms added */ + +//*** BnInitializeWord() +// This function is used to initialize an allocated bigNum with a word value. The +// bigNum does not have to be allocated with a single word. +LIB_EXPORT bigNum BnInitializeWord(bigNum bn, // IN: + crypt_uword_t allocated, // IN: + crypt_uword_t word // IN: +); + +//*** BnInit() +// This function initializes a stack allocated bignum_t. It initializes +// 'allocated' and 'size' and zeros the words of 'd'. +LIB_EXPORT bigNum BnInit(bigNum bn, crypt_uword_t allocated); + +//*** BnCopy() +// Function to copy a bignum_t. If the output is NULL, then +// nothing happens. If the input is NULL, the output is set +// to zero. +LIB_EXPORT BOOL BnCopy(bigNum out, bigConst in); +#if ALG_ECC + +#if 0 /* libtpms added */ +//*** BnPointCopy() +// Function to copy a bn point. +LIB_EXPORT BOOL BnPointCopy(bigPoint pOut, pointConst pIn); +#endif /* libtpms added */ + +//*** BnInitializePoint() +// This function is used to initialize a point structure with the addresses +// of the coordinates. +LIB_EXPORT bn_point_t* BnInitializePoint( + bigPoint p, // OUT: structure to receive pointers + bigNum x, // IN: x coordinate + bigNum y, // IN: y coordinate + bigNum z // IN: x coordinate +); +#endif // ALG_ECC + +#endif // _BN_MEMORY_FP_H_ diff --git a/src/tpm2/BnSupport_Interface.h b/src/tpm2/TPMCmd/tpm/cryptolibs/TpmBigNum/include/BnSupport_Interface.h similarity index 59% rename from src/tpm2/BnSupport_Interface.h rename to src/tpm2/TPMCmd/tpm/cryptolibs/TpmBigNum/include/BnSupport_Interface.h index 5928a02f5..e99cbe0fb 100644 --- a/src/tpm2/BnSupport_Interface.h +++ b/src/tpm2/TPMCmd/tpm/cryptolibs/TpmBigNum/include/BnSupport_Interface.h @@ -1,62 +1,4 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2023 */ -/* */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause //** Introduction // Prototypes for functions the bignum library requires @@ -78,8 +20,8 @@ #ifndef BN_SUPPORT_INTERFACE_H #define BN_SUPPORT_INTERFACE_H // TODO_RENAME_INC_FOLDER:private refers to the TPM_CoreLib private headers -#include "GpMacros.h" -#include "CryptoInterface.h" +#include "tpm_public/GpMacros.h" +#include #include "BnValues.h" //** BnSupportLibInit() diff --git a/src/tpm2/TPMCmd/tpm/cryptolibs/TpmBigNum/include/BnUtil_fp.h b/src/tpm2/TPMCmd/tpm/cryptolibs/TpmBigNum/include/BnUtil_fp.h new file mode 100644 index 000000000..be35e5885 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/cryptolibs/TpmBigNum/include/BnUtil_fp.h @@ -0,0 +1,8 @@ +// SPDX-License-Identifier: BSD-2-Clause + +//** Introduction +// Utility functions to support TpmBigNum library +#ifndef _BNUTIL_FP_H_ +#define _BNUTIL_FP_H_ + +#endif // _BNUTIL_FP_H_ diff --git a/src/tpm2/crypto/openssl/BnValues.h b/src/tpm2/TPMCmd/tpm/cryptolibs/TpmBigNum/include/BnValues.h similarity index 64% rename from src/tpm2/crypto/openssl/BnValues.h rename to src/tpm2/TPMCmd/tpm/cryptolibs/TpmBigNum/include/BnValues.h index afbae7e3d..301bb91d2 100644 --- a/src/tpm2/crypto/openssl/BnValues.h +++ b/src/tpm2/TPMCmd/tpm/cryptolibs/TpmBigNum/include/BnValues.h @@ -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 @@ -84,21 +26,21 @@ #ifndef _BN_NUMBERS_H #define _BN_NUMBERS_H // TODO_RENAME_INC_FOLDER:private refers to the TPM_CoreLib private headers -#include "TpmAlgorithmDefines.h" -#include "GpMacros.h" // required for TpmFail_fp.h -#include "Capabilities.h" -#include "TpmTypes.h" // requires capabilities & GpMacros +#include +#include // required for TpmFail_fp.h +#include +#include // requires capabilities & GpMacros // These are the basic big number formats. This is convertible to the library- // 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) diff --git a/src/tpm2/TPMCmd/tpm/cryptolibs/TpmBigNum/include/TpmBigNum/TpmToTpmBigNumMath.h b/src/tpm2/TPMCmd/tpm/cryptolibs/TpmBigNum/include/TpmBigNum/TpmToTpmBigNumMath.h new file mode 100644 index 000000000..24a2bf0b7 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/cryptolibs/TpmBigNum/include/TpmBigNum/TpmToTpmBigNumMath.h @@ -0,0 +1,62 @@ +// SPDX-License-Identifier: BSD-2-Clause + +//** Introduction +// This file contains OpenSSL specific functions called by TpmBigNum library to provide +// the TpmBigNum + OpenSSL math support. + +#ifndef _TPM_TO_TPMBIGNUM_MATH_H_ +#define _TPM_TO_TPMBIGNUM_MATH_H_ + +#ifdef MATH_LIB_DEFINED +# error only one primary math library allowed +#endif +#define MATH_LIB_DEFINED + +// indicate the TPMBIGNUM library is active +#define MATH_LIB_TPMBIGNUM + +// TODO_RENAME_INC_FOLDER: private refers to the TPM_CoreLib private headers +#include // required for TpmFail_fp.h +#include +#include // requires capabilities & GpMacros +#include "BnValues.h" + +#ifndef LIB_INCLUDE +# error include ordering error, LIB_INCLUDE not defined +#endif +#ifndef BN_MATH_LIB +# error BN_MATH_LIB not defined, required to provide BN library functions. +#endif + +#if defined(CRYPT_CURVE_INITIALIZED) || defined(CRYPT_CURVE_FREE) +#error include ordering error, expected CRYPT_CURVE_INITIALIZED & CRYPT_CURVE_FREE to be undefined. +#endif + +// Add support library dependent definitions. +// For TpmBigNum, we expect bigCurveData to be a defined type. +#include LIB_INCLUDE(BnTo, BN_MATH_LIB, Math) + +#include "BnConvert_fp.h" +#include "BnMath_fp.h" +#include "BnMemory_fp.h" +#include "BnSupport_Interface.h" + +// Define macros and types necessary for the math library abstraction layer +// Create a data object backing a Crypt_Int big enough for the given number of +// data bits +#define CRYPT_INT_BUF(buftypename, bits) BN_STRUCT(buftypename, bits) + +// Create a data object backing a Crypt_Point big enough for the given number of +// data bits, per coordinate +#define CRYPT_POINT_BUF(buftypename, bits) BN_POINT_BUF(buftypename, bits) + +// Create an instance of a data object underlying Crypt_EccCurve on the stack +// sufficient for given bit size. In our case, all are the same size. +#define CRYPT_CURVE_BUF(buftypename, max_size_in_bits) bigCurveData + +// now include the math library functional interface and instantiate the +// Crypt_Int & related types +// TODO_RENAME_INC_FOLDER: This should have a Tpm_Cryptolib_Common component prefix. +#include + +#endif // _TPM_TO_TPMBIGNUM_MATH_H_ diff --git a/src/tpm2/TPMCmd/tpm/cryptolibs/common/include/CryptoInterface.h b/src/tpm2/TPMCmd/tpm/cryptolibs/common/include/CryptoInterface.h new file mode 100644 index 000000000..a342f01cb --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/cryptolibs/common/include/CryptoInterface.h @@ -0,0 +1,30 @@ +// SPDX-License-Identifier: BSD-2-Clause + +//** Introduction +// +// This file contains prototypes that are common to all TPM crypto interfaces. +// +#ifndef CRYPTO_INTERFACE_H +#define CRYPTO_INTERFACE_H + +#include "TpmConfiguration/TpmBuildSwitches.h" + +#if SIMULATION && CRYPTO_LIB_REPORTING + +typedef struct crypto_impl_description +{ + // The name of the crypto library, ASCII encoded. + char name[32]; + // The version of the crypto library, ASCII encoded. + char version[32]; +} _CRYPTO_IMPL_DESCRIPTION; + +// When building the simulator, the plugged-in crypto libraries can report its +// version information by implementing these interfaces. +void _crypto_GetSymImpl(_CRYPTO_IMPL_DESCRIPTION* result); +void _crypto_GetHashImpl(_CRYPTO_IMPL_DESCRIPTION* result); +void _crypto_GetMathImpl(_CRYPTO_IMPL_DESCRIPTION* result); + +#endif // SIMULATION && CRYPTO_LIB_REPORTING + +#endif // CRYPTO_INTERFACE_H diff --git a/src/tpm2/EccConstantData.inl b/src/tpm2/TPMCmd/tpm/cryptolibs/common/include/EccConstantData.inl similarity index 80% rename from src/tpm2/EccConstantData.inl rename to src/tpm2/TPMCmd/tpm/cryptolibs/common/include/EccConstantData.inl index e444b66b0..c19a8b039 100644 --- a/src/tpm2/EccConstantData.inl +++ b/src/tpm2/TPMCmd/tpm/cryptolibs/common/include/EccConstantData.inl @@ -1,97 +1,5 @@ -/********************************************************************************/ -/* */ -/* */ -/* 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 -/* 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 diff --git a/src/tpm2/MathLibraryInterface.h b/src/tpm2/TPMCmd/tpm/cryptolibs/common/include/MathLibraryInterface.h similarity index 82% rename from src/tpm2/MathLibraryInterface.h rename to src/tpm2/TPMCmd/tpm/cryptolibs/common/include/MathLibraryInterface.h index 87cb02973..5a3d0cd44 100644 --- a/src/tpm2/MathLibraryInterface.h +++ b/src/tpm2/TPMCmd/tpm/cryptolibs/common/include/MathLibraryInterface.h @@ -1,62 +1,4 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2023 */ -/* */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause //** Introduction // @@ -354,7 +296,7 @@ LIB_EXPORT const Crypt_EccCurve* ExtEcc_CurveInitialize(Crypt_EccCurve* E, //*** ExtEcc_CurveFree() // This function will free the allocated components of the curve and end the // frame in which the curve data exists. -// WARNING: Not guaranteed to be called in presence of LONGJMP. +// WARNING: Not guaranteed to be called in presence of LONGJMP_SUPPORTED. LIB_EXPORT void ExtEcc_CurveFree(const Crypt_EccCurve* E); // ################# diff --git a/src/tpm2/TPMCmd/tpm/cryptolibs/common/include/MathLibraryInterfaceTypes.h b/src/tpm2/TPMCmd/tpm/cryptolibs/common/include/MathLibraryInterfaceTypes.h new file mode 100644 index 000000000..f9e3cf2eb --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/cryptolibs/common/include/MathLibraryInterfaceTypes.h @@ -0,0 +1,86 @@ +// SPDX-License-Identifier: BSD-2-Clause + +//** Introduction +// This file contains the declaration and initialization macros for +// low-level cryptographic buffer types. This requires the underlying +// Crypto library to have already defined the CRYPT_INT_BUF family of +// macros. See tpm_crypto_lib.md for details. + +#ifndef MATH_LIBRARY_INTERFACE_TYPES_H +#define MATH_LIBRARY_INTERFACE_TYPES_H + +#ifndef CRYPT_INT_BUF +# error CRYPT_INT_BUF must be defined before including this file. +#endif +#ifndef CRYPT_POINT_BUF +# error CRYPT_POINT_BUF must be defined before including this file. +#endif +#ifndef CRYPT_CURVE_BUF +# error CRYPT_CURVE_BUF must be defined before including this file. +#endif + +// Crypt_Int underlying types Crypt_Int is an abstract type that is used as a +// pointer. The underlying math library is expected to be able to find the +// actual allocated size for a given Crypt_Int object given a pointer to it, and +// therefore we typedef here to a size 1 (smallest possible). +typedef CRYPT_INT_BUF(one, 1) Crypt_Int; +typedef CRYPT_POINT_BUF(pointone, 1) Crypt_Point; +typedef CRYPT_CURVE_BUF(curvebuft, MAX_ECC_KEY_BITS) Crypt_EccCurve; + +// produces bare typedef ci__t +#define CRYPT_INT_TYPE(typename, bits) \ + typedef CRYPT_INT_BUF(ci_##typename##_buf_t, bits) ci_##typename##_t + +// produces allocated `Crypt_Int* varname` backed by a +// stack buffer named `_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); + +// produces initialized `Crypt_Int* varname = (TPM2B) initializer` backed by a +// stack buffer named `_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); + +// 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) + +// 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); + +// 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) + +/* 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_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 diff --git a/src/tpm2/TPMCmd/tpm/include/platform_interface/pcrstruct.h b/src/tpm2/TPMCmd/tpm/include/platform_interface/pcrstruct.h new file mode 100644 index 000000000..34efcfa2d --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/platform_interface/pcrstruct.h @@ -0,0 +1,99 @@ +// SPDX-License-Identifier: BSD-2-Clause + +// +// This file defines the PCR and PCR_Attributes structures and +// related interface functions +// + +#ifndef _PCRSTRUCT_H_ +#define _PCRSTRUCT_H_ + +#include +#include +#include + +// a single PCR +typedef struct +{ +#if ALG_SHA1 + BYTE Sha1Pcr[SHA1_DIGEST_SIZE]; +#endif +#if ALG_SHA256 + BYTE Sha256Pcr[SHA256_DIGEST_SIZE]; +#endif +#if ALG_SHA384 + BYTE Sha384Pcr[SHA384_DIGEST_SIZE]; // libtpms: appended 'pcr' +#endif +#if ALG_SHA512 + BYTE Sha512Pcr[SHA512_DIGEST_SIZE]; // libtpms: appended 'pcr' +#endif +#if ALG_SM3_256 + BYTE Sm3_256[SM3_256_DIGEST_SIZE]; +#endif +#if ALG_SHA3_256 + BYTE Sha3_256[SHA3_256_DIGEST_SIZE]; +#endif +#if ALG_SHA3_384 + BYTE Sha3_384[SHA3_384_DIGEST_SIZE]; +#endif +#if ALG_SHA3_512 + BYTE Sha3_512[SHA3_512_DIGEST_SIZE]; +#endif +} PCR; + +// see the comments below for supportsPolicyAuth to explain this +#define MAX_PCR_GROUP_BITS 3 + +typedef struct +{ + // SET if the PCR value should be saved in state save + unsigned int stateSave : 1; + + // SET if the PCR is part of the "TCB group", causes the PCR counter not to increment + unsigned int doNotIncrementPcrCounter : 1; + + // PCRs may support policy or auth-value authorization. + // + // Such authorization values, if supported, are set by + // TPM2_PCR_SetAuthPolicy and/or TPM2_PCR_SetAuthValue. + // + // PCRs that share the same policy/auth value are said to be in a "group". + // PCRs that don't support authorization are said to be in group Zero. + // + // Group numbers are only used internally to indicate which PCRs share an + // authorization value. IOW the TPM client cannot refer to PCRs by group + // number; the range of group numbers is implementation defined. zero + // indicates the PCR doesn't support policy or auth verification. + // + // The size of this field must be large enough to support + // NUM_POLICY_PCR_GROUP & NUM_AUTHVALUE_PCR_GROUP; the maximum number of groups + // actually supported by this build of the core library. + // + // The number of bits allocated here does not control the number of groups, + // but there is a static assert that the number of bits here is large + // enough. + unsigned int policyAuthGroup : MAX_PCR_GROUP_BITS; + unsigned int authValuesGroup : MAX_PCR_GROUP_BITS; + + // these bitfields indicating the localities that can + // reset or extend this PCR. A SET bit indicates the PCR can + // be extended or reset from that locality. The low-order bit in + // each field is locality zero, and the high-order bit is locality 4. + unsigned int resetLocality : 5; + unsigned int extendLocality : 5; +} PCR_Attributes; + +// Get pointer to particular PCR from array if that PCR is allocated. +// otherwise returns NULL +BYTE* GetPcrPointerIfAllocated(PCR* pPcrArray, + TPM_ALG_ID alg, // IN: algorithm for bank + UINT32 pcrNumber // IN: PCR number +); + +// get a PCR pointer from the TPM's internal list, if it's allocated +// otherwise NULL +BYTE* GetPcrPointer(TPM_ALG_ID alg, // IN: algorithm for bank + UINT32 pcrNumber // IN: PCR number +); + +#endif diff --git a/src/tpm2/TPMCmd/tpm/include/platform_interface/platform_to_tpm_interface.h b/src/tpm2/TPMCmd/tpm/include/platform_interface/platform_to_tpm_interface.h new file mode 100644 index 000000000..9fb0f2250 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/platform_interface/platform_to_tpm_interface.h @@ -0,0 +1,10 @@ +// SPDX-License-Identifier: BSD-2-Clause + +#include +#include +#include +#include +#include +#include +// TODO_RENAME_INC_FOLDER: public refers to the TPM_CoreLib public headers +#include diff --git a/src/tpm2/TPMCmd/tpm/include/platform_interface/prototypes/ExecCommand_fp.h b/src/tpm2/TPMCmd/tpm/include/platform_interface/prototypes/ExecCommand_fp.h new file mode 100644 index 000000000..b858b0ddb --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/platform_interface/prototypes/ExecCommand_fp.h @@ -0,0 +1,54 @@ +// SPDX-License-Identifier: BSD-2-Clause + +/*(Auto-generated) + * Created by TpmPrototypes; Version 3.0 July 18, 2017 + * Date: Mar 28, 2019 Time: 08:25:19PM + */ + +#ifndef _EXEC_COMMAND_FP_H_ +#define _EXEC_COMMAND_FP_H_ + +//** ExecuteCommand() +// +// The function performs the following steps. +// +// a) Parses the command header from input buffer. +// b) Calls ParseHandleBuffer() to parse the handle area of the command. +// c) Validates that each of the handles references a loaded entity. +// d) Calls ParseSessionBuffer () to: +// 1) unmarshal and parse the session area; +// 2) check the authorizations; and +// 3) when necessary, decrypt a parameter. +// e) Calls CommandDispatcher() to: +// 1) unmarshal the command parameters from the command buffer; +// 2) call the routine that performs the command actions; and +// 3) marshal the responses into the response buffer. +// f) If any error occurs in any of the steps above create the error response +// and return. +// g) Calls BuildResponseSession() to: +// 1) when necessary, encrypt a parameter +// 2) build the response authorization sessions +// 3) update the audit sessions and nonces +// h) Calls BuildResponseHeader() to complete the construction of the response. +// +// 'responseSize' is set by the caller to the maximum number of bytes available in +// the output buffer. ExecuteCommand will adjust the value and return the number +// of bytes placed in the buffer. +// +// 'response' is also set by the caller to indicate the buffer into which +// ExecuteCommand is to place the response. +// +// 'request' and 'response' may point to the same buffer +// +// Note: The failure processing has been moved to the +// platform-specific code. When the TPM code encounters an unrecoverable failure, it +// will call _plat__Fail() and call _plat__InFailureMode() to query failure mode. +// +LIB_EXPORT void ExecuteCommand( + uint32_t requestSize, // IN: command buffer size + unsigned char* request, // IN: command buffer + uint32_t* responseSize, // IN/OUT: response buffer size + unsigned char** response // IN/OUT: response buffer +); + +#endif // _EXEC_COMMAND_FP_H_ diff --git a/src/tpm2/TPMCmd/tpm/include/platform_interface/prototypes/Manufacture_fp.h b/src/tpm2/TPMCmd/tpm/include/platform_interface/prototypes/Manufacture_fp.h new file mode 100644 index 000000000..94dd4befe --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/platform_interface/prototypes/Manufacture_fp.h @@ -0,0 +1,50 @@ +// SPDX-License-Identifier: BSD-2-Clause + +#ifndef _MANUFACTURE_FP_H_ +#define _MANUFACTURE_FP_H_ + +//*** TPM_Manufacture() +// This function initializes the TPM values in preparation for the TPM's first +// use. This function will fail if previously called. The TPM can be re-manufactured +// by calling TPM_Teardown() first and then calling this function again. +// NV must be enabled first (typically with NvPowerOn() via _TPM_Init) +// +// return type: int +// -2 NV System not available +// -1 FAILURE - System is incorrectly compiled. +// 0 success +// 1 manufacturing process previously performed +// returns +#define MANUF_NV_NOT_READY (-2) +#define MANUF_INVALID_CONFIG (-1) +#define MANUF_OK 0 +#define MANUF_ALREADY_DONE 1 +// params +#define MANUF_FIRST_TIME 1 +#define MANUF_REMANUFACTURE 0 +LIB_EXPORT int TPM_Manufacture( + int firstTime, // IN: indicates if this is the first call from + // main() + const char *profile // libtpms added +); + +//*** TPM_TearDown() +// This function prepares the TPM for re-manufacture. It should not be implemented +// in anything other than a simulated TPM. +// +// In this implementation, all that is needs is to stop the cryptographic units +// and set a flag to indicate that the TPM can be re-manufactured. This should +// be all that is necessary to start the manufacturing process again. +// Return Type: int +// 0 success +// 1 TPM not previously manufactured +#define TEARDOWN_OK 0 +#define TEARDOWN_NOTHINGDONE 1 +LIB_EXPORT int TPM_TearDown(void); + +//*** TpmEndSimulation() +// This function is called at the end of the simulation run. It is used to provoke +// printing of any statistics that might be needed. +LIB_EXPORT void TpmEndSimulation(void); + +#endif // _MANUFACTURE_FP_H_ diff --git a/src/tpm2/TPMCmd/tpm/include/platform_interface/prototypes/_TPM_Hash_Data_fp.h b/src/tpm2/TPMCmd/tpm/include/platform_interface/prototypes/_TPM_Hash_Data_fp.h new file mode 100644 index 000000000..f8ee63fcf --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/platform_interface/prototypes/_TPM_Hash_Data_fp.h @@ -0,0 +1,18 @@ +// SPDX-License-Identifier: BSD-2-Clause + +/*(Auto-generated) + * Created by TpmPrototypes; Version 3.0 July 18, 2017 + * Date: Mar 28, 2019 Time: 08:25:19PM + */ + +#ifndef __TPM_HASH_DATA_FP_H_ +#define __TPM_HASH_DATA_FP_H_ + +// This function is called to process a _TPM_Hash_Data indication. Returns FALSE +//on failure. If FALSE is returned caller should check for failure mode, (not +//all failures are fatal) +LIB_EXPORT BOOL _TPM_Hash_Data(uint32_t dataSize, // IN: size of data to be extend + unsigned char* data // IN: data buffer +); + +#endif // __TPM_HASH_DATA_FP_H_ diff --git a/src/tpm2/TPMCmd/tpm/include/platform_interface/prototypes/_TPM_Hash_End_fp.h b/src/tpm2/TPMCmd/tpm/include/platform_interface/prototypes/_TPM_Hash_End_fp.h new file mode 100644 index 000000000..03cc7480a --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/platform_interface/prototypes/_TPM_Hash_End_fp.h @@ -0,0 +1,16 @@ +// SPDX-License-Identifier: BSD-2-Clause + +/*(Auto-generated) + * Created by TpmPrototypes; Version 3.0 July 18, 2017 + * Date: Mar 28, 2019 Time: 08:25:19PM + */ + +#ifndef __TPM_HASH_END_FP_H_ +#define __TPM_HASH_END_FP_H_ + +// This function is called to process a _TPM_Hash_End indication. Returns FALSE +// on failure. If FALSE is returned caller should check for failure mode, (not +// all failures are fatal) +LIB_EXPORT BOOL _TPM_Hash_End(void); + +#endif // __TPM_HASH_END_FP_H_ diff --git a/src/tpm2/TPMCmd/tpm/include/platform_interface/prototypes/_TPM_Hash_Start_fp.h b/src/tpm2/TPMCmd/tpm/include/platform_interface/prototypes/_TPM_Hash_Start_fp.h new file mode 100644 index 000000000..d84d55c39 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/platform_interface/prototypes/_TPM_Hash_Start_fp.h @@ -0,0 +1,16 @@ +// SPDX-License-Identifier: BSD-2-Clause + +/*(Auto-generated) + * Created by TpmPrototypes; Version 3.0 July 18, 2017 + * Date: Mar 28, 2019 Time: 08:25:19PM + */ + +#ifndef __TPM_HASH_START_FP_H_ +#define __TPM_HASH_START_FP_H_ + +// This function is called to process a _TPM_Hash_Start indication. +// It returns FALSE if the indication cannot be handled, and the TPM +// will be in FailureMode. +LIB_EXPORT BOOL _TPM_Hash_Start(void); + +#endif // __TPM_HASH_START_FP_H_ diff --git a/src/tpm2/TPMCmd/tpm/include/platform_interface/prototypes/_TPM_Init_fp.h b/src/tpm2/TPMCmd/tpm/include/platform_interface/prototypes/_TPM_Init_fp.h new file mode 100644 index 000000000..e84faf3cc --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/platform_interface/prototypes/_TPM_Init_fp.h @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: BSD-2-Clause + +/*(Auto-generated) + * Created by TpmPrototypes; Version 3.0 July 18, 2017 + * Date: Mar 28, 2019 Time: 08:25:19PM + */ + +#ifndef __TPM_INIT_FP_H_ +#define __TPM_INIT_FP_H_ + +// This function is used to process a _TPM_Init indication. +LIB_EXPORT void _TPM_Init(void); + +#endif // __TPM_INIT_FP_H_ diff --git a/src/tpm2/TPMCmd/tpm/include/platform_interface/prototypes/platform_failure_mode_fp.h b/src/tpm2/TPMCmd/tpm/include/platform_interface/prototypes/platform_failure_mode_fp.h new file mode 100644 index 000000000..0e1eb7166 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/platform_interface/prototypes/platform_failure_mode_fp.h @@ -0,0 +1,56 @@ +// SPDX-License-Identifier: BSD-2-Clause + +// Failure mode platform functions +// The platform is responsible for tracking and handling failure +// mode, and for returning the data for GetTestResult when in +// failure mode. This allows the Core TPM library to implement +// the basic command handling while making minimal assumptions +// about the data the platform will track, and also, critically, +// allows the platform to put the TPM into failure mode due to +// it's own internal failures without forcing a dependency on the +// tpm library's internal error handling macros and functions +// throughout unrelated platform code + +#ifndef _PLATFORM_FAILURE_MODE_FP_H_ +#define _PLATFORM_FAILURE_MODE_FP_H_ + +//***_plat__Fail() +// A function for the TPM to call the platform to indicate the +// TPM code has detected a failure. +LIB_EXPORT NORETURN_IF_LONGJMP void _plat__Fail( +#if FAIL_TRACE + const char* function, + int line, +#endif + uint64_t locationCode, + int failureCode); + +// Indicates to the TPM Library that a failure has occurred. +// This is REQUIRED to return true after any call to _plat__Fail. +// It MAY return true for any other reason the platform deems appropriate. +LIB_EXPORT BOOL _plat__InFailureMode(void); + +LIB_EXPORT void _plat__SetInFailureMode(BOOL inFailureMode); // libtpms added begin +LIB_EXPORT void _plat__SetFailureModeParameters( +#if FAIL_TRACE + const char* function, + int line, +#endif + int failureCode); // libtpms added end + +// The failure reason. Values are vendor defined by the TpmConfiguration +// project in the TpmProfile_ErrorCodes.h header +LIB_EXPORT UINT32 _plat__GetFailureCode(void); + +// A vendor defined 64-bit code indicating where the failure occured. +// this is defined by the return of the CODELOCATION() macro which may be +// defined in TpmConfiguration. If not defined, returns zero. +LIB_EXPORT uint64_t _plat__GetFailureLocation(void); + +// Provides human readable failure information. Not necessarily suitable for production. +#if FAIL_TRACE +LIB_EXPORT const char* _plat__GetFailureFunctionName(void); +LIB_EXPORT uint32_t _plat__GetFailureLine(void); +#endif + +#endif // _PLATFORM_FAILURE_MODE_FP_H_ diff --git a/src/tpm2/TPMCmd/tpm/include/platform_interface/prototypes/platform_init_fp.h b/src/tpm2/TPMCmd/tpm/include/platform_interface/prototypes/platform_init_fp.h new file mode 100644 index 000000000..b30a9014f --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/platform_interface/prototypes/platform_init_fp.h @@ -0,0 +1,20 @@ +// SPDX-License-Identifier: BSD-2-Clause + +// Platform Initialization Functions +// Notify the platform the TPM is processing TpmInit. +// These are opportunities for the Platform to initialize its own data. +// Usually these are only called once (and could therefore be omitted by +// static variable initialization, but are useful in unit testing. + +#ifndef _PLATFORM_INIT_FP_H_ +#define _PLATFORM_INIT_FP_H_ + +// Notification at very start of TPM_Init(); +LIB_EXPORT void _plat__StartTpmInit(void); + +// Notification at very end of a SUCCESSFUL TPM_Init(); +// if the TPM has failed TpmInit (and entered failure mode) +// this will not be called +LIB_EXPORT void _plat__EndOkTpmInit(void); + +#endif // _PLATFORM_INIT_FP_H_ diff --git a/src/tpm2/TPMCmd/tpm/include/platform_interface/prototypes/platform_pcr_fp.h b/src/tpm2/TPMCmd/tpm/include/platform_interface/prototypes/platform_pcr_fp.h new file mode 100644 index 000000000..b06425539 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/platform_interface/prototypes/platform_pcr_fp.h @@ -0,0 +1,44 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// platform PCR functions called by the TPM library + +#ifndef _PLATFORM_PCR_FP_H_ +#define _PLATFORM_PCR_FP_H_ + +#include +#include +#include + +// return the number of PCRs the platform recognizes for GetPcrInitializationAttributes. +// PCRs are numbered starting at zero. +// Note: The TPM Library will enter failure mode if this number doesn't match +// IMPLEMENTATION_PCR. +UINT32 _platPcr__NumberOfPcrs(void); + +// return the initialization attributes of a given PCR. +// pcrNumber expected to be in [0, _platPcr__NumberOfPcrs) +// returns the attributes for PCR[0] if the requested pcrNumber is out of range. +// Note this returns a structure by-value, which is fast because the structure is +// a bitfield. +PCR_Attributes _platPcr__GetPcrInitializationAttributes(UINT32 pcrNumber); + +// Fill a given buffer with the PCR initialization value for a particular PCR and hash +// combination, and return its length. If the platform doesn't have a value, then +// the result size is expected to be zero, and the rfunction will return TPM_RC_PCR. +// If a valid is not available, then the core TPM library will ignore the value and +// treat it as non-existant and provide a default. +// If the buffer is not large enough for a pcr consistent with pcrAlg, then the +// platform will return TPM_RC_FAILURE. +TPM_RC _platPcr__GetInitialValueForPcr( + UINT32 pcrNumber, // IN: PCR to be initialized + TPM_ALG_ID pcrAlg, // IN: Algorithm of the PCR Bank being initialized + BYTE startupLocality, // IN: locality where startup is being called from + BYTE* pcrBuffer, // OUT: buffer to put PCR initialization value into + uint16_t bufferSize, // IN: maximum size of value buffer can hold + uint16_t* pcrLength); // OUT: size of initialization value returned in pcrBuffer + +// should the given PCR algorithm default to active in a new TPM? +BOOL _platPcr_IsPcrBankDefaultActive(TPM_ALG_ID pcrAlg); + +#endif // _PLATFORM_PCR_FP_H_ diff --git a/src/tpm2/TPMCmd/tpm/include/platform_interface/prototypes/platform_virtual_nv_fp.h b/src/tpm2/TPMCmd/tpm/include/platform_interface/prototypes/platform_virtual_nv_fp.h new file mode 100644 index 000000000..397f8cb3f --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/platform_interface/prototypes/platform_virtual_nv_fp.h @@ -0,0 +1,50 @@ +// SPDX-License-Identifier: BSD-2-Clause + +#ifndef _PLATFORM_VIRTUAL_FP_H_ +#define _PLATFORM_VIRTUAL_FP_H_ + +#include +#include + +// The ECC EK Cert and EK ICA Cert NV indexes are not populated like normal. +// Data is generated on the fly and returned when NV_Read or NV_ReadPublic is +// called for them. This function populates the given NV_VIRTUAL_INDEX structure with +// attributes for the EK cert and EKICA cert scenarios. If the NV index is not virtual, +// the function should return TPM_RC_NO_RESULT. +LIB_EXPORT TPM_RC _plat__NvVirtual_PopulateNvIndexInfo( + TPM_HANDLE handle, // IN: handle for the index + TPMS_NV_PUBLIC* publicArea, // INOUT: The public area structure to be modified. + TPM2B_AUTH* authValue // INOUT: The auth value structure to be modified. +); + +// Performs NV Read call to handle EK/EKICA cert scenarios. +LIB_EXPORT TPM_RC _plat__NvVirtual_Read( + NV_Read_In* dataIn, // IN: input parameter list + NV_Read_Out* dataOut // OUT: output parameter list +); + +// Performs NV Read Public call to handle EK/EKICA cert scenarios. +LIB_EXPORT TPM_RC _plat__NvVirtual_ReadPublic( + NV_ReadPublic_In* dataIn, // IN: input parameter list + NV_ReadPublic_Out* dataOut // OUT: output parameter list +); + +// Returns a list of handles of virtual NV indices, starting from 'handle'. +// 'Handle' must be in the range of NV indices, but does not have to reference +// an existing virtual NV Index. +LIB_EXPORT TPMI_YES_NO _plat__NvVirtual_CapGetIndex( + TPMI_DH_OBJECT handle, // IN: start handle + UINT32 count, // IN: max number of returned handles + TPML_HANDLE* handleList // OUT: list of handle +); + +// Does this NV operation accept virtual NV handles? +// If the operation is not an NV operation, returns false. +LIB_EXPORT BOOL _plat__NvOperationAcceptsVirtualHandles(TPM_CC commandCode); + +// Checks if the given handle belongs to one of the virtual indices. +// Currently only used with the ECC EK Certificate and EKICA Certificate +// indices. +LIB_EXPORT BOOL _plat__IsNvVirtualIndex(TPM_HANDLE handle); + +#endif // _PLATFORM_VIRTUAL_FP_H_ diff --git a/src/tpm2/tpm_to_platform_interface.h b/src/tpm2/TPMCmd/tpm/include/platform_interface/tpm_to_platform_interface.h similarity index 79% rename from src/tpm2/tpm_to_platform_interface.h rename to src/tpm2/TPMCmd/tpm/include/platform_interface/tpm_to_platform_interface.h index fdb366797..8f44de363 100644 --- a/src/tpm2/tpm_to_platform_interface.h +++ b/src/tpm2/TPMCmd/tpm/include/platform_interface/tpm_to_platform_interface.h @@ -1,62 +1,4 @@ -/********************************************************************************/ -/* */ -/* NV read and write access methods */ -/* 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 // This file represents the functional interface that all platform libraries must @@ -65,8 +7,8 @@ #define _TPM_TO_PLATFORM_INTERFACE_H_ // need to read configuration for ACT_SUPPORT flag check below -#include "TpmBuildSwitches.h" -#include "TpmProfile.h" +#include +#include #include //** From Cancel.c @@ -144,7 +86,7 @@ uint64_t ClockGetTime(clockid_t clk_id); // libtpms: added end //** From DebugHelpers.c - + #if CERTIFYX509_DEBUG #if 0 // libtpms: added @@ -315,7 +257,7 @@ LIB_EXPORT uint32_t _plat__ACT_GetRemaining(uint32_t act //IN: the ACT selector //*** _plat__ACT_GetSignaled() LIB_EXPORT int _plat__ACT_GetSignaled(uint32_t act //IN: number of ACT to check - ); +); //*** _plat__ACT_SetSignaled() LIB_EXPORT void _plat__ACT_SetSignaled(uint32_t act, int on); @@ -366,10 +308,6 @@ LIB_EXPORT int _plat__WasPowerLost(void); // FALSE(0) if physical presence is not signaled LIB_EXPORT int _plat__PhysicalPresenceAsserted(void); -//***_plat__Fail() -// This is the platform depended failure exit for the TPM. -LIB_EXPORT NORETURN void _plat__Fail(void); - //** From Unique.c #if VENDOR_PERMANENT_AUTH_ENABLED == YES @@ -400,23 +338,60 @@ LIB_EXPORT uint32_t _plat__GetUnique(uint32_t which, LIB_EXPORT void _plat__GetPlatformManufactureData(uint8_t* pPlatformPersistentData, uint32_t bufferSize); -// return the 4 character Manufacturer Capability code. This +// return the 4 character Manufacturer Capability code (TPM_PT_MANUFACTURER). This // should come from the platform library since that is provided by the manufacturer -LIB_EXPORT uint32_t _plat__GetManufacturerCapabilityCode(void); // libtpms changed +LIB_EXPORT uint32_t _plat__GetManufacturerCapabilityCode(void); -// return the 4 character VendorStrings for Capabilities. +// return the 4 character VendorStrings for GetCapability (TPM_PT_VENDOR_STRING_1-4) // Index is ONE-BASED, and may be in the range [1,4] inclusive. // Any other index returns all zeros. The return value will be interpreted // as an array of 4 ASCII characters (with no null terminator) LIB_EXPORT uint32_t _plat__GetVendorCapabilityCode(int index); // return the most-significant 32-bits of the TPM Firmware Version reported by -// getCapability. -LIB_EXPORT uint32_t _plat__GetTpmFirmwareVersionHigh(void); // libtpms changed +// getCapability (TPM_PT_FIRMWARE_VERSION_1) +LIB_EXPORT uint32_t _plat__GetTpmFirmwareVersionHigh(void); // return the least-significant 32-bits of the TPM Firmware Version reported by -// getCapability. -LIB_EXPORT uint32_t _plat__GetTpmFirmwareVersionLow(void); // libtpms changed +// getCapability (TPM_PT_FIRMWARE_VERSION_2) +LIB_EXPORT uint32_t _plat__GetTpmFirmwareVersionLow(void); + +// return the Vendor TPM Type returned by TPM_PT_VENDOR_TPM_TYPE +LIB_EXPORT uint32_t _plat__GetVendorTpmType(void); + +// Struct to define TPM and platform specific capability value +typedef struct _spec_capability_value +{ + uint32_t tpmSpecLevel; + uint32_t tpmSpecVersion; + uint32_t tpmSpecYear; + uint32_t tpmSpecDayOfYear; + + uint32_t platformFamily; + uint32_t platfromLevel; + uint32_t platformRevision; + uint32_t platformYear; + uint32_t platformDayOfYear; +} SPEC_CAPABILITY_VALUE; + +// return info on TPM and Platform Specific capability values. +LIB_EXPORT void _plat_GetSpecCapabilityValue(SPEC_CAPABILITY_VALUE* returnData); + +// Return enabled self-tests on the platform when TPM SelfTest is called. +// +// pToTestVector is a byte array allocated by the TPM library, each bit in the array +// represents a TPM_ALG_ID to be tested. The bit length of the vector is +// (8 * toTestVectorSize), which is larger than or equal to TPM_ALG_LAST + 1. +// +// Initially the vector have bits set for all implemented algorithms or remaining +// algorithms to test, based on fullTest option, and platform should update the vector +// to indicate which tests are actually enabled on the platform based on the its +// capabilities at the time of the call. +LIB_EXPORT void _plat_GetEnabledSelfTest( + uint8_t fullTest, // IN: full test or not + uint8_t* pToTestVector, // INOUT: initialized byte array of tracked tests + size_t toTestVectorSize // IN: size of the byte array in bytes +); // return the TPM Firmware's current SVN. LIB_EXPORT uint16_t _plat__GetTpmFirmwareSvn(void); @@ -453,10 +428,29 @@ LIB_EXPORT int _plat__GetTpmFirmwareSecret( ); #endif // FW_LIMITED_SUPPORT -// return the TPM Type returned by TPM_PT_VENDOR_TPM_TYPE -LIB_EXPORT uint32_t _plat__GetTpmType(void); // libtpms changed + +#if ENABLE_TPM_DEBUG_PRINT + +LIB_EXPORT void _plat_debug_print(const char* str); +LIB_EXPORT void _plat_debug_print_buffer(const void* buf, const size_t size); +LIB_EXPORT void _plat_debug_print_int32(const char* name, uint32_t value); +LIB_EXPORT void _plat_debug_print_int64(const char* name, uint64_t value); +LIB_EXPORT void _plat_debug_printf(const char* fmt, ...); +LIB_EXPORT size_t _plat_debug_snprintf( + char* buf, size_t bufSize, const char* fmt, ...); + +#endif // ENABLE_TPM_DEBUG_PRINT // platform PCR initialization functions -#include "platform_pcr_fp.h" +#include + +// platform initialization functions +#include + +// platform failure mode functions +#include + +// platform virtual NV functions +#include #endif // _TPM_TO_PLATFORM_INTERFACE_H_ diff --git a/src/tpm2/CommandAttributeData.h b/src/tpm2/TPMCmd/tpm/include/private/CommandAttributeData.h similarity index 71% rename from src/tpm2/CommandAttributeData.h rename to src/tpm2/TPMCmd/tpm/include/private/CommandAttributeData.h index ab86ae2a2..2a419a4b7 100644 --- a/src/tpm2/CommandAttributeData.h +++ b/src/tpm2/TPMCmd/tpm/include/private/CommandAttributeData.h @@ -1,62 +1,4 @@ -/********************************************************************************/ -/* */ -/* Command code attribute array for GetCapability */ -/* 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 // FILE GENERATED BY TpmExtractCode: DO NOT EDIT @@ -67,11 +9,11 @@ #include "CommandAttributes.h" -#if COMPRESSED_LISTS +#if COMPRESSED_LISTS // libtpms added begin # define PAD_LIST 0 #else # define PAD_LIST 1 -#endif +#endif // libtpms added end // This is the command code attribute array for GetCapability. // Both this array and s_commandAttributes provides command code attributes, @@ -464,530 +406,546 @@ const TPMA_CC s_ccAttr [] = { #if (PAD_LIST || CC_SetCapability) TPMA_CC_INITIALIZER(0x019F, 0, 1, 0, 0, 1, 0, 0, 0), #endif -#if (PAD_LIST || CC_Vendor_TCG_Test) - TPMA_CC_INITIALIZER(0x0000, 0, 0, 0, 0, 0, 0, 1, 0), +#if (PAD_LIST || CC_ReadOnlyControl) + TPMA_CC_INITIALIZER(0x01A0, 0, 1, 0, 0, 1, 0, 0, 0), +#endif +#if (PAD_LIST || CC_PolicyTransportSPDM) + TPMA_CC_INITIALIZER(0x01A1, 0, 0, 0, 0, 1, 0, 0, 0), #endif + +// Include attributes for vendor commands +#include "TpmConfiguration/VendorCommands/CommandAttributeData_s_ccAttr.inl" + +// list terminator TPMA_ZERO_INITIALIZER() }; - // This is the command code attribute structure. const COMMAND_ATTRIBUTES s_commandAttributes [] = { #if (PAD_LIST || CC_NV_UndefineSpaceSpecial) (COMMAND_ATTRIBUTES)(CC_NV_UndefineSpaceSpecial * // 0x011F - (IS_IMPLEMENTED+HANDLE_1_ADMIN+HANDLE_2_USER+PP_COMMAND)), + (HANDLE_1_ADMIN+HANDLE_2_USER+PP_COMMAND+RO_DISALLOW)), #endif #if (PAD_LIST || CC_EvictControl) (COMMAND_ATTRIBUTES)(CC_EvictControl * // 0x0120 - (IS_IMPLEMENTED+HANDLE_1_USER+PP_COMMAND)), + (HANDLE_1_USER+PP_COMMAND+RO_DISALLOW)), #endif #if (PAD_LIST || CC_HierarchyControl) (COMMAND_ATTRIBUTES)(CC_HierarchyControl * // 0x0121 - (IS_IMPLEMENTED+HANDLE_1_USER+PP_COMMAND)), + (HANDLE_1_USER+PP_COMMAND+RO_DISALLOW)), #endif #if (PAD_LIST || CC_NV_UndefineSpace) (COMMAND_ATTRIBUTES)(CC_NV_UndefineSpace * // 0x0122 - (IS_IMPLEMENTED+HANDLE_1_USER+PP_COMMAND)), + (HANDLE_1_USER+PP_COMMAND+RO_DISALLOW)), #endif #if (PAD_LIST) (COMMAND_ATTRIBUTES)(0), // 0x0123 #endif #if (PAD_LIST || CC_ChangeEPS) (COMMAND_ATTRIBUTES)(CC_ChangeEPS * // 0x0124 - (IS_IMPLEMENTED+HANDLE_1_USER+PP_COMMAND)), + (HANDLE_1_USER+PP_COMMAND+RO_DISALLOW)), #endif #if (PAD_LIST || CC_ChangePPS) (COMMAND_ATTRIBUTES)(CC_ChangePPS * // 0x0125 - (IS_IMPLEMENTED+HANDLE_1_USER+PP_COMMAND)), + (HANDLE_1_USER+PP_COMMAND+RO_DISALLOW)), #endif #if (PAD_LIST || CC_Clear) (COMMAND_ATTRIBUTES)(CC_Clear * // 0x0126 - (IS_IMPLEMENTED+HANDLE_1_USER+PP_COMMAND)), + (HANDLE_1_USER+PP_COMMAND+RO_DISALLOW)), #endif #if (PAD_LIST || CC_ClearControl) (COMMAND_ATTRIBUTES)(CC_ClearControl * // 0x0127 - (IS_IMPLEMENTED+HANDLE_1_USER+PP_COMMAND)), + (HANDLE_1_USER+PP_COMMAND+RO_DISALLOW)), #endif #if (PAD_LIST || CC_ClockSet) (COMMAND_ATTRIBUTES)(CC_ClockSet * // 0x0128 - (IS_IMPLEMENTED+HANDLE_1_USER+PP_COMMAND)), + (HANDLE_1_USER+PP_COMMAND+RO_DISALLOW)), #endif #if (PAD_LIST || CC_HierarchyChangeAuth) (COMMAND_ATTRIBUTES)(CC_HierarchyChangeAuth * // 0x0129 - (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+PP_COMMAND)), + (DECRYPT_2+HANDLE_1_USER+PP_COMMAND+RO_DISALLOW)), #endif #if (PAD_LIST || CC_NV_DefineSpace) (COMMAND_ATTRIBUTES)(CC_NV_DefineSpace * // 0x012A - (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+PP_COMMAND)), + (DECRYPT_2+HANDLE_1_USER+PP_COMMAND+RO_DISALLOW)), #endif #if (PAD_LIST || CC_PCR_Allocate) (COMMAND_ATTRIBUTES)(CC_PCR_Allocate * // 0x012B - (IS_IMPLEMENTED+HANDLE_1_USER+PP_COMMAND)), + (HANDLE_1_USER+PP_COMMAND+RO_DISALLOW)), #endif #if (PAD_LIST || CC_PCR_SetAuthPolicy) (COMMAND_ATTRIBUTES)(CC_PCR_SetAuthPolicy * // 0x012C - (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+PP_COMMAND)), + (DECRYPT_2+HANDLE_1_USER+PP_COMMAND+RO_DISALLOW)), #endif #if (PAD_LIST || CC_PP_Commands) (COMMAND_ATTRIBUTES)(CC_PP_Commands * // 0x012D - (IS_IMPLEMENTED+HANDLE_1_USER+PP_REQUIRED)), + (HANDLE_1_USER+PP_REQUIRED+RO_DISALLOW)), #endif #if (PAD_LIST || CC_SetPrimaryPolicy) (COMMAND_ATTRIBUTES)(CC_SetPrimaryPolicy * // 0x012E - (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+PP_COMMAND)), + (DECRYPT_2+HANDLE_1_USER+PP_COMMAND+RO_DISALLOW)), #endif #if (PAD_LIST || CC_FieldUpgradeStart) (COMMAND_ATTRIBUTES)(CC_FieldUpgradeStart * // 0x012F - (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_ADMIN+PP_COMMAND)), + (DECRYPT_2+HANDLE_1_ADMIN+PP_COMMAND+RO_DISALLOW)), #endif #if (PAD_LIST || CC_ClockRateAdjust) (COMMAND_ATTRIBUTES)(CC_ClockRateAdjust * // 0x0130 - (IS_IMPLEMENTED+HANDLE_1_USER+PP_COMMAND)), + (HANDLE_1_USER+PP_COMMAND+RO_DISALLOW)), #endif #if (PAD_LIST || CC_CreatePrimary) (COMMAND_ATTRIBUTES)(CC_CreatePrimary * // 0x0131 - (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+PP_COMMAND+ENCRYPT_2+R_HANDLE)), + (DECRYPT_2+HANDLE_1_USER+PP_COMMAND+ENCRYPT_2+R_HANDLE+RO_DISALLOW)), #endif #if (PAD_LIST || CC_NV_GlobalWriteLock) (COMMAND_ATTRIBUTES)(CC_NV_GlobalWriteLock * // 0x0132 - (IS_IMPLEMENTED+HANDLE_1_USER+PP_COMMAND)), + (HANDLE_1_USER+PP_COMMAND+RO_DISALLOW)), #endif #if (PAD_LIST || CC_GetCommandAuditDigest) (COMMAND_ATTRIBUTES)(CC_GetCommandAuditDigest * // 0x0133 - (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+HANDLE_2_USER+ENCRYPT_2)), + (DECRYPT_2+HANDLE_1_USER+HANDLE_2_USER+ENCRYPT_2)), #endif #if (PAD_LIST || CC_NV_Increment) (COMMAND_ATTRIBUTES)(CC_NV_Increment * // 0x0134 - (IS_IMPLEMENTED+HANDLE_1_USER)), + (HANDLE_1_USER+RO_DISALLOW)), #endif #if (PAD_LIST || CC_NV_SetBits) (COMMAND_ATTRIBUTES)(CC_NV_SetBits * // 0x0135 - (IS_IMPLEMENTED+HANDLE_1_USER)), + (HANDLE_1_USER)), #endif #if (PAD_LIST || CC_NV_Extend) (COMMAND_ATTRIBUTES)(CC_NV_Extend * // 0x0136 - (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER)), + (DECRYPT_2+HANDLE_1_USER)), #endif #if (PAD_LIST || CC_NV_Write) (COMMAND_ATTRIBUTES)(CC_NV_Write * // 0x0137 - (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER)), + (DECRYPT_2+HANDLE_1_USER)), #endif #if (PAD_LIST || CC_NV_WriteLock) (COMMAND_ATTRIBUTES)(CC_NV_WriteLock * // 0x0138 - (IS_IMPLEMENTED+HANDLE_1_USER)), + (HANDLE_1_USER)), #endif #if (PAD_LIST || CC_DictionaryAttackLockReset) (COMMAND_ATTRIBUTES)(CC_DictionaryAttackLockReset * // 0x0139 - (IS_IMPLEMENTED+HANDLE_1_USER)), + (HANDLE_1_USER)), #endif #if (PAD_LIST || CC_DictionaryAttackParameters) (COMMAND_ATTRIBUTES)(CC_DictionaryAttackParameters * // 0x013A - (IS_IMPLEMENTED+HANDLE_1_USER)), + (HANDLE_1_USER+RO_DISALLOW)), #endif #if (PAD_LIST || CC_NV_ChangeAuth) (COMMAND_ATTRIBUTES)(CC_NV_ChangeAuth * // 0x013B - (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_ADMIN)), + (DECRYPT_2+HANDLE_1_ADMIN+RO_DISALLOW)), #endif #if (PAD_LIST || CC_PCR_Event) (COMMAND_ATTRIBUTES)(CC_PCR_Event * // 0x013C - (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER)), + (DECRYPT_2+HANDLE_1_USER)), #endif #if (PAD_LIST || CC_PCR_Reset) (COMMAND_ATTRIBUTES)(CC_PCR_Reset * // 0x013D - (IS_IMPLEMENTED+HANDLE_1_USER)), + (HANDLE_1_USER)), #endif #if (PAD_LIST || CC_SequenceComplete) (COMMAND_ATTRIBUTES)(CC_SequenceComplete * // 0x013E - (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+ENCRYPT_2)), + (DECRYPT_2+HANDLE_1_USER+ENCRYPT_2)), #endif #if (PAD_LIST || CC_SetAlgorithmSet) (COMMAND_ATTRIBUTES)(CC_SetAlgorithmSet * // 0x013F - (IS_IMPLEMENTED+HANDLE_1_USER)), + (HANDLE_1_USER+RO_DISALLOW)), #endif #if (PAD_LIST || CC_SetCommandCodeAuditStatus) (COMMAND_ATTRIBUTES)(CC_SetCommandCodeAuditStatus * // 0x0140 - (IS_IMPLEMENTED+HANDLE_1_USER+PP_COMMAND)), + (HANDLE_1_USER+PP_COMMAND+RO_DISALLOW)), #endif #if (PAD_LIST || CC_FieldUpgradeData) (COMMAND_ATTRIBUTES)(CC_FieldUpgradeData * // 0x0141 - (IS_IMPLEMENTED+DECRYPT_2)), + (DECRYPT_2+RO_DISALLOW)), #endif #if (PAD_LIST || CC_IncrementalSelfTest) (COMMAND_ATTRIBUTES)(CC_IncrementalSelfTest * // 0x0142 - (IS_IMPLEMENTED)), + (0)), #endif #if (PAD_LIST || CC_SelfTest) (COMMAND_ATTRIBUTES)(CC_SelfTest * // 0x0143 - (IS_IMPLEMENTED)), + (0)), #endif #if (PAD_LIST || CC_Startup) (COMMAND_ATTRIBUTES)(CC_Startup * // 0x0144 - (IS_IMPLEMENTED+NO_SESSIONS)), + (NO_SESSIONS)), #endif #if (PAD_LIST || CC_Shutdown) (COMMAND_ATTRIBUTES)(CC_Shutdown * // 0x0145 - (IS_IMPLEMENTED)), + (0)), #endif #if (PAD_LIST || CC_StirRandom) (COMMAND_ATTRIBUTES)(CC_StirRandom * // 0x0146 - (IS_IMPLEMENTED+DECRYPT_2)), + (DECRYPT_2)), #endif #if (PAD_LIST || CC_ActivateCredential) (COMMAND_ATTRIBUTES)(CC_ActivateCredential * // 0x0147 - (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_ADMIN+HANDLE_2_USER+ENCRYPT_2)), + (DECRYPT_2+HANDLE_1_ADMIN+HANDLE_2_USER+ENCRYPT_2)), #endif #if (PAD_LIST || CC_Certify) (COMMAND_ATTRIBUTES)(CC_Certify * // 0x0148 - (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_ADMIN+HANDLE_2_USER+ENCRYPT_2)), + (DECRYPT_2+HANDLE_1_ADMIN+HANDLE_2_USER+ENCRYPT_2)), #endif #if (PAD_LIST || CC_PolicyNV) (COMMAND_ATTRIBUTES)(CC_PolicyNV * // 0x0149 - (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+ALLOW_TRIAL)), + (DECRYPT_2+HANDLE_1_USER+ALLOW_TRIAL)), #endif #if (PAD_LIST || CC_CertifyCreation) (COMMAND_ATTRIBUTES)(CC_CertifyCreation * // 0x014A - (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+ENCRYPT_2)), + (DECRYPT_2+HANDLE_1_USER+ENCRYPT_2)), #endif #if (PAD_LIST || CC_Duplicate) (COMMAND_ATTRIBUTES)(CC_Duplicate * // 0x014B - (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_DUP+ENCRYPT_2)), + (DECRYPT_2+HANDLE_1_DUP+ENCRYPT_2)), #endif #if (PAD_LIST || CC_GetTime) (COMMAND_ATTRIBUTES)(CC_GetTime * // 0x014C - (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+HANDLE_2_USER+ENCRYPT_2)), + (DECRYPT_2+HANDLE_1_USER+HANDLE_2_USER+ENCRYPT_2)), #endif #if (PAD_LIST || CC_GetSessionAuditDigest) (COMMAND_ATTRIBUTES)(CC_GetSessionAuditDigest * // 0x014D - (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+HANDLE_2_USER+ENCRYPT_2)), + (DECRYPT_2+HANDLE_1_USER+HANDLE_2_USER+ENCRYPT_2)), #endif #if (PAD_LIST || CC_NV_Read) (COMMAND_ATTRIBUTES)(CC_NV_Read * // 0x014E - (IS_IMPLEMENTED+HANDLE_1_USER+ENCRYPT_2)), + (HANDLE_1_USER+ENCRYPT_2)), #endif #if (PAD_LIST || CC_NV_ReadLock) (COMMAND_ATTRIBUTES)(CC_NV_ReadLock * // 0x014F - (IS_IMPLEMENTED+HANDLE_1_USER)), + (HANDLE_1_USER)), #endif #if (PAD_LIST || CC_ObjectChangeAuth) (COMMAND_ATTRIBUTES)(CC_ObjectChangeAuth * // 0x0150 - (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_ADMIN+ENCRYPT_2)), + (DECRYPT_2+HANDLE_1_ADMIN+ENCRYPT_2+RO_DISALLOW)), #endif #if (PAD_LIST || CC_PolicySecret) (COMMAND_ATTRIBUTES)(CC_PolicySecret * // 0x0151 - (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+ALLOW_TRIAL+ENCRYPT_2)), + (DECRYPT_2+HANDLE_1_USER+ALLOW_TRIAL+ENCRYPT_2)), #endif #if (PAD_LIST || CC_Rewrap) (COMMAND_ATTRIBUTES)(CC_Rewrap * // 0x0152 - (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+ENCRYPT_2)), + (DECRYPT_2+HANDLE_1_USER+ENCRYPT_2)), #endif #if (PAD_LIST || CC_Create) (COMMAND_ATTRIBUTES)(CC_Create * // 0x0153 - (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+ENCRYPT_2)), + (DECRYPT_2+HANDLE_1_USER+ENCRYPT_2+RO_DISALLOW)), #endif #if (PAD_LIST || CC_ECDH_ZGen) (COMMAND_ATTRIBUTES)(CC_ECDH_ZGen * // 0x0154 - (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+ENCRYPT_2)), + (DECRYPT_2+HANDLE_1_USER+ENCRYPT_2)), #endif #if (PAD_LIST || (CC_HMAC || CC_MAC)) (COMMAND_ATTRIBUTES)((CC_HMAC || CC_MAC) * // 0x0155 - (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+ENCRYPT_2)), + (DECRYPT_2+HANDLE_1_USER+ENCRYPT_2)), #endif #if (PAD_LIST || CC_Import) (COMMAND_ATTRIBUTES)(CC_Import * // 0x0156 - (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+ENCRYPT_2)), + (DECRYPT_2+HANDLE_1_USER+ENCRYPT_2)), #endif #if (PAD_LIST || CC_Load) (COMMAND_ATTRIBUTES)(CC_Load * // 0x0157 - (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+ENCRYPT_2+R_HANDLE)), + (DECRYPT_2+HANDLE_1_USER+ENCRYPT_2+R_HANDLE)), #endif #if (PAD_LIST || CC_Quote) (COMMAND_ATTRIBUTES)(CC_Quote * // 0x0158 - (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+ENCRYPT_2)), + (DECRYPT_2+HANDLE_1_USER+ENCRYPT_2)), #endif #if (PAD_LIST || CC_RSA_Decrypt) (COMMAND_ATTRIBUTES)(CC_RSA_Decrypt * // 0x0159 - (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+ENCRYPT_2)), + (DECRYPT_2+HANDLE_1_USER+ENCRYPT_2)), #endif #if (PAD_LIST) (COMMAND_ATTRIBUTES)(0), // 0x015A #endif #if (PAD_LIST || (CC_HMAC_Start || CC_MAC_Start)) (COMMAND_ATTRIBUTES)((CC_HMAC_Start || CC_MAC_Start) * // 0x015B - (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+R_HANDLE)), + (DECRYPT_2+HANDLE_1_USER+R_HANDLE)), #endif #if (PAD_LIST || CC_SequenceUpdate) (COMMAND_ATTRIBUTES)(CC_SequenceUpdate * // 0x015C - (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER)), + (DECRYPT_2+HANDLE_1_USER)), #endif #if (PAD_LIST || CC_Sign) (COMMAND_ATTRIBUTES)(CC_Sign * // 0x015D - (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER)), + (DECRYPT_2+HANDLE_1_USER)), #endif #if (PAD_LIST || CC_Unseal) (COMMAND_ATTRIBUTES)(CC_Unseal * // 0x015E - (IS_IMPLEMENTED+HANDLE_1_USER+ENCRYPT_2)), + (HANDLE_1_USER+ENCRYPT_2)), #endif #if (PAD_LIST) (COMMAND_ATTRIBUTES)(0), // 0x015F #endif #if (PAD_LIST || CC_PolicySigned) (COMMAND_ATTRIBUTES)(CC_PolicySigned * // 0x0160 - (IS_IMPLEMENTED+DECRYPT_2+ALLOW_TRIAL+ENCRYPT_2)), + (DECRYPT_2+ALLOW_TRIAL+ENCRYPT_2)), #endif #if (PAD_LIST || CC_ContextLoad) (COMMAND_ATTRIBUTES)(CC_ContextLoad * // 0x0161 - (IS_IMPLEMENTED+NO_SESSIONS+R_HANDLE)), + (NO_SESSIONS+R_HANDLE)), #endif #if (PAD_LIST || CC_ContextSave) (COMMAND_ATTRIBUTES)(CC_ContextSave * // 0x0162 - (IS_IMPLEMENTED+NO_SESSIONS)), + (NO_SESSIONS)), #endif #if (PAD_LIST || CC_ECDH_KeyGen) (COMMAND_ATTRIBUTES)(CC_ECDH_KeyGen * // 0x0163 - (IS_IMPLEMENTED+ENCRYPT_2)), + (ENCRYPT_2)), #endif #if (PAD_LIST || CC_EncryptDecrypt) (COMMAND_ATTRIBUTES)(CC_EncryptDecrypt * // 0x0164 - (IS_IMPLEMENTED+HANDLE_1_USER+ENCRYPT_2)), + (HANDLE_1_USER+ENCRYPT_2)), #endif #if (PAD_LIST || CC_FlushContext) (COMMAND_ATTRIBUTES)(CC_FlushContext * // 0x0165 - (IS_IMPLEMENTED+NO_SESSIONS)), + (NO_SESSIONS)), #endif #if (PAD_LIST) (COMMAND_ATTRIBUTES)(0), // 0x0166 #endif #if (PAD_LIST || CC_LoadExternal) (COMMAND_ATTRIBUTES)(CC_LoadExternal * // 0x0167 - (IS_IMPLEMENTED+DECRYPT_2+ENCRYPT_2+R_HANDLE)), + (DECRYPT_2+ENCRYPT_2+R_HANDLE)), #endif #if (PAD_LIST || CC_MakeCredential) (COMMAND_ATTRIBUTES)(CC_MakeCredential * // 0x0168 - (IS_IMPLEMENTED+DECRYPT_2+ENCRYPT_2)), + (DECRYPT_2+ENCRYPT_2)), #endif #if (PAD_LIST || CC_NV_ReadPublic) (COMMAND_ATTRIBUTES)(CC_NV_ReadPublic * // 0x0169 - (IS_IMPLEMENTED+ENCRYPT_2)), + (ENCRYPT_2)), #endif #if (PAD_LIST || CC_PolicyAuthorize) (COMMAND_ATTRIBUTES)(CC_PolicyAuthorize * // 0x016A - (IS_IMPLEMENTED+DECRYPT_2+ALLOW_TRIAL)), + (DECRYPT_2+ALLOW_TRIAL)), #endif #if (PAD_LIST || CC_PolicyAuthValue) (COMMAND_ATTRIBUTES)(CC_PolicyAuthValue * // 0x016B - (IS_IMPLEMENTED+ALLOW_TRIAL)), + (ALLOW_TRIAL)), #endif #if (PAD_LIST || CC_PolicyCommandCode) (COMMAND_ATTRIBUTES)(CC_PolicyCommandCode * // 0x016C - (IS_IMPLEMENTED+ALLOW_TRIAL)), + (ALLOW_TRIAL)), #endif #if (PAD_LIST || CC_PolicyCounterTimer) (COMMAND_ATTRIBUTES)(CC_PolicyCounterTimer * // 0x016D - (IS_IMPLEMENTED+DECRYPT_2+ALLOW_TRIAL)), + (DECRYPT_2+ALLOW_TRIAL)), #endif #if (PAD_LIST || CC_PolicyCpHash) (COMMAND_ATTRIBUTES)(CC_PolicyCpHash * // 0x016E - (IS_IMPLEMENTED+DECRYPT_2+ALLOW_TRIAL)), + (DECRYPT_2+ALLOW_TRIAL)), #endif #if (PAD_LIST || CC_PolicyLocality) (COMMAND_ATTRIBUTES)(CC_PolicyLocality * // 0x016F - (IS_IMPLEMENTED+ALLOW_TRIAL)), + (ALLOW_TRIAL)), #endif -#if (PAD_LIST || CC_PolicyNameHash) +#if (PAD_LIST || CC_PolicyNameHash) (COMMAND_ATTRIBUTES)(CC_PolicyNameHash * // 0x0170 - (IS_IMPLEMENTED+DECRYPT_2+ALLOW_TRIAL)), + (DECRYPT_2+ALLOW_TRIAL)), #endif -#if (PAD_LIST || CC_PolicyOR) +#if (PAD_LIST || CC_PolicyOR) (COMMAND_ATTRIBUTES)(CC_PolicyOR * // 0x0171 - (IS_IMPLEMENTED+ALLOW_TRIAL)), + (ALLOW_TRIAL)), #endif #if (PAD_LIST || CC_PolicyTicket) (COMMAND_ATTRIBUTES)(CC_PolicyTicket * // 0x0172 - (IS_IMPLEMENTED+DECRYPT_2+ALLOW_TRIAL)), + (DECRYPT_2+ALLOW_TRIAL)), #endif #if (PAD_LIST || CC_ReadPublic) (COMMAND_ATTRIBUTES)(CC_ReadPublic * // 0x0173 - (IS_IMPLEMENTED+ENCRYPT_2)), + (ENCRYPT_2)), #endif #if (PAD_LIST || CC_RSA_Encrypt) (COMMAND_ATTRIBUTES)(CC_RSA_Encrypt * // 0x0174 - (IS_IMPLEMENTED+DECRYPT_2+ENCRYPT_2)), + (DECRYPT_2+ENCRYPT_2)), #endif #if (PAD_LIST) (COMMAND_ATTRIBUTES)(0), // 0x0175 #endif #if (PAD_LIST || CC_StartAuthSession) (COMMAND_ATTRIBUTES)(CC_StartAuthSession * // 0x0176 - (IS_IMPLEMENTED+DECRYPT_2+ENCRYPT_2+R_HANDLE)), + (DECRYPT_2+ENCRYPT_2+R_HANDLE)), #endif #if (PAD_LIST || CC_VerifySignature) (COMMAND_ATTRIBUTES)(CC_VerifySignature * // 0x0177 - (IS_IMPLEMENTED+DECRYPT_2)), + (DECRYPT_2)), #endif #if (PAD_LIST || CC_ECC_Parameters) (COMMAND_ATTRIBUTES)(CC_ECC_Parameters * // 0x0178 - (IS_IMPLEMENTED)), + (0)), #endif #if (PAD_LIST || CC_FirmwareRead) (COMMAND_ATTRIBUTES)(CC_FirmwareRead * // 0x0179 - (IS_IMPLEMENTED+ENCRYPT_2)), + (ENCRYPT_2)), #endif #if (PAD_LIST || CC_GetCapability) (COMMAND_ATTRIBUTES)(CC_GetCapability * // 0x017A - (IS_IMPLEMENTED)), + (0)), #endif #if (PAD_LIST || CC_GetRandom) (COMMAND_ATTRIBUTES)(CC_GetRandom * // 0x017B - (IS_IMPLEMENTED+ENCRYPT_2)), + (ENCRYPT_2)), #endif #if (PAD_LIST || CC_GetTestResult) (COMMAND_ATTRIBUTES)(CC_GetTestResult * // 0x017C - (IS_IMPLEMENTED+ENCRYPT_2)), + (ENCRYPT_2)), #endif #if (PAD_LIST || CC_Hash) (COMMAND_ATTRIBUTES)(CC_Hash * // 0x017D - (IS_IMPLEMENTED+DECRYPT_2+ENCRYPT_2)), + (DECRYPT_2+ENCRYPT_2)), #endif #if (PAD_LIST || CC_PCR_Read) (COMMAND_ATTRIBUTES)(CC_PCR_Read * // 0x017E - (IS_IMPLEMENTED)), + (0)), #endif #if (PAD_LIST || CC_PolicyPCR) (COMMAND_ATTRIBUTES)(CC_PolicyPCR * // 0x017F - (IS_IMPLEMENTED+DECRYPT_2+ALLOW_TRIAL)), + (DECRYPT_2+ALLOW_TRIAL)), #endif #if (PAD_LIST || CC_PolicyRestart) (COMMAND_ATTRIBUTES)(CC_PolicyRestart * // 0x0180 - (IS_IMPLEMENTED+ALLOW_TRIAL)), + (ALLOW_TRIAL)), #endif #if (PAD_LIST || CC_ReadClock) (COMMAND_ATTRIBUTES)(CC_ReadClock * // 0x0181 - (IS_IMPLEMENTED)), + (0)), #endif #if (PAD_LIST || CC_PCR_Extend) (COMMAND_ATTRIBUTES)(CC_PCR_Extend * // 0x0182 - (IS_IMPLEMENTED+HANDLE_1_USER)), + (HANDLE_1_USER)), #endif #if (PAD_LIST || CC_PCR_SetAuthValue) (COMMAND_ATTRIBUTES)(CC_PCR_SetAuthValue * // 0x0183 - (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER)), + (DECRYPT_2+HANDLE_1_USER+RO_DISALLOW)), #endif #if (PAD_LIST || CC_NV_Certify) (COMMAND_ATTRIBUTES)(CC_NV_Certify * // 0x0184 - (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+HANDLE_2_USER+ENCRYPT_2)), + (DECRYPT_2+HANDLE_1_USER+HANDLE_2_USER+ENCRYPT_2)), #endif #if (PAD_LIST || CC_EventSequenceComplete) (COMMAND_ATTRIBUTES)(CC_EventSequenceComplete * // 0x0185 - (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+HANDLE_2_USER)), + (DECRYPT_2+HANDLE_1_USER+HANDLE_2_USER)), #endif #if (PAD_LIST || CC_HashSequenceStart) (COMMAND_ATTRIBUTES)(CC_HashSequenceStart * // 0x0186 - (IS_IMPLEMENTED+DECRYPT_2+R_HANDLE)), + (DECRYPT_2+R_HANDLE)), #endif #if (PAD_LIST || CC_PolicyPhysicalPresence) (COMMAND_ATTRIBUTES)(CC_PolicyPhysicalPresence * // 0x0187 - (IS_IMPLEMENTED+ALLOW_TRIAL)), + (ALLOW_TRIAL)), #endif #if (PAD_LIST || CC_PolicyDuplicationSelect) (COMMAND_ATTRIBUTES)(CC_PolicyDuplicationSelect * // 0x0188 - (IS_IMPLEMENTED+DECRYPT_2+ALLOW_TRIAL)), + (DECRYPT_2+ALLOW_TRIAL)), #endif #if (PAD_LIST || CC_PolicyGetDigest) (COMMAND_ATTRIBUTES)(CC_PolicyGetDigest * // 0x0189 - (IS_IMPLEMENTED+ALLOW_TRIAL+ENCRYPT_2)), + (ALLOW_TRIAL+ENCRYPT_2)), #endif #if (PAD_LIST || CC_TestParms) (COMMAND_ATTRIBUTES)(CC_TestParms * // 0x018A - (IS_IMPLEMENTED)), + (0)), #endif #if (PAD_LIST || CC_Commit) (COMMAND_ATTRIBUTES)(CC_Commit * // 0x018B - (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+ENCRYPT_2)), + (DECRYPT_2+HANDLE_1_USER+ENCRYPT_2)), #endif #if (PAD_LIST || CC_PolicyPassword) (COMMAND_ATTRIBUTES)(CC_PolicyPassword * // 0x018C - (IS_IMPLEMENTED+ALLOW_TRIAL)), + (ALLOW_TRIAL)), #endif #if (PAD_LIST || CC_ZGen_2Phase) (COMMAND_ATTRIBUTES)(CC_ZGen_2Phase * // 0x018D - (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+ENCRYPT_2)), + (DECRYPT_2+HANDLE_1_USER+ENCRYPT_2)), #endif #if (PAD_LIST || CC_EC_Ephemeral) (COMMAND_ATTRIBUTES)(CC_EC_Ephemeral * // 0x018E - (IS_IMPLEMENTED+ENCRYPT_2)), + (ENCRYPT_2)), #endif #if (PAD_LIST || CC_PolicyNvWritten) (COMMAND_ATTRIBUTES)(CC_PolicyNvWritten * // 0x018F - (IS_IMPLEMENTED+ALLOW_TRIAL)), + (ALLOW_TRIAL)), #endif #if (PAD_LIST || CC_PolicyTemplate) (COMMAND_ATTRIBUTES)(CC_PolicyTemplate * // 0x0190 - (IS_IMPLEMENTED+DECRYPT_2+ALLOW_TRIAL)), + (DECRYPT_2+ALLOW_TRIAL)), #endif #if (PAD_LIST || CC_CreateLoaded) (COMMAND_ATTRIBUTES)(CC_CreateLoaded * // 0x0191 - (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+PP_COMMAND+ENCRYPT_2+R_HANDLE)), + (DECRYPT_2+HANDLE_1_USER+PP_COMMAND+ENCRYPT_2+R_HANDLE+RO_DISALLOW)), #endif #if (PAD_LIST || CC_PolicyAuthorizeNV) (COMMAND_ATTRIBUTES)(CC_PolicyAuthorizeNV * // 0x0192 - (IS_IMPLEMENTED+HANDLE_1_USER+ALLOW_TRIAL)), + (HANDLE_1_USER+ALLOW_TRIAL)), #endif #if (PAD_LIST || CC_EncryptDecrypt2) (COMMAND_ATTRIBUTES)(CC_EncryptDecrypt2 * // 0x0193 - (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+ENCRYPT_2)), + (DECRYPT_2+HANDLE_1_USER+ENCRYPT_2)), #endif #if (PAD_LIST || CC_AC_GetCapability) (COMMAND_ATTRIBUTES)(CC_AC_GetCapability * // 0x0194 - (IS_IMPLEMENTED)), + (0)), #endif #if (PAD_LIST || CC_AC_Send) (COMMAND_ATTRIBUTES)(CC_AC_Send * // 0x0195 - (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_DUP+HANDLE_2_USER)), + (DECRYPT_2+HANDLE_1_DUP+HANDLE_2_USER)), #endif #if (PAD_LIST || CC_Policy_AC_SendSelect) (COMMAND_ATTRIBUTES)(CC_Policy_AC_SendSelect * // 0x0196 - (IS_IMPLEMENTED+DECRYPT_2+ALLOW_TRIAL)), + (DECRYPT_2+ALLOW_TRIAL)), #endif #if (PAD_LIST || CC_CertifyX509) (COMMAND_ATTRIBUTES)(CC_CertifyX509 * // 0x0197 - (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_ADMIN+HANDLE_2_USER+ENCRYPT_2)), + (DECRYPT_2+HANDLE_1_ADMIN+HANDLE_2_USER+ENCRYPT_2)), #endif #if (PAD_LIST || CC_ACT_SetTimeout) (COMMAND_ATTRIBUTES)(CC_ACT_SetTimeout * // 0x0198 - (IS_IMPLEMENTED+HANDLE_1_USER)), + (HANDLE_1_USER)), #endif #if (PAD_LIST || CC_ECC_Encrypt) (COMMAND_ATTRIBUTES)(CC_ECC_Encrypt * // 0x0199 - (IS_IMPLEMENTED+DECRYPT_2+ENCRYPT_2)), + (DECRYPT_2+ENCRYPT_2)), #endif #if (PAD_LIST || CC_ECC_Decrypt) (COMMAND_ATTRIBUTES)(CC_ECC_Decrypt * // 0x019A - (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+ENCRYPT_2)), + (DECRYPT_2+HANDLE_1_USER+ENCRYPT_2)), #endif #if (PAD_LIST || CC_PolicyCapability) (COMMAND_ATTRIBUTES)(CC_PolicyCapability * // 0x019B - (IS_IMPLEMENTED+DECRYPT_2+ALLOW_TRIAL)), + (DECRYPT_2+ALLOW_TRIAL)), #endif #if (PAD_LIST || CC_PolicyParameters) (COMMAND_ATTRIBUTES)(CC_PolicyParameters * // 0x019C - (IS_IMPLEMENTED+DECRYPT_2+ALLOW_TRIAL)), + (DECRYPT_2+ALLOW_TRIAL)), #endif #if (PAD_LIST || CC_NV_DefineSpace2) (COMMAND_ATTRIBUTES)(CC_NV_DefineSpace2 * // 0x019D - (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+PP_COMMAND)), + (DECRYPT_2+HANDLE_1_USER+PP_COMMAND+RO_DISALLOW)), #endif #if (PAD_LIST || CC_NV_ReadPublic2) (COMMAND_ATTRIBUTES)(CC_NV_ReadPublic2 * // 0x019E - (IS_IMPLEMENTED+ENCRYPT_2)), + (ENCRYPT_2)), #endif #if (PAD_LIST || CC_SetCapability) (COMMAND_ATTRIBUTES)(CC_SetCapability * // 0x019F - (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER)), + (DECRYPT_2+HANDLE_1_USER+RO_DISALLOW)), +#endif +#if (PAD_LIST || CC_ReadOnlyControl) + (COMMAND_ATTRIBUTES)(CC_ReadOnlyControl * // 0x01A0 + (HANDLE_1_USER+PP_COMMAND)), #endif -#if (PAD_LIST || CC_Vendor_TCG_Test) - (COMMAND_ATTRIBUTES)(CC_Vendor_TCG_Test * // 0x0000 - (IS_IMPLEMENTED+DECRYPT_2+ENCRYPT_2)), +#if (PAD_LIST || CC_PolicyTransportSPDM) + (COMMAND_ATTRIBUTES)(CC_PolicyTransportSPDM * // 0x01A1 + (DECRYPT_2+ALLOW_TRIAL)), #endif + +// Include attributes for vendor commands +#include "TpmConfiguration/VendorCommands/CommandAttributeData_s_commandAttributes.inl" + +// list terminator 0 }; diff --git a/src/tpm2/TPMCmd/tpm/include/private/CommandAttributes.h b/src/tpm2/TPMCmd/tpm/include/private/CommandAttributes.h new file mode 100644 index 000000000..33d0af841 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/CommandAttributes.h @@ -0,0 +1,35 @@ +// SPDX-License-Identifier: BSD-2-Clause + +/*(Auto-generated) + * Created by TpmStructures; Version 4.4 Mar 26, 2019 + * Date: Aug 30, 2019 Time: 02:11:52PM + */ + +// The attributes defined in this file are produced by the parser that +// creates the structure definitions from Part 3. The attributes are defined +// in that parser and should track the attributes being tested in +// CommandCodeAttributes.c. Generally, when an attribute is added to this list, +// new code will be needed in CommandCodeAttributes.c to test it. + +#ifndef COMMAND_ATTRIBUTES_H +#define COMMAND_ATTRIBUTES_H + +typedef UINT16 COMMAND_ATTRIBUTES; +#define ENCRYPT_2 ((COMMAND_ATTRIBUTES)1 << 0) +#define ENCRYPT_4 ((COMMAND_ATTRIBUTES)1 << 1) +#define DECRYPT_2 ((COMMAND_ATTRIBUTES)1 << 2) +#define DECRYPT_4 ((COMMAND_ATTRIBUTES)1 << 3) +#define HANDLE_1_USER ((COMMAND_ATTRIBUTES)1 << 4) +#define HANDLE_1_ADMIN ((COMMAND_ATTRIBUTES)1 << 5) +#define HANDLE_1_DUP ((COMMAND_ATTRIBUTES)1 << 6) +#define HANDLE_2_USER ((COMMAND_ATTRIBUTES)1 << 7) +#define PP_COMMAND ((COMMAND_ATTRIBUTES)1 << 8) +// Bit 9 is reserved. (was IS_IMPLEMENTED) +#define NO_SESSIONS ((COMMAND_ATTRIBUTES)1 << 10) +#define NV_COMMAND ((COMMAND_ATTRIBUTES)1 << 11) +#define PP_REQUIRED ((COMMAND_ATTRIBUTES)1 << 12) +#define R_HANDLE ((COMMAND_ATTRIBUTES)1 << 13) +#define ALLOW_TRIAL ((COMMAND_ATTRIBUTES)1 << 14) +#define RO_DISALLOW (((COMMAND_ATTRIBUTES)1 << 15) * CC_ReadOnlyControl) + +#endif // COMMAND_ATTRIBUTES_H diff --git a/src/tpm2/CommandDispatchData.h b/src/tpm2/TPMCmd/tpm/include/private/CommandDispatchData.h similarity index 97% rename from src/tpm2/CommandDispatchData.h rename to src/tpm2/TPMCmd/tpm/include/private/CommandDispatchData.h index a236ffaf9..9823eac2c 100644 --- a/src/tpm2/CommandDispatchData.h +++ b/src/tpm2/TPMCmd/tpm/include/private/CommandDispatchData.h @@ -1,62 +1,4 @@ -/********************************************************************************/ -/* */ -/* Command DIspatch Data */ -/* 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 // FILE GENERATED BY TpmExtractCode: DO NOT EDIT @@ -139,7 +81,19 @@ const _UNMARSHAL_T_ unmarshalArray[] = { UNMARSHAL_DISPATCH(TPMI_RH_HIERARCHY), // PARAMETER_FIRST_TYPE marks the end of the handle list. #define PARAMETER_FIRST_TYPE (TPMI_RH_HIERARCHY_H_UNMARSHAL + 1) -#define TPM2B_DATA_P_UNMARSHAL (TPMI_RH_HIERARCHY_H_UNMARSHAL + 1) +#define TPM_AT_P_UNMARSHAL (TPMI_RH_HIERARCHY_H_UNMARSHAL + 1) + UNMARSHAL_DISPATCH(TPM_AT), +#define TPM_CAP_P_UNMARSHAL (TPM_AT_P_UNMARSHAL + 1) + UNMARSHAL_DISPATCH(TPM_CAP), +#define TPM_CLOCK_ADJUST_P_UNMARSHAL (TPM_CAP_P_UNMARSHAL + 1) + UNMARSHAL_DISPATCH(TPM_CLOCK_ADJUST), +#define TPM_EO_P_UNMARSHAL (TPM_CLOCK_ADJUST_P_UNMARSHAL + 1) + UNMARSHAL_DISPATCH(TPM_EO), +#define TPM_SE_P_UNMARSHAL (TPM_EO_P_UNMARSHAL + 1) + UNMARSHAL_DISPATCH(TPM_SE), +#define TPM_SU_P_UNMARSHAL (TPM_SE_P_UNMARSHAL + 1) + UNMARSHAL_DISPATCH(TPM_SU), +#define TPM2B_DATA_P_UNMARSHAL (TPM_SU_P_UNMARSHAL + 1) UNMARSHAL_DISPATCH(TPM2B_DATA), #define TPM2B_DIGEST_P_UNMARSHAL (TPM2B_DATA_P_UNMARSHAL + 1) UNMARSHAL_DISPATCH(TPM2B_DIGEST), @@ -208,21 +162,9 @@ const _UNMARSHAL_T_ unmarshalArray[] = { #define TPMT_TK_HASHCHECK_P_UNMARSHAL (TPMT_TK_CREATION_P_UNMARSHAL + 1) UNMARSHAL_DISPATCH(TPMT_TK_HASHCHECK), #define TPMT_TK_VERIFIED_P_UNMARSHAL (TPMT_TK_HASHCHECK_P_UNMARSHAL + 1) - UNMARSHAL_DISPATCH(TPMT_TK_VERIFIED), -#define TPM_AT_P_UNMARSHAL (TPMT_TK_VERIFIED_P_UNMARSHAL + 1) - UNMARSHAL_DISPATCH(TPM_AT), -#define TPM_CAP_P_UNMARSHAL (TPM_AT_P_UNMARSHAL + 1) - UNMARSHAL_DISPATCH(TPM_CAP), -#define TPM_CLOCK_ADJUST_P_UNMARSHAL (TPM_CAP_P_UNMARSHAL + 1) - UNMARSHAL_DISPATCH(TPM_CLOCK_ADJUST), -#define TPM_EO_P_UNMARSHAL (TPM_CLOCK_ADJUST_P_UNMARSHAL + 1) - UNMARSHAL_DISPATCH(TPM_EO), -#define TPM_SE_P_UNMARSHAL (TPM_EO_P_UNMARSHAL + 1) - UNMARSHAL_DISPATCH(TPM_SE), -#define TPM_SU_P_UNMARSHAL (TPM_SE_P_UNMARSHAL + 1) - UNMARSHAL_DISPATCH(TPM_SU), -#define UINT16_P_UNMARSHAL (TPM_SU_P_UNMARSHAL + 1) - UNMARSHAL_DISPATCH(UINT16), + UNMARSHAL_DISPATCH(TPMT_TK_VERIFIED), +#define UINT16_P_UNMARSHAL (TPMT_TK_VERIFIED_P_UNMARSHAL + 1) + UNMARSHAL_DISPATCH(UINT16), #define UINT32_P_UNMARSHAL (UINT16_P_UNMARSHAL + 1) UNMARSHAL_DISPATCH(UINT32), #define UINT64_P_UNMARSHAL (UINT32_P_UNMARSHAL + 1) @@ -253,11 +195,11 @@ const _UNMARSHAL_T_ unmarshalArray[] = { UNMARSHAL_DISPATCH(TPMT_KDF_SCHEME), #define TPMT_RSA_DECRYPT_P_UNMARSHAL (TPMT_KDF_SCHEME_P_UNMARSHAL + 1) UNMARSHAL_DISPATCH(TPMT_RSA_DECRYPT), -#define TPMT_SIGNATURE_P_UNMARSHAL (TPMT_RSA_DECRYPT_P_UNMARSHAL + 1) - UNMARSHAL_DISPATCH(TPMT_SIGNATURE), -#define TPMT_SIG_SCHEME_P_UNMARSHAL (TPMT_SIGNATURE_P_UNMARSHAL + 1) +#define TPMT_SIG_SCHEME_P_UNMARSHAL (TPMT_RSA_DECRYPT_P_UNMARSHAL + 1) UNMARSHAL_DISPATCH(TPMT_SIG_SCHEME), -#define TPMT_SYM_DEF_P_UNMARSHAL (TPMT_SIG_SCHEME_P_UNMARSHAL + 1) +#define TPMT_SIGNATURE_P_UNMARSHAL (TPMT_SIG_SCHEME_P_UNMARSHAL + 1) + UNMARSHAL_DISPATCH(TPMT_SIGNATURE), +#define TPMT_SYM_DEF_P_UNMARSHAL (TPMT_SIGNATURE_P_UNMARSHAL + 1) UNMARSHAL_DISPATCH(TPMT_SYM_DEF), #define TPMT_SYM_DEF_OBJECT_P_UNMARSHAL (TPMT_SYM_DEF_P_UNMARSHAL + 1) UNMARSHAL_DISPATCH(TPMT_SYM_DEF_OBJECT) @@ -309,9 +251,7 @@ const _MARSHAL_T_ marshalArray[] = { MARSHAL_DISPATCH(TPM2B_SENSITIVE_DATA), #define TPM2B_TIMEOUT_P_MARSHAL (TPM2B_SENSITIVE_DATA_P_MARSHAL + 1) MARSHAL_DISPATCH(TPM2B_TIMEOUT), -#define UINT8_P_MARSHAL (TPM2B_TIMEOUT_P_MARSHAL + 1) - MARSHAL_DISPATCH(UINT8), -#define TPML_AC_CAPABILITIES_P_MARSHAL (UINT8_P_MARSHAL + 1) +#define TPML_AC_CAPABILITIES_P_MARSHAL (TPM2B_TIMEOUT_P_MARSHAL + 1) MARSHAL_DISPATCH(TPML_AC_CAPABILITIES), #define TPML_ALG_P_MARSHAL (TPML_AC_CAPABILITIES_P_MARSHAL + 1) MARSHAL_DISPATCH(TPML_ALG), @@ -343,12 +283,14 @@ const _MARSHAL_T_ marshalArray[] = { MARSHAL_DISPATCH(TPMT_TK_HASHCHECK), #define TPMT_TK_VERIFIED_P_MARSHAL (TPMT_TK_HASHCHECK_P_MARSHAL + 1) MARSHAL_DISPATCH(TPMT_TK_VERIFIED), -#define UINT32_P_MARSHAL (TPMT_TK_VERIFIED_P_MARSHAL + 1) +#define UINT16_P_MARSHAL (TPMT_TK_VERIFIED_P_MARSHAL + 1) + MARSHAL_DISPATCH(UINT16), +#define UINT32_P_MARSHAL (UINT16_P_MARSHAL + 1) MARSHAL_DISPATCH(UINT32), -#define UINT16_P_MARSHAL (UINT32_P_MARSHAL + 1) - MARSHAL_DISPATCH(UINT16) +#define UINT8_P_MARSHAL (UINT32_P_MARSHAL + 1) + MARSHAL_DISPATCH(UINT8) // RESPONSE_PARAMETER_LAST_TYPE is the index of the last response parameter. -#define RESPONSE_PARAMETER_LAST_TYPE (UINT16_P_MARSHAL) +#define RESPONSE_PARAMETER_LAST_TYPE (UINT8_P_MARSHAL) }; // This list of aliases allows the types in the _COMMAND_DESCRIPTOR_t to match @@ -3565,6 +3507,42 @@ PolicyParameters_COMMAND_DESCRIPTOR_t _PolicyParametersData = { #define _PolicyParametersDataAddress 0 #endif // CC_PolicyParameters +#if CC_PolicyTransportSPDM +#include "PolicyTransportSPDM_fp.h" + +typedef TPM_RC (PolicyTransportSPDM_Entry)( + PolicyTransportSPDM_In* in +); + +typedef const struct +{ + PolicyTransportSPDM_Entry *entry; + UINT16 inSize; + UINT16 outSize; + UINT16 offsetOfTypes; + UINT16 paramOffsets[2]; + BYTE types[5]; +} PolicyTransportSPDM_COMMAND_DESCRIPTOR_t; + +PolicyTransportSPDM_COMMAND_DESCRIPTOR_t _PolicyTransportSPDMData = { + /* entry */ &TPM2_PolicyTransportSPDM, + /* inSize */ (UINT16)(sizeof(PolicyTransportSPDM_In)), + /* outSize */ 0, + /* offsetOfTypes */ offsetof(PolicyTransportSPDM_COMMAND_DESCRIPTOR_t, types), + /* offsets */ {(UINT16)(offsetof(PolicyTransportSPDM_In, reqKeyName)), + (UINT16)(offsetof(PolicyTransportSPDM_In, tpmKeyName))}, + /* types */ {TPMI_SH_POLICY_H_UNMARSHAL, + TPM2B_NAME_P_UNMARSHAL, + TPM2B_NAME_P_UNMARSHAL, + END_OF_LIST, + END_OF_LIST} +}; + +#define _PolicyTransportSPDMDataAddress (&_PolicyTransportSPDMData) +#else +#define _PolicyTransportSPDMDataAddress 0 +#endif // CC_PolicyTransportSPDM + #if CC_CreatePrimary #include "CreatePrimary_fp.h" @@ -5061,6 +5039,40 @@ SetCapability_COMMAND_DESCRIPTOR_t _SetCapabilityData = { #define _SetCapabilityDataAddress 0 #endif // CC_SetCapability +#if CC_ReadOnlyControl +#include "ReadOnlyControl_fp.h" + +typedef TPM_RC (ReadOnlyControl_Entry)( + ReadOnlyControl_In* in +); + +typedef const struct +{ + ReadOnlyControl_Entry *entry; + UINT16 inSize; + UINT16 outSize; + UINT16 offsetOfTypes; + UINT16 paramOffsets[1]; + BYTE types[4]; +} ReadOnlyControl_COMMAND_DESCRIPTOR_t; + +ReadOnlyControl_COMMAND_DESCRIPTOR_t _ReadOnlyControlData = { + /* entry */ &TPM2_ReadOnlyControl, + /* inSize */ (UINT16)(sizeof(ReadOnlyControl_In)), + /* outSize */ 0, + /* offsetOfTypes */ offsetof(ReadOnlyControl_COMMAND_DESCRIPTOR_t, types), + /* offsets */ {(UINT16)(offsetof(ReadOnlyControl_In, state))}, + /* types */ {TPMI_RH_PLATFORM_H_UNMARSHAL, + TPMI_YES_NO_P_UNMARSHAL, + END_OF_LIST, + END_OF_LIST} +}; + +#define _ReadOnlyControlDataAddress (&_ReadOnlyControlData) +#else +#define _ReadOnlyControlDataAddress 0 +#endif // CC_ReadOnlyControl + #if CC_AC_Send #include "AC_Send_fp.h" @@ -5178,41 +5190,7 @@ ACT_SetTimeout_COMMAND_DESCRIPTOR_t _ACT_SetTimeoutData = { #define _ACT_SetTimeoutDataAddress 0 #endif // CC_ACT_SetTimeout -#if CC_Vendor_TCG_Test -#include "Vendor_TCG_Test_fp.h" - -typedef TPM_RC (Vendor_TCG_Test_Entry)( - Vendor_TCG_Test_In* in, - Vendor_TCG_Test_Out* out -); - - -typedef const struct -{ - Vendor_TCG_Test_Entry *entry; - UINT16 inSize; - UINT16 outSize; - UINT16 offsetOfTypes; - BYTE types[4]; -} Vendor_TCG_Test_COMMAND_DESCRIPTOR_t; - -Vendor_TCG_Test_COMMAND_DESCRIPTOR_t _Vendor_TCG_TestData = { - /* entry */ &TPM2_Vendor_TCG_Test, - /* inSize */ (UINT16)(sizeof(Vendor_TCG_Test_In)), - /* outSize */ (UINT16)(sizeof(Vendor_TCG_Test_Out)), - /* offsetOfTypes */ offsetof(Vendor_TCG_Test_COMMAND_DESCRIPTOR_t, types), - /* offsets */ // No parameter offsets - /* types */ {TPM2B_DATA_P_UNMARSHAL, - END_OF_LIST, - TPM2B_DATA_P_MARSHAL, - END_OF_LIST} -}; - -#define _Vendor_TCG_TestDataAddress (&_Vendor_TCG_TestData) -#else -#define _Vendor_TCG_TestDataAddress 0 -#endif // CC_Vendor_TCG_Test - +#include // Lookup table to access the per-command tables above @@ -5585,7 +5563,8 @@ COMMAND_DESCRIPTOR_t* s_CommandDataArray[] = { (COMMAND_DESCRIPTOR_t*)_EncryptDecrypt2DataAddress, #endif // CC_EncryptDecrypt2 #if (PAD_LIST || CC_AC_GetCapability) - (COMMAND_DESCRIPTOR_t*)_GetCapabilityDataAddress, +//#error "Not Implemented the Dispatch structure needs to be created" // libtpms changed begin + (COMMAND_DESCRIPTOR_t*)_GetCapabilityDataAddress, // libtpms changed end #endif // CC_AC_GetCapability #if (PAD_LIST || CC_AC_Send) (COMMAND_DESCRIPTOR_t*)_AC_SendDataAddress, @@ -5620,10 +5599,16 @@ COMMAND_DESCRIPTOR_t* s_CommandDataArray[] = { #if (PAD_LIST || CC_SetCapability) (COMMAND_DESCRIPTOR_t*)_SetCapabilityDataAddress, #endif // CC_SetCapability -#if (PAD_LIST || CC_Vendor_TCG_Test) - (COMMAND_DESCRIPTOR_t*)_Vendor_TCG_TestDataAddress, -#endif // CC_Vendor_TCG_Test +#if (PAD_LIST || CC_ReadOnlyControl) + (COMMAND_DESCRIPTOR_t*)_ReadOnlyControlDataAddress, +#endif // CC_ReadOnlyControl +#if (PAD_LIST || CC_PolicyTransportSPDM) + (COMMAND_DESCRIPTOR_t*)_PolicyTransportSPDMDataAddress, +#endif // CC_PolicyTransportSPDM + +#include +// list terminator 0 }; diff --git a/src/tpm2/TPMCmd/tpm/include/private/CryptEcc.h b/src/tpm2/TPMCmd/tpm/include/private/CryptEcc.h new file mode 100644 index 000000000..66888a586 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/CryptEcc.h @@ -0,0 +1,62 @@ +// SPDX-License-Identifier: BSD-2-Clause + +//** Introduction +// +// This file contains structure definitions used for ECC. The structures in this +// file are only used internally. The ECC-related structures that cross the +// public TPM interface are defined in TpmTypes.h +// + +// ECC Curve data type decoder ring +// ================================ +// | Name | Old Name* | Comments | +// | ------------------------- | -------------- | ------------------------------------------------------------------------------------------ | +// | TPM_ECC_CURVE | | 16-bit Curve ID from Part 2 of TCG TPM Spec | +// | TPM_ECC_CURVE_METADATA | ECC_CURVE | See description below | +// | | | | +// * - if different + +// TPM_ECC_CURVE_METADATA +// ====================== +// TPM-specific metadata for a particular curve, such as OIDs and signing/kdf +// schemes associated with the curve. +// +// TODO_ECC: Need to remove the curve constants from this structure and replace +// them with a reference to math-lib provided calls. Note: this structure does *NOT* +// include the actual curve constants. The curve constants are no longer in this +// structure because the constants need to be in a format compatible with the +// math library and are retrieved by the `ExtEcc_CurveGet*` family of functions. +// +// Using the math library's constant structure here is not necessary and breaks +// encapsulation. Using a tpm-specific format means either redundancy (the same +// values exist here and in a math-specific format), or forces the math library +// to adopt a particular format determined by this structure. Neither outcome +// is as clean as simply leaving the actual constants out of this structure. + +#ifndef _CRYPT_ECC_H +#define _CRYPT_ECC_H + +//** Structures + +#define ECC_BITS (MAX_ECC_KEY_BYTES * 8) +CRYPT_INT_TYPE(ecc, ECC_BITS); + +#define CRYPT_ECC_NUM(name) CRYPT_INT_VAR(name, ECC_BITS) + +#define CRYPT_ECC_INITIALIZED(name, initializer) \ + CRYPT_INT_INITIALIZED(name, ECC_BITS, initializer) + +typedef struct TPM_ECC_CURVE_METADATA +{ + const TPM_ECC_CURVE curveId; + const UINT16 keySizeBits; + const TPMT_KDF_SCHEME kdf; + const TPMT_ECC_SCHEME sign; + const BYTE* OID; +} TPM_ECC_CURVE_METADATA; + +//*** Macros +extern const TPM_ECC_CURVE_METADATA eccCurves[ECC_CURVE_COUNT]; + +#endif diff --git a/src/tpm2/crypto/CryptHash.h b/src/tpm2/TPMCmd/tpm/include/private/CryptHash.h similarity index 64% rename from src/tpm2/crypto/CryptHash.h rename to src/tpm2/TPMCmd/tpm/include/private/CryptHash.h index 6a18fe5fc..9e20e5688 100644 --- a/src/tpm2/crypto/CryptHash.h +++ b/src/tpm2/TPMCmd/tpm/include/private/CryptHash.h @@ -1,63 +1,4 @@ -/********************************************************************************/ -/* */ -/* Hash structure definitions */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: CryptHash.h 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, 2016 - 2021 */ -/* */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause //** Introduction // This header contains the hash structure definitions used in the TPM code @@ -154,15 +95,15 @@ typedef struct SMAC_STATE # define IF_IMPLEMENTED_SHA3_512(op) #endif -#define FOR_EACH_HASH(op) \ - IF_IMPLEMENTED_SHA1(op) \ - IF_IMPLEMENTED_SHA256(op) \ - IF_IMPLEMENTED_SHA384(op) \ - IF_IMPLEMENTED_SHA512(op) \ - IF_IMPLEMENTED_SM3_256(op) \ - IF_IMPLEMENTED_SHA3_256(op) \ - IF_IMPLEMENTED_SHA3_384(op) \ - IF_IMPLEMENTED_SHA3_512(op) +#define FOR_EACH_HASH(op) \ + IF_IMPLEMENTED_SHA1(op) \ + IF_IMPLEMENTED_SHA256(op) \ + IF_IMPLEMENTED_SHA384(op) \ + IF_IMPLEMENTED_SHA512(op) \ + IF_IMPLEMENTED_SM3_256(op) \ + IF_IMPLEMENTED_SHA3_256(op) \ + IF_IMPLEMENTED_SHA3_384(op) \ + IF_IMPLEMENTED_SHA3_512(op) #define HASH_TYPE(HASH, Hash) tpmHashState##HASH##_t Hash; typedef union @@ -176,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; @@ -186,7 +127,7 @@ typedef union typedef ANY_HASH_STATE* PANY_HASH_STATE; typedef const ANY_HASH_STATE* PCANY_HASH_STATE; -#define ALIGNED_SIZE(x, b) ((((x) + (b)-1) / (b)) * (b)) +#define ALIGNED_SIZE(x, b) ((((x) + (b) - 1) / (b)) * (b)) // MAX_HASH_STATE_SIZE will change with each implementation. It is assumed that // a hash state will not be larger than twice the block size plus some // overhead (in this case, 16 bytes). The overall size needs to be as @@ -283,20 +224,21 @@ typedef const struct HASH_DEF_STRUCT // Macro to fill in the HASH_DEF for an algorithm. For SHA1, the instance would be: // HASH_DEF_TEMPLATE(Sha1, SHA1) // This handles the difference in capitalization for the various pieces. -#define HASH_DEF_TEMPLATE(HASH, Hash) \ - HASH_DEF Hash##_Def = {{ \ - (HASH_START_METHOD*)&tpmHashStart_##HASH, \ - (HASH_DATA_METHOD*)&tpmHashData_##HASH, \ - (HASH_END_METHOD*)&tpmHashEnd_##HASH, \ - (HASH_STATE_COPY_METHOD*)&tpmHashStateCopy_##HASH, \ - (HASH_STATE_EXPORT_METHOD*)&tpmHashStateExport_##HASH, \ - (HASH_STATE_IMPORT_METHOD*)&tpmHashStateImport_##HASH, \ - }, \ - HASH##_BLOCK_SIZE, /*block size */ \ - HASH##_DIGEST_SIZE, /*data size */ \ - sizeof(tpmHashState##HASH##_t), \ - TPM_ALG_##HASH, \ - OID_##HASH PKCS1_OID(HASH) ECDSA_OID(HASH)}; +#define HASH_DEF_TEMPLATE(HASH, Hash) \ + HASH_DEF Hash##_Def = \ + {{ \ + (HASH_START_METHOD*)&tpmHashStart_##HASH, \ + (HASH_DATA_METHOD*)&tpmHashData_##HASH, \ + (HASH_END_METHOD*)&tpmHashEnd_##HASH, \ + (HASH_STATE_COPY_METHOD*)&tpmHashStateCopy_##HASH, \ + (HASH_STATE_EXPORT_METHOD*)&tpmHashStateExport_##HASH, \ + (HASH_STATE_IMPORT_METHOD*)&tpmHashStateImport_##HASH, \ + }, \ + HASH##_BLOCK_SIZE, /*block size */ \ + HASH##_DIGEST_SIZE, /*data size */ \ + sizeof(tpmHashState##HASH##_t), \ + TPM_ALG_##HASH, \ + OID_##HASH PKCS1_OID(HASH) ECDSA_OID(HASH)}; // These definitions are for the types that can be in a hash state structure. // These types are used in the cryptographic utilities. This is a define rather than diff --git a/src/tpm2/crypto/CryptRand.h b/src/tpm2/TPMCmd/tpm/include/private/CryptRand.h similarity index 59% rename from src/tpm2/crypto/CryptRand.h rename to src/tpm2/TPMCmd/tpm/include/private/CryptRand.h index c906eda4d..302cd0275 100644 --- a/src/tpm2/crypto/CryptRand.h +++ b/src/tpm2/TPMCmd/tpm/include/private/CryptRand.h @@ -1,62 +1,4 @@ -/********************************************************************************/ -/* */ -/* DRBG with a behavior according to SP800-90A */ -/* 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 constant definition shared by CryptUtil and the parts @@ -83,14 +25,15 @@ #define DRBG_ALGORITHM TPM_ALG_AES #define DRBG_ENCRYPT_SETUP(key, keySizeInBits, schedule) \ - TpmCryptSetEncryptKeyAES(key, keySizeInBits, schedule) + TpmCryptSetEncryptKeyAES(key, keySizeInBits, schedule) #define DRBG_ENCRYPT(keySchedule, in, out) \ - TpmCryptEncryptAES(SWIZZLE(keySchedule, in, out)) + TpmCryptEncryptAES(SWIZZLE(keySchedule, in, out)) -#if((DRBG_KEY_SIZE_BITS % RADIX_BITS) != 0) || ((DRBG_IV_SIZE_BITS % RADIX_BITS) != 0) +#if ((DRBG_KEY_SIZE_BITS % RADIX_BITS) != 0) \ + || ((DRBG_IV_SIZE_BITS % RADIX_BITS) != 0) # error "Key size and IV for DRBG must be even multiples of the radix" #endif -#if(DRBG_KEY_SIZE_BITS % DRBG_IV_SIZE_BITS) != 0 +#if (DRBG_KEY_SIZE_BITS % DRBG_IV_SIZE_BITS) != 0 # error "Key size for DRBG must be even multiple of the cypher block size" #endif diff --git a/src/tpm2/TPMCmd/tpm/include/private/CryptRsa.h b/src/tpm2/TPMCmd/tpm/include/private/CryptRsa.h new file mode 100644 index 000000000..df9e77aeb --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/CryptRsa.h @@ -0,0 +1,84 @@ +// SPDX-License-Identifier: BSD-2-Clause + +// This file contains the RSA-related structures and defines. + +#ifndef _CRYPT_RSA_H +#define _CRYPT_RSA_H + +// These values are used in the Crypt_Int* representation of various RSA values. +// define ci_rsa_t as buffer containing a CRYPT_INT object with space for +// (MAX_RSA_KEY_BITS) of actual data. +CRYPT_INT_TYPE(rsa, MAX_RSA_KEY_BITS); +#define CRYPT_RSA_VAR(name) CRYPT_INT_VAR(name, MAX_RSA_KEY_BITS) +#define CRYPT_RSA_INITIALIZED(name, initializer) \ + CRYPT_INT_INITIALIZED(name, MAX_RSA_KEY_BITS, initializer) + +#define CRYPT_PRIME_VAR(name) CRYPT_INT_VAR(name, (MAX_RSA_KEY_BITS / 2)) +// define ci_prime_t as buffer containing a CRYPT_INT object with space for +// (MAX_RSA_KEY_BITS/2) of actual data. +CRYPT_INT_TYPE(prime, (MAX_RSA_KEY_BITS / 2)); +#define CRYPT_PRIME_INITIALIZED(name, initializer) \ + CRYPT_INT_INITIALIZED(name, MAX_RSA_KEY_BITS / 2, initializer) + +#if !CRT_FORMAT_RSA +# error This verson only works with CRT formatted data +#endif // !CRT_FORMAT_RSA + +typedef struct privateExponent +{ + Crypt_Int* P; + Crypt_Int* Q; + Crypt_Int* dP; + Crypt_Int* dQ; + Crypt_Int* qInv; + ci_prime_t entries[5]; +} privateExponent; + +#define NEW_PRIVATE_EXPONENT(X) \ + privateExponent _##X; \ + privateExponent* X = RsaInitializeExponent(&(_##X)) + + // libtpms added begin: keep old privateExponent +/* The privateExponentOld is part of the OBJECT and we keep it there even though + * upstream got rid of it and stores Q, dP, dQ, and qInv by appending them to + * P stored in TPMT_SENSITIVE.TPMU_SENSITIVE_COMPOSITE.TPM2B_PRIVATE_KEY_RSA + */ +typedef struct privateExponentOld +{ + ci_prime_t Q; + ci_prime_t dP; + ci_prime_t dQ; + ci_prime_t qInv; +} privateExponent_t; + +#include "BnMemory_fp.h" + +static inline void RsaInitializeExponentOld(privateExponent_t* pExp) +{ + BN_INIT(pExp->Q); + BN_INIT(pExp->dP); + BN_INIT(pExp->dQ); + BN_INIT(pExp->qInv); +} + +static inline void RsaSetExponentOld(privateExponent_t* pExp, // OUT + privateExponent* Z // IN + ) +{ + // pExp->Q must be set elsewhere + ExtMath_Copy((Crypt_Int*)&pExp->dP, Z->dP); + ExtMath_Copy((Crypt_Int*)&pExp->dQ, Z->dQ); + ExtMath_Copy((Crypt_Int*)&pExp->qInv, Z->qInv); +} + +static inline void RsaSetExponentFromOld(privateExponent* Z, // OUT + privateExponent_t* pExp // IN + ) +{ + ExtMath_Copy(Z->Q, (Crypt_Int*)&pExp->Q); + ExtMath_Copy(Z->dP, (Crypt_Int*)&pExp->dP); + ExtMath_Copy(Z->dQ, (Crypt_Int*)&pExp->dQ); + ExtMath_Copy(Z->qInv, (Crypt_Int*)&pExp->qInv); +} + // libtpms added end +#endif // _CRYPT_RSA_H diff --git a/src/tpm2/TPMCmd/tpm/include/private/CryptSym.h b/src/tpm2/TPMCmd/tpm/include/private/CryptSym.h new file mode 100644 index 000000000..4ed786e39 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/CryptSym.h @@ -0,0 +1,93 @@ +// SPDX-License-Identifier: BSD-2-Clause + +//** Introduction +// +// This file contains the implementation of the symmetric block cipher modes +// allowed for a TPM. These functions only use the single block encryption functions +// of the selected symmetric cryptographic library. + +//** Includes, Defines, and Typedefs +#ifndef CRYPT_SYM_H +#define CRYPT_SYM_H + +#if ALG_AES +# define IF_IMPLEMENTED_AES(op) op(AES, aes) +#else +# define IF_IMPLEMENTED_AES(op) +#endif +#if ALG_SM4 +# define IF_IMPLEMENTED_SM4(op) op(SM4, sm4) +#else +# define IF_IMPLEMENTED_SM4(op) +#endif +#if ALG_CAMELLIA +# define IF_IMPLEMENTED_CAMELLIA(op) op(CAMELLIA, camellia) +#else +# define IF_IMPLEMENTED_CAMELLIA(op) +#endif +#if ALG_TDES // libtpms added begin +# define IF_IMPLEMENTED_TDES(op) op(TDES, tdes) +#else +# define IF_IMPLEMENTED_TDES(op) +#endif // libtpms added end + +#define FOR_EACH_SYM(op) \ + IF_IMPLEMENTED_AES(op) \ + IF_IMPLEMENTED_SM4(op) \ + IF_IMPLEMENTED_CAMELLIA(op) \ + IF_IMPLEMENTED_TDES(op) + + /* libtpms added begin */ +#define FOR_EACH_SYM_WITHOUT_TDES(op) \ + IF_IMPLEMENTED_AES(op) \ + IF_IMPLEMENTED_SM4(op) \ + IF_IMPLEMENTED_CAMELLIA(op) /* libtpms added end */ + +// Macros for creating the key schedule union +#define KEY_SCHEDULE(SYM, sym) tpmKeySchedule##SYM sym; +typedef union tpmCryptKeySchedule_t { + FOR_EACH_SYM_WITHOUT_TDES(KEY_SCHEDULE) /* libtpms changed from FOR_EACH_SYM */ + + tpmKeyScheduleTDES tdes[3]; /* libtpms added */ + +#if SYMMETRIC_ALIGNMENT == 8 + uint64_t alignment; +#else + uint32_t alignment; +# if defined(__x86_64__) // libtpms added begin +# error Bad SYMMETRIC_ALIGNMENT +# endif // libtpms added end +#endif +} tpmCryptKeySchedule_t; + +// Each block cipher within a library is expected to conform to the same calling +// conventions with three parameters ('keySchedule', 'in', and 'out') in the same +// order. That means that all algorithms would use the same order of the same +// parameters. The code is written assuming the ('keySchedule', 'in', and 'out') +// order. However, if the library uses a different order, the order can be changed +// with a SWIZZLE macro that puts the parameters in the correct order. +// Note that all algorithms have to use the same order and number of parameters +// because the code to build the calling list is common for each call to encrypt +// or decrypt with the algorithm chosen by setting a function pointer to select +// the algorithm that is used. + +#define ENCRYPT(keySchedule, in, out) encrypt(SWIZZLE(keySchedule, in, out)) + +#define DECRYPT(keySchedule, in, out) decrypt(SWIZZLE(keySchedule, in, out)) + +// Note that the macros rely on 'encrypt' as local values in the +// functions that use these macros. Those parameters are set by the macro that +// set the key schedule to be used for the call. + +#define ENCRYPT_CASE(ALG, alg) \ + case TPM_ALG_##ALG: \ + TpmCryptSetEncryptKey##ALG(key, keySizeInBits, &keySchedule.alg); \ + encrypt = (TpmCryptSetSymKeyCall_t)TpmCryptEncrypt##ALG; \ + break; +#define DECRYPT_CASE(ALG, alg) \ + case TPM_ALG_##ALG: \ + TpmCryptSetDecryptKey##ALG(key, keySizeInBits, &keySchedule.alg); \ + decrypt = (TpmCryptSetSymKeyCall_t)TpmCryptDecrypt##ALG; \ + break; + +#endif // CRYPT_SYM_H diff --git a/src/tpm2/TPMCmd/tpm/include/private/CryptTest.h b/src/tpm2/TPMCmd/tpm/include/private/CryptTest.h new file mode 100644 index 000000000..b88767e1b --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/CryptTest.h @@ -0,0 +1,37 @@ +// SPDX-License-Identifier: BSD-2-Clause + +// This file contains constant definitions used for self-test. + +#ifndef _CRYPT_TEST_H +#define _CRYPT_TEST_H + +// This is the definition of a bit array with one bit per algorithm. +// NOTE: Since bit numbering starts at zero, when TPM_ALG_LAST is a multiple of 8, +// ALGORITHM_VECTOR will need to have byte for the single bit in the last byte. So, +// for example, when TPM_ALG_LAST is 8, ALGORITHM_VECTOR will need 2 bytes. +#define ALGORITHM_VECTOR_BYTES ((TPM_ALG_LAST + 8) / 8) +typedef BYTE ALGORITHM_VECTOR[ALGORITHM_VECTOR_BYTES]; + +#ifdef TEST_SELF_TEST +LIB_EXPORT extern ALGORITHM_VECTOR LibToTest; +#endif + +// This structure is used to contain self-test tracking information for the +// cryptographic modules. Each of the major modules is given a 32-bit value in +// which it may maintain its own self test information. The convention for this +// state is that when all of the bits in this structure are 0, all functions need +// to be tested. +typedef struct +{ + UINT32 rng; + UINT32 hash; + UINT32 sym; +#if ALG_RSA + UINT32 rsa; +#endif +#if ALG_ECC + UINT32 ecc; +#endif +} CRYPTO_SELF_TEST_STATE; + +#endif // _CRYPT_TEST_H diff --git a/src/tpm2/EccTestData.h b/src/tpm2/TPMCmd/tpm/include/private/EccTestData.h similarity index 68% rename from src/tpm2/EccTestData.h rename to src/tpm2/TPMCmd/tpm/include/private/EccTestData.h index a68a14172..b3ee558e4 100644 --- a/src/tpm2/EccTestData.h +++ b/src/tpm2/TPMCmd/tpm/include/private/EccTestData.h @@ -1,63 +1,4 @@ -/********************************************************************************/ -/* */ -/* Parameter data for ECC testing */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: EccTestData.h 1259 2018-07-10 19:11:09Z 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 - 2018 */ -/* */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause // This file contains the parameter data for ECC testing. diff --git a/src/tpm2/Global.h b/src/tpm2/TPMCmd/tpm/include/private/Global.h similarity index 92% rename from src/tpm2/Global.h rename to src/tpm2/TPMCmd/tpm/include/private/Global.h index b9b2a35d9..9517e08fd 100644 --- a/src/tpm2/Global.h +++ b/src/tpm2/TPMCmd/tpm/include/private/Global.h @@ -1,62 +1,4 @@ -/********************************************************************************/ -/* */ -/* Internal Global Type Definitions */ -/* 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 - 2024 */ -/* */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause //** Description @@ -90,9 +32,9 @@ _REDUCE_WARNING_LEVEL_(2) _NORMAL_WARNING_LEVEL_ #include "BackwardsCompatibility.h" // libtpms added -# include "GpMacros.h" -# include "Capabilities.h" -# include "TpmTypes.h" // requires GpMacros & Capabilities +# include "tpm_public/GpMacros.h" +# include "tpm_public/Capabilities.h" +# include "tpm_public/TpmTypes.h" // requires GpMacros & Capabilities # include "CommandAttributes.h" # include "CryptTest.h" @@ -108,7 +50,7 @@ _NORMAL_WARNING_LEVEL_ # include "CryptRsa.h" # include "CryptTest.h" # include "NV.h" -# include "ACT.h" +# include "tpm_public/ACT.h" # include "Utils.h" // libtpms added //** Defines and Types @@ -195,7 +137,7 @@ typedef struct #endif // libtpms added unsigned occupied : 1; //15) SET when the slot is occupied. unsigned derivation : 1; //16) SET when the key is a derivation - // parent + // parent unsigned external : 1; //17) SET when the object is loaded with // TPM2_LoadExternal(); unsigned reserved : 14; //18-31) /* libtpms added */ @@ -398,10 +340,26 @@ typedef struct SESSION_ATTRIBUTES // SET if the pHash has been defined. This attribute is not SET unless // 'isPolicy' is SET. unsigned isParametersHashDefined : 1; /* libtpms added: for rev180; @stateFormatLevel 4 */ - unsigned _reserved : 16; //17-32 /* libtpms added */ +# if SEC_CHANNEL_SUPPORT || 1 + // SET if the presence of a secure channel needs to be checked when the policy + // is used for authorization. + unsigned checkSecureChannel : 1; + // SET if the requester secure channel key needs to be checked when the policy + // is used for authorization. This attribute is only SET if checkSecureChannel + // is SET. + unsigned checkReqKey : 1; + // SET if the TPM secure channel key needs to be checked when the policy + // is used for authorization. This attribute is only SET if checkSecureChannel + // is SET. + unsigned checkTpmKey : 1; +# endif // SEC_CHANNEL_SUPPORT + unsigned _reserved : 13; //17-32 /* libtpms added */ #endif /* libtpms added */ #if BIG_ENDIAN_TPM == YES /* libtpms added begin */ - unsigned _reserved : 16; //17-32 + unsigned _reserved : 13; //17-32 + unsigned checkTpmKey : 1; + unsigned checkReqKey : 1; + unsigned checkSecureChannel : 1; unsigned isParametersHashDefined : 1; //16 unsigned isNameHashDefined : 1; //15 unsigned isTemplateHashDefined : 1; //14) SET if the templateHash needs to be @@ -477,6 +435,12 @@ typedef struct SESSION TPM2B_DIGEST policyDigest; // policyHash } u2; // audit log and policyHash may // share space to save memory +# if SEC_CHANNEL_SUPPORT +# if CC_PolicyTransportSPDM +# error Need Marshaling support +# endif + TPM2B_DIGEST scKeyNameHash; // the required secure channel key name hash +# endif // SEC_CHANNEL_SUPPORT } SESSION; # define EXPIRES_ON_RESET INT32_MIN @@ -856,7 +820,7 @@ typedef struct // This implementation only supports a single group of PCR controlled by // policy. If more are required, then this structure would be changed to // an array. -# if defined NUM_POLICY_PCR_GROUP && NUM_POLICY_PCR_GROUP > 0 +# if defined NUM_POLICY_PCR_GROUP && NUM_POLICY_PCR_GROUP > 0 PCR_POLICY pcrPolicies; # endif @@ -1050,12 +1014,14 @@ typedef struct state_clear_data // The set of PCR to be saved on Shutdown(STATE) PCR_SAVE pcrSave; // default reset is 0...0 +# if defined NUM_AUTHVALUE_PCR_GROUP && NUM_AUTHVALUE_PCR_GROUP > 0 // This structure hold the authorization values for those PCR that have an // update authorization. // This implementation only supports a single group of PCR controlled by // authorization. If more are required, then this structure would be changed to // an array. PCR_AUTHVALUE pcrAuthValues; +# endif #ifndef __ACT_DISABLED // libtpms added //***************************************************************************** @@ -1068,6 +1034,15 @@ typedef struct state_clear_data BYTE reserved[STATE_CLEAR_DATA_PADDING]; # endif #endif // libtpms added + +# if CC_ReadOnlyControl +#error Need Marshaling/Unmarshaling support + //***************************************************************************** + // Read-Only Control + //***************************************************************************** + BOOL readOnly; // default reset is CLEAR +# endif + } STATE_CLEAR_DATA; EXTERN STATE_CLEAR_DATA gc; @@ -1109,19 +1084,17 @@ typedef struct state_reset_data // the TPM will return TPM_RC_RANGE and the TPM will only accept Shutdown(CLEAR). UINT32 clearCount; // The default reset value is 0. - UINT64 objectContextID; // This is the context ID for a saved - // object context. The default reset - // value is 0. - CONTEXT_SLOT contextArray[MAX_ACTIVE_SESSIONS]; // This array contains - // contains the values used to track - // the version numbers of saved - // contexts (see - // Session.c in for details). The - // default reset value is {0}. + // This is the context ID for a saved object context. The default reset + // value is 0. + UINT64 objectContextID; + + // This array contains the values used to track the version numbers of saved + // contexts (see Session.c in for details). The default reset value is {0}. + CONTEXT_SLOT contextArray[MAX_ACTIVE_SESSIONS]; - CONTEXT_COUNTER contextCounter; // This is the value from which the - // 'contextID' is derived. The - // default reset value is {0}. + // This is the value from which the 'contextID' is derived. The default + // reset value is {0}. + CONTEXT_COUNTER contextCounter; //***************************************************************************** // Command Audit @@ -1458,7 +1431,7 @@ EXTERN OBJECT s_objects[MAX_LOADED_OBJECTS]; //*** From PCR.c //***************************************************************************** # if defined PCR_C || defined GLOBAL_C -# include "pcrstruct.h" +# include EXTERN PCR s_pcrs[IMPLEMENTATION_PCR]; @@ -1505,27 +1478,6 @@ EXTERN UINT32 s_actionIoAllocation; // number of UIN64 allocated for the // action input structure # endif // IO_BUFFER_C -//***************************************************************************** -//*** From TPMFail.c -//***************************************************************************** -// This value holds the address of the string containing the name of the function -// in which the failure occurred. This address value is not useful for anything -// other than helping the vendor to know in which file the failure occurred. -EXTERN BOOL g_inFailureMode; // Indicates that the TPM is in failure mode -# if ALLOW_FORCE_FAILURE_MODE -EXTERN BOOL g_forceFailureMode; // flag to force failure mode during test -# endif - -typedef void(FailFunction)(const char *function, int line, int code); -#if defined TPM_FAIL_C || defined GLOBAL_C || 1 -EXTERN UINT32 s_failFunction; -// The line in the file at which the error was signaled. -EXTERN UINT32 s_failLine; -// the reason for the failure. -EXTERN UINT32 s_failCode; -EXTERN FailFunction *LibFailCallback; -#endif // TPM_FAIL_C - //***************************************************************************** //*** From ACT_spt.c //***************************************************************************** @@ -1545,4 +1497,7 @@ EXTERN UINT16 s_ActUpdated; extern const TPMA_CC s_ccAttr[]; extern const COMMAND_ATTRIBUTES s_commandAttributes[]; +// TRUE if _TPM_Init() ran to completion. +// checked by execute command +EXTERN BOOL g_initCompleted; #endif // GLOBAL_H diff --git a/src/tpm2/HashTestData.h b/src/tpm2/TPMCmd/tpm/include/private/HashTestData.h similarity index 67% rename from src/tpm2/HashTestData.h rename to src/tpm2/TPMCmd/tpm/include/private/HashTestData.h index 7fcd52d49..4bd174bed 100644 --- a/src/tpm2/HashTestData.h +++ b/src/tpm2/TPMCmd/tpm/include/private/HashTestData.h @@ -1,63 +1,4 @@ -/********************************************************************************/ -/* */ -/* Hash Test Vectors */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: HashTestData.h 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, 2016 - 2021 */ -/* */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause // // Hash Test Vectors diff --git a/src/tpm2/TPMCmd/tpm/include/private/InternalRoutines.h b/src/tpm2/TPMCmd/tpm/include/private/InternalRoutines.h new file mode 100644 index 000000000..5256b7575 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/InternalRoutines.h @@ -0,0 +1,103 @@ +// SPDX-License-Identifier: BSD-2-Clause + +#ifndef INTERNAL_ROUTINES_H +#define INTERNAL_ROUTINES_H + +#if !defined _LIB_SUPPORT_H_ && !defined _TPM_H_ +# error "Should not be called" +#endif + +// DRTM functions +// TODO_RENAME_INC_FOLDER:platform_interface refers to the TPM_CoreLib platform interface +#include +#include +#include + +// Internal subsystem functions +#include "Object_fp.h" +#include "Context_spt_fp.h" +#include "Object_spt_fp.h" +#include "Entity_fp.h" +#include "Session_fp.h" +#include "Hierarchy_fp.h" +#include "NvReserved_fp.h" +#include "NvDynamic_fp.h" +#include "NV_spt_fp.h" +#include "ACT_spt_fp.h" +#include "PCR_fp.h" +#include "DA_fp.h" +#if SEC_CHANNEL_SUPPORT +# include "SecChannel_fp.h" +#endif // SEC_CHANNEL_SUPPORT +// TODO_RENAME_INC_FOLDER: public refers to the TPM_CoreLib public headers +#include +#include "SessionProcess_fp.h" + +// Internal support functions +#include "CommandCodeAttributes_fp.h" +#include "Marshal.h" +#include "Time_fp.h" +#include "Locality_fp.h" +#include "PP_fp.h" +#include "CommandAudit_fp.h" +// TODO_RENAME_INC_FOLDER:platform_interface refers to the TPM_CoreLib platform interface +#include +#include "Handle_fp.h" +#include "Power_fp.h" +#include "Response_fp.h" +#include "CommandDispatcher_fp.h" + +#if CC_AC_Send & 0 // libtpms changed: from #ifdef +# include "AC_spt_fp.h" +#endif // CC_AC_Send + +// Miscellaneous +#include "Bits_fp.h" +#include "AlgorithmCap_fp.h" +#include "PropertyCap_fp.h" +#include "IoBuffers_fp.h" +#include "Memory_fp.h" +#include "ResponseCodeProcessing_fp.h" + +// Asymmetric Support library Interface +// TODO_RENAME_INC_FOLDER: needs a component prefix +// Math interface must be included before other Crypt headers to define types +#include + +// Internal cryptographic functions +#include "Ticket_fp.h" +#include "CryptUtil_fp.h" +#include "CryptHash_fp.h" +#include "CryptSym_fp.h" +#include "CryptDes_fp.h" // libtpms added +#include "CryptPrime_fp.h" +#include "CryptRand_fp.h" +#include "CryptSelfTest_fp.h" +#include "MathOnByteBuffers_fp.h" +#include "CryptSym_fp.h" +#include "AlgorithmTests_fp.h" + +#if ALG_RSA +# include "CryptRsa_fp.h" +# include "CryptPrimeSieve_fp.h" +#endif + +#if ALG_ECC +# include "CryptEccMain_fp.h" +# include "CryptEccSignature_fp.h" +# include "CryptEccKeyExchange_fp.h" +# include "CryptEccCrypt_fp.h" +#endif + +#if CC_MAC || CC_MAC_Start +# include "CryptSmac_fp.h" +# if ALG_CMAC +# include "CryptCmac_fp.h" +# endif +#endif + +// Linkage to platform functions +// TODO_RENAME_INC_FOLDER:platform_interface refers to the TPM_CoreLib platform interface +#include + +#endif diff --git a/src/tpm2/TPMCmd/tpm/include/private/KdfTestData.h b/src/tpm2/TPMCmd/tpm/include/private/KdfTestData.h new file mode 100644 index 000000000..b886b2774 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/KdfTestData.h @@ -0,0 +1,66 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// +// Hash Test Vectors +// + +#define TEST_KDF_KEY_SIZE 20 + +TPM2B_TYPE(KDF_TEST_KEY, TEST_KDF_KEY_SIZE); +TPM2B_KDF_TEST_KEY c_kdfTestKeyIn = { + {TEST_KDF_KEY_SIZE, + {0x27, 0x1F, 0xA0, 0x8B, 0xBD, 0xC5, 0x06, 0x0E, 0xC3, 0xDF, + 0xA9, 0x28, 0xFF, 0x9B, 0x73, 0x12, 0x3A, 0x12, 0xDA, 0x0C}}}; + +TPM2B_TYPE(KDF_TEST_LABEL, 17); +TPM2B_KDF_TEST_LABEL c_kdfTestLabel = {{17, + {0x4B, + 0x44, + 0x46, + 0x53, + 0x45, + 0x4C, + 0x46, + 0x54, + 0x45, + 0x53, + 0x54, + 0x4C, + 0x41, + 0x42, + 0x45, + 0x4C, + 0x00}}}; + +TPM2B_TYPE(KDF_TEST_CONTEXT, 8); +TPM2B_KDF_TEST_CONTEXT c_kdfTestContextU = { + {8, {0xCE, 0x24, 0x4F, 0x39, 0x5D, 0xCA, 0x73, 0x91}}}; + +TPM2B_KDF_TEST_CONTEXT c_kdfTestContextV = { + {8, {0xDA, 0x50, 0x40, 0x31, 0xDD, 0xF1, 0x2E, 0x83}}}; + +#if ALG_SHA512 == ALG_YES +TPM2B_KDF_TEST_KEY c_kdfTestKeyOut = { + {20, {0x8b, 0xe2, 0xc1, 0xb8, 0x5b, 0x78, 0x56, 0x9b, 0x9f, 0xa7, + 0x59, 0xf5, 0x85, 0x7c, 0x56, 0xd6, 0x84, 0x81, 0x0f, 0xd3}}}; +# define KDF_TEST_ALG TPM_ALG_SHA512 + +#elif ALG_SHA384 == ALG_YES +TPM2B_KDF_TEST_KEY c_kdfTestKeyOut = { + {20, {0x1d, 0xce, 0x70, 0xc9, 0x11, 0x3e, 0xb2, 0xdb, 0xa4, 0x7b, + 0xd9, 0xcf, 0xc7, 0x2b, 0xf4, 0x6f, 0x45, 0xb0, 0x93, 0x12}}}; +# define KDF_TEST_ALG TPM_ALG_SHA384 + +#elif ALG_SHA256 == ALG_YES +TPM2B_KDF_TEST_KEY c_kdfTestKeyOut = { + {20, {0xbb, 0x02, 0x59, 0xe1, 0xc8, 0xba, 0x60, 0x7e, 0x6a, 0x2c, + 0xd7, 0x04, 0xb6, 0x9a, 0x90, 0x2e, 0x9a, 0xde, 0x84, 0xc4}}}; +# define KDF_TEST_ALG TPM_ALG_SHA256 + +#elif ALG_SHA1 == ALG_YES +TPM2B_KDF_TEST_KEY c_kdfTestKeyOut = { + {20, {0x55, 0xb5, 0xa7, 0x18, 0x4a, 0xa0, 0x74, 0x23, 0xc4, 0x7d, + 0xae, 0x76, 0x6c, 0x26, 0xa2, 0x37, 0x7d, 0x7c, 0xf8, 0x51}}}; +# define KDF_TEST_ALG TPM_ALG_SHA1 +#endif diff --git a/src/tpm2/TPMCmd/tpm/include/private/LibSupport.h b/src/tpm2/TPMCmd/tpm/include/private/LibSupport.h new file mode 100644 index 000000000..69a8e0ef4 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/LibSupport.h @@ -0,0 +1,26 @@ +// SPDX-License-Identifier: BSD-2-Clause + +// This header file is used to select the library code that gets included in the +// TPM build. + +#ifndef _LIB_SUPPORT_H_ +#define _LIB_SUPPORT_H_ +// TODO_RENAME_INC_FOLDER: public refers to the TPM_CoreLib public headers +#include + +// Include the options for hashing and symmetric. Defer the load of the math package +// Until the bignum parameters are defined. +#ifndef SYM_LIB +# error SYM_LIB required +#endif +#ifndef HASH_LIB +# error HASH_LIB required +#endif + +#include LIB_INCLUDE(TpmTo, SYM_LIB, Sym) +#include LIB_INCLUDE(TpmTo, HASH_LIB, Hash) + +//TODO: was #undef MIN +//was #undef MAX + +#endif // _LIB_SUPPORT_H_ diff --git a/src/tpm2/TPMCmd/tpm/include/private/Marshal.h b/src/tpm2/TPMCmd/tpm/include/private/Marshal.h new file mode 100644 index 000000000..430fccd62 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/Marshal.h @@ -0,0 +1,21 @@ +// SPDX-License-Identifier: BSD-2-Clause + +//** Introduction +// This file is used to provide the things needed by a module that uses the marshaling +// functions. It handles the variations between the marshaling choices (procedural or +// table-driven). + +#if TABLE_DRIVEN_MARSHAL + +# include "TableMarshalTypes.h" + +# include "TableMarshalDefines.h" + +# include "TableDrivenMarshal_fp.h" + +#else + +# include "Marshal_fp.h" +# include "Unmarshal_fp.h" // libtpms added + +#endif diff --git a/src/tpm2/TPMCmd/tpm/include/private/NV.h b/src/tpm2/TPMCmd/tpm/include/private/NV.h new file mode 100644 index 000000000..5a5069bb5 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/NV.h @@ -0,0 +1,118 @@ +// SPDX-License-Identifier: BSD-2-Clause + +//** Index Type Definitions + +// These definitions allow the same code to be used pre and post 1.21. The main +// action is to redefine the index type values from the bit values. +// Use TPM_NT_ORDINARY to indicate if the TPM_NT type is defined + +#ifndef _NV_H_ +#define _NV_H_ + +#ifdef TPM_NT_ORDINARY +// If TPM_NT_ORDINARY is defined, then the TPM_NT field is present in a TPMA_NV +# define GET_TPM_NT(attributes) GET_ATTRIBUTE(attributes, TPMA_NV, TPM_NT) +#else +// If TPM_NT_ORDINARY is not defined, then need to synthesize it from the +// attributes +# define GetNv_TPM_NV(attributes) \ + (IS_ATTRIBUTE(attributes, TPMA_NV, COUNTER) \ + + (IS_ATTRIBUTE(attributes, TPMA_NV, BITS) << 1) \ + + (IS_ATTRIBUTE(attributes, TPMA_NV, EXTEND) << 2)) +# define TPM_NT_ORDINARY (0) +# define TPM_NT_COUNTER (1) +# define TPM_NT_BITS (2) +# define TPM_NT_EXTEND (4) +#endif + +//** Attribute Macros +// These macros are used to isolate the differences in the way that the index type +// changed in version 1.21 of the specification +#define IsNvOrdinaryIndex(attributes) (GET_TPM_NT(attributes) == TPM_NT_ORDINARY) + +#define IsNvCounterIndex(attributes) (GET_TPM_NT(attributes) == TPM_NT_COUNTER) + +#define IsNvBitsIndex(attributes) (GET_TPM_NT(attributes) == TPM_NT_BITS) + +#define IsNvExtendIndex(attributes) (GET_TPM_NT(attributes) == TPM_NT_EXTEND) + +#ifdef TPM_NT_PIN_PASS +# define IsNvPinPassIndex(attributes) (GET_TPM_NT(attributes) == TPM_NT_PIN_PASS) +#endif + +#ifdef TPM_NT_PIN_FAIL +# define IsNvPinFailIndex(attributes) (GET_TPM_NT(attributes) == TPM_NT_PIN_FAIL) +#endif + +typedef struct +{ + UINT32 size; + TPM_HANDLE handle; +} NV_ENTRY_HEADER; + +#define NV_EVICT_OBJECT_SIZE (sizeof(UINT32) + sizeof(TPM_HANDLE) + sizeof(OBJECT)) + +#define NV_INDEX_COUNTER_SIZE (sizeof(UINT32) + sizeof(NV_INDEX) + sizeof(UINT64)) + +#define NV_RAM_INDEX_COUNTER_SIZE (sizeof(NV_RAM_HEADER) + sizeof(UINT64)) + +typedef struct +{ + UINT32 size; + TPM_HANDLE handle; + TPMA_NV attributes; +} NV_RAM_HEADER; + +// Defines the end-of-list marker for NV. The list terminator is +// a UINT32 of zero, followed by the current value of s_maxCounter which is a +// 64-bit value. The structure is defined as an array of 3 UINT32 values so that +// there is no padding between the UINT32 list end marker and the UINT64 maxCounter +// value. +typedef UINT32 NV_LIST_TERMINATOR[3]; + +//** Orderly RAM Values +// The following defines are for accessing orderly RAM values. + +// This is the initialize for the RAM reference iterator. +#define NV_RAM_REF_INIT 0 +// This is the starting address of the RAM space used for orderly data +#define RAM_ORDERLY_START (&s_indexOrderlyRam[0]) +// This is the offset within NV that is used to save the orderly data on an +// orderly shutdown. +#define NV_ORDERLY_START (NV_INDEX_RAM_DATA) +// This is the end of the orderly RAM space. It is actually the first byte after the +// last byte of orderly RAM data +#define RAM_ORDERLY_END (RAM_ORDERLY_START + sizeof(s_indexOrderlyRam)) +// This is the end of the orderly space in NV memory. As with RAM_ORDERLY_END, it is +// actually the offset of the first byte after the end of the NV orderly data. +#define NV_ORDERLY_END (NV_ORDERLY_START + sizeof(s_indexOrderlyRam)) + +// Macro to check that an orderly RAM address is with range. +#define ORDERLY_RAM_ADDRESS_OK(start, offset) \ + ((start >= RAM_ORDERLY_START) && ((start + offset - 1) < RAM_ORDERLY_END)) + +#define RETURN_IF_NV_IS_NOT_AVAILABLE \ + { \ + if(g_NvStatus != TPM_RC_SUCCESS) \ + return g_NvStatus; \ + } + +// Routinely have to clear the orderly flag and fail if the +// NV is not available so that it can be cleared. +#define RETURN_IF_ORDERLY \ + { \ + if(NvClearOrderly() != TPM_RC_SUCCESS) \ + return g_NvStatus; \ + } + +#define NV_IS_AVAILABLE (g_NvStatus == TPM_RC_SUCCESS) + +#define IS_ORDERLY(value) (value < SU_DA_USED_VALUE) + +#define NV_IS_ORDERLY (IS_ORDERLY(gp.orderlyState)) + +// Macro to set the NV UPDATE_TYPE. This deals with the fact that the update is +// possibly a combination of UT_NV and UT_ORDERLY. +#define SET_NV_UPDATE(type) g_updateNV |= (type) + +#endif // _NV_H_ diff --git a/src/tpm2/OIDs.h b/src/tpm2/TPMCmd/tpm/include/private/OIDs.h similarity index 60% rename from src/tpm2/OIDs.h rename to src/tpm2/TPMCmd/tpm/include/private/OIDs.h index d2c9bcbb6..735b55ec0 100644 --- a/src/tpm2/OIDs.h +++ b/src/tpm2/TPMCmd/tpm/include/private/OIDs.h @@ -1,63 +1,4 @@ -/********************************************************************************/ -/* */ -/* OID values */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: OIDs.h 1628 2020-05-27 19:35:29Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2019 - 2020 */ -/* */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause #ifndef _OIDS_H_ @@ -182,37 +123,37 @@ SHA3_512_OID(_); #if ALG_RSA # define OID_MGF1_VALUE \ - 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x08 + 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x08 MAKE_OID(_MGF1); # define OID_RSAPSS_VALUE \ - 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x0A + 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x0A MAKE_OID(_RSAPSS); // This is the OID to designate the public part of an RSA key. # define OID_PKCS1_PUB_VALUE \ - 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01 + 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01 MAKE_OID(_PKCS1_PUB); // These are used for RSA PKCS1 signature Algorithms # define OID_PKCS1_SHA1_VALUE \ - 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x05 + 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x05 SHA1_OID(_PKCS1_); // (1.2.840.113549.1.1.5) # define OID_PKCS1_SHA256_VALUE \ - 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x0B + 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x0B SHA256_OID(_PKCS1_); // (1.2.840.113549.1.1.11) # define OID_PKCS1_SHA384_VALUE \ - 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x0C + 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x0C SHA384_OID(_PKCS1_); // (1.2.840.113549.1.1.12) # define OID_PKCS1_SHA512_VALUE \ - 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x0D + 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x0D SHA512_OID(_PKCS1_); //(1.2.840.113549.1.1.13) # define OID_PKCS1_SM3_256_VALUE \ - 0x06, 0x08, 0x2A, 0x81, 0x1C, 0xCF, 0x55, 0x01, 0x83, 0x78 + 0x06, 0x08, 0x2A, 0x81, 0x1C, 0xCF, 0x55, 0x01, 0x83, 0x78 SM3_256_OID(_PKCS1_); // 1.2.156.10197.1.504 # define OID_PKCS1_SHA3_256_VALUE NIST_SIG, 14 @@ -230,19 +171,19 @@ SHA3_512_OID(_PKCS1_); SHA1_OID(_ECDSA_); // (1.2.840.10045.4.1) SHA1 digest signed by an ECDSA key. # define OID_ECDSA_SHA256_VALUE \ - 0x06, 0x08, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x04, 0x03, 0x02 + 0x06, 0x08, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x04, 0x03, 0x02 SHA256_OID(_ECDSA_); // (1.2.840.10045.4.3.2) SHA256 digest signed by an ECDSA key. # define OID_ECDSA_SHA384_VALUE \ - 0x06, 0x08, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x04, 0x03, 0x03 + 0x06, 0x08, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x04, 0x03, 0x03 SHA384_OID(_ECDSA_); // (1.2.840.10045.4.3.3) SHA384 digest signed by an ECDSA key. # define OID_ECDSA_SHA512_VALUE \ - 0x06, 0x08, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x04, 0x03, 0x04 + 0x06, 0x08, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x04, 0x03, 0x04 SHA512_OID(_ECDSA_); // (1.2.840.10045.4.3.4) SHA512 digest signed by an ECDSA key. # define OID_ECDSA_SM3_256_VALUE \ - 0x06, 0x08, 0x2A, 0x81, 0x1C, 0xCF, 0x55, 0x01, 0x83, 0x75 + 0x06, 0x08, 0x2A, 0x81, 0x1C, 0xCF, 0x55, 0x01, 0x83, 0x75 SM3_256_OID(_ECDSA_); // 1.2.156.10197.1.501 # define OID_ECDSA_SHA3_256_VALUE NIST_SIG, 10 @@ -260,7 +201,7 @@ SHA3_512_OID(_ECDSA_); MAKE_OID(_ECC_PUBLIC); # define OID_ECC_NIST_P192_VALUE \ - 0x06, 0x08, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x03, 0x01, 0x01 + 0x06, 0x08, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x03, 0x01, 0x01 # if ECC_NIST_P192 MAKE_OID(_ECC_NIST_P192); // (1.2.840.10045.3.1.1) 'nistP192' # endif // ECC_NIST_P192 @@ -271,7 +212,7 @@ MAKE_OID(_ECC_NIST_P224); // (1.3.132.0.33) 'nistP224' # endif // ECC_NIST_P224 # define OID_ECC_NIST_P256_VALUE \ - 0x06, 0x08, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x03, 0x01, 0x07 + 0x06, 0x08, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x03, 0x01, 0x07 # if ECC_NIST_P256 MAKE_OID(_ECC_NIST_P256); // (1.2.840.10045.3.1.7) 'nistP256' # endif // ECC_NIST_P256 @@ -298,7 +239,7 @@ MAKE_OID(_ECC_BN_P638); # endif // ECC_BN_P638 # define OID_ECC_SM2_P256_VALUE \ - 0x06, 0x08, 0x2A, 0x81, 0x1C, 0xCF, 0x55, 0x01, 0x82, 0x2D + 0x06, 0x08, 0x2A, 0x81, 0x1C, 0xCF, 0x55, 0x01, 0x82, 0x2D # if ECC_SM2_P256 MAKE_OID(_ECC_SM2_P256); // Don't know where I found this OID. It needs checking # endif // ECC_SM2_P256 diff --git a/src/tpm2/TPMCmd/tpm/include/private/PRNG_TestVectors.h b/src/tpm2/TPMCmd/tpm/include/private/PRNG_TestVectors.h new file mode 100644 index 000000000..c716a9b53 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/PRNG_TestVectors.h @@ -0,0 +1,99 @@ +// SPDX-License-Identifier: BSD-2-Clause + +#ifndef _MSBN_DRBG_TEST_VECTORS_H +#define _MSBN_DRBG_TEST_VECTORS_H + +//#if DRBG_ALGORITHM == TPM_ALG_AES && DRBG_KEY_BITS == 256 +#if DRBG_KEY_SIZE_BITS == 256 + +/*(NIST test vector) +[AES-256 no df] +[PredictionResistance = False] +[EntropyInputLen = 384] +[NonceLen = 128] +[PersonalizationStringLen = 0] +[AdditionalInputLen = 0] + +COUNT = 0 +EntropyInput = 0d15aa80 b16c3a10 906cfedb 795dae0b 5b81041c 5c5bfacb + 373d4440 d9120f7e 3d6cf909 86cf52d8 5d3e947d 8c061f91 +Nonce = 06caef5f b538e08e 1f3b0452 03f8f4b2 +PersonalizationString = +AdditionalInput = + INTERMEDIATE Key = be5df629 34cc1230 166a6773 345bbd6b + 4c8869cf 8aec1c3b 1aa98bca 37cacf61 + INTERMEDIATE V = 3182dd1e 7638ec70 014e93bd 813e524c + INTERMEDIATE ReturnedBits = 28e0ebb8 21016650 8c8f65f2 207bd0a3 +EntropyInputReseed = 6ee793a3 3955d72a d12fd80a 8a3fcf95 ed3b4dac 5795fe25 + cf869f7c 27573bbc 56f1acae 13a65042 b340093c 464a7a22 +AdditionalInputReseed = +AdditionalInput = +ReturnedBits = 946f5182 d54510b9 461248f5 71ca06c9 +*/ + +// Entropy is the size of the state. The state is the size of the key +// plus the IV. The IV is a block. If Key = 256 and Block = 128 then State = 384 +# define DRBG_TEST_INITIATE_ENTROPY \ + 0x0d, 0x15, 0xaa, 0x80, 0xb1, 0x6c, 0x3a, 0x10, 0x90, 0x6c, 0xfe, 0xdb, 0x79, \ + 0x5d, 0xae, 0x0b, 0x5b, 0x81, 0x04, 0x1c, 0x5c, 0x5b, 0xfa, 0xcb, 0x37, \ + 0x3d, 0x44, 0x40, 0xd9, 0x12, 0x0f, 0x7e, 0x3d, 0x6c, 0xf9, 0x09, 0x86, \ + 0xcf, 0x52, 0xd8, 0x5d, 0x3e, 0x94, 0x7d, 0x8c, 0x06, 0x1f, 0x91 + +# define DRBG_TEST_RESEED_ENTROPY \ + 0x6e, 0xe7, 0x93, 0xa3, 0x39, 0x55, 0xd7, 0x2a, 0xd1, 0x2f, 0xd8, 0x0a, 0x8a, \ + 0x3f, 0xcf, 0x95, 0xed, 0x3b, 0x4d, 0xac, 0x57, 0x95, 0xfe, 0x25, 0xcf, \ + 0x86, 0x9f, 0x7c, 0x27, 0x57, 0x3b, 0xbc, 0x56, 0xf1, 0xac, 0xae, 0x13, \ + 0xa6, 0x50, 0x42, 0xb3, 0x40, 0x09, 0x3c, 0x46, 0x4a, 0x7a, 0x22 + +# define DRBG_TEST_GENERATED_INTERM \ + 0x28, 0xe0, 0xeb, 0xb8, 0x21, 0x01, 0x66, 0x50, 0x8c, 0x8f, 0x65, 0xf2, 0x20, \ + 0x7b, 0xd0, 0xa3 + +# define DRBG_TEST_GENERATED \ + 0x94, 0x6f, 0x51, 0x82, 0xd5, 0x45, 0x10, 0xb9, 0x46, 0x12, 0x48, 0xf5, 0x71, \ + 0xca, 0x06, 0xc9 +#elif DRBG_KEY_SIZE_BITS == 128 +/*(NIST test vector) +[AES-128 no df] +[PredictionResistance = False] +[EntropyInputLen = 256] +[NonceLen = 64] +[PersonalizationStringLen = 0] +[AdditionalInputLen = 0] + +COUNT = 0 +EntropyInput = 8fc11bdb5aabb7e093b61428e0907303cb459f3b600dad870955f22da80a44f8 +Nonce = be1f73885ddd15aa +PersonalizationString = +AdditionalInput = + INTERMEDIATE Key = b134ecc836df6dbd624900af118dd7e6 + INTERMEDIATE V = 01bb09e86dabd75c9f26dbf6f9531368 + INTERMEDIATE ReturnedBits = dc3cf6bf5bd341135f2c6811a1071c87 +EntropyInputReseed = + 0cd53cd5eccd5a10d7ea266111259b05574fc6ddd8bed8bd72378cf82f1dba2a +AdditionalInputReseed = +AdditionalInput = +ReturnedBits = b61850decfd7106d44769a8e6e8c1ad4 +*/ + +# define DRBG_TEST_INITIATE_ENTROPY \ + 0x8f, 0xc1, 0x1b, 0xdb, 0x5a, 0xab, 0xb7, 0xe0, 0x93, 0xb6, 0x14, 0x28, 0xe0, \ + 0x90, 0x73, 0x03, 0xcb, 0x45, 0x9f, 0x3b, 0x60, 0x0d, 0xad, 0x87, 0x09, \ + 0x55, 0xf2, 0x2d, 0xa8, 0x0a, 0x44, 0xf8 + +# define DRBG_TEST_RESEED_ENTROPY \ + 0x0c, 0xd5, 0x3c, 0xd5, 0xec, 0xcd, 0x5a, 0x10, 0xd7, 0xea, 0x26, 0x61, 0x11, \ + 0x25, 0x9b, 0x05, 0x57, 0x4f, 0xc6, 0xdd, 0xd8, 0xbe, 0xd8, 0xbd, 0x72, \ + 0x37, 0x8c, 0xf8, 0x2f, 0x1d, 0xba, 0x2a + +# define DRBG_TEST_GENERATED_INTERM \ + 0xdc, 0x3c, 0xf6, 0xbf, 0x5b, 0xd3, 0x41, 0x13, 0x5f, 0x2c, 0x68, 0x11, 0xa1, \ + 0x07, 0x1c, 0x87 + +# define DRBG_TEST_GENERATED \ + 0xb6, 0x18, 0x50, 0xde, 0xcf, 0xd7, 0x10, 0x6d, 0x44, 0x76, 0x9a, 0x8e, 0x6e, \ + 0x8c, 0x1a, 0xd4 + +#endif + +#endif // _MSBN_DRBG_TEST_VECTORS_H diff --git a/src/tpm2/RsaTestData.h b/src/tpm2/TPMCmd/tpm/include/private/RsaTestData.h similarity index 90% rename from src/tpm2/RsaTestData.h rename to src/tpm2/TPMCmd/tpm/include/private/RsaTestData.h index 27cb5c62c..772f59c10 100644 --- a/src/tpm2/RsaTestData.h +++ b/src/tpm2/TPMCmd/tpm/include/private/RsaTestData.h @@ -1,63 +1,4 @@ -/********************************************************************************/ -/* */ -/* RSA Test Vectors */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: RsaTestData.h 1259 2018-07-10 19:11:09Z 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 - 2018 */ -/* */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause // // RSA Test Vectors diff --git a/src/tpm2/TPMCmd/tpm/include/private/SelfTest.h b/src/tpm2/TPMCmd/tpm/include/private/SelfTest.h new file mode 100644 index 000000000..39faca3c4 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/SelfTest.h @@ -0,0 +1,73 @@ +// SPDX-License-Identifier: BSD-2-Clause + +//** Introduction +// This file contains the structure definitions for the self-test. It also contains +// macros for use when the self-test is implemented. +#ifndef _SELF_TEST_H_ +#define _SELF_TEST_H_ + +//** Defines + +// Was typing this a lot +#define SELF_TEST_FAILURE FAIL(FATAL_ERROR_SELF_TEST) + +// Use the definition of key sizes to set algorithm values for key size. +#define AES_ENTRIES (AES_128 + AES_192 + AES_256) +#define SM4_ENTRIES (SM4_128) +#define CAMELLIA_ENTRIES (CAMELLIA_128 + CAMELLIA_192 + CAMELLIA_256) +#define TDES_ENTRIES (TDES_128 * 2 + TDES_192 * 2) /* libtpms changed */ + +#define NUM_SYMS (AES_ENTRIES + SM4_ENTRIES + CAMELLIA_ENTRIES + TDES_ENTRIES) // libtpmss added TDES_ENTRIES + +typedef UINT32 SYM_INDEX; + +// These two defines deal with the fact that the TPM_ALG_ID table does not delimit +// the symmetric mode values with a SYM_MODE_FIRST and SYM_MODE_LAST +#define SYM_MODE_FIRST ALG_CTR_VALUE +#define SYM_MODE_LAST ALG_ECB_VALUE + +#define NUM_SYM_MODES (SYM_MODE_LAST - SYM_MODE_FIRST + 1) + +// Define a type to hold a bit vector for the modes. +#if NUM_SYM_MODES <= 0 +# error "No symmetric modes implemented" +#elif NUM_SYM_MODES <= 8 +typedef BYTE SYM_MODES; +#elif NUM_SYM_MODES <= 16 +typedef UINT16 SYM_MODES; +#elif NUM_SYM_MODES <= 32 +typedef UINT32 SYM_MODES; +#else +# error "Too many symmetric modes" +#endif + +typedef struct SYMMETRIC_TEST_VECTOR +{ + const TPM_ALG_ID alg; // the algorithm + const UINT16 keyBits; // bits in the key + const BYTE* key; // The test key + const UINT32 ivSize; // block size of the algorithm + const UINT32 dataInOutSize; // size to encrypt/decrypt + const BYTE* dataIn; // data to encrypt + const BYTE* dataOut[NUM_SYM_MODES]; // data to decrypt +} SYMMETRIC_TEST_VECTOR; + +#if ALG_SHA512 +# define DEFAULT_TEST_HASH ALG_SHA512_VALUE +# define DEFAULT_TEST_DIGEST_SIZE SHA512_DIGEST_SIZE +# define DEFAULT_TEST_HASH_BLOCK_SIZE SHA512_BLOCK_SIZE +#elif ALG_SHA384 +# define DEFAULT_TEST_HASH ALG_SHA384_VALUE +# define DEFAULT_TEST_DIGEST_SIZE SHA384_DIGEST_SIZE +# define DEFAULT_TEST_HASH_BLOCK_SIZE SHA384_BLOCK_SIZE +#elif ALG_SHA256 +# define DEFAULT_TEST_HASH ALG_SHA256_VALUE +# define DEFAULT_TEST_DIGEST_SIZE SHA256_DIGEST_SIZE +# define DEFAULT_TEST_HASH_BLOCK_SIZE SHA256_BLOCK_SIZE +#elif ALG_SHA1 +# define DEFAULT_TEST_HASH ALG_SHA1_VALUE +# define DEFAULT_TEST_DIGEST_SIZE SHA1_DIGEST_SIZE +# define DEFAULT_TEST_HASH_BLOCK_SIZE SHA1_BLOCK_SIZE +#endif + +#endif // _SELF_TEST_H_ diff --git a/src/tpm2/SymmetricTest.h b/src/tpm2/TPMCmd/tpm/include/private/SymmetricTest.h similarity index 50% rename from src/tpm2/SymmetricTest.h rename to src/tpm2/TPMCmd/tpm/include/private/SymmetricTest.h index c79ef1f67..6163be74b 100644 --- a/src/tpm2/SymmetricTest.h +++ b/src/tpm2/TPMCmd/tpm/include/private/SymmetricTest.h @@ -1,62 +1,4 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2023 */ -/* */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause //** Introduction diff --git a/src/tpm2/SymmetricTestData.h b/src/tpm2/TPMCmd/tpm/include/private/SymmetricTestData.h similarity index 84% rename from src/tpm2/SymmetricTestData.h rename to src/tpm2/TPMCmd/tpm/include/private/SymmetricTestData.h index c2a167f43..e1b766f0b 100644 --- a/src/tpm2/SymmetricTestData.h +++ b/src/tpm2/TPMCmd/tpm/include/private/SymmetricTestData.h @@ -1,62 +1,4 @@ -/********************************************************************************/ -/* */ -/* Vector for testing Either Encrypt or Decrypt */ -/* 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 is a vector for testing either encrypt or decrypt. The premise for decrypt // is that the IV for decryption is the same as the IV for encryption. However, diff --git a/src/tpm2/TPMCmd/tpm/include/private/Tpm.h b/src/tpm2/TPMCmd/tpm/include/private/Tpm.h new file mode 100644 index 000000000..16aefdacc --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/Tpm.h @@ -0,0 +1,20 @@ +// SPDX-License-Identifier: BSD-2-Clause + +// Root header file for building any TPM.lib code + +#ifndef _TPM_H_ +#define _TPM_H_ +// TODO_RENAME_INC_FOLDER: public refers to the TPM_CoreLib public headers +#include + +#include "tpm_public/TpmAlgorithmDefines.h" +#include "LibSupport.h" // Types from the library. These need to come before + // Global.h because some of the structures in + // that file depend on the structures used by the + // cryptographic libraries. +#include "tpm_public/GpMacros.h" // Define additional macros +#include "Global.h" // Define other TPM types +#include "InternalRoutines.h" // Function prototypes +#include "RuntimeProfile_fp.h" // libtpms added + +#endif // _TPM_H_ diff --git a/src/tpm2/TPMCmd/tpm/include/private/TpmASN1.h b/src/tpm2/TPMCmd/tpm/include/private/TpmASN1.h new file mode 100644 index 000000000..7e737d22c --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/TpmASN1.h @@ -0,0 +1,98 @@ +// SPDX-License-Identifier: BSD-2-Clause + +//** Introduction +// This file contains the macro and structure definitions for the X509 commands and +// functions. + +#ifndef _TPMASN1_H_ +#define _TPMASN1_H_ + +//** Includes + +#include "Tpm.h" +#include "OIDs.h" + +//** Defined Constants +//*** ASN.1 Universal Types (Class 00b) +#define ASN1_EOC 0x00 +#define ASN1_BOOLEAN 0x01 +#define ASN1_INTEGER 0x02 +#define ASN1_BITSTRING 0x03 +#define ASN1_OCTET_STRING 0x04 +#define ASN1_NULL 0x05 +#define ASN1_OBJECT_IDENTIFIER 0x06 +#define ASN1_OBJECT_DESCRIPTOR 0x07 +#define ASN1_EXTERNAL 0x08 +#define ASN1_REAL 0x09 +#define ASN1_ENUMERATED 0x0A +#define ASN1_EMBEDDED 0x0B +#define ASN1_UTF8String 0x0C +#define ASN1_RELATIVE_OID 0x0D +#define ASN1_SEQUENCE 0x10 // Primitive + Constructed + 0x10 +#define ASN1_SET 0x11 // Primitive + Constructed + 0x11 +#define ASN1_NumericString 0x12 +#define ASN1_PrintableString 0x13 +#define ASN1_T61String 0x14 +#define ASN1_VideoString 0x15 +#define ASN1_IA5String 0x16 +#define ASN1_UTCTime 0x17 +#define ASN1_GeneralizeTime 0x18 +#define ASN1_VisibleString 0x1A +#define ASN1_GeneralString 0x1B +#define ASN1_UniversalString 0x1C +#define ASN1_CHARACTER STRING 0x1D +#define ASN1_BMPString 0x1E +#define ASN1_CONSTRUCTED 0x20 + +#define ASN1_APPLICAIION_SPECIFIC 0xA0 + +#define ASN1_CONSTRUCTED_SEQUENCE (ASN1_SEQUENCE + ASN1_CONSTRUCTED) + +#define MAX_DEPTH 10 // maximum push depth for marshaling context. + +//** Macros + +//*** Unmarshaling Macros +#ifndef GOTO_ERROR_UNLESS +# error missing GOTO_ERROR_UNLESS definition +#endif + +// Checks the validity of the size making sure that there is no wrap around +#define CHECK_SIZE(context, length) \ + GOTO_ERROR_UNLESS((((length) + (context)->offset) >= (context)->offset) \ + && (((length) + (context)->offset) <= (context)->size)) +#define NEXT_OCTET(context) ((context)->buffer[(context)->offset++]) +#define PEEK_NEXT(context) ((context)->buffer[(context)->offset]) + +//*** Marshaling Macros + +// Marshaling works in reverse order. The offset is set to the top of the buffer and, +// as the buffer is filled, 'offset' counts down to zero. When the full thing is +// encoded it can be moved to the top of the buffer. This happens when the last +// context is closed. + +#define CHECK_SPACE(context, length) GOTO_ERROR_UNLESS(context->offset > length) + +//** Structures + +typedef struct ASN1UnmarshalContext +{ + BYTE* buffer; // pointer to the buffer + INT16 size; // size of the buffer (a negative number indicates + // a parsing failure). + INT16 offset; // current offset into the buffer (a negative number + // indicates a parsing failure). Not used + BYTE tag; // The last unmarshaled tag +} ASN1UnmarshalContext; + +typedef struct ASN1MarshalContext +{ + BYTE* buffer; // pointer to the start of the buffer + INT16 offset; // place on the top where the last entry was added + // items are added from the bottom up. + INT16 end; // the end offset of the current value + INT16 depth; // how many pushed end values. + INT16 ends[MAX_DEPTH]; +} ASN1MarshalContext; + +#endif // _TPMASN1_H_ diff --git a/src/tpm2/TPMCmd/tpm/include/private/X509.h b/src/tpm2/TPMCmd/tpm/include/private/X509.h new file mode 100644 index 000000000..396d739e6 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/X509.h @@ -0,0 +1,100 @@ +// SPDX-License-Identifier: BSD-2-Clause + +//** Introduction +// This file contains the macro and structure definitions for the X509 commands and +// functions. + +#ifndef _X509_H_ +#define _X509_H_ + +//** Includes + +#include "Tpm.h" +#include "TpmASN1.h" + +//** Defined Constants + +//*** X509 Application-specific types +#define X509_SELECTION 0xA0 +#define X509_ISSUER_UNIQUE_ID 0xA1 +#define X509_SUBJECT_UNIQUE_ID 0xA2 +#define X509_EXTENSIONS 0xA3 + +// These defines give the order in which values appear in the TBScertificate +// of an x.509 certificate. These values are used to index into an array of +// +#define ENCODED_SIZE_REF 0 +#define VERSION_REF (ENCODED_SIZE_REF + 1) +#define SERIAL_NUMBER_REF (VERSION_REF + 1) +#define SIGNATURE_REF (SERIAL_NUMBER_REF + 1) +#define ISSUER_REF (SIGNATURE_REF + 1) +#define VALIDITY_REF (ISSUER_REF + 1) +#define SUBJECT_KEY_REF (VALIDITY_REF + 1) +#define SUBJECT_PUBLIC_KEY_REF (SUBJECT_KEY_REF + 1) +#define EXTENSIONS_REF (SUBJECT_PUBLIC_KEY_REF + 1) +#define REF_COUNT (EXTENSIONS_REF + 1) + +//** Structures + +// Used to access the fields of a TBSsignature some of which are in the in_CertifyX509 +// structure and some of which are in the out_CertifyX509 structure. +typedef struct stringRef +{ + BYTE* buf; + INT16 len; +} stringRef; + +// This is defined to avoid bit by bit comparisons within a UINT32 +typedef union x509KeyUsageUnion +{ + TPMA_X509_KEY_USAGE x509; + UINT32 integer; +} x509KeyUsageUnion; + +//** Global X509 Constants +// These values are instanced by X509_spt.c and referenced by other X509-related +// files. + +// This is the DER-encoded value for the Key Usage OID (2.5.29.15). This is the +// full OID, not just the numeric value +#define OID_KEY_USAGE_EXTENSION_VALUE 0x06, 0x03, 0x55, 0x1D, 0x0F +MAKE_OID(_KEY_USAGE_EXTENSION); + +// This is the DER-encoded value for the TCG-defined TPMA_OBJECT OID +// (2.23.133.10.1.1.1) +#define OID_TCG_TPMA_OBJECT_VALUE 0x06, 0x07, 0x67, 0x81, 0x05, 0x0a, 0x01, 0x01, 0x01 +MAKE_OID(_TCG_TPMA_OBJECT); + +#ifdef _X509_SPT_ +// If a bit is SET in KEY_USAGE_SIGN is also SET in keyUsage then +// the associated key has to have 'sign' SET. +const x509KeyUsageUnion KEY_USAGE_SIGN = {TPMA_X509_KEY_USAGE_INITIALIZER( + /* bits_at_0 */ 0, + /* decipheronly */ 0, + /* encipheronly */ 0, + /* crlsign */ 1, + /* keycertsign */ 1, + /* keyagreement */ 0, + /* dataencipherment */ 0, + /* keyencipherment */ 0, + /* nonrepudiation */ 0, + /* digitalsignature */ 1)}; +// If a bit is SET in KEY_USAGE_DECRYPT is also SET in keyUsage then +// the associated key has to have 'decrypt' SET. +const x509KeyUsageUnion KEY_USAGE_DECRYPT = {TPMA_X509_KEY_USAGE_INITIALIZER( + /* bits_at_0 */ 0, + /* decipheronly */ 1, + /* encipheronly */ 1, + /* crlsign */ 0, + /* keycertsign */ 0, + /* keyagreement */ 1, + /* dataencipherment */ 1, + /* keyencipherment */ 1, + /* nonrepudiation */ 0, + /* digitalsignature */ 0)}; +#else +extern x509KeyUsageUnion KEY_USAGE_SIGN; +extern x509KeyUsageUnion KEY_USAGE_DECRYPT; +#endif + +#endif // _X509_H_ diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/ACT_SetTimeout_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/ACT_SetTimeout_fp.h new file mode 100644 index 000000000..3ea3f8c9c --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/ACT_SetTimeout_fp.h @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_ACT_SetTimeout // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_ACT_SETTIMEOUT_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_ACT_SETTIMEOUT_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_RH_ACT actHandle; + UINT32 startTimeout; +} ACT_SetTimeout_In; + +// Response code modifiers +# define RC_ACT_SetTimeout_actHandle (TPM_RC_H + TPM_RC_1) +# define RC_ACT_SetTimeout_startTimeout (TPM_RC_P + TPM_RC_1) + +// Function prototype +TPM_RC +TPM2_ACT_SetTimeout(ACT_SetTimeout_In* in); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_ACT_SETTIMEOUT_FP_H_ +#endif // CC_ACT_SetTimeout diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/ACT_spt_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/ACT_spt_fp.h new file mode 100644 index 000000000..dd7cae3ce --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/ACT_spt_fp.h @@ -0,0 +1,54 @@ +// SPDX-License-Identifier: BSD-2-Clause + +/*(Auto-generated) + * Created by TpmPrototypes 1.00 + * Date: Oct 24, 2019 Time: 10:38:43AM + */ + +#ifndef _ACT_SPT_FP_H_ +#define _ACT_SPT_FP_H_ + +//*** ActStartup() +// This function is called by TPM2_Startup() to initialize the ACT counter values. +BOOL ActStartup(STARTUP_TYPE type); + +//*** ActGetSignaled() +// This function returns the state of the signaled flag associated with an ACT. +BOOL ActGetSignaled(TPM_RH actHandle); + +//***ActShutdown() +// This function saves the current state of the counters +BOOL ActShutdown(TPM_SU state //IN: the type of the shutdown. +); + +//*** ActIsImplemented() +// This function determines if an ACT is implemented in both the TPM and the platform +// code. +BOOL ActIsImplemented(UINT32 act); + +//***ActCounterUpdate() +// This function updates the ACT counter. If the counter already has a pending update, +// it returns TPM_RC_RETRY so that the update can be tried again later. +TPM_RC +ActCounterUpdate(TPM_RH handle, //IN: the handle of the act + UINT32 newValue //IN: the value to set in the ACT +); + +//*** ActGetCapabilityData() +// This function returns the list of ACT data +// Return Type: TPMI_YES_NO +// YES if more ACT data is available +// NO if no more ACT data to +TPMI_YES_NO +ActGetCapabilityData(TPM_HANDLE actHandle, // IN: the handle for the starting ACT + UINT32 maxCount, // IN: maximum allowed return values + TPML_ACT_DATA* actList // OUT: ACT data list +); + +//*** ActGetOneCapability() +// This function returns an ACT's capability, if present. +BOOL ActGetOneCapability(TPM_HANDLE actHandle, // IN: the handle for the ACT + TPMS_ACT_DATA* actData // OUT: ACT data +); + +#endif // _ACT_SPT_FP_H_ diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/ActivateCredential_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/ActivateCredential_fp.h new file mode 100644 index 000000000..c6e28ea31 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/ActivateCredential_fp.h @@ -0,0 +1,37 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_ActivateCredential // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_ACTIVATECREDENTIAL_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_ACTIVATECREDENTIAL_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_DH_OBJECT activateHandle; + TPMI_DH_OBJECT keyHandle; + TPM2B_ID_OBJECT credentialBlob; + TPM2B_ENCRYPTED_SECRET secret; +} ActivateCredential_In; + +// Output structure definition +typedef struct +{ + TPM2B_DIGEST certInfo; +} ActivateCredential_Out; + +// Response code modifiers +# define RC_ActivateCredential_activateHandle (TPM_RC_H + TPM_RC_1) +# define RC_ActivateCredential_keyHandle (TPM_RC_H + TPM_RC_2) +# define RC_ActivateCredential_credentialBlob (TPM_RC_P + TPM_RC_1) +# define RC_ActivateCredential_secret (TPM_RC_P + TPM_RC_2) + +// Function prototype +TPM_RC +TPM2_ActivateCredential(ActivateCredential_In* in, ActivateCredential_Out* out); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_ACTIVATECREDENTIAL_FP_H_ +#endif // CC_ActivateCredential diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/AlgorithmCap_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/AlgorithmCap_fp.h new file mode 100644 index 000000000..5e19a0fc2 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/AlgorithmCap_fp.h @@ -0,0 +1,39 @@ +// SPDX-License-Identifier: BSD-2-Clause + +/*(Auto-generated) + * Created by TpmPrototypes; Version 3.0 July 18, 2017 + * Date: Mar 28, 2019 Time: 08:25:19PM + */ + +#ifndef _ALGORITHM_CAP_FP_H_ +#define _ALGORITHM_CAP_FP_H_ + +//** AlgorithmCapGetImplemented() +// This function is used by TPM2_GetCapability() to return a list of the +// implemented algorithms. +// +// Return Type: TPMI_YES_NO +// YES more algorithms to report +// NO no more algorithms to report +TPMI_YES_NO +AlgorithmCapGetImplemented(TPM_ALG_ID algID, // IN: the starting algorithm ID + UINT32 count, // IN: count of returned algorithms + TPML_ALG_PROPERTY* algList // OUT: algorithm list +); + +//** AlgorithmCapGetOneImplemented() +// This function returns whether a single algorithm was implemented, along +// with its properties (if implemented). +BOOL AlgorithmCapGetOneImplemented( + TPM_ALG_ID algID, // IN: the algorithm ID + TPMS_ALG_PROPERTY* algProperty // OUT: algorithm properties +); + +//** AlgorithmGetImplementedVector() +// This function returns the bit vector of the implemented algorithms. +LIB_EXPORT +void AlgorithmGetImplementedVector( + ALGORITHM_VECTOR* implemented // OUT: the implemented bits are SET +); + +#endif // _ALGORITHM_CAP_FP_H_ diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/AlgorithmTests_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/AlgorithmTests_fp.h new file mode 100644 index 000000000..392fa8bab --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/AlgorithmTests_fp.h @@ -0,0 +1,37 @@ +// SPDX-License-Identifier: BSD-2-Clause + +/*(Auto-generated) + * Created by TpmPrototypes; Version 3.0 July 18, 2017 + * Date: Mar 4, 2020 Time: 02:36:44PM + */ + +#ifndef _ALGORITHM_TESTS_FP_H_ +#define _ALGORITHM_TESTS_FP_H_ + +#if ENABLE_SELF_TESTS + +//*** TestAlgorithm() +// Dispatches to the correct test function for the algorithm or gets a list of +// testable algorithms. +// +// If 'toTest' is not NULL, then the test decisions are based on the algorithm +// selections in 'toTest'. Otherwise, 'g_toTest' is used. When bits are clear in +// 'g_toTest' they will also be cleared 'toTest'. +// +// If there doesn't happen to be a test for the algorithm, its associated bit is +// quietly cleared. +// +// If 'alg' is zero (TPM_ALG_ERROR), then the toTest vector is cleared of any bits +// for which there is no test (i.e. no tests are actually run but the vector is +// cleared). +// +// Note: 'toTest' will only ever have bits set for implemented algorithms but 'alg' +// can be anything. +// Return Type: TPM_RC +// TPM_RC_CANCELED test was canceled +LIB_EXPORT +TPM_RC +TestAlgorithm(TPM_ALG_ID alg, ALGORITHM_VECTOR* toTest); +#endif // ENABLE_SELF_TESTS + +#endif // _ALGORITHM_TESTS_FP_H_ diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/Attest_spt_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/Attest_spt_fp.h new file mode 100644 index 000000000..36d13431b --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/Attest_spt_fp.h @@ -0,0 +1,52 @@ +// SPDX-License-Identifier: BSD-2-Clause + +/*(Auto-generated) + * Created by TpmPrototypes; Version 3.0 July 18, 2017 + * Date: Mar 28, 2019 Time: 08:25:18PM + */ + +#ifndef _ATTEST_SPT_FP_H_ +#define _ATTEST_SPT_FP_H_ + +//***FillInAttestInfo() +// Fill in common fields of TPMS_ATTEST structure. +void FillInAttestInfo( + TPMI_DH_OBJECT signHandle, // IN: handle of signing object + TPMT_SIG_SCHEME* scheme, // IN/OUT: scheme to be used for signing + TPM2B_DATA* data, // IN: qualifying data + TPMS_ATTEST* attest // OUT: attest structure +); + +//***SignAttestInfo() +// Sign a TPMS_ATTEST structure. If signHandle is TPM_RH_NULL, a null signature +// is returned. +// +// Return Type: TPM_RC +// TPM_RC_ATTRIBUTES 'signHandle' references not a signing key +// TPM_RC_SCHEME 'scheme' is not compatible with 'signHandle' type +// TPM_RC_VALUE digest generated for the given 'scheme' is greater than +// the modulus of 'signHandle' (for an RSA key); +// invalid commit status or failed to generate "r" value +// (for an ECC key) +TPM_RC +SignAttestInfo(OBJECT* signKey, // IN: sign object + TPMT_SIG_SCHEME* scheme, // IN: sign scheme + TPMS_ATTEST* certifyInfo, // IN: the data to be signed + TPM2B_DATA* qualifyingData, // IN: extra data for the signing + // process + TPM2B_ATTEST* attest, // OUT: marshaled attest blob to be + // signed + TPMT_SIGNATURE* signature // OUT: signature +); + +//*** IsSigningObject() +// Checks to see if the object is OK for signing. This is here rather than in +// Object_spt.c because all the attestation commands use this file but not +// Object_spt.c. +// Return Type: BOOL +// TRUE(1) object may sign +// FALSE(0) object may not sign +BOOL IsSigningObject(OBJECT* object // IN: +); + +#endif // _ATTEST_SPT_FP_H_ diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/Bits_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/Bits_fp.h new file mode 100644 index 000000000..858738777 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/Bits_fp.h @@ -0,0 +1,35 @@ +// SPDX-License-Identifier: BSD-2-Clause + +/*(Auto-generated) + * Created by TpmPrototypes; Version 3.0 July 18, 2017 + * Date: Mar 28, 2019 Time: 08:25:19PM + */ + +#ifndef _BITS_FP_H_ +#define _BITS_FP_H_ + +//*** TestBit() +// This function is used to check the setting of a bit in an array of bits. +// Return Type: BOOL +// TRUE(1) bit is set +// FALSE(0) bit is not set +BOOL TestBit(unsigned int bitNum, // IN: number of the bit in 'bArray' + BYTE* bArray, // IN: array containing the bits + unsigned int bytesInArray // IN: size in bytes of 'bArray' +); + +//*** SetBit() +// This function will set the indicated bit in 'bArray'. +void SetBit(unsigned int bitNum, // IN: number of the bit in 'bArray' + BYTE* bArray, // IN: array containing the bits + unsigned int bytesInArray // IN: size in bytes of 'bArray' +); + +//*** ClearBit() +// This function will clear the indicated bit in 'bArray'. +void ClearBit(unsigned int bitNum, // IN: number of the bit in 'bArray'. + BYTE* bArray, // IN: array containing the bits + unsigned int bytesInArray // IN: size in bytes of 'bArray' +); + +#endif // _BITS_FP_H_ diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/CertifyCreation_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/CertifyCreation_fp.h new file mode 100644 index 000000000..164cdbaf3 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/CertifyCreation_fp.h @@ -0,0 +1,42 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_CertifyCreation // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_CERTIFYCREATION_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_CERTIFYCREATION_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_DH_OBJECT signHandle; + TPMI_DH_OBJECT objectHandle; + TPM2B_DATA qualifyingData; + TPM2B_DIGEST creationHash; + TPMT_SIG_SCHEME inScheme; + TPMT_TK_CREATION creationTicket; +} CertifyCreation_In; + +// Output structure definition +typedef struct +{ + TPM2B_ATTEST certifyInfo; + TPMT_SIGNATURE signature; +} CertifyCreation_Out; + +// Response code modifiers +# define RC_CertifyCreation_signHandle (TPM_RC_H + TPM_RC_1) +# define RC_CertifyCreation_objectHandle (TPM_RC_H + TPM_RC_2) +# define RC_CertifyCreation_qualifyingData (TPM_RC_P + TPM_RC_1) +# define RC_CertifyCreation_creationHash (TPM_RC_P + TPM_RC_2) +# define RC_CertifyCreation_inScheme (TPM_RC_P + TPM_RC_3) +# define RC_CertifyCreation_creationTicket (TPM_RC_P + TPM_RC_4) + +// Function prototype +TPM_RC +TPM2_CertifyCreation(CertifyCreation_In* in, CertifyCreation_Out* out); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_CERTIFYCREATION_FP_H_ +#endif // CC_CertifyCreation diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/CertifyX509_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/CertifyX509_fp.h new file mode 100644 index 000000000..96d4576ee --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/CertifyX509_fp.h @@ -0,0 +1,41 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_CertifyX509 // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_CERTIFYX509_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_CERTIFYX509_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_DH_OBJECT objectHandle; + TPMI_DH_OBJECT signHandle; + TPM2B_DATA reserved; + TPMT_SIG_SCHEME inScheme; + TPM2B_MAX_BUFFER partialCertificate; +} CertifyX509_In; + +// Output structure definition +typedef struct +{ + TPM2B_MAX_BUFFER addedToCertificate; + TPM2B_DIGEST tbsDigest; + TPMT_SIGNATURE signature; +} CertifyX509_Out; + +// Response code modifiers +# define RC_CertifyX509_objectHandle (TPM_RC_H + TPM_RC_1) +# define RC_CertifyX509_signHandle (TPM_RC_H + TPM_RC_2) +# define RC_CertifyX509_reserved (TPM_RC_P + TPM_RC_1) +# define RC_CertifyX509_inScheme (TPM_RC_P + TPM_RC_2) +# define RC_CertifyX509_partialCertificate (TPM_RC_P + TPM_RC_3) + +// Function prototype +TPM_RC +TPM2_CertifyX509(CertifyX509_In* in, CertifyX509_Out* out); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_CERTIFYX509_FP_H_ +#endif // CC_CertifyX509 diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/Certify_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/Certify_fp.h new file mode 100644 index 000000000..8be033486 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/Certify_fp.h @@ -0,0 +1,38 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_Certify // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_CERTIFY_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_CERTIFY_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_DH_OBJECT objectHandle; + TPMI_DH_OBJECT signHandle; + TPM2B_DATA qualifyingData; + TPMT_SIG_SCHEME inScheme; +} Certify_In; + +// Output structure definition +typedef struct +{ + TPM2B_ATTEST certifyInfo; + TPMT_SIGNATURE signature; +} Certify_Out; + +// Response code modifiers +# define RC_Certify_objectHandle (TPM_RC_H + TPM_RC_1) +# define RC_Certify_signHandle (TPM_RC_H + TPM_RC_2) +# define RC_Certify_qualifyingData (TPM_RC_P + TPM_RC_1) +# define RC_Certify_inScheme (TPM_RC_P + TPM_RC_2) + +// Function prototype +TPM_RC +TPM2_Certify(Certify_In* in, Certify_Out* out); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_CERTIFY_FP_H_ +#endif // CC_Certify diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/ChangeEPS_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/ChangeEPS_fp.h new file mode 100644 index 000000000..29c7edca7 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/ChangeEPS_fp.h @@ -0,0 +1,25 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_ChangeEPS // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_CHANGEEPS_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_CHANGEEPS_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_RH_PLATFORM authHandle; +} ChangeEPS_In; + +// Response code modifiers +# define RC_ChangeEPS_authHandle (TPM_RC_H + TPM_RC_1) + +// Function prototype +TPM_RC +TPM2_ChangeEPS(ChangeEPS_In* in); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_CHANGEEPS_FP_H_ +#endif // CC_ChangeEPS diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/ChangePPS_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/ChangePPS_fp.h new file mode 100644 index 000000000..e705e66b1 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/ChangePPS_fp.h @@ -0,0 +1,25 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_ChangePPS // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_CHANGEPPS_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_CHANGEPPS_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_RH_PLATFORM authHandle; +} ChangePPS_In; + +// Response code modifiers +# define RC_ChangePPS_authHandle (TPM_RC_H + TPM_RC_1) + +// Function prototype +TPM_RC +TPM2_ChangePPS(ChangePPS_In* in); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_CHANGEPPS_FP_H_ +#endif // CC_ChangePPS diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/ClearControl_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/ClearControl_fp.h new file mode 100644 index 000000000..2d929a0d4 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/ClearControl_fp.h @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_ClearControl // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_CLEARCONTROL_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_CLEARCONTROL_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_RH_CLEAR auth; + TPMI_YES_NO disable; +} ClearControl_In; + +// Response code modifiers +# define RC_ClearControl_auth (TPM_RC_H + TPM_RC_1) +# define RC_ClearControl_disable (TPM_RC_P + TPM_RC_1) + +// Function prototype +TPM_RC +TPM2_ClearControl(ClearControl_In* in); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_CLEARCONTROL_FP_H_ +#endif // CC_ClearControl diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/Clear_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/Clear_fp.h new file mode 100644 index 000000000..07f12bfb2 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/Clear_fp.h @@ -0,0 +1,25 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_Clear // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_CLEAR_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_CLEAR_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_RH_CLEAR authHandle; +} Clear_In; + +// Response code modifiers +# define RC_Clear_authHandle (TPM_RC_H + TPM_RC_1) + +// Function prototype +TPM_RC +TPM2_Clear(Clear_In* in); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_CLEAR_FP_H_ +#endif // CC_Clear diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/ClockRateAdjust_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/ClockRateAdjust_fp.h new file mode 100644 index 000000000..fa78ada9f --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/ClockRateAdjust_fp.h @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_ClockRateAdjust // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_CLOCKRATEADJUST_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_CLOCKRATEADJUST_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_RH_PROVISION auth; + TPM_CLOCK_ADJUST rateAdjust; +} ClockRateAdjust_In; + +// Response code modifiers +# define RC_ClockRateAdjust_auth (TPM_RC_H + TPM_RC_1) +# define RC_ClockRateAdjust_rateAdjust (TPM_RC_P + TPM_RC_1) + +// Function prototype +TPM_RC +TPM2_ClockRateAdjust(ClockRateAdjust_In* in); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_CLOCKRATEADJUST_FP_H_ +#endif // CC_ClockRateAdjust diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/ClockSet_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/ClockSet_fp.h new file mode 100644 index 000000000..e48643ef1 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/ClockSet_fp.h @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_ClockSet // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_CLOCKSET_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_CLOCKSET_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_RH_PROVISION auth; + UINT64 newTime; +} ClockSet_In; + +// Response code modifiers +# define RC_ClockSet_auth (TPM_RC_H + TPM_RC_1) +# define RC_ClockSet_newTime (TPM_RC_P + TPM_RC_1) + +// Function prototype +TPM_RC +TPM2_ClockSet(ClockSet_In* in); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_CLOCKSET_FP_H_ +#endif // CC_ClockSet diff --git a/src/tpm2/CommandAudit_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/CommandAudit_fp.h similarity index 51% rename from src/tpm2/CommandAudit_fp.h rename to src/tpm2/TPMCmd/tpm/include/private/prototypes/CommandAudit_fp.h index ed6dd60cf..e05544c58 100644 --- a/src/tpm2/CommandAudit_fp.h +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/CommandAudit_fp.h @@ -1,62 +1,4 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2016 - 2023 */ -/* */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause /*(Auto-generated) * Created by TpmPrototypes; Version 3.0 July 18, 2017 diff --git a/src/tpm2/CommandCodeAttributes_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/CommandCodeAttributes_fp.h similarity index 60% rename from src/tpm2/CommandCodeAttributes_fp.h rename to src/tpm2/TPMCmd/tpm/include/private/prototypes/CommandCodeAttributes_fp.h index de5d8def2..7b7b090c7 100644 --- a/src/tpm2/CommandCodeAttributes_fp.h +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/CommandCodeAttributes_fp.h @@ -1,62 +1,4 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2016 - 2023 */ -/* */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause /*(Auto-generated) * Created by TpmPrototypes; Version 3.0 July 18, 2017 @@ -151,6 +93,10 @@ BOOL IsSessionAllowed(COMMAND_INDEX commandIndex // IN: the command to be check // This function determines if a command has a handle in the response BOOL IsHandleInResponse(COMMAND_INDEX commandIndex); +//*** IsDisallowedInReadOnlyMode() +// This function determines if a command is disallowed when operating in Read-Only mode +BOOL IsDisallowedInReadOnlyMode(COMMAND_INDEX commandIndex); + //*** IsWriteOperation() // Checks to see if an operation will write to an NV Index and is subject to being // blocked by read-lock diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/CommandDispatcher_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/CommandDispatcher_fp.h new file mode 100644 index 000000000..27ca42848 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/CommandDispatcher_fp.h @@ -0,0 +1,22 @@ +// SPDX-License-Identifier: BSD-2-Clause + +/*(Auto-generated) + * Created by TpmPrototypes; Version 3.0 July 18, 2017 + * Date: Mar 7, 2020 Time: 07:06:44PM + */ + +#ifndef _COMMAND_DISPATCHER_FP_H_ +#define _COMMAND_DISPATCHER_FP_H_ + +//** ParseHandleBuffer() +// This is the table-driven version of the handle buffer unmarshaling code +TPM_RC +ParseHandleBuffer(COMMAND* command); + +//** CommandDispatcher() +// Function to unmarshal the command parameters, call the selected action code, and +// marshal the response parameters. +TPM_RC +CommandDispatcher(COMMAND* command); + +#endif // _COMMAND_DISPATCHER_FP_H_ diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/Commit_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/Commit_fp.h new file mode 100644 index 000000000..b88e4229c --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/Commit_fp.h @@ -0,0 +1,40 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_Commit // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_COMMIT_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_COMMIT_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_DH_OBJECT signHandle; + TPM2B_ECC_POINT P1; + TPM2B_SENSITIVE_DATA s2; + TPM2B_ECC_PARAMETER y2; +} Commit_In; + +// Output structure definition +typedef struct +{ + TPM2B_ECC_POINT K; + TPM2B_ECC_POINT L; + TPM2B_ECC_POINT E; + UINT16 counter; +} Commit_Out; + +// Response code modifiers +# define RC_Commit_signHandle (TPM_RC_H + TPM_RC_1) +# define RC_Commit_P1 (TPM_RC_P + TPM_RC_1) +# define RC_Commit_s2 (TPM_RC_P + TPM_RC_2) +# define RC_Commit_y2 (TPM_RC_P + TPM_RC_3) + +// Function prototype +TPM_RC +TPM2_Commit(Commit_In* in, Commit_Out* out); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_COMMIT_FP_H_ +#endif // CC_Commit diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/ContextLoad_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/ContextLoad_fp.h new file mode 100644 index 000000000..39e8b7ace --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/ContextLoad_fp.h @@ -0,0 +1,31 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_ContextLoad // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_CONTEXTLOAD_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_CONTEXTLOAD_FP_H_ + +// Input structure definition +typedef struct +{ + TPMS_CONTEXT context; +} ContextLoad_In; + +// Output structure definition +typedef struct +{ + TPMI_DH_CONTEXT loadedHandle; +} ContextLoad_Out; + +// Response code modifiers +# define RC_ContextLoad_context (TPM_RC_P + TPM_RC_1) + +// Function prototype +TPM_RC +TPM2_ContextLoad(ContextLoad_In* in, ContextLoad_Out* out); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_CONTEXTLOAD_FP_H_ +#endif // CC_ContextLoad diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/ContextSave_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/ContextSave_fp.h new file mode 100644 index 000000000..1ef6c05f9 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/ContextSave_fp.h @@ -0,0 +1,31 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_ContextSave // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_CONTEXTSAVE_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_CONTEXTSAVE_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_DH_CONTEXT saveHandle; +} ContextSave_In; + +// Output structure definition +typedef struct +{ + TPMS_CONTEXT context; +} ContextSave_Out; + +// Response code modifiers +# define RC_ContextSave_saveHandle (TPM_RC_H + TPM_RC_1) + +// Function prototype +TPM_RC +TPM2_ContextSave(ContextSave_In* in, ContextSave_Out* out); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_CONTEXTSAVE_FP_H_ +#endif // CC_ContextSave diff --git a/src/tpm2/Context_spt_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/Context_spt_fp.h similarity index 52% rename from src/tpm2/Context_spt_fp.h rename to src/tpm2/TPMCmd/tpm/include/private/prototypes/Context_spt_fp.h index 5b7e892e8..f7e61e13b 100644 --- a/src/tpm2/Context_spt_fp.h +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/Context_spt_fp.h @@ -1,62 +1,4 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2016 - 2023 */ -/* */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause /*(Auto-generated) * Created by TpmPrototypes; Version 3.0 July 18, 2017 diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/CreateLoaded_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/CreateLoaded_fp.h new file mode 100644 index 000000000..81b9ccadc --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/CreateLoaded_fp.h @@ -0,0 +1,38 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_CreateLoaded // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_CREATELOADED_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_CREATELOADED_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_DH_PARENT parentHandle; + TPM2B_SENSITIVE_CREATE inSensitive; + TPM2B_TEMPLATE inPublic; +} CreateLoaded_In; + +// Output structure definition +typedef struct +{ + TPM_HANDLE objectHandle; + TPM2B_PRIVATE outPrivate; + TPM2B_PUBLIC outPublic; + TPM2B_NAME name; +} CreateLoaded_Out; + +// Response code modifiers +# define RC_CreateLoaded_parentHandle (TPM_RC_H + TPM_RC_1) +# define RC_CreateLoaded_inSensitive (TPM_RC_P + TPM_RC_1) +# define RC_CreateLoaded_inPublic (TPM_RC_P + TPM_RC_2) + +// Function prototype +TPM_RC +TPM2_CreateLoaded(CreateLoaded_In* in, CreateLoaded_Out* out); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_CREATELOADED_FP_H_ +#endif // CC_CreateLoaded diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/CreatePrimary_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/CreatePrimary_fp.h new file mode 100644 index 000000000..4620fb7ce --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/CreatePrimary_fp.h @@ -0,0 +1,44 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_CreatePrimary // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_CREATEPRIMARY_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_CREATEPRIMARY_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_RH_HIERARCHY primaryHandle; + TPM2B_SENSITIVE_CREATE inSensitive; + TPM2B_PUBLIC inPublic; + TPM2B_DATA outsideInfo; + TPML_PCR_SELECTION creationPCR; +} CreatePrimary_In; + +// Output structure definition +typedef struct +{ + TPM_HANDLE objectHandle; + TPM2B_PUBLIC outPublic; + TPM2B_CREATION_DATA creationData; + TPM2B_DIGEST creationHash; + TPMT_TK_CREATION creationTicket; + TPM2B_NAME name; +} CreatePrimary_Out; + +// Response code modifiers +# define RC_CreatePrimary_primaryHandle (TPM_RC_H + TPM_RC_1) +# define RC_CreatePrimary_inSensitive (TPM_RC_P + TPM_RC_1) +# define RC_CreatePrimary_inPublic (TPM_RC_P + TPM_RC_2) +# define RC_CreatePrimary_outsideInfo (TPM_RC_P + TPM_RC_3) +# define RC_CreatePrimary_creationPCR (TPM_RC_P + TPM_RC_4) + +// Function prototype +TPM_RC +TPM2_CreatePrimary(CreatePrimary_In* in, CreatePrimary_Out* out); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_CREATEPRIMARY_FP_H_ +#endif // CC_CreatePrimary diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/Create_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/Create_fp.h new file mode 100644 index 000000000..54b1a753d --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/Create_fp.h @@ -0,0 +1,43 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_Create // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_CREATE_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_CREATE_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_DH_OBJECT parentHandle; + TPM2B_SENSITIVE_CREATE inSensitive; + TPM2B_PUBLIC inPublic; + TPM2B_DATA outsideInfo; + TPML_PCR_SELECTION creationPCR; +} Create_In; + +// Output structure definition +typedef struct +{ + TPM2B_PRIVATE outPrivate; + TPM2B_PUBLIC outPublic; + TPM2B_CREATION_DATA creationData; + TPM2B_DIGEST creationHash; + TPMT_TK_CREATION creationTicket; +} Create_Out; + +// Response code modifiers +# define RC_Create_parentHandle (TPM_RC_H + TPM_RC_1) +# define RC_Create_inSensitive (TPM_RC_P + TPM_RC_1) +# define RC_Create_inPublic (TPM_RC_P + TPM_RC_2) +# define RC_Create_outsideInfo (TPM_RC_P + TPM_RC_3) +# define RC_Create_creationPCR (TPM_RC_P + TPM_RC_4) + +// Function prototype +TPM_RC +TPM2_Create(Create_In* in, Create_Out* out); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_CREATE_FP_H_ +#endif // CC_Create diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/CryptCmac_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/CryptCmac_fp.h new file mode 100644 index 000000000..993ac3abf --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/CryptCmac_fp.h @@ -0,0 +1,39 @@ +// SPDX-License-Identifier: BSD-2-Clause + +/*(Auto-generated) + * Created by TpmPrototypes; Version 3.0 July 18, 2017 + * Date: Mar 28, 2019 Time: 08:25:18PM + */ + +#ifndef _CRYPT_CMAC_FP_H_ +#define _CRYPT_CMAC_FP_H_ + +#if ALG_CMAC + +//*** CryptCmacStart() +// This is the function to start the CMAC sequence operation. It initializes the +// dispatch functions for the data and end operations for CMAC and initializes the +// parameters that are used for the processing of data, including the key, key size +// and block cipher algorithm. +UINT16 +CryptCmacStart( + SMAC_STATE* state, TPMU_PUBLIC_PARMS* keyParms, TPM_ALG_ID macAlg, TPM2B* key); + +//*** CryptCmacData() +// This function is used to add data to the CMAC sequence computation. The function +// will XOR new data into the IV. If the buffer is full, and there is additional +// input data, the data is encrypted into the IV buffer, the new data is then +// XOR into the IV. When the data runs out, the function returns without encrypting +// even if the buffer is full. The last data block of a sequence will not be +// encrypted until the call to CryptCmacEnd(). This is to allow the proper subkey +// to be computed and applied before the last block is encrypted. +void CryptCmacData(SMAC_STATES* state, UINT32 size, const BYTE* buffer); + +//*** CryptCmacEnd() +// This is the completion function for the CMAC. It does padding, if needed, and +// selects the subkey to be applied before the last block is encrypted. +UINT16 +CryptCmacEnd(SMAC_STATES* state, UINT32 outSize, BYTE* outBuffer); +#endif + +#endif // _CRYPT_CMAC_FP_H_ diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/CryptEccCrypt_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/CryptEccCrypt_fp.h new file mode 100644 index 000000000..c82db9c37 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/CryptEccCrypt_fp.h @@ -0,0 +1,62 @@ +// SPDX-License-Identifier: BSD-2-Clause + +/*(Auto-generated) + * Created by TpmPrototypes; Version 3.0 July 18, 2017 + * Date: Feb 28, 2020 Time: 03:04:48PM + */ + +#ifndef _CRYPT_ECC_CRYPT_FP_H_ +#define _CRYPT_ECC_CRYPT_FP_H_ + +#if CC_ECC_Encrypt || CC_ECC_Encrypt + +//*** CryptEccSelectScheme() +// This function is used by TPM2_ECC_Decrypt and TPM2_ECC_Encrypt. It sets scheme +// either the input scheme or the key scheme. If they key scheme is not TPM_ALG_NULL +// then the input scheme must be TPM_ALG_NULL or the same as the key scheme. If +// not, then the function returns FALSE. +// Return Type: BOOL +// TRUE 'scheme' is set +// FALSE 'scheme' is not valid (it may have been changed). +BOOL CryptEccSelectScheme(OBJECT* key, //IN: key containing default scheme + TPMT_KDF_SCHEME* scheme // IN: a decrypt scheme +); + +//*** CryptEccEncrypt() +//This function performs ECC-based data obfuscation. The only scheme that is currently +// supported is MGF1 based. See Part 1, Annex D for details. +// Return Type: TPM_RC +// TPM_RC_CURVE unsupported curve +// TPM_RC_HASH hash not allowed +// TPM_RC_SCHEME 'scheme' is not supported +// TPM_RC_NO_RESULT internal error in big number processing +LIB_EXPORT TPM_RC CryptEccEncrypt( + OBJECT* key, // IN: public key of recipient + TPMT_KDF_SCHEME* scheme, // IN: scheme to use. + TPM2B_MAX_BUFFER* plainText, // IN: the text to obfuscate + TPMS_ECC_POINT* c1, // OUT: public ephemeral key + TPM2B_MAX_BUFFER* c2, // OUT: obfuscated text + TPM2B_DIGEST* c3 // OUT: digest of ephemeral key + // and plainText +); + +//*** CryptEccDecrypt() +// This function performs ECC decryption and integrity check of the input data. +// Return Type: TPM_RC +// TPM_RC_CURVE unsupported curve +// TPM_RC_HASH hash not allowed +// TPM_RC_SCHEME 'scheme' is not supported +// TPM_RC_NO_RESULT internal error in big number processing +// TPM_RC_VALUE C3 did not match hash of recovered data +LIB_EXPORT TPM_RC CryptEccDecrypt( + OBJECT* key, // IN: key used for data recovery + TPMT_KDF_SCHEME* scheme, // IN: scheme to use. + TPM2B_MAX_BUFFER* plainText, // OUT: the recovered text + TPMS_ECC_POINT* c1, // IN: public ephemeral key + TPM2B_MAX_BUFFER* c2, // IN: obfuscated text + TPM2B_DIGEST* c3 // IN: digest of ephemeral key + // and plainText +); +#endif // CC_ECC_Encrypt || CC_ECC_Encrypt + +#endif // _CRYPT_ECC_CRYPT_FP_H_ diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/CryptEccKeyExchange_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/CryptEccKeyExchange_fp.h new file mode 100644 index 000000000..8a38f5c72 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/CryptEccKeyExchange_fp.h @@ -0,0 +1,54 @@ +// SPDX-License-Identifier: BSD-2-Clause + +/*(Auto-generated) + * Created by TpmPrototypes; Version 3.0 July 18, 2017 + * Date: Mar 28, 2019 Time: 08:25:18PM + */ + +#ifndef _CRYPT_ECC_KEY_EXCHANGE_FP_H_ +#define _CRYPT_ECC_KEY_EXCHANGE_FP_H_ + +#if CC_ZGen_2Phase == YES + +//*** CryptEcc2PhaseKeyExchange() +// This function is the dispatch routine for the EC key exchange functions that use +// two ephemeral and two static keys. +// Return Type: TPM_RC +// TPM_RC_SCHEME scheme is not defined +LIB_EXPORT TPM_RC CryptEcc2PhaseKeyExchange( + TPMS_ECC_POINT* outZ1, // OUT: a computed point + TPMS_ECC_POINT* outZ2, // OUT: and optional second point + TPM_ECC_CURVE curveId, // IN: the curve for the computations + TPM_ALG_ID scheme, // IN: the key exchange scheme + TPM2B_ECC_PARAMETER* dsA, // IN: static private TPM key + TPM2B_ECC_PARAMETER* deA, // IN: ephemeral private TPM key + TPMS_ECC_POINT* QsB, // IN: static public party B key + TPMS_ECC_POINT* QeB // IN: ephemeral public party B key +); +# if ALG_SM2 + +//*** SM2KeyExchange() +// This function performs the key exchange defined in SM2. +// The first step is to compute +// 'tA' = ('dsA' + 'deA' avf(Xe,A)) mod 'n' +// Then, compute the 'Z' value from +// 'outZ' = ('h' 'tA' mod 'n') ('QsA' + [avf('QeB.x')]('QeB')). +// The function will compute the ephemeral public key from the ephemeral +// private key. +// All points are required to be on the curve of 'inQsA'. The function will fail +// catastrophically if this is not the case +// Return Type: TPM_RC +// TPM_RC_NO_RESULT the value for dsA does not give a valid point on the +// curve +LIB_EXPORT TPM_RC SM2KeyExchange( + TPMS_ECC_POINT* outZ, // OUT: the computed point + TPM_ECC_CURVE curveId, // IN: the curve for the computations + TPM2B_ECC_PARAMETER* dsAIn, // IN: static private TPM key + TPM2B_ECC_PARAMETER* deAIn, // IN: ephemeral private TPM key + TPMS_ECC_POINT* QsBIn, // IN: static public party B key + TPMS_ECC_POINT* QeBIn // IN: ephemeral public party B key +); +# endif +#endif // CC_ZGen_2Phase + +#endif // _CRYPT_ECC_KEY_EXCHANGE_FP_H_ diff --git a/src/tpm2/crypto/CryptEccMain_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/CryptEccMain_fp.h similarity index 78% rename from src/tpm2/crypto/CryptEccMain_fp.h rename to src/tpm2/TPMCmd/tpm/include/private/prototypes/CryptEccMain_fp.h index fea3c4770..76d04ddb7 100644 --- a/src/tpm2/crypto/CryptEccMain_fp.h +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/CryptEccMain_fp.h @@ -1,62 +1,4 @@ -/********************************************************************************/ -/* */ -/* ECC Main */ -/* 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 /*(Auto-generated) * Created by TpmPrototypes; Version 3.0 July 18, 2017 @@ -67,6 +9,7 @@ #define _CRYPT_ECC_MAIN_FP_H_ #if ALG_ECC +# include //** Functions # if SIMULATION diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/CryptEccSignature_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/CryptEccSignature_fp.h new file mode 100644 index 000000000..223b78c10 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/CryptEccSignature_fp.h @@ -0,0 +1,71 @@ +// SPDX-License-Identifier: BSD-2-Clause + +/*(Auto-generated) + * Created by TpmPrototypes; Version 3.0 July 18, 2017 + * Date: Mar 28, 2019 Time: 08:25:18PM + */ + +#ifndef _CRYPT_ECC_SIGNATURE_FP_H_ +#define _CRYPT_ECC_SIGNATURE_FP_H_ + +#if ALG_ECC + +//*** CryptEccSign() +// This function is the dispatch function for the various ECC-based +// signing schemes. +// There is a bit of ugliness to the parameter passing. In order to test this, +// we sometime would like to use a deterministic RNG so that we can get the same +// signatures during testing. The easiest way to do this for most schemes is to +// pass in a deterministic RNG and let it return canned values during testing. +// There is a competing need for a canned parameter to use in ECDAA. To accommodate +// both needs with minimal fuss, a special type of RAND_STATE is defined to carry +// the address of the commit value. The setup and handling of this is not very +// different for the caller than what was in previous versions of the code. +// Return Type: TPM_RC +// TPM_RC_SCHEME 'scheme' is not supported +LIB_EXPORT TPM_RC CryptEccSign(TPMT_SIGNATURE* signature, // OUT: signature + OBJECT* signKey, // IN: ECC key to sign the hash + const TPM2B_DIGEST* digest, // IN: digest to sign + TPMT_ECC_SCHEME* scheme, // IN: signing scheme + RAND_STATE* rand); + +//*** CryptEccValidateSignature() +// This function validates an EcDsa or EcSchnorr signature. +// The point 'Qin' needs to have been validated to be on the curve of 'curveId'. +// Return Type: TPM_RC +// TPM_RC_SIGNATURE not a valid signature +LIB_EXPORT TPM_RC CryptEccValidateSignature( + TPMT_SIGNATURE* signature, // IN: signature to be verified + OBJECT* signKey, // IN: ECC key signed the hash + const TPM2B_DIGEST* digest // IN: digest that was signed +); + +//***CryptEccCommitCompute() +// This function performs the point multiply operations required by TPM2_Commit. +// +// If 'B' or 'M' is provided, they must be on the curve defined by 'curveId'. This +// routine does not check that they are on the curve and results are unpredictable +// if they are not. +// +// It is a fatal error if 'r' is NULL. If 'B' is not NULL, then it is a +// fatal error if 'd' is NULL or if 'K' and 'L' are both NULL. +// If 'M' is not NULL, then it is a fatal error if 'E' is NULL. +// +// Return Type: TPM_RC +// TPM_RC_NO_RESULT if 'K', 'L' or 'E' was computed to be the point +// at infinity +// TPM_RC_CANCELED a cancel indication was asserted during this +// function +LIB_EXPORT TPM_RC CryptEccCommitCompute( + TPMS_ECC_POINT* K, // OUT: [d]B or [r]Q + TPMS_ECC_POINT* L, // OUT: [r]B + TPMS_ECC_POINT* E, // OUT: [r]M + TPM_ECC_CURVE curveId, // IN: the curve for the computations + TPMS_ECC_POINT* M, // IN: M (optional) + TPMS_ECC_POINT* B, // IN: B (optional) + TPM2B_ECC_PARAMETER* d, // IN: d (optional) + TPM2B_ECC_PARAMETER* r // IN: the computed r value (required) +); +#endif // ALG_ECC + +#endif // _CRYPT_ECC_SIGNATURE_FP_H_ diff --git a/src/tpm2/crypto/CryptHash_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/CryptHash_fp.h similarity index 80% rename from src/tpm2/crypto/CryptHash_fp.h rename to src/tpm2/TPMCmd/tpm/include/private/prototypes/CryptHash_fp.h index 2a7f33ea4..97772c2c4 100644 --- a/src/tpm2/crypto/CryptHash_fp.h +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/CryptHash_fp.h @@ -1,62 +1,4 @@ -/********************************************************************************/ -/* */ -/* Implementation of cryptographic functions for hashing. */ -/* 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 /*(Auto-generated) * Created by TpmPrototypes; Version 3.0 July 18, 2017 @@ -89,9 +31,10 @@ CryptGetHashDef(TPM_ALG_ID hashAlg); // Return Type: BOOL // TRUE(1) hashAlg is a valid, implemented hash on this TPM // FALSE(0) hashAlg is not valid for this TPM -BOOL CryptHashIsValidAlg(TPM_ALG_ID hashAlg, // IN: the algorithm to check - BOOL isAlgNullValid // IN: TRUE if TPM_ALG_NULL is to be treated - // as a valid hash +BOOL CryptHashIsValidAlg( + TPM_ALG_ID hashAlg, // IN: the algorithm to check + BOOL isAlgNullValid // IN: TRUE if TPM_ALG_NULL is to be treated + // as a valid hash ); //*** CryptHashGetAlgByIndex() diff --git a/src/tpm2/crypto/CryptPrimeSieve_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/CryptPrimeSieve_fp.h similarity index 57% rename from src/tpm2/crypto/CryptPrimeSieve_fp.h rename to src/tpm2/TPMCmd/tpm/include/private/prototypes/CryptPrimeSieve_fp.h index 1cfee9ccc..349913b2d 100644 --- a/src/tpm2/crypto/CryptPrimeSieve_fp.h +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/CryptPrimeSieve_fp.h @@ -1,63 +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, 2016 - 2023 */ -/* */ -/********************************************************************************/ - +// SPDX-License-Identifier: BSD-2-Clause /*(Auto-generated) * Created by TpmPrototypes; Version 3.0 July 18, 2017 diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/CryptPrime_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/CryptPrime_fp.h new file mode 100644 index 000000000..748d082b8 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/CryptPrime_fp.h @@ -0,0 +1,70 @@ +// SPDX-License-Identifier: BSD-2-Clause + +/*(Auto-generated) + * Created by TpmPrototypes; Version 3.0 July 18, 2017 + * Date: Aug 30, 2019 Time: 02:11:54PM + */ + +#ifndef _CRYPT_PRIME_FP_H_ +#define _CRYPT_PRIME_FP_H_ + +//*** IsPrimeInt() +// This will do a test of a word of up to 32-bits in size. +BOOL IsPrimeInt(uint32_t n); + +//*** TpmMath_IsProbablyPrime() +// This function is used when the key sieve is not implemented. This function +// Will try to eliminate some of the obvious things before going on +// to perform MillerRabin as a final verification of primeness. +BOOL TpmMath_IsProbablyPrime(Crypt_Int* prime, // IN: + RAND_STATE* rand // IN: the random state just + // in case Miller-Rabin is required +); + +//*** MillerRabinRounds() +// Function returns the number of Miller-Rabin rounds necessary to give an +// error probability equal to the security strength of the prime. These values +// are from FIPS 186-3. +UINT32 +MillerRabinRounds(UINT32 bits // IN: Number of bits in the RSA prime +); + +//*** MillerRabin() +// This function performs a Miller-Rabin test from FIPS 186-3. It does +// 'iterations' trials on the number. In all likelihood, if the number +// is not prime, the first test fails. +// Return Type: BOOL +// TRUE(1) probably prime +// FALSE(0) composite +BOOL MillerRabin(Crypt_Int* bnW, RAND_STATE* rand); +#if ALG_RSA + +//*** RsaCheckPrime() +// This will check to see if a number is prime and appropriate for an +// RSA prime. +// +// This has different functionality based on whether we are using key +// sieving or not. If not, the number checked to see if it is divisible by +// the public exponent, then the number is adjusted either up or down +// in order to make it a better candidate. It is then checked for being +// probably prime. +// +// If sieving is used, the number is used to root a sieving process. +// +TPM_RC +RsaCheckPrime(Crypt_Int* prime, UINT32 exponent, RAND_STATE* rand); + +//*** TpmRsa_GeneratePrimeForRSA() +// Function to generate a prime of the desired size with the proper attributes +// for an RSA prime. +TPM_RC +TpmRsa_GeneratePrimeForRSA( + Crypt_Int* prime, // IN/OUT: points to the BN that will get the + // random value + UINT32 bits, // IN: number of bits to get + UINT32 exponent, // IN: the exponent + RAND_STATE* rand // IN: the random state +); +#endif // ALG_RSA + +#endif // _CRYPT_PRIME_FP_H_ diff --git a/src/tpm2/crypto/CryptRand_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/CryptRand_fp.h similarity index 63% rename from src/tpm2/crypto/CryptRand_fp.h rename to src/tpm2/TPMCmd/tpm/include/private/prototypes/CryptRand_fp.h index 04ae9a637..e75468993 100644 --- a/src/tpm2/crypto/CryptRand_fp.h +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/CryptRand_fp.h @@ -1,63 +1,4 @@ -/********************************************************************************/ -/* */ -/* DRBG with a behavior according to SP800-90A */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: CryptRand_fp.h 1476 2019-06-10 19:32:03Z 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 /*(Auto-generated) * Created by TpmPrototypes; Version 3.0 July 18, 2017 diff --git a/src/tpm2/crypto/CryptRsa_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/CryptRsa_fp.h similarity index 64% rename from src/tpm2/crypto/CryptRsa_fp.h rename to src/tpm2/TPMCmd/tpm/include/private/prototypes/CryptRsa_fp.h index e9f59c266..01890db12 100644 --- a/src/tpm2/crypto/CryptRsa_fp.h +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/CryptRsa_fp.h @@ -1,67 +1,4 @@ -/********************************************************************************/ -/* */ -/* Implementation of cryptographic primitives for RSA */ -/* 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 */ -/* */ -/********************************************************************************/ - -/*(Auto-generated) - * Created by TpmPrototypes; Version 3.0 July 18, 2017 - * Date: Apr 2, 2019 Time: 03:18:00PM - */ +// SPDX-License-Identifier: BSD-2-Clause #ifndef _CRYPT_RSA_FP_H_ #define _CRYPT_RSA_FP_H_ diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/CryptSelfTest_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/CryptSelfTest_fp.h new file mode 100644 index 000000000..13e24f043 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/CryptSelfTest_fp.h @@ -0,0 +1,68 @@ +// SPDX-License-Identifier: BSD-2-Clause + +/*(Auto-generated) + * Created by TpmPrototypes; Version 3.0 July 18, 2017 + * Date: Mar 4, 2020 Time: 02:36:44PM + */ + +#ifndef _CRYPT_SELF_TEST_FP_H_ +#define _CRYPT_SELF_TEST_FP_H_ + +//*** CryptSelfTest() +// This function is called to start/complete a full self-test. +// If 'fullTest' is NO, then only the untested algorithms will be run. If +// 'fullTest' is YES, then 'g_untestedDecryptionAlgorithms' is reinitialized and then +// all tests are run. +// This implementation of the reference design does not support processing outside +// the framework of a TPM command. As a consequence, this command does not +// complete until all tests are done. Since this can take a long time, the TPM +// will check after each test to see if the command is canceled. If so, then the +// TPM will returned TPM_RC_CANCELLED. To continue with the self-tests, call +// TPM2_SelfTest(fullTest == No) and the TPM will complete the testing. +// Return Type: TPM_RC +// TPM_RC_CANCELED if the command is canceled +LIB_EXPORT +TPM_RC +CryptSelfTest(TPMI_YES_NO fullTest // IN: if full test is required +); + +//*** CryptIncrementalSelfTest() +// This function is used to perform an incremental self-test. This implementation +// will perform the toTest values before returning. That is, it assumes that the +// TPM cannot perform background tasks between commands. +// +// This command may be canceled. If it is, then there is no return result. +// However, this command can be run again and the incremental progress will not +// be lost. +// Return Type: TPM_RC +// TPM_RC_CANCELED processing of this command was canceled +// TPM_RC_TESTING if toTest list is not empty +// TPM_RC_VALUE an algorithm in the toTest list is not implemented +TPM_RC +CryptIncrementalSelfTest(TPML_ALG* toTest, // IN: list of algorithms to be tested + TPML_ALG* toDoList // OUT: list of algorithms needing test +); + +//*** CryptInitializeToTest() +// This function will initialize the data structures for testing all the +// algorithms. This should not be called unless CryptAlgsSetImplemented() has +// been called +void CryptInitializeToTest(void); + +//*** CryptTestAlgorithm() +// Only point of contact with the actual self tests. If a self-test fails, there +// is no return and the TPM goes into failure mode. +// The call to TestAlgorithm uses an algorithm selector and a bit vector. When the +// test is run, the corresponding bit in 'toTest' and in 'g_toTest' is CLEAR. If +// 'toTest' is NULL, then only the bit in 'g_toTest' is CLEAR. +// There is a special case for the call to TestAlgorithm(). When 'alg' is +// ALG_ERROR, TestAlgorithm() will CLEAR any bit in 'toTest' for which it has +// no test. This allows the knowledge about which algorithms have test to be +// accessed through the interface that provides the test. +// Return Type: TPM_RC +// TPM_RC_CANCELED test was canceled +LIB_EXPORT +TPM_RC +CryptTestAlgorithm(TPM_ALG_ID alg, ALGORITHM_VECTOR* toTest); + +#endif // _CRYPT_SELF_TEST_FP_H_ diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/CryptSmac_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/CryptSmac_fp.h new file mode 100644 index 000000000..9fde0a2ef --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/CryptSmac_fp.h @@ -0,0 +1,41 @@ +// SPDX-License-Identifier: BSD-2-Clause + +/*(Auto-generated) + * Created by TpmPrototypes; Version 3.0 July 18, 2017 + * Date: Mar 28, 2019 Time: 08:25:19PM + */ + +#ifndef _CRYPT_SMAC_FP_H_ +#define _CRYPT_SMAC_FP_H_ + +#if SMAC_IMPLEMENTED + +//*** CryptSmacStart() +// Function to start an SMAC. +UINT16 +CryptSmacStart(HASH_STATE* state, + TPMU_PUBLIC_PARMS* keyParameters, + TPM_ALG_ID macAlg, // IN: the type of MAC + TPM2B* key); + +//*** CryptMacStart() +// Function to start either an HMAC or an SMAC. Cannot reuse the CryptHmacStart +// function because of the difference in number of parameters. +UINT16 +CryptMacStart(HMAC_STATE* state, + TPMU_PUBLIC_PARMS* keyParameters, + TPM_ALG_ID macAlg, // IN: the type of MAC + TPM2B* key); + +//*** CryptMacEnd() +// Dispatch to the MAC end function using a size and buffer pointer. +UINT16 +CryptMacEnd(HMAC_STATE* state, UINT32 size, BYTE* buffer); + +//*** CryptMacEnd2B() +// Dispatch to the MAC end function using a 2B. +UINT16 +CryptMacEnd2B(HMAC_STATE* state, TPM2B* data); +#endif // SMAC_IMPLEMENTED + +#endif // _CRYPT_SMAC_FP_H_ diff --git a/src/tpm2/crypto/CryptSym_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/CryptSym_fp.h similarity index 50% rename from src/tpm2/crypto/CryptSym_fp.h rename to src/tpm2/TPMCmd/tpm/include/private/prototypes/CryptSym_fp.h index fef3dd151..da2b55886 100644 --- a/src/tpm2/crypto/CryptSym_fp.h +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/CryptSym_fp.h @@ -1,63 +1,4 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: CryptSym_fp.h 1047 2017-07-20 18:27:34Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2016 */ -/* */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause /*(Auto-generated) * Created by TpmPrototypes; Version 3.0 July 18, 2017 diff --git a/src/tpm2/crypto/CryptUtil_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/CryptUtil_fp.h similarity index 77% rename from src/tpm2/crypto/CryptUtil_fp.h rename to src/tpm2/TPMCmd/tpm/include/private/prototypes/CryptUtil_fp.h index 24063b81d..cd7765ca0 100644 --- a/src/tpm2/crypto/CryptUtil_fp.h +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/CryptUtil_fp.h @@ -1,62 +1,4 @@ -/********************************************************************************/ -/* */ -/* Interfaces to the CryptoEngine */ -/* 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 /*(Auto-generated) * Created by TpmPrototypes; Version 3.0 July 18, 2017 @@ -75,38 +17,38 @@ BOOL CryptIsSchemeAnonymous(TPM_ALG_ID scheme // IN: the scheme algorithm to te //*** ParmDecryptSym() // This function performs parameter decryption using symmetric block cipher. -void ParmDecryptSym(TPM_ALG_ID symAlg, // IN: the symmetric algorithm - TPM_ALG_ID hash, // IN: hash algorithm for KDFa - UINT16 keySizeInBits, // IN: the key size in bits - TPM2B* key, // IN: KDF HMAC key - TPM2B* nonceCaller, // IN: nonce caller - TPM2B* nonceTpm, // IN: nonce TPM - UINT32 dataSize, // IN: size of parameter buffer - BYTE* data // OUT: buffer to be decrypted +TPM_RC ParmDecryptSym(TPM_ALG_ID symAlg, // IN: the symmetric algorithm + TPM_ALG_ID hash, // IN: hash algorithm for KDFa + UINT16 keySizeInBits, // IN: the key size in bits + TPM2B* key, // IN: KDF HMAC key + TPM2B* nonceCaller, // IN: nonce caller + TPM2B* nonceTpm, // IN: nonce TPM + UINT32 dataSize, // IN: size of parameter buffer + BYTE* data // OUT: buffer to be decrypted ); //*** ParmEncryptSym() // This function performs parameter encryption using symmetric block cipher. -void ParmEncryptSym(TPM_ALG_ID symAlg, // IN: symmetric algorithm - TPM_ALG_ID hash, // IN: hash algorithm for KDFa - UINT16 keySizeInBits, // IN: symmetric key size in bits - TPM2B* key, // IN: KDF HMAC key - TPM2B* nonceCaller, // IN: nonce caller - TPM2B* nonceTpm, // IN: nonce TPM - UINT32 dataSize, // IN: size of parameter buffer - BYTE* data // OUT: buffer to be encrypted +TPM_RC ParmEncryptSym(TPM_ALG_ID symAlg, // IN: symmetric algorithm + TPM_ALG_ID hash, // IN: hash algorithm for KDFa + UINT16 keySizeInBits, // IN: symmetric key size in bits + TPM2B* key, // IN: KDF HMAC key + TPM2B* nonceCaller, // IN: nonce caller + TPM2B* nonceTpm, // IN: nonce TPM + UINT32 dataSize, // IN: size of parameter buffer + BYTE* data // OUT: buffer to be encrypted ); //*** CryptXORObfuscation() // This function implements XOR obfuscation. It should not be called if the // hash algorithm is not implemented. The only return value from this function // is TPM_RC_SUCCESS. -void CryptXORObfuscation(TPM_ALG_ID hash, // IN: hash algorithm for KDF - TPM2B* key, // IN: KDF key - TPM2B* contextU, // IN: contextU - TPM2B* contextV, // IN: contextV - UINT32 dataSize, // IN: size of data buffer - BYTE* data // IN/OUT: data to be XORed in place +TPM_RC CryptXORObfuscation(TPM_ALG_ID hash, // IN: hash algorithm for KDF + TPM2B* key, // IN: KDF key + TPM2B* contextU, // IN: contextU + TPM2B* contextV, // IN: contextV + UINT32 dataSize, // IN: size of data buffer + BYTE* data // IN/OUT: data to be XORed in place ); //*** CryptInit() @@ -202,7 +144,7 @@ CryptSecretDecrypt(OBJECT* decryptKey, // IN: decrypt key //*** CryptParameterEncryption() // This function does in-place encryption of a response parameter. -void CryptParameterEncryption( +TPM_RC CryptParameterEncryption( TPM_HANDLE handle, // IN: encrypt session handle TPM2B* nonceCaller, // IN: nonce caller INT32 bufferSize, // IN: size of parameter buffer @@ -296,7 +238,8 @@ BOOL CryptIsSplitSign(TPM_ALG_ID scheme // IN: the algorithm selector ); //*** CryptIsAsymSignScheme() -// This function indicates if a scheme algorithm is a sign algorithm. +// This function indicates if a scheme algorithm is a sign algorithm valid for the +// public key type. BOOL CryptIsAsymSignScheme(TPMI_ALG_PUBLIC publicType, // IN: Type of the object TPMI_ALG_ASYM_SCHEME scheme // IN: the scheme ); diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/DA_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/DA_fp.h new file mode 100644 index 000000000..8b43dec1b --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/DA_fp.h @@ -0,0 +1,46 @@ +// SPDX-License-Identifier: BSD-2-Clause + +/*(Auto-generated) + * Created by TpmPrototypes; Version 3.0 July 18, 2017 + * Date: Apr 2, 2019 Time: 04:23:27PM + */ + +#ifndef _DA_FP_H_ +#define _DA_FP_H_ + +//*** DAPreInstall_Init() +// This function initializes the DA parameters to their manufacturer-default +// values. The default values are determined by a platform-specific specification. +// +// This function should not be called outside of a manufacturing or simulation +// environment. +// +// The DA parameters will be restored to these initial values by TPM2_Clear(). +void DAPreInstall_Init(void); + +//*** DAStartup() +// This function is called by TPM2_Startup() to initialize the DA parameters. +// In the case of Startup(CLEAR), use of lockoutAuth will be enabled if the +// lockout recovery time is 0. Otherwise, lockoutAuth will not be enabled until +// the TPM has been continuously powered for the lockoutRecovery time. +// +// This function requires that NV be available and not rate limiting. +BOOL DAStartup(STARTUP_TYPE type // IN: startup type +); + +//*** DARegisterFailure() +// This function is called when a authorization failure occurs on an entity +// that is subject to dictionary-attack protection. When a DA failure is +// triggered, register the failure by resetting the relevant self-healing +// timer to the current time. +void DARegisterFailure(TPM_HANDLE handle // IN: handle for failure +); + +//*** DASelfHeal() +// This function is called to check if sufficient time has passed to allow +// decrement of failedTries or to re-enable use of lockoutAuth. +// +// This function should be called when the time interval is updated. +void DASelfHeal(void); + +#endif // _DA_FP_H_ diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/DictionaryAttackLockReset_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/DictionaryAttackLockReset_fp.h new file mode 100644 index 000000000..1db2068de --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/DictionaryAttackLockReset_fp.h @@ -0,0 +1,25 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_DictionaryAttackLockReset // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_DICTIONARYATTACKLOCKRESET_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_DICTIONARYATTACKLOCKRESET_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_RH_LOCKOUT lockHandle; +} DictionaryAttackLockReset_In; + +// Response code modifiers +# define RC_DictionaryAttackLockReset_lockHandle (TPM_RC_H + TPM_RC_1) + +// Function prototype +TPM_RC +TPM2_DictionaryAttackLockReset(DictionaryAttackLockReset_In* in); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_DICTIONARYATTACKLOCKRESET_FP_H_ +#endif // CC_DictionaryAttackLockReset diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/DictionaryAttackParameters_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/DictionaryAttackParameters_fp.h new file mode 100644 index 000000000..374373e5c --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/DictionaryAttackParameters_fp.h @@ -0,0 +1,31 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_DictionaryAttackParameters // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_DICTIONARYATTACKPARAMETERS_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_DICTIONARYATTACKPARAMETERS_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_RH_LOCKOUT lockHandle; + UINT32 newMaxTries; + UINT32 newRecoveryTime; + UINT32 lockoutRecovery; +} DictionaryAttackParameters_In; + +// Response code modifiers +# define RC_DictionaryAttackParameters_lockHandle (TPM_RC_H + TPM_RC_1) +# define RC_DictionaryAttackParameters_newMaxTries (TPM_RC_P + TPM_RC_1) +# define RC_DictionaryAttackParameters_newRecoveryTime (TPM_RC_P + TPM_RC_2) +# define RC_DictionaryAttackParameters_lockoutRecovery (TPM_RC_P + TPM_RC_3) + +// Function prototype +TPM_RC +TPM2_DictionaryAttackParameters(DictionaryAttackParameters_In* in); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_DICTIONARYATTACKPARAMETERS_FP_H_ +#endif // CC_DictionaryAttackParameters diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/Duplicate_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/Duplicate_fp.h new file mode 100644 index 000000000..2ff3fa800 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/Duplicate_fp.h @@ -0,0 +1,39 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_Duplicate // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_DUPLICATE_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_DUPLICATE_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_DH_OBJECT objectHandle; + TPMI_DH_OBJECT newParentHandle; + TPM2B_DATA encryptionKeyIn; + TPMT_SYM_DEF_OBJECT symmetricAlg; +} Duplicate_In; + +// Output structure definition +typedef struct +{ + TPM2B_DATA encryptionKeyOut; + TPM2B_PRIVATE duplicate; + TPM2B_ENCRYPTED_SECRET outSymSeed; +} Duplicate_Out; + +// Response code modifiers +# define RC_Duplicate_objectHandle (TPM_RC_H + TPM_RC_1) +# define RC_Duplicate_newParentHandle (TPM_RC_H + TPM_RC_2) +# define RC_Duplicate_encryptionKeyIn (TPM_RC_P + TPM_RC_1) +# define RC_Duplicate_symmetricAlg (TPM_RC_P + TPM_RC_2) + +// Function prototype +TPM_RC +TPM2_Duplicate(Duplicate_In* in, Duplicate_Out* out); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_DUPLICATE_FP_H_ +#endif // CC_Duplicate diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/ECC_Decrypt_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/ECC_Decrypt_fp.h new file mode 100644 index 000000000..10c3aaf45 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/ECC_Decrypt_fp.h @@ -0,0 +1,39 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_ECC_Decrypt // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_ECC_DECRYPT_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_ECC_DECRYPT_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_DH_OBJECT keyHandle; + TPM2B_ECC_POINT C1; + TPM2B_MAX_BUFFER C2; + TPM2B_DIGEST C3; + TPMT_KDF_SCHEME inScheme; +} ECC_Decrypt_In; + +// Output structure definition +typedef struct +{ + TPM2B_MAX_BUFFER plainText; +} ECC_Decrypt_Out; + +// Response code modifiers +# define RC_ECC_Decrypt_keyHandle (TPM_RC_H + TPM_RC_1) +# define RC_ECC_Decrypt_C1 (TPM_RC_P + TPM_RC_1) +# define RC_ECC_Decrypt_C2 (TPM_RC_P + TPM_RC_2) +# define RC_ECC_Decrypt_C3 (TPM_RC_P + TPM_RC_3) +# define RC_ECC_Decrypt_inScheme (TPM_RC_P + TPM_RC_4) + +// Function prototype +TPM_RC +TPM2_ECC_Decrypt(ECC_Decrypt_In* in, ECC_Decrypt_Out* out); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_ECC_DECRYPT_FP_H_ +#endif // CC_ECC_Decrypt diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/ECC_Encrypt_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/ECC_Encrypt_fp.h new file mode 100644 index 000000000..4a37f23cd --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/ECC_Encrypt_fp.h @@ -0,0 +1,37 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_ECC_Encrypt // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_ECC_ENCRYPT_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_ECC_ENCRYPT_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_DH_OBJECT keyHandle; + TPM2B_MAX_BUFFER plainText; + TPMT_KDF_SCHEME inScheme; +} ECC_Encrypt_In; + +// Output structure definition +typedef struct +{ + TPM2B_ECC_POINT C1; + TPM2B_MAX_BUFFER C2; + TPM2B_DIGEST C3; +} ECC_Encrypt_Out; + +// Response code modifiers +# define RC_ECC_Encrypt_keyHandle (TPM_RC_H + TPM_RC_1) +# define RC_ECC_Encrypt_plainText (TPM_RC_P + TPM_RC_1) +# define RC_ECC_Encrypt_inScheme (TPM_RC_P + TPM_RC_2) + +// Function prototype +TPM_RC +TPM2_ECC_Encrypt(ECC_Encrypt_In* in, ECC_Encrypt_Out* out); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_ECC_ENCRYPT_FP_H_ +#endif // CC_ECC_Encrypt diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/ECC_Parameters_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/ECC_Parameters_fp.h new file mode 100644 index 000000000..62eef6ec9 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/ECC_Parameters_fp.h @@ -0,0 +1,31 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_ECC_Parameters // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_ECC_PARAMETERS_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_ECC_PARAMETERS_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_ECC_CURVE curveID; +} ECC_Parameters_In; + +// Output structure definition +typedef struct +{ + TPMS_ALGORITHM_DETAIL_ECC parameters; +} ECC_Parameters_Out; + +// Response code modifiers +# define RC_ECC_Parameters_curveID (TPM_RC_P + TPM_RC_1) + +// Function prototype +TPM_RC +TPM2_ECC_Parameters(ECC_Parameters_In* in, ECC_Parameters_Out* out); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_ECC_PARAMETERS_FP_H_ +#endif // CC_ECC_Parameters diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/ECDH_KeyGen_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/ECDH_KeyGen_fp.h new file mode 100644 index 000000000..19e7fbdf6 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/ECDH_KeyGen_fp.h @@ -0,0 +1,32 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_ECDH_KeyGen // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_ECDH_KEYGEN_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_ECDH_KEYGEN_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_DH_OBJECT keyHandle; +} ECDH_KeyGen_In; + +// Output structure definition +typedef struct +{ + TPM2B_ECC_POINT zPoint; + TPM2B_ECC_POINT pubPoint; +} ECDH_KeyGen_Out; + +// Response code modifiers +# define RC_ECDH_KeyGen_keyHandle (TPM_RC_H + TPM_RC_1) + +// Function prototype +TPM_RC +TPM2_ECDH_KeyGen(ECDH_KeyGen_In* in, ECDH_KeyGen_Out* out); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_ECDH_KEYGEN_FP_H_ +#endif // CC_ECDH_KeyGen diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/ECDH_ZGen_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/ECDH_ZGen_fp.h new file mode 100644 index 000000000..45a6b347b --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/ECDH_ZGen_fp.h @@ -0,0 +1,33 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_ECDH_ZGen // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_ECDH_ZGEN_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_ECDH_ZGEN_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_DH_OBJECT keyHandle; + TPM2B_ECC_POINT inPoint; +} ECDH_ZGen_In; + +// Output structure definition +typedef struct +{ + TPM2B_ECC_POINT outPoint; +} ECDH_ZGen_Out; + +// Response code modifiers +# define RC_ECDH_ZGen_keyHandle (TPM_RC_H + TPM_RC_1) +# define RC_ECDH_ZGen_inPoint (TPM_RC_P + TPM_RC_1) + +// Function prototype +TPM_RC +TPM2_ECDH_ZGen(ECDH_ZGen_In* in, ECDH_ZGen_Out* out); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_ECDH_ZGEN_FP_H_ +#endif // CC_ECDH_ZGen diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/EC_Ephemeral_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/EC_Ephemeral_fp.h new file mode 100644 index 000000000..09f5184a7 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/EC_Ephemeral_fp.h @@ -0,0 +1,32 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_EC_Ephemeral // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_EC_EPHEMERAL_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_EC_EPHEMERAL_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_ECC_CURVE curveID; +} EC_Ephemeral_In; + +// Output structure definition +typedef struct +{ + TPM2B_ECC_POINT Q; + UINT16 counter; +} EC_Ephemeral_Out; + +// Response code modifiers +# define RC_EC_Ephemeral_curveID (TPM_RC_P + TPM_RC_1) + +// Function prototype +TPM_RC +TPM2_EC_Ephemeral(EC_Ephemeral_In* in, EC_Ephemeral_Out* out); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_EC_EPHEMERAL_FP_H_ +#endif // CC_EC_Ephemeral diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/EncryptDecrypt2_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/EncryptDecrypt2_fp.h new file mode 100644 index 000000000..a25432713 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/EncryptDecrypt2_fp.h @@ -0,0 +1,40 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_EncryptDecrypt2 // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_ENCRYPTDECRYPT2_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_ENCRYPTDECRYPT2_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_DH_OBJECT keyHandle; + TPM2B_MAX_BUFFER inData; + TPMI_YES_NO decrypt; + TPMI_ALG_CIPHER_MODE mode; + TPM2B_IV ivIn; +} EncryptDecrypt2_In; + +// Output structure definition +typedef struct +{ + TPM2B_MAX_BUFFER outData; + TPM2B_IV ivOut; +} EncryptDecrypt2_Out; + +// Response code modifiers +# define RC_EncryptDecrypt2_keyHandle (TPM_RC_H + TPM_RC_1) +# define RC_EncryptDecrypt2_inData (TPM_RC_P + TPM_RC_1) +# define RC_EncryptDecrypt2_decrypt (TPM_RC_P + TPM_RC_2) +# define RC_EncryptDecrypt2_mode (TPM_RC_P + TPM_RC_3) +# define RC_EncryptDecrypt2_ivIn (TPM_RC_P + TPM_RC_4) + +// Function prototype +TPM_RC +TPM2_EncryptDecrypt2(EncryptDecrypt2_In* in, EncryptDecrypt2_Out* out); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_ENCRYPTDECRYPT2_FP_H_ +#endif // CC_EncryptDecrypt2 diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/EncryptDecrypt_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/EncryptDecrypt_fp.h new file mode 100644 index 000000000..2fbdf61e5 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/EncryptDecrypt_fp.h @@ -0,0 +1,40 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_EncryptDecrypt // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_ENCRYPTDECRYPT_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_ENCRYPTDECRYPT_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_DH_OBJECT keyHandle; + TPMI_YES_NO decrypt; + TPMI_ALG_CIPHER_MODE mode; + TPM2B_IV ivIn; + TPM2B_MAX_BUFFER inData; +} EncryptDecrypt_In; + +// Output structure definition +typedef struct +{ + TPM2B_MAX_BUFFER outData; + TPM2B_IV ivOut; +} EncryptDecrypt_Out; + +// Response code modifiers +# define RC_EncryptDecrypt_keyHandle (TPM_RC_H + TPM_RC_1) +# define RC_EncryptDecrypt_decrypt (TPM_RC_P + TPM_RC_1) +# define RC_EncryptDecrypt_mode (TPM_RC_P + TPM_RC_2) +# define RC_EncryptDecrypt_ivIn (TPM_RC_P + TPM_RC_3) +# define RC_EncryptDecrypt_inData (TPM_RC_P + TPM_RC_4) + +// Function prototype +TPM_RC +TPM2_EncryptDecrypt(EncryptDecrypt_In* in, EncryptDecrypt_Out* out); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_ENCRYPTDECRYPT_FP_H_ +#endif // CC_EncryptDecrypt diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/EncryptDecrypt_spt_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/EncryptDecrypt_spt_fp.h new file mode 100644 index 000000000..b74c86392 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/EncryptDecrypt_spt_fp.h @@ -0,0 +1,30 @@ +// SPDX-License-Identifier: BSD-2-Clause + +/*(Auto-generated) + * Created by TpmPrototypes; Version 3.0 July 18, 2017 + * Date: Mar 28, 2019 Time: 08:25:18PM + */ + +#ifndef _ENCRYPT_DECRYPT_SPT_FP_H_ +#define _ENCRYPT_DECRYPT_SPT_FP_H_ + +#if CC_EncryptDecrypt2 + +// Return Type: TPM_RC +// TPM_RC_KEY is not a symmetric decryption key with both +// public and private portions loaded +// TPM_RC_SIZE 'IvIn' size is incompatible with the block cipher mode; +// or 'inData' size is not an even multiple of the block +// size for CBC or ECB mode +// TPM_RC_VALUE 'keyHandle' is restricted and the argument 'mode' does +// not match the key's mode +TPM_RC +EncryptDecryptShared(TPMI_DH_OBJECT keyHandleIn, + TPMI_YES_NO decryptIn, + TPMI_ALG_SYM_MODE modeIn, + TPM2B_IV* ivIn, + TPM2B_MAX_BUFFER* inData, + EncryptDecrypt_Out* out); +#endif // CC_EncryptDecrypt + +#endif // _ENCRYPT_DECRYPT_SPT_FP_H_ diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/Entity_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/Entity_fp.h new file mode 100644 index 000000000..042eea66b --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/Entity_fp.h @@ -0,0 +1,70 @@ +// SPDX-License-Identifier: BSD-2-Clause + +/*(Auto-generated) + * Created by TpmPrototypes; Version 3.0 July 18, 2017 + * Date: Mar 7, 2020 Time: 07:19:36PM + */ + +#ifndef _ENTITY_FP_H_ +#define _ENTITY_FP_H_ + +//** Functions +//*** EntityGetLoadStatus() +// This function will check that all the handles access loaded entities. +// Return Type: TPM_RC +// TPM_RC_HANDLE handle type does not match +// TPM_RC_REFERENCE_Hx entity is not present +// TPM_RC_HIERARCHY entity belongs to a disabled hierarchy +// TPM_RC_OBJECT_MEMORY handle is an evict object but there is no +// space to load it to RAM +TPM_RC +EntityGetLoadStatus(COMMAND* command // IN/OUT: command parsing structure +); + +//*** EntityGetAuthValue() +// This function is used to access the 'authValue' associated with a handle. +// This function assumes that the handle references an entity that is accessible +// and the handle is not for a persistent objects. That is EntityGetLoadStatus() +// should have been called. Also, the accessibility of the authValue should have +// been verified by IsAuthValueAvailable(). +// +// This function copies the authorization value of the entity to 'auth'. +// Return Type: UINT16 +// count number of bytes in the authValue with 0's stripped +UINT16 +EntityGetAuthValue(TPMI_DH_ENTITY handle, // IN: handle of entity + TPM2B_AUTH* auth // OUT: authValue of the entity +); + +//*** EntityGetAuthPolicy() +// This function is used to access the 'authPolicy' associated with a handle. +// This function assumes that the handle references an entity that is accessible +// and the handle is not for a persistent objects. That is EntityGetLoadStatus() +// should have been called. Also, the accessibility of the authPolicy should have +// been verified by IsAuthPolicyAvailable(). +// +// This function copies the authorization policy of the entity to 'authPolicy'. +// +// The return value is the hash algorithm for the policy. +TPMI_ALG_HASH +EntityGetAuthPolicy(TPMI_DH_ENTITY handle, // IN: handle of entity + TPM2B_DIGEST* authPolicy // OUT: authPolicy of the entity +); + +//*** EntityGetName() +// This function returns the Name associated with a handle. +TPM2B_NAME* EntityGetName(TPMI_DH_ENTITY handle, // IN: handle of entity + TPM2B_NAME* name // OUT: name of entity +); + +//*** EntityGetHierarchy() +// This function returns the hierarchy handle associated with an entity. +// a) A handle that is a hierarchy handle is associated with itself. +// b) An NV index belongs to TPM_RH_PLATFORM if TPMA_NV_PLATFORMCREATE, +// is SET, otherwise it belongs to TPM_RH_OWNER +// c) An object handle belongs to its hierarchy. +TPMI_RH_HIERARCHY +EntityGetHierarchy(TPMI_DH_ENTITY handle // IN :handle of entity +); + +#endif // _ENTITY_FP_H_ diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/EventSequenceComplete_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/EventSequenceComplete_fp.h new file mode 100644 index 000000000..177aa2e48 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/EventSequenceComplete_fp.h @@ -0,0 +1,36 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_EventSequenceComplete // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_EVENTSEQUENCECOMPLETE_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_EVENTSEQUENCECOMPLETE_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_DH_PCR pcrHandle; + TPMI_DH_OBJECT sequenceHandle; + TPM2B_MAX_BUFFER buffer; +} EventSequenceComplete_In; + +// Output structure definition +typedef struct +{ + TPML_DIGEST_VALUES results; +} EventSequenceComplete_Out; + +// Response code modifiers +# define RC_EventSequenceComplete_pcrHandle (TPM_RC_H + TPM_RC_1) +# define RC_EventSequenceComplete_sequenceHandle (TPM_RC_H + TPM_RC_2) +# define RC_EventSequenceComplete_buffer (TPM_RC_P + TPM_RC_1) + +// Function prototype +TPM_RC +TPM2_EventSequenceComplete(EventSequenceComplete_In* in, + EventSequenceComplete_Out* out); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_EVENTSEQUENCECOMPLETE_FP_H_ +#endif // CC_EventSequenceComplete diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/EvictControl_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/EvictControl_fp.h new file mode 100644 index 000000000..2e7a00011 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/EvictControl_fp.h @@ -0,0 +1,29 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_EvictControl // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_EVICTCONTROL_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_EVICTCONTROL_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_RH_PROVISION auth; + TPMI_DH_OBJECT objectHandle; + TPMI_DH_PERSISTENT persistentHandle; +} EvictControl_In; + +// Response code modifiers +# define RC_EvictControl_auth (TPM_RC_H + TPM_RC_1) +# define RC_EvictControl_objectHandle (TPM_RC_H + TPM_RC_2) +# define RC_EvictControl_persistentHandle (TPM_RC_P + TPM_RC_1) + +// Function prototype +TPM_RC +TPM2_EvictControl(EvictControl_In* in); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_EVICTCONTROL_FP_H_ +#endif // CC_EvictControl diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/FlushContext_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/FlushContext_fp.h new file mode 100644 index 000000000..b408d84b2 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/FlushContext_fp.h @@ -0,0 +1,25 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_FlushContext // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_FLUSHCONTEXT_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_FLUSHCONTEXT_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_DH_CONTEXT flushHandle; +} FlushContext_In; + +// Response code modifiers +# define RC_FlushContext_flushHandle (TPM_RC_P + TPM_RC_1) + +// Function prototype +TPM_RC +TPM2_FlushContext(FlushContext_In* in); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_FLUSHCONTEXT_FP_H_ +#endif // CC_FlushContext diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/GetCapability_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/GetCapability_fp.h new file mode 100644 index 000000000..57bcfeb50 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/GetCapability_fp.h @@ -0,0 +1,36 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_GetCapability // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_GETCAPABILITY_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_GETCAPABILITY_FP_H_ + +// Input structure definition +typedef struct +{ + TPM_CAP capability; + UINT32 property; + UINT32 propertyCount; +} GetCapability_In; + +// Output structure definition +typedef struct +{ + TPMI_YES_NO moreData; + TPMS_CAPABILITY_DATA capabilityData; +} GetCapability_Out; + +// Response code modifiers +# define RC_GetCapability_capability (TPM_RC_P + TPM_RC_1) +# define RC_GetCapability_property (TPM_RC_P + TPM_RC_2) +# define RC_GetCapability_propertyCount (TPM_RC_P + TPM_RC_3) + +// Function prototype +TPM_RC +TPM2_GetCapability(GetCapability_In* in, GetCapability_Out* out); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_GETCAPABILITY_FP_H_ +#endif // CC_GetCapability diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/GetCommandAuditDigest_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/GetCommandAuditDigest_fp.h new file mode 100644 index 000000000..2c5e4c0e5 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/GetCommandAuditDigest_fp.h @@ -0,0 +1,39 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_GetCommandAuditDigest // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_GETCOMMANDAUDITDIGEST_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_GETCOMMANDAUDITDIGEST_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_RH_ENDORSEMENT privacyHandle; + TPMI_DH_OBJECT signHandle; + TPM2B_DATA qualifyingData; + TPMT_SIG_SCHEME inScheme; +} GetCommandAuditDigest_In; + +// Output structure definition +typedef struct +{ + TPM2B_ATTEST auditInfo; + TPMT_SIGNATURE signature; +} GetCommandAuditDigest_Out; + +// Response code modifiers +# define RC_GetCommandAuditDigest_privacyHandle (TPM_RC_H + TPM_RC_1) +# define RC_GetCommandAuditDigest_signHandle (TPM_RC_H + TPM_RC_2) +# define RC_GetCommandAuditDigest_qualifyingData (TPM_RC_P + TPM_RC_1) +# define RC_GetCommandAuditDigest_inScheme (TPM_RC_P + TPM_RC_2) + +// Function prototype +TPM_RC +TPM2_GetCommandAuditDigest(GetCommandAuditDigest_In* in, + GetCommandAuditDigest_Out* out); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_GETCOMMANDAUDITDIGEST_FP_H_ +#endif // CC_GetCommandAuditDigest diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/GetRandom_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/GetRandom_fp.h new file mode 100644 index 000000000..80e03b80e --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/GetRandom_fp.h @@ -0,0 +1,31 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_GetRandom // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_GETRANDOM_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_GETRANDOM_FP_H_ + +// Input structure definition +typedef struct +{ + UINT16 bytesRequested; +} GetRandom_In; + +// Output structure definition +typedef struct +{ + TPM2B_DIGEST randomBytes; +} GetRandom_Out; + +// Response code modifiers +# define RC_GetRandom_bytesRequested (TPM_RC_P + TPM_RC_1) + +// Function prototype +TPM_RC +TPM2_GetRandom(GetRandom_In* in, GetRandom_Out* out); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_GETRANDOM_FP_H_ +#endif // CC_GetRandom diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/GetSessionAuditDigest_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/GetSessionAuditDigest_fp.h new file mode 100644 index 000000000..7be21aeb5 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/GetSessionAuditDigest_fp.h @@ -0,0 +1,41 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_GetSessionAuditDigest // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_GETSESSIONAUDITDIGEST_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_GETSESSIONAUDITDIGEST_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_RH_ENDORSEMENT privacyAdminHandle; + TPMI_DH_OBJECT signHandle; + TPMI_SH_HMAC sessionHandle; + TPM2B_DATA qualifyingData; + TPMT_SIG_SCHEME inScheme; +} GetSessionAuditDigest_In; + +// Output structure definition +typedef struct +{ + TPM2B_ATTEST auditInfo; + TPMT_SIGNATURE signature; +} GetSessionAuditDigest_Out; + +// Response code modifiers +# define RC_GetSessionAuditDigest_privacyAdminHandle (TPM_RC_H + TPM_RC_1) +# define RC_GetSessionAuditDigest_signHandle (TPM_RC_H + TPM_RC_2) +# define RC_GetSessionAuditDigest_sessionHandle (TPM_RC_H + TPM_RC_3) +# define RC_GetSessionAuditDigest_qualifyingData (TPM_RC_P + TPM_RC_1) +# define RC_GetSessionAuditDigest_inScheme (TPM_RC_P + TPM_RC_2) + +// Function prototype +TPM_RC +TPM2_GetSessionAuditDigest(GetSessionAuditDigest_In* in, + GetSessionAuditDigest_Out* out); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_GETSESSIONAUDITDIGEST_FP_H_ +#endif // CC_GetSessionAuditDigest diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/GetTestResult_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/GetTestResult_fp.h new file mode 100644 index 000000000..6913e71b0 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/GetTestResult_fp.h @@ -0,0 +1,23 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_GetTestResult // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_GETTESTRESULT_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_GETTESTRESULT_FP_H_ + +// Output structure definition +typedef struct +{ + TPM2B_MAX_BUFFER outData; + TPM_RC testResult; +} GetTestResult_Out; + +// Function prototype +TPM_RC +TPM2_GetTestResult(GetTestResult_Out* out); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_GETTESTRESULT_FP_H_ +#endif // CC_GetTestResult diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/GetTime_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/GetTime_fp.h new file mode 100644 index 000000000..07816d7f0 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/GetTime_fp.h @@ -0,0 +1,38 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_GetTime // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_GETTIME_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_GETTIME_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_RH_ENDORSEMENT privacyAdminHandle; + TPMI_DH_OBJECT signHandle; + TPM2B_DATA qualifyingData; + TPMT_SIG_SCHEME inScheme; +} GetTime_In; + +// Output structure definition +typedef struct +{ + TPM2B_ATTEST timeInfo; + TPMT_SIGNATURE signature; +} GetTime_Out; + +// Response code modifiers +# define RC_GetTime_privacyAdminHandle (TPM_RC_H + TPM_RC_1) +# define RC_GetTime_signHandle (TPM_RC_H + TPM_RC_2) +# define RC_GetTime_qualifyingData (TPM_RC_P + TPM_RC_1) +# define RC_GetTime_inScheme (TPM_RC_P + TPM_RC_2) + +// Function prototype +TPM_RC +TPM2_GetTime(GetTime_In* in, GetTime_Out* out); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_GETTIME_FP_H_ +#endif // CC_GetTime diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/HMAC_Start_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/HMAC_Start_fp.h new file mode 100644 index 000000000..c1249be92 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/HMAC_Start_fp.h @@ -0,0 +1,35 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_HMAC_Start // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_HMAC_START_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_HMAC_START_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_DH_OBJECT handle; + TPM2B_AUTH auth; + TPMI_ALG_HASH hashAlg; +} HMAC_Start_In; + +// Output structure definition +typedef struct +{ + TPMI_DH_OBJECT sequenceHandle; +} HMAC_Start_Out; + +// Response code modifiers +# define RC_HMAC_Start_handle (TPM_RC_H + TPM_RC_1) +# define RC_HMAC_Start_auth (TPM_RC_P + TPM_RC_1) +# define RC_HMAC_Start_hashAlg (TPM_RC_P + TPM_RC_2) + +// Function prototype +TPM_RC +TPM2_HMAC_Start(HMAC_Start_In* in, HMAC_Start_Out* out); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_HMAC_START_FP_H_ +#endif // CC_HMAC_Start diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/HMAC_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/HMAC_fp.h new file mode 100644 index 000000000..a2f26157a --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/HMAC_fp.h @@ -0,0 +1,35 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_HMAC // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_HMAC_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_HMAC_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_DH_OBJECT handle; + TPM2B_MAX_BUFFER buffer; + TPMI_ALG_HASH hashAlg; +} HMAC_In; + +// Output structure definition +typedef struct +{ + TPM2B_DIGEST outHMAC; +} HMAC_Out; + +// Response code modifiers +# define RC_HMAC_handle (TPM_RC_H + TPM_RC_1) +# define RC_HMAC_buffer (TPM_RC_P + TPM_RC_1) +# define RC_HMAC_hashAlg (TPM_RC_P + TPM_RC_2) + +// Function prototype +TPM_RC +TPM2_HMAC(HMAC_In* in, HMAC_Out* out); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_HMAC_FP_H_ +#endif // CC_HMAC diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/Handle_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/Handle_fp.h new file mode 100644 index 000000000..4179afa71 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/Handle_fp.h @@ -0,0 +1,62 @@ +// SPDX-License-Identifier: BSD-2-Clause + +/*(Auto-generated) + * Created by TpmPrototypes; Version 3.0 July 18, 2017 + * Date: Mar 28, 2019 Time: 08:25:19PM + */ + +#ifndef _HANDLE_FP_H_ +#define _HANDLE_FP_H_ + +//*** HandleGetType() +// This function returns the type of a handle which is the MSO of the handle. +TPM_HT +HandleGetType(TPM_HANDLE handle // IN: a handle to be checked +); + +//*** NextPermanentHandle() +// This function returns the permanent handle that is equal to the input value or +// is the next higher value. If there is no handle with the input value and there +// is no next higher value, it returns 0: +TPM_HANDLE +NextPermanentHandle(TPM_HANDLE inHandle // IN: the handle to check +); + +//*** PermanentCapGetHandles() +// This function returns a list of the permanent handles of PCR, started from +// 'handle'. If 'handle' is larger than the largest permanent handle, an empty list +// will be returned with 'more' set to NO. +// Return Type: TPMI_YES_NO +// YES if there are more handles available +// NO all the available handles has been returned +TPMI_YES_NO +PermanentCapGetHandles(TPM_HANDLE handle, // IN: start handle + UINT32 count, // IN: count of returned handles + TPML_HANDLE* handleList // OUT: list of handle +); + +//*** PermanentCapGetOneHandle() +// This function returns whether a permanent handle exists. +BOOL PermanentCapGetOneHandle(TPM_HANDLE handle // IN: handle +); + +//*** PermanentHandleGetPolicy() +// This function returns a list of the permanent handles of PCR, started from +// 'handle'. If 'handle' is larger than the largest permanent handle, an empty list +// will be returned with 'more' set to NO. +// Return Type: TPMI_YES_NO +// YES if there are more handles available +// NO all the available handles has been returned +TPMI_YES_NO +PermanentHandleGetPolicy(TPM_HANDLE handle, // IN: start handle + UINT32 count, // IN: max count of returned handles + TPML_TAGGED_POLICY* policyList // OUT: list of handle +); + +//*** PermanentHandleGetOnePolicy() +// This function returns a permanent handle's policy, if present. +BOOL PermanentHandleGetOnePolicy(TPM_HANDLE handle, // IN: handle + TPMS_TAGGED_POLICY* policy // OUT: tagged policy +); + +#endif // _HANDLE_FP_H_ diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/HashSequenceStart_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/HashSequenceStart_fp.h new file mode 100644 index 000000000..cf59f95e6 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/HashSequenceStart_fp.h @@ -0,0 +1,33 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_HashSequenceStart // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_HASHSEQUENCESTART_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_HASHSEQUENCESTART_FP_H_ + +// Input structure definition +typedef struct +{ + TPM2B_AUTH auth; + TPMI_ALG_HASH hashAlg; +} HashSequenceStart_In; + +// Output structure definition +typedef struct +{ + TPMI_DH_OBJECT sequenceHandle; +} HashSequenceStart_Out; + +// Response code modifiers +# define RC_HashSequenceStart_auth (TPM_RC_P + TPM_RC_1) +# define RC_HashSequenceStart_hashAlg (TPM_RC_P + TPM_RC_2) + +// Function prototype +TPM_RC +TPM2_HashSequenceStart(HashSequenceStart_In* in, HashSequenceStart_Out* out); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_HASHSEQUENCESTART_FP_H_ +#endif // CC_HashSequenceStart diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/Hash_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/Hash_fp.h new file mode 100644 index 000000000..bf434efbe --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/Hash_fp.h @@ -0,0 +1,36 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_Hash // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_HASH_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_HASH_FP_H_ + +// Input structure definition +typedef struct +{ + TPM2B_MAX_BUFFER data; + TPMI_ALG_HASH hashAlg; + TPMI_RH_HIERARCHY hierarchy; +} Hash_In; + +// Output structure definition +typedef struct +{ + TPM2B_DIGEST outHash; + TPMT_TK_HASHCHECK validation; +} Hash_Out; + +// Response code modifiers +# define RC_Hash_data (TPM_RC_P + TPM_RC_1) +# define RC_Hash_hashAlg (TPM_RC_P + TPM_RC_2) +# define RC_Hash_hierarchy (TPM_RC_P + TPM_RC_3) + +// Function prototype +TPM_RC +TPM2_Hash(Hash_In* in, Hash_Out* out); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_HASH_FP_H_ +#endif // CC_Hash diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/HierarchyChangeAuth_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/HierarchyChangeAuth_fp.h new file mode 100644 index 000000000..140d608d4 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/HierarchyChangeAuth_fp.h @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_HierarchyChangeAuth // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_HIERARCHYCHANGEAUTH_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_HIERARCHYCHANGEAUTH_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_RH_HIERARCHY_AUTH authHandle; + TPM2B_AUTH newAuth; +} HierarchyChangeAuth_In; + +// Response code modifiers +# define RC_HierarchyChangeAuth_authHandle (TPM_RC_H + TPM_RC_1) +# define RC_HierarchyChangeAuth_newAuth (TPM_RC_P + TPM_RC_1) + +// Function prototype +TPM_RC +TPM2_HierarchyChangeAuth(HierarchyChangeAuth_In* in); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_HIERARCHYCHANGEAUTH_FP_H_ +#endif // CC_HierarchyChangeAuth diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/HierarchyControl_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/HierarchyControl_fp.h new file mode 100644 index 000000000..44700e285 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/HierarchyControl_fp.h @@ -0,0 +1,29 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_HierarchyControl // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_HIERARCHYCONTROL_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_HIERARCHYCONTROL_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_RH_BASE_HIERARCHY authHandle; + TPMI_RH_ENABLES enable; + TPMI_YES_NO state; +} HierarchyControl_In; + +// Response code modifiers +# define RC_HierarchyControl_authHandle (TPM_RC_H + TPM_RC_1) +# define RC_HierarchyControl_enable (TPM_RC_P + TPM_RC_1) +# define RC_HierarchyControl_state (TPM_RC_P + TPM_RC_2) + +// Function prototype +TPM_RC +TPM2_HierarchyControl(HierarchyControl_In* in); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_HIERARCHYCONTROL_FP_H_ +#endif // CC_HierarchyControl diff --git a/src/tpm2/Hierarchy_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/Hierarchy_fp.h similarity index 55% rename from src/tpm2/Hierarchy_fp.h rename to src/tpm2/TPMCmd/tpm/include/private/prototypes/Hierarchy_fp.h index 49a5dcd66..c878b3666 100644 --- a/src/tpm2/Hierarchy_fp.h +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/Hierarchy_fp.h @@ -1,62 +1,4 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2016 - 2023 */ -/* */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause /*(Auto-generated) * Created by TpmPrototypes; Version 3.0 July 18, 2017 diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/Import_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/Import_fp.h new file mode 100644 index 000000000..b4d2d5206 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/Import_fp.h @@ -0,0 +1,41 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_Import // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_IMPORT_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_IMPORT_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_DH_OBJECT parentHandle; + TPM2B_DATA encryptionKey; + TPM2B_PUBLIC objectPublic; + TPM2B_PRIVATE duplicate; + TPM2B_ENCRYPTED_SECRET inSymSeed; + TPMT_SYM_DEF_OBJECT symmetricAlg; +} Import_In; + +// Output structure definition +typedef struct +{ + TPM2B_PRIVATE outPrivate; +} Import_Out; + +// Response code modifiers +# define RC_Import_parentHandle (TPM_RC_H + TPM_RC_1) +# define RC_Import_encryptionKey (TPM_RC_P + TPM_RC_1) +# define RC_Import_objectPublic (TPM_RC_P + TPM_RC_2) +# define RC_Import_duplicate (TPM_RC_P + TPM_RC_3) +# define RC_Import_inSymSeed (TPM_RC_P + TPM_RC_4) +# define RC_Import_symmetricAlg (TPM_RC_P + TPM_RC_5) + +// Function prototype +TPM_RC +TPM2_Import(Import_In* in, Import_Out* out); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_IMPORT_FP_H_ +#endif // CC_Import diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/IncrementalSelfTest_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/IncrementalSelfTest_fp.h new file mode 100644 index 000000000..5db9c1270 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/IncrementalSelfTest_fp.h @@ -0,0 +1,31 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_IncrementalSelfTest // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_INCREMENTALSELFTEST_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_INCREMENTALSELFTEST_FP_H_ + +// Input structure definition +typedef struct +{ + TPML_ALG toTest; +} IncrementalSelfTest_In; + +// Output structure definition +typedef struct +{ + TPML_ALG toDoList; +} IncrementalSelfTest_Out; + +// Response code modifiers +# define RC_IncrementalSelfTest_toTest (TPM_RC_P + TPM_RC_1) + +// Function prototype +TPM_RC +TPM2_IncrementalSelfTest(IncrementalSelfTest_In* in, IncrementalSelfTest_Out* out); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_INCREMENTALSELFTEST_FP_H_ +#endif // CC_IncrementalSelfTest diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/IoBuffers_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/IoBuffers_fp.h new file mode 100644 index 000000000..c123f92cf --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/IoBuffers_fp.h @@ -0,0 +1,42 @@ +// SPDX-License-Identifier: BSD-2-Clause + +/*(Auto-generated) + * Created by TpmPrototypes; Version 3.0 July 18, 2017 + * Date: Mar 28, 2019 Time: 08:25:19PM + */ + +#ifndef _IO_BUFFERS_FP_H_ +#define _IO_BUFFERS_FP_H_ + +//*** MemoryIoBufferAllocationReset() +// This function is used to reset the allocation of buffers. +void MemoryIoBufferAllocationReset(void); + +//*** MemoryIoBufferZero() +// Function zeros the action I/O buffer at the end of a command. Calling this is +// not mandatory for proper functionality. +void MemoryIoBufferZero(void); + +//*** MemoryGetInBuffer() +// This function returns the address of the buffer into which the +// command parameters will be unmarshaled in preparation for calling +// the command actions. Returns NULL if not possible. +BYTE* MemoryGetInBuffer(UINT32 size // Size, in bytes, required for the input + // unmarshaling +); + +//*** MemoryGetOutBuffer() +// This function returns the address of the buffer into which the command +// action code places its output values. Returns NULL if not possible. +BYTE* MemoryGetOutBuffer(UINT32 size // required size of the buffer +); + +//*** IsLabelProperlyFormatted() +// This function checks that a label is a null-terminated string. +// NOTE: this function is here because there was no better place for it. +// Return Type: BOOL +// TRUE(1) string is null terminated +// FALSE(0) string is not null terminated +BOOL IsLabelProperlyFormatted(TPM2B* x); + +#endif // _IO_BUFFERS_FP_H_ diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/LoadExternal_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/LoadExternal_fp.h new file mode 100644 index 000000000..72794644e --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/LoadExternal_fp.h @@ -0,0 +1,36 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_LoadExternal // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_LOADEXTERNAL_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_LOADEXTERNAL_FP_H_ + +// Input structure definition +typedef struct +{ + TPM2B_SENSITIVE inPrivate; + TPM2B_PUBLIC inPublic; + TPMI_RH_HIERARCHY hierarchy; +} LoadExternal_In; + +// Output structure definition +typedef struct +{ + TPM_HANDLE objectHandle; + TPM2B_NAME name; +} LoadExternal_Out; + +// Response code modifiers +# define RC_LoadExternal_inPrivate (TPM_RC_P + TPM_RC_1) +# define RC_LoadExternal_inPublic (TPM_RC_P + TPM_RC_2) +# define RC_LoadExternal_hierarchy (TPM_RC_P + TPM_RC_3) + +// Function prototype +TPM_RC +TPM2_LoadExternal(LoadExternal_In* in, LoadExternal_Out* out); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_LOADEXTERNAL_FP_H_ +#endif // CC_LoadExternal diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/Load_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/Load_fp.h new file mode 100644 index 000000000..f440c65d3 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/Load_fp.h @@ -0,0 +1,36 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_Load // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_LOAD_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_LOAD_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_DH_OBJECT parentHandle; + TPM2B_PRIVATE inPrivate; + TPM2B_PUBLIC inPublic; +} Load_In; + +// Output structure definition +typedef struct +{ + TPM_HANDLE objectHandle; + TPM2B_NAME name; +} Load_Out; + +// Response code modifiers +# define RC_Load_parentHandle (TPM_RC_H + TPM_RC_1) +# define RC_Load_inPrivate (TPM_RC_P + TPM_RC_1) +# define RC_Load_inPublic (TPM_RC_P + TPM_RC_2) + +// Function prototype +TPM_RC +TPM2_Load(Load_In* in, Load_Out* out); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_LOAD_FP_H_ +#endif // CC_Load diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/Locality_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/Locality_fp.h new file mode 100644 index 000000000..06898c293 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/Locality_fp.h @@ -0,0 +1,20 @@ +// SPDX-License-Identifier: BSD-2-Clause + +/*(Auto-generated) + * Created by TpmPrototypes; Version 3.0 July 18, 2017 + * Date: Mar 28, 2019 Time: 08:25:19PM + */ + +#ifndef _LOCALITY_FP_H_ +#define _LOCALITY_FP_H_ + +//** LocalityGetAttributes() +// This function will convert a locality expressed as an integer into +// TPMA_LOCALITY form. +// +// The function returns the locality attribute. +TPMA_LOCALITY +LocalityGetAttributes(UINT8 locality // IN: locality value +); + +#endif // _LOCALITY_FP_H_ diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/MAC_Start_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/MAC_Start_fp.h new file mode 100644 index 000000000..8baf4549e --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/MAC_Start_fp.h @@ -0,0 +1,35 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_MAC_Start // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_MAC_START_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_MAC_START_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_DH_OBJECT handle; + TPM2B_AUTH auth; + TPMI_ALG_MAC_SCHEME inScheme; +} MAC_Start_In; + +// Output structure definition +typedef struct +{ + TPMI_DH_OBJECT sequenceHandle; +} MAC_Start_Out; + +// Response code modifiers +# define RC_MAC_Start_handle (TPM_RC_H + TPM_RC_1) +# define RC_MAC_Start_auth (TPM_RC_P + TPM_RC_1) +# define RC_MAC_Start_inScheme (TPM_RC_P + TPM_RC_2) + +// Function prototype +TPM_RC +TPM2_MAC_Start(MAC_Start_In* in, MAC_Start_Out* out); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_MAC_START_FP_H_ +#endif // CC_MAC_Start diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/MAC_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/MAC_fp.h new file mode 100644 index 000000000..9e9d8a7f5 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/MAC_fp.h @@ -0,0 +1,35 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_MAC // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_MAC_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_MAC_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_DH_OBJECT handle; + TPM2B_MAX_BUFFER buffer; + TPMI_ALG_MAC_SCHEME inScheme; +} MAC_In; + +// Output structure definition +typedef struct +{ + TPM2B_DIGEST outMAC; +} MAC_Out; + +// Response code modifiers +# define RC_MAC_handle (TPM_RC_H + TPM_RC_1) +# define RC_MAC_buffer (TPM_RC_P + TPM_RC_1) +# define RC_MAC_inScheme (TPM_RC_P + TPM_RC_2) + +// Function prototype +TPM_RC +TPM2_MAC(MAC_In* in, MAC_Out* out); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_MAC_FP_H_ +#endif // CC_MAC diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/MakeCredential_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/MakeCredential_fp.h new file mode 100644 index 000000000..0658b71f1 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/MakeCredential_fp.h @@ -0,0 +1,36 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_MakeCredential // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_MAKECREDENTIAL_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_MAKECREDENTIAL_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_DH_OBJECT handle; + TPM2B_DIGEST credential; + TPM2B_NAME objectName; +} MakeCredential_In; + +// Output structure definition +typedef struct +{ + TPM2B_ID_OBJECT credentialBlob; + TPM2B_ENCRYPTED_SECRET secret; +} MakeCredential_Out; + +// Response code modifiers +# define RC_MakeCredential_handle (TPM_RC_H + TPM_RC_1) +# define RC_MakeCredential_credential (TPM_RC_P + TPM_RC_1) +# define RC_MakeCredential_objectName (TPM_RC_P + TPM_RC_2) + +// Function prototype +TPM_RC +TPM2_MakeCredential(MakeCredential_In* in, MakeCredential_Out* out); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_MAKECREDENTIAL_FP_H_ +#endif // CC_MakeCredential diff --git a/src/tpm2/Marshal_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/Marshal_fp.h similarity index 85% rename from src/tpm2/Marshal_fp.h rename to src/tpm2/TPMCmd/tpm/include/private/prototypes/Marshal_fp.h index ccf42c4c2..9fea6705f 100644 --- a/src/tpm2/Marshal_fp.h +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/Marshal_fp.h @@ -1,68 +1,48 @@ +// SPDX-License-Identifier: BSD-2-Clause + /********************************************************************************/ /* */ /* Parameter Marshaling */ /* 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 */ +/* (c) Copyright IBM Corporation 2015 - 2026 */ /* */ +/* All rights reserved. */ +/* */ +/* Redistribution and use in source and binary forms, with or without */ +/* modification, are permitted provided that the following conditions are */ +/* met: */ +/* */ +/* Redistributions of source code must retain the above copyright notice, */ +/* this list of conditions and the following disclaimer. */ +/* */ +/* Redistributions in binary form must reproduce the above copyright */ +/* notice, this list of conditions and the following disclaimer in the */ +/* documentation and/or other materials provided with the distribution. */ +/* */ +/* Neither the names of the IBM Corporation nor the names of its */ +/* contributors may be used to endorse or promote products derived from */ +/* this software without specific prior written permission. */ +/* */ +/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */ +/* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */ +/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR */ +/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */ +/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */ +/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */ +/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, */ +/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY */ +/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */ +/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE */ +/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /********************************************************************************/ #ifndef MARSHAL_FP_H #define MARSHAL_FP_H #include "Tpm.h" -#include "TpmTypes.h" +#include #ifdef __cplusplus extern "C" { @@ -176,6 +156,10 @@ extern "C" { TPMS_TAGGED_POLICY_Marshal(TPMS_TAGGED_POLICY *source, BYTE **buffer, INT32 *size); UINT16 TPMS_ACT_DATA_Marshal(TPMS_ACT_DATA *source, BYTE **buffer, INT32 *size); +# if SEC_CHANNEL_SUPPORT + UINT16 + TPMS_SPDM_SESSION_INFO_Marshal(TPMS_SPDM_SESSION_INFO* source, BYTE** buffer, INT32* size); +# endif // SEC_CHANNEL_SUPPORT UINT16 TPMS_TAGGED_PROPERTY_Marshal(TPMS_TAGGED_PROPERTY *source, BYTE **buffer, INT32 *size); UINT16 @@ -204,6 +188,12 @@ extern "C" { TPML_TAGGED_POLICY_Marshal(TPML_TAGGED_POLICY *source, BYTE **buffer, INT32 *size); UINT16 TPML_ACT_DATA_Marshal(TPML_ACT_DATA *source, BYTE **buffer, INT32 *size); +#if SEC_CHANNEL_SUPPORT + UINT16 + TPML_PUB_KEY_Marshal(TPML_PUB_KEY* source, BYTE** buffer, INT32* size); + UINT16 + TPML_SPDM_SESSION_INFO_Marshal(TPML_SPDM_SESSION_INFO* source, BYTE** buffer, INT32* size); +#endif UINT16 TPMU_CAPABILITIES_Marshal(TPMU_CAPABILITIES *source, BYTE **buffer, INT32 *size, UINT32 selector); UINT16 @@ -414,6 +404,12 @@ extern "C" { TPMS_SET_CAPABILITY_DATA_Unmarshal(TPMS_SET_CAPABILITY_DATA* target, BYTE** buffer, INT32* size); TPM_RC TPM2B_SET_CAPABILITY_DATA_Unmarshal(TPM2B_SET_CAPABILITY_DATA* target, BYTE** buffer, INT32* size); +# if SEC_CHANNEL_SUPPORT + UINT16 + TPM2B_PUBLIC_Array_Marshal(TPM2B_PUBLIC* source, BYTE** buffer, INT32* size, INT32 count); + UINT16 + TPMS_SPDM_SESSION_INFO_Array_Marshal(TPMS_SPDM_SESSION_INFO* source, BYTE** buffer, INT32* size, INT32 count); +# endif // SEC_CHANNEL_SUPPORT #ifdef __cplusplus } #endif diff --git a/src/tpm2/MathOnByteBuffers_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/MathOnByteBuffers_fp.h similarity index 52% rename from src/tpm2/MathOnByteBuffers_fp.h rename to src/tpm2/TPMCmd/tpm/include/private/prototypes/MathOnByteBuffers_fp.h index b4a29f3fb..e9d051d9d 100644 --- a/src/tpm2/MathOnByteBuffers_fp.h +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/MathOnByteBuffers_fp.h @@ -1,62 +1,4 @@ -/********************************************************************************/ -/* */ -/* Math functions performed with canonical integers in byte buffers */ -/* 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 /*(Auto-generated) * Created by TpmPrototypes; Version 3.0 July 18, 2017 diff --git a/src/tpm2/Memory_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/Memory_fp.h similarity index 52% rename from src/tpm2/Memory_fp.h rename to src/tpm2/TPMCmd/tpm/include/private/prototypes/Memory_fp.h index 03aaebd4d..9e6358e47 100644 --- a/src/tpm2/Memory_fp.h +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/Memory_fp.h @@ -1,63 +1,4 @@ -/********************************************************************************/ -/* */ -/* Miscellaneous Memory Manipulation Routines */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: Memory_fp.h 1476 2019-06-10 19:32:03Z 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 /*(Auto-generated) * Created by TpmPrototypes; Version 3.0 July 18, 2017 diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/NV_Certify_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/NV_Certify_fp.h new file mode 100644 index 000000000..593709ce2 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/NV_Certify_fp.h @@ -0,0 +1,44 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_NV_Certify // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_CERTIFY_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_CERTIFY_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_DH_OBJECT signHandle; + TPMI_RH_NV_AUTH authHandle; + TPMI_RH_NV_INDEX nvIndex; + TPM2B_DATA qualifyingData; + TPMT_SIG_SCHEME inScheme; + UINT16 size; + UINT16 offset; +} NV_Certify_In; + +// Output structure definition +typedef struct +{ + TPM2B_ATTEST certifyInfo; + TPMT_SIGNATURE signature; +} NV_Certify_Out; + +// Response code modifiers +# define RC_NV_Certify_signHandle (TPM_RC_H + TPM_RC_1) +# define RC_NV_Certify_authHandle (TPM_RC_H + TPM_RC_2) +# define RC_NV_Certify_nvIndex (TPM_RC_H + TPM_RC_3) +# define RC_NV_Certify_qualifyingData (TPM_RC_P + TPM_RC_1) +# define RC_NV_Certify_inScheme (TPM_RC_P + TPM_RC_2) +# define RC_NV_Certify_size (TPM_RC_P + TPM_RC_3) +# define RC_NV_Certify_offset (TPM_RC_P + TPM_RC_4) + +// Function prototype +TPM_RC +TPM2_NV_Certify(NV_Certify_In* in, NV_Certify_Out* out); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_CERTIFY_FP_H_ +#endif // CC_NV_Certify diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/NV_ChangeAuth_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/NV_ChangeAuth_fp.h new file mode 100644 index 000000000..96f48b9de --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/NV_ChangeAuth_fp.h @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_NV_ChangeAuth // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_CHANGEAUTH_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_CHANGEAUTH_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_RH_NV_INDEX nvIndex; + TPM2B_AUTH newAuth; +} NV_ChangeAuth_In; + +// Response code modifiers +# define RC_NV_ChangeAuth_nvIndex (TPM_RC_H + TPM_RC_1) +# define RC_NV_ChangeAuth_newAuth (TPM_RC_P + TPM_RC_1) + +// Function prototype +TPM_RC +TPM2_NV_ChangeAuth(NV_ChangeAuth_In* in); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_CHANGEAUTH_FP_H_ +#endif // CC_NV_ChangeAuth diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/NV_DefineSpace2_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/NV_DefineSpace2_fp.h new file mode 100644 index 000000000..d17d81014 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/NV_DefineSpace2_fp.h @@ -0,0 +1,29 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_NV_DefineSpace2 // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_DEFINESPACE2_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_DEFINESPACE2_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_RH_PROVISION authHandle; + TPM2B_AUTH auth; + TPM2B_NV_PUBLIC_2 publicInfo; +} NV_DefineSpace2_In; + +// Response code modifiers +# define RC_NV_DefineSpace2_authHandle (TPM_RC_H + TPM_RC_1) +# define RC_NV_DefineSpace2_auth (TPM_RC_P + TPM_RC_1) +# define RC_NV_DefineSpace2_publicInfo (TPM_RC_P + TPM_RC_2) + +// Function prototype +TPM_RC +TPM2_NV_DefineSpace2(NV_DefineSpace2_In* in); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_DEFINESPACE2_FP_H_ +#endif // CC_NV_DefineSpace2 diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/NV_DefineSpace_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/NV_DefineSpace_fp.h new file mode 100644 index 000000000..d02305921 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/NV_DefineSpace_fp.h @@ -0,0 +1,29 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_NV_DefineSpace // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_DEFINESPACE_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_DEFINESPACE_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_RH_PROVISION authHandle; + TPM2B_AUTH auth; + TPM2B_NV_PUBLIC publicInfo; +} NV_DefineSpace_In; + +// Response code modifiers +# define RC_NV_DefineSpace_authHandle (TPM_RC_H + TPM_RC_1) +# define RC_NV_DefineSpace_auth (TPM_RC_P + TPM_RC_1) +# define RC_NV_DefineSpace_publicInfo (TPM_RC_P + TPM_RC_2) + +// Function prototype +TPM_RC +TPM2_NV_DefineSpace(NV_DefineSpace_In* in); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_DEFINESPACE_FP_H_ +#endif // CC_NV_DefineSpace diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/NV_Extend_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/NV_Extend_fp.h new file mode 100644 index 000000000..4845b4a53 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/NV_Extend_fp.h @@ -0,0 +1,29 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_NV_Extend // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_EXTEND_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_EXTEND_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_RH_NV_AUTH authHandle; + TPMI_RH_NV_INDEX nvIndex; + TPM2B_MAX_NV_BUFFER data; +} NV_Extend_In; + +// Response code modifiers +# define RC_NV_Extend_authHandle (TPM_RC_H + TPM_RC_1) +# define RC_NV_Extend_nvIndex (TPM_RC_H + TPM_RC_2) +# define RC_NV_Extend_data (TPM_RC_P + TPM_RC_1) + +// Function prototype +TPM_RC +TPM2_NV_Extend(NV_Extend_In* in); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_EXTEND_FP_H_ +#endif // CC_NV_Extend diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/NV_GlobalWriteLock_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/NV_GlobalWriteLock_fp.h new file mode 100644 index 000000000..16e89d0b5 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/NV_GlobalWriteLock_fp.h @@ -0,0 +1,25 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_NV_GlobalWriteLock // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_GLOBALWRITELOCK_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_GLOBALWRITELOCK_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_RH_PROVISION authHandle; +} NV_GlobalWriteLock_In; + +// Response code modifiers +# define RC_NV_GlobalWriteLock_authHandle (TPM_RC_H + TPM_RC_1) + +// Function prototype +TPM_RC +TPM2_NV_GlobalWriteLock(NV_GlobalWriteLock_In* in); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_GLOBALWRITELOCK_FP_H_ +#endif // CC_NV_GlobalWriteLock diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/NV_Increment_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/NV_Increment_fp.h new file mode 100644 index 000000000..8e51daced --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/NV_Increment_fp.h @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_NV_Increment // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_INCREMENT_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_INCREMENT_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_RH_NV_AUTH authHandle; + TPMI_RH_NV_INDEX nvIndex; +} NV_Increment_In; + +// Response code modifiers +# define RC_NV_Increment_authHandle (TPM_RC_H + TPM_RC_1) +# define RC_NV_Increment_nvIndex (TPM_RC_H + TPM_RC_2) + +// Function prototype +TPM_RC +TPM2_NV_Increment(NV_Increment_In* in); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_INCREMENT_FP_H_ +#endif // CC_NV_Increment diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/NV_ReadLock_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/NV_ReadLock_fp.h new file mode 100644 index 000000000..1eaa5fccb --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/NV_ReadLock_fp.h @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_NV_ReadLock // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_READLOCK_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_READLOCK_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_RH_NV_AUTH authHandle; + TPMI_RH_NV_INDEX nvIndex; +} NV_ReadLock_In; + +// Response code modifiers +# define RC_NV_ReadLock_authHandle (TPM_RC_H + TPM_RC_1) +# define RC_NV_ReadLock_nvIndex (TPM_RC_H + TPM_RC_2) + +// Function prototype +TPM_RC +TPM2_NV_ReadLock(NV_ReadLock_In* in); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_READLOCK_FP_H_ +#endif // CC_NV_ReadLock diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/NV_ReadPublic2_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/NV_ReadPublic2_fp.h new file mode 100644 index 000000000..d5d4eb7ea --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/NV_ReadPublic2_fp.h @@ -0,0 +1,32 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_NV_ReadPublic2 // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_READPUBLIC2_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_READPUBLIC2_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_RH_NV_INDEX nvIndex; +} NV_ReadPublic2_In; + +// Output structure definition +typedef struct +{ + TPM2B_NV_PUBLIC_2 nvPublic; + TPM2B_NAME nvName; +} NV_ReadPublic2_Out; + +// Response code modifiers +# define RC_NV_ReadPublic2_nvIndex (TPM_RC_H + TPM_RC_1) + +// Function prototype +TPM_RC +TPM2_NV_ReadPublic2(NV_ReadPublic2_In* in, NV_ReadPublic2_Out* out); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_READPUBLIC2_FP_H_ +#endif // CC_NV_ReadPublic2 diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/NV_ReadPublic_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/NV_ReadPublic_fp.h new file mode 100644 index 000000000..b88c2606f --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/NV_ReadPublic_fp.h @@ -0,0 +1,32 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_NV_ReadPublic // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_READPUBLIC_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_READPUBLIC_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_RH_NV_INDEX nvIndex; +} NV_ReadPublic_In; + +// Output structure definition +typedef struct +{ + TPM2B_NV_PUBLIC nvPublic; + TPM2B_NAME nvName; +} NV_ReadPublic_Out; + +// Response code modifiers +# define RC_NV_ReadPublic_nvIndex (TPM_RC_H + TPM_RC_1) + +// Function prototype +TPM_RC +TPM2_NV_ReadPublic(NV_ReadPublic_In* in, NV_ReadPublic_Out* out); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_READPUBLIC_FP_H_ +#endif // CC_NV_ReadPublic diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/NV_Read_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/NV_Read_fp.h new file mode 100644 index 000000000..940a2bd91 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/NV_Read_fp.h @@ -0,0 +1,37 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_NV_Read // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_READ_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_READ_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_RH_NV_AUTH authHandle; + TPMI_RH_NV_INDEX nvIndex; + UINT16 size; + UINT16 offset; +} NV_Read_In; + +// Output structure definition +typedef struct +{ + TPM2B_MAX_NV_BUFFER data; +} NV_Read_Out; + +// Response code modifiers +# define RC_NV_Read_authHandle (TPM_RC_H + TPM_RC_1) +# define RC_NV_Read_nvIndex (TPM_RC_H + TPM_RC_2) +# define RC_NV_Read_size (TPM_RC_P + TPM_RC_1) +# define RC_NV_Read_offset (TPM_RC_P + TPM_RC_2) + +// Function prototype +TPM_RC +TPM2_NV_Read(NV_Read_In* in, NV_Read_Out* out); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_READ_FP_H_ +#endif // CC_NV_Read diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/NV_SetBits_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/NV_SetBits_fp.h new file mode 100644 index 000000000..5fe15d935 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/NV_SetBits_fp.h @@ -0,0 +1,29 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_NV_SetBits // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_SETBITS_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_SETBITS_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_RH_NV_AUTH authHandle; + TPMI_RH_NV_INDEX nvIndex; + UINT64 bits; +} NV_SetBits_In; + +// Response code modifiers +# define RC_NV_SetBits_authHandle (TPM_RC_H + TPM_RC_1) +# define RC_NV_SetBits_nvIndex (TPM_RC_H + TPM_RC_2) +# define RC_NV_SetBits_bits (TPM_RC_P + TPM_RC_1) + +// Function prototype +TPM_RC +TPM2_NV_SetBits(NV_SetBits_In* in); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_SETBITS_FP_H_ +#endif // CC_NV_SetBits diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/NV_UndefineSpaceSpecial_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/NV_UndefineSpaceSpecial_fp.h new file mode 100644 index 000000000..db9b84f92 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/NV_UndefineSpaceSpecial_fp.h @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_NV_UndefineSpaceSpecial // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_UNDEFINESPACESPECIAL_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_UNDEFINESPACESPECIAL_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_RH_NV_DEFINED_INDEX nvIndex; + TPMI_RH_PLATFORM platform; +} NV_UndefineSpaceSpecial_In; + +// Response code modifiers +# define RC_NV_UndefineSpaceSpecial_nvIndex (TPM_RC_H + TPM_RC_1) +# define RC_NV_UndefineSpaceSpecial_platform (TPM_RC_H + TPM_RC_2) + +// Function prototype +TPM_RC +TPM2_NV_UndefineSpaceSpecial(NV_UndefineSpaceSpecial_In* in); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_UNDEFINESPACESPECIAL_FP_H_ +#endif // CC_NV_UndefineSpaceSpecial diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/NV_UndefineSpace_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/NV_UndefineSpace_fp.h new file mode 100644 index 000000000..cbde53e15 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/NV_UndefineSpace_fp.h @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_NV_UndefineSpace // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_UNDEFINESPACE_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_UNDEFINESPACE_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_RH_PROVISION authHandle; + TPMI_RH_NV_DEFINED_INDEX nvIndex; +} NV_UndefineSpace_In; + +// Response code modifiers +# define RC_NV_UndefineSpace_authHandle (TPM_RC_H + TPM_RC_1) +# define RC_NV_UndefineSpace_nvIndex (TPM_RC_H + TPM_RC_2) + +// Function prototype +TPM_RC +TPM2_NV_UndefineSpace(NV_UndefineSpace_In* in); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_UNDEFINESPACE_FP_H_ +#endif // CC_NV_UndefineSpace diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/NV_WriteLock_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/NV_WriteLock_fp.h new file mode 100644 index 000000000..21ae5d95d --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/NV_WriteLock_fp.h @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_NV_WriteLock // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_WRITELOCK_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_WRITELOCK_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_RH_NV_AUTH authHandle; + TPMI_RH_NV_INDEX nvIndex; +} NV_WriteLock_In; + +// Response code modifiers +# define RC_NV_WriteLock_authHandle (TPM_RC_H + TPM_RC_1) +# define RC_NV_WriteLock_nvIndex (TPM_RC_H + TPM_RC_2) + +// Function prototype +TPM_RC +TPM2_NV_WriteLock(NV_WriteLock_In* in); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_WRITELOCK_FP_H_ +#endif // CC_NV_WriteLock diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/NV_Write_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/NV_Write_fp.h new file mode 100644 index 000000000..9480c774a --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/NV_Write_fp.h @@ -0,0 +1,31 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_NV_Write // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_WRITE_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_WRITE_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_RH_NV_AUTH authHandle; + TPMI_RH_NV_INDEX nvIndex; + TPM2B_MAX_NV_BUFFER data; + UINT16 offset; +} NV_Write_In; + +// Response code modifiers +# define RC_NV_Write_authHandle (TPM_RC_H + TPM_RC_1) +# define RC_NV_Write_nvIndex (TPM_RC_H + TPM_RC_2) +# define RC_NV_Write_data (TPM_RC_P + TPM_RC_1) +# define RC_NV_Write_offset (TPM_RC_P + TPM_RC_2) + +// Function prototype +TPM_RC +TPM2_NV_Write(NV_Write_In* in); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_NV_WRITE_FP_H_ +#endif // CC_NV_Write diff --git a/src/tpm2/NV_spt_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/NV_spt_fp.h similarity index 51% rename from src/tpm2/NV_spt_fp.h rename to src/tpm2/TPMCmd/tpm/include/private/prototypes/NV_spt_fp.h index bd134b58f..d32021385 100644 --- a/src/tpm2/NV_spt_fp.h +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/NV_spt_fp.h @@ -1,62 +1,4 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2016 - 2023 */ -/* */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause /*(Auto-generated) * Created by TpmPrototypes; Version 3.0 July 18, 2017 @@ -97,6 +39,20 @@ NvWriteAccessChecks( TPMA_NV attributes // IN: the attributes of 'nvHandle' ); +//*** NvReadOnlyModeChecks() +// Common routine to verify whether an NV command is allowed on an index +// with the given 'attributes' while the TPM is in Read-Only mode +// Used by TPM2_NV_Write, TPM2_NV_Extend, TPM2_SetBits, TPM2_NV_WriteLock +// and TPM2_NV_ReadLock +// Return Type: TPM_RC +// TPM_RC_SUCCESS The command is allowed +// TPM_RC_READ_ONLY The TPM is in Read-Only mode and the command is +// not allowed +// +TPM_RC +NvReadOnlyModeChecks(TPMA_NV attributes // IN: the attributes of the index to check +); + //*** NvClearOrderly() // This function is used to cause gp.orderlyState to be cleared to the // non-orderly state. @@ -111,6 +67,15 @@ NvClearOrderly(void); BOOL NvIsPinPassIndex(TPM_HANDLE index // IN: Handle to check ); +//*** NvIsPinCountedIndex() +// Function to check to see if an NV index is either a PIN Pass +// or a PIN FAIL Index +// Return Type: BOOL +// TRUE(1) is pin pass or pin fail +// FALSE(0) is neither pin pass nor pin fail +BOOL NvIsPinCountedIndex(TPM_HANDLE index // IN: Handle to check +); + //*** NvGetIndexName() // This function computes the Name of an index // The 'name' buffer receives the bytes of the Name and the return value diff --git a/src/tpm2/NvDynamic_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/NvDynamic_fp.h similarity index 81% rename from src/tpm2/NvDynamic_fp.h rename to src/tpm2/TPMCmd/tpm/include/private/prototypes/NvDynamic_fp.h index e960f515c..d679bd139 100644 --- a/src/tpm2/NvDynamic_fp.h +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/NvDynamic_fp.h @@ -1,62 +1,4 @@ -/********************************************************************************/ -/* */ -/* Dynamic space for user defined NV */ -/* 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 /*(Auto-generated) * Created by TpmPrototypes; Version 3.0 July 18, 2017 @@ -136,8 +78,8 @@ BOOL NvIsOwnerPersistentHandle(TPM_HANDLE handle // IN: handle // TPM_RC_NV_WRITELOCKED Index is present but locked for writing and command // writes to the index TPM_RC -NvIndexIsAccessible(TPMI_RH_NV_INDEX handle // IN: handle -); +NvIndexIsAccessible(TPMI_RH_NV_INDEX handle, // IN: handle + BOOL commandAcceptsVirtualHandles); //*** NvGetEvictObject() // This function is used to dereference an evict object handle and get a pointer diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/NvReserved_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/NvReserved_fp.h new file mode 100644 index 000000000..908daa5c4 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/NvReserved_fp.h @@ -0,0 +1,78 @@ +// SPDX-License-Identifier: BSD-2-Clause + +/*(Auto-generated) + * Created by TpmPrototypes; Version 3.0 July 18, 2017 + * Date: Apr 2, 2019 Time: 04:23:27PM + */ + +#ifndef _NV_RESERVED_FP_H_ +#define _NV_RESERVED_FP_H_ + +#include "NVMarshal.h" /* libtpms added */ + +//*** NvCheckState() +// Function to check the NV state by accessing the platform-specific function +// to get the NV state. The result state is registered in s_NvIsAvailable +// that will be reported by NvIsAvailable. +// +// This function is called at the beginning of ExecuteCommand before any potential +// check of g_NvStatus. +void NvCheckState(void); + +//*** NvCommit +// This is a wrapper for the platform function to commit pending NV writes. +BOOL NvCommit(void); + +//*** NvPowerOn() +// This function is called at _TPM_Init to initialize the NV environment. +// Return Type: BOOL +// TRUE(1) all NV was initialized +// FALSE(0) the NV containing saved state had an error and +// TPM2_Startup(CLEAR) is required +BOOL NvPowerOn(void); + +//*** NvManufacture() +// This function initializes the NV system at pre-install time. +// +// This function should only be called in a manufacturing environment or in a +// simulation. +// +// The layout of NV memory space is an implementation choice. +void NvManufacture(void); + +//*** NvRead() +// This function is used to move reserved data from NV memory to RAM. +void NvRead(void* outBuffer, // OUT: buffer to receive data + UINT32 nvOffset, // IN: offset in NV of value + UINT32 size // IN: size of the value to read +); + +//*** NvWrite() +// This function is used to post reserved data for writing to NV memory. Before +// the TPM completes the operation, the value will be written. +BOOL NvWrite(UINT32 nvOffset, // IN: location in NV to receive data + UINT32 size, // IN: size of the data to move + void* inBuffer // IN: location containing data to write +); + +//*** NvUpdatePersistent() +// This function is used to update a value in the PERSISTENT_DATA structure and +// commits the value to NV. +void NvUpdatePersistent( + UINT32 offset, // IN: location in PERMANENT_DATA to be updated + UINT32 size, // IN: size of the value + void* buffer // IN: the new data +); + +//*** NvClearPersistent() +// This function is used to clear a persistent data entry and commit it to NV +void NvClearPersistent(UINT32 offset, // IN: the offset in the PERMANENT_DATA + // structure to be cleared (zeroed) + UINT32 size // IN: number of bytes to clear +); + +//*** NvReadPersistent() +// This function reads persistent data to the RAM copy of the 'gp' structure. +void NvReadPersistent(void); + +#endif // _NV_RESERVED_FP_H_ diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/ObjectChangeAuth_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/ObjectChangeAuth_fp.h new file mode 100644 index 000000000..3953a3826 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/ObjectChangeAuth_fp.h @@ -0,0 +1,35 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_ObjectChangeAuth // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_OBJECTCHANGEAUTH_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_OBJECTCHANGEAUTH_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_DH_OBJECT objectHandle; + TPMI_DH_OBJECT parentHandle; + TPM2B_AUTH newAuth; +} ObjectChangeAuth_In; + +// Output structure definition +typedef struct +{ + TPM2B_PRIVATE outPrivate; +} ObjectChangeAuth_Out; + +// Response code modifiers +# define RC_ObjectChangeAuth_objectHandle (TPM_RC_H + TPM_RC_1) +# define RC_ObjectChangeAuth_parentHandle (TPM_RC_H + TPM_RC_2) +# define RC_ObjectChangeAuth_newAuth (TPM_RC_P + TPM_RC_1) + +// Function prototype +TPM_RC +TPM2_ObjectChangeAuth(ObjectChangeAuth_In* in, ObjectChangeAuth_Out* out); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_OBJECTCHANGEAUTH_FP_H_ +#endif // CC_ObjectChangeAuth diff --git a/src/tpm2/Object_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/Object_fp.h similarity index 77% rename from src/tpm2/Object_fp.h rename to src/tpm2/TPMCmd/tpm/include/private/prototypes/Object_fp.h index 52990cf5c..e29375183 100644 --- a/src/tpm2/Object_fp.h +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/Object_fp.h @@ -1,62 +1,4 @@ -/********************************************************************************/ -/* */ -/* Functions That Manage the Object Store of the TPM */ -/* 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 /*(Auto-generated) * Created by TpmPrototypes; Version 3.0 July 18, 2017 @@ -247,7 +189,7 @@ ObjectContextLoadLibtpms(BYTE *buffer, // IN: buffer holding the // This function frees an object slot. // // This function requires that the object is loaded. -void FlushObject(TPMI_DH_OBJECT handle // IN: handle to be freed +BOOL FlushObject(TPMI_DH_OBJECT handle // IN: handle to be freed ); //*** ObjectFlushHierarchy() diff --git a/src/tpm2/Object_spt_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/Object_spt_fp.h similarity index 81% rename from src/tpm2/Object_spt_fp.h rename to src/tpm2/TPMCmd/tpm/include/private/prototypes/Object_spt_fp.h index 780d2c739..bafbde9d1 100644 --- a/src/tpm2/Object_spt_fp.h +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/Object_spt_fp.h @@ -1,62 +1,4 @@ -/********************************************************************************/ -/* */ -/* Object Command Support */ -/* 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 /*(Auto-generated) * Created by TpmPrototypes; Version 3.0 July 18, 2017 @@ -154,7 +96,7 @@ PublicAttributesValidation( //*** FillInCreationData() // Fill in creation data for an object. // Return Type: void -void FillInCreationData( +TPM_RC FillInCreationData( TPMI_DH_OBJECT parentHandle, // IN: handle of parent TPMI_ALG_HASH nameHashAlg, // IN: name hash algorithm TPML_PCR_SELECTION* creationPCR, // IN: PCR selection @@ -232,7 +174,7 @@ UnwrapOuter(OBJECT* protector, // IN: The object that provides // a) marshals TPM2B_SENSITIVE structure into the buffer of TPM2B_PRIVATE // b) applies encryption to the sensitive area; and // c) applies outer integrity computation. -void SensitiveToPrivate( +TPM_RC SensitiveToPrivate( TPMT_SENSITIVE* sensitive, // IN: sensitive structure TPM2B_NAME* name, // IN: the name of the object OBJECT* parent, // IN: The parent object @@ -278,7 +220,7 @@ PrivateToSensitive(TPM2B* inPrivate, // IN: input private structure // a) marshals TPMT_SENSITIVE structure into the buffer of TPM2B_PRIVATE; // b) applies inner wrap to the sensitive area if required; and // c) applies outer wrap if required. -void SensitiveToDuplicate( +TPM_RC SensitiveToDuplicate( TPMT_SENSITIVE* sensitive, // IN: sensitive structure TPM2B* name, // IN: the name of the object OBJECT* parent, // IN: The new parent object @@ -338,11 +280,11 @@ DuplicateToSensitive( // b) encrypts the private buffer, excluding the leading integrity HMAC area; // c) computes integrity HMAC and append to the beginning of the buffer; and // d) sets the total size of TPM2B_ID_OBJECT buffer. -void SecretToCredential(TPM2B_DIGEST* secret, // IN: secret information - TPM2B* name, // IN: the name of the object - TPM2B* seed, // IN: an external seed. - OBJECT* protector, // IN: the protector - TPM2B_ID_OBJECT* outIDObject // OUT: output credential +TPM_RC SecretToCredential(TPM2B_DIGEST* secret, // IN: secret information + TPM2B* name, // IN: the name of the object + TPM2B* seed, // IN: an external seed. + OBJECT* protector, // IN: the protector + TPM2B_ID_OBJECT* outIDObject // OUT: output credential ); //*** CredentialToSecret() diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/PCR_Allocate_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/PCR_Allocate_fp.h new file mode 100644 index 000000000..d66978f18 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/PCR_Allocate_fp.h @@ -0,0 +1,36 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_PCR_Allocate // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_PCR_ALLOCATE_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_PCR_ALLOCATE_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_RH_PLATFORM authHandle; + TPML_PCR_SELECTION pcrAllocation; +} PCR_Allocate_In; + +// Output structure definition +typedef struct +{ + TPMI_YES_NO allocationSuccess; + UINT32 maxPCR; + UINT32 sizeNeeded; + UINT32 sizeAvailable; +} PCR_Allocate_Out; + +// Response code modifiers +# define RC_PCR_Allocate_authHandle (TPM_RC_H + TPM_RC_1) +# define RC_PCR_Allocate_pcrAllocation (TPM_RC_P + TPM_RC_1) + +// Function prototype +TPM_RC +TPM2_PCR_Allocate(PCR_Allocate_In* in, PCR_Allocate_Out* out); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_PCR_ALLOCATE_FP_H_ +#endif // CC_PCR_Allocate diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/PCR_Event_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/PCR_Event_fp.h new file mode 100644 index 000000000..89b877ec9 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/PCR_Event_fp.h @@ -0,0 +1,33 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_PCR_Event // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_PCR_EVENT_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_PCR_EVENT_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_DH_PCR pcrHandle; + TPM2B_EVENT eventData; +} PCR_Event_In; + +// Output structure definition +typedef struct +{ + TPML_DIGEST_VALUES digests; +} PCR_Event_Out; + +// Response code modifiers +# define RC_PCR_Event_pcrHandle (TPM_RC_H + TPM_RC_1) +# define RC_PCR_Event_eventData (TPM_RC_P + TPM_RC_1) + +// Function prototype +TPM_RC +TPM2_PCR_Event(PCR_Event_In* in, PCR_Event_Out* out); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_PCR_EVENT_FP_H_ +#endif // CC_PCR_Event diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/PCR_Extend_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/PCR_Extend_fp.h new file mode 100644 index 000000000..2799ab672 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/PCR_Extend_fp.h @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_PCR_Extend // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_PCR_EXTEND_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_PCR_EXTEND_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_DH_PCR pcrHandle; + TPML_DIGEST_VALUES digests; +} PCR_Extend_In; + +// Response code modifiers +# define RC_PCR_Extend_pcrHandle (TPM_RC_H + TPM_RC_1) +# define RC_PCR_Extend_digests (TPM_RC_P + TPM_RC_1) + +// Function prototype +TPM_RC +TPM2_PCR_Extend(PCR_Extend_In* in); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_PCR_EXTEND_FP_H_ +#endif // CC_PCR_Extend diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/PCR_Read_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/PCR_Read_fp.h new file mode 100644 index 000000000..fbc1ef898 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/PCR_Read_fp.h @@ -0,0 +1,33 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_PCR_Read // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_PCR_READ_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_PCR_READ_FP_H_ + +// Input structure definition +typedef struct +{ + TPML_PCR_SELECTION pcrSelectionIn; +} PCR_Read_In; + +// Output structure definition +typedef struct +{ + UINT32 pcrUpdateCounter; + TPML_PCR_SELECTION pcrSelectionOut; + TPML_DIGEST pcrValues; +} PCR_Read_Out; + +// Response code modifiers +# define RC_PCR_Read_pcrSelectionIn (TPM_RC_P + TPM_RC_1) + +// Function prototype +TPM_RC +TPM2_PCR_Read(PCR_Read_In* in, PCR_Read_Out* out); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_PCR_READ_FP_H_ +#endif // CC_PCR_Read diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/PCR_Reset_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/PCR_Reset_fp.h new file mode 100644 index 000000000..55cb9621a --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/PCR_Reset_fp.h @@ -0,0 +1,25 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_PCR_Reset // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_PCR_RESET_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_PCR_RESET_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_DH_PCR pcrHandle; +} PCR_Reset_In; + +// Response code modifiers +# define RC_PCR_Reset_pcrHandle (TPM_RC_H + TPM_RC_1) + +// Function prototype +TPM_RC +TPM2_PCR_Reset(PCR_Reset_In* in); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_PCR_RESET_FP_H_ +#endif // CC_PCR_Reset diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/PCR_SetAuthPolicy_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/PCR_SetAuthPolicy_fp.h new file mode 100644 index 000000000..cae53b885 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/PCR_SetAuthPolicy_fp.h @@ -0,0 +1,31 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_PCR_SetAuthPolicy // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_PCR_SETAUTHPOLICY_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_PCR_SETAUTHPOLICY_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_RH_PLATFORM authHandle; + TPM2B_DIGEST authPolicy; + TPMI_ALG_HASH hashAlg; + TPMI_DH_PCR pcrNum; +} PCR_SetAuthPolicy_In; + +// Response code modifiers +# define RC_PCR_SetAuthPolicy_authHandle (TPM_RC_H + TPM_RC_1) +# define RC_PCR_SetAuthPolicy_authPolicy (TPM_RC_P + TPM_RC_1) +# define RC_PCR_SetAuthPolicy_hashAlg (TPM_RC_P + TPM_RC_2) +# define RC_PCR_SetAuthPolicy_pcrNum (TPM_RC_P + TPM_RC_3) + +// Function prototype +TPM_RC +TPM2_PCR_SetAuthPolicy(PCR_SetAuthPolicy_In* in); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_PCR_SETAUTHPOLICY_FP_H_ +#endif // CC_PCR_SetAuthPolicy diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/PCR_SetAuthValue_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/PCR_SetAuthValue_fp.h new file mode 100644 index 000000000..3cfc9df13 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/PCR_SetAuthValue_fp.h @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_PCR_SetAuthValue // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_PCR_SETAUTHVALUE_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_PCR_SETAUTHVALUE_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_DH_PCR pcrHandle; + TPM2B_DIGEST auth; +} PCR_SetAuthValue_In; + +// Response code modifiers +# define RC_PCR_SetAuthValue_pcrHandle (TPM_RC_H + TPM_RC_1) +# define RC_PCR_SetAuthValue_auth (TPM_RC_P + TPM_RC_1) + +// Function prototype +TPM_RC +TPM2_PCR_SetAuthValue(PCR_SetAuthValue_In* in); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_PCR_SETAUTHVALUE_FP_H_ +#endif // CC_PCR_SetAuthValue diff --git a/src/tpm2/PCR_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/PCR_fp.h similarity index 72% rename from src/tpm2/PCR_fp.h rename to src/tpm2/TPMCmd/tpm/include/private/prototypes/PCR_fp.h index f1d853b23..90bf463b9 100644 --- a/src/tpm2/PCR_fp.h +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/PCR_fp.h @@ -1,62 +1,4 @@ -/********************************************************************************/ -/* */ -/* Functions Needed for 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 /*(Auto-generated) * Created by TpmPrototypes; Version 3.0 July 18, 2017 @@ -213,7 +155,7 @@ void PCRExtend(TPMI_DH_PCR handle, // IN: PCR handle to be extended // // As a side-effect, 'selection' is modified so that only the implemented PCR // will have their bits still set. -void PCRComputeCurrentDigest( +TPM_RC PCRComputeCurrentDigest( TPMI_ALG_HASH hashAlg, // IN: hash algorithm to compute digest TPML_PCR_SELECTION* selection, // IN/OUT: PCR selection (filtered on // output) @@ -224,11 +166,11 @@ void PCRComputeCurrentDigest( // This function is used to read a list of selected PCR. If the requested PCR // number exceeds the maximum number that can be output, the 'selection' is // adjusted to reflect the actual output PCR. -void PCRRead(TPML_PCR_SELECTION* selection, // IN/OUT: PCR selection (filtered on - // output) - TPML_DIGEST* digest, // OUT: digest - UINT32* pcrCounter // OUT: the current value of PCR generation - // number +TPM_RC PCRRead(TPML_PCR_SELECTION* selection, // IN/OUT: PCR selection (filtered on + // output) + TPML_DIGEST* digest, // OUT: digest + UINT32* pcrCounter // OUT: the current value of PCR generation + // number ); //*** PCRAllocate() diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/PP_Commands_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/PP_Commands_fp.h new file mode 100644 index 000000000..b75f8f77b --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/PP_Commands_fp.h @@ -0,0 +1,29 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_PP_Commands // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_PP_COMMANDS_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_PP_COMMANDS_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_RH_PLATFORM auth; + TPML_CC setList; + TPML_CC clearList; +} PP_Commands_In; + +// Response code modifiers +# define RC_PP_Commands_auth (TPM_RC_H + TPM_RC_1) +# define RC_PP_Commands_setList (TPM_RC_P + TPM_RC_1) +# define RC_PP_Commands_clearList (TPM_RC_P + TPM_RC_2) + +// Function prototype +TPM_RC +TPM2_PP_Commands(PP_Commands_In* in); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_PP_COMMANDS_FP_H_ +#endif // CC_PP_Commands diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/PP_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/PP_fp.h new file mode 100644 index 000000000..5a9cb9581 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/PP_fp.h @@ -0,0 +1,61 @@ +// SPDX-License-Identifier: BSD-2-Clause + +/*(Auto-generated) + * Created by TpmPrototypes; Version 3.0 July 18, 2017 + * Date: Mar 28, 2019 Time: 08:25:19PM + */ + +#ifndef _PP_FP_H_ +#define _PP_FP_H_ + +//*** PhysicalPresencePreInstall_Init() +// This function is used to initialize the array of commands that always require +// confirmation with physical presence. The array is an array of bits that +// has a correspondence with the command code. +// +// This command should only ever be executable in a manufacturing setting or in +// a simulation. +// +// When set, these cannot be cleared. +// +void PhysicalPresencePreInstall_Init(void); + +//*** PhysicalPresenceCommandSet() +// This function is used to set the indicator that a command requires +// PP confirmation. +void PhysicalPresenceCommandSet(TPM_CC commandCode // IN: command code +); + +//*** PhysicalPresenceCommandClear() +// This function is used to clear the indicator that a command requires PP +// confirmation. +void PhysicalPresenceCommandClear(TPM_CC commandCode // IN: command code +); + +//*** PhysicalPresenceIsRequired() +// This function indicates if PP confirmation is required for a command. +// Return Type: BOOL +// TRUE(1) physical presence is required +// FALSE(0) physical presence is not required +BOOL PhysicalPresenceIsRequired(COMMAND_INDEX commandIndex // IN: command index +); + +//*** PhysicalPresenceCapGetCCList() +// This function returns a list of commands that require PP confirmation. The +// list starts from the first implemented command that has a command code that +// the same or greater than 'commandCode'. +// Return Type: TPMI_YES_NO +// YES if there are more command codes available +// NO all the available command codes have been returned +TPMI_YES_NO +PhysicalPresenceCapGetCCList(TPM_CC commandCode, // IN: start command code + UINT32 count, // IN: count of returned TPM_CC + TPML_CC* commandList // OUT: list of TPM_CC +); + +//*** PhysicalPresenceCapGetOneCC() +// This function returns true if the command requires Physical Presence. +BOOL PhysicalPresenceCapGetOneCC(TPM_CC commandCode // IN: command code +); + +#endif // _PP_FP_H_ diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/PolicyAuthValue_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/PolicyAuthValue_fp.h new file mode 100644 index 000000000..6864a112c --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/PolicyAuthValue_fp.h @@ -0,0 +1,25 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_PolicyAuthValue // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYAUTHVALUE_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYAUTHVALUE_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_SH_POLICY policySession; +} PolicyAuthValue_In; + +// Response code modifiers +# define RC_PolicyAuthValue_policySession (TPM_RC_H + TPM_RC_1) + +// Function prototype +TPM_RC +TPM2_PolicyAuthValue(PolicyAuthValue_In* in); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYAUTHVALUE_FP_H_ +#endif // CC_PolicyAuthValue diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/PolicyAuthorizeNV_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/PolicyAuthorizeNV_fp.h new file mode 100644 index 000000000..31aff24b2 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/PolicyAuthorizeNV_fp.h @@ -0,0 +1,29 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_PolicyAuthorizeNV // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYAUTHORIZENV_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYAUTHORIZENV_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_RH_NV_AUTH authHandle; + TPMI_RH_NV_INDEX nvIndex; + TPMI_SH_POLICY policySession; +} PolicyAuthorizeNV_In; + +// Response code modifiers +# define RC_PolicyAuthorizeNV_authHandle (TPM_RC_H + TPM_RC_1) +# define RC_PolicyAuthorizeNV_nvIndex (TPM_RC_H + TPM_RC_2) +# define RC_PolicyAuthorizeNV_policySession (TPM_RC_H + TPM_RC_3) + +// Function prototype +TPM_RC +TPM2_PolicyAuthorizeNV(PolicyAuthorizeNV_In* in); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYAUTHORIZENV_FP_H_ +#endif // CC_PolicyAuthorizeNV diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/PolicyAuthorize_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/PolicyAuthorize_fp.h new file mode 100644 index 000000000..962266993 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/PolicyAuthorize_fp.h @@ -0,0 +1,33 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_PolicyAuthorize // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYAUTHORIZE_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYAUTHORIZE_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_SH_POLICY policySession; + TPM2B_DIGEST approvedPolicy; + TPM2B_NONCE policyRef; + TPM2B_NAME keySign; + TPMT_TK_VERIFIED checkTicket; +} PolicyAuthorize_In; + +// Response code modifiers +# define RC_PolicyAuthorize_policySession (TPM_RC_H + TPM_RC_1) +# define RC_PolicyAuthorize_approvedPolicy (TPM_RC_P + TPM_RC_1) +# define RC_PolicyAuthorize_policyRef (TPM_RC_P + TPM_RC_2) +# define RC_PolicyAuthorize_keySign (TPM_RC_P + TPM_RC_3) +# define RC_PolicyAuthorize_checkTicket (TPM_RC_P + TPM_RC_4) + +// Function prototype +TPM_RC +TPM2_PolicyAuthorize(PolicyAuthorize_In* in); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYAUTHORIZE_FP_H_ +#endif // CC_PolicyAuthorize diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/PolicyCapability_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/PolicyCapability_fp.h new file mode 100644 index 000000000..bb924bee2 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/PolicyCapability_fp.h @@ -0,0 +1,35 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_PolicyCapability // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYCAPABILITY_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYCAPABILITY_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_SH_POLICY policySession; + TPM2B_OPERAND operandB; + UINT16 offset; + TPM_EO operation; + TPM_CAP capability; + UINT32 property; +} PolicyCapability_In; + +// Response code modifiers +# define RC_PolicyCapability_policySession (TPM_RC_H + TPM_RC_1) +# define RC_PolicyCapability_operandB (TPM_RC_P + TPM_RC_1) +# define RC_PolicyCapability_offset (TPM_RC_P + TPM_RC_2) +# define RC_PolicyCapability_operation (TPM_RC_P + TPM_RC_3) +# define RC_PolicyCapability_capability (TPM_RC_P + TPM_RC_4) +# define RC_PolicyCapability_property (TPM_RC_P + TPM_RC_5) + +// Function prototype +TPM_RC +TPM2_PolicyCapability(PolicyCapability_In* in); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYCAPABILITY_FP_H_ +#endif // CC_PolicyCapability diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/PolicyCommandCode_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/PolicyCommandCode_fp.h new file mode 100644 index 000000000..3c8f1fb6f --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/PolicyCommandCode_fp.h @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_PolicyCommandCode // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYCOMMANDCODE_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYCOMMANDCODE_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_SH_POLICY policySession; + TPM_CC code; +} PolicyCommandCode_In; + +// Response code modifiers +# define RC_PolicyCommandCode_policySession (TPM_RC_H + TPM_RC_1) +# define RC_PolicyCommandCode_code (TPM_RC_P + TPM_RC_1) + +// Function prototype +TPM_RC +TPM2_PolicyCommandCode(PolicyCommandCode_In* in); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYCOMMANDCODE_FP_H_ +#endif // CC_PolicyCommandCode diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/PolicyCounterTimer_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/PolicyCounterTimer_fp.h new file mode 100644 index 000000000..03ab1972e --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/PolicyCounterTimer_fp.h @@ -0,0 +1,31 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_PolicyCounterTimer // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYCOUNTERTIMER_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYCOUNTERTIMER_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_SH_POLICY policySession; + TPM2B_OPERAND operandB; + UINT16 offset; + TPM_EO operation; +} PolicyCounterTimer_In; + +// Response code modifiers +# define RC_PolicyCounterTimer_policySession (TPM_RC_H + TPM_RC_1) +# define RC_PolicyCounterTimer_operandB (TPM_RC_P + TPM_RC_1) +# define RC_PolicyCounterTimer_offset (TPM_RC_P + TPM_RC_2) +# define RC_PolicyCounterTimer_operation (TPM_RC_P + TPM_RC_3) + +// Function prototype +TPM_RC +TPM2_PolicyCounterTimer(PolicyCounterTimer_In* in); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYCOUNTERTIMER_FP_H_ +#endif // CC_PolicyCounterTimer diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/PolicyCpHash_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/PolicyCpHash_fp.h new file mode 100644 index 000000000..e8e2d93f7 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/PolicyCpHash_fp.h @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_PolicyCpHash // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYCPHASH_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYCPHASH_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_SH_POLICY policySession; + TPM2B_DIGEST cpHashA; +} PolicyCpHash_In; + +// Response code modifiers +# define RC_PolicyCpHash_policySession (TPM_RC_H + TPM_RC_1) +# define RC_PolicyCpHash_cpHashA (TPM_RC_P + TPM_RC_1) + +// Function prototype +TPM_RC +TPM2_PolicyCpHash(PolicyCpHash_In* in); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYCPHASH_FP_H_ +#endif // CC_PolicyCpHash diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/PolicyDuplicationSelect_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/PolicyDuplicationSelect_fp.h new file mode 100644 index 000000000..ffad1b384 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/PolicyDuplicationSelect_fp.h @@ -0,0 +1,31 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_PolicyDuplicationSelect // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYDUPLICATIONSELECT_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYDUPLICATIONSELECT_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_SH_POLICY policySession; + TPM2B_NAME objectName; + TPM2B_NAME newParentName; + TPMI_YES_NO includeObject; +} PolicyDuplicationSelect_In; + +// Response code modifiers +# define RC_PolicyDuplicationSelect_policySession (TPM_RC_H + TPM_RC_1) +# define RC_PolicyDuplicationSelect_objectName (TPM_RC_P + TPM_RC_1) +# define RC_PolicyDuplicationSelect_newParentName (TPM_RC_P + TPM_RC_2) +# define RC_PolicyDuplicationSelect_includeObject (TPM_RC_P + TPM_RC_3) + +// Function prototype +TPM_RC +TPM2_PolicyDuplicationSelect(PolicyDuplicationSelect_In* in); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYDUPLICATIONSELECT_FP_H_ +#endif // CC_PolicyDuplicationSelect diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/PolicyGetDigest_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/PolicyGetDigest_fp.h new file mode 100644 index 000000000..ba2852e28 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/PolicyGetDigest_fp.h @@ -0,0 +1,31 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_PolicyGetDigest // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYGETDIGEST_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYGETDIGEST_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_SH_POLICY policySession; +} PolicyGetDigest_In; + +// Output structure definition +typedef struct +{ + TPM2B_DIGEST policyDigest; +} PolicyGetDigest_Out; + +// Response code modifiers +# define RC_PolicyGetDigest_policySession (TPM_RC_H + TPM_RC_1) + +// Function prototype +TPM_RC +TPM2_PolicyGetDigest(PolicyGetDigest_In* in, PolicyGetDigest_Out* out); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYGETDIGEST_FP_H_ +#endif // CC_PolicyGetDigest diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/PolicyLocality_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/PolicyLocality_fp.h new file mode 100644 index 000000000..bece261e1 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/PolicyLocality_fp.h @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_PolicyLocality // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYLOCALITY_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYLOCALITY_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_SH_POLICY policySession; + TPMA_LOCALITY locality; +} PolicyLocality_In; + +// Response code modifiers +# define RC_PolicyLocality_policySession (TPM_RC_H + TPM_RC_1) +# define RC_PolicyLocality_locality (TPM_RC_P + TPM_RC_1) + +// Function prototype +TPM_RC +TPM2_PolicyLocality(PolicyLocality_In* in); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYLOCALITY_FP_H_ +#endif // CC_PolicyLocality diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/PolicyNV_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/PolicyNV_fp.h new file mode 100644 index 000000000..9b52a7184 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/PolicyNV_fp.h @@ -0,0 +1,35 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_PolicyNV // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYNV_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYNV_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_RH_NV_AUTH authHandle; + TPMI_RH_NV_INDEX nvIndex; + TPMI_SH_POLICY policySession; + TPM2B_OPERAND operandB; + UINT16 offset; + TPM_EO operation; +} PolicyNV_In; + +// Response code modifiers +# define RC_PolicyNV_authHandle (TPM_RC_H + TPM_RC_1) +# define RC_PolicyNV_nvIndex (TPM_RC_H + TPM_RC_2) +# define RC_PolicyNV_policySession (TPM_RC_H + TPM_RC_3) +# define RC_PolicyNV_operandB (TPM_RC_P + TPM_RC_1) +# define RC_PolicyNV_offset (TPM_RC_P + TPM_RC_2) +# define RC_PolicyNV_operation (TPM_RC_P + TPM_RC_3) + +// Function prototype +TPM_RC +TPM2_PolicyNV(PolicyNV_In* in); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYNV_FP_H_ +#endif // CC_PolicyNV diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/PolicyNameHash_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/PolicyNameHash_fp.h new file mode 100644 index 000000000..4fda016b7 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/PolicyNameHash_fp.h @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_PolicyNameHash // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYNAMEHASH_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYNAMEHASH_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_SH_POLICY policySession; + TPM2B_DIGEST nameHash; +} PolicyNameHash_In; + +// Response code modifiers +# define RC_PolicyNameHash_policySession (TPM_RC_H + TPM_RC_1) +# define RC_PolicyNameHash_nameHash (TPM_RC_P + TPM_RC_1) + +// Function prototype +TPM_RC +TPM2_PolicyNameHash(PolicyNameHash_In* in); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYNAMEHASH_FP_H_ +#endif // CC_PolicyNameHash diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/PolicyNvWritten_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/PolicyNvWritten_fp.h new file mode 100644 index 000000000..4905de165 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/PolicyNvWritten_fp.h @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_PolicyNvWritten // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYNVWRITTEN_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYNVWRITTEN_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_SH_POLICY policySession; + TPMI_YES_NO writtenSet; +} PolicyNvWritten_In; + +// Response code modifiers +# define RC_PolicyNvWritten_policySession (TPM_RC_H + TPM_RC_1) +# define RC_PolicyNvWritten_writtenSet (TPM_RC_P + TPM_RC_1) + +// Function prototype +TPM_RC +TPM2_PolicyNvWritten(PolicyNvWritten_In* in); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYNVWRITTEN_FP_H_ +#endif // CC_PolicyNvWritten diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/PolicyOR_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/PolicyOR_fp.h new file mode 100644 index 000000000..d470477c0 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/PolicyOR_fp.h @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_PolicyOR // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYOR_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYOR_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_SH_POLICY policySession; + TPML_DIGEST pHashList; +} PolicyOR_In; + +// Response code modifiers +# define RC_PolicyOR_policySession (TPM_RC_H + TPM_RC_1) +# define RC_PolicyOR_pHashList (TPM_RC_P + TPM_RC_1) + +// Function prototype +TPM_RC +TPM2_PolicyOR(PolicyOR_In* in); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYOR_FP_H_ +#endif // CC_PolicyOR diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/PolicyPCR_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/PolicyPCR_fp.h new file mode 100644 index 000000000..e19d03c9f --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/PolicyPCR_fp.h @@ -0,0 +1,29 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_PolicyPCR // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYPCR_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYPCR_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_SH_POLICY policySession; + TPM2B_DIGEST pcrDigest; + TPML_PCR_SELECTION pcrs; +} PolicyPCR_In; + +// Response code modifiers +# define RC_PolicyPCR_policySession (TPM_RC_H + TPM_RC_1) +# define RC_PolicyPCR_pcrDigest (TPM_RC_P + TPM_RC_1) +# define RC_PolicyPCR_pcrs (TPM_RC_P + TPM_RC_2) + +// Function prototype +TPM_RC +TPM2_PolicyPCR(PolicyPCR_In* in); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYPCR_FP_H_ +#endif // CC_PolicyPCR diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/PolicyParameters_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/PolicyParameters_fp.h new file mode 100644 index 000000000..32f1acb7f --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/PolicyParameters_fp.h @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_PolicyParameters // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYPARAMETERS_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYPARAMETERS_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_SH_POLICY policySession; + TPM2B_DIGEST pHash; +} PolicyParameters_In; + +// Response code modifiers +# define RC_PolicyParameters_policySession (TPM_RC_H + TPM_RC_1) +# define RC_PolicyParameters_pHash (TPM_RC_P + TPM_RC_1) + +// Function prototype +TPM_RC +TPM2_PolicyParameters(PolicyParameters_In* in); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYPARAMETERS_FP_H_ +#endif // CC_PolicyParameters diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/PolicyPassword_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/PolicyPassword_fp.h new file mode 100644 index 000000000..d47c6a286 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/PolicyPassword_fp.h @@ -0,0 +1,25 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_PolicyPassword // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYPASSWORD_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYPASSWORD_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_SH_POLICY policySession; +} PolicyPassword_In; + +// Response code modifiers +# define RC_PolicyPassword_policySession (TPM_RC_H + TPM_RC_1) + +// Function prototype +TPM_RC +TPM2_PolicyPassword(PolicyPassword_In* in); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYPASSWORD_FP_H_ +#endif // CC_PolicyPassword diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/PolicyPhysicalPresence_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/PolicyPhysicalPresence_fp.h new file mode 100644 index 000000000..d09e69ae9 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/PolicyPhysicalPresence_fp.h @@ -0,0 +1,25 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_PolicyPhysicalPresence // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYPHYSICALPRESENCE_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYPHYSICALPRESENCE_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_SH_POLICY policySession; +} PolicyPhysicalPresence_In; + +// Response code modifiers +# define RC_PolicyPhysicalPresence_policySession (TPM_RC_H + TPM_RC_1) + +// Function prototype +TPM_RC +TPM2_PolicyPhysicalPresence(PolicyPhysicalPresence_In* in); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYPHYSICALPRESENCE_FP_H_ +#endif // CC_PolicyPhysicalPresence diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/PolicyRestart_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/PolicyRestart_fp.h new file mode 100644 index 000000000..ccabc183e --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/PolicyRestart_fp.h @@ -0,0 +1,25 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_PolicyRestart // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYRESTART_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYRESTART_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_SH_POLICY sessionHandle; +} PolicyRestart_In; + +// Response code modifiers +# define RC_PolicyRestart_sessionHandle (TPM_RC_H + TPM_RC_1) + +// Function prototype +TPM_RC +TPM2_PolicyRestart(PolicyRestart_In* in); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYRESTART_FP_H_ +#endif // CC_PolicyRestart diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/PolicySecret_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/PolicySecret_fp.h new file mode 100644 index 000000000..113628597 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/PolicySecret_fp.h @@ -0,0 +1,42 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_PolicySecret // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYSECRET_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYSECRET_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_DH_ENTITY authHandle; + TPMI_SH_POLICY policySession; + TPM2B_NONCE nonceTPM; + TPM2B_DIGEST cpHashA; + TPM2B_NONCE policyRef; + INT32 expiration; +} PolicySecret_In; + +// Output structure definition +typedef struct +{ + TPM2B_TIMEOUT timeout; + TPMT_TK_AUTH policyTicket; +} PolicySecret_Out; + +// Response code modifiers +# define RC_PolicySecret_authHandle (TPM_RC_H + TPM_RC_1) +# define RC_PolicySecret_policySession (TPM_RC_H + TPM_RC_2) +# define RC_PolicySecret_nonceTPM (TPM_RC_P + TPM_RC_1) +# define RC_PolicySecret_cpHashA (TPM_RC_P + TPM_RC_2) +# define RC_PolicySecret_policyRef (TPM_RC_P + TPM_RC_3) +# define RC_PolicySecret_expiration (TPM_RC_P + TPM_RC_4) + +// Function prototype +TPM_RC +TPM2_PolicySecret(PolicySecret_In* in, PolicySecret_Out* out); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYSECRET_FP_H_ +#endif // CC_PolicySecret diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/PolicySigned_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/PolicySigned_fp.h new file mode 100644 index 000000000..e7c251637 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/PolicySigned_fp.h @@ -0,0 +1,44 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_PolicySigned // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYSIGNED_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYSIGNED_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_DH_OBJECT authObject; + TPMI_SH_POLICY policySession; + TPM2B_NONCE nonceTPM; + TPM2B_DIGEST cpHashA; + TPM2B_NONCE policyRef; + INT32 expiration; + TPMT_SIGNATURE auth; +} PolicySigned_In; + +// Output structure definition +typedef struct +{ + TPM2B_TIMEOUT timeout; + TPMT_TK_AUTH policyTicket; +} PolicySigned_Out; + +// Response code modifiers +# define RC_PolicySigned_authObject (TPM_RC_H + TPM_RC_1) +# define RC_PolicySigned_policySession (TPM_RC_H + TPM_RC_2) +# define RC_PolicySigned_nonceTPM (TPM_RC_P + TPM_RC_1) +# define RC_PolicySigned_cpHashA (TPM_RC_P + TPM_RC_2) +# define RC_PolicySigned_policyRef (TPM_RC_P + TPM_RC_3) +# define RC_PolicySigned_expiration (TPM_RC_P + TPM_RC_4) +# define RC_PolicySigned_auth (TPM_RC_P + TPM_RC_5) + +// Function prototype +TPM_RC +TPM2_PolicySigned(PolicySigned_In* in, PolicySigned_Out* out); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYSIGNED_FP_H_ +#endif // CC_PolicySigned diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/PolicyTemplate_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/PolicyTemplate_fp.h new file mode 100644 index 000000000..9cee56046 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/PolicyTemplate_fp.h @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_PolicyTemplate // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYTEMPLATE_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYTEMPLATE_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_SH_POLICY policySession; + TPM2B_DIGEST templateHash; +} PolicyTemplate_In; + +// Response code modifiers +# define RC_PolicyTemplate_policySession (TPM_RC_H + TPM_RC_1) +# define RC_PolicyTemplate_templateHash (TPM_RC_P + TPM_RC_1) + +// Function prototype +TPM_RC +TPM2_PolicyTemplate(PolicyTemplate_In* in); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYTEMPLATE_FP_H_ +#endif // CC_PolicyTemplate diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/PolicyTicket_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/PolicyTicket_fp.h new file mode 100644 index 000000000..dcbb83fdd --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/PolicyTicket_fp.h @@ -0,0 +1,35 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_PolicyTicket // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYTICKET_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYTICKET_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_SH_POLICY policySession; + TPM2B_TIMEOUT timeout; + TPM2B_DIGEST cpHashA; + TPM2B_NONCE policyRef; + TPM2B_NAME authName; + TPMT_TK_AUTH ticket; +} PolicyTicket_In; + +// Response code modifiers +# define RC_PolicyTicket_policySession (TPM_RC_H + TPM_RC_1) +# define RC_PolicyTicket_timeout (TPM_RC_P + TPM_RC_1) +# define RC_PolicyTicket_cpHashA (TPM_RC_P + TPM_RC_2) +# define RC_PolicyTicket_policyRef (TPM_RC_P + TPM_RC_3) +# define RC_PolicyTicket_authName (TPM_RC_P + TPM_RC_4) +# define RC_PolicyTicket_ticket (TPM_RC_P + TPM_RC_5) + +// Function prototype +TPM_RC +TPM2_PolicyTicket(PolicyTicket_In* in); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYTICKET_FP_H_ +#endif // CC_PolicyTicket diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/PolicyTransportSPDM_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/PolicyTransportSPDM_fp.h new file mode 100644 index 000000000..91f0d459a --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/PolicyTransportSPDM_fp.h @@ -0,0 +1,26 @@ +// SPDX-License-Identifier: BSD-2-Clause + +#if CC_PolicyTransportSPDM // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYTRANSPORTSPDM_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYTRANSPORTSPDM_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_SH_POLICY policySession; + TPM2B_NAME reqKeyName; + TPM2B_NAME tpmKeyName; +} PolicyTransportSPDM_In; + +// Response code modifiers +# define RC_PolicyTransportSPDM_policySession (TPM_RC_H + TPM_RC_1) +# define RC_PolicyTransportSPDM_reqKeyName (TPM_RC_P + TPM_RC_1) +# define RC_PolicyTransportSPDM_tpmKeyName (TPM_RC_P + TPM_RC_2) + +// Function prototype +TPM_RC +TPM2_PolicyTransportSPDM(PolicyTransportSPDM_In* in); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_POLICYTRANSPORTSPDM_FP_H_ +#endif // CC_PolicyTransportSPDM diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/Policy_spt_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/Policy_spt_fp.h new file mode 100644 index 000000000..62bc6d530 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/Policy_spt_fp.h @@ -0,0 +1,60 @@ +// SPDX-License-Identifier: BSD-2-Clause + +/*(Auto-generated) + * Created by TpmPrototypes; Version 3.0 July 18, 2017 + * Date: Mar 4, 2020 Time: 02:36:44PM + */ + +#ifndef _POLICY_SPT_FP_H_ +#define _POLICY_SPT_FP_H_ + +//** Functions +//*** PolicyParameterChecks() +// This function validates the common parameters of TPM2_PolicySiged() +// and TPM2_PolicySecret(). The common parameters are 'nonceTPM', +// 'expiration', and 'cpHashA'. +TPM_RC +PolicyParameterChecks(SESSION* session, + UINT64 authTimeout, + TPM2B_DIGEST* cpHashA, + TPM2B_NONCE* nonce, + TPM_RC blameNonce, + TPM_RC blameCpHash, + TPM_RC blameExpiration); + +//*** PolicyContextUpdate() +// Update policy hash +// Update the policyDigest in policy session by extending policyRef and +// objectName to it. This will also update the cpHash if it is present. +// +// Return Type: void +TPM_RC PolicyContextUpdate( + TPM_CC commandCode, // IN: command code + TPM2B_NAME* name, // IN: name of entity + TPM2B_NONCE* ref, // IN: the reference data + TPM2B_DIGEST* cpHash, // IN: the cpHash (optional) + UINT64 policyTimeout, // IN: the timeout value for the policy + SESSION* session // IN/OUT: policy session to be updated +); + +//*** ComputeAuthTimeout() +// This function is used to determine what the authorization timeout value for +// the session should be. +UINT64 +ComputeAuthTimeout(SESSION* session, // IN: the session containing the time + // values + INT32 expiration, // IN: either the number of seconds from + // the start of the session or the + // time in g_timer; + TPM2B_NONCE* nonce // IN: indicator of the time base +); + +//*** PolicyDigestClear() +// Function to reset the policyDigest of a session +void PolicyDigestClear(SESSION* session); + +//*** PolicySptCheckCondition() +// Checks to see if the condition in the policy is satisfied. +BOOL PolicySptCheckCondition(TPM_EO operation, BYTE* opA, BYTE* opB, UINT16 size); + +#endif // _POLICY_SPT_FP_H_ diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/Power_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/Power_fp.h new file mode 100644 index 000000000..acbaa1465 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/Power_fp.h @@ -0,0 +1,28 @@ +// SPDX-License-Identifier: BSD-2-Clause + +/*(Auto-generated) + * Created by TpmPrototypes; Version 3.0 July 18, 2017 + * Date: Apr 2, 2019 Time: 11:00:49AM + */ + +#ifndef _POWER_FP_H_ +#define _POWER_FP_H_ + +//*** TPMInit() +// This function is used to process a power on event. +void TPMInit(void); + +//*** TPMRegisterStartup() +// This function registers the fact that the TPM has been initialized +// (a TPM2_Startup() has completed successfully). +BOOL TPMRegisterStartup(void); + +//*** TPMIsStarted() +// Indicates if the TPM has been initialized (a TPM2_Startup() has completed +// successfully after a _TPM_Init). +// Return Type: BOOL +// TRUE(1) TPM has been initialized +// FALSE(0) TPM has not been initialized +BOOL TPMIsStarted(void); + +#endif // _POWER_FP_H_ diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/PropertyCap_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/PropertyCap_fp.h new file mode 100644 index 000000000..bb32c935b --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/PropertyCap_fp.h @@ -0,0 +1,32 @@ +// SPDX-License-Identifier: BSD-2-Clause + +/*(Auto-generated) + * Created by TpmPrototypes; Version 3.0 July 18, 2017 + * Date: Mar 28, 2019 Time: 08:25:19PM + */ + +#ifndef _PROPERTY_CAP_FP_H_ +#define _PROPERTY_CAP_FP_H_ + +//*** TPMCapGetProperties() +// This function is used to get the TPM_PT values. The search of properties will +// start at 'property' and continue until 'propertyList' has as many values as +// will fit, or the last property has been reported, or the list has as many +// values as requested in 'count'. +// Return Type: TPMI_YES_NO +// YES more properties are available +// NO no more properties to be reported +TPMI_YES_NO +TPMCapGetProperties(TPM_PT property, // IN: the starting TPM property + UINT32 count, // IN: maximum number of returned + // properties + TPML_TAGGED_TPM_PROPERTY* propertyList // OUT: property list +); + +//*** TPMCapGetOneProperty() +// This function returns a single TPM property, if present. +BOOL TPMCapGetOneProperty(TPM_PT pt, // IN: the TPM property + TPMS_TAGGED_PROPERTY* property // OUT: tagged property +); + +#endif // _PROPERTY_CAP_FP_H_ diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/Quote_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/Quote_fp.h new file mode 100644 index 000000000..bf63c8132 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/Quote_fp.h @@ -0,0 +1,38 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_Quote // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_QUOTE_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_QUOTE_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_DH_OBJECT signHandle; + TPM2B_DATA qualifyingData; + TPMT_SIG_SCHEME inScheme; + TPML_PCR_SELECTION PCRselect; +} Quote_In; + +// Output structure definition +typedef struct +{ + TPM2B_ATTEST quoted; + TPMT_SIGNATURE signature; +} Quote_Out; + +// Response code modifiers +# define RC_Quote_signHandle (TPM_RC_H + TPM_RC_1) +# define RC_Quote_qualifyingData (TPM_RC_P + TPM_RC_1) +# define RC_Quote_inScheme (TPM_RC_P + TPM_RC_2) +# define RC_Quote_PCRselect (TPM_RC_P + TPM_RC_3) + +// Function prototype +TPM_RC +TPM2_Quote(Quote_In* in, Quote_Out* out); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_QUOTE_FP_H_ +#endif // CC_Quote diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/RSA_Decrypt_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/RSA_Decrypt_fp.h new file mode 100644 index 000000000..64aa9bffe --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/RSA_Decrypt_fp.h @@ -0,0 +1,37 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_RSA_Decrypt // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_RSA_DECRYPT_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_RSA_DECRYPT_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_DH_OBJECT keyHandle; + TPM2B_PUBLIC_KEY_RSA cipherText; + TPMT_RSA_DECRYPT inScheme; + TPM2B_DATA label; +} RSA_Decrypt_In; + +// Output structure definition +typedef struct +{ + TPM2B_PUBLIC_KEY_RSA message; +} RSA_Decrypt_Out; + +// Response code modifiers +# define RC_RSA_Decrypt_keyHandle (TPM_RC_H + TPM_RC_1) +# define RC_RSA_Decrypt_cipherText (TPM_RC_P + TPM_RC_1) +# define RC_RSA_Decrypt_inScheme (TPM_RC_P + TPM_RC_2) +# define RC_RSA_Decrypt_label (TPM_RC_P + TPM_RC_3) + +// Function prototype +TPM_RC +TPM2_RSA_Decrypt(RSA_Decrypt_In* in, RSA_Decrypt_Out* out); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_RSA_DECRYPT_FP_H_ +#endif // CC_RSA_Decrypt diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/RSA_Encrypt_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/RSA_Encrypt_fp.h new file mode 100644 index 000000000..b82ab4307 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/RSA_Encrypt_fp.h @@ -0,0 +1,37 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_RSA_Encrypt // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_RSA_ENCRYPT_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_RSA_ENCRYPT_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_DH_OBJECT keyHandle; + TPM2B_PUBLIC_KEY_RSA message; + TPMT_RSA_DECRYPT inScheme; + TPM2B_DATA label; +} RSA_Encrypt_In; + +// Output structure definition +typedef struct +{ + TPM2B_PUBLIC_KEY_RSA outData; +} RSA_Encrypt_Out; + +// Response code modifiers +# define RC_RSA_Encrypt_keyHandle (TPM_RC_H + TPM_RC_1) +# define RC_RSA_Encrypt_message (TPM_RC_P + TPM_RC_1) +# define RC_RSA_Encrypt_inScheme (TPM_RC_P + TPM_RC_2) +# define RC_RSA_Encrypt_label (TPM_RC_P + TPM_RC_3) + +// Function prototype +TPM_RC +TPM2_RSA_Encrypt(RSA_Encrypt_In* in, RSA_Encrypt_Out* out); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_RSA_ENCRYPT_FP_H_ +#endif // CC_RSA_Encrypt diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/ReadClock_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/ReadClock_fp.h new file mode 100644 index 000000000..405f9befa --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/ReadClock_fp.h @@ -0,0 +1,22 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_ReadClock // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_READCLOCK_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_READCLOCK_FP_H_ + +// Output structure definition +typedef struct +{ + TPMS_TIME_INFO currentTime; +} ReadClock_Out; + +// Function prototype +TPM_RC +TPM2_ReadClock(ReadClock_Out* out); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_READCLOCK_FP_H_ +#endif // CC_ReadClock diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/ReadOnlyControl_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/ReadOnlyControl_fp.h new file mode 100644 index 000000000..24338b4e3 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/ReadOnlyControl_fp.h @@ -0,0 +1,24 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +#if CC_ReadOnlyControl // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_READONLYCONTROL_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_READONLYCONTROL_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_RH_PLATFORM authHandle; + TPMI_YES_NO state; +} ReadOnlyControl_In; + +// Response code modifiers +# define ReadOnlyControl_authHandle (TPM_RC_H + TPM_RC_1) +# define ReadOnlyControl_state (TPM_RC_P + TPM_RC_1) + +// Function prototype +TPM_RC TPM2_ReadOnlyControl(ReadOnlyControl_In* in); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_READONLYCONTROL_FP_H_ +#endif // CC_ReadOnlyControl diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/ReadPublic_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/ReadPublic_fp.h new file mode 100644 index 000000000..8604580cf --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/ReadPublic_fp.h @@ -0,0 +1,33 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_ReadPublic // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_READPUBLIC_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_READPUBLIC_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_DH_OBJECT objectHandle; +} ReadPublic_In; + +// Output structure definition +typedef struct +{ + TPM2B_PUBLIC outPublic; + TPM2B_NAME name; + TPM2B_NAME qualifiedName; +} ReadPublic_Out; + +// Response code modifiers +# define RC_ReadPublic_objectHandle (TPM_RC_H + TPM_RC_1) + +// Function prototype +TPM_RC +TPM2_ReadPublic(ReadPublic_In* in, ReadPublic_Out* out); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_READPUBLIC_FP_H_ +#endif // CC_ReadPublic diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/ResponseCodeProcessing_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/ResponseCodeProcessing_fp.h new file mode 100644 index 000000000..227ccff8b --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/ResponseCodeProcessing_fp.h @@ -0,0 +1,17 @@ +// SPDX-License-Identifier: BSD-2-Clause + +/*(Auto-generated) + * Created by TpmPrototypes; Version 3.0 July 18, 2017 + * Date: Mar 28, 2019 Time: 08:25:19PM + */ + +#ifndef _RESPONSE_CODE_PROCESSING_FP_H_ +#define _RESPONSE_CODE_PROCESSING_FP_H_ + +//** RcSafeAddToResult() +// Adds a modifier to a response code as long as the response code allows a modifier +// and no modifier has already been added. +TPM_RC +RcSafeAddToResult(TPM_RC responseCode, TPM_RC modifier); + +#endif // _RESPONSE_CODE_PROCESSING_FP_H_ diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/Response_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/Response_fp.h new file mode 100644 index 000000000..7fd9d3744 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/Response_fp.h @@ -0,0 +1,19 @@ +// SPDX-License-Identifier: BSD-2-Clause + +/*(Auto-generated) + * Created by TpmPrototypes; Version 3.0 July 18, 2017 + * Date: Mar 28, 2019 Time: 08:25:19PM + */ + +#ifndef _RESPONSE_FP_H_ +#define _RESPONSE_FP_H_ + +//** BuildResponseHeader() +// Adds the response header to the response. It will update command->parameterSize +// to indicate the total size of the response. +void BuildResponseHeader(COMMAND* command, // IN: main control structure + BYTE* buffer, // OUT: the output buffer + TPM_RC result // IN: the response code +); + +#endif // _RESPONSE_FP_H_ diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/Rewrap_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/Rewrap_fp.h new file mode 100644 index 000000000..fae583343 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/Rewrap_fp.h @@ -0,0 +1,40 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_Rewrap // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_REWRAP_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_REWRAP_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_DH_OBJECT oldParent; + TPMI_DH_OBJECT newParent; + TPM2B_PRIVATE inDuplicate; + TPM2B_NAME name; + TPM2B_ENCRYPTED_SECRET inSymSeed; +} Rewrap_In; + +// Output structure definition +typedef struct +{ + TPM2B_PRIVATE outDuplicate; + TPM2B_ENCRYPTED_SECRET outSymSeed; +} Rewrap_Out; + +// Response code modifiers +# define RC_Rewrap_oldParent (TPM_RC_H + TPM_RC_1) +# define RC_Rewrap_newParent (TPM_RC_H + TPM_RC_2) +# define RC_Rewrap_inDuplicate (TPM_RC_P + TPM_RC_1) +# define RC_Rewrap_name (TPM_RC_P + TPM_RC_2) +# define RC_Rewrap_inSymSeed (TPM_RC_P + TPM_RC_3) + +// Function prototype +TPM_RC +TPM2_Rewrap(Rewrap_In* in, Rewrap_Out* out); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_REWRAP_FP_H_ +#endif // CC_Rewrap diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/SecChannel_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/SecChannel_fp.h new file mode 100644 index 000000000..905ea494a --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/SecChannel_fp.h @@ -0,0 +1,41 @@ +// SPDX-License-Identifier: BSD-2-Clause + +#ifndef _SEC_CHANNEL_FP_H_ +#define _SEC_CHANNEL_FP_H_ + +//*** GetTpmSpdmPubKey() +// This function is used to get the dummy TPM SPDM public key +void GetTpmSpdmPubKey(TPMT_PUBLIC* tpmPubKey); + +//*** SpdmCapGetTpmPubKeys() +// This function is used to get the 'TPM_PUB_KEY' public keys for GetCapability. +// Return Type: TPMI_YES_NO +// 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 +); + +//*** SpdmCapGetSessionInfo() +// This function is used to get the SPDM session information for GetCapability. +// Return Type: TPMI_YES_NO +// NO no more properties to be reported +TPMI_YES_NO +SpdmCapGetSessionInfo( + TPML_SPDM_SESSION_INFO* spdmSessionInfoList // OUT: property list +); + +//*** 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. +// 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 +); + +#endif // _SEC_CHANNEL_FP_H_ diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/SelfTest_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/SelfTest_fp.h new file mode 100644 index 000000000..f5f9306bf --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/SelfTest_fp.h @@ -0,0 +1,25 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_SelfTest // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_SELFTEST_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_SELFTEST_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_YES_NO fullTest; +} SelfTest_In; + +// Response code modifiers +# define RC_SelfTest_fullTest (TPM_RC_P + TPM_RC_1) + +// Function prototype +TPM_RC +TPM2_SelfTest(SelfTest_In* in); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_SELFTEST_FP_H_ +#endif // CC_SelfTest diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/SequenceComplete_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/SequenceComplete_fp.h new file mode 100644 index 000000000..644ab12ac --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/SequenceComplete_fp.h @@ -0,0 +1,36 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_SequenceComplete // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_SEQUENCECOMPLETE_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_SEQUENCECOMPLETE_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_DH_OBJECT sequenceHandle; + TPM2B_MAX_BUFFER buffer; + TPMI_RH_HIERARCHY hierarchy; +} SequenceComplete_In; + +// Output structure definition +typedef struct +{ + TPM2B_DIGEST result; + TPMT_TK_HASHCHECK validation; +} SequenceComplete_Out; + +// Response code modifiers +# define RC_SequenceComplete_sequenceHandle (TPM_RC_H + TPM_RC_1) +# define RC_SequenceComplete_buffer (TPM_RC_P + TPM_RC_1) +# define RC_SequenceComplete_hierarchy (TPM_RC_P + TPM_RC_2) + +// Function prototype +TPM_RC +TPM2_SequenceComplete(SequenceComplete_In* in, SequenceComplete_Out* out); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_SEQUENCECOMPLETE_FP_H_ +#endif // CC_SequenceComplete diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/SequenceUpdate_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/SequenceUpdate_fp.h new file mode 100644 index 000000000..919f2a9be --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/SequenceUpdate_fp.h @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_SequenceUpdate // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_SEQUENCEUPDATE_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_SEQUENCEUPDATE_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_DH_OBJECT sequenceHandle; + TPM2B_MAX_BUFFER buffer; +} SequenceUpdate_In; + +// Response code modifiers +# define RC_SequenceUpdate_sequenceHandle (TPM_RC_H + TPM_RC_1) +# define RC_SequenceUpdate_buffer (TPM_RC_P + TPM_RC_1) + +// Function prototype +TPM_RC +TPM2_SequenceUpdate(SequenceUpdate_In* in); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_SEQUENCEUPDATE_FP_H_ +#endif // CC_SequenceUpdate diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/SessionProcess_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/SessionProcess_fp.h new file mode 100644 index 000000000..6f88a3c2c --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/SessionProcess_fp.h @@ -0,0 +1,97 @@ +// SPDX-License-Identifier: BSD-2-Clause + +/*(Auto-generated) + * Created by TpmPrototypes; Version 3.0 July 18, 2017 + * Date: Mar 7, 2020 Time: 07:17:48PM + */ + +#ifndef _SESSION_PROCESS_FP_H_ +#define _SESSION_PROCESS_FP_H_ + +//*** IsDAExempted() +// This function indicates if a handle is exempted from DA logic. +// A handle is exempted if it is: +// a) a primary seed handle; +// b) an object with noDA bit SET; +// c) an NV Index with TPMA_NV_NO_DA bit SET; or +// d) a PCR handle. +// +// Return Type: BOOL +// TRUE(1) handle is exempted from DA logic +// FALSE(0) handle is not exempted from DA logic +BOOL IsDAExempted(TPM_HANDLE handle // IN: entity handle +); + +//*** ClearCpRpHashes() +void ClearCpRpHashes(COMMAND* command); + +//*** CompareNameHash() +// This function computes the name hash and compares it to the nameHash in the +// session data, returning true if they are equal. +BOOL CompareNameHash(COMMAND* command, // IN: main parsing structure + SESSION* session // IN: session structure with nameHash +); + +//*** CompareParametersHash() +// This function computes the parameters hash and compares it to the pHash in +// the session data, returning true if they are equal. +BOOL CompareParametersHash(COMMAND* command, // IN: main parsing structure + SESSION* session // IN: session structure with pHash +); + +#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 +// 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 +); +#endif // SEC_CHANNEL_SUPPORT + +//*** ParseSessionBuffer() +// This function is the entry function for command session processing. +// It iterates sessions in session area and reports if the required authorization +// has been properly provided. It also processes audit session and passes the +// information of encryption sessions to parameter encryption module. +// +// Return Type: TPM_RC +// various parsing failure or authorization failure +// +TPM_RC +ParseSessionBuffer(COMMAND* command // IN: the structure that contains +); + +//*** CheckAuthNoSession() +// Function to process a command with no session associated. +// The function makes sure all the handles in the command require no authorization. +// +// Return Type: TPM_RC +// TPM_RC_AUTH_MISSING failure - one or more handles require +// authorization +TPM_RC +CheckAuthNoSession(COMMAND* command // IN: command parsing structure +); + +//*** BuildResponseSession() +// Function to build Session buffer in a response. The authorization data is added +// to the end of command->responseBuffer. The size of the authorization area is +// accumulated in command->authSize. +// When this is called, command->responseBuffer is pointing at the next location +// in the response buffer to be filled. This is where the authorization sessions +// will go, if any. command->parameterSize is the number of bytes that have been +// marshaled as parameters in the output buffer. +TPM_RC +BuildResponseSession(COMMAND* command // IN: structure that has relevant command + // information +); + +//*** SessionRemoveAssociationToHandle() +// This function deals with the case where an entity associated with an authorization +// is deleted during command processing. The primary use of this is to support +// UndefineSpaceSpecial(). +void SessionRemoveAssociationToHandle(TPM_HANDLE handle); + +#endif // _SESSION_PROCESS_FP_H_ diff --git a/src/tpm2/Session_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/Session_fp.h similarity index 72% rename from src/tpm2/Session_fp.h rename to src/tpm2/TPMCmd/tpm/include/private/prototypes/Session_fp.h index ba3e9050a..22648315d 100644 --- a/src/tpm2/Session_fp.h +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/Session_fp.h @@ -1,62 +1,4 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2016 - 2023 */ -/* */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause /*(Auto-generated) * Created by TpmPrototypes; Version 3.0 July 18, 2017 diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/SetAlgorithmSet_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/SetAlgorithmSet_fp.h new file mode 100644 index 000000000..5b074ae3a --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/SetAlgorithmSet_fp.h @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_SetAlgorithmSet // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_SETALGORITHMSET_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_SETALGORITHMSET_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_RH_PLATFORM authHandle; + UINT32 algorithmSet; +} SetAlgorithmSet_In; + +// Response code modifiers +# define RC_SetAlgorithmSet_authHandle (TPM_RC_H + TPM_RC_1) +# define RC_SetAlgorithmSet_algorithmSet (TPM_RC_P + TPM_RC_1) + +// Function prototype +TPM_RC +TPM2_SetAlgorithmSet(SetAlgorithmSet_In* in); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_SETALGORITHMSET_FP_H_ +#endif // CC_SetAlgorithmSet diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/SetCapability_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/SetCapability_fp.h new file mode 100644 index 000000000..a12921f0c --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/SetCapability_fp.h @@ -0,0 +1,24 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +#if CC_SetCapability // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_SETCAPABILITY_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_SETCAPABILITY_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_RH_HIERARCHY authHandle; + TPM2B_SET_CAPABILITY_DATA setCapabilityData; +} SetCapability_In; + +// Response code modifiers +# define SetCapability_authHandle (TPM_RC_H + TPM_RC_1) +# define SetCapability_setCapabilityData (TPM_RC_P + TPM_RC_1) + +// Function prototype +TPM_RC TPM2_SetCapability(SetCapability_In* in); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_SETCAPABILITY_FP_H_ +#endif // CC_SetCapability diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/SetCommandCodeAuditStatus_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/SetCommandCodeAuditStatus_fp.h new file mode 100644 index 000000000..800033313 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/SetCommandCodeAuditStatus_fp.h @@ -0,0 +1,31 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_SetCommandCodeAuditStatus // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_SETCOMMANDCODEAUDITSTATUS_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_SETCOMMANDCODEAUDITSTATUS_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_RH_PROVISION auth; + TPMI_ALG_HASH auditAlg; + TPML_CC setList; + TPML_CC clearList; +} SetCommandCodeAuditStatus_In; + +// Response code modifiers +# define RC_SetCommandCodeAuditStatus_auth (TPM_RC_H + TPM_RC_1) +# define RC_SetCommandCodeAuditStatus_auditAlg (TPM_RC_P + TPM_RC_1) +# define RC_SetCommandCodeAuditStatus_setList (TPM_RC_P + TPM_RC_2) +# define RC_SetCommandCodeAuditStatus_clearList (TPM_RC_P + TPM_RC_3) + +// Function prototype +TPM_RC +TPM2_SetCommandCodeAuditStatus(SetCommandCodeAuditStatus_In* in); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_SETCOMMANDCODEAUDITSTATUS_FP_H_ +#endif // CC_SetCommandCodeAuditStatus diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/SetPrimaryPolicy_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/SetPrimaryPolicy_fp.h new file mode 100644 index 000000000..4aed86bfb --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/SetPrimaryPolicy_fp.h @@ -0,0 +1,29 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_SetPrimaryPolicy // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_SETPRIMARYPOLICY_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_SETPRIMARYPOLICY_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_RH_HIERARCHY_POLICY authHandle; + TPM2B_DIGEST authPolicy; + TPMI_ALG_HASH hashAlg; +} SetPrimaryPolicy_In; + +// Response code modifiers +# define RC_SetPrimaryPolicy_authHandle (TPM_RC_H + TPM_RC_1) +# define RC_SetPrimaryPolicy_authPolicy (TPM_RC_P + TPM_RC_1) +# define RC_SetPrimaryPolicy_hashAlg (TPM_RC_P + TPM_RC_2) + +// Function prototype +TPM_RC +TPM2_SetPrimaryPolicy(SetPrimaryPolicy_In* in); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_SETPRIMARYPOLICY_FP_H_ +#endif // CC_SetPrimaryPolicy diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/Shutdown_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/Shutdown_fp.h new file mode 100644 index 000000000..87ac70a0a --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/Shutdown_fp.h @@ -0,0 +1,25 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_Shutdown // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_SHUTDOWN_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_SHUTDOWN_FP_H_ + +// Input structure definition +typedef struct +{ + TPM_SU shutdownType; +} Shutdown_In; + +// Response code modifiers +# define RC_Shutdown_shutdownType (TPM_RC_P + TPM_RC_1) + +// Function prototype +TPM_RC +TPM2_Shutdown(Shutdown_In* in); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_SHUTDOWN_FP_H_ +#endif // CC_Shutdown diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/Sign_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/Sign_fp.h new file mode 100644 index 000000000..913382485 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/Sign_fp.h @@ -0,0 +1,37 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_Sign // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_SIGN_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_SIGN_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_DH_OBJECT keyHandle; + TPM2B_DIGEST digest; + TPMT_SIG_SCHEME inScheme; + TPMT_TK_HASHCHECK validation; +} Sign_In; + +// Output structure definition +typedef struct +{ + TPMT_SIGNATURE signature; +} Sign_Out; + +// Response code modifiers +# define RC_Sign_keyHandle (TPM_RC_H + TPM_RC_1) +# define RC_Sign_digest (TPM_RC_P + TPM_RC_1) +# define RC_Sign_inScheme (TPM_RC_P + TPM_RC_2) +# define RC_Sign_validation (TPM_RC_P + TPM_RC_3) + +// Function prototype +TPM_RC +TPM2_Sign(Sign_In* in, Sign_Out* out); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_SIGN_FP_H_ +#endif // CC_Sign diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/StartAuthSession_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/StartAuthSession_fp.h new file mode 100644 index 000000000..6337f28f4 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/StartAuthSession_fp.h @@ -0,0 +1,44 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_StartAuthSession // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_STARTAUTHSESSION_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_STARTAUTHSESSION_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_DH_OBJECT tpmKey; + TPMI_DH_ENTITY bind; + TPM2B_NONCE nonceCaller; + TPM2B_ENCRYPTED_SECRET encryptedSalt; + TPM_SE sessionType; + TPMT_SYM_DEF symmetric; + TPMI_ALG_HASH authHash; +} StartAuthSession_In; + +// Output structure definition +typedef struct +{ + TPMI_SH_AUTH_SESSION sessionHandle; + TPM2B_NONCE nonceTPM; +} StartAuthSession_Out; + +// Response code modifiers +# define RC_StartAuthSession_tpmKey (TPM_RC_H + TPM_RC_1) +# define RC_StartAuthSession_bind (TPM_RC_H + TPM_RC_2) +# define RC_StartAuthSession_nonceCaller (TPM_RC_P + TPM_RC_1) +# define RC_StartAuthSession_encryptedSalt (TPM_RC_P + TPM_RC_2) +# define RC_StartAuthSession_sessionType (TPM_RC_P + TPM_RC_3) +# define RC_StartAuthSession_symmetric (TPM_RC_P + TPM_RC_4) +# define RC_StartAuthSession_authHash (TPM_RC_P + TPM_RC_5) + +// Function prototype +TPM_RC +TPM2_StartAuthSession(StartAuthSession_In* in, StartAuthSession_Out* out); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_STARTAUTHSESSION_FP_H_ +#endif // CC_StartAuthSession diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/Startup_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/Startup_fp.h new file mode 100644 index 000000000..82922bf1b --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/Startup_fp.h @@ -0,0 +1,25 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_Startup // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_STARTUP_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_STARTUP_FP_H_ + +// Input structure definition +typedef struct +{ + TPM_SU startupType; +} Startup_In; + +// Response code modifiers +# define RC_Startup_startupType (TPM_RC_P + TPM_RC_1) + +// Function prototype +TPM_RC +TPM2_Startup(Startup_In* in); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_STARTUP_FP_H_ +#endif // CC_Startup diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/StirRandom_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/StirRandom_fp.h new file mode 100644 index 000000000..7f43c6c6d --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/StirRandom_fp.h @@ -0,0 +1,25 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_StirRandom // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_STIRRANDOM_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_STIRRANDOM_FP_H_ + +// Input structure definition +typedef struct +{ + TPM2B_SENSITIVE_DATA inData; +} StirRandom_In; + +// Response code modifiers +# define RC_StirRandom_inData (TPM_RC_P + TPM_RC_1) + +// Function prototype +TPM_RC +TPM2_StirRandom(StirRandom_In* in); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_STIRRANDOM_FP_H_ +#endif // CC_StirRandom diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/TestParms_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/TestParms_fp.h new file mode 100644 index 000000000..3dd3abe40 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/TestParms_fp.h @@ -0,0 +1,25 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_TestParms // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_TESTPARMS_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_TESTPARMS_FP_H_ + +// Input structure definition +typedef struct +{ + TPMT_PUBLIC_PARMS parameters; +} TestParms_In; + +// Response code modifiers +# define RC_TestParms_parameters (TPM_RC_P + TPM_RC_1) + +// Function prototype +TPM_RC +TPM2_TestParms(TestParms_In* in); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_TESTPARMS_FP_H_ +#endif // CC_TestParms diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/Ticket_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/Ticket_fp.h new file mode 100644 index 000000000..e7ce4d7e6 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/Ticket_fp.h @@ -0,0 +1,61 @@ +// SPDX-License-Identifier: BSD-2-Clause + +/*(Auto-generated) + * Created by TpmPrototypes; Version 3.0 July 18, 2017 + * Date: Mar 28, 2019 Time: 08:25:19PM + */ + +#ifndef _TICKET_FP_H_ +#define _TICKET_FP_H_ + +//*** TicketIsSafe() +// This function indicates if producing a ticket is safe. +// It checks if the leading bytes of an input buffer is TPM_GENERATED_VALUE +// or its substring of canonical form. If so, it is not safe to produce ticket +// for an input buffer claiming to be TPM generated buffer +// Return Type: BOOL +// TRUE(1) safe to produce ticket +// FALSE(0) not safe to produce ticket +BOOL TicketIsSafe(TPM2B* buffer); + +//*** TicketComputeVerified() +// This function creates a TPMT_TK_VERIFIED ticket. +TPM_RC TicketComputeVerified( + TPMI_RH_HIERARCHY hierarchy, // IN: hierarchy constant for ticket + TPM2B_DIGEST* digest, // IN: digest + TPM2B_NAME* keyName, // IN: name of key that signed the values + TPMT_TK_VERIFIED* ticket // OUT: verified ticket +); + +//*** TicketComputeAuth() +// This function creates a TPMT_TK_AUTH ticket. +TPM_RC TicketComputeAuth( + TPM_ST type, // IN: the type of ticket. + TPMI_RH_HIERARCHY hierarchy, // IN: hierarchy constant for ticket + UINT64 timeout, // IN: timeout + BOOL expiresOnReset, // IN: flag to indicate if ticket expires on + // TPM Reset + TPM2B_DIGEST* cpHashA, // IN: input cpHashA + TPM2B_NONCE* policyRef, // IN: input policyRef + TPM2B_NAME* entityName, // IN: name of entity + TPMT_TK_AUTH* ticket // OUT: Created ticket +); + +//*** TicketComputeHashCheck() +// This function creates a TPMT_TK_HASHCHECK ticket. +TPM_RC TicketComputeHashCheck( + TPMI_RH_HIERARCHY hierarchy, // IN: hierarchy constant for ticket + TPM_ALG_ID hashAlg, // IN: the hash algorithm for 'digest' + TPM2B_DIGEST* digest, // IN: input digest + TPMT_TK_HASHCHECK* ticket // OUT: Created ticket +); + +//*** TicketComputeCreation() +// This function creates a TPMT_TK_CREATION ticket. +TPM_RC TicketComputeCreation(TPMI_RH_HIERARCHY hierarchy, // IN: hierarchy for ticket + TPM2B_NAME* name, // IN: object name + TPM2B_DIGEST* creation, // IN: creation hash + TPMT_TK_CREATION* ticket // OUT: created ticket +); + +#endif // _TICKET_FP_H_ diff --git a/src/tpm2/Time_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/Time_fp.h similarity index 51% rename from src/tpm2/Time_fp.h rename to src/tpm2/TPMCmd/tpm/include/private/prototypes/Time_fp.h index 56f74a275..53dc89c16 100644 --- a/src/tpm2/Time_fp.h +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/Time_fp.h @@ -1,62 +1,4 @@ -/********************************************************************************/ -/* */ -/* Functions relating to the TPM's time functions */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2016 - 2023 */ -/* */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause /*(Auto-generated) * Created by TpmPrototypes; Version 3.0 July 18, 2017 diff --git a/src/tpm2/TpmASN1_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/TpmASN1_fp.h similarity index 61% rename from src/tpm2/TpmASN1_fp.h rename to src/tpm2/TPMCmd/tpm/include/private/prototypes/TpmASN1_fp.h index 0d1f2ae95..91bba7c8e 100644 --- a/src/tpm2/TpmASN1_fp.h +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/TpmASN1_fp.h @@ -1,62 +1,4 @@ -/********************************************************************************/ -/* */ -/* TPM ASN.1 */ -/* 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 - 2023 */ -/* */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause /*(Auto-generated) * Created by TpmPrototypes; Version 3.0 July 18, 2017 diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/TpmEcc_Signature_ECDAA_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/TpmEcc_Signature_ECDAA_fp.h new file mode 100644 index 000000000..9b1765fa1 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/TpmEcc_Signature_ECDAA_fp.h @@ -0,0 +1,35 @@ +// SPDX-License-Identifier: BSD-2-Clause + +#ifndef _TPMECC_SIGNATURE_ECDAA_FP_H_ +#define _TPMECC_SIGNATURE_ECDAA_FP_H_ +#if ALG_ECC && ALG_ECDAA + +//*** TpmEcc_SignEcdaa() +// +// This function performs 's' = 'r' + 'T' * 'd' mod 'q' where +// 1) 'r' is a random, or pseudo-random value created in the commit phase +// 2) 'nonceK' is a TPM-generated, random value 0 < 'nonceK' < 'n' +// 3) 'T' is mod 'q' of "Hash"('nonceK' || 'digest'), and +// 4) 'd' is a private key. +// +// The signature is the tuple ('nonceK', 's') +// +// Regrettably, the parameters in this function kind of collide with the parameter +// names used in ECSCHNORR making for a lot of confusion. +// Return Type: TPM_RC +// TPM_RC_SCHEME unsupported hash algorithm +// TPM_RC_NO_RESULT cannot get values from random number generator +TPM_RC TpmEcc_SignEcdaa( + TPM2B_ECC_PARAMETER* nonceK, // OUT: 'nonce' component of the signature + Crypt_Int* bnS, // OUT: 's' component of the signature + const Crypt_EccCurve* E, // IN: the curve used in signing + Crypt_Int* bnD, // IN: the private key + const TPM2B_DIGEST* digest, // IN: the value to sign (mod 'q') + TPMT_ECC_SCHEME* scheme, // IN: signing scheme (contains the + // commit count value). + OBJECT* eccKey, // IN: The signing key + RAND_STATE* rand // IN: a random number state +); + +#endif // ALG_ECC && ALG_ECDAA +#endif // _TPMECC_SIGNATURE_ECDAA_FP_H_ diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/TpmEcc_Signature_ECDSA_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/TpmEcc_Signature_ECDSA_fp.h new file mode 100644 index 000000000..b7407a43f --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/TpmEcc_Signature_ECDSA_fp.h @@ -0,0 +1,38 @@ +// SPDX-License-Identifier: BSD-2-Clause + +#ifndef _TPMECC_SIGNATURE_ECDSA_FP_H_ +#define _TPMECC_SIGNATURE_ECDSA_FP_H_ + +#if ALG_ECC && ALG_ECDSA +# include + +//*** TpmEcc_SignEcdsa() +// This function implements the ECDSA signing algorithm. The method is described +// in the comments below. +TPM_RC +TpmEcc_SignEcdsa(Crypt_Int* bnR, // OUT: 'r' component of the signature + Crypt_Int* bnS, // OUT: 's' component of the signature + const Crypt_EccCurve* E, // IN: the curve used in the signature + // process + Crypt_Int* bnD, // IN: private signing key + const TPM2B_DIGEST* digest, // IN: the digest to sign + RAND_STATE* rand // IN: used in debug of signing +); + +//*** TpmEcc_ValidateSignatureEcdsa() +// This function validates an ECDSA signature. rIn and sIn should have been checked +// to make sure that they are in the range 0 < 'v' < 'n' +// Return Type: TPM_RC +// TPM_RC_SIGNATURE signature not valid +TPM_RC +TpmEcc_ValidateSignatureEcdsa( + Crypt_Int* bnR, // IN: 'r' component of the signature + Crypt_Int* bnS, // IN: 's' component of the signature + const Crypt_EccCurve* E, // IN: the curve used in the signature + // process + const Crypt_Point* ecQ, // IN: the public point of the key + const TPM2B_DIGEST* digest // IN: the digest that was signed +); + +#endif // ALG_ECC && ALG_ECDSA +#endif // _TPMECC_SIGNATURE_ECDSA_FP_H_ diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/TpmEcc_Signature_SM2_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/TpmEcc_Signature_SM2_fp.h new file mode 100644 index 000000000..e66d14dc5 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/TpmEcc_Signature_SM2_fp.h @@ -0,0 +1,37 @@ +// SPDX-License-Identifier: BSD-2-Clause + +#ifndef _TPMECC_SIGNATURE_SM2_FP_H_ +#define _TPMECC_SIGNATURE_SM2_FP_H_ + +#if ALG_ECC && ALG_SM2 +//*** TpmEcc_SignEcSm2() +// This function signs a digest using the method defined in SM2 Part 2. The method +// in the standard will add a header to the message to be signed that is a hash of +// the values that define the key. This then hashed with the message to produce a +// digest ('e'). This function signs 'e'. +// Return Type: TPM_RC +// TPM_RC_VALUE bad curve +TPM_RC TpmEcc_SignEcSm2(Crypt_Int* bnR, // OUT: 'r' component of the signature + Crypt_Int* bnS, // OUT: 's' component of the signature + const Crypt_EccCurve* E, // IN: the curve used in signing + Crypt_Int* bnD, // IN: the private key + const TPM2B_DIGEST* digest, // IN: the digest to sign + RAND_STATE* rand // IN: random number generator (mostly for + // debug) +); + +//*** TpmEcc_ValidateSignatureEcSm2() +// This function is used to validate an SM2 signature. +// Return Type: TPM_RC +// TPM_RC_SIGNATURE signature not valid +TPM_RC TpmEcc_ValidateSignatureEcSm2( + Crypt_Int* bnR, // IN: 'r' component of the signature + Crypt_Int* bnS, // IN: 's' component of the signature + const Crypt_EccCurve* E, // IN: the curve used in the signature + // process + Crypt_Point* ecQ, // IN: the public point of the key + const TPM2B_DIGEST* digest // IN: the digest that was signed +); + +#endif // ALG_ECC && ALG_SM2 +#endif // _TPMECC_SIGNATURE_SM2_FP_H_ diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/TpmEcc_Signature_Schnorr_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/TpmEcc_Signature_Schnorr_fp.h new file mode 100644 index 000000000..19d89cd49 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/TpmEcc_Signature_Schnorr_fp.h @@ -0,0 +1,32 @@ +// SPDX-License-Identifier: BSD-2-Clause + +#ifndef _TPMECC_SIGNATURE_SCHNORR_FP_H_ +#define _TPMECC_SIGNATURE_SCHNORR_FP_H_ + +#if ALG_ECC && ALG_ECSCHNORR +TPM_RC TpmEcc_SignEcSchnorr( + Crypt_Int* bnR, // OUT: 'r' component of the signature + Crypt_Int* bnS, // OUT: 's' component of the signature + const Crypt_EccCurve* E, // IN: the curve used in signing + Crypt_Int* bnD, // IN: the signing key + const TPM2B_DIGEST* digest, // IN: the digest to sign + TPM_ALG_ID hashAlg, // IN: signing scheme (contains a hash) + RAND_STATE* rand // IN: non-NULL when testing +); + +//*** TpmEcc_ValidateSignatureEcSchnorr() +// This function is used to validate an EC Schnorr signature. +// Return Type: TPM_RC +// TPM_RC_SIGNATURE signature not valid +TPM_RC TpmEcc_ValidateSignatureEcSchnorr( + Crypt_Int* bnR, // IN: 'r' component of the signature + Crypt_Int* bnS, // IN: 's' component of the signature + TPM_ALG_ID hashAlg, // IN: hash algorithm of the signature + const Crypt_EccCurve* E, // IN: the curve used in the signature + // process + Crypt_Point* ecQ, // IN: the public point of the key + const TPM2B_DIGEST* digest // IN: the digest that was signed +); + +#endif // ALG_ECC && ALG_ECSCHNORR +#endif // _TPMECC_SIGNATURE_SCHNORR_FP_H_ diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/TpmEcc_Signature_Util_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/TpmEcc_Signature_Util_fp.h new file mode 100644 index 000000000..6fb88ee70 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/TpmEcc_Signature_Util_fp.h @@ -0,0 +1,29 @@ +// SPDX-License-Identifier: BSD-2-Clause + +// functions shared by multiple signature algorithms +#ifndef _TPMECC_SIGNATURE_UTIL_FP_H_ +#define _TPMECC_SIGNATURE_UTIL_FP_H_ + +#if ALG_ECC +//*** TpmEcc_SchnorrCalculateS() +// This contains the Schnorr signature (S) computation. It is used by both ECDSA and +// Schnorr signing. The result is computed as: ['s' = 'k' + 'r' * 'd' (mod 'n')] +// where +// 1) 's' is the signature +// 2) 'k' is a random value +// 3) 'r' is the value to sign +// 4) 'd' is the private EC key +// 5) 'n' is the order of the curve +// Return Type: TPM_RC +// TPM_RC_NO_RESULT the result of the operation was zero or 'r' (mod 'n') +// is zero +TPM_RC TpmEcc_SchnorrCalculateS( + Crypt_Int* bnS, // OUT: 's' component of the signature + const Crypt_Int* bnK, // IN: a random value + Crypt_Int* bnR, // IN: the signature 'r' value + const Crypt_Int* bnD, // IN: the private key + const Crypt_Int* bnN // IN: the order of the curve +); + +#endif // ALG_ECC +#endif // _TPMECC_SIGNATURE_UTIL_FP_H_ diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/TpmEcc_Util_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/TpmEcc_Util_fp.h new file mode 100644 index 000000000..9c9aa1f89 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/TpmEcc_Util_fp.h @@ -0,0 +1,31 @@ +// SPDX-License-Identifier: BSD-2-Clause + +#ifndef _TPMECC_UTIL_FP_H_ +#define _TPMECC_UTIL_FP_H_ + +#if ALG_ECC + +//*** TpmEcc_PointFrom2B() +// Function to create a Crypt_Point structure from a 2B point. +// This function doesn't take an Crypt_EccCurve for legacy reasons - +// this should probably be changed. +// returns NULL if the input value is invalid or doesn't fit. +LIB_EXPORT Crypt_Point* TpmEcc_PointFrom2B( + Crypt_Point* ecP, // OUT: the preallocated point structure + TPMS_ECC_POINT* p // IN: the number to convert +); + +//*** TpmEcc_PointTo2B() +// This function converts a Crypt_Point into a TPMS_ECC_POINT. A TPMS_ECC_POINT +// contains two TPM2B_ECC_PARAMETER values. The maximum size of the parameters +// is dependent on the maximum EC key size used in an implementation. +// The presumption is that the TPMS_ECC_POINT is large enough to hold 2 TPM2B +// values, each as large as a MAX_ECC_PARAMETER_BYTES +LIB_EXPORT BOOL TpmEcc_PointTo2B( + TPMS_ECC_POINT* p, // OUT: the converted 2B structure + const Crypt_Point* ecP, // IN: the values to be converted + const Crypt_EccCurve* E // IN: curve descriptor for the point +); + +#endif // ALG_ECC +#endif // _TPMECC_UTIL_FP_H_ diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/TpmMath_Debug_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/TpmMath_Debug_fp.h new file mode 100644 index 000000000..449a24610 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/TpmMath_Debug_fp.h @@ -0,0 +1,28 @@ +// SPDX-License-Identifier: BSD-2-Clause + +// +// debug and test utilities. Not expected to be compiled into final products +#ifndef _TPMMATH_DEBUG_FP_H_ +#define _TPMMATH_DEBUG_FP_H_ + +#if ALG_ECC || ALG_RSA + +//*** TpmEccDebug_HexEqual() +// This function compares a bignum value to a hex string. +// using TpmEcc namespace because code assumes the max size +// is correct for ECC. +// Return Type: BOOL +// TRUE(1) values equal +// FALSE(0) values not equal +BOOL TpmMath_Debug_HexEqual(const Crypt_Int* bn, //IN: big number value + const char* c //IN: character string number +); + +LIB_EXPORT Crypt_Int* TpmMath_Debug_FromHex( + Crypt_Int* bn, // OUT: + const unsigned char* hex, // IN: + size_t maxsizeHex // IN: maximum size of hex +); + +#endif // ALG_ECC or ALG_RSA +#endif //_TPMMATH_DEBUG_FP_H_ diff --git a/src/tpm2/TpmMath_Util_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/TpmMath_Util_fp.h similarity index 52% rename from src/tpm2/TpmMath_Util_fp.h rename to src/tpm2/TPMCmd/tpm/include/private/prototypes/TpmMath_Util_fp.h index 7072816f0..a34cbadfe 100644 --- a/src/tpm2/TpmMath_Util_fp.h +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/TpmMath_Util_fp.h @@ -1,62 +1,4 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2023 */ -/* */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause #ifndef _TPM_MATH_FP_H_ #define _TPM_MATH_FP_H_ diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/TpmSizeChecks_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/TpmSizeChecks_fp.h new file mode 100644 index 000000000..eac18c859 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/TpmSizeChecks_fp.h @@ -0,0 +1,21 @@ +// SPDX-License-Identifier: BSD-2-Clause + +/*(Auto-generated) + * Created by TpmPrototypes; Version 3.0 July 18, 2017 + * Date: Oct 24, 2019 Time: 11:37:07AM + */ + +#ifndef _TPM_SIZE_CHECKS_FP_H_ +#define _TPM_SIZE_CHECKS_FP_H_ + +#if RUNTIME_SIZE_CHECKS + +//** TpmSizeChecks() +// This function is used during the development process to make sure that the +// vendor-specific values result in a consistent implementation. When possible, +// the code contains "#if" to do compile-time checks. However, in some cases, the +// values require the use of "sizeof()" and that can't be used in an #if. +BOOL TpmSizeChecks(void); +#endif // RUNTIME_SIZE_CHECKS + +#endif // _TPM_SIZE_CHECKS_FP_H_ diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/Unseal_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/Unseal_fp.h new file mode 100644 index 000000000..afce5fe7b --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/Unseal_fp.h @@ -0,0 +1,31 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_Unseal // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_UNSEAL_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_UNSEAL_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_DH_OBJECT itemHandle; +} Unseal_In; + +// Output structure definition +typedef struct +{ + TPM2B_SENSITIVE_DATA outData; +} Unseal_Out; + +// Response code modifiers +# define RC_Unseal_itemHandle (TPM_RC_H + TPM_RC_1) + +// Function prototype +TPM_RC +TPM2_Unseal(Unseal_In* in, Unseal_Out* out); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_UNSEAL_FP_H_ +#endif // CC_Unseal diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/VerifySignature_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/VerifySignature_fp.h new file mode 100644 index 000000000..4365202fc --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/VerifySignature_fp.h @@ -0,0 +1,35 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_VerifySignature // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_VERIFYSIGNATURE_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_VERIFYSIGNATURE_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_DH_OBJECT keyHandle; + TPM2B_DIGEST digest; + TPMT_SIGNATURE signature; +} VerifySignature_In; + +// Output structure definition +typedef struct +{ + TPMT_TK_VERIFIED validation; +} VerifySignature_Out; + +// Response code modifiers +# define RC_VerifySignature_keyHandle (TPM_RC_H + TPM_RC_1) +# define RC_VerifySignature_digest (TPM_RC_P + TPM_RC_1) +# define RC_VerifySignature_signature (TPM_RC_P + TPM_RC_2) + +// Function prototype +TPM_RC +TPM2_VerifySignature(VerifySignature_In* in, VerifySignature_Out* out); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_VERIFYSIGNATURE_FP_H_ +#endif // CC_VerifySignature diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/X509_ECC_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/X509_ECC_fp.h new file mode 100644 index 000000000..c19ffcee8 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/X509_ECC_fp.h @@ -0,0 +1,38 @@ +// SPDX-License-Identifier: BSD-2-Clause + +/*(Auto-generated) + * Created by TpmPrototypes; Version 3.0 July 18, 2017 + * Date: Apr 2, 2019 Time: 11:00:49AM + */ + +#ifndef _X509_ECC_FP_H_ +#define _X509_ECC_FP_H_ + +//*** X509PushPoint() +// This seems like it might be used more than once so... +// Return Type: INT16 +// > 0 number of bytes added +// == 0 failure +INT16 +X509PushPoint(ASN1MarshalContext* ctx, TPMS_ECC_POINT* p); + +//*** X509AddSigningAlgorithmECC() +// This creates the singing algorithm data. +// Return Type: INT16 +// > 0 number of bytes added +// == 0 failure +INT16 +X509AddSigningAlgorithmECC( + OBJECT* signKey, TPMT_SIG_SCHEME* scheme, ASN1MarshalContext* ctx); + +//*** X509AddPublicECC() +// This function will add the publicKey description to the DER data. If ctx is +// NULL, then no data is transferred and this function will indicate if the TPM +// has the values for DER-encoding of the public key. +// Return Type: INT16 +// > 0 number of bytes added +// == 0 failure +INT16 +X509AddPublicECC(OBJECT* object, ASN1MarshalContext* ctx); + +#endif // _X509_ECC_FP_H_ diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/X509_RSA_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/X509_RSA_fp.h new file mode 100644 index 000000000..392f5ab34 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/X509_RSA_fp.h @@ -0,0 +1,33 @@ +// SPDX-License-Identifier: BSD-2-Clause + +/*(Auto-generated) + * Created by TpmPrototypes; Version 3.0 July 18, 2017 + * Date: Apr 2, 2019 Time: 11:00:49AM + */ + +#ifndef _X509_RSA_FP_H_ +#define _X509_RSA_FP_H_ + +#if ALG_RSA + +//*** X509AddSigningAlgorithmRSA() +// This creates the singing algorithm data. +// Return Type: INT16 +// > 0 number of bytes added +// == 0 failure +INT16 +X509AddSigningAlgorithmRSA( + OBJECT* signKey, TPMT_SIG_SCHEME* scheme, ASN1MarshalContext* ctx); + +//*** X509AddPublicRSA() +// This function will add the publicKey description to the DER data. If fillPtr is +// NULL, then no data is transferred and this function will indicate if the TPM +// has the values for DER-encoding of the public key. +// Return Type: INT16 +// > 0 number of bytes added +// == 0 failure +INT16 +X509AddPublicRSA(OBJECT* object, ASN1MarshalContext* ctx); +#endif // ALG_RSA + +#endif // _X509_RSA_FP_H_ diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/X509_spt_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/X509_spt_fp.h new file mode 100644 index 000000000..22b3b52a3 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/X509_spt_fp.h @@ -0,0 +1,73 @@ +// SPDX-License-Identifier: BSD-2-Clause + +/*(Auto-generated) + * Created by TpmPrototypes; Version 3.0 July 18, 2017 + * Date: Nov 14, 2019 Time: 05:57:02PM + */ + +#ifndef _X509_SPT_FP_H_ +#define _X509_SPT_FP_H_ + +//*** X509FindExtensionByOID() +// This will search a list of X509 extensions to find an extension with the +// requested OID. If the extension is found, the output context ('ctx') is set up +// to point to the OID in the extension. +// Return Type: BOOL +// TRUE(1) success +// FALSE(0) failure (could be catastrophic) +BOOL X509FindExtensionByOID(ASN1UnmarshalContext* ctxIn, // IN: the context to search + ASN1UnmarshalContext* ctx, // OUT: the extension context + const BYTE* OID // IN: oid to search for +); + +//*** X509GetExtensionBits() +// This function will extract a bit field from an extension. If the extension doesn't +// contain a bit string, it will fail. +// Return Type: BOOL +// TRUE(1) success +// FALSE(0) failure +UINT32 +X509GetExtensionBits(ASN1UnmarshalContext* ctx, UINT32* value); + +//***X509ProcessExtensions() +// This function is used to process the TPMA_OBJECT and KeyUsage extensions. It is not +// in the CertifyX509.c code because it makes the code harder to follow. +// Return Type: TPM_RC +// TPM_RCS_ATTRIBUTES the attributes of object are not consistent with +// the extension setting +// TPM_RC_VALUE problem parsing the extensions +TPM_RC +X509ProcessExtensions( + OBJECT* object, // IN: The object with the attributes to + // check + stringRef* extension // IN: The start and length of the extensions +); + +//*** X509AddSigningAlgorithm() +// This creates the singing algorithm data. +// Return Type: INT16 +// > 0 number of octets added +// <= 0 failure +INT16 +X509AddSigningAlgorithm( + ASN1MarshalContext* ctx, OBJECT* signKey, TPMT_SIG_SCHEME* scheme); + +//*** X509AddPublicKey() +// This function will add the publicKey description to the DER data. If fillPtr is +// NULL, then no data is transferred and this function will indicate if the TPM +// has the values for DER-encoding of the public key. +// Return Type: INT16 +// > 0 number of octets added +// == 0 failure +INT16 +X509AddPublicKey(ASN1MarshalContext* ctx, OBJECT* object); + +//*** X509PushAlgorithmIdentifierSequence() +// The function adds the algorithm identifier sequence. +// Return Type: INT16 +// > 0 number of bytes added +// == 0 failure +INT16 +X509PushAlgorithmIdentifierSequence(ASN1MarshalContext* ctx, const BYTE* OID); + +#endif // _X509_SPT_FP_H_ diff --git a/src/tpm2/TPMCmd/tpm/include/private/prototypes/ZGen_2Phase_fp.h b/src/tpm2/TPMCmd/tpm/include/private/prototypes/ZGen_2Phase_fp.h new file mode 100644 index 000000000..0cc9842f1 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/private/prototypes/ZGen_2Phase_fp.h @@ -0,0 +1,40 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#if CC_ZGen_2Phase // Command must be enabled + +# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_ZGEN_2PHASE_FP_H_ +# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_ZGEN_2PHASE_FP_H_ + +// Input structure definition +typedef struct +{ + TPMI_DH_OBJECT keyA; + TPM2B_ECC_POINT inQsB; + TPM2B_ECC_POINT inQeB; + TPMI_ECC_KEY_EXCHANGE inScheme; + UINT16 counter; +} ZGen_2Phase_In; + +// Output structure definition +typedef struct +{ + TPM2B_ECC_POINT outZ1; + TPM2B_ECC_POINT outZ2; +} ZGen_2Phase_Out; + +// Response code modifiers +# define RC_ZGen_2Phase_keyA (TPM_RC_H + TPM_RC_1) +# define RC_ZGen_2Phase_inQsB (TPM_RC_P + TPM_RC_1) +# define RC_ZGen_2Phase_inQeB (TPM_RC_P + TPM_RC_2) +# define RC_ZGen_2Phase_inScheme (TPM_RC_P + TPM_RC_3) +# define RC_ZGen_2Phase_counter (TPM_RC_P + TPM_RC_4) + +// Function prototype +TPM_RC +TPM2_ZGen_2Phase(ZGen_2Phase_In* in, ZGen_2Phase_Out* out); + +# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_ZGEN_2PHASE_FP_H_ +#endif // CC_ZGen_2Phase diff --git a/src/tpm2/ACT.h b/src/tpm2/TPMCmd/tpm/include/tpm_public/ACT.h similarity index 55% rename from src/tpm2/ACT.h rename to src/tpm2/TPMCmd/tpm/include/tpm_public/ACT.h index cd5b7d1b3..5523b9444 100644 --- a/src/tpm2/ACT.h +++ b/src/tpm2/TPMCmd/tpm/include/tpm_public/ACT.h @@ -1,68 +1,9 @@ -/********************************************************************************/ -/* */ -/* 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_ -#include "TpmProfile.h" +#include #if 0 // libtpms added #if ACT_SUPPORT \ @@ -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) diff --git a/src/tpm2/TPMCmd/tpm/include/tpm_public/BaseTypes.h b/src/tpm2/TPMCmd/tpm/include/tpm_public/BaseTypes.h new file mode 100644 index 000000000..fff55b9b1 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/tpm_public/BaseTypes.h @@ -0,0 +1,35 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +// FILE GENERATED BY TpmExtractCode: DO NOT EDIT + +#ifndef _TPM_INCLUDE_PUBLIC_BASETYPES_H_ +#define _TPM_INCLUDE_PUBLIC_BASETYPES_H_ + +// NULL definition +#ifndef NULL +# define NULL (0) +#endif // NULL + +#include +#include + +typedef uint8_t UINT8; +typedef uint8_t BYTE; +typedef int8_t INT8; +typedef int BOOL; +typedef uint16_t UINT16; +typedef int16_t INT16; +typedef uint32_t UINT32; +typedef int32_t INT32; +typedef uint64_t UINT64; +typedef int64_t INT64; + +// declare function noreturn macro based on whether longjmp is enabled +#if LONGJMP_SUPPORTED +# define NORETURN_IF_LONGJMP NORETURN +#else +# define NORETURN_IF_LONGJMP +#endif + +#endif // _TPM_INCLUDE_PUBLIC_BASETYPES_H_ diff --git a/src/tpm2/TPMCmd/tpm/include/tpm_public/Capabilities.h b/src/tpm2/TPMCmd/tpm/include/tpm_public/Capabilities.h new file mode 100644 index 000000000..192117f4c --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/tpm_public/Capabilities.h @@ -0,0 +1,21 @@ +// SPDX-License-Identifier: BSD-2-Clause + +#ifndef _CAPABILITIES_H +#define _CAPABILITIES_H + +#define MAX_CAP_DATA (MAX_CAP_BUFFER - sizeof(TPM_CAP) - sizeof(UINT32)) +#define MAX_CAP_ALGS (MAX_CAP_DATA / sizeof(TPMS_ALG_PROPERTY)) +#define MAX_CAP_HANDLES (MAX_CAP_DATA / sizeof(TPM_HANDLE)) +#define MAX_CAP_CC (MAX_CAP_DATA / sizeof(TPM_CC)) +#define MAX_TPM_PROPERTIES (MAX_CAP_DATA / sizeof(TPMS_TAGGED_PROPERTY)) +#define MAX_PCR_PROPERTIES (MAX_CAP_DATA / sizeof(TPMS_TAGGED_PCR_SELECT)) +#define MAX_ECC_CURVES (MAX_CAP_DATA / sizeof(TPM_ECC_CURVE)) +#define MAX_TAGGED_POLICIES (MAX_CAP_DATA / sizeof(TPMS_TAGGED_POLICY)) +#define MAX_ACT_DATA (MAX_CAP_DATA / sizeof(TPMS_ACT_DATA)) +#define MAX_AC_CAPABILITIES (MAX_CAP_DATA / sizeof(TPMS_AC_OUTPUT)) +#if SEC_CHANNEL_SUPPORT +# define MAX_PUB_KEYS (MAX_CAP_DATA / sizeof(TPM2B_PUBLIC)) +# define MAX_SPDM_SESS_INFO (MAX_CAP_DATA / sizeof(TPMS_SPDM_SESSION_INFO)) +#endif // SEC_CHANNEL_SUPPORT + +#endif diff --git a/src/tpm2/TPMCmd/tpm/include/tpm_public/CompilerDependencies.h b/src/tpm2/TPMCmd/tpm/include/tpm_public/CompilerDependencies.h new file mode 100644 index 000000000..f05885454 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/tpm_public/CompilerDependencies.h @@ -0,0 +1,57 @@ +// SPDX-License-Identifier: BSD-2-Clause + +// This file contains the build switches. This contains switches for multiple +// versions of the crypto-library so some may not apply to your environment. +// + +#ifndef _COMPILER_DEPENDENCIES_H_ +#define _COMPILER_DEPENDENCIES_H_ + +#if defined(__GNUC__) +# include "CompilerDependencies_gcc.h" +#elif defined(_MSC_VER) +# include "CompilerDependencies_msvc.h" +#else +# error unexpected +#endif + +#include +#include + +// Things that are not defined should be defined as + +#ifndef NORETURN +# define NORETURN +#endif +#ifndef LIB_EXPORT +# define LIB_EXPORT +#endif +#ifndef LIB_IMPORT +# define LIB_IMPORT +#endif +#ifndef _REDUCE_WARNING_LEVEL_ +# define _REDUCE_WARNING_LEVEL_(n) +#endif +#ifndef _NORMAL_WARNING_LEVEL_ +# define _NORMAL_WARNING_LEVEL_ +#endif +#ifndef NOT_REFERENCED +# define NOT_REFERENCED(x) ((void)(x)) +#endif + +#ifdef _POSIX_ +typedef int SOCKET; +#endif + +#if !defined(TPM_STATIC_ASSERT) || !defined(COMPILER_CHECKS) +# error Expect definitions of COMPILER_CHECKS and TPM_STATIC_ASSERT +#elif COMPILER_CHECKS +// pre static_assert static_assert +# define MUST_BE(e) TPM_STATIC_ASSERT(e) + +#else +// intentionally disabled, fine. +# define MUST_BE(e) +#endif + +#endif // _COMPILER_DEPENDENCIES_H_ diff --git a/src/tpm2/TPMCmd/tpm/include/tpm_public/CompilerDependencies_gcc.h b/src/tpm2/TPMCmd/tpm/include/tpm_public/CompilerDependencies_gcc.h new file mode 100644 index 000000000..d630f34c4 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/tpm_public/CompilerDependencies_gcc.h @@ -0,0 +1,77 @@ +// SPDX-License-Identifier: BSD-2-Clause + +// This file contains compiler specific switches. +// These definitions are for the GCC compiler +// + +#ifndef _COMPILER_DEPENDENCIES_GCC_H_ +#define _COMPILER_DEPENDENCIES_GCC_H_ + +#if !defined(__GNUC__) +# error CompilerDependencies_gcc.h included for wrong compiler +#endif + +// silence specific GCC errors +#pragma GCC diagnostic push +// don't warn on unused local typedefs, they are used as a +// cross-compiler static_assert +#pragma GCC diagnostic ignored "-Wunused-local-typedefs" + +// This is needed when compiling against OpenSSL 3.0, as the Ossl bindings use: +// - EC_POINT_set_affine_coordinates_GFp / EC_POINTs_mul +// - AES_set_encrypt_key / AES_encrypt +// - Camellia_set_key / Camellia_encrypt +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" + +#undef _MSC_VER +#undef WIN32 + +#ifndef WINAPI +# define WINAPI +#endif +#ifndef __pragma +# define __pragma(x) +#endif + /* libtpms added begin */ +#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2) +# define REVERSE_ENDIAN_16(_Number) __builtin_bswap16(_Number) +# define REVERSE_ENDIAN_32(_Number) __builtin_bswap32(_Number) +# define REVERSE_ENDIAN_64(_Number) __builtin_bswap64(_Number) +#else +# if defined __linux__ || defined __CYGWIN__ +# include +# define REVERSE_ENDIAN_16(_Number) bswap_16(_Number) +# define REVERSE_ENDIAN_32(_Number) bswap_32(_Number) +# define REVERSE_ENDIAN_64(_Number) bswap_64(_Number) +# elif defined __OpenBSD__ +# include +# define REVERSE_ENDIAN_16(_Number) swap16(_Number) +# define REVERSE_ENDIAN_32(_Number) swap32(_Number) +# define REVERSE_ENDIAN_64(_Number) swap64(_Number) +# elif defined __APPLE__ +# include +# define REVERSE_ENDIAN_16(_Number) _OSSwapInt16(_Number) +# define REVERSE_ENDIAN_32(_Number) _OSSwapInt32(_Number) +# define REVERSE_ENDIAN_64(_Number) _OSSwapInt64(_Number) +# elif defined __FreeBSD__ +# include +# define REVERSE_ENDIAN_16(_Number) bswap16(_Number) +# define REVERSE_ENDIAN_32(_Number) bswap32(_Number) +# define REVERSE_ENDIAN_64(_Number) bswap64(_Number) +# else +# error Unsupported OS +# endif +#endif + /* libtpms added end */ + +#define NORETURN __attribute__((noreturn)) + +#define TPM_INLINE inline __attribute__((always_inline)) + +#ifdef __cplusplus +// c++ needed for google test +# define TPM_STATIC_ASSERT(e) static_assert(e, "static assert") +#else +# define TPM_STATIC_ASSERT(e) _Static_assert(e, "static assert") +#endif +#endif // _COMPILER_DEPENDENCIES_H_ diff --git a/src/tpm2/TPMCmd/tpm/include/tpm_public/CompilerDependencies_msvc.h b/src/tpm2/TPMCmd/tpm/include/tpm_public/CompilerDependencies_msvc.h new file mode 100644 index 000000000..ce654bb9f --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/tpm_public/CompilerDependencies_msvc.h @@ -0,0 +1,66 @@ +// SPDX-License-Identifier: BSD-2-Clause + +// This file contains compiler specific switches. +// These definitions are for the Microsoft compiler +// + +#ifndef _COMPILER_DEPENDENCIES_MSVC_H_ +#define _COMPILER_DEPENDENCIES_MSVC_H_ + +#if !defined(_MSC_VER) +# error CompilerDependencies_msvc.h included for wrong compiler +#endif + +// Endian conversion for aligned structures +#define REVERSE_ENDIAN_16(_Number) _byteswap_ushort(_Number) +#define REVERSE_ENDIAN_32(_Number) _byteswap_ulong(_Number) +#define REVERSE_ENDIAN_64(_Number) _byteswap_uint64(_Number) + +// Avoid compiler warning for in line of stdio (or not) +//#define _NO_CRT_STDIO_INLINE + +// This macro is used to handle LIB_EXPORT of function and variable names in lieu +// of a .def file. Visual Studio requires that functions be explicitly exported and +// imported. +#ifdef TPM_AS_DLL +# define LIB_EXPORT __declspec(dllexport) // VS compatible version +# define LIB_IMPORT __declspec(dllimport) +#else +// building static libraries +# define LIB_EXPORT +# define LIB_IMPORT +#endif + +#define TPM_INLINE inline + +// This is defined to indicate a function that does not return. Microsoft compilers +// do not support the _Noreturn function parameter. +#define NORETURN __declspec(noreturn) +#if _MSC_VER >= 1400 // SAL processing when needed +# include +#endif + +// # ifdef _WIN64 +// # define _INTPTR 2 +// # else +// # define _INTPTR 1 +// # endif + +#define NOT_REFERENCED(x) ((void)(x)) + +// Lower the compiler error warning for system include +// files. They tend not to be that clean and there is no +// reason to sort through all the spurious errors that they +// generate when the normal error level is set to /Wall +#define _REDUCE_WARNING_LEVEL_(n) __pragma(warning(push, n)) +// Restore the compiler warning level +#define _NORMAL_WARNING_LEVEL_ __pragma(warning(pop)) + +#ifdef TPM_STATIC_ASSERT +# error TPM_STATIC_ASSERT already defined +#endif + +// MSVC: failure results in error C2118: negative subscript error +#define TPM_STATIC_ASSERT(e) typedef char __C_ASSERT__[(e) ? 1 : -1] + +#endif // _COMPILER_DEPENDENCIES_MSVC_H_ diff --git a/src/tpm2/GpMacros.h b/src/tpm2/TPMCmd/tpm/include/tpm_public/GpMacros.h similarity index 68% rename from src/tpm2/GpMacros.h rename to src/tpm2/TPMCmd/tpm/include/tpm_public/GpMacros.h index bc62d4ae3..1f316af91 100644 --- a/src/tpm2/GpMacros.h +++ b/src/tpm2/TPMCmd/tpm/include/tpm_public/GpMacros.h @@ -1,62 +1,4 @@ -/********************************************************************************/ -/* */ -/* This file is a collection of miscellaneous macros. */ -/* 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 - 2024 */ -/* */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause //** Introduction // This file is a collection of miscellaneous macros. @@ -69,7 +11,8 @@ #endif #include "endian_swap.h" -#include "VendorInfo.h" +#include +#include //** For Self-test // These macros are used in CryptUtil to invoke the incremental self test. @@ -91,23 +34,28 @@ # define FUNCTION_NAME __FUNCTION__ #endif -#if defined(FAIL_TRACE) && FAIL_TRACE != 0 -# define CODELOCATOR() FUNCTION_NAME, __LINE__ +// CODELOCATOR, if defined, returns a 64-bit vendor-defined value that indicates where +// an event has occurred in the program. This is a placeholder in the +// case it is not defined. +#ifndef CODELOCATOR +# define CODELOCATOR() (0ull) +#endif + +// Use no Parens in this macro value because it is pasted into a function call below +#if defined(FAIL_TRACE) && FAIL_TRACE != NO +# define FAILLOCATOR() FUNCTION_NAME, __LINE__, CODELOCATOR() #else // !FAIL_TRACE -// if provided, use the definition of CODELOCATOR from TpmConfiguration so -// implementor can customize this. -# ifndef CODELOCATOR -# define CODELOCATOR() 0 -# endif +# define FAILLOCATOR() CODELOCATOR() #endif // FAIL_TRACE -// SETFAILED calls TpmFail. It may or may not return based on the NO_LONGJMP flag. -// CODELOCATOR is a macro that expands to either one 64-bit value that encodes the -// location, or two parameters: Function Name and Line Number. -#define SETFAILED(errorCode) (TpmFail(CODELOCATOR(), errorCode)) +// SETFAILED calls EnterFailureMode. It may or may not return based on the +// LONGJMP_SUPPORTED flag. FAILLOCATOR is a macro that expands to either one +// 64-bit value that encodes the location, or two parameters: Function Name and +// Line Number. +#define SETFAILED(errorCode) (EnterFailureMode(FAILLOCATOR(), errorCode)) -// If implementation is using longjmp, then calls to TpmFail() will never -// return. However, without longjmp facility, TpmFail will return while most of +// If implementation is using longjmp, then calls to EnterFailureMode() will never +// return. However, without longjmp facility, EnterFailureMode will return while most of // the code currently expects FAIL() calls to immediately abort the current // command. If they don't, some commands return success instead of failure. The // family of macros below are provided to allow the code to be modified to @@ -131,22 +79,19 @@ // // The TPM library was originally written with a lot of error checking omitted, // which means code occurring after a FAIL macro may not expect to be called -// when the TPM is in failure mode. When NO_LONGJMP is false (the system has a -// longjmp API), then none of that code is executed because the sample platform -// sets up longjmp before calling ExecuteCommand. However, in the NO_LONGJMP -// case, code following a FAIL or FAIL_NORET macro will get run. The -// conservative assumption is that code is untested and may be unsafe in such a -// situation. FAIL_NORET can replace FAIL when the code has been reviewed to -// ensure the post-FAIL code is safe. Of course, this is a point-in-time -// assertion that is only true when the FAIL_NORET macro is first inserted; -// hence it is better to use one of the early-exit macros to immediately return. -// However, the necessary return-code plumbing may be large and FAIL/FAIL_NORET -// are provided to support gradual improvement over time. - -#ifndef NO_LONGJMP -// has longjmp -// necesary to reference Exit, even though the code is no-return -# define TPM_FAIL_RETURN NORETURN void +// when the TPM is in failure mode. When LONGJMP_SUPPORTED is true (the system +// has a longjmp API), then none of that code is executed because the sample +// platform sets up longjmp before calling ExecuteCommand. However, in the +// !LONGJMP_SUPPORTED case, code following a FAIL or FAIL_NORET macro will get +// run. The conservative assumption is that code is untested and may be unsafe +// in such a situation. FAIL_NORET can replace FAIL when the code has been +// reviewed to ensure the post-FAIL code is safe. Of course, this is a +// point-in-time assertion that is only true when the FAIL_NORET macro is first +// inserted; hence it is better to use one of the early-exit macros to +// immediately return. However, the necessary return-code plumbing may be large +// and FAIL/FAIL_NORET are provided to support gradual improvement over time. + +#if LONGJMP_SUPPORTED // see discussion above about FAIL/FAIL_NORET # define FAIL(failCode) SETFAILED(failCode) @@ -163,9 +108,7 @@ goto Exit; \ } while(0) -#else // NO_LONGJMP -// no longjmp service is available -# define TPM_FAIL_RETURN void +#else // !LONGJMP_SUPPORTED // This macro is provided for existing code and should not be used in new code. // see discussion above. @@ -208,7 +151,7 @@ goto Exit; \ } while(0) -#endif +#endif // !LONGJMP_SUPPORTED // This macro tests that a condition is TRUE and puts the TPM into failure mode // if it is not. If longjmp is being used, then the macro makes a call from @@ -241,7 +184,7 @@ #define VERIFY_RC(rc) \ do \ { \ - if(g_inFailureMode) \ + if(_plat__InFailureMode()) \ { \ return TPM_RC_FAILURE; \ } \ @@ -255,7 +198,7 @@ #define VERIFY_NOT_FAILED() \ do \ { \ - if(g_inFailureMode) \ + if(_plat__InFailureMode()) \ { \ return TPM_RC_FAILURE; \ } \ @@ -265,7 +208,7 @@ #define VERIFY_RC_VOID(rc) \ do \ { \ - if(g_inFailureMode) \ + if(_plat__InFailureMode()) \ { \ return; \ } \ @@ -300,10 +243,10 @@ #define VERIFY_CRYPTO_OR_NULL(fn) VERIFY((fn), FATAL_ERROR_CRYPTO, NULL) // these VERIFY_CRYPTO macros all set a result value and goto Exit -#define VERIFY_CRYPTO_OR_EXIT(fn, returnVar, returnCode) \ +#define VERIFY_CRYPTO_OR_EXIT_GENERIC(fn, returnVar, returnCode) \ VERIFY_OR_EXIT(fn, FATAL_ERROR_CRYPTO, returnVar, returnCode); -// these VERIFY_CRYPTO_OR_EXIT functions assume the return value variable is +// these VERIFY_CRYPTO_OR_EXIT_* functions assume the return value variable is // named retVal #define VERIFY_CRYPTO_OR_EXIT_RC(fn) \ VERIFY_CRYPTO_OR_EXIT_GENERIC(fn, retVal, TPM_RC_FAILURE) @@ -321,14 +264,24 @@ } \ } while(0) -#if(defined EMPTY_ASSERT) && (EMPTY_ASSERT != NO) +// pAsserts can assertions that can be compiled out. +// unlike VERIFY which is always run. +// The pAssert macros set failure mode and set the error code +// to FATAL_ERROR_ASSERT. +#if (defined EMPTY_ASSERT) && (EMPTY_ASSERT != NO) # define pAssert(a) ((void)0) +# define pAssert_ZERO(a) +# define pAssert_RC(a) +# define pAssert_BOOL(a) +# define pAssert_NULL(a) +# define pAssert_NORET(a) +# define pAssert_VOID_OK(a) #else # define pAssert(a) \ do \ { \ if(!(a)) \ - FAIL(FATAL_ERROR_PARAMETER); \ + FAIL(FATAL_ERROR_ASSERT); \ } while(0) # define pAssert_ZERO(a) \ @@ -380,6 +333,11 @@ #endif +// pAssert_SKIPPED indicates a pAssert that was left as-is on purpose. +// because the code is dead/unsupported, or the work is left for a future +// review. +#define pAssert_SKIPPED(a) pAssert(a) + // These macros are commonly used in the "Crypt" code as a way to keep listings from // getting too long. This is not to save paper but to allow one to see more // useful stuff on the screen at any given time. Neither macro sets failure mode. @@ -390,13 +348,13 @@ goto Exit; \ } while(0) -// braces are necessary for this usage: +// The do loop is to prevent confusion in cases such as this: // if (y) // GOTO_ERROR_UNLESS(x) // else ... -// without braces the else would attach to the GOTO macro instead of the -// outer if statement; given the amount of TPM code that doesn't use braces on -// if statements, this is a live risk. +// without braces or the do statement, the else would attach to the GOTO macro +// instead of the outer if statement; given the amount of TPM code that doesn't +// use braces on if statements, this is a live risk. #define GOTO_ERROR_UNLESS(_X) \ do \ { \ @@ -404,10 +362,8 @@ goto Error; \ } while(0) -#include "MinMax.h" - #ifndef IsOdd -# define IsOdd(a) (((a)&1) != 0) +# define IsOdd(a) (((a) & 1) != 0) #endif #ifndef BITS_TO_BYTES @@ -444,28 +400,11 @@ // at least once every 292,471,208 years rather than once every 584,942,417 years. #define EXPIRATION_BIT ((UINT64)1 << 63) -// Check for consistency of the bit ordering of bit fields -#if BIG_ENDIAN_TPM && MOST_SIGNIFICANT_BIT_0 && USE_BIT_FIELD_STRUCTURES -# error "Settings not consistent" -#endif - -// These macros are used to handle the variation in handling of bit fields. If -#if USE_BIT_FIELD_STRUCTURES // The default, old version, with bit fields -# define IS_ATTRIBUTE(a, type, b) ((a.b) != 0) -# define SET_ATTRIBUTE(a, type, b) (a.b = SET) -# define CLEAR_ATTRIBUTE(a, type, b) (a.b = CLEAR) -# define GET_ATTRIBUTE(a, type, b) (a.b) -# define TPMA_ZERO_INITIALIZER() \ - { \ - 0 \ - } -#else -# define IS_ATTRIBUTE(a, type, b) ((a & type##_##b) != 0) -# define SET_ATTRIBUTE(a, type, b) (a |= type##_##b) -# define CLEAR_ATTRIBUTE(a, type, b) (a &= ~type##_##b) -# define GET_ATTRIBUTE(a, type, b) (type)((a & type##_##b) >> type##_##b##_SHIFT) -# define TPMA_ZERO_INITIALIZER() (0) -#endif +#define IS_ATTRIBUTE(a, type, b) ((a & type##_##b) != 0) +#define SET_ATTRIBUTE(a, type, b) (a |= type##_##b) +#define CLEAR_ATTRIBUTE(a, type, b) (a &= ~type##_##b) +#define GET_ATTRIBUTE(a, type, b) (type)((a & type##_##b) >> type##_##b##_SHIFT) +#define TPMA_ZERO_INITIALIZER() (0) // These macros determine if the values in this file are referenced or instanced. // Global.c defines GLOBAL_C so all the values in this file will be instanced in @@ -495,6 +434,6 @@ // and that is a UINT64. So, this is an invariant value #define CONTEXT_COUNTER UINT64 -#include "TpmCalculatedAttributes.h" +#include "tpm_public/TpmCalculatedAttributes.h" #endif // GP_MACROS_H diff --git a/src/tpm2/TPMCmd/tpm/include/tpm_public/MinMax.h b/src/tpm2/TPMCmd/tpm/include/tpm_public/MinMax.h new file mode 100644 index 000000000..b108beaf9 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/tpm_public/MinMax.h @@ -0,0 +1,18 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +#ifndef _MIN_MAX_H_ +#define _MIN_MAX_H_ + +#ifndef MAX +# define MAX(a, b) ((a) > (b) ? (a) : (b)) +#endif +#ifndef MIN +# define MIN(a, b) ((a) < (b) ? (a) : (b)) +#endif + +#ifndef SIZEOF_MEMBER +# define SIZEOF_MEMBER(type, member) sizeof(((type*)0)->member) +#endif + +#endif // _MIN_MAX_H_ diff --git a/src/tpm2/TPMCmd/tpm/include/tpm_public/TPMB.h b/src/tpm2/TPMCmd/tpm/include/tpm_public/TPMB.h new file mode 100644 index 000000000..fdc570a91 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/tpm_public/TPMB.h @@ -0,0 +1,50 @@ +// SPDX-License-Identifier: BSD-2-Clause + +// +// This file contains extra TPM2B structures +// + +#ifndef _TPMB_H +#define _TPMB_H + +#include + +//*** Size Types +// These types are used to differentiate the two different size values used. +// +// NUMBYTES is used when a size is a number of bytes (usually a TPM2B) +typedef UINT16 NUMBYTES; + +// TPM2B Types +typedef struct +{ + NUMBYTES size; + BYTE buffer[1]; +} TPM2B, *P2B; +typedef const TPM2B* PC2B; + +// This macro helps avoid having to type in the structure in order to create +// a new TPM2B type that is used in a function. +#define TPM2B_TYPE(name, bytes) \ + typedef union \ + { \ + struct \ + { \ + 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. +// This lets the user of the label add their terminating 0. This method +// is chosen so that existing code that provides a label will continue +// to work correctly. + +// Macro to instance and initialize a TPM2B value +#define TPM2B_INIT(TYPE, name) TPM2B_##TYPE name = {sizeof(name.t.buffer), {0}} + +#define TPM2B_BYTE_VALUE(bytes) TPM2B_TYPE(bytes##_BYTE_VALUE, bytes) + +#endif diff --git a/src/tpm2/TpmAlgorithmDefines.h b/src/tpm2/TPMCmd/tpm/include/tpm_public/TpmAlgorithmDefines.h similarity index 72% rename from src/tpm2/TpmAlgorithmDefines.h rename to src/tpm2/TPMCmd/tpm/include/tpm_public/TpmAlgorithmDefines.h index e03030a9d..1dfab9ea7 100644 --- a/src/tpm2/TpmAlgorithmDefines.h +++ b/src/tpm2/TPMCmd/tpm/include/tpm_public/TpmAlgorithmDefines.h @@ -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 @@ -64,9 +6,9 @@ #ifndef _TPM_INCLUDE_PRIVATE_TPMALGORITHMDEFINES_H_ #define _TPM_INCLUDE_PRIVATE_TPMALGORITHMDEFINES_H_ -#include "TpmProfile.h" -#include "MinMax.h" -#include "TPMB.h" +#include +#include "tpm_public/MinMax.h" +#include "tpm_public/TPMB.h" #if ALG_ECC // Table "Defines for NIST_P192 ECC Values" (TCG Algorithm Registry) @@ -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 \ diff --git a/src/tpm2/TpmCalculatedAttributes.h b/src/tpm2/TPMCmd/tpm/include/tpm_public/TpmCalculatedAttributes.h similarity index 65% rename from src/tpm2/TpmCalculatedAttributes.h rename to src/tpm2/TPMCmd/tpm/include/tpm_public/TpmCalculatedAttributes.h index e50336d70..c9541c1fb 100644 --- a/src/tpm2/TpmCalculatedAttributes.h +++ b/src/tpm2/TPMCmd/tpm/include/tpm_public/TpmCalculatedAttributes.h @@ -1,68 +1,10 @@ -/********************************************************************************/ -/* */ -/* */ -/* 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 #ifndef _TPM_CALCULATED_ATTRIBUTES_H_ #define _TPM_CALCULATED_ATTRIBUTES_H_ -#include "TpmAlgorithmDefines.h" -#include "GpMacros.h" +#include "tpm_public/TpmAlgorithmDefines.h" +#include "tpm_public/GpMacros.h" #define JOIN(x, y) x##y #define JOIN3(x, y, z) x##y##z diff --git a/src/tpm2/TpmTypes.h b/src/tpm2/TPMCmd/tpm/include/tpm_public/TpmTypes.h similarity index 68% rename from src/tpm2/TpmTypes.h rename to src/tpm2/TPMCmd/tpm/include/tpm_public/TpmTypes.h index 9968573df..9decf0580 100644 --- a/src/tpm2/TpmTypes.h +++ b/src/tpm2/TPMCmd/tpm/include/tpm_public/TpmTypes.h @@ -1,62 +1,4 @@ -/********************************************************************************/ -/* */ -/* TPM Part 2 Headers */ -/* 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 - 2024 */ -/* */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause // FILE GENERATED BY TpmExtractCode: DO NOT EDIT @@ -67,10 +9,10 @@ #ifndef MAX_CAP_BUFFER # error MAX_CAP_BUFFER must be defined before this file so it can calculate maximum capability sizes #endif -#include "Capabilities.h" -#include "TpmAlgorithmDefines.h" -#include "TpmCalculatedAttributes.h" -#include "GpMacros.h" +#include "tpm_public/Capabilities.h" +#include "tpm_public/TpmAlgorithmDefines.h" +#include "tpm_public/TpmCalculatedAttributes.h" +#include "tpm_public/GpMacros.h" // Table "Definition of Types for Documentation Clarity" (Part 2: Structures) typedef UINT32 TPM_ALGORITHM_ID; @@ -361,9 +303,10 @@ typedef UINT32 TPM_CC; #define TPM_CC_NV_DefineSpace2 (TPM_CC)(0x0000019D) #define TPM_CC_NV_ReadPublic2 (TPM_CC)(0x0000019E) #define TPM_CC_SetCapability (TPM_CC)(0x0000019F) -#define TPM_CC_LAST (TPM_CC)(0x0000019F) +#define TPM_CC_ReadOnlyControl (TPM_CC)(0x000001A0) +#define TPM_CC_PolicyTransportSPDM (TPM_CC)(0x000001A1) +#define TPM_CC_LAST (TPM_CC)(0x000001A1) #define CC_VEND (TPM_CC)(0x20000000) -#define TPM_CC_Vendor_TCG_Test (TPM_CC)(0x20000000) // This large macro is needed to determine the maximum commandIndex. This value // is needed in order to size typdef'ed structures. As a consequence, the @@ -375,11 +318,11 @@ typedef UINT32 TPM_CC; // packed (only defined commands) or dense // (having entries for unimplemented commands). This overly large macro // computes the size of the array and sets some global constants -#if COMPRESSED_LISTS +#if COMPRESSED_LISTS // libtpms added begin # define ADD_FILL 0 #else # define ADD_FILL 1 -#endif +#endif // libtpms added end #define LIBRARY_COMMAND_ARRAY_SIZE \ (0 + (ADD_FILL || CC_NV_UndefineSpaceSpecial) /* 0x0000011F */ \ + (ADD_FILL || CC_EvictControl) /* 0x00000120 */ \ @@ -510,7 +453,13 @@ typedef UINT32 TPM_CC; + (ADD_FILL || CC_NV_DefineSpace2) /* 0x0000019D */ \ + (ADD_FILL || CC_NV_ReadPublic2) /* 0x0000019E */ \ + (ADD_FILL || CC_SetCapability) /* 0x0000019F */ \ + + (ADD_FILL || CC_ReadOnlyControl) /* 0x000001A0 */ \ + + (ADD_FILL || CC_PolicyTransportSPDM) /* 0x000001A1 */ \ ) +#if LIBRARY_COMMAND_ARRAY_SIZE == 0 +# error "No commands are enabled -- something is terribly wrong." +#endif + #define VENDOR_COMMAND_ARRAY_SIZE (CC_Vendor_TCG_Test) #define COMMAND_COUNT (LIBRARY_COMMAND_ARRAY_SIZE + VENDOR_COMMAND_ARRAY_SIZE) @@ -554,6 +503,7 @@ typedef UINT32 TPM_RC; #define TPM_RC_NEEDS_TEST (TPM_RC)(RC_VER1 + 0x053) #define TPM_RC_NO_RESULT (TPM_RC)(RC_VER1 + 0x054) #define TPM_RC_SENSITIVE (TPM_RC)(RC_VER1 + 0x055) +#define TPM_RC_READ_ONLY (TPM_RC)(RC_VER1 + 0x056) #define RC_MAX_FM0 (TPM_RC)(RC_VER1 + 0x07F) #define RC_FMT1 (TPM_RC)(0x080) #define TPM_RC_ASYMMETRIC (TPM_RC)(RC_FMT1 + 0x001) @@ -624,6 +574,8 @@ typedef UINT32 TPM_RC; #define TPM_RCS_ECC_POINT (TPM_RC)(RC_FMT1 + 0x027) #define TPM_RC_FW_LIMITED (TPM_RC)(RC_FMT1 + 0x028) #define TPM_RC_SVN_LIMITED (TPM_RC)(RC_FMT1 + 0x029) +#define TPM_RC_CHANNEL (TPM_RC)(RC_FMT1 + 0x030) +#define TPM_RC_CHANNEL_KEY (TPM_RC)(RC_FMT1 + 0x031) #define RC_WARN (TPM_RC)(0x900) #define TPM_RC_CONTEXT_GAP (TPM_RC)(RC_WARN + 0x001) #define TPM_RC_OBJECT_MEMORY (TPM_RC)(RC_WARN + 0x002) @@ -738,21 +690,23 @@ typedef UINT8 TPM_SE; // Table "Definition of TPM_CAP Constants" (Part 2: Structures) typedef UINT32 TPM_CAP; -#define TYPE_OF_TPM_CAP UINT32 -#define TPM_CAP_FIRST (TPM_CAP)(0x00000000) -#define TPM_CAP_ALGS (TPM_CAP)(0x00000000) -#define TPM_CAP_HANDLES (TPM_CAP)(0x00000001) -#define TPM_CAP_COMMANDS (TPM_CAP)(0x00000002) -#define TPM_CAP_PP_COMMANDS (TPM_CAP)(0x00000003) -#define TPM_CAP_AUDIT_COMMANDS (TPM_CAP)(0x00000004) -#define TPM_CAP_PCRS (TPM_CAP)(0x00000005) -#define TPM_CAP_TPM_PROPERTIES (TPM_CAP)(0x00000006) -#define TPM_CAP_PCR_PROPERTIES (TPM_CAP)(0x00000007) -#define TPM_CAP_ECC_CURVES (TPM_CAP)(0x00000008) -#define TPM_CAP_AUTH_POLICIES (TPM_CAP)(0x00000009) -#define TPM_CAP_ACT (TPM_CAP)(0x0000000A) -#define TPM_CAP_LAST (TPM_CAP)(0x0000000A) -#define TPM_CAP_VENDOR_PROPERTY (TPM_CAP)(0x00000100) +#define TYPE_OF_TPM_CAP UINT32 +#define TPM_CAP_FIRST (TPM_CAP)(0x00000000) +#define TPM_CAP_ALGS (TPM_CAP)(0x00000000) +#define TPM_CAP_HANDLES (TPM_CAP)(0x00000001) +#define TPM_CAP_COMMANDS (TPM_CAP)(0x00000002) +#define TPM_CAP_PP_COMMANDS (TPM_CAP)(0x00000003) +#define TPM_CAP_AUDIT_COMMANDS (TPM_CAP)(0x00000004) +#define TPM_CAP_PCRS (TPM_CAP)(0x00000005) +#define TPM_CAP_TPM_PROPERTIES (TPM_CAP)(0x00000006) +#define TPM_CAP_PCR_PROPERTIES (TPM_CAP)(0x00000007) +#define TPM_CAP_ECC_CURVES (TPM_CAP)(0x00000008) +#define TPM_CAP_AUTH_POLICIES (TPM_CAP)(0x00000009) +#define TPM_CAP_ACT (TPM_CAP)(0x0000000A) +#define TPM_CAP_PUB_KEYS (TPM_CAP)(0x0000000B) +#define TPM_CAP_SPDM_SESSION_INFO (TPM_CAP)(0x0000000C) +#define TPM_CAP_LAST (TPM_CAP)(0x0000000C) +#define TPM_CAP_VENDOR_PROPERTY (TPM_CAP)(0x00000100) // Table "Definition of TPM_PT Constants" (Part 2: Structures) typedef UINT32 TPM_PT; @@ -981,6 +935,11 @@ typedef TPM_HANDLE TPM_HC; #define AC_FIRST (TPM_HC)((HR_AC + 0)) #define AC_LAST (TPM_HC)((HR_AC + 0x0000FFFF)) +// Table "Definition of TPM_PUB_KEY Constants" (Part 2: Structures) +typedef UINT32 TPM_PUB_KEY; +#define TYPE_OF_TPM_PUB_KEY UINT32 +#define TPM_PUB_KEY_TPM_SPDM_00 (TPM_PUB_KEY)(0x00000000) + // Table "Definition of TPMA_ALGORITHM Bits" (Part 2: Structures) #define TYPE_OF_TPMA_ALGORITHM UINT32 #define TPMA_ALGORITHM_TO_UINT32(a) (*((UINT32*)&(a))) @@ -992,62 +951,31 @@ typedef TPM_HANDLE TPM_HC; UINT32 x = BYTE_ARRAY_TO_UINT32(a); \ i = UINT32_TO_TPMA_ALGORITHM(x); \ } -#if USE_BIT_FIELD_STRUCTURES -typedef struct -{ - unsigned asymmetric : 1; - unsigned symmetric : 1; - unsigned hash : 1; - unsigned object : 1; - unsigned Reserved_bits_at_4 : 4; - unsigned signing : 1; - unsigned encrypting : 1; - unsigned method : 1; - unsigned Reserved_bits_at_11 : 21; -} TPMA_ALGORITHM; - -// Initializer for the bit-field structure -# define TPMA_ALGORITHM_INITIALIZER(asymmetric, \ - symmetric, \ - hash, \ - object, \ - bits_at_4, \ - signing, \ - encrypting, \ - method, \ - bits_at_11) \ - { \ - asymmetric, symmetric, hash, object, bits_at_4, signing, encrypting, \ - method, bits_at_11 \ - } -#else // USE_BIT_FIELD_STRUCTURES // This implements Table "Definition of TPMA_ALGORITHM Bits" (Part 2: Structures) using bit masking typedef UINT32 TPMA_ALGORITHM; -# define TPMA_ALGORITHM_asymmetric (TPMA_ALGORITHM)(1 << 0) -# define TPMA_ALGORITHM_symmetric (TPMA_ALGORITHM)(1 << 1) -# define TPMA_ALGORITHM_hash (TPMA_ALGORITHM)(1 << 2) -# define TPMA_ALGORITHM_object (TPMA_ALGORITHM)(1 << 3) -# define TPMA_ALGORITHM_signing (TPMA_ALGORITHM)(1 << 8) -# define TPMA_ALGORITHM_encrypting (TPMA_ALGORITHM)(1 << 9) -# define TPMA_ALGORITHM_method (TPMA_ALGORITHM)(1 << 10) +#define TPMA_ALGORITHM_asymmetric (TPMA_ALGORITHM)(1 << 0) +#define TPMA_ALGORITHM_symmetric (TPMA_ALGORITHM)(1 << 1) +#define TPMA_ALGORITHM_hash (TPMA_ALGORITHM)(1 << 2) +#define TPMA_ALGORITHM_object (TPMA_ALGORITHM)(1 << 3) +#define TPMA_ALGORITHM_signing (TPMA_ALGORITHM)(1 << 8) +#define TPMA_ALGORITHM_encrypting (TPMA_ALGORITHM)(1 << 9) +#define TPMA_ALGORITHM_method (TPMA_ALGORITHM)(1 << 10) #define TPMA_ALGORITHM_reserved 0xfffff8f0 // libtpms added // This is the initializer for a TPMA_ALGORITHM bit array. -# define TPMA_ALGORITHM_INITIALIZER(asymmetric, \ - symmetric, \ - hash, \ - object, \ - bits_at_4, \ - signing, \ - encrypting, \ - method, \ - bits_at_11) \ - (TPMA_ALGORITHM)((asymmetric << 0) + (symmetric << 1) + (hash << 2) \ - + (object << 3) + (signing << 8) + (encrypting << 9) \ - + (method << 10)) - -#endif // USE_BIT_FIELD_STRUCTURES +#define TPMA_ALGORITHM_INITIALIZER(asymmetric, \ + symmetric, \ + hash, \ + object, \ + bits_at_4, \ + signing, \ + encrypting, \ + method, \ + bits_at_11) \ + (TPMA_ALGORITHM)((asymmetric << 0) + (symmetric << 1) + (hash << 2) \ + + (object << 3) + (signing << 8) + (encrypting << 9) \ + + (method << 10)) // Table "Definition of TPMA_OBJECT Bits" (Part 2: Structures) #define TYPE_OF_TPMA_OBJECT UINT32 @@ -1060,50 +988,25 @@ typedef UINT32 TPMA_ALGORITHM; UINT32 x = BYTE_ARRAY_TO_UINT32(a); \ i = UINT32_TO_TPMA_OBJECT(x); \ } -#if USE_BIT_FIELD_STRUCTURES -typedef struct -{ - unsigned Reserved_bit_at_0 : 1; - unsigned fixedTPM : 1; - unsigned stClear : 1; - unsigned Reserved_bit_at_3 : 1; - unsigned fixedParent : 1; - unsigned sensitiveDataOrigin : 1; - unsigned userWithAuth : 1; - unsigned adminWithPolicy : 1; - unsigned firmwareLimited : 1; - unsigned svnLimited : 1; - unsigned noDA : 1; - unsigned encryptedDuplication : 1; - unsigned Reserved_bits_at_12 : 4; - unsigned restricted : 1; - unsigned decrypt : 1; - unsigned sign : 1; - unsigned x509sign : 1; - unsigned Reserved_bits_at_20 : 12; -} TPMA_OBJECT; - -#else // USE_BIT_FIELD_STRUCTURES // This implements Table "Definition of TPMA_OBJECT Bits" (Part 2: Structures) using bit masking typedef UINT32 TPMA_OBJECT; -# define TPMA_OBJECT_fixedTPM (TPMA_OBJECT)(1 << 1) -# define TPMA_OBJECT_stClear (TPMA_OBJECT)(1 << 2) -# define TPMA_OBJECT_fixedParent (TPMA_OBJECT)(1 << 4) -# define TPMA_OBJECT_sensitiveDataOrigin (TPMA_OBJECT)(1 << 5) -# define TPMA_OBJECT_userWithAuth (TPMA_OBJECT)(1 << 6) -# define TPMA_OBJECT_adminWithPolicy (TPMA_OBJECT)(1 << 7) -# define TPMA_OBJECT_firmwareLimited (TPMA_OBJECT)(1 << 8) -# define TPMA_OBJECT_svnLimited (TPMA_OBJECT)(1 << 9) -# define TPMA_OBJECT_noDA (TPMA_OBJECT)(1 << 10) -# define TPMA_OBJECT_encryptedDuplication (TPMA_OBJECT)(1 << 11) -# define TPMA_OBJECT_restricted (TPMA_OBJECT)(1 << 16) -# define TPMA_OBJECT_decrypt (TPMA_OBJECT)(1 << 17) -# define TPMA_OBJECT_sign (TPMA_OBJECT)(1 << 18) -# define TPMA_OBJECT_x509sign (TPMA_OBJECT)(1 << 19) -#define TPMA_OBJECT_reserved ((TPMA_OBJECT)0xfff0f009) // libtpms added - -#endif // USE_BIT_FIELD_STRUCTURES +#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) +#define TPMA_OBJECT_adminWithPolicy (TPMA_OBJECT)(1 << 7) +#define TPMA_OBJECT_firmwareLimited (TPMA_OBJECT)(1 << 8) +#define TPMA_OBJECT_svnLimited (TPMA_OBJECT)(1 << 9) +#define TPMA_OBJECT_noDA (TPMA_OBJECT)(1 << 10) +#define TPMA_OBJECT_encryptedDuplication (TPMA_OBJECT)(1 << 11) +#define TPMA_OBJECT_restricted (TPMA_OBJECT)(1 << 16) +#define TPMA_OBJECT_decrypt (TPMA_OBJECT)(1 << 17) +#define TPMA_OBJECT_sign (TPMA_OBJECT)(1 << 18) +#define TPMA_OBJECT_x509sign (TPMA_OBJECT)(1 << 19) +#define TPMA_OBJECT_reserved ((TPMA_OBJECT)0xfff0f009) // libtpms added // Table "Definition of TPMA_SESSION Bits" (Part 2: Structures) #define TYPE_OF_TPMA_SESSION UINT8 @@ -1116,55 +1019,23 @@ typedef UINT32 TPMA_OBJECT; UINT8 x = BYTE_ARRAY_TO_UINT8(a); \ i = UINT8_TO_TPMA_SESSION(x); \ } -#if USE_BIT_FIELD_STRUCTURES -typedef struct -{ - unsigned continueSession : 1; - unsigned auditExclusive : 1; - unsigned auditReset : 1; - unsigned Reserved_bits_at_3 : 2; - unsigned decrypt : 1; - unsigned encrypt : 1; - unsigned audit : 1; -} TPMA_SESSION; - -// Initializer for the bit-field structure -# define TPMA_SESSION_INITIALIZER(continuesession, \ - auditexclusive, \ - auditreset, \ - bits_at_3, \ - decrypt, \ - encrypt, \ - audit) \ - { \ - continuesession, auditexclusive, auditreset, bits_at_3, decrypt, encrypt, \ - audit \ - } -#else // USE_BIT_FIELD_STRUCTURES // This implements Table "Definition of TPMA_SESSION Bits" (Part 2: Structures) using bit masking typedef UINT8 TPMA_SESSION; -# define TPMA_SESSION_continueSession (TPMA_SESSION)(1 << 0) -# define TPMA_SESSION_auditExclusive (TPMA_SESSION)(1 << 1) -# define TPMA_SESSION_auditReset (TPMA_SESSION)(1 << 2) -# define TPMA_SESSION_decrypt (TPMA_SESSION)(1 << 5) -# define TPMA_SESSION_encrypt (TPMA_SESSION)(1 << 6) -# define TPMA_SESSION_audit (TPMA_SESSION)(1 << 7) +#define TPMA_SESSION_continueSession (TPMA_SESSION)(1 << 0) +#define TPMA_SESSION_auditExclusive (TPMA_SESSION)(1 << 1) +#define TPMA_SESSION_auditReset (TPMA_SESSION)(1 << 2) +#define TPMA_SESSION_decrypt (TPMA_SESSION)(1 << 5) +#define TPMA_SESSION_encrypt (TPMA_SESSION)(1 << 6) +#define TPMA_SESSION_audit (TPMA_SESSION)(1 << 7) #define TPMA_SESSION_reserved 0x18 // libtpms added // This is the initializer for a TPMA_SESSION bit array. -# define TPMA_SESSION_INITIALIZER(continuesession, \ - auditexclusive, \ - auditreset, \ - bits_at_3, \ - decrypt, \ - encrypt, \ - audit) \ - (TPMA_SESSION)((continuesession << 0) + (auditexclusive << 1) \ - + (auditreset << 2) + (decrypt << 5) + (encrypt << 6) \ - + (audit << 7)) - -#endif // USE_BIT_FIELD_STRUCTURES +#define TPMA_SESSION_INITIALIZER( \ + continuesession, auditexclusive, auditreset, bits_at_3, decrypt, encrypt, audit) \ + (TPMA_SESSION)((continuesession << 0) + (auditexclusive << 1) \ + + (auditreset << 2) + (decrypt << 5) + (encrypt << 6) \ + + (audit << 7)) // Table "Definition of TPMA_LOCALITY Bits" (Part 2: Structures) #define TYPE_OF_TPMA_LOCALITY UINT8 @@ -1177,44 +1048,22 @@ typedef UINT8 TPMA_SESSION; UINT8 x = BYTE_ARRAY_TO_UINT8(a); \ i = UINT8_TO_TPMA_LOCALITY(x); \ } -#if USE_BIT_FIELD_STRUCTURES -typedef struct -{ - unsigned TPM_LOC_ZERO : 1; - unsigned TPM_LOC_ONE : 1; - unsigned TPM_LOC_TWO : 1; - unsigned TPM_LOC_THREE : 1; - unsigned TPM_LOC_FOUR : 1; - unsigned Extended : 3; -} TPMA_LOCALITY; - -// Initializer for the bit-field structure -# define TPMA_LOCALITY_INITIALIZER( \ - tpm_loc_zero, tpm_loc_one, tpm_loc_two, tpm_loc_three, tpm_loc_four, extended) \ - { \ - tpm_loc_zero, tpm_loc_one, tpm_loc_two, tpm_loc_three, tpm_loc_four, \ - extended \ - } -#else // USE_BIT_FIELD_STRUCTURES // This implements Table "Definition of TPMA_LOCALITY Bits" (Part 2: Structures) using bit masking typedef UINT8 TPMA_LOCALITY; -# define TPMA_LOCALITY_TPM_LOC_ZERO (TPMA_LOCALITY)(1 << 0) -# define TPMA_LOCALITY_TPM_LOC_ONE (TPMA_LOCALITY)(1 << 1) -# define TPMA_LOCALITY_TPM_LOC_TWO (TPMA_LOCALITY)(1 << 2) -# define TPMA_LOCALITY_TPM_LOC_THREE (TPMA_LOCALITY)(1 << 3) -# define TPMA_LOCALITY_TPM_LOC_FOUR (TPMA_LOCALITY)(1 << 4) -# define TPMA_LOCALITY_Extended (TPMA_LOCALITY)(7 << 5) -# define TPMA_LOCALITY_Extended_SHIFT 5 +#define TPMA_LOCALITY_TPM_LOC_ZERO (TPMA_LOCALITY)(1 << 0) +#define TPMA_LOCALITY_TPM_LOC_ONE (TPMA_LOCALITY)(1 << 1) +#define TPMA_LOCALITY_TPM_LOC_TWO (TPMA_LOCALITY)(1 << 2) +#define TPMA_LOCALITY_TPM_LOC_THREE (TPMA_LOCALITY)(1 << 3) +#define TPMA_LOCALITY_TPM_LOC_FOUR (TPMA_LOCALITY)(1 << 4) +#define TPMA_LOCALITY_Extended (TPMA_LOCALITY)(7 << 5) +#define TPMA_LOCALITY_Extended_SHIFT 5 // This is the initializer for a TPMA_LOCALITY bit array. -# define TPMA_LOCALITY_INITIALIZER( \ - tpm_loc_zero, tpm_loc_one, tpm_loc_two, tpm_loc_three, tpm_loc_four, extended) \ - (TPMA_LOCALITY)((tpm_loc_zero << 0) + (tpm_loc_one << 1) + (tpm_loc_two << 2) \ - + (tpm_loc_three << 3) + (tpm_loc_four << 4) \ - + (extended << 5)) - -#endif // USE_BIT_FIELD_STRUCTURES +#define TPMA_LOCALITY_INITIALIZER( \ + tpm_loc_zero, tpm_loc_one, tpm_loc_two, tpm_loc_three, tpm_loc_four, extended) \ + (TPMA_LOCALITY)((tpm_loc_zero << 0) + (tpm_loc_one << 1) + (tpm_loc_two << 2) \ + + (tpm_loc_three << 3) + (tpm_loc_four << 4) + (extended << 5)) // Table "Definition of TPMA_PERMANENT Bits" (Part 2: Structures) #define TYPE_OF_TPMA_PERMANENT UINT32 @@ -1227,57 +1076,28 @@ typedef UINT8 TPMA_LOCALITY; UINT32 x = BYTE_ARRAY_TO_UINT32(a); \ i = UINT32_TO_TPMA_PERMANENT(x); \ } -#if USE_BIT_FIELD_STRUCTURES -typedef struct -{ - unsigned ownerAuthSet : 1; - unsigned endorsementAuthSet : 1; - unsigned lockoutAuthSet : 1; - unsigned Reserved_bits_at_3 : 5; - unsigned disableClear : 1; - unsigned inLockout : 1; - unsigned tpmGeneratedEPS : 1; - unsigned Reserved_bits_at_11 : 21; -} TPMA_PERMANENT; - -// Initializer for the bit-field structure -# define TPMA_PERMANENT_INITIALIZER(ownerauthset, \ - endorsementauthset, \ - lockoutauthset, \ - bits_at_3, \ - disableclear, \ - inlockout, \ - tpmgeneratedeps, \ - bits_at_11) \ - { \ - ownerauthset, endorsementauthset, lockoutauthset, bits_at_3, disableclear, \ - inlockout, tpmgeneratedeps, bits_at_11 \ - } -#else // USE_BIT_FIELD_STRUCTURES // This implements Table "Definition of TPMA_PERMANENT Bits" (Part 2: Structures) using bit masking typedef UINT32 TPMA_PERMANENT; -# define TPMA_PERMANENT_ownerAuthSet (TPMA_PERMANENT)(1 << 0) -# define TPMA_PERMANENT_endorsementAuthSet (TPMA_PERMANENT)(1 << 1) -# define TPMA_PERMANENT_lockoutAuthSet (TPMA_PERMANENT)(1 << 2) -# define TPMA_PERMANENT_disableClear (TPMA_PERMANENT)(1 << 8) -# define TPMA_PERMANENT_inLockout (TPMA_PERMANENT)(1 << 9) -# define TPMA_PERMANENT_tpmGeneratedEPS (TPMA_PERMANENT)(1 << 10) +#define TPMA_PERMANENT_ownerAuthSet (TPMA_PERMANENT)(1 << 0) +#define TPMA_PERMANENT_endorsementAuthSet (TPMA_PERMANENT)(1 << 1) +#define TPMA_PERMANENT_lockoutAuthSet (TPMA_PERMANENT)(1 << 2) +#define TPMA_PERMANENT_disableClear (TPMA_PERMANENT)(1 << 8) +#define TPMA_PERMANENT_inLockout (TPMA_PERMANENT)(1 << 9) +#define TPMA_PERMANENT_tpmGeneratedEPS (TPMA_PERMANENT)(1 << 10) // This is the initializer for a TPMA_PERMANENT bit array. -# define TPMA_PERMANENT_INITIALIZER(ownerauthset, \ - endorsementauthset, \ - lockoutauthset, \ - bits_at_3, \ - disableclear, \ - inlockout, \ - tpmgeneratedeps, \ - bits_at_11) \ - (TPMA_PERMANENT)((ownerauthset << 0) + (endorsementauthset << 1) \ - + (lockoutauthset << 2) + (disableclear << 8) \ - + (inlockout << 9) + (tpmgeneratedeps << 10)) - -#endif // USE_BIT_FIELD_STRUCTURES +#define TPMA_PERMANENT_INITIALIZER(ownerauthset, \ + endorsementauthset, \ + lockoutauthset, \ + bits_at_3, \ + disableclear, \ + inlockout, \ + tpmgeneratedeps, \ + bits_at_11) \ + (TPMA_PERMANENT)((ownerauthset << 0) + (endorsementauthset << 1) \ + + (lockoutauthset << 2) + (disableclear << 8) \ + + (inlockout << 9) + (tpmgeneratedeps << 10)) // Table "Definition of TPMA_STARTUP_CLEAR Bits" (Part 2: Structures) #define TYPE_OF_TPMA_STARTUP_CLEAR UINT32 @@ -1290,40 +1110,21 @@ typedef UINT32 TPMA_PERMANENT; UINT32 x = BYTE_ARRAY_TO_UINT32(a); \ i = UINT32_TO_TPMA_STARTUP_CLEAR(x); \ } -#if USE_BIT_FIELD_STRUCTURES -typedef struct -{ - unsigned phEnable : 1; - unsigned shEnable : 1; - unsigned ehEnable : 1; - unsigned phEnableNV : 1; - unsigned Reserved_bits_at_4 : 27; - unsigned orderly : 1; -} TPMA_STARTUP_CLEAR; - -// Initializer for the bit-field structure -# define TPMA_STARTUP_CLEAR_INITIALIZER( \ - phenable, shenable, ehenable, phenablenv, bits_at_4, orderly) \ - { \ - phenable, shenable, ehenable, phenablenv, bits_at_4, orderly \ - } -#else // USE_BIT_FIELD_STRUCTURES // This implements Table "Definition of TPMA_STARTUP_CLEAR Bits" (Part 2: Structures) using bit masking typedef UINT32 TPMA_STARTUP_CLEAR; -# define TPMA_STARTUP_CLEAR_phEnable (TPMA_STARTUP_CLEAR)(1 << 0) -# define TPMA_STARTUP_CLEAR_shEnable (TPMA_STARTUP_CLEAR)(1 << 1) -# define TPMA_STARTUP_CLEAR_ehEnable (TPMA_STARTUP_CLEAR)(1 << 2) -# define TPMA_STARTUP_CLEAR_phEnableNV (TPMA_STARTUP_CLEAR)(1 << 3) -# define TPMA_STARTUP_CLEAR_orderly (TPMA_STARTUP_CLEAR)((UINT32)1 << 31) // libtpms changed: UBSAN +#define TPMA_STARTUP_CLEAR_phEnable (TPMA_STARTUP_CLEAR)(1 << 0) +#define TPMA_STARTUP_CLEAR_shEnable (TPMA_STARTUP_CLEAR)(1 << 1) +#define TPMA_STARTUP_CLEAR_ehEnable (TPMA_STARTUP_CLEAR)(1 << 2) +#define TPMA_STARTUP_CLEAR_phEnableNV (TPMA_STARTUP_CLEAR)(1 << 3) +#define TPMA_STARTUP_CLEAR_readOnly (TPMA_STARTUP_CLEAR)(1 << 4) +#define TPMA_STARTUP_CLEAR_orderly (TPMA_STARTUP_CLEAR)((UINT32)1 << 31) // libtpms changed: UBSAN // This is the initializer for a TPMA_STARTUP_CLEAR bit array. -# define TPMA_STARTUP_CLEAR_INITIALIZER( \ - phenable, shenable, ehenable, phenablenv, bits_at_4, orderly) \ - (TPMA_STARTUP_CLEAR)((phenable << 0) + (shenable << 1) + (ehenable << 2) \ - + (phenablenv << 3) + ((UINT32)orderly << 31)) // libtpms chanegd: UBSAN - -#endif // USE_BIT_FIELD_STRUCTURES +#define TPMA_STARTUP_CLEAR_INITIALIZER( \ + phenable, shenable, ehenable, phenablenv, readonly, bits_at_5, orderly) \ + (TPMA_STARTUP_CLEAR)((phenable << 0) + (shenable << 1) + (ehenable << 2) \ + + (phenablenv << 3) + (readonly << 4) + ((UINT32)orderly << 31)) // libtpms changed: UBSAN // Table "Definition of TPMA_MEMORY Bits" (Part 2: Structures) #define TYPE_OF_TPMA_MEMORY UINT32 @@ -1336,33 +1137,16 @@ typedef UINT32 TPMA_STARTUP_CLEAR; UINT32 x = BYTE_ARRAY_TO_UINT32(a); \ i = UINT32_TO_TPMA_MEMORY(x); \ } -#if USE_BIT_FIELD_STRUCTURES -typedef struct -{ - unsigned sharedRAM : 1; - unsigned sharedNV : 1; - unsigned objectCopiedToRam : 1; - unsigned Reserved_bits_at_3 : 29; -} TPMA_MEMORY; - -// Initializer for the bit-field structure -# define TPMA_MEMORY_INITIALIZER(sharedram, sharednv, objectcopiedtoram, bits_at_3) \ - { \ - sharedram, sharednv, objectcopiedtoram, bits_at_3 \ - } -#else // USE_BIT_FIELD_STRUCTURES // This implements Table "Definition of TPMA_MEMORY Bits" (Part 2: Structures) using bit masking typedef UINT32 TPMA_MEMORY; -# define TPMA_MEMORY_sharedRAM (TPMA_MEMORY)(1 << 0) -# define TPMA_MEMORY_sharedNV (TPMA_MEMORY)(1 << 1) -# define TPMA_MEMORY_objectCopiedToRam (TPMA_MEMORY)(1 << 2) +#define TPMA_MEMORY_sharedRAM (TPMA_MEMORY)(1 << 0) +#define TPMA_MEMORY_sharedNV (TPMA_MEMORY)(1 << 1) +#define TPMA_MEMORY_objectCopiedToRam (TPMA_MEMORY)(1 << 2) // This is the initializer for a TPMA_MEMORY bit array. -# define TPMA_MEMORY_INITIALIZER(sharedram, sharednv, objectcopiedtoram, bits_at_3) \ - (TPMA_MEMORY)((sharedram << 0) + (sharednv << 1) + (objectcopiedtoram << 2)) - -#endif // USE_BIT_FIELD_STRUCTURES +#define TPMA_MEMORY_INITIALIZER(sharedram, sharednv, objectcopiedtoram, bits_at_3) \ + (TPMA_MEMORY)((sharedram << 0) + (sharednv << 1) + (objectcopiedtoram << 2)) // Table "Definition of TPMA_CC Bits" (Part 2: Structures) #define TYPE_OF_TPMA_CC UINT32 @@ -1374,63 +1158,32 @@ typedef UINT32 TPMA_MEMORY; UINT32 x = BYTE_ARRAY_TO_UINT32(a); \ i = UINT32_TO_TPMA_CC(x); \ } -#if USE_BIT_FIELD_STRUCTURES -typedef struct -{ - unsigned commandIndex : 16; - unsigned Reserved_bits_at_16 : 6; - unsigned nv : 1; - unsigned extensive : 1; - unsigned flushed : 1; - unsigned cHandles : 3; - unsigned rHandle : 1; - unsigned V : 1; - unsigned Reserved_bits_at_30 : 2; -} TPMA_CC; - -// Initializer for the bit-field structure -# define TPMA_CC_INITIALIZER(commandindex, \ - bits_at_16, \ - nv, \ - extensive, \ - flushed, \ - chandles, \ - rhandle, \ - v, \ - bits_at_30) \ - { \ - commandindex, bits_at_16, nv, extensive, flushed, chandles, rhandle, v, \ - bits_at_30 \ - } -#else // USE_BIT_FIELD_STRUCTURES // This implements Table "Definition of TPMA_CC Bits" (Part 2: Structures) using bit masking typedef TPM_CC TPMA_CC; -# define TPMA_CC_commandIndex (TPMA_CC)(0xFFFF << 0) -# define TPMA_CC_commandIndex_SHIFT 0 -# define TPMA_CC_nv (TPMA_CC)(1 << 22) -# define TPMA_CC_extensive (TPMA_CC)(1 << 23) -# define TPMA_CC_flushed (TPMA_CC)(1 << 24) -# define TPMA_CC_cHandles (TPMA_CC)(7 << 25) -# define TPMA_CC_cHandles_SHIFT 25 -# define TPMA_CC_rHandle (TPMA_CC)(1 << 28) -# define TPMA_CC_V (TPMA_CC)(1 << 29) -# define TPMA_CC_reserved 0xc03f0000 // libtpms added +#define TPMA_CC_commandIndex (TPMA_CC)(0xFFFF << 0) +#define TPMA_CC_commandIndex_SHIFT 0 +#define TPMA_CC_nv (TPMA_CC)(1 << 22) +#define TPMA_CC_extensive (TPMA_CC)(1 << 23) +#define TPMA_CC_flushed (TPMA_CC)(1 << 24) +#define TPMA_CC_cHandles (TPMA_CC)(7 << 25) +#define TPMA_CC_cHandles_SHIFT 25 +#define TPMA_CC_rHandle (TPMA_CC)(1 << 28) +#define TPMA_CC_V (TPMA_CC)(1 << 29) +#define TPMA_CC_reserved 0xc03f0000 // libtpms added // This is the initializer for a TPMA_CC bit array. -# define TPMA_CC_INITIALIZER(commandindex, \ - bits_at_16, \ - nv, \ - extensive, \ - flushed, \ - chandles, \ - rhandle, \ - v, \ - bits_at_30) \ - (TPMA_CC)((commandindex << 0) + (nv << 22) + (extensive << 23) \ - + (flushed << 24) + (chandles << 25) + (rhandle << 28) + (v << 29)) - -#endif // USE_BIT_FIELD_STRUCTURES +#define TPMA_CC_INITIALIZER(commandindex, \ + bits_at_16, \ + nv, \ + extensive, \ + flushed, \ + chandles, \ + rhandle, \ + v, \ + bits_at_30) \ + (TPMA_CC)((commandindex << 0) + (nv << 22) + (extensive << 23) + (flushed << 24) \ + + (chandles << 25) + (rhandle << 28) + (v << 29)) // Table "Definition of TPMA_MODES Bits" (Part 2: Structures) #define TYPE_OF_TPMA_MODES UINT32 @@ -1443,37 +1196,18 @@ typedef TPM_CC TPMA_CC; UINT32 x = BYTE_ARRAY_TO_UINT32(a); \ i = UINT32_TO_TPMA_MODES(x); \ } -#if USE_BIT_FIELD_STRUCTURES -typedef struct -{ - unsigned FIPS_140_2 : 1; - unsigned FIPS_140_3 : 1; - unsigned FIPS_140_3_INDICATOR : 2; - unsigned Reserved_bits_at_4 : 28; -} TPMA_MODES; - -// Initializer for the bit-field structure -# define TPMA_MODES_INITIALIZER( \ - fips_140_2, fips_140_3, fips_140_3_indicator, bits_at_4) \ - { \ - fips_140_2, fips_140_3, fips_140_3_indicator, bits_at_4 \ - } -#else // USE_BIT_FIELD_STRUCTURES // This implements Table "Definition of TPMA_MODES Bits" (Part 2: Structures) using bit masking typedef UINT32 TPMA_MODES; -# define TPMA_MODES_FIPS_140_2 (TPMA_MODES)(1 << 0) -# define TPMA_MODES_FIPS_140_3 (TPMA_MODES)(1 << 1) -# define TPMA_MODES_FIPS_140_3_INDICATOR (TPMA_MODES)(3 << 2) -# define TPMA_MODES_FIPS_140_3_INDICATOR_SHIFT 2 +#define TPMA_MODES_FIPS_140_2 (TPMA_MODES)(1 << 0) +#define TPMA_MODES_FIPS_140_3 (TPMA_MODES)(1 << 1) +#define TPMA_MODES_FIPS_140_3_INDICATOR (TPMA_MODES)(3 << 2) +#define TPMA_MODES_FIPS_140_3_INDICATOR_SHIFT 2 // This is the initializer for a TPMA_MODES bit array. -# define TPMA_MODES_INITIALIZER( \ - fips_140_2, fips_140_3, fips_140_3_indicator, bits_at_4) \ - (TPMA_MODES)( \ - (fips_140_2 << 0) + (fips_140_3 << 1) + (fips_140_3_indicator << 2)) - -#endif // USE_BIT_FIELD_STRUCTURES +#define TPMA_MODES_INITIALIZER( \ + fips_140_2, fips_140_3, fips_140_3_indicator, bits_at_4) \ + (TPMA_MODES)((fips_140_2 << 0) + (fips_140_3 << 1) + (fips_140_3_indicator << 2)) // Table "Definition of TPMA_X509_KEY_USAGE Bits" (Part 2: Structures) #define TYPE_OF_TPMA_X509_KEY_USAGE UINT32 @@ -1487,68 +1221,35 @@ typedef UINT32 TPMA_MODES; i = UINT32_TO_TPMA_X509_KEY_USAGE(x); \ } #define TPMA_X509_KEY_USAGE_ALLOWED_BITS (0xff800000) -#if USE_BIT_FIELD_STRUCTURES -typedef struct -{ - unsigned Reserved_bits_at_0 : 23; - unsigned decipherOnly : 1; - unsigned encipherOnly : 1; - unsigned cRLSign : 1; - unsigned keyCertSign : 1; - unsigned keyAgreement : 1; - unsigned dataEncipherment : 1; - unsigned keyEncipherment : 1; - unsigned nonrepudiation : 1; - unsigned digitalSignature : 1; -} TPMA_X509_KEY_USAGE; - -// Initializer for the bit-field structure -# define TPMA_X509_KEY_USAGE_INITIALIZER(bits_at_0, \ - decipheronly, \ - encipheronly, \ - crlsign, \ - keycertsign, \ - keyagreement, \ - dataencipherment, \ - keyencipherment, \ - nonrepudiation, \ - digitalsignature) \ - { \ - bits_at_0, decipheronly, encipheronly, crlsign, keycertsign, keyagreement, \ - dataencipherment, keyencipherment, nonrepudiation, digitalsignature \ - } -#else // USE_BIT_FIELD_STRUCTURES // This implements Table "Definition of TPMA_X509_KEY_USAGE Bits" (Part 2: Structures) using bit masking typedef UINT32 TPMA_X509_KEY_USAGE; -# define TPMA_X509_KEY_USAGE_decipherOnly (TPMA_X509_KEY_USAGE)(1 << 23) -# define TPMA_X509_KEY_USAGE_encipherOnly (TPMA_X509_KEY_USAGE)(1 << 24) -# define TPMA_X509_KEY_USAGE_cRLSign (TPMA_X509_KEY_USAGE)(1 << 25) -# define TPMA_X509_KEY_USAGE_keyCertSign (TPMA_X509_KEY_USAGE)(1 << 26) -# define TPMA_X509_KEY_USAGE_keyAgreement (TPMA_X509_KEY_USAGE)(1 << 27) -# define TPMA_X509_KEY_USAGE_dataEncipherment (TPMA_X509_KEY_USAGE)(1 << 28) -# define TPMA_X509_KEY_USAGE_keyEncipherment (TPMA_X509_KEY_USAGE)(1 << 29) -# define TPMA_X509_KEY_USAGE_nonrepudiation (TPMA_X509_KEY_USAGE)(1 << 30) -# define TPMA_X509_KEY_USAGE_digitalSignature (TPMA_X509_KEY_USAGE)((UINT32)1 << 31) // libtpms changed: UBSAN +#define TPMA_X509_KEY_USAGE_decipherOnly (TPMA_X509_KEY_USAGE)(1 << 23) +#define TPMA_X509_KEY_USAGE_encipherOnly (TPMA_X509_KEY_USAGE)(1 << 24) +#define TPMA_X509_KEY_USAGE_cRLSign (TPMA_X509_KEY_USAGE)(1 << 25) +#define TPMA_X509_KEY_USAGE_keyCertSign (TPMA_X509_KEY_USAGE)(1 << 26) +#define TPMA_X509_KEY_USAGE_keyAgreement (TPMA_X509_KEY_USAGE)(1 << 27) +#define TPMA_X509_KEY_USAGE_dataEncipherment (TPMA_X509_KEY_USAGE)(1 << 28) +#define TPMA_X509_KEY_USAGE_keyEncipherment (TPMA_X509_KEY_USAGE)(1 << 29) +#define TPMA_X509_KEY_USAGE_nonrepudiation (TPMA_X509_KEY_USAGE)(1 << 30) +#define TPMA_X509_KEY_USAGE_digitalSignature (TPMA_X509_KEY_USAGE)((UINT32)1 << 31) // libtpms changed: UBSAN // This is the initializer for a TPMA_X509_KEY_USAGE bit array. -# define TPMA_X509_KEY_USAGE_INITIALIZER(bits_at_0, \ - decipheronly, \ - encipheronly, \ - crlsign, \ - keycertsign, \ - keyagreement, \ - dataencipherment, \ - keyencipherment, \ - nonrepudiation, \ - digitalsignature) \ - (TPMA_X509_KEY_USAGE)((decipheronly << 23) + (encipheronly << 24) \ - + (crlsign << 25) + (keycertsign << 26) \ - + (keyagreement << 27) + (dataencipherment << 28) \ - + (keyencipherment << 29) + (nonrepudiation << 30) \ - + ((UINT32)digitalsignature << 31)) // libtpms changed: UBSAN - -#endif // USE_BIT_FIELD_STRUCTURES +#define TPMA_X509_KEY_USAGE_INITIALIZER(bits_at_0, \ + decipheronly, \ + encipheronly, \ + crlsign, \ + keycertsign, \ + keyagreement, \ + dataencipherment, \ + keyencipherment, \ + nonrepudiation, \ + digitalsignature) \ + (TPMA_X509_KEY_USAGE)((decipheronly << 23) + (encipheronly << 24) \ + + (crlsign << 25) + (keycertsign << 26) \ + + (keyagreement << 27) + (dataencipherment << 28) \ + + (keyencipherment << 29) + (nonrepudiation << 30) \ + + ((UINT32)digitalsignature << 31)) // libtpms changed: UBSAN // Table "Definition of TPMA_ACT Bits" (Part 2: Structures) #define TYPE_OF_TPMA_ACT UINT32 @@ -1561,31 +1262,15 @@ typedef UINT32 TPMA_X509_KEY_USAGE; UINT32 x = BYTE_ARRAY_TO_UINT32(a); \ i = UINT32_TO_TPMA_ACT(x); \ } -#if USE_BIT_FIELD_STRUCTURES -typedef struct -{ - unsigned signaled : 1; - unsigned preserveSignaled : 1; - unsigned Reserved_bits_at_2 : 30; -} TPMA_ACT; - -// Initializer for the bit-field structure -# define TPMA_ACT_INITIALIZER(signaled, preservesignaled, bits_at_2) \ - { \ - signaled, preservesignaled, bits_at_2 \ - } -#else // USE_BIT_FIELD_STRUCTURES // This implements Table "Definition of TPMA_ACT Bits" (Part 2: Structures) using bit masking typedef UINT32 TPMA_ACT; -# define TPMA_ACT_signaled (TPMA_ACT)(1 << 0) -# define TPMA_ACT_preserveSignaled (TPMA_ACT)(1 << 1) +#define TPMA_ACT_signaled (TPMA_ACT)(1 << 0) +#define TPMA_ACT_preserveSignaled (TPMA_ACT)(1 << 1) // This is the initializer for a TPMA_ACT bit array. -# define TPMA_ACT_INITIALIZER(signaled, preservesignaled, bits_at_2) \ - (TPMA_ACT)((signaled << 0) + (preservesignaled << 1)) - -#endif // USE_BIT_FIELD_STRUCTURES +#define TPMA_ACT_INITIALIZER(signaled, preservesignaled, bits_at_2) \ + (TPMA_ACT)((signaled << 0) + (preservesignaled << 1)) typedef BYTE TPMI_YES_NO; // (Part 2: Structures) typedef TPM_HANDLE TPMI_DH_OBJECT; // (Part 2: Structures) @@ -1862,6 +1547,14 @@ typedef struct TPMA_ACT attributes; } TPMS_ACT_DATA; +#if SEC_CHANNEL_SUPPORT +typedef struct +{ // (Part 2: Structures) + TPM2B_NAME reqKeyName; + TPM2B_NAME tpmKeyName; +} TPMS_SPDM_SESSION_INFO; +#endif // SEC_CHANNEL_SUPPORT + typedef struct { // (Part 2: Structures) UINT32 count; @@ -1940,34 +1633,19 @@ typedef struct TPMS_ACT_DATA actData[MAX_ACT_DATA]; } TPML_ACT_DATA; +#if SEC_CHANNEL_SUPPORT typedef struct { // (Part 2: Structures) - UINT32 count; - TPM2B_VENDOR_PROPERTY vendorData[MAX_VENDOR_PROPERTY]; -} TPML_VENDOR_PROPERTY; - -typedef union -{ // (Part 2: Structures) - TPML_ALG_PROPERTY algorithms; - TPML_HANDLE handles; - TPML_CCA command; - TPML_CC ppCommands; - TPML_CC auditCommands; - TPML_PCR_SELECTION assignedPCR; - TPML_TAGGED_TPM_PROPERTY tpmProperties; - TPML_TAGGED_PCR_PROPERTY pcrProperties; -#if ALG_ECC - TPML_ECC_CURVE eccCurves; -#endif // ALG_ECC - TPML_TAGGED_POLICY authPolicies; - TPML_ACT_DATA actData; -} TPMU_CAPABILITIES; + UINT32 count; + TPMS_SPDM_SESSION_INFO spdmSessionInfo[MAX_SPDM_SESS_INFO]; +} TPML_SPDM_SESSION_INFO; +#endif // SEC_CHANNEL_SUPPORT typedef struct { // (Part 2: Structures) - TPM_CAP capability; - TPMU_CAPABILITIES data; -} TPMS_CAPABILITY_DATA; + UINT32 count; + TPM2B_VENDOR_PROPERTY vendorData[MAX_VENDOR_PROPERTY]; +} TPML_VENDOR_PROPERTY; typedef union { // (Part 2: Structures) @@ -2101,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) @@ -2696,6 +2374,41 @@ typedef struct TPMT_PUBLIC publicArea; } TPM2B_PUBLIC; +#if SEC_CHANNEL_SUPPORT +typedef struct +{ // (Part 2: Structures) + UINT32 count; + TPM2B_PUBLIC pubKeys[MAX_PUB_KEYS]; +} TPML_PUB_KEY; +#endif // SEC_CHANNEL_SUPPORT + +typedef union +{ // (Part 2: Structures) + TPML_ALG_PROPERTY algorithms; + TPML_HANDLE handles; + TPML_CCA command; + TPML_CC ppCommands; + TPML_CC auditCommands; + TPML_PCR_SELECTION assignedPCR; + TPML_TAGGED_TPM_PROPERTY tpmProperties; + TPML_TAGGED_PCR_PROPERTY pcrProperties; +#if ALG_ECC + 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 +} TPMU_CAPABILITIES; + +typedef struct +{ // (Part 2: Structures) + TPM_CAP capability; + TPMU_CAPABILITIES data; +} TPMS_CAPABILITY_DATA; + typedef union { // (Part 2: Structures) struct @@ -2791,32 +2504,17 @@ typedef union UINT32 x = BYTE_ARRAY_TO_UINT32(a); \ i = UINT32_TO_TPM_NV_INDEX(x); \ } -#if USE_BIT_FIELD_STRUCTURES -typedef struct -{ - unsigned index : 24; - unsigned RH_NV : 8; -} TPM_NV_INDEX; - -// Initializer for the bit-field structure -# define TPM_NV_INDEX_INITIALIZER(index, rh_nv) \ - { \ - index, rh_nv \ - } -#else // USE_BIT_FIELD_STRUCTURES // This implements Table "Definition of TPM_NV_INDEX Bits" (Part 2: Structures) using bit masking typedef UINT32 TPM_NV_INDEX; -# define TPM_NV_INDEX_index (TPM_NV_INDEX)(0xFFFFFF << 0) -# define TPM_NV_INDEX_index_SHIFT 0 -# define TPM_NV_INDEX_RH_NV (TPM_NV_INDEX)((UINT32)0xFF << 24) // libtpms changed: UBSAN -# define TPM_NV_INDEX_RH_NV_SHIFT 24 +#define TPM_NV_INDEX_index (TPM_NV_INDEX)(0xFFFFFF << 0) +#define TPM_NV_INDEX_index_SHIFT 0 +#define TPM_NV_INDEX_RH_NV (TPM_NV_INDEX)(0xFF << 24) +#define TPM_NV_INDEX_RH_NV_SHIFT 24 // This is the initializer for a TPM_NV_INDEX bit array. -# define TPM_NV_INDEX_INITIALIZER(index, rh_nv) \ - (TPM_NV_INDEX)((index << 0) + (rh_nv << 24)) - -#endif // USE_BIT_FIELD_STRUCTURES +#define TPM_NV_INDEX_INITIALIZER(index, rh_nv) \ + (TPM_NV_INDEX)((index << 0) + (rh_nv << 24)) // Table "Definition of TPM_NT Constants" (Part 2: Structures) typedef UINT32 TPM_NT; @@ -2844,131 +2542,67 @@ typedef struct UINT32 x = BYTE_ARRAY_TO_UINT32(a); \ i = UINT32_TO_TPMA_NV(x); \ } -#if USE_BIT_FIELD_STRUCTURES -typedef struct -{ - unsigned PPWRITE : 1; - unsigned OWNERWRITE : 1; - unsigned AUTHWRITE : 1; - unsigned POLICYWRITE : 1; - unsigned TPM_NT : 4; - unsigned Reserved_bits_at_8 : 2; - unsigned POLICY_DELETE : 1; - unsigned WRITELOCKED : 1; - unsigned WRITEALL : 1; - unsigned WRITEDEFINE : 1; - unsigned WRITE_STCLEAR : 1; - unsigned GLOBALLOCK : 1; - unsigned PPREAD : 1; - unsigned OWNERREAD : 1; - unsigned AUTHREAD : 1; - unsigned POLICYREAD : 1; - unsigned Reserved_bits_at_20 : 5; - unsigned NO_DA : 1; - unsigned ORDERLY : 1; - unsigned CLEAR_STCLEAR : 1; - unsigned READLOCKED : 1; - unsigned WRITTEN : 1; - unsigned PLATFORMCREATE : 1; - unsigned READ_STCLEAR : 1; -} TPMA_NV; - -// Initializer for the bit-field structure -# define TPMA_NV_INITIALIZER(ppwrite, \ - ownerwrite, \ - authwrite, \ - policywrite, \ - tpm_nt, \ - bits_at_8, \ - policy_delete, \ - writelocked, \ - writeall, \ - writedefine, \ - write_stclear, \ - globallock, \ - ppread, \ - ownerread, \ - authread, \ - policyread, \ - bits_at_20, \ - no_da, \ - orderly, \ - clear_stclear, \ - readlocked, \ - written, \ - platformcreate, \ - read_stclear) \ - { \ - ppwrite, ownerwrite, authwrite, policywrite, tpm_nt, bits_at_8, \ - policy_delete, writelocked, writeall, writedefine, write_stclear, \ - globallock, ppread, ownerread, authread, policyread, bits_at_20, \ - no_da, orderly, clear_stclear, readlocked, written, platformcreate, \ - read_stclear \ - } -#else // USE_BIT_FIELD_STRUCTURES // This implements Table "Definition of TPMA_NV Bits" (Part 2: Structures) using bit masking typedef UINT32 TPMA_NV; -# define TPMA_NV_PPWRITE (TPMA_NV)(1 << 0) -# define TPMA_NV_OWNERWRITE (TPMA_NV)(1 << 1) -# define TPMA_NV_AUTHWRITE (TPMA_NV)(1 << 2) -# define TPMA_NV_POLICYWRITE (TPMA_NV)(1 << 3) -# define TPMA_NV_TPM_NT (TPMA_NV)(0xF << 4) -# define TPMA_NV_TPM_NT_SHIFT 4 -# define TPMA_NV_POLICY_DELETE (TPMA_NV)(1 << 10) -# define TPMA_NV_WRITELOCKED (TPMA_NV)(1 << 11) -# define TPMA_NV_WRITEALL (TPMA_NV)(1 << 12) -# define TPMA_NV_WRITEDEFINE (TPMA_NV)(1 << 13) -# define TPMA_NV_WRITE_STCLEAR (TPMA_NV)(1 << 14) -# define TPMA_NV_GLOBALLOCK (TPMA_NV)(1 << 15) -# define TPMA_NV_PPREAD (TPMA_NV)(1 << 16) -# define TPMA_NV_OWNERREAD (TPMA_NV)(1 << 17) -# define TPMA_NV_AUTHREAD (TPMA_NV)(1 << 18) -# define TPMA_NV_POLICYREAD (TPMA_NV)(1 << 19) -# define TPMA_NV_NO_DA (TPMA_NV)(1 << 25) -# define TPMA_NV_ORDERLY (TPMA_NV)(1 << 26) -# define TPMA_NV_CLEAR_STCLEAR (TPMA_NV)(1 << 27) -# define TPMA_NV_READLOCKED (TPMA_NV)(1 << 28) -# define TPMA_NV_WRITTEN (TPMA_NV)(1 << 29) -# define TPMA_NV_PLATFORMCREATE (TPMA_NV)(1 << 30) -# define TPMA_NV_READ_STCLEAR (TPMA_NV)((UINT32)1 << 31) // libtpms changed: UBSAN -#define TPMA_NV_RESERVED (0x00000300 | 0x01f00000) // libtpms added +#define TPMA_NV_PPWRITE (TPMA_NV)(1 << 0) +#define TPMA_NV_OWNERWRITE (TPMA_NV)(1 << 1) +#define TPMA_NV_AUTHWRITE (TPMA_NV)(1 << 2) +#define TPMA_NV_POLICYWRITE (TPMA_NV)(1 << 3) +#define TPMA_NV_TPM_NT (TPMA_NV)(0xF << 4) +#define TPMA_NV_TPM_NT_SHIFT 4 +#define TPMA_NV_POLICY_DELETE (TPMA_NV)(1 << 10) +#define TPMA_NV_WRITELOCKED (TPMA_NV)(1 << 11) +#define TPMA_NV_WRITEALL (TPMA_NV)(1 << 12) +#define TPMA_NV_WRITEDEFINE (TPMA_NV)(1 << 13) +#define TPMA_NV_WRITE_STCLEAR (TPMA_NV)(1 << 14) +#define TPMA_NV_GLOBALLOCK (TPMA_NV)(1 << 15) +#define TPMA_NV_PPREAD (TPMA_NV)(1 << 16) +#define TPMA_NV_OWNERREAD (TPMA_NV)(1 << 17) +#define TPMA_NV_AUTHREAD (TPMA_NV)(1 << 18) +#define TPMA_NV_POLICYREAD (TPMA_NV)(1 << 19) +#define TPMA_NV_NO_DA (TPMA_NV)(1 << 25) +#define TPMA_NV_ORDERLY (TPMA_NV)(1 << 26) +#define TPMA_NV_CLEAR_STCLEAR (TPMA_NV)(1 << 27) +#define TPMA_NV_READLOCKED (TPMA_NV)(1 << 28) +#define TPMA_NV_WRITTEN (TPMA_NV)(1 << 29) +#define TPMA_NV_PLATFORMCREATE (TPMA_NV)(1 << 30) +#define TPMA_NV_READ_STCLEAR (TPMA_NV)((UINT32)1 << 31) // libtpms changed: UBSAN +#define TPMA_NV_RESERVED (0x00000300 | 0x01f00000) // libtpms added // This is the initializer for a TPMA_NV bit array. -# define TPMA_NV_INITIALIZER(ppwrite, \ - ownerwrite, \ - authwrite, \ - policywrite, \ - tpm_nt, \ - bits_at_8, \ - policy_delete, \ - writelocked, \ - writeall, \ - writedefine, \ - write_stclear, \ - globallock, \ - ppread, \ - ownerread, \ - authread, \ - policyread, \ - bits_at_20, \ - no_da, \ - orderly, \ - clear_stclear, \ - readlocked, \ - written, \ - platformcreate, \ - read_stclear) \ - (TPMA_NV)((ppwrite << 0) + (ownerwrite << 1) + (authwrite << 2) \ - + (policywrite << 3) + (tpm_nt << 4) + (policy_delete << 10) \ - + (writelocked << 11) + (writeall << 12) + (writedefine << 13) \ - + (write_stclear << 14) + (globallock << 15) + (ppread << 16) \ - + (ownerread << 17) + (authread << 18) + (policyread << 19) \ - + (no_da << 25) + (orderly << 26) + (clear_stclear << 27) \ - + (readlocked << 28) + (written << 29) + (platformcreate << 30) \ - + ((UINT32)read_stclear << 31)) // libtpms changed: UBSAN - -#endif // USE_BIT_FIELD_STRUCTURES +#define TPMA_NV_INITIALIZER(ppwrite, \ + ownerwrite, \ + authwrite, \ + policywrite, \ + tpm_nt, \ + bits_at_8, \ + policy_delete, \ + writelocked, \ + writeall, \ + writedefine, \ + write_stclear, \ + globallock, \ + ppread, \ + ownerread, \ + authread, \ + policyread, \ + bits_at_20, \ + no_da, \ + orderly, \ + clear_stclear, \ + readlocked, \ + written, \ + platformcreate, \ + read_stclear) \ + (TPMA_NV)((ppwrite << 0) + (ownerwrite << 1) + (authwrite << 2) \ + + (policywrite << 3) + (tpm_nt << 4) + (policy_delete << 10) \ + + (writelocked << 11) + (writeall << 12) + (writedefine << 13) \ + + (write_stclear << 14) + (globallock << 15) + (ppread << 16) \ + + (ownerread << 17) + (authread << 18) + (policyread << 19) \ + + (no_da << 25) + (orderly << 26) + (clear_stclear << 27) \ + + (readlocked << 28) + (written << 29) + (platformcreate << 30) \ + + (read_stclear << 31)) // Table "Definition of TPMA_NV_EXP Bits" (Part 2: Structures) #define TYPE_OF_TPMA_NV_EXP UINT64 @@ -2981,156 +2615,80 @@ typedef UINT32 TPMA_NV; UINT64 x = BYTE_ARRAY_TO_UINT64(a); \ i = UINT64_TO_TPMA_NV_EXP(x); \ } -#if USE_BIT_FIELD_STRUCTURES -typedef struct -{ - unsigned TPMA_NV_PPWRITE : 1; - unsigned TPMA_NV_OWNERWRITE : 1; - unsigned TPMA_NV_AUTHWRITE : 1; - unsigned TPMA_NV_POLICYWRITE : 1; - unsigned TPM_NT : 4; - unsigned Reserved_bits_at_8 : 2; - unsigned TPMA_NV_POLICY_DELETE : 1; - unsigned TPMA_NV_WRITELOCKED : 1; - unsigned TPMA_NV_WRITEALL : 1; - unsigned TPMA_NV_WRITEDEFINE : 1; - unsigned TPMA_NV_WRITE_STCLEAR : 1; - unsigned TPMA_NV_GLOBALLOCK : 1; - unsigned TPMA_NV_PPREAD : 1; - unsigned TPMA_NV_OWNERREAD : 1; - unsigned TPMA_NV_AUTHREAD : 1; - unsigned TPMA_NV_POLICYREAD : 1; - unsigned Reserved_bits_at_20 : 5; - unsigned TPMA_NV_NO_DA : 1; - unsigned TPMA_NV_ORDERLY : 1; - unsigned TPMA_NV_CLEAR_STCLEAR : 1; - unsigned TPMA_NV_READLOCKED : 1; - unsigned TPMA_NV_WRITTEN : 1; - unsigned TPMA_NV_PLATFORMCREATE : 1; - unsigned TPMA_NV_READ_STCLEAR : 1; - unsigned TPMA_EXTERNAL_NV_ENCRYPTION : 1; - unsigned TPMA_EXTERNAL_NV_INTEGRITY : 1; - unsigned TPMA_EXTERNAL_NV_ANTIROLLBACK : 1; - unsigned Reserved_bits_at_35 : 29; -} TPMA_NV_EXP; - -// Initializer for the bit-field structure -# define TPMA_NV_EXP_INITIALIZER(tpma_nv_ppwrite, \ - tpma_nv_ownerwrite, \ - tpma_nv_authwrite, \ - tpma_nv_policywrite, \ - tpm_nt, \ - bits_at_8, \ - tpma_nv_policy_delete, \ - tpma_nv_writelocked, \ - tpma_nv_writeall, \ - tpma_nv_writedefine, \ - tpma_nv_write_stclear, \ - tpma_nv_globallock, \ - tpma_nv_ppread, \ - tpma_nv_ownerread, \ - tpma_nv_authread, \ - tpma_nv_policyread, \ - bits_at_20, \ - tpma_nv_no_da, \ - tpma_nv_orderly, \ - tpma_nv_clear_stclear, \ - tpma_nv_readlocked, \ - tpma_nv_written, \ - tpma_nv_platformcreate, \ - tpma_nv_read_stclear, \ - tpma_external_nv_encryption, \ - tpma_external_nv_integrity, \ - tpma_external_nv_antirollback, \ - bits_at_35) \ - { \ - tpma_nv_ppwrite, tpma_nv_ownerwrite, tpma_nv_authwrite, \ - tpma_nv_policywrite, tpm_nt, bits_at_8, tpma_nv_policy_delete, \ - tpma_nv_writelocked, tpma_nv_writeall, tpma_nv_writedefine, \ - tpma_nv_write_stclear, tpma_nv_globallock, tpma_nv_ppread, \ - tpma_nv_ownerread, tpma_nv_authread, tpma_nv_policyread, bits_at_20, \ - tpma_nv_no_da, tpma_nv_orderly, tpma_nv_clear_stclear, \ - tpma_nv_readlocked, tpma_nv_written, tpma_nv_platformcreate, \ - tpma_nv_read_stclear, tpma_external_nv_encryption, \ - tpma_external_nv_integrity, tpma_external_nv_antirollback, bits_at_35 \ - } -#else // USE_BIT_FIELD_STRUCTURES // This implements Table "Definition of TPMA_NV_EXP Bits" (Part 2: Structures) using bit masking typedef UINT64 TPMA_NV_EXP; -# define TPMA_NV_EXP_TPMA_NV_PPWRITE (TPMA_NV_EXP)(1 << 0) -# define TPMA_NV_EXP_TPMA_NV_OWNERWRITE (TPMA_NV_EXP)(1 << 1) -# define TPMA_NV_EXP_TPMA_NV_AUTHWRITE (TPMA_NV_EXP)(1 << 2) -# define TPMA_NV_EXP_TPMA_NV_POLICYWRITE (TPMA_NV_EXP)(1 << 3) -# define TPMA_NV_EXP_TPM_NT (TPMA_NV_EXP)(0xF << 4) -# define TPMA_NV_EXP_TPM_NT_SHIFT 4 -# define TPMA_NV_EXP_TPMA_NV_POLICY_DELETE (TPMA_NV_EXP)(1 << 10) -# define TPMA_NV_EXP_TPMA_NV_WRITELOCKED (TPMA_NV_EXP)(1 << 11) -# define TPMA_NV_EXP_TPMA_NV_WRITEALL (TPMA_NV_EXP)(1 << 12) -# define TPMA_NV_EXP_TPMA_NV_WRITEDEFINE (TPMA_NV_EXP)(1 << 13) -# define TPMA_NV_EXP_TPMA_NV_WRITE_STCLEAR (TPMA_NV_EXP)(1 << 14) -# define TPMA_NV_EXP_TPMA_NV_GLOBALLOCK (TPMA_NV_EXP)(1 << 15) -# define TPMA_NV_EXP_TPMA_NV_PPREAD (TPMA_NV_EXP)(1 << 16) -# define TPMA_NV_EXP_TPMA_NV_OWNERREAD (TPMA_NV_EXP)(1 << 17) -# define TPMA_NV_EXP_TPMA_NV_AUTHREAD (TPMA_NV_EXP)(1 << 18) -# define TPMA_NV_EXP_TPMA_NV_POLICYREAD (TPMA_NV_EXP)(1 << 19) -# define TPMA_NV_EXP_TPMA_NV_NO_DA (TPMA_NV_EXP)(1 << 25) -# define TPMA_NV_EXP_TPMA_NV_ORDERLY (TPMA_NV_EXP)(1 << 26) -# define TPMA_NV_EXP_TPMA_NV_CLEAR_STCLEAR (TPMA_NV_EXP)(1 << 27) -# define TPMA_NV_EXP_TPMA_NV_READLOCKED (TPMA_NV_EXP)(1 << 28) -# define TPMA_NV_EXP_TPMA_NV_WRITTEN (TPMA_NV_EXP)(1 << 29) -# define TPMA_NV_EXP_TPMA_NV_PLATFORMCREATE (TPMA_NV_EXP)(1 << 30) -# define TPMA_NV_EXP_TPMA_NV_READ_STCLEAR (TPMA_NV_EXP)((UINT64)1 << 31) // libtpms changed begin: UBSAN -# define TPMA_NV_EXP_TPMA_EXTERNAL_NV_ENCRYPTION (TPMA_NV_EXP)((UINT64)1 << 32) -# define TPMA_NV_EXP_TPMA_EXTERNAL_NV_INTEGRITY (TPMA_NV_EXP)((UINT64)1 << 33) -# define TPMA_NV_EXP_TPMA_EXTERNAL_NV_ANTIROLLBACK (TPMA_NV_EXP)((UINT64)1 << 34) // libtpms changed end -# define TPMA_NV_EXP_reserved 0xfffffff800000000L // libtpms added +#define TPMA_NV_EXP_TPMA_NV_PPWRITE (TPMA_NV_EXP)(1 << 0) +#define TPMA_NV_EXP_TPMA_NV_OWNERWRITE (TPMA_NV_EXP)(1 << 1) +#define TPMA_NV_EXP_TPMA_NV_AUTHWRITE (TPMA_NV_EXP)(1 << 2) +#define TPMA_NV_EXP_TPMA_NV_POLICYWRITE (TPMA_NV_EXP)(1 << 3) +#define TPMA_NV_EXP_TPM_NT (TPMA_NV_EXP)(0xF << 4) +#define TPMA_NV_EXP_TPM_NT_SHIFT 4 +#define TPMA_NV_EXP_TPMA_NV_POLICY_DELETE (TPMA_NV_EXP)(1 << 10) +#define TPMA_NV_EXP_TPMA_NV_WRITELOCKED (TPMA_NV_EXP)(1 << 11) +#define TPMA_NV_EXP_TPMA_NV_WRITEALL (TPMA_NV_EXP)(1 << 12) +#define TPMA_NV_EXP_TPMA_NV_WRITEDEFINE (TPMA_NV_EXP)(1 << 13) +#define TPMA_NV_EXP_TPMA_NV_WRITE_STCLEAR (TPMA_NV_EXP)(1 << 14) +#define TPMA_NV_EXP_TPMA_NV_GLOBALLOCK (TPMA_NV_EXP)(1 << 15) +#define TPMA_NV_EXP_TPMA_NV_PPREAD (TPMA_NV_EXP)(1 << 16) +#define TPMA_NV_EXP_TPMA_NV_OWNERREAD (TPMA_NV_EXP)(1 << 17) +#define TPMA_NV_EXP_TPMA_NV_AUTHREAD (TPMA_NV_EXP)(1 << 18) +#define TPMA_NV_EXP_TPMA_NV_POLICYREAD (TPMA_NV_EXP)(1 << 19) +#define TPMA_NV_EXP_TPMA_NV_NO_DA (TPMA_NV_EXP)(1 << 25) +#define TPMA_NV_EXP_TPMA_NV_ORDERLY (TPMA_NV_EXP)(1 << 26) +#define TPMA_NV_EXP_TPMA_NV_CLEAR_STCLEAR (TPMA_NV_EXP)(1 << 27) +#define TPMA_NV_EXP_TPMA_NV_READLOCKED (TPMA_NV_EXP)(1 << 28) +#define TPMA_NV_EXP_TPMA_NV_WRITTEN (TPMA_NV_EXP)(1 << 29) +#define TPMA_NV_EXP_TPMA_NV_PLATFORMCREATE (TPMA_NV_EXP)(1 << 30) +#define TPMA_NV_EXP_TPMA_NV_READ_STCLEAR (TPMA_NV_EXP)((UINT64)1 << 31) // libtpms changed begin: UBSAN +#define TPMA_NV_EXP_TPMA_EXTERNAL_NV_ENCRYPTION (TPMA_NV_EXP)((UINT64)1 << 32) +#define TPMA_NV_EXP_TPMA_EXTERNAL_NV_INTEGRITY (TPMA_NV_EXP)((UINT64)1 << 33) +#define TPMA_NV_EXP_TPMA_EXTERNAL_NV_ANTIROLLBACK (TPMA_NV_EXP)((UINT64)1 << 34) // libtpms changed end +#define TPMA_NV_EXP_reserved 0xfffffff800000000L // libtpms added // This is the initializer for a TPMA_NV_EXP bit array. -# define TPMA_NV_EXP_INITIALIZER(tpma_nv_ppwrite, \ - tpma_nv_ownerwrite, \ - tpma_nv_authwrite, \ - tpma_nv_policywrite, \ - tpm_nt, \ - bits_at_8, \ - tpma_nv_policy_delete, \ - tpma_nv_writelocked, \ - tpma_nv_writeall, \ - tpma_nv_writedefine, \ - tpma_nv_write_stclear, \ - tpma_nv_globallock, \ - tpma_nv_ppread, \ - tpma_nv_ownerread, \ - tpma_nv_authread, \ - tpma_nv_policyread, \ - bits_at_20, \ - tpma_nv_no_da, \ - tpma_nv_orderly, \ - tpma_nv_clear_stclear, \ - tpma_nv_readlocked, \ - tpma_nv_written, \ - tpma_nv_platformcreate, \ - tpma_nv_read_stclear, \ - tpma_external_nv_encryption, \ - tpma_external_nv_integrity, \ - tpma_external_nv_antirollback, \ - bits_at_35) \ - (TPMA_NV_EXP)((tpma_nv_ppwrite << 0) + (tpma_nv_ownerwrite << 1) \ - + (tpma_nv_authwrite << 2) + (tpma_nv_policywrite << 3) \ - + (tpm_nt << 4) + (tpma_nv_policy_delete << 10) \ - + (tpma_nv_writelocked << 11) + (tpma_nv_writeall << 12) \ - + (tpma_nv_writedefine << 13) + (tpma_nv_write_stclear << 14) \ - + (tpma_nv_globallock << 15) + (tpma_nv_ppread << 16) \ - + (tpma_nv_ownerread << 17) + (tpma_nv_authread << 18) \ - + (tpma_nv_policyread << 19) + (tpma_nv_no_da << 25) \ - + (tpma_nv_orderly << 26) + (tpma_nv_clear_stclear << 27) \ - + (tpma_nv_readlocked << 28) + (tpma_nv_written << 29) \ - + (tpma_nv_platformcreate << 30) + ((UINT64)tpma_nv_read_stclear << 31) /* libtpms changed: UBSAN */ \ - + ((UINT64)tpma_external_nv_encryption << 32) /* libtpms changed: UBSAN */ \ - + ((UINT64)tpma_external_nv_integrity << 33) /* libtpms changed: UBSAN */ \ - + ((UINT64)tpma_external_nv_antirollback << 34)) /* libtpms changed: UBSAN */ - -#endif // USE_BIT_FIELD_STRUCTURES +#define TPMA_NV_EXP_INITIALIZER(tpma_nv_ppwrite, \ + tpma_nv_ownerwrite, \ + tpma_nv_authwrite, \ + tpma_nv_policywrite, \ + tpm_nt, \ + bits_at_8, \ + tpma_nv_policy_delete, \ + tpma_nv_writelocked, \ + tpma_nv_writeall, \ + tpma_nv_writedefine, \ + tpma_nv_write_stclear, \ + tpma_nv_globallock, \ + tpma_nv_ppread, \ + tpma_nv_ownerread, \ + tpma_nv_authread, \ + tpma_nv_policyread, \ + bits_at_20, \ + tpma_nv_no_da, \ + tpma_nv_orderly, \ + tpma_nv_clear_stclear, \ + tpma_nv_readlocked, \ + tpma_nv_written, \ + tpma_nv_platformcreate, \ + tpma_nv_read_stclear, \ + tpma_external_nv_encryption, \ + tpma_external_nv_integrity, \ + tpma_external_nv_antirollback, \ + bits_at_35) \ + (TPMA_NV_EXP)((tpma_nv_ppwrite << 0) + (tpma_nv_ownerwrite << 1) \ + + (tpma_nv_authwrite << 2) + (tpma_nv_policywrite << 3) \ + + (tpm_nt << 4) + (tpma_nv_policy_delete << 10) \ + + (tpma_nv_writelocked << 11) + (tpma_nv_writeall << 12) \ + + (tpma_nv_writedefine << 13) + (tpma_nv_write_stclear << 14) \ + + (tpma_nv_globallock << 15) + (tpma_nv_ppread << 16) \ + + (tpma_nv_ownerread << 17) + (tpma_nv_authread << 18) \ + + (tpma_nv_policyread << 19) + (tpma_nv_no_da << 25) \ + + (tpma_nv_orderly << 26) + (tpma_nv_clear_stclear << 27) \ + + (tpma_nv_readlocked << 28) + (tpma_nv_written << 29) \ + + (tpma_nv_platformcreate << 30) + ((UINT64)tpma_nv_read_stclear << 31) /* libtpms changed: UBSAN */ \ + + ((UINT64)tpma_external_nv_encryption << 32) /* libtpms changed: UBSAN */ \ + + ((UINT64)tpma_external_nv_integrity << 33) /* libtpms changed: UBSAN */ \ + + ((UINT64)tpma_external_nv_antirollback << 34)) /* libtpms changed: UBSAN */ typedef struct { // (Part 2: Structures) diff --git a/src/tpm2/TPMCmd/tpm/include/tpm_public/VerifyConfiguration.h b/src/tpm2/TPMCmd/tpm/include/tpm_public/VerifyConfiguration.h new file mode 100644 index 000000000..31e37986d --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/tpm_public/VerifyConfiguration.h @@ -0,0 +1,104 @@ +// SPDX-License-Identifier: BSD-2-Clause + +// +// This verifies that information expected from the consumer's TpmConfiguration is +// set properly and consistently. +// +#ifndef _VERIFY_CONFIGURATION_H +#define _VERIFY_CONFIGURATION_H + +MUST_BE(YES == 1); +MUST_BE(NO == 0); + +// verify these defines are either YES or NO. +#define MUST_BE_0_OR_1(x) MUST_BE(((x) == NO) || ((x) == YES)) +#define MUST_BE_0(x) MUST_BE((x) == NO) +#define MUST_BE_1(x) MUST_BE((x) == YES) + +// Debug Options +MUST_BE_0_OR_1(DEBUG); +MUST_BE_0_OR_1(SIMULATION); +MUST_BE_0_OR_1(ENABLE_TPM_DEBUG_PRINT); +MUST_BE_0_OR_1(DRBG_DEBUG_PRINT); +MUST_BE_0_OR_1(CERTIFYX509_DEBUG); +MUST_BE_0_OR_1(USE_DEBUG_RNG); + +// RSA Debug Options +MUST_BE_0_OR_1(RSA_INSTRUMENT); +MUST_BE_0_OR_1(USE_RSA_KEY_CACHE); +MUST_BE_0_OR_1(USE_KEY_CACHE_FILE); + +// Test Options +MUST_BE_0_OR_1(ALLOW_FORCE_FAILURE_MODE); + +// Internal checks +MUST_BE_0_OR_1(LIBRARY_COMPATIBILITY_CHECK); +MUST_BE_0_OR_1(COMPILER_CHECKS); +MUST_BE_0_OR_1(RUNTIME_SIZE_CHECKS); + +// Compliance options +MUST_BE_0_OR_1(FIPS_COMPLIANT); +MUST_BE_0_OR_1(USE_SPEC_COMPLIANT_PROOFS); +MUST_BE_0_OR_1(SKIP_PROOF_ERRORS); + +// Implementation alternatives - should not change external behavior +MUST_BE_0_OR_1(TABLE_DRIVEN_MARSHAL); +MUST_BE_0_OR_1(COMPRESSED_LISTS); // libtpms added +MUST_BE_0_OR_1(RSA_KEY_SIEVE); + +// Implementation alternatives - changes external behavior +MUST_BE_0_OR_1(LONGJMP_SUPPORTED); +MUST_BE_0_OR_1(_DRBG_STATE_SAVE); +MUST_BE_0_OR_1(USE_DA_USED); +MUST_BE_0_OR_1(ENABLE_SELF_TESTS); +MUST_BE_0_OR_1(CLOCK_STOPS); +MUST_BE_0_OR_1(ACCUMULATE_SELF_HEAL_TIMER); +MUST_BE_0_OR_1(FAIL_TRACE); + +// Vendor alternatives +// Check VENDOR_PERMANENT_AUTH_ENABLED & VENDOR_PERMANENT_AUTH_HANDLE are consistent +MUST_BE_0_OR_1(VENDOR_PERMANENT_AUTH_ENABLED); + +#if VENDOR_PERMANENT_AUTH_ENABLED == YES +# if !defined(VENDOR_PERMANENT_AUTH_HANDLE) \ + || VENDOR_PERMANENT_AUTH_HANDLE < TPM_RH_AUTH_00 \ + || VENDOR_PERMANENT_AUTH_HANDLE > TPM_RH_AUTH_FF +# error VENDOR_PERMANENT_AUTH_ENABLED requires a valid definition for VENDOR_PERMANENT_AUTH_HANDLE, see Part2 +# endif +#else +# if defined(VENDOR_PERMANENT_AUTH_HANDLE) +# error VENDOR_PERMANENT_AUTH_HANDLE requires VENDOR_PERMANENT_AUTH_ENABLED to be YES +# endif +#endif + +// now check for inconsistent combinations of options +#if USE_KEY_CACHE_FILE && !USE_RSA_KEY_CACHE +# error cannot use USE_KEY_CACHE_FILE if not using USE_RSA_KEY_CACHE +#endif + +#if !DEBUG +# if USE_KEY_CACHE_FILE || USE_RSA_KEY_CACHE || DRBG_DEBUG_PRINT \ + || CERTIFYX509_DEBUG || USE_DEBUG_RNG || ENABLE_TPM_DEBUG_PRINT +# error using insecure options not in DEBUG mode. +# endif +#endif + +#if !SIMULATION +# if USE_KEY_CACHE_FILE +# error USE_KEY_CACHE_FILE requires SIMULATION +# endif +# if RSA_INSTRUMENT +# error RSA_INSTRUMENT requires SIMULATION +# endif +# if USE_DEBUG_RNG +# error USE_DEBUG_RNG requires SIMULATION +# 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 diff --git a/src/tpm2/TPMCmd/tpm/include/tpm_public/endian_swap.h b/src/tpm2/TPMCmd/tpm/include/tpm_public/endian_swap.h new file mode 100644 index 000000000..fa3cb6745 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/tpm_public/endian_swap.h @@ -0,0 +1,97 @@ +// SPDX-License-Identifier: BSD-2-Clause + +#ifndef _SWAP_H +#define _SWAP_H + +#if LITTLE_ENDIAN_TPM +# define TO_BIG_ENDIAN_UINT16(i) REVERSE_ENDIAN_16(i) +# define FROM_BIG_ENDIAN_UINT16(i) REVERSE_ENDIAN_16(i) +# define TO_BIG_ENDIAN_UINT32(i) REVERSE_ENDIAN_32(i) +# define FROM_BIG_ENDIAN_UINT32(i) REVERSE_ENDIAN_32(i) +# define TO_BIG_ENDIAN_UINT64(i) REVERSE_ENDIAN_64(i) +# define FROM_BIG_ENDIAN_UINT64(i) REVERSE_ENDIAN_64(i) +#else +# define TO_BIG_ENDIAN_UINT16(i) (i) +# define FROM_BIG_ENDIAN_UINT16(i) (i) +# define TO_BIG_ENDIAN_UINT32(i) (i) +# define FROM_BIG_ENDIAN_UINT32(i) (i) +# define TO_BIG_ENDIAN_UINT64(i) (i) +# define FROM_BIG_ENDIAN_UINT64(i) (i) +#endif + +#if AUTO_ALIGN == NO + +// The aggregation macros for machines that do not allow unaligned access or for +// little-endian machines. + +// Aggregate bytes into an UINT + +# define BYTE_ARRAY_TO_UINT8(b) (uint8_t)((b)[0]) +# define BYTE_ARRAY_TO_UINT16(b) ByteArrayToUint16((BYTE*)(b)) +# define BYTE_ARRAY_TO_UINT32(b) ByteArrayToUint32((BYTE*)(b)) +# define BYTE_ARRAY_TO_UINT64(b) ByteArrayToUint64((BYTE*)(b)) +# define UINT8_TO_BYTE_ARRAY(i, b) ((b)[0] = (uint8_t)(i)) +# define UINT16_TO_BYTE_ARRAY(i, b) Uint16ToByteArray((i), (BYTE*)(b)) +# define UINT32_TO_BYTE_ARRAY(i, b) Uint32ToByteArray((i), (BYTE*)(b)) +# define UINT64_TO_BYTE_ARRAY(i, b) Uint64ToByteArray((i), (BYTE*)(b)) + +#else // AUTO_ALIGN + +# if BIG_ENDIAN_TPM +// the big-endian macros for machines that allow unaligned memory access +// Aggregate a byte array into a UINT +# define BYTE_ARRAY_TO_UINT8(b) *((uint8_t*)(b)) +# define BYTE_ARRAY_TO_UINT16(b) *((uint16_t*)(b)) +# define BYTE_ARRAY_TO_UINT32(b) *((uint32_t*)(b)) +# define BYTE_ARRAY_TO_UINT64(b) *((uint64_t*)(b)) + +// 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)) = (i); \ + } +# define UINT32_TO_BYTE_ARRAY(i, b) \ + { \ + *((uint32_t*)(b)) = (i); \ + } +# define UINT64_TO_BYTE_ARRAY(i, b) \ + { \ + *((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 +// Aggregate a byte array into a UINT +# define BYTE_ARRAY_TO_UINT8(b) *((uint8_t*)(b)) +# define BYTE_ARRAY_TO_UINT16(b) REVERSE_ENDIAN_16(*((uint16_t*)(b))) +# define BYTE_ARRAY_TO_UINT32(b) REVERSE_ENDIAN_32(*((uint32_t*)(b))) +# define BYTE_ARRAY_TO_UINT64(b) REVERSE_ENDIAN_64(*((uint64_t*)(b))) + +// 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); \ + } +# endif // BIG_ENDIAN_TPM + +#endif // AUTO_ALIGN == NO + +#endif // _SWAP_H diff --git a/src/tpm2/TPMCmd/tpm/include/tpm_public/prototypes/TpmFail_fp.h b/src/tpm2/TPMCmd/tpm/include/tpm_public/prototypes/TpmFail_fp.h new file mode 100644 index 000000000..4d66fe7f4 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/tpm_public/prototypes/TpmFail_fp.h @@ -0,0 +1,40 @@ +// SPDX-License-Identifier: BSD-2-Clause + +/*(Auto-generated) + * Created by TpmPrototypes; Version 3.0 July 18, 2017 + * Date: Apr 2, 2019 Time: 03:18:00PM + */ + +#ifndef _TPM_FAIL_FP_H_ +#define _TPM_FAIL_FP_H_ + +//*** EnterFailureMode() +// This function is called by TPM.lib when a failure occurs. It will set up the +// failure values to be returned on TPM2_GetTestResult(). +NORETURN_IF_LONGJMP void EnterFailureMode( +#if FAIL_TRACE + const char* function, + int line, +#endif + uint64_t locationCode, + int failureCode); + +void // libtpms added begin +TpmLogFailure( +#if FAIL_TRACE + const char *function, + int line, +#endif + int code + ); // libtpms added end + +//*** TpmFailureMode( +// This function is called by the interface code when the platform is in failure +// mode. +void TpmFailureMode(uint32_t inRequestSize, // IN: command buffer size + unsigned char* inRequest, // IN: command buffer + uint32_t* outResponseSize, // OUT: response buffer size + unsigned char** outResponse // OUT: response buffer +); + +#endif // _TPM_FAIL_FP_H_ diff --git a/src/tpm2/TPMCmd/tpm/include/tpm_public/tpm_debug.h b/src/tpm2/TPMCmd/tpm/include/tpm_public/tpm_debug.h new file mode 100644 index 000000000..3337e6d76 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/tpm_public/tpm_debug.h @@ -0,0 +1,74 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +#ifndef _TPM_DEBUG_H_ +#define _TPM_DEBUG_H_ + +#include + +// Basic Debug Printing +#if ENABLE_TPM_DEBUG_PRINT + +# define TPM_DEBUG_PRINT(s) _plat_debug_print(s) +# define TPM_DEBUG_PRINT_BUFFER(buf, size) _plat_debug_print_buffer(buf, size) +# define TPM_DEBUG_PRINT_INT32(name, value) _plat_debug_print_int32(name, value) +# define TPM_DEBUG_PRINT_INT64(name, value) _plat_debug_print_int64(name, value) +// use the TPM_DEBUG_PRINTF versions only if there are extra arguments. +// GCC doesn't support an empty variable list, use TPM_DEBUG_PRINT instead. +# define TPM_DEBUG_PRINTF(s, ...) _plat_debug_printf(s, __VA_ARGS__) +# define TPM_DEBUG_SNPRINTF(buf, bufsize, s, ...) \ + _plat_debug_snprintf(buf, bufsize, s, __VA_ARGS__) + +#else + +# define TPM_DEBUG_PRINT(s) +# define TPM_DEBUG_PRINT_BUFFER(buf, size) +# define TPM_DEBUG_PRINT_INT32(name, value) +# define TPM_DEBUG_PRINT_INT64(name, value) +# define TPM_DEBUG_PRINTF(s, ...) +# define TPM_DEBUG_SNPRINTF(buf, bufsize, s, ...) + +#endif // ENABLE_TPM_DEBUG_PRINT + +// Verbose Code Path tracing +#if ENABLE_TPM_DEBUG_TRACE && ENABLE_TPM_DEBUG_PRINT + +# define TPM_DEBUG_TRACEX(extra) \ + TPM_DEBUG_PRINT(__func__); \ + TPM_DEBUG_PRINT(extra) + +# define TPM_DEBUG_TRACE() TPM_DEBUG_PRINT(__func__) + +#else + +# define TPM_DEBUG_TRACEX(s) +# define TPM_DEBUG_TRACE() + +#endif // ENABLE_TPM_DEBUG_TRACE && ENABLE_TPM_DEBUG_PRINT + +// Low Level Crypto Debugging +#if ENABLE_TPM_DEBUG_PRINT && ENABLE_CRYPTO_DEBUG + +// these functions are not declared here, but expect to be declared where these macros are consumed. +# define TPM_DEBUG_PRINT_BIGNUM(name, value) _bnDebug_printBigNum(name, value); +# define TPM_DEBUG_PRINT_BIGNUM_FULL(name, value) \ + _bnDebug_printBigNumFull(name, value); +# define TPM_DEBUG_PRINT_BIGPOINT(name, value) _bnDebug_printBigPoint(name, value); +# define TPM_DEBUG_PRINT_TPMS_ECC_POINT(name, value) \ + _bnDebug_printTPMS_ECC_POINT(name, value); +# define TPM_DEBUG_PRINT_TPM2B(name, value, reverse) \ + _bnDebug_printTpm2B(name, value, reverse); + +//#error SHOULD BE OFF + +#else + +# define TPM_DEBUG_PRINT_BIGNUM(name, value) +# define TPM_DEBUG_PRINT_BIGNUM_FULL(name, value) +# define TPM_DEBUG_PRINT_BIGPOINT(name, value) +# define TPM_DEBUG_PRINT_TPMS_ECC_POINT(name, value) +# define TPM_DEBUG_PRINT_TPM2B(name, value, reverse) + +#endif + +#endif //_TPM_DEBUG_H_ diff --git a/src/tpm2/TPMCmd/tpm/include/tpm_public/tpm_public.h b/src/tpm2/TPMCmd/tpm/include/tpm_public/tpm_public.h new file mode 100644 index 000000000..27d534f5e --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/include/tpm_public/tpm_public.h @@ -0,0 +1,15 @@ +// SPDX-License-Identifier: BSD-2-Clause + +#include +#include + +// public refers to the TPM_CoreLib public headers +#include +#include +#include +#include +#include +#include +#include +#include +#include diff --git a/src/tpm2/crypto/openssl/tpm_radix.h b/src/tpm2/TPMCmd/tpm/include/tpm_public/tpm_radix.h similarity index 54% rename from src/tpm2/crypto/openssl/tpm_radix.h rename to src/tpm2/TPMCmd/tpm/include/tpm_public/tpm_radix.h index c8b69754d..7e0a4350e 100644 --- a/src/tpm2/crypto/openssl/tpm_radix.h +++ b/src/tpm2/TPMCmd/tpm/include/tpm_public/tpm_radix.h @@ -1,62 +1,4 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2023 */ -/* */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause //** Introduction // Common defines for supporting large numbers and cryptographic buffer sizing. @@ -157,6 +99,13 @@ typedef int32_t crypt_word_t; #define MAX_ECC_PARAMETER_BYTES (MAX_ECC_KEY_BYTES * ALG_ECC) +// round up to a multiple of stride; by 0 if already a multiple +#define ALIGN_UP(size, stride) ((((size) + (stride) - 1) / (stride)) * (stride)) +// rounds down to multiple of stride +#define ALIGN_DOWN(size, stride) ((size) - ((size) % (stride))) +#define IS_ALIGNED(ptr, stride) ((((size_t)ptr) % (stride)) == 0) +#define IS_ALIGNED4(ptr) IS_ALIGNED(ptr, 4) + // These macros use the selected libraries to get the proper include files. // clang-format off #define LIB_QUOTE(_STRING_) #_STRING_ diff --git a/src/tpm2/TpmASN1.c b/src/tpm2/TPMCmd/tpm/src/X509/TpmASN1.c similarity index 81% rename from src/tpm2/TpmASN1.c rename to src/tpm2/TPMCmd/tpm/src/X509/TpmASN1.c index bc1501386..aaa6e2da7 100644 --- a/src/tpm2/TpmASN1.c +++ b/src/tpm2/TPMCmd/tpm/src/X509/TpmASN1.c @@ -1,62 +1,4 @@ -/********************************************************************************/ -/* */ -/* TPM ASN.1 */ -/* 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 - 2023 */ -/* */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause //** Includes #include "Tpm.h" @@ -275,7 +217,7 @@ void ASN1InitialializeMarshalContext( // that was previously placed in the structure. void ASN1StartMarshalContext(ASN1MarshalContext* ctx) { - pAssert((ctx->depth + 1) < MAX_DEPTH); + pAssert_VOID_OK((ctx->depth + 1) < MAX_DEPTH); ctx->depth++; ctx->ends[ctx->depth] = ctx->end; ctx->end = ctx->offset; @@ -290,7 +232,7 @@ INT16 ASN1EndMarshalContext(ASN1MarshalContext* ctx) { INT16 length; - pAssert(ctx->depth >= 0); + pAssert_ZERO(ctx->depth >= 0); length = ctx->end - ctx->offset; ctx->end = ctx->ends[ctx->depth--]; return length; diff --git a/src/tpm2/X509_ECC.c b/src/tpm2/TPMCmd/tpm/src/X509/X509_ECC.c similarity index 52% rename from src/tpm2/X509_ECC.c rename to src/tpm2/TPMCmd/tpm/src/X509/X509_ECC.c index 2d73f9db8..70b30624e 100644 --- a/src/tpm2/X509_ECC.c +++ b/src/tpm2/TPMCmd/tpm/src/X509/X509_ECC.c @@ -1,62 +1,4 @@ -/********************************************************************************/ -/* */ -/* TPM X509 ECC */ -/* 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 - 2023 */ -/* */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause //** Includes #include "Tpm.h" @@ -67,6 +9,8 @@ #include "X509_spt_fp.h" #include "CryptHash_fp.h" +#if ALG_ECC && CC_CertifyX509 + //** Functions //*** X509PushPoint() @@ -163,3 +107,5 @@ X509AddPublicECC(OBJECT* object, ASN1MarshalContext* ctx) } return ASN1EndEncapsulation(ctx, ASN1_CONSTRUCTED_SEQUENCE); // Ends SEQUENCE 1st } + +#endif // #if ALG_ECC && CC_CertifyX509 diff --git a/src/tpm2/X509_RSA.c b/src/tpm2/TPMCmd/tpm/src/X509/X509_RSA.c similarity index 70% rename from src/tpm2/X509_RSA.c rename to src/tpm2/TPMCmd/tpm/src/X509/X509_RSA.c index 651e90688..385b2c2a6 100644 --- a/src/tpm2/X509_RSA.c +++ b/src/tpm2/TPMCmd/tpm/src/X509/X509_RSA.c @@ -1,62 +1,4 @@ -/********************************************************************************/ -/* */ -/* TPM X509 RSA */ -/* 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 - 2023 */ -/* */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause //** Includes #include "Tpm.h" @@ -69,7 +11,7 @@ //** Functions -#if ALG_RSA +#if ALG_RSA && CC_CertifyX509 //*** X509AddSigningAlgorithmRSA() // This creates the singing algorithm data. @@ -253,4 +195,4 @@ X509AddPublicRSA(OBJECT* object, ASN1MarshalContext* ctx) return ASN1EndEncapsulation(ctx, ASN1_CONSTRUCTED_SEQUENCE); } -#endif // ALG_RSA +#endif // ALG_RSA && CC_CertifyX509 diff --git a/src/tpm2/X509_spt.c b/src/tpm2/TPMCmd/tpm/src/X509/X509_spt.c similarity index 72% rename from src/tpm2/X509_spt.c rename to src/tpm2/TPMCmd/tpm/src/X509/X509_spt.c index 1db7eddd9..fe78af0ae 100644 --- a/src/tpm2/X509_spt.c +++ b/src/tpm2/TPMCmd/tpm/src/X509/X509_spt.c @@ -1,62 +1,4 @@ -/********************************************************************************/ -/* */ -/* X509 Support */ -/* 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 rants 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 //** Includes #include "Tpm.h" @@ -93,7 +35,7 @@ BOOL X509FindExtensionByOID(ASN1UnmarshalContext* ctxIn, // IN: the context to { INT16 length; // - pAssert(ctxIn != NULL); + pAssert_BOOL(ctxIn != NULL); // Make the search non-destructive of the input if ctx provided. Otherwise, use // the provided context. if(ctx == NULL) diff --git a/src/tpm2/Attest_spt.c b/src/tpm2/TPMCmd/tpm/src/command/Attestation/Attest_spt.c similarity index 65% rename from src/tpm2/Attest_spt.c rename to src/tpm2/TPMCmd/tpm/src/command/Attestation/Attest_spt.c index 12bccad56..8414c9b60 100644 --- a/src/tpm2/Attest_spt.c +++ b/src/tpm2/TPMCmd/tpm/src/command/Attestation/Attest_spt.c @@ -1,63 +1,4 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: Attest_spt.c 1490 2019-07-26 21:13:22Z 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 - 2018 */ -/* */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause //** Includes #include "Tpm.h" diff --git a/src/tpm2/TPMCmd/tpm/src/command/Attestation/Quote.c b/src/tpm2/TPMCmd/tpm/src/command/Attestation/Quote.c new file mode 100644 index 000000000..6ffc1b75c --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/src/command/Attestation/Quote.c @@ -0,0 +1,75 @@ +// SPDX-License-Identifier: BSD-2-Clause + +#include "Tpm.h" +#include "Attest_spt_fp.h" +#include "Quote_fp.h" + +#if CC_Quote // Conditional expansion of this file + +/*(See part 3 specification) +// quote PCR values +*/ +// Return Type: TPM_RC +// TPM_RC_KEY 'signHandle' does not reference a signing key; +// TPM_RC_SCHEME the scheme is not compatible with sign key type, +// or input scheme is not compatible with default +// scheme, or the chosen scheme is not a valid +// sign scheme +TPM_RC +TPM2_Quote(Quote_In* in, // IN: input parameter list + Quote_Out* out // OUT: output parameter list +) +{ + TPMI_ALG_HASH hashAlg; + TPMS_ATTEST quoted; + OBJECT* signObject = HandleToObject(in->signHandle); + // Input Validation + if(!IsSigningObject(signObject)) + return TPM_RCS_KEY + RC_Quote_signHandle; + if(!CryptSelectSignScheme(signObject, &in->inScheme)) + return TPM_RCS_SCHEME + RC_Quote_inScheme; + + // Command Output + + // Filling in attest information + // Common fields + // FillInAttestInfo may return TPM_RC_SCHEME or TPM_RC_KEY + FillInAttestInfo(in->signHandle, &in->inScheme, &in->qualifyingData, "ed); + + // Quote specific fields + // Attestation type + quoted.type = TPM_ST_ATTEST_QUOTE; + + // Get hash algorithm in sign scheme. This hash algorithm is used to + // compute PCR digest. If there is no algorithm, then the PCR cannot + // be digested and this command returns TPM_RC_SCHEME + hashAlg = in->inScheme.details.any.hashAlg; + + if(hashAlg == TPM_ALG_NULL) + return TPM_RCS_SCHEME + RC_Quote_inScheme; + + // Compute PCR digest + TPM_RC result = PCRComputeCurrentDigest( + hashAlg, &in->PCRselect, "ed.attested.quote.pcrDigest); + + if(result != TPM_RC_SUCCESS) + return result; + + // Copy PCR select. "PCRselect" is modified in PCRComputeCurrentDigest + // function + quoted.attested.quote.pcrSelect = in->PCRselect; + + // Sign attestation structure. A NULL signature will be returned if + // signObject is NULL. + + result = SignAttestInfo(signObject, + &in->inScheme, + "ed, + &in->qualifyingData, + &out->quoted, + &out->signature); + + return result; +} + +#endif // CC_Quote diff --git a/src/tpm2/ACT_spt.c b/src/tpm2/TPMCmd/tpm/src/command/ClockTimer/ACT_spt.c similarity index 74% rename from src/tpm2/ACT_spt.c rename to src/tpm2/TPMCmd/tpm/src/command/ClockTimer/ACT_spt.c index be0262b4b..bf3254306 100644 --- a/src/tpm2/ACT_spt.c +++ b/src/tpm2/TPMCmd/tpm/src/command/ClockTimer/ACT_spt.c @@ -1,62 +1,4 @@ -/********************************************************************************/ -/* */ -/* ACT Command Support */ -/* 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 code implements the ACT update code. It does not use a mutex. This code uses @@ -71,7 +13,7 @@ #include "Tpm.h" #include "ACT_spt_fp.h" // TODO_RENAME_INC_FOLDER:platform_interface refers to the TPM_CoreLib platform interface -#include "tpm_to_platform_interface.h" +#include //** Functions diff --git a/src/tpm2/Context_spt.c b/src/tpm2/TPMCmd/tpm/src/command/Context/Context_spt.c similarity index 73% rename from src/tpm2/Context_spt.c rename to src/tpm2/TPMCmd/tpm/src/command/Context/Context_spt.c index 963d9f880..db29319bb 100644 --- a/src/tpm2/Context_spt.c +++ b/src/tpm2/TPMCmd/tpm/src/command/Context/Context_spt.c @@ -1,62 +1,4 @@ -/********************************************************************************/ -/* */ -/* Context Management Command Support */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2016 - 2023 */ -/* */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause //** Includes @@ -140,11 +82,11 @@ TPM_RC ComputeContextProtectionKey(TPMS_CONTEXT* contextBlob, // IN: context b MemorySet(proof.b.buffer, 0, proof.b.size); // Copy part of the returned value as the key - pAssert(symKey->t.size <= sizeof(symKey->t.buffer)); + pAssert_RC(symKey->t.size <= sizeof(symKey->t.buffer)); MemoryCopy(symKey->t.buffer, kdfResult, symKey->t.size); // Copy the rest as the IV - pAssert(iv->t.size <= sizeof(iv->t.buffer)); + pAssert_RC(iv->t.size <= sizeof(iv->t.buffer)); MemoryCopy(iv->t.buffer, &kdfResult[symKey->t.size], iv->t.size); return TPM_RC_SUCCESS; @@ -210,7 +152,7 @@ TPM_RC ComputeContextIntegrity(TPMS_CONTEXT* contextBlob, // IN: context blob &hmacState.hashState, sizeof(gp.totalResetCount), gp.totalResetCount); // If this is a ST_CLEAR object, add the clear count - // so that this contest cannot be loaded after a TPM Restart + // so that this context cannot be loaded after a TPM Restart if(contextBlob->savedHandle == 0x80000002) CryptDigestUpdateInt( &hmacState.hashState, sizeof(gr.clearCount), gr.clearCount); diff --git a/src/tpm2/TPMCmd/tpm/src/command/Duplication/Duplicate.c b/src/tpm2/TPMCmd/tpm/src/command/Duplication/Duplicate.c new file mode 100644 index 000000000..df7f39efa --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/src/command/Duplication/Duplicate.c @@ -0,0 +1,132 @@ +// SPDX-License-Identifier: BSD-2-Clause + +#include "Tpm.h" +#include "Duplicate_fp.h" + +#if CC_Duplicate // Conditional expansion of this file + +# include "Object_spt_fp.h" + +/*(See part 3 specification) +// Duplicate a loaded object +*/ +// Return Type: TPM_RC +// TPM_RC_ATTRIBUTES key to duplicate has 'fixedParent' SET +// TPM_RC_HASH for an RSA key, the nameAlg digest size for the +// newParent is not compatible with the key size +// TPM_RC_HIERARCHY 'encryptedDuplication' is SET and 'newParentHandle' +// specifies Null Hierarchy +// TPM_RC_KEY 'newParentHandle' references invalid ECC key (public +// point not on the curve) +// TPM_RC_SIZE input encryption key size does not match the +// size specified in symmetric algorithm +// TPM_RC_SYMMETRIC 'encryptedDuplication' is SET but no symmetric +// algorithm is provided +// TPM_RC_TYPE 'newParentHandle' is neither a storage key nor +// TPM_RH_NULL; or the object has a NULL nameAlg +// TPM_RC_VALUE for an RSA newParent, the sizes of the digest and +// the encryption key are too large to be OAEP encoded +TPM_RC +TPM2_Duplicate(Duplicate_In* in, // IN: input parameter list + Duplicate_Out* out // OUT: output parameter list +) +{ + TPM_RC result = TPM_RC_SUCCESS; + TPMT_SENSITIVE sensitive; + + UINT16 innerKeySize = 0; // encrypt key size for inner wrap + + OBJECT* object; + OBJECT* newParent; + TPM2B_DATA data; + + // Input Validation + + // Get duplicate object pointer + object = HandleToObject(in->objectHandle); + pAssert_RC(object != NULL); + + // Get new parent + newParent = HandleToObject(in->newParentHandle); + + // duplicate key must have fixParent bit CLEAR. + if(IS_ATTRIBUTE(object->publicArea.objectAttributes, TPMA_OBJECT, fixedParent)) + return TPM_RCS_ATTRIBUTES + RC_Duplicate_objectHandle; + + // Do not duplicate object with NULL nameAlg + if(object->publicArea.nameAlg == TPM_ALG_NULL) + return TPM_RCS_TYPE + RC_Duplicate_objectHandle; + + // new parent key must be a storage object or TPM_RH_NULL + if(in->newParentHandle != TPM_RH_NULL && !ObjectIsStorage(in->newParentHandle)) + return TPM_RCS_TYPE + RC_Duplicate_newParentHandle; + + // If the duplicated object has encryptedDuplication SET, then there must be + // an inner wrapper and the new parent may not be TPM_RH_NULL + if(IS_ATTRIBUTE( + object->publicArea.objectAttributes, TPMA_OBJECT, encryptedDuplication)) + { + if(in->symmetricAlg.algorithm == TPM_ALG_NULL) + return TPM_RCS_SYMMETRIC + RC_Duplicate_symmetricAlg; + if(in->newParentHandle == TPM_RH_NULL) + return TPM_RCS_HIERARCHY + RC_Duplicate_newParentHandle; + } + + if(in->symmetricAlg.algorithm == TPM_ALG_NULL) + { + // if algorithm is TPM_ALG_NULL, input key size must be 0 + if(in->encryptionKeyIn.t.size != 0) + return TPM_RCS_SIZE + RC_Duplicate_encryptionKeyIn; + } + else + { + // Get inner wrap key size + innerKeySize = in->symmetricAlg.keyBits.sym; + + // If provided the input symmetric key must match the size of the algorithm + if(in->encryptionKeyIn.t.size != 0 + && in->encryptionKeyIn.t.size != (innerKeySize + 7) / 8) + return TPM_RCS_SIZE + RC_Duplicate_encryptionKeyIn; + } + + // Command Output + + if(in->newParentHandle != TPM_RH_NULL) + { + // Make encrypt key and its associated secret structure. A TPM_RC_KEY + // error may be returned at this point + out->outSymSeed.t.size = sizeof(out->outSymSeed.t.secret); + result = + CryptSecretEncrypt(newParent, DUPLICATE_STRING, &data, &out->outSymSeed); + if(result != TPM_RC_SUCCESS) + return result; + } + else + { + // Do not apply outer wrapper + data.t.size = 0; + out->outSymSeed.t.size = 0; + } + + // Copy sensitive area + sensitive = object->sensitive; + + // Prepare output private data from sensitive. + // Note: If there is no encryption key, one will be provided by + // SensitiveToDuplicate(). This is why the assignment of encryptionKeyIn to + // encryptionKeyOut will work properly and is not conditional. + result = SensitiveToDuplicate(&sensitive, + &object->name.b, + newParent, + object->publicArea.nameAlg, + &data.b, + &in->symmetricAlg, + &in->encryptionKeyIn, + &out->duplicate); + + out->encryptionKeyOut = in->encryptionKeyIn; + + return result; +} + +#endif // CC_Duplicate diff --git a/src/tpm2/TPMCmd/tpm/src/command/Duplication/Import.c b/src/tpm2/TPMCmd/tpm/src/command/Duplication/Import.c new file mode 100644 index 000000000..e8dc4a1c6 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/src/command/Duplication/Import.c @@ -0,0 +1,187 @@ +// SPDX-License-Identifier: BSD-2-Clause + +#include "Tpm.h" +#include "Import_fp.h" + +#if CC_Import // Conditional expansion of this file + +# include "Object_spt_fp.h" + +/*(See part 3 specification) +// This command allows an asymmetrically encrypted blob, containing a duplicated +// object to be re-encrypted using the group symmetric key associated with the +// parent. +*/ +// Return Type: TPM_RC +// TPM_RC_ATTRIBUTES 'FixedTPM' and 'fixedParent' of 'objectPublic' are not +// both CLEAR; or 'inSymSeed' is nonempty and +// 'parentHandle' does not reference a decryption key; or +// 'objectPublic' and 'parentHandle' have incompatible +// or inconsistent attributes; or +// encrytpedDuplication is SET in 'objectPublic' but the +// inner or outer wrapper is missing. +// Note that if the TPM provides parameter values, the +// parameter number will indicate 'symmetricKey' (missing +// inner wrapper) or 'inSymSeed' (missing outer wrapper) +// TPM_RC_BINDING 'duplicate' and 'objectPublic' are not +// cryptographically bound +// TPM_RC_ECC_POINT 'inSymSeed' is nonempty and ECC point in 'inSymSeed' +// is not on the curve +// TPM_RC_HASH 'objectPublic' does not have a valid nameAlg +// TPM_RC_INSUFFICIENT 'inSymSeed' is nonempty and failed to retrieve ECC +// point from the secret; or unmarshaling sensitive value +// from 'duplicate' failed the result of 'inSymSeed' +// decryption +// TPM_RC_INTEGRITY 'duplicate' integrity is broken +// TPM_RC_KDF 'objectPublic' representing decrypting keyed hash +// object specifies invalid KDF +// TPM_RC_KEY inconsistent parameters of 'objectPublic'; or +// 'inSymSeed' is nonempty and 'parentHandle' does not +// reference a key of supported type; or +// invalid key size in 'objectPublic' representing an +// asymmetric key +// TPM_RC_NO_RESULT 'inSymSeed' is nonempty and multiplication resulted in +// ECC point at infinity +// TPM_RC_OBJECT_MEMORY no available object slot +// TPM_RC_SCHEME inconsistent attributes 'decrypt', 'sign', +// 'restricted' and key's scheme ID in 'objectPublic'; +// or hash algorithm is inconsistent with the scheme ID +// for keyed hash object +// TPM_RC_SIZE 'authPolicy' size does not match digest size of the +// name algorithm in 'objectPublic'; or +// 'symmetricAlg' and 'encryptionKey' have different +// sizes; or +// 'inSymSeed' is nonempty and it size is not +// consistent with the type of 'parentHandle'; or +// unmarshaling sensitive value from 'duplicate' failed +// TPM_RC_SYMMETRIC 'objectPublic' is either a storage key with no +// symmetric algorithm or a non-storage key with +// symmetric algorithm different from TPM_ALG_NULL +// TPM_RC_TYPE unsupported type of 'objectPublic'; or +// 'parentHandle' is not a storage key; or +// only the public portion of 'parentHandle' is loaded; +// or 'objectPublic' and 'duplicate' are of different +// types +// TPM_RC_VALUE nonempty 'inSymSeed' and its numeric value is +// greater than the modulus of the key referenced by +// 'parentHandle' or 'inSymSeed' is larger than the +// size of the digest produced by the name algorithm of +// the symmetric key referenced by 'parentHandle' +TPM_RC +TPM2_Import(Import_In* in, // IN: input parameter list + Import_Out* out // OUT: output parameter list +) +{ + TPM_RC result = TPM_RC_SUCCESS; + OBJECT* parentObject; + TPM2B_DATA data; // symmetric key + TPMT_SENSITIVE sensitive; + TPM2B_NAME name; + TPMA_OBJECT attributes; + UINT16 innerKeySize = 0; // encrypt key size for inner + // wrapper + + // Input Validation + // to save typing + attributes = in->objectPublic.publicArea.objectAttributes; + // FixedTPM and fixedParent must be CLEAR + if(IS_ATTRIBUTE(attributes, TPMA_OBJECT, fixedTPM) + || IS_ATTRIBUTE(attributes, TPMA_OBJECT, fixedParent)) + return TPM_RCS_ATTRIBUTES + RC_Import_objectPublic; + + // Get parent pointer + parentObject = HandleToObject(in->parentHandle); + pAssert_RC(parentObject != NULL); + + if(!ObjectIsParent(parentObject)) + return TPM_RCS_TYPE + RC_Import_parentHandle; + + if(in->symmetricAlg.algorithm != TPM_ALG_NULL) + { + // Get inner wrap key size + innerKeySize = in->symmetricAlg.keyBits.sym; + // Input symmetric key must match the size of algorithm. + if(in->encryptionKey.t.size != (innerKeySize + 7) / 8) + return TPM_RCS_SIZE + RC_Import_encryptionKey; + } + else + { + // If input symmetric algorithm is NULL, input symmetric key size must + // be 0 as well + if(in->encryptionKey.t.size != 0) + return TPM_RCS_SIZE + RC_Import_encryptionKey; + // If encryptedDuplication is SET, then the object must have an inner + // wrapper + if(IS_ATTRIBUTE(attributes, TPMA_OBJECT, encryptedDuplication)) + return TPM_RCS_ATTRIBUTES + RC_Import_encryptionKey; + } + // See if there is an outer wrapper + if(in->inSymSeed.t.size != 0) + { + // in->inParentHandle is a parent, but in order to decrypt an outer wrapper, + // it must be able to do key exchange and a symmetric key can't do that. + if(parentObject->publicArea.type == TPM_ALG_SYMCIPHER) + return TPM_RCS_TYPE + RC_Import_parentHandle; + + // Decrypt input secret data via asymmetric decryption. TPM_RC_ATTRIBUTES, + // TPM_RC_ECC_POINT, TPM_RC_INSUFFICIENT, TPM_RC_KEY, TPM_RC_NO_RESULT, + // TPM_RC_SIZE, TPM_RC_VALUE may be returned at this point + result = CryptSecretDecrypt( + parentObject, NULL, DUPLICATE_STRING, &in->inSymSeed, &data); + pAssert_RC(result != TPM_RC_BINDING); + if(result != TPM_RC_SUCCESS) + return RcSafeAddToResult(result, RC_Import_inSymSeed); + } + else + { + // If encrytpedDuplication is set, then the object must have an outer + // wrapper + if(IS_ATTRIBUTE(attributes, TPMA_OBJECT, encryptedDuplication)) + return TPM_RCS_ATTRIBUTES + RC_Import_inSymSeed; + data.t.size = 0; + } + // Compute name of object + PublicMarshalAndComputeName(&(in->objectPublic.publicArea), &name); + if(name.t.size == 0) + return TPM_RCS_HASH + RC_Import_objectPublic; + + // Retrieve sensitive from private. + // TPM_RC_INSUFFICIENT, TPM_RC_INTEGRITY, TPM_RC_SIZE may be returned here. + result = DuplicateToSensitive(&in->duplicate.b, + &name.b, + parentObject, + in->objectPublic.publicArea.nameAlg, + &data.b, + &in->symmetricAlg, + &in->encryptionKey.b, + &sensitive); + if(result != TPM_RC_SUCCESS) + return RcSafeAddToResult(result, RC_Import_duplicate); + + // If the parent of this object has fixedTPM SET, then validate this + // object as if it were being loaded so that validation can be skipped + // when it is actually loaded. + if(IS_ATTRIBUTE(parentObject->publicArea.objectAttributes, TPMA_OBJECT, fixedTPM)) + { + result = ObjectLoad(NULL, + NULL, + &in->objectPublic.publicArea, + &sensitive, + RC_Import_objectPublic, + RC_Import_duplicate, + NULL); + } + // Command output + if(result == TPM_RC_SUCCESS) + { + // Prepare output private data from sensitive + result = SensitiveToPrivate(&sensitive, + &name, + parentObject, + in->objectPublic.publicArea.nameAlg, + &out->outPrivate); + } + return result; +} + +#endif // CC_Import diff --git a/src/tpm2/TPMCmd/tpm/src/command/EA/PolicyAuthorize.c b/src/tpm2/TPMCmd/tpm/src/command/EA/PolicyAuthorize.c new file mode 100644 index 000000000..4a18c71ff --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/src/command/EA/PolicyAuthorize.c @@ -0,0 +1,98 @@ +// SPDX-License-Identifier: BSD-2-Clause + +#include "Tpm.h" +#include "PolicyAuthorize_fp.h" + +#if CC_PolicyAuthorize // Conditional expansion of this file + +# include "Policy_spt_fp.h" + +/*(See part 3 specification) +// Change policy by a signature from authority +*/ +// Return Type: TPM_RC +// TPM_RC_HASH hash algorithm in 'keyName' is not supported +// TPM_RC_SIZE 'keyName' is not the correct size for its hash algorithm +// TPM_RC_VALUE the current policyDigest of 'policySession' does not +// match 'approvedPolicy'; or 'checkTicket' doesn't match +// the provided values +TPM_RC +TPM2_PolicyAuthorize(PolicyAuthorize_In* in // IN: input parameter list +) +{ + TPM_RC result = TPM_RC_SUCCESS; + SESSION* session; + TPM2B_DIGEST authHash; + HASH_STATE hashState; + TPMT_TK_VERIFIED ticket; + TPM_ALG_ID hashAlg; + UINT16 digestSize; + + // Input Validation + + // Get pointer to the session structure + session = SessionGet(in->policySession); + pAssert_RC(session); + + if(in->keySign.t.size < 2) + { + return TPM_RCS_SIZE + RC_PolicyAuthorize_keySign; + } + + // Extract from the Name of the key, the algorithm used to compute its Name + hashAlg = BYTE_ARRAY_TO_UINT16(in->keySign.t.name); + + // 'keySign' parameter needs to use a supported hash algorithm, otherwise + // can't tell how large the digest should be + if(!CryptHashIsValidAlg(hashAlg, FALSE)) + return TPM_RCS_HASH + RC_PolicyAuthorize_keySign; + + digestSize = CryptHashGetDigestSize(hashAlg); + if(digestSize != (in->keySign.t.size - 2)) + return TPM_RCS_SIZE + RC_PolicyAuthorize_keySign; + + //If this is a trial policy, skip all validations + if(session->attributes.isTrialPolicy == CLEAR) + { + // Check that "approvedPolicy" matches the current value of the + // policyDigest in policy session + if(!MemoryEqual2B(&session->u2.policyDigest.b, &in->approvedPolicy.b)) + return TPM_RCS_VALUE + RC_PolicyAuthorize_approvedPolicy; + + // Validate ticket TPMT_TK_VERIFIED + // Compute aHash. The authorizing object sign a digest + // aHash := hash(approvedPolicy || policyRef). + // Start hash + authHash.t.size = CryptHashStart(&hashState, hashAlg); + + // add approvedPolicy + CryptDigestUpdate2B(&hashState, &in->approvedPolicy.b); + + // add policyRef + CryptDigestUpdate2B(&hashState, &in->policyRef.b); + + // complete hash + CryptHashEnd2B(&hashState, &authHash.b); + + // re-compute TPMT_TK_VERIFIED + result = TicketComputeVerified( + in->checkTicket.hierarchy, &authHash, &in->keySign, &ticket); + if(result != TPM_RC_SUCCESS) + return result; + + // Compare ticket digest. If not match, return error + if(!MemoryEqual2B(&in->checkTicket.digest.b, &ticket.digest.b)) + return TPM_RCS_VALUE + RC_PolicyAuthorize_checkTicket; + } + + // Internal Data Update + + // Set policyDigest to zero digest + PolicyDigestClear(session); + + // Update policyDigest + return PolicyContextUpdate( + TPM_CC_PolicyAuthorize, &in->keySign, &in->policyRef, NULL, 0, session); +} + +#endif // CC_PolicyAuthorize diff --git a/src/tpm2/TPMCmd/tpm/src/command/EA/PolicyAuthorizeNV.c b/src/tpm2/TPMCmd/tpm/src/command/EA/PolicyAuthorizeNV.c new file mode 100644 index 000000000..c4b8236f6 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/src/command/EA/PolicyAuthorizeNV.c @@ -0,0 +1,91 @@ +// SPDX-License-Identifier: BSD-2-Clause + +#include "Tpm.h" + +#if CC_PolicyAuthorizeNV // Conditional expansion of this file + +# include "PolicyAuthorizeNV_fp.h" +# include "Policy_spt_fp.h" +# include "Marshal.h" + +/*(See part 3 specification) +// Change policy by a signature from authority +*/ +// Return Type: TPM_RC +// TPM_RC_HASH hash algorithm in 'keyName' is not supported or is not +// the same as the hash algorithm of the policy session +// TPM_RC_SIZE 'keyName' is not the correct size for its hash algorithm +// TPM_RC_VALUE the current policyDigest of 'policySession' does not +// match 'approvedPolicy'; or 'checkTicket' doesn't match +// the provided values +TPM_RC +TPM2_PolicyAuthorizeNV(PolicyAuthorizeNV_In* in) +{ + SESSION* session; + TPM_RC result; + NV_REF locator; + NV_INDEX* nvIndex = NvGetIndexInfo(in->nvIndex, &locator); + TPM2B_NAME name; + TPMT_HA policyInNv = { + .hashAlg = 0, // libpms added: Coverity + }; + BYTE nvTemp[sizeof(TPMT_HA)]; + BYTE* buffer = nvTemp; + INT32 size; + + // Input Validation + // Get pointer to the session structure + session = SessionGet(in->policySession); + pAssert_RC(session); + + // Skip checks if this is a trial policy + if(!session->attributes.isTrialPolicy) + { + // Check the authorizations for reading + // Common read access checks. NvReadAccessChecks() returns + // TPM_RC_NV_AUTHORIZATION, TPM_RC_NV_LOCKED, or TPM_RC_NV_UNINITIALIZED + // error may be returned at this point + result = NvReadAccessChecks( + in->authHandle, in->nvIndex, nvIndex->publicArea.attributes); + if(result != TPM_RC_SUCCESS) + return result; + + // Read the contents of the index into a temp buffer + size = MIN(nvIndex->publicArea.dataSize, sizeof(TPMT_HA)); + NvGetIndexData(nvIndex, locator, 0, (UINT16)size, nvTemp); + + // Unmarshal the contents of the buffer into the internal format of a + // TPMT_HA so that the hash and digest elements can be accessed from the + // structure rather than the byte array that is in the Index (written by + // user of the Index). + result = TPMT_HA_Unmarshal(&policyInNv, &buffer, &size, FALSE); + if(result != TPM_RC_SUCCESS) + return result; + + // Verify that the hash is the same + if(policyInNv.hashAlg != session->authHashAlg) + return TPM_RC_HASH; + + // See if the contents of the digest in the Index matches the value + // in the policy + if(!MemoryEqual(&policyInNv.digest, + &session->u2.policyDigest.t.buffer, + session->u2.policyDigest.t.size)) + return TPM_RC_VALUE; + } + + // Internal Data Update + + // Set policyDigest to zero digest + PolicyDigestClear(session); + + // Update policyDigest + return PolicyContextUpdate(TPM_CC_PolicyAuthorizeNV, + EntityGetName(in->nvIndex, &name), + NULL, + NULL, + 0, + session); +} + +#endif // CC_PolicyAuthorize diff --git a/src/tpm2/TPMCmd/tpm/src/command/EA/PolicyPCR.c b/src/tpm2/TPMCmd/tpm/src/command/EA/PolicyPCR.c new file mode 100644 index 000000000..e8292c405 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/src/command/EA/PolicyPCR.c @@ -0,0 +1,98 @@ +// SPDX-License-Identifier: BSD-2-Clause + +#include "Tpm.h" + +#if CC_PolicyPCR // Conditional expansion of this file + +# include "PolicyPCR_fp.h" +# include "Marshal.h" + +/*(See part 3 specification) +// Add a PCR gate for a policy session +*/ +// Return Type: TPM_RC +// TPM_RC_VALUE if provided, 'pcrDigest' does not match the +// current PCR settings +// TPM_RC_PCR_CHANGED a previous TPM2_PolicyPCR() set +// pcrCounter and it has changed +TPM_RC +TPM2_PolicyPCR(PolicyPCR_In* in // IN: input parameter list +) +{ + SESSION* session; + TPM2B_DIGEST pcrDigest; + BYTE pcrs[sizeof(TPML_PCR_SELECTION)]; + UINT32 pcrSize; + BYTE* buffer; + TPM_CC commandCode = TPM_CC_PolicyPCR; + HASH_STATE hashState; + + // Input Validation + + // Get pointer to the session structure + session = SessionGet(in->policySession); + pAssert_RC(session); + + // Compute current PCR digest + TPM_RC result = + PCRComputeCurrentDigest(session->authHashAlg, &in->pcrs, &pcrDigest); + if(result != TPM_RC_SUCCESS) + return result; + + // Do validation for non trial session + if(session->attributes.isTrialPolicy == CLEAR) + { + // Make sure that this is not going to invalidate a previous PCR check + if(session->pcrCounter != 0 && session->pcrCounter != gr.pcrCounter) + return TPM_RC_PCR_CHANGED; + + // If the caller specified the PCR digest and it does not + // match the current PCR settings, return an error.. + if(in->pcrDigest.t.size != 0) + { + if(!MemoryEqual2B(&in->pcrDigest.b, &pcrDigest.b)) + return TPM_RCS_VALUE + RC_PolicyPCR_pcrDigest; + } + } + else + { + // For trial session, just use the input PCR digest if one provided + // Note: It can't be too big because it is a TPM2B_DIGEST and the size + // would have been checked during unmarshaling + if(in->pcrDigest.t.size != 0) + pcrDigest = in->pcrDigest; + } + // Internal Data Update + // Update policy hash + // policyDigestnew = hash( policyDigestold || TPM_CC_PolicyPCR + // || PCRS || pcrDigest) + // Start hash + CryptHashStart(&hashState, session->authHashAlg); + + // add old digest + CryptDigestUpdate2B(&hashState, &session->u2.policyDigest.b); + + // add commandCode + CryptDigestUpdateInt(&hashState, sizeof(TPM_CC), commandCode); + + // add PCRS + buffer = pcrs; + pcrSize = TPML_PCR_SELECTION_Marshal(&in->pcrs, &buffer, NULL); + CryptDigestUpdate(&hashState, pcrSize, pcrs); + + // add PCR digest + CryptDigestUpdate2B(&hashState, &pcrDigest.b); + + // complete the hash and get the results + CryptHashEnd2B(&hashState, &session->u2.policyDigest.b); + + // update pcrCounter in session context for non trial session + if(session->attributes.isTrialPolicy == CLEAR) + { + session->pcrCounter = gr.pcrCounter; + } + + return TPM_RC_SUCCESS; +} + +#endif // CC_PolicyPCR diff --git a/src/tpm2/TPMCmd/tpm/src/command/EA/PolicySecret.c b/src/tpm2/TPMCmd/tpm/src/command/EA/PolicySecret.c new file mode 100644 index 000000000..6ef0fb64c --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/src/command/EA/PolicySecret.c @@ -0,0 +1,120 @@ +// SPDX-License-Identifier: BSD-2-Clause + +#include "Tpm.h" +#include "PolicySecret_fp.h" + +#if CC_PolicySecret // Conditional expansion of this file + +# include "Policy_spt_fp.h" +# include "NV_spt_fp.h" + +/*(See part 3 specification) +// Add a secret-based authorization to the policy evaluation +*/ +// Return Type: TPM_RC +// TPM_RC_CPHASH cpHash for policy was previously set to a +// value that is not the same as 'cpHashA' +// TPM_RC_EXPIRED 'expiration' indicates a time in the past +// TPM_RC_NONCE 'nonceTPM' does not match the nonce associated +// with 'policySession' +// TPM_RC_SIZE 'cpHashA' is not the size of a digest for the +// hash associated with 'policySession' +TPM_RC +TPM2_PolicySecret(PolicySecret_In* in, // IN: input parameter list + PolicySecret_Out* out // OUT: output parameter list +) +{ + TPM_RC result; + SESSION* session; + TPM2B_NAME entityName; + UINT64 authTimeout = 0; + // Input Validation + +# if CC_ReadOnlyControl + // Don't allow on PIN PASS or PIN FAIL indices when in Read-Only mode + if(gc.readOnly && NvIsPinCountedIndex(in->authHandle)) + return TPM_RC_READ_ONLY; +# endif // CC_ReadOnlyControl + + // Get pointer to the session structure + session = SessionGet(in->policySession); + pAssert_RC(session); + + //Only do input validation if this is not a trial policy session + if(session->attributes.isTrialPolicy == CLEAR) + { + authTimeout = ComputeAuthTimeout(session, in->expiration, &in->nonceTPM); + + result = PolicyParameterChecks(session, + authTimeout, + &in->cpHashA, + &in->nonceTPM, + RC_PolicySecret_nonceTPM, + RC_PolicySecret_cpHashA, + RC_PolicySecret_expiration); + if(result != TPM_RC_SUCCESS) + return result; + } + // Internal Data Update + // Update policy context with input policyRef and name of authorizing key + // This value is computed even for trial sessions. Possibly update the cpHash + result = PolicyContextUpdate(TPM_CC_PolicySecret, + EntityGetName(in->authHandle, &entityName), + &in->policyRef, + &in->cpHashA, + authTimeout, + session); + if(result != TPM_RC_SUCCESS) + { + return result; + } + + // Command Output + // Create ticket and timeout buffer if in->expiration < 0 and this is not + // a trial session. + // NOTE: PolicyParameterChecks() makes sure that nonceTPM is present + // when expiration is non-zero. + if(in->expiration < 0 && session->attributes.isTrialPolicy == CLEAR + && !NvIsPinPassIndex(in->authHandle)) + { + BOOL expiresOnReset = (in->nonceTPM.t.size == 0); + // Compute policy ticket + authTimeout &= ~EXPIRATION_BIT; + result = TicketComputeAuth(TPM_ST_AUTH_SECRET, + EntityGetHierarchy(in->authHandle), + authTimeout, + expiresOnReset, + &in->cpHashA, + &in->policyRef, + &entityName, + &out->policyTicket); + if(result != TPM_RC_SUCCESS) + return result; + + // Generate timeout buffer. The format of output timeout buffer is + // TPM-specific. + // Note: In this implementation, the timeout buffer value is computed after + // the ticket is produced so, when the ticket is checked, the expiration + // flag needs to be extracted before the ticket is checked. + out->timeout.t.size = sizeof(authTimeout); + // In the Windows compatible version, the least-significant bit of the + // timeout value is used as a flag to indicate if the authorization expires + // on reset. The flag is the MSb. + if(expiresOnReset) + authTimeout |= EXPIRATION_BIT; + UINT64_TO_BYTE_ARRAY(authTimeout, out->timeout.t.buffer); + } + else + { + // timeout buffer is null + out->timeout.t.size = 0; + + // authorization ticket is null + out->policyTicket.tag = TPM_ST_AUTH_SECRET; + out->policyTicket.hierarchy = TPM_RH_NULL; + out->policyTicket.digest.t.size = 0; + } + return result; +} + +#endif // CC_PolicySecret diff --git a/src/tpm2/TPMCmd/tpm/src/command/EA/PolicySigned.c b/src/tpm2/TPMCmd/tpm/src/command/EA/PolicySigned.c new file mode 100644 index 000000000..37a1f1950 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/src/command/EA/PolicySigned.c @@ -0,0 +1,164 @@ +// SPDX-License-Identifier: BSD-2-Clause + +#include "Tpm.h" +#include "Policy_spt_fp.h" +#include "PolicySigned_fp.h" + +#if CC_PolicySigned // Conditional expansion of this file + +/*(See part 3 specification) +// Include an asymmetrically signed authorization to the policy evaluation +*/ +// Return Type: TPM_RC +// TPM_RC_CPHASH cpHash was previously set to a different value +// TPM_RC_EXPIRED 'expiration' indicates a time in the past or +// 'expiration' is non-zero but no nonceTPM is present +// TPM_RC_NONCE 'nonceTPM' is not the nonce associated with the +// 'policySession' +// TPM_RC_SCHEME the signing scheme of 'auth' is not supported by the +// TPM +// TPM_RC_SIGNATURE the signature is not genuine +// TPM_RC_SIZE input cpHash has wrong size +TPM_RC +TPM2_PolicySigned(PolicySigned_In* in, // IN: input parameter list + PolicySigned_Out* out // OUT: output parameter list +) +{ + TPM_RC result = TPM_RC_SUCCESS; + SESSION* session; + TPM2B_NAME entityName; + TPM2B_DIGEST authHash; + HASH_STATE hashState; + UINT64 authTimeout = 0; + // Input Validation + // Set up local pointers + session = SessionGet(in->policySession); // the session structure + pAssert_RC(session); + + // Only do input validation if this is not a trial policy session + if(session->attributes.isTrialPolicy == CLEAR) + { + authTimeout = ComputeAuthTimeout(session, in->expiration, &in->nonceTPM); + + result = PolicyParameterChecks(session, + authTimeout, + &in->cpHashA, + &in->nonceTPM, + RC_PolicySigned_nonceTPM, + RC_PolicySigned_cpHashA, + RC_PolicySigned_expiration); + if(result != TPM_RC_SUCCESS) + return result; + // Re-compute the digest being signed + /*(See part 3 specification) + // The digest is computed as: + // aHash := hash ( nonceTPM | expiration | cpHashA | policyRef) + // where: + // hash() the hash associated with the signed authorization + // nonceTPM the nonceTPM value from the TPM2_StartAuthSession . + // response If the authorization is not limited to this + // session, the size of this value is zero. + // expiration time limit on authorization set by authorizing object. + // This 32-bit value is set to zero if the expiration + // time is not being set. + // cpHashA hash of the command parameters for the command being + // approved using the hash algorithm of the PSAP session. + // Set to NULLauth if the authorization is not limited + // to a specific command. + // policyRef hash of an opaque value determined by the authorizing + // object. Set to the NULLdigest if no hash is present. + */ + // Start hash + authHash.t.size = CryptHashStart(&hashState, CryptGetSignHashAlg(&in->auth)); + // If there is no digest size, then we don't have a verification function + // for this algorithm (e.g. TPM_ALG_ECDAA) so indicate that it is a + // bad scheme. + if(authHash.t.size == 0) + return TPM_RCS_SCHEME + RC_PolicySigned_auth; + + // nonceTPM + CryptDigestUpdate2B(&hashState, &in->nonceTPM.b); + + // expiration + CryptDigestUpdateInt(&hashState, sizeof(UINT32), in->expiration); + + // cpHashA + CryptDigestUpdate2B(&hashState, &in->cpHashA.b); + + // policyRef + CryptDigestUpdate2B(&hashState, &in->policyRef.b); + + // Complete digest + CryptHashEnd2B(&hashState, &authHash.b); + + // Validate Signature. A TPM_RC_SCHEME, TPM_RC_HANDLE or TPM_RC_SIGNATURE + // error may be returned at this point + result = CryptValidateSignature(in->authObject, &authHash, &in->auth); + if(result != TPM_RC_SUCCESS) + return RcSafeAddToResult(result, RC_PolicySigned_auth); + } + // Internal Data Update + // Update policy with input policyRef and name of authorization key + // These values are updated even if the session is a trial session + result = PolicyContextUpdate(TPM_CC_PolicySigned, + EntityGetName(in->authObject, &entityName), + &in->policyRef, + &in->cpHashA, + authTimeout, + session); + + if(result != TPM_RC_SUCCESS) + { + return result; + } + + // Command Output + // Create ticket and timeout buffer if in->expiration < 0 and this is not + // a trial session. + // NOTE: PolicyParameterChecks() makes sure that nonceTPM is present + // when expiration is non-zero. + if(in->expiration < 0 && session->attributes.isTrialPolicy == CLEAR) + { + BOOL expiresOnReset = (in->nonceTPM.t.size == 0); + // Compute policy ticket + authTimeout &= ~EXPIRATION_BIT; + + result = TicketComputeAuth(TPM_ST_AUTH_SIGNED, + EntityGetHierarchy(in->authObject), + authTimeout, + expiresOnReset, + &in->cpHashA, + &in->policyRef, + &entityName, + &out->policyTicket); + if(result != TPM_RC_SUCCESS) + return result; + + // Generate timeout buffer. The format of output timeout buffer is + // TPM-specific. + // Note: In this implementation, the timeout buffer value is computed after + // the ticket is produced so, when the ticket is checked, the expiration + // flag needs to be extracted before the ticket is checked. + // In the Windows compatible version, the least-significant bit of the + // timeout value is used as a flag to indicate if the authorization expires + // on reset. The flag is the MSb. + out->timeout.t.size = sizeof(authTimeout); + if(expiresOnReset) + authTimeout |= EXPIRATION_BIT; + UINT64_TO_BYTE_ARRAY(authTimeout, out->timeout.t.buffer); + } + else + { + // Generate a null ticket. + // timeout buffer is null + out->timeout.t.size = 0; + + // authorization ticket is null + out->policyTicket.tag = TPM_ST_AUTH_SIGNED; + out->policyTicket.hierarchy = TPM_RH_NULL; + out->policyTicket.digest.t.size = 0; + } + return result; +} + +#endif // CC_PolicySigned diff --git a/src/tpm2/TPMCmd/tpm/src/command/EA/PolicyTicket.c b/src/tpm2/TPMCmd/tpm/src/command/EA/PolicyTicket.c new file mode 100644 index 000000000..c2ad3b731 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/src/command/EA/PolicyTicket.c @@ -0,0 +1,107 @@ +// SPDX-License-Identifier: BSD-2-Clause + +#include "Tpm.h" +#include "PolicyTicket_fp.h" + +#if CC_PolicyTicket // Conditional expansion of this file + +# include "Policy_spt_fp.h" + +/*(See part 3 specification) +// Include ticket to the policy evaluation +*/ +// Return Type: TPM_RC +// TPM_RC_CPHASH policy's cpHash was previously set to a different +// value +// TPM_RC_EXPIRED 'timeout' value in the ticket is in the past and the +// ticket has expired +// TPM_RC_SIZE 'timeout' or 'cpHash' has invalid size for the +// TPM_RC_TICKET 'ticket' is not valid +TPM_RC +TPM2_PolicyTicket(PolicyTicket_In* in // IN: input parameter list +) +{ + TPM_RC result; + SESSION* session; + UINT64 authTimeout; + TPMT_TK_AUTH ticketToCompare; + TPM_CC commandCode = TPM_CC_PolicySecret; + BOOL expiresOnReset; + + // Input Validation + + // Get pointer to the session structure + session = SessionGet(in->policySession); + pAssert_RC(session); + + // NOTE: A trial policy session is not allowed to use this command. + // A ticket is used in place of a previously given authorization. Since + // a trial policy doesn't actually authenticate, the validated + // ticket is not necessary and, in place of using a ticket, one + // should use the intended authorization for which the ticket + // would be a substitute. + if(session->attributes.isTrialPolicy) + return TPM_RCS_ATTRIBUTES + RC_PolicyTicket_policySession; + // Restore timeout data. The format of timeout buffer is TPM-specific. + // In this implementation, the most significant bit of the timeout value is + // used as the flag to indicate that the ticket expires on TPM Reset or + // TPM Restart. The flag has to be removed before the parameters and ticket + // are checked. + if(in->timeout.t.size != sizeof(UINT64)) + return TPM_RCS_SIZE + RC_PolicyTicket_timeout; + authTimeout = BYTE_ARRAY_TO_UINT64(in->timeout.t.buffer); + + // extract the flag + expiresOnReset = (authTimeout & EXPIRATION_BIT) != 0; + authTimeout &= ~EXPIRATION_BIT; + + // Do the normal checks on the cpHashA and timeout values + result = PolicyParameterChecks(session, + authTimeout, + &in->cpHashA, + NULL, // no nonce + 0, // no bad nonce return + RC_PolicyTicket_cpHashA, + RC_PolicyTicket_timeout); + if(result != TPM_RC_SUCCESS) + return result; + // Validate Ticket + // Re-generate policy ticket by input parameters + result = TicketComputeAuth(in->ticket.tag, + in->ticket.hierarchy, + authTimeout, + expiresOnReset, + &in->cpHashA, + &in->policyRef, + &in->authName, + &ticketToCompare); + if(result != TPM_RC_SUCCESS) + return result; + + // Compare generated digest with input ticket digest + if(!MemoryEqual2B(&in->ticket.digest.b, &ticketToCompare.digest.b)) + return TPM_RCS_TICKET + RC_PolicyTicket_ticket; + + // Internal Data Update + + // Is this ticket to take the place of a TPM2_PolicySigned() or + // a TPM2_PolicySecret()? + if(in->ticket.tag == TPM_ST_AUTH_SIGNED) + commandCode = TPM_CC_PolicySigned; + else if(in->ticket.tag == TPM_ST_AUTH_SECRET) + commandCode = TPM_CC_PolicySecret; + else + // There could only be two possible tag values. Any other value should + // be caught by the ticket validation process. + FAIL(FATAL_ERROR_INTERNAL); + + // Update policy context + return PolicyContextUpdate(commandCode, + &in->authName, + &in->policyRef, + &in->cpHashA, + authTimeout, + session); +} + +#endif // CC_PolicyTicket diff --git a/src/tpm2/TPMCmd/tpm/src/command/EA/PolicyTransportSPDM.c b/src/tpm2/TPMCmd/tpm/src/command/EA/PolicyTransportSPDM.c new file mode 100644 index 000000000..e51aa48d0 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/src/command/EA/PolicyTransportSPDM.c @@ -0,0 +1,139 @@ +// SPDX-License-Identifier: BSD-2-Clause + +#include "Tpm.h" +#include "PolicyTransportSPDM_fp.h" + +#if CC_PolicyTransportSPDM // Conditional expansion of this file + +/*(See part 3 specification) +// Add secure channel restrictions to the policyDigest +*/ +// Return Type: TPM_RC +// TPM_RC_VALUE TPM2_PolicyTransportSPDM has previously been executed +// TPM_RC_HASH hash algorithm in 'reqKeyName' or 'tpmKeyName' is not supported +// TPM_RC_SIZE 'reqKeyName' or 'tpmKeyName' is not the correct size for its hash algorithm +TPM_RC +TPM2_PolicyTransportSPDM(PolicyTransportSPDM_In* in // IN: input parameter list +) +{ + SESSION* session; + TPM_CC commandCode = TPM_CC_PolicyTransportSPDM; + TPM_ALG_ID hashAlg; + UINT16 digestSize; + HASH_STATE hashState; + TPM2B_DIGEST scKeyNameHash; + + // Input Validation + + // Get pointer to the session structure + session = SessionGet(in->policySession); + + // Check that TPM2_PolicyTransportSPDM has not previously been executed + if(session->attributes.checkSecureChannel == SET) + return TPM_RC_VALUE; + + // If 'reqKeyName' or 'tpmKeyName' are provided, check that they are valid Names + if(in->reqKeyName.t.size != 0) + { + if(in->reqKeyName.t.size < 2) + { + return TPM_RCS_SIZE + RC_PolicyTransportSPDM_reqKeyName; + } + + // Extract from the Name of the key, the algorithm used to compute its Name + hashAlg = BYTE_ARRAY_TO_UINT16(in->reqKeyName.t.name); + + // 'reqKeyName' parameter must use a supported hash algorithm + if(!CryptHashIsValidAlg(hashAlg, FALSE)) + return TPM_RCS_HASH + RC_PolicyTransportSPDM_reqKeyName; + + // and its size must be consistent with the hash algorithm + digestSize = CryptHashGetDigestSize(hashAlg); + if(digestSize != (in->reqKeyName.t.size - 2)) + return TPM_RCS_SIZE + RC_PolicyTransportSPDM_reqKeyName; + } + + if(in->tpmKeyName.t.size != 0) + { + if(in->tpmKeyName.t.size < 2) + { + return TPM_RCS_SIZE + RC_PolicyTransportSPDM_tpmKeyName; + } + + // Extract from the Name of the key, the algorithm used to compute its Name + hashAlg = BYTE_ARRAY_TO_UINT16(in->tpmKeyName.t.name); + + // 'tpmKeyName' parameter must use a supported hash algorithm + if(!CryptHashIsValidAlg(hashAlg, FALSE)) + return TPM_RCS_HASH + RC_PolicyTransportSPDM_tpmKeyName; + + // and its size must be consistent with the hash algorithm + digestSize = CryptHashGetDigestSize(hashAlg); + if(digestSize != (in->tpmKeyName.t.size - 2)) + return TPM_RCS_SIZE + RC_PolicyTransportSPDM_tpmKeyName; + } + + // Internal Data Update + if(in->reqKeyName.t.size != 0 || in->tpmKeyName.t.size != 0) + { + // Compute secure channel key name hash + // scKeyNameHash = hash(reqKeyName.size || reqKeyName.name || tpmKeyName.size || tpmKeyName.name) + // Start hash + scKeyNameHash.t.size = CryptHashStart(&hashState, session->authHashAlg); + + // Add reqKeyName.size + CryptDigestUpdateInt(&hashState, sizeof(UINT16), in->reqKeyName.t.size); + + // Add reqKeyName.name (absent if Empty Buffer) + CryptDigestUpdate2B(&hashState, &in->reqKeyName.b); + + // Add tpmKeyName.size + CryptDigestUpdateInt(&hashState, sizeof(UINT16), in->tpmKeyName.t.size); + + // Add tpmKeyName.name (absent if Empty Buffer) + CryptDigestUpdate2B(&hashState, &in->tpmKeyName.b); + + // Complete digest + CryptHashEnd2B(&hashState, &scKeyNameHash.b); + + // Update scKeyNameHash in session context + session->scKeyNameHash = scKeyNameHash; + } + else + { + scKeyNameHash.t.size = 0; + } + + // Update policy hash + // policyDigestnew = hash(policyDigestold || TPM_CC_PolicyTransportSPDM || scKeyNameHash) + // Start hash + session->u2.policyDigest.t.size = + CryptHashStart(&hashState, session->authHashAlg); + + // Add old digest + CryptDigestUpdate2B(&hashState, &session->u2.policyDigest.b); + + // Add commandCode + CryptDigestUpdateInt(&hashState, sizeof(TPM_CC), commandCode); + + // Add scKeyNameHash (absent if Empty Buffer) + CryptDigestUpdate2B(&hashState, &scKeyNameHash.b); + + // Complete the digest and get the results + CryptHashEnd2B(&hashState, &session->u2.policyDigest.b); + + // Update session context + session->attributes.checkSecureChannel = SET; + if(in->reqKeyName.t.size != 0) + { + session->attributes.checkReqKey = SET; + } + if(in->tpmKeyName.t.size != 0) + { + session->attributes.checkTpmKey = SET; + } + + return TPM_RC_SUCCESS; +} + +#endif // CC_PolicyTransportSPDM diff --git a/src/tpm2/Policy_spt.c b/src/tpm2/TPMCmd/tpm/src/command/EA/Policy_spt.c similarity index 71% rename from src/tpm2/Policy_spt.c rename to src/tpm2/TPMCmd/tpm/src/command/EA/Policy_spt.c index 30e627245..8bee89d0c 100644 --- a/src/tpm2/Policy_spt.c +++ b/src/tpm2/TPMCmd/tpm/src/command/EA/Policy_spt.c @@ -1,63 +1,4 @@ -/********************************************************************************/ -/* */ -/* Policy Command Support */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: Policy_spt.c 1594 2020-03-26 22:15:48Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2016 - 2020 */ -/* */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause //** Includes #include "Tpm.h" @@ -121,7 +62,7 @@ PolicyParameterChecks(SESSION* session, // objectName to it. This will also update the cpHash if it is present. // // Return Type: void -void PolicyContextUpdate( +TPM_RC PolicyContextUpdate( TPM_CC commandCode, // IN: command code TPM2B_NAME* name, // IN: name of entity TPM2B_NONCE* ref, // IN: the reference data @@ -136,8 +77,8 @@ void PolicyContextUpdate( CryptHashStart(&hashState, session->authHashAlg); // policyDigest size should always be the digest size of session hash algorithm. - pAssert(session->u2.policyDigest.t.size - == CryptHashGetDigestSize(session->authHashAlg)); + pAssert_RC(session->u2.policyDigest.t.size + == CryptHashGetDigestSize(session->authHashAlg)); // add old digest CryptDigestUpdate2B(&hashState, &session->u2.policyDigest.b); @@ -186,7 +127,8 @@ void PolicyContextUpdate( if(session->timeout == 0 || session->timeout > policyTimeout) session->timeout = policyTimeout; } - return; + VERIFY_NOT_FAILED(); + return TPM_RC_SUCCESS; } //*** ComputeAuthTimeout() // This function is used to determine what the authorization timeout value for diff --git a/src/tpm2/TPMCmd/tpm/src/command/Hierarchy/CreatePrimary.c b/src/tpm2/TPMCmd/tpm/src/command/Hierarchy/CreatePrimary.c new file mode 100644 index 000000000..1e5fa2ce2 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/src/command/Hierarchy/CreatePrimary.c @@ -0,0 +1,137 @@ +// SPDX-License-Identifier: BSD-2-Clause + +#include "Tpm.h" +#include "CreatePrimary_fp.h" + +#if CC_CreatePrimary // Conditional expansion of this file + +/*(See part 3 specification) +// Creates a primary or temporary object from a primary seed. +*/ +// Return Type: TPM_RC +// TPM_RC_ATTRIBUTES sensitiveDataOrigin is CLEAR when sensitive.data is an +// Empty Buffer; 'fixedTPM', 'fixedParent', or +// 'encryptedDuplication' attributes are inconsistent +// between themselves or with those of the parent object; +// inconsistent 'restricted', 'decrypt', 'sign', +// 'firmwareLimited', or 'svnLimited' attributes; +// attempt to inject sensitive data for an asymmetric +// key; +// TPM_RC_FW_LIMITED The requested hierarchy is FW-limited, but the TPM +// does not support FW-limited objects or the TPM failed +// to derive the Firmware Secret. +// TPM_RC_SVN_LIMITED The requested hierarchy is SVN-limited, but the TPM +// does not support SVN-limited objects or the TPM failed +// to derive the Firmware SVN Secret for the requested +// SVN. +// TPM_RC_KDF incorrect KDF specified for decrypting keyed hash +// object +// TPM_RC_KEY a provided symmetric key value is not allowed +// TPM_RC_OBJECT_MEMORY there is no free slot for the object +// TPM_RC_SCHEME inconsistent attributes 'decrypt', 'sign', +// 'restricted' and key's scheme ID; or hash algorithm is +// inconsistent with the scheme ID for keyed hash object +// TPM_RC_SIZE size of public authorization policy or sensitive +// authorization value does not match digest size of the +// name algorithm; or sensitive data size for the keyed +// hash object is larger than is allowed for the scheme +// TPM_RC_SYMMETRIC a storage key with no symmetric algorithm specified; +// or non-storage key with symmetric algorithm different +// from TPM_ALG_NULL +// TPM_RC_TYPE unknown object type +TPM_RC +TPM2_CreatePrimary(CreatePrimary_In* in, // IN: input parameter list + CreatePrimary_Out* out // OUT: output parameter list +) +{ + TPM_RC result = TPM_RC_SUCCESS; + TPMT_PUBLIC* publicArea; + DRBG_STATE rand; + OBJECT* newObject; + TPM2B_NAME name; + TPM2B_SEED primary_seed; + + // Input Validation + // Will need a place to put the result + newObject = FindEmptyObjectSlot(&out->objectHandle); + if(newObject == NULL) + return TPM_RC_OBJECT_MEMORY; + // Get the address of the public area in the new object + // (this is just to save typing) + publicArea = &newObject->publicArea; + + *publicArea = in->inPublic.publicArea; + + // Check attributes in input public area. CreateChecks() checks the things that + // are unique to creation and then validates the attributes and values that are + // common to create and load. + result = CreateChecks( + NULL, in->primaryHandle, publicArea, in->inSensitive.sensitive.data.t.size); + if(result != TPM_RC_SUCCESS) + return RcSafeAddToResult(result, RC_CreatePrimary_inPublic); + // Validate the sensitive area values + if(!AdjustAuthSize(&in->inSensitive.sensitive.userAuth, publicArea->nameAlg)) + return TPM_RCS_SIZE + RC_CreatePrimary_inSensitive; + // Command output + // Compute the name using out->name as a scratch area (this is not the value + // that ultimately will be returned, then instantiate the state that will be + // used as a random number generator during the object creation. + // The caller does not know the seed values so the actual name does not have + // to be over the input, it can be over the unmarshaled structure. + + result = HierarchyGetPrimarySeed(in->primaryHandle, &primary_seed); + if(result != TPM_RC_SUCCESS) + return result; + + result = + DRBG_InstantiateSeeded(&rand, + &primary_seed.b, + PRIMARY_OBJECT_CREATION, + (TPM2B*)PublicMarshalAndComputeName(publicArea, &name), + &in->inSensitive.sensitive.data.b, + HierarchyGetPrimarySeedCompatLevel(in->primaryHandle)); // libtpms added + MemorySet(primary_seed.b.buffer, 0, primary_seed.b.size); + + if(result == TPM_RC_SUCCESS) + { + newObject->attributes.primary = SET; + if(HierarchyNormalizeHandle(in->primaryHandle) == TPM_RH_ENDORSEMENT) + newObject->attributes.epsHierarchy = SET; + + // Create the primary object. + result = CryptCreateObject( + newObject, &in->inSensitive.sensitive, (RAND_STATE*)&rand); + DRBG_Uninstantiate(&rand); + } + if(result != TPM_RC_SUCCESS) + return result; + + // Set the publicArea and name from the computed values + out->outPublic.publicArea = newObject->publicArea; + out->name = newObject->name; + + // Fill in creation data + result = FillInCreationData(in->primaryHandle, + publicArea->nameAlg, + &in->creationPCR, + &in->outsideInfo, + &out->creationData, + &out->creationHash); + if(result != TPM_RC_SUCCESS) + return result; + + // Compute creation ticket + result = TicketComputeCreation(EntityGetHierarchy(in->primaryHandle), + &out->name, + &out->creationHash, + &out->creationTicket); + if(result != TPM_RC_SUCCESS) + return result; + + // Set the remaining attributes for a loaded object + ObjectSetLoadedAttributes(newObject, in->primaryHandle, + HierarchyGetPrimarySeedCompatLevel(in->primaryHandle)); // libtpms added + return result; +} + +#endif // CC_CreatePrimary diff --git a/src/tpm2/TPMCmd/tpm/src/command/Hierarchy/ReadOnlyControl.c b/src/tpm2/TPMCmd/tpm/src/command/Hierarchy/ReadOnlyControl.c new file mode 100644 index 000000000..4fef83a8b --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/src/command/Hierarchy/ReadOnlyControl.c @@ -0,0 +1,31 @@ +// SPDX-License-Identifier: BSD-2-Clause + +#include "Tpm.h" +#include "ReadOnlyControl_fp.h" + +#if CC_ReadOnlyControl // Conditional expansion of this file + +/*(See part 3 specification) +// Enable or disable read-only mode of operation +*/ +TPM_RC +TPM2_ReadOnlyControl(ReadOnlyControl_In* in // IN: input parameter list +) +{ + if(in->state != gc.readOnly) + { + // Before changing the internal state, make sure that NV is available. + // Only need to update NV if changing the orderly state + RETURN_IF_ORDERLY; + + // 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; + } + return TPM_RC_SUCCESS; +} + +#endif // CC_ReadOnlyControl diff --git a/src/tpm2/TPMCmd/tpm/src/command/NVStorage/NV_Read.c b/src/tpm2/TPMCmd/tpm/src/command/NVStorage/NV_Read.c new file mode 100644 index 000000000..aad4bb9c3 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/src/command/NVStorage/NV_Read.c @@ -0,0 +1,71 @@ +// SPDX-License-Identifier: BSD-2-Clause + +#include "Tpm.h" +#include "NV_Read_fp.h" +#include + +#if CC_NV_Read // Conditional expansion of this file + +/*(See part 3 specification) +// Read of an NV index +*/ +// Return Type: TPM_RC +// TPM_RC_NV_AUTHORIZATION the authorization was valid but the +// authorizing entity ('authHandle') +// is not allowed to read from the Index +// referenced by 'nvIndex' +// TPM_RC_NV_LOCKED the Index referenced by 'nvIndex' is +// read locked +// TPM_RC_NV_RANGE read range defined by 'size' and 'offset' +// is outside the range of the Index referenced +// by 'nvIndex' +// TPM_RC_NV_UNINITIALIZED the Index referenced by 'nvIndex' has +// not been initialized (written) +// TPM_RC_VALUE the read size is larger than the +// MAX_NV_BUFFER_SIZE +TPM_RC +TPM2_NV_Read(NV_Read_In* in, // IN: input parameter list + NV_Read_Out* out // OUT: output parameter list +) +{ + // Handle special cases for EK cert and EKICA cert. + if(_plat__IsNvVirtualIndex(in->nvIndex)) + { + return _plat__NvVirtual_Read(in, out); + } + + NV_REF locator; + NV_INDEX* nvIndex = NvGetIndexInfo(in->nvIndex, &locator); + TPM_RC result; + + // Input Validation + // Common read access checks. NvReadAccessChecks() may return + // TPM_RC_NV_AUTHORIZATION, TPM_RC_NV_LOCKED, or TPM_RC_NV_UNINITIALIZED + result = NvReadAccessChecks( + in->authHandle, in->nvIndex, nvIndex->publicArea.attributes); + if(result != TPM_RC_SUCCESS) + return result; + + // Make sure the data will fit the return buffer + if(in->size > MAX_NV_BUFFER_SIZE) + return TPM_RCS_VALUE + RC_NV_Read_size; + + // Verify that the offset is not too large + if(in->offset > nvIndex->publicArea.dataSize) + return TPM_RCS_VALUE + RC_NV_Read_offset; + + // Make sure that the selection is within the range of the Index + if(in->size > (nvIndex->publicArea.dataSize - in->offset)) + return TPM_RC_NV_RANGE; + + // Command Output + // Set the return size + out->data.t.size = in->size; + + // Perform the read + NvGetIndexData(nvIndex, locator, in->offset, in->size, out->data.t.buffer); + + return TPM_RC_SUCCESS; +} + +#endif // CC_NV_Read diff --git a/src/tpm2/TPMCmd/tpm/src/command/NVStorage/NV_ReadPublic.c b/src/tpm2/TPMCmd/tpm/src/command/NVStorage/NV_ReadPublic.c new file mode 100644 index 000000000..27fc61e0d --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/src/command/NVStorage/NV_ReadPublic.c @@ -0,0 +1,42 @@ +// SPDX-License-Identifier: BSD-2-Clause + +#include "Tpm.h" +#include "NV_ReadPublic_fp.h" +#include + +#if CC_NV_ReadPublic // Conditional expansion of this file + +/*(See part 3 specification) +// Read the public information of a NV index +*/ +TPM_RC +TPM2_NV_ReadPublic(NV_ReadPublic_In* in, // IN: input parameter list + NV_ReadPublic_Out* out // OUT: output parameter list +) +{ + // This command only supports TPM_HT_NV_INDEX-typed NV indices. + if(HandleGetType(in->nvIndex) != TPM_HT_NV_INDEX) + { + return TPM_RCS_HANDLE + RC_NV_ReadPublic_nvIndex; + } + + // Handle special cases for EK cert and special indexes + if(_plat__IsNvVirtualIndex(in->nvIndex)) + { + return _plat__NvVirtual_ReadPublic(in, out); + } + + NV_INDEX* nvIndex = NvGetIndexInfo(in->nvIndex, NULL); + + // Command Output + + // Copy index public data to output + out->nvPublic.nvPublic = nvIndex->publicArea; + + // Compute NV name + NvGetIndexName(nvIndex, &out->nvName); + + return TPM_RC_SUCCESS; +} + +#endif // CC_NV_ReadPublic diff --git a/src/tpm2/TPMCmd/tpm/src/command/NVStorage/NV_ReadPublic2.c b/src/tpm2/TPMCmd/tpm/src/command/NVStorage/NV_ReadPublic2.c new file mode 100644 index 000000000..1e0560e56 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/src/command/NVStorage/NV_ReadPublic2.c @@ -0,0 +1,47 @@ +// SPDX-License-Identifier: BSD-2-Clause + +#include "Tpm.h" +#include "NV_ReadPublic2_fp.h" +#include "NV_DefineSpace_fp.h" // for the RC modifiers +#include + +#if CC_NV_ReadPublic2 // Conditional expansion of this file + +/*(See part 3 specification) +// Read the public information of a NV index +*/ +TPM_RC +TPM2_NV_ReadPublic2(NV_ReadPublic2_In* in, // IN: input parameter list + NV_ReadPublic2_Out* out // OUT: output parameter list +) +{ + TPM_RC result; + NV_INDEX* nvIndex; + + // Handle special cases for EK cert and special indexes + if(_plat__IsNvVirtualIndex(in->nvIndex)) + { + // currently NV_ReadPublic2 doesn't know how to handle virtual indexes. + return TPM_RCS_HANDLE + RC_NV_DefineSpace_publicInfo; + } + + nvIndex = NvGetIndexInfo(in->nvIndex, NULL); + + // Command Output + + // The reference code stores its NV indices in the legacy form, because + // it doesn't support any extended attributes. + // Translate the legacy form to the general form. + result = NvPublic2FromNvPublic(&nvIndex->publicArea, &out->nvPublic.nvPublic2); + if(result != TPM_RC_SUCCESS) + { + return RcSafeAddToResult(result, RC_NV_ReadPublic2_nvIndex); + } + + // Compute NV name + NvGetIndexName(nvIndex, &out->nvName); + + return TPM_RC_SUCCESS; +} + +#endif // CC_NV_ReadPublic2 diff --git a/src/tpm2/NV_spt.c b/src/tpm2/TPMCmd/tpm/src/command/NVStorage/NV_spt.c similarity index 83% rename from src/tpm2/NV_spt.c rename to src/tpm2/TPMCmd/tpm/src/command/NVStorage/NV_spt.c index ab217a49c..636296016 100644 --- a/src/tpm2/NV_spt.c +++ b/src/tpm2/TPMCmd/tpm/src/command/NVStorage/NV_spt.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, 2016 -2023 */ -/* */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause //** Includes #include "Tpm.h" @@ -154,6 +96,33 @@ NvWriteAccessChecks( return TPM_RC_SUCCESS; } +//*** NvReadOnlyModeChecks() +// Common routine to verify whether an NV command is allowed on an index +// with the given 'attributes' while the TPM is in Read-Only mode +// Used by TPM2_NV_Write, TPM2_NV_Extend, TPM2_SetBits, TPM2_NV_WriteLock +// and TPM2_NV_ReadLock +// Return Type: TPM_RC +// TPM_RC_SUCCESS The command is allowed +// TPM_RC_READ_ONLY The TPM is in Read-Only mode and the command is +// not allowed +// +TPM_RC +NvReadOnlyModeChecks(TPMA_NV attributes // IN: the attributes of the index to check +) +{ + +#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))) + return TPM_RC_READ_ONLY; +#endif // CC_ReadOnlyControl + + return TPM_RC_SUCCESS; +} + //*** NvClearOrderly() // This function is used to cause gp.orderlyState to be cleared to the // non-orderly state. @@ -166,6 +135,28 @@ NvClearOrderly(void) return TPM_RC_SUCCESS; } +//*** GetIndexAttributesByHandle() +// Function to return the TPMA_NV attributes of an index given a handle +// On success 'attributes' is set to receive the result +// 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 +) +{ + if(HandleGetType(index) == TPM_HT_NV_INDEX) + { + NV_INDEX* nvIndex = NvGetIndexInfo(index, NULL); + if(nvIndex != NULL) + { + *attributes = nvIndex->publicArea.attributes; + return TRUE; + } + } + return FALSE; +} + //*** NvIsPinPassIndex() // Function to check to see if an NV index is a PIN Pass Index // Return Type: BOOL @@ -174,13 +165,23 @@ NvClearOrderly(void) BOOL NvIsPinPassIndex(TPM_HANDLE index // IN: Handle to check ) { - if(HandleGetType(index) == TPM_HT_NV_INDEX) - { - NV_INDEX* nvIndex = NvGetIndexInfo(index, NULL); + TPMA_NV attributes; + return GetIndexAttributesByHandle(index, &attributes) + && IsNvPinPassIndex(attributes); +} - return IsNvPinPassIndex(nvIndex->publicArea.attributes); - } - return FALSE; +//*** NvIsPinCountedIndex() +// Function to check to see if an NV index is either a PIN Pass +// or a PIN FAIL Index +// Return Type: BOOL +// TRUE(1) is pin pass or pin fail +// FALSE(0) is neither pin pass nor pin fail +BOOL NvIsPinCountedIndex(TPM_HANDLE index // IN: Handle to check +) +{ + TPMA_NV attributes; + return GetIndexAttributesByHandle(index, &attributes) + && (IsNvPinPassIndex(attributes) || IsNvPinFailIndex(attributes)); } //*** NvGetIndexName() diff --git a/src/tpm2/TPMCmd/tpm/src/command/Object/Create.c b/src/tpm2/TPMCmd/tpm/src/command/Object/Create.c new file mode 100644 index 000000000..ef31cfff1 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/src/command/Object/Create.c @@ -0,0 +1,137 @@ +// SPDX-License-Identifier: BSD-2-Clause + +#include "Tpm.h" +#include "Object_spt_fp.h" +#include "Create_fp.h" + +#if CC_Create // Conditional expansion of this file + +/*(See part 3 specification) +// Create a regular object +*/ +// Return Type: TPM_RC +// TPM_RC_ATTRIBUTES 'sensitiveDataOrigin' is CLEAR when 'sensitive.data' +// is an Empty Buffer, or is SET when 'sensitive.data' is +// not empty; +// 'fixedTPM', 'fixedParent', or 'encryptedDuplication' +// attributes are inconsistent between themselves or with +// those of the parent object; +// inconsistent 'restricted', 'decrypt' and 'sign' +// attributes; +// attempt to inject sensitive data for an asymmetric +// key; +// TPM_RC_HASH non-duplicable storage key and its parent have +// different name algorithm +// TPM_RC_KDF incorrect KDF specified for decrypting keyed hash +// object +// TPM_RC_KEY invalid key size values in an asymmetric key public +// area or a provided symmetric key has a value that is +// not allowed +// TPM_RC_KEY_SIZE key size in public area for symmetric key differs from +// the size in the sensitive creation area; may also be +// returned if the TPM does not allow the key size to be +// used for a Storage Key +// TPM_RC_OBJECT_MEMORY a free slot is not available as scratch memory for +// object creation +// TPM_RC_RANGE the exponent value of an RSA key is not supported. +// TPM_RC_SCHEME inconsistent attributes 'decrypt', 'sign', or +// 'restricted' and key's scheme ID; or hash algorithm is +// inconsistent with the scheme ID for keyed hash object +// TPM_RC_SIZE size of public authPolicy or sensitive authValue does +// not match digest size of the name algorithm +// sensitive data size for the keyed hash object is +// larger than is allowed for the scheme +// TPM_RC_SYMMETRIC a storage key with no symmetric algorithm specified; +// or non-storage key with symmetric algorithm different +// from TPM_ALG_NULL +// TPM_RC_TYPE unknown object type; +// 'parentHandle' does not reference a restricted +// decryption key in the storage hierarchy with both +// public and sensitive portion loaded +// TPM_RC_VALUE exponent is not prime or could not find a prime using +// the provided parameters for an RSA key; +// unsupported name algorithm for an ECC key +// TPM_RC_OBJECT_MEMORY there is no free slot for the object +TPM_RC +TPM2_Create(Create_In* in, // IN: input parameter list + Create_Out* out // OUT: output parameter list +) +{ + TPM_RC result = TPM_RC_SUCCESS; + OBJECT* parentObject; + OBJECT* newObject; + TPMT_PUBLIC* publicArea; + + // Input Validation + parentObject = HandleToObject(in->parentHandle); + pAssert_RC(parentObject != NULL); + + // Does parent have the proper attributes? + if(!ObjectIsParent(parentObject)) + return TPM_RCS_TYPE + RC_Create_parentHandle; + + // Get a slot for the creation + newObject = FindEmptyObjectSlot(NULL); + if(newObject == NULL) + return TPM_RC_OBJECT_MEMORY; + // If the TPM2B_PUBLIC was passed as a structure, marshal it into is canonical + // form for processing + + // to save typing. + publicArea = &newObject->publicArea; + + // Copy the input structure to the allocated structure + *publicArea = in->inPublic.publicArea; + + // Check attributes in input public area. CreateChecks() checks the things that + // are unique to creation and then validates the attributes and values that are + // common to create and load. + result = CreateChecks(parentObject, + /* primaryHierarchy = */ 0, + publicArea, + in->inSensitive.sensitive.data.t.size); + if(result != TPM_RC_SUCCESS) + return RcSafeAddToResult(result, RC_Create_inPublic); + // Clean up the authValue if necessary + if(!AdjustAuthSize(&in->inSensitive.sensitive.userAuth, publicArea->nameAlg)) + return TPM_RCS_SIZE + RC_Create_inSensitive; + + // Command Output + // Create the object using the default TPM random-number generator + result = CryptCreateObject(newObject, &in->inSensitive.sensitive, NULL); + if(result != TPM_RC_SUCCESS) + return result; + // Fill in creation data + result = FillInCreationData(in->parentHandle, + publicArea->nameAlg, + &in->creationPCR, + &in->outsideInfo, + &out->creationData, + &out->creationHash); + if(result != TPM_RC_SUCCESS) + return result; + + // Compute creation ticket + result = TicketComputeCreation(EntityGetHierarchy(in->parentHandle), + &newObject->name, + &out->creationHash, + &out->creationTicket); + if(result != TPM_RC_SUCCESS) + return result; + + // Prepare output private data from sensitive + result = SensitiveToPrivate(&newObject->sensitive, + &newObject->name, + parentObject, + publicArea->nameAlg, + &out->outPrivate); + + newObject->hierarchy = parentObject->hierarchy; + + // Finish by copying the remaining return values + out->outPublic.publicArea = newObject->publicArea; + + return result; +} + +#endif // CC_Create diff --git a/src/tpm2/TPMCmd/tpm/src/command/Object/CreateLoaded.c b/src/tpm2/TPMCmd/tpm/src/command/Object/CreateLoaded.c new file mode 100644 index 000000000..c2ab154df --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/src/command/Object/CreateLoaded.c @@ -0,0 +1,223 @@ +// SPDX-License-Identifier: BSD-2-Clause + +#include "Tpm.h" +#include "CreateLoaded_fp.h" + +#if CC_CreateLoaded // Conditional expansion of this file + +/*(See part 3 of specification) + * Create and load any type of key, including a temporary key. + * The input template is a marshaled public area rather than an unmarshaled one as + * used in Create and CreatePrimary. This is so that the label and context that + * could be in the template can be processed without changing the formats for the + * calls to Create and CreatePrimary. +*/ +// Return Type: TPM_RC +// TPM_RC_ATTRIBUTES 'sensitiveDataOrigin' is CLEAR when 'sensitive.data' +// is an Empty Buffer; +// 'fixedTPM', 'fixedParent', or 'encryptedDuplication' +// attributes are inconsistent between themselves or with +// those of the parent object; +// inconsistent 'restricted', 'decrypt' and 'sign' +// attributes; +// attempt to inject sensitive data for an asymmetric +// key; +// attempt to create a symmetric cipher key that is not +// a decryption key +// TPM_RC_FW_LIMITED The requested hierarchy is FW-limited, but the TPM +// does not support FW-limited objects or the TPM failed +// to derive the Firmware Secret. +// TPM_RC_SVN_LIMITED The requested hierarchy is SVN-limited, but the TPM +// does not support SVN-limited objects or the TPM failed +// to derive the Firmware SVN Secret for the requested +// SVN. +// TPM_RC_KDF incorrect KDF specified for decrypting keyed hash +// object +// TPM_RC_KEY the value of a provided symmetric key is not allowed +// TPM_RC_OBJECT_MEMORY there is no free slot for the object +// TPM_RC_SCHEME inconsistent attributes 'decrypt', 'sign', +// 'restricted' and key's scheme ID; or hash algorithm is +// inconsistent with the scheme ID for keyed hash object +// TPM_RC_SIZE size of public authorization policy or sensitive +// authorization value does not match digest size of the +// name algorithm sensitive data size for the keyed hash +// object is larger than is allowed for the scheme +// TPM_RC_SYMMETRIC a storage key with no symmetric algorithm specified; +// or non-storage key with symmetric algorithm different +// from TPM_ALG_NULL +// TPM_RC_TYPE cannot create the object of the indicated type +// (usually only occurs if trying to derive an RSA key). +TPM_RC +TPM2_CreateLoaded(CreateLoaded_In* in, // IN: input parameter list + CreateLoaded_Out* out // OUT: output parameter list +) +{ + TPM_RC result = TPM_RC_SUCCESS; + OBJECT* parent = HandleToObject(in->parentHandle); + OBJECT* newObject; + BOOL derivation; + TPMT_PUBLIC* publicArea; + RAND_STATE randState; + RAND_STATE* rand = &randState; + TPMS_DERIVE labelContext; + SEED_COMPAT_LEVEL seedCompatLevel = RuntimeProfileGetSeedCompatLevel(); // libtpms added + + // Input Validation + + // How the public area is unmarshaled is determined by the parent, so + // see if parent is a derivation parent + derivation = (parent != NULL && parent->attributes.derivation); + + // If the parent is an object, then make sure that it is either a parent or + // derivation parent + if(parent != NULL && !parent->attributes.isParent && !derivation) + return TPM_RCS_TYPE + RC_CreateLoaded_parentHandle; + + // Get a spot in which to create the newObject + newObject = FindEmptyObjectSlot(&out->objectHandle); + if(newObject == NULL) + return TPM_RC_OBJECT_MEMORY; + + // Do this to save typing + publicArea = &newObject->publicArea; + + // Unmarshal the template into the object space. TPM2_Create() and + // TPM2_CreatePrimary() have the publicArea unmarshaled by CommandDispatcher. + // This command is different because of an unfortunate property of the + // unique field of an ECC key. It is a structure rather than a single TPM2B. If + // if had been a TPM2B, then the label and context could be within a TPM2B and + // unmarshaled like other public areas. Since it is not, this command needs its + // on template that is a TPM2B that is unmarshaled as a BYTE array with a + // its own unmarshal function. + result = UnmarshalToPublic(publicArea, &in->inPublic, derivation, &labelContext); + if(result != TPM_RC_SUCCESS) + return result + RC_CreateLoaded_inPublic; + + // Validate that the authorization size is appropriate + if(!AdjustAuthSize(&in->inSensitive.sensitive.userAuth, publicArea->nameAlg)) + return TPM_RCS_SIZE + RC_CreateLoaded_inSensitive; + + // Command output + if(derivation) + { + TPMT_KEYEDHASH_SCHEME* scheme; + scheme = &parent->publicArea.parameters.keyedHashDetail.scheme; + + // SP800-108 is the only KDF supported by this implementation and there is + // no default hash algorithm. + pAssert_RC(scheme->details.xor.hashAlg != TPM_ALG_NULL + && scheme->details.xor.kdf == TPM_ALG_KDF1_SP800_108); + // Don't derive RSA keys + if(publicArea->type == TPM_ALG_RSA) + return TPM_RCS_TYPE + RC_CreateLoaded_inPublic; + if(publicArea->type == TPM_ALG_ECC && // libtpms added begin + RuntimeProfileRequiresAttributeFlags(&g_RuntimeProfile, + RUNTIME_ATTRIBUTE_NO_ECC_KEY_DERIVATION)) + return TPM_RCS_TYPE + RC_CreateLoaded_inPublic; // libtpms added end + // sensitiveDataOrigin has to be CLEAR in a derived object. Since this + // is specific to a derived object, it is checked here. + if(IS_ATTRIBUTE( + publicArea->objectAttributes, TPMA_OBJECT, sensitiveDataOrigin)) + return TPM_RCS_ATTRIBUTES; + // Check the rest of the attributes + result = PublicAttributesValidation(parent, 0, publicArea); + if(result != TPM_RC_SUCCESS) + return RcSafeAddToResult(result, RC_CreateLoaded_inPublic); + // Process the template and sensitive areas to get the actual 'label' and + // 'context' values to be used for this derivation. + result = SetLabelAndContext(&labelContext, &in->inSensitive.sensitive.data); + if(result != TPM_RC_SUCCESS) + return result; + // Set up the KDF for object generation + DRBG_InstantiateSeededKdf((KDF_STATE*)rand, + scheme->details.xor.hashAlg, + scheme->details.xor.kdf, + &parent->sensitive.sensitive.bits.b, + &labelContext.label.b, + &labelContext.context.b, + TPM_MAX_DERIVATION_BITS); + // Clear the sensitive size so that the creation functions will not try + // to use this value. + in->inSensitive.sensitive.data.t.size = 0; + seedCompatLevel = parent->seedCompatLevel; // libtpms added + } + else + { + // Check attributes in input public area. CreateChecks() checks the things + // that are unique to creation and then validates the attributes and values + // that are common to create and load. + result = CreateChecks(parent, + (parent == NULL) ? in->parentHandle : 0, + publicArea, + in->inSensitive.sensitive.data.t.size); + + if(result != TPM_RC_SUCCESS) + return RcSafeAddToResult(result, RC_CreateLoaded_inPublic); + // Creating a primary object + if(parent == NULL) + { + TPM2B_NAME name; + TPM2B_SEED primary_seed; + + newObject->attributes.primary = SET; + if(HierarchyNormalizeHandle(in->parentHandle) == TPM_RH_ENDORSEMENT) + newObject->attributes.epsHierarchy = SET; + seedCompatLevel = HierarchyGetPrimarySeedCompatLevel(in->parentHandle); // libtpms added + // If so, use the primary seed and the digest of the template + // to seed the DRBG + + result = HierarchyGetPrimarySeed(in->parentHandle, &primary_seed); + if(result != TPM_RC_SUCCESS) + return result; + + // If so, use the primary seed and the digest of the template + // to seed the DRBG + result = DRBG_InstantiateSeeded( + (DRBG_STATE*)rand, + &primary_seed.b, + PRIMARY_OBJECT_CREATION, + (TPM2B*)PublicMarshalAndComputeName(publicArea, &name), + &in->inSensitive.sensitive.data.b, + seedCompatLevel); // libtpms added + MemorySet(primary_seed.b.buffer, 0, primary_seed.b.size); + + if(result != TPM_RC_SUCCESS) + return result; + } + else + { + // This is an ordinary object so use the normal random number generator + rand = NULL; + } + } + // Internal data update + // Create the object + result = CryptCreateObject(newObject, &in->inSensitive.sensitive, rand); + DRBG_Uninstantiate((DRBG_STATE*)rand); + if(result != TPM_RC_SUCCESS) + return result; + // if this is not a Primary key and not a derived key, then return the sensitive + // area + if(parent != NULL && !derivation) + { + // Prepare output private data from sensitive + result = SensitiveToPrivate(&newObject->sensitive, + &newObject->name, + parent, + newObject->publicArea.nameAlg, + &out->outPrivate); + } + else + { + out->outPrivate.t.size = 0; + } + // Set the remaining return values + out->outPublic.publicArea = newObject->publicArea; + out->name = newObject->name; + // Set the remaining attributes for a loaded object + ObjectSetLoadedAttributes(newObject, in->parentHandle, + seedCompatLevel); // libtpms added + return result; +} + +#endif // CC_CreateLoaded diff --git a/src/tpm2/TPMCmd/tpm/src/command/Object/MakeCredential.c b/src/tpm2/TPMCmd/tpm/src/command/Object/MakeCredential.c new file mode 100644 index 000000000..f858d5b1d --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/src/command/Object/MakeCredential.c @@ -0,0 +1,61 @@ +// SPDX-License-Identifier: BSD-2-Clause + +#include "Tpm.h" +#include "MakeCredential_fp.h" + +#if CC_MakeCredential // Conditional expansion of this file + +# include "Object_spt_fp.h" + +/*(See part 3 specification) +// Make Credential with an object +*/ +// Return Type: TPM_RC +// TPM_RC_KEY 'handle' referenced an ECC key that has a unique +// field that is not a point on the curve of the key +// TPM_RC_SIZE 'credential' is larger than the digest size of +// Name algorithm of 'handle' +// TPM_RC_TYPE 'handle' does not reference an asymmetric +// decryption key +TPM_RC +TPM2_MakeCredential(MakeCredential_In* in, // IN: input parameter list + MakeCredential_Out* out // OUT: output parameter list +) +{ + TPM_RC result = TPM_RC_SUCCESS; + + OBJECT* object; + TPM2B_DATA data; + + // Input Validation + + // Get object pointer + object = HandleToObject(in->handle); + pAssert_RC(object != NULL); + + // input key must be an asymmetric, restricted decryption key + // NOTE: Needs to be restricted to have a symmetric value. + if(!CryptIsAsymAlgorithm(object->publicArea.type) + || !IS_ATTRIBUTE(object->publicArea.objectAttributes, TPMA_OBJECT, decrypt) + || !IS_ATTRIBUTE(object->publicArea.objectAttributes, TPMA_OBJECT, restricted)) + return TPM_RCS_TYPE + RC_MakeCredential_handle; + + // The credential information may not be larger than the digest size used for + // the Name of the key associated with handle. + if(in->credential.t.size > CryptHashGetDigestSize(object->publicArea.nameAlg)) + return TPM_RCS_SIZE + RC_MakeCredential_credential; + + // Command Output + + // Make encrypt key and its associated secret structure. + out->secret.t.size = sizeof(out->secret.t.secret); + result = CryptSecretEncrypt(object, IDENTITY_STRING, &data, &out->secret); + if(result != TPM_RC_SUCCESS) + return result; + + // Prepare output credential data from secret + return SecretToCredential( + &in->credential, &in->objectName.b, &data.b, object, &out->credentialBlob); +} + +#endif // CC_MakeCredential diff --git a/src/tpm2/TPMCmd/tpm/src/command/Object/ObjectChangeAuth.c b/src/tpm2/TPMCmd/tpm/src/command/Object/ObjectChangeAuth.c new file mode 100644 index 000000000..55c07c3f0 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/src/command/Object/ObjectChangeAuth.c @@ -0,0 +1,64 @@ +// SPDX-License-Identifier: BSD-2-Clause + +#include "Tpm.h" +#include "ObjectChangeAuth_fp.h" + +#if CC_ObjectChangeAuth // Conditional expansion of this file + +# include "Object_spt_fp.h" + +/*(See part 3 specification) +// Create an object +*/ +// Return Type: TPM_RC +// TPM_RC_SIZE 'newAuth' is larger than the size of the digest +// of the Name algorithm of 'objectHandle' +// TPM_RC_TYPE the key referenced by 'parentHandle' is not the +// parent of the object referenced by 'objectHandle'; +// or 'objectHandle' is a sequence object. +TPM_RC +TPM2_ObjectChangeAuth(ObjectChangeAuth_In* in, // IN: input parameter list + ObjectChangeAuth_Out* out // OUT: output parameter list +) +{ + TPMT_SENSITIVE sensitive; + + OBJECT* object = HandleToObject(in->objectHandle); + TPM2B_NAME QNCompare; + + // Input Validation + + // Can not change authorization on sequence object + if(ObjectIsSequence(object)) + return TPM_RCS_TYPE + RC_ObjectChangeAuth_objectHandle; + + // deliberately after ObjectIsSequence in case ObjectInSequence decides a + // null object is a non-fatal error + pAssert_RC(object != NULL); + + // Make sure that the authorization value is consistent with the nameAlg + if(!AdjustAuthSize(&in->newAuth, object->publicArea.nameAlg)) + return TPM_RCS_SIZE + RC_ObjectChangeAuth_newAuth; + + // Parent handle should be the parent of object handle. In this + // implementation we verify this by checking the QN of object. Other + // implementation may choose different method to verify this attribute. + ComputeQualifiedName( + in->parentHandle, object->publicArea.nameAlg, &object->name, &QNCompare); + if(!MemoryEqual2B(&object->qualifiedName.b, &QNCompare.b)) + return TPM_RCS_TYPE + RC_ObjectChangeAuth_parentHandle; + + // Command Output + // Prepare the sensitive area with the new authorization value + sensitive = object->sensitive; + sensitive.authValue = in->newAuth; + + // Protect the sensitive area + return SensitiveToPrivate(&sensitive, + &object->name, + HandleToObject(in->parentHandle), + object->publicArea.nameAlg, + &out->outPrivate); +} + +#endif // CC_ObjectChangeAuth diff --git a/src/tpm2/Object_spt.c b/src/tpm2/TPMCmd/tpm/src/command/Object/Object_spt.c similarity index 93% rename from src/tpm2/Object_spt.c rename to src/tpm2/TPMCmd/tpm/src/command/Object/Object_spt.c index a758c051c..9dc6915b4 100644 --- a/src/tpm2/Object_spt.c +++ b/src/tpm2/TPMCmd/tpm/src/command/Object/Object_spt.c @@ -1,62 +1,4 @@ -/********************************************************************************/ -/* */ -/* Object Command Support */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2016 - 2023 */ -/* */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause //** Includes #include "Tpm.h" @@ -423,9 +365,8 @@ CreateChecks(OBJECT* parentObject, && !IS_ATTRIBUTE(attributes, TPMA_OBJECT, decrypt) && IS_ATTRIBUTE(attributes, TPMA_OBJECT, sensitiveDataOrigin)) result = TPM_RC_ATTRIBUTES; - // comment out the next line in order to prevent a fixedTPM derivation - // parent - // break; + // fall through to prevent a fixedTPM derivation parent + // [[fallthrough]]; /* fallthrough */ // libtpms added case TPM_ALG_SYMCIPHER: // A restricted key symmetric key (SYMCIPHER and KEYEDHASH) @@ -589,7 +530,7 @@ SchemeChecks(OBJECT* parentObject, // IN: parent (null if primary seed) curveID = publicArea->parameters.eccDetail.curveID; curveScheme = CryptGetCurveSignScheme(curveID); // The curveId must be valid or the unmarshaling is busted. - pAssert(curveScheme != NULL); + pAssert_RC(curveScheme != NULL); // If the curveID requires a specific scheme, then the key must // select the same scheme @@ -804,7 +745,7 @@ PublicAttributesValidation( //*** FillInCreationData() // Fill in creation data for an object. // Return Type: void -void FillInCreationData( +TPM_RC FillInCreationData( TPMI_DH_OBJECT parentHandle, // IN: handle of parent TPMI_ALG_HASH nameHashAlg, // IN: name hash algorithm TPML_PCR_SELECTION* creationPCR, // IN: PCR selection @@ -820,8 +761,10 @@ void FillInCreationData( // Fill in TPMS_CREATION_DATA in outCreation // Compute PCR digest - PCRComputeCurrentDigest( + TPM_RC result = PCRComputeCurrentDigest( nameHashAlg, creationPCR, &outCreation->creationData.pcrDigest); + if(result != TPM_RC_SUCCESS) + return result; // Put back PCR selection list outCreation->creationData.pcrSelect = *creationPCR; @@ -867,7 +810,7 @@ void FillInCreationData( CryptDigestUpdate(&hashState, outCreation->size, creationBuffer); CryptHashEnd2B(&hashState, &creationDigest->b); - return; + return TPM_RC_SUCCESS; } //*** GetSeedForKDF() @@ -1074,7 +1017,7 @@ UnwrapOuter(OBJECT* protector, // IN: The object that provides // This function is used to marshal a sensitive area. Among other things, it // adjusts the size of the authValue to be no smaller than the digest of // 'nameAlg' -// Returns the size of the marshaled area. +// Returns the size of the marshaled area. 0 indicates an error static UINT16 MarshalSensitive( OBJECT* parent LIBTPMS_ATTR_UNUSED, // IN: the object parent (optional) BYTE* buffer, // OUT: receiving buffer @@ -1090,11 +1033,16 @@ static UINT16 MarshalSensitive( MemoryPad2B(&sensitive->authValue.b, CryptHashGetDigestSize(nameAlg)); buffer += 2; +#if !ALG_RSA + NOT_REFERENCED(parent); +#endif + // Marshal the structure #if 0 /* ALG_RSA */ // libtpms changed: We never set the RSA_prime_flag! // If the sensitive size is the special case for a prime in the type if((sensitive->sensitive.rsa.t.size & RSA_prime_flag) > 0) { + pAssert_ZERO(sensitive->sensitiveType == ALG_RSA_VALUE); UINT16 sizeSave = sensitive->sensitive.rsa.t.size; // // Turn off the flag that indicates that the sensitive->sensitive contains @@ -1113,7 +1061,9 @@ static UINT16 MarshalSensitive( } else #endif + { retVal = TPMT_SENSITIVE_Marshal(sensitive, &buffer, NULL); + } // Marshal the size retVal = (UINT16)(retVal + UINT16_Marshal(&retVal, &sizeField, NULL)); @@ -1127,7 +1077,7 @@ static UINT16 MarshalSensitive( // 1. marshal TPM2B_SENSITIVE structure into the buffer of TPM2B_PRIVATE // 2. apply encryption to the sensitive area. // 3. apply outer integrity computation. -void SensitiveToPrivate( +TPM_RC SensitiveToPrivate( TPMT_SENSITIVE* sensitive, // IN: sensitive structure TPM2B_NAME* name, // IN: the name of the object OBJECT* parent, // IN: The parent object @@ -1144,7 +1094,7 @@ void SensitiveToPrivate( UINT16 integritySize; UINT16 ivSize; // - pAssert(name != NULL && name->t.size != 0); + pAssert_RC(name != NULL && name->t.size != 0); // Find the hash algorithm for integrity computation if(parent == NULL) @@ -1174,11 +1124,13 @@ void SensitiveToPrivate( // Marshal the sensitive area including authValue size adjustments. dataSize = MarshalSensitive(parent, sensitiveData, sensitive, nameAlg); + pAssert_RC(dataSize != 0); // 0 indicates a failure mode assertion //Produce outer wrap, including encryption and HMAC outPrivate->t.size = ProduceOuterWrap( parent, &name->b, hashAlg, NULL, TRUE, dataSize, outPrivate->t.buffer); - return; + + return TPM_RC_SUCCESS; } //*** PrivateToSensitive() @@ -1222,7 +1174,7 @@ PrivateToSensitive(TPM2B* inPrivate, // IN: input private structure UINT16 ivSize; // // Make sure that name is provided - pAssert(name != NULL && name->size != 0); + pAssert_RC(name != NULL && name->size != 0); // Find the hash algorithm for integrity computation // For Temporary Object (parent == NULL) use self name algorithm; @@ -1271,7 +1223,7 @@ PrivateToSensitive(TPM2B* inPrivate, // IN: input private structure // 1. marshal TPMT_SENSITIVE structure into the buffer of TPM2B_PRIVATE // 2. apply inner wrap to the sensitive area if required // 3. apply outer wrap if required -void SensitiveToDuplicate( +TPM_RC SensitiveToDuplicate( TPMT_SENSITIVE* sensitive, // IN: sensitive structure TPM2B* name, // IN: the name of the object OBJECT* parent, // IN: The new parent object @@ -1301,10 +1253,10 @@ void SensitiveToDuplicate( BOOL doOuterWrap = FALSE; // // Make sure that name is provided - pAssert(name != NULL && name->size != 0); + pAssert_RC(name != NULL && name->size != 0); // Make sure symDef and innerSymKey are not NULL - pAssert(symDef != NULL && innerSymKey != NULL); + pAssert_RC(symDef != NULL && innerSymKey != NULL); // Starting of sensitive data without wrappers sensitiveData = outPrivate->t.buffer; @@ -1333,6 +1285,7 @@ void SensitiveToDuplicate( } // Marshal sensitive area dataSize = MarshalSensitive(NULL, sensitiveData, sensitive, nameAlg); + pAssert_RC(dataSize != 0); // 0 indicates a failure mode assertion // Apply inner wrap for duplication blob. It includes both integrity and // encryption @@ -1357,18 +1310,18 @@ void SensitiveToDuplicate( else { // assume the input key size should matches the symmetric definition - pAssert(innerSymKey->t.size == (symDef->keyBits.sym + 7) / 8); + pAssert_RC(innerSymKey->t.size == (symDef->keyBits.sym + 7) / 8); } // Encrypt inner buffer in place - CryptSymmetricEncrypt(innerBuffer, - symDef->algorithm, - symDef->keyBits.sym, - innerSymKey->t.buffer, - NULL, - TPM_ALG_CFB, - dataSize, - innerBuffer); + VERIFY_RC(CryptSymmetricEncrypt(innerBuffer, + symDef->algorithm, + symDef->keyBits.sym, + innerSymKey->t.buffer, + NULL, + TPM_ALG_CFB, + dataSize, + innerBuffer)); // If the symmetric encryption key is imported, clear the buffer for // output @@ -1385,7 +1338,7 @@ void SensitiveToDuplicate( // Data size for output outPrivate->t.size = dataSize; - return; + return TPM_RC_SUCCESS; } //*** DuplicateToSensitive() @@ -1427,10 +1380,10 @@ DuplicateToSensitive( UINT16 dataSizeInput; // // Make sure that name is provided - pAssert(name != NULL && name->size != 0); + pAssert_RC(name != NULL && name->size != 0); // Make sure symDef and innerSymKey are not NULL - pAssert(symDef != NULL && innerSymKey != NULL); + pAssert_RC(symDef != NULL && innerSymKey != NULL); // Starting of sensitive data sensitiveData = inPrivate->buffer; @@ -1454,7 +1407,7 @@ DuplicateToSensitive( if(symDef->algorithm != TPM_ALG_NULL) { // assume the input key size matches the symmetric definition - pAssert(innerSymKey->size == (symDef->keyBits.sym + 7) / 8); + pAssert_RC(innerSymKey->size == (symDef->keyBits.sym + 7) / 8); // Decrypt inner buffer in place CryptSymmetricDecrypt(sensitiveData, @@ -1501,11 +1454,11 @@ DuplicateToSensitive( // 2. encrypt the private buffer, excluding the leading integrity HMAC area // 3. compute integrity HMAC and append to the beginning of the buffer. // 4. Set the total size of TPM2B_ID_OBJECT buffer -void SecretToCredential(TPM2B_DIGEST* secret, // IN: secret information - TPM2B* name, // IN: the name of the object - TPM2B* seed, // IN: an external seed. - OBJECT* protector, // IN: the protector - TPM2B_ID_OBJECT* outIDObject // OUT: output credential +TPM_RC SecretToCredential(TPM2B_DIGEST* secret, // IN: secret information + TPM2B* name, // IN: the name of the object + TPM2B* seed, // IN: an external seed. + OBJECT* protector, // IN: the protector + TPM2B_ID_OBJECT* outIDObject // OUT: output credential ) { BYTE* buffer; // Auxiliary buffer pointer @@ -1513,7 +1466,7 @@ void SecretToCredential(TPM2B_DIGEST* secret, // IN: secret information TPMI_ALG_HASH outerHash; // The hash algorithm for outer wrap UINT16 dataSize; // data blob size // - pAssert(secret != NULL && outIDObject != NULL); + pAssert_RC(secret != NULL && outIDObject != NULL); // use protector's name algorithm as outer hash ???? outerHash = protector->publicArea.nameAlg; @@ -1528,7 +1481,7 @@ void SecretToCredential(TPM2B_DIGEST* secret, // IN: secret information // Apply outer wrap outIDObject->t.size = ProduceOuterWrap( protector, name, outerHash, seed, FALSE, dataSize, outIDObject->t.credential); - return; + return TPM_RC_SUCCESS; } //*** CredentialToSecret() diff --git a/src/tpm2/TPMCmd/tpm/src/command/PCR/PCR_Read.c b/src/tpm2/TPMCmd/tpm/src/command/PCR/PCR_Read.c new file mode 100644 index 000000000..0cb1f552a --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/src/command/PCR/PCR_Read.c @@ -0,0 +1,30 @@ +// SPDX-License-Identifier: BSD-2-Clause + +#include "Tpm.h" +#include "PCR_Read_fp.h" + +#if CC_PCR_Read // Conditional expansion of this file + +/*(See part 3 specification) +// Read a set of PCR +*/ +TPM_RC +TPM2_PCR_Read(PCR_Read_In* in, // IN: input parameter list + PCR_Read_Out* out // OUT: output parameter list +) +{ + // Command Output + + // Call PCR read function. input pcrSelectionIn parameter could be changed + // to reflect the actual PCR being returned + TPM_RC result = + PCRRead(&in->pcrSelectionIn, &out->pcrValues, &out->pcrUpdateCounter); + if(result == TPM_RC_SUCCESS) + { + out->pcrSelectionOut = in->pcrSelectionIn; + } + + return result; +} + +#endif // CC_PCR_Read diff --git a/src/tpm2/EncryptDecrypt_spt.c b/src/tpm2/TPMCmd/tpm/src/command/Symmetric/EncryptDecrypt_spt.c similarity index 58% rename from src/tpm2/EncryptDecrypt_spt.c rename to src/tpm2/TPMCmd/tpm/src/command/Symmetric/EncryptDecrypt_spt.c index 95d70b672..151bcaecc 100644 --- a/src/tpm2/EncryptDecrypt_spt.c +++ b/src/tpm2/TPMCmd/tpm/src/command/Symmetric/EncryptDecrypt_spt.c @@ -1,63 +1,4 @@ -/********************************************************************************/ -/* */ -/* Encrypt Decrypt Support */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: EncryptDecrypt_spt.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, 2016 - 2021 */ -/* */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause #include "Tpm.h" #include "EncryptDecrypt_fp.h" @@ -94,7 +35,8 @@ EncryptDecryptShared(TPMI_DH_OBJECT keyHandleIn, BOOL OK; // Input Validation symKey = HandleToObject(keyHandleIn); - mode = symKey->publicArea.parameters.symDetail.sym.mode.sym; + pAssert_RC(symKey != NULL); + mode = symKey->publicArea.parameters.symDetail.sym.mode.sym; // The input key should be a symmetric key if(symKey->publicArea.type != TPM_ALG_SYMCIPHER) diff --git a/src/tpm2/AlgorithmTests.c b/src/tpm2/TPMCmd/tpm/src/crypt/AlgorithmTests.c similarity index 90% rename from src/tpm2/AlgorithmTests.c rename to src/tpm2/TPMCmd/tpm/src/crypt/AlgorithmTests.c index d97ffcfc0..33a74a1af 100644 --- a/src/tpm2/AlgorithmTests.c +++ b/src/tpm2/TPMCmd/tpm/src/crypt/AlgorithmTests.c @@ -1,62 +1,4 @@ -/********************************************************************************/ -/* */ -/* Code to perform the various self-test functions. */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2016 - 2024 */ -/* */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause //** Introduction // This file contains the code to perform the various self-test functions. @@ -123,7 +65,7 @@ static TPM_RC TestHash(TPM_ALG_ID hashAlg, ALGORITHM_VECTOR* toTest) const TPM2B* testDigest = NULL; // TPM2B_TYPE(HMAC_BLOCK, DEFAULT_TEST_HASH_BLOCK_SIZE); - pAssert(hashAlg != TPM_ALG_NULL); + pAssert_RC(hashAlg != TPM_ALG_NULL); # define HASH_CASE_FOR_TEST(HASH, hash) \ case ALG_##HASH##_VALUE: \ testDigest = &c_##HASH##_digest.b; \ @@ -366,7 +308,7 @@ static TPM_RC TestSymmetric(TPM_ALG_ID alg, ALGORITHM_VECTOR* toTest) } } else - pAssert(alg == 0 && alg != 0); + pAssert_RC(alg == 0 && alg != 0); return TPM_RC_SUCCESS; } @@ -858,7 +800,7 @@ TestAlgorithm(TPM_ALG_ID alg, ALGORITHM_VECTOR* toTest) // silently CLEAR it. Decided to just clear. if(!TEST_BIT(alg, g_implementedAlgorithms)) { - CLEAR_BIT(alg, *toTest); + CLEAR_BOTH(alg); continue; } // Process whatever is left. @@ -992,7 +934,7 @@ TestAlgorithm(TPM_ALG_ID alg, ALGORITHM_VECTOR* toTest) break; # endif // ALG_ECC default: - CLEAR_BIT(alg, *toTest); + CLEAR_BOTH(alg); break; } if(result != TPM_RC_SUCCESS) diff --git a/src/tpm2/crypto/openssl/CryptCmac.c b/src/tpm2/TPMCmd/tpm/src/crypt/CryptCmac.c similarity index 62% rename from src/tpm2/crypto/openssl/CryptCmac.c rename to src/tpm2/TPMCmd/tpm/src/crypt/CryptCmac.c index f60dbf151..ec87b5617 100644 --- a/src/tpm2/crypto/openssl/CryptCmac.c +++ b/src/tpm2/TPMCmd/tpm/src/crypt/CryptCmac.c @@ -1,62 +1,4 @@ -/********************************************************************************/ -/* */ -/* Message Authentication Codes Based on a Symmetric Block Cipher */ -/* 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, 2018 - 2023 */ -/* */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause //** Introduction // @@ -124,7 +66,7 @@ void CryptCmacData(SMAC_STATES* state, UINT32 size, const BYTE* buffer) { FOR_EACH_SYM(ENCRYPT_CASE) default: - FAIL(FATAL_ERROR_INTERNAL); + FAIL_VOID(FATAL_ERROR_INTERNAL); } while(size > 0) { @@ -175,9 +117,10 @@ CryptCmacEnd(SMAC_STATES* state, UINT32 outSize, BYTE* outBuffer) xorVal = ((subkey.t.buffer[0] & 0x80) == 0) ? 0 : 0x87; ShiftLeft(&subkey.b); subkey.t.buffer[subkey.t.size - 1] ^= xorVal; + // this is a sanity check to make sure that the algorithm is working properly. - // remove this check when debug is done - pAssert(cState->bcount <= cState->iv.t.size); + pAssert_ZERO(cState->bcount <= cState->iv.t.size); + // If the buffer is full then no need to compute subkey 2. if(cState->bcount < cState->iv.t.size) { diff --git a/src/tpm2/crypto/openssl/CryptDes.c b/src/tpm2/TPMCmd/tpm/src/crypt/CryptDes.c similarity index 100% rename from src/tpm2/crypto/openssl/CryptDes.c rename to src/tpm2/TPMCmd/tpm/src/crypt/CryptDes.c diff --git a/src/tpm2/crypto/openssl/CryptEccCrypt.c b/src/tpm2/TPMCmd/tpm/src/crypt/CryptEccCrypt.c similarity index 68% rename from src/tpm2/crypto/openssl/CryptEccCrypt.c rename to src/tpm2/TPMCmd/tpm/src/crypt/CryptEccCrypt.c index 6fa62aca1..10aef195b 100644 --- a/src/tpm2/crypto/openssl/CryptEccCrypt.c +++ b/src/tpm2/TPMCmd/tpm/src/crypt/CryptEccCrypt.c @@ -1,62 +1,4 @@ -/********************************************************************************/ -/* */ -/* Asymmetric ECC Commands */ -/* 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, 2022 - 2023 */ -/* */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause //** Includes and Defines #include "Tpm.h" diff --git a/src/tpm2/TPMCmd/tpm/src/crypt/CryptEccData.c b/src/tpm2/TPMCmd/tpm/src/crypt/CryptEccData.c new file mode 100644 index 000000000..c1b6afeed --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/src/crypt/CryptEccData.c @@ -0,0 +1,96 @@ +// SPDX-License-Identifier: BSD-2-Clause + +/*(Auto-generated) + * Created by TpmStructures; Version 4.4 Mar 26, 2019 + * Date: Aug 30, 2019 Time: 02:11:52PM + */ + +#include "Tpm.h" +#include "OIDs.h" + +#if ALG_ECC + +// This file contains the TPM Specific ECC curve metadata and pointers to the ecc-lib specific +// constant structure. +// The CURVE_NAME macro is used to remove the name string from normal builds, but leaves the +// string available in the initialization lists for potenial use during debugging by changing this +// macro (and the structure declaration) +# define CURVE_NAME(N) + +# define comma +const TPM_ECC_CURVE_METADATA eccCurves[] = { +# if ECC_NIST_P192 + comma{TPM_ECC_NIST_P192, + 192, + {TPM_ALG_KDF1_SP800_56A, {{TPM_ALG_SHA256}}}, + {TPM_ALG_NULL, {{TPM_ALG_NULL}}}, + OID_ECC_NIST_P192 CURVE_NAME("NIST_P192")} +# undef comma +# define comma , +# endif // ECC_NIST_P192 +# if ECC_NIST_P224 + comma{TPM_ECC_NIST_P224, + 224, + {TPM_ALG_KDF1_SP800_56A, {{TPM_ALG_SHA256}}}, + {TPM_ALG_NULL, {{TPM_ALG_NULL}}}, + OID_ECC_NIST_P224 CURVE_NAME("NIST_P224")} +# undef comma +# define comma , +# endif // ECC_NIST_P224 +# if ECC_NIST_P256 + comma{TPM_ECC_NIST_P256, + 256, + {TPM_ALG_KDF1_SP800_56A, {{TPM_ALG_SHA256}}}, + {TPM_ALG_NULL, {{TPM_ALG_NULL}}}, + OID_ECC_NIST_P256 CURVE_NAME("NIST_P256")} +# undef comma +# define comma , +# endif // ECC_NIST_P256 +# if ECC_NIST_P384 + comma{TPM_ECC_NIST_P384, + 384, + {TPM_ALG_KDF1_SP800_56A, {{TPM_ALG_SHA384}}}, + {TPM_ALG_NULL, {{TPM_ALG_NULL}}}, + OID_ECC_NIST_P384 CURVE_NAME("NIST_P384")} +# undef comma +# define comma , +# endif // ECC_NIST_P384 +# if ECC_NIST_P521 + comma{TPM_ECC_NIST_P521, + 521, + {TPM_ALG_KDF1_SP800_56A, {{TPM_ALG_SHA512}}}, + {TPM_ALG_NULL, {{TPM_ALG_NULL}}}, + OID_ECC_NIST_P521 CURVE_NAME("NIST_P521")} +# undef comma +# define comma , +# endif // ECC_NIST_P521 +# if ECC_BN_P256 + comma{TPM_ECC_BN_P256, + 256, + {TPM_ALG_NULL, {{TPM_ALG_NULL}}}, + {TPM_ALG_NULL, {{TPM_ALG_NULL}}}, + OID_ECC_BN_P256 CURVE_NAME("BN_P256")} +# undef comma +# define comma , +# endif // ECC_BN_P256 +# if ECC_BN_P638 + comma{TPM_ECC_BN_P638, + 638, + {TPM_ALG_NULL, {{TPM_ALG_NULL}}}, + {TPM_ALG_NULL, {{TPM_ALG_NULL}}}, + OID_ECC_BN_P638 CURVE_NAME("BN_P638")} +# undef comma +# define comma , +# endif // ECC_BN_P638 +# if ECC_SM2_P256 + comma{TPM_ECC_SM2_P256, + 256, + {TPM_ALG_KDF1_SP800_56A, {{TPM_ALG_SM3_256}}}, + {TPM_ALG_NULL, {{TPM_ALG_NULL}}}, + OID_ECC_SM2_P256 CURVE_NAME("SM2_P256")} +# undef comma +# define comma , +# endif // ECC_SM2_P256 +}; + +#endif // TPM_ALG_ECC diff --git a/src/tpm2/crypto/openssl/CryptEccKeyExchange.c b/src/tpm2/TPMCmd/tpm/src/crypt/CryptEccKeyExchange.c similarity index 77% rename from src/tpm2/crypto/openssl/CryptEccKeyExchange.c rename to src/tpm2/TPMCmd/tpm/src/crypt/CryptEccKeyExchange.c index 3dbeba8b1..c25cba48d 100644 --- a/src/tpm2/crypto/openssl/CryptEccKeyExchange.c +++ b/src/tpm2/TPMCmd/tpm/src/crypt/CryptEccKeyExchange.c @@ -1,62 +1,4 @@ -/********************************************************************************/ -/* */ -/* Functions that are used for the two-phase, ECC, key-exchange protocols */ -/* 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 functions that are used for the two-phase, ECC, @@ -90,7 +32,7 @@ static BOOL avf1(Crypt_Int* bnX, // IN/OUT: the reduced value int f = (ExtMath_SizeInBits(bnN) + 1) / 2; // x' = 2^f + (x mod 2^f) ExtMath_MaskBits(bnX, f); // This is mod 2*2^f but it doesn't matter because - // the next operation will SET the extra bit anyway + // the next operation will SET the extra bit anyway if(!ExtMath_SetBit(bnX, f)) { FAIL(FATAL_ERROR_CRYPTO); @@ -132,7 +74,7 @@ static TPM_RC C_2_2_MQV(TPMS_ECC_POINT* outZ, // OUT: the computed point // Parameter checks if(E == NULL) ERROR_EXIT(TPM_RC_VALUE); - pAssert( + pAssert_RC( outZ != NULL && pQeB != NULL && pQsB != NULL && deA != NULL && dsA != NULL); // Process: // 1. implicitsigA = (de,A + avf(Qe,A)ds,A ) mod n. @@ -217,7 +159,7 @@ static TPM_RC C_2_2_ECDH(TPMS_ECC_POINT* outZs, // OUT: Zs // Parameter checks if(E == NULL) ERROR_EXIT(TPM_RC_CURVE); - pAssert( + pAssert_RC( outZs != NULL && dsA != NULL && deA != NULL && QsB != NULL && QeB != NULL); // Do the point multiply for the Zs value ([dsA]QsB) @@ -252,7 +194,7 @@ LIB_EXPORT TPM_RC CryptEcc2PhaseKeyExchange( TPMS_ECC_POINT* QeB // IN: ephemeral public party B key ) { - pAssert( + pAssert_RC( outZ1 != NULL && dsA != NULL && deA != NULL && QsB != NULL && QeB != NULL); // Initialize the output points so that they are empty until one of the @@ -358,7 +300,8 @@ LIB_EXPORT TPM_RC SM2KeyExchange( // Parameter checks if(E == NULL) ERROR_EXIT(TPM_RC_CURVE); - pAssert(outZ != NULL && dsA != NULL && deA != NULL && QsB != NULL && QeB != NULL); + pAssert_RC( + outZ != NULL && dsA != NULL && deA != NULL && QsB != NULL && QeB != NULL); // Compute the value for w w = ComputeWForSM2(curveId); diff --git a/src/tpm2/crypto/openssl/CryptEccMain.c b/src/tpm2/TPMCmd/tpm/src/crypt/CryptEccMain.c similarity index 89% rename from src/tpm2/crypto/openssl/CryptEccMain.c rename to src/tpm2/TPMCmd/tpm/src/crypt/CryptEccMain.c index ef84d9357..e35484b63 100644 --- a/src/tpm2/crypto/openssl/CryptEccMain.c +++ b/src/tpm2/TPMCmd/tpm/src/crypt/CryptEccMain.c @@ -1,62 +1,4 @@ -/********************************************************************************/ -/* */ -/* ECC Main */ -/* 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 - 2024 */ -/* */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause //** Includes and Defines #include "Tpm.h" @@ -64,6 +6,7 @@ #include "TpmEcc_Util_fp.h" #include "TpmEcc_Signature_ECDSA_fp.h" // required for pairwise test in key generation #include "Helpers_fp.h" // libtpms added + #if ALG_ECC //** Functions @@ -534,7 +477,8 @@ BOOL TpmEcc_GenPrivateScalar( OK = OK && ExtMath_SubtractWord(nMinus1, order, 1); OK = OK && ExtMath_Mod(bnExtraBits, nMinus1); OK = OK && ExtMath_AddWord(dOut, bnExtraBits, 1); - return OK && !g_inFailureMode; + + return OK && !_plat__InFailureMode(); } #else // libtpms added begin BOOL TpmEcc_GenPrivateScalar( @@ -568,7 +512,8 @@ BOOL TpmEcc_GenPrivateScalar( OK = OK && ExtMath_SubtractWord(nMinus1, order, 1); OK = OK && ExtMath_Mod(bnExtraBits, nMinus1); OK = OK && ExtMath_AddWord(dOut, bnExtraBits, 1); - return OK && !g_inFailureMode; + + return OK && !_plat__InFailureMode(); } #endif // USE_OPENSSL_FUNCTIONS_EC libtpms added end @@ -588,6 +533,7 @@ BOOL TpmEcc_GenerateKeyPair(Crypt_Int* bnD, // OUT: private scalar // Do a point multiply OK = OK && ExtEcc_PointMultiply(ecQ, NULL, bnD, E); + return OK; } @@ -715,6 +661,7 @@ LIB_EXPORT TPM_RC CryptEccPointMultiply( TpmEcc_PointTo2B(Rout, ecR, E); else ClearPoint2B(Rout); + CRYPT_CURVE_FREE(E); return retVal; } @@ -736,7 +683,7 @@ LIB_EXPORT BOOL CryptEccIsPointOnCurve( CRYPT_POINT_INITIALIZED(ecQ, Qin); BOOL OK; // - pAssert(Qin != NULL); + pAssert_BOOL(Qin != NULL); OK = (E != NULL && (ExtEcc_IsPointOnCurve(ecQ, E))); CRYPT_CURVE_FREE(E); // libtpms added return OK; @@ -806,7 +753,7 @@ LIB_EXPORT TPM_RC CryptEccGenerateKey( digest.t.size = MIN(sensitive->sensitive.ecc.t.size, sizeof(digest.t.buffer)); // Get a random value to sign using the built in DRBG state DRBG_Generate(NULL, digest.t.buffer, digest.t.size); - if(g_inFailureMode) + if(_plat__InFailureMode()) return TPM_RC_FAILURE; TpmEcc_SignEcdsa(bnT, bnS, E, bnD, &digest, NULL); // and make sure that we can validate the signature diff --git a/src/tpm2/crypto/openssl/CryptEccSignature.c b/src/tpm2/TPMCmd/tpm/src/crypt/CryptEccSignature.c similarity index 73% rename from src/tpm2/crypto/openssl/CryptEccSignature.c rename to src/tpm2/TPMCmd/tpm/src/crypt/CryptEccSignature.c index 395099512..4d9da51a0 100644 --- a/src/tpm2/crypto/openssl/CryptEccSignature.c +++ b/src/tpm2/TPMCmd/tpm/src/crypt/CryptEccSignature.c @@ -1,62 +1,4 @@ -/********************************************************************************/ -/* */ -/* ECC Signatures */ -/* 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 - 2024 */ -/* */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause //** Includes and Defines #include "Tpm.h" @@ -227,7 +169,7 @@ LIB_EXPORT TPM_RC CryptEccValidateSignature( break; # endif default: - FAIL(FATAL_ERROR_INTERNAL); + FAIL_RC(FATAL_ERROR_INTERNAL); } Exit: CRYPT_CURVE_FREE(E); @@ -270,7 +212,7 @@ LIB_EXPORT TPM_RC CryptEccCommitCompute( // Validate that the required parameters are provided. // Note: E has to be provided if computing E := [r]Q or E := [r]M. Will do // E := [r]Q if both M and B are NULL. - pAssert(r != NULL && E != NULL); + pAssert_RC(r != NULL && E != NULL); // Initialize the output points in case they are not computed ClearPoint2B(K); @@ -278,7 +220,7 @@ LIB_EXPORT TPM_RC CryptEccCommitCompute( ClearPoint2B(E); // Sizes of the r parameter may not be zero - pAssert(r->t.size > 0); + pAssert_RC(r->t.size > 0); // If B is provided, compute K=[d]B and L=[r]B if(B != NULL) @@ -288,7 +230,7 @@ LIB_EXPORT TPM_RC CryptEccCommitCompute( CRYPT_POINT_VAR(pK); CRYPT_POINT_VAR(pL); // - pAssert(d != NULL && K != NULL && L != NULL); + pAssert_RC(d != NULL && K != NULL && L != NULL); if (!curve) // libtpms added ERROR_EXIT(TPM_RC_NO_RESULT); // libtpms added @@ -318,7 +260,7 @@ LIB_EXPORT TPM_RC CryptEccCommitCompute( CRYPT_POINT_VAR(pE); // // Make sure that a place was provided for the result - pAssert(E != NULL); + pAssert_RC(E != NULL); // if this is the third point multiply, check for cancel first if((B != NULL) && _plat__IsCanceled()) diff --git a/src/tpm2/crypto/openssl/CryptHash.c b/src/tpm2/TPMCmd/tpm/src/crypt/CryptHash.c similarity index 87% rename from src/tpm2/crypto/openssl/CryptHash.c rename to src/tpm2/TPMCmd/tpm/src/crypt/CryptHash.c index 13e5099f9..952ed3a64 100644 --- a/src/tpm2/crypto/openssl/CryptHash.c +++ b/src/tpm2/TPMCmd/tpm/src/crypt/CryptHash.c @@ -1,62 +1,4 @@ -/********************************************************************************/ -/* */ -/* Implementation of cryptographic functions for hashing. */ -/* 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 - 2024 */ -/* */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause //** Description // @@ -119,9 +61,9 @@ BOOL CryptHashStartup(void) PHASH_DEF CryptGetHashDef(TPM_ALG_ID hashAlg) { -#define GET_DEF(HASH, Hash) \ - case ALG_##HASH##_VALUE: \ - return &Hash##_Def; +#define GET_DEF(HASH, Hash) \ + case ALG_##HASH##_VALUE: \ + return &Hash##_Def; switch(hashAlg) { FOR_EACH_HASH(GET_DEF) @@ -137,9 +79,10 @@ CryptGetHashDef(TPM_ALG_ID hashAlg) // Return Type: BOOL // TRUE(1) hashAlg is a valid, implemented hash on this TPM // FALSE(0) hashAlg is not valid for this TPM -BOOL CryptHashIsValidAlg(TPM_ALG_ID hashAlg, // IN: the algorithm to check - BOOL isAlgNullValid // IN: TRUE if TPM_ALG_NULL is to be treated - // as a valid hash +BOOL CryptHashIsValidAlg( + TPM_ALG_ID hashAlg, // IN: the algorithm to check + BOOL isAlgNullValid // IN: TRUE if TPM_ALG_NULL is to be treated + // as a valid hash ) { if(hashAlg == TPM_ALG_NULL) @@ -258,10 +201,10 @@ void CryptHashExportState( MUST_BE(sizeof(HASH_STATE) <= sizeof(EXPORT_HASH_STATE)); // the following #define is used to move data from an aligned internal data // structure to a byte buffer (external format data. -#define CopyToOffset(value) \ - memcpy(&outBuf[offsetof(HASH_STATE, value)], \ - &internalFmt->value, \ - sizeof(internalFmt->value)) +#define CopyToOffset(value) \ + memcpy(&outBuf[offsetof(HASH_STATE, value)], \ + &internalFmt->value, \ + sizeof(internalFmt->value)) // Copy the hashAlg CopyToOffset(hashAlg); CopyToOffset(type); @@ -295,10 +238,10 @@ void CryptHashImportState( { BYTE* inBuf = (BYTE*)externalFmt; // -#define CopyFromOffset(value) \ - memcpy(&internalFmt->value, \ - &inBuf[offsetof(HASH_STATE, value)], \ - sizeof(internalFmt->value)) +#define CopyFromOffset(value) \ + memcpy(&internalFmt->value, \ + &inBuf[offsetof(HASH_STATE, value)], \ + sizeof(internalFmt->value)) // Copy the hashAlg of the byte-aligned input structure to the structure-aligned // internal structure. @@ -415,7 +358,14 @@ void CryptDigestUpdate(PHASH_STATE hashState, // IN: the hash context informati &hashState->state.smac.state, dataSize, data); #endif // SMAC_IMPLEMENTED else - FAIL(FATAL_ERROR_INTERNAL); + { + // this void assert is OK because these values only indicate the + // intention of the hash, but don't actually affect the hash + // calculation or buffer size calculations. IOW, the failure + // set here can safely percolate out and be checked at a higher + // level. + FAIL_VOID(FATAL_ERROR_INTERNAL); + } } return; } @@ -433,7 +383,7 @@ LIB_EXPORT UINT16 CryptHashEnd(PHASH_STATE hashState, // IN: the state of hash BYTE* dOut // OUT: hash digest ) { - pAssert(hashState->type == HASH_STATE_HASH); + pAssert_ZERO(hashState->type == HASH_STATE_HASH); return HashEnd(hashState, dOutSize, dOut); } @@ -471,7 +421,10 @@ LIB_EXPORT void CryptDigestUpdate2B(PHASH_STATE state, // IN: the digest state // In CryptDigestUpdate(), if size is zero or buffer is NULL, then no change // to the digest occurs. This function should not provide a buffer if bIn is // not provided. - pAssert(bIn != NULL); + // as indicated by the comment above CryptDigestUpdate is tolerant of null, but + // we don't expect a null pointer here, so simply return but trigger failure + // mode because this is an unexpected internal programming error. + pAssert_VOID_OK(bIn != NULL); CryptDigestUpdate(state, bIn->size, bIn->buffer); return; } @@ -594,7 +547,7 @@ LIB_EXPORT UINT16 CryptHmacEnd(PHMAC_STATE state, // IN: the hash state buff return (state->hashState.state.smac.smacMethods.end)( &state->hashState.state.smac.state, dOutSize, dOut); #endif - pAssert(hState->type == HASH_STATE_HMAC); + pAssert_ZERO(hState->type == HASH_STATE_HMAC); hState->def = CryptGetHashDef(hState->hashAlg); // Change the state type for completion processing hState->type = HASH_STATE_HASH; @@ -739,7 +692,7 @@ LIB_EXPORT UINT16 CryptKDFa( HMAC_STATE hState; UINT16 digestSize = CryptHashGetDigestSize(hashAlg); - pAssert(key != NULL && keyStream != NULL); + pAssert_ZERO(key != NULL && keyStream != NULL); TPM_DO_SELF_TEST(TPM_ALG_KDF1_SP800_108); @@ -751,7 +704,7 @@ LIB_EXPORT UINT16 CryptKDFa( // If the size of the request is larger than the numbers will handle, // it is a fatal error. - pAssert(((sizeInBits + 7) / 8) <= INT16_MAX); + pAssert_ZERO(((sizeInBits + 7) / 8) <= INT16_MAX); // The number of bytes to be generated is the smaller of the sizeInBits bytes or // the number of requested blocks. The number of blocks is the smaller of the @@ -833,7 +786,8 @@ LIB_EXPORT UINT16 CryptKDFe(TPM_ALG_ID hashAlg, // IN: hash algorithm used in BYTE* stream = keyStream; INT16 bytes; // number of bytes to generate - pAssert(keyStream != NULL && Z != NULL && ((sizeInBits + 7) / 8) < INT16_MAX); + pAssert_ZERO( + keyStream != NULL && Z != NULL && ((sizeInBits + 7) / 8) < INT16_MAX); // hLen = hashDef->digestSize; bytes = (INT16)((sizeInBits + 7) / 8); diff --git a/src/tpm2/crypto/openssl/CryptPrime.c b/src/tpm2/TPMCmd/tpm/src/crypt/CryptPrime.c similarity index 81% rename from src/tpm2/crypto/openssl/CryptPrime.c rename to src/tpm2/TPMCmd/tpm/src/crypt/CryptPrime.c index e2087343e..f1304ff6d 100644 --- a/src/tpm2/crypto/openssl/CryptPrime.c +++ b/src/tpm2/TPMCmd/tpm/src/crypt/CryptPrime.c @@ -1,62 +1,4 @@ -/********************************************************************************/ -/* */ -/* Code for prime validation. */ -/* 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 code for prime validation. @@ -238,7 +180,7 @@ BOOL MillerRabin(Crypt_Int* bnW, RAND_STATE* rand) && ((ExtMath_UnsignedCmpWord(bnB, 1) <= 0) || (ExtMath_UnsignedCmp(bnB, bnWm1) >= 0))) ; - if(g_inFailureMode) + if( _plat__InFailureMode()) return FALSE; // 4.3 z = b^m mod w. @@ -310,7 +252,7 @@ RsaCheckPrime(Crypt_Int* prime, UINT32 exponent, RAND_STATE* rand) ExtMath_SubtractWord(prime, prime, 2); if(TpmMath_IsProbablyPrime(prime, rand) == 0) - ERROR_EXIT(g_inFailureMode ? TPM_RC_FAILURE : TPM_RC_VALUE); + ERROR_EXIT( _plat__InFailureMode() ? TPM_RC_FAILURE : TPM_RC_VALUE); Exit: return retVal; # else @@ -470,9 +412,9 @@ TPM_RC TpmRsa_GeneratePrimeForRSA( BOOL found = FALSE; // // Make sure that the prime is large enough - pAssert(prime->allocated >= BITS_TO_CRYPT_WORDS(bits)); + pAssert_RC(prime->allocated >= BITS_TO_CRYPT_WORDS(bits)); // Only try to handle specific sizes of keys in order to save overhead - pAssert((bits % 32) == 0); + pAssert_RC((bits % 32) == 0); prime->size = BITS_TO_CRYPT_WORDS(bits); @@ -481,12 +423,12 @@ TPM_RC TpmRsa_GeneratePrimeForRSA( // The change below is to make sure that all keys that are generated from the same // seed value will be the same regardless of the endianess or word size of the CPU. // DRBG_Generate(rand, (BYTE *)prime->d, (UINT16)BITS_TO_BYTES(bits));// old - // if(g_inFailureMode) // old + // if(_plat_InFailureMode()) // old // libtpms changed begin switch (DRBG_GetSeedCompatLevel(rand)) { case SEED_COMPAT_LEVEL_ORIGINAL: DRBG_Generate(rand, (BYTE *)prime->d, (UINT16)BITS_TO_BYTES(bits)); - if (g_inFailureMode) + if (_plat__InFailureMode()) return TPM_RC_FAILURE; RsaAdjustPrimeCandidate_PreRev155(prime); break; diff --git a/src/tpm2/crypto/openssl/CryptPrimeSieve.c b/src/tpm2/TPMCmd/tpm/src/crypt/CryptPrimeSieve.c similarity index 86% rename from src/tpm2/crypto/openssl/CryptPrimeSieve.c rename to src/tpm2/TPMCmd/tpm/src/crypt/CryptPrimeSieve.c index 9bfeccca4..e1ccb5010 100644 --- a/src/tpm2/crypto/openssl/CryptPrimeSieve.c +++ b/src/tpm2/TPMCmd/tpm/src/crypt/CryptPrimeSieve.c @@ -1,62 +1,4 @@ -/********************************************************************************/ -/* */ -/* CryptPrimeSieve */ -/* 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 - 2024 */ -/* */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause //** Includes and defines @@ -477,7 +419,7 @@ LIB_EXPORT TPM_RC PrimeSelectWithSieve( ones = PrimeSieve(candidate, fieldSize, field); // PrimeSieve shouldn't fail, but does call functions that may. - if(!g_inFailureMode) + if(! _plat__InFailureMode()) { pAssert(ones > 0 && ones < (fieldSize * 8)); for(; ones > 0; ones--) @@ -506,7 +448,7 @@ LIB_EXPORT TPM_RC PrimeSelectWithSieve( // Ran out of bits and couldn't find a prime in this field INSTRUMENT_INC(noPrimeFields[PrimeIndex]); } - return (g_inFailureMode ? TPM_RC_FAILURE : TPM_RC_NO_RESULT); + return ( _plat__InFailureMode() ? TPM_RC_FAILURE : TPM_RC_NO_RESULT); } # if RSA_INSTRUMENT diff --git a/src/tpm2/crypto/openssl/CryptRand.c b/src/tpm2/TPMCmd/tpm/src/crypt/CryptRand.c similarity index 88% rename from src/tpm2/crypto/openssl/CryptRand.c rename to src/tpm2/TPMCmd/tpm/src/crypt/CryptRand.c index d2fc789d1..da02fde7e 100644 --- a/src/tpm2/crypto/openssl/CryptRand.c +++ b/src/tpm2/TPMCmd/tpm/src/crypt/CryptRand.c @@ -1,62 +1,4 @@ -/********************************************************************************/ -/* */ -/* DRBG with a behavior according to SP800-90A */ -/* 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 implements a DRBG with a behavior according to SP800-90A using @@ -167,43 +109,42 @@ static void DfStart(PDF_STATE dfState, uint32_t inputLength) { BYTE init[8]; int i; - UINT32 drbgSeedSize = sizeof(DRBG_SEED); - - const BYTE dfKey[DRBG_KEY_SIZE_BYTES] = - { 0x00, - 0x01, - 0x02, - 0x03, - 0x04, - 0x05, - 0x06, - 0x07, - 0x08, - 0x09, - 0x0a, - 0x0b, - 0x0c, - 0x0d, - 0x0e, - 0x0f + UINT32 drbgSeedSize = sizeof(DRBG_SEED); + + const BYTE dfKey[DRBG_KEY_SIZE_BYTES] = {0x00, + 0x01, + 0x02, + 0x03, + 0x04, + 0x05, + 0x06, + 0x07, + 0x08, + 0x09, + 0x0a, + 0x0b, + 0x0c, + 0x0d, + 0x0e, + 0x0f #if DRBG_KEY_SIZE_BYTES > 16 - , - 0x10, - 0x11, - 0x12, - 0x13, - 0x14, - 0x15, - 0x16, - 0x17, - 0x18, - 0x19, - 0x1a, - 0x1b, - 0x1c, - 0x1d, - 0x1e, - 0x1f + , + 0x10, + 0x11, + 0x12, + 0x13, + 0x14, + 0x15, + 0x16, + 0x17, + 0x18, + 0x19, + 0x1a, + 0x1b, + 0x1c, + 0x1d, + 0x1e, + 0x1f #endif }; memset(dfState, 0, sizeof(DF_STATE)); @@ -238,7 +179,8 @@ static void DfUpdate(PDF_STATE dfState, int size, const BYTE* data) data += toFill; // increase the buffer contents count by the amount copied dfState->contents += toFill; - pAssert(dfState->contents <= DRBG_IV_SIZE_BYTES); + // error will eventually get handled + pAssert_VOID_OK(dfState->contents <= DRBG_IV_SIZE_BYTES); // If we have a full buffer, do a computation pass. if(dfState->contents == DRBG_IV_SIZE_BYTES) DfCompute(dfState); @@ -312,7 +254,7 @@ BOOL DRBG_GetEntropy(UINT32 requiredEntropy, // IN: requested number of bytes o { // In self-test, the caller should be asking for exactly the seed // size of entropy. - pAssert(requiredEntropy == sizeof(DRBG_NistTestVector_Entropy)); + pAssert_BOOL(requiredEntropy == sizeof(DRBG_NistTestVector_Entropy)); memcpy(entropy, DRBG_NistTestVector_Entropy, sizeof(DRBG_NistTestVector_Entropy)); @@ -447,7 +389,7 @@ static BOOL DRBG_Update( memset(&localKeySchedule, 0, sizeof(localKeySchedule)); /* libtpms added: coverity */ // - pAssert(drbgState->magic == DRBG_MAGIC); + pAssert_BOOL(drbgState->magic == DRBG_MAGIC); // If an key schedule was not provided, make one if(keySchedule == NULL) @@ -487,7 +429,7 @@ BOOL DRBG_Reseed(DRBG_STATE* drbgState, // IN: the state to update { DRBG_SEED seed; - pAssert((drbgState != NULL) && (drbgState->magic == DRBG_MAGIC)); + pAssert_BOOL((drbgState != NULL) && (drbgState->magic == DRBG_MAGIC)); if(providedEntropy == NULL) { @@ -524,7 +466,7 @@ BOOL DRBG_SelfTest(void) BYTE* p; DRBG_STATE testState; // - pAssert(!IsSelfTest()); + pAssert_BOOL(!IsSelfTest()); // no recursion SetSelfTest(); SetDrbgTested(); @@ -605,7 +547,7 @@ LIB_EXPORT TPM_RC CryptRandomStir(UINT16 additionalDataSize, BYTE* additionalDat &tmpBuf, DfBuffer(&dfResult, additionalDataSize, additionalData)); drbgDefault.reseedCounter = 1; - + VERIFY_NOT_FAILED(); return TPM_RC_SUCCESS; #else @@ -730,7 +672,7 @@ LIB_EXPORT TPM_RC DRBG_InstantiateSeeded( // Used the derivation function output as the "entropy" input. This is not // how it is described in SP800-90A but this is the equivalent function DRBG_Reseed(((DRBG_STATE*)drbgState), DfEnd(&dfState), NULL); - + VERIFY_NOT_FAILED(); return TPM_RC_SUCCESS; } @@ -960,7 +902,8 @@ LIB_EXPORT BOOL DRBG_Instantiate( DRBG_SEED seed; DRBG_SEED dfResult; // - pAssert((pSize == 0) || (pSize <= sizeof(seed)) || (personalization != NULL)); + pAssert_BOOL( + (pSize == 0) || (pSize <= sizeof(seed)) || (personalization != NULL)); // If the DRBG has not been tested, test when doing an instantiation. Since // Instantiation is called during self test, make sure we don't get stuck in a // loop. @@ -978,7 +921,7 @@ LIB_EXPORT BOOL DRBG_Instantiate( // reseeding does. So, do a reduction on the personalization value (if any) // and do a reseed. DRBG_Reseed(drbgState, &seed, DfBuffer(&dfResult, pSize, personalization)); - + VERIFY(!_plat__InFailureMode(), FATAL_ERROR_ENTROPY, TPM_RC_FAILURE); return TRUE; } diff --git a/src/tpm2/crypto/openssl/CryptRsa.c b/src/tpm2/TPMCmd/tpm/src/crypt/CryptRsa.c similarity index 95% rename from src/tpm2/crypto/openssl/CryptRsa.c rename to src/tpm2/TPMCmd/tpm/src/crypt/CryptRsa.c index e52ff432d..93884e176 100644 --- a/src/tpm2/crypto/openssl/CryptRsa.c +++ b/src/tpm2/TPMCmd/tpm/src/crypt/CryptRsa.c @@ -1,62 +1,4 @@ -/********************************************************************************/ -/* */ -/* Implementation of cryptographic primitives for RSA */ -/* 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 - 2024 */ -/* */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause //** Introduction // @@ -147,7 +89,7 @@ static BOOL PackExponent(TPM2B_PRIVATE_KEY_RSA* packed, privateExponent* Z) UINT16 primeSize = (UINT16)BITS_TO_BYTES(ExtMath_MostSigBitNum(Z->P)); UINT16 pS = primeSize; // - pAssert((primeSize * 5) <= sizeof(packed->t.buffer)); + pAssert((size_t)(primeSize * 5) <= sizeof(packed->t.buffer)); packed->t.size = (primeSize * 5) + RSA_prime_flag; for(i = 0; i < 5; i++) if(!ExtMath_IntToBytes( @@ -390,7 +332,7 @@ static TPM_RC OaepEncode( dbSize = hLen + padLen + message->size; DRBG_Generate(rand, mySeed, (UINT16)hLen); - if(g_inFailureMode) + if( _plat__InFailureMode()) ERROR_EXIT(TPM_RC_FAILURE); // mask = MGF1 (seed, nSize hLen 1) CryptMGF_KDF(dbSize, mask, hashAlg, hLen, seed, 0); @@ -535,7 +477,7 @@ static TPM_RC RSAES_PKCS1v1_5Encode(TPM2B* padded, // OUT: the pad data // Fill with random bytes DRBG_Generate(rand, &padded->buffer[2], (UINT16)ps); - if(g_inFailureMode) + if( _plat__InFailureMode()) return TPM_RC_FAILURE; // Set the delimiter for the random field to 0 @@ -645,7 +587,7 @@ static TPM_RC PssEncode(TPM2B* out, // OUT: the encoded buffer // Get set the salt DRBG_Generate(rand, salt, saltSize); - if(g_inFailureMode) + if( _plat__InFailureMode()) return TPM_RC_FAILURE; // Create the hash of the pad || input hash || salt diff --git a/src/tpm2/CryptSelfTest.c b/src/tpm2/TPMCmd/tpm/src/crypt/CryptSelfTest.c similarity index 65% rename from src/tpm2/CryptSelfTest.c rename to src/tpm2/TPMCmd/tpm/src/crypt/CryptSelfTest.c index d20831aaa..0aa50ce56 100644 --- a/src/tpm2/CryptSelfTest.c +++ b/src/tpm2/TPMCmd/tpm/src/crypt/CryptSelfTest.c @@ -1,62 +1,4 @@ -/********************************************************************************/ -/* */ -/* Self-Test of Cryptographic Functions */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2016 - 2024 */ -/* */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause //** Introduction // The functions in this file are designed to support self-test of cryptographic @@ -116,10 +58,7 @@ TPM_RC CryptSelfTest(TPMI_YES_NO fullTest // IN: if full test is required ) { -#if ALLOW_FORCE_FAILURE_MODE - if(g_forceFailureMode) - FAIL(FATAL_ERROR_FORCED); -#endif + ALGORITHM_VECTOR toTestVector = {0}; // If the caller requested a full test, then reset the to test vector so that // all the tests will be run @@ -127,7 +66,21 @@ CryptSelfTest(TPMI_YES_NO fullTest // IN: if full test is required { MemoryCopy(g_toTest, g_implementedAlgorithms, sizeof(g_toTest)); } - return CryptRunSelfTests(&g_toTest); + + // Some platforms may have alternative crypto libraries and self-test capabilities, + // so allow the platform to return the list of tests it wants the TPM code to run + // directly. We assume the platform will make alternative arrangements for any + // tests it does not return here, consistent with that platform's compliance goals. + // + // A platform may provide different lists at different times and we leave the + // g_toTest flags set for any tests that are not requested by the platform. + // + // Note that a crypto library may also perform additional self-tests through other + // means and/or in response to g_toTest at other points in the code. + MemoryCopy(toTestVector, g_toTest, sizeof(toTestVector)); + _plat_GetEnabledSelfTest(fullTest, toTestVector, sizeof(toTestVector)); + + return CryptRunSelfTests(&toTestVector); } //*** CryptIncrementalSelfTest() @@ -151,7 +104,7 @@ CryptIncrementalSelfTest(TPML_ALG* toTest, // IN: list of algorithms to be tes TPM_ALG_ID alg; UINT32 i; - pAssert(toTest != NULL && toDoList != NULL); + pAssert_RC(toTest != NULL && toDoList != NULL); if(toTest->count > 0) { // Transcribe the toTest list into the toTestVector diff --git a/src/tpm2/TPMCmd/tpm/src/crypt/CryptSmac.c b/src/tpm2/TPMCmd/tpm/src/crypt/CryptSmac.c new file mode 100644 index 000000000..4d6af6d0f --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/src/crypt/CryptSmac.c @@ -0,0 +1,91 @@ +// SPDX-License-Identifier: BSD-2-Clause + +//** Introduction +// +// This file contains the implementation of the message authentication codes based +// on a symmetric block cipher. These functions only use the single block +// encryption functions of the selected symmetric cryptographic library. + +//** Includes, Defines, and Typedefs +#define _CRYPT_HASH_C_ +#include "Tpm.h" + +#if SMAC_IMPLEMENTED + +//*** CryptSmacStart() +// Function to start an SMAC. +UINT16 +CryptSmacStart(HASH_STATE* state, + TPMU_PUBLIC_PARMS* keyParameters, + TPM_ALG_ID macAlg, // IN: the type of MAC + TPM2B* key) +{ + UINT16 retVal = 0; + // + // Make sure that the key size is correct. This should have been checked + // at key load, but... + if(BITS_TO_BYTES(keyParameters->symDetail.sym.keyBits.sym) == key->size) + { + switch(macAlg) + { +# if ALG_CMAC + case TPM_ALG_CMAC: + retVal = + CryptCmacStart(&state->state.smac, keyParameters, macAlg, key); + break; +# endif + default: + break; + } + } + state->type = (retVal != 0) ? HASH_STATE_SMAC : HASH_STATE_EMPTY; + return retVal; +} + +//*** CryptMacStart() +// Function to start either an HMAC or an SMAC. Cannot reuse the CryptHmacStart +// function because of the difference in number of parameters. +UINT16 +CryptMacStart(HMAC_STATE* state, + TPMU_PUBLIC_PARMS* keyParameters, + TPM_ALG_ID macAlg, // IN: the type of MAC + TPM2B* key) +{ + MemorySet(state, 0, sizeof(HMAC_STATE)); + if(CryptHashIsValidAlg(macAlg, FALSE)) + { + return CryptHmacStart(state, macAlg, key->size, key->buffer); + } + else if(CryptSmacIsValidAlg(macAlg, FALSE)) + { + return CryptSmacStart(&state->hashState, keyParameters, macAlg, key); + } + else + return 0; +} + +//*** CryptMacEnd() +// Dispatch to the MAC end function using a size and buffer pointer. +UINT16 +CryptMacEnd(HMAC_STATE* state, UINT32 size, BYTE* buffer) +{ + UINT16 retVal = 0; + if(state->hashState.type == HASH_STATE_SMAC) + retVal = (state->hashState.state.smac.smacMethods.end)( + &state->hashState.state.smac.state, size, buffer); + else if(state->hashState.type == HASH_STATE_HMAC) + retVal = CryptHmacEnd(state, size, buffer); + state->hashState.type = HASH_STATE_EMPTY; + return retVal; +} + +#if 0 /* libtpms added */ +//*** CryptMacEnd2B() +// Dispatch to the MAC end function using a 2B. +UINT16 +CryptMacEnd2B(HMAC_STATE* state, TPM2B* data) +{ + return CryptMacEnd(state, data->size, data->buffer); +} +#endif /* libtpms added */ +#endif // SMAC_IMPLEMENTED diff --git a/src/tpm2/crypto/openssl/CryptSym.c b/src/tpm2/TPMCmd/tpm/src/crypt/CryptSym.c similarity index 87% rename from src/tpm2/crypto/openssl/CryptSym.c rename to src/tpm2/TPMCmd/tpm/src/crypt/CryptSym.c index 70d52f286..dd3533a56 100644 --- a/src/tpm2/crypto/openssl/CryptSym.c +++ b/src/tpm2/TPMCmd/tpm/src/crypt/CryptSym.c @@ -1,62 +1,4 @@ -/********************************************************************************/ -/* */ -/* Symmetric block cipher modes */ -/* 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 - 2024 */ -/* */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause //** Introduction // @@ -103,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 @@ -177,7 +118,7 @@ LIB_EXPORT TPM_RC CryptSymmetricEncrypt( BYTE* iv; BYTE defaultIv[MAX_SYM_BLOCK_SIZE] = {0}; // - pAssert(dOut != NULL && key != NULL && dIn != NULL); + pAssert_RC(dOut != NULL && key != NULL && dIn != NULL); memset((void *)&keySchedule, 0, sizeof(keySchedule)); /* silence false positive; coverity */ memset(tmp, 0, sizeof(tmp)); if(dSize == 0) @@ -342,7 +283,7 @@ LIB_EXPORT TPM_RC CryptSymmetricDecrypt( encrypt = NULL; decrypt = NULL; - pAssert(dOut != NULL && key != NULL && dIn != NULL); + pAssert_RC(dOut != NULL && key != NULL && dIn != NULL); if(dSize == 0) return TPM_RC_SUCCESS; @@ -565,7 +506,7 @@ CryptSymmetricEncrypt( UINT16 keyToUseLen = (UINT16)sizeof(keyToUse); TPM_RC retVal = TPM_RC_SUCCESS; - pAssert(dOut != NULL && key != NULL && dIn != NULL); + pAssert_RC(dOut != NULL && key != NULL && dIn != NULL); if(dSize == 0) return TPM_RC_SUCCESS; TPM_DO_SELF_TEST(algorithm); @@ -623,7 +564,7 @@ CryptSymmetricEncrypt( EVP_EncryptUpdate(ctx, pOut, &outlen1, dIn, dSize) != 1) ERROR_EXIT(TPM_RC_FAILURE); - pAssert(outlen1 <= dSize || dSize >= outlen1 + blockSize); + pAssert_RC(outlen1 <= dSize || dSize >= outlen1 + blockSize); if (EVP_EncryptFinal_ex(ctx, pOut + outlen1, &outlen2) != 1) ERROR_EXIT(TPM_RC_FAILURE); @@ -677,7 +618,7 @@ CryptSymmetricDecrypt( // in case statements and it can't tell if they are always initialized // when needed, so... Comment these out if the compiler can tell or doesn't // care that these are initialized before use. - pAssert(dOut != NULL && key != NULL && dIn != NULL); + pAssert_RC(dOut != NULL && key != NULL && dIn != NULL); if(dSize == 0) return TPM_RC_SUCCESS; TPM_DO_SELF_TEST(algorithm); @@ -736,20 +677,20 @@ CryptSymmetricDecrypt( EVP_DecryptUpdate(ctx, buffer, &outlen1, dIn, dSize) != 1) ERROR_EXIT(TPM_RC_FAILURE); - pAssert((int)buffersize >= outlen1); + pAssert_RC((int)buffersize >= outlen1); if ((int)buffersize <= outlen1 /* coverity */ || EVP_DecryptFinal(ctx, &buffer[outlen1], &outlen2) != 1) ERROR_EXIT(TPM_RC_FAILURE); - pAssert((int)buffersize >= outlen1 + outlen2); + pAssert_RC((int)buffersize >= outlen1 + outlen2); if (ivInOut) retVal = CryptSymmetricGetUpdatedIV(ctx, ivInOut); Exit: if (retVal == TPM_RC_SUCCESS) { - pAssert(dSize >= outlen1 + outlen2); + pAssert_RC(dSize >= outlen1 + outlen2); memcpy(dOut, buffer, outlen1 + outlen2); } diff --git a/src/tpm2/CryptUtil.c b/src/tpm2/TPMCmd/tpm/src/crypt/CryptUtil.c similarity index 88% rename from src/tpm2/CryptUtil.c rename to src/tpm2/TPMCmd/tpm/src/crypt/CryptUtil.c index 3775b23f4..e1975645a 100644 --- a/src/tpm2/CryptUtil.c +++ b/src/tpm2/TPMCmd/tpm/src/crypt/CryptUtil.c @@ -1,62 +1,4 @@ -/********************************************************************************/ -/* */ -/* Interfaces to the Crypto Engine */ -/* 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 // @@ -68,13 +10,15 @@ #include "Tpm.h" #include "Marshal.h" +#include "tpm_library_intern.h" // libtpms added + //****************************************************************************/ //** Hash/HMAC Functions //****************************************************************************/ //*** CryptHmacSign() -// Sign a digest using an HMAC key. This an HMAC of a digest, not an HMAC of a -// message. +// Sign a digest using an HMAC key. This is an HMAC of a digest, not an HMAC of +// a message. // Return Type: TPM_RC // TPM_RC_HASH not a valid hash static TPM_RC CryptHmacSign(TPMT_SIGNATURE* signature, // OUT: signature @@ -92,13 +36,14 @@ static TPM_RC CryptHmacSign(TPMT_SIGNATURE* signature, // OUT: signature g_RuntimeProfile.stateFormatLevel)) return TPM_RC_KEY_SIZE; // libtpms added end - if (signature->sigAlg == TPM_ALG_HMAC) + if(signature->sigAlg == TPM_ALG_HMAC) { - digestSize = CryptHmacStart2B(&hmacState, - signature->signature.any.hashAlg, - &signKey->sensitive.sensitive.bits.b); + digestSize = CryptHmacStart2B(&hmacState, + signature->signature.any.hashAlg, + &signKey->sensitive.sensitive.bits.b); CryptDigestUpdate2B(&hmacState.hashState, &hashData->b); - CryptHmacEnd(&hmacState, digestSize, (BYTE*)&signature->signature.hmac.digest); + CryptHmacEnd( + &hmacState, digestSize, (BYTE*)&signature->signature.hmac.digest); return TPM_RC_SUCCESS; } return TPM_RC_SCHEME; @@ -225,7 +170,7 @@ static TPM_RC CryptGenerateKeyedHash( sensitive->sensitive.bits.t.size = DRBG_Generate(rand, sensitive->sensitive.bits.t.buffer, digestSize); if(sensitive->sensitive.bits.t.size == 0) - return (g_inFailureMode) ? TPM_RC_FAILURE : TPM_RC_NO_RESULT; + return (_plat__InFailureMode()) ? TPM_RC_FAILURE : TPM_RC_NO_RESULT; } return TPM_RC_SUCCESS; } @@ -259,14 +204,14 @@ BOOL CryptIsSchemeAnonymous(TPM_ALG_ID scheme // IN: the scheme algorithm to te // bits the number of bits required for the symmetric key // plus an IV */ -void ParmDecryptSym(TPM_ALG_ID symAlg, // IN: the symmetric algorithm - TPM_ALG_ID hash, // IN: hash algorithm for KDFa - UINT16 keySizeInBits, // IN: the key size in bits - TPM2B* key, // IN: KDF HMAC key - TPM2B* nonceCaller, // IN: nonce caller - TPM2B* nonceTpm, // IN: nonce TPM - UINT32 dataSize, // IN: size of parameter buffer - BYTE* data // OUT: buffer to be decrypted +TPM_RC ParmDecryptSym(TPM_ALG_ID symAlg, // IN: the symmetric algorithm + TPM_ALG_ID hash, // IN: hash algorithm for KDFa + UINT16 keySizeInBits, // IN: the key size in bits + TPM2B* key, // IN: KDF HMAC key + TPM2B* nonceCaller, // IN: nonce caller + TPM2B* nonceTpm, // IN: nonce TPM + UINT32 dataSize, // IN: size of parameter buffer + BYTE* data // OUT: buffer to be decrypted ) { // KDF output buffer @@ -293,16 +238,16 @@ void ParmDecryptSym(TPM_ALG_ID symAlg, // IN: the symmetric algorithm FALSE); MemoryCopy(iv.t.buffer, &symParmString[keySize], iv.t.size); - CryptSymmetricDecrypt(data, - symAlg, - keySizeInBits, - symParmString, - &iv, - TPM_ALG_CFB, - dataSize, - data); + return CryptSymmetricDecrypt(data, + symAlg, + keySizeInBits, + symParmString, + &iv, + TPM_ALG_CFB, + dataSize, + data); } - return; + return TPM_RC_SUCCESS; } //*** ParmEncryptSym() @@ -319,14 +264,14 @@ void ParmDecryptSym(TPM_ALG_ID symAlg, // IN: the symmetric algorithm // bits the number of bits required for the symmetric key // plus an IV */ -void ParmEncryptSym(TPM_ALG_ID symAlg, // IN: symmetric algorithm - TPM_ALG_ID hash, // IN: hash algorithm for KDFa - UINT16 keySizeInBits, // IN: symmetric key size in bits - TPM2B* key, // IN: KDF HMAC key - TPM2B* nonceCaller, // IN: nonce caller - TPM2B* nonceTpm, // IN: nonce TPM - UINT32 dataSize, // IN: size of parameter buffer - BYTE* data // OUT: buffer to be encrypted +TPM_RC ParmEncryptSym(TPM_ALG_ID symAlg, // IN: symmetric algorithm + TPM_ALG_ID hash, // IN: hash algorithm for KDFa + UINT16 keySizeInBits, // IN: symmetric key size in bits + TPM2B* key, // IN: KDF HMAC key + TPM2B* nonceCaller, // IN: nonce caller + TPM2B* nonceTpm, // IN: nonce TPM + UINT32 dataSize, // IN: size of parameter buffer + BYTE* data // OUT: buffer to be encrypted ) { // KDF output buffer @@ -354,16 +299,16 @@ void ParmEncryptSym(TPM_ALG_ID symAlg, // IN: symmetric algorithm FALSE); MemoryCopy(iv.t.buffer, &symParmString[keySize], iv.t.size); - CryptSymmetricEncrypt(data, - symAlg, - keySizeInBits, - symParmString, - &iv, - TPM_ALG_CFB, - dataSize, - data); + return CryptSymmetricEncrypt(data, + symAlg, + keySizeInBits, + symParmString, + &iv, + TPM_ALG_CFB, + dataSize, + data); } - return; + return TPM_RC_SUCCESS; } //*** CryptGenerateKeySymmetric() @@ -408,7 +353,7 @@ static TPM_RC CryptGenerateKeySymmetric( { sensitive->sensitive.sym.t.size = DRBG_Generate( rand, sensitive->sensitive.sym.t.buffer, BITS_TO_BYTES(keyBits)); - if(g_inFailureMode) + if(_plat__InFailureMode()) result = TPM_RC_FAILURE; else if(sensitive->sensitive.sym.t.size == 0) result = TPM_RC_NO_RESULT; @@ -420,14 +365,13 @@ static TPM_RC CryptGenerateKeySymmetric( //*** CryptXORObfuscation() // This function implements XOR obfuscation. It should not be called if the -// hash algorithm is not implemented. The only return value from this function -// is TPM_RC_SUCCESS. -void CryptXORObfuscation(TPM_ALG_ID hash, // IN: hash algorithm for KDF - TPM2B* key, // IN: KDF key - TPM2B* contextU, // IN: contextU - TPM2B* contextV, // IN: contextV - UINT32 dataSize, // IN: size of data buffer - BYTE* data // IN/OUT: data to be XORed in place +// hash algorithm is not implemented. +TPM_RC CryptXORObfuscation(TPM_ALG_ID hash, // IN: hash algorithm for KDF + TPM2B* key, // IN: KDF key + TPM2B* contextU, // IN: contextU + TPM2B* contextV, // IN: contextV + UINT32 dataSize, // IN: size of data buffer + BYTE* data // IN/OUT: data to be XORed in place ) { BYTE mask[MAX_DIGEST_SIZE]; // Allocate a digest sized buffer @@ -438,7 +382,7 @@ void CryptXORObfuscation(TPM_ALG_ID hash, // IN: hash algorithm for KDF UINT32 requestSize = dataSize * 8; INT32 remainBytes = (INT32)dataSize; - pAssert((key != NULL) && (data != NULL) && (hLen != 0)); + pAssert_RC((key != NULL) && (data != NULL) && (hLen != 0)); // Call KDFa to generate XOR mask for(; remainBytes > 0; remainBytes -= hLen) @@ -459,7 +403,7 @@ void CryptXORObfuscation(TPM_ALG_ID hash, // IN: hash algorithm for KDF for(i = hLen < remainBytes ? hLen : remainBytes; i > 0; i--) *data++ ^= *pm++; } - return; + return TPM_RC_SUCCESS; } //**************************************************************************** @@ -872,12 +816,15 @@ CryptSecretDecrypt(OBJECT* decryptKey, // IN: decrypt key // nonceCaller the parameter from the TPM2_StartAuthHMAC command // nullNonce a zero-length nonce // XOR Obfuscation in place - CryptXORObfuscation(decryptKey->publicArea.nameAlg, - &decryptKey->sensitive.sensitive.bits.b, - &nonceCaller->b, - NULL, - secret->t.size, - secret->t.secret); + result = CryptXORObfuscation(decryptKey->publicArea.nameAlg, + &decryptKey->sensitive.sensitive.bits.b, + &nonceCaller->b, + NULL, + secret->t.size, + secret->t.secret); + if(result != TPM_RC_SUCCESS) + return result; + // Copy decrypted seed MemoryCopy2B(&data->b, &secret->b, sizeof(data->t.buffer)); } @@ -933,7 +880,7 @@ CryptSecretDecrypt(OBJECT* decryptKey, // IN: decrypt key //*** CryptParameterEncryption() // This function does in-place encryption of a response parameter. -void CryptParameterEncryption( +TPM_RC CryptParameterEncryption( TPM_HANDLE handle, // IN: encrypt session handle TPM2B* nonceCaller, // IN: nonce caller INT32 bufferSize, // IN: size of parameter buffer @@ -945,6 +892,8 @@ void CryptParameterEncryption( ) { SESSION* session = SessionGet(handle); // encrypt session + pAssert_RC(session); + TPM2B_TYPE(TEMP_KEY, (sizeof(extraKey->t.buffer) + sizeof(session->sessionKey.t.buffer))); TPM2B_TEMP_KEY key; // encryption key @@ -952,54 +901,54 @@ void CryptParameterEncryption( if(bufferSize < leadingSizeInByte) { - FAIL(FATAL_ERROR_INTERNAL); - return; + FAIL_RC(FATAL_ERROR_INTERNAL); } // Parameter encryption for a non-2B is not supported. if(leadingSizeInByte != 2) { - FAIL(FATAL_ERROR_INTERNAL); - return; + FAIL_RC(FATAL_ERROR_INTERNAL); } // Retrieve encrypted data size. if(UINT16_Unmarshal(&cipherSize, &buffer, &bufferSize) != TPM_RC_SUCCESS) { - FAIL(FATAL_ERROR_INTERNAL); - return; + FAIL_RC(FATAL_ERROR_INTERNAL); } if(cipherSize > bufferSize) { - FAIL(FATAL_ERROR_INTERNAL); - return; + FAIL_RC(FATAL_ERROR_INTERNAL); } // Compute encryption key by concatenating sessionKey with extra key MemoryCopy2B(&key.b, &session->sessionKey.b, sizeof(key.t.buffer)); MemoryConcat2B(&key.b, &extraKey->b, sizeof(key.t.buffer)); + TPM_RC result; if(session->symmetric.algorithm == TPM_ALG_XOR) - + { // XOR parameter encryption formulation: // XOR(parameter, hash, sessionAuth, nonceNewer, nonceOlder) - CryptXORObfuscation(session->authHashAlg, - &(key.b), - &(session->nonceTPM.b), - nonceCaller, - (UINT32)cipherSize, - buffer); + result = CryptXORObfuscation(session->authHashAlg, + &(key.b), + &(session->nonceTPM.b), + nonceCaller, + (UINT32)cipherSize, + buffer); + } else - ParmEncryptSym(session->symmetric.algorithm, - session->authHashAlg, - session->symmetric.keyBits.aes, - &(key.b), - nonceCaller, - &(session->nonceTPM.b), - (UINT32)cipherSize, - buffer); - return; + { + result = ParmEncryptSym(session->symmetric.algorithm, + session->authHashAlg, + session->symmetric.keyBits.aes, + &(key.b), + nonceCaller, + &(session->nonceTPM.b), + (UINT32)cipherSize, + buffer); + } + return result; } //*** CryptParameterDecryption() @@ -1019,6 +968,8 @@ CryptParameterDecryption( ) { SESSION* session = SessionGet(handle); // encrypt session + pAssert_RC(session); + // The HMAC key is going to be the concatenation of the session key and any // additional key material (like the authValue). The size of both of these // is the size of the buffer which can contain a TPMT_HA. @@ -1036,6 +987,7 @@ CryptParameterDecryption( if(leadingSizeInByte != 2) { FAIL_RC(FATAL_ERROR_INTERNAL); + return TPM_RC_SIZE; } // Retrieve encrypted data size. @@ -1044,7 +996,8 @@ CryptParameterDecryption( return TPM_RC_INSUFFICIENT; } - if(cipherSize > bufferSize) + if(cipherSize > MAX_COMMAND_SIZE || bufferSize <= 0 + || (UINT32)cipherSize > (UINT32)bufferSize) { return TPM_RC_SIZE; } @@ -1053,28 +1006,33 @@ CryptParameterDecryption( MemoryCopy2B(&key.b, &session->sessionKey.b, sizeof(key.t.buffer)); MemoryConcat2B(&key.b, &extraKey->b, sizeof(key.t.buffer)); + TPM_RC result; if(session->symmetric.algorithm == TPM_ALG_XOR) + { // XOR parameter decryption formulation: // XOR(parameter, hash, sessionAuth, nonceNewer, nonceOlder) // Call XOR obfuscation function - CryptXORObfuscation(session->authHashAlg, - &key.b, - nonceCaller, - &(session->nonceTPM.b), - (UINT32)cipherSize, - buffer); + result = CryptXORObfuscation(session->authHashAlg, + &key.b, + nonceCaller, + &(session->nonceTPM.b), + (UINT32)cipherSize, + buffer); + } else + { // Assume that it is one of the symmetric block ciphers. - ParmDecryptSym(session->symmetric.algorithm, - session->authHashAlg, - session->symmetric.keyBits.sym, - &key.b, - nonceCaller, - &session->nonceTPM.b, - (UINT32)cipherSize, - buffer); + result = ParmDecryptSym(session->symmetric.algorithm, + session->authHashAlg, + session->symmetric.keyBits.sym, + &key.b, + nonceCaller, + &session->nonceTPM.b, + (UINT32)cipherSize, + buffer); + } - return TPM_RC_SUCCESS; + return result; } //*** CryptComputeSymmetricUnique() @@ -1209,12 +1167,14 @@ CryptCreateObject(OBJECT* object, // IN: new object structure po DRBG_AdditionalData((DRBG_STATE*)rand, &gp.shProof.b); DRBG_AdditionalData((DRBG_STATE*)rand, &gp.ehProof.b); } + VERIFY_NOT_FAILED(); + // Generate a seedValue that is the size of the digest produced by nameAlg sensitive->seedValue.t.size = DRBG_Generate(rand, sensitive->seedValue.t.buffer, CryptHashGetDigestSize(publicArea->nameAlg)); - if(g_inFailureMode) + if(_plat__InFailureMode()) return TPM_RC_FAILURE; else if(sensitive->seedValue.t.size == 0) return TPM_RC_NO_RESULT; @@ -1316,7 +1276,8 @@ BOOL CryptIsSplitSign(TPM_ALG_ID scheme // IN: the algorithm selector } //*** CryptIsAsymSignScheme() -// This function indicates if a scheme algorithm is a sign algorithm. +// This function indicates if a scheme algorithm is a sign algorithm valid for the +// public key type. BOOL CryptIsAsymSignScheme(TPMI_ALG_PUBLIC publicType, // IN: Type of the object TPMI_ALG_ASYM_SCHEME scheme // IN: the scheme ) @@ -1350,7 +1311,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: @@ -1379,8 +1339,9 @@ BOOL CryptIsAsymSignScheme(TPMI_ALG_PUBLIC publicType, // IN: Type of the // This function checks that a signing scheme is valid. This includes verifying // that the scheme signing algorithm is compatible with the signing object type // and that the scheme specifies a valid hash algorithm. -static BOOL CryptIsValidSignScheme(TPMI_ALG_PUBLIC publicType, // IN: Type of the object - TPMT_SIG_SCHEME* scheme // IN: the signing scheme +static BOOL CryptIsValidSignScheme( + TPMI_ALG_PUBLIC publicType, // IN: Type of the object + TPMT_SIG_SCHEME* scheme // IN: the signing scheme ) { BOOL isValidSignScheme = TRUE; @@ -1388,27 +1349,27 @@ static BOOL CryptIsValidSignScheme(TPMI_ALG_PUBLIC publicType, // IN: Type of switch(publicType) { #if ALG_RSA - case TPM_ALG_RSA: - isValidSignScheme = CryptIsAsymSignScheme(publicType, scheme->scheme); - break; + case TPM_ALG_RSA: + isValidSignScheme = CryptIsAsymSignScheme(publicType, scheme->scheme); + break; #endif // ALG_RSA #if ALG_ECC - case TPM_ALG_ECC: - isValidSignScheme = CryptIsAsymSignScheme(publicType, scheme->scheme); - break; + case TPM_ALG_ECC: + isValidSignScheme = CryptIsAsymSignScheme(publicType, scheme->scheme); + break; #endif // ALG_ECC - case TPM_ALG_KEYEDHASH: - if(scheme->scheme != TPM_ALG_HMAC) - { - isValidSignScheme = FALSE; - } - break; + case TPM_ALG_KEYEDHASH: + if(scheme->scheme != TPM_ALG_HMAC) + { + isValidSignScheme = FALSE; + } + break; - default: - isValidSignScheme = FALSE; - break; + default: + isValidSignScheme = FALSE; + break; } // Ensure that a valid hash algorithm is specified. Pass 'flag' = FALSE to @@ -1422,7 +1383,7 @@ static BOOL CryptIsValidSignScheme(TPMI_ALG_PUBLIC publicType, // IN: Type of // hash algorithm IDs are the same for all signature scheme types.) if(!CryptHashIsValidAlg(scheme->details.any.hashAlg, /* flag = */ FALSE)) { - isValidSignScheme = FALSE; + isValidSignScheme = FALSE; } return isValidSignScheme; @@ -1483,12 +1444,14 @@ BOOL CryptIsAsymDecryptScheme(TPMI_ALG_PUBLIC publicType, // IN: Type of the ob //*** CryptSelectSignScheme() // This function is used by the attestation and signing commands. It implements -// the rules for selecting the signature scheme to use in signing. This function -// requires that the signing key either be TPM_RH_NULL or be loaded. +// the rules for selecting the signature scheme to use in signing and validates +// that the selected scheme is compatible with the key type. It also ensures +// the selected scheme specifies a valid hash algorithm. This function requires +// that the signing key either be TPM_RH_NULL or be loaded. // // If a default scheme is defined in object, the default scheme should be chosen, // otherwise, the input scheme should be chosen. -// In the case that both object and input scheme has a non-NULL scheme +// In the case that both object and input scheme have a non-NULL scheme // algorithm, if the schemes are compatible, the input scheme will be chosen. // // This function should not be called if 'signObject->publicArea.type' == @@ -1499,7 +1462,9 @@ BOOL CryptIsAsymDecryptScheme(TPMI_ALG_PUBLIC publicType, // IN: Type of the ob // FALSE(0) both 'scheme' and key's default scheme are empty; or // 'scheme' is empty while key's default scheme requires // explicit input scheme (split signing); or -// non-empty default key scheme differs from 'scheme' +// non-empty default key scheme differs from 'scheme'; or +// 'scheme' not valid for key type; or invalid hash +// algorithm specified; or key type is ALG_SYMCIPHER BOOL CryptSelectSignScheme(OBJECT* signObject, // IN: signing key TPMT_SIG_SCHEME* scheme // IN/OUT: signing scheme ) @@ -1524,13 +1489,13 @@ BOOL CryptSelectSignScheme(OBJECT* signObject, // IN: signing key // Get a pointer to the scheme object. if(CryptIsAsymAlgorithm(publicArea->type)) { - objectScheme = - (TPMT_SIG_SCHEME*)&publicArea->parameters.asymDetail.scheme; + objectScheme = + (TPMT_SIG_SCHEME*)&publicArea->parameters.asymDetail.scheme; } else if(publicArea->type == TPM_ALG_KEYEDHASH) { objectScheme = - (TPMT_SIG_SCHEME*)&publicArea->parameters.keyedHashDetail.scheme; + (TPMT_SIG_SCHEME*)&publicArea->parameters.keyedHashDetail.scheme; } else { @@ -1546,8 +1511,6 @@ BOOL CryptSelectSignScheme(OBJECT* signObject, // IN: signing key { // Input and default can't both be NULL OK = (scheme->scheme != TPM_ALG_NULL); - // Assume that the scheme is compatible with the key. If not, - // an error will be generated in the signing operation. } else if(scheme->scheme == TPM_ALG_NULL) { diff --git a/src/tpm2/Ticket.c b/src/tpm2/TPMCmd/tpm/src/crypt/Ticket.c similarity index 73% rename from src/tpm2/Ticket.c rename to src/tpm2/TPMCmd/tpm/src/crypt/Ticket.c index 6776841f4..f8f9d56e0 100644 --- a/src/tpm2/Ticket.c +++ b/src/tpm2/TPMCmd/tpm/src/crypt/Ticket.c @@ -1,62 +1,4 @@ -/********************************************************************************/ -/* */ -/* Functions used for ticket computations. */ -/* 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 /* diff --git a/src/tpm2/TpmEcc_Signature_ECDAA.c b/src/tpm2/TPMCmd/tpm/src/crypt/ecc/TpmEcc_Signature_ECDAA.c similarity index 53% rename from src/tpm2/TpmEcc_Signature_ECDAA.c rename to src/tpm2/TPMCmd/tpm/src/crypt/ecc/TpmEcc_Signature_ECDAA.c index 7e6fadfc9..dc13f3d36 100644 --- a/src/tpm2/TpmEcc_Signature_ECDAA.c +++ b/src/tpm2/TPMCmd/tpm/src/crypt/ecc/TpmEcc_Signature_ECDAA.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 #include "Tpm.h" #include "TpmEcc_Signature_ECDAA_fp.h" @@ -136,7 +78,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, diff --git a/src/tpm2/TpmEcc_Signature_SM2.c b/src/tpm2/TPMCmd/tpm/src/crypt/ecc/TpmEcc_Signature_SM2.c similarity index 58% rename from src/tpm2/TpmEcc_Signature_SM2.c rename to src/tpm2/TPMCmd/tpm/src/crypt/ecc/TpmEcc_Signature_SM2.c index d3ea93d77..1d6ddf1ae 100644 --- a/src/tpm2/TpmEcc_Signature_SM2.c +++ b/src/tpm2/TPMCmd/tpm/src/crypt/ecc/TpmEcc_Signature_SM2.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 #include "Tpm.h" #include "TpmEcc_Signature_SM2_fp.h" @@ -151,9 +93,9 @@ TPM_RC TpmEcc_SignEcSm2(Crypt_Int* bnR, // OUT: 'r' component of the signature ExtMath_Add(bnR, bnE, ExtEcc_PointX(Q1)); ExtMath_Mod(bnR, order); # ifdef _SM2_SIGN_DEBUG - pAssert(TpmEccDebug_HexEqual(bnR, - "40F1EC59F793D9F49E09DCEF49130D41" - "94F79FB1EED2CAA55BACDB49C4E755D1")); + pAssert_RC(TpmEccDebug_HexEqual(bnR, + "40F1EC59F793D9F49E09DCEF49130D41" + "94F79FB1EED2CAA55BACDB49C4E755D1")); # endif // if r=0 or r+k=n, return to A3; if(ExtMath_IsZero(bnR)) @@ -167,9 +109,9 @@ TPM_RC TpmEcc_SignEcSm2(Crypt_Int* bnR, // OUT: 'r' component of the signature ExtMath_AddWord(bnT, bnD, 1); ExtMath_ModInverse(bnT, bnT, order); # ifdef _SM2_SIGN_DEBUG - pAssert(TpmEccDebug_HexEqual(bnT, - "79BFCF3052C80DA7B939E0C6914A18CB" - "B2D96D8555256E83122743A7D4F5F956")); + pAssert_RC(TpmEccDebug_HexEqual(bnT, + "79BFCF3052C80DA7B939E0C6914A18CB" + "B2D96D8555256E83122743A7D4F5F956")); # endif // compute s = t * (k - r * dA) mod n ExtMath_ModMult(bnS, bnR, bnD, order); @@ -178,9 +120,9 @@ TPM_RC TpmEcc_SignEcSm2(Crypt_Int* bnR, // OUT: 'r' component of the signature ExtMath_Add(bnS, bnK, bnS); ExtMath_ModMult(bnS, bnS, bnT, order); # ifdef _SM2_SIGN_DEBUG - pAssert(TpmEccDebug_HexEqual(bnS, - "6FC6DAC32C5D5CF10C77DFB20F7C2EB6" - "67A457872FB09EC56327A67EC7DEEBE7")); + pAssert_RC(TpmEccDebug_HexEqual(bnS, + "6FC6DAC32C5D5CF10C77DFB20F7C2EB6" + "67A457872FB09EC56327A67EC7DEEBE7")); # endif if(ExtMath_IsZero(bnS)) goto loop; @@ -190,12 +132,12 @@ TPM_RC TpmEcc_SignEcSm2(Crypt_Int* bnR, // OUT: 'r' component of the signature // is (r, s). // This is handled by the common return code # ifdef _SM2_SIGN_DEBUG - pAssert(TpmEccDebug_HexEqual(bnR, - "40F1EC59F793D9F49E09DCEF49130D41" - "94F79FB1EED2CAA55BACDB49C4E755D1")); - pAssert(TpmEccDebug_HexEqual(bnS, - "6FC6DAC32C5D5CF10C77DFB20F7C2EB6" - "67A457872FB09EC56327A67EC7DEEBE7")); + pAssert_RC(TpmEccDebug_HexEqual(bnR, + "40F1EC59F793D9F49E09DCEF49130D41" + "94F79FB1EED2CAA55BACDB49C4E755D1")); + pAssert_RC(TpmEccDebug_HexEqual(bnS, + "6FC6DAC32C5D5CF10C77DFB20F7C2EB6" + "67A457872FB09EC56327A67EC7DEEBE7")); # endif return TPM_RC_SUCCESS; } @@ -227,20 +169,20 @@ TPM_RC TpmEcc_ValidateSignatureEcSm2( # ifdef _SM2_SIGN_DEBUG // Make sure that the input signature is the test signature - pAssert(TpmEccDebug_HexEqual(bnR, - "40F1EC59F793D9F49E09DCEF49130D41" - "94F79FB1EED2CAA55BACDB49C4E755D1")); - pAssert(TpmEccDebug_HexEqual(bnS, - "6FC6DAC32C5D5CF10C77DFB20F7C2EB6" - "67A457872FB09EC56327A67EC7DEEBE7")); + pAssert_RC(TpmEccDebug_HexEqual(bnR, + "40F1EC59F793D9F49E09DCEF49130D41" + "94F79FB1EED2CAA55BACDB49C4E755D1")); + pAssert_RC(TpmEccDebug_HexEqual(bnS, + "6FC6DAC32C5D5CF10C77DFB20F7C2EB6" + "67A457872FB09EC56327A67EC7DEEBE7")); # endif // b) compute t := (r + s) mod n ExtMath_Add(bnT, bnR, bnS); ExtMath_Mod(bnT, order); # ifdef _SM2_SIGN_DEBUG - pAssert(TpmEccDebug_HexEqual(bnT, - "2B75F07ED7ECE7CCC1C8986B991F441A" - "D324D6D619FE06DD63ED32E0C997C801")); + pAssert_RC(TpmEccDebug_HexEqual(bnT, + "2B75F07ED7ECE7CCC1C8986B991F441A" + "D324D6D619FE06DD63ED32E0C997C801")); # endif // c) verify that t > 0 OK = !ExtMath_IsZero(bnT); @@ -251,10 +193,10 @@ TPM_RC TpmEcc_ValidateSignatureEcSm2( // d) compute (x, y) := [s]G + [t]Q OK = ExtEcc_PointMultiplyAndAdd(P, NULL, bnS, ecQ, bnT, E); # ifdef _SM2_SIGN_DEBUG - pAssert(OK - && TpmEccDebug_HexEqual(ExtEcc_PointX(P), - "110FCDA57615705D5E7B9324AC4B856D" - "23E6D9188B2AE47759514657CE25D112")); + pAssert_RC(OK + && TpmEccDebug_HexEqual(ExtEcc_PointX(P), + "110FCDA57615705D5E7B9324AC4B856D" + "23E6D9188B2AE47759514657CE25D112")); # endif // e) compute r' := (e + x) mod n (the x coordinate is in bnT) OK = OK && ExtMath_Add(bnRp, bnE, ExtEcc_PointX(P)); diff --git a/src/tpm2/TpmEcc_Signature_Schnorr.c b/src/tpm2/TPMCmd/tpm/src/crypt/ecc/TpmEcc_Signature_Schnorr.c similarity index 64% rename from src/tpm2/TpmEcc_Signature_Schnorr.c rename to src/tpm2/TPMCmd/tpm/src/crypt/ecc/TpmEcc_Signature_Schnorr.c index 9c6733268..b310b5e3e 100644 --- a/src/tpm2/TpmEcc_Signature_Schnorr.c +++ b/src/tpm2/TPMCmd/tpm/src/crypt/ecc/TpmEcc_Signature_Schnorr.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 #include "Tpm.h" #include "TpmEcc_Signature_Schnorr_fp.h" @@ -148,7 +90,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))); diff --git a/src/tpm2/TPMCmd/tpm/src/crypt/ecc/TpmEcc_Signature_Util.c b/src/tpm2/TPMCmd/tpm/src/crypt/ecc/TpmEcc_Signature_Util.c new file mode 100644 index 000000000..10ed6c369 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/src/crypt/ecc/TpmEcc_Signature_Util.c @@ -0,0 +1,49 @@ +// SPDX-License-Identifier: BSD-2-Clause + +// functions shared by multiple signature algorithms +#include "Tpm.h" +#include "TpmEcc_Signature_Util_fp.h" +#include "TpmMath_Debug_fp.h" +#include "TpmMath_Util_fp.h" + +#if (ALG_ECC && (ALG_ECSCHNORR || ALG_ECDAA)) + +//*** TpmEcc_SchnorrCalculateS() +// This contains the Schnorr signature (S) computation. It is used by both ECDAA and +// Schnorr signing. The result is computed as: ['s' = 'k' + 'r' * 'd' (mod 'n')] +// where +// 1) 's' is the signature +// 2) 'k' is a random value +// 3) 'r' is the value to sign +// 4) 'd' is the private EC key +// 5) 'n' is the order of the curve +// Return Type: TPM_RC +// TPM_RC_NO_RESULT the result of the operation was zero or 'r' (mod 'n') +// is zero +TPM_RC TpmEcc_SchnorrCalculateS( + Crypt_Int* bnS, // OUT: 's' component of the signature + const Crypt_Int* bnK, // IN: a random value + Crypt_Int* bnR, // IN: the signature 'r' value + const Crypt_Int* bnD, // IN: the private key + const Crypt_Int* bnN // IN: the order of the curve +) +{ + // Need a local temp value to store the intermediate computation because product + // size can be larger than will fit in bnS. + CRYPT_INT_VAR(bnT1, MAX_ECC_PARAMETER_BYTES * 2 * 8); + // + // Reduce bnR without changing the input value + ExtMath_Divide(NULL, bnT1, bnR, bnN); + if(ExtMath_IsZero(bnT1)) + return TPM_RC_NO_RESULT; + // compute s = (k + r * d)(mod n) + // r * d + ExtMath_Multiply(bnT1, bnT1, bnD); + // k + r * d + ExtMath_Add(bnT1, bnT1, bnK); + // k + r * d (mod n) + ExtMath_Divide(NULL, bnS, bnT1, bnN); + return (ExtMath_IsZero(bnS)) ? TPM_RC_NO_RESULT : TPM_RC_SUCCESS; +} + +#endif // (ALG_ECC && (ALG_ECSCHNORR || ALG_ECDAA)) diff --git a/src/tpm2/TPMCmd/tpm/src/crypt/ecc/TpmEcc_Util.c b/src/tpm2/TPMCmd/tpm/src/crypt/ecc/TpmEcc_Util.c new file mode 100644 index 000000000..6e51eb5df --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/src/crypt/ecc/TpmEcc_Util.c @@ -0,0 +1,65 @@ +// SPDX-License-Identifier: BSD-2-Clause + +//** Introduction +// This file contains utility functions to help using the external Math library +// for Ecc functions. +#include "Tpm.h" +#include "TpmMath_Util_fp.h" +#include "TpmEcc_Util_fp.h" // libtpms added + +#if ALG_ECC + +//*** +// TpmEcc_PointFrom2B() Function to create a Crypt_Point structure from a 2B +// point. The target point is expected to have memory allocated and +// uninitialized. A TPMS_ECC_POINT is going to be two ECC values in the same +// buffer. The values are going to be the size of the modulus. They are in +// modular form. +// +// NOTE: This function considers both parameters optional because of use +// cases where points may not be specified in the calling function. If the +// initializer or point buffer is NULL, then NULL is returned. As a result, the +// only error detection when the initializer value is invalid is to return NULL +// in that error case as well. If a caller wants to handle that error case +// differently, then the caller must perform the correct validation before/after +// this function. +LIB_EXPORT Crypt_Point* TpmEcc_PointFrom2B( + Crypt_Point* ecP, // OUT: the preallocated point structure + TPMS_ECC_POINT* p // IN: the number to convert +) +{ + if(p == NULL) + return NULL; + + if(ecP != NULL) + { + return ExtEcc_PointFromBytes( + ecP, p->x.t.buffer, p->x.t.size, p->y.t.buffer, p->y.t.size); + } + return ecP; // will return NULL if ecP is NULL. +} + +//*** TpmEcc_PointTo2B() +// This function converts a BIG_POINT into a TPMS_ECC_POINT. A TPMS_ECC_POINT +// contains two TPM2B_ECC_PARAMETER values. The maximum size of the parameters +// is dependent on the maximum EC key size used in an implementation. +// The presumption is that the TPMS_ECC_POINT is large enough to hold 2 TPM2B +// values, each as large as a MAX_ECC_PARAMETER_BYTES +LIB_EXPORT BOOL TpmEcc_PointTo2B( + TPMS_ECC_POINT* p, // OUT: the converted 2B structure + const Crypt_Point* ecP, // IN: the values to be converted + const Crypt_EccCurve* E // IN: curve descriptor for the point +) +{ + pAssert_BOOL(p && ecP && E); + TPM_ECC_CURVE curveId = ExtEcc_CurveGetCurveId(E); + NUMBYTES size = CryptEccGetKeySizeForCurve(curveId); + size = (UINT16)BITS_TO_BYTES(size); + MemorySet(p, 0, sizeof(*p)); + p->x.t.size = size; + p->y.t.size = size; + return ExtEcc_PointToBytes( + ecP, p->x.t.buffer, &p->x.t.size, p->y.t.buffer, &p->y.t.size); +} + +#endif // ALG_ECC diff --git a/src/tpm2/TPMCmd/tpm/src/crypt/math/TpmMath_Debug.c b/src/tpm2/TPMCmd/tpm/src/crypt/math/TpmMath_Debug.c new file mode 100644 index 000000000..22ebe9583 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/src/crypt/math/TpmMath_Debug.c @@ -0,0 +1,114 @@ +// SPDX-License-Identifier: BSD-2-Clause + +//** Introduction +// This file contains debug utility functions to help testing Ecc. +#include "Tpm.h" +#include "TpmEcc_Util_fp.h" +#include "TpmMath_Debug_fp.h" + +#if ALG_SM2 +# ifdef _SM2_SIGN_DEBUG + +//*** SafeGetStringLength() +// self-implemented version of strnlen_s. This is necessary because +// some environments don't have a C-runtime library, or are limited to +// C99, and strnlen_s was standardized in C11. +static size_t SafeGetStringLength(const char* string, size_t maxsize) +{ + // strnlen_s has two boundary conditions: + // return 0 if pointer is nullptr, or + // maxsize if no null character is found. + if(string == NULL) + return 0; + + const char* pos = string; + size_t size = 0; + + while(*pos != '\0' && size < maxsize) + { + pos++; + size++; + } + return size; +} + +// convert from hex value. If invalid, result will be out of range. +static LIB_EXPORT BYTE FromHex(unsigned char c) +{ + // hack for the ASCII characters we care about + BYTE upper = (c & (~0x20)); + if(c >= '0' && c <= '9') + return c - '0'; + else if(c >= 'A' && c <= 'F') + return c - 'A'; + else if(c >= 'a' && c <= 'f') + return c - 'a'; + + return 255; +} + +//*** TpmEccDebug_FromHex() +// Convert a hex string into a Crypt_Int*. This is primarily used in debugging. +LIB_EXPORT Crypt_Int* TpmEccDebug_FromHex( + Crypt_Int* bn, // OUT: + const unsigned char* hex, // IN: + size_t maxsizeHex // IN: maximum size of hex +) +{ + // if value is larger than this, then fail + BYTE tempBuf[MAX_ECC_KEY_BYTES]; + MemorySet(tempBuf, 0, sizeof(tempBuf)); + ExtMath_SetWord(bn, 0); + + size_t len = SafeGetStringLength(hex, maxsizeHex); + BOOL OK = FALSE; + if((len % 2) == 0) + { + OK = TRUE; + for(size_t i = 0; i < len; i += 2) + { + BYTE highNibble = FromHex(*hex); + hex++; + BYTE lowNibble = FromHex(*hex); + hex++; + // unsigned, no need to check zero + if(highNibble > 15 || lowNibble > 15) + { + OK = FALSE; + break; + } + BYTE b = ((highNibble << 4) | lowNibble); + tempBuf[i / 2] = b; + } + if(OK) + { + ExtMath_IntFromBytes(bn, tempBuf, (NUMBYTES)(len / 2)); + } + } + + if(!OK) + { + // this should only be called in testing, so any + // errors are fatal. + FAIL(FATAL_ERROR_INTERNAL); + } + return bn; +} + +//*** TpmEccDebug_HexEqual() +// This function compares a bignum value to a hex string. +// using TpmEcc namespace because code assumes the max size +// is correct for ECC. +// Return Type: BOOL +// TRUE(1) values equal +// FALSE(0) values not equal +BOOL TpmEccDebug_HexEqual(const Crypt_Int* bn, //IN: big number value + const char* c //IN: character string number +) +{ + CRYPT_ECC_NUM(bnC); + TpmEccDebug_FromHex(bnC, c, MAX_ECC_KEY_BYTES * 2 + 1); + return (ExtMath_UnsignedCmp(bn, bnC) == 0); +} +# endif // _SM2_SIGN_DEBUG +#endif // ALG_SM2 diff --git a/src/tpm2/TpmMath_Util.c b/src/tpm2/TPMCmd/tpm/src/crypt/math/TpmMath_Util.c similarity index 68% rename from src/tpm2/TpmMath_Util.c rename to src/tpm2/TPMCmd/tpm/src/crypt/math/TpmMath_Util.c index 6be39d2b9..5fc2f3e3f 100644 --- a/src/tpm2/TpmMath_Util.c +++ b/src/tpm2/TPMCmd/tpm/src/crypt/math/TpmMath_Util.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 // This file contains utility functions to help using the external Math library @@ -163,9 +105,9 @@ LIB_EXPORT BOOL TpmMath_GetRandomBits(BYTE* pBuffer, size_t bits, RAND_STATE* ra // 2 0x03 6 = (8 - 2) % 8 // ... etc ... // 7 0x7F 1 = (8 - 7) % 8 - int excessBits = bits % 8; - static const BYTE mask[8] = {0xff, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f}; // libtpms changed: fix - pBuffer[0] &= mask[excessBits]; // libtpms changed: fix + static const BYTE mask[8] = {0xff, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f}; + int excessBits = bits % 8; + pBuffer[0] = pBuffer[0] & mask[excessBits]; return TRUE; } return FALSE; @@ -230,5 +172,5 @@ LIB_EXPORT BOOL TpmMath_GetRandomInRange( && (ExtMath_IsZero(dest) || (ExtMath_UnsignedCmp(dest, limit) >= 0))) ; } - return !g_inFailureMode; + return !_plat__InFailureMode(); } diff --git a/src/tpm2/TPMCmd/tpm/src/events/_TPM_Init.c b/src/tpm2/TPMCmd/tpm/src/events/_TPM_Init.c new file mode 100644 index 000000000..4f933744b --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/src/events/_TPM_Init.c @@ -0,0 +1,110 @@ +// SPDX-License-Identifier: BSD-2-Clause + +#include +// TODO_RENAME_INC_FOLDER:platform_interface refers to the TPM_CoreLib platform interface +#include +#include "StateMarshal.h" // libtpms added + +// Move this to a future _plat_NvUpdateData() API and perform this in +// platform code. +static void UpgradeNvData() // libtpms changed: static +{ + // only update when required to avoid unnecessary flash defragmentation + if(gp.firmwareV1 != _plat__GetTpmFirmwareVersionHigh() + || gp.firmwareV2 != _plat__GetTpmFirmwareVersionLow()) + { + gp.firmwareV1 = _plat__GetTpmFirmwareVersionHigh(); + gp.firmwareV2 = _plat__GetTpmFirmwareVersionLow(); + NV_SYNC_PERSISTENT(firmwareV1); + NV_SYNC_PERSISTENT(firmwareV2); + } +} + +// This function is used to process a _TPM_Init indication. +LIB_EXPORT void _TPM_Init(void) +{ + BOOL restored = FALSE; /* libtpms added */ + _plat__StartTpmInit(); + g_powerWasLost = g_powerWasLost | _plat__WasPowerLost(); + +#if SIMULATION && DEBUG + // If power was lost and this was a simulation, put canary in RAM used by NV + // so that uninitialized memory can be detected more easily + if(g_powerWasLost) + { + memset(&gc, 0xbb, sizeof(gc)); + memset(&gr, 0xbb, sizeof(gr)); + memset(&gp, 0xbb, sizeof(gp)); + memset(&go, 0xbb, sizeof(go)); + } +#endif + +#if ALLOW_FORCE_FAILURE_MODE + // Clear the flag that forces failure on self-test + g_forceFailureMode = FALSE; +#endif + + // Disable the tick processing +#if ACT_SUPPORT || 1 // libtpms: changed + _plat__ACT_EnableTicks(FALSE); +#endif + + // Set initialization state + TPMInit(); + + // Set g_DRTMHandle as unassigned + g_DRTMHandle = TPM_RH_UNASSIGNED; + + // No H-CRTM, yet. + g_DrtmPreStartup = FALSE; + + // Initialize the NvEnvironment. + g_nvOk = NvPowerOn(); + + // Initialize cryptographic functions + +#if 0 // libtpms added + // libtpms: FAIL would do longjmp, but there was no setjmp + if(g_nvOk != TRUE) + { + FAIL(FATAL_ERROR_NV_INIT); + } + else if(!CryptInit()) + { + FAIL(FATAL_ERROR_CRYPTO_INIT); + } +#else // libtpms added begin + BOOL inFailureMode = (g_nvOk == FALSE) || (CryptInit() == FALSE); + if (inFailureMode) + _plat__SetInFailureMode(TRUE); +#endif // libtpms added end + + if(!_plat__InFailureMode()) + { + // Load the persistent data + NvReadPersistent(); + + // Load the orderly data (clock and DRBG state). + // If this is not done here, things break + NvRead(&go, NV_ORDERLY_DATA, sizeof(go)); + + // Update and fix up any NV variables + UpgradeNvData(); + + // Start clock. Need to do this after NV has been restored. + TimePowerOn(); + /* libtpms added begin */ + VolatileLoad(&restored); + if (restored) + NVShadowRestore(); + /* libtpms added end */ + } + + g_initCompleted = TRUE; + if(! _plat__InFailureMode()) + { + _plat__EndOkTpmInit(); + } + + return; +} diff --git a/src/tpm2/CommandDispatcher.c b/src/tpm2/TPMCmd/tpm/src/main/CommandDispatcher.c similarity index 72% rename from src/tpm2/CommandDispatcher.c rename to src/tpm2/TPMCmd/tpm/src/main/CommandDispatcher.c index 435bbe601..993fdf932 100644 --- a/src/tpm2/CommandDispatcher.c +++ b/src/tpm2/TPMCmd/tpm/src/main/CommandDispatcher.c @@ -1,71 +1,10 @@ -/********************************************************************************/ -/* */ -/* Command Dispatcher */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: CommandDispatcher.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, 2016 - 2021 */ -/* */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause //* Includes and Typedefs #include "Tpm.h" #include "Marshal.h" -#if TABLE_DRIVEN_DISPATCH || TABLE_DRIVEN_MARSHAL - typedef TPM_RC(NoFlagFunction)(void* target, BYTE** buffer, INT32* size); typedef TPM_RC(FlagFunction)(void* target, BYTE** buffer, INT32* size, BOOL flag); @@ -150,23 +89,13 @@ typedef struct COMMAND_DESCRIPTOR_t // The types list is constructed with a byte of 0xff at the end of the command // parameters and with an 0xff at the end of the response parameters. -# if COMPRESSED_LISTS +# if COMPRESSED_LISTS // libtpms added begin # define PAD_LIST 0 # else # define PAD_LIST 1 -# endif -# define _COMMAND_TABLE_DISPATCH_ -# include "CommandDispatchData.h" - -# define TEST_COMMAND TPM_CC_Startup - -# define NEW_CC - -#else - -# include "Commands.h" - -#endif +# endif // libtpms added end +#define _COMMAND_TABLE_DISPATCH_ +#include "CommandDispatchData.h" //* Marshal/Unmarshal Functions @@ -175,25 +104,22 @@ typedef struct COMMAND_DESCRIPTOR_t TPM_RC ParseHandleBuffer(COMMAND* command) { - TPM_RC result; -#if TABLE_DRIVEN_DISPATCH || TABLE_DRIVEN_MARSHAL + TPM_RC result; COMMAND_DESCRIPTOR_t* desc; BYTE* types; BYTE type; BYTE dType; // Make sure that nothing strange has happened - pAssert( + pAssert_RC( command->index < sizeof(s_CommandDataArray) / sizeof(COMMAND_DESCRIPTOR_t*)); // Get the address of the descriptor for this command desc = s_CommandDataArray[command->index]; - pAssert(desc != NULL); + pAssert_RC(desc != NULL); // Get the associated list of unmarshaling data types. types = &((BYTE*)desc)[desc->typesOffset]; - // if(s_ccAttr[commandIndex].commandIndex == TEST_COMMAND) - // commandIndex = commandIndex; // No handles yet command->handleNum = 0; @@ -205,7 +131,7 @@ ParseHandleBuffer(COMMAND* command) // get the next type type = *types++) { -# if TABLE_DRIVEN_MARSHAL +#if TABLE_DRIVEN_MARSHAL marshalIndex_t index; index = unmarshalArray[dType] | ((type & 0x80) ? NULL_FLAG : 0); result = Unmarshal(index, @@ -213,7 +139,7 @@ ParseHandleBuffer(COMMAND* command) &command->parameterBuffer, &command->parameterSize); -# else +#else // See if unmarshaling of this handle type requires a flag if(dType < HANDLE_FIRST_FLAG_TYPE) { @@ -235,7 +161,7 @@ ParseHandleBuffer(COMMAND* command) &command->parameterSize, (type & 0x80) != 0); } -# endif +#endif // Got a handle // We do this first so that the match for the handle offset of the @@ -246,21 +172,6 @@ ParseHandleBuffer(COMMAND* command) // handle indication set return result + TPM_RC_H + (command->handleNum * TPM_RC_1); } -#else - BYTE** handleBufferStart = &command->parameterBuffer; - INT32* bufferRemainingSize = &command->parameterSize; - TPM_HANDLE* handles = &command->handles[0]; - UINT32* handleCount = &command->handleNum; - *handleCount = 0; - switch(command->code) - { -# include "HandleProcess.h" -# undef handles - default: - FAIL(FATAL_ERROR_INTERNAL); - break; - } -#endif return TPM_RC_SUCCESS; } @@ -270,33 +181,6 @@ ParseHandleBuffer(COMMAND* command) TPM_RC CommandDispatcher(COMMAND* command) { -#if !TABLE_DRIVEN_DISPATCH || TABLE_DRIVEN_MARSHAL - TPM_RC result; - BYTE** paramBuffer = &command->parameterBuffer; - INT32* paramBufferSize = &command->parameterSize; - BYTE** responseBuffer = &command->responseBuffer; - INT32* respParmSize = &command->parameterSize; - INT32 rSize; - TPM_HANDLE* handles = &command->handles[0]; - // - command->handleNum = 0; // The command-specific code knows how - // many handles there are. This is for - // cataloging the number of response - // handles - MemoryIoBufferAllocationReset(); // Initialize so that allocation will - // work properly - switch(GetCommandCode(command->index)) - { -# include "CommandDispatcher.h" - - default: - FAIL(FATAL_ERROR_INTERNAL); - break; - } -Exit: - MemoryIoBufferZero(); - return result; -#else COMMAND_DESCRIPTOR_t* desc; BYTE* types; BYTE type; @@ -315,12 +199,12 @@ CommandDispatcher(COMMAND* command) TPM_RC result; // // Get the address of the descriptor for this command - pAssert( + pAssert_RC( command->index < sizeof(s_CommandDataArray) / sizeof(COMMAND_DESCRIPTOR_t*)); desc = s_CommandDataArray[command->index]; // Get the list of parameter types for this command - pAssert(desc != NULL); + pAssert_RC(desc != NULL); types = &((BYTE*)desc)[desc->typesOffset]; // Get a pointer to the list of parameter offsets @@ -339,6 +223,11 @@ CommandDispatcher(COMMAND* command) // And the output parameters commandOut = (BYTE*)MemoryGetOutBuffer((UINT32)maxOutSize); + if(commandIn == NULL || commandOut == NULL) + { + return TPM_RC_FAILURE; + } + // Get the address of the action code dispatch cmd = desc->command; @@ -366,7 +255,7 @@ CommandDispatcher(COMMAND* command) for(; (dType = (type & 0x7F)) <= PARAMETER_LAST_TYPE; type = *types++) { pNum++; -# if TABLE_DRIVEN_MARSHAL +#if TABLE_DRIVEN_MARSHAL { marshalIndex_t index = unmarshalArray[dType]; index |= (type & 0x80) ? NULL_FLAG : 0; @@ -375,7 +264,7 @@ CommandDispatcher(COMMAND* command) &command->parameterBuffer, &command->parameterSize); } -# else +#else if(dType < PARAMETER_FIRST_FLAG_TYPE) { NoFlagFunction* f = (NoFlagFunction*)unmarshalArray[dType]; @@ -391,7 +280,7 @@ CommandDispatcher(COMMAND* command) &command->parameterSize, (type & 0x80) != 0); } -# endif +#endif if(result != TPM_RC_SUCCESS) { result += TPM_RC_P + (TPM_RC_1 * pNum); @@ -461,24 +350,24 @@ CommandDispatcher(COMMAND* command) // no pointers to data, all of the data being returned has to be in the // command action output buffer. If we try to marshal more bytes than // could fit into the output buffer, we need to fail. - for(; (dType = (type & 0x7F)) <= RESPONSE_PARAMETER_LAST_TYPE && !g_inFailureMode; + for(; (dType = (type & 0x7F)) <= RESPONSE_PARAMETER_LAST_TYPE + && !_plat__InFailureMode(); type = *types++) { -# if TABLE_DRIVEN_MARSHAL +#if TABLE_DRIVEN_MARSHAL marshalIndex_t index = marshalArray[dType]; command->parameterSize += Marshal( index, &commandOut[offset], &command->responseBuffer, &maxOutSize); -# else +#else const MARSHAL_t f = marshalArray[dType]; command->parameterSize += f(&commandOut[offset], &command->responseBuffer, &maxOutSize); -# endif +#endif offset = *offsets++; } result = (maxOutSize < 0) ? TPM_RC_FAILURE : TPM_RC_SUCCESS; Exit: MemoryIoBufferZero(); return result; -#endif } diff --git a/src/tpm2/ExecCommand.c b/src/tpm2/TPMCmd/tpm/src/main/ExecCommand.c similarity index 64% rename from src/tpm2/ExecCommand.c rename to src/tpm2/TPMCmd/tpm/src/main/ExecCommand.c index 069f3e3a1..51a43ca0e 100644 --- a/src/tpm2/ExecCommand.c +++ b/src/tpm2/TPMCmd/tpm/src/main/ExecCommand.c @@ -1,62 +1,4 @@ -/********************************************************************************/ -/* */ -/* ExecCommand */ -/* 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 // @@ -68,7 +10,7 @@ #include "Tpm.h" #include "Marshal.h" // TODO_RENAME_INC_FOLDER:platform_interface refers to the TPM_CoreLib platform interface -#include "ExecCommand_fp.h" // libtpms changed +#include // Uncomment this next #include if doing static command/response buffer sizing // #include "CommandResponseSizes_fp.h" @@ -108,11 +50,9 @@ // // 'request' and 'response' may point to the same buffer // -// Note: As of February, 2016, the failure processing has been moved to the +// Note: The failure processing has been moved to the // platform-specific code. When the TPM code encounters an unrecoverable failure, it -// will SET g_inFailureMode and call _plat__Fail(). That function should not return -// but may call ExecuteCommand(). -// +// will call _plat__Fail() and call _plat__InFailureMode() to query failure mode. LIB_EXPORT void ExecuteCommand( uint32_t requestSize, // IN: command buffer size unsigned char* request, // IN: command buffer @@ -139,13 +79,25 @@ LIB_EXPORT void ExecuteCommand( // the sizes do not include the tag, command.code, requestSize, or the authorization // fields. //CommandResponseSizes(); + // Set flags for NV access state. This should happen before any other // operation that may require a NV write. Note, that this needs to be done // even when in failure mode. Otherwise, g_updateNV would stay SET while in // Failure mode and the NV would be written on each call. g_updateNV = UT_NONE; g_clearOrderly = FALSE; - if(g_inFailureMode) + + if(!g_initCompleted) + { + // no return because failure will happen immediately below. this is + // treated as fatal because it is a system level failure for there to be + // no TPM_INIT indication. Since init is an out-of-band indication from + // Execute command, we don't return TPM_RC_INITIALIZE which refers to + // the TPM2_Startup command + FAIL_NORET(FATAL_ERROR_NO_INIT); + } + + if(_plat__InFailureMode()) { // Do failure mode processing TpmFailureMode(requestSize, request, responseSize, response); @@ -159,11 +111,9 @@ LIB_EXPORT void ExecuteCommand( // will go into failure mode. NvCheckState(); - // Due to the limitations of the simulation, TPM clock must be explicitly - // synchronized with the system clock whenever a command is received. - // This function call is not necessary in a hardware TPM. However, taking - // a snapshot of the hardware timer at the beginning of the command allows - // the time value to be consistent for the duration of the command execution. + // Taking a snapshot of the hardware timer at the beginning of the command + // allows the time value to be consistent for the duration of the command + // execution. This will also update the NV time state if appropriate. TimeUpdateToCurrent(); // Any command through this function will unceremoniously end the @@ -212,6 +162,17 @@ LIB_EXPORT void ExecuteCommand( result = TPM_RC_COMMAND_CODE; goto Cleanup; } +#if CC_ReadOnlyControl + // Check if the TPM is operating in Read-Only mode. If so, reject commands + // that are disallowed in this mode before performing any further auth checks. + // The execution of some commands may still be disallowed under certain conditions, + // but those will be evaluated in the corresponding command implementation. + if(gc.readOnly && IsDisallowedInReadOnlyMode(command.index)) + { + result = TPM_RC_READ_ONLY; + goto Cleanup; + } +#endif #if FIELD_UPGRADE_IMPLEMENTED == YES // If the TPM is in FUM, then the only allowed command is // TPM_CC_FieldUpgradeData. @@ -309,45 +270,60 @@ LIB_EXPORT void ExecuteCommand( } Cleanup: - if(g_clearOrderly == TRUE && NV_IS_ORDERLY) + if(!_plat__InFailureMode()) { + if(g_clearOrderly == TRUE && NV_IS_ORDERLY) + { #if USE_DA_USED - gp.orderlyState = g_daUsed ? SU_DA_USED_VALUE : SU_NONE_VALUE; + gp.orderlyState = g_daUsed ? SU_DA_USED_VALUE : SU_NONE_VALUE; #else - gp.orderlyState = SU_NONE_VALUE; + gp.orderlyState = SU_NONE_VALUE; #endif - NV_SYNC_PERSISTENT(orderlyState); - } - // This implementation loads an "evict" object to a transient object slot in - // RAM whenever an "evict" object handle is used in a command so that the - // access to any object is the same. These temporary objects need to be - // cleared from RAM whether the command succeeds or fails. - ObjectCleanupEvict(); + NV_SYNC_PERSISTENT(orderlyState); + } + // This implementation loads an "evict" object to a transient object slot in + // RAM whenever an "evict" object handle is used in a command so that the + // access to any object is the same. These temporary objects need to be + // cleared from RAM whether the command succeeds or fails. + ObjectCleanupEvict(); - // The parameters and sessions have been marshaled. Now tack on the header and - // set the sizes - BuildResponseHeader(&command, *response, result); + // The parameters and sessions have been marshaled. Now tack on the header and + // set the sizes. This sets command.parameterSize to the size of the entire + // response. + BuildResponseHeader(&command, *response, result); - // Try to commit all the writes to NV if any NV write happened during this - // command execution. This check should be made for both succeeded and failed - // commands, because a failed one may trigger a NV write in DA logic as well. - // This is the only place in the command execution path that may call the NV - // commit. If the NV commit fails, the TPM should be put in failure mode. - if((g_updateNV != UT_NONE) && !g_inFailureMode) - { - if(g_updateNV == UT_ORDERLY) - NvUpdateIndexOrderlyData(); - if(!NvCommit()) - FAIL(FATAL_ERROR_INTERNAL); - g_updateNV = UT_NONE; - } - pAssert((UINT32)command.parameterSize <= maxResponse); + // Try to commit all the writes to NV if any NV write happened during this + // command execution. This check should be made for both succeeded and failed + // commands, because a failed one may trigger a NV write in DA logic as well. + // This is the only place in the command execution path that may call the NV + // commit. If the NV commit fails, the TPM should be put in failure mode. + // Don't write in failure mode because we can't trust what we are + // writing. + if((g_updateNV != UT_NONE) && !_plat__InFailureMode()) + { + if(g_updateNV == UT_ORDERLY) + { + NvUpdateIndexOrderlyData(); + } + if(!NvCommit()) + { + FAIL_NORET(FATAL_ERROR_INTERNAL); + } + g_updateNV = UT_NONE; + } - // Clear unused bits in response buffer. - MemorySet(*response + *responseSize, 0, maxResponse - *responseSize); + pAssert_NORET((UINT32)command.parameterSize <= maxResponse); - // as a final act, and not before, update the response size. - *responseSize = (UINT32)command.parameterSize; + // Clear unused bits in response buffer. + MemorySet(*response + *responseSize, 0, maxResponse - *responseSize); - return; + // as a final act, and not before, update the response size. + *responseSize = (UINT32)command.parameterSize; + } + + if(_plat__InFailureMode()) + { + // something in the command triggered failure mode - handle command as a failure instead + TpmFailureMode(requestSize, request, responseSize, response); + } } diff --git a/src/tpm2/SessionProcess.c b/src/tpm2/TPMCmd/tpm/src/main/SessionProcess.c similarity index 92% rename from src/tpm2/SessionProcess.c rename to src/tpm2/TPMCmd/tpm/src/main/SessionProcess.c index b0ffeb3a7..690e0cb4b 100644 --- a/src/tpm2/SessionProcess.c +++ b/src/tpm2/TPMCmd/tpm/src/main/SessionProcess.c @@ -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 @@ -69,8 +11,12 @@ #define SESSION_PROCESS_C #include "Tpm.h" -#include "ACT.h" +#include "tpm_public/ACT.h" #include "Marshal.h" +#include +#if SEC_CHANNEL_SUPPORT +# include "SecChannel_fp.h" +#endif // SEC_CHANNEL_SUPPORT // //** Authorization Support Functions @@ -109,7 +55,18 @@ BOOL IsDAExempted(TPM_HANDLE handle // IN: entity handle } case TPM_HT_NV_INDEX: { - NV_INDEX* nvIndex = NvGetIndexInfo(handle, NULL); + NV_INDEX* nvIndex = NULL; + NV_INDEX ekIndex = {0}; + if(_plat__IsNvVirtualIndex(handle)) + { + _plat__NvVirtual_PopulateNvIndexInfo( + handle, &ekIndex.publicArea, &ekIndex.authValue); + nvIndex = &ekIndex; + } + else + { + nvIndex = NvGetIndexInfo(handle, NULL); + } result = IS_ATTRIBUTE(nvIndex->publicArea.attributes, TPMA_NV, NO_DA); break; } @@ -148,6 +105,7 @@ static TPM_RC IncrementLockout(UINT32 sessionIndex) else { session = SessionGet(sessionHandle); + pAssert_RC(session); // If the session is bound to lockout, then use that as the relevant // handle. This means that an authorization failure with a bound session // bound to lockoutAuth will take precedence over any other @@ -162,7 +120,7 @@ static TPM_RC IncrementLockout(UINT32 sessionIndex) } if(handle == TPM_RH_LOCKOUT) { - pAssert(gp.lockOutAuthEnabled == TRUE); + pAssert_RC(gp.lockOutAuthEnabled == TRUE); // lockout is no longer enabled gp.lockOutAuthEnabled = FALSE; @@ -262,7 +220,7 @@ static BOOL IsPolicySessionRequired(COMMAND_INDEX commandIndex, // IN: command if(type == TPM_HT_TRANSIENT) { OBJECT* object = HandleToObject(s_associatedHandles[sessionIndex]); - + pAssert_BOOL(object != NULL); if(!IS_ATTRIBUTE( object->publicArea.objectAttributes, TPMA_OBJECT, adminWithPolicy)) return FALSE; @@ -352,7 +310,8 @@ static BOOL IsAuthValueAvailable(TPM_HANDLE handle, // IN: handle of e OBJECT* object; TPMA_OBJECT attributes; // - object = HandleToObject(handle); + object = HandleToObject(handle); + pAssert_BOOL(object != NULL); attributes = object->publicArea.objectAttributes; // authValue is always available for a sequence object. @@ -380,10 +339,24 @@ static BOOL IsAuthValueAvailable(TPM_HANDLE handle, // IN: handle of e // NV Index. { NV_REF locator; - NV_INDEX* nvIndex = NvGetIndexInfo(handle, &locator); + NV_INDEX* nvIndex = NULL; TPMA_NV nvAttributes; // - pAssert(nvIndex != 0); + + if(_plat__IsNvVirtualIndex(handle)) + { + NV_INDEX tempIndex = {0}; + _plat__NvVirtual_PopulateNvIndexInfo( + handle, &tempIndex.publicArea, &tempIndex.authValue); + nvIndex = &tempIndex; + + locator = (NV_REF)0; + } + else + { + nvIndex = NvGetIndexInfo(handle, &locator); + } + pAssert_BOOL(nvIndex != 0); nvAttributes = nvIndex->publicArea.attributes; @@ -404,6 +377,10 @@ static BOOL IsAuthValueAvailable(TPM_HANDLE handle, // IN: handle of e NV_PIN pin; if(!IS_ATTRIBUTE(nvAttributes, TPMA_NV, WRITTEN)) break; // return false + + if(locator == (NV_REF)0) + break; // return false + // get the index values pin.intVal = NvGetUINT64Data(nvIndex, locator); if(pin.pin.pinCount < pin.pin.pinLimit) @@ -487,6 +464,7 @@ static BOOL IsAuthPolicyAvailable(TPM_HANDLE handle, // IN: handle of // An evict object would already have been loaded and given a // transient object handle by this point. OBJECT* object = HandleToObject(handle); + pAssert_BOOL(object != NULL); // Policy authorization is not available for an object with only // public portion loaded. if(object->attributes.publicOnly == CLEAR) @@ -649,7 +627,7 @@ static TPM2B_DIGEST* GetCpHash(COMMAND* command, TPMI_ALG_HASH hashAlg) { TPM2B_DIGEST* cpHash = GetCpHashPointer(command, hashAlg); // - pAssert(cpHash->t.size != 0); + pAssert_NULL(cpHash && cpHash->t.size != 0); return cpHash; } @@ -748,6 +726,66 @@ BOOL CompareParametersHash(COMMAND* command, // IN: main parsing structure return MemoryEqual2B(&session->u1.pHash.b, &pHash.b); } +#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 +// 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 +) +{ + HASH_STATE hashState; + TPM2B_DIGEST scKeyNameHash; + UINT16 zeroSize = 0x0000; + + // Compute secure channel key name hash + // scKeyNameHash = hash(reqKeyName.size || reqKeyName.name || tpmKeyName.size || tpmKeyName.name) + // Start hash + scKeyNameHash.t.size = CryptHashStart(&hashState, session->authHashAlg); + + // Include reqKeyName if it needs to be checked, otherwise include Empty Buffer + if(session->attributes.checkReqKey) + { + // Add reqKeyName.size + CryptDigestUpdateInt(&hashState, sizeof(UINT16), reqKeyName->t.size); + + // Add reqKeyName.name + CryptDigestUpdate2B(&hashState, &reqKeyName->b); + } + else + { + // Add zero size + CryptDigestUpdateInt(&hashState, sizeof(UINT16), zeroSize); + } + + // Include tpmKeyName if it needs to be checked, otherwise include Empty Buffer + if(session->attributes.checkTpmKey) + { + // Add tpmKeyName.size + CryptDigestUpdateInt(&hashState, sizeof(UINT16), tpmKeyName->t.size); + + // Add tpmKeyName.name + CryptDigestUpdate2B(&hashState, &tpmKeyName->b); + } + else + { + // Add zero size + CryptDigestUpdateInt(&hashState, sizeof(UINT16), zeroSize); + } + + // Complete hash + CryptHashEnd2B(&hashState, &scKeyNameHash.b); + + // and compare + return MemoryEqual(session->scKeyNameHash.t.buffer, + scKeyNameHash.t.buffer, + scKeyNameHash.t.size); +} +#endif // SEC_CHANNEL_SUPPORT + //*** CheckPWAuthSession() // This function validates the authorization provided in a PWAP session. It // compares the input value to authValue of the authorized entity. Argument @@ -826,7 +864,7 @@ static TPM_RC CheckPWAuthSession( // sessionAttributes A byte indicating the attributes associated with the // particular use of the session. */ -static TPM2B_DIGEST* ComputeCommandHMAC( +static TPM_RC ComputeCommandHMAC( COMMAND* command, // IN: primary control structure UINT32 sessionIndex, // IN: index of session to be processed TPM2B_DIGEST* hmac // OUT: authorization HMAC @@ -859,6 +897,7 @@ static TPM2B_DIGEST* ComputeCommandHMAC( // Will add the nonce for the decrypt session. SESSION* decryptSession = SessionGet(s_sessionHandles[s_decryptSessionIndex]); + pAssert_RC(decryptSession != NULL); nonceDecrypt = &decryptSession->nonceTPM; } // Now repeat for the encrypt session. @@ -869,12 +908,14 @@ static TPM2B_DIGEST* ComputeCommandHMAC( // Have to have the nonce for the encrypt session. SESSION* encryptSession = SessionGet(s_sessionHandles[s_encryptSessionIndex]); + pAssert_RC(encryptSession != NULL); nonceEncrypt = &encryptSession->nonceTPM; } } // Continue with the HMAC processing. session = SessionGet(s_sessionHandles[sessionIndex]); + pAssert_RC(session != NULL); // Generate HMAC key. MemoryCopy2B(&key.b, &session->sessionKey.b, sizeof(key.t.buffer)); @@ -899,7 +940,7 @@ static TPM2B_DIGEST* ComputeCommandHMAC( if(key.t.size == 0 && s_inputAuthValues[sessionIndex].t.size == 0) { hmac->t.size = 0; - return hmac; + return TPM_RC_SUCCESS; } // Start HMAC hmac->t.size = CryptHmacStart2B(&hmacState, session->authHashAlg, &key.b); @@ -921,7 +962,7 @@ static TPM2B_DIGEST* ComputeCommandHMAC( // Complete the HMAC computation CryptHmacEnd2B(&hmacState, &hmac->b); - return hmac; + return TPM_RC_SUCCESS; } //*** CheckSessionHMAC() @@ -947,7 +988,9 @@ static TPM_RC CheckSessionHMAC( TPM2B_DIGEST hmac; // authHMAC for comparing // // Compute authHMAC - ComputeCommandHMAC(command, sessionIndex, &hmac); + TPM_RC result = ComputeCommandHMAC(command, sessionIndex, &hmac); + if(result != TPM_RC_SUCCESS) + return result; // Compare the input HMAC with the authHMAC computed above. if(!MemoryEqual2B(&s_inputAuthValues[sessionIndex].b, &hmac.b)) @@ -984,6 +1027,8 @@ static TPM_RC CheckSessionHMAC( // TPM_RC_PP PP is required but not asserted // TPM_RC_NV_UNAVAILABLE NV is not available for write // TPM_RC_NV_RATE NV is rate limiting +// TPM_RC_CHANNEL No secure channel is active +// TPM_RC_CHANNEL_KEY Secure channel key is incorrect static TPM_RC CheckPolicyAuthSession( COMMAND* command, // IN: primary parsing structure UINT32 sessionIndex // IN: index of session to be processed @@ -996,6 +1041,7 @@ static TPM_RC CheckPolicyAuthSession( // // Initialize pointer to the authorization session. session = SessionGet(s_sessionHandles[sessionIndex]); + pAssert_RC(session != NULL); // If the command is TPM2_PolicySecret(), make sure that // either password or authValue is required @@ -1116,6 +1162,26 @@ static TPM_RC CheckPolicyAuthSession( != (session->attributes.nvWrittenState == SET)) return TPM_RC_POLICY_FAIL; } +#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 + // 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(!CompareScKeyNameHash(session, &reqKeyName, &tpmKeyName)) + return TPM_RC_CHANNEL_KEY; + } + } +#endif // SEC_CHANNEL_SUPPORT return TPM_RC_SUCCESS; } @@ -1206,6 +1272,7 @@ static TPM_RC RetrieveSessionData( return TPM_RC_REFERENCE_S0 + sessionIndex; sessionType = HandleGetType(s_sessionHandles[sessionIndex]); session = SessionGet(s_sessionHandles[sessionIndex]); + pAssert_RC(session != NULL); // Check if the session is an HMAC/policy session. if((session->attributes.isPolicy == SET && sessionType == TPM_HT_HMAC_SESSION) @@ -1375,7 +1442,7 @@ static TPM_RC CheckAuthSession( TPM_HT sessionHandleType = HandleGetType(sessionHandle); BOOL authUsed; // - pAssert(sessionHandle != TPM_RH_UNASSIGNED); + pAssert_RC(sessionHandle != TPM_RH_UNASSIGNED); // Take care of physical presence if(associatedHandle == TPM_RH_PLATFORM) @@ -1389,6 +1456,7 @@ static TPM_RC CheckAuthSession( if(sessionHandle != TPM_RS_PW) { session = SessionGet(sessionHandle); + pAssert_RC(session != NULL); // Set includeAuth to indicate if DA checking will be required and if the // authValue will be included in any HMAC. @@ -1460,17 +1528,34 @@ static TPM_RC CheckAuthSession( if((TPM_HT_NV_INDEX == HandleGetType(associatedHandle)) && authUsed) { NV_REF locator; - NV_INDEX* nvIndex = NvGetIndexInfo(associatedHandle, &locator); + NV_INDEX* nvIndex = NULL; NV_PIN pinData; TPMA_NV nvAttributes; + NV_INDEX tempIndex = {0}; + + if(_plat__IsNvVirtualIndex(associatedHandle)) + { + _plat__NvVirtual_PopulateNvIndexInfo( + associatedHandle, &tempIndex.publicArea, &tempIndex.authValue); + nvIndex = &tempIndex; + + locator = (NV_REF)0; + } + else + { + nvIndex = NvGetIndexInfo(associatedHandle, &locator); + } + // - pAssert(nvIndex != NULL); + pAssert_RC(nvIndex != NULL); nvAttributes = nvIndex->publicArea.attributes; // If this is a PIN FAIL index and the value has been written // then we can update the counter (increment or clear) if(IsNvPinFailIndex(nvAttributes) && IS_ATTRIBUTE(nvAttributes, TPMA_NV, WRITTEN)) { + if(locator == (NV_REF)0) + return TPM_RC_AUTH_UNAVAILABLE; pinData.intVal = NvGetUINT64Data(nvIndex, locator); if(result != TPM_RC_SUCCESS) pinData.pin.pinCount++; @@ -1487,6 +1572,8 @@ static TPM_RC CheckAuthSession( && IS_ATTRIBUTE(nvAttributes, TPMA_NV, WRITTEN) && result == TPM_RC_SUCCESS) { + if(locator == (NV_REF)0) + return TPM_RC_AUTH_UNAVAILABLE; // If the access is valid, then increment the use counter pinData.intVal = NvGetUINT64Data(nvIndex, locator); pinData.pin.pinCount++; @@ -1553,7 +1640,7 @@ ParseSessionBuffer(COMMAND* command // IN: the structure that contains return result; // There is no command in the TPM spec that has more handles than // MAX_SESSION_NUM. - pAssert(command->handleNum <= MAX_SESSION_NUM); + pAssert_RC(command->handleNum <= MAX_SESSION_NUM); // Associate the session with an authorization handle. for(i = 0; i < command->handleNum; i++) @@ -1593,6 +1680,7 @@ ParseSessionBuffer(COMMAND* command // IN: the structure that contains else { session = SessionGet(s_sessionHandles[sessionIndex]); + pAssert_RC(session != NULL); // A trial session can not appear in session area, because it cannot // be used for authorization, audit or encrypt/decrypt. @@ -1631,7 +1719,7 @@ ParseSessionBuffer(COMMAND* command // IN: the structure that contains return TPM_RCS_ATTRIBUTES + errorIndex; // no authValue included in any of the HMAC computations - pAssert(session != NULL); + pAssert_RC(session != NULL); session->attributes.includeAuth = CLEAR; // check HMAC for encrypt/decrypt/audit only sessions @@ -1668,7 +1756,8 @@ ParseSessionBuffer(COMMAND* command // IN: the structure that contains { extraKey.b.size = 0; } - size = DecryptSize(command->index); + size = DecryptSize(command->index); + pAssert_RC(command->parameterSize <= INT32_MAX); result = CryptParameterDecryption(s_sessionHandles[s_decryptSessionIndex], &s_nonceCaller[s_decryptSessionIndex].b, command->parameterSize, @@ -1785,7 +1874,7 @@ static void UpdateAuditDigest( TPM2B_DIGEST* cpHash = GetCpHash(command, hashAlg); TPM2B_DIGEST* rpHash = ComputeRpHash(command, hashAlg); // - pAssert(cpHash != NULL); + pAssert_VOID_OK(cpHash != NULL); // digestNew := hash (digestOld || cpHash || rpHash) // Start hash computation. @@ -1868,6 +1957,7 @@ static void UpdateAuditSessionStatus( if(s_sessionHandles[i] == TPM_RS_PW) continue; session = SessionGet(s_sessionHandles[i]); + pAssert_VOID_OK(session != NULL); // If a session is used for audit if(IS_ATTRIBUTE(s_attributes[i], TPMA_SESSION, audit)) @@ -2039,7 +2129,8 @@ static TPM2B_NONCE* BuildSingleResponseAuth( { // Fill in policy/HMAC based session response. SESSION* session = SessionGet(s_sessionHandles[sessionIndex]); - // + pAssert_NULL(session != NULL); + // If the session is a policy session with isPasswordNeeded SET, the // authorization field is empty. if(HandleGetType(s_sessionHandles[sessionIndex]) == TPM_HT_POLICY_SESSION @@ -2067,6 +2158,7 @@ static void UpdateAllNonceTPM(COMMAND* command // IN: controlling structure if(s_sessionHandles[i] != TPM_RS_PW) { session = SessionGet(s_sessionHandles[i]); + pAssert_VOID_OK(session != NULL); // Update nonceTPM in both internal session and response. CryptRandomGenerate(session->nonceTPM.t.size, session->nonceTPM.t.buffer); } @@ -2089,7 +2181,7 @@ BuildResponseSession(COMMAND* command // IN: structure that has relevant comman { TPM_RC result = TPM_RC_SUCCESS; - pAssert(command->authSize == 0); + pAssert_RC(command->authSize == 0); // Reset the parameter buffer to point to the start of the parameters so that // there is a starting point for any rpHash that might be generated and so there @@ -2100,6 +2192,7 @@ BuildResponseSession(COMMAND* command // IN: structure that has relevant comman if(command->tag == TPM_ST_SESSIONS) { UpdateAllNonceTPM(command); + VERIFY_NOT_FAILED(); // Encrypt first parameter if applicable. Parameter encryption should // happen after nonce update and before any rpHash is computed. @@ -2122,6 +2215,7 @@ BuildResponseSession(COMMAND* command // IN: structure that has relevant comman &extraKey); } size = EncryptSize(command->index); + pAssert_RC(command->parameterSize <= INT32_MAX); // This function operates on internally-generated data that is // expected to be well-formed for parameter encryption. // In the event that there is a bug elsewhere in the code and the @@ -2134,7 +2228,7 @@ BuildResponseSession(COMMAND* command // IN: structure that has relevant comman (UINT16)size, &extraKey, command->parameterBuffer); - if(g_inFailureMode) + if(_plat__InFailureMode()) { result = TPM_RC_FAILURE; goto Cleanup; @@ -2144,6 +2238,7 @@ BuildResponseSession(COMMAND* command // IN: structure that has relevant comman // Audit sessions should be processed regardless of the tag because // a command with no session may cause a change of the exclusivity state. UpdateAuditSessionStatus(command); + VERIFY_NOT_FAILED(); #if CC_GetCommandAuditDigest // Command Audit if(CommandAuditIsRequired(command->index)) @@ -2154,7 +2249,7 @@ BuildResponseSession(COMMAND* command // IN: structure that has relevant comman { UINT32 i; // - pAssert(command->sessionNum > 0); + pAssert_RC(command->sessionNum > 0); // Iterate over each session in the command session area, and create // corresponding sessions for response. @@ -2176,6 +2271,7 @@ BuildResponseSession(COMMAND* command // IN: structure that has relevant comman // Compute the response HMAC and get a pointer to the nonce used. // This function will also update the values if needed. Note, the nonceTPM = BuildSingleResponseAuth(command, i, &responseAuth); + pAssert_RC(nonceTPM != NULL); } command->authSize += TPM2B_NONCE_Marshal(nonceTPM, &command->responseBuffer, NULL); @@ -2184,7 +2280,10 @@ BuildResponseSession(COMMAND* command // IN: structure that has relevant comman command->authSize += TPM2B_DIGEST_Marshal(&responseAuth, &command->responseBuffer, NULL); if(!IS_ATTRIBUTE(s_attributes[i], TPMA_SESSION, continueSession)) + { SessionFlush(s_sessionHandles[i]); + VERIFY_NOT_FAILED(); + } } } diff --git a/src/tpm2/CommandAudit.c b/src/tpm2/TPMCmd/tpm/src/subsystem/CommandAudit.c similarity index 69% rename from src/tpm2/CommandAudit.c rename to src/tpm2/TPMCmd/tpm/src/subsystem/CommandAudit.c index c546dd117..2138efda5 100644 --- a/src/tpm2/CommandAudit.c +++ b/src/tpm2/TPMCmd/tpm/src/subsystem/CommandAudit.c @@ -1,62 +1,4 @@ -/********************************************************************************/ -/* */ -/* Functions That Support Command Audit */ -/* 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 functions that support command audit. diff --git a/src/tpm2/DA.c b/src/tpm2/TPMCmd/tpm/src/subsystem/DA.c similarity index 65% rename from src/tpm2/DA.c rename to src/tpm2/TPMCmd/tpm/src/subsystem/DA.c index 07262aafd..ca5372a98 100644 --- a/src/tpm2/DA.c +++ b/src/tpm2/TPMCmd/tpm/src/subsystem/DA.c @@ -1,63 +1,4 @@ -/********************************************************************************/ -/* */ -/* Dictionary Attack Logic. */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: DA.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, 2016 - 2019 */ -/* */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause //** Introduction // This file contains the functions and data definitions relating to the diff --git a/src/tpm2/Hierarchy.c b/src/tpm2/TPMCmd/tpm/src/subsystem/Hierarchy.c similarity index 83% rename from src/tpm2/Hierarchy.c rename to src/tpm2/TPMCmd/tpm/src/subsystem/Hierarchy.c index 22328c72b..de31c7713 100644 --- a/src/tpm2/Hierarchy.c +++ b/src/tpm2/TPMCmd/tpm/src/subsystem/Hierarchy.c @@ -1,62 +1,4 @@ -/********************************************************************************/ -/* */ -/* Managing and accessing the hierarchy-related values */ -/* 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 functions used for managing and accessing the @@ -101,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); @@ -176,6 +118,11 @@ BOOL HierarchyStartup(STARTUP_TYPE type // IN: start up type // enable the storage and endorsement hierarchies and the platformNV gc.shEnable = gc.ehEnable = gc.phEnableNV = TRUE; + +#if CC_ReadOnlyControl + // clear read-only mode + gc.readOnly = FALSE; +#endif } // nullProof and nullSeed are updated at every TPM_RESET diff --git a/src/tpm2/NvDynamic.c b/src/tpm2/TPMCmd/tpm/src/subsystem/NvDynamic.c similarity index 93% rename from src/tpm2/NvDynamic.c rename to src/tpm2/TPMCmd/tpm/src/subsystem/NvDynamic.c index cc48a7719..a8c28d03e 100644 --- a/src/tpm2/NvDynamic.c +++ b/src/tpm2/TPMCmd/tpm/src/subsystem/NvDynamic.c @@ -1,62 +1,4 @@ -/********************************************************************************/ -/* */ -/* Dynamic space for user defined NV */ -/* 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 @@ -99,6 +41,7 @@ #define NV_C #include "Tpm.h" #include "Marshal.h" +#include #include "tpm_library_intern.h" // libtpms added #include "BackwardsCompatibilityObject.h" // libtpms added @@ -277,7 +220,17 @@ NvWriteNvListEnd(NV_REF end) // Copy the maxCount value to the marker buffer MemoryCopy(&listEndMarker[sizeof(UINT32)], &maxCount, sizeof(UINT64)); - pAssert(end + sizeof(NV_LIST_TERMINATOR) <= s_evictNvEnd); + + // was a pAssert that (end + sizeof(NV_LIST_TERMINATOR) <= s_evictNvEnd); + if(end + sizeof(NV_LIST_TERMINATOR) > s_evictNvEnd) + { + // enter failure mode, but don't return yet. + FAIL_NORET(FATAL_ERROR_ASSERT); + // write NV_REF at last valid space. + // This will truncate the last entry, but + // better than writing past buffer or leaving buffer unterminated. + end = s_evictNvEnd - sizeof(NV_LIST_TERMINATOR); + } // Write it to memory NvWrite(end, sizeof(NV_LIST_TERMINATOR), &listEndMarker); @@ -364,7 +317,7 @@ static TPM_RC NvDelete(NV_REF entityRef // IN: reference to entity to be delete // If this is not the last entry, move everything up if(nextAddr < endRef) { - pAssert(nextAddr > entryRef); + pAssert_RC(nextAddr > entryRef); _plat__NvMemoryMove(nextAddr, entryRef, (endRef - nextAddr)); } // The end of the used space is now moved up by the amount of space we just @@ -397,7 +350,9 @@ static TPM_RC NvDelete(NV_REF entityRef // IN: reference to entity to be delete //*** NvRamNext() // This function is used to iterate trough the list of Ram Index values. *iter needs -// to be initialized by calling +// to be initialized to NV_RAM_REF_INIT before starting iteration. +// returns the handle and REF of the current item and advances iterator. +// return 0 when at the end of the list. static NV_RAM_REF NvRamNext(NV_RAM_REF* iter, // IN/OUT: the list iterator TPM_HANDLE* handle // OUT: the handle of the next item. ) @@ -418,19 +373,33 @@ static NV_RAM_REF NvRamNext(NV_RAM_REF* iter, // IN/OUT: the list iterator // that we are at the end of the list. The end of the list occurs when // we don't have space for a size and a handle if(currentAddr + sizeof(NV_RAM_HEADER) > RAM_ORDERLY_END) + { return NULL; + } + // read the header of the next entry memcpy(&header, currentAddr, sizeof(NV_RAM_HEADER)); // libtpms: do not use MemoryCopy to avoid gcc warning // if the size field is zero, then we have hit the end of the list if(header.size == 0) + { // leave the *iter pointing at the end of the list return NULL; + } + + if(*iter + header.size > RAM_ORDERLY_END) + { + // enter failure mode and stop iteration. + FAIL_IMMEDIATE(FATAL_ERROR_INTERNAL, 0); + } + // advance the header by the size of the entry - *iter = currentAddr + header.size; + *iter += header.size; - // pAssert(*iter <= RAM_ORDERLY_END); if(handle != NULL) + { *handle = header.handle; + } + return currentAddr; } @@ -502,7 +471,7 @@ void NvUpdateIndexOrderlyData(void) // This function should be called after the NV Index space has been updated // and the index removed. This insures that NV is available so that checking // for NV availability is not required during this function. -static void NvAddRAM(TPMS_NV_PUBLIC* index // IN: the index descriptor +static TPM_RC NvAddRAM(TPMS_NV_PUBLIC* index // IN: the index descriptor ) { NV_RAM_HEADER header; @@ -512,7 +481,7 @@ static void NvAddRAM(TPMS_NV_PUBLIC* index // IN: the index descriptor header.handle = index->nvIndex; MemoryCopy(&header.attributes, &index->attributes, sizeof(TPMA_NV)); - pAssert(ORDERLY_RAM_ADDRESS_OK(end, header.size)); + pAssert_RC(ORDERLY_RAM_ADDRESS_OK(end, header.size)); // Copy the header to the memory MemoryCopy(end, &header, sizeof(NV_RAM_HEADER)); @@ -529,7 +498,7 @@ static void NvAddRAM(TPMS_NV_PUBLIC* index // IN: the index descriptor // Write reserved RAM space to NV to reflect the newly added NV Index SET_NV_UPDATE(UT_ORDERLY); - return; + return TPM_RC_SUCCESS; } //*** NvDeleteRAM() @@ -542,7 +511,7 @@ static void NvAddRAM(TPMS_NV_PUBLIC* index // IN: the index descriptor // This function should be called after the NV Index space has been updated // and the index removed. This insures that NV is available so that checking // for NV availability is not required during this function. -static void NvDeleteRAM(TPMI_RH_NV_INDEX handle // IN: NV handle +static TPM_RC NvDeleteRAM(TPMI_RH_NV_INDEX handle // IN: NV handle ) { NV_RAM_REF nodeAddress; @@ -552,7 +521,7 @@ static void NvDeleteRAM(TPMI_RH_NV_INDEX handle // IN: NV handle // nodeAddress = NvRamGetIndex(handle); - pAssert(nodeAddress != 0); + pAssert_RC(nodeAddress != 0); // Get node size MemoryCopy(&size, nodeAddress, sizeof(size)); @@ -569,7 +538,7 @@ static void NvDeleteRAM(TPMI_RH_NV_INDEX handle // IN: NV handle // Write reserved RAM space to NV to reflect the newly delete NV Index SET_NV_UPDATE(UT_ORDERLY); - return; + return TPM_RC_SUCCESS; } //*** NvReadIndex() @@ -581,7 +550,10 @@ void NvReadNvIndexInfo(NV_REF ref, // IN: points to NV where index is loc NV_INDEX* nvIndex // OUT: place to receive index data ) { - pAssert(nvIndex != NULL); + // internal function that should have validated parameters. enter failure + // mode and return without reading. currently existing callers pass private + // buffers so are all guaranteed non-null + pAssert_VOID_OK(nvIndex != NULL); NvRead(nvIndex, ref, sizeof(NV_INDEX)); return; } @@ -634,11 +606,11 @@ static void NvObjectFromBuffer(OBJECT* object, BYTE* buf, UINT32 buf_size) */ rc = ANY_OBJECT_Unmarshal(object, &buffer, &size, false); if (!rc) { - pAssert(size == 0); + pAssert_VOID_OK(size == 0); } else { /* It could not be unmarshalled, it must be a plain RSA3072_OBJECT */ rc = RSA3072_OBJECT_Buffer_To_OBJECT(object, buf, buf_size); - pAssert(rc == TPM_RC_SUCCESS); + pAssert_VOID_OK(rc == TPM_RC_SUCCESS); } } // libtpms added end @@ -661,7 +633,7 @@ void NvReadObject(NV_REF ref, // IN: points to NV where index is located entrysize -= sizeof(NV_ENTRY_HEADER); /* read the flat object into a buffer */ - pAssert(entrysize <= sizeof(buffer)); + pAssert_VOID_OK(entrysize <= sizeof(buffer)); NvRead(buffer, ref + sizeof(TPM_HANDLE), entrysize); NvObjectFromBuffer(object, buffer, entrysize); @@ -824,9 +796,17 @@ BOOL NvIsOwnerPersistentHandle(TPM_HANDLE handle // IN: handle // TPM_RC_NV_WRITELOCKED Index is present but locked for writing and command // writes to the index TPM_RC -NvIndexIsAccessible(TPMI_RH_NV_INDEX handle // IN: handle -) +NvIndexIsAccessible(TPMI_RH_NV_INDEX handle, // IN: handle + BOOL commandAcceptsVirtualHandles) { + // For virtual indexes nothing is actually stored in the NV + // so if it exists, it's considered "accessible", though the relevant + // virtual API may return a locked result later. + if(_plat__IsNvVirtualIndex(handle)) + { + return commandAcceptsVirtualHandles ? TPM_RC_SUCCESS : TPM_RC_NV_LOCKED; + } + NV_INDEX* nvIndex = NvGetIndexInfo(handle, NULL); // if(nvIndex == NULL) @@ -923,27 +903,35 @@ void NvGetIndexData(NV_INDEX* nvIndex, // IN: the in RAM index descriptor ) { TPMA_NV nvAttributes; - // - pAssert(nvIndex != NULL); + + // early exit/fail to read is an appropriate response if input data is invalid. + // these should have been checked by NvReadAccessChecks before getting here, so + // failure mode is appropriate + pAssert_VOID_OK(nvIndex != NULL); nvAttributes = nvIndex->publicArea.attributes; - pAssert(IS_ATTRIBUTE(nvAttributes, TPMA_NV, WRITTEN)); + pAssert_VOID_OK(IS_ATTRIBUTE(nvAttributes, TPMA_NV, WRITTEN)); if(IS_ATTRIBUTE(nvAttributes, TPMA_NV, ORDERLY)) { // Get data from RAM buffer NV_RAM_REF ramAddr = NvRamGetIndex(nvIndex->publicArea.nvIndex); - pAssert(ramAddr != 0 - && (size <= ((NV_RAM_HEADER*)ramAddr)->size - sizeof(NV_RAM_HEADER) - - offset)); + + // Copy the contents of ramAddr into a local NV_RAM_HEADER variable before + // performing the boundary check to avoid potential alignment issues + NV_RAM_HEADER nvRamHeader; + MemoryCopy(&nvRamHeader, ramAddr, sizeof(NV_RAM_HEADER)); + pAssert_VOID_OK( + ramAddr != 0 + && (size <= (nvRamHeader.size - sizeof(NV_RAM_HEADER) - offset))); MemoryCopy(data, ramAddr + sizeof(NV_RAM_HEADER) + offset, size); } else { // Validate that read falls within range of the index - pAssert(offset <= nvIndex->publicArea.dataSize - && size <= (nvIndex->publicArea.dataSize - offset)); + pAssert_VOID_OK(offset <= nvIndex->publicArea.dataSize + && size <= (nvIndex->publicArea.dataSize - offset)); NvRead(data, locator + sizeof(NV_INDEX) + offset, size); } return; @@ -1112,15 +1100,15 @@ NvWriteIndexData(NV_INDEX* nvIndex, // IN: the description of the index { TPM_RC result = TPM_RC_SUCCESS; // - pAssert(nvIndex != NULL); + pAssert_RC(nvIndex != NULL); // Make sure that this is dealing with the 'default' index. // Note: it is tempting to change the calling sequence so that the 'default' is // presumed. - pAssert(nvIndex->publicArea.nvIndex == s_cachedNvIndex.publicArea.nvIndex); + pAssert_RC(nvIndex->publicArea.nvIndex == s_cachedNvIndex.publicArea.nvIndex); // Validate that write falls within range of the index - pAssert(offset <= nvIndex->publicArea.dataSize - && size <= (nvIndex->publicArea.dataSize - offset)); + pAssert_RC(offset <= nvIndex->publicArea.dataSize + && size <= (nvIndex->publicArea.dataSize - offset)); // Update TPMA_NV_WRITTEN bit if necessary if(!IS_ATTRIBUTE(nvIndex->publicArea.attributes, TPMA_NV, WRITTEN)) @@ -1217,8 +1205,25 @@ TPM2B_NAME* NvGetNameByIndexHandle( TPM2B_NAME* name // OUT: name of the index ) { - NV_INDEX* nvIndex = NvGetIndexInfo(handle, NULL); - // + NV_INDEX* nvIndex = NULL; + NV_INDEX tempIndex = {0}; + + if(_plat__IsNvVirtualIndex(handle)) + { + _plat__NvVirtual_PopulateNvIndexInfo( + handle, &tempIndex.publicArea, &tempIndex.authValue); + nvIndex = &tempIndex; + } + else + { + nvIndex = NvGetIndexInfo(handle, NULL); + if(nvIndex == NULL) + { + name->b.size = 0; // set to empty reply. + return name; + } + } + return NvGetIndexName(nvIndex, name); } @@ -1267,7 +1272,9 @@ NvDefineIndex(TPMS_NV_PUBLIC* publicArea, // IN: A template for an area to crea { // If the data of NV Index is RAM backed, add the data area in RAM as well if(IS_ATTRIBUTE(publicArea->attributes, TPMA_NV, ORDERLY)) - NvAddRAM(publicArea); + { + result = NvAddRAM(publicArea); + } } return result; } @@ -1348,7 +1355,13 @@ NvDeleteIndex(NV_INDEX* nvIndex, // IN: an in RAM index descriptor return result; // If the NV Index is RAM backed, delete the RAM data as well if(IS_ATTRIBUTE(nvIndex->publicArea.attributes, TPMA_NV, ORDERLY)) - NvDeleteRAM(nvIndex->publicArea.nvIndex); + { + result = NvDeleteRAM(nvIndex->publicArea.nvIndex); + } + + if(result != TPM_RC_SUCCESS) + return result; + NvIndexCacheInit(); } return TPM_RC_SUCCESS; @@ -1547,7 +1560,7 @@ NvCapGetPersistent(TPMI_DH_OBJECT handle, // IN: start handle NV_REF currentAddr; TPM_HANDLE entityHandle; // - pAssert(HandleGetType(handle) == TPM_HT_PERSISTENT); + VERIFY(HandleGetType(handle) == TPM_HT_PERSISTENT, FATAL_ERROR_INTERNAL, NO); // Initialize output handle list handleList->count = 0; @@ -1586,7 +1599,7 @@ BOOL NvCapGetOnePersistent(TPMI_DH_OBJECT handle) // IN: handle NV_REF currentAddr; TPM_HANDLE entityHandle; - pAssert(HandleGetType(handle) == TPM_HT_PERSISTENT); + pAssert_BOOL(HandleGetType(handle) == TPM_HT_PERSISTENT); while((currentAddr = NvNextEvict(&entityHandle, &iter)) != 0) { @@ -1616,7 +1629,7 @@ NvCapGetIndex(TPMI_DH_OBJECT handle, // IN: start handle NV_REF currentAddr; TPM_HANDLE nvHandle; // - pAssert(HandleGetType(handle) == TPM_HT_NV_INDEX); + VERIFY(HandleGetType(handle) == TPM_HT_NV_INDEX, FATAL_ERROR_INTERNAL, NO); // Initialize output handle list handleList->count = 0; @@ -1642,6 +1655,10 @@ NvCapGetIndex(TPMI_DH_OBJECT handle, // IN: start handle // used here. InsertSort(handleList, count, nvHandle); } + + // Check virtual indices as well. + more |= _plat__NvVirtual_CapGetIndex(handle, count, handleList); + return more; } @@ -1653,7 +1670,7 @@ BOOL NvCapGetOneIndex(TPMI_DH_OBJECT handle) // IN: handle NV_REF currentAddr; TPM_HANDLE nvHandle; - pAssert(HandleGetType(handle) == TPM_HT_NV_INDEX); + pAssert_BOOL(HandleGetType(handle) == TPM_HT_NV_INDEX); while((currentAddr = NvNextIndex(&nvHandle, &iter)) != 0) { diff --git a/src/tpm2/NvReserved.c b/src/tpm2/TPMCmd/tpm/src/subsystem/NvReserved.c similarity index 66% rename from src/tpm2/NvReserved.c rename to src/tpm2/TPMCmd/tpm/src/subsystem/NvReserved.c index 5f1a8b956..dcda91883 100644 --- a/src/tpm2/NvReserved.c +++ b/src/tpm2/TPMCmd/tpm/src/subsystem/NvReserved.c @@ -1,62 +1,4 @@ -/********************************************************************************/ -/* */ -/* NV TPM persistent and state save data */ -/* 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 @@ -213,8 +155,10 @@ void NvRead(void* outBuffer, // OUT: buffer to receive data UINT32 size // IN: size of the value to read ) { - // Input type should be valid - pAssert(nvOffset + size < NV_MEMORY_SIZE); + // Input addresses must be inside the memory buffer. + // void is OK because we simply skip the read, which is the only reasonable + // response. + pAssert_VOID_OK(nvOffset + size < NV_MEMORY_SIZE); _plat__NvMemoryRead(nvOffset, size, outBuffer); return; } @@ -228,13 +172,10 @@ BOOL NvWrite(UINT32 nvOffset, // IN: location in NV to receive data ) { // Input type should be valid - if(nvOffset + size <= NV_MEMORY_SIZE) - { - // Set the flag that a NV write happened - SET_NV_UPDATE(UT_NV); - return _plat__NvMemoryWrite(nvOffset, size, inBuffer); - } - return FALSE; + pAssert_BOOL(nvOffset + size <= NV_MEMORY_SIZE); + // Set the flag that a NV write happened + SET_NV_UPDATE(UT_NV); + return _plat__NvMemoryWrite(nvOffset, size, inBuffer); } #if 0 // libtpms added begin (for Coverity) @@ -247,7 +188,12 @@ void NvUpdatePersistent( void* buffer // IN: the new data ) { - pAssert(offset + size <= sizeof(gp)); + // Input addresses must be inside the memory buffer. Any callers using the + // expected CLEAR_PERSISTENT macro should encounter a build error before + // tripping this assert so void is reasonable as a defense in depth against + // a manual caller of this function. Skipping the write is the only + // reasonable response. + pAssert_VOID_OK(offset + size <= sizeof(gp)); MemoryCopy(&gp + offset, buffer, size); NvWrite(offset, size, buffer); } @@ -259,7 +205,12 @@ void NvClearPersistent(UINT32 offset, // IN: the offset in the PERMANENT_DATA UINT32 size // IN: number of bytes to clear ) { - pAssert(offset + size <= sizeof(gp)); + // Input addresses must be inside the memory buffer. Any callers using the + // expected CLEAR_PERSISTENT macro should encounter a build error before + // tripping this assert so void is reasonable as a defense in depth against + // a manual caller of this function. Skipping the write is the only + // reasonable response. + pAssert_VOID_OK(offset + size <= sizeof(gp)); MemorySet((&gp) + offset, 0, size); NvWrite(offset, size, (&gp) + offset); } diff --git a/src/tpm2/Object.c b/src/tpm2/TPMCmd/tpm/src/subsystem/Object.c similarity index 89% rename from src/tpm2/Object.c rename to src/tpm2/TPMCmd/tpm/src/subsystem/Object.c index f80264f66..ff321d29f 100644 --- a/src/tpm2/Object.c +++ b/src/tpm2/TPMCmd/tpm/src/subsystem/Object.c @@ -1,62 +1,4 @@ -/********************************************************************************/ -/* */ -/* Manage the object store of the TPM. */ -/* 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 functions that manage the object store of the TPM. @@ -157,7 +99,7 @@ BOOL IsObjectPresent(TPMI_DH_OBJECT handle // IN: handle to be checked BOOL ObjectIsSequence(OBJECT* object // IN: handle to be checked ) { - pAssert(object != NULL); + pAssert_BOOL(object != NULL); return (object->attributes.hmacSeq == SET || object->attributes.hashSeq == SET || object->attributes.eventSeq == SET); } @@ -178,9 +120,16 @@ OBJECT* HandleToObject(TPMI_DH_OBJECT handle // IN: handle of the object return NULL; // In this implementation, the handle is determined by the slot occupied by the // object. + // this can be an underflow if TPM_Init hasn't happened or the usual handle + // checks are skipped. Enter failure mode on this unexpected condition + if(handle < TRANSIENT_FIRST) + { + FAIL_NULL(FATAL_ERROR_ASSERT); + } + index = handle - TRANSIENT_FIRST; - pAssert(index < MAX_LOADED_OBJECTS); - pAssert(s_objects[index].attributes.occupied); + pAssert_NULL(index < MAX_LOADED_OBJECTS); + pAssert_NULL(s_objects[index].attributes.occupied); return &s_objects[index]; } @@ -385,7 +334,7 @@ ObjectLoad(OBJECT* object, // IN: pointer to object slot TPM_RC result = TPM_RC_SUCCESS; // // Do validations of public area object descriptions - pAssert(publicArea != NULL); + pAssert_RC(publicArea != NULL); // Is this public only or a no-name object? if(sensitive == NULL || publicArea->nameAlg == TPM_ALG_NULL) @@ -698,15 +647,16 @@ ObjectContextLoadLibtpms(BYTE *buffer, // This function frees an object slot. // // This function requires that the object is loaded. -void FlushObject(TPMI_DH_OBJECT handle // IN: handle to be freed +// returns FALSE and enters failure mode if the handle is invalid. +BOOL FlushObject(TPMI_DH_OBJECT handle // IN: handle to be freed ) { UINT32 index = handle - TRANSIENT_FIRST; - // - pAssert(index < MAX_LOADED_OBJECTS); + // checks for underflow due to unsigned math + pAssert_BOOL(index < MAX_LOADED_OBJECTS); // Clear all the object attributes MemorySet((BYTE*)&(s_objects[index].attributes), 0, sizeof(OBJECT_ATTRIBUTES)); - return; + return TRUE; } //*** ObjectFlushHierarchy() @@ -920,8 +870,8 @@ ObjectCapGetLoaded(TPMI_DH_OBJECT handle, // IN: start handle { TPMI_YES_NO more = NO; UINT32 i; - // - pAssert(HandleGetType(handle) == TPM_HT_TRANSIENT); + // enter failure mode and stop iterating if we encounter an internal error + VERIFY(HandleGetType(handle) == TPM_HT_TRANSIENT, FATAL_ERROR_INTERNAL, NO); // Initialize output handle list handleList->count = 0; @@ -936,7 +886,7 @@ ObjectCapGetLoaded(TPMI_DH_OBJECT handle, // IN: start handle if(s_objects[i].attributes.occupied == TRUE) { // A valid transient object can not be the copy of a persistent object - pAssert(s_objects[i].attributes.evict == CLEAR); + VERIFY(s_objects[i].attributes.evict == CLEAR, FATAL_ERROR_INTERNAL, NO); if(handleList->count < count) { @@ -964,7 +914,7 @@ BOOL ObjectCapGetOneLoaded(TPMI_DH_OBJECT handle) // IN: handle { UINT32 i; - pAssert(HandleGetType(handle) == TPM_HT_TRANSIENT); + pAssert_BOOL(HandleGetType(handle) == TPM_HT_TRANSIENT); // Iterate object slots to get loaded object handles for(i = handle - TRANSIENT_FIRST; i < MAX_LOADED_OBJECTS; i++) @@ -972,7 +922,7 @@ BOOL ObjectCapGetOneLoaded(TPMI_DH_OBJECT handle) // IN: handle if(s_objects[i].attributes.occupied == TRUE) { // A valid transient object can not be the copy of a persistent object - pAssert(s_objects[i].attributes.evict == CLEAR); + pAssert_BOOL(s_objects[i].attributes.evict == CLEAR); return TRUE; } diff --git a/src/tpm2/PCR.c b/src/tpm2/TPMCmd/tpm/src/subsystem/PCR.c similarity index 91% rename from src/tpm2/PCR.c rename to src/tpm2/TPMCmd/tpm/src/subsystem/PCR.c index 4b2dd9805..82032ba35 100644 --- a/src/tpm2/PCR.c +++ b/src/tpm2/TPMCmd/tpm/src/subsystem/PCR.c @@ -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 // @@ -75,6 +17,7 @@ //** Includes, Defines, and Data Definitions #define PCR_C #include "Tpm.h" +#include // verify values from pcrstruct.h. not <= because group #0 is reserved // indicating no auth/policy support @@ -117,7 +60,8 @@ BOOL PCRBelongsAuthGroup(TPMI_DH_PCR handle, // IN: handle of PCR pAssert_BOOL(*groupIndex < NUM_AUTHVALUE_PCR_GROUP); return TRUE; } - +#else + NOT_REFERENCED(handle); #endif return FALSE; } @@ -153,6 +97,8 @@ BOOL PCRBelongsPolicyGroup( pAssert_BOOL(*groupIndex < NUM_POLICY_PCR_GROUP); return TRUE; } +#else + NOT_REFERENCED(handle); #endif return FALSE; } @@ -172,6 +118,7 @@ static BOOL PCRBelongsTCBGroup(TPMI_DH_PCR handle // IN: handle of PCR _platPcr__GetPcrInitializationAttributes(pcr); return currentPcrAttributes.doNotIncrementPcrCounter; #else + NOT_REFERENCED(handle); return FALSE; #endif } @@ -195,6 +142,7 @@ BOOL PCRPolicyIsAvailable(TPMI_DH_PCR handle // IN: PCR handle TPM2B_AUTH* PCRGetAuthValue(TPMI_DH_PCR handle // IN: PCR handle ) { +#if defined NUM_AUTHVALUE_PCR_GROUP && NUM_AUTHVALUE_PCR_GROUP > 0 UINT32 groupIndex; if(PCRBelongsAuthGroup(handle, &groupIndex)) @@ -202,6 +150,9 @@ TPM2B_AUTH* PCRGetAuthValue(TPMI_DH_PCR handle // IN: PCR handle return &gc.pcrAuthValues.auth[groupIndex]; } else +#else + NOT_REFERENCED(handle); +#endif { return NULL; } @@ -216,6 +167,7 @@ PCRGetAuthPolicy(TPMI_DH_PCR handle, // IN: PCR handle TPM2B_DIGEST* policy // OUT: policy of PCR ) { +#if defined NUM_AUTHVALUE_PCR_GROUP && NUM_AUTHVALUE_PCR_GROUP > 0 UINT32 groupIndex; if(PCRBelongsPolicyGroup(handle, &groupIndex)) @@ -224,6 +176,9 @@ PCRGetAuthPolicy(TPMI_DH_PCR handle, // IN: PCR handle return gp.pcrPolicies.hashAlg[groupIndex]; } else +#else + NOT_REFERENCED(handle); +#endif { policy->t.size = 0; return TPM_ALG_NULL; @@ -271,7 +226,9 @@ void PCRManufacture(void) } // Store the initial configuration to NV +#if defined NUM_AUTHVALUE_PCR_GROUP && NUM_AUTHVALUE_PCR_GROUP > 0 NV_SYNC_PERSISTENT(pcrPolicies); +#endif NV_SYNC_PERSISTENT(pcrAllocated); return; @@ -804,7 +761,7 @@ void PCRExtend(TPMI_DH_PCR handle, // IN: PCR handle to be extended // // As a side-effect, 'selection' is modified so that only the implemented PCR // will have their bits still set. -void PCRComputeCurrentDigest( +TPM_RC PCRComputeCurrentDigest( TPMI_ALG_HASH hashAlg, // IN: hash algorithm to compute digest TPML_PCR_SELECTION* selection, // IN/OUT: PCR selection (filtered on // output) @@ -820,7 +777,7 @@ void PCRComputeCurrentDigest( // Initialize the hash digest->t.size = CryptHashStart(&hashState, hashAlg); - pAssert(digest->t.size > 0 && digest->t.size < UINT16_MAX); + pAssert_RC(digest->t.size > 0 && digest->t.size < UINT16_MAX); // Iterate through the list of PCR selection structures for(i = 0; i < selection->count; i++) @@ -839,7 +796,7 @@ void PCRComputeCurrentDigest( { // Get pointer to the digest data for the bank pcrData = GetPcrPointer(selection->pcrSelections[i].hash, pcr); - pAssert(pcrData != NULL); + pAssert_RC(pcrData != NULL); CryptDigestUpdate(&hashState, pcrSize, pcrData); // add to digest } } @@ -847,18 +804,18 @@ void PCRComputeCurrentDigest( // Complete hash stack CryptHashEnd2B(&hashState, &digest->b); - return; + return TPM_RC_SUCCESS; } //*** PCRRead() // This function is used to read a list of selected PCR. If the requested PCR // number exceeds the maximum number that can be output, the 'selection' is // adjusted to reflect the actual output PCR. -void PCRRead(TPML_PCR_SELECTION* selection, // IN/OUT: PCR selection (filtered on - // output) - TPML_DIGEST* digest, // OUT: digest - UINT32* pcrCounter // OUT: the current value of PCR generation - // number +TPM_RC PCRRead(TPML_PCR_SELECTION* selection, // IN/OUT: PCR selection (filtered on + // output) + TPML_DIGEST* digest, // OUT: digest + UINT32* pcrCounter // OUT: the current value of PCR generation + // number ) { TPMS_PCR_SELECTION* select; @@ -901,7 +858,7 @@ void PCRRead(TPML_PCR_SELECTION* selection, // IN/OUT: PCR selection (filtered // Get pointer to the digest data for the bank pcrData = GetPcrPointer(selection->pcrSelections[i].hash, pcr); - pAssert(pcrData != NULL); + pAssert_RC(pcrData != NULL); // Add to the data to digest MemoryCopy(digest->digests[digest->count].t.buffer, pcrData, @@ -927,7 +884,7 @@ void PCRRead(TPML_PCR_SELECTION* selection, // IN/OUT: PCR selection (filtered *pcrCounter = gr.pcrCounter; - return; + return TPM_RC_SUCCESS; } //*** PCRAllocate() @@ -972,7 +929,7 @@ PCRAllocate(TPML_PCR_SELECTION* allocate, // IN: required allocation } } // The j loop must exit with a match. - pAssert(j < newAllocate.count); + pAssert_RC(j < newAllocate.count); } // Max PCR in a bank is MIN(implemented PCR, PCR with attributes defined) @@ -993,7 +950,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) @@ -1310,7 +1267,7 @@ PCRCapGetHandles(TPMI_DH_PCR handle, // IN: start handle TPMI_YES_NO more = NO; UINT32 i; - pAssert(HandleGetType(handle) == TPM_HT_PCR); + VERIFY(HandleGetType(handle) == TPM_HT_PCR, FATAL_ERROR_INTERNAL, NO); // Initialize output handle list handleList->count = 0; @@ -1344,7 +1301,7 @@ PCRCapGetHandles(TPMI_DH_PCR handle, // IN: start handle // This function is used to check whether a PCR handle exists. BOOL PCRCapGetOneHandle(TPMI_DH_PCR handle) // IN: handle { - pAssert(HandleGetType(handle) == TPM_HT_PCR); + pAssert_BOOL(HandleGetType(handle) == TPM_HT_PCR); if((handle & HR_HANDLE_MASK) <= PCR_LAST) { diff --git a/src/tpm2/PP.c b/src/tpm2/TPMCmd/tpm/src/subsystem/PP.c similarity index 58% rename from src/tpm2/PP.c rename to src/tpm2/TPMCmd/tpm/src/subsystem/PP.c index facdcfbb5..6c1840035 100644 --- a/src/tpm2/PP.c +++ b/src/tpm2/TPMCmd/tpm/src/subsystem/PP.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, 2016 - 2023 */ -/* */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause //** Introduction // This file contains the functions that support the physical presence operations @@ -87,8 +29,7 @@ void PhysicalPresencePreInstall_Init(void) // Any command that is PP_REQUIRED should be SET for(commandIndex = 0; commandIndex < COMMAND_COUNT; commandIndex++) { - if(s_commandAttributes[commandIndex] & IS_IMPLEMENTED - && s_commandAttributes[commandIndex] & PP_REQUIRED) + if(s_commandAttributes[commandIndex] & PP_REQUIRED) SET_BIT(commandIndex, gp.ppList); } // Write PP list to NV diff --git a/src/tpm2/Session.c b/src/tpm2/TPMCmd/tpm/src/subsystem/Session.c similarity index 88% rename from src/tpm2/Session.c rename to src/tpm2/TPMCmd/tpm/src/subsystem/Session.c index 72ba096f3..f13308816 100644 --- a/src/tpm2/Session.c +++ b/src/tpm2/TPMCmd/tpm/src/subsystem/Session.c @@ -1,62 +1,4 @@ -/********************************************************************************/ -/* */ -/* Manage the session context counter */ -/* 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 /* @@ -170,8 +112,8 @@ static void ContextIdSetOldest(void) CONTEXT_SLOT entry; CONTEXT_SLOT smallest = CONTEXT_SLOT_MASKED(~0); // libtpms changed UINT32 i; - pAssert(s_ContextSlotMask == 0xff || s_ContextSlotMask == 0xffff); // libtpms added + pAssert_VOID_OK(s_ContextSlotMask == 0xff || s_ContextSlotMask == 0xffff); // libtpms added // Set oldestSaveContext to a value indicating none assigned s_oldestSavedSession = MAX_ACTIVE_SESSIONS + 1; lowBits = CONTEXT_SLOT_MASKED(gr.contextCounter); // libtpms changed @@ -265,8 +207,8 @@ BOOL SessionStartup(STARTUP_TYPE type) BOOL SessionIsLoaded(TPM_HANDLE handle // IN: session handle ) { - pAssert(HandleGetType(handle) == TPM_HT_POLICY_SESSION - || HandleGetType(handle) == TPM_HT_HMAC_SESSION); + pAssert_BOOL(HandleGetType(handle) == TPM_HT_POLICY_SESSION + || HandleGetType(handle) == TPM_HT_HMAC_SESSION); handle = handle & HR_HANDLE_MASK; @@ -294,8 +236,8 @@ BOOL SessionIsLoaded(TPM_HANDLE handle // IN: session handle BOOL SessionIsSaved(TPM_HANDLE handle // IN: session handle ) { - pAssert(HandleGetType(handle) == TPM_HT_POLICY_SESSION - || HandleGetType(handle) == TPM_HT_HMAC_SESSION); + pAssert_BOOL(HandleGetType(handle) == TPM_HT_POLICY_SESSION + || HandleGetType(handle) == TPM_HT_HMAC_SESSION); handle = handle & HR_HANDLE_MASK; // if out of range of possible active session, or not assigned, or @@ -364,18 +306,18 @@ SESSION* SessionGet(TPM_HANDLE handle // IN: session handle size_t slotIndex; CONTEXT_SLOT sessionIndex; - pAssert(HandleGetType(handle) == TPM_HT_POLICY_SESSION - || HandleGetType(handle) == TPM_HT_HMAC_SESSION); + pAssert_NULL(HandleGetType(handle) == TPM_HT_POLICY_SESSION + || HandleGetType(handle) == TPM_HT_HMAC_SESSION); slotIndex = handle & HR_HANDLE_MASK; - pAssert(slotIndex < MAX_ACTIVE_SESSIONS); + pAssert_NULL(slotIndex < MAX_ACTIVE_SESSIONS); // get the contents of the session array. Because session is loaded, we // should always get a valid sessionIndex sessionIndex = gr.contextArray[slotIndex] - 1; - pAssert(sessionIndex < MAX_LOADED_SESSIONS); + pAssert_NULL(sessionIndex < MAX_LOADED_SESSIONS); return &s_sessions[sessionIndex].session; } @@ -408,7 +350,7 @@ static TPM_RC ContextIdSessionCreate( // be occupied by the created session ) { - pAssert(sessionIndex < MAX_LOADED_SESSIONS); + pAssert_RC(sessionIndex < MAX_LOADED_SESSIONS); // check to see if creating the context is safe // Is this going to be an assignment for the last session context @@ -468,8 +410,8 @@ SessionCreate(TPM_SE sessionType, // IN: the session type CONTEXT_SLOT slotIndex; SESSION* session = NULL; - pAssert(sessionType == TPM_SE_HMAC || sessionType == TPM_SE_POLICY - || sessionType == TPM_SE_TRIAL); + pAssert_RC(sessionType == TPM_SE_HMAC || sessionType == TPM_SE_POLICY + || sessionType == TPM_SE_TRIAL); // If there are no open spots in the session array, then no point in searching if(s_freeSessionSlots == 0) @@ -554,7 +496,7 @@ SessionCreate(TPM_SE sessionType, // IN: the session type // Get authValue of associated entity EntityGetAuthValue(bind, (TPM2B_AUTH*)&key); - pAssert(key.t.size + seed->t.size <= sizeof(key.t.buffer)); + pAssert_RC((size_t)(key.t.size + seed->t.size) <= sizeof(key.t.buffer)); // Concatenate authValue and seed MemoryConcat2B(&key.b, &seed->b, sizeof(key.t.buffer)); @@ -610,7 +552,7 @@ SessionContextSave(TPM_HANDLE handle, // IN: session handle UINT32 contextIndex; CONTEXT_SLOT slotIndex; - pAssert(SessionIsLoaded(handle)); + pAssert_RC(SessionIsLoaded(handle)); pAssert(s_ContextSlotMask == 0xff || s_ContextSlotMask == 0xffff); // libtpms added // check to see if the gap is already maxed out @@ -626,7 +568,7 @@ SessionContextSave(TPM_HANDLE handle, // IN: session handle *contextID = gr.contextCounter; contextIndex = handle & HR_HANDLE_MASK; - pAssert(contextIndex < MAX_ACTIVE_SESSIONS); + pAssert_RC(contextIndex < MAX_ACTIVE_SESSIONS); // Extract the session slot number referenced by the contextArray // because we are going to overwrite this with the low order @@ -688,8 +630,8 @@ SessionContextLoad(SESSION_BUF* session, // IN: session structure from saved co CONTEXT_SLOT slotIndex; pAssert(s_ContextSlotMask == 0xff || s_ContextSlotMask == 0xffff); // libtpms added - pAssert(HandleGetType(*handle) == TPM_HT_POLICY_SESSION - || HandleGetType(*handle) == TPM_HT_HMAC_SESSION); + pAssert_RC(HandleGetType(*handle) == TPM_HT_POLICY_SESSION + || HandleGetType(*handle) == TPM_HT_HMAC_SESSION); // Don't bother looking if no openings if(s_freeSessionSlots == 0) @@ -701,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 @@ -718,7 +660,7 @@ SessionContextLoad(SESSION_BUF* session, // IN: session structure from saved co && contextIndex != s_oldestSavedSession) return TPM_RC_CONTEXT_GAP; - pAssert(contextIndex < MAX_ACTIVE_SESSIONS); + pAssert_RC(contextIndex < MAX_ACTIVE_SESSIONS); // set the contextArray value to point to the session slot where // the context is loaded @@ -753,15 +695,16 @@ void SessionFlush(TPM_HANDLE handle // IN: loaded or saved session handle CONTEXT_SLOT slotIndex; UINT32 contextIndex; // Index into contextArray - pAssert((HandleGetType(handle) == TPM_HT_POLICY_SESSION - || HandleGetType(handle) == TPM_HT_HMAC_SESSION) - && (SessionIsLoaded(handle) || SessionIsSaved(handle))); + pAssert_VOID_OK((HandleGetType(handle) == TPM_HT_POLICY_SESSION + || HandleGetType(handle) == TPM_HT_HMAC_SESSION) + && (SessionIsLoaded(handle) || SessionIsSaved(handle))); // Flush context ID of this session // Convert handle to an index into the contextArray contextIndex = handle & HR_HANDLE_MASK; - pAssert(contextIndex < sizeof(gr.contextArray) / sizeof(gr.contextArray[0])); + pAssert_VOID_OK( + contextIndex < sizeof(gr.contextArray) / sizeof(gr.contextArray[0])); // Get the current contents of the array slotIndex = gr.contextArray[contextIndex]; @@ -845,7 +788,7 @@ void SessionResetPolicyData(SESSION* session // IN: the session to reset ) { SESSION_ATTRIBUTES oldAttributes; - pAssert(session != NULL); + pAssert_VOID_OK(session != NULL); // Will need later oldAttributes = session->attributes; @@ -898,7 +841,7 @@ SessionCapGetLoaded(TPMI_SH_POLICY handle, // IN: start handle TPMI_YES_NO more = NO; UINT32 i; - pAssert(HandleGetType(handle) == TPM_HT_LOADED_SESSION); + VERIFY(HandleGetType(handle) == TPM_HT_LOADED_SESSION, FATAL_ERROR_ASSERT, NO); // Initialize output handle list handleList->count = 0; @@ -925,6 +868,7 @@ SessionCapGetLoaded(TPMI_SH_POLICY handle, // IN: start handle // assume that this is going to be an HMAC session handle = i + HMAC_SESSION_FIRST; session = SessionGet(handle); + VERIFY(session != NULL, FATAL_ERROR_ASSERT, NO); if(session->attributes.isPolicy) handle = i + POLICY_SESSION_FIRST; handleList->handle[handleList->count] = handle; @@ -948,7 +892,7 @@ SessionCapGetLoaded(TPMI_SH_POLICY handle, // IN: start handle // This function returns whether a session handle exists and is loaded. BOOL SessionCapGetOneLoaded(TPMI_SH_POLICY handle) // IN: handle { - pAssert(HandleGetType(handle) == TPM_HT_LOADED_SESSION); + pAssert_BOOL(HandleGetType(handle) == TPM_HT_LOADED_SESSION); if((handle & HR_HANDLE_MASK) < MAX_ACTIVE_SESSIONS && gr.contextArray[(handle & HR_HANDLE_MASK)]) @@ -1021,7 +965,7 @@ SessionCapGetSaved(TPMI_SH_HMAC handle, // IN: start handle // This function returns whether a session handle exists and is saved. BOOL SessionCapGetOneSaved(TPMI_SH_HMAC handle) // IN: handle { - pAssert(HandleGetType(handle) == TPM_HT_SAVED_SESSION); + pAssert_BOOL(HandleGetType(handle) == TPM_HT_SAVED_SESSION); if((handle & HR_HANDLE_MASK) < MAX_ACTIVE_SESSIONS && gr.contextArray[(handle & HR_HANDLE_MASK)]) @@ -1098,5 +1042,5 @@ SessionCapGetActiveAvail(void) BOOL IsCpHashUnionOccupied(SESSION_ATTRIBUTES attrs) { return attrs.isBound || attrs.isCpHashDefined || attrs.isNameHashDefined - || attrs.isParametersHashDefined || attrs.isTemplateHashDefined; + || attrs.isParametersHashDefined || attrs.isTemplateHashDefined; } diff --git a/src/tpm2/Time.c b/src/tpm2/TPMCmd/tpm/src/subsystem/Time.c similarity index 69% rename from src/tpm2/Time.c rename to src/tpm2/TPMCmd/tpm/src/subsystem/Time.c index a80a85963..4061bb2d8 100644 --- a/src/tpm2/Time.c +++ b/src/tpm2/TPMCmd/tpm/src/subsystem/Time.c @@ -1,62 +1,4 @@ -/********************************************************************************/ -/* */ -/* Functions relating to the TPM's time functions */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2016 - 2023 */ -/* */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause //** Introduction // This file contains the functions relating to the TPM's time functions including @@ -133,7 +75,7 @@ void TimeClockUpdate(UINT64 newTime // IN: New time value in mS. // Check to see if the update will cause a need for an nvClock update if((newTime | CLOCK_UPDATE_MASK) > (go.clock | CLOCK_UPDATE_MASK)) { - pAssert(g_NvStatus == TPM_RC_SUCCESS); + pAssert_VOID_OK(g_NvStatus == TPM_RC_SUCCESS); // Going to update the NV time state so SET the safe flag go.clockSafe = YES; diff --git a/src/tpm2/AlgorithmCap.c b/src/tpm2/TPMCmd/tpm/src/support/AlgorithmCap.c similarity index 70% rename from src/tpm2/AlgorithmCap.c rename to src/tpm2/TPMCmd/tpm/src/support/AlgorithmCap.c index d2becd807..2caf9ba26 100644 --- a/src/tpm2/AlgorithmCap.c +++ b/src/tpm2/TPMCmd/tpm/src/support/AlgorithmCap.c @@ -1,62 +1,4 @@ -/********************************************************************************/ -/* */ -/* Algorithm Property Definitions */ -/* 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 //** Description // This file contains the algorithm property definitions for the algorithms and the diff --git a/src/tpm2/TPMCmd/tpm/src/support/Bits.c b/src/tpm2/TPMCmd/tpm/src/support/Bits.c new file mode 100644 index 000000000..d95616170 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/src/support/Bits.c @@ -0,0 +1,56 @@ +// SPDX-License-Identifier: BSD-2-Clause + +//** Introduction +// This file contains bit manipulation routines. They operate on bit arrays. +// +// The 0th bit in the array is the right-most bit in the 0th octet in +// the array. + +//** Includes + +#include "Tpm.h" + +//** Functions + +//*** TestBit() +// This function is used to check the setting of a bit in an array of bits. +// Return Type: BOOL +// TRUE(1) bit is set +// FALSE(0) bit is not set +BOOL TestBit(unsigned int bitNum, // IN: number of the bit in 'bArray' + BYTE* bArray, // IN: array containing the bits + unsigned int bytesInArray // IN: size in bytes of 'bArray' +) +{ + NOT_REFERENCED(bytesInArray); // if assertions are disabled. + pAssert_BOOL(bytesInArray > (bitNum >> 3)); + return ((bArray[bitNum >> 3] & (1 << (bitNum & 7))) != 0); +} + +//*** SetBit() +// This function will set the indicated bit in 'bArray'. +void SetBit(unsigned int bitNum, // IN: number of the bit in 'bArray' + BYTE* bArray, // IN: array containing the bits + unsigned int bytesInArray // IN: size in bytes of 'bArray' +) +{ + NOT_REFERENCED(bytesInArray); // if assertions are disabled. + // failure will get checked at the end of the command processing, which + // is soon enough for SetBit use cases. + pAssert_VOID_OK(bytesInArray > (bitNum >> 3)); + bArray[bitNum >> 3] |= (1 << (bitNum & 7)); +} + +//*** ClearBit() +// This function will clear the indicated bit in 'bArray'. +void ClearBit(unsigned int bitNum, // IN: number of the bit in 'bArray'. + BYTE* bArray, // IN: array containing the bits + unsigned int bytesInArray // IN: size in bytes of 'bArray' +) +{ + NOT_REFERENCED(bytesInArray); // if assertions are disabled. + // failure will get checked at the end of the command processing, which + // is soon enough for ClearBit use cases. (command auditing, self-test, etc.) + pAssert_VOID_OK(bytesInArray > (bitNum >> 3)); + bArray[bitNum >> 3] &= ~(1 << (bitNum & 7)); +} diff --git a/src/tpm2/CommandCodeAttributes.c b/src/tpm2/TPMCmd/tpm/src/support/CommandCodeAttributes.c similarity index 81% rename from src/tpm2/CommandCodeAttributes.c rename to src/tpm2/TPMCmd/tpm/src/support/CommandCodeAttributes.c index fbba01f65..dd9b21e7d 100644 --- a/src/tpm2/CommandCodeAttributes.c +++ b/src/tpm2/TPMCmd/tpm/src/support/CommandCodeAttributes.c @@ -1,62 +1,4 @@ -/********************************************************************************/ -/* */ -/* Functions for testing various command properties */ -/* 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 functions for testing various command properties. @@ -84,7 +26,7 @@ typedef UINT16 ATTRIBUTE_TYPE; //** Command Attribute Functions -//*** NextImplementedIndex() +//*** NextImplementedIndex() // libtpms added begin // This function is used when the lists are not compressed. In a compressed list, // only the implemented commands are present. So, a search might find a value // but that value may not be implemented. This function checks to see if the input @@ -99,8 +41,7 @@ static COMMAND_INDEX NextImplementedIndex(COMMAND_INDEX commandIndex) { for(; commandIndex < COMMAND_COUNT; commandIndex++) { - if((s_commandAttributes[commandIndex] & IS_IMPLEMENTED) && // libtpms changed - RuntimeCommandsCheckEnabled(&g_RuntimeProfile.RuntimeCommands, // libtpms added begin + if(RuntimeCommandsCheckEnabled(&g_RuntimeProfile.RuntimeCommands, // libtpms added begin GET_ATTRIBUTE(s_ccAttr[commandIndex], TPMA_CC, commandIndex))) // libtpms added end return commandIndex; @@ -109,7 +50,7 @@ static COMMAND_INDEX NextImplementedIndex(COMMAND_INDEX commandIndex) } #else # define NextImplementedIndex(x) (x) -#endif +#endif // libtpms added end //*** GetClosestCommandIndex() // This function returns the command index for the command with a value that is @@ -137,7 +78,7 @@ GetClosestCommandIndex(TPM_CC commandCode // IN: the command code to start at // vendor-command, then it is out of range. if(vendor) { -#if VENDOR_COMMAND_ARRAY_SIZE > 0 +#if VENDOR_COMMAND_ARRAY_COUNT > 0 COMMAND_INDEX commandIndex; COMMAND_INDEX min; COMMAND_INDEX max; @@ -203,7 +144,7 @@ GetClosestCommandIndex(TPM_CC commandCode // IN: the command code to start at < searchIndex) { // requested index is out of the range to the top -#if VENDOR_COMMAND_ARRAY_SIZE > 0 +#if VENDOR_COMMAND_ARRAY_COUNT > 0 // If there are vendor commands, then the first vendor command // is the next value greater than the commandCode. // NOTE: we got here if the starting index did not have the V bit but we @@ -221,11 +162,11 @@ GetClosestCommandIndex(TPM_CC commandCode // IN: the command code to start at // the lowest value (needs to be an index for an implemented command if(GET_ATTRIBUTE(s_ccAttr[0], TPMA_CC, commandIndex) >= searchIndex) { - return NextImplementedIndex(0); + return NextImplementedIndex(0); // libtpms changed } else { -#if COMPRESSED_LISTS +#if COMPRESSED_LISTS // libtpms added COMMAND_INDEX commandIndex = UNIMPLEMENTED_COMMAND_INDEX; COMMAND_INDEX min = 0; COMMAND_INDEX max = LIBRARY_COMMAND_ARRAY_SIZE - 1; @@ -236,9 +177,11 @@ GetClosestCommandIndex(TPM_CC commandCode // IN: the command code to start at // The s_ccAttr array contains an extra entry at the end (a zero value). // Don't count this as an array entry. This means that max should start // out pointing to the last valid entry in the array which is - 2 - pAssert( - max - == (sizeof(s_ccAttr) / sizeof(TPMA_CC) - VENDOR_COMMAND_ARRAY_SIZE - 2)); + VERIFY(max + == (sizeof(s_ccAttr) / sizeof(TPMA_CC) - VENDOR_COMMAND_ARRAY_COUNT + - 2), + FATAL_ERROR_ASSERT, + UNIMPLEMENTED_COMMAND_INDEX); while(min <= max) { commandIndex = (min + max + 1) / 2; @@ -262,13 +205,13 @@ GetClosestCommandIndex(TPM_CC commandCode // IN: the command code to start at // Note: this will necessarily be in range because of the earlier check // that the index was within range. return commandIndex + 1; -#else +#else // libtpms added begin // The list is not compressed so offset into the array by the command // code value of the first entry in the list. Then go find the first // implemented command. return NextImplementedIndex( - searchIndex - (COMMAND_INDEX)GET_ATTRIBUTE(s_ccAttr[0], TPMA_CC, commandIndex)); // libtpms changed -#endif + searchIndex - (COMMAND_INDEX)GET_ATTRIBUTE(s_ccAttr[0], TPMA_CC, commandIndex)); +#endif // libtpms added end } } @@ -286,23 +229,22 @@ CommandCodeToCommandIndex(TPM_CC commandCode // IN: the command code to look up COMMAND_INDEX searchIndex = (COMMAND_INDEX)commandCode; BOOL vendor = (commandCode & CC_VEND) != 0; COMMAND_INDEX commandIndex; -#if !COMPRESSED_LISTS +#if !COMPRESSED_LISTS // libtpms added begin if(!vendor) { - commandIndex = searchIndex - (COMMAND_INDEX)GET_ATTRIBUTE(s_ccAttr[0], TPMA_CC, commandIndex); // libtpms changed + commandIndex = searchIndex - (COMMAND_INDEX)GET_ATTRIBUTE(s_ccAttr[0], TPMA_CC, commandIndex); // Check for out of range or unimplemented. // Note, since a COMMAND_INDEX is unsigned, if searchIndex is smaller than // the lowest value of command, it will become a 'negative' number making // it look like a large unsigned number, this will cause it to fail // the unsigned check below. if(commandIndex >= LIBRARY_COMMAND_ARRAY_SIZE - || (s_commandAttributes[commandIndex] & IS_IMPLEMENTED) == 0 - || !RuntimeCommandsCheckEnabled(&g_RuntimeProfile.RuntimeCommands, // libtpms added - commandCode)) // libtpms added + || !RuntimeCommandsCheckEnabled(&g_RuntimeProfile.RuntimeCommands, + commandCode)) return UNIMPLEMENTED_COMMAND_INDEX; return commandIndex; } -#endif +#endif // libtpms added end // Need this code for any vendor code lookup or for compressed lists commandIndex = GetClosestCommandIndex(commandCode); @@ -336,10 +278,7 @@ GetNextCommandIndex(COMMAND_INDEX commandIndex // IN: the starting index GET_ATTRIBUTE(s_ccAttr[commandIndex], TPMA_CC, commandIndex))) continue; // libtpms added end -#if !COMPRESSED_LISTS - if(s_commandAttributes[commandIndex] & IS_IMPLEMENTED) -#endif - return commandIndex; + return commandIndex; } return UNIMPLEMENTED_COMMAND_INDEX; } @@ -442,6 +381,13 @@ BOOL IsHandleInResponse(COMMAND_INDEX commandIndex) return ((s_commandAttributes[commandIndex] & R_HANDLE) != 0); } +//*** IsDisallowedInReadOnlyMode() +// This function determines if a command is disallowed when operating in Read-Only mode +BOOL IsDisallowedInReadOnlyMode(COMMAND_INDEX commandIndex) +{ + return ((s_commandAttributes[commandIndex] & RO_DISALLOW) != 0); +} + //*** IsWriteOperation() // Checks to see if an operation will write to an NV Index and is subject to being // blocked by read-lock @@ -534,15 +480,10 @@ CommandCapGetCCList(TPM_CC commandCode, // IN: start command code commandIndex != UNIMPLEMENTED_COMMAND_INDEX; commandIndex = GetNextCommandIndex(commandIndex)) { -#if !COMPRESSED_LISTS - // this check isn't needed for compressed lists. - if(!(s_commandAttributes[commandIndex] & IS_IMPLEMENTED)) - continue; -#endif - if (!RuntimeCommandsCheckEnabled(&g_RuntimeProfile.RuntimeCommands, // libtpms added begin + if (!RuntimeCommandsCheckEnabled(&g_RuntimeProfile.RuntimeCommands, // libtpms added begin GET_ATTRIBUTE(s_ccAttr[commandIndex], TPMA_CC, commandIndex))) - continue; // libtpms added end + continue; // libtpms added end if(commandList->count < count) { // If the list is not full, add the attributes for this command. diff --git a/src/tpm2/Entity.c b/src/tpm2/TPMCmd/tpm/src/support/Entity.c similarity index 80% rename from src/tpm2/Entity.c rename to src/tpm2/TPMCmd/tpm/src/support/Entity.c index 7d38e67e4..5030f3f71 100644 --- a/src/tpm2/Entity.c +++ b/src/tpm2/TPMCmd/tpm/src/support/Entity.c @@ -1,62 +1,4 @@ -/********************************************************************************/ -/* */ -/* Accessing properties for handles of various types */ -/* 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 - 2024 */ -/* */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause //** Description // The functions in this file are used for accessing properties for handles of @@ -66,6 +8,7 @@ //** Includes #include "Tpm.h" +#include //** Functions //*** EntityGetLoadStatus() @@ -149,6 +92,7 @@ EntityGetLoadStatus(COMMAND* command // IN/OUT: command parsing structure { SESSION* session; session = SessionGet(handle); + pAssert_RC(session != NULL); // Check if the session is a HMAC session if(session->attributes.isPolicy == SET) result = TPM_RC_HANDLE; @@ -164,6 +108,7 @@ EntityGetLoadStatus(COMMAND* command // IN/OUT: command parsing structure { SESSION* session; session = SessionGet(handle); + pAssert_RC(session != NULL); // Check if the session is a policy session if(session->attributes.isPolicy == CLEAR) result = TPM_RC_HANDLE; @@ -172,10 +117,14 @@ EntityGetLoadStatus(COMMAND* command // IN/OUT: command parsing structure result = TPM_RC_REFERENCE_H0; break; case TPM_HT_NV_INDEX: - // For an NV Index, use the TPM-specific routine + { + // For an NV Index, use the platform-specific routine // to search the IN Index space. - result = NvIndexIsAccessible(handle); + BOOL commandAcceptsVirtualHandles = + _plat__NvOperationAcceptsVirtualHandles(command->index); + result = NvIndexIsAccessible(handle, commandAcceptsVirtualHandles); break; + } case TPM_HT_PCR: // Any PCR handle that is unmarshaled successfully referenced // a PCR that is defined. @@ -223,9 +172,11 @@ EntityGetAuthValue(TPMI_DH_ENTITY handle, // IN: handle of entity TPM2B_AUTH* auth // OUT: authValue of the entity ) { - TPM2B_AUTH* pAuth = NULL; + TPM2B_AUTH* pAuth = NULL; + NV_INDEX* nvIndex = NULL; + NV_INDEX tempIndex = {0}; - auth->t.size = 0; + auth->t.size = 0; switch(HandleGetType(handle)) { @@ -288,7 +239,7 @@ EntityGetAuthValue(TPMI_DH_ENTITY handle, // IN: handle of entity // Authorization is available only when the private portion of // the object is loaded. The check should be made before // this function is called - pAssert(object->attributes.publicOnly == CLEAR); + pAssert_ZERO(object && object->attributes.publicOnly == CLEAR); pAuth = &object->sensitive.authValue; } } @@ -296,8 +247,18 @@ EntityGetAuthValue(TPMI_DH_ENTITY handle, // IN: handle of entity case TPM_HT_NV_INDEX: // authValue for an NV index { - NV_INDEX* nvIndex = NvGetIndexInfo(handle, NULL); - pAssert(nvIndex != NULL); + if(_plat__IsNvVirtualIndex(handle)) + { + _plat__NvVirtual_PopulateNvIndexInfo( + handle, &tempIndex.publicArea, &tempIndex.authValue); + nvIndex = &tempIndex; + } + else + { + nvIndex = NvGetIndexInfo(handle, NULL); + } + pAssert_ZERO(nvIndex != NULL); + pAuth = &nvIndex->authValue; } break; @@ -376,15 +337,31 @@ EntityGetAuthPolicy(TPMI_DH_ENTITY handle, // IN: handle of entity // authPolicy for an object { OBJECT* object = HandleToObject(handle); - *authPolicy = object->publicArea.authPolicy; - hashAlg = object->publicArea.nameAlg; + GOTO_ERROR_UNLESS(object != NULL); + *authPolicy = object->publicArea.authPolicy; + hashAlg = object->publicArea.nameAlg; } break; case TPM_HT_NV_INDEX: // authPolicy for a NV index { - NV_INDEX* nvIndex = NvGetIndexInfo(handle, NULL); - pAssert(nvIndex != 0); + NV_INDEX* nvIndex = NvGetIndexInfo(handle, NULL); + NV_INDEX tempNvIndex = {0}; + if(nvIndex == NULL) + { + if(!_plat__IsNvVirtualIndex(handle)) + { + FAIL_IMMEDIATE(FATAL_ERROR_INTERNAL, TPM_ALG_NULL); + } + else + { + _plat__NvVirtual_PopulateNvIndexInfo( + handle, &tempNvIndex.publicArea, &tempNvIndex.authValue); + nvIndex = &tempNvIndex; + } + } + // nvIndex guaranteed non-null at this point. + *authPolicy = nvIndex->publicArea.authPolicy; hashAlg = nvIndex->publicArea.nameAlg; } @@ -398,6 +375,7 @@ EntityGetAuthPolicy(TPMI_DH_ENTITY handle, // IN: handle of entity FAIL(FATAL_ERROR_INTERNAL); break; } +Error: return hashAlg; } @@ -413,8 +391,17 @@ TPM2B_NAME* EntityGetName(TPMI_DH_ENTITY handle, // IN: handle of entity { // Name for an object OBJECT* object = HandleToObject(handle); - // an object with no nameAlg has no name - if(object->publicArea.nameAlg == TPM_ALG_NULL) + + if(object == NULL) + { + // should not have gotten in this function in this case but we + // can safely enter failure mode and return an empty name + // through the if statement below. + FAIL_NORET(FATAL_ERROR_ASSERT); + } + + // an invalid object or an object with no nameAlg has no name + if(object == NULL || object->publicArea.nameAlg == TPM_ALG_NULL) name->b.size = 0; else *name = object->name; @@ -474,16 +461,35 @@ EntityGetHierarchy(TPMI_DH_ENTITY handle // IN :handle of entity // hierarchy for NV index { NV_INDEX* nvIndex = NvGetIndexInfo(handle, NULL); - pAssert(nvIndex != NULL); + if(nvIndex == NULL) + { + if(!_plat__IsNvVirtualIndex(handle)) + { + FAIL_IMMEDIATE(FATAL_ERROR_INTERNAL, TPM_RH_NULL); + } + else + { + NV_INDEX tempNvIndex = {0}; + _plat__NvVirtual_PopulateNvIndexInfo( + handle, &tempNvIndex.publicArea, &tempNvIndex.authValue); + nvIndex = &tempNvIndex; + } + } + // nvIndex guaranteed non-null at this point. // If only the platform can delete the index, then it is // considered to be in the platform hierarchy, otherwise it // is in the owner hierarchy. - if(IS_ATTRIBUTE( + if(nvIndex != NULL + && IS_ATTRIBUTE( nvIndex->publicArea.attributes, TPMA_NV, PLATFORMCREATE)) + { hierarchy = TPM_RH_PLATFORM; + } else + { hierarchy = TPM_RH_OWNER; + } } break; case TPM_HT_TRANSIENT: @@ -491,6 +497,8 @@ EntityGetHierarchy(TPMI_DH_ENTITY handle // IN :handle of entity { OBJECT* object; object = HandleToObject(handle); + VERIFY(object != NULL, FATAL_ERROR_ASSERT, TPM_RH_NULL); + if(object->attributes.ppsHierarchy) { hierarchy = TPM_RH_PLATFORM; diff --git a/src/tpm2/Global.c b/src/tpm2/TPMCmd/tpm/src/support/Global.c similarity index 53% rename from src/tpm2/Global.c rename to src/tpm2/TPMCmd/tpm/src/support/Global.c index 1ba989d8b..efaa1b68c 100644 --- a/src/tpm2/Global.c +++ b/src/tpm2/TPMCmd/tpm/src/support/Global.c @@ -1,62 +1,4 @@ -/********************************************************************************/ -/* */ -/* TPM variables that are not stack allocated */ -/* 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 - 2024 */ -/* */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause //** Description // This file will instance the TPM variables that are not stack allocated. @@ -143,3 +85,4 @@ const UINT16 g_rcIndex[15] = {TPM_RC_1, TPM_RC_F}; BOOL g_manufactured = FALSE; +BOOL g_initCompleted = FALSE; diff --git a/src/tpm2/Handle.c b/src/tpm2/TPMCmd/tpm/src/support/Handle.c similarity index 67% rename from src/tpm2/Handle.c rename to src/tpm2/TPMCmd/tpm/src/support/Handle.c index 46041719f..12246c253 100644 --- a/src/tpm2/Handle.c +++ b/src/tpm2/TPMCmd/tpm/src/support/Handle.c @@ -1,62 +1,4 @@ -/********************************************************************************/ -/* */ -/* fUnctions that return the type of a handle. */ -/* 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 //** Description // This file contains the functions that return the type of a handle. @@ -159,7 +101,7 @@ PermanentCapGetHandles(TPM_HANDLE handle, // IN: start handle TPMI_YES_NO more = NO; UINT32 i; - pAssert(HandleGetType(handle) == TPM_HT_PERMANENT); + VERIFY(HandleGetType(handle) == TPM_HT_PERMANENT, FATAL_ERROR_ASSERT, NO); // Initialize output handle list handleList->count = 0; @@ -195,7 +137,7 @@ BOOL PermanentCapGetOneHandle(TPM_HANDLE handle) // IN: handle { UINT32 i; - pAssert(HandleGetType(handle) == TPM_HT_PERMANENT); + pAssert_BOOL(HandleGetType(handle) == TPM_HT_PERMANENT); // Iterate permanent handle range for(i = NextPermanentHandle(handle); i != 0; i = NextPermanentHandle(i + 1)) @@ -223,7 +165,7 @@ PermanentHandleGetPolicy(TPM_HANDLE handle, // IN: start handle { TPMI_YES_NO more = NO; - pAssert(HandleGetType(handle) == TPM_HT_PERMANENT); + VERIFY(HandleGetType(handle) == TPM_HT_PERMANENT, FATAL_ERROR_ASSERT, NO); // Initialize output handle list policyList->count = 0; @@ -270,7 +212,7 @@ BOOL PermanentHandleGetOnePolicy(TPM_HANDLE handle, // IN: handle TPMS_TAGGED_POLICY* policy // OUT: tagged policy ) { - pAssert(HandleGetType(handle) == TPM_HT_PERMANENT); + pAssert_BOOL(HandleGetType(handle) == TPM_HT_PERMANENT); if(NextPermanentHandle(handle) == handle) { diff --git a/src/tpm2/TPMCmd/tpm/src/support/IoBuffers.c b/src/tpm2/TPMCmd/tpm/src/support/IoBuffers.c new file mode 100644 index 000000000..17e152dd3 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/src/support/IoBuffers.c @@ -0,0 +1,80 @@ +// SPDX-License-Identifier: BSD-2-Clause + + +//** Includes and Data Definitions + +// This definition allows this module to "see" the values that are private +// to this module but kept in Global.c for ease of state migration. +#define IO_BUFFER_C +#include "Tpm.h" +#include "IoBuffers_fp.h" + +//** Buffers and Functions + +// These buffers are set aside to hold command and response values. In this +// implementation, it is not guaranteed that the code will stop accessing +// the s_actionInputBuffer before starting to put values in the +// s_actionOutputBuffer so different buffers are required. +// + +//*** MemoryIoBufferAllocationReset() +// This function is used to reset the allocation of buffers. +void MemoryIoBufferAllocationReset(void) +{ + s_actionIoAllocation = 0; +} + +//*** MemoryIoBufferZero() +// Function zeros the action I/O buffer at the end of a command. Calling this is +// not mandatory for proper functionality. +void MemoryIoBufferZero(void) +{ + memset(s_actionIoBuffer, 0, s_actionIoAllocation); +} + +//*** MemoryGetInBuffer() +// This function returns the address of the buffer into which the +// command parameters will be unmarshaled in preparation for calling +// the command actions. +BYTE* MemoryGetInBuffer(UINT32 size // Size, in bytes, required for the input + // unmarshaling +) +{ + pAssert_NULL(size <= sizeof(s_actionIoBuffer)); +// In this implementation, a static buffer is set aside for the command action +// buffers. The buffer is shared between input and output. This is because +// there is no need to allocate for the worst case input and worst case output +// at the same time. +// Round size up +#define UoM (sizeof(s_actionIoBuffer[0])) + size = (size + (UoM - 1)) & (UINT32_MAX - (UoM - 1)); + memset(s_actionIoBuffer, 0, size); + s_actionIoAllocation = size; + return (BYTE*)&s_actionIoBuffer[0]; +} + +//*** MemoryGetOutBuffer() +// This function returns the address of the buffer into which the command +// action code places its output values. +BYTE* MemoryGetOutBuffer(UINT32 size // required size of the buffer +) +{ + BYTE* retVal = (BYTE*)(&s_actionIoBuffer[s_actionIoAllocation / UoM]); + pAssert_NULL((size + s_actionIoAllocation) < (sizeof(s_actionIoBuffer))); + // In this implementation, a static buffer is set aside for the command action + // output buffer. + memset(retVal, 0, size); + s_actionIoAllocation += size; + return retVal; +} + +//*** IsLabelProperlyFormatted() +// This function checks that a label is a null-terminated string. +// NOTE: this function is here because there was no better place for it. +// Return Type: BOOL +// TRUE(1) string is null terminated +// FALSE(0) string is not null terminated +BOOL IsLabelProperlyFormatted(TPM2B* x) +{ + return (((x)->size == 0) || ((x)->buffer[(x)->size - 1] == 0)); +} diff --git a/src/tpm2/TPMCmd/tpm/src/support/Locality.c b/src/tpm2/TPMCmd/tpm/src/support/Locality.c new file mode 100644 index 000000000..88ba47ca4 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/src/support/Locality.c @@ -0,0 +1,42 @@ +// SPDX-License-Identifier: BSD-2-Clause + +//** Includes +#include "Tpm.h" + +//** LocalityGetAttributes() +// This function will convert a locality expressed as an integer into +// TPMA_LOCALITY form. +// +// The function returns the locality attribute. +TPMA_LOCALITY +LocalityGetAttributes(UINT8 locality // IN: locality value +) +{ + TPMA_LOCALITY locality_attributes; + BYTE* localityAsByte = (BYTE*)&locality_attributes; + + MemorySet(&locality_attributes, 0, sizeof(TPMA_LOCALITY)); + switch(locality) + { + case 0: + SET_ATTRIBUTE(locality_attributes, TPMA_LOCALITY, TPM_LOC_ZERO); + break; + case 1: + SET_ATTRIBUTE(locality_attributes, TPMA_LOCALITY, TPM_LOC_ONE); + break; + case 2: + SET_ATTRIBUTE(locality_attributes, TPMA_LOCALITY, TPM_LOC_TWO); + break; + case 3: + SET_ATTRIBUTE(locality_attributes, TPMA_LOCALITY, TPM_LOC_THREE); + break; + case 4: + SET_ATTRIBUTE(locality_attributes, TPMA_LOCALITY, TPM_LOC_FOUR); + break; + default: + VERIFY(locality > 31, FATAL_ERROR_ASSERT, 0); + *localityAsByte = locality; + break; + } + return locality_attributes; +} diff --git a/src/tpm2/Manufacture.c b/src/tpm2/TPMCmd/tpm/src/support/Manufacture.c similarity index 63% rename from src/tpm2/Manufacture.c rename to src/tpm2/TPMCmd/tpm/src/support/Manufacture.c index 1ff8bdf42..527e64a52 100644 --- a/src/tpm2/Manufacture.c +++ b/src/tpm2/TPMCmd/tpm/src/support/Manufacture.c @@ -1,62 +1,4 @@ -/********************************************************************************/ -/* */ -/* Performs the manufacturing of the TPM */ -/* 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 //** Description // This file contains the function that performs the "manufacturing" of the TPM @@ -117,7 +59,7 @@ LIB_EXPORT int TPM_Manufacture( // trigger failure mode if called in error. int nvReadyState = _plat__GetNvReadyState(); - pAssert(nvReadyState == NV_READY); // else failure mode + pAssert_NORET(nvReadyState == NV_READY); // else failure mode if(nvReadyState != NV_READY) { return MANUF_NV_NOT_READY; @@ -216,6 +158,7 @@ LIB_EXPORT int TPM_TearDown(void) { RuntimeProfileFree(&g_RuntimeProfile); // libtpms added g_manufactured = FALSE; + g_initCompleted = FALSE; return TEARDOWN_OK; } diff --git a/src/tpm2/Marshal.c b/src/tpm2/TPMCmd/tpm/src/support/Marshal.c similarity index 93% rename from src/tpm2/Marshal.c rename to src/tpm2/TPMCmd/tpm/src/support/Marshal.c index 7c77a4d5b..23d1eb600 100644 --- a/src/tpm2/Marshal.c +++ b/src/tpm2/TPMCmd/tpm/src/support/Marshal.c @@ -1,64 +1,43 @@ +// SPDX-License-Identifier: BSD-2-Clause + /********************************************************************************/ /* */ /* Parameter Marshaling */ /* 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 */ +/* (c) Copyright IBM Corporation 2015 - 2026. */ /* */ +/* All rights reserved. */ +/* */ +/* Redistribution and use in source and binary forms, with or without */ +/* modification, are permitted provided that the following conditions are */ +/* met: */ +/* */ +/* Redistributions of source code must retain the above copyright notice, */ +/* this list of conditions and the following disclaimer. */ +/* */ +/* Redistributions in binary form must reproduce the above copyright */ +/* notice, this list of conditions and the following disclaimer in the */ +/* documentation and/or other materials provided with the distribution. */ +/* */ +/* Neither the names of the IBM Corporation nor the names of its */ +/* contributors may be used to endorse or promote products derived from */ +/* this software without specific prior written permission. */ +/* */ +/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */ +/* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */ +/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR */ +/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */ +/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */ +/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */ +/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, */ +/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY */ +/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */ +/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE */ +/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /********************************************************************************/ - #include // libtpms added #include @@ -713,6 +692,20 @@ TPMS_ACT_DATA_Marshal(TPMS_ACT_DATA *source, BYTE **buffer, INT32 *size) return written; } +# if SEC_CHANNEL_SUPPORT +// Table "Definition of TPMS_SPDM_SESSION_INFO Structure" (Part 2: Structures) + +UINT16 +TPMS_SPDM_SESSION_INFO_Marshal(TPMS_SPDM_SESSION_INFO* source, BYTE** buffer, INT32* size) +{ + UINT16 written = 0; + + written += TPM2B_NAME_Marshal((TPM2B_NAME*)&(source->reqKeyName), buffer, size); + written += TPM2B_NAME_Marshal((TPM2B_NAME*)&(source->tpmKeyName), buffer, size); + return written; +} +# endif // SEC_CHANNEL_SUPPORT + /* Table 2:94 - Definition of TPMS_TAGGED_PROPERTY Structure (StructuresTable()) */ UINT16 @@ -922,6 +915,38 @@ TPML_ACT_DATA_Marshal(TPML_ACT_DATA *source, BYTE **buffer, INT32 *size) return written; } +# if SEC_CHANNEL_SUPPORT +// Table "Definition of TPML_PUB_KEY Structure" (Part 2: Structures) +UINT16 +TPML_PUB_KEY_Marshal(TPML_PUB_KEY* source, BYTE** buffer, INT32* size) +{ + UINT16 written = 0; + + written += UINT32_Marshal((UINT32*)&(source->count), buffer, size); + written += TPM2B_PUBLIC_Array_Marshal((TPM2B_PUBLIC*)&(source->pubKeys), + buffer, + size, + (INT32)source->count); + return written; +} + +// Table "Definition of TPML_SPDM_SESSION_INFO Structure" (Part 2: Structures) + +UINT16 +TPML_SPDM_SESSION_INFO_Marshal(TPML_SPDM_SESSION_INFO* source, BYTE** buffer, INT32* size) +{ + UINT16 written = 0; + + written += UINT32_Marshal((UINT32*)&(source->count), buffer, size); + written += TPMS_SPDM_SESSION_INFO_Array_Marshal( + (TPMS_SPDM_SESSION_INFO*)&(source->spdmSessionInfo), + buffer, + size, + (INT32)source->count); + return written; +} +# endif // SEC_CHANNEL_SUPPORT + /* Table 2:110 - Definition of TPMU_CAPABILITIES Union (StructuresTable()) */ UINT16 @@ -963,6 +988,15 @@ TPMU_CAPABILITIES_Marshal(TPMU_CAPABILITIES *source, BYTE **buffer, INT32 *size, case TPM_CAP_ACT: written += TPML_ACT_DATA_Marshal(&source->actData, buffer, size); break; +# if SEC_CHANNEL_SUPPORT + case TPM_CAP_PUB_KEYS: + written += TPML_PUB_KEY_Marshal((TPML_PUB_KEY*)&(source->pubKeys), buffer, size); + break; + case TPM_CAP_SPDM_SESSION_INFO: + written += TPML_SPDM_SESSION_INFO_Marshal( + (TPML_SPDM_SESSION_INFO*)&(source->spdmSessionInfo), buffer, size); + break; +# endif // SEC_CHANNEL_SUPPORT default: pAssert(FALSE); } @@ -2401,3 +2435,35 @@ TPML_AC_CAPABILITIES_Marshal(TPML_AC_CAPABILITIES *source, BYTE **buffer, INT32 return written; } +# if SEC_CHANNEL_SUPPORT +// Array Marshal for TPM2B_PUBLIC +UINT16 +TPM2B_PUBLIC_Array_Marshal( + TPM2B_PUBLIC* source, BYTE** buffer, INT32* size, INT32 count) +{ + UINT16 written = 0; + INT32 i; + + for(i = 0; i < count; i++) + { + written += TPM2B_PUBLIC_Marshal(&source[i], buffer, size); + } + return written; +} + +// Array Marshal for TPMS_SPDM_SESSION_INFO +UINT16 +TPMS_SPDM_SESSION_INFO_Array_Marshal( + TPMS_SPDM_SESSION_INFO* source, BYTE** buffer, INT32* size, INT32 count) +{ + UINT16 written = 0; + INT32 i; + + for(i = 0; i < count; i++) + { + written += TPMS_SPDM_SESSION_INFO_Marshal(&source[i], buffer, size); + } + return written; +} + +# endif // SEC_CHANNEL_SUPPORT \ No newline at end of file diff --git a/src/tpm2/MathOnByteBuffers.c b/src/tpm2/TPMCmd/tpm/src/support/MathOnByteBuffers.c similarity index 67% rename from src/tpm2/MathOnByteBuffers.c rename to src/tpm2/TPMCmd/tpm/src/support/MathOnByteBuffers.c index da7d0a9ed..ece710147 100644 --- a/src/tpm2/MathOnByteBuffers.c +++ b/src/tpm2/TPMCmd/tpm/src/support/MathOnByteBuffers.c @@ -1,62 +1,4 @@ -/********************************************************************************/ -/* */ -/* Math functions performed with canonical integers in byte buffers */ -/* 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 // diff --git a/src/tpm2/Memory.c b/src/tpm2/TPMCmd/tpm/src/support/Memory.c similarity index 61% rename from src/tpm2/Memory.c rename to src/tpm2/TPMCmd/tpm/src/support/Memory.c index 7b15026aa..9ade6c610 100644 --- a/src/tpm2/Memory.c +++ b/src/tpm2/TPMCmd/tpm/src/support/Memory.c @@ -1,63 +1,4 @@ -/********************************************************************************/ -/* */ -/* Miscellaneous Memory Manipulation Routines */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: Memory.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, 2016 - 2021 */ -/* */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause //** Description // This file contains a set of miscellaneous memory manipulation routines. Many @@ -116,12 +57,12 @@ LIB_EXPORT INT16 MemoryCopy2B(TPM2B* dest, // OUT: receiving TPM2B unsigned int dSize // IN: size of the receiving buffer ) { - pAssert(dest != NULL); - if(source == NULL) - dest->size = 0; - else + pAssert_ZERO(dest != NULL); + dest->size = 0; + if(source != NULL) { - pAssert(source->size <= dSize); + NOT_REFERENCED(dSize); // if pAsserts compiled out. + pAssert_ZERO(source->size <= dSize); MemoryCopy(dest->buffer, source->buffer, source->size); dest->size = source->size; } @@ -139,7 +80,9 @@ void MemoryConcat2B( // aInOut.size) ) { - pAssert(bIn->size <= aMaxSize - aInOut->size); + NOT_REFERENCED(aMaxSize); // if pAsserts compiled out. + // if won't fit, enter failure mode and return unchanged. + pAssert_VOID_OK(bIn->size <= aMaxSize - aInOut->size); MemoryCopy(&aInOut->buffer[aInOut->size], &bIn->buffer, bIn->size); aInOut->size = aInOut->size + bIn->size; return; diff --git a/src/tpm2/TPMCmd/tpm/src/support/Power.c b/src/tpm2/TPMCmd/tpm/src/support/Power.c new file mode 100644 index 000000000..e9b0c9531 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/src/support/Power.c @@ -0,0 +1,41 @@ +// SPDX-License-Identifier: BSD-2-Clause + +//** Description + +// This file contains functions that receive the simulated power state +// transitions of the TPM. + +//** Includes and Data Definitions +#define POWER_C +#include "Tpm.h" + +//** Functions + +//*** TPMInit() +// This function is used to process a power on event. +void TPMInit(void) +{ + // Set state as not initialized. This means that Startup is required + g_initialized = FALSE; + return; +} + +//*** TPMRegisterStartup() +// This function registers the fact that the TPM has been initialized +// (a TPM2_Startup() has completed successfully). +BOOL TPMRegisterStartup(void) +{ + g_initialized = TRUE; + return TRUE; +} + +//*** TPMIsStarted() +// Indicates if the TPM has been initialized (a TPM2_Startup() has completed +// successfully after a _TPM_Init). +// Return Type: BOOL +// TRUE(1) TPM has been initialized +// FALSE(0) TPM has not been initialized +BOOL TPMIsStarted(void) +{ + return g_initialized; +} diff --git a/src/tpm2/PropertyCap.c b/src/tpm2/TPMCmd/tpm/src/support/PropertyCap.c similarity index 79% rename from src/tpm2/PropertyCap.c rename to src/tpm2/TPMCmd/tpm/src/support/PropertyCap.c index ffc89d622..1a36751f9 100644 --- a/src/tpm2/PropertyCap.c +++ b/src/tpm2/TPMCmd/tpm/src/support/PropertyCap.c @@ -1,62 +1,5 @@ -/********************************************************************************/ -/* */ -/* For accessing the TPM_CAP_TPM_PROPERTY values */ -/* 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 - 2025 */ -/* */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause + //** Description // This file contains the functions that are used for accessing the // TPM_CAP_TPM_PROPERTY values. @@ -69,6 +12,9 @@ #include "tpm_library_intern.h" // libtpms added //** Functions +const char TPM_PT_FAMILY_INDICATOR_VALUE[] = "2.0"; +TPM_STATIC_ASSERT(sizeof(TPM_PT_FAMILY_INDICATOR_VALUE) == sizeof(UINT32)); + //*** TPMPropertyIsDefined() // This function accepts a property selection and, if so, sets 'value' // to the value of the property. @@ -83,28 +29,30 @@ static BOOL TPMPropertyIsDefined(TPM_PT property, // IN: property UINT32* value // OUT: property value ) { + SPEC_CAPABILITY_VALUE spec_capability_value = {0}; + _plat_GetSpecCapabilityValue(&spec_capability_value); switch(property) { case TPM_PT_FAMILY_INDICATOR: // from the title page of the specification // For this specification, the value is "2.0". - *value = TPM_SPEC_FAMILY; + *value = BYTE_ARRAY_TO_UINT32(TPM_PT_FAMILY_INDICATOR_VALUE); break; case TPM_PT_LEVEL: // from the title page of the specification - *value = TPM_SPEC_LEVEL; + *value = spec_capability_value.tpmSpecLevel; break; case TPM_PT_REVISION: // from the title page of the specification - *value = TPM_SPEC_VERSION; + *value = spec_capability_value.tpmSpecVersion; break; case TPM_PT_DAY_OF_YEAR: // computed from the date value on the title page of the specification - *value = TPM_SPEC_DAY_OF_YEAR; + *value = spec_capability_value.tpmSpecDayOfYear; break; case TPM_PT_YEAR: // from the title page of the specification - *value = TPM_SPEC_YEAR; + *value = spec_capability_value.tpmSpecYear; break; case TPM_PT_MANUFACTURER: @@ -135,15 +83,19 @@ static BOOL TPMPropertyIsDefined(TPM_PT property, // IN: property case TPM_PT_VENDOR_TPM_TYPE: // vendor-defined value indicating the TPM model // We just make up a number here - *value = _plat__GetTpmType(); + *value = _plat__GetVendorTpmType(); break; case TPM_PT_FIRMWARE_VERSION_1: // more significant 32-bits of a vendor-specific value + // note this value originates in the platform, and is set into gp + // during TPM_Manufacture. *value = gp.firmwareV1; break; case TPM_PT_FIRMWARE_VERSION_2: // less significant 32-bits of a vendor-specific value + // note this value originates in the platform, and is set into gp + // during TPM_Manufacture. *value = gp.firmwareV2; break; case TPM_PT_INPUT_BUFFER: @@ -209,10 +161,8 @@ static BOOL TPMPropertyIsDefined(TPM_PT property, // IN: property SET_ATTRIBUTE(attributes.att, TPMA_MEMORY, sharedNV); SET_ATTRIBUTE(attributes.att, TPMA_MEMORY, objectCopiedToRam); - // Note: For a LSb0 machine, the bits in a bit field are in the correct - // order even if the machine is MSB0. For a MSb0 machine, a TPMA will - // be an integer manipulated by masking (USE_BIT_FIELD_STRUCTURES will - // be NO) so the bits are manipulate correctly. + // A TPMA will be an integer manipulated by masking so the bits + // are manipulated correctly regardless of machine endianness. *value = attributes.u32; break; } @@ -311,24 +261,26 @@ static BOOL TPMPropertyIsDefined(TPM_PT property, // IN: property // platform specific values for the TPM_PT_PS parameters from // the relevant platform-specific specification // In this reference implementation, all of these values are 0. - *value = PLATFORM_FAMILY; + *value = spec_capability_value.platformFamily; break; case TPM_PT_PS_LEVEL: // level of the platform-specific specification - *value = PLATFORM_LEVEL; + *value = spec_capability_value.platfromLevel; break; case TPM_PT_PS_REVISION: - // specification Revision times 100 for the platform-specific - // specification - *value = PLATFORM_VERSION; + // The platform spec version is recorded such that 0x00000101 means version 1.01 + // Note this differs from some TPM/TCG specifications, but matches the behavior of Windows. + // more recent TCG specs have discontinued using this field, but Windows displays it, so we + // retain it using the historical encoding. + *value = spec_capability_value.platformRevision; break; case TPM_PT_PS_DAY_OF_YEAR: // platform-specific specification day of year using TCG calendar - *value = PLATFORM_DAY_OF_YEAR; + *value = spec_capability_value.platformDayOfYear; break; case TPM_PT_PS_YEAR: // platform-specific specification year using the CE - *value = PLATFORM_YEAR; + *value = spec_capability_value.platformYear; break; case TPM_PT_SPLIT_MAX: // number of split signing operations supported by the TPM @@ -339,14 +291,8 @@ static BOOL TPMPropertyIsDefined(TPM_PT property, // IN: property break; case TPM_PT_TOTAL_COMMANDS: // total number of commands implemented in the TPM - // Since the reference implementation does not have any - // vendor-defined commands, this will be the same as the - // number of library commands. { -#if COMPRESSED_LISTS - (*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 @@ -355,17 +301,13 @@ static BOOL TPMPropertyIsDefined(TPM_PT property, // IN: property commandIndex = GetNextCommandIndex(commandIndex)) { (*value)++; // count of all implemented - } -#endif + } // libtpms changed end break; } case TPM_PT_LIBRARY_COMMANDS: // number of commands from the TPM library that are implemented { -#if COMPRESSED_LISTS - *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 @@ -374,13 +316,12 @@ static BOOL TPMPropertyIsDefined(TPM_PT property, // IN: property commandIndex = GetNextCommandIndex(commandIndex)) { (*value)++; - } -#endif + } // libtpms changed end break; } case TPM_PT_VENDOR_COMMANDS: // number of vendor commands that are implemented - *value = VENDOR_COMMAND_ARRAY_SIZE; + *value = VENDOR_COMMAND_ARRAY_COUNT; break; case TPM_PT_NV_BUFFER_MAX: // Maximum data size in an NV write command @@ -431,10 +372,8 @@ static BOOL TPMPropertyIsDefined(TPM_PT property, // IN: property // In this implementation, EPS is always generated by TPM SET_ATTRIBUTE(flags.attr, TPMA_PERMANENT, tpmGeneratedEPS); - // Note: For a LSb0 machine, the bits in a bit field are in the correct - // order even if the machine is MSB0. For a MSb0 machine, a TPMA will - // be an integer manipulated by masking (USE_BIT_FIELD_STRUCTURES will - // be NO) so the bits are manipulate correctly. + // A TPMA will be an integer manipulated by masking so the bits + // are manipulated correctly regardless of machine endianness. *value = flags.u32; break; } @@ -455,13 +394,15 @@ static BOOL TPMPropertyIsDefined(TPM_PT property, // IN: property SET_ATTRIBUTE(flags.attr, TPMA_STARTUP_CLEAR, ehEnable); if(gc.phEnableNV) SET_ATTRIBUTE(flags.attr, TPMA_STARTUP_CLEAR, phEnableNV); +#if CC_ReadOnlyControl + if(gc.readOnly) + SET_ATTRIBUTE(flags.attr, TPMA_STARTUP_CLEAR, readOnly); +#endif if(g_prevOrderlyState != SU_NONE_VALUE) SET_ATTRIBUTE(flags.attr, TPMA_STARTUP_CLEAR, orderly); - // Note: For a LSb0 machine, the bits in a bit field are in the correct - // order even if the machine is MSB0. For a MSb0 machine, a TPMA will - // be an integer manipulated by masking (USE_BIT_FIELD_STRUCTURES will - // be NO) so the bits are manipulate correctly. + // A TPMA will be an integer manipulated by masking so the bits + // are manipulated correctly regardless of machine endianness. *value = flags.u32; break; } diff --git a/src/tpm2/TPMCmd/tpm/src/support/Response.c b/src/tpm2/TPMCmd/tpm/src/support/Response.c new file mode 100644 index 000000000..e3be4f474 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/src/support/Response.c @@ -0,0 +1,48 @@ +// SPDX-License-Identifier: BSD-2-Clause + +//** Description +// This file contains the common code for building a response header, including +// setting the size of the structure. 'command' may be NULL if result is +// not TPM_RC_SUCCESS. + +//** Includes and Defines +#include "Tpm.h" +#include "Marshal.h" + +//** BuildResponseHeader() +// Adds the response header to the response. It will update command->parameterSize +// to indicate the total size of the response. +void BuildResponseHeader(COMMAND* command, // IN: main control structure + BYTE* buffer, // OUT: the output buffer + TPM_RC result // IN: the response code +) +{ + TPM_ST tag; + UINT32 size; + + if(result != TPM_RC_SUCCESS) + { + tag = TPM_ST_NO_SESSIONS; + size = 10; + } + else + { + tag = command->tag; + // Compute the overall size of the response + size = STD_RESPONSE_HEADER + command->handleNum * sizeof(TPM_HANDLE); + size += command->parameterSize; + size += (command->tag == TPM_ST_SESSIONS) ? command->authSize + sizeof(UINT32) + : 0; + } + TPM_ST_Marshal(&tag, &buffer, NULL); + UINT32_Marshal(&size, &buffer, NULL); + TPM_RC_Marshal(&result, &buffer, NULL); + if(result == TPM_RC_SUCCESS) + { + if(command->handleNum > 0) + TPM_HANDLE_Marshal(&command->handles[0], &buffer, NULL); + if(tag == TPM_ST_SESSIONS) + UINT32_Marshal((UINT32*)&command->parameterSize, &buffer, NULL); + } + command->parameterSize = size; +} diff --git a/src/tpm2/TPMCmd/tpm/src/support/ResponseCodeProcessing.c b/src/tpm2/TPMCmd/tpm/src/support/ResponseCodeProcessing.c new file mode 100644 index 000000000..aa2a5daf9 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/src/support/ResponseCodeProcessing.c @@ -0,0 +1,20 @@ +// SPDX-License-Identifier: BSD-2-Clause + +//** Description +// This file contains the miscellaneous functions for processing response codes. +// NOTE: Currently, there is only one. + +//** Includes and Defines +#include "Tpm.h" + +//** RcSafeAddToResult() +// Adds a modifier to a response code as long as the response code allows a modifier +// and no modifier has already been added. +TPM_RC +RcSafeAddToResult(TPM_RC responseCode, TPM_RC modifier) +{ + if((responseCode & RC_FMT1) && !(responseCode & 0xf40)) + return responseCode + modifier; + else + return responseCode; +} diff --git a/src/tpm2/TPMCmd/tpm/src/support/SecChannel.c b/src/tpm2/TPMCmd/tpm/src/support/SecChannel.c new file mode 100644 index 000000000..19b9a3ea5 --- /dev/null +++ b/src/tpm2/TPMCmd/tpm/src/support/SecChannel.c @@ -0,0 +1,120 @@ +// SPDX-License-Identifier: BSD-2-Clause + +#include "Tpm.h" + +#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 + { + 0x00, 0x0C, // hashAlg = TPM_ALG_SHA384 + // 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 + } +}}; + +// 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->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; + // 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); +} + +//*** SpdmCapGetTpmPubKeys() +// This function is used to get the 'TPM_PUB_KEY' public keys for GetCapability. +// Return Type: TPMI_YES_NO +// 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 +) +{ + NOT_REFERENCED(spdmPubKey); + NOT_REFERENCED(count); + 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); + pubKeyList->pubKeys[0].size = sizeof(TPMT_PUBLIC); + + return more; +} + +//*** SpdmCapGetSessionInfo() +// 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 +) +{ + 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)) + spdmSessionInfoList->count = 1; + else + // 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. +// 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 +) +{ + 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)); + + // Get TPM SPDM pub key and compute its name + GetTpmSpdmPubKey(&tpmPubKey); + PublicMarshalAndComputeName(&tpmPubKey, tpmKeyName); + + return TRUE; +} +#endif // SEC_CHANNEL_SUPPORT diff --git a/src/tpm2/TpmFail.c b/src/tpm2/TPMCmd/tpm/src/support/TpmFail.c similarity index 57% rename from src/tpm2/TpmFail.c rename to src/tpm2/TPMCmd/tpm/src/support/TpmFail.c index 7c69dccac..271227de5 100644 --- a/src/tpm2/TpmFail.c +++ b/src/tpm2/TPMCmd/tpm/src/support/TpmFail.c @@ -1,62 +1,4 @@ -/********************************************************************************/ -/* */ -/* Failure Mode Handling */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2016 - 2023 */ -/* */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause //** Includes, Defines, and Types #define TPM_FAIL_C @@ -68,7 +10,7 @@ // structures is not important as this function does not use any of the structures // in TpmTypes.h and only include it for the #defines of the capabilities, // properties, and command code values. -#include "TpmTypes.h" +#include "tpm_public/TpmTypes.h" #define TPM_HAVE_TPM2_DECLARATIONS #include "tpm_library_intern.h" // libtpms added @@ -134,9 +76,14 @@ typedef union // compelling reason to move all the typedefs to Global.h and this structure // to Global.c. #ifndef __IGNORE_STATE__ // Don't define this value -static BYTE response[sizeof(RESPONSES)]; +static BYTE failure_response_buffer[1000 + sizeof(RESPONSES)]; #endif +// the total size of the failure_response_buffer must be at least: +// 4 * sizeof(UINT32) + sizeof(UINT16) since that's what TPM_CC_GetTestResult +// returns +TPM_STATIC_ASSERT(sizeof(failure_response_buffer) > 100); + //** Local Functions //*** MarshalUint16() @@ -177,61 +124,69 @@ static BOOL Unmarshal16(UINT16* target, BYTE** buffer, INT32* size) return TRUE; } -//** Public Functions - -//*** SetForceFailureMode() -// This function is called by the simulator to enable failure mode testing. -#if ALLOW_FORCE_FAILURE_MODE -LIB_EXPORT void SetForceFailureMode(void) -{ - g_forceFailureMode = TRUE; - return; -} -#endif // ALLOW_FORCE_FAILURE_MODE - -/* libtpms added begin */ -static void -TpmSetFailureMode( +//*** EnterFailureMode() +// This function is called by TPM.lib when a failure occurs. It will set up the +// failure values to be returned on TPM2_GetTestResult(). +NORETURN_IF_LONGJMP void EnterFailureMode( #if FAIL_TRACE - const char *function, - int line, + const char* function, + int line, #endif - int code - ) + uint64_t locationCode, + int failureCode) { - // Save the values that indicate where the error occurred. - // On a 64-bit machine, this may truncate the address of the string - // of the function name where the error occurred. -#if FAIL_TRACE - s_failFunction = *(UINT32 *)function; - s_failLine = line; -#else - s_failFunction = (UINT32)0; - s_failLine = 0; -#endif - s_failCode = code; + TPM_DEBUG_TRACE(); + if(_plat__InFailureMode()) + { + TPM_DEBUG_PRINT("Fail On Fail, Original Failure:"); - TPMLIB_LogTPM2Error("Entering failure mode; code: %d" #if FAIL_TRACE - ", location: %s line %d" + TPM_DEBUG_PRINTF("Function:", _plat__GetFailureFunctionName()); + TPM_DEBUG_PRINTF(" Line:", _plat__GetFailureLine()); #endif - "\n", s_failCode + + TPM_DEBUG_PRINTF(" Code:", _plat__GetFailureCode()); + uint32_t failureLocation_low = (uint32_t)(_plat__GetFailureLocation()); + uint32_t failureLocation_hi = (uint32_t)(_plat__GetFailureLocation() >> 32); + // reference in case printing is disabled + NOT_REFERENCED(failureLocation_low); + NOT_REFERENCED(failureLocation_hi); + TPM_DEBUG_PRINTF( + "Location: %08x:%08x", failureLocation_hi, failureLocation_low); + TPM_DEBUG_PRINT("New Failure:"); #if FAIL_TRACE - , function, s_failLine + TPM_DEBUG_PRINTF("Function:", function); + TPM_DEBUG_PRINTF(" Line:", line); #endif - ); - // We are in failure mode - g_inFailureMode = TRUE; + TPM_DEBUG_PRINTF(" Code:", failureCode); + failureLocation_low = (uint32_t)(locationCode); + failureLocation_hi = (uint32_t)(locationCode >> 32); + // reference in case printing is disabled + NOT_REFERENCED(failureLocation_low); + NOT_REFERENCED(failureLocation_hi); + TPM_DEBUG_PRINTF( + "Location: %08x:%08x", failureLocation_hi, failureLocation_low); + } + + // Notify the platform that we hit a failure. + // + // In the LONGJMP_SUPPORTED case, the reference platform code is expected to + // long-jmp back to the ExecuteCommand call and output a failure response. + // + // In the !LONGJMP_SUPPORTED case, this is a notification to the platform, + // and the platform may take any (implementation-defined) behavior, + // including no-op, debugging, or whatever. The core library is expected to + // surface the failure back to ExecuteCommand through error propagation and + // return an appropriate failure reply. + // + // The general expectation is for the platform to ignore this and not update + // the failure data if the platform is already in failure + _plat__Fail(function, line, locationCode, failureCode); } -/* libtpms added end */ - -/* 9.17.4.2 TpmLogFailure() */ -/* This function saves the failure values when the code will continue to operate. It if similar to - TpmFail() but returns to the caller. The assumption is that the caller will propagate a failure - back up the stack. */ -void -TpmLogFailure( + + // libtpms added begin +void TpmLogFailure( #if FAIL_TRACE const char *function, int line, @@ -239,102 +194,37 @@ TpmLogFailure( int code ) { -#if 0 // libtpms added - // Save the values that indicate where the error occurred. - // On a 64-bit machine, this may truncate the address of the string - // of the function name where the error occurred. -#if FAIL_TRACE - memcpy(&s_failFunction, function, sizeof(uint32_t)); /* kgold */ - s_failLine = line; -#else - s_failFunction = 0; - s_failLine = 0; -#endif - s_failCode = code; - - // We are in failure mode - g_inFailureMode = TRUE; -#else // libtpms added begin - - TpmSetFailureMode( -#if FAIL_TRACE - function, line, -#endif - code); - -#endif // libtpms added end - return; -} - -//*** TpmFail() -// This function is called by TPM.lib when a failure occurs. It will set up the -// failure values to be returned on TPM2_GetTestResult(). -NORETURN void TpmFail( + TPMLIB_LogTPM2Error("Entering failure mode; code: %d" #if FAIL_TRACE - const char* function, - int line, -#else - uint64_t locationCode, + ", location: %s line %d" #endif - int failureCode) -{ -#if 0 /* libtpms added */ - // Save the values that indicate where the error occurred. - // On a 64-bit machine, this may truncate the address of the string - // of the function name where the error occurred. + "\n", code #if FAIL_TRACE - memcpy(&s_failFunction, function, sizeof(uint32_t)); // libtpms changed - s_failLine = line; -#else - s_failFunction = (UINT32)(locationCode >> 32); - s_failLine = (UINT32)(locationCode); -#endif - s_failCode = failureCode; - - // We are in failure mode - g_inFailureMode = TRUE; - // if asserts are enabled, then do an assert unless the failure mode code - // is being tested. -#if SIMULATION -# ifndef NDEBUG - assert(g_forceFailureMode); -# endif - // Clear this flag - g_forceFailureMode = FALSE; + , function, line #endif + ); -#else /* libtpms added begin */ - - TpmSetFailureMode( + _plat__SetFailureModeParameters( #if FAIL_TRACE - function, line, + function, + line, #endif - failureCode); - -#endif /* libtpms added end */ - // Notify the platform that we hit a failure. - // - // In the LONGJMP case, the reference platform code is expected to long-jmp - // back to the ExecuteCommand call and output a failure response. - // - // In the NO_LONGJMP case, this is a notification to the platform, and the - // platform may take any (implementation-defined) behavior, including no-op, - // debugging, or whatever. The core library is expected to surface the failure - // back to ExecuteCommand through error propagation and return an appropriate - // failure reply. - _plat__Fail(); -} + code + ); + _plat__SetInFailureMode(TRUE); +} // libtpms added end //*** TpmFailureMode( -// This function is called by the interface code when the platform is in failure -// mode. +// This function is called by ExecuteCommand code to construct failure responses +// when the platform is in failure mode. void TpmFailureMode(uint32_t inRequestSize, // IN: command buffer size unsigned char* inRequest, // IN: command buffer uint32_t* outResponseSize, // OUT: response buffer size unsigned char** outResponse // OUT: response buffer ) { - UINT32 marshalSize; + TPM_DEBUG_TRACE(); + UINT32 marshalSize; // final size of the response. UINT32 capability; HEADER header; // unmarshaled command header UINT32 pt; // unmarshaled property type @@ -342,33 +232,57 @@ void TpmFailureMode(uint32_t inRequestSize, // IN: command buffer size UINT8* buffer = inRequest; INT32 size = inRequestSize; + //TPM_DEBUG_PRINT("In TpmFailureMode)"); + // If there is no command buffer, then just return TPM_RC_FAILURE if(inRequestSize == 0 || inRequest == NULL) + { goto FailureModeReturn; + } // If the header is not correct for TPM2_GetCapability() or // TPM2_GetTestResult() then just return the in failure mode response; if(!(Unmarshal16(&header.tag, &buffer, &size) && Unmarshal32(&header.size, &buffer, &size) && Unmarshal32(&header.code, &buffer, &size))) + { goto FailureModeReturn; + } if(header.tag != TPM_ST_NO_SESSIONS || header.size < 10) + { goto FailureModeReturn; + } + switch(header.code) { case TPM_CC_GetTestResult: + { // make sure that the command size is correct if(header.size != 10) + { goto FailureModeReturn; - buffer = &response[10]; - marshalSize = MarshalUint16(3 * sizeof(UINT32), &buffer); - marshalSize += MarshalUint32(s_failFunction, &buffer); - marshalSize += MarshalUint32(s_failLine, &buffer); - marshalSize += MarshalUint32(s_failCode, &buffer); - if(s_failCode == FATAL_ERROR_NV_UNRECOVERABLE) + } + buffer = &failure_response_buffer[10]; + + UINT16 sizeofTestResultData = 8 // size of Failure Location + + 4; // sizeof(_plat__GetFailureCode); + + marshalSize = MarshalUint16(sizeofTestResultData, &buffer); + UINT32 low = (UINT32)(_plat__GetFailureLocation() & 0xFFFFFFFF); + UINT32 high = (UINT32)((_plat__GetFailureLocation() >> 32) & 0xFFFFFFFF); + marshalSize += MarshalUint32(high, &buffer); + marshalSize += MarshalUint32(low, &buffer); + marshalSize += MarshalUint32(_plat__GetFailureCode(), &buffer); + // the final code isn't part of the TestResultData size and is always UINT32 + if(_plat__GetFailureCode() == FATAL_ERROR_NV_UNRECOVERABLE) + { marshalSize += MarshalUint32(TPM_RC_NV_UNINITIALIZED, &buffer); + } else + { marshalSize += MarshalUint32(TPM_RC_FAILURE, &buffer); - break; + } + } + break; case TPM_CC_GetCapability: // make sure that the size of the command is exactly the size // returned for the capability, property, and count @@ -387,7 +301,7 @@ void TpmFailureMode(uint32_t inRequestSize, // IN: command buffer size if(pt < TPM_PT_MANUFACTURER) pt = TPM_PT_MANUFACTURER; // set up for return - buffer = &response[10]; + buffer = &failure_response_buffer[10]; // if the request was for a PT less than the last one // then we indicate more, otherwise, not. if(pt < TPM_PT_FIRMWARE_VERSION_2) @@ -434,7 +348,7 @@ void TpmFailureMode(uint32_t inRequestSize, // IN: command buffer size case TPM_PT_VENDOR_TPM_TYPE: // vendor-defined value indicating the TPM model // We just make up a number here - pt = _plat__GetTpmType(); + pt = _plat__GetVendorTpmType(); break; case TPM_PT_FIRMWARE_VERSION_1: @@ -452,10 +366,11 @@ void TpmFailureMode(uint32_t inRequestSize, // IN: command buffer size marshalSize += MarshalUint32(pt, &buffer); break; default: // default for switch (cc) + //TPM_DEBUG_PRINT(" goto FailureModeReturn from default"); goto FailureModeReturn; } // Now do the header - buffer = response; + buffer = failure_response_buffer; marshalSize = marshalSize + 10; // Add the header size to the // stuff already marshaled MarshalUint16(TPM_ST_NO_SESSIONS, &buffer); // structure tag @@ -463,15 +378,21 @@ void TpmFailureMode(uint32_t inRequestSize, // IN: command buffer size MarshalUint32(TPM_RC_SUCCESS, &buffer); // response code *outResponseSize = marshalSize; - *outResponse = (unsigned char*)&response; + *outResponse = (unsigned char*)&failure_response_buffer; return; + FailureModeReturn: - buffer = response; + TPM_DEBUG_TRACEX("returning."); + + buffer = failure_response_buffer; + //TPM_DEBUG_PRINT("FailureModeReturn:1"); marshalSize = MarshalUint16(TPM_ST_NO_SESSIONS, &buffer); + //TPM_DEBUG_PRINT("FailureModeReturn:2"); marshalSize += MarshalUint32(10, &buffer); + //TPM_DEBUG_PRINT("FailureModeReturn:3"); marshalSize += MarshalUint32(TPM_RC_FAILURE, &buffer); *outResponseSize = marshalSize; - *outResponse = (unsigned char*)response; + *outResponse = (unsigned char*)failure_response_buffer; return; } diff --git a/src/tpm2/TpmSizeChecks.c b/src/tpm2/TPMCmd/tpm/src/support/TpmSizeChecks.c similarity index 55% rename from src/tpm2/TpmSizeChecks.c rename to src/tpm2/TPMCmd/tpm/src/support/TpmSizeChecks.c index 6be1e0a92..484d7ca6b 100644 --- a/src/tpm2/TpmSizeChecks.c +++ b/src/tpm2/TPMCmd/tpm/src/support/TpmSizeChecks.c @@ -1,63 +1,4 @@ -/********************************************************************************/ -/* */ -/* TPM Size Checks */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: TpmSizeChecks.c 1628 2020-05-27 19:35:29Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2016 - 2020 */ -/* */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause //** Includes, Defines, and Types #include "Tpm.h" @@ -135,17 +76,20 @@ BOOL TpmSizeChecks(void) } # endif // ALG_RSA # if TABLE_DRIVEN_MARSHAL - printf("sizeof(MarshalData) = %zu\n", sizeof(MarshalData_st)); + TPM_DEBUG_PRINTF("sizeof(MarshalData) = %zu\n", sizeof(MarshalData_st)); # endif - printf("Size of OBJECT = %zu\n", sizeof(OBJECT)); - printf("Size of components in TPMT_SENSITIVE = %zu\n", - sizeof(TPMT_SENSITIVE)); - printf(" TPMI_ALG_PUBLIC %zu\n", sizeof(TPMI_ALG_PUBLIC)); - printf(" TPM2B_AUTH %zu\n", sizeof(TPM2B_AUTH)); - printf(" TPM2B_DIGEST %zu\n", sizeof(TPM2B_DIGEST)); - printf(" TPMU_SENSITIVE_COMPOSITE %zu\n", - sizeof(TPMU_SENSITIVE_COMPOSITE)); + TPM_DEBUG_PRINTF("Size of OBJECT = %zu\n", sizeof(OBJECT)); + TPM_DEBUG_PRINTF("Size of components in TPMT_SENSITIVE = %zu\n", + sizeof(TPMT_SENSITIVE)); + TPM_DEBUG_PRINTF(" TPMI_ALG_PUBLIC %zu\n", + sizeof(TPMI_ALG_PUBLIC)); + TPM_DEBUG_PRINTF(" TPM2B_AUTH %zu\n", + sizeof(TPM2B_AUTH)); + TPM_DEBUG_PRINTF(" TPM2B_DIGEST %zu\n", + sizeof(TPM2B_DIGEST)); + TPM_DEBUG_PRINTF(" TPMU_SENSITIVE_COMPOSITE %zu\n", + sizeof(TPMU_SENSITIVE_COMPOSITE)); } // Make sure that the size of the context blob is large enough for the largest // context @@ -175,16 +119,17 @@ BOOL TpmSizeChecks(void) if(MAX_CONTEXT_SIZE < biggestContext) { - printf("MAX_CONTEXT_SIZE needs to be increased to at least %d (%d)\n", - biggestContext, - MAX_CONTEXT_SIZE); + TPM_DEBUG_PRINTF("MAX_CONTEXT_SIZE needs to be increased to at least %d " + "(%d)\n", + biggestContext, + MAX_CONTEXT_SIZE); PASS = FALSE; } else if(MAX_CONTEXT_SIZE > biggestContext) { - printf("MAX_CONTEXT_SIZE can be reduced to %d (%d)\n", - biggestContext, - MAX_CONTEXT_SIZE); + TPM_DEBUG_PRINTF("MAX_CONTEXT_SIZE can be reduced to %d (%d)\n", + biggestContext, + MAX_CONTEXT_SIZE); } } { @@ -201,12 +146,13 @@ BOOL TpmSizeChecks(void) SET_ATTRIBUTE(u.attributes, TPMA_OBJECT, fixedTPM); if(u.uint32Value != 2) { - printf("The bit allocation in a TPMA_OBJECT is not as expected"); + TPM_DEBUG_PRINT("The bit allocation in a TPMA_OBJECT is not as " + "expected"); PASS = FALSE; } if(aSize != uSize) // comparison of two sizeof() values annoys compiler { - printf("A TPMA_OBJECT is not the expected size."); + TPM_DEBUG_PRINT("A TPMA_OBJECT is not the expected size."); PASS = FALSE; } } @@ -222,7 +168,8 @@ BOOL TpmSizeChecks(void) FOR_EACH_ACT(CASE_ACT_NUMBER) if(!_plat__ACT_GetImplemented(act)) { - printf("TPM_RH_ACT_%1X is not implemented by platform\n", act); + TPM_DEBUG_PRINTF( + "TPM_RH_ACT_%1X is not implemented by platform\n", act); PASS = FALSE; } default: @@ -237,7 +184,8 @@ BOOL TpmSizeChecks(void) int t = MAX_DIGEST_SIZE; if(t < 20) { - printf("Check the MAX_DIGEST_SIZE computation (%d)", MAX_DIGEST_SIZE); + TPM_DEBUG_PRINTF("Check the MAX_DIGEST_SIZE computation (%d)", + MAX_DIGEST_SIZE); PASS = FALSE; } } diff --git a/src/tpm2/TcpServerPosix_fp.h b/src/tpm2/TcpServerPosix_fp.h deleted file mode 100644 index d984130ae..000000000 --- a/src/tpm2/TcpServerPosix_fp.h +++ /dev/null @@ -1,131 +0,0 @@ -/********************************************************************************/ -/* */ -/* Socket Interface to a TPM Simulator */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: TcpServerPosix_fp.h 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, 2016 - 2021 */ -/* */ -/********************************************************************************/ - -#ifndef TCPSERVERPOSIX_FP_H -#define TCPSERVERPOSIX_FP_H - -#include -#include -#include -#include -#include - -#include "CompilerDependencies.h" -#include "BaseTypes.h" - -bool -PlatformServer( - SOCKET s - ); -int -PlatformSvcRoutine( - void *port - ); -int -PlatformSignalService( - int *PortNumberPlatform - ); -int -RegularCommandService( - int *PortNumber - ); -int -StartTcpServer( - int *PortNumber, - int *PortNumberPlatform - ); -bool -ReadBytes( - SOCKET s, - char *buffer, - int NumBytes - ); -bool -WriteBytes( - SOCKET s, - char *buffer, - int NumBytes - ); -bool -WriteUINT32( - SOCKET s, - UINT32 val - ); -bool -ReadVarBytes( - SOCKET s, - char *buffer, - UINT32 *BytesReceived, - int MaxLen - ); -bool -WriteVarBytes( - SOCKET s, - char *buffer, - int BytesToSend - ); -bool -TpmServer( - SOCKET s - ); - - -#endif diff --git a/src/tpm2/TestParms_fp.h b/src/tpm2/TestParms_fp.h deleted file mode 100644 index f744f80cd..000000000 --- a/src/tpm2/TestParms_fp.h +++ /dev/null @@ -1,84 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: TestParms_fp.h 809 2016-11-16 18:31:54Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_TestParms // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_TESTPARMS_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_TESTPARMS_FP_H_ - -// Input structure definition -typedef struct -{ - TPMT_PUBLIC_PARMS parameters; -} TestParms_In; - -// Response code modifiers -# define RC_TestParms_parameters (TPM_RC_P + TPM_RC_1) - -// Function prototype -TPM_RC -TPM2_TestParms(TestParms_In* in); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_TESTPARMS_FP_H_ -#endif // CC_TestParms diff --git a/src/tpm2/Ticket_fp.h b/src/tpm2/Ticket_fp.h deleted file mode 100644 index 2cc80b45c..000000000 --- a/src/tpm2/Ticket_fp.h +++ /dev/null @@ -1,119 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* 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 */ -/* */ -/********************************************************************************/ - -/*(Auto-generated) - * Created by TpmPrototypes; Version 3.0 July 18, 2017 - * Date: Mar 28, 2019 Time: 08:25:19PM - */ - -#ifndef _TICKET_FP_H_ -#define _TICKET_FP_H_ - -//*** TicketIsSafe() -// This function indicates if producing a ticket is safe. -// It checks if the leading bytes of an input buffer is TPM_GENERATED_VALUE -// or its substring of canonical form. If so, it is not safe to produce ticket -// for an input buffer claiming to be TPM generated buffer -// Return Type: BOOL -// TRUE(1) safe to produce ticket -// FALSE(0) not safe to produce ticket -BOOL TicketIsSafe(TPM2B* buffer); - -//*** TicketComputeVerified() -// This function creates a TPMT_TK_VERIFIED ticket. -TPM_RC TicketComputeVerified( - TPMI_RH_HIERARCHY hierarchy, // IN: hierarchy constant for ticket - TPM2B_DIGEST* digest, // IN: digest - TPM2B_NAME* keyName, // IN: name of key that signed the values - TPMT_TK_VERIFIED* ticket // OUT: verified ticket -); - -//*** TicketComputeAuth() -// This function creates a TPMT_TK_AUTH ticket. -TPM_RC TicketComputeAuth( - TPM_ST type, // IN: the type of ticket. - TPMI_RH_HIERARCHY hierarchy, // IN: hierarchy constant for ticket - UINT64 timeout, // IN: timeout - BOOL expiresOnReset, // IN: flag to indicate if ticket expires on - // TPM Reset - TPM2B_DIGEST* cpHashA, // IN: input cpHashA - TPM2B_NONCE* policyRef, // IN: input policyRef - TPM2B_NAME* entityName, // IN: name of entity - TPMT_TK_AUTH* ticket // OUT: Created ticket -); - -//*** TicketComputeHashCheck() -// This function creates a TPMT_TK_HASHCHECK ticket. -TPM_RC TicketComputeHashCheck( - TPMI_RH_HIERARCHY hierarchy, // IN: hierarchy constant for ticket - TPM_ALG_ID hashAlg, // IN: the hash algorithm for 'digest' - TPM2B_DIGEST* digest, // IN: input digest - TPMT_TK_HASHCHECK* ticket // OUT: Created ticket -); - -//*** TicketComputeCreation() -// This function creates a TPMT_TK_CREATION ticket. -TPM_RC TicketComputeCreation(TPMI_RH_HIERARCHY hierarchy, // IN: hierarchy for ticket - TPM2B_NAME* name, // IN: object name - TPM2B_DIGEST* creation, // IN: creation hash - TPMT_TK_CREATION* ticket // OUT: created ticket -); - -#endif // _TICKET_FP_H_ diff --git a/src/tpm2/Tpm.h b/src/tpm2/Tpm.h deleted file mode 100644 index 7dbe8ac7f..000000000 --- a/src/tpm2/Tpm.h +++ /dev/null @@ -1,78 +0,0 @@ -/********************************************************************************/ -/* */ -/* Root header file for building any TPM.lib code */ -/* 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 */ -/* */ -/********************************************************************************/ - -// Root header file for building any TPM.lib code - -#ifndef _TPM_H_ -#define _TPM_H_ -// TODO_RENAME_INC_FOLDER: public refers to the TPM_CoreLib public headers -#include "tpm_public.h" - -#include "TpmAlgorithmDefines.h" -#include "LibSupport.h" // Types from the library. These need to come before - // Global.h because some of the structures in - // that file depend on the structures used by the - // cryptographic libraries. -#include "GpMacros.h" // Define additional macros -#include "Global.h" // Define other TPM types -#include "InternalRoutines.h" // Function prototypes -#include "RuntimeProfile_fp.h" // libtpms added - -#endif // _TPM_H_ diff --git a/src/tpm2/TpmASN1.h b/src/tpm2/TpmASN1.h deleted file mode 100644 index 21934abba..000000000 --- a/src/tpm2/TpmASN1.h +++ /dev/null @@ -1,156 +0,0 @@ -/********************************************************************************/ -/* */ -/* Macro and Structure Definitions for the X509 Commands and Functions. */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2019 - 2023 */ -/* */ -/********************************************************************************/ - -//** Introduction -// This file contains the macro and structure definitions for the X509 commands and -// functions. - -#ifndef _TPMASN1_H_ -#define _TPMASN1_H_ - -//** Includes - -#include "Tpm.h" -#include "OIDs.h" - -//** Defined Constants -//*** ASN.1 Universal Types (Class 00b) -#define ASN1_EOC 0x00 -#define ASN1_BOOLEAN 0x01 -#define ASN1_INTEGER 0x02 -#define ASN1_BITSTRING 0x03 -#define ASN1_OCTET_STRING 0x04 -#define ASN1_NULL 0x05 -#define ASN1_OBJECT_IDENTIFIER 0x06 -#define ASN1_OBJECT_DESCRIPTOR 0x07 -#define ASN1_EXTERNAL 0x08 -#define ASN1_REAL 0x09 -#define ASN1_ENUMERATED 0x0A -#define ASN1_EMBEDDED 0x0B -#define ASN1_UTF8String 0x0C -#define ASN1_RELATIVE_OID 0x0D -#define ASN1_SEQUENCE 0x10 // Primitive + Constructed + 0x10 -#define ASN1_SET 0x11 // Primitive + Constructed + 0x11 -#define ASN1_NumericString 0x12 -#define ASN1_PrintableString 0x13 -#define ASN1_T61String 0x14 -#define ASN1_VideoString 0x15 -#define ASN1_IA5String 0x16 -#define ASN1_UTCTime 0x17 -#define ASN1_GeneralizeTime 0x18 -#define ASN1_VisibleString 0x1A -#define ASN1_GeneralString 0x1B -#define ASN1_UniversalString 0x1C -#define ASN1_CHARACTER STRING 0x1D -#define ASN1_BMPString 0x1E -#define ASN1_CONSTRUCTED 0x20 - -#define ASN1_APPLICAIION_SPECIFIC 0xA0 - -#define ASN1_CONSTRUCTED_SEQUENCE (ASN1_SEQUENCE + ASN1_CONSTRUCTED) - -#define MAX_DEPTH 10 // maximum push depth for marshaling context. - -//** Macros - -//*** Unmarshaling Macros -#ifndef GOTO_ERROR_UNLESS -# error missing GOTO_ERROR_UNLESS definition -#endif - -// Checks the validity of the size making sure that there is no wrap around -#define CHECK_SIZE(context, length) \ - GOTO_ERROR_UNLESS((((length) + (context)->offset) >= (context)->offset) \ - && (((length) + (context)->offset) <= (context)->size)) -#define NEXT_OCTET(context) ((context)->buffer[(context)->offset++]) -#define PEEK_NEXT(context) ((context)->buffer[(context)->offset]) - -//*** Marshaling Macros - -// Marshaling works in reverse order. The offset is set to the top of the buffer and, -// as the buffer is filled, 'offset' counts down to zero. When the full thing is -// encoded it can be moved to the top of the buffer. This happens when the last -// context is closed. - -#define CHECK_SPACE(context, length) GOTO_ERROR_UNLESS(context->offset > length) - -//** Structures - -typedef struct ASN1UnmarshalContext -{ - BYTE* buffer; // pointer to the buffer - INT16 size; // size of the buffer (a negative number indicates - // a parsing failure). - INT16 offset; // current offset into the buffer (a negative number - // indicates a parsing failure). Not used - BYTE tag; // The last unmarshaled tag -} ASN1UnmarshalContext; - -typedef struct ASN1MarshalContext -{ - BYTE* buffer; // pointer to the start of the buffer - INT16 offset; // place on the top where the last entry was added - // items are added from the bottom up. - INT16 end; // the end offset of the current value - INT16 depth; // how many pushed end values. - INT16 ends[MAX_DEPTH]; -} ASN1MarshalContext; - -#endif // _TPMASN1_H_ diff --git a/src/tpm2/TpmBigNum.h b/src/tpm2/TpmBigNum.h deleted file mode 100644 index 725e5bca2..000000000 --- a/src/tpm2/TpmBigNum.h +++ /dev/null @@ -1,77 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* 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 */ -/* */ -/********************************************************************************/ - -//** Introduction -// This file contains the headers necessary to build the tpm big num library. -// TODO_RENAME_INC_FOLDER: public refers to the TPM_CoreLib public headers -#include "tpm_public.h" -#include "TpmFail_fp.h" -// TODO_RENAME_INC_FOLDER: private refers to the TPM_CoreLib private(protected) headers -#include "TpmAlgorithmDefines.h" -#include "GpMacros.h" // required for TpmFail_fp.h -#include "Capabilities.h" -#include "TpmTypes.h" // requires capabilities & GpMacros -#include "TpmToTpmBigNumMath.h" -#include "BnSupport_Interface.h" -#include "BnConvert_fp.h" -#include "BnMemory_fp.h" -#include "BnMath_fp.h" -#include "BnUtil_fp.h" -#include "MathLibraryInterface.h" diff --git a/src/tpm2/TpmEcc_Signature_ECDAA_fp.h b/src/tpm2/TpmEcc_Signature_ECDAA_fp.h deleted file mode 100644 index 4be2058d9..000000000 --- a/src/tpm2/TpmEcc_Signature_ECDAA_fp.h +++ /dev/null @@ -1,93 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* 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 */ -/* */ -/********************************************************************************/ - -#ifndef _TPMECC_SIGNATURE_ECDAA_FP_H_ -#define _TPMECC_SIGNATURE_ECDAA_FP_H_ -#if ALG_ECC && ALG_ECDAA - -//*** TpmEcc_SignEcdaa() -// -// This function performs 's' = 'r' + 'T' * 'd' mod 'q' where -// 1) 'r' is a random, or pseudo-random value created in the commit phase -// 2) 'nonceK' is a TPM-generated, random value 0 < 'nonceK' < 'n' -// 3) 'T' is mod 'q' of "Hash"('nonceK' || 'digest'), and -// 4) 'd' is a private key. -// -// The signature is the tuple ('nonceK', 's') -// -// Regrettably, the parameters in this function kind of collide with the parameter -// names used in ECSCHNORR making for a lot of confusion. -// Return Type: TPM_RC -// TPM_RC_SCHEME unsupported hash algorithm -// TPM_RC_NO_RESULT cannot get values from random number generator -TPM_RC TpmEcc_SignEcdaa( - TPM2B_ECC_PARAMETER* nonceK, // OUT: 'nonce' component of the signature - Crypt_Int* bnS, // OUT: 's' component of the signature - const Crypt_EccCurve* E, // IN: the curve used in signing - Crypt_Int* bnD, // IN: the private key - const TPM2B_DIGEST* digest, // IN: the value to sign (mod 'q') - TPMT_ECC_SCHEME* scheme, // IN: signing scheme (contains the - // commit count value). - OBJECT* eccKey, // IN: The signing key - RAND_STATE* rand // IN: a random number state -); - -#endif // ALG_ECC && ALG_ECDAA -#endif // _TPMECC_SIGNATURE_ECDAA_FP_H_ diff --git a/src/tpm2/TpmEcc_Signature_ECDSA_fp.h b/src/tpm2/TpmEcc_Signature_ECDSA_fp.h deleted file mode 100644 index 3283bb89b..000000000 --- a/src/tpm2/TpmEcc_Signature_ECDSA_fp.h +++ /dev/null @@ -1,94 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* 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 */ -/* */ -/********************************************************************************/ - -#ifndef _TPMECC_SIGNATURE_ECDSA_FP_H_ -#define _TPMECC_SIGNATURE_ECDSA_FP_H_ -#if ALG_ECC && ALG_ECDSA - -//*** TpmEcc_SignEcdsa() -// This function implements the ECDSA signing algorithm. The method is described -// in the comments below. -TPM_RC -TpmEcc_SignEcdsa(Crypt_Int* bnR, // OUT: 'r' component of the signature - Crypt_Int* bnS, // OUT: 's' component of the signature - const Crypt_EccCurve* E, // IN: the curve used in the signature - // process - Crypt_Int* bnD, // IN: private signing key - const TPM2B_DIGEST* digest, // IN: the digest to sign - RAND_STATE* rand // IN: used in debug of signing -); - -//*** TpmEcc_ValidateSignatureEcdsa() -// This function validates an ECDSA signature. rIn and sIn should have been checked -// to make sure that they are in the range 0 < 'v' < 'n' -// Return Type: TPM_RC -// TPM_RC_SIGNATURE signature not valid -TPM_RC -TpmEcc_ValidateSignatureEcdsa( - Crypt_Int* bnR, // IN: 'r' component of the signature - Crypt_Int* bnS, // IN: 's' component of the signature - const Crypt_EccCurve* E, // IN: the curve used in the signature - // process - const Crypt_Point* ecQ, // IN: the public point of the key - const TPM2B_DIGEST* digest // IN: the digest that was signed -); - -#endif // ALG_ECC && ALG_ECDSA -#endif // _TPMECC_SIGNATURE_ECDSA_FP_H_ diff --git a/src/tpm2/TpmEcc_Signature_SM2_fp.h b/src/tpm2/TpmEcc_Signature_SM2_fp.h deleted file mode 100644 index 303c3a996..000000000 --- a/src/tpm2/TpmEcc_Signature_SM2_fp.h +++ /dev/null @@ -1,95 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* 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 */ -/* */ -/********************************************************************************/ - -#ifndef _TPMECC_SIGNATURE_SM2_FP_H_ -#define _TPMECC_SIGNATURE_SM2_FP_H_ - -#if ALG_ECC && ALG_SM2 -//*** TpmEcc_SignEcSm2() -// This function signs a digest using the method defined in SM2 Part 2. The method -// in the standard will add a header to the message to be signed that is a hash of -// the values that define the key. This then hashed with the message to produce a -// digest ('e'). This function signs 'e'. -// Return Type: TPM_RC -// TPM_RC_VALUE bad curve -TPM_RC TpmEcc_SignEcSm2(Crypt_Int* bnR, // OUT: 'r' component of the signature - Crypt_Int* bnS, // OUT: 's' component of the signature - const Crypt_EccCurve* E, // IN: the curve used in signing - Crypt_Int* bnD, // IN: the private key - const TPM2B_DIGEST* digest, // IN: the digest to sign - RAND_STATE* rand // IN: random number generator (mostly for - // debug) -); - -//*** TpmEcc_ValidateSignatureEcSm2() -// This function is used to validate an SM2 signature. -// Return Type: TPM_RC -// TPM_RC_SIGNATURE signature not valid -TPM_RC TpmEcc_ValidateSignatureEcSm2( - Crypt_Int* bnR, // IN: 'r' component of the signature - Crypt_Int* bnS, // IN: 's' component of the signature - const Crypt_EccCurve* E, // IN: the curve used in the signature - // process - Crypt_Point* ecQ, // IN: the public point of the key - const TPM2B_DIGEST* digest // IN: the digest that was signed -); - -#endif // ALG_ECC && ALG_SM2 -#endif // _TPMECC_SIGNATURE_SM2_FP_H_ diff --git a/src/tpm2/TpmEcc_Signature_Schnorr_fp.h b/src/tpm2/TpmEcc_Signature_Schnorr_fp.h deleted file mode 100644 index c7c4b46af..000000000 --- a/src/tpm2/TpmEcc_Signature_Schnorr_fp.h +++ /dev/null @@ -1,90 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* 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 */ -/* */ -/********************************************************************************/ - -#ifndef _TPMECC_SIGNATURE_SCHNORR_FP_H_ -#define _TPMECC_SIGNATURE_SCHNORR_FP_H_ - -#if ALG_ECC && ALG_ECSCHNORR -TPM_RC TpmEcc_SignEcSchnorr( - Crypt_Int* bnR, // OUT: 'r' component of the signature - Crypt_Int* bnS, // OUT: 's' component of the signature - const Crypt_EccCurve* E, // IN: the curve used in signing - Crypt_Int* bnD, // IN: the signing key - const TPM2B_DIGEST* digest, // IN: the digest to sign - TPM_ALG_ID hashAlg, // IN: signing scheme (contains a hash) - RAND_STATE* rand // IN: non-NULL when testing -); - -//*** TpmEcc_ValidateSignatureEcSchnorr() -// This function is used to validate an EC Schnorr signature. -// Return Type: TPM_RC -// TPM_RC_SIGNATURE signature not valid -TPM_RC TpmEcc_ValidateSignatureEcSchnorr( - Crypt_Int* bnR, // IN: 'r' component of the signature - Crypt_Int* bnS, // IN: 's' component of the signature - TPM_ALG_ID hashAlg, // IN: hash algorithm of the signature - const Crypt_EccCurve* E, // IN: the curve used in the signature - // process - Crypt_Point* ecQ, // IN: the public point of the key - const TPM2B_DIGEST* digest // IN: the digest that was signed -); - -#endif // ALG_ECC && ALG_ECSCHNORR -#endif // _TPMECC_SIGNATURE_SCHNORR_FP_H_ diff --git a/src/tpm2/TpmEcc_Signature_Util.c b/src/tpm2/TpmEcc_Signature_Util.c deleted file mode 100644 index b599d4062..000000000 --- a/src/tpm2/TpmEcc_Signature_Util.c +++ /dev/null @@ -1,107 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* 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 */ -/* */ -/********************************************************************************/ - -// functions shared by multiple signature algorithms -#include "Tpm.h" -#include "TpmEcc_Signature_Util_fp.h" -#include "TpmMath_Debug_fp.h" -#include "TpmMath_Util_fp.h" - -#if(ALG_ECC && (ALG_ECSCHNORR || ALG_ECDAA)) - -//*** TpmEcc_SchnorrCalculateS() -// This contains the Schnorr signature (S) computation. It is used by both ECDAA and -// Schnorr signing. The result is computed as: ['s' = 'k' + 'r' * 'd' (mod 'n')] -// where -// 1) 's' is the signature -// 2) 'k' is a random value -// 3) 'r' is the value to sign -// 4) 'd' is the private EC key -// 5) 'n' is the order of the curve -// Return Type: TPM_RC -// TPM_RC_NO_RESULT the result of the operation was zero or 'r' (mod 'n') -// is zero -TPM_RC TpmEcc_SchnorrCalculateS( - Crypt_Int* bnS, // OUT: 's' component of the signature - const Crypt_Int* bnK, // IN: a random value - Crypt_Int* bnR, // IN: the signature 'r' value - const Crypt_Int* bnD, // IN: the private key - const Crypt_Int* bnN // IN: the order of the curve -) -{ - // Need a local temp value to store the intermediate computation because product - // size can be larger than will fit in bnS. - CRYPT_INT_VAR(bnT1, MAX_ECC_PARAMETER_BYTES * 2 * 8); - // - // Reduce bnR without changing the input value - ExtMath_Divide(NULL, bnT1, bnR, bnN); - if(ExtMath_IsZero(bnT1)) - return TPM_RC_NO_RESULT; - // compute s = (k + r * d)(mod n) - // r * d - ExtMath_Multiply(bnT1, bnT1, bnD); - // k + r * d - ExtMath_Add(bnT1, bnT1, bnK); - // k + r * d (mod n) - ExtMath_Divide(NULL, bnS, bnT1, bnN); - return (ExtMath_IsZero(bnS)) ? TPM_RC_NO_RESULT : TPM_RC_SUCCESS; -} - -#endif // (ALG_ECC && (ALG_ECSCHNORR || ALG_ECDAA)) diff --git a/src/tpm2/TpmEcc_Signature_Util_fp.h b/src/tpm2/TpmEcc_Signature_Util_fp.h deleted file mode 100644 index f36249247..000000000 --- a/src/tpm2/TpmEcc_Signature_Util_fp.h +++ /dev/null @@ -1,87 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* 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 */ -/* */ -/********************************************************************************/ - -// functions shared by multiple signature algorithms -#ifndef _TPMECC_SIGNATURE_UTIL_FP_H_ -#define _TPMECC_SIGNATURE_UTIL_FP_H_ - -#if ALG_ECC -//*** TpmEcc_SchnorrCalculateS() -// This contains the Schnorr signature (S) computation. It is used by both ECDSA and -// Schnorr signing. The result is computed as: ['s' = 'k' + 'r' * 'd' (mod 'n')] -// where -// 1) 's' is the signature -// 2) 'k' is a random value -// 3) 'r' is the value to sign -// 4) 'd' is the private EC key -// 5) 'n' is the order of the curve -// Return Type: TPM_RC -// TPM_RC_NO_RESULT the result of the operation was zero or 'r' (mod 'n') -// is zero -TPM_RC TpmEcc_SchnorrCalculateS( - Crypt_Int* bnS, // OUT: 's' component of the signature - const Crypt_Int* bnK, // IN: a random value - Crypt_Int* bnR, // IN: the signature 'r' value - const Crypt_Int* bnD, // IN: the private key - const Crypt_Int* bnN // IN: the order of the curve -); - -#endif // ALG_ECC -#endif // _TPMECC_SIGNATURE_UTIL_FP_H_ diff --git a/src/tpm2/TpmEcc_Util.c b/src/tpm2/TpmEcc_Util.c deleted file mode 100644 index d60f3c7a5..000000000 --- a/src/tpm2/TpmEcc_Util.c +++ /dev/null @@ -1,123 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* 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 */ -/* */ -/********************************************************************************/ - -//** Introduction -// This file contains utility functions to help using the external Math library -// for Ecc functions. -#include "Tpm.h" -#include "TpmMath_Util_fp.h" -#include "TpmEcc_Util_fp.h" // libtpms added - -#if ALG_ECC - -//*** -// TpmEcc_PointFrom2B() Function to create a Crypt_Point structure from a 2B -// point. The target point is expected to have memory allocated and -// uninitialized. A TPMS_ECC_POINT is going to be two ECC values in the same -// buffer. The values are going to be the size of the modulus. They are in -// modular form. -// -// NOTE: This function considers both parameters optional because of use -// cases where points may not be specified in the calling function. If the -// initializer or point buffer is NULL, then NULL is returned. As a result, the -// only error detection when the initializer value is invalid is to return NULL -// in that error case as well. If a caller wants to handle that error case -// differently, then the caller must perform the correct validation before/after -// this function. -LIB_EXPORT Crypt_Point* TpmEcc_PointFrom2B( - Crypt_Point* ecP, // OUT: the preallocated point structure - TPMS_ECC_POINT* p // IN: the number to convert -) -{ - if(p == NULL) - return NULL; - - if(ecP != NULL) - { - return ExtEcc_PointFromBytes( - ecP, p->x.t.buffer, p->x.t.size, p->y.t.buffer, p->y.t.size); - } - return ecP; // will return NULL if ecP is NULL. -} - -//*** TpmEcc_PointTo2B() -// This function converts a BIG_POINT into a TPMS_ECC_POINT. A TPMS_ECC_POINT -// contains two TPM2B_ECC_PARAMETER values. The maximum size of the parameters -// is dependent on the maximum EC key size used in an implementation. -// The presumption is that the TPMS_ECC_POINT is large enough to hold 2 TPM2B -// values, each as large as a MAX_ECC_PARAMETER_BYTES -LIB_EXPORT BOOL TpmEcc_PointTo2B( - TPMS_ECC_POINT* p, // OUT: the converted 2B structure - const Crypt_Point* ecP, // IN: the values to be converted - const Crypt_EccCurve* E // IN: curve descriptor for the point -) -{ - pAssert(p && ecP && E); - TPM_ECC_CURVE curveId = ExtEcc_CurveGetCurveId(E); - NUMBYTES size = CryptEccGetKeySizeForCurve(curveId); - size = (UINT16)BITS_TO_BYTES(size); - MemorySet(p, 0, sizeof(*p)); - p->x.t.size = size; - p->y.t.size = size; - return ExtEcc_PointToBytes( - ecP, p->x.t.buffer, &p->x.t.size, p->y.t.buffer, &p->y.t.size); -} - -#endif // ALG_ECC diff --git a/src/tpm2/TpmEcc_Util_fp.h b/src/tpm2/TpmEcc_Util_fp.h deleted file mode 100644 index a2ca3e093..000000000 --- a/src/tpm2/TpmEcc_Util_fp.h +++ /dev/null @@ -1,89 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* 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 */ -/* */ -/********************************************************************************/ - -#ifndef _TPMECC_UTIL_FP_H_ -#define _TPMECC_UTIL_FP_H_ - -#if ALG_ECC - -//*** TpmEcc_PointFrom2B() -// Function to create a Crypt_Point structure from a 2B point. -// This function doesn't take an Crypt_EccCurve for legacy reasons - -// this should probably be changed. -// returns NULL if the input value is invalid or doesn't fit. -LIB_EXPORT Crypt_Point* TpmEcc_PointFrom2B( - Crypt_Point* ecP, // OUT: the preallocated point structure - TPMS_ECC_POINT* p // IN: the number to convert -); - -//*** TpmEcc_PointTo2B() -// This function converts a Crypt_Point into a TPMS_ECC_POINT. A TPMS_ECC_POINT -// contains two TPM2B_ECC_PARAMETER values. The maximum size of the parameters -// is dependent on the maximum EC key size used in an implementation. -// The presumption is that the TPMS_ECC_POINT is large enough to hold 2 TPM2B -// values, each as large as a MAX_ECC_PARAMETER_BYTES -LIB_EXPORT BOOL TpmEcc_PointTo2B( - TPMS_ECC_POINT* p, // OUT: the converted 2B structure - const Crypt_Point* ecP, // IN: the values to be converted - const Crypt_EccCurve* E // IN: curve descriptor for the point -); - -#endif // ALG_ECC -#endif // _TPMECC_UTIL_FP_H_ diff --git a/src/tpm2/TpmFail_fp.h b/src/tpm2/TpmFail_fp.h deleted file mode 100644 index eb73f3e87..000000000 --- a/src/tpm2/TpmFail_fp.h +++ /dev/null @@ -1,114 +0,0 @@ -/********************************************************************************/ -/* */ -/* Failure Mode Handling */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2016 - 2023 */ -/* */ -/********************************************************************************/ - -/*(Auto-generated) - * Created by TpmPrototypes; Version 3.0 July 18, 2017 - * Date: Apr 2, 2019 Time: 03:18:00PM - */ - -#ifndef _TPM_FAIL_FP_H_ -#define _TPM_FAIL_FP_H_ - -#if 0 /* libtpms added */ -//*** SetForceFailureMode() -// This function is called by the simulator to enable failure mode testing. -#if SIMULATION -LIB_EXPORT void SetForceFailureMode(void); -#endif -#endif /* libtpms added */ - -void -TpmLogFailure( -#if FAIL_TRACE - const char *function, - int line, -#endif - int code - ); - -//*** TpmFail() -// This function is called by TPM.lib when a failure occurs. It will set up the -// failure values to be returned on TPM2_GetTestResult(). -NORETURN void TpmFail( -#if FAIL_TRACE - const char* function, - int line, -#else - uint64_t locationCode, -#endif - int failureCode); - -//*** TpmFailureMode( -// This function is called by the interface code when the platform is in failure -// mode. -void TpmFailureMode(uint32_t inRequestSize, // IN: command buffer size - unsigned char* inRequest, // IN: command buffer - uint32_t* outResponseSize, // OUT: response buffer size - unsigned char** outResponse // OUT: response buffer -); - -#if 0 /* libtpms added */ -//*** UnmarshalFail() -// This is a stub that is used to catch an attempt to unmarshal an entry -// that is not defined. Don't ever expect this to be called but... -void UnmarshalFail(void* type, BYTE** buffer, INT32* size); -#endif /* libtpms added */ - -#endif // _TPM_FAIL_FP_H_ diff --git a/src/tpm2/TpmMath_Debug.c b/src/tpm2/TpmMath_Debug.c deleted file mode 100644 index 84784a1e0..000000000 --- a/src/tpm2/TpmMath_Debug.c +++ /dev/null @@ -1,170 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* 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 */ -/* */ -/********************************************************************************/ - -//** Introduction -// This file contains debug utility functions to help testing Ecc. -#include "Tpm.h" -#include "TpmEcc_Util_fp.h" -#include "TpmMath_Debug_fp.h" - -#if ALG_SM2 -# ifdef _SM2_SIGN_DEBUG - -//*** SafeGetStringLength() -// self-implemented version of strnlen_s. This is necessary because -// some environments don't have a C-runtime library, or are limited to -// C99, and strnlen_s was standardized in C11. -static size_t SafeGetStringLength(const char* string, size_t maxsize) -{ - // strnlen_s has two boundary conditions: - // return 0 if pointer is nullptr, or - // maxsize if no null character is found. - if(string == NULL) - return 0; - - const char* pos = string; - size_t size = 0; - - while(*pos != '\0' && size < maxsize) - { - pos++; - size++; - } - return size; -} - -// convert from hex value. If invalid, result will be out of range. -static LIB_EXPORT BYTE FromHex(unsigned char c) -{ - // hack for the ASCII characters we care about - BYTE upper = (c & (~0x20)); - if(c >= '0' && c <= '9') - return c - '0'; - else if(c >= 'A' && c <= 'F') - return c - 'A'; - - return 255; -} - -//*** TpmEccDebug_FromHex() -// Convert a hex string into a Crypt_Int*. This is primarily used in debugging. -LIB_EXPORT Crypt_Int* TpmEccDebug_FromHex( - Crypt_Int* bn, // OUT: - const unsigned char* hex, // IN: - size_t maxsizeHex // IN: maximum size of hex -) -{ - // if value is larger than this, then fail - BYTE tempBuf[MAX_ECC_KEY_BYTES]; - MemorySet(tempBuf, 0, sizeof(tempBuf)); - ExtMath_SetWord(bn, 0); - - size_t len = SafeGetStringLength(hex, maxsizeHex); - BOOL OK = FALSE; - if((len % 2) == 0) - { - OK = TRUE; - for(size_t i = 0; i < len; i += 2) - { - BYTE highNibble = FromHex(*hex); - hex++; - BYTE lowNibble = FromHex(*hex); - hex++; - // unsigned, no need to check zero - if(highNibble > 15 || lowNibble > 15) - { - OK = FALSE; - break; - } - BYTE b = ((highNibble << 4) | lowNibble); - tempBuf[i / 2] = b; - } - if(OK) - { - ExtMath_IntFromBytes(bn, tempBuf, (NUMBYTES)(len / 2)); - } - } - - if(!OK) - { - // this should only be called in testing, so any - // errors are fatal. - FAIL(FATAL_ERROR_INTERNAL); - } - return bn; -} - -//*** TpmEccDebug_HexEqual() -// This function compares a bignum value to a hex string. -// using TpmEcc namespace because code assumes the max size -// is correct for ECC. -// Return Type: BOOL -// TRUE(1) values equal -// FALSE(0) values not equal -BOOL TpmEccDebug_HexEqual(const Crypt_Int* bn, //IN: big number value - const char* c //IN: character string number -) -{ - CRYPT_ECC_NUM(bnC); - TpmEccDebug_FromHex(bnC, c, MAX_ECC_KEY_BYTES * 2 + 1); - return (ExtMath_UnsignedCmp(bn, bnC) == 0); -} -# endif // _SM2_SIGN_DEBUG -#endif // ALG_SM2 diff --git a/src/tpm2/TpmMath_Debug_fp.h b/src/tpm2/TpmMath_Debug_fp.h deleted file mode 100644 index 14314de4a..000000000 --- a/src/tpm2/TpmMath_Debug_fp.h +++ /dev/null @@ -1,86 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* 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 */ -/* */ -/********************************************************************************/ - -// -// debug and test utilities. Not expected to be compiled into final products -#ifndef _TPMMATH_DEBUG_FP_H_ -#define _TPMMATH_DEBUG_FP_H_ - -#if ALG_ECC || ALG_RSA - -//*** TpmEccDebug_HexEqual() -// This function compares a bignum value to a hex string. -// using TpmEcc namespace because code assumes the max size -// is correct for ECC. -// Return Type: BOOL -// TRUE(1) values equal -// FALSE(0) values not equal -BOOL TpmMath_Debug_HexEqual(const Crypt_Int* bn, //IN: big number value - const char* c //IN: character string number -); - -LIB_EXPORT Crypt_Int* TpmMath_Debug_FromHex( - Crypt_Int* bn, // OUT: - const unsigned char* hex, // IN: - size_t maxsizeHex // IN: maximum size of hex -); - -#endif // ALG_ECC or ALG_RSA -#endif //_TPMMATH_DEBUG_FP_H_ diff --git a/src/tpm2/TpmProfile.h b/src/tpm2/TpmProfile.h deleted file mode 100644 index 9e7a6bbd5..000000000 --- a/src/tpm2/TpmProfile.h +++ /dev/null @@ -1,91 +0,0 @@ -/********************************************************************************/ -/* */ -/* Constants Reflecting a Particular TPM Implementation (e.g. PC Client) */ -/* 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 - 2023 */ -/* */ -/********************************************************************************/ - -// FOR LIBTPMS: DO NOT EDIT THIS or INCLUDED FILES! -// ANY MODIFICATION WILL LEAD TO AN UNSUPPORTED CONFIGURATION - -// The primary configuration file that collects all configuration options for a -// TPM build. -#ifndef _TPM_PROFILE_H_ -#define _TPM_PROFILE_H_ - -#include "TpmBuildSwitches.h" -#include "TpmProfile_Common.h" -#include "TpmProfile_CommandList.h" -#include "TpmProfile_Misc.h" -#include "TpmProfile_ErrorCodes.h" -#include "VendorInfo.h" - -// libtpms: added begin -#ifndef HASH_LIB -#define HASH_LIB Ossl -#endif -#ifndef SYM_LIB -#define SYM_LIB Ossl -#endif -#ifndef MATH_LIB -#define MATH_LIB TpmBigNum -#endif -#ifndef BN_MATH_LIB -#define BN_MATH_LIB Ossl -#endif -// libtpms: added end - -#endif // _TPM_PROFILE_H_ diff --git a/src/tpm2/TpmProfile_ErrorCodes.h b/src/tpm2/TpmProfile_ErrorCodes.h deleted file mode 100644 index eed72126b..000000000 --- a/src/tpm2/TpmProfile_ErrorCodes.h +++ /dev/null @@ -1,111 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* 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 */ -/* */ -/********************************************************************************/ - -//** Introduction -// This file defines error codes used in failure macros in the TPM Core Library. -// This file is part of TpmConfiguration because the Platform library can add error -// codes of it's own, and ultimately the specific error codes are a vendor decision -// because TPM2_GetTestResult returns manufacturer-defined data in failure mode. -// The only thing in this file that must be consistent with a vendor's implementation -// are the _names_ of error codes used by the core library. Even the values can -// change and are only a suggestion. - -#ifndef _TPMPROFILE_ERRORCODES_H -#define _TPMPROFILE_ERRORCODES_H - -// turn off clang-format because alignment doesn't persist across comments -// with current settings -// clang-format off - -#define FATAL_ERROR_ALLOCATION (1) -#define FATAL_ERROR_DIVIDE_ZERO (2) -#define FATAL_ERROR_INTERNAL (3) -#define FATAL_ERROR_PARAMETER (4) -#define FATAL_ERROR_ENTROPY (5) -#define FATAL_ERROR_SELF_TEST (6) -#define FATAL_ERROR_CRYPTO (7) -#define FATAL_ERROR_NV_UNRECOVERABLE (8) - -// indicates that the TPM has been re-manufactured after an -// unrecoverable NV error -#define FATAL_ERROR_REMANUFACTURED (9) -#define FATAL_ERROR_DRBG (10) -#define FATAL_ERROR_MOVE_SIZE (11) -#define FATAL_ERROR_COUNTER_OVERFLOW (12) -#define FATAL_ERROR_SUBTRACT (13) -#define FATAL_ERROR_MATHLIBRARY (14) -// end of codes defined through v1.52 - -// leave space for numbers that may have been used by vendors or platforms. -// Ultimately this file and these ranges are only a suggestion because -// TPM2_GetTestResult returns manufacturer-defined data in failure mode. -// Reserve 15-499 -#define FATAL_ERROR_RESERVED_START (15) -#define FATAL_ERROR_RESERVED_END (499) - -// Additional error codes defined by TPM library: -#define FATAL_ERROR_ASSERT (500) -// Platform library violated interface contract. -#define FATAL_ERROR_PLATFORM (600) - -// Test/Simulator errors 1000+ -#define FATAL_ERROR_FORCED (1000) - -#endif // _TPMPROFILE_ERRORCODES_H diff --git a/src/tpm2/TpmProfile_Misc.h b/src/tpm2/TpmProfile_Misc.h deleted file mode 100644 index 9696a9e88..000000000 --- a/src/tpm2/TpmProfile_Misc.h +++ /dev/null @@ -1,134 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* 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 */ -/* */ -/********************************************************************************/ - -// Misc profile settings that don't currently have a better home. -// These are rarely changed, but available for vendor customization. - -#ifndef _TPM_PROFILE_MISC_H_ -#define _TPM_PROFILE_MISC_H_ - -// YES & NO defined by TpmBuildSwitches.h -#if(YES != 1 || NO != 0) -# error YES or NO incorrectly set -#endif - -// clang-format off -// clang-format off to preserve horizontal spacing -#define IMPLEMENTATION_PCR 24 -#define PLATFORM_PCR 24 -#define DRTM_PCR 17 -#define HCRTM_PCR 0 -#define NUM_LOCALITIES 5 -#define MAX_HANDLE_NUM 3 -#define MAX_ACTIVE_SESSIONS 64 -#define MAX_LOADED_SESSIONS 3 -#define MAX_SESSION_NUM 3 -#define MAX_LOADED_OBJECTS 3 -#define MIN_EVICT_OBJECTS 7 /* libtpms: for PC client */ -#define NUM_POLICY_PCR_GROUP 1 -#define NUM_AUTHVALUE_PCR_GROUP 1 -//#define MAX_CONTEXT_SIZE 2168 -#define MAX_CONTEXT_SIZE 2680 /* libtpms: changed for RSA-3072 */ -#define MAX_DIGEST_BUFFER 1024 -#define MAX_NV_INDEX_SIZE 2048 -#define MAX_NV_BUFFER_SIZE 1024 -#define MAX_CAP_BUFFER 1024 -/* libtmps: 65 OBJECTs in USER NVRAM expanded by 704 bytes due to size - * increase of OBJECT from 2048 bit RSA keys to 3072 bit by 704 bytes*/ -#define NV_MEMORY_SIZE (128 * 1024 + 65 * 704) /* libtpms changed */ -#define MIN_COUNTER_INDICES 8 -#define NUM_STATIC_PCR 16 -#define MAX_ALG_LIST_SIZE 64 -#define PRIMARY_SEED_SIZE 64 /* libtpms: 64 per define USE_SPEC_COMPLIANT_PROOFS */ -#define CONTEXT_ENCRYPT_ALGORITHM AES -#define NV_CLOCK_UPDATE_INTERVAL 12 /* libtpms: keep old value */ -#define NUM_POLICY_PCR 1 - -#define ORDERLY_BITS 8 -#define MAX_SYM_DATA 128 -#define MAX_RNG_ENTROPY_SIZE 64 -#define RAM_INDEX_SPACE 512 -#define ENABLE_PCR_NO_INCREMENT YES - -#define SIZE_OF_X509_SERIAL_NUMBER 20 - -// amount of space the platform can provide in PERSISTENT_DATA during -// manufacture -#define PERSISTENT_DATA_PLATFORM_SPACE 0 /* libtpms: changed from '16' */ - -// structure padding space for these structures. Used if a -// particular configuration needs them to be aligned to a -// specific size -#define ORDERLY_DATA_PADDING 0 -#define STATE_CLEAR_DATA_PADDING 0 -#define STATE_RESET_DATA_PADDING 0 - -// configuration values that may vary by SIMULATION/DEBUG -#if SIMULATION && DEBUG -// This forces the use of a smaller context slot size. This reduction reduces the -// range of the epoch allowing the tester to force the epoch to occur faster than -// the normal production size -# define CONTEXT_SLOT UINT8 -# error SIMULATION & DEBUG is not supported /* libtpms: added */ -#else -# define CONTEXT_SLOT UINT16 /* libtpms: changed from UINT8 in v0.9.0 */ -#endif - -#endif // _TPM_PROFILE_MISC_H_ diff --git a/src/tpm2/TpmSizeChecks_fp.h b/src/tpm2/TpmSizeChecks_fp.h deleted file mode 100644 index 695a63be7..000000000 --- a/src/tpm2/TpmSizeChecks_fp.h +++ /dev/null @@ -1,80 +0,0 @@ -/********************************************************************************/ -/* */ -/* Check COmpiler Options */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: TpmSizeChecks_fp.h 1519 2019-11-15 20:43:51Z 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 */ -/* */ -/********************************************************************************/ - -/*(Auto-generated) - * Created by TpmPrototypes; Version 3.0 July 18, 2017 - * Date: Oct 24, 2019 Time: 11:37:07AM - */ - -#ifndef _TPM_SIZE_CHECKS_FP_H_ -#define _TPM_SIZE_CHECKS_FP_H_ - -#if RUNTIME_SIZE_CHECKS - -//** TpmSizeChecks() -// This function is used during the development process to make sure that the -// vendor-specific values result in a consistent implementation. When possible, -// the code contains "#if" to do compile-time checks. However, in some cases, the -// values require the use of "sizeof()" and that can't be used in an #if. -BOOL TpmSizeChecks(void); -#endif // RUNTIME_SIZE_CHECKS - -#endif // _TPM_SIZE_CHECKS_FP_H_ diff --git a/src/tpm2/TpmTcpProtocol.h b/src/tpm2/TpmTcpProtocol.h deleted file mode 100644 index 095268665..000000000 --- a/src/tpm2/TpmTcpProtocol.h +++ /dev/null @@ -1,156 +0,0 @@ -/********************************************************************************/ -/* */ -/* TPM commands are communicated as BYTE streams on a TCP connection */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: TpmTcpProtocol.h 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, 2016 - 2021 */ -/* */ -/********************************************************************************/ - -//** Introduction - -// TPM commands are communicated as uint8_t streams on a TCP connection. The TPM -// command protocol is enveloped with the interface protocol described in this -// file. The command is indicated by a uint32 with one of the values below. Most -// commands take no parameters return no TPM errors. In these cases the TPM -// interface protocol acknowledges that command processing is completed by returning -// a uint32=0. The command TPM_SIGNAL_HASH_DATA takes a uint32-prepended variable -// length byte array and the interface protocol acknowledges command completion -// with a uint32=0. Most TPM commands are enveloped using the TPM_SEND_COMMAND -// interface command. The parameters are as indicated below. The interface layer -// also appends a UIN32=0 to the TPM response for regularity. - -//** Typedefs and Defines -#ifndef TCP_TPM_PROTOCOL_H -#define TCP_TPM_PROTOCOL_H - -//** TPM Commands. -// All commands acknowledge processing by returning a uint32 == 0 except where noted -#define TPM_SIGNAL_POWER_ON 1 -#define TPM_SIGNAL_POWER_OFF 2 -#define TPM_SIGNAL_PHYS_PRES_ON 3 -#define TPM_SIGNAL_PHYS_PRES_OFF 4 -#define TPM_SIGNAL_HASH_START 5 -#define TPM_SIGNAL_HASH_DATA 6 -// {uint32_t BufferSize, uint8_t[BufferSize] Buffer} -#define TPM_SIGNAL_HASH_END 7 -#define TPM_SEND_COMMAND 8 -// {uint8_t Locality, uint32_t InBufferSize, uint8_t[InBufferSize] InBuffer} -> -// {uint32_t OutBufferSize, uint8_t[OutBufferSize] OutBuffer} - -#define TPM_SIGNAL_CANCEL_ON 9 -#define TPM_SIGNAL_CANCEL_OFF 10 -#define TPM_SIGNAL_NV_ON 11 -#define TPM_SIGNAL_NV_OFF 12 -#define TPM_SIGNAL_KEY_CACHE_ON 13 -#define TPM_SIGNAL_KEY_CACHE_OFF 14 - -#define TPM_REMOTE_HANDSHAKE 15 -#define TPM_SET_ALTERNATIVE_RESULT 16 - -#define TPM_SIGNAL_RESET 17 -#define TPM_SIGNAL_RESTART 18 - -#define TPM_SESSION_END 20 -#define TPM_STOP 21 - -#define TPM_GET_COMMAND_RESPONSE_SIZES 25 - -#define TPM_ACT_GET_SIGNALED 26 - -#define TPM_TEST_FAILURE_MODE 30 - -#define TPM_SET_FW_HASH 35 -#define TPM_SET_FW_SVN 36 - -//** Enumerations and Structures -enum TpmEndPointInfo -{ - tpmPlatformAvailable = 0x01, - tpmUsesTbs = 0x02, - tpmInRawMode = 0x04, - tpmSupportsPP = 0x08 -}; - -#ifdef _MSC_VER -# pragma warning(push, 3) -#endif - -// Existing RPC interface type definitions retained so that the implementation -// can be re-used -typedef struct in_buffer -{ - unsigned long BufferSize; - unsigned char* Buffer; -} _IN_BUFFER; - -typedef unsigned char* _OUTPUT_BUFFER; - -typedef struct out_buffer -{ - uint32_t BufferSize; - _OUTPUT_BUFFER Buffer; -} _OUT_BUFFER; - -#ifdef _MSC_VER -# pragma warning(pop) -#endif - -#ifndef WIN32 -typedef unsigned long DWORD; -typedef void* LPVOID; -#endif - -#endif diff --git a/src/tpm2/Unique.c b/src/tpm2/Unique.c deleted file mode 100644 index 23d50b67b..000000000 --- a/src/tpm2/Unique.c +++ /dev/null @@ -1,108 +0,0 @@ -/********************************************************************************/ -/* */ -/* Secret Value to the TPM */ -/* 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 */ -/* */ -/********************************************************************************/ - -//** Introduction -// In some implementations of the TPM, the hardware can provide a secret -// value to the TPM. This secret value is statistically unique to the -// instance of the TPM. Typical uses of this value are to provide -// personalization to the random number generation and as a shared secret -// between the TPM and the manufacturer. - -//** Includes -#include "Platform.h" - -#if VENDOR_PERMANENT_AUTH_ENABLED == YES - -const char notReallyUnique[] = "This is not really a unique value. A real " - "unique value should" - " be generated by the platform."; - -//** _plat__GetUnique() -// This function is used to access the platform-specific vendor unique values. -// This function places the unique value in the provided buffer ('b') -// and returns the number of bytes transferred. The function will not -// copy more data than 'bSize'. -// NOTE: If a platform unique value has unequal distribution of uniqueness -// and 'bSize' is smaller than the size of the unique value, the 'bSize' -// portion with the most uniqueness should be returned. -// -// 'which' indicates the unique value to return: -// 0 = RESERVED, do not use -// 1 = the VENDOR_PERMANENT_AUTH_HANDLE authorization value for this device -LIB_EXPORT uint32_t _plat__GetUnique(uint32_t which, // which vendor value to return? - uint32_t bSize, // size of the buffer - unsigned char* b // output buffer -) -{ - const char* from = notReallyUnique; - uint32_t retVal = 0; - - if(which == 1) - { - const size_t uSize = - sizeof(notReallyUnique) <= bSize ? sizeof(notReallyUnique) : bSize; - MemoryCopy(b, notReallyUnique, uSize); - } - // else fall through to default 0 - - return retVal; -} - -#endif diff --git a/src/tpm2/Unmarshal.c b/src/tpm2/Unmarshal.c index f33973264..32cb30ef7 100644 --- a/src/tpm2/Unmarshal.c +++ b/src/tpm2/Unmarshal.c @@ -1,40 +1,12 @@ -/********************************************************************************/ -/* */ -/* Parameter Unmarshaling */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* */ -/* (c) Copyright IBM Corporation 2015 - 2024 */ -/* */ -/* All rights reserved. */ -/* */ -/* Redistribution and use in source and binary forms, with or without */ -/* modification, are permitted provided that the following conditions are */ -/* met: */ -/* */ -/* Redistributions of source code must retain the above copyright notice, */ -/* this list of conditions and the following disclaimer. */ -/* */ -/* Redistributions in binary form must reproduce the above copyright */ -/* notice, this list of conditions and the following disclaimer in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* Neither the names of the IBM Corporation nor the names of its */ -/* contributors may be used to endorse or promote products derived from */ -/* this software without specific prior written permission. */ -/* */ -/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */ -/* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */ -/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR */ -/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */ -/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */ -/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */ -/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, */ -/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY */ -/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */ -/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE */ -/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause + +// (c) Copyright IBM Corporation 2015 - 2024 +// +// All rights reserved. +// +// Neither the names of the IBM Corporation nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. /* rev 136 */ @@ -457,6 +429,10 @@ TPM_CAP_Unmarshal(TPM_CAP *target, BYTE **buffer, INT32 *size) case TPM_CAP_ECC_CURVES: case TPM_CAP_AUTH_POLICIES: case TPM_CAP_ACT: +# if SEC_CHANNEL_SUPPORT + case TPM_CAP_PUB_KEYS: + case TPM_CAP_SPDM_SESSION_INFO: +# endif // SEC_CHANNEL_SUPPORT case TPM_CAP_VENDOR_PROPERTY: break; default: diff --git a/src/tpm2/Unmarshal_fp.h b/src/tpm2/Unmarshal_fp.h index 4f48a3ad0..8a28e6f8e 100644 --- a/src/tpm2/Unmarshal_fp.h +++ b/src/tpm2/Unmarshal_fp.h @@ -1,61 +1,41 @@ +// SPDX-License-Identifier: BSD-2-Clause + /********************************************************************************/ /* */ /* Unmarshal Prototypes */ /* Written by Ken Goldman */ /* IBM Thomas J. Watson Research Center */ /* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012 - 2023 */ +/* (c) Copyright IBM Corporation 2015 - 2026 */ /* */ +/* All rights reserved. */ +/* */ +/* Redistribution and use in source and binary forms, with or without */ +/* modification, are permitted provided that the following conditions are */ +/* met: */ +/* */ +/* Redistributions of source code must retain the above copyright notice, */ +/* this list of conditions and the following disclaimer. */ +/* */ +/* Redistributions in binary form must reproduce the above copyright */ +/* notice, this list of conditions and the following disclaimer in the */ +/* documentation and/or other materials provided with the distribution. */ +/* */ +/* Neither the names of the IBM Corporation nor the names of its */ +/* contributors may be used to endorse or promote products derived from */ +/* this software without specific prior written permission. */ +/* */ +/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */ +/* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */ +/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR */ +/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */ +/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */ +/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */ +/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, */ +/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY */ +/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */ +/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE */ +/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /********************************************************************************/ /* rev 136 */ @@ -64,7 +44,7 @@ #define UNMARSHAL_FP_H #include "Tpm.h" -#include "TpmTypes.h" +#include #ifdef __cplusplus extern "C" { diff --git a/src/tpm2/Unseal_fp.h b/src/tpm2/Unseal_fp.h deleted file mode 100644 index 83a3ad945..000000000 --- a/src/tpm2/Unseal_fp.h +++ /dev/null @@ -1,90 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: Unseal_fp.h 809 2016-11-16 18:31:54Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_Unseal // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_UNSEAL_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_UNSEAL_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_DH_OBJECT itemHandle; -} Unseal_In; - -// Output structure definition -typedef struct -{ - TPM2B_SENSITIVE_DATA outData; -} Unseal_Out; - -// Response code modifiers -# define RC_Unseal_itemHandle (TPM_RC_H + TPM_RC_1) - -// Function prototype -TPM_RC -TPM2_Unseal(Unseal_In* in, Unseal_Out* out); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_UNSEAL_FP_H_ -#endif // CC_Unseal diff --git a/src/tpm2/Utils.h b/src/tpm2/Utils.h index b9becef29..e79072d63 100644 --- a/src/tpm2/Utils.h +++ b/src/tpm2/Utils.h @@ -1,45 +1,11 @@ -/********************************************************************************/ -/* */ -/* Utility functions */ -/* Written by Stefan Berger */ -/* IBM Thomas J. Watson Research Center */ -/* */ -/* (c) Copyright IBM Corporation 2017,2018. */ -/* */ -/* All rights reserved. */ -/* */ -/* Redistribution and use in source and binary forms, with or without */ -/* modification, are permitted provided that the following conditions are */ -/* met: */ -/* */ -/* Redistributions of source code must retain the above copyright notice, */ -/* this list of conditions and the following disclaimer. */ -/* */ -/* Redistributions in binary form must reproduce the above copyright */ -/* notice, this list of conditions and the following disclaimer in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* Neither the names of the IBM Corporation nor the names of its */ -/* contributors may be used to endorse or promote products derived from */ -/* this software without specific prior written permission. */ -/* */ -/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */ -/* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */ -/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR */ -/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */ -/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */ -/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */ -/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, */ -/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY */ -/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */ -/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE */ -/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause + +// (c) Copyright IBM Corporation 2017,2018. #ifndef UTILS_H #define UTILS_H -#include "Memory_fp.h" +#include "prototypes/Memory_fp.h" #define TPM2_ROUNDUP(VAL, SIZE) \ ( ( (VAL) + (SIZE) - 1) / (SIZE) ) * (SIZE) diff --git a/src/tpm2/VendorInfo.h b/src/tpm2/VendorInfo.h deleted file mode 100644 index 67f4323d0..000000000 --- a/src/tpm2/VendorInfo.h +++ /dev/null @@ -1,82 +0,0 @@ -/********************************************************************************/ -/* */ -/* Vendor Info */ -/* 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-2024 */ -/* */ -/********************************************************************************/ - - -#ifndef _VENDORINFO_H -#define _VENDORINFO_H - -// Define the TPM specification-specific capability values. -#define TPM_SPEC_FAMILY (0x322E3000) -#define TPM_SPEC_LEVEL_NUM 0 // libtpms added: TPM_SPEC_LEVEL without leading zeros and '()' -#define TPM_SPEC_LEVEL (00) -#define TPM_SPEC_VERSION 183 // libtpms changed: removed '()' -#define TPM_SPEC_YEAR (2024) -#define TPM_SPEC_DAY_OF_YEAR (25) -#define MAX_VENDOR_PROPERTY (1) - -// Define the platform specification-specific capability values. -#define PLATFORM_FAMILY (1) /* kgold changed for PC Client */ -#define PLATFORM_LEVEL TPM_SPEC_LEVEL_NUM // libtpms: changed -#define PLATFORM_VERSION (0x00000106) -#define PLATFORM_YEAR TPM_SPEC_YEAR // libtpms: changed -#define PLATFORM_DAY_OF_YEAR TPM_SPEC_DAY_OF_YEAR // libtpms: changed - -#endif - diff --git a/src/tpm2/Vendor_TCG_Test.c b/src/tpm2/Vendor_TCG_Test.c deleted file mode 100644 index b8f674647..000000000 --- a/src/tpm2/Vendor_TCG_Test.c +++ /dev/null @@ -1,76 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: Vendor_TCG_Test.c 1548 2019-12-13 23:15:40Z 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 */ -/* */ -/********************************************************************************/ - -#include "Tpm.h" - -#if CC_Vendor_TCG_Test // Conditional expansion of this file -# include "Vendor_TCG_Test_fp.h" - -TPM_RC -TPM2_Vendor_TCG_Test(Vendor_TCG_Test_In* in, // IN: input parameter list - Vendor_TCG_Test_Out* out // OUT: output parameter list -) -{ - out->outputData = in->inputData; - return TPM_RC_SUCCESS; -} - -#endif // CC_Vendor_TCG_Test diff --git a/src/tpm2/Vendor_TCG_Test_fp.h b/src/tpm2/Vendor_TCG_Test_fp.h deleted file mode 100644 index 7f3149559..000000000 --- a/src/tpm2/Vendor_TCG_Test_fp.h +++ /dev/null @@ -1,90 +0,0 @@ -/********************************************************************************/ -/* */ -/* Sample Vendor Specific Command */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: Vendor_TCG_Test_fp.h 1635 2020-06-12 21:48:27Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2016 - 2020 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_Vendor_TCG_Test // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_VENDOR_TCG_TEST_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_VENDOR_TCG_TEST_FP_H_ - -// Input structure definition -typedef struct -{ - TPM2B_DATA inputData; -} Vendor_TCG_Test_In; - -// Output structure definition -typedef struct -{ - TPM2B_DATA outputData; -} Vendor_TCG_Test_Out; - -// Response code modifiers -# define RC_Vendor_TCG_Test_inputData (TPM_RC_P + TPM_RC_1) - -// Function prototype -TPM_RC -TPM2_Vendor_TCG_Test(Vendor_TCG_Test_In* in, Vendor_TCG_Test_Out* out); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_VENDOR_TCG_TEST_FP_H_ -#endif // CC_Vendor_TCG_Test diff --git a/src/tpm2/VerifyConfiguration.h b/src/tpm2/VerifyConfiguration.h deleted file mode 100644 index 85b05553e..000000000 --- a/src/tpm2/VerifyConfiguration.h +++ /dev/null @@ -1,152 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* 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 */ -/* */ -/********************************************************************************/ - -// -// This verifies that information expected from the consumer's TpmConfiguration is -// set properly and consistently. -// -#ifndef _VERIFY_CONFIGURATION_H -#define _VERIFY_CONFIGURATION_H - -// verify these defines are either YES or NO. -#define MUST_BE_0_OR_1(x) MUST_BE(((x) == 0) || ((x) == 1)) - -// Debug Options -MUST_BE_0_OR_1(DEBUG); -MUST_BE_0_OR_1(SIMULATION); -MUST_BE_0_OR_1(DRBG_DEBUG_PRINT); -MUST_BE_0_OR_1(CERTIFYX509_DEBUG); -MUST_BE_0_OR_1(USE_DEBUG_RNG); - -// RSA Debug Options -MUST_BE_0_OR_1(RSA_INSTRUMENT); -MUST_BE_0_OR_1(USE_RSA_KEY_CACHE); -MUST_BE_0_OR_1(USE_KEY_CACHE_FILE); - -// Test Options -MUST_BE_0_OR_1(ALLOW_FORCE_FAILURE_MODE); - -// Internal checks -MUST_BE_0_OR_1(LIBRARY_COMPATIBILITY_CHECK); -MUST_BE_0_OR_1(COMPILER_CHECKS); -MUST_BE_0_OR_1(RUNTIME_SIZE_CHECKS); - -// Compliance options -MUST_BE_0_OR_1(FIPS_COMPLIANT); -MUST_BE_0_OR_1(USE_SPEC_COMPLIANT_PROOFS); -MUST_BE_0_OR_1(SKIP_PROOF_ERRORS); - -// Implementation alternatives - should not change external behavior -MUST_BE_0_OR_1(TABLE_DRIVEN_DISPATCH); -MUST_BE_0_OR_1(TABLE_DRIVEN_MARSHAL); -MUST_BE_0_OR_1(USE_MARSHALING_DEFINES); -MUST_BE_0_OR_1(COMPRESSED_LISTS); -MUST_BE_0_OR_1(USE_BIT_FIELD_STRUCTURES); -MUST_BE_0_OR_1(RSA_KEY_SIEVE); - -// Implementation alternatives - changes external behavior -MUST_BE_0_OR_1(_DRBG_STATE_SAVE); -MUST_BE_0_OR_1(USE_DA_USED); -MUST_BE_0_OR_1(ENABLE_SELF_TESTS); -MUST_BE_0_OR_1(CLOCK_STOPS); -MUST_BE_0_OR_1(ACCUMULATE_SELF_HEAL_TIMER); -MUST_BE_0_OR_1(FAIL_TRACE); - -// Vendor alternatives -// Check VENDOR_PERMANENT_AUTH_ENABLED & VENDOR_PERMANENT_AUTH_HANDLE are consistent -MUST_BE_0_OR_1(VENDOR_PERMANENT_AUTH_ENABLED); - -#if VENDOR_PERMANENT_AUTH_ENABLED == YES -# if !defined(VENDOR_PERMANENT_AUTH_HANDLE) \ - || VENDOR_PERMANENT_AUTH_HANDLE < TPM_RH_AUTH_00 \ - || VENDOR_PERMANENT_AUTH_HANDLE > TPM_RH_AUTH_FF -# error VENDOR_PERMANENT_AUTH_ENABLED requires a valid definition for VENDOR_PERMANENT_AUTH_HANDLE, see Part2 -# endif -#else -# if defined(VENDOR_PERMANENT_AUTH_HANDLE) -# error VENDOR_PERMANENT_AUTH_HANDLE requires VENDOR_PERMANENT_AUTH_ENABLED to be YES -# endif -#endif - -// now check for inconsistent combinations of options -#if USE_KEY_CACHE_FILE && !USE_RSA_KEY_CACHE -# error cannot use USE_KEY_CACHE_FILE if not using USE_RSA_KEY_CACHE -#endif - -#if !DEBUG -# if USE_KEY_CACHE_FILE || USE_RSA_KEY_CACHE || DRBG_DEBUG_PRINT \ - || CERTIFYX509_DEBUG || USE_DEBUG_RNG -# error using insecure options not in DEBUG mode. -# endif -#endif - -#if !SIMULATION -# if USE_KEY_CACHE_FILE -# error USE_KEY_CACHE_FILE requires SIMULATION -# endif -# if RSA_INSTRUMENT -# error RSA_INSTRUMENT requires SIMULATION -# endif -# if USE_DEBUG_RNG -# error USE_DEBUG_RNG requires SIMULATION -# endif -#endif - -#endif // _VERIFY_CONFIGURATION_H diff --git a/src/tpm2/VerifySignature_fp.h b/src/tpm2/VerifySignature_fp.h deleted file mode 100644 index 17719e1dd..000000000 --- a/src/tpm2/VerifySignature_fp.h +++ /dev/null @@ -1,94 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: VerifySignature_fp.h 809 2016-11-16 18:31:54Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_VerifySignature // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_VERIFYSIGNATURE_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_VERIFYSIGNATURE_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_DH_OBJECT keyHandle; - TPM2B_DIGEST digest; - TPMT_SIGNATURE signature; -} VerifySignature_In; - -// Output structure definition -typedef struct -{ - TPMT_TK_VERIFIED validation; -} VerifySignature_Out; - -// Response code modifiers -# define RC_VerifySignature_keyHandle (TPM_RC_H + TPM_RC_1) -# define RC_VerifySignature_digest (TPM_RC_P + TPM_RC_1) -# define RC_VerifySignature_signature (TPM_RC_P + TPM_RC_2) - -// Function prototype -TPM_RC -TPM2_VerifySignature(VerifySignature_In* in, VerifySignature_Out* out); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_VERIFYSIGNATURE_FP_H_ -#endif // CC_VerifySignature diff --git a/src/tpm2/Volatile.c b/src/tpm2/Volatile.c index cedeb4a6e..c0d30f3a3 100644 --- a/src/tpm2/Volatile.c +++ b/src/tpm2/Volatile.c @@ -1,40 +1,6 @@ -/********************************************************************************/ -/* */ -/* Marshalling and unmarshalling of state */ -/* Written by Stefan Berger */ -/* IBM Thomas J. Watson Research Center */ -/* */ -/* (c) Copyright IBM Corporation 2017,2018. */ -/* */ -/* All rights reserved. */ -/* */ -/* Redistribution and use in source and binary forms, with or without */ -/* modification, are permitted provided that the following conditions are */ -/* met: */ -/* */ -/* Redistributions of source code must retain the above copyright notice, */ -/* this list of conditions and the following disclaimer. */ -/* */ -/* Redistributions in binary form must reproduce the above copyright */ -/* notice, this list of conditions and the following disclaimer in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* Neither the names of the IBM Corporation nor the names of its */ -/* contributors may be used to endorse or promote products derived from */ -/* this software without specific prior written permission. */ -/* */ -/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */ -/* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */ -/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR */ -/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */ -/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */ -/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */ -/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, */ -/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY */ -/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */ -/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE */ -/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause + +// (c) Copyright IBM Corporation 2017,2018. #if defined __FreeBSD__ || defined __DragonFly__ # include @@ -112,7 +78,7 @@ VolatileState_Load(BYTE **buffer, INT32 *size) rc = irc; if (rc != TPM_RC_SUCCESS) - g_inFailureMode = TRUE; + _plat__SetInFailureMode(TRUE); return rc; } diff --git a/src/tpm2/Volatile.h b/src/tpm2/Volatile.h index 9913e8d91..3fd704c18 100644 --- a/src/tpm2/Volatile.h +++ b/src/tpm2/Volatile.h @@ -1,45 +1,11 @@ -/********************************************************************************/ -/* */ -/* Marshalling and unmarshalling of state */ -/* Written by Stefan Berger */ -/* IBM Thomas J. Watson Research Center */ -/* */ -/* (c) Copyright IBM Corporation 2017,2018. */ -/* */ -/* All rights reserved. */ -/* */ -/* Redistribution and use in source and binary forms, with or without */ -/* modification, are permitted provided that the following conditions are */ -/* met: */ -/* */ -/* Redistributions of source code must retain the above copyright notice, */ -/* this list of conditions and the following disclaimer. */ -/* */ -/* Redistributions in binary form must reproduce the above copyright */ -/* notice, this list of conditions and the following disclaimer in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* Neither the names of the IBM Corporation nor the names of its */ -/* contributors may be used to endorse or promote products derived from */ -/* this software without specific prior written permission. */ -/* */ -/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */ -/* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */ -/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR */ -/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */ -/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */ -/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */ -/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, */ -/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY */ -/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */ -/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE */ -/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/********************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause + +// (c) Copyright IBM Corporation 2017,2018. #ifndef VOLATILE_H #define VOLATILE_H -#include "BaseTypes.h" +#include TPM_RC VolatileState_Load(BYTE **buffer, INT32 *size); UINT16 VolatileState_Save(BYTE **buffer, INT32 *size); diff --git a/src/tpm2/X509.h b/src/tpm2/X509.h deleted file mode 100644 index d5839a8e0..000000000 --- a/src/tpm2/X509.h +++ /dev/null @@ -1,159 +0,0 @@ -/********************************************************************************/ -/* */ -/* Macro and Structure Definitions for the X509 Commands and Functions. */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: X509.h 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 */ -/* */ -/********************************************************************************/ - -//** Introduction -// This file contains the macro and structure definitions for the X509 commands and -// functions. - -#ifndef _X509_H_ -#define _X509_H_ - -//** Includes - -#include "Tpm.h" -#include "TpmASN1.h" - -//** Defined Constants - -//*** X509 Application-specific types -#define X509_SELECTION 0xA0 -#define X509_ISSUER_UNIQUE_ID 0xA1 -#define X509_SUBJECT_UNIQUE_ID 0xA2 -#define X509_EXTENSIONS 0xA3 - -// These defines give the order in which values appear in the TBScertificate -// of an x.509 certificate. These values are used to index into an array of -// -#define ENCODED_SIZE_REF 0 -#define VERSION_REF (ENCODED_SIZE_REF + 1) -#define SERIAL_NUMBER_REF (VERSION_REF + 1) -#define SIGNATURE_REF (SERIAL_NUMBER_REF + 1) -#define ISSUER_REF (SIGNATURE_REF + 1) -#define VALIDITY_REF (ISSUER_REF + 1) -#define SUBJECT_KEY_REF (VALIDITY_REF + 1) -#define SUBJECT_PUBLIC_KEY_REF (SUBJECT_KEY_REF + 1) -#define EXTENSIONS_REF (SUBJECT_PUBLIC_KEY_REF + 1) -#define REF_COUNT (EXTENSIONS_REF + 1) - -//** Structures - -// Used to access the fields of a TBSsignature some of which are in the in_CertifyX509 -// structure and some of which are in the out_CertifyX509 structure. -typedef struct stringRef -{ - BYTE* buf; - INT16 len; -} stringRef; - -// This is defined to avoid bit by bit comparisons within a UINT32 -typedef union x509KeyUsageUnion -{ - TPMA_X509_KEY_USAGE x509; - UINT32 integer; -} x509KeyUsageUnion; - -//** Global X509 Constants -// These values are instanced by X509_spt.c and referenced by other X509-related -// files. - -// This is the DER-encoded value for the Key Usage OID (2.5.29.15). This is the -// full OID, not just the numeric value -#define OID_KEY_USAGE_EXTENSION_VALUE 0x06, 0x03, 0x55, 0x1D, 0x0F -MAKE_OID(_KEY_USAGE_EXTENSION); - -// This is the DER-encoded value for the TCG-defined TPMA_OBJECT OID -// (2.23.133.10.1.1.1) -#define OID_TCG_TPMA_OBJECT_VALUE 0x06, 0x07, 0x67, 0x81, 0x05, 0x0a, 0x01, 0x01, 0x01 -MAKE_OID(_TCG_TPMA_OBJECT); - -#ifdef _X509_SPT_ -// If a bit is SET in KEY_USAGE_SIGN is also SET in keyUsage then -// the associated key has to have 'sign' SET. -const x509KeyUsageUnion KEY_USAGE_SIGN = {TPMA_X509_KEY_USAGE_INITIALIZER( - /* bits_at_0 */ 0, - /* decipheronly */ 0, - /* encipheronly */ 0, - /* crlsign */ 1, - /* keycertsign */ 1, - /* keyagreement */ 0, - /* dataencipherment */ 0, - /* keyencipherment */ 0, - /* nonrepudiation */ 0, - /* digitalsignature */ 1)}; -// If a bit is SET in KEY_USAGE_DECRYPT is also SET in keyUsage then -// the associated key has to have 'decrypt' SET. -const x509KeyUsageUnion KEY_USAGE_DECRYPT = {TPMA_X509_KEY_USAGE_INITIALIZER( - /* bits_at_0 */ 0, - /* decipheronly */ 1, - /* encipheronly */ 1, - /* crlsign */ 0, - /* keycertsign */ 0, - /* keyagreement */ 1, - /* dataencipherment */ 1, - /* keyencipherment */ 1, - /* nonrepudiation */ 0, - /* digitalsignature */ 0)}; -#else -extern x509KeyUsageUnion KEY_USAGE_SIGN; -extern x509KeyUsageUnion KEY_USAGE_DECRYPT; -#endif - -#endif // _X509_H_ diff --git a/src/tpm2/X509_ECC_fp.h b/src/tpm2/X509_ECC_fp.h deleted file mode 100644 index e570c3dcc..000000000 --- a/src/tpm2/X509_ECC_fp.h +++ /dev/null @@ -1,97 +0,0 @@ -/********************************************************************************/ -/* */ -/* TPM X509 ECC */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: X509_ECC_fp.h 1490 2019-07-26 21:13:22Z 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 */ -/* */ -/********************************************************************************/ - -/*(Auto-generated) - * Created by TpmPrototypes; Version 3.0 July 18, 2017 - * Date: Apr 2, 2019 Time: 11:00:49AM - */ - -#ifndef _X509_ECC_FP_H_ -#define _X509_ECC_FP_H_ - -//*** X509PushPoint() -// This seems like it might be used more than once so... -// Return Type: INT16 -// > 0 number of bytes added -// == 0 failure -INT16 -X509PushPoint(ASN1MarshalContext* ctx, TPMS_ECC_POINT* p); - -//*** X509AddSigningAlgorithmECC() -// This creates the singing algorithm data. -// Return Type: INT16 -// > 0 number of bytes added -// == 0 failure -INT16 -X509AddSigningAlgorithmECC( - OBJECT* signKey, TPMT_SIG_SCHEME* scheme, ASN1MarshalContext* ctx); - -//*** X509AddPublicECC() -// This function will add the publicKey description to the DER data. If ctx is -// NULL, then no data is transferred and this function will indicate if the TPM -// has the values for DER-encoding of the public key. -// Return Type: INT16 -// > 0 number of bytes added -// == 0 failure -INT16 -X509AddPublicECC(OBJECT* object, ASN1MarshalContext* ctx); - -#endif // _X509_ECC_FP_H_ diff --git a/src/tpm2/X509_RSA_fp.h b/src/tpm2/X509_RSA_fp.h deleted file mode 100644 index 6f4cd1ee7..000000000 --- a/src/tpm2/X509_RSA_fp.h +++ /dev/null @@ -1,92 +0,0 @@ -/********************************************************************************/ -/* */ -/* TPM X509 RSA */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: X509_RSA_fp.h 1490 2019-07-26 21:13:22Z 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 */ -/* */ -/********************************************************************************/ - -/*(Auto-generated) - * Created by TpmPrototypes; Version 3.0 July 18, 2017 - * Date: Apr 2, 2019 Time: 11:00:49AM - */ - -#ifndef _X509_RSA_FP_H_ -#define _X509_RSA_FP_H_ - -#if ALG_RSA - -//*** X509AddSigningAlgorithmRSA() -// This creates the singing algorithm data. -// Return Type: INT16 -// > 0 number of bytes added -// == 0 failure -INT16 -X509AddSigningAlgorithmRSA( - OBJECT* signKey, TPMT_SIG_SCHEME* scheme, ASN1MarshalContext* ctx); - -//*** X509AddPublicRSA() -// This function will add the publicKey description to the DER data. If fillPtr is -// NULL, then no data is transferred and this function will indicate if the TPM -// has the values for DER-encoding of the public key. -// Return Type: INT16 -// > 0 number of bytes added -// == 0 failure -INT16 -X509AddPublicRSA(OBJECT* object, ASN1MarshalContext* ctx); -#endif // ALG_RSA - -#endif // _X509_RSA_FP_H_ diff --git a/src/tpm2/X509_spt_fp.h b/src/tpm2/X509_spt_fp.h deleted file mode 100644 index 268feafcc..000000000 --- a/src/tpm2/X509_spt_fp.h +++ /dev/null @@ -1,132 +0,0 @@ -/********************************************************************************/ -/* */ -/* X509 Support */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: X509_spt_fp.h 1490 2019-07-26 21:13:22Z 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. */ -/* */ -/********************************************************************************/ - -/*(Auto-generated) - * Created by TpmPrototypes; Version 3.0 July 18, 2017 - * Date: Nov 14, 2019 Time: 05:57:02PM - */ - -#ifndef _X509_SPT_FP_H_ -#define _X509_SPT_FP_H_ - -//*** X509FindExtensionByOID() -// This will search a list of X509 extensions to find an extension with the -// requested OID. If the extension is found, the output context ('ctx') is set up -// to point to the OID in the extension. -// Return Type: BOOL -// TRUE(1) success -// FALSE(0) failure (could be catastrophic) -BOOL X509FindExtensionByOID(ASN1UnmarshalContext* ctxIn, // IN: the context to search - ASN1UnmarshalContext* ctx, // OUT: the extension context - const BYTE* OID // IN: oid to search for -); - -//*** X509GetExtensionBits() -// This function will extract a bit field from an extension. If the extension doesn't -// contain a bit string, it will fail. -// Return Type: BOOL -// TRUE(1) success -// FALSE(0) failure -UINT32 -X509GetExtensionBits(ASN1UnmarshalContext* ctx, UINT32* value); - -//***X509ProcessExtensions() -// This function is used to process the TPMA_OBJECT and KeyUsage extensions. It is not -// in the CertifyX509.c code because it makes the code harder to follow. -// Return Type: TPM_RC -// TPM_RCS_ATTRIBUTES the attributes of object are not consistent with -// the extension setting -// TPM_RC_VALUE problem parsing the extensions -TPM_RC -X509ProcessExtensions( - OBJECT* object, // IN: The object with the attributes to - // check - stringRef* extension // IN: The start and length of the extensions -); - -//*** X509AddSigningAlgorithm() -// This creates the singing algorithm data. -// Return Type: INT16 -// > 0 number of octets added -// <= 0 failure -INT16 -X509AddSigningAlgorithm( - ASN1MarshalContext* ctx, OBJECT* signKey, TPMT_SIG_SCHEME* scheme); - -//*** X509AddPublicKey() -// This function will add the publicKey description to the DER data. If fillPtr is -// NULL, then no data is transferred and this function will indicate if the TPM -// has the values for DER-encoding of the public key. -// Return Type: INT16 -// > 0 number of octets added -// == 0 failure -INT16 -X509AddPublicKey(ASN1MarshalContext* ctx, OBJECT* object); - -//*** X509PushAlgorithmIdentifierSequence() -// The function adds the algorithm identifier sequence. -// Return Type: INT16 -// > 0 number of bytes added -// == 0 failure -INT16 -X509PushAlgorithmIdentifierSequence(ASN1MarshalContext* ctx, const BYTE* OID); - -#endif // _X509_SPT_FP_H_ diff --git a/src/tpm2/ZGen_2Phase_fp.h b/src/tpm2/ZGen_2Phase_fp.h deleted file mode 100644 index 252d2e8e4..000000000 --- a/src/tpm2/ZGen_2Phase_fp.h +++ /dev/null @@ -1,99 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: ZGen_2Phase_fp.h 809 2016-11-16 18:31:54Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2012-2015 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_ZGen_2Phase // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_ZGEN_2PHASE_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_ZGEN_2PHASE_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_DH_OBJECT keyA; - TPM2B_ECC_POINT inQsB; - TPM2B_ECC_POINT inQeB; - TPMI_ECC_KEY_EXCHANGE inScheme; - UINT16 counter; -} ZGen_2Phase_In; - -// Output structure definition -typedef struct -{ - TPM2B_ECC_POINT outZ1; - TPM2B_ECC_POINT outZ2; -} ZGen_2Phase_Out; - -// Response code modifiers -# define RC_ZGen_2Phase_keyA (TPM_RC_H + TPM_RC_1) -# define RC_ZGen_2Phase_inQsB (TPM_RC_P + TPM_RC_1) -# define RC_ZGen_2Phase_inQeB (TPM_RC_P + TPM_RC_2) -# define RC_ZGen_2Phase_inScheme (TPM_RC_P + TPM_RC_3) -# define RC_ZGen_2Phase_counter (TPM_RC_P + TPM_RC_4) - -// Function prototype -TPM_RC -TPM2_ZGen_2Phase(ZGen_2Phase_In* in, ZGen_2Phase_Out* out); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_ZGEN_2PHASE_FP_H_ -#endif // CC_ZGen_2Phase diff --git a/src/tpm2/_TPM_Hash_Data_fp.h b/src/tpm2/_TPM_Hash_Data_fp.h deleted file mode 100644 index ee17c383b..000000000 --- a/src/tpm2/_TPM_Hash_Data_fp.h +++ /dev/null @@ -1,75 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: _TPM_Hash_Data_fp.h 1521 2019-11-15 21:00:47Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2016 */ -/* */ -/********************************************************************************/ - -/*(Auto-generated) - * Created by TpmPrototypes; Version 3.0 July 18, 2017 - * Date: Mar 28, 2019 Time: 08:25:19PM - */ - -#ifndef __TPM_HASH_DATA_FP_H_ -#define __TPM_HASH_DATA_FP_H_ - -// This function is called to process a _TPM_Hash_Data indication. -LIB_EXPORT void _TPM_Hash_Data(uint32_t dataSize, // IN: size of data to be extend - unsigned char* data // IN: data buffer -); - -#endif // __TPM_HASH_DATA_FP_H_ diff --git a/src/tpm2/_TPM_Hash_End_fp.h b/src/tpm2/_TPM_Hash_End_fp.h deleted file mode 100644 index e1ab079ca..000000000 --- a/src/tpm2/_TPM_Hash_End_fp.h +++ /dev/null @@ -1,73 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: _TPM_Hash_End_fp.h 1521 2019-11-15 21:00:47Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2016 */ -/* */ -/********************************************************************************/ - -/*(Auto-generated) - * Created by TpmPrototypes; Version 3.0 July 18, 2017 - * Date: Mar 28, 2019 Time: 08:25:19PM - */ - -#ifndef __TPM_HASH_END_FP_H_ -#define __TPM_HASH_END_FP_H_ - -// This function is called to process a _TPM_Hash_End indication. -LIB_EXPORT void _TPM_Hash_End(void); - -#endif // __TPM_HASH_END_FP_H_ diff --git a/src/tpm2/_TPM_Hash_Start_fp.h b/src/tpm2/_TPM_Hash_Start_fp.h deleted file mode 100644 index e187105d7..000000000 --- a/src/tpm2/_TPM_Hash_Start_fp.h +++ /dev/null @@ -1,73 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: _TPM_Hash_Start_fp.h 1521 2019-11-15 21:00:47Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2016 */ -/* */ -/********************************************************************************/ - -/*(Auto-generated) - * Created by TpmPrototypes; Version 3.0 July 18, 2017 - * Date: Mar 28, 2019 Time: 08:25:19PM - */ - -#ifndef __TPM_HASH_START_FP_H_ -#define __TPM_HASH_START_FP_H_ - -// This function is called to process a _TPM_Hash_Start indication. -LIB_EXPORT void _TPM_Hash_Start(void); - -#endif // __TPM_HASH_START_FP_H_ diff --git a/src/tpm2/_TPM_Init_fp.h b/src/tpm2/_TPM_Init_fp.h deleted file mode 100644 index 944da553f..000000000 --- a/src/tpm2/_TPM_Init_fp.h +++ /dev/null @@ -1,73 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: _TPM_Init_fp.h 1490 2019-07-26 21:13:22Z 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 */ -/* */ -/********************************************************************************/ - -/*(Auto-generated) - * Created by TpmPrototypes; Version 3.0 July 18, 2017 - * Date: Mar 28, 2019 Time: 08:25:19PM - */ - -#ifndef __TPM_INIT_FP_H_ -#define __TPM_INIT_FP_H_ - -// This function is used to process a _TPM_Init indication. -LIB_EXPORT void _TPM_Init(void); - -#endif // __TPM_INIT_FP_H_ diff --git a/src/tpm2/crypto/CryptCmac_fp.h b/src/tpm2/crypto/CryptCmac_fp.h deleted file mode 100644 index f61b26cee..000000000 --- a/src/tpm2/crypto/CryptCmac_fp.h +++ /dev/null @@ -1,97 +0,0 @@ -/********************************************************************************/ -/* Message Authentication Codes Based on a Symmetric Block Cipher */ -/* Implementation of cryptographic functions for hashing. */ -/* 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, 2018 - 2023 */ -/* */ -/********************************************************************************/ - -/*(Auto-generated) - * Created by TpmPrototypes; Version 3.0 July 18, 2017 - * Date: Mar 28, 2019 Time: 08:25:18PM - */ - -#ifndef _CRYPT_CMAC_FP_H_ -#define _CRYPT_CMAC_FP_H_ - -#if ALG_CMAC - -//*** CryptCmacStart() -// This is the function to start the CMAC sequence operation. It initializes the -// dispatch functions for the data and end operations for CMAC and initializes the -// parameters that are used for the processing of data, including the key, key size -// and block cipher algorithm. -UINT16 -CryptCmacStart( - SMAC_STATE* state, TPMU_PUBLIC_PARMS* keyParms, TPM_ALG_ID macAlg, TPM2B* key); - -//*** CryptCmacData() -// This function is used to add data to the CMAC sequence computation. The function -// will XOR new data into the IV. If the buffer is full, and there is additional -// input data, the data is encrypted into the IV buffer, the new data is then -// XOR into the IV. When the data runs out, the function returns without encrypting -// even if the buffer is full. The last data block of a sequence will not be -// encrypted until the call to CryptCmacEnd(). This is to allow the proper subkey -// to be computed and applied before the last block is encrypted. -void CryptCmacData(SMAC_STATES* state, UINT32 size, const BYTE* buffer); - -//*** CryptCmacEnd() -// This is the completion function for the CMAC. It does padding, if needed, and -// selects the subkey to be applied before the last block is encrypted. -UINT16 -CryptCmacEnd(SMAC_STATES* state, UINT32 outSize, BYTE* outBuffer); -#endif - -#endif // _CRYPT_CMAC_FP_H_ diff --git a/src/tpm2/crypto/CryptEcc.h b/src/tpm2/crypto/CryptEcc.h deleted file mode 100644 index 58a864c28..000000000 --- a/src/tpm2/crypto/CryptEcc.h +++ /dev/null @@ -1,120 +0,0 @@ -/********************************************************************************/ -/* */ -/* Structure definitions used for ECC */ -/* 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 */ -/* */ -/********************************************************************************/ - -//** Introduction -// -// This file contains structure definitions used for ECC. The structures in this -// file are only used internally. The ECC-related structures that cross the -// public TPM interface are defined in TpmTypes.h -// - -// ECC Curve data type decoder ring -// ================================ -// | Name | Old Name* | Comments | -// | ------------------------- | -------------- | ------------------------------------------------------------------------------------------ | -// | TPM_ECC_CURVE | | 16-bit Curve ID from Part 2 of TCG TPM Spec | -// | TPM_ECC_CURVE_METADATA | ECC_CURVE | See description below | -// | | | | -// * - if different - -// TPM_ECC_CURVE_METADATA -// ====================== -// TPM-specific metadata for a particular curve, such as OIDs and signing/kdf -// schemes associated with the curve. -// -// TODO_ECC: Need to remove the curve constants from this structure and replace -// them with a reference to math-lib provided calls. Note: this structure does *NOT* -// include the actual curve constants. The curve constants are no longer in this -// structure because the constants need to be in a format compatible with the -// math library and are retrieved by the `ExtEcc_CurveGet*` family of functions. -// -// Using the math library's constant structure here is not necessary and breaks -// encapsulation. Using a tpm-specific format means either redundancy (the same -// values exist here and in a math-specific format), or forces the math library -// to adopt a particular format determined by this structure. Neither outcome -// is as clean as simply leaving the actual constants out of this structure. - -#ifndef _CRYPT_ECC_H -#define _CRYPT_ECC_H - -//** Structures - -#define ECC_BITS (MAX_ECC_KEY_BYTES * 8) -CRYPT_INT_TYPE(ecc, ECC_BITS); - -#define CRYPT_ECC_NUM(name) CRYPT_INT_VAR(name, ECC_BITS) - -#define CRYPT_ECC_INITIALIZED(name, initializer) \ - CRYPT_INT_INITIALIZED(name, ECC_BITS, initializer) - -typedef struct TPM_ECC_CURVE_METADATA -{ - const TPM_ECC_CURVE curveId; - const UINT16 keySizeBits; - const TPMT_KDF_SCHEME kdf; - const TPMT_ECC_SCHEME sign; - const BYTE* OID; -} TPM_ECC_CURVE_METADATA; - -//*** Macros -extern const TPM_ECC_CURVE_METADATA eccCurves[ECC_CURVE_COUNT]; - -#endif diff --git a/src/tpm2/crypto/CryptEccCrypt_fp.h b/src/tpm2/crypto/CryptEccCrypt_fp.h deleted file mode 100644 index 872114f8f..000000000 --- a/src/tpm2/crypto/CryptEccCrypt_fp.h +++ /dev/null @@ -1,121 +0,0 @@ -/********************************************************************************/ -/* */ -/* Include Headers for Internal Routines */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: CryptEccCrypt_fp.h 1594 2020-03-26 22:15:48Z 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, 2020 - 2022 */ -/* */ -/********************************************************************************/ - -/*(Auto-generated) - * Created by TpmPrototypes; Version 3.0 July 18, 2017 - * Date: Feb 28, 2020 Time: 03:04:48PM - */ - -#ifndef _CRYPT_ECC_CRYPT_FP_H_ -#define _CRYPT_ECC_CRYPT_FP_H_ - -#if CC_ECC_Encrypt || CC_ECC_Encrypt - -//*** CryptEccSelectScheme() -// This function is used by TPM2_ECC_Decrypt and TPM2_ECC_Encrypt. It sets scheme -// either the input scheme or the key scheme. If they key scheme is not TPM_ALG_NULL -// then the input scheme must be TPM_ALG_NULL or the same as the key scheme. If -// not, then the function returns FALSE. -// Return Type: BOOL -// TRUE 'scheme' is set -// FALSE 'scheme' is not valid (it may have been changed). -BOOL CryptEccSelectScheme(OBJECT* key, //IN: key containing default scheme - TPMT_KDF_SCHEME* scheme // IN: a decrypt scheme -); - -//*** CryptEccEncrypt() -//This function performs ECC-based data obfuscation. The only scheme that is currently -// supported is MGF1 based. See Part 1, Annex D for details. -// Return Type: TPM_RC -// TPM_RC_CURVE unsupported curve -// TPM_RC_HASH hash not allowed -// TPM_RC_SCHEME 'scheme' is not supported -// TPM_RC_NO_RESULT internal error in big number processing -LIB_EXPORT TPM_RC CryptEccEncrypt( - OBJECT* key, // IN: public key of recipient - TPMT_KDF_SCHEME* scheme, // IN: scheme to use. - TPM2B_MAX_BUFFER* plainText, // IN: the text to obfuscate - TPMS_ECC_POINT* c1, // OUT: public ephemeral key - TPM2B_MAX_BUFFER* c2, // OUT: obfuscated text - TPM2B_DIGEST* c3 // OUT: digest of ephemeral key - // and plainText -); - -//*** CryptEccDecrypt() -// This function performs ECC decryption and integrity check of the input data. -// Return Type: TPM_RC -// TPM_RC_CURVE unsupported curve -// TPM_RC_HASH hash not allowed -// TPM_RC_SCHEME 'scheme' is not supported -// TPM_RC_NO_RESULT internal error in big number processing -// TPM_RC_VALUE C3 did not match hash of recovered data -LIB_EXPORT TPM_RC CryptEccDecrypt( - OBJECT* key, // IN: key used for data recovery - TPMT_KDF_SCHEME* scheme, // IN: scheme to use. - TPM2B_MAX_BUFFER* plainText, // OUT: the recovered text - TPMS_ECC_POINT* c1, // IN: public ephemeral key - TPM2B_MAX_BUFFER* c2, // IN: obfuscated text - TPM2B_DIGEST* c3 // IN: digest of ephemeral key - // and plainText -); -#endif // CC_ECC_Encrypt || CC_ECC_Encrypt - -#endif // _CRYPT_ECC_CRYPT_FP_H_ diff --git a/src/tpm2/crypto/CryptEccKeyExchange_fp.h b/src/tpm2/crypto/CryptEccKeyExchange_fp.h deleted file mode 100644 index 2edfed2d9..000000000 --- a/src/tpm2/crypto/CryptEccKeyExchange_fp.h +++ /dev/null @@ -1,112 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* 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 */ -/* */ -/********************************************************************************/ - -/*(Auto-generated) - * Created by TpmPrototypes; Version 3.0 July 18, 2017 - * Date: Mar 28, 2019 Time: 08:25:18PM - */ - -#ifndef _CRYPT_ECC_KEY_EXCHANGE_FP_H_ -#define _CRYPT_ECC_KEY_EXCHANGE_FP_H_ - -#if CC_ZGen_2Phase == YES - -//*** CryptEcc2PhaseKeyExchange() -// This function is the dispatch routine for the EC key exchange functions that use -// two ephemeral and two static keys. -// Return Type: TPM_RC -// TPM_RC_SCHEME scheme is not defined -LIB_EXPORT TPM_RC CryptEcc2PhaseKeyExchange( - TPMS_ECC_POINT* outZ1, // OUT: a computed point - TPMS_ECC_POINT* outZ2, // OUT: and optional second point - TPM_ECC_CURVE curveId, // IN: the curve for the computations - TPM_ALG_ID scheme, // IN: the key exchange scheme - TPM2B_ECC_PARAMETER* dsA, // IN: static private TPM key - TPM2B_ECC_PARAMETER* deA, // IN: ephemeral private TPM key - TPMS_ECC_POINT* QsB, // IN: static public party B key - TPMS_ECC_POINT* QeB // IN: ephemeral public party B key -); -# if ALG_SM2 - -//*** SM2KeyExchange() -// This function performs the key exchange defined in SM2. -// The first step is to compute -// 'tA' = ('dsA' + 'deA' avf(Xe,A)) mod 'n' -// Then, compute the 'Z' value from -// 'outZ' = ('h' 'tA' mod 'n') ('QsA' + [avf('QeB.x')]('QeB')). -// The function will compute the ephemeral public key from the ephemeral -// private key. -// All points are required to be on the curve of 'inQsA'. The function will fail -// catastrophically if this is not the case -// Return Type: TPM_RC -// TPM_RC_NO_RESULT the value for dsA does not give a valid point on the -// curve -LIB_EXPORT TPM_RC SM2KeyExchange( - TPMS_ECC_POINT* outZ, // OUT: the computed point - TPM_ECC_CURVE curveId, // IN: the curve for the computations - TPM2B_ECC_PARAMETER* dsAIn, // IN: static private TPM key - TPM2B_ECC_PARAMETER* deAIn, // IN: ephemeral private TPM key - TPMS_ECC_POINT* QsBIn, // IN: static public party B key - TPMS_ECC_POINT* QeBIn // IN: ephemeral public party B key -); -# endif -#endif // CC_ZGen_2Phase - -#endif // _CRYPT_ECC_KEY_EXCHANGE_FP_H_ diff --git a/src/tpm2/crypto/CryptEccSignature_fp.h b/src/tpm2/crypto/CryptEccSignature_fp.h deleted file mode 100644 index 3851f82c1..000000000 --- a/src/tpm2/crypto/CryptEccSignature_fp.h +++ /dev/null @@ -1,129 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* 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 */ -/* */ -/********************************************************************************/ - -/*(Auto-generated) - * Created by TpmPrototypes; Version 3.0 July 18, 2017 - * Date: Mar 28, 2019 Time: 08:25:18PM - */ - -#ifndef _CRYPT_ECC_SIGNATURE_FP_H_ -#define _CRYPT_ECC_SIGNATURE_FP_H_ - -#if ALG_ECC - -//*** CryptEccSign() -// This function is the dispatch function for the various ECC-based -// signing schemes. -// There is a bit of ugliness to the parameter passing. In order to test this, -// we sometime would like to use a deterministic RNG so that we can get the same -// signatures during testing. The easiest way to do this for most schemes is to -// pass in a deterministic RNG and let it return canned values during testing. -// There is a competing need for a canned parameter to use in ECDAA. To accommodate -// both needs with minimal fuss, a special type of RAND_STATE is defined to carry -// the address of the commit value. The setup and handling of this is not very -// different for the caller than what was in previous versions of the code. -// Return Type: TPM_RC -// TPM_RC_SCHEME 'scheme' is not supported -LIB_EXPORT TPM_RC CryptEccSign(TPMT_SIGNATURE* signature, // OUT: signature - OBJECT* signKey, // IN: ECC key to sign the hash - const TPM2B_DIGEST* digest, // IN: digest to sign - TPMT_ECC_SCHEME* scheme, // IN: signing scheme - RAND_STATE* rand); - -//*** CryptEccValidateSignature() -// This function validates an EcDsa or EcSchnorr signature. -// The point 'Qin' needs to have been validated to be on the curve of 'curveId'. -// Return Type: TPM_RC -// TPM_RC_SIGNATURE not a valid signature -LIB_EXPORT TPM_RC CryptEccValidateSignature( - TPMT_SIGNATURE* signature, // IN: signature to be verified - OBJECT* signKey, // IN: ECC key signed the hash - const TPM2B_DIGEST* digest // IN: digest that was signed -); - -//***CryptEccCommitCompute() -// This function performs the point multiply operations required by TPM2_Commit. -// -// If 'B' or 'M' is provided, they must be on the curve defined by 'curveId'. This -// routine does not check that they are on the curve and results are unpredictable -// if they are not. -// -// It is a fatal error if 'r' is NULL. If 'B' is not NULL, then it is a -// fatal error if 'd' is NULL or if 'K' and 'L' are both NULL. -// If 'M' is not NULL, then it is a fatal error if 'E' is NULL. -// -// Return Type: TPM_RC -// TPM_RC_NO_RESULT if 'K', 'L' or 'E' was computed to be the point -// at infinity -// TPM_RC_CANCELED a cancel indication was asserted during this -// function -LIB_EXPORT TPM_RC CryptEccCommitCompute( - TPMS_ECC_POINT* K, // OUT: [d]B or [r]Q - TPMS_ECC_POINT* L, // OUT: [r]B - TPMS_ECC_POINT* E, // OUT: [r]M - TPM_ECC_CURVE curveId, // IN: the curve for the computations - TPMS_ECC_POINT* M, // IN: M (optional) - TPMS_ECC_POINT* B, // IN: B (optional) - TPM2B_ECC_PARAMETER* d, // IN: d (optional) - TPM2B_ECC_PARAMETER* r // IN: the computed r value (required) -); -#endif // ALG_ECC - -#endif // _CRYPT_ECC_SIGNATURE_FP_H_ diff --git a/src/tpm2/crypto/CryptPrime_fp.h b/src/tpm2/crypto/CryptPrime_fp.h deleted file mode 100644 index a2e317810..000000000 --- a/src/tpm2/crypto/CryptPrime_fp.h +++ /dev/null @@ -1,128 +0,0 @@ -/********************************************************************************/ -/* */ -/* Code for prime validation */ -/* 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 */ -/* */ -/********************************************************************************/ - -/*(Auto-generated) - * Created by TpmPrototypes; Version 3.0 July 18, 2017 - * Date: Aug 30, 2019 Time: 02:11:54PM - */ - -#ifndef _CRYPT_PRIME_FP_H_ -#define _CRYPT_PRIME_FP_H_ - -//*** IsPrimeInt() -// This will do a test of a word of up to 32-bits in size. -BOOL IsPrimeInt(uint32_t n); - -//*** TpmMath_IsProbablyPrime() -// This function is used when the key sieve is not implemented. This function -// Will try to eliminate some of the obvious things before going on -// to perform MillerRabin as a final verification of primeness. -BOOL TpmMath_IsProbablyPrime(Crypt_Int* prime, // IN: - RAND_STATE* rand // IN: the random state just - // in case Miller-Rabin is required -); - -//*** MillerRabinRounds() -// Function returns the number of Miller-Rabin rounds necessary to give an -// error probability equal to the security strength of the prime. These values -// are from FIPS 186-3. -UINT32 -MillerRabinRounds(UINT32 bits // IN: Number of bits in the RSA prime -); - -//*** MillerRabin() -// This function performs a Miller-Rabin test from FIPS 186-3. It does -// 'iterations' trials on the number. In all likelihood, if the number -// is not prime, the first test fails. -// Return Type: BOOL -// TRUE(1) probably prime -// FALSE(0) composite -BOOL MillerRabin(Crypt_Int* bnW, RAND_STATE* rand); -#if ALG_RSA - -//*** RsaCheckPrime() -// This will check to see if a number is prime and appropriate for an -// RSA prime. -// -// This has different functionality based on whether we are using key -// sieving or not. If not, the number checked to see if it is divisible by -// the public exponent, then the number is adjusted either up or down -// in order to make it a better candidate. It is then checked for being -// probably prime. -// -// If sieving is used, the number is used to root a sieving process. -// -TPM_RC -RsaCheckPrime(Crypt_Int* prime, UINT32 exponent, RAND_STATE* rand); - -//*** TpmRsa_GeneratePrimeForRSA() -// Function to generate a prime of the desired size with the proper attributes -// for an RSA prime. -TPM_RC -TpmRsa_GeneratePrimeForRSA( - Crypt_Int* prime, // IN/OUT: points to the BN that will get the - // random value - UINT32 bits, // IN: number of bits to get - UINT32 exponent, // IN: the exponent - RAND_STATE* rand // IN: the random state -); -#endif // ALG_RSA - -#endif // _CRYPT_PRIME_FP_H_ diff --git a/src/tpm2/crypto/CryptRsa.h b/src/tpm2/crypto/CryptRsa.h deleted file mode 100644 index a8ee5f8a8..000000000 --- a/src/tpm2/crypto/CryptRsa.h +++ /dev/null @@ -1,142 +0,0 @@ -/********************************************************************************/ -/* */ -/* RSA-related structures and defines */ -/* 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 */ -/* */ -/********************************************************************************/ - -// This file contains the RSA-related structures and defines. - -#ifndef _CRYPT_RSA_H -#define _CRYPT_RSA_H - -// These values are used in the Crypt_Int* representation of various RSA values. -// define ci_rsa_t as buffer containing a CRYPT_INT object with space for -// (MAX_RSA_KEY_BITS) of actual data. -CRYPT_INT_TYPE(rsa, MAX_RSA_KEY_BITS); -#define CRYPT_RSA_VAR(name) CRYPT_INT_VAR(name, MAX_RSA_KEY_BITS) -#define CRYPT_RSA_INITIALIZED(name, initializer) \ - CRYPT_INT_INITIALIZED(name, MAX_RSA_KEY_BITS, initializer) - -#define CRYPT_PRIME_VAR(name) CRYPT_INT_VAR(name, (MAX_RSA_KEY_BITS / 2)) -// define ci_prime_t as buffer containing a CRYPT_INT object with space for -// (MAX_RSA_KEY_BITS/2) of actual data. -CRYPT_INT_TYPE(prime, (MAX_RSA_KEY_BITS / 2)); -#define CRYPT_PRIME_INITIALIZED(name, initializer) \ - CRYPT_INT_INITIALIZED(name, MAX_RSA_KEY_BITS / 2, initializer) - -#if !CRT_FORMAT_RSA -# error This verson only works with CRT formatted data -#endif // !CRT_FORMAT_RSA - -typedef struct privateExponent -{ - Crypt_Int* P; - Crypt_Int* Q; - Crypt_Int* dP; - Crypt_Int* dQ; - Crypt_Int* qInv; - ci_prime_t entries[5]; -} privateExponent; - -#define NEW_PRIVATE_EXPONENT(X) \ - privateExponent _##X; \ - privateExponent* X = RsaInitializeExponent(&(_##X)) - - // libtpms added begin: keep old privateExponent -/* The privateExponentOld is part of the OBJECT and we keep it there even though - * upstream got rid of it and stores Q, dP, dQ, and qInv by appending them to - * P stored in TPMT_SENSITIVE.TPMU_SENSITIVE_COMPOSITE.TPM2B_PRIVATE_KEY_RSA - */ -typedef struct privateExponentOld -{ - ci_prime_t Q; - ci_prime_t dP; - ci_prime_t dQ; - ci_prime_t qInv; -} privateExponent_t; - -#include "BnMemory_fp.h" - -static inline void RsaInitializeExponentOld(privateExponent_t* pExp) -{ - BN_INIT(pExp->Q); - BN_INIT(pExp->dP); - BN_INIT(pExp->dQ); - BN_INIT(pExp->qInv); -} - -static inline void RsaSetExponentOld(privateExponent_t* pExp, // OUT - privateExponent* Z // IN - ) -{ - // pExp->Q must be set elsewhere - ExtMath_Copy((Crypt_Int*)&pExp->dP, Z->dP); - ExtMath_Copy((Crypt_Int*)&pExp->dQ, Z->dQ); - ExtMath_Copy((Crypt_Int*)&pExp->qInv, Z->qInv); -} - -static inline void RsaSetExponentFromOld(privateExponent* Z, // OUT - privateExponent_t* pExp // IN - ) -{ - ExtMath_Copy(Z->Q, (Crypt_Int*)&pExp->Q); - ExtMath_Copy(Z->dP, (Crypt_Int*)&pExp->dP); - ExtMath_Copy(Z->dQ, (Crypt_Int*)&pExp->dQ); - ExtMath_Copy(Z->qInv, (Crypt_Int*)&pExp->qInv); -} - // libtpms added end -#endif // _CRYPT_RSA_H diff --git a/src/tpm2/crypto/CryptSelfTest_fp.h b/src/tpm2/crypto/CryptSelfTest_fp.h deleted file mode 100644 index e91df04b2..000000000 --- a/src/tpm2/crypto/CryptSelfTest_fp.h +++ /dev/null @@ -1,127 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: CryptSelfTest_fp.h 1490 2019-07-26 21:13:22Z 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 */ -/* */ -/********************************************************************************/ - -/*(Auto-generated) - * Created by TpmPrototypes; Version 3.0 July 18, 2017 - * Date: Mar 4, 2020 Time: 02:36:44PM - */ - -#ifndef _CRYPT_SELF_TEST_FP_H_ -#define _CRYPT_SELF_TEST_FP_H_ - -//*** CryptSelfTest() -// This function is called to start/complete a full self-test. -// If 'fullTest' is NO, then only the untested algorithms will be run. If -// 'fullTest' is YES, then 'g_untestedDecryptionAlgorithms' is reinitialized and then -// all tests are run. -// This implementation of the reference design does not support processing outside -// the framework of a TPM command. As a consequence, this command does not -// complete until all tests are done. Since this can take a long time, the TPM -// will check after each test to see if the command is canceled. If so, then the -// TPM will returned TPM_RC_CANCELLED. To continue with the self-tests, call -// TPM2_SelfTest(fullTest == No) and the TPM will complete the testing. -// Return Type: TPM_RC -// TPM_RC_CANCELED if the command is canceled -LIB_EXPORT -TPM_RC -CryptSelfTest(TPMI_YES_NO fullTest // IN: if full test is required -); - -//*** CryptIncrementalSelfTest() -// This function is used to perform an incremental self-test. This implementation -// will perform the toTest values before returning. That is, it assumes that the -// TPM cannot perform background tasks between commands. -// -// This command may be canceled. If it is, then there is no return result. -// However, this command can be run again and the incremental progress will not -// be lost. -// Return Type: TPM_RC -// TPM_RC_CANCELED processing of this command was canceled -// TPM_RC_TESTING if toTest list is not empty -// TPM_RC_VALUE an algorithm in the toTest list is not implemented -TPM_RC -CryptIncrementalSelfTest(TPML_ALG* toTest, // IN: list of algorithms to be tested - TPML_ALG* toDoList // OUT: list of algorithms needing test -); - -//*** CryptInitializeToTest() -// This function will initialize the data structures for testing all the -// algorithms. This should not be called unless CryptAlgsSetImplemented() has -// been called -void CryptInitializeToTest(void); - -//*** CryptTestAlgorithm() -// Only point of contact with the actual self tests. If a self-test fails, there -// is no return and the TPM goes into failure mode. -// The call to TestAlgorithm uses an algorithm selector and a bit vector. When the -// test is run, the corresponding bit in 'toTest' and in 'g_toTest' is CLEAR. If -// 'toTest' is NULL, then only the bit in 'g_toTest' is CLEAR. -// There is a special case for the call to TestAlgorithm(). When 'alg' is -// ALG_ERROR, TestAlgorithm() will CLEAR any bit in 'toTest' for which it has -// no test. This allows the knowledge about which algorithms have test to be -// accessed through the interface that provides the test. -// Return Type: TPM_RC -// TPM_RC_CANCELED test was canceled -LIB_EXPORT -TPM_RC -CryptTestAlgorithm(TPM_ALG_ID alg, ALGORITHM_VECTOR* toTest); - -#endif // _CRYPT_SELF_TEST_FP_H_ diff --git a/src/tpm2/crypto/CryptSmac_fp.h b/src/tpm2/crypto/CryptSmac_fp.h deleted file mode 100644 index de5e0df95..000000000 --- a/src/tpm2/crypto/CryptSmac_fp.h +++ /dev/null @@ -1,100 +0,0 @@ -/********************************************************************************/ -/* Message Authentication Codes Based on a Symmetric Block Cipher */ -/* Implementation of cryptographic functions for hashing. */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: CryptSmac_fp.h 1490 2019-07-26 21:13:22Z kgoldman $ */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* - Trusted Computing Group (TCG) grants to the user of the source code in */ -/* this specification (the "Source Code") a worldwide, irrevocable, */ -/* nonexclusive, royalty free, copyright license to reproduce, create */ -/* derivative works, distribute, display and perform the Source Code and */ -/* derivative works thereof, and to grant others the rights granted herein. */ -/* */ -/* - The TCG grants to the user of the other parts of the specification */ -/* (other than the Source Code) the rights to reproduce, distribute, */ -/* display, and perform the specification solely for the purpose of */ -/* developing products based on such documents. */ -/* */ -/* 2. Source Code Distribution Conditions: */ -/* */ -/* - Redistributions of Source Code must retain the above copyright licenses, */ -/* this list of conditions and the following disclaimers. */ -/* */ -/* - Redistributions in binary form must reproduce the above copyright */ -/* licenses, this list of conditions and the following disclaimers in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* 3. Disclaimers: */ -/* */ -/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ -/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ -/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ -/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ -/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ -/* information on specification licensing rights available through TCG */ -/* membership agreements. */ -/* */ -/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ -/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ -/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ -/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ -/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ -/* */ -/* - Without limitation, TCG and its members and licensors disclaim all */ -/* liability, including liability for infringement of any proprietary */ -/* rights, relating to use of information in this specification and to the */ -/* implementation of this specification, and TCG disclaims all liability for */ -/* cost of procurement of substitute goods or services, lost profits, loss */ -/* of use, loss of data or any incidental, consequential, direct, indirect, */ -/* or special damages, whether under contract, tort, warranty or otherwise, */ -/* arising in any way out of use or reliance upon this specification or any */ -/* information herein. */ -/* */ -/* (c) Copyright IBM Corp. and others, 2018 */ -/* */ -/********************************************************************************/ - -/*(Auto-generated) - * Created by TpmPrototypes; Version 3.0 July 18, 2017 - * Date: Mar 28, 2019 Time: 08:25:19PM - */ - -#ifndef _CRYPT_SMAC_FP_H_ -#define _CRYPT_SMAC_FP_H_ - -#if SMAC_IMPLEMENTED - -//*** CryptSmacStart() -// Function to start an SMAC. -UINT16 -CryptSmacStart(HASH_STATE* state, - TPMU_PUBLIC_PARMS* keyParameters, - TPM_ALG_ID macAlg, // IN: the type of MAC - TPM2B* key); - -//*** CryptMacStart() -// Function to start either an HMAC or an SMAC. Cannot reuse the CryptHmacStart -// function because of the difference in number of parameters. -UINT16 -CryptMacStart(HMAC_STATE* state, - TPMU_PUBLIC_PARMS* keyParameters, - TPM_ALG_ID macAlg, // IN: the type of MAC - TPM2B* key); - -//*** CryptMacEnd() -// Dispatch to the MAC end function using a size and buffer pointer. -UINT16 -CryptMacEnd(HMAC_STATE* state, UINT32 size, BYTE* buffer); - -//*** CryptMacEnd2B() -// Dispatch to the MAC end function using a 2B. -UINT16 -CryptMacEnd2B(HMAC_STATE* state, TPM2B* data); -#endif // SMAC_IMPLEMENTED - -#endif // _CRYPT_SMAC_FP_H_ diff --git a/src/tpm2/crypto/CryptSym.h b/src/tpm2/crypto/CryptSym.h deleted file mode 100644 index 31009eab6..000000000 --- a/src/tpm2/crypto/CryptSym.h +++ /dev/null @@ -1,151 +0,0 @@ -/********************************************************************************/ -/* */ -/* Implementation of the symmetric block cipher modes */ -/* 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, 2017 - 2023 */ -/* */ -/********************************************************************************/ - -//** Introduction -// -// This file contains the implementation of the symmetric block cipher modes -// allowed for a TPM. These functions only use the single block encryption functions -// of the selected symmetric cryptographic library. - -//** Includes, Defines, and Typedefs -#ifndef CRYPT_SYM_H -#define CRYPT_SYM_H - -#if ALG_AES -# define IF_IMPLEMENTED_AES(op) op(AES, aes) -#else -# define IF_IMPLEMENTED_AES(op) -#endif -#if ALG_SM4 -# define IF_IMPLEMENTED_SM4(op) op(SM4, sm4) -#else -# define IF_IMPLEMENTED_SM4(op) -#endif -#if ALG_CAMELLIA -# define IF_IMPLEMENTED_CAMELLIA(op) op(CAMELLIA, camellia) -#else -# define IF_IMPLEMENTED_CAMELLIA(op) -#endif -#if ALG_TDES -# define IF_IMPLEMENTED_TDES(op) op(TDES, tdes) -#else -# define IF_IMPLEMENTED_TDES(op) -#endif - -#define FOR_EACH_SYM(op) \ - IF_IMPLEMENTED_AES(op) \ - IF_IMPLEMENTED_SM4(op) \ - IF_IMPLEMENTED_CAMELLIA(op) \ - IF_IMPLEMENTED_TDES(op) - - /* libtpms added begin */ -#define FOR_EACH_SYM_WITHOUT_TDES(op) \ - IF_IMPLEMENTED_AES(op) \ - IF_IMPLEMENTED_SM4(op) \ - IF_IMPLEMENTED_CAMELLIA(op) /* libtpms added end */ - -// Macros for creating the key schedule union -#define KEY_SCHEDULE(SYM, sym) tpmKeySchedule##SYM sym; -typedef union tpmCryptKeySchedule_t { - FOR_EACH_SYM_WITHOUT_TDES(KEY_SCHEDULE) /* libtpms changed from FOR_EACH_SYM */ - - tpmKeyScheduleTDES tdes[3]; /* libtpms added */ - -#if SYMMETRIC_ALIGNMENT == 8 - uint64_t alignment; -#else - uint32_t alignment; -# if defined(__x86_64__) -# error Bad SYMMETRIC_ALIGNMENT -# endif -#endif -} tpmCryptKeySchedule_t; - -// Each block cipher within a library is expected to conform to the same calling -// conventions with three parameters ('keySchedule', 'in', and 'out') in the same -// order. That means that all algorithms would use the same order of the same -// parameters. The code is written assuming the ('keySchedule', 'in', and 'out') -// order. However, if the library uses a different order, the order can be changed -// with a SWIZZLE macro that puts the parameters in the correct order. -// Note that all algorithms have to use the same order and number of parameters -// because the code to build the calling list is common for each call to encrypt -// or decrypt with the algorithm chosen by setting a function pointer to select -// the algorithm that is used. - -#define ENCRYPT(keySchedule, in, out) encrypt(SWIZZLE(keySchedule, in, out)) - -#define DECRYPT(keySchedule, in, out) decrypt(SWIZZLE(keySchedule, in, out)) - -// Note that the macros rely on 'encrypt' as local values in the -// functions that use these macros. Those parameters are set by the macro that -// set the key schedule to be used for the call. - -#define ENCRYPT_CASE(ALG, alg) \ - case TPM_ALG_##ALG: \ - TpmCryptSetEncryptKey##ALG(key, keySizeInBits, &keySchedule.alg); \ - encrypt = (TpmCryptSetSymKeyCall_t)TpmCryptEncrypt##ALG; \ - break; -#define DECRYPT_CASE(ALG, alg) \ - case TPM_ALG_##ALG: \ - TpmCryptSetDecryptKey##ALG(key, keySizeInBits, &keySchedule.alg); \ - decrypt = (TpmCryptSetSymKeyCall_t)TpmCryptDecrypt##ALG; \ - break; - -#endif // CRYPT_SYM_H diff --git a/src/tpm2/crypto/CryptTest.h b/src/tpm2/crypto/CryptTest.h deleted file mode 100644 index 3d2136026..000000000 --- a/src/tpm2/crypto/CryptTest.h +++ /dev/null @@ -1,95 +0,0 @@ -/********************************************************************************/ -/* */ -/* constant definitions used for self-test. */ -/* 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 */ -/* */ -/********************************************************************************/ - -// This file contains constant definitions used for self-test. - -#ifndef _CRYPT_TEST_H -#define _CRYPT_TEST_H - -// This is the definition of a bit array with one bit per algorithm. -// NOTE: Since bit numbering starts at zero, when TPM_ALG_LAST is a multiple of 8, -// ALGORITHM_VECTOR will need to have byte for the single bit in the last byte. So, -// for example, when TPM_ALG_LAST is 8, ALGORITHM_VECTOR will need 2 bytes. -#define ALGORITHM_VECTOR_BYTES ((TPM_ALG_LAST + 8) / 8) -typedef BYTE ALGORITHM_VECTOR[ALGORITHM_VECTOR_BYTES]; - -#ifdef TEST_SELF_TEST -LIB_EXPORT extern ALGORITHM_VECTOR LibToTest; -#endif - -// This structure is used to contain self-test tracking information for the -// cryptographic modules. Each of the major modules is given a 32-bit value in -// which it may maintain its own self test information. The convention for this -// state is that when all of the bits in this structure are 0, all functions need -// to be tested. -typedef struct -{ - UINT32 rng; - UINT32 hash; - UINT32 sym; -#if ALG_RSA - UINT32 rsa; -#endif -#if ALG_ECC - UINT32 ecc; -#endif -} CRYPTO_SELF_TEST_STATE; - -#endif // _CRYPT_TEST_H diff --git a/src/tpm2/crypto/ECC_Decrypt_fp.h b/src/tpm2/crypto/ECC_Decrypt_fp.h deleted file mode 100644 index 0d5d3d1e8..000000000 --- a/src/tpm2/crypto/ECC_Decrypt_fp.h +++ /dev/null @@ -1,98 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* 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, 2022 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_ECC_Decrypt // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_ECC_DECRYPT_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_ECC_DECRYPT_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_DH_OBJECT keyHandle; - TPM2B_ECC_POINT C1; - TPM2B_MAX_BUFFER C2; - TPM2B_DIGEST C3; - TPMT_KDF_SCHEME inScheme; -} ECC_Decrypt_In; - -// Output structure definition -typedef struct -{ - TPM2B_MAX_BUFFER plainText; -} ECC_Decrypt_Out; - -// Response code modifiers -# define RC_ECC_Decrypt_keyHandle (TPM_RC_H + TPM_RC_1) -# define RC_ECC_Decrypt_C1 (TPM_RC_P + TPM_RC_1) -# define RC_ECC_Decrypt_C2 (TPM_RC_P + TPM_RC_2) -# define RC_ECC_Decrypt_C3 (TPM_RC_P + TPM_RC_3) -# define RC_ECC_Decrypt_inScheme (TPM_RC_P + TPM_RC_4) - -// Function prototype -TPM_RC -TPM2_ECC_Decrypt(ECC_Decrypt_In* in, ECC_Decrypt_Out* out); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_ECC_DECRYPT_FP_H_ -#endif // CC_ECC_Decrypt diff --git a/src/tpm2/crypto/ECC_Encrypt_fp.h b/src/tpm2/crypto/ECC_Encrypt_fp.h deleted file mode 100644 index 8ad4fc716..000000000 --- a/src/tpm2/crypto/ECC_Encrypt_fp.h +++ /dev/null @@ -1,96 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* 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, 2022 */ -/* */ -/********************************************************************************/ - - -// FILE GENERATED BY TpmExtractCode: DO NOT EDIT - -#if CC_ECC_Encrypt // Command must be enabled - -# ifndef _TPM_INCLUDE_PRIVATE_PROTOTYPES_ECC_ENCRYPT_FP_H_ -# define _TPM_INCLUDE_PRIVATE_PROTOTYPES_ECC_ENCRYPT_FP_H_ - -// Input structure definition -typedef struct -{ - TPMI_DH_OBJECT keyHandle; - TPM2B_MAX_BUFFER plainText; - TPMT_KDF_SCHEME inScheme; -} ECC_Encrypt_In; - -// Output structure definition -typedef struct -{ - TPM2B_ECC_POINT C1; - TPM2B_MAX_BUFFER C2; - TPM2B_DIGEST C3; -} ECC_Encrypt_Out; - -// Response code modifiers -# define RC_ECC_Encrypt_keyHandle (TPM_RC_H + TPM_RC_1) -# define RC_ECC_Encrypt_plainText (TPM_RC_P + TPM_RC_1) -# define RC_ECC_Encrypt_inScheme (TPM_RC_P + TPM_RC_2) - -// Function prototype -TPM_RC -TPM2_ECC_Encrypt(ECC_Encrypt_In* in, ECC_Encrypt_Out* out); - -# endif // _TPM_INCLUDE_PRIVATE_PROTOTYPES_ECC_ENCRYPT_FP_H_ -#endif // CC_ECC_Encrypt diff --git a/src/tpm2/crypto/openssl/BnMemory_fp.h b/src/tpm2/crypto/openssl/BnMemory_fp.h deleted file mode 100644 index 4b8269ce7..000000000 --- a/src/tpm2/crypto/openssl/BnMemory_fp.h +++ /dev/null @@ -1,120 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* 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 */ -/* */ -/********************************************************************************/ - -/*(Auto-generated) - * Created by TpmPrototypes; Version 3.0 July 18, 2017 - * Date: Mar 28, 2019 Time: 08:25:18PM - */ - -#ifndef _BN_MEMORY_FP_H_ -#define _BN_MEMORY_FP_H_ - -//*** BnSetTop() -// This function is used when the size of a bignum_t is changed. It -// makes sure that the unused words are set to zero and that any significant -// words of zeros are eliminated from the used size indicator. -LIB_EXPORT bigNum BnSetTop(bigNum bn, // IN/OUT: number to clean - crypt_uword_t top // IN: the new top -); - -#if 0 /* libtpms added */ -//*** BnClearTop() -// This function will make sure that all unused words are zero. -LIB_EXPORT bigNum BnClearTop(bigNum bn); -#endif /* libtpms added */ - -//*** BnInitializeWord() -// This function is used to initialize an allocated bigNum with a word value. The -// bigNum does not have to be allocated with a single word. -LIB_EXPORT bigNum BnInitializeWord(bigNum bn, // IN: - crypt_uword_t allocated, // IN: - crypt_uword_t word // IN: -); - -//*** BnInit() -// This function initializes a stack allocated bignum_t. It initializes -// 'allocated' and 'size' and zeros the words of 'd'. -LIB_EXPORT bigNum BnInit(bigNum bn, crypt_uword_t allocated); - -//*** BnCopy() -// Function to copy a bignum_t. If the output is NULL, then -// nothing happens. If the input is NULL, the output is set -// to zero. -LIB_EXPORT BOOL BnCopy(bigNum out, bigConst in); -#if ALG_ECC - -#if 0 /* libtpms added */ -//*** BnPointCopy() -// Function to copy a bn point. -LIB_EXPORT BOOL BnPointCopy(bigPoint pOut, pointConst pIn); -#endif /* libtpms added */ - -//*** BnInitializePoint() -// This function is used to initialize a point structure with the addresses -// of the coordinates. -LIB_EXPORT bn_point_t* BnInitializePoint( - bigPoint p, // OUT: structure to receive pointers - bigNum x, // IN: x coordinate - bigNum y, // IN: y coordinate - bigNum z // IN: x coordinate -); -#endif // ALG_ECC - -#endif // _BN_MEMORY_FP_H_ diff --git a/src/tpm2/crypto/openssl/BnOssl.h b/src/tpm2/crypto/openssl/BnOssl.h deleted file mode 100644 index 004d9f49f..000000000 --- a/src/tpm2/crypto/openssl/BnOssl.h +++ /dev/null @@ -1,86 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* 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 */ -/* */ -/********************************************************************************/ - -//** Introduction -// This file contains the headers necessary to build the Open SSL support for -// the TpmBigNum library. -#ifndef _BNOSSL_H_ -#define _BNOSSL_H_ -// TODO_RENAME_INC_FOLDER: public refers to the TPM_CoreLib public headers -#include "tpm_public.h" -#include "TpmFail_fp.h" -#include "BnToOsslMath.h" -// TODO_RENAME_INC_FOLDER: these refer to TpmBigNum protected headers -#include "BnSupport_Interface.h" -#include "BnUtil_fp.h" -#include "BnMemory_fp.h" -#include "BnMath_fp.h" -#include "BnConvert_fp.h" - -#if CRYPTO_LIB_REPORTING -# include - -//*** OsslGetVersion() -// Report the current version of OpenSSL. -void OsslGetVersion(_CRYPTO_IMPL_DESCRIPTION* result); - -#endif // CRYPTO_LIB_REPORTING - -#endif // _BNOSSL_H_ diff --git a/src/tpm2/crypto/openssl/BnToOsslMath_fp.h b/src/tpm2/crypto/openssl/BnToOsslMath_fp.h deleted file mode 100644 index 64406e331..000000000 --- a/src/tpm2/crypto/openssl/BnToOsslMath_fp.h +++ /dev/null @@ -1,94 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* 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 */ -/* */ -/********************************************************************************/ - -/*(Auto-generated) - * Created by TpmPrototypes; Version 3.0 July 18, 2017 - * Date: Oct 24, 2019 Time: 11:37:07AM - */ - -#ifndef _BN_TO_OSSL_MATH_FP_H_ -#define _BN_TO_OSSL_MATH_FP_H_ - -#ifdef MATH_LIB_OSSL - -//*** OsslToTpmBn() -// This function converts an OpenSSL BIGNUM to a TPM bigNum. In this implementation -// it is assumed that OpenSSL uses a different control structure but the same data -// layout -- an array of native-endian words in little-endian order. -// Return Type: BOOL -// TRUE(1) success -// FALSE(0) failure because value will not fit or OpenSSL variable doesn't -// exist -BOOL OsslToTpmBn(bigNum bn, const BIGNUM* osslBn); // libtpms changed - -//*** BigInitialized() -// This function initializes an OSSL BIGNUM from a TPM bigConst. Do not use this for -// values that are passed to OpenSLL when they are not declared as const in the -// function prototype. Instead, use BnNewVariable(). -BIGNUM* BigInitialized(BIGNUM* toInit, bigConst initializer); -#endif // MATHLIB OSSL - -// libtpms added begin -EC_POINT *EcPointInitialized(pointConst initializer, - const bigCurveData* E - ); -// libtpms added end - -#endif // _TPM_TO_OSSL_MATH_FP_H_ diff --git a/src/tpm2/crypto/openssl/ConsttimeUtils.h b/src/tpm2/crypto/openssl/ConsttimeUtils.h deleted file mode 100644 index 22d8a05ff..000000000 --- a/src/tpm2/crypto/openssl/ConsttimeUtils.h +++ /dev/null @@ -1,100 +0,0 @@ -/********************************************************************************/ -/* */ -/* Constant time debugging helper functions */ -/* Written by Stefan Berger */ -/* IBM Thomas J. Watson Research Center */ -/* */ -/* Licenses and Notices */ -/* */ -/* 1. Copyright Licenses: */ -/* */ -/* (c) Copyright IBM Corporation, 2020-2025 */ -/* */ -/* All rights reserved. */ -/* */ -/* Redistribution and use in source and binary forms, with or without */ -/* modification, are permitted provided that the following conditions are */ -/* met: */ -/* */ -/* Redistributions of source code must retain the above copyright notice, */ -/* this list of conditions and the following disclaimer. */ -/* */ -/* Redistributions in binary form must reproduce the above copyright */ -/* notice, this list of conditions and the following disclaimer in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* Neither the names of the IBM Corporation nor the names of its */ -/* contributors may be used to endorse or promote products derived from */ -/* this software without specific prior written permission. */ -/* */ -/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */ -/* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */ -/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR */ -/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */ -/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */ -/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */ -/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, */ -/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY */ -/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */ -/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE */ -/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* */ -/********************************************************************************/ - -#ifndef CONSTTIME_UTILS_H -#define CONSTTIME_UTILS_H - -#include -#include - -#include "BnValues.h" - -#include - -static __inline__ unsigned long long rdtsc() { - unsigned long h, l; - - __asm__ __volatile__ ("rdtsc" : "=a"(l), "=d"(h)); - - return (unsigned long long)l | - ((unsigned long long)h << 32 ); -} - -// Make sure that the given BIGNUM has the given number of expected bytes. -// Skip over any leading zeros the BIGNUM may have. -static inline void assert_ossl_num_bytes(const BIGNUM *a, - unsigned int num_bytes, - int verbose, - const char *caller) { - unsigned char buffer[LARGEST_NUMBER] = { 0, }; - int len, i; - - len = BN_bn2bin(a, buffer); - for (i = 0; i < len; i++) { - if (buffer[i]) - break; - } - len -= i; - if (num_bytes != (unsigned int)len) { - printf("%s: Expected %u bytes but found %d (caller: %s)\n", __func__, num_bytes, len, caller); - } else { - if (verbose) - printf("%s: check passed; num_bytes = %d (caller: %s)\n",__func__, num_bytes, caller); - } - assert(num_bytes == (unsigned int)len); -} - -// Make sure that the bigNum has the expected number of bytes after it was -// converted to an OpenSSL BIGNUM. -static inline void assert_bn_ossl_num_bytes(bigNum tpmb, - unsigned int num_bytes, - int verbose, - const char *caller) { - BIG_INITIALIZED(osslb, tpmb); - - assert_ossl_num_bytes(osslb, num_bytes, verbose, caller); - - BN_free(osslb); -} - -#endif /* CONSTTIME_UTILS_H */ diff --git a/src/tpm2/crypto/openssl/CryptSmac.c b/src/tpm2/crypto/openssl/CryptSmac.c deleted file mode 100644 index 2c8809935..000000000 --- a/src/tpm2/crypto/openssl/CryptSmac.c +++ /dev/null @@ -1,150 +0,0 @@ -/********************************************************************************/ -/* */ -/* Message Authentication Codes Based on a Symmetric Block Cipher */ -/* Written by Ken Goldman */ -/* IBM Thomas J. Watson Research Center */ -/* $Id: CryptSmac.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, 2018 - 2021 */ -/* */ -/********************************************************************************/ - -//** Introduction -// -// This file contains the implementation of the message authentication codes based -// on a symmetric block cipher. These functions only use the single block -// encryption functions of the selected symmetric cryptographic library. - -//** Includes, Defines, and Typedefs -#define _CRYPT_HASH_C_ -#include "Tpm.h" - -#if SMAC_IMPLEMENTED - -//*** CryptSmacStart() -// Function to start an SMAC. -UINT16 -CryptSmacStart(HASH_STATE* state, - TPMU_PUBLIC_PARMS* keyParameters, - TPM_ALG_ID macAlg, // IN: the type of MAC - TPM2B* key) -{ - UINT16 retVal = 0; - // - // Make sure that the key size is correct. This should have been checked - // at key load, but... - if(BITS_TO_BYTES(keyParameters->symDetail.sym.keyBits.sym) == key->size) - { - switch(macAlg) - { -# if ALG_CMAC - case TPM_ALG_CMAC: - retVal = - CryptCmacStart(&state->state.smac, keyParameters, macAlg, key); - break; -# endif - default: - break; - } - } - state->type = (retVal != 0) ? HASH_STATE_SMAC : HASH_STATE_EMPTY; - return retVal; -} - -//*** CryptMacStart() -// Function to start either an HMAC or an SMAC. Cannot reuse the CryptHmacStart -// function because of the difference in number of parameters. -UINT16 -CryptMacStart(HMAC_STATE* state, - TPMU_PUBLIC_PARMS* keyParameters, - TPM_ALG_ID macAlg, // IN: the type of MAC - TPM2B* key) -{ - MemorySet(state, 0, sizeof(HMAC_STATE)); - if(CryptHashIsValidAlg(macAlg, FALSE)) - { - return CryptHmacStart(state, macAlg, key->size, key->buffer); - } - else if(CryptSmacIsValidAlg(macAlg, FALSE)) - { - return CryptSmacStart(&state->hashState, keyParameters, macAlg, key); - } - else - return 0; -} - -//*** CryptMacEnd() -// Dispatch to the MAC end function using a size and buffer pointer. -UINT16 -CryptMacEnd(HMAC_STATE* state, UINT32 size, BYTE* buffer) -{ - UINT16 retVal = 0; - if(state->hashState.type == HASH_STATE_SMAC) - retVal = (state->hashState.state.smac.smacMethods.end)( - &state->hashState.state.smac.state, size, buffer); - else if(state->hashState.type == HASH_STATE_HMAC) - retVal = CryptHmacEnd(state, size, buffer); - state->hashState.type = HASH_STATE_EMPTY; - return retVal; -} - -#if 0 /* libtpms added */ -//*** CryptMacEnd2B() -// Dispatch to the MAC end function using a 2B. -UINT16 -CryptMacEnd2B(HMAC_STATE* state, TPM2B* data) -{ - return CryptMacEnd(state, data->size, data->buffer); -} -#endif /* libtpms added */ -#endif // SMAC_IMPLEMENTED diff --git a/src/tpm2/crypto/openssl/ExpDCache_fp.h b/src/tpm2/crypto/openssl/ExpDCache_fp.h deleted file mode 100644 index e7db0580d..000000000 --- a/src/tpm2/crypto/openssl/ExpDCache_fp.h +++ /dev/null @@ -1,56 +0,0 @@ -/********************************************************************************/ -/* */ -/* Private Exponent D cache functions */ -/* Written by Stefan Berger */ -/* IBM Thomas J. Watson Research Center */ -/* */ -/* Licenses and Notices */ -/* */ -/* (c) Copyright IBM Corporation, 2021-2025 */ -/* */ -/* All rights reserved. */ -/* */ -/* Redistribution and use in source and binary forms, with or without */ -/* modification, are permitted provided that the following conditions are */ -/* met: */ -/* */ -/* Redistributions of source code must retain the above copyright notice, */ -/* this list of conditions and the following disclaimer. */ -/* */ -/* Redistributions in binary form must reproduce the above copyright */ -/* notice, this list of conditions and the following disclaimer in the */ -/* documentation and/or other materials provided with the distribution. */ -/* */ -/* Neither the names of the IBM Corporation nor the names of its */ -/* contributors may be used to endorse or promote products derived from */ -/* this software without specific prior written permission. */ -/* */ -/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */ -/* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */ -/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR */ -/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */ -/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */ -/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */ -/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, */ -/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY */ -/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */ -/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE */ -/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* */ -/********************************************************************************/ - -#ifndef DCACHE_FP_H -#define DCACHE_FP_H - -#include - -BIGNUM *ExpDCacheFind(const BIGNUM *P, const BIGNUM *N, const BIGNUM *E, - BIGNUM **Q); - -void ExpDCacheAdd(const BIGNUM *P, const BIGNUM *N, const BIGNUM *E, - const BIGNUM *Q, const BIGNUM *D); - -void ExpDCacheFree(void); - -#endif /* DCACHE_FP_H */ - diff --git a/src/tpm2/crypto/openssl/LibSupport.h b/src/tpm2/crypto/openssl/LibSupport.h deleted file mode 100644 index 88c32eac2..000000000 --- a/src/tpm2/crypto/openssl/LibSupport.h +++ /dev/null @@ -1,84 +0,0 @@ -/********************************************************************************/ -/* */ -/* select the library code that gets included in the TPM build */ -/* 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 */ -/* */ -/********************************************************************************/ - -// This header file is used to select the library code that gets included in the -// TPM build. - -#ifndef _LIB_SUPPORT_H_ -#define _LIB_SUPPORT_H_ -// TODO_RENAME_INC_FOLDER: public refers to the TPM_CoreLib public headers -#include "tpm_radix.h" - -// Include the options for hashing and symmetric. Defer the load of the math package -// Until the bignum parameters are defined. -#ifndef SYM_LIB -# error SYM_LIB required -#endif -#ifndef HASH_LIB -# error HASH_LIB required -#endif - -#include LIB_INCLUDE(TpmTo, SYM_LIB, Sym) -#include LIB_INCLUDE(TpmTo, HASH_LIB, Hash) - -//TODO: was #undef MIN -//was #undef MAX - -#endif // _LIB_SUPPORT_H_ diff --git a/src/tpm2/crypto/openssl/TpmToOsslSupport.c b/src/tpm2/crypto/openssl/TpmToOsslSupport.c deleted file mode 100644 index b2b421d12..000000000 --- a/src/tpm2/crypto/openssl/TpmToOsslSupport.c +++ /dev/null @@ -1,172 +0,0 @@ -/********************************************************************************/ -/* */ -/* Initialization of the Interface to the OpenSSL Library. */ -/* 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 */ -/* */ -/********************************************************************************/ - -//** Introduction -// -// The functions in this file are used for initialization of the interface to the -// OpenSSL library. - -//** Defines and Includes - -#include "BnOssl.h" -#include "CryptoInterface.h" -#include "TpmToOsslSym.h" -#include "TpmToOsslHash.h" -#include -#include - -#if CRYPTO_LIB_REPORTING - -//*** OsslGetVersion() -// Report the version of OpenSSL. -void OsslGetVersion(_CRYPTO_IMPL_DESCRIPTION* result) -{ - snprintf(result->name, sizeof(result->name), "OpenSSL"); -# if defined(OPENSSL_VERSION_STR) - snprintf(result->version, sizeof(result->version), "%s", OPENSSL_VERSION_STR); -# else - // decode the hex version string according to the rules described in opensslv.h - snprintf(result->version, - sizeof(result->version), - "%d.%d.%d%c", - (unsigned char)((OPENSSL_VERSION_NUMBER >> 28) & 0x0f), - (unsigned char)((OPENSSL_VERSION_NUMBER >> 20) & 0xff), - (unsigned char)((OPENSSL_VERSION_NUMBER >> 12) & 0xff), - (char)((OPENSSL_VERSION_NUMBER >> 4) & 0xff) - 1 + 'a'); -# endif //OPENSSL_VERSION_STR -} - -#endif //CRYPTO_LIB_REPORTING - -#if defined(HASH_LIB_OSSL) || defined(MATH_LIB_OSSL) || defined(SYM_LIB_OSSL) -// Used to pass the pointers to the correct sub-keys -typedef const BYTE* desKeyPointers[3]; - -//*** BnSupportLibInit() -// This does any initialization required by the support library. -LIB_EXPORT int BnSupportLibInit(void) -{ - return TRUE; -} - -//*** OsslContextEnter() -// This function is used to initialize an OpenSSL context at the start of a function -// that will call to an OpenSSL math function. -BN_CTX* OsslContextEnter(void) -{ - BN_CTX* CTX = BN_CTX_new(); - // - return OsslPushContext(CTX); -} - -//*** OsslContextLeave() -// This is the companion function to OsslContextEnter(). -void OsslContextLeave(BN_CTX* CTX) -{ - OsslPopContext(CTX); - BN_CTX_free(CTX); -} - -//*** OsslPushContext() -// This function is used to create a frame in a context. All values allocated within -// this context after the frame is started will be automatically freed when the -// context (OsslPopContext() -BN_CTX* OsslPushContext(BN_CTX* CTX) -{ - if(CTX == NULL) - FAIL(FATAL_ERROR_ALLOCATION); - BN_CTX_start(CTX); - return CTX; -} - -//*** OsslPopContext() -// This is the companion function to OsslPushContext(). -void OsslPopContext(BN_CTX* CTX) -{ - // BN_CTX_end can't be called with NULL. It will blow up. - if(CTX != NULL) - BN_CTX_end(CTX); -} - -# if CRYPTO_LIB_REPORTING - -# if defined(SYM_LIB_OSSL) && SIMULATION && CRYPTO_LIB_REPORTING -//*** _crypto_GetSymImpl() -// Report the version of OpenSSL being used for symmetric crypto. -void _crypto_GetSymImpl(_CRYPTO_IMPL_DESCRIPTION* result) -{ - OsslGetVersion(result); -} -# else -# error huh? -# endif // defined(SYM_LIB_OSSL) && SIMULATION - -# if defined(HASH_LIB_OSSL) && SIMULATION && CRYPTO_LIB_REPORTING -//*** _crypto_GetHashImpl() -// Report the version of OpenSSL being used for hashing. -void _crypto_GetHashImpl(_CRYPTO_IMPL_DESCRIPTION* result) -{ - OsslGetVersion(result); -} -# endif // defined(HASH_LIB_OSSL) && SIMULATION - -# endif // CRYPTO_LIB_REPORTING - -#endif // HASH_LIB_OSSL || MATH_LIB_OSSL || SYM_LIB_OSSL diff --git a/src/tpm2/crypto/openssl/TpmToOsslSupport_fp.h b/src/tpm2/crypto/openssl/TpmToOsslSupport_fp.h deleted file mode 100644 index b509b25d2..000000000 --- a/src/tpm2/crypto/openssl/TpmToOsslSupport_fp.h +++ /dev/null @@ -1,95 +0,0 @@ -/********************************************************************************/ -/* */ -/* Initialization of the Interface to the OpenSSL Library */ -/* 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 */ -/* */ -/********************************************************************************/ - -/*(Auto-generated) - * Created by TpmPrototypes; Version 3.0 July 18, 2017 - * Date: Mar 28, 2019 Time: 08:25:19PM - */ - -#ifndef _TPM_TO_OSSL_SUPPORT_FP_H_ -#define _TPM_TO_OSSL_SUPPORT_FP_H_ - -#if defined(HASH_LIB_OSSL) || defined(MATH_LIB_OSSL) || defined(SYM_LIB_OSSL) - -//*** BnSupportLibInit() -// This does any initialization required by the support library. -LIB_EXPORT int BnSupportLibInit(void); - -//*** OsslContextEnter() -// This function is used to initialize an OpenSSL context at the start of a function -// that will call to an OpenSSL math function. -BN_CTX* OsslContextEnter(void); - -//*** OsslContextLeave() -// This is the companion function to OsslContextEnter(). -void OsslContextLeave(BN_CTX* CTX); - -//*** OsslPushContext() -// This function is used to create a frame in a context. All values allocated within -// this context after the frame is started will be automatically freed when the -// context (OsslPopContext() -BN_CTX* OsslPushContext(BN_CTX* CTX); - -//*** OsslPopContext() -// This is the companion function to OsslPushContext(). -void OsslPopContext(BN_CTX* CTX); -#endif // HASH_LIB_OSSL || MATH_LIB_OSSL || SYM_LIB_OSSL - -#endif // _TPM_TO_OSSL_SUPPORT_FP_H_ diff --git a/src/tpm2/crypto/openssl/TpmToOsslSym.h b/src/tpm2/crypto/openssl/TpmToOsslSym.h deleted file mode 100644 index 654d2c05a..000000000 --- a/src/tpm2/crypto/openssl/TpmToOsslSym.h +++ /dev/null @@ -1,200 +0,0 @@ -/********************************************************************************/ -/* */ -/* Splice the OpenSSL() library into the TPM code. */ -/* 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 */ -/* */ -/********************************************************************************/ - -//** Introduction -// -// This header file is used to 'splice' the OpenSSL library into the TPM code. -// -// The support required of a library are a hash module, a block cipher module and -// portions of a big number library. - -// All of the library-dependent headers should have the same guard to that only the -// first one gets defined. -#ifndef SYM_LIB_DEFINED -#define SYM_LIB_DEFINED - -#define SYM_LIB_OSSL - -#include -#if ALG_TDES -#include -#endif - -#if ALG_SM4 -# if defined(OPENSSL_NO_SM4) || OPENSSL_VERSION_NUMBER < 0x10101010L -# error "Current version of OpenSSL doesn't support SM4" -# elif OPENSSL_VERSION_NUMBER >= 0x10200000L -# include -# else -// OpenSSL 1.1.1 keeps smX.h headers in the include/crypto directory, -// and they do not get installed as part of the libssl package - -# define SM4_KEY_SCHEDULE 32 - -typedef struct SM4_KEY_st { - uint32_t rk[SM4_KEY_SCHEDULE]; -} SM4_KEY; - -int SM4_set_key(const uint8_t *key, SM4_KEY *ks); -void SM4_encrypt(const uint8_t* in, uint8_t* out, const SM4_KEY* ks); -void SM4_decrypt(const uint8_t* in, uint8_t* out, const SM4_KEY* ks); -void SM4_final(const SM4_KEY *ks); -# endif // OpenSSL < 1.2 -#endif // ALG_SM4 - -#if ALG_CAMELLIA -# include -#endif - -#include -#include - -//*************************************************************** -//** Links to the OpenSSL symmetric algorithms. -//*************************************************************** - -// The Crypt functions that call the block encryption function use the parameters -// in the order: -// 1) keySchedule -// 2) in buffer -// 3) out buffer -// Since open SSL uses the order in encryptoCall_t above, need to swizzle the -// values to the order required by the library. -#define SWIZZLE(keySchedule, in, out) \ - (const BYTE*)(in), (BYTE*)(out), (void*)(keySchedule) - -// Define the order of parameters to the library functions that do block encryption -// and decryption. -typedef void (*TpmCryptSetSymKeyCall_t)(const BYTE* in, BYTE* out, void* keySchedule); - -#define SYM_ALIGNMENT 4 /* libtpms: keep old value */ - -//*************************************************************** -//** Links to the OpenSSL AES code -//*************************************************************** -// Macros to set up the encryption/decryption key schedules -// -// AES: -#define TpmCryptSetEncryptKeyAES(key, keySizeInBits, schedule) \ - AES_set_encrypt_key((key), (keySizeInBits), (tpmKeyScheduleAES*)(schedule)) -#define TpmCryptSetDecryptKeyAES(key, keySizeInBits, schedule) \ - AES_set_decrypt_key((key), (keySizeInBits), (tpmKeyScheduleAES*)(schedule)) - -// Macros to alias encryption calls to specific algorithms. This should be used -// sparingly. Currently, only used by CryptSym.c and CryptRand.c -// -// When using these calls, to call the AES block encryption code, the caller -// should use: -// TpmCryptEncryptAES(SWIZZLE(keySchedule, in, out)); -#define TpmCryptEncryptAES AES_encrypt -#define TpmCryptDecryptAES AES_decrypt -#define tpmKeyScheduleAES AES_KEY - -#define TpmCryptSetEncryptKeyTDES(key, keySizeInBits, schedule) \ - TDES_set_encrypt_key((key), (keySizeInBits), (tpmKeyScheduleTDES *)(schedule)) -#define TpmCryptSetDecryptKeyTDES(key, keySizeInBits, schedule) \ - TDES_set_encrypt_key((key), (keySizeInBits), (tpmKeyScheduleTDES *)(schedule)) - -#define TpmCryptEncryptTDES TDES_encrypt -#define TpmCryptDecryptTDES TDES_decrypt -#define tpmKeyScheduleTDES DES_key_schedule - -#if ALG_TDES // libtpms added begin -#include "TpmToOsslDesSupport_fp.h" -#endif // libtpms added end - -//*************************************************************** -//** Links to the OpenSSL SM4 code -//*************************************************************** -// Macros to set up the encryption/decryption key schedules -#define TpmCryptSetEncryptKeySM4(key, keySizeInBits, schedule) \ - SM4_set_key((key), (tpmKeyScheduleSM4 *)(schedule)) -#define TpmCryptSetDecryptKeySM4(key, keySizeInBits, schedule) \ - SM4_set_key((key), (tpmKeyScheduleSM4 *)(schedule)) - -// Macros to alias encryption calls to specific algorithms. This should be used -// sparingly. -#define TpmCryptEncryptSM4 SM4_encrypt -#define TpmCryptDecryptSM4 SM4_decrypt -#define tpmKeyScheduleSM4 SM4_KEY - -//*************************************************************** -//** Links to the OpenSSL CAMELLIA code -//*************************************************************** -// Macros to set up the encryption/decryption key schedules -#define TpmCryptSetEncryptKeyCAMELLIA(key, keySizeInBits, schedule) \ - Camellia_set_key((key), (keySizeInBits), (tpmKeyScheduleCAMELLIA*)(schedule)) -#define TpmCryptSetDecryptKeyCAMELLIA(key, keySizeInBits, schedule) \ - Camellia_set_key((key), (keySizeInBits), (tpmKeyScheduleCAMELLIA*)(schedule)) - -// Macros to alias encryption calls to specific algorithms. This should be used -// sparingly. -#define TpmCryptEncryptCAMELLIA Camellia_encrypt -#define TpmCryptDecryptCAMELLIA Camellia_decrypt -#define tpmKeyScheduleCAMELLIA CAMELLIA_KEY - -// Forward reference - -typedef union tpmCryptKeySchedule_t tpmCryptKeySchedule_t; - -// This definition would change if there were something to report -#define SymLibSimulationEnd() - -#endif // SYM_LIB_DEFINED diff --git a/src/tpm2/crypto/openssl/TpmToTpmBigNumMath.h b/src/tpm2/crypto/openssl/TpmToTpmBigNumMath.h deleted file mode 100644 index dbd625ce3..000000000 --- a/src/tpm2/crypto/openssl/TpmToTpmBigNumMath.h +++ /dev/null @@ -1,120 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* 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 */ -/* */ -/********************************************************************************/ - -//** Introduction -// This file contains OpenSSL specific functions called by TpmBigNum library to provide -// the TpmBigNum + OpenSSL math support. - -#ifndef _TPM_TO_TPMBIGNUM_MATH_H_ -#define _TPM_TO_TPMBIGNUM_MATH_H_ - -#ifdef MATH_LIB_DEFINED -# error only one primary math library allowed -#endif -#define MATH_LIB_DEFINED - -// indicate the TPMBIGNUM library is active -#define MATH_LIB_TPMBIGNUM - -// TODO_RENAME_INC_FOLDER: private refers to the TPM_CoreLib private headers -#include "GpMacros.h" // required for TpmFail_fp.h -#include "Capabilities.h" -#include "TpmTypes.h" // requires capabilities & GpMacros -#include "BnValues.h" - -#ifndef LIB_INCLUDE -# error include ordering error, LIB_INCLUDE not defined -#endif -#ifndef BN_MATH_LIB -# error BN_MATH_LIB not defined, required to provide BN library functions. -#endif - -#if defined(CRYPT_CURVE_INITIALIZED) || defined(CRYPT_CURVE_FREE) -#error include ordering error, expected CRYPT_CURVE_INITIALIZED & CRYPT_CURVE_FREE to be undefined. -#endif - -// Add support library dependent definitions. -// For TpmBigNum, we expect bigCurveData to be a defined type. -#include LIB_INCLUDE(BnTo, BN_MATH_LIB, Math) - -#include "BnConvert_fp.h" -#include "BnMath_fp.h" -#include "BnMemory_fp.h" -#include "BnSupport_Interface.h" - -// Define macros and types necessary for the math library abstraction layer -// Create a data object backing a Crypt_Int big enough for the given number of -// data bits -#define CRYPT_INT_BUF(buftypename, bits) BN_STRUCT(buftypename, bits) - -// Create a data object backing a Crypt_Point big enough for the given number of -// data bits, per coordinate -#define CRYPT_POINT_BUF(buftypename, bits) BN_POINT_BUF(buftypename, bits) - -// Create an instance of a data object underlying Crypt_EccCurve on the stack -// sufficient for given bit size. In our case, all are the same size. -#define CRYPT_CURVE_BUF(buftypename, max_size_in_bits) bigCurveData - -// now include the math library functional interface and instantiate the -// Crypt_Int & related types -// TODO_RENAME_INC_FOLDER: This should have a Tpm_Cryptolib_Common component prefix. -#include "MathLibraryInterface.h" - -#endif // _TPM_TO_TPMBIGNUM_MATH_H_ diff --git a/src/tpm2/crypto/openssl/consttime.txt b/src/tpm2/crypto/openssl/consttime.txt deleted file mode 100644 index 6dd8328f2..000000000 --- a/src/tpm2/crypto/openssl/consttime.txt +++ /dev/null @@ -1,76 +0,0 @@ -The following (top level) OpenSSL public BIGNUM functions check for -the BN_FLG_CONSTTIME: - -bn_blind.c: - BN_BLINDING_new() - -bn_exp.c: - BN_exp : must not be set for input bignums -! BN_mod_exp : SHOULD be set for any one of input bignums (only) if m is odd - BN_mod_exp_recp: must NOT be set for input bignums - BN_mod_exp_mont: SHOULD be set for any one of input bignums - BN_mod_exp_mont_word: must NOT be set for input bignums - BN_mod_exp_simple: must NOT bet set for input bignums - -bn_gcd.c: -! BN_mod_inverse: SHOULD be set for any one of input bignums - -bn_lib: - BN_num_bits -! BN_copy - -bn_mont.c: - BN_MONT_CTX_set - -bn.h: -! BN_num_bytes: Calls BN_num_bits - - -Relevant files and functions in the files: -Helpers.c - ComputePrivateExponentD: - - BN_dup: -> BN_copy: YES, BN_FLG_CONSTTIME set by caller on P and Q - - BN_sub: no - - BN_add_word: no - - BN_mod_inverse: YES, DONE - InitOpenSSLRSAPublicKey: - - BN_set_word: no - - BN_bin2bn: no - InitOpenSSLRSAPrivateKey: - - BN_bin2bn: no - - BN_div: -> BN_copy: YES, DONE - - BN_is_zero: no - -TpmToOsslMath: - OsslToTpmBn: - - BN_num_bytes: need not - - BN_bn2bin: -> BN_num_bytes: need not - BigInitialized: - - BN_bin2bn: no - - BN_copy: YES, DONE - BnModMult: - - BN_mul: no - - BN_div: -> BN_copy: ? - BnMult: - - BN_mul: no - BnDiv: - - BN_div: -> BN_copy: ? - BnGcd: /* FUNCTION IS NOT USED */ - - BN_gcd: -> BN_copy, BN_num_bits: YES, DONE - BnModExp: - - BN_mod_exp: YES, DONE - BnModInverse: - - BN_mod_inverse: YES, DONE - - -Elliptic curve signing : - -CryptEccMain.c: - BnEccGenerateKeyPair: - - BnEccModMult: YES, DONE (we have control over random number bnD) - called by BnSignEcSchnorr - called by BnSignEcdsa (if OpenSSL function not used) - -CryptEccSignature.c: - BnEccSignSM2: - - BnEccModMult: YES, DONE (we have control over random number bnK) diff --git a/src/tpm2/crypto/openssl/consttime.txt' b/src/tpm2/crypto/openssl/consttime.txt' deleted file mode 100644 index b66708617..000000000 --- a/src/tpm2/crypto/openssl/consttime.txt' +++ /dev/null @@ -1,58 +0,0 @@ -The following OpenSSL public BIGNUM functions check for the BN_FLG_CONSTTIME: - -bn_blind.c: - BN_BLINDING_new() - -bn_exp.c: - BN_exp : must not be set for input bignums -! BN_mod_exp : SHOULD be set for any one of input bignums (only) if m is odd - BN_mod_exp_recp: must NOT be set for input bignums - BN_mod_exp_mont: SHOULD be set for any one of input bignums - BN_mod_exp_mont_word: must NOT be set for input bignums - BN_mod_exp_simple: must NOT bet set for input bignums - -bn_gcd.c: -! BN_mod_inverse: SHOULD be set for any one of input bignums - -bn_lib: - BN_num_bits -! BN_copy - -bn_mont.c: - BN_MONT_CTX_set - -bn.h: -! BN_num_bytes: Calls BN_num_bits - - -Relevant files and functions in the files: -Helpers.c - - BN_dup: - - BN_sub: - - BN_add_word: - - BN_mod_inverse: yes - - BN_set_word: - - BN_bin2bn: - - BN_div: - - BN_is_zero: - -TpmToOsslMath: - OsslToTpmBn: - - BN_num_bytes: - - BN_bn2bin: - BigInitialized: - - BN_bin2bn: - - BN_copy: - BnModMult: - - BN_mul: - - BN_div: - BnMult: - - BN_mul: - BnDiv: - - BN_div: - BnGcd: - - BN_gcd: - BnModExp: - - BN_mod_exp: YES - BnModInverse: - - BN_mod_inverse: YES diff --git a/src/tpm2/endian_swap.h b/src/tpm2/endian_swap.h deleted file mode 100644 index b19fd318a..000000000 --- a/src/tpm2/endian_swap.h +++ /dev/null @@ -1,155 +0,0 @@ -/********************************************************************************/ -/* */ -/* 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 */ -/* */ -/********************************************************************************/ - -#ifndef _SWAP_H -#define _SWAP_H - -#if LITTLE_ENDIAN_TPM -# define TO_BIG_ENDIAN_UINT16(i) REVERSE_ENDIAN_16(i) -# define FROM_BIG_ENDIAN_UINT16(i) REVERSE_ENDIAN_16(i) -# define TO_BIG_ENDIAN_UINT32(i) REVERSE_ENDIAN_32(i) -# define FROM_BIG_ENDIAN_UINT32(i) REVERSE_ENDIAN_32(i) -# define TO_BIG_ENDIAN_UINT64(i) REVERSE_ENDIAN_64(i) -# define FROM_BIG_ENDIAN_UINT64(i) REVERSE_ENDIAN_64(i) -#else -# define TO_BIG_ENDIAN_UINT16(i) (i) -# define FROM_BIG_ENDIAN_UINT16(i) (i) -# define TO_BIG_ENDIAN_UINT32(i) (i) -# define FROM_BIG_ENDIAN_UINT32(i) (i) -# define TO_BIG_ENDIAN_UINT64(i) (i) -# define FROM_BIG_ENDIAN_UINT64(i) (i) -#endif - -#if AUTO_ALIGN == NO - -// The aggregation macros for machines that do not allow unaligned access or for -// little-endian machines. - -// Aggregate bytes into an UINT - -# define BYTE_ARRAY_TO_UINT8(b) (uint8_t)((b)[0]) -# define BYTE_ARRAY_TO_UINT16(b) ByteArrayToUint16((BYTE*)(b)) -# define BYTE_ARRAY_TO_UINT32(b) ByteArrayToUint32((BYTE*)(b)) -# define BYTE_ARRAY_TO_UINT64(b) ByteArrayToUint64((BYTE*)(b)) -# define UINT8_TO_BYTE_ARRAY(i, b) ((b)[0] = (uint8_t)(i)) -# define UINT16_TO_BYTE_ARRAY(i, b) Uint16ToByteArray((i), (BYTE*)(b)) -# define UINT32_TO_BYTE_ARRAY(i, b) Uint32ToByteArray((i), (BYTE*)(b)) -# define UINT64_TO_BYTE_ARRAY(i, b) Uint64ToByteArray((i), (BYTE*)(b)) - -#else // AUTO_ALIGN - -# if BIG_ENDIAN_TPM -// the big-endian macros for machines that allow unaligned memory access -// Aggregate a byte array into a UINT -# define BYTE_ARRAY_TO_UINT8(b) *((uint8_t*)(b)) -# define BYTE_ARRAY_TO_UINT16(b) *((uint16_t*)(b)) -# define BYTE_ARRAY_TO_UINT32(b) *((uint32_t*)(b)) -# define BYTE_ARRAY_TO_UINT64(b) *((uint64_t*)(b)) - -// 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)) = (i); \ - } -# define UINT32_TO_BYTE_ARRAY(i, b) \ - { \ - *((uint32_t*)(b)) = (i); \ - } -# define UINT64_TO_BYTE_ARRAY(i, b) \ - { \ - *((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 -// Aggregate a byte array into a UINT -# define BYTE_ARRAY_TO_UINT8(b) *((uint8_t*)(b)) -# define BYTE_ARRAY_TO_UINT16(b) REVERSE_ENDIAN_16(*((uint16_t*)(b))) -# define BYTE_ARRAY_TO_UINT32(b) REVERSE_ENDIAN_32(*((uint32_t*)(b))) -# define BYTE_ARRAY_TO_UINT64(b) REVERSE_ENDIAN_64(*((uint64_t*)(b))) - -// 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); \ - } -# endif // BIG_ENDIAN_TPM - -#endif // AUTO_ALIGN == NO - -#endif // _SWAP_H diff --git a/src/tpm2/gensymtestsdata.sh b/src/tpm2/gensymtestsdata.sh index 1c51c2f53..742c48a2a 100755 --- a/src/tpm2/gensymtestsdata.sh +++ b/src/tpm2/gensymtestsdata.sh @@ -1,4 +1,5 @@ #!/bin/bash +# SPDX-License-Identifier: BSD-2-Clause function do_aes() { local data="$1" diff --git a/src/tpm2/pcrstruct.h b/src/tpm2/pcrstruct.h deleted file mode 100644 index 8025888db..000000000 --- a/src/tpm2/pcrstruct.h +++ /dev/null @@ -1,157 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* 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 */ -/* */ -/********************************************************************************/ - -// -// This file defines the PCR and PCR_Attributes structures and -// related interface functions -// - -#ifndef _PCRSTRUCT_H_ -#define _PCRSTRUCT_H_ - -#include "BaseTypes.h" -#include "TpmAlgorithmDefines.h" -#include "TpmTypes.h" - -// a single PCR -typedef struct -{ -#if ALG_SHA1 - BYTE Sha1Pcr[SHA1_DIGEST_SIZE]; -#endif -#if ALG_SHA256 - BYTE Sha256Pcr[SHA256_DIGEST_SIZE]; -#endif -#if ALG_SHA384 - BYTE Sha384Pcr[SHA384_DIGEST_SIZE]; // libtpms: appended 'pcr' -#endif -#if ALG_SHA512 - BYTE Sha512Pcr[SHA512_DIGEST_SIZE]; // libtpms: appended 'pcr' -#endif -#if ALG_SM3_256 - BYTE Sm3_256[SM3_256_DIGEST_SIZE]; -#endif -#if ALG_SHA3_256 - BYTE Sha3_256[SHA3_256_DIGEST_SIZE]; -#endif -#if ALG_SHA3_384 - BYTE Sha3_384[SHA3_384_DIGEST_SIZE]; -#endif -#if ALG_SHA3_512 - BYTE Sha3_512[SHA3_512_DIGEST_SIZE]; -#endif -} PCR; - -// see the comments below for supportsPolicyAuth to explain this -#define MAX_PCR_GROUP_BITS 3 - -typedef struct -{ - // SET if the PCR value should be saved in state save - unsigned int stateSave : 1; - - // SET if the PCR is part of the "TCB group", causes the PCR counter not to increment - unsigned int doNotIncrementPcrCounter : 1; - - // PCRs may support policy or auth-value authorization. - // - // Such authorization values, if supported, are set by - // TPM2_PCR_SetAuthPolicy and/or TPM2_PCR_SetAuthValue. - // - // PCRs that share the same policy/auth value are said to be in a "group". - // PCRs that don't support authorization are said to be in group Zero. - // - // Group numbers are only used internally to indicate which PCRs share an - // authorization value. IOW the TPM client cannot refer to PCRs by group - // number; the range of group numbers is implementation defined. zero - // indicates the PCR doesn't support policy or auth verification. - // - // The size of this field must be large enough to support - // NUM_POLICY_PCR_GROUP & NUM_AUTHVALUE_PCR_GROUP; the maximum number of groups - // actually supported by this build of the core library. - // - // The number of bits allocated here does not control the number of groups, - // but there is a static assert that the number of bits here is large - // enough. - unsigned int policyAuthGroup : MAX_PCR_GROUP_BITS; - unsigned int authValuesGroup : MAX_PCR_GROUP_BITS; - - // these bitfields indicating the localities that can - // reset or extend this PCR. A SET bit indicates the PCR can - // be extended or reset from that locality. The low-order bit in - // each field is locality zero, and the high-order bit is locality 4. - unsigned int resetLocality : 5; - unsigned int extendLocality : 5; -} PCR_Attributes; - -// Get pointer to particular PCR from array if that PCR is allocated. -// otherwise returns NULL -BYTE* GetPcrPointerIfAllocated(PCR* pPcrArray, - TPM_ALG_ID alg, // IN: algorithm for bank - UINT32 pcrNumber // IN: PCR number -); - -// get a PCR pointer from the TPM's internal list, if it's allocated -// otherwise NULL -BYTE* GetPcrPointer(TPM_ALG_ID alg, // IN: algorithm for bank - UINT32 pcrNumber // IN: PCR number -); - -#endif diff --git a/src/tpm2/platform_pcr_fp.h b/src/tpm2/platform_pcr_fp.h deleted file mode 100644 index 5d9f39247..000000000 --- a/src/tpm2/platform_pcr_fp.h +++ /dev/null @@ -1,102 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* 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 */ -/* */ -/********************************************************************************/ - - -// platform PCR functions called by the TPM library - -#ifndef _PLATFORM_PCR_FP_H_ -#define _PLATFORM_PCR_FP_H_ - -#include "BaseTypes.h" -#include "TpmTypes.h" -#include "pcrstruct.h" - -// return the number of PCRs the platform recognizes for GetPcrInitializationAttributes. -// PCRs are numbered starting at zero. -// Note: The TPM Library will enter failure mode if this number doesn't match -// IMPLEMENTATION_PCR. -UINT32 _platPcr__NumberOfPcrs(void); - -// return the initialization attributes of a given PCR. -// pcrNumber expected to be in [0, _platPcr__NumberOfPcrs) -// returns the attributes for PCR[0] if the requested pcrNumber is out of range. -// Note this returns a structure by-value, which is fast because the structure is -// a bitfield. -PCR_Attributes _platPcr__GetPcrInitializationAttributes(UINT32 pcrNumber); - -// Fill a given buffer with the PCR initialization value for a particular PCR and hash -// combination, and return its length. If the platform doesn't have a value, then -// the result size is expected to be zero, and the rfunction will return TPM_RC_PCR. -// If a valid is not available, then the core TPM library will ignore the value and -// treat it as non-existant and provide a default. -// If the buffer is not large enough for a pcr consistent with pcrAlg, then the -// platform will return TPM_RC_FAILURE. -TPM_RC _platPcr__GetInitialValueForPcr( - UINT32 pcrNumber, // IN: PCR to be initialized - TPM_ALG_ID pcrAlg, // IN: Algorithm of the PCR Bank being initialized - BYTE startupLocality, // IN: locality where startup is being called from - BYTE* pcrBuffer, // OUT: buffer to put PCR initialization value into - uint16_t bufferSize, // IN: maximum size of value buffer can hold - uint16_t* pcrLength); // OUT: size of initialization value returned in pcrBuffer - -// should the given PCR algorithm default to active in a new TPM? -BOOL _platPcr_IsPcrBankDefaultActive(TPM_ALG_ID pcrAlg); - -#endif // _PLATFORM_PCR_FP_H_ diff --git a/src/tpm2/platform_to_tpm_interface.h b/src/tpm2/platform_to_tpm_interface.h deleted file mode 100644 index 71024c99c..000000000 --- a/src/tpm2/platform_to_tpm_interface.h +++ /dev/null @@ -1,72 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* 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 */ -/* */ -/********************************************************************************/ - -#ifndef _PLATFORM_TO_TPM_INTERFACE_H_ -#define _PLATFORM_TO_TPM_INTERFACE_H_ - -#include "_TPM_Hash_Data_fp.h" -#include "_TPM_Hash_End_fp.h" -#include "_TPM_Hash_Start_fp.h" -#include "_TPM_Init_fp.h" -#include "ExecCommand_fp.h" -#include "Manufacture_fp.h" -// TODO_RENAME_INC_FOLDER: public refers to the TPM_CoreLib public headers -#include "TpmFail_fp.h" -#endif diff --git a/src/tpm2/simulatorPrivate.h b/src/tpm2/simulatorPrivate.h deleted file mode 100644 index 003c044f7..000000000 --- a/src/tpm2/simulatorPrivate.h +++ /dev/null @@ -1,81 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* 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 */ -/* */ -/********************************************************************************/ - - -// common headers for simulator implementation files - -#ifndef SIMULATOR_PRIVATE_H -#define SIMULATOR_PRIVATE_H - -//** Includes, Locals, Defines and Function Prototypes -#include "tpm_public.h" - -#include "simulator_sysheaders.h" - -// TODO_RENAME_INC_FOLDER:prototypes refers to the platform library -#include "platform_public_interface.h" -// TODO_RENAME_INC_FOLDER:platform_interface refers to the TPM_CoreLib platform interface -#include "tpm_to_platform_interface.h" -#include "platform_to_tpm_interface.h" - -#include "TpmTcpProtocol.h" -#include "Simulator_fp.h" - -#endif // SIMULATOR_PRIVATE_H diff --git a/src/tpm2/simulator_sysheaders.h b/src/tpm2/simulator_sysheaders.h deleted file mode 100644 index 1dbbbc5d2..000000000 --- a/src/tpm2/simulator_sysheaders.h +++ /dev/null @@ -1,105 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* 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 */ -/* */ -/********************************************************************************/ - -// system headers for the simulator, both Windows and Linux - -#ifndef _SIMULATOR_SYSHEADERS_H_ -#define _SIMULATOR_SYSHEADERS_H_ -// include the system headers silencing warnings that occur with /Wall -#include -#include -#include -#include -#include -#include - -#ifdef _MSC_VER -# pragma warning(push, 3) -// C4668 is supposed to be level 4, but this is still necessary to suppress the -// error. We don't want to suppress it globally because the same error can -// happen in the TPM code and it shouldn't be ignored in those cases because it -// generally means a configuration header is missing. -// -// X is not defined as a preprocessor macro, assuming 0 for #if -# pragma warning(disable : 4668) -# include -# include -# pragma warning(pop) -typedef int socklen_t; -#elif defined(__unix__) || defined(__APPLE__) -# include -# include -# include -# include -# include -// simulate certain windows APIs -# define ZeroMemory(ptr, sz) (memset((ptr), 0, (sz))) -# define closesocket(x) close(x) -# define INVALID_SOCKET (-1) -# define SOCKET_ERROR (-1) -# define WSAGetLastError() (errno) -# define WSAEADDRINUSE EADDRINUSE -# define INT_PTR intptr_t -typedef int SOCKET; -# define _strcmpi strcasecmp -#else -# error "Unsupported platform." -#endif // _MSC_VER -#endif // _SIMULATOR_SYSHEADERS_H_ diff --git a/src/tpm2/tpm_public.h b/src/tpm2/tpm_public.h deleted file mode 100644 index c7343ee95..000000000 --- a/src/tpm2/tpm_public.h +++ /dev/null @@ -1,69 +0,0 @@ -/********************************************************************************/ -/* */ -/* */ -/* 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 */ -/* */ -/********************************************************************************/ - -#include "TpmBuildSwitches.h" -#include "TpmProfile.h" - -#include "VerifyConfiguration.h" -#include "BaseTypes.h" -#include "TPMB.h" -#include "MinMax.h" -#include "tpm_radix.h" -#include "TpmTypes.h" diff --git a/src/tpm_tpm2_interface.c b/src/tpm_tpm2_interface.c index 7bebbc9e1..508a0338b 100644 --- a/src/tpm_tpm2_interface.c +++ b/src/tpm_tpm2_interface.c @@ -44,19 +44,15 @@ #ifndef LIB_EXPORT #define LIB_EXPORT #endif -#include "tpm2/Tpm.h" -#include "tpm2/Manufacture_fp.h" -#include "tpm2/Platform_fp.h" -#include "tpm2/ExecCommand_fp.h" -#include "tpm2/TpmTcpProtocol.h" -#include "tpm2/Simulator_fp.h" -#include "tpm2/_TPM_Hash_Data_fp.h" -#include "tpm2/_TPM_Init_fp.h" -#include "tpm2/StateMarshal.h" -#include "tpm2/PlatformACT.h" -#include "tpm2/PlatformData.h" -#include "tpm2/Volatile.h" -#include "tpm2/crypto/openssl/ExpDCache_fp.h" + +#include "Tpm.h" +#include +#include +#include "PlatformData.h" +#include "PlatformInternal.h" +#include "StateMarshal.h" +#include "Volatile.h" +#include "ExpDCache_fp.h" #define TPM_HAVE_TPM2_DECLARATIONS #include "tpm_nvfile.h" // TPM_NVRAM_Loaddata() @@ -64,7 +60,6 @@ #include "tpm_library_intern.h" #include "tpm_nvfilename.h" -extern BOOL g_inFailureMode; static BOOL reportedFailureCommand; static char *g_profile; static TPM_BOOL g_wasManufactured; @@ -104,7 +99,7 @@ static TPM_RESULT TPM2_MainInit(void) bool has_nvram_file; bool has_nvram_loaddata_callback; - g_inFailureMode = FALSE; + _plat_internal_resetFailureData(); reportedFailureCommand = FALSE; g_wasManufactured = FALSE; @@ -136,7 +131,7 @@ static TPM_RESULT TPM2_MainInit(void) TPMLIB_LogTPM2Error( "%s: _plat__NVEnable(NULL) failed: %d\n", __func__, ret); - if (TPM_Manufacture(TRUE, g_profile) < 0 || g_inFailureMode) { + if (TPM_Manufacture(TRUE, g_profile) < 0 || _plat__InFailureMode()) { TPMLIB_LogTPM2Error("%s: TPM_Manufacture(TRUE) failed or TPM in " "failure mode\n", __func__); reportedFailureCommand = TRUE; @@ -156,7 +151,7 @@ static TPM_RESULT TPM2_MainInit(void) _rpc__Signal_NvOn(); if (ret == TPM_SUCCESS) { - if (g_inFailureMode) + if (_plat__InFailureMode()) ret = TPM_RC_FAILURE; } @@ -233,7 +228,7 @@ static TPM_RESULT TPM2_Process(unsigned char **respbuffer, uint32_t *resp_size, *resp_size = resp.BufferSize; - if (g_inFailureMode && !reportedFailureCommand) { + if (_plat__InFailureMode() && !reportedFailureCommand) { reportedFailureCommand = TRUE; TPMLIB_LogTPM2Error("%s: Entered failure mode through command:\n", __func__); @@ -360,11 +355,11 @@ static TPM_RESULT TPM2_GetTPMProperty(enum TPMLIB_TPMProperty prop, */ static char *TPM2_GetInfo(enum TPMLIB_InfoFlags flags) { - const char *tpmspec = + const char *tpmspec_temp = "\"TPMSpecification\":{" "\"family\":\"2.0\"," - "\"level\":" STRINGIFY(TPM_SPEC_LEVEL_NUM) "," - "\"revision\":" STRINGIFY(TPM_SPEC_VERSION) + "\"level\": %u," + "\"revision\": %u" "}"; const char *tpmattrs_temp = "\"TPMAttributes\":{" @@ -408,10 +403,12 @@ static char *TPM2_GetInfo(enum TPMLIB_InfoFlags flags) "]"; char *fmt = NULL, *buffer; bool printed = false; + char *tpmspec = NULL; char *tpmattrs = NULL; char *tpmfeatures = NULL; char rsakeys[32]; char camelliakeys[16]; + SPEC_CAPABILITY_VALUE spec_capability_value = {0}; char *runtimeAlgos[RUNTIME_ALGO_NUM] = { NULL, }; char *runtimeCmds[RUNTIME_CMD_NUM] = { NULL, }; char *runtimeAttrs[RUNTIME_ATTR_NUM] = { NULL, }; @@ -431,8 +428,14 @@ static char *TPM2_GetInfo(enum TPMLIB_InfoFlags flags) return NULL; if ((flags & TPMLIB_INFO_TPMSPECIFICATION)) { + _plat_GetSpecCapabilityValue(&spec_capability_value); + fmt = buffer; buffer = NULL; + if (TPMLIB_asprintf(&tpmspec, tpmspec_temp, + spec_capability_value.tpmSpecLevel, + spec_capability_value.tpmSpecVersion) < 0) + goto error; if (TPMLIB_asprintf(&buffer, fmt, "", tpmspec, "%s%s%s") < 0) goto error; free(fmt); @@ -597,6 +600,7 @@ static char *TPM2_GetInfo(enum TPMLIB_InfoFlags flags) exit: free(fmt); + free(tpmspec); free(tpmattrs); free(tpmfeatures); free(profile); diff --git a/src/tpm_tpm2_tis.c b/src/tpm_tpm2_tis.c index 08623eb10..50676315a 100644 --- a/src/tpm_tpm2_tis.c +++ b/src/tpm_tpm2_tis.c @@ -40,15 +40,10 @@ #include -#include "tpm2/Tpm.h" -#include "tpm2/TpmTypes.h" -#include "tpm2/TpmBuildSwitches.h" -#include "tpm2/_TPM_Hash_Start_fp.h" -#include "tpm2/_TPM_Hash_Data_fp.h" -#include "tpm2/_TPM_Hash_End_fp.h" -#include "tpm2/TpmTcpProtocol.h" -#include "tpm2/Platform_fp.h" -#include "tpm2/Simulator_fp.h" +#include "Tpm.h" +#include "TpmTcpProtocol.h" +#include "Simulator_fp.h" +#include "prototypes/platform_public_interface.h" #define TPM_HAVE_TPM2_DECLARATIONS #include "tpm_library_intern.h" diff --git a/tests/Makefile.am b/tests/Makefile.am index 059aab555..3317f2cb7 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -13,6 +13,26 @@ AM_CFLAGS = -I$(top_srcdir)/include $(SANITIZERS) AM_LDFLAGS = -no-undefined $(SANITIZERS) LDADD = $(top_builddir)/src/libtpms.la +HEADER_CFLAGS = \ + -I$(top_srcdir)/include/libtpms \ + -I$(top_srcdir)/src \ + -I$(top_srcdir)/src/tpm2 \ + -I$(top_srcdir)/src/tpm2/crypto/openssl \ + -I$(top_srcdir)/src/tpm2/TPMCmd/Platform/include/ \ + -I$(top_srcdir)/src/tpm2/TPMCmd/Simulator/include/ \ + -I$(top_srcdir)/src/tpm2/TPMCmd/Simulator/include/prototypes \ + -I$(top_srcdir)/src/tpm2/TPMCmd/TpmConfiguration \ + -I$(top_srcdir)/src/tpm2/TPMCmd/tpm/include/ \ + -I$(top_srcdir)/src/tpm2/TPMCmd/tpm/include/private \ + -I$(top_srcdir)/src/tpm2/TPMCmd/tpm/include/private/prototypes/ \ + -I$(top_srcdir)/src/tpm2/TPMCmd/tpm/cryptolibs/common/include/ \ + -I$(top_srcdir)/src/tpm2/TPMCmd/tpm/cryptolibs/TpmBigNum/include/ \ + -I$(top_srcdir)/src/tpm2/TPMCmd/tpm/cryptolibs/TpmBigNum/include/TpmBigNum/ \ + -I$(top_srcdir)/src/tpm2/TPMCmd/tpm/cryptolibs/ \ + -I$(top_srcdir)/src/tpm2/TPMCmd/tpm/cryptolibs/Ossl/ \ + -I$(top_srcdir)/src/tpm2/TPMCmd/tpm/cryptolibs/Ossl/include \ + -I$(top_srcdir)/src/tpm2/TPMCmd/tpm/cryptolibs/Ossl/include/Ossl + check_PROGRAMS = \ base64decode @@ -42,11 +62,7 @@ endif nvram_offsets_SOURCES = nvram_offsets.c nvram_offsets_CFLAGS = $(AM_CFLAGS) \ - -I$(top_srcdir)/include/libtpms \ - -I$(top_srcdir)/src \ - -I$(top_srcdir)/src/tpm2 \ - -I$(top_srcdir)/src/tpm2/crypto \ - -I$(top_srcdir)/src/tpm2/crypto/openssl \ + $(HEADER_CFLAGS) \ -DTPM_POSIX nvram_offsets_LDFLAGS = $(AM_LDFLAGS) @@ -62,12 +78,8 @@ TESTS += \ object_size_SOURCES = object_size.c object_size_CFLAGS = $(AM_CFLAGS) \ + $(HEADER_CFLAGS) \ -static \ - -I$(top_srcdir)/include/libtpms \ - -I$(top_srcdir)/src \ - -I$(top_srcdir)/src/tpm2 \ - -I$(top_srcdir)/src/tpm2/crypto \ - -I$(top_srcdir)/src/tpm2/crypto/openssl \ -DTPM_POSIX object_size_LDFLAGS = $(AM_LDFLAGS) endif # ENABLE_STATIC_TESTS