diff options
author | Werner Koch <wk@gnupg.org> | 1998-06-11 09:16:50 +0200 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 1998-06-11 09:16:50 +0200 |
commit | d9b3dc000085007bdd198ca4c0500e80a72475d7 (patch) | |
tree | bb3ffa42fa8b9e30476fdbc843632c896fcfec37 | |
parent | . (diff) | |
download | gnupg2-d9b3dc000085007bdd198ca4c0500e80a72475d7.tar.xz gnupg2-d9b3dc000085007bdd198ca4c0500e80a72475d7.zip |
update from tobold
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | Makefile.in | 2 | ||||
-rw-r--r-- | acconfig.h | 1 | ||||
-rw-r--r-- | cipher/ChangeLog | 5 | ||||
-rw-r--r-- | cipher/cipher.c | 104 | ||||
-rw-r--r-- | cipher/dynload.c | 187 | ||||
-rw-r--r-- | cipher/dynload.h | 7 | ||||
-rw-r--r-- | cipher/pubkey.c | 84 | ||||
-rw-r--r-- | cipher/rand-dummy.c | 2 | ||||
-rw-r--r-- | config.h.in | 1 | ||||
-rw-r--r-- | configure.in | 3 | ||||
-rw-r--r-- | g10/ChangeLog | 4 | ||||
-rw-r--r-- | g10/Makefile.am | 1 | ||||
-rw-r--r-- | g10/Makefile.in | 2 | ||||
-rw-r--r-- | g10/encode.c | 4 | ||||
-rw-r--r-- | g10/g10.c | 6 | ||||
-rw-r--r-- | g10/options.h | 1 | ||||
-rw-r--r-- | g10/packet.h | 16 | ||||
-rw-r--r-- | g10/pubkey-enc.c | 10 | ||||
-rw-r--r-- | g10/sign.c | 9 | ||||
-rw-r--r-- | include/cipher.h | 3 | ||||
-rw-r--r-- | include/mpi.h | 9 | ||||
-rw-r--r-- | include/util.h | 1 | ||||
-rw-r--r-- | mpi/Makefile.in | 2 | ||||
-rw-r--r-- | tools/Makefile.in | 2 | ||||
-rwxr-xr-x | tools/mk-tdata | bin | 35307 -> 11769 bytes | |||
-rw-r--r-- | util/ChangeLog | 6 | ||||
-rw-r--r-- | util/Makefile.in | 2 | ||||
-rw-r--r-- | util/argparse.c | 7 | ||||
-rw-r--r-- | util/fileutil.c | 14 | ||||
-rw-r--r-- | zlib/Makefile | 2 | ||||
-rw-r--r-- | zlib/Makefile.in | 2 |
32 files changed, 402 insertions, 101 deletions
@@ -1,3 +1,7 @@ +Wed Jun 10 07:48:59 1998 Werner Koch,mobil,,, (wk@tobold) + + * configure.in (GNUPG_LIBDIR): New. + Mon May 25 19:10:59 1998 Werner Koch (wk@isil.d.shuttle.de) * rand-unix.c (fast_random_poll): fixed syntax bug. diff --git a/Makefile.in b/Makefile.in index cd28655e3..b5bcddac5 100644 --- a/Makefile.in +++ b/Makefile.in @@ -64,8 +64,6 @@ target_triplet = @target@ CATALOGS = @CATALOGS@ CATOBJEXT = @CATOBJEXT@ CC = @CC@ -CIPHER_EXTRA_DIST = @CIPHER_EXTRA_DIST@ -CIPHER_EXTRA_OBJS = @CIPHER_EXTRA_OBJS@ CPP = @CPP@ DATADIRNAME = @DATADIRNAME@ G10_LOCALEDIR = @G10_LOCALEDIR@ diff --git a/acconfig.h b/acconfig.h index 477ef64ef..50014cf39 100644 --- a/acconfig.h +++ b/acconfig.h @@ -33,6 +33,7 @@ #undef PACKAGE #undef G10_LOCALEDIR #undef PRINTABLE_OS_NAME +#undef GNUPG_LIBDIR /* Define if your locale.h file contains LC_MESSAGES. */ #undef HAVE_LC_MESSAGES diff --git a/cipher/ChangeLog b/cipher/ChangeLog index 79f3dc171..6e59455a9 100644 --- a/cipher/ChangeLog +++ b/cipher/ChangeLog @@ -1,3 +1,8 @@ +Wed Jun 10 07:52:08 1998 Werner Koch,mobil,,, (wk@tobold) + + * dynload.c: New + * cipher.c: Major changes to allow extensions. + Mon Jun 8 22:43:00 1998 Werner Koch (wk@isil.d.shuttle.de) * cipher.c: Major internal chnages to support extensions. diff --git a/cipher/cipher.c b/cipher/cipher.c index 5d39c3ca3..6ac468274 100644 --- a/cipher/cipher.c +++ b/cipher/cipher.c @@ -32,21 +32,23 @@ #include "blowfish.h" #include "cast5.h" #include "des.h" +#include "dynload.h" -#include <dlfcn.h> #define STD_BLOCKSIZE 8 #define TABLE_SIZE 20 -static struct { +struct cipher_table_s { const char *name; int algo; - int keylen; - int contextsize; /* allocate this amount of context */ + size_t keylen; + size_t contextsize; /* allocate this amount of context */ void (*setkey)( void *c, byte *key, unsigned keylen ); void (*encrypt)( void *c, byte *outbuf, byte *inbuf ); void (*decrypt)( void *c, byte *outbuf, byte *inbuf ); -} cipher_table[TABLE_SIZE]; +}; + +static struct cipher_table_s cipher_table[TABLE_SIZE]; struct cipher_handle_s { @@ -142,56 +144,54 @@ static int load_cipher_modules() { static int done = 0; + void *context = NULL; + struct cipher_table_s *ct; + int ct_idx; + size_t blocksize; + int i; + const char *name; + int any = 0; - if( !done ) { - void *handle; - char **name; - void *sym; - void * (*enumfunc)(int, int*, int*, int*); - const char *err; - - log_debug("load_cipher_modules\n"); - handle = dlopen("/sahara/proj/psst+g10/non-free-src/rsa+idea.so", RTLD_LAZY); - if( !handle ) - log_bug("dlopen(rsa+idea) failed: %s\n", dlerror() ); - name = (char**)dlsym(handle, "gnupgext_version"); - if( (err=dlerror()) ) - log_error("dlsym: gnupgext_version not found: %s\n", err ); - else { - log_debug("dlsym: gnupgext_version='%s'\n", *name ); - sym = dlsym(handle, "gnupgext_enum_func"); - if( (err=dlerror()) ) - log_error("dlsym: gnupgext_enum_func not found: %s\n", err ); - else { - int seq = 0; - int class, vers; - - enumfunc = (void *(*)(int,int*,int*,int*))sym; - while( (sym = enumfunc(0, &seq, &class, &vers)) ) { - if( vers != 1 ) { - log_debug("ignoring extfunc with version %d\n", vers); - continue; - } - switch( class ) { - case 11: - case 21: - case 31: - log_info("provides %s algorithm %d\n", - class == 11? "md" : - class == 21? "cipher" : "pubkey", - *(int*)sym); - break; - default: - log_debug("skipping class %d\n", class); - } - } - } + if( done ) + return 0; + done = 1; + + for(ct_idx=0, ct = cipher_table; ct_idx < TABLE_SIZE; ct_idx++,ct++ ) { + if( !ct->name ) + break; + } + if( ct_idx >= TABLE_SIZE-1 ) + BUG(); /* table already full */ + /* now load all extensions */ + while( (name = enum_gnupgext_ciphers( &context, &ct->algo, + &ct->keylen, &blocksize, &ct->contextsize, + &ct->setkey, &ct->encrypt, &ct->decrypt)) ) { + if( blocksize != STD_BLOCKSIZE ) { + log_info("skipping cipher %d: unsupported blocksize\n", ct->algo); + continue; + } + for(i=0; cipher_table[i].name; i++ ) + if( cipher_table[i].algo == ct->algo ) + break; + if( cipher_table[i].name ) { + log_info("skipping cipher %d: already loaded\n", ct->algo ); + continue; + } + /* put it into the table */ + log_info("loaded cipher %d (%s)\n", ct->algo, name); + ct->name = name; + ct_idx++; + ct++; + any = 1; + /* check whether there are more available table slots */ + if( ct_idx >= TABLE_SIZE-1 ) { + log_info("cipher table full; ignoring other extensions\n"); + break; } - dlclose(handle); - done = 1; } - - return 0; + enum_gnupgext_ciphers( &context, NULL, NULL, NULL, NULL, + NULL, NULL, NULL ); + return any; } diff --git a/cipher/dynload.c b/cipher/dynload.c index 19e035d9d..b40eb4056 100644 --- a/cipher/dynload.c +++ b/cipher/dynload.c @@ -18,13 +18,194 @@ * 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 <dlfcn.h> +#include "util.h" +#include "cipher.h" #include "dynload.h" +typedef struct ext_list { + struct ext_list *next; + void *handle; /* handle from dlopen() */ + int failed; /* already tried but failed */ + void * (*enumfunc)(int, int*, int*, int*); + char name[1]; +} *EXTLIST; + +static EXTLIST extensions; + +typedef struct { + EXTLIST r; + int seq1; + int seq2; + void *sym; +} ENUMCONTEXT; + +/**************** + * Register an extension module. The last registered module will + * be loaded first. + */ +void +register_cipher_extension( const char *fname ) +{ + EXTLIST r, el; + + if( *fname != '/' ) { /* do tilde expansion etc */ + char *p ; + + if( strchr(fname, '/') ) + p = make_filename(fname, NULL); + else + p = make_filename(GNUPG_LIBDIR, fname, NULL); + el = m_alloc_clear( sizeof *el + strlen(p) ); + strcpy(el->name, p ); + m_free(p); + } + else { + el = m_alloc_clear( sizeof *el + strlen(fname) ); + strcpy(el->name, fname ); + } + /* check that it is not already registered */ + for(r = extensions; r; r = r->next ) + if( !compare_filenames(r->name, el->name) ) { + log_debug("extension '%s' already registered\n", el->name ); + m_free(el); + return; + } + log_debug("extension '%s' registered\n", el->name ); + /* and register */ + el->next = extensions; + extensions = el; +} + + +static int +load_extension( EXTLIST el ) +{ + char **name; + void *sym; + const char *err; + int seq = 0; + int class, vers; + + el->handle = dlopen(el->name, RTLD_LAZY); + if( !el->handle ) { + log_error("%s: error loading extension: %s\n", el->name, dlerror() ); + goto failure; + } + name = (char**)dlsym(el->handle, "gnupgext_version"); + if( (err=dlerror()) ) { + log_error("%s: not a gnupg extension: %s\n", el->name, err ); + goto failure; + } + + log_info("%s: version '%s'\n", el->name, *name ); + + sym = dlsym(el->handle, "gnupgext_enum_func"); + if( (err=dlerror()) ) { + log_error("%s: invalid gnupg extension: %s\n", el->name, err ); + goto failure; + } + el->enumfunc = (void *(*)(int,int*,int*,int*))sym; + + /* list the contents of the module */ + while( (sym = (*el->enumfunc)(0, &seq, &class, &vers)) ) { + if( vers != 1 ) { + log_error("%s: ignoring func with version %d\n", el->name, vers); + continue; + } + switch( class ) { + case 11: + case 21: + case 31: + log_info("%s: provides %s algorithm %d\n", el->name, + class == 11? "md" : + class == 21? "cipher" : "pubkey", + *(int*)sym); + break; + default: + log_debug("%s: skipping class %d\n", el->name, class); + } + } + return 0; + + failure: + if( el->handle ) { + dlclose(el->handle); + el->handle = NULL; + } + el->failed = 1; + return -1; +} + + + +const char * +enum_gnupgext_ciphers( void **enum_context, int *algo, + size_t *keylen, size_t *blocksize, size_t *contextsize, + void (**setkey)( void *c, byte *key, unsigned keylen ), + void (**encrypt)( void *c, byte *outbuf, byte *inbuf ), + void (**decrypt)( void *c, byte *outbuf, byte *inbuf ) + ) +{ + EXTLIST r; + ENUMCONTEXT *ctx; + const char * (*finfo)(int, size_t*, size_t*, size_t*, + void (**)( void *, byte *, unsigned), + void (**)( void *, byte *, byte *), + void (**)( void *, byte *, byte *)); + + if( !*enum_context ) { /* init context */ + ctx = m_alloc_clear( sizeof( *ctx ) ); + ctx->r = extensions; + *enum_context = ctx; + } + else if( !algo ) { /* release the context */ + m_free(*enum_context); + *enum_context = NULL; + return NULL; + } + else + ctx = *enum_context; + + for( r = ctx->r; r; r = r->next ) { + int class, vers; + if( r->failed ) + continue; + if( !r->handle && load_extension(r) ) + continue; + /* get a cipher info function */ + if( ctx->sym ) + goto inner_loop; + while( (ctx->sym = (*r->enumfunc)(20, &ctx->seq1, &class, &vers)) ) { + void *sym; + /* must check class because enumfunc may be wrong coded */ + if( vers != 1 || class != 20 ) + continue; + inner_loop: + finfo = ctx->sym; + while( (sym = (*r->enumfunc)(21, &ctx->seq2, &class, &vers)) ) { + const char *algname; + if( vers != 1 || class != 21 ) + continue; + *algo = *(int*)sym; + algname = (*finfo)( *algo, keylen, blocksize, contextsize, + setkey, encrypt, decrypt ); + log_debug("found algo %d (%s)\n", *algo, algname ); + if( algname ) { + ctx->r = r; + return algname; + } + } + ctx->seq2 = 0; + } + ctx->seq1 = 0; + } + ctx->r = r; + return NULL; +} diff --git a/cipher/dynload.h b/cipher/dynload.h index a839a91b3..78f41c644 100644 --- a/cipher/dynload.h +++ b/cipher/dynload.h @@ -20,5 +20,12 @@ #ifndef G10_CIPHER_DYNLOAD_H #define G10_CIPHER_DYNLOAD_H +const char * +enum_gnupgext_ciphers( void **enum_context, int *algo, + size_t *keylen, size_t *blocksize, size_t *contextsize, + void (**setkey)( void *c, byte *key, unsigned keylen ), + void (**encrypt)( void *c, byte *outbuf, byte *inbuf ), + void (**decrypt)( void *c, byte *outbuf, byte *inbuf ) + ); #endif /*G10_CIPHER_DYNLOAD_H*/ diff --git a/cipher/pubkey.c b/cipher/pubkey.c new file mode 100644 index 000000000..3ffc1ca33 --- /dev/null +++ b/cipher/pubkey.c @@ -0,0 +1,84 @@ +/* pubkey.c - pubkey dispatcher + * Copyright (C) 1998 Free Software Foundation, Inc. + * + * This file is part of GNUPG. + * + * GNUPG 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. + * + * GNUPG 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 "util.h" +#include "errors.h" +#include "mpi.h" +#include "cipher.h" +#include "dynload.h" + + +/**************** + * This is the interface for the public key decryption. + * ALGO gives the algorithm to use and this implicitly determines + * the size of the arrays. + * result is a pointer to a mpi variable which will receive a + * newly allocated mpi or NULL in case of an error. + */ +int +pubkey_decrypt( int algo, MPI *result, int ndata, MPI *data, + int nskey, MPI *skey ) +{ + MPI plain = NULL; + + *result = NULL; /* so the caller can do always do an mpi_free */ + if( DBG_CIPHER ) { + int i; + log_debug("pubkey_decrypt: algo=%d\n", algo ); + for(i=0; i < nskey; i++ ) + log_mpidump(" skey:", skey[i] ); + for(i=0; i < ndata; i++ ) + log_mpidump(" data:", data[i] ); + } + if( is_ELGAMAL(algo) ) { + ELG_secret_key sk; + assert( ndata == 2 && nskey == 4 ); + sk.p = skey[0]; + sk.g = skey[1]; + sk.y = skey[2]; + sk.x = skey[3]; + plain = mpi_alloc_secure( mpi_get_nlimbs( sk.p ) ); + elg_decrypt( plain, data[0], data[1], &sk ); + } + else if( is_RSA(k->pubkey_algo) ) { + RSA_secret_key sk; + assert( ndata == 1 && nskey == 6 ); + sk.e = skey[0]; + sk.n = skey[1]; + sk.p = skey[2]; + sk.q = skey[3]; + sk.d = skey[4]; + sk.u = skey[5]; + plain = mpi_alloc_secure( mpi_get_nlimbs(sk.n) ); + rsa_secret( plain, data[0], &sk ); + } + else + return G10ERR_PUBKEY_ALGO; + *result = plain; + return 0; +} + + diff --git a/cipher/rand-dummy.c b/cipher/rand-dummy.c index 3e7a42573..e2c754ebb 100644 --- a/cipher/rand-dummy.c +++ b/cipher/rand-dummy.c @@ -69,7 +69,7 @@ fast_random_poll() { #if HAVE_GETHRTIME { hrtime_t tv; - tv = gethrtime(void); + tv = gethrtime(); add_randomness( &tv, sizeof(tv), 1 ); } #elif HAVE_GETTIMEOFTIME diff --git a/config.h.in b/config.h.in index 3be8f18f1..c6a178af1 100644 --- a/config.h.in +++ b/config.h.in @@ -88,6 +88,7 @@ #undef PACKAGE #undef G10_LOCALEDIR #undef PRINTABLE_OS_NAME +#undef GNUPG_LIBDIR /* Define if your locale.h file contains LC_MESSAGES. */ #undef HAVE_LC_MESSAGES diff --git a/configure.in b/configure.in index 7a3093bfd..37e0bc6b0 100644 --- a/configure.in +++ b/configure.in @@ -86,6 +86,7 @@ case "${target}" in RANLIB="i386--mingw32-ranlib" ac_cv_have_dev_random=no AC_DEFINE(USE_RAND_W32) + GNUPG_LIBDIR="c:/lib/gnupg" ;; *) AC_PROG_RANLIB @@ -93,8 +94,10 @@ AC_PROG_INSTALL AC_PROG_CC AC_PROG_CPP AC_DEFINE(USE_RAND_UNIX) + GNUPG_LIBDIR="$g10_prefix/lib/gnupg" ;; esac +AC_DEFINE_UNQUOTED(GNUPG_LIBDIR, "$GNUPG_LIBDIR") case "${target}" in i386--mingw32) diff --git a/g10/ChangeLog b/g10/ChangeLog index 9b42cb3d8..a10527cf1 100644 --- a/g10/ChangeLog +++ b/g10/ChangeLog @@ -1,3 +1,7 @@ +Wed Jun 10 07:22:02 1998 Werner Koch,mobil,,, (wk@tobold) + + * g10.c ("load-extension"): New option. + Mon Jun 8 22:23:37 1998 Werner Koch (wk@isil.d.shuttle.de) * seckey-cert.c (do_check): Removed cipher constants diff --git a/g10/Makefile.am b/g10/Makefile.am index fdf5f28b8..3e20a48c2 100644 --- a/g10/Makefile.am +++ b/g10/Makefile.am @@ -3,6 +3,7 @@ INCLUDES = -I$(top_srcdir)/include -I$(top_srcdir)/intl -I../intl EXTRA_DIST = OPTIONS pubring.asc OMIT_DEPENDENCIES = zlib.h zconf.h +LDFLAGS = -rdynamic needed_libs = ../cipher/libcipher.a ../mpi/libmpi.a ../util/libutil.a noinst_PROGRAMS = gpgd diff --git a/g10/Makefile.in b/g10/Makefile.in index bc306754b..eba874517 100644 --- a/g10/Makefile.in +++ b/g10/Makefile.in @@ -93,6 +93,7 @@ l = @l@ INCLUDES = -I$(top_srcdir)/include -I$(top_srcdir)/intl -I../intl EXTRA_DIST = OPTIONS pubring.asc OMIT_DEPENDENCIES = zlib.h zconf.h +LDFLAGS = -rdynamic needed_libs = ../cipher/libcipher.a ../mpi/libmpi.a ../util/libutil.a noinst_PROGRAMS = gpgd @@ -170,7 +171,6 @@ PROGRAMS = $(bin_PROGRAMS) $(noinst_PROGRAMS) DEFS = @DEFS@ -I. -I$(srcdir) -I.. CPPFLAGS = @CPPFLAGS@ -LDFLAGS = @LDFLAGS@ LIBS = @LIBS@ gpg_OBJECTS = g10.o build-packet.o compress.o free-packet.o getkey.o \ pkclist.o skclist.o ringedit.o kbnode.o mainproc.o armor.o mdfilter.o \ diff --git a/g10/encode.c b/g10/encode.c index 142ffeac2..d3d88ca7b 100644 --- a/g10/encode.c +++ b/g10/encode.c @@ -89,7 +89,7 @@ encode_simple( const char *filename, int mode ) cfx.dek = NULL; if( mode ) { s2k = m_alloc_clear( sizeof *s2k ); - s2k->mode = 1; + s2k->mode = opt.rfc1991? 0:1; s2k->hash_algo = opt.def_digest_algo ? opt.def_digest_algo : DEFAULT_DIGEST_ALGO; cfx.dek = passphrase_to_dek( NULL, opt.def_cipher_algo, s2k, 2 ); @@ -116,7 +116,7 @@ encode_simple( const char *filename, int mode ) write_comment( out, "#created by GNUPG v" VERSION " (" PRINTABLE_OS_NAME ")"); - if( s2k ) { + if( s2k && !opt.rfc1991 ) { PKT_symkey_enc *enc = m_alloc_clear( sizeof *enc ); enc->version = 4; enc->cipher_algo = cfx.dek->algo; @@ -111,6 +111,8 @@ static ARGPARSE_OPTS opts[] = { { 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)")}, + { 560, "load-extension" ,2, N_("|file|load extension module")}, + { 561, "rfc1991", 0, N_("emulate the mode described in RFC1991")}, #ifdef IS_G10 { 527, "cipher-algo", 2 , N_("|NAME|use cipher algorithm NAME")}, { 528, "pubkey-algo", 2 , N_("|NAME|use public key algorithm NAME")}, @@ -427,7 +429,7 @@ main( int argc, char **argv ) orig_argv = argv; pargs.argc = &argc; pargs.argv = &argv; - pargs.flags= 1; /* do not remove the args */ + pargs.flags= 1|(1<<6); /* do not remove the args, ignore version */ while( arg_parse( &pargs, opts) ) { if( pargs.r_opt == 510 || pargs.r_opt == 511 ) parse_debug++; @@ -586,6 +588,8 @@ main( int argc, char **argv ) case 557: opt.compress_keys = 1; break; case 558: set_cmd( &cmd, aListSecretKeys); break; case 559: opt.always_trust = 1; break; + case 560: register_cipher_extension(pargs.r.ret_str); break; + case 561: opt.rfc1991 = 1; break; default : errors++; pargs.err = configfp? 1:2; break; } } diff --git a/g10/options.h b/g10/options.h index 8bc30eeba..4b32b524c 100644 --- a/g10/options.h +++ b/g10/options.h @@ -47,6 +47,7 @@ struct { int skip_verify; int compress_keys; int always_trust; + int rfc1991; } opt; diff --git a/g10/packet.h b/g10/packet.h index 3fc1ea280..cb9740cc6 100644 --- a/g10/packet.h +++ b/g10/packet.h @@ -27,12 +27,6 @@ #include "cipher.h" #include "filter.h" -#ifndef HAVE_RSA_CIPHER -/* although we don't have RSA we need these structures to handle keyrings */ -typedef struct { MPI e, n; } RSA_public_key; -typedef struct { MPI e, n, p, q, d, u; } RSA_secret_key; -#endif - typedef enum { PKT_NONE =0, PKT_PUBKEY_ENC =1, /* public key encrypted packet */ @@ -74,14 +68,8 @@ typedef struct { u32 keyid[2]; /* 64 bit keyid */ byte version; byte pubkey_algo; /* algorithm used for public key scheme */ - union { - struct { - MPI a, b; /* integers with the encrypteded DEK */ - } elg; - struct { - MPI rsa_integer; /* integer containing the DEK */ - } rsa; - } d; + int mpi_count; /* 1 for rsa, 2 for ELG */ + MPI material[2]; /* (ELG needs 2) } PKT_pubkey_enc; diff --git a/g10/pubkey-enc.c b/g10/pubkey-enc.c index 8f15057ec..8b48255dc 100644 --- a/g10/pubkey-enc.c +++ b/g10/pubkey-enc.c @@ -46,10 +46,11 @@ get_session_key( PKT_pubkey_enc *k, DEK *dek ) u16 csum, csum2; PKT_secret_cert *skc = m_alloc_clear( sizeof *skc ); - #ifndef HAVE_RSA_CIPHER - if( is_RSA(k->pubkey_algo) ) + if( is_RSA(k->pubkey_algo) ) /* warn about that */ write_status(STATUS_RSA_OR_IDEA); - #endif + rc=check_pubkey_algo( k->pubkey_algo ); + if( rc ) + goto leave; skc->pubkey_algo = k->pubkey_algo; /* we want a pubkey with this algo*/ if( (rc = get_seckey( skc, k->keyid )) ) @@ -63,7 +64,6 @@ get_session_key( PKT_pubkey_enc *k, DEK *dek ) plain_dek = mpi_alloc_secure( mpi_get_nlimbs(skc->d.elg.p) ); elg_decrypt( plain_dek, k->d.elg.a, k->d.elg.b, &skc->d.elg ); } - #ifdef HAVE_RSA_CIPHER else if( is_RSA(k->pubkey_algo) ) { if( DBG_CIPHER ) log_mpidump("Encr DEK frame:", k->d.rsa.rsa_integer ); @@ -71,8 +71,8 @@ get_session_key( PKT_pubkey_enc *k, DEK *dek ) plain_dek = mpi_alloc_secure( mpi_get_nlimbs(skc->d.rsa.n) ); rsa_secret( plain_dek, k->d.rsa.rsa_integer, &skc->d.rsa ); } - #endif/*HAVE_RSA_CIPHER*/ else { + log_info("need some glue code for pubkey algo %d\n", k->pubkey_algo); rc = G10ERR_PUBKEY_ALGO; /* unsupported algorithm */ goto leave; } diff --git a/g10/sign.c b/g10/sign.c index 598f60998..bd435a7c9 100644 --- a/g10/sign.c +++ b/g10/sign.c @@ -183,7 +183,7 @@ sign_file( STRLIST filenames, int detached, STRLIST locusr, iobuf_push_filter( out, compress_filter, &zfx ); - if( !detached ) { + if( !detached && !opt.rfc1991 ) { /* loop over the secret certificates and build headers */ for( skc_rover = skc_list; skc_rover; skc_rover = skc_rover->next ) { PKT_secret_cert *skc; @@ -254,6 +254,8 @@ sign_file( STRLIST filenames, int detached, STRLIST locusr, * data, it is not possible to know the used length * without a double read of the file - to avoid that * we simple use partial length packets. + * FIXME: We have to do the double read when opt.rfc1991 + * is active. */ if( opt.textmode && !outfile ) filesize = 0; @@ -449,9 +451,10 @@ clearsign_file( const char *fname, STRLIST locusr, const char *outfile ) goto leave; } - /* FIXME: This stuff is not correct if mutliplehash algos are used*/ + /* FIXME: This stuff is not correct if mutliple hash algos are used*/ iobuf_writestr(out, "-----BEGIN PGP SIGNED MESSAGE-----\n" ); - if( (opt.def_digest_algo?opt.def_digest_algo:DEFAULT_DIGEST_ALGO) + if( opt.rfc1991 + || (opt.def_digest_algo?opt.def_digest_algo:DEFAULT_DIGEST_ALGO) == DIGEST_ALGO_MD5 ) iobuf_writestr(out, "\n" ); else { diff --git a/include/cipher.h b/include/cipher.h index 502825553..186851a33 100644 --- a/include/cipher.h +++ b/include/cipher.h @@ -86,6 +86,9 @@ struct cipher_handle_s { char does_not_matter[1]; }; int cipher_debug_mode; +/*-- dynload.c --*/ +void register_cipher_extension( const char *fname ); + /*-- cipher.c --*/ int string_to_cipher_algo( const char *string ); const char * cipher_algo_to_string( int algo ); diff --git a/include/mpi.h b/include/mpi.h index 9a151291c..0725b7d6b 100644 --- a/include/mpi.h +++ b/include/mpi.h @@ -1,15 +1,14 @@ /* mpi.h - Multi Precision Integers - * Copyright (c) 1997 by Werner Koch (dd9jn) - * Copyright (C) 1994, 1996 Free Software Foundation, Inc. + * Copyright (C) 1994, 1996, 1998 Free Software Foundation, Inc. * - * This file is part of G10. + * This file is part of GNUPG. * - * G10 is free software; you can redistribute it and/or modify + * GNUPG 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, + * GNUPG 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. diff --git a/include/util.h b/include/util.h index 5fcce6063..3dec01cdd 100644 --- a/include/util.h +++ b/include/util.h @@ -101,6 +101,7 @@ const char *strusage( int level ); /*-- fileutil.c --*/ char *make_filename( const char *first_part, ... ); +int compare_filenames( const char *a, const char *b ); const char *print_fname_stdin( const char *s ); const char *print_fname_stdout( const char *s ); diff --git a/mpi/Makefile.in b/mpi/Makefile.in index cd14c3849..ac020c553 100644 --- a/mpi/Makefile.in +++ b/mpi/Makefile.in @@ -64,8 +64,6 @@ target_triplet = @target@ CATALOGS = @CATALOGS@ CATOBJEXT = @CATOBJEXT@ CC = @CC@ -CIPHER_EXTRA_DIST = @CIPHER_EXTRA_DIST@ -CIPHER_EXTRA_OBJS = @CIPHER_EXTRA_OBJS@ CPP = @CPP@ DATADIRNAME = @DATADIRNAME@ G10_LOCALEDIR = @G10_LOCALEDIR@ diff --git a/tools/Makefile.in b/tools/Makefile.in index 96f53d4cb..d9e4e7ad0 100644 --- a/tools/Makefile.in +++ b/tools/Makefile.in @@ -64,8 +64,6 @@ target_triplet = @target@ CATALOGS = @CATALOGS@ CATOBJEXT = @CATOBJEXT@ CC = @CC@ -CIPHER_EXTRA_DIST = @CIPHER_EXTRA_DIST@ -CIPHER_EXTRA_OBJS = @CIPHER_EXTRA_OBJS@ CPP = @CPP@ DATADIRNAME = @DATADIRNAME@ G10_LOCALEDIR = @G10_LOCALEDIR@ diff --git a/tools/mk-tdata b/tools/mk-tdata Binary files differindex 85e20d812..7fcfb389f 100755 --- a/tools/mk-tdata +++ b/tools/mk-tdata diff --git a/util/ChangeLog b/util/ChangeLog index a62ba84db..b2a1d21b7 100644 --- a/util/ChangeLog +++ b/util/ChangeLog @@ -1,3 +1,9 @@ +Wed Jun 10 07:39:41 1998 Werner Koch,mobil,,, (wk@tobold) + + * fileutil.c (compare_filenames): New. + + * argparse.c (arg_parse): New flag bit 6 to ignore --version + Thu May 14 16:45:13 1998 Werner Koch (wk@isil.d.shuttle.de) * argparse.c (show_help): Add some formatting stuff diff --git a/util/Makefile.in b/util/Makefile.in index 025ea3f8e..5e50aabcf 100644 --- a/util/Makefile.in +++ b/util/Makefile.in @@ -64,8 +64,6 @@ target_triplet = @target@ CATALOGS = @CATALOGS@ CATOBJEXT = @CATOBJEXT@ CC = @CC@ -CIPHER_EXTRA_DIST = @CIPHER_EXTRA_DIST@ -CIPHER_EXTRA_OBJS = @CIPHER_EXTRA_OBJS@ CPP = @CPP@ DATADIRNAME = @DATADIRNAME@ G10_LOCALEDIR = @G10_LOCALEDIR@ diff --git a/util/argparse.c b/util/argparse.c index ce1dbc6af..9a9909e30 100644 --- a/util/argparse.c +++ b/util/argparse.c @@ -72,6 +72,7 @@ * Bit 3 : Do not use -- to stop option processing. * Bit 4 : Do not skip the first arg. * Bit 5 : allow usage of long option with only one dash + * Bit 6 : ignore --version * all other bits must be set to zero, this value is modified by the function * so assume this is write only. * Local flags (for each option): @@ -377,8 +378,10 @@ arg_parse( ARGPARSE_ARGS *arg, ARGPARSE_OPTS *opts) if( !opts[i].short_opt && !strcmp( "help", s+2) ) show_help(opts, arg->flags); else if( !opts[i].short_opt && !strcmp( "version", s+2) ) { - show_version(); - exit(0); + if( !(arg->flags & (1<<6)) ) { + show_version(); + exit(0); + } } else if( !opts[i].short_opt && !strcmp( "warranty", s+2) ) { puts( strusage(16) ); diff --git a/util/fileutil.c b/util/fileutil.c index 88c84ecff..2cedf0f9e 100644 --- a/util/fileutil.c +++ b/util/fileutil.c @@ -65,6 +65,20 @@ make_filename( const char *first_part, ... ) } +int +compare_filenames( const char *a, const char *b ) +{ + /* ? check whether this is an absolute filename and + * resolve symlinks? + */ + #ifdef __MINGW32__ + return stricmp(a,b); + #else + return strcmp(a,b); + #endif +} + + /**************** * A simple function to decide whether the filename is stdout * or a real filename. diff --git a/zlib/Makefile b/zlib/Makefile index 6d752930c..0330f59c5 100644 --- a/zlib/Makefile +++ b/zlib/Makefile @@ -69,8 +69,6 @@ target_triplet = i586-pc-linux-gnu CATALOGS = de.gmo it.gmo CATOBJEXT = .gmo CC = gcc -CIPHER_EXTRA_DIST = @CIPHER_EXTRA_DIST@ -CIPHER_EXTRA_OBJS = @CIPHER_EXTRA_OBJS@ CPP = gcc -E DATADIRNAME = share G10_LOCALEDIR = /usr/local/share/locale diff --git a/zlib/Makefile.in b/zlib/Makefile.in index 1e489370a..07f93df52 100644 --- a/zlib/Makefile.in +++ b/zlib/Makefile.in @@ -69,8 +69,6 @@ target_triplet = @target@ CATALOGS = @CATALOGS@ CATOBJEXT = @CATOBJEXT@ CC = @CC@ -CIPHER_EXTRA_DIST = @CIPHER_EXTRA_DIST@ -CIPHER_EXTRA_OBJS = @CIPHER_EXTRA_OBJS@ CPP = @CPP@ DATADIRNAME = @DATADIRNAME@ G10_LOCALEDIR = @G10_LOCALEDIR@ |