comparison src/md5/hmactest.c @ 10:26e34ae9a3e3

changed indention and line wrapping to a more consistent style
author meillo@marmaro.de
date Mon, 27 Oct 2008 16:23:10 +0100
parents 08114f7dcc23
children dcb315792513
comparison
equal deleted inserted replaced
9:31cc8a89cb74 10:26e34ae9a3e3
4 #include <string.h> 4 #include <string.h>
5 #include "global.h" 5 #include "global.h"
6 #include "md5.h" 6 #include "md5.h"
7 #include "hmac_md5.h" 7 #include "hmac_md5.h"
8 8
9 static 9 static void
10 void pad0_copy(char *d, char *s, int sz) 10 pad0_copy(char *d, char *s, int sz)
11 { 11 {
12 int i = 0; 12 int i = 0;
13 while(*s && (i < sz)) { *(d++) = *(s++); i++; } 13 while (*s && (i < sz)) {
14 while(i <= sz) { *(d++) = 0; i++; } 14 *(d++) = *(s++);
15 i++;
16 }
17 while (i <= sz) {
18 *(d++) = 0;
19 i++;
20 }
15 } 21 }
16 22
17 int main() 23 int
24 main()
18 { 25 {
19 int i; 26 int i;
20 // unsigned char digest[16]; 27 // unsigned char digest[16];
21 char digest[16]; 28 char digest[16];
22 char *msgid = "<1896.697170952@postoffice.reston.mci.net>"; 29 char *msgid = "<1896.697170952@postoffice.reston.mci.net>";
23 char secret[65]; 30 char secret[65];
24 31
25 hmac_md5("<48157.953508124@mail.class-c.net>", 34, 32 hmac_md5("<48157.953508124@mail.class-c.net>", 34, "no!SpamAtAll", 12, digest);
26 "no!SpamAtAll", 12, digest); 33 for (i = 0; i < 16; i++)
27 for(i = 0; i < 16; i++) 34 printf("%x", (unsigned int) digest[i]);
28 printf("%x", (unsigned int)digest[i]); 35 printf("\n");
29 printf("\n");
30 36
31 hmac_md5(msgid, strlen(msgid), 37 hmac_md5(msgid, strlen(msgid), "tanstaaftanstaaf", 16, digest);
32 "tanstaaftanstaaf", 16, digest); 38 for (i = 0; i < 16; i++)
33 for(i = 0; i < 16; i++) 39 printf("%x", (unsigned int) digest[i]);
34 printf("%x", (unsigned int)digest[i]); 40 printf("\n");
35 printf("\n");
36 41
37 pad0_copy(secret, "tanstaaftanstaaf", 64); 42 pad0_copy(secret, "tanstaaftanstaaf", 64);
38 hmac_md5(msgid, strlen(msgid), 43 hmac_md5(msgid, strlen(msgid), secret, 64, digest);
39 secret, 64, digest); 44 for (i = 0; i < 16; i++)
40 for(i = 0; i < 16; i++) 45 printf("%x", (unsigned int) digest[i]);
41 printf("%x", (unsigned int)digest[i]); 46 printf("\n");
42 printf("\n");
43 47
44 exit(0); 48 exit(0);
45 } 49 }
46