1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-06-16 00:29:50 +02:00

gpg: Improve --version algo info output.

* g10/misc.c (openpgp_pk_algo_name): Return a different string for
each ECC algorithm.
* g10/gpg.c (build_list_pk_test_algo): New wrapper to cope with the
different algo type enums.
(build_list_pk_algo_name): Ditto.
(build_list_cipher_test_algo): Ditto.
(build_list_cipher_algo_name): Ditto.
(build_list_md_test_algo): Ditto.
(build_list_md_algo_name): Ditto.
(my_strusage): Use them.
(list_config): Ditto. Add "pubkeyname".
(build_list): Add letter==1 hack.
This commit is contained in:
Werner Koch 2014-01-31 15:55:04 +01:00
parent bf50604a0d
commit 71540d4041
2 changed files with 67 additions and 16 deletions

View File

@ -811,6 +811,43 @@ make_libversion (const char *libname, const char *(*getfnc)(const char*))
} }
static int
build_list_pk_test_algo (int algo)
{
return openpgp_pk_test_algo (algo);
}
static const char *
build_list_pk_algo_name (int algo)
{
return openpgp_pk_algo_name (algo);
}
static int
build_list_cipher_test_algo (int algo)
{
return openpgp_cipher_test_algo (algo);
}
static const char *
build_list_cipher_algo_name (int algo)
{
return openpgp_cipher_algo_name (algo);
}
static int
build_list_md_test_algo (int algo)
{
return openpgp_md_test_algo (algo);
}
static const char *
build_list_md_algo_name (int algo)
{
return openpgp_md_algo_name (algo);
}
static const char * static const char *
my_strusage( int level ) my_strusage( int level )
{ {
@ -861,23 +898,23 @@ my_strusage( int level )
case 33: p = _("\nSupported algorithms:\n"); break; case 33: p = _("\nSupported algorithms:\n"); break;
case 34: case 34:
if (!pubkeys) if (!pubkeys)
pubkeys = build_list (_("Pubkey: "), 0, pubkeys = build_list (_("Pubkey: "), 1,
openpgp_pk_algo_name, build_list_pk_algo_name,
openpgp_pk_test_algo ); build_list_pk_test_algo );
p = pubkeys; p = pubkeys;
break; break;
case 35: case 35:
if( !ciphers ) if( !ciphers )
ciphers = build_list(_("Cipher: "), 'S', ciphers = build_list(_("Cipher: "), 'S',
openpgp_cipher_algo_name, build_list_cipher_algo_name,
openpgp_cipher_test_algo ); build_list_cipher_test_algo );
p = ciphers; p = ciphers;
break; break;
case 36: case 36:
if( !digests ) if( !digests )
digests = build_list(_("Hash: "), 'H', digests = build_list(_("Hash: "), 'H',
gcry_md_algo_name, build_list_md_algo_name,
openpgp_md_test_algo ); build_list_md_test_algo );
p = digests; p = digests;
break; break;
case 37: case 37:
@ -931,7 +968,10 @@ build_list (const char *text, char letter,
if (opt.verbose && letter) if (opt.verbose && letter)
{ {
char num[20]; char num[20];
snprintf (num, sizeof num, " (%c%d)", letter, i); if (letter == 1)
snprintf (num, sizeof num, " (%d)", i);
else
snprintf (num, sizeof num, " (%c%d)", letter, i);
put_membuf_str (&mb, num); put_membuf_str (&mb, num);
} }
} }
@ -1533,7 +1573,16 @@ list_config(char *items)
if(show_all || ascii_strcasecmp(name,"pubkey")==0) if(show_all || ascii_strcasecmp(name,"pubkey")==0)
{ {
es_printf ("cfg:pubkey:"); es_printf ("cfg:pubkey:");
print_algo_numbers (openpgp_pk_test_algo); print_algo_numbers (build_list_pk_test_algo);
es_printf ("\n");
any=1;
}
if(show_all || ascii_strcasecmp(name,"pubkeyname")==0)
{
es_printf ("cfg:pubkeyname:");
print_algo_names (build_list_pk_test_algo,
build_list_pk_algo_name);
es_printf ("\n"); es_printf ("\n");
any=1; any=1;
} }
@ -1541,7 +1590,7 @@ list_config(char *items)
if(show_all || ascii_strcasecmp(name,"cipher")==0) if(show_all || ascii_strcasecmp(name,"cipher")==0)
{ {
es_printf ("cfg:cipher:"); es_printf ("cfg:cipher:");
print_algo_numbers(openpgp_cipher_test_algo); print_algo_numbers (build_list_cipher_test_algo);
es_printf ("\n"); es_printf ("\n");
any=1; any=1;
} }
@ -1549,7 +1598,8 @@ list_config(char *items)
if (show_all || !ascii_strcasecmp (name,"ciphername")) if (show_all || !ascii_strcasecmp (name,"ciphername"))
{ {
es_printf ("cfg:ciphername:"); es_printf ("cfg:ciphername:");
print_algo_names (openpgp_cipher_test_algo,openpgp_cipher_algo_name); print_algo_names (build_list_cipher_test_algo,
build_list_cipher_algo_name);
es_printf ("\n"); es_printf ("\n");
any = 1; any = 1;
} }
@ -1559,7 +1609,7 @@ list_config(char *items)
|| ascii_strcasecmp(name,"hash")==0) || ascii_strcasecmp(name,"hash")==0)
{ {
es_printf ("cfg:digest:"); es_printf ("cfg:digest:");
print_algo_numbers(openpgp_md_test_algo); print_algo_numbers (build_list_md_test_algo);
es_printf ("\n"); es_printf ("\n");
any=1; any=1;
} }
@ -1569,7 +1619,8 @@ list_config(char *items)
|| !ascii_strcasecmp(name,"hashname")) || !ascii_strcasecmp(name,"hashname"))
{ {
es_printf ("cfg:digestname:"); es_printf ("cfg:digestname:");
print_algo_names (openpgp_md_test_algo, gcry_md_algo_name); print_algo_names (build_list_md_test_algo,
build_list_md_algo_name);
es_printf ("\n"); es_printf ("\n");
any=1; any=1;
} }

View File

@ -572,9 +572,9 @@ openpgp_pk_algo_name (pubkey_algo_t algo)
case PUBKEY_ALGO_ELGAMAL: case PUBKEY_ALGO_ELGAMAL:
case PUBKEY_ALGO_ELGAMAL_E: return "ELG"; case PUBKEY_ALGO_ELGAMAL_E: return "ELG";
case PUBKEY_ALGO_DSA: return "DSA"; case PUBKEY_ALGO_DSA: return "DSA";
case PUBKEY_ALGO_ECDH: case PUBKEY_ALGO_ECDH: return "ECDH";
case PUBKEY_ALGO_ECDSA: case PUBKEY_ALGO_ECDSA: return "ECDSA";
case PUBKEY_ALGO_EDDSA: return "ECC"; case PUBKEY_ALGO_EDDSA: return "EDDSA";
} }
return "?"; return "?";
} }