diff --git a/.ci/docker/docker-compose-system-test.yml b/.ci/docker/docker-compose-system-test.yml index 37d9366c..0417cd41 100644 --- a/.ci/docker/docker-compose-system-test.yml +++ b/.ci/docker/docker-compose-system-test.yml @@ -9,7 +9,7 @@ services: ports: - "${HIRS_ACA_PORTAL_PORT}:${HIRS_ACA_PORTAL_CONTAINER_PORT}" entrypoint: /bin/bash -c - command: [HIRS/.ci/setup/setup_aca.sh] + command: [HIRS/.ci/setup/container/setup_aca.sh] hostname: ${HIRS_ACA_HOSTNAME} networks: hirs_aca_system_tests: diff --git a/.ci/setup/setup_aca.sh b/.ci/setup/container/setup_aca.sh similarity index 100% rename from .ci/setup/setup_aca.sh rename to .ci/setup/container/setup_aca.sh diff --git a/.ci/setup/container/setup_tpm2provisioner.sh b/.ci/setup/container/setup_tpm2provisioner.sh new file mode 100755 index 00000000..6a4abed6 --- /dev/null +++ b/.ci/setup/container/setup_tpm2provisioner.sh @@ -0,0 +1,36 @@ +#!/bin/bash +######################################################################################### +# Script to setup the TPM 2.0 Provisioner for System Tests +# Initial setup only use resetTpm2Emulator to reset PCR values in subsequent tests +######################################################################################### +set -e +pushd / > /dev/null +echo "Setting up TPM emulator for the TPM2 Provisioner" + +source /HIRS/.ci/setup/container/tpm2_common.sh + +#Wait for the ACA to spin up, if it hasnt already +waitForAca + +# Install packages +installProvisioner + +# set location of tcg artifacts +setTcgProperties +#echo "Contents of /etc/hirs is $(ls -al /etc/hirs)"; + +# Install TPM 2.0 Emulator +initTpm2Emulator + +# Update the hirs-site.config file +updateHirsSiteConfigFile + +echo "TPM 2.0 Emulator NV RAM list" +tpm2_nvlist + +echo "" +echo "===========HIRS ACA TPM 2.0 Provisioner Setup Complete!===========" + +popd > /dev/null + +#tpm2_pcrlist -g sha256 diff --git a/.ci/setup/setup_tpmprovisioner.sh b/.ci/setup/container/setup_tpmprovisioner.sh similarity index 100% rename from .ci/setup/setup_tpmprovisioner.sh rename to .ci/setup/container/setup_tpmprovisioner.sh diff --git a/.ci/setup/setup_tpm2provisioner.sh b/.ci/setup/container/tpm2_common.sh similarity index 86% rename from .ci/setup/setup_tpm2provisioner.sh rename to .ci/setup/container/tpm2_common.sh index 1aea584f..ed08ed25 100755 --- a/.ci/setup/setup_tpm2provisioner.sh +++ b/.ci/setup/container/tpm2_common.sh @@ -1,11 +1,8 @@ #!/bin/bash ######################################################################################### -# Script to setup the TPM 2.0 Provisioner Docker Image for System Tests +# Support scripts for the TPM 2.0 Provisioner System Tests # ######################################################################################### -set -e -pushd / > /dev/null -echo "Setting up TPM emulator for the TPM2 Provisioner" # Function to make and install TPM 2.0 Provisioner packages function installProvisioner { @@ -24,8 +21,8 @@ function setTpmPcrValues { mkdir /ibmtss pushd /ibmtss > /dev/null echo "Installing IBM TSS to set the TPM simulator intial values correctly..." - wget --no-check-certificate https://downloads.sourceforge.net/project/ibmtpm20tss/ibmtss1.5.0.tar.gz > /dev/null - tar -zxvf ibmtss1.5.0.tar.gz > /dev/null + wget --no-check-certificate https://downloads.sourceforge.net/project/ibmtpm20tss/ibmtss1.6.0.tar.gz > /dev/null + tar -zxvf ibmtss1.6.0.tar.gz > /dev/null cd utils make -f makefiletpmc > /dev/null cd ../utils @@ -61,7 +58,7 @@ function initTpm2Emulator { echo "DBus started" # Give DBus time to start up - sleep 5 + sleep 3 /ibmtpm/src/./tpm_server & echo "TPM Emulator started" @@ -76,7 +73,7 @@ function initTpm2Emulator { echo "TPM2-Abrmd started" # Give ABRMD time to start and register on the DBus - sleep 2 + sleep 1 # Certificates ek_cert="/HIRS/.ci/setup/certs/ek_cert.der" @@ -112,10 +109,25 @@ function initTpm2Emulator { sed -i "s/WARN/INFO/" /etc/hirs/TPM2_Provisioner/log4cplus_config.ini } +# Clear out existing TPM PCR values by restarting the ibm tpm simulator +function resetTpm2Emulator { + echo "clearing the TPM PCR values" + # Stop tpm2-abrmd and the tpm server + pkill -f "tpm2-abrmd" + pkill -f "tpm_server" + # restart the tpm server and tpm2-abrmd + /ibmtpm/src/./tpm_server & + pushd /ibmtss/utils > /dev/null + ./startup + popd > /dev/null + tpm2-abrmd -t socket & + sleep 1 + # tpm2_pcrlist -g sha256 +} + # Function to update the hirs-site.config file function updateHirsSiteConfigFile { HIRS_SITE_CONFIG="/etc/hirs/hirs-site.config" - echo "" echo "===========Updating ${HIRS_SITE_CONFIG}, using values from /HIRS/.ci/docker/.env file...===========" cat /HIRS/.ci/docker/.env @@ -142,8 +154,8 @@ DEFAULT_SITE_CONFIG_FILE cat /etc/hirs/hirs-site.config } -function waitForAca { # Wait for ACA to boot +function waitForAca { echo "Waiting for ACA to spin up at address ${HIRS_ACA_PORTAL_IP} on port ${HIRS_ACA_PORTAL_PORT} ..." until [ "`curl --silent --connect-timeout 1 -I -k https://${HIRS_ACA_PORTAL_IP}:${HIRS_ACA_PORTAL_PORT}/HIRS_AttestationCAPortal | grep '302 Found'`" != "" ]; do sleep 1; @@ -151,27 +163,3 @@ function waitForAca { done echo "ACA is up!" } - -#Wait for the ACA to spin up, if it hasnt already -waitForAca - -# Install packages -installProvisioner - -# set location of tcg artifacts -setTcgProperties -#echo "Contents of /etc/hirs is $(ls -al /etc/hirs)"; - -# Install TPM 2.0 Emulator -initTpm2Emulator - -# Update the hirs-site.config file -updateHirsSiteConfigFile - -echo "TPM 2.0 Emulator NV RAM list" -tpm2_nvlist - -echo "" -echo "===========HIRS ACA TPM 2.0 Provisioner Setup Complete!===========" - -popd > /dev/null \ No newline at end of file diff --git a/.ci/system-tests/container/pc_setup.sh b/.ci/system-tests/container/pc_setup.sh index 20697ad1..660c69f1 100644 --- a/.ci/system-tests/container/pc_setup.sh +++ b/.ci/system-tests/container/pc_setup.sh @@ -2,12 +2,18 @@ ######################################################################################### # Setup for platform certificates for testing # Copies platform certs (Base and Delta) to the tcg directory +# usage pc_setup.sh ######################################################################################### profile=$1 test=$2 +tcgDir="/boot/tcg" compscript="$profile"_"$test"_allcomponents.sh hwlist="$profile"_"$test"_hw.json +testDir="/HIRS/.ci/system-tests/profiles/$profile/$test" +pcDir=$testDir/platformcerts +profileDir="/HIRS/.ci/system-tests/profiles/$profile" + # Current TCG folder for platform certs, likely to change with release of the next FIM specification tcgDir=/boot/tcg/cert/platform/ mkdir -p $tcgDir; # Create the platform cert folder if its not there @@ -34,7 +40,11 @@ fi cp -f $allCompJson /opt/paccor/scripts/$hwlist ; # Step 3: Copy the platform cert to tcg folder on boot drive -pushd /HIRS/.ci/system-tests/profiles/$profile/$test/platformcerts/ > /dev/null +# a: See if test specific swidtag folder exists, if not use the defualt folder +if [[ ! -d $pcDir ]]; then + pcDir=$profileDir/default/platformcerts; +fi +pushd $pcDir > /dev/null # Skip copy of platform cert if .gitigore exists (empty profile) if [[ ! -f ".gitignore" ]]; then for cert in * ; do diff --git a/.ci/system-tests/container/rim_setup.sh b/.ci/system-tests/container/rim_setup.sh index 82b11691..7a93114a 100644 --- a/.ci/system-tests/container/rim_setup.sh +++ b/.ci/system-tests/container/rim_setup.sh @@ -1,40 +1,61 @@ #!/bin/bash ######################################################################################### # Setup for PC Client Reference Integrity Manifest (RIM) tests -# +# usage rim_setup.sh