3 #include "silcincludes.h"
10 unsigned char key[256];
11 unsigned char plain[256];
12 unsigned char plain2[256];
13 unsigned char cipher[256];
14 unsigned char iv[256];
17 memset(&key, 0, sizeof(key));
18 memset(&plain, 0, sizeof(plain));
19 memset(&plain2, 0, sizeof(plain2));
20 memset(&cipher, 0, sizeof(cipher));
21 memset(&iv, 0, sizeof(iv));
23 context = malloc(silc_twofish_context_len());
25 fprintf(stderr, "\nKey:\n");
26 for (i = 0; i < (sizeof(key) / 2); i += 2) {
27 fprintf(stderr, "%02x%02x ", key[i], key[i+1]);
30 fprintf(stderr, "\nSetting key\n");
31 silc_twofish_set_key(context, key, 256);
33 fprintf(stderr, "\nPlaintext:\n");
34 for (i = 0; i < (sizeof(plain) / 2); i += 2) {
37 fprintf(stderr, "%02x%02x ", plain[i], plain[i+1]);
40 fprintf(stderr, "\n\nEncrypting\n");
41 silc_twofish_encrypt_cbc(context, plain, cipher, 256, iv);
43 fprintf(stderr, "Ciphertext:\n");
44 for (i = 0; i < (sizeof(cipher)/2); i += 2) {
45 fprintf(stderr, "%02x", cipher[i]);
46 fprintf(stderr, "%02x ", cipher[i+1]);
49 memset(&iv, 0, sizeof(iv));
51 fprintf(stderr, "\n\nDecrypting\n");
52 silc_twofish_decrypt_cbc(context, cipher, plain2, 256, iv);
54 fprintf(stderr, "Decryptedtext:\n");
55 for (i = 0; i < (sizeof(plain2)/2); i += 2) {
56 fprintf(stderr, "%02x", plain2[i]);
57 fprintf(stderr, "%02x ", plain2[i+1]);
59 fprintf(stderr, "\nDone\n");