Home
last modified time | relevance | path

Searched hist:d803b8857e50cc2a4d7fa86dcbcfe8c983cdbc0c (Results 1 – 1 of 1) sorted by relevance

/optee_os/core/lib/libtomcrypt/
H A Dsha256_accel.cd803b8857e50cc2a4d7fa86dcbcfe8c983cdbc0c Wed Dec 01 09:14:17 UTC 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_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>