]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
Patches for the new OpenCDK version and some stricter checks
authorTimo Schulz <twoaday@gnutls.org>
Sat, 9 Mar 2002 21:06:36 +0000 (21:06 +0000)
committerTimo Schulz <twoaday@gnutls.org>
Sat, 9 Mar 2002 21:06:36 +0000 (21:06 +0000)
for memory leaks.

lib/gnutls_openpgp.c
lib/x509_ASN.c

index f2626f101f7ca089bff970cf1e402685a50df2c9..bbec8dd97da304b25e5fe89330804aa0966cf5ce 100644 (file)
@@ -99,6 +99,8 @@ keyring_blob_new(keyring_blob **r_ctx)
     return GNUTLS_E_INVALID_PARAMETERS;
   
   c = cdk_alloc_clear( sizeof * c);
+  if ( !c )
+    return GNUTLS_E_MEMORY_ERROR;
   *r_ctx = c;
 
   return 0;
@@ -122,6 +124,8 @@ keyring_to_keydb(keyring_blob *blob)
     return NULL;
   
   khd = cdk_alloc_clear(sizeof *khd);
+  if ( !khd )
+    return NULL;
   khd->used = 1;
   if (blob->type == 0x00) /* file */
       khd->name = cdk_strdup(blob->data);   
@@ -165,6 +169,8 @@ read_keyring_blob(const gnutls_datum* keyring, size_t pos)
       return NULL;
     }
   blob->data = cdk_alloc_clear(blob->size + 1);
+  if ( !blob->data )
+    return NULL;
   memcpy(blob->data, keyring->data+(pos+5), blob->size);
   blob->data[blob->size] = '\0';
   
@@ -187,13 +193,15 @@ conv_data_to_keyring(int type, const char *data, size_t size, size_t *r_size)
     return NULL;
   
   p = gnutls_malloc( 1+4+size );
+  if ( !p )
+    return NULL;
   p[0] = type; /* type: keyring name */
   p[1] = (size >> 24) & 0xff;
   p[2] = (size >> 16) & 0xff;
   p[3] = (size >>  8) & 0xff;
   p[4] = (size      ) & 0xff;
   memcpy(p+5, data, size);
-  if (r_size)
+  if ( r_size )
     *r_size = 1+4+size;
   
   return p; 
@@ -218,6 +226,8 @@ is_file_armored(char *file)
           goto leave;
         }
       data = cdk_alloc_clear(f_stat.st_size+1);
+      if ( !data )
+        return 0;
       fread(data, 1, f_stat.st_size, fp);
       if ( strstr(data, "-----BEGIN PGP")
            && strstr(data, "-----END PGP") )
@@ -231,41 +241,27 @@ leave:
 }
 
 static int
-pkt_find_type(PACKET pkt, int type)
+kbnode_to_datum( KBNODE kb_pk, gnutls_datum *raw )
 {
-  struct packet_struct *p;
-  
-  if (!pkt)
-    return 0;
-  
-  for (p=pkt; p && p->pkttype; p=p->next)
-    {
-      if (p->pkttype == type)
-        return 1;
-    }
-  
-  return 0;
-}
-
-static int
-pkt_to_datum(PACKET pkt, gnutls_datum *raw)
-{
-  struct packet_struct *p;
-  byte *data;
+  KBNODE p = NULL;
+  byte *data = NULL;
   size_t n = 0;
   int rc = 0;
+  PACKET pkt = {0};
   IOBUF a;
   
-  if (!pkt || !raw)
+  if (!kb_pk || !raw)
     return GNUTLS_E_INVALID_PARAMETERS;
 
   /* fixme: conver the whole key */
-  for (p=pkt; p && p->pkttype; p=p->next)
+  for (p=kb_pk; p && p->pkt->pkttype; p=p->next)
     {
-      if (p->pkttype == PKT_PUBLIC_KEY)
+      if (p->pkt->pkttype == PKT_PUBLIC_KEY)
         {
           a = cdk_iobuf_temp();
-          rc = cdk_pkt_write_public_key(a, p->pkt.public_key);
+          pkt.pkttype = PKT_PUBLIC_KEY;
+          pkt.pkt.public_key = p->pkt->pkt.public_key;
+          rc = cdk_pkt_build( a, &pkt );
           if (rc)
             return GNUTLS_E_UNKNOWN_ERROR;
           data = cdk_iobuf_get_data(a, &n);
@@ -284,25 +280,27 @@ pkt_to_datum(PACKET pkt, gnutls_datum *raw)
 }
 
 static int
-datum_to_openpgp_pkt( const gnutls_datum *raw, PACKET *r_pkt )
+datum_to_kbnode( const gnutls_datum *raw, KBNODE *r_pkt )
 {
   IOBUF buf;
-  PACKET pkt = NULL;
+  KBNODE pkt = NULL;
+  int dummy = 0;
   int rc = 0;
 
   if (!raw || !r_pkt)
     return GNUTLS_E_INVALID_PARAMETERS;
 
-  cdk_iobuf_new(&buf, raw->size);
-  cdk_iobuf_write(buf, raw->data, raw->size);
-  rc = cdk_pkt_parse(buf, &pkt);
-  if ( rc != CDKERR_EOF )
+  cdk_iobuf_new( &buf, raw->size );
+  cdk_iobuf_write( buf, raw->data, raw->size );
+  rc = cdk_keydb_get_keyblock( buf, &pkt, &dummy );
+  /*rc = cdk_pkt_parse(buf, &pkt);*/
+  if ( rc && rc != CDKERR_EOF )
     {
       rc = GNUTLS_E_NO_CERTIFICATE_FOUND;
       goto leave;
     }
   else
-    rc = 0;
+    rc = 0;  
 
 leave:
   cdk_iobuf_close(buf);
@@ -335,57 +333,6 @@ iobuf_to_datum(IOBUF buf, gnutls_datum *raw)
   return rc;
 }
 
-static PKT_signature *
-openpgp_pkt_to_sig(PACKET pkt, size_t idx)
-{
-  struct packet_struct *p = NULL;
-  size_t n = 0;
-
-  for (p=pkt; p && p->pkttype; p=p->next)
-    {
-      if (p->pkttype == PKT_SIGNATURE && n == idx)
-        return p->pkt.signature;
-      else if (p->pkttype == PKT_SIGNATURE)
-        n++;
-    }
-  
-  return NULL;
-}
-
-static PKT_public_key *
-openpgp_pkt_to_pk(PACKET pkt, size_t idx)
-{
-  struct packet_struct *p = NULL;
-  size_t n = 0;
-
-  for (p=pkt; p && p->pkttype; p=p->next)
-    {
-      if (p->pkttype == PKT_PUBLIC_KEY && n == idx)
-        return p->pkt.public_key;
-      else if (p->pkttype == PKT_PUBLIC_KEY)
-        n++;
-    }
-  
-  return NULL;
-}
-
-static PKT_user_id *
-openpgp_pkt_to_uid(PACKET pkt, size_t idx)
-{
-  struct packet_struct *p = NULL;
-  size_t n = 0;
-
-  for (p=pkt; p && p->pkttype; p=p->next)
-    {
-      if (p->pkttype == PKT_USER_ID && n == idx)
-        return p->pkt.user_id;
-      else if (p->pkttype == PKT_USER_ID)
-        n++;
-    }
-  
-  return NULL;
-}
-
 static int
 openpgp_pk_to_gnutls_cert(gnutls_cert *cert, PKT_public_key *pk)
 {
@@ -405,15 +352,15 @@ openpgp_pk_to_gnutls_cert(gnutls_cert *cert, PKT_public_key *pk)
   cert->valid = 0; /* fixme: should set after the verification */
   cert->cert_type = GNUTLS_CRT_OPENPGP;
 
-  if (is_DSA(pk->pubkey_algo) || pk->pubkey_algo == PKE_RSA_S)
+  if (is_DSA(pk->pubkey_algo) || pk->pubkey_algo == GCRY_PK_RSA_S)
     cert->keyUsage = GNUTLS_X509KEY_DIGITAL_SIGNATURE;
-  else if (pk->pubkey_algo == PKE_RSA_E)
+  else if (pk->pubkey_algo == GCRY_PK_RSA_E)
     cert->keyUsage = GNUTLS_X509KEY_ENCIPHER_ONLY;
-  else if (pk->pubkey_algo == PKE_RSA_ES)
+  else if (pk->pubkey_algo == GCRY_PK_RSA)
     cert->keyUsage = GNUTLS_X509KEY_DIGITAL_SIGNATURE
                    | GNUTLS_X509KEY_ENCIPHER_ONLY;
 
-  cert->params_size = cdk_key_pk_get_nmpis(pk->pubkey_algo, 0);
+  cert->params_size = cdk_pk_get_npkey( pk->pubkey_algo );
   for (i=0; i<cert->params_size; i++)
     {      
       nbytes = pk->mpi[i].bytes+2;
@@ -443,13 +390,16 @@ openpgp_sig_to_gnutls_cert(gnutls_cert *cert, PKT_signature *sig)
   size_t nbytes = 0;
   size_t sigsize = 0;
   byte *data = NULL;
+  PACKET pkt = {0};
   
   if (!cert || !sig)
     return GNUTLS_E_INVALID_PARAMETERS;
 
   sigsize = 20 + sig->hashed_size + sig->unhashed_size + 2*MAX_MPI_BYTES;
   cdk_iobuf_new(&buf, sigsize);
-  rc = cdk_pkt_write_signature(buf, sig);
+  pkt.pkttype = PKT_SIGNATURE;
+  pkt.pkt.signature = sig;
+  rc = cdk_pkt_build( buf, &pkt );
   if (rc)
     goto leave;
   data = cdk_iobuf_get_data(buf, &nbytes);
@@ -481,16 +431,15 @@ leave:
  * GnuTLS specific data which is need to perform secret key operations.
  -*/
 int
-_gnutls_openpgp_key2gnutls_key(gnutls_private_key *pkey,
-                               gnutls_datum raw_key)
+_gnutls_openpgp_key2gnutls_key( gnutls_private_key *pkey,
+                                gnutls_datum raw_key )
 {
-  struct packet_struct *p = NULL;
+  KBNODE p = NULL, kb_sk;
   PKT_secret_key *sk = NULL;
-  PACKET pkt = NULL;
   IOBUF buf;
   int pke_algo, i, j, eof = 0;
-  int rc = 0;
   size_t nbytes = 0;
+  int rc = 0;
 
   if (!pkey || raw_key.size <= 0)
     return GNUTLS_E_INVALID_PARAMETERS;
@@ -499,30 +448,23 @@ _gnutls_openpgp_key2gnutls_key(gnutls_private_key *pkey,
   cdk_iobuf_new(&buf, raw_key.size);
   cdk_iobuf_write(buf, raw_key.data, raw_key.size);
 
-  cdk_pkt_new(&pkt);
-  rc = cdk_keydb_enum_sk(buf, &pkt, &eof);
-  if ( (eof == 1 && !pkt) || rc)
+  rc = cdk_keydb_get_keyblock( buf, &kb_sk, &eof );
+  if ( !kb_sk || rc )
     {
       rc = GNUTLS_E_UNKNOWN_ERROR;
       goto leave;
     }
-  
-  for (p=pkt; p; p=p->next)
-    {
-      if (p->pkttype == PKT_SECRET_KEY)
-        {
-          sk = p->pkt.secret_key;
-          break;
-        }
-    }
-  if (sk == NULL)
+  p = cdk_kbnode_find( kb_sk, PKT_SECRET_KEY );
+  if ( p )
+    sk = p->pkt->pkt.secret_key;
+  if ( sk == NULL )
     {
       rc = GNUTLS_E_NO_CERTIFICATE_FOUND;
       goto leave;
     }
   
   pke_algo = sk->pk->pubkey_algo;
-  pkey->params_size = cdk_key_pk_get_nmpis(pke_algo, 0);
+  pkey->params_size = cdk_pk_get_npkey( pke_algo );
   for (i=0; i<pkey->params_size; i++)
     {
       nbytes = sk->pk->mpi[i].bytes+2;
@@ -535,8 +477,8 @@ _gnutls_openpgp_key2gnutls_key(gnutls_private_key *pkey,
           goto leave;
         }
     }
-  pkey->params_size += cdk_key_sk_get_nmpis(pke_algo);
-  for (j=0; j<cdk_key_sk_get_nmpis(pke_algo); j++, i++)
+  pkey->params_size += cdk_pk_get_nskey( pke_algo );
+  for (j=0; j< cdk_pk_get_nskey( pke_algo ); j++, i++)
     {
       nbytes = sk->mpi[j]->bytes+2;
       rc = gcry_mpi_scan(&pkey->params[i], GCRYMPI_FMT_PGP,
@@ -563,7 +505,7 @@ _gnutls_openpgp_key2gnutls_key(gnutls_private_key *pkey,
 
 leave:
   cdk_iobuf_close(buf);
-  cdk_pkt_release(pkt);
+  cdk_kbnode_release( kb_sk );
 
   return rc;
 }
@@ -579,8 +521,7 @@ leave:
 int
 _gnutls_openpgp_cert2gnutls_cert(gnutls_cert *cert, gnutls_datum raw)
 {
-  struct packet_struct *p;
-  PACKET pkt = NULL;
+  KBNODE p, kb_pk = NULL;
   PKT_public_key *pk = NULL;
   int rc = 0;
   
@@ -588,17 +529,12 @@ _gnutls_openpgp_cert2gnutls_cert(gnutls_cert *cert, gnutls_datum raw)
     return GNUTLS_E_INVALID_PARAMETERS;
 
   memset(cert, 0, sizeof *cert);
-  rc = datum_to_openpgp_pkt(&raw, &pkt);
+  rc = datum_to_kbnode( &raw, &kb_pk );
   if (rc)
     return rc;
-  for (p=pkt; p && p->pkttype; p=p->next)
-    {
-      if (p->pkttype == PKT_PUBLIC_KEY)
-        {
-          pk = p->pkt.public_key;
-          break;
-        }
-    }
+  p = cdk_kbnode_find( kb_pk, PKT_PUBLIC_KEY );
+  if ( p )
+    pk = p->pkt->pkt.public_key;
   if (pk == NULL)
     {
       rc = GNUTLS_E_NO_CERTIFICATE_FOUND;
@@ -611,9 +547,11 @@ _gnutls_openpgp_cert2gnutls_cert(gnutls_cert *cert, gnutls_datum raw)
       rc = GNUTLS_E_MEMORY_ERROR;
       goto leave;
     }
-  rc = openpgp_pk_to_gnutls_cert(cert, p->pkt.public_key);
+  rc = openpgp_pk_to_gnutls_cert( cert, pk );
 
 leave:
+  cdk_kbnode_release( kb_pk );
+  
   return rc;
 }
 
@@ -634,7 +572,7 @@ gnutls_openpgp_get_key(gnutls_datum *key, const gnutls_datum *keyring,
   int rc = 0;
   keyring_blob *blob = NULL;
   KEYDB_HD khd = NULL;
-  PACKET pk = NULL;
+  KBNODE pk = NULL;
   KEYDB_SEARCH ks;
   
   if (!key || !keyring || by == KEY_ATTR_NONE)
@@ -664,24 +602,24 @@ gnutls_openpgp_get_key(gnutls_datum *key, const gnutls_datum *keyring,
       goto leave;
     }
   
-  rc = cdk_keydb_search_key(khd, &pk, &ks);
+  rc = cdk_keydb_search( khd, &ks, &pk );
   if (rc)
     {
-      rc = GNUTLS_E_NO_CERTIFICATE_FOUND; 
+      rc = GNUTLS_E_NO_CERTIFICATE_FOUND;
       goto leave;
     }    
 
-  if ( !pkt_find_type(pk, PKT_PUBLIC_KEY) )
+  if ( !cdk_kbnode_find( pk, PKT_PUBLIC_KEY ) )
     {
       rc = GNUTLS_E_NO_CERTIFICATE_FOUND;
       goto leave;
     }
 
-  rc = pkt_to_datum(pk, key);
+  rc = kbnode_to_datum( pk, key );
   
 leave:
   cdk_free(khd);
-  cdk_pkt_release(pk);
+  cdk_kbnode_release( pk );
   keyring_blob_release(blob);
   
   return rc;
@@ -692,16 +630,15 @@ gnutls_certificate_set_openpgp_key_mem(GNUTLS_CERTIFICATE_CREDENTIALS res,
                                        gnutls_datum *cert,
                                        gnutls_datum *key)
 {
-  struct packet_struct *p;
   gnutls_datum raw;
-  PACKET pk = NULL;
+  KBNODE kb_pk = NULL, p;
   int rc = 0;
   int i;
   
   if (!res || !key || !cert)
     return GNUTLS_E_INVALID_PARAMETERS;
 
-  rc = datum_to_openpgp_pkt(cert, &pk);
+  rc = datum_to_kbnode( cert, &kb_pk );
   if (rc)
     goto leave;
 
@@ -729,22 +666,24 @@ gnutls_certificate_set_openpgp_key_mem(GNUTLS_CERTIFICATE_CREDENTIALS res,
       return GNUTLS_E_MEMORY_ERROR; 
     }
 
-  for (i=1, p=pk; p && p->pkttype; p=p->next)
+  for (i=1, p=kb_pk; p && p->pkt->pkttype; p=p->next)
     {
       if (i > MAX_PARAMS_SIZE)
         break;
-      if (p->pkttype == PKT_PUBLIC_KEY)
+      if (p->pkt->pkttype == PKT_PUBLIC_KEY)
         {
           int n = res->ncerts;
+          PKT_public_key *pk = p->pkt->pkt.public_key;
           res->cert_list_length[n] = 1;
           gnutls_set_datum(&res->cert_list[n][0].raw, cert->data, cert->size);
-          openpgp_pk_to_gnutls_cert(&res->cert_list[n][0], p->pkt.public_key);
+          openpgp_pk_to_gnutls_cert( &res->cert_list[n][0], pk );
           i++;
         }
-      else if (p->pkttype == PKT_SIGNATURE)
+      else if (p->pkt->pkttype == PKT_SIGNATURE)
         {
           int n = res->ncerts;
-          openpgp_sig_to_gnutls_cert(&res->cert_list[n][0], p->pkt.signature); 
+          PKT_signature *sig = p->pkt->pkt.signature;
+          openpgp_sig_to_gnutls_cert( &res->cert_list[n][0], sig ); 
         }
     }
   
@@ -762,7 +701,7 @@ gnutls_certificate_set_openpgp_key_mem(GNUTLS_CERTIFICATE_CREDENTIALS res,
   gnutls_free_datum(&raw);
   
 leave:
-  cdk_pkt_release(pk);
+  cdk_kbnode_release( kb_pk );
   
   return rc;
 }
@@ -783,9 +722,8 @@ gnutls_certificate_set_openpgp_key_file(GNUTLS_CERTIFICATE_CREDENTIALS res,
                                         char* KEYFILE)
 {
   IOBUF buf = NULL;
-  PACKET pkt = NULL;
+  KBNODE kb_pk = NULL, p;
   gnutls_datum raw;
-  struct packet_struct *p = NULL;
   armor_filter_s afx;
   int eof = 0, i;
   int rc = 0;
@@ -817,8 +755,6 @@ gnutls_certificate_set_openpgp_key_file(GNUTLS_CERTIFICATE_CREDENTIALS res,
       if (rc == -1)
         return GNUTLS_E_FILE;
     }
-  cdk_pkt_new(&pkt);
-
   res->cert_list = gnutls_realloc(res->cert_list,
                                   (1+res->ncerts)*sizeof(gnutls_cert*));
   if (res->cert_list == NULL)
@@ -843,25 +779,27 @@ gnutls_certificate_set_openpgp_key_file(GNUTLS_CERTIFICATE_CREDENTIALS res,
     }
 
   do {
-    rc = cdk_keydb_enum_pk(buf, &pkt, &eof);
-    if ( (eof == 1 && !pkt) || rc)
+    rc = cdk_keydb_get_keyblock( buf, &kb_pk, &eof );
+    if ( !kb_pk || rc )
       break;
-    for (i=1, p=pkt; p && p->pkttype; p=p->next)
+    for (i=1, p=kb_pk; p && p->pkt->pkttype; p=p->next)
       {
         if (i > MAX_PARAMS_SIZE)
           break;
-        if (p->pkttype == PKT_PUBLIC_KEY)
+        if (p->pkt->pkttype == PKT_PUBLIC_KEY)
           {
             int n = res->ncerts;
+            PKT_public_key *pk = p->pkt->pkt.public_key;
             res->cert_list_length[n] = 1;
             iobuf_to_datum(buf, &res->cert_list[n][0].raw);
-            openpgp_pk_to_gnutls_cert(&res->cert_list[n][0], p->pkt.public_key);
+            openpgp_pk_to_gnutls_cert( &res->cert_list[n][0], pk );
             i++;
           }
-        else if (p->pkttype == PKT_SIGNATURE)
+        else if (p->pkt->pkttype == PKT_SIGNATURE)
           {
             int n = res->ncerts;
-            openpgp_sig_to_gnutls_cert( &res->cert_list[n][0], p->pkt.signature);
+            PKT_signature *sig = p->pkt->pkt.signature;
+            openpgp_sig_to_gnutls_cert( &res->cert_list[n][0], sig );
           }
       }
   } while (!eof && !rc);
@@ -869,11 +807,11 @@ gnutls_certificate_set_openpgp_key_file(GNUTLS_CERTIFICATE_CREDENTIALS res,
   cdk_iobuf_close(buf);
   if (rc)
     {
-      cdk_pkt_release(pkt);
+      cdk_kbnode_release( kb_pk );
       rc = GNUTLS_E_UNKNOWN_ERROR;
       goto leave;
     }
-  cdk_pkt_release(pkt);
+  cdk_kbnode_release( kb_pk );
 
   if ( is_file_armored(KEYFILE) )
     {
@@ -928,9 +866,9 @@ int
 gnutls_openpgp_extract_key_name( const gnutls_datum *cert,
                                  gnutls_openpgp_name *dn )
 {
-  PACKET pkt = NULL;
+  KBNODE kb_pk = NULL, p;
   PKT_user_id *uid = NULL;
-  char *p;
+  char *email;
   int rc = 0;
   int pos1 = 0, pos2 = 0;
   size_t size = 0;
@@ -938,17 +876,19 @@ gnutls_openpgp_extract_key_name( const gnutls_datum *cert,
   if (!cert || !dn)
     return GNUTLS_E_INVALID_PARAMETERS;
 
-  rc = datum_to_openpgp_pkt(cert, &pkt);
+  rc = datum_to_kbnode( cert, &kb_pk );
   if (rc)
     return rc;
-  uid = openpgp_pkt_to_uid(pkt, 0);
+  p = cdk_kbnode_find( kb_pk, PKT_USER_ID );
+  if ( p )
+    uid = p->pkt->pkt.user_id;
   if (!uid)
     {
       rc = GNUTLS_E_UNKNOWN_ERROR;
       goto leave;
     }
   memset(dn, 0, sizeof *dn);
-  size = uid->size < OPENPGP_NAME_SIZE? uid->size : OPENPGP_NAME_SIZE;
+  size = uid->len < OPENPGP_NAME_SIZE? uid->len : OPENPGP_NAME_SIZE;
   memcpy(dn->name, uid->name, size);
   dn->name[size-1] = '\0'; /* make sure it's a string */
 
@@ -956,12 +896,12 @@ gnutls_openpgp_extract_key_name( const gnutls_datum *cert,
    * Extract the email address from the userID string and save it to
    * the email field.
    */
-  p = strchr(uid->name, '<');
-  if (p)
-    pos1 = p-uid->name+1;
-  p = strchr(uid->name, '>');
-  if (p)
-    pos2 = p-uid->name+1;
+  email = strchr(uid->name, '<');
+  if ( email )
+    pos1 = email-uid->name+1;
+  email = strchr(uid->name, '>');
+  if ( email )
+    pos2 = email-uid->name+1;
   if (pos1 && pos2)
     {
       pos2 -= pos1;
@@ -971,7 +911,7 @@ gnutls_openpgp_extract_key_name( const gnutls_datum *cert,
     }
   
 leave:
-  cdk_pkt_release(pkt);
+  cdk_kbnode_release( kb_pk );
   
   return rc;
 }
@@ -985,19 +925,18 @@ leave:
 int
 gnutls_openpgp_extract_key_version( const gnutls_datum *cert )
 {
-  PACKET pkt = NULL;
-  PKT_public_key *pk = NULL;
+  KBNODE kb_pk = NULL, p;
   int version = 0;
 
   if (!cert)
     return GNUTLS_E_INVALID_PARAMETERS;
 
-  if ( datum_to_openpgp_pkt(cert, &pkt) )
+  if ( datum_to_kbnode( cert, &kb_pk ) )
     return 0;
-  pk = openpgp_pkt_to_pk(pkt, 0);
-  if (pk)
-    version = pk->version;
-  cdk_pkt_release(pkt);
+  p = cdk_kbnode_find( kb_pk, PKT_PUBLIC_KEY );
+  if ( p )
+    version = p->pkt->pkt.public_key->version;
+  cdk_kbnode_release( kb_pk );
 
   return version;
 }
@@ -1011,19 +950,18 @@ gnutls_openpgp_extract_key_version( const gnutls_datum *cert )
 time_t
 gnutls_openpgp_extract_key_creation_time( const gnutls_datum *cert )
 {
-  PACKET pkt = NULL;
-  PKT_public_key *pk = NULL;
+  KBNODE kb_pk = NULL, p;
   time_t timestamp = 0;
 
   if (!cert)
     return GNUTLS_E_INVALID_PARAMETERS;
   
-  if ( datum_to_openpgp_pkt(cert, &pkt) )
+  if ( datum_to_kbnode( cert, &kb_pk ) )
     return 0;
-  pk = openpgp_pkt_to_pk(pkt, 0);
-  if (pk)
-    timestamp = pk->timestamp;
-  cdk_pkt_release(pkt);
+  p = cdk_kbnode_find( kb_pk, PKT_PUBLIC_KEY );
+  if ( p )
+    timestamp = p->pkt->pkt.public_key->timestamp;
+  cdk_kbnode_release( kb_pk );
   
   return timestamp;
 }
@@ -1038,19 +976,18 @@ gnutls_openpgp_extract_key_creation_time( const gnutls_datum *cert )
 time_t
 gnutls_openpgp_extract_key_expiration_time( const gnutls_datum *cert )
 {
-  PACKET pkt = NULL;
-  PKT_public_key *pk = NULL;
+  KBNODE kb_pk = NULL, p;
   time_t expiredate = 0;
 
   if (!cert)
     return GNUTLS_E_INVALID_PARAMETERS;
   
-  if ( datum_to_openpgp_pkt(cert, &pkt) )
+  if ( datum_to_kbnode( cert, &kb_pk ) )
     return 0;
-  pk = openpgp_pkt_to_pk(pkt, 0);
-  if (pk)
-    expiredate = pk->expiredate;
-  cdk_pkt_release(pkt);
+  p = cdk_kbnode_find( kb_pk, PKT_PUBLIC_KEY );
+  if ( p )
+    expiredate = p->pkt->pkt.public_key->expiredate;
+  cdk_kbnode_release( kb_pk );
   
   return expiredate;
 }
@@ -1063,7 +1000,7 @@ _gnutls_openpgp_get_key_trust(const char *trustdb,
   int flags = 0;
   int ot = 0, trustval = 0;
   int rc = 0;
-  PACKET pkt;
+  KBNODE kb_pk = NULL, p;
   PKT_public_key *pk = NULL;
   IOBUF buf;
 
@@ -1071,11 +1008,13 @@ _gnutls_openpgp_get_key_trust(const char *trustdb,
     return GNUTLS_E_NO_CERTIFICATE_FOUND;
 
   *r_success = 0;
-  rc = datum_to_openpgp_pkt(key, &pkt);
+  rc = datum_to_kbnode( key, &kb_pk );
   if (rc)
     return GNUTLS_E_NO_CERTIFICATE_FOUND;
-  
-  pk = openpgp_pkt_to_pk(pkt, 0);
+
+  p = cdk_kbnode_find( kb_pk, PKT_PUBLIC_KEY );
+  if ( p )
+    pk = p->pkt->pkt.public_key;
   if (!pk)
     return GNUTLS_E_NO_CERTIFICATE_FOUND;
 
@@ -1085,7 +1024,7 @@ _gnutls_openpgp_get_key_trust(const char *trustdb,
       trustval = GNUTLS_E_NO_CERTIFICATE_FOUND;
       goto leave;
     }
-  rc = cdk_trustdb_find_ownertrust(buf, pk, &ot, &flags);
+  rc = cdk_trustdb_get_ownertrust(buf, pk, &ot, &flags);
   cdk_iobuf_close(buf);
   if (rc)
     {
@@ -1114,7 +1053,7 @@ _gnutls_openpgp_get_key_trust(const char *trustdb,
       
     case TRUST_FULLY:
     case TRUST_ULTIMATE:
-      trustval |= GNUTLS_CERT_TRUSTED;
+      trustval |= 1; /* means okay */
       *r_success = 1;
       break;
     }      
@@ -1138,7 +1077,7 @@ gnutls_openpgp_verify_key( const char *trustdb,
                            const gnutls_datum* cert_list,
                            int cert_list_length )
 {
-  PACKET pkt = NULL;
+  KBNODE kb_pk = NULL;
   KEYDB_HD khd = NULL;
   keyring_blob *blob = NULL;
   int rc = 0;
@@ -1168,32 +1107,14 @@ gnutls_openpgp_verify_key( const char *trustdb,
         goto leave;
     }
   
-  rc = datum_to_openpgp_pkt(cert_list, &pkt);
+  rc = datum_to_kbnode( cert_list, &kb_pk );
   if (rc)
     {
       goto leave;
       return GNUTLS_CERT_INVALID;
     }
-  
-  {
-    struct packet_struct *p;
-    PKT_user_id *id = NULL;
-    PKT_signature *sig = NULL;
-    for (p=pkt; p && p->pkttype; p=p->next)
-      {
-        if (p->pkttype == PKT_SIGNATURE)
-          sig = p->pkt.signature;
-        if (p->pkttype == PKT_USER_ID && sig && !sig->userid_hash)
-          {
-              id = p->pkt.user_id;
-            if (sig->sig_class >= 0x10 && sig->sig_class <= 0x13)
-              sig->userid_hash  = cdk_userid_create_hash(id);
-            id = NULL;
-          }
-      }
-  }
-  
-  rc = cdk_key_check_sigs(pkt, khd, &status);
+
+  rc = cdk_key_check_sigs( kb_pk, khd, &status );
   if (rc == CDKERR_NOKEY)
     rc = 0; /* fixme */
       
@@ -1215,6 +1136,8 @@ gnutls_openpgp_verify_key( const char *trustdb,
 leave:
   keyring_blob_release(blob);
   cdk_free(khd);
+  cdk_kbnode_release( kb_pk );
+  
   return rc;
 }
 
@@ -1230,30 +1153,27 @@ leave:
 int
 gnutls_openpgp_fingerprint(const gnutls_datum *cert, byte *fpr, size_t *fprlen)
 {
-  PACKET pkt = NULL;
+  KBNODE kb_pk = NULL, p;
   PKT_public_key *pk = NULL;
-  struct packet_struct *p;
   int rc = 0;
   
   if (!cert || !fpr || !fprlen)
     return GNUTLS_E_UNKNOWN_ERROR;
 
   *fprlen = 0;
-  rc = datum_to_openpgp_pkt(cert, &pkt);
+  rc = datum_to_kbnode( cert, &kb_pk );
   if (rc)
     return rc;
-  for (p=pkt; p && p->pkttype; p=p->next)
-    {
-      if (p->pkttype == PKT_PUBLIC_KEY)
-        {
-          pk = p->pkt.public_key;
-          if ( is_RSA(pk->pubkey_algo) && pk->version < 4 )
-            *fprlen = 16;
-          else
-            *fprlen = 20;
-          cdk_key_create_fpr(pk, fpr);
-        }
-    }
+  p = cdk_kbnode_find( kb_pk, PKT_PUBLIC_KEY );
+  if ( p )
+    pk = p->pkt->pkt.public_key;
+  if ( !pk )
+    return GNUTLS_E_UNKNOWN_ERROR;
+
+  *fprlen = 20;
+  if ( is_RSA(pk->pubkey_algo) && pk->version < 4 )
+    *fprlen = 16;
+  cdk_pk_get_fingerprint( pk, fpr );
   
   return 0;  
 }
@@ -1268,26 +1188,24 @@ gnutls_openpgp_fingerprint(const gnutls_datum *cert, byte *fpr, size_t *fprlen)
 int
 gnutls_openpgp_keyid( const gnutls_datum *cert, uint32 *keyid )
 {
-  PACKET pkt;
+  KBNODE kb_pk = NULL, p;
   PKT_public_key *pk = NULL;
-  struct packet_struct *p;
   int rc = 0;
   
   if (!cert || !keyid)
     return GNUTLS_E_UNKNOWN_ERROR;
 
-  rc = datum_to_openpgp_pkt(cert, &pkt);
+  rc = datum_to_kbnode( cert, &kb_pk );
   if (rc)
     return rc;
-  for (p=pkt; p && p->pkttype; p=p->next)
-    {
-      if (p->pkttype == PKT_PUBLIC_KEY)
-        {
-          pk = p->pkt.public_key;
-          cdk_key_keyid_from_pk(pk, (u32*)keyid);
-        }
-    }
 
+  p = cdk_kbnode_find( kb_pk, PKT_PUBLIC_KEY );
+  if ( p )
+    pk = p->pkt->pkt.public_key;
+  if ( !pk )
+    return GNUTLS_E_UNKNOWN_ERROR;
+  cdk_pk_get_keyid( pk, (u32 *)keyid );
+  
   return 0;
 }
 
@@ -1464,8 +1382,13 @@ gnutls_openpgp_recv_key(const char *host, short port, uint32 keyid,
       close(fd);
       return -1;
     }
-
+  
   request = cdk_alloc_clear(strlen(host)+100);
+  if ( request == NULL )
+    {
+      close( fd );
+      return -1;
+    }
   sprintf(request, "GET /pks/lookup?op=get&search=0x%08X HTTP/1.0\r\n"
           "Host: %s:%d\r\n", (u32)keyid, host, port);
   if ( write(fd, request, strlen(request)) == -1 )
@@ -1576,7 +1499,7 @@ gnutls_certificate_set_openpgp_keyserver(GNUTLS_CERTIFICATE_CREDENTIALS res,
   if (!port)
     port = 11371;
   
-  res->pgp_key_server = keyserver;
+  res->pgp_key_server = gnutls_strdup( keyserver );
   res->pgp_key_server_port = port;
 }
 
@@ -1605,7 +1528,6 @@ _gnutls_openpgp_cert2gnutls_cert(gnutls_cert *cert, gnutls_datum raw)
   return GNUTLS_E_UNIMPLEMENTED_FEATURE;  
 }
 
-
 int
 gnutls_certificate_set_openpgp_key_mem(GNUTLS_CERTIFICATE_CREDENTIALS res,
                                        gnutls_datum *cert,
index 2cd2fe1b3997755b14c08676684567019d4ba689..ea1102fd850a8167c4783301f90794ca860defbe 100644 (file)
@@ -1,5 +1,6 @@
+
 /* A Bison parser, made from x509_ASN.y
-   by GNU bison 1.32.  */
+   by GNU bison 1.30.  */
 
 #define YYBISON 1  /* Identify Bison output.  */
 
@@ -59,17 +60,12 @@ int yylex(void);
 
 
 #line 48 "x509_ASN.y"
-#ifndef YYSTYPE
 typedef union {
   unsigned int constant;
   char str[129];
   node_asn* node;
-} yystype;
-# define YYSTYPE yystype
-#endif
-#ifndef YYDEBUG
-# define YYDEBUG 0
-#endif
+} YYSTYPE;
+#include <stdio.h>
 
 
 
@@ -115,7 +111,7 @@ static const char yytranslate[] =
       36,    37,    38,    39
 };
 
-#if YYDEBUG
+#if YYDEBUG != 0
 static const short yyprhs[] =
 {
        0,     0,     1,     4,     6,     9,    12,    14,    16,    18,
@@ -167,7 +163,7 @@ static const short yyrhs[] =
 
 #endif
 
-#if YYDEBUG
+#if YYDEBUG != 0
 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
 static const short yyrline[] =
 {
@@ -185,7 +181,7 @@ static const short yyrline[] =
 #endif
 
 
-#if (YYDEBUG) || defined YYERROR_VERBOSE
+#if YYDEBUG != 0 || defined YYERROR_VERBOSE
 
 /* YYTNAME[TOKEN_NUM] -- String name of the token TOKEN_NUM. */
 static const char *const yytname[] =
@@ -361,7 +357,7 @@ static const short yycheck[] =
 #line 3 "/usr/share/bison/bison.simple"
 
 /* Skeleton output parser for bison,
-   Copyright (C) 1984, 1989, 1990, 2000, 2001 Free Software Foundation, Inc.
+   Copyright 1984, 1989, 1990, 2000, 2001 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -388,120 +384,58 @@ static const short yycheck[] =
    It was written by Richard Stallman by simplifying the hairy parser
    used when %semantic_parser is specified.  */
 
-/* All symbols defined below should begin with yy or YY, to avoid
-   infringing on user name space.  This should be done even for local
-   variables, as they might otherwise be expanded by user macros.
-   There are some unavoidable exceptions within include files to
-   define necessary library symbols; they are noted "INFRINGES ON
-   USER NAME SPACE" below.  */
-
-#ifdef __cplusplus
-# define YYSTD(x) std::x
-#else
-# define YYSTD(x) x
+#ifndef YYSTACK_USE_ALLOCA
+# ifdef alloca
+#  define YYSTACK_USE_ALLOCA 1
+# else /* alloca not defined */
+#  ifdef __GNUC__
+#   define YYSTACK_USE_ALLOCA 1
+#   define alloca __builtin_alloca
+#  else /* not GNU C.  */
+#   if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
+#    define YYSTACK_USE_ALLOCA 1
+#    include <alloca.h>
+#   else /* not sparc */
+     /* We think this test detects Watcom and Microsoft C.  */
+     /* This used to test MSDOS, but that is a bad idea since that
+       symbol is in the user namespace.  */
+#    if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
+#     if 0
+       /* No need for malloc.h, which pollutes the namespace; instead,
+         just don't use alloca.  */
+#      include <malloc.h>
+#     endif
+#    else /* not MSDOS, or __TURBOC__ */
+#     if defined(_AIX)
+       /* I don't know what this was needed for, but it pollutes the
+         namespace.  So I turned it off.  rms, 2 May 1997.  */
+       /* #include <malloc.h>  */
+ #pragma alloca
+#      define YYSTACK_USE_ALLOCA 1
+#     else /* not MSDOS, or __TURBOC__, or _AIX */
+#      if 0
+       /* haible@ilog.fr says this works for HPUX 9.05 and up, and on
+          HPUX 10.  Eventually we can turn this on.  */
+#       ifdef __hpux
+#        define YYSTACK_USE_ALLOCA 1
+#        define alloca __builtin_alloca
+#      endif /* __hpux */
+#      endif
+#     endif /* not _AIX */
+#    endif /* not MSDOS, or __TURBOC__ */
+#   endif /* not sparc */
+#  endif /* not GNU C */
+# endif /* alloca not defined */
+#endif /* YYSTACK_USE_ALLOCA not defined */
+
+#ifndef YYSTACK_USE_ALLOCA
+# define YYSTACK_USE_ALLOCA 0
 #endif
 
-#if ! defined (yyoverflow) || defined (YYERROR_VERBOSE)
-
-/* The parser invokes alloca or malloc; define the necessary symbols.  */
-
-# if YYSTACK_USE_ALLOCA
-#  define YYSTACK_ALLOC alloca
-#  define YYSIZE_T YYSTD (size_t)
-# else
-#  ifndef YYSTACK_USE_ALLOCA
-#   if defined (alloca) || defined (_ALLOCA_H)
-#    define YYSTACK_ALLOC alloca
-#    define YYSIZE_T YYSTD (size_t)
-#   else
-#    ifdef __GNUC__
-#     define YYSTACK_ALLOC __builtin_alloca
-#    endif
-#   endif
-#  endif
-# endif
-
-# ifdef YYSTACK_ALLOC
-   /* Pacify GCC's `empty if-body' warning. */
-#  define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
-# else
-#  ifdef __cplusplus
-#   include <cstdlib> /* INFRINGES ON USER NAME SPACE */
-#   define YYSIZE_T std::size_t
-#  else
-#   ifdef __STDC__
-#    include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
-#    define YYSIZE_T size_t
-#   endif
-#  endif
-#  define YYSTACK_ALLOC YYSTD (malloc)
-#  define YYSTACK_FREE YYSTD (free)
-# endif
-
-/* A type that is properly aligned for any stack member.  */
-union yyalloc
-{
-  short yyss;
-  YYSTYPE yyvs;
-# if YYLSP_NEEDED
-  YYLTYPE yyls;
-# endif
-};
-
-/* The size of the maximum gap between one aligned stack and the next.  */
-# define YYSTACK_GAP_MAX (sizeof (union yyalloc) - 1)
-
-/* The size of an array large to enough to hold all stacks, each with
-   N elements.  */
-# if YYLSP_NEEDED
-#  define YYSTACK_BYTES(N) \
-     ((N) * (sizeof (short) + sizeof (YYSTYPE) + sizeof (YYLTYPE))     \
-      + 2 * YYSTACK_GAP_MAX)
-# else
-#  define YYSTACK_BYTES(N) \
-     ((N) * (sizeof (short) + sizeof (YYSTYPE))                                \
-      + YYSTACK_GAP_MAX)
-# endif
-
-/* Relocate the TYPE STACK from its old location to the new one.  The
-   local variables YYSIZE and YYSTACKSIZE give the old and new number of
-   elements in the stack, and YYPTR gives the new location of the
-   stack.  Advance YYPTR to a properly aligned location for the next
-   stack.  */
-# define YYSTACK_RELOCATE(Type, Stack)                                 \
-    do                                                                 \
-      {                                                                        \
-       YYSIZE_T yynewbytes;                                            \
-       yymemcpy ((char *) yyptr, (char *) (Stack),                     \
-                 yysize * (YYSIZE_T) sizeof (Type));                   \
-       Stack = &yyptr->Stack;                                          \
-       yynewbytes = yystacksize * sizeof (Type) + YYSTACK_GAP_MAX;     \
-       yyptr += yynewbytes / sizeof (*yyptr);                          \
-      }                                                                        \
-    while (0)
-
-#endif /* ! defined (yyoverflow) || defined (YYERROR_VERBOSE) */
-
-
-#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
-# define YYSIZE_T __SIZE_TYPE__
-#endif
-#if ! defined (YYSIZE_T) && defined (size_t)
-# define YYSIZE_T size_t
-#endif
-#if ! defined (YYSIZE_T)
-# ifdef __cplusplus
-#  include <cstddef> /* INFRINGES ON USER NAME SPACE */
-#  define YYSIZE_T std::size_t
-# else
-#  ifdef __STDC__
-#   include <stddef.h> /* INFRINGES ON USER NAME SPACE */
-#   define YYSIZE_T size_t
-#  endif
-# endif
-#endif
-#if ! defined (YYSIZE_T)
-# define YYSIZE_T unsigned int
+#if YYSTACK_USE_ALLOCA
+# define YYSTACK_ALLOC alloca
+#else
+# define YYSTACK_ALLOC malloc
 #endif
 
 #define yyerrok                (yyerrstatus = 0)
@@ -574,20 +508,10 @@ while (0)
 
 /* Enable debugging if requested.  */
 #if YYDEBUG
-
-# ifndef YYFPRINTF
-#  ifdef __cplusplus
-#   include <cstdio>  /* INFRINGES ON USER NAME SPACE */
-#  else
-#   include <stdio.h> /* INFRINGES ON USER NAME SPACE */
-#  endif
-#  define YYFPRINTF YYSTD (fprintf)
-# endif
-
 # define YYDPRINTF(Args)                       \
 do {                                           \
   if (yydebug)                                 \
-    YYFPRINTF Args;                            \
+    fprintf Args;                              \
 } while (0)
 /* Nonzero means print parse trace. [The following comment makes no
    sense to me.  Could someone clarify it?  --akim] Since this is
@@ -604,12 +528,7 @@ int yydebug;
 #endif
 
 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
-   if the built-in stack extension method is used).
-
-   Do not make this value too large; the results are undefined if
-   SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
-   evaluated with infinite-precision integer arithmetic.  */
-
+   if the built-in stack extension method is used).  */
 #if YYMAXDEPTH == 0
 # undef YYMAXDEPTH
 #endif
@@ -618,86 +537,38 @@ int yydebug;
 # define YYMAXDEPTH 10000
 #endif
 \f
-#if ! defined (yyoverflow) && ! defined (yymemcpy)
-# if __GNUC__ > 1              /* GNU C and GNU C++ define this.  */
-#  define yymemcpy __builtin_memcpy
-# else                         /* not GNU C or C++ */
+/* Define __yy_memcpy.  Note that the size argument
+   should be passed with type unsigned int, because that is what the non-GCC
+   definitions require.  With GCC, __builtin_memcpy takes an arg
+   of type size_t, but it can handle unsigned int.  */
+
+#if __GNUC__ > 1               /* GNU C and GNU C++ define this.  */
+# define __yy_memcpy(To, From, Count)  __builtin_memcpy (To, From, Count)
+#else                          /* not GNU C or C++ */
 
 /* This is the most reliable way to avoid incompatibilities
    in available built-in functions on various systems.  */
 static void
-#  if defined (__STDC__) || defined (__cplusplus)
-yymemcpy (char *yyto, const char *yyfrom, YYSIZE_T yycount)
-#  else
-yymemcpy (yyto, yyfrom, yycount)
-     char *yyto;
-     const char *yyfrom;
-     YYSIZE_T yycount;
-#  endif
-{
-  register const char *yyf = yyfrom;
-  register char *yyt = yyto;
-  register YYSIZE_T yyi = yycount;
-
-  while (yyi-- != 0)
-    *yyt++ = *yyf++;
-}
+# ifndef __cplusplus
+__yy_memcpy (to, from, count)
+     char *to;
+     const char *from;
+     unsigned int count;
+# else /* __cplusplus */
+__yy_memcpy (char *to, const char *from, unsigned int count)
 # endif
-#endif
-
-#ifdef YYERROR_VERBOSE
-
-# ifndef yystrlen
-#  if defined (__GLIBC__) && defined (_STRING_H)
-#   define yystrlen strlen
-#  else
-/* Return the length of YYSTR.  */
-static YYSIZE_T
-#   if defined (__STDC__) || defined (__cplusplus)
-yystrlen (const char *yystr)
-#   else
-yystrlen (yystr)
-     const char *yystr;
-#   endif
 {
-  register const char *yys = yystr;
+  register const char *f = from;
+  register char *t = to;
+  register int i = count;
 
-  while (*yys++ != '\0')
-    continue;
-
-  return yys - yystr - 1;
+  while (i-- > 0)
+    *t++ = *f++;
 }
-#  endif
-# endif
-
-# ifndef yystpcpy
-#  if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
-#   define yystpcpy stpcpy
-#  else
-/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
-   YYDEST.  */
-static char *
-#   if defined (__STDC__) || defined (__cplusplus)
-yystpcpy (char *yydest, const char *yysrc)
-#   else
-yystpcpy (yydest, yysrc)
-     char *yydest;
-     const char *yysrc;
-#   endif
-{
-  register char *yyd = yydest;
-  register const char *yys = yysrc;
 
-  while ((*yyd++ = *yys++) != '\0')
-    continue;
-
-  return yyd - 1;
-}
-#  endif
-# endif
 #endif
 \f
-#line 341 "/usr/share/bison/bison.simple"
+#line 216 "/usr/share/bison/bison.simple"
 
 
 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
@@ -731,7 +602,7 @@ int yyparse (void);
 /* YY_DECL_VARIABLES -- depending whether we use a pure parser,
    variables are global, or local to YYPARSE.  */
 
-#define YY_DECL_NON_LSP_VARIABLES                      \
+#define _YY_DECL_VARIABLES                             \
 /* The lookahead symbol.  */                           \
 int yychar;                                            \
                                                        \
@@ -743,13 +614,13 @@ int yynerrs;
 
 #if YYLSP_NEEDED
 # define YY_DECL_VARIABLES                     \
-YY_DECL_NON_LSP_VARIABLES                      \
+_YY_DECL_VARIABLES                             \
                                                \
 /* Location data for the lookahead symbol.  */ \
 YYLTYPE yylloc;
 #else
 # define YY_DECL_VARIABLES                     \
-YY_DECL_NON_LSP_VARIABLES
+_YY_DECL_VARIABLES
 #endif
 
 
@@ -770,7 +641,6 @@ yyparse (YYPARSE_PARAM_ARG)
 
   register int yystate;
   register int yyn;
-  int yyresult;
   /* Number of tokens to shift before error messages enabled.  */
   int yyerrstatus;
   /* Lookahead token as an internal (translated) token number.  */
@@ -778,7 +648,7 @@ yyparse (YYPARSE_PARAM_ARG)
 
   /* Three stacks and their tools:
      `yyss': related to states,
-     `yyvs': related to semantic values,
+     `yysv': related to semantic values,
      `yyls': related to locations.
 
      Refer to the stacks thru separate pointers, to allow yyoverflow
@@ -807,15 +677,16 @@ yyparse (YYPARSE_PARAM_ARG)
 # define YYPOPSTACK   (yyvsp--, yyssp--)
 #endif
 
-  YYSIZE_T yystacksize = YYINITDEPTH;
+  int yystacksize = YYINITDEPTH;
+  int yyfree_stacks = 0;
 
 
   /* The variables used to return semantic value and location from the
      action routines.  */
   YYSTYPE yyval;
-#if YYLSP_NEEDED
+# if YYLSP_NEEDED
   YYLTYPE yyloc;
-#endif
+# endif
 
   /* When reducing, the number of symbols on the RHS of the reduced
      rule. */
@@ -854,71 +725,81 @@ yyparse (YYPARSE_PARAM_ARG)
 
   if (yyssp >= yyss + yystacksize - 1)
     {
+      /* Give user a chance to reallocate the stack. Use copies of
+        these so that the &'s don't force the real ones into memory.
+        */
+      YYSTYPE *yyvs1 = yyvs;
+      short *yyss1 = yyss;
+#if YYLSP_NEEDED
+      YYLTYPE *yyls1 = yyls;
+#endif
+
       /* Get the current used size of the three stacks, in elements.  */
-      YYSIZE_T yysize = yyssp - yyss + 1;
+      int size = yyssp - yyss + 1;
 
 #ifdef yyoverflow
-      {
-       /* Give user a chance to reallocate the stack. Use copies of
-          these so that the &'s don't force the real ones into
-          memory.  */
-       YYSTYPE *yyvs1 = yyvs;
-       short *yyss1 = yyss;
-
-       /* Each stack pointer address is followed by the size of the
-          data in use in that stack, in bytes.  */
+      /* Each stack pointer address is followed by the size of the
+        data in use in that stack, in bytes.  */
 # if YYLSP_NEEDED
-       YYLTYPE *yyls1 = yyls;
-       /* This used to be a conditional around just the two extra args,
-          but that might be undefined if yyoverflow is a macro.  */
-       yyoverflow ("parser stack overflow",
-                   &yyss1, yysize * sizeof (*yyssp),
-                   &yyvs1, yysize * sizeof (*yyvsp),
-                   &yyls1, yysize * sizeof (*yylsp),
-                   &yystacksize);
-       yyls = yyls1;
+      /* This used to be a conditional around just the two extra args,
+        but that might be undefined if yyoverflow is a macro.  */
+      yyoverflow ("parser stack overflow",
+                 &yyss1, size * sizeof (*yyssp),
+                 &yyvs1, size * sizeof (*yyvsp),
+                 &yyls1, size * sizeof (*yylsp),
+                 &yystacksize);
 # else
-       yyoverflow ("parser stack overflow",
-                   &yyss1, yysize * sizeof (*yyssp),
-                   &yyvs1, yysize * sizeof (*yyvsp),
-                   &yystacksize);
+      yyoverflow ("parser stack overflow",
+                 &yyss1, size * sizeof (*yyssp),
+                 &yyvs1, size * sizeof (*yyvsp),
+                 &yystacksize);
+# endif
+
+      yyss = yyss1; yyvs = yyvs1;
+# if YYLSP_NEEDED
+      yyls = yyls1;
 # endif
-       yyss = yyss1;
-       yyvs = yyvs1;
-      }
 #else /* no yyoverflow */
       /* Extend the stack our own way.  */
       if (yystacksize >= YYMAXDEPTH)
-       goto yyoverflowlab;
+       {
+         yyerror ("parser stack overflow");
+         if (yyfree_stacks)
+           {
+             free (yyss);
+             free (yyvs);
+# if YYLSP_NEEDED
+             free (yyls);
+# endif
+           }
+         return 2;
+       }
       yystacksize *= 2;
       if (yystacksize > YYMAXDEPTH)
        yystacksize = YYMAXDEPTH;
-
-      {
-       short *yyss1 = yyss;
-       union yyalloc *yyptr =
-         (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
-       if (! yyptr)
-         goto yyoverflowlab;
-       YYSTACK_RELOCATE (short, yyss);
-       YYSTACK_RELOCATE (YYSTYPE, yyvs);
+# if !YYSTACK_USE_ALLOCA
+      yyfree_stacks = 1;
+# endif
+      yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
+      __yy_memcpy ((char *)yyss, (char *)yyss1,
+                  size * (unsigned int) sizeof (*yyssp));
+      yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
+      __yy_memcpy ((char *)yyvs, (char *)yyvs1,
+                  size * (unsigned int) sizeof (*yyvsp));
 # if YYLSP_NEEDED
-       YYSTACK_RELOCATE (YYLTYPE, yyls);
+      yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
+      __yy_memcpy ((char *)yyls, (char *)yyls1,
+                  size * (unsigned int) sizeof (*yylsp));
 # endif
-# undef YYSTACK_RELOCATE
-       if (yyss1 != yyssa)
-         YYSTACK_FREE (yyss1);
-      }
 #endif /* no yyoverflow */
 
-      yyssp = yyss + yysize - 1;
-      yyvsp = yyvs + yysize - 1;
+      yyssp = yyss + size - 1;
+      yyvsp = yyvs + size - 1;
 #if YYLSP_NEEDED
-      yylsp = yyls + yysize - 1;
+      yylsp = yyls + size - 1;
 #endif
 
-      YYDPRINTF ((stderr, "Stack size increased to %lu\n",
-                 (unsigned long int) yystacksize));
+      YYDPRINTF ((stderr, "Stack size increased to %d\n", yystacksize));
 
       if (yyssp >= yyss + yystacksize - 1)
        YYABORT;
@@ -973,14 +854,13 @@ yybackup:
        which are defined only if `YYDEBUG' is set.  */
       if (yydebug)
        {
-         YYFPRINTF (stderr, "Next token is %d (%s",
-                    yychar, yytname[yychar1]);
+         fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
          /* Give the individual parser a way to print the precise
             meaning of a token, for further debugging info.  */
 # ifdef YYPRINT
          YYPRINT (stderr, yychar, yylval);
 # endif
-         YYFPRINTF (stderr, ")\n");
+         fprintf (stderr, ")\n");
        }
 #endif
     }
@@ -1012,8 +892,7 @@ yybackup:
     YYACCEPT;
 
   /* Shift the lookahead token.  */
-  YYDPRINTF ((stderr, "Shifting token %d (%s), ",
-             yychar, yytname[yychar1]));
+  YYDPRINTF ((stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]));
 
   /* Discard the token being shifted unless it is eof.  */
   if (yychar != YYEOF)
@@ -1072,15 +951,15 @@ yyreduce:
      are defined only if `YYDEBUG' is set.  */
   if (yydebug)
     {
-      int yyi;
+      int i;
 
-      YYFPRINTF (stderr, "Reducing via rule %d (line %d), ",
-                yyn, yyrline[yyn]);
+      fprintf (stderr, "Reducing via rule %d (line %d), ",
+              yyn, yyrline[yyn]);
 
       /* Print the symbols being reduced, and their result.  */
-      for (yyi = yyprhs[yyn]; yyrhs[yyi] > 0; yyi++)
-       YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]);
-      YYFPRINTF (stderr, " -> %s\n", yytname[yyr1[yyn]]);
+      for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
+       fprintf (stderr, "%s ", yytname[yyrhs[i]]);
+      fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
     }
 #endif
 
@@ -1088,438 +967,438 @@ yyreduce:
 
 case 3:
 #line 111 "x509_ASN.y"
-{strcpy(yyval.str,yyvsp[0].str);}
-    break;
+{strcpy(yyval.str,yyvsp[0].str);;
+    break;}
 case 4:
 #line 112 "x509_ASN.y"
-{strcpy(yyval.str,yyvsp[0].str);}
-    break;
+{strcpy(yyval.str,yyvsp[0].str);;
+    break;}
 case 5:
 #line 115 "x509_ASN.y"
 {strcpy(yyval.str,"-");
-                       strcat(yyval.str,yyvsp[0].str);}
-    break;
+                       strcat(yyval.str,yyvsp[0].str);;
+    break;}
 case 6:
 #line 119 "x509_ASN.y"
-{strcpy(yyval.str,yyvsp[0].str);}
-    break;
+{strcpy(yyval.str,yyvsp[0].str);;
+    break;}
 case 7:
 #line 120 "x509_ASN.y"
-{strcpy(yyval.str,yyvsp[0].str);}
-    break;
+{strcpy(yyval.str,yyvsp[0].str);;
+    break;}
 case 8:
 #line 123 "x509_ASN.y"
-{strcpy(yyval.str,yyvsp[0].str);}
-    break;
+{strcpy(yyval.str,yyvsp[0].str);;
+    break;}
 case 9:
 #line 124 "x509_ASN.y"
-{strcpy(yyval.str,yyvsp[0].str);}
-    break;
+{strcpy(yyval.str,yyvsp[0].str);;
+    break;}
 case 10:
 #line 127 "x509_ASN.y"
-{strcpy(yyval.str,yyvsp[0].str);}
-    break;
+{strcpy(yyval.str,yyvsp[0].str);;
+    break;}
 case 11:
 #line 128 "x509_ASN.y"
-{strcpy(yyval.str,yyvsp[0].str);}
-    break;
+{strcpy(yyval.str,yyvsp[0].str);;
+    break;}
 case 12:
 #line 131 "x509_ASN.y"
 {yyval.node=_asn1_add_node(TYPE_CONSTANT); 
-                                       _asn1_set_value(yyval.node,yyvsp[-1].str,strlen(yyvsp[-1].str)+1);}
-    break;
+                                       _asn1_set_value(yyval.node,yyvsp[-1].str,strlen(yyvsp[-1].str)+1);;
+    break;}
 case 13:
 #line 133 "x509_ASN.y"
 {yyval.node=_asn1_add_node(TYPE_CONSTANT);
                                       _asn1_set_name(yyval.node,yyvsp[-3].str); 
-                                       _asn1_set_value(yyval.node,yyvsp[-1].str,strlen(yyvsp[-1].str)+1);}
-    break;
+                                       _asn1_set_value(yyval.node,yyvsp[-1].str,strlen(yyvsp[-1].str)+1);;
+    break;}
 case 14:
 #line 138 "x509_ASN.y"
-{yyval.node=yyvsp[0].node;}
-    break;
+{yyval.node=yyvsp[0].node;;
+    break;}
 case 15:
 #line 139 "x509_ASN.y"
 {yyval.node=yyvsp[-2].node;
-                                            _asn1_set_right(_asn1_get_last_right(yyvsp[-2].node),yyvsp[0].node);}
-    break;
+                                            _asn1_set_right(_asn1_get_last_right(yyvsp[-2].node),yyvsp[0].node);;
+    break;}
 case 16:
 #line 143 "x509_ASN.y"
 {yyval.node=_asn1_add_node(TYPE_IDENTIFIER);
-                                 _asn1_set_name(yyval.node,yyvsp[0].str);}
-    break;
+                                 _asn1_set_name(yyval.node,yyvsp[0].str);;
+    break;}
 case 17:
 #line 146 "x509_ASN.y"
 {yyval.node=yyvsp[-1].node;
                                  _asn1_set_right(_asn1_get_last_right(yyval.node),_asn1_add_node(TYPE_IDENTIFIER));
-                                 _asn1_set_name(_asn1_get_last_right(yyval.node),yyvsp[0].str);}
-    break;
+                                 _asn1_set_name(_asn1_get_last_right(yyval.node),yyvsp[0].str);;
+    break;}
 case 18:
 #line 151 "x509_ASN.y"
 {yyval.node=_asn1_add_node(TYPE_CONSTANT); 
-                                   _asn1_set_value(yyval.node,yyvsp[0].str,strlen(yyvsp[0].str)+1);}
-    break;
+                                   _asn1_set_value(yyval.node,yyvsp[0].str,strlen(yyvsp[0].str)+1);;
+    break;}
 case 19:
 #line 153 "x509_ASN.y"
 {yyval.node=_asn1_add_node(TYPE_CONSTANT);
                                    _asn1_set_name(yyval.node,yyvsp[-3].str); 
-                                    _asn1_set_value(yyval.node,yyvsp[-1].str,strlen(yyvsp[-1].str)+1);}
-    break;
+                                    _asn1_set_value(yyval.node,yyvsp[-1].str,strlen(yyvsp[-1].str)+1);;
+    break;}
 case 20:
 #line 158 "x509_ASN.y"
-{yyval.node=yyvsp[0].node;}
-    break;
+{yyval.node=yyvsp[0].node;;
+    break;}
 case 21:
 #line 159 "x509_ASN.y"
 {yyval.node=yyvsp[-1].node;
-                                                    _asn1_set_right(_asn1_get_last_right(yyvsp[-1].node),yyvsp[0].node);}
-    break;
+                                                    _asn1_set_right(_asn1_get_last_right(yyvsp[-1].node),yyvsp[0].node);;
+    break;}
 case 22:
 #line 163 "x509_ASN.y"
-{yyval.constant=CONST_UNIVERSAL;}
-    break;
+{yyval.constant=CONST_UNIVERSAL;;
+    break;}
 case 23:
 #line 164 "x509_ASN.y"
-{yyval.constant=CONST_PRIVATE;}
-    break;
+{yyval.constant=CONST_PRIVATE;;
+    break;}
 case 24:
 #line 165 "x509_ASN.y"
-{yyval.constant=CONST_APPLICATION;}
-    break;
+{yyval.constant=CONST_APPLICATION;;
+    break;}
 case 25:
 #line 168 "x509_ASN.y"
 {yyval.node=_asn1_add_node(TYPE_TAG); 
-                            _asn1_set_value(yyval.node,yyvsp[-1].str,strlen(yyvsp[-1].str)+1);}
-    break;
+                            _asn1_set_value(yyval.node,yyvsp[-1].str,strlen(yyvsp[-1].str)+1);;
+    break;}
 case 26:
 #line 170 "x509_ASN.y"
 {yyval.node=_asn1_add_node(TYPE_TAG | yyvsp[-2].constant); 
-                                _asn1_set_value(yyval.node,yyvsp[-1].str,strlen(yyvsp[-1].str)+1);}
-    break;
+                                _asn1_set_value(yyval.node,yyvsp[-1].str,strlen(yyvsp[-1].str)+1);;
+    break;}
 case 27:
 #line 174 "x509_ASN.y"
-{yyval.node=yyvsp[0].node;}
-    break;
+{yyval.node=yyvsp[0].node;;
+    break;}
 case 28:
 #line 175 "x509_ASN.y"
-{yyval.node=_asn1_mod_type(yyvsp[-1].node,CONST_EXPLICIT);}
-    break;
+{yyval.node=_asn1_mod_type(yyvsp[-1].node,CONST_EXPLICIT);;
+    break;}
 case 29:
 #line 176 "x509_ASN.y"
-{yyval.node=_asn1_mod_type(yyvsp[-1].node,CONST_IMPLICIT);}
-    break;
+{yyval.node=_asn1_mod_type(yyvsp[-1].node,CONST_IMPLICIT);;
+    break;}
 case 30:
 #line 179 "x509_ASN.y"
 {yyval.node=_asn1_add_node(TYPE_DEFAULT); 
-                                       _asn1_set_value(yyval.node,yyvsp[0].str,strlen(yyvsp[0].str)+1);}
-    break;
+                                       _asn1_set_value(yyval.node,yyvsp[0].str,strlen(yyvsp[0].str)+1);;
+    break;}
 case 31:
 #line 181 "x509_ASN.y"
-{yyval.node=_asn1_add_node(TYPE_DEFAULT|CONST_TRUE);}
-    break;
+{yyval.node=_asn1_add_node(TYPE_DEFAULT|CONST_TRUE);;
+    break;}
 case 32:
 #line 182 "x509_ASN.y"
-{yyval.node=_asn1_add_node(TYPE_DEFAULT|CONST_FALSE);}
-    break;
+{yyval.node=_asn1_add_node(TYPE_DEFAULT|CONST_FALSE);;
+    break;}
 case 33:
 #line 185 "x509_ASN.y"
-{yyval.node=_asn1_add_node(TYPE_INTEGER);}
-    break;
+{yyval.node=_asn1_add_node(TYPE_INTEGER);;
+    break;}
 case 34:
 #line 186 "x509_ASN.y"
 {yyval.node=_asn1_add_node(TYPE_INTEGER|CONST_LIST);
-                                        _asn1_set_down(yyval.node,yyvsp[-1].node);}
-    break;
+                                        _asn1_set_down(yyval.node,yyvsp[-1].node);;
+    break;}
 case 35:
 #line 189 "x509_ASN.y"
 {yyval.node=_asn1_add_node(TYPE_INTEGER|CONST_MIN_MAX);
                                          _asn1_set_down(yyval.node,_asn1_add_node(TYPE_SIZE)); 
                                          _asn1_set_value(_asn1_get_down(yyval.node),yyvsp[-1].str,strlen(yyvsp[-1].str)+1); 
-                                         _asn1_set_name(_asn1_get_down(yyval.node),yyvsp[-4].str);}
-    break;
+                                         _asn1_set_name(_asn1_get_down(yyval.node),yyvsp[-4].str);;
+    break;}
 case 36:
 #line 195 "x509_ASN.y"
-{yyval.node=_asn1_add_node(TYPE_BOOLEAN);}
-    break;
+{yyval.node=_asn1_add_node(TYPE_BOOLEAN);;
+    break;}
 case 37:
 #line 198 "x509_ASN.y"
-{yyval.node=_asn1_add_node(TYPE_TIME|CONST_UTC);}
-    break;
+{yyval.node=_asn1_add_node(TYPE_TIME|CONST_UTC);;
+    break;}
 case 38:
 #line 199 "x509_ASN.y"
-{yyval.node=_asn1_add_node(TYPE_TIME|CONST_GENERALIZED);}
-    break;
+{yyval.node=_asn1_add_node(TYPE_TIME|CONST_GENERALIZED);;
+    break;}
 case 39:
 #line 202 "x509_ASN.y"
 {yyval.node=_asn1_add_node(TYPE_SIZE|CONST_1_PARAM);
-                                     _asn1_set_value(yyval.node,yyvsp[-1].str,strlen(yyvsp[-1].str)+1);}
-    break;
+                                     _asn1_set_value(yyval.node,yyvsp[-1].str,strlen(yyvsp[-1].str)+1);;
+    break;}
 case 40:
 #line 205 "x509_ASN.y"
 {yyval.node=_asn1_add_node(TYPE_SIZE|CONST_MIN_MAX);
                                      _asn1_set_value(yyval.node,yyvsp[-4].str,strlen(yyvsp[-4].str)+1);
-                                      _asn1_set_name(yyval.node,yyvsp[-1].str);}
-    break;
+                                      _asn1_set_name(yyval.node,yyvsp[-1].str);;
+    break;}
 case 41:
 #line 210 "x509_ASN.y"
-{yyval.node=yyvsp[0].node;}
-    break;
+{yyval.node=yyvsp[0].node;;
+    break;}
 case 42:
 #line 211 "x509_ASN.y"
-{yyval.node=yyvsp[-1].node;}
-    break;
+{yyval.node=yyvsp[-1].node;;
+    break;}
 case 43:
 #line 214 "x509_ASN.y"
-{yyval.node=_asn1_add_node(TYPE_OCTET_STRING);}
-    break;
+{yyval.node=_asn1_add_node(TYPE_OCTET_STRING);;
+    break;}
 case 44:
 #line 215 "x509_ASN.y"
 {yyval.node=_asn1_add_node(TYPE_OCTET_STRING|CONST_SIZE);
-                                           _asn1_set_down(yyval.node,yyvsp[0].node);}
-    break;
+                                           _asn1_set_down(yyval.node,yyvsp[0].node);;
+    break;}
 case 45:
 #line 219 "x509_ASN.y"
 {yyval.node=_asn1_add_node(TYPE_CONSTANT);
                                   _asn1_set_name(yyval.node,yyvsp[-3].str); 
-                                    _asn1_set_value(yyval.node,yyvsp[-1].str,strlen(yyvsp[-1].str)+1);}
-    break;
+                                    _asn1_set_value(yyval.node,yyvsp[-1].str,strlen(yyvsp[-1].str)+1);;
+    break;}
 case 46:
 #line 224 "x509_ASN.y"
-{yyval.node=yyvsp[0].node;}
-    break;
+{yyval.node=yyvsp[0].node;;
+    break;}
 case 47:
 #line 225 "x509_ASN.y"
 {yyval.node=yyvsp[-2].node;
-                                                       _asn1_set_right(_asn1_get_last_right(yyvsp[-2].node),yyvsp[0].node);}
-    break;
+                                                       _asn1_set_right(_asn1_get_last_right(yyvsp[-2].node),yyvsp[0].node);;
+    break;}
 case 48:
 #line 229 "x509_ASN.y"
-{yyval.node=_asn1_add_node(TYPE_BIT_STRING);}
-    break;
+{yyval.node=_asn1_add_node(TYPE_BIT_STRING);;
+    break;}
 case 49:
 #line 231 "x509_ASN.y"
 {yyval.node=_asn1_add_node(TYPE_BIT_STRING|CONST_LIST);
-                                _asn1_set_down(yyval.node,yyvsp[-1].node);}
-    break;
+                                _asn1_set_down(yyval.node,yyvsp[-1].node);;
+    break;}
 case 50:
 #line 236 "x509_ASN.y"
 {yyval.node=_asn1_add_node(TYPE_ENUMERATED|CONST_LIST);
-                                _asn1_set_down(yyval.node,yyvsp[-1].node);}
-    break;
+                                _asn1_set_down(yyval.node,yyvsp[-1].node);;
+    break;}
 case 51:
 #line 240 "x509_ASN.y"
-{yyval.node=_asn1_add_node(TYPE_OBJECT_ID);}
-    break;
+{yyval.node=_asn1_add_node(TYPE_OBJECT_ID);;
+    break;}
 case 52:
 #line 243 "x509_ASN.y"
 {yyval.node=_asn1_add_node(TYPE_IDENTIFIER);
-                                       _asn1_set_value(yyval.node,yyvsp[0].str,strlen(yyvsp[0].str)+1);}
-    break;
+                                       _asn1_set_value(yyval.node,yyvsp[0].str,strlen(yyvsp[0].str)+1);;
+    break;}
 case 53:
 #line 245 "x509_ASN.y"
 {yyval.node=_asn1_add_node(TYPE_IDENTIFIER|CONST_SIZE);
                                        _asn1_set_value(yyval.node,yyvsp[-1].str,strlen(yyvsp[-1].str)+1);
-                                       _asn1_set_down(yyval.node,yyvsp[0].node);}
-    break;
+                                       _asn1_set_down(yyval.node,yyvsp[0].node);;
+    break;}
 case 54:
 #line 248 "x509_ASN.y"
-{yyval.node=yyvsp[0].node;}
-    break;
+{yyval.node=yyvsp[0].node;;
+    break;}
 case 55:
 #line 249 "x509_ASN.y"
-{yyval.node=yyvsp[0].node;}
-    break;
+{yyval.node=yyvsp[0].node;;
+    break;}
 case 56:
 #line 250 "x509_ASN.y"
-{yyval.node=yyvsp[0].node;}
-    break;
+{yyval.node=yyvsp[0].node;;
+    break;}
 case 58:
 #line 252 "x509_ASN.y"
-{yyval.node=yyvsp[0].node;}
-    break;
+{yyval.node=yyvsp[0].node;;
+    break;}
 case 59:
 #line 253 "x509_ASN.y"
-{yyval.node=yyvsp[0].node;}
-    break;
+{yyval.node=yyvsp[0].node;;
+    break;}
 case 60:
 #line 254 "x509_ASN.y"
-{yyval.node=yyvsp[0].node;}
-    break;
+{yyval.node=yyvsp[0].node;;
+    break;}
 case 61:
 #line 255 "x509_ASN.y"
-{yyval.node=yyvsp[0].node;}
-    break;
+{yyval.node=yyvsp[0].node;;
+    break;}
 case 62:
 #line 256 "x509_ASN.y"
-{yyval.node=yyvsp[0].node;}
-    break;
+{yyval.node=yyvsp[0].node;;
+    break;}
 case 63:
 #line 257 "x509_ASN.y"
-{yyval.node=yyvsp[0].node;}
-    break;
+{yyval.node=yyvsp[0].node;;
+    break;}
 case 64:
 #line 258 "x509_ASN.y"
-{yyval.node=yyvsp[0].node;}
-    break;
+{yyval.node=yyvsp[0].node;;
+    break;}
 case 65:
 #line 259 "x509_ASN.y"
-{yyval.node=_asn1_add_node(TYPE_NULL);}
-    break;
+{yyval.node=_asn1_add_node(TYPE_NULL);;
+    break;}
 case 66:
 #line 262 "x509_ASN.y"
-{yyval.node=yyvsp[0].node;}
-    break;
+{yyval.node=yyvsp[0].node;;
+    break;}
 case 67:
 #line 263 "x509_ASN.y"
 {yyval.node=_asn1_mod_type(yyvsp[0].node,CONST_TAG);
                                                _asn1_set_right(yyvsp[-1].node,_asn1_get_down(yyval.node));
-                                               _asn1_set_down(yyval.node,yyvsp[-1].node);}
-    break;
+                                               _asn1_set_down(yyval.node,yyvsp[-1].node);;
+    break;}
 case 68:
 #line 268 "x509_ASN.y"
-{yyval.node=yyvsp[0].node;}
-    break;
+{yyval.node=yyvsp[0].node;;
+    break;}
 case 69:
 #line 269 "x509_ASN.y"
 {yyval.node=_asn1_mod_type(yyvsp[-1].node,CONST_DEFAULT);
                                                        _asn1_set_right(yyvsp[0].node,_asn1_get_down(yyval.node));
-                                                      _asn1_set_down(yyval.node,yyvsp[0].node);}
-    break;
+                                                      _asn1_set_down(yyval.node,yyvsp[0].node);;
+    break;}
 case 70:
 #line 272 "x509_ASN.y"
-{yyval.node=_asn1_mod_type(yyvsp[-1].node,CONST_OPTION);}
-    break;
+{yyval.node=_asn1_mod_type(yyvsp[-1].node,CONST_OPTION);;
+    break;}
 case 71:
 #line 275 "x509_ASN.y"
-{yyval.node=_asn1_set_name(yyvsp[0].node,yyvsp[-1].str);}
-    break;
+{yyval.node=_asn1_set_name(yyvsp[0].node,yyvsp[-1].str);;
+    break;}
 case 72:
 #line 278 "x509_ASN.y"
-{yyval.node=yyvsp[0].node;}
-    break;
+{yyval.node=yyvsp[0].node;;
+    break;}
 case 73:
 #line 279 "x509_ASN.y"
 {yyval.node=yyvsp[-2].node;
-                                                _asn1_set_right(_asn1_get_last_right(yyvsp[-2].node),yyvsp[0].node);}
-    break;
+                                                _asn1_set_right(_asn1_get_last_right(yyvsp[-2].node),yyvsp[0].node);;
+    break;}
 case 74:
 #line 283 "x509_ASN.y"
 {yyval.node=_asn1_add_node(TYPE_SEQUENCE);
-                                              _asn1_set_down(yyval.node,yyvsp[-1].node);}
-    break;
+                                              _asn1_set_down(yyval.node,yyvsp[-1].node);;
+    break;}
 case 75:
 #line 285 "x509_ASN.y"
 {yyval.node=_asn1_add_node(TYPE_SEQUENCE_OF);
-                                              _asn1_set_down(yyval.node,yyvsp[0].node);}
-    break;
+                                              _asn1_set_down(yyval.node,yyvsp[0].node);;
+    break;}
 case 76:
 #line 287 "x509_ASN.y"
 {yyval.node=_asn1_add_node(TYPE_SEQUENCE_OF|CONST_SIZE);
                                             _asn1_set_right(yyvsp[-2].node,yyvsp[0].node);
-                                            _asn1_set_down(yyval.node,yyvsp[-2].node);}
-    break;
+                                            _asn1_set_down(yyval.node,yyvsp[-2].node);;
+    break;}
 case 77:
 #line 292 "x509_ASN.y"
 {yyval.node=_asn1_add_node(TYPE_SET);
-                                     _asn1_set_down(yyval.node,yyvsp[-1].node);}
-    break;
+                                     _asn1_set_down(yyval.node,yyvsp[-1].node);;
+    break;}
 case 78:
 #line 294 "x509_ASN.y"
 {yyval.node=_asn1_add_node(TYPE_SET_OF);
-                                     _asn1_set_down(yyval.node,yyvsp[0].node);}
-    break;
+                                     _asn1_set_down(yyval.node,yyvsp[0].node);;
+    break;}
 case 79:
 #line 296 "x509_ASN.y"
 {yyval.node=_asn1_add_node(TYPE_SET_OF|CONST_SIZE);
                                        _asn1_set_right(yyvsp[-2].node,yyvsp[0].node);
-                                       _asn1_set_down(yyval.node,yyvsp[-2].node);}
-    break;
+                                       _asn1_set_down(yyval.node,yyvsp[-2].node);;
+    break;}
 case 80:
 #line 301 "x509_ASN.y"
 {yyval.node=_asn1_add_node(TYPE_CHOICE);
-                                             _asn1_set_down(yyval.node,yyvsp[-1].node);}
-    break;
+                                             _asn1_set_down(yyval.node,yyvsp[-1].node);;
+    break;}
 case 81:
 #line 305 "x509_ASN.y"
-{yyval.node=_asn1_add_node(TYPE_ANY);}
-    break;
+{yyval.node=_asn1_add_node(TYPE_ANY);;
+    break;}
 case 82:
 #line 306 "x509_ASN.y"
 {yyval.node=_asn1_add_node(TYPE_ANY|CONST_DEFINED_BY);
                                         _asn1_set_down(yyval.node,_asn1_add_node(TYPE_CONSTANT));
-                                       _asn1_set_name(_asn1_get_down(yyval.node),yyvsp[0].str);}
-    break;
+                                       _asn1_set_name(_asn1_get_down(yyval.node),yyvsp[0].str);;
+    break;}
 case 83:
 #line 311 "x509_ASN.y"
-{yyval.node=_asn1_set_name(yyvsp[0].node,yyvsp[-2].str);}
-    break;
+{yyval.node=_asn1_set_name(yyvsp[0].node,yyvsp[-2].str);;
+    break;}
 case 84:
 #line 315 "x509_ASN.y"
 {yyval.node=_asn1_add_node(TYPE_OBJECT_ID|CONST_ASSIGN);
                          _asn1_set_name(yyval.node,yyvsp[-6].str);  
-                         _asn1_set_down(yyval.node,yyvsp[-1].node);}
-    break;
+                         _asn1_set_down(yyval.node,yyvsp[-1].node);;
+    break;}
 case 85:
 #line 319 "x509_ASN.y"
 {yyval.node=_asn1_add_node(TYPE_OBJECT_ID|CONST_ASSIGN|CONST_1_PARAM);
                          _asn1_set_name(yyval.node,yyvsp[-5].str);  
                          _asn1_set_value(yyval.node,yyvsp[-4].str,strlen(yyvsp[-4].str)+1);
-                         _asn1_set_down(yyval.node,yyvsp[-1].node);}
-    break;
+                         _asn1_set_down(yyval.node,yyvsp[-1].node);;
+    break;}
 case 86:
 #line 324 "x509_ASN.y"
 {yyval.node=_asn1_add_node(TYPE_INTEGER|CONST_ASSIGN);
                          _asn1_set_name(yyval.node,yyvsp[-3].str);  
-                         _asn1_set_value(yyval.node,yyvsp[0].str,strlen(yyvsp[0].str)+1);}
-    break;
+                         _asn1_set_value(yyval.node,yyvsp[0].str,strlen(yyvsp[0].str)+1);;
+    break;}
 case 87:
 #line 329 "x509_ASN.y"
-{yyval.node=yyvsp[0].node;}
-    break;
+{yyval.node=yyvsp[0].node;;
+    break;}
 case 88:
 #line 330 "x509_ASN.y"
-{yyval.node=yyvsp[0].node;}
-    break;
+{yyval.node=yyvsp[0].node;;
+    break;}
 case 89:
 #line 333 "x509_ASN.y"
-{yyval.node=yyvsp[0].node;}
-    break;
+{yyval.node=yyvsp[0].node;;
+    break;}
 case 90:
 #line 334 "x509_ASN.y"
 {yyval.node=yyvsp[-1].node;
-                                                          _asn1_set_right(_asn1_get_last_right(yyvsp[-1].node),yyvsp[0].node);}
-    break;
+                                                          _asn1_set_right(_asn1_get_last_right(yyvsp[-1].node),yyvsp[0].node);;
+    break;}
 case 91:
 #line 338 "x509_ASN.y"
 {yyval.node=_asn1_add_node(TYPE_OBJECT_ID);
                                                           _asn1_set_down(yyval.node,yyvsp[-1].node);
-                                                          _asn1_set_name(yyval.node,yyvsp[-3].str);}
-    break;
+                                                          _asn1_set_name(yyval.node,yyvsp[-3].str);;
+    break;}
 case 92:
 #line 341 "x509_ASN.y"
 {yyval.node=_asn1_add_node(TYPE_OBJECT_ID);
-                                                          _asn1_set_name(yyval.node,yyvsp[-2].str);}
-    break;
+                                                          _asn1_set_name(yyval.node,yyvsp[-2].str);;
+    break;}
 case 93:
 #line 345 "x509_ASN.y"
-{yyval.node=NULL;}
-    break;
+{yyval.node=NULL;;
+    break;}
 case 94:
 #line 347 "x509_ASN.y"
 {yyval.node=_asn1_add_node(TYPE_IMPORTS);
                          _asn1_set_down(yyval.node,_asn1_add_node(TYPE_OBJECT_ID));
                          _asn1_set_name(_asn1_get_down(yyval.node),yyvsp[-1].str);  
                          _asn1_set_down(_asn1_get_down(yyval.node),yyvsp[0].node);
-                         _asn1_set_right(yyval.node,yyvsp[-3].node);}
-    break;
+                         _asn1_set_right(yyval.node,yyvsp[-3].node);;
+    break;}
 case 95:
 #line 354 "x509_ASN.y"
-{yyval.constant=CONST_EXPLICIT;}
-    break;
+{yyval.constant=CONST_EXPLICIT;;
+    break;}
 case 96:
 #line 355 "x509_ASN.y"
-{yyval.constant=CONST_IMPLICIT;}
-    break;
+{yyval.constant=CONST_IMPLICIT;;
+    break;}
 case 97:
 #line 361 "x509_ASN.y"
 {yyval.node=_asn1_add_node(TYPE_DEFINITIONS|yyvsp[-6].constant|((yyvsp[-2].node==NULL)?0:CONST_IMPORTS));
@@ -1535,11 +1414,11 @@ case 97:
                      if(result_parse==ASN_IDENTIFIER_NOT_FOUND)
                        asn1_delete_structure(yyval.node);
                      else p_tree=yyval.node;
-                   }}
-    break;
+                   };
+    break;}
 }
 
-#line 727 "/usr/share/bison/bison.simple"
+#line 610 "/usr/share/bison/bison.simple"
 
 \f
   yyvsp -= yylen;
@@ -1551,11 +1430,11 @@ case 97:
 #if YYDEBUG
   if (yydebug)
     {
-      short *yyssp1 = yyss - 1;
-      YYFPRINTF (stderr, "state stack now");
-      while (yyssp1 != yyssp)
-       YYFPRINTF (stderr, " %d", *++yyssp1);
-      YYFPRINTF (stderr, "\n");
+      short *ssp1 = yyss - 1;
+      fprintf (stderr, "state stack now");
+      while (ssp1 != yyssp)
+       fprintf (stderr, " %d", *++ssp1);
+      fprintf (stderr, "\n");
     }
 #endif
 
@@ -1593,47 +1472,46 @@ yyerrlab:
 
       if (yyn > YYFLAG && yyn < YYLAST)
        {
-         YYSIZE_T yysize = 0;
-         char *yymsg;
-         int yyx, yycount;
-
-         yycount = 0;
-         /* Start YYX at -YYN if negative to avoid negative indexes in
-            YYCHECK.  */
-         for (yyx = yyn < 0 ? -yyn : 0;
-              yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++)
-           if (yycheck[yyx + yyn] == yyx)
-             yysize += yystrlen (yytname[yyx]) + 15, yycount++;
-         yysize += yystrlen ("parse error, unexpected ") + 1;
-         yysize += yystrlen (yytname[YYTRANSLATE (yychar)]);
-         yymsg = (char *) YYSTACK_ALLOC (yysize);
-         if (yymsg != 0)
+         int size = 0;
+         char *msg;
+         int x, count;
+
+         count = 0;
+         /* Start X at -yyn if nec to avoid negative indexes in yycheck.  */
+         for (x = (yyn < 0 ? -yyn : 0);
+              x < (int) (sizeof (yytname) / sizeof (char *)); x++)
+           if (yycheck[x + yyn] == x)
+             size += strlen (yytname[x]) + 15, count++;
+         size += strlen ("parse error, unexpected `") + 1;
+         size += strlen (yytname[YYTRANSLATE (yychar)]);
+         msg = (char *) malloc (size);
+         if (msg != 0)
            {
-             char *yyp = yystpcpy (yymsg, "parse error, unexpected ");
-             yyp = yystpcpy (yyp, yytname[YYTRANSLATE (yychar)]);
+             strcpy (msg, "parse error, unexpected `");
+             strcat (msg, yytname[YYTRANSLATE (yychar)]);
+             strcat (msg, "'");
 
-             if (yycount < 5)
+             if (count < 5)
                {
-                 yycount = 0;
-                 for (yyx = yyn < 0 ? -yyn : 0;
-                      yyx < (int) (sizeof (yytname) / sizeof (char *));
-                      yyx++)
-                   if (yycheck[yyx + yyn] == yyx)
+                 count = 0;
+                 for (x = (yyn < 0 ? -yyn : 0);
+                      x < (int) (sizeof (yytname) / sizeof (char *)); x++)
+                   if (yycheck[x + yyn] == x)
                      {
-                       const char *yyq = ! yycount ? ", expecting " : " or ";
-                       yyp = yystpcpy (yyp, yyq);
-                       yyp = yystpcpy (yyp, yytname[yyx]);
-                       yycount++;
+                       strcat (msg, count == 0 ? ", expecting `" : " or `");
+                       strcat (msg, yytname[x]);
+                       strcat (msg, "'");
+                       count++;
                      }
                }
-             yyerror (yymsg);
-             YYSTACK_FREE (yymsg);
+             yyerror (msg);
+             free (msg);
            }
          else
-           yyerror ("parse error; also virtual memory exhausted");
+           yyerror ("parse error; also virtual memory exceeded");
        }
       else
-#endif /* defined (YYERROR_VERBOSE) */
+#endif /* YYERROR_VERBOSE */
        yyerror ("parse error");
     }
   goto yyerrlab1;
@@ -1696,11 +1574,11 @@ yyerrpop:
 #if YYDEBUG
   if (yydebug)
     {
-      short *yyssp1 = yyss - 1;
-      YYFPRINTF (stderr, "Error: state stack now");
-      while (yyssp1 != yyssp)
-       YYFPRINTF (stderr, " %d", *++yyssp1);
-      YYFPRINTF (stderr, "\n");
+      short *ssp1 = yyss - 1;
+      fprintf (stderr, "Error: state stack now");
+      while (ssp1 != yyssp)
+       fprintf (stderr, " %d", *++ssp1);
+      fprintf (stderr, "\n");
     }
 #endif
 
@@ -1745,30 +1623,30 @@ yyerrhandle:
 | yyacceptlab -- YYACCEPT comes here.  |
 `-------------------------------------*/
 yyacceptlab:
-  yyresult = 0;
-  goto yyreturn;
+  if (yyfree_stacks)
+    {
+      free (yyss);
+      free (yyvs);
+#if YYLSP_NEEDED
+      free (yyls);
+#endif
+    }
+  return 0;
+
 
 /*-----------------------------------.
 | yyabortlab -- YYABORT comes here.  |
 `-----------------------------------*/
 yyabortlab:
-  yyresult = 1;
-  goto yyreturn;
-
-/*---------------------------------------------.
-| yyoverflowab -- parser overflow comes here.  |
-`---------------------------------------------*/
-yyoverflowlab:
-  yyerror ("parser stack overflow");
-  yyresult = 2;
-  /* Fall through.  */
-
-yyreturn:
-#ifndef yyoverflow
-  if (yyss != yyssa)
-    YYSTACK_FREE (yyss);
+  if (yyfree_stacks)
+    {
+      free (yyss);
+      free (yyvs);
+#if YYLSP_NEEDED
+      free (yyls);
 #endif
-  return yyresult;
+    }
+  return 1;
 }
 #line 377 "x509_ASN.y"