]>
git.ipfire.org Git - people/ms/strongswan.git/blob - src/libfreeswan/libcrypto/libaes/test_main.c
5 #define AES_BLOCK_SIZE 16
6 #define KEY_SIZE 128 /* bits */
7 #define KEY "1234567890123456"
8 #define STR "hola guaso como estaisss ... 012"
9 #define STRSZ (sizeof(STR)-1)
11 #define EMT_AESCBC_BLKLEN AES_BLOCK_SIZE
12 #define AES_CONTEXT_T aes_context
13 #define EMT_ESPAES_KEY_SZ 16
14 int pretty_print(const unsigned char *buf
, int count
) {
17 if (i
%8==0) putchar(' ');
18 if (i
%16==0) putchar('\n');
19 printf ("%02hhx ", buf
[i
]);
24 //#define SIZE STRSZ/2
28 char buf0
[SIZE
+1], buf1
[SIZE
+1];
29 char IV
[AES_BLOCK_SIZE
]="\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0";
31 AES_set_key(&ac
, KEY
, KEY_SIZE
);
32 //pretty_print((char *)&ac.aes_e_key, sizeof(ac.aes_e_key));
33 memset(buf0
, 0, sizeof (buf0
));
34 memset(buf1
, 0, sizeof (buf1
));
35 ret
=AES_cbc_encrypt(&ac
, STR
, buf0
, SIZE
, IV
, 1);
36 pretty_print(buf0
, SIZE
);
37 printf("size=%d ret=%d\n%s\n", SIZE
, ret
, buf0
);
38 ret
=AES_cbc_encrypt(&ac
, buf0
, buf1
, SIZE
, IV
, 0);
39 printf("size=%d ret=%d\n%s\n", SIZE
, ret
, buf1
);