masqmail-0.2

diff 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 diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/md5/hmactest.c	Fri Sep 26 17:05:23 2008 +0200
     1.3 @@ -0,0 +1,46 @@
     1.4 +#include <stdio.h>
     1.5 +#include <stdlib.h>
     1.6 +#include <sys/time.h>
     1.7 +#include <string.h>
     1.8 +#include "global.h"
     1.9 +#include "md5.h"
    1.10 +#include "hmac_md5.h"
    1.11 +
    1.12 +static
    1.13 +void pad0_copy(char *d, char *s, int sz)
    1.14 +{
    1.15 +  int i = 0;
    1.16 +  while(*s && (i < sz)) { *(d++) = *(s++); i++; }
    1.17 +  while(i <= sz) { *(d++) = 0; i++; }
    1.18 +}
    1.19 +
    1.20 +int main()
    1.21 +{
    1.22 +  int i;
    1.23 +  //  unsigned char digest[16];
    1.24 +  char digest[16];
    1.25 +  char *msgid = "<1896.697170952@postoffice.reston.mci.net>";
    1.26 +  char secret[65];
    1.27 +
    1.28 +  hmac_md5("<48157.953508124@mail.class-c.net>", 34,
    1.29 +	   "no!SpamAtAll", 12, digest);
    1.30 +  for(i = 0; i < 16; i++)
    1.31 +    printf("%x", (unsigned int)digest[i]);
    1.32 +  printf("\n");
    1.33 +
    1.34 +  hmac_md5(msgid, strlen(msgid),
    1.35 +	    "tanstaaftanstaaf", 16, digest);
    1.36 +  for(i = 0; i < 16; i++)
    1.37 +    printf("%x", (unsigned int)digest[i]);
    1.38 +  printf("\n");
    1.39 +
    1.40 +  pad0_copy(secret, "tanstaaftanstaaf", 64);
    1.41 +  hmac_md5(msgid, strlen(msgid),
    1.42 +	    secret, 64, digest);
    1.43 +  for(i = 0; i < 16; i++)
    1.44 +    printf("%x", (unsigned int)digest[i]);
    1.45 +  printf("\n");
    1.46 +
    1.47 +  exit(0);
    1.48 +}
    1.49 +