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


C++ CRYPTO_r_lock函数代码示例

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


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

示例1: CRYPTO_r_lock

const char *ERR_reason_error_string(unsigned long e)
	{
	ERR_STRING_DATA d,*p=NULL;
	unsigned long l,r;

	l=ERR_GET_LIB(e);
	r=ERR_GET_REASON(e);

	CRYPTO_r_lock(CRYPTO_LOCK_ERR_HASH);

	if (error_hash != NULL)
		{
		d.error=ERR_PACK(l,0,r);
		p=(ERR_STRING_DATA *)lh_retrieve(error_hash,&d);
		if (p == NULL)
			{
			d.error=ERR_PACK(0,0,r);
			p=(ERR_STRING_DATA *)lh_retrieve(error_hash,&d);
			}
		}

	CRYPTO_r_unlock(CRYPTO_LOCK_ERR_HASH);

	return((p == NULL)?NULL:p->string);
	}
开发者ID:Apple-FOSS-Mirror,项目名称:Security,代码行数:25,代码来源:err.c

示例2: BN_MONT_CTX_set_locked

BN_MONT_CTX *
BN_MONT_CTX_set_locked(BN_MONT_CTX **pmont, int lock, const BIGNUM *mod,
    BN_CTX *ctx)
{
	int got_write_lock = 0;
	BN_MONT_CTX *ret;

	CRYPTO_r_lock(lock);
	if (!*pmont) {
		CRYPTO_r_unlock(lock);
		CRYPTO_w_lock(lock);
		got_write_lock = 1;

		if (!*pmont) {
			ret = BN_MONT_CTX_new();
			if (ret && !BN_MONT_CTX_set(ret, mod, ctx))
				BN_MONT_CTX_free(ret);
			else
				*pmont = ret;
		}
	}

	ret = *pmont;

	if (got_write_lock)
		CRYPTO_w_unlock(lock);
	else
		CRYPTO_r_unlock(lock);

	return ret;
}
开发者ID:mr-moai-2016,项目名称:znk_project,代码行数:31,代码来源:bn_mont.c

示例3: SSL_get_ex_data_X509_STORE_CTX_idx

int SSL_get_ex_data_X509_STORE_CTX_idx(void) {
  static int ssl_x509_store_ctx_idx = -1;
  int got_write_lock = 0;

  CRYPTO_r_lock(CRYPTO_LOCK_SSL_CTX);

  if (ssl_x509_store_ctx_idx < 0) {
    CRYPTO_r_unlock(CRYPTO_LOCK_SSL_CTX);
    CRYPTO_w_lock(CRYPTO_LOCK_SSL_CTX);
    got_write_lock = 1;

    if (ssl_x509_store_ctx_idx < 0) {
      ssl_x509_store_ctx_idx = X509_STORE_CTX_get_ex_new_index(
          0, "SSL for verify callback", NULL, NULL, NULL);
    }
  }

  if (got_write_lock) {
    CRYPTO_w_unlock(CRYPTO_LOCK_SSL_CTX);
  } else {
    CRYPTO_r_unlock(CRYPTO_LOCK_SSL_CTX);
  }

  return ssl_x509_store_ctx_idx;
}
开发者ID:randombit,项目名称:hacrypto,代码行数:25,代码来源:ssl_cert.c

示例4: dh_init

NOEXPORT int dh_init(SERVICE_OPTIONS *section) {

#ifdef WITH_WOLFSSL
    s_log(LOG_DEBUG, "DH initialization");
    if(wolfSSL_CTX_SetTmpDH_file(section->ctx, section->cert,
               SSL_FILETYPE_ASN1) == SSL_SUCCESS) { /* DH file loading failed */
		return 0;
     } else {
		s_log(LOG_DEBUG, "Error loading DH params from file: %s", section->cert);
	}
#else
    DH *dh=NULL;

    s_log(LOG_DEBUG, "DH initialization");
#ifndef OPENSSL_NO_ENGINE
    if(!section->engine) /* cert is a file and not an identifier */
#endif
        dh=dh_read(section->cert);
    if(dh) {
        SSL_CTX_set_tmp_dh(section->ctx, dh);
        s_log(LOG_INFO, "%d-bit DH parameters loaded", 8*DH_size(dh));
        DH_free(dh);
        return 0; /* OK */
    }
#endif /* WITH_WOLFSSL */

    CRYPTO_r_lock(stunnel_locks[LOCK_DH]);
    SSL_CTX_set_tmp_dh(section->ctx, dh_params);
    CRYPTO_r_unlock(stunnel_locks[LOCK_DH]);
    dh_needed=1; /* generate temporary DH parameters in cron */
    section->option.dh_needed=1; /* update this context */
    s_log(LOG_INFO, "Using dynamic DH parameters");
    return 0; /* OK */
}
开发者ID:NickolasLapp,项目名称:stunnel,代码行数:34,代码来源:ctx.c

示例5: load_builtin_compressions

static void load_builtin_compressions(void)
	{
	int got_write_lock = 0;

	CRYPTO_r_lock(CRYPTO_LOCK_SSL);
	if (ssl_comp_methods == NULL)
		{
		CRYPTO_r_unlock(CRYPTO_LOCK_SSL);
		CRYPTO_w_lock(CRYPTO_LOCK_SSL);
		got_write_lock = 1;
		
		if (ssl_comp_methods == NULL)
			{
			SSL_COMP *comp = NULL;

			MemCheck_off();
			ssl_comp_methods=sk_SSL_COMP_new(sk_comp_cmp);
			MemCheck_on();
			}
		}
	
	if (got_write_lock)
		CRYPTO_w_unlock(CRYPTO_LOCK_SSL);
	else
		CRYPTO_r_unlock(CRYPTO_LOCK_SSL);
	}
开发者ID:aosm,项目名称:OpenSSL098,代码行数:26,代码来源:ssl_ciph.c

示例6: CRYPTO_r_lock

static BN_BLINDING *rsa_get_blinding(RSA *rsa, int *local, BN_CTX *ctx)
{
	BN_BLINDING *ret;
	int got_write_lock = 0;

	CRYPTO_r_lock(CRYPTO_LOCK_RSA);

	if (rsa->blinding == NULL)
		{
		CRYPTO_r_unlock(CRYPTO_LOCK_RSA);
		CRYPTO_w_lock(CRYPTO_LOCK_RSA);
		got_write_lock = 1;

		if (rsa->blinding == NULL)
			rsa->blinding = RSA_setup_blinding(rsa, ctx);
		}

	ret = rsa->blinding;
	if (ret == NULL)
		goto err;

	if (BN_BLINDING_get_thread_id(ret) == CRYPTO_thread_id())
		{
		/* rsa->blinding is ours! */

		*local = 1;
		}
	else
		{
		/* resort to rsa->mt_blinding instead */

		*local = 0; /* instructs rsa_blinding_convert(), rsa_blinding_invert()
		             * that the BN_BLINDING is shared, meaning that accesses
		             * require locks, and that the blinding factor must be
		             * stored outside the BN_BLINDING
		             */

		if (rsa->mt_blinding == NULL)
			{
			if (!got_write_lock)
				{
				CRYPTO_r_unlock(CRYPTO_LOCK_RSA);
				CRYPTO_w_lock(CRYPTO_LOCK_RSA);
				got_write_lock = 1;
				}
			
			if (rsa->mt_blinding == NULL)
				rsa->mt_blinding = RSA_setup_blinding(rsa, ctx);
			}
		ret = rsa->mt_blinding;
		}

 err:
	if (got_write_lock)
		CRYPTO_w_unlock(CRYPTO_LOCK_RSA);
	else
		CRYPTO_r_unlock(CRYPTO_LOCK_RSA);
	return ret;
}
开发者ID:repos-holder,项目名称:openbsd-patches,代码行数:59,代码来源:rsa_eay.c

示例7: void

void *EC_KEY_get_key_method_data(EC_KEY *key,
	void *(*dup_func)(void *), void (*free_func)(void *), void (*clear_free_func)(void *))
	{
	void *ret;

	CRYPTO_r_lock(CRYPTO_LOCK_EC);
	ret = EC_EX_DATA_get_data(key->method_data, dup_func, free_func, clear_free_func);
	CRYPTO_r_unlock(CRYPTO_LOCK_EC);

	return ret;
	}
开发者ID:oss-forks,项目名称:openssl,代码行数:11,代码来源:ec_key.c

示例8: FIPS_mode

int FIPS_mode(void)
	{
	int ret = 0;
	int owning_thread = fips_is_owning_thread();

	if (fips_is_started())
		{
		if (!owning_thread) CRYPTO_r_lock(CRYPTO_LOCK_FIPS);
		ret = fips_mode;
		if (!owning_thread) CRYPTO_r_unlock(CRYPTO_LOCK_FIPS);
		}
	return ret;
	}
开发者ID:FelipeFernandes1988,项目名称:Alice-1121-Modem,代码行数:13,代码来源:cryptlib.c

示例9: LHASH_OF

static ERR_STRING_DATA *int_err_get_item(const ERR_STRING_DATA *d)
{
    ERR_STRING_DATA *p = NULL;
    LHASH_OF(ERR_STRING_DATA) *hash;

    CRYPTO_r_lock(CRYPTO_LOCK_ERR);
    hash = get_hash(0, 0);
    if (hash)
        p = lh_ERR_STRING_DATA_retrieve(hash, d);
    CRYPTO_r_unlock(CRYPTO_LOCK_ERR);

    return p;
}
开发者ID:AndreV84,项目名称:openssl,代码行数:13,代码来源:err.c

示例10: fips_is_owning_thread

void *FIPS_rand_check(void)
	{
	void *ret = 0;
	int owning_thread = fips_is_owning_thread();

	if (fips_is_started())
		{
		if (!owning_thread) CRYPTO_r_lock(CRYPTO_LOCK_FIPS);
		ret = fips_rand_check;
		if (!owning_thread) CRYPTO_r_unlock(CRYPTO_LOCK_FIPS);
		}
	return ret;
	}
开发者ID:FelipeFernandes1988,项目名称:Alice-1121-Modem,代码行数:13,代码来源:cryptlib.c

示例11: fips_is_owning_thread

int fips_is_owning_thread(void)
	{
	int ret = 0;

	if (fips_is_started())
		{
		CRYPTO_r_lock(CRYPTO_LOCK_FIPS2);
		if (fips_thread != 0 && fips_thread == CRYPTO_thread_id())
			ret = 1;
		CRYPTO_r_unlock(CRYPTO_LOCK_FIPS2);
		}
	return ret;
	}
开发者ID:aosm,项目名称:OpenSSL097,代码行数:13,代码来源:cryptlib.c

示例12: rsa_blinding_convert

static int rsa_blinding_convert(BN_BLINDING *b, int local, BIGNUM *f,
	BIGNUM *r, BN_CTX *ctx)
{
	if (local)
		return BN_BLINDING_convert_ex(f, NULL, b, ctx);
	else
		{
		int ret;
		CRYPTO_r_lock(CRYPTO_LOCK_RSA_BLINDING);
		ret = BN_BLINDING_convert_ex(f, r, b, ctx);
		CRYPTO_r_unlock(CRYPTO_LOCK_RSA_BLINDING);
		return ret;
		}
}
开发者ID:mxOBS,项目名称:debian_openssl,代码行数:14,代码来源:rsa_eay.c

示例13: build_SYS_str_reasons

static void build_SYS_str_reasons(void)
	{
	/* OPENSSL_malloc cannot be used here, use static storage instead */
	static char strerror_tab[NUM_SYS_STR_REASONS][LEN_SYS_STR_REASON];
	int i;
	static int init = 1;

	CRYPTO_r_lock(CRYPTO_LOCK_ERR);
	if (!init)
		{
		CRYPTO_r_unlock(CRYPTO_LOCK_ERR);
		return;
		}
	
	CRYPTO_r_unlock(CRYPTO_LOCK_ERR);
	CRYPTO_w_lock(CRYPTO_LOCK_ERR);
	if (!init)
		{
		CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
		return;
		}

	for (i = 1; i <= NUM_SYS_STR_REASONS; i++)
		{
		ERR_STRING_DATA *str = &SYS_str_reasons[i - 1];

		str->error = (unsigned long)i;
		if (str->string == NULL)
			{
			char (*dest)[LEN_SYS_STR_REASON] = &(strerror_tab[i - 1]);
			char *src = strerror(i);
			if (src != NULL)
				{
				strncpy(*dest, src, sizeof *dest);
				(*dest)[sizeof *dest - 1] = '\0';
				str->string = *dest;
				}
			}
		if (str->string == NULL)
			str->string = "unknown";
		}

	/* Now we still have SYS_str_reasons[NUM_SYS_STR_REASONS] = {0, NULL},
	 * as required by ERR_load_strings. */

	init = 0;
	
	CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
	}
开发者ID:aosm,项目名称:OpenSSL098,代码行数:49,代码来源:err_str.c

示例14: fips_is_owning_thread

static int fips_is_owning_thread(void)
{
    int ret = 0;

    if (fips_started) {
        CRYPTO_r_lock(CRYPTO_LOCK_FIPS2);
        if (fips_thread_set) {
            CRYPTO_THREADID cur;
            CRYPTO_THREADID_current(&cur);
            if (!CRYPTO_THREADID_cmp(&cur, &fips_thread))
                ret = 1;
        }
        CRYPTO_r_unlock(CRYPTO_LOCK_FIPS2);
    }
    return ret;
}
开发者ID:davidlt,项目名称:openssl-fedora,代码行数:16,代码来源:fips.c

示例15: err_fns_check

static ERR_STRING_DATA *int_err_get_item(const ERR_STRING_DATA *d)
	{
	ERR_STRING_DATA *p;
	LHASH *hash;

	err_fns_check();
	hash = ERRFN(err_get)(0);
	if (!hash)
		return NULL;

	CRYPTO_r_lock(CRYPTO_LOCK_ERR);
	p = (ERR_STRING_DATA *)lh_retrieve(hash, d);
	CRYPTO_r_unlock(CRYPTO_LOCK_ERR);

	return p;
	}
开发者ID:174high,项目名称:openssl-0.9.8e_linux_porting,代码行数:16,代码来源:err.c


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