New ASN1 functions that just deal with
[openssl.git] / crypto / asn1 / asn1.h
index 8cf317640e0d5ab5566f1cb8ce25ad2093431a2f..fcce0f6925622e760f10e4f194b807df367736d4 100644 (file)
@@ -60,6 +60,9 @@
 #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>
@@ -83,11 +86,13 @@ extern "C" {
 
 #define V_ASN1_APP_CHOOSE              -2      /* let the recipient choose */
 
+#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 +101,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
@@ -140,32 +145,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
        {
@@ -274,6 +257,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;
@@ -542,14 +528,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
@@ -563,8 +552,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);
@@ -579,6 +571,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);
@@ -673,10 +666,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);
@@ -731,7 +724,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);
@@ -768,9 +761,9 @@ 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 );
+                            int *len );
 void *ASN1_unpack_string(ASN1_STRING *oct, char *(*d2i)());
 ASN1_STRING *ASN1_pack_string(void *obj, int (*i2d)(), ASN1_OCTET_STRING **oct);