diff options
-rw-r--r-- | README | 5 | ||||
-rw-r--r-- | THANKS | 1 | ||||
-rw-r--r-- | mpi/ChangeLog | 9 | ||||
-rw-r--r-- | mpi/mpicoder.c | 44 | ||||
-rw-r--r-- | mpi/mpiutil.c | 65 |
5 files changed, 115 insertions, 9 deletions
@@ -22,7 +22,7 @@ "pub 1312G/FF3EAA0B 1998-02-09 Werner Koch <wk@isil.d.shuttle.de>" "Key fingerprint = 8489 6CD0 1851 0E33 45DA CD67 036F 11B8 FF3E AA0B" - My standard key is now: + My usual key is now: "pub 1024D/621CC013 1998-07-07 Werner Koch <werner.koch@guug.de>" "Key fingerprint = ECAF 7590 EB34 43B5 C7CF 3ACB 6C7E E1B8 621C C013" @@ -42,7 +42,8 @@ IDEA (which is patented worldwide) and RSA (which is patented in the United States until Sep 20, 2000). - GNUPG is in most aspects compatible with other OpenPGP implementations. + GNUPG is in almost all aspects compatible with other OpenPGP + implementations. The default algorithms are now DSA and ELGamal. ELGamal for signing is still available, but due to the larger size of such signatures it @@ -29,6 +29,7 @@ Nicolas Graner Nicolas.Graner@cri.u-psud.fr Oskari Jääskeläinen f33003a@cc.hut.fi Peter Gutmann pgut001@cs.auckland.ac.nz Ralph Gillen gillen@theochem.uni-duesseldorf.de +Serge Munhoven munhoven@mema.ucl.ac.be Steffen Ullrich ccrlphr@xensei.com Thomas Roessler roessler@guug.de Tom Spindler dogcow@home.merit.edu diff --git a/mpi/ChangeLog b/mpi/ChangeLog index babbabdf..3fc0b332 100644 --- a/mpi/ChangeLog +++ b/mpi/ChangeLog @@ -1,3 +1,12 @@ +Wed Aug 5 15:11:12 1998 Werner Koch (wk@(none)) + + * mpicoder.c (mpi_read_from_buffer): New. + + * mpiutil.c (mpi_set_opaque): New. + (mpi_get_opaque): New. + (mpi_copy): Changed to support opauqe flag + (mpi_free): Ditto. + Sat Jul 4 10:11:11 1998 Werner Koch (wk@isil.d.shuttle.de) * mpiutil.c (mpi_clear): Reset flags. diff --git a/mpi/mpicoder.c b/mpi/mpicoder.c index eba82a28..2775f5be 100644 --- a/mpi/mpicoder.c +++ b/mpi/mpicoder.c @@ -123,6 +123,50 @@ mpi_read(IOBUF inp, unsigned *ret_nread, int secure) } +MPI +mpi_read_from_buffer(byte *buffer, unsigned *ret_nread, int secure) +{ + int i, j; + unsigned nbits, nbytes, nlimbs, nread=0; + mpi_limb_t a; + MPI val = MPI_NULL; + + if( *ret_nread < 2 ) + goto leave; + nbits = buffer[0] << 8 | buffer[1]; + if( nbits > MAX_EXTERN_MPI_BITS ) { + log_error("mpi too large (%u bits)\n", nbits); + goto leave; + } + buffer += 2; + nread = 2; + + nbytes = (nbits+7) / 8; + nlimbs = (nbytes+BYTES_PER_MPI_LIMB-1) / BYTES_PER_MPI_LIMB; + val = secure? mpi_alloc_secure( nlimbs ) + : mpi_alloc( nlimbs ); + i = BYTES_PER_MPI_LIMB - nbytes % BYTES_PER_MPI_LIMB; + i %= BYTES_PER_MPI_LIMB; + val->nbits = nbits; + j= val->nlimbs = nlimbs; + val->sign = 0; + for( ; j > 0; j-- ) { + a = 0; + for(; i < BYTES_PER_MPI_LIMB; i++ ) { + if( ++nread > *ret_nread ) + log_bug("mpi larger than buffer"); + a <<= 8; + a |= *buffer++; + } + i = 0; + val->d[j-1] = a; + } + + leave: + *ret_nread = nread; + return val; +} + /**************** * Make an mpi from a character string. diff --git a/mpi/mpiutil.c b/mpi/mpiutil.c index c9af5056..f2f1726c 100644 --- a/mpi/mpiutil.c +++ b/mpi/mpiutil.c @@ -193,12 +193,16 @@ mpi_free( MPI a ) return; if( DBG_MEMORY ) log_debug("mpi_free\n" ); - #ifdef M_DEBUG - mpi_debug_free_limb_space(a->d, info); - #else - mpi_free_limb_space(a->d); - #endif - if( a->flags & ~3 ) + if( a->flags & 4 ) + m_free( a->d ); + else { + #ifdef M_DEBUG + mpi_debug_free_limb_space(a->d, info); + #else + mpi_free_limb_space(a->d); + #endif + } + if( a->flags & ~7 ) log_bug("invalid flag value in mpi\n"); m_free(a); } @@ -232,6 +236,47 @@ mpi_set_secure( MPI a ) } +MPI +mpi_set_opaque( MPI a, void *p, int len ) +{ + if( !a ) { + #ifdef M_DEBUG + a = mpi_debug_alloc(0,"alloc_opaque"); + #else + a = mpi_alloc(0); + #endif + } + + if( a->flags & 4 ) + m_free( a->d ); + else { + #ifdef M_DEBUG + mpi_debug_free_limb_space(a->d, "alloc_opaque"); + #else + mpi_free_limb_space(a->d); + #endif + } + + a->d = p; + a->alloced = 0; + a->nlimbs = 0; + a->nbits = len; + a->flags = 4; + return a; +} + + +void * +mpi_get_opaque( MPI a, int *len ) +{ + if( !(a->flags & 4) ) + log_bug("mpi_get_opaque on normal mpi\n"); + if( len ) + *len = a->nbits; + return a->d; +} + + /**************** * Note: This copy function should not interpret the MPI * but copy it transparently. @@ -246,7 +291,13 @@ mpi_copy( MPI a ) int i; MPI b; - if( a ) { + if( a && (a->flags & 4) ) { + void *p = m_is_secure(a->d)? m_alloc_secure( a->nbits ) + : m_alloc( a->nbits ); + memcpy( p, a->d, a->nbits ); + b = mpi_set_opaque( NULL, p, a->nbits ); + } + else if( a ) { #ifdef M_DEBUG b = mpi_is_secure(a)? mpi_debug_alloc_secure( a->nlimbs, info ) : mpi_debug_alloc( a->nlimbs, info ); |