1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-12-22 10:19:57 +01:00

scd: Support direct use of app for PKAUTH and PKDECIPHER.

scd/command.c (cmd_pkauth): Likewise.
(cmd_pkdecrypt): Likewise.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
NIIBE Yutaka 2019-04-26 11:16:06 +09:00
parent c2da86bbf1
commit 93a1b2f9f4

View File

@ -843,6 +843,8 @@ cmd_pkauth (assuan_context_t ctx, char *line)
unsigned char *outdata; unsigned char *outdata;
size_t outdatalen; size_t outdatalen;
char *keyidstr; char *keyidstr;
app_t app;
int direct = 0;
if ((rc = open_card (ctrl))) if ((rc = open_card (ctrl)))
return rc; return rc;
@ -857,9 +859,29 @@ cmd_pkauth (assuan_context_t ctx, char *line)
if (!keyidstr) if (!keyidstr)
return out_of_core (); return out_of_core ();
rc = app_auth (ctrl->app_ctx, ctrl, keyidstr, pin_cb, ctx, /* When it's a keygrip, we directly use APP, with no change of
ctrl->in_data.value, ctrl->in_data.valuelen, ctrl->app_ctx. */
&outdata, &outdatalen); if (strlen (keyidstr) == 40)
{
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_auth (app, ctrl, keyidstr, 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)
{ {
@ -888,6 +910,8 @@ cmd_pkdecrypt (assuan_context_t ctx, char *line)
size_t outdatalen; size_t outdatalen;
char *keyidstr; char *keyidstr;
unsigned int infoflags; unsigned int infoflags;
app_t app;
int direct = 0;
if ((rc = open_card (ctrl))) if ((rc = open_card (ctrl)))
return rc; return rc;
@ -895,9 +919,29 @@ cmd_pkdecrypt (assuan_context_t ctx, char *line)
keyidstr = xtrystrdup (line); keyidstr = xtrystrdup (line);
if (!keyidstr) if (!keyidstr)
return out_of_core (); return out_of_core ();
rc = app_decipher (ctrl->app_ctx, ctrl, keyidstr, pin_cb, ctx,
ctrl->in_data.value, ctrl->in_data.valuelen, /* When it's a keygrip, we directly use APP, with no change of
&outdata, &outdatalen, &infoflags); ctrl->app_ctx. */
if (strlen (keyidstr) == 40)
{
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_decipher (ctrl->app_ctx, ctrl, keyidstr, pin_cb, ctx,
ctrl->in_data.value, ctrl->in_data.valuelen,
&outdata, &outdatalen, &infoflags);
if (direct)
app->ref_count--;
}
else
rc = gpg_error (GPG_ERR_NO_SECKEY);
xfree (keyidstr); xfree (keyidstr);
if (rc) if (rc)