2022-01-25 15:54:54 +00:00
|
|
|
#!/bin/bash
|
|
|
|
#########################################################################################
|
|
|
|
# Setup for PC Client Reference Integrity Manifest (RIM) tests
|
2022-02-17 19:50:10 +00:00
|
|
|
# usage rim_setup.sh <profile> <test> <option>
|
|
|
|
# use "clear" option to clear existing TPM PCR values
|
2022-01-25 15:54:54 +00:00
|
|
|
#########################################################################################
|
|
|
|
|
|
|
|
profile=$1
|
|
|
|
test=$2
|
2024-06-07 10:28:25 +00:00
|
|
|
ciTestDir="/ci_test"
|
|
|
|
tcgDir="$ciTestDir/boot/efi/EFI/tcg"
|
|
|
|
|
|
|
|
# Profile selections
|
2024-06-07 17:27:08 +00:00
|
|
|
profileDir="/hirs/.ci/system-tests/profiles/$profile"
|
2022-02-03 21:58:11 +00:00
|
|
|
defaultDir="$profileDir/default"
|
2024-06-07 17:27:08 +00:00
|
|
|
testDir="/hirs/.ci/system-tests/profiles/$profile/$test"
|
2022-01-26 15:24:29 +00:00
|
|
|
eventLog="$testDir"/"$profile"_"$test"_binary_bios_measurements
|
2022-02-03 20:30:10 +00:00
|
|
|
swidDir="$testDir/swidtags"
|
|
|
|
rimDir="$testDir/rims"
|
|
|
|
pcrScript="$testDir/"$profile"_"$test"_setpcrs.sh"
|
2024-06-07 10:28:25 +00:00
|
|
|
ciTestEventLog="$ciTestDir/binary_bios_measurements"
|
2022-02-04 22:02:50 +00:00
|
|
|
|
2022-02-03 20:30:10 +00:00
|
|
|
echo "Test is using RIM files from $profile : $test"
|
2022-01-25 15:54:54 +00:00
|
|
|
|
2022-02-03 20:30:10 +00:00
|
|
|
# Make sure TCG defined RIM folders exist and are cleared out
|
2022-01-25 15:54:54 +00:00
|
|
|
mkdir -p $tcgDir/manifest/rim/; # Create the platform cert folder if its not there
|
2022-02-03 20:30:10 +00:00
|
|
|
rm -f $tcgDir/manifest/rim/*; # clear out any previous data
|
2022-01-25 15:54:54 +00:00
|
|
|
|
|
|
|
mkdir -p $tcgDir/manifest/swidtag/; # Create the platform cert folder if its not there
|
|
|
|
rm -f $tcgDir/manifest/swidtag/*; # clear out any previous data
|
|
|
|
|
2024-06-07 10:28:25 +00:00
|
|
|
# Step 1: Copy binary_bios_measurement file
|
2024-06-07 17:27:08 +00:00
|
|
|
if [ ! -e "$eventLog" ]; then
|
|
|
|
eventLog="$defaultDir"/laptop_default_binary_bios_measurements
|
|
|
|
fi
|
2024-06-07 10:28:25 +00:00
|
|
|
echo "eventLog used was $eventLog"
|
|
|
|
cp "$eventLog" "$ciTestEventLog"
|
2022-01-25 15:54:54 +00:00
|
|
|
|
|
|
|
# Step 2: Copy Base RIM files to the TCG folder
|
2022-02-03 20:30:10 +00:00
|
|
|
# a: See if test specific swidtag folder exists, if not use the defualt folder
|
|
|
|
if [[ ! -d $swidDir ]]; then
|
|
|
|
swidDir=$defaultDir/swidtags;
|
|
|
|
fi
|
|
|
|
pushd $swidDir > /dev/null
|
2022-01-25 15:54:54 +00:00
|
|
|
if [[ ! -f ".gitignore" ]]; then
|
|
|
|
for swidtag in * ; do
|
|
|
|
cp -f $swidtag $tcgDir/manifest/swidtag/$swidtag;
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
popd > /dev/null
|
2022-02-03 20:30:10 +00:00
|
|
|
# Step 3: Copy Support RIM files to the TCG folder in the same mannor
|
|
|
|
if [[ ! -d $rimDir ]]; then
|
|
|
|
rimDir=$defaultDir/rims;
|
|
|
|
fi
|
|
|
|
pushd $rimDir > /dev/null
|
2022-01-25 15:54:54 +00:00
|
|
|
|
|
|
|
if [[ ! -f ".gitignore" ]]; then
|
|
|
|
for rim in * ; do
|
|
|
|
cp -f $rim $tcgDir/manifest/rim/$rim;
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
popd > /dev/null
|
|
|
|
|
|
|
|
#Step 4, run the setpcr script to make the TPM emulator hold values that correspond the binary_bios_measurement file
|
2022-02-03 23:52:12 +00:00
|
|
|
# a: Clear the TPM PCR registers vi a call to the tss clear
|
|
|
|
# b: Check if a test specific setpcr.sh file exists. If not use the profiles default script
|
2022-02-04 22:02:50 +00:00
|
|
|
|
2022-02-03 23:52:12 +00:00
|
|
|
|
2022-02-03 20:30:10 +00:00
|
|
|
if [[ ! -f $pcrScript ]]; then
|
2022-02-03 21:58:11 +00:00
|
|
|
pcrScript="$profileDir/default/"$profile"_default_setpcrs.sh"
|
2022-02-03 20:30:10 +00:00
|
|
|
fi
|
|
|
|
sh $pcrScript;
|
2022-02-17 21:47:02 +00:00
|
|
|
#echo "PCR script was $pcrScript"
|
2022-02-17 19:50:10 +00:00
|
|
|
#tpm2_pcrlist -g sha256
|
2022-01-25 15:54:54 +00:00
|
|
|
|
2024-06-07 10:28:25 +00:00
|
|
|
# Done with rim_setup
|