diff options
Diffstat (limited to 'g10/misc.c')
-rw-r--r-- | g10/misc.c | 50 |
1 files changed, 2 insertions, 48 deletions
diff --git a/g10/misc.c b/g10/misc.c index f4728eb5d..ae553eb47 100644 --- a/g10/misc.c +++ b/g10/misc.c @@ -109,25 +109,11 @@ checksum_u16( unsigned n ) u16 a; a = (n >> 8) & 0xff; - if( opt.emulate_bugs & EMUBUG_GPGCHKSUM ) { - a |= n & 0xff; - log_debug("csum_u16 emulated for n=%u\n", n); - } - else - a += n & 0xff; - return a; -} - -static u16 -checksum_u16_nobug( unsigned n ) -{ - u16 a; - - a = (n >> 8) & 0xff; a += n & 0xff; return a; } + u16 checksum( byte *p, unsigned n ) { @@ -147,45 +133,13 @@ checksum_mpi( MPI a ) unsigned nbits; buffer = mpi_get_buffer( a, &nbytes, NULL ); - /* some versions of gpg encode wrong values for the length of an mpi - * so that mpi_get_nbits() which counts the mpi yields another (shorter) - * value than the one store with the mpi. mpi_get_nbit_info() returns - * this stored value if it is still available. - */ - - if( opt.emulate_bugs & EMUBUG_GPGCHKSUM ) - nbits = 0; - else - nbits = mpi_get_nbit_info(a); - if( !nbits ) - nbits = mpi_get_nbits(a); - csum = checksum_u16( nbits ); - csum += checksum( buffer, nbytes ); - m_free( buffer ); - return csum; -} - -/**************** - * This is the correct function - */ -u16 -checksum_mpi_counted_nbits( MPI a ) -{ - u16 csum; - byte *buffer; - unsigned nbytes; - unsigned nbits; - - buffer = mpi_get_buffer( a, &nbytes, NULL ); nbits = mpi_get_nbits(a); - mpi_set_nbit_info(a,nbits); - csum = checksum_u16_nobug( nbits ); + csum = checksum_u16( nbits ); csum += checksum( buffer, nbytes ); m_free( buffer ); return csum; } - u32 buffer_to_u32( const byte *buffer ) { |