change asn1_create_element interface
authorFabio Fiorina <fiorinaf@gnutls.org>
Wed, 5 Feb 2003 19:50:48 +0000 (19:50 +0000)
committerFabio Fiorina <fiorinaf@gnutls.org>
Wed, 5 Feb 2003 19:50:48 +0000 (19:50 +0000)
doc/asn1.tex
lib/element.c
lib/structure.c
src/asn1Coding_test.asg
tests/Test_parser.c
tests/Test_tree.asn
tests/Test_tree.c

index 8e6839d..937d453 100644 (file)
@@ -19,7 +19,7 @@ This is part of the GnuTLS project\\
 
 \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
@@ -39,7 +39,7 @@ chapter entitled "GNU Free Documentation License".
 \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}
@@ -85,6 +85,7 @@ Here is the list of types that the parser can manage:
 \item      OCTET STRING
 \item      UTCTime
 \item      GeneralizedTime
+\item      GeneralString
 \item      SEQUENCE
 \item      SEQUENCE OF
 \item      SET 
@@ -133,10 +134,10 @@ Elements of structured types that don't have a name, receive the name "?1","?2",
 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 
@@ -234,3 +235,8 @@ Options:
 
 
 
+
+
+
+
+
index 37a3272..9a4b6fb 100644 (file)
@@ -232,14 +232,14 @@ _asn1_append_sequence_set(node_asn *node)
   * \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 
index e187ef0..5a6e612 100644 (file)
@@ -533,7 +533,7 @@ _asn1_expand_identifier(node_asn **node,node_asn *root)
   *  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,
@@ -542,10 +542,6 @@ 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;
index 6f594e0..b0f9495 100644 (file)
@@ -1,6 +1,6 @@
 
 
-Sequence         Test.Sequence1
+TEST    Test.Sequence1
 
-Sequence.int1    10
-Sequence.int2    -10
+int1    10
+int2    -10
index 31755c6..87c1ee2 100644 (file)
@@ -89,10 +89,10 @@ test_type test_array[]={
   {0}
 };
 
-char
+int
 readLine(FILE *file,char *line)
 {
-  char c;
+  int c;
 
   while(((c=fgetc(file))!=EOF) && (c!='\n')){
     *line=c;
index 657090c..4e3db3f 100644 (file)
@@ -17,6 +17,13 @@ Sequence1 ::= SEQUENCE{
     oct      OCTET STRING
 }
 
+DHParameter ::= SEQUENCE {
+    prime INTEGER,
+    base  INTEGER,
+    privateValueLength INTEGER OPTIONAL
+}
+
+
 id-octetTest1 OBJECT IDENTIFIER  ::=  {1 2 3 4}
 
 Sequence_octetTest1 ::= SEQUENCE{
index bfd58c8..cd01222 100644 (file)
@@ -64,6 +64,20 @@ test_type test_array[]={
   {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},