#include #include #include #include "sha1.h" #include "hmac.h" char sha1sum[41]; #define SHA1STR() { \ p=sha1sum; \ for(i=19; i>=0; --i){ \ sprintf(p,"%02x", ((unsigned char*)(sha1_digest))[i] ); \ p+=2; \ }} #define SOMEDATA "fassadenpassformpassendedachkonstuktionen_lagerraumroboterverwaltungssoftwarejungelnesehtorptsurb_fahrradpumpenschlauch_mcguiver_mit_pommes" #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 "what do ya want for nothing?" int main(){ /*SHA1STR makro needs those two*/ int i; char* p; sha1_init(); sha1_fill(0); SHA1STR(); printf("SHA1: %s\n",sha1sum); assert(strcmp("da39a3ee5e6b4b0d3255bfef95601890afd80709",sha1sum)==0); sha1_init(); sha1_addbyte('a'); sha1_addbyte('b'); sha1_addbyte('c'); sha1_fill(3); SHA1STR(); printf("SHA1: %s\n",sha1sum); assert(strcmp("a9993e364706816aba3e25717850c26c9cd0d89d",sha1sum)==0); sha1_init(); for(i=0;i