* protect-tool.c: Add command --show-keygrip

(show_keygrip): New.
This commit is contained in:
Werner Koch 2002-06-12 09:55:41 +00:00
parent 0dec11fbe7
commit f393e0d6b2
3 changed files with 43 additions and 1 deletions

View File

@ -1,3 +1,8 @@
2002-06-11 Werner Koch <wk@gnupg.org>
* protect-tool.c: Add command --show-keygrip
(show_keygrip): New.
2002-05-23 Werner Koch <wk@gnupg.org>
* call-scd.c: Seirialized all scdaeom access when using Pth.

View File

@ -658,7 +658,7 @@ void
agent_exit (int rc)
{
/*FIXME: update_random_seed_file();*/
#if 0
#if 1
/* at this time a bit annoying */
if (opt.debug & DBG_MEMSTAT_VALUE)
{

View File

@ -51,6 +51,7 @@ enum cmd_and_opt_values
oNoVerbose = 500,
oShadow,
oShowShadowInfo,
oShowKeygrip,
aTest };
@ -69,6 +70,7 @@ static ARGPARSE_OPTS opts[] = {
{ oUnprotect, "unprotect", 256, "unprotect a private key"},
{ oShadow, "shadow", 256, "create a shadow entry for a priblic key"},
{ oShowShadowInfo, "show-shadow-info", 256, "return the shadow info"},
{ oShowKeygrip, "show-keygrip", 256, " show the \"keygrip\""},
{0}
};
@ -376,6 +378,7 @@ show_file (const char *fname)
key = read_key (fname);
if (!key)
return;
keylen = gcry_sexp_canon_len (key, 0, NULL,NULL);
assert (keylen);
@ -388,6 +391,37 @@ show_file (const char *fname)
}
}
static void
show_keygrip (const char *fname)
{
unsigned char *key;
GcrySexp private;
unsigned char grip[20];
int i;
key = read_key (fname);
if (!key)
return;
if (gcry_sexp_new (&private, key, 0, 0))
{
log_error ("gcry_sexp_new failed\n");
return;
}
xfree (key);
if (!gcry_pk_get_keygrip (private, grip))
{
log_error ("can't calculate keygrip\n");
return;
}
gcry_sexp_release (private);
for (i=0; i < 20; i++)
printf ("%02X", grip[i]);
putchar ('\n');
}
@ -426,6 +460,7 @@ main (int argc, char **argv )
case oUnprotect: cmd = oUnprotect; break;
case oShadow: cmd = oShadow; break;
case oShowShadowInfo: cmd = oShowShadowInfo; break;
case oShowKeygrip: cmd = oShowKeygrip; break;
case oPassphrase: passphrase = pargs.r.ret_str; break;
@ -446,6 +481,8 @@ main (int argc, char **argv )
read_and_shadow (*argv);
else if (cmd == oShowShadowInfo)
show_shadow_info (*argv);
else if (cmd == oShowKeygrip)
show_keygrip (*argv);
else
show_file (*argv);