1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-06-15 00:29:49 +02:00

Fixed a few bugs

This commit is contained in:
Werner Koch 1998-02-03 12:09:20 +00:00
parent c8f12e218f
commit 899b8378ec
33 changed files with 152 additions and 80 deletions

View File

@ -72,6 +72,7 @@ G10_LOCALEDIR = @G10_LOCALEDIR@
GENCAT = @GENCAT@ GENCAT = @GENCAT@
GMOFILES = @GMOFILES@ GMOFILES = @GMOFILES@
GMSGFMT = @GMSGFMT@ GMSGFMT = @GMSGFMT@
HAVE_ZLIB_H = @HAVE_ZLIB_H@
INSTOBJEXT = @INSTOBJEXT@ INSTOBJEXT = @INSTOBJEXT@
INTLDEPS = @INTLDEPS@ INTLDEPS = @INTLDEPS@
INTLLIBS = @INTLLIBS@ INTLLIBS = @INTLLIBS@

View File

@ -1 +1 @@
0.2.1 0.2.1w

View File

@ -311,7 +311,7 @@ define(WK_CHECK_ENDIAN,
#include <sys/param.h>], [ #include <sys/param.h>], [
#if BYTE_ORDER != BIG_ENDIAN #if BYTE_ORDER != BIG_ENDIAN
not 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 if test "$wk_cv_c_endian" = unknown; then
AC_TRY_RUN([main () { AC_TRY_RUN([main () {
/* Are we little or big endian? From Harbison&Steele. */ /* Are we little or big endian? From Harbison&Steele. */

View File

@ -72,6 +72,7 @@ G10_LOCALEDIR = @G10_LOCALEDIR@
GENCAT = @GENCAT@ GENCAT = @GENCAT@
GMOFILES = @GMOFILES@ GMOFILES = @GMOFILES@
GMSGFMT = @GMSGFMT@ GMSGFMT = @GMSGFMT@
HAVE_ZLIB_H = @HAVE_ZLIB_H@
INSTOBJEXT = @INSTOBJEXT@ INSTOBJEXT = @INSTOBJEXT@
INTLDEPS = @INTLDEPS@ INTLDEPS = @INTLDEPS@
INTLLIBS = @INTLLIBS@ INTLLIBS = @INTLLIBS@

View File

@ -142,6 +142,9 @@ elg_generate( ELG_public_key *pk, ELG_secret_key *sk, unsigned nbits )
/* select a random number which has these properties: /* select a random number which has these properties:
* 0 < x < p-1 * 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 ); x = mpi_alloc_secure( nbits/BITS_PER_MPI_LIMB );
if( DBG_CIPHER ) if( DBG_CIPHER )

View File

@ -21,6 +21,7 @@
#include <config.h> #include <config.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#include <errno.h> #include <errno.h>
#include "util.h" #include "util.h"
#include "cipher.h" #include "cipher.h"

View File

@ -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 MPI
generate_elg_prime( unsigned pbits, unsigned qbits, MPI g ) 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 ); pbits, qbits, fbits, n );
prime = mpi_alloc( (pbits + BITS_PER_MPI_LIMB - 1) / BITS_PER_MPI_LIMB ); 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 */ /* allocate an array to hold the factors + 2 for later usage */
factors = m_alloc_clear( (n+2) * sizeof *factors ); 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 ); perms = m_alloc_clear( m );
for(i=0; i < n; i++ ) { for(i=0; i < n; i++ ) {
perms[i] = 1; perms[i] = 1;
pool[i] = gen_prime( fbits, 0, 2 ); pool[i] = gen_prime( fbits, 0, 1 );
factors[i] = pool[i]; 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++ ) for(i=j=0; i < m && j < n ; i++ )
if( perms[i] ) { if( perms[i] ) {
if( !pool[i] ) if( !pool[i] )
pool[i] = gen_prime( fbits, 0, 2 ); pool[i] = gen_prime( fbits, 0, 1 );
factors[j++] = pool[i]; factors[j++] = pool[i];
} }
if( i == n ) { if( i == n ) {
@ -142,7 +148,7 @@ generate_elg_prime( unsigned pbits, unsigned qbits, MPI g )
count1 = 0; count1 = 0;
qbits++; qbits++;
fputc('>', stderr); fputc('>', stderr);
q = gen_prime( qbits, 0, 2 ); q = gen_prime( qbits, 0, 1 );
goto next_try; goto next_try;
} }
} }
@ -153,7 +159,7 @@ generate_elg_prime( unsigned pbits, unsigned qbits, MPI g )
count2 = 0; count2 = 0;
qbits--; qbits--;
fputc('<', stderr); fputc('<', stderr);
q = gen_prime( qbits, 0, 2 ); q = gen_prime( qbits, 0, 1 );
goto next_try; goto next_try;
} }
} }
@ -379,8 +385,9 @@ is_prime( MPI n, int steps, int *count )
else { else {
mpi_set_bytes( x, nbits-1, get_random_byte, 0 ); mpi_set_bytes( x, nbits-1, get_random_byte, 0 );
/* work around a bug in mpi_set_bytes */ /* 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 */ mpi_set_highbit( x, nbits-2 ); /* clear all higher bits */
}
else { else {
mpi_set_highbit( x, nbits-2 ); mpi_set_highbit( x, nbits-2 );
mpi_clear_bit( x, nbits-2 ); mpi_clear_bit( x, nbits-2 );

View File

@ -26,6 +26,7 @@
#include <sys/time.h> #include <sys/time.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <string.h>
#include <unistd.h> #include <unistd.h>
#include <fcntl.h> #include <fcntl.h>
#include "util.h" #include "util.h"

View File

@ -6,8 +6,8 @@ dnl (Process this file with autoconf to produce a configure script.)
AC_INIT(g10/g10.c) AC_INIT(g10/g10.c)
AC_CONFIG_AUX_DIR(scripts) AC_CONFIG_AUX_DIR(scripts)
dnl Ooops: automake 1.2d looks for AC_CONFIG_HEADER (and not AM_..) 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 to decide where config.h is - so we have to add -I.. to
dnl every makefile.am dnl every Makefile.am
AM_CONFIG_HEADER(config.h) AM_CONFIG_HEADER(config.h)
@ -34,10 +34,20 @@ AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE")
AC_DEFINE_UNQUOTED(G10_LOCALEDIR, "$G10_LOCALEDIR") AC_DEFINE_UNQUOTED(G10_LOCALEDIR, "$G10_LOCALEDIR")
AC_ARG_ENABLE(m-debug, 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 if test "$enableval" = y || test "$enableval" = yes; then
AC_DEFINE(M_DEBUG) AC_DEFINE(M_DEBUG)
fi 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" CFLAGS="-g -Wall"
@ -159,13 +169,15 @@ AC_MSG_RESULT()
fi fi
AC_SUBST(MPI_EXTRA_ASM_OBJS) AC_SUBST(MPI_EXTRA_ASM_OBJS)
dnl Do we have zlib? Must do it here because Solaris failed dnl Do we have zlib? Must do it here because Solaris failed
dnl when compiling a conftest (due to the "-lz" from LIBS). dnl when compiling a conftest (due to the "-lz" from LIBS).
if test "$g10_use_zlib" = "yes"; then
AC_CHECK_HEADERS(zlib.h, AC_CHECK_HEADERS(zlib.h,
[LIBS="$LIBS -lz"], [LIBS="$LIBS -lz"],
AC_MSG_WARN([zlib missing - creating without ZLIB support!]) AC_MSG_WARN([zlib missing - creating without ZLIB support!])
) )
fi
AC_SUBST(HAVE_ZLIB_H)
dnl checking whether we have other cipher source files dnl checking whether we have other cipher source files
CIPHER_EXTRA_OBJS="" CIPHER_EXTRA_OBJS=""

View File

@ -72,6 +72,7 @@ G10_LOCALEDIR = @G10_LOCALEDIR@
GENCAT = @GENCAT@ GENCAT = @GENCAT@
GMOFILES = @GMOFILES@ GMOFILES = @GMOFILES@
GMSGFMT = @GMSGFMT@ GMSGFMT = @GMSGFMT@
HAVE_ZLIB_H = @HAVE_ZLIB_H@
INSTOBJEXT = @INSTOBJEXT@ INSTOBJEXT = @INSTOBJEXT@
INTLDEPS = @INTLDEPS@ INTLDEPS = @INTLDEPS@
INTLLIBS = @INTLLIBS@ INTLLIBS = @INTLLIBS@

View File

@ -698,7 +698,7 @@ armor_filter( void *opaque, int control,
iobuf_writestr(a, head_strings[afx->what] ); iobuf_writestr(a, head_strings[afx->what] );
iobuf_writestr(a, "-----\n"); iobuf_writestr(a, "-----\n");
iobuf_writestr(a, "Version: G10 pre-release " VERSION "\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->status++;
afx->idx = 0; afx->idx = 0;
afx->idx2 = 0; afx->idx2 = 0;

View File

@ -211,7 +211,7 @@ hash_public_cert( MD_HANDLE md, PKT_public_cert *pkc )
int rc = 0; int rc = 0;
int c; int c;
IOBUF a = iobuf_temp(); IOBUF a = iobuf_temp();
FILE *fp = fopen("dump.pkc", "a"); /* FILE *fp = fopen("dump.pkc", "a");*/
/* build the packet */ /* build the packet */
init_packet(&pkt); init_packet(&pkt);
@ -220,10 +220,10 @@ hash_public_cert( MD_HANDLE md, PKT_public_cert *pkc )
if( (rc = build_packet( a, &pkt )) ) if( (rc = build_packet( a, &pkt )) )
log_fatal("build public_cert for hashing failed: %s\n", g10_errstr(rc)); log_fatal("build public_cert for hashing failed: %s\n", g10_errstr(rc));
while( (c=iobuf_get(a)) != -1 ) { while( (c=iobuf_get(a)) != -1 ) {
putc( c, fp); /* putc( c, fp);*/
md_putc( md, c ); md_putc( md, c );
} }
fclose(fp); /*fclose(fp);*/
iobuf_cancel(a); iobuf_cancel(a);
} }

View File

@ -234,7 +234,6 @@ compress_filter( void *opaque, int control,
IOBUF a, byte *buf, size_t *ret_len) IOBUF a, byte *buf, size_t *ret_len)
{ {
size_t size = *ret_len; size_t size = *ret_len;
compress_filter_context_t *zfx = opaque;
int c, rc=0; int c, rc=0;
size_t n; size_t n;

View File

@ -146,6 +146,9 @@ set_cmd( enum cmd_values *ret_cmd, enum cmd_values new_cmd )
cmd = aSignEncr; cmd = aSignEncr;
else if( cmd == aKMode && new_cmd == aSym ) else if( cmd == aKMode && new_cmd == aSym )
cmd = aKModeC; cmd = aKModeC;
else if( ( cmd == aSign && new_cmd == aClearsig )
|| ( cmd == aClearsig && new_cmd == aSign ) )
cmd = aClearsig;
else { else {
log_error(_("conflicting commands\n")); log_error(_("conflicting commands\n"));
g10_exit(2); g10_exit(2);
@ -294,11 +297,11 @@ main( int argc, char **argv )
break; break;
case 'z': opt.compress = pargs.r.ret_int; break; case 'z': opt.compress = pargs.r.ret_int; break;
case 'a': opt.armor = 1; opt.no_armor=0; 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 'c': set_cmd( &cmd , aSym); break;
case 'o': opt.outfile = pargs.r.ret_str; break; case 'o': opt.outfile = pargs.r.ret_str; break;
case 'e': set_cmd( &cmd, aEncr); break; case 'e': set_cmd( &cmd, aEncr); break;
case 'b': detached_sig = 1; case 'b': detached_sig = 1; /* fall trough */
/* fall trough */
case 's': set_cmd( &cmd, aSign ); break; case 's': set_cmd( &cmd, aSign ); break;
case 't': set_cmd( &cmd , aClearsig); break; case 't': set_cmd( &cmd , aClearsig); break;
case 'u': /* store the local users */ case 'u': /* store the local users */

View File

@ -179,6 +179,7 @@ main( int argc, char **argv )
{ 526, "no-verbose", 0, "\r"}, { 526, "no-verbose", 0, "\r"},
{ 531, "list-trustdb",0 , "\r"}, { 531, "list-trustdb",0 , "\r"},
{ 533, "list-trust-path",0, "\r"}, { 533, "list-trust-path",0, "\r"},
{ 532, "quick-random", 0, "\r"},
{ 534, "no-comment", 0, N_("do not write comment packets")}, { 534, "no-comment", 0, N_("do not write comment packets")},
{ 535, "completes-needed", 1, N_("(default is 1)")}, { 535, "completes-needed", 1, N_("(default is 1)")},
{ 536, "marginals-needed", 1, N_("(default is 3)")}, { 536, "marginals-needed", 1, N_("(default is 3)")},

View File

@ -454,12 +454,12 @@ scan_keyring( PKT_public_cert *pkc, u32 *keyid,
if( !DBG_CACHE ) if( !DBG_CACHE )
; ;
else if( shortkeyid ) 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 ) else if( name )
log_debug("scan_keyring %s for '%s'\n", filename, name ); log_debug("scan_keyring %s for '%s'\n", filename, name );
else if( keyid ) else if( keyid )
log_debug("scan_keyring %s for %08lx %08lx\n", filename, log_debug("scan_keyring %s for %08lx %08lx\n", filename,
keyid[0], keyid[1] ); (ulong)keyid[0], (ulong)keyid[1] );
else else
log_debug("scan_keyring %s (all)\n", filename ); 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 ) for(r=user_id_db; r; r = r->next )
if( r->keyid[0] == keyid[0] && r->keyid[1] == keyid[1] ) { if( r->keyid[0] == keyid[0] && r->keyid[1] == keyid[1] ) {
p = m_alloc( r->len + 10 ); 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; return p;
} }
} while( ++pass < 2 && !get_pubkey( NULL, keyid ) ); } while( ++pass < 2 && !get_pubkey( NULL, keyid ) );
p = m_alloc( 15 ); p = m_alloc( 15 );
sprintf(p, "%08lX [?]", keyid[1] ); sprintf(p, "%08lX [?]", (ulong)keyid[1] );
return p; return p;
} }

View File

@ -476,7 +476,7 @@ list_node( CTX c, KBNODE node )
} }
} }
printf("%c %08lX %s ", printf("%c %08lX %s ",
sigrc, sig->keyid[1], datestr_from_sig(sig)); sigrc, (ulong)sig->keyid[1], datestr_from_sig(sig));
if( sigrc == '%' ) if( sigrc == '%' )
printf("[%s] ", g10_errstr(rc2) ); printf("[%s] ", g10_errstr(rc2) );
else if( sigrc == '?' ) else if( sigrc == '?' )
@ -597,7 +597,7 @@ check_sig_and_print( CTX c, KBNODE node )
else { else {
write_status( STATUS_ERRSIG ); write_status( STATUS_ERRSIG );
log_error("Can't check signature made by %08lX: %s\n", 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; return rc;
} }

View File

@ -343,7 +343,7 @@ parse_publickey( IOBUF inp, int pkttype, unsigned long pktlen, PACKET *packet )
k->pubkey_algo = iobuf_get_noeof(inp); pktlen--; k->pubkey_algo = iobuf_get_noeof(inp); pktlen--;
if( list_mode ) if( list_mode )
printf(":public key encoded packet: keyid %08lX%08lX\n", 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 ) { if( k->pubkey_algo == PUBKEY_ALGO_ELGAMAL ) {
n = pktlen; n = pktlen;
k->d.elg.a = mpi_read(inp, &n, 0); pktlen -=n; 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 ) if( list_mode )
printf(":signature packet: keyid %08lX%08lX\n" printf(":signature packet: keyid %08lX%08lX\n"
"\tversion %d, created %lu, md5len %d, sigclass %02x\n", "\tversion %d, created %lu, md5len %d, sigclass %02x\n",
sig->keyid[0], sig->keyid[1], (ulong)sig->keyid[0], (ulong)sig->keyid[1],
version, sig->timestamp, md5_len, sig->sig_class ); version, (ulong)sig->timestamp, md5_len, sig->sig_class );
if( sig->pubkey_algo == PUBKEY_ALGO_ELGAMAL ) { if( sig->pubkey_algo == PUBKEY_ALGO_ELGAMAL ) {
if( pktlen < 5 ) { if( pktlen < 5 ) {
log_error("packet(%d) too short\n", pkttype); 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 ) if( list_mode )
printf(":onepass_sig packet: keyid %08lX%08lX\n" printf(":onepass_sig packet: keyid %08lX%08lX\n"
"\tversion %d, sigclass %02x, digest %d, pubkey %d, last=%d\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, version, ops->sig_class,
ops->digest_algo, ops->pubkey_algo, ops->last ); 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" printf(":literal data packet:\n"
"\tmode %c, created %lu, name=\"", "\tmode %c, created %lu, name=\"",
mode >= ' ' && mode <'z'? mode : '?', mode >= ' ' && mode <'z'? mode : '?',
pt->timestamp ); (ulong)pt->timestamp );
for(p=pt->name,i=0; i < namelen; p++, i++ ) { for(p=pt->name,i=0; i < namelen; p++, i++ ) {
if( *p >= ' ' && *p <= 'z' ) if( *p >= ' ' && *p <= 'z' )
putchar(*p); putchar(*p);
else else
printf("\\x%02x", *p ); printf("\\x%02x", *p );
} }
printf("\",\n\traw data: %lu bytes\n", pt->len ); printf("\",\n\traw data: %lu bytes\n", (ulong)pt->len );
} }
leave: leave:

View File

@ -680,6 +680,7 @@ keyring_delete( KBPOS *kbpos )
} }
len = kbpos->length; len = kbpos->length;
assert( len < 100000 ); /* there is a bug somewhere */
/*log_debug("writing a dummy packet of length %lu\n", (ulong)len);*/ /*log_debug("writing a dummy packet of length %lu\n", (ulong)len);*/
if( len < 2 ) if( len < 2 )

View File

@ -317,7 +317,7 @@ protect_secret_key( PKT_secret_cert *cert, DEK *dek )
if( cert->pubkey_algo == PUBKEY_ALGO_ELGAMAL ) if( cert->pubkey_algo == PUBKEY_ALGO_ELGAMAL )
return protect_elg( cert, dek ); return protect_elg( cert, dek );
#ifdef 0 /* noy yet implemented */ #if 0 /* noy yet implemented */
else if( cert->pubkey_algo == PUBKEY_ALGO_RSA ) else if( cert->pubkey_algo == PUBKEY_ALGO_RSA )
return protect_rsa( cert, dek ); return protect_rsa( cert, dek );
#endif #endif

View File

@ -570,7 +570,8 @@ sign_key( const char *username, STRLIST locusr )
&& (node->pkt->pkt.signature->sig_class&~3) == 0x10 ) { && (node->pkt->pkt.signature->sig_class&~3) == 0x10 ) {
if( akeyid[0] == node->pkt->pkt.signature->keyid[0] if( akeyid[0] == node->pkt->pkt.signature->keyid[0]
&& akeyid[1] == node->pkt->pkt.signature->keyid[1] ) { && 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; skc_rover->mark = 1;
} }
} }
@ -833,7 +834,7 @@ make_keysig_packet( PKT_signature **ret_sig, PKT_public_cert *pkc,
assert( sigclass >= 0x10 && sigclass <= 0x13 ); assert( sigclass >= 0x10 && sigclass <= 0x13 );
md = md_open( digest_algo, 0 ); 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 ); hash_public_cert( md, pkc );
md_write( md, uid->name, uid->len ); md_write( md, uid->name, uid->len );
/* and make the signature packet */ /* 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 >> 8) & 0xff );
md_putc( md, a & 0xff ); md_putc( md, a & 0xff );
} }
md_final(md);
rc = complete_sig( sig, skc, md ); rc = complete_sig( sig, skc, md );

View File

@ -21,6 +21,7 @@
#include <config.h> #include <config.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#include <unistd.h> #include <unistd.h>
#include "status.h" #include "status.h"

View File

@ -371,8 +371,8 @@ dump_record( ulong rnum, TRUSTREC *rec, FILE *fp )
case RECTYPE_VER: fprintf(fp, "version\n"); case RECTYPE_VER: fprintf(fp, "version\n");
break; break;
case RECTYPE_DIR: case RECTYPE_DIR:
fprintf(fp, "dir keyid=%08lx, key=%lu, ctl=%lu, sig=%lu", fprintf(fp, "dir keyid=%08lX, key=%lu, ctl=%lu, sig=%lu",
rec->r.dir.keyid[1], (ulong)rec->r.dir.keyid[1],
rec->r.dir.keyrec, rec->r.dir.ctlrec, rec->r.dir.sigrec ); rec->r.dir.keyrec, rec->r.dir.ctlrec, rec->r.dir.sigrec );
if( rec->r.dir.no_sigs == 1 ) if( rec->r.dir.no_sigs == 1 )
fputs(", (none)", fp ); fputs(", (none)", fp );
@ -382,8 +382,8 @@ dump_record( ulong rnum, TRUSTREC *rec, FILE *fp )
fputs(", (revoked)", fp ); fputs(", (revoked)", fp );
putc('\n', fp); putc('\n', fp);
break; break;
case RECTYPE_KEY: fprintf(fp, "key keyid=%08lx, own=%lu, ownertrust=%02x\n", case RECTYPE_KEY: fprintf(fp, "key keyid=%08lX, own=%lu, ownertrust=%02x\n",
rec->r.key.keyid[1], (ulong)rec->r.key.keyid[1],
rec->r.key.owner, rec->r.key.ownertrust ); rec->r.key.owner, rec->r.key.ownertrust );
break; break;
case RECTYPE_CTL: fprintf(fp, "ctl\n"); case RECTYPE_CTL: fprintf(fp, "ctl\n");

View File

@ -57,9 +57,9 @@
#ifndef HAVE_U32_TYPEDEF #ifndef HAVE_U32_TYPEDEF
#undef u32 /* maybe there is a macro with this name */ #undef u32 /* maybe there is a macro with this name */
#if SIZEOF_UNSIGNED_INT == 4 #if SIZEOF_UNSIGNED_INT == 4
typedef unsigned long u32;
#elif SIZEOF_UNSIGNED_LONG == 4
typedef unsigned int u32; typedef unsigned int u32;
#elif SIZEOF_UNSIGNED_LONG == 4
typedef unsigned long u32;
#else #else
#error no typedef for u32 #error no typedef for u32
#endif #endif

View File

@ -11,6 +11,8 @@ EXTRA_DIST = config.links
noinst_LIBRARIES = libmpi.a noinst_LIBRARIES = libmpi.a
# noinst_HEADERS = # noinst_HEADERS =
libmpi_a_SOURCES = longlong.h \ libmpi_a_SOURCES = longlong.h \
mpi-add.c \ mpi-add.c \
mpi-bit.c \ mpi-bit.c \
@ -31,11 +33,16 @@ libmpi_a_SOURCES = longlong.h \
mpih-mul.c \ mpih-mul.c \
mpiutil.c mpiutil.c
libmpi_a_LIBADD = mpih-mul1.o \ # Note this objects are actually links, the sourcefiles are
mpih-mul2.o \ # distributed by special code in dist-hook
mpih-mul3.o \ common_asm_objects = mpih-mul1.o \
mpih-add1.o \ mpih-mul2.o \
mpih-sub1.o \ mpih-mul3.o \
mpih-shift.o @MPI_EXTRA_ASM_OBJS@ 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@

View File

@ -72,6 +72,7 @@ G10_LOCALEDIR = @G10_LOCALEDIR@
GENCAT = @GENCAT@ GENCAT = @GENCAT@
GMOFILES = @GMOFILES@ GMOFILES = @GMOFILES@
GMSGFMT = @GMSGFMT@ GMSGFMT = @GMSGFMT@
HAVE_ZLIB_H = @HAVE_ZLIB_H@
INSTOBJEXT = @INSTOBJEXT@ INSTOBJEXT = @INSTOBJEXT@
INTLDEPS = @INTLDEPS@ INTLDEPS = @INTLDEPS@
INTLLIBS = @INTLLIBS@ INTLLIBS = @INTLLIBS@
@ -114,12 +115,16 @@ libmpi_a_SOURCES = longlong.h \
mpih-mul.c \ mpih-mul.c \
mpiutil.c mpiutil.c
libmpi_a_LIBADD = mpih-mul1.o \ # Note this objects are actually links, the sourcefiles are
mpih-mul2.o \ # distributed by special code in dist-hook
mpih-mul3.o \ common_asm_objects = mpih-mul1.o \
mpih-add1.o \ mpih-mul2.o \
mpih-sub1.o \ mpih-mul3.o \
mpih-shift.o @MPI_EXTRA_ASM_OBJS@ 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 mkinstalldirs = $(SHELL) $(top_srcdir)/scripts/mkinstalldirs
CONFIG_HEADER = ../config.h CONFIG_HEADER = ../config.h
CONFIG_CLEAN_FILES = CONFIG_CLEAN_FILES =
@ -328,6 +333,8 @@ maintainer-clean-generic clean mostlyclean distclean maintainer-clean
CFLAGS += -O2 CFLAGS += -O2
$(LIBRARIES): $(common_asm_objects) @MPI_EXTRA_ASM_OBJS@
# 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.
# Otherwise a system limit (for SysV at least) may be exceeded. # Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT: .NOEXPORT:

View File

@ -45,6 +45,7 @@ __clz_tab[] =
#endif #endif
#define A_LIMB_1 ((mpi_limb_t)1)
@ -88,7 +89,7 @@ mpi_test_bit( MPI a, unsigned n )
if( limbno >= a->nlimbs ) if( limbno >= a->nlimbs )
return 0; /* too far left: this is a 0 */ return 0; /* too far left: this is a 0 */
limb = a->d[limbno]; 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 ); mpi_resize(a, limbno+1 );
a->nlimbs = limbno+1; a->nlimbs = limbno+1;
} }
a->d[limbno] |= (1<<bitno); a->d[limbno] |= (A_LIMB_1<<bitno);
} }
/**************** /****************
@ -127,9 +128,9 @@ mpi_set_highbit( MPI a, unsigned n )
mpi_resize(a, limbno+1 ); mpi_resize(a, limbno+1 );
a->nlimbs = limbno+1; a->nlimbs = limbno+1;
} }
a->d[limbno] |= (1<<bitno); a->d[limbno] |= (A_LIMB_1<<bitno);
for( bitno++; bitno < BITS_PER_MPI_LIMB; bitno++ ) for( bitno++; bitno < BITS_PER_MPI_LIMB; bitno++ )
a->d[limbno] &= ~(1 << bitno); a->d[limbno] &= ~(A_LIMB_1 << bitno);
a->nlimbs = limbno+1; a->nlimbs = limbno+1;
} }
@ -146,7 +147,7 @@ mpi_clear_bit( MPI a, unsigned n )
if( limbno >= a->nlimbs ) if( limbno >= a->nlimbs )
return; /* don't need to clear this bit, it's to far to left */ 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);
} }

View File

@ -54,22 +54,20 @@ mpi_getbyte( MPI a, unsigned index )
* Put a value at position INDEX into A. index counts from lsb to msb * Put a value at position INDEX into A. index counts from lsb to msb
*/ */
void void
mpi_putbyte( MPI a, unsigned index, int c ) mpi_putbyte( MPI a, unsigned index, int xc )
{ {
int i, j; int i, j;
unsigned n; unsigned n;
mpi_ptr_t ap; mpi_ptr_t ap;
mpi_limb_t limb; mpi_limb_t limb, c;
#if BYTES_PER_MPI_LIMB != 4 c = xc & 0xff;
#error please enhance this function, its ugly - i know.
#endif
c &= 0xff;
ap = a->d; ap = a->d;
for(n=0,i=0; i < a->alloced; i++ ) { for(n=0,i=0; i < a->alloced; i++ ) {
limb = ap[i]; limb = ap[i];
for( j=0; j < BYTES_PER_MPI_LIMB; j++, n++ ) for( j=0; j < BYTES_PER_MPI_LIMB; j++, n++ )
if( n == index ) { if( n == index ) {
#if BYTES_PER_MPI_LIMB == 4
if( j == 0 ) if( j == 0 )
limb = (limb & 0xffffff00) | c; limb = (limb & 0xffffff00) | c;
else if( j == 1 ) else if( j == 1 )
@ -78,6 +76,26 @@ mpi_putbyte( MPI a, unsigned index, int c )
limb = (limb & 0xff00ffff) | (c<<16); limb = (limb & 0xff00ffff) | (c<<16);
else else
limb = (limb & 0x00ffffff) | (c<<24); 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 ) if( a->nlimbs <= i )
a->nlimbs = i+1; a->nlimbs = i+1;
ap[i] = limb; ap[i] = limb;

View File

@ -20,6 +20,7 @@
#include <config.h> #include <config.h>
#include <stdio.h> #include <stdio.h>
#include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <assert.h> #include <assert.h>
@ -326,14 +327,15 @@ mpi_set_buffer( MPI a, const byte *buffer, unsigned nbytes, int sign )
alimb |= *p-- << 16 ; alimb |= *p-- << 16 ;
alimb |= *p-- << 24 ; alimb |= *p-- << 24 ;
#elif BYTES_PER_MPI_LIMB == 8 #elif BYTES_PER_MPI_LIMB == 8
alimb = *p-- ; /* cast due to egc's "left shift count >= width of type" warning*/
alimb |= *p-- << 8 ; alimb = (mpi_limb_t)*p-- ;
alimb |= *p-- << 16 ; alimb |= (mpi_limb_t)*p-- << 8 ;
alimb |= *p-- << 24 ; alimb |= (mpi_limb_t)*p-- << 16 ;
alimb |= *p-- << 32 ; alimb |= (mpi_limb_t)*p-- << 24 ;
alimb |= *p-- << 40 ; alimb |= (mpi_limb_t)*p-- << 32 ;
alimb |= *p-- << 48 ; alimb |= (mpi_limb_t)*p-- << 40 ;
alimb |= *p-- << 56 ; alimb |= (mpi_limb_t)*p-- << 48 ;
alimb |= (mpi_limb_t)*p-- << 56 ;
#else #else
#error please implement for this limb size. #error please implement for this limb size.
#endif #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-- << 16 ;
if( p >= buffer ) alimb |= *p-- << 24 ; if( p >= buffer ) alimb |= *p-- << 24 ;
#elif BYTES_PER_MPI_LIMB == 8 #elif BYTES_PER_MPI_LIMB == 8
alimb = *p-- ; alimb = (mpi_limb_t)*p-- ;
if( p >= buffer ) alimb |= *p-- << 8 ; if( p >= buffer ) alimb |= (mpi_limb_t)*p-- << 8 ;
if( p >= buffer ) alimb |= *p-- << 16 ; if( p >= buffer ) alimb |= (mpi_limb_t)*p-- << 16 ;
if( p >= buffer ) alimb |= *p-- << 24 ; if( p >= buffer ) alimb |= (mpi_limb_t)*p-- << 24 ;
if( p >= buffer ) alimb |= *p-- << 32 ; if( p >= buffer ) alimb |= (mpi_limb_t)*p-- << 32 ;
if( p >= buffer ) alimb |= *p-- << 40 ; if( p >= buffer ) alimb |= (mpi_limb_t)*p-- << 40 ;
if( p >= buffer ) alimb |= *p-- << 48 ; if( p >= buffer ) alimb |= (mpi_limb_t)*p-- << 48 ;
if( p >= buffer ) alimb |= *p-- << 56 ; if( p >= buffer ) alimb |= (mpi_limb_t)*p-- << 56 ;
#else #else
#error please implement for this limb size. #error please implement for this limb size.
#endif #endif

View File

@ -103,7 +103,7 @@ mpi_alloc_limb_space( unsigned nlimbs, int secure )
size_t len = nlimbs * sizeof(mpi_limb_t); size_t len = nlimbs * sizeof(mpi_limb_t);
if( DBG_MEMORY ) 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 #ifdef M_DEBUG
return secure? m_debug_alloc_secure(len, info):m_debug_alloc( len, info ); return secure? m_debug_alloc_secure(len, info):m_debug_alloc( len, info );
#else #else

View File

@ -72,6 +72,7 @@ G10_LOCALEDIR = @G10_LOCALEDIR@
GENCAT = @GENCAT@ GENCAT = @GENCAT@
GMOFILES = @GMOFILES@ GMOFILES = @GMOFILES@
GMSGFMT = @GMSGFMT@ GMSGFMT = @GMSGFMT@
HAVE_ZLIB_H = @HAVE_ZLIB_H@
INSTOBJEXT = @INSTOBJEXT@ INSTOBJEXT = @INSTOBJEXT@
INTLDEPS = @INTLDEPS@ INTLDEPS = @INTLDEPS@
INTLLIBS = @INTLLIBS@ INTLLIBS = @INTLLIBS@

View File

@ -72,6 +72,7 @@ G10_LOCALEDIR = @G10_LOCALEDIR@
GENCAT = @GENCAT@ GENCAT = @GENCAT@
GMOFILES = @GMOFILES@ GMOFILES = @GMOFILES@
GMSGFMT = @GMSGFMT@ GMSGFMT = @GMSGFMT@
HAVE_ZLIB_H = @HAVE_ZLIB_H@
INSTOBJEXT = @INSTOBJEXT@ INSTOBJEXT = @INSTOBJEXT@
INTLDEPS = @INTLDEPS@ INTLDEPS = @INTLDEPS@
INTLLIBS = @INTLLIBS@ INTLLIBS = @INTLLIBS@

View File

@ -20,6 +20,7 @@
#include <config.h> #include <config.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#include <ctype.h> #include <ctype.h>
#include "types.h" #include "types.h"
#include "util.h" #include "util.h"