mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-02 22:46:30 +02:00
gpg: Allow printing of MPI values in --list-mode.
* g10/parse-packet.c (set_packet_list_mode): Set mpi_print_mode. * g10/misc.c (mpi_print): Do not print an extra leading zero. -- This was in older versions possible using "--debug 4" but that was disabled in 2.1 due to a conflict using this values also for Libgcrypt. Now the values are dumped either with --debug 4 or using --list-packets along with --verbose. Because OpenPGP only uses unsigned integers an extra leading zero will not be printed anymore. Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
8bc1debfef
commit
bcc8250bc5
3 changed files with 33 additions and 17 deletions
15
g10/misc.c
15
g10/misc.c
|
@ -1636,7 +1636,8 @@ pubkey_nbits( int algo, gcry_mpi_t *key )
|
|||
int
|
||||
mpi_print (estream_t fp, gcry_mpi_t a, int mode)
|
||||
{
|
||||
int n=0;
|
||||
int n = 0;
|
||||
size_t nwritten;
|
||||
|
||||
if (!a)
|
||||
return es_fprintf (fp, "[MPI_NULL]");
|
||||
|
@ -1654,19 +1655,19 @@ mpi_print (estream_t fp, gcry_mpi_t a, int mode)
|
|||
n += es_fprintf (fp, "[invalid opaque value]");
|
||||
else
|
||||
{
|
||||
nbits = (nbits + 7)/8;
|
||||
for (; nbits; nbits--, p++)
|
||||
n += es_fprintf (fp, "%02X", *p);
|
||||
if (!es_write_hexstring (fp, p, (nbits + 7)/8, 0, &nwritten))
|
||||
n += nwritten;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned char *buffer;
|
||||
size_t buflen;
|
||||
|
||||
if (gcry_mpi_aprint (GCRYMPI_FMT_HEX, &buffer, NULL, a))
|
||||
if (gcry_mpi_aprint (GCRYMPI_FMT_USG, &buffer, &buflen, a))
|
||||
BUG ();
|
||||
es_fputs (buffer, fp);
|
||||
n += strlen (buffer);
|
||||
if (!es_write_hexstring (fp, buffer, buflen, 0, &nwritten))
|
||||
n += nwritten;
|
||||
gcry_free (buffer);
|
||||
}
|
||||
return n;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue