Preliminary streaming ASN1 encode support.
[openssl.git] / crypto / asn1 / asn1.h
index bd033f85ecb67743a14363aed157eb7d8cd5d7bc..e870948e8df0a1cce0b41bcf88363f4a797c9469 100644 (file)
@@ -71,6 +71,7 @@
 #include <openssl/symhacks.h>
 
 #include <openssl/e_os2.h>
+#include <openssl/ossl_typ.h>
 
 #ifdef OPENSSL_BUILD_SHLIBCRYPTO
 # undef OPENSSL_EXTERN
@@ -191,6 +192,11 @@ typedef struct asn1_object_st
        } ASN1_OBJECT;
 
 #define ASN1_STRING_FLAG_BITS_LEFT 0x08 /* Set if 0x07 has bits left value */
+/* This indicates that the ASN1_STRING is not a real value but just a place
+ * holder for the location where indefinite length constructed data should
+ * be inserted in the memory buffer 
+ */
+#define ASN1_STRING_FLAG_NDEF 0x010 
 /* This is the base type that holds just about everything :-) */
 typedef struct asn1_string_st
        {
@@ -246,44 +252,6 @@ DECLARE_STACK_OF(ASN1_STRING_TABLE)
 #define ub_title                       64
 #define ub_email_address               128
 
-#ifdef NO_ASN1_TYPEDEFS
-#define ASN1_INTEGER           ASN1_STRING
-#define ASN1_ENUMERATED                ASN1_STRING
-#define ASN1_BIT_STRING                ASN1_STRING
-#define ASN1_OCTET_STRING      ASN1_STRING
-#define ASN1_PRINTABLESTRING   ASN1_STRING
-#define ASN1_T61STRING         ASN1_STRING
-#define ASN1_IA5STRING         ASN1_STRING
-#define ASN1_UTCTIME           ASN1_STRING
-#define ASN1_GENERALIZEDTIME   ASN1_STRING
-#define ASN1_TIME              ASN1_STRING
-#define ASN1_GENERALSTRING     ASN1_STRING
-#define ASN1_UNIVERSALSTRING   ASN1_STRING
-#define ASN1_BMPSTRING         ASN1_STRING
-#define ASN1_VISIBLESTRING     ASN1_STRING
-#define ASN1_UTF8STRING                ASN1_STRING
-#define ASN1_BOOLEAN           int
-#define ASN1_NULL              int
-#else
-typedef struct asn1_string_st ASN1_INTEGER;
-typedef struct asn1_string_st ASN1_ENUMERATED;
-typedef struct asn1_string_st ASN1_BIT_STRING;
-typedef struct asn1_string_st ASN1_OCTET_STRING;
-typedef struct asn1_string_st ASN1_PRINTABLESTRING;
-typedef struct asn1_string_st ASN1_T61STRING;
-typedef struct asn1_string_st ASN1_IA5STRING;
-typedef struct asn1_string_st ASN1_GENERALSTRING;
-typedef struct asn1_string_st ASN1_UNIVERSALSTRING;
-typedef struct asn1_string_st ASN1_BMPSTRING;
-typedef struct asn1_string_st ASN1_UTCTIME;
-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;
-typedef int ASN1_NULL;
-#endif
-
 /* Declarations for template structures: for full definitions
  * see asn1t.h
  */
@@ -317,6 +285,9 @@ typedef struct ASN1_VALUE_st ASN1_VALUE;
        int i2d_##name(const type *a, unsigned char **out); \
        DECLARE_ASN1_ITEM(name)
 
+#define        DECLARE_ASN1_NDEF_FUNCTION(name) \
+       int i2d_##name##_NDEF(name *a, unsigned char **out);
+
 #define DECLARE_ASN1_FUNCTIONS_const(name) \
        name *name##_new(void); \
        void name##_free(name *a);
@@ -477,6 +448,8 @@ typedef const ASN1_ITEM * ASN1_ITEM_EXP(void);
 DECLARE_STACK_OF(ASN1_INTEGER)
 DECLARE_ASN1_SET_OF(ASN1_INTEGER)
 
+DECLARE_STACK_OF(ASN1_GENERALSTRING)
+
 typedef struct asn1_type_st
        {
        int type;
@@ -808,6 +781,7 @@ int         ASN1_OCTET_STRING_cmp(ASN1_OCTET_STRING *a, ASN1_OCTET_STRING *b);
 int    ASN1_OCTET_STRING_set(ASN1_OCTET_STRING *str, unsigned char *data, int len);
 
 DECLARE_ASN1_FUNCTIONS(ASN1_VISIBLESTRING)
+DECLARE_ASN1_FUNCTIONS(ASN1_UNIVERSALSTRING)
 DECLARE_ASN1_FUNCTIONS(ASN1_UTF8STRING)
 DECLARE_ASN1_FUNCTIONS(ASN1_NULL)
 DECLARE_ASN1_FUNCTIONS(ASN1_BMPSTRING)
@@ -827,6 +801,8 @@ DECLARE_ASN1_FUNCTIONS(ASN1_UTCTIME)
 DECLARE_ASN1_FUNCTIONS(ASN1_GENERALIZEDTIME)
 DECLARE_ASN1_FUNCTIONS(ASN1_TIME)
 
+DECLARE_ASN1_ITEM(ASN1_OCTET_STRING_NDEF)
+
 ASN1_TIME *ASN1_TIME_set(ASN1_TIME *s,time_t t);
 int ASN1_TIME_check(ASN1_TIME *t);
 ASN1_GENERALIZEDTIME *ASN1_TIME_to_generalizedtime(ASN1_TIME *t, ASN1_GENERALIZEDTIME **out);
@@ -883,6 +859,7 @@ int ASN1_get_object(unsigned char **pp, long *plength, int *ptag,
 int ASN1_check_infinite_end(unsigned char **p,long len);
 void ASN1_put_object(unsigned char **pp, int constructed, int length,
        int tag, int xclass);
+int ASN1_put_eoc(unsigned char **pp);
 int ASN1_object_size(int constructed, int length, int tag);
 
 /* Used to implement other functions */
@@ -923,8 +900,6 @@ void ASN1_HEADER_free(ASN1_HEADER *a);
 
 int ASN1_UNIVERSALSTRING_to_string(ASN1_UNIVERSALSTRING *s);
 
-void ERR_load_ASN1_strings(void);
-
 /* Not used that much at this point, except for the first two */
 ASN1_METHOD *X509_asn1_meth(void);
 ASN1_METHOD *RSAPrivateKey_asn1_meth(void);
@@ -971,12 +946,15 @@ ASN1_VALUE *ASN1_item_new(const ASN1_ITEM *it);
 void ASN1_item_free(ASN1_VALUE *val, const ASN1_ITEM *it);
 ASN1_VALUE * ASN1_item_d2i(ASN1_VALUE **val, unsigned char **in, long len, const ASN1_ITEM *it);
 int ASN1_item_i2d(ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it);
+int ASN1_item_ndef_i2d(ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it);
 
+void ASN1_add_oid_module(void);
 
 /* BEGIN ERROR CODES */
 /* The following lines are auto generated by the script mkerr.pl. Any changes
  * made after this point may be overwritten when the script is next run.
  */
+void ERR_load_ASN1_strings(void);
 
 /* Error codes for the ASN1 functions. */
 
@@ -1043,11 +1021,14 @@ int ASN1_item_i2d(ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it);
 #define ASN1_F_D2I_X509_PKEY                            159
 #define ASN1_F_I2D_ASN1_TIME                            160
 #define ASN1_F_I2D_DSA_PUBKEY                           161
+#define ASN1_F_I2D_ECDSA_PUBKEY                                 174
+#define ASN1_F_I2D_EC_PUBKEY                            176
 #define ASN1_F_I2D_NETSCAPE_RSA                                 162
 #define ASN1_F_I2D_PRIVATEKEY                           163
 #define ASN1_F_I2D_PUBLICKEY                            164
 #define ASN1_F_I2D_RSA_PUBKEY                           165
 #define ASN1_F_LONG_C2I                                         166
+#define ASN1_F_OID_MODULE_INIT                          175
 #define ASN1_F_PKCS5_PBE2_SET                           167
 #define ASN1_F_X509_CINF_NEW                            168
 #define ASN1_F_X509_CRL_ADD0_REVOKED                    169
@@ -1057,6 +1038,7 @@ int ASN1_item_i2d(ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it);
 #define ASN1_F_X509_PKEY_NEW                            173
 
 /* Reason codes. */
+#define ASN1_R_ADDING_OBJECT                            171
 #define ASN1_R_AUX_ERROR                                100
 #define ASN1_R_BAD_CLASS                                101
 #define ASN1_R_BAD_OBJECT_HEADER                        102
@@ -1070,6 +1052,7 @@ int ASN1_item_i2d(ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it);
 #define ASN1_R_DECODE_ERROR                             110
 #define ASN1_R_DECODING_ERROR                           111
 #define ASN1_R_ENCODE_ERROR                             112
+#define ASN1_R_ERROR_LOADING_SECTION                    172
 #define ASN1_R_ERROR_PARSING_SET_ELEMENT                113
 #define ASN1_R_ERROR_SETTING_CIPHER_PARAMS              114
 #define ASN1_R_EXPECTING_AN_INTEGER                     115
@@ -1133,4 +1116,3 @@ int ASN1_item_i2d(ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it);
 }
 #endif
 #endif
-