Skip to content

Commit

Permalink
Cleared UB in cast.cpp due to use of rotVariable. On PowerPC, the spe…
Browse files Browse the repository at this point in the history
…cialization that uses inline assembler will activate. The inline assembly uses __rlwnm which takes a mask and does not suffer C/C++ UB
  • Loading branch information
noloader committed Jul 23, 2015
1 parent ac0f94c commit 7b629dc
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions cast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ NAMESPACE_BEGIN(CryptoPP)

/* CAST uses three different round functions */
#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)]) - \
S[2][U8c(t)]) + S[3][U8d(t)];
#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)]) + \
S[2][U8c(t)]) ^ S[3][U8d(t)];
#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)]) ^ \
S[2][U8c(t)]) - S[3][U8d(t)];

Expand Down

0 comments on commit 7b629dc

Please sign in to comment.