Another stack.
authorBen Laurie <ben@openssl.org>
Sat, 1 May 1999 18:08:44 +0000 (18:08 +0000)
committerBen Laurie <ben@openssl.org>
Sat, 1 May 1999 18:08:44 +0000 (18:08 +0000)
apps/req.c
crypto/asn1/asn1_mac.h
crypto/asn1/t_req.c
crypto/asn1/x_req.c
crypto/x509/x509.h
crypto/x509/x509_r2x.c
crypto/x509/x509_vfy.c

index b7342f0..c3f6a1a 100644 (file)
  */
 
 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);
index f0ab1e9..2689f22 100644 (file)
@@ -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, \
index 6e04b08..b836844 100644 (file)
@@ -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)
index 0f14e30..9b1d6ab 100644 (file)
@@ -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,8 +133,9 @@ 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,
-                       X509_ATTRIBUTE_free,0);
+               M_ASN1_D2I_get_IMP_set_type(X509_ATTRIBUTE,ret->attributes,
+                                           d2i_X509_ATTRIBUTE,
+                                           X509_ATTRIBUTE_free,0);
                }
 
        M_ASN1_D2I_Finish(a,X509_REQ_INFO_free,ASN1_F_D2I_X509_REQ_INFO);
@@ -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);
        }
 
index df04cfe..5c2894b 100644 (file)
@@ -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;
index ec92d2f..bb4697a 100644 (file)
@@ -80,7 +80,7 @@ X509 *X509_REQ_to_X509(X509_REQ *r, int days, EVP_PKEY *pkey)
        /* duplicate the request */
        xi=ret->cert_info;
 
-       if (sk_num(r->req_info->attributes) != 0)
+       if (sk_X509_ATTRIBUTE_num(r->req_info->attributes) != 0)
                {
                if ((xi->version=ASN1_INTEGER_new()) == NULL) goto err;
                if (!ASN1_INTEGER_set(xi->version,2)) goto err;
index 16fef85..7bee615 100644 (file)
@@ -628,5 +628,8 @@ void X509_STORE_CTX_set_chain(X509_STORE_CTX *ctx, STACK_OF(X509) *sk)
 
 IMPLEMENT_STACK_OF(X509)
 IMPLEMENT_ASN1_SET_OF(X509)
+
 IMPLEMENT_STACK_OF(X509_NAME)
+
 IMPLEMENT_STACK_OF(X509_ATTRIBUTE)
+IMPLEMENT_ASN1_SET_OF(X509_ATTRIBUTE)