当前位置: 首页>>代码示例>>C++>>正文


C++ CRYPTO_set_dynlock_lock_callback函数代码示例

本文整理汇总了C++中CRYPTO_set_dynlock_lock_callback函数的典型用法代码示例。如果您正苦于以下问题:C++ CRYPTO_set_dynlock_lock_callback函数的具体用法?C++ CRYPTO_set_dynlock_lock_callback怎么用?C++ CRYPTO_set_dynlock_lock_callback使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了CRYPTO_set_dynlock_lock_callback函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: sthreads_init

int sthreads_init(void) {
    int i;

    /* initialize stunnel critical sections */
    for(i=0; i<CRIT_SECTIONS; i++)
        pthread_mutex_init(stunnel_cs+i, NULL);

    /* initialize OpenSSL locking callback */
    lock_cs=str_alloc_detached(
                (size_t)CRYPTO_num_locks()*sizeof(pthread_mutex_t));
    for(i=0; i<CRYPTO_num_locks(); i++)
        pthread_mutex_init(lock_cs+i, NULL);
#if OPENSSL_VERSION_NUMBER>=0x10000000L
    CRYPTO_THREADID_set_callback(threadid_func);
#else
    CRYPTO_set_id_callback(stunnel_thread_id);
#endif
    CRYPTO_set_locking_callback(locking_callback);

    /* initialize OpenSSL dynamic locks callbacks */
    CRYPTO_set_dynlock_create_callback(dyn_create_function);
    CRYPTO_set_dynlock_lock_callback(dyn_lock_function);
    CRYPTO_set_dynlock_destroy_callback(dyn_destroy_function);

    return 0;
}
开发者ID:NickolasLapp,项目名称:stunnel_local,代码行数:26,代码来源:sthreads.c

示例2: tor_init

void
tor_init (void)
{
	if (initialized) {
		return;
	}

	ERR_load_crypto_strings();
	OpenSSL_add_all_algorithms();

	// enable proper threading
	locks.length = CRYPTO_num_locks();
	locks.item   = malloc(locks.length * sizeof(uv_mutex_t));

	for (size_t i = 0; i < locks.length; i++) {
		uv_mutex_init(&locks.item[i]);
	}

	CRYPTO_set_locking_callback(_locking_callback);
	CRYPTO_set_id_callback(uv_thread_self);
	CRYPTO_set_dynlock_create_callback(_dynlock_create_callback);
	CRYPTO_set_dynlock_lock_callback(_dynlock_lock_callback);
	CRYPTO_set_dynlock_destroy_callback(_dynlock_destroy_callback);

	ENGINE_load_builtin_engines();
	ENGINE_register_all_complete();

	initialized = true;
}
开发者ID:postfix,项目名称:libtor,代码行数:29,代码来源:tor.c

示例3: server_destroy_ssl

/*
 * Bring down the OpenSSL subsystem
 */
static BOOL server_destroy_ssl( Remote * remote )
{
	int i = 0;

	if( remote == NULL )
		return FALSE;

	dprintf("[SERVER] Destroying SSL");

	lock_acquire( remote->lock );

	SSL_free( remote->ssl );
	
	SSL_CTX_free( remote->ctx );

	CRYPTO_set_locking_callback( NULL );
	CRYPTO_set_id_callback( NULL );
	CRYPTO_set_dynlock_create_callback( NULL );
	CRYPTO_set_dynlock_lock_callback( NULL );
	CRYPTO_set_dynlock_destroy_callback( NULL );

	for( i=0 ; i<CRYPTO_num_locks() ; i++ )
		lock_destroy( ssl_locks[i] );
		
	free( ssl_locks );

	lock_release( remote->lock );

	return TRUE;
}
开发者ID:kartikeyap,项目名称:meterpreter,代码行数:33,代码来源:server_setup.c

示例4: SSL_library_init

void SSLContext::initializeOpenSSLLocked() {
  if (initialized_) {
    return;
  }
  SSL_library_init();
  SSL_load_error_strings();
  ERR_load_crypto_strings();
  // static locking
  locks.reset(new SSLLock[::CRYPTO_num_locks()]);
  for (auto it: lockTypes) {
    locks[it.first].lockType = it.second;
  }
  CRYPTO_set_id_callback(callbackThreadID);
  CRYPTO_set_locking_callback(callbackLocking);
  // dynamic locking
  CRYPTO_set_dynlock_create_callback(dyn_create);
  CRYPTO_set_dynlock_lock_callback(dyn_lock);
  CRYPTO_set_dynlock_destroy_callback(dyn_destroy);
  randomize();
#ifdef OPENSSL_NPN_NEGOTIATED
  sNextProtocolsExDataIndex_ = SSL_get_ex_new_index(0,
      (void*)"Advertised next protocol index", nullptr, nullptr, nullptr);
#endif
  initialized_ = true;
}
开发者ID:axiak,项目名称:folly,代码行数:25,代码来源:SSLContext.cpp

示例5: Thread_cleanup

int
Thread_cleanup(void)
{
#ifdef _USE_OPENSSL
  int i;

  if (!mutex_buf)
    return 0;

  CRYPTO_set_id_callback(NULL);
  CRYPTO_set_locking_callback(NULL);

#ifdef _DYNAMIC_LOCKING_MECHANISM_

  CRYPTO_set_dynlock_create_callback(NULL);
  CRYPTO_set_dynlock_lock_callback(NULL);
  CRYPTO_set_dynlock_destroy_callback(NULL);
#endif
  for (i=0 ; i < CRYPTO_num_locks(); i++)
    MUTEX_CLEANUP(mutex_buf[i]);

  mutex_buf = NULL ;
  return 1;
#else
  return -1;
#endif
}
开发者ID:SIPp,项目名称:polycom-sipped,代码行数:27,代码来源:sslthreadsafe.cpp

示例6: lock

void OpenSSLInitializer::initialize()
{
	Poco::FastMutex::ScopedLock lock(_mutex);
	
	if (++_rc == 1)
	{
#if OPENSSL_VERSION_NUMBER >= 0x0907000L
		OPENSSL_config(NULL);
#endif
		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);
		
		int nMutexes = CRYPTO_num_locks();
		_mutexes = new Poco::FastMutex[nMutexes];
		CRYPTO_set_locking_callback(&OpenSSLInitializer::lock);
#ifndef POCO_OS_FAMILY_WINDOWS // SF# 1828231: random unhandled exceptions when linking with ssl
		CRYPTO_set_id_callback(&OpenSSLInitializer::id);
#endif
		CRYPTO_set_dynlock_create_callback(&OpenSSLInitializer::dynlockCreate);
		CRYPTO_set_dynlock_lock_callback(&OpenSSLInitializer::dynlock);
		CRYPTO_set_dynlock_destroy_callback(&OpenSSLInitializer::dynlockDestroy);
	}
}
开发者ID:Fangang,项目名称:poco,代码行数:29,代码来源:OpenSSLInitializer.cpp

示例7: CleanupThreadState

CSSLInitializer::~CSSLInitializer()
{
	CleanupThreadState();

#if OPENSSL_VERSION_NUMBER < OPENSSL_VERSION_1_1_0
	CONF_modules_free();
	ENGINE_cleanup();
	EVP_cleanup();
	CRYPTO_cleanup_all_ex_data();
	ERR_free_strings();
	SSL_COMP_free_compression_methods();

	CRYPTO_set_locking_callback			(nullptr);
	CRYPTO_set_dynlock_create_callback	(nullptr);
	CRYPTO_set_dynlock_destroy_callback	(nullptr);
	CRYPTO_set_dynlock_lock_callback	(nullptr);

	if(sm_iLockNum > 0)
	{
		delete[] sm_pcsLocks;

		sm_pcsLocks = nullptr;
		sm_iLockNum = 0;
	}
#endif
}
开发者ID:MarkYangUp,项目名称:HP-Socket,代码行数:26,代码来源:SSLHelper.cpp

示例8: sthreads_init

int sthreads_init(void) {
    int i;

    /* initialize OpenSSL dynamic locks callbacks */
    CRYPTO_set_dynlock_create_callback(dyn_create_function);
    CRYPTO_set_dynlock_lock_callback(dyn_lock_function);
    CRYPTO_set_dynlock_destroy_callback(dyn_destroy_function);

    /* initialize stunnel critical sections */
    for(i=0; i<STUNNEL_LOCKS; i++)
        stunnel_locks[i]=CRYPTO_get_new_dynlockid();

    /* initialize OpenSSL locking callback */
    lock_cs=str_alloc_detached(
        (size_t)CRYPTO_num_locks()*sizeof(struct CRYPTO_dynlock_value));
    for(i=0; i<CRYPTO_num_locks(); i++)
        pthread_rwlock_init(&lock_cs[i].rwlock, NULL);
#if OPENSSL_VERSION_NUMBER>=0x10000000L
    CRYPTO_THREADID_set_callback(threadid_func);
#else
    CRYPTO_set_id_callback(stunnel_thread_id);
#endif
    CRYPTO_set_locking_callback(locking_callback);

    return 0;
}
开发者ID:NickolasLapp,项目名称:stunnel,代码行数:26,代码来源:sthreads.c

示例9: server_initialize_ssl

/*!
 * @brief Initialize the OpenSSL subsystem for use in a multi threaded enviroment.
 * @param transport Pointer to the transport instance.
 * @return Indication of success or failure.
 */
static BOOL server_initialize_ssl(Transport* transport) {
	int i;

	lock_acquire(transport->lock);

	// Begin to bring up the OpenSSL subsystem...
	CRYPTO_malloc_init();
	SSL_load_error_strings();
	SSL_library_init();

	// Setup the required OpenSSL multi-threaded enviroment...
	ssl_locks = malloc(CRYPTO_num_locks() * sizeof(LOCK *));
	if (ssl_locks == NULL) {
			dprintf("[SSL INIT] failed to allocate locks (%d locks)", CRYPTO_num_locks());
		lock_release(transport->lock);
		return FALSE;
	}

	for (i = 0; i < CRYPTO_num_locks(); i++) {
		ssl_locks[i] = lock_create();
	}

	CRYPTO_set_id_callback(server_threadid_callback);
	CRYPTO_set_locking_callback(server_locking_callback);
	CRYPTO_set_dynlock_create_callback(server_dynamiclock_create);
	CRYPTO_set_dynlock_lock_callback(server_dynamiclock_lock);
	CRYPTO_set_dynlock_destroy_callback(server_dynamiclock_destroy);
	lock_release(transport->lock);

	return TRUE;
}
开发者ID:LucaBongiorni,项目名称:metasploit-payloads,代码行数:36,代码来源:server_setup_posix.c

示例10: InitializeTLS

static rfbBool
InitializeTLS(void)
{
  int i;

  if (rfbTLSInitialized) return TRUE;

  mutex_buf = malloc(CRYPTO_num_locks() * sizeof(pthread_mutex_t));
  if (mutex_buf == NULL) {
    rfbClientLog("Failed to initialized OpenSSL: memory.\n");
    return (-1);
  }

  for (i = 0; i < CRYPTO_num_locks(); i++)
    pthread_mutex_init(&mutex_buf[i], NULL);

  CRYPTO_set_locking_callback(locking_function);
  CRYPTO_set_id_callback(id_function);
  CRYPTO_set_dynlock_create_callback(dyn_create_function);
  CRYPTO_set_dynlock_lock_callback(dyn_lock_function);
  CRYPTO_set_dynlock_destroy_callback(dyn_destroy_function);
  SSL_load_error_strings();
  SSLeay_add_ssl_algorithms();
  RAND_load_file("/dev/urandom", 1024);

  rfbClientLog("OpenSSL initialized.\n");
  rfbTLSInitialized = TRUE;
  return TRUE;
}
开发者ID:5victor,项目名称:droidvncserver,代码行数:29,代码来源:tls_openssl.c

示例11: openssl_init_threads

/*
 * Initialize OpenSSL thread support
 *  Returns: 0 on success
 *           errno on failure
 */
int openssl_init_threads (void)
{
   int i, numlocks;
   int status;


   /* Set thread ID callback */
   CRYPTO_set_id_callback(get_openssl_thread_id);

   /* Initialize static locking */
   numlocks = CRYPTO_num_locks();
   mutexes = (pthread_mutex_t *) malloc(numlocks * sizeof(pthread_mutex_t));
   for (i = 0; i < numlocks; i++) {
      if ((status = pthread_mutex_init(&mutexes[i], NULL)) != 0) {
         berrno be;
         Jmsg1(NULL, M_FATAL, 0, _("Unable to init mutex: ERR=%s\n"), be.bstrerror(status));
         return status;
      }
   }

   /* Set static locking callback */
   CRYPTO_set_locking_callback(openssl_update_static_mutex);

   /* Initialize dyanmic locking */
   CRYPTO_set_dynlock_create_callback(openssl_create_dynamic_mutex);
   CRYPTO_set_dynlock_lock_callback(openssl_update_dynamic_mutex);
   CRYPTO_set_dynlock_destroy_callback(openssl_destroy_dynamic_mutex);

   return 0;
}
开发者ID:eneuhauss,项目名称:bareos,代码行数:35,代码来源:openssl.c

示例12: ssl_fini

/*
 * Deinitialize OpenSSL and free as much memory as possible.
 * Some 10k-100k will still remain resident no matter what.
 */
void
ssl_fini(void)
{
	if (!ssl_initialized)
		return;

	ERR_remove_state(0); /* current thread */

#ifdef OPENSSL_THREADS
	CRYPTO_set_locking_callback(NULL);
	CRYPTO_set_dynlock_create_callback(NULL);
	CRYPTO_set_dynlock_lock_callback(NULL);
	CRYPTO_set_dynlock_destroy_callback(NULL);
#ifdef OPENSSL_NO_THREADID
	CRYPTO_set_id_callback(NULL);
#else /* !OPENSSL_NO_THREADID */
	CRYPTO_THREADID_set_callback(NULL);
#endif /* !OPENSSL_NO_THREADID */

	int i;
	for (i = 0; i < ssl_mutex_num; i++) {
		pthread_mutex_destroy(&ssl_mutex[i]);
	}
	free(ssl_mutex);
#endif

	ENGINE_cleanup();
	CONF_modules_finish();
	CONF_modules_unload(1);
	CONF_modules_free();

	EVP_cleanup();
	ERR_free_strings();
	CRYPTO_cleanup_all_ex_data();
}
开发者ID:caidongyun,项目名称:backup,代码行数:39,代码来源:ssl.c

示例13: ssl_util_thread_setup

void ssl_util_thread_setup(apr_pool_t *p)
{
    int i;

    lock_num_locks = CRYPTO_num_locks();
    lock_cs = apr_palloc(p, lock_num_locks * sizeof(*lock_cs));

    for (i = 0; i < lock_num_locks; i++) {
        apr_thread_mutex_create(&(lock_cs[i]), APR_THREAD_MUTEX_DEFAULT, p);
    }

    CRYPTO_set_id_callback(ssl_util_thr_id);

    CRYPTO_set_locking_callback(ssl_util_thr_lock);

    /* Set up dynamic locking scaffolding for OpenSSL to use at its
     * convenience.
     */
    dynlockpool = p;
    CRYPTO_set_dynlock_create_callback(ssl_dyn_create_function);
    CRYPTO_set_dynlock_lock_callback(ssl_dyn_lock_function);
    CRYPTO_set_dynlock_destroy_callback(ssl_dyn_destroy_function);

    apr_pool_cleanup_register(p, NULL, ssl_util_thread_cleanup,
                                       apr_pool_cleanup_null);
}
开发者ID:Aimbot2,项目名称:apache2,代码行数:26,代码来源:ssl_util.c

示例14: ocaml_ssl_init

CAMLprim value ocaml_ssl_init(value use_threads)
{
  int i;

  SSL_library_init();
  SSL_load_error_strings();

  if(Int_val(use_threads))
  {
#ifdef WIN32
    mutex_buf = malloc(CRYPTO_num_locks() * sizeof(HANDLE));
#else
    mutex_buf = malloc(CRYPTO_num_locks() * sizeof(pthread_mutex_t));
#endif
    assert(mutex_buf);
    for (i = 0; i < CRYPTO_num_locks(); i++)
#ifdef WIN32
      mutex_buf[i] = CreateMutex(NULL, FALSE, NULL);
#else
      pthread_mutex_init(&mutex_buf[i], NULL);
#endif
    CRYPTO_set_locking_callback(locking_function);
#ifndef WIN32
    /* Windows does not require id_function, see threads(3) */
    CRYPTO_set_id_callback(id_function);
#endif
    CRYPTO_set_dynlock_create_callback(dyn_create_function);
    CRYPTO_set_dynlock_lock_callback(dyn_lock_function);
    CRYPTO_set_dynlock_destroy_callback(dyn_destroy_function);
  }

  return Val_unit;
}
开发者ID:marcolinoas,项目名称:libres3,代码行数:33,代码来源:ssl_stubs.c

示例15: start

	void start() {
		PlatformSpecific::ThirdParty::start();

		if (!RAND_status()) { // should be always inited in all modern OS
			char buf[16];
			memcpy(buf, &_msStart, 8);
			memcpy(buf + 8, &_msFreq, 8);
			uchar sha256Buffer[32];
			RAND_seed(hashSha256(buf, 16, sha256Buffer), 32);
			if (!RAND_status()) {
				LOG(("MTP Error: Could not init OpenSSL rand, RAND_status() is 0.."));
			}
		}

		int32 numLocks = CRYPTO_num_locks();
		if (numLocks) {
			_sslLocks = new QMutex[numLocks];
			CRYPTO_set_locking_callback(_sslLockingCallback);
		} else {
			LOG(("MTP Error: Could not init OpenSSL threads, CRYPTO_num_locks() returned zero!"));
		}
		CRYPTO_THREADID_set_callback(_sslThreadId);
		CRYPTO_set_dynlock_create_callback(_sslCreateFunction);
		CRYPTO_set_dynlock_lock_callback(_sslLockFunction);
		CRYPTO_set_dynlock_destroy_callback(_sslDestroyFunction);

		av_register_all();
		avcodec_register_all();

		av_lockmgr_register(_ffmpegLockManager);

		_sslInited = true;
	}
开发者ID:hosseindotnet,项目名称:tdesktop,代码行数:33,代码来源:types.cpp


注:本文中的CRYPTO_set_dynlock_lock_callback函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。