Hello,
I used SHA1 functions to create HMAC fingerprint
It is a very simple prog:

---------------------------------
        char *content;
        SHA_CTX ctx;
        unsigned char message_digest[SHA_DIGEST_LENGTH];
        int retval;
        FILE *fh;

        /* SHA1 DIGEST */
        SHA1_Init(&ctx);

        fh = fopen(argv[1], "r");
        content = (char*)malloc(4096);

        while( !feof(fh) ) {
                retval = fread((char*)content, 1, 4096, fh);
                printf("Read:%d\n", retval);
                SHA1_Update(&ctx, content, retval);
        }

        SHA1_Final(message_digest, &ctx);
        puts((char *)message_digest);

        free((void*)content);
        fclose(fh);
-------------------------------

I read file and I create a message digest with SHA1_Final;
For 99,99% of files, I have a good message digest

But, recently I tried to create a message digest for a file and my software 
doesn't work.
I've tried to understand and I've seen that SHA1_Final gives an empty 
message_digest

File available here: http://team.lea-linux.org/prae/fichier.bin
MD5SUM: 9bda8cfe9fef3a6fb94cc3836e0ad993 

File are correctly readed but nothing append after SHA1_Final and software 
doesn't crash (no segfault)
After a small investigation, I see in HASH_FINAL, a function called 
"HASH_MAKE_STRING" (in  crypto/md32_common.h )
Before this call, message digest is correctly defined (md), after this call, md 
is broken

maybe it is not a openssl bug, maybe it's a problem with my implementation
But I prefer to report this, in doubt.

Sincerely




______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
Development Mailing List                       [email protected]
Automated List Manager                           [email protected]

Reply via email to