masqmail-0.2

view src/md5/hmactest.c @ 162:52c82d755215

replaced the MD5 implementation with the one of Solar Designer Until now, the sample code of RFC 1321 was used. It had an ugly license. Now we use the implementation of Solar Designer, which is in the Public Domain. http://openwall.info/wiki/people/solar/software/public-domain-source-code/md5
author meillo@marmaro.de
date Sun, 18 Jul 2010 22:01:04 +0200
parents 26e34ae9a3e3
children ca99aa7f052a
line source
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <sys/time.h>
4 #include <string.h>
5 #include "md5.h"
6 #include "hmac_md5.h"
8 static void
9 pad0_copy(char *d, char *s, int sz)
10 {
11 int i = 0;
12 while (*s && (i < sz)) {
13 *(d++) = *(s++);
14 i++;
15 }
16 while (i <= sz) {
17 *(d++) = 0;
18 i++;
19 }
20 }
22 int
23 main()
24 {
25 int i;
26 // unsigned char digest[16];
27 char digest[16];
28 char *msgid = "<1896.697170952@postoffice.reston.mci.net>";
29 char secret[65];
31 hmac_md5("<48157.953508124@mail.class-c.net>", 34, "no!SpamAtAll", 12, digest);
32 for (i = 0; i < 16; i++)
33 printf("%x", (unsigned int) digest[i]);
34 printf("\n");
36 hmac_md5(msgid, strlen(msgid), "tanstaaftanstaaf", 16, digest);
37 for (i = 0; i < 16; i++)
38 printf("%x", (unsigned int) digest[i]);
39 printf("\n");
41 pad0_copy(secret, "tanstaaftanstaaf", 64);
42 hmac_md5(msgid, strlen(msgid), secret, 64, digest);
43 for (i = 0; i < 16; i++)
44 printf("%x", (unsigned int) digest[i]);
45 printf("\n");
47 exit(0);
48 }