这篇教程C++ ASN1_object_size函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中ASN1_object_size函数的典型用法代码示例。如果您正苦于以下问题:C++ ASN1_object_size函数的具体用法?C++ ASN1_object_size怎么用?C++ ASN1_object_size使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了ASN1_object_size函数的21个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: i2d_X509_EXTENSIONint i2d_X509_EXTENSION(X509_EXTENSION *a, unsigned char **pp) { int k=0; int r=0,ret=0; unsigned char **p=NULL; if (a == NULL) return(0); p=NULL; for (;;) { if (k) { r=ASN1_object_size(1,ret,V_ASN1_SEQUENCE); if (pp == NULL) return(r); p=pp; ASN1_put_object(p,1,ret,V_ASN1_SEQUENCE, V_ASN1_UNIVERSAL); } ret+=i2d_ASN1_OBJECT(a->object,p); if ((a->critical) || a->netscape_hack) ret+=i2d_ASN1_BOOLEAN(a->critical,p); ret+=i2d_ASN1_OCTET_STRING(a->value,p); if (k++) return(r); } }
开发者ID:ahenroid,项目名称:ptptl-0.2,代码行数:27,
示例2: i2d_X509_ATTRIBUTE/* sequence */int i2d_X509_ATTRIBUTE(X509_ATTRIBUTE *a, unsigned char **pp){ int k=0; int r=0,ret=0; unsigned char **p=NULL; if (a == NULL) return(0); p=NULL; for (;;) { if (k) { r=ASN1_object_size(1,ret,V_ASN1_SEQUENCE); if (pp == NULL) return(r); p=pp; ASN1_put_object(p,1,ret,V_ASN1_SEQUENCE, V_ASN1_UNIVERSAL); } ret+=i2d_ASN1_OBJECT(a->object,p); if (a->set) ret+=i2d_ASN1_SET_OF_ASN1_TYPE(a->value.set,p,(i2d_func_t)i2d_ASN1_TYPE, V_ASN1_SET,V_ASN1_UNIVERSAL,IS_SET); else ret+=i2d_ASN1_TYPE(a->value.single,p); if (k++) return(r); }}
开发者ID:jhbsz,项目名称:actiontec_opensource_mi424wr-rev-acd-56-0-10-14-4,代码行数:30,
示例3: btls_change_obj_dataint btls_change_obj_data(ASN1_OBJECT **a, const char* pp){ int res = 1; unsigned char *buf; unsigned char *p; const unsigned char *cp; int i, j; i=a2d_ASN1_OBJECT(NULL,0, pp,-1); if (i <= 0) { /* Don't clear the error */ /*ERR_clear_error();*/ return 0; } /* Work out total size */ j = ASN1_object_size(0,i,V_ASN1_OBJECT); if((buf=(unsigned char *)OPENSSL_malloc(j)) == NULL) return 0; p = buf; /* Write out tag+length */ ASN1_put_object(&p,0,i,V_ASN1_OBJECT,V_ASN1_UNIVERSAL); /* Write out contents */ a2d_ASN1_OBJECT(p,i,pp,-1); cp=buf; (*a)=btls_d2i_ASN1_OBJECT(a,&cp,j); OPENSSL_free(buf); return 1;}
开发者ID:ppmi-bsu,项目名称:btls_e,代码行数:31,
示例4: i2d_ASN1_bytesint i2d_ASN1_bytes(ASN1_STRING *a, unsigned char **pp, int tag, int xclass) { int ret,r,constructed; unsigned char *p; if (a == NULL) return(0); if (tag == V_ASN1_BIT_STRING) return(i2d_ASN1_BIT_STRING(a,pp)); ret=a->length; r=ASN1_object_size(0,ret,tag); if (pp == NULL) return(r); p= *pp; if ((tag == V_ASN1_SEQUENCE) || (tag == V_ASN1_SET)) constructed=1; else constructed=0; ASN1_put_object(&p,constructed,ret,tag,xclass); memcpy(p,a->data,a->length); p+=a->length; *pp= p; return(r); }
开发者ID:HungMingWu,项目名称:libquic,代码行数:25,
示例5: ECDSA_sizeint ECDSA_size(const EC_KEY *r){ int ret,i; ASN1_INTEGER bs; BIGNUM *order=NULL; unsigned char buf[4]; const EC_GROUP *group; if (r == NULL) return 0; group = EC_KEY_get0_group(r); if (group == NULL) return 0; if ((order = BN_new()) == NULL) return 0; if (!EC_GROUP_get_order(group,order,NULL)) { BN_clear_free(order); return 0; } i=BN_num_bits(order); bs.length=(i+7)/8; bs.data=buf; bs.type=V_ASN1_INTEGER; /* If the top bit is set the asn1 encoding is 1 larger. */ buf[0]=0xff; i=i2d_ASN1_INTEGER(&bs,NULL); i+=i; /* r and s */ ret=ASN1_object_size(1,i,V_ASN1_SEQUENCE); BN_clear_free(order); return(ret);}
开发者ID:0omega,项目名称:platform_external_openssl,代码行数:33,
示例6: ossl_asn1prim_to_derstatic VALUEossl_asn1prim_to_der(VALUE self, SEL sel){ ASN1_TYPE *asn1; int tn, tc, explicit; long len, reallen; unsigned char *buf, *p; VALUE str; tn = NUM2INT(ossl_asn1_get_tag(self)); tc = ossl_asn1_tag_class(self); explicit = ossl_asn1_is_explicit(self); asn1 = ossl_asn1_get_asn1type(self); len = ASN1_object_size(1, ossl_i2d_ASN1_TYPE(asn1, NULL), tn); if(!(buf = OPENSSL_malloc(len))){ ossl_ASN1_TYPE_free(asn1); ossl_raise(eASN1Error, "cannot alloc buffer"); } p = buf; if (tc == V_ASN1_UNIVERSAL) { ossl_i2d_ASN1_TYPE(asn1, &p); } else if (explicit) { ASN1_put_object(&p, 1, ossl_i2d_ASN1_TYPE(asn1, NULL), tn, tc); ossl_i2d_ASN1_TYPE(asn1, &p); } else {
开发者ID:DocPsy,项目名称:MacRuby,代码行数:26,
示例7: ossl_asn1data_to_derstatic VALUEossl_asn1data_to_der(VALUE self, SEL sel){ VALUE value, der; int tag, tag_class, is_cons = 0; long length; unsigned char *p; value = ossl_asn1_get_value(self); if(rb_obj_is_kind_of(value, rb_cArray)){ is_cons = 1; value = join_der(value); } StringValue(value); tag = ossl_asn1_tag(self); tag_class = ossl_asn1_tag_class(self); if((length = ASN1_object_size(1, RSTRING_LEN(value), tag)) <= 0) ossl_raise(eASN1Error, NULL); der = rb_bstr_new(); rb_bstr_resize(der, length); p = (unsigned char *)rb_bstr_bytes(der); ASN1_put_object(&p, is_cons, RSTRING_LEN(value), tag, tag_class); memcpy(p, RSTRING_PTR(value), RSTRING_LEN(value)); p += RSTRING_LEN(value); ossl_str_adjust(der, p); return der;}
开发者ID:DocPsy,项目名称:MacRuby,代码行数:29,
示例8: asn1_i2d_ex_primitivestatic int asn1_i2d_ex_primitive(ASN1_VALUE **pval, unsigned char **out, const ASN1_ITEM *it, int tag, int aclass){ int len; int utype; int usetag; int ndef = 0; utype = it->utype; /* * Get length of content octets and maybe find out the underlying type. */ len = asn1_ex_i2c(pval, NULL, &utype, it); /* * If SEQUENCE, SET or OTHER then header is included in pseudo content * octets so don't include tag+length. We need to check here because the * call to asn1_ex_i2c() could change utype. */ if ((utype == V_ASN1_SEQUENCE) || (utype == V_ASN1_SET) || (utype == V_ASN1_OTHER)) usetag = 0; else usetag = 1; /* -1 means omit type */ if (len == -1) return 0; /* -2 return is special meaning use ndef */ if (len == -2) { ndef = 2; len = 0; } /* If not implicitly tagged get tag from underlying type */ if (tag == -1) tag = utype; /* Output tag+length followed by content octets */ if (out) { if (usetag) ASN1_put_object(out, ndef, len, tag, aclass); asn1_ex_i2c(pval, *out, &utype, it); if (ndef) ASN1_put_eoc(out); else *out += len; } if (usetag) return ASN1_object_size(ndef, len, tag); return len;}
开发者ID:kobemiller,项目名称:mycode,代码行数:57,
示例9: i2d_ASN1_BOOLEANint i2d_ASN1_BOOLEAN(int a, unsigned char **pp) { int r; unsigned char *p; r=ASN1_object_size(0,1,V_ASN1_BOOLEAN); if (pp == NULL) return(r); p= *pp; ASN1_put_object(&p,0,1,V_ASN1_BOOLEAN,V_ASN1_UNIVERSAL); *(p++)= (unsigned char)a; *pp=p; return(r); }
开发者ID:RafaelRMachado,项目名称:MinnowBoard,代码行数:14,
示例10: ECDSA_sizesize_t ECDSA_size(const EC_KEY *key) { size_t ret, i, group_order_size; ASN1_INTEGER bs; BIGNUM *order = NULL; unsigned char buf[4]; const EC_GROUP *group; if (key->ecdsa_meth && key->ecdsa_meth->group_order_size) { group_order_size = key->ecdsa_meth->group_order_size(key); } else { size_t num_bits; if (key == NULL) { return 0; } group = EC_KEY_get0_group(key); if (group == NULL) { return 0; } order = BN_new(); if (order == NULL) { return 0; } if (!EC_GROUP_get_order(group, order, NULL)) { BN_clear_free(order); return 0; } num_bits = BN_num_bits(order); group_order_size = (num_bits + 7) / 8; } bs.length = group_order_size; bs.data = buf; bs.type = V_ASN1_INTEGER; /* If the top bit is set the ASN.1 encoding is 1 larger. */ buf[0] = 0xff; i = i2d_ASN1_INTEGER(&bs, NULL); i += i; /* r and s */ ret = ASN1_object_size(1, i, V_ASN1_SEQUENCE); BN_clear_free(order); return ret;}
开发者ID:hoangmichel,项目名称:webrtc,代码行数:45,
示例11: DSA_sizeint DSA_size(DSA *r) { int ret,i; ASN1_INTEGER bs; unsigned char buf[4]; i=BN_num_bits(r->q); bs.length=(i+7)/8; bs.data=buf; bs.type=V_ASN1_INTEGER; /* If the top bit is set the asn1 encoding is 1 larger. */ buf[0]=0xff; i=i2d_ASN1_INTEGER(&bs,NULL); i+=i; /* r and s */ ret=ASN1_object_size(1,i,V_ASN1_SEQUENCE); return(ret); }
开发者ID:ahenroid,项目名称:ptptl-0.2,代码行数:18,
示例12: i2d_ASN1_OBJECTint i2d_ASN1_OBJECT(ASN1_OBJECT *a, unsigned char **pp) { unsigned char *p; int objsize; if ((a == NULL) || (a->data == NULL)) return(0); objsize = ASN1_object_size(0,a->length,V_ASN1_OBJECT); if (pp == NULL) return objsize; p= *pp; ASN1_put_object(&p,0,a->length,V_ASN1_OBJECT,V_ASN1_UNIVERSAL); memcpy(p,a->data,a->length); p+=a->length; *pp=p; return(objsize); }
开发者ID:109383670,项目名称:node,代码行数:18,
示例13: DSA_sizeint DSA_size(const DSA *dsa) { int ret, i; ASN1_INTEGER bs; unsigned char buf[4]; /* 4 bytes looks really small. However, i2d_ASN1_INTEGER() will not look beyond the first byte, as long as the second parameter is NULL. */ i = BN_num_bits(dsa->q); bs.length = (i + 7) / 8; bs.data = buf; bs.type = V_ASN1_INTEGER; /* If the top bit is set the asn1 encoding is 1 larger. */ buf[0] = 0xff; i = i2d_ASN1_INTEGER(&bs, NULL); i += i; /* r and s */ ret = ASN1_object_size(1, i, V_ASN1_SEQUENCE); return ret;}
开发者ID:RobinWuDev,项目名称:Qt,代码行数:20,
示例14: ASN1_TYPE_set_int_octetstringintASN1_TYPE_set_int_octetstring(ASN1_TYPE *a, long num, unsigned char *data, int len){ int n, size; ASN1_OCTET_STRING os, *osp; ASN1_INTEGER in; unsigned char *p; unsigned char buf[32]; /* when they have 256bit longs, * I'll be in trouble */ in.data = buf; in.length = 32; os.data = data; os.type = V_ASN1_OCTET_STRING; os.length = len; ASN1_INTEGER_set(&in, num); n = i2d_ASN1_INTEGER(&in, NULL); n += M_i2d_ASN1_OCTET_STRING(&os, NULL); size = ASN1_object_size(1, n, V_ASN1_SEQUENCE); if ((osp = ASN1_STRING_new()) == NULL) return (0); /* Grow the 'string' */ if (!ASN1_STRING_set(osp, NULL, size)) { ASN1_STRING_free(osp); return (0); } M_ASN1_STRING_length_set(osp, size); p = M_ASN1_STRING_data(osp); ASN1_put_object(&p, 1,n, V_ASN1_SEQUENCE, V_ASN1_UNIVERSAL); i2d_ASN1_INTEGER(&in, &p); M_i2d_ASN1_OCTET_STRING(&os, &p); ASN1_TYPE_set(a, V_ASN1_SEQUENCE, osp); return (1);}
开发者ID:DiamondLovesYou,项目名称:libressl-pnacl-sys,代码行数:39,
示例15: add_signed_seq2string/* ########################################### */intadd_signed_seq2string(PKCS7_SIGNER_INFO *si, char *str1, char *str2){ /* To add an object of OID 1.9.999, which is a sequence containing * 2 octet strings */ unsigned char *p; ASN1_OCTET_STRING *os1, *os2; ASN1_STRING *seq; unsigned char *data; int i, total; if (signed_seq2string_nid == -1) signed_seq2string_nid = OBJ_create("1.9.9999","OID_example","Our example OID"); os1 = ASN1_OCTET_STRING_new(); os2 = ASN1_OCTET_STRING_new(); ASN1_OCTET_STRING_set(os1, (unsigned char*)str1, strlen(str1)); ASN1_OCTET_STRING_set(os2, (unsigned char*)str1, strlen(str1)); i = i2d_ASN1_OCTET_STRING(os1, NULL); i += i2d_ASN1_OCTET_STRING(os2, NULL); total = ASN1_object_size(1, i, V_ASN1_SEQUENCE); data = malloc(total); p = data; ASN1_put_object(&p, 1,i, V_ASN1_SEQUENCE, V_ASN1_UNIVERSAL); i2d_ASN1_OCTET_STRING(os1, &p); i2d_ASN1_OCTET_STRING(os2, &p); seq = ASN1_STRING_new(); ASN1_STRING_set(seq, data, total); free(data); ASN1_OCTET_STRING_free(os1); ASN1_OCTET_STRING_free(os2); PKCS7_add_signed_attribute(si, signed_seq2string_nid, V_ASN1_SEQUENCE, (char *)seq); return (1);}
开发者ID:robertbachmann,项目名称:openbsd-libssl,代码行数:40,
示例16: OBJ_ln2nidASN1_OBJECT *OBJ_txt2obj(const char *s, int no_name) { int nid = NID_undef; ASN1_OBJECT *op=NULL; unsigned char *buf; unsigned char *p; const unsigned char *cp; int i, j; if(!no_name) { if( ((nid = OBJ_sn2nid(s)) != NID_undef) || ((nid = OBJ_ln2nid(s)) != NID_undef) ) return OBJ_nid2obj(nid); } /* Work out size of content octets */ i=a2d_ASN1_OBJECT(NULL,0,s,-1); if (i <= 0) { /* Clear the error */ ERR_clear_error(); return NULL; } /* Work out total size */ j = ASN1_object_size(0,i,V_ASN1_OBJECT); if((buf=(unsigned char *)OPENSSL_malloc(j)) == NULL) return NULL; p = buf; /* Write out tag+length */ ASN1_put_object(&p,0,i,V_ASN1_OBJECT,V_ASN1_UNIVERSAL); /* Write out contents */ a2d_ASN1_OBJECT(p,i,s,-1); cp=buf; op=d2i_ASN1_OBJECT(NULL,&cp,j); OPENSSL_free(buf); return op; }
开发者ID:yyyyyao,项目名称:Slicer3-lib-mirrors,代码行数:38,
示例17: i2d_RSA_NETint i2d_RSA_NET(RSA *a, unsigned char **pp, int (*cb)(), int sgckey) { int i,j,l[6]; NETSCAPE_PKEY *pkey; unsigned char buf[256],*zz; unsigned char key[EVP_MAX_KEY_LENGTH]; EVP_CIPHER_CTX ctx; X509_ALGOR *alg=NULL; ASN1_OCTET_STRING os,os2; M_ASN1_I2D_vars(a); if (a == NULL) return(0);#ifdef WIN32 r=r; /* shut the damn compiler up :-) */#endif os.data=os2.data=NULL; if ((pkey=NETSCAPE_PKEY_new()) == NULL) goto err; if (!ASN1_INTEGER_set(pkey->version,0)) goto err; if (pkey->algor->algorithm != NULL) ASN1_OBJECT_free(pkey->algor->algorithm); pkey->algor->algorithm=OBJ_nid2obj(NID_rsaEncryption); if ((pkey->algor->parameter=ASN1_TYPE_new()) == NULL) goto err; pkey->algor->parameter->type=V_ASN1_NULL; l[0]=i2d_RSAPrivateKey(a,NULL); pkey->private_key->length=l[0]; os2.length=i2d_NETSCAPE_PKEY(pkey,NULL); l[1]=i2d_ASN1_OCTET_STRING(&os2,NULL); if ((alg=X509_ALGOR_new()) == NULL) goto err; if (alg->algorithm != NULL) ASN1_OBJECT_free(alg->algorithm); alg->algorithm=OBJ_nid2obj(NID_rc4); if ((alg->parameter=ASN1_TYPE_new()) == NULL) goto err; alg->parameter->type=V_ASN1_NULL; l[2]=i2d_X509_ALGOR(alg,NULL); l[3]=ASN1_object_size(1,l[2]+l[1],V_ASN1_SEQUENCE);#ifndef CONST_STRICT os.data=(unsigned char *)"private-key";#endif os.length=11; l[4]=i2d_ASN1_OCTET_STRING(&os,NULL); l[5]=ASN1_object_size(1,l[4]+l[3],V_ASN1_SEQUENCE); if (pp == NULL) { if (pkey != NULL) NETSCAPE_PKEY_free(pkey); if (alg != NULL) X509_ALGOR_free(alg); return(l[5]); } if (pkey->private_key->data != NULL) OPENSSL_free(pkey->private_key->data); if ((pkey->private_key->data=(unsigned char *)OPENSSL_malloc(l[0])) == NULL) { ASN1err(ASN1_F_I2D_NETSCAPE_RSA,ERR_R_MALLOC_FAILURE); goto err; } zz=pkey->private_key->data; i2d_RSAPrivateKey(a,&zz); if ((os2.data=(unsigned char *)OPENSSL_malloc(os2.length)) == NULL) { ASN1err(ASN1_F_I2D_NETSCAPE_RSA,ERR_R_MALLOC_FAILURE); goto err; } zz=os2.data; i2d_NETSCAPE_PKEY(pkey,&zz); if (cb == NULL) cb=EVP_read_pw_string; i=cb(buf,256,"Enter Private Key password:",1); if (i != 0) { ASN1err(ASN1_F_I2D_NETSCAPE_RSA,ASN1_R_BAD_PASSWORD_READ); goto err; } i = strlen((char *)buf); /* If the key is used for SGC the algorithm is modified a little. */ if(sgckey){ EVP_MD_CTX mctx; EVP_DigestInit(&mctx, EVP_md5()); EVP_DigestUpdate(&mctx, buf, i); EVP_DigestFinal(&mctx, buf, NULL); memcpy(buf + 16, "SGCKEYSALT", 10); i = 26; } EVP_BytesToKey(EVP_rc4(),EVP_md5(),NULL,buf,i,1,key,NULL); memset(buf,0,256); EVP_CIPHER_CTX_init(&ctx); EVP_EncryptInit(&ctx,EVP_rc4(),key,NULL);//.........这里部分代码省略.........
开发者ID:houzhenggang,项目名称:mt7688_mips_ecos,代码行数:101,
示例18: ASN1errASN1_TYPE *ASN1_generate_v3(char *str, X509V3_CTX *cnf) { ASN1_TYPE *ret; tag_exp_arg asn1_tags; tag_exp_type *etmp; int i, len; unsigned char *orig_der = NULL, *new_der = NULL; const unsigned char *cpy_start; unsigned char *p; const unsigned char *cp; int cpy_len; long hdr_len; int hdr_constructed = 0, hdr_tag, hdr_class; int r; asn1_tags.imp_tag = -1; asn1_tags.imp_class = -1; asn1_tags.format = ASN1_GEN_FORMAT_ASCII; asn1_tags.exp_count = 0; if (CONF_parse_list(str, ',', 1, asn1_cb, &asn1_tags) != 0) return NULL; if ((asn1_tags.utype == V_ASN1_SEQUENCE) || (asn1_tags.utype == V_ASN1_SET)) { if (!cnf) { ASN1err(ASN1_F_ASN1_GENERATE_V3, ASN1_R_SEQUENCE_OR_SET_NEEDS_CONFIG); return NULL; } ret = asn1_multi(asn1_tags.utype, asn1_tags.str, cnf); } else ret = asn1_str2type(asn1_tags.str, asn1_tags.format, asn1_tags.utype); if (!ret) return NULL; /* If no tagging return base type */ if ((asn1_tags.imp_tag == -1) && (asn1_tags.exp_count == 0)) return ret; /* Generate the encoding */ cpy_len = i2d_ASN1_TYPE(ret, &orig_der); ASN1_TYPE_free(ret); ret = NULL; /* Set point to start copying for modified encoding */ cpy_start = orig_der; /* Do we need IMPLICIT tagging? */ if (asn1_tags.imp_tag != -1) { /* If IMPLICIT we will replace the underlying tag */ /* Skip existing tag+len */ r = ASN1_get_object(&cpy_start, &hdr_len, &hdr_tag, &hdr_class, cpy_len); if (r & 0x80) goto err; /* Update copy length */ cpy_len -= (int)(cpy_start - orig_der); /* For IMPLICIT tagging the length should match the * original length and constructed flag should be * consistent. */ if (r & 0x1) { /* Indefinite length constructed */ hdr_constructed = 2; hdr_len = 0; } else /* Just retain constructed flag */ hdr_constructed = r & V_ASN1_CONSTRUCTED; /* Work out new length with IMPLICIT tag: ignore constructed * because it will mess up if indefinite length */ len = ASN1_object_size(0, hdr_len, asn1_tags.imp_tag); } else len = cpy_len; /* Work out length in any EXPLICIT, starting from end */ for(i = 0, etmp = asn1_tags.exp_list + asn1_tags.exp_count - 1; i < asn1_tags.exp_count; i++, etmp--) { /* Content length: number of content octets + any padding */ len += etmp->exp_pad; etmp->exp_len = len; /* Total object length: length including new header */ len = ASN1_object_size(0, len, etmp->exp_tag); } /* Allocate buffer for new encoding */ new_der = OPENSSL_malloc(len); /* Generate tagged encoding */ p = new_der;//.........这里部分代码省略.........
开发者ID:imgits,项目名称:rkanalyzer,代码行数:101,
示例19: i2d_ASN1_SET/* int is_set: if TRUE, then sort the contents (i.e. it isn't a SEQUENCE) */int i2d_ASN1_SET(STACK *a, unsigned char **pp, i2d_of_void *i2d, int ex_tag, int ex_class, int is_set) { int ret=0,r; int i; unsigned char *p; unsigned char *pStart, *pTempMem; MYBLOB *rgSetBlob; int totSize; if (a == NULL) return(0); for (i=sk_num(a)-1; i>=0; i--) ret+=i2d(sk_value(a,i),NULL); r=ASN1_object_size(1,ret,ex_tag); if (pp == NULL) return(r); p= *pp; ASN1_put_object(&p,1,ret,ex_tag,ex_class);/* Modified by [email C++ ASN1err函数代码示例 C++ ASN1_item_new函数代码示例
|