diff options
author | Werner Koch <[email protected]> | 2002-09-11 07:27:54 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2002-09-11 07:27:54 +0000 |
commit | c5445cc3239e7654fbaf145c6e697de54093892f (patch) | |
tree | fb8e0b6e5018951bd13aade5f46b3444d2fe005c /g10/misc.c | |
parent | * exec.c (expand_args): Remove loop left over from earlier implementation. (diff) | |
download | gnupg-c5445cc3239e7654fbaf145c6e697de54093892f.tar.gz gnupg-c5445cc3239e7654fbaf145c6e697de54093892f.zip |
* g10.c, options.h: Removed option --emulate-checksum-bug.
* misc.c (checksum_u16_nobug): Removed.
(checksum_u16): Removed the bug emulation.
(checksum_mpi): Ditto.
(checksum_mpi_counted_nbits): Removed and replaced all calls
with checksum_mpi.
* parse-packet.c (read_protected_v3_mpi): New.
(parse_key): Use it here to store it as an opaque MPI.
* seckey-cert.c (do_check): Changed the v3 unprotection to the new
why to store these keys.
(protect_secret_key): Likewise.
* build-packet.c (do_secret_key): And changed the writing.
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 ) { |