66 uint8_t *schedule = sched;
67 memcpy(schedule, key, 32);
70 uint8_t iteration = 1;
76 keyScheduleCore(schedule + 32, schedule + 28, iteration);
77 schedule[32] ^= schedule[0];
78 schedule[33] ^= schedule[1];
79 schedule[34] ^= schedule[2];
80 schedule[35] ^= schedule[3];
85 applySbox(schedule + 32, schedule + 28);
86 schedule[32] ^= schedule[0];
87 schedule[33] ^= schedule[1];
88 schedule[34] ^= schedule[2];
89 schedule[35] ^= schedule[3];
92 schedule[32] = schedule[28] ^ schedule[0];
93 schedule[33] = schedule[29] ^ schedule[1];
94 schedule[34] = schedule[30] ^ schedule[2];
95 schedule[35] = schedule[31] ^ schedule[3];
135 #define ENCRYPT(phase) \
137 AESCommon::subBytesAndShiftRows(state2, state1); \
138 AESCommon::mixColumn(state1, state2); \
139 AESCommon::mixColumn(state1 + 4, state2 + 4); \
140 AESCommon::mixColumn(state1 + 8, state2 + 8); \
141 AESCommon::mixColumn(state1 + 12, state2 + 12); \
142 for (posn = 0; posn < 16; ++posn) \
143 state1[posn] ^= schedule[posn + (phase)]; \
145 #define DECRYPT(phase) \
147 for (posn = 0; posn < 16; ++posn) \
148 state2[posn] ^= schedule[posn + (phase)]; \
149 AESCommon::inverseMixColumn(state1, state2); \
150 AESCommon::inverseMixColumn(state1 + 4, state2 + 4); \
151 AESCommon::inverseMixColumn(state1 + 8, state2 + 8); \
152 AESCommon::inverseMixColumn(state1 + 12, state2 + 12); \
153 AESCommon::inverseShiftRowsAndSubBytes(state2, state1); \
157 AESCommon::keyScheduleCore(temp, schedule + 28, (n)); \
158 schedule[0] ^= temp[0]; \
159 schedule[1] ^= temp[1]; \
160 schedule[2] ^= temp[2]; \
161 schedule[3] ^= temp[3]; \
165 schedule[(a) * 4] ^= schedule[(b) * 4]; \
166 schedule[(a) * 4 + 1] ^= schedule[(b) * 4 + 1]; \
167 schedule[(a) * 4 + 2] ^= schedule[(b) * 4 + 2]; \
168 schedule[(a) * 4 + 3] ^= schedule[(b) * 4 + 3]; \
172 AESCommon::applySbox(temp, schedule + 12); \
173 schedule[16] ^= temp[0]; \
174 schedule[17] ^= temp[1]; \
175 schedule[18] ^= temp[2]; \
176 schedule[19] ^= temp[3]; \
191 AESTiny256::~AESTiny256()
218 memcpy(schedule, key, 32);
226 uint8_t schedule[32];
234 memcpy(schedule, this->schedule, 32);
237 for (posn = 0; posn < 16; ++posn)
238 state1[posn] = input[posn] ^ schedule[posn];
242 for (round = 1; round <= 6; ++round) {
265 AESCommon::subBytesAndShiftRows(state2, state1);
266 for (posn = 0; posn < 16; ++posn)
267 output[posn] = state2[posn] ^ schedule[posn];
310 AESSmall256::~AESSmall256()
329 memcpy(schedule, key, 32);
330 for (round = 1; round <= 6; ++round) {
351 uint8_t schedule[32];
359 memcpy(schedule, reverse, 32);
362 for (posn = 0; posn < 16; ++posn)
363 state1[posn] = input[posn] ^ schedule[posn];
364 AESCommon::inverseShiftRowsAndSubBytes(state2, state1);
371 for (round = 6; round >= 1; --round) {
389 for (posn = 0; posn < 16; ++posn)
390 output[posn] = state2[posn] ^ schedule[posn];
void clear()
Clears all security-sensitive state from this block cipher.
size_t keySize() const
Size of a 256-bit AES key in bytes.
AESSmall256()
Constructs an AES 256-bit block cipher with no initial key.
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.
void decryptBlock(uint8_t *output, const uint8_t *input)
Decrypts a single block using this cipher.
AES256()
Constructs an AES 256-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.
bool setKey(const uint8_t *key, size_t len)
Sets the key to use for future encryption and decryption operations.
void clear()
Clears all security-sensitive state from this block cipher.
AESTiny256()
Constructs an AES 256-bit block cipher with no initial key.
size_t keySize() const
Size of a 256-bit AES key in bytes.
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.