Commit d500de16 authored by Ben Laurie's avatar Ben Laurie
Browse files

Another stack.

parent b3ca645f
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -108,8 +108,9 @@
 */

static int make_REQ(X509_REQ *req,EVP_PKEY *pkey,int attribs);
static int add_attribute_object(STACK *n, char *text, char *def, 
	char *value, int nid,int min,int max);
static int add_attribute_object(STACK_OF(X509_ATTRIBUTE) *n, char *text,
				char *def, char *value, int nid, int min,
				int max);
static int add_DN_object(X509_NAME *n, char *text, char *def, char *value,
	int nid,int min,int max);
static void MS_CALLBACK req_cb(int p,int n,char *arg);
@@ -1022,8 +1023,9 @@ err:
	return(ret);
	}

static int add_attribute_object(STACK *n, char *text, char *def, char *value,
	     int nid, int min, int max)
static int add_attribute_object(STACK_OF(X509_ATTRIBUTE) *n, char *text,
				char *def, char *value, int nid, int min,
				int max)
	{
	int i,z;
	X509_ATTRIBUTE *xa=NULL;
@@ -1098,7 +1100,7 @@ start:
	at=NULL;
	/* only one item per attribute */

	if (!sk_push(n,(char *)xa)) goto err;
	if (!sk_X509_ATTRIBUTE_push(n,xa)) goto err;
	return(1);
err:
	if (xa != NULL) X509_ATTRIBUTE_free(xa);
+21 −0
Original line number Diff line number Diff line
@@ -210,6 +210,10 @@ err:\
		M_ASN1_D2I_get_imp_set(r,func,free_func,\
			x,V_ASN1_CONTEXT_SPECIFIC);

#define M_ASN1_D2I_get_IMP_set_type(type,r,func,free_func,x) \
		M_ASN1_D2I_get_imp_set_type(type,r,func,free_func,\
			x,V_ASN1_CONTEXT_SPECIFIC);

#define M_ASN1_D2I_get_imp_set(r,func,free_func,a,b) \
	c.q=c.p; \
	if (d2i_ASN1_SET(&(r),&c.p,c.slen,(char *(*)())func,\
@@ -328,11 +332,20 @@ err:\
#define M_ASN1_I2D_len_IMP_SET(a,f,x) \
		ret+=i2d_ASN1_SET(a,NULL,f,x,V_ASN1_CONTEXT_SPECIFIC,IS_SET);

#define M_ASN1_I2D_len_IMP_SET_type(type,a,f,x) \
		ret+=i2d_ASN1_SET_OF_##type(a,NULL,f,x, \
					    V_ASN1_CONTEXT_SPECIFIC,IS_SET);

#define M_ASN1_I2D_len_IMP_SET_opt(a,f,x) \
		if ((a != NULL) && (sk_num(a) != 0)) \
			ret+=i2d_ASN1_SET(a,NULL,f,x,V_ASN1_CONTEXT_SPECIFIC, \
					  IS_SET);

#define M_ASN1_I2D_len_IMP_SET_opt_type(type,a,f,x) \
		if ((a != NULL) && (sk_##type##_num(a) != 0)) \
			ret+=i2d_ASN1_SET_OF_##type(a,NULL,f,x, \
					       V_ASN1_CONTEXT_SPECIFIC,IS_SET);

#define M_ASN1_I2D_len_IMP_SEQUENCE(a,f,x) \
		ret+=i2d_ASN1_SET(a,NULL,f,x,V_ASN1_CONTEXT_SPECIFIC, \
				  IS_SEQUENCE);
@@ -385,6 +398,8 @@ err:\
			V_ASN1_UNIVERSAL,IS_SET)
#define M_ASN1_I2D_put_IMP_SET(a,f,x) i2d_ASN1_SET(a,&p,f,x,\
			V_ASN1_CONTEXT_SPECIFIC,IS_SET)
#define M_ASN1_I2D_put_IMP_SET_type(type,a,f,x) \
     i2d_ASN1_SET_OF_##type(a,&p,f,x,V_ASN1_CONTEXT_SPECIFIC,IS_SET)
#define M_ASN1_I2D_put_IMP_SEQUENCE(a,f,x) i2d_ASN1_SET(a,&p,f,x,\
			V_ASN1_CONTEXT_SPECIFIC,IS_SEQUENCE)

@@ -404,6 +419,12 @@ err:\
			{ i2d_ASN1_SET(a,&p,f,x,V_ASN1_CONTEXT_SPECIFIC, \
				       IS_SET); }

#define M_ASN1_I2D_put_IMP_SET_opt_type(type,a,f,x) \
		if ((a != NULL) && (sk_##type##_num(a) != 0)) \
			{ i2d_ASN1_SET_OF_##type(a,&p,f,x, \
						 V_ASN1_CONTEXT_SPECIFIC, \
						 IS_SET); }

#define M_ASN1_I2D_put_IMP_SEQUENCE_opt(a,f,x) \
		if ((a != NULL) && (sk_num(a) != 0)) \
			{ i2d_ASN1_SET(a,&p,f,x,V_ASN1_CONTEXT_SPECIFIC, \
+4 −4
Original line number Diff line number Diff line
@@ -89,7 +89,7 @@ int X509_REQ_print(BIO *bp, X509_REQ *x)
	const char *neg;
	X509_REQ_INFO *ri;
	EVP_PKEY *pkey;
	STACK *sk;
	STACK_OF(X509_ATTRIBUTE) *sk;
	char str[128];

	ri=x->req_info;
@@ -142,7 +142,7 @@ int X509_REQ_print(BIO *bp, X509_REQ *x)
	if (BIO_puts(bp,str) <= 0) goto err;

	sk=x->req_info->attributes;
	if ((sk == NULL) || (sk_num(sk) == 0))
	if ((sk == NULL) || (sk_X509_ATTRIBUTE_num(sk) == 0))
		{
		if (!x->req_info->req_kludge)
			{
@@ -152,7 +152,7 @@ int X509_REQ_print(BIO *bp, X509_REQ *x)
		}
	else
		{
		for (i=0; i<sk_num(sk); i++)
		for (i=0; i<sk_X509_ATTRIBUTE_num(sk); i++)
			{
			ASN1_TYPE *at;
			X509_ATTRIBUTE *a;
@@ -160,7 +160,7 @@ int X509_REQ_print(BIO *bp, X509_REQ *x)
			ASN1_TYPE *t;
			int j,type=0,count=1,ii=0;

			a=(X509_ATTRIBUTE *)sk_value(sk,i);
			a=sk_X509_ATTRIBUTE_value(sk,i);
			sprintf(str,"%12s","");
			if (BIO_puts(bp,str) <= 0) goto err;
			if ((j=i2a_ASN1_OBJECT(bp,a->object)) > 0)
+12 −8
Original line number Diff line number Diff line
@@ -78,11 +78,12 @@ int i2d_X509_REQ_INFO(X509_REQ_INFO *a, unsigned char **pp)
	 */
	if (a->req_kludge) 
	        {
	        M_ASN1_I2D_len_IMP_SET_opt(a->attributes,i2d_X509_ATTRIBUTE,0);
	        M_ASN1_I2D_len_IMP_SET_opt_type(X509_ATTRIBUTE,a->attributes,i2d_X509_ATTRIBUTE,0);
		}
	else
	        {
	        M_ASN1_I2D_len_IMP_SET(a->attributes,	i2d_X509_ATTRIBUTE,0);
	        M_ASN1_I2D_len_IMP_SET_type(X509_ATTRIBUTE,a->attributes,
					    i2d_X509_ATTRIBUTE,0);
		}
	
	M_ASN1_I2D_seq_total();
@@ -98,11 +99,13 @@ int i2d_X509_REQ_INFO(X509_REQ_INFO *a, unsigned char **pp)
	 */
	if (a->req_kludge)
		{
	        M_ASN1_I2D_put_IMP_SET_opt(a->attributes,i2d_X509_ATTRIBUTE,0);
	        M_ASN1_I2D_put_IMP_SET_opt_type(X509_ATTRIBUTE,a->attributes,
						i2d_X509_ATTRIBUTE,0);
		}
	else
		{
	        M_ASN1_I2D_put_IMP_SET(a->attributes,i2d_X509_ATTRIBUTE,0);
	        M_ASN1_I2D_put_IMP_SET_type(X509_ATTRIBUTE,a->attributes,
					    i2d_X509_ATTRIBUTE,0);
		}

	M_ASN1_I2D_finish();
@@ -130,7 +133,8 @@ X509_REQ_INFO *d2i_X509_REQ_INFO(X509_REQ_INFO **a, unsigned char **pp,
		ret->req_kludge=1;
	else
		{
		M_ASN1_D2I_get_IMP_set(ret->attributes,d2i_X509_ATTRIBUTE,
		M_ASN1_D2I_get_IMP_set_type(X509_ATTRIBUTE,ret->attributes,
					    d2i_X509_ATTRIBUTE,
					    X509_ATTRIBUTE_free,0);
		}

@@ -146,7 +150,7 @@ X509_REQ_INFO *X509_REQ_INFO_new(void)
	M_ASN1_New(ret->version,ASN1_INTEGER_new);
	M_ASN1_New(ret->subject,X509_NAME_new);
	M_ASN1_New(ret->pubkey,X509_PUBKEY_new);
	M_ASN1_New(ret->attributes,sk_new_null);
	M_ASN1_New(ret->attributes,sk_X509_ATTRIBUTE_new_null);
	ret->req_kludge=0;
	return(ret);
	M_ASN1_New_Error(ASN1_F_X509_REQ_INFO_NEW);
@@ -158,7 +162,7 @@ void X509_REQ_INFO_free(X509_REQ_INFO *a)
	ASN1_INTEGER_free(a->version);
	X509_NAME_free(a->subject);
	X509_PUBKEY_free(a->pubkey);
	sk_pop_free(a->attributes,X509_ATTRIBUTE_free);
	sk_X509_ATTRIBUTE_pop_free(a->attributes,X509_ATTRIBUTE_free);
	Free((char *)a);
	}

+16 −15
Original line number Diff line number Diff line
@@ -167,13 +167,28 @@ typedef struct X509_extension_st
	void (*ex_free)();		/* clear argp stuff */
	} X509_EXTENSION;

/* a sequence of these are used */
typedef struct x509_attributes_st
	{
	ASN1_OBJECT *object;
	int set; /* 1 for a set, 0 for a single item (which is wrong) */
	union	{
		char		*ptr;
/* 1 */		STACK /* ASN1_TYPE */ *set;
/* 0 */		ASN1_TYPE	*single;
		} value;
	} X509_ATTRIBUTE;

DECLARE_STACK_OF(X509_ATTRIBUTE)
DECLARE_ASN1_SET_OF(X509_ATTRIBUTE)

typedef struct X509_req_info_st
	{
	ASN1_INTEGER *version;
	X509_NAME *subject;
	X509_PUBKEY *pubkey;
	/*  d=2 hl=2 l=  0 cons: cont: 00 */
	STACK /* X509_ATTRIBUTE */ *attributes; /* [ 0 ] */
	STACK_OF(X509_ATTRIBUTE) *attributes; /* [ 0 ] */
	int req_kludge;
	} X509_REQ_INFO;

@@ -240,20 +255,6 @@ typedef struct X509_crl_st
	int references;
	} X509_CRL;

/* a sequence of these are used */
typedef struct x509_attributes_st
	{
	ASN1_OBJECT *object;
	int set; /* 1 for a set, 0 for a single item (which is wrong) */
	union	{
		char		*ptr;
/* 1 */		STACK /* ASN1_TYPE */ *set;
/* 0 */		ASN1_TYPE	*single;
		} value;
	} X509_ATTRIBUTE;

DECLARE_STACK_OF(X509_ATTRIBUTE)

typedef struct private_key_st
	{
	int version;
Loading