SizeT AesCbc_Encode(CAesCbc *p, Byte *data, SizeT size) { SizeT i; if (size == 0) return 0; if (size < AES_BLOCK_SIZE) return AES_BLOCK_SIZE; size -= AES_BLOCK_SIZE; for (i = 0; i <= size; i += AES_BLOCK_SIZE, data += AES_BLOCK_SIZE) { p->prev[0] ^= GetUi32(data); p->prev[1] ^= GetUi32(data + 4); p->prev[2] ^= GetUi32(data + 8); p->prev[3] ^= GetUi32(data + 12); AesEncode32(p->prev, p->prev, p->aes.rkey, p->aes.numRounds2); SetUi32(data, p->prev[0]); SetUi32(data + 4, p->prev[1]); SetUi32(data + 8, p->prev[2]); SetUi32(data + 12, p->prev[3]); } return i; }
UInt32 MY_FAST_CALL AesCbcEncode(CAesCbc *cbc, Byte *data, UInt32 size) { UInt32 i; if (size == 0) return 0; if (size < AES_BLOCK_SIZE) return AES_BLOCK_SIZE; size -= AES_BLOCK_SIZE; for (i = 0; i <= size; i += AES_BLOCK_SIZE, data += AES_BLOCK_SIZE) { cbc->prev[0] ^= GetUi32(data); cbc->prev[1] ^= GetUi32(data + 4); cbc->prev[2] ^= GetUi32(data + 8); cbc->prev[3] ^= GetUi32(data + 12); AesEncode32(cbc->prev, cbc->prev, cbc->aes.rkey, cbc->aes.numRounds2); SetUi32(data, cbc->prev[0]); SetUi32(data + 4, cbc->prev[1]); SetUi32(data + 8, cbc->prev[2]); SetUi32(data + 12, cbc->prev[3]); } return i; }
void Aes_Encode32(const CAes *p, UInt32 *dest, const UInt32 *src) { AesEncode32(dest, src, p->rkey, p->numRounds2); }