void RijndaelDecryption::ProcessBlock(const UCHAR *inBlock, UCHAR *outBlock) const { ULONG b0[4], b1[4]; GetBlockLittleEndian(inBlock, b0[0], b0[1], b0[2], b0[3]); b0[0] ^= key[4 * k_len + 24]; b0[1] ^= key[4 * k_len + 25]; b0[2] ^= key[4 * k_len + 26]; b0[3] ^= key[4 * k_len + 27]; const ULONG *kp = key + 4 * (k_len + 5); if(k_len > 6) { i_nround(b1, b0, kp); i_nround(b0, b1, kp); } if(k_len > 4) { i_nround(b1, b0, kp); i_nround(b0, b1, kp); } i_nround(b1, b0, kp); i_nround(b0, b1, kp); i_nround(b1, b0, kp); i_nround(b0, b1, kp); i_nround(b1, b0, kp); i_nround(b0, b1, kp); i_nround(b1, b0, kp); i_nround(b0, b1, kp); i_nround(b1, b0, kp); i_lround(b0, b1, kp); PutBlockLittleEndian(outBlock, b0[0], b0[1], b0[2], b0[3]); }
void rijndael_decrypt(rijndaelCtx *ctx, const uint32_t *in_blk, uint32_t *out_blk) { uint32_t b0[4], b1[4], *kp; uint32_t k_len = ctx->k_len; uint32_t *e_key = ctx->e_key; uint32_t *d_key = ctx->d_key; b0[0] = io_swap(in_blk[0]) ^ e_key[4 * k_len + 24]; b0[1] = io_swap(in_blk[1]) ^ e_key[4 * k_len + 25]; b0[2] = io_swap(in_blk[2]) ^ e_key[4 * k_len + 26]; b0[3] = io_swap(in_blk[3]) ^ e_key[4 * k_len + 27]; kp = d_key + 4 * (k_len + 5); if (k_len > 6) { i_nround(b1, b0, kp); i_nround(b0, b1, kp); } if (k_len > 4) { i_nround(b1, b0, kp); i_nround(b0, b1, kp); } i_nround(b1, b0, kp); i_nround(b0, b1, kp); i_nround(b1, b0, kp); i_nround(b0, b1, kp); i_nround(b1, b0, kp); i_nround(b0, b1, kp); i_nround(b1, b0, kp); i_nround(b0, b1, kp); i_nround(b1, b0, kp); i_lround(b0, b1, kp); out_blk[0] = io_swap(b0[0]); out_blk[1] = io_swap(b0[1]); out_blk[2] = io_swap(b0[2]); out_blk[3] = io_swap(b0[3]); }
void AES::decrypt(const u1byte in_blk[16], u1byte out_blk[16]) { u4byte b0[4], b1[4], *kp; b0[0] = u4byte_in(in_blk ) ^ e_key[4 * k_len + 24]; b0[1] = u4byte_in(in_blk + 4) ^ e_key[4 * k_len + 25]; b0[2] = u4byte_in(in_blk + 8) ^ e_key[4 * k_len + 26]; b0[3] = u4byte_in(in_blk + 12) ^ e_key[4 * k_len + 27]; kp = d_key + 4 * (k_len + 5); if(k_len > 6) { i_nround(b1, b0, kp); i_nround(b0, b1, kp); } if(k_len > 4) { i_nround(b1, b0, kp); i_nround(b0, b1, kp); } i_nround(b1, b0, kp); i_nround(b0, b1, kp); i_nround(b1, b0, kp); i_nround(b0, b1, kp); i_nround(b1, b0, kp); i_nround(b0, b1, kp); i_nround(b1, b0, kp); i_nround(b0, b1, kp); i_nround(b1, b0, kp); i_lround(b0, b1, kp); u4byte_out(out_blk, b0[0]); u4byte_out(out_blk + 4, b0[1]); u4byte_out(out_blk + 8, b0[2]); u4byte_out(out_blk + 12, b0[3]); }