masqmail-0.2

view src/md5/hmactest.c @ 0:08114f7dcc23

this is masqmail-0.2.21 from oliver kurth
author meillo@marmaro.de
date Fri, 26 Sep 2008 17:05:23 +0200
parents
children 26e34ae9a3e3
line source
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <sys/time.h>
4 #include <string.h>
5 #include "global.h"
6 #include "md5.h"
7 #include "hmac_md5.h"
9 static
10 void pad0_copy(char *d, char *s, int sz)
11 {
12 int i = 0;
13 while(*s && (i < sz)) { *(d++) = *(s++); i++; }
14 while(i <= sz) { *(d++) = 0; i++; }
15 }
17 int main()
18 {
19 int i;
20 // unsigned char digest[16];
21 char digest[16];
22 char *msgid = "<1896.697170952@postoffice.reston.mci.net>";
23 char secret[65];
25 hmac_md5("<48157.953508124@mail.class-c.net>", 34,
26 "no!SpamAtAll", 12, digest);
27 for(i = 0; i < 16; i++)
28 printf("%x", (unsigned int)digest[i]);
29 printf("\n");
31 hmac_md5(msgid, strlen(msgid),
32 "tanstaaftanstaaf", 16, digest);
33 for(i = 0; i < 16; i++)
34 printf("%x", (unsigned int)digest[i]);
35 printf("\n");
37 pad0_copy(secret, "tanstaaftanstaaf", 64);
38 hmac_md5(msgid, strlen(msgid),
39 secret, 64, digest);
40 for(i = 0; i < 16; i++)
41 printf("%x", (unsigned int)digest[i]);
42 printf("\n");
44 exit(0);
45 }