*** empty log message ***
[gnutls.git] / lib / x509_asn1.h
blob2890b9dd8109acc6a356aa501b2933526fe908fb
2 /*************************************************/
3 /* File: x509_asn1.h */
4 /* Description: list of exported object by */
5 /* "x509_asn1.c" */
6 /*************************************************/
8 #ifndef _GNUTLS_ASN1_H
9 #define _GNUTLS_ASN1_H
11 #define PARSE_MODE_CHECK 1
12 #define PARSE_MODE_CREATE 2
14 /* List of constants for field type of typedef node_asn */
15 #define TYPE_CONSTANT 1
16 #define TYPE_IDENTIFIER 2
17 #define TYPE_INTEGER 3
18 #define TYPE_BOOLEAN 4
19 #define TYPE_SEQUENCE 5
20 #define TYPE_BIT_STRING 6
21 #define TYPE_OCTET_STRING 7
22 #define TYPE_TAG 8
23 #define TYPE_DEFAULT 9
24 #define TYPE_SIZE 10
25 #define TYPE_SEQUENCE_OF 11
26 #define TYPE_OBJECT_ID 12
27 #define TYPE_ANY 13
28 #define TYPE_SET 14
29 #define TYPE_SET_OF 15
30 #define TYPE_DEFINITIONS 16
31 #define TYPE_TIME 17
32 #define TYPE_CHOICE 18
33 #define TYPE_IMPORTS 19
34 #define TYPE_NULL 20
35 #define TYPE_ENUMERATED 21
38 /***********************************************************************/
39 /* List of constants for specify better the type of typedef node_asn. */
40 /***********************************************************************/
41 /* Used with TYPE_TAG */
42 #define CONST_UNIVERSAL (1<<8)
43 #define CONST_PRIVATE (1<<9)
44 #define CONST_APPLICATION (1<<10)
45 #define CONST_EXPLICIT (1<<11)
46 #define CONST_IMPLICIT (1<<12)
48 #define CONST_TAG (1<<13) /* Used in ASN.1 assignement */
49 #define CONST_OPTION (1<<14)
50 #define CONST_DEFAULT (1<<15)
51 #define CONST_TRUE (1<<16)
52 #define CONST_FALSE (1<<17)
54 #define CONST_LIST (1<<18) /* Used with TYPE_INTEGER and TYPE_BIT_STRING */
55 #define CONST_MIN_MAX (1<<19)
57 #define CONST_1_PARAM (1<<20)
59 #define CONST_SIZE (1<<21)
61 #define CONST_DEFINED_BY (1<<22)
63 #define CONST_GENERALIZED (1<<23)
64 #define CONST_UTC (1<<24)
66 #define CONST_IMPORTS (1<<25)
68 #define CONST_NOT_USED (1<<26)
69 #define CONST_SET (1<<27)
70 #define CONST_ASSIGN (1<<28)
72 #define CONST_DOWN (1<<29)
73 #define CONST_RIGHT (1<<30)
76 #define ASN_OK 0
77 #define ASN_FILE_NOT_FOUND 1
78 #define ASN_ELEMENT_NOT_FOUND 2
79 #define ASN_IDENTIFIER_NOT_FOUND 3
80 #define ASN_DER_ERROR 4
81 #define ASN_VALUE_NOT_FOUND 5
82 #define ASN_GENERIC_ERROR 6
83 #define ASN_VALUE_NOT_VALID 7
84 #define ASN_TAG_ERROR 8
85 #define ASN_TAG_IMPLICIT 9
86 #define ASN_ERROR_TYPE_ANY 10
87 #define ASN_SYNTAX_ERROR 11
88 #define ASN_MEM_ERROR 12
89 #define ASN_DER_OVERFLOW 13
92 /******************************************************/
93 /* Structure definition used for the node of the tree */
94 /* that rappresent an ASN.1 DEFINITION. */
95 /******************************************************/
96 typedef struct node_asn_struct{
97 char *name; /* Node name */
98 unsigned int type; /* Node type */
99 unsigned char *value; /* Node value */
100 struct node_asn_struct *down; /* Pointer to the son node */
101 struct node_asn_struct *right; /* Pointer to the brother node */
102 struct node_asn_struct *left; /* Pointer to the next list element */
103 } node_asn;
107 typedef struct static_struct_asn{
108 char *name; /* Node name */
109 unsigned int type; /* Node type */
110 unsigned char *value; /* Node value */
111 } static_asn;
114 /****************************************/
115 /* Returns the first 8 bits. */
116 /* Used with the field type of node_asn */
117 /****************************************/
118 #define type_field(x) (x&0xFF)
121 /***************************************/
122 /* Functions used by ASN.1 parser */
123 /***************************************/
124 node_asn *
125 _asn1_add_node(unsigned int type);
127 node_asn *
128 _asn1_set_value(node_asn *node,unsigned char *value,unsigned int len);
130 node_asn *
131 _asn1_set_name(node_asn *node,char *name);
133 node_asn *
134 _asn1_set_right(node_asn *node,node_asn *right);
136 node_asn *
137 _asn1_get_right(node_asn *node);
139 node_asn *
140 _asn1_get_last_right(node_asn *node);
142 node_asn *
143 _asn1_set_down(node_asn *node,node_asn *down);
145 char *
146 _asn1_get_name(node_asn *node);
148 node_asn *
149 _asn1_get_down(node_asn *node);
151 node_asn *
152 _asn1_mod_type(node_asn *node,unsigned int value);
154 void
155 _asn1_append_tree(node_asn *node);
157 node_asn *
158 _asn1_find_node(node_asn *pointer,char *name);
160 node_asn *
161 _asn1_find_up(node_asn *node);
163 int
164 _asn1_append_sequence_set(node_asn *node);
166 int
167 _asn1_delete_not_used(node_asn *node);
169 int
170 _asn1_set_default_tag(node_asn *node);
172 /* prototypes - not defined elsewere */
173 int _asn1_change_integer_value(node_asn *node);
174 int _asn1_expand_object_id(node_asn *node);
175 int _asn1_expand_identifier(node_asn **node,node_asn *root);
176 int _asn1_type_choice_config(node_asn *node);
177 int _asn1_type_set_config(node_asn *node);
178 int _asn1_check_identifier(node_asn *node);
179 int _asn1_create_static_structure(node_asn *pointer,char *file_name, char* out_name);
181 int
182 asn1_parser_asn1(char *file_name,node_asn **pointer);
185 asn1_create_structure(node_asn *root,char *source_name,node_asn **pointer,
186 char *dest_name);
189 asn1_delete_structure(node_asn *root);
191 int
192 asn1_write_value(node_asn *root,char *name,unsigned char *value,int len);
194 int
195 asn1_read_value(node_asn *root,char *name,unsigned char *value,int *len);
198 asn1_create_tree(const static_asn *root,node_asn **pointer);
200 int
201 asn1_number_of_elements(node_asn *root,char *name,int *num);
203 #endif