Hi all,

I have a question for Win coders.. I am porting LibPKI, which is based on
OpenSSL, to Win OSes. On UNiX OSes we used pthread to initialize support
for threads in OpenSSL.

What is the best practice for Win OS ? Does anybody have some sample code
around ? In particular, I am referring to the code like:

void OpenSSL_pthread_init(void) {

        int i;

        lock_cs=OPENSSL_malloc((size_t) (((size_t)CRYPTO_num_locks()) *
                                                sizeof(pthread_mutex_t)));
        lock_count=OPENSSL_malloc(((size_t) (CRYPTO_num_locks()) *
                                                sizeof(long)));
        for (i=0; i<CRYPTO_num_locks(); i++)
                {
                lock_count[i]=0;
                pthread_mutex_init(&(lock_cs[i]),NULL);
                }

        CRYPTO_set_id_callback((unsigned long (*)())pthreads_thread_id);
        CRYPTO_set_locking_callback((void (*)())pthreads_locking_callback);

        /* Initializing the OpenSSL dynamic callbacks as well,
           needed by the nCipher driver */
        CRYPTO_set_dynlock_create_callback(_dyn_create_callback);
        CRYPTO_set_dynlock_lock_callback(_dyn_lock_callback);
        CRYPTO_set_dynlock_destroy_callback(_dyn_destroy_callback);

        return;
}

One possibility would be to use the port of pthreads for Win.. but I was
wondering if some of you already went through the process and know the
best way to provide OpenSSL with thread safety (using native Win calls
instead of pthread ones?)


--

Best Regards,

        Massimiliano Pala

--o------------------------------------------------------------------------
Massimiliano Pala [OpenCA Project Manager]                   ope...@acm.org
                                                 project.mana...@openca.org

Dartmouth Computer Science Dept               Home Phone: +1 (603) 369-9332
PKI/Trust Laboratory                          Work Phone: +1 (603) 646-8734
--o------------------------------------------------------------------------
People who think they know everything are a great annoyance to those of us
who do.
                                                           -- Isaac Asimov

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

Reply via email to