aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHaibo Huang <hhb@google.com>2020-12-09 15:52:20 -0800
committerHaibo Huang <hhb@google.com>2020-12-09 15:52:20 -0800
commit6f9639fdfd051ad4abeab80ae9c21be5dece3b46 (patch)
tree076a2eaa768d9f079eac1421af61d3628b72ff17
parentf59c59194cc01b480351cb7335718f6253f7b407 (diff)
parentf640b4bdb3a0fe944628e9f7df1362e2b9aa647d (diff)
downloadms-tpm-20-ref-6f9639fdfd051ad4abeab80ae9c21be5dece3b46.tar.gz
Upgrade ms-tpm-20-ref to f640b4bdb3a0fe944628e9f7df1362e2b9aa647d
Test: make Change-Id: I5a145825ec0249c426528364dcd26629d000d7b1
-rw-r--r--.travis.yml1
-rw-r--r--METADATA6
-rw-r--r--README.md45
-rw-r--r--TPMCmd/tpm/Tpm.vcxproj28
-rw-r--r--TPMCmd/tpm/include/TpmProfile.h6
-rw-r--r--TPMCmd/tpm/include/Wolf/TpmToWolfHash.h6
-rw-r--r--TPMCmd/tpm/include/Wolf/TpmToWolfSym.h8
-rw-r--r--TPMCmd/tpm/src/command/Attestation/CertifyX509.c6
-rw-r--r--TPMCmd/tpm/src/crypt/AlgorithmTests.c2
-rw-r--r--TPMCmd/tpm/src/crypt/CryptRsa.c2
-rw-r--r--TPMCmd/tpm/src/main/ExecCommand.c2
-rw-r--r--TPMCmd/tpm/src/subsystem/NvDynamic.c4
12 files changed, 64 insertions, 52 deletions
diff --git a/.travis.yml b/.travis.yml
index 4af1ff6..92b333d 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -12,7 +12,6 @@ addons:
arch:
- amd64
- arm64
- - ppc64le
- s390x
matrix:
diff --git a/METADATA b/METADATA
index 34f32c8..81c313d 100644
--- a/METADATA
+++ b/METADATA
@@ -5,11 +5,11 @@ third_party {
type: GIT
value: "https://github.com/microsoft/ms-tpm-20-ref.git"
}
- version: "69437ff7622a0110ac2088fca5ae9bb265c0fb1c"
+ version: "f640b4bdb3a0fe944628e9f7df1362e2b9aa647d"
license_type: NOTICE
last_upgrade_date {
year: 2020
- month: 5
- day: 14
+ month: 12
+ day: 9
}
}
diff --git a/README.md b/README.md
index 6fcc0f5..28ed2d9 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-# MS TPM 2.0 Reference Implementation #
+# Official TPM 2.0 Reference Implementation (by Microsoft) #
[![Build Status](https://travis-ci.org/Microsoft/ms-tpm-20-ref.svg?branch=master)](https://travis-ci.org/Microsoft/ms-tpm-20-ref)
@@ -6,44 +6,47 @@ This is the official TCG reference implementation of the [TPM 2.0 Specification]
See the definition of the `SPEC_VERSION`, `SPEC_YEAR` and `SPEC_DAY_OF_YEAR` values in the [TpmTypes.h](TPMCmd/tpm/include/TpmTypes.h) header for the exact revision/date of the TPM 2.0 specification, which the given source tree snapshot corresponds to.
-## Visual Studio build ##
+The reference implementation can be directly used via the [TPM 2.0 simulator](TPMCmd/Simulator) that emulates a TPM 2.0 device and can be accessed via a custom TCP based protocol. The simplest way to work with the simulator is to use a [TSS library](https://github.com/Microsoft/TSS.MSR) for the programming language of your choice - C#/.Net, C++, Java, Python, JavaScript/Node.js are currently supported. The C language TSS implementing the TCG's TSS API specifiaction is available [here](https://github.com/tpm2-software/tpm2-tss).
-Before building the Visual Studio solution:
+## Windows build ##
-1. Uncomment and update the definitions of the following macros in the [VendorString.h](TPMCmd/tpm/include/VendorString.h) header:
- - MANUFACTURER
- - VENDOR_STRING_1
- - FIRMWARE_V1 and FIRMWARE_V2
+Windows build is implemented as a Visual Studio 2017 solution. Before building it:
-2. Setup the underlying cryptographic library:
+* Setup one or both of the following underlying cryptographic libraries:
-### OpenSSL library ###
+ ### OpenSSL library ###
-1. Create `TPMCmd/lib` folder and place a static OpenSSL library (`libcrypto.lib`) built for the `x86` architecture there. For the `x64` architecture use the `TPMCmd/lib/x64` folder.
+ 1. Create `TPMCmd/lib` folder and place a static OpenSSL library (`libcrypto.lib`) built for the `x86` architecture there. For the `x64` architecture use the `TPMCmd/lib/x64` folder.
- The static libs can be either static libraries proper, or import libraries accompanying the corresponding DLLs. In the latter case you'll need to ensure that ther is a matching copy of the OpenSSL DLL in the standard Windows search path, so that it is available when you run the simulator executable (e.g. copy it into the same folder where `simulator.exe` is located).
+ The static libs can be either static libraries proper, or import libraries accompanying the corresponding DLLs. In the latter case you'll need to ensure that ther is a matching copy of the OpenSSL DLL in the standard Windows search path, so that it is available when you run the simulator executable (e.g. copy it into the same folder where `simulator.exe` is located).
- Recommended version of OpenSSL is `1.1.1d`.
+ Recommended version of OpenSSL is `1.1.1d` or higher.
-2. Create `TPMCmd/OsslInclude/openssl` folder and copy there the contents of the `openssl/include/openssl` folder of the OpenSSL source tree used to build the static library used on the step 2).
+ 2. Create `TPMCmd/OsslInclude/openssl` folder and copy there the contents of the `openssl/include/openssl` folder in the OpenSSL source tree used to build the OpenSSL library.
-3. Build the solution with either Debug or Release as the active configuration.
+ If you enable SM{2,3,4} algorithms in `TpmProfile.h`, the build may fail because of missing `SM{2,3,4}.h` headers. In this case you will need to manually copy them over from OpenSSL’s `include/crypt` folder.
-### Wolfcrypt library (wolfSSL) ###
+ 3. Build the solution with either Debug or Release as the active configuration.
-1. WolfSSL is included as a submodule. Initialize and update the submodule to fetch the project and checkout the appropriate commit.
+ ### Wolfcrypt library (wolfSSL) ###
- > git submodule init
- > git submodule update
+ 1. WolfSSL is included as a submodule. Initialize and update the submodule to fetch the project and checkout the appropriate commit.
- The current commit will point the minimum recommended version of wolfSSL. Moving to a more recent tag or commit should also be supported but might not be tested.
+ > git submodule init
+ > git submodule update
-2. Build the solution with either WolfDebug or WolfRelease as the active configuration, either from inside the Visual Studio or with the following command line:
+ The current commit will point the minimum recommended version of wolfSSL. Moving to a more recent tag or commit should also be supported but might not be tested.
+
+ 2. Build the solution with either WolfDebug or WolfRelease as the active configuration, either from inside the Visual Studio or with the following command line:
> msbuild TPMCmd\simulator.sln /p:Configuration=WolfDebug
-
+
+* If necessary, update the definitions of the following macros in the [VendorString.h](TPMCmd/tpm/include/VendorString.h) header: `MANUFACTURER`, `VENDOR_STRING_1`, `FIRMWARE_V1 and FIRMWARE_V2`
+
## Linux build
Follows the common `./bootstrap && ./configure && make` convention.
Note that autotools scripts require the following prerequisite packages: `autoconf-archive`, `pkg-config`, and sometimes `build-essential` and `automake`. Their absence is not automatically detected. The build also needs `gcc` and `libssl-dev` packages.
+
+Similarly to the Windows build, if you enable SM{2,3,4} algorithms in `TpmProfile.h`, the build may fail because of missing `SM{2,3,4}.h` headers. In this case you will need to manually copy them over from OpenSSL’s `include/crypt` folder.
diff --git a/TPMCmd/tpm/Tpm.vcxproj b/TPMCmd/tpm/Tpm.vcxproj
index b08f14c..7c4af04 100644
--- a/TPMCmd/tpm/Tpm.vcxproj
+++ b/TPMCmd/tpm/Tpm.vcxproj
@@ -230,7 +230,7 @@
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>$(ProjectDir)include\;$(ProjectDir)include\prototypes\;$(SolutionDir)Platform\include\;$(SolutionDir)Platform\include\prototypes\;$(SolutionDir)LtcInclude\;$(SolutionDIr)OsslInclude\;$(SolutionDir)MsBnInclude\</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>HASH_LIB=Ossl;SYM_LIB=Ossl;MATH_LIB=Ossl;%(PreprocessorDefinitions); </PreprocessorDefinitions>
+ <PreprocessorDefinitions>TABLE_DRIVEN_DISPATCH=0;HASH_LIB=Ossl;SYM_LIB=Ossl;MATH_LIB=Ossl;%(PreprocessorDefinitions); </PreprocessorDefinitions>
<MinimalRebuild>false</MinimalRebuild>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
@@ -284,7 +284,7 @@ del $(SolutionDir)Simulator\RsaKeyCache*.data</Command>
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>$(ProjectDir)include\wolf;$(SolutionDir)..\external\wolfssl;$(SolutionDir)\wolfcrypt\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>COMPILER_CHECKS;LIBRARY_COMPATIBILITY_CHECK;HASH_LIB=Wolf;SYM_LIB=Wolf;MATH_LIB=Wolf;WOLFSSL_USER_SETTINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>TABLE_DRIVEN_DISPATCH=0;COMPILER_CHECKS;LIBRARY_COMPATIBILITY_CHECK;HASH_LIB=Wolf;SYM_LIB=Wolf;MATH_LIB=Wolf;WOLFSSL_USER_SETTINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>false</MinimalRebuild>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
@@ -293,7 +293,7 @@ del $(SolutionDir)Simulator\RsaKeyCache*.data</Command>
<CallingConvention>Cdecl</CallingConvention>
<CompileAs>CompileAsC</CompileAs>
<StructMemberAlignment>Default</StructMemberAlignment>
- <DisableSpecificWarnings>4255;4668; 4710;4711; 4820;5045</DisableSpecificWarnings>
+ <DisableSpecificWarnings>4127;4255;4668; 4710;4711; 4820;5045</DisableSpecificWarnings>
<BrowseInformation>true</BrowseInformation>
<InlineFunctionExpansion>Default</InlineFunctionExpansion>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
@@ -334,7 +334,7 @@ del $(SolutionDir)Simulator\RsaKeyCache*.data</Command>
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>$(ProjectDir)include\;$(ProjectDir)include\prototypes\;$(SolutionDir)Platform\include\;$(SolutionDir)Platform\include\prototypes\;$(SolutionDir)LtcInclude\;$(SolutionDIr)OsslInclude\;$(SolutionDir)MsBnInclude\</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>HASH_LIB=Ossl;SYM_LIB=Ossl;MATH_LIB=Ossl;CRYPTO_ALIGN_4;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>TABLE_DRIVEN_DISPATCH=0;HASH_LIB=Ossl;SYM_LIB=Ossl;MATH_LIB=Ossl;CRYPTO_ALIGN_4;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>false</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
@@ -384,7 +384,7 @@ del $(SolutionDir)Simulator\RsaKeyCache*.data</Command>
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>$(ProjectDir)include\;$(ProjectDir)include\prototypes\;$(SolutionDir)Platform\include\;$(SolutionDir)Platform\include\prototypes\;$(SolutionDir)LtcInclude\;$(SolutionDIr)OsslInclude\;$(SolutionDir)MsBnInclude\</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>HASH_LIB=Ossl;SYM_LIB=Ossl;MATH_LIB=Ossl;CRYPTO_ALIGN_16;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>TABLE_DRIVEN_DISPATCH=0;HASH_LIB=Ossl;SYM_LIB=Ossl;MATH_LIB=Ossl;CRYPTO_ALIGN_16;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
@@ -412,7 +412,7 @@ del $(SolutionDir)Simulator\RsaKeyCache*.data</Command>
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>$(ProjectDir)include\wolf;$(SolutionDir)..\external\wolfssl;$(SolutionDir)\wolfcrypt\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>COMPILER_CHECKS;LIBRARY_COMPATIBILITY_CHECK;HASH_LIB=Wolf;SYM_LIB=Wolf;MATH_LIB=Wolf;WOLFSSL_USER_SETTINGS;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>TABLE_DRIVEN_DISPATCH=0;COMPILER_CHECKS;LIBRARY_COMPATIBILITY_CHECK;HASH_LIB=Wolf;SYM_LIB=Wolf;MATH_LIB=Wolf;WOLFSSL_USER_SETTINGS;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
@@ -420,7 +420,7 @@ del $(SolutionDir)Simulator\RsaKeyCache*.data</Command>
</PrecompiledHeader>
<WarningLevel>EnableAllWarnings</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
- <DisableSpecificWarnings>4255;4668; 4710;4711; 4820;5045</DisableSpecificWarnings>
+ <DisableSpecificWarnings>4127;4255;4668; 4710;4711; 4820;5045</DisableSpecificWarnings>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
@@ -440,7 +440,7 @@ del $(SolutionDir)Simulator\RsaKeyCache*.data</Command>
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>$(ProjectDir)include\;$(ProjectDir)include\prototypes\;$(SolutionDir)Platform\include\;$(SolutionDir)Platform\include\prototypes\;$(SolutionDir)LtcInclude\;$(SolutionDIr)OsslInclude\;$(SolutionDir)MsBnInclude\</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>HASH_LIB=Ossl;SYM_LIB=Ossl;MATH_LIB=Ossl;CRYPTO_ALIGN_16;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>TABLE_DRIVEN_DISPATCH=0;HASH_LIB=Ossl;SYM_LIB=Ossl;MATH_LIB=Ossl;CRYPTO_ALIGN_16;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
@@ -466,7 +466,7 @@ del $(SolutionDir)Simulator\RsaKeyCache*.data</Command>
<Optimization>MaxSpeed</Optimization>
<AdditionalIncludeDirectories>$(ProjectDir)include\;$(ProjectDir)include\prototypes\;$(SolutionDir)Platform\include\;$(SolutionDir)Platform\include\prototypes\;$(SolutionDir)LtcInclude\;$(SolutionDIr)OsslInclude\;$(SolutionDir)MsBnInclude\</AdditionalIncludeDirectories>
<IntrinsicFunctions>true</IntrinsicFunctions>
- <PreprocessorDefinitions>HASH_LIB=Ossl;SYM_LIB=Ossl;MATH_LIB=Ossl;CRYPTO_ALIGN_4;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>TABLE_DRIVEN_DISPATCH=0;HASH_LIB=Ossl;SYM_LIB=Ossl;MATH_LIB=Ossl;CRYPTO_ALIGN_4;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
@@ -494,14 +494,14 @@ del $(SolutionDir)Simulator\RsaKeyCache*.data</Command>
<Optimization>MaxSpeed</Optimization>
<AdditionalIncludeDirectories>$(ProjectDir)include\wolf;$(SolutionDir)..\external\wolfssl;$(SolutionDir)\wolfcrypt\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<IntrinsicFunctions>true</IntrinsicFunctions>
- <PreprocessorDefinitions>HASH_LIB=Wolf;SYM_LIB=Wolf;MATH_LIB=Wolf;WOLFSSL_USER_SETTINGS;CRYPTO_ALIGN_4;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>TABLE_DRIVEN_DISPATCH=0;HASH_LIB=Wolf;SYM_LIB=Wolf;MATH_LIB=Wolf;WOLFSSL_USER_SETTINGS;CRYPTO_ALIGN_4;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>EnableAllWarnings</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<CompileAs>CompileAsC</CompileAs>
- <DisableSpecificWarnings>4255;4668; 4710;4711; 4820;5045</DisableSpecificWarnings>
+ <DisableSpecificWarnings>4127;4255;4668; 4710;4711; 4820;5045</DisableSpecificWarnings>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
@@ -525,7 +525,7 @@ del $(SolutionDir)Simulator\RsaKeyCache*.data</Command>
<Optimization>MaxSpeed</Optimization>
<AdditionalIncludeDirectories>$(ProjectDir)include\;$(ProjectDir)include\prototypes\;$(SolutionDir)Platform\include\;$(SolutionDir)Platform\include\prototypes\;$(SolutionDir)LtcInclude\;$(SolutionDIr)OsslInclude\;$(SolutionDir)MsBnInclude\</AdditionalIncludeDirectories>
<IntrinsicFunctions>true</IntrinsicFunctions>
- <PreprocessorDefinitions>HASH_LIB=Ossl;SYM_LIB=Ossl;MATH_LIB=Ossl;CRYPTO_ALIGN_16;NDEBUG;%(PreprocessorDefinitions);</PreprocessorDefinitions>
+ <PreprocessorDefinitions>TABLE_DRIVEN_DISPATCH=0;HASH_LIB=Ossl;SYM_LIB=Ossl;MATH_LIB=Ossl;CRYPTO_ALIGN_16;NDEBUG;%(PreprocessorDefinitions);</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeader>
@@ -560,7 +560,7 @@ del $(SolutionDir)Simulator\RsaKeyCache*.data</Command>
<Optimization>MaxSpeed</Optimization>
<AdditionalIncludeDirectories>$(ProjectDir)include\wolf;$(SolutionDir)..\external\wolfssl;$(SolutionDir)\wolfcrypt\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<IntrinsicFunctions>true</IntrinsicFunctions>
- <PreprocessorDefinitions>HASH_LIB=Wolf;SYM_LIB=Wolf;MATH_LIB=Wolf;WOLFSSL_USER_SETTINGS;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>TABLE_DRIVEN_DISPATCH=0;HASH_LIB=Wolf;SYM_LIB=Wolf;MATH_LIB=Wolf;WOLFSSL_USER_SETTINGS;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeader>
@@ -569,7 +569,7 @@ del $(SolutionDir)Simulator\RsaKeyCache*.data</Command>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<StructMemberAlignment>16Bytes</StructMemberAlignment>
<TreatWarningAsError>true</TreatWarningAsError>
- <DisableSpecificWarnings>4255;4668; 4710;4711; 4820;5045</DisableSpecificWarnings>
+ <DisableSpecificWarnings>4127;4255;4668; 4710;4711; 4820;5045</DisableSpecificWarnings>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
diff --git a/TPMCmd/tpm/include/TpmProfile.h b/TPMCmd/tpm/include/TpmProfile.h
index 077f1f8..b8cfe41 100644
--- a/TPMCmd/tpm/include/TpmProfile.h
+++ b/TPMCmd/tpm/include/TpmProfile.h
@@ -343,13 +343,13 @@
#define ALG_SHA512 ALG_NO
#endif
#ifndef ALG_SM2
-#define ALG_SM2 (ALG_YES && ALG_ECC)
+#define ALG_SM2 (ALG_NO && ALG_ECC)
#endif
#ifndef ALG_SM3_256
-#define ALG_SM3_256 ALG_YES
+#define ALG_SM3_256 ALG_NO
#endif
#ifndef ALG_SM4
-#define ALG_SM4 ALG_YES
+#define ALG_SM4 ALG_NO
#endif
#ifndef ALG_SYMCIPHER
#define ALG_SYMCIPHER ALG_YES
diff --git a/TPMCmd/tpm/include/Wolf/TpmToWolfHash.h b/TPMCmd/tpm/include/Wolf/TpmToWolfHash.h
index 1a20f6f..23d0cdd 100644
--- a/TPMCmd/tpm/include/Wolf/TpmToWolfHash.h
+++ b/TPMCmd/tpm/include/Wolf/TpmToWolfHash.h
@@ -52,6 +52,12 @@
#define WOLFSSL_SHA512
#endif
+#if ALG_SM3_256
+#undef ALG_SM3_256
+#define ALG_SM3_256 ALG_NO
+//#error "SM3 is not available"
+#endif
+
#include <wolfssl/wolfcrypt/sha.h>
#include <wolfssl/wolfcrypt/sha256.h>
#include <wolfssl/wolfcrypt/sha512.h>
diff --git a/TPMCmd/tpm/include/Wolf/TpmToWolfSym.h b/TPMCmd/tpm/include/Wolf/TpmToWolfSym.h
index a160d53..e91df2d 100644
--- a/TPMCmd/tpm/include/Wolf/TpmToWolfSym.h
+++ b/TPMCmd/tpm/include/Wolf/TpmToWolfSym.h
@@ -51,11 +51,15 @@
//** Links to the wolfCrypt AES code
//***************************************************************
#if ALG_SM4
-#error "SM4 is not available"
+#undef ALG_SM4
+#define ALG_SM4 ALG_NO
+//#error "SM4 is not available"
#endif
#if ALG_CAMELLIA
-#error "Camellia is not available"
+#undef ALG_CAMELLIA
+#define ALG_CAMELLIA ALG_NO
+//#error "Camellia is not available"
#endif
// Define the order of parameters to the library functions that do block encryption
diff --git a/TPMCmd/tpm/src/command/Attestation/CertifyX509.c b/TPMCmd/tpm/src/command/Attestation/CertifyX509.c
index 0f19289..8ed5602 100644
--- a/TPMCmd/tpm/src/command/Attestation/CertifyX509.c
+++ b/TPMCmd/tpm/src/command/Attestation/CertifyX509.c
@@ -77,9 +77,9 @@ TPM2_CertifyX509(
// 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
- stringRef certTBS[REF_COUNT] = {{0}};
+ stringRef certTBS[REF_COUNT] = {0};
#define ALLOWED_SEQUENCES (SUBJECT_PUBLIC_KEY_REF - SIGNATURE_REF)
- stringRef partial[ALLOWED_SEQUENCES] = {{0}};
+ stringRef partial[ALLOWED_SEQUENCES] = {0};
INT16 countOfSequences = 0;
INT16 i;
//
@@ -149,7 +149,7 @@ TPM2_CertifyX509(
// number of elements.
if((ctx.offset != ctx.size) || (countOfSequences < 3)
|| (countOfSequences > 4)
- || (certTBS[EXTENSIONS_REF].buf == NULL))
+ || (certTBS[EXTENSIONS_REF].buf == 0))
return TPM_RCS_VALUE + RC_CertifyX509_partialCertificate;
// Now that we know how many sequences there were, we can put them where they
// belong
diff --git a/TPMCmd/tpm/src/crypt/AlgorithmTests.c b/TPMCmd/tpm/src/crypt/AlgorithmTests.c
index 652cbb6..7120f0e 100644
--- a/TPMCmd/tpm/src/crypt/AlgorithmTests.c
+++ b/TPMCmd/tpm/src/crypt/AlgorithmTests.c
@@ -104,7 +104,7 @@ TestHash(
FOR_EACH_HASH(HASH_CASE_FOR_TEST)
default:
- FAIL(FATAL_ERROR_INTERNAL);
+ FAIL(FATAL_ERROR_INTERNAL);
}
// Clear the to-test bits
CLEAR_BOTH(hashAlg);
diff --git a/TPMCmd/tpm/src/crypt/CryptRsa.c b/TPMCmd/tpm/src/crypt/CryptRsa.c
index b42322f..1d8b1e9 100644
--- a/TPMCmd/tpm/src/crypt/CryptRsa.c
+++ b/TPMCmd/tpm/src/crypt/CryptRsa.c
@@ -563,7 +563,7 @@ RSAES_Decode(
// Make sure that pSize has not gone over the end and that there are at least 8
// bytes of pad data.
fail = (pSize > coded->size) | fail;
- fail = ((pSize - 2) < 8) | fail;
+ fail = ((pSize - 2) <= 8) | fail;
if((message->size < (UINT16)(coded->size - pSize)) || fail)
return TPM_RC_VALUE;
message->size = coded->size - pSize;
diff --git a/TPMCmd/tpm/src/main/ExecCommand.c b/TPMCmd/tpm/src/main/ExecCommand.c
index d7673c5..7e70632 100644
--- a/TPMCmd/tpm/src/main/ExecCommand.c
+++ b/TPMCmd/tpm/src/main/ExecCommand.c
@@ -62,7 +62,7 @@
// 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 BuildResponseSessions() to:
+// g) Calls BuildResponseSession() to:
// 1) when necessary, encrypt a parameter
// 2) build the response authorization sessions
// 3) update the audit sessions and nonces
diff --git a/TPMCmd/tpm/src/subsystem/NvDynamic.c b/TPMCmd/tpm/src/subsystem/NvDynamic.c
index eba52f6..81cbd43 100644
--- a/TPMCmd/tpm/src/subsystem/NvDynamic.c
+++ b/TPMCmd/tpm/src/subsystem/NvDynamic.c
@@ -129,13 +129,13 @@ NvNext(
// != 0 the next entry of the indicated type
static NV_REF
NvNextByType(
- TPM_HANDLE *handle, // OUT: the handle of the found type
+ TPM_HANDLE *handle, // OUT: the handle of the found type or 0
NV_REF *iter, // IN: the iterator
TPM_HT type // IN: the handle type to look for
)
{
NV_REF addr;
- TPM_HANDLE nvHandle;
+ TPM_HANDLE nvHandle = 0;
//
while((addr = NvNext(iter, &nvHandle)) != 0)
{