1 \input texinfo @c -*-texinfo-*-
3 @comment %**start of header
4 @setfilename libtasn1.info
6 @settitle Libtasn1 @value{VERSION}
8 @c Unify some of the indices.
12 @comment %**end of header
14 This manual is for Libtasn1
15 (version @value{VERSION}, @value{UPDATED}),
16 which is a library for Abstract Syntax Notation One (ASN.1) and
17 Distinguish Encoding Rules (DER) manipulation.
19 Copyright @copyright{} 2004, 2006, 2007 Free Software Foundation
21 Copyright @copyright{} 2001, 2002, 2003 Fabio Fiorina
24 Permission is granted to copy, distribute and/or modify this document
25 under the terms of the GNU Free Documentation License, Version 1.2 or
26 any later version published by the Free Software Foundation; with no
27 Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A
28 copy of the license is included in the section entitled ``GNU Free
29 Documentation License''.
33 @dircategory GNU Libraries
35 * libtasn1: (libtasn1). Library for Abstract Syntax Notation One (ASN.1).
40 @subtitle Abstract Syntax Notation One (ASN.1) library for the GNU system
41 @subtitle part of the GnuTLS project
42 @subtitle for version @value{VERSION}, @value{UPDATED}
44 @author Simon Josefsson (@email{bug-gnutls@@gnu.org})
46 @vskip 0pt plus 1filll
61 * ASN.1 structure handling::
63 * Function reference::
64 * Copying Information::
68 * Concept Index:: Index of concepts and programs.
69 * Function and Data Index:: Index of functions, variables and data types.
75 Libtasn1 is library for dealing with ASN.1 and DER data.
77 The library is licensed under the GNU Lesser General Public License
78 version 2.1 (@pxref{GNU LGPL}). The command line tools, self-tests
79 and build infrastructure are licensed under the GNU General Public
80 License version 3.0 (@pxref{GNU GPL}).
83 @node ASN.1 structure handling
84 @chapter ASN.1 structure handling
86 This document describes the Libtasn1 library developed for ASN.1
87 (Abstract Syntax Notation One) structures management.
89 The main features of this library are:
93 @item On line ASN1 structure management that doesn't require any
94 C code file generation.
96 @item Off line ASN1 structure management with C code file generation
99 @item DER (Distinguish Encoding Rules) encoding.
101 @item No limits for INTEGER and ENUMERATED values.
103 @item It's Free Software.
104 Anybody can use, modify, and redistribute the library under the terms
105 of the GNU Lesser General Public License.
107 @item It's thread-safe.
109 No global variables are used and multiple library handles and session
110 handles may be used in parallel.
114 It should work on all Unix like operating systems, including Windows.
115 The library itself should be portable to any C89 system, not even
123 * Future developments::
127 @section ASN.1 syntax
131 The parser is case sensitive. The comments begin with "-- " and end at
132 the end of lines. An example is in "pkix.asn" file. ASN.1
133 definitions must have this syntax:
136 definitions_name {<object definition>}
138 DEFINITIONS <EXPLICIT or IMPLICIT> TAGS ::=
142 <type and constants definitions>
147 The token "::=" must be separate from others elements, so this is a
161 Here is the list of types that the parser can manage:
163 @cindex Supported ASN.1 types, list of
170 @item OBJECT IDENTIFIER
175 @item GeneralizedTime
187 This version doesn't manage REAL type. It doesn't allow the "EXPORT"
188 and "IMPORT" sections too.
190 The SIZE constraints are allowed, but no check is done on them.
195 Consider this definition:
200 DEFINITIONS EXPLICIT TAGS ::=
205 id OBJECT IDENTIFIER,
217 To identify the type 'Group' you have to use the null terminated
218 string "Example.Group". These strings are used in functions that are
223 Field 'id' in 'Group' type : "Example.Group.id".
225 Field 'value1' in field 'value' in type 'Group':
226 "Example.Group.value.value1".
228 Elements of structured types that don't have a name, receive the name
229 "?1","?2", and so on.
231 The name "?LAST" indicates the last element of a @code{SET_OF} or
235 @section Library Notes
237 @cindex Header file libtasn1.h
239 The header file of this library is @file{libtasn1.h}.
241 @cindex Main type ASN1_TYPE
243 The main type used in it is @code{ASN1_TYPE}, and it's used to store
244 the @acronym{ASN.1} definitions and structures (instances).
246 The constant @acronym{ASN1_TYPE_EMPTY} can be used for the variable
247 initialization. For example:
250 ASN1_TYPE definitions=ASN1_TYPE_EMPTY;
253 Some functions require a parameter named errorDescription of char*
254 type. The array must be already allocated and must have at least
255 @code{MAX_ERROR_DESCRIPTION_SIZE} bytes (E.g, as in @code{char
256 Description[MAX_ERROR_DESCRIPTION_SIZE];}).
258 @code{MAX_NAME_SIZE} indicates the maximum number of characters of a
259 name inside a file with ASN1 definitions.
261 @node Future developments
262 @section Future developments
263 @cindex Future developments
267 @item Add functions for a C code file generation containing equivalent
268 data structures (not a single array like now).
278 * Invoking asn1Parser::
279 * Invoking asn1Coding::
280 * Invoking asn1Decoding::
283 @node Invoking asn1Parser
284 @section Invoking asn1Parser
285 @cindex asn1Parser program
287 @file{asn1Parser} reads one file with ASN1 definitions and generates a
288 file with an array to use with libtasn1 functions.
291 Usage: asn1Parser [options] file
294 -h : shows the help message.
295 -v : shows version information and exit.
296 -c : checks the syntax only.
297 -o file : output file.
298 -n name : array name.
301 @node Invoking asn1Coding
302 @section Invoking asn1Coding
303 @cindex asn1Coding program
305 @file{asn1Coding} generates a DER encoding from a file with ASN1
306 definitions and another one with assignments.
308 The file with assignments must have this syntax:
311 InstanceName Asn1Definition
319 The output file is a binary file with the DER encoding.
322 Usage: asn1Coding [options] file1 file2
323 file1 : file with ASN1 definitions.
324 file2 : file with assignments.
326 -h : shows the help message.
327 -v : shows version information and exit.
328 -c : checks the syntax only.
329 -o file : output file.
332 @node Invoking asn1Decoding
333 @section Invoking asn1Decoding
334 @cindex asn1Decoding program
336 @file{asn1Decoding} generates an ASN1 structure from a file with ASN1
337 definitions and a binary file with a DER encoding.
340 Usage: asn1Decoding [options] file1 file2 type
341 file1 : file with ASN1 definitions.
342 file2 : binary file with a DER encoding.
343 type : ASN1 definition name.
345 -h : shows the help message.
346 -v : shows version information and exit.
347 -c : checks the syntax only.
348 -o file : output file.
351 @node Function reference
352 @chapter Function reference
355 * ASN.1 schema functions::
356 * ASN.1 field functions::
358 * Error handling functions::
359 * Auxilliary functions::
362 @node ASN.1 schema functions
363 @section ASN.1 schema functions
365 @include texi/ASN1.c.texi
367 @node ASN.1 field functions
368 @section ASN.1 field functions
370 @include texi/structure.c.texi
371 @include texi/element.c.texi
374 @section DER functions
376 @include texi/coding.c.texi
377 @include texi/decoding.c.texi
379 @node Error handling functions
380 @section Error handling functions
382 @include texi/errors.c.texi
384 @node Auxilliary functions
385 @section Auxilliary functions
387 @include texi/parser_aux.c.texi
389 @node Copying Information
390 @appendix Copying Information
393 * GNU Free Documentation License:: License for copying this manual.
394 * GNU LGPL:: License for copying the core GnuTLS library.
395 * GNU GPL:: License for copying GNUTLS extra and tools.
398 @node GNU Free Documentation License
399 @appendixsec GNU Free Documentation License
401 @cindex FDL, GNU Free Documentation License
406 @appendixsec GNU Lesser General Public License
407 @cindex LGPL, GNU Lesser General Public License
408 @cindex License, GNU LGPL
410 @include lgpl-2.1.texi
413 @appendixsec GNU General Public License
414 @cindex GPL, GNU General Public License
415 @cindex License, GNU GPL
417 @include gpl-3.0.texi
420 @unnumbered Concept Index
424 @node Function and Data Index
425 @unnumbered Function and Data Index