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 static int pretty_print(const unsigned char *buf, int count) {
16 for (;i<count;i++) printf ("%02hhx ", buf[i]);
20 //#define SIZE STRSZ/2
24 char buf0[SIZE+1], buf1[SIZE+1];
25 char IV[AES_BLOCK_SIZE];
27 AES_set_key(&ac, KEY, KEY_SIZE);
28 memset(buf0, 0, sizeof (buf0));
29 memset(buf1, 0, sizeof (buf1));
30 pretty_print(STR, SIZE);
31 ret=AES_cbc_encrypt(&ac, STR, buf0, SIZE, IV, 1);
32 pretty_print(buf0, SIZE);
33 printf("size=%d ret=%d\n%s\n", SIZE, ret, buf0);
34 ret=AES_cbc_encrypt(&ac, buf0, buf1, SIZE, IV, 0);
35 printf("size=%d ret=%d\n%s\n", SIZE, ret, buf1);