Sourcecode and documentation for libtasn1-2 version 0.2.10-3sarge1
show bar | Show file versions
Search packages:
| Sourcecode archive home

int.h

00001 /*
00002  *      Copyright (C) 2002 Fabio Fiorina
00003  *
00004  * This file is part of LIBASN1.
00005  *
00006  * GNUTLS is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License, or
00009  * (at your option) any later version.
00010  *
00011  * GNUTLS is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
00019  */
00020 
00021 #ifndef INT_H
00022 
00023 #define INT_H
00024 
00025 #include <defines.h>
00026 
00027 /*
00028 #define LIBTASN1_DEBUG
00029 #define LIBTASN1_DEBUG_PARSER
00030 #define LIBTASN1_DEBUG_INTEGER
00031 */
00032 
00033 #include <mem.h>
00034 
00035 #define LIBTASN1_VERSION "0.2.10"
00036 
00037 #define MAX32 4294967295
00038 #define MAX24 16777215
00039 #define MAX16 65535
00040 
00041 #define MAX_LOG_SIZE 1024 /* maximum number of characters of a log message */
00042 #define MAX_NAME_SIZE 128 /* maximum number of characters of a name inside an ASN1 file definitons */
00043 #define MAX_ERROR_DESCRIPTION_SIZE 128 /* maximum number of characters of a description message */
00044 
00045 /*****************************************/
00046 /* Constants returned by asn1_read_tag   */
00047 /*****************************************/
00048 #define ASN1_CLASS_UNIVERSAL        1
00049 #define ASN1_CLASS_APPLICATION      2
00050 #define ASN1_CLASS_CONTEXT_SPECIFIC 3
00051 #define ASN1_CLASS_PRIVATE          4
00052 
00053 
00054 /*****************************************/
00055 /* Constants returned by asn1_read_tag   */
00056 /*****************************************/
00057 #define ASN1_TAG_BOOLEAN          0x01
00058 #define ASN1_TAG_INTEGER          0x02
00059 #define ASN1_TAG_SEQUENCE         0x10
00060 #define ASN1_TAG_SET              0x11
00061 #define ASN1_TAG_OCTET_STRING     0x04
00062 #define ASN1_TAG_BIT_STRING       0x03
00063 #define ASN1_TAG_UTCTime          0x17
00064 #define ASN1_TAG_GENERALIZEDTime  0x18
00065 #define ASN1_TAG_OBJECT_ID        0x06
00066 #define ASN1_TAG_ENUMERATED       0x0A
00067 #define ASN1_TAG_NULL             0x05
00068 #define ASN1_TAG_GENERALSTRING    0x1B
00069 
00070 
00071 /* define used for visiting trees */
00072 #define UP     1
00073 #define RIGHT  2
00074 #define DOWN   3
00075 
00076 
00077 typedef int asn1_retCode;  /* type returned by libasn1 functions */
00078 
00079 
00080 /******************************************************/
00081 /* Structure definition used for the node of the tree */
00082 /* that rappresent an ASN.1 DEFINITION.               */
00083 /******************************************************/
00084 typedef struct node_asn_struct{
00085   char *name;                    /* Node name */
00086   unsigned int type;             /* Node type */
00087   unsigned char *value;          /* Node value */
00088   int value_len;
00089   struct node_asn_struct *down;  /* Pointer to the son node */
00090   struct node_asn_struct *right; /* Pointer to the brother node */
00091   struct node_asn_struct *left;  /* Pointer to the next list element */ 
00092 } node_asn;
00093 
00094 typedef node_asn* ASN1_TYPE;
00095 
00096 #define ASN1_TYPE_EMPTY  NULL
00097 
00098 struct static_struct_asn{
00099   char *name;                    /* Node name */
00100   unsigned int type;             /* Node type */
00101   unsigned char *value;          /* Node value */
00102 };
00103 
00104 typedef struct static_struct_asn ASN1_ARRAY_TYPE;
00105 
00106 
00107 /****************************************/
00108 /* Returns the first 8 bits.            */
00109 /* Used with the field type of node_asn */
00110 /****************************************/
00111 #define type_field(x)     (x&0xFF) 
00112 
00113 
00114 /* List of constants for field type of typedef node_asn  */
00115 #define TYPE_CONSTANT       1
00116 #define TYPE_IDENTIFIER     2
00117 #define TYPE_INTEGER        3
00118 #define TYPE_BOOLEAN        4
00119 #define TYPE_SEQUENCE       5
00120 #define TYPE_BIT_STRING     6
00121 #define TYPE_OCTET_STRING   7
00122 #define TYPE_TAG            8
00123 #define TYPE_DEFAULT        9
00124 #define TYPE_SIZE          10
00125 #define TYPE_SEQUENCE_OF   11
00126 #define TYPE_OBJECT_ID     12
00127 #define TYPE_ANY           13
00128 #define TYPE_SET           14
00129 #define TYPE_SET_OF        15
00130 #define TYPE_DEFINITIONS   16
00131 #define TYPE_TIME          17
00132 #define TYPE_CHOICE        18
00133 #define TYPE_IMPORTS       19
00134 #define TYPE_NULL          20
00135 #define TYPE_ENUMERATED    21
00136 #define TYPE_GENERALSTRING 27
00137 
00138 
00139 /***********************************************************************/
00140 /* List of constants for specify better the type of typedef node_asn.  */
00141 /***********************************************************************/
00142 /*  Used with TYPE_TAG  */
00143 #define CONST_UNIVERSAL   (1<<8)
00144 #define CONST_PRIVATE     (1<<9)
00145 #define CONST_APPLICATION (1<<10)
00146 #define CONST_EXPLICIT    (1<<11)
00147 #define CONST_IMPLICIT    (1<<12)
00148 
00149 #define CONST_TAG         (1<<13)  /*  Used in ASN.1 assignement  */
00150 #define CONST_OPTION      (1<<14)
00151 #define CONST_DEFAULT     (1<<15)
00152 #define CONST_TRUE        (1<<16)
00153 #define CONST_FALSE       (1<<17)
00154 
00155 #define CONST_LIST        (1<<18)  /*  Used with TYPE_INTEGER and TYPE_BIT_STRING  */
00156 #define CONST_MIN_MAX     (1<<19)
00157 
00158 #define CONST_1_PARAM     (1<<20)
00159 
00160 #define CONST_SIZE        (1<<21)
00161 
00162 #define CONST_DEFINED_BY  (1<<22)
00163 
00164 #define CONST_GENERALIZED (1<<23)
00165 #define CONST_UTC         (1<<24)
00166 
00167 /* #define CONST_IMPORTS     (1<<25) */
00168 
00169 #define CONST_NOT_USED    (1<<26)
00170 #define CONST_SET         (1<<27)
00171 #define CONST_ASSIGN      (1<<28)
00172 
00173 #define CONST_DOWN        (1<<29)
00174 #define CONST_RIGHT       (1<<30)
00175 
00176 
00177 /* functions */
00178 asn1_retCode asn1_delete_structure(ASN1_TYPE *structure);
00179 
00180 asn1_retCode asn1_create_element(ASN1_TYPE definitions,const char *source_name,
00181                                  ASN1_TYPE *element);
00182 
00183 asn1_retCode asn1_read_value(ASN1_TYPE element,const char *name,
00184                        void *value,int *len);
00185 
00186 asn1_retCode
00187 asn1_expand_octet_string(ASN1_TYPE definitions,ASN1_TYPE *element,
00188                          const char *octetName,const char *objectName);
00189 
00190 asn1_retCode
00191 asn1_expand_any_defined_by(ASN1_TYPE definitions,ASN1_TYPE *element);
00192 
00193 asn1_retCode
00194 asn1_der_decoding(ASN1_TYPE *element,const void *ider,int len,
00195               char *errorDescription);
00196 
00197 
00198 #endif /* INT_H */
00199 
00200 

Generated by  Doxygen 1.5.1