00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 
00030 
00031 
00032 
00033 
00034 
00035 
00036 
00037 
00038 
00039 
00040 
00041 
00042 
00043 
00044 
00045 
00046 
00047 
00048 
00049 
00050 
00051 
00052 
00053 
00054 
00055 
00056 
00057 
00058 
00059 #ifndef HEADER_ASN1_H
00060 #define HEADER_ASN1_H
00061 
00062 #include <time.h>
00063 #include <openssl/e_os2.h>
00064 #ifndef OPENSSL_NO_BIO
00065 #include <openssl/bio.h>
00066 #endif
00067 #include <openssl/stack.h>
00068 #include <openssl/safestack.h>
00069 
00070 #include <openssl/symhacks.h>
00071 
00072 #include <openssl/ossl_typ.h>
00073 #ifndef OPENSSL_NO_DEPRECATED
00074 #include <openssl/bn.h>
00075 #endif
00076 
00077 #ifdef OPENSSL_BUILD_SHLIBCRYPTO
00078 # undef OPENSSL_EXTERN
00079 # define OPENSSL_EXTERN OPENSSL_EXPORT
00080 #endif
00081 
00082 #ifdef  __cplusplus
00083 extern "C" {
00084 #endif
00085 
00086 #define V_ASN1_UNIVERSAL      0x00
00087 #define  V_ASN1_APPLICATION      0x40
00088 #define V_ASN1_CONTEXT_SPECIFIC     0x80
00089 #define V_ASN1_PRIVATE        0xc0
00090 
00091 #define V_ASN1_CONSTRUCTED    0x20
00092 #define V_ASN1_PRIMITIVE_TAG     0x1f
00093 #define V_ASN1_PRIMATIVE_TAG     0x1f
00094 
00095 #define V_ASN1_APP_CHOOSE     -2 
00096 #define V_ASN1_OTHER       -3 
00097 #define V_ASN1_ANY         -4 
00098 
00099 #define V_ASN1_NEG         0x100 
00100 
00101 #define V_ASN1_UNDEF       -1
00102 #define V_ASN1_EOC         0
00103 #define V_ASN1_BOOLEAN        1  
00104 #define V_ASN1_INTEGER        2
00105 #define V_ASN1_NEG_INTEGER    (2 | V_ASN1_NEG)
00106 #define V_ASN1_BIT_STRING     3
00107 #define V_ASN1_OCTET_STRING      4
00108 #define V_ASN1_NULL        5
00109 #define V_ASN1_OBJECT         6
00110 #define V_ASN1_OBJECT_DESCRIPTOR 7
00111 #define V_ASN1_EXTERNAL       8
00112 #define V_ASN1_REAL        9
00113 #define V_ASN1_ENUMERATED     10
00114 #define V_ASN1_NEG_ENUMERATED    (10 | V_ASN1_NEG)
00115 #define V_ASN1_UTF8STRING     12
00116 #define V_ASN1_SEQUENCE       16
00117 #define V_ASN1_SET         17
00118 #define V_ASN1_NUMERICSTRING     18 
00119 #define V_ASN1_PRINTABLESTRING      19
00120 #define V_ASN1_T61STRING      20
00121 #define V_ASN1_TELETEXSTRING     20 
00122 #define V_ASN1_VIDEOTEXSTRING    21 
00123 #define V_ASN1_IA5STRING      22
00124 #define V_ASN1_UTCTIME        23
00125 #define V_ASN1_GENERALIZEDTIME      24 
00126 #define V_ASN1_GRAPHICSTRING     25 
00127 #define V_ASN1_ISO64STRING    26 
00128 #define V_ASN1_VISIBLESTRING     26 
00129 #define V_ASN1_GENERALSTRING     27 
00130 #define V_ASN1_UNIVERSALSTRING      28 
00131 #define V_ASN1_BMPSTRING      30
00132 
00133 
00134 #define B_ASN1_NUMERICSTRING  0x0001
00135 #define B_ASN1_PRINTABLESTRING   0x0002
00136 #define B_ASN1_T61STRING   0x0004
00137 #define B_ASN1_TELETEXSTRING  0x0004
00138 #define B_ASN1_VIDEOTEXSTRING 0x0008
00139 #define B_ASN1_IA5STRING   0x0010
00140 #define B_ASN1_GRAPHICSTRING  0x0020
00141 #define B_ASN1_ISO64STRING 0x0040
00142 #define B_ASN1_VISIBLESTRING  0x0040
00143 #define B_ASN1_GENERALSTRING  0x0080
00144 #define B_ASN1_UNIVERSALSTRING   0x0100
00145 #define B_ASN1_OCTET_STRING   0x0200
00146 #define B_ASN1_BIT_STRING  0x0400
00147 #define B_ASN1_BMPSTRING   0x0800
00148 #define B_ASN1_UNKNOWN     0x1000
00149 #define B_ASN1_UTF8STRING  0x2000
00150 #define B_ASN1_UTCTIME     0x4000
00151 #define B_ASN1_GENERALIZEDTIME   0x8000
00152 #define B_ASN1_SEQUENCE    0x10000
00153 
00154 
00155 #define MBSTRING_FLAG      0x1000
00156 #define MBSTRING_UTF8      (MBSTRING_FLAG)
00157 #define MBSTRING_ASC    (MBSTRING_FLAG|1)
00158 #define MBSTRING_BMP    (MBSTRING_FLAG|2)
00159 #define MBSTRING_UNIV      (MBSTRING_FLAG|4)
00160 
00161 struct X509_algor_st;
00162 
00163 #define DECLARE_ASN1_SET_OF(type) 
00164 #define IMPLEMENT_ASN1_SET_OF(type) 
00165 
00166 
00167 
00168 
00169 
00170 typedef struct asn1_ctx_st
00171    {
00172    unsigned char *p;
00173    int eos; 
00174    int error;  
00175    int inf; 
00176    int tag; 
00177    int xclass; 
00178    long slen;  
00179    unsigned char *max; 
00180    unsigned char *q;
00181    unsigned char **pp;
00182    int line;   
00183    } ASN1_CTX;
00184 
00185 typedef struct asn1_const_ctx_st
00186    {
00187    const unsigned char *p;
00188    int eos; 
00189    int error;  
00190    int inf; 
00191    int tag; 
00192    int xclass; 
00193    long slen;  
00194    const unsigned char *max; 
00195    const unsigned char *q;
00196    const unsigned char **pp;
00197    int line;   
00198    } ASN1_const_CTX;
00199 
00200 
00201 
00202 #define ASN1_OBJECT_FLAG_DYNAMIC  0x01 
00203 #define ASN1_OBJECT_FLAG_CRITICAL    0x02 
00204 #define ASN1_OBJECT_FLAG_DYNAMIC_STRINGS 0x04   
00205 #define ASN1_OBJECT_FLAG_DYNAMIC_DATA   0x08 
00206 typedef struct asn1_object_st
00207    {
00208    const char *sn,*ln;
00209    int nid;
00210    int length;
00211    unsigned char *data;
00212    int flags;  
00213    } ASN1_OBJECT;
00214 
00215 #define ASN1_STRING_FLAG_BITS_LEFT 0x08 
00216 
00217 
00218 
00219 
00220 #define ASN1_STRING_FLAG_NDEF 0x010
00221 
00222 typedef struct asn1_string_st
00223    {
00224    int length;
00225    int type;
00226    unsigned char *data;
00227    
00228 
00229 
00230 
00231    long flags;
00232    } ASN1_STRING;
00233 
00234 
00235 
00236 
00237 
00238 
00239 typedef struct ASN1_ENCODING_st
00240    {
00241    unsigned char *enc;  
00242    long len;      
00243    int modified;      
00244    } ASN1_ENCODING;
00245 
00246 
00247 #define ASN1_LONG_UNDEF 0x7fffffffL
00248 
00249 #define STABLE_FLAGS_MALLOC   0x01
00250 #define STABLE_NO_MASK     0x02
00251 #define DIRSTRING_TYPE  \
00252  (B_ASN1_PRINTABLESTRING|B_ASN1_T61STRING|B_ASN1_BMPSTRING|B_ASN1_UTF8STRING)
00253 #define PKCS9STRING_TYPE (DIRSTRING_TYPE|B_ASN1_IA5STRING)
00254 
00255 typedef struct asn1_string_table_st {
00256    int nid;
00257    long minsize;
00258    long maxsize;
00259    unsigned long mask;
00260    unsigned long flags;
00261 } ASN1_STRING_TABLE;
00262 
00263 DECLARE_STACK_OF(ASN1_STRING_TABLE)
00264 
00265 
00266 
00267 #define ub_name            32768
00268 #define ub_common_name        64
00269 #define ub_locality_name      128
00270 #define ub_state_name         128
00271 #define ub_organization_name     64
00272 #define ub_organization_unit_name   64
00273 #define ub_title        64
00274 #define ub_email_address      128
00275 
00276 
00277 
00278 
00279 typedef struct ASN1_TEMPLATE_st ASN1_TEMPLATE;
00280 typedef struct ASN1_ITEM_st ASN1_ITEM;
00281 typedef struct ASN1_TLC_st ASN1_TLC;
00282 
00283 typedef struct ASN1_VALUE_st ASN1_VALUE;
00284 
00285 
00286 
00287 #define DECLARE_ASN1_FUNCTIONS(type) DECLARE_ASN1_FUNCTIONS_name(type, type)
00288 
00289 #define DECLARE_ASN1_ALLOC_FUNCTIONS(type) \
00290    DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, type)
00291 
00292 #define DECLARE_ASN1_FUNCTIONS_name(type, name) \
00293    DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, name) \
00294    DECLARE_ASN1_ENCODE_FUNCTIONS(type, name, name)
00295 
00296 #define DECLARE_ASN1_FUNCTIONS_fname(type, itname, name) \
00297    DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, name) \
00298    DECLARE_ASN1_ENCODE_FUNCTIONS(type, itname, name)
00299 
00300 #define  DECLARE_ASN1_ENCODE_FUNCTIONS(type, itname, name) \
00301    type *d2i_##name(type **a, const unsigned char **in, long len); \
00302    int i2d_##name(type *a, unsigned char **out); \
00303    DECLARE_ASN1_ITEM(itname)
00304 
00305 #define  DECLARE_ASN1_ENCODE_FUNCTIONS_const(type, name) \
00306    type *d2i_##name(type **a, const unsigned char **in, long len); \
00307    int i2d_##name(const type *a, unsigned char **out); \
00308    DECLARE_ASN1_ITEM(name)
00309 
00310 #define  DECLARE_ASN1_NDEF_FUNCTION(name) \
00311    int i2d_##name##_NDEF(name *a, unsigned char **out);
00312 
00313 #define DECLARE_ASN1_FUNCTIONS_const(name) \
00314    name *name##_new(void); \
00315    void name##_free(name *a);
00316 
00317 #define DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, name) \
00318    type *name##_new(void); \
00319    void name##_free(type *a);
00320 
00321 #define D2I_OF(type) type *(*)(type **,const unsigned char **,long)
00322 #define I2D_OF(type) int (*)(type *,unsigned char **)
00323 #define I2D_OF_const(type) int (*)(const type *,unsigned char **)
00324 
00325 #define TYPEDEF_D2I_OF(type) typedef type *d2i_of_##type(type **,const unsigned char **,long)
00326 #define TYPEDEF_I2D_OF(type) typedef int i2d_of_##type(type *,unsigned char **)
00327 #define TYPEDEF_D2I2D_OF(type) TYPEDEF_D2I_OF(type); TYPEDEF_I2D_OF(type)
00328 
00329 TYPEDEF_D2I2D_OF(void);
00330 
00331 
00332 
00333 
00334 
00335 
00336 
00337 
00338 
00339 
00340 
00341 
00342 
00343 
00344 
00345 
00346 
00347 
00348 
00349 
00350 
00351 
00352 
00353 
00354 
00355 
00356 
00357 
00358 
00359 
00360 
00361 
00362 
00363 
00364 
00365 
00366 #ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION
00367 
00368 
00369 typedef const ASN1_ITEM ASN1_ITEM_EXP;
00370 
00371 
00372 #define ASN1_ITEM_ptr(iptr) (iptr)
00373 
00374 
00375 #define ASN1_ITEM_ref(iptr) (&(iptr##_it))
00376 
00377 #define ASN1_ITEM_rptr(ref) (&(ref##_it))
00378 
00379 #define DECLARE_ASN1_ITEM(name) \
00380    OPENSSL_EXTERN const ASN1_ITEM name##_it;
00381 
00382 #else
00383 
00384 
00385 
00386 
00387 
00388 
00389 typedef const ASN1_ITEM * ASN1_ITEM_EXP(void);
00390 
00391 
00392 #define ASN1_ITEM_ptr(iptr) (iptr())
00393 
00394 
00395 #define ASN1_ITEM_ref(iptr) (iptr##_it)
00396 
00397 #define ASN1_ITEM_rptr(ref) (ref##_it())
00398 
00399 #define DECLARE_ASN1_ITEM(name) \
00400    const ASN1_ITEM * name##_it(void);
00401 
00402 #endif
00403 
00404 
00405 
00406 
00407 
00408 
00409 
00410 
00411 #define ASN1_STRFLGS_ESC_2253    1
00412 #define ASN1_STRFLGS_ESC_CTRL    2
00413 #define ASN1_STRFLGS_ESC_MSB     4
00414 
00415 
00416 
00417 
00418 
00419 
00420 
00421 #define ASN1_STRFLGS_ESC_QUOTE      8
00422 
00423 
00424 
00425 
00426 
00427 #define CHARTYPE_PRINTABLESTRING 0x10
00428 
00429 #define CHARTYPE_FIRST_ESC_2253     0x20
00430 
00431 #define CHARTYPE_LAST_ESC_2253      0x40
00432 
00433 
00434 
00435 
00436 
00437 
00438 
00439 
00440 
00441 #define ASN1_STRFLGS_UTF8_CONVERT   0x10
00442 
00443 
00444 
00445 
00446 
00447 
00448 #define ASN1_STRFLGS_IGNORE_TYPE 0x20
00449 
00450 
00451 #define ASN1_STRFLGS_SHOW_TYPE      0x40
00452 
00453 
00454 
00455 
00456 
00457 
00458 
00459 
00460 
00461 #define ASN1_STRFLGS_DUMP_ALL    0x80
00462 #define ASN1_STRFLGS_DUMP_UNKNOWN   0x100
00463 
00464 
00465 
00466 
00467 
00468 
00469 #define ASN1_STRFLGS_DUMP_DER    0x200
00470 
00471 
00472 
00473 
00474 
00475 
00476 #define ASN1_STRFLGS_RFC2253  (ASN1_STRFLGS_ESC_2253 | \
00477             ASN1_STRFLGS_ESC_CTRL | \
00478             ASN1_STRFLGS_ESC_MSB | \
00479             ASN1_STRFLGS_UTF8_CONVERT | \
00480             ASN1_STRFLGS_DUMP_UNKNOWN | \
00481             ASN1_STRFLGS_DUMP_DER)
00482 
00483 DECLARE_STACK_OF(ASN1_INTEGER)
00484 DECLARE_ASN1_SET_OF(ASN1_INTEGER)
00485 
00486 DECLARE_STACK_OF(ASN1_GENERALSTRING)
00487 
00488 typedef struct asn1_type_st
00489    {
00490    int type;
00491    union {
00492       char *ptr;
00493       ASN1_BOOLEAN      boolean;
00494       ASN1_STRING *     asn1_string;
00495       ASN1_OBJECT *     object;
00496       ASN1_INTEGER *    integer;
00497       ASN1_ENUMERATED * enumerated;
00498       ASN1_BIT_STRING * bit_string;
00499       ASN1_OCTET_STRING *  octet_string;
00500       ASN1_PRINTABLESTRING *  printablestring;
00501       ASN1_T61STRING *  t61string;
00502       ASN1_IA5STRING *  ia5string;
00503       ASN1_GENERALSTRING * generalstring;
00504       ASN1_BMPSTRING *  bmpstring;
00505       ASN1_UNIVERSALSTRING *  universalstring;
00506       ASN1_UTCTIME *    utctime;
00507       ASN1_GENERALIZEDTIME *  generalizedtime;
00508       ASN1_VISIBLESTRING * visiblestring;
00509       ASN1_UTF8STRING * utf8string;
00510       
00511 
00512       ASN1_STRING *     set;
00513       ASN1_STRING *     sequence;
00514       } value;
00515    } ASN1_TYPE;
00516 
00517 DECLARE_STACK_OF(ASN1_TYPE)
00518 DECLARE_ASN1_SET_OF(ASN1_TYPE)
00519 
00520 typedef struct asn1_method_st
00521    {
00522    i2d_of_void *i2d;
00523    d2i_of_void *d2i;
00524    void *(*create)(void);
00525    void (*destroy)(void *);
00526    } ASN1_METHOD;
00527 
00528 
00529 typedef struct asn1_header_st
00530    {
00531    ASN1_OCTET_STRING *header;
00532    void *data;
00533    ASN1_METHOD *meth;
00534    } ASN1_HEADER;
00535 
00536 
00537 typedef struct BIT_STRING_BITNAME_st {
00538    int bitnum;
00539    const char *lname;
00540    const char *sname;
00541 } BIT_STRING_BITNAME;
00542 
00543 
00544 #define M_ASN1_STRING_length(x)  ((x)->length)
00545 #define M_ASN1_STRING_length_set(x, n) ((x)->length = (n))
00546 #define M_ASN1_STRING_type(x) ((x)->type)
00547 #define M_ASN1_STRING_data(x) ((x)->data)
00548 
00549 
00550 #define M_ASN1_BIT_STRING_new()  (ASN1_BIT_STRING *)\
00551       ASN1_STRING_type_new(V_ASN1_BIT_STRING)
00552 #define M_ASN1_BIT_STRING_free(a)   ASN1_STRING_free((ASN1_STRING *)a)
00553 #define M_ASN1_BIT_STRING_dup(a) (ASN1_BIT_STRING *)\
00554       ASN1_STRING_dup((ASN1_STRING *)a)
00555 #define M_ASN1_BIT_STRING_cmp(a,b) ASN1_STRING_cmp(\
00556       (ASN1_STRING *)a,(ASN1_STRING *)b)
00557 #define M_ASN1_BIT_STRING_set(a,b,c) ASN1_STRING_set((ASN1_STRING *)a,b,c)
00558 
00559 #define M_ASN1_INTEGER_new()  (ASN1_INTEGER *)\
00560       ASN1_STRING_type_new(V_ASN1_INTEGER)
00561 #define M_ASN1_INTEGER_free(a)      ASN1_STRING_free((ASN1_STRING *)a)
00562 #define M_ASN1_INTEGER_dup(a) (ASN1_INTEGER *)ASN1_STRING_dup((ASN1_STRING *)a)
00563 #define M_ASN1_INTEGER_cmp(a,b)  ASN1_STRING_cmp(\
00564       (ASN1_STRING *)a,(ASN1_STRING *)b)
00565 
00566 #define M_ASN1_ENUMERATED_new()  (ASN1_ENUMERATED *)\
00567       ASN1_STRING_type_new(V_ASN1_ENUMERATED)
00568 #define M_ASN1_ENUMERATED_free(a)   ASN1_STRING_free((ASN1_STRING *)a)
00569 #define M_ASN1_ENUMERATED_dup(a) (ASN1_ENUMERATED *)ASN1_STRING_dup((ASN1_STRING *)a)
00570 #define M_ASN1_ENUMERATED_cmp(a,b)  ASN1_STRING_cmp(\
00571       (ASN1_STRING *)a,(ASN1_STRING *)b)
00572 
00573 #define M_ASN1_OCTET_STRING_new()   (ASN1_OCTET_STRING *)\
00574       ASN1_STRING_type_new(V_ASN1_OCTET_STRING)
00575 #define M_ASN1_OCTET_STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a)
00576 #define M_ASN1_OCTET_STRING_dup(a) (ASN1_OCTET_STRING *)\
00577       ASN1_STRING_dup((ASN1_STRING *)a)
00578 #define M_ASN1_OCTET_STRING_cmp(a,b) ASN1_STRING_cmp(\
00579       (ASN1_STRING *)a,(ASN1_STRING *)b)
00580 #define M_ASN1_OCTET_STRING_set(a,b,c) ASN1_STRING_set((ASN1_STRING *)a,b,c)
00581 #define M_ASN1_OCTET_STRING_print(a,b) ASN1_STRING_print(a,(ASN1_STRING *)b)
00582 #define M_i2d_ASN1_OCTET_STRING(a,pp) \
00583       i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_OCTET_STRING,\
00584       V_ASN1_UNIVERSAL)
00585 
00586 #define B_ASN1_TIME \
00587          B_ASN1_UTCTIME | \
00588          B_ASN1_GENERALIZEDTIME
00589 
00590 #define B_ASN1_PRINTABLE \
00591          B_ASN1_PRINTABLESTRING| \
00592          B_ASN1_T61STRING| \
00593          B_ASN1_IA5STRING| \
00594          B_ASN1_BIT_STRING| \
00595          B_ASN1_UNIVERSALSTRING|\
00596          B_ASN1_BMPSTRING|\
00597          B_ASN1_UTF8STRING|\
00598          B_ASN1_SEQUENCE|\
00599          B_ASN1_UNKNOWN
00600 
00601 #define B_ASN1_DIRECTORYSTRING \
00602          B_ASN1_PRINTABLESTRING| \
00603          B_ASN1_TELETEXSTRING|\
00604          B_ASN1_BMPSTRING|\
00605          B_ASN1_UNIVERSALSTRING|\
00606          B_ASN1_UTF8STRING
00607 
00608 #define B_ASN1_DISPLAYTEXT \
00609          B_ASN1_IA5STRING| \
00610          B_ASN1_VISIBLESTRING| \
00611          B_ASN1_BMPSTRING|\
00612          B_ASN1_UTF8STRING
00613 
00614 #define M_ASN1_PRINTABLE_new()   ASN1_STRING_type_new(V_ASN1_T61STRING)
00615 #define M_ASN1_PRINTABLE_free(a) ASN1_STRING_free((ASN1_STRING *)a)
00616 #define M_i2d_ASN1_PRINTABLE(a,pp) i2d_ASN1_bytes((ASN1_STRING *)a,\
00617       pp,a->type,V_ASN1_UNIVERSAL)
00618 #define M_d2i_ASN1_PRINTABLE(a,pp,l) \
00619       d2i_ASN1_type_bytes((ASN1_STRING **)a,pp,l, \
00620          B_ASN1_PRINTABLE)
00621 
00622 #define M_DIRECTORYSTRING_new() ASN1_STRING_type_new(V_ASN1_PRINTABLESTRING)
00623 #define M_DIRECTORYSTRING_free(a)   ASN1_STRING_free((ASN1_STRING *)a)
00624 #define M_i2d_DIRECTORYSTRING(a,pp) i2d_ASN1_bytes((ASN1_STRING *)a,\
00625                   pp,a->type,V_ASN1_UNIVERSAL)
00626 #define M_d2i_DIRECTORYSTRING(a,pp,l) \
00627       d2i_ASN1_type_bytes((ASN1_STRING **)a,pp,l, \
00628          B_ASN1_DIRECTORYSTRING)
00629 
00630 #define M_DISPLAYTEXT_new() ASN1_STRING_type_new(V_ASN1_VISIBLESTRING)
00631 #define M_DISPLAYTEXT_free(a) ASN1_STRING_free((ASN1_STRING *)a)
00632 #define M_i2d_DISPLAYTEXT(a,pp) i2d_ASN1_bytes((ASN1_STRING *)a,\
00633                   pp,a->type,V_ASN1_UNIVERSAL)
00634 #define M_d2i_DISPLAYTEXT(a,pp,l) \
00635       d2i_ASN1_type_bytes((ASN1_STRING **)a,pp,l, \
00636          B_ASN1_DISPLAYTEXT)
00637 
00638 #define M_ASN1_PRINTABLESTRING_new() (ASN1_PRINTABLESTRING *)\
00639       ASN1_STRING_type_new(V_ASN1_PRINTABLESTRING)
00640 #define M_ASN1_PRINTABLESTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a)
00641 #define M_i2d_ASN1_PRINTABLESTRING(a,pp) \
00642       i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_PRINTABLESTRING,\
00643       V_ASN1_UNIVERSAL)
00644 #define M_d2i_ASN1_PRINTABLESTRING(a,pp,l) \
00645       (ASN1_PRINTABLESTRING *)d2i_ASN1_type_bytes\
00646       ((ASN1_STRING **)a,pp,l,B_ASN1_PRINTABLESTRING)
00647 
00648 #define M_ASN1_T61STRING_new()   (ASN1_T61STRING *)\
00649       ASN1_STRING_type_new(V_ASN1_T61STRING)
00650 #define M_ASN1_T61STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a)
00651 #define M_i2d_ASN1_T61STRING(a,pp) \
00652       i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_T61STRING,\
00653       V_ASN1_UNIVERSAL)
00654 #define M_d2i_ASN1_T61STRING(a,pp,l) \
00655       (ASN1_T61STRING *)d2i_ASN1_type_bytes\
00656       ((ASN1_STRING **)a,pp,l,B_ASN1_T61STRING)
00657 
00658 #define M_ASN1_IA5STRING_new()   (ASN1_IA5STRING *)\
00659       ASN1_STRING_type_new(V_ASN1_IA5STRING)
00660 #define M_ASN1_IA5STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a)
00661 #define M_ASN1_IA5STRING_dup(a)  \
00662          (ASN1_IA5STRING *)ASN1_STRING_dup((ASN1_STRING *)a)
00663 #define M_i2d_ASN1_IA5STRING(a,pp) \
00664       i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_IA5STRING,\
00665          V_ASN1_UNIVERSAL)
00666 #define M_d2i_ASN1_IA5STRING(a,pp,l) \
00667       (ASN1_IA5STRING *)d2i_ASN1_type_bytes((ASN1_STRING **)a,pp,l,\
00668          B_ASN1_IA5STRING)
00669 
00670 #define M_ASN1_UTCTIME_new()  (ASN1_UTCTIME *)\
00671       ASN1_STRING_type_new(V_ASN1_UTCTIME)
00672 #define M_ASN1_UTCTIME_free(a)   ASN1_STRING_free((ASN1_STRING *)a)
00673 #define M_ASN1_UTCTIME_dup(a) (ASN1_UTCTIME *)ASN1_STRING_dup((ASN1_STRING *)a)
00674 
00675 #define M_ASN1_GENERALIZEDTIME_new()   (ASN1_GENERALIZEDTIME *)\
00676       ASN1_STRING_type_new(V_ASN1_GENERALIZEDTIME)
00677 #define M_ASN1_GENERALIZEDTIME_free(a) ASN1_STRING_free((ASN1_STRING *)a)
00678 #define M_ASN1_GENERALIZEDTIME_dup(a) (ASN1_GENERALIZEDTIME *)ASN1_STRING_dup(\
00679    (ASN1_STRING *)a)
00680 
00681 #define M_ASN1_TIME_new()  (ASN1_TIME *)\
00682       ASN1_STRING_type_new(V_ASN1_UTCTIME)
00683 #define M_ASN1_TIME_free(a)   ASN1_STRING_free((ASN1_STRING *)a)
00684 #define M_ASN1_TIME_dup(a) (ASN1_TIME *)ASN1_STRING_dup((ASN1_STRING *)a)
00685 
00686 #define M_ASN1_GENERALSTRING_new()  (ASN1_GENERALSTRING *)\
00687       ASN1_STRING_type_new(V_ASN1_GENERALSTRING)
00688 #define M_ASN1_GENERALSTRING_free(a)   ASN1_STRING_free((ASN1_STRING *)a)
00689 #define M_i2d_ASN1_GENERALSTRING(a,pp) \
00690       i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_GENERALSTRING,\
00691          V_ASN1_UNIVERSAL)
00692 #define M_d2i_ASN1_GENERALSTRING(a,pp,l) \
00693       (ASN1_GENERALSTRING *)d2i_ASN1_type_bytes\
00694       ((ASN1_STRING **)a,pp,l,B_ASN1_GENERALSTRING)
00695 
00696 #define M_ASN1_UNIVERSALSTRING_new()   (ASN1_UNIVERSALSTRING *)\
00697       ASN1_STRING_type_new(V_ASN1_UNIVERSALSTRING)
00698 #define M_ASN1_UNIVERSALSTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a)
00699 #define M_i2d_ASN1_UNIVERSALSTRING(a,pp) \
00700       i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_UNIVERSALSTRING,\
00701          V_ASN1_UNIVERSAL)
00702 #define M_d2i_ASN1_UNIVERSALSTRING(a,pp,l) \
00703       (ASN1_UNIVERSALSTRING *)d2i_ASN1_type_bytes\
00704       ((ASN1_STRING **)a,pp,l,B_ASN1_UNIVERSALSTRING)
00705 
00706 #define M_ASN1_BMPSTRING_new()   (ASN1_BMPSTRING *)\
00707       ASN1_STRING_type_new(V_ASN1_BMPSTRING)
00708 #define M_ASN1_BMPSTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a)
00709 #define M_i2d_ASN1_BMPSTRING(a,pp) \
00710       i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_BMPSTRING,\
00711          V_ASN1_UNIVERSAL)
00712 #define M_d2i_ASN1_BMPSTRING(a,pp,l) \
00713       (ASN1_BMPSTRING *)d2i_ASN1_type_bytes\
00714       ((ASN1_STRING **)a,pp,l,B_ASN1_BMPSTRING)
00715 
00716 #define M_ASN1_VISIBLESTRING_new()  (ASN1_VISIBLESTRING *)\
00717       ASN1_STRING_type_new(V_ASN1_VISIBLESTRING)
00718 #define M_ASN1_VISIBLESTRING_free(a)   ASN1_STRING_free((ASN1_STRING *)a)
00719 #define M_i2d_ASN1_VISIBLESTRING(a,pp) \
00720       i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_VISIBLESTRING,\
00721          V_ASN1_UNIVERSAL)
00722 #define M_d2i_ASN1_VISIBLESTRING(a,pp,l) \
00723       (ASN1_VISIBLESTRING *)d2i_ASN1_type_bytes\
00724       ((ASN1_STRING **)a,pp,l,B_ASN1_VISIBLESTRING)
00725 
00726 #define M_ASN1_UTF8STRING_new()  (ASN1_UTF8STRING *)\
00727       ASN1_STRING_type_new(V_ASN1_UTF8STRING)
00728 #define M_ASN1_UTF8STRING_free(a)   ASN1_STRING_free((ASN1_STRING *)a)
00729 #define M_i2d_ASN1_UTF8STRING(a,pp) \
00730       i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_UTF8STRING,\
00731          V_ASN1_UNIVERSAL)
00732 #define M_d2i_ASN1_UTF8STRING(a,pp,l) \
00733       (ASN1_UTF8STRING *)d2i_ASN1_type_bytes\
00734       ((ASN1_STRING **)a,pp,l,B_ASN1_UTF8STRING)
00735 
00736   
00737 #define IS_SEQUENCE  0
00738 #define IS_SET    1
00739 
00740 DECLARE_ASN1_FUNCTIONS_fname(ASN1_TYPE, ASN1_ANY, ASN1_TYPE)
00741 
00742 int ASN1_TYPE_get(ASN1_TYPE *a);
00743 void ASN1_TYPE_set(ASN1_TYPE *a, int type, void *value);
00744 
00745 ASN1_OBJECT *  ASN1_OBJECT_new(void );
00746 void     ASN1_OBJECT_free(ASN1_OBJECT *a);
00747 int      i2d_ASN1_OBJECT(ASN1_OBJECT *a,unsigned char **pp);
00748 ASN1_OBJECT *  c2i_ASN1_OBJECT(ASN1_OBJECT **a,const unsigned char **pp,
00749          long length);
00750 ASN1_OBJECT *  d2i_ASN1_OBJECT(ASN1_OBJECT **a,const unsigned char **pp,
00751          long length);
00752 
00753 DECLARE_ASN1_ITEM(ASN1_OBJECT)
00754 
00755 DECLARE_STACK_OF(ASN1_OBJECT)
00756 DECLARE_ASN1_SET_OF(ASN1_OBJECT)
00757 
00758 ASN1_STRING *  ASN1_STRING_new(void);
00759 void     ASN1_STRING_free(ASN1_STRING *a);
00760 ASN1_STRING *  ASN1_STRING_dup(ASN1_STRING *a);
00761 ASN1_STRING *  ASN1_STRING_type_new(int type );
00762 int      ASN1_STRING_cmp(ASN1_STRING *a, ASN1_STRING *b);
00763   
00764 
00765 int      ASN1_STRING_set(ASN1_STRING *str, const void *data, int len);
00766 int ASN1_STRING_length(ASN1_STRING *x);
00767 void ASN1_STRING_length_set(ASN1_STRING *x, int n);
00768 int ASN1_STRING_type(ASN1_STRING *x);
00769 unsigned char * ASN1_STRING_data(ASN1_STRING *x);
00770 
00771 DECLARE_ASN1_FUNCTIONS(ASN1_BIT_STRING)
00772 int      i2c_ASN1_BIT_STRING(ASN1_BIT_STRING *a,unsigned char **pp);
00773 ASN1_BIT_STRING *c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a,const unsigned char **pp,
00774          long length);
00775 int      ASN1_BIT_STRING_set(ASN1_BIT_STRING *a, unsigned char *d,
00776          int length );
00777 int      ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value);
00778 int      ASN1_BIT_STRING_get_bit(ASN1_BIT_STRING *a, int n);
00779 
00780 #ifndef OPENSSL_NO_BIO
00781 int ASN1_BIT_STRING_name_print(BIO *out, ASN1_BIT_STRING *bs,
00782             BIT_STRING_BITNAME *tbl, int indent);
00783 #endif
00784 int ASN1_BIT_STRING_num_asc(char *name, BIT_STRING_BITNAME *tbl);
00785 int ASN1_BIT_STRING_set_asc(ASN1_BIT_STRING *bs, char *name, int value,
00786             BIT_STRING_BITNAME *tbl);
00787 
00788 int      i2d_ASN1_BOOLEAN(int a,unsigned char **pp);
00789 int      d2i_ASN1_BOOLEAN(int *a,const unsigned char **pp,long length);
00790 
00791 DECLARE_ASN1_FUNCTIONS(ASN1_INTEGER)
00792 int      i2c_ASN1_INTEGER(ASN1_INTEGER *a,unsigned char **pp);
00793 ASN1_INTEGER *c2i_ASN1_INTEGER(ASN1_INTEGER **a,const unsigned char **pp,
00794          long length);
00795 ASN1_INTEGER *d2i_ASN1_UINTEGER(ASN1_INTEGER **a,const unsigned char **pp,
00796          long length);
00797 ASN1_INTEGER * ASN1_INTEGER_dup(ASN1_INTEGER *x);
00798 int ASN1_INTEGER_cmp(ASN1_INTEGER *x, ASN1_INTEGER *y);
00799 
00800 DECLARE_ASN1_FUNCTIONS(ASN1_ENUMERATED)
00801 
00802 int ASN1_UTCTIME_check(ASN1_UTCTIME *a);
00803 ASN1_UTCTIME *ASN1_UTCTIME_set(ASN1_UTCTIME *s,time_t t);
00804 int ASN1_UTCTIME_set_string(ASN1_UTCTIME *s, const char *str);
00805 int ASN1_UTCTIME_cmp_time_t(const ASN1_UTCTIME *s, time_t t);
00806 #if 0
00807 time_t ASN1_UTCTIME_get(const ASN1_UTCTIME *s);
00808 #endif
00809 
00810 int ASN1_GENERALIZEDTIME_check(ASN1_GENERALIZEDTIME *a);
00811 ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_set(ASN1_GENERALIZEDTIME *s,time_t t);
00812 int ASN1_GENERALIZEDTIME_set_string(ASN1_GENERALIZEDTIME *s, const char *str);
00813 
00814 DECLARE_ASN1_FUNCTIONS(ASN1_OCTET_STRING)
00815 ASN1_OCTET_STRING *  ASN1_OCTET_STRING_dup(ASN1_OCTET_STRING *a);
00816 int   ASN1_OCTET_STRING_cmp(ASN1_OCTET_STRING *a, ASN1_OCTET_STRING *b);
00817 int   ASN1_OCTET_STRING_set(ASN1_OCTET_STRING *str, const unsigned char *data, int len);
00818 
00819 DECLARE_ASN1_FUNCTIONS(ASN1_VISIBLESTRING)
00820 DECLARE_ASN1_FUNCTIONS(ASN1_UNIVERSALSTRING)
00821 DECLARE_ASN1_FUNCTIONS(ASN1_UTF8STRING)
00822 DECLARE_ASN1_FUNCTIONS(ASN1_NULL)
00823 DECLARE_ASN1_FUNCTIONS(ASN1_BMPSTRING)
00824 
00825 int UTF8_getc(const unsigned char *str, int len, unsigned long *val);
00826 int UTF8_putc(unsigned char *str, int len, unsigned long value);
00827 
00828 DECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, ASN1_PRINTABLE)
00829 
00830 DECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, DIRECTORYSTRING)
00831 DECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, DISPLAYTEXT)
00832 DECLARE_ASN1_FUNCTIONS(ASN1_PRINTABLESTRING)
00833 DECLARE_ASN1_FUNCTIONS(ASN1_T61STRING)
00834 DECLARE_ASN1_FUNCTIONS(ASN1_IA5STRING)
00835 DECLARE_ASN1_FUNCTIONS(ASN1_GENERALSTRING)
00836 DECLARE_ASN1_FUNCTIONS(ASN1_UTCTIME)
00837 DECLARE_ASN1_FUNCTIONS(ASN1_GENERALIZEDTIME)
00838 DECLARE_ASN1_FUNCTIONS(ASN1_TIME)
00839 
00840 DECLARE_ASN1_ITEM(ASN1_OCTET_STRING_NDEF)
00841 
00842 ASN1_TIME *ASN1_TIME_set(ASN1_TIME *s,time_t t);
00843 int ASN1_TIME_check(ASN1_TIME *t);
00844 ASN1_GENERALIZEDTIME *ASN1_TIME_to_generalizedtime(ASN1_TIME *t, ASN1_GENERALIZEDTIME **out);
00845 
00846 int i2d_ASN1_SET(STACK *a, unsigned char **pp,
00847        i2d_of_void *i2d, int ex_tag, int ex_class, int is_set);
00848 STACK *  d2i_ASN1_SET(STACK **a, const unsigned char **pp, long length,
00849            d2i_of_void *d2i, void (*free_func)(void *),
00850            int ex_tag, int ex_class);
00851 
00852 #ifndef OPENSSL_NO_BIO
00853 int i2a_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *a);
00854 int a2i_ASN1_INTEGER(BIO *bp,ASN1_INTEGER *bs,char *buf,int size);
00855 int i2a_ASN1_ENUMERATED(BIO *bp, ASN1_ENUMERATED *a);
00856 int a2i_ASN1_ENUMERATED(BIO *bp,ASN1_ENUMERATED *bs,char *buf,int size);
00857 int i2a_ASN1_OBJECT(BIO *bp,ASN1_OBJECT *a);
00858 int a2i_ASN1_STRING(BIO *bp,ASN1_STRING *bs,char *buf,int size);
00859 int i2a_ASN1_STRING(BIO *bp, ASN1_STRING *a, int type);
00860 #endif
00861 int i2t_ASN1_OBJECT(char *buf,int buf_len,ASN1_OBJECT *a);
00862 
00863 int a2d_ASN1_OBJECT(unsigned char *out,int olen, const char *buf, int num);
00864 ASN1_OBJECT *ASN1_OBJECT_create(int nid, unsigned char *data,int len,
00865    const char *sn, const char *ln);
00866 
00867 int ASN1_INTEGER_set(ASN1_INTEGER *a, long v);
00868 long ASN1_INTEGER_get(ASN1_INTEGER *a);
00869 ASN1_INTEGER *BN_to_ASN1_INTEGER(BIGNUM *bn, ASN1_INTEGER *ai);
00870 BIGNUM *ASN1_INTEGER_to_BN(ASN1_INTEGER *ai,BIGNUM *bn);
00871 
00872 int ASN1_ENUMERATED_set(ASN1_ENUMERATED *a, long v);
00873 long ASN1_ENUMERATED_get(ASN1_ENUMERATED *a);
00874 ASN1_ENUMERATED *BN_to_ASN1_ENUMERATED(BIGNUM *bn, ASN1_ENUMERATED *ai);
00875 BIGNUM *ASN1_ENUMERATED_to_BN(ASN1_ENUMERATED *ai,BIGNUM *bn);
00876 
00877 
00878 
00879 int ASN1_PRINTABLE_type(const unsigned char *s, int max);
00880 
00881 int i2d_ASN1_bytes(ASN1_STRING *a, unsigned char **pp, int tag, int xclass);
00882 ASN1_STRING *d2i_ASN1_bytes(ASN1_STRING **a, const unsigned char **pp,
00883    long length, int Ptag, int Pclass);
00884 unsigned long ASN1_tag2bit(int tag);
00885 
00886 ASN1_STRING *d2i_ASN1_type_bytes(ASN1_STRING **a,const unsigned char **pp,
00887       long length,int type);
00888 
00889 
00890 int asn1_Finish(ASN1_CTX *c);
00891 int asn1_const_Finish(ASN1_const_CTX *c);
00892 
00893 
00894 int ASN1_get_object(const unsigned char **pp, long *plength, int *ptag,
00895    int *pclass, long omax);
00896 int ASN1_check_infinite_end(unsigned char **p,long len);
00897 int ASN1_const_check_infinite_end(const unsigned char **p,long len);
00898 void ASN1_put_object(unsigned char **pp, int constructed, int length,
00899    int tag, int xclass);
00900 int ASN1_put_eoc(unsigned char **pp);
00901 int ASN1_object_size(int constructed, int length, int tag);
00902 
00903 
00904 void *ASN1_dup(i2d_of_void *i2d, d2i_of_void *d2i, char *x);
00905 #define ASN1_dup_of(type,i2d,d2i,x) \
00906    ((type *(*)(I2D_OF(type),D2I_OF(type),type *))openssl_fcast(ASN1_dup))(i2d,d2i,x)
00907 #define ASN1_dup_of_const(type,i2d,d2i,x) \
00908    ((type *(*)(I2D_OF_const(type),D2I_OF(type),type *))openssl_fcast(ASN1_dup))(i2d,d2i,x)
00909 
00910 void *ASN1_item_dup(const ASN1_ITEM *it, void *x);
00911 
00912 #ifndef OPENSSL_NO_FP_API
00913 void *ASN1_d2i_fp(void *(*xnew)(void), d2i_of_void *d2i, FILE *in, void **x);
00914 #define ASN1_d2i_fp_of(type,xnew,d2i,in,x) \
00915    ((type *(*)(type *(*)(void),D2I_OF(type),FILE *,type **))openssl_fcast(ASN1_d2i_fp))(xnew,d2i,in,x)
00916 void *ASN1_item_d2i_fp(const ASN1_ITEM *it, FILE *in, void *x);
00917 int ASN1_i2d_fp(i2d_of_void *i2d,FILE *out,void *x);
00918 #define ASN1_i2d_fp_of(type,i2d,out,x) \
00919    ((int (*)(I2D_OF(type),FILE *,type *))openssl_fcast(ASN1_i2d_fp))(i2d,out,x)
00920 #define ASN1_i2d_fp_of_const(type,i2d,out,x) \
00921    ((int (*)(I2D_OF_const(type),FILE *,type *))openssl_fcast(ASN1_i2d_fp))(i2d,out,x)
00922 int ASN1_item_i2d_fp(const ASN1_ITEM *it, FILE *out, void *x);
00923 int ASN1_STRING_print_ex_fp(FILE *fp, ASN1_STRING *str, unsigned long flags);
00924 #endif
00925 
00926 int ASN1_STRING_to_UTF8(unsigned char **out, ASN1_STRING *in);
00927 
00928 #ifndef OPENSSL_NO_BIO
00929 void *ASN1_d2i_bio(void *(*xnew)(void), d2i_of_void *d2i, BIO *in, void **x);
00930 #define ASN1_d2i_bio_of(type,xnew,d2i,in,x) \
00931    ((type *(*)(type *(*)(void),D2I_OF(type),BIO *,type **))openssl_fcast(ASN1_d2i_bio))(xnew,d2i,in,x)
00932 void *ASN1_item_d2i_bio(const ASN1_ITEM *it, BIO *in, void *x);
00933 int ASN1_i2d_bio(i2d_of_void *i2d,BIO *out, unsigned char *x);
00934 #define ASN1_i2d_bio_of(type,i2d,out,x) \
00935    ((int (*)(I2D_OF(type),BIO *,type *))openssl_fcast(ASN1_i2d_bio))(i2d,out,x)
00936 #define ASN1_i2d_bio_of_const(type,i2d,out,x) \
00937    ((int (*)(I2D_OF_const(type),BIO *,const type *))openssl_fcast(ASN1_i2d_bio))(i2d,out,x)
00938 int ASN1_item_i2d_bio(const ASN1_ITEM *it, BIO *out, void *x);
00939 int ASN1_UTCTIME_print(BIO *fp,ASN1_UTCTIME *a);
00940 int ASN1_GENERALIZEDTIME_print(BIO *fp,ASN1_GENERALIZEDTIME *a);
00941 int ASN1_TIME_print(BIO *fp,ASN1_TIME *a);
00942 int ASN1_STRING_print(BIO *bp,ASN1_STRING *v);
00943 int ASN1_STRING_print_ex(BIO *out, ASN1_STRING *str, unsigned long flags);
00944 int ASN1_parse(BIO *bp,const unsigned char *pp,long len,int indent);
00945 int ASN1_parse_dump(BIO *bp,const unsigned char *pp,long len,int indent,int dump);
00946 #endif
00947 const char *ASN1_tag2str(int tag);
00948 
00949 
00950 int i2d_ASN1_HEADER(ASN1_HEADER *a,unsigned char **pp);
00951 ASN1_HEADER *d2i_ASN1_HEADER(ASN1_HEADER **a,const unsigned char **pp, long length);
00952 ASN1_HEADER *ASN1_HEADER_new(void );
00953 void ASN1_HEADER_free(ASN1_HEADER *a);
00954 
00955 int ASN1_UNIVERSALSTRING_to_string(ASN1_UNIVERSALSTRING *s);
00956 
00957 
00958 ASN1_METHOD *X509_asn1_meth(void);
00959 ASN1_METHOD *RSAPrivateKey_asn1_meth(void);
00960 ASN1_METHOD *ASN1_IA5STRING_asn1_meth(void);
00961 ASN1_METHOD *ASN1_BIT_STRING_asn1_meth(void);
00962 
00963 int ASN1_TYPE_set_octetstring(ASN1_TYPE *a,
00964    unsigned char *data, int len);
00965 int ASN1_TYPE_get_octetstring(ASN1_TYPE *a,
00966    unsigned char *data, int max_len);
00967 int ASN1_TYPE_set_int_octetstring(ASN1_TYPE *a, long num,
00968    unsigned char *data, int len);
00969 int ASN1_TYPE_get_int_octetstring(ASN1_TYPE *a,long *num,
00970    unsigned char *data, int max_len);
00971 
00972 STACK *ASN1_seq_unpack(const unsigned char *buf, int len,
00973              d2i_of_void *d2i, void (*free_func)(void *));
00974 unsigned char *ASN1_seq_pack(STACK *safes, i2d_of_void *i2d,
00975               unsigned char **buf, int *len );
00976 void *ASN1_unpack_string(ASN1_STRING *oct, d2i_of_void *d2i);
00977 void *ASN1_item_unpack(ASN1_STRING *oct, const ASN1_ITEM *it);
00978 ASN1_STRING *ASN1_pack_string(void *obj, i2d_of_void *i2d,
00979                ASN1_OCTET_STRING **oct);
00980 #define ASN1_pack_string_of(type,obj,i2d,oct) \
00981    ((ASN1_STRING *(*)(type *,I2D_OF(type),ASN1_OCTET_STRING **))openssl_fcast(ASN1_pack_string))(obj,i2d,oct)
00982 ASN1_STRING *ASN1_item_pack(void *obj, const ASN1_ITEM *it, ASN1_OCTET_STRING **oct);
00983 
00984 void ASN1_STRING_set_default_mask(unsigned long mask);
00985 int ASN1_STRING_set_default_mask_asc(char *p);
00986 unsigned long ASN1_STRING_get_default_mask(void);
00987 int ASN1_mbstring_copy(ASN1_STRING **out, const unsigned char *in, int len,
00988                int inform, unsigned long mask);
00989 int ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len,
00990                int inform, unsigned long mask,
00991                long minsize, long maxsize);
00992 
00993 ASN1_STRING *ASN1_STRING_set_by_NID(ASN1_STRING **out,
00994       const unsigned char *in, int inlen, int inform, int nid);
00995 ASN1_STRING_TABLE *ASN1_STRING_TABLE_get(int nid);
00996 int ASN1_STRING_TABLE_add(int, long, long, unsigned long, unsigned long);
00997 void ASN1_STRING_TABLE_cleanup(void);
00998 
00999 
01000 
01001 
01002 ASN1_VALUE *ASN1_item_new(const ASN1_ITEM *it);
01003 void ASN1_item_free(ASN1_VALUE *val, const ASN1_ITEM *it);
01004 ASN1_VALUE * ASN1_item_d2i(ASN1_VALUE **val, const unsigned char **in, long len, const ASN1_ITEM *it);
01005 int ASN1_item_i2d(ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it);
01006 int ASN1_item_ndef_i2d(ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it);
01007 
01008 void ASN1_add_oid_module(void);
01009 
01010 ASN1_TYPE *ASN1_generate_nconf(char *str, CONF *nconf);
01011 ASN1_TYPE *ASN1_generate_v3(char *str, X509V3_CTX *cnf);
01012 
01013 
01014 
01015 
01016 
01017 void ERR_load_ASN1_strings(void);
01018 
01019 
01020 
01021 
01022 #define ASN1_F_A2D_ASN1_OBJECT             100
01023 #define ASN1_F_A2I_ASN1_ENUMERATED         101
01024 #define ASN1_F_A2I_ASN1_INTEGER            102
01025 #define ASN1_F_A2I_ASN1_STRING             103
01026 #define ASN1_F_APPEND_EXP            176
01027 #define ASN1_F_ASN1_BIT_STRING_SET_BIT        183
01028 #define ASN1_F_ASN1_CB               177
01029 #define ASN1_F_ASN1_CHECK_TLEN             104
01030 #define ASN1_F_ASN1_COLLATE_PRIMITIVE         105
01031 #define ASN1_F_ASN1_COLLECT             106
01032 #define ASN1_F_ASN1_D2I_EX_PRIMITIVE          108
01033 #define ASN1_F_ASN1_D2I_FP           109
01034 #define ASN1_F_ASN1_D2I_READ_BIO        107
01035 #define ASN1_F_ASN1_DIGEST           184
01036 #define ASN1_F_ASN1_DO_ADB           110
01037 #define ASN1_F_ASN1_DUP              111
01038 #define ASN1_F_ASN1_ENUMERATED_SET         112
01039 #define ASN1_F_ASN1_ENUMERATED_TO_BN          113
01040 #define ASN1_F_ASN1_EX_C2I           204
01041 #define ASN1_F_ASN1_FIND_END            190
01042 #define ASN1_F_ASN1_GENERALIZEDTIME_SET          185
01043 #define ASN1_F_ASN1_GENERATE_V3            178
01044 #define ASN1_F_ASN1_GET_OBJECT             114
01045 #define ASN1_F_ASN1_HEADER_NEW             115
01046 #define ASN1_F_ASN1_I2D_BIO             116
01047 #define ASN1_F_ASN1_I2D_FP           117
01048 #define ASN1_F_ASN1_INTEGER_SET            118
01049 #define ASN1_F_ASN1_INTEGER_TO_BN          119
01050 #define ASN1_F_ASN1_ITEM_D2I_FP            206
01051 #define ASN1_F_ASN1_ITEM_DUP            191
01052 #define ASN1_F_ASN1_ITEM_EX_COMBINE_NEW          121
01053 #define ASN1_F_ASN1_ITEM_EX_D2I            120
01054 #define ASN1_F_ASN1_ITEM_I2D_BIO        192
01055 #define ASN1_F_ASN1_ITEM_I2D_FP            193
01056 #define ASN1_F_ASN1_ITEM_PACK           198
01057 #define ASN1_F_ASN1_ITEM_SIGN           195
01058 #define ASN1_F_ASN1_ITEM_UNPACK            199
01059 #define ASN1_F_ASN1_ITEM_VERIFY            197
01060 #define ASN1_F_ASN1_MBSTRING_NCOPY         122
01061 #define ASN1_F_ASN1_OBJECT_NEW             123
01062 #define ASN1_F_ASN1_PACK_STRING            124
01063 #define ASN1_F_ASN1_PCTX_NEW            205
01064 #define ASN1_F_ASN1_PKCS5_PBE_SET          125
01065 #define ASN1_F_ASN1_SEQ_PACK            126
01066 #define ASN1_F_ASN1_SEQ_UNPACK             127
01067 #define ASN1_F_ASN1_SIGN             128
01068 #define ASN1_F_ASN1_STR2TYPE            179
01069 #define ASN1_F_ASN1_STRING_SET             186
01070 #define ASN1_F_ASN1_STRING_TABLE_ADD          129
01071 #define ASN1_F_ASN1_STRING_TYPE_NEW        130
01072 #define ASN1_F_ASN1_TEMPLATE_EX_D2I        132
01073 #define ASN1_F_ASN1_TEMPLATE_NEW        133
01074 #define ASN1_F_ASN1_TEMPLATE_NOEXP_D2I        131
01075 #define ASN1_F_ASN1_TIME_SET            175
01076 #define ASN1_F_ASN1_TYPE_GET_INT_OCTETSTRING     134
01077 #define ASN1_F_ASN1_TYPE_GET_OCTETSTRING      135
01078 #define ASN1_F_ASN1_UNPACK_STRING          136
01079 #define ASN1_F_ASN1_UTCTIME_SET            187
01080 #define ASN1_F_ASN1_VERIFY           137
01081 #define ASN1_F_BITSTR_CB             180
01082 #define ASN1_F_BN_TO_ASN1_ENUMERATED          138
01083 #define ASN1_F_BN_TO_ASN1_INTEGER          139
01084 #define ASN1_F_C2I_ASN1_BIT_STRING         189
01085 #define ASN1_F_C2I_ASN1_INTEGER            194
01086 #define ASN1_F_C2I_ASN1_OBJECT             196
01087 #define ASN1_F_COLLECT_DATA             140
01088 #define ASN1_F_D2I_ASN1_BIT_STRING         141
01089 #define ASN1_F_D2I_ASN1_BOOLEAN            142
01090 #define ASN1_F_D2I_ASN1_BYTES           143
01091 #define ASN1_F_D2I_ASN1_GENERALIZEDTIME          144
01092 #define ASN1_F_D2I_ASN1_HEADER             145
01093 #define ASN1_F_D2I_ASN1_INTEGER            146
01094 #define ASN1_F_D2I_ASN1_OBJECT             147
01095 #define ASN1_F_D2I_ASN1_SET             148
01096 #define ASN1_F_D2I_ASN1_TYPE_BYTES         149
01097 #define ASN1_F_D2I_ASN1_UINTEGER        150
01098 #define ASN1_F_D2I_ASN1_UTCTIME            151
01099 #define ASN1_F_D2I_NETSCAPE_RSA            152
01100 #define ASN1_F_D2I_NETSCAPE_RSA_2          153
01101 #define ASN1_F_D2I_PRIVATEKEY           154
01102 #define ASN1_F_D2I_PUBLICKEY            155
01103 #define ASN1_F_D2I_RSA_NET           200
01104 #define ASN1_F_D2I_RSA_NET_2            201
01105 #define ASN1_F_D2I_X509              156
01106 #define ASN1_F_D2I_X509_CINF            157
01107 #define ASN1_F_D2I_X509_PKEY            159
01108 #define ASN1_F_I2D_ASN1_SET             188
01109 #define ASN1_F_I2D_ASN1_TIME            160
01110 #define ASN1_F_I2D_DSA_PUBKEY           161
01111 #define ASN1_F_I2D_EC_PUBKEY            181
01112 #define ASN1_F_I2D_PRIVATEKEY           163
01113 #define ASN1_F_I2D_PUBLICKEY            164
01114 #define ASN1_F_I2D_RSA_NET           162
01115 #define ASN1_F_I2D_RSA_PUBKEY           165
01116 #define ASN1_F_LONG_C2I              166
01117 #define ASN1_F_OID_MODULE_INIT             174
01118 #define ASN1_F_PARSE_TAGGING            182
01119 #define ASN1_F_PKCS5_PBE2_SET           167
01120 #define ASN1_F_PKCS5_PBE_SET            202
01121 #define ASN1_F_X509_CINF_NEW            168
01122 #define ASN1_F_X509_CRL_ADD0_REVOKED          169
01123 #define ASN1_F_X509_INFO_NEW            170
01124 #define ASN1_F_X509_NAME_ENCODE            203
01125 #define ASN1_F_X509_NAME_EX_D2I            158
01126 #define ASN1_F_X509_NAME_EX_NEW            171
01127 #define ASN1_F_X509_NEW              172
01128 #define ASN1_F_X509_PKEY_NEW            173
01129 
01130 
01131 #define ASN1_R_ADDING_OBJECT            171
01132 #define ASN1_R_AUX_ERROR             100
01133 #define ASN1_R_BAD_CLASS             101
01134 #define ASN1_R_BAD_OBJECT_HEADER        102
01135 #define ASN1_R_BAD_PASSWORD_READ        103
01136 #define ASN1_R_BAD_TAG               104
01137 #define ASN1_R_BN_LIB                105
01138 #define ASN1_R_BOOLEAN_IS_WRONG_LENGTH        106
01139 #define ASN1_R_BUFFER_TOO_SMALL            107
01140 #define ASN1_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER      108
01141 #define ASN1_R_DATA_IS_WRONG            109
01142 #define ASN1_R_DECODE_ERROR             110
01143 #define ASN1_R_DECODING_ERROR           111
01144 #define ASN1_R_DEPTH_EXCEEDED           174
01145 #define ASN1_R_ENCODE_ERROR             112
01146 #define ASN1_R_ERROR_GETTING_TIME          173
01147 #define ASN1_R_ERROR_LOADING_SECTION          172
01148 #define ASN1_R_ERROR_PARSING_SET_ELEMENT      113
01149 #define ASN1_R_ERROR_SETTING_CIPHER_PARAMS       114
01150 #define ASN1_R_EXPECTING_AN_INTEGER        115
01151 #define ASN1_R_EXPECTING_AN_OBJECT         116
01152 #define ASN1_R_EXPECTING_A_BOOLEAN         117
01153 #define ASN1_R_EXPECTING_A_TIME            118
01154 #define ASN1_R_EXPLICIT_LENGTH_MISMATCH          119
01155 #define ASN1_R_EXPLICIT_TAG_NOT_CONSTRUCTED      120
01156 #define ASN1_R_FIELD_MISSING            121
01157 #define ASN1_R_FIRST_NUM_TOO_LARGE         122
01158 #define ASN1_R_HEADER_TOO_LONG             123
01159 #define ASN1_R_ILLEGAL_BITSTRING_FORMAT          175
01160 #define ASN1_R_ILLEGAL_BOOLEAN             176
01161 #define ASN1_R_ILLEGAL_CHARACTERS          124
01162 #define ASN1_R_ILLEGAL_FORMAT           177
01163 #define ASN1_R_ILLEGAL_HEX           178
01164 #define ASN1_R_ILLEGAL_IMPLICIT_TAG        179
01165 #define ASN1_R_ILLEGAL_INTEGER             180
01166 #define ASN1_R_ILLEGAL_NESTED_TAGGING         181
01167 #define ASN1_R_ILLEGAL_NULL             125
01168 #define ASN1_R_ILLEGAL_NULL_VALUE          182
01169 #define ASN1_R_ILLEGAL_OBJECT           183
01170 #define ASN1_R_ILLEGAL_OPTIONAL_ANY        126
01171 #define ASN1_R_ILLEGAL_OPTIONS_ON_ITEM_TEMPLATE     170
01172 #define ASN1_R_ILLEGAL_TAGGED_ANY          127
01173 #define ASN1_R_ILLEGAL_TIME_VALUE          184
01174 #define ASN1_R_INTEGER_NOT_ASCII_FORMAT          185
01175 #define ASN1_R_INTEGER_TOO_LARGE_FOR_LONG     128
01176 #define ASN1_R_INVALID_BMPSTRING_LENGTH          129
01177 #define ASN1_R_INVALID_DIGIT            130
01178 #define ASN1_R_INVALID_MODIFIER            186
01179 #define ASN1_R_INVALID_NUMBER           187
01180 #define ASN1_R_INVALID_SEPARATOR        131
01181 #define ASN1_R_INVALID_TIME_FORMAT         132
01182 #define ASN1_R_INVALID_UNIVERSALSTRING_LENGTH       133
01183 #define ASN1_R_INVALID_UTF8STRING          134
01184 #define ASN1_R_IV_TOO_LARGE             135
01185 #define ASN1_R_LENGTH_ERROR             136
01186 #define ASN1_R_LIST_ERROR            188
01187 #define ASN1_R_MISSING_EOC           137
01188 #define ASN1_R_MISSING_SECOND_NUMBER          138
01189 #define ASN1_R_MISSING_VALUE            189
01190 #define ASN1_R_MSTRING_NOT_UNIVERSAL          139
01191 #define ASN1_R_MSTRING_WRONG_TAG        140
01192 #define ASN1_R_NESTED_ASN1_STRING          197
01193 #define ASN1_R_NON_HEX_CHARACTERS          141
01194 #define ASN1_R_NOT_ASCII_FORMAT            190
01195 #define ASN1_R_NOT_ENOUGH_DATA             142
01196 #define ASN1_R_NO_MATCHING_CHOICE_TYPE        143
01197 #define ASN1_R_NULL_IS_WRONG_LENGTH        144
01198 #define ASN1_R_OBJECT_NOT_ASCII_FORMAT        191
01199 #define ASN1_R_ODD_NUMBER_OF_CHARS         145
01200 #define ASN1_R_PRIVATE_KEY_HEADER_MISSING     146
01201 #define ASN1_R_SECOND_NUMBER_TOO_LARGE        147
01202 #define ASN1_R_SEQUENCE_LENGTH_MISMATCH          148
01203 #define ASN1_R_SEQUENCE_NOT_CONSTRUCTED          149
01204 #define ASN1_R_SEQUENCE_OR_SET_NEEDS_CONFIG      192
01205 #define ASN1_R_SHORT_LINE            150
01206 #define ASN1_R_STRING_TOO_LONG             151
01207 #define ASN1_R_STRING_TOO_SHORT            152
01208 #define ASN1_R_TAG_VALUE_TOO_HIGH          153
01209 #define ASN1_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD 154
01210 #define ASN1_R_TIME_NOT_ASCII_FORMAT          193
01211 #define ASN1_R_TOO_LONG              155
01212 #define ASN1_R_TYPE_NOT_CONSTRUCTED        156
01213 #define ASN1_R_UNABLE_TO_DECODE_RSA_KEY          157
01214 #define ASN1_R_UNABLE_TO_DECODE_RSA_PRIVATE_KEY     158
01215 #define ASN1_R_UNEXPECTED_EOC           159
01216 #define ASN1_R_UNKNOWN_FORMAT           160
01217 #define ASN1_R_UNKNOWN_MESSAGE_DIGEST_ALGORITHM     161
01218 #define ASN1_R_UNKNOWN_OBJECT_TYPE         162
01219 #define ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE        163
01220 #define ASN1_R_UNKNOWN_TAG           194
01221 #define ASN1_R_UNKOWN_FORMAT            195
01222 #define ASN1_R_UNSUPPORTED_ANY_DEFINED_BY_TYPE      164
01223 #define ASN1_R_UNSUPPORTED_CIPHER          165
01224 #define ASN1_R_UNSUPPORTED_ENCRYPTION_ALGORITHM     166
01225 #define ASN1_R_UNSUPPORTED_PUBLIC_KEY_TYPE       167
01226 #define ASN1_R_UNSUPPORTED_TYPE            196
01227 #define ASN1_R_WRONG_TAG             168
01228 #define ASN1_R_WRONG_TYPE            169
01229 
01230 #ifdef  __cplusplus
01231 }
01232 #endif
01233 #endif