annotate src/md5/hmactest.c @ 1:af25f5c39d90
added diff from debian (masqmail-0.2.21-4)
author |
meillo@marmaro.de |
date |
Fri, 26 Sep 2008 20:56:23 +0200 |
parents |
|
children |
26e34ae9a3e3 |
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@0
|
9 static
|
meillo@0
|
10 void pad0_copy(char *d, char *s, int sz)
|
meillo@0
|
11 {
|
meillo@0
|
12 int i = 0;
|
meillo@0
|
13 while(*s && (i < sz)) { *(d++) = *(s++); i++; }
|
meillo@0
|
14 while(i <= sz) { *(d++) = 0; i++; }
|
meillo@0
|
15 }
|
meillo@0
|
16
|
meillo@0
|
17 int main()
|
meillo@0
|
18 {
|
meillo@0
|
19 int i;
|
meillo@0
|
20 // unsigned char digest[16];
|
meillo@0
|
21 char digest[16];
|
meillo@0
|
22 char *msgid = "<1896.697170952@postoffice.reston.mci.net>";
|
meillo@0
|
23 char secret[65];
|
meillo@0
|
24
|
meillo@0
|
25 hmac_md5("<48157.953508124@mail.class-c.net>", 34,
|
meillo@0
|
26 "no!SpamAtAll", 12, digest);
|
meillo@0
|
27 for(i = 0; i < 16; i++)
|
meillo@0
|
28 printf("%x", (unsigned int)digest[i]);
|
meillo@0
|
29 printf("\n");
|
meillo@0
|
30
|
meillo@0
|
31 hmac_md5(msgid, strlen(msgid),
|
meillo@0
|
32 "tanstaaftanstaaf", 16, digest);
|
meillo@0
|
33 for(i = 0; i < 16; i++)
|
meillo@0
|
34 printf("%x", (unsigned int)digest[i]);
|
meillo@0
|
35 printf("\n");
|
meillo@0
|
36
|
meillo@0
|
37 pad0_copy(secret, "tanstaaftanstaaf", 64);
|
meillo@0
|
38 hmac_md5(msgid, strlen(msgid),
|
meillo@0
|
39 secret, 64, digest);
|
meillo@0
|
40 for(i = 0; i < 16; i++)
|
meillo@0
|
41 printf("%x", (unsigned int)digest[i]);
|
meillo@0
|
42 printf("\n");
|
meillo@0
|
43
|
meillo@0
|
44 exit(0);
|
meillo@0
|
45 }
|
meillo@0
|
46
|