diff options
author | Simon Glass <sjg@chromium.org> | 2021-07-18 14:18:06 -0600 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2021-08-01 09:05:24 -0600 |
commit | 1c6608bd92acfa3a4c269ccdcb92905a4e512813 (patch) | |
tree | 43bb1198016b8d21d52696b3cd4075b6faea6a11 /test | |
parent | 9f0b53564f035743a2ce60636cadd17c97937dee (diff) | |
download | u-boot-1c6608bd92acfa3a4c269ccdcb92905a4e512813.tar.gz u-boot-1c6608bd92acfa3a4c269ccdcb92905a4e512813.tar.bz2 u-boot-1c6608bd92acfa3a4c269ccdcb92905a4e512813.zip |
sandbox: tpm: Support extending a PCR multiple times
It is fairly easy to handle this case and it makes the emulator more
useful, since PCRs are commonly extended several times.
Add support for this, using U-Boot's sha256 support.
For now sandbox only supports a single PCR, but that is enough for the
tests that currently exist.
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'test')
-rw-r--r-- | test/py/tests/test_tpm2.py | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/test/py/tests/test_tpm2.py b/test/py/tests/test_tpm2.py index 70f906da51..ac04f7191e 100644 --- a/test/py/tests/test_tpm2.py +++ b/test/py/tests/test_tpm2.py @@ -216,7 +216,9 @@ def test_tpm2_pcr_extend(u_boot_console): output = u_boot_console.run_command('echo $?') assert output.endswith('0') - read_pcr = u_boot_console.run_command('tpm2 pcr_read 0 0x%x' % ram) + # Read the value back into a different place so we can still use 'ram' as + # our zero bytes + read_pcr = u_boot_console.run_command('tpm2 pcr_read 0 0x%x' % (ram + 0x20)) output = u_boot_console.run_command('echo $?') assert output.endswith('0') assert 'f5 a5 fd 42 d1 6a 20 30 27 98 ef 6e d3 09 97 9b' in read_pcr @@ -226,6 +228,20 @@ def test_tpm2_pcr_extend(u_boot_console): new_updates = int(re.findall(r'\d+', str)[0]) assert (updates + 1) == new_updates + u_boot_console.run_command('tpm2 pcr_extend 0 0x%x' % ram) + output = u_boot_console.run_command('echo $?') + assert output.endswith('0') + + read_pcr = u_boot_console.run_command('tpm2 pcr_read 0 0x%x' % (ram + 0x20)) + output = u_boot_console.run_command('echo $?') + assert output.endswith('0') + assert '7a 05 01 f5 95 7b df 9c b3 a8 ff 49 66 f0 22 65' in read_pcr + assert 'f9 68 65 8b 7a 9c 62 64 2c ba 11 65 e8 66 42 f5' in read_pcr + + str = re.findall(r'\d+ known updates', read_pcr)[0] + new_updates = int(re.findall(r'\d+', str)[0]) + assert (updates + 2) == new_updates + @pytest.mark.buildconfigspec('cmd_tpm_v2') def test_tpm2_cleanup(u_boot_console): """Ensure the TPM is cleared from password or test related configuration.""" |