66 uint8_t *schedule = sched;
67 memcpy(schedule, key, 16);
70 uint8_t iteration = 1;
76 keyScheduleCore(schedule + 16, schedule + 12, iteration);
77 schedule[16] ^= schedule[0];
78 schedule[17] ^= schedule[1];
79 schedule[18] ^= schedule[2];
80 schedule[19] ^= schedule[3];
85 schedule[16] = schedule[12] ^ schedule[0];
86 schedule[17] = schedule[13] ^ schedule[1];
87 schedule[18] = schedule[14] ^ schedule[2];
88 schedule[19] = schedule[15] ^ schedule[3];
128 AESCommon::keyScheduleCore(temp, schedule + 12, (n)); \
129 schedule[0] ^= temp[0]; \
130 schedule[1] ^= temp[1]; \
131 schedule[2] ^= temp[2]; \
132 schedule[3] ^= temp[3]; \
136 schedule[(a) * 4] ^= schedule[(b) * 4]; \
137 schedule[(a) * 4 + 1] ^= schedule[(b) * 4 + 1]; \
138 schedule[(a) * 4 + 2] ^= schedule[(b) * 4 + 2]; \
139 schedule[(a) * 4 + 3] ^= schedule[(b) * 4 + 3]; \
154 AESTiny128::~AESTiny128()
181 memcpy(schedule, key, 16);
189 uint8_t schedule[16];
197 memcpy(schedule, this->schedule, 16);
200 for (posn = 0; posn < 16; ++posn)
201 state1[posn] = input[posn] ^ schedule[posn];
204 for (round = 1; round <= 9; ++round) {
212 AESCommon::subBytesAndShiftRows(state2, state1);
213 AESCommon::mixColumn(state1, state2);
214 AESCommon::mixColumn(state1 + 4, state2 + 4);
215 AESCommon::mixColumn(state1 + 8, state2 + 8);
216 AESCommon::mixColumn(state1 + 12, state2 + 12);
217 for (posn = 0; posn < 16; ++posn)
218 state1[posn] ^= schedule[posn];
228 AESCommon::subBytesAndShiftRows(state2, state1);
229 for (posn = 0; posn < 16; ++posn)
230 output[posn] = state2[posn] ^ schedule[posn];
273 AESSmall128::~AESSmall128()
292 memcpy(schedule, key, 16);
293 for (round = 1; round <= 10; ++round) {
306 uint8_t schedule[16];
314 memcpy(schedule, reverse, 16);
317 for (posn = 0; posn < 16; ++posn)
318 state1[posn] = input[posn] ^ schedule[posn];
319 AESCommon::inverseShiftRowsAndSubBytes(state2, state1);
326 for (round = 9; round >= 1; --round) {
328 for (posn = 0; posn < 16; ++posn)
329 state2[posn] ^= schedule[posn];
330 AESCommon::inverseMixColumn(state1, state2);
331 AESCommon::inverseMixColumn(state1 + 4, state2 + 4);
332 AESCommon::inverseMixColumn(state1 + 8, state2 + 8);
333 AESCommon::inverseMixColumn(state1 + 12, state2 + 12);
334 AESCommon::inverseShiftRowsAndSubBytes(state2, state1);
344 for (posn = 0; posn < 16; ++posn)
345 output[posn] = state2[posn] ^ schedule[posn];
size_t keySize() const
Size of a 128-bit AES key in bytes.
void clear()
Clears all security-sensitive state from this block cipher.
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.
void decryptBlock(uint8_t *output, const uint8_t *input)
Decrypts a single block using this cipher.
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.
size_t blockSize() const
Size of an AES block in bytes.
AESTiny128()
Constructs an AES 128-bit block cipher with no initial key.
bool setKey(const uint8_t *key, size_t len)
Sets the key to use for future encryption and decryption operations.
AES128()
Constructs an AES 128-bit block cipher with no initial key.
bool setKey(const uint8_t *key, size_t len)
Sets the key to use for future encryption and decryption operations.
AESSmall128()
Constructs an AES 128-bit block cipher with no initial key.