diff options
| author | Heiko Schocher <[email protected]> | 2025-11-18 05:30:38 +0100 |
|---|---|---|
| committer | Tom Rini <[email protected]> | 2025-12-04 09:38:58 -0600 |
| commit | 41c0131b950a16747929ab310588cf5db8e38123 (patch) | |
| tree | 2c7e9bde33a6578f514af153128d5355eb5a7cdd /include/u-boot | |
| parent | 6a0c939b88fd42c6b0a374f7c87317f292df46a1 (diff) | |
lib: import sm3 256 hash parts from linux
Implement SM3_256 Hash algorithm, based on
linux commit f83a4f2a4d8c: ("Merge tag 'erofs-for-6.17-rc6-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs")
Therefore add the needed parts from linux.
Signed-off-by: Heiko Schocher <[email protected]>
Acked-by: Ilias Apalodimas <[email protected]>
Diffstat (limited to 'include/u-boot')
| -rw-r--r-- | include/u-boot/sm3.h | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/include/u-boot/sm3.h b/include/u-boot/sm3.h new file mode 100644 index 00000000000..de16684ca0a --- /dev/null +++ b/include/u-boot/sm3.h @@ -0,0 +1,27 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef _SM3_H +#define _SM3_H + +#define SM3_DIGEST_SIZE 32 /* 256 bits */ +#define SM3_BLOCK_SIZE 64 /* 512 bits */ +#define SM3_PAD_UNIT 56 /* 448 bits */ + +#define SM3_T1 0x79CC4519 +#define SM3_T2 0x7A879D8A + +#define SM3_IVA 0x7380166f +#define SM3_IVB 0x4914b2b9 +#define SM3_IVC 0x172442d7 +#define SM3_IVD 0xda8a0600 +#define SM3_IVE 0xa96f30bc +#define SM3_IVF 0x163138aa +#define SM3_IVG 0xe38dee4d +#define SM3_IVH 0xb0fb0e4e + +struct sm3_context { + uint32_t state[SM3_DIGEST_SIZE / 4]; + uint64_t count; /* Message length in bits */ + uint8_t buffer[SM3_BLOCK_SIZE]; + int buflen; +}; +#endif |
