File: test_main_mac.c

package info (click to toggle)
openswan 1%3A2.4.6%2Bdfsg.2-1.1%2Betch2
  • links: PTS
  • area: main
  • in suites: etch
  • size: 25,000 kB
  • ctags: 16,877
  • sloc: ansic: 121,112; sh: 19,782; xml: 9,699; asm: 4,422; perl: 4,087; makefile: 3,367; tcl: 713; exp: 657; yacc: 396; pascal: 328; lex: 289; sed: 265; awk: 124; lisp: 3
file content (30 lines) | stat: -rw-r--r-- 784 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <stdio.h>
#include <sys/types.h>
#include <string.h>
#include "aes.h"
#include "aes_xcbc_mac.h"
#define STR "Hola guasssso c|mo estais ...012"  
void print_hash(const __u8 *hash) {
	printf("%08x %08x %08x %08x\n", 
			*(__u32*)(&hash[0]), 
			*(__u32*)(&hash[4]), 
			*(__u32*)(&hash[8]), 
			*(__u32*)(&hash[12]));
}
int main(int argc, char *argv[]) {
	aes_block key= { 0xdeadbeef, 0xceedcaca, 0xcafebabe, 0xff010204 };
	__u8  hash[16];
	char *str = argv[1];
	aes_context_mac ctx;
	if (str==NULL) {
		fprintf(stderr, "pasame el str\n");
		return 255;
	}
	AES_xcbc_mac_set_key(&ctx, (__u8 *)&key, sizeof(key));
	AES_xcbc_mac_hash(&ctx, str, strlen(str), hash);
	print_hash(hash);
	str[2]='x';
	AES_xcbc_mac_hash(&ctx, str, strlen(str), hash);
	print_hash(hash);
	return 0;
}