Exemplo n.º 1
0
static void OpenSslThreadId(CRYPTO_THREADID *ti) {
#if UCFG_WIN32
	CRYPTO_THREADID_set_numeric(ti, ::GetCurrentThreadId());
#else
	CRYPTO_THREADID_set_numeric(ti, ::pthread_self());
#endif
}
void CRYPTO_THREADID_current(CRYPTO_THREADID *id)
	{
	if (threadid_callback)
		{
		threadid_callback(id);
		return;
		}
#ifndef OPENSSL_NO_DEPRECATED
	/* If the deprecated callback was set, fall back to that */
	if (id_callback)
		{
		CRYPTO_THREADID_set_numeric(id, id_callback());
		return;
		}
#endif
	/* Else pick a backup */
#ifdef OPENSSL_SYS_WIN16
	CRYPTO_THREADID_set_numeric(id, (unsigned long)GetCurrentTask());
#elif defined(OPENSSL_SYS_WIN32)
	CRYPTO_THREADID_set_numeric(id, (unsigned long)GetCurrentThreadId());
#elif defined(OPENSSL_SYS_BEOS)
	CRYPTO_THREADID_set_numeric(id, (unsigned long)find_thread(NULL));
#else
	/* For everything else, default to using the address of 'errno' */
	CRYPTO_THREADID_set_pointer(id, (void*)&errno);
#endif
	}
Exemplo n.º 3
0
extern void SSLThread_id(CRYPTO_THREADID *id)
{
#if defined(WIN32)
	CRYPTO_THREADID_set_numeric(id, (unsigned long)GetCurrentThreadId());
#else
	CRYPTO_THREADID_set_numeric(id, (unsigned long)pthread_self());
#endif
}
	static void crypto_threadid_callback(CRYPTO_THREADID *threadId)
	{
		std::ostringstream oss;
		oss << std::this_thread::get_id();
		std::hash<std::string> hash;
		CRYPTO_THREADID_set_numeric(threadId, static_cast<unsigned long>(hash(oss.str())));
	}
Exemplo n.º 5
0
void OpenSSLInitializer::uninitialize()
{
	if (--_rc == 0)
	{
        if(_mutexes != NULL) {
		    CRYPTO_set_dynlock_create_callback(0);
		    CRYPTO_set_dynlock_lock_callback(0);
		    CRYPTO_set_dynlock_destroy_callback(0);
		    CRYPTO_set_locking_callback(0);
#ifndef POCO_OS_FAMILY_WINDOWS
#ifndef OPENSSL_NO_DEPRECATED
		    CRYPTO_set_id_callback(0);
#else
		    CRYPTO_THREADID tid;
		    CRYPTO_THREADID_set_numeric(&tid, 0);
#endif /* OPENSSL_NO_DEPRECATED */
#endif
		    delete [] _mutexes;
		}
        if(! _disableSSLInitialization) {
    		EVP_cleanup();
	    	ERR_free_strings();
    		CONF_modules_free();
        }
	}
}
Exemplo n.º 6
0
static void threadIdCallback(CRYPTO_THREADID * id)
{
/// ACE_thread_t turns out to be a struct under Mac OS.
#ifndef __APPLE__
    CRYPTO_THREADID_set_numeric(id, ACE_Thread::self());
#else
    CRYPTO_THREADID_set_pointer(id, ACE_Thread::self());
#endif
}
Exemplo n.º 7
0
static void
pthreads_thread_id(CRYPTO_THREADID *tid)
{
#if !defined(_MSC_VER)
	CRYPTO_THREADID_set_numeric(tid, (unsigned long)pthread_self());
#else
	CRYPTO_THREADID_set_pointer(tid, pthread_self().p);
#endif
}
Exemplo n.º 8
0
static void cb_openssl_threadid(CRYPTO_THREADID *tid) {
	pthread_t me;

	me = pthread_self();

	if (sizeof(me) == sizeof(void *))
		CRYPTO_THREADID_set_pointer(tid, (void *) me);
	else
		CRYPTO_THREADID_set_numeric(tid, (unsigned long) me);
}
Exemplo n.º 9
0
static void janus_dtls_cb_openssl_threadid(CRYPTO_THREADID *tid) {
	/* FIXME Assuming pthread, which is fine as GLib wraps pthread and
	 * so that's what we use anyway? */
	pthread_t me = pthread_self();

	if(sizeof(me) == sizeof(void *)) {
		CRYPTO_THREADID_set_pointer(tid, (void *) me);
	} else {
		CRYPTO_THREADID_set_numeric(tid, (unsigned long) me);
	}
}
Exemplo n.º 10
0
void CRYPTO_THREADID_current(CRYPTO_THREADID *id) {
  if (threadid_callback) {
    threadid_callback(id);
    return;
  }

#if defined(OPENSSL_WINDOWS)
  CRYPTO_THREADID_set_numeric(id, (unsigned long)GetCurrentThreadId());
#else
  /* For everything else, default to using the address of 'errno' */
  CRYPTO_THREADID_set_pointer(id, (void *)&errno);
#endif
}
Exemplo n.º 11
0
void OpenSSLInitializer::initialize()
{
	if (++_rc == 1)
	{
#if OPENSSL_VERSION_NUMBER >= 0x0907000L
		OPENSSL_config(NULL);
#endif
        if(! _disableSSLInitialization) {
		    SSL_library_init();
		    SSL_load_error_strings();
		    OpenSSL_add_all_algorithms();
        }

		char seed[SEEDSIZE];
		RandomInputStream rnd;
		rnd.read(seed, sizeof(seed));
		RAND_seed(seed, SEEDSIZE);
		
        if(CRYPTO_get_locking_callback() == NULL) {
    		int nMutexes = CRYPTO_num_locks();
	    	_mutexes = new Poco::FastMutex[nMutexes];
    		CRYPTO_set_locking_callback(&OpenSSLInitializer::lock);
#ifndef POCO_OS_FAMILY_WINDOWS
// Not needed on Windows (see SF #110: random unhandled exceptions when linking with ssl).
// https://sourceforge.net/p/poco/bugs/110/
//
// From http://www.openssl.org/docs/crypto/threads.html :
// "If the application does not register such a callback using CRYPTO_THREADID_set_callback(), 
//  then a default implementation is used - on Windows and BeOS this uses the system's 
//  default thread identifying APIs"
#ifndef OPENSSL_NO_DEPRECATED
		    CRYPTO_set_id_callback(&OpenSSLInitializer::id);
#else
		    CRYPTO_THREADID tid;
		    CRYPTO_THREADID_set_numeric(&tid, OpenSSLInitializer::id());
#endif /* OPENSSL_NO_DEPRECATED */
#endif
		    CRYPTO_set_dynlock_create_callback(&OpenSSLInitializer::dynlockCreate);
		    CRYPTO_set_dynlock_lock_callback(&OpenSSLInitializer::dynlock);
		    CRYPTO_set_dynlock_destroy_callback(&OpenSSLInitializer::dynlockDestroy);
        }
	}
}
Exemplo n.º 12
0
static void threadIdCallback(CRYPTO_THREADID * id)
{
    CRYPTO_THREADID_set_numeric(id, ACE_Thread::self());
}
Exemplo n.º 13
0
/*
 * OpenSSL thread-safety thread ID callback, up-to-date version.
 */
static void
ssl_thr_id_cb(CRYPTO_THREADID *id)
{
	CRYPTO_THREADID_set_numeric(id, (unsigned long) pthread_self());
}
Exemplo n.º 14
0
/*
================================================================================
	Function	:getThreadId
	Input		:CRYPTO_THREADID *id
				 < thread id information of ssl management >
	Output		:void
	Return		:void
	Description	:get an id of thread
================================================================================
*/
static void getThreadId( CRYPTO_THREADID *id )
{
	CRYPTO_THREADID_set_numeric( id, ( unsigned long )pthread_self( ) );
}
Exemplo n.º 15
0
static void thread_id(CRYPTO_THREADID *pId)
{
	CRYPTO_THREADID_set_numeric(pId, (unsigned long)uv_thread_self());
}
Exemplo n.º 16
0
 static void sdns_openssl_id_cb(CRYPTO_THREADID * id)
 {
     CRYPTO_THREADID_set_numeric(id, (unsigned long)sdns_thread_self());
 }
Exemplo n.º 17
0
NOEXPORT void threadid_func(CRYPTO_THREADID *tid) {
    CRYPTO_THREADID_set_numeric(tid, stunnel_thread_id());
}
Exemplo n.º 18
0
static void my_cb_threadid(CRYPTO_THREADID *id)
{
  CRYPTO_THREADID_set_numeric(id, (unsigned long)pthread_self());
}
Exemplo n.º 19
0
static void threadid_cb(CRYPTO_THREADID *threadid)
{
	GIT_UNUSED(threadid);
	CRYPTO_THREADID_set_numeric(threadid, git_thread_currentid());
}
Exemplo n.º 20
0
void OpenSSL::SetThreadId(CRYPTO_THREADID* id) {
	// MS_TRACE();

	CRYPTO_THREADID_set_numeric(id, (unsigned long)pthread_self());
}
Exemplo n.º 21
0
void OpenSSL::SetThreadId(CRYPTO_THREADID* thread_id)
{
	// ::Debug("-OpenSSL::SetThreadId() [thread_id: 0x%lx]\n", (long)thread_id);
	// Let's assume pthread_self() is an unsigned long (otherwise this won't compile anyway).
	CRYPTO_THREADID_set_numeric(thread_id, (unsigned long)pthread_self());
}