From 5e0fa6bbd21d3bd8a212280e6443079d0fb20052 Mon Sep 17 00:00:00 2001 From: Brian Telfer Date: Thu, 22 Feb 2018 00:08:02 +0000 Subject: Added support for wolfSSL Implements platform hooks to enable wolfcrypt as an alternative crypto engine. ECC, RSA, AES, and hashing is enabled and tested. Adds specific wolfSSL configurations to the TPM simulator project. --- .gitignore | 6 + README.md | 50 ++- TPMCmd/Platform/platform.vcxproj | 195 ++++++++ TPMCmd/Simulator/simulator.vcxproj | 177 ++++++++ TPMCmd/simulator.sln | 120 ++++- TPMCmd/tpm/Tpm.vcxproj | 257 ++++++++++- TPMCmd/tpm/Tpm.vcxproj.filters | 11 +- TPMCmd/tpm/include/Implementation.h | 8 +- TPMCmd/tpm/include/VendorString.h | 10 +- .../include/prototypes/TpmToWolfDesSupport_fp.h | 90 ++++ TPMCmd/tpm/include/prototypes/TpmToWolfMath_fp.h | 209 +++++++++ .../tpm/include/prototypes/TpmToWolfSupport_fp.h | 56 +++ TPMCmd/tpm/include/wolf/TpmToWolfHash.h | 4 +- TPMCmd/tpm/include/wolf/TpmToWolfMath.h | 69 +-- TPMCmd/tpm/include/wolf/TpmToWolfSym.h | 40 +- TPMCmd/tpm/include/wolf/user_settings.h | 42 -- TPMCmd/tpm/src/crypt/CryptEccMain.c | 6 +- TPMCmd/tpm/src/crypt/wolf/TpmToWolfDesSupport.c | 76 ++-- TPMCmd/tpm/src/crypt/wolf/TpmToWolfMath.c | 489 +++++++++------------ TPMCmd/tpm/src/crypt/wolf/TpmToWolfSupport.c | 33 +- TPMCmd/wolfcrypt/include/user_settings.h | 95 ++++ TPMCmd/wolfcrypt/wolfssl.vcxproj | 192 ++++++++ external/wolfssl | 2 +- 23 files changed, 1719 insertions(+), 518 deletions(-) create mode 100644 TPMCmd/tpm/include/prototypes/TpmToWolfDesSupport_fp.h create mode 100644 TPMCmd/tpm/include/prototypes/TpmToWolfMath_fp.h create mode 100644 TPMCmd/tpm/include/prototypes/TpmToWolfSupport_fp.h delete mode 100644 TPMCmd/tpm/include/wolf/user_settings.h create mode 100644 TPMCmd/wolfcrypt/include/user_settings.h create mode 100644 TPMCmd/wolfcrypt/wolfssl.vcxproj diff --git a/.gitignore b/.gitignore index 36b6a53..8c7210f 100644 --- a/.gitignore +++ b/.gitignore @@ -290,5 +290,11 @@ __pycache__/ # TPM simulator run-time/state files NVChip RsaKeyCacheCrt.data + +# Ossl support TPMCmd/OsslInclude/* TPMCmd/Lib/* + +# Wolf Build results +TPMCmd/WolfDebug/* +TPMCmd/WolfRelease/* diff --git a/README.md b/README.md index c0f7747..e81653a 100644 --- a/README.md +++ b/README.md @@ -1,22 +1,44 @@ +# MS TPM 2.0 Reference Implementation # + This is a Microsoft Visual Studio solution that contains reference implementation of the TPM 2.0 Specification by TCG available at https://trustedcomputinggroup.org/tpm-library-specification. See the TPMCmd/tpm/include/TpmTypes.h header for the exact revision/date of the TPM 2.0 specification issue, which the given source tree snapshot corresponds to. -Before building the solution: +## Before building the solution ## -1) Uncomment and update the definitions of the following macros in the TPMCmd/tpm/include/VendorString.h header: - - MANUFACTURER - - VENDOR_STRING_1 - - FIRMWARE_V1 and FIRMWARE_V2 - -2) Create TPMCmd/lib folder and place a static OpenSSL library (libeay32.lib or libcrypto.lib) there. This may be either complete static library, or import library accompanying the corresponding DLL. In the latter case you'll need to copy the OpenSSL DLL into the standard Windows search path, so that it was available when you run the simulator executable (e.g. copy it into the same folder where simulator.exe is located). - - If you use libcrypto.lib, you'll need to either update "Linker|Input|Additional Dependencies" property of the Tpm project in the simulator solution or, alternatively, rename libcrypto.lib to libeay32.lib. +1. Uncomment and update the definitions of the following macros in the TPMCmd/tpm/include/VendorString.h header: + - MANUFACTURER + - VENDOR_STRING_1 + - FIRMWARE_V1 and FIRMWARE_V2 + +2. Setup the cryptography platform the TPM will use for the underlying primitives: + +### OpenSSL library ### + +1. Create TPMCmd/lib folder and place a static OpenSSL library (libeay32.lib or libcrypto.lib) there. This may be either complete static library, or import library accompanying the corresponding DLL. In the latter case you'll need to copy the OpenSSL DLL into the standard Windows search path, so that it was available when you run the simulator executable (e.g. copy it into the same folder where simulator.exe is located). + + If you use libcrypto.lib, you'll need to either update "Linker|Input|Additional Dependencies" property of the Tpm project in the simulator solution or, alternatively, rename libcrypto.lib to libeay32.lib. - Recommended version of OpenSSL is 1.0.2d or higher. + Recommended version of OpenSSL is 1.0.2d 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). + + If you use OpenSSL 1.1, you'll additionally need to: + + - Copy the openssl/crypto/bn/bn_lcl.h header to the TPMCmd/OsslInclude/openssl folder; + - Create TPMCmd/OsslInclude/openssl/internal folder and copy there the contents of the openssl/crypto/include/internal folder (do not confuse it with the openssl/include/internal folder that need not be copied). + +2. Build the solution with either Debug or Release as the active configuration. + +### Wolfcrypt library (wolfSSL) ### + +1. WolfSSL is included as a submodule. Initialize and update the submodule to fetch the project and checkout the appropriate commit. + + > git submodule init + > git submodule update + + 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. -3) 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. Build the solution with either WolfDebug or WolfRelease as the active configuration. - If you use OpenSSL 1.1, you'll additionally need to: - - Copy the openssl/crypto/bn/bn_lcl.h header to the TPMCmd/OsslInclude/openssl folder; - - Create TPMCmd/OsslInclude/openssl/internal folder and copy there the contents of the openssl/crypto/include/internal folder (do not confuse it with the openssl/include/internal folder that need not be copied). + > msbuild TPMCmd\simulator.sln /p:Configuration=WolfDebug \ No newline at end of file diff --git a/TPMCmd/Platform/platform.vcxproj b/TPMCmd/Platform/platform.vcxproj index 7284d14..06d8fb0 100644 --- a/TPMCmd/Platform/platform.vcxproj +++ b/TPMCmd/Platform/platform.vcxproj @@ -65,6 +65,22 @@ Static x64 + + WolfDebug + Win32 + + + WolfDebug + x64 + + + WolfRelease + Win32 + + + WolfRelease + x64 + @@ -96,17 +112,34 @@ true v141 + + StaticLibrary + Unicode + true + v141 + DynamicLibrary Unicode false v141 + + DynamicLibrary + Unicode + false + v141 + StaticLibrary Unicode v141 + + StaticLibrary + Unicode + v141 + Makefile Unicode @@ -137,6 +170,11 @@ Unicode v141 + + DynamicLibrary + Unicode + v141 + DynamicLibrary Unicode @@ -175,12 +213,21 @@ + + + + + + + + + @@ -199,6 +246,9 @@ + + + @@ -218,68 +268,86 @@ <_ProjectFileVersion>10.0.30319.1 $(SolutionDir)\$(Configuration)\ + $(SolutionDir)\$(Configuration)\ $(SolutionDir)\$(Configuration)\ bin\$(PlatformTarget)\$(Configuration)\ $(Configuration)\ bin\$(PlatformTarget)\$(Configuration)\ bin\$(PlatformTarget)\$(Configuration)\ $(SolutionDir)\bin\$(ProjectName)\$(PlatformTarget)\$(Configuration)\ + $(SolutionDir)\bin\$(ProjectName)\$(PlatformTarget)\$(Configuration)\ $(SolutionDir)\bin\$(ProjectName)\$(PlatformTarget)\$(Configuration)\ bin\obj\$(PlatformTarget)\$(Configuration)\ bin\obj\$(PlatformTarget)\$(Configuration)\ bin\obj\$(PlatformTarget)\$(Configuration)\ bin\obj\$(PlatformTarget)\$(Configuration)\ $(SolutionDir)\$(Configuration)\ + $(SolutionDir)\$(Configuration)\ $(SolutionDir)\bin\$(ProjectName)\$(PlatformTarget)\$(Configuration)\ + $(SolutionDir)\bin\$(ProjectName)\$(PlatformTarget)\$(Configuration)\ AllRules.ruleset + AllRules.ruleset AllRules.ruleset AllRules.ruleset AllRules.ruleset AllRules.ruleset AllRules.ruleset AllRules.ruleset + AllRules.ruleset AllRules.ruleset AllRules.ruleset AllRules.ruleset AllRules.ruleset AllRules.ruleset + + + + AllRules.ruleset + AllRules.ruleset AllRules.ruleset + AllRules.ruleset + + + + .lib + .lib .dll .lib .dll .dll .dll .dll + .dll .dll .dll .dll @@ -290,6 +358,9 @@ true + + true + true $(SolutionDir)GccCompile\GccCompile.pl $(ProjectDir)$(ProjectFileName) $(SolutionDir)$(SolutionFileName) @@ -310,6 +381,10 @@ false .lib + + false + .lib + bin\$(PlatformTarget)\$(Configuration)\ bin\obj\$(PlatformTarget)\$(Configuration)\ @@ -318,6 +393,10 @@ bin\$(PlatformTarget)\$(Configuration)\ bin\obj\$(PlatformTarget)\$(Configuration)\ + + bin\$(PlatformTarget)\$(Configuration)\ + bin\obj\$(PlatformTarget)\$(Configuration)\ + bin\$(PlatformTarget)\$(Configuration)\ bin\obj\$(PlatformTarget)\$(Configuration)\ @@ -334,6 +413,10 @@ bin\$(PlatformTarget)\$(Configuration)\ bin\obj\$(PlatformTarget)\$(Configuration)\ + + bin\$(PlatformTarget)\$(Configuration)\ + bin\obj\$(PlatformTarget)\$(Configuration)\ + bin\$(PlatformTarget)\$(Configuration)\ bin\obj\$(PlatformTarget)\$(Configuration)\ @@ -395,6 +478,50 @@ + + + Disabled + $(ProjectDir)\include;$(ProjectDir)\include\prototypes;$(SolutionDir)\tpm\include;$(SolutionDir)\tpm\include\prototypes + WIN32;DEBUG;_LIB;%(PreprocessorDefinitions) + false + EnableFastChecks + MultiThreadedDebugDLL + NotUsing + Level3 + ProgramDatabase + CompileAsC + 4820;4668 + Default + true + + + + + true + $(OutDir)$(TargetName)$(TargetExt) + %(AdditionalDependencies) + false + true + $(OutDir)Platform.map + + + $(OutDir)$(TargetName)$(TargetExt) + + + $(ProjectDir)\lib;$(OutDir); + + + + + + + true + + + + + + Disabled @@ -606,6 +733,36 @@ $(ProjectDir)\platform\platform.def + + + Disabled + $(ProjectDir)\include;$(ProjectDir)\include\prototypes;$(SolutionDir)\tpm\include;$(SolutionDir)\tpm\include\prototypes + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + EnableFastChecks + MultiThreadedDebugDLL + + + EnableAllWarnings + ProgramDatabase + CompileAsC + 4820;4668 + Default + + + + + true + + + $(OutDir)$(TargetName)$(TargetExt) + + + $(ProjectDir)\lib;$(OutDir); + + + $(ProjectDir)\platform\platform.def + + Disabled @@ -775,6 +932,25 @@ tpm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + MaxSpeed + true + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + MultiThreadedDLL + true + NotUsing + Level3 + ProgramDatabase + $(ProjectDir)\include;$(ProjectDir)\include\prototypes;$(SolutionDir)\tpm\include;$(SolutionDir)\tpm\include\prototypes + + + + + $(OutDir)$(TargetName)$(TargetExt) + tpm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + MaxSpeed @@ -794,6 +970,25 @@ kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib + + + MaxSpeed + true + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + MultiThreadedDLL + true + + + Level3 + ProgramDatabase + $(ProjectDir)\include;$(ProjectDir)\include\prototypes;$(SolutionDir)\tpm\include;$(SolutionDir)\tpm\include\prototypes + + + + + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib + + GCC diff --git a/TPMCmd/Simulator/simulator.vcxproj b/TPMCmd/Simulator/simulator.vcxproj index 5b022d6..a46b805 100644 --- a/TPMCmd/Simulator/simulator.vcxproj +++ b/TPMCmd/Simulator/simulator.vcxproj @@ -65,6 +65,22 @@ Static x64 + + WolfDebug + Win32 + + + WolfDebug + x64 + + + WolfRelease + Win32 + + + WolfRelease + x64 + {AAB9FA21-8671-4792-B000-B40A526058AD} @@ -80,17 +96,34 @@ false v141 + + Application + Unicode + false + v141 + Application Unicode false v141 + + Application + Unicode + false + v141 + Application Unicode v141 + + Application + Unicode + v141 + Makefile Unicode @@ -121,6 +154,11 @@ Unicode v141 + + Application + Unicode + v141 + Application Unicode @@ -159,12 +197,21 @@ + + + + + + + + + @@ -183,6 +230,9 @@ + + + @@ -202,75 +252,95 @@ <_ProjectFileVersion>10.0.30319.1 $(SolutionDir)\$(Configuration)\ + $(SolutionDir)\$(Configuration)\ $(SolutionDir)\$(Configuration)\ bin\$(PlatformTarget)\$(Configuration)\ $(Configuration)\ bin\$(PlatformTarget)\$(Configuration)\ bin\$(PlatformTarget)\$(Configuration)\ $(SolutionDir)\bin\$(ProjectName)\$(PlatformTarget)\$(Configuration)\ + $(SolutionDir)\bin\$(ProjectName)\$(PlatformTarget)\$(Configuration)\ $(SolutionDir)\bin\$(ProjectName)\$(PlatformTarget)\$(Configuration)\ bin\obj\$(PlatformTarget)\$(Configuration)\ bin\obj\$(PlatformTarget)\$(Configuration)\ bin\obj\$(PlatformTarget)\$(Configuration)\ bin\obj\$(PlatformTarget)\$(Configuration)\ true + true true true true false false true + true true true true true true $(SolutionDir)\$(Configuration)\ + $(SolutionDir)\$(Configuration)\ $(SolutionDir)\bin\$(ProjectName)\$(PlatformTarget)\$(Configuration)\ + $(SolutionDir)\bin\$(ProjectName)\$(PlatformTarget)\$(Configuration)\ false + false false + false AllRules.ruleset + AllRules.ruleset AllRules.ruleset AllRules.ruleset AllRules.ruleset AllRules.ruleset AllRules.ruleset AllRules.ruleset + AllRules.ruleset AllRules.ruleset AllRules.ruleset AllRules.ruleset AllRules.ruleset AllRules.ruleset + + + + AllRules.ruleset + AllRules.ruleset AllRules.ruleset + AllRules.ruleset + + + + bin\$(PlatformTarget)\$(Configuration)\ @@ -280,6 +350,10 @@ bin\$(PlatformTarget)\$(Configuration)\ bin\obj\$(PlatformTarget)\$(Configuration)\ + + bin\$(PlatformTarget)\$(Configuration)\ + bin\obj\$(PlatformTarget)\$(Configuration)\ + bin\$(PlatformTarget)\$(Configuration)\ bin\obj\$(PlatformTarget)\$(Configuration)\ @@ -296,6 +370,10 @@ bin\$(PlatformTarget)\$(Configuration)\ bin\obj\$(PlatformTarget)\$(Configuration)\ + + bin\$(PlatformTarget)\$(Configuration)\ + bin\obj\$(PlatformTarget)\$(Configuration)\ + bin\$(PlatformTarget)\$(Configuration)\ bin\obj\$(PlatformTarget)\$(Configuration)\ @@ -313,6 +391,9 @@ false + + false + Disabled @@ -342,6 +423,35 @@ true + + + Disabled + $(ProjectDir)include\;$(ProjectDir)include\prototypes;$(SolutionDir)tpm\include\;$(SolutionDir)tpm\include\prototypes;$(SolutionDir)platform\include\;$(SolutionDir)platform\include\prototypes + WIN32;DEBUG;_CONSOLE;%(PreprocessorDefinitions);_DIAGNOSTICS + true + EnableFastChecks + MultiThreadedDebugDLL + NotUsing + Level3 + ProgramDatabase + CompileAsC + true + + + tpm.lib;platform.lib;Ws2_32.lib;Rpcrt4.lib;%(AdditionalDependencies) + $(ProjectDir)\lib;$(OutDir);%(AdditionalLibraryDirectories) + true + Console + MachineX86 + $(OutDir)$(TargetName)$(TargetExt) + false + $(OutDir)Simulator.map + false + + + true + + Disabled @@ -486,6 +596,25 @@ Console + + + Disabled + $(ProjectDir)include\;$(ProjectDir)include\prototypes;$(SolutionDir)tpm\include\;$(SolutionDir)tpm\include\prototypes;$(SolutionDir)platform\include\;$(SolutionDir)platform\include\prototypes + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions);_DIAGNOSTICS + EnableFastChecks + MultiThreadedDebugDLL + + + Level3 + ProgramDatabase + + + tpm.lib;platform.lib;Ws2_32.lib;Rpcrt4.lib;%(AdditionalDependencies) + $(ProjectDir)\lib;$(OutDir);%(AdditionalLibraryDirectories) + true + Console + + Disabled @@ -604,6 +733,29 @@ $(OutDir)$(TargetName)$(TargetExt) + + + MaxSpeed + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + MultiThreadedDLL + true + NotUsing + Level3 + ProgramDatabase + $(ProjectDir)include\;$(ProjectDir)include\prototypes;$(SolutionDir)tpm\include\;$(SolutionDir)tpm\include\prototypes;$(SolutionDir)platform\include\;$(SolutionDir)platform\include\prototypes + + + true + Console + true + true + MachineX86 + tpm.lib;platform.lib;Ws2_32.lib;Rpcrt4.lib;%(AdditionalDependencies) + $(ProjectDir)\lib;$(OutDir);%(AdditionalLibraryDirectories) + $(OutDir)$(TargetName)$(TargetExt) + + MaxSpeed @@ -629,6 +781,31 @@ false + + + MaxSpeed + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + MultiThreadedDLL + true + + + Level3 + ProgramDatabase + $(ProjectDir)include\;$(ProjectDir)include\prototypes;$(SolutionDir)tpm\include\;$(SolutionDir)tpm\include\prototypes;$(SolutionDir)platform\include\;$(SolutionDir)platform\include\prototypes + + + true + Console + true + true + tpm.lib;platform.lib;Ws2_32.lib;Rpcrt4.lib + $(ProjectDir)\lib;$(OutDir);%(AdditionalLibraryDirectories) + + + false + + GCC diff --git a/TPMCmd/simulator.sln b/TPMCmd/simulator.sln index 465bfb1..c359d47 100644 --- a/TPMCmd/simulator.sln +++ b/TPMCmd/simulator.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -VisualStudioVersion = 14.0.23107.0 +# Visual Studio 15 +VisualStudioVersion = 15.0.27004.2002 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Simulator", "simulator\simulator.vcxproj", "{AAB9FA21-8671-4792-B000-B40A526058AD}" ProjectSection(ProjectDependencies) = postProject @@ -11,11 +11,16 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Simulator", "simulator\simu EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Platform", "Platform\platform.vcxproj", "{A9249F05-0DF5-4D06-9873-FBBE61B6768B}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Tpm", "Tpm\TPM.vcxproj", "{B7456491-A2ED-4B1C-B59E-41C7B32B7E3B}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Tpm", "tpm\TPM.vcxproj", "{B7456491-A2ED-4B1C-B59E-41C7B32B7E3B}" ProjectSection(ProjectDependencies) = postProject {A9249F05-0DF5-4D06-9873-FBBE61B6768B} = {A9249F05-0DF5-4D06-9873-FBBE61B6768B} + {73973223-5EE8-41CA-8E88-1D60E89A237B} = {73973223-5EE8-41CA-8E88-1D60E89A237B} EndProjectSection EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Crypt", "Crypt", "{26AD7978-27E2-46E7-9F8C-36CDB1B5AB01}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "wolfssl", "wolfcrypt\wolfssl.vcxproj", "{73973223-5EE8-41CA-8E88-1D60E89A237B}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Coverage|Win32 = Coverage|Win32 @@ -39,6 +44,12 @@ Global Static|Win32 = Static|Win32 Static|x64 = Static|x64 Static|Xbox 360 = Static|Xbox 360 + WolfDebug|Win32 = WolfDebug|Win32 + WolfDebug|x64 = WolfDebug|x64 + WolfDebug|Xbox 360 = WolfDebug|Xbox 360 + WolfRelease|Win32 = WolfRelease|Win32 + WolfRelease|x64 = WolfRelease|x64 + WolfRelease|Xbox 360 = WolfRelease|Xbox 360 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {AAB9FA21-8671-4792-B000-B40A526058AD}.Coverage|Win32.ActiveCfg = Coverage|Win32 @@ -62,8 +73,8 @@ Global {AAB9FA21-8671-4792-B000-B40A526058AD}.Profile|Xbox 360.ActiveCfg = Profile|Win32 {AAB9FA21-8671-4792-B000-B40A526058AD}.Release|Win32.ActiveCfg = Release|Win32 {AAB9FA21-8671-4792-B000-B40A526058AD}.Release|Win32.Build.0 = Release|Win32 - {AAB9FA21-8671-4792-B000-B40A526058AD}.Release|x64.ActiveCfg = Release|x64 - {AAB9FA21-8671-4792-B000-B40A526058AD}.Release|x64.Build.0 = Release|x64 + {AAB9FA21-8671-4792-B000-B40A526058AD}.Release|x64.ActiveCfg = WolfRelease|x64 + {AAB9FA21-8671-4792-B000-B40A526058AD}.Release|x64.Build.0 = WolfRelease|x64 {AAB9FA21-8671-4792-B000-B40A526058AD}.Release|Xbox 360.ActiveCfg = Release|Win32 {AAB9FA21-8671-4792-B000-B40A526058AD}.SelfTest|Win32.ActiveCfg = SelfTest|Win32 {AAB9FA21-8671-4792-B000-B40A526058AD}.SelfTest|Win32.Build.0 = SelfTest|Win32 @@ -75,6 +86,16 @@ Global {AAB9FA21-8671-4792-B000-B40A526058AD}.Static|x64.ActiveCfg = Static|x64 {AAB9FA21-8671-4792-B000-B40A526058AD}.Static|x64.Build.0 = Static|x64 {AAB9FA21-8671-4792-B000-B40A526058AD}.Static|Xbox 360.ActiveCfg = Static|Win32 + {AAB9FA21-8671-4792-B000-B40A526058AD}.WolfDebug|Win32.ActiveCfg = WolfDebug|Win32 + {AAB9FA21-8671-4792-B000-B40A526058AD}.WolfDebug|Win32.Build.0 = WolfDebug|Win32 + {AAB9FA21-8671-4792-B000-B40A526058AD}.WolfDebug|x64.ActiveCfg = WolfDebug|x64 + {AAB9FA21-8671-4792-B000-B40A526058AD}.WolfDebug|x64.Build.0 = WolfDebug|x64 + {AAB9FA21-8671-4792-B000-B40A526058AD}.WolfDebug|Xbox 360.ActiveCfg = WolfDebug|Win32 + {AAB9FA21-8671-4792-B000-B40A526058AD}.WolfRelease|Win32.ActiveCfg = WolfRelease|Win32 + {AAB9FA21-8671-4792-B000-B40A526058AD}.WolfRelease|Win32.Build.0 = WolfRelease|Win32 + {AAB9FA21-8671-4792-B000-B40A526058AD}.WolfRelease|x64.ActiveCfg = WolfRelease|x64 + {AAB9FA21-8671-4792-B000-B40A526058AD}.WolfRelease|x64.Build.0 = WolfRelease|x64 + {AAB9FA21-8671-4792-B000-B40A526058AD}.WolfRelease|Xbox 360.ActiveCfg = WolfDebug|Win32 {A9249F05-0DF5-4D06-9873-FBBE61B6768B}.Coverage|Win32.ActiveCfg = Coverage|Win32 {A9249F05-0DF5-4D06-9873-FBBE61B6768B}.Coverage|Win32.Build.0 = Coverage|Win32 {A9249F05-0DF5-4D06-9873-FBBE61B6768B}.Coverage|x64.ActiveCfg = Coverage|x64 @@ -96,8 +117,8 @@ Global {A9249F05-0DF5-4D06-9873-FBBE61B6768B}.Profile|Xbox 360.ActiveCfg = Profile|Win32 {A9249F05-0DF5-4D06-9873-FBBE61B6768B}.Release|Win32.ActiveCfg = Release|Win32 {A9249F05-0DF5-4D06-9873-FBBE61B6768B}.Release|Win32.Build.0 = Release|Win32 - {A9249F05-0DF5-4D06-9873-FBBE61B6768B}.Release|x64.ActiveCfg = Release|x64 - {A9249F05-0DF5-4D06-9873-FBBE61B6768B}.Release|x64.Build.0 = Release|x64 + {A9249F05-0DF5-4D06-9873-FBBE61B6768B}.Release|x64.ActiveCfg = WolfRelease|x64 + {A9249F05-0DF5-4D06-9873-FBBE61B6768B}.Release|x64.Build.0 = WolfRelease|x64 {A9249F05-0DF5-4D06-9873-FBBE61B6768B}.Release|Xbox 360.ActiveCfg = Release|Win32 {A9249F05-0DF5-4D06-9873-FBBE61B6768B}.SelfTest|Win32.ActiveCfg = SelfTest|Win32 {A9249F05-0DF5-4D06-9873-FBBE61B6768B}.SelfTest|Win32.Build.0 = SelfTest|Win32 @@ -109,6 +130,20 @@ Global {A9249F05-0DF5-4D06-9873-FBBE61B6768B}.Static|x64.ActiveCfg = Static|x64 {A9249F05-0DF5-4D06-9873-FBBE61B6768B}.Static|x64.Build.0 = Static|x64 {A9249F05-0DF5-4D06-9873-FBBE61B6768B}.Static|Xbox 360.ActiveCfg = Static|Win32 + {A9249F05-0DF5-4D06-9873-FBBE61B6768B}.WolfDebug|Win32.ActiveCfg = WolfDebug|Win32 + {A9249F05-0DF5-4D06-9873-FBBE61B6768B}.WolfDebug|Win32.Build.0 = WolfDebug|Win32 + {A9249F05-0DF5-4D06-9873-FBBE61B6768B}.WolfDebug|x64.ActiveCfg = WolfDebug|x64 + {A9249F05-0DF5-4D06-9873-FBBE61B6768B}.WolfDebug|x64.Build.0 = WolfDebug|x64 + {A9249F05-0DF5-4D06-9873-FBBE61B6768B}.WolfDebug|x64.Deploy.0 = WolfDebug|x64 + {A9249F05-0DF5-4D06-9873-FBBE61B6768B}.WolfDebug|Xbox 360.ActiveCfg = GCC Debug|Win32 + {A9249F05-0DF5-4D06-9873-FBBE61B6768B}.WolfDebug|Xbox 360.Deploy.0 = GCC Debug|Win32 + {A9249F05-0DF5-4D06-9873-FBBE61B6768B}.WolfRelease|Win32.ActiveCfg = WolfRelease|Win32 + {A9249F05-0DF5-4D06-9873-FBBE61B6768B}.WolfRelease|Win32.Build.0 = WolfRelease|Win32 + {A9249F05-0DF5-4D06-9873-FBBE61B6768B}.WolfRelease|x64.ActiveCfg = WolfRelease|x64 + {A9249F05-0DF5-4D06-9873-FBBE61B6768B}.WolfRelease|x64.Build.0 = WolfRelease|x64 + {A9249F05-0DF5-4D06-9873-FBBE61B6768B}.WolfRelease|x64.Deploy.0 = WolfRelease|x64 + {A9249F05-0DF5-4D06-9873-FBBE61B6768B}.WolfRelease|Xbox 360.ActiveCfg = GCC Debug|Win32 + {A9249F05-0DF5-4D06-9873-FBBE61B6768B}.WolfRelease|Xbox 360.Deploy.0 = GCC Debug|Win32 {B7456491-A2ED-4B1C-B59E-41C7B32B7E3B}.Coverage|Win32.ActiveCfg = Coverage|Win32 {B7456491-A2ED-4B1C-B59E-41C7B32B7E3B}.Coverage|Win32.Build.0 = Coverage|Win32 {B7456491-A2ED-4B1C-B59E-41C7B32B7E3B}.Coverage|x64.ActiveCfg = Coverage|x64 @@ -130,8 +165,8 @@ Global {B7456491-A2ED-4B1C-B59E-41C7B32B7E3B}.Profile|Xbox 360.ActiveCfg = Profile|Win32 {B7456491-A2ED-4B1C-B59E-41C7B32B7E3B}.Release|Win32.ActiveCfg = Release|Win32 {B7456491-A2ED-4B1C-B59E-41C7B32B7E3B}.Release|Win32.Build.0 = Release|Win32 - {B7456491-A2ED-4B1C-B59E-41C7B32B7E3B}.Release|x64.ActiveCfg = Release|x64 - {B7456491-A2ED-4B1C-B59E-41C7B32B7E3B}.Release|x64.Build.0 = Release|x64 + {B7456491-A2ED-4B1C-B59E-41C7B32B7E3B}.Release|x64.ActiveCfg = WolfRelease|x64 + {B7456491-A2ED-4B1C-B59E-41C7B32B7E3B}.Release|x64.Build.0 = WolfRelease|x64 {B7456491-A2ED-4B1C-B59E-41C7B32B7E3B}.Release|Xbox 360.ActiveCfg = Release|Win32 {B7456491-A2ED-4B1C-B59E-41C7B32B7E3B}.SelfTest|Win32.ActiveCfg = SelfTest|Win32 {B7456491-A2ED-4B1C-B59E-41C7B32B7E3B}.SelfTest|Win32.Build.0 = SelfTest|Win32 @@ -143,8 +178,75 @@ Global {B7456491-A2ED-4B1C-B59E-41C7B32B7E3B}.Static|x64.ActiveCfg = Static|x64 {B7456491-A2ED-4B1C-B59E-41C7B32B7E3B}.Static|x64.Build.0 = Static|x64 {B7456491-A2ED-4B1C-B59E-41C7B32B7E3B}.Static|Xbox 360.ActiveCfg = Static|Win32 + {B7456491-A2ED-4B1C-B59E-41C7B32B7E3B}.WolfDebug|Win32.ActiveCfg = WolfDebug|Win32 + {B7456491-A2ED-4B1C-B59E-41C7B32B7E3B}.WolfDebug|Win32.Build.0 = WolfDebug|Win32 + {B7456491-A2ED-4B1C-B59E-41C7B32B7E3B}.WolfDebug|x64.ActiveCfg = WolfDebug|x64 + {B7456491-A2ED-4B1C-B59E-41C7B32B7E3B}.WolfDebug|x64.Build.0 = WolfDebug|x64 + {B7456491-A2ED-4B1C-B59E-41C7B32B7E3B}.WolfDebug|Xbox 360.ActiveCfg = WolfDebug|Win32 + {B7456491-A2ED-4B1C-B59E-41C7B32B7E3B}.WolfRelease|Win32.ActiveCfg = WolfRelease|Win32 + {B7456491-A2ED-4B1C-B59E-41C7B32B7E3B}.WolfRelease|Win32.Build.0 = WolfRelease|Win32 + {B7456491-A2ED-4B1C-B59E-41C7B32B7E3B}.WolfRelease|x64.ActiveCfg = WolfRelease|x64 + {B7456491-A2ED-4B1C-B59E-41C7B32B7E3B}.WolfRelease|x64.Build.0 = WolfRelease|x64 + {B7456491-A2ED-4B1C-B59E-41C7B32B7E3B}.WolfRelease|Xbox 360.ActiveCfg = WolfRelease|Win32 + {73973223-5EE8-41CA-8E88-1D60E89A237B}.Coverage|Win32.ActiveCfg = Coverage|Win32 + {73973223-5EE8-41CA-8E88-1D60E89A237B}.Coverage|x64.ActiveCfg = Coverage|x64 + {73973223-5EE8-41CA-8E88-1D60E89A237B}.Coverage|x64.Deploy.0 = Coverage|x64 + {73973223-5EE8-41CA-8E88-1D60E89A237B}.Coverage|Xbox 360.ActiveCfg = Coverage|Win32 + {73973223-5EE8-41CA-8E88-1D60E89A237B}.Debug|Win32.ActiveCfg = WolfDebug|Win32 + {73973223-5EE8-41CA-8E88-1D60E89A237B}.Debug|x64.ActiveCfg = WolfDebug|x64 + {73973223-5EE8-41CA-8E88-1D60E89A237B}.Debug|Xbox 360.ActiveCfg = WolfRelease|Win32 + {73973223-5EE8-41CA-8E88-1D60E89A237B}.Debug|Xbox 360.Deploy.0 = WolfRelease|Win32 + {73973223-5EE8-41CA-8E88-1D60E89A237B}.GccCompile|Win32.ActiveCfg = WolfRelease|Win32 + {73973223-5EE8-41CA-8E88-1D60E89A237B}.GccCompile|Win32.Deploy.0 = WolfRelease|Win32 + {73973223-5EE8-41CA-8E88-1D60E89A237B}.GccCompile|x64.ActiveCfg = WolfRelease|x64 + {73973223-5EE8-41CA-8E88-1D60E89A237B}.GccCompile|x64.Deploy.0 = WolfRelease|x64 + {73973223-5EE8-41CA-8E88-1D60E89A237B}.GccCompile|Xbox 360.ActiveCfg = WolfRelease|Win32 + {73973223-5EE8-41CA-8E88-1D60E89A237B}.GccCompile|Xbox 360.Deploy.0 = WolfRelease|Win32 + {73973223-5EE8-41CA-8E88-1D60E89A237B}.Profile|Win32.ActiveCfg = WolfRelease|Win32 + {73973223-5EE8-41CA-8E88-1D60E89A237B}.Profile|Win32.Deploy.0 = WolfRelease|Win32 + {73973223-5EE8-41CA-8E88-1D60E89A237B}.Profile|x64.ActiveCfg = WolfRelease|x64 + {73973223-5EE8-41CA-8E88-1D60E89A237B}.Profile|x64.Deploy.0 = WolfRelease|x64 + {73973223-5EE8-41CA-8E88-1D60E89A237B}.Profile|Xbox 360.ActiveCfg = WolfRelease|Win32 + {73973223-5EE8-41CA-8E88-1D60E89A237B}.Profile|Xbox 360.Deploy.0 = WolfRelease|Win32 + {73973223-5EE8-41CA-8E88-1D60E89A237B}.Release|Win32.ActiveCfg = WolfRelease|Win32 + {73973223-5EE8-41CA-8E88-1D60E89A237B}.Release|x64.ActiveCfg = WolfRelease|x64 + {73973223-5EE8-41CA-8E88-1D60E89A237B}.Release|x64.Build.0 = WolfRelease|x64 + {73973223-5EE8-41CA-8E88-1D60E89A237B}.Release|Xbox 360.ActiveCfg = WolfRelease|Win32 + {73973223-5EE8-41CA-8E88-1D60E89A237B}.Release|Xbox 360.Deploy.0 = WolfRelease|Win32 + {73973223-5EE8-41CA-8E88-1D60E89A237B}.SelfTest|Win32.ActiveCfg = WolfRelease|Win32 + {73973223-5EE8-41CA-8E88-1D60E89A237B}.SelfTest|Win32.Deploy.0 = WolfRelease|Win32 + {73973223-5EE8-41CA-8E88-1D60E89A237B}.SelfTest|x64.ActiveCfg = WolfRelease|x64 + {73973223-5EE8-41CA-8E88-1D60E89A237B}.SelfTest|x64.Deploy.0 = WolfRelease|x64 + {73973223-5EE8-41CA-8E88-1D60E89A237B}.SelfTest|Xbox 360.ActiveCfg = WolfRelease|Win32 + {73973223-5EE8-41CA-8E88-1D60E89A237B}.SelfTest|Xbox 360.Deploy.0 = WolfRelease|Win32 + {73973223-5EE8-41CA-8E88-1D60E89A237B}.Static|Win32.ActiveCfg = WolfRelease|Win32 + {73973223-5EE8-41CA-8E88-1D60E89A237B}.Static|Win32.Deploy.0 = WolfRelease|Win32 + {73973223-5EE8-41CA-8E88-1D60E89A237B}.Static|x64.ActiveCfg = WolfRelease|x64 + {73973223-5EE8-41CA-8E88-1D60E89A237B}.Static|x64.Deploy.0 = WolfRelease|x64 + {73973223-5EE8-41CA-8E88-1D60E89A237B}.Static|Xbox 360.ActiveCfg = WolfRelease|Win32 + {73973223-5EE8-41CA-8E88-1D60E89A237B}.Static|Xbox 360.Deploy.0 = WolfRelease|Win32 + {73973223-5EE8-41CA-8E88-1D60E89A237B}.WolfDebug|Win32.ActiveCfg = WolfDebug|Win32 + {73973223-5EE8-41CA-8E88-1D60E89A237B}.WolfDebug|Win32.Build.0 = WolfDebug|Win32 + {73973223-5EE8-41CA-8E88-1D60E89A237B}.WolfDebug|x64.ActiveCfg = WolfDebug|x64 + {73973223-5EE8-41CA-8E88-1D60E89A237B}.WolfDebug|x64.Build.0 = WolfDebug|x64 + {73973223-5EE8-41CA-8E88-1D60E89A237B}.WolfDebug|Xbox 360.ActiveCfg = Coverage|Win32 + {73973223-5EE8-41CA-8E88-1D60E89A237B}.WolfDebug|Xbox 360.Deploy.0 = Coverage|Win32 + {73973223-5EE8-41CA-8E88-1D60E89A237B}.WolfRelease|Win32.ActiveCfg = WolfRelease|Win32 + {73973223-5EE8-41CA-8E88-1D60E89A237B}.WolfRelease|Win32.Build.0 = WolfRelease|Win32 + {73973223-5EE8-41CA-8E88-1D60E89A237B}.WolfRelease|Win32.Deploy.0 = WolfRelease|Win32 + {73973223-5EE8-41CA-8E88-1D60E89A237B}.WolfRelease|x64.ActiveCfg = WolfRelease|x64 + {73973223-5EE8-41CA-8E88-1D60E89A237B}.WolfRelease|x64.Build.0 = WolfRelease|x64 + {73973223-5EE8-41CA-8E88-1D60E89A237B}.WolfRelease|x64.Deploy.0 = WolfRelease|x64 + {73973223-5EE8-41CA-8E88-1D60E89A237B}.WolfRelease|Xbox 360.ActiveCfg = Coverage|Win32 + {73973223-5EE8-41CA-8E88-1D60E89A237B}.WolfRelease|Xbox 360.Deploy.0 = Coverage|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {73973223-5EE8-41CA-8E88-1D60E89A237B} = {26AD7978-27E2-46E7-9F8C-36CDB1B5AB01} + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {C15EF5ED-F2C1-4785-A9C2-A2D213A367F7} + EndGlobalSection EndGlobal diff --git a/TPMCmd/tpm/Tpm.vcxproj b/TPMCmd/tpm/Tpm.vcxproj index 8633a2f..21096d4 100644 --- a/TPMCmd/tpm/Tpm.vcxproj +++ b/TPMCmd/tpm/Tpm.vcxproj @@ -57,6 +57,22 @@ Static x64 + + WolfDebug + Win32 + + + WolfDebug + x64 + + + WolfRelease + Win32 + + + WolfRelease + x64 + Tpm @@ -72,11 +88,22 @@ false v141 + + DynamicLibrary + Unicode + false + v141 + DynamicLibrary Unicode v141 + + DynamicLibrary + Unicode + v141 + StaticLibrary Unicode @@ -103,11 +130,22 @@ false v141 + + DynamicLibrary + Unicode + false + v141 + DynamicLibrary Unicode v141 + + DynamicLibrary + Unicode + v141 + DynamicLibrary Unicode @@ -141,9 +179,15 @@ + + + + + + @@ -159,9 +203,15 @@ + + + + + + @@ -178,90 +228,119 @@ <_ProjectFileVersion>10.0.30319.1 .\Debug;$(ReferencePath) + .\Debug;$(ReferencePath) .\Debug;$(ReferencePath) .\Debug;$(ReferencePath) .\Debug;$(ReferencePath) .\Debug;$(ReferencePath) $(SolutionDir)\$(Configuration)\ + $(SolutionDir)\$(Configuration)\ bin\$(PlatformTarget)\$(Configuration)\ $(Configuration)\ bin\$(PlatformTarget)\$(Configuration)\ bin\$(PlatformTarget)\$(Configuration)\ $(SolutionDir)\bin\$(ProjectName)\$(PlatformTarget)\$(Configuration)\ + $(SolutionDir)\bin\$(ProjectName)\$(PlatformTarget)\$(Configuration)\ bin\obj\$(PlatformTarget)\$(Configuration)\ bin\obj\$(PlatformTarget)\$(Configuration)\ bin\obj\$(PlatformTarget)\$(Configuration)\ bin\obj\$(PlatformTarget)\$(Configuration)\ true + true true true false false .\Debug;$(ReferencePath) + .\Debug;$(ReferencePath) .\Debug;$(ReferencePath) .\Debug;$(ReferencePath) .\Debug;$(ReferencePath) .\Debug;$(ReferencePath) bin\$(PlatformTarget)\$(Configuration)\ + bin\$(PlatformTarget)\$(Configuration)\ bin\$(PlatformTarget)\$(Configuration)\ bin\$(PlatformTarget)\$(Configuration)\ bin\$(PlatformTarget)\$(Configuration)\ bin\$(PlatformTarget)\$(Configuration)\ bin\obj\$(PlatformTarget)\$(Configuration)\ + bin\obj\$(PlatformTarget)\$(Configuration)\ bin\obj\$(PlatformTarget)\$(Configuration)\ bin\obj\$(PlatformTarget)\$(Configuration)\ bin\obj\$(PlatformTarget)\$(Configuration)\ bin\obj\$(PlatformTarget)\$(Configuration)\ true + true true true true true .\Debug;$(ReferencePath) + .\Debug;$(ReferencePath) $(SolutionDir)\$(Configuration)\ + $(SolutionDir)\$(Configuration)\ $(SolutionDir)\bin\$(ProjectName)\$(PlatformTarget)\$(Configuration)\ + $(SolutionDir)\bin\$(ProjectName)\$(PlatformTarget)\$(Configuration)\ false + false .\Debug;$(ReferencePath) + .\Debug;$(ReferencePath) bin\$(PlatformTarget)\$(Configuration)\ + bin\$(PlatformTarget)\$(Configuration)\ bin\obj\$(PlatformTarget)\$(Configuration)\ + bin\obj\$(PlatformTarget)\$(Configuration)\ false + false AllRules.ruleset + AllRules.ruleset AllRules.ruleset AllRules.ruleset AllRules.ruleset AllRules.ruleset + + AllRules.ruleset + AllRules.ruleset AllRules.ruleset AllRules.ruleset AllRules.ruleset AllRules.ruleset + + AllRules.ruleset + AllRules.ruleset + + AllRules.ruleset + AllRules.ruleset + + .dll + .dll .lib .dll .dll @@ -277,10 +356,18 @@ false + + false + + + + $(ProjectDir)include\;$(ProjectDir)include\prototypes\;$(SolutionDir)Platform\include\;$(SolutionDir)Platform\include\prototypes\;$(SolutionDir)LtcInclude\;$(SolutionDIr)OsslInclude\;$(SolutionDir)MsBnInclude\ + + + Disabled - $(ProjectDir)include\;$(ProjectDir)include\prototypes\;$(SolutionDir)Platform\include\;$(SolutionDir)Platform\include\prototypes\;$(SolutionDir)LtcInclude\;$(SolutionDIr)OsslInclude\;$(SolutionDir)MsBnInclude\;$(SolutionDir)..\external\wolfssl %(PreprocessorDefinitions) false MultiThreadedDebugDLL @@ -291,7 +378,6 @@ CompileAsC Default 4820 - false true Default EnableFastChecks @@ -327,10 +413,58 @@ true + + + Disabled + $(ProjectDir)include\wolf;$(SolutionDir)..\external\wolfssl;$(SolutionDir)\wolfcrypt\include;%(AdditionalIncludeDirectories) + USE_WOLFCRYPT;%(PreprocessorDefinitions) + false + MultiThreadedDebugDLL + NotUsing + $(IntDir)Server.pdb + EnableAllWarnings + Cdecl + CompileAsC + Default + 4820;4255 + true + Default + EnableFastChecks + + + true + true + + + wolfssl.lib;platform.lib;%(AdditionalDependencies) + $(SolutionDir)\lib;$(SolutionDir)\Debug;$(OutDir);%(AdditionalLibraryDirectories) + + + true + NotSet + MachineX86 + $(OutDir)$(TargetName)$(TargetExt) + false + false + $(OutDir)Tpm.map + + + $(OutDir)$(TargetName)$(TargetExt) + + + $(ProjectDir)\lib;$(OutDir); + + + $(ProjectDir)\tpm\TPM.def + CryptoEngine.dll;platform.lib + + + true + + Disabled - $(ProjectDir)include\;$(ProjectDir)include\prototypes\;$(SolutionDir)Platform\include\;$(SolutionDir)Platform\include\prototypes\;$(SolutionDir)LtcInclude\;$(SolutionDIr)OsslInclude\;$(SolutionDir)MsBnInclude\ CRYPTO_ALIGN_4;_DEBUG;%(PreprocessorDefinitions) false EnableFastChecks @@ -376,7 +510,6 @@ Disabled - $(ProjectDir)include\;$(ProjectDir)include\prototypes\;$(SolutionDir)Platform\include\;$(SolutionDir)Platform\include\prototypes\;$(SolutionDir)LtcInclude\;$(SolutionDIr)OsslInclude\;$(SolutionDir)MsBnInclude\ CRYPTO_ALIGN_4;_DEBUG;%(PreprocessorDefinitions) false EnableFastChecks @@ -418,7 +551,6 @@ Disabled - $(ProjectDir)include\;$(ProjectDir)include\prototypes\;$(SolutionDir)Platform\include\;$(SolutionDir)Platform\include\prototypes\;$(SolutionDir)LtcInclude\;$(SolutionDIr)OsslInclude\;$(SolutionDir)MsBnInclude\ EMPTY_ASSERT;CRYPTO_ALIGN_4;_DEBUG;%(PreprocessorDefinitions) false EnableFastChecks @@ -460,7 +592,6 @@ Disabled - $(ProjectDir)include\;$(ProjectDir)include\prototypes\;$(SolutionDir)Platform\include\;$(SolutionDir)Platform\include\prototypes\;$(SolutionDir)LtcInclude\;$(SolutionDIr)OsslInclude\;$(SolutionDir)MsBnInclude\ CRYPTO_ALIGNMENT=4;_DEBUG;%(PreprocessorDefinitions) false EnableFastChecks @@ -526,7 +657,6 @@ Level3 ProgramDatabase - $(ProjectDir)include\;$(ProjectDir)include\prototypes\;$(SolutionDir)Platform\include\;$(SolutionDir)Platform\include\prototypes\;$(SolutionDir)LtcInclude\;$(SolutionDIr)OsslInclude\;$(SolutionDir)MsBnInclude\ 4668 @@ -539,6 +669,33 @@ + + + X64 + + + Disabled + $(ProjectDir)include\wolf;$(SolutionDir)..\external\wolfssl;$(SolutionDir)\wolfcrypt\include;%(AdditionalIncludeDirectories) + USE_WOLFCRYPT;CRYPTO_ALIGN_16;_DEBUG;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + + + Level3 + ProgramDatabase + 4668;4255 + + + wolfssl.lib;cryptoengine.lib;platform.lib;%(AdditionalDependencies) + true + Console + MachineX64 + $(ProjectDir)\lib;$(OutDir);%(AdditionalLibraryDirectories) + + + + X64 @@ -553,7 +710,6 @@ Level3 ProgramDatabase - $(ProjectDir)include\;$(ProjectDir)include\prototypes\;$(SolutionDir)Platform\include\;$(SolutionDir)Platform\include\prototypes\;$(SolutionDir)LtcInclude\;$(SolutionDIr)OsslInclude\;$(SolutionDir)MsBnInclude\ 4668 @@ -580,7 +736,6 @@ Level3 ProgramDatabase - $(ProjectDir)include\;$(ProjectDir)include\prototypes\;$(SolutionDir)Platform\include\;$(SolutionDir)Platform\include\prototypes\;$(SolutionDir)LtcInclude\;$(SolutionDIr)OsslInclude\;$(SolutionDir)MsBnInclude\ 4668 @@ -606,7 +761,6 @@ Level3 ProgramDatabase - $(ProjectDir)include\;$(ProjectDir)include\prototypes\;$(SolutionDir)Platform\include\;$(SolutionDir)Platform\include\prototypes\;$(SolutionDir)LtcInclude\;$(SolutionDIr)OsslInclude\;$(SolutionDir)MsBnInclude\ 4668 @@ -633,7 +787,6 @@ Level3 ProgramDatabase - $(ProjectDir)include\;$(ProjectDir)include\prototypes\;$(SolutionDir)Platform\include\;$(SolutionDir)Platform\include\prototypes\;$(SolutionDir)LtcInclude\;$(SolutionDIr)OsslInclude\;$(SolutionDir)MsBnInclude\ 4668 @@ -648,6 +801,7 @@ MaxSpeed + $(ProjectDir)include\wolf;$(SolutionDir)..\external\wolfssl;$(SolutionDir)\wolfcrypt\include;%(AdditionalIncludeDirectories) true CRYPTO_ALIGN_4;NDEBUG;%(PreprocessorDefinitions) MultiThreadedDLL @@ -656,10 +810,35 @@ Level3 ProgramDatabase CompileAsC - $(ProjectDir)include\;$(ProjectDir)include\prototypes\;$(SolutionDir)Platform\include\;$(SolutionDir)Platform\include\prototypes\;$(SolutionDir)LtcInclude\;$(SolutionDIr)OsslInclude\;$(SolutionDir)MsBnInclude\ - platform.lib;libeay32.lib;%(AdditionalDependencies) + platform.lib;%(AdditionalDependencies) + true + Console + true + true + MachineX86 + $(ProjectDir)\lib;$(OutDir);%(AdditionalLibraryDirectories) + + + $(OutDir)$(TargetName)$(TargetExt) + + + + + MaxSpeed + $(ProjectDir)include\wolf;$(SolutionDir)..\external\wolfssl;$(SolutionDir)\wolfcrypt\include;%(AdditionalIncludeDirectories) + true + USE_WOLFCRYPT;CRYPTO_ALIGN_4;NDEBUG;%(PreprocessorDefinitions) + MultiThreadedDLL + true + NotUsing + Level3 + ProgramDatabase + CompileAsC + + + wolfssl.lib;platform.lib;%(AdditionalDependencies) true Console true @@ -685,7 +864,6 @@ Level3 ProgramDatabase - $(ProjectDir)include\;$(ProjectDir)include\prototypes\;$(SolutionDir)Platform\include\;$(SolutionDir)Platform\include\prototypes\;$(SolutionDir)LtcInclude\;$(SolutionDIr)OsslInclude\;$(SolutionDir)MsBnInclude\ 16Bytes @@ -704,10 +882,41 @@ false + + + X64 + + + MaxSpeed + true + USE_WOLFCRYPT;CRYPTO_ALIGN_16;NDEBUG;%(PreprocessorDefinitions) + MultiThreadedDLL + true + + + Level3 + ProgramDatabase + 16Bytes + + + true + Console + true + true + MachineX64 + $(ProjectDir)\lib;$(OutDir);%(AdditionalLibraryDirectories) + wolfssl.lib;cryptoengine.lib;platform.lib + + + + + false + false + + GCC - $(ProjectDir)include\;$(ProjectDir)include\prototypes\;$(SolutionDir)Platform\include\;$(SolutionDir)Platform\include\prototypes\;$(SolutionDir)LtcInclude\;$(SolutionDIr)OsslInclude\;$(SolutionDir)MsBnInclude\ @@ -846,6 +1055,7 @@ true + true @@ -860,6 +1070,7 @@ false + false @@ -871,14 +1082,8 @@ - - $(SolutionDir)..\external\wolfssl\wolfssl;%(AdditionalIncludeDirectories) - $(SolutionDir)..\external\wolfssl\wolfssl;%(AdditionalIncludeDirectories) - - - $(SolutionDir)..\external\wolfssl\wolfssl;$(ProjectDir)include\;$(ProjectDir)include\prototypes\;$(SolutionDir)Platform\include\;$(SolutionDir)Platform\include\prototypes\;$(SolutionDir)LtcInclude\;$(SolutionDIr)OsslInclude\;$(SolutionDir)MsBnInclude\ - $(SolutionDir)..\external\wolfssl\wolfssl;$(ProjectDir)include\;$(ProjectDir)include\prototypes\;$(SolutionDir)Platform\include\;$(SolutionDir)Platform\include\prototypes\;$(SolutionDir)LtcInclude\;$(SolutionDIr)OsslInclude\;$(SolutionDir)MsBnInclude\ - + + @@ -915,6 +1120,7 @@ false + false @@ -1129,6 +1335,9 @@ + + + @@ -1157,7 +1366,7 @@ - + diff --git a/TPMCmd/tpm/Tpm.vcxproj.filters b/TPMCmd/tpm/Tpm.vcxproj.filters index 7a28045..afaa9ef 100644 --- a/TPMCmd/tpm/Tpm.vcxproj.filters +++ b/TPMCmd/tpm/Tpm.vcxproj.filters @@ -1302,9 +1302,18 @@ Headers\Crypt\wolf - + Headers\Crypt\wolf + + Headers\prototypes + + + Headers\prototypes + + + Headers\prototypes + diff --git a/TPMCmd/tpm/include/Implementation.h b/TPMCmd/tpm/include/Implementation.h index b3aad82..921d26c 100644 --- a/TPMCmd/tpm/include/Implementation.h +++ b/TPMCmd/tpm/include/Implementation.h @@ -314,9 +314,15 @@ #define RADIX_BITS 32 #define HASH_ALIGNMENT 4 #define SYMMETRIC_ALIGNMENT 4 -#define HASH_LIB WOLF +#ifndef USE_WOLFCRYPT +#define HASH_LIB OSSL #define SYM_LIB OSSL #define MATH_LIB OSSL +#else +#define HASH_LIB WOLF +#define SYM_LIB WOLF +#define MATH_LIB WOLF +#endif #define BSIZE UINT16 #define IMPLEMENTATION_PCR 24 #define PLATFORM_PCR 24 diff --git a/TPMCmd/tpm/include/VendorString.h b/TPMCmd/tpm/include/VendorString.h index da2c648..a7740f9 100644 --- a/TPMCmd/tpm/include/VendorString.h +++ b/TPMCmd/tpm/include/VendorString.h @@ -40,7 +40,7 @@ // for TPM_PT_MANUFACTURER in TPM2_GetCapability. // The following line should be un-commented and a vendor specific string // should be provided here. -#define MANUFACTURER "MSFT" +//#define MANUFACTURER "MSFT" // The following #if macro may be deleted after a proper MANUFACTURER is provided. #ifndef MANUFACTURER @@ -57,8 +57,8 @@ manufacturer name. // The following line should be un-commented and a vendor specific string // // A vendor-specific string should be provided here. -#define VENDOR_STRING_1 "DPA " -#define VENDOR_STRING_2 "fTPM" +//#define VENDOR_STRING_1 "DPA " +//#define VENDOR_STRING_2 "fTPM" // The vendor strings 2-4 may also be defined as needed. //#define VENDOR_STRING_3 @@ -75,11 +75,11 @@ string. // A vendor-specific FIRMWARE_V1 is required here. It is // the more significant 32-bits of a vendor-specific value // indicating the version of the firmware -#define FIRMWARE_V1 (0x20170615) +//#define FIRMWARE_V1 (0x20170615) // A vendor-specific FIRMWARE_V2 may be provided here. If present, it is the less // significant 32-bits of the version of the firmware. -#define FIRMWARE_V2 (0x00000000) +//#define FIRMWARE_V2 (0x00000000) // The following macro is just to insure that a FIRMWARE_V1 value is provided. #ifndef FIRMWARE_V1 diff --git a/TPMCmd/tpm/include/prototypes/TpmToWolfDesSupport_fp.h b/TPMCmd/tpm/include/prototypes/TpmToWolfDesSupport_fp.h new file mode 100644 index 0000000..1910142 --- /dev/null +++ b/TPMCmd/tpm/include/prototypes/TpmToWolfDesSupport_fp.h @@ -0,0 +1,90 @@ +/* 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. + */ + +/*(Auto) + Automatically Generated by TpmPrototypes version 2.2 February 10, 2016 + Date: Sep 9, 2016 Time: 01:03:57 PM +*/ + +#ifndef _TPMTOWOLFDESSUPPORT_FP_H_ +#define _TPMTOWOLFDESSUPPORT_FP_H_ + +#if SYM_LIB == WOLF && defined TPM_ALG_TDES +//**Functions + +//** TDES_setup +// This function calls the wolfcrypt function to generate a TDES key schedule. If the +// If the key is two key (16 bytes), then the first DES key is replicated to the third +// key position. +int TDES_setup( + const BYTE *key, + UINT32 keyBits, + tpmKeyScheduleTDES *skey, + int dir + ); + +//** TDES_setup_encrypt_key +// This function calls into TDES_setup(), specifically for an encryption key. +int TDES_setup_encrypt_key( + const BYTE *key, + UINT32 keyBits, + tpmKeyScheduleTDES *skey + ); + +//** TDES_setup_decrypt_key +// This function calls into TDES_setup(), specifically for an decryption key. +int TDES_setup_decrypt_key( + const BYTE *key, + UINT32 keyBits, + tpmKeyScheduleTDES *skey + ); + +//*** TDES_encyrpt() +void TDES_encrypt( + const BYTE *in, + BYTE *out, + tpmKeyScheduleTDES *ks + ); + +//*** TDES_decrypt() +void TDES_decrypt( + const BYTE *in, + BYTE *out, + tpmKeyScheduleTDES *ks + ); +#endif // SYM_LIB == WOLF + + +#endif // _TPMTOWOLFDESSUPPORT_FP_H_ diff --git a/TPMCmd/tpm/include/prototypes/TpmToWolfMath_fp.h b/TPMCmd/tpm/include/prototypes/TpmToWolfMath_fp.h new file mode 100644 index 0000000..e5fe91e --- /dev/null +++ b/TPMCmd/tpm/include/prototypes/TpmToWolfMath_fp.h @@ -0,0 +1,209 @@ +/* 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. + */ + +/*(Auto) + Automatically Generated by TpmPrototypes version 2.2 February 10, 2016 + Date: Sep 9, 2016 Time: 01:03:57 PM +*/ + +#ifndef _TPMTOWOLFMATH_FP_H_ +#define _TPMTOWOLFMATH_FP_H_ + +#if MATH_LIB == WOLF +//**Functions + +//*** BnFromWolf() +// This function converts a wolfcrypt mp_int to a TPM bignum. In this implementation +// it is assumed that wolfcrypt used the same format for a big number as does the +// TPM -- an array of native-endian words in little-endian order. +void +BnFromWolf( + bigNum bn, + mp_int *wolfBn + ); + +//*** BnToWolf() +// This function converts a TPM bignum to a wolfcrypt mp_init, and has the same +// assumptions as made by BnFromWolf() +void +BnToWolf( + mp_int *toInit, + bigConst initializer + ); + +//*** MpInitialize() +// This function initializes an wolfcrypt mp_int. +mp_int * +MpInitialize( + mp_int *toInit + ); + +//** MathLibraryCompatibililtyCheck() +// This function is only used during development to make sure that the library +// that is being referenced is using the same size of data structures as the TPM. +void +MathLibraryCompatibilityCheck( + void + ); + +//*** BnModMult() +// Does multiply and divide returning the remainder of the divide. +LIB_EXPORT BOOL +BnModMult( + bigNum result, + bigConst op1, + bigConst op2, + bigConst modulus + ); + +//*** BnMult() +// Multiplies two numbers +LIB_EXPORT BOOL +BnMult( + bigNum result, + bigConst multiplicand, + bigConst multiplier + ); + +//*** BnDiv() +// This function divides two bigNum values. The function returns FALSE if +// there is an error in the operation. +LIB_EXPORT BOOL +BnDiv( + bigNum quotient, + bigNum remainder, + bigConst dividend, + bigConst divisor + ); + +#ifdef TPM_ALG_RSA +//*** BnGcd() +// Get the greatest common divisor of two numbers +LIB_EXPORT BOOL +BnGcd( + bigNum gcd, // OUT: the common divisor + bigConst number1, // IN: + bigConst number2 // IN: + ); + +//***BnModExp() +// Do modular exponentiation using bigNum values. The conversion from a mp_int to +// a bigNum is trivial as they are based on the same structure +LIB_EXPORT BOOL +BnModExp( + bigNum result, // OUT: the result + bigConst number, // IN: number to exponentiate + bigConst exponent, // IN: + bigConst modulus // IN: + ); + +//*** BnModInverse() +// Modular multiplicative inverse +LIB_EXPORT BOOL +BnModInverse( + bigNum result, + bigConst number, + bigConst modulus + ); +#endif // TPM_ALG_RSA + +#ifdef TPM_ALG_ECC + +//*** PointFromWolf() +// Function to copy the point result from a wolf ecc_point to a bigNum +void +PointFromWolf( + bigPoint pOut, // OUT: resulting point + ecc_point *pIn // IN: the point to return + ); + +//*** PointToWolf() +// Function to copy the point result from a bigNum to a wolf ecc_point +void +PointToWolf( + ecc_point *pOut, // OUT: resulting point + pointConst pIn // IN: the point to return + ); + +//*** EcPointInitialized() +// Allocate and initialize a point. +static ecc_point * +EcPointInitialized( + pointConst initializer + ); + +//*** BnEccModMult() +// This function does a point multiply of the form R = [d]S +// return type: BOOL +// FALSE failure in operation; treat as result being point at infinity +LIB_EXPORT BOOL +BnEccModMult( + bigPoint R, // OUT: computed point + pointConst S, // IN: point to multiply by 'd' (optional) + bigConst d, // IN: scalar for [d]S + bigCurve E + ); + +//*** BnEccModMult2() +// This function does a point multiply of the form R = [d]G + [u]Q +// return type: BOOL +// FALSE failure in operation; treat as result being point at infinity +LIB_EXPORT BOOL +BnEccModMult2( + bigPoint R, // OUT: computed point + pointConst S, // IN: optional point + bigConst d, // IN: scalar for [d]S or [d]G + pointConst Q, // IN: second point + bigConst u, // IN: second scalar + bigCurve E // IN: curve + ); + +//** BnEccAdd() +// This function does addition of two points. +// return type: BOOL +// FALSE failure in operation; treat as result being point at infinity +LIB_EXPORT BOOL +BnEccAdd( + bigPoint R, // OUT: computed point + pointConst S, // IN: point to multiply by 'd' + pointConst Q, // IN: second point + bigCurve E // IN: curve + ); +#endif // TPM_ALG_ECC + +#endif // MATH_LIB == WOLF + + +#endif // _TPMTOWOLFMATH_FP_H_ diff --git a/TPMCmd/tpm/include/prototypes/TpmToWolfSupport_fp.h b/TPMCmd/tpm/include/prototypes/TpmToWolfSupport_fp.h new file mode 100644 index 0000000..9ef5aa1 --- /dev/null +++ b/TPMCmd/tpm/include/prototypes/TpmToWolfSupport_fp.h @@ -0,0 +1,56 @@ +/* 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. + */ + +/*(Auto) + Automatically Generated by TpmPrototypes version 2.2 February 10, 2016 + Date: Sep 9, 2016 Time: 01:03:57 PM +*/ + +#ifndef _TPMTOWOLFSUPPORT_FP_H_ +#define _TPMTOWOLFSUPPORT_FP_H_ + +#if MATH_LIB == WOLF +//**Functions + +//*** SupportLibInit() +// This does any initialization required by the support library. +LIB_EXPORT int +SupportLibInit( + void + ); +#endif // MATH_LIB == WOLF + + +#endif // _TPMTOWOLFSUPPORT_FP_H_ diff --git a/TPMCmd/tpm/include/wolf/TpmToWolfHash.h b/TPMCmd/tpm/include/wolf/TpmToWolfHash.h index 21bb335..c75e2e3 100644 --- a/TPMCmd/tpm/include/wolf/TpmToWolfHash.h +++ b/TPMCmd/tpm/include/wolf/TpmToWolfHash.h @@ -35,7 +35,7 @@ //** Introduction // -// This header file is used to 'splice' the OpenSSL hash code into the TPM code. +// This header file is used to 'splice' the wolfcrypt hash code into the TPM code. // #ifndef _TPM_TO_WOLF_HASH_H_ #define _TPM_TO_WOLF_HASH_H_ @@ -49,7 +49,7 @@ //*************************************************************** -//** Links to the OpenSSL HASH code +//** Links to the wolfcrypt HASH code //*************************************************************** // Redefine the internal name used for each of the hash state structures to the diff --git a/TPMCmd/tpm/include/wolf/TpmToWolfMath.h b/TPMCmd/tpm/include/wolf/TpmToWolfMath.h index 4f2ce24..2887e12 100644 --- a/TPMCmd/tpm/include/wolf/TpmToWolfMath.h +++ b/TPMCmd/tpm/include/wolf/TpmToWolfMath.h @@ -45,66 +45,41 @@ #if MATH_LIB == WOLF -#include -#include -#if OPENSSL_VERSION_NUMBER >= 0x10100000L -#include -#endif -#include - -//** Macros and Defines +#include +#include -// Make sure that the library is using the correct size for a crypt word -#if defined THIRTY_TWO_BIT && (RADIX_BITS != 32) \ - || defined SIXTY_FOUR_BIT && (RADIX_BITS != 64) -# error "Ossl library is using different radix" -#endif +#define MP_VAR(name) \ + mp_int _##name; \ + mp_int *name = MpInitialize(&_##name); -// Allocate a local BIGNUM value. For the allocation, a bigNum structure is created -// as is a local BIGNUM. The bigNum is initialized and then the BIGNUM is -// set to reference the local value. -#define BIG_VAR(name, bits) \ - BN_VAR(name##Bn, (bits)); \ - BIGNUM _##name; \ - BIGNUM *name = BigInitialized(&_##name, \ - BnInit(name##Bn, \ - BYTES_TO_CRYPT_WORDS(sizeof(_##name##Bn.d)))) +// Allocate a mp_int and initialize with the values in a mp_int* initializer +#define MP_INITIALIZED(name, initializer) \ + MP_VAR(name); \ + BnToWolf(name, initializer); -// Allocate a BIGNUM and initialize with the values in a bigNum initializer -#define BIG_INITIALIZED(name, initializer) \ - BIGNUM _##name; \ - BIGNUM *name = BigInitialized(&_##name, initializer) +#define POINT_CREATE(name, initializer) \ + ecc_point *name = EcPointInitialized(initializer); +#define POINT_DELETE(name) \ + wc_ecc_del_point(name); \ + name = NULL; -typedef struct -{ - const ECC_CURVE_DATA *C; // the TPM curve values - EC_GROUP *G; // group parameters - BN_CTX *CTX; // the context for the math (this might not be - // the context in which the curve was created>; -} OSSL_CURVE_DATA; +typedef ECC_CURVE_DATA bnCurve_t; -typedef OSSL_CURVE_DATA *bigCurve; +typedef bnCurve_t *bigCurve; -#define AccessCurveData(E) ((E)->C) +#define AccessCurveData(E) (E) #define CURVE_INITIALIZED(name, initializer) \ - OSSL_CURVE_DATA _##name; \ - bigCurve name = BnCurveInitialize(&_##name, initializer) + bnCurve_t *name = (ECC_CURVE_DATA *)GetCurveData(initializer) -#include "TpmToOsslSupport_fp.h" +#define CURVE_FREE(E) -#define CURVE_FREE(E) \ - if(E != NULL) \ - { \ - if(E->G != NULL) \ - EC_GROUP_free(E->G); \ - OsslContextLeave(E->CTX); \ - } +#include "TpmToWolfSupport_fp.h" -#define OSSL_ENTER() BN_CTX *CTX = OsslContextEnter() +#define WOLF_ENTER() -#define OSSL_LEAVE() OsslContextLeave(CTX) +#define WOLF_LEAVE() // This definition would change if there were something to report #define MathLibSimulationEnd() diff --git a/TPMCmd/tpm/include/wolf/TpmToWolfSym.h b/TPMCmd/tpm/include/wolf/TpmToWolfSym.h index 7695a2d..d970bd8 100644 --- a/TPMCmd/tpm/include/wolf/TpmToWolfSym.h +++ b/TPMCmd/tpm/include/wolf/TpmToWolfSym.h @@ -35,23 +35,18 @@ //** 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. +// This header file is used to 'splice' the wolfcrypt library into the TPM code. #ifndef _TPM_TO_WOLF_SYM_H_ #define _TPM_TO_WOLF_SYM_H_ #if SYM_LIB == WOLF -#include -#include -#include -#include +#include +#include //*************************************************************** -//** Links to the OpenSSL AES code +//** Links to the wolfCrypt AES code //*************************************************************** #ifdef TPM_ALG_SM4 @@ -65,9 +60,9 @@ // Define the order of parameters to the library functions that do block encryption // and decryption. typedef void(*TpmCryptSetSymKeyCall_t)( - const BYTE *in, + void *keySchedule, BYTE *out, - void *keySchedule + const BYTE *in ); // The Crypt functions that call the block encryption function use the parameters @@ -75,24 +70,24 @@ typedef void(*TpmCryptSetSymKeyCall_t)( // 1) keySchedule // 2) in buffer // 3) out buffer -// Since open SSL uses the order in encryptoCall_t above, need to swizzle the +// Since wolfcrypt 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) + (void *)(keySchedule), (BYTE *)(out), (const BYTE *)(in) // Macros to set up the encryption/decryption key schedules // // AES: #define TpmCryptSetEncryptKeyAES(key, keySizeInBits, schedule) \ - AES_set_encrypt_key((key), (keySizeInBits), (tpmKeyScheduleAES *)(schedule)) + wc_AesSetKeyDirect((tpmKeyScheduleAES *)(schedule), key, BITS_TO_BYTES(keySizeInBits), 0, AES_ENCRYPTION) #define TpmCryptSetDecryptKeyAES(key, keySizeInBits, schedule) \ - AES_set_decrypt_key((key), (keySizeInBits), (tpmKeyScheduleAES *)(schedule)) + wc_AesSetKeyDirect((tpmKeyScheduleAES *)(schedule), key, BITS_TO_BYTES(keySizeInBits), 0, AES_DECRYPTION) // TDES: #define TpmCryptSetEncryptKeyTDES(key, keySizeInBits, schedule) \ - TDES_set_encrypt_key((key), (keySizeInBits), (tpmKeyScheduleTDES *)(schedule)) + TDES_setup_encrypt_key((key), (keySizeInBits), (tpmKeyScheduleTDES *)(schedule)) #define TpmCryptSetDecryptKeyTDES(key, keySizeInBits, schedule) \ - TDES_set_encrypt_key((key), (keySizeInBits), (tpmKeyScheduleTDES *)(schedule)) + TDES_setup_decrypt_key((key), (keySizeInBits), (tpmKeyScheduleTDES *)(schedule)) // Macros to alias encryption calls to specific algorithms. This should be used // sparingly. Currently, only used by CryptRand.c @@ -100,19 +95,18 @@ typedef void(*TpmCryptSetSymKeyCall_t)( // 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 TpmCryptEncryptAES wc_AesEncryptDirect +#define TpmCryptDecryptAES wc_AesDecryptDirect +#define tpmKeyScheduleAES Aes #define TpmCryptEncryptTDES TDES_encrypt #define TpmCryptDecryptTDES TDES_decrypt -#define tpmKeyScheduleTDES DES_key_schedule +#define tpmKeyScheduleTDES Des3 typedef union tpmCryptKeySchedule_t tpmCryptKeySchedule_t; #ifdef TPM_ALG_TDES -#include "TpmToOsslDesSupport_fp.h" +#include "TpmToWolfDesSupport_fp.h" #endif // This definition would change if there were something to report diff --git a/TPMCmd/tpm/include/wolf/user_settings.h b/TPMCmd/tpm/include/wolf/user_settings.h deleted file mode 100644 index 5cf6e98..0000000 --- a/TPMCmd/tpm/include/wolf/user_settings.h +++ /dev/null @@ -1,42 +0,0 @@ -/* settings.h - * - * Copyright (C) 2006-2017 wolfSSL Inc. - * - * This file is part of wolfSSL. - * - * wolfSSL is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * wolfSSL is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA - */ - - -/* Place OS specific preprocessor flags, defines, includes here, will be - included into every file because types.h includes it */ - - -#ifndef WOLF_CRYPT_USER_SETTINGS_H -#define WOLF_CRYPT_USER_SETTINGS_H - -#ifdef __cplusplus - extern "C" { -#endif - -#define NO_OLD_WC_NAMES -#define WOLFSSL_SHA384 -#define WOLFSSL_SHA512 - -#ifdef __cplusplus - } /* extern "C" */ -#endif - -#endif diff --git a/TPMCmd/tpm/src/crypt/CryptEccMain.c b/TPMCmd/tpm/src/crypt/CryptEccMain.c index 53ee287..f6bec9d 100644 --- a/TPMCmd/tpm/src/crypt/CryptEccMain.c +++ b/TPMCmd/tpm/src/crypt/CryptEccMain.c @@ -542,8 +542,8 @@ BnPointMult( if(!OK) return TPM_RC_VALUE; - OK = (S == NULL) || BnIsOnCurve(S, E->C); - OK = OK && ((Q == NULL) || BnIsOnCurve(Q, E->C)); + OK = (S == NULL) || BnIsOnCurve(S, AccessCurveData(E)); + OK = OK && ((Q == NULL) || BnIsOnCurve(Q, AccessCurveData(E))); if(!OK) return TPM_RC_ECC_POINT; @@ -622,7 +622,7 @@ BnEccGenerateKeyPair( { BOOL OK = FALSE; // Get a private scalar - OK = BnEccGetPrivate(bnD, E->C, rand); + OK = BnEccGetPrivate(bnD, AccessCurveData(E), rand); // Do a point multiply OK = OK && BnEccModMult(ecQ, NULL, bnD, E); diff --git a/TPMCmd/tpm/src/crypt/wolf/TpmToWolfDesSupport.c b/TPMCmd/tpm/src/crypt/wolf/TpmToWolfDesSupport.c index b261171..b53277d 100644 --- a/TPMCmd/tpm/src/crypt/wolf/TpmToWolfDesSupport.c +++ b/TPMCmd/tpm/src/crypt/wolf/TpmToWolfDesSupport.c @@ -36,7 +36,7 @@ //** Introduction // // The functions in this file are used for initialization of the interface to the -// OpenSSL library. +// wolfcrypt library. //** Defines and Includes @@ -45,57 +45,73 @@ #if SYM_LIB == WOLF && defined TPM_ALG_TDES //**Functions -//*** TDES_set_encyrpt_key() -// This function makes creation of a TDES key look like the creation of a key for -// any of the other OpenSSL block ciphers. It will create three key schedules, -// one for each of the DES keys. If there are only two keys, then the third schedule -// is a copy of the first. -void -TDES_set_encrypt_key( - const BYTE *key, - UINT16 keySizeInBits, - tpmKeyScheduleTDES *keySchedule +//** TDES_setup +// This function calls the wolfcrypt function to generate a TDES key schedule. If the +// If the key is two key (16 bytes), then the first DES key is replicated to the third +// key position. +int TDES_setup( + const BYTE *key, + UINT32 keyBits, + tpmKeyScheduleTDES *skey, + int dir ) { - DES_set_key_unchecked((const_DES_cblock *)key, &keySchedule[0]); - DES_set_key_unchecked((const_DES_cblock *)&key[8], &keySchedule[1]); - // If is two-key, copy the schedule for K1 into K3, otherwise, compute the - // the schedule for K3 - if(keySizeInBits == 128) - keySchedule[2] = keySchedule[0]; + BYTE k[24]; + BYTE *kp; + + // If this is two-key, make it three key by replicating K1 + if(keyBits == 128) + { + memcpy(k, key, 16); + memcpy(&k[16], key, 8); + kp = k; + } else - DES_set_key_unchecked((const_DES_cblock *)&key[16], - &keySchedule[2]); + kp = (BYTE *)key; + + return wc_Des3_SetKey( skey, kp, 0, dir ); } +//** TDES_setup_encrypt_key +// This function calls into TDES_setup(), specifically for an encryption key. +int TDES_setup_encrypt_key( + const BYTE *key, + UINT32 keyBits, + tpmKeyScheduleTDES *skey +) +{ + return TDES_setup( key, keyBits, skey, DES_ENCRYPTION ); +} + +//** TDES_setup_decrypt_key +// This function calls into TDES_setup(), specifically for an decryption key. +int TDES_setup_decrypt_key( + const BYTE *key, + UINT32 keyBits, + tpmKeyScheduleTDES *skey +) +{ + return TDES_setup( key, keyBits, skey, DES_DECRYPTION ); +} //*** TDES_encyrpt() -// The TPM code uses one key schedule. For TDES, the schedule contains three -// schedules. OpenSSL wants the schedules referenced separately. This function -// does that. void TDES_encrypt( const BYTE *in, BYTE *out, tpmKeyScheduleTDES *ks ) { - DES_ecb3_encrypt((const_DES_cblock *)in, (DES_cblock *)out, - &ks[0], &ks[1], &ks[2], - DES_ENCRYPT); + wc_Des3_EcbEncrypt( ks, out, in, DES_BLOCK_SIZE ); } //*** TDES_decrypt() -// As with TDES_encypt() this function bridges between the TPM single schedule -// model and the OpenSSL three schedule model. void TDES_decrypt( const BYTE *in, BYTE *out, tpmKeyScheduleTDES *ks ) { - DES_ecb3_encrypt((const_DES_cblock *)in, (DES_cblock *)out, - &ks[0], &ks[1], &ks[2], - DES_DECRYPT); + wc_Des3_EcbDecrypt( ks, out, in, DES_BLOCK_SIZE ); } #endif // SYM_LIB == WOLF diff --git a/TPMCmd/tpm/src/crypt/wolf/TpmToWolfMath.c b/TPMCmd/tpm/src/crypt/wolf/TpmToWolfMath.c index 8cbea96..8941d6b 100644 --- a/TPMCmd/tpm/src/crypt/wolf/TpmToWolfMath.c +++ b/TPMCmd/tpm/src/crypt/wolf/TpmToWolfMath.c @@ -36,124 +36,91 @@ //** Introduction // // This file contains the math functions that are not implemented in the BnMath -// library (yet). These math functions will call the OpenSSL library to execute +// library (yet). These math functions will call the wolfcrypt library to execute // the operations. There is a difference between the internal format and the -// OpenSSL format. To call the OpenSSL function, a BIGNUM structure is created -// for each passed variable. The sizes in the bignum_t are copied and the 'd' -// pointer in the BIGNUM is set to point to the 'd' parameter of the bignum_t. -// On return, SetSizeOsslToTpm is used for each returned variable to make sure that -// the pointers are not changed. The size of the returned BIGGNUM is copied to -// bignum_t. +// wolfcrypt format. To call the wolfcrypt function, a mp_int structure is created +// for each passed variable. We define USE_FAST_MATH wolfcrypt option, which allocates +// mp_int on the stack. We must copy each word to the new structure, and set the used +// size. +// +// Not using USE_FAST_MATH would allow for a simple pointer swap for the big integer +// buffer 'd', however wolfcrypt expects to manage this memory, and will swap out +// the pointer to and from temporary variables and free the reference underneath us. +// Using USE_FAST_MATH also instructs wolfcrypt to use the stack for all these +// intermediate variables + //** Includes and Defines #include "Tpm.h" #if MATH_LIB == WOLF -#include "TpmToOsslMath_fp.h" +#include "BnConvert_fp.h" +#include "TpmToWolfMath_fp.h" //** Functions -//*** OsslToTpmBn() -// This function converts an OpenSSL BIGNUM to a TPM bignum. In this implementation -// it is assumed that OpenSSL used the same format for a big number as does the +//*** BnFromWolf() +// This function converts a wolfcrypt mp_int to a TPM bignum. In this implementation +// it is assumed that wolfcrypt used the same format for a big number as does the // TPM -- an array of native-endian words in little-endian order. -// -// If the array allocated for the OpenSSL BIGNUM is not the space within the TPM -// bignum, then the data is copied. Otherwise, just the size field of the BIGNUM -// is copied. void -OsslToTpmBn( +BnFromWolf( bigNum bn, - BIGNUM *osslBn + mp_int *wolfBn ) { if(bn != NULL) { - if((crypt_uword_t *)osslBn->d != bn->d) - { - int i; - pAssert((unsigned)osslBn->top <= BnGetAllocated(bn)); - for(i = 0; i < osslBn->top; i++) - bn->d[i] = osslBn->d[i]; - } - BnSetTop(bn, osslBn->top); + int i; + pAssert((unsigned)wolfBn->used <= BnGetAllocated(bn)); + for(i = 0; i < wolfBn->used; i++) + bn->d[i] = wolfBn->dp[i]; + + BnSetTop(bn, wolfBn->used); } } -//*** BigInitialized() -// This function initializes an OSSL BIGNUM from a TPM bignum. -BIGNUM * -BigInitialized( - BIGNUM *toInit, +//*** BnToWolf() +// This function converts a TPM bignum to a wolfcrypt mp_init, and has the same +// assumptions as made by BnFromWolf() +void +BnToWolf( + mp_int *toInit, bigConst initializer ) { - if(toInit == NULL || initializer == NULL) - return NULL; - toInit->d = (BN_ULONG *)&initializer->d[0]; - toInit->dmax = initializer->allocated; - toInit->top = initializer->size; - toInit->neg = 0; - toInit->flags = 0; - return toInit; + uint32_t i; + if (toInit != NULL && initializer != NULL) + { + for (i = 0; i < initializer->size; i++) + toInit->dp[i] = initializer->d[i]; + + toInit->used = initializer->size; + toInit->sign = 0; + } } -#ifndef OSSL_DEBUG -# define BIGNUM_PRINT(label, bn, eol) -# define DEBUG_PRINT(x) -#else -# define DEBUG_PRINT(x) printf("%s", x) -# define BIGNUM_PRINT(label, bn, eol) BIGNUM_print((label), (bn), (eol)) -static -void BIGNUM_print( - const char *label, - const BIGNUM *a, - BOOL eol - ) +//*** MpInitialize() +// This function initializes an wolfcrypt mp_int. +mp_int * +MpInitialize( + mp_int *toInit +) { - BN_ULONG *d; - int i; - int notZero = FALSE; - - if(label != NULL) - printf("%s", label); - if(a == NULL) - { - printf("NULL"); - goto done; - } - if (a->neg) - printf("-"); - for(i = a->top, d = &a->d[i - 1]; i > 0; i--) - { - int j; - BN_ULONG l = *d--; - for(j = BN_BITS2 - 8; j >= 0; j -= 8) - { - BYTE b = (BYTE)((l >> j) & 0xFF); - notZero = notZero || (b != 0); - if(notZero) - printf("%02x", b); - } - if(!notZero) - printf("0"); - } -done: - if(eol) - printf("\n"); - return; + mp_init( toInit ); + return toInit; } -#endif #ifdef LIBRARY_COMPATIBILITY_CHECK +//** MathLibraryCompatibililtyCheck() +// This function is only used during development to make sure that the library +// that is being referenced is using the same size of data structures as the TPM. void MathLibraryCompatibilityCheck( void ) { - OSSL_ENTER(); - BIGNUM *osslTemp = BN_CTX_get(CTX); BN_VAR(tpmTemp, 64 * 8); // allocate some space for a test value crypt_uword_t i; TPM2B_TYPE(TEST, 16); @@ -163,13 +130,12 @@ MathLibraryCompatibilityCheck( 0x03, 0x02, 0x01, 0x00}}}; // Convert the test TPM2B to a bigNum BnFrom2B(tpmTemp, &test.b); - // Convert the test TPM2B to an OpenSSL BIGNUM - BN_bin2bn(test.t.buffer, test.t.size, osslTemp); + MP_INITIALIZED(wolfTemp, tpmTemp); + (wolfTemp); // compiler warning // Make sure the values are consistent - cAssert(osslTemp->top == (int)tpmTemp->size); + cAssert(wolfTemp->used == (int)tpmTemp->size); for(i = 0; i < tpmTemp->size; i++) - cAssert(osslTemp->d[0] == tpmTemp->d[0]); - OSSL_LEAVE(); + cAssert(wolfTemp->d[i] == tpmTemp->d[i]); } #endif @@ -183,22 +149,23 @@ BnModMult( bigConst modulus ) { - OSSL_ENTER(); - BIG_INITIALIZED(bnResult, result); - BIG_INITIALIZED(bnOp1, op1); - BIG_INITIALIZED(bnOp2, op2); - BIG_INITIALIZED(bnMod, modulus); - BIG_VAR(bnTemp, (LARGEST_NUMBER_BITS * 4)); + WOLF_ENTER(); BOOL OK; + MP_INITIALIZED(bnOp1, op1); + MP_INITIALIZED(bnOp2, op2); + MP_INITIALIZED(bnTemp, NULL); + BN_VAR(temp, LARGEST_NUMBER_BITS * 2); + pAssert(BnGetAllocated(result) >= BnGetSize(modulus)); - OK = BN_mul(bnTemp, bnOp1, bnOp2, CTX); - OK = OK && BN_div(NULL, bnResult, bnTemp, bnMod, CTX); + + OK = (mp_mul( bnOp1, bnOp2, bnTemp ) == MP_OKAY); if(OK) { - result->size = bnResult->top; - OsslToTpmBn(result, bnResult); + BnFromWolf(temp, bnTemp); + OK = BnDiv(NULL, result, temp, modulus); } - OSSL_LEAVE(); + + WOLF_LEAVE(); return OK; } @@ -211,22 +178,23 @@ BnMult( bigConst multiplier ) { - OSSL_ENTER(); - BN_VAR(temp, (LARGEST_NUMBER_BITS * 2)); - BIG_INITIALIZED(bnTemp, temp); - BIG_INITIALIZED(bnA, multiplicand); - BIG_INITIALIZED(bnB, multiplier); + WOLF_ENTER(); BOOL OK; + MP_INITIALIZED(bnTemp, NULL); + MP_INITIALIZED(bnA, multiplicand); + MP_INITIALIZED(bnB, multiplier); + pAssert(result->allocated >= (BITS_TO_CRYPT_WORDS(BnSizeInBits(multiplicand) + BnSizeInBits(multiplier)))); - OK = BN_mul(bnTemp, bnA, bnB, CTX); + + OK = (mp_mul( bnA, bnB, bnTemp ) == MP_OKAY); if(OK) { - OsslToTpmBn(temp, bnTemp); - BnCopy(result, temp); + BnFromWolf(result, bnTemp); } - OSSL_LEAVE(); + + WOLF_LEAVE(); return OK; } @@ -241,12 +209,12 @@ BnDiv( bigConst divisor ) { - OSSL_ENTER(); - BIG_INITIALIZED(bnQ, quotient); - BIG_INITIALIZED(bnR, remainder); - BIG_INITIALIZED(bnDend, dividend); - BIG_INITIALIZED(bnSor, divisor); + WOLF_ENTER(); BOOL OK; + MP_INITIALIZED(bnQ, quotient); + MP_INITIALIZED(bnR, remainder); + MP_INITIALIZED(bnDend, dividend); + MP_INITIALIZED(bnSor, divisor); pAssert(!BnEqualZero(divisor)); if(BnGetSize(dividend) < BnGetSize(divisor)) { @@ -263,19 +231,15 @@ BnDiv( - divisor->size))); pAssert((remainder == NULL) || (remainder->allocated >= divisor->size)); - OK = BN_div(bnQ, bnR, bnDend, bnSor, CTX); + OK = (mp_div(bnDend , bnSor, bnQ, bnR) == MP_OKAY); if(OK) { - OsslToTpmBn(quotient, bnQ); - OsslToTpmBn(remainder, bnR); + BnFromWolf(quotient, bnQ); + BnFromWolf(remainder, bnR); } } - DEBUG_PRINT("In BnDiv:\n"); - BIGNUM_PRINT(" bnDividend: ", bnDend, TRUE); - BIGNUM_PRINT(" bnDivisor: ", bnSor, TRUE); - BIGNUM_PRINT(" bnQuotient: ", bnQ, TRUE); - BIGNUM_PRINT(" bnRemainder: ", bnR, TRUE); - OSSL_LEAVE(); + + WOLF_LEAVE(); return OK; } @@ -289,24 +253,23 @@ BnGcd( bigConst number2 // IN: ) { - OSSL_ENTER(); - BIG_INITIALIZED(bnGcd, gcd); - BIG_INITIALIZED(bn1, number1); - BIG_INITIALIZED(bn2, number2); + WOLF_ENTER(); BOOL OK; + MP_INITIALIZED(bnGcd, gcd); + MP_INITIALIZED(bn1, number1); + MP_INITIALIZED(bn2, number2); pAssert(gcd != NULL); - OK = BN_gcd(bnGcd, bn1, bn2, CTX); + OK = (mp_gcd( bn1, bn2, bnGcd ) == MP_OKAY); if(OK) { - OsslToTpmBn(gcd, bnGcd); - gcd->size = bnGcd->top; + BnFromWolf(gcd, bnGcd); } - OSSL_LEAVE(); + WOLF_LEAVE(); return OK; } //***BnModExp() -// Do modular exponentiation using bigNum values. The conversion from a bignum_t to +// Do modular exponentiation using bigNum values. The conversion from a mp_int to // a bigNum is trivial as they are based on the same structure LIB_EXPORT BOOL BnModExp( @@ -316,19 +279,19 @@ BnModExp( bigConst modulus // IN: ) { - OSSL_ENTER(); - BIG_INITIALIZED(bnResult, result); - BIG_INITIALIZED(bnN, number); - BIG_INITIALIZED(bnE, exponent); - BIG_INITIALIZED(bnM, modulus); + WOLF_ENTER(); BOOL OK; -// - OK = BN_mod_exp(bnResult, bnN, bnE, bnM, CTX); + MP_INITIALIZED(bnResult, result); + MP_INITIALIZED(bnN, number); + MP_INITIALIZED(bnE, exponent); + MP_INITIALIZED(bnM, modulus); + OK = (mp_exptmod( bnN, bnE, bnM, bnResult ) == MP_OKAY); if(OK) { - OsslToTpmBn(result, bnResult); + BnFromWolf(result, bnResult); } - OSSL_LEAVE(); + + WOLF_LEAVE(); return OK; } @@ -341,137 +304,70 @@ BnModInverse( bigConst modulus ) { - OSSL_ENTER(); - BIG_INITIALIZED(bnResult, result); - BIG_INITIALIZED(bnN, number); - BIG_INITIALIZED(bnM, modulus); - BOOL OK; + WOLF_ENTER(); + BOOL OK; + MP_INITIALIZED(bnResult, result); + MP_INITIALIZED(bnN, number); + MP_INITIALIZED(bnM, modulus); - OK = (BN_mod_inverse(bnResult, bnN, bnM, CTX) != NULL); + OK = (mp_invmod(bnN, bnM, bnResult) == MP_OKAY); if(OK) { - OsslToTpmBn(result, bnResult); + BnFromWolf(result, bnResult); } - OSSL_LEAVE(); + + WOLF_LEAVE(); return OK; } #endif // TPM_ALG_RSA #ifdef TPM_ALG_ECC -//*** PointFromOssl() -// Function to copy the point result from an OSSL function to a bigNum -static BOOL -PointFromOssl( +//*** PointFromWolf() +// Function to copy the point result from a wolf ecc_point to a bigNum +void +PointFromWolf( bigPoint pOut, // OUT: resulting point - EC_POINT *pIn, // IN: the point to return - bigCurve E // IN: the curve + ecc_point *pIn // IN: the point to return ) { - BIGNUM *x = NULL; - BIGNUM *y = NULL; - BOOL OK; - BN_CTX_start(E->CTX); -// - x = BN_CTX_get(E->CTX); - y = BN_CTX_get(E->CTX); + BnFromWolf(pOut->x, pIn->x); + BnFromWolf(pOut->y, pIn->y); + BnFromWolf(pOut->z, pIn->z); +} - if(y == NULL) - FAIL(FATAL_ERROR_ALLOCATION); - // If this returns false, then the point is at infinity - OK = EC_POINT_get_affine_coordinates_GFp(E->G, pIn, x, y, E->CTX); - if(OK) - { - OsslToTpmBn(pOut->x, x); - OsslToTpmBn(pOut->y, y); - BnSetWord(pOut->z, 1); - } - else - BnSetWord(pOut->z, 0); - BN_CTX_end(E->CTX); - return OK; +//*** PointToWolf() +// Function to copy the point result from a bigNum to a wolf ecc_point +void +PointToWolf( + ecc_point *pOut, // OUT: resulting point + pointConst pIn // IN: the point to return + ) +{ + BnToWolf(pOut->x, pIn->x); + BnToWolf(pOut->y, pIn->y); + BnToWolf(pOut->z, pIn->z); } //*** EcPointInitialized() // Allocate and initialize a point. -static EC_POINT * +static ecc_point * EcPointInitialized( - pointConst initializer, - bigCurve E + pointConst initializer ) { - BIG_INITIALIZED(bnX, (initializer != NULL) ? initializer->x : NULL); - BIG_INITIALIZED(bnY, (initializer != NULL) ? initializer->y : NULL); - - EC_POINT *P = (initializer != NULL && E != NULL) - ? EC_POINT_new(E->G) : NULL; - pAssert(E != NULL); - if(P != NULL) - EC_POINT_set_affine_coordinates_GFp(E->G, P, bnX, bnY, E->CTX); - return P; -} + ecc_point *P; -//*** BnCurveInitialize() -// This function initializes the OpenSSL group definition -// -// It is a fatal error if 'groupContext' is not provided. -// return type: bigCurve * -// NULL the TPM_ECC_CURVE is not valid -// non-NULL points to a structure in 'groupContext' -bigCurve -BnCurveInitialize( - bigCurve E, // IN: curve structure to initialize - TPM_ECC_CURVE curveId // IN: curve identifier - ) -{ - EC_GROUP *group = NULL; - EC_POINT *P = NULL; - const ECC_CURVE_DATA *C = GetCurveData(curveId); - BN_CTX *CTX = NULL; - BIG_INITIALIZED(bnP, C != NULL ? C->prime : NULL); - BIG_INITIALIZED(bnA, C != NULL ? C->a : NULL); - BIG_INITIALIZED(bnB, C != NULL ? C->b : NULL); - BIG_INITIALIZED(bnX, C != NULL ? C->base.x : NULL); - BIG_INITIALIZED(bnY, C != NULL ? C->base.y : NULL); - BIG_INITIALIZED(bnN, C != NULL ? C->order : NULL); - BIG_INITIALIZED(bnH, C != NULL ? C->h : NULL); - int OK = (C != NULL); -// - OK = OK && ((CTX = OsslContextEnter()) != NULL); - - // initialize EC group, associate a generator point and initialize the point - // from the parameter data - // Create a group structure - OK = OK && (group = EC_GROUP_new_curve_GFp(bnP, bnA, bnB, CTX)) != NULL; - - // Allocate a point in the group that will be used in setting the - // generator. This is not needed after the generator is set. - OK = OK && ((P = EC_POINT_new(group)) != NULL); - // Need to use this in case Montgomery method is being used - OK = OK - && EC_POINT_set_affine_coordinates_GFp(group, P, bnX, bnY, CTX); - // Now set the generator - OK = OK && EC_GROUP_set_generator(group, P, bnN, bnH); - - if(P != NULL) - EC_POINT_free(P); - - if(!OK && group != NULL) + P = wc_ecc_new_point(); + pAssert(P != NULL); + // mp_int x,y,z are stack allocated. + // initializer is not required + if (P != NULL && initializer != NULL) { - EC_GROUP_free(group); - group = NULL; + PointToWolf( P, initializer ); } - if(!OK && CTX != NULL) - { - OsslContextLeave(CTX); - CTX = NULL; - } - - E->G = group; - E->CTX = CTX; - E->C = C; - return OK ? E : NULL; + return P; } //*** BnEccModMult() @@ -486,17 +382,28 @@ BnEccModMult( bigCurve E ) { - EC_POINT *pR = EC_POINT_new(E->G); - EC_POINT *pS = EcPointInitialized(S, E); - BIG_INITIALIZED(bnD, d); + WOLF_ENTER(); + BOOL OK; + MP_INITIALIZED(bnD, d); + MP_INITIALIZED(bnPrime, CurveGetPrime(E)); + POINT_CREATE(pS, NULL); + POINT_CREATE(pR, NULL); if(S == NULL) - EC_POINT_mul(E->G, pR, bnD, NULL, NULL, E->CTX); - else - EC_POINT_mul(E->G, pR, NULL, pS, bnD, E->CTX); - PointFromOssl(R, pR, E); - EC_POINT_free(pR); - EC_POINT_free(pS); + S = CurveGetG(AccessCurveData(E)); + + PointToWolf(pS, S); + + OK = (wc_ecc_mulmod(bnD, pS, pR, NULL, bnPrime, 1 ) == MP_OKAY); + if(OK) + { + PointFromWolf(R, pR); + } + + POINT_DELETE(pR); + POINT_DELETE(pS); + + WOLF_LEAVE(); return !BnEqualZero(R->z); } @@ -514,28 +421,31 @@ BnEccModMult2( bigCurve E // IN: curve ) { - EC_POINT *pR = EC_POINT_new(E->G); - EC_POINT *pS = EcPointInitialized(S, E); - BIG_INITIALIZED(bnD, d); - EC_POINT *pQ = EcPointInitialized(Q, E); - BIG_INITIALIZED(bnU, u); - - if(S == NULL || S == (pointConst)&E->C->base) - EC_POINT_mul(E->G, pR, bnD, pQ, bnU, E->CTX); - else + WOLF_ENTER(); + BOOL OK; + POINT_CREATE(pR, NULL); + POINT_CREATE(pS, NULL); + POINT_CREATE(pQ, Q); + MP_INITIALIZED(bnD, d); + MP_INITIALIZED(bnU, u); + MP_INITIALIZED(bnPrime, CurveGetPrime(E)); + MP_INITIALIZED(bnA, CurveGet_a(E)); + + if(S == NULL) + S = CurveGetG(AccessCurveData(E)); + PointToWolf( pS, S ); + + OK = (ecc_mul2add(pS, bnD, pQ, bnU, pR, bnA, bnPrime, NULL) == MP_OKAY); + if(OK) { - const EC_POINT *points[2]; - const BIGNUM *scalars[2]; - points[0] = pS; - points[1] = pQ; - scalars[0] = bnD; - scalars[1] = bnU; - EC_POINTs_mul(E->G, pR, NULL, 2, points, scalars, E->CTX); + PointFromWolf(R, pR); } - PointFromOssl(R, pR, E); - EC_POINT_free(pR); - EC_POINT_free(pS); - EC_POINT_free(pQ); + + POINT_DELETE(pS); + POINT_DELETE(pQ); + POINT_DELETE(pR); + + WOLF_LEAVE(); return !BnEqualZero(R->z); } @@ -551,16 +461,27 @@ BnEccAdd( bigCurve E // IN: curve ) { - EC_POINT *pR = EC_POINT_new(E->G); - EC_POINT *pS = EcPointInitialized(S, E); - EC_POINT *pQ = EcPointInitialized(Q, E); + WOLF_ENTER(); + BOOL OK; + mp_digit mp; + POINT_CREATE(pR, NULL); + POINT_CREATE(pS, S); + POINT_CREATE(pQ, Q); + MP_INITIALIZED(bnA, CurveGet_a(E)); + MP_INITIALIZED(bnMod, CurveGetPrime(E)); // - EC_POINT_add(E->G, pR, pS, pQ, E->CTX); + OK = (mp_montgomery_setup(bnMod, &mp) == MP_OKAY); + OK = OK && (ecc_projective_add_point(pS, pQ, pR, bnA, bnMod, mp ) == MP_OKAY); + if(OK) + { + PointFromWolf(R, pR); + } + + POINT_DELETE(pS); + POINT_DELETE(pQ); + POINT_DELETE(pR); - PointFromOssl(R, pR, E); - EC_POINT_free(pR); - EC_POINT_free(pS); - EC_POINT_free(pQ); + WOLF_LEAVE(); return !BnEqualZero(R->z); } diff --git a/TPMCmd/tpm/src/crypt/wolf/TpmToWolfSupport.c b/TPMCmd/tpm/src/crypt/wolf/TpmToWolfSupport.c index 542058b..194ac44 100644 --- a/TPMCmd/tpm/src/crypt/wolf/TpmToWolfSupport.c +++ b/TPMCmd/tpm/src/crypt/wolf/TpmToWolfSupport.c @@ -36,7 +36,7 @@ //** Introduction // // The functions in this file are used for initialization of the interface to the -// OpenSSL library. +// wolfSSL library. //** Defines and Includes @@ -44,9 +44,6 @@ #if MATH_LIB == WOLF -// Used to pass the pointers to the correct sub-keys -typedef const BYTE *desKeyPointers[3]; - //*** SupportLibInit() // This does any initialization required by the support library. LIB_EXPORT int @@ -60,33 +57,5 @@ SupportLibInit( 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 *context = BN_CTX_new(); - if(context == NULL) - FAIL(FATAL_ERROR_ALLOCATION); - BN_CTX_start(context); - return context; -} - -//*** OsslContextLeave() -// This is the companion function to OsslContextEnter(). -void -OsslContextLeave( - BN_CTX *context - ) -{ - if(context != NULL) - { - BN_CTX_end(context); - BN_CTX_free(context); - } -} #endif // MATH_LIB == WOLF diff --git a/TPMCmd/wolfcrypt/include/user_settings.h b/TPMCmd/wolfcrypt/include/user_settings.h new file mode 100644 index 0000000..4210798 --- /dev/null +++ b/TPMCmd/wolfcrypt/include/user_settings.h @@ -0,0 +1,95 @@ +/* settings.h + * + * Copyright (C) 2006-2017 wolfSSL Inc. + * + * This file is part of wolfSSL. + * + * wolfSSL is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * wolfSSL is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA + */ + + +/* Place OS specific preprocessor flags, defines, includes here, will be + included into every file because types.h includes it */ + + +#ifndef WOLF_CRYPT_USER_SETTINGS_H +#define WOLF_CRYPT_USER_SETTINGS_H + +#include + +#ifdef __cplusplus + extern "C" { +#endif + +/* Remove the automatic setting of the default I/O functions EmbedSend() + and EmbedReceive(). */ +#define WOLFSSL_USER_IO + +/* Avoid naming conflicts */ +#define NO_OLD_WC_NAMES + +/* Use stack based fast math for all big integer math */ +#define USE_FAST_MATH +#define TFM_TIMING_RESISTANT + +/* Expose direct encryption functions */ +#define WOLFSSL_AES_DIRECT + +/* Enable/Disable algorithm support based on TPM implementation header */ +#ifdef TPM_ALG_SHA256 + #define WOLFSSL_SHA256 +#endif +#if defined(TPM_ALG_SHA384) || defined(TPM_ALG_SHA512) + #define WOLFSSL_SHA384 + #define WOLFSSL_SHA512 +#endif +#ifdef TPM_ALG_TDES + #define WOLFSSL_DES_ECB +#endif +#ifdef TPM_ALG_RSA + /* Turn on RSA key generation functionality */ + #define WOLFSSL_KEY_GEN +#endif +#ifdef TPM_ALG_ECC + #define HAVE_ECC + + /* Expose additional ECC primitives */ + #define WOLFSSL_PUBLIC_ECC_ADD_DBL + #define ECC_TIMING_RESISTANT + + /* Enables Shamir calc method */ + #define ECC_SHAMIR + + /* The TPM only needs low level ECC crypto */ + #define NO_ECC_SIGN + #define NO_ECC_VERIFY + #define NO_ECC_SECP +#endif + +/* Disable explicit RSA. The TPM support for RSA is dependent only on TFM */ +#define NO_RSA +#define NO_RC4 +#define NO_ASN + +/* Enable debug wolf library check */ +//#define LIBRARY_COMPATIBILITY_CHECK + +#define WOLFSSL_ + +#ifdef __cplusplus + } /* extern "C" */ +#endif + +#endif diff --git a/TPMCmd/wolfcrypt/wolfssl.vcxproj b/TPMCmd/wolfcrypt/wolfssl.vcxproj new file mode 100644 index 0000000..784234f --- /dev/null +++ b/TPMCmd/wolfcrypt/wolfssl.vcxproj @@ -0,0 +1,192 @@ + + + + + Coverage + Win32 + + + Coverage + x64 + + + WolfDebug + Win32 + + + WolfDebug + x64 + + + WolfRelease + Win32 + + + WolfRelease + x64 + + + + {73973223-5EE8-41CA-8E88-1D60E89A237B} + wolfssl + Win32Proj + 10.0.16299.0 + $(ProjectDir)..\..\external\wolfssl\ + + + + StaticLibrary + v141 + Unicode + true + + + StaticLibrary + v141 + Unicode + true + + + StaticLibrary + v141 + Unicode + + + StaticLibrary + v141 + Unicode + + + StaticLibrary + v141 + Unicode + + + StaticLibrary + v141 + Unicode + + + + + + + + + + + + + + + + + + + + + + + + + $(SolutionDir)\$(Configuration)\ + $(SolutionDir)\bin\$(ProjectName)\$(PlatformTarget)\$(Configuration)\ + $(VC_IncludePath);$(WindowsSDK_IncludePath);$(WolfRootDir);$(ProjectDir)\include + + + + WOLFSSL_LIB;WOLFSSL_USER_SETTINGS;CYASSL_USER_SETTINGS;%(PreprocessorDefinitions) + + + + + Disabled + true + EnableFastChecks + MultiThreadedDebugDLL + + Level4 + EditAndContinue + 4206;4214;4706;%(DisableSpecificWarnings) + $(SolutionDir)\tpm\include;%(AdditionalIncludeDirectories) + + + + + Disabled + true + EnableFastChecks + MultiThreadedDebugDLL + + + Level4 + EditAndContinue + 4206;4214;4706;%(DisableSpecificWarnings) + $(SolutionDir)\tpm\include;%(AdditionalIncludeDirectories) + + + + + Disabled + EnableFastChecks + MultiThreadedDebugDLL + + + Level4 + ProgramDatabase + 4206;4214;4706;%(DisableSpecificWarnings) + + + + + Disabled + EnableFastChecks + MultiThreadedDebugDLL + + + Level4 + ProgramDatabase + 4206;4214;4706;%(DisableSpecificWarnings) + + + + + MaxSpeed + true + MultiThreadedDLL + true + + Level3 + ProgramDatabase + $(SolutionDir)\tpm\include;%(AdditionalIncludeDirectories) + + + + + MaxSpeed + true + MultiThreadedDLL + true + + + Level3 + ProgramDatabase + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/external/wolfssl b/external/wolfssl index 8285042..74ebf51 160000 --- a/external/wolfssl +++ b/external/wolfssl @@ -1 +1 @@ -Subproject commit 82850422fc77dc49a2a423fdcbf0c3559b27add0 +Subproject commit 74ebf510a3d73e98767eac26082eabdc84e19d31 -- cgit v1.2.3