Page MenuHome GnuPG

No OneTemporary

This document is not UTF8. It was detected as Shift JIS and converted to UTF8 for display.
diff --git a/cipher/ChangeLog b/cipher/ChangeLog
index 91a27704..1c6a7c15 100644
--- a/cipher/ChangeLog
+++ b/cipher/ChangeLog
@@ -1,474 +1,470 @@
Wed Jul 7 13:08:40 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
-
* Makefile.am: Support for libtool.
Fri Jul 2 11:45:54 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
-
* dsa.c (gen_k): Changed algorithm to consume less random bytes
* elgamal.c (gen_k): Ditto.
* random.c (random_dump_stats): New.
Thu Jul 1 12:47:31 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
-
* primegen.c, elgamal.c, dsa.c (progess): New and replaced all
fputc with a call to this function.
Sat Jun 26 12:15:59 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
-
* rndegd.c (do_write): s/ssize_t/int/ due to SunOS 4.1 probs.
* cipher.c (do_cbc_encrypt, do_cbc_decrypt): New.
* dynload.c (HAVE_DL_SHL_LOAD): Map hpux API to dlopen (Dave Dykstra).
* Makefile.am (install-exec-hook): Removed.
Sun May 23 14:20:22 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
* cipher.c (setup_cipher_table): Enable Twofish
* random.c (fast_random_poll): Disable use of times() for mingw32.
Mon May 17 21:54:43 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
* dynload.c (register_internal_cipher_extension): Minor init fix.
Tue May 4 15:47:53 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
* primegen.c (gen_prime): Readded the Fermat test. Fixed the bug
that we didn't correct for step when passing the prime to the
Rabin-Miller test which led to bad performance (Stefan Keller).
(check_prime): Add a first Fermat test.
Sun Apr 18 10:11:28 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
* cipher.c (cipher_setiv): Add ivlen arg, changed all callers.
* random.c (randomize_buffer): alway use secure memory because
we can't use m_is_secure() on a statically allocated buffer.
* twofish.c: Replaced some macros by a loop to reduce text size.
* Makefile.am (twofish): No more need for sed editing.
Fri Apr 9 12:26:25 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
* cipher.c (cipher_open): Reversed the changes for AUTO_CFB.
* blowfish.c: Dropped the Blowfish 160 mode.
* cipher.c (cipher_open): Ditto.
(setup_cipher_table): Ditto. And removed support of twofish128
Wed Apr 7 20:51:39 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
* random.c (get_random_bits): Can now handle requests > POOLSIZE
* cipher.c (cipher_open): Now uses standard CFB for automode if
the blocksize is gt 8 (according to rfc2440).
* twofish.c: Applied Matthew Skala's patches for 256 bit key.
Tue Apr 6 19:58:12 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
* random.c (get_random_bits): Can now handle requests > POOLSIZE
* cipher.c (cipher_open): Now uses standard CFB for automode if
the blocksize is gt 8 (according to rfc2440).
Sat Mar 20 11:44:21 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
* rndlinux.c (tty_printf) [IS_MODULE]: Removed.
* rndegd.c (gather_random): Some fixes.
Wed Mar 17 13:09:03 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
* rndegd.c (do_read): New.
(gather_random): Changed the implementation.
Mon Mar 8 20:47:17 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
* dynload.c (DLSYM_NEEDS_UNDERSCORE): Renamed.
Fri Feb 26 17:55:41 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
* md.c: Nearly a total rewrote.
Wed Feb 24 11:07:27 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
* cipher.c (context): Fixed alignment
* md.c: Ditto.
* rndegd.c: New
Mon Feb 22 20:04:00 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
* rndegd.c: New.
Wed Feb 10 17:15:39 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
* Makefile.am: Modules are now figured out by configure
* construct.c: New. Generated by configure. Changed all modules
to work with that.
* sha1.h: Removed.
* md5.h: Removed.
* twofish.c: Changed interface to allow Twofish/256
* rndunix.c (start_gatherer): Die on SIGPIPE.
Wed Jan 20 18:59:49 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
* rndunix.c (gather_random): Fix to avoid infinite loop.
Sun Jan 17 11:04:33 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
* des.c (is_weak_key): Replace system memcmp due to bugs
in SunOS's memcmp.
(des_get_info): Return error on failed selftest.
* twofish.c (twofish_setkey): Return error on failed selftest or
invalid keylength.
* cast5.c (cast_setkey): Ditto.
* blowfish.c (bf_setkey): Return error on failed selftest.
Tue Jan 12 11:17:18 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
* random.c (random_is_faked): New.
* tiger.c: Only compile if we have the u64 type
Sat Jan 9 16:02:23 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
* rndunix.c (gather_random): check for setuid.
* Makefile.am: Add a way to staically link random modules
Thu Jan 7 18:00:58 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
* md.c (md_stop_debug): Do a flush first.
(md_open): size of buffer now depends on the secure parameter
Sun Jan 3 15:28:44 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
* rndunix.c (start_gatherer): Fixed stupid ==/= bug
1998-12-31 Geoff Keating <geoffk@ozemail.com.au>
* des.c (is_weak_key): Rewrite loop end condition.
Tue Dec 29 14:41:47 CET 1998 Werner Koch <wk@isil.d.shuttle.de>
* random.c: add unistd.h for getpid().
(RAND_MAX): Fallback value for Sun.
Wed Dec 23 17:12:24 CET 1998 Werner Koch <wk@isil.d.shuttle.de>
* md.c (md_copy): Reset debug.
Mon Dec 14 21:18:49 CET 1998 Werner Koch <wk@isil.d.shuttle.de>
* random.c (read_random_source): Changed the interface to the
random gathering function.
(gather_faked): Use new interface.
* dynload.c (dynload_getfnc_fast_random_poll): Ditto.
(dynload_getfnc_gather_random): Ditto.
* rndlinux.c (gather_random): Ditto.
* rndunix.c (gather_random): Ditto.
Sat Dec 12 18:40:32 CET 1998 Werner Koch <wk@isil.d.shuttle.de>
* dynload.c (SYMBOL_VERSION): New to cope with system which needs
underscores.
* rndunix.c: Rewrote large parts
Thu Dec 10 20:15:36 CET 1998 Werner Koch <wk@isil.d.shuttle.de>
* dynload.c (load_extension): increased needed verbosity level.
* random.c (fast_random_poll): Fallback to a default fast random
poll function.
(read_random_source): Always use the faked entroy gatherer if no
gather module is available.
* rndlinux.c (fast_poll): Removed.
* rndunix.c (fast_poll): Removed.
Wed Nov 25 12:33:41 1998 Werner Koch (wk@isil.d.shuttle.de)
* rand-*.c: Removed.
* rndlinux.c : New.
* rndunix.c : New.
* random.c : Restructured the interface to the gather modules.
(intialize): Call constructor functions
(read_radnom_source): Moved to here.
* dynload.c (dynload_getfnc_gather_random): New.
(dynload_getfnc_fast_random_poll): New.
(register_internal_cipher_extension): New.
(register_cipher_extension): Support of internal modules.
Sun Nov 8 17:44:36 1998 Werner Koch (wk@isil.d.shuttle.de)
* rand-unix.c (read_random_source): Removed the assert.
Mon Oct 19 18:34:30 1998 me,,, (wk@tobold)
* pubkey.c: Hack to allow us to give some info about RSA keys back.
Thu Oct 15 11:47:57 1998 Werner Koch (wk@isil.d.shuttle.de)
* dynload.c: Support for DLD
Wed Oct 14 12:13:07 1998 Werner Koch (wk@isil.d.shuttle.de)
* rand-unix.c: Now uses names from configure for /dev/random.
1998-10-10 SL Baur <steve@altair.xemacs.org>
* Makefile.am: fix sed -O substitutions to catch -O6, etc.
Tue Oct 6 10:06:32 1998 Werner Koch (wk@isil.d.shuttle.de)
* rand-unix.c (HAVE_GETTIMEOFDAY): Fixed (was ..GETTIMEOFTIME :-)
* rand-dummy.c (HAVE_GETTIMEOFDAY): Ditto.
Mon Sep 28 13:23:09 1998 Werner Koch (wk@isil.d.shuttle.de)
* md.c (md_digest): New.
(md_reset): New.
Wed Sep 23 12:27:02 1998 Werner Koch (wk@isil.d.shuttle.de)
* tiger.c (TIGER_CONTEXT): moved "buf", so that it is 64 bit aligned.
Mon Sep 21 06:22:53 1998 Werner Koch (wk@(none))
* des.c: Some patches from Michael.
Thu Sep 17 19:00:06 1998 Werner Koch (wk@(none))
* des.c : New file from Michael Roth <mroth@nessie.de>
Mon Sep 14 11:10:55 1998 Werner Koch (wk@(none))
* blowfish.c (bf_setkey): Niklas Hernaeus patch to detect weak keys.
Mon Sep 14 09:19:25 1998 Werner Koch (wk@(none))
* dynload.c (RTLD_NOW): Now defined to 1 if it is undefined.
Mon Sep 7 17:04:33 1998 Werner Koch (wk@(none))
* Makefile.am: Fixes to allow a different build directory
Thu Aug 6 17:25:38 1998 Werner Koch,mobil,,, (wk@tobold)
* random.c (get_random_byte): Removed and changed all callers
to use get_random_bits()
Mon Jul 27 10:30:22 1998 Werner Koch (wk@(none))
* cipher.c : Support for other blocksizes
(cipher_get_blocksize): New.
* twofish.c: New.
* Makefile.am: Add twofish module.
Mon Jul 13 21:30:52 1998 Werner Koch (wk@isil.d.shuttle.de)
* random.c (read_pool): Simple alloc if secure_alloc is not set.
(get_random_bits): Ditto.
Thu Jul 9 13:01:14 1998 Werner Koch (wk@isil.d.shuttle.de)
* dynload.c (load_extension): Function now nbails out if
the program is run setuid.
Wed Jul 8 18:58:23 1998 Werner Koch (wk@isil.d.shuttle.de)
* rmd160.c (rmd160_hash_buffer): New.
Thu Jul 2 10:50:30 1998 Werner Koch (wk@isil.d.shuttle.de)
* cipher.c (cipher_open): algos >=100 use standard CFB
Thu Jun 25 11:18:25 1998 Werner Koch (wk@isil.d.shuttle.de)
* Makefile.am: Support for extensions
Thu Jun 18 12:09:38 1998 Werner Koch (wk@isil.d.shuttle.de)
* random.c (mix_pool): simpler handling for level 0
Mon Jun 15 14:40:48 1998 Werner Koch (wk@isil.d.shuttle.de)
* tiger.c: Removed from dist, will reappear as dynload module
Sat Jun 13 14:16:57 1998 Werner Koch (wk@isil.d.shuttle.de)
* pubkey.c: Major changes to allow extensions. Changed the inteface
of all public key ciphers and added the ability to load extensions
on demand.
* misc.c: Removed.
Wed Jun 10 07:52:08 1998 Werner Koch,mobil,,, (wk@tobold)
* dynload.c: New.
* cipher.c: Major changes to allow extensions.
Mon Jun 8 22:43:00 1998 Werner Koch (wk@isil.d.shuttle.de)
* cipher.c: Major internal chnages to support extensions.
* blowfish.c (blowfish_get_info): New and made all internal
functions static, changed heder.
* cast5.c (cast5_get_info): Likewise.
Mon Jun 8 12:27:52 1998 Werner Koch (wk@isil.d.shuttle.de)
* tiger.c (transform): Fix for big endian
* cipher.c (do_cfb_decrypt): Big endian fix.
Fri May 22 07:30:39 1998 Werner Koch (wk@isil.d.shuttle.de)
* md.c (md_get_oid): Add a new one for TIGER.
Thu May 21 13:24:52 1998 Werner Koch (wk@isil.d.shuttle.de)
* cipher.c: Add support for a dummy cipher
Thu May 14 15:40:36 1998 Werner Koch (wk@isil.d.shuttle.de)
* rmd160.c (transform): fixed sigbus - I should better
add Christian von Roques's new implemenation of rmd160_write.
Fri May 8 18:07:44 1998 Werner Koch (wk@isil.d.shuttle.de)
* rand-internal.h, rand-unix.c, rand-w32.c, rand_dummy.c: New
* random.c: Moved system specific functions to rand-****.c
Fri May 8 14:01:17 1998 Werner Koch (wk@isil.d.shuttle.de)
* random.c (fast_random_poll): add call to gethrtime.
Tue May 5 21:28:55 1998 Werner Koch (wk@isil.d.shuttle.de)
* elgamal.c (elg_generate): choosing x was not correct, could
yield 6 bytes which are not from the random pool, tsss, tsss..
Tue May 5 14:09:06 1998 Werner Koch (wk@isil.d.shuttle.de)
* primegen.c (generate_elg_prime): Add arg mode, changed all
callers and implemented mode 1.
Mon Apr 27 14:41:58 1998 Werner Koch (wk@isil.d.shuttle.de)
* cipher.c (cipher_get_keylen): New.
Sun Apr 26 14:44:52 1998 Werner Koch (wk@isil.d.shuttle.de)
* tiger.c, tiger.h: New.
Wed Apr 8 14:57:11 1998 Werner Koch (wk@isil.d.shuttle.de)
* misc.c (check_pubkey_algo2): New.
Tue Apr 7 18:46:49 1998 Werner Koch (wk@isil.d.shuttle.de)
* cipher.c: New
* misc.c (check_cipher_algo): Moved to cipher.c
* cast5.c: Moved many functions to cipher.c
* blowfish.c: Likewise.
Sat Apr 4 19:52:08 1998 Werner Koch (wk@isil.d.shuttle.de)
* cast5.c: Implemented and tested.
Wed Apr 1 16:38:27 1998 Werner Koch (wk@isil.d.shuttle.de)
* elgamal.c (elg_generate): Faster generation of x in some cases.
Thu Mar 19 13:54:48 1998 Werner Koch (wk@isil.d.shuttle.de)
* blowfish.c (blowfish_decode_cfb): changed XOR operation
(blowfish_encode_cfb): Ditto.
Thu Mar 12 14:04:05 1998 Werner Koch (wk@isil.d.shuttle.de)
* sha1.c (transform): Rewrote
* blowfish.c (encrypt): Unrolled for rounds == 16
(decrypt): Ditto.
Tue Mar 10 16:32:08 1998 Werner Koch (wk@isil.d.shuttle.de)
* rmd160.c (transform): Unrolled the loop.
Tue Mar 10 13:05:14 1998 Werner Koch (wk@isil.d.shuttle.de)
* random.c (read_pool): Add pool_balance stuff.
(get_random_bits): New.
* elgamal.c (elg_generate): Now uses get_random_bits to generate x.
Tue Mar 10 11:33:51 1998 Werner Koch (wk@isil.d.shuttle.de)
* md.c (md_digest_length): New.
Tue Mar 10 11:27:41 1998 Werner Koch (wk@isil.d.shuttle.de)
* dsa.c (dsa_verify): Works.
Mon Mar 9 12:59:08 1998 Werner Koch (wk@isil.d.shuttle.de)
* dsa.c, dsa.h: Removed some unused code.
Wed Mar 4 10:39:22 1998 Werner Koch (wk@isil.d.shuttle.de)
* md.c (md_open): Add call to fast_random_poll.
blowfish.c (blowfish_setkey): Ditto.
Tue Mar 3 13:32:54 1998 Werner Koch (wk@isil.d.shuttle.de)
* rmd160.c (rmd160_mixblock): New.
* random.c: Restructured to start with a new RNG implementation.
* random.h: New.
Mon Mar 2 19:21:46 1998 Werner Koch (wk@isil.d.shuttle.de)
* gost.c, gost.h: Removed because they did only conatin trash.
Sun Mar 1 16:42:29 1998 Werner Koch (wk@isil.d.shuttle.de)
* random.c (fill_buffer): removed error message if n == -1.
Fri Feb 27 16:39:34 1998 Werner Koch (wk@isil.d.shuttle.de)
* md.c (md_enable): No init if called twice.
Thu Feb 26 07:57:02 1998 Werner Koch (wk@isil.d.shuttle.de)
* primegen.c (generate_elg_prime): Changed the progress printing.
(gen_prime): Ditto.
Tue Feb 24 12:28:42 1998 Werner Koch (wk@isil.d.shuttle.de)
* md5.c, md.5 : Replaced by a modified version of md5.c from
GNU textutils 1.22.
Wed Feb 18 14:08:30 1998 Werner Koch (wk@isil.d.shuttle.de)
* md.c, md.h : New debugging support
Mon Feb 16 10:08:47 1998 Werner Koch (wk@isil.d.shuttle.de)
* misc.c (cipher_algo_to_string): New
(pubkey_algo_to_string): New.
(digest_algo_to_string): New.
diff --git a/scripts/ChangeLog b/scripts/ChangeLog
index 14765db2..6f73e8cc 100644
--- a/scripts/ChangeLog
+++ b/scripts/ChangeLog
@@ -1,70 +1,75 @@
+Mon Jul 12 14:55:34 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+
+ * autogen.sh: Run libtoolize
+
Sat May 22 22:47:26 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
* autogen.sh: Fixed the error message for a missing libtool.
Sat May 8 19:28:08 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
* mkinstalldirs, install-sh: New from GNU repository
* config.sub, config.guess: Merged with rep version.
Sun Mar 14 19:34:36 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
* autogen.sh: Add a check for libtool because some autoconf macros
are needed.
Mon Feb 22 20:04:00 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
* autogen.sh: Enhanced the version testing code (Philippe Laliberte)
* mkwebpage: Edits the buglist.
Sat Feb 13 12:04:43 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
* autogen.sh: Now uses gettextize
Wed Feb 10 17:15:39 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
* config.sub, config.guess: Support i386-emx-os2
Sun Jan 17 11:04:33 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
* autogen.sh: Now checks for installed gettext
Sat Jan 16 09:27:30 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
* config.guess (m68k-atari-mint): New.
* config.sub: Add support for atarist-MiNT
Wed Jan 13 12:49:36 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
* gnupg.spec.in: New
* gnupg.spec: Removed
Wed Dec 23 13:18:14 CET 1998 Werner Koch <wk@isil.d.shuttle.de>
* gnupg.spec: Updated version by Fabio Coatti
Thu Dec 17 18:31:15 CET 1998 Werner Koch <wk@isil.d.shuttle.de>
* gnupg.spec: New version by Reuben Sumner and did some more
changes.
Fri Nov 27 12:39:29 CET 1998 Werner Koch <wk@isil.d.shuttle.de>
* commit: New
Fri Nov 20 12:01:57 1998 Werner Koch (wk@isil.d.shuttle.de)
* mkdiff: signs the patch file
Sat Oct 17 16:10:16 1998 Werner Koch (wk@isil.d.shuttle.de)
* autogen.sh: New.
Wed Oct 14 09:55:25 1998 Werner Koch (wk@isil.d.shuttle.de)
* config.guess (FreeBSD): Changes from Jun Kuriyama to support ELF
* config.sub: (freebsd): Add to maybe_os
diff --git a/scripts/autogen.sh b/scripts/autogen.sh
index 045716b8..23cb5bd0 100755
--- a/scripts/autogen.sh
+++ b/scripts/autogen.sh
@@ -1,102 +1,104 @@
#!/bin/sh
# Run this to generate all the initial makefiles, etc.
PGM=GnuPG
DIE=no
autoconf_vers=2.13
automake_vers=1.4
aclocal_vers=1.4
libtool_vers=1.3
if (autoconf --version) < /dev/null > /dev/null 2>&1 ; then
if (autoconf --version | awk 'NR==1 { if( $3 >= '$autoconf_vers') \
exit 1; exit 0; }');
then
echo "**Error**: "\`autoconf\'" is too old."
echo ' (version ' $autoconf_vers ' or newer is required)'
DIE="yes"
fi
else
echo
echo "**Error**: You must have "\`autoconf\'" installed to compile $PGM."
echo ' (version ' $autoconf_vers ' or newer is required)'
DIE="yes"
fi
if (automake --version) < /dev/null > /dev/null 2>&1 ; then
if (automake --version | awk 'NR==1 { if( $4 >= '$automake_vers') \
exit 1; exit 0; }');
then
echo "**Error**: "\`automake\'" is too old."
echo ' (version ' $automake_vers ' or newer is required)'
DIE="yes"
fi
if (aclocal --version) < /dev/null > /dev/null 2>&1; then
if (aclocal --version | awk 'NR==1 { if( $4 >= '$aclocal_vers' ) \
exit 1; exit 0; }' );
then
echo "**Error**: "\`aclocal\'" is too old."
echo ' (version ' $aclocal_vers ' or newer is required)'
DIE="yes"
fi
else
echo
echo "**Error**: Missing "\`aclocal\'". The version of "\`automake\'
echo " installed doesn't appear recent enough."
DIE="yes"
fi
else
echo
echo "**Error**: You must have "\`automake\'" installed to compile $PGM."
echo ' (version ' $automake_vers ' or newer is required)'
DIE="yes"
fi
if (gettext --version </dev/null 2>/dev/null | awk 'NR==1 { split($4,A,"\."); \
X=10000*A[1]+100*A[2]+A[3]; echo X; if( X >= 1035 ) exit 1; exit 0}')
then
echo "**Error**: You must have "\`gettext\'" installed to compile $PGM."
echo ' (version 0.10.35 or newer is required; get'
echo ' ftp://alpha.gnu.org/gnu/gettext-0.10.35.tar.gz'
echo ' or install the latest Debian package)'
DIE="yes"
fi
if (libtool --version) < /dev/null > /dev/null 2>&1 ; then
if (libtool --version | awk 'NR==1 { if( $4 >= '$libtool_vers') \
exit 1; exit 0; }');
then
echo "**Error**: "\`libtool\'" is too old."
echo ' (version ' $libtool_vers ' or newer is required)'
DIE="yes"
fi
else
echo
echo "**Error**: You must have "\`libtool\'" installed to compile $PGM."
echo ' (version ' $libtool_vers ' or newer is required)'
DIE="yes"
fi
if test "$DIE" = "yes"; then
exit 1
fi
echo "Running gettextize... Ignore non-fatal messages."
echo "no" | gettextize --force
+echo "Running libtoolize... Ignore non-fatal messages."
+echo "no" | libtoolize
echo "Running aclocal..."
aclocal
echo "Running autoheader..."
autoheader
echo "Running automake --gnu ..."
automake --gnu;
echo "Running autoconf..."
autoconf
echo "You can now run \"./configure\" and then \"make\"."
diff --git a/src/sexp.c b/src/sexp.c
index d95807ce..c9dfdd00 100644
--- a/src/sexp.c
+++ b/src/sexp.c
@@ -1,497 +1,595 @@
-/* sexp.c - S-Expression handling
+/* sexp.c - Sex^H^H-Expression handling
* Copyright (C) 1999 Free Software Foundation, Inc.
*
* This file is part of GnuPG.
*
* GnuPG 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 2 of the License, or
* (at your option) any later version.
*
* GnuPG 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
/****************
* TODO:
* - implement reference counting to defere freeing of
* data and make copies of the data on demand.
* --> do we really need this?
*
*/
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <ctype.h>
#include <assert.h>
#define GCRYPT_NO_MPI_MACROS 1
#include "g10lib.h"
#include "util.h"
#include "memory.h"
/* FIXME: We should really have the m_lib functions to allow
* overriding of the default malloc functions
* For now use this kludge: */
#define m_lib_alloc m_alloc
#define m_lib_alloc_clear m_alloc_clear
#define m_lib_free m_free
#if 0
struct sexp_node;
typedef struct sexp_node *NODE;
struct gcry_sexp {
int orig_format; /* format which we used to create this object */
NODE sexp; /* a NULL indicates an empty list */
};
#else
typedef struct gcry_sexp *NODE;
#endif
enum node_types { ntLIST, ntDATA, ntMPI };
struct gcry_sexp {
NODE next;
NODE up; /* helper needed for faster traversal */
enum node_types type;
union {
NODE list;
GCRY_MPI mpi;
struct {
size_t len;
byte d[1];
} data;
} u;
};
static void
dump_mpi( GCRY_MPI a )
{
char buffer[1000];
size_t n = 1000;
if( gcry_mpi_print( GCRYMPI_FMT_HEX, buffer, &n, a ) )
fputs("[MPI too large to print]", stderr );
else
fputs( buffer, stderr );
}
static void
do_dump_list( NODE node, int indent )
{
for( ; node; node = node->next ) {
switch( node->type ) {
case ntLIST:
if( indent )
putc('\n', stderr);
fprintf(stderr, "%*s(", indent, "");
do_dump_list( node->u.list, indent+1 );
putc(')', stderr);
break;
case ntDATA:
if( !node->u.data.len )
fputs("EMPTY", stderr );
else
print_string(stderr, node->u.data.d, node->u.data.len, ')');
putc(' ', stderr);
break;
case ntMPI:
dump_mpi( node->u.mpi );
putc(' ', stderr);
break;
}
if( !indent )
putc('\n', stderr);
}
}
static void
dump_sexp( NODE node )
{
do_dump_list( node, 0 );
}
/****************
* Create a new SEXP element (data)
*/
GCRY_SEXP
gcry_sexp_new( const char *buffer, size_t length )
{
NODE node;
node = m_alloc_clear( sizeof *node + length );
node->type = ntDATA;
node->u.data.len = length;
memcpy(node->u.data.d, buffer, length );
return node;
}
/****************
* Release resource of the given SEXP object.
*/
void
gcry_sexp_release( GCRY_SEXP sexp )
{
}
/****************
* Make a pair from items a and b
*/
GCRY_SEXP
gcry_sexp_cons( GCRY_SEXP a, GCRY_SEXP b )
{
NODE head;
head = m_alloc_clear( sizeof *head );
head->type = ntLIST;
head->u.list = a;
a->up = head;
a->next = b;
b->up = head;
return head;
}
/****************
* Make a list from all items, the end of list is indicated by a NULL
*/
GCRY_SEXP
gcry_sexp_vlist( GCRY_SEXP a, ... )
{
NODE head, tail, node;
va_list arg_ptr ;
head = m_alloc_clear( sizeof *node );
head->type = ntLIST;
head->u.list = a;
a->up = head;
tail = a;
va_start( arg_ptr, a ) ;
while( (node = va_arg( arg_ptr, NODE )) ) {
tail->next = node;
node->up = head;
tail = node;
}
va_end( arg_ptr );
return head;
}
+/****************
+ * Locate data in a list. Data must be the first item in the list.
+ * Returns: The sublist with that Data (don't modify it!)
+ */
+GCRY_SEXP
+gcry_sexp_find_token( GCRY_SEXP list, const char *tok, size_t toklen )
+{
+ NODE node;
+ for( node=list ; node; node = node->next )
+ {
+ switch( node->type ) {
+ case ntLIST: {
+ NODE n = gcry_sexp_find_token( node->u.list, tok, toklen );
+ if( n )
+ return n;
+ }
+ break;
+ case ntDATA:
+ if( node == list
+ && node->u.data.len == toklen
+ && !memcmp( node->u.data.d, tok, toklen ) )
+ {
+ return node;
+ }
+ break;
+ case ntMPI:
+ break;
+ }
+ }
+ return NULL;
+}
+/****************
+ * Enumerate all objects in the list. Ther firts time you call this, pass
+ * the address of a void pointer initialized to NULL. Then don't touch this
+ * variable anymore but pass it verbatim to the function; you will get
+ * all lists back in turn. End of lists is indicated by a returned NIL in
+ * whic case you should not continue to use this function
+ * (it would wrap around). If you decide to cancel the operation before
+ * the final NIL you vae to release the context by calling the function
+ * with a the context but a LIST set to NULL.
+ * Note that this function returns only lists and not single objects.
+ */
+GCRY_SEXP
+gcry_sexp_enum_lists( GCRY_SEXP list, void **context )
+{
+ NODE node;
+
+ if( !list ) {
+ /* we are lucky that we can hold all information in the pointer
+ * value ;-) - so there is no need to release any memory */
+ *context = NULL;
+ return NULL;
+ }
+ if( !*context ) /* start enumeration */
+ node = list;
+ else
+ node = *context;
+
+
+ for( ; node; node = node->next ) {
+ if( node->type == ntLIST ) {
+ node = node->u.list;
+ *context = node; /* store our context */
+ return node;
+ }
+ }
+ /* release resources and return nil */
+ return gcry_sexp_enum_lists( NULL, context );
+}
+
+
+/****************
+ * cdr the mpi from the list or NULL if there is no MPI.
+ * This function tries to convert plain data to an MPI.
+ */
+MPI
+gcry_sexp_cdr_mpi( GCRY_SEXP list )
+{
+
+}
/****************
* Scan the provided buffer and return the S expression in our internal
* format. Returns a newly allocated expression. If erroff is not NULL and
* a parsing error has occured, the offset into buffer will be returned.
*/
int
gcry_sexp_sscan( GCRY_SEXP *retsexp, const char *buffer,
size_t length, size_t *erroff )
{
static const char tokenchars[] = "abcdefghijklmnopqrstuvwxyz"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"0123456789-./_:*+=";
const char *p;
size_t n;
NODE head, tail, node;
const char *digptr=NULL;
const char *quoted=NULL;
const char *tokenp=NULL;
const char *hexfmt=NULL;
const char *base64=NULL;
const char *disphint=NULL;
int quoted_esc=0;
int datalen=0;
int first;
tail = head = NULL;
first = 0;
for(p=buffer,n=length; n; p++, n-- ) {
if( tokenp ) {
if( strchr( tokenchars, *p ) )
continue;
}
if( quoted ) {
if( quoted_esc ) {
switch( *p ) {
case 'b': case 't': case 'v': case 'n': case 'f':
case 'r': case '"': case '\'': case '\\':
quoted_esc = 0;
break;
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7':
if( !(n > 2 && p[1] >= '0' && p[1] <= '7'
&& p[2] >= '0' && p[2] <= '7') ) {
*erroff = p - buffer;
return -6; /* invalid octal value */
}
p += 2; n -= 2;
quoted_esc = 0;
break;
case 'x':
if( !(n > 2 && isxdigit(p[1]) && isxdigit(p[2]) ) ) {
*erroff = p - buffer;
return -6; /* invalid hex value */
}
p += 2; n -= 2;
quoted_esc = 0;
break;
case '\r': /* ignore CR[,LF] */
if( n && p[1] == '\n' ) {
p++; n--;
}
quoted_esc = 0;
break;
case '\n': /* ignore LF[,CR] */
if( n && p[1] == '\r' ) {
p++; n--;
}
quoted_esc = 0;
break;
default:
*erroff = p - buffer;
return -6; /* invalid quoted string escape */
}
}
else if( *p == '\\' )
quoted_esc = 1;
else if( *p == '\"' ) {
/* fixme: add item */
quoted = NULL;
}
}
else if( hexfmt ) {
if( *p == '#' )
hexfmt = NULL;
}
else if( base64 ) {
if( *p == '|' )
base64 = NULL;
}
else if( digptr ) {
if( isdigit(*p) )
;
else if( *p == ':' ) {
if( !head ) {
*erroff = 0;
return -4; /* not a list */
}
datalen = atoi( digptr ); /* fixme: check for overflow */
digptr = NULL;
if( datalen > n-1 ) {
*erroff = p - buffer;
return -2; /* buffer too short */
}
/* make a new list entry */
node = m_alloc_clear( sizeof *node + datalen );
if( first ) { /* stuff it into the first node */
first = 0;
node->up = tail;
tail->u.list = node;
}
else {
node->up = tail->up;
tail->next = node;
}
tail = node;
/* and fill in the value (we store the value in the node)*/
node->type = ntDATA;
node->u.data.len = datalen;
memcpy(node->u.data.d, p+1, datalen );
n -= datalen;
p += datalen;
}
else if( *p == '\"' ) {
digptr = NULL; /* we ignore the optional length */
quoted = p;
quoted_esc = 0;
}
else if( *p == '#' ) {
digptr = NULL; /* we ignore the optional length */
hexfmt = p;
}
else if( *p == '|' ) {
digptr = NULL; /* we ignore the optional length */
base64 = p;
}
else {
*erroff = p - buffer;
return -1;
}
}
else if( *p == '(' ) {
if( disphint ) {
*erroff = p - buffer;
return -9; /* open display hint */
}
node = m_alloc_clear( sizeof *node );
if( !head )
head = node;
else {
node->up = tail->up;
tail->next = node;
}
node->type = ntLIST;
tail = node;
first = 1;
}
else if( *p == ')' ) { /* walk up */
if( disphint ) {
*erroff = p - buffer;
return -9; /* open display hint */
}
if( !head ) {
*erroff = 0;
return -4; /* not a list */
}
tail = tail->up;
if( !tail ) {
*erroff = p - buffer;
return -3;
}
}
else if( *p == '\"' ) {
quoted = p;
quoted_esc = 0;
}
else if( *p == '#' )
hexfmt = p;
else if( *p == '|' )
base64 = p;
else if( *p == '[' ) {
if( disphint ) {
*erroff = p - buffer;
return -8; /* nested display hints */
}
disphint = p;
}
else if( *p == ']' ) {
if( !disphint ) {
*erroff = p - buffer;
return -9; /* unmatched display hint close */
}
disphint = NULL;
}
else if( isdigit(*p) ) {
if( *p == '0' ) { /* a length may not begin with zero */
*erroff = p - buffer;
return -7;
}
digptr = p;
}
else if( strchr( tokenchars, *p ) )
tokenp = p;
else if( isspace(*p) )
;
else if( *p == '{' ) {
/* fixme: handle rescanning:
* we can do this by saving our current state
* and start over at p+1 -- Hmmm. At this point here
* we are in a well defined state, so we donエ need to save
* it. Great.
*/
*erroff = p - buffer;
return -10; /* unexpected reserved punctuation */
}
else if( strchr( "&\\", *p ) ) { /*reserved punctuation*/
*erroff = p - buffer;
return -10; /* unexpected reserved punctuation */
}
else { /* bad or unavailable*/
*erroff = p - buffer;
return -5;
}
}
dump_sexp( head );
return 0;
}
/****************
* Print SEXP to buffer using the MODE. Returns the length of the
* SEXP in buffer or 0 if the buffer is too short (We have at least an
* empty list consisting of 2 bytes). If a buffer of NULL is provided,
* the required length is returned.
*/
size_t
gcry_sexp_sprint( GCRY_SEXP sexp, int mode, char *buffer, size_t maxlength )
{
return 0;
}
/***********************************************************/
const char *
strusage( int level )
{
return default_strusage(level);
}
int
main(int argc, char **argv)
{
char buffer[5000];
size_t erroff;
int rc, n;
FILE *fp;
GCRY_SEXP s_pk, s_dsa, s_p, s_q, s_g, sexp;
+ #if 0
if( argc > 1 ) {
fp = fopen( argv[1], "r" );
if( !fp )
exit(1);
n = fread(buffer, 1, 5000, fp );
fprintf(stderr,"read %d bytes\n", n );
rc = gcry_sexp_sscan( NULL, buffer, n, &erroff );
fprintf(stderr, "read: rc=%d erroff=%u\n", rc, erroff );
}
+ #endif
s_pk = SEXP_NEW( "public-key", 10 );
fputs("pk:\n",stderr);dump_sexp( s_pk );
s_dsa = SEXP_NEW( "dsa", 3 );
s_p = SEXP_CONS( SEXP_NEW( "p", 1 ), SEXP_NEW( "PPPPPP", 6 ) );
fputs("p:\n",stderr);dump_sexp( s_p );
s_q = SEXP_CONS( SEXP_NEW( "q", 1 ), SEXP_NEW( "QQQ", 3 ) );
s_g = SEXP_CONS( SEXP_NEW( "g", 1 ), SEXP_NEW( "GGGGGG", 6 ) );
sexp = SEXP_CONS( s_pk, gcry_sexp_vlist( s_dsa,
s_p,
s_q,
s_g,
NULL ));
fputs("all:\n",stderr);dump_sexp( sexp );
+ /* now find something */
+ if( argc > 1 )
+ {
+ GCRY_SEXP s1;
+
+ s1 = gcry_sexp_find_token( sexp, argv[1], strlen(argv[1]) );
+ if( !s1 )
+ {
+ fprintf(stderr, "didn't found `%s'\n", argv[1] );
+ }
+ else
+ {
+ fprintf(stderr, "found `%s':\n", argv[1] );
+ dump_sexp( s1 );
+ }
+ }
return 0;
}

File Metadata

Mime Type
text/x-diff
Expires
Fri, Feb 6, 8:09 AM (1 h, 14 m)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
21/f9/2db76c05ece8b3659c83418e0b15

Event Timeline