Back to index

nordugrid-arc-nox  1.1.0~rc6
VOMSAttribute.h
Go to the documentation of this file.
00001 
00007 #ifndef ARC_VOMSATTRIBUTE_H
00008 #define ARC_VOMSATTRIBUTE_H
00009 
00010 #include <openssl/opensslv.h>
00011 
00012 #if (OPENSSL_VERSION_NUMBER >= 0x10000000L)
00013 // workaround for buggy openssl headers
00014 
00015 #define i2d_ASN1_SET i2d_ASN1_SET_buggy
00016 #define d2i_ASN1_SET d2i_ASN1_SET_buggy
00017 #define ASN1_seq_unpack ASN1_seq_unpack_buggy
00018 #define ASN1_seq_pack ASN1_seq_pack_buggy
00019 #include <openssl/asn1.h>
00020 #undef i2d_ASN1_SET
00021 #undef d2i_ASN1_SET
00022 #undef ASN1_seq_unpack
00023 #undef ASN1_seq_pack
00024 
00025 extern "C" {
00026 int i2d_ASN1_SET(void *a, unsigned char **pp,
00027                i2d_of_void *i2d, int ex_tag, int ex_class,
00028                int is_set);
00029 void *d2i_ASN1_SET(void *a, const unsigned char **pp,
00030                  long length, d2i_of_void *d2i,
00031                  void (*free_func)(void*), int ex_tag,
00032                  int ex_class);
00033 void *ASN1_seq_unpack(const unsigned char *buf, int len,
00034                     d2i_of_void *d2i, void (*free_func)(void*));
00035 unsigned char *ASN1_seq_pack(void *safes, i2d_of_void *i2d,
00036                           unsigned char **buf, int *len );
00037 }
00038 
00039 #endif
00040 
00041 #include <openssl/evp.h>
00042 #include <openssl/asn1_mac.h>
00043 #include <openssl/x509.h>
00044 #include <openssl/x509v3.h>
00045 #include <openssl/stack.h>
00046 #include <openssl/safestack.h>
00047 #include <openssl/err.h>
00048 
00049 namespace ArcCredential {
00050 
00051 #define ASN1_F_D2I_AC_ATTR          5000
00052 #define AC_F_ATTR_New               5001
00053 #define ASN1_F_D2I_AC_ROLE          5002
00054 #define AC_F_ROLE_New               5003
00055 #define ASN1_F_D2I_AC_IETFATTR      5004
00056 #define AC_F_IETFATTR_New           5005
00057 #define ASN1_F_D2I_AC_IETFATTRVAL   5006
00058 #define ASN1_F_D2I_AC_DIGEST        5007
00059 #define AC_F_DIGEST_New             5008
00060 #define ASN1_F_D2I_AC_IS            5009
00061 #define AC_F_AC_IS_New              5010
00062 #define ASN1_F_D2I_AC_FORM          5011
00063 #define AC_F_AC_FORM_New            5012
00064 #define ASN1_F_D2I_AC_ACI           5013
00065 #define ASN1_F_AC_ACI_New           5014
00066 #define ASN1_F_D2I_AC_HOLDER        5015
00067 #define ASN1_F_AC_HOLDER_New        5016
00068 #define ASN1_F_AC_VAL_New           5017
00069 #define AC_F_AC_INFO_NEW            5018
00070 #define AC_F_D2I_AC                 5019
00071 #define AC_F_AC_New                 5020
00072 #define ASN1_F_I2D_AC_IETFATTRVAL   5021
00073 #define AC_F_D2I_AC_DIGEST          5022
00074 #define AC_F_AC_DIGEST_New          5023
00075 #define AC_F_D2I_AC_IS              5024
00076 #define AC_ERR_UNSET                5025
00077 #define AC_ERR_SET                  5026
00078 #define AC_ERR_SIGNATURE            5027
00079 #define AC_ERR_VERSION              5028
00080 #define AC_ERR_HOLDER_SERIAL        5029
00081 #define AC_ERR_HOLDER               5030
00082 #define AC_ERR_UID_MISMATCH         5031
00083 #define AC_ERR_ISSUER_NAME          5032
00084 #define AC_ERR_SERIAL               5033
00085 #define AC_ERR_DATES                5034
00086 #define AC_ERR_ATTRIBS              5035
00087 #define AC_F_AC_TARGET_New          5036
00088 #define ASN1_F_D2I_AC_TARGET        5037
00089 #define AC_F_AC_TARGETS_New         5036
00090 #define ASN1_F_D2I_AC_TARGETS       5037
00091 #define ASN1_F_D2I_AC_SEQ           5038
00092 #define AC_F_AC_SEQ_new             5039
00093 #define AC_ERR_ATTRIB_URI           5040
00094 #define AC_ERR_ATTRIB_FQAN          5041
00095 #define AC_ERR_EXTS_ABSENT          5042
00096 #define AC_ERR_MEMORY               5043
00097 #define AC_ERR_EXT_CRIT             5044
00098 #define AC_ERR_EXT_TARGET           5045
00099 #define AC_ERR_EXT_KEY              5046
00100 #define AC_ERR_UNKNOWN              5047
00101 
00102 #define AC_ERR_PARAMETERS           5048
00103 #define X509_ERR_ISSUER_NAME        5049
00104 #define X509_ERR_HOLDER_NAME        5050
00105 #define AC_ERR_NO_EXTENSION         5051
00106 
00107 #define ASN1_F_D2I_AC_CERTS         5052
00108 #define AC_F_X509_New               5053
00109 
00110 #define AC_F_D2I_AC_ATTRIBUTE       5054
00111 #define AC_F_ATTRIBUTE_New          5055
00112 #define ASN1_F_D2I_AC_ATT_HOLDER    5056
00113 #define AC_F_AC_ATT_HOLDER_New      5057
00114 #define ASN1_F_D2I_AC_FULL_ATTRIBUTES 5058
00115 #define AC_F_AC_FULL_ATTRIBUTES_New 5059
00116 #define ASN1_F_D2I_AC_ATTRIBUTEVAL  5060
00117 #define ASN1_F_I2D_AC_ATTRIBUTEVAL  5061
00118 #define AC_F_AC_ATTRIBUTEVAL_New    5062
00119 #define AC_ERR_ATTRIB               5063
00120 
00121 typedef struct ACDIGEST {
00122   ASN1_ENUMERATED *type;
00123   ASN1_OBJECT     *oid;
00124   X509_ALGOR      *algor;
00125   ASN1_BIT_STRING *digest;
00126 } AC_DIGEST;
00127 
00128 typedef struct ACIS {
00129   STACK_OF(GENERAL_NAME) *issuer;
00130   ASN1_INTEGER  *serial;
00131   ASN1_BIT_STRING *uid;
00132 } AC_IS;
00133 
00134 typedef struct ACFORM {
00135   STACK_OF(GENERAL_NAME) *names;
00136   AC_IS         *is;
00137   AC_DIGEST     *digest;
00138 } AC_FORM;
00139 
00140 typedef struct ACACI {
00141   STACK_OF(GENERAL_NAME) *names;
00142   AC_FORM       *form;
00143 } AC_ACI;
00144 
00145 typedef struct ACHOLDER {
00146   AC_IS         *baseid;
00147   STACK_OF(GENERAL_NAME) *name;
00148   AC_DIGEST     *digest;
00149 } AC_HOLDER;
00150 
00151 typedef struct ACVAL {
00152   ASN1_GENERALIZEDTIME *notBefore;
00153   ASN1_GENERALIZEDTIME *notAfter;
00154 } AC_VAL;
00155 
00156 typedef struct asn1_string_st AC_IETFATTRVAL;
00157 
00158 typedef struct ACIETFATTR {
00159   STACK_OF(GENERAL_NAME)   *names;
00160   STACK_OF(AC_IETFATTRVAL) *values;
00161 } AC_IETFATTR;
00162 
00163 typedef struct ACTARGET {
00164   GENERAL_NAME *name;
00165   GENERAL_NAME *group;
00166   AC_IS        *cert;
00167 } AC_TARGET;
00168  
00169 typedef struct ACTARGETS {
00170   STACK_OF(AC_TARGET) *targets;
00171 } AC_TARGETS;
00172 
00173 typedef struct ACATTR {
00174   ASN1_OBJECT * type;
00175   int get_type;
00176   STACK_OF(AC_IETFATTR) *ietfattr;
00177   STACK_OF(AC_FULL_ATTRIBUTES) *fullattributes;
00178 } AC_ATTR;
00179 #define GET_TYPE_FQAN 1
00180 #define GET_TYPE_ATTRIBUTES 2
00181 
00182 typedef struct ACINFO {
00183   ASN1_INTEGER             *version;
00184   AC_HOLDER                *holder;
00185   AC_FORM                  *form;
00186   X509_ALGOR               *alg;
00187   ASN1_INTEGER             *serial;
00188   AC_VAL                   *validity;
00189   STACK_OF(AC_ATTR)        *attrib;
00190   ASN1_BIT_STRING          *id;
00191   STACK_OF(X509_EXTENSION) *exts;
00192 } AC_INFO;
00193 
00194 typedef struct ACC {
00195   AC_INFO         *acinfo;
00196   X509_ALGOR      *sig_alg;
00197   ASN1_BIT_STRING *signature;
00198 } AC;
00199 
00200 typedef struct ACSEQ {
00201   STACK_OF(AC) *acs;
00202 } AC_SEQ;
00203 
00204 typedef struct ACCERTS {
00205   STACK_OF(X509) *stackcert;
00206 } AC_CERTS;
00207 
00208 typedef struct ACATTRIBUTE {
00209   ASN1_OCTET_STRING *name;
00210   ASN1_OCTET_STRING *qualifier;
00211   ASN1_OCTET_STRING *value;
00212 } AC_ATTRIBUTE;
00213 
00214 typedef struct ACATTHOLDER {
00215   STACK_OF(GENERAL_NAME) *grantor;
00216   STACK_OF(AC_ATTRIBUTE) *attributes;
00217 } AC_ATT_HOLDER;
00218 
00219 typedef struct ACFULLATTRIBUTES {
00220   STACK_OF(AC_ATT_HOLDER) *providers;
00221 } AC_FULL_ATTRIBUTES;
00222 
00223 #if (OPENSSL_VERSION_NUMBER >= 0x10000000L)
00224 #define IMPL_STACK(type)                                       \
00225   DECLARE_STACK_OF(type)                                       \
00226   STACK_OF(type) *sk_##type##_new (int (*cmp)(const type * const *,   \
00227                                          const type * const *))       \
00228     { return (STACK_OF(type) *)sk_new(CHECKED_SK_CMP_FUNC(type, cmp));}                    \
00229   STACK_OF(type) *sk_##type##_new_null () { return (STACK_OF(type) *)sk_new_null(); }      \
00230   void   sk_##type##_free (STACK_OF(type) *st) { sk_free(CHECKED_STACK_OF(type, st)); } \
00231   int    sk_##type##_num (const STACK_OF(type) *st) { return sk_num(CHECKED_STACK_OF(type, st)); } \
00232   type  *sk_##type##_value (const STACK_OF(type) *st, int i) { return (type *)sk_value(CHECKED_STACK_OF(type, st), i); } \
00233   type  *sk_##type##_set (STACK_OF(type) *st, int i, type *val) { return (type *)sk_set(CHECKED_STACK_OF(type, st), i, CHECKED_PTR_OF(type, val)); } \
00234   void   sk_##type##_zero (STACK_OF(type) *st) { sk_zero(CHECKED_STACK_OF(type, st)); } \
00235   int    sk_##type##_push (STACK_OF(type) *st, type *val) { return sk_push(CHECKED_STACK_OF(type, st), CHECKED_PTR_OF(type, val)); } \
00236   int    sk_##type##_unshift (STACK_OF(type) *st, type *val) { return sk_unshift(CHECKED_STACK_OF(type, st), CHECKED_PTR_OF(type, val)); } \
00237   int    sk_##type##_find (STACK_OF(type) *st, type *val) { return sk_find(CHECKED_STACK_OF(type, st), CHECKED_PTR_OF(type, val)); } \
00238   type  *sk_##type##_delete (STACK_OF(type) *st, int i) { return (type *)sk_delete(CHECKED_STACK_OF(type, st), i); } \
00239   type  *sk_##type##_delete_ptr (STACK_OF(type) *st, type *ptr) { return (type *)sk_delete_ptr(CHECKED_STACK_OF(type, st), CHECKED_PTR_OF(type, ptr)); } \
00240   int    sk_##type##_insert (STACK_OF(type) *st, type *val, int i) { return sk_insert(CHECKED_STACK_OF(type, st), CHECKED_PTR_OF(type, val), i); } \
00241   int (*sk_##type##_set_cmp_func (STACK_OF(type) *st, int (*cmp)(const type * const *, const type * const *)))(const type * const *, const type * const *) \
00242     { return (int ((*)(const type * const *, const type * const *)))sk_set_cmp_func(CHECKED_STACK_OF(type, st), CHECKED_SK_CMP_FUNC(type, cmp)); } \
00243   STACK_OF(type) *sk_##type##_dup (STACK_OF(type) *st) { return (STACK_OF(type) *)sk_dup(CHECKED_STACK_OF(type, st)); } \
00244   void   sk_##type##_pop_free (STACK_OF(type) *st, void (*func)(type *)) { sk_pop_free(CHECKED_STACK_OF(type, st), CHECKED_SK_FREE_FUNC(type, func)); } \
00245   type  *sk_##type##_shift (STACK_OF(type) *st) { return (type *)sk_shift(CHECKED_STACK_OF(type, st)); } \
00246   type  *sk_##type##_pop (STACK_OF(type) *st) { return (type *)sk_pop(CHECKED_STACK_OF(type, st)); } \
00247   void   sk_##type##_sort (STACK_OF(type) *st) { sk_sort(CHECKED_STACK_OF(type, st)); }           \
00248   STACK_OF(type) *d2i_ASN1_SET_OF_##type (STACK_OF(type) *st, const unsigned char **pp, long length, type *(*d2ifunc)(type**, const unsigned char**, long), void (*freefunc)(type *), int ex_tag, int ex_class) \
00249     { return (STACK_OF(type) *)d2i_ASN1_SET(CHECKED_STACK_OF(type, st), \
00250                             pp, length, \
00251                             CHECKED_D2I_OF(type, d2ifunc), \
00252                             CHECKED_SK_FREE_FUNC(type, freefunc), \
00253                             ex_tag, ex_class); } \
00254   int i2d_ASN1_SET_OF_##type (STACK_OF(type) *st, unsigned char **pp, int (*i2dfunc)(type*, unsigned char**), int ex_tag, int ex_class, int is_set) \
00255   { return i2d_ASN1_SET(CHECKED_STACK_OF(type, st), pp, \
00256                             CHECKED_I2D_OF(type, i2dfunc), \
00257                             ex_tag, ex_class, is_set); }       \
00258   unsigned char *ASN1_seq_pack_##type (STACK_OF(type) *st, int (*i2dfunc)(type*, unsigned char**), unsigned char **buf, int *len) { return ASN1_seq_pack(CHECKED_PTR_OF(STACK_OF(type), st), \
00259                      CHECKED_I2D_OF(type, i2dfunc), buf, len); } \
00260   STACK_OF(type) *ASN1_seq_unpack_##type (unsigned char *buf, int len, type *(*d2ifunc)(type**, const unsigned char**, long), void (*freefunc)(type *)) \
00261        { return (STACK_OF(type) *)ASN1_seq_unpack(buf, len, CHECKED_D2I_OF(type, d2ifunc), CHECKED_SK_FREE_FUNC(type, freefunc)); }
00262 
00263 #define DECL_STACK(type)  \
00264    PREDECLARE_STACK_OF(type) \
00265    STACK_OF(type) *sk_##type##_new (int (*)(const type * const *, const type * const *)); \
00266    STACK_OF(type) *sk_##type##_new_null (); \
00267    void   sk_##type##_free (STACK_OF(type) *); \
00268    int    sk_##type##_num (const STACK_OF(type) *); \
00269    type  *sk_##type##_value (const STACK_OF(type) *, int); \
00270    type  *sk_##type##_set (STACK_OF(type) *, int, type *); \
00271    void   sk_##type##_zero (STACK_OF(type) *); \
00272    int    sk_##type##_push (STACK_OF(type) *, type *); \
00273    int    sk_##type##_unshift (STACK_OF(type) *, type *); \
00274    int    sk_##type##_find (STACK_OF(type) *, type *); \
00275    type  *sk_##type##_delete (STACK_OF(type) *, int); \
00276    type  *sk_##type##_delete_ptr (STACK_OF(type) *, type *); \
00277    int    sk_##type##_insert (STACK_OF(type) *, type *, int); \
00278    int (*sk_##type##_set_cmp_func (STACK_OF(type) *, int (*)(const type * const *, const type * const *)))(const type * const *, const type * const *); \
00279    STACK_OF(type) *sk_##type##_dup (STACK_OF(type) *); \
00280    void   sk_##type##_pop_free (STACK_OF(type) *, void (*)(type *)); \
00281    type  *sk_##type##_shift (STACK_OF(type) *); \
00282    type  *sk_##type##_pop (STACK_OF(type) *); \
00283    void   sk_##type##_sort (STACK_OF(type) *); \
00284    STACK_OF(type) *d2i_ASN1_SET_OF_##type (STACK_OF(type) *, const unsigned char **, long, type *(*)(type**, const unsigned char **, long), void (*)(type *), int, int); \
00285    int i2d_ASN1_SET_OF_##type (STACK_OF(type) *, unsigned char **, int (*)(type*, unsigned char**), int, int, int); \
00286    unsigned char *ASN1_seq_pack_##type (STACK_OF(type) *, int (*)(type*, unsigned char**), unsigned char **, int *); \
00287    STACK_OF(type) *ASN1_seq_unpack_##type (unsigned char *, int, type *(*)(), void (*)(type *)) ;
00288 
00289 #elif (OPENSSL_VERSION_NUMBER >= 0x0090800fL)
00290 #define IMPL_STACK(type) \
00291    DECLARE_STACK_OF(type) \
00292    STACK_OF(type) *sk_##type##_new (int (*cmp)(const type * const *, const type * const *)) \
00293        { return sk_new ( (int (*)(const char * const *, const char * const *))cmp);} \
00294    STACK_OF(type) *sk_##type##_new_null () { return sk_new_null(); } \
00295    void   sk_##type##_free (STACK_OF(type) *st) { sk_free(st); } \
00296    int    sk_##type##_num (const STACK_OF(type) *st) { return sk_num(st); } \
00297    type  *sk_##type##_value (const STACK_OF(type) *st, int i) { return (type *)sk_value(st, i); } \
00298    type  *sk_##type##_set (STACK_OF(type) *st, int i, type *val) { return ((type *)sk_set(st, i, (char *)val)); } \
00299    void   sk_##type##_zero (STACK_OF(type) *st) { sk_zero(st);} \
00300    int    sk_##type##_push (STACK_OF(type) *st, type *val) { return sk_push(st, (char *)val); } \
00301    int    sk_##type##_unshift (STACK_OF(type) *st, type *val) { return sk_unshift(st, (char *)val); } \
00302    int    sk_##type##_find (STACK_OF(type) *st, type *val) { return sk_find(st, (char *)val); } \
00303    type  *sk_##type##_delete (STACK_OF(type) *st, int i) { return (type *)sk_delete(st, i); } \
00304    type  *sk_##type##_delete_ptr (STACK_OF(type) *st, type *ptr) { return (type *)sk_delete_ptr(st, (char *)ptr); } \
00305    int    sk_##type##_insert (STACK_OF(type) *st, type *val, int i) { return sk_insert(st, (char *)val, i); } \
00306    int (*sk_##type##_set_cmp_func (STACK_OF(type) *st, int (*cmp)(const type * const *, const type * const *)))(const type * const *, const type * const *) \
00307        { return (int ((*)(const type * const *, const type * const *)))sk_set_cmp_func (st, (int (*)(const char * const *, const char * const *))cmp); } \
00308    STACK_OF(type) *sk_##type##_dup (STACK_OF(type) *st) { return sk_dup(st); } \
00309    void   sk_##type##_pop_free (STACK_OF(type) *st, void (*func)(type *)) { sk_pop_free(st, (void (*)(void *))func); } \
00310    type  *sk_##type##_shift (STACK_OF(type) *st) { return (type *)sk_shift(st); } \
00311    type  *sk_##type##_pop (STACK_OF(type) *st) { return (type *)sk_pop(st); } \
00312    void   sk_##type##_sort (STACK_OF(type) *st) { sk_sort(st); } \
00313    STACK_OF(type) *d2i_ASN1_SET_OF_##type (STACK_OF(type) **st, const unsigned char **pp, long length, type *(*d2ifunc)(), void (*freefunc)(type *), int ex_tag, int ex_class) \
00314        { return d2i_ASN1_SET(st, pp, length, (void*(*)(void**, const unsigned char**, long int))d2ifunc, (void (*)(void *))freefunc, ex_tag, ex_class); } \
00315    int i2d_ASN1_SET_OF_##type (STACK_OF(type) *st, unsigned char **pp, int (*i2dfunc)(void*, unsigned char**), int ex_tag, int ex_class, int is_set) \
00316        { return i2d_ASN1_SET(st, pp, i2dfunc, ex_tag, ex_class, is_set); }  \
00317    unsigned char *ASN1_seq_pack_##type (STACK_OF(type) *st, int (*i2d)(void*, unsigned char**), unsigned char **buf, int *len) { return ASN1_seq_pack(st, i2d, buf, len); } \
00318    STACK_OF(type) *ASN1_seq_unpack_##type (unsigned char *buf, int len, type *(*d2i)(), void (*freefunc)(type *)) \
00319        { return ASN1_seq_unpack(buf, len, (void*(*)(void**, const unsigned char**, long int))d2i, (void (*)(void *))freefunc); }
00320 
00321 #define DECL_STACK(type) \
00322    PREDECLARE_STACK_OF(type) \
00323    STACK_OF(type) *sk_##type##_new (int (*)(const type * const *, const type * const *)); \
00324    STACK_OF(type) *sk_##type##_new_null (); \
00325    void   sk_##type##_free (STACK_OF(type) *); \
00326    int    sk_##type##_num (const STACK_OF(type) *); \
00327    type  *sk_##type##_value (const STACK_OF(type) *, int); \
00328    type  *sk_##type##_set (STACK_OF(type) *, int, type *); \
00329    void   sk_##type##_zero (STACK_OF(type) *); \
00330    int    sk_##type##_push (STACK_OF(type) *, type *); \
00331    int    sk_##type##_unshift (STACK_OF(type) *, type *); \
00332    int    sk_##type##_find (STACK_OF(type) *, type *); \
00333    type  *sk_##type##_delete (STACK_OF(type) *, int); \
00334    type  *sk_##type##_delete_ptr (STACK_OF(type) *, type *); \
00335    int    sk_##type##_insert (STACK_OF(type) *, type *, int); \
00336    int (*sk_##type##_set_cmp_func (STACK_OF(type) *, int (*)(const type * const *, const type * const *)))(const type * const *, const type * const *); \
00337    STACK_OF(type) *sk_##type##_dup (STACK_OF(type) *); \
00338    void   sk_##type##_pop_free (STACK_OF(type) *, void (*)(type *)); \
00339    type  *sk_##type##_shift (STACK_OF(type) *); \
00340    type  *sk_##type##_pop (STACK_OF(type) *); \
00341    void   sk_##type##_sort (STACK_OF(type) *); \
00342    STACK_OF(type) *d2i_ASN1_SET_OF_##type (STACK_OF(type) **, const unsigned char **, long, type *(*)(), void (*)(type *), int, int); \
00343    int i2d_ASN1_SET_OF_##type (STACK_OF(type) *, unsigned char **, int (*)(void*, unsigned char**), int, int, int); \
00344    unsigned char *ASN1_seq_pack_##type (STACK_OF(type) *, int (*)(void*, unsigned char**), unsigned char **, int *); \
00345    STACK_OF(type) *ASN1_seq_unpack_##type (unsigned char *, int, type *(*)(), void (*)(type *)) ;
00346 
00347 #else
00348 #define IMPL_STACK(type) \
00349    DECLARE_STACK_OF(type) \
00350    STACK_OF(type) *sk_##type##_new (int (*cmp)(const type * const *, const type * const *)) \
00351        { return sk_new ( (int (*)(const char * const *, const char * const *))cmp);} \
00352    STACK_OF(type) *sk_##type##_new_null () { return sk_new_null(); } \
00353    void   sk_##type##_free (STACK_OF(type) *st) { sk_free(st); } \
00354    int    sk_##type##_num (const STACK_OF(type) *st) { return sk_num(st); } \
00355    type  *sk_##type##_value (const STACK_OF(type) *st, int i) { return (type *)sk_value(st, i); } \
00356    type  *sk_##type##_set (STACK_OF(type) *st, int i, type *val) { return ((type *)sk_set(st, i, (char *)val)); } \
00357    void   sk_##type##_zero (STACK_OF(type) *st) { sk_zero(st);} \
00358    int    sk_##type##_push (STACK_OF(type) *st, type *val) { return sk_push(st, (char *)val); } \
00359    int    sk_##type##_unshift (STACK_OF(type) *st, type *val) { return sk_unshift(st, (char *)val); } \
00360    int    sk_##type##_find (STACK_OF(type) *st, type *val) { return sk_find(st, (char *)val); } \
00361    type  *sk_##type##_delete (STACK_OF(type) *st, int i) { return (type *)sk_delete(st, i); } \
00362    type  *sk_##type##_delete_ptr (STACK_OF(type) *st, type *ptr) { return (type *)sk_delete_ptr(st, (char *)ptr); } \
00363    int    sk_##type##_insert (STACK_OF(type) *st, type *val, int i) { return sk_insert(st, (char *)val, i); } \
00364    int (*sk_##type##_set_cmp_func (STACK_OF(type) *st, int (*cmp)(const type * const *, const type * const *)))(const type * const *, const type * const *) \
00365        { return (int ((*)(const type * const *, const type * const *)))sk_set_cmp_func (st, (int (*)(const char * const *, const char * const *))cmp); } \
00366    STACK_OF(type) *sk_##type##_dup (STACK_OF(type) *st) { return sk_dup(st); } \
00367    void   sk_##type##_pop_free (STACK_OF(type) *st, void (*func)(type *)) { sk_pop_free(st, (void (*)(void *))func); } \
00368    type  *sk_##type##_shift (STACK_OF(type) *st) { return (type *)sk_shift(st); } \
00369    type  *sk_##type##_pop (STACK_OF(type) *st) { return (type *)sk_pop(st); } \
00370    void   sk_##type##_sort (STACK_OF(type) *st) { sk_sort(st); } \
00371    STACK_OF(type) *d2i_ASN1_SET_OF_##type (STACK_OF(type) **st, unsigned char **pp, long length, type *(*d2ifunc)(), void (*freefunc)(type *), int ex_tag, int ex_class) \
00372        { return d2i_ASN1_SET(st, pp, length, (char *(*)())d2ifunc, (void (*)(void *))freefunc, ex_tag, ex_class); } \
00373    int i2d_ASN1_SET_OF_##type (STACK_OF(type) *st, unsigned char **pp, int (*i2dfunc)(), int ex_tag, int ex_class, int is_set) \
00374        { return i2d_ASN1_SET(st, pp, i2dfunc, ex_tag, ex_class, is_set); }  \
00375    unsigned char *ASN1_seq_pack_##type (STACK_OF(type) *st, int (*i2d)(), unsigned char **buf, int *len) { return ASN1_seq_pack(st, i2d, buf, len); } \
00376    STACK_OF(type) *ASN1_seq_unpack_##type (unsigned char *buf, int len, type *(*d2i)(), void (*freefunc)(type *)) \
00377        { return ASN1_seq_unpack(buf, len, (char *(*)())d2i, (void (*)(void *))freefunc); }
00378 
00379 #define DECL_STACK(type) \
00380    PREDECLARE_STACK_OF(type) \
00381    STACK_OF(type) *sk_##type##_new (int (*)(const type * const *, const type * const *)); \
00382    STACK_OF(type) *sk_##type##_new_null (); \
00383    void   sk_##type##_free (STACK_OF(type) *); \
00384    int    sk_##type##_num (const STACK_OF(type) *); \
00385    type  *sk_##type##_value (const STACK_OF(type) *, int); \
00386    type  *sk_##type##_set (STACK_OF(type) *, int, type *); \
00387    void   sk_##type##_zero (STACK_OF(type) *); \
00388    int    sk_##type##_push (STACK_OF(type) *, type *); \
00389    int    sk_##type##_unshift (STACK_OF(type) *, type *); \
00390    int    sk_##type##_find (STACK_OF(type) *, type *); \
00391    type  *sk_##type##_delete (STACK_OF(type) *, int); \
00392    type  *sk_##type##_delete_ptr (STACK_OF(type) *, type *); \
00393    int    sk_##type##_insert (STACK_OF(type) *, type *, int); \
00394    int (*sk_##type##_set_cmp_func (STACK_OF(type) *, int (*)(const type * const *, const type * const *)))(const type * const *, const type * const *); \
00395    STACK_OF(type) *sk_##type##_dup (STACK_OF(type) *); \
00396    void   sk_##type##_pop_free (STACK_OF(type) *, void (*)(type *)); \
00397    type  *sk_##type##_shift (STACK_OF(type) *); \
00398    type  *sk_##type##_pop (STACK_OF(type) *); \
00399    void   sk_##type##_sort (STACK_OF(type) *); \
00400    STACK_OF(type) *d2i_ASN1_SET_OF_##type (STACK_OF(type) **, unsigned char **, long, type *(*)(), void (*)(type *), int, int); \
00401    int i2d_ASN1_SET_OF_##type (STACK_OF(type) *, unsigned char **, int (*)(), int, int, int); \
00402    unsigned char *ASN1_seq_pack_##type (STACK_OF(type) *, int (*)(), unsigned char **, int *); \
00403    STACK_OF(type) *ASN1_seq_unpack_##type (unsigned char *, int, type *(*)(), void (*)(type *)) ;
00404 #endif
00405 
00406 DECL_STACK(AC_TARGET)
00407 DECL_STACK(AC_TARGETS)
00408 DECL_STACK(AC_IETFATTR)
00409 DECL_STACK(AC_IETFATTRVAL)
00410 DECL_STACK(AC_ATTR)
00411 DECL_STACK(AC)
00412 DECL_STACK(AC_INFO)
00413 DECL_STACK(AC_VAL)
00414 DECL_STACK(AC_HOLDER)
00415 DECL_STACK(AC_ACI)
00416 DECL_STACK(AC_FORM)
00417 DECL_STACK(AC_IS)
00418 DECL_STACK(AC_DIGEST)
00419 DECL_STACK(AC_CERTS)
00420 DECL_STACK(AC_ATTRIBUTE)
00421 DECL_STACK(AC_ATT_HOLDER)
00422 DECL_STACK(AC_FULL_ATTRIBUTES)
00423 
00424 #if (OPENSSL_VERSION_NUMBER >= 0x0090800fL)
00425 #define SSLCONST const
00426 #else
00427 #define SSLCONST
00428 #endif
00429 
00430 int i2d_AC_ATTR(AC_ATTR *a, unsigned char **pp);
00431 AC_ATTR *d2i_AC_ATTR(AC_ATTR **a, SSLCONST unsigned char **p, long length);
00432 AC_ATTR *AC_ATTR_new();
00433 void AC_ATTR_free(AC_ATTR *a);
00434 
00435 int i2d_AC_IETFATTR(AC_IETFATTR *a, unsigned char **pp);
00436 AC_IETFATTR *d2i_AC_IETFATTR(AC_IETFATTR **a, SSLCONST unsigned char **p, long length);
00437 AC_IETFATTR *AC_IETFATTR_new();
00438 void AC_IETFATTR_free (AC_IETFATTR *a);
00439 
00440 int i2d_AC_IETFATTRVAL(AC_IETFATTRVAL *a, unsigned char **pp);
00441 AC_IETFATTRVAL *d2i_AC_IETFATTRVAL(AC_IETFATTRVAL **a, SSLCONST unsigned char **pp, long length);
00442 AC_IETFATTRVAL *AC_IETFATTRVAL_new();
00443 void AC_IETFATTRVAL_free(AC_IETFATTRVAL *a);
00444 
00445 int i2d_AC_DIGEST(AC_DIGEST *a, unsigned char **pp);
00446 AC_DIGEST *d2i_AC_DIGEST(AC_DIGEST **a, SSLCONST unsigned char **pp, long length);
00447 AC_DIGEST *AC_DIGEST_new(void);
00448 void AC_DIGEST_free(AC_DIGEST *a);
00449 
00450 int i2d_AC_IS(AC_IS *a, unsigned char **pp);
00451 AC_IS *d2i_AC_IS(AC_IS **a, SSLCONST unsigned char **pp, long length);
00452 AC_IS *AC_IS_new(void);
00453 void AC_IS_free(AC_IS *a);
00454 
00455 int i2d_AC_FORM(AC_FORM *a, unsigned char **pp);
00456 AC_FORM *d2i_AC_FORM(AC_FORM **a, SSLCONST unsigned char **pp, long length);
00457 AC_FORM *AC_FORM_new(void);
00458 void AC_FORM_free(AC_FORM *a);
00459 
00460 int i2d_AC_ACI(AC_ACI *a, unsigned char **pp);
00461 AC_ACI *d2i_AC_ACI(AC_ACI **a, SSLCONST unsigned char **pp, long length);
00462 AC_ACI *AC_ACI_new(void);
00463 void AC_ACI_free(AC_ACI *a);
00464 
00465 int i2d_AC_HOLDER(AC_HOLDER *a, unsigned char **pp);
00466 AC_HOLDER *d2i_AC_HOLDER(AC_HOLDER **a, SSLCONST unsigned char **pp, long length);
00467 AC_HOLDER *AC_HOLDER_new(void);
00468 void AC_HOLDER_free(AC_HOLDER *a);
00469 
00470 /* new AC_VAL functions by Valerio */
00471 int i2d_AC_VAL(AC_VAL *a, unsigned char **pp);
00472 AC_VAL *d2i_AC_VAL(AC_VAL **a, SSLCONST unsigned char **pp, long length);
00473 AC_VAL *AC_VAL_new(void);
00474 void AC_VAL_free(AC_VAL *a);
00475 /* end */
00476 
00477 int i2d_AC_INFO(AC_INFO *a, unsigned char **pp);
00478 AC_INFO *d2i_AC_INFO(AC_INFO **a, SSLCONST unsigned char **p, long length);
00479 AC_INFO *AC_INFO_new(void);
00480 void AC_INFO_free(AC_INFO *a);
00481 
00482 int i2d_AC(AC *a, unsigned char **pp) ;
00483 AC *d2i_AC(AC **a, SSLCONST unsigned char **pp, long length);
00484 AC *AC_new(void);
00485 void AC_free(AC *a);
00486 
00487 int i2d_AC_TARGETS(AC_TARGETS *a, unsigned char **pp) ;
00488 AC_TARGETS *d2i_AC_TARGETS(AC_TARGETS **a, SSLCONST unsigned char **pp, long length);
00489 AC_TARGETS *AC_TARGETS_new(void);
00490 void AC_TARGETS_free(AC_TARGETS *a);
00491 
00492 int i2d_AC_TARGET(AC_TARGET *a, unsigned char **pp) ;
00493 AC_TARGET *d2i_AC_TARGET(AC_TARGET **a, SSLCONST unsigned char **pp, long length);
00494 AC_TARGET *AC_TARGET_new(void);
00495 void AC_TARGET_free(AC_TARGET *a);
00496 
00497 int i2d_AC_SEQ(AC_SEQ *a, unsigned char **pp) ;
00498 AC_SEQ *d2i_AC_SEQ(AC_SEQ **a, SSLCONST unsigned char **pp, long length);
00499 AC_SEQ *AC_SEQ_new(void);
00500 void AC_SEQ_free(AC_SEQ *a);
00501 
00502 int i2d_AC_CERTS(AC_CERTS *a, unsigned char **pp) ;
00503 AC_CERTS *d2i_AC_CERTS(AC_CERTS **a, SSLCONST unsigned char **pp, long length);
00504 AC_CERTS *AC_CERTS_new(void);
00505 void AC_CERTS_free(AC_CERTS *a);
00506 
00507 int i2d_AC_ATTRIBUTE(AC_ATTRIBUTE *, unsigned char **);
00508 AC_ATTRIBUTE *d2i_AC_ATTRIBUTE(AC_ATTRIBUTE **, SSLCONST unsigned char **, long);
00509 AC_ATTRIBUTE *AC_ATTRIBUTE_new();
00510 void AC_ATTRIBUTE_free(AC_ATTRIBUTE *);
00511 
00512 int i2d_AC_ATT_HOLDER(AC_ATT_HOLDER *, unsigned char **);
00513 AC_ATT_HOLDER *d2i_AC_ATT_HOLDER(AC_ATT_HOLDER **, SSLCONST unsigned char **, long);
00514 AC_ATT_HOLDER *AC_ATT_HOLDER_new();
00515 void AC_ATT_HOLDER_free(AC_ATT_HOLDER *);
00516 
00517 int i2d_AC_FULL_ATTRIBUTES(AC_FULL_ATTRIBUTES *, unsigned char **);
00518 AC_FULL_ATTRIBUTES *d2i_AC_FULL_ATTRIBUTES(AC_FULL_ATTRIBUTES **, SSLCONST unsigned char **, long);
00519 AC_FULL_ATTRIBUTES *AC_FULL_ATTRIBUTES_new();
00520 void AC_FULL_ATTRIBUTES_free(AC_FULL_ATTRIBUTES *);
00521 
00522 X509V3_EXT_METHOD * VOMSAttribute_auth_x509v3_ext_meth();
00523 X509V3_EXT_METHOD * VOMSAttribute_avail_x509v3_ext_meth();
00524 X509V3_EXT_METHOD * VOMSAttribute_targets_x509v3_ext_meth();
00525 X509V3_EXT_METHOD * VOMSAttribute_acseq_x509v3_ext_meth();
00526 X509V3_EXT_METHOD * VOMSAttribute_certseq_x509v3_ext_meth();
00527 X509V3_EXT_METHOD * VOMSAttribute_attribs_x509v3_ext_meth();
00528 
00529 } // namespace ArcCredential
00530 
00531 #endif