mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-03 12:11:33 +01:00
changed configuration stuff, replaced some Makefile.am by distfiles.
This commit is contained in:
parent
a112009805
commit
c351df1dc5
11
Makefile.am
11
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
|
||||
|
||||
|
13
Makefile.in
13
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.
|
||||
|
17
acconfig.h
17
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*/
|
||||
|
@ -24,6 +24,6 @@ cipher_SOURCES = blowfish.c \
|
||||
md.c \
|
||||
smallprime.c
|
||||
|
||||
##cipher_LIBADD = rsa.o
|
||||
cipher_LIBADD = rsa.o
|
||||
|
||||
|
||||
|
@ -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 =
|
||||
|
20
config.h.in
20
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*/
|
||||
|
106
configure.in
106
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 \
|
||||
|
||||
AC_OUTPUT([ Makefile \
|
||||
util/Makefile \
|
||||
mpi/Makefile \
|
||||
cipher/Makefile \
|
||||
include/Makefile \
|
||||
g10/Makefile tools/Makefile ],
|
||||
[echo timestamp > stamp-h ] )
|
||||
|
||||
g10/Makefile \
|
||||
tools/Makefile \
|
||||
], [echo timestamp > stamp-h ] )
|
||||
|
||||
|
@ -21,6 +21,7 @@ g10_SOURCES = g10.c \
|
||||
mainproc.c \
|
||||
armor.c \
|
||||
mdfilter.c \
|
||||
textfilter.c \
|
||||
cipher.c \
|
||||
options.h \
|
||||
openfile.c \
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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 );
|
||||
|
@ -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 */
|
||||
|
15
g10/filter.h
15
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*/
|
||||
|
@ -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 */
|
||||
|
36
g10/keygen.c
36
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
|
||||
|
@ -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 );
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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 */
|
||||
|
@ -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 );
|
||||
|
@ -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);
|
||||
|
106
g10/textfilter.c
Normal file
106
g10/textfilter.c
Normal 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;
|
||||
}
|
||||
|
||||
|
||||
|
@ -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
8
include/distfiles
Normal file
@ -0,0 +1,8 @@
|
||||
cipher.h
|
||||
errors.h
|
||||
iobuf.h
|
||||
memory.h
|
||||
mpi.h
|
||||
ttyio.h
|
||||
types.h
|
||||
util.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
|
||||
|
@ -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
|
||||
|
@ -20,6 +20,7 @@
|
||||
#ifndef G10_UTIL_H
|
||||
#define G10_UTIL_H
|
||||
|
||||
#include "types.h"
|
||||
#include "errors.h"
|
||||
#include "types.h"
|
||||
#include "mpi.h"
|
||||
|
@ -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 \
|
||||
|
112
mpi/Makefile.in
112
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
|
||||
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-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
|
||||
clean: clean-noinstLIBRARIES clean-compile clean-tags clean-generic \
|
||||
mostlyclean
|
||||
|
||||
distclean-am: distclean-noinstLIBRARIES distclean-compile \
|
||||
distclean-tags distclean-generic clean-am
|
||||
|
||||
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
|
||||
|
3
mpi/alpha/distfiles
Normal file
3
mpi/alpha/distfiles
Normal file
@ -0,0 +1,3 @@
|
||||
|
||||
udiv-qrnnd.S
|
||||
|
161
mpi/alpha/udiv-qrnnd.S
Normal file
161
mpi/alpha/udiv-qrnnd.S
Normal 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
|
@ -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=
|
||||
|
7
mpi/generic/distfiles
Normal file
7
mpi/generic/distfiles
Normal 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
4
mpi/hppa/distfiles
Normal file
@ -0,0 +1,4 @@
|
||||
|
||||
mpih-add1.S
|
||||
udiv-qrnnd.S
|
||||
|
70
mpi/hppa/mpih-add1.S
Normal file
70
mpi/hppa/mpih-add1.S
Normal 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
297
mpi/hppa/udiv-qrnnd.S
Normal 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
8
mpi/i386/distfiles
Normal 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
|
||||
|
@ -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*/
|
||||
|
@ -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,
|
||||
|
@ -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 );
|
||||
}
|
||||
|
||||
|
@ -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 );
|
||||
}
|
||||
}
|
||||
|
4
scripts/distfiles
Normal file
4
scripts/distfiles
Normal file
@ -0,0 +1,4 @@
|
||||
config.guess
|
||||
config.sub
|
||||
install-sh
|
||||
mkinstalldirs
|
14
util/iobuf.c
14
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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user