void RC6::Dec::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const { const RC6_WORD *sptr = sTable.end(); RC6_WORD a, b, c, d, t, u; Block::Get(inBlock)(a)(b)(c)(d); sptr -= 2; c -= sptr[1]; a -= sptr[0]; for (unsigned i=0; i < r; i++) { sptr -= 2; t = a; a = d; d = c; c = b; b = t; u = rotlFixed(d*(2*d+1), 5); t = rotlFixed(b*(2*b+1), 5); c = rotrMod(c-sptr[1], t) ^ u; a = rotrMod(a-sptr[0], u) ^ t; } sptr -= 2; d -= sTable[1]; b -= sTable[0]; Block::Put(xorBlock, outBlock)(a)(b)(c)(d); }
void RC6Decryption::ProcessBlock(const byte *in, byte *out) const { const RC6_WORD *sptr = sTable+sTable.size; RC6_WORD a, b, c, d, t, u; GetBlockLittleEndian(in, a, b, c, d); sptr -= 2; c -= sptr[1]; a -= sptr[0]; for (unsigned i=0; i < r; i++) { sptr -= 2; t = a; a = d; d = c; c = b; b = t; u = rotlFixed(d*(2*d+1), 5); t = rotlFixed(b*(2*b+1), 5); c = rotrMod(c-sptr[1], t) ^ u; a = rotrMod(a-sptr[0], u) ^ t; } sptr -= 2; d -= sTable[1]; b -= sTable[0]; PutBlockLittleEndian(out, a, b, c, d); }
void RC5::Dec::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const { const RC5_WORD *sptr = sTable.end(); RC5_WORD a, b; Block::Get(inBlock)(a)(b); for (unsigned i=0; i<r; i++) { sptr-=2; b = rotrMod(b-sptr[1], a) ^ a; a = rotrMod(a-sptr[0], b) ^ b; } b -= sTable[1]; a -= sTable[0]; Block::Put(xorBlock, outBlock)(a)(b); }