| #
d803b885 |
| 01-Dec-2021 |
Dominique Martinet <dominique.martinet@atmark-techno.com> |
libtomcrypt/sha256_accel: fix stringop-overflow error
Attempting to build optee-os with gcc11 fails with the following error ---- In function ‘sha256_compress_nblocks’, inlined from ‘sha256_comp
libtomcrypt/sha256_accel: fix stringop-overflow error
Attempting to build optee-os with gcc11 fails with the following error ---- In function ‘sha256_compress_nblocks’, inlined from ‘sha256_compress’ at core/lib/libtomcrypt/sha256_accel.c:81:11, inlined from ‘sha256_done’ at core/lib/libtomcrypt/sha256_accel.c:158:5: core/lib/libtomcrypt/sha256_accel.c:75:5: error: ‘crypto_accel_sha256_compress’ accessing 32 bytes in a region of size 20 [-Werror=stringop-overflow=] 75 | crypto_accel_sha256_compress(state, buf, blocks); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ core/lib/libtomcrypt/sha256_accel.c: In function ‘sha256_done’: core/lib/libtomcrypt/sha256_accel.c:75:5: note: referencing argument 1 of type ‘uint32_t *’ {aka ‘unsigned int *’} In file included from core/lib/libtomcrypt/sha256_accel.c:41: core/include/crypto/crypto_accel.h:45:6: note: in a call to function ‘crypto_accel_sha256_compress’ 45 | void crypto_accel_sha256_compress(uint32_t state[8], const void *src, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ ----
Indeed, the 'state' argument here is taken from sha1.state which is a uint32_t state[5], so 20 bytes long instead of the uint32_t state[8] crypto_accel_sha256_compress expects.
OTOH we're in a sha256 function, and sha256.state conveniently is of the correct size, so use sha256.state as appropriate instead.
Note that hash_state is a union and sha{1,256}.state are at the same offset, so this is actually a no-op change.
Signed-off-by: Dominique Martinet <dominique.martinet@atmark-techno.com> Acked-by: Jens Wiklander <jens.wiklander@linaro.org> Acked-by: Jerome Forissier <jerome@forissier.org>
show more ...
|
| #
a828d70f |
| 02-Apr-2020 |
Jens Wiklander <jens.wiklander@linaro.org> |
core: ltc: use SHA-256 crypto accelerated function
Uses the recently provided accelerated SHA-256 function in LTC.
Acked-by: Etienne Carriere <etienne.carriere@linaro.org> Signed-off-by: Jens Wikla
core: ltc: use SHA-256 crypto accelerated function
Uses the recently provided accelerated SHA-256 function in LTC.
Acked-by: Etienne Carriere <etienne.carriere@linaro.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|