Main Page | Modules | Class List | Directories | File List | Class Members | File Members | Related Pages

asn1.h

Go to the documentation of this file.
00001 #ifndef __ASN1_H__
00002 #define __ASN1_H__
00003 
00004 /*
00005 **  ASN.1 Identifier Classes
00006 */
00007 #define SF_ASN1_CLASS_MASK        0xc0
00008 #define SF_ASN1_CLASS_UNIVERSAL   0x00
00009 #define SF_ASN1_CLASS_APPLICATION 0x40
00010 #define SF_ASN1_CLASS_CONTEXT     0x80
00011 #define SF_ASN1_CLASS_PRIVATE     0xc0
00012 
00013 /*
00014 **  ASN.1 Identifier Flags
00015 */
00016 #define SF_ASN1_FLAG_MASK       0x20
00017 #define SF_ASN1_FLAG_PRIMITIVE  0x00
00018 #define SF_ASN1_FLAG_CONSTRUCT  0x20
00019 
00020 /*
00021 **  ASN.1 Universal Tags
00022 */
00023 #define SF_ASN1_TAG_MASK      0x1f
00024 
00025 #define SF_ASN1_TAG_RSV_ENC   0
00026 #define SF_ASN1_TAG_BOOL      1 
00027 #define SF_ASN1_TAG_INT       2
00028 #define SF_ASN1_TAG_BIT_STR   3
00029 #define SF_ASN1_TAG_OCT_STR   4
00030 #define SF_ASN1_TAG_NULL      5
00031 #define SF_ASN1_TAG_OBJ_IDENT 6
00032 #define SF_ASN1_TAG_OBJ_DESC  7
00033 #define SF_ASN1_TAG_EXT       8
00034 #define SF_ASN1_TAG_REAL      9
00035 #define SF_ASN1_TAG_ENUM      10
00036 #define SF_ASN1_TAG_EMB_PDV   11
00037 #define SF_ASN1_TAG_REL_OBJ   13
00038 
00039 #define SF_ASN1_TAG_SEQ       16
00040 #define SF_ASN1_TAG_SET       17 
00041 
00042 #define SF_ASN1_TAG_UTF8_STR  12
00043 #define SF_ASN1_TAG_NUM_STR   18
00044 #define SF_ASN1_TAG_PRINT_STR 19 
00045 #define SF_ASN1_TAG_T61_STR   20
00046 #define SF_ASN1_TAG_VID_STR   21
00047 #define SF_ASN1_TAG_IA5_STR   22
00048 #define SF_ASN1_TAG_GRAPH_STR 25
00049 #define SF_ASN1_TAG_VIS_STR   26
00050 #define SF_ASN1_TAG_GEN_STR   27
00051 #define SF_ASN1_TAG_UNIV_STR  28
00052 #define SF_ASN1_TAG_BMP_STR   30
00053 
00054 #define SF_ASN1_TAG_UTC_TIME  23
00055 #define SF_ASN1_TAG_GEN_TIME  24
00056 
00057 #define SF_ASN1_TAG_EXTENSION 31
00058 
00059 /*
00060 **  BER Length Decoding
00061 */
00062 #define SF_BER_LEN_MASK      0x80
00063 #define SF_BER_LEN_DEF_SHORT 1
00064 #define SF_BER_LEN_DEF_LONG  2
00065 #define SF_BER_LEN_INDEF     3
00066 
00067 typedef struct s_ASN1_LEN
00068 {
00069     unsigned char type;
00070     unsigned int  size;
00071 
00072 } ASN1_LEN;
00073 
00074 typedef struct s_ASN1_IDENT
00075 {
00076     unsigned char  class;
00077     unsigned char  flag;
00078     unsigned char  tag_type;
00079     unsigned int   tag;
00080 
00081 } ASN1_IDENT;
00082 
00083 typedef struct s_ASN1_TYPE
00084 {
00085     ASN1_IDENT ident;
00086     ASN1_LEN   len;
00087     
00088     unsigned char     *data;
00089     unsigned int      data_len;
00090 
00091     unsigned char     eoc;
00092 
00093     struct s_ASN1_TYPE  *next;
00094     struct s_ASN1_TYPE  *cnext;
00095     
00096 } ASN1_TYPE;
00097 
00098 typedef struct s_ASN1_DATA
00099 {
00100     unsigned char *data;
00101     unsigned char *start;
00102     unsigned char *end;
00103     unsigned int   len;
00104 
00105 } ASN1_DATA;
00106 
00107 /*
00108 **  Error Codes
00109 */
00110 #define ASN1_ERR_OOB          1
00111 #define ASN1_ERR_NONFATAL     2
00112 #define ASN1_ERR_OVERLONG_LEN 3
00113 
00114 #define ASN1_OK      0
00115 
00116 #define ASN1_ERR_NULL_MEM            -1
00117 #define ASN1_ERR_INVALID_BER_TAG_LEN -3
00118 #define ASN1_ERR_MEM_ALLOC           -4
00119 #define ASN1_ERR_FATAL               -5
00120 #define ASN1_ERR_INVALID_INDEF_LEN   -6
00121 #define ASN1_ERR_INVALID_ARG         -7
00122 #define ASN1_ERR_STACK               -8
00123 
00124 int asn1_init_mem(int iNodes);
00125 int asn1_decode(unsigned char *data, unsigned int len, ASN1_TYPE **asn1_type);
00126 int asn1_print_types(ASN1_TYPE *asn1_type, void *user);
00127 int asn1_traverse(ASN1_TYPE *asn1, void * user, 
00128                   int (*DetectFunc)(ASN1_TYPE *, void *));
00129 
00130 #endif

Generated on Sun May 14 14:51:18 2006 by  doxygen 1.4.2