issue_825: Successfully deleted HIRS_Provisioner TPM2 and can build successfully.

This commit is contained in:
TheSilentCoder 2024-11-01 15:13:54 -04:00
parent 775ab4acc6
commit 22912634ec
54 changed files with 45 additions and 7959 deletions

View File

@ -70,10 +70,10 @@ configurations.checkstyle {
}
}
checkstyleMain {
source ='src/main/java'
source = 'src/main/java'
}
checkstyleTest {
source ='src/test/java'
source = 'src/test/java'
}
tasks.withType(Checkstyle) {
reports {
@ -82,16 +82,16 @@ tasks.withType(Checkstyle) {
}
}
protobuf {
protoc {
artifact = 'com.google.protobuf:protoc:3.24.3'
}
protoc {
artifact = 'com.google.protobuf:protoc:3.24.3'
}
}
sourceSets {
main {
proto {
srcDir '../HIRS_ProvisionerTPM2/src'
main {
proto {
srcDir '../HIRS_Provisioner.NET/hirs/Resources'
}
}
}
}
test {

View File

@ -7,10 +7,10 @@
dir=$(pwd)
# Relative paths are different when building locally versus on CI
if [[ "$dir" == *"package"* ]]; then
SRC_DIR=$dir/../../../../../../HIRS_ProvisionerTPM2/src
SRC_DIR=$dir/../../../../../../HIRS_Provisioner.NET/hirs/Resources
DEST_DIR=$dir/../src/main/java
else
SRC_DIR=../../HIRS_ProvisionerTPM2/src
SRC_DIR=../../HIRS_Provisioner.NET/hirs/Resources
DEST_DIR=../src/main/java
fi
protoc -I=$SRC_DIR --java_out=$DEST_DIR $SRC_DIR/ProvisionerTpm2.proto

View File

@ -1,6 +1,5 @@
package hirs.attestationca.persist.provision;
import com.fasterxml.jackson.databind.ser.Serializers;
import com.google.protobuf.ByteString;
import hirs.attestationca.configuration.provisionerTpm2.ProvisionerTpm2;
import hirs.attestationca.persist.entity.manager.CertificateRepository;
@ -69,24 +68,23 @@ import java.util.regex.Pattern;
@Log4j2
public class IdentityClaimProcessor extends AbstractProcessor {
private static final String PCR_QUOTE_MASK = "0,1,2,3,4,5,6,7,8,9,10,11,12,13,"
+ "14,15,16,17,18,19,20,21,22,23";
private static final int NUM_OF_VARIABLES = 5;
/**
* Number of bytes to include in the TPM2.0 nonce.
*/
public static final int NONCE_LENGTH = 20;
private static final String PCR_QUOTE_MASK = "0,1,2,3,4,5,6,7,8,9,10,11,12,13,"
+ "14,15,16,17,18,19,20,21,22,23";
private static final int NUM_OF_VARIABLES = 5;
private static final int MAC_BYTES = 6;
private SupplyChainValidationService supplyChainValidationService;
private CertificateRepository certificateRepository;
private ComponentResultRepository componentResultRepository;
private ComponentInfoRepository componentInfoRepository;
private ReferenceManifestRepository referenceManifestRepository;
private ReferenceDigestValueRepository referenceDigestValueRepository;
private DeviceRepository deviceRepository;
private TPM2ProvisionerStateRepository tpm2ProvisionerStateRepository;
private final SupplyChainValidationService supplyChainValidationService;
private final CertificateRepository certificateRepository;
private final ComponentResultRepository componentResultRepository;
private final ComponentInfoRepository componentInfoRepository;
private final ReferenceManifestRepository referenceManifestRepository;
private final ReferenceDigestValueRepository referenceDigestValueRepository;
private final DeviceRepository deviceRepository;
private final TPM2ProvisionerStateRepository tpm2ProvisionerStateRepository;
/**
* Constructor.
@ -116,8 +114,8 @@ public class IdentityClaimProcessor extends AbstractProcessor {
* Basic implementation of the ACA processIdentityClaimTpm2 method. Parses the claim,
* stores the device info, performs supply chain validation, generates a nonce,
* and wraps that nonce with the make credential process before returning it to the client.
* attCert.setPcrValues(pcrValues);
* attCert.setPcrValues(pcrValues);
*
* @param identityClaim the request to process, cannot be null
* @return an identity claim response for the specified request containing a wrapped blob
*/
@ -147,7 +145,7 @@ public class IdentityClaimProcessor extends AbstractProcessor {
}
}
ByteString blobStr = ByteString.copyFrom(new byte[]{});
ByteString blobStr = ByteString.copyFrom(new byte[] {});
if (validationResult == AppraisalStatus.Status.PASS) {
RSAPublicKey akPub = ProvisionUtils.parsePublicKey(claim.getAkPublicArea().toByteArray());
byte[] nonce = ProvisionUtils.generateRandomBytes(NONCE_LENGTH);
@ -195,7 +193,8 @@ public class IdentityClaimProcessor extends AbstractProcessor {
private AppraisalStatus.Status doSupplyChainValidation(
final ProvisionerTpm2.IdentityClaim claim, final PublicKey ekPub) {
// attempt to find an endorsement credential to validate
EndorsementCredential endorsementCredential = parseEcFromIdentityClaim(claim, ekPub, certificateRepository);
EndorsementCredential endorsementCredential =
parseEcFromIdentityClaim(claim, ekPub, certificateRepository);
// attempt to find platform credentials to validate
List<PlatformCredential> platformCredentials = parsePcsFromIdentityClaim(claim,
@ -283,6 +282,7 @@ public class IdentityClaimProcessor extends AbstractProcessor {
/**
* Converts a protobuf DeviceInfo object to a HIRS Utils DeviceInfoReport object.
*
* @param claim the protobuf serialized identity claim containing the device info
* @return a HIRS Utils DeviceInfoReport representation of device info
*/
@ -357,7 +357,7 @@ public class IdentityClaimProcessor extends AbstractProcessor {
String fileName = "";
Pattern pattern = Pattern.compile("([^\\s]+(\\.(?i)(rimpcr|rimel|bin|log))$)");
Matcher matcher;
MessageDigest messageDigest = MessageDigest.getInstance("SHA-256");
MessageDigest messageDigest = MessageDigest.getInstance("SHA-256");
if (dv.getSwidfileCount() > 0) {
for (ByteString swidFile : dv.getSwidfileList()) {
@ -425,9 +425,10 @@ public class IdentityClaimProcessor extends AbstractProcessor {
if (dv.getLogfileCount() > 0) {
for (ByteString logFile : dv.getLogfileList()) {
try {
support = (SupportReferenceManifest) referenceManifestRepository.findByHexDecHashAndRimType(
support =
(SupportReferenceManifest) referenceManifestRepository.findByHexDecHashAndRimType(
Hex.encodeHexString(messageDigest.digest(logFile.toByteArray())),
ReferenceManifest.SUPPORT_RIM);
ReferenceManifest.SUPPORT_RIM);
if (support == null) {
/*
Either the logFile does not have a corresponding support RIM in the backend
@ -512,8 +513,10 @@ public class IdentityClaimProcessor extends AbstractProcessor {
}
// now update support rim
SupportReferenceManifest dbSupport = (SupportReferenceManifest) referenceManifestRepository
.findByHexDecHashAndRimType(swid.getHashValue(), ReferenceManifest.SUPPORT_RIM);
SupportReferenceManifest dbSupport =
(SupportReferenceManifest) referenceManifestRepository
.findByHexDecHashAndRimType(swid.getHashValue(),
ReferenceManifest.SUPPORT_RIM);
if (dbSupport != null) {
dbSupport.setFileName(swid.getName());
dbSupport.setSwidTagVersion(dbBaseRim.getSwidTagVersion());
@ -584,7 +587,7 @@ public class IdentityClaimProcessor extends AbstractProcessor {
dv.getNw().getHostname()));
}
// Get TPM info, currently unimplemented
// Get TPM info, currently unimplemented
TPMInfo tpmInfo = new TPMInfo(DeviceInfoEnums.NOT_SPECIFIED,
(short) 0,
(short) 0,
@ -628,7 +631,8 @@ public class IdentityClaimProcessor extends AbstractProcessor {
}
if (baseSupportRim != null
&& referenceDigestValueRepository.findBySupportRimHash(baseSupportRim.getHexDecHash()).isEmpty()) {
&& referenceDigestValueRepository.findBySupportRimHash(baseSupportRim.getHexDecHash())
.isEmpty()) {
try {
TCGEventLog logProcessor = new TCGEventLog(baseSupportRim.getRimBytes());
ReferenceDigestValue rdv;
@ -688,7 +692,7 @@ public class IdentityClaimProcessor extends AbstractProcessor {
log.error(String.format("Patching value does not exist (%s)",
patchedValue));
} else {
// WIP - Until we get patch examples
// WIP - Until we get patch examples
dbRdv.setPatched(true);
}
}
@ -721,7 +725,7 @@ public class IdentityClaimProcessor extends AbstractProcessor {
}
private int handleDeviceComponents(final String hostName, final String paccorString) {
int deviceComponents = 0 ;
int deviceComponents = 0;
Map<Integer, ComponentInfo> componentInfoMap = new HashMap<>();
try {
List<ComponentInfo> componentInfos = SupplyChainCredentialValidator

View File

@ -7,10 +7,10 @@
dir=$(pwd)
# Relative paths are different when building locally versus on CI
if [[ "$dir" == *"package"* ]]; then
SRC_DIR=$dir/../../../../../../HIRS_ProvisionerTPM2/src
SRC_DIR=$dir/../../../../../../HIRS_Provisioner.NET/hirs/Resources
DEST_DIR=$dir/../src/main/java
else
SRC_DIR=../../HIRS_ProvisionerTPM2/src
SRC_DIR=../../HIRS_Provisioner.NET/hirs/Resources
DEST_DIR=../src/main/java
fi
protoc -I=$SRC_DIR --java_out=$DEST_DIR $SRC_DIR/ProvisionerTpm2.proto

View File

@ -1,312 +0,0 @@
# Root CMake file in charge of managing build/testing of TPM 2.0 Provisioner Library and Executable
# General CMake Configuration
cmake_minimum_required(VERSION 2.8.12)
# Initialize Project
project(HIRS_ProvisionerTPM2)
# Set Project Information Variables
set(PROJECT_NAME hirs-provisioner-tpm2)
# Retrieve Complete Version
file(STRINGS ../VERSION COMPLETE_VERSION LIMIT_COUNT 1)
# Break Version into Components
string(REGEX MATCHALL "[0-9]+" VERSION_COMPONENTS ${COMPLETE_VERSION})
# Set MAJOR_VERSION
list(GET VERSION_COMPONENTS 0 MAJOR_VERSION)
# Set MINOR_VERSION
list(GET VERSION_COMPONENTS 1 MINOR_VERSION)
# Set PATCH_VERSION
list(GET VERSION_COMPONENTS 2 PATCH_VERSION)
# Sets PACKAGE_RELEASE_NUMBER & PACKAGE_RELEASE_RETURN_CODE
execute_process(COMMAND sh "package/package_release.sh"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
RESULT_VARIABLE PACKAGE_RELEASE_RETURN_ERROR
OUTPUT_VARIABLE PACKAGE_RELEASE_NUMBER
ERROR_STRIP_TRAILING_WHITESPACE
OUTPUT_STRIP_TRAILING_WHITESPACE)
list(LENGTH VERSION_COMPONENTS VERSION_COMPONENTS_LENGTH)
# Check if version information pulled successfully, error otherwise
if(NOT ${VERSION_COMPONENTS_LENGTH} EQUAL 3)
message(FATAL_ERROR "Failed to pull version information from VERSION file, aborting.")
elseif(${PACKAGE_RELEASE_RETURN_ERROR})
message(FATAL_ERROR "Failed to pull package release information from git, aborting.")
endif()
# Embed version and package release into header file
configure_file ("${CMAKE_SOURCE_DIR}/include/Version.h.in"
"${CMAKE_SOURCE_DIR}/include/Version.h")
# Attempt to Determine Build Environment
if (UNIX AND NOT APPLE)
file(READ /etc/os-release OS_INFO)
string(REGEX MATCH "NAME=\"[A-Za-z ]+\"" DISTRIBUTION_NAME ${OS_INFO})
string(REGEX MATCH "VERSION_ID=\"[0-9. ]+\"" DISTRIBUTION_VERSION ${OS_INFO})
string(REPLACE "NAME=" "" DISTRIBUTION ${DISTRIBUTION_NAME})
string(REPLACE "VERSION_ID=" "" DISTRIBUTION_VERSION ${DISTRIBUTION_VERSION})
string(REPLACE "\"" "" DISTRIBUTION ${DISTRIBUTION})
string(REPLACE "\"" "" DISTRIBUTION_VERSION ${DISTRIBUTION_VERSION})
endif()
# Set C++ Standard 11 based on version information
if (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 3.0)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
else ()
set(CMAKE_CXX_FLAGS "-std=gnu++11")
endif ()
# Set User configurable options
option(BUILD_TESTS "Set to OFF to turn off testing" ON)
option(GENERATE_DOCS "Set to OFF to turn off documentation generation" ON)
option(STATIC_ANALYSIS "Set to OFF to turn off Static Analysis" ON)
option(STYLE_CHECK "Set to OFF to turn off code style checking" ON)
# Set Project Path Variables
set(EXECUTABLE_OUTPUT_PATH bin)
set(PROJECT_CONFIG_DIR ${CMAKE_SOURCE_DIR}/config)
set(PROJECT_CONFIG_FILES ${PROJECT_CONFIG_DIR}/log4cplus_config.ini)
# Set directories to look for header files
include_directories(${CMAKE_SOURCE_DIR}/include)
# Protobuf generated files are placed in the binary directory. The structure of
# the binary directory matches that of the source directory. Specifically,
# protobuf places the generated files in the same subfolder of the binary
# directory where the spec file was located in the source directory. In this
# case, that is the src folder. We get this file location automatically in the
# src/CMakeLists.txt file, but the variable holding its location is not defined
# in the scope of this file, so we need to add that directory to the include
# path manually.
include_directories(${CMAKE_BINARY_DIR}/src)
# Attempt to find local 3rd party libraries and set their absolute paths
# Sets LOG_LIB
find_library(LOG_LIB NAMES log4cplus)
list(APPEND REQUIRED_LIBS ${LOG_LIB})
# Sets RE_LIB
find_library(RE_LIB NAMES re2)
list(APPEND REQUIRED_LIBS ${RE_LIB})
# Setup for TPM2_TSS_LIBRARIES
find_library(TPM2_SAPI_LIB NAMES sapi tss2)
find_library(TPM2_TCTI_DEVICE_LIB NAMES tcti-device tss2)
find_library(TPM2_TCTI_SOCKET_LIB NAMES tcti-socket tss2)
find_library(TPM2_TCTI_TABRMD_LIB NAMES tcti-tabrmd tss2)
set(TPM2_TSS_LIBRARIES ${TPM2_SAPI_LIB} ${TPM2_TCTI_DEVICE_LIB}
${TPM2_TCTI_SOCKET_LIB} ${TPM2_TCTI_TABRMD_LIB})
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
# Setup for CPR
configure_file(lib/CPR.CMakeLists.txt.in ${CMAKE_BINARY_DIR}/lib/cpr-download/CMakeLists.txt)
set(USE_SYSTEM_CURL ON CACHE BOOL "Do not allow CPR to use its own version of curl." FORCE)
set(BUILD_CPR_TESTS OFF CACHE BOOL "Do not waste time running CPR unit tests" FORCE)
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/lib/cpr-download)
if(result)
message(FATAL_ERROR "CMake step for CPR failed: ${result}")
endif()
execute_process(COMMAND ${CMAKE_COMMAND} --build .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/lib/cpr-download )
if(result)
message(FATAL_ERROR "Build step for CPR failed: ${result}")
endif()
# Add cpr directly to our build and define the cpr target.
add_subdirectory(${CMAKE_BINARY_DIR}/lib/cpr-src
${CMAKE_BINARY_DIR}/lib/cpr-build)
list(APPEND REQUIRED_LIBS ${CPR_LIBRARIES})
# Imports the FindProtobuf module, used to locate protobuf package and
# do source code generation
include(FindProtobuf)
# Finds protobuf binaries
find_package(Protobuf REQUIRED)
list(APPEND REQUIRED_LIBS ${PROTOBUF_LIBRARY})
# Define the TPM 2.0 Provisioner Library
add_subdirectory(src)
# Create project executable
add_executable(${PROJECT_NAME} src/TPM2_Provisioner.cpp ${PROJECT_CONFIG_FILES})
# In TPM 2.0 land, there is currently not a way to fetch the TPM version info
add_executable(tpm_version src/tpm_version.cpp)
target_link_libraries(tpm_version ${TPM2_SAPI_LIB} ${TPM2_TCTI_TABRMD_LIB})
# Link necessary libraries
target_link_libraries(${PROJECT_NAME} TPM2_PROVISIONER_LIBRARY)
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
if(THREADS_HAVE_PTHREAD_ARG)
target_compile_options(${PROJECT_NAME} PUBLIC "-pthread")
endif()
if(CMAKE_THREAD_LIBS_INIT)
target_link_libraries(${PROJECT_NAME} "${CMAKE_THREAD_LIBS_INIT}")
endif()
# Set commands for installation of project on target system (i.e. "make install")
install(TARGETS ${PROJECT_NAME} tpm_version
DESTINATION "bin")
install(FILES config/log4cplus_config.ini DESTINATION /etc/hirs/TPM2_Provisioner)
install(FILES scripts/tpm_aca_provision DESTINATION /usr/local/bin PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
install(DIRECTORY DESTINATION ${/var/log/hirs/provisioner}
DIRECTORY_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ
GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
install(DIRECTORY DESTINATION ${/etc/hirs/provisioner}
DIRECTORY_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ
GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
install(FILES ../HIRS_Provisioner/src/main/resources/defaults.properties DESTINATION /etc/hirs/provisioner RENAME provisioner.properties)
install(FILES ../HIRS_Provisioner/hirs-provisioner-config.sh DESTINATION /etc/hirs/provisioner
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ
GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
install(FILES ../HIRS_Provisioner/scripts/install/hirs-provisioner.sh DESTINATION /etc/hirs/provisioner
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ
GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
execute_process(COMMAND cp ../HIRS_Utils/src/main/resources/logging.properties ./config/
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
if(result)
message(FATAL_ERROR "cp logging.properties from HIRS_Utils failed.")
endif()
execute_process(COMMAND cp ../HIRS_Provisioner/scripts/install/tpm_aca_provision ./scripts/
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
if(result)
message(FATAL_ERROR "cp tpm_aca_provision from HIRS_Provisioner failed.")
endif()
install(FILES config/logging.properties DESTINATION /etc/hirs/)
# check if Doxygen is installed
if(GENERATE_DOCS)
find_package(Doxygen)
if (DOXYGEN_FOUND)
# set input config file
set(DOXYGEN_CONFIG ${PROJECT_CONFIG_DIR}/doxygen.config)
add_custom_target( doc_doxygen ALL
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_CONFIG}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMENT "Generating API documentation with Doxygen"
VERBATIM )
else (DOXYGEN_FOUND)
message("Doxygen needs to be installed to generate the doxygen documentation")
endif (DOXYGEN_FOUND)
endif(GENERATE_DOCS)
# Based on user-defined flag, optionally code style check the TPM 2.0 Library
if(STYLE_CHECK)
# Download and integrate CppLint for Style Checking
configure_file(lib/CppLint.CMakeLists.txt.in ${CMAKE_BINARY_DIR}/lib/cpplint/CMakeLists.txt)
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/lib/cpplint)
if(result)
message(FATAL_ERROR "CMake step for CppLint failed: ${result}")
endif()
execute_process(COMMAND ${CMAKE_COMMAND} --build .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/lib/cpplint)
if(result)
message(FATAL_ERROR "Build step for CppLint failed: ${result}")
endif()
configure_file(${CMAKE_BINARY_DIR}/lib/cpplint-download/cpplint/cpplint.py ${CMAKE_SOURCE_DIR}/lint/cpplint.py)
add_custom_command(
TARGET ${PROJECT_NAME}
COMMENT "Run Style Check"
PRE_BUILD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/lint
COMMAND python cpplint.py --root=${CMAKE_SOURCE_DIR}/../ --filter=-build/c++11,-legal/copyright ${CMAKE_SOURCE_DIR}/src/*.cpp ${CMAKE_SOURCE_DIR}/include/*.hpp ${CMAKE_SOURCE_DIR}/src/*.c ${CMAKE_SOURCE_DIR}/include/*.h ${CMAKE_SOURCE_DIR}/test/*.cpp
)
endif(STYLE_CHECK)
if(STATIC_ANALYSIS)
add_custom_command(
TARGET ${PROJECT_NAME}
COMMENT "Run Cppcheck Static Analysis"
PRE_BUILD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMAND cppcheck
--enable=warning,performance,portability,style
--std=c++11
--library=posix.cfg
--error-exitcode=1
--verbose
--suppress=readdirCalled
--suppress=passedByValue
-I include/
src/
)
endif(STATIC_ANALYSIS)
# Set variables for CPack Package generation tool
set(CPACK_PACKAGE_NAME HIRS_Provisioner_TPM_2_0)
set(CPACK_PACKAGE_VENDOR "U.S. Government")
set(CPACK_PACKAGE_CONTACT "U.S. Government")
set(CPACK_PACKAGE_VERSION_MAJOR ${MAJOR_VERSION})
set(CPACK_PACKAGE_VERSION_MINOR ${MINOR_VERSION})
set(CPACK_PACKAGE_VERSION_PATCH ${PATCH_VERSION})
set(CPACK_PACKAGE_RELEASE ${PACKAGE_RELEASE_NUMBER})
set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
set(CPACK_PACKAGING_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX})
# Setup Development Distribution CPack
if (${DISTRIBUTION} STREQUAL "Ubuntu")
# Set variables specific to CPack DEB package generator
set(CPACK_GENERATOR "DEB")
set(CPACK_DEBIAN_PACKAGE_NAME "HIRSProvisionerTPM2.0")
set(CPACK_DEBIAN_PACKAGE_SECTION "admin")
set(CPACK_DEBIAN_PACKAGE_DEPENDS "liblog4cplus-1.1-9(>=1.1.2), libcurl4-openssl-dev(>=7.0.0), paccor, procps(>=3.3.0)")
# 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), libprotobuf9v5(>=2.4.1)")
else()
set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS}, libprotobuf10(>=2.4.1)")
if (${DISTRIBUTION_VERSION} STREQUAL "17.10")
set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS}, libre2-3(>=20160201)")
elseif(${DISTRIBUTION_VERSION} STREQUAL "18.04" OR ${DISTRIBUTION_VERSION} STREQUAL "18.10")
set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS}, libre2-4(>=20160201)")
endif()
endif()
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE amd64)
set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA ${CMAKE_SOURCE_DIR}/package/postinst)
set(CPACK_PACKAGE_FILE_NAME "${CPACK_DEBIAN_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION}-${CPACK_PACKAGE_RELEASE}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}")
elseif (${DISTRIBUTION} STREQUAL "CentOS Linux")
# Set variables specific to CPack RPM package generator
set(CPACK_GENERATOR "RPM")
set(CPACK_RPM_PACKAGE_NAME "HIRS_Provisioner_TPM_2_0")
set(CPACK_RPM_PACKAGE_RELEASE_DIST "el7")
set(CPACK_RPM_PACKAGE_LICENSE "Apache License, Version 2.0")
set(CPACK_RPM_PACKAGE_GROUP "System Environment/Base")
set(CPACK_RPM_PACKAGE_REQUIRES "log4cplus >= 1.1.2, tpm2-tss >= 1.0, tpm2-tools >= 1.1.0, protobuf >= 2.4.1, re2 >= 20160401, libcurl >= 7.0.0, paccor, procps-ng >= 3.3.0")
set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE ${CMAKE_SOURCE_DIR}/package/rpm-post-install.sh)
set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION /usr/local /usr/local/bin /usr/local/include /usr/local/lib)
set(CPACK_PACKAGE_FILE_NAME "${CPACK_RPM_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_PACKAGE_RELEASE}.${CPACK_RPM_PACKAGE_RELEASE_DIST}.${CMAKE_SYSTEM_PROCESSOR}")
endif()
# Set command to allow for running of CPack tool in build directory
include(CPack)
# Based on user-defined flag, optionally build tests for TPM 2.0 Library
if (BUILD_TESTS)
enable_testing()
add_subdirectory(test)
endif(BUILD_TESTS)

View File

@ -1,71 +0,0 @@
# HIRS TPM 2.0 Provisioner
Notice: The HIRS TPM 2.0 Provisioner is being deprecated.
Please refer to the [HIRS_Provisioner.Net](https://github.com/nsacyber/HIRS/tree/main/HIRS_Provisioner.NET) for currently supported HIRS provisioner.
### Overview
This document describes the HIRS TPM 2.0 Provisioner, a program that can leverage a machine and its TPM to:
- verify system attributes (as chosen in the ACA policy)
- request and store an Attestation Identity Credential
See the top-level project documentation for more details.
### Requirements
**Development and runtime of this project is currently only supported on CentOS 7.**
This project is built with the CMake cross-platform build suite. Consult the developer dependencies in [docs/](docs/) for a list of all third-party software that should be installed before attempting to the compile the project. Additional dependencies will be downloaded and built by CMake, so an active Internet connection is required to properly build the project.
Python 2 is required for style checking. If you do not have Python 2 installed, either install it or set the `STYLE_CHECK` option to `OFF` as part of your CMake command or in the root `CMakeLists.txt` file.
This project uses cppcheck to provide static code analysis. If you do not wish to run this analysis, set the `STATIC_ANALYSIS` option to `OFF` as part of your CMake Command or in the root `CMakeLists.txt` file.
### Building
Before you begin, please ensure you have the prerequisite dependencies installed on your system (listed in docs/developer-dependencies-centos.md).
Two procedures for building the HIRS TPM 2.0 Provisioner with CMake are described below.
#### Building with the CLion IDE
1. Import the root directory as a project into the [CLion](https://www.jetbrains.com/clion/) IDE.
2. Click `Tools` > `CMake` > `Reset Cache and Reload Project`
3. Click `Run` > `Build`
#### Building on the CLI
1. Navigate to the root of the project directory.
2. Make a build folder.
3. Navigate into the build folder.
4. Run the following command to generate the appropriate make files:
```
cmake ../
```
5. Run the following command to build the executable in the `bin` directory of the build folder:
```
make
```
By default, the build will gather additional third-party dependencies, run the unit test suite, run static analsysis with cppcheck, and will generate code documentation (which is placed in the `./docs` directory.)
#### Troubleshooting build issues
- CMake will fetch additional third-party dependencies during the build. The build will fail if these cannot be retrieved, so please ensure you have an active Internet connection before building.
- If it is found that CMake is building in an unusual/undesired directory, it's likely that CMake is using a cached target directory in lieu of an implicit target. At this point, look around the local project for a CMakeCache.txt file and delete it to force a cache refresh.
### RPM Packaging
The only currently supported target runtime environment is CentOS7.
The CMakeLists is configured to package the project into an RPM using CPack. To build the RPM, navigate to the target build directory and run the following command:
```
cpack
```
This will create the CentOS 7 RPM.
**NOTE:** Packaging of the software for a given distribution should be done in the same environment as the target environment. Due to host-system specific, compilation-time targeting of certain system libraries and APIs, cross-platform compilation is not advised and could lead to package installation errors.
### Installing
Ensure that the third-party runtime dependencies are present on the target machine(s). These can be found in [/docs/developer-depedencies-centos.md](/docs/developer-depedencies-centos.md). If installing these via yum or another package manager that performs dependency resolution, the EPEL repository will need to be configured, as several of the Provisioner's dependencies are not in the base CentOS 7 repository. The Provisioner RPM can be transferred and installed on client machines via the usual mechanisms (rpm/yum/etc.)

View File

@ -1,19 +0,0 @@
task cleanup(type: Delete) {
delete fileTree(dir: 'build', exclude: 'lib/')
}
task cmake(type: Exec) {
workingDir './build'
commandLine 'cmake', '../'
}
task make(type: Exec) {
workingDir './build'
commandLine 'make'
}
task fullBuild(type: GradleBuild) {
tasks = ['cleanup', 'cmake', 'make']
}
build.dependsOn tasks.fullBuild

File diff suppressed because it is too large Load Diff

View File

@ -1,27 +0,0 @@
###################################
########Define log Levels##########
###################################
# All classes - except as otherwise specified.
# The logging threshold will be overridden if a value for root.level
# is set in /etc/hirs/logging.properties.
log4cplus.rootLogger=WARN, FILE
# Configure top level main logger
# The logging threshold will be overridden if a value for tpm2_provisioner.level
# is set in /etc/hirs/logging.properties.
log4cplus.logger.tpm2_provisioner=WARN, FILE
log4cplus.additivity.tpm2_provisioner=false
###################################
########Define the Appenders#######
###################################
# File Appender
log4cplus.appender.FILE.File=/var/log/hirs/provisioner/HIRS_ProvisionerTPM2.log
log4cplus.appender.FILE=log4cplus::RollingFileAppender
log4cplus.appender.FILE.MaxFileSize=10MB
log4cplus.appender.FILE.Append=true
log4cplus.appender.FILE.MaxBackupIndex=1
log4cplus.appender.FILE.layout=log4cplus::PatternLayout
log4cplus.appender.FILE.layout.ConversionPattern=[%d{%Y/%m/%d %H:%M:%S:%q}][%-5p][%-l] %m%n

View File

@ -1,19 +0,0 @@
Dependencies
============
These are the dependencies currently used by the TPM2 Provisioner that must be supplied by the runtime environment (in this case CentOS 7) and which are not statically linked.
Please look up their respective names in the CentOS repositories.
**NOTE**: Please consult [the developer dependency list](./developer-dependencies-centos.md) and make sure both the regular lib and the devel libs are installed.
| Dependency | Version used | Minimum required | Repository required | Project repository |
| -----------| ------------ | ----------------- | --------------------- | ------------------------------------------- |
| libcurl | 7.29.0 | 7.0.0 (estimated) | CentOS 7 base | https://github.com/curl/curl |
| log4cplus | 1.1.2 | 1.1.2 | CentOS 7 epel-release | https://github.com/log4cplus/log4cplus |
| protobuf | 2.5.0 | 2.4.1 (estimated) | CentOS 7 base | https://github.com/google/protobuf |
| re2 | 20160401 | 20160201 | CentOS 7 epel-release | https://github.com/google/re2 |
| tpm2-tss | 1.2.0 | 1.0.0 | CentOS 7 base | https://github.com/intel/tpm2-tss |
| tpm2-tools | 1.1.0 | 1.1.0 | CentOS 7 base | https://github.com/tpm2-software/tpm2-tools |
| paccor | 1.0.6 | none | N/A | https://github.com/nsacyber/paccor |
| procps-ng | 3.3.10 | 3.3.0 | CentOS 7 base | https://gitlab.com/procps-ng/procps |

View File

@ -1,27 +0,0 @@
Developer Dependencies
======================
These are the dependencies currently used by the TPM2 Provisioner project that must be supplied by the development environment (in this case CentOS 7) in order to properly build and package the project.
Please look up their respective names in the CentOS repositories.
If no available repository for the development environment contains the dependencies at an acceptable version level, it is expected that the packages be retrieved and built from their respective source repositories.
| Dependency | Version used | Minimum required | Repository | Project repository |
| ----------------- | ------------ | ------------------ | --------------------- | -------------------------------------- |
| cppcheck | 1.80 | 1.72 | CentOS 7 epel-release | http://cppcheck.sourceforge.net/ |
| doxygen | 1.8.13 | 1.8.0 (estimated) | CentOS 7 base | https://github.com/doxygen/doxygen |
| graphviz | 2.30.1 | 2.28.0 (estimated) | CentOS 7 base | https://gitlab.com/graphviz/graphviz |
| gcc-c++ | 4.8.5 | 4.8.5 | CentOS 7 base | https://gcc.gnu.org/ |
| libcurl-devel | 7.29.0 | 7.0.0 (estimated) | CentOS 7 base | https://github.com/curl/curl |
| libssh2-devel | 1.4.3 | 1.4.3 (estimated) | CentOS 7 base | https://github.com/libssh2/libssh2 |
| log4cplus-devel | 1.1.3 | 1.1.2 | CentOS 7 epel-release | https://github.com/log4cplus/log4cplus |
| openssl-devel | 1.0.2k | 1.0.2g (estimated) | CentOS 7 base | https://github.com/openssl/openssl |
| protobuf-compiler | 2.5.0 | 2.4.1 (estimated) | CentOS 7 base | https://github.com/google/protobuf |
| protobuf-devel | 2.5.0 | 2.4.1 (estimated) | CentOS 7 base | https://github.com/google/protobuf |
| re2-devel | 20160401 | 20160201 | CentOS 7 epel-release | https://github.com/google/re2 |
| tpm2-tss-devel | 1.2.0 | 1.0.0 | CentOS 7 base | https://github.com/intel/tpm2-tss |
| tpm2-abrmd-devel | 1.1.0 | 1.1.0 | CentOS 7 base | https://github.com/tpm2-software/tpm2-abrmd |
| cmake | 2.8.12.2 | 2.6.0 (estimated) | CentOS 7 base | https://cmake.org/ |
| cpack | 2.8.12.2 | 2.6.0 (estimated) | CentOS 7 base | https://cmake.org/ |
| git | 1.8.3.1 | 1.6.0 (estimated) | CentOS 7 base | https://github.com/git/git |

View File

@ -1,25 +0,0 @@
Developer Dependencies
======================
These are the dependencies currently used by the TPM2 Provisioner project that must be supplied by the development environment (in this case Debian-based) in order to properly build and package the project.
Please look up their respective names in the appropriate repositories.
If no available repository for the development environment contains the dependencies at an acceptable version level, it is expected that the packages be retrieved and built from their respective source repositories.
| Dependency | Version used | Minimum required | Repository | Project repository |
| -------------------- | ------------ | ------------------ | --------------------- | --------------------------------------------- |
| cppcheck | 1.82 | 1.72 | Ubuntu 18.04 base | http://cppcheck.sourceforge.net/ |
| doxygen | 1.8.13 | 1.8.0 (estimated) | Ubuntu 18.04 base | https://github.com/doxygen/doxygen |
| graphviz | 2.40.1 | 2.28.0 (estimated) | Ubuntu 18.04 base | https://gitlab.com/graphviz/graphviz |
| libcurl4-openssl-dev | 7.47.0 | 7.0.0 (estimated) | Ubuntu 18.04 base | https://github.com/curl/curl |
| liblog4cplus-dev | 1.1.2 | 1.1.2 | Ubuntu 18.04 base | https://github.com/log4cplus/log4cplus |
| libssl-dev | 1.1.0g | 1.0.2g (estimated) | Ubuntu 18.04 base | https://github.com/openssl/openssl |
| protobuf-compiler | 3.0.0 | 2.4.1 (estimated) | Ubuntu 18.04 base | https://github.com/google/protobuf |
| libprotobuf-dev | 3.0.0 | 2.4.1 (estimated) | Ubuntu 18.04 base | https://github.com/google/protobuf |
| libre2-dev | 20180201 | 20160201 | Ubuntu 18.04 base | https://github.com/google/re2 |
| libsapi-dev | 1.0.0 | 1.0.0 | Ubuntu 18.04 base | https://github.com/intel/tpm2-tss |
| tpm2-tss | 1.3.0 | 1.3.0 | Source Code | https://github.com/tpm2-software/tpm2-tss |
| tpm2-abrmd | 1.3.1 | 1.3.1 | Source Code | https://github.com/tpm2-software/tpm2-abrmd |
| cmake | 3.10.2 | 2.6.0 (estimated) | Ubuntu 18.04 base | https://cmake.org/ |
| git | 2.17.1 | 1.6.0 (estimated) | Ubuntu 18.04 base | https://github.com/git/git |

View File

@ -1,145 +0,0 @@
/**
* Copyright (C) 2017-2018, U.S. Government
*/
#ifndef HIRS_PROVISIONERTPM2_INCLUDE_COMMANDTPM2_H_
#define HIRS_PROVISIONERTPM2_INCLUDE_COMMANDTPM2_H_
#include <Logger.h>
#include <ProvisionerTpm2.pb.h>
#include <Tpm2ToolsUtils.h>
#include <Tss.h>
#include <string>
#include <vector>
namespace hirs {
namespace tpm2 {
enum class AsymmetricKeyType {
RSA,
ECC
};
/**
* Manages the issuing of commands to tpm2-tools executables.
*/
class CommandTpm2 {
private:
static const hirs::log::Logger LOGGER;
static const int kMaxRetryCommandAttempts;
static const char* const kAKCertificateHandle;
static const char* const kTpm2ToolsTakeOwnershipCommand;
static const char* const kTpm2ToolsNvDefineCommand;
static const char* const kTpm2ToolsNvListCommand;
static const char* const kTpm2ToolsNvReadCommand;
static const char* const kTpm2ToolsNvReleaseCommand;
static const char* const kTpm2ToolsNvWriteCommand;
static const char* const kTpm2ToolsGetPubAkCommand;
static const char* const kTpm2ToolsGetPubEkCommand;
static const char* const kTpm2ToolsListPersistentCommand;
static const char* const kTpm2ToolsReadPublicCommand;
static const char* const kTpm2ToolsActivateCredential;
static const char* const kTpm2ToolsEvictControlCommand;
static const char* const kTpm2RetryCommandCode;
static const char* const kWellKnownSecret;
static const char* const kRsaAlgorithmId;
static const char* const kEccAlgorithmId;
static const char* const kDefaultAttributeValue;
static const char* const kDefaultOwnerAuthHandle;
static const char* const kDefaultRsaEkCredentialHandle;
static const char* const kDefaultEccEkCredentialHandle;
static const char* const kDefaultPlatformCredentialHandle;
static const char* const kDefaultEkHandle;
static const char* const kDefaultAkHandle;
static const char* const kDefaultAkCertFilename;
static const char* const kDefaultAkNameFilename;
static const char* const kDefaultAkPubFilename;
static const char* const kDefaultEkPubFilename;
static const char* const kTpm2ToolsGetQuoteCommand;
static const char* const kTpm2DefaultQuoteFilename;
static const char* const kTpm2DefaultSigFilename;
static const char* const kTpm2Sha256SigAlgorithm;
static const char* const kTpm2ToolsPcrListCommand;
const hirs::tpm2_tools_utils::Tpm2ToolsVersion version;
uint16_t getNvIndexDataSize(const std::string& nvIndex);
std::string readNvIndex(const std::string& beginNvIndex,
const uint16_t& dataSize);
bool hasNvIndexDefined(const std::string& nvIndex);
void releaseNvIndex(const std::string& nvIndex);
std::string createNvReadCommandArgs(const std::string& nvIndexValue,
const uint16_t& offset,
const uint16_t& readSize);
std::string createNvWriteCommandArgs(const std::string& nvIndexValue,
const std::string& writeFile);
bool hasPersistentObject(const std::string& handle);
void flushPersistentObject(const std::string& handle);
void createPublicAreaFile(const std::string& keyHandle,
const std::string& filename);
std::string getPublicArea(const std::string& filename);
std::string runTpm2CommandWithRetry(const std::string& command,
const std::string& args,
int sourceCodeLineNumber);
public:
static const char* const kDefaultIdentityClaimResponseFilename;
static const char* const kDefaultActivatedIdentityFilename;
explicit CommandTpm2(
const hirs::tpm2_tools_utils::Tpm2ToolsVersion& version
= hirs::tpm2_tools_utils::Tpm2ToolsVersionChecker
::findTpm2ToolsVersion());
void setAuthData();
std::string getEndorsementCredentialDefault(
const AsymmetricKeyType& keyType);
std::string getPlatformCredentialDefault();
std::string getStoredCredential(
const std::string& credentialHandle);
void createEndorsementKey(const AsymmetricKeyType& keyType =
AsymmetricKeyType::RSA);
std::string getEndorsementKeyPublicArea();
void createAttestationKey();
std::string getAttestationKeyPublicArea();
hirs::pb::IdentityClaim createIdentityClaim(
const hirs::pb::DeviceInfo& deviceInfo,
const std::string& akPublicArea,
const std::string& ekPublicArea,
const std::string& endorsementCredential = {},
const std::vector<std::string>& platformCredentials = {});
std::string activateIdentity();
void storeAKCertificate(const std::string& akCertificateByteString);
std::string getQuote(const std::string& pcr_selection,
const std::string& nonce);
std::string getPcrList();
};
} // namespace tpm2
} // namespace hirs
#endif // HIRS_PROVISIONERTPM2_INCLUDE_COMMANDTPM2_H_

View File

@ -1,43 +0,0 @@
/**
* Copyright (C) 2017-2018, U.S. Government
*/
#ifndef HIRS_PROVISIONERTPM2_INCLUDE_DEVICEINFOCOLLECTOR_H_
#define HIRS_PROVISIONERTPM2_INCLUDE_DEVICEINFOCOLLECTOR_H_
#include <Logger.h>
#include <ProvisionerTpm2.pb.h>
#include <utility>
#include <string>
#include <vector>
/**
* Manages collection of device information for the client. Retrieves the OS,
* network, hardware, firmware, and TPM info.
*/
class DeviceInfoCollector {
private:
DeviceInfoCollector() {}
static const hirs::log::Logger LOGGER;
static std::vector<std::pair<std::string, std::string>> getNetworks();
static hirs::pb::FirmwareInfo collectFirmwareInfo();
static hirs::pb::HardwareInfo collectHardwareInfo();
static std::string collectHostname();
static hirs::pb::NetworkInfo collectNetworkInfo();
static hirs::pb::OsInfo collectOsInfo();
public:
/**
* Collect all device info from the system and return it in a filled out
* DeviceInfo object.
*/
static hirs::pb::DeviceInfo collectDeviceInfo();
};
#endif // HIRS_PROVISIONERTPM2_INCLUDE_DEVICEINFOCOLLECTOR_H_

View File

@ -1,31 +0,0 @@
/**
* Copyright (C) 2017-2018, U.S. Government
*/
#ifndef HIRS_PROVISIONERTPM2_INCLUDE_HIRSRUNTIMEEXCEPTION_H_
#define HIRS_PROVISIONERTPM2_INCLUDE_HIRSRUNTIMEEXCEPTION_H_
#include <stdexcept>
#include <string>
namespace hirs {
namespace exception {
/**
* Represents a runtime exception thrown by HIRS code.
*/
class HirsRuntimeException : public std::runtime_error {
private:
static std::string buildMessage(const std::string& msg,
const std::string& origin = "");
public:
HirsRuntimeException(const std::string& msg,
const std::string& origin);
virtual ~HirsRuntimeException();
};
} // namespace exception
} // namespace hirs
#endif // HIRS_PROVISIONERTPM2_INCLUDE_HIRSRUNTIMEEXCEPTION_H_

View File

@ -1,67 +0,0 @@
/**
* Copyright (C) 2017-2018, U.S. Government
*/
#ifndef HIRS_PROVISIONERTPM2_INCLUDE_LOGGER_H_
#define HIRS_PROVISIONERTPM2_INCLUDE_LOGGER_H_
#include <log4cplus/logger.h>
#include <string>
#include <exception>
namespace hirs {
namespace log {
/**
* The Logger class provides a wrapper for log4cplus that allows for
* getting standardized Loggers in the TPM 2 Provisioner Library.
*/
class Logger {
private:
static const char* const kDefaultProvisionerLoggerName;
static const char* const kPropFileLocation;
const log4cplus::Logger kLogger;
explicit Logger(std::string loggerName);
enum class LogLevel {
DEBUG,
ERROR,
FATAL,
INFO,
TRACE,
WARN
};
void log(const LogLevel& logLevel, const std::string& msg,
const std::exception* ex) const;
static void setThresholdFromLoggingProperties(log4cplus::Logger logger);
public:
static Logger getDefaultLogger();
static Logger getLogger(const std::string& loggerName);
void debug(const std::string& msg) const;
void debug(const std::string& msg, const std::exception* ex) const;
void error(const std::string& msg) const;
void error(const std::string& msg, const std::exception* ex) const;
void fatal(const std::string& msg) const;
void fatal(const std::string& msg, const std::exception* ex) const;
void info(const std::string& msg) const;
void info(const std::string& msg, const std::exception* ex) const;
void trace(const std::string& msg) const;
void trace(const std::string& msg, const std::exception* ex) const;
void warn(const std::string& msg) const;
void warn(const std::string& msg, const std::exception* ex) const;
};
} // namespace log
} // namespace hirs
#endif // HIRS_PROVISIONERTPM2_INCLUDE_LOGGER_H_

View File

@ -1,58 +0,0 @@
/**
* Copyright (C) 2017-2018, U.S. Government
*/
#ifndef HIRS_PROVISIONERTPM2_INCLUDE_PROCESS_H_
#define HIRS_PROVISIONERTPM2_INCLUDE_PROCESS_H_
#include "Logger.h"
#include <string>
#include <iostream>
namespace hirs {
namespace utils {
/**
* The Process class represents a Linux process, its return value,
* and the standard output stream.
*/
class Process {
private:
static const hirs::log::Logger LOGGER;
static const char* const kPgrepCommand;
static const int kMaxStatFileProcessNameLength;
std::string executable;
std::string arguments;
std::string output;
public:
explicit Process(const std::string& executable,
const std::string& arguments = "");
int run();
int run(std::ostream& osForErrorLogging);
std::string getOutputString() const;
static std::string run(const std::string& executable,
const std::string& arguments,
const std::string& sourceFileName,
int sourceLineNumber);
static std::string runData(const std::string& executable,
const std::string& arguments,
const std::string& sourceFileName,
int sourceLineNumber);
static bool isRunning(const std::string& executable);
};
} // namespace utils
} // namespace hirs
#endif // HIRS_PROVISIONERTPM2_INCLUDE_PROCESS_H_

View File

@ -1,42 +0,0 @@
/**
* Copyright (C) 2017-2018, U.S. Government
*/
#ifndef HIRS_PROVISIONERTPM2_INCLUDE_PROPERTIES_H_
#define HIRS_PROVISIONERTPM2_INCLUDE_PROPERTIES_H_
#include <map>
#include <string>
#include "Logger.h"
namespace hirs {
namespace properties {
/**
* Manages the loading and retrieval of key-value configuration.
*/
class Properties {
private:
static const hirs::log::Logger LOGGER;
std::map<std::string, std::string> properties;
public:
Properties();
explicit Properties(const std::string& filepath);
void load(const std::string& filepath);
std::string get(const std::string& key);
std::string get(const std::string& key,
const std::string& defaultValue);
bool isSet(const std::string& key);
void set(const std::string& key, const std::string& value);
};
} // namespace properties
} // namespace hirs
#endif // HIRS_PROVISIONERTPM2_INCLUDE_PROPERTIES_H_

View File

@ -1,69 +0,0 @@
/**
* Copyright (C) 2017-2018, U.S. Government
*/
#ifndef HIRS_PROVISIONERTPM2_INCLUDE_RESTFULCLIENTPROVISIONER_H_
#define HIRS_PROVISIONERTPM2_INCLUDE_RESTFULCLIENTPROVISIONER_H_
#include <Logger.h>
#include <ProvisionerTpm2.pb.h>
#include <string>
/**
* Manages the sending of messages to the ACA and their relevant replies.
*/
class RestfulClientProvisioner {
private:
// Logger
static const hirs::log::Logger LOGGER;
static const char * const PROP_FILE_LOC;
static const char * const PROP_ACA_FQDN;
static const char * const PROP_ACA_PORT;
static const char * const ACA_ERROR_FIELDNAME;
/**
* IP address of ACA
*/
std::string acaAddress;
/**
* Port used by the ACA to service requests.
*/
int port;
public:
RestfulClientProvisioner();
RestfulClientProvisioner(const std::string& acaAddress, int acaPort);
/**
* Return the IP address of the ACA
* @return the IP address of the ACA
*/
std::string getAcaAddress();
/**
* Sends the identity claim to the ACA to initiate the identity claim
* procedure. Return the wrapped challenge nonce reply from the ACA for
* decoding with TPM2_ActivateCredential.
*
* @param identityClaim request containing deviceInfo, EK public area
* AK public area and optionally an Endorsement and/or Platform Credential
* @returns the byte-encoded encrypted nonce blob
*/
std::string sendIdentityClaim(hirs::pb::IdentityClaim identityClaim);
/**
* Sends the request to get the public Attestation Certificate from the
* ACA. Contains the decrypted nonce returned from
* RestfulClientProvisioner::sendIdentityClaim.
*
* @param certificateRequest request containing nonce
* @return the byte-encoded public attestation certificate
*/
std::string sendAttestationCertificateRequest(
hirs::pb::CertificateRequest certificateRequest);
};
#endif // HIRS_PROVISIONERTPM2_INCLUDE_RESTFULCLIENTPROVISIONER_H_

View File

@ -1,112 +0,0 @@
/**
* Copyright (C) 2017-2018, U.S. Government
*/
#ifndef HIRS_PROVISIONERTPM2_INCLUDE_TPM2TOOLSUTILS_H_
#define HIRS_PROVISIONERTPM2_INCLUDE_TPM2TOOLSUTILS_H_
#include <string>
#include <unordered_map>
namespace hirs {
namespace tpm2_tools_utils {
/**
* Enum class that provides list of supported tpm2_tools versions
*/
enum class Tpm2ToolsVersion {
VERSION_1_1_0,
VERSION_2_1_0,
VERSION_3
};
/**
* Utility class that determines the version of tpm2_tools present on the
* system.
*/
class Tpm2ToolsVersionChecker {
private:
static const std::unordered_map<std::string, Tpm2ToolsVersion> kVersionMap;
static const std::unordered_map<std::string,
Tpm2ToolsVersion> kMaxSupportedVersionMap;