mirror of
https://github.com/nsacyber/HIRS.git
synced 2024-12-24 07:06:46 +00:00
Adding Tpm2-tss support for Deb packaging.
Changes how tpm20.h, which contains the TPM2 SAPI, is imported to allow successful packaging of both debs and rpms.
This commit is contained in:
parent
cc12a02c53
commit
23570f71c3
1
.gitignore
vendored
1
.gitignore
vendored
@ -88,6 +88,7 @@ HIRS_ProvisionerTPM2/CMakeCache.txt
|
|||||||
Makefile
|
Makefile
|
||||||
CMakeFiles/
|
CMakeFiles/
|
||||||
HIRS_ProvisionerTPM2/DartConfiguration.tcl
|
HIRS_ProvisionerTPM2/DartConfiguration.tcl
|
||||||
|
HIRS_ProvisionerTPM2/include/Tss.h
|
||||||
HIRS_ProvisionerTPM2/include/Version.h
|
HIRS_ProvisionerTPM2/include/Version.h
|
||||||
HIRS_ProvisionerTPM2/lib/cpplint-download/
|
HIRS_ProvisionerTPM2/lib/cpplint-download/
|
||||||
HIRS_ProvisionerTPM2/lib/cpplint/
|
HIRS_ProvisionerTPM2/lib/cpplint/
|
||||||
|
@ -29,9 +29,9 @@ execute_process(COMMAND sh "package/package_release.sh"
|
|||||||
list(LENGTH VERSION_COMPONENTS VERSION_COMPONENTS_LENGTH)
|
list(LENGTH VERSION_COMPONENTS VERSION_COMPONENTS_LENGTH)
|
||||||
# Check if version information pulled successfully, error otherwise
|
# Check if version information pulled successfully, error otherwise
|
||||||
if(NOT ${VERSION_COMPONENTS_LENGTH} EQUAL 3)
|
if(NOT ${VERSION_COMPONENTS_LENGTH} EQUAL 3)
|
||||||
message(FATAL "Failed to pull version information from VERSION file, aborting.")
|
message(FATAL_ERROR "Failed to pull version information from VERSION file, aborting.")
|
||||||
elseif(${PACKAGE_RELEASE_RETURN_ERROR})
|
elseif(${PACKAGE_RELEASE_RETURN_ERROR})
|
||||||
message(FATAL "Failed to pull package release information from git, aborting.")
|
message(FATAL_ERROR "Failed to pull package release information from git, aborting.")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Embed version and package release into header file
|
# Embed version and package release into header file
|
||||||
@ -90,12 +90,23 @@ find_library(RE_LIB NAMES re2)
|
|||||||
list(APPEND REQUIRED_LIBS ${RE_LIB})
|
list(APPEND REQUIRED_LIBS ${RE_LIB})
|
||||||
|
|
||||||
# Setup for TPM2_TSS_LIBRARIES
|
# Setup for TPM2_TSS_LIBRARIES
|
||||||
find_library(TPM2_SAPI_LIB NAMES sapi)
|
find_library(TPM2_SAPI_LIB NAMES sapi tss2)
|
||||||
find_library(TPM2_TCTI_DEVICE_LIB NAMES tcti-device)
|
find_library(TPM2_TCTI_DEVICE_LIB NAMES tcti-device tss2)
|
||||||
find_library(TPM2_TCTI_SOCKET_LIB NAMES tcti-socket)
|
find_library(TPM2_TCTI_SOCKET_LIB NAMES tcti-socket tss2)
|
||||||
set(TPM2_TSS_LIBRARIES ${TPM2_SAPI_LIB} ${TPM2_TCTI_DEVICE_LIB} ${TPM2_TCTI_SOCKET_LIB})
|
set(TPM2_TSS_LIBRARIES ${TPM2_SAPI_LIB} ${TPM2_TCTI_DEVICE_LIB} ${TPM2_TCTI_SOCKET_LIB})
|
||||||
list(APPEND REQUIRED_LIBS ${TPM2_TSS_LIBRARIES})
|
list(APPEND REQUIRED_LIBS ${TPM2_TSS_LIBRARIES})
|
||||||
|
|
||||||
|
# Set variable to determine TSS SAPI import
|
||||||
|
set(TSS_LIBRARY "<sapi/tpm20.h>")
|
||||||
|
string(COMPARE EQUAL ${TPM2_SAPI_LIB} ${TPM2_TCTI_DEVICE_LIB} LEGACY_TSS2_LIB_PRESENT)
|
||||||
|
if(LEGACY_TSS2_LIB_PRESENT)
|
||||||
|
set(TSS_LIBRARY "<tss2/tpm20.h>")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Embed correct TSS import into header file
|
||||||
|
configure_file ("${CMAKE_SOURCE_DIR}/include/Tss.h.in"
|
||||||
|
"${CMAKE_SOURCE_DIR}/include/Tss.h")
|
||||||
|
|
||||||
# Download necessary 3rd party libraries
|
# Download necessary 3rd party libraries
|
||||||
# Setup for CPR
|
# Setup for CPR
|
||||||
configure_file(lib/CPR.CMakeLists.txt.in ${CMAKE_BINARY_DIR}/lib/cpr-download/CMakeLists.txt)
|
configure_file(lib/CPR.CMakeLists.txt.in ${CMAKE_BINARY_DIR}/lib/cpr-download/CMakeLists.txt)
|
||||||
@ -104,13 +115,13 @@ execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
|
|||||||
RESULT_VARIABLE result
|
RESULT_VARIABLE result
|
||||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/lib/cpr-download)
|
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/lib/cpr-download)
|
||||||
if(result)
|
if(result)
|
||||||
message(FATAL "CMake step for CPR failed: ${result}")
|
message(FATAL_ERROR "CMake step for CPR failed: ${result}")
|
||||||
endif()
|
endif()
|
||||||
execute_process(COMMAND ${CMAKE_COMMAND} --build .
|
execute_process(COMMAND ${CMAKE_COMMAND} --build .
|
||||||
RESULT_VARIABLE result
|
RESULT_VARIABLE result
|
||||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/lib/cpr-download )
|
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/lib/cpr-download )
|
||||||
if(result)
|
if(result)
|
||||||
message(FATAL "Build step for CPR failed: ${result}")
|
message(FATAL_ERROR "Build step for CPR failed: ${result}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Add cpr directly to our build and define the cpr target.
|
# Add cpr directly to our build and define the cpr target.
|
||||||
@ -158,13 +169,13 @@ execute_process(COMMAND cp ../HIRS_Utils/src/main/resources/logging.properties .
|
|||||||
RESULT_VARIABLE result
|
RESULT_VARIABLE result
|
||||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
|
||||||
if(result)
|
if(result)
|
||||||
message(FATAL "cp logging.properties from HIRS_Utils failed.")
|
message(FATAL_ERROR "cp logging.properties from HIRS_Utils failed.")
|
||||||
endif()
|
endif()
|
||||||
execute_process(COMMAND cp ../HIRS_Provisioner/scripts/install/tpm_aca_provision ./scripts/
|
execute_process(COMMAND cp ../HIRS_Provisioner/scripts/install/tpm_aca_provision ./scripts/
|
||||||
RESULT_VARIABLE result
|
RESULT_VARIABLE result
|
||||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
|
||||||
if(result)
|
if(result)
|
||||||
message(FATAL "cp tpm_aca_provision from HIRS_Provisioner failed.")
|
message(FATAL_ERROR "cp tpm_aca_provision from HIRS_Provisioner failed.")
|
||||||
endif()
|
endif()
|
||||||
install(FILES config/logging.properties DESTINATION /etc/hirs/)
|
install(FILES config/logging.properties DESTINATION /etc/hirs/)
|
||||||
|
|
||||||
@ -193,13 +204,13 @@ if(STYLE_CHECK)
|
|||||||
RESULT_VARIABLE result
|
RESULT_VARIABLE result
|
||||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/lib/cpplint)
|
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/lib/cpplint)
|
||||||
if(result)
|
if(result)
|
||||||
message(FATAL "CMake step for CppLint failed: ${result}")
|
message(FATAL_ERROR "CMake step for CppLint failed: ${result}")
|
||||||
endif()
|
endif()
|
||||||
execute_process(COMMAND ${CMAKE_COMMAND} --build .
|
execute_process(COMMAND ${CMAKE_COMMAND} --build .
|
||||||
RESULT_VARIABLE result
|
RESULT_VARIABLE result
|
||||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/lib/cpplint)
|
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/lib/cpplint)
|
||||||
if(result)
|
if(result)
|
||||||
message(FATAL "Build step for CppLint failed: ${result}")
|
message(FATAL_ERROR "Build step for CppLint failed: ${result}")
|
||||||
endif()
|
endif()
|
||||||
configure_file(${CMAKE_BINARY_DIR}/lib/cpplint-download/cpplint/cpplint.py ${CMAKE_SOURCE_DIR}/lint/cpplint.py)
|
configure_file(${CMAKE_BINARY_DIR}/lib/cpplint-download/cpplint/cpplint.py ${CMAKE_SOURCE_DIR}/lint/cpplint.py)
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
@ -246,11 +257,17 @@ if (${DISTRIBUTION} STREQUAL "Ubuntu")
|
|||||||
set(CPACK_GENERATOR "DEB")
|
set(CPACK_GENERATOR "DEB")
|
||||||
set(CPACK_DEBIAN_PACKAGE_NAME "HIRSProvisionerTPM2.0")
|
set(CPACK_DEBIAN_PACKAGE_NAME "HIRSProvisionerTPM2.0")
|
||||||
set(CPACK_DEBIAN_PACKAGE_SECTION "admin")
|
set(CPACK_DEBIAN_PACKAGE_SECTION "admin")
|
||||||
set(CPACK_DEBIAN_PACKAGE_DEPENDS "liblog4cplus-1.1-9(>=1.1.2), libsapi-utils(>=1.0), tpm2-tools(>=1.1), libprotobuf10(>=2.4.1), libcurlpp0(>=0.8), lshw")
|
set(CPACK_DEBIAN_PACKAGE_DEPENDS "liblog4cplus-1.1-9(>=1.1.2), tpm2-tools(>=1.0), libcurlpp0(>=0.7), lshw")
|
||||||
|
# Set variables specific to Ubuntu release version
|
||||||
|
if (${DISTRIBUTION_VERSION} STREQUAL "16.04")
|
||||||
|
set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS}, libre2-1v5(>=20160201), libtss2-utils(>=0.98), libprotobuf9v5(>=2.4.1)")
|
||||||
|
else()
|
||||||
|
set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS}, libsapi-utils(>=1.0), libprotobuf10(>=2.4.1)")
|
||||||
if (${DISTRIBUTION_VERSION} STREQUAL "17.10")
|
if (${DISTRIBUTION_VERSION} STREQUAL "17.10")
|
||||||
set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS}, libre2-3(>=20160401)")
|
set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS}, libre2-3(>=20160201)")
|
||||||
elseif(${DISTRIBUTION_VERSION} STREQUAL "18.04" OR ${DISTRIBUTION_VERSION} STREQUAL "18.10")
|
elseif(${DISTRIBUTION_VERSION} STREQUAL "18.04" OR ${DISTRIBUTION_VERSION} STREQUAL "18.10")
|
||||||
set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS}, libre2-4(>=20160401)")
|
set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS}, libre2-4(>=20160201)")
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE amd64)
|
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE amd64)
|
||||||
set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA ${CMAKE_SOURCE_DIR}/package/postinst)
|
set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA ${CMAKE_SOURCE_DIR}/package/postinst)
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
#include <ProvisionerTpm2.pb.h>
|
#include <ProvisionerTpm2.pb.h>
|
||||||
#include <Utils.h>
|
#include <Utils.h>
|
||||||
|
|
||||||
#include <sapi/tpm20.h>
|
#include <Tss.h>
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
6
HIRS_ProvisionerTPM2/include/Tss.h.in
Normal file
6
HIRS_ProvisionerTPM2/include/Tss.h.in
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#ifndef HIRS_PROVISIONERTPM2_INCLUDE_TSS_H_
|
||||||
|
#define HIRS_PROVISIONERTPM2_INCLUDE_TSS_H_
|
||||||
|
|
||||||
|
#include @TSS_LIBRARY@
|
||||||
|
|
||||||
|
#endif // HIRS_PROVISIONERTPM2_INCLUDE_TSS_H_
|
@ -21,6 +21,7 @@ add_library(TPM2_PROVISIONER_LIBRARY
|
|||||||
${CMAKE_SOURCE_DIR}/include/Process.h
|
${CMAKE_SOURCE_DIR}/include/Process.h
|
||||||
${CMAKE_SOURCE_DIR}/include/Properties.h
|
${CMAKE_SOURCE_DIR}/include/Properties.h
|
||||||
${CMAKE_SOURCE_DIR}/include/RestfulClientProvisioner.h
|
${CMAKE_SOURCE_DIR}/include/RestfulClientProvisioner.h
|
||||||
|
${CMAKE_SOURCE_DIR}/include/Tss.h
|
||||||
${CMAKE_SOURCE_DIR}/include/Utils.h
|
${CMAKE_SOURCE_DIR}/include/Utils.h
|
||||||
${CMAKE_SOURCE_DIR}/include/Version.h
|
${CMAKE_SOURCE_DIR}/include/Version.h
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
#include <log4cplus/loggingmacros.h>
|
#include <log4cplus/loggingmacros.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <mutex>
|
||||||
#include <Properties.h>
|
#include <Properties.h>
|
||||||
#include <Utils.h>
|
#include <Utils.h>
|
||||||
|
|
||||||
|
@ -71,15 +71,17 @@ mv $SCRIPT_DIR/deb/DEB_SOURCES/hirs-provisioner*.deb $SCRIPT_DIR/deb/DEBS/
|
|||||||
echo "HIRS Provisioner deb building complete"
|
echo "HIRS Provisioner deb building complete"
|
||||||
|
|
||||||
# TPM Module
|
# TPM Module
|
||||||
cd $SCRIPT_DIR/../tpm_module
|
cd $SCRIPT_DIR/..
|
||||||
|
|
||||||
|
# Compile the TPM Module
|
||||||
|
./gradlew :tpm_module:build
|
||||||
|
cd tpm_module
|
||||||
|
|
||||||
# Setup build directories
|
# Setup build directories
|
||||||
mkdir -p $SCRIPT_DIR/deb/DEB_SOURCES/tpm-module/
|
mkdir -p $SCRIPT_DIR/deb/DEB_SOURCES/tpm-module/
|
||||||
mkdir -p $SCRIPT_DIR/deb/DEB_SOURCES/tpm-module/debian
|
mkdir -p $SCRIPT_DIR/deb/DEB_SOURCES/tpm-module/debian
|
||||||
mkdir -p $SCRIPT_DIR/deb/DEB_SOURCES/tpm-module/src
|
mkdir -p $SCRIPT_DIR/deb/DEB_SOURCES/tpm-module/src
|
||||||
|
|
||||||
# Compile the TPM Module
|
|
||||||
../gradlew build
|
|
||||||
|
|
||||||
# Copy build files
|
# Copy build files
|
||||||
cp tpm_module $SCRIPT_DIR/deb/DEB_SOURCES/tpm-module/src/
|
cp tpm_module $SCRIPT_DIR/deb/DEB_SOURCES/tpm-module/src/
|
||||||
cp -r debian/* $SCRIPT_DIR/deb/DEB_SOURCES/tpm-module/debian
|
cp -r debian/* $SCRIPT_DIR/deb/DEB_SOURCES/tpm-module/debian
|
||||||
|
Loading…
Reference in New Issue
Block a user