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


C++ RSA_PKCS1_SSLeay函数代码示例

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


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

示例1: bind_helper

/* This internal function is used by ENGINE_cswift() and possibly by the
 * "dynamic" ENGINE support too */
static int bind_helper(ENGINE *e)
	{
#ifndef OPENSSL_NO_RSA
	const RSA_METHOD *meth1;
#endif
#ifndef OPENSSL_NO_DH
	const DH_METHOD *meth2;
#endif
	if(!ENGINE_set_id(e, engine_cswift_id) ||
			!ENGINE_set_name(e, engine_cswift_name) ||
#ifndef OPENSSL_NO_RSA
			!ENGINE_set_RSA(e, &cswift_rsa) ||
#endif
#ifndef OPENSSL_NO_DSA
			!ENGINE_set_DSA(e, &cswift_dsa) ||
#endif
#ifndef OPENSSL_NO_DH
			!ENGINE_set_DH(e, &cswift_dh) ||
#endif
			!ENGINE_set_RAND(e, &cswift_random) ||
			!ENGINE_set_destroy_function(e, cswift_destroy) ||
			!ENGINE_set_init_function(e, cswift_init) ||
			!ENGINE_set_finish_function(e, cswift_finish) ||
			!ENGINE_set_ctrl_function(e, cswift_ctrl) ||
			!ENGINE_set_cmd_defns(e, cswift_cmd_defns))
		return 0;

#ifndef OPENSSL_NO_RSA
	/* We know that the "PKCS1_SSLeay()" functions hook properly
	 * to the cswift-specific mod_exp and mod_exp_crt so we use
	 * those functions. NB: We don't use ENGINE_openssl() or
	 * anything "more generic" because something like the RSAref
	 * code may not hook properly, and if you own one of these
	 * cards then you have the right to do RSA operations on it
	 * anyway! */ 
	meth1 = RSA_PKCS1_SSLeay();
	cswift_rsa.rsa_pub_enc = meth1->rsa_pub_enc;
	cswift_rsa.rsa_pub_dec = meth1->rsa_pub_dec;
	cswift_rsa.rsa_priv_enc = meth1->rsa_priv_enc;
	cswift_rsa.rsa_priv_dec = meth1->rsa_priv_dec;
#endif

#ifndef OPENSSL_NO_DH
	/* Much the same for Diffie-Hellman */
	meth2 = DH_OpenSSL();
	cswift_dh.generate_key = meth2->generate_key;
	cswift_dh.compute_key = meth2->compute_key;
#endif

	/* Ensure the cswift error handling is set up */
	ERR_load_CSWIFT_strings();
	return 1;
	}
开发者ID:0culus,项目名称:openssl,代码行数:55,代码来源:e_cswift.c

示例2: OPENSSL_malloc

RSA *FIPS_rsa_new(void)
	{
	RSA *ret;
	ret = OPENSSL_malloc(sizeof(RSA));
	if (!ret)
		return NULL;
	memset(ret, 0, sizeof(RSA));
	ret->meth = RSA_PKCS1_SSLeay();
	if (ret->meth->init)
		ret->meth->init(ret);
	return ret;
	}
开发者ID:alisw,项目名称:alice-openssl,代码行数:12,代码来源:fips_rsa_lib.c

示例3: RSA_PKCS1_SSLeay

const RSA_METHOD *RSA_get_default_method(void)
	{
#ifndef OPERA_SMALL_VERSION
	if (default_RSA_meth == NULL)
		{
#ifdef RSA_NULL
		default_RSA_meth=RSA_null_method();
#else
#if 0 /* was: #ifdef RSAref */
		default_RSA_meth=RSA_PKCS1_RSAref();
#else
		default_RSA_meth=RSA_PKCS1_SSLeay();
#endif
#endif
		}

	return default_RSA_meth;
#else
	return RSA_PKCS1_SSLeay();
#endif
	}
开发者ID:prestocore,项目名称:browser,代码行数:21,代码来源:rsa_lib.c

示例4:

const RSA_METHOD *RSA_get_default_method(void)
	{
	if (default_RSA_meth == NULL)
		{
#ifdef RSA_NULL
		default_RSA_meth=RSA_null_method();
#else
		default_RSA_meth=RSA_PKCS1_SSLeay();
#endif
		}

	return default_RSA_meth;
	}
开发者ID:benwh4,项目名称:libressl,代码行数:13,代码来源:rsa_lib.c

示例5: capi_init

static int capi_init(ENGINE *e)
	{
	CAPI_CTX *ctx;
	const RSA_METHOD *ossl_rsa_meth;
	const DSA_METHOD *ossl_dsa_meth;
	capi_idx = ENGINE_get_ex_new_index(0, NULL, NULL, NULL, 0);
	cert_capi_idx = X509_get_ex_new_index(0, NULL, NULL, NULL, 0);

	ctx = capi_ctx_new();
	if (!ctx || (capi_idx < 0))
		goto memerr;

	ENGINE_set_ex_data(e, capi_idx, ctx);
	/* Setup RSA_METHOD */
	rsa_capi_idx = RSA_get_ex_new_index(0, NULL, NULL, NULL, 0);
	ossl_rsa_meth = RSA_PKCS1_SSLeay();
	capi_rsa_method.rsa_pub_enc = ossl_rsa_meth->rsa_pub_enc;
	capi_rsa_method.rsa_pub_dec = ossl_rsa_meth->rsa_pub_dec;
	capi_rsa_method.rsa_mod_exp = ossl_rsa_meth->rsa_mod_exp;
	capi_rsa_method.bn_mod_exp = ossl_rsa_meth->bn_mod_exp;

	/* Setup DSA Method */
	dsa_capi_idx = DSA_get_ex_new_index(0, NULL, NULL, NULL, 0);
	ossl_dsa_meth = DSA_OpenSSL();
	capi_dsa_method.dsa_do_verify = ossl_dsa_meth->dsa_do_verify;
	capi_dsa_method.dsa_mod_exp = ossl_dsa_meth->dsa_mod_exp;
	capi_dsa_method.bn_mod_exp = ossl_dsa_meth->bn_mod_exp;

#ifdef OPENSSL_CAPIENG_DIALOG
	{
	HMODULE cryptui = LoadLibrary(TEXT("CRYPTUI.DLL"));
	HMODULE kernel = GetModuleHandle(TEXT("KERNEL32.DLL"));
	if (cryptui)
		ctx->certselectdlg = (CERTDLG)GetProcAddress(cryptui, "CryptUIDlgSelectCertificateFromStore");
	if (kernel)
		ctx->getconswindow = (GETCONSWIN)GetProcAddress(kernel, "GetConsoleWindow");
	if (cryptui && !OPENSSL_isservice())
		ctx->client_cert_select = cert_select_dialog;
	}
#endif
		

	return 1;

	memerr:
	CAPIerr(CAPI_F_CAPI_INIT, ERR_R_MALLOC_FAILURE);
	return 0;

	return 1;
	}
开发者ID:Groestlcoin,项目名称:foreign,代码行数:50,代码来源:e_capi.c

示例6: ubsec_mod_exp_mont

/*
 * This function is aliased to mod_exp (with the mont stuff dropped).
 */
static int ubsec_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
                              const BIGNUM *m, BN_CTX *ctx,
                              BN_MONT_CTX *m_ctx)
{
    int ret = 0;

    /* Do in software if the key is too large for the hardware. */
    if (BN_num_bits(m) > max_key_len) {
        const RSA_METHOD *meth = RSA_PKCS1_SSLeay();
        ret = (*meth->bn_mod_exp) (r, a, p, m, ctx, m_ctx);
    } else {
        ret = ubsec_mod_exp(r, a, p, m, ctx);
    }

    return ret;
}
开发者ID:mwgoldsmith,项目名称:openssl,代码行数:19,代码来源:e_ubsec.c

示例7: RSA_zencod_rsa_mod_exp

static int RSA_zencod_rsa_mod_exp ( BIGNUM *r0, const BIGNUM *i, RSA *rsa )
{

	CHEESE () ;

	if ( !zencod_dso ) {
		ENGINEerr(ZENCOD_F_ZENCOD_RSA_MOD_EXP_CRT, ZENCOD_R_NOT_LOADED);
		return 0;
	}

	if ( !rsa->p || !rsa->q || !rsa->dmp1 || !rsa->dmq1 || !rsa->iqmp ) {
		ENGINEerr(ZENCOD_F_ZENCOD_RSA_MOD_EXP_CRT, ZENCOD_R_BAD_KEY_COMPONENTS);
		return 0;
	}

	/* Do in software if argument is too large for hardware */
	if ( RSA_size(rsa) * 8 > ZENBRIDGE_MAX_KEYSIZE_RSA_CRT ) {
		const RSA_METHOD *meth;

		meth = RSA_PKCS1_SSLeay();
		return meth->rsa_mod_exp(r0, i, rsa);
	} else {
		zen_nb_t y, x, p, q, dmp1, dmq1, iqmp;

		if ( !bn_expand(r0, RSA_size(rsa) * 8) ) {
			ENGINEerr(ZENCOD_F_ZENCOD_RSA_MOD_EXP_CRT, ZENCOD_R_BN_EXPAND_FAIL);
			return 0;
		}
		r0->top = (RSA_size(rsa) * 8 + BN_BITS2 - 1) / BN_BITS2;

		BIGNUM2ZEN ( &x, i ) ;
		BIGNUM2ZEN ( &y, r0 ) ;
		BIGNUM2ZEN ( &p, rsa->p ) ;
		BIGNUM2ZEN ( &q, rsa->q ) ;
		BIGNUM2ZEN ( &dmp1, rsa->dmp1 ) ;
		BIGNUM2ZEN ( &dmq1, rsa->dmq1 ) ;
		BIGNUM2ZEN ( &iqmp, rsa->iqmp ) ;

		if ( ptr_zencod_rsa_mod_exp_crt ( &y, &x, &p, &q, &dmp1, &dmq1, &iqmp ) < 0 ) {
			PERROR("zenbridge_rsa_mod_exp_crt");
			ENGINEerr(ZENCOD_F_ZENCOD_RSA_MOD_EXP_CRT, ZENCOD_R_REQUEST_FAILED);
			return 0;
		}

		return 1;
	}
}
开发者ID:AustinWise,项目名称:Netduino-Micro-Framework,代码行数:47,代码来源:hw_zencod.c

示例8: aos_signature_init

int aos_signature_init(struct aos_signature *sign)
{
	memset(sign, 0, sizeof(struct aos_signature));
	
	sign->rsa = RSA_new();
	if(sign->rsa == NULL)
		return 0;
	
	RSA_set_method(sign->rsa, RSA_PKCS1_SSLeay());
	
	sign->rsa->e = BN_new();
	if(sign->rsa->e == NULL)
		return 0;
	
	BN_set_word(sign->rsa->e, 3);
	
	return 1;
}
开发者ID:kenrestivo,项目名称:aos-tools,代码行数:18,代码来源:crypto.c

示例9: tpm_rsa_pub_dec

static int tpm_rsa_pub_dec(int flen,
			   const unsigned char *from,
			   unsigned char *to,
			   RSA *rsa,
			   int padding)
{
	int rv;

	DBG("%s", __FUNCTION__);

	if ((rv = RSA_PKCS1_SSLeay()->rsa_pub_dec(flen, from, to, rsa,
						  padding)) < 0) {
		TSSerr(TPM_F_TPM_RSA_PUB_DEC, TPM_R_REQUEST_FAILED);
		return 0;
	}

	return rv;
}
开发者ID:tavlima,项目名称:openssl-tpm-engine,代码行数:18,代码来源:e_tpm.c

示例10: aep_rsa_mod_exp

static int aep_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa, BN_CTX *ctx)
	{
	int to_return = 0;
	AEP_RV rv = AEP_R_OK;

	if (!aep_dso)
		{
		AEPHKerr(AEPHK_F_AEP_RSA_MOD_EXP,AEPHK_R_NOT_LOADED);
		goto err;
		}

	/*See if we have all the necessary bits for a crt*/
	if (rsa->q && rsa->dmp1 && rsa->dmq1 && rsa->iqmp)
		{
		rv =  aep_mod_exp_crt(r0,I,rsa->p,rsa->q, rsa->dmp1,rsa->dmq1,rsa->iqmp,ctx);

		if (rv == FAIL_TO_SW){
			const RSA_METHOD *meth = RSA_PKCS1_SSLeay();
			to_return = (*meth->rsa_mod_exp)(r0, I, rsa, ctx);
			goto err;
		}
		else if (rv != AEP_R_OK)
			goto err;
		}
	else
		{
		if (!rsa->d || !rsa->n)
			{
			AEPHKerr(AEPHK_F_AEP_RSA_MOD_EXP,AEPHK_R_MISSING_KEY_COMPONENTS);
			goto err;
			}
 
		rv = aep_mod_exp(r0,I,rsa->d,rsa->n,ctx);
		if  (rv != AEP_R_OK)
			goto err;
	
		}

	to_return = 1;

 err:
	return to_return;
}
开发者ID:jiangzhu1212,项目名称:oooii,代码行数:43,代码来源:e_aep.c

示例11: cswift_rsa_mod_exp

static int cswift_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa)
	{
	BN_CTX *ctx;
	int to_return = 0;
	const RSA_METHOD * def_rsa_method;

	/* Try the limits of RSA (2048 bits) */
	if(BN_num_bytes(rsa->p) > 128 ||
		BN_num_bytes(rsa->q) > 128 ||
		BN_num_bytes(rsa->dmp1) > 128 ||
		BN_num_bytes(rsa->dmq1) > 128 ||
		BN_num_bytes(rsa->iqmp) > 128)
	{
#ifdef RSA_NULL
		def_rsa_method=RSA_null_method();
#else
#if 0
		def_rsa_method=RSA_PKCS1_RSAref();
#else
		def_rsa_method=RSA_PKCS1_SSLeay();
#endif
#endif
		if(def_rsa_method)
			return def_rsa_method->rsa_mod_exp(r0, I, rsa);
	}

	if((ctx = BN_CTX_new()) == NULL)
		goto err;
	if(!rsa->p || !rsa->q || !rsa->dmp1 || !rsa->dmq1 || !rsa->iqmp)
		{
		CSWIFTerr(CSWIFT_F_CSWIFT_RSA_MOD_EXP,CSWIFT_R_MISSING_KEY_COMPONENTS);
		goto err;
		}
	to_return = cswift_mod_exp_crt(r0, I, rsa->p, rsa->q, rsa->dmp1,
		rsa->dmq1, rsa->iqmp, ctx);
err:
	if(ctx)
		BN_CTX_free(ctx);
	return to_return;
	}
开发者ID:aosm,项目名称:OpenSSL097,代码行数:40,代码来源:hw_cswift.c

示例12: RSA_zencod_bn_mod_exp

/* This function is aliased to RSA_mod_exp (with the mont stuff dropped).
 */
static int RSA_zencod_bn_mod_exp ( BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
		const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx )
{

	CHEESE () ;

	if ( !zencod_dso ) {
		ENGINEerr(ZENCOD_F_ZENCOD_RSA_MOD_EXP, ZENCOD_R_NOT_LOADED);
		return 0;
	}

	/* Do in software if argument is too large for hardware */
	if ( BN_num_bits(m) > ZENBRIDGE_MAX_KEYSIZE_RSA ) {
		const RSA_METHOD *meth;

		meth = RSA_PKCS1_SSLeay();
		return meth->bn_mod_exp(r, a, p, m, ctx, m_ctx);
	} else {
		zen_nb_t y, x, e, n;

		if ( !bn_expand(r, BN_num_bits(m)) ) {
			ENGINEerr(ZENCOD_F_ZENCOD_RSA_MOD_EXP, ZENCOD_R_BN_EXPAND_FAIL);
			return 0;
		}
		r->top = (BN_num_bits(m) + BN_BITS2 - 1) / BN_BITS2;

		BIGNUM2ZEN ( &x, a ) ;
		BIGNUM2ZEN ( &y, r ) ;
		BIGNUM2ZEN ( &e, p ) ;
		BIGNUM2ZEN ( &n, m ) ;

		if ( ptr_zencod_rsa_mod_exp ( &y, &x, &n, &e ) < 0 ) {
			PERROR("zenbridge_rsa_mod_exp");
			ENGINEerr(ZENCOD_F_ZENCOD_RSA_MOD_EXP, ZENCOD_R_REQUEST_FAILED);
			return 0;
		}

		return 1;
	}
}
开发者ID:AustinWise,项目名称:Netduino-Micro-Framework,代码行数:42,代码来源:hw_zencod.c

示例13: ubsec_rsa_mod_exp

static int ubsec_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa,
                             BN_CTX *ctx)
{
    int to_return = 0;

    if (!rsa->p || !rsa->q || !rsa->dmp1 || !rsa->dmq1 || !rsa->iqmp) {
        UBSECerr(UBSEC_F_UBSEC_RSA_MOD_EXP, UBSEC_R_MISSING_KEY_COMPONENTS);
        goto err;
    }

    to_return = ubsec_mod_exp_crt(r0, I, rsa->p, rsa->q, rsa->dmp1,
                                  rsa->dmq1, rsa->iqmp, ctx);
    if (to_return == FAIL_TO_SOFTWARE) {
        /*
         * Do in software as hardware failed.
         */
        const RSA_METHOD *meth = RSA_PKCS1_SSLeay();
        to_return = (*meth->rsa_mod_exp) (r0, I, rsa, ctx);
    }
 err:
    return to_return;
}
开发者ID:mwgoldsmith,项目名称:openssl,代码行数:22,代码来源:e_ubsec.c

示例14: cryptodev_rsa_mod_exp

static int
cryptodev_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa, BN_CTX *ctx)
{
	struct crypt_kop kop;
	int ret = 1;

	if (!rsa->p || !rsa->q || !rsa->dmp1 || !rsa->dmq1 || !rsa->iqmp) {
		/* XXX 0 means failure?? */
		return (0);
	}

	memset(&kop, 0, sizeof kop);
	kop.crk_op = CRK_MOD_EXP_CRT;
	/* inputs: rsa->p rsa->q I rsa->dmp1 rsa->dmq1 rsa->iqmp */
	if (bn2crparam(rsa->p, &kop.crk_param[0]))
		goto err;
	if (bn2crparam(rsa->q, &kop.crk_param[1]))
		goto err;
	if (bn2crparam(I, &kop.crk_param[2]))
		goto err;
	if (bn2crparam(rsa->dmp1, &kop.crk_param[3]))
		goto err;
	if (bn2crparam(rsa->dmq1, &kop.crk_param[4]))
		goto err;
	if (bn2crparam(rsa->iqmp, &kop.crk_param[5]))
		goto err;
	kop.crk_iparams = 6;

	if (cryptodev_asym(&kop, BN_num_bytes(rsa->n), r0, 0, NULL) == -1) {
		const RSA_METHOD *meth = RSA_PKCS1_SSLeay();
		ret = (*meth->rsa_mod_exp)(r0, I, rsa, ctx);
	}
err:
	zapparams(&kop);
	return (ret);
}
开发者ID:repos-holder,项目名称:openbsd-patches,代码行数:36,代码来源:hw_cryptodev.c

示例15: cswift_mod_exp_mont

/* This function is aliased to mod_exp (with the mont stuff dropped). */
static int cswift_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
                               const BIGNUM *m, BN_CTX *ctx,
                               BN_MONT_CTX *m_ctx)
{
    const RSA_METHOD *def_rsa_method;

    /* Try the limits of RSA (2048 bits) */
    if (BN_num_bytes(r) > 256 ||
        BN_num_bytes(a) > 256 || BN_num_bytes(m) > 256) {
#   ifdef RSA_NULL
        def_rsa_method = RSA_null_method();
#   else
#    if 0
        def_rsa_method = RSA_PKCS1_RSAref();
#    else
        def_rsa_method = RSA_PKCS1_SSLeay();
#    endif
#   endif
        if (def_rsa_method)
            return def_rsa_method->bn_mod_exp(r, a, p, m, ctx, m_ctx);
    }

    return cswift_mod_exp(r, a, p, m, ctx);
}
开发者ID:119120119,项目名称:node,代码行数:25,代码来源:e_cswift.c


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