Initial revision
[silc.git] / lib / silccrypt / tests / test_rijndael.c
1 #include <stdio.h>
2 #include <stdlib.h>
3
4 main()
5 {
6         int i, k;
7         unsigned char key[256];
8         unsigned char plain[256];
9         unsigned char plain2[256];
10         unsigned char cipher[256];
11         memset(&key, 0, sizeof(key));
12         memset(&plain, 0, sizeof(plain));
13         memset(&plain2, 0, sizeof(plain2));
14         memset(&cipher, 0, sizeof(cipher));
15
16         fprintf(stderr, "\nKey:\n");
17         for (i = 0; i < sizeof(key) / 2; i++) {
18                 key[i] = i;
19                 key[i+1] = i+1;
20                 fprintf(stderr, "%02x%02x ", key[i], key[i+1]);
21         }
22
23         fprintf(stderr, "\nSetting key\n");
24         set_key(key, 128);
25
26         fprintf(stderr, "\nPlaintext:\n");
27         for (i = 0; i < sizeof(plain) / 2; i++) {
28                 plain[i] = i;
29                 plain[i+1] = i+1;
30                 fprintf(stderr, "%02x%02x ", plain[i], plain[i+1]);
31         }
32
33         fprintf(stderr, "Encrypting\n");
34         encrypt(plain, cipher);
35
36         fprintf(stderr, "\nCiphertext:\n");
37         for (i = 0; i < sizeof(cipher); i++) {
38                 fprintf(stderr, "%02x", cipher[i]);
39         }
40
41         fprintf(stderr, "Decrypting\n");
42         decrypt(cipher, plain2);
43
44         fprintf(stderr, "\nDecryptedtext:\n");
45         for (i = 0; i < sizeof(plain2); i++) {
46                 fprintf(stderr, "%02x", plain2[i]);
47         }
48
49 }