1
0
Fork 0
mirror of git://git.gnupg.org/gnupg.git synced 2025-07-02 22:46:30 +02:00

scd: Cleanup SERIALNO protocol.

* scd/app.c (app_get_serial_and_stamp): Remove.
(app_get_serialno): New.
(app_write_learn_status): Use send_status_direct.
(app_getattr): Use app_get_serialno for SERIALNO and
send with send_status_direct.
* scd/app-openpgp.c (do_getattr): Likewise.
* scd/command.c (cmd_serialno): Don't send TIMESTAMP of 0.
(cmd_learn): Likewise.  Don't inquire with TIMESTAMP of 0.

--

In the SERIALNO protocol, timestamp used to be considered, but had never
used at all.  In the new implementation, removed card/token is always
detected and connection becomes invalid, no timestamp is required any
more.  Examined scute and poldi as well for this protocol change.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
NIIBE Yutaka 2017-01-18 15:48:50 +09:00
parent 8b1f24a29e
commit 79cea89774
5 changed files with 40 additions and 68 deletions

View file

@ -264,7 +264,6 @@ cmd_serialno (assuan_context_t ctx, char *line)
struct server_local_s *sl;
int rc = 0;
char *serial;
time_t stamp;
const char *demand;
if ( IS_LOCKED (ctrl) )
@ -302,12 +301,11 @@ cmd_serialno (assuan_context_t ctx, char *line)
c->server_local->card_removed = 0;
}
rc = app_get_serial_and_stamp (ctrl->app_ctx, &serial, &stamp);
if (rc)
return rc;
serial = app_get_serialno (ctrl->app_ctx);
if (!serial)
return gpg_error (GPG_ERR_INV_VALUE);
rc = print_assuan_status (ctx, "SERIALNO", "%s %lu",
serial, (unsigned long)stamp);
rc = assuan_write_status (ctx, "SERIALNO", serial);
xfree (serial);
return rc;
}
@ -320,7 +318,7 @@ static const char hlp_learn[] =
"used without the force options, the command might do an INQUIRE\n"
"like this:\n"
"\n"
" INQUIRE KNOWNCARDP <hexstring_with_serialNumber> <timestamp>\n"
" INQUIRE KNOWNCARDP <hexstring_with_serialNumber>\n"
"\n"
"The client should just send an \"END\" if the processing should go on\n"
"or a \"CANCEL\" to force the function to terminate with a Cancel\n"
@ -400,7 +398,6 @@ cmd_learn (assuan_context_t ctx, char *line)
{
const char *reader;
char *serial;
time_t stamp;
app_t app = ctrl->app_ctx;
if (!app)
@ -412,12 +409,11 @@ cmd_learn (assuan_context_t ctx, char *line)
send_status_direct (ctrl, "READER", reader);
/* No need to free the string of READER. */
rc = app_get_serial_and_stamp (ctrl->app_ctx, &serial, &stamp);
if (rc)
return rc;
serial = app_get_serialno (ctrl->app_ctx);
if (!serial)
return gpg_error (GPG_ERR_INV_VALUE);
rc = print_assuan_status (ctx, "SERIALNO", "%s %lu",
serial, (unsigned long)stamp);
rc = assuan_write_status (ctx, "SERIALNO", serial);
if (rc < 0)
{
xfree (serial);
@ -428,8 +424,7 @@ cmd_learn (assuan_context_t ctx, char *line)
{
char *command;
rc = gpgrt_asprintf (&command, "KNOWNCARDP %s %lu",
serial, (unsigned long)stamp);
rc = gpgrt_asprintf (&command, "KNOWNCARDP %s", serial);
if (rc < 0)
{
xfree (serial);