[PATCH v2 4/5] tpm2: add sm3 256 hash support
Ilias Apalodimas
ilias.apalodimas at linaro.org
Tue Nov 11 10:38:32 CET 2025
[...]
> > @@ -143,6 +144,12 @@ int tcg2_create_digest(struct udevice *dev, const u8 *input, u32 length,
> > sha512_finish(&ctx_512, final);
> > len = TPM2_SHA512_DIGEST_SIZE;
> > break;
> > +#endif
> > +#if IS_ENABLED(CONFIG_SM3)
> > + case TPM2_ALG_SM3_256:
> > + sm3_hash(input, length, final);
I haven't looked at the sm3 implementation yet, but it doesn't have the usual
start
update
finish
?
Thanks
/Ilias
> > + len = TPM2_SM3_256_DIGEST_SIZE;
> > + break;
> > #endif
> > default:
> > printf("%s: unsupported algorithm %x\n", __func__,
> > @@ -319,6 +326,7 @@ static int tcg2_replay_eventlog(struct tcg2_event_log *elog,
> > case TPM2_ALG_SHA256:
> > case TPM2_ALG_SHA384:
> > case TPM2_ALG_SHA512:
> > + case TPM2_ALG_SM3_256:
> > len = tpm2_algorithm_to_len(algo);
> > break;
> > default:
> > @@ -431,6 +439,7 @@ static int tcg2_log_parse(struct udevice *dev, struct tcg2_event_log *elog,
> > case TPM2_ALG_SHA256:
> > case TPM2_ALG_SHA384:
> > case TPM2_ALG_SHA512:
> > + case TPM2_ALG_SM3_256:
> > len = get_unaligned_le16(&event->digest_sizes[i].digest_size);
> > if (tpm2_algorithm_to_len(algo) != len) {
> > log_err("EventLog invalid algorithm length\n");
> > --
> > 2.20.1
> >
More information about the U-Boot
mailing list