Allow UTCTIME objects to be retrieved. Check for imminent cert expiry.
[openssl.git] / crypto / asn1 / asn1.h
index bf481042bc33d272c6e9701c5b8764dc78d1e523..f340ed41df346800038a9e5115f6c32954a6da49 100644 (file)
 #ifndef HEADER_ASN1_H
 #define HEADER_ASN1_H
 
-#ifdef  __cplusplus
-extern "C" {
-#endif
-
 #include <time.h>
 #include <openssl/bn.h>
 #include <openssl/stack.h>
@@ -72,6 +68,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 +81,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
@@ -176,7 +176,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 */
@@ -212,6 +212,10 @@ typedef struct asn1_string_st
        } ASN1_STRING;
 
 #define STABLE_FLAGS_MALLOC    0x01
+#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;
@@ -234,7 +238,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
@@ -268,6 +272,8 @@ typedef struct asn1_string_st ASN1_VISIBLESTRING;
 typedef struct asn1_string_st ASN1_UTF8STRING;
 #endif
 
+typedef int ASN1_NULL;
+
 typedef struct asn1_type_st
        {
        int type;
@@ -573,6 +579,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);
@@ -599,6 +606,11 @@ int                i2d_ASN1_UTF8STRING(ASN1_UTF8STRING *a,unsigned char **pp);
 ASN1_UTF8STRING *d2i_ASN1_UTF8STRING(ASN1_UTF8STRING **a,
                        unsigned char **pp,long length);
 
+ASN1_NULL *    ASN1_NULL_new(void);
+void           ASN1_NULL_free(ASN1_NULL *a);
+int            i2d_ASN1_NULL(ASN1_NULL *a,unsigned char **pp);
+ASN1_NULL *d2i_ASN1_NULL(ASN1_NULL **a, unsigned char **pp,long length);
+
 ASN1_BMPSTRING *       ASN1_BMPSTRING_new(void);
 void           ASN1_BMPSTRING_free(ASN1_BMPSTRING *a);
 int i2d_ASN1_BMPSTRING(ASN1_BMPSTRING *a, unsigned char **pp);
@@ -617,6 +629,7 @@ ASN1_PRINTABLESTRING *      ASN1_PRINTABLESTRING_new(void);
 void           ASN1_PRINTABLESTRING_free(ASN1_PRINTABLESTRING *a);
 ASN1_PRINTABLESTRING *d2i_ASN1_PRINTABLESTRING(ASN1_PRINTABLESTRING **a,
        unsigned char **pp, long l);
+int i2d_ASN1_PRINTABLESTRING(ASN1_PRINTABLESTRING *a, unsigned char **pp);
 
 ASN1_STRING *  DIRECTORYSTRING_new(void);
 void           DIRECTORYSTRING_free(ASN1_STRING *a);
@@ -773,8 +786,8 @@ 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);
-int ASN1_STRING_TABLE_add_standard(void);
 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 */
@@ -789,6 +802,7 @@ void ASN1_STRING_TABLE_cleanup(void);
 #define ASN1_F_A2I_ASN1_ENUMERATED                      236
 #define ASN1_F_A2I_ASN1_INTEGER                                 101
 #define ASN1_F_A2I_ASN1_STRING                          102
+#define ASN1_F_ACCESS_DESCRIPTION_NEW                   291
 #define ASN1_F_ASN1_COLLATE_PRIMITIVE                   103
 #define ASN1_F_ASN1_D2I_BIO                             104
 #define ASN1_F_ASN1_D2I_FP                              105
@@ -811,7 +825,6 @@ void ASN1_STRING_TABLE_cleanup(void);
 #define ASN1_F_ASN1_SIGN                                114
 #define ASN1_F_ASN1_STRING_NEW                          115
 #define ASN1_F_ASN1_STRING_TABLE_ADD                    283
-#define ASN1_F_ASN1_STRING_TABLE_ADD_STANDARD           284
 #define ASN1_F_ASN1_STRING_TYPE_NEW                     116
 #define ASN1_F_ASN1_TYPE_GET_INT_OCTETSTRING            117
 #define ASN1_F_ASN1_TYPE_GET_OCTETSTRING                118
@@ -823,6 +836,7 @@ void ASN1_STRING_TABLE_cleanup(void);
 #define ASN1_F_BASIC_CONSTRAINTS_NEW                    226
 #define ASN1_F_BN_TO_ASN1_ENUMERATED                    234
 #define ASN1_F_BN_TO_ASN1_INTEGER                       122
+#define ASN1_F_D2I_ACCESS_DESCRIPTION                   284
 #define ASN1_F_D2I_ASN1_BIT_STRING                      123
 #define ASN1_F_D2I_ASN1_BMPSTRING                       124
 #define ASN1_F_D2I_ASN1_BOOLEAN                                 125
@@ -831,6 +845,7 @@ void ASN1_STRING_TABLE_cleanup(void);
 #define ASN1_F_D2I_ASN1_GENERALIZEDTIME                         223
 #define ASN1_F_D2I_ASN1_HEADER                          127
 #define ASN1_F_D2I_ASN1_INTEGER                                 128
+#define ASN1_F_D2I_ASN1_NULL                            292
 #define ASN1_F_D2I_ASN1_OBJECT                          129
 #define ASN1_F_D2I_ASN1_OCTET_STRING                    130
 #define ASN1_F_D2I_ASN1_PRINT_TYPE                      131
@@ -914,12 +929,14 @@ void ASN1_STRING_TABLE_cleanup(void);
 #define ASN1_F_I2D_DSAPARAMS                            178
 #define ASN1_F_I2D_DSAPRIVATEKEY                        179
 #define ASN1_F_I2D_DSAPUBLICKEY                                 180
+#define ASN1_F_I2D_DSA_PUBKEY                           290
 #define ASN1_F_I2D_NETSCAPE_RSA                                 181
 #define ASN1_F_I2D_PKCS7                                182
 #define ASN1_F_I2D_PRIVATEKEY                           183
 #define ASN1_F_I2D_PUBLICKEY                            184
 #define ASN1_F_I2D_RSAPRIVATEKEY                        185
 #define ASN1_F_I2D_RSAPUBLICKEY                                 186
+#define ASN1_F_I2D_RSA_PUBKEY                           289
 #define ASN1_F_I2D_X509_ATTRIBUTE                       187
 #define ASN1_F_I2T_ASN1_OBJECT                          188
 #define ASN1_F_NETSCAPE_CERT_SEQUENCE_NEW               229
@@ -986,6 +1003,7 @@ void ASN1_STRING_TABLE_cleanup(void);
 #define ASN1_R_BN_LIB                                   107
 #define ASN1_R_BOOLEAN_IS_WRONG_LENGTH                  108
 #define ASN1_R_BUFFER_TOO_SMALL                                 109
+#define ASN1_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER          166
 #define ASN1_R_DATA_IS_WRONG                            110
 #define ASN1_R_DECODE_ERROR                             155
 #define ASN1_R_DECODING_ERROR                           111
@@ -999,6 +1017,7 @@ void ASN1_STRING_TABLE_cleanup(void);
 #define ASN1_R_EXPECTING_A_BIT_STRING                   116
 #define ASN1_R_EXPECTING_A_BOOLEAN                      117
 #define ASN1_R_EXPECTING_A_GENERALIZEDTIME              151
+#define ASN1_R_EXPECTING_A_NULL                                 164
 #define ASN1_R_EXPECTING_A_TIME                                 152
 #define ASN1_R_EXPECTING_A_UTCTIME                      118
 #define ASN1_R_FIRST_NUM_TOO_LARGE                      119
@@ -1016,6 +1035,7 @@ void ASN1_STRING_TABLE_cleanup(void);
 #define ASN1_R_MISSING_SECOND_NUMBER                    126
 #define ASN1_R_NON_HEX_CHARACTERS                       127
 #define ASN1_R_NOT_ENOUGH_DATA                          128
+#define ASN1_R_NULL_IS_WRONG_LENGTH                     165
 #define ASN1_R_ODD_NUMBER_OF_CHARS                      129
 #define ASN1_R_PARSING                                  130
 #define ASN1_R_PRIVATE_KEY_HEADER_MISSING               131