-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUnitTests.cpp
More file actions
69 lines (44 loc) · 1.31 KB
/
Copy pathUnitTests.cpp
File metadata and controls
69 lines (44 loc) · 1.31 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include <iostream>
#include <iomanip>
#include <random>
void PrintBuff(uint8_t* state, int size, int column);
#include "AES.h"
void TestAES();
int main(){
TestAES();
}
void PrintBuff(uint8_t* state, int size, int column=4){
for (int i = 0; i < size; i++){
std::cout << std::hex << (int)state[i] << std::dec << " " << (((i+1)%column) ? "" : "\n");
}
std::cout << "\n";
}
void TestAES(){
std::cout << "=============================AES TEST=============================\n";
srand(time(0));
uint8_t state[16] = {
0x67, 0x67, 0x67, 0x67,
0x67, 0x67, 0x67, 0x67,
0x42, 0x42, 0x42, 0x42,
0x42, 0x42, 0x42, 0x42
};
uint8_t keyRound[16] = {
0x67, 0x67, 0x67, 0x67,
0x00, 0x00, 0x00, 0x00,
0xaa, 0xaa, 0xaa, 0xaa,
0x77, 0x77, 0x77, 0x77
};
uint8_t state1[16], state2[16];
for (int i = 0; i<16; i++){
state1[i] = state[i];
state2[i] = state[i];
}
std::cout << "Manual Implementation Single Round\n\n";
PrintBuff(state1, 16);
SingleRoundAES(state1, keyRound);
PrintBuff(state1, 16);
std::cout << "Hardware Implementation Single Round\n\n";
PrintBuff(state2, 16);
SingleInstructionRoundAES(state2, keyRound);
PrintBuff(state2, 16);
}