From: Heiko Schocher <hs@nabladev.com>
To: U-Boot Mailing List <u-boot@lists.denx.de>
Cc: Heiko Schocher <hs@nabladev.com>,
Andrew Goodbody <andrew.goodbody@linaro.org>,
Heinrich Schuchardt <xypron.glpk@gmx.de>,
Ilias Apalodimas <ilias.apalodimas@linaro.org>,
Miquel Raynal <miquel.raynal@bootlin.com>,
Raymond Mao <raymond.mao@linaro.org>,
Tom Rini <trini@konsulko.com>
Subject: [PATCH v1 4/5] tpm2: add sm3 256 hash support
Date: Sat, 1 Nov 2025 07:49:06 +0100 [thread overview]
Message-ID: <20251101064907.5037-5-hs@nabladev.com> (raw)
In-Reply-To: <20251101064907.5037-1-hs@nabladev.com>
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 <hs@nabladev.com>
---
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
next prev parent reply other threads:[~2025-11-01 6:49 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-01 6:49 [PATCH v1 0/5] Add support for SM3 secure hash Heiko Schocher
2025-11-01 6:49 ` [PATCH v1 1/5] lib: Import rol32 function from Linux Heiko Schocher
2025-11-01 6:49 ` [PATCH v1 2/5] lib: implement SM3 secure hash Heiko Schocher
2025-11-01 17:11 ` Raymond Mao
2025-11-03 8:56 ` Heiko Schocher
2025-11-04 2:30 ` Raymond Mao
2025-11-01 6:49 ` [PATCH v1 3/5] test: cmd: add unit test for sm3 hash Heiko Schocher
2025-11-01 6:49 ` Heiko Schocher [this message]
2025-11-10 11:51 ` [PATCH v1 4/5] tpm2: add sm3 256 hash support Ilias Apalodimas
2025-11-10 13:06 ` Heiko Schocher
2025-11-01 6:49 ` [PATCH v1 5/5] test: cmd: fix a typo in md5 test Heiko Schocher
2025-11-01 7:45 ` Heinrich Schuchardt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251101064907.5037-5-hs@nabladev.com \
--to=hs@nabladev.com \
--cc=andrew.goodbody@linaro.org \
--cc=ilias.apalodimas@linaro.org \
--cc=miquel.raynal@bootlin.com \
--cc=raymond.mao@linaro.org \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
--cc=xypron.glpk@gmx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox