The majority of the OCSP code from CertCo.
[openssl.git] / crypto / asn1 / asn1.h
index 50a0cfb16250fc366fcafebf2fc7fe51526fa1c9..3daf4e483a200217d974b98de03503d76a9703dc 100644 (file)
 #define HEADER_ASN1_H
 
 #include <time.h>
+#ifndef NO_BIO
+#include <openssl/bio.h>
+#endif
 #include <openssl/bn.h>
 #include <openssl/stack.h>
 #include <openssl/safestack.h>
 
-#ifdef VMS
-#include <openssl/vms_idhacks.h>
-#endif
+#include <openssl/symhacks.h>
 
 #ifdef  __cplusplus
 extern "C" {
@@ -82,12 +83,15 @@ extern "C" {
 #define V_ASN1_PRIMATIVE_TAG           0x1f
 
 #define V_ASN1_APP_CHOOSE              -2      /* let the recipient choose */
+#define V_ASN1_OTHER                   -3      /* used in ASN1_TYPE */
+
+#define V_ASN1_NEG                     0x100   /* negative flag */
 
 #define V_ASN1_UNDEF                   -1
 #define V_ASN1_EOC                     0
 #define V_ASN1_BOOLEAN                 1       /**/
 #define V_ASN1_INTEGER                 2
-#define V_ASN1_NEG_INTEGER             (2+0x100)
+#define V_ASN1_NEG_INTEGER             (2 | V_ASN1_NEG)
 #define V_ASN1_BIT_STRING              3
 #define V_ASN1_OCTET_STRING            4
 #define V_ASN1_NULL                    5
@@ -96,7 +100,7 @@ extern "C" {
 #define V_ASN1_EXTERNAL                        8
 #define V_ASN1_REAL                    9
 #define V_ASN1_ENUMERATED              10
-#define V_ASN1_NEG_ENUMERATED          (10+0x100)
+#define V_ASN1_NEG_ENUMERATED          (10 | V_ASN1_NEG)
 #define V_ASN1_UTF8STRING              12
 #define V_ASN1_SEQUENCE                        16
 #define V_ASN1_SET                     17
@@ -142,49 +146,8 @@ extern "C" {
 
 struct X509_algor_st;
 
-#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); \
-unsigned char *ASN1_seq_pack_##type(STACK_OF(type) *st, \
-                                   int (*i2d)(type *,unsigned char **), \
-                                   unsigned char **buf,int *len); \
-STACK_OF(type) *ASN1_seq_unpack_##type(unsigned char *buf,int len, \
-                                      type *(*d2i)(type **,unsigned char **, \
-                                                   long), \
-                                      void (*free_func)(type *));
-
-#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); } \
-unsigned char *ASN1_seq_pack_##type(STACK_OF(type) *st, \
-                                   int (*i2d)(type *,unsigned char **), \
-                                   unsigned char **buf,int *len) \
-    { return ASN1_seq_pack((STACK *)st,i2d,buf,len); } \
-STACK_OF(type) *ASN1_seq_unpack_##type(unsigned char *buf,int len, \
-                                      type *(*d2i)(type **,unsigned char **, \
-                                                   long), \
-                                      void (*free_func)(type *)) \
-    { return (STACK_OF(type) *)ASN1_seq_unpack(buf,len,(char *(*)())d2i, \
-                                              (void(*)(void *))free_func); }
+#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
        {
@@ -245,37 +208,6 @@ typedef struct asn1_string_table_st {
 } ASN1_STRING_TABLE;
 
 DECLARE_STACK_OF(ASN1_STRING_TABLE)
-/* This block of defines is updated by a perl script, please do not touch! */
-#ifndef DEBUG_SAFESTACK
-       #define sk_ASN1_STRING_TABLE_new(a) sk_new((int (*) \
-               (const char * const *, const char * const *))(a))
-       #define sk_ASN1_STRING_TABLE_new_null() sk_new_null()
-       #define sk_ASN1_STRING_TABLE_free(a) sk_free(a)
-       #define sk_ASN1_STRING_TABLE_num(a) sk_num(a)
-       #define sk_ASN1_STRING_TABLE_value(a,b) ((ASN1_STRING_TABLE *) \
-               sk_value((a),(b)))
-       #define sk_ASN1_STRING_TABLE_set(a,b,c) ((ASN1_STRING_TABLE *) \
-               sk_set((a),(b),(char *)(c)))
-       #define sk_ASN1_STRING_TABLE_zero(a) sk_zero(a)
-       #define sk_ASN1_STRING_TABLE_push(a,b) sk_push((a),(char *)(b))
-       #define sk_ASN1_STRING_TABLE_unshift(a,b) sk_unshift((a),(b))
-       #define sk_ASN1_STRING_TABLE_find(a,b) sk_find((a), (char *)(b))
-       #define sk_ASN1_STRING_TABLE_delete(a,b) ((ASN1_STRING_TABLE *) \
-               sk_delete((a),(b)))
-       #define sk_ASN1_STRING_TABLE_delete_ptr(a,b) ((ASN1_STRING_TABLE *) \
-               sk_delete_ptr((a),(char *)(b)))
-       #define sk_ASN1_STRING_TABLE_insert(a,b,c) sk_insert((a),(char *)(b),(c))
-       #define sk_ASN1_STRING_TABLE_set_cmp_func(a,b) ((int (*) \
-               (const ASN1_STRING_TABLE * const *,const ASN1_STRING_TABLE * const *)) \
-               sk_set_cmp_func((a),(int (*) \
-               (const char * const *, const char * const *))(b)))
-       #define sk_ASN1_STRING_TABLE_dup(a) sk_dup(a)
-       #define sk_ASN1_STRING_TABLE_pop_free(a,b) sk_pop_free((a),(void (*)(void *))(b))
-       #define sk_ASN1_STRING_TABLE_shift(a) ((ASN1_STRING_TABLE *)sk_shift(a))
-       #define sk_ASN1_STRING_TABLE_pop(a) ((ASN1_STRING_TABLE *)sk_pop(a))
-       #define sk_ASN1_STRING_TABLE_sort(a) sk_sort(a)
-#endif /* !DEBUG_SAFESTACK */
-/* End of perl script block, you may now edit :-) */
 
 /* size limits: this stuff is taken straight from RFC2459 */
 
@@ -304,6 +236,7 @@ DECLARE_STACK_OF(ASN1_STRING_TABLE)
 #define ASN1_BMPSTRING         ASN1_STRING
 #define ASN1_VISIBLESTRING     ASN1_STRING
 #define ASN1_UTF8STRING                ASN1_STRING
+#define ASN1_BOOLEAN           int
 #else
 typedef struct asn1_string_st ASN1_INTEGER;
 typedef struct asn1_string_st ASN1_ENUMERATED;
@@ -320,42 +253,91 @@ typedef struct asn1_string_st ASN1_TIME;
 typedef struct asn1_string_st ASN1_GENERALIZEDTIME;
 typedef struct asn1_string_st ASN1_VISIBLESTRING;
 typedef struct asn1_string_st ASN1_UTF8STRING;
+typedef int ASN1_BOOLEAN;
 #endif
 
 typedef int ASN1_NULL;
 
+/* Parameters used by ASN1_STRING_print_ex() */
+
+/* These determine which characters to escape:
+ * RFC2253 special characters, control characters and
+ * MSB set characters
+ */
+
+#define ASN1_STRFLGS_ESC_2253          1
+#define ASN1_STRFLGS_ESC_CTRL          2
+#define ASN1_STRFLGS_ESC_MSB           4
+
+
+/* This flag determines how we do escaping: normally
+ * RC2253 backslash only, set this to use backslash and
+ * quote.
+ */
+
+#define ASN1_STRFLGS_ESC_QUOTE         8
+
+
+/* These three flags are internal use only. */
+
+/* Character is a valid PrintableString character */
+#define CHARTYPE_PRINTABLESTRING       0x10
+/* Character needs escaping if it is the first character */
+#define CHARTYPE_FIRST_ESC_2253                0x20
+/* Character needs escaping if it is the last character */
+#define CHARTYPE_LAST_ESC_2253         0x40
+
+/* NB the internal flags are safely reused below by flags
+ * handled at the top level.
+ */
+
+/* If this is set we convert all character strings
+ * to UTF8 first 
+ */
+
+#define ASN1_STRFLGS_UTF8_CONVERT      0x10
+
+/* If this is set we don't attempt to interpret content:
+ * just assume all strings are 1 byte per character. This
+ * will produce some pretty odd looking output!
+ */
+
+#define ASN1_STRFLGS_IGNORE_TYPE       0x20
+
+/* If this is set we include the string type in the output */
+#define ASN1_STRFLGS_SHOW_TYPE         0x40
+
+/* This determines which strings to display and which to
+ * 'dump' (hex dump of content octets or DER encoding). We can
+ * only dump non character strings or everything. If we
+ * don't dump 'unknown' they are interpreted as character
+ * strings with 1 octet per character and are subject to
+ * the usual escaping options.
+ */
+
+#define ASN1_STRFLGS_DUMP_ALL          0x80
+#define ASN1_STRFLGS_DUMP_UNKNOWN      0x100
+
+/* These determine what 'dumping' does, we can dump the
+ * content octets or the DER encoding: both use the
+ * RFC2253 #XXXXX notation.
+ */
+
+#define ASN1_STRFLGS_DUMP_DER          0x200
+
+/* All the string flags consistent with RFC2253,
+ * escaping control characters isn't essential in
+ * RFC2253 but it is advisable anyway.
+ */
+
+#define ASN1_STRFLGS_RFC2253   (ASN1_STRFLGS_ESC_2253 | \
+                               ASN1_STRFLGS_ESC_CTRL | \
+                               ASN1_STRFLGS_ESC_MSB | \
+                               ASN1_STRFLGS_UTF8_CONVERT | \
+                               ASN1_STRFLGS_DUMP_UNKNOWN | \
+                               ASN1_STRFLGS_DUMP_DER)
+
 DECLARE_STACK_OF(ASN1_INTEGER)
-/* This block of defines is updated by a perl script, please do not touch! */
-#ifndef DEBUG_SAFESTACK
-       #define sk_ASN1_INTEGER_new(a) sk_new((int (*) \
-               (const char * const *, const char * const *))(a))
-       #define sk_ASN1_INTEGER_new_null() sk_new_null()
-       #define sk_ASN1_INTEGER_free(a) sk_free(a)
-       #define sk_ASN1_INTEGER_num(a) sk_num(a)
-       #define sk_ASN1_INTEGER_value(a,b) ((ASN1_INTEGER *) \
-               sk_value((a),(b)))
-       #define sk_ASN1_INTEGER_set(a,b,c) ((ASN1_INTEGER *) \
-               sk_set((a),(b),(char *)(c)))
-       #define sk_ASN1_INTEGER_zero(a) sk_zero(a)
-       #define sk_ASN1_INTEGER_push(a,b) sk_push((a),(char *)(b))
-       #define sk_ASN1_INTEGER_unshift(a,b) sk_unshift((a),(b))
-       #define sk_ASN1_INTEGER_find(a,b) sk_find((a), (char *)(b))
-       #define sk_ASN1_INTEGER_delete(a,b) ((ASN1_INTEGER *) \
-               sk_delete((a),(b)))
-       #define sk_ASN1_INTEGER_delete_ptr(a,b) ((ASN1_INTEGER *) \
-               sk_delete_ptr((a),(char *)(b)))
-       #define sk_ASN1_INTEGER_insert(a,b,c) sk_insert((a),(char *)(b),(c))
-       #define sk_ASN1_INTEGER_set_cmp_func(a,b) ((int (*) \
-               (const ASN1_INTEGER * const *,const ASN1_INTEGER * const *)) \
-               sk_set_cmp_func((a),(int (*) \
-               (const char * const *, const char * const *))(b)))
-       #define sk_ASN1_INTEGER_dup(a) sk_dup(a)
-       #define sk_ASN1_INTEGER_pop_free(a,b) sk_pop_free((a),(void (*)(void *))(b))
-       #define sk_ASN1_INTEGER_shift(a) ((ASN1_INTEGER *)sk_shift(a))
-       #define sk_ASN1_INTEGER_pop(a) ((ASN1_INTEGER *)sk_pop(a))
-       #define sk_ASN1_INTEGER_sort(a) sk_sort(a)
-#endif /* !DEBUG_SAFESTACK */
-/* End of perl script block, you may now edit :-) */
 DECLARE_ASN1_SET_OF(ASN1_INTEGER)
 
 typedef struct asn1_type_st
@@ -363,6 +345,7 @@ typedef struct asn1_type_st
        int type;
        union   {
                char *ptr;
+               ASN1_BOOLEAN            boolean;
                ASN1_STRING *           asn1_string;
                ASN1_OBJECT *           object;
                ASN1_INTEGER *          integer;
@@ -387,37 +370,6 @@ typedef struct asn1_type_st
        } ASN1_TYPE;
 
 DECLARE_STACK_OF(ASN1_TYPE)
-/* This block of defines is updated by a perl script, please do not touch! */
-#ifndef DEBUG_SAFESTACK
-       #define sk_ASN1_TYPE_new(a) sk_new((int (*) \
-               (const char * const *, const char * const *))(a))
-       #define sk_ASN1_TYPE_new_null() sk_new_null()
-       #define sk_ASN1_TYPE_free(a) sk_free(a)
-       #define sk_ASN1_TYPE_num(a) sk_num(a)
-       #define sk_ASN1_TYPE_value(a,b) ((ASN1_TYPE *) \
-               sk_value((a),(b)))
-       #define sk_ASN1_TYPE_set(a,b,c) ((ASN1_TYPE *) \
-               sk_set((a),(b),(char *)(c)))
-       #define sk_ASN1_TYPE_zero(a) sk_zero(a)
-       #define sk_ASN1_TYPE_push(a,b) sk_push((a),(char *)(b))
-       #define sk_ASN1_TYPE_unshift(a,b) sk_unshift((a),(b))
-       #define sk_ASN1_TYPE_find(a,b) sk_find((a), (char *)(b))
-       #define sk_ASN1_TYPE_delete(a,b) ((ASN1_TYPE *) \
-               sk_delete((a),(b)))
-       #define sk_ASN1_TYPE_delete_ptr(a,b) ((ASN1_TYPE *) \
-               sk_delete_ptr((a),(char *)(b)))
-       #define sk_ASN1_TYPE_insert(a,b,c) sk_insert((a),(char *)(b),(c))
-       #define sk_ASN1_TYPE_set_cmp_func(a,b) ((int (*) \
-               (const ASN1_TYPE * const *,const ASN1_TYPE * const *)) \
-               sk_set_cmp_func((a),(int (*) \
-               (const char * const *, const char * const *))(b)))
-       #define sk_ASN1_TYPE_dup(a) sk_dup(a)
-       #define sk_ASN1_TYPE_pop_free(a,b) sk_pop_free((a),(void (*)(void *))(b))
-       #define sk_ASN1_TYPE_shift(a) ((ASN1_TYPE *)sk_shift(a))
-       #define sk_ASN1_TYPE_pop(a) ((ASN1_TYPE *)sk_pop(a))
-       #define sk_ASN1_TYPE_sort(a) sk_sort(a)
-#endif /* !DEBUG_SAFESTACK */
-/* End of perl script block, you may now edit :-) */
 DECLARE_ASN1_SET_OF(ASN1_TYPE)
 
 typedef struct asn1_method_st
@@ -635,41 +587,12 @@ void ASN1_TYPE_set(ASN1_TYPE *a, int type, void *value);
 ASN1_OBJECT *  ASN1_OBJECT_new(void );
 void           ASN1_OBJECT_free(ASN1_OBJECT *a);
 int            i2d_ASN1_OBJECT(ASN1_OBJECT *a,unsigned char **pp);
+ASN1_OBJECT *  c2i_ASN1_OBJECT(ASN1_OBJECT **a,unsigned char **pp,
+                       long length);
 ASN1_OBJECT *  d2i_ASN1_OBJECT(ASN1_OBJECT **a,unsigned char **pp,
                        long length);
 
 DECLARE_STACK_OF(ASN1_OBJECT)
-/* This block of defines is updated by a perl script, please do not touch! */
-#ifndef DEBUG_SAFESTACK
-       #define sk_ASN1_OBJECT_new(a) sk_new((int (*) \
-               (const char * const *, const char * const *))(a))
-       #define sk_ASN1_OBJECT_new_null() sk_new_null()
-       #define sk_ASN1_OBJECT_free(a) sk_free(a)
-       #define sk_ASN1_OBJECT_num(a) sk_num(a)
-       #define sk_ASN1_OBJECT_value(a,b) ((ASN1_OBJECT *) \
-               sk_value((a),(b)))
-       #define sk_ASN1_OBJECT_set(a,b,c) ((ASN1_OBJECT *) \
-               sk_set((a),(b),(char *)(c)))
-       #define sk_ASN1_OBJECT_zero(a) sk_zero(a)
-       #define sk_ASN1_OBJECT_push(a,b) sk_push((a),(char *)(b))
-       #define sk_ASN1_OBJECT_unshift(a,b) sk_unshift((a),(b))
-       #define sk_ASN1_OBJECT_find(a,b) sk_find((a), (char *)(b))
-       #define sk_ASN1_OBJECT_delete(a,b) ((ASN1_OBJECT *) \
-               sk_delete((a),(b)))
-       #define sk_ASN1_OBJECT_delete_ptr(a,b) ((ASN1_OBJECT *) \
-               sk_delete_ptr((a),(char *)(b)))
-       #define sk_ASN1_OBJECT_insert(a,b,c) sk_insert((a),(char *)(b),(c))
-       #define sk_ASN1_OBJECT_set_cmp_func(a,b) ((int (*) \
-               (const ASN1_OBJECT * const *,const ASN1_OBJECT * const *)) \
-               sk_set_cmp_func((a),(int (*) \
-               (const char * const *, const char * const *))(b)))
-       #define sk_ASN1_OBJECT_dup(a) sk_dup(a)
-       #define sk_ASN1_OBJECT_pop_free(a,b) sk_pop_free((a),(void (*)(void *))(b))
-       #define sk_ASN1_OBJECT_shift(a) ((ASN1_OBJECT *)sk_shift(a))
-       #define sk_ASN1_OBJECT_pop(a) ((ASN1_OBJECT *)sk_pop(a))
-       #define sk_ASN1_OBJECT_sort(a) sk_sort(a)
-#endif /* !DEBUG_SAFESTACK */
-/* End of perl script block, you may now edit :-) */
 DECLARE_ASN1_SET_OF(ASN1_OBJECT)
 
 ASN1_STRING *  ASN1_STRING_new(void);
@@ -688,14 +611,17 @@ unsigned char * ASN1_STRING_data(ASN1_STRING *x);
 ASN1_BIT_STRING *      ASN1_BIT_STRING_new(void);
 void           ASN1_BIT_STRING_free(ASN1_BIT_STRING *a);
 int            i2d_ASN1_BIT_STRING(ASN1_BIT_STRING *a,unsigned char **pp);
+int            i2c_ASN1_BIT_STRING(ASN1_BIT_STRING *a,unsigned char **pp);
 ASN1_BIT_STRING *d2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a,unsigned char **pp,
                        long length);
+ASN1_BIT_STRING *c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a,unsigned char **pp,
+                       long length);
 int            ASN1_BIT_STRING_set(ASN1_BIT_STRING *a, unsigned char *d,
                        int length );
 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
@@ -709,8 +635,11 @@ int                d2i_ASN1_BOOLEAN(int *a,unsigned char **pp,long length);
 ASN1_INTEGER * ASN1_INTEGER_new(void);
 void           ASN1_INTEGER_free(ASN1_INTEGER *a);
 int            i2d_ASN1_INTEGER(ASN1_INTEGER *a,unsigned char **pp);
+int            i2c_ASN1_INTEGER(ASN1_INTEGER *a,unsigned char **pp);
 ASN1_INTEGER *d2i_ASN1_INTEGER(ASN1_INTEGER **a,unsigned char **pp,
                        long length);
+ASN1_INTEGER *c2i_ASN1_INTEGER(ASN1_INTEGER **a,unsigned char **pp,
+                       long length);
 ASN1_INTEGER *d2i_ASN1_UINTEGER(ASN1_INTEGER **a,unsigned char **pp,
                        long length);
 ASN1_INTEGER * ASN1_INTEGER_dup(ASN1_INTEGER *x);
@@ -725,7 +654,10 @@ 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); 
+int ASN1_UTCTIME_cmp_time_t(const ASN1_UTCTIME *s, time_t t);
+#if 0
 time_t ASN1_UTCTIME_get(const ASN1_UTCTIME *s);
+#endif
 
 int ASN1_GENERALIZEDTIME_check(ASN1_GENERALIZEDTIME *a);
 ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_set(ASN1_GENERALIZEDTIME *s,time_t t);
@@ -820,10 +752,10 @@ ASN1_TIME *ASN1_TIME_set(ASN1_TIME *s,time_t t);
 int            i2d_ASN1_SET(STACK *a, unsigned char **pp,
                        int (*func)(), int ex_tag, int ex_class, int is_set);
 STACK *                d2i_ASN1_SET(STACK **a, unsigned char **pp, long length,
-                       char *(*func)(), void (*free_func)(),
+                       char *(*func)(), void (*free_func)(void *),
                        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);
@@ -876,16 +808,21 @@ char *ASN1_dup(int (*i2d)(),char *(*d2i)(),char *x);
 #ifndef NO_FP_API
 char *ASN1_d2i_fp(char *(*xnew)(),char *(*d2i)(),FILE *fp,unsigned char **x);
 int ASN1_i2d_fp(int (*i2d)(),FILE *out,unsigned char *x);
+int ASN1_STRING_print_ex_fp(FILE *fp, ASN1_STRING *str, unsigned long flags);
 #endif
 
-#ifdef HEADER_BIO_H
+int ASN1_STRING_to_UTF8(unsigned char **out, ASN1_STRING *in);
+
+#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);
 int ASN1_GENERALIZEDTIME_print(BIO *fp,ASN1_GENERALIZEDTIME *a);
 int ASN1_TIME_print(BIO *fp,ASN1_TIME *a);
 int ASN1_STRING_print(BIO *bp,ASN1_STRING *v);
+int ASN1_STRING_print_ex(BIO *out, ASN1_STRING *str, unsigned long flags);
 int ASN1_parse(BIO *bp,unsigned char *pp,long len,int indent);
+int ASN1_parse_dump(BIO *bp,unsigned char *pp,long len,int indent,int dump);
 #endif
 const char *ASN1_tag2str(int tag);
 
@@ -915,7 +852,7 @@ int ASN1_TYPE_get_int_octetstring(ASN1_TYPE *a,long *num,
        unsigned char *data, int max_len);
 
 STACK *ASN1_seq_unpack(unsigned char *buf, int len, char *(*d2i)(),
-                                                void (*free_func)() ); 
+                                                void (*free_func)(void *) ); 
 unsigned char *ASN1_seq_pack(STACK *safes, int (*i2d)(), unsigned char **buf,
                             int *len );
 void *ASN1_unpack_string(ASN1_STRING *oct, char *(*d2i)());
@@ -1019,6 +956,21 @@ void ASN1_STRING_TABLE_cleanup(void);
 #define ASN1_F_D2I_NETSCAPE_SPKAC                       143
 #define ASN1_F_D2I_NETSCAPE_SPKI                        144
 #define ASN1_F_D2I_NOTICEREF                            268
+#define ASN1_F_D2I_OCSP_BASICRESP                       293
+#define ASN1_F_D2I_OCSP_CERTID                          294
+#define ASN1_F_D2I_OCSP_CERTSTATUS                      295
+#define ASN1_F_D2I_OCSP_CRLID                           296
+#define ASN1_F_D2I_OCSP_ONEREQ                          297
+#define ASN1_F_D2I_OCSP_REQINFO                                 298
+#define ASN1_F_D2I_OCSP_REQUEST                                 299
+#define ASN1_F_D2I_OCSP_RESPBYTES                       300
+#define ASN1_F_D2I_OCSP_RESPDATA                        301
+#define ASN1_F_D2I_OCSP_RESPID                          302
+#define ASN1_F_D2I_OCSP_RESPONSE                        303
+#define ASN1_F_D2I_OCSP_REVOKEDINFO                     304
+#define ASN1_F_D2I_OCSP_SERVICELOC                      305
+#define ASN1_F_D2I_OCSP_SIGNATURE                       306
+#define ASN1_F_D2I_OCSP_SINGLERESP                      307
 #define ASN1_F_D2I_OTHERNAME                            287
 #define ASN1_F_D2I_PBE2PARAM                            262
 #define ASN1_F_D2I_PBEPARAM                             249
@@ -1090,6 +1042,21 @@ void ASN1_STRING_TABLE_cleanup(void);
 #define ASN1_F_NETSCAPE_SPKAC_NEW                       190
 #define ASN1_F_NETSCAPE_SPKI_NEW                        191
 #define ASN1_F_NOTICEREF_NEW                            272
+#define ASN1_F_OCSP_BASICRESP_NEW                       308
+#define ASN1_F_OCSP_CERTID_NEW                          309
+#define ASN1_F_OCSP_CERTSTATUS_NEW                      310
+#define ASN1_F_OCSP_CRLID_NEW                           311
+#define ASN1_F_OCSP_ONEREQ_NEW                          312
+#define ASN1_F_OCSP_REQINFO_NEW                                 313
+#define ASN1_F_OCSP_REQUEST_NEW                                 314
+#define ASN1_F_OCSP_RESPBYTES_NEW                       315
+#define ASN1_F_OCSP_RESPDATA_NEW                        316
+#define ASN1_F_OCSP_RESPID_NEW                          317
+#define ASN1_F_OCSP_RESPONSE_NEW                        318
+#define ASN1_F_OCSP_REVOKEDINFO_NEW                     319
+#define ASN1_F_OCSP_SERVICELOC_NEW                      320
+#define ASN1_F_OCSP_SIGNATURE_NEW                       321
+#define ASN1_F_OCSP_SINGLERESP_NEW                      322
 #define ASN1_F_OTHERNAME_NEW                            288
 #define ASN1_F_PBE2PARAM_NEW                            264
 #define ASN1_F_PBEPARAM_NEW                             251