[PATCH v1 4/5] tpm2: add sm3 256 hash support

Ilias Apalodimas ilias.apalodimas at linaro.org
Mon Nov 10 12:51:22 CET 2025


Hello Heiko,

Thanks for doing this.
This patch is fine. I do think we should extend this more though.

Adding the missing SM3 algo is indeed needed. But when using a TPM,
the specs that currently describe it require all the PCR banks to be
extended. IOW we need to add some code to lib/tpm_tcg2.c as well.
I haven't looked at all the details yet, but we at least need to add
the new algo to tcg2_create_digest(). I am happy to help if you need
more details.

[...]

>
>  /* 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) {

Since you are changing this we might as well make it future proof.
Can you please change this and just use the ARRAY_SIZE() of the
hash_algo_list[] instead?

>                 printf("%s: too many pcrs: %u\n", __func__, pcrs->count);
>                 return -EMSGSIZE;
>         }
> --
> 2.20.1
>

Regards
/Ilias


More information about the U-Boot mailing list