|
|
|
|
@ -8,7 +8,7 @@ |
|
|
|
|
|
|
|
|
|
char sha1sum[41]; |
|
|
|
|
|
|
|
|
|
#define SHA1STR() { \ |
|
|
|
|
#define SHA1STR() { \ |
|
|
|
|
p=sha1sum; \
|
|
|
|
|
for(i=19; i>=0; --i){ \
|
|
|
|
|
sprintf(p,"%02x", ((unsigned char*)(sha1_digest))[i] ); \
|
|
|
|
|
@ -20,6 +20,9 @@ char sha1sum[41]; |
|
|
|
|
#define SECRET1 {0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b} |
|
|
|
|
#define MSG1 "Hi There" |
|
|
|
|
|
|
|
|
|
#define SECRET2 {'J', 'e', 'f', 'e'}; |
|
|
|
|
#define MSG2 "" |
|
|
|
|
|
|
|
|
|
int main(){ |
|
|
|
|
/*SHA1STR makro needs those two*/ |
|
|
|
|
int i; |
|
|
|
|
@ -49,10 +52,17 @@ int main(){ |
|
|
|
|
printf("SHA1: %s\n",sha1sum); |
|
|
|
|
assert(strcmp("4d71043a68fa28b9592d1aa5748e5cd4291c0512",sha1sum)==0);
|
|
|
|
|
|
|
|
|
|
char sec[20]=SECRET1; |
|
|
|
|
char sec1[20]=SECRET1; |
|
|
|
|
hmac(MSG1,8,sec,20); |
|
|
|
|
SHA1STR(); |
|
|
|
|
printf("HMAC: %s\n",sha1sum); |
|
|
|
|
assert(strcmp("b617318655057264e28bc0b6fb378c8ef146be00",sha1sum)==0);
|
|
|
|
|
|
|
|
|
|
char sec1[20]=SECRET2; |
|
|
|
|
hmac(MSG2,8,sec,20); |
|
|
|
|
SHA1STR(); |
|
|
|
|
printf("HMAC: %s\n",sha1sum); |
|
|
|
|
//assert(strcmp("b617318655057264e28bc0b6fb378c8ef146be00",sha1sum)==0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|