Add getdate stuff.
[shishi.git] / asn1 / int.h
blob9aa0543d0be60d76474993f110d86a7ebef4f863
1 /*
2 * Copyright (C) 2002 Fabio Fiorina
4 * This file is part of LIBASN1.
6 * GNUTLS is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * GNUTLS is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
21 #ifndef INT_H
23 #define INT_H
25 #include <defines.h>
28 #define LIBTASN1_DEBUG
29 #define LIBTASN1_DEBUG_PARSER
30 #define LIBTASN1_DEBUG_INTEGER
33 #include <mem.h>
35 #define LIBTASN1_VERSION "0.2.5"
37 #define MAX32 4294967295
38 #define MAX24 16777215
39 #define MAX16 65535
41 #define MAX_LOG_SIZE 1024 /* maximum number of characters of a log message */
42 #define MAX_NAME_SIZE 128 /* maximum number of characters of a name inside an ASN1 file definitons */
43 #define MAX_ERROR_DESCRIPTION_SIZE 128 /* maximum number of characters of a description message */
45 /*****************************************/
46 /* Constants returned by asn1_read_tag */
47 /*****************************************/
48 #define ASN1_CLASS_UNIVERSAL 1
49 #define ASN1_CLASS_APPLICATION 2
50 #define ASN1_CLASS_CONTEXT_SPECIFIC 3
51 #define ASN1_CLASS_PRIVATE 4
54 /*****************************************/
55 /* Constants returned by asn1_read_tag */
56 /*****************************************/
57 #define ASN1_TAG_BOOLEAN 0x01
58 #define ASN1_TAG_INTEGER 0x02
59 #define ASN1_TAG_SEQUENCE 0x10
60 #define ASN1_TAG_SET 0x11
61 #define ASN1_TAG_OCTET_STRING 0x04
62 #define ASN1_TAG_BIT_STRING 0x03
63 #define ASN1_TAG_UTCTime 0x17
64 #define ASN1_TAG_GENERALIZEDTime 0x18
65 #define ASN1_TAG_OBJECT_ID 0x06
66 #define ASN1_TAG_ENUMERATED 0x0A
67 #define ASN1_TAG_NULL 0x05
68 #define ASN1_TAG_GENERALSTRING 0x1B
71 /* define used for visiting trees */
72 #define UP 1
73 #define RIGHT 2
74 #define DOWN 3
77 typedef int asn1_retCode; /* type returned by libasn1 functions */
80 /******************************************************/
81 /* Structure definition used for the node of the tree */
82 /* that rappresent an ASN.1 DEFINITION. */
83 /******************************************************/
84 typedef struct node_asn_struct{
85 char *name; /* Node name */
86 unsigned int type; /* Node type */
87 unsigned char *value; /* Node value */
88 struct node_asn_struct *down; /* Pointer to the son node */
89 struct node_asn_struct *right; /* Pointer to the brother node */
90 struct node_asn_struct *left; /* Pointer to the next list element */
91 } node_asn;
93 typedef node_asn* ASN1_TYPE;
95 #define ASN1_TYPE_EMPTY NULL
97 struct static_struct_asn{
98 char *name; /* Node name */
99 unsigned int type; /* Node type */
100 unsigned char *value; /* Node value */
103 typedef struct static_struct_asn ASN1_ARRAY_TYPE;
106 /****************************************/
107 /* Returns the first 8 bits. */
108 /* Used with the field type of node_asn */
109 /****************************************/
110 #define type_field(x) (x&0xFF)
113 /* List of constants for field type of typedef node_asn */
114 #define TYPE_CONSTANT 1
115 #define TYPE_IDENTIFIER 2
116 #define TYPE_INTEGER 3
117 #define TYPE_BOOLEAN 4
118 #define TYPE_SEQUENCE 5
119 #define TYPE_BIT_STRING 6
120 #define TYPE_OCTET_STRING 7
121 #define TYPE_TAG 8
122 #define TYPE_DEFAULT 9
123 #define TYPE_SIZE 10
124 #define TYPE_SEQUENCE_OF 11
125 #define TYPE_OBJECT_ID 12
126 #define TYPE_ANY 13
127 #define TYPE_SET 14
128 #define TYPE_SET_OF 15
129 #define TYPE_DEFINITIONS 16
130 #define TYPE_TIME 17
131 #define TYPE_CHOICE 18
132 #define TYPE_IMPORTS 19
133 #define TYPE_NULL 20
134 #define TYPE_ENUMERATED 21
135 #define TYPE_GENERALSTRING 27
138 /***********************************************************************/
139 /* List of constants for specify better the type of typedef node_asn. */
140 /***********************************************************************/
141 /* Used with TYPE_TAG */
142 #define CONST_UNIVERSAL (1<<8)
143 #define CONST_PRIVATE (1<<9)
144 #define CONST_APPLICATION (1<<10)
145 #define CONST_EXPLICIT (1<<11)
146 #define CONST_IMPLICIT (1<<12)
148 #define CONST_TAG (1<<13) /* Used in ASN.1 assignement */
149 #define CONST_OPTION (1<<14)
150 #define CONST_DEFAULT (1<<15)
151 #define CONST_TRUE (1<<16)
152 #define CONST_FALSE (1<<17)
154 #define CONST_LIST (1<<18) /* Used with TYPE_INTEGER and TYPE_BIT_STRING */
155 #define CONST_MIN_MAX (1<<19)
157 #define CONST_1_PARAM (1<<20)
159 #define CONST_SIZE (1<<21)
161 #define CONST_DEFINED_BY (1<<22)
163 #define CONST_GENERALIZED (1<<23)
164 #define CONST_UTC (1<<24)
166 /* #define CONST_IMPORTS (1<<25) */
168 #define CONST_NOT_USED (1<<26)
169 #define CONST_SET (1<<27)
170 #define CONST_ASSIGN (1<<28)
172 #define CONST_DOWN (1<<29)
173 #define CONST_RIGHT (1<<30)
176 /* functions */
177 asn1_retCode asn1_delete_structure(ASN1_TYPE *structure);
179 asn1_retCode asn1_create_element(ASN1_TYPE definitions,const char *source_name,
180 ASN1_TYPE *element);
182 asn1_retCode asn1_read_value(ASN1_TYPE element,const char *name,
183 unsigned char *value,int *len);
185 asn1_retCode
186 asn1_expand_octet_string(ASN1_TYPE definitions,ASN1_TYPE *element,
187 const char *octetName,const char *objectName);
189 asn1_retCode
190 asn1_expand_any_defined_by(ASN1_TYPE definitions,ASN1_TYPE *element);
192 asn1_retCode
193 asn1_der_decoding(ASN1_TYPE *element,const unsigned char *der,int len,
194 char *errorDescription);
197 #endif /* INT_H */