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

asn1.h File Reference

Go to the source code of this file.

Defines

#define SF_ASN1_CLASS_MASK   0xc0
#define SF_ASN1_CLASS_UNIVERSAL   0x00
#define SF_ASN1_CLASS_APPLICATION   0x40
#define SF_ASN1_CLASS_CONTEXT   0x80
#define SF_ASN1_CLASS_PRIVATE   0xc0
#define SF_ASN1_FLAG_MASK   0x20
#define SF_ASN1_FLAG_PRIMITIVE   0x00
#define SF_ASN1_FLAG_CONSTRUCT   0x20
#define SF_ASN1_TAG_MASK   0x1f
#define SF_ASN1_TAG_RSV_ENC   0
#define SF_ASN1_TAG_BOOL   1
#define SF_ASN1_TAG_INT   2
#define SF_ASN1_TAG_BIT_STR   3
#define SF_ASN1_TAG_OCT_STR   4
#define SF_ASN1_TAG_NULL   5
#define SF_ASN1_TAG_OBJ_IDENT   6
#define SF_ASN1_TAG_OBJ_DESC   7
#define SF_ASN1_TAG_EXT   8
#define SF_ASN1_TAG_REAL   9
#define SF_ASN1_TAG_ENUM   10
#define SF_ASN1_TAG_EMB_PDV   11
#define SF_ASN1_TAG_REL_OBJ   13
#define SF_ASN1_TAG_SEQ   16
#define SF_ASN1_TAG_SET   17
#define SF_ASN1_TAG_UTF8_STR   12
#define SF_ASN1_TAG_NUM_STR   18
#define SF_ASN1_TAG_PRINT_STR   19
#define SF_ASN1_TAG_T61_STR   20
#define SF_ASN1_TAG_VID_STR   21
#define SF_ASN1_TAG_IA5_STR   22
#define SF_ASN1_TAG_GRAPH_STR   25
#define SF_ASN1_TAG_VIS_STR   26
#define SF_ASN1_TAG_GEN_STR   27
#define SF_ASN1_TAG_UNIV_STR   28
#define SF_ASN1_TAG_BMP_STR   30
#define SF_ASN1_TAG_UTC_TIME   23
#define SF_ASN1_TAG_GEN_TIME   24
#define SF_ASN1_TAG_EXTENSION   31
#define SF_BER_LEN_MASK   0x80
#define SF_BER_LEN_DEF_SHORT   1
#define SF_BER_LEN_DEF_LONG   2
#define SF_BER_LEN_INDEF   3
#define ASN1_ERR_OOB   1
#define ASN1_ERR_NONFATAL   2
#define ASN1_ERR_OVERLONG_LEN   3
#define ASN1_OK   0
#define ASN1_ERR_NULL_MEM   -1
#define ASN1_ERR_INVALID_BER_TAG_LEN   -3
#define ASN1_ERR_MEM_ALLOC   -4
#define ASN1_ERR_FATAL   -5
#define ASN1_ERR_INVALID_INDEF_LEN   -6
#define ASN1_ERR_INVALID_ARG   -7
#define ASN1_ERR_STACK   -8

Typedefs

typedef s_ASN1_LEN ASN1_LEN
typedef s_ASN1_IDENT ASN1_IDENT
typedef s_ASN1_TYPE ASN1_TYPE
typedef s_ASN1_DATA ASN1_DATA

Functions

int asn1_init_mem (int iNodes)
int asn1_decode (unsigned char *data, unsigned int len, ASN1_TYPE **asn1_type)
int asn1_print_types (ASN1_TYPE *asn1_type, void *user)
int asn1_traverse (ASN1_TYPE *asn1, void *user, int(*DetectFunc)(ASN1_TYPE *, void *))


Define Documentation

#define ASN1_ERR_FATAL   -5
 

Definition at line 119 of file asn1.h.

Referenced by asn1_decode_len().

#define ASN1_ERR_INVALID_ARG   -7
 

Definition at line 121 of file asn1.h.

Referenced by asn1_decode_type(), and asn1_init_mem().

#define ASN1_ERR_INVALID_BER_TAG_LEN   -3
 

Definition at line 117 of file asn1.h.

Referenced by asn1_decode_ident().

#define ASN1_ERR_INVALID_INDEF_LEN   -6
 

Definition at line 120 of file asn1.h.

Referenced by asn1_decode_type().

#define ASN1_ERR_MEM_ALLOC   -4
 

Definition at line 118 of file asn1.h.

Referenced by asn1_decode_type(), and asn1_init_mem().

#define ASN1_ERR_NONFATAL   2
 

Definition at line 111 of file asn1.h.

#define ASN1_ERR_NULL_MEM   -1
 

Definition at line 116 of file asn1.h.

Referenced by asn1_decode(), asn1_decode_ident(), asn1_decode_len(), asn1_decode_len_ext(), and asn1_decode_tag_num_ext().

#define ASN1_ERR_OOB   1
 

Definition at line 110 of file asn1.h.

Referenced by asn1_decode_ident(), asn1_decode_len(), asn1_decode_len_ext(), asn1_decode_tag_num_ext(), and asn1_decode_type().

#define ASN1_ERR_OVERLONG_LEN   3
 

Definition at line 112 of file asn1.h.

Referenced by asn1_decode(), asn1_decode_len_ext(), asn1_decode_tag_num_ext(), and Asn1DetectFuncs().

#define ASN1_ERR_STACK   -8
 

Definition at line 122 of file asn1.h.

Referenced by asn1_decode().

#define ASN1_OK   0
 

Definition at line 114 of file asn1.h.

Referenced by asn1_decode(), asn1_decode_ident(), asn1_decode_len(), asn1_decode_len_ext(), asn1_decode_tag_num_ext(), asn1_decode_type(), and asn1_init_mem().

#define SF_ASN1_CLASS_APPLICATION   0x40
 

Definition at line 9 of file asn1.h.

#define SF_ASN1_CLASS_CONTEXT   0x80
 

Definition at line 10 of file asn1.h.

#define SF_ASN1_CLASS_MASK   0xc0
 

Definition at line 7 of file asn1.h.

#define SF_ASN1_CLASS_PRIVATE   0xc0
 

Definition at line 11 of file asn1.h.

#define SF_ASN1_CLASS_UNIVERSAL   0x00
 

Definition at line 8 of file asn1.h.

#define SF_ASN1_FLAG_CONSTRUCT   0x20
 

Definition at line 18 of file asn1.h.

Referenced by asn1_decode(), asn1_decode_type(), and asn1_traverse().

#define SF_ASN1_FLAG_MASK   0x20
 

Definition at line 16 of file asn1.h.

#define SF_ASN1_FLAG_PRIMITIVE   0x00
 

Definition at line 17 of file asn1.h.

#define SF_ASN1_TAG_BIT_STR   3
 

Definition at line 28 of file asn1.h.

Referenced by BitStringOverflow().

#define SF_ASN1_TAG_BMP_STR   30
 

Definition at line 52 of file asn1.h.

#define SF_ASN1_TAG_BOOL   1
 

Definition at line 26 of file asn1.h.

#define SF_ASN1_TAG_EMB_PDV   11
 

Definition at line 36 of file asn1.h.

#define SF_ASN1_TAG_ENUM   10
 

Definition at line 35 of file asn1.h.

#define SF_ASN1_TAG_EXT   8
 

Definition at line 33 of file asn1.h.

#define SF_ASN1_TAG_EXTENSION   31
 

Definition at line 57 of file asn1.h.

Referenced by asn1_decode_ident().

#define SF_ASN1_TAG_GEN_STR   27
 

Definition at line 50 of file asn1.h.

#define SF_ASN1_TAG_GEN_TIME   24
 

Definition at line 55 of file asn1.h.

#define SF_ASN1_TAG_GRAPH_STR   25
 

Definition at line 48 of file asn1.h.

#define SF_ASN1_TAG_IA5_STR   22
 

Definition at line 47 of file asn1.h.

#define SF_ASN1_TAG_INT   2
 

Definition at line 27 of file asn1.h.

#define SF_ASN1_TAG_MASK   0x1f
 

Definition at line 23 of file asn1.h.

#define SF_ASN1_TAG_NULL   5
 

Definition at line 30 of file asn1.h.

#define SF_ASN1_TAG_NUM_STR   18
 

Definition at line 43 of file asn1.h.

#define SF_ASN1_TAG_OBJ_DESC   7
 

Definition at line 32 of file asn1.h.

#define SF_ASN1_TAG_OBJ_IDENT   6
 

Definition at line 31 of file asn1.h.

#define SF_ASN1_TAG_OCT_STR   4
 

Definition at line 29 of file asn1.h.

#define SF_ASN1_TAG_PRINT_STR   19
 

Definition at line 44 of file asn1.h.

#define SF_ASN1_TAG_REAL   9
 

Definition at line 34 of file asn1.h.

Referenced by DoubleOverflow().

#define SF_ASN1_TAG_REL_OBJ   13
 

Definition at line 37 of file asn1.h.

#define SF_ASN1_TAG_RSV_ENC   0
 

Definition at line 25 of file asn1.h.

#define SF_ASN1_TAG_SEQ   16
 

Definition at line 39 of file asn1.h.

#define SF_ASN1_TAG_SET   17
 

Definition at line 40 of file asn1.h.

#define SF_ASN1_TAG_T61_STR   20
 

Definition at line 45 of file asn1.h.

#define SF_ASN1_TAG_UNIV_STR   28
 

Definition at line 51 of file asn1.h.

#define SF_ASN1_TAG_UTC_TIME   23
 

Definition at line 54 of file asn1.h.

#define SF_ASN1_TAG_UTF8_STR   12
 

Definition at line 42 of file asn1.h.

#define SF_ASN1_TAG_VID_STR   21
 

Definition at line 46 of file asn1.h.

#define SF_ASN1_TAG_VIS_STR   26
 

Definition at line 49 of file asn1.h.

#define SF_BER_LEN_DEF_LONG   2
 

Definition at line 64 of file asn1.h.

Referenced by asn1_decode_len(), and asn1_decode_len_type().

#define SF_BER_LEN_DEF_SHORT   1
 

Definition at line 63 of file asn1.h.

Referenced by asn1_decode_len(), asn1_decode_len_type(), and asn1_is_eoc().

#define SF_BER_LEN_INDEF   3
 

Definition at line 65 of file asn1.h.

Referenced by asn1_decode(), asn1_decode_len(), asn1_decode_len_type(), and asn1_decode_type().

#define SF_BER_LEN_MASK   0x80
 

Definition at line 62 of file asn1.h.


Typedef Documentation

typedef struct s_ASN1_DATA ASN1_DATA
 

typedef struct s_ASN1_IDENT ASN1_IDENT
 

typedef struct s_ASN1_LEN ASN1_LEN
 

typedef struct s_ASN1_TYPE ASN1_TYPE
 


Function Documentation

int asn1_decode unsigned char *  data,
unsigned int  len,
ASN1_TYPE **  asn1_type
 

int asn1_init_mem int  iNodes  ) 
 

This function initializes the number of nodes that we want to track in an ASN.1 decode. Pass in the max number of nodes for an ASN.1 decode and we will track that many.

Returns:
integer
Return values:
ASN1_OK function successful
ASN1_ERR_MEM_ALLOC memory allocation failed
ASN1_ERR_INVALID_ARG invalid argument

Definition at line 105 of file asn1.c.

References ASN1_ERR_INVALID_ARG, ASN1_ERR_MEM_ALLOC, ASN1_OK, and g_asn1_max_nodes.

Referenced by ParseConfig(), and SnortMain().

int asn1_print_types ASN1_TYPE asn1_type,
void *  user
 

Print out the ASN.1 type.

Returns:
integer
Return values:
0 printed

Definition at line 929 of file asn1.c.

References s_ASN1_IDENT::class, s_ASN1_TYPE::data, s_ASN1_TYPE::data_len, s_ASN1_IDENT::flag, s_ASN1_TYPE::ident, s_ASN1_TYPE::len, s_ASN1_LEN::size, s_ASN1_IDENT::tag, s_ASN1_IDENT::tag_type, and s_ASN1_LEN::type.

Referenced by Asn1DetectFuncs().

int asn1_traverse ASN1_TYPE asn1,
void *  user,
int(*)(ASN1_TYPE *, void *)  DetectFunc
 

This function traverses a decoded ASN1 structure, applying a detection function for the different types. This is just to make this user stack generic AND easy.

Returns:
integer
Return values:
1 detection function successful
0 detection function unsuccessful

Definition at line 868 of file asn1.c.

References ASN1_MAX_STACK, s_ASN1_TYPE::cnext, s_ASN1_IDENT::flag, s_ASN1_TYPE::ident, index, s_ASN1_TYPE::next, and SF_ASN1_FLAG_CONSTRUCT.

Referenced by Asn1DetectFuncs(), DetectBitStringOverflow(), DetectDoubleOverflow(), and DetectOversizeLength().


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