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


C++ CRYPTO_w_lock函数代码示例

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


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

示例1: X509_PUBKEY_get0

EVP_PKEY *
X509_PUBKEY_get0(X509_PUBKEY *key)
{
	EVP_PKEY *ret = NULL;

	if (key == NULL)
		goto error;

	if (key->pkey != NULL)
		return key->pkey;

	if (key->public_key == NULL)
		goto error;

	if ((ret = EVP_PKEY_new()) == NULL) {
		X509error(ERR_R_MALLOC_FAILURE);
		goto error;
	}

	if (!EVP_PKEY_set_type(ret, OBJ_obj2nid(key->algor->algorithm))) {
		X509error(X509_R_UNSUPPORTED_ALGORITHM);
		goto error;
	}

	if (ret->ameth->pub_decode) {
		if (!ret->ameth->pub_decode(ret, key)) {
			X509error(X509_R_PUBLIC_KEY_DECODE_ERROR);
			goto error;
		}
	} else {
		X509error(X509_R_METHOD_NOT_SUPPORTED);
		goto error;
	}

	/* Check to see if another thread set key->pkey first */
	CRYPTO_w_lock(CRYPTO_LOCK_EVP_PKEY);
	if (key->pkey) {
		CRYPTO_w_unlock(CRYPTO_LOCK_EVP_PKEY);
		EVP_PKEY_free(ret);
		ret = key->pkey;
	} else {
		key->pkey = ret;
		CRYPTO_w_unlock(CRYPTO_LOCK_EVP_PKEY);
	}

	return ret;

error:
	EVP_PKEY_free(ret);
	return (NULL);
}
开发者ID:mr-moai-2016,项目名称:znk_project,代码行数:51,代码来源:x_pubkey.c

示例2: open_console

/* Internal functions to open, handle and close a channel to the console.  */
static int open_console(UI *ui)
{
    CRYPTO_w_lock(CRYPTO_LOCK_UI);
    is_a_tty = 1;

#if defined(OPENSSL_SYS_MACINTOSH_CLASSIC) || defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_NETWARE) || defined(OPENSSL_SYS_BEOS)
    tty_in = stdin;
    tty_out = stderr;
#else
# ifdef OPENSSL_SYS_MSDOS
#  define DEV_TTY "con"
# else
#  define DEV_TTY "/dev/tty"
# endif
    if ((tty_in = fopen(DEV_TTY, "r")) == NULL)
        tty_in = stdin;
    if ((tty_out = fopen(DEV_TTY, "w")) == NULL)
        tty_out = stderr;
#endif

#if defined(TTY_get) && !defined(OPENSSL_SYS_VMS)
    if (TTY_get(fileno(tty_in), &tty_orig) == -1) {
# ifdef ENOTTY
        if (errno == ENOTTY)
            is_a_tty = 0;
        else
# endif
# ifdef EINVAL
            /*
             * Ariel Glenn [email protected] reports that solaris can return
             * EINVAL instead.  This should be ok
             */
        if (errno == EINVAL)
            is_a_tty = 0;
        else
# endif
            return 0;
    }
#endif
#ifdef OPENSSL_SYS_VMS
    status = sys$assign(&terminal, &channel, 0, 0);
    if (status != SS$_NORMAL)
        return 0;
    status =
        sys$qiow(0, channel, IO$_SENSEMODE, &iosb, 0, 0, tty_orig, 12, 0, 0,
                 0, 0);
    if ((status != SS$_NORMAL) || (iosb.iosb$w_value != SS$_NORMAL))
        return 0;
#endif
    return 1;
}
开发者ID:NickAger,项目名称:elm-slider,代码行数:52,代码来源:ui_openssl.c

示例3: void

void *EC_KEY_insert_key_method_data (EC_KEY * key, void *data,
                                     void *(*dup_func) (void *), void (*free_func) (void *),
                                     void (*clear_free_func) (void *))
{
    EC_EXTRA_DATA *ex_data;

    CRYPTO_w_lock (CRYPTO_LOCK_EC);
    ex_data = EC_EX_DATA_get_data (key->method_data, dup_func, free_func, clear_free_func);
    if (ex_data == NULL)
        EC_EX_DATA_set_data (&key->method_data, data, dup_func, free_func, clear_free_func);
    CRYPTO_w_unlock (CRYPTO_LOCK_EC);

    return ex_data;
}
开发者ID:274914765,项目名称:C,代码行数:14,代码来源:ec_key.c

示例4: ENGINE_ctrl

int
ENGINE_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)(void))
{
	int ctrl_exists, ref_exists;

	if (e == NULL) {
		ENGINEerr(ENGINE_F_ENGINE_CTRL, ERR_R_PASSED_NULL_PARAMETER);
		return 0;
	}
	CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
	ref_exists = ((e->struct_ref > 0) ? 1 : 0);
	CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
	ctrl_exists = ((e->ctrl == NULL) ? 0 : 1);
	if (!ref_exists) {
		ENGINEerr(ENGINE_F_ENGINE_CTRL, ENGINE_R_NO_REFERENCE);
		return 0;
	}
	/* Intercept any "root-level" commands before trying to hand them on to
	 * ctrl() handlers. */
	switch (cmd) {
	case ENGINE_CTRL_HAS_CTRL_FUNCTION:
		return ctrl_exists;
	case ENGINE_CTRL_GET_FIRST_CMD_TYPE:
	case ENGINE_CTRL_GET_NEXT_CMD_TYPE:
	case ENGINE_CTRL_GET_CMD_FROM_NAME:
	case ENGINE_CTRL_GET_NAME_LEN_FROM_CMD:
	case ENGINE_CTRL_GET_NAME_FROM_CMD:
	case ENGINE_CTRL_GET_DESC_LEN_FROM_CMD:
	case ENGINE_CTRL_GET_DESC_FROM_CMD:
	case ENGINE_CTRL_GET_CMD_FLAGS:
		if (ctrl_exists && !(e->flags & ENGINE_FLAGS_MANUAL_CMD_CTRL))
			return int_ctrl_helper(e, cmd, i, p, f);
		if (!ctrl_exists) {
			ENGINEerr(ENGINE_F_ENGINE_CTRL,
			    ENGINE_R_NO_CONTROL_FUNCTION);
			/* For these cmd-related functions, failure is indicated
			 * by a -1 return value (because 0 is used as a valid
			 * return in some places). */
			return -1;
		}
	default:
		break;
	}
	/* Anything else requires a ctrl() handler to exist. */
	if (!ctrl_exists) {
		ENGINEerr(ENGINE_F_ENGINE_CTRL, ENGINE_R_NO_CONTROL_FUNCTION);
		return 0;
	}
	return e->ctrl(e, cmd, i, p, f);
}
开发者ID:randombit,项目名称:hacrypto,代码行数:50,代码来源:eng_ctrl.c

示例5: rsa_blinding_invert

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

示例6: err_fns_check

/* err_fns_check is an internal function that checks whether "err_fns" is set
 * and if not, sets it to the default. */
static void err_fns_check(void) {
  /* In practice, this is not a race problem because loading the error strings
   * at init time will cause this pointer to be set before the process goes
   * multithreaded. */
  if (err_fns) {
    return;
  }

  CRYPTO_w_lock(CRYPTO_LOCK_ERR);
  if (!err_fns) {
    err_fns = &openssl_err_default_impl;
  }
  CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
}
开发者ID:xin3liang,项目名称:platform_external_chromium_org_third_party_boringssl_src,代码行数:16,代码来源:err.c

示例7: 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

示例8: fips_set_owning_thread

int fips_set_owning_thread(void)
{
    int ret = 0;

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

示例9: ERR_set_implementation

int ERR_set_implementation(const ERR_FNS *fns)
	{
	int ret = 0;

	CRYPTO_w_lock(CRYPTO_LOCK_ERR);
	/* It's too late if 'err_fns' is non-NULL. BTW: not much point setting
	 * an error is there?! */
	if (!err_fns)
		{
		err_fns = fns;
		ret = 1;
		}
	CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
	return ret;
	}
开发者ID:174high,项目名称:openssl-0.9.8e_linux_porting,代码行数:15,代码来源:err.c

示例10: CRYPTO_w_lock

static BN_BLINDING *rsa_get_blinding(RSA *rsa, BIGNUM **r, int *local, BN_CTX *ctx)
{
	BN_BLINDING *ret;

	if (rsa->blinding == NULL)
		{
		if (rsa->blinding == NULL)
			{
			CRYPTO_w_lock(CRYPTO_LOCK_RSA);
			if (rsa->blinding == NULL)
				rsa->blinding = RSA_setup_blinding(rsa, ctx);
			CRYPTO_w_unlock(CRYPTO_LOCK_RSA);
			}
		}

	ret = rsa->blinding;
	if (ret == NULL)
		return NULL;

	if (BN_BLINDING_get_thread_id(ret) != CRYPTO_thread_id())
		{
		*local = 0;
		if (rsa->mt_blinding == NULL)
			{
			CRYPTO_w_lock(CRYPTO_LOCK_RSA);
			if (rsa->mt_blinding == NULL)
				rsa->mt_blinding = RSA_setup_blinding(rsa, ctx);
			CRYPTO_w_unlock(CRYPTO_LOCK_RSA);
			}
		ret = rsa->mt_blinding;
		}
	else
		*local = 1;

	return ret;
}
开发者ID:mxOBS,项目名称:debian_openssl,代码行数:36,代码来源:rsa_eay.c

示例11: X509_check_purpose

/* As much as I'd like to make X509_check_purpose use a "const" X509*
 * I really can't because it does recalculate hashes and do other non-const
 * things. */
int X509_check_purpose(X509 *x, int id, int ca)
{
  int idx;
  const X509_PURPOSE *pt;
  if(!(x->ex_flags & EXFLAG_SET)) {
    CRYPTO_w_lock(CRYPTO_LOCK_X509);
    x509v3_cache_extensions(x);
    CRYPTO_w_unlock(CRYPTO_LOCK_X509);
  }
  if(id == -1) return 1;
  idx = X509_PURPOSE_get_by_id(id);
  if(idx == -1) return -1;
  pt = X509_PURPOSE_get0(idx);
  return pt->check_purpose(pt, x, ca);
}
开发者ID:yyyyyao,项目名称:Slicer3-lib-mirrors,代码行数:18,代码来源:v3_purp.c

示例12: ERR_remove_state

void ERR_remove_state(unsigned long pid)
	{
	ERR_STATE *p,tmp;

	if (thread_hash == NULL)
		return;
	if (pid == 0)
		pid=(unsigned long)CRYPTO_thread_id();
	tmp.pid=pid;
	CRYPTO_w_lock(CRYPTO_LOCK_ERR);
	p=(ERR_STATE *)lh_delete(thread_hash,&tmp);
	CRYPTO_w_unlock(CRYPTO_LOCK_ERR);

	if (p != NULL) ERR_STATE_free(p);
	}
开发者ID:Apple-FOSS-Mirror,项目名称:Security,代码行数:15,代码来源:err.c

示例13: ENGINE_remove

/* Remove an existing "ENGINE" type from the array. */
int ENGINE_remove(ENGINE *e)
{
    int to_return = 1;
    if (e == NULL) {
        ENGINEerr(ENGINE_F_ENGINE_REMOVE, ERR_R_PASSED_NULL_PARAMETER);
        return 0;
    }
    CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
    if (!engine_list_remove(e)) {
        ENGINEerr(ENGINE_F_ENGINE_REMOVE, ENGINE_R_INTERNAL_LIST_ERROR);
        to_return = 0;
    }
    CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
    return to_return;
}
开发者ID:Voxer,项目名称:openssl,代码行数:16,代码来源:eng_list.c

示例14: RAND_cleanup

/* RAND_cleanup frees all buffers, closes any cached file descriptor
 * and resets the global state. */
void RAND_cleanup(void) {
  struct rand_buffer *cur;

  CRYPTO_w_lock(CRYPTO_LOCK_RAND);
  while ((cur = list_head)) {
    list_head = cur->next;
    OPENSSL_free(cur);
  }
  if (urandom_fd >= 0) {
    close(urandom_fd);
  }
  urandom_fd = -2;
  list_head = NULL;
  CRYPTO_w_unlock(CRYPTO_LOCK_RAND);
}
开发者ID:HungMingWu,项目名称:libquic,代码行数:17,代码来源:urandom.c

示例15: ENGINE_by_id

ENGINE *
ENGINE_by_id(const char *id)
{
	ENGINE *iterator;
	ENGINE *tmp;
	tmp = engine_list_head;
    while (tmp) {
        printf("my engine iterator, id%s\n", tmp->id);
		tmp = tmp->next;
    }

    printf("my engine, file:%s line:%d\n", __FILE__, __LINE__);
	if (id == NULL) {
		ENGINEerr(ENGINE_F_ENGINE_BY_ID,
		    ERR_R_PASSED_NULL_PARAMETER);
		return NULL;
	}
	CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
    printf("my engine, file:%s line:%d\n", __FILE__, __LINE__);
	iterator = engine_list_head;
	while (iterator && (strcmp(id, iterator->id) != 0) && printf("my engine iterator, id%s\n", iterator->id))
		iterator = iterator->next;
	if (iterator) {
		/* We need to return a structural reference. If this is an
		 * ENGINE type that returns copies, make a duplicate - otherwise
		 * increment the existing ENGINE's reference count. */
		if (iterator->flags & ENGINE_FLAGS_BY_ID_COPY) {
			ENGINE *cp = ENGINE_new();
			if (!cp)
				iterator = NULL;
			else {
				engine_cpy(cp, iterator);
				iterator = cp;
			}
		} else {
			iterator->struct_ref++;
			engine_ref_debug(iterator, 0, 1)
		}
	}
	CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
    printf("my engine, file:%s line:%d\n", __FILE__, __LINE__);

	if (iterator == NULL) {
		ENGINEerr(ENGINE_F_ENGINE_BY_ID, ENGINE_R_NO_SUCH_ENGINE);
		ERR_asprintf_error_data("id=%s", id);
	}
	return iterator;
}
开发者ID:luocn99,项目名称:nginx,代码行数:48,代码来源:eng_list.c


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