Skip to content

Commit f898440

Browse files
lcpDaniel Kiper
authored and
Daniel Kiper
committed
tests: Add tpm2_key_protector_test
For the tpm2_key_protector module, the TCG2 command submission function is the only difference between a QEMU instance and grub-emu. To test TPM2 key unsealing with a QEMU instance, it requires an extra OS image to invoke grub-protect to seal the LUKS key, rather than a simple grub-shell rescue CD image. On the other hand, grub-emu can share the emulated TPM2 device with the host, so that we can seal the LUKS key on host and test key unsealing with grub-emu. This test script firstly creates a simple LUKS image to be loaded as a loopback device in grub-emu. Then an emulated TPM2 device is created by "swtpm chardev" and PCR 0 and 1 are extended. There are several test cases in the script to test various settings. Each test case uses grub-protect or tpm2-tools to seal the LUKS password with PCR 0 and PCR 1. Then grub-emu is launched to load the LUKS image, try to mount the image with tpm2_key_protector_init and cryptomount, and verify the result. Based on the idea from Michael Chang. Cc: Michael Chang <[email protected]> Cc: Stefan Berger <[email protected]> Cc: Glenn Washburn <[email protected]> Signed-off-by: Gary Lin <[email protected]> Reviewed-by: Daniel Kiper <[email protected]> Reviewed-by: Stefan Berger <[email protected]> Tested-by: Stefan Berger <[email protected]>
1 parent 76a2bcb commit f898440

File tree

3 files changed

+400
-1
lines changed

3 files changed

+400
-1
lines changed

Makefile.util.def

+6
Original file line numberDiff line numberDiff line change
@@ -1290,6 +1290,12 @@ script = {
12901290
common = tests/asn1_test.in;
12911291
};
12921292

1293+
script = {
1294+
testcase = native;
1295+
name = tpm2_key_protector_test;
1296+
common = tests/tpm2_key_protector_test.in;
1297+
};
1298+
12931299
program = {
12941300
testcase = native;
12951301
name = example_unit_test;

0 commit comments

Comments
 (0)