-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathroundkey.c
29 lines (25 loc) · 1.01 KB
/
roundkey.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <stdio.h>
#include <inttypes.h>
int main(int argc, char **argv)
{
// uint8_t state[4][4] = { {0x32, 0x88, 0x31, 0xe0},
// {0x43, 0x5a, 0x31, 0x37},
// {0xf6, 0x30, 0x98, 0x07},
// {0xa8, 0x8d, 0xa2, 0x34} };
// uint32_t round[] = {0x2b, 0x28, 0xab, 0x09, 0x7e, 0xae, 0xf7, 0xcf, 0x15, 0xd2, 0x15, 0x4f, 0x16, 0xa6, 0x88, 0x3c};
uint32_t state[] = {0x32, 0x88, 0x31, 0xE0, 0x43, 0x5A, 0x31, 0x37, 0xF6, 0x30, 0x98, 0x07, 0xA8, 0x8D, 0xA2, 0x34};
uint32_t round[] = {0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c};
size_t row, col;
for (row = 0; row < 4; row++) {
for (col = 0; col < 4; col++) {
// state[row][col] = state[row][col] ^ round[row + 4*col];
state[4*row + col] = state[4*row + col] ^ round[row + 4*col];
// printf("%02x ", state[row][col]);
// printf("%02x ", round[row + 4*col]);
printf("%02x ", state[4*row + col]);
}
printf("\n");
}
printf("\n");
return 0;
}