agent,scd: Make sure to set CONFIDENTIAL flag in Assuan.

* agent/call-scd.c (inq_needpin): Call assuan_begin_confidential
and assuan_end_confidential, and wipe the memory after use.
* agent/command.c (cmd_preset_passphrase): Likewise.
* scd/command.c (pin_cb): Likewise.

--

Backport the change of master commit of:
	052f58422d

GnuPG-bug-id: 5977
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
NIIBE Yutaka 2022-05-25 14:53:06 +09:00
parent cc1d475f98
commit aeee62593a
3 changed files with 17 additions and 3 deletions

View File

@ -737,7 +737,12 @@ inq_needpin (void *opaque, const char *line)
rc = parm->getpin_cb (parm->getpin_cb_arg, parm->getpin_cb_desc,
line, pin, pinlen);
if (!rc)
rc = assuan_send_data (parm->ctx, pin, pinlen);
{
assuan_begin_confidential (parm->ctx);
rc = assuan_send_data (parm->ctx, pin, pinlen);
assuan_end_confidential (parm->ctx);
}
wipememory (pin, pinlen);
xfree (pin);
}
else if ((s = has_leading_keyword (line, "POPUPPINPADPROMPT")))

View File

@ -2120,7 +2120,11 @@ cmd_preset_passphrase (assuan_context_t ctx, char *line)
rc = print_assuan_status (ctx, "INQUIRE_MAXLEN", "%zu", maxlen);
if (!rc)
rc = assuan_inquire (ctx, "PASSPHRASE", &passphrase, &len, maxlen);
{
assuan_begin_confidential (ctx);
rc = assuan_inquire (ctx, "PASSPHRASE", &passphrase, &len, maxlen);
assuan_end_confidential (ctx);
}
}
else
rc = set_error (GPG_ERR_NOT_IMPLEMENTED, "passphrase is required");
@ -2129,7 +2133,10 @@ cmd_preset_passphrase (assuan_context_t ctx, char *line)
{
rc = agent_put_cache (ctrl, grip_clear, CACHE_MODE_ANY, passphrase, ttl);
if (opt_inquire)
xfree (passphrase);
{
wipememory (passphrase, len);
xfree (passphrase);
}
}
leave:

View File

@ -698,7 +698,9 @@ pin_cb (void *opaque, const char *info, char **retstr)
/* Fixme: Write an inquire function which returns the result in
secure memory and check all further handling of the PIN. */
assuan_begin_confidential (ctx);
rc = assuan_inquire (ctx, command, &value, &valuelen, MAXLEN_PIN);
assuan_end_confidential (ctx);
xfree (command);
if (rc)
return rc;