masqmail

annotate src/md5/hmactest.c @ 210:e0938c511243

we need at least 32 bits, so let's take a long Solar Designer explained to me that it was int for better performance
author meillo@marmaro.de
date Sun, 18 Jul 2010 22:02:54 +0200
parents dcb315792513
children 38f86ae6171b
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 "md5.h"
meillo@0 6 #include "hmac_md5.h"
meillo@0 7
meillo@10 8 static void
meillo@10 9 pad0_copy(char *d, char *s, int sz)
meillo@0 10 {
meillo@10 11 int i = 0;
meillo@10 12 while (*s && (i < sz)) {
meillo@10 13 *(d++) = *(s++);
meillo@10 14 i++;
meillo@10 15 }
meillo@10 16 while (i <= sz) {
meillo@10 17 *(d++) = 0;
meillo@10 18 i++;
meillo@10 19 }
meillo@0 20 }
meillo@0 21
meillo@10 22 int
meillo@10 23 main()
meillo@0 24 {
meillo@10 25 int i;
meillo@207 26 /* unsigned char digest[16]; */
meillo@10 27 char digest[16];
meillo@10 28 char *msgid = "<1896.697170952@postoffice.reston.mci.net>";
meillo@10 29 char secret[65];
meillo@0 30
meillo@10 31 hmac_md5("<48157.953508124@mail.class-c.net>", 34, "no!SpamAtAll", 12, digest);
meillo@10 32 for (i = 0; i < 16; i++)
meillo@10 33 printf("%x", (unsigned int) digest[i]);
meillo@10 34 printf("\n");
meillo@0 35
meillo@10 36 hmac_md5(msgid, strlen(msgid), "tanstaaftanstaaf", 16, digest);
meillo@10 37 for (i = 0; i < 16; i++)
meillo@10 38 printf("%x", (unsigned int) digest[i]);
meillo@10 39 printf("\n");
meillo@0 40
meillo@10 41 pad0_copy(secret, "tanstaaftanstaaf", 64);
meillo@10 42 hmac_md5(msgid, strlen(msgid), secret, 64, digest);
meillo@10 43 for (i = 0; i < 16; i++)
meillo@10 44 printf("%x", (unsigned int) digest[i]);
meillo@10 45 printf("\n");
meillo@0 46
meillo@10 47 exit(0);
meillo@0 48 }