add sm3 256 hash support, so TPM2 chips which report 5 pcrs with sm3 hash do not fail with:
u-boot=> tpm2 autostart tpm2_get_pcr_info: too many pcrs: 5 Error: -90 Signed-off-by: Heiko Schocher <[email protected]> --- cmd/tpm-v2.c | 1 + include/tpm-v2.h | 12 ++++++++++++ lib/tpm-v2.c | 4 ++-- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/cmd/tpm-v2.c b/cmd/tpm-v2.c index 346e21d27bb..847b2691581 100644 --- a/cmd/tpm-v2.c +++ b/cmd/tpm-v2.c @@ -589,6 +589,7 @@ U_BOOT_CMD(tpm2, CONFIG_SYS_MAXARGS, 1, do_tpm, "Issue a TPMv2.x command", " * sha256\n" " * sha384\n" " * sha512\n" +" * sm3_256\n" " <on|off> is one of:\n" " * on - Select all available PCRs associated with the specified\n" " algorithm (bank)\n" diff --git a/include/tpm-v2.h b/include/tpm-v2.h index f3eb2ef5643..a776d24d71f 100644 --- a/include/tpm-v2.h +++ b/include/tpm-v2.h @@ -345,6 +345,18 @@ static const struct digest_info hash_algo_list[] = { false, #endif }, + { + "sm3_256", + TPM2_ALG_SM3_256, + TCG2_BOOT_HASH_ALG_SM3_256, + TPM2_SM3_256_DIGEST_SIZE, +#if IS_ENABLED(CONFIG_SM3) + true, +#else + false, +#endif + }, + }; /* NV index attributes */ diff --git a/lib/tpm-v2.c b/lib/tpm-v2.c index 5b21c57ae42..0fea35e5ae0 100644 --- a/lib/tpm-v2.c +++ b/lib/tpm-v2.c @@ -686,10 +686,10 @@ int tpm2_get_pcr_info(struct udevice *dev, struct tpml_pcr_selection *pcrs) pcrs->count = get_unaligned_be32(response); /* - * We only support 4 algorithms for now so check against that + * We only support 5 algorithms for now so check against that * instead of TPM2_NUM_PCR_BANKS */ - if (pcrs->count > 4 || pcrs->count < 1) { + if (pcrs->count > 5 || pcrs->count < 1) { printf("%s: too many pcrs: %u\n", __func__, pcrs->count); return -EMSGSIZE; } -- 2.20.1

