OSDN Git Service

2013.10.24
[uclinux-h8/uClinux-dist.git] / freeswan / libcrypto / libaes / test_main_mac.c
1 #include <stdio.h>
2 #include <sys/types.h>
3 #include <string.h>
4 #include "aes.h"
5 #include "aes_xcbc_mac.h"
6 #define STR "Hola guasssso c|mo estais ...012"  
7 void print_hash(const __u8 *hash) {
8         printf("%08x %08x %08x %08x\n", 
9                         *(__u32*)(&hash[0]), 
10                         *(__u32*)(&hash[4]), 
11                         *(__u32*)(&hash[8]), 
12                         *(__u32*)(&hash[12]));
13 }
14 int main(int argc, char *argv[]) {
15         aes_block key= { 0xdeadbeef, 0xceedcaca, 0xcafebabe, 0xff010204 };
16         __u8  hash[16];
17         char *str = argv[1];
18         aes_context_mac ctx;
19         if (str==NULL) {
20                 fprintf(stderr, "pasame el str\n");
21                 return 255;
22         }
23         AES_xcbc_mac_set_key(&ctx, (__u8 *)&key, sizeof(key));
24         AES_xcbc_mac_hash(&ctx, str, strlen(str), hash);
25         print_hash(hash);
26         str[2]='x';
27         AES_xcbc_mac_hash(&ctx, str, strlen(str), hash);
28         print_hash(hash);
29         return 0;
30 }