27 #if defined(CRYPTO_AES_DEFAULT) || defined(CRYPTO_DOC)
68 uint8_t *schedule = sched;
69 memcpy(schedule, key, 16);
72 uint8_t iteration = 1;
78 keyScheduleCore(schedule + 16, schedule + 12, iteration);
79 schedule[16] ^= schedule[0];
80 schedule[17] ^= schedule[1];
81 schedule[18] ^= schedule[2];
82 schedule[19] ^= schedule[3];
87 schedule[16] = schedule[12] ^ schedule[0];
88 schedule[17] = schedule[13] ^ schedule[1];
89 schedule[18] = schedule[14] ^ schedule[2];
90 schedule[19] = schedule[15] ^ schedule[3];
130 AESCommon::keyScheduleCore(temp, schedule + 12, (n)); \
131 schedule[0] ^= temp[0]; \
132 schedule[1] ^= temp[1]; \
133 schedule[2] ^= temp[2]; \
134 schedule[3] ^= temp[3]; \
138 schedule[(a) * 4] ^= schedule[(b) * 4]; \
139 schedule[(a) * 4 + 1] ^= schedule[(b) * 4 + 1]; \
140 schedule[(a) * 4 + 2] ^= schedule[(b) * 4 + 2]; \
141 schedule[(a) * 4 + 3] ^= schedule[(b) * 4 + 3]; \
156 AESTiny128::~AESTiny128()
183 memcpy(schedule, key, 16);
191 uint8_t schedule[16];
199 memcpy(schedule, this->schedule, 16);
202 for (posn = 0; posn < 16; ++posn)
203 state1[posn] = input[posn] ^ schedule[posn];
206 for (round = 1; round <= 9; ++round) {
214 AESCommon::subBytesAndShiftRows(state2, state1);
215 AESCommon::mixColumn(state1, state2);
216 AESCommon::mixColumn(state1 + 4, state2 + 4);
217 AESCommon::mixColumn(state1 + 8, state2 + 8);
218 AESCommon::mixColumn(state1 + 12, state2 + 12);
219 for (posn = 0; posn < 16; ++posn)
220 state1[posn] ^= schedule[posn];
230 AESCommon::subBytesAndShiftRows(state2, state1);
231 for (posn = 0; posn < 16; ++posn)
232 output[posn] = state2[posn] ^ schedule[posn];
275 AESSmall128::~AESSmall128()
294 memcpy(schedule, key, 16);
295 for (round = 1; round <= 10; ++round) {
308 uint8_t schedule[16];
316 memcpy(schedule, reverse, 16);
319 for (posn = 0; posn < 16; ++posn)
320 state1[posn] = input[posn] ^ schedule[posn];
321 AESCommon::inverseShiftRowsAndSubBytes(state2, state1);
328 for (round = 9; round >= 1; --round) {
330 for (posn = 0; posn < 16; ++posn)
331 state2[posn] ^= schedule[posn];
332 AESCommon::inverseMixColumn(state1, state2);
333 AESCommon::inverseMixColumn(state1 + 4, state2 + 4);
334 AESCommon::inverseMixColumn(state1 + 8, state2 + 8);
335 AESCommon::inverseMixColumn(state1 + 12, state2 + 12);
336 AESCommon::inverseShiftRowsAndSubBytes(state2, state1);
346 for (posn = 0; posn < 16; ++posn)
347 output[posn] = state2[posn] ^ schedule[posn];
bool setKey(const uint8_t *key, size_t len)
Sets the key to use for future encryption and decryption operations.
size_t keySize() const
Size of a 128-bit AES key in bytes.
AES128()
Constructs an AES 128-bit block cipher with no initial key.
void clear()
Clears all security-sensitive state from this block cipher.
bool setKey(const uint8_t *key, size_t len)
Sets the key to use for future encryption and decryption operations.
void decryptBlock(uint8_t *output, const uint8_t *input)
Decrypts a single block using this cipher.
AESSmall128()
Constructs an AES 128-bit block cipher with no initial key.
void clear()
Clears all security-sensitive state from this block cipher.
AESTiny128()
Constructs an AES 128-bit block cipher with no initial key.
size_t blockSize() const
Size of an AES block in bytes.
bool setKey(const uint8_t *key, size_t len)
Sets the key to use for future encryption and decryption operations.
void decryptBlock(uint8_t *output, const uint8_t *input)
Decrypts a single block using this cipher.
void encryptBlock(uint8_t *output, const uint8_t *input)
Encrypts a single block using this cipher.
size_t keySize() const
Size of a 128-bit AES key in bytes.