On Sat, Oct 03, 2026 at 12:16:06AM +0800, Xiaoyi Suo wrote: > sha1_hmac(), sha256_hmac() and the mbedTLS sha1 shim build the HMAC key > schedule in local arrays and clear them with memset() just before they > return. The buffers die with the frame, so the stores are dead and GCC > removes them from -O1 up, leaving the caller's key on the stack as > 0x36 ^ key and 0x5c ^ key. > > Those functions are generic; in U-Boot the caller is the TPM 1.2 code, > where the key is the usage auth of a TPM key. > > Take memzero_explicit() from the Linux kernel, where it is a static inline > in include/linux/string.h, and use it for the three key schedules. Plain > memset() stays where a buffer is only being initialised. > > Cc: Tom Rini <[email protected]> > Signed-off-by: Xiaoyi Suo <[email protected]>
Thanks. Now, as we talk about https://docs.u-boot-project.org/en/latest/develop/sending_patches.html#attributing-code-copyrights-signing the part from the linux kernel should be its own patch, and note which commit it is based on, in case there's fixes in the future we need to sync over. The rest of the series should be making use of this function in small logical steps. -- Tom
signature.asc
Description: PGP signature
