blob: 8bb4fe670acf0b2a024f6c4c8aa855c53afa81b1 (
plain)
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
|
#include <stdio.h>
#include <stdlib.h>
#include "rijndael.h"
int main(void)
{
RIJNDAEL_context ctx;
UINT8 key[32];
UINT8 text[16];
int i, j;
for (i=0; i<16; i++)
text[i] = i;
for (i=0; i<32; i++)
key[i] = 0;
key[0] = 1;
for (j=16; j<=32; j+=8) {
rijndael_setup(&ctx, j, key);
printf("\nBlock Size = 128 bits, Key Size = %d bits\n", j*8);
printf("\nPlain= ");
for (i=0; i<16; i++)
printf("%2x", text[i]);
printf("\n");
rijndael_encrypt(&ctx, text, text);
printf("Encrypt= ");
for (i=0; i<16; i++)
printf("%02x", text[i]);
printf("\nDecrypt= ");
rijndael_decrypt(&ctx, text, text);
for (i=0; i<16; i++)
printf("%2x", text[i]);
printf("\n");
}
return(0);
}
|