Handle ASN1_SET_OF and PKCS12_STACK_OF using function
[openssl.git] / crypto / asn1 / asn1.h
index aba0b5fe71c7d1dd7932ed5ce6b29a57446bcf6e..4aa5a5687623e30d701f608c9e26c6451a7aa460 100644 (file)
 #ifndef HEADER_ASN1_H
 #define HEADER_ASN1_H
 
-#ifdef  __cplusplus
-extern "C" {
-#endif
-
 #include <time.h>
+#ifndef NO_BIO
+#include <openssl/bio.h>
+#endif
 #include <openssl/bn.h>
 #include <openssl/stack.h>
 #include <openssl/safestack.h>
@@ -72,6 +71,10 @@ extern "C" {
 #include <openssl/vms_idhacks.h>
 #endif
 
+#ifdef  __cplusplus
+extern "C" {
+#endif
+
 #define V_ASN1_UNIVERSAL               0x00
 #define        V_ASN1_APPLICATION              0x40
 #define V_ASN1_CONTEXT_SPECIFIC                0x80
@@ -81,7 +84,7 @@ extern "C" {
 #define V_ASN1_PRIMITIVE_TAG           0x1f
 #define V_ASN1_PRIMATIVE_TAG           0x1f
 
-#define V_ASN1_APP_CHOOSE              -2      /* let the recipent choose */
+#define V_ASN1_APP_CHOOSE              -2      /* let the recipient choose */
 
 #define V_ASN1_UNDEF                   -1
 #define V_ASN1_EOC                     0
@@ -140,32 +143,10 @@ extern "C" {
 #define MBSTRING_UNIV          (MBSTRING_FLAG|3)
 #define MBSTRING_UTF8          (MBSTRING_FLAG|4)
 
-#define DECLARE_ASN1_SET_OF(type) \
-int i2d_ASN1_SET_OF_##type(STACK_OF(type) *a,unsigned char **pp, \
-                          int (*func)(type *,unsigned char **), int ex_tag, \
-                          int ex_class, int is_set); \
-STACK_OF(type) *d2i_ASN1_SET_OF_##type(STACK_OF(type) **a,unsigned char **pp, \
-                                      long length, \
-                                      type *(*func)(type **, \
-                                                    unsigned char **,long), \
-                                      void (*free_func)(type *), \
-                                      int ex_tag,int ex_class);
-
-#define IMPLEMENT_ASN1_SET_OF(type) \
-int i2d_ASN1_SET_OF_##type(STACK_OF(type) *a,unsigned char **pp, \
-                          int (*func)(type *,unsigned char **), int ex_tag, \
-                          int ex_class, int is_set) \
-    { return i2d_ASN1_SET((STACK *)a,pp,func,ex_tag,ex_class,is_set); } \
-STACK_OF(type) *d2i_ASN1_SET_OF_##type(STACK_OF(type) **a,unsigned char **pp, \
-                                      long length, \
-                                      type *(*func)(type **, \
-                                                    unsigned char **,long), \
-                                      void (*free_func)(type *), \
-                                      int ex_tag,int ex_class) \
-    { return (STACK_OF(type) *)d2i_ASN1_SET((STACK **)a,pp,length, \
-                                           (char *(*)())func, \
-                                           (void (*)())free_func, \
-                                           ex_tag,ex_class); }
+struct X509_algor_st;
+
+#define DECLARE_ASN1_SET_OF(type) /* filled in by mkstack.pl */
+#define IMPLEMENT_ASN1_SET_OF(type) /* nothing, no longer needed */
 
 typedef struct asn1_ctx_st
        {
@@ -176,7 +157,7 @@ typedef struct asn1_ctx_st
        int tag;        /* tag from last 'get object' */
        int xclass;     /* class from last 'get object' */
        long slen;      /* length of last 'get object' */
-       unsigned char *max; /* largest value of p alowed */
+       unsigned char *max; /* largest value of p allowed */
        unsigned char *q;/* temporary variable */
        unsigned char **pp;/* variable */
        int line;       /* used in error processing */
@@ -215,6 +196,7 @@ typedef struct asn1_string_st
 #define STABLE_NO_MASK         0x02
 #define DIRSTRING_TYPE \
  (B_ASN1_PRINTABLESTRING|B_ASN1_T61STRING|B_ASN1_BMPSTRING|B_ASN1_UTF8STRING)
+#define PKCS9STRING_TYPE (DIRSTRING_TYPE|B_ASN1_IA5STRING)
 
 typedef struct asn1_string_table_st {
        int nid;
@@ -237,7 +219,7 @@ DECLARE_STACK_OF(ASN1_STRING_TABLE)
 #define ub_title                       64
 #define ub_email_address               128
 
-#ifndef DEBUG
+#ifdef NO_ASN1_TYPEDEFS
 #define ASN1_INTEGER           ASN1_STRING
 #define ASN1_ENUMERATED                ASN1_STRING
 #define ASN1_BIT_STRING                ASN1_STRING
@@ -273,6 +255,9 @@ typedef struct asn1_string_st ASN1_UTF8STRING;
 
 typedef int ASN1_NULL;
 
+DECLARE_STACK_OF(ASN1_INTEGER)
+DECLARE_ASN1_SET_OF(ASN1_INTEGER)
+
 typedef struct asn1_type_st
        {
        int type;
@@ -548,7 +533,7 @@ int         ASN1_BIT_STRING_set(ASN1_BIT_STRING *a, unsigned char *d,
 int            ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value);
 int            ASN1_BIT_STRING_get_bit(ASN1_BIT_STRING *a, int n);
 
-#ifdef HEADER_BIO_H
+#ifndef NO_BIO
 int ASN1_BIT_STRING_name_print(BIO *out, ASN1_BIT_STRING *bs,
                                BIT_STRING_BITNAME *tbl, int indent);
 #endif
@@ -578,6 +563,7 @@ ASN1_ENUMERATED *d2i_ASN1_ENUMERATED(ASN1_ENUMERATED **a,unsigned char **pp,
 int ASN1_UTCTIME_check(ASN1_UTCTIME *a);
 ASN1_UTCTIME *ASN1_UTCTIME_set(ASN1_UTCTIME *s,time_t t);
 int ASN1_UTCTIME_set_string(ASN1_UTCTIME *s, char *str); 
+time_t ASN1_UTCTIME_get(const ASN1_UTCTIME *s);
 
 int ASN1_GENERALIZEDTIME_check(ASN1_GENERALIZEDTIME *a);
 ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_set(ASN1_GENERALIZEDTIME *s,time_t t);
@@ -675,7 +661,7 @@ STACK *             d2i_ASN1_SET(STACK **a, unsigned char **pp, long length,
                        char *(*func)(), void (*free_func)(),
                        int ex_tag, int ex_class);
 
-#ifdef HEADER_BIO_H
+#ifndef NO_BIO
 int i2a_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *a);
 int a2i_ASN1_INTEGER(BIO *bp,ASN1_INTEGER *bs,char *buf,int size);
 int i2a_ASN1_ENUMERATED(BIO *bp, ASN1_ENUMERATED *a);
@@ -730,7 +716,7 @@ char *ASN1_d2i_fp(char *(*xnew)(),char *(*d2i)(),FILE *fp,unsigned char **x);
 int ASN1_i2d_fp(int (*i2d)(),FILE *out,unsigned char *x);
 #endif
 
-#ifdef HEADER_BIO_H
+#ifndef NO_BIO
 char *ASN1_d2i_bio(char *(*xnew)(),char *(*d2i)(),BIO *bp,unsigned char **x);
 int ASN1_i2d_bio(int (*i2d)(),BIO *out,unsigned char *x);
 int ASN1_UTCTIME_print(BIO *fp,ASN1_UTCTIME *a);
@@ -769,7 +755,7 @@ int ASN1_TYPE_get_int_octetstring(ASN1_TYPE *a,long *num,
 STACK *ASN1_seq_unpack(unsigned char *buf, int len, char *(*d2i)(),
                                                 void (*free_func)() ); 
 unsigned char *ASN1_seq_pack(STACK *safes, int (*i2d)(), unsigned char **buf,
-                                                                int *len );
+                            int *len );
 void *ASN1_unpack_string(ASN1_STRING *oct, char *(*d2i)());
 ASN1_STRING *ASN1_pack_string(void *obj, int (*i2d)(), ASN1_OCTET_STRING **oct);
 
@@ -785,6 +771,7 @@ int ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len,
 ASN1_STRING *ASN1_STRING_set_by_NID(ASN1_STRING **out, 
                const unsigned char *in, int inlen, int inform, int nid);
 ASN1_STRING_TABLE *ASN1_STRING_TABLE_get(int nid);
+int ASN1_STRING_TABLE_add(int, long, long, unsigned long, unsigned long);
 void ASN1_STRING_TABLE_cleanup(void);
 
 /* BEGIN ERROR CODES */