67 static int asn1_i2d_ex_primitive(
ASN1_VALUE **pval,
unsigned char **out,
72 int do_sort,
int iclass);
73 static int asn1_template_ex_i2d(
ASN1_VALUE **pval,
unsigned char **out,
76 static int asn1_item_flags_i2d(
ASN1_VALUE *val,
unsigned char **out,
91 return asn1_item_flags_i2d(val, out, it, 0);
103 static int asn1_item_flags_i2d(
ASN1_VALUE *val,
unsigned char **out,
108 unsigned char *
p, *buf;
131 const ASN1_ITEM *it,
int tag,
int aclass)
134 unsigned char *p = NULL;
135 int i, seqcontlen, seqlen, ndef = 1;
152 return asn1_template_ex_i2d(pval, out, it->
templates,
154 return asn1_i2d_ex_primitive(pval, out, it, tag, aclass);
158 return asn1_i2d_ex_primitive(pval, out, it, -1, aclass);
164 if ((i >= 0) && (i < it->tcount))
170 return asn1_template_ex_i2d(pchval, out, chtt,
181 return ef->
asn1_ex_i2d(pval, out, it, tag, aclass);
192 if (out && (tag != -1))
222 for (i = 0, tt = it->
templates; i < it->tcount; tt++, i++)
231 seqcontlen += asn1_template_ex_i2d(pseqval, NULL, seqtt,
240 for (i = 0, tt = it->
templates; i < it->tcount; tt++, i++)
249 asn1_template_ex_i2d(pseqval, out, seqtt, -1, aclass);
267 return asn1_template_ex_i2d(pval, out, tt, -1, 0);
270 static int asn1_template_ex_i2d(
ASN1_VALUE **pval,
unsigned char **out,
273 int i, ret,
flags, ttag, tclass, ndef;
321 int isset, sktag, skaclass;
322 int skcontlen, sklen;
373 if (flags & ASN1_TFLG_EXPTAG)
383 if (flags & ASN1_TFLG_EXPTAG)
390 if (flags & ASN1_TFLG_EXPTAG)
414 ttag, tclass | iclass);
426 static int der_cmp(
const void *
a,
const void *
b)
430 cmplen = (d1->
length < d2->length) ? d1->
length : d2->length;
431 i = memcmp(d1->
data, d2->data, cmplen);
434 return d1->
length - d2->length;
441 int do_sort,
int iclass)
445 unsigned char *tmpdat = NULL, *p = NULL;
457 if (!derlst || !tmpdat)
479 tder->field = skitem;
488 memcpy(p, tder->data, tder->length);
504 static int asn1_i2d_ex_primitive(
ASN1_VALUE **pval,
unsigned char **out,
505 const ASN1_ITEM *it,
int tag,
int aclass)
544 if (tag == -1) tag = utype;
572 const unsigned char *cont;
578 return pf->
prim_i2c(pval, cout, putype, it);
584 if (!*pval)
return -1;
591 utype = strtmp->
type;
603 else utype = *putype;
625 if (*tbool && (it->
size > 0))
627 if (!*tbool && !it->
size)
630 c = (
unsigned char)*tbool;
637 cout ? &cout : NULL);
648 cout ? &cout : NULL);
671 if ((it->
size == ASN1_TFLG_NDEF)
689 memcpy(cout, cont, len);