Skip to contentSkip to conversation

boot aggregate test

RFC PATCH New Mimi Zohar 1 participant 4 messages Mar 25, 2020 Keys-trusted

lore
Share & tools
lore

Mimi Zohar

author maintainer
#0 lore raw

cover 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
author maintainer
#1 lore raw

RFC 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
index 029f2ffd5efb..ff928e177406 100644
@@ -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
new file mode 100644
index 000000000000..937b5038127e
@@ -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
new file mode 100644
index 0000000000000000000000000000000000000000..338ba22f9e41e9039ff5ce81bb18197c5ac1647c
GIT binary patch
Signature · 1 line
2.7.5
author maintainer
#2 lore raw

RFC PATCH 2/3 ima-evm-utils: tests: verify the last "boot_aggregate" record

In reply to Mimi Zohar

For 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
index 307a309433fe..73af423e30a1 100755
@@ -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
author maintainer
#3 lore raw

RFC PATCH 3/3 ima_evm_utils: tests: color boot_aggregate.test tty output

In reply to Mimi Zohar

Use 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
index 73af423e30a1..38084d5cbf45 100755
@@ -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