mirror of
git://git.gnupg.org/gnupg.git
synced 2024-06-07 23:27:48 +02:00
Added KEYINFO field to show the protection type of a key. This differs from the second field which shows the location of the key.
This commit is contained in:
parent
f1e9f510ec
commit
893b455a3d
|
@ -1,3 +1,7 @@
|
||||||
|
2011-04-06 Ben Kibbey <bjk@luxsci.net>
|
||||||
|
|
||||||
|
* command.c: (do_one_keyinfo): Add protection type field.
|
||||||
|
|
||||||
2011-03-10 Werner Koch <wk@g10code.com>
|
2011-03-10 Werner Koch <wk@g10code.com>
|
||||||
|
|
||||||
* protect.c (hash_passphrase): Use the new gcry_kdf_derive.
|
* protect.c (hash_passphrase): Use the new gcry_kdf_derive.
|
||||||
|
|
|
@ -938,7 +938,7 @@ static const char hlp_keyinfo[] =
|
||||||
"available keys are returned. The information is returned as a\n"
|
"available keys are returned. The information is returned as a\n"
|
||||||
"status line unless --data was specified, with this format:\n"
|
"status line unless --data was specified, with this format:\n"
|
||||||
"\n"
|
"\n"
|
||||||
" KEYINFO <keygrip> <type> <serialno> <idstr> <cached>\n"
|
" KEYINFO <keygrip> <type> <serialno> <idstr> <cached> <protection>\n"
|
||||||
"\n"
|
"\n"
|
||||||
"KEYGRIP is the keygrip.\n"
|
"KEYGRIP is the keygrip.\n"
|
||||||
"\n"
|
"\n"
|
||||||
|
@ -957,6 +957,11 @@ static const char hlp_keyinfo[] =
|
||||||
"CACHED is 1 if the passphrase for the key was found in the key cache.\n"
|
"CACHED is 1 if the passphrase for the key was found in the key cache.\n"
|
||||||
" If not, a '-' is used instead.\n"
|
" If not, a '-' is used instead.\n"
|
||||||
"\n"
|
"\n"
|
||||||
|
"PROTECTION describes the key protection type:\n"
|
||||||
|
" 'P' - The key is protected with a passphrase,\n"
|
||||||
|
" 'C' - The key is not protected,\n"
|
||||||
|
" '-' - Unknown protection.\n"
|
||||||
|
"\n"
|
||||||
"More information may be added in the future.";
|
"More information may be added in the future.";
|
||||||
static gpg_error_t
|
static gpg_error_t
|
||||||
do_one_keyinfo (ctrl_t ctrl, const unsigned char *grip, assuan_context_t ctx,
|
do_one_keyinfo (ctrl_t ctrl, const unsigned char *grip, assuan_context_t ctx,
|
||||||
|
@ -970,6 +975,7 @@ do_one_keyinfo (ctrl_t ctrl, const unsigned char *grip, assuan_context_t ctx,
|
||||||
char *idstr = NULL;
|
char *idstr = NULL;
|
||||||
const char *keytypestr;
|
const char *keytypestr;
|
||||||
const char *cached;
|
const char *cached;
|
||||||
|
const char *protectionstr;
|
||||||
char *pw;
|
char *pw;
|
||||||
|
|
||||||
err = agent_key_info_from_file (ctrl, grip, &keytype, &shadow_info);
|
err = agent_key_info_from_file (ctrl, grip, &keytype, &shadow_info);
|
||||||
|
@ -979,13 +985,17 @@ do_one_keyinfo (ctrl_t ctrl, const unsigned char *grip, assuan_context_t ctx,
|
||||||
/* Reformat the grip so that we use uppercase as good style. */
|
/* Reformat the grip so that we use uppercase as good style. */
|
||||||
bin2hex (grip, 20, hexgrip);
|
bin2hex (grip, 20, hexgrip);
|
||||||
|
|
||||||
if (keytype == PRIVATE_KEY_CLEAR
|
switch (keytype)
|
||||||
|| keytype == PRIVATE_KEY_PROTECTED)
|
{
|
||||||
keytypestr = "D";
|
case PRIVATE_KEY_CLEAR: protectionstr = "C"; keytypestr = "D";
|
||||||
else if (keytype == PRIVATE_KEY_SHADOWED)
|
break;
|
||||||
keytypestr = "T";
|
case PRIVATE_KEY_PROTECTED: protectionstr = "P"; keytypestr = "D";
|
||||||
else
|
break;
|
||||||
keytypestr = "-";
|
case PRIVATE_KEY_SHADOWED: protectionstr = "-"; keytypestr = "T";
|
||||||
|
break;
|
||||||
|
default: protectionstr = "-"; keytypestr = "-";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
/* Here we have a little race by doing the cache check separately
|
/* Here we have a little race by doing the cache check separately
|
||||||
from the retrieval function. Given that the cache flag is only a
|
from the retrieval function. Given that the cache flag is only a
|
||||||
|
@ -1008,15 +1018,16 @@ do_one_keyinfo (ctrl_t ctrl, const unsigned char *grip, assuan_context_t ctx,
|
||||||
serialno? serialno : "-",
|
serialno? serialno : "-",
|
||||||
idstr? idstr : "-",
|
idstr? idstr : "-",
|
||||||
cached,
|
cached,
|
||||||
|
protectionstr,
|
||||||
NULL);
|
NULL);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
char *string;
|
char *string;
|
||||||
|
|
||||||
string = xtryasprintf ("%s %s %s %s %s\n",
|
string = xtryasprintf ("%s %s %s %s %s %s\n",
|
||||||
hexgrip, keytypestr,
|
hexgrip, keytypestr,
|
||||||
serialno? serialno : "-",
|
serialno? serialno : "-",
|
||||||
idstr? idstr : "-", cached);
|
idstr? idstr : "-", cached, protectionstr);
|
||||||
if (!string)
|
if (!string)
|
||||||
err = gpg_error_from_syserror ();
|
err = gpg_error_from_syserror ();
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue
Block a user