diff options
Diffstat (limited to 'doc/asn1.tex')
-rw-r--r-- | doc/asn1.tex | 142 |
1 files changed, 142 insertions, 0 deletions
diff --git a/doc/asn1.tex b/doc/asn1.tex new file mode 100644 index 0000000..1ef06ed --- /dev/null +++ b/doc/asn1.tex @@ -0,0 +1,142 @@ +\documentclass{book} +\usepackage{html} +\usepackage{fancyheadings} +\usepackage{graphicx} + +\begin{document} + +\vspace*{\stretch{2}} + +\begin{center} +\par +Copyright \copyright\ 2001, 2002 Fabio Fiorina\\ +\setlength{\parskip}{4mm} +\par +Permission is granted to copy, distribute and/or modify this +document under the terms of the GNU Free Documentation License, +Version 1.1 or any later version published by the Free Software +Foundation; with no Invariant Sections, no Front-Cover Texts and +no Back-Cover Texts. A copy of the license is included in the +chapter entitled "GNU Free Documentation License". +\end{center} + +\setlength{\parindent}{2mm} + +\setlength{\parskip}{1mm} + + +\chapter{ASN.1 structures handling} + +\section{Introduction} + This file describes the forth version of ASN.1 parser I +developed. +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. + +\end{enumerate} + +\input{asn1-api} + +\input{fdl.tex} + +\end{document} |