mirror of
git://git.gnupg.org/gnupg.git
synced 2024-06-15 00:29:49 +02:00
scd: Support direct use of app with PKSIGN.
* scd/command.c (cmd_pksign): When length of keyidstr is 40, it is considered a keygrip for direct use. Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
parent
874bc970ba
commit
c2da86bbf1
|
@ -757,6 +757,8 @@ cmd_pksign (assuan_context_t ctx, char *line)
|
||||||
size_t outdatalen;
|
size_t outdatalen;
|
||||||
char *keyidstr;
|
char *keyidstr;
|
||||||
int hash_algo;
|
int hash_algo;
|
||||||
|
app_t app;
|
||||||
|
int direct = 0;
|
||||||
|
|
||||||
if (has_option (line, "--hash=rmd160"))
|
if (has_option (line, "--hash=rmd160"))
|
||||||
hash_algo = GCRY_MD_RMD160;
|
hash_algo = GCRY_MD_RMD160;
|
||||||
|
@ -789,11 +791,30 @@ cmd_pksign (assuan_context_t ctx, char *line)
|
||||||
if (!keyidstr)
|
if (!keyidstr)
|
||||||
return out_of_core ();
|
return out_of_core ();
|
||||||
|
|
||||||
rc = app_sign (ctrl->app_ctx, ctrl,
|
/* When it's a keygrip, we directly use APP, with no change of
|
||||||
keyidstr, hash_algo,
|
ctrl->app_ctx. */
|
||||||
pin_cb, ctx,
|
if (strlen (keyidstr) == 40)
|
||||||
ctrl->in_data.value, ctrl->in_data.valuelen,
|
{
|
||||||
&outdata, &outdatalen);
|
app = app_do_with_keygrip (ctrl, KEYGRIP_ACTION_LOOKUP, keyidstr);
|
||||||
|
direct = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
app = ctrl->app_ctx;
|
||||||
|
|
||||||
|
if (app)
|
||||||
|
{
|
||||||
|
if (direct)
|
||||||
|
app->ref_count++;
|
||||||
|
rc = app_sign (app, ctrl,
|
||||||
|
keyidstr, hash_algo,
|
||||||
|
pin_cb, ctx,
|
||||||
|
ctrl->in_data.value, ctrl->in_data.valuelen,
|
||||||
|
&outdata, &outdatalen);
|
||||||
|
if (direct)
|
||||||
|
app->ref_count--;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
rc = gpg_error (GPG_ERR_NO_SECKEY);
|
||||||
|
|
||||||
xfree (keyidstr);
|
xfree (keyidstr);
|
||||||
if (rc)
|
if (rc)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user