if (!a2i_ASN1_INTEGER(hex,r->serialNumber,
buf[0],BSIZE)) goto err;
- sk_push(ci->revoked,(char *)r);
+ sk_X509_REVOKED_push(ci->revoked,r);
}
}
/* sort the data so it will be written in serial
* number order */
- sk_find(ci->revoked,NULL);
- for (i=0; i<sk_num(ci->revoked); i++)
+ sk_X509_REVOKED_sort(ci->revoked);
+ for (i=0; i<sk_X509_REVOKED_num(ci->revoked); i++)
{
- r=(X509_REVOKED *)sk_value(ci->revoked,i);
+ r=sk_X509_REVOKED_value(ci->revoked,i);
r->sequence=i;
}
{
char buf[256];
unsigned char *s;
- STACK *rev;
+ STACK_OF(X509_REVOKED) *rev;
X509_REVOKED *r;
long l;
int i, j, n;
rev = X509_CRL_get_REVOKED(x);
- if(sk_num(rev)) BIO_printf(out, "Revoked Certificates:\n");
+ if(sk_X509_REVOKED_num(rev))
+ BIO_printf(out, "Revoked Certificates:\n");
else BIO_printf(out, "No Revoked Certificates.\n");
- for(i = 0; i < sk_num(rev); i++) {
- r = (X509_REVOKED *) sk_value(rev, i);
+ for(i = 0; i < sk_X509_REVOKED_num(rev); i++) {
+ r = sk_X509_REVOKED_value(rev, i);
BIO_printf(out," Serial Number: ");
i2a_ASN1_INTEGER(out,r->serialNumber);
BIO_printf(out,"\n Revocation Date: ","");
{
int v1=0;
long l=0;
+ int (*old_cmp)(X509_REVOKED **,X509_REVOKED **);
M_ASN1_I2D_vars(a);
+
+ old_cmp=sk_X509_REVOKED_set_cmp_func(a->revoked,X509_REVOKED_seq_cmp);
+ sk_X509_REVOKED_sort(a->revoked);
+ sk_X509_REVOKED_set_cmp_func(a->revoked,old_cmp);
- if (sk_num(a->revoked) != 0)
- qsort((char *)a->revoked->data,sk_num(a->revoked),
- sizeof(X509_REVOKED *),(int (*)(const void *,const void *))X509_REVOKED_seq_cmp);
if ((a->version != NULL) && ((l=ASN1_INTEGER_get(a->version)) != 0))
{
M_ASN1_I2D_len(a->version,i2d_ASN1_INTEGER);
M_ASN1_I2D_len(a->lastUpdate,i2d_ASN1_TIME);
if (a->nextUpdate != NULL)
{ M_ASN1_I2D_len(a->nextUpdate,i2d_ASN1_TIME); }
- M_ASN1_I2D_len_SEQUENCE_opt(a->revoked,i2d_X509_REVOKED);
+ M_ASN1_I2D_len_SEQUENCE_opt_type(X509_REVOKED,a->revoked,
+ i2d_X509_REVOKED);
M_ASN1_I2D_len_EXP_SEQUENCE_opt_type(X509_EXTENSION,a->extensions,
i2d_X509_EXTENSION,0,
V_ASN1_SEQUENCE,v1);
M_ASN1_I2D_put(a->lastUpdate,i2d_ASN1_UTCTIME);
if (a->nextUpdate != NULL)
{ M_ASN1_I2D_put(a->nextUpdate,i2d_ASN1_UTCTIME); }
- M_ASN1_I2D_put_SEQUENCE_opt(a->revoked,i2d_X509_REVOKED);
+ M_ASN1_I2D_put_SEQUENCE_opt_type(X509_REVOKED,a->revoked,
+ i2d_X509_REVOKED);
M_ASN1_I2D_put_EXP_SEQUENCE_opt_type(X509_EXTENSION,a->extensions,
i2d_X509_EXTENSION,0,
V_ASN1_SEQUENCE,v1);
V_ASN1_GENERALIZEDTIME);
if (ret->revoked != NULL)
{
- while (sk_num(ret->revoked))
- X509_REVOKED_free((X509_REVOKED *)sk_pop(ret->revoked));
+ while (sk_X509_REVOKED_num(ret->revoked))
+ X509_REVOKED_free(sk_X509_REVOKED_pop(ret->revoked));
}
- M_ASN1_D2I_get_seq_opt(ret->revoked,d2i_X509_REVOKED,X509_REVOKED_free);
+ M_ASN1_D2I_get_seq_opt_type(X509_REVOKED,ret->revoked,d2i_X509_REVOKED,
+ X509_REVOKED_free);
if (ret->revoked != NULL)
{
- for (i=0; i<sk_num(ret->revoked); i++)
+ for (i=0; i<sk_X509_REVOKED_num(ret->revoked); i++)
{
- ((X509_REVOKED *)sk_value(ret->revoked,i))->sequence=i;
+ sk_X509_REVOKED_value(ret->revoked,i)->sequence=i;
}
}
M_ASN1_New(ret->issuer,X509_NAME_new);
M_ASN1_New(ret->lastUpdate,ASN1_UTCTIME_new);
ret->nextUpdate=NULL;
- M_ASN1_New(ret->revoked,sk_new_null);
+ M_ASN1_New(ret->revoked,sk_X509_REVOKED_new_null);
M_ASN1_New(ret->extensions,sk_X509_EXTENSION_new_null);
- ret->revoked->comp=(int (*)())X509_REVOKED_cmp;
+ sk_X509_REVOKED_set_cmp_func(ret->revoked,X509_REVOKED_cmp);
return(ret);
M_ASN1_New_Error(ASN1_F_X509_CRL_INFO_NEW);
}
ASN1_UTCTIME_free(a->lastUpdate);
if (a->nextUpdate)
ASN1_UTCTIME_free(a->nextUpdate);
- sk_pop_free(a->revoked,X509_REVOKED_free);
+ sk_X509_REVOKED_pop_free(a->revoked,X509_REVOKED_free);
sk_X509_EXTENSION_pop_free(a->extensions,X509_EXTENSION_free);
Free(a);
}
{
return((*a)->sequence-(*b)->sequence);
}
+
+IMPLEMENT_STACK_OF(X509_REVOKED)
+IMPLEMENT_ASN1_SET_OF(X509_REVOKED)
STACK_OF(type) *sk_##type##_dup(STACK_OF(type) *sk); \
void sk_##type##_pop_free(STACK_OF(type) *sk,void (*func)(type *)); \
type *sk_##type##_shift(STACK_OF(type) *sk); \
-type *sk_##type##_pop(STACK_OF(type) *sk);
+type *sk_##type##_pop(STACK_OF(type) *sk); \
+void sk_##type##_sort(STACK_OF(type) *sk);
#define IMPLEMENT_STACK_OF(type) \
STACK_OF(type) *sk_##type##_new(int (*cmp)(type **,type **)) \
type *sk_##type##_shift(STACK_OF(type) *sk) \
{ return (type *)sk_shift((STACK *)sk); } \
type *sk_##type##_pop(STACK_OF(type) *sk) \
- { return (type *)sk_pop((STACK *)sk); }
+ { return (type *)sk_pop((STACK *)sk); } \
+void sk_##type##_sort(STACK_OF(type) *sk) \
+ { sk_sort((STACK *)sk); }
#endif /* ndef HEADER_SAFESTACK_H */
return(i);
return(-1);
}
- comp_func=(int (*)())st->comp;
- if (!st->sorted)
- {
- qsort((char *)st->data,st->num,sizeof(char *),FP_ICC comp_func);
- st->sorted=1;
- }
+ sk_sort(st);
if (data == NULL) return(-1);
+ comp_func=(int (*)())st->comp;
r=(char **)bsearch(&data,(char *)st->data,
st->num,sizeof(char *),FP_ICC comp_func);
if (r == NULL) return(-1);
if(st == NULL) return NULL;
return (st->data[i] = value);
}
+
+void sk_sort(STACK *st)
+ {
+ if (!st->sorted)
+ {
+ int (*comp_func)();
+
+ comp_func=(int (*)())st->comp;
+ qsort(st->data,st->num,sizeof(char *),FP_ICC comp_func);
+ st->sorted=1;
+ }
+ }
void sk_zero(STACK *st);
int (*sk_set_cmp_func(STACK *sk, int (*c)()))();
STACK *sk_dup(STACK *st);
+void sk_sort(STACK *st);
#ifdef __cplusplus
}
int sequence; /* load sequence */
} X509_REVOKED;
+DECLARE_STACK_OF(X509_REVOKED)
+DECLARE_ASN1_SET_OF(X509_REVOKED)
+
typedef struct X509_crl_info_st
{
ASN1_INTEGER *version;
X509_NAME *issuer;
ASN1_UTCTIME *lastUpdate;
ASN1_UTCTIME *nextUpdate;
- STACK /* X509_REVOKED */ *revoked;
+ STACK_OF(X509_REVOKED) *revoked;
STACK_OF(X509_EXTENSION) /* [0] */ *extensions;
} X509_CRL_INFO;