tpm2_listpcrs: use TPM2_GetCapability to determine PCRs to read
tpm2_listpcrs: use TPM2_GetCapability to determine PCRs to read

Allow TPM to tell us PCRs that are available to be read in a bank
instead of assuming there will be 24. This resolves an issue on
a system where in the bios you can choose between hash functions
(sha1 and sha256 in this case). Both will show up as supported,
but when it tries reading the bank that isn't selected in the bios
it makes no progress, and then fails saying that there are too many
PCRs to read.

This consolidates the pcr_selections init code into one function.

Also a minor change to show_pcr_values to use sizeofSelect to
determine loop iteration instead of hardcoding 24.

Signed-off-by: Jerry Snitselaar <c95488007d076e3a8af5983fc4082d7c589fa2a6@redhat.com>

martinezjavier/tpm2-tools,01org/tpm2.0-tools,martinezjavier/tpm2-tools,01org/tpm2.0-tools,01org/tpm2.0-tools,martinezjavier/tpm2-tools,martinezjavier/tpm2-tools