本文整理汇总了C++中ASN1_OBJECT_free函数的典型用法代码示例。如果您正苦于以下问题:C++ ASN1_OBJECT_free函数的具体用法?C++ ASN1_OBJECT_free怎么用?C++ ASN1_OBJECT_free使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ASN1_OBJECT_free函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cms_enveloped_data_init
static CMS_EnvelopedData *
cms_enveloped_data_init(CMS_ContentInfo *cms)
{
if (cms->d.other == NULL) {
cms->d.envelopedData = M_ASN1_new_of(CMS_EnvelopedData);
if (!cms->d.envelopedData) {
CMSerr(CMS_F_CMS_ENVELOPED_DATA_INIT,
ERR_R_MALLOC_FAILURE);
return NULL;
}
cms->d.envelopedData->version = 0;
cms->d.envelopedData->encryptedContentInfo->contentType =
OBJ_nid2obj(NID_pkcs7_data);
ASN1_OBJECT_free(cms->contentType);
cms->contentType = OBJ_nid2obj(NID_pkcs7_enveloped);
return cms->d.envelopedData;
}
return cms_get0_enveloped(cms);
}
示例2: X509_add1_trust_object
int X509_add1_trust_object(X509 *x, ASN1_OBJECT *obj)
{
X509_CERT_AUX *aux;
ASN1_OBJECT *objtmp = NULL;
if (obj) {
objtmp = OBJ_dup(obj);
if (!objtmp)
return 0;
}
if ((aux = aux_get(x)) == NULL)
goto err;
if (aux->trust == NULL
&& (aux->trust = sk_ASN1_OBJECT_new_null()) == NULL)
goto err;
if (!objtmp || sk_ASN1_OBJECT_push(aux->trust, objtmp))
return 1;
err:
ASN1_OBJECT_free(objtmp);
return 0;
}
示例3: gost94_param_decode
static int gost94_param_decode(EVP_PKEY *pkey, const unsigned char **pder,
int derlen)
{
ASN1_OBJECT *obj = NULL;
DSA *dsa = EVP_PKEY_get0(pkey);
int nid;
if (d2i_ASN1_OBJECT(&obj, pder, derlen) == NULL) {
return 0;
}
nid = OBJ_obj2nid(obj);
ASN1_OBJECT_free(obj);
if (!dsa) {
dsa = DSA_new();
if (!EVP_PKEY_assign(pkey, NID_id_GostR3410_94, dsa))
return 0;
}
if (!fill_GOST94_params(dsa, nid))
return 0;
return 1;
}
示例4: gost2001_param_decode
static int gost2001_param_decode(EVP_PKEY *pkey, const unsigned char **pder,
int derlen)
{
ASN1_OBJECT *obj = NULL;
int nid;
EC_KEY *ec = EVP_PKEY_get0(pkey);
if (d2i_ASN1_OBJECT(&obj, pder, derlen) == NULL) {
return 0;
}
nid = OBJ_obj2nid(obj);
ASN1_OBJECT_free(obj);
if (!ec) {
ec = EC_KEY_new();
if (!EVP_PKEY_assign(pkey, NID_id_GostR3410_2001, ec))
return 0;
}
if (!fill_GOST2001_params(ec, nid))
return 0;
return 1;
}
示例5: M_ASN1_new_of
static CMS_SignedData *cms_signed_data_init(CMS_ContentInfo *cms)
{
if (cms->d.other == NULL)
{
cms->d.signedData = M_ASN1_new_of(CMS_SignedData);
if (!cms->d.signedData)
{
CMSerr(CMS_F_CMS_SIGNED_DATA_INIT, ERR_R_MALLOC_FAILURE);
return NULL;
}
cms->d.signedData->version = 1;
cms->d.signedData->encapContentInfo->eContentType =
OBJ_nid2obj(NID_pkcs7_data);
cms->d.signedData->encapContentInfo->partial = 1;
ASN1_OBJECT_free(cms->contentType);
cms->contentType = OBJ_nid2obj(NID_pkcs7_signed);
return cms->d.signedData;
}
return cms_get0_signed(cms);
}
示例6: X509V3err
/* Create a generic extension: for now just handle DER type */
static X509_EXTENSION *v3_generic_extension(const char *ext, char *value,
int crit, int type)
{
unsigned char *ext_der=NULL;
long ext_len;
ASN1_OBJECT *obj=NULL;
ASN1_OCTET_STRING *oct=NULL;
X509_EXTENSION *extension=NULL;
if (!(obj = OBJ_txt2obj(ext, 0)))
{
X509V3err(X509V3_F_V3_GENERIC_EXTENSION,X509V3_R_EXTENSION_NAME_ERROR);
ERR_add_error_data(2, "name=", ext);
goto err;
}
if (!(ext_der = string_to_hex(value, &ext_len)))
{
X509V3err(X509V3_F_V3_GENERIC_EXTENSION,X509V3_R_EXTENSION_VALUE_ERROR);
ERR_add_error_data(2, "value=", value);
goto err;
}
if (!(oct = M_ASN1_OCTET_STRING_new()))
{
X509V3err(X509V3_F_V3_GENERIC_EXTENSION,ERR_R_MALLOC_FAILURE);
goto err;
}
oct->data = ext_der;
oct->length = ext_len;
ext_der = NULL;
extension = X509_EXTENSION_create_by_OBJ(NULL, obj, crit, oct);
err:
ASN1_OBJECT_free(obj);
M_ASN1_OCTET_STRING_free(oct);
if(ext_der) OPENSSL_free(ext_der);
return extension;
}
示例7: memcpy
ASN1_OBJECT *c2i_ASN1_OBJECT(ASN1_OBJECT **a, unsigned char **pp,
long len)
{
ASN1_OBJECT *ret=NULL;
unsigned char *p;
int i;
/* only the ASN1_OBJECTs from the 'table' will have values
* for ->sn or ->ln */
if ((a == NULL) || ((*a) == NULL) ||
!((*a)->flags & ASN1_OBJECT_FLAG_DYNAMIC))
{
if ((ret=ASN1_OBJECT_new()) == NULL) return(NULL);
}
else ret=(*a);
p= *pp;
if ((ret->data == NULL) || (ret->length < len))
{
if (ret->data != NULL) OPENSSL_free(ret->data);
ret->data=(unsigned char *)OPENSSL_malloc(len ? (int)len : 1);
ret->flags|=ASN1_OBJECT_FLAG_DYNAMIC_DATA;
if (ret->data == NULL)
{ i=ERR_R_MALLOC_FAILURE; goto err; }
}
memcpy(ret->data,p,(int)len);
ret->length=(int)len;
ret->sn=NULL;
ret->ln=NULL;
/* ret->flags=ASN1_OBJECT_FLAG_DYNAMIC; we know it is dynamic */
p+=len;
if (a != NULL) (*a)=ret;
*pp=p;
return(ret);
err:
ASN1err(ASN1_F_D2I_ASN1_OBJECT,i);
if ((ret != NULL) && ((a == NULL) || (*a != ret)))
ASN1_OBJECT_free(ret);
return(NULL);
}
示例8: X509_add1_reject_object
int
X509_add1_reject_object(X509 *x, ASN1_OBJECT *obj)
{
X509_CERT_AUX *aux;
ASN1_OBJECT *objtmp;
int rc;
if (!(objtmp = OBJ_dup(obj)))
return 0;
if (!(aux = aux_get(x)))
goto err;
if (!aux->reject && !(aux->reject = sk_ASN1_OBJECT_new_null()))
goto err;
rc = sk_ASN1_OBJECT_push(aux->reject, objtmp);
if (rc != 0)
return rc;
err:
ASN1_OBJECT_free(objtmp);
return 0;
}
示例9: openssl_ts_req_policy_id
static int openssl_ts_req_policy_id(lua_State*L)
{
TS_REQ* req = CHECK_OBJECT(1, TS_REQ, "openssl.ts_req");
if (lua_isnone(L, 2))
{
ASN1_OBJECT* obj = TS_REQ_get_policy_id(req);
openssl_push_asn1object(L, obj);
ASN1_OBJECT_free(obj);
return 1;
}
else
{
int nid = openssl_get_nid(L, 2);
ASN1_OBJECT* obj;
int ret;
luaL_argcheck(L, nid != NID_undef, 2, "must be asn1_object object identified");
obj = OBJ_nid2obj(nid);
ret = TS_REQ_set_policy_id(req, obj);
return openssl_pushresult(L, ret);
}
}
示例10: crypto_cert_get_public_key
CRYPTO_PUBLIC_KEY *
crypto_cert_get_public_key(CRYPTO_CERT * cert, uint32 * key_len)
{
#ifdef CRYPTO_OPENSSL
int nid;
CRYPTO_PUBLIC_KEY *lkey;
EVP_PKEY *epk = NULL;
/* For some reason, Microsoft sets the OID of the Public RSA key to
the oid for "MD5 with RSA Encryption" instead of "RSA Encryption"
Kudos to Richard Levitte for the following (intuitive)
lines of code that resets the OID and lets us extract the key. */
nid = OBJ_obj2nid(cert->cert_info->key->algor->algorithm);
if ((nid == NID_md5WithRSAEncryption) || (nid == NID_shaWithRSAEncryption))
{
ASN1_OBJECT_free(cert->cert_info->key->algor->algorithm);
cert->cert_info->key->algor->algorithm = OBJ_nid2obj(NID_rsaEncryption);
}
epk = X509_get_pubkey(cert);
if (NULL == epk)
return NULL;
lkey = RSAPublicKey_dup((RSA *) epk->pkey.ptr);
*key_len = RSA_size(lkey);
EVP_PKEY_free(epk);
return lkey;
#else /* built-in crypto */
return ssl_cert_get_public_key(cert, key_len);
#endif
}
示例11: eckey_pub_encode
static int eckey_pub_encode(X509_PUBKEY *pk, const EVP_PKEY *pkey) {
EC_KEY *ec_key = pkey->pkey.ec;
void *pval = NULL;
int ptype;
uint8_t *penc = NULL, *p;
int penclen;
if (!eckey_param2type(&ptype, &pval, ec_key)) {
OPENSSL_PUT_ERROR(EVP, ERR_R_EC_LIB);
return 0;
}
penclen = i2o_ECPublicKey(ec_key, NULL);
if (penclen <= 0) {
goto err;
}
penc = OPENSSL_malloc(penclen);
if (!penc) {
goto err;
}
p = penc;
penclen = i2o_ECPublicKey(ec_key, &p);
if (penclen <= 0) {
goto err;
}
if (X509_PUBKEY_set0_param(pk, OBJ_nid2obj(EVP_PKEY_EC), ptype, pval, penc,
penclen)) {
return 1;
}
err:
if (ptype == V_ASN1_OBJECT) {
ASN1_OBJECT_free(pval);
} else {
ASN1_STRING_free(pval);
}
if (penc) {
OPENSSL_free(penc);
}
return 0;
}
示例12: has_voms_extension
int
has_voms_extension(const char *certfilepath)
{
ASN1_OBJECT *acseq_oid = NULL;
X509 *cert = NULL;
int position = -1;
int result = -1;
assert (certfilepath != NULL);
acseq_oid = OBJ_txt2obj(ACSEQ_OID, 1);
if (acseq_oid == NULL) {
return result;
}
cert = load_X509_from_file(certfilepath);
if (cert == NULL) {
goto error;
}
position = X509_get_ext_by_OBJ(cert, acseq_oid, -1);
if (position >= 0) {
result = 1;
} else {
result = 0;
}
if (cert != NULL) {
X509_free(cert);
}
error:
if (acseq_oid != NULL) {
ASN1_OBJECT_free(acseq_oid);
}
return result;
}
示例13: get_extension
static PyObject *
get_extension (certificate_x509 *self, PyObject *args, PyObject *keywords)
{
const char *oid = NULL;
const char *name = NULL;
static char *keywordlist[] = { "oid", "name", NULL };
if (!PyArg_ParseTupleAndKeywords (args, keywords, "|ss", keywordlist,
&oid, &name)) {
return NULL;
}
char *value = NULL;
size_t length;
ASN1_OBJECT *obj = NULL;
if (name != NULL) {
obj = get_object_by_name (name);
} else {
obj = get_object_by_oid (oid);
}
if (obj == NULL) {
Py_INCREF (Py_None);
return Py_None;
}
length = get_extension_by_object (self->x509, obj, &value);
ASN1_OBJECT_free (obj);
if (value != NULL) {
PyObject *extension = PyString_FromStringAndSize (value,
length);
free (value);
return extension;
} else {
Py_INCREF (Py_None);
return Py_None;
}
}
示例14: 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) {
ASN1_OBJECT_free(alg->algorithm);
alg->algorithm = aobj;
}
if (ptype == 0)
return 1;
if (ptype == V_ASN1_UNDEF) {
ASN1_TYPE_free(alg->parameter);
alg->parameter = NULL;
} else
ASN1_TYPE_set(alg->parameter, ptype, pval);
return 1;
}
示例15: TS_CONF_set_def_policy
int TS_CONF_set_def_policy(CONF *conf, const char *section,
const char *policy, TS_RESP_CTX *ctx)
{
int ret = 0;
ASN1_OBJECT *policy_obj = NULL;
if (!policy)
policy = NCONF_get_string(conf, section, ENV_DEFAULT_POLICY);
if (!policy) {
ts_CONF_lookup_fail(section, ENV_DEFAULT_POLICY);
goto err;
}
if ((policy_obj = OBJ_txt2obj(policy, 0)) == NULL) {
ts_CONF_invalid(section, ENV_DEFAULT_POLICY);
goto err;
}
if (!TS_RESP_CTX_set_def_policy(ctx, policy_obj))
goto err;
ret = 1;
err:
ASN1_OBJECT_free(policy_obj);
return ret;
}