Mercurial > masqmail
view src/md5/hmactest.c @ 209:10da50168dab
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 21:58:15 +0200 |
parents | dcb315792513 |
children | 38f86ae6171b |
line wrap: on
line source
#include <stdio.h> #include <stdlib.h> #include <sys/time.h> #include <string.h> #include "md5.h" #include "hmac_md5.h" static void pad0_copy(char *d, char *s, int sz) { int i = 0; while (*s && (i < sz)) { *(d++) = *(s++); i++; } while (i <= sz) { *(d++) = 0; i++; } } int main() { int i; /* unsigned char digest[16]; */ char digest[16]; char *msgid = "<1896.697170952@postoffice.reston.mci.net>"; char secret[65]; hmac_md5("<48157.953508124@mail.class-c.net>", 34, "no!SpamAtAll", 12, digest); for (i = 0; i < 16; i++) printf("%x", (unsigned int) digest[i]); printf("\n"); hmac_md5(msgid, strlen(msgid), "tanstaaftanstaaf", 16, digest); for (i = 0; i < 16; i++) printf("%x", (unsigned int) digest[i]); printf("\n"); pad0_copy(secret, "tanstaaftanstaaf", 64); hmac_md5(msgid, strlen(msgid), secret, 64, digest); for (i = 0; i < 16; i++) printf("%x", (unsigned int) digest[i]); printf("\n"); exit(0); }