shishi-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[SCM] GNU shishi branch, master, updated. shishi-1-0-1-46-g5d0d262


From: Simon Josefsson
Subject: [SCM] GNU shishi branch, master, updated. shishi-1-0-1-46-g5d0d262
Date: Wed, 03 Apr 2013 08:58:07 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU shishi".

http://git.savannah.gnu.org/cgit/shishi.git/commit/?id=5d0d26294d97ea1cc18cc0bc70e1c8f0538678bb

The branch, master has been updated
       via  5d0d26294d97ea1cc18cc0bc70e1c8f0538678bb (commit)
       via  4523ebcfbc33fec175ce3e30fc64869f08b670d5 (commit)
      from  12ad39b366190d73cd46a7991c6ff79b22ef1246 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 5d0d26294d97ea1cc18cc0bc70e1c8f0538678bb
Author: Simon Josefsson <address@hidden>
Date:   Wed Apr 3 10:56:12 2013 +0200

    Drop AC_COPYRIGHT, it is just one more place to keep updated.

commit 4523ebcfbc33fec175ce3e30fc64869f08b670d5
Author: Simon Josefsson <address@hidden>
Date:   Wed Apr 3 10:44:49 2013 +0200

    Drop internal minitasn1 copy.

-----------------------------------------------------------------------

Summary of changes:
 Makefile.am       |   11 +-
 NEWS              |    4 +-
 README            |    5 +-
 README-alpha      |    2 +-
 asn1/Makefile.am  |   28 -
 asn1/README       |   14 -
 asn1/coding.c     | 1225 ----------------------
 asn1/decoding.c   | 2904 -----------------------------------------------------
 asn1/element.c    |  978 ------------------
 asn1/element.h    |   34 -
 asn1/errors.c     |  143 ---
 asn1/errors.h     |   30 -
 asn1/gstr.c       |   68 --
 asn1/gstr.h       |   26 -
 asn1/int.h        |  147 ---
 asn1/libtasn1.h   |  317 ------
 asn1/parser_aux.c | 1098 --------------------
 asn1/parser_aux.h |   79 --
 asn1/structure.c  | 1195 ----------------------
 asn1/structure.h  |   41 -
 asn1/version.c    |   51 -
 configure.ac      |   27 +-
 22 files changed, 11 insertions(+), 8416 deletions(-)
 delete mode 100644 asn1/Makefile.am
 delete mode 100644 asn1/README
 delete mode 100644 asn1/coding.c
 delete mode 100644 asn1/decoding.c
 delete mode 100644 asn1/element.c
 delete mode 100644 asn1/element.h
 delete mode 100644 asn1/errors.c
 delete mode 100644 asn1/errors.h
 delete mode 100644 asn1/gstr.c
 delete mode 100644 asn1/gstr.h
 delete mode 100644 asn1/int.h
 delete mode 100644 asn1/libtasn1.h
 delete mode 100644 asn1/parser_aux.c
 delete mode 100644 asn1/parser_aux.h
 delete mode 100644 asn1/structure.c
 delete mode 100644 asn1/structure.h
 delete mode 100644 asn1/version.c

diff --git a/Makefile.am b/Makefile.am
index ca4f283..deb77d1 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -18,18 +18,11 @@
 # to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
 # Floor, Boston, MA 02110-1301, USA.
 
-DISTCHECK_CONFIGURE_FLAGS = --enable-gtk-doc \
-       --without-system-asn1 --without-libgcrypt
+DISTCHECK_CONFIGURE_FLAGS = --enable-gtk-doc --without-libgcrypt
 
 EXTRA_DIST = cfg.mk maint.mk .clcopying
 
-SUBDIRS = po gl
-
-if ASN1
-SUBDIRS += asn1
-endif
-
-SUBDIRS += lib db src tests doc extra examples
+SUBDIRS = po gl lib db src tests doc extra examples
 
 ACLOCAL_AMFLAGS = -I m4 -I gl/m4 -I src/gl/m4 -I db/gl/m4
 
diff --git a/NEWS b/NEWS
index 7d96ea9..3a187b3 100644
--- a/NEWS
+++ b/NEWS
@@ -24,7 +24,9 @@ Patch by Mats Erik Andersson <address@hidden>.
 ** shishid: The syslog facility is now LOG_AUTH instead of LOG_DAEMON.
 Suggested by Mats Erik Andersson <address@hidden>.
 
-** minitasn1: Internal copy upgraded to GNU Libtasn1 v2.13.
+** minitasn1: Removed.  You must use an external installed libtasn1.
+With recent libtasn1 it is no longer trivial to build libtasn1 as
+copied source code files.
 
 ** Update gnulib files and various other fixes.
 
diff --git a/README b/README
index ea57ec8..26b62d1 100644
--- a/README
+++ b/README
@@ -13,9 +13,8 @@ licensed under the GNU General Public License license version 
3 or
 later (see COPYING), and the documentation (doc/) is licensed under
 the GNU Free Documentation License version 1.3 or later.
 
-Third party packages (asn1/ and gl/) are distributed here for
-convenience, and they have their own respective licenses, typically
-the GPL or the LGPL.
+Third party files (e.g., gl/) are distributed here for convenience,
+and they have their own respective licenses, typically the (L)GPL.
 
 For updates to the project, see <http://www.gnu.org/software/shishi/>.
 
diff --git a/README-alpha b/README-alpha
index c019df3..6e0292f 100644
--- a/README-alpha
+++ b/README-alpha
@@ -25,7 +25,7 @@ We require several tools to build the software, including:
 - Perl <http://www.cpan.org/>
 - Valgrind <http://valgrind.org/> (optional)
 - libgcrypt <http://www.gnupg.org/>
-- libtasn1 <http://josefsson.org/libtasn1/> (optional)
+- libtasn1 <http://www.gnu.org/software/libtasn1/>
 - libidn <http://www.gnu.org/software/libidn/> (optional)
 - GnuTLS <http://www.gnu.org/software/gnutls/> (for TLS support)
 - PAM <http://www.gnu.org/software/gnutls/> (for pam-shishi)
diff --git a/asn1/Makefile.am b/asn1/Makefile.am
deleted file mode 100644
index 6c71248..0000000
--- a/asn1/Makefile.am
+++ /dev/null
@@ -1,28 +0,0 @@
-## Process this file with automake to produce Makefile.in
-# Copyright (C) 2002-2013 Simon Josefsson.
-#
-# This file is part of Shishi.
-#
-# Shishi is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3 of the License, or
-# (at your option) any later version.
-#
-# Shishi is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-# General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Shishi; if not, see http://www.gnu.org/licenses or write
-# to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
-# Floor, Boston, MA 02110-1301, USA.
-
-AM_CPPFLAGS = -DASN1_BUILDING -I$(srcdir)/../gl -I$(builddir)/../gl
-
-EXTRA_DIST = README
-
-noinst_LTLIBRARIES = libminitasn1.la
-libminitasn1_la_SOURCES = libtasn1.h gstr.h errors.h int.h             \
-       parser_aux.h structure.h element.h decoding.c gstr.c errors.c   \
-       parser_aux.c structure.c element.c coding.c version.c
diff --git a/asn1/README b/asn1/README
deleted file mode 100644
index 643e400..0000000
--- a/asn1/README
+++ /dev/null
@@ -1,14 +0,0 @@
-Shishi asn1/README -- Information about the ASN.1 library.
-Copyright (C) 2003-2013 Simon Josefsson
-See the end for copying conditions.
-
-This directory contains a copy of most of the files in the lib/
-directory of the GNUTLS ASN.1 library "libtasn1".
-
-If you notice any discrepencies between the copy in Shishi and the
-upstream version, please let me know, it is most likely an oversight.
-
-----------------------------------------------------------------------
-Copying and distribution of this file, with or without modification,
-are permitted in any medium without royalty provided the copyright
-notice and this notice are preserved.
diff --git a/asn1/coding.c b/asn1/coding.c
deleted file mode 100644
index 307dd40..0000000
--- a/asn1/coding.c
+++ /dev/null
@@ -1,1225 +0,0 @@
-/*
- * Copyright (C) 2002-2012 Free Software Foundation, Inc.
- *
- * This file is part of LIBTASN1.
- *
- * The LIBTASN1 library is free software; you can redistribute it
- * and/or modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA
- */
-
-
-/*****************************************************/
-/* File: coding.c                                    */
-/* Description: Functions to create a DER coding of  */
-/*   an ASN1 type.                                   */
-/*****************************************************/
-
-#include <int.h>
-#include "parser_aux.h"
-#include <gstr.h>
-#include "element.h"
-#include <structure.h>
-
-#define MAX_TAG_LEN 16
-
-/******************************************************/
-/* Function : _asn1_error_description_value_not_found */
-/* Description: creates the ErrorDescription string   */
-/* for the ASN1_VALUE_NOT_FOUND error.                */
-/* Parameters:                                        */
-/*   node: node of the tree where the value is NULL.  */
-/*   ErrorDescription: string returned.               */
-/* Return:                                            */
-/******************************************************/
-static void
-_asn1_error_description_value_not_found (ASN1_TYPE node,
-                                        char *ErrorDescription)
-{
-
-  if (ErrorDescription == NULL)
-    return;
-
-  Estrcpy (ErrorDescription, ":: value of element '");
-  _asn1_hierarchical_name (node, ErrorDescription + strlen (ErrorDescription),
-                          ASN1_MAX_ERROR_DESCRIPTION_SIZE - 40);
-  Estrcat (ErrorDescription, "' not found");
-
-}
-
-/**
- * asn1_length_der:
- * @len: value to convert.
- * @ans: string returned.
- * @ans_len: number of meaningful bytes of ANS (ans[0]..ans[ans_len-1]).
- *
- * Creates the DER coding for the LEN parameter (only the length).
- * The @ans buffer is pre-allocated and must have room for the output.
- **/
-void
-asn1_length_der (unsigned long int len, unsigned char *ans, int *ans_len)
-{
-  int k;
-  unsigned char temp[SIZEOF_UNSIGNED_LONG_INT];
-
-  if (len < 128)
-    {
-      /* short form */
-      if (ans != NULL)
-       ans[0] = (unsigned char) len;
-      *ans_len = 1;
-    }
-  else
-    {
-      /* Long form */
-      k = 0;
-      while (len)
-       {
-         temp[k++] = len & 0xFF;
-         len = len >> 8;
-       }
-      *ans_len = k + 1;
-      if (ans != NULL)
-       {
-         ans[0] = ((unsigned char) k & 0x7F) + 128;
-         while (k--)
-           ans[*ans_len - 1 - k] = temp[k];
-       }
-    }
-}
-
-/******************************************************/
-/* Function : _asn1_tag_der                           */
-/* Description: creates the DER coding for the CLASS  */
-/* and TAG parameters.                                */
-/* Parameters:                                        */
-/*   class: value to convert.                         */
-/*   tag_value: value to convert.                     */
-/*   ans: string returned.                            */
-/*   ans_len: number of meaningful bytes of ANS       */
-/*            (ans[0]..ans[ans_len-1]).               */
-/* Return:                                            */
-/******************************************************/
-static void
-_asn1_tag_der (unsigned char class, unsigned int tag_value,
-              unsigned char *ans, int *ans_len)
-{
-  int k;
-  unsigned char temp[SIZEOF_UNSIGNED_INT];
-
-  if (tag_value < 31)
-    {
-      /* short form */
-      ans[0] = (class & 0xE0) + ((unsigned char) (tag_value & 0x1F));
-      *ans_len = 1;
-    }
-  else
-    {
-      /* Long form */
-      ans[0] = (class & 0xE0) + 31;
-      k = 0;
-      while (tag_value)
-       {
-         temp[k++] = tag_value & 0x7F;
-         tag_value = tag_value >> 7;
-       }
-      *ans_len = k + 1;
-      while (k--)
-       ans[*ans_len - 1 - k] = temp[k] + 128;
-      ans[*ans_len - 1] -= 128;
-    }
-}
-
-/**
- * asn1_octet_der:
- * @str: OCTET string.
- * @str_len: STR length (str[0]..str[str_len-1]).
- * @der: string returned.
- * @der_len: number of meaningful bytes of DER (der[0]..der[ans_len-1]).
- *
- * Creates the DER coding for an OCTET type (length included).
- **/
-void
-asn1_octet_der (const unsigned char *str, int str_len,
-               unsigned char *der, int *der_len)
-{
-  int len_len;
-
-  if (der == NULL || str_len < 0)
-    return;
-  asn1_length_der (str_len, der, &len_len);
-  memcpy (der + len_len, str, str_len);
-  *der_len = str_len + len_len;
-}
-
-/******************************************************/
-/* Function : _asn1_time_der                          */
-/* Description: creates the DER coding for a TIME     */
-/* type (length included).                            */
-/* Parameters:                                        */
-/*   str: TIME null-terminated string.                */
-/*   der: string returned.                            */
-/*   der_len: number of meaningful bytes of DER       */
-/*            (der[0]..der[ans_len-1]). Initially it  */
-/*            if must store the lenght of DER.        */
-/* Return:                                            */
-/*   ASN1_MEM_ERROR when DER isn't big enough         */
-/*   ASN1_SUCCESS otherwise                           */
-/******************************************************/
-static asn1_retCode
-_asn1_time_der (unsigned char *str, unsigned char *der, int *der_len)
-{
-  int len_len;
-  int max_len;
-  int str_len = _asn1_strlen (str);
-
-  max_len = *der_len;
-
-  asn1_length_der (str_len, (max_len > 0) ? der : NULL, &len_len);
-
-  if ((len_len + str_len) <= max_len)
-    memcpy (der + len_len, str, str_len);
-  *der_len = len_len + str_len;
-
-  if ((*der_len) > max_len)
-    return ASN1_MEM_ERROR;
-
-  return ASN1_SUCCESS;
-}
-
-
-/*
-void
-_asn1_get_utctime_der(unsigned char *der,int *der_len,unsigned char *str)
-{
-  int len_len,str_len;
-  char temp[20];
-
-  if(str==NULL) return;
-  str_len=asn1_get_length_der(der,*der_len,&len_len);
-  if (str_len<0) return;
-  memcpy(temp,der+len_len,str_len);
-  *der_len=str_len+len_len;
-  switch(str_len){
-  case 11:
-    temp[10]=0;
-    strcat(temp,"00+0000");
-    break;
-  case 13:
-    temp[12]=0;
-    strcat(temp,"+0000");
-    break;
-  case 15:
-    temp[15]=0;
-    memmove(temp+12,temp+10,6);
-    temp[10]=temp[11]='0';
-    break;
-  case 17:
-    temp[17]=0;
-    break;
-  default:
-    return;
-  }
-  strcpy(str,temp);
-}
-*/
-
-/******************************************************/
-/* Function : _asn1_objectid_der                      */
-/* Description: creates the DER coding for an         */
-/* OBJECT IDENTIFIER  type (length included).         */
-/* Parameters:                                        */
-/*   str: OBJECT IDENTIFIER null-terminated string.   */
-/*   der: string returned.                            */
-/*   der_len: number of meaningful bytes of DER       */
-/*            (der[0]..der[ans_len-1]). Initially it  */
-/*            must store the length of DER.           */
-/* Return:                                            */
-/*   ASN1_MEM_ERROR when DER isn't big enough         */
-/*   ASN1_SUCCESS otherwise                           */
-/******************************************************/
-static asn1_retCode
-_asn1_objectid_der (unsigned char *str, unsigned char *der, int *der_len)
-{
-  int len_len, counter, k, first, max_len;
-  char *temp, *n_end, *n_start;
-  unsigned char bit7;
-  unsigned long val, val1 = 0;
-  int str_len = _asn1_strlen (str);
-
-  max_len = *der_len;
-
-  temp = _asn1_malloc (str_len + 2);
-  if (temp == NULL)
-    return ASN1_MEM_ALLOC_ERROR;
-
-  memcpy (temp, str, str_len);
-  temp[str_len] = '.';
-  temp[str_len + 1] = 0;
-
-  counter = 0;
-  n_start = temp;
-  while ((n_end = strchr (n_start, '.')))
-    {
-      *n_end = 0;
-      val = strtoul (n_start, NULL, 10);
-      counter++;
-
-      if (counter == 1)
-       val1 = val;
-      else if (counter == 2)
-       {
-         if (max_len > 0)
-           der[0] = 40 * val1 + val;
-         *der_len = 1;
-       }
-      else
-       {
-         first = 0;
-         for (k = 4; k >= 0; k--)
-           {
-             bit7 = (val >> (k * 7)) & 0x7F;
-             if (bit7 || first || !k)
-               {
-                 if (k)
-                   bit7 |= 0x80;
-                 if (max_len > (*der_len))
-                   der[*der_len] = bit7;
-                 (*der_len)++;
-                 first = 1;
-               }
-           }
-
-       }
-      n_start = n_end + 1;
-    }
-
-  asn1_length_der (*der_len, NULL, &len_len);
-  if (max_len >= (*der_len + len_len))
-    {
-      memmove (der + len_len, der, *der_len);
-      asn1_length_der (*der_len, der, &len_len);
-    }
-  *der_len += len_len;
-
-  _asn1_free (temp);
-
-  if (max_len < (*der_len))
-    return ASN1_MEM_ERROR;
-
-  return ASN1_SUCCESS;
-}
-
-
-static const unsigned char bit_mask[] =
-  { 0xFF, 0xFE, 0xFC, 0xF8, 0xF0, 0xE0, 0xC0, 0x80 };
-
-/**
- * asn1_bit_der:
- * @str: BIT string.
- * @bit_len: number of meaningful bits in STR.
- * @der: string returned.
- * @der_len: number of meaningful bytes of DER
- *   (der[0]..der[ans_len-1]).
- *
- * Creates the DER coding for a BIT STRING type (length and pad
- * included).
- **/
-void
-asn1_bit_der (const unsigned char *str, int bit_len,
-             unsigned char *der, int *der_len)
-{
-  int len_len, len_byte, len_pad;
-
-  if (der == NULL)
-    return;
-  len_byte = bit_len >> 3;
-  len_pad = 8 - (bit_len & 7);
-  if (len_pad == 8)
-    len_pad = 0;
-  else
-    len_byte++;
-  asn1_length_der (len_byte + 1, der, &len_len);
-  der[len_len] = len_pad;
-  memcpy (der + len_len + 1, str, len_byte);
-  der[len_len + len_byte] &= bit_mask[len_pad];
-  *der_len = len_byte + len_len + 1;
-}
-
-
-/******************************************************/
-/* Function : _asn1_complete_explicit_tag             */
-/* Description: add the length coding to the EXPLICIT */
-/* tags.                                              */
-/* Parameters:                                        */
-/*   node: pointer to the tree element.               */
-/*   der: string with the DER coding of the whole tree*/
-/*   counter: number of meaningful bytes of DER       */
-/*            (der[0]..der[*counter-1]).              */
-/*   max_len: size of der vector                      */
-/* Return:                                            */
-/*   ASN1_MEM_ERROR if der vector isn't big enough,   */
-/*   otherwise ASN1_SUCCESS.                          */
-/******************************************************/
-static asn1_retCode
-_asn1_complete_explicit_tag (ASN1_TYPE node, unsigned char *der,
-                            int *counter, int *max_len)
-{
-  ASN1_TYPE p;
-  int is_tag_implicit, len2, len3;
-  unsigned char temp[SIZEOF_UNSIGNED_INT];
-
-  is_tag_implicit = 0;
-
-  if (node->type & CONST_TAG)
-    {
-      p = node->down;
-      /* When there are nested tags we must complete them reverse to
-         the order they were created. This is because completing a tag
-         modifies all data within it, including the incomplete tags
-         which store buffer positions -- address@hidden 2002-09-06
-       */
-      while (p->right)
-       p = p->right;
-      while (p && p != node->down->left)
-       {
-         if (type_field (p->type) == TYPE_TAG)
-           {
-             if (p->type & CONST_EXPLICIT)
-               {
-                 len2 = strtol (p->name, NULL, 10);
-                 _asn1_set_name (p, NULL);
-                 asn1_length_der (*counter - len2, temp, &len3);
-                 if (len3 <= (*max_len))
-                   {
-                     memmove (der + len2 + len3, der + len2,
-                              *counter - len2);
-                     memcpy (der + len2, temp, len3);
-                   }
-                 *max_len -= len3;
-                 *counter += len3;
-                 is_tag_implicit = 0;
-               }
-             else
-               {               /* CONST_IMPLICIT */
-                 if (!is_tag_implicit)
-                   {
-                     is_tag_implicit = 1;
-                   }
-               }
-           }
-         p = p->left;
-       }
-    }
-
-  if (*max_len < 0)
-    return ASN1_MEM_ERROR;
-
-  return ASN1_SUCCESS;
-}
-
-
-/******************************************************/
-/* Function : _asn1_insert_tag_der                    */
-/* Description: creates the DER coding of tags of one */
-/* NODE.                                              */
-/* Parameters:                                        */
-/*   node: pointer to the tree element.               */
-/*   der: string returned                             */
-/*   counter: number of meaningful bytes of DER       */
-/*            (counter[0]..der[*counter-1]).          */
-/*   max_len: size of der vector                      */
-/* Return:                                            */
-/*   ASN1_GENERIC_ERROR if the type is unknown,       */
-/*   ASN1_MEM_ERROR if der vector isn't big enough,   */
-/*   otherwise ASN1_SUCCESS.                          */
-/******************************************************/
-static asn1_retCode
-_asn1_insert_tag_der (ASN1_TYPE node, unsigned char *der, int *counter,
-                     int *max_len)
-{
-  ASN1_TYPE p;
-  int tag_len, is_tag_implicit;
-  unsigned char class, class_implicit = 0, temp[SIZEOF_UNSIGNED_INT * 3 + 1];
-  unsigned long tag_implicit = 0;
-  unsigned char tag_der[MAX_TAG_LEN];
-
-  is_tag_implicit = 0;
-
-  if (node->type & CONST_TAG)
-    {
-      p = node->down;
-      while (p)
-       {
-         if (type_field (p->type) == TYPE_TAG)
-           {
-             if (p->type & CONST_APPLICATION)
-               class = ASN1_CLASS_APPLICATION;
-             else if (p->type & CONST_UNIVERSAL)
-               class = ASN1_CLASS_UNIVERSAL;
-             else if (p->type & CONST_PRIVATE)
-               class = ASN1_CLASS_PRIVATE;
-             else
-               class = ASN1_CLASS_CONTEXT_SPECIFIC;
-
-             if (p->type & CONST_EXPLICIT)
-               {
-                 if (is_tag_implicit)
-                   _asn1_tag_der (class_implicit, tag_implicit, tag_der,
-                                  &tag_len);
-                 else
-                   _asn1_tag_der (class | ASN1_CLASS_STRUCTURED,
-                                  _asn1_strtoul (p->value, NULL, 10),
-                                  tag_der, &tag_len);
-
-                 *max_len -= tag_len;
-                 if (*max_len >= 0)
-                   memcpy (der + *counter, tag_der, tag_len);
-                 *counter += tag_len;
-
-                 _asn1_ltostr (*counter, (char *) temp);
-                 _asn1_set_name (p, (const char *) temp);
-
-                 is_tag_implicit = 0;
-               }
-             else
-               {               /* CONST_IMPLICIT */
-                 if (!is_tag_implicit)
-                   {
-                     if ((type_field (node->type) == TYPE_SEQUENCE) ||
-                         (type_field (node->type) == TYPE_SEQUENCE_OF) ||
-                         (type_field (node->type) == TYPE_SET) ||
-                         (type_field (node->type) == TYPE_SET_OF))
-                       class |= ASN1_CLASS_STRUCTURED;
-                     class_implicit = class;
-                     tag_implicit = _asn1_strtoul (p->value, NULL, 10);
-                     is_tag_implicit = 1;
-                   }
-               }
-           }
-         p = p->right;
-       }
-    }
-
-  if (is_tag_implicit)
-    {
-      _asn1_tag_der (class_implicit, tag_implicit, tag_der, &tag_len);
-    }
-  else
-    {
-      switch (type_field (node->type))
-       {
-       case TYPE_NULL:
-         _asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_NULL, tag_der,
-                        &tag_len);
-         break;
-       case TYPE_BOOLEAN:
-         _asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_BOOLEAN, tag_der,
-                        &tag_len);
-         break;
-       case TYPE_INTEGER:
-         _asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_INTEGER, tag_der,
-                        &tag_len);
-         break;
-       case TYPE_ENUMERATED:
-         _asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_ENUMERATED, tag_der,
-                        &tag_len);
-         break;
-       case TYPE_OBJECT_ID:
-         _asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_OBJECT_ID, tag_der,
-                        &tag_len);
-         break;
-       case TYPE_TIME:
-         if (node->type & CONST_UTC)
-           {
-             _asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_UTCTime, tag_der,
-                            &tag_len);
-           }
-         else
-           _asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_GENERALIZEDTime,
-                          tag_der, &tag_len);
-         break;
-       case TYPE_OCTET_STRING:
-         _asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_OCTET_STRING, tag_der,
-                        &tag_len);
-         break;
-       case TYPE_GENERALSTRING:
-         _asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_GENERALSTRING,
-                        tag_der, &tag_len);
-         break;
-       case TYPE_BIT_STRING:
-         _asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_BIT_STRING, tag_der,
-                        &tag_len);
-         break;
-       case TYPE_SEQUENCE:
-       case TYPE_SEQUENCE_OF:
-         _asn1_tag_der (ASN1_CLASS_UNIVERSAL | ASN1_CLASS_STRUCTURED,
-                        ASN1_TAG_SEQUENCE, tag_der, &tag_len);
-         break;
-       case TYPE_SET:
-       case TYPE_SET_OF:
-         _asn1_tag_der (ASN1_CLASS_UNIVERSAL | ASN1_CLASS_STRUCTURED,
-                        ASN1_TAG_SET, tag_der, &tag_len);
-         break;
-       case TYPE_TAG:
-         tag_len = 0;
-         break;
-       case TYPE_CHOICE:
-         tag_len = 0;
-         break;
-       case TYPE_ANY:
-         tag_len = 0;
-         break;
-       default:
-         return ASN1_GENERIC_ERROR;
-       }
-    }
-
-  *max_len -= tag_len;
-  if (*max_len >= 0)
-    memcpy (der + *counter, tag_der, tag_len);
-  *counter += tag_len;
-
-  if (*max_len < 0)
-    return ASN1_MEM_ERROR;
-
-  return ASN1_SUCCESS;
-}
-
-/******************************************************/
-/* Function : _asn1_ordering_set                      */
-/* Description: puts the elements of a SET type in    */
-/* the correct order according to DER rules.          */
-/* Parameters:                                        */
-/*   der: string with the DER coding.                 */
-/*   node: pointer to the SET element.                */
-/* Return:                                            */
-/******************************************************/
-static void
-_asn1_ordering_set (unsigned char *der, int der_len, ASN1_TYPE node)
-{
-  struct vet
-  {
-    int end;
-    unsigned long value;
-    struct vet *next, *prev;
-  };
-
-  int counter, len, len2;
-  struct vet *first, *last, *p_vet, *p2_vet;
-  ASN1_TYPE p;
-  unsigned char class, *temp;
-  unsigned long tag;
-
-  counter = 0;
-
-  if (type_field (node->type) != TYPE_SET)
-    return;
-
-  p = node->down;
-  while ((type_field (p->type) == TYPE_TAG)
-        || (type_field (p->type) == TYPE_SIZE))
-    p = p->right;
-
-  if ((p == NULL) || (p->right == NULL))
-    return;
-
-  first = last = NULL;
-  while (p)
-    {
-      p_vet = (struct vet *) _asn1_malloc (sizeof (struct vet));
-      if (p_vet == NULL)
-       return;
-
-      p_vet->next = NULL;
-      p_vet->prev = last;
-      if (first == NULL)
-       first = p_vet;
-      else
-       last->next = p_vet;
-      last = p_vet;
-
-      /* tag value calculation */
-      if (asn1_get_tag_der
-         (der + counter, der_len - counter, &class, &len2,
-          &tag) != ASN1_SUCCESS)
-       return;
-      p_vet->value = (class << 24) | tag;
-      counter += len2;
-
-      /* extraction and length */
-      len2 = asn1_get_length_der (der + counter, der_len - counter, &len);
-      if (len2 < 0)
-       return;
-      counter += len + len2;
-
-      p_vet->end = counter;
-      p = p->right;
-    }
-
-  p_vet = first;
-
-  while (p_vet)
-    {
-      p2_vet = p_vet->next;
-      counter = 0;
-      while (p2_vet)
-       {
-         if (p_vet->value > p2_vet->value)
-           {
-             /* change position */
-             temp = (unsigned char *) _asn1_malloc (p_vet->end - counter);
-             if (temp == NULL)
-               return;
-
-             memcpy (temp, der + counter, p_vet->end - counter);
-             memcpy (der + counter, der + p_vet->end,
-                     p2_vet->end - p_vet->end);
-             memcpy (der + counter + p2_vet->end - p_vet->end, temp,
-                     p_vet->end - counter);
-             _asn1_free (temp);
-
-             tag = p_vet->value;
-             p_vet->value = p2_vet->value;
-             p2_vet->value = tag;
-
-             p_vet->end = counter + (p2_vet->end - p_vet->end);
-           }
-         counter = p_vet->end;
-
-         p2_vet = p2_vet->next;
-         p_vet = p_vet->next;
-       }
-
-      if (p_vet != first)
-       p_vet->prev->next = NULL;
-      else
-       first = NULL;
-      _asn1_free (p_vet);
-      p_vet = first;
-    }
-}
-
-/******************************************************/
-/* Function : _asn1_ordering_set_of                   */
-/* Description: puts the elements of a SET OF type in */
-/* the correct order according to DER rules.          */
-/* Parameters:                                        */
-/*   der: string with the DER coding.                 */
-/*   node: pointer to the SET OF element.             */
-/* Return:                                            */
-/******************************************************/
-static void
-_asn1_ordering_set_of (unsigned char *der, int der_len, ASN1_TYPE node)
-{
-  struct vet
-  {
-    int end;
-    struct vet *next, *prev;
-  };
-
-  int counter, len, len2, change;
-  struct vet *first, *last, *p_vet, *p2_vet;
-  ASN1_TYPE p;
-  unsigned char *temp, class;
-  unsigned long k, max;
-
-  counter = 0;
-
-  if (type_field (node->type) != TYPE_SET_OF)
-    return;
-
-  p = node->down;
-  while ((type_field (p->type) == TYPE_TAG)
-        || (type_field (p->type) == TYPE_SIZE))
-    p = p->right;
-  p = p->right;
-
-  if ((p == NULL) || (p->right == NULL))
-    return;
-
-  first = last = NULL;
-  while (p)
-    {
-      p_vet = (struct vet *) _asn1_malloc (sizeof (struct vet));
-      if (p_vet == NULL)
-       return;
-
-      p_vet->next = NULL;
-      p_vet->prev = last;
-      if (first == NULL)
-       first = p_vet;
-      else
-       last->next = p_vet;
-      last = p_vet;
-
-      /* extraction of tag and length */
-      if (der_len - counter > 0)
-       {
-
-         if (asn1_get_tag_der
-             (der + counter, der_len - counter, &class, &len,
-              NULL) != ASN1_SUCCESS)
-           return;
-         counter += len;
-
-         len2 = asn1_get_length_der (der + counter, der_len - counter, &len);
-         if (len2 < 0)
-           return;
-         counter += len + len2;
-       }
-
-      p_vet->end = counter;
-      p = p->right;
-    }
-
-  p_vet = first;
-
-  while (p_vet)
-    {
-      p2_vet = p_vet->next;
-      counter = 0;
-      while (p2_vet)
-       {
-         if ((p_vet->end - counter) > (p2_vet->end - p_vet->end))
-           max = p_vet->end - counter;
-         else
-           max = p2_vet->end - p_vet->end;
-
-         change = -1;
-         for (k = 0; k < max; k++)
-           if (der[counter + k] > der[p_vet->end + k])
-             {
-               change = 1;
-               break;
-             }
-           else if (der[counter + k] < der[p_vet->end + k])
-             {
-               change = 0;
-               break;
-             }
-
-         if ((change == -1)
-             && ((p_vet->end - counter) > (p2_vet->end - p_vet->end)))
-           change = 1;
-
-         if (change == 1)
-           {
-             /* change position */
-             temp = (unsigned char *) _asn1_malloc (p_vet->end - counter);
-             if (temp == NULL)
-               return;
-
-             memcpy (temp, der + counter, (p_vet->end) - counter);
-             memcpy (der + counter, der + (p_vet->end),
-                     (p2_vet->end) - (p_vet->end));
-             memcpy (der + counter + (p2_vet->end) - (p_vet->end), temp,
-                     (p_vet->end) - counter);
-             _asn1_free (temp);
-
-             p_vet->end = counter + (p2_vet->end - p_vet->end);
-           }
-         counter = p_vet->end;
-
-         p2_vet = p2_vet->next;
-         p_vet = p_vet->next;
-       }
-
-      if (p_vet != first)
-       p_vet->prev->next = NULL;
-      else
-       first = NULL;
-      _asn1_free (p_vet);
-      p_vet = first;
-    }
-}
-
-/**
- * asn1_der_coding:
- * @element: pointer to an ASN1 element
- * @name: the name of the structure you want to encode (it must be
- *   inside *POINTER).
- * @ider: vector that will contain the DER encoding. DER must be a
- *   pointer to memory cells already allocated.
- * @len: number of bytes of address@hidden: @address@hidden, Initialy
- *   holds the sizeof of der vector.
- * @errorDescription : return the error description or an empty
- *   string if success.
- *
- * Creates the DER encoding for the NAME structure (inside *POINTER
- * structure).
- *
- * Returns: %ASN1_SUCCESS if DER encoding OK, %ASN1_ELEMENT_NOT_FOUND
- *   if @name is not a valid element, %ASN1_VALUE_NOT_FOUND if there
- *   is an element without a value, %ASN1_MEM_ERROR if the @ider
- *   vector isn't big enough and in this case @len will contain the
- *   length needed.
- **/
-asn1_retCode
-asn1_der_coding (ASN1_TYPE element, const char *name, void *ider, int *len,
-                char *ErrorDescription)
-{
-  ASN1_TYPE node, p, p2;
-  unsigned char temp[SIZEOF_UNSIGNED_LONG_INT * 3 + 1];
-  int counter, counter_old, len2, len3, tlen, move, max_len, max_len_old;
-  asn1_retCode err;
-  unsigned char *der = ider;
-
-  node = asn1_find_node (element, name);
-  if (node == NULL)
-    return ASN1_ELEMENT_NOT_FOUND;
-
-  /* Node is now a locally allocated variable.
-   * That is because in some point we modify the
-   * structure, and I don't know why! --nmav
-   */
-  node = _asn1_copy_structure3 (node);
-  if (node == NULL)
-    return ASN1_ELEMENT_NOT_FOUND;
-
-  max_len = *len;
-
-  counter = 0;
-  move = DOWN;
-  p = node;
-  while (1)
-    {
-
-      counter_old = counter;
-      max_len_old = max_len;
-      if (move != UP)
-       {
-         err = _asn1_insert_tag_der (p, der, &counter, &max_len);
-         if (err != ASN1_SUCCESS && err != ASN1_MEM_ERROR)
-           goto error;
-       }
-      switch (type_field (p->type))
-       {
-       case TYPE_NULL:
-         max_len--;
-         if (max_len >= 0)
-           der[counter] = 0;
-         counter++;
-         move = RIGHT;
-         break;
-       case TYPE_BOOLEAN:
-         if ((p->type & CONST_DEFAULT) && (p->value == NULL))
-           {
-             counter = counter_old;
-             max_len = max_len_old;
-           }
-         else
-           {
-             if (p->value == NULL)
-               {
-                 _asn1_error_description_value_not_found (p,
-                                                          ErrorDescription);
-                 err = ASN1_VALUE_NOT_FOUND;
-                 goto error;
-               }
-             max_len -= 2;
-             if (max_len >= 0)
-               {
-                 der[counter++] = 1;
-                 if (p->value[0] == 'F')
-                   der[counter++] = 0;
-                 else
-                   der[counter++] = 0xFF;
-               }
-             else
-               counter += 2;
-           }
-         move = RIGHT;
-         break;
-       case TYPE_INTEGER:
-       case TYPE_ENUMERATED:
-         if ((p->type & CONST_DEFAULT) && (p->value == NULL))
-           {
-             counter = counter_old;
-             max_len = max_len_old;
-           }
-         else
-           {
-             if (p->value == NULL)
-               {
-                 _asn1_error_description_value_not_found (p,
-                                                          ErrorDescription);
-                 err = ASN1_VALUE_NOT_FOUND;
-                 goto error;
-               }
-             len2 = asn1_get_length_der (p->value, p->value_len, &len3);
-             if (len2 < 0)
-               {
-                 err = ASN1_DER_ERROR;
-                 goto error;
-               }
-             max_len -= len2 + len3;
-             if (max_len >= 0)
-               memcpy (der + counter, p->value, len3 + len2);
-             counter += len3 + len2;
-           }
-         move = RIGHT;
-         break;
-       case TYPE_OBJECT_ID:
-         if ((p->type & CONST_DEFAULT) && (p->value == NULL))
-           {
-             counter = counter_old;
-             max_len = max_len_old;
-           }
-         else
-           {
-             if (p->value == NULL)
-               {
-                 _asn1_error_description_value_not_found (p,
-                                                          ErrorDescription);
-                 err = ASN1_VALUE_NOT_FOUND;
-                 goto error;
-               }
-             len2 = max_len;
-             err = _asn1_objectid_der (p->value, der + counter, &len2);
-             if (err != ASN1_SUCCESS && err != ASN1_MEM_ERROR)
-               goto error;
-
-             max_len -= len2;
-             counter += len2;
-           }
-         move = RIGHT;
-         break;
-       case TYPE_TIME:
-         if (p->value == NULL)
-           {
-             _asn1_error_description_value_not_found (p, ErrorDescription);
-             err = ASN1_VALUE_NOT_FOUND;
-             goto error;
-           }
-         len2 = max_len;
-         err = _asn1_time_der (p->value, der + counter, &len2);
-         if (err != ASN1_SUCCESS && err != ASN1_MEM_ERROR)
-           goto error;
-
-         max_len -= len2;
-         counter += len2;
-         move = RIGHT;
-         break;
-       case TYPE_OCTET_STRING:
-         if (p->value == NULL)
-           {
-             _asn1_error_description_value_not_found (p, ErrorDescription);
-             err = ASN1_VALUE_NOT_FOUND;
-             goto error;
-           }
-         len2 = asn1_get_length_der (p->value, p->value_len, &len3);
-         if (len2 < 0)
-           {
-             err = ASN1_DER_ERROR;
-             goto error;
-           }
-         max_len -= len2 + len3;
-         if (max_len >= 0)
-           memcpy (der + counter, p->value, len3 + len2);
-         counter += len3 + len2;
-         move = RIGHT;
-         break;
-       case TYPE_GENERALSTRING:
-         if (p->value == NULL)
-           {
-             _asn1_error_description_value_not_found (p, ErrorDescription);
-             err = ASN1_VALUE_NOT_FOUND;
-             goto error;
-           }
-         len2 = asn1_get_length_der (p->value, p->value_len, &len3);
-         if (len2 < 0)
-           {
-             err = ASN1_DER_ERROR;
-             goto error;
-           }
-         max_len -= len2 + len3;
-         if (max_len >= 0)
-           memcpy (der + counter, p->value, len3 + len2);
-         counter += len3 + len2;
-         move = RIGHT;
-         break;
-       case TYPE_BIT_STRING:
-         if (p->value == NULL)
-           {
-             _asn1_error_description_value_not_found (p, ErrorDescription);
-             err = ASN1_VALUE_NOT_FOUND;
-             goto error;
-           }
-         len2 = asn1_get_length_der (p->value, p->value_len, &len3);
-         if (len2 < 0)
-           {
-             err = ASN1_DER_ERROR;
-             goto error;
-           }
-         max_len -= len2 + len3;
-         if (max_len >= 0)
-           memcpy (der + counter, p->value, len3 + len2);
-         counter += len3 + len2;
-         move = RIGHT;
-         break;
-       case TYPE_SEQUENCE:
-       case TYPE_SET:
-         if (move != UP)
-           {
-             _asn1_ltostr (counter, (char *) temp);
-             tlen = _asn1_strlen (temp);
-             if (tlen > 0)
-               _asn1_set_value (p, temp, tlen + 1);
-             if (p->down == NULL)
-               {
-                 move = UP;
-                 continue;
-               }
-             else
-               {
-                 p2 = p->down;
-                 while (p2 && (type_field (p2->type) == TYPE_TAG))
-                   p2 = p2->right;
-                 if (p2)
-                   {
-                     p = p2;
-                     move = RIGHT;
-                     continue;
-                   }
-                 move = UP;
-                 continue;
-               }
-           }
-         else
-           {                   /* move==UP */
-             len2 = _asn1_strtol (p->value, NULL, 10);
-             _asn1_set_value (p, NULL, 0);
-             if ((type_field (p->type) == TYPE_SET) && (max_len >= 0))
-               _asn1_ordering_set (der + len2, max_len - len2, p);
-             asn1_length_der (counter - len2, temp, &len3);
-             max_len -= len3;
-             if (max_len >= 0)
-               {
-                 memmove (der + len2 + len3, der + len2, counter - len2);
-                 memcpy (der + len2, temp, len3);
-               }
-             counter += len3;
-             move = RIGHT;
-           }
-         break;
-       case TYPE_SEQUENCE_OF:
-       case TYPE_SET_OF:
-         if (move != UP)
-           {
-             _asn1_ltostr (counter, (char *) temp);
-             tlen = _asn1_strlen (temp);
-
-             if (tlen > 0)
-               _asn1_set_value (p, temp, tlen + 1);
-             p = p->down;
-             while ((type_field (p->type) == TYPE_TAG)
-                    || (type_field (p->type) == TYPE_SIZE))
-               p = p->right;
-             if (p->right)
-               {
-                 p = p->right;
-                 move = RIGHT;
-                 continue;
-               }
-             else
-               p = _asn1_find_up (p);
-             move = UP;
-           }
-         if (move == UP)
-           {
-             len2 = _asn1_strtol (p->value, NULL, 10);
-             _asn1_set_value (p, NULL, 0);
-             if ((type_field (p->type) == TYPE_SET_OF)
-                 && (max_len - len2 > 0))
-               {
-                 _asn1_ordering_set_of (der + len2, max_len - len2, p);
-               }
-             asn1_length_der (counter - len2, temp, &len3);
-             max_len -= len3;
-             if (max_len >= 0)
-               {
-                 memmove (der + len2 + len3, der + len2, counter - len2);
-                 memcpy (der + len2, temp, len3);
-               }
-             counter += len3;
-             move = RIGHT;
-           }
-         break;
-       case TYPE_ANY:
-         if (p->value == NULL)
-           {
-             _asn1_error_description_value_not_found (p, ErrorDescription);
-             err = ASN1_VALUE_NOT_FOUND;
-             goto error;
-           }
-         len2 = asn1_get_length_der (p->value, p->value_len, &len3);
-         if (len2 < 0)
-           {
-             err = ASN1_DER_ERROR;
-             goto error;
-           }
-         max_len -= len2;
-         if (max_len >= 0)
-           memcpy (der + counter, p->value + len3, len2);
-         counter += len2;
-         move = RIGHT;
-         break;
-       default:
-         move = (move == UP) ? RIGHT : DOWN;
-         break;
-       }
-
-      if ((move != DOWN) && (counter != counter_old))
-       {
-         err = _asn1_complete_explicit_tag (p, der, &counter, &max_len);
-         if (err != ASN1_SUCCESS && err != ASN1_MEM_ERROR)
-           goto error;
-       }
-
-      if (p == node && move != DOWN)
-       break;
-
-      if (move == DOWN)
-       {
-         if (p->down)
-           p = p->down;
-         else
-           move = RIGHT;
-       }
-      if (move == RIGHT)
-       {
-         if (p->right)
-           p = p->right;
-         else
-           move = UP;
-       }
-      if (move == UP)
-       p = _asn1_find_up (p);
-    }
-
-  *len = counter;
-
-  if (max_len < 0)
-    {
-      err = ASN1_MEM_ERROR;
-      goto error;
-    }
-
-  err = ASN1_SUCCESS;
-
-error:
-  asn1_delete_structure (&node);
-  return err;
-}
diff --git a/asn1/decoding.c b/asn1/decoding.c
deleted file mode 100644
index e6cdb98..0000000
--- a/asn1/decoding.c
+++ /dev/null
@@ -1,2904 +0,0 @@
-/*
- * Copyright (C) 2002-2012 Free Software Foundation, Inc.
- *
- * This file is part of LIBTASN1.
- *
- * The LIBTASN1 library is free software; you can redistribute it
- * and/or modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA
- */
-
-
-/*****************************************************/
-/* File: decoding.c                                  */
-/* Description: Functions to manage DER decoding     */
-/*****************************************************/
-
-#include <int.h>
-#include "parser_aux.h"
-#include <gstr.h>
-#include "structure.h"
-#include "element.h"
-#include <limits.h>
-
-static asn1_retCode
-_asn1_get_indefinite_length_string (const unsigned char *der, int *len);
-
-static void
-_asn1_error_description_tag_error (ASN1_TYPE node, char *ErrorDescription)
-{
-
-  Estrcpy (ErrorDescription, ":: tag error near element '");
-  _asn1_hierarchical_name (node, ErrorDescription + strlen (ErrorDescription),
-                          ASN1_MAX_ERROR_DESCRIPTION_SIZE - 40);
-  Estrcat (ErrorDescription, "'");
-
-}
-
-/**
- * asn1_get_length_der:
- * @der: DER data to decode.
- * @der_len: Length of DER data to decode.
- * @len: Output variable containing the length of the DER length field.
- *
- * Extract a length field from DER data.
- *
- * Returns: Return the decoded length value, or -1 on indefinite
- *   length, or -2 when the value was too big to fit in a int, or -4
- *   when the decoded length value plus @len would exceed @der_len.
- **/
-long
-asn1_get_length_der (const unsigned char *der, int der_len, int *len)
-{
-  unsigned int ans, sum, last;
-  int k, punt;
-
-  *len = 0;
-  if (der_len <= 0)
-    return 0;
-
-  if (!(der[0] & 128))
-    {
-      /* short form */
-      *len = 1;
-      ans = der[0];
-    }
-  else
-    {
-      /* Long form */
-      k = der[0] & 0x7F;
-      punt = 1;
-      if (k)
-       {                       /* definite length method */
-         ans = 0;
-         while (punt <= k && punt < der_len)
-           {
-             last = ans;
-
-             ans = (ans*256) + der[punt++];
-             if (ans < last)
-               /* we wrapped around, no bignum support... */
-               return -2;
-           }
-       }
-      else
-       {                       /* indefinite length method */
-         *len = punt;
-         return -1;
-       }
-
-      *len = punt;
-    }
-
-  sum = ans + *len;
-
-  /* check for overflow as well INT_MAX as a maximum upper
-   * limit for length */
-  if (sum >= INT_MAX || sum < ans)
-    return -2;
-
-  if (((int) sum) > der_len)
-    return -4;
-
-  return ans;
-}
-
-/**
- * asn1_get_tag_der:
- * @der: DER data to decode.
- * @der_len: Length of DER data to decode.
- * @cls: Output variable containing decoded class.
- * @len: Output variable containing the length of the DER TAG data.
- * @tag: Output variable containing the decoded tag.
- *
- * Decode the class and TAG from DER code.
- *
- * Returns: Returns %ASN1_SUCCESS on success, or an error.
- **/
-int
-asn1_get_tag_der (const unsigned char *der, int der_len,
-                 unsigned char *cls, int *len, unsigned long *tag)
-{
-  unsigned int ris;
-  int punt;
-  unsigned int last;
-
-  if (der == NULL || der_len < 2 || len == NULL)
-    return ASN1_DER_ERROR;
-
-  *cls = der[0] & 0xE0;
-  if ((der[0] & 0x1F) != 0x1F)
-    {
-      /* short form */
-      *len = 1;
-      ris = der[0] & 0x1F;
-    }
-  else
-    {
-      /* Long form */
-      punt = 1;
-      ris = 0;
-      while (punt <= der_len && der[punt] & 128)
-       {
-         last = ris;
-
-         ris = (ris * 128) + (der[punt++] & 0x7F);
-         if (ris < last)
-           /* wrapped around, and no bignums... */
-           return ASN1_DER_ERROR;
-       }
-
-      if (punt >= der_len)
-       return ASN1_DER_ERROR;
-
-      last = ris;
-
-      ris = (ris * 128) + (der[punt++] & 0x7F);
-      if (ris < last)
-       return ASN1_DER_ERROR;
-
-      *len = punt;
-    }
-  if (tag)
-    *tag = ris;
-  return ASN1_SUCCESS;
-}
-
-/**
- * asn1_get_length_ber:
- * @ber: BER data to decode.
- * @ber_len: Length of BER data to decode.
- * @len: Output variable containing the length of the BER length field.
- *
- * Extract a length field from BER data.  The difference to
- * asn1_get_length_der() is that this function will return a length
- * even if the value has indefinite encoding.
- *
- * Returns: Return the decoded length value, or negative value when
- *   the value was too big.
- *
- * Since: 2.0
- **/
-long
-asn1_get_length_ber (const unsigned char *ber, int ber_len, int *len)
-{
-  int ret;
-  long err;
-
-  ret = asn1_get_length_der (ber, ber_len, len);
-  if (ret == -1)
-    {                          /* indefinite length method */
-      ret = ber_len;
-      err = _asn1_get_indefinite_length_string (ber + 1, &ret);
-      if (err != ASN1_SUCCESS)
-       return -3;
-    }
-
-  return ret;
-}
-
-/**
- * asn1_get_octet_der:
- * @der: DER data to decode containing the OCTET SEQUENCE.
- * @der_len: Length of DER data to decode.
- * @ret_len: Output variable containing the length of the DER data.
- * @str: Pre-allocated output buffer to put decoded OCTET SEQUENCE in.
- * @str_size: Length of pre-allocated output buffer.
- * @str_len: Output variable containing the length of the OCTET SEQUENCE.
- *
- * Extract an OCTET SEQUENCE from DER data.
- *
- * Returns: Returns %ASN1_SUCCESS on success, or an error.
- **/
-int
-asn1_get_octet_der (const unsigned char *der, int der_len,
-                   int *ret_len, unsigned char *str, int str_size,
-                   int *str_len)
-{
-  int len_len;
-
-  if (der_len <= 0)
-    return ASN1_GENERIC_ERROR;
-
-  /* if(str==NULL) return ASN1_SUCCESS; */
-  *str_len = asn1_get_length_der (der, der_len, &len_len);
-
-  if (*str_len < 0)
-    return ASN1_DER_ERROR;
-
-  *ret_len = *str_len + len_len;
-  if (str_size >= *str_len)
-    memcpy (str, der + len_len, *str_len);
-  else
-    {
-      return ASN1_MEM_ERROR;
-    }
-
-  return ASN1_SUCCESS;
-}
-
-/* Returns ASN1_SUCCESS on success or an error code on error.
- */
-static int
-_asn1_get_time_der (const unsigned char *der, int der_len, int *ret_len,
-                   char *str, int str_size)
-{
-  int len_len, str_len;
-
-  if (der_len <= 0 || str == NULL)
-    return ASN1_DER_ERROR;
-  str_len = asn1_get_length_der (der, der_len, &len_len);
-  if (str_len < 0 || str_size < str_len)
-    return ASN1_DER_ERROR;
-  memcpy (str, der + len_len, str_len);
-  str[str_len] = 0;
-  *ret_len = str_len + len_len;
-
-  return ASN1_SUCCESS;
-}
-
-static int
-_asn1_get_objectid_der (const unsigned char *der, int der_len, int *ret_len,
-                       char *str, int str_size)
-{
-  int len_len, len, k;
-  int leading;
-  char temp[20];
-  unsigned long val, val1, prev_val;
-
-  *ret_len = 0;
-  if (str && str_size > 0)
-    str[0] = 0;                        /* no oid */
-
-  if (str == NULL || der_len <= 0)
-    return ASN1_GENERIC_ERROR;
-  len = asn1_get_length_der (der, der_len, &len_len);
-
-  if (len < 0 || len > der_len || len_len > der_len)
-    return ASN1_DER_ERROR;
-
-  val1 = der[len_len] / 40;
-  val = der[len_len] - val1 * 40;
-
-  _asn1_str_cpy (str, str_size, _asn1_ltostr (val1, temp));
-  _asn1_str_cat (str, str_size, ".");
-  _asn1_str_cat (str, str_size, _asn1_ltostr (val, temp));
-
-  prev_val = 0;
-  val = 0;
-  leading = 1;
-  for (k = 1; k < len; k++)
-    {
-      /* X.690 mandates that the leading byte must never be 0x80
-       */
-      if (leading != 0 && der[len_len + k] == 0x80)
-       return ASN1_DER_ERROR;
-      leading = 0;
-
-      /* check for wrap around */
-      val = val << 7;
-      val |= der[len_len + k] & 0x7F;
-
-      if (val < prev_val)
-       return ASN1_DER_ERROR;
-
-      prev_val = val;
-
-      if (!(der[len_len + k] & 0x80))
-       {
-         _asn1_str_cat (str, str_size, ".");
-         _asn1_str_cat (str, str_size, _asn1_ltostr (val, temp));
-         val = 0;
-         prev_val = 0;
-         leading = 1;
-       }
-    }
-  *ret_len = len + len_len;
-
-  return ASN1_SUCCESS;
-}
-
-/**
- * asn1_get_bit_der:
- * @der: DER data to decode containing the BIT SEQUENCE.
- * @der_len: Length of DER data to decode.
- * @ret_len: Output variable containing the length of the DER data.
- * @str: Pre-allocated output buffer to put decoded BIT SEQUENCE in.
- * @str_size: Length of pre-allocated output buffer.
- * @bit_len: Output variable containing the size of the BIT SEQUENCE.
- *
- * Extract a BIT SEQUENCE from DER data.
- *
- * Returns: Return %ASN1_SUCCESS on success, or an error.
- **/
-int
-asn1_get_bit_der (const unsigned char *der, int der_len,
-                 int *ret_len, unsigned char *str, int str_size,
-                 int *bit_len)
-{
-  int len_len, len_byte;
-
-  if (der_len <= 0)
-    return ASN1_GENERIC_ERROR;
-  len_byte = asn1_get_length_der (der, der_len, &len_len) - 1;
-  if (len_byte < 0)
-    return ASN1_DER_ERROR;
-
-  *ret_len = len_byte + len_len + 1;
-  *bit_len = len_byte * 8 - der[len_len];
-
-  if (str_size >= len_byte)
-    memcpy (str, der + len_len + 1, len_byte);
-  else
-    {
-      return ASN1_MEM_ERROR;
-    }
-
-  return ASN1_SUCCESS;
-}
-
-static int
-_asn1_extract_tag_der (ASN1_TYPE node, const unsigned char *der, int der_len,
-                      int *ret_len)
-{
-  ASN1_TYPE p;
-  int counter, len2, len3, is_tag_implicit;
-  unsigned long tag, tag_implicit = 0;
-  unsigned char class, class2, class_implicit = 0;
-
-  if (der_len <= 0)
-    return ASN1_GENERIC_ERROR;
-
-  counter = is_tag_implicit = 0;
-
-  if (node->type & CONST_TAG)
-    {
-      p = node->down;
-      while (p)
-       {
-         if (type_field (p->type) == TYPE_TAG)
-           {
-             if (p->type & CONST_APPLICATION)
-               class2 = ASN1_CLASS_APPLICATION;
-             else if (p->type & CONST_UNIVERSAL)
-               class2 = ASN1_CLASS_UNIVERSAL;
-             else if (p->type & CONST_PRIVATE)
-               class2 = ASN1_CLASS_PRIVATE;
-             else
-               class2 = ASN1_CLASS_CONTEXT_SPECIFIC;
-
-             if (p->type & CONST_EXPLICIT)
-               {
-                 if (asn1_get_tag_der
-                     (der + counter, der_len - counter, &class, &len2,
-                      &tag) != ASN1_SUCCESS)
-                   return ASN1_DER_ERROR;
-
-                 if (counter + len2 > der_len)
-                   return ASN1_DER_ERROR;
-                 counter += len2;
-
-                 len3 =
-                   asn1_get_length_ber (der + counter, der_len - counter,
-                                        &len2);
-                 if (len3 < 0)
-                   return ASN1_DER_ERROR;
-
-                 counter += len2;
-                 if (counter > der_len)
-                   return ASN1_DER_ERROR;
-
-                 if (!is_tag_implicit)
-                   {
-                     if ((class != (class2 | ASN1_CLASS_STRUCTURED)) ||
-                         (tag != strtoul ((char *) p->value, NULL, 10)))
-                       return ASN1_TAG_ERROR;
-                   }
-                 else
-                   {           /* ASN1_TAG_IMPLICIT */
-                     if ((class != class_implicit) || (tag != tag_implicit))
-                       return ASN1_TAG_ERROR;
-                   }
-                 is_tag_implicit = 0;
-               }
-             else
-               {               /* ASN1_TAG_IMPLICIT */
-                 if (!is_tag_implicit)
-                   {
-                     if ((type_field (node->type) == TYPE_SEQUENCE) ||
-                         (type_field (node->type) == TYPE_SEQUENCE_OF) ||
-                         (type_field (node->type) == TYPE_SET) ||
-                         (type_field (node->type) == TYPE_SET_OF))
-                       class2 |= ASN1_CLASS_STRUCTURED;
-                     class_implicit = class2;
-                     tag_implicit = strtoul ((char *) p->value, NULL, 10);
-                     is_tag_implicit = 1;
-                   }
-               }
-           }
-         p = p->right;
-       }
-    }
-
-  if (is_tag_implicit)
-    {
-      if (asn1_get_tag_der
-         (der + counter, der_len - counter, &class, &len2,
-          &tag) != ASN1_SUCCESS)
-       return ASN1_DER_ERROR;
-      if (counter + len2 > der_len)
-       return ASN1_DER_ERROR;
-
-      if ((class != class_implicit) || (tag != tag_implicit))
-       {
-         if (type_field (node->type) == TYPE_OCTET_STRING)
-           {
-             class_implicit |= ASN1_CLASS_STRUCTURED;
-             if ((class != class_implicit) || (tag != tag_implicit))
-               return ASN1_TAG_ERROR;
-           }
-         else
-           return ASN1_TAG_ERROR;
-       }
-    }
-  else
-    {
-      if (type_field (node->type) == TYPE_TAG)
-       {
-         counter = 0;
-         *ret_len = counter;
-         return ASN1_SUCCESS;
-       }
-
-      if (asn1_get_tag_der
-         (der + counter, der_len - counter, &class, &len2,
-          &tag) != ASN1_SUCCESS)
-       return ASN1_DER_ERROR;
-
-      if (counter + len2 > der_len)
-       return ASN1_DER_ERROR;
-
-      switch (type_field (node->type))
-       {
-       case TYPE_NULL:
-         if ((class != ASN1_CLASS_UNIVERSAL) || (tag != ASN1_TAG_NULL))
-           return ASN1_DER_ERROR;
-         break;
-       case TYPE_BOOLEAN:
-         if ((class != ASN1_CLASS_UNIVERSAL) || (tag != ASN1_TAG_BOOLEAN))
-           return ASN1_DER_ERROR;
-         break;
-       case TYPE_INTEGER:
-         if ((class != ASN1_CLASS_UNIVERSAL) || (tag != ASN1_TAG_INTEGER))
-           return ASN1_DER_ERROR;
-         break;
-       case TYPE_ENUMERATED:
-         if ((class != ASN1_CLASS_UNIVERSAL) || (tag != ASN1_TAG_ENUMERATED))
-           return ASN1_DER_ERROR;
-         break;
-       case TYPE_OBJECT_ID:
-         if ((class != ASN1_CLASS_UNIVERSAL) || (tag != ASN1_TAG_OBJECT_ID))
-           return ASN1_DER_ERROR;
-         break;
-       case TYPE_TIME:
-         if (node->type & CONST_UTC)
-           {
-             if ((class != ASN1_CLASS_UNIVERSAL)
-                 || (tag != ASN1_TAG_UTCTime))
-               return ASN1_DER_ERROR;
-           }
-         else
-           {
-             if ((class != ASN1_CLASS_UNIVERSAL)
-                 || (tag != ASN1_TAG_GENERALIZEDTime))
-               return ASN1_DER_ERROR;
-           }
-         break;
-       case TYPE_OCTET_STRING:
-         if (((class != ASN1_CLASS_UNIVERSAL)
-              && (class != (ASN1_CLASS_UNIVERSAL | ASN1_CLASS_STRUCTURED)))
-             || (tag != ASN1_TAG_OCTET_STRING))
-           return ASN1_DER_ERROR;
-         break;
-       case TYPE_GENERALSTRING:
-         if ((class != ASN1_CLASS_UNIVERSAL)
-             || (tag != ASN1_TAG_GENERALSTRING))
-           return ASN1_DER_ERROR;
-         break;
-       case TYPE_BIT_STRING:
-         if ((class != ASN1_CLASS_UNIVERSAL) || (tag != ASN1_TAG_BIT_STRING))
-           return ASN1_DER_ERROR;
-         break;
-       case TYPE_SEQUENCE:
-       case TYPE_SEQUENCE_OF:
-         if ((class != (ASN1_CLASS_UNIVERSAL | ASN1_CLASS_STRUCTURED))
-             || (tag != ASN1_TAG_SEQUENCE))
-           return ASN1_DER_ERROR;
-         break;
-       case TYPE_SET:
-       case TYPE_SET_OF:
-         if ((class != (ASN1_CLASS_UNIVERSAL | ASN1_CLASS_STRUCTURED))
-             || (tag != ASN1_TAG_SET))
-           return ASN1_DER_ERROR;
-         break;
-       case TYPE_ANY:
-         counter -= len2;
-         break;
-       default:
-         return ASN1_DER_ERROR;
-         break;
-       }
-    }
-
-  counter += len2;
-  *ret_len = counter;
-  return ASN1_SUCCESS;
-}
-
-static int
-_asn1_delete_not_used (ASN1_TYPE node)
-{
-  ASN1_TYPE p, p2;
-
-  if (node == NULL)
-    return ASN1_ELEMENT_NOT_FOUND;
-
-  p = node;
-  while (p)
-    {
-      if (p->type & CONST_NOT_USED)
-       {
-         p2 = NULL;
-         if (p != node)
-           {
-             p2 = _asn1_find_left (p);
-             if (!p2)
-               p2 = _asn1_find_up (p);
-           }
-         asn1_delete_structure (&p);
-         p = p2;
-       }
-
-      if (!p)
-       break;                  /* reach node */
-
-      if (p->down)
-       {
-         p = p->down;
-       }
-      else
-       {
-         if (p == node)
-           p = NULL;
-         else if (p->right)
-           p = p->right;
-         else
-           {
-             while (1)
-               {
-                 p = _asn1_find_up (p);
-                 if (p == node)
-                   {
-                     p = NULL;
-                     break;
-                   }
-                 if (p->right)
-                   {
-                     p = p->right;
-                     break;
-                   }
-               }
-           }
-       }
-    }
-  return ASN1_SUCCESS;
-}
-
-static asn1_retCode
-_asn1_extract_der_octet (ASN1_TYPE node, const unsigned char *der,
-                        int der_len)
-{
-  int len2, len3;
-  int counter2, counter_end;
-
-  len2 = asn1_get_length_der (der, der_len, &len3);
-  if (len2 < -1)
-    return ASN1_DER_ERROR;
-
-  counter2 = len3 + 1;
-
-  if (len2 == -1)
-    counter_end = der_len - 2;
-  else
-    counter_end = der_len;
-
-  while (counter2 < counter_end)
-    {
-      len2 = asn1_get_length_der (der + counter2, der_len - counter2, &len3);
-
-      if (len2 < -1)
-       return ASN1_DER_ERROR;
-
-      if (len2 > 0)
-       {
-         _asn1_append_value (node, der + counter2 + len3, len2);
-       }
-      else
-       {                       /* indefinite */
-
-         len2 =
-           _asn1_extract_der_octet (node, der + counter2 + len3,
-                                    der_len - counter2 - len3);
-         if (len2 < 0)
-           return len2;
-       }
-
-      counter2 += len2 + len3 + 1;
-    }
-
-  return ASN1_SUCCESS;
-}
-
-static asn1_retCode
-_asn1_get_octet_string (const unsigned char *der, ASN1_TYPE node, int *len)
-{
-  int len2, len3, counter, tot_len, indefinite;
-
-  counter = 0;
-
-  if (*(der - 1) & ASN1_CLASS_STRUCTURED)
-    {
-      tot_len = 0;
-      indefinite = asn1_get_length_der (der, *len, &len3);
-      if (indefinite < -1)
-       return ASN1_DER_ERROR;
-
-      counter += len3;
-      if (indefinite >= 0)
-       indefinite += len3;
-
-      while (1)
-       {
-         if (counter > (*len))
-           return ASN1_DER_ERROR;
-
-         if (indefinite == -1)
-           {
-             if ((der[counter] == 0) && (der[counter + 1] == 0))
-               {
-                 counter += 2;
-                 break;
-               }
-           }
-         else if (counter >= indefinite)
-           break;
-
-         if (der[counter] != ASN1_TAG_OCTET_STRING)
-           return ASN1_DER_ERROR;
-
-         counter++;
-
-         len2 = asn1_get_length_der (der + counter, *len - counter, &len3);
-         if (len2 <= 0)
-           return ASN1_DER_ERROR;
-
-         counter += len3 + len2;
-         tot_len += len2;
-       }
-
-      /* copy */
-      if (node)
-       {
-         unsigned char temp[DER_LEN];
-         int ret;
-
-         len2 = sizeof (temp);
-
-         asn1_length_der (tot_len, temp, &len2);
-         _asn1_set_value (node, temp, len2);
-
-         tot_len += len2;
-
-         ret = _asn1_extract_der_octet (node, der, *len);
-         if (ret != ASN1_SUCCESS)
-           return ret;
-
-       }
-    }
-  else
-    {                          /* NOT STRUCTURED */
-      len2 = asn1_get_length_der (der, *len, &len3);
-      if (len2 < 0)
-       return ASN1_DER_ERROR;
-      if (node)
-       _asn1_set_value (node, der, len3 + len2);
-      counter = len3 + len2;
-    }
-
-  *len = counter;
-  return ASN1_SUCCESS;
-
-}
-
-static asn1_retCode
-_asn1_get_indefinite_length_string (const unsigned char *der, int *len)
-{
-  int len2, len3, counter, indefinite;
-  unsigned long tag;
-  unsigned char class;
-
-  counter = indefinite = 0;
-
-  while (1)
-    {
-      if ((*len) < counter)
-       return ASN1_DER_ERROR;
-
-      if ((der[counter] == 0) && (der[counter + 1] == 0))
-       {
-         counter += 2;
-         indefinite--;
-         if (indefinite <= 0)
-           break;
-         else
-           continue;
-       }
-
-      if (asn1_get_tag_der
-         (der + counter, *len - counter, &class, &len2,
-          &tag) != ASN1_SUCCESS)
-       return ASN1_DER_ERROR;
-      if (counter + len2 > *len)
-       return ASN1_DER_ERROR;
-      counter += len2;
-      len2 = asn1_get_length_der (der + counter, *len - counter, &len3);
-      if (len2 < -1)
-       return ASN1_DER_ERROR;
-      if (len2 == -1)
-       {
-         indefinite++;
-         counter += 1;
-       }
-      else
-       {
-         counter += len2 + len3;
-       }
-    }
-
-  *len = counter;
-  return ASN1_SUCCESS;
-
-}
-
-/**
- * asn1_der_decoding:
- * @element: pointer to an ASN1 structure.
- * @ider: vector that contains the DER encoding.
- * @len: number of bytes of address@hidden: @address@hidden
- * @errorDescription: null-terminated string contains details when an
- *   error occurred.
- *
- * Fill the structure address@hidden with values of a DER encoding
- * string. The structure must just be created with function
- * asn1_create_element().  If an error occurs during the decoding
- * procedure, the address@hidden is deleted and set equal to
- * %ASN1_TYPE_EMPTY.
- *
- * Returns: %ASN1_SUCCESS if DER encoding OK, %ASN1_ELEMENT_NOT_FOUND
- *   if @ELEMENT is %ASN1_TYPE_EMPTY, and %ASN1_TAG_ERROR or
- *   %ASN1_DER_ERROR if the der encoding doesn't match the structure
- *   name (address@hidden deleted).
- **/
-asn1_retCode
-asn1_der_decoding (ASN1_TYPE * element, const void *ider, int len,
-                  char *errorDescription)
-{
-  ASN1_TYPE node, p, p2, p3;
-  char temp[128];
-  int counter, len2, len3, len4, move, ris, tlen;
-  unsigned char class;
-  unsigned long tag;
-  int indefinite, result;
-  const unsigned char *der = ider;
-
-  node = *element;
-
-  if (node == ASN1_TYPE_EMPTY)
-    return ASN1_ELEMENT_NOT_FOUND;
-
-  if (node->type & CONST_OPTION)
-    {
-      result = ASN1_GENERIC_ERROR;
-      goto cleanup;
-    }
-
-  counter = 0;
-  move = DOWN;
-  p = node;
-  while (1)
-    {
-      ris = ASN1_SUCCESS;
-      if (move != UP)
-       {
-         if (p->type & CONST_SET)
-           {
-             p2 = _asn1_find_up (p);
-             len2 = _asn1_strtol (p2->value, NULL, 10);
-             if (len2 == -1)
-               {
-                 if (!der[counter] && !der[counter + 1])
-                   {
-                     p = p2;
-                     move = UP;
-                     counter += 2;
-                     continue;
-                   }
-               }
-             else if (counter == len2)
-               {
-                 p = p2;
-                 move = UP;
-                 continue;
-               }
-             else if (counter > len2)
-               {
-                 result = ASN1_DER_ERROR;
-                 goto cleanup;
-               }
-             p2 = p2->down;
-             while (p2)
-               {
-                 if ((p2->type & CONST_SET) && (p2->type & CONST_NOT_USED))
-                   {
-                     if (type_field (p2->type) != TYPE_CHOICE)
-                       ris =
-                         _asn1_extract_tag_der (p2, der + counter,
-                                                len - counter, &len2);
-                     else
-                       {
-                         p3 = p2->down;
-                         while (p3)
-                           {
-                             ris =
-                               _asn1_extract_tag_der (p3, der + counter,
-                                                      len - counter, &len2);
-                             if (ris == ASN1_SUCCESS)
-                               break;
-                             p3 = p3->right;
-                           }
-                       }
-                     if (ris == ASN1_SUCCESS)
-                       {
-                         p2->type &= ~CONST_NOT_USED;
-                         p = p2;
-                         break;
-                       }
-                   }
-                 p2 = p2->right;
-               }
-             if (p2 == NULL)
-               {
-                 result = ASN1_DER_ERROR;
-                 goto cleanup;
-               }
-           }
-
-         if ((p->type & CONST_OPTION) || (p->type & CONST_DEFAULT))
-           {
-             p2 = _asn1_find_up (p);
-             len2 = _asn1_strtol (p2->value, NULL, 10);
-             if (counter == len2)
-               {
-                 if (p->right)
-                   {
-                     p2 = p->right;
-                     move = RIGHT;
-                   }
-                 else
-                   move = UP;
-
-                 if (p->type & CONST_OPTION)
-                   asn1_delete_structure (&p);
-
-                 p = p2;
-                 continue;
-               }
-           }
-
-         if (type_field (p->type) == TYPE_CHOICE)
-           {
-             while (p->down)
-               {
-                 if (counter < len)
-                   ris =
-                     _asn1_extract_tag_der (p->down, der + counter,
-                                            len - counter, &len2);
-                 else
-                   ris = ASN1_DER_ERROR;
-                 if (ris == ASN1_SUCCESS)
-                   {
-                     while (p->down->right)
-                       {
-                         p2 = p->down->right;
-                         asn1_delete_structure (&p2);
-                       }
-                     break;
-                   }
-                 else if (ris == ASN1_ERROR_TYPE_ANY)
-                   {
-                     result = ASN1_ERROR_TYPE_ANY;
-                     goto cleanup;
-                   }
-                 else
-                   {
-                     p2 = p->down;
-                     asn1_delete_structure (&p2);
-                   }
-               }
-
-             if (p->down == NULL)
-               {
-                 if (!(p->type & CONST_OPTION))
-                   {
-                     result = ASN1_DER_ERROR;
-                     goto cleanup;
-                   }
-               }
-             else
-               p = p->down;
-           }
-
-         if ((p->type & CONST_OPTION) || (p->type & CONST_DEFAULT))
-           {
-             p2 = _asn1_find_up (p);
-             len2 = _asn1_strtol (p2->value, NULL, 10);
-             if ((len2 != -1) && (counter > len2))
-               ris = ASN1_TAG_ERROR;
-           }
-
-         if (ris == ASN1_SUCCESS)
-           ris =
-             _asn1_extract_tag_der (p, der + counter, len - counter, &len2);
-         if (ris != ASN1_SUCCESS)
-           {
-             if (p->type & CONST_OPTION)
-               {
-                 p->type |= CONST_NOT_USED;
-                 move = RIGHT;
-               }
-             else if (p->type & CONST_DEFAULT)
-               {
-                 _asn1_set_value (p, NULL, 0);
-                 move = RIGHT;
-               }
-             else
-               {
-                 if (errorDescription != NULL)
-                   _asn1_error_description_tag_error (p, errorDescription);
-
-                 result = ASN1_TAG_ERROR;
-                 goto cleanup;
-               }
-           }
-         else
-           counter += len2;
-       }
-
-      if (ris == ASN1_SUCCESS)
-       {
-         switch (type_field (p->type))
-           {
-           case TYPE_NULL:
-             if (der[counter])
-               {
-                 result = ASN1_DER_ERROR;
-                 goto cleanup;
-               }
-             counter++;
-             move = RIGHT;
-             break;
-           case TYPE_BOOLEAN:
-             if (der[counter++] != 1)
-               {
-                 result = ASN1_DER_ERROR;
-                 goto cleanup;
-               }
-             if (der[counter++] == 0)
-               _asn1_set_value (p, "F", 1);
-             else
-               _asn1_set_value (p, "T", 1);
-             move = RIGHT;
-             break;
-           case TYPE_INTEGER:
-           case TYPE_ENUMERATED:
-             len2 =
-               asn1_get_length_der (der + counter, len - counter, &len3);
-             if (len2 < 0)
-               {
-                 result = ASN1_DER_ERROR;
-                 goto cleanup;
-               }
-
-             _asn1_set_value (p, der + counter, len3 + len2);
-             counter += len3 + len2;
-             move = RIGHT;
-             break;
-           case TYPE_OBJECT_ID:
-             result =
-               _asn1_get_objectid_der (der + counter, len - counter, &len2,
-                                       temp, sizeof (temp));
-             if (result != ASN1_SUCCESS)
-               goto cleanup;
-
-             tlen = strlen (temp);
-             if (tlen > 0)
-               _asn1_set_value (p, temp, tlen + 1);
-             counter += len2;
-             move = RIGHT;
-             break;
-           case TYPE_TIME:
-             result =
-               _asn1_get_time_der (der + counter, len - counter, &len2, temp,
-                                   sizeof (temp) - 1);
-             if (result != ASN1_SUCCESS)
-               goto cleanup;
-
-             tlen = strlen (temp);
-             if (tlen > 0)
-               _asn1_set_value (p, temp, tlen + 1);
-             counter += len2;
-             move = RIGHT;
-             break;
-           case TYPE_OCTET_STRING:
-             len3 = len - counter;
-             result = _asn1_get_octet_string (der + counter, p, &len3);
-             if (result != ASN1_SUCCESS)
-               goto cleanup;
-
-             counter += len3;
-             move = RIGHT;
-             break;
-           case TYPE_GENERALSTRING:
-             len2 =
-               asn1_get_length_der (der + counter, len - counter, &len3);
-             if (len2 < 0)
-               {
-                 result = ASN1_DER_ERROR;
-                 goto cleanup;
-               }
-
-             _asn1_set_value (p, der + counter, len3 + len2);
-             counter += len3 + len2;
-             move = RIGHT;
-             break;
-           case TYPE_BIT_STRING:
-             len2 =
-               asn1_get_length_der (der + counter, len - counter, &len3);
-             if (len2 < 0)
-               {
-                 result = ASN1_DER_ERROR;
-                 goto cleanup;
-               }
-
-             _asn1_set_value (p, der + counter, len3 + len2);
-             counter += len3 + len2;
-             move = RIGHT;
-             break;
-           case TYPE_SEQUENCE:
-           case TYPE_SET:
-             if (move == UP)
-               {
-                 len2 = _asn1_strtol (p->value, NULL, 10);
-                 _asn1_set_value (p, NULL, 0);
-                 if (len2 == -1)
-                   {           /* indefinite length method */
-                     if (len - counter + 1 > 0)
-                       {
-                         if ((der[counter]) || der[counter + 1])
-                           {
-                             result = ASN1_DER_ERROR;
-                             goto cleanup;
-                           }
-                       }
-                     else
-                       {
-                         result = ASN1_DER_ERROR;
-                         goto cleanup;
-                       }
-                     counter += 2;
-                   }
-                 else
-                   {           /* definite length method */
-                     if (len2 != counter)
-                       {
-                         result = ASN1_DER_ERROR;
-                         goto cleanup;
-                       }
-                   }
-                 move = RIGHT;
-               }
-             else
-               {               /* move==DOWN || move==RIGHT */
-                 len3 =
-                   asn1_get_length_der (der + counter, len - counter, &len2);
-                 if (len3 < -1)
-                   {
-                     result = ASN1_DER_ERROR;
-                     goto cleanup;
-                   }
-                 counter += len2;
-                 if (len3 > 0)
-                   {
-                     _asn1_ltostr (counter + len3, temp);
-                     tlen = strlen (temp);
-                     if (tlen > 0)
-                       _asn1_set_value (p, temp, tlen + 1);
-                     move = DOWN;
-                   }
-                 else if (len3 == 0)
-                   {
-                     p2 = p->down;
-                     while (p2)
-                       {
-                         if (type_field (p2->type) != TYPE_TAG)
-                           {
-                             p3 = p2->right;
-                             asn1_delete_structure (&p2);
-                             p2 = p3;
-                           }
-                         else
-                           p2 = p2->right;
-                       }
-                     move = RIGHT;
-                   }
-                 else
-                   {           /* indefinite length method */
-                     _asn1_set_value (p, "-1", 3);
-                     move = DOWN;
-                   }
-               }
-             break;
-           case TYPE_SEQUENCE_OF:
-           case TYPE_SET_OF:
-             if (move == UP)
-               {
-                 len2 = _asn1_strtol (p->value, NULL, 10);
-                 if (len2 == -1)
-                   {           /* indefinite length method */
-                     if ((counter + 2) > len)
-                       {
-                         result = ASN1_DER_ERROR;
-                         goto cleanup;
-                       }
-
-                     if ((der[counter]) || der[counter + 1])
-                       {
-                         _asn1_append_sequence_set (p);
-                         p = p->down;
-                         while (p->right)
-                           p = p->right;
-                         move = RIGHT;
-                         continue;
-                       }
-                     _asn1_set_value (p, NULL, 0);
-                     counter += 2;
-                   }
-                 else
-                   {           /* definite length method */
-                     if (len2 > counter)
-                       {
-                         _asn1_append_sequence_set (p);
-                         p = p->down;
-                         while (p->right)
-                           p = p->right;
-                         move = RIGHT;
-                         continue;
-                       }
-                     _asn1_set_value (p, NULL, 0);
-                     if (len2 != counter)
-                       {
-                         result = ASN1_DER_ERROR;
-                         goto cleanup;
-                       }
-                   }
-               }
-             else
-               {               /* move==DOWN || move==RIGHT */
-                 len3 =
-                   asn1_get_length_der (der + counter, len - counter, &len2);
-                 if (len3 < -1)
-                   {
-                     result = ASN1_DER_ERROR;
-                     goto cleanup;
-                   }
-                 counter += len2;
-                 if (len3)
-                   {
-                     if (len3 > 0)
-                       {       /* definite length method */
-                         _asn1_ltostr (counter + len3, temp);
-                         tlen = strlen (temp);
-
-                         if (tlen > 0)
-                           _asn1_set_value (p, temp, tlen + 1);
-                       }
-                     else
-                       {       /* indefinite length method */
-                         _asn1_set_value (p, "-1", 3);
-                       }
-                     p2 = p->down;
-                     while ((type_field (p2->type) == TYPE_TAG)
-                            || (type_field (p2->type) == TYPE_SIZE))
-                       p2 = p2->right;
-                     if (p2->right == NULL)
-                       _asn1_append_sequence_set (p);
-                     p = p2;
-                   }
-               }
-             move = RIGHT;
-             break;
-           case TYPE_ANY:
-             if (asn1_get_tag_der
-                 (der + counter, len - counter, &class, &len2,
-                  &tag) != ASN1_SUCCESS)
-               {
-                 result = ASN1_DER_ERROR;
-                 goto cleanup;
-               }
-
-             if (counter + len2 > len)
-               {
-                 result = ASN1_DER_ERROR;
-                 goto cleanup;
-               }
-             len4 =
-               asn1_get_length_der (der + counter + len2,
-                                    len - counter - len2, &len3);
-             if (len4 < -1)
-               {
-                 result = ASN1_DER_ERROR;
-                 goto cleanup;
-               }
-             if (len4 != -1)
-               {
-                 len2 += len4;
-                 _asn1_set_value_octet (p, der + counter, len2 + len3);
-                 counter += len2 + len3;
-               }
-             else
-               {               /* indefinite length */
-                 /* Check indefinite lenth method in an EXPLICIT TAG */
-                 if ((p->type & CONST_TAG) && (der[counter - 1] == 0x80))
-                   indefinite = 1;
-                 else
-                   indefinite = 0;
-
-                 len2 = len - counter;
-                 result =
-                   _asn1_get_indefinite_length_string (der + counter, &len2);
-                 if (result != ASN1_SUCCESS)
-                   goto cleanup;
-
-                 _asn1_set_value_octet (p, der + counter, len2);
-                 counter += len2;
-
-                 /* Check if a couple of 0x00 are present due to an EXPLICIT 
TAG with
-                    an indefinite length method. */
-                 if (indefinite)
-                   {
-                     if (!der[counter] && !der[counter + 1])
-                       {
-                         counter += 2;
-                       }
-                     else
-                       {
-                         result = ASN1_DER_ERROR;
-                         goto cleanup;
-                       }
-                   }
-               }
-             move = RIGHT;
-             break;
-           default:
-             move = (move == UP) ? RIGHT : DOWN;
-             break;
-           }
-       }
-
-      if (p == node && move != DOWN)
-       break;
-
-      if (move == DOWN)
-       {
-         if (p->down)
-           p = p->down;
-         else
-           move = RIGHT;
-       }
-      if ((move == RIGHT) && !(p->type & CONST_SET))
-       {
-         if (p->right)
-           p = p->right;
-         else
-           move = UP;
-       }
-      if (move == UP)
-       p = _asn1_find_up (p);
-    }
-
-  _asn1_delete_not_used (*element);
-
-  if (counter != len)
-    {
-      result = ASN1_DER_ERROR;
-      goto cleanup;
-    }
-
-  return ASN1_SUCCESS;
-
-cleanup:
-  asn1_delete_structure (element);
-  return result;
-}
-
-#define FOUND        1
-#define SAME_BRANCH  2
-#define OTHER_BRANCH 3
-#define EXIT         4
-
-/**
- * asn1_der_decoding_element:
- * @structure: pointer to an ASN1 structure
- * @elementName: name of the element to fill
- * @ider: vector that contains the DER encoding of the whole structure.
- * @len: number of bytes of *der: der[0]..der[len-1]
- * @errorDescription: null-terminated string contains details when an
- *   error occurred.
- *
- * Fill the element named @ELEMENTNAME with values of a DER encoding
- * string.  The structure must just be created with function
- * asn1_create_element().  The DER vector must contain the encoding
- * string of the whole @STRUCTURE.  If an error occurs during the
- * decoding procedure, the address@hidden is deleted and set equal to
- * %ASN1_TYPE_EMPTY.
- *
- * Returns: %ASN1_SUCCESS if DER encoding OK, %ASN1_ELEMENT_NOT_FOUND
- *   if ELEMENT is %ASN1_TYPE_EMPTY or @elementName == NULL, and
- *   %ASN1_TAG_ERROR or %ASN1_DER_ERROR if the der encoding doesn't
- *   match the structure @structure (*ELEMENT deleted).
- **/
-asn1_retCode
-asn1_der_decoding_element (ASN1_TYPE * structure, const char *elementName,
-                          const void *ider, int len, char *errorDescription)
-{
-  ASN1_TYPE node, p, p2, p3, nodeFound = ASN1_TYPE_EMPTY;
-  char temp[128], currentName[ASN1_MAX_NAME_SIZE * 10], *dot_p, *char_p;
-  int nameLen = ASN1_MAX_NAME_SIZE * 10 - 1, state;
-  int counter, len2, len3, len4, move, ris, tlen;
-  unsigned char class;
-  unsigned long tag;
-  int indefinite, result;
-  const unsigned char *der = ider;
-
-  node = *structure;
-
-  if (node == ASN1_TYPE_EMPTY)
-    return ASN1_ELEMENT_NOT_FOUND;
-
-  if (elementName == NULL)
-    {
-      result = ASN1_ELEMENT_NOT_FOUND;
-      goto cleanup;
-    }
-
-  if (node->type & CONST_OPTION)
-    {
-      result = ASN1_GENERIC_ERROR;
-      goto cleanup;
-    }
-
-  if ((*structure)->name)
-    {                          /* Has *structure got a name? */
-      nameLen -= strlen ((*structure)->name);
-      if (nameLen > 0)
-       strcpy (currentName, (*structure)->name);
-      else
-       {
-         result = ASN1_MEM_ERROR;
-         goto cleanup;
-       }
-      if (!(strcmp (currentName, elementName)))
-       {
-         state = FOUND;
-         nodeFound = *structure;
-       }
-      else if (!memcmp (currentName, elementName, strlen (currentName)))
-       state = SAME_BRANCH;
-      else
-       state = OTHER_BRANCH;
-    }
-  else
-    {                          /* *structure doesn't have a name? */
-      currentName[0] = 0;
-      if (elementName[0] == 0)
-       {
-         state = FOUND;
-         nodeFound = *structure;
-       }
-      else
-       {
-         state = SAME_BRANCH;
-       }
-    }
-
-  counter = 0;
-  move = DOWN;
-  p = node;
-  while (1)
-    {
-
-      ris = ASN1_SUCCESS;
-
-      if (move != UP)
-       {
-         if (p->type & CONST_SET)
-           {
-             p2 = _asn1_find_up (p);
-             len2 = _asn1_strtol (p2->value, NULL, 10);
-             if (counter == len2)
-               {
-                 p = p2;
-                 move = UP;
-                 continue;
-               }
-             else if (counter > len2)
-               {
-                 result = ASN1_DER_ERROR;
-                 goto cleanup;
-               }
-             p2 = p2->down;
-             while (p2)
-               {
-                 if ((p2->type & CONST_SET) && (p2->type & CONST_NOT_USED))
-                   {
-                     if (type_field (p2->type) != TYPE_CHOICE)
-                       ris =
-                         _asn1_extract_tag_der (p2, der + counter,
-                                                len - counter, &len2);
-                     else
-                       {
-                         p3 = p2->down;
-                         while (p3)
-                           {
-                             ris =
-                               _asn1_extract_tag_der (p3, der + counter,
-                                                      len - counter, &len2);
-                             if (ris == ASN1_SUCCESS)
-                               break;
-                             p3 = p3->right;
-                           }
-                       }
-                     if (ris == ASN1_SUCCESS)
-                       {
-                         p2->type &= ~CONST_NOT_USED;
-                         p = p2;
-                         break;
-                       }
-                   }
-                 p2 = p2->right;
-               }
-             if (p2 == NULL)
-               {
-                 result = ASN1_DER_ERROR;
-                 goto cleanup;
-               }
-           }
-
-         if ((p->type & CONST_OPTION) || (p->type & CONST_DEFAULT))
-           {
-             p2 = _asn1_find_up (p);
-             len2 = _asn1_strtol (p2->value, NULL, 10);
-             if (counter == len2)
-               {
-                 if (p->right)
-                   {
-                     p2 = p->right;
-                     move = RIGHT;
-                   }
-                 else
-                   move = UP;
-
-                 if (p->type & CONST_OPTION)
-                   asn1_delete_structure (&p);
-
-                 p = p2;
-                 continue;
-               }
-           }
-
-         if (type_field (p->type) == TYPE_CHOICE)
-           {
-             while (p->down)
-               {
-                 if (counter < len)
-                   ris =
-                     _asn1_extract_tag_der (p->down, der + counter,
-                                            len - counter, &len2);
-                 else
-                   ris = ASN1_DER_ERROR;
-                 if (ris == ASN1_SUCCESS)
-                   {
-                     while (p->down->right)
-                       {
-                         p2 = p->down->right;
-                         asn1_delete_structure (&p2);
-                       }
-                     break;
-                   }
-                 else if (ris == ASN1_ERROR_TYPE_ANY)
-                   {
-                     result = ASN1_ERROR_TYPE_ANY;
-                     goto cleanup;
-                   }
-                 else
-                   {
-                     p2 = p->down;
-                     asn1_delete_structure (&p2);
-                   }
-               }
-
-             if (p->down == NULL)
-               {
-                 if (!(p->type & CONST_OPTION))
-                   {
-                     result = ASN1_DER_ERROR;
-                     goto cleanup;
-                   }
-               }
-             else
-               p = p->down;
-           }
-
-         if ((p->type & CONST_OPTION) || (p->type & CONST_DEFAULT))
-           {
-             p2 = _asn1_find_up (p);
-             len2 = _asn1_strtol (p2->value, NULL, 10);
-             if (counter > len2)
-               ris = ASN1_TAG_ERROR;
-           }
-
-         if (ris == ASN1_SUCCESS)
-           ris =
-             _asn1_extract_tag_der (p, der + counter, len - counter, &len2);
-         if (ris != ASN1_SUCCESS)
-           {
-             if (p->type & CONST_OPTION)
-               {
-                 p->type |= CONST_NOT_USED;
-                 move = RIGHT;
-               }
-             else if (p->type & CONST_DEFAULT)
-               {
-                 _asn1_set_value (p, NULL, 0);
-                 move = RIGHT;
-               }
-             else
-               {
-                 if (errorDescription != NULL)
-                   _asn1_error_description_tag_error (p, errorDescription);
-
-                 result = ASN1_TAG_ERROR;
-                 goto cleanup;
-               }
-           }
-         else
-           counter += len2;
-       }
-
-      if (ris == ASN1_SUCCESS)
-       {
-         switch (type_field (p->type))
-           {
-           case TYPE_NULL:
-             if (der[counter])
-               {
-                 result = ASN1_DER_ERROR;
-                 goto cleanup;
-               }
-
-             if (p == nodeFound)
-               state = EXIT;
-
-             counter++;
-             move = RIGHT;
-             break;
-           case TYPE_BOOLEAN:
-             if (der[counter++] != 1)
-               {
-                 result = ASN1_DER_ERROR;
-                 goto cleanup;
-               }
-
-             if (state == FOUND)
-               {
-                 if (der[counter++] == 0)
-                   _asn1_set_value (p, "F", 1);
-                 else
-                   _asn1_set_value (p, "T", 1);
-
-                 if (p == nodeFound)
-                   state = EXIT;
-
-               }
-             else
-               counter++;
-
-             move = RIGHT;
-             break;
-           case TYPE_INTEGER:
-           case TYPE_ENUMERATED:
-             len2 =
-               asn1_get_length_der (der + counter, len - counter, &len3);
-             if (len2 < 0)
-               {
-                 result = ASN1_DER_ERROR;
-                 goto cleanup;
-               }
-
-             if (state == FOUND)
-               {
-                 if (len3 + len2 > len - counter)
-                   {
-                     result = ASN1_DER_ERROR;
-                     goto cleanup;
-                   }
-                 _asn1_set_value (p, der + counter, len3 + len2);
-
-                 if (p == nodeFound)
-                   state = EXIT;
-               }
-             counter += len3 + len2;
-             move = RIGHT;
-             break;
-           case TYPE_OBJECT_ID:
-             if (state == FOUND)
-               {
-                 result =
-                   _asn1_get_objectid_der (der + counter, len - counter,
-                                           &len2, temp, sizeof (temp));
-                 if (result != ASN1_SUCCESS)
-                   goto cleanup;
-
-                 tlen = strlen (temp);
-
-                 if (tlen > 0)
-                   _asn1_set_value (p, temp, tlen + 1);
-
-                 if (p == nodeFound)
-                   state = EXIT;
-               }
-             else
-               {
-                 len2 =
-                   asn1_get_length_der (der + counter, len - counter, &len3);
-                 if (len2 < 0)
-                   {
-                     result = ASN1_DER_ERROR;
-                     goto cleanup;
-                   }
-                 len2 += len3;
-               }
-
-             counter += len2;
-             move = RIGHT;
-             break;
-           case TYPE_TIME:
-             if (state == FOUND)
-               {
-                 result =
-                   _asn1_get_time_der (der + counter, len - counter, &len2,
-                                       temp, sizeof (temp) - 1);
-                 if (result != ASN1_SUCCESS)
-                   goto cleanup;
-
-                 tlen = strlen (temp);
-                 if (tlen > 0)
-                   _asn1_set_value (p, temp, tlen + 1);
-
-                 if (p == nodeFound)
-                   state = EXIT;
-               }
-             else
-               {
-                 len2 =
-                   asn1_get_length_der (der + counter, len - counter, &len3);
-                 if (len2 < 0)
-                   {
-                     result = ASN1_DER_ERROR;
-                     goto cleanup;
-                   }
-                 len2 += len3;
-               }
-
-             counter += len2;
-             move = RIGHT;
-             break;
-           case TYPE_OCTET_STRING:
-             len3 = len - counter;
-             if (state == FOUND)
-               {
-                 result = _asn1_get_octet_string (der + counter, p, &len3);
-                 if (p == nodeFound)
-                   state = EXIT;
-               }
-             else
-               result = _asn1_get_octet_string (der + counter, NULL, &len3);
-
-             if (result != ASN1_SUCCESS)
-               goto cleanup;
-
-             counter += len3;
-             move = RIGHT;
-             break;
-           case TYPE_GENERALSTRING:
-             len2 =
-               asn1_get_length_der (der + counter, len - counter, &len3);
-             if (len2 < 0)
-               {
-                 result = ASN1_DER_ERROR;
-                 goto cleanup;
-               }
-
-             if (state == FOUND)
-               {
-                 if (len3 + len2 > len - counter)
-                   {
-                     result = ASN1_DER_ERROR;
-                     goto cleanup;
-                   }
-                 _asn1_set_value (p, der + counter, len3 + len2);
-
-                 if (p == nodeFound)
-                   state = EXIT;
-               }
-             counter += len3 + len2;
-             move = RIGHT;
-             break;
-           case TYPE_BIT_STRING:
-             len2 =
-               asn1_get_length_der (der + counter, len - counter, &len3);
-             if (len2 < 0)
-               {
-                 result = ASN1_DER_ERROR;
-                 goto cleanup;
-               }
-             if (state == FOUND)
-               {
-                 if (len3 + len2 > len - counter)
-                   {
-                     result = ASN1_DER_ERROR;
-                     goto cleanup;
-                   }
-                 _asn1_set_value (p, der + counter, len3 + len2);
-
-                 if (p == nodeFound)
-                   state = EXIT;
-               }
-             counter += len3 + len2;
-             move = RIGHT;
-             break;
-           case TYPE_SEQUENCE:
-           case TYPE_SET:
-             if (move == UP)
-               {
-                 len2 = _asn1_strtol (p->value, NULL, 10);
-                 _asn1_set_value (p, NULL, 0);
-                 if (len2 == -1)
-                   {           /* indefinite length method */
-                     if ((der[counter]) || der[counter + 1])
-                       {
-                         result = ASN1_DER_ERROR;
-                         goto cleanup;
-                       }
-                     counter += 2;
-                   }
-                 else
-                   {           /* definite length method */
-                     if (len2 != counter)
-                       {
-                         result = ASN1_DER_ERROR;
-                         goto cleanup;
-                       }
-                   }
-                 if (p == nodeFound)
-                   state = EXIT;
-                 move = RIGHT;
-               }
-             else
-               {               /* move==DOWN || move==RIGHT */
-                 if (state == OTHER_BRANCH)
-                   {
-                     len3 =
-                       asn1_get_length_der (der + counter, len - counter,
-                                            &len2);
-                     if (len3 < 0)
-                       {
-                         result = ASN1_DER_ERROR;
-                         goto cleanup;
-                       }
-                     counter += len2 + len3;
-                     move = RIGHT;
-                   }
-                 else
-                   {           /*  state==SAME_BRANCH or state==FOUND */
-                     len3 =
-                       asn1_get_length_der (der + counter, len - counter,
-                                            &len2);
-                     if (len3 < 0)
-                       {
-                         result = ASN1_DER_ERROR;
-                         goto cleanup;
-                       }
-                     counter += len2;
-                     if (len3 > 0)
-                       {
-                         _asn1_ltostr (counter + len3, temp);
-                         tlen = strlen (temp);
-
-                         if (tlen > 0)
-                           _asn1_set_value (p, temp, tlen + 1);
-                         move = DOWN;
-                       }
-                     else if (len3 == 0)
-                       {
-                         p2 = p->down;
-                         while (p2)
-                           {
-                             if (type_field (p2->type) != TYPE_TAG)
-                               {
-                                 p3 = p2->right;
-                                 asn1_delete_structure (&p2);
-                                 p2 = p3;
-                               }
-                             else
-                               p2 = p2->right;
-                           }
-                         move = RIGHT;
-                       }
-                     else
-                       {       /* indefinite length method */
-                         _asn1_set_value (p, "-1", 3);
-                         move = DOWN;
-                       }
-                   }
-               }
-             break;
-           case TYPE_SEQUENCE_OF:
-           case TYPE_SET_OF:
-             if (move == UP)
-               {
-                 len2 = _asn1_strtol (p->value, NULL, 10);
-                 if (len2 > counter)
-                   {
-                     _asn1_append_sequence_set (p);
-                     p = p->down;
-                     while (p->right)
-                       p = p->right;
-                     move = RIGHT;
-                     continue;
-                   }
-                 _asn1_set_value (p, NULL, 0);
-                 if (len2 != counter)
-                   {
-                     result = ASN1_DER_ERROR;
-                     goto cleanup;
-                   }
-
-                 if (p == nodeFound)
-                   state = EXIT;
-               }
-             else
-               {               /* move==DOWN || move==RIGHT */
-                 if (state == OTHER_BRANCH)
-                   {
-                     len3 =
-                       asn1_get_length_der (der + counter, len - counter,
-                                            &len2);
-                     if (len3 < 0)
-                       {
-                         result = ASN1_DER_ERROR;
-                         goto cleanup;
-                       }
-                     counter += len2 + len3;
-                     move = RIGHT;
-                   }
-                 else
-                   {           /* state==FOUND or state==SAME_BRANCH */
-                     len3 =
-                       asn1_get_length_der (der + counter, len - counter,
-                                            &len2);
-                     if (len3 < 0)
-                       {
-                         result = ASN1_DER_ERROR;
-                         goto cleanup;
-                       }
-                     counter += len2;
-                     if (len3)
-                       {
-                         _asn1_ltostr (counter + len3, temp);
-                         tlen = strlen (temp);
-
-                         if (tlen > 0)
-                           _asn1_set_value (p, temp, tlen + 1);
-                         p2 = p->down;
-                         while ((type_field (p2->type) == TYPE_TAG)
-                                || (type_field (p2->type) == TYPE_SIZE))
-                           p2 = p2->right;
-                         if (p2->right == NULL)
-                           _asn1_append_sequence_set (p);
-                         p = p2;
-                         state = FOUND;
-                       }
-                   }
-               }
-
-             break;
-           case TYPE_ANY:
-             if (asn1_get_tag_der
-                 (der + counter, len - counter, &class, &len2,
-                  &tag) != ASN1_SUCCESS)
-               {
-                 result = ASN1_DER_ERROR;
-                 goto cleanup;
-               }
-
-             if (counter + len2 > len)
-               {
-                 result = ASN1_DER_ERROR;
-                 goto cleanup;
-               }
-
-             len4 =
-               asn1_get_length_der (der + counter + len2,
-                                    len - counter - len2, &len3);
-             if (len4 < -1)
-               {
-                 result = ASN1_DER_ERROR;
-                 goto cleanup;
-               }
-
-             if (len4 != -1)
-               {
-                 len2 += len4;
-                 if (state == FOUND)
-                   {
-                     _asn1_set_value_octet (p, der + counter, len2 + len3);
-
-                     if (p == nodeFound)
-                       state = EXIT;
-                   }
-                 counter += len2 + len3;
-               }
-             else
-               {               /* indefinite length */
-                 /* Check indefinite lenth method in an EXPLICIT TAG */
-                 if ((p->type & CONST_TAG) && (der[counter - 1] == 0x80))
-                   indefinite = 1;
-                 else
-                   indefinite = 0;
-
-                 len2 = len - counter;
-                 result =
-                   _asn1_get_indefinite_length_string (der + counter, &len2);
-                 if (result != ASN1_SUCCESS)
-                   goto cleanup;
-
-                 if (state == FOUND)
-                   {
-                     _asn1_set_value_octet (p, der + counter, len2);
-
-                     if (p == nodeFound)
-                       state = EXIT;
-                   }
-
-                 counter += len2;
-
-                 /* Check if a couple of 0x00 are present due to an EXPLICIT 
TAG with
-                    an indefinite length method. */
-                 if (indefinite)
-                   {
-                     if (!der[counter] && !der[counter + 1])
-                       {
-                         counter += 2;
-                       }
-                     else
-                       {
-                         result = ASN1_DER_ERROR;
-                         goto cleanup;
-                       }
-                   }
-               }
-             move = RIGHT;
-             break;
-
-           default:
-             move = (move == UP) ? RIGHT : DOWN;
-             break;
-           }
-       }
-
-      if ((p == node && move != DOWN) || (state == EXIT))
-       break;
-
-      if (move == DOWN)
-       {
-         if (p->down)
-           {
-             p = p->down;
-
-             if (state != FOUND)
-               {
-                 nameLen -= strlen (p->name) + 1;
-                 if (nameLen > 0)
-                   {
-                     if (currentName[0])
-                       strcat (currentName, ".");
-                     strcat (currentName, p->name);
-                   }
-                 else
-                   {
-                     result = ASN1_MEM_ERROR;
-                     goto cleanup;
-                   }
-                 if (!(strcmp (currentName, elementName)))
-                   {
-                     state = FOUND;
-                     nodeFound = p;
-                   }
-                 else
-                   if (!memcmp
-                       (currentName, elementName, strlen (currentName)))
-                   state = SAME_BRANCH;
-                 else
-                   state = OTHER_BRANCH;
-               }
-           }
-         else
-           move = RIGHT;
-       }
-
-      if ((move == RIGHT) && !(p->type & CONST_SET))
-       {
-         if (p->right)
-           {
-             p = p->right;
-
-             if (state != FOUND)
-               {
-                 dot_p = char_p = currentName;
-                 while ((char_p = strchr (char_p, '.')))
-                   {
-                     dot_p = char_p++;
-                     dot_p++;
-                   }
-
-                 nameLen += strlen (currentName) - (dot_p - currentName);
-                 *dot_p = 0;
-
-                 nameLen -= strlen (p->name);
-                 if (nameLen > 0)
-                   strcat (currentName, p->name);
-                 else
-                   {
-                     result = ASN1_MEM_ERROR;
-                     goto cleanup;
-                   }
-
-                 if (!(strcmp (currentName, elementName)))
-                   {
-                     state = FOUND;
-                     nodeFound = p;
-                   }
-                 else
-                   if (!memcmp
-                       (currentName, elementName, strlen (currentName)))
-                   state = SAME_BRANCH;
-                 else
-                   state = OTHER_BRANCH;
-               }
-           }
-         else
-           move = UP;
-       }
-
-      if (move == UP)
-       {
-         p = _asn1_find_up (p);
-
-         if (state != FOUND)
-           {
-             dot_p = char_p = currentName;
-             while ((char_p = strchr (char_p, '.')))
-               {
-                 dot_p = char_p++;
-                 dot_p++;
-               }
-
-             nameLen += strlen (currentName) - (dot_p - currentName);
-             *dot_p = 0;
-
-             if (!(strcmp (currentName, elementName)))
-               {
-                 state = FOUND;
-                 nodeFound = p;
-               }
-             else
-               if (!memcmp (currentName, elementName, strlen (currentName)))
-               state = SAME_BRANCH;
-             else
-               state = OTHER_BRANCH;
-           }
-       }
-    }
-
-  _asn1_delete_not_used (*structure);
-
-  if (counter > len)
-    {
-      result = ASN1_DER_ERROR;
-      goto cleanup;
-    }
-
-  return ASN1_SUCCESS;
-
-cleanup:
-  asn1_delete_structure (structure);
-  return result;
-}
-
-/**
- * asn1_der_decoding_startEnd:
- * @element: pointer to an ASN1 element
- * @ider: vector that contains the DER encoding.
- * @len: number of bytes of address@hidden: @address@hidden
- * @name_element: an element of NAME structure.
- * @start: the position of the first byte of NAME_ELEMENT decoding
- *   (@ider[*start])
- * @end: the position of the last byte of NAME_ELEMENT decoding
- *  (@ider[*end])
- *
- * Find the start and end point of an element in a DER encoding
- * string. I mean that if you have a der encoding and you have already
- * used the function asn1_der_decoding() to fill a structure, it may
- * happen that you want to find the piece of string concerning an
- * element of the structure.
- *
- * One example is the sequence "tbsCertificate" inside an X509
- * certificate.
- *
- * Returns: %ASN1_SUCCESS if DER encoding OK, %ASN1_ELEMENT_NOT_FOUND
- *   if ELEMENT is %ASN1_TYPE EMPTY or @name_element is not a valid
- *   element, %ASN1_TAG_ERROR or %ASN1_DER_ERROR if the der encoding
- *   doesn't match the structure ELEMENT.
- **/
-asn1_retCode
-asn1_der_decoding_startEnd (ASN1_TYPE element, const void *ider, int len,
-                           const char *name_element, int *start, int *end)
-{
-  ASN1_TYPE node, node_to_find, p, p2, p3;
-  int counter, len2, len3, len4, move, ris;
-  unsigned char class;
-  unsigned long tag;
-  int indefinite;
-  const unsigned char *der = ider;
-
-  node = element;
-
-  if (node == ASN1_TYPE_EMPTY)
-    return ASN1_ELEMENT_NOT_FOUND;
-
-  node_to_find = asn1_find_node (node, name_element);
-
-  if (node_to_find == NULL)
-    return ASN1_ELEMENT_NOT_FOUND;
-
-  if (node_to_find == node)
-    {
-      *start = 0;
-      *end = len - 1;
-      return ASN1_SUCCESS;
-    }
-
-  if (node->type & CONST_OPTION)
-    return ASN1_GENERIC_ERROR;
-
-  counter = 0;
-  move = DOWN;
-  p = node;
-  while (1)
-    {
-      ris = ASN1_SUCCESS;
-
-      if (move != UP)
-       {
-         if (p->type & CONST_SET)
-           {
-             p2 = _asn1_find_up (p);
-             len2 = _asn1_strtol (p2->value, NULL, 10);
-             if (len2 == -1)
-               {
-                 if (!der[counter] && !der[counter + 1])
-                   {
-                     p = p2;
-                     move = UP;
-                     counter += 2;
-                     continue;
-                   }
-               }
-             else if (counter == len2)
-               {
-                 p = p2;
-                 move = UP;
-                 continue;
-               }
-             else if (counter > len2)
-               return ASN1_DER_ERROR;
-             p2 = p2->down;
-             while (p2)
-               {
-                 if ((p2->type & CONST_SET) && (p2->type & CONST_NOT_USED))
-                   {           /* CONTROLLARE */
-                     if (type_field (p2->type) != TYPE_CHOICE)
-                       ris =
-                         _asn1_extract_tag_der (p2, der + counter,
-                                                len - counter, &len2);
-                     else
-                       {
-                         p3 = p2->down;
-                         ris =
-                           _asn1_extract_tag_der (p3, der + counter,
-                                                  len - counter, &len2);
-                       }
-                     if (ris == ASN1_SUCCESS)
-                       {
-                         p2->type &= ~CONST_NOT_USED;
-                         p = p2;
-                         break;
-                       }
-                   }
-                 p2 = p2->right;
-               }
-             if (p2 == NULL)
-               return ASN1_DER_ERROR;
-           }
-
-         if (p == node_to_find)
-           *start = counter;
-
-         if (type_field (p->type) == TYPE_CHOICE)
-           {
-             p = p->down;
-             ris =
-               _asn1_extract_tag_der (p, der + counter, len - counter,
-                                      &len2);
-             if (p == node_to_find)
-               *start = counter;
-           }
-
-         if (ris == ASN1_SUCCESS)
-           ris =
-             _asn1_extract_tag_der (p, der + counter, len - counter, &len2);
-         if (ris != ASN1_SUCCESS)
-           {
-             if (p->type & CONST_OPTION)
-               {
-                 p->type |= CONST_NOT_USED;
-                 move = RIGHT;
-               }
-             else if (p->type & CONST_DEFAULT)
-               {
-                 move = RIGHT;
-               }
-             else
-               {
-                 return ASN1_TAG_ERROR;
-               }
-           }
-         else
-           counter += len2;
-       }
-
-      if (ris == ASN1_SUCCESS)
-       {
-         switch (type_field (p->type))
-           {
-           case TYPE_NULL:
-             if (der[counter])
-               return ASN1_DER_ERROR;
-             counter++;
-             move = RIGHT;
-             break;
-           case TYPE_BOOLEAN:
-             if (der[counter++] != 1)
-               return ASN1_DER_ERROR;
-             counter++;
-             move = RIGHT;
-             break;
-           case TYPE_INTEGER:
-           case TYPE_ENUMERATED:
-             len2 =
-               asn1_get_length_der (der + counter, len - counter, &len3);
-             if (len2 < 0)
-               return ASN1_DER_ERROR;
-             counter += len3 + len2;
-             move = RIGHT;
-             break;
-           case TYPE_OBJECT_ID:
-             len2 =
-               asn1_get_length_der (der + counter, len - counter, &len3);
-             if (len2 < 0)
-               return ASN1_DER_ERROR;
-             counter += len2 + len3;
-             move = RIGHT;
-             break;
-           case TYPE_TIME:
-             len2 =
-               asn1_get_length_der (der + counter, len - counter, &len3);
-             if (len2 < 0)
-               return ASN1_DER_ERROR;
-             counter += len2 + len3;
-             move = RIGHT;
-             break;
-           case TYPE_OCTET_STRING:
-             len3 = len - counter;
-             ris = _asn1_get_octet_string (der + counter, NULL, &len3);
-             if (ris != ASN1_SUCCESS)
-               return ris;
-             counter += len3;
-             move = RIGHT;
-             break;
-           case TYPE_GENERALSTRING:
-             len2 =
-               asn1_get_length_der (der + counter, len - counter, &len3);
-             if (len2 < 0)
-               return ASN1_DER_ERROR;
-             counter += len3 + len2;
-             move = RIGHT;
-             break;
-           case TYPE_BIT_STRING:
-             len2 =
-               asn1_get_length_der (der + counter, len - counter, &len3);
-             if (len2 < 0)
-               return ASN1_DER_ERROR;
-             counter += len3 + len2;
-             move = RIGHT;
-             break;
-           case TYPE_SEQUENCE:
-           case TYPE_SET:
-             if (move != UP)
-               {
-                 len3 =
-                   asn1_get_length_der (der + counter, len - counter, &len2);
-                 if (len3 < -1)
-                   return ASN1_DER_ERROR;
-                 counter += len2;
-                 if (len3 == 0)
-                   move = RIGHT;
-                 else
-                   move = DOWN;
-               }
-             else
-               {
-                 if (!der[counter] && !der[counter + 1])       /* indefinite 
length method */
-                   counter += 2;
-                 move = RIGHT;
-               }
-             break;
-           case TYPE_SEQUENCE_OF:
-           case TYPE_SET_OF:
-             if (move != UP)
-               {
-                 len3 =
-                   asn1_get_length_der (der + counter, len - counter, &len2);
-                 if (len3 < -1)
-                   return ASN1_DER_ERROR;
-                 counter += len2;
-                 if ((len3 == -1) && !der[counter] && !der[counter + 1])
-                   counter += 2;
-                 else if (len3)
-                   {
-                     p2 = p->down;
-                     while ((type_field (p2->type) == TYPE_TAG) ||
-                            (type_field (p2->type) == TYPE_SIZE))
-                       p2 = p2->right;
-                     p = p2;
-                   }
-               }
-             else
-               {
-                 if (!der[counter] && !der[counter + 1])       /* indefinite 
length method */
-                   counter += 2;
-               }
-             move = RIGHT;
-             break;
-           case TYPE_ANY:
-             if (asn1_get_tag_der
-                 (der + counter, len - counter, &class, &len2,
-                  &tag) != ASN1_SUCCESS)
-               return ASN1_DER_ERROR;
-             if (counter + len2 > len)
-               return ASN1_DER_ERROR;
-
-             len4 =
-               asn1_get_length_der (der + counter + len2,
-                                    len - counter - len2, &len3);
-             if (len4 < -1)
-               return ASN1_DER_ERROR;
-
-             if (len4 != -1)
-               {
-                 counter += len2 + len4 + len3;
-               }
-             else
-               {               /* indefinite length */
-                 /* Check indefinite lenth method in an EXPLICIT TAG */
-                 if ((p->type & CONST_TAG) && (der[counter - 1] == 0x80))
-                   indefinite = 1;
-                 else
-                   indefinite = 0;
-
-                 len2 = len - counter;
-                 ris =
-                   _asn1_get_indefinite_length_string (der + counter, &len2);
-                 if (ris != ASN1_SUCCESS)
-                   return ris;
-                 counter += len2;
-
-                 /* Check if a couple of 0x00 are present due to an EXPLICIT 
TAG with
-                    an indefinite length method. */
-                 if (indefinite)
-                   {
-                     if (!der[counter] && !der[counter + 1])
-                       counter += 2;
-                     else
-                       return ASN1_DER_ERROR;
-                   }
-               }
-             move = RIGHT;
-             break;
-           default:
-             move = (move == UP) ? RIGHT : DOWN;
-             break;
-           }
-       }
-
-      if ((p == node_to_find) && (move == RIGHT))
-       {
-         *end = counter - 1;
-         return ASN1_SUCCESS;
-       }
-
-      if (p == node && move != DOWN)
-       break;
-
-      if (move == DOWN)
-       {
-         if (p->down)
-           p = p->down;
-         else
-           move = RIGHT;
-       }
-      if ((move == RIGHT) && !(p->type & CONST_SET))
-       {
-         if (p->right)
-           p = p->right;
-         else
-           move = UP;
-       }
-      if (move == UP)
-       p = _asn1_find_up (p);
-    }
-
-  return ASN1_ELEMENT_NOT_FOUND;
-}
-
-/**
- * asn1_expand_any_defined_by:
- * @definitions: ASN1 definitions
- * @element: pointer to an ASN1 structure
- *
- * Expands every "ANY DEFINED BY" element of a structure created from
- * a DER decoding process (asn1_der_decoding function). The element
- * ANY must be defined by an OBJECT IDENTIFIER. The type used to
- * expand the element ANY is the first one following the definition of
- * the actual value of the OBJECT IDENTIFIER.
- *
- * Returns: %ASN1_SUCCESS if Substitution OK, %ASN1_ERROR_TYPE_ANY if
- *   some "ANY DEFINED BY" element couldn't be expanded due to a
- *   problem in OBJECT_ID -> TYPE association, or other error codes
- *   depending on DER decoding.
- **/
-asn1_retCode
-asn1_expand_any_defined_by (ASN1_TYPE definitions, ASN1_TYPE * element)
-{
-  char definitionsName[ASN1_MAX_NAME_SIZE], name[2 * ASN1_MAX_NAME_SIZE + 1],
-    value[ASN1_MAX_NAME_SIZE];
-  asn1_retCode retCode = ASN1_SUCCESS, result;
-  int len, len2, len3;
-  ASN1_TYPE p, p2, p3, aux = ASN1_TYPE_EMPTY;
-  char errorDescription[ASN1_MAX_ERROR_DESCRIPTION_SIZE];
-
-  if ((definitions == ASN1_TYPE_EMPTY) || (*element == ASN1_TYPE_EMPTY))
-    return ASN1_ELEMENT_NOT_FOUND;
-
-  strcpy (definitionsName, definitions->name);
-  strcat (definitionsName, ".");
-
-  p = *element;
-  while (p)
-    {
-
-      switch (type_field (p->type))
-       {
-       case TYPE_ANY:
-         if ((p->type & CONST_DEFINED_BY) && (p->value))
-           {
-             /* search the "DEF_BY" element */
-             p2 = p->down;
-             while ((p2) && (type_field (p2->type) != TYPE_CONSTANT))
-               p2 = p2->right;
-
-             if (!p2)
-               {
-                 retCode = ASN1_ERROR_TYPE_ANY;
-                 break;
-               }
-
-             p3 = _asn1_find_up (p);
-
-             if (!p3)
-               {
-                 retCode = ASN1_ERROR_TYPE_ANY;
-                 break;
-               }
-
-             p3 = p3->down;
-             while (p3)
-               {
-                 if ((p3->name) && !(strcmp (p3->name, p2->name)))
-                   break;
-                 p3 = p3->right;
-               }
-
-             if ((!p3) || (type_field (p3->type) != TYPE_OBJECT_ID) ||
-                 (p3->value == NULL))
-               {
-
-                 p3 = _asn1_find_up (p);
-                 p3 = _asn1_find_up (p3);
-
-                 if (!p3)
-                   {
-                     retCode = ASN1_ERROR_TYPE_ANY;
-                     break;
-                   }
-
-                 p3 = p3->down;
-
-                 while (p3)
-                   {
-                     if ((p3->name) && !(strcmp (p3->name, p2->name)))
-                       break;
-                     p3 = p3->right;
-                   }
-
-                 if ((!p3) || (type_field (p3->type) != TYPE_OBJECT_ID) ||
-                     (p3->value == NULL))
-                   {
-                     retCode = ASN1_ERROR_TYPE_ANY;
-                     break;
-                   }
-               }
-
-             /* search the OBJECT_ID into definitions */
-             p2 = definitions->down;
-             while (p2)
-               {
-                 if ((type_field (p2->type) == TYPE_OBJECT_ID) &&
-                     (p2->type & CONST_ASSIGN))
-                   {
-                     strcpy (name, definitionsName);
-                     strcat (name, p2->name);
-
-                     len = ASN1_MAX_NAME_SIZE;
-                     result =
-                       asn1_read_value (definitions, name, value, &len);
-
-                     if ((result == ASN1_SUCCESS)
-                         && (!_asn1_strcmp (p3->value, value)))
-                       {
-                         p2 = p2->right;       /* pointer to the structure to
-                                                  use for expansion */
-                         while ((p2) && (p2->type & CONST_ASSIGN))
-                           p2 = p2->right;
-
-                         if (p2)
-                           {
-                             strcpy (name, definitionsName);
-                             strcat (name, p2->name);
-
-                             result =
-                               asn1_create_element (definitions, name, &aux);
-                             if (result == ASN1_SUCCESS)
-                               {
-                                 _asn1_set_name (aux, p->name);
-                                 len2 =
-                                   asn1_get_length_der (p->value,
-                                                        p->value_len, &len3);
-                                 if (len2 < 0)
-                                   return ASN1_DER_ERROR;
-
-                                 result =
-                                   asn1_der_decoding (&aux, p->value + len3,
-                                                      len2,
-                                                      errorDescription);
-                                 if (result == ASN1_SUCCESS)
-                                   {
-
-                                     _asn1_set_right (aux, p->right);
-                                     _asn1_set_right (p, aux);
-
-                                     result = asn1_delete_structure (&p);
-                                     if (result == ASN1_SUCCESS)
-                                       {
-                                         p = aux;
-                                         aux = ASN1_TYPE_EMPTY;
-                                         break;
-                                       }
-                                     else
-                                       {       /* error with 
asn1_delete_structure */
-                                         asn1_delete_structure (&aux);
-                                         retCode = result;
-                                         break;
-                                       }
-                                   }
-                                 else
-                                   {   /* error with asn1_der_decoding */
-                                     retCode = result;
-                                     break;
-                                   }
-                               }
-                             else
-                               {       /* error with asn1_create_element */
-                                 retCode = result;
-                                 break;
-                               }
-                           }
-                         else
-                           {   /* error with the pointer to the structure to 
exapand */
-                             retCode = ASN1_ERROR_TYPE_ANY;
-                             break;
-                           }
-                       }
-                   }
-                 p2 = p2->right;
-               }               /* end while */
-
-             if (!p2)
-               {
-                 retCode = ASN1_ERROR_TYPE_ANY;
-                 break;
-               }
-
-           }
-         break;
-       default:
-         break;
-       }
-
-
-      if (p->down)
-       {
-         p = p->down;
-       }
-      else if (p == *element)
-       {
-         p = NULL;
-         break;
-       }
-      else if (p->right)
-       p = p->right;
-      else
-       {
-         while (1)
-           {
-             p = _asn1_find_up (p);
-             if (p == *element)
-               {
-                 p = NULL;
-                 break;
-               }
-             if (p->right)
-               {
-                 p = p->right;
-                 break;
-               }
-           }
-       }
-    }
-
-  return retCode;
-}
-
-/**
- * asn1_expand_octet_string:
- * @definitions: ASN1 definitions
- * @element: pointer to an ASN1 structure
- * @octetName: name of the OCTECT STRING field to expand.
- * @objectName: name of the OBJECT IDENTIFIER field to use to define
- *    the type for expansion.
- *
- * Expands an "OCTET STRING" element of a structure created from a DER
- * decoding process (the asn1_der_decoding() function).  The type used
- * for expansion is the first one following the definition of the
- * actual value of the OBJECT IDENTIFIER indicated by OBJECTNAME.
- *
- * Returns: %ASN1_SUCCESS if substitution OK, %ASN1_ELEMENT_NOT_FOUND
- *   if @objectName or @octetName are not correct,
- *   %ASN1_VALUE_NOT_VALID if it wasn't possible to find the type to
- *   use for expansion, or other errors depending on DER decoding.
- **/
-asn1_retCode
-asn1_expand_octet_string (ASN1_TYPE definitions, ASN1_TYPE * element,
-                         const char *octetName, const char *objectName)
-{
-  char name[2 * ASN1_MAX_NAME_SIZE + 1], value[ASN1_MAX_NAME_SIZE];
-  asn1_retCode retCode = ASN1_SUCCESS, result;
-  int len, len2, len3;
-  ASN1_TYPE p2, aux = ASN1_TYPE_EMPTY;
-  ASN1_TYPE octetNode = ASN1_TYPE_EMPTY, objectNode = ASN1_TYPE_EMPTY;
-  char errorDescription[ASN1_MAX_ERROR_DESCRIPTION_SIZE];
-
-  if ((definitions == ASN1_TYPE_EMPTY) || (*element == ASN1_TYPE_EMPTY))
-    return ASN1_ELEMENT_NOT_FOUND;
-
-  octetNode = asn1_find_node (*element, octetName);
-  if (octetNode == ASN1_TYPE_EMPTY)
-    return ASN1_ELEMENT_NOT_FOUND;
-  if (type_field (octetNode->type) != TYPE_OCTET_STRING)
-    return ASN1_ELEMENT_NOT_FOUND;
-  if (octetNode->value == NULL)
-    return ASN1_VALUE_NOT_FOUND;
-
-  objectNode = asn1_find_node (*element, objectName);
-  if (objectNode == ASN1_TYPE_EMPTY)
-    return ASN1_ELEMENT_NOT_FOUND;
-
-  if (type_field (objectNode->type) != TYPE_OBJECT_ID)
-    return ASN1_ELEMENT_NOT_FOUND;
-
-  if (objectNode->value == NULL)
-    return ASN1_VALUE_NOT_FOUND;
-
-
-  /* search the OBJECT_ID into definitions */
-  p2 = definitions->down;
-  while (p2)
-    {
-      if ((type_field (p2->type) == TYPE_OBJECT_ID) &&
-         (p2->type & CONST_ASSIGN))
-       {
-         strcpy (name, definitions->name);
-         strcat (name, ".");
-         strcat (name, p2->name);
-
-         len = sizeof (value);
-         result = asn1_read_value (definitions, name, value, &len);
-
-         if ((result == ASN1_SUCCESS)
-             && (!_asn1_strcmp (objectNode->value, value)))
-           {
-
-             p2 = p2->right;   /* pointer to the structure to
-                                  use for expansion */
-             while ((p2) && (p2->type & CONST_ASSIGN))
-               p2 = p2->right;
-
-             if (p2)
-               {
-                 strcpy (name, definitions->name);
-                 strcat (name, ".");
-                 strcat (name, p2->name);
-
-                 result = asn1_create_element (definitions, name, &aux);
-                 if (result == ASN1_SUCCESS)
-                   {
-                     _asn1_set_name (aux, octetNode->name);
-                     len2 =
-                       asn1_get_length_der (octetNode->value,
-                                            octetNode->value_len, &len3);
-                     if (len2 < 0)
-                       return ASN1_DER_ERROR;
-
-                     result =
-                       asn1_der_decoding (&aux, octetNode->value + len3,
-                                          len2, errorDescription);
-                     if (result == ASN1_SUCCESS)
-                       {
-
-                         _asn1_set_right (aux, octetNode->right);
-                         _asn1_set_right (octetNode, aux);
-
-                         result = asn1_delete_structure (&octetNode);
-                         if (result == ASN1_SUCCESS)
-                           {
-                             aux = ASN1_TYPE_EMPTY;
-                             break;
-                           }
-                         else
-                           {   /* error with asn1_delete_structure */
-                             asn1_delete_structure (&aux);
-                             retCode = result;
-                             break;
-                           }
-                       }
-                     else
-                       {       /* error with asn1_der_decoding */
-                         retCode = result;
-                         break;
-                       }
-                   }
-                 else
-                   {           /* error with asn1_create_element */
-                     retCode = result;
-                     break;
-                   }
-               }
-             else
-               {               /* error with the pointer to the structure to 
exapand */
-                 retCode = ASN1_VALUE_NOT_VALID;
-                 break;
-               }
-           }
-       }
-
-      p2 = p2->right;
-
-    }
-
-  if (!p2)
-    retCode = ASN1_VALUE_NOT_VALID;
-
-  return retCode;
-}
diff --git a/asn1/element.c b/asn1/element.c
deleted file mode 100644
index ead899c..0000000
--- a/asn1/element.c
+++ /dev/null
@@ -1,978 +0,0 @@
-/*
- * Copyright (C) 2000-2012 Free Software Foundation, Inc.
- *
- * This file is part of LIBTASN1.
- *
- * The LIBTASN1 library is free software; you can redistribute it
- * and/or modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA
- */
-
-/*****************************************************/
-/* File: element.c                                   */
-/* Description: Functions with the read and write    */
-/*   functions.                                      */
-/*****************************************************/
-
-
-#include <int.h>
-#include "parser_aux.h"
-#include <gstr.h>
-#include "structure.h"
-
-#include "element.h"
-
-void
-_asn1_hierarchical_name (ASN1_TYPE node, char *name, int name_size)
-{
-  ASN1_TYPE p;
-  char tmp_name[64];
-
-  p = node;
-
-  name[0] = 0;
-
-  while (p != NULL)
-    {
-      if (p->name != NULL)
-       {
-         _asn1_str_cpy (tmp_name, sizeof (tmp_name), name),
-           _asn1_str_cpy (name, name_size, p->name);
-         _asn1_str_cat (name, name_size, ".");
-         _asn1_str_cat (name, name_size, tmp_name);
-       }
-      p = _asn1_find_up (p);
-    }
-
-  if (name[0] == 0)
-    _asn1_str_cpy (name, name_size, "ROOT");
-}
-
-
-/******************************************************************/
-/* Function : _asn1_convert_integer                               */
-/* Description: converts an integer from a null terminated string */
-/*              to der decoding. The convertion from a null       */
-/*              terminated string to an integer is made with      */
-/*              the 'strtol' function.                            */
-/* Parameters:                                                    */
-/*   value: null terminated string to convert.                    */
-/*   value_out: convertion result (memory must be already         */
-/*              allocated).                                       */
-/*   value_out_size: number of bytes of value_out.                */
-/*   len: number of significant byte of value_out.                */
-/* Return: ASN1_MEM_ERROR or ASN1_SUCCESS                         */
-/******************************************************************/
-asn1_retCode
-_asn1_convert_integer (const unsigned char *value, unsigned char *value_out,
-                      int value_out_size, int *len)
-{
-  char negative;
-  unsigned char val[SIZEOF_UNSIGNED_LONG_INT];
-  long valtmp;
-  int k, k2;
-
-  valtmp = _asn1_strtol (value, NULL, 10);
-
-  for (k = 0; k < SIZEOF_UNSIGNED_LONG_INT; k++)
-    {
-      val[SIZEOF_UNSIGNED_LONG_INT - k - 1] = (valtmp >> (8 * k)) & 0xFF;
-    }
-
-  if (val[0] & 0x80)
-    negative = 1;
-  else
-    negative = 0;
-
-  for (k = 0; k < SIZEOF_UNSIGNED_LONG_INT - 1; k++)
-    {
-      if (negative && (val[k] != 0xFF))
-       break;
-      else if (!negative && val[k])
-       break;
-    }
-
-  if ((negative && !(val[k] & 0x80)) || (!negative && (val[k] & 0x80)))
-    k--;
-
-  *len = SIZEOF_UNSIGNED_LONG_INT - k;
-
-  if (SIZEOF_UNSIGNED_LONG_INT - k > value_out_size)
-    /* VALUE_OUT is too short to contain the value conversion */
-    return ASN1_MEM_ERROR;
-
-  for (k2 = k; k2 < SIZEOF_UNSIGNED_LONG_INT; k2++)
-    value_out[k2 - k] = val[k2];
-
-#if 0
-  printf ("_asn1_convert_integer: valueIn=%s, lenOut=%d", value, *len);
-  for (k = 0; k < SIZEOF_UNSIGNED_LONG_INT; k++)
-    printf (", vOut[%d]=%d", k, value_out[k]);
-  printf ("\n");
-#endif
-
-  return ASN1_SUCCESS;
-}
-
-
-int
-_asn1_append_sequence_set (ASN1_TYPE node)
-{
-  ASN1_TYPE p, p2;
-  char temp[10];
-  long n;
-
-  if (!node || !(node->down))
-    return ASN1_GENERIC_ERROR;
-
-  p = node->down;
-  while ((type_field (p->type) == TYPE_TAG)
-        || (type_field (p->type) == TYPE_SIZE))
-    p = p->right;
-  p2 = _asn1_copy_structure3 (p);
-  while (p->right)
-    p = p->right;
-  _asn1_set_right (p, p2);
-
-  if (p->name == NULL)
-    _asn1_str_cpy (temp, sizeof (temp), "?1");
-  else
-    {
-      n = strtol (p->name + 1, NULL, 0);
-      n++;
-      temp[0] = '?';
-      _asn1_ltostr (n, temp + 1);
-    }
-  _asn1_set_name (p2, temp);
-  /*  p2->type |= CONST_OPTION; */
-
-  return ASN1_SUCCESS;
-}
-
-
-/**
- * asn1_write_value:
- * @node_root: pointer to a structure
- * @name: the name of the element inside the structure that you want to set.
- * @ivalue: vector used to specify the value to set. If len is >0,
- *   VALUE must be a two's complement form integer.  if len=0 *VALUE
- *   must be a null terminated string with an integer value.
- * @len: number of bytes of *value to use to set the value:
- *   value[0]..value[len-1] or 0 if value is a null terminated string
- *
- * Set the value of one element inside a structure.
- *
- * 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, "tbsCertificate.issuerUniqueID",
- * NULL, 0);
- *
- * Description for each type:
- *
- * INTEGER: VALUE must contain a two's complement form integer.
- *
- *            value[0]=0xFF ,               len=1 -> integer=-1.
- *            value[0]=0xFF value[1]=0xFF , len=2 -> integer=-1.
- *            value[0]=0x01 ,               len=1 -> integer= 1.
- *            value[0]=0x00 value[1]=0x01 , len=2 -> integer= 1.
- *            value="123"                 , len=0 -> integer= 123.
- *
- * ENUMERATED: As INTEGER (but only with not negative numbers).
- *
- * BOOLEAN: VALUE must be the null terminated string "TRUE" or
- *   "FALSE" and LEN != 0.
- *
- *            value="TRUE" , len=1 -> boolean=TRUE.
- *            value="FALSE" , len=1 -> boolean=FALSE.
- *
- * OBJECT IDENTIFIER: VALUE must be a null terminated string with
- *   each number separated by a dot (e.g. "1.2.3.543.1").  LEN != 0.
- *
- *            value="1 2 840 10040 4 3" , len=1 -> OID=dsa-with-sha.
- *
- * UTCTime: VALUE must be a null terminated string in one of these
- *   formats: "YYMMDDhhmmssZ", "YYMMDDhhmmssZ",
- *   "YYMMDDhhmmss+hh'mm'", "YYMMDDhhmmss-hh'mm'",
- *   "YYMMDDhhmm+hh'mm'", or "YYMMDDhhmm-hh'mm'".  LEN != 0.
- *
- *            value="9801011200Z" , len=1 -> time=Jannuary 1st, 1998
- *            at 12h 00m Greenwich Mean Time
- *
- * GeneralizedTime: VALUE must be in one of this format:
- *   "YYYYMMDDhhmmss.sZ", "YYYYMMDDhhmmss.sZ",
- *   "YYYYMMDDhhmmss.s+hh'mm'", "YYYYMMDDhhmmss.s-hh'mm'",
- *   "YYYYMMDDhhmm+hh'mm'", or "YYYYMMDDhhmm-hh'mm'" where ss.s
- *   indicates the seconds with any precision like "10.1" or "01.02".
- *   LEN != 0
- *
- *            value="2001010112001.12-0700" , len=1 -> time=Jannuary
- *            1st, 2001 at 12h 00m 01.12s Pacific Daylight Time
- *
- * OCTET STRING: VALUE contains the octet string and LEN is the
- *   number of octets.
- *
- *            value="$\backslash$x01$\backslash$x02$\backslash$x03" ,
- *            len=3 -> three bytes octet string
- *
- * GeneralString: VALUE contains the generalstring and LEN is the
- *   number of octets.
- *
- *            value="$\backslash$x01$\backslash$x02$\backslash$x03" ,
- *            len=3 -> three bytes generalstring
- *
- * BIT STRING: VALUE contains the bit string organized by bytes and
- *   LEN is the number of bits.
- *
- *   value="$\backslash$xCF" , len=6 -> bit string="110011" (six
- *   bits)
- *
- * CHOICE: if NAME indicates a choice type, VALUE must specify one of
- *   the alternatives with a null terminated string. LEN != 0. Using
- *   "pkix.asn"\:
- *
- *           result=asn1_write_value(cert,
- *           "certificate1.tbsCertificate.subject", "rdnSequence",
- *           1);
- *
- * ANY: VALUE indicates the der encoding of a structure.  LEN != 0.
- *
- * SEQUENCE OF: VALUE must be the null terminated string "NEW" and
- *   LEN != 0. With this instruction another element is appended in
- *   the sequence. The name of this element will be "?1" if it's the
- *   first one, "?2" for the second and so on.
- *
- *   Using "pkix.asn"\:
- *
- *   result=asn1_write_value(cert,
- *   "certificate1.tbsCertificate.subject.rdnSequence", "NEW", 1);
- *
- * SET OF: the same as SEQUENCE OF.  Using "pkix.asn":
- *
- *           result=asn1_write_value(cert,
- *           "tbsCertificate.subject.rdnSequence.?LAST", "NEW", 1);
- *
- * Returns: %ASN1_SUCCESS if the value was set,
- *   %ASN1_ELEMENT_NOT_FOUND if @name is not a valid element, and
- *   %ASN1_VALUE_NOT_VALID if @ivalue has a wrong format.
- **/
-asn1_retCode
-asn1_write_value (ASN1_TYPE node_root, const char *name,
-                 const void *ivalue, int len)
-{
-  ASN1_TYPE node, p, p2;
-  unsigned char *temp, *value_temp = NULL, *default_temp = NULL;
-  int len2, k, k2, negative;
-  size_t i;
-  const unsigned char *value = ivalue;
-
-  node = asn1_find_node (node_root, name);
-  if (node == NULL)
-    return ASN1_ELEMENT_NOT_FOUND;
-
-  if ((node->type & CONST_OPTION) && (value == NULL) && (len == 0))
-    {
-      asn1_delete_structure (&node);
-      return ASN1_SUCCESS;
-    }
-
-  if ((type_field (node->type) == TYPE_SEQUENCE_OF) && (value == NULL)
-      && (len == 0))
-    {
-      p = node->down;
-      while ((type_field (p->type) == TYPE_TAG)
-            || (type_field (p->type) == TYPE_SIZE))
-       p = p->right;
-
-      while (p->right)
-       asn1_delete_structure (&p->right);
-
-      return ASN1_SUCCESS;
-    }
-
-  switch (type_field (node->type))
-    {
-    case TYPE_BOOLEAN:
-      if (!_asn1_strcmp (value, "TRUE"))
-       {
-         if (node->type & CONST_DEFAULT)
-           {
-             p = node->down;
-             while (type_field (p->type) != TYPE_DEFAULT)
-               p = p->right;
-             if (p->type & CONST_TRUE)
-               _asn1_set_value (node, NULL, 0);
-             else
-               _asn1_set_value (node, "T", 1);
-           }
-         else
-           _asn1_set_value (node, "T", 1);
-       }
-      else if (!_asn1_strcmp (value, "FALSE"))
-       {
-         if (node->type & CONST_DEFAULT)
-           {
-             p = node->down;
-             while (type_field (p->type) != TYPE_DEFAULT)
-               p = p->right;
-             if (p->type & CONST_FALSE)
-               _asn1_set_value (node, NULL, 0);
-             else
-               _asn1_set_value (node, "F", 1);
-           }
-         else
-           _asn1_set_value (node, "F", 1);
-       }
-      else
-       return ASN1_VALUE_NOT_VALID;
-      break;
-    case TYPE_INTEGER:
-    case TYPE_ENUMERATED:
-      if (len == 0)
-       {
-         if ((isdigit (value[0])) || (value[0] == '-'))
-           {
-             value_temp =
-               (unsigned char *) _asn1_malloc (SIZEOF_UNSIGNED_LONG_INT);
-             if (value_temp == NULL)
-               return ASN1_MEM_ALLOC_ERROR;
-
-             _asn1_convert_integer (value, value_temp,
-                                    SIZEOF_UNSIGNED_LONG_INT, &len);
-           }
-         else
-           {                   /* is an identifier like v1 */
-             if (!(node->type & CONST_LIST))
-               return ASN1_VALUE_NOT_VALID;
-             p = node->down;
-             while (p)
-               {
-                 if (type_field (p->type) == TYPE_CONSTANT)
-                   {
-                     if ((p->name) && (!_asn1_strcmp (p->name, value)))
-                       {
-                         value_temp =
-                           (unsigned char *)
-                           _asn1_malloc (SIZEOF_UNSIGNED_LONG_INT);
-                         if (value_temp == NULL)
-                           return ASN1_MEM_ALLOC_ERROR;
-
-                         _asn1_convert_integer (p->value,
-                                                value_temp,
-                                                SIZEOF_UNSIGNED_LONG_INT,
-                                                &len);
-                         break;
-                       }
-                   }
-                 p = p->right;
-               }
-             if (p == NULL)
-               return ASN1_VALUE_NOT_VALID;
-           }
-       }
-      else
-       {                       /* len != 0 */
-         value_temp = (unsigned char *) _asn1_malloc (len);
-         if (value_temp == NULL)
-           return ASN1_MEM_ALLOC_ERROR;
-         memcpy (value_temp, value, len);
-       }
-
-
-      if (value_temp[0] & 0x80)
-       negative = 1;
-      else
-       negative = 0;
-
-      if (negative && (type_field (node->type) == TYPE_ENUMERATED))
-       {
-         _asn1_free (value_temp);
-         return ASN1_VALUE_NOT_VALID;
-       }
-
-      for (k = 0; k < len - 1; k++)
-       if (negative && (value_temp[k] != 0xFF))
-         break;
-       else if (!negative && value_temp[k])
-         break;
-
-      if ((negative && !(value_temp[k] & 0x80)) ||
-         (!negative && (value_temp[k] & 0x80)))
-       k--;
-
-      _asn1_set_value_octet (node, value_temp + k, len - k);
-
-      if (node->type & CONST_DEFAULT)
-       {
-         p = node->down;
-         while (type_field (p->type) != TYPE_DEFAULT)
-           p = p->right;
-         if ((isdigit (p->value[0])) || (p->value[0] == '-'))
-           {
-             default_temp =
-               (unsigned char *) _asn1_malloc (SIZEOF_UNSIGNED_LONG_INT);
-             if (default_temp == NULL)
-               {
-                 _asn1_free (value_temp);
-                 return ASN1_MEM_ALLOC_ERROR;
-               }
-
-             _asn1_convert_integer (p->value, default_temp,
-                                    SIZEOF_UNSIGNED_LONG_INT, &len2);
-           }
-         else
-           {                   /* is an identifier like v1 */
-             if (!(node->type & CONST_LIST))
-               {
-                 _asn1_free (value_temp);
-                 return ASN1_VALUE_NOT_VALID;
-               }
-             p2 = node->down;
-             while (p2)
-               {
-                 if (type_field (p2->type) == TYPE_CONSTANT)
-                   {
-                     if ((p2->name) && (!_asn1_strcmp (p2->name, p->value)))
-                       {
-                         default_temp =
-                           (unsigned char *)
-                           _asn1_malloc (SIZEOF_UNSIGNED_LONG_INT);
-                         if (default_temp == NULL)
-                           {
-                             _asn1_free (value_temp);
-                             return ASN1_MEM_ALLOC_ERROR;
-                           }
-
-                         _asn1_convert_integer (p2->value,
-                                                default_temp,
-                                                SIZEOF_UNSIGNED_LONG_INT,
-                                                &len2);
-                         break;
-                       }
-                   }
-                 p2 = p2->right;
-               }
-             if (p2 == NULL)
-               {
-                 _asn1_free (value_temp);
-                 return ASN1_VALUE_NOT_VALID;
-               }
-           }
-
-
-         if ((len - k) == len2)
-           {
-             for (k2 = 0; k2 < len2; k2++)
-               if (value_temp[k + k2] != default_temp[k2])
-                 {
-                   break;
-                 }
-             if (k2 == len2)
-               _asn1_set_value (node, NULL, 0);
-           }
-         _asn1_free (default_temp);
-       }
-      _asn1_free (value_temp);
-      break;
-    case TYPE_OBJECT_ID:
-      for (i = 0; i < _asn1_strlen (value); i++)
-       if ((!isdigit (value[i])) && (value[i] != '.') && (value[i] != '+'))
-         return ASN1_VALUE_NOT_VALID;
-      if (node->type & CONST_DEFAULT)
-       {
-         p = node->down;
-         while (type_field (p->type) != TYPE_DEFAULT)
-           p = p->right;
-         if (!_asn1_strcmp (value, p->value))
-           {
-             _asn1_set_value (node, NULL, 0);
-             break;
-           }
-       }
-      _asn1_set_value (node, value, _asn1_strlen (value) + 1);
-      break;
-    case TYPE_TIME:
-      if (node->type & CONST_UTC)
-       {
-         if (_asn1_strlen (value) < 11)
-           return ASN1_VALUE_NOT_VALID;
-         for (k = 0; k < 10; k++)
-           if (!isdigit (value[k]))
-             return ASN1_VALUE_NOT_VALID;
-         switch (_asn1_strlen (value))
-           {
-           case 11:
-             if (value[10] != 'Z')
-               return ASN1_VALUE_NOT_VALID;
-             break;
-           case 13:
-             if ((!isdigit (value[10])) || (!isdigit (value[11])) ||
-                 (value[12] != 'Z'))
-               return ASN1_VALUE_NOT_VALID;
-             break;
-           case 15:
-             if ((value[10] != '+') && (value[10] != '-'))
-               return ASN1_VALUE_NOT_VALID;
-             for (k = 11; k < 15; k++)
-               if (!isdigit (value[k]))
-                 return ASN1_VALUE_NOT_VALID;
-             break;
-           case 17:
-             if ((!isdigit (value[10])) || (!isdigit (value[11])))
-               return ASN1_VALUE_NOT_VALID;
-             if ((value[12] != '+') && (value[12] != '-'))
-               return ASN1_VALUE_NOT_VALID;
-             for (k = 13; k < 17; k++)
-               if (!isdigit (value[k]))
-                 return ASN1_VALUE_NOT_VALID;
-             break;
-           default:
-             return ASN1_VALUE_NOT_FOUND;
-           }
-         _asn1_set_value (node, value, _asn1_strlen (value) + 1);
-       }
-      else
-       {                       /* GENERALIZED TIME */
-         if (value)
-           _asn1_set_value (node, value, _asn1_strlen (value) + 1);
-       }
-      break;
-    case TYPE_OCTET_STRING:
-      if (len == 0)
-       len = _asn1_strlen (value);
-      _asn1_set_value_octet (node, value, len);
-      break;
-    case TYPE_GENERALSTRING:
-      if (len == 0)
-       len = _asn1_strlen (value);
-      _asn1_set_value_octet (node, value, len);
-      break;
-    case TYPE_BIT_STRING:
-      if (len == 0)
-       len = _asn1_strlen (value);
-      asn1_length_der ((len >> 3) + 2, NULL, &len2);
-      temp = (unsigned char *) _asn1_malloc ((len >> 3) + 2 + len2);
-      if (temp == NULL)
-       return ASN1_MEM_ALLOC_ERROR;
-
-      asn1_bit_der (value, len, temp, &len2);
-      _asn1_set_value_m (node, temp, len2);
-      temp = NULL;
-      break;
-    case TYPE_CHOICE:
-      p = node->down;
-      while (p)
-       {
-         if (!_asn1_strcmp (p->name, value))
-           {
-             p2 = node->down;
-             while (p2)
-               {
-                 if (p2 != p)
-                   {
-                     asn1_delete_structure (&p2);
-                     p2 = node->down;
-                   }
-                 else
-                   p2 = p2->right;
-               }
-             break;
-           }
-         p = p->right;
-       }
-      if (!p)
-       return ASN1_ELEMENT_NOT_FOUND;
-      break;
-    case TYPE_ANY:
-      _asn1_set_value_octet (node, value, len);
-      break;
-    case TYPE_SEQUENCE_OF:
-    case TYPE_SET_OF:
-      if (_asn1_strcmp (value, "NEW"))
-       return ASN1_VALUE_NOT_VALID;
-      _asn1_append_sequence_set (node);
-      break;
-    default:
-      return ASN1_ELEMENT_NOT_FOUND;
-      break;
-    }
-
-  return ASN1_SUCCESS;
-}
-
-
-#define PUT_VALUE( ptr, ptr_size, data, data_size) \
-       *len = data_size; \
-       if (ptr_size < data_size) { \
-               return ASN1_MEM_ERROR; \
-       } else { \
-               memcpy( ptr, data, data_size); \
-       }
-
-#define PUT_STR_VALUE( ptr, ptr_size, data) \
-       *len = _asn1_strlen(data) + 1; \
-       if (ptr_size < *len) { \
-               return ASN1_MEM_ERROR; \
-       } else { \
-               /* this strcpy is checked */ \
-               _asn1_strcpy(ptr, data); \
-       }
-
-#define ADD_STR_VALUE( ptr, ptr_size, data) \
-       *len = (int) _asn1_strlen(data) + 1; \
-       if (ptr_size < (int) _asn1_strlen(ptr)+(*len)) { \
-               return ASN1_MEM_ERROR; \
-       } else { \
-               /* this strcat is checked */ \
-               _asn1_strcat(ptr, data); \
-       }
-
-/**
- * asn1_read_value:
- * @root: pointer to a structure.
- * @name: the name of the element inside a structure that you want to read.
- * @ivalue: vector that will contain the element's content, must be a
- *   pointer to memory cells already allocated.
- * @len: number of bytes of *value: value[0]..value[len-1]. Initialy
- *   holds the sizeof value.
- *
- * Returns the value of one element inside a structure.
- *
- * If an element is OPTIONAL and the function "read_value" returns
- * %ASN1_ELEMENT_NOT_FOUND, it means that this element wasn't present
- * in the der encoding that created the structure.  The first element
- * of a SEQUENCE_OF or SET_OF is named "?1". The second one "?2" and
- * so on.
- *
- * INTEGER: VALUE will contain a two's complement form integer.
- *
- *            integer=-1  -> value[0]=0xFF , len=1.
- *            integer=1   -> value[0]=0x01 , len=1.
- *
- * ENUMERATED: As INTEGER (but only with not negative numbers).
- *
- * BOOLEAN: VALUE will be the null terminated string "TRUE" or
- *   "FALSE" and LEN=5 or LEN=6.
- *
- * OBJECT IDENTIFIER: VALUE will be a null terminated string with
- *   each number separated by a dot (i.e. "1.2.3.543.1").
- *
- *                      LEN = strlen(VALUE)+1
- *
- * UTCTime: VALUE will be a null terminated string in one of these
- *   formats: "YYMMDDhhmmss+hh'mm'" or "YYMMDDhhmmss-hh'mm'".
- *   LEN=strlen(VALUE)+1.
- *
- * GeneralizedTime: VALUE will be a null terminated string in the
- *   same format used to set the value.
- *
- * OCTET STRING: VALUE will contain the octet string and LEN will be
- *   the number of octets.
- *
- * GeneralString: VALUE will contain the generalstring and LEN will
- *   be the number of octets.
- *
- * BIT STRING: VALUE will contain the bit string organized by bytes
- *   and LEN will be the number of bits.
- *
- * CHOICE: If NAME indicates a choice type, VALUE will specify the
- *   alternative selected.
- *
- * ANY: If NAME indicates an any type, VALUE will indicate the DER
- *   encoding of the structure actually used.
- *
- * Returns: %ASN1_SUCCESS if value is returned,
- *   %ASN1_ELEMENT_NOT_FOUND if @name is not a valid element,
- *   %ASN1_VALUE_NOT_FOUND if there isn't any value for the element
- *   selected, and %ASN1_MEM_ERROR if The value vector isn't big enough
- *   to store the result, and in this case @len will contain the number of
- *   bytes needed.
- **/
-asn1_retCode
-asn1_read_value (ASN1_TYPE root, const char *name, void *ivalue, int *len)
-{
-  ASN1_TYPE node, p, p2;
-  int len2, len3;
-  int value_size = *len;
-  unsigned char *value = ivalue;
-
-  node = asn1_find_node (root, name);
-  if (node == NULL)
-    return ASN1_ELEMENT_NOT_FOUND;
-
-  if ((type_field (node->type) != TYPE_NULL) &&
-      (type_field (node->type) != TYPE_CHOICE) &&
-      !(node->type & CONST_DEFAULT) && !(node->type & CONST_ASSIGN) &&
-      (node->value == NULL))
-    return ASN1_VALUE_NOT_FOUND;
-
-  switch (type_field (node->type))
-    {
-    case TYPE_NULL:
-      PUT_STR_VALUE (value, value_size, "NULL");
-      break;
-    case TYPE_BOOLEAN:
-      if ((node->type & CONST_DEFAULT) && (node->value == NULL))
-       {
-         p = node->down;
-         while (type_field (p->type) != TYPE_DEFAULT)
-           p = p->right;
-         if (p->type & CONST_TRUE)
-           {
-             PUT_STR_VALUE (value, value_size, "TRUE");
-           }
-         else
-           {
-             PUT_STR_VALUE (value, value_size, "FALSE");
-           }
-       }
-      else if (node->value[0] == 'T')
-       {
-         PUT_STR_VALUE (value, value_size, "TRUE");
-       }
-      else
-       {
-         PUT_STR_VALUE (value, value_size, "FALSE");
-       }
-      break;
-    case TYPE_INTEGER:
-    case TYPE_ENUMERATED:
-      if ((node->type & CONST_DEFAULT) && (node->value == NULL))
-       {
-         p = node->down;
-         while (type_field (p->type) != TYPE_DEFAULT)
-           p = p->right;
-         if ((isdigit (p->value[0])) || (p->value[0] == '-')
-             || (p->value[0] == '+'))
-           {
-             if (_asn1_convert_integer
-                 (p->value, value, value_size, len) != ASN1_SUCCESS)
-               return ASN1_MEM_ERROR;
-           }
-         else
-           {                   /* is an identifier like v1 */
-             p2 = node->down;
-             while (p2)
-               {
-                 if (type_field (p2->type) == TYPE_CONSTANT)
-                   {
-                     if ((p2->name) && (!_asn1_strcmp (p2->name, p->value)))
-                       {
-                         if (_asn1_convert_integer
-                             (p2->value, value, value_size,
-                              len) != ASN1_SUCCESS)
-                           return ASN1_MEM_ERROR;
-                         break;
-                       }
-                   }
-                 p2 = p2->right;
-               }
-           }
-       }
-      else
-       {
-         len2 = -1;
-         if (asn1_get_octet_der
-             (node->value, node->value_len, &len2, value, value_size,
-              len) != ASN1_SUCCESS)
-           return ASN1_MEM_ERROR;
-       }
-      break;
-    case TYPE_OBJECT_ID:
-      if (node->type & CONST_ASSIGN)
-       {
-         value[0] = 0;
-         p = node->down;
-         while (p)
-           {
-             if (type_field (p->type) == TYPE_CONSTANT)
-               {
-                 ADD_STR_VALUE (value, value_size, p->value);
-                 if (p->right)
-                   {
-                     ADD_STR_VALUE (value, value_size, ".");
-                   }
-               }
-             p = p->right;
-           }
-         *len = _asn1_strlen (value) + 1;
-       }
-      else if ((node->type & CONST_DEFAULT) && (node->value == NULL))
-       {
-         p = node->down;
-         while (type_field (p->type) != TYPE_DEFAULT)
-           p = p->right;
-         PUT_STR_VALUE (value, value_size, p->value);
-       }
-      else
-       {
-         PUT_STR_VALUE (value, value_size, node->value);
-       }
-      break;
-    case TYPE_TIME:
-      PUT_STR_VALUE (value, value_size, node->value);
-      break;
-    case TYPE_OCTET_STRING:
-      len2 = -1;
-      if (asn1_get_octet_der
-         (node->value, node->value_len, &len2, value, value_size,
-          len) != ASN1_SUCCESS)
-       return ASN1_MEM_ERROR;
-      break;
-    case TYPE_GENERALSTRING:
-      len2 = -1;
-      if (asn1_get_octet_der
-         (node->value, node->value_len, &len2, value, value_size,
-          len) != ASN1_SUCCESS)
-       return ASN1_MEM_ERROR;
-      break;
-    case TYPE_BIT_STRING:
-      len2 = -1;
-      if (asn1_get_bit_der
-         (node->value, node->value_len, &len2, value, value_size,
-          len) != ASN1_SUCCESS)
-       return ASN1_MEM_ERROR;
-      break;
-    case TYPE_CHOICE:
-      PUT_STR_VALUE (value, value_size, node->down->name);
-      break;
-    case TYPE_ANY:
-      len3 = -1;
-      len2 = asn1_get_length_der (node->value, node->value_len, &len3);
-      if (len2 < 0)
-       return ASN1_DER_ERROR;
-      PUT_VALUE (value, value_size, node->value + len3, len2);
-      break;
-    default:
-      return ASN1_ELEMENT_NOT_FOUND;
-      break;
-    }
-  return ASN1_SUCCESS;
-}
-
-
-/**
- * asn1_read_tag:
- * @root: pointer to a structure
- * @name: the name of the element inside a structure.
- * @tagValue:  variable that will contain the TAG value.
- * @classValue: variable that will specify the TAG type.
- *
- * Returns the TAG and the CLASS of one element inside a structure.
- * CLASS can have one of these constants: %ASN1_CLASS_APPLICATION,
- * %ASN1_CLASS_UNIVERSAL, %ASN1_CLASS_PRIVATE or
- * %ASN1_CLASS_CONTEXT_SPECIFIC.
- *
- * Returns: %ASN1_SUCCESS if successful, %ASN1_ELEMENT_NOT_FOUND if
- *   @name is not a valid element.
- **/
-asn1_retCode
-asn1_read_tag (ASN1_TYPE root, const char *name, int *tagValue,
-              int *classValue)
-{
-  ASN1_TYPE node, p, pTag;
-
-  node = asn1_find_node (root, name);
-  if (node == NULL)
-    return ASN1_ELEMENT_NOT_FOUND;
-
-  p = node->down;
-
-  /* pTag will points to the IMPLICIT TAG */
-  pTag = NULL;
-  if (node->type & CONST_TAG)
-    {
-      while (p)
-       {
-         if (type_field (p->type) == TYPE_TAG)
-           {
-             if ((p->type & CONST_IMPLICIT) && (pTag == NULL))
-               pTag = p;
-             else if (p->type & CONST_EXPLICIT)
-               pTag = NULL;
-           }
-         p = p->right;
-       }
-    }
-
-  if (pTag)
-    {
-      *tagValue = _asn1_strtoul (pTag->value, NULL, 10);
-
-      if (pTag->type & CONST_APPLICATION)
-       *classValue = ASN1_CLASS_APPLICATION;
-      else if (pTag->type & CONST_UNIVERSAL)
-       *classValue = ASN1_CLASS_UNIVERSAL;
-      else if (pTag->type & CONST_PRIVATE)
-       *classValue = ASN1_CLASS_PRIVATE;
-      else
-       *classValue = ASN1_CLASS_CONTEXT_SPECIFIC;
-    }
-  else
-    {
-      *classValue = ASN1_CLASS_UNIVERSAL;
-
-      switch (type_field (node->type))
-       {
-       case TYPE_NULL:
-         *tagValue = ASN1_TAG_NULL;
-         break;
-       case TYPE_BOOLEAN:
-         *tagValue = ASN1_TAG_BOOLEAN;
-         break;
-       case TYPE_INTEGER:
-         *tagValue = ASN1_TAG_INTEGER;
-         break;
-       case TYPE_ENUMERATED:
-         *tagValue = ASN1_TAG_ENUMERATED;
-         break;
-       case TYPE_OBJECT_ID:
-         *tagValue = ASN1_TAG_OBJECT_ID;
-         break;
-       case TYPE_TIME:
-         if (node->type & CONST_UTC)
-           {
-             *tagValue = ASN1_TAG_UTCTime;
-           }
-         else
-           *tagValue = ASN1_TAG_GENERALIZEDTime;
-         break;
-       case TYPE_OCTET_STRING:
-         *tagValue = ASN1_TAG_OCTET_STRING;
-         break;
-       case TYPE_GENERALSTRING:
-         *tagValue = ASN1_TAG_GENERALSTRING;
-         break;
-       case TYPE_BIT_STRING:
-         *tagValue = ASN1_TAG_BIT_STRING;
-         break;
-       case TYPE_SEQUENCE:
-       case TYPE_SEQUENCE_OF:
-         *tagValue = ASN1_TAG_SEQUENCE;
-         break;
-       case TYPE_SET:
-       case TYPE_SET_OF:
-         *tagValue = ASN1_TAG_SET;
-         break;
-       case TYPE_TAG:
-       case TYPE_CHOICE:
-       case TYPE_ANY:
-         break;
-       default:
-         break;
-       }
-    }
-
-  return ASN1_SUCCESS;
-}
diff --git a/asn1/element.h b/asn1/element.h
deleted file mode 100644
index 9cad46e..0000000
--- a/asn1/element.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (C) 2000-2012 Free Software Foundation, Inc.
- *
- * This file is part of LIBTASN1.
- *
- * The LIBTASN1 library is free software; you can redistribute it
- * and/or modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA
- */
-
-#ifndef _ELEMENT_H
-#define _ELEMENT_H
-
-
-asn1_retCode _asn1_append_sequence_set (ASN1_TYPE node);
-
-asn1_retCode _asn1_convert_integer (const unsigned char *value,
-                                   unsigned char *value_out,
-                                   int value_out_size, int *len);
-
-void _asn1_hierarchical_name (ASN1_TYPE node, char *name, int name_size);
-
-#endif
diff --git a/asn1/errors.c b/asn1/errors.c
deleted file mode 100644
index 76611d8..0000000
--- a/asn1/errors.c
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * Copyright (C) 2002-2012 Free Software Foundation, Inc.
- *
- * This file is part of LIBTASN1.
- *
- * The LIBTASN1 library is free software; you can redistribute it
- * and/or modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA
- */
-
-#include <int.h>
-#ifdef STDC_HEADERS
-#include <stdarg.h>
-#endif
-
-#define LIBTASN1_ERROR_ENTRY(name) { #name, name }
-
-struct libtasn1_error_entry
-{
-  const char *name;
-  int number;
-};
-typedef struct libtasn1_error_entry libtasn1_error_entry;
-
-static const libtasn1_error_entry error_algorithms[] = {
-  LIBTASN1_ERROR_ENTRY (ASN1_SUCCESS),
-  LIBTASN1_ERROR_ENTRY (ASN1_FILE_NOT_FOUND),
-  LIBTASN1_ERROR_ENTRY (ASN1_ELEMENT_NOT_FOUND),
-  LIBTASN1_ERROR_ENTRY (ASN1_IDENTIFIER_NOT_FOUND),
-  LIBTASN1_ERROR_ENTRY (ASN1_DER_ERROR),
-  LIBTASN1_ERROR_ENTRY (ASN1_VALUE_NOT_FOUND),
-  LIBTASN1_ERROR_ENTRY (ASN1_GENERIC_ERROR),
-  LIBTASN1_ERROR_ENTRY (ASN1_VALUE_NOT_VALID),
-  LIBTASN1_ERROR_ENTRY (ASN1_TAG_ERROR),
-  LIBTASN1_ERROR_ENTRY (ASN1_TAG_IMPLICIT),
-  LIBTASN1_ERROR_ENTRY (ASN1_ERROR_TYPE_ANY),
-  LIBTASN1_ERROR_ENTRY (ASN1_SYNTAX_ERROR),
-  LIBTASN1_ERROR_ENTRY (ASN1_MEM_ERROR),
-  LIBTASN1_ERROR_ENTRY (ASN1_MEM_ALLOC_ERROR),
-  LIBTASN1_ERROR_ENTRY (ASN1_DER_OVERFLOW),
-  LIBTASN1_ERROR_ENTRY (ASN1_NAME_TOO_LONG),
-  LIBTASN1_ERROR_ENTRY (ASN1_ARRAY_ERROR),
-  LIBTASN1_ERROR_ENTRY (ASN1_ELEMENT_NOT_EMPTY),
-  {0, 0}
-};
-
-/**
- * asn1_perror:
- * @error: is an error returned by a libtasn1 function.
- *
- * Prints a string to stderr with a description of an error.  This
- * function is like perror().  The only difference is that it accepts
- * an error returned by a libtasn1 function.
- *
- * This function replaces libtasn1_perror() in older libtasn1.
- *
- * Since: 1.6
- **/
-void
-asn1_perror (asn1_retCode error)
-{
-  const char *str = asn1_strerror (error);
-  fprintf (stderr, "LIBTASN1 ERROR: %s\n", str ? str : "(null)");
-}
-
-/**
- * asn1_strerror:
- * @error: is an error returned by a libtasn1 function.
- *
- * Returns a string with a description of an error.  This function is
- * similar to strerror.  The only difference is that it accepts an
- * error (number) returned by a libtasn1 function.
- *
- * This function replaces libtasn1_strerror() in older libtasn1.
- *
- * Returns: Pointer to static zero-terminated string describing error
- *   code.
- *
- * Since: 1.6
- **/
-const char *
-asn1_strerror (asn1_retCode error)
-{
-  const libtasn1_error_entry *p;
-
-  for (p = error_algorithms; p->name != NULL; p++)
-    if (p->number == error)
-      return p->name + sizeof ("ASN1_") - 1;
-
-  return NULL;
-}
-
-#ifndef ASN1_DISABLE_DEPRECATED
-
-/* Compatibility mappings to preserve ABI. */
-
-/**
- * libtasn1_perror:
- * @error: is an error returned by a libtasn1 function.
- *
- * Prints a string to stderr with a description of an error.  This
- * function is like perror(). The only difference is that it accepts
- * an error returned by a libtasn1 function.
- *
- * Deprecated: Use asn1_perror() instead.
- **/
-void
-libtasn1_perror (asn1_retCode error)
-{
-  asn1_perror (error);
-}
-
-/**
- * libtasn1_strerror:
- * @error: is an error returned by a libtasn1 function.
- *
- * Returns a string with a description of an error.  This function is
- * similar to strerror.  The only difference is that it accepts an
- * error (number) returned by a libtasn1 function.
- *
- * Returns: Pointer to static zero-terminated string describing error
- *   code.
- *
- * Deprecated: Use asn1_strerror() instead.
- **/
-const char *
-libtasn1_strerror (asn1_retCode error)
-{
-  return asn1_strerror (error);
-}
-
-#endif
diff --git a/asn1/errors.h b/asn1/errors.h
deleted file mode 100644
index ceb2e7b..0000000
--- a/asn1/errors.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (C) 2004, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
- * Copyright (C) 2002 Fabio Fiorina
- *
- * This file is part of LIBTASN1.
- *
- * The LIBTASN1 library is free software; you can redistribute it
- * and/or modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA
- */
-
-#ifndef ERRORS_H
-#define ERRORS_H
-
-#include "int.h"
-
-void _libtasn1_log( const char *fmt, ...);
-
-#endif /* ERRORS_H */
diff --git a/asn1/gstr.c b/asn1/gstr.c
deleted file mode 100644
index 4785073..0000000
--- a/asn1/gstr.c
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (C) 2002-2012 Free Software Foundation, Inc.
- *
- * This file is part of LIBTASN1.
- *
- * The LIBTASN1 library is free software; you can redistribute it
- * and/or modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA
- */
-
-#include <int.h>
-#include "gstr.h"
-
-/* These function are like strcat, strcpy. They only
- * do bounds checking (they shouldn't cause buffer overruns),
- * and they always produce null terminated strings.
- *
- * They should be used only with null terminated strings.
- */
-void
-_asn1_str_cat (char *dest, size_t dest_tot_size, const char *src)
-{
-  size_t str_size = strlen (src);
-  size_t dest_size = strlen (dest);
-
-  if (dest_tot_size - dest_size > str_size)
-    {
-      strcat (dest, src);
-    }
-  else
-    {
-      if (dest_tot_size - dest_size > 0)
-       {
-         strncat (dest, src, (dest_tot_size - dest_size) - 1);
-         dest[dest_tot_size - 1] = 0;
-       }
-    }
-}
-
-void
-_asn1_str_cpy (char *dest, size_t dest_tot_size, const char *src)
-{
-  size_t str_size = strlen (src);
-
-  if (dest_tot_size > str_size)
-    {
-      strcpy (dest, src);
-    }
-  else
-    {
-      if (dest_tot_size > 0)
-       {
-         memcpy (dest, src, dest_tot_size - 1);
-         dest[dest_tot_size - 1] = 0;
-       }
-    }
-}
diff --git a/asn1/gstr.h b/asn1/gstr.h
deleted file mode 100644
index baaa6a0..0000000
--- a/asn1/gstr.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (C) 2002-2012 Free Software Foundation, Inc.
- *
- * This file is part of LIBTASN1.
- *
- * The LIBTASN1 library is free software; you can redistribute it
- * and/or modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA
- */
-
-void _asn1_str_cpy (char *dest, size_t dest_tot_size, const char *src);
-void _asn1_str_cat (char *dest, size_t dest_tot_size, const char *src);
-
-#define Estrcpy(x,y) _asn1_str_cpy(x,ASN1_MAX_ERROR_DESCRIPTION_SIZE,y)
-#define Estrcat(x,y) _asn1_str_cat(x,ASN1_MAX_ERROR_DESCRIPTION_SIZE,y)
diff --git a/asn1/int.h b/asn1/int.h
deleted file mode 100644
index 82de579..0000000
--- a/asn1/int.h
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * Copyright (C) 2002-2012 Free Software Foundation, Inc.
- *
- * This file is part of LIBTASN1.
- *
- * The LIBTASN1 library is free software; you can redistribute it
- * and/or modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA
- */
-
-#ifndef INT_H
-#define INT_H
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <string.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <ctype.h>
-#include <stdint.h>
-
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-
-#include <libtasn1.h>
-
-#define ASN1_SMALL_VALUE_SIZE 16
-
-/* This structure is also in libtasn1.h, but then contains less
-   fields.  You cannot make any modifications to these first fields
-   without breaking ABI.  */
-struct node_asn_struct
-{
-  /* public fields: */
-  char *name;                  /* Node name */
-  unsigned int type;           /* Node type */
-  unsigned char *value;                /* Node value */
-  int value_len;
-  ASN1_TYPE down;              /* Pointer to the son node */
-  ASN1_TYPE right;             /* Pointer to the brother node */
-  ASN1_TYPE left;              /* Pointer to the next list element */
-  /* private fields: */
-  unsigned char small_value[ASN1_SMALL_VALUE_SIZE];    /* For small values */
-};
-
-#define _asn1_malloc malloc
-#define _asn1_free free
-#define _asn1_calloc calloc
-#define _asn1_realloc realloc
-#define _asn1_strdup strdup
-#define _asn1_strlen(s) strlen((const char *) s)
-#define _asn1_strtol(n,e,b) strtol((const char *) n, e, b)
-#define _asn1_strtoul(n,e,b) strtoul((const char *) n, e, b)
-#define _asn1_strcmp(a,b) strcmp((const char *)a, (const char *)b)
-#define _asn1_strcpy(a,b) strcpy((char *)a, (const char *)b)
-#define _asn1_strcat(a,b) strcat((char *)a, (const char *)b)
-
-#define MAX_LOG_SIZE 1024      /* maximum number of characters of a log 
message */
-
-/* Define used for visiting trees. */
-#define UP     1
-#define RIGHT  2
-#define DOWN   3
-
-/****************************************/
-/* Returns the first 8 bits.            */
-/* Used with the field type of node_asn */
-/****************************************/
-#define type_field(x)     (x&0xFF)
-
-/* List of constants for field type of typedef node_asn  */
-#define TYPE_CONSTANT       1
-#define TYPE_IDENTIFIER     2
-#define TYPE_INTEGER        3
-#define TYPE_BOOLEAN        4
-#define TYPE_SEQUENCE       5
-#define TYPE_BIT_STRING     6
-#define TYPE_OCTET_STRING   7
-#define TYPE_TAG            8
-#define TYPE_DEFAULT        9
-#define TYPE_SIZE          10
-#define TYPE_SEQUENCE_OF   11
-#define TYPE_OBJECT_ID     12
-#define TYPE_ANY           13
-#define TYPE_SET           14
-#define TYPE_SET_OF        15
-#define TYPE_DEFINITIONS   16
-#define TYPE_TIME          17
-#define TYPE_CHOICE        18
-#define TYPE_IMPORTS       19
-#define TYPE_NULL          20
-#define TYPE_ENUMERATED    21
-#define TYPE_GENERALSTRING 27
-
-
-/***********************************************************************/
-/* List of constants to better specify the type of typedef node_asn.   */
-/***********************************************************************/
-/*  Used with TYPE_TAG  */
-#define CONST_UNIVERSAL   (1<<8)
-#define CONST_PRIVATE     (1<<9)
-#define CONST_APPLICATION (1<<10)
-#define CONST_EXPLICIT    (1<<11)
-#define CONST_IMPLICIT    (1<<12)
-
-#define CONST_TAG         (1<<13)      /*  Used in ASN.1 assignement  */
-#define CONST_OPTION      (1<<14)
-#define CONST_DEFAULT     (1<<15)
-#define CONST_TRUE        (1<<16)
-#define CONST_FALSE       (1<<17)
-
-#define CONST_LIST        (1<<18)      /*  Used with TYPE_INTEGER and 
TYPE_BIT_STRING  */
-#define CONST_MIN_MAX     (1<<19)
-
-#define CONST_1_PARAM     (1<<20)
-
-#define CONST_SIZE        (1<<21)
-
-#define CONST_DEFINED_BY  (1<<22)
-
-#define CONST_GENERALIZED (1<<23)
-#define CONST_UTC         (1<<24)
-
-/* #define CONST_IMPORTS     (1<<25) */
-
-#define CONST_NOT_USED    (1<<26)
-#define CONST_SET         (1<<27)
-#define CONST_ASSIGN      (1<<28)
-
-#define CONST_DOWN        (1<<29)
-#define CONST_RIGHT       (1<<30)
-
-#endif /* INT_H */
diff --git a/asn1/libtasn1.h b/asn1/libtasn1.h
deleted file mode 100644
index 063b1d6..0000000
--- a/asn1/libtasn1.h
+++ /dev/null
@@ -1,317 +0,0 @@
-/*
- * Copyright (C) 2002-2012 Free Software Foundation, Inc.
- *
- * This file is part of LIBTASN1.
- *
- * LIBTASN1 is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * LIBTASN1 is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with LIBTASN1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA
- *
- */
-
-#ifndef LIBTASN1_H
-# define LIBTASN1_H
-
-# ifndef ASN1_API
-#  if defined ASN1_BUILDING && defined HAVE_VISIBILITY && HAVE_VISIBILITY
-#   define ASN1_API __attribute__((__visibility__("default")))
-#  elif defined ASN1_BUILDING && defined _MSC_VER && ! defined ASN1_STATIC
-#   define ASN1_API __declspec(dllexport)
-#  elif defined _MSC_VER && ! defined ASN1_STATIC
-#   define ASN1_API __declspec(dllimport)
-#  else
-#   define ASN1_API
-#  endif
-# endif
-
-#include <stdio.h>             /* for FILE* */
-#include <sys/types.h>
-#include <time.h>
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-#define ASN1_VERSION "2.13"
-
-  typedef int asn1_retCode;    /* type returned by libtasn1 functions */
-
-  /*****************************************/
-  /* Errors returned by libtasn1 functions */
-  /*****************************************/
-#define ASN1_SUCCESS                   0
-#define ASN1_FILE_NOT_FOUND            1
-#define ASN1_ELEMENT_NOT_FOUND         2
-#define ASN1_IDENTIFIER_NOT_FOUND      3
-#define ASN1_DER_ERROR                 4
-#define ASN1_VALUE_NOT_FOUND           5
-#define ASN1_GENERIC_ERROR             6
-#define ASN1_VALUE_NOT_VALID           7
-#define ASN1_TAG_ERROR                 8
-#define ASN1_TAG_IMPLICIT              9
-#define ASN1_ERROR_TYPE_ANY            10
-#define ASN1_SYNTAX_ERROR              11
-#define ASN1_MEM_ERROR                 12
-#define ASN1_MEM_ALLOC_ERROR           13
-#define ASN1_DER_OVERFLOW              14
-#define ASN1_NAME_TOO_LONG             15
-#define ASN1_ARRAY_ERROR               16
-#define ASN1_ELEMENT_NOT_EMPTY         17
-
-  /*************************************/
-  /* Constants used in asn1_visit_tree */
-  /*************************************/
-#define ASN1_PRINT_NAME                        1
-#define ASN1_PRINT_NAME_TYPE           2
-#define ASN1_PRINT_NAME_TYPE_VALUE     3
-#define ASN1_PRINT_ALL                 4
-
-  /*****************************************/
-  /* Constants returned by asn1_read_tag   */
-  /*****************************************/
-#define ASN1_CLASS_UNIVERSAL           0x00    /* old: 1 */
-#define ASN1_CLASS_APPLICATION         0x40    /* old: 2 */
-#define ASN1_CLASS_CONTEXT_SPECIFIC    0x80    /* old: 3 */
-#define ASN1_CLASS_PRIVATE             0xC0    /* old: 4 */
-#define ASN1_CLASS_STRUCTURED          0x20
-
-  /*****************************************/
-  /* Constants returned by asn1_read_tag   */
-  /*****************************************/
-#define ASN1_TAG_BOOLEAN               0x01
-#define ASN1_TAG_INTEGER               0x02
-#define ASN1_TAG_SEQUENCE              0x10
-#define ASN1_TAG_SET                   0x11
-#define ASN1_TAG_OCTET_STRING          0x04
-#define ASN1_TAG_BIT_STRING            0x03
-#define ASN1_TAG_UTCTime               0x17
-#define ASN1_TAG_GENERALIZEDTime       0x18
-#define ASN1_TAG_OBJECT_ID             0x06
-#define ASN1_TAG_ENUMERATED            0x0A
-#define ASN1_TAG_NULL                  0x05
-#define ASN1_TAG_GENERALSTRING         0x1B
-
-  /******************************************************/
-  /* Structure definition used for the node of the tree */
-  /* that represent an ASN.1 DEFINITION.                */
-  /******************************************************/
-
-#if !defined ASN1_BUILDING
-  /* This structure is also in internal.h, but then contains more
-     fields.  You cannot make any modifications to these fields
-     without breaking ABI.  */
-  struct node_asn_struct
-  {
-    char *name;                        /* Node name */
-    unsigned int type;         /* Node type */
-    unsigned char *value;      /* Node value */
-    int value_len;
-    struct node_asn_struct *down;      /* Pointer to the son node */
-    struct node_asn_struct *right;     /* Pointer to the brother node */
-    struct node_asn_struct *left;      /* Pointer to the next list element */
-  };
-#endif
-
-  typedef struct node_asn_struct node_asn;
-
-  typedef node_asn *ASN1_TYPE;
-
-#define ASN1_TYPE_EMPTY  NULL
-
-  /*****************************************/
-  /* For the on-disk format of ASN.1 trees */
-  /*****************************************/
-  struct static_struct_asn
-  {
-    const char *name;          /* Node name */
-    unsigned int type;         /* Node type */
-    const void *value;         /* Node value */
-  };
-  typedef struct static_struct_asn ASN1_ARRAY_TYPE;
-
-  /***********************************/
-  /*  Fixed constants                */
-  /***********************************/
-
-  /* maximum number of characters of a name */
-  /* inside a file with ASN1 definitons     */
-#define ASN1_MAX_NAME_SIZE 128
-
-  /* maximum number of characters */
-  /* of a description message     */
-  /* (null character included)    */
-#define ASN1_MAX_ERROR_DESCRIPTION_SIZE 128
-
-  /***********************************/
-  /*  Functions definitions          */
-  /***********************************/
-
-  extern ASN1_API asn1_retCode
-    asn1_parser2tree (const char *file_name,
-                     ASN1_TYPE * definitions, char *errorDescription);
-
-  extern ASN1_API asn1_retCode
-    asn1_parser2array (const char *inputFileName,
-                      const char *outputFileName,
-                      const char *vectorName, char *errorDescription);
-
-  extern ASN1_API asn1_retCode
-    asn1_array2tree (const ASN1_ARRAY_TYPE * array,
-                    ASN1_TYPE * definitions, char *errorDescription);
-
-  extern ASN1_API void
-    asn1_print_structure (FILE * out, ASN1_TYPE structure,
-                         const char *name, int mode);
-
-  extern ASN1_API asn1_retCode
-    asn1_create_element (ASN1_TYPE definitions,
-                        const char *source_name, ASN1_TYPE * element);
-
-  extern ASN1_API asn1_retCode asn1_delete_structure (ASN1_TYPE * structure);
-
-  extern ASN1_API asn1_retCode
-    asn1_delete_element (ASN1_TYPE structure, const char *element_name);
-
-  extern ASN1_API asn1_retCode
-    asn1_write_value (ASN1_TYPE node_root, const char *name,
-                     const void *ivalue, int len);
-
-  extern ASN1_API asn1_retCode
-    asn1_read_value (ASN1_TYPE root, const char *name,
-                    void *ivalue, int *len);
-
-  extern ASN1_API asn1_retCode
-    asn1_number_of_elements (ASN1_TYPE element, const char *name, int *num);
-
-  extern ASN1_API asn1_retCode
-    asn1_der_coding (ASN1_TYPE element, const char *name,
-                    void *ider, int *len, char *ErrorDescription);
-
-  extern ASN1_API asn1_retCode
-    asn1_der_decoding (ASN1_TYPE * element, const void *ider,
-                      int len, char *errorDescription);
-
-  extern ASN1_API asn1_retCode
-    asn1_der_decoding_element (ASN1_TYPE * structure,
-                              const char *elementName,
-                              const void *ider, int len,
-                              char *errorDescription);
-
-  extern ASN1_API asn1_retCode
-    asn1_der_decoding_startEnd (ASN1_TYPE element,
-                               const void *ider, int len,
-                               const char *name_element,
-                               int *start, int *end);
-
-  extern ASN1_API asn1_retCode
-    asn1_expand_any_defined_by (ASN1_TYPE definitions, ASN1_TYPE * element);
-
-  extern ASN1_API asn1_retCode
-    asn1_expand_octet_string (ASN1_TYPE definitions,
-                             ASN1_TYPE * element,
-                             const char *octetName, const char *objectName);
-
-  extern ASN1_API asn1_retCode
-    asn1_read_tag (ASN1_TYPE root, const char *name,
-                  int *tagValue, int *classValue);
-
-  extern ASN1_API const char *asn1_find_structure_from_oid (ASN1_TYPE
-                                                           definitions,
-                                                           const char
-                                                           *oidValue);
-
-  extern ASN1_API const char *asn1_check_version (const char *req_version);
-
-  extern ASN1_API const char *asn1_strerror (asn1_retCode error);
-
-  extern ASN1_API void asn1_perror (asn1_retCode error);
-
-  /* DER utility functions. */
-
-  extern ASN1_API int
-    asn1_get_tag_der (const unsigned char *der, int der_len,
-                     unsigned char *cls, int *len, unsigned long *tag);
-
-  extern ASN1_API void
-    asn1_octet_der (const unsigned char *str, int str_len,
-                   unsigned char *der, int *der_len);
-
-  extern ASN1_API asn1_retCode
-    asn1_get_octet_der (const unsigned char *der, int der_len,
-                       int *ret_len, unsigned char *str,
-                       int str_size, int *str_len);
-
-  extern ASN1_API void asn1_bit_der (const unsigned char *str, int bit_len,
-                                    unsigned char *der, int *der_len);
-
-  extern ASN1_API asn1_retCode
-    asn1_get_bit_der (const unsigned char *der, int der_len,
-                     int *ret_len, unsigned char *str,
-                     int str_size, int *bit_len);
-
-  extern ASN1_API long
-    asn1_get_length_der (const unsigned char *der, int der_len, int *len);
-
-  extern ASN1_API long
-    asn1_get_length_ber (const unsigned char *ber, int ber_len, int *len);
-
-  extern ASN1_API void
-    asn1_length_der (unsigned long int len, unsigned char *ans, int *ans_len);
-
-  /* Other utility functions. */
-
-  extern ASN1_API ASN1_TYPE
-    asn1_find_node (ASN1_TYPE pointer, const char *name);
-
-  extern ASN1_API asn1_retCode
-    asn1_copy_node (ASN1_TYPE dst, const char *dst_name,
-                   ASN1_TYPE src, const char *src_name);
-
-  /* Deprecated stuff. */
-
-#ifndef ASN1_DISABLE_DEPRECATED
-
-#define LIBTASN1_VERSION ASN1_VERSION
-
-#ifndef MAX_NAME_SIZE
-# define MAX_NAME_SIZE ASN1_MAX_NAME_SIZE
-#endif
-
-#ifndef MAX_ERROR_DESCRIPTION_SIZE
-# define MAX_ERROR_DESCRIPTION_SIZE ASN1_MAX_ERROR_DESCRIPTION_SIZE
-#endif
-
-#ifndef __attribute__
-  /* This feature is available in gcc versions 2.5 and later.  */
-# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)
-#  define __attribute__(Spec)  /* empty */
-# endif
-#endif
-
-  /* Use asn1_strerror instead. */
-  extern ASN1_API const char *libtasn1_strerror (asn1_retCode error)
-    __attribute__ ((deprecated));
-
-  /* Use asn1_perror instead. */
-  extern ASN1_API void
-    libtasn1_perror (asn1_retCode error) __attribute__ ((deprecated));
-
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif                         /* LIBTASN1_H */
diff --git a/asn1/parser_aux.c b/asn1/parser_aux.c
deleted file mode 100644
index 2e1f7ee..0000000
--- a/asn1/parser_aux.c
+++ /dev/null
@@ -1,1098 +0,0 @@
-/*
- * Copyright (C) 2000-2012 Free Software Foundation, Inc.
- *
- * This file is part of LIBTASN1.
- *
- * The LIBTASN1 library is free software; you can redistribute it
- * and/or modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA
- */
-
-#include <int.h>
-#include "parser_aux.h"
-#include "gstr.h"
-#include "structure.h"
-#include "element.h"
-
-char _asn1_identifierMissing[ASN1_MAX_NAME_SIZE + 1];  /* identifier name not 
found */
-
-/***********************************************/
-/* Type: list_type                             */
-/* Description: type used in the list during   */
-/* the structure creation.                     */
-/***********************************************/
-typedef struct list_struct
-{
-  ASN1_TYPE node;
-  struct list_struct *next;
-} list_type;
-
-
-/* Pointer to the first element of the list */
-list_type *firstElement = NULL;
-
-/******************************************************/
-/* Function : _asn1_add_node                          */
-/* Description: creates a new NODE_ASN element and    */
-/* puts it in the list pointed by firstElement.       */
-/* Parameters:                                        */
-/*   type: type of the new element (see TYPE_         */
-/*         and CONST_ constants).                     */
-/* Return: pointer to the new element.                */
-/******************************************************/
-ASN1_TYPE
-_asn1_add_node (unsigned int type)
-{
-  list_type *listElement;
-  ASN1_TYPE punt;
-
-  punt = (ASN1_TYPE) _asn1_calloc (1, sizeof (struct node_asn_struct));
-  if (punt == NULL)
-    return NULL;
-
-  listElement = (list_type *) _asn1_malloc (sizeof (list_type));
-  if (listElement == NULL)
-    {
-      _asn1_free (punt);
-      return NULL;
-    }
-
-  listElement->node = punt;
-  listElement->next = firstElement;
-  firstElement = listElement;
-
-  punt->type = type;
-
-  return punt;
-}
-
-/**
- * asn1_find_node:
- * @pointer: NODE_ASN element pointer.
- * @name: null terminated string with the element's name to find.
- *
- * Searches for an element called @name starting from @pointer.  The
- * name is composed by differents identifiers separated by dots.  When
- * address@hidden has a name, the first identifier must be the name of
- * address@hidden, otherwise it must be the name of one child of address@hidden
- *
- * Returns: the search result, or %NULL if not found.
- **/
-ASN1_TYPE
-asn1_find_node (ASN1_TYPE pointer, const char *name)
-{
-  ASN1_TYPE p;
-  char *n_end, n[ASN1_MAX_NAME_SIZE + 1];
-  const char *n_start;
-
-  if (pointer == NULL)
-    return NULL;
-
-  if (name == NULL)
-    return NULL;
-
-  p = pointer;
-  n_start = name;
-
-  if (p->name != NULL)
-    {                          /* has *pointer got a name ? */
-      n_end = strchr (n_start, '.');   /* search the first dot */
-      if (n_end)
-       {
-         memcpy (n, n_start, n_end - n_start);
-         n[n_end - n_start] = 0;
-         n_start = n_end;
-         n_start++;
-       }
-      else
-       {
-         _asn1_str_cpy (n, sizeof (n), n_start);
-         n_start = NULL;
-       }
-
-      while (p)
-       {
-         if ((p->name) && (!strcmp (p->name, n)))
-           break;
-         else
-           p = p->right;
-       }                       /* while */
-
-      if (p == NULL)
-       return NULL;
-    }
-  else
-    {                          /* *pointer doesn't have a name */
-      if (n_start[0] == 0)
-       return p;
-    }
-
-  while (n_start)
-    {                          /* Has the end of NAME been reached? */
-      n_end = strchr (n_start, '.');   /* search the next dot */
-      if (n_end)
-       {
-         memcpy (n, n_start, n_end - n_start);
-         n[n_end - n_start] = 0;
-         n_start = n_end;
-         n_start++;
-       }
-      else
-       {
-         _asn1_str_cpy (n, sizeof (n), n_start);
-         n_start = NULL;
-       }
-
-      if (p->down == NULL)
-       return NULL;
-
-      p = p->down;
-
-      /* The identifier "?LAST" indicates the last element
-         in the right chain. */
-      if (!strcmp (n, "?LAST"))
-       {
-         if (p == NULL)
-           return NULL;
-         while (p->right)
-           p = p->right;
-       }
-      else
-       {                       /* no "?LAST" */
-         while (p)
-           {
-             if ((p->name) && (!strcmp (p->name, n)))
-               break;
-             else
-               p = p->right;
-           }
-         if (p == NULL)
-           return NULL;
-       }
-    }                          /* while */
-
-  return p;
-}
-
-
-/******************************************************************/
-/* Function : _asn1_set_value                                     */
-/* Description: sets the field VALUE in a NODE_ASN element. The   */
-/*              previous value (if exist) will be lost            */
-/* Parameters:                                                    */
-/*   node: element pointer.                                       */
-/*   value: pointer to the value that you want to set.            */
-/*   len: character number of value.                              */
-/* Return: pointer to the NODE_ASN element.                       */
-/******************************************************************/
-ASN1_TYPE
-_asn1_set_value (ASN1_TYPE node, const void *value, unsigned int len)
-{
-  if (node == NULL)
-    return node;
-  if (node->value)
-    {
-      if (node->value != node->small_value)
-       _asn1_free (node->value);
-      node->value = NULL;
-      node->value_len = 0;
-    }
-
-  if (!len)
-    return node;
-
-  if (len < sizeof (node->small_value))
-    {
-      node->value = node->small_value;
-    }
-  else
-    {
-      node->value = _asn1_malloc (len);
-      if (node->value == NULL)
-       return NULL;
-    }
-  node->value_len = len;
-
-  memcpy (node->value, value, len);
-  return node;
-}
-
-/******************************************************************/
-/* Function : _asn1_set_value_octet                               */
-/* Description: sets the field VALUE in a NODE_ASN element. The   */
-/*              previous value (if exist) will be lost. The value */
-/*             given is stored as an octet string.               */
-/* Parameters:                                                    */
-/*   node: element pointer.                                       */
-/*   value: pointer to the value that you want to set.            */
-/*   len: character number of value.                              */
-/* Return: pointer to the NODE_ASN element.                       */
-/******************************************************************/
-ASN1_TYPE
-_asn1_set_value_octet (ASN1_TYPE node, const void *value, unsigned int len)
-{
-  int len2;
-  void *temp;
-
-  if (node == NULL)
-    return node;
-
-  asn1_length_der (len, NULL, &len2);
-  temp = (unsigned char *) _asn1_malloc (len + len2);
-  if (temp == NULL)
-    return NULL;
-
-  asn1_octet_der (value, len, temp, &len2);
-  return _asn1_set_value_m (node, temp, len2);
-}
-
-/* the same as _asn1_set_value except that it sets an already malloc'ed
- * value.
- */
-ASN1_TYPE
-_asn1_set_value_m (ASN1_TYPE node, void *value, unsigned int len)
-{
-  if (node == NULL)
-    return node;
-
-  if (node->value)
-    {
-      if (node->value != node->small_value)
-       _asn1_free (node->value);
-      node->value = NULL;
-      node->value_len = 0;
-    }
-
-  if (!len)
-    return node;
-
-  node->value = value;
-  node->value_len = len;
-
-  return node;
-}
-
-/******************************************************************/
-/* Function : _asn1_append_value                                  */
-/* Description: appends to the field VALUE in a NODE_ASN element. */
-/*                                                               */
-/* Parameters:                                                    */
-/*   node: element pointer.                                       */
-/*   value: pointer to the value that you want to be appended.    */
-/*   len: character number of value.                              */
-/* Return: pointer to the NODE_ASN element.                       */
-/******************************************************************/
-ASN1_TYPE
-_asn1_append_value (ASN1_TYPE node, const void *value, unsigned int len)
-{
-  if (node == NULL)
-    return node;
-  if (node->value != NULL && node->value != node->small_value)
-    {
-      /* value is allocated */
-      int prev_len = node->value_len;
-      node->value_len += len;
-      node->value = _asn1_realloc (node->value, node->value_len);
-      if (node->value == NULL)
-       {
-         node->value_len = 0;
-         return NULL;
-       }
-      memcpy (&node->value[prev_len], value, len);
-
-      return node;
-    }
-  else if (node->value == node->small_value)
-    {
-      /* value is in node */
-      int prev_len = node->value_len;
-      node->value_len += len;
-      node->value = _asn1_malloc (node->value_len);
-      if (node->value == NULL)
-       {
-         node->value_len = 0;
-         return NULL;
-       }
-      memcpy (node->value, node->small_value, prev_len);
-      memcpy (&node->value[prev_len], value, len);
-
-      return node;
-    }
-  else                         /* node->value == NULL */
-    return _asn1_set_value (node, value, len);
-}
-
-/******************************************************************/
-/* Function : _asn1_set_name                                      */
-/* Description: sets the field NAME in a NODE_ASN element. The    */
-/*              previous value (if exist) will be lost            */
-/* Parameters:                                                    */
-/*   node: element pointer.                                       */
-/*   name: a null terminated string with the name that you want   */
-/*         to set.                                                */
-/* Return: pointer to the NODE_ASN element.                       */
-/******************************************************************/
-ASN1_TYPE
-_asn1_set_name (ASN1_TYPE node, const char *name)
-{
-  if (node == NULL)
-    return node;
-
-  if (node->name)
-    {
-      _asn1_free (node->name);
-      node->name = NULL;
-    }
-
-  if (name == NULL)
-    return node;
-
-  if (strlen (name))
-    {
-      node->name = (char *) _asn1_strdup (name);
-      if (node->name == NULL)
-       return NULL;
-    }
-  else
-    node->name = NULL;
-  return node;
-}
-
-/******************************************************************/
-/* Function : _asn1_set_right                                     */
-/* Description: sets the field RIGHT in a NODE_ASN element.       */
-/* Parameters:                                                    */
-/*   node: element pointer.                                       */
-/*   right: pointer to a NODE_ASN element that you want be pointed*/
-/*          by NODE.                                              */
-/* Return: pointer to *NODE.                                      */
-/******************************************************************/
-ASN1_TYPE
-_asn1_set_right (ASN1_TYPE node, ASN1_TYPE right)
-{
-  if (node == NULL)
-    return node;
-  node->right = right;
-  if (right)
-    right->left = node;
-  return node;
-}
-
-/******************************************************************/
-/* Function : _asn1_get_right                                     */
-/* Description: returns the element pointed by the RIGHT field of */
-/*              a NODE_ASN element.                               */
-/* Parameters:                                                    */
-/*   node: NODE_ASN element pointer.                              */
-/* Return: field RIGHT of NODE.                                   */
-/******************************************************************/
-ASN1_TYPE
-_asn1_get_right (ASN1_TYPE node)
-{
-  if (node == NULL)
-    return NULL;
-  return node->right;
-}
-
-/******************************************************************/
-/* Function : _asn1_get_last_right                                */
-/* Description: return the last element along the right chain.    */
-/* Parameters:                                                    */
-/*   node: starting element pointer.                              */
-/* Return: pointer to the last element along the right chain.     */
-/******************************************************************/
-ASN1_TYPE
-_asn1_get_last_right (ASN1_TYPE node)
-{
-  ASN1_TYPE p;
-
-  if (node == NULL)
-    return NULL;
-  p = node;
-  while (p->right)
-    p = p->right;
-  return p;
-}
-
-/******************************************************************/
-/* Function : _asn1_set_down                                      */
-/* Description: sets the field DOWN in a NODE_ASN element.        */
-/* Parameters:                                                    */
-/*   node: element pointer.                                       */
-/*   down: pointer to a NODE_ASN element that you want be pointed */
-/*          by NODE.                                              */
-/* Return: pointer to *NODE.                                      */
-/******************************************************************/
-ASN1_TYPE
-_asn1_set_down (ASN1_TYPE node, ASN1_TYPE down)
-{
-  if (node == NULL)
-    return node;
-  node->down = down;
-  if (down)
-    down->left = node;
-  return node;
-}
-
-/******************************************************************/
-/* Function : _asn1_get_down                                      */
-/* Description: returns the element pointed by the DOWN field of  */
-/*              a NODE_ASN element.                               */
-/* Parameters:                                                    */
-/*   node: NODE_ASN element pointer.                              */
-/* Return: field DOWN of NODE.                                    */
-/******************************************************************/
-ASN1_TYPE
-_asn1_get_down (ASN1_TYPE node)
-{
-  if (node == NULL)
-    return NULL;
-  return node->down;
-}
-
-/******************************************************************/
-/* Function : _asn1_get_name                                      */
-/* Description: returns the name of a NODE_ASN element.           */
-/* Parameters:                                                    */
-/*   node: NODE_ASN element pointer.                              */
-/* Return: a null terminated string.                              */
-/******************************************************************/
-char *
-_asn1_get_name (ASN1_TYPE node)
-{
-  if (node == NULL)
-    return NULL;
-  return node->name;
-}
-
-/******************************************************************/
-/* Function : _asn1_mod_type                                      */
-/* Description: change the field TYPE of an NODE_ASN element.     */
-/*              The new value is the old one | (bitwise or) the   */
-/*              paramener VALUE.                                  */
-/* Parameters:                                                    */
-/*   node: NODE_ASN element pointer.                              */
-/*   value: the integer value that must be or-ed with the current */
-/*          value of field TYPE.                                  */
-/* Return: NODE pointer.                                          */
-/******************************************************************/
-ASN1_TYPE
-_asn1_mod_type (ASN1_TYPE node, unsigned int value)
-{
-  if (node == NULL)
-    return node;
-  node->type |= value;
-  return node;
-}
-
-
-/******************************************************************/
-/* Function : _asn1_remove_node                                   */
-/* Description: gets free the memory allocated for an NODE_ASN    */
-/*              element (not the elements pointed by it).         */
-/* Parameters:                                                    */
-/*   node: NODE_ASN element pointer.                              */
-/******************************************************************/
-void
-_asn1_remove_node (ASN1_TYPE node)
-{
-  if (node == NULL)
-    return;
-
-  if (node->name != NULL)
-    _asn1_free (node->name);
-  if (node->value != NULL && node->value != node->small_value)
-    _asn1_free (node->value);
-  _asn1_free (node);
-}
-
-/******************************************************************/
-/* Function : _asn1_find_up                                       */
-/* Description: return the father of the NODE_ASN element.        */
-/* Parameters:                                                    */
-/*   node: NODE_ASN element pointer.                              */
-/* Return: Null if not found.                                     */
-/******************************************************************/
-ASN1_TYPE
-_asn1_find_up (ASN1_TYPE node)
-{
-  ASN1_TYPE p;
-
-  if (node == NULL)
-    return NULL;
-
-  p = node;
-
-  while ((p->left != NULL) && (p->left->right == p))
-    p = p->left;
-
-  return p->left;
-}
-
-/******************************************************************/
-/* Function : _asn1_delete_list                                   */
-/* Description: deletes the list elements (not the elements       */
-/*  pointed by them).                                             */
-/******************************************************************/
-void
-_asn1_delete_list (void)
-{
-  list_type *listElement;
-
-  while (firstElement)
-    {
-      listElement = firstElement;
-      firstElement = firstElement->next;
-      _asn1_free (listElement);
-    }
-}
-
-/******************************************************************/
-/* Function : _asn1_delete_list_and nodes                         */
-/* Description: deletes the list elements and the elements        */
-/*  pointed by them.                                              */
-/******************************************************************/
-void
-_asn1_delete_list_and_nodes (void)
-{
-  list_type *listElement;
-
-  while (firstElement)
-    {
-      listElement = firstElement;
-      firstElement = firstElement->next;
-      _asn1_remove_node (listElement->node);
-      _asn1_free (listElement);
-    }
-}
-
-
-char *
-_asn1_ltostr (long v, char *str)
-{
-  long d, r;
-  char temp[20];
-  int count, k, start;
-
-  if (v < 0)
-    {
-      str[0] = '-';
-      start = 1;
-      v = -v;
-    }
-  else
-    start = 0;
-
-  count = 0;
-  do
-    {
-      d = v / 10;
-      r = v - d * 10;
-      temp[start + count] = '0' + (char) r;
-      count++;
-      v = d;
-    }
-  while (v);
-
-  for (k = 0; k < count; k++)
-    str[k + start] = temp[start + count - k - 1];
-  str[count + start] = 0;
-  return str;
-}
-
-
-/******************************************************************/
-/* Function : _asn1_change_integer_value                          */
-/* Description: converts into DER coding the value assign to an   */
-/*   INTEGER constant.                                            */
-/* Parameters:                                                    */
-/*   node: root of an ASN1element.                                */
-/* Return:                                                        */
-/*   ASN1_ELEMENT_NOT_FOUND if NODE is NULL,                       */
-/*   otherwise ASN1_SUCCESS                                             */
-/******************************************************************/
-asn1_retCode
-_asn1_change_integer_value (ASN1_TYPE node)
-{
-  ASN1_TYPE p;
-  unsigned char val[SIZEOF_UNSIGNED_LONG_INT];
-  unsigned char val2[SIZEOF_UNSIGNED_LONG_INT + 1];
-  int len;
-
-  if (node == NULL)
-    return ASN1_ELEMENT_NOT_FOUND;
-
-  p = node;
-  while (p)
-    {
-      if ((type_field (p->type) == TYPE_INTEGER) && (p->type & CONST_ASSIGN))
-       {
-         if (p->value)
-           {
-             _asn1_convert_integer (p->value, val, sizeof (val), &len);
-             asn1_octet_der (val, len, val2, &len);
-             _asn1_set_value (p, val2, len);
-           }
-       }
-
-      if (p->down)
-       {
-         p = p->down;
-       }
-      else
-       {
-         if (p == node)
-           p = NULL;
-         else if (p->right)
-           p = p->right;
-         else
-           {
-             while (1)
-               {
-                 p = _asn1_find_up (p);
-                 if (p == node)
-                   {
-                     p = NULL;
-                     break;
-                   }
-                 if (p->right)
-                   {
-                     p = p->right;
-                     break;
-                   }
-               }
-           }
-       }
-    }
-
-  return ASN1_SUCCESS;
-}
-
-
-/******************************************************************/
-/* Function : _asn1_expand_object_id                              */
-/* Description: expand the IDs of an OBJECT IDENTIFIER constant.  */
-/* Parameters:                                                    */
-/*   node: root of an ASN1 element.                               */
-/* Return:                                                        */
-/*   ASN1_ELEMENT_NOT_FOUND if NODE is NULL,                       */
-/*   otherwise ASN1_SUCCESS                                             */
-/******************************************************************/
-asn1_retCode
-_asn1_expand_object_id (ASN1_TYPE node)
-{
-  ASN1_TYPE p, p2, p3, p4, p5;
-  char name_root[ASN1_MAX_NAME_SIZE], name2[2 * ASN1_MAX_NAME_SIZE + 1];
-  int move, tlen;
-
-  if (node == NULL)
-    return ASN1_ELEMENT_NOT_FOUND;
-
-  _asn1_str_cpy (name_root, sizeof (name_root), node->name);
-
-  p = node;
-  move = DOWN;
-
-  while (!((p == node) && (move == UP)))
-    {
-      if (move != UP)
-       {
-         if ((type_field (p->type) == TYPE_OBJECT_ID)
-             && (p->type & CONST_ASSIGN))
-           {
-             p2 = p->down;
-             if (p2 && (type_field (p2->type) == TYPE_CONSTANT))
-               {
-                 if (p2->value && !isdigit (p2->value[0]))
-                   {
-                     _asn1_str_cpy (name2, sizeof (name2), name_root);
-                     _asn1_str_cat (name2, sizeof (name2), ".");
-                     _asn1_str_cat (name2, sizeof (name2),
-                                    (char *) p2->value);
-                     p3 = asn1_find_node (node, name2);
-                     if (!p3 || (type_field (p3->type) != TYPE_OBJECT_ID) ||
-                         !(p3->type & CONST_ASSIGN))
-                       return ASN1_ELEMENT_NOT_FOUND;
-                     _asn1_set_down (p, p2->right);
-                     _asn1_remove_node (p2);
-                     p2 = p;
-                     p4 = p3->down;
-                     while (p4)
-                       {
-                         if (type_field (p4->type) == TYPE_CONSTANT)
-                           {
-                             p5 = _asn1_add_node_only (TYPE_CONSTANT);
-                             _asn1_set_name (p5, p4->name);
-                             tlen = _asn1_strlen (p4->value);
-                             if (tlen > 0)
-                               _asn1_set_value (p5, p4->value, tlen + 1);
-                             if (p2 == p)
-                               {
-                                 _asn1_set_right (p5, p->down);
-                                 _asn1_set_down (p, p5);
-                               }
-                             else
-                               {
-                                 _asn1_set_right (p5, p2->right);
-                                 _asn1_set_right (p2, p5);
-                               }
-                             p2 = p5;
-                           }
-                         p4 = p4->right;
-                       }
-                     move = DOWN;
-                     continue;
-                   }
-               }
-           }
-         move = DOWN;
-       }
-      else
-       move = RIGHT;
-
-      if (move == DOWN)
-       {
-         if (p->down)
-           p = p->down;
-         else
-           move = RIGHT;
-       }
-
-      if (p == node)
-       {
-         move = UP;
-         continue;
-       }
-
-      if (move == RIGHT)
-       {
-         if (p->right)
-           p = p->right;
-         else
-           move = UP;
-       }
-      if (move == UP)
-       p = _asn1_find_up (p);
-    }
-
-
-  /*******************************/
-  /*       expand DEFAULT        */
-  /*******************************/
-  p = node;
-  move = DOWN;
-
-  while (!((p == node) && (move == UP)))
-    {
-      if (move != UP)
-       {
-         if ((type_field (p->type) == TYPE_OBJECT_ID) &&
-             (p->type & CONST_DEFAULT))
-           {
-             p2 = p->down;
-             if (p2 && (type_field (p2->type) == TYPE_DEFAULT))
-               {
-                 _asn1_str_cpy (name2, sizeof (name2), name_root);
-                 _asn1_str_cat (name2, sizeof (name2), ".");
-                 _asn1_str_cat (name2, sizeof (name2), (char *) p2->value);
-                 p3 = asn1_find_node (node, name2);
-                 if (!p3 || (type_field (p3->type) != TYPE_OBJECT_ID) ||
-                     !(p3->type & CONST_ASSIGN))
-                   return ASN1_ELEMENT_NOT_FOUND;
-                 p4 = p3->down;
-                 name2[0] = 0;
-                 while (p4)
-                   {
-                     if (type_field (p4->type) == TYPE_CONSTANT)
-                       {
-                         if (name2[0])
-                           _asn1_str_cat (name2, sizeof (name2), ".");
-                         _asn1_str_cat (name2, sizeof (name2),
-                                        (char *) p4->value);
-                       }
-                     p4 = p4->right;
-                   }
-                 tlen = strlen (name2);
-                 if (tlen > 0)
-                   _asn1_set_value (p2, name2, tlen + 1);
-               }
-           }
-         move = DOWN;
-       }
-      else
-       move = RIGHT;
-
-      if (move == DOWN)
-       {
-         if (p->down)
-           p = p->down;
-         else
-           move = RIGHT;
-       }
-
-      if (p == node)
-       {
-         move = UP;
-         continue;
-       }
-
-      if (move == RIGHT)
-       {
-         if (p->right)
-           p = p->right;
-         else
-           move = UP;
-       }
-      if (move == UP)
-       p = _asn1_find_up (p);
-    }
-
-  return ASN1_SUCCESS;
-}
-
-
-/******************************************************************/
-/* Function : _asn1_type_set_config                               */
-/* Description: sets the CONST_SET and CONST_NOT_USED properties  */
-/*   in the fields of the SET elements.                           */
-/* Parameters:                                                    */
-/*   node: root of an ASN1 element.                               */
-/* Return:                                                        */
-/*   ASN1_ELEMENT_NOT_FOUND if NODE is NULL,                       */
-/*   otherwise ASN1_SUCCESS                                             */
-/******************************************************************/
-asn1_retCode
-_asn1_type_set_config (ASN1_TYPE node)
-{
-  ASN1_TYPE p, p2;
-  int move;
-
-  if (node == NULL)
-    return ASN1_ELEMENT_NOT_FOUND;
-
-  p = node;
-  move = DOWN;
-
-  while (!((p == node) && (move == UP)))
-    {
-      if (move != UP)
-       {
-         if (type_field (p->type) == TYPE_SET)
-           {
-             p2 = p->down;
-             while (p2)
-               {
-                 if (type_field (p2->type) != TYPE_TAG)
-                   p2->type |= CONST_SET | CONST_NOT_USED;
-                 p2 = p2->right;
-               }
-           }
-         move = DOWN;
-       }
-      else
-       move = RIGHT;
-
-      if (move == DOWN)
-       {
-         if (p->down)
-           p = p->down;
-         else
-           move = RIGHT;
-       }
-
-      if (p == node)
-       {
-         move = UP;
-         continue;
-       }
-
-      if (move == RIGHT)
-       {
-         if (p->right)
-           p = p->right;
-         else
-           move = UP;
-       }
-      if (move == UP)
-       p = _asn1_find_up (p);
-    }
-
-  return ASN1_SUCCESS;
-}
-
-
-/******************************************************************/
-/* Function : _asn1_check_identifier                              */
-/* Description: checks the definitions of all the identifiers     */
-/*   and the first element of an OBJECT_ID (e.g. {pkix 0 4}).     */
-/*   The _asn1_identifierMissing global variable is filled if     */
-/*   necessary.                                                   */
-/* Parameters:                                                    */
-/*   node: root of an ASN1 element.                               */
-/* Return:                                                        */
-/*   ASN1_ELEMENT_NOT_FOUND      if NODE is NULL,                 */
-/*   ASN1_IDENTIFIER_NOT_FOUND   if an identifier is not defined, */
-/*   otherwise ASN1_SUCCESS                                       */
-/******************************************************************/
-asn1_retCode
-_asn1_check_identifier (ASN1_TYPE node)
-{
-  ASN1_TYPE p, p2;
-  char name2[ASN1_MAX_NAME_SIZE * 2 + 2];
-
-  if (node == NULL)
-    return ASN1_ELEMENT_NOT_FOUND;
-
-  p = node;
-  while (p)
-    {
-      if (type_field (p->type) == TYPE_IDENTIFIER)
-       {
-         _asn1_str_cpy (name2, sizeof (name2), node->name);
-         _asn1_str_cat (name2, sizeof (name2), ".");
-         _asn1_str_cat (name2, sizeof (name2), (char *) p->value);
-         p2 = asn1_find_node (node, name2);
-         if (p2 == NULL)
-           {
-             _asn1_strcpy (_asn1_identifierMissing, p->value);
-             return ASN1_IDENTIFIER_NOT_FOUND;
-           }
-       }
-      else if ((type_field (p->type) == TYPE_OBJECT_ID) &&
-              (p->type & CONST_DEFAULT))
-       {
-         p2 = p->down;
-         if (p2 && (type_field (p2->type) == TYPE_DEFAULT))
-           {
-             _asn1_str_cpy (name2, sizeof (name2), node->name);
-             _asn1_str_cat (name2, sizeof (name2), ".");
-             _asn1_str_cat (name2, sizeof (name2), (char *) p2->value);
-             _asn1_strcpy (_asn1_identifierMissing, p2->value);
-             p2 = asn1_find_node (node, name2);
-             if (!p2 || (type_field (p2->type) != TYPE_OBJECT_ID) ||
-                 !(p2->type & CONST_ASSIGN))
-               return ASN1_IDENTIFIER_NOT_FOUND;
-             else
-               _asn1_identifierMissing[0] = 0;
-           }
-       }
-      else if ((type_field (p->type) == TYPE_OBJECT_ID) &&
-              (p->type & CONST_ASSIGN))
-       {
-         p2 = p->down;
-         if (p2 && (type_field (p2->type) == TYPE_CONSTANT))
-           {
-             if (p2->value && !isdigit (p2->value[0]))
-               {
-                 _asn1_str_cpy (name2, sizeof (name2), node->name);
-                 _asn1_str_cat (name2, sizeof (name2), ".");
-                 _asn1_str_cat (name2, sizeof (name2), (char *) p2->value);
-                 _asn1_strcpy (_asn1_identifierMissing, p2->value);
-                 p2 = asn1_find_node (node, name2);
-                 if (!p2 || (type_field (p2->type) != TYPE_OBJECT_ID) ||
-                     !(p2->type & CONST_ASSIGN))
-                   return ASN1_IDENTIFIER_NOT_FOUND;
-                 else
-                   _asn1_identifierMissing[0] = 0;
-               }
-           }
-       }
-
-      if (p->down)
-       {
-         p = p->down;
-       }
-      else if (p->right)
-       p = p->right;
-      else
-       {
-         while (1)
-           {
-             p = _asn1_find_up (p);
-             if (p == node)
-               {
-                 p = NULL;
-                 break;
-               }
-             if (p->right)
-               {
-                 p = p->right;
-                 break;
-               }
-           }
-       }
-    }
-
-  return ASN1_SUCCESS;
-}
-
-
-/******************************************************************/
-/* Function : _asn1_set_default_tag                               */
-/* Description: sets the default IMPLICIT or EXPLICIT property in */
-/*   the tagged elements that don't have this declaration.        */
-/* Parameters:                                                    */
-/*   node: pointer to a DEFINITIONS element.                      */
-/* Return:                                                        */
-/*   ASN1_ELEMENT_NOT_FOUND if NODE is NULL or not a pointer to   */
-/*     a DEFINITIONS element,                                     */
-/*   otherwise ASN1_SUCCESS                                       */
-/******************************************************************/
-asn1_retCode
-_asn1_set_default_tag (ASN1_TYPE node)
-{
-  ASN1_TYPE p;
-
-  if ((node == NULL) || (type_field (node->type) != TYPE_DEFINITIONS))
-    return ASN1_ELEMENT_NOT_FOUND;
-
-  p = node;
-  while (p)
-    {
-      if ((type_field (p->type) == TYPE_TAG) &&
-         !(p->type & CONST_EXPLICIT) && !(p->type & CONST_IMPLICIT))
-       {
-         if (node->type & CONST_EXPLICIT)
-           p->type |= CONST_EXPLICIT;
-         else
-           p->type |= CONST_IMPLICIT;
-       }
-
-      if (p->down)
-       {
-         p = p->down;
-       }
-      else if (p->right)
-       p = p->right;
-      else
-       {
-         while (1)
-           {
-             p = _asn1_find_up (p);
-             if (p == node)
-               {
-                 p = NULL;
-                 break;
-               }
-             if (p->right)
-               {
-                 p = p->right;
-                 break;
-               }
-           }
-       }
-    }
-
-  return ASN1_SUCCESS;
-}
diff --git a/asn1/parser_aux.h b/asn1/parser_aux.h
deleted file mode 100644
index 374f599..0000000
--- a/asn1/parser_aux.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (C) 2000-2012 Free Software Foundation, Inc.
- *
- * This file is part of LIBTASN1.
- *
- * The LIBTASN1 library is free software; you can redistribute it
- * and/or modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA
- */
-
-#ifndef _PARSER_AUX_H
-#define _PARSER_AUX_H
-
-#define DER_LEN 16
-
-/***************************************/
-/*  Functions used by ASN.1 parser     */
-/***************************************/
-ASN1_TYPE _asn1_add_node (unsigned int type);
-
-ASN1_TYPE
-_asn1_set_value (ASN1_TYPE node, const void *value, unsigned int len);
-
-ASN1_TYPE _asn1_set_value_m (ASN1_TYPE node, void *value, unsigned int len);
-
-ASN1_TYPE
-_asn1_set_value_octet (ASN1_TYPE node, const void *value, unsigned int len);
-
-ASN1_TYPE
-_asn1_append_value (ASN1_TYPE node, const void *value, unsigned int len);
-
-ASN1_TYPE _asn1_set_name (ASN1_TYPE node, const char *name);
-
-ASN1_TYPE _asn1_set_right (ASN1_TYPE node, ASN1_TYPE right);
-
-ASN1_TYPE _asn1_get_right (ASN1_TYPE node);
-
-ASN1_TYPE _asn1_get_last_right (ASN1_TYPE node);
-
-ASN1_TYPE _asn1_set_down (ASN1_TYPE node, ASN1_TYPE down);
-
-char *_asn1_get_name (ASN1_TYPE node);
-
-ASN1_TYPE _asn1_get_down (ASN1_TYPE node);
-
-ASN1_TYPE _asn1_mod_type (ASN1_TYPE node, unsigned int value);
-
-void _asn1_remove_node (ASN1_TYPE node);
-
-void _asn1_delete_list (void);
-
-void _asn1_delete_list_and_nodes (void);
-
-char *_asn1_ltostr (long v, char *str);
-
-ASN1_TYPE _asn1_find_up (ASN1_TYPE node);
-
-asn1_retCode _asn1_change_integer_value (ASN1_TYPE node);
-
-asn1_retCode _asn1_expand_object_id (ASN1_TYPE node);
-
-asn1_retCode _asn1_type_set_config (ASN1_TYPE node);
-
-asn1_retCode _asn1_check_identifier (ASN1_TYPE node);
-
-asn1_retCode _asn1_set_default_tag (ASN1_TYPE node);
-
-#endif
diff --git a/asn1/structure.c b/asn1/structure.c
deleted file mode 100644
index 41cebe4..0000000
--- a/asn1/structure.c
+++ /dev/null
@@ -1,1195 +0,0 @@
-/*
- * Copyright (C) 2002-2012 Free Software Foundation, Inc.
- *
- * This file is part of LIBTASN1.
- *
- * The LIBTASN1 library is free software; you can redistribute it
- * and/or modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA
- */
-
-
-/*****************************************************/
-/* File: structure.c                                 */
-/* Description: Functions to create and delete an    */
-/*  ASN1 tree.                                       */
-/*****************************************************/
-
-
-#include <int.h>
-#include <structure.h>
-#include "parser_aux.h"
-#include <gstr.h>
-
-
-extern char _asn1_identifierMissing[];
-
-
-/******************************************************/
-/* Function : _asn1_add_node_only                     */
-/* Description: creates a new NODE_ASN element.       */
-/* Parameters:                                        */
-/*   type: type of the new element (see TYPE_         */
-/*         and CONST_ constants).                     */
-/* Return: pointer to the new element.                */
-/******************************************************/
-ASN1_TYPE
-_asn1_add_node_only (unsigned int type)
-{
-  ASN1_TYPE punt;
-
-  punt = (ASN1_TYPE) _asn1_calloc (1, sizeof (struct node_asn_struct));
-  if (punt == NULL)
-    return NULL;
-
-  punt->type = type;
-
-  return punt;
-}
-
-
-/******************************************************************/
-/* Function : _asn1_find_left                                     */
-/* Description: returns the NODE_ASN element with RIGHT field that*/
-/*              points the element NODE.                          */
-/* Parameters:                                                    */
-/*   node: NODE_ASN element pointer.                              */
-/* Return: NULL if not found.                                     */
-/******************************************************************/
-ASN1_TYPE
-_asn1_find_left (ASN1_TYPE node)
-{
-  if ((node == NULL) || (node->left == NULL) || (node->left->down == node))
-    return NULL;
-
-  return node->left;
-}
-
-
-asn1_retCode
-_asn1_create_static_structure (ASN1_TYPE pointer, char *output_file_name,
-                              char *vector_name)
-{
-  FILE *file;
-  ASN1_TYPE p;
-  unsigned long t;
-
-  file = fopen (output_file_name, "w");
-
-  if (file == NULL)
-    return ASN1_FILE_NOT_FOUND;
-
-  fprintf (file, "#if HAVE_CONFIG_H\n");
-  fprintf (file, "# include \"config.h\"\n");
-  fprintf (file, "#endif\n\n");
-
-  fprintf (file, "#include <libtasn1.h>\n\n");
-
-  fprintf (file, "const ASN1_ARRAY_TYPE %s[] = {\n", vector_name);
-
-  p = pointer;
-
-  while (p)
-    {
-      fprintf (file, "  { ");
-
-      if (p->name)
-       fprintf (file, "\"%s\", ", p->name);
-      else
-       fprintf (file, "NULL, ");
-
-      t = p->type;
-      if (p->down)
-       t |= CONST_DOWN;
-      if (p->right)
-       t |= CONST_RIGHT;
-
-      fprintf (file, "%lu, ", t);
-
-      if (p->value)
-       fprintf (file, "\"%s\"},\n", p->value);
-      else
-       fprintf (file, "NULL },\n");
-
-      if (p->down)
-       {
-         p = p->down;
-       }
-      else if (p->right)
-       {
-         p = p->right;
-       }
-      else
-       {
-         while (1)
-           {
-             p = _asn1_find_up (p);
-             if (p == pointer)
-               {
-                 p = NULL;
-                 break;
-               }
-             if (p->right)
-               {
-                 p = p->right;
-                 break;
-               }
-           }
-       }
-    }
-
-  fprintf (file, "  { NULL, 0, NULL }\n};\n");
-
-  fclose (file);
-
-  return ASN1_SUCCESS;
-}
-
-
-/**
- * asn1_array2tree:
- * @array: specify the array that contains ASN.1 declarations
- * @definitions: return the pointer to the structure created by
- *   *ARRAY ASN.1 declarations
- * @errorDescription: return the error description.
- *
- * Creates the structures needed to manage the ASN.1 definitions.
- * @array is a vector created by asn1_parser2array().
- *
- * Returns: %ASN1_SUCCESS if structure was created correctly,
- *   %ASN1_ELEMENT_NOT_EMPTY if address@hidden not ASN1_TYPE_EMPTY,
- *   %ASN1_IDENTIFIER_NOT_FOUND if in the file there is an identifier
- *   that is not defined (see @errorDescription for more information),
- *   %ASN1_ARRAY_ERROR if the array pointed by @array is wrong.
- **/
-asn1_retCode
-asn1_array2tree (const ASN1_ARRAY_TYPE * array, ASN1_TYPE * definitions,
-                char *errorDescription)
-{
-  ASN1_TYPE p, p_last = NULL;
-  unsigned long k;
-  int move;
-  asn1_retCode result;
-
-
-  if (*definitions != ASN1_TYPE_EMPTY)
-    return ASN1_ELEMENT_NOT_EMPTY;
-
-  move = UP;
-
-  k = 0;
-  while (array[k].value || array[k].type || array[k].name)
-    {
-      p = _asn1_add_node (array[k].type & (~CONST_DOWN));
-      if (array[k].name)
-       _asn1_set_name (p, array[k].name);
-      if (array[k].value)
-       _asn1_set_value (p, array[k].value, strlen (array[k].value) + 1);
-
-      if (*definitions == NULL)
-       *definitions = p;
-
-      if (move == DOWN)
-       _asn1_set_down (p_last, p);
-      else if (move == RIGHT)
-       _asn1_set_right (p_last, p);
-
-      p_last = p;
-
-      if (array[k].type & CONST_DOWN)
-       move = DOWN;
-      else if (array[k].type & CONST_RIGHT)
-       move = RIGHT;
-      else
-       {
-         while (1)
-           {
-             if (p_last == *definitions)
-               break;
-
-             p_last = _asn1_find_up (p_last);
-
-             if (p_last == NULL)
-               break;
-
-             if (p_last->type & CONST_RIGHT)
-               {
-                 p_last->type &= ~CONST_RIGHT;
-                 move = RIGHT;
-                 break;
-               }
-           }                   /* while */
-       }
-      k++;
-    }                          /* while */
-
-  if (p_last == *definitions)
-    {
-      result = _asn1_check_identifier (*definitions);
-      if (result == ASN1_SUCCESS)
-       {
-         _asn1_change_integer_value (*definitions);
-         _asn1_expand_object_id (*definitions);
-       }
-    }
-  else
-    {
-      result = ASN1_ARRAY_ERROR;
-    }
-
-  if (errorDescription != NULL)
-    {
-      if (result == ASN1_IDENTIFIER_NOT_FOUND)
-       {
-         Estrcpy (errorDescription, ":: identifier '");
-         Estrcat (errorDescription, _asn1_identifierMissing);
-         Estrcat (errorDescription, "' not found");
-       }
-      else
-       errorDescription[0] = 0;
-    }
-
-  if (result != ASN1_SUCCESS)
-    {
-      _asn1_delete_list_and_nodes ();
-      *definitions = ASN1_TYPE_EMPTY;
-    }
-  else
-    _asn1_delete_list ();
-
-  return result;
-}
-
-/**
- * asn1_delete_structure:
- * @structure: pointer to the structure that you want to delete.
- *
- * Deletes the structure address@hidden  At the end, address@hidden is set
- * to ASN1_TYPE_EMPTY.
- *
- * Returns: %ASN1_SUCCESS if successful, %ASN1_ELEMENT_NOT_FOUND if
- *   address@hidden was ASN1_TYPE_EMPTY.
- **/
-asn1_retCode
-asn1_delete_structure (ASN1_TYPE * structure)
-{
-  ASN1_TYPE p, p2, p3;
-
-  if (*structure == ASN1_TYPE_EMPTY)
-    return ASN1_ELEMENT_NOT_FOUND;
-
-  p = *structure;
-  while (p)
-    {
-      if (p->down)
-       {
-         p = p->down;
-       }
-      else
-       {                       /* no down */
-         p2 = p->right;
-         if (p != *structure)
-           {
-             p3 = _asn1_find_up (p);
-             _asn1_set_down (p3, p2);
-             _asn1_remove_node (p);
-             p = p3;
-           }
-         else
-           {                   /* p==root */
-             p3 = _asn1_find_left (p);
-             if (!p3)
-               {
-                 p3 = _asn1_find_up (p);
-                 if (p3)
-                   _asn1_set_down (p3, p2);
-                 else
-                   {
-                     if (p->right)
-                       p->right->left = NULL;
-                   }
-               }
-             else
-               _asn1_set_right (p3, p2);
-             _asn1_remove_node (p);
-             p = NULL;
-           }
-       }
-    }
-
-  *structure = ASN1_TYPE_EMPTY;
-  return ASN1_SUCCESS;
-}
-
-
-
-/**
- * asn1_delete_element:
- * @structure: pointer to the structure that contains the element you
- *   want to delete.
- * @element_name: element's name you want to delete.
- *
- * Deletes the element named address@hidden inside address@hidden
- *
- * Returns: %ASN1_SUCCESS if successful, %ASN1_ELEMENT_NOT_FOUND if
- *   the @element_name was not found.
- **/
-asn1_retCode
-asn1_delete_element (ASN1_TYPE structure, const char *element_name)
-{
-  ASN1_TYPE p2, p3, source_node;
-
-  source_node = asn1_find_node (structure, element_name);
-
-  if (source_node == ASN1_TYPE_EMPTY)
-    return ASN1_ELEMENT_NOT_FOUND;
-
-  p2 = source_node->right;
-  p3 = _asn1_find_left (source_node);
-  if (!p3)
-    {
-      p3 = _asn1_find_up (source_node);
-      if (p3)
-       _asn1_set_down (p3, p2);
-      else if (source_node->right)
-       source_node->right->left = NULL;
-    }
-  else
-    _asn1_set_right (p3, p2);
-
-  return asn1_delete_structure (&source_node);
-}
-
-ASN1_TYPE
-_asn1_copy_structure3 (ASN1_TYPE source_node)
-{
-  ASN1_TYPE dest_node, p_s, p_d, p_d_prev;
-  int move;
-
-  if (source_node == NULL)
-    return NULL;
-
-  dest_node = _asn1_add_node_only (source_node->type);
-
-  p_s = source_node;
-  p_d = dest_node;
-
-  move = DOWN;
-
-  do
-    {
-      if (move != UP)
-       {
-         if (p_s->name)
-           _asn1_set_name (p_d, p_s->name);
-         if (p_s->value)
-           _asn1_set_value (p_d, p_s->value, p_s->value_len);
-         move = DOWN;
-       }
-      else
-       move = RIGHT;
-
-      if (move == DOWN)
-       {
-         if (p_s->down)
-           {
-             p_s = p_s->down;
-             p_d_prev = p_d;
-             p_d = _asn1_add_node_only (p_s->type);
-             _asn1_set_down (p_d_prev, p_d);
-           }
-         else
-           move = RIGHT;
-       }
-
-      if (p_s == source_node)
-       break;
-
-      if (move == RIGHT)
-       {
-         if (p_s->right)
-           {
-             p_s = p_s->right;
-             p_d_prev = p_d;
-             p_d = _asn1_add_node_only (p_s->type);
-             _asn1_set_right (p_d_prev, p_d);
-           }
-         else
-           move = UP;
-       }
-      if (move == UP)
-       {
-         p_s = _asn1_find_up (p_s);
-         p_d = _asn1_find_up (p_d);
-       }
-    }
-  while (p_s != source_node);
-
-  return dest_node;
-}
-
-
-static ASN1_TYPE
-_asn1_copy_structure2 (ASN1_TYPE root, const char *source_name)
-{
-  ASN1_TYPE source_node;
-
-  source_node = asn1_find_node (root, source_name);
-
-  return _asn1_copy_structure3 (source_node);
-
-}
-
-
-static asn1_retCode
-_asn1_type_choice_config (ASN1_TYPE node)
-{
-  ASN1_TYPE p, p2, p3, p4;
-  int move, tlen;
-
-  if (node == NULL)
-    return ASN1_ELEMENT_NOT_FOUND;
-
-  p = node;
-  move = DOWN;
-
-  while (!((p == node) && (move == UP)))
-    {
-      if (move != UP)
-       {
-         if ((type_field (p->type) == TYPE_CHOICE) && (p->type & CONST_TAG))
-           {
-             p2 = p->down;
-             while (p2)
-               {
-                 if (type_field (p2->type) != TYPE_TAG)
-                   {
-                     p2->type |= CONST_TAG;
-                     p3 = _asn1_find_left (p2);
-                     while (p3)
-                       {
-                         if (type_field (p3->type) == TYPE_TAG)
-                           {
-                             p4 = _asn1_add_node_only (p3->type);
-                             tlen = _asn1_strlen (p3->value);
-                             if (tlen > 0)
-                               _asn1_set_value (p4, p3->value, tlen + 1);
-                             _asn1_set_right (p4, p2->down);
-                             _asn1_set_down (p2, p4);
-                           }
-                         p3 = _asn1_find_left (p3);
-                       }
-                   }
-                 p2 = p2->right;
-               }
-             p->type &= ~(CONST_TAG);
-             p2 = p->down;
-             while (p2)
-               {
-                 p3 = p2->right;
-                 if (type_field (p2->type) == TYPE_TAG)
-                   asn1_delete_structure (&p2);
-                 p2 = p3;
-               }
-           }
-         move = DOWN;
-       }
-      else
-       move = RIGHT;
-
-      if (move == DOWN)
-       {
-         if (p->down)
-           p = p->down;
-         else
-           move = RIGHT;
-       }
-
-      if (p == node)
-       {
-         move = UP;
-         continue;
-       }
-
-      if (move == RIGHT)
-       {
-         if (p->right)
-           p = p->right;
-         else
-           move = UP;
-       }
-      if (move == UP)
-       p = _asn1_find_up (p);
-    }
-
-  return ASN1_SUCCESS;
-}
-
-
-static asn1_retCode
-_asn1_expand_identifier (ASN1_TYPE * node, ASN1_TYPE root)
-{
-  ASN1_TYPE p, p2, p3;
-  char name2[ASN1_MAX_NAME_SIZE + 2];
-  int move;
-
-  if (node == NULL)
-    return ASN1_ELEMENT_NOT_FOUND;
-
-  p = *node;
-  move = DOWN;
-
-  while (!((p == *node) && (move == UP)))
-    {
-      if (move != UP)
-       {
-         if (type_field (p->type) == TYPE_IDENTIFIER)
-           {
-             _asn1_str_cpy (name2, sizeof (name2), root->name);
-             _asn1_str_cat (name2, sizeof (name2), ".");
-             _asn1_str_cat (name2, sizeof (name2), (char *) p->value);
-             p2 = _asn1_copy_structure2 (root, name2);
-             if (p2 == NULL)
-               {
-                 return ASN1_IDENTIFIER_NOT_FOUND;
-               }
-             _asn1_set_name (p2, p->name);
-             p2->right = p->right;
-             p2->left = p->left;
-             if (p->right)
-               p->right->left = p2;
-             p3 = p->down;
-             if (p3)
-               {
-                 while (p3->right)
-                   p3 = p3->right;
-                 _asn1_set_right (p3, p2->down);
-                 _asn1_set_down (p2, p->down);
-               }
-
-             p3 = _asn1_find_left (p);
-             if (p3)
-               _asn1_set_right (p3, p2);
-             else
-               {
-                 p3 = _asn1_find_up (p);
-                 if (p3)
-                   _asn1_set_down (p3, p2);
-                 else
-                   {
-                     p2->left = NULL;
-                   }
-               }
-
-             if (p->type & CONST_SIZE)
-               p2->type |= CONST_SIZE;
-             if (p->type & CONST_TAG)
-               p2->type |= CONST_TAG;
-             if (p->type & CONST_OPTION)
-               p2->type |= CONST_OPTION;
-             if (p->type & CONST_DEFAULT)
-               p2->type |= CONST_DEFAULT;
-             if (p->type & CONST_SET)
-               p2->type |= CONST_SET;
-             if (p->type & CONST_NOT_USED)
-               p2->type |= CONST_NOT_USED;
-
-             if (p == *node)
-               *node = p2;
-             _asn1_remove_node (p);
-             p = p2;
-             move = DOWN;
-             continue;
-           }
-         move = DOWN;
-       }
-      else
-       move = RIGHT;
-
-      if (move == DOWN)
-       {
-         if (p->down)
-           p = p->down;
-         else
-           move = RIGHT;
-       }
-
-      if (p == *node)
-       {
-         move = UP;
-         continue;
-       }
-
-      if (move == RIGHT)
-       {
-         if (p->right)
-           p = p->right;
-         else
-           move = UP;
-       }
-      if (move == UP)
-       p = _asn1_find_up (p);
-    }
-
-  return ASN1_SUCCESS;
-}
-
-
-/**
- * asn1_create_element:
- * @definitions: pointer to the structure returned by "parser_asn1" function
- * @source_name: the name of the type of the new structure (must be
- *   inside p_structure).
- * @element: pointer to the structure created.
- *
- * Creates a structure of type @source_name.  Example using
- *  "pkix.asn":
- *
- * rc = asn1_create_element(cert_def, "PKIX1.Certificate", certptr);
- *
- * Returns: %ASN1_SUCCESS if creation OK, %ASN1_ELEMENT_NOT_FOUND if
- *   @source_name is not known.
- **/
-asn1_retCode
-asn1_create_element (ASN1_TYPE definitions, const char *source_name,
-                    ASN1_TYPE * element)
-{
-  ASN1_TYPE dest_node;
-  int res;
-
-  dest_node = _asn1_copy_structure2 (definitions, source_name);
-
-  if (dest_node == NULL)
-    return ASN1_ELEMENT_NOT_FOUND;
-
-  _asn1_set_name (dest_node, "");
-
-  res = _asn1_expand_identifier (&dest_node, definitions);
-  _asn1_type_choice_config (dest_node);
-
-  *element = dest_node;
-
-  return res;
-}
-
-
-/**
- * asn1_print_structure:
- * @out: pointer to the output file (e.g. stdout).
- * @structure: pointer to the structure that you want to visit.
- * @name: an element of the structure
- * @mode: specify how much of the structure to print, can be
- *   %ASN1_PRINT_NAME, %ASN1_PRINT_NAME_TYPE,
- *   %ASN1_PRINT_NAME_TYPE_VALUE, or %ASN1_PRINT_ALL.
- *
- * Prints on the @out file descriptor the structure's tree starting
- * from the @name element inside the structure @structure.
- **/
-void
-asn1_print_structure (FILE * out, ASN1_TYPE structure, const char *name,
-                     int mode)
-{
-  ASN1_TYPE p, root;
-  int k, indent = 0, len, len2, len3;
-
-  if (out == NULL)
-    return;
-
-  root = asn1_find_node (structure, name);
-
-  if (root == NULL)
-    return;
-
-  p = root;
-  while (p)
-    {
-      if (mode == ASN1_PRINT_ALL)
-       {
-         for (k = 0; k < indent; k++)
-           fprintf (out, " ");
-         fprintf (out, "name:");
-         if (p->name)
-           fprintf (out, "%s  ", p->name);
-         else
-           fprintf (out, "NULL  ");
-       }
-      else
-       {
-         switch (type_field (p->type))
-           {
-           case TYPE_CONSTANT:
-           case TYPE_TAG:
-           case TYPE_SIZE:
-             break;
-           default:
-             for (k = 0; k < indent; k++)
-               fprintf (out, " ");
-             fprintf (out, "name:");
-             if (p->name)
-               fprintf (out, "%s  ", p->name);
-             else
-               fprintf (out, "NULL  ");
-           }
-       }
-
-      if (mode != ASN1_PRINT_NAME)
-       {
-         switch (type_field (p->type))
-           {
-           case TYPE_CONSTANT:
-             if (mode == ASN1_PRINT_ALL)
-               fprintf (out, "type:CONST");
-             break;
-           case TYPE_TAG:
-             if (mode == ASN1_PRINT_ALL)
-               fprintf (out, "type:TAG");
-             break;
-           case TYPE_SIZE:
-             if (mode == ASN1_PRINT_ALL)
-               fprintf (out, "type:SIZE");
-             break;
-           case TYPE_DEFAULT:
-             fprintf (out, "type:DEFAULT");
-             break;
-           case TYPE_NULL:
-             fprintf (out, "type:NULL");
-             break;
-           case TYPE_IDENTIFIER:
-             fprintf (out, "type:IDENTIFIER");
-             break;
-           case TYPE_INTEGER:
-             fprintf (out, "type:INTEGER");
-             break;
-           case TYPE_ENUMERATED:
-             fprintf (out, "type:ENUMERATED");
-             break;
-           case TYPE_TIME:
-             fprintf (out, "type:TIME");
-             break;
-           case TYPE_BOOLEAN:
-             fprintf (out, "type:BOOLEAN");
-             break;
-           case TYPE_SEQUENCE:
-             fprintf (out, "type:SEQUENCE");
-             break;
-           case TYPE_BIT_STRING:
-             fprintf (out, "type:BIT_STR");
-             break;
-           case TYPE_OCTET_STRING:
-             fprintf (out, "type:OCT_STR");
-             break;
-           case TYPE_GENERALSTRING:
-             fprintf (out, "type:GENERALSTRING");
-             break;
-           case TYPE_SEQUENCE_OF:
-             fprintf (out, "type:SEQ_OF");
-             break;
-           case TYPE_OBJECT_ID:
-             fprintf (out, "type:OBJ_ID");
-             break;
-           case TYPE_ANY:
-             fprintf (out, "type:ANY");
-             break;
-           case TYPE_SET:
-             fprintf (out, "type:SET");
-             break;
-           case TYPE_SET_OF:
-             fprintf (out, "type:SET_OF");
-             break;
-           case TYPE_CHOICE:
-             fprintf (out, "type:CHOICE");
-             break;
-           case TYPE_DEFINITIONS:
-             fprintf (out, "type:DEFINITIONS");
-             break;
-           default:
-             break;
-           }
-       }
-
-      if ((mode == ASN1_PRINT_NAME_TYPE_VALUE) || (mode == ASN1_PRINT_ALL))
-       {
-         switch (type_field (p->type))
-           {
-           case TYPE_CONSTANT:
-             if (mode == ASN1_PRINT_ALL)
-               if (p->value)
-                 fprintf (out, "  value:%s", p->value);
-             break;
-           case TYPE_TAG:
-             if (mode == ASN1_PRINT_ALL)
-               if (p->value)
-                 fprintf (out, "  value:%s", p->value);
-             break;
-           case TYPE_SIZE:
-             if (mode == ASN1_PRINT_ALL)
-               if (p->value)
-                 fprintf (out, "  value:%s", p->value);
-             break;
-           case TYPE_DEFAULT:
-             if (p->value)
-               fprintf (out, "  value:%s", p->value);
-             else if (p->type & CONST_TRUE)
-               fprintf (out, "  value:TRUE");
-             else if (p->type & CONST_FALSE)
-               fprintf (out, "  value:FALSE");
-             break;
-           case TYPE_IDENTIFIER:
-             if (p->value)
-               fprintf (out, "  value:%s", p->value);
-             break;
-           case TYPE_INTEGER:
-             if (p->value)
-               {
-                 len2 = -1;
-                 len = asn1_get_length_der (p->value, p->value_len, &len2);
-                 fprintf (out, "  value:0x");
-                 if (len > 0)
-                   for (k = 0; k < len; k++)
-                     fprintf (out, "%02x", (p->value)[k + len2]);
-               }
-             break;
-           case TYPE_ENUMERATED:
-             if (p->value)
-               {
-                 len2 = -1;
-                 len = asn1_get_length_der (p->value, p->value_len, &len2);
-                 fprintf (out, "  value:0x");
-                 if (len > 0)
-                   for (k = 0; k < len; k++)
-                     fprintf (out, "%02x", (p->value)[k + len2]);
-               }
-             break;
-           case TYPE_TIME:
-             if (p->value)
-               fprintf (out, "  value:%s", p->value);
-             break;
-           case TYPE_BOOLEAN:
-             if (p->value)
-               {
-                 if (p->value[0] == 'T')
-                   fprintf (out, "  value:TRUE");
-                 else if (p->value[0] == 'F')
-                   fprintf (out, "  value:FALSE");
-               }
-             break;
-           case TYPE_BIT_STRING:
-             if (p->value)
-               {
-                 len2 = -1;
-                 len = asn1_get_length_der (p->value, p->value_len, &len2);
-                 if (len > 0)
-                   {
-                     fprintf (out, "  value(%i):",
-                              (len - 1) * 8 - (p->value[len2]));
-                     for (k = 1; k < len; k++)
-                       fprintf (out, "%02x", (p->value)[k + len2]);
-                   }
-               }
-             break;
-           case TYPE_OCTET_STRING:
-             if (p->value)
-               {
-                 len2 = -1;
-                 len = asn1_get_length_der (p->value, p->value_len, &len2);
-                 fprintf (out, "  value:");
-                 if (len > 0)
-                   for (k = 0; k < len; k++)
-                     fprintf (out, "%02x", (p->value)[k + len2]);
-               }
-             break;
-           case TYPE_GENERALSTRING:
-             if (p->value)
-               {
-                 len2 = -1;
-                 len = asn1_get_length_der (p->value, p->value_len, &len2);
-                 fprintf (out, "  value:");
-                 if (len > 0)
-                   for (k = 0; k < len; k++)
-                     fprintf (out, "%02x", (p->value)[k + len2]);
-               }
-             break;
-           case TYPE_OBJECT_ID:
-             if (p->value)
-               fprintf (out, "  value:%s", p->value);
-             break;
-           case TYPE_ANY:
-             if (p->value)
-               {
-                 len3 = -1;
-                 len2 = asn1_get_length_der (p->value, p->value_len, &len3);
-                 fprintf (out, "  value:");
-                 if (len2 > 0)
-                   for (k = 0; k < len2; k++)
-                     fprintf (out, "%02x", (p->value)[k + len3]);
-               }
-             break;
-           case TYPE_SET:
-           case TYPE_SET_OF:
-           case TYPE_CHOICE:
-           case TYPE_DEFINITIONS:
-           case TYPE_SEQUENCE_OF:
-           case TYPE_SEQUENCE:
-           case TYPE_NULL:
-             break;
-           default:
-             break;
-           }
-       }
-
-      if (mode == ASN1_PRINT_ALL)
-       {
-         if (p->type & 0x1FFFFF00)
-           {
-             fprintf (out, "  attr:");
-             if (p->type & CONST_UNIVERSAL)
-               fprintf (out, "UNIVERSAL,");
-             if (p->type & CONST_PRIVATE)
-               fprintf (out, "PRIVATE,");
-             if (p->type & CONST_APPLICATION)
-               fprintf (out, "APPLICATION,");
-             if (p->type & CONST_EXPLICIT)
-               fprintf (out, "EXPLICIT,");
-             if (p->type & CONST_IMPLICIT)
-               fprintf (out, "IMPLICIT,");
-             if (p->type & CONST_TAG)
-               fprintf (out, "TAG,");
-             if (p->type & CONST_DEFAULT)
-               fprintf (out, "DEFAULT,");
-             if (p->type & CONST_TRUE)
-               fprintf (out, "TRUE,");
-             if (p->type & CONST_FALSE)
-               fprintf (out, "FALSE,");
-             if (p->type & CONST_LIST)
-               fprintf (out, "LIST,");
-             if (p->type & CONST_MIN_MAX)
-               fprintf (out, "MIN_MAX,");
-             if (p->type & CONST_OPTION)
-               fprintf (out, "OPTION,");
-             if (p->type & CONST_1_PARAM)
-               fprintf (out, "1_PARAM,");
-             if (p->type & CONST_SIZE)
-               fprintf (out, "SIZE,");
-             if (p->type & CONST_DEFINED_BY)
-               fprintf (out, "DEF_BY,");
-             if (p->type & CONST_GENERALIZED)
-               fprintf (out, "GENERALIZED,");
-             if (p->type & CONST_UTC)
-               fprintf (out, "UTC,");
-             if (p->type & CONST_SET)
-               fprintf (out, "SET,");
-             if (p->type & CONST_NOT_USED)
-               fprintf (out, "NOT_USED,");
-             if (p->type & CONST_ASSIGN)
-               fprintf (out, "ASSIGNMENT,");
-           }
-       }
-
-      if (mode == ASN1_PRINT_ALL)
-       {
-         fprintf (out, "\n");
-       }
-      else
-       {
-         switch (type_field (p->type))
-           {
-           case TYPE_CONSTANT:
-           case TYPE_TAG:
-           case TYPE_SIZE:
-             break;
-           default:
-             fprintf (out, "\n");
-           }
-       }
-
-      if (p->down)
-       {
-         p = p->down;
-         indent += 2;
-       }
-      else if (p == root)
-       {
-         p = NULL;
-         break;
-       }
-      else if (p->right)
-       p = p->right;
-      else
-       {
-         while (1)
-           {
-             p = _asn1_find_up (p);
-             if (p == root)
-               {
-                 p = NULL;
-                 break;
-               }
-             indent -= 2;
-             if (p->right)
-               {
-                 p = p->right;
-                 break;
-               }
-           }
-       }
-    }
-}
-
-
-
-/**
- * asn1_number_of_elements:
- * @element: pointer to the root of an ASN1 structure.
- * @name: the name of a sub-structure of ROOT.
- * @num: pointer to an integer where the result will be stored
- *
- * Counts the number of elements of a sub-structure called NAME with
- * names equal to "?1","?2", ...
- *
- * Returns: %ASN1_SUCCESS if successful, %ASN1_ELEMENT_NOT_FOUND if
- *   @name is not known, %ASN1_GENERIC_ERROR if pointer @num is %NULL.
- **/
-asn1_retCode
-asn1_number_of_elements (ASN1_TYPE element, const char *name, int *num)
-{
-  ASN1_TYPE node, p;
-
-  if (num == NULL)
-    return ASN1_GENERIC_ERROR;
-
-  *num = 0;
-
-  node = asn1_find_node (element, name);
-  if (node == NULL)
-    return ASN1_ELEMENT_NOT_FOUND;
-
-  p = node->down;
-
-  while (p)
-    {
-      if ((p->name) && (p->name[0] == '?'))
-       (*num)++;
-      p = p->right;
-    }
-
-  return ASN1_SUCCESS;
-}
-
-
-/**
- * asn1_find_structure_from_oid:
- * @definitions: ASN1 definitions
- * @oidValue: value of the OID to search (e.g. "1.2.3.4").
- *
- * Search the structure that is defined just after an OID definition.
- *
- * Returns: %NULL when @oidValue not found, otherwise the pointer to a
- *   constant string that contains the element name defined just after
- *   the OID.
- **/
-const char *
-asn1_find_structure_from_oid (ASN1_TYPE definitions, const char *oidValue)
-{
-  char definitionsName[ASN1_MAX_NAME_SIZE], name[2 * ASN1_MAX_NAME_SIZE + 1];
-  char value[ASN1_MAX_NAME_SIZE];
-  ASN1_TYPE p;
-  int len;
-  asn1_retCode result;
-
-  if ((definitions == ASN1_TYPE_EMPTY) || (oidValue == NULL))
-    return NULL;               /* ASN1_ELEMENT_NOT_FOUND; */
-
-
-  strcpy (definitionsName, definitions->name);
-  strcat (definitionsName, ".");
-
-  /* search the OBJECT_ID into definitions */
-  p = definitions->down;
-  while (p)
-    {
-      if ((type_field (p->type) == TYPE_OBJECT_ID) &&
-         (p->type & CONST_ASSIGN))
-       {
-         strcpy (name, definitionsName);
-         strcat (name, p->name);
-
-         len = ASN1_MAX_NAME_SIZE;
-         result = asn1_read_value (definitions, name, value, &len);
-
-         if ((result == ASN1_SUCCESS) && (!strcmp (oidValue, value)))
-           {
-             p = p->right;
-             if (p == NULL)    /* reach the end of ASN1 definitions */
-               return NULL;    /* ASN1_ELEMENT_NOT_FOUND; */
-
-             return p->name;
-           }
-       }
-      p = p->right;
-    }
-
-  return NULL;                 /* ASN1_ELEMENT_NOT_FOUND; */
-}
-
-/**
- * asn1_copy_node:
- * @dst: Destination ASN1_TYPE node.
- * @dst_name: Field name in destination node.
- * @src: Source ASN1_TYPE node.
- * @src_name: Field name in source node.
- *
- * Create a deep copy of a ASN1_TYPE variable.
- *
- * Returns: Return %ASN1_SUCCESS on success.
- **/
-asn1_retCode
-asn1_copy_node (ASN1_TYPE dst, const char *dst_name,
-               ASN1_TYPE src, const char *src_name)
-{
-/* FIXME: rewrite using copy_structure().
- * It seems quite hard to do.
- */
-  int result;
-  ASN1_TYPE dst_node;
-  void *data = NULL;
-  int size = 0;
-
-  result = asn1_der_coding (src, src_name, NULL, &size, NULL);
-  if (result != ASN1_MEM_ERROR)
-    return result;
-
-  data = _asn1_malloc (size);
-  if (data == NULL)
-    return ASN1_MEM_ERROR;
-
-  result = asn1_der_coding (src, src_name, data, &size, NULL);
-  if (result != ASN1_SUCCESS)
-    {
-      _asn1_free (data);
-      return result;
-    }
-
-  dst_node = asn1_find_node (dst, dst_name);
-  if (dst_node == NULL)
-    {
-      _asn1_free (data);
-      return ASN1_ELEMENT_NOT_FOUND;
-    }
-
-  result = asn1_der_decoding (&dst_node, data, size, NULL);
-
-  _asn1_free (data);
-
-  return result;
-}
diff --git a/asn1/structure.h b/asn1/structure.h
deleted file mode 100644
index 0a84e26..0000000
--- a/asn1/structure.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2002-2012 Free Software Foundation, Inc.
- *
- * This file is part of LIBTASN1.
- *
- * The LIBTASN1 library is free software; you can redistribute it
- * and/or modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA
- */
-
-/*************************************************/
-/* File: structure.h                             */
-/* Description: list of exported object by       */
-/*   "structure.c"                               */
-/*************************************************/
-
-#ifndef _STRUCTURE_H
-#define _STRUCTURE_H
-
-asn1_retCode _asn1_create_static_structure (ASN1_TYPE pointer,
-                                           char *output_file_name,
-                                           char *vector_name);
-
-ASN1_TYPE _asn1_copy_structure3 (ASN1_TYPE source_node);
-
-ASN1_TYPE _asn1_add_node_only (unsigned int type);
-
-ASN1_TYPE _asn1_find_left (ASN1_TYPE node);
-
-#endif
diff --git a/asn1/version.c b/asn1/version.c
deleted file mode 100644
index 83d70c9..0000000
--- a/asn1/version.c
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (C) 2000-2012 Free Software Foundation, Inc.
- *
- * This file is part of LIBTASN1.
- *
- * The LIBTASN1 library is free software; you can redistribute it
- * and/or modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <string.h>            /* for strverscmp */
-
-#include "libtasn1.h"
-
-/**
- * asn1_check_version:
- * @req_version: Required version number, or %NULL.
- *
- * Check that the version of the library is at minimum the
- * requested one and return the version string; return %NULL if the
- * condition is not satisfied.  If a %NULL is passed to this function,
- * no check is done, but the version string is simply returned.
- *
- * See %ASN1_VERSION for a suitable @req_version string.
- *
- * Returns: Version string of run-time library, or %NULL if the
- *   run-time library does not meet the required version number.
- */
-const char *
-asn1_check_version (const char *req_version)
-{
-  if (!req_version || strverscmp (req_version, ASN1_VERSION) <= 0)
-    return ASN1_VERSION;
-
-  return NULL;
-}
diff --git a/configure.ac b/configure.ac
index bef5885..3dc1ee5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -20,7 +20,6 @@
 
 AC_PREREQ(2.61)
 AC_INIT([GNU Shishi], [1.0.2], address@hidden)
-AC_COPYRIGHT([Copyright (c) 2002-2012 Simon Josefsson <address@hidden>.])
 AC_CONFIG_AUX_DIR([build-aux])
 AC_CONFIG_MACRO_DIR([m4])
 AC_CONFIG_HEADERS(config.h)
@@ -72,10 +71,6 @@ AC_TYPE_UID_T
 AC_TYPE_SIGNAL
 AC_CHECK_DECLS(h_errno)
 
-# For libtasn1
-AC_CHECK_SIZEOF(unsigned long int, 4)
-AC_CHECK_SIZEOF(unsigned int, 4)
-
 # For gnulib stuff in gl/.
 with_libgcrypt=yes
 AC_DEFINE([OK_TO_USE_1S_CLOCK], 1, [Define to 1 to make gettime work.])
@@ -182,24 +177,10 @@ AC_MSG_CHECKING([if String processing support via Libidn 
should be built])
 AC_MSG_RESULT($stringprep)
 
 # Check for libtasn1
-AC_ARG_WITH(system-asn1,
-       AC_HELP_STRING([--with-system-asn1], [Use the system's libtasn1]),
-       system_asn1=$withval, system_asn1=yes)
-if test "$system_asn1" != "no"; then
-  AC_LIB_HAVE_LINKFLAGS(tasn1,, [#include <libtasn1.h>], [asn1_strerror (0);])
-fi
-if test "$ac_cv_libtasn1" = "yes"; then
-  system_asn1=yes
-else
-  system_asn1=no
-  LTLIBTASN1="\$(top_builddir)/asn1/libminitasn1.la"
-  LIBTASN1_CFLAGS="-I\$(top_srcdir)/asn1"
-  AC_SUBST(LIBTASN1_CFLAGS)
-  AC_MSG_WARN([Libtasn1 >= 1.7 not found. Using included one.])
+AC_LIB_HAVE_LINKFLAGS(tasn1,, [#include <libtasn1.h>], [asn1_strerror (0);])
+if test "$ac_cv_libtasn1" != "yes"; then
+  AC_MSG_ERROR([Libtasn1 not found.])
 fi
-AC_MSG_CHECKING([whether to use the system's libtasn1])
-AC_MSG_RESULT($system_asn1)
-AM_CONDITIONAL(ASN1, test "$system_asn1" = "no")
 
 # Check for gnutls.
 AC_ARG_ENABLE(starttls,
@@ -382,7 +363,6 @@ fi
 
 AC_CONFIG_FILES([
   Makefile
-  asn1/Makefile
   db/Makefile
   db/gl/Makefile
   doc/Makefile
@@ -416,5 +396,4 @@ AC_MSG_NOTICE([summary of build options:
   Library types:    Shared=${enable_shared}, Static=${enable_static}
   Valgrind:         ${VALGRIND}
   Version script:   $have_ld_version_script
-  System libtasn1:  $system_asn1
 ])


hooks/post-receive
-- 
GNU shishi



reply via email to

[Prev in Thread] Current Thread [Next in Thread]