summaryrefslogtreecommitdiffstats
path: root/tools/gpg-auth.c
diff options
context:
space:
mode:
authorNIIBE Yutaka <gniibe@fsij.org>2022-09-06 06:52:51 +0200
committerNIIBE Yutaka <gniibe@fsij.org>2022-09-06 06:52:51 +0200
commitdc9227ca577dc7e34ca45de54a4903aecf31fb64 (patch)
tree1668dc7656a9e50eb647edd3ae19b332ce17f2de /tools/gpg-auth.c
parentcommon: Fix to determine ECC curve for SSH. (diff)
downloadgnupg2-dc9227ca577dc7e34ca45de54a4903aecf31fb64.tar.xz
gnupg2-dc9227ca577dc7e34ca45de54a4903aecf31fb64.zip
tools:gpg-auth: Support use of pinpad.
* tools/gpg-auth.c (getpin): Use comment. (inq_needpin): Support "POPUPPINPADPROMPT" protocol response. -- Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
Diffstat (limited to '')
-rw-r--r--tools/gpg-auth.c41
1 files changed, 27 insertions, 14 deletions
diff --git a/tools/gpg-auth.c b/tools/gpg-auth.c
index cc8cc3943..b7ab6dece 100644
--- a/tools/gpg-auth.c
+++ b/tools/gpg-auth.c
@@ -199,7 +199,7 @@ static gpg_error_t ga_filter_by_authorized_keys (struct ga_key_list **r_key_list
static void ga_release_auth_keys (struct ga_key_list *key_list);
static gpg_error_t scd_pkauth (assuan_context_t ctx, const char *keygrip);
static gpg_error_t authenticate (assuan_context_t ctx, struct ga_key_list *key_list);
-static int getpin (assuan_context_t ctx, const char *info, char *buf, size_t *r_len);
+static int getpin (const char *comment, const char *info, char *buf, size_t *r_len);
/* gpg-auth main. */
int
@@ -508,6 +508,7 @@ inq_needpin (void *opaque, const char *line)
char *pin;
size_t pinlen;
int rc;
+ const char *comment = assuan_get_pointer (ctx);
rc = 0;
@@ -519,7 +520,7 @@ inq_needpin (void *opaque, const char *line)
if (!pin)
return out_of_core ();
- rc = getpin (ctx, line, pin, &pinlen);
+ rc = getpin (comment, line, pin, &pinlen);
if (!rc)
{
assuan_begin_confidential (ctx);
@@ -531,8 +532,20 @@ inq_needpin (void *opaque, const char *line)
}
else if ((s = has_leading_keyword (line, "POPUPPINPADPROMPT")))
{
- /* i 18 */;
- /* Please use PINPAD! */;
+
+ if (comment)
+ {
+ int msg_len = 27 + strlen (comment);
+ fprintf (stdout, "i %d\n", msg_len);
+ fprintf (stdout, "Please use PINPAD for KEY: %s\n", comment);
+ fflush (stdout);
+ }
+ else
+ {
+ fputs ("i 18\n", stdout);
+ fputs ("Please use PINPAD!\n", stdout);
+ fflush (stdout);
+ }
}
else if ((s = has_leading_keyword (line, "DISMISSPINPADPROMPT")))
{
@@ -900,27 +913,27 @@ ga_release_auth_keys (struct ga_key_list *key_list)
}
static int
-getpin (assuan_context_t ctx, const char *info, char *buf, size_t *r_len)
+getpin (const char *comment, const char *info, char *buf, size_t *r_len)
{
int rc = 0;
char line[ASSUAN_LINELENGTH];
const char *fields[2];
- const char *comment;
(void)info;
- comment = assuan_get_pointer (ctx);
if (comment)
{
- int msg_len = 5 + strlen (comment);
- fprintf (stdout, "i %d\n", msg_len);
- fprintf (stdout, "KEY: %s\n", comment);
+ int msg_len = 29 + strlen (comment);
+ fprintf (stdout, "P %d\n", msg_len);
+ fprintf (stdout, "Please input PIN for KEY (%s): \n", comment);
+ fflush (stdout);
+ }
+ else
+ {
+ fputs ("P 18\n", stdout);
+ fputs ("Please input PIN: \n", stdout);
fflush (stdout);
}
-
- fputs ("P 18\n", stdout);
- fputs ("Please input PIN: \n", stdout);
- fflush (stdout);
fgets (line, ASSUAN_LINELENGTH, stdin);
if (split_fields (line, fields, DIM (fields)) < DIM (fields))