Cleared UB in cast.cpp due to use of rotVariable. On PowerPC, the specialization that uses inline assembler will activate. The inline assembly uses __rlwnm which takes a mask and does not suffer C/C++ UB

pull/35/head
Jeffrey Walton 2015-07-23 05:10:12 -04:00
parent ac0f94c23a
commit 7b629dcfa6
1 changed files with 3 additions and 3 deletions

View File

@ -15,15 +15,15 @@ NAMESPACE_BEGIN(CryptoPP)
/* CAST uses three different round functions */ /* CAST uses three different round functions */
#define f1(l, r, km, kr) \ #define f1(l, r, km, kr) \
t = rotlVariable(km + r, kr); \ t = rotlMod(km + r, kr); \
l ^= ((S[0][U8a(t)] ^ S[1][U8b(t)]) - \ l ^= ((S[0][U8a(t)] ^ S[1][U8b(t)]) - \
S[2][U8c(t)]) + S[3][U8d(t)]; S[2][U8c(t)]) + S[3][U8d(t)];
#define f2(l, r, km, kr) \ #define f2(l, r, km, kr) \
t = rotlVariable(km ^ r, kr); \ t = rotlMod(km ^ r, kr); \
l ^= ((S[0][U8a(t)] - S[1][U8b(t)]) + \ l ^= ((S[0][U8a(t)] - S[1][U8b(t)]) + \
S[2][U8c(t)]) ^ S[3][U8d(t)]; S[2][U8c(t)]) ^ S[3][U8d(t)];
#define f3(l, r, km, kr) \ #define f3(l, r, km, kr) \
t = rotlVariable(km - r, kr); \ t = rotlMod(km - r, kr); \
l ^= ((S[0][U8a(t)] + S[1][U8b(t)]) ^ \ l ^= ((S[0][U8a(t)] + S[1][U8b(t)]) ^ \
S[2][U8c(t)]) - S[3][U8d(t)]; S[2][U8c(t)]) - S[3][U8d(t)];