本文整理汇总了C++中ASN1_OCTET_STRING_free函数的典型用法代码示例。如果您正苦于以下问题:C++ ASN1_OCTET_STRING_free函数的具体用法?C++ ASN1_OCTET_STRING_free怎么用?C++ ASN1_OCTET_STRING_free使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ASN1_OCTET_STRING_free函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: X509_PKEY_free
void X509_PKEY_free(X509_PKEY *x)
{
int i;
if (x == NULL)
return;
i = CRYPTO_add(&x->references, -1, CRYPTO_LOCK_X509_PKEY);
#ifdef REF_PRINT
REF_PRINT("X509_PKEY", x);
#endif
if (i > 0)
return;
#ifdef REF_CHECK
if (i < 0) {
fprintf(stderr, "X509_PKEY_free, bad reference count\n");
abort();
}
#endif
X509_ALGOR_free(x->enc_algor);
ASN1_OCTET_STRING_free(x->enc_pkey);
EVP_PKEY_free(x->dec_pkey);
if (x->key_free)
OPENSSL_free(x->key_data);
OPENSSL_free(x);
}
开发者ID:TheTypoMaster,项目名称:openssl,代码行数:27,代码来源:x_pkey.c
示例2: main
/* Make sure we do the right thing. Add here if you convert ones in tree */
int
main(int argc, char **argv)
{
ASN1_INTEGER_free(NULL);
ASN1_OBJECT_free(NULL);
ASN1_OCTET_STRING_free(NULL);
BIO_free_all(NULL);
DIST_POINT_free(NULL);
EVP_PKEY_free(NULL);
GENERAL_NAME_free(NULL);
GENERAL_SUBTREE_free(NULL);
NAME_CONSTRAINTS_free(NULL);
sk_GENERAL_NAME_pop_free(NULL, GENERAL_NAME_free);
sk_X509_NAME_ENTRY_pop_free(NULL, X509_NAME_ENTRY_free);
X509_NAME_ENTRY_free(NULL);
printf("PASS\n");
return (0);
}
开发者ID:soundsrc,项目名称:git-lfs-server,代码行数:28,代码来源:freenull.c
示例3: PKCS12err
ASN1_OCTET_STRING *PKCS12_item_i2d_encrypt(X509_ALGOR *algor,
const ASN1_ITEM *it,
const char *pass, int passlen,
void *obj, int zbuf)
{
ASN1_OCTET_STRING *oct = NULL;
unsigned char *in = NULL;
int inlen;
if ((oct = ASN1_OCTET_STRING_new()) == NULL) {
PKCS12err(PKCS12_F_PKCS12_ITEM_I2D_ENCRYPT, ERR_R_MALLOC_FAILURE);
goto err;
}
inlen = ASN1_item_i2d(obj, &in, it);
if (!in) {
PKCS12err(PKCS12_F_PKCS12_ITEM_I2D_ENCRYPT, PKCS12_R_ENCODE_ERROR);
goto err;
}
if (!PKCS12_pbe_crypt(algor, pass, passlen, in, inlen, &oct->data,
&oct->length, 1)) {
PKCS12err(PKCS12_F_PKCS12_ITEM_I2D_ENCRYPT, PKCS12_R_ENCRYPT_ERROR);
OPENSSL_free(in);
goto err;
}
if (zbuf)
OPENSSL_cleanse(in, inlen);
OPENSSL_free(in);
return oct;
err:
ASN1_OCTET_STRING_free(oct);
return NULL;
}
开发者ID:tuskitumizhou,项目名称:openssl,代码行数:32,代码来源:p12_decr.c
示例4: d2i_ocsp_nonce
static void *
d2i_ocsp_nonce(void *a, const unsigned char **pp, long length)
{
ASN1_OCTET_STRING *os, **pos;
pos = a;
if (pos == NULL || *pos == NULL) {
os = ASN1_OCTET_STRING_new();
if (os == NULL)
goto err;
} else
os = *pos;
if (ASN1_OCTET_STRING_set(os, *pp, length) == 0)
goto err;
*pp += length;
if (pos != NULL)
*pos = os;
return os;
err:
if (pos == NULL || *pos != os)
ASN1_OCTET_STRING_free(os);
OCSPerror(ERR_R_MALLOC_FAILURE);
return NULL;
}
开发者ID:MiKTeX,项目名称:miktex,代码行数:27,代码来源:v3_ocsp.c
示例5: CMS_set_detached
int CMS_set_detached(CMS_ContentInfo *cms, int detached)
{
ASN1_OCTET_STRING **pos;
pos = CMS_get0_content(cms);
if (!pos)
return 0;
if (detached)
{
if (*pos)
{
ASN1_OCTET_STRING_free(*pos);
*pos = NULL;
}
return 1;
}
if (!*pos)
*pos = ASN1_OCTET_STRING_new();
if (*pos)
{
/* NB: special flag to show content is created and not
* read in.
*/
(*pos)->flags |= ASN1_STRING_FLAG_CONT;
return 1;
}
CMSerr(CMS_F_CMS_SET_DETACHED, ERR_R_MALLOC_FAILURE);
return 0;
}
开发者ID:Chenhx,项目名称:moai-dev,代码行数:28,代码来源:cms_lib.c
示例6: PKCS12_item_i2d_encrypt
X509_SIG *PKCS8_set0_pbe(const char *pass, int passlen,
PKCS8_PRIV_KEY_INFO *p8inf, X509_ALGOR *pbe)
{
X509_SIG *p8;
ASN1_OCTET_STRING *enckey;
enckey =
PKCS12_item_i2d_encrypt(pbe, ASN1_ITEM_rptr(PKCS8_PRIV_KEY_INFO),
pass, passlen, p8inf, 1);
if (!enckey) {
PKCS12err(PKCS12_F_PKCS8_SET0_PBE, PKCS12_R_ENCRYPT_ERROR);
return NULL;
}
p8 = OPENSSL_zalloc(sizeof(*p8));
if (p8 == NULL) {
PKCS12err(PKCS12_F_PKCS8_SET0_PBE, ERR_R_MALLOC_FAILURE);
ASN1_OCTET_STRING_free(enckey);
return NULL;
}
p8->algor = pbe;
p8->digest = enckey;
return p8;
}
开发者ID:Ana06,项目名称:openssl,代码行数:26,代码来源:p12_p8e.c
示例7: pub_decode_gost94
/* ---------- Public key functions * --------------------------------------*/
static int pub_decode_gost94(EVP_PKEY *pk, X509_PUBKEY *pub)
{
X509_ALGOR *palg = NULL;
const unsigned char *pubkey_buf = NULL;
unsigned char *databuf;
ASN1_OBJECT *palgobj = NULL;
int pub_len,i,j;
DSA *dsa;
ASN1_OCTET_STRING *octet= NULL;
if (!X509_PUBKEY_get0_param(&palgobj,&pubkey_buf,&pub_len,
&palg, pub)) return 0;
EVP_PKEY_assign(pk,OBJ_obj2nid(palgobj),NULL);
if (!decode_gost_algor_params(pk,palg)) return 0;
octet = d2i_ASN1_OCTET_STRING(NULL,&pubkey_buf,pub_len);
if (!octet)
{
GOSTerr(GOST_F_PUB_DECODE_GOST94,ERR_R_MALLOC_FAILURE);
return 0;
}
databuf = (unsigned char*)OPENSSL_malloc(octet->length);
for (i=0,j=octet->length-1;i<octet->length;i++,j--)
{
databuf[j]=octet->data[i];
}
dsa = (DSA*)EVP_PKEY_get0(pk);
dsa->pub_key=BN_bin2bn(databuf,octet->length,NULL);
ASN1_OCTET_STRING_free(octet);
OPENSSL_free(databuf);
return 1;
}
开发者ID:AustinWise,项目名称:Netduino-Micro-Framework,代码行数:33,代码来源:gost_ameth.cpp
示例8: PROXYPOLICY_set_policy
/**
* @ingroup proxypolicy
*
* Sets the policy of the PROXYPOLICY
*
* @param proxypolicy the proxy policy to set the policy of
* @param policy the policy to set it to
* @param length the length of the policy
*
* @return 1 on success, 0 on error
*/
int PROXYPOLICY_set_policy(
PROXYPOLICY * proxypolicy,
unsigned char * policy,
int length)
{
if(policy != NULL)
{
unsigned char * copy = malloc(length);
memcpy(copy, policy, length);
if(!proxypolicy->policy)
{
proxypolicy->policy = ASN1_OCTET_STRING_new();
}
ASN1_OCTET_STRING_set(proxypolicy->policy, copy, length);
}
else
{
if(proxypolicy->policy)
{
ASN1_OCTET_STRING_free(proxypolicy->policy);
}
}
return 1;
}
开发者ID:eunsungc,项目名称:globus_toolkit-6.0.1430141288-RAMSES,代码行数:39,代码来源:proxypolicy.c
示例9: get_signed_seq2string
/* For this case, I will malloc the return strings */
static int
get_signed_seq2string(PKCS7_SIGNER_INFO *si, char **str1, char **str2) {
ASN1_TYPE *so;
#if 0
if (signed_seq2string_nid == -1)
signed_seq2string_nid=
OBJ_create("1.9.9999","OID_example","Our example OID");
/* To retrieve */
so=PKCS7_get_signed_attribute(si,signed_seq2string_nid);
if (so && (so->type == V_ASN1_SEQUENCE))
{
ASN1_CTX c;
ASN1_STRING *s;
long length;
ASN1_OCTET_STRING *os1,*os2;
s=so->value.sequence;
c.p=ASN1_STRING_data(s);
c.max=c.p+ASN1_STRING_length(s);
if (!asn1_GetSequence(&c,&length)) GOTO_ERR("") err;
/* Length is the length of the seqence */
c.q=c.p;
if ((os1=d2i_ASN1_OCTET_STRING(NULL,&c.p,c.slen)) == NULL)
GOTO_ERR("");
c.slen-=(c.p-c.q);
c.q=c.p;
if ((os2=d2i_ASN1_OCTET_STRING(NULL,&c.p,c.slen)) == NULL)
GOTO_ERR("");
c.slen-=(c.p-c.q);
if (!asn1_Finish(&c)) GOTO_ERR("") err;
*str1=Malloc(os1->length+1);
*str2=Malloc(os2->length+1);
memcpy(*str1,os1->data,os1->length);
memcpy(*str2,os2->data,os2->length);
(*str1)[os1->length]='\0';
(*str2)[os2->length]='\0';
ASN1_OCTET_STRING_free(os1);
ASN1_OCTET_STRING_free(os2);
return(1);
}
#endif
err:
return(0);
}
开发者ID:gitpan,项目名称:smime,代码行数:48,代码来源:smime-vfy.c
示例10: pub_decode_gost01
static int pub_decode_gost01(EVP_PKEY *pk,X509_PUBKEY *pub)
{
X509_ALGOR *palg = NULL;
const unsigned char *pubkey_buf = NULL;
unsigned char *databuf;
ASN1_OBJECT *palgobj = NULL;
int pub_len,i,j;
EC_POINT *pub_key;
BIGNUM *X,*Y;
ASN1_OCTET_STRING *octet= NULL;
int len;
const EC_GROUP *group;
if (!X509_PUBKEY_get0_param(&palgobj,&pubkey_buf,&pub_len,
&palg, pub)) return 0;
EVP_PKEY_assign(pk,OBJ_obj2nid(palgobj),NULL);
if (!decode_gost_algor_params(pk,palg)) return 0;
group = EC_KEY_get0_group(EVP_PKEY_get0(pk));
octet = d2i_ASN1_OCTET_STRING(NULL,&pubkey_buf,pub_len);
if (!octet)
{
GOSTerr(GOST_F_PUB_DECODE_GOST01,ERR_R_MALLOC_FAILURE);
return 0;
}
databuf = OPENSSL_malloc(octet->length);
for (i=0,j=octet->length-1;i<octet->length;i++,j--)
{
databuf[j]=octet->data[i];
}
len=octet->length/2;
ASN1_OCTET_STRING_free(octet);
Y= getbnfrombuf(databuf,len);
X= getbnfrombuf(databuf+len,len);
OPENSSL_free(databuf);
pub_key = EC_POINT_new(group);
if (!EC_POINT_set_affine_coordinates_GFp(group
,pub_key,X,Y,NULL))
{
GOSTerr(GOST_F_PUB_DECODE_GOST01,
ERR_R_EC_LIB);
EC_POINT_free(pub_key);
BN_free(X);
BN_free(Y);
return 0;
}
BN_free(X);
BN_free(Y);
if (!EC_KEY_set_public_key(EVP_PKEY_get0(pk),pub_key))
{
GOSTerr(GOST_F_PUB_DECODE_GOST01,
ERR_R_EC_LIB);
EC_POINT_free(pub_key);
return 0;
}
EC_POINT_free(pub_key);
return 1;
}
开发者ID:0culus,项目名称:openssl,代码行数:59,代码来源:gost_ameth.c
示例11: get_extension_by_object
static size_t
get_extension_by_object (X509 *x509, ASN1_OBJECT *obj, char **output)
{
int pos = X509_get_ext_by_OBJ (x509, obj, -1);
if (pos < 0) {
return 0;
}
X509_EXTENSION *ext = X509_get_ext (x509, pos);
int tag;
long len;
int tc;
const unsigned char *p = ext->value->data;
ASN1_get_object (&p, &len, &tag, &tc, ext->value->length);
size_t size;
switch (tag) {
case V_ASN1_UTF8STRING:
{
ASN1_UTF8STRING *str =
ASN1_item_unpack (ext->value,
ASN1_ITEM_rptr
(ASN1_UTF8STRING));
*output = strndup ((const char *)
ASN1_STRING_data (str),
str->length);
size = str->length;
ASN1_UTF8STRING_free (str);
return size;
}
case V_ASN1_OCTET_STRING:
{
ASN1_OCTET_STRING *octstr =
ASN1_item_unpack (ext->value,
ASN1_ITEM_rptr
(ASN1_OCTET_STRING));
*output = malloc (octstr->length);
memcpy (*output, octstr->data, octstr->length);
size = octstr->length;
ASN1_OCTET_STRING_free (octstr);
return size;
}
default:
{
BIO *bio = BIO_new (BIO_s_mem ());
X509V3_EXT_print (bio, ext, 0, 0);
size_t size = BIO_ctrl_pending (bio);
char *buf = malloc (sizeof (char) * size);
BIO_read (bio, buf, size);
*output = buf;
BIO_free (bio);
return size;
}
}
}
开发者ID:jlsherrill,项目名称:python-rhsm,代码行数:57,代码来源:certificate.c
示例12: hmac_key_free
static void hmac_key_free(EVP_PKEY *pkey)
{
ASN1_OCTET_STRING *os = (ASN1_OCTET_STRING *)pkey->pkey.ptr;
if (os) {
if (os->data)
OPENSSL_cleanse(os->data, os->length);
ASN1_OCTET_STRING_free(os);
}
}
开发者ID:bbidd985,项目名称:IEEE_Taggant_System,代码行数:9,代码来源:hm_ameth.c
示例13: hmac_key_free
static void hmac_key_free(EVP_PKEY *pkey)
{
ASN1_OCTET_STRING *os = (ASN1_OCTET_STRING *)pkey->pkey.ptr;
if (os) {
if (os->data)
vigortls_zeroize(os->data, os->length);
ASN1_OCTET_STRING_free(os);
}
}
开发者ID:vigortls,项目名称:vigortls,代码行数:9,代码来源:hm_ameth.c
示例14: hmac_key_free
static void hmac_key_free(EVP_PKEY *pkey)
{
ASN1_OCTET_STRING *os = EVP_PKEY_get0(pkey);
if (os) {
if (os->data)
OPENSSL_cleanse(os->data, os->length);
ASN1_OCTET_STRING_free(os);
}
}
开发者ID:1234-,项目名称:openssl,代码行数:9,代码来源:hm_ameth.c
示例15: siphash_key_free
static void siphash_key_free(EVP_PKEY *pkey)
{
ASN1_OCTET_STRING *os = EVP_PKEY_get0(pkey);
if (os != NULL) {
if (os->data != NULL)
OPENSSL_cleanse(os->data, os->length);
ASN1_OCTET_STRING_free(os);
}
}
开发者ID:Bilibili,项目名称:openssl,代码行数:10,代码来源:siphash_ameth.c
示例16: ASN1_item_i2d
static X509_EXTENSION *do_ext_i2d(const X509V3_EXT_METHOD *method,
int ext_nid, int crit, void *ext_struc)
{
unsigned char *ext_der = NULL;
int ext_len;
ASN1_OCTET_STRING *ext_oct = NULL;
X509_EXTENSION *ext;
/* Convert internal representation to DER */
if (method->it) {
ext_der = NULL;
ext_len =
ASN1_item_i2d(ext_struc, &ext_der, ASN1_ITEM_ptr(method->it));
if (ext_len < 0)
goto merr;
} else {
unsigned char *p;
ext_len = method->i2d(ext_struc, NULL);
if ((ext_der = OPENSSL_malloc(ext_len)) == NULL)
goto merr;
p = ext_der;
method->i2d(ext_struc, &p);
}
if ((ext_oct = ASN1_OCTET_STRING_new()) == NULL)
goto merr;
ext_oct->data = ext_der;
ext_der = NULL;
ext_oct->length = ext_len;
ext = X509_EXTENSION_create_by_NID(NULL, ext_nid, crit, ext_oct);
if (!ext)
goto merr;
ASN1_OCTET_STRING_free(ext_oct);
return ext;
merr:
X509V3err(X509V3_F_DO_EXT_I2D, ERR_R_MALLOC_FAILURE);
OPENSSL_free(ext_der);
ASN1_OCTET_STRING_free(ext_oct);
return NULL;
}
开发者ID:regoecuaycong,项目名称:openssl,代码行数:43,代码来源:v3_conf.c
示例17: throw
SubjectKeyIdentifierExtension::SubjectKeyIdentifierExtension(X509_EXTENSION *ext)
throw (CertificationException) : Extension(ext)
{
ASN1_OCTET_STRING *octetString;
if (OBJ_obj2nid(ext->object) != NID_subject_key_identifier)
{
throw CertificationException(CertificationException::INVALID_TYPE, "SubjectKeyIdentifierExtension::SubjectKeyIdentifierExtension");
}
octetString = (ASN1_OCTET_STRING *)X509V3_EXT_d2i(ext);
keyIdentifier = ByteArray(octetString->data, octetString->length);
ASN1_OCTET_STRING_free(octetString);
}
开发者ID:GNakayama,项目名称:libcryptosec,代码行数:12,代码来源:SubjectKeyIdentifierExtension.cpp
示例18: X509_PKEY_free
void X509_PKEY_free(X509_PKEY *x)
{
if (x == NULL)
return;
X509_ALGOR_free(x->enc_algor);
ASN1_OCTET_STRING_free(x->enc_pkey);
EVP_PKEY_free(x->dec_pkey);
if (x->key_free)
OPENSSL_free(x->key_data);
OPENSSL_free(x);
}
开发者ID:RTEMS,项目名称:rtems-libbsd,代码行数:12,代码来源:x_pkey.c
示例19: ASN1_TYPE_get_int_octetstring
/* int max_len: for returned value */
int ASN1_TYPE_get_int_octetstring(ASN1_TYPE *a, long *num,
unsigned char *data, int max_len)
{
int ret = -1, n;
ASN1_INTEGER *ai = NULL;
ASN1_OCTET_STRING *os = NULL;
const unsigned char *p;
long length;
ASN1_const_CTX c;
if ((a->type != V_ASN1_SEQUENCE) || (a->value.sequence == NULL)) {
goto err;
}
p = ASN1_STRING_data(a->value.sequence);
length = ASN1_STRING_length(a->value.sequence);
c.pp = &p;
c.p = p;
c.max = p + length;
c.error = ASN1_R_DATA_IS_WRONG;
M_ASN1_D2I_start_sequence();
c.q = c.p;
if ((ai = d2i_ASN1_INTEGER(NULL, &c.p, c.slen)) == NULL)
goto err;
c.slen -= (c.p - c.q);
c.q = c.p;
if ((os = d2i_ASN1_OCTET_STRING(NULL, &c.p, c.slen)) == NULL)
goto err;
c.slen -= (c.p - c.q);
if (!M_ASN1_D2I_end_sequence())
goto err;
if (num != NULL)
*num = ASN1_INTEGER_get(ai);
ret = ASN1_STRING_length(os);
if (max_len > ret)
n = ret;
else
n = max_len;
if (data != NULL)
memcpy(data, ASN1_STRING_data(os), n);
if (0) {
err:
ASN1err(ASN1_F_ASN1_TYPE_GET_INT_OCTETSTRING, ASN1_R_DATA_IS_WRONG);
}
ASN1_OCTET_STRING_free(os);
if (ai != NULL)
ASN1_INTEGER_free(ai);
return (ret);
}
开发者ID:dlabs,项目名称:openssl,代码行数:54,代码来源:evp_asn1.c
示例20: gost2814789_set_asn1_params
int
gost2814789_set_asn1_params(EVP_CIPHER_CTX *ctx, ASN1_TYPE *params)
{
int len = 0;
unsigned char *buf = NULL;
unsigned char *p = NULL;
EVP_GOST2814789_CTX *c = ctx->cipher_data;
ASN1_OCTET_STRING *os = NULL;
GOST_CIPHER_PARAMS *gcp = GOST_CIPHER_PARAMS_new();
if (gcp == NULL) {
GOSTerr(GOST_F_GOST89_SET_ASN1_PARAMETERS,
ERR_R_MALLOC_FAILURE);
return 0;
}
if (ASN1_OCTET_STRING_set(gcp->iv, ctx->iv, ctx->cipher->iv_len) == 0) {
GOST_CIPHER_PARAMS_free(gcp);
GOSTerr(GOST_F_GOST89_SET_ASN1_PARAMETERS, ERR_R_ASN1_LIB);
return 0;
}
ASN1_OBJECT_free(gcp->enc_param_set);
gcp->enc_param_set = OBJ_nid2obj(c->param_nid);
len = i2d_GOST_CIPHER_PARAMS(gcp, NULL);
p = buf = malloc(len);
if (buf == NULL) {
GOST_CIPHER_PARAMS_free(gcp);
GOSTerr(GOST_F_GOST89_SET_ASN1_PARAMETERS,
ERR_R_MALLOC_FAILURE);
return 0;
}
i2d_GOST_CIPHER_PARAMS(gcp, &p);
GOST_CIPHER_PARAMS_free(gcp);
os = ASN1_OCTET_STRING_new();
if (os == NULL) {
free(buf);
GOSTerr(GOST_F_GOST89_SET_ASN1_PARAMETERS,
ERR_R_MALLOC_FAILURE);
return 0;
}
if (ASN1_OCTET_STRING_set(os, buf, len) == 0) {
ASN1_OCTET_STRING_free(os);
free(buf);
GOSTerr(GOST_F_GOST89_SET_ASN1_PARAMETERS, ERR_R_ASN1_LIB);
return 0;
}
free(buf);
ASN1_TYPE_set(params, V_ASN1_SEQUENCE, os);
return 1;
}
开发者ID:Basskrapfen,项目名称:openbsd,代码行数:52,代码来源:e_gost2814789.c
注:本文中的ASN1_OCTET_STRING_free函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论