boot aggregate test
Mimi Zohar
maintainercover boot aggregate test
The "boot_aggregate" contained in the IMA measurement list has always been a SHA1 hash. With Roberto's "ima: support stronger algorithms for attestation" patch set, the hash algorithm used to calculate the "boot_aggregate" will either be the IMA default hash algorithm or fall back to using SHA1 for TPM 1.2 or SHA256 for TPM 2.0, assuming a SHA256 TPM bank exists.
This test may be used to verify the "boot_aggregate" based on a physical TPM or a software TPM. If a software TPM is not running on the system, one is started and initialized by walking a sample binary_bios_measurements log and extending the software TPM with those values. The "boot_aggregate" is then calculated and compared against the sample ascii_runtime_measurements record.
This test depends on Vitaly's "ima-evm-utils: Add some tests for evmctl" patch being upstreamed. I would appreciate some review on both his patch and on this patch set. To help facilitate this review, I've pushed out a next-testing topic branch. Included in this topic branch is Patrick Uiterwijk's support for reading the TPM PCRs using Intel's TSS2.
Thanks!
Mimi
Mimi Zohar (3):
ima-evm-utils: tests: verify boot_aggregate
ima-evm-utils: tests: verify the last "boot_aggregate" record
ima_evm_utils: tests: color boot_aggregate.test tty output
tests/Makefile.am | 2 +- tests/boot_aggregate.test | 150 ++++++++++++++++++++++++++++++++++ tests/test_ascii_runtime_measurements | 3 + tests/test_binary_bios_measurements | Bin 0 -> 23248 bytes 4 files changed, 154 insertions(+), 1 deletion(-) create mode 100755 tests/boot_aggregate.test create mode 100644 tests/test_ascii_runtime_measurements create mode 100644 tests/test_binary_bios_measurements
Signature · 1 line
2.7.5
Mimi Zohar
maintainerRFC PATCH 1/3 ima-evm-utils: tests: verify boot_aggregate
Calculate the boot_aggregate for each TPM bank and verify that the boot_aggregate in the IMA measurement list matches one of them.
A software TPM may be used to verify the boot_aggregate. If a software TPM is not already running on the system, this test starts one and initializes the TPM PCR banks by walking the sample binary_bios_measurements event log, included in this directory, and extending the TPM PCRs. The associated ascii_runtime_measurements for verifying the calculated boot_aggregate is included in this directory as well.
--- tests/Makefile.am | 2 +- tests/boot_aggregate.test | 144 ++++++++++++++++++++++++++++++++++ tests/test_ascii_runtime_measurements | 3 + tests/test_binary_bios_measurements | Bin 0 -> 23248 bytes 4 files changed, 148 insertions(+), 1 deletion(-) create mode 100755 tests/boot_aggregate.test create mode 100644 tests/test_ascii_runtime_measurements create mode 100644 tests/test_binary_bios_measurements
tests/Makefile.am +1 -1
@@ -1,7 +1,7 @@ check_SCRIPTS = TESTS = $(check_SCRIPTS) -check_SCRIPTS += ima_hash.test sign_verify.test +check_SCRIPTS += ima_hash.test sign_verify.test boot_aggregate.test clean-local: -rm -f *.txt *.out *.sig *.sig2
tests/boot_aggregate.test new file +144 -0
144 lines not on this page · raw message
tests/test_ascii_runtime_measurements new file +3 -0
@@ -0,0 +1,3 @@ +10 cf41b43c4031672fcc2bd358b309ad33b977424f ima-ng sha256:f1b4c7c9b27e94569f4c2b64051c452bc609c3cb891dd7fae06b758f8bc83d14 boot_aggregate +10 983dcd8e6f7c84a1a5f10e762d1850623966ceab ima-ng sha256:ae06e032a65fed8102aff5f8f31c678dcf2eb25b826f77ecb699faa0411f89e0 /init +10 b6e4d01c73f6e4b698eaf48e7d76a2bae0c02514 ima-ng sha256:4b1764ee112aa8b2a6ae9a3a2f1e272b6601681f610708497673cd49e5bd2f5c /bin/sh
tests/test_binary_bios_measurements new file binary +0 -0
Signature · 1 line
2.7.5
Mimi Zohar
maintainerRFC PATCH 2/3 ima-evm-utils: tests: verify the last "boot_aggregate" record
In reply to Mimi ZoharFor each kexec, an additional "boot_aggregate" will appear in the measurement list, assuming the previous measurement list is carried across kexec.
Verify that the last "boot_aggregate" record in the IMA measurement list matches. The "boot_aggregate" is either the last field (e.g. "ima-ng") or the second to last field (e.g. "ima-sig") in the measurement list record.
--- tests/boot_aggregate.test | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
tests/boot_aggregate.test +7 -1
@@ -98,6 +98,12 @@ display_pcrs() { } # The first entry in the IMA measuremnet list is the "boot_aggregate". +# For each kexec, an additional "boot_aggregate" will appear in the +# measurement list, assuming the previous measurement list is carried +# across the kexec. +# +# Verify that the last "boot_aggregate" record in the IMA measurement +# list matches. check() { echo "INFO: Calculating the boot_aggregate (PCRs 0 - 7) for multiple banks" bootaggr=$(evmctl ima_boot_aggregate)
@@ -113,7 +119,7 @@ check() { if [ "$VERBOSE" != "0" ]; then echo "$hash" fi - if grep -q "${hash}" "${ASCII_RUNTIME_MEASUREMENTS}"; then + if grep -e "boot_aggregate$" -e "boot_aggregate.$" "${ASCII_RUNTIME_MEASUREMENTS}" | tail -n 1 | grep -q "${hash}"; then echo "SUCCESS: boot_aggregate ${hash} found" return $OK fi
Signature · 1 line
2.7.5
Mimi Zohar
maintainerRFC PATCH 3/3 ima_evm_utils: tests: color boot_aggregate.test tty output
In reply to Mimi ZoharUse the "functions.sh" tty color scheme, which defines SKIP as CYAN.
FAILURE: RED (31)
SUCCESS: GREEN (32)
SKIP: CYAN (36)
Should VERBOSE or informational messages be color coded?
--- tests/boot_aggregate.test | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
tests/boot_aggregate.test +5 -5
@@ -49,7 +49,7 @@ swtpm_start() { local swtpm="$(which tpm_server)" if [ -z ${swtpm} ]; then - echo "SKIP: Softare TPM (tpm_server) not found" + echo $CYAN"SKIP: Softare TPM (tpm_server) not found"$NORM return $SKIP fi
@@ -68,7 +68,7 @@ swtpm_start() { # Initialize the software TPM using the sample binary_bios_measurements log. swtpm_init() { if [ ! -f ${TSSDIR}/tssstartup ] || [ ! -f ${TSSDIR}/tsseventextend ]; then - echo "SKIP: tssstartup and tsseventextend needed for test" + echo $CYAN"SKIP: tssstartup and tsseventextend needed for test"$NORM return $SKIP fi
@@ -108,7 +108,7 @@ check() { echo "INFO: Calculating the boot_aggregate (PCRs 0 - 7) for multiple banks" bootaggr=$(evmctl ima_boot_aggregate) if [ $? -ne 0 ]; then - echo "SKIP: evmctl ima_boot_aggregate: $bootaggr" + echo $CYAN"SKIP: evmctl ima_boot_aggregate: $bootaggr"$NORM exit $SKIP fi
@@ -120,11 +120,11 @@ check() { echo "$hash" fi if grep -e "boot_aggregate$" -e "boot_aggregate.$" "${ASCII_RUNTIME_MEASUREMENTS}" | tail -n 1 | grep -q "${hash}"; then - echo "SUCCESS: boot_aggregate ${hash} found" + echo $GREEN"SUCCESS: boot_aggregate ${hash} found"$NORM return $OK fi done - echo "FAILURE: boot_aggregate not found" + echo $RED"FAILURE: boot_aggregate not found"$NORM return $FAIL }
Signature · 1 line
2.7.5