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


C++ ASN1_TYPE_free函数代码示例

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


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

示例1: do_generate

static int do_generate(BIO *bio, char *genstr, char *genconf, BUF_MEM *buf)
	{
	CONF *cnf = NULL;
	int len;
	long errline;
	unsigned char *p;
	ASN1_TYPE *atyp = NULL;

	if (genconf)
		{
		cnf = NCONF_new(NULL);
		if (!NCONF_load(cnf, genconf, &errline))
			goto conferr;
		if (!genstr)
			genstr = NCONF_get_string(cnf, "default", "asn1");
		if (!genstr)
			{
			BIO_printf(bio, "Can't find 'asn1' in '%s'\n", genconf);
			goto err;
			}
		}

	atyp = ASN1_generate_nconf(genstr, cnf);
	NCONF_free(cnf);

	if (!atyp)
		return -1;

	len = i2d_ASN1_TYPE(atyp, NULL);

	if (len <= 0)
		goto err;

	if (!BUF_MEM_grow(buf,len))
		goto err;

	p=(unsigned char *)buf->data;

	i2d_ASN1_TYPE(atyp, &p);

	ASN1_TYPE_free(atyp);
	return len;

	conferr:

	if (errline > 0)
		BIO_printf(bio, "Error on line %ld of config file '%s'\n",
							errline, genconf);
	else
		BIO_printf(bio, "Error loading config file '%s'\n", genconf);

	err:
	NCONF_free(cnf);
	ASN1_TYPE_free(atyp);

	return -1;

	}
开发者ID:0w,项目名称:moai-dev,代码行数:58,代码来源:asn1pars.c

示例2: X509_ALGOR_free

void X509_ALGOR_free(X509_ALGOR *a)
	{
	if (a == NULL) return;
	ASN1_OBJECT_free(a->algorithm);
	ASN1_TYPE_free(a->parameter);
	OPENSSL_free(a);
	}
开发者ID:ahenroid,项目名称:ptptl-0.2,代码行数:7,代码来源:x_algor.c

示例3: openssl_xattr_data

static int openssl_xattr_data(lua_State*L)
{
  X509_ATTRIBUTE* attr = CHECK_OBJECT(1, X509_ATTRIBUTE, "openssl.x509_attribute");
  if (lua_type(L, 2) == LUA_TSTRING)
  {
    int attrtype = luaL_checkint(L, 2);
    size_t size;
    int ret;
    const char *data = luaL_checklstring(L, 3, &size);
    if (attr->single)
      ASN1_TYPE_free((ASN1_TYPE*)attr->value.ptr);
    else
      sk_ASN1_TYPE_pop_free(attr->value.set, ASN1_TYPE_free);
    attr->value.ptr = NULL;

    ret = X509_ATTRIBUTE_set1_data(attr, attrtype, data, size);
    return openssl_pushresult(L, ret);
  }
  else
  {
    int idx = luaL_checkint(L, 2);
    int attrtype = luaL_checkint(L, 3);
    ASN1_STRING *as = (ASN1_STRING *)X509_ATTRIBUTE_get0_data(attr, idx, attrtype, NULL);
    as = ASN1_STRING_dup(as);
    PUSH_OBJECT(as, "openssl.asn1_string");
    return 1;
  }
}
开发者ID:witchu,项目名称:lua-openssl,代码行数:28,代码来源:xattrs.c

示例4: X509_ALGOR_set0

int X509_ALGOR_set0(X509_ALGOR *alg, ASN1_OBJECT *aobj, int ptype, void *pval)
	{
	if (!alg)
		return 0;
	if (ptype != V_ASN1_UNDEF)
		{
		if (alg->parameter == NULL)
			alg->parameter = ASN1_TYPE_new();
		if (alg->parameter == NULL)
			return 0;
		}
	if (alg)
		{
		if (alg->algorithm)
			ASN1_OBJECT_free(alg->algorithm);
		alg->algorithm = aobj;
		}
	if (ptype == 0)
		return 1;	
	if (ptype == V_ASN1_UNDEF)
		{
		if (alg->parameter)
			{
			ASN1_TYPE_free(alg->parameter);
			alg->parameter = NULL;
			}
		}
	else
		ASN1_TYPE_set(alg->parameter, ptype, pval);
	return 1;
	}
开发者ID:002301,项目名称:node,代码行数:31,代码来源:x_algor.c

示例5: PKCS12_SAFEBAG_free

void PKCS12_SAFEBAG_free (PKCS12_SAFEBAG *a)
{
	if (a == NULL) return;
	switch (OBJ_obj2nid(a->type)) {

		case NID_keyBag:
			PKCS8_PRIV_KEY_INFO_free (a->value.keybag);
		break;

		case NID_pkcs8ShroudedKeyBag:
			X509_SIG_free (a->value.shkeybag);
		break;

		case NID_certBag:
		case NID_crlBag:
		case NID_secretBag:
			PKCS12_BAGS_free (a->value.bag);
		break;

		default:
			ASN1_TYPE_free (a->value.other);
		break;
	}

	ASN1_OBJECT_free (a->type);
	sk_X509_ATTRIBUTE_pop_free (a->attrib, X509_ATTRIBUTE_free);
	OPENSSL_free (a);
}
开发者ID:jhbsz,项目名称:actiontec_opensource_mi424wr-rev-acd-56-0-10-14-4,代码行数:28,代码来源:p12_sbag.c

示例6: X509_ATTRIBUTE_create

X509_ATTRIBUTE *
X509_ATTRIBUTE_create(int nid, int atrtype, void *value)
{
	X509_ATTRIBUTE *ret = NULL;
	ASN1_TYPE *val = NULL;

	if ((ret = X509_ATTRIBUTE_new()) == NULL)
		return (NULL);
	ret->object = OBJ_nid2obj(nid);
	ret->single = 0;
	if ((ret->value.set = sk_ASN1_TYPE_new_null()) == NULL)
		goto err;
	if ((val = ASN1_TYPE_new()) == NULL)
		goto err;
	if (!sk_ASN1_TYPE_push(ret->value.set, val))
		goto err;

	ASN1_TYPE_set(val, atrtype, value);
	return (ret);

err:
	if (ret != NULL)
		X509_ATTRIBUTE_free(ret);
	if (val != NULL)
		ASN1_TYPE_free(val);
	return (NULL);
}
开发者ID:MiKTeX,项目名称:miktex,代码行数:27,代码来源:x_attrib.c

示例7: GENERAL_NAME_free

void GENERAL_NAME_free(GENERAL_NAME *a)
{
	if (a == NULL) return;
	switch(a->type) {
		case GEN_X400:
		case GEN_EDIPARTY:
		ASN1_TYPE_free(a->d.other);
		break;

		case GEN_OTHERNAME:
		OTHERNAME_free(a->d.otherName);
		break;

		case GEN_EMAIL:
		case GEN_DNS:
		case GEN_URI:

		M_ASN1_IA5STRING_free(a->d.ia5);
		break;

		case GEN_DIRNAME:
		X509_NAME_free(a->d.dirn);
		break;

		case GEN_IPADD:
		M_ASN1_OCTET_STRING_free(a->d.ip);
		break;
	
		case GEN_RID:
		ASN1_OBJECT_free(a->d.rid);
		break;

	}
	OPENSSL_free (a);
}
开发者ID:jhbsz,项目名称:actiontec_opensource_mi424wr-rev-acd-56-0-10-14-4,代码行数:35,代码来源:v3_genn.c

示例8: openssl_xattr_data

static int openssl_xattr_data(lua_State*L)
{
  X509_ATTRIBUTE* attr = CHECK_OBJECT(1, X509_ATTRIBUTE, "openssl.x509_attribute");
  if (lua_type(L, 2) == LUA_TSTRING)
  {
    int attrtype = luaL_checkint(L, 2);
    size_t size;
    int ret;
    const char *data = luaL_checklstring(L, 3, &size);
#if OPENSSL_VERSION_NUMBER < 0x10100000L
    if (X509_ATTRIBUTE_count(attr) == 1)
      ASN1_TYPE_free((ASN1_TYPE*)attr->value.ptr);
    else
      sk_ASN1_TYPE_pop_free(attr->value.set, ASN1_TYPE_free);
    attr->value.ptr = NULL;
#else
#endif
    ret = X509_ATTRIBUTE_set1_data(attr, attrtype, data, size);
    return openssl_pushresult(L, ret);
  }
  else
  {
    int idx = luaL_checkint(L, 2);
    int attrtype = luaL_checkint(L, 3);
    ASN1_STRING *as = (ASN1_STRING *)X509_ATTRIBUTE_get0_data(attr, idx, attrtype, NULL);
    PUSH_ASN1_STRING(L, as);
    return 1;
  }
}
开发者ID:imzyxwvu,项目名称:lua-openssl,代码行数:29,代码来源:xattrs.c

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

示例10: do_generate

static int do_generate(char *genstr, const char *genconf, BUF_MEM *buf)
{
    CONF *cnf = NULL;
    int len;
    unsigned char *p;
    ASN1_TYPE *atyp = NULL;

    if (genconf) {
        if ((cnf = app_load_config(genconf)) == NULL)
            goto err;
        if (!genstr)
            genstr = NCONF_get_string(cnf, "default", "asn1");
        if (!genstr) {
            BIO_printf(bio_err, "Can't find 'asn1' in '%s'\n", genconf);
            goto err;
        }
    }

    atyp = ASN1_generate_nconf(genstr, cnf);
    NCONF_free(cnf);
    cnf = NULL;

    if (!atyp)
        return -1;

    len = i2d_ASN1_TYPE(atyp, NULL);

    if (len <= 0)
        goto err;

    if (!BUF_MEM_grow(buf, len))
        goto err;

    p = (unsigned char *)buf->data;

    i2d_ASN1_TYPE(atyp, &p);

    ASN1_TYPE_free(atyp);
    return len;

 err:
    NCONF_free(cnf);
    ASN1_TYPE_free(atyp);
    return -1;
}
开发者ID:Frrank1,项目名称:node,代码行数:45,代码来源:asn1pars.c

示例11: PBKDF2PARAM_free

void PBKDF2PARAM_free (PBKDF2PARAM *a)
{
	if(a==NULL) return;
	ASN1_TYPE_free(a->salt);
	M_ASN1_INTEGER_free(a->iter);
	M_ASN1_INTEGER_free(a->keylength);
	X509_ALGOR_free(a->prf);
	OPENSSL_free (a);
}
开发者ID:jhbsz,项目名称:actiontec_opensource_mi424wr-rev-acd-56-0-10-14-4,代码行数:9,代码来源:p5_pbev2.c

示例12: ASN1err

X509_ALGOR *PKCS5_pbe_set(int alg, int iter, unsigned char *salt,
	     int saltlen)
{
	PBEPARAM *pbe=NULL;
	ASN1_OBJECT *al;
	X509_ALGOR *algor;
	ASN1_TYPE *astype=NULL;

	if (!(pbe = PBEPARAM_new ())) {
		ASN1err(ASN1_F_PKCS5_PBE_SET,ERR_R_MALLOC_FAILURE);
		goto err;
	}
	if(iter <= 0) iter = PKCS5_DEFAULT_ITER;
	if (!ASN1_INTEGER_set(pbe->iter, iter)) {
		ASN1err(ASN1_F_PKCS5_PBE_SET,ERR_R_MALLOC_FAILURE);
		goto err;
	}
	if (!saltlen) saltlen = PKCS5_SALT_LEN;
	if (!(pbe->salt->data = OPENSSL_malloc (saltlen))) {
		ASN1err(ASN1_F_PKCS5_PBE_SET,ERR_R_MALLOC_FAILURE);
		goto err;
	}
	pbe->salt->length = saltlen;
	if (salt) memcpy (pbe->salt->data, salt, saltlen);
	else if (RAND_pseudo_bytes (pbe->salt->data, saltlen) < 0)
		goto err;

	if (!(astype = ASN1_TYPE_new())) {
		ASN1err(ASN1_F_PKCS5_PBE_SET,ERR_R_MALLOC_FAILURE);
		goto err;
	}

	astype->type = V_ASN1_SEQUENCE;
	if(!ASN1_pack_string_of(PBEPARAM, pbe, i2d_PBEPARAM,
				&astype->value.sequence)) {
		ASN1err(ASN1_F_PKCS5_PBE_SET,ERR_R_MALLOC_FAILURE);
		goto err;
	}
	PBEPARAM_free (pbe);
	pbe = NULL;
	
	al = OBJ_nid2obj(alg); /* never need to free al */
	if (!(algor = X509_ALGOR_new())) {
		ASN1err(ASN1_F_PKCS5_PBE_SET,ERR_R_MALLOC_FAILURE);
		goto err;
	}
	ASN1_OBJECT_free(algor->algorithm);
	algor->algorithm = al;
	algor->parameter = astype;

	return (algor);
err:
	if (pbe != NULL) PBEPARAM_free(pbe);
	if (astype != NULL) ASN1_TYPE_free(astype);
	return NULL;
}
开发者ID:174high,项目名称:openssl-0.9.8e_linux_porting,代码行数:56,代码来源:p5_pbe.c

示例13: X509_ATTRIBUTE_free

void X509_ATTRIBUTE_free(X509_ATTRIBUTE *a)
{
    if (a == NULL) return;
    ASN1_OBJECT_free(a->object);
    if (a->set)
        sk_ASN1_TYPE_pop_free(a->value.set,ASN1_TYPE_free);
    else
        ASN1_TYPE_free(a->value.single);
    OPENSSL_free(a);
}
开发者ID:jhbsz,项目名称:actiontec_opensource_mi424wr-rev-acd-56-0-10-14-4,代码行数:10,代码来源:x_attrib.c

示例14: ASN1_generate_v3

static unsigned char *generic_asn1(char *value, X509V3_CTX *ctx, long *ext_len)
	{
	ASN1_TYPE *typ;
	unsigned char *ext_der = NULL;
	typ = ASN1_generate_v3(value, ctx);
	if (typ == NULL)
		return NULL;
	*ext_len = i2d_ASN1_TYPE(typ, &ext_der);
	ASN1_TYPE_free(typ);
	return ext_der;
	}
开发者ID:millken,项目名称:zhuxianB30,代码行数:11,代码来源:v3_conf.c

示例15: ossl_ASN1_TYPE_free

static void
ossl_ASN1_TYPE_free(ASN1_TYPE *a)
{
#if OPENSSL_VERSION_NUMBER < 0x00907000L
    if(!a) return;
    if(a->type == V_ASN1_BOOLEAN){
        OPENSSL_free(a);
        return;
    }
#endif
    ASN1_TYPE_free(a);
}
开发者ID:DocPsy,项目名称:MacRuby,代码行数:12,代码来源:ossl_asn1.c


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