Remove unnecessary console output
This commit is contained in:
parent
994b6e654f
commit
cfe7cbd136
|
@ -41,31 +41,12 @@ const uint8_t rCon[12] = {
|
|||
/* AES state type */
|
||||
typedef uint32_t t_state[4];
|
||||
|
||||
/* Helper functions */
|
||||
void hexprint16(uint8_t *p) {
|
||||
for (int i = 0; i < 16; i++)
|
||||
printf("%02hhx ", p[i]);
|
||||
puts("");
|
||||
}
|
||||
|
||||
void hexprintw(uint32_t w) {
|
||||
for (int i = 0; i < 32; i += 8)
|
||||
printf("%02hhx ", (w >> i) & 0xffU);
|
||||
}
|
||||
|
||||
void hexprintws(uint32_t * p, int cnt) {
|
||||
for (int i = 0; i < cnt; i++)
|
||||
hexprintw(p[i]);
|
||||
puts("");
|
||||
}
|
||||
void printstate(t_state s) {
|
||||
hexprintw(s[0]);
|
||||
hexprintw(s[1]);
|
||||
hexprintw(s[2]);
|
||||
hexprintw(s[3]);
|
||||
puts("");
|
||||
}
|
||||
|
||||
uint32_t word(uint8_t a0, uint8_t a1, uint8_t a2, uint8_t a3) {
|
||||
return a0 | (uint32_t)a1 << 8 | (uint32_t)a2 << 16 | (uint32_t)a3 << 24;
|
||||
}
|
||||
|
@ -177,38 +158,22 @@ void aes(uint8_t *in, uint8_t *out, uint8_t *skey)
|
|||
state[i] = word(in[i * 4], in[i * 4 + 1], in[i * 4 + 2], in[i * 4 + 3]);
|
||||
}
|
||||
|
||||
printf("IN: "); printstate(state);
|
||||
|
||||
uint32_t expKey[11 * 4];
|
||||
|
||||
expandKey(skey, expKey);
|
||||
|
||||
for (int i = 0; i < 11; i++) {
|
||||
printf("K%02d: ", i);
|
||||
hexprintws(expKey + 4 * i, 4);
|
||||
}
|
||||
|
||||
addRoundKey(state, expKey, 0);
|
||||
printf("ARK: "); printstate(state);
|
||||
|
||||
for (int i = 1; i <= 10; i++) {
|
||||
subBytes(state);
|
||||
printf("SB: ");
|
||||
printstate(state);
|
||||
|
||||
shiftRows(state);
|
||||
printf("SR: ");
|
||||
printstate(state);
|
||||
|
||||
if (i < 10) {
|
||||
mixColumns(state);
|
||||
printf("MC: ");
|
||||
printstate(state);
|
||||
}
|
||||
|
||||
addRoundKey(state, expKey, 4*i);
|
||||
printf("ARK: ");
|
||||
printstate(state);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 16; i++) {
|
||||
|
@ -348,13 +313,6 @@ int main(int argc, char* argv[])
|
|||
uint8_t out[16] = { 0, /*...*/ };
|
||||
uint8_t res_out[16] = { 0xa3, 0x3a, 0xca, 0x68, 0x72, 0xa2, 0x27, 0x74, 0xbf, 0x99, 0xf3, 0x71, 0xaa, 0x99, 0xd2, 0x5a };
|
||||
|
||||
printf("Key: ");
|
||||
hexprint16(key);
|
||||
puts("");
|
||||
printf("In: ");
|
||||
hexprint16(in);
|
||||
puts("");
|
||||
|
||||
aes(in, out, key);
|
||||
|
||||
printf("Out: ");
|
||||
|
|
Loading…
Reference in a new issue