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


C++ CRYPTO_add函数代码示例

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


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

示例1: RSA_up_ref

int RSA_up_ref(RSA *r)
	{
	int i = CRYPTO_add(&r->references, 1, CRYPTO_LOCK_RSA);
#ifdef REF_PRINT
	REF_PRINT("RSA",r);
#endif
#if 0//def REF_CHECK
	if (i < 2)
		{
		abort();
		}
#endif
	return ((i > 1) ? 1 : 0);
	}
开发者ID:4Fwolf,项目名称:motorola-hawk-kernel-3.4.67,代码行数:14,代码来源:rsa_lib.c

示例2: EC_KEY_up_ref

int EC_KEY_up_ref(EC_KEY *r)
{
    int i = CRYPTO_add(&r->references, 1, CRYPTO_LOCK_EC);
#ifdef REF_PRINT
    REF_PRINT("EC_KEY", r);
#endif
#ifdef REF_CHECK
    if (i < 2) {
        fprintf(stderr, "EC_KEY_up, bad reference count\n");
        abort();
    }
#endif
    return ((i > 1) ? 1 : 0);
}
开发者ID:GH-JY,项目名称:openssl,代码行数:14,代码来源:ec_key.c

示例3: DSA_up_ref

int DSA_up_ref(DSA *r)
{
    int i = CRYPTO_add(&r->references, 1, CRYPTO_LOCK_DSA);
#ifdef REF_PRINT
    REF_PRINT("DSA", r);
#endif
#ifdef REF_CHECK
    if (i < 2) {
        fprintf(stderr, "DSA_up_ref, bad reference count\n");
        abort();
    }
#endif
    return ((i > 1) ? 1 : 0);
}
开发者ID:davidlt,项目名称:openssl-fedora,代码行数:14,代码来源:dsa_lib.c

示例4: CRYPTO_add

X509 *original_SSL_get_peer_certificate(const SSL *ssl)
{
    X509 *r;

    if ((ssl == NULL) || (ssl->session == NULL))
        r=NULL;
    else
        r=ssl->session->peer;

    if (r == NULL) return(r);

    CRYPTO_add(&r->references,1,CRYPTO_LOCK_X509);

    return(r);
}
开发者ID:dardevelin,项目名称:core-1,代码行数:15,代码来源:tls_generic_test.c

示例5: PKCS7_RECIP_INFO_set

int
PKCS7_RECIP_INFO_set(PKCS7_RECIP_INFO *p7i, X509 *x509)
{
	int ret;
	EVP_PKEY *pkey = NULL;
	if (!ASN1_INTEGER_set(p7i->version, 0))
		return 0;
	if (!X509_NAME_set(&p7i->issuer_and_serial->issuer,
	    X509_get_issuer_name(x509)))
		return 0;

	M_ASN1_INTEGER_free(p7i->issuer_and_serial->serial);
	if (!(p7i->issuer_and_serial->serial =
	    M_ASN1_INTEGER_dup(X509_get_serialNumber(x509))))
		return 0;

	pkey = X509_get_pubkey(x509);

	if (!pkey || !pkey->ameth || !pkey->ameth->pkey_ctrl) {
		PKCS7err(PKCS7_F_PKCS7_RECIP_INFO_SET,
		    PKCS7_R_ENCRYPTION_NOT_SUPPORTED_FOR_THIS_KEY_TYPE);
		goto err;
	}

	ret = pkey->ameth->pkey_ctrl(pkey, ASN1_PKEY_CTRL_PKCS7_ENCRYPT,
	    0, p7i);
	if (ret == -2) {
		PKCS7err(PKCS7_F_PKCS7_RECIP_INFO_SET,
		    PKCS7_R_ENCRYPTION_NOT_SUPPORTED_FOR_THIS_KEY_TYPE);
		goto err;
	}
	if (ret <= 0) {
		PKCS7err(PKCS7_F_PKCS7_RECIP_INFO_SET,
		    PKCS7_R_ENCRYPTION_CTRL_FAILURE);
		goto err;
	}

	EVP_PKEY_free(pkey);

	CRYPTO_add(&x509->references, 1, CRYPTO_LOCK_X509);
	p7i->cert = x509;

	return 1;

err:
	if (pkey)
		EVP_PKEY_free(pkey);
	return 0;
}
开发者ID:DiamondLovesYou,项目名称:libressl-pnacl-sys,代码行数:49,代码来源:pk7_lib.c

示例6: ssl_cert_free

void ssl_cert_free(CERT *c)
	{
	int i;

	if(c == NULL)
	    return;

	i=CRYPTO_add(&c->references,-1,CRYPTO_LOCK_SSL_CERT);
#ifdef REF_PRINT
	REF_PRINT("CERT",c);
#endif
	if (i > 0) return;
#ifdef REF_CHECK
	if (i < 0)
		{
		fprintf(stderr,"ssl_cert_free, bad reference count\n");
		abort(); /* ok */
		}
#endif

#ifndef OPENSSL_NO_RSA
	if (c->rsa_tmp) RSA_free(c->rsa_tmp);
#endif
#ifndef OPENSSL_NO_DH
	if (c->dh_tmp) DH_free(c->dh_tmp);
#endif
#ifndef OPENSSL_NO_ECDH
	if (c->ecdh_tmp) EC_KEY_free(c->ecdh_tmp);
#endif

	ssl_cert_clear_certs(c);
	if (c->peer_sigalgs)
		OPENSSL_free(c->peer_sigalgs);
	if (c->conf_sigalgs)
		OPENSSL_free(c->conf_sigalgs);
	if (c->client_sigalgs)
		OPENSSL_free(c->client_sigalgs);
	if (c->shared_sigalgs)
		OPENSSL_free(c->shared_sigalgs);
	if (c->ctypes)
		OPENSSL_free(c->ctypes);
	if (c->verify_store)
		X509_STORE_free(c->verify_store);
	if (c->chain_store)
		X509_STORE_free(c->chain_store);
	if (c->ciphers_raw)
		OPENSSL_free(c->ciphers_raw);
	OPENSSL_free(c);
	}
开发者ID:0culus,项目名称:openssl,代码行数:49,代码来源:ssl_cert.c

示例7: OCSP_request_add1_cert

int OCSP_request_add1_cert(OCSP_REQUEST *req, X509 *cert)
	{
	OCSP_SIGNATURE *sig;
	if (!req->optionalSignature)
		req->optionalSignature = OCSP_SIGNATURE_new();
	sig = req->optionalSignature;
	if (!sig) return 0;
	if (!cert) return 1;
	if (!sig->certs && !(sig->certs = sk_X509_new_null()))
		return 0;

	if(!sk_X509_push(sig->certs, cert)) return 0;
	CRYPTO_add(&cert->references, 1, CRYPTO_LOCK_X509);
	return 1;
	}
开发者ID:Acidburn0zzz,项目名称:openssl,代码行数:15,代码来源:ocsp_cl.c

示例8: LUA_FUNCTION

static LUA_FUNCTION(openssl_bio_pop)
{
  BIO* bio = CHECK_OBJECT(1, BIO, "openssl.bio");
  BIO* end = BIO_pop(bio);
  if (end)
  {
    lua_pushnil(L);
  }
  else
  {
    CRYPTO_add(&end->references, 1, CRYPTO_LOCK_BIO);
    PUSH_OBJECT(end, "openssl.bio");
  }
  return 1;
}
开发者ID:Shaddy1884,项目名称:lua-openssl,代码行数:15,代码来源:bio.c

示例9: DH_up_ref

int DH_up_ref(DH *r)
	{
	int i = CRYPTO_add(&r->references, 1, CRYPTO_LOCK_DH);
#ifdef REF_PRINT
	REF_PRINT("DH",r);
#endif
#ifdef REF_CHECK
	if (i < 2)
		{
		TINYCLR_SSL_FPRINTF(OPENSSL_TYPE__FILE_STDERR, "DH_up, bad reference count\n");
		TINYCLR_SSL_ABORT();
		}
#endif
	return ((i > 1) ? 1 : 0);
	}
开发者ID:EddieGarmon,项目名称:netduino-netmf,代码行数:15,代码来源:dh_lib.cpp

示例10: EVP_PKEY_free

void EVP_PKEY_free(EVP_PKEY *x)
{
    int i;

    if (x == NULL)
        return;

    i = CRYPTO_add(&x->references, -1, CRYPTO_LOCK_EVP_PKEY);
    REF_PRINT_COUNT("EVP_PKEY", x);
    if (i > 0)
        return;
    REF_ASSERT_ISNT(i < 0);
    EVP_PKEY_free_it(x);
    sk_X509_ATTRIBUTE_pop_free(x->attributes, X509_ATTRIBUTE_free);
    OPENSSL_free(x);
}
开发者ID:DarovskikhAndrei,项目名称:openssl,代码行数:16,代码来源:p_lib.c

示例11: ssl_set_pkey

static int ssl_set_pkey(CERT *c, EVP_PKEY *pkey)
{
    int i;
    i = ssl_cert_type(NULL, pkey);
    if (i < 0) {
        SSLerr(SSL_F_SSL_SET_PKEY, SSL_R_UNKNOWN_CERTIFICATE_TYPE);
        return (0);
    }

    if (c->pkeys[i].x509 != NULL) {
        EVP_PKEY *pktmp;
        pktmp = X509_get_pubkey(c->pkeys[i].x509);
        if (pktmp == NULL) {
            SSLerr(SSL_F_SSL_SET_PKEY, ERR_R_MALLOC_FAILURE);
            EVP_PKEY_free(pktmp);
            return 0;
        }
        /*
         * The return code from EVP_PKEY_copy_parameters is deliberately
         * ignored. Some EVP_PKEY types cannot do this.
         */
        EVP_PKEY_copy_parameters(pktmp, pkey);
        EVP_PKEY_free(pktmp);
        ERR_clear_error();

#ifndef OPENSSL_NO_RSA
        /*
         * Don't check the public/private key, this is mostly for smart
         * cards.
         */
        if ((pkey->type == EVP_PKEY_RSA) &&
            (RSA_flags(pkey->pkey.rsa) & RSA_METHOD_FLAG_NO_CHECK)) ;
        else
#endif
        if (!X509_check_private_key(c->pkeys[i].x509, pkey)) {
            X509_free(c->pkeys[i].x509);
            c->pkeys[i].x509 = NULL;
            return 0;
        }
    }

    EVP_PKEY_free(c->pkeys[i].privatekey);
    CRYPTO_add(&pkey->references, 1, CRYPTO_LOCK_EVP_PKEY);
    c->pkeys[i].privatekey = pkey;
    c->key = &(c->pkeys[i]);
    return (1);
}
开发者ID:goofwear,项目名称:openssl,代码行数:47,代码来源:ssl_rsa.c

示例12: PKCS7_SIGNER_INFO_set

int PKCS7_SIGNER_INFO_set(PKCS7_SIGNER_INFO *p7i, X509 *x509, EVP_PKEY *pkey,
	     EVP_MD *dgst)
	{
	char is_dsa;
	if (pkey->type == EVP_PKEY_DSA) is_dsa = 1;
	else is_dsa = 0;
	/* We now need to add another PKCS7_SIGNER_INFO entry */
	ASN1_INTEGER_set(p7i->version,1);
	X509_NAME_set(&p7i->issuer_and_serial->issuer,
		X509_get_issuer_name(x509));

	/* because ASN1_INTEGER_set is used to set a 'long' we will do
	 * things the ugly way. */
	M_ASN1_INTEGER_free(p7i->issuer_and_serial->serial);
	p7i->issuer_and_serial->serial=
		M_ASN1_INTEGER_dup(X509_get_serialNumber(x509));

	/* lets keep the pkey around for a while */
	CRYPTO_add(&pkey->references,1,CRYPTO_LOCK_EVP_PKEY);
	p7i->pkey=pkey;

	/* Set the algorithms */
	if (is_dsa) p7i->digest_alg->algorithm=OBJ_nid2obj(NID_sha1);
	else	
		p7i->digest_alg->algorithm=OBJ_nid2obj(EVP_MD_type(dgst));

	if (p7i->digest_alg->parameter != NULL)
		ASN1_TYPE_free(p7i->digest_alg->parameter);
	if ((p7i->digest_alg->parameter=ASN1_TYPE_new()) == NULL)
		goto err;
	p7i->digest_alg->parameter->type=V_ASN1_NULL;

	p7i->digest_enc_alg->algorithm=OBJ_nid2obj(EVP_PKEY_type(pkey->type));

	if (p7i->digest_enc_alg->parameter != NULL)
		ASN1_TYPE_free(p7i->digest_enc_alg->parameter);
	if(is_dsa) p7i->digest_enc_alg->parameter = NULL;
	else {
		if (!(p7i->digest_enc_alg->parameter=ASN1_TYPE_new()))
			goto err;
		p7i->digest_enc_alg->parameter->type=V_ASN1_NULL;
	}

	return(1);
err:
	return(0);
	}
开发者ID:jhbsz,项目名称:actiontec_opensource_mi424wr-rev-acd-56-0-10-14-4,代码行数:47,代码来源:pk7_lib.c

示例13: DH_free

void DH_free (DH * r)
{
    int i;

    if (r == NULL)
        return;
    i = CRYPTO_add (&r->references, -1, CRYPTO_LOCK_DH);
#ifdef REF_PRINT
    REF_PRINT ("DH", r);
#endif
    if (i > 0)
        return;
#ifdef REF_CHECK
    if (i < 0)
    {
        fprintf (stderr, "DH_free, bad reference count\n");
        abort ();
    }
#endif

    if (r->meth->finish)
        r->meth->finish (r);
#ifndef OPENSSL_NO_ENGINE
    if (r->engine)
        ENGINE_finish (r->engine);
#endif

    CRYPTO_free_ex_data (CRYPTO_EX_INDEX_DH, r, &r->ex_data);

    if (r->p != NULL)
        BN_clear_free (r->p);
    if (r->g != NULL)
        BN_clear_free (r->g);
    if (r->q != NULL)
        BN_clear_free (r->q);
    if (r->j != NULL)
        BN_clear_free (r->j);
    if (r->seed)
        OPENSSL_free (r->seed);
    if (r->counter != NULL)
        BN_clear_free (r->counter);
    if (r->pub_key != NULL)
        BN_clear_free (r->pub_key);
    if (r->priv_key != NULL)
        BN_clear_free (r->priv_key);
    OPENSSL_free (r);
}
开发者ID:274914765,项目名称:C,代码行数:47,代码来源:dh_lib.c

示例14: PKCS7_SIGNER_INFO_set

int PKCS7_SIGNER_INFO_set(PKCS7_SIGNER_INFO *p7i, X509 *x509, EVP_PKEY *pkey,
	     const EVP_MD *dgst)
	{
	int ret;

	/* We now need to add another PKCS7_SIGNER_INFO entry */
	if (!ASN1_INTEGER_set(p7i->version,1))
		goto err;
	if (!X509_NAME_set(&p7i->issuer_and_serial->issuer,
			X509_get_issuer_name(x509)))
		goto err;

	/* because ASN1_INTEGER_set is used to set a 'long' we will do
	 * things the ugly way. */
	M_ASN1_INTEGER_free(p7i->issuer_and_serial->serial);
	if (!(p7i->issuer_and_serial->serial=
			M_ASN1_INTEGER_dup(X509_get_serialNumber(x509))))
		goto err;

	/* lets keep the pkey around for a while */
	CRYPTO_add(&pkey->references,1,CRYPTO_LOCK_EVP_PKEY);
	p7i->pkey=pkey;

	/* Set the algorithms */

	X509_ALGOR_set0(p7i->digest_alg, OBJ_nid2obj(EVP_MD_type(dgst)),
				V_ASN1_NULL, NULL);

	if (pkey->ameth && pkey->ameth->pkey_ctrl)
		{
		ret = pkey->ameth->pkey_ctrl(pkey, ASN1_PKEY_CTRL_PKCS7_SIGN,
						0, p7i);
		if (ret > 0)
			return 1;
		if (ret != -2)
			{
			PKCS7err(PKCS7_F_PKCS7_SIGNER_INFO_SET,
					PKCS7_R_SIGNING_CTRL_FAILURE);
			return 0;
			}
		}
	PKCS7err(PKCS7_F_PKCS7_SIGNER_INFO_SET,
			PKCS7_R_SIGNING_NOT_SUPPORTED_FOR_THIS_KEY_TYPE);
err:
	return 0;
	}
开发者ID:OpenKod,项目名称:src,代码行数:46,代码来源:pk7_lib.c

示例15: EVP_PKEY_free

void
EVP_PKEY_free(EVP_PKEY *x)
{
	int i;

	if (x == NULL)
		return;

	i = CRYPTO_add(&x->references, -1, CRYPTO_LOCK_EVP_PKEY);
	if (i > 0)
		return;

	EVP_PKEY_free_it(x);
	if (x->attributes)
		sk_X509_ATTRIBUTE_pop_free(x->attributes, X509_ATTRIBUTE_free);
	free(x);
}
开发者ID:Basskrapfen,项目名称:openbsd,代码行数:17,代码来源:p_lib.c


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