Add support for SM3 secure hash
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v3 Latest6 patches 14 repliesIn review
- v25 patches 9 repliesSuperseded
- v15 patches 6 repliesSuperseded
Changes in v3 from the cover letter · 21 lines
Added Reviewed-by from Ilias
rebased series to
commit: 69cc92d6869 ("Merge tag 'efi-2026-01-rc3' of https://source.denx.de/u-boot/custodians/u-boot-efi")
add comments from Ilias
- use sizeof(*sctx) instead of sizeof(struct sm3_context)
- use output[] instead of output[SM3_DIGEST_SIZE] comment from Ilias
This leaded to CI error:
+lib/sm3.c:241:50: error: argument 2 of type ‘uint8_t[]’ {aka ‘unsigned char[]’} with mismatched bound [-Werror=array-parameter=]
+ 241 | void sm3_final(struct sm3_context *sctx, uint8_t output[])
+ | ~~~~~~~~^~~~~~~~
see:
https://dev.azure.com/hs0298/hs/_build/results?buildId=192&view=logs&j=182673a4-17b9-5c0c-69ad-98f742450579&t=34b689f8-3e29-5ffe-50ea-32bfe99f47c7&l=334
so made this change back to v2 state of the series, to have the same
arguments as the other hashes in lib/
- seperate linux and U-Boot parts into 2 commits
New in version 3 as Ilias recommended to split linux
and U-boot changes.
use CMD_TEST instead of DM_TEST, as Heinrich confirmed
add comment from Ilias
- add SM3 support in tcg2_hash_pe_image()
Added Reviewed-by from Ilias
Patches in v3 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/6 | lib: Import rol32 function from Linuxinclude/ | +11 | 0 replies | |
| 2/6 | lib: import sm3 256 hash parts from linuxMAINTAINERS include/ lib/ +2 more | +228 | 1 reply | |
| 3/6 | lib: sm3: implement U-Boot partsMAINTAINERS boot/ cmd/ +5 more | +240 | 2 replies | |
| 4/6 | test: cmd: hash: add unit test for sm3_256test/ | +47 | 0 replies | |
| 5/6 | tpm2: add sm3 256 hash supportcmd/ include/ lib/ +2 more | +27 | 0 replies | |
| 6/6 | test: cmd: fix a typo in md5 testtest/ | +1 | 0 replies |
Reviews trailers per patch
3 of 6 patches have a Reviewed-by or Acked-by.
| Patch | Ilias Apalodimas | Heinrich Schuchardt |
|---|---|---|
| 1/6 | R-b | |
| 2/6 | A-b | |
| 3/6 | ||
| 4/6 | ||
| 5/6 | ||
| 6/6 | R-b | R-b |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH v3 0/6] Add support for SM3 secure hash
Add SM3 secure hash, as specified by OSCCA GM/T 0004-2012 SM3 and described at https://datatracker.ietf.org/doc/html/draft-sca-cfrg-sm3-02
TPMv2 defines hash algo sm3_256, which is currently not supported and prevented TPMv2 chip with newer firmware to work with U-Boot. Seen this on a ST33TPHF2XI2C
u-boot=> tpm2 init
u-boot=> tpm2 autostart
tpm2_get_pcr_info: too many pcrs: 5
Error: -90
u-boot=>
Implement sm3 hash, so we can fix this problem.
Azure build:
https://dev.azure.com/hs0298/hs/_build/results?buildId=194&view=results
Changes in v3:
Added Reviewed-by from Ilias
rebased series to
commit: 69cc92d6869 ("Merge tag 'efi-2026-01-rc3' of https://source.denx.de/u-boot/custodians/u-boot-efi")
add comments from Ilias
- use sizeof(*sctx) instead of sizeof(struct sm3_context)
- use output[] instead of output[SM3_DIGEST_SIZE] comment from Ilias
This leaded to CI error:
+lib/sm3.c:241:50: error: argument 2 of type ‘uint8_t[]’ {aka ‘unsigned char[]’} with mismatched bound [-Werror=array-parameter=]
+ 241 | void sm3_final(struct sm3_context *sctx, uint8_t output[])
+ | ~~~~~~~~^~~~~~~~
see:
https://dev.azure.com/hs0298/hs/_build/results?buildId=192&view=logs&j=182673a4-17b9-5c0c-69ad-98f742450579&t=34b689f8-3e29-5ffe-50ea-32bfe99f47c7&l=334
so made this change back to v2 state of the series, to have the same
arguments as the other hashes in lib/
- seperate linux and U-Boot parts into 2 commits
New in version 3 as Ilias recommended to split linux
and U-boot changes.
use CMD_TEST instead of DM_TEST, as Heinrich confirmed
add comment from Ilias
- add SM3 support in tcg2_hash_pe_image()
Added Reviewed-by from Ilias
Changes in v2:
rebase to6b27b688694: ("Merge branch 'master' of https://source.denx.de/u-boot/custodians/u-boot-sh")
add Ilias to Series-cc
add sm3_hash to header file, so we can use it.
add comments from Ilias
- use ARRAY_SIZE(hash_algo_list) instead of a fix number
in tpm2_get_pcr_info() for the count of supported hashes
in U-Boot.
- add SM3 hash in tpm_tcg2
Added Reviewed-by tag from Heinrich
Heiko Schocher (6):
lib: Import rol32 function from Linux
lib: import sm3 256 hash parts from linux
lib: sm3: implement U-Boot parts
test: cmd: hash: add unit test for sm3_256
tpm2: add sm3 256 hash support
test: cmd: fix a typo in md5 test
MAINTAINERS | 7 + boot/Kconfig | 1 + cmd/Kconfig | 15 ++ cmd/Makefile | 1 + cmd/sm3sum.c | 48 ++++++ cmd/tpm-v2.c | 1 + common/hash.c | 42 ++++- include/linux/bitops.h | 11 ++ include/tpm-v2.h | 12 ++ include/u-boot/sm3.h | 35 +++++ lib/Kconfig | 7 + lib/Makefile | 1 + lib/efi_loader/efi_tcg2.c | 3 + lib/sm3.c | 312 ++++++++++++++++++++++++++++++++++++++ lib/tpm-v2.c | 4 +- lib/tpm_tcg2.c | 9 ++ test/cmd/hash.c | 49 +++++- 17 files changed, 554 insertions(+), 4 deletions(-) create mode 100644 cmd/sm3sum.c create mode 100644 include/u-boot/sm3.h create mode 100644 lib/sm3.c
Signature · 3 lines
2.20.1 base-commit: 69cc92d6869b8ff4591e5b8850872da34934bab9