Hi, I'm currently working on my masterthesis and encounter the next problem with openssl.
I want to generate a bitstring of a given size, constructed on a given word using SHA1 hash functions. Just by performing SHA1 on the word and concat to that with the SHA1 of the previous SHA1 result. for example. I want a 450bit string, generated by the word "test" > SHA1("test")|SHA(SHA1("test"))|SHA1(SHA(SHA1("test"))) should give me a 480bit string. When I try to implement and test this,for example 19000bits on "testphrase", I noticed that something goes wrong with the SHA1 output now and then. SHA1 outputs 20 bytes almost all time, witch I expect, but sometimes it output a hash that differs from 20bytes ? I theire something wrong with my code ? Or is this normal ? unsigned char* genSha1Key(unsigned char* word, int bitsize) { printf("Generating Sha1Key from given string...\n"); unsigned char* hashcode = NULL; unsigned char* result = NULL; int sha1_count = ((int) (bitsize/160))+1; // = ceil() hashcode =(unsigned char*)malloc(20); result =(unsigned char*)malloc(20*sha1_count); SHA1((const unsigned char*)word,strlen(word), hashcode); result = strcpy(result,hashcode); printf("%i byte code generated\n> Result is now %i bytes long\n",strlen(hashcode),strlen(result)); while(sha1_count>1) { SHA1((const unsigned char*)hashcode,strlen(hashcode), hashcode); strcat(result,hashcode); printf("%i byte code generated\n> Result is now %i bytes long\n",strlen(hashcode),strlen(result)); sha1_count--; } free(hashcode); printf("asked %i bits and generated %i bits\n",bitsize,(strlen(result)*8)); return result; } Thanks for your time Grtz ______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List openssl-users@openssl.org Automated List Manager [EMAIL PROTECTED]