summaryrefslogtreecommitdiff
path: root/doc/tex/asn1.tex
blob: d0014dbce09d388f6755b7a4e08e6f869fe65a24 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
\chapter{ASN.1 Structure Handling}


\section{Introduction}
 This file describes the forth version of ASN.1 parser I
developed\footnote{ASN.1 Structure handling in \gnutls is developed by Fabio
Fiorina}.
The main difference from the first version is the use of pointers and the
possibility to save/get ASN1 definitions in/from a C vector.
Other differences are:
\begin{itemize}
\item write\_value function for type ANY
\item the introduction of ENUMERATED type,
\item negative integer are allowed in ASN.1 syntax files,
\item PKIX1Implicit88.txt instead of Certificate.txt for the Certificate description
\item functions naming 
\item an easier way to set INTEGER and get OBJECT IDENTFIER  
\end{itemize}


\section{ASN.1 Syntax}
The parser is case sensitive. The comments begin with "-- " and end at the end of line.
An example is in "Certificate.txt" file.
The ASN.1 declarations must have this form:
      
\begin{verbatim}
      object_name {<object definition>}

      DEFINITIONS <EXPLICIT or IMPLICIT> TAGS ::=

      BEGIN 

      <type and constants definitions>

      END
\end{verbatim}

\par
The token "::=" must be separate from others elements, so this is a wrong declaration:
      Version ::=INTEGER 
the correct one is :   Version ::= INTEGER
Here is the list of types that the parser can manage:
\begin{itemize}

\item      INTEGER
\item      ENUMERATED
\item      BOOLEAN
\item      OBJECT IDENTIFIER
\item      NULL
\item      BIT STRING
\item      OCTET STRING
\item      UTCTime
\item      GeneralizedTime
\item      SEQUENCE
\item      SEQUENCE OF
\item      SET 
\item      SET OF
\item      CHOICE
\item      ANY
\item      ANY DEFINED BY
\end{itemize}

This version doesn't manage REAL type. It also not allow the use of 
"EXPORT" and "IMPORT" sections.

The SIZE constraints are allowed but no check is done on them.



\section{Naming}
If you have this definitions:

\begin{verbatim}
      Example { 1 2 3 4 }

      DEFINITIONS EXPLICIT TAGS ::=

      BEGIN 

      Group ::= SEQUENCE {
         id   OBJECT IDENTIFIER,
         value  Value
      }

      Value ::= SEQUENCE {
         value1  INTEGER,
         value2  BOOLEAN 
      }

      END
\end{verbatim}

to identify the type 'Group' you have to use the null terminated string "Example.Group".
Others examples:
Field 'id' in 'Group' type :  "Example.Group.id"
Field 'value1' in filed 'value' in type 'Group':   "Example.Group.value.value1" 
These strings are used in functions that are described below.
Elements of structured types that don't have a name, receve the name "?1","?2", and so on. 
The name "?LAST" indicates the last element of a SET\_OF or SEQUENCE\_OF.

\section{Future Developments}
\begin{enumerate}
\item type REAL 
\item improve the error signaling with strings that give you more details. 
   Examples: in case of ASN1 syntax error you will have the line number where the error is,  
             if creating a der encoding the result is ASN\_VALUE\_NOT\_FOUND you will have the
             name of the element without the value.
\item improve the 'visit\_tree' function and change the output from stdout to a null terminated 
   string.  

\input{asn1-api}

\end{enumerate}