本文整理汇总了C++中EVP_PKEY_assign_DSA函数的典型用法代码示例。如果您正苦于以下问题:C++ EVP_PKEY_assign_DSA函数的具体用法?C++ EVP_PKEY_assign_DSA怎么用?C++ EVP_PKEY_assign_DSA使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了EVP_PKEY_assign_DSA函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: pkey_dsa_paramgen
static int pkey_dsa_paramgen(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey)
{
DSA *dsa = NULL;
DSA_PKEY_CTX *dctx = ctx->data;
BN_GENCB *pcb;
int ret;
if (ctx->pkey_gencb) {
pcb = BN_GENCB_new();
if (pcb == NULL)
return 0;
evp_pkey_set_cb_translate(pcb, ctx);
} else
pcb = NULL;
dsa = DSA_new();
if (dsa == NULL) {
BN_GENCB_free(pcb);
return 0;
}
ret = dsa_builtin_paramgen(dsa, dctx->nbits, dctx->qbits, dctx->pmd,
NULL, 0, NULL, NULL, NULL, pcb);
BN_GENCB_free(pcb);
if (ret)
EVP_PKEY_assign_DSA(pkey, dsa);
else
DSA_free(dsa);
return ret;
}
开发者ID:AlexanderPankiv,项目名称:node,代码行数:27,代码来源:dsa_pmeth.c
示例2: EVP_PKEY_set1_DSA
int EVP_PKEY_set1_DSA(EVP_PKEY *pkey, DSA *key) {
if (EVP_PKEY_assign_DSA(pkey, key)) {
DSA_up_ref(key);
return 1;
}
return 0;
}
开发者ID:Cyril2004,项目名称:proto-quic,代码行数:7,代码来源:evp.c
示例3: NativeCrypto_EVP_PKEY_new_DSA
/**
* private static native int EVP_PKEY_new_DSA(byte[] p, byte[] q, byte[] g, byte[] pub_key, byte[] priv_key);
*/
static EVP_PKEY* NativeCrypto_EVP_PKEY_new_DSA(JNIEnv* env, jclass clazz, jbyteArray p, jbyteArray q, jbyteArray g, jbyteArray pub_key, jbyteArray priv_key) {
// LOGD("Entering EVP_PKEY_new_DSA()");
DSA* dsa = DSA_new();
dsa->p = arrayToBignum(env, p);
dsa->q = arrayToBignum(env, q);
dsa->g = arrayToBignum(env, g);
dsa->pub_key = arrayToBignum(env, pub_key);
if (priv_key != NULL) {
dsa->priv_key = arrayToBignum(env, priv_key);
}
if (dsa->p == NULL || dsa->q == NULL || dsa->g == NULL || dsa->pub_key == NULL) {
DSA_free(dsa);
throwRuntimeException(env, "Unable to convert BigInteger to BIGNUM");
return NULL;
}
EVP_PKEY* pkey = EVP_PKEY_new();
EVP_PKEY_assign_DSA(pkey, dsa);
return pkey;
}
开发者ID:llnull,项目名称:platform_dalvik,代码行数:28,代码来源:org_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
示例4: generate_dsa_key
static EP_STAT
generate_dsa_key(EP_CRYPTO_KEY *key, int keylen)
{
DSA *dsakey;
// generate new parameter block
dsakey = DSA_new();
if (DSA_generate_parameters_ex(dsakey, keylen,
NULL, 0, NULL, NULL, NULL) != 1)
{
_ep_crypto_error("cannot initialize DSA parameters");
goto fail0;
}
if (DSA_generate_key(dsakey) != 1)
{
_ep_crypto_error("cannot generate DSA key");
goto fail0;
}
if (EVP_PKEY_assign_DSA(key, dsakey) != 1)
{
_ep_crypto_error("cannot save DSA key");
goto fail0;
}
return EP_STAT_OK;
fail0:
return EP_STAT_CRYPTO_KEYCREATE;
}
开发者ID:jugador87,项目名称:gdp,代码行数:30,代码来源:ep_crypto_key.c
示例5: EVP_PKEY_set1_DSA
int EVP_PKEY_set1_DSA(EVP_PKEY *pkey, DSA *key)
{
int ret = EVP_PKEY_assign_DSA(pkey, key);
if(ret)
DSA_up_ref(key);
return ret;
}
开发者ID:1310701102,项目名称:sl4a,代码行数:7,代码来源:p_lib.c
示例6: old_dsa_priv_decode
static int
old_dsa_priv_decode(EVP_PKEY *pkey, const unsigned char **pder, int derlen)
{
DSA *dsa;
BN_CTX *ctx = NULL;
BIGNUM *j, *p1, *newp1;
if (!(dsa = d2i_DSAPrivateKey(NULL, pder, derlen))) {
DSAerror(ERR_R_DSA_LIB);
return 0;
}
ctx = BN_CTX_new();
if (ctx == NULL)
goto err;
/*
* Check that p and q are consistent with each other.
*/
j = BN_CTX_get(ctx);
p1 = BN_CTX_get(ctx);
newp1 = BN_CTX_get(ctx);
if (j == NULL || p1 == NULL || newp1 == NULL)
goto err;
/* p1 = p - 1 */
if (BN_sub(p1, dsa->p, BN_value_one()) == 0)
goto err;
/* j = (p - 1) / q */
if (BN_div_ct(j, NULL, p1, dsa->q, ctx) == 0)
goto err;
/* q * j should == p - 1 */
if (BN_mul(newp1, dsa->q, j, ctx) == 0)
goto err;
if (BN_cmp(newp1, p1) != 0) {
DSAerror(DSA_R_BAD_Q_VALUE);
goto err;
}
/*
* Check that q is not a composite number.
*/
if (BN_is_prime_ex(dsa->q, BN_prime_checks, ctx, NULL) <= 0) {
DSAerror(DSA_R_BAD_Q_VALUE);
goto err;
}
BN_CTX_free(ctx);
EVP_PKEY_assign_DSA(pkey, dsa);
return 1;
err:
BN_CTX_free(ctx);
DSA_free(dsa);
return 0;
}
开发者ID:libressl-portable,项目名称:openbsd,代码行数:58,代码来源:dsa_ameth.c
示例7: dsa_pub_decode
static int dsa_pub_decode(EVP_PKEY *pkey, X509_PUBKEY *pubkey) {
const uint8_t *p, *pm;
int pklen, pmlen;
int ptype;
void *pval;
ASN1_STRING *pstr;
X509_ALGOR *palg;
ASN1_INTEGER *public_key = NULL;
DSA *dsa = NULL;
if (!X509_PUBKEY_get0_param(NULL, &p, &pklen, &palg, pubkey)) {
return 0;
}
X509_ALGOR_get0(NULL, &ptype, &pval, palg);
if (ptype == V_ASN1_SEQUENCE) {
pstr = pval;
pm = pstr->data;
pmlen = pstr->length;
dsa = d2i_DSAparams(NULL, &pm, pmlen);
if (dsa == NULL) {
OPENSSL_PUT_ERROR(EVP, EVP_R_DECODE_ERROR);
goto err;
}
} else if (ptype == V_ASN1_NULL || ptype == V_ASN1_UNDEF) {
dsa = DSA_new();
if (dsa == NULL) {
OPENSSL_PUT_ERROR(EVP, ERR_R_MALLOC_FAILURE);
goto err;
}
} else {
OPENSSL_PUT_ERROR(EVP, EVP_R_PARAMETER_ENCODING_ERROR);
goto err;
}
public_key = d2i_ASN1_INTEGER(NULL, &p, pklen);
if (public_key == NULL) {
OPENSSL_PUT_ERROR(EVP, EVP_R_DECODE_ERROR);
goto err;
}
dsa->pub_key = ASN1_INTEGER_to_BN(public_key, NULL);
if (dsa->pub_key == NULL) {
OPENSSL_PUT_ERROR(EVP, EVP_R_BN_DECODE_ERROR);
goto err;
}
ASN1_INTEGER_free(public_key);
EVP_PKEY_assign_DSA(pkey, dsa);
return 1;
err:
ASN1_INTEGER_free(public_key);
DSA_free(dsa);
return 0;
}
开发者ID:bheesham,项目名称:boringssl,代码行数:58,代码来源:p_dsa_asn1.c
示例8: dsa_pub_decode
static int dsa_pub_decode(EVP_PKEY *pkey, X509_PUBKEY *pubkey)
{
const unsigned char *p, *pm;
int pklen, pmlen;
int ptype;
void *pval;
ASN1_STRING *pstr;
X509_ALGOR *palg;
ASN1_INTEGER *public_key = NULL;
DSA *dsa = NULL;
if (!X509_PUBKEY_get0_param(NULL, &p, &pklen, &palg, pubkey))
return 0;
X509_ALGOR_get0(NULL, &ptype, &pval, palg);
if (ptype == V_ASN1_SEQUENCE) {
pstr = pval;
pm = pstr->data;
pmlen = pstr->length;
if (!(dsa = d2i_DSAparams(NULL, &pm, pmlen))) {
DSAerr(DSA_F_DSA_PUB_DECODE, DSA_R_DECODE_ERROR);
goto err;
}
} else if ((ptype == V_ASN1_NULL) || (ptype == V_ASN1_UNDEF)) {
if (!(dsa = DSA_new())) {
DSAerr(DSA_F_DSA_PUB_DECODE, ERR_R_MALLOC_FAILURE);
goto err;
}
} else {
DSAerr(DSA_F_DSA_PUB_DECODE, DSA_R_PARAMETER_ENCODING_ERROR);
goto err;
}
if (!(public_key = d2i_ASN1_INTEGER(NULL, &p, pklen))) {
DSAerr(DSA_F_DSA_PUB_DECODE, DSA_R_DECODE_ERROR);
goto err;
}
if (!(dsa->pub_key = ASN1_INTEGER_to_BN(public_key, NULL))) {
DSAerr(DSA_F_DSA_PUB_DECODE, DSA_R_BN_DECODE_ERROR);
goto err;
}
ASN1_INTEGER_free(public_key);
EVP_PKEY_assign_DSA(pkey, dsa);
return 1;
err:
if (public_key)
ASN1_INTEGER_free(public_key);
if (dsa)
DSA_free(dsa);
return 0;
}
开发者ID:1Project,项目名称:SafeBoardMessenger,代码行数:58,代码来源:dsa_ameth.c
示例9: dsa_param_decode
static int dsa_param_decode(EVP_PKEY *pkey, const uint8_t **pder, int derlen) {
DSA *dsa;
dsa = d2i_DSAparams(NULL, pder, derlen);
if (dsa == NULL) {
OPENSSL_PUT_ERROR(EVP, ERR_R_DSA_LIB);
return 0;
}
EVP_PKEY_assign_DSA(pkey, dsa);
return 1;
}
开发者ID:bheesham,项目名称:boringssl,代码行数:10,代码来源:p_dsa_asn1.c
示例10: old_dsa_priv_decode
static int old_dsa_priv_decode(EVP_PKEY *pkey, const uint8_t **pder,
int derlen) {
DSA *dsa;
dsa = d2i_DSAPrivateKey(NULL, pder, derlen);
if (dsa == NULL) {
OPENSSL_PUT_ERROR(EVP, old_dsa_priv_decode, ERR_R_DSA_LIB);
return 0;
}
EVP_PKEY_assign_DSA(pkey, dsa);
return 1;
}
开发者ID:krunalsoni01,项目名称:src,代码行数:11,代码来源:p_dsa_asn1.c
示例11: old_dsa_priv_decode
static int old_dsa_priv_decode(EVP_PKEY *pkey,
const unsigned char **pder, int derlen)
{
DSA *dsa;
if (!(dsa = d2i_DSAPrivateKey(NULL, pder, derlen))) {
DSAerr(DSA_F_OLD_DSA_PRIV_DECODE, ERR_R_DSA_LIB);
return 0;
}
EVP_PKEY_assign_DSA(pkey, dsa);
return 1;
}
开发者ID:1Project,项目名称:SafeBoardMessenger,代码行数:11,代码来源:dsa_ameth.c
示例12: dsa_param_decode
static int dsa_param_decode(EVP_PKEY *pkey,
const unsigned char **pder, int derlen)
{
DSA *dsa;
if (!(dsa = d2i_DSAparams(NULL, pder, derlen))) {
DSAerr(DSA_F_DSA_PARAM_DECODE, ERR_R_DSA_LIB);
return 0;
}
EVP_PKEY_assign_DSA(pkey, dsa);
return 1;
}
开发者ID:1Project,项目名称:SafeBoardMessenger,代码行数:11,代码来源:dsa_ameth.c
示例13: switch
void pki_evp::generate(int bits, int type, QProgressBar *progress, int curve_nid)
{
RSA *rsakey;
DSA *dsakey;
EC_KEY *eckey;
progress->setMinimum(0);
progress->setMaximum(100);
progress->setValue(50);
switch (type) {
case EVP_PKEY_RSA:
rsakey = RSA_generate_key(bits, 0x10001, inc_progress_bar,
progress);
if (rsakey)
EVP_PKEY_assign_RSA(key, rsakey);
break;
case EVP_PKEY_DSA:
progress->setMaximum(500);
dsakey = DSA_generate_parameters(bits, NULL, 0, NULL, NULL,
inc_progress_bar, progress);
DSA_generate_key(dsakey);
if (dsakey)
EVP_PKEY_assign_DSA(key, dsakey);
break;
case EVP_PKEY_EC:
EC_GROUP *group = EC_GROUP_new_by_curve_name(curve_nid);
if (!group)
break;
eckey = EC_KEY_new();
if (eckey == NULL) {
EC_GROUP_free(group);
break;
}
EC_GROUP_set_asn1_flag(group, 1);
if (EC_KEY_set_group(eckey, group)) {
if (EC_KEY_generate_key(eckey)) {
EVP_PKEY_assign_EC_KEY(key, eckey);
EC_GROUP_free(group);
break;
}
}
EC_KEY_free(eckey);
EC_GROUP_free(group);
break;
}
pki_openssl_error();
encryptKey();
}
开发者ID:J-Javan,项目名称:xca,代码行数:49,代码来源:pki_evp.cpp
示例14: generate_dsa_keypair
static int generate_dsa_keypair(EVP_PKEY* pkey, const keymaster_dsa_keygen_params_t* dsa_params) {
if (dsa_params->key_size < 512) {
ALOGI("Requested DSA key size is too small (<512)");
return -1;
}
Unique_DSA dsa(DSA_new());
if (dsa_params->generator_len == 0 || dsa_params->prime_p_len == 0 ||
dsa_params->prime_q_len == 0 || dsa_params->generator == NULL ||
dsa_params->prime_p == NULL || dsa_params->prime_q == NULL) {
if (DSA_generate_parameters_ex(dsa.get(), dsa_params->key_size, NULL, 0, NULL, NULL,
NULL) != 1) {
logOpenSSLError("generate_dsa_keypair");
return -1;
}
} else {
dsa->g = BN_bin2bn(dsa_params->generator, dsa_params->generator_len, NULL);
if (dsa->g == NULL) {
logOpenSSLError("generate_dsa_keypair");
return -1;
}
dsa->p = BN_bin2bn(dsa_params->prime_p, dsa_params->prime_p_len, NULL);
if (dsa->p == NULL) {
logOpenSSLError("generate_dsa_keypair");
return -1;
}
dsa->q = BN_bin2bn(dsa_params->prime_q, dsa_params->prime_q_len, NULL);
if (dsa->q == NULL) {
logOpenSSLError("generate_dsa_keypair");
return -1;
}
}
if (DSA_generate_key(dsa.get()) != 1) {
logOpenSSLError("generate_dsa_keypair");
return -1;
}
if (EVP_PKEY_assign_DSA(pkey, dsa.get()) == 0) {
logOpenSSLError("generate_dsa_keypair");
return -1;
}
release_because_ownership_transferred(dsa);
return 0;
}
开发者ID:LordNerevar,项目名称:system_security,代码行数:49,代码来源:keymaster_openssl.cpp
示例15: pkey_dsa_keygen
static int pkey_dsa_keygen(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey)
{
DSA *dsa = NULL;
if (ctx->pkey == NULL) {
DSAerr(DSA_F_PKEY_DSA_KEYGEN, DSA_R_NO_PARAMETERS_SET);
return 0;
}
dsa = DSA_new();
if (dsa == NULL)
return 0;
EVP_PKEY_assign_DSA(pkey, dsa);
/* Note: if error return, pkey is freed by parent routine */
if (!EVP_PKEY_copy_parameters(pkey, ctx->pkey))
return 0;
return DSA_generate_key(pkey->pkey.dsa);
}
开发者ID:AlexanderPankiv,项目名称:node,代码行数:16,代码来源:dsa_pmeth.c
示例16: isns_dsa_decode_public
EVP_PKEY *
isns_dsa_decode_public(const void *ptr, size_t len)
{
const unsigned char *der = ptr;
EVP_PKEY *evp;
DSA *dsa;
/* Assigning ptr to a temporary variable avoids a silly
* compiled warning about type-punning. */
dsa = d2i_DSA_PUBKEY(NULL, &der, len);
if (dsa == NULL)
return NULL;
evp = EVP_PKEY_new();
EVP_PKEY_assign_DSA(evp, dsa);
return evp;
}
开发者ID:open-iscsi,项目名称:open-isns,代码行数:17,代码来源:pki.c
示例17: dsa_create_pkey
/*!
* \brief Create DSA private key from key parameters.
* \see rsa_create_pkey
*/
static int dsa_create_pkey(const knot_key_params_t *params, EVP_PKEY *key)
{
assert(key);
DSA *dsa = DSA_new();
if (dsa == NULL)
return KNOT_ENOMEM;
dsa->p = knot_b64_to_bignum(params->prime);
dsa->q = knot_b64_to_bignum(params->subprime);
dsa->g = knot_b64_to_bignum(params->base);
dsa->priv_key = knot_b64_to_bignum(params->private_value);
dsa->pub_key = knot_b64_to_bignum(params->public_value);
if (!EVP_PKEY_assign_DSA(key, dsa)) {
DSA_free(dsa);
return KNOT_DNSSEC_EASSIGN_KEY;
}
return KNOT_EOK;
}
开发者ID:stribika,项目名称:curveprotect,代码行数:25,代码来源:dnssec.c
示例18: EVP_PKEY_new
static EVP_PKEY *old_priv_decode(CBS *cbs, int type) {
EVP_PKEY *ret = EVP_PKEY_new();
if (ret == NULL) {
return NULL;
}
switch (type) {
case EVP_PKEY_EC: {
EC_KEY *ec_key = EC_KEY_parse_private_key(cbs, NULL);
if (ec_key == NULL || !EVP_PKEY_assign_EC_KEY(ret, ec_key)) {
EC_KEY_free(ec_key);
goto err;
}
return ret;
}
case EVP_PKEY_DSA: {
DSA *dsa = DSA_parse_private_key(cbs);
if (dsa == NULL || !EVP_PKEY_assign_DSA(ret, dsa)) {
DSA_free(dsa);
goto err;
}
return ret;
}
case EVP_PKEY_RSA: {
RSA *rsa = RSA_parse_private_key(cbs);
if (rsa == NULL || !EVP_PKEY_assign_RSA(ret, rsa)) {
RSA_free(rsa);
goto err;
}
return ret;
}
default:
OPENSSL_PUT_ERROR(EVP, EVP_R_UNKNOWN_PUBLIC_KEY_TYPE);
goto err;
}
err:
EVP_PKEY_free(ret);
return NULL;
}
开发者ID:AadityaDev,项目名称:AadityaDev.github.io,代码行数:40,代码来源:evp_asn1.c
示例19: FIPS_selftest_dsa
int FIPS_selftest_dsa()
{
DSA *dsa = NULL;
EVP_PKEY *pk = NULL;
int ret = 0;
dsa = DSA_new();
if (dsa == NULL)
goto err;
fips_load_key_component(dsa, p, dsa_test_2048);
fips_load_key_component(dsa, q, dsa_test_2048);
fips_load_key_component(dsa, g, dsa_test_2048);
fips_load_key_component(dsa, pub_key, dsa_test_2048);
fips_load_key_component(dsa, priv_key, dsa_test_2048);
if (corrupt_dsa)
BN_set_bit(dsa->pub_key, 2047);
if ((pk = EVP_PKEY_new()) == NULL)
goto err;
EVP_PKEY_assign_DSA(pk, dsa);
if (!fips_pkey_signature_test(pk, NULL, 0,
NULL, 0, EVP_sha256(), 0, "DSA SHA256"))
goto err;
ret = 1;
err:
if (pk)
EVP_PKEY_free(pk);
else if (dsa)
DSA_free(dsa);
return ret;
}
开发者ID:davidlt,项目名称:openssl-fedora,代码行数:37,代码来源:fips_dsa_selftest.c
示例20: isns_dsa_generate_key
/*
* DSA key generation
*/
EVP_PKEY *
isns_dsa_generate_key(void)
{
EVP_PKEY *pkey;
DSA *dsa = NULL;
if (!(dsa = isns_dsa_load_params(isns_config.ic_dsa.param_file)))
goto failed;
if (!DSA_generate_key(dsa)) {
isns_dsasig_report_errors("Failed to generate DSA key",
isns_error);
goto failed;
}
pkey = EVP_PKEY_new();
EVP_PKEY_assign_DSA(pkey, dsa);
return pkey;
failed:
if (dsa)
DSA_free(dsa);
return NULL;
}
开发者ID:open-iscsi,项目名称:open-isns,代码行数:27,代码来源:pki.c
注:本文中的EVP_PKEY_assign_DSA函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论