9 unsigned char key[256];
10 unsigned char plain[256];
11 unsigned char plain2[256];
12 unsigned char cipher[256];
13 unsigned char iv[256];
15 memset(&key, 0, sizeof(key));
16 memset(&plain, 0, sizeof(plain));
17 memset(&plain2, 0, sizeof(plain2));
18 memset(&cipher, 0, sizeof(cipher));
19 memset(&iv, 0, sizeof(iv));
21 fprintf(stderr, "\nKey:\n");
22 for (i = 0; i < (sizeof(key) / 2); i += 2) {
23 fprintf(stderr, "%02x%02x ", key[i], key[i+1]);
26 fprintf(stderr, "\nSetting key\n");
27 silc_mars_init(NULL, key, 128);
29 fprintf(stderr, "\nPlaintext:\n");
30 for (i = 0; i < (sizeof(plain) / 2); i += 2) {
33 fprintf(stderr, "%02x%02x ", plain[i], plain[i+1]);
36 fprintf(stderr, "\n\nEncrypting\n");
37 silc_mars_encrypt_cbc(NULL, plain, cipher, 256, iv);
39 fprintf(stderr, "Ciphertext:\n");
40 for (i = 0; i < (sizeof(cipher)/2); i += 2) {
41 fprintf(stderr, "%02x", cipher[i]);
42 fprintf(stderr, "%02x ", cipher[i+1]);
45 fprintf(stderr, "\n\nDecrypting\n");
46 silc_mars_decrypt_cbc(NULL, cipher, plain2, 256, iv);
48 fprintf(stderr, "Decryptedtext:\n");
49 for (i = 0; i < (sizeof(plain2)/2); i += 2) {
50 fprintf(stderr, "%02x", plain2[i]);
51 fprintf(stderr, "%02x ", plain2[i+1]);
53 fprintf(stderr, "\nDone\n");