From cd65a0b49df3dbf3bff66b1c5c183cc722754910 Mon Sep 17 00:00:00 2001 From: Helio Chissini de Castro Date: Mon, 27 Jan 2020 16:09:40 +0100 Subject: [PATCH 01/15] CMake buildsystem overhaul - Linux * Build with gcc and clang * Install systemd simple service in case of Linux * Use GNUInstallDirs as regular Linux FSB paths install Signed-off-by: Helio Chissini de Castro --- CMakeLists.txt | 16 ++++ src/CMakeLists.txt | 158 ++++++++++++++++++++++++++++++++++++ utils/CMakeLists.txt | 6 ++ utils/tpm_server.service.in | 8 ++ 4 files changed, 188 insertions(+) create mode 100644 CMakeLists.txt create mode 100644 src/CMakeLists.txt create mode 100644 utils/CMakeLists.txt create mode 100644 utils/tpm_server.service.in diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..4f0b287 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 3.12) + +project(ibmswtpm2 VERSION 1563 LANGUAGES C) + +include (GNUInstallDirs) +include(TestBigEndian) + +set(CMAKE_POSITION_INDEPENDENT_CODE ON) + +find_package(OpenSSL REQUIRED) +if(UNIX) + find_package(Threads REQUIRED) +endif() + +add_subdirectory(src) +add_subdirectory(utils) \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..8498e11 --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,158 @@ +test_big_endian(BIG_ENDIAN) + +add_executable(tpm_server + ACTCommands.c + ACT_spt.c + AlgorithmCap.c + AlgorithmTests.c + AsymmetricCommands.c + Attest_spt.c + AttestationCommands.c + AuditCommands.c + Bits.c + BnConvert.c + BnMath.c + BnMemory.c + Cancel.c + CapabilityCommands.c + Clock.c + ClockCommands.c + CommandAudit.c + CommandCodeAttributes.c + CommandDispatcher.c + ContextCommands.c + Context_spt.c + CryptDes.c + CryptCmac.c + CryptEccData.c + CryptEccKeyExchange.c + CryptEccMain.c + CryptEccSignature.c + CryptHash.c + CryptPrime.c + CryptPrimeSieve.c + CryptRand.c + CryptRsa.c + CryptSelfTest.c + CryptSmac.c + CryptSym.c + CryptUtil.c + DA.c + DebugHelpers.c + DictionaryCommands.c + DuplicationCommands.c + EACommands.c + EncryptDecrypt_spt.c + Entity.c + Entropy.c + EphemeralCommands.c + ExecCommand.c + Global.c + Handle.c + HashCommands.c + Hierarchy.c + HierarchyCommands.c + IoBuffers.c + IntegrityCommands.c + Locality.c + LocalityPlat.c + ManagementCommands.c + Manufacture.c + Marshal.c + MathOnByteBuffers.c + Memory.c + NVCommands.c + NVDynamic.c + NVMem.c + NVReserved.c + NV_spt.c + Object.c + ObjectCommands.c + Object_spt.c + PCR.c + PP.c + PPPlat.c + PlatformACT.c + PlatformData.c + Policy_spt.c + Power.c + PowerPlat.c + PrimeData.c + PropertyCap.c + RandomCommands.c + Response.c + ResponseCodeProcessing.c + RsaKeyCache.c + RunCommand.c + Session.c + SessionCommands.c + SessionProcess.c + SigningCommands.c + StartupCommands.c + SymmetricCommands.c + TPMCmdp.c + TPMCmds.c + TestingCommands.c + Ticket.c + Time.c + TpmAsn1.c + TpmFail.c + TpmSizeChecks.c + TpmToOsslDesSupport.c + TpmToOsslMath.c + TpmToOsslSupport.c + Unique.c + Unmarshal.c + Vendor_TCG_Test.c + X509_ECC.c + X509_RSA.c + X509_spt.c + ntc2lib.c + ntc2.c + $<$:TcpServerPosix.c> + $<$:applink.c> +) + +target_compile_definitions(tpm_server + PRIVATE + # Unix defines + $<$:_POSIX_> + $<$:TPM_NUVOTON> + $<$:TPM_POSIX> + # Big endian + $<$:BIG_ENDIAN_TPM=YES> + # Common + USE_BIT_FIELD_STRUCTURES=NO +) + +# Common compile options +target_compile_options(tpm_server + PRIVATE + -Wall + -Wnested-externs +) + +if(UNIX) + target_compile_options(tpm_server + PRIVATE + -Werror + -Wmissing-declarations + -Wmissing-prototypes + -Wsign-compare + ) +endif() + +target_include_directories(tpm_server + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR} +) + +target_link_libraries(tpm_server + PRIVATE + OpenSSL::Crypto + $<$:Threads::Threads> +) + +install(TARGETS tpm_server + RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR} +) diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt new file mode 100644 index 0000000..642e1fe --- /dev/null +++ b/utils/CMakeLists.txt @@ -0,0 +1,6 @@ +# Install systemd files for server if running on Linux +if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") + configure_file(tpm_server.service.in tpm_server.service @ONLY) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/tpm_server.service + DESTINATION ${CMAKE_INSTALL_FULL_SYSCONFDIR}/systemd/system/) +endif() diff --git a/utils/tpm_server.service.in b/utils/tpm_server.service.in new file mode 100644 index 0000000..3429957 --- /dev/null +++ b/utils/tpm_server.service.in @@ -0,0 +1,8 @@ +[Unit] +Description=Implementation of the TCG TPM 2.0 specification + +[Service] +ExecStart=@CMAKE_INSTALL_FULL_SBINDIR@/tpm_server + +[Install] +WantedBy=multi-user.target From 79b077e5c42ee59c0bf39c1e0406fc1e615237fe Mon Sep 17 00:00:00 2001 From: Helio Chissini de Castro Date: Mon, 27 Jan 2020 16:14:46 +0100 Subject: [PATCH 02/15] Fix warning for macro expansion producing 'defined' has undefined behavior' gcc still hide this but clang9 is explicitly on the error --- src/CryptHash.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/CryptHash.h b/src/CryptHash.h index de9a060..adec8ab 100644 --- a/src/CryptHash.h +++ b/src/CryptHash.h @@ -88,7 +88,11 @@ typedef struct sequenceMethods { SMAC_DATA_METHOD data; SMAC_END_METHOD end; } SMAC_METHODS; -#define SMAC_IMPLEMENTED (defined CC_MAC || defined CC_MAC_Start) +#if (defined CC_MAC || defined CC_MAC_Start) +#define SMAC_IMPLEMENTED 1 +#else +#define SMAC_IMPLEMENTED 0 +#endif /* These definitions are here because the SMAC state is in the union of hash states. */ From 23ecdf24333ff9cecb7de56d96d2076f4858c196 Mon Sep 17 00:00:00 2001 From: Helio Chissini de Castro Date: Mon, 27 Jan 2020 16:28:33 +0100 Subject: [PATCH 03/15] Silence warning for unused variables. Use (void) as a portable solution instead of equal, which breaks clang compilation. --- src/Marshal.c | 7 ++++--- src/Unmarshal.c | 9 +++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/Marshal.c b/src/Marshal.c index cd6f3ec..a6181f1 100644 --- a/src/Marshal.c +++ b/src/Marshal.c @@ -1382,9 +1382,10 @@ TPMS_ENC_SCHEME_OAEP_Marshal(TPMS_ENC_SCHEME_OAEP *source, BYTE **buffer, INT32 UINT16 TPMS_ENC_SCHEME_RSAES_Marshal(TPMS_ENC_SCHEME_RSAES *source, BYTE **buffer, INT32 *size) { - source = source; - buffer = buffer; - size = size; + (void)source; + (void)buffer; + (void)size; + return 0; } diff --git a/src/Unmarshal.c b/src/Unmarshal.c index 2143ef9..218518b 100644 --- a/src/Unmarshal.c +++ b/src/Unmarshal.c @@ -767,7 +767,7 @@ TPM_RC TPMI_DH_SAVED_Unmarshal(TPMI_DH_SAVED *target, BYTE **buffer, INT32 *size, BOOL allowNull) { TPM_RC rc = TPM_RC_SUCCESS; - allowNull = allowNull; + (void)allowNull; if (rc == TPM_RC_SUCCESS) { rc = TPM_HANDLE_Unmarshal(target, buffer, size); @@ -1466,9 +1466,10 @@ TPM_RC TPMS_EMPTY_Unmarshal(TPMS_EMPTY *target, BYTE **buffer, INT32 *size) { TPM_RC rc = TPM_RC_SUCCESS; - target = target; - buffer = buffer; - size = size; + (void)target; + (void)buffer; + (void)size; + return rc; } From dd0dbf4d1e23ae1f0b172e8dbf7eb11e8e613dc3 Mon Sep 17 00:00:00 2001 From: Helio Chissini de Castro Date: Thu, 30 Jan 2020 09:07:08 +0100 Subject: [PATCH 04/15] CMake buildsystem overhaul - Mac * Build with XCode, gcc and clang compilers * Use GNUInstallDirs as regular FSB paths install Signed-off-by: Helio Chissini de Castro --- CMakeLists.txt | 5 +++++ conanfile.txt | 5 +++++ 2 files changed, 10 insertions(+) create mode 100644 conanfile.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 4f0b287..021e5b3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,6 +5,11 @@ project(ibmswtpm2 VERSION 1563 LANGUAGES C) include (GNUInstallDirs) include(TestBigEndian) +if(APPLE) + include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) + conan_basic_setup() +endif() + set(CMAKE_POSITION_INDEPENDENT_CODE ON) find_package(OpenSSL REQUIRED) diff --git a/conanfile.txt b/conanfile.txt new file mode 100644 index 0000000..d4e2417 --- /dev/null +++ b/conanfile.txt @@ -0,0 +1,5 @@ + [requires] + openssl/1.1.1d + + [generators] + cmake \ No newline at end of file From 812fe2d6c5bf1b6bbed773177620780352f3b205 Mon Sep 17 00:00:00 2001 From: Helio Chissini de Castro Date: Thu, 30 Jan 2020 09:07:08 +0100 Subject: [PATCH 05/15] CMake buildsystem overhaul - Mac * Build with XCode, gcc and clang compilers * Use GNUInstallDirs as regular FSB paths install Signed-off-by: Helio Chissini de Castro --- CMakeLists.txt | 5 +++++ conanfile.txt | 5 +++++ 2 files changed, 10 insertions(+) create mode 100644 conanfile.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 4f0b287..021e5b3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,6 +5,11 @@ project(ibmswtpm2 VERSION 1563 LANGUAGES C) include (GNUInstallDirs) include(TestBigEndian) +if(APPLE) + include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) + conan_basic_setup() +endif() + set(CMAKE_POSITION_INDEPENDENT_CODE ON) find_package(OpenSSL REQUIRED) diff --git a/conanfile.txt b/conanfile.txt new file mode 100644 index 0000000..d4e2417 --- /dev/null +++ b/conanfile.txt @@ -0,0 +1,5 @@ + [requires] + openssl/1.1.1d + + [generators] + cmake \ No newline at end of file From 4d92a2a079f9b5fd01482f4f201ad661154b89b3 Mon Sep 17 00:00:00 2001 From: Helio Chissini de Castro Date: Thu, 30 Jan 2020 09:14:11 +0100 Subject: [PATCH 06/15] Add .gitignore Signed-off-by: Helio Chissini de Castro --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e7bc5e9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +build +.vscode +*.o From 52b697feb07257cf826e5e3ec5d25befdb192894 Mon Sep 17 00:00:00 2001 From: Helio Chissini de Castro Date: Mon, 3 Feb 2020 20:55:40 +0100 Subject: [PATCH 07/15] Update README.md Signed-off-by: Helio Chissini de Castro --- README.md | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/README.md b/README.md index c2ca143..3e3fe86 100644 --- a/README.md +++ b/README.md @@ -2,3 +2,69 @@ This project is an implementation of the TCG TPM 2.0 specification. It is based on the TPM specification Parts 3 and 4 source code donated by Microsoft, with additional files to complete the implementation. See the companion IBM TSS at https://sourceforge.net/projects/ibmtpm20tss/ + +# ibmswtpm2 +This project is an implementation of the TCG TPM 2.0 specification. It is based on the TPM specification Parts 3 and 4 source code donated by Microsoft, with additional files to complete the implementation. + +See the companion IBM TSS at https://sourceforge.net/projects/ibmtpm20tss/ + +# Building +## Dependencies +* For all platforms +* * cmake - http://cmake.org +* * openssl ( See conan instructions for Mac and Windows easy deps ) +* Mac ( XCode and brew clang/gcc ) and Windows ( MSVC ) +* * conan - http://conan.io + +## Easy openssl dependency for Mac and Windows with Conan +* After install conan do: +``` +mkdir build +cd build +conan profile new default --detect +conan install .. +``` +On Windows Conan has preset binary dependencies for openssl 64 bits and MSVC 16 and up +If you get an error of non availability of openssl for your old MSVC build, you can execute +``` +conan install .. --build * +``` +This will rebuild the dependencies for your compiler + +## Simple build instructions for Linux and Mac +Building is straightforward, as long you installed all dependencies: +``` +mkdir build +cd build +cmake .. +make +``` + +## Simple build instructions for Windows Visual Studio +Build for Windows Visual Studio must be "almost" straightforward. +Builds are tested with MSVC +``` +mkdir build +cmake -DCMAKE_BUILD_TYPE=Release .. +cmake --build . +``` + +## Install +* Linux +On Linux, binary is installed in default sbin dir and an extra systemd service file is installed to start and stop the service. +No firewall exclusion files are included, so remember to open the required ports + +* Mac and Windows +Install works, but only mac is guaranteed to end up in proper path + +# Troubleshoot + +## Windows has symbols / 32/64 bits mismatch +Only 64 bits compilations are tested with conan deps. If you installed openssl by your own, some possible issues: +* Your compiler is 64 bits and you have 32 bits deps, configure this way: +``` +cmake -DCMAKE_BUILD_TYPE=Release -A win32 .. +``` + +## Mac You are using gcc or clang from Homebrew,ad Connan detected XCode Clang as default compiler +* Read profile section of Conan - https://docs.conan.io/en/latest/reference/profiles.html From a6847e619937d530509ce5e33f8d59eed8b3121e Mon Sep 17 00:00:00 2001 From: Helio Chissini de Castro Date: Mon, 3 Feb 2020 20:56:08 +0100 Subject: [PATCH 08/15] Remove duplicate entries Signed-off-by: Helio Chissini de Castro --- README.md | 5 ----- 1 file changed, 5 deletions(-) diff --git a/README.md b/README.md index 3e3fe86..b0213a7 100644 --- a/README.md +++ b/README.md @@ -3,11 +3,6 @@ This project is an implementation of the TCG TPM 2.0 specification. It is based See the companion IBM TSS at https://sourceforge.net/projects/ibmtpm20tss/ -# ibmswtpm2 -This project is an implementation of the TCG TPM 2.0 specification. It is based on the TPM specification Parts 3 and 4 source code donated by Microsoft, with additional files to complete the implementation. - -See the companion IBM TSS at https://sourceforge.net/projects/ibmtpm20tss/ - # Building ## Dependencies * For all platforms From 2b4dc66e5fad36833fbc851a818e01b9a2e4929b Mon Sep 17 00:00:00 2001 From: Helio Chissini de Castro Date: Mon, 3 Feb 2020 20:58:39 +0100 Subject: [PATCH 09/15] Cmake buildsystem overhaul - Windows Signed-off-by: Helio Chissini de Castro --- CMakeLists.txt | 2 +- src/CMakeLists.txt | 29 ++++++++++++++++++++--------- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 021e5b3..8214439 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,7 +5,7 @@ project(ibmswtpm2 VERSION 1563 LANGUAGES C) include (GNUInstallDirs) include(TestBigEndian) -if(APPLE) +if(APPLE OR MSVC) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) conan_basic_setup() endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8498e11..5b82e91 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -110,6 +110,7 @@ add_executable(tpm_server ntc2lib.c ntc2.c $<$:TcpServerPosix.c> + $<$:TcpServer.c> $<$:applink.c> ) @@ -117,28 +118,35 @@ target_compile_definitions(tpm_server PRIVATE # Unix defines $<$:_POSIX_> - $<$:TPM_NUVOTON> $<$:TPM_POSIX> + # Windows defines + $<$:WIN32> + $<$:TPM_WINDOWS> + $<$:_CRT_SECURE_NO_WARNINGS> + $<$>:NO_FAIL_TRACE> # Big endian $<$:BIG_ENDIAN_TPM=YES> # Common USE_BIT_FIELD_STRUCTURES=NO + TPM_NUVOTON ) -# Common compile options -target_compile_options(tpm_server - PRIVATE - -Wall - -Wnested-externs -) - -if(UNIX) +if(UNIX OR MINGW) target_compile_options(tpm_server PRIVATE + -Wall -Werror -Wmissing-declarations -Wmissing-prototypes -Wsign-compare + -Wnested-externs + ) +else(MSVC) + target_compile_options(tpm_server + PRIVATE + /W3 + # Enable if you want warning as error + # /WX ) endif() @@ -151,6 +159,9 @@ target_link_libraries(tpm_server PRIVATE OpenSSL::Crypto $<$:Threads::Threads> + $<$:wsock32> + $<$:ws2_32> + $<$:crypt32> ) install(TARGETS tpm_server From a4eaae1c7ca174945991cae14c6b106b08d9e81d Mon Sep 17 00:00:00 2001 From: Helio Chissini de Castro Date: Fri, 7 Feb 2020 11:05:30 +0100 Subject: [PATCH 10/15] Using AND with CONFIG in generators cause Linux build to break since CONFIG is undefined. Using Double BOOL checking solution Signed-off-by: Helio Chissini de Castro --- src/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5b82e91..858901e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -123,7 +123,7 @@ target_compile_definitions(tpm_server $<$:WIN32> $<$:TPM_WINDOWS> $<$:_CRT_SECURE_NO_WARNINGS> - $<$>:NO_FAIL_TRACE> + $<$:$:NO_FAIL_TRACE>> # Big endian $<$:BIG_ENDIAN_TPM=YES> # Common From 77cf951ae21cf10b3aa19f76320b3120e5c8c8fa Mon Sep 17 00:00:00 2001 From: Helio Chissini de Castro Date: Sun, 9 Feb 2020 22:50:19 +0100 Subject: [PATCH 11/15] * Add appveyor configuration * Better Windows flag detection * WIP: Move conan stup for a cmake instructions to be better automatized. Signed-off-by: Helio Chissini de Castro --- CMakeLists.txt | 5 +- appveyor.yml | 17 + cmake/ConanAutoSetup.cmake | 2 + src/CMakeLists.txt | 8 +- tpmvstudio/tpm_server/tpm_server.sln | 20 - tpmvstudio/tpm_server/tpm_server.vcxproj | 208 ----------- .../tpm_server/tpm_server.vcxproj.filters | 349 ------------------ 7 files changed, 26 insertions(+), 583 deletions(-) create mode 100644 appveyor.yml create mode 100644 cmake/ConanAutoSetup.cmake delete mode 100644 tpmvstudio/tpm_server/tpm_server.sln delete mode 100644 tpmvstudio/tpm_server/tpm_server.vcxproj delete mode 100644 tpmvstudio/tpm_server/tpm_server.vcxproj.filters diff --git a/CMakeLists.txt b/CMakeLists.txt index 8214439..81214c4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,12 +2,13 @@ cmake_minimum_required(VERSION 3.12) project(ibmswtpm2 VERSION 1563 LANGUAGES C) +list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) + include (GNUInstallDirs) include(TestBigEndian) if(APPLE OR MSVC) - include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) - conan_basic_setup() + include(ConanAutoSetup) endif() set(CMAKE_POSITION_INDEPENDENT_CODE ON) diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 0000000..951c958 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,17 @@ +version: 1.0.{build} +image: Visual Studio 2019 +verbosity: normal + +install: +- cmd: echo "Downloading conan..." +- cmd: set PATH=%PATH%;%PYTHON%/Scripts/ +- cmd: pip.exe install conan +- cmd: conan user # Create the conan data directory +- cmd: conan --version + +build_script: +- cmd: mkdir build +- cmd: cd build +- cmd: conan install .. --build=missing +- cmd: cmake .. +- cmd: cmake --build . --config Release diff --git a/cmake/ConanAutoSetup.cmake b/cmake/ConanAutoSetup.cmake new file mode 100644 index 0000000..0ccf11c --- /dev/null +++ b/cmake/ConanAutoSetup.cmake @@ -0,0 +1,2 @@ +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 858901e..dce6926 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -120,10 +120,10 @@ target_compile_definitions(tpm_server $<$:_POSIX_> $<$:TPM_POSIX> # Windows defines - $<$:WIN32> - $<$:TPM_WINDOWS> - $<$:_CRT_SECURE_NO_WARNINGS> - $<$:$:NO_FAIL_TRACE>> + $<$:WIN32> + $<$:TPM_WINDOWS> + $<$:_CRT_SECURE_NO_WARNINGS> + $<$,$>:NO_FAIL_TRACE> # Big endian $<$:BIG_ENDIAN_TPM=YES> # Common diff --git a/tpmvstudio/tpm_server/tpm_server.sln b/tpmvstudio/tpm_server/tpm_server.sln deleted file mode 100644 index 4e6c6bd..0000000 --- a/tpmvstudio/tpm_server/tpm_server.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Express 2012 for Windows Desktop -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tpm_server", "tpm_server.vcxproj", "{6DC26888-4343-4B0F-8A56-4B026B4B20F3}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {6DC26888-4343-4B0F-8A56-4B026B4B20F3}.Debug|Win32.ActiveCfg = Debug|Win32 - {6DC26888-4343-4B0F-8A56-4B026B4B20F3}.Debug|Win32.Build.0 = Debug|Win32 - {6DC26888-4343-4B0F-8A56-4B026B4B20F3}.Release|Win32.ActiveCfg = Release|Win32 - {6DC26888-4343-4B0F-8A56-4B026B4B20F3}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/tpmvstudio/tpm_server/tpm_server.vcxproj b/tpmvstudio/tpm_server/tpm_server.vcxproj deleted file mode 100644 index ecf2d11..0000000 --- a/tpmvstudio/tpm_server/tpm_server.vcxproj +++ /dev/null @@ -1,208 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {6DC26888-4343-4B0F-8A56-4B026B4B20F3} - Win32Proj - tpm_server - 10.0.17763.0 - - - - Application - true - v141 - Unicode - - - Application - false - v141 - true - Unicode - - - - - - - - - - - - - true - - - false - - - - - - Level3 - Disabled - WIN32;TPM_WINDOWS;_CRT_SECURE_NO_WARNINGS;USE_BIT_FIELD_STRUCTURES=NO;TPM_NUVOTON - c:/program files/openssl/include;%(AdditionalIncludeDirectories) - false - false - - - Console - true - libcrypto32mdd.lib;ws2_32.lib;%(AdditionalDependencies) - c:\program files\openssl\lib\vc;%(AdditionalLibraryDirectories) - - - - - Level3 - - - MaxSpeed - true - true - WIN32;TPM_WINDOWS;_CRT_SECURE_NO_WARNINGS;USE_BIT_FIELD_STRUCTURES=NO;TPM_NUVOTON - c:/program files/openssl/include;%(AdditionalIncludeDirectories) - false - false - - - Console - true - true - true - libcrypto32md.lib;ws2_32.lib;%(AdditionalDependencies) - c:\program files\openssl\lib\vc;%(AdditionalLibraryDirectories) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - false - - - - - - - - - - \ No newline at end of file diff --git a/tpmvstudio/tpm_server/tpm_server.vcxproj.filters b/tpmvstudio/tpm_server/tpm_server.vcxproj.filters deleted file mode 100644 index 510456a..0000000 --- a/tpmvstudio/tpm_server/tpm_server.vcxproj.filters +++ /dev/null @@ -1,349 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - \ No newline at end of file From 365ab8f70aaa5e7fc5f49d0e0a0a0b31fed2f1f1 Mon Sep 17 00:00:00 2001 From: Helio Chissini de Castro Date: Mon, 10 Feb 2020 14:23:31 +0100 Subject: [PATCH 12/15] Rem,oved invalid appveyor verbosity entry Signed-off-by: Helio Chissini de Castro --- appveyor.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 951c958..7979f21 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,6 +1,5 @@ version: 1.0.{build} image: Visual Studio 2019 -verbosity: normal install: - cmd: echo "Downloading conan..." From 4e56681dfb00d8dac99a71a08d7ae6cc546de201 Mon Sep 17 00:00:00 2001 From: Helio Chissini de Castro Date: Mon, 10 Feb 2020 15:44:26 +0100 Subject: [PATCH 13/15] * Debian package Signed-off-by: Helio Chissini de Castro --- .gitignore | 2 ++ debian/changelog | 4 ++++ debian/control | 19 +++++++++++++++++++ debian/rules | 9 +++++++++ src/CMakeLists.txt | 1 + utils/CMakeLists.txt | 2 +- 6 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 debian/changelog create mode 100644 debian/control create mode 100755 debian/rules diff --git a/.gitignore b/.gitignore index e7bc5e9..ee2fe8d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ build .vscode *.o +*.debhelper.log +obj-x86_64-linux-gnu diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..fb84c72 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,4 @@ +ibmswtpm2 (0.1.1563) unstable; urgency=low + * First cmake port release + + -- Helio Chissini de Castro Mon, 10 Feb 2020 20:20:00 +0100 \ No newline at end of file diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..835287a --- /dev/null +++ b/debian/control @@ -0,0 +1,19 @@ +Source: ibmswtpm2 +Maintainer: Helio Chissini de Castro +Description: TPM2 Simulator +Priority: optional +Homepage: https://github.com/heliocastro/ibmswtpm2 +Build-Depends: cmake (>= 3.0~), + libssl-dev (>= 1.1.0~), + debhelper-compat (= 12) +Section: Miscellaneous +Rules-Requires-Root: no +Standards-Version: 4.4.0 + +Package: tpm-server +Architecture: any +Section: Miscellaneous +Depends: ${misc:Depends}, ${shlibs:Depends} +Description: This project is an implementation of the TCG TPM 2.0 specification. + It is based on the TPM specification Parts 3 and 4 source code + donated by Microsoft, with additional files to complete the implementation. \ No newline at end of file diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..96ac203 --- /dev/null +++ b/debian/rules @@ -0,0 +1,9 @@ +#!/usr/bin/make -f + +export DH_VERBOSE = 1 + +%: + dh $@ + +#override_dh_auto_install: +# dh_auto_install -- prefix=/usr diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index dce6926..dcb810d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -140,6 +140,7 @@ if(UNIX OR MINGW) -Wmissing-prototypes -Wsign-compare -Wnested-externs + $<$:-fno-strict-aliasing> ) else(MSVC) target_compile_options(tpm_server diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt index 642e1fe..bf65eda 100644 --- a/utils/CMakeLists.txt +++ b/utils/CMakeLists.txt @@ -2,5 +2,5 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") configure_file(tpm_server.service.in tpm_server.service @ONLY) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/tpm_server.service - DESTINATION ${CMAKE_INSTALL_FULL_SYSCONFDIR}/systemd/system/) + DESTINATION /lib/systemd/system ) endif() From 8faa44150fa954d92b17530e27380e78a71a8754 Mon Sep 17 00:00:00 2001 From: Helio Chissini de Castro Date: Tue, 11 Feb 2020 14:53:12 +0100 Subject: [PATCH 14/15] Initialize empty member. Signed-off-by: Helio Chissini de Castro --- src/TcpServer.c | 2 +- src/TcpServerPosix.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/TcpServer.c b/src/TcpServer.c index 9d0163e..25fcc7f 100644 --- a/src/TcpServer.c +++ b/src/TcpServer.c @@ -220,7 +220,7 @@ PlatformServer( break; case TPM_ACT_GET_SIGNALED: { - UINT32 actHandle; + UINT32 actHandle = 0; OK = ReadUINT32(s, &actHandle); WriteUINT32(s, _rpc__ACT_GetSignaled(actHandle)); break; diff --git a/src/TcpServerPosix.c b/src/TcpServerPosix.c index 20fcb29..ac87fa6 100644 --- a/src/TcpServerPosix.c +++ b/src/TcpServerPosix.c @@ -276,7 +276,7 @@ PlatformServer( break; case TPM_ACT_GET_SIGNALED: { - UINT32 actHandle; + UINT32 actHandle = 0; ok = ReadUINT32(s, &actHandle); WriteUINT32(s, _rpc__ACT_GetSignaled(actHandle)); break; From b208d1c2db14ada22966aeadf660c803a88de6af Mon Sep 17 00:00:00 2001 From: Helio Chissini de Castro Date: Tue, 11 Feb 2020 15:06:47 +0100 Subject: [PATCH 15/15] Add back original msvc solution files wiped by mistake Signed-off-by: Helio Chissini de Castro --- tpmvstudio/tpm_server/tpm_server.sln | 20 + tpmvstudio/tpm_server/tpm_server.vcxproj | 208 +++++++++++ .../tpm_server/tpm_server.vcxproj.filters | 349 ++++++++++++++++++ 3 files changed, 577 insertions(+) create mode 100644 tpmvstudio/tpm_server/tpm_server.sln create mode 100644 tpmvstudio/tpm_server/tpm_server.vcxproj create mode 100644 tpmvstudio/tpm_server/tpm_server.vcxproj.filters diff --git a/tpmvstudio/tpm_server/tpm_server.sln b/tpmvstudio/tpm_server/tpm_server.sln new file mode 100644 index 0000000..4e6c6bd --- /dev/null +++ b/tpmvstudio/tpm_server/tpm_server.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Express 2012 for Windows Desktop +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tpm_server", "tpm_server.vcxproj", "{6DC26888-4343-4B0F-8A56-4B026B4B20F3}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {6DC26888-4343-4B0F-8A56-4B026B4B20F3}.Debug|Win32.ActiveCfg = Debug|Win32 + {6DC26888-4343-4B0F-8A56-4B026B4B20F3}.Debug|Win32.Build.0 = Debug|Win32 + {6DC26888-4343-4B0F-8A56-4B026B4B20F3}.Release|Win32.ActiveCfg = Release|Win32 + {6DC26888-4343-4B0F-8A56-4B026B4B20F3}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/tpmvstudio/tpm_server/tpm_server.vcxproj b/tpmvstudio/tpm_server/tpm_server.vcxproj new file mode 100644 index 0000000..ecf2d11 --- /dev/null +++ b/tpmvstudio/tpm_server/tpm_server.vcxproj @@ -0,0 +1,208 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {6DC26888-4343-4B0F-8A56-4B026B4B20F3} + Win32Proj + tpm_server + 10.0.17763.0 + + + + Application + true + v141 + Unicode + + + Application + false + v141 + true + Unicode + + + + + + + + + + + + + true + + + false + + + + + + Level3 + Disabled + WIN32;TPM_WINDOWS;_CRT_SECURE_NO_WARNINGS;USE_BIT_FIELD_STRUCTURES=NO;TPM_NUVOTON + c:/program files/openssl/include;%(AdditionalIncludeDirectories) + false + false + + + Console + true + libcrypto32mdd.lib;ws2_32.lib;%(AdditionalDependencies) + c:\program files\openssl\lib\vc;%(AdditionalLibraryDirectories) + + + + + Level3 + + + MaxSpeed + true + true + WIN32;TPM_WINDOWS;_CRT_SECURE_NO_WARNINGS;USE_BIT_FIELD_STRUCTURES=NO;TPM_NUVOTON + c:/program files/openssl/include;%(AdditionalIncludeDirectories) + false + false + + + Console + true + true + true + libcrypto32md.lib;ws2_32.lib;%(AdditionalDependencies) + c:\program files\openssl\lib\vc;%(AdditionalLibraryDirectories) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + false + + + + + + + + + + \ No newline at end of file diff --git a/tpmvstudio/tpm_server/tpm_server.vcxproj.filters b/tpmvstudio/tpm_server/tpm_server.vcxproj.filters new file mode 100644 index 0000000..510456a --- /dev/null +++ b/tpmvstudio/tpm_server/tpm_server.vcxproj.filters @@ -0,0 +1,349 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + \ No newline at end of file