mirror of
git://git.gnupg.org/gnupg.git
synced 2025-04-17 15:44:34 +02:00
gpg: Add commands "fpr *" and "grip" to --edit-key.
* g10/keyedit.c (cmdGRIP): New. (cmds): Add command "grip". (keyedit_menu) <cmdFPR>: Print subkeys with argument "*". (keyedit_menu) <cmdGRIP>: Print keygrip. (show_key_and_fingerprint): Add arg "with_subkeys". (show_key_and_grip): New. * g10/keylist.c (print_fingerprint): Add mode 4. -- Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
969542c8c2
commit
fbb6c25ab5
@ -56,7 +56,8 @@ static void show_key_with_all_names (ctrl_t ctrl, estream_t fp,
|
|||||||
int with_revoker, int with_fpr,
|
int with_revoker, int with_fpr,
|
||||||
int with_subkeys, int with_prefs,
|
int with_subkeys, int with_prefs,
|
||||||
int nowarn);
|
int nowarn);
|
||||||
static void show_key_and_fingerprint (KBNODE keyblock);
|
static void show_key_and_fingerprint (kbnode_t keyblock, int with_subkeys);
|
||||||
|
static void show_key_and_grip (kbnode_t keyblock);
|
||||||
static void subkey_expire_warning (kbnode_t keyblock);
|
static void subkey_expire_warning (kbnode_t keyblock);
|
||||||
static int menu_adduid (KBNODE keyblock, int photo, const char *photo_name,
|
static int menu_adduid (KBNODE keyblock, int photo, const char *photo_name,
|
||||||
const char *uidstr);
|
const char *uidstr);
|
||||||
@ -1305,7 +1306,7 @@ enum cmdids
|
|||||||
cmdSHOWPREF,
|
cmdSHOWPREF,
|
||||||
cmdSETPREF, cmdPREFKS, cmdNOTATION, cmdINVCMD, cmdSHOWPHOTO, cmdUPDTRUST,
|
cmdSETPREF, cmdPREFKS, cmdNOTATION, cmdINVCMD, cmdSHOWPHOTO, cmdUPDTRUST,
|
||||||
cmdCHKTRUST, cmdADDCARDKEY, cmdKEYTOCARD, cmdBKUPTOCARD, cmdCHECKBKUPKEY,
|
cmdCHKTRUST, cmdADDCARDKEY, cmdKEYTOCARD, cmdBKUPTOCARD, cmdCHECKBKUPKEY,
|
||||||
cmdCLEAN, cmdMINIMIZE, cmdNOP
|
cmdCLEAN, cmdMINIMIZE, cmdGRIP, cmdNOP
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct
|
static struct
|
||||||
@ -1322,6 +1323,7 @@ static struct
|
|||||||
{ "help", cmdHELP, 0, N_("show this help")},
|
{ "help", cmdHELP, 0, N_("show this help")},
|
||||||
{ "?", cmdHELP, 0, NULL},
|
{ "?", cmdHELP, 0, NULL},
|
||||||
{ "fpr", cmdFPR, 0, N_("show key fingerprint")},
|
{ "fpr", cmdFPR, 0, N_("show key fingerprint")},
|
||||||
|
{ "grip", cmdGRIP, 0, N_("show the keygrip")},
|
||||||
{ "list", cmdLIST, 0, N_("list key and user IDs")},
|
{ "list", cmdLIST, 0, N_("list key and user IDs")},
|
||||||
{ "l", cmdLIST, 0, NULL},
|
{ "l", cmdLIST, 0, NULL},
|
||||||
{ "uid", cmdSELUID, 0, N_("select user ID N")},
|
{ "uid", cmdSELUID, 0, N_("select user ID N")},
|
||||||
@ -1644,7 +1646,13 @@ keyedit_menu (ctrl_t ctrl, const char *username, strlist_t locusr,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case cmdFPR:
|
case cmdFPR:
|
||||||
show_key_and_fingerprint (keyblock);
|
show_key_and_fingerprint
|
||||||
|
(keyblock, (*arg_string == '*'
|
||||||
|
&& (!arg_string[1] || spacep (arg_string + 1))));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case cmdGRIP:
|
||||||
|
show_key_and_grip (keyblock);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case cmdSELUID:
|
case cmdSELUID:
|
||||||
@ -3235,10 +3243,11 @@ show_basic_key_info (KBNODE keyblock)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
show_key_and_fingerprint (KBNODE keyblock)
|
show_key_and_fingerprint (kbnode_t keyblock, int with_subkeys)
|
||||||
{
|
{
|
||||||
KBNODE node;
|
kbnode_t node;
|
||||||
PKT_public_key *pk = NULL;
|
PKT_public_key *pk = NULL;
|
||||||
char pkstrbuf[PUBKEY_STRING_SIZE];
|
char pkstrbuf[PUBKEY_STRING_SIZE];
|
||||||
|
|
||||||
@ -3262,6 +3271,56 @@ show_key_and_fingerprint (KBNODE keyblock)
|
|||||||
tty_printf ("\n");
|
tty_printf ("\n");
|
||||||
if (pk)
|
if (pk)
|
||||||
print_fingerprint (NULL, pk, 2);
|
print_fingerprint (NULL, pk, 2);
|
||||||
|
if (with_subkeys)
|
||||||
|
{
|
||||||
|
for (node = keyblock; node; node = node->next)
|
||||||
|
{
|
||||||
|
if (node->pkt->pkttype == PKT_PUBLIC_SUBKEY)
|
||||||
|
{
|
||||||
|
pk = node->pkt->pkt.public_key;
|
||||||
|
tty_printf ("sub %s/%s %s [%s]\n",
|
||||||
|
pubkey_string (pk, pkstrbuf, sizeof pkstrbuf),
|
||||||
|
keystr_from_pk(pk),
|
||||||
|
datestr_from_pk (pk),
|
||||||
|
usagestr_from_pk (pk, 0));
|
||||||
|
|
||||||
|
print_fingerprint (NULL, pk, 4);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Show a listing of the primary and its subkeys along with their
|
||||||
|
keygrips. */
|
||||||
|
static void
|
||||||
|
show_key_and_grip (kbnode_t keyblock)
|
||||||
|
{
|
||||||
|
kbnode_t node;
|
||||||
|
PKT_public_key *pk = NULL;
|
||||||
|
char pkstrbuf[PUBKEY_STRING_SIZE];
|
||||||
|
char *hexgrip;
|
||||||
|
|
||||||
|
for (node = keyblock; node; node = node->next)
|
||||||
|
{
|
||||||
|
if (node->pkt->pkttype == PKT_PUBLIC_KEY
|
||||||
|
|| node->pkt->pkttype == PKT_PUBLIC_SUBKEY)
|
||||||
|
{
|
||||||
|
pk = node->pkt->pkt.public_key;
|
||||||
|
tty_printf ("%s %s/%s %s [%s]\n",
|
||||||
|
node->pkt->pkttype == PKT_PUBLIC_KEY? "pub":"sub",
|
||||||
|
pubkey_string (pk, pkstrbuf, sizeof pkstrbuf),
|
||||||
|
keystr_from_pk(pk),
|
||||||
|
datestr_from_pk (pk),
|
||||||
|
usagestr_from_pk (pk, 0));
|
||||||
|
|
||||||
|
if (!hexkeygrip_from_pk (pk, &hexgrip))
|
||||||
|
{
|
||||||
|
tty_printf (" Keygrip: %s\n", hexgrip);
|
||||||
|
xfree (hexgrip);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1726,6 +1726,7 @@ print_icao_hexdigit (estream_t fp, int c)
|
|||||||
* 1: print using log_info ()
|
* 1: print using log_info ()
|
||||||
* 2: direct use of tty
|
* 2: direct use of tty
|
||||||
* 3: direct use of tty but only primary key.
|
* 3: direct use of tty but only primary key.
|
||||||
|
* 4: direct use of tty but only subkey.
|
||||||
* 10: Same as 0 but with_colons etc is ignored.
|
* 10: Same as 0 but with_colons etc is ignored.
|
||||||
*
|
*
|
||||||
* Modes 1 and 2 will try and print both subkey and primary key
|
* Modes 1 and 2 will try and print both subkey and primary key
|
||||||
@ -1784,7 +1785,7 @@ print_fingerprint (estream_t override_fp, PKT_public_key *pk, int mode)
|
|||||||
{
|
{
|
||||||
fp = override_fp; /* Use tty or given stream. */
|
fp = override_fp; /* Use tty or given stream. */
|
||||||
if (primary)
|
if (primary)
|
||||||
/* TRANSLATORS: this should fit into 24 bytes to that the
|
/* TRANSLATORS: this should fit into 24 bytes so that the
|
||||||
* fingerprint data is properly aligned with the user ID */
|
* fingerprint data is properly aligned with the user ID */
|
||||||
text = _(" Primary key fingerprint:");
|
text = _(" Primary key fingerprint:");
|
||||||
else
|
else
|
||||||
@ -1795,6 +1796,11 @@ print_fingerprint (estream_t override_fp, PKT_public_key *pk, int mode)
|
|||||||
fp = override_fp; /* Use tty or given stream. */
|
fp = override_fp; /* Use tty or given stream. */
|
||||||
text = _(" Key fingerprint =");
|
text = _(" Key fingerprint =");
|
||||||
}
|
}
|
||||||
|
else if (mode == 4)
|
||||||
|
{
|
||||||
|
fp = override_fp; /* Use tty or given stream. */
|
||||||
|
text = _(" Subkey fingerprint:");
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fp = override_fp? override_fp : es_stdout;
|
fp = override_fp? override_fp : es_stdout;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user