]>
git.ipfire.org Git - people/ms/strongswan.git/blob - lib/libcrypto/libtwofish/test_main.c
1e8b0db563c76c04769d880a8de825aef0d76428
3 #include "twofish_cbc.h"
5 #define KEY_SIZE 128 /* bits */
6 #define KEY "1234567890123456"
7 #define STR "hola guaso como estaisss ... 012"
8 #define STRSZ (sizeof(STR)-1)
10 #define BLKLEN BLOCK_SIZE
11 #define CONTEXT_T twofish_context
12 static int pretty_print(const unsigned char *buf
, int count
) {
14 for (;i
<count
;i
++) printf ("%02hhx ", buf
[i
]);
18 //#define SIZE STRSZ/2
22 char buf0
[SIZE
+1], buf1
[SIZE
+1];
25 twofish_set_key(&ac
, (void *)KEY
, KEY_SIZE
);
26 memset(buf0
, 0, sizeof (buf0
));
27 memset(buf1
, 0, sizeof (buf1
));
28 twofish_cbc_encrypt(&ac
, STR
, buf0
, SIZE
, IV
, 1);
29 pretty_print(buf0
, SIZE
);
30 printf("size=%d ret=%d\n%s\n", SIZE
, ret
, buf0
);
31 ret
=twofish_cbc_encrypt(&ac
, buf0
, buf1
, SIZE
, IV
, 0);
32 printf("size=%d ret=%d\n%s\n", SIZE
, ret
, buf1
);