Hi,

I'm currently using the openssl utilities for computing MD5 sums on files. Until now I have always done these operations in the main thread. Now I want to use the same code in a working thread to be able to update GUI while computing the MD5.

The main thread will only update GUI and wait for the working thread to end. I.e: the main thread will never access the openssl libs while the working thread is alive. I figured that this scenario wouldn't need the callback functions. Please correct me if I'm wrong.

My question is: Given the scenario above, is the following code dangerous in a MT environment?

Simplified example:


   FILE* file = fopen ("testfile", "rb");

   EVP_MD_CTX mdctx;
   unsigned char md_value[EVP_MAX_MD_SIZE];
   unsigned int md_len;

   OpenSSL_add_all_digests();

   EVP_MD_CTX_init(&mdctx);
   EVP_DigestInit_ex(&mdctx, EVP_md5 (), NULL);
char buffer[65536];

   int bytesread;
   while (bytesread = fread (buffer, 1, 65535, file)) {
       EVP_DigestUpdate (&mdctx, buffer, bytesread);
   }

   fclose (file);

   EVP_DigestFinal_ex(&mdctx, md_value, &md_len);
   EVP_MD_CTX_cleanup(&mdctx);



Thanks for any help.

Magnus
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@openssl.org
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to