aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2024-08-07 09:20:59 +0000
committerWerner Koch <[email protected]>2024-08-07 09:21:31 +0000
commit1d0874c3d2c964edc4803f26b665343e0feb0d88 (patch)
tree4177e1d48e2ddd413b960137f1ee4213d3bb7481
parentdoc: Fix URL to the OpenPGP card specs (diff)
downloadgnupg-1d0874c3d2c964edc4803f26b665343e0feb0d88.tar.gz
gnupg-1d0874c3d2c964edc4803f26b665343e0feb0d88.zip
scd: New getinfo subcommand "manufacturer"
* scd/command.c (cmd_getinfo): Add subcommand "manufacturer". * scd/app-openpgp.c (get_manufacturer): Rename to ... (app_openpgp_manufacturer): this and make global. -- Example: $ gpg-connect-agent 'scd getinfo manufacturer 42' /bye D Magrathea OK Backported-from-master: a8cef7ebc2b8c3aa1477b61fecfaa8e5d63446d7
-rw-r--r--scd/app-common.h1
-rw-r--r--scd/app-openpgp.c6
-rw-r--r--scd/command.c32
3 files changed, 24 insertions, 15 deletions
diff --git a/scd/app-common.h b/scd/app-common.h
index f95db7433..1cb866d30 100644
--- a/scd/app-common.h
+++ b/scd/app-common.h
@@ -286,6 +286,7 @@ gpg_error_t app_check_pin (app_t app, ctrl_t ctrl, const char *keyidstr,
/*-- app-openpgp.c --*/
gpg_error_t app_select_openpgp (app_t app);
+const char *app_openpgp_manufacturer (unsigned int no);
/*-- app-nks.c --*/
gpg_error_t app_select_nks (app_t app);
diff --git a/scd/app-openpgp.c b/scd/app-openpgp.c
index 8527c4734..cb7eb25c2 100644
--- a/scd/app-openpgp.c
+++ b/scd/app-openpgp.c
@@ -279,8 +279,8 @@ static gpg_error_t change_keyattr_from_string
/* Return the OpenPGP card manufacturer name. */
-static const char *
-get_manufacturer (unsigned int no)
+const char *
+app_openpgp_manufacturer (unsigned int no)
{
/* Note: Make sure that there is no colon or linefeed in the string. */
switch (no)
@@ -1207,7 +1207,7 @@ do_getattr (app_t app, ctrl_t ctrl, const char *name)
return send_status_printf
(ctrl, table[idx].name, "%u %s",
app->app_local->manufacturer,
- get_manufacturer (app->app_local->manufacturer));
+ app_openpgp_manufacturer (app->app_local->manufacturer));
}
if (table[idx].special == -9)
{
diff --git a/scd/command.c b/scd/command.c
index 363e2f087..0a93f1b94 100644
--- a/scd/command.c
+++ b/scd/command.c
@@ -1470,15 +1470,18 @@ static const char hlp_getinfo[] =
" application per line, fields delimited by colons,\n"
" first field is the name.\n"
" card_list - Return a list of serial numbers of active cards,\n"
- " using a status response.";
+ " using a status response."
+ " manufacturer NUMBER\n"
+ " - Return a description of the OpenPGP manufacturer id.\n";
static gpg_error_t
cmd_getinfo (assuan_context_t ctx, char *line)
{
int rc = 0;
+ const char *s;
if (!strcmp (line, "version"))
{
- const char *s = VERSION;
+ s = VERSION;
rc = assuan_send_data (ctx, s, strlen (s));
}
else if (!strcmp (line, "pid"))
@@ -1490,7 +1493,7 @@ cmd_getinfo (assuan_context_t ctx, char *line)
}
else if (!strcmp (line, "socket_name"))
{
- const char *s = scd_get_socket_name ();
+ s = scd_get_socket_name ();
if (s)
rc = assuan_send_data (ctx, s, strlen (s));
@@ -1518,30 +1521,35 @@ cmd_getinfo (assuan_context_t ctx, char *line)
}
else if (!strcmp (line, "reader_list"))
{
- char *s = apdu_get_reader_list ();
- if (s)
- rc = pretty_assuan_send_data (ctx, s, strlen (s));
+ char *p = apdu_get_reader_list ();
+ if (p)
+ rc = pretty_assuan_send_data (ctx, p, strlen (p));
else
rc = gpg_error (GPG_ERR_NO_DATA);
- xfree (s);
+ xfree (p);
}
else if (!strcmp (line, "deny_admin"))
rc = opt.allow_admin? gpg_error (GPG_ERR_GENERAL) : 0;
else if (!strcmp (line, "app_list"))
{
- char *s = get_supported_applications ();
- if (s)
- rc = assuan_send_data (ctx, s, strlen (s));
+ char *p = get_supported_applications ();
+ if (p)
+ rc = assuan_send_data (ctx, p, strlen (p));
else
rc = 0;
- xfree (s);
+ xfree (p);
}
else if (!strcmp (line, "card_list"))
{
ctrl_t ctrl = assuan_get_pointer (ctx);
-
app_send_card_list (ctrl);
}
+ else if ((s=has_leading_keyword (line, "manufacturer")))
+ {
+ unsigned long ul = strtoul (s, NULL, 0);
+ s = app_openpgp_manufacturer (ul);
+ rc = assuan_send_data (ctx, s, strlen (s));
+ }
else
rc = set_error (GPG_ERR_ASS_PARAMETER, "unknown value for WHAT");
return rc;