-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.c
64 lines (56 loc) · 2.19 KB
/
test.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
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
#include <stdio.h>
#include <stdlib.h>
#include "aes.h"
#include "opmode.h"
void PrintText(uint8_t text[16]) {
for (int i = 0; i < 16; i++)
printf("%02x", text[i]);
printf("\n");
}
int main(void) {
uint8_t plaintext[16] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee,
0xff};
uint8_t plaintext2[16] = {0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10};
uint8_t key128[16] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
0x0f};
uint8_t key192[24] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
0x0f,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17};
uint8_t key256[32] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
0x0f,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e,
0x1f};
uint8_t ciphertext[16];
uint8_t cbckey[16] = {0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c};
uint8_t iv[16] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f};
// PrintText(plaintext);
SetKey(cbckey, 16);
// SetKey(key192, 24);
// DecryptLUT(ciphertext, plaintext);
//
// SetLUTMode();
//
// EncryptLUT(plaintext, ciphertext);
// DecryptLUT(ciphertext, plaintext);
// PrintText(plaintext);
//
// SetKey(key256, 32);
// EncryptLUT(plaintext, ciphertext);
// PrintText(ciphertext);
// DecryptLUT(ciphertext, plaintext);
// PrintText(plaintext);
//
// QuitLUTMode();
//
// EncryptLUT(plaintext, ciphertext);
// DecryptLUT(ciphertext, plaintext);
//
// EncryptSBox(plaintext, ciphertext);
// PrintText(ciphertext);
// EncryptSBox(plaintext2, ciphertext);
// PrintText(ciphertext);
SetIV(iv);
EncryptCBC("testdata.txt","Encrypted.txt");
DecryptCBC("Encrypted.txt", "decrypted.txt");
// system("pause");
}