summaryrefslogtreecommitdiff
path: root/set4/task27.c
blob: ae279cd5aad2551e343a3a220a8fc44d488fcfe0 (plain)
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
#include "../lib/lib.h"
#include "../lib/lib2.h"
#include "../lib/lib3.h"
#include "../lib/lib4.h"
#include <time.h>


int main()
{
	unsigned int hex[5];
	int i;
	char text[] = "Rolling on the floor lauthing";
	char *key = "ROFL";

	sha1_hmac(hex, text, strlen(text), key, strlen(key));
	for(i=0; i<5; i++) {
		printf("%08x", hex[i]);
	}
	printf("\n");

	if(sha1_hmac_verify(hex, text, strlen(text), key, strlen(key)))
		printf("MACs are equal\n");

	// tamper message change R to r
	text[0] = 'r';

	if(!sha1_hmac_verify(hex, text, strlen(text), key, strlen(key)))
		printf("MACs of tampered message are NOT equal\n");
}