• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ CRYPTO_set_locking_callback函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: THREAD_cleanup

int THREAD_cleanup(void)
{
  int i;

  if (!mutex_buf)
    return 0;

  CRYPTO_set_id_callback(NULL);
  CRYPTO_set_locking_callback(NULL);
  
  for (i = 0; i < CRYPTO_num_locks(); i++) {
    MUTEX_CLEANUP(mutex_buf[i]);
  }
  free(mutex_buf);
  mutex_buf = NULL;
  return 1;
}
开发者ID:wdli,项目名称:NPU,代码行数:17,代码来源:ssl_common.c


示例2: curl_global_init

void LLCurl::initClass()
{
	// Do not change this "unless you are familiar with and mean to control 
	// internal operations of libcurl"
	// - http://curl.haxx.se/libcurl/c/curl_global_init.html
	curl_global_init(CURL_GLOBAL_ALL);
	
#if SAFE_SSL
	S32 mutex_count = CRYPTO_num_locks();
	for (S32 i=0; i<mutex_count; i++)
	{
		sSSLMutex.push_back(new LLMutex(gAPRPoolp));
	}
	CRYPTO_set_id_callback(&LLCurl::ssl_thread_id);
	CRYPTO_set_locking_callback(&LLCurl::ssl_locking_callback);
#endif
}
开发者ID:Krazy-Bish-Margie,项目名称:sl-viewer-source-archive,代码行数:17,代码来源:llcurl.cpp


示例3: start

	void start() {
		Platform::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..."));
			}
		}

		// Force OpenSSL loading if it is linked in Qt,
		// so that we won't mess with our OpenSSL locking with Qt OpenSSL locking.
		auto sslSupported = QSslSocket::supportsSsl();
		if (!sslSupported) {
			LOG(("Error: current Qt build doesn't support SSL requests."));
		}
		if (!CRYPTO_get_locking_callback()) {
			// Qt didn't initialize OpenSSL, so we will.
			auto 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);
		}
		if (!CRYPTO_get_dynlock_create_callback()) {
			CRYPTO_set_dynlock_create_callback(_sslCreateFunction);
			CRYPTO_set_dynlock_lock_callback(_sslLockFunction);
			CRYPTO_set_dynlock_destroy_callback(_sslDestroyFunction);
		} else if (!CRYPTO_get_dynlock_lock_callback()) {
			LOG(("MTP Error: dynlock_create callback is set without dynlock_lock callback!"));
		}

		av_register_all();
		avcodec_register_all();

		av_lockmgr_register(_ffmpegLockManager);

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


示例4: tls_init_locks

/* returns -1 on error, 0 on success */
int tls_init_locks()
{
	/* init "static" tls locks */
	n_static_locks=CRYPTO_num_locks();
	if (n_static_locks<0){
		LOG(L_CRIT, "BUG: tls: tls_init_locking: bad CRYPTO_num_locks %d\n",
					n_static_locks);
		n_static_locks=0;
	}
	if (n_static_locks){
		static_locks=lock_set_alloc(n_static_locks);
		if (static_locks==0){
			LOG(L_CRIT, "ERROR: tls_init_locking: could not allocate lockset"
					" with %d locks\n", n_static_locks);
			goto error;
		}
		if (lock_set_init(static_locks)==0){
			LOG(L_CRIT, "ERROR: tls_init_locking: lock_set_init failed "
					"(%d locks)\n", n_static_locks);
			lock_set_dealloc(static_locks);
			static_locks=0;
			n_static_locks=0;
			goto error;
		}
		CRYPTO_set_locking_callback(locking_f);
	}
	/* set "dynamic" locks callbacks */
	CRYPTO_set_dynlock_create_callback(dyn_create_f);
	CRYPTO_set_dynlock_lock_callback(dyn_lock_f);
	CRYPTO_set_dynlock_destroy_callback(dyn_destroy_f);
	
	/* thread id callback: not needed because ser doesn't use thread and
	 * openssl already uses getpid() (by default)
	 * CRYPTO_set_id_callback(id_f);
	 */
	/* atomic add -- since for now we don't have atomic_add
	 *  (only atomic_inc), fallback to the default use-locks mode
	 * CRYPTO_set_add_lock_callback(atomic_add_f);
	 */
	
	
	return 0;
error:
	tls_destroy_locks();
	return -1;
}
开发者ID:Gaoithe,项目名称:openimscore_ims,代码行数:47,代码来源:tls_locking.c


示例5: SetupOpenSSLThreadLocks

static void SetupOpenSSLThreadLocks(void)
{
#if defined(HAVE_PTHREAD)
    const int numLocks = CRYPTO_num_locks();
    cf_openssl_locks = OPENSSL_malloc(numLocks * sizeof(pthread_mutex_t));

    for (int i = 0; i < numLocks; i++)
    {
        pthread_mutex_init(&(cf_openssl_locks[i]),NULL);
    }

#ifndef __MINGW32__
    CRYPTO_set_id_callback((unsigned long (*)())ThreadId_callback);
#endif
    CRYPTO_set_locking_callback((void (*)())OpenSSLLock_callback);
#endif
}
开发者ID:cduclos,项目名称:core,代码行数:17,代码来源:crypto.c


示例6: torque_stop_ssl

int torque_stop_ssl(void){
	int ret = 0;
	unsigned z;

	RAND_cleanup();
	CRYPTO_set_locking_callback(NULL);
	CRYPTO_set_id_callback(NULL);
	for(z = 0 ; z < numlocks ; ++z){
		if(pthread_mutex_destroy(&openssl_locks[z])){
			ret = -1;
		}
	}
	numlocks = 0;
	free(openssl_locks);
	openssl_locks = NULL;
	return ret;
}
开发者ID:dankamongmen,项目名称:libtorque,代码行数:17,代码来源:ssl.c


示例7: CRYPTO_thread_setup

void CRYPTO_thread_setup(void)
{
    int i;

    syslog(LOG_DEBUG, "Setting up pthreads TLS.");

    lock_cs = OPENSSL_malloc(CRYPTO_num_locks() * sizeof(pthread_mutex_t));
    lock_count = OPENSSL_malloc(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);
}
开发者ID:JensErat,项目名称:cyrus-imapd,代码行数:17,代码来源:tls_th-lock.c


示例8: sthreads_init

void 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 */
    for(i=0; i<CRYPTO_NUM_LOCKS; i++)
        pthread_mutex_init(lock_cs+i, NULL);
    CRYPTO_set_id_callback(stunnel_thread_id);
    CRYPTO_set_locking_callback(locking_callback);

    pthread_attr_init(&pth_attr);
    pthread_attr_setdetachstate(&pth_attr, PTHREAD_CREATE_DETACHED);
    pthread_attr_setstacksize(&pth_attr, STACK_SIZE);
}
开发者ID:djs55,项目名称:stunnel,代码行数:17,代码来源:sthreads.c


示例9: sdns_openssl_lock_init

int sdns_openssl_lock_init(void)
{
    int i;
    sdns_openssl_locks = (lock_basic_t*)malloc(
        sizeof(lock_basic_t)*CRYPTO_num_locks());
    if(!sdns_openssl_locks)
        return 0;
    for(i=0; i<CRYPTO_num_locks(); i++) {
        lock_basic_init(&sdns_openssl_locks[i]);
    }

    //openssl 1.0.0 CRYPTO_set_id_callback was replaced by CRYPTO_THREADID_set_callback
    openssl_set_id_callback(sdns_openssl_id_cb);

    CRYPTO_set_locking_callback(&sdns_openssl_lock_cb);
    return 1;
}
开发者ID:xiexiaohui,项目名称:snail-c,代码行数:17,代码来源:locks.c


示例10: THREAD_setup

int THREAD_setup(void) {
	int i;

	mutex_buf = (MUTEX_TYPE *) malloc(CRYPTO_num_locks() * sizeof(MUTEX_TYPE));
	if(!mutex_buf) {
		return 0; 
	}

	for(i = 0; i < CRYPTO_num_locks(); i++) {
		MUTEX_SETUP(mutex_buf[i]);
	}

	CRYPTO_set_id_callback(id_function);
	CRYPTO_set_locking_callback(locking_function);

	return 1;
}
开发者ID:modsix,项目名称:destroyd,代码行数:17,代码来源:common.c


示例11: ff_openssl_deinit

void ff_openssl_deinit(void)
{
    avpriv_lock_avformat();
    openssl_init--;
    if (!openssl_init) {
#if HAVE_THREADS
        if (CRYPTO_get_locking_callback() == openssl_lock) {
            int i;
            CRYPTO_set_locking_callback(NULL);
            for (i = 0; i < CRYPTO_num_locks(); i++)
                pthread_mutex_destroy(&openssl_mutexes[i]);
            av_free(openssl_mutexes);
        }
#endif
    }
    avpriv_unlock_avformat();
}
开发者ID:AVLeo,项目名称:libav,代码行数:17,代码来源:tls_openssl.c


示例12: SSLSocket_initialize

int SSLSocket_initialize()
{
	int rc = 0;
	/*int prc;*/
	int i;
	int lockMemSize;

	FUNC_ENTRY;

	if ((rc = SSL_library_init()) != 1)
		rc = -1;

	ERR_load_crypto_strings();
	SSL_load_error_strings();

	/* OpenSSL 0.9.8o and 1.0.0a and later added SHA2 algorithms to SSL_library_init().
	Applications which need to use SHA2 in earlier versions of OpenSSL should call
	OpenSSL_add_all_algorithms() as well. */

	OpenSSL_add_all_algorithms();

	lockMemSize = CRYPTO_num_locks() * sizeof(ssl_mutex_type);

	sslLocks = malloc(lockMemSize);
	if (!sslLocks)
	{
		rc = -1;
		goto exit;
	}
	else
		memset(sslLocks, 0, lockMemSize);

	for (i = 0; i < CRYPTO_num_locks(); i++)
	{
		/* prc = */SSL_create_mutex(&sslLocks[i]);
	}

	CRYPTO_THREADID_set_callback(SSLThread_id);
	CRYPTO_set_locking_callback(SSLLocks_callback);

	SSL_create_mutex(&sslCoreMutex);

exit:
	FUNC_EXIT_RC(rc);
	return rc;
}
开发者ID:brc859844,项目名称:paho.mqtt.c,代码行数:46,代码来源:SSLSocket.c


示例13: debug

void TlsSocket::Init()
{
	debug("Initializing TLS library");

#ifdef HAVE_LIBGNUTLS
	int error_code;

#ifdef NEED_GCRYPT_LOCKING
	error_code = gcry_control(GCRYCTL_SET_THREAD_CBS, &gcry_threads_Mutex);
	if (error_code != 0)
	{
		error("Could not initialize libcrypt");
		return;
	}
#endif /* NEED_GCRYPT_LOCKING */

	error_code = gnutls_global_init();
	if (error_code != 0)
	{
		error("Could not initialize libgnutls");
		return;
	}

#endif /* HAVE_LIBGNUTLS */

#ifdef HAVE_OPENSSL
	for (int i = 0, num = CRYPTO_num_locks(); i < num; i++)
	{
		g_OpenSSLMutexes.emplace_back(std::make_unique<Mutex>());
	}

	SSL_load_error_strings();
	SSL_library_init();
	OpenSSL_add_all_algorithms();

	CRYPTO_set_locking_callback(openssl_locking);
	//CRYPTO_set_id_callback(openssl_thread_id);
	CRYPTO_set_dynlock_create_callback(openssl_dynlock_create);
	CRYPTO_set_dynlock_destroy_callback(openssl_dynlock_destroy);
	CRYPTO_set_dynlock_lock_callback(openssl_dynlock_lock);

#endif /* HAVE_OPENSSL */

	m_tlsSocketFinalizer = std::make_unique<TlsSocketFinalizer>();
}
开发者ID:outtahere,项目名称:nzbget,代码行数:45,代码来源:TlsSocket.cpp


示例14: neo4j_openssl_init

int neo4j_openssl_init(void)
{
    SSL_library_init();
    SSL_load_error_strings();
    ERR_load_BIO_strings();
    OpenSSL_add_all_algorithms();

    int num_locks = CRYPTO_num_locks();
    thread_locks = calloc(num_locks, sizeof(neo4j_mutex_t));
    if (thread_locks == NULL)
    {
        return -1;
    }

    for (int i = 0; i < num_locks; i++)
    {
        int err = neo4j_mutex_init(&(thread_locks[i]));
        if (err)
        {
            for (; i > 0; --i)
            {
                neo4j_mutex_destroy(&(thread_locks[i-1]));
            }
            free(thread_locks);
            errno = err;
            return -1;
        }
    }

    if (CRYPTO_get_locking_callback() == NULL)
    {
        CRYPTO_set_locking_callback(locking_callback);
        CRYPTO_set_id_callback(neo4j_current_thread_id);
    }

    SSL_CTX *ctx = SSL_CTX_new(TLSv1_method());
    if (ctx == NULL)
    {
        errno = openssl_error(NULL, NEO4J_LOG_ERROR, __FILE__, __LINE__);
        return -1;
    }
    SSL_CTX_free(ctx);

    return 0;
}
开发者ID:Dan-McG,项目名称:libneo4j-client,代码行数:45,代码来源:openssl.c


示例15: _winpr_openssl_cleanup_locking

static BOOL _winpr_openssl_cleanup_locking(void)
{
	/* undo our static locking modifications */
	if (CRYPTO_get_locking_callback() == _winpr_openssl_locking)
	{
		int i;
		CRYPTO_set_locking_callback(NULL);

		for (i = 0; i < g_winpr_openssl_num_locks; i++)
		{
			CloseHandle(g_winpr_openssl_locks[i]);
		}

		g_winpr_openssl_num_locks = 0;
		free(g_winpr_openssl_locks);
		g_winpr_openssl_locks = NULL;
	}

	/* unset our dynamic locking callbacks */

	if (CRYPTO_get_dynlock_create_callback() == _winpr_openssl_dynlock_create)
	{
		CRYPTO_set_dynlock_create_callback(NULL);
	}

	if (CRYPTO_get_dynlock_lock_callback() == _winpr_openssl_dynlock_lock)
	{
		CRYPTO_set_dynlock_lock_callback(NULL);
	}

	if (CRYPTO_get_dynlock_destroy_callback() == _winpr_openssl_dynlock_destroy)
	{
		CRYPTO_set_dynlock_destroy_callback(NULL);
	}

#if (OPENSSL_VERSION_NUMBER < 0x10000000L)

	if (CRYPTO_get_id_callback() == _winpr_openssl_id)
	{
		CRYPTO_set_id_callback(NULL);
	}

#endif
	return TRUE;
}
开发者ID:dcatonR1,项目名称:FreeRDP,代码行数:45,代码来源:ssl.c


示例16: dst__openssl_destroy

void
dst__openssl_destroy(void) {
	/*
	 * Sequence taken from apps_shutdown() in <apps/apps.h>.
	 */
	if (rm != NULL) {
#if OPENSSL_VERSION_NUMBER >= 0x00907000L
		RAND_cleanup();
#endif
		mem_free(rm);
		rm = NULL;
	}
#if (OPENSSL_VERSION_NUMBER >= 0x00907000L)
	CONF_modules_free();
#endif
	OBJ_cleanup();
	EVP_cleanup();
#if defined(USE_ENGINE)
	if (e != NULL)
		ENGINE_free(e);
	e = NULL;
#if defined(USE_ENGINE) && OPENSSL_VERSION_NUMBER >= 0x00907000L
	ENGINE_cleanup();
#endif
#endif
#if (OPENSSL_VERSION_NUMBER >= 0x00907000L)
	CRYPTO_cleanup_all_ex_data();
#endif
	ERR_clear_error();
#if OPENSSL_VERSION_NUMBER < 0x10100000L
	ERR_remove_state(0);
#endif
	ERR_free_strings();

#ifdef  DNS_CRYPTO_LEAKS
	CRYPTO_mem_leaks_fp(stderr);
#endif

	if (locks != NULL) {
		CRYPTO_set_locking_callback(NULL);
		DESTROYMUTEXBLOCK(locks, nlocks);
		mem_free(locks);
		locks = NULL;
	}
}
开发者ID:edmonds,项目名称:isc-bind9,代码行数:45,代码来源:openssl_link.c


示例17: internal_idevice_init

static void internal_idevice_init(void)
{
#ifdef HAVE_OPENSSL
	int i;
	SSL_library_init();

	mutex_buf = (mutex_t*)malloc(CRYPTO_num_locks() * sizeof(mutex_t));
	if (!mutex_buf)
		return;
	for (i = 0; i < CRYPTO_num_locks(); i++)
		mutex_init(&mutex_buf[i]);

	CRYPTO_set_id_callback(id_function);
	CRYPTO_set_locking_callback(locking_function);
#else
	gnutls_global_init();
#endif
}
开发者ID:HSHtime,项目名称:libiphone,代码行数:18,代码来源:idevice.c


示例18: neo4j_openssl_cleanup

int neo4j_openssl_cleanup(void)
{
    if (CRYPTO_get_locking_callback() == locking_callback)
    {
        CRYPTO_set_locking_callback(NULL);
        CRYPTO_set_id_callback(NULL);
    }

    int num_locks = CRYPTO_num_locks();
    for (int i = 0; i < num_locks; i++)
    {
        neo4j_mutex_destroy(&(thread_locks[i]));
    }
    free(thread_locks);

    EVP_cleanup();
    return 0;
}
开发者ID:Dan-McG,项目名称:libneo4j-client,代码行数:18,代码来源:openssl.c


示例19: seafile_curl_init

void seafile_curl_init()
{
    int i;
    curl_locks = malloc (sizeof(pthread_mutex_t) * CRYPTO_num_locks());
    for (i = 0; i < CRYPTO_num_locks(); ++i) {
        pthread_mutex_init (&curl_locks[i], NULL);
    }

#ifndef WIN32
    /* On Windows it's better to use the default id_function.
     * As per http://linux.die.net/man/3/crypto_set_id_callback,
     * the default id_functioin uses system's default thread
     * identifying API.
     */
    CRYPTO_set_id_callback (pthread_self);
#endif
    CRYPTO_set_locking_callback (seafile_curl_locking_callback);
}
开发者ID:atriwidada,项目名称:seafile,代码行数:18,代码来源:curl-init.c


示例20: mstoneSslInit

/* Do any extra initialization related to ssl
 */
void
mstoneSslInit(void)
{
#ifdef USE_PTHREADS
  int n;
  num_locks = CRYPTO_num_locks();
  locks = xcalloc(num_locks * sizeof(*locks));
  for (n = 0; n < num_locks; n++) {
    if (pthread_mutex_init(&locks[n], NULL)) {
      returnerr(stderr, "Failed to initialize mutex %d\n", n);
    }
  }
  CRYPTO_set_id_callback(thread_id);
  CRYPTO_set_locking_callback(thread_lock);
  D_PRINTF(stderr, "Initialized SSL for threading\n");

#endif /* USE_PTHREADS */
}
开发者ID:thomoco,项目名称:mstone,代码行数:20,代码来源:ssl.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ CRYPTO_thread_id函数代码示例发布时间:2022-05-30
下一篇:
C++ CRYPTO_set_id_callback函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap