Tool/software: TI C/C++ Compiler
Hi,
I encountered a problem during the compiling of the wolfssl library. In function wc_AesDecrypt there is code like this:
#define GETBYTE(x, y) (word32)((byte)((x) >> (8 * (y))))
…
static const byte Td4[256] = {…}
…
s0 =
((word32)Td4[GETBYTE(t0, 3)] << 24) ^
((word32)Td4[GETBYTE(t3, 2)] << 16) ^
((word32)Td4[GETBYTE(t2, 1)] << 8) ^
((word32)Td4[GETBYTE(t1, 0)]) ^
rk[0];
Compiling is done in order, but the application crashes. The problem seems to be that in the GETBYTE macro, the result of the expression is not correctly cropped to BYTE so Td field is indexed beyond the boundary. If the macro is replaced by (((x) >> (8 * (y))) & 0xFF) everything is fine.
I tried compilers tms470_4.9.7, ti-cgt-arm_5.2.9 and ti-cgt-arm_16.9.3 with same results. C64+ DSP compilers works fine.
Please tell me what’s wrong.
Thanks
Jiri