masqmail

annotate src/md5/hmactest.c @ 203:45acc5727493

removed --with-glib-static configure option linking glib statically is interesting if no other program uses it on today's systems glib is widely used if one cares on linking statically, he can link everything statically the special case for glib will not get special care anymore
author meillo@marmaro.de
date Fri, 16 Jul 2010 14:48:17 +0200
parents 08114f7dcc23
children dcb315792513
rev   line source
meillo@0 1 #include <stdio.h>
meillo@0 2 #include <stdlib.h>
meillo@0 3 #include <sys/time.h>
meillo@0 4 #include <string.h>
meillo@0 5 #include "global.h"
meillo@0 6 #include "md5.h"
meillo@0 7 #include "hmac_md5.h"
meillo@0 8
meillo@10 9 static void
meillo@10 10 pad0_copy(char *d, char *s, int sz)
meillo@0 11 {
meillo@10 12 int i = 0;
meillo@10 13 while (*s && (i < sz)) {
meillo@10 14 *(d++) = *(s++);
meillo@10 15 i++;
meillo@10 16 }
meillo@10 17 while (i <= sz) {
meillo@10 18 *(d++) = 0;
meillo@10 19 i++;
meillo@10 20 }
meillo@0 21 }
meillo@0 22
meillo@10 23 int
meillo@10 24 main()
meillo@0 25 {
meillo@10 26 int i;
meillo@10 27 // unsigned char digest[16];
meillo@10 28 char digest[16];
meillo@10 29 char *msgid = "<1896.697170952@postoffice.reston.mci.net>";
meillo@10 30 char secret[65];
meillo@0 31
meillo@10 32 hmac_md5("<48157.953508124@mail.class-c.net>", 34, "no!SpamAtAll", 12, digest);
meillo@10 33 for (i = 0; i < 16; i++)
meillo@10 34 printf("%x", (unsigned int) digest[i]);
meillo@10 35 printf("\n");
meillo@0 36
meillo@10 37 hmac_md5(msgid, strlen(msgid), "tanstaaftanstaaf", 16, digest);
meillo@10 38 for (i = 0; i < 16; i++)
meillo@10 39 printf("%x", (unsigned int) digest[i]);
meillo@10 40 printf("\n");
meillo@0 41
meillo@10 42 pad0_copy(secret, "tanstaaftanstaaf", 64);
meillo@10 43 hmac_md5(msgid, strlen(msgid), secret, 64, digest);
meillo@10 44 for (i = 0; i < 16; i++)
meillo@10 45 printf("%x", (unsigned int) digest[i]);
meillo@10 46 printf("\n");
meillo@0 47
meillo@10 48 exit(0);
meillo@0 49 }