#include <stddef.h>
#include <string.h>
+#include "cryptlib.h"
#include <openssl/asn1.h>
#include <openssl/asn1t.h>
#include <openssl/objects.h>
return asn1_i2d_ex_primitive(pval, out, it, -1, aclass);
case ASN1_ITYPE_CHOICE:
- if (asn1_cb && !asn1_cb(ASN1_OP_I2D_PRE, pval, it))
+ if (asn1_cb && !asn1_cb(ASN1_OP_I2D_PRE, pval, it, NULL))
return 0;
i = asn1_get_choice_selector(pval, it);
if ((i >= 0) && (i < it->tcount))
-1, aclass);
}
/* Fixme: error condition if selector out of range */
- if (asn1_cb && !asn1_cb(ASN1_OP_I2D_POST, pval, it))
+ if (asn1_cb && !asn1_cb(ASN1_OP_I2D_POST, pval, it, NULL))
return 0;
break;
aclass = (aclass & ~ASN1_TFLG_TAG_CLASS)
| V_ASN1_UNIVERSAL;
}
- if (asn1_cb && !asn1_cb(ASN1_OP_I2D_PRE, pval, it))
+ if (asn1_cb && !asn1_cb(ASN1_OP_I2D_PRE, pval, it, NULL))
return 0;
/* First work out sequence content length */
- for(i = 0, tt = it->templates; i < it->tcount; tt++, i++)
+ for (i = 0, tt = it->templates; i < it->tcount; tt++, i++)
{
const ASN1_TEMPLATE *seqtt;
ASN1_VALUE **pseqval;
return seqlen;
/* Output SEQUENCE header */
ASN1_put_object(out, ndef, seqcontlen, tag, aclass);
- for(i = 0, tt = it->templates; i < it->tcount; tt++, i++)
+ for (i = 0, tt = it->templates; i < it->tcount; tt++, i++)
{
const ASN1_TEMPLATE *seqtt;
ASN1_VALUE **pseqval;
}
if (ndef == 2)
ASN1_put_eoc(out);
- if (asn1_cb && !asn1_cb(ASN1_OP_I2D_POST, pval, it))
+ if (asn1_cb && !asn1_cb(ASN1_OP_I2D_POST, pval, it, NULL))
return 0;
return seqlen;
/* Determine total length of items */
skcontlen = 0;
- for(i = 0; i < sk_ASN1_VALUE_num(sk); i++)
+ for (i = 0; i < sk_ASN1_VALUE_num(sk); i++)
{
skitem = sk_ASN1_VALUE_value(sk, i);
skcontlen += ASN1_item_ex_i2d(&skitem, NULL,
/* If not sorting just output each item */
if (!do_sort)
{
- for(i = 0; i < sk_ASN1_VALUE_num(sk); i++)
+ for (i = 0; i < sk_ASN1_VALUE_num(sk); i++)
{
skitem = sk_ASN1_VALUE_value(sk, i);
ASN1_item_ex_i2d(&skitem, out, item, -1, iclass);
p = tmpdat;
/* Doing sort: build up a list of each member's DER encoding */
- for(i = 0, tder = derlst; i < sk_ASN1_VALUE_num(sk); i++, tder++)
+ for (i = 0, tder = derlst; i < sk_ASN1_VALUE_num(sk); i++, tder++)
{
skitem = sk_ASN1_VALUE_value(sk, i);
tder->data = p;
qsort(derlst, sk_ASN1_VALUE_num(sk), sizeof(*derlst), der_cmp);
/* Output sorted DER encoding */
p = *out;
- for(i = 0, tder = derlst; i < sk_ASN1_VALUE_num(sk); i++, tder++)
+ for (i = 0, tder = derlst; i < sk_ASN1_VALUE_num(sk); i++, tder++)
{
memcpy(p, tder->data, tder->length);
p += tder->length;
/* If do_sort is 2 then reorder the STACK */
if (do_sort == 2)
{
- for(i = 0, tder = derlst; i < sk_ASN1_VALUE_num(sk);
+ for (i = 0, tder = derlst; i < sk_ASN1_VALUE_num(sk);
i++, tder++)
sk_ASN1_VALUE_set(sk, i, tder->field);
}
tbool = (ASN1_BOOLEAN *)pval;
if (*tbool == -1)
return -1;
- /* Default handling if value == size field then omit */
- if (*tbool && (it->size > 0))
- return -1;
- if (!*tbool && !it->size)
- return -1;
+ if (it->utype != V_ASN1_ANY)
+ {
+ /* Default handling if value == size field then omit */
+ if (*tbool && (it->size > 0))
+ return -1;
+ if (!*tbool && !it->size)
+ return -1;
+ }
c = (unsigned char)*tbool;
cont = &c;
len = 1;