\begin{center}
\par
-Copyright \copyright\ 2001, 2002 Fabio Fiorina\\
+Copyright \copyright\ 2001, 2002, 2003 Fabio Fiorina\\
\setlength{\parskip}{4mm}
\par
Permission is granted to copy, distribute and/or modify this
\chapter{ASN.1 structures handling}
\section{Introduction}
- This document describes the first version of library 'libasn1' developed
+ This document describes the version 0.2.0 of library 'libtasn1' developed
for ASN1 (Abstract Syntax Notation One) structures management.
The main features of this library are:
\begin{itemize}
\item OCTET STRING
\item UTCTime
\item GeneralizedTime
+\item GeneralString
\item SEQUENCE
\item SEQUENCE OF
\item SET
The name "?LAST" indicates the last element of a SET\_OF or SEQUENCE\_OF.
\section{Library Notes}
-The header file of this library is libasn1.h .
+The header file of this library is libtasn1.h .
The main type used in it is ASN1\_TYPE, and it's used to
store the ASN1 definitions and structures (instances).
-The constant ASN1\_TYPE\_EMPTY must be used for the variable initialization.
+The constant ASN1\_TYPE\_EMPTY can be used for the variable initialization.
\par
Example: ASN1\_TYPE definitions=ASN1\_TYPE\_EMPTY;
\par
+
+
+
+
+
* \item SET OF\: the same as SEQUENCE OF.
* Using "pkix.asn":
*
- * result=asn1_write_value(cert,"certificate1.tbsCertificate.subject.rdnSequence.?LAST","NEW",1);
+ * result=asn1_write_value(cert,"tbsCertificate.subject.rdnSequence.?LAST","NEW",1);
*\end{itemize}
*
* If an element is OPTIONAL and you want to delete it, you must use the value=NULL and len=0.
*
* Using "pkix.asn"\:
*
- * result=asn1_write_value(cert,"certificate1.tbsCertificate.issuerUniqueID",NULL,0);
+ * result=asn1_write_value(cert,"tbsCertificate.issuerUniqueID",NULL,0);
*
**/
asn1_retCode
* ASN1_ELEMENT_NOT_FOUND\: SOURCE_NAME isn't known
*
* Example: using "pkix.asn"
- * result=asn1_create_structure(cert_def,"PKIX1.Certificate",&cert,"certificate1");
+ * result=asn1_create_structure(cert_def,"PKIX1.Certificate",&cert);
**/
asn1_retCode
asn1_create_element(ASN1_TYPE definitions,const char *source_name,
node_asn *dest_node;
int res;
- if(*element!=ASN1_TYPE_EMPTY){
- asn1_delete_structure(element);
- }
-
dest_node=_asn1_copy_structure2(definitions,source_name);
if(dest_node==NULL) return ASN1_ELEMENT_NOT_FOUND;
-Sequence Test.Sequence1
+TEST Test.Sequence1
-Sequence.int1 10
-Sequence.int2 -10
+int1 10
+int2 -10
{0}
};
-char
+int
readLine(FILE *file,char *line)
{
- char c;
+ int c;
while(((c=fgetc(file))!=EOF) && (c!='\n')){
*line=c;
oct OCTET STRING
}
+DHParameter ::= SEQUENCE {
+ prime INTEGER,
+ base INTEGER,
+ privateValueLength INTEGER OPTIONAL
+}
+
+
id-octetTest1 OBJECT IDENTIFIER ::= {1 2 3 4}
Sequence_octetTest1 ::= SEQUENCE{
{ACT_DELETE,"","",0,ASN1_ELEMENT_NOT_FOUND},
/* Test: Integer */
+ {ACT_CREATE,"TEST_TREE.DHParameter",0,0,ASN1_SUCCESS},
+ {ACT_WRITE,"prime","1",0,ASN1_SUCCESS},
+ {ACT_WRITE,"base","2",0,ASN1_SUCCESS},
+ {ACT_WRITE,"privateValueLength",NULL,0,ASN1_SUCCESS},
+ {ACT_VISIT,"","",ASN1_PRINT_ALL,ASN1_SUCCESS},
+ {ACT_ENCODING,"",0,0,ASN1_SUCCESS},
+ {ACT_PRINT_DER,0,0,0,ASN1_SUCCESS},
+ {ACT_DELETE,"","",0,ASN1_SUCCESS},
+ {ACT_CREATE,"TEST_TREE.DHParameter",0,0,ASN1_SUCCESS},
+ {ACT_DECODING,0,0,0,ASN1_SUCCESS},
+ {ACT_VISIT,"","",ASN1_PRINT_ALL,ASN1_SUCCESS},
+ {ACT_DELETE,"","",0,ASN1_SUCCESS},
+
+ /* Test: Integer */
{ACT_CREATE,"TEST_TREE.AnyTest2",0,0,ASN1_SUCCESS},
{ACT_WRITE,"","int",0,ASN1_SUCCESS},
{ACT_WRITE,"int","0",0,ASN1_SUCCESS},