summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>1997-12-23 18:30:18 +0100
committerWerner Koch <wk@gnupg.org>1997-12-23 18:30:18 +0100
commitc351df1dc5294dfd81619fea3c1ff6a7e25ba774 (patch)
treeb0fa86a4d1455e53c3a51d696eac51abe0308b0d
parentNow created by config.links (diff)
downloadgnupg2-c351df1dc5294dfd81619fea3c1ff6a7e25ba774.tar.xz
gnupg2-c351df1dc5294dfd81619fea3c1ff6a7e25ba774.zip
changed configuration stuff, replaced some Makefile.am by distfiles.
-rw-r--r--Makefile.am11
-rw-r--r--Makefile.in13
-rw-r--r--acconfig.h17
-rw-r--r--cipher/Makefile.am2
-rw-r--r--cipher/Makefile.in3
-rw-r--r--config.h.in20
-rw-r--r--configure.in106
-rw-r--r--g10/Makefile.am1
-rw-r--r--g10/Makefile.in10
-rw-r--r--g10/compress.c2
-rw-r--r--g10/encode.c4
-rw-r--r--g10/filter.h15
-rw-r--r--g10/g10.c5
-rw-r--r--g10/keygen.c36
-rw-r--r--g10/main.h3
-rw-r--r--g10/mainproc.c21
-rw-r--r--g10/openfile.c33
-rw-r--r--g10/options.h2
-rw-r--r--g10/packet.h2
-rw-r--r--g10/plaintext.c42
-rw-r--r--g10/textfilter.c106
-rw-r--r--include/Makefile.am5
-rw-r--r--include/distfiles8
-rw-r--r--include/mpi.h12
-rw-r--r--include/types.h13
-rw-r--r--include/util.h1
-rw-r--r--mpi/Makefile.am3
-rw-r--r--mpi/Makefile.in112
-rw-r--r--mpi/alpha/distfiles3
-rw-r--r--mpi/alpha/udiv-qrnnd.S161
-rw-r--r--mpi/config.links68
-rw-r--r--mpi/generic/distfiles7
-rw-r--r--mpi/hppa/distfiles4
-rw-r--r--mpi/hppa/mpih-add1.S70
-rw-r--r--mpi/hppa/udiv-qrnnd.S297
-rw-r--r--mpi/i386/distfiles8
-rw-r--r--mpi/mpi-inline.h1
-rw-r--r--mpi/mpi-internal.h18
-rw-r--r--mpi/mpi-pow.c21
-rw-r--r--mpi/mpih-mul.c27
-rw-r--r--scripts/distfiles4
-rw-r--r--util/iobuf.c14
42 files changed, 1091 insertions, 220 deletions
diff --git a/Makefile.am b/Makefile.am
index 11d469c7e..4a2c3a20f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,6 +1,6 @@
## Process this file with automake to produce Makefile.in
-SUBDIRS = scripts include util mpi cipher tools g10
+SUBDIRS = util mpi cipher tools g10
EXTRA_DIST =
@@ -9,4 +9,13 @@ tar: clean
cd ..; tar czvf ~/bkup/g10-`date +%d%m`.tar.gz src
+dist-hook:
+ @set -e; \
+ for file in `find $(srcdir) -type f -name distfiles`; do \
+ dir=`dirname $$file` ; $(mkinstalldirs) $(distdir)/$$dir ; \
+ for i in distfiles `cat $$file` ; do \
+ ln $(srcdir)/$$dir/$$i $(distdir)/$$dir/$$i 2> /dev/null \
+ || cp -p $(srcdir)/$$dir/$$i $(distdir)/$$dir/$$i; \
+ done ; \
+ done
diff --git a/Makefile.in b/Makefile.in
index 8c81c6e11..61e204f85 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -38,7 +38,7 @@ INSTALL_DATA = @INSTALL_DATA@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
transform = @program_transform_name@
-SUBDIRS = scripts include util mpi cipher tools g10
+SUBDIRS = util mpi cipher tools g10
EXTRA_DIST =
ACCONFIG = acconfig.h
CONFIG_HEADER_IN = config.h.in
@@ -176,6 +176,7 @@ distdir: $(DEP_DISTFILES)
(cd $$subdir && $(MAKE) distdir=../$(distdir)/$$subdir distdir) \
|| exit 1; \
done
+ $(MAKE) dist-hook
info: info-recursive
dvi: dvi-recursive
@@ -254,6 +255,16 @@ maintainer-clean
tar: clean
cd ..; tar czvf ~/bkup/g10-`date +%d%m`.tar.gz src
+
+dist-hook:
+ @set -e; \
+ for file in `find $(srcdir) -type f -name distfiles`; do \
+ dir=`dirname $$file` ; $(mkinstalldirs) $(distdir)/$$dir ; \
+ for i in distfiles `cat $$file` ; do \
+ ln $(srcdir)/$$dir/$$i $(distdir)/$$dir/$$i 2> /dev/null \
+ || cp -p $(srcdir)/$$dir/$$i $(distdir)/$$dir/$$i; \
+ done ; \
+ done
.SUFFIXES:
# Tell versions [3.59,3.63) of GNU make to not export all variables.
diff --git a/acconfig.h b/acconfig.h
index 334d6ad84..7f4943aa9 100644
--- a/acconfig.h
+++ b/acconfig.h
@@ -26,6 +26,17 @@
#undef M_DEBUG
#undef VERSION
#undef PACKAGE
+
+#undef BIG_ENDIAN_HOST
+#undef LITTLE_ENDIAN_HOST
+
+#undef HAVE_BYTE_TYPEDEF
+#undef HAVE_USHORT_TYPEDEF
+#undef HAVE_ULONG_TYPEDEF
+#undef HAVE_U16_TYPEDEF
+#undef HAVE_U32_TYPEDEF
+
+
/* RSA is only compiled in if you have these files. You can use
* RSA without any restrictions, if your not in the U.S. or
* wait until sep 20, 2000
@@ -35,11 +46,5 @@
@BOTTOM@
-#ifdef WORDS_BIGENDIAN
- #define BIG_ENDIAN_HOST
-#else
- #define LITTLE_ENDIAN_HOST
-#endif
-
#endif /*G10_CONFIG_H*/
diff --git a/cipher/Makefile.am b/cipher/Makefile.am
index 52de7fab5..40b131dd9 100644
--- a/cipher/Makefile.am
+++ b/cipher/Makefile.am
@@ -24,6 +24,6 @@ cipher_SOURCES = blowfish.c \
md.c \
smallprime.c
-##cipher_LIBADD = rsa.o
+cipher_LIBADD = rsa.o
diff --git a/cipher/Makefile.in b/cipher/Makefile.in
index 2747e165f..8391d9e9c 100644
--- a/cipher/Makefile.in
+++ b/cipher/Makefile.in
@@ -60,6 +60,8 @@ cipher_SOURCES = blowfish.c \
dsa.c \
md.c \
smallprime.c
+
+cipher_LIBADD = rsa.o
mkinstalldirs = $(top_srcdir)/scripts/mkinstalldirs
CONFIG_HEADER = ../config.h
LIBRARIES = $(noinst_LIBRARIES)
@@ -78,7 +80,6 @@ LIBS = @LIBS@
COMPILE = $(CC) -c $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)
LINK = $(CC) $(LDFLAGS) -o $@
-cipher_LIBADD =
cipher_OBJECTS = blowfish.o elgamal.o gost.o md5.o primegen.o random.o \
rmd160.o sha1.o dsa.o md.o smallprime.o
EXTRA_cipher_SOURCES =
diff --git a/config.h.in b/config.h.in
index 54a2fcb9c..45f3e5114 100644
--- a/config.h.in
+++ b/config.h.in
@@ -41,13 +41,19 @@
/* Define if you have the ANSI C header files. */
#undef STDC_HEADERS
-/* Define if your processor stores words with the most significant
- byte first (like Motorola and SPARC, unlike Intel and VAX). */
-#undef WORDS_BIGENDIAN
-
#undef M_DEBUG
#undef VERSION
#undef PACKAGE
+
+#undef BIG_ENDIAN_HOST
+#undef LITTLE_ENDIAN_HOST
+
+#undef HAVE_BYTE_TYPEDEF
+#undef HAVE_USHORT_TYPEDEF
+#undef HAVE_ULONG_TYPEDEF
+#undef HAVE_U16_TYPEDEF
+#undef HAVE_U32_TYPEDEF
+
/* RSA is only compiled in if you have these files. You can use
* RSA without any restrictions, if your not in the U.S. or
* wait until sep 20, 2000
@@ -78,11 +84,5 @@
/* Define if you have the <zlib.h> header file. */
#undef HAVE_ZLIB_H
-#ifdef WORDS_BIGENDIAN
- #define BIG_ENDIAN_HOST
-#else
- #define LITTLE_ENDIAN_HOST
-#endif
-
#endif /*G10_CONFIG_H*/
diff --git a/configure.in b/configure.in
index 3b1d5352a..a476acd02 100644
--- a/configure.in
+++ b/configure.in
@@ -7,6 +7,7 @@ AC_INIT(g10/g10.c)
AC_CONFIG_AUX_DIR(scripts)
AC_CONFIG_HEADER(config.h)
+
VERSION=0.0.0
PACKAGE=g10
AC_SUBST(VERSION)
@@ -19,7 +20,26 @@ AC_ARG_ENABLE(m-debug,
if test "$enableval" = y || test "$enableval" = yes; then
AC_DEFINE(M_DEBUG)
fi
-CFLAGS="-g"
+
+dnl some additional macros
+
+dnl WK_CHECK_TYPEDEF(TYPE, HAVE_NAME)
+AC_DEFUN(WK_CHECK_TYPEDEF,
+[AC_MSG_CHECKING(for $1 typedef)
+AC_CACHE_VAL(wk_cv_typedef_$1,
+[AC_TRY_COMPILE([#include <stdlib.h>
+#include <sys/types.h>], [
+#undef $1
+int a = sizeof($1);
+], wk_cv_typedef_$1=yes, wk_cv_typedef_$1=no )])
+AC_MSG_RESULT($wk_cv_typedef_$1)
+if test "$wk_cv_typedef_$1" = yes; then
+ AC_DEFINE($2)
+fi
+])
+
+
+
dnl
AC_CANONICAL_SYSTEM
@@ -46,7 +66,6 @@ AC_PROG_CPP
AC_ARG_PROGRAM
-
dnl Checks for libraries.
dnl Checks for header files.
@@ -63,10 +82,56 @@ AC_C_CONST
AC_C_INLINE
AC_TYPE_SIZE_T
-AC_C_BIGENDIAN
-AC_CHECK_SIZEOF(unsigned short)
-AC_CHECK_SIZEOF(unsigned int)
-AC_CHECK_SIZEOF(unsigned long)
+
+dnl autoconf doesn't support a default value for AC_C_BIGENDIAN
+dnl so here is the modified version
+if test "$cross_compiling" = yes; then
+ AC_MSG_WARN(cross compiling; assuming little endianess)
+fi
+AC_CACHE_CHECK(for little endianess, ac_cv_c_littleendian,
+[ac_cv_c_littleendian=unknown
+# See if sys/param.h defines the BYTE_ORDER macro.
+AC_TRY_COMPILE([#include <sys/types.h>
+#include <sys/param.h>], [
+#if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN
+ bogus endian macros
+#endif], [# It does; now see whether it defined to BIG_ENDIAN or not.
+AC_TRY_COMPILE([#include <sys/types.h>
+#include <sys/param.h>], [
+#if BYTE_ORDER != BIG_ENDIAN
+ not big endian
+#endif], ac_cv_c_littleendian=no, ac_cv_c_littleendian=yes)])
+if test "$ac_cv_c_littleendian" = unknown; then
+AC_TRY_RUN([main () {
+ /* Are we little or big endian? From Harbison&Steele. */
+ union
+ {
+ long l;
+ char c[sizeof (long)];
+ } u;
+ u.l = 1;
+ exit (u.c[sizeof (long) - 1] == 1);
+}], ac_cv_c_littleendian=yes, ac_cv_c_littleendian=no, ac_cv_c_littleendian=yes)
+fi])
+
+if test "$ac_cv_c_littleendian" = yes; then
+ AC_DEFINE(LITTLE_ENDIAN_HOST)
+else
+ AC_DEFINE(BIG_ENDIAN_HOST)
+fi
+
+
+WK_CHECK_TYPEDEF(byte, HAVE_BYTE_TYPEDEF)
+WK_CHECK_TYPEDEF(ushort, HAVE_USHORT_TYPEDEF)
+WK_CHECK_TYPEDEF(ulong, HAVE_ULONG_TYPEDEF)
+WK_CHECK_TYPEDEF(u16, HAVE_U16_TYPEDEF)
+WK_CHECK_TYPEDEF(u32, HAVE_U32_TYPEDEF)
+
+AC_CHECK_SIZEOF(unsigned short, 16)
+AC_CHECK_SIZEOF(unsigned int, 32)
+AC_CHECK_SIZEOF(unsigned long, 32)
+
+
dnl Checks for library functions.
@@ -86,24 +151,21 @@ fi
dnl checking whether we have the RSA source
-dnl fixme: I found no way (aside of using Makefile.am.in)
-dnl to add the requeired source int Makefile.am
-dnl I used: add_cipher_SOURCES="rsa.c rsa.h"
-dnl but of cource it can't work
-AC_MSG_CHECKING(whether we have the rsa source)
-if test -f cipher/rsa.c && test -f cipher/rsa.h; then
+dnl Add stuff to insert this into the makefile
+dnl AC_SUBST(add_cipher_SOURCES)
+AC_CACHE_CHECK(for rsa source, ac_cv_have_rsa_cipher,
+[if test -f cipher/rsa.c && test -f cipher/rsa.h; then
+ ac_cv_have_rsa_cipher=yes; else ac_cv_have_rsa_cipher=no; fi])
+if test $ac_cv_have_rsa_cipher = yes; then
AC_DEFINE(HAVE_RSA_CIPHER)
- AC_MSG_RESULT(yes)
-else
- AC_MSG_RESULT(no)
fi
-AC_SUBST(add_cipher_SOURCES)
-AC_OUTPUT([ Makefile scripts/Makefile util/Makefile mpi/Makefile \
- mpi/generic/Makefile mpi/i386/Makefile \
- cipher/Makefile \
- include/Makefile \
- g10/Makefile tools/Makefile ],
- [echo timestamp > stamp-h ] )
+AC_OUTPUT([ Makefile \
+ util/Makefile \
+ mpi/Makefile \
+ cipher/Makefile \
+ g10/Makefile \
+ tools/Makefile \
+], [echo timestamp > stamp-h ] )
diff --git a/g10/Makefile.am b/g10/Makefile.am
index e13459e97..ee22d2ed9 100644
--- a/g10/Makefile.am
+++ b/g10/Makefile.am
@@ -21,6 +21,7 @@ g10_SOURCES = g10.c \
mainproc.c \
armor.c \
mdfilter.c \
+ textfilter.c \
cipher.c \
options.h \
openfile.c \
diff --git a/g10/Makefile.in b/g10/Makefile.in
index 6ce262c02..b77793783 100644
--- a/g10/Makefile.in
+++ b/g10/Makefile.in
@@ -59,6 +59,7 @@ g10_SOURCES = g10.c \
mainproc.c \
armor.c \
mdfilter.c \
+ textfilter.c \
cipher.c \
options.h \
openfile.c \
@@ -94,9 +95,9 @@ COMPILE = $(CC) -c $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)
LINK = $(CC) $(LDFLAGS) -o $@
g10_OBJECTS = g10.o build-packet.o compress.o encode.o encr-data.o \
free-packet.o getkey.o ringedit.o kbnode.o keygen.o mainproc.o armor.o \
-mdfilter.o cipher.o openfile.o keyid.o parse-packet.o passphrase.o \
-plaintext.o pubkey-enc.o seckey-cert.o seskey.o sign.o comment.o \
-sig-check.o
+mdfilter.o textfilter.o cipher.o openfile.o keyid.o parse-packet.o \
+passphrase.o plaintext.o pubkey-enc.o seckey-cert.o seskey.o sign.o \
+comment.o sig-check.o
EXTRA_g10_SOURCES =
g10_LDADD = $(LDADD)
DIST_COMMON = Makefile.am Makefile.in
@@ -122,7 +123,8 @@ $(srcdir)/.deps/openfile.P $(srcdir)/.deps/parse-packet.P \
$(srcdir)/.deps/passphrase.P $(srcdir)/.deps/plaintext.P \
$(srcdir)/.deps/pubkey-enc.P $(srcdir)/.deps/ringedit.P \
$(srcdir)/.deps/seckey-cert.P $(srcdir)/.deps/seskey.P \
-$(srcdir)/.deps/sig-check.P $(srcdir)/.deps/sign.P
+$(srcdir)/.deps/sig-check.P $(srcdir)/.deps/sign.P \
+$(srcdir)/.deps/textfilter.P
SOURCES = $(g10_SOURCES)
OBJECTS = $(g10_OBJECTS)
diff --git a/g10/compress.c b/g10/compress.c
index 2b10c983b..0502b3637 100644
--- a/g10/compress.c
+++ b/g10/compress.c
@@ -154,7 +154,7 @@ do_uncompress( compress_filter_context_t *zfx, z_stream *zs,
log_debug("inflate returned: avail_in=%u, avail_out=%u, zrc=%d\n",
(unsigned)zs->avail_in, (unsigned)zs->avail_out, zrc);
if( zrc == Z_STREAM_END )
- rc = -1; /* eof */
+ rc = -1; /* eof FIXME: return remaining bytes until EOF */
else if( zrc != Z_OK ) {
if( zs->msg )
log_fatal("zlib inflate problem: %s\n", zs->msg );
diff --git a/g10/encode.c b/g10/encode.c
index 53d03c038..b3d97d8b5 100644
--- a/g10/encode.c
+++ b/g10/encode.c
@@ -97,7 +97,7 @@ encode_simple( const char *filename, int mode )
}
}
- if( !(out = open_outfile( filename )) ) {
+ if( !(out = open_outfile( filename, opt.armor? 1:0 )) ) {
iobuf_close(inp);
m_free(cfx.dek);
return G10ERR_CREATE_FILE; /* or user said: do not overwrite */
@@ -190,7 +190,7 @@ encode_crypt( const char *filename, STRLIST remusr )
else if( opt.verbose )
log_error("reding from '%s'\n", filename? filename: "[stdin]");
- if( !(out = open_outfile( filename )) ) {
+ if( !(out = open_outfile( filename, opt.armor? 1:0 )) ) {
iobuf_close(inp);
free_strlist(local_remusr);
return G10ERR_CREATE_FILE; /* or user said: do not overwrite */
diff --git a/g10/filter.h b/g10/filter.h
index 72029c61f..69f5174d4 100644
--- a/g10/filter.h
+++ b/g10/filter.h
@@ -35,6 +35,10 @@ typedef struct {
byte radbuf[4];
int idx, idx2;
u32 crc;
+ byte helpbuf[100];
+ int helpidx, helplen;
+ int last_c;
+ int fake;
int inp_checked; /* set if inp has been checked */
int inp_bypass; /* set if the input is not armored */
int inp_eof;
@@ -60,6 +64,13 @@ typedef struct {
} cipher_filter_context_t;
+typedef struct {
+ size_t linesize;
+ byte *line;
+ size_t linelen;
+ size_t pos;
+ int eof;
+} text_filter_context_t;
/*-- mdfilter.c --*/
int md_filter( void *opaque, int control, IOBUF a, byte *buf, size_t *ret_len);
@@ -77,6 +88,10 @@ int compress_filter( void *opaque, int control,
int cipher_filter( void *opaque, int control,
IOBUF chain, byte *buf, size_t *ret_len);
+/*-- textfilter.c --*/
+int text_filter( void *opaque, int control,
+ IOBUF chain, byte *buf, size_t *ret_len);
+
#endif /*G10_FILTER_H*/
diff --git a/g10/g10.c b/g10/g10.c
index a8a278997..9a1966d02 100644
--- a/g10/g10.c
+++ b/g10/g10.c
@@ -116,6 +116,7 @@ main( int argc, char **argv )
{ 508, "check-key" ,0, "check signatures on a key in the keyring" },
{ 509, "keyring" ,2, "add this keyring to the list of keyrings" },
{ 's', "sign", 0, "make a signature"},
+ { 't', "textmode", 0, "use canonical text mode"},
{ 'b', "detach-sign", 0, "make a detached signature"},
{ 'e', "encrypt", 0, "encrypt data" },
{ 'd', "decrypt", 0, "decrypt data (default)" },
@@ -140,7 +141,7 @@ main( int argc, char **argv )
IOBUF a;
int rc;
enum { aNull, aSym, aStore, aEncr, aPrimegen, aKeygen, aSign, aSignEncr,
- aTest, aPrintMDs, aSignKey,
+ aTest, aPrintMDs, aSignKey, aClearsig
} action = aNull;
int orig_argc;
char **orig_argv;
@@ -219,6 +220,7 @@ main( int argc, char **argv )
case 'b': detached_sig = 1;
/* fall trough */
case 's': action = action == aEncr? aSignEncr : aSign; break;
+ case 't': action = aClearsig; break;
case 'l': /* store the local users */
sl = m_alloc( sizeof *sl + strlen(pargs.r.ret_str));
strcpy(sl->d, pargs.r.ret_str);
@@ -329,7 +331,6 @@ main( int argc, char **argv )
log_error("sign_file('%s'): %s\n", fname_print, g10_errstr(rc) );
break;
-
case aSignEncr: /* sign and encrypt the given file */
log_fatal("signing and encryption is not yet implemented\n");
usage(1); /* FIXME */
diff --git a/g10/keygen.c b/g10/keygen.c
index 2582f9b47..43924395c 100644
--- a/g10/keygen.c
+++ b/g10/keygen.c
@@ -38,7 +38,9 @@
#define TEST_UID "Karl Test"
#endif
-
+#if defined(HAVE_RSA_CIPHER) && 0
+ #define ENABLE_RSA_KEYGEN 1
+#endif
static u16
@@ -197,7 +199,7 @@ gen_elg(unsigned nbits, KBNODE pub_root, KBNODE sec_root, DEK *dek,
-#ifdef HAVE_RSA_CIPHER
+#ifdef ENABLE_RSA_KEYGEN
static int
gen_rsa(unsigned nbits, IOBUF pub_io, IOBUF sec_io, DEK *dek,
PKT_public_cert **ret_pkc, PKT_secret_cert **ret_skc )
@@ -271,7 +273,7 @@ gen_rsa(unsigned nbits, IOBUF pub_io, IOBUF sec_io, DEK *dek,
free_packet(&pkt2);
return rc;
}
-#endif /*HAVE_RSA_CIPHER*/
+#endif /*ENABLE_RSA_KEYGEN*/
static int
@@ -310,10 +312,10 @@ generate_keypair()
tty_printf("Please select the algorithm to use:\n"
" (1) ElGamal is the suggested one.\n"
- #ifdef HAVE_RSA_CIPHER
- " (2) RSA cannot be used in the U.S.\n"
+ " (2) DSA can only be used for signatures.\n"
+ #ifdef ENABLE_RSA_KEYGEN
+ " (3) RSA cannot be used in the U.S.\n"
#endif
- " (3) DSA can only be used for signatures.\n"
);
#endif
@@ -321,11 +323,11 @@ generate_keypair()
#ifdef TEST_ALGO
algo = TEST_ALGO;
#else
- answer = tty_get("Your selection? (1"
- #ifdef HAVE_RSA_CIPHER
- ",2"
+ answer = tty_get("Your selection? (1,2"
+ #ifdef ENABLE_RSA_KEYGEN
+ ",3"
#endif
- ",3) ");
+ ") ");
tty_kill_prompt();
algo = *answer? atoi(answer): 1;
m_free(answer);
@@ -335,18 +337,18 @@ generate_keypair()
algo_name = "ElGamal";
break;
}
- #ifdef HAVE_RSA_CIPHER
else if( algo == 2 ) {
+ algo = PUBKEY_ALGO_DSA;
+ algo_name = "DSA";
+ tty_printf("Sorry; DSA is not yet supported.\n");
+ }
+ #ifdef ENABLE_RSA_KEYGEN
+ else if( algo == 3 ) {
algo = PUBKEY_ALGO_RSA;
algo_name = "RSA";
break;
}
#endif
- else if( algo == 3 ) {
- algo = PUBKEY_ALGO_DSA;
- algo_name = "DSA";
- tty_printf("Sorry; DSA is not yet supported.\n");
- }
}
@@ -479,7 +481,7 @@ generate_keypair()
if( algo == PUBKEY_ALGO_ELGAMAL )
rc = gen_elg(nbits, pub_root, sec_root, dek, &skc );
- #ifdef HAVE_RSA_CIPHER
+ #ifdef ENABLE_RSA_KEYGEN
else if( algo == PUBKEY_ALGO_RSA )
rc = gen_rsa(nbits, pub_io, sec_io, dek, &skc );
#endif
diff --git a/g10/main.h b/g10/main.h
index 0d769c8b0..a8d28af79 100644
--- a/g10/main.h
+++ b/g10/main.h
@@ -45,7 +45,8 @@ void generate_keypair(void);
/*-- openfile.c --*/
int overwrite_filep( const char *fname );
-IOBUF open_outfile( const char *fname );
+IOBUF open_outfile( const char *fname, int mode );
+IOBUF open_sigfile( const char *iname );
/*-- seskey.c --*/
void make_session_key( DEK *dek );
diff --git a/g10/mainproc.c b/g10/mainproc.c
index 8bee0de09..338ce3d2d 100644
--- a/g10/mainproc.c
+++ b/g10/mainproc.c
@@ -49,6 +49,7 @@ typedef struct {
int opt_list;
KBNODE cert; /* the current certificate */
int have_data;
+ IOBUF iobuf; /* used to get the filename etc. */
} *CTX;
@@ -259,8 +260,11 @@ proc_plaintext( CTX c, PACKET *pkt )
printf("txt: plain text data name='%.*s'\n", pt->namelen, pt->name);
free_md_filter_context( &c->mfx );
- /* fixme: take the digest algo to use from the
- * onepass_sig packet (if we have these) */
+ /* fixme: take the digest algo(s) to use from the
+ * onepass_sig packet (if we have these)
+ * And look at the sigclass to check wether we should use the
+ * textmode filter (sigclass 0x01)
+ */
c->mfx.md = md_open(DIGEST_ALGO_RMD160, 0);
result = handle_plaintext( pt, &c->mfx );
if( !result )
@@ -463,8 +467,9 @@ list_node( CTX c, KBNODE node )
if( !opt.list_sigs )
return;
+ fputs("sig", stdout);
if( opt.check_sigs ) {
-
+ fflush(stdout);
switch( (rc2=do_check_sig( c, node )) ) {
case 0: sigrc = '!'; break;
case G10ERR_BAD_SIGN: sigrc = '-'; break;
@@ -472,7 +477,7 @@ list_node( CTX c, KBNODE node )
default: sigrc = '%'; break;
}
}
- printf("sig%c %08lX %s ",
+ printf("%c %08lX %s ",
sigrc, sig->keyid[1], datestr_from_sig(sig));
if( sigrc == '%' )
printf("[%s] ", g10_errstr(rc2) );
@@ -501,6 +506,7 @@ proc_packets( IOBUF a )
int newpkt;
c->opt_list = 1;
+ c->iobuf = a;
init_packet(pkt);
while( (rc=parse_packet(a, pkt)) != -1 ) {
/* cleanup if we have an illegal data structure */
@@ -511,6 +517,8 @@ proc_packets( IOBUF a )
if( rc ) {
free_packet(pkt);
+ if( rc == G10ERR_INVALID_PACKET )
+ break;
continue;
}
newpkt = -1;
@@ -559,7 +567,7 @@ print_keyid( FILE *fp, u32 *keyid )
}
/****************
- * Preocess the tree which starts at node
+ * Process the tree which starts at node
*/
static void
proc_tree( CTX c, KBNODE node )
@@ -582,7 +590,8 @@ proc_tree( CTX c, KBNODE node )
/* fixme: take the digest algo to use from the
* onepass_sig packet (if we have these) */
c->mfx.md = md_open(DIGEST_ALGO_RMD160, 0);
- rc = ask_for_detached_datafile( &c->mfx );
+ rc = ask_for_detached_datafile( &c->mfx,
+ iobuf_get_fname(c->iobuf));
if( rc ) {
log_error("can't hash datafile: %s\n", g10_errstr(rc));
return;
diff --git a/g10/openfile.c b/g10/openfile.c
index 4b7331dcd..388c9bfa7 100644
--- a/g10/openfile.c
+++ b/g10/openfile.c
@@ -23,6 +23,7 @@
#include <stdlib.h>
#include <string.h>
#include <assert.h>
+#include <errno.h>
#include <unistd.h>
#include "util.h"
#include "memory.h"
@@ -80,9 +81,12 @@ overwrite_filep( const char *fname )
/****************
* Make an output filename for the inputfile INAME.
* Returns an IOBUF
+ * Mode 0 = use ".g10"
+ * 1 = use ".asc"
+ * 2 = use ".sig"
*/
IOBUF
-open_outfile( const char *iname )
+open_outfile( const char *iname, int mode )
{
IOBUF a = NULL;
int rc;
@@ -101,7 +105,8 @@ open_outfile( const char *iname )
name = opt.outfile;
else {
buf = m_alloc(strlen(iname)+4+1);
- strcpy(stpcpy(buf,iname), ".g10");
+ strcpy(stpcpy(buf,iname), mode==1 ? ".asc" :
+ mode==2 ? ".sig" : ".g10");
name = buf;
}
if( !(rc=overwrite_filep( name )) ) {
@@ -117,3 +122,27 @@ open_outfile( const char *iname )
return a;
}
+
+/****************
+ * Try to open a file without the extension ".sig"
+ * Return NULL if such a file is not available.
+ */
+IOBUF
+open_sigfile( const char *iname )
+{
+ IOBUF a = NULL;
+ size_t len;
+
+ if( iname ) {
+ len = strlen(iname);
+ if( len > 4 && !strcmp(iname + len - 4, ".sig") ) {
+ char *buf;
+ buf = m_strdup(iname);
+ buf[len-4] = 0 ;
+ a = iobuf_open( buf );
+ m_free(buf);
+ }
+ }
+ return a;
+}
+
diff --git a/g10/options.h b/g10/options.h
index 8338404ea..c1aea3f95 100644
--- a/g10/options.h
+++ b/g10/options.h
@@ -26,7 +26,7 @@ struct {
int armor;
int compress;
char *outfile;
- int reserved0;
+ int textmode;
int batch; /* run in batch mode */
int answer_yes; /* answer yes on most questions */
int answer_no; /* answer no on most questions */
diff --git a/g10/packet.h b/g10/packet.h
index 609bf8853..f7dbf9734 100644
--- a/g10/packet.h
+++ b/g10/packet.h
@@ -252,7 +252,7 @@ int encrypt_data( PKT_encrypted *ed, DEK *dek );
/*-- plaintext.c --*/
int handle_plaintext( PKT_plaintext *pt, md_filter_context_t *mfx );
-int ask_for_detached_datafile( md_filter_context_t *mfx );
+int ask_for_detached_datafile( md_filter_context_t *mfx, const char *inname );
/*-- comment.c --*/
int write_comment( IOBUF out, const char *s );
diff --git a/g10/plaintext.c b/g10/plaintext.c
index 831a81089..114db1df0 100644
--- a/g10/plaintext.c
+++ b/g10/plaintext.c
@@ -29,6 +29,7 @@
#include "packet.h"
#include "ttyio.h"
#include "filter.h"
+#include "main.h"
/****************
@@ -124,27 +125,42 @@ handle_plaintext( PKT_plaintext *pt, md_filter_context_t *mfx )
/****************
* Ask for the detached datafile and calculate the digest from it.
+ * INFILE is the name of the input file.
*/
int
-ask_for_detached_datafile( md_filter_context_t *mfx )
+ask_for_detached_datafile( md_filter_context_t *mfx, const char *inname )
{
- char *answer;
- FILE *fp;
+ char *answer = NULL;
+ IOBUF fp;
int rc = 0;
int c;
- tty_printf("Detached signature.\n");
- answer = tty_get("Please enter name of data file: ");
- tty_kill_prompt();
-
- fp = fopen(answer,"rb");
+ fp = open_sigfile( inname ); /* open default file */
if( !fp ) {
- log_error("can't open '%s': %s\n", answer, strerror(errno) );
- rc = G10ERR_READ_FILE;
- goto leave;
+ int any=0;
+ tty_printf("Detached signature.\n");
+ do {
+ m_free(answer);
+ answer = tty_get("Please enter name of data file: ");
+ tty_kill_prompt();
+ if( any && !*answer ) {
+ rc = G10ERR_READ_FILE;
+ goto leave;
+ }
+ fp = iobuf_open(answer);
+ if( !fp && errno == ENOENT ) {
+ tty_printf("No such file, try again or hit enter to quit.\n");
+ any++;
+ }
+ else if( !fp ) {
+ log_error("can't open '%s': %s\n", answer, strerror(errno) );
+ rc = G10ERR_READ_FILE;
+ goto leave;
+ }
+ } while( !fp );
}
- while( (c = getc(fp)) != EOF ) {
+ while( (c = iobuf_get(fp)) != -1 ) {
if( mfx->md )
md_putchar(mfx->md, c );
if( mfx->rmd160 )
@@ -152,7 +168,7 @@ ask_for_detached_datafile( md_filter_context_t *mfx )
if( mfx->md5 )
md5_putchar(mfx->md5, c );
}
- fclose(fp);
+ iobuf_close(fp);
leave:
m_free(answer);
diff --git a/g10/textfilter.c b/g10/textfilter.c
new file mode 100644
index 000000000..e57b429e8
--- /dev/null
+++ b/g10/textfilter.c
@@ -0,0 +1,106 @@
+/* textfilter.c
+ * Copyright (c) 1997 by Werner Koch (dd9jn)
+ *
+ * This file is part of G10.
+ *
+ * G10 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.
+ *
+ * G10 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
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <assert.h>
+
+#include "errors.h"
+#include "iobuf.h"
+#include "memory.h"
+#include "util.h"
+#include "filter.h"
+
+
+/****************
+ * The filter is used to make canonical text: Lines are terminated by
+ * CR, LF, trailing white spaces are removed.
+ */
+int
+text_filter( void *opaque, int control,
+ IOBUF a, byte *buf, size_t *ret_len)
+{
+ size_t size = *ret_len;
+ text_filter_context_t *tfx = opaque;
+ int i, c, rc=0;
+ byte *p;
+
+ if( control == IOBUFCTRL_UNDERFLOW ) {
+ for(i=0; i < size; i++ ) {
+ if( !tfx->linelen && !tfx->eof ) { /* read a complete line */
+ for(;;) {
+ if( (c = iobuf_get(a)) == -1 ) {
+ tfx->eof=1;
+ break;
+ }
+ if( c == '\n' )
+ break;
+ if( tfx->linelen >= tfx->linesize ) {
+ tfx->linesize += 500;
+ tfx->line = m_realloc( tfx->line, tfx->linesize );
+ }
+ tfx->line[tfx->linelen++] = c;
+ }
+ /* remove trailing white spaces */
+ p = tfx->line + tfx->linelen - 1;
+ for( ; p >= tfx->line; p--, tfx->linelen-- ) {
+ if( *p != ' ' && *p == '\t' && *p != '\r' )
+ break;
+ }
+ if( tfx->linelen+2 >= tfx->linesize ) {
+ tfx->linesize += 10;
+ tfx->line = m_realloc( tfx->line, tfx->linesize );
+ }
+ tfx->line[tfx->linelen++] = '\r';
+ tfx->line[tfx->linelen++] = '\n';
+ tfx->pos=0;
+ }
+ if( tfx->pos < tfx->linelen )
+ buf[i] = tfx->line[tfx->pos++];
+ else if( tfx->eof )
+ break;
+ else
+ tfx->linelen = 0;
+ }
+ if( !i )
+ rc = -1;
+ *ret_len = i;
+ }
+ else if( control == IOBUFCTRL_INIT ) {
+ tfx->linesize = 500;
+ tfx->line = m_alloc(tfx->linesize);
+ tfx->linelen = 0;
+ tfx->pos = 0;
+ tfx->eof = 0;
+ }
+ else if( control == IOBUFCTRL_FREE ) {
+ m_free( tfx->line );
+ tfx->line = NULL;
+ }
+ else if( control == IOBUFCTRL_DESC )
+ *(char**)buf = "text_filter";
+ return rc;
+}
+
+
+
diff --git a/include/Makefile.am b/include/Makefile.am
deleted file mode 100644
index bee636750..000000000
--- a/include/Makefile.am
+++ /dev/null
@@ -1,5 +0,0 @@
-## Process this file with automake to produce Makefile.in
-
-EXTRA_DIST = cipher.h errors.h iobuf.h memory.h mpi.h ttyio.h types.h \
- util.h
-
diff --git a/include/distfiles b/include/distfiles
new file mode 100644
index 000000000..342530c4e
--- /dev/null
+++ b/include/distfiles
@@ -0,0 +1,8 @@
+cipher.h
+errors.h
+iobuf.h
+memory.h
+mpi.h
+ttyio.h
+types.h
+util.h
diff --git a/include/mpi.h b/include/mpi.h
index fd93f3075..4e25ab201 100644
--- a/include/mpi.h
+++ b/include/mpi.h
@@ -45,6 +45,18 @@ int mpi_debug_mode;
#define BYTES_PER_MPI_LIMB2 8
typedef unsigned long int mpi_limb_t;
typedef signed long int mpi_limb_signed_t;
+#elif defined(__hppa__)
+ #define BITS_PER_MPI_LIMB 32
+ #define BYTES_PER_MPI_LIMB 4
+ #define BYTES_PER_MPI_LIMB2 8
+ typedef unsigned long int mpi_limb_t;
+ typedef signed long int mpi_limb_signed_t;
+#elif defined(__alpha__)
+ #define BITS_PER_MPI_LIMB 64
+ #define BYTES_PER_MPI_LIMB 8
+ #define BYTES_PER_MPI_LIMB2 16
+ typedef unsigned long int mpi_limb_t;
+ typedef signed long int mpi_limb_signed_t;
#else
#error add definions for this machine here
#endif
diff --git a/include/types.h b/include/types.h
index 575f15224..0a2d8752f 100644
--- a/include/types.h
+++ b/include/types.h
@@ -21,29 +21,29 @@
#ifndef G10_TYPES_H
#define G10_TYPES_H
-#ifdef __linux__
- /* FIXME: add stuff to configure to detect for typedefs */
- #include <linux/types.h>
- #define HAVE_ULONG_TYPEDEF
- #define HAVE_USHORT_TYPEDEF
-#endif
+#include <sys/types.h>
+
#ifndef HAVE_BYTE_TYPEDEF
+ #undef byte /* maybe there is a macro with this name */
typedef unsigned char byte;
#define HAVE_BYTE_TYPEDEF
#endif
#ifndef HAVE_USHORT_TYPEDEF
+ #undef ushort /* maybe there is a macro with this name */
typedef unsigned short ushort;
#define HAVE_USHORT_TYPEDEF
#endif
#ifndef HAVE_ULONG_TYPEDEF
+ #undef ulong /* maybe there is a macro with this name */
typedef unsigned long ulong;
#define HAVE_ULONG_TYPEDEF
#endif
#ifndef HAVE_U16_TYPEDEF
+ #undef u16 /* maybe there is a macro with this name */
#if SIZEOF_UNSIGNED_INT == 2
typedef unsigned int u16;
#elif SIZEOF_UNSIGNED_SHORT == 2
@@ -55,6 +55,7 @@
#endif
#ifndef HAVE_U32_TYPEDEF
+ #undef u32 /* maybe there is a macro with this name */
#if SIZEOF_UNSIGNED_INT == 4
typedef unsigned long u32;
#elif SIZEOF_UNSIGNED_LONG == 4
diff --git a/include/util.h b/include/util.h
index 69cfc0bb0..6a07fcb73 100644
--- a/include/util.h
+++ b/include/util.h
@@ -20,6 +20,7 @@
#ifndef G10_UTIL_H
#define G10_UTIL_H
+#include "types.h"
#include "errors.h"
#include "types.h"
#include "mpi.h"
diff --git a/mpi/Makefile.am b/mpi/Makefile.am
index 33e1ac456..0daf86042 100644
--- a/mpi/Makefile.am
+++ b/mpi/Makefile.am
@@ -5,12 +5,11 @@ CFLAGS += -O2
SUFFIXES = .S .s
-SUBDIRS = generic i386
EXTRA_DIST = config.links
noinst_LIBRARIES = mpi
-noinst_HEADERS = sysdep.h
+# noinst_HEADERS =
mpi_SOURCES = longlong.h \
mpi-add.c \
diff --git a/mpi/Makefile.in b/mpi/Makefile.in
index 382a222cd..c179f53f9 100644
--- a/mpi/Makefile.in
+++ b/mpi/Makefile.in
@@ -42,11 +42,10 @@ INCLUDES = -I$(top_srcdir)/include
SUFFIXES = .S .s
-SUBDIRS = generic i386
EXTRA_DIST = config.links
noinst_LIBRARIES = mpi
-noinst_HEADERS = sysdep.h
+# noinst_HEADERS =
mpi_SOURCES = longlong.h \
mpi-add.c \
@@ -99,8 +98,6 @@ EXTRA_mpi_SOURCES =
LIBFILES = libmpi.a
AR = ar
RANLIB = @RANLIB@
-HEADERS = $(noinst_HEADERS)
-
DIST_COMMON = Makefile.am Makefile.in
@@ -161,45 +158,13 @@ libmpi.a: $(mpi_OBJECTS) $(mpi_LIBADD)
$(AR) cru libmpi.a $(mpi_OBJECTS) $(mpi_LIBADD)
$(RANLIB) libmpi.a
-# This directory's subdirectories are mostly independent; you can cd
-# into them and run `make' without going through this Makefile.
-# To change the values of `make' variables: instead of editing Makefiles,
-# (1) if the variable is set in `config.status', edit `config.status'
-# (which will cause the Makefiles to be regenerated when you run `make');
-# (2) otherwise, pass the desired values on the `make' command line.
-
-@SET_MAKE@
-
-all-recursive install-data-recursive install-exec-recursive \
-installdirs-recursive install-recursive uninstall-recursive \
-check-recursive installcheck-recursive info-recursive dvi-recursive \
-mostlyclean-recursive clean-recursive distclean-recursive \
-maintainer-clean-recursive:
- for subdir in $(SUBDIRS); do \
- target=`echo $@ | sed s/-recursive//`; \
- echo making $$target in $$subdir; \
- (cd $$subdir && $(MAKE) $$target) \
- || case "$(MFLAGS)" in *k*) fail=yes;; *) exit 1;; esac; \
- done && test -z "$$fail"
+ID: $(HEADERS) $(SOURCES)
+ here=`pwd` && cd $(srcdir) && mkid -f$$here/ID $(SOURCES) $(HEADERS)
tags: TAGS
-tags-recursive:
- list="$(SUBDIRS)"; for subdir in $$list; do \
- (cd $$subdir && $(MAKE) tags); \
- done
-
-TAGS: tags-recursive $(HEADERS) $(SOURCES) $(CONFIG_HEADER) \
- $(TAGS_DEPENDENCIES)
- tags=; \
- here=`pwd`; \
- for subdir in $(SUBDIRS); do \
- test -f $$subdir/TAGS && { \
- tags="$$tags -i $$here/$$subdir/TAGS"; \
- }; \
- done; \
- test -z "$(ETAGS_ARGS)$(CONFIG_HEADER)$(SOURCES)$(HEADERS)$$tags" \
- || etags $(ETAGS_ARGS) $$tags $(CONFIG_HEADER) $(SOURCES) $(HEADERS)
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES)
+ here=`pwd` && cd $(srcdir) && etags $(ETAGS_ARGS) $(SOURCES) $(HEADERS) -o $$here/TAGS
mostlyclean-tags:
@@ -218,14 +183,6 @@ distdir: $(DEP_DISTFILES)
|| ln $(srcdir)/$$file $(distdir)/$$file 2> /dev/null \
|| cp -p $(srcdir)/$$file $(distdir)/$$file; \
done
- for subdir in $(SUBDIRS); do \
- test -d $(distdir)/$$subdir \
- || mkdir $(distdir)/$$subdir \
- || exit 1; \
- chmod 777 $(distdir)/$$subdir; \
- (cd $$subdir && $(MAKE) distdir=../$(distdir)/$$subdir distdir) \
- || exit 1; \
- done
# This fragment is probably only useful for maintainers. It relies on
# GNU make and gcc. It is only included in the generated Makefile.in
@@ -253,30 +210,28 @@ $(srcdir)/.deps/%.P: $(srcdir)/%.c
fi
# End of maintainer-only section
-info: info-recursive
-
-dvi: dvi-recursive
+info:
-check: all check-recursive
+dvi:
-installcheck: installcheck-recursive
+check: all
-all-am: $(LIBFILES) $(HEADERS) Makefile
+installcheck:
-install-exec: install-exec-recursive
+install-exec:
-install-data: install-data-recursive
+install-data:
-install: install-recursive
+install: install-exec install-data all
@:
-uninstall: uninstall-recursive
+uninstall:
-all: all-recursive all-am
+all: $(LIBFILES) Makefile
install-strip:
$(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' install
-installdirs: installdirs-recursive
+installdirs:
mostlyclean-generic:
@@ -292,42 +247,29 @@ distclean-generic:
maintainer-clean-generic:
test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES)
-mostlyclean-am: mostlyclean-noinstLIBRARIES mostlyclean-compile \
+mostlyclean: mostlyclean-noinstLIBRARIES mostlyclean-compile \
mostlyclean-tags mostlyclean-generic
-clean-am: clean-noinstLIBRARIES clean-compile clean-tags clean-generic \
- mostlyclean-am
-
-distclean-am: distclean-noinstLIBRARIES distclean-compile \
- distclean-tags distclean-generic clean-am
+clean: clean-noinstLIBRARIES clean-compile clean-tags clean-generic \
+ mostlyclean
-maintainer-clean-am: maintainer-clean-noinstLIBRARIES \
- maintainer-clean-compile maintainer-clean-tags \
- maintainer-clean-generic distclean-am
-
-mostlyclean: mostlyclean-am mostlyclean-recursive
-
-clean: clean-am clean-recursive
-
-distclean: distclean-am distclean-recursive
+distclean: distclean-noinstLIBRARIES distclean-compile distclean-tags \
+ distclean-generic clean
rm -f config.status
-maintainer-clean: maintainer-clean-am maintainer-clean-recursive
+maintainer-clean: maintainer-clean-noinstLIBRARIES \
+ maintainer-clean-compile maintainer-clean-tags \
+ maintainer-clean-generic distclean
@echo "This command is intended for maintainers to use;"
@echo "it deletes files that may require special tools to rebuild."
.PHONY: default mostlyclean-noinstLIBRARIES distclean-noinstLIBRARIES \
clean-noinstLIBRARIES maintainer-clean-noinstLIBRARIES \
mostlyclean-compile distclean-compile clean-compile \
-maintainer-clean-compile install-data-recursive \
-uninstall-data-recursive install-exec-recursive \
-uninstall-exec-recursive installdirs-recursive uninstalldirs-recursive \
-all-recursive check-recursive installcheck-recursive info-recursive \
-dvi-recursive mostlyclean-recursive distclean-recursive clean-recursive \
-maintainer-clean-recursive tags tags-recursive mostlyclean-tags \
-distclean-tags clean-tags maintainer-clean-tags distdir info dvi check \
-installcheck all-am install-exec install-data install uninstall all \
-installdirs mostlyclean-generic distclean-generic clean-generic \
+maintainer-clean-compile tags mostlyclean-tags distclean-tags \
+clean-tags maintainer-clean-tags distdir info dvi check installcheck \
+install-exec install-data install uninstall all installdirs \
+mostlyclean-generic distclean-generic clean-generic \
maintainer-clean-generic clean mostlyclean distclean maintainer-clean
CFLAGS += -O2
diff --git a/mpi/alpha/distfiles b/mpi/alpha/distfiles
new file mode 100644
index 000000000..4dd0ffe3a
--- /dev/null
+++ b/mpi/alpha/distfiles
@@ -0,0 +1,3 @@
+
+udiv-qrnnd.S
+
diff --git a/mpi/alpha/udiv-qrnnd.S b/mpi/alpha/udiv-qrnnd.S
new file mode 100644
index 000000000..487991cd8
--- /dev/null
+++ b/mpi/alpha/udiv-qrnnd.S
@@ -0,0 +1,161 @@
+/* Alpha 21064 __udiv_qrnnd
+ *
+ * Copyright (C) 1992, 1994, 1995 Free Software Foundation, Inc.
+ * Copyright (c) 1997 by Werner Koch (dd9jn)
+ *
+ * This file is part of G10.
+ *
+ * G10 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.
+ *
+ * G10 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
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ * The GNU MP Library itself is published under the LGPL;
+ * however I decided to publish this code under the plain GPL.
+ */
+
+
+
+ .set noreorder
+ .set noat
+.text
+ .align 3
+ .globl __udiv_qrnnd
+ .ent __udiv_qrnnd
+__udiv_qrnnd:
+ .frame $30,0,$26,0
+ .prologue 0
+#define cnt $2
+#define tmp $3
+#define rem_ptr $16
+#define n1 $17
+#define n0 $18
+#define d $19
+#define qb $20
+
+ ldiq cnt,16
+ blt d,.Largedivisor
+
+.Loop1: cmplt n0,0,tmp
+ addq n1,n1,n1
+ bis n1,tmp,n1
+ addq n0,n0,n0
+ cmpule d,n1,qb
+ subq n1,d,tmp
+ cmovne qb,tmp,n1
+ bis n0,qb,n0
+ cmplt n0,0,tmp
+ addq n1,n1,n1
+ bis n1,tmp,n1
+ addq n0,n0,n0
+ cmpule d,n1,qb
+ subq n1,d,tmp
+ cmovne qb,tmp,n1
+ bis n0,qb,n0
+ cmplt n0,0,tmp
+ addq n1,n1,n1
+ bis n1,tmp,n1
+ addq n0,n0,n0
+ cmpule d,n1,qb
+ subq n1,d,tmp
+ cmovne qb,tmp,n1
+ bis n0,qb,n0
+ cmplt n0,0,tmp
+ addq n1,n1,n1
+ bis n1,tmp,n1
+ addq n0,n0,n0
+ cmpule d,n1,qb
+ subq n1,d,tmp
+ cmovne qb,tmp,n1
+ bis n0,qb,n0
+ subq cnt,1,cnt
+ bgt cnt,.Loop1
+ stq n1,0(rem_ptr)
+ bis $31,n0,$0
+ ret $31,($26),1
+
+.Largedivisor:
+ and n0,1,$4
+
+ srl n0,1,n0
+ sll n1,63,tmp
+ or tmp,n0,n0
+ srl n1,1,n1
+
+ and d,1,$6
+ srl d,1,$5
+ addq $5,$6,$5
+
+.Loop2: cmplt n0,0,tmp
+ addq n1,n1,n1
+ bis n1,tmp,n1
+ addq n0,n0,n0
+ cmpule $5,n1,qb
+ subq n1,$5,tmp
+ cmovne qb,tmp,n1
+ bis n0,qb,n0
+ cmplt n0,0,tmp
+ addq n1,n1,n1
+ bis n1,tmp,n1
+ addq n0,n0,n0
+ cmpule $5,n1,qb
+ subq n1,$5,tmp
+ cmovne qb,tmp,n1
+ bis n0,qb,n0
+ cmplt n0,0,tmp
+ addq n1,n1,n1
+ bis n1,tmp,n1
+ addq n0,n0,n0
+ cmpule $5,n1,qb
+ subq n1,$5,tmp
+ cmovne qb,tmp,n1
+ bis n0,qb,n0
+ cmplt n0,0,tmp
+ addq n1,n1,n1
+ bis n1,tmp,n1
+ addq n0,n0,n0
+ cmpule $5,n1,qb
+ subq n1,$5,tmp
+ cmovne qb,tmp,n1
+ bis n0,qb,n0
+ subq cnt,1,cnt
+ bgt cnt,.Loop2
+
+ addq n1,n1,n1
+ addq $4,n1,n1
+ bne $6,.LOdd
+ stq n1,0(rem_ptr)
+ bis $31,n0,$0
+ ret $31,($26),1
+
+.LOdd:
+ /* q' in n0. r' in n1 */
+ addq n1,n0,n1
+ cmpult n1,n0,tmp # tmp := carry from addq
+ beq tmp,.LLp6
+ addq n0,1,n0
+ subq n1,d,n1
+.LLp6: cmpult n1,d,tmp
+ bne tmp,.LLp7
+ addq n0,1,n0
+ subq n1,d,n1
+.LLp7:
+ stq n1,0(rem_ptr)
+ bis $31,n0,$0
+ ret $31,($26),1
+
+ .end __udiv_qrnnd
diff --git a/mpi/config.links b/mpi/config.links
index e48cf7a08..0560b7de5 100644
--- a/mpi/config.links
+++ b/mpi/config.links
@@ -2,9 +2,22 @@
# this should set $mpi_ln_src and mpi_ln_dst.
# Note: this is called from the above directory.
-echo '# created by config.links - do not edit' >./mpi/asm-syntax.h
+
+mpi_extra_modules=
+
+echo '/* created by config.links - do not edit */' >./mpi/asm-syntax.h
case "${target}" in
+ i[345]86*-*-linuxaout* | i[345]86*-*-linuxoldld* | i[345]86*-*-*bsd*)
+ echo '#define BSD_SYNTAX' >>./mpi/asm-syntax.h
+ echo '#include "./i386/syntax.h"' >>./mpi/asm-syntax.h
+ path="i386"
+ ;;
+ i[56]86*-*-linuxaout* | i[56]86*-*-linuxoldld* | i[56]86*-*-*bsd*)
+ echo '#define BSD_SYNTAX' >>./mpi/asm-syntax.h
+ echo '#include "./i386/syntax.h"' >>./mpi/asm-syntax.h
+ path="i586 i386"
+ ;;
i[3456]86*-*-*)
echo '#define ELF_SYNTAX' >>./mpi/asm-syntax.h
echo '#include "./i386/syntax.h"' >>./mpi/asm-syntax.h
@@ -13,7 +26,27 @@ case "${target}" in
i[56]86*-*-* | pentium-*-* | pentiumpro-*-*)
echo '#define ELF_SYNTAX' >>./mpi/asm-syntax.h
echo '#include "./i586/syntax.h"' >>./mpi/asm-syntax.h
- path="i586"
+ path="i586 i386"
+ ;;
+ alpha*-*-*)
+ echo '/* configured for alpha */' >>./mpi/asm-syntax.h
+ path="alpha"
+ mpi_extra_modules="udiv-qrnnd"
+ ;;
+ hppa7000*-*-*)
+ echo '/* configured for HPPA (pa7000) */' >>./mpi/asm-syntax.h
+ path="hppa1_1 hppa"
+ mpi_extra_modules="udiv-qrnnd"
+ ;;
+ hppa1.0*-*-*)
+ echo '/* configured for HPPA 1.0 */' >>./mpi/asm-syntax.h
+ path="hppa"
+ mpi_extra_modules="udiv-qrnnd"
+ ;;
+ hppa*-*-*) # assume pa7100
+ echo '/* configured for HPPA (pa7100) */' >>./mpi/asm-syntax.h
+ path="pa7100 hppa1_1 hppa"
+ mpi_extra_modules="udiv-qrnnd"
;;
*)
echo '/* No assembler modules configured */' >>./mpi/asm-syntax.h
@@ -21,9 +54,38 @@ case "${target}" in
;;
esac
+case "${target}" in
+ *-*-linuxaout* | *-*-linuxoldld*)
+ needs_underscore="y"
+ ;;
+ *-*-linux* | *-sysv* | *-solaris*)
+ needs_underscore="n"
+ ;;
+ *)
+ needs_underscore="y"
+ ;;
+esac
+
+
+# Make sysdep.h
+echo '/* created by config.links - do not edit */' >./mpi/sysdep.h
+if test "$needs_underscore" = "y" ; then
+ cat <<EOF >>./mpi/sysdep.h
+#if __STDC__
+#define C_SYMBOL_NAME(name) _##name
+#else
+#define C_SYMBOL_NAME(name) _/**/name
+#endif
+EOF
+else
+ cat <<EOF >>./mpi/sysdep.h
+#define C_SYMBOL_NAME(name) name
+EOF
+fi
+
# fixme: grep these modules from Makefile.in
-mpi_ln_modules="mpih-add1 mpih-mul1 mpih-mul2 mpih-mul3 \
+mpi_ln_modules="${mpi_extra_modules} mpih-add1 mpih-mul1 mpih-mul2 mpih-mul3 \
mpih-shift mpih-sub1"
mpi_ln_objects=
diff --git a/mpi/generic/distfiles b/mpi/generic/distfiles
new file mode 100644
index 000000000..1febb49dd
--- /dev/null
+++ b/mpi/generic/distfiles
@@ -0,0 +1,7 @@
+mpih-add1.c
+mpih-mul1.c
+mpih-mul2.c
+mpih-mul3.c
+mpih-shift.c
+mpih-sub1.c
+
diff --git a/mpi/hppa/distfiles b/mpi/hppa/distfiles
new file mode 100644
index 000000000..7ca77f801
--- /dev/null
+++ b/mpi/hppa/distfiles
@@ -0,0 +1,4 @@
+
+mpih-add1.S
+udiv-qrnnd.S
+
diff --git a/mpi/hppa/mpih-add1.S b/mpi/hppa/mpih-add1.S
new file mode 100644
index 000000000..a30e80b83
--- /dev/null
+++ b/mpi/hppa/mpih-add1.S
@@ -0,0 +1,70 @@
+/* hppa add_n -- Add two limb vectors of the same length > 0 and store
+ * sum in a third limb vector.
+ *
+ * Copyright (C) 1992, 1994 Free Software Foundation, Inc.
+ * Copyright (c) 1997 by Werner Koch (dd9jn)
+ *
+ * This file is part of G10.
+ *
+ * G10 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.
+ *
+ * G10 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
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ * The GNU MP Library itself is published under the LGPL;
+ * however I decided to publish this code under the plain GPL.
+ */
+
+
+
+/*******************
+ * mpi_limb_t
+ * mpihelp_add_n( mpi_ptr_t res_ptr, (gr26)
+ * mpi_ptr_t s1_ptr, (gr25)
+ * mpi_ptr_t s2_ptr, (gr24)
+ * mpi_size_t size) (gr23)
+ *
+ * One might want to unroll this as for other processors, but it turns
+ * out that the data cache contention after a store makes such
+ * unrolling useless. We can't come under 5 cycles/limb anyway.
+ */
+
+ .code
+ .export __mpihelp_add_n
+__mpihelp_add_n
+ .proc
+ .callinfo frame=0,no_calls
+ .entry
+
+ ldws,ma 4(0,%r25),%r20
+ ldws,ma 4(0,%r24),%r19
+
+ addib,= -1,%r23,L$end ; check for (SIZE == 1)
+ add %r20,%r19,%r28 ; add first limbs ignoring cy
+
+L$loop ldws,ma 4(0,%r25),%r20
+ ldws,ma 4(0,%r24),%r19
+ stws,ma %r28,4(0,%r26)
+ addib,<> -1,%r23,L$loop
+ addc %r20,%r19,%r28
+
+L$end stws %r28,0(0,%r26)
+ bv 0(%r2)
+ addc %r0,%r0,%r28
+
+ .exit
+ .procend
diff --git a/mpi/hppa/udiv-qrnnd.S b/mpi/hppa/udiv-qrnnd.S
new file mode 100644
index 000000000..849238349
--- /dev/null
+++ b/mpi/hppa/udiv-qrnnd.S
@@ -0,0 +1,297 @@
+/* HP-PA __udiv_qrnnd division support, used from longlong.h.
+ * This version runs fast on pre-PA7000 CPUs.
+ *
+ * Copyright (C) 1993, 1994 Free Software Foundation, Inc.
+ * Copyright (c) 1997 by Werner Koch (dd9jn)
+ *
+ * This file is part of G10.
+ *
+ * G10 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.
+ *
+ * G10 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
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ * The GNU MP Library itself is published under the LGPL;
+ * however I decided to publish this code under the plain GPL.
+ */
+
+
+
+/* INPUT PARAMETERS
+ * rem_ptr gr26
+ * n1 gr25
+ * n0 gr24
+ * d gr23
+ *
+ * The code size is a bit excessive. We could merge the last two ds;addc
+ * sequences by simply moving the "bb,< Odd" instruction down. The only
+ * trouble is the FFFFFFFF code that would need some hacking.
+ */
+
+ .code
+ .export __udiv_qrnnd
+__udiv_qrnnd
+ .proc
+ .callinfo frame=0,no_calls
+ .entry
+
+ comb,< %r23,0,L$largedivisor
+ sub %r0,%r23,%r1 ; clear cy as side-effect
+ ds %r0,%r1,%r0
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r28
+ ds %r25,%r23,%r25
+ comclr,>= %r25,%r0,%r0
+ addl %r25,%r23,%r25
+ stws %r25,0(0,%r26)
+ bv 0(%r2)
+ addc %r28,%r28,%r28
+
+L$largedivisor
+ extru %r24,31,1,%r19 ; r19 = n0 & 1
+ bb,< %r23,31,L$odd
+ extru %r23,30,31,%r22 ; r22 = d >> 1
+ shd %r25,%r24,1,%r24 ; r24 = new n0
+ extru %r25,30,31,%r25 ; r25 = new n1
+ sub %r0,%r22,%r21
+ ds %r0,%r21,%r0
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ comclr,>= %r25,%r0,%r0
+ addl %r25,%r22,%r25
+ sh1addl %r25,%r19,%r25
+ stws %r25,0(0,%r26)
+ bv 0(%r2)
+ addc %r24,%r24,%r28
+
+L$odd addib,sv,n 1,%r22,L$FF.. ; r22 = (d / 2 + 1)
+ shd %r25,%r24,1,%r24 ; r24 = new n0
+ extru %r25,30,31,%r25 ; r25 = new n1
+ sub %r0,%r22,%r21
+ ds %r0,%r21,%r0
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r28
+ comclr,>= %r25,%r0,%r0
+ addl %r25,%r22,%r25
+ sh1addl %r25,%r19,%r25
+; We have computed (n1,,n0) / (d + 1), q' = r28, r' = r25
+ add,nuv %r28,%r25,%r25
+ addl %r25,%r1,%r25
+ addc %r0,%r28,%r28
+ sub,<< %r25,%r23,%r0
+ addl %r25,%r1,%r25
+ stws %r25,0(0,%r26)
+ bv 0(%r2)
+ addc %r0,%r28,%r28
+
+; This is just a special case of the code above.
+; We come here when d == 0xFFFFFFFF
+L$FF.. add,uv %r25,%r24,%r24
+ sub,<< %r24,%r23,%r0
+ ldo 1(%r24),%r24
+ stws %r24,0(0,%r26)
+ bv 0(%r2)
+ addc %r0,%r25,%r28
+
+ .exit
+ .procend
diff --git a/mpi/i386/distfiles b/mpi/i386/distfiles
new file mode 100644
index 000000000..34de91574
--- /dev/null
+++ b/mpi/i386/distfiles
@@ -0,0 +1,8 @@
+mpih-add1.S
+mpih-mul1.S
+mpih-mul2.S
+mpih-mul3.S
+mpih-shift.S
+mpih-sub1.S
+syntax.h
+
diff --git a/mpi/mpi-inline.h b/mpi/mpi-inline.h
index 4d19942ad..03b5fbc86 100644
--- a/mpi/mpi-inline.h
+++ b/mpi/mpi-inline.h
@@ -123,5 +123,4 @@ mpihelp_sub( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, mpi_size_t s1_size,
}
-
#endif /*G10_MPI_INLINE_H*/
diff --git a/mpi/mpi-internal.h b/mpi/mpi-internal.h
index 93ed688ae..f084c7e8a 100644
--- a/mpi/mpi-internal.h
+++ b/mpi/mpi-internal.h
@@ -32,6 +32,21 @@
#include "mpi.h"
+/* If KARATSUBA_THRESHOLD is not already defined, define it to a
+ * value which is good on most machines. */
+
+/* tested 4, 16, 32 and 64, where 16 gave the best performance when
+ * checking a 768 and a 1024 bit ElGamal signature.
+ * (wk 22.12.97) */
+#ifndef KARATSUBA_THRESHOLD
+ #define KARATSUBA_THRESHOLD 16
+#endif
+
+/* The code can't handle KARATSUBA_THRESHOLD smaller than 2. */
+#if KARATSUBA_THRESHOLD < 2
+ #undef KARATSUBA_THRESHOLD
+ #define KARATSUBA_THRESHOLD 2
+#endif
typedef mpi_limb_t *mpi_ptr_t; /* pointer to a limb */
@@ -174,6 +189,9 @@ void mpihelp_mul_n( mpi_ptr_t prodp, mpi_ptr_t up, mpi_ptr_t vp,
mpi_size_t size);
mpi_limb_t mpihelp_mul( mpi_ptr_t prodp, mpi_ptr_t up, mpi_size_t usize,
mpi_ptr_t vp, mpi_size_t vsize);
+void mpih_sqr_n_basecase( mpi_ptr_t prodp, mpi_ptr_t up, mpi_size_t size );
+void mpih_sqr_n( mpi_ptr_t prodp, mpi_ptr_t up, mpi_size_t size,
+ mpi_ptr_t tspace);
/*-- mpihelp-mul_1.c (or xxx/cpu/*.S) --*/
mpi_limb_t mpihelp_mul_1( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr,
diff --git a/mpi/mpi-pow.c b/mpi/mpi-pow.c
index 43514567b..fcf500c36 100644
--- a/mpi/mpi-pow.c
+++ b/mpi/mpi-pow.c
@@ -51,6 +51,8 @@ mpi_powm( MPI res, MPI base, MPI exp, MPI mod)
mpi_ptr_t mp_marker=NULL, bp_marker=NULL, ep_marker=NULL;
mpi_ptr_t xp_marker=NULL;
int assign_rp=0;
+ mpi_ptr_t tspace = NULL;
+ mpi_size_t tsize;
esize = exp->nlimbs;
msize = mod->nlimbs;
@@ -179,7 +181,23 @@ mpi_powm( MPI res, MPI base, MPI exp, MPI mod)
mpi_ptr_t tp;
mpi_size_t xsize;
- mpihelp_mul_n(xp, rp, rp, rsize);
+ /*mpihelp_mul_n(xp, rp, rp, rsize);*/
+ if( rsize < KARATSUBA_THRESHOLD )
+ mpih_sqr_n_basecase( xp, rp, rsize );
+ else {
+ if( !tspace ) {
+ tsize = 2 * rsize;
+ tspace = mpi_alloc_limb_space( tsize, 0 );
+ }
+ else if( tsize < (2*rsize) ) {
+ mpi_free_limb_space( tspace );
+ tsize = 2 * rsize;
+ tspace = mpi_alloc_limb_space( tsize, 0 );
+
+ }
+ mpih_sqr_n( xp, rp, rsize, tspace );
+ }
+
xsize = 2 * rsize;
if( xsize > msize ) {
mpihelp_divrem(xp + msize, 0, xp, xsize, mp, msize);
@@ -258,5 +276,6 @@ mpi_powm( MPI res, MPI base, MPI exp, MPI mod)
if( bp_marker ) mpi_free_limb_space( bp_marker );
if( ep_marker ) mpi_free_limb_space( ep_marker );
if( xp_marker ) mpi_free_limb_space( xp_marker );
+ if( tspace ) mpi_free_limb_space( tspace );
}
diff --git a/mpi/mpih-mul.c b/mpi/mpih-mul.c
index 0e52488ec..3b6b732b6 100644
--- a/mpi/mpih-mul.c
+++ b/mpi/mpih-mul.c
@@ -33,17 +33,6 @@
#include "mpi-internal.h"
#include "longlong.h"
-/* If KARATSUBA_THRESHOLD is not already defined, define it to a
- * value which is good on most machines. */
-#ifndef KARATSUBA_THRESHOLD
- #define KARATSUBA_THRESHOLD 32
-#endif
-
-/* The code can't handle KARATSUBA_THRESHOLD smaller than 2. */
-#if KARATSUBA_THRESHOLD < 2
- #undef KARATSUBA_THRESHOLD
- #define KARATSUBA_THRESHOLD 2
-#endif
#define MPN_MUL_N_RECURSE(prodp, up, vp, size, tspace) \
@@ -57,9 +46,9 @@
#define MPN_SQR_N_RECURSE(prodp, up, size, tspace) \
do { \
if ((size) < KARATSUBA_THRESHOLD) \
- sqr_n_basecase (prodp, up, size); \
+ mpih_sqr_n_basecase (prodp, up, size); \
else \
- sqr_n (prodp, up, size, tspace); \
+ mpih_sqr_n (prodp, up, size, tspace); \
} while (0);
@@ -235,8 +224,8 @@ mul_n( mpi_ptr_t prodp, mpi_ptr_t up, mpi_ptr_t vp,
}
-static void
-sqr_n_basecase( mpi_ptr_t prodp, mpi_ptr_t up, mpi_size_t size )
+void
+mpih_sqr_n_basecase( mpi_ptr_t prodp, mpi_ptr_t up, mpi_size_t size )
{
mpi_size_t i;
mpi_limb_t cy_limb;
@@ -276,8 +265,8 @@ sqr_n_basecase( mpi_ptr_t prodp, mpi_ptr_t up, mpi_size_t size )
}
-static void
-sqr_n( mpi_ptr_t prodp, mpi_ptr_t up, mpi_size_t size, mpi_ptr_t tspace)
+void
+mpih_sqr_n( mpi_ptr_t prodp, mpi_ptr_t up, mpi_size_t size, mpi_ptr_t tspace)
{
if( size & 1 ) {
/* The size is odd, the code code below doesn't handle that.
@@ -361,11 +350,11 @@ mpihelp_mul_n( mpi_ptr_t prodp, mpi_ptr_t up, mpi_ptr_t vp, mpi_size_t size)
if( up == vp ) {
if( size < KARATSUBA_THRESHOLD )
- sqr_n_basecase( prodp, up, size );
+ mpih_sqr_n_basecase( prodp, up, size );
else {
mpi_ptr_t tspace;
tspace = mpi_alloc_limb_space( 2 * size, 0 );
- sqr_n( prodp, up, size, tspace );
+ mpih_sqr_n( prodp, up, size, tspace );
mpi_free_limb_space( tspace );
}
}
diff --git a/scripts/distfiles b/scripts/distfiles
new file mode 100644
index 000000000..bdfb3987f
--- /dev/null
+++ b/scripts/distfiles
@@ -0,0 +1,4 @@
+config.guess
+config.sub
+install-sh
+mkinstalldirs
diff --git a/util/iobuf.c b/util/iobuf.c
index b4b9c195e..58b0d7785 100644
--- a/util/iobuf.c
+++ b/util/iobuf.c
@@ -579,12 +579,14 @@ underflow(IOBUF a)
size_t dummy_len;
/* and tell the filter to free it self */
- if( (rc = a->filter(a->filter_ov, IOBUFCTRL_FREE, a->chain,
- NULL, &dummy_len)) )
- log_error("IOBUFCTRL_FREE failed: %s\n", g10_errstr(rc) );
- a->filter = NULL;
- a->desc = NULL;
- a->filter_ov = NULL;
+ if( a->filter != file_filter ) {
+ if( (rc = a->filter(a->filter_ov, IOBUFCTRL_FREE, a->chain,
+ NULL, &dummy_len)) )
+ log_error("IOBUFCTRL_FREE failed: %s\n", g10_errstr(rc) );
+ a->filter = NULL;
+ a->desc = NULL;
+ a->filter_ov = NULL;
+ }
a->filter_eof = 1;
}