selftests: tpm2: Determine available PCR bank
authorStefan Berger <stefanb@linux.ibm.com>
Sun, 28 Nov 2021 04:10:51 +0000 (23:10 -0500)
committerJarkko Sakkinen <jarkko@kernel.org>
Sun, 20 Feb 2022 23:22:05 +0000 (00:22 +0100)
commit1cc3880bf8bd6a2a8ee26c7664be69b16e90b0fc
tree95b1b2838640094f8c2ab881f7481568cd393fff
parentcfb92440ee71adcc2105b0890bb01ac3cddb8507
selftests: tpm2: Determine available PCR bank

Determine an available PCR bank to be used by a test case by querying the
capability TPM2_GET_CAP. The TPM2 returns TPML_PCR_SELECTIONS that
contains an array of TPMS_PCR_SELECTIONs indicating available PCR banks
and the bitmasks that show which PCRs are enabled in each bank. Collect
the data in a dictionary. From the dictionary determine the PCR bank that
has the PCRs enabled that the test needs. This avoids test failures with
TPM2's that either to not have a SHA-1 bank or whose SHA-1 bank is
disabled.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Tested-by: Jarkko Sakkinen <jarkko@kernel.org>
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
tools/testing/selftests/tpm2/tpm2.py
tools/testing/selftests/tpm2/tpm2_tests.py