本文整理汇总了C++中CRYPTO_set_id_callback函数的典型用法代码示例。如果您正苦于以下问题:C++ CRYPTO_set_id_callback函数的具体用法?C++ CRYPTO_set_id_callback怎么用?C++ CRYPTO_set_id_callback使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CRYPTO_set_id_callback函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: ff_tls_init
void ff_tls_init(void)
{
avpriv_lock_avformat();
#if CONFIG_OPENSSL
if (!openssl_init) {
SSL_library_init();
SSL_load_error_strings();
#if HAVE_THREADS
if (!CRYPTO_get_locking_callback()) {
int i;
openssl_mutexes = av_malloc_array(sizeof(pthread_mutex_t), CRYPTO_num_locks());
for (i = 0; i < CRYPTO_num_locks(); i++)
pthread_mutex_init(&openssl_mutexes[i], NULL);
CRYPTO_set_locking_callback(openssl_lock);
#if !defined(WIN32) && OPENSSL_VERSION_NUMBER < 0x10000000
CRYPTO_set_id_callback(openssl_thread_id);
#endif
}
#endif
}
openssl_init++;
#endif
#if CONFIG_GNUTLS
#if HAVE_THREADS && GNUTLS_VERSION_NUMBER < 0x020b00
if (gcry_control(GCRYCTL_ANY_INITIALIZATION_P) == 0)
gcry_control(GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread);
#endif
gnutls_global_init();
#endif
avpriv_unlock_avformat();
}
开发者ID:AlphaPerfect,项目名称:FFmpeg,代码行数:31,代码来源:network.c
示例2: CRYPTO_thread_setup
void CRYPTO_thread_setup (void)
{
int i;
char filename[20];
strcpy (filename, "/tmp/mttest.XXXXXX");
mktemp (filename);
usconfig (CONF_STHREADIOOFF);
usconfig (CONF_STHREADMALLOCOFF);
usconfig (CONF_INITUSERS, 100);
usconfig (CONF_LOCKTYPE, US_DEBUGPLUS);
arena = usinit (filename);
unlink (filename);
lock_cs = OPENSSL_malloc (CRYPTO_num_locks () * sizeof (usema_t *));
for (i = 0; i < CRYPTO_num_locks (); i++)
{
lock_cs[i] = usnewsema (arena, 1);
}
CRYPTO_set_id_callback ((unsigned long (*)()) irix_thread_id);
CRYPTO_set_locking_callback ((void (*)()) irix_locking_callback);
}
开发者ID:274914765,项目名称:C,代码行数:25,代码来源:th-lock.c
示例3: 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:BrianHoldsworth,项目名称:Poco,代码行数:29,代码来源:OpenSSLInitializer.cpp
示例4: server_initialize_ssl
/*
* Initialize the OpenSSL subsystem for use in a multi threaded enviroment.
*/
static BOOL server_initialize_ssl( Remote * remote )
{
int i = 0;
lock_acquire( remote->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 = (LOCK**)malloc( CRYPTO_num_locks() * sizeof(LOCK *) );
if( ssl_locks == NULL )
{
lock_release( remote->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( remote->lock );
return TRUE;
}
开发者ID:anitha2012,项目名称:evandrix.github.com,代码行数:35,代码来源:server_setup.c
示例5: 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:anitha2012,项目名称:evandrix.github.com,代码行数:33,代码来源:server_setup.c
示例6: 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 */
for (int 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:0x0mar,项目名称:sslsplit,代码行数:37,代码来源:ssl.c
示例7: SetupOpenSSLThreadLocks
static void SetupOpenSSLThreadLocks(void)
{
const int num_locks = CRYPTO_num_locks();
assert(cf_openssl_locks == NULL);
cf_openssl_locks = xmalloc(num_locks * sizeof(*cf_openssl_locks));
for (int i = 0; i < num_locks; i++)
{
pthread_mutexattr_t attr;
pthread_mutexattr_init(&attr);
int ret = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK);
if (ret != 0)
{
Log(LOG_LEVEL_ERR,
"Failed to use error-checking mutexes for openssl,"
" falling back to normal ones (pthread_mutexattr_settype: %s)",
GetErrorStrFromCode(ret));
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_NORMAL);
}
ret = pthread_mutex_init(&cf_openssl_locks[i], &attr);
if (ret != 0)
{
Log(LOG_LEVEL_CRIT,
"Failed to use initialise mutexes for openssl"
" (pthread_mutex_init: %s)!",
GetErrorStrFromCode(ret));
}
pthread_mutexattr_destroy(&attr);
}
#ifndef __MINGW32__
CRYPTO_set_id_callback((unsigned long (*)())ThreadId_callback);
#endif
CRYPTO_set_locking_callback((void (*)())OpenSSLLock_callback);
}
开发者ID:lra,项目名称:core,代码行数:35,代码来源:crypto.c
示例8: main
int main(int argc, char **argv)
{
int i;
pthread_t thread1, thread2, thread3, thread4;
int iret1, iret2, iret3, iret4;
start = time(NULL);
signal(SIGUSR2, sig_handler);
/* setup for openssl to handle multithreading
code taken from 'the definitive guide to linux network programming, pages 250ish*/
mutex_buffer = (pthread_mutex_t *) malloc(CRYPTO_num_locks() * sizeof(pthread_mutex_t));
for(i=0; i<CRYPTO_num_locks(); i++)
pthread_mutex_init(&mutex_buffer[i],NULL);
CRYPTO_set_id_callback(thread_id_function);
CRYPTO_set_locking_callback(locking_function);
/* each thread searches quarter the space, split on the first character of the message */
iret1 = pthread_create( &thread1, NULL, fun1, NULL);
iret2 = pthread_create( &thread2, NULL, fun2, NULL);
iret3 = pthread_create( &thread3, NULL, fun3, NULL);
iret4 = pthread_create( &thread4, NULL, fun4, NULL);
pthread_join( thread1, NULL);
pthread_join( thread2, NULL);
pthread_join( thread3, NULL);
pthread_join( thread4, NULL);
return 0;
}
开发者ID:dval9,项目名称:school,代码行数:25,代码来源:p5pthread4.c
示例9: pthread_mutex_lock
void SSLSupport::init(void)
{
pthread_mutex_lock(&s_initLock);
if (s_initCounter) {
//already inited, exit
pthread_mutex_unlock(&s_initLock);
return;
}
++s_initCounter;
SSL_load_error_strings(); /* readable error messages */
SSL_library_init(); /* initialize library */
OpenSSL_add_all_ciphers();
OpenSSL_add_all_digests();
ERR_load_crypto_strings();
s_nLocks = CRYPTO_num_locks();
s_mutexArray = (pthread_mutex_t*) OPENSSL_malloc(s_nLocks * sizeof(pthread_mutex_t));
for (int i = 0; i < s_nLocks; i++)
{
pthread_mutex_init(&s_mutexArray[i], NULL);
}
CRYPTO_set_id_callback(getThreadID);
CRYPTO_set_locking_callback(lock);
pthread_mutex_unlock(&s_initLock);
}
开发者ID:dkirker,项目名称:BrowserServer,代码行数:29,代码来源:SSLSupport.cpp
示例10: tls_init_multithread
static int tls_init_multithread(void)
{
/* init static locks support */
tls_static_locks_no = CRYPTO_num_locks();
if (tls_static_locks_no>0) {
/* init a lock set & pass locking function to SSL */
tls_static_locks = lock_set_alloc(tls_static_locks_no);
if (tls_static_locks == NULL) {
LM_ERR("Failed to alloc static locks\n");
return -1;
}
if (lock_set_init(tls_static_locks)==0) {
LM_ERR("Failed to init static locks\n");
lock_set_dealloc(tls_static_locks);
return -1;
}
CRYPTO_set_locking_callback(tls_static_locks_ops);
}
CRYPTO_set_id_callback(tls_get_id);
/* dynamic locks support*/
CRYPTO_set_dynlock_create_callback(tls_dyn_lock_create);
CRYPTO_set_dynlock_lock_callback(tls_dyn_lock_ops);
CRYPTO_set_dynlock_destroy_callback(tls_dyn_lock_destroy);
return 0;
}
开发者ID:Parantido,项目名称:opensips,代码行数:29,代码来源:tls_mgm.c
示例11: 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:Genomicsplc,项目名称:apache2,代码行数:26,代码来源:ssl_util.c
示例12: CRYPTO_malloc_debug_init
CSSLApplication::CSSLApplication()
{
if (SSLInited) return;
SSLInited = 1;
NeedDataOp = 0;
#ifdef _DEBUG
// OpenSSL internal memory-leak checkers
CRYPTO_malloc_debug_init();
CRYPTO_dbg_set_options(V_CRYPTO_MDEBUG_ALL);
CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
#endif
openssl_locks = new Synchronizer[CRYPTO_num_locks()];
// callbacks for static lock
CRYPTO_set_locking_callback(funcOpenSSLLockingCallback);
CRYPTO_set_id_callback(funcOpenSSLIDCallback);
// callbacks for dynamic lock
CRYPTO_set_dynlock_create_callback(funcOpenSSLDynCreateCallback);
CRYPTO_set_dynlock_destroy_callback(funcOpenSSLDynDestroyCallback);
CRYPTO_set_dynlock_lock_callback(funcOpenSSLDynLockCallback);
// Load algorithms and error strings.
SSL_load_error_strings();
SSL_library_init();
};
开发者ID:RaymonSHan,项目名称:learning,代码行数:28,代码来源:SSLApplication.cpp
示例13: setup_ssl_mutexes
static int setup_ssl_mutexes(void)
{
int i;
#ifdef HAVE_OPENSSL_EVP_H
/*
* Enable all ciphers and digests.
*/
OpenSSL_add_all_algorithms();
#endif
ssl_mutexes = rad_malloc(CRYPTO_num_locks() * sizeof(pthread_mutex_t));
if (!ssl_mutexes) {
radlog(L_ERR, "Error allocating memory for SSL mutexes!");
return 0;
}
for (i = 0; i < CRYPTO_num_locks(); i++) {
pthread_mutex_init(&(ssl_mutexes[i]), NULL);
}
CRYPTO_set_id_callback(ssl_id_function);
CRYPTO_set_locking_callback(ssl_locking_function);
return 1;
}
开发者ID:Antti,项目名称:freeradius-server,代码行数:26,代码来源:threads.c
示例14: _ossSSLTheadInit
static INT32 _ossSSLTheadInit()
{
INT32 i;
INT32 ret = SSL_OK;
_ossSSLThreadLocks = (ossMutex*)OPENSSL_malloc(CRYPTO_num_locks() * sizeof(ossMutex));
if (NULL == _ossSSLThreadLocks)
{
goto error;
}
for (i = 0; i < CRYPTO_num_locks(); i++)
{
ossMutexInit(&_ossSSLThreadLocks[i]);
}
/* set OpenSSL multithreading callbacks */
CRYPTO_set_id_callback(_ossSSLThreadIdCallback);
CRYPTO_set_locking_callback(_ossSSLThreadLockingCallback);
done:
return ret;
error:
ret = SSL_ERROR;
goto done;
}
开发者ID:Andrew8305,项目名称:SequoiaDB,代码行数:26,代码来源:ossSSLWrapper.c
示例15: SSL_library_init
bool CSSLClient::Initial(unsigned long encryptionType)
{
//初始SSL
s_Lock.Lock();
if (0 == s_objectCount)
{
SSL_library_init();
const SSL_METHOD * pSSLMethod = NULL;
if (TVT_ENCRYPTION_SSL == encryptionType)
{
pSSLMethod = TLSv1_client_method();
}
else if(TVT_ENCRYPTION_TLS == encryptionType)
{
pSSLMethod = SSLv3_client_method();
}
SSL_load_error_strings();
s_SSLCTX = SSL_CTX_new(pSSLMethod);
if(NULL == s_SSLCTX)
{
int errNum = ERR_get_error();
printf("%s:%s:%d, ssl connect error:%s\n", __FUNCTION__, __FILE__, __LINE__, ERR_reason_error_string(errNum));
printf("%s:%s:%d, error function=%s\n", __FUNCTION__, __FILE__, __LINE__, ERR_func_error_string(errNum));
s_Lock.UnLock();
return false;
}
/* if (SSL_CTX_use_certificate_file(s_SSLCTX, CA_CERT_FILE, SSL_FILETYPE_PEM) <= 0)
{
printf("Error: %s\n", ERR_reason_error_string(ERR_get_error()));
s_Lock.UnLock();
return false;
}
if (SSL_CTX_use_PrivateKey_file_pass(s_SSLCTX, CA_KEY_FILE, "123456") <= 0)
{
printf("use_PrivateKey_file err\n");
s_Lock.UnLock();
return false;
}
*/
for (int i=0; i < CRYPTO_num_locks(); ++i)
{
CPUB_Lock *pLock = new CPUB_Lock;
s_vecLock.push_back(pLock);
}
CRYPTO_set_id_callback(GetThreadId);
CRYPTO_set_locking_callback(pthreads_locking_callback);
s_bHasInitial = true;
}
s_objectCount++;
s_Lock.UnLock();
return true;
}
开发者ID:dulton,项目名称:proxy,代码行数:59,代码来源:SSLClient.cpp
示例16: set_ssl_option
// Dynamically load SSL library. Set up ctx->ssl_ctx pointer.
static int set_ssl_option(struct mg_context *ctx) {
int i, size;
const char *pem;
// If PEM file is not specified and the init_ssl callback
// is not specified, skip SSL initialization.
if ((pem = ctx->config[SSL_CERTIFICATE]) == NULL) {
// MG_INIT_SSL
// ctx->callbacks.init_ssl == NULL) {
return 1;
}
#if !defined(NO_SSL_DL)
if (!load_dll(ctx, SSL_LIB, ssl_sw) ||
!load_dll(ctx, CRYPTO_LIB, crypto_sw)) {
return 0;
}
#endif // NO_SSL_DL
// Initialize SSL library
SSL_library_init();
SSL_load_error_strings();
if ((ctx->ssl_ctx = SSL_CTX_new(SSLv23_server_method())) == NULL) {
cry(fc(ctx), "SSL_CTX_new (server) error: %s", ssl_error());
return 0;
}
// If user callback returned non-NULL, that means that user callback has
// set up certificate itself. In this case, skip sertificate setting.
// MG_INIT_SSL
if (SSL_CTX_use_certificate_file(ctx->ssl_ctx, pem, 1) == 0 ||
SSL_CTX_use_PrivateKey_file(ctx->ssl_ctx, pem, 1) == 0) {
cry(fc(ctx), "%s: cannot open %s: %s", __func__, pem, ssl_error());
return 0;
}
if (pem != NULL) {
(void) SSL_CTX_use_certificate_chain_file(ctx->ssl_ctx, pem);
}
// Initialize locking callbacks, needed for thread safety.
// http://www.openssl.org/support/faq.html#PROG1
size = sizeof(pthread_mutex_t) * CRYPTO_num_locks();
if ((ssl_mutexes = (pthread_mutex_t *) malloc((size_t)size)) == NULL) {
cry(fc(ctx), "%s: cannot allocate mutexes: %s", __func__, ssl_error());
return 0;
}
for (i = 0; i < CRYPTO_num_locks(); i++) {
pthread_mutex_init(&ssl_mutexes[i], NULL);
}
CRYPTO_set_locking_callback(&ssl_locking_callback);
CRYPTO_set_id_callback(&ssl_id_callback);
return 1;
}
开发者ID:Andersbakken,项目名称:mongoose,代码行数:59,代码来源:ssl.c
示例17: init_locks
static void init_locks(void)
{
int i;
lockarray = (pthread_mutex_t*) OPENSSL_malloc(CRYPTO_num_locks() * sizeof(pthread_mutex_t));
for (i = 0; i < CRYPTO_num_locks(); i++)
pthread_mutex_init(&(lockarray[i]), NULL);
CRYPTO_set_id_callback((unsigned long (*)()) thread_id);
CRYPTO_set_locking_callback((void (*)()) lock_callback);
}
开发者ID:bensteinfeld,项目名称:john-the-ripper,代码行数:9,代码来源:rar_fmt.c
示例18: assert
void SSLInit::Init() {
assert(!s_isSSLInited);
s_locks = new Mutex[CRYPTO_num_locks()];
CRYPTO_set_id_callback((unsigned long (*)())callback_thread_id);
CRYPTO_set_locking_callback(
(void (*)(int mode, int type, const char *file, int line))
callback_locking);
s_isSSLInited = true;
}
开发者ID:anthonyattard,项目名称:hhvm,代码行数:9,代码来源:ssl-init.cpp
示例19: mprSslInit
/*
Initialize the MPR SSL layer
*/
PUBLIC int mprSslInit(void *unused, MprModule *module)
{
RandBuf randBuf;
int i;
randBuf.now = mprGetTime();
randBuf.pid = getpid();
RAND_seed((void*) &randBuf, sizeof(randBuf));
#if ME_UNIX_LIKE
RAND_load_file("/dev/urandom", 256);
#endif
if ((openProvider = mprAllocObj(MprSocketProvider, manageOpenProvider)) == NULL) {
return MPR_ERR_MEMORY;
}
openProvider->name = sclone("openssl");
openProvider->upgradeSocket = upgradeOss;
openProvider->closeSocket = closeOss;
openProvider->disconnectSocket = disconnectOss;
openProvider->flushSocket = flushOss;
openProvider->socketState = getOssState;
openProvider->readSocket = readOss;
openProvider->writeSocket = writeOss;
mprSetSslProvider(openProvider);
/*
Configure the SSL library. Use the crypto ID as a one-time test. This allows
users to configure the library and have their configuration used instead.
*/
mprGlobalLock();
if (CRYPTO_get_id_callback() == 0) {
numLocks = CRYPTO_num_locks();
if ((olocks = mprAlloc(numLocks * sizeof(MprMutex*))) == 0) {
return MPR_ERR_MEMORY;
}
for (i = 0; i < numLocks; i++) {
olocks[i] = mprCreateLock();
}
CRYPTO_set_id_callback(sslThreadId);
CRYPTO_set_locking_callback(sslStaticLock);
CRYPTO_set_dynlock_create_callback(sslCreateDynLock);
CRYPTO_set_dynlock_destroy_callback(sslDestroyDynLock);
CRYPTO_set_dynlock_lock_callback(sslDynLock);
#if !ME_WIN_LIKE
OpenSSL_add_all_algorithms();
#endif
/*
WARNING: SSL_library_init() is not reentrant. Caller must ensure safety.
*/
SSL_library_init();
SSL_load_error_strings();
}
mprGlobalUnlock();
return 0;
}
开发者ID:leemit,项目名称:ejscript,代码行数:59,代码来源:mpr-openssl.c
示例20: tlso_thr_init
static void tlso_thr_init( void )
{
int i;
for( i=0; i< CRYPTO_NUM_LOCKS ; i++ ) {
ldap_pvt_thread_mutex_init( &tlso_mutexes[i] );
}
CRYPTO_set_locking_callback( tlso_locking_cb );
CRYPTO_set_id_callback( tlso_thread_self );
}
开发者ID:cptaffe,项目名称:openldap,代码行数:10,代码来源:tls_o.c
注:本文中的CRYPTO_set_id_callback函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论