From e6c975280ac0d01ad02669478465acc49a4dcfbb Mon Sep 17 00:00:00 2001 From: NIIBE Yutaka Date: Fri, 8 May 2020 11:42:20 +0900 Subject: [PATCH] ecc-sos: Remove zero-octet removal on write. * g10/build-packet.c (gpg_mpi_write): Don't remove zero bits. * g10/packet.h (CALC_NBITS): Remove. Signed-off-by: NIIBE Yutaka --- g10/build-packet.c | 8 -------- g10/packet.h | 10 ---------- 2 files changed, 18 deletions(-) diff --git a/g10/build-packet.c b/g10/build-packet.c index 2e100f179..e0570806e 100644 --- a/g10/build-packet.c +++ b/g10/build-packet.c @@ -304,14 +304,6 @@ gpg_mpi_write (iobuf_t out, gcry_mpi_t a, unsigned int *r_nwritten) /* gcry_log_debugmpi ("a", a); */ p = gcry_mpi_get_opaque (a, &nbits); - if (p) - { - nbits = ((nbits + 7)/8)*8; - /* Strip leading zero bits. */ - for (; nbits >= 8 && !*p; p++, nbits -= 8) - ; - CALC_NBITS (nbits, p); - } /* gcry_log_debug (" [%u bit]\n", nbits); */ /* gcry_log_debughex (" ", p, (nbits+7)/8); */ lenhdr[0] = nbits >> 8; diff --git a/g10/packet.h b/g10/packet.h index 7bf379af5..ed0749cb8 100644 --- a/g10/packet.h +++ b/g10/packet.h @@ -63,16 +63,6 @@ #define is_ELGAMAL(a) ((a)==PUBKEY_ALGO_ELGAMAL_E) #define is_DSA(a) ((a)==PUBKEY_ALGO_DSA) -#define CALC_NBITS(nbits,p) if (nbits >= 8 && !(*p & 0x80)) \ - if (--nbits >= 7 && !(*p & 0x40)) \ - if (--nbits >= 6 && !(*p & 0x20)) \ - if (--nbits >= 5 && !(*p & 0x10)) \ - if (--nbits >= 4 && !(*p & 0x08)) \ - if (--nbits >= 3 && !(*p & 0x04)) \ - if (--nbits >= 2 && !(*p & 0x02)) \ - if (--nbits >= 1 && !(*p & 0x01)) \ - --nbits - /* A pointer to the packet object. */ typedef struct packet_struct PACKET;