static int crl_inf_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it)
{
	X509_CRL_INFO *a = (X509_CRL_INFO *)*pval;
	int i;
	int (*old_cmp)(const X509_REVOKED * const *,
			const X509_REVOKED * const *);

	if(!a || !a->revoked) return 1;
	switch(operation) {

		/* Save original order */
		case ASN1_OP_D2I_POST:
		for (i=0; i<sk_X509_REVOKED_num(a->revoked); i++)
			sk_X509_REVOKED_value(a->revoked,i)->sequence=i;
		sk_X509_REVOKED_set_cmp_func(a->revoked,X509_REVOKED_cmp);
		break;

		/* Restore original order */
		case ASN1_OP_I2D_PRE:
		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);
		break;
	}
	return 1;
}