Searched hist:e429c45ff395fd16b7eed44093e1a0a138373201 (Results 1 – 1 of 1) sorted by relevance
| /optee_os/core/crypto/ |
| H A D | sm3.c | e429c45ff395fd16b7eed44093e1a0a138373201 Wed Jan 10 13:30:07 UTC 2024 Clement Faure <clement.faure@nxp.com> core: crypto: sm3: fix undefined behavior on right shifting operation
In the expression ROTL(T[j], j), with j=0, we right shift by more than 31 bits (32 in this case). This behavior is undefined according to the C99 standard:
6.5.7 Bitwise shift operators The integer promotions are performed on each of the operands. The type of the result is that of the promoted left operand. If the value of the right operand is negative or is greater than or equal to the width of the promoted left operand, the behavior is undefined.
Skip the shift operation if the shift value is 0.
Signed-off-by: Clement Faure <clement.faure@nxp.com> Reviewed-by: Etienne Carriere <etienne.carriere@foss.st.com> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org> Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
|