changed configuration stuff, replaced some Makefile.am by distfiles.

This commit is contained in:
Werner Koch 1997-12-23 17:30:18 +00:00
parent a112009805
commit c351df1dc5
42 changed files with 1091 additions and 220 deletions

View File

@ -1,6 +1,6 @@
## Process this file with automake to produce Makefile.in ## 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 = EXTRA_DIST =
@ -9,4 +9,13 @@ tar: clean
cd ..; tar czvf ~/bkup/g10-`date +%d%m`.tar.gz src 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

View File

@ -38,7 +38,7 @@ INSTALL_DATA = @INSTALL_DATA@
INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_SCRIPT = @INSTALL_SCRIPT@
transform = @program_transform_name@ transform = @program_transform_name@
SUBDIRS = scripts include util mpi cipher tools g10 SUBDIRS = util mpi cipher tools g10
EXTRA_DIST = EXTRA_DIST =
ACCONFIG = acconfig.h ACCONFIG = acconfig.h
CONFIG_HEADER_IN = config.h.in CONFIG_HEADER_IN = config.h.in
@ -176,6 +176,7 @@ distdir: $(DEP_DISTFILES)
(cd $$subdir && $(MAKE) distdir=../$(distdir)/$$subdir distdir) \ (cd $$subdir && $(MAKE) distdir=../$(distdir)/$$subdir distdir) \
|| exit 1; \ || exit 1; \
done done
$(MAKE) dist-hook
info: info-recursive info: info-recursive
dvi: dvi-recursive dvi: dvi-recursive
@ -254,6 +255,16 @@ maintainer-clean
tar: clean tar: clean
cd ..; tar czvf ~/bkup/g10-`date +%d%m`.tar.gz src 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: .SUFFIXES:
# Tell versions [3.59,3.63) of GNU make to not export all variables. # Tell versions [3.59,3.63) of GNU make to not export all variables.

View File

@ -26,6 +26,17 @@
#undef M_DEBUG #undef M_DEBUG
#undef VERSION #undef VERSION
#undef PACKAGE #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 is only compiled in if you have these files. You can use
* RSA without any restrictions, if your not in the U.S. or * RSA without any restrictions, if your not in the U.S. or
* wait until sep 20, 2000 * wait until sep 20, 2000
@ -35,11 +46,5 @@
@BOTTOM@ @BOTTOM@
#ifdef WORDS_BIGENDIAN
#define BIG_ENDIAN_HOST
#else
#define LITTLE_ENDIAN_HOST
#endif
#endif /*G10_CONFIG_H*/ #endif /*G10_CONFIG_H*/

View File

@ -24,6 +24,6 @@ cipher_SOURCES = blowfish.c \
md.c \ md.c \
smallprime.c smallprime.c
##cipher_LIBADD = rsa.o cipher_LIBADD = rsa.o

View File

@ -60,6 +60,8 @@ cipher_SOURCES = blowfish.c \
dsa.c \ dsa.c \
md.c \ md.c \
smallprime.c smallprime.c
cipher_LIBADD = rsa.o
mkinstalldirs = $(top_srcdir)/scripts/mkinstalldirs mkinstalldirs = $(top_srcdir)/scripts/mkinstalldirs
CONFIG_HEADER = ../config.h CONFIG_HEADER = ../config.h
LIBRARIES = $(noinst_LIBRARIES) LIBRARIES = $(noinst_LIBRARIES)
@ -78,7 +80,6 @@ LIBS = @LIBS@
COMPILE = $(CC) -c $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) COMPILE = $(CC) -c $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)
LINK = $(CC) $(LDFLAGS) -o $@ LINK = $(CC) $(LDFLAGS) -o $@
cipher_LIBADD =
cipher_OBJECTS = blowfish.o elgamal.o gost.o md5.o primegen.o random.o \ cipher_OBJECTS = blowfish.o elgamal.o gost.o md5.o primegen.o random.o \
rmd160.o sha1.o dsa.o md.o smallprime.o rmd160.o sha1.o dsa.o md.o smallprime.o
EXTRA_cipher_SOURCES = EXTRA_cipher_SOURCES =

View File

@ -41,13 +41,19 @@
/* Define if you have the ANSI C header files. */ /* Define if you have the ANSI C header files. */
#undef STDC_HEADERS #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 M_DEBUG
#undef VERSION #undef VERSION
#undef PACKAGE #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 is only compiled in if you have these files. You can use
* RSA without any restrictions, if your not in the U.S. or * RSA without any restrictions, if your not in the U.S. or
* wait until sep 20, 2000 * wait until sep 20, 2000
@ -78,11 +84,5 @@
/* Define if you have the <zlib.h> header file. */ /* Define if you have the <zlib.h> header file. */
#undef HAVE_ZLIB_H #undef HAVE_ZLIB_H
#ifdef WORDS_BIGENDIAN
#define BIG_ENDIAN_HOST
#else
#define LITTLE_ENDIAN_HOST
#endif
#endif /*G10_CONFIG_H*/ #endif /*G10_CONFIG_H*/

View File

@ -7,6 +7,7 @@ AC_INIT(g10/g10.c)
AC_CONFIG_AUX_DIR(scripts) AC_CONFIG_AUX_DIR(scripts)
AC_CONFIG_HEADER(config.h) AC_CONFIG_HEADER(config.h)
VERSION=0.0.0 VERSION=0.0.0
PACKAGE=g10 PACKAGE=g10
AC_SUBST(VERSION) AC_SUBST(VERSION)
@ -19,7 +20,26 @@ AC_ARG_ENABLE(m-debug,
if test "$enableval" = y || test "$enableval" = yes; then if test "$enableval" = y || test "$enableval" = yes; then
AC_DEFINE(M_DEBUG) AC_DEFINE(M_DEBUG)
fi 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 dnl
AC_CANONICAL_SYSTEM AC_CANONICAL_SYSTEM
@ -46,7 +66,6 @@ AC_PROG_CPP
AC_ARG_PROGRAM AC_ARG_PROGRAM
dnl Checks for libraries. dnl Checks for libraries.
dnl Checks for header files. dnl Checks for header files.
@ -63,10 +82,56 @@ AC_C_CONST
AC_C_INLINE AC_C_INLINE
AC_TYPE_SIZE_T AC_TYPE_SIZE_T
AC_C_BIGENDIAN
AC_CHECK_SIZEOF(unsigned short) dnl autoconf doesn't support a default value for AC_C_BIGENDIAN
AC_CHECK_SIZEOF(unsigned int) dnl so here is the modified version
AC_CHECK_SIZEOF(unsigned long) 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. dnl Checks for library functions.
@ -86,24 +151,21 @@ fi
dnl checking whether we have the RSA source dnl checking whether we have the RSA source
dnl fixme: I found no way (aside of using Makefile.am.in) dnl Add stuff to insert this into the makefile
dnl to add the requeired source int Makefile.am dnl AC_SUBST(add_cipher_SOURCES)
dnl I used: add_cipher_SOURCES="rsa.c rsa.h" AC_CACHE_CHECK(for rsa source, ac_cv_have_rsa_cipher,
dnl but of cource it can't work [if test -f cipher/rsa.c && test -f cipher/rsa.h; then
AC_MSG_CHECKING(whether we have the rsa source) ac_cv_have_rsa_cipher=yes; else ac_cv_have_rsa_cipher=no; fi])
if test -f cipher/rsa.c && test -f cipher/rsa.h; then if test $ac_cv_have_rsa_cipher = yes; then
AC_DEFINE(HAVE_RSA_CIPHER) AC_DEFINE(HAVE_RSA_CIPHER)
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
fi fi
AC_SUBST(add_cipher_SOURCES)
AC_OUTPUT([ Makefile scripts/Makefile util/Makefile mpi/Makefile \
mpi/generic/Makefile mpi/i386/Makefile \ AC_OUTPUT([ Makefile \
util/Makefile \
mpi/Makefile \
cipher/Makefile \ cipher/Makefile \
include/Makefile \ g10/Makefile \
g10/Makefile tools/Makefile ], tools/Makefile \
[echo timestamp > stamp-h ] ) ], [echo timestamp > stamp-h ] )

View File

@ -21,6 +21,7 @@ g10_SOURCES = g10.c \
mainproc.c \ mainproc.c \
armor.c \ armor.c \
mdfilter.c \ mdfilter.c \
textfilter.c \
cipher.c \ cipher.c \
options.h \ options.h \
openfile.c \ openfile.c \

View File

@ -59,6 +59,7 @@ g10_SOURCES = g10.c \
mainproc.c \ mainproc.c \
armor.c \ armor.c \
mdfilter.c \ mdfilter.c \
textfilter.c \
cipher.c \ cipher.c \
options.h \ options.h \
openfile.c \ openfile.c \
@ -94,9 +95,9 @@ COMPILE = $(CC) -c $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)
LINK = $(CC) $(LDFLAGS) -o $@ LINK = $(CC) $(LDFLAGS) -o $@
g10_OBJECTS = g10.o build-packet.o compress.o encode.o encr-data.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 \ 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 \ mdfilter.o textfilter.o cipher.o openfile.o keyid.o parse-packet.o \
plaintext.o pubkey-enc.o seckey-cert.o seskey.o sign.o comment.o \ passphrase.o plaintext.o pubkey-enc.o seckey-cert.o seskey.o sign.o \
sig-check.o comment.o sig-check.o
EXTRA_g10_SOURCES = EXTRA_g10_SOURCES =
g10_LDADD = $(LDADD) g10_LDADD = $(LDADD)
DIST_COMMON = Makefile.am Makefile.in 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/passphrase.P $(srcdir)/.deps/plaintext.P \
$(srcdir)/.deps/pubkey-enc.P $(srcdir)/.deps/ringedit.P \ $(srcdir)/.deps/pubkey-enc.P $(srcdir)/.deps/ringedit.P \
$(srcdir)/.deps/seckey-cert.P $(srcdir)/.deps/seskey.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) SOURCES = $(g10_SOURCES)
OBJECTS = $(g10_OBJECTS) OBJECTS = $(g10_OBJECTS)

View File

@ -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", log_debug("inflate returned: avail_in=%u, avail_out=%u, zrc=%d\n",
(unsigned)zs->avail_in, (unsigned)zs->avail_out, zrc); (unsigned)zs->avail_in, (unsigned)zs->avail_out, zrc);
if( zrc == Z_STREAM_END ) if( zrc == Z_STREAM_END )
rc = -1; /* eof */ rc = -1; /* eof FIXME: return remaining bytes until EOF */
else if( zrc != Z_OK ) { else if( zrc != Z_OK ) {
if( zs->msg ) if( zs->msg )
log_fatal("zlib inflate problem: %s\n", zs->msg ); log_fatal("zlib inflate problem: %s\n", zs->msg );

View File

@ -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); iobuf_close(inp);
m_free(cfx.dek); m_free(cfx.dek);
return G10ERR_CREATE_FILE; /* or user said: do not overwrite */ 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 ) else if( opt.verbose )
log_error("reding from '%s'\n", filename? filename: "[stdin]"); 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); iobuf_close(inp);
free_strlist(local_remusr); free_strlist(local_remusr);
return G10ERR_CREATE_FILE; /* or user said: do not overwrite */ return G10ERR_CREATE_FILE; /* or user said: do not overwrite */

View File

@ -35,6 +35,10 @@ typedef struct {
byte radbuf[4]; byte radbuf[4];
int idx, idx2; int idx, idx2;
u32 crc; u32 crc;
byte helpbuf[100];
int helpidx, helplen;
int last_c;
int fake;
int inp_checked; /* set if inp has been checked */ int inp_checked; /* set if inp has been checked */
int inp_bypass; /* set if the input is not armored */ int inp_bypass; /* set if the input is not armored */
int inp_eof; int inp_eof;
@ -60,6 +64,13 @@ typedef struct {
} cipher_filter_context_t; } 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 --*/ /*-- mdfilter.c --*/
int md_filter( void *opaque, int control, IOBUF a, byte *buf, size_t *ret_len); 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, int cipher_filter( void *opaque, int control,
IOBUF chain, byte *buf, size_t *ret_len); 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*/ #endif /*G10_FILTER_H*/

View File

@ -116,6 +116,7 @@ main( int argc, char **argv )
{ 508, "check-key" ,0, "check signatures on a key in the keyring" }, { 508, "check-key" ,0, "check signatures on a key in the keyring" },
{ 509, "keyring" ,2, "add this keyring to the list of keyrings" }, { 509, "keyring" ,2, "add this keyring to the list of keyrings" },
{ 's', "sign", 0, "make a signature"}, { 's', "sign", 0, "make a signature"},
{ 't', "textmode", 0, "use canonical text mode"},
{ 'b', "detach-sign", 0, "make a detached signature"}, { 'b', "detach-sign", 0, "make a detached signature"},
{ 'e', "encrypt", 0, "encrypt data" }, { 'e', "encrypt", 0, "encrypt data" },
{ 'd', "decrypt", 0, "decrypt data (default)" }, { 'd', "decrypt", 0, "decrypt data (default)" },
@ -140,7 +141,7 @@ main( int argc, char **argv )
IOBUF a; IOBUF a;
int rc; int rc;
enum { aNull, aSym, aStore, aEncr, aPrimegen, aKeygen, aSign, aSignEncr, enum { aNull, aSym, aStore, aEncr, aPrimegen, aKeygen, aSign, aSignEncr,
aTest, aPrintMDs, aSignKey, aTest, aPrintMDs, aSignKey, aClearsig
} action = aNull; } action = aNull;
int orig_argc; int orig_argc;
char **orig_argv; char **orig_argv;
@ -219,6 +220,7 @@ main( int argc, char **argv )
case 'b': detached_sig = 1; case 'b': detached_sig = 1;
/* fall trough */ /* fall trough */
case 's': action = action == aEncr? aSignEncr : aSign; break; case 's': action = action == aEncr? aSignEncr : aSign; break;
case 't': action = aClearsig; break;
case 'l': /* store the local users */ case 'l': /* store the local users */
sl = m_alloc( sizeof *sl + strlen(pargs.r.ret_str)); sl = m_alloc( sizeof *sl + strlen(pargs.r.ret_str));
strcpy(sl->d, 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) ); log_error("sign_file('%s'): %s\n", fname_print, g10_errstr(rc) );
break; break;
case aSignEncr: /* sign and encrypt the given file */ case aSignEncr: /* sign and encrypt the given file */
log_fatal("signing and encryption is not yet implemented\n"); log_fatal("signing and encryption is not yet implemented\n");
usage(1); /* FIXME */ usage(1); /* FIXME */

View File

@ -38,7 +38,9 @@
#define TEST_UID "Karl Test" #define TEST_UID "Karl Test"
#endif #endif
#if defined(HAVE_RSA_CIPHER) && 0
#define ENABLE_RSA_KEYGEN 1
#endif
static u16 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 static int
gen_rsa(unsigned nbits, IOBUF pub_io, IOBUF sec_io, DEK *dek, gen_rsa(unsigned nbits, IOBUF pub_io, IOBUF sec_io, DEK *dek,
PKT_public_cert **ret_pkc, PKT_secret_cert **ret_skc ) 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); free_packet(&pkt2);
return rc; return rc;
} }
#endif /*HAVE_RSA_CIPHER*/ #endif /*ENABLE_RSA_KEYGEN*/
static int static int
@ -310,10 +312,10 @@ generate_keypair()
tty_printf("Please select the algorithm to use:\n" tty_printf("Please select the algorithm to use:\n"
" (1) ElGamal is the suggested one.\n" " (1) ElGamal is the suggested one.\n"
#ifdef HAVE_RSA_CIPHER " (2) DSA can only be used for signatures.\n"
" (2) RSA cannot be used in the U.S.\n" #ifdef ENABLE_RSA_KEYGEN
" (3) RSA cannot be used in the U.S.\n"
#endif #endif
" (3) DSA can only be used for signatures.\n"
); );
#endif #endif
@ -321,11 +323,11 @@ generate_keypair()
#ifdef TEST_ALGO #ifdef TEST_ALGO
algo = TEST_ALGO; algo = TEST_ALGO;
#else #else
answer = tty_get("Your selection? (1" answer = tty_get("Your selection? (1,2"
#ifdef HAVE_RSA_CIPHER #ifdef ENABLE_RSA_KEYGEN
",2" ",3"
#endif #endif
",3) "); ") ");
tty_kill_prompt(); tty_kill_prompt();
algo = *answer? atoi(answer): 1; algo = *answer? atoi(answer): 1;
m_free(answer); m_free(answer);
@ -335,18 +337,18 @@ generate_keypair()
algo_name = "ElGamal"; algo_name = "ElGamal";
break; break;
} }
#ifdef HAVE_RSA_CIPHER
else if( algo == 2 ) { 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 = PUBKEY_ALGO_RSA;
algo_name = "RSA"; algo_name = "RSA";
break; break;
} }
#endif #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 ) if( algo == PUBKEY_ALGO_ELGAMAL )
rc = gen_elg(nbits, pub_root, sec_root, dek, &skc ); rc = gen_elg(nbits, pub_root, sec_root, dek, &skc );
#ifdef HAVE_RSA_CIPHER #ifdef ENABLE_RSA_KEYGEN
else if( algo == PUBKEY_ALGO_RSA ) else if( algo == PUBKEY_ALGO_RSA )
rc = gen_rsa(nbits, pub_io, sec_io, dek, &skc ); rc = gen_rsa(nbits, pub_io, sec_io, dek, &skc );
#endif #endif

View File

@ -45,7 +45,8 @@ void generate_keypair(void);
/*-- openfile.c --*/ /*-- openfile.c --*/
int overwrite_filep( const char *fname ); 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 --*/ /*-- seskey.c --*/
void make_session_key( DEK *dek ); void make_session_key( DEK *dek );

View File

@ -49,6 +49,7 @@ typedef struct {
int opt_list; int opt_list;
KBNODE cert; /* the current certificate */ KBNODE cert; /* the current certificate */
int have_data; int have_data;
IOBUF iobuf; /* used to get the filename etc. */
} *CTX; } *CTX;
@ -259,8 +260,11 @@ proc_plaintext( CTX c, PACKET *pkt )
printf("txt: plain text data name='%.*s'\n", pt->namelen, pt->name); printf("txt: plain text data name='%.*s'\n", pt->namelen, pt->name);
free_md_filter_context( &c->mfx ); free_md_filter_context( &c->mfx );
/* fixme: take the digest algo to use from the /* fixme: take the digest algo(s) to use from the
* onepass_sig packet (if we have these) */ * 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); c->mfx.md = md_open(DIGEST_ALGO_RMD160, 0);
result = handle_plaintext( pt, &c->mfx ); result = handle_plaintext( pt, &c->mfx );
if( !result ) if( !result )
@ -463,8 +467,9 @@ list_node( CTX c, KBNODE node )
if( !opt.list_sigs ) if( !opt.list_sigs )
return; return;
fputs("sig", stdout);
if( opt.check_sigs ) { if( opt.check_sigs ) {
fflush(stdout);
switch( (rc2=do_check_sig( c, node )) ) { switch( (rc2=do_check_sig( c, node )) ) {
case 0: sigrc = '!'; break; case 0: sigrc = '!'; break;
case G10ERR_BAD_SIGN: sigrc = '-'; break; case G10ERR_BAD_SIGN: sigrc = '-'; break;
@ -472,7 +477,7 @@ list_node( CTX c, KBNODE node )
default: sigrc = '%'; break; default: sigrc = '%'; break;
} }
} }
printf("sig%c %08lX %s ", printf("%c %08lX %s ",
sigrc, sig->keyid[1], datestr_from_sig(sig)); sigrc, sig->keyid[1], datestr_from_sig(sig));
if( sigrc == '%' ) if( sigrc == '%' )
printf("[%s] ", g10_errstr(rc2) ); printf("[%s] ", g10_errstr(rc2) );
@ -501,6 +506,7 @@ proc_packets( IOBUF a )
int newpkt; int newpkt;
c->opt_list = 1; c->opt_list = 1;
c->iobuf = a;
init_packet(pkt); init_packet(pkt);
while( (rc=parse_packet(a, pkt)) != -1 ) { while( (rc=parse_packet(a, pkt)) != -1 ) {
/* cleanup if we have an illegal data structure */ /* cleanup if we have an illegal data structure */
@ -511,6 +517,8 @@ proc_packets( IOBUF a )
if( rc ) { if( rc ) {
free_packet(pkt); free_packet(pkt);
if( rc == G10ERR_INVALID_PACKET )
break;
continue; continue;
} }
newpkt = -1; 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 static void
proc_tree( CTX c, KBNODE node ) 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 /* fixme: take the digest algo to use from the
* onepass_sig packet (if we have these) */ * onepass_sig packet (if we have these) */
c->mfx.md = md_open(DIGEST_ALGO_RMD160, 0); 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 ) { if( rc ) {
log_error("can't hash datafile: %s\n", g10_errstr(rc)); log_error("can't hash datafile: %s\n", g10_errstr(rc));
return; return;

View File

@ -23,6 +23,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <assert.h> #include <assert.h>
#include <errno.h>
#include <unistd.h> #include <unistd.h>
#include "util.h" #include "util.h"
#include "memory.h" #include "memory.h"
@ -80,9 +81,12 @@ overwrite_filep( const char *fname )
/**************** /****************
* Make an output filename for the inputfile INAME. * Make an output filename for the inputfile INAME.
* Returns an IOBUF * Returns an IOBUF
* Mode 0 = use ".g10"
* 1 = use ".asc"
* 2 = use ".sig"
*/ */
IOBUF IOBUF
open_outfile( const char *iname ) open_outfile( const char *iname, int mode )
{ {
IOBUF a = NULL; IOBUF a = NULL;
int rc; int rc;
@ -101,7 +105,8 @@ open_outfile( const char *iname )
name = opt.outfile; name = opt.outfile;
else { else {
buf = m_alloc(strlen(iname)+4+1); 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; name = buf;
} }
if( !(rc=overwrite_filep( name )) ) { if( !(rc=overwrite_filep( name )) ) {
@ -117,3 +122,27 @@ open_outfile( const char *iname )
return a; 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;
}

View File

@ -26,7 +26,7 @@ struct {
int armor; int armor;
int compress; int compress;
char *outfile; char *outfile;
int reserved0; int textmode;
int batch; /* run in batch mode */ int batch; /* run in batch mode */
int answer_yes; /* answer yes on most questions */ int answer_yes; /* answer yes on most questions */
int answer_no; /* answer no on most questions */ int answer_no; /* answer no on most questions */

View File

@ -252,7 +252,7 @@ int encrypt_data( PKT_encrypted *ed, DEK *dek );
/*-- plaintext.c --*/ /*-- plaintext.c --*/
int handle_plaintext( PKT_plaintext *pt, md_filter_context_t *mfx ); 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 --*/ /*-- comment.c --*/
int write_comment( IOBUF out, const char *s ); int write_comment( IOBUF out, const char *s );

View File

@ -29,6 +29,7 @@
#include "packet.h" #include "packet.h"
#include "ttyio.h" #include "ttyio.h"
#include "filter.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. * Ask for the detached datafile and calculate the digest from it.
* INFILE is the name of the input file.
*/ */
int int
ask_for_detached_datafile( md_filter_context_t *mfx ) ask_for_detached_datafile( md_filter_context_t *mfx, const char *inname )
{ {
char *answer; char *answer = NULL;
FILE *fp; IOBUF fp;
int rc = 0; int rc = 0;
int c; int c;
tty_printf("Detached signature.\n"); fp = open_sigfile( inname ); /* open default file */
answer = tty_get("Please enter name of data file: ");
tty_kill_prompt();
fp = fopen(answer,"rb");
if( !fp ) { if( !fp ) {
log_error("can't open '%s': %s\n", answer, strerror(errno) ); int any=0;
rc = G10ERR_READ_FILE; tty_printf("Detached signature.\n");
goto leave; 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 ) if( mfx->md )
md_putchar(mfx->md, c ); md_putchar(mfx->md, c );
if( mfx->rmd160 ) if( mfx->rmd160 )
@ -152,7 +168,7 @@ ask_for_detached_datafile( md_filter_context_t *mfx )
if( mfx->md5 ) if( mfx->md5 )
md5_putchar(mfx->md5, c ); md5_putchar(mfx->md5, c );
} }
fclose(fp); iobuf_close(fp);
leave: leave:
m_free(answer); m_free(answer);

106
g10/textfilter.c Normal file
View File

@ -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;
}

View File

@ -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

8
include/distfiles Normal file
View File

@ -0,0 +1,8 @@
cipher.h
errors.h
iobuf.h
memory.h
mpi.h
ttyio.h
types.h
util.h

View File

@ -45,6 +45,18 @@ int mpi_debug_mode;
#define BYTES_PER_MPI_LIMB2 8 #define BYTES_PER_MPI_LIMB2 8
typedef unsigned long int mpi_limb_t; typedef unsigned long int mpi_limb_t;
typedef signed long int mpi_limb_signed_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 #else
#error add definions for this machine here #error add definions for this machine here
#endif #endif

View File

@ -21,29 +21,29 @@
#ifndef G10_TYPES_H #ifndef G10_TYPES_H
#define G10_TYPES_H #define G10_TYPES_H
#ifdef __linux__ #include <sys/types.h>
/* FIXME: add stuff to configure to detect for typedefs */
#include <linux/types.h>
#define HAVE_ULONG_TYPEDEF
#define HAVE_USHORT_TYPEDEF
#endif
#ifndef HAVE_BYTE_TYPEDEF #ifndef HAVE_BYTE_TYPEDEF
#undef byte /* maybe there is a macro with this name */
typedef unsigned char byte; typedef unsigned char byte;
#define HAVE_BYTE_TYPEDEF #define HAVE_BYTE_TYPEDEF
#endif #endif
#ifndef HAVE_USHORT_TYPEDEF #ifndef HAVE_USHORT_TYPEDEF
#undef ushort /* maybe there is a macro with this name */
typedef unsigned short ushort; typedef unsigned short ushort;
#define HAVE_USHORT_TYPEDEF #define HAVE_USHORT_TYPEDEF
#endif #endif
#ifndef HAVE_ULONG_TYPEDEF #ifndef HAVE_ULONG_TYPEDEF
#undef ulong /* maybe there is a macro with this name */
typedef unsigned long ulong; typedef unsigned long ulong;
#define HAVE_ULONG_TYPEDEF #define HAVE_ULONG_TYPEDEF
#endif #endif
#ifndef HAVE_U16_TYPEDEF #ifndef HAVE_U16_TYPEDEF
#undef u16 /* maybe there is a macro with this name */
#if SIZEOF_UNSIGNED_INT == 2 #if SIZEOF_UNSIGNED_INT == 2
typedef unsigned int u16; typedef unsigned int u16;
#elif SIZEOF_UNSIGNED_SHORT == 2 #elif SIZEOF_UNSIGNED_SHORT == 2
@ -55,6 +55,7 @@
#endif #endif
#ifndef HAVE_U32_TYPEDEF #ifndef HAVE_U32_TYPEDEF
#undef u32 /* maybe there is a macro with this name */
#if SIZEOF_UNSIGNED_INT == 4 #if SIZEOF_UNSIGNED_INT == 4
typedef unsigned long u32; typedef unsigned long u32;
#elif SIZEOF_UNSIGNED_LONG == 4 #elif SIZEOF_UNSIGNED_LONG == 4

View File

@ -20,6 +20,7 @@
#ifndef G10_UTIL_H #ifndef G10_UTIL_H
#define G10_UTIL_H #define G10_UTIL_H
#include "types.h"
#include "errors.h" #include "errors.h"
#include "types.h" #include "types.h"
#include "mpi.h" #include "mpi.h"

View File

@ -5,12 +5,11 @@ CFLAGS += -O2
SUFFIXES = .S .s SUFFIXES = .S .s
SUBDIRS = generic i386
EXTRA_DIST = config.links EXTRA_DIST = config.links
noinst_LIBRARIES = mpi noinst_LIBRARIES = mpi
noinst_HEADERS = sysdep.h # noinst_HEADERS =
mpi_SOURCES = longlong.h \ mpi_SOURCES = longlong.h \
mpi-add.c \ mpi-add.c \

View File

@ -42,11 +42,10 @@ INCLUDES = -I$(top_srcdir)/include
SUFFIXES = .S .s SUFFIXES = .S .s
SUBDIRS = generic i386
EXTRA_DIST = config.links EXTRA_DIST = config.links
noinst_LIBRARIES = mpi noinst_LIBRARIES = mpi
noinst_HEADERS = sysdep.h # noinst_HEADERS =
mpi_SOURCES = longlong.h \ mpi_SOURCES = longlong.h \
mpi-add.c \ mpi-add.c \
@ -99,8 +98,6 @@ EXTRA_mpi_SOURCES =
LIBFILES = libmpi.a LIBFILES = libmpi.a
AR = ar AR = ar
RANLIB = @RANLIB@ RANLIB = @RANLIB@
HEADERS = $(noinst_HEADERS)
DIST_COMMON = Makefile.am Makefile.in DIST_COMMON = Makefile.am Makefile.in
@ -161,45 +158,13 @@ libmpi.a: $(mpi_OBJECTS) $(mpi_LIBADD)
$(AR) cru libmpi.a $(mpi_OBJECTS) $(mpi_LIBADD) $(AR) cru libmpi.a $(mpi_OBJECTS) $(mpi_LIBADD)
$(RANLIB) libmpi.a $(RANLIB) libmpi.a
# This directory's subdirectories are mostly independent; you can cd ID: $(HEADERS) $(SOURCES)
# into them and run `make' without going through this Makefile. here=`pwd` && cd $(srcdir) && mkid -f$$here/ID $(SOURCES) $(HEADERS)
# 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"
tags: TAGS tags: TAGS
tags-recursive: TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES)
list="$(SUBDIRS)"; for subdir in $$list; do \ here=`pwd` && cd $(srcdir) && etags $(ETAGS_ARGS) $(SOURCES) $(HEADERS) -o $$here/TAGS
(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)
mostlyclean-tags: mostlyclean-tags:
@ -218,14 +183,6 @@ distdir: $(DEP_DISTFILES)
|| ln $(srcdir)/$$file $(distdir)/$$file 2> /dev/null \ || ln $(srcdir)/$$file $(distdir)/$$file 2> /dev/null \
|| cp -p $(srcdir)/$$file $(distdir)/$$file; \ || cp -p $(srcdir)/$$file $(distdir)/$$file; \
done 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 # This fragment is probably only useful for maintainers. It relies on
# GNU make and gcc. It is only included in the generated Makefile.in # GNU make and gcc. It is only included in the generated Makefile.in
@ -253,30 +210,28 @@ $(srcdir)/.deps/%.P: $(srcdir)/%.c
fi fi
# End of maintainer-only section # End of maintainer-only section
info: info-recursive info:
dvi: dvi-recursive dvi:
check: all check-recursive check: all
installcheck: installcheck-recursive installcheck:
all-am: $(LIBFILES) $(HEADERS) Makefile install-exec:
install-exec: install-exec-recursive install-data:
install-data: install-data-recursive install: install-exec install-data all
install: install-recursive
@: @:
uninstall: uninstall-recursive uninstall:
all: all-recursive all-am all: $(LIBFILES) Makefile
install-strip: install-strip:
$(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' install $(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' install
installdirs: installdirs-recursive installdirs:
mostlyclean-generic: mostlyclean-generic:
@ -292,42 +247,29 @@ distclean-generic:
maintainer-clean-generic: maintainer-clean-generic:
test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES)
mostlyclean-am: mostlyclean-noinstLIBRARIES mostlyclean-compile \ mostlyclean: mostlyclean-noinstLIBRARIES mostlyclean-compile \
mostlyclean-tags mostlyclean-generic mostlyclean-tags mostlyclean-generic
clean-am: clean-noinstLIBRARIES clean-compile clean-tags clean-generic \ clean: clean-noinstLIBRARIES clean-compile clean-tags clean-generic \
mostlyclean-am mostlyclean
distclean-am: distclean-noinstLIBRARIES distclean-compile \ distclean: distclean-noinstLIBRARIES distclean-compile distclean-tags \
distclean-tags distclean-generic clean-am distclean-generic clean
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
rm -f config.status 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 "This command is intended for maintainers to use;"
@echo "it deletes files that may require special tools to rebuild." @echo "it deletes files that may require special tools to rebuild."
.PHONY: default mostlyclean-noinstLIBRARIES distclean-noinstLIBRARIES \ .PHONY: default mostlyclean-noinstLIBRARIES distclean-noinstLIBRARIES \
clean-noinstLIBRARIES maintainer-clean-noinstLIBRARIES \ clean-noinstLIBRARIES maintainer-clean-noinstLIBRARIES \
mostlyclean-compile distclean-compile clean-compile \ mostlyclean-compile distclean-compile clean-compile \
maintainer-clean-compile install-data-recursive \ maintainer-clean-compile tags mostlyclean-tags distclean-tags \
uninstall-data-recursive install-exec-recursive \ clean-tags maintainer-clean-tags distdir info dvi check installcheck \
uninstall-exec-recursive installdirs-recursive uninstalldirs-recursive \ install-exec install-data install uninstall all installdirs \
all-recursive check-recursive installcheck-recursive info-recursive \ mostlyclean-generic distclean-generic clean-generic \
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-generic clean mostlyclean distclean maintainer-clean maintainer-clean-generic clean mostlyclean distclean maintainer-clean
CFLAGS += -O2 CFLAGS += -O2

3
mpi/alpha/distfiles Normal file
View File

@ -0,0 +1,3 @@
udiv-qrnnd.S

161
mpi/alpha/udiv-qrnnd.S Normal file
View File

@ -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

View File

@ -2,9 +2,22 @@
# this should set $mpi_ln_src and mpi_ln_dst. # this should set $mpi_ln_src and mpi_ln_dst.
# Note: this is called from the above directory. # 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 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*-*-*) i[3456]86*-*-*)
echo '#define ELF_SYNTAX' >>./mpi/asm-syntax.h echo '#define ELF_SYNTAX' >>./mpi/asm-syntax.h
echo '#include "./i386/syntax.h"' >>./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-*-*) i[56]86*-*-* | pentium-*-* | pentiumpro-*-*)
echo '#define ELF_SYNTAX' >>./mpi/asm-syntax.h echo '#define ELF_SYNTAX' >>./mpi/asm-syntax.h
echo '#include "./i586/syntax.h"' >>./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 echo '/* No assembler modules configured */' >>./mpi/asm-syntax.h
@ -21,9 +54,38 @@ case "${target}" in
;; ;;
esac 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 # 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" mpih-shift mpih-sub1"
mpi_ln_objects= mpi_ln_objects=

7
mpi/generic/distfiles Normal file
View File

@ -0,0 +1,7 @@
mpih-add1.c
mpih-mul1.c
mpih-mul2.c
mpih-mul3.c
mpih-shift.c
mpih-sub1.c

4
mpi/hppa/distfiles Normal file
View File

@ -0,0 +1,4 @@
mpih-add1.S
udiv-qrnnd.S

70
mpi/hppa/mpih-add1.S Normal file
View File

@ -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

297
mpi/hppa/udiv-qrnnd.S Normal file
View File

@ -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

8
mpi/i386/distfiles Normal file
View File

@ -0,0 +1,8 @@
mpih-add1.S
mpih-mul1.S
mpih-mul2.S
mpih-mul3.S
mpih-shift.S
mpih-sub1.S
syntax.h

View File

@ -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*/ #endif /*G10_MPI_INLINE_H*/

View File

@ -32,6 +32,21 @@
#include "mpi.h" #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 */ 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_size_t size);
mpi_limb_t mpihelp_mul( mpi_ptr_t prodp, mpi_ptr_t up, mpi_size_t usize, 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); 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) --*/ /*-- mpihelp-mul_1.c (or xxx/cpu/*.S) --*/
mpi_limb_t mpihelp_mul_1( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, mpi_limb_t mpihelp_mul_1( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr,

View File

@ -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 mp_marker=NULL, bp_marker=NULL, ep_marker=NULL;
mpi_ptr_t xp_marker=NULL; mpi_ptr_t xp_marker=NULL;
int assign_rp=0; int assign_rp=0;
mpi_ptr_t tspace = NULL;
mpi_size_t tsize;
esize = exp->nlimbs; esize = exp->nlimbs;
msize = mod->nlimbs; msize = mod->nlimbs;
@ -179,7 +181,23 @@ mpi_powm( MPI res, MPI base, MPI exp, MPI mod)
mpi_ptr_t tp; mpi_ptr_t tp;
mpi_size_t xsize; 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; xsize = 2 * rsize;
if( xsize > msize ) { if( xsize > msize ) {
mpihelp_divrem(xp + msize, 0, xp, xsize, mp, 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( bp_marker ) mpi_free_limb_space( bp_marker );
if( ep_marker ) mpi_free_limb_space( ep_marker ); if( ep_marker ) mpi_free_limb_space( ep_marker );
if( xp_marker ) mpi_free_limb_space( xp_marker ); if( xp_marker ) mpi_free_limb_space( xp_marker );
if( tspace ) mpi_free_limb_space( tspace );
} }

View File

@ -33,17 +33,6 @@
#include "mpi-internal.h" #include "mpi-internal.h"
#include "longlong.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) \ #define MPN_MUL_N_RECURSE(prodp, up, vp, size, tspace) \
@ -57,9 +46,9 @@
#define MPN_SQR_N_RECURSE(prodp, up, size, tspace) \ #define MPN_SQR_N_RECURSE(prodp, up, size, tspace) \
do { \ do { \
if ((size) < KARATSUBA_THRESHOLD) \ if ((size) < KARATSUBA_THRESHOLD) \
sqr_n_basecase (prodp, up, size); \ mpih_sqr_n_basecase (prodp, up, size); \
else \ else \
sqr_n (prodp, up, size, tspace); \ mpih_sqr_n (prodp, up, size, tspace); \
} while (0); } while (0);
@ -235,8 +224,8 @@ mul_n( mpi_ptr_t prodp, mpi_ptr_t up, mpi_ptr_t vp,
} }
static void void
sqr_n_basecase( mpi_ptr_t prodp, mpi_ptr_t up, mpi_size_t size ) mpih_sqr_n_basecase( mpi_ptr_t prodp, mpi_ptr_t up, mpi_size_t size )
{ {
mpi_size_t i; mpi_size_t i;
mpi_limb_t cy_limb; 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 void
sqr_n( mpi_ptr_t prodp, mpi_ptr_t up, mpi_size_t size, mpi_ptr_t tspace) mpih_sqr_n( mpi_ptr_t prodp, mpi_ptr_t up, mpi_size_t size, mpi_ptr_t tspace)
{ {
if( size & 1 ) { if( size & 1 ) {
/* The size is odd, the code code below doesn't handle that. /* 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( up == vp ) {
if( size < KARATSUBA_THRESHOLD ) if( size < KARATSUBA_THRESHOLD )
sqr_n_basecase( prodp, up, size ); mpih_sqr_n_basecase( prodp, up, size );
else { else {
mpi_ptr_t tspace; mpi_ptr_t tspace;
tspace = mpi_alloc_limb_space( 2 * size, 0 ); 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 ); mpi_free_limb_space( tspace );
} }
} }

4
scripts/distfiles Normal file
View File

@ -0,0 +1,4 @@
config.guess
config.sub
install-sh
mkinstalldirs

View File

@ -579,12 +579,14 @@ underflow(IOBUF a)
size_t dummy_len; size_t dummy_len;
/* and tell the filter to free it self */ /* and tell the filter to free it self */
if( (rc = a->filter(a->filter_ov, IOBUFCTRL_FREE, a->chain, if( a->filter != file_filter ) {
NULL, &dummy_len)) ) if( (rc = a->filter(a->filter_ov, IOBUFCTRL_FREE, a->chain,
log_error("IOBUFCTRL_FREE failed: %s\n", g10_errstr(rc) ); NULL, &dummy_len)) )
a->filter = NULL; log_error("IOBUFCTRL_FREE failed: %s\n", g10_errstr(rc) );
a->desc = NULL; a->filter = NULL;
a->filter_ov = NULL; a->desc = NULL;
a->filter_ov = NULL;
}
a->filter_eof = 1; a->filter_eof = 1;
} }