Searched hist:f0ead74813951effd2adf67da8f98b2a2ae37337 (Results 1 – 1 of 1) sorted by relevance
| /optee_os/core/crypto/ |
| H A D | sm3.c | f0ead74813951effd2adf67da8f98b2a2ae37337 Tue Jun 16 15:56:36 UTC 2020 Jerome Forissier <jerome@forissier.org> core: crypto: fix invalid SM3 output with Clang -Os
Several crypto tests fail when OP-TEE is built with Clang in non-debug mode, more precisely with -Os. xtest numbers 4001, 4002, 4006 and 4014 are impacted.
The root cause is the shift operations in the ROTL(x, n) are undefined when n > 32 because the values to shift are uint32_t, but the macro is used with 0 <= n < 64.
By masking n with 0x1F (thus implementing a modulo 32), we continue rotating the bits when n >= 32.
Signed-off-by: Jerome Forissier <jerome@forissier.org> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org> Reviewed-by: Volodymyr Babchuk <volodymyr_babchuk@epam.com>
|