diff --git a/Makefile.in b/Makefile.in index 95edd9711..3c7b2a42b 100644 --- a/Makefile.in +++ b/Makefile.in @@ -72,6 +72,7 @@ G10_LOCALEDIR = @G10_LOCALEDIR@ GENCAT = @GENCAT@ GMOFILES = @GMOFILES@ GMSGFMT = @GMSGFMT@ +HAVE_ZLIB_H = @HAVE_ZLIB_H@ INSTOBJEXT = @INSTOBJEXT@ INTLDEPS = @INTLDEPS@ INTLLIBS = @INTLLIBS@ diff --git a/VERSION b/VERSION index 0c62199f1..f3bfaf01e 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.2.1 +0.2.1w diff --git a/acinclude.m4 b/acinclude.m4 index 0c30b7d68..5b9d35518 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -311,7 +311,7 @@ define(WK_CHECK_ENDIAN, #include ], [ #if BYTE_ORDER != BIG_ENDIAN not big endian - #endif], wk_cv_c_endian=big, wk_cv_c_endian=big)]) + #endif], wk_cv_c_endian=big, wk_cv_c_endian=little)]) if test "$wk_cv_c_endian" = unknown; then AC_TRY_RUN([main () { /* Are we little or big endian? From Harbison&Steele. */ diff --git a/cipher/Makefile.in b/cipher/Makefile.in index a1cfa5acd..9e4860f6a 100644 --- a/cipher/Makefile.in +++ b/cipher/Makefile.in @@ -72,6 +72,7 @@ G10_LOCALEDIR = @G10_LOCALEDIR@ GENCAT = @GENCAT@ GMOFILES = @GMOFILES@ GMSGFMT = @GMSGFMT@ +HAVE_ZLIB_H = @HAVE_ZLIB_H@ INSTOBJEXT = @INSTOBJEXT@ INTLDEPS = @INTLDEPS@ INTLLIBS = @INTLLIBS@ diff --git a/cipher/elgamal.c b/cipher/elgamal.c index 1f1699f8f..9e6805d62 100644 --- a/cipher/elgamal.c +++ b/cipher/elgamal.c @@ -142,6 +142,9 @@ elg_generate( ELG_public_key *pk, ELG_secret_key *sk, unsigned nbits ) /* select a random number which has these properties: * 0 < x < p-1 + * This must be a very good random number because this is the + * secret part. The prime is public and may be shared anyware, + * so a random generator level of 1 has been used for the prime */ x = mpi_alloc_secure( nbits/BITS_PER_MPI_LIMB ); if( DBG_CIPHER ) diff --git a/cipher/md.c b/cipher/md.c index eb7b7b845..221cf7199 100644 --- a/cipher/md.c +++ b/cipher/md.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include "util.h" #include "cipher.h" diff --git a/cipher/primegen.c b/cipher/primegen.c index 9514fdae8..9d91ae4df 100644 --- a/cipher/primegen.c +++ b/cipher/primegen.c @@ -58,6 +58,12 @@ generate_public_prime( unsigned nbits ) } +/**************** + * We do not need to use the strongest RNG because we gain no extra + * security from it - The prime number is public and we could also + * offer the factors for those who are willing to check that it is + * indeed a strong prime. + */ MPI generate_elg_prime( unsigned pbits, unsigned qbits, MPI g ) { @@ -87,7 +93,7 @@ generate_elg_prime( unsigned pbits, unsigned qbits, MPI g ) pbits, qbits, fbits, n ); prime = mpi_alloc( (pbits + BITS_PER_MPI_LIMB - 1) / BITS_PER_MPI_LIMB ); - q = gen_prime( qbits, 0, 2 ); + q = gen_prime( qbits, 0, 1 ); /* allocate an array to hold the factors + 2 for later usage */ factors = m_alloc_clear( (n+2) * sizeof *factors ); @@ -112,7 +118,7 @@ generate_elg_prime( unsigned pbits, unsigned qbits, MPI g ) perms = m_alloc_clear( m ); for(i=0; i < n; i++ ) { perms[i] = 1; - pool[i] = gen_prime( fbits, 0, 2 ); + pool[i] = gen_prime( fbits, 0, 1 ); factors[i] = pool[i]; } } @@ -121,7 +127,7 @@ generate_elg_prime( unsigned pbits, unsigned qbits, MPI g ) for(i=j=0; i < m && j < n ; i++ ) if( perms[i] ) { if( !pool[i] ) - pool[i] = gen_prime( fbits, 0, 2 ); + pool[i] = gen_prime( fbits, 0, 1 ); factors[j++] = pool[i]; } if( i == n ) { @@ -142,7 +148,7 @@ generate_elg_prime( unsigned pbits, unsigned qbits, MPI g ) count1 = 0; qbits++; fputc('>', stderr); - q = gen_prime( qbits, 0, 2 ); + q = gen_prime( qbits, 0, 1 ); goto next_try; } } @@ -153,7 +159,7 @@ generate_elg_prime( unsigned pbits, unsigned qbits, MPI g ) count2 = 0; qbits--; fputc('<', stderr); - q = gen_prime( qbits, 0, 2 ); + q = gen_prime( qbits, 0, 1 ); goto next_try; } } @@ -379,8 +385,9 @@ is_prime( MPI n, int steps, int *count ) else { mpi_set_bytes( x, nbits-1, get_random_byte, 0 ); /* work around a bug in mpi_set_bytes */ - if( mpi_test_bit( x, nbits-2 ) ) + if( mpi_test_bit( x, nbits-2 ) ) { mpi_set_highbit( x, nbits-2 ); /* clear all higher bits */ + } else { mpi_set_highbit( x, nbits-2 ); mpi_clear_bit( x, nbits-2 ); diff --git a/cipher/random.c b/cipher/random.c index 3355abf1a..ac98f54c2 100644 --- a/cipher/random.c +++ b/cipher/random.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include "util.h" diff --git a/configure.in b/configure.in index e83e10d5d..c7fe37b67 100644 --- a/configure.in +++ b/configure.in @@ -6,8 +6,8 @@ dnl (Process this file with autoconf to produce a configure script.) AC_INIT(g10/g10.c) AC_CONFIG_AUX_DIR(scripts) dnl Ooops: automake 1.2d looks for AC_CONFIG_HEADER (and not AM_..) -dnl to decide where config.h is - so we have to add it to -dnl every makefile.am +dnl to decide where config.h is - so we have to add -I.. to +dnl every Makefile.am AM_CONFIG_HEADER(config.h) @@ -34,10 +34,20 @@ AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE") AC_DEFINE_UNQUOTED(G10_LOCALEDIR, "$G10_LOCALEDIR") AC_ARG_ENABLE(m-debug, -[ --enable-m-debug Enable debugging of memory allocation]) +[ --enable-m-debug Enable debugging of memory allocation]) if test "$enableval" = y || test "$enableval" = yes; then AC_DEFINE(M_DEBUG) fi + +dnl Some systems have a broken zlib. "--disable-zlib" avoids it's usage +enableval=yes +AC_ARG_ENABLE(zlib, +[ --disable-zlib Avoid usage of zlib]) +if test "$enableval" = y || test "$enableval" = yes; then + g10_use_zlib=yes +else + g10_use_zlib=no +fi CFLAGS="-g -Wall" @@ -159,13 +169,15 @@ AC_MSG_RESULT() fi AC_SUBST(MPI_EXTRA_ASM_OBJS) - dnl Do we have zlib? Must do it here because Solaris failed dnl when compiling a conftest (due to the "-lz" from LIBS). +if test "$g10_use_zlib" = "yes"; then AC_CHECK_HEADERS(zlib.h, [LIBS="$LIBS -lz"], AC_MSG_WARN([zlib missing - creating without ZLIB support!]) ) +fi +AC_SUBST(HAVE_ZLIB_H) dnl checking whether we have other cipher source files CIPHER_EXTRA_OBJS="" diff --git a/g10/Makefile.in b/g10/Makefile.in index 68c10cba3..808d99fdb 100644 --- a/g10/Makefile.in +++ b/g10/Makefile.in @@ -72,6 +72,7 @@ G10_LOCALEDIR = @G10_LOCALEDIR@ GENCAT = @GENCAT@ GMOFILES = @GMOFILES@ GMSGFMT = @GMSGFMT@ +HAVE_ZLIB_H = @HAVE_ZLIB_H@ INSTOBJEXT = @INSTOBJEXT@ INTLDEPS = @INTLDEPS@ INTLLIBS = @INTLLIBS@ diff --git a/g10/armor.c b/g10/armor.c index 3a6fc41f3..7269b325a 100644 --- a/g10/armor.c +++ b/g10/armor.c @@ -698,7 +698,7 @@ armor_filter( void *opaque, int control, iobuf_writestr(a, head_strings[afx->what] ); iobuf_writestr(a, "-----\n"); iobuf_writestr(a, "Version: G10 pre-release " VERSION "\n"); - iobuf_writestr(a, "Comment: This is a alpha test version!\n\n"); + iobuf_writestr(a, "Comment: This is an alpha test version!\n\n"); afx->status++; afx->idx = 0; afx->idx2 = 0; diff --git a/g10/build-packet.c b/g10/build-packet.c index b0fd0859a..2e1a48337 100644 --- a/g10/build-packet.c +++ b/g10/build-packet.c @@ -211,7 +211,7 @@ hash_public_cert( MD_HANDLE md, PKT_public_cert *pkc ) int rc = 0; int c; IOBUF a = iobuf_temp(); - FILE *fp = fopen("dump.pkc", "a"); + /* FILE *fp = fopen("dump.pkc", "a");*/ /* build the packet */ init_packet(&pkt); @@ -220,10 +220,10 @@ hash_public_cert( MD_HANDLE md, PKT_public_cert *pkc ) if( (rc = build_packet( a, &pkt )) ) log_fatal("build public_cert for hashing failed: %s\n", g10_errstr(rc)); while( (c=iobuf_get(a)) != -1 ) { - putc( c, fp); + /* putc( c, fp);*/ md_putc( md, c ); } - fclose(fp); + /*fclose(fp);*/ iobuf_cancel(a); } diff --git a/g10/compress.c b/g10/compress.c index 8f8b5e6de..c237b4ac7 100644 --- a/g10/compress.c +++ b/g10/compress.c @@ -234,7 +234,6 @@ compress_filter( void *opaque, int control, IOBUF a, byte *buf, size_t *ret_len) { size_t size = *ret_len; - compress_filter_context_t *zfx = opaque; int c, rc=0; size_t n; diff --git a/g10/g10.c b/g10/g10.c index 16ec5c277..bbc46285d 100644 --- a/g10/g10.c +++ b/g10/g10.c @@ -146,6 +146,9 @@ set_cmd( enum cmd_values *ret_cmd, enum cmd_values new_cmd ) cmd = aSignEncr; else if( cmd == aKMode && new_cmd == aSym ) cmd = aKModeC; + else if( ( cmd == aSign && new_cmd == aClearsig ) + || ( cmd == aClearsig && new_cmd == aSign ) ) + cmd = aClearsig; else { log_error(_("conflicting commands\n")); g10_exit(2); @@ -294,11 +297,11 @@ main( int argc, char **argv ) break; case 'z': opt.compress = pargs.r.ret_int; break; case 'a': opt.armor = 1; opt.no_armor=0; break; + case 'd': break; /* it is default */ case 'c': set_cmd( &cmd , aSym); break; case 'o': opt.outfile = pargs.r.ret_str; break; case 'e': set_cmd( &cmd, aEncr); break; - case 'b': detached_sig = 1; - /* fall trough */ + case 'b': detached_sig = 1; /* fall trough */ case 's': set_cmd( &cmd, aSign ); break; case 't': set_cmd( &cmd , aClearsig); break; case 'u': /* store the local users */ diff --git a/g10/g10maint.c b/g10/g10maint.c index f02bb11e7..a6ba7dc63 100644 --- a/g10/g10maint.c +++ b/g10/g10maint.c @@ -179,6 +179,7 @@ main( int argc, char **argv ) { 526, "no-verbose", 0, "\r"}, { 531, "list-trustdb",0 , "\r"}, { 533, "list-trust-path",0, "\r"}, + { 532, "quick-random", 0, "\r"}, { 534, "no-comment", 0, N_("do not write comment packets")}, { 535, "completes-needed", 1, N_("(default is 1)")}, { 536, "marginals-needed", 1, N_("(default is 3)")}, diff --git a/g10/getkey.c b/g10/getkey.c index eea9b6beb..6564f1095 100644 --- a/g10/getkey.c +++ b/g10/getkey.c @@ -454,12 +454,12 @@ scan_keyring( PKT_public_cert *pkc, u32 *keyid, if( !DBG_CACHE ) ; else if( shortkeyid ) - log_debug("scan_keyring %s for %08lx\n", filename, keyid[1] ); + log_debug("scan_keyring %s for %08lx\n", filename, (ulong)keyid[1] ); else if( name ) log_debug("scan_keyring %s for '%s'\n", filename, name ); else if( keyid ) log_debug("scan_keyring %s for %08lx %08lx\n", filename, - keyid[0], keyid[1] ); + (ulong)keyid[0], (ulong)keyid[1] ); else log_debug("scan_keyring %s (all)\n", filename ); @@ -740,12 +740,12 @@ get_user_id_string( u32 *keyid ) for(r=user_id_db; r; r = r->next ) if( r->keyid[0] == keyid[0] && r->keyid[1] == keyid[1] ) { p = m_alloc( r->len + 10 ); - sprintf(p, "%08lX %.*s", keyid[1], r->len, r->name ); + sprintf(p, "%08lX %.*s", (ulong)keyid[1], r->len, r->name ); return p; } } while( ++pass < 2 && !get_pubkey( NULL, keyid ) ); p = m_alloc( 15 ); - sprintf(p, "%08lX [?]", keyid[1] ); + sprintf(p, "%08lX [?]", (ulong)keyid[1] ); return p; } diff --git a/g10/mainproc.c b/g10/mainproc.c index 607d7125a..70a50c615 100644 --- a/g10/mainproc.c +++ b/g10/mainproc.c @@ -476,7 +476,7 @@ list_node( CTX c, KBNODE node ) } } printf("%c %08lX %s ", - sigrc, sig->keyid[1], datestr_from_sig(sig)); + sigrc, (ulong)sig->keyid[1], datestr_from_sig(sig)); if( sigrc == '%' ) printf("[%s] ", g10_errstr(rc2) ); else if( sigrc == '?' ) @@ -597,7 +597,7 @@ check_sig_and_print( CTX c, KBNODE node ) else { write_status( STATUS_ERRSIG ); log_error("Can't check signature made by %08lX: %s\n", - sig->keyid[1], g10_errstr(rc) ); + (ulong)sig->keyid[1], g10_errstr(rc) ); } return rc; } diff --git a/g10/parse-packet.c b/g10/parse-packet.c index 1a11ec467..886bc66e3 100644 --- a/g10/parse-packet.c +++ b/g10/parse-packet.c @@ -343,7 +343,7 @@ parse_publickey( IOBUF inp, int pkttype, unsigned long pktlen, PACKET *packet ) k->pubkey_algo = iobuf_get_noeof(inp); pktlen--; if( list_mode ) printf(":public key encoded packet: keyid %08lX%08lX\n", - k->keyid[0], k->keyid[1]); + (ulong)k->keyid[0], (ulong)k->keyid[1]); if( k->pubkey_algo == PUBKEY_ALGO_ELGAMAL ) { n = pktlen; k->d.elg.a = mpi_read(inp, &n, 0); pktlen -=n; @@ -400,8 +400,8 @@ parse_signature( IOBUF inp, int pkttype, unsigned long pktlen, if( list_mode ) printf(":signature packet: keyid %08lX%08lX\n" "\tversion %d, created %lu, md5len %d, sigclass %02x\n", - sig->keyid[0], sig->keyid[1], - version, sig->timestamp, md5_len, sig->sig_class ); + (ulong)sig->keyid[0], (ulong)sig->keyid[1], + version, (ulong)sig->timestamp, md5_len, sig->sig_class ); if( sig->pubkey_algo == PUBKEY_ALGO_ELGAMAL ) { if( pktlen < 5 ) { log_error("packet(%d) too short\n", pkttype); @@ -477,7 +477,7 @@ parse_onepass_sig( IOBUF inp, int pkttype, unsigned long pktlen, if( list_mode ) printf(":onepass_sig packet: keyid %08lX%08lX\n" "\tversion %d, sigclass %02x, digest %d, pubkey %d, last=%d\n", - ops->keyid[0], ops->keyid[1], + (ulong)ops->keyid[0], (ulong)ops->keyid[1], version, ops->sig_class, ops->digest_algo, ops->pubkey_algo, ops->last ); @@ -832,14 +832,14 @@ parse_plaintext( IOBUF inp, int pkttype, unsigned long pktlen, PACKET *pkt ) printf(":literal data packet:\n" "\tmode %c, created %lu, name=\"", mode >= ' ' && mode <'z'? mode : '?', - pt->timestamp ); + (ulong)pt->timestamp ); for(p=pt->name,i=0; i < namelen; p++, i++ ) { if( *p >= ' ' && *p <= 'z' ) putchar(*p); else printf("\\x%02x", *p ); } - printf("\",\n\traw data: %lu bytes\n", pt->len ); + printf("\",\n\traw data: %lu bytes\n", (ulong)pt->len ); } leave: diff --git a/g10/ringedit.c b/g10/ringedit.c index ad5706c1e..61f915c17 100644 --- a/g10/ringedit.c +++ b/g10/ringedit.c @@ -680,6 +680,7 @@ keyring_delete( KBPOS *kbpos ) } len = kbpos->length; + assert( len < 100000 ); /* there is a bug somewhere */ /*log_debug("writing a dummy packet of length %lu\n", (ulong)len);*/ if( len < 2 ) diff --git a/g10/seckey-cert.c b/g10/seckey-cert.c index 0fa297914..855e3d1b9 100644 --- a/g10/seckey-cert.c +++ b/g10/seckey-cert.c @@ -317,7 +317,7 @@ protect_secret_key( PKT_secret_cert *cert, DEK *dek ) if( cert->pubkey_algo == PUBKEY_ALGO_ELGAMAL ) return protect_elg( cert, dek ); - #ifdef 0 /* noy yet implemented */ + #if 0 /* noy yet implemented */ else if( cert->pubkey_algo == PUBKEY_ALGO_RSA ) return protect_rsa( cert, dek ); #endif diff --git a/g10/sign.c b/g10/sign.c index 31fe2bd05..ee9b98254 100644 --- a/g10/sign.c +++ b/g10/sign.c @@ -570,7 +570,8 @@ sign_key( const char *username, STRLIST locusr ) && (node->pkt->pkt.signature->sig_class&~3) == 0x10 ) { if( akeyid[0] == node->pkt->pkt.signature->keyid[0] && akeyid[1] == node->pkt->pkt.signature->keyid[1] ) { - log_info("Already signed by keyid %08lX\n", akeyid[1] ); + log_info("Already signed by keyid %08lX\n", + (ulong)akeyid[1] ); skc_rover->mark = 1; } } @@ -833,7 +834,7 @@ make_keysig_packet( PKT_signature **ret_sig, PKT_public_cert *pkc, assert( sigclass >= 0x10 && sigclass <= 0x13 ); md = md_open( digest_algo, 0 ); - /* hash the public key certificate */ + /* hash the public key certificate and the user id */ hash_public_cert( md, pkc ); md_write( md, uid->name, uid->len ); /* and make the signature packet */ @@ -849,6 +850,7 @@ make_keysig_packet( PKT_signature **ret_sig, PKT_public_cert *pkc, md_putc( md, (a >> 8) & 0xff ); md_putc( md, a & 0xff ); } + md_final(md); rc = complete_sig( sig, skc, md ); diff --git a/g10/status.c b/g10/status.c index 6c660b7ee..baae1e96e 100644 --- a/g10/status.c +++ b/g10/status.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include "status.h" diff --git a/g10/trustdb.c b/g10/trustdb.c index 116d2679f..d317a665a 100644 --- a/g10/trustdb.c +++ b/g10/trustdb.c @@ -371,8 +371,8 @@ dump_record( ulong rnum, TRUSTREC *rec, FILE *fp ) case RECTYPE_VER: fprintf(fp, "version\n"); break; case RECTYPE_DIR: - fprintf(fp, "dir keyid=%08lx, key=%lu, ctl=%lu, sig=%lu", - rec->r.dir.keyid[1], + fprintf(fp, "dir keyid=%08lX, key=%lu, ctl=%lu, sig=%lu", + (ulong)rec->r.dir.keyid[1], rec->r.dir.keyrec, rec->r.dir.ctlrec, rec->r.dir.sigrec ); if( rec->r.dir.no_sigs == 1 ) fputs(", (none)", fp ); @@ -382,8 +382,8 @@ dump_record( ulong rnum, TRUSTREC *rec, FILE *fp ) fputs(", (revoked)", fp ); putc('\n', fp); break; - case RECTYPE_KEY: fprintf(fp, "key keyid=%08lx, own=%lu, ownertrust=%02x\n", - rec->r.key.keyid[1], + case RECTYPE_KEY: fprintf(fp, "key keyid=%08lX, own=%lu, ownertrust=%02x\n", + (ulong)rec->r.key.keyid[1], rec->r.key.owner, rec->r.key.ownertrust ); break; case RECTYPE_CTL: fprintf(fp, "ctl\n"); diff --git a/include/types.h b/include/types.h index 0a2d8752f..e5804be66 100644 --- a/include/types.h +++ b/include/types.h @@ -57,9 +57,9 @@ #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 typedef unsigned int u32; + #elif SIZEOF_UNSIGNED_LONG == 4 + typedef unsigned long u32; #else #error no typedef for u32 #endif diff --git a/mpi/Makefile.am b/mpi/Makefile.am index 11b15dd3b..3c4995cc4 100644 --- a/mpi/Makefile.am +++ b/mpi/Makefile.am @@ -11,6 +11,8 @@ EXTRA_DIST = config.links noinst_LIBRARIES = libmpi.a # noinst_HEADERS = + + libmpi_a_SOURCES = longlong.h \ mpi-add.c \ mpi-bit.c \ @@ -31,11 +33,16 @@ libmpi_a_SOURCES = longlong.h \ mpih-mul.c \ mpiutil.c -libmpi_a_LIBADD = mpih-mul1.o \ - mpih-mul2.o \ - mpih-mul3.o \ - mpih-add1.o \ - mpih-sub1.o \ - mpih-shift.o @MPI_EXTRA_ASM_OBJS@ +# Note this objects are actually links, the sourcefiles are +# distributed by special code in dist-hook +common_asm_objects = mpih-mul1.o \ + mpih-mul2.o \ + mpih-mul3.o \ + mpih-add1.o \ + mpih-sub1.o \ + mpih-shift.o +libmpi_a_LIBADD = $(common_asm_objects) @MPI_EXTRA_ASM_OBJS@ + +$(LIBRARIES): $(common_asm_objects) @MPI_EXTRA_ASM_OBJS@ diff --git a/mpi/Makefile.in b/mpi/Makefile.in index 98b42753d..c9ae7cfd0 100644 --- a/mpi/Makefile.in +++ b/mpi/Makefile.in @@ -72,6 +72,7 @@ G10_LOCALEDIR = @G10_LOCALEDIR@ GENCAT = @GENCAT@ GMOFILES = @GMOFILES@ GMSGFMT = @GMSGFMT@ +HAVE_ZLIB_H = @HAVE_ZLIB_H@ INSTOBJEXT = @INSTOBJEXT@ INTLDEPS = @INTLDEPS@ INTLLIBS = @INTLLIBS@ @@ -114,12 +115,16 @@ libmpi_a_SOURCES = longlong.h \ mpih-mul.c \ mpiutil.c -libmpi_a_LIBADD = mpih-mul1.o \ - mpih-mul2.o \ - mpih-mul3.o \ - mpih-add1.o \ - mpih-sub1.o \ - mpih-shift.o @MPI_EXTRA_ASM_OBJS@ +# Note this objects are actually links, the sourcefiles are +# distributed by special code in dist-hook +common_asm_objects = mpih-mul1.o \ + mpih-mul2.o \ + mpih-mul3.o \ + mpih-add1.o \ + mpih-sub1.o \ + mpih-shift.o + +libmpi_a_LIBADD = $(common_asm_objects) @MPI_EXTRA_ASM_OBJS@ mkinstalldirs = $(SHELL) $(top_srcdir)/scripts/mkinstalldirs CONFIG_HEADER = ../config.h CONFIG_CLEAN_FILES = @@ -328,6 +333,8 @@ maintainer-clean-generic clean mostlyclean distclean maintainer-clean CFLAGS += -O2 +$(LIBRARIES): $(common_asm_objects) @MPI_EXTRA_ASM_OBJS@ + # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: diff --git a/mpi/mpi-bit.c b/mpi/mpi-bit.c index 0f69b6580..0d8cab706 100644 --- a/mpi/mpi-bit.c +++ b/mpi/mpi-bit.c @@ -45,6 +45,7 @@ __clz_tab[] = #endif +#define A_LIMB_1 ((mpi_limb_t)1) @@ -88,7 +89,7 @@ mpi_test_bit( MPI a, unsigned n ) if( limbno >= a->nlimbs ) return 0; /* too far left: this is a 0 */ limb = a->d[limbno]; - return (limb & (1 << bitno))? 1: 0; + return (limb & (A_LIMB_1 << bitno))? 1: 0; } @@ -108,7 +109,7 @@ mpi_set_bit( MPI a, unsigned n ) mpi_resize(a, limbno+1 ); a->nlimbs = limbno+1; } - a->d[limbno] |= (1<d[limbno] |= (A_LIMB_1<nlimbs = limbno+1; } - a->d[limbno] |= (1<d[limbno] |= (A_LIMB_1<d[limbno] &= ~(1 << bitno); + a->d[limbno] &= ~(A_LIMB_1 << bitno); a->nlimbs = limbno+1; } @@ -146,7 +147,7 @@ mpi_clear_bit( MPI a, unsigned n ) if( limbno >= a->nlimbs ) return; /* don't need to clear this bit, it's to far to left */ - a->d[limbno] &= ~(1 << bitno); + a->d[limbno] &= ~(A_LIMB_1 << bitno); } diff --git a/mpi/mpi-scan.c b/mpi/mpi-scan.c index b9745e1af..329b868ca 100644 --- a/mpi/mpi-scan.c +++ b/mpi/mpi-scan.c @@ -54,22 +54,20 @@ mpi_getbyte( MPI a, unsigned index ) * Put a value at position INDEX into A. index counts from lsb to msb */ void -mpi_putbyte( MPI a, unsigned index, int c ) +mpi_putbyte( MPI a, unsigned index, int xc ) { int i, j; unsigned n; mpi_ptr_t ap; - mpi_limb_t limb; + mpi_limb_t limb, c; -#if BYTES_PER_MPI_LIMB != 4 - #error please enhance this function, its ugly - i know. -#endif - c &= 0xff; + c = xc & 0xff; ap = a->d; for(n=0,i=0; i < a->alloced; i++ ) { limb = ap[i]; for( j=0; j < BYTES_PER_MPI_LIMB; j++, n++ ) if( n == index ) { + #if BYTES_PER_MPI_LIMB == 4 if( j == 0 ) limb = (limb & 0xffffff00) | c; else if( j == 1 ) @@ -78,6 +76,26 @@ mpi_putbyte( MPI a, unsigned index, int c ) limb = (limb & 0xff00ffff) | (c<<16); else limb = (limb & 0x00ffffff) | (c<<24); + #elif BYTES_PER_MPI_LIMB == 8 + if( j == 0 ) + limb = (limb & 0xffffffffffffff00) | c; + else if( j == 1 ) + limb = (limb & 0xffffffffffff00ff) | (c<<8); + else if( j == 2 ) + limb = (limb & 0xffffffffff00ffff) | (c<<16); + else if( j == 3 ) + limb = (limb & 0xffffffff00ffffff) | (c<<24); + else if( j == 4 ) + limb = (limb & 0xffffff00ffffffff) | (c<<32); + else if( j == 5 ) + limb = (limb & 0xffff00ffffffffff) | (c<<40); + else if( j == 6 ) + limb = (limb & 0xff00ffffffffffff) | (c<<48); + else + limb = (limb & 0x00ffffffffffffff) | (c<<56); + #else + #error please enhance this function, its ugly - i know. + #endif if( a->nlimbs <= i ) a->nlimbs = i+1; ap[i] = limb; diff --git a/mpi/mpicoder.c b/mpi/mpicoder.c index efb5d0904..bccb51ff5 100644 --- a/mpi/mpicoder.c +++ b/mpi/mpicoder.c @@ -20,6 +20,7 @@ #include #include +#include #include #include @@ -326,14 +327,15 @@ mpi_set_buffer( MPI a, const byte *buffer, unsigned nbytes, int sign ) alimb |= *p-- << 16 ; alimb |= *p-- << 24 ; #elif BYTES_PER_MPI_LIMB == 8 - alimb = *p-- ; - alimb |= *p-- << 8 ; - alimb |= *p-- << 16 ; - alimb |= *p-- << 24 ; - alimb |= *p-- << 32 ; - alimb |= *p-- << 40 ; - alimb |= *p-- << 48 ; - alimb |= *p-- << 56 ; + /* cast due to egc's "left shift count >= width of type" warning*/ + alimb = (mpi_limb_t)*p-- ; + alimb |= (mpi_limb_t)*p-- << 8 ; + alimb |= (mpi_limb_t)*p-- << 16 ; + alimb |= (mpi_limb_t)*p-- << 24 ; + alimb |= (mpi_limb_t)*p-- << 32 ; + alimb |= (mpi_limb_t)*p-- << 40 ; + alimb |= (mpi_limb_t)*p-- << 48 ; + alimb |= (mpi_limb_t)*p-- << 56 ; #else #error please implement for this limb size. #endif @@ -346,14 +348,14 @@ mpi_set_buffer( MPI a, const byte *buffer, unsigned nbytes, int sign ) if( p >= buffer ) alimb |= *p-- << 16 ; if( p >= buffer ) alimb |= *p-- << 24 ; #elif BYTES_PER_MPI_LIMB == 8 - alimb = *p-- ; - if( p >= buffer ) alimb |= *p-- << 8 ; - if( p >= buffer ) alimb |= *p-- << 16 ; - if( p >= buffer ) alimb |= *p-- << 24 ; - if( p >= buffer ) alimb |= *p-- << 32 ; - if( p >= buffer ) alimb |= *p-- << 40 ; - if( p >= buffer ) alimb |= *p-- << 48 ; - if( p >= buffer ) alimb |= *p-- << 56 ; + alimb = (mpi_limb_t)*p-- ; + if( p >= buffer ) alimb |= (mpi_limb_t)*p-- << 8 ; + if( p >= buffer ) alimb |= (mpi_limb_t)*p-- << 16 ; + if( p >= buffer ) alimb |= (mpi_limb_t)*p-- << 24 ; + if( p >= buffer ) alimb |= (mpi_limb_t)*p-- << 32 ; + if( p >= buffer ) alimb |= (mpi_limb_t)*p-- << 40 ; + if( p >= buffer ) alimb |= (mpi_limb_t)*p-- << 48 ; + if( p >= buffer ) alimb |= (mpi_limb_t)*p-- << 56 ; #else #error please implement for this limb size. #endif diff --git a/mpi/mpiutil.c b/mpi/mpiutil.c index 7515eafd1..09be317f2 100644 --- a/mpi/mpiutil.c +++ b/mpi/mpiutil.c @@ -103,7 +103,7 @@ mpi_alloc_limb_space( unsigned nlimbs, int secure ) size_t len = nlimbs * sizeof(mpi_limb_t); if( DBG_MEMORY ) - log_debug("mpi_alloc_limb_space(%u)\n", len*8 ); + log_debug("mpi_alloc_limb_space(%u)\n", (unsigned)len*8 ); #ifdef M_DEBUG return secure? m_debug_alloc_secure(len, info):m_debug_alloc( len, info ); #else diff --git a/tools/Makefile.in b/tools/Makefile.in index f6b077672..6b9d2a32a 100644 --- a/tools/Makefile.in +++ b/tools/Makefile.in @@ -72,6 +72,7 @@ G10_LOCALEDIR = @G10_LOCALEDIR@ GENCAT = @GENCAT@ GMOFILES = @GMOFILES@ GMSGFMT = @GMSGFMT@ +HAVE_ZLIB_H = @HAVE_ZLIB_H@ INSTOBJEXT = @INSTOBJEXT@ INTLDEPS = @INTLDEPS@ INTLLIBS = @INTLLIBS@ diff --git a/util/Makefile.in b/util/Makefile.in index 1f0135745..7b067bfdd 100644 --- a/util/Makefile.in +++ b/util/Makefile.in @@ -72,6 +72,7 @@ G10_LOCALEDIR = @G10_LOCALEDIR@ GENCAT = @GENCAT@ GMOFILES = @GMOFILES@ GMSGFMT = @GMSGFMT@ +HAVE_ZLIB_H = @HAVE_ZLIB_H@ INSTOBJEXT = @INSTOBJEXT@ INTLDEPS = @INTLDEPS@ INTLLIBS = @INTLLIBS@ diff --git a/util/strgutil.c b/util/strgutil.c index 286e90237..a687d0af3 100644 --- a/util/strgutil.c +++ b/util/strgutil.c @@ -20,6 +20,7 @@ #include #include +#include #include #include "types.h" #include "util.h"