aboutsummaryrefslogtreecommitdiffstats
path: root/scd/app-nks.c
diff options
context:
space:
mode:
authorNIIBE Yutaka <[email protected]>2022-05-26 03:01:16 +0000
committerNIIBE Yutaka <[email protected]>2022-05-26 03:01:16 +0000
commit5264d3f58e8a8362900c3518bdd683ff9a23cccc (patch)
treed49c9b558c4f2ca4408fcb98910d742c8789f2e8 /scd/app-nks.c
parentscd,piv: Fix status report of KEYPAIRINFO. (diff)
downloadgnupg-5264d3f58e8a8362900c3518bdd683ff9a23cccc.tar.gz
gnupg-5264d3f58e8a8362900c3518bdd683ff9a23cccc.zip
scd: Return USAGE information for KEYINFO command.
* scd/command.c (hlp_keyinfo): Update. (send_keyinfo): Add a USAGE argument. * scd/scdaemon.h (send_keyinfo): Add a USAGE argument. * scd/app-nks.c (set_usage_string): New. (do_learn_status_core, do_readkey): Use set_usage_string. (do_with_keygrip): Add USAGE to call send_keyinfo, using set_usage_string. * scd/app-openpgp.c (get_usage_string): New. (send_keypair_info): Use get_usage_string. (send_keyinfo_if_available): Add USAGE to call send_keyinfo, using get_usage_string. * scd/app-p15.c (set_usage_string): New. (send_keypairinfo): Use set_usage_string. (do_with_keygrip): Add USAGE to call send_keyinfo, using set_usage_string. * scd/app-piv.c (do_with_keygrip): Add USAGE to call send_keyinfo. -- Signed-off-by: NIIBE Yutaka <[email protected]>
Diffstat (limited to 'scd/app-nks.c')
-rw-r--r--scd/app-nks.c41
1 files changed, 20 insertions, 21 deletions
diff --git a/scd/app-nks.c b/scd/app-nks.c
index 31b91ac93..8b962722e 100644
--- a/scd/app-nks.c
+++ b/scd/app-nks.c
@@ -815,6 +815,21 @@ get_nks_tag (app_t app, int nks_app_id)
}
static void
+set_usage_string (char usagebuf[5], int i)
+{
+ int usageidx = 0;
+ if (filelist[i].issignkey)
+ usagebuf[usageidx++] = 's';
+ if (filelist[i].isauthkey)
+ usagebuf[usageidx++] = 'a';
+ if (filelist[i].isencrkey)
+ usagebuf[usageidx++] = 'e';
+ if (!usageidx)
+ usagebuf[usageidx++] = '-';
+ usagebuf[usageidx] = 0;
+}
+
+static void
do_learn_status_core (app_t app, ctrl_t ctrl, unsigned int flags,
int nks_app_id)
{
@@ -856,7 +871,6 @@ do_learn_status_core (app_t app, ctrl_t ctrl, unsigned int flags,
{
char gripstr[40+1];
char usagebuf[5];
- int usageidx = 0;
char *algostr = NULL;
err = keygripstr_from_pk_file (app, filelist[i].fid,
@@ -869,15 +883,7 @@ do_learn_status_core (app_t app, ctrl_t ctrl, unsigned int flags,
{
snprintf (id_buf, sizeof id_buf, "NKS-%s.%04X",
tag, filelist[i].fid);
- if (filelist[i].issignkey)
- usagebuf[usageidx++] = 's';
- if (filelist[i].isauthkey)
- usagebuf[usageidx++] = 'a';
- if (filelist[i].isencrkey)
- usagebuf[usageidx++] = 'e';
- if (!usageidx)
- usagebuf[usageidx++] = '-';
- usagebuf[usageidx] = 0;
+ set_usage_string (usagebuf, i);
send_status_info (ctrl, "KEYPAIRINFO",
gripstr, 40,
id_buf, strlen (id_buf),
@@ -1280,7 +1286,6 @@ do_readkey (app_t app, ctrl_t ctrl, const char *keyid, unsigned int flags,
{
char *algostr;
char usagebuf[5];
- int usageidx = 0;
char id_buf[100];
if (app_help_get_keygrip_string_pk (*pk, *pklen, NULL, NULL, NULL,
@@ -1290,15 +1295,7 @@ do_readkey (app_t app, ctrl_t ctrl, const char *keyid, unsigned int flags,
snprintf (id_buf, sizeof id_buf, "NKS-%s.%04X",
get_nks_tag (app, filelist[i].nks_app_id),
filelist[i].fid);
- if (filelist[i].issignkey)
- usagebuf[usageidx++] = 's';
- if (filelist[i].isauthkey)
- usagebuf[usageidx++] = 'a';
- if (filelist[i].isencrkey)
- usagebuf[usageidx++] = 'e';
- if (!usageidx)
- usagebuf[usageidx++] = '-';
- usagebuf[usageidx] = 0;
+ set_usage_string (usagebuf, i);
send_status_info (ctrl, "KEYPAIRINFO",
keygripstr, strlen (keygripstr),
id_buf, strlen (id_buf),
@@ -2334,6 +2331,7 @@ do_with_keygrip (app_t app, ctrl_t ctrl, int action,
{
char idbuf[20];
const char *tagstr;
+ char usagebuf[5];
if (app->app_local->active_nks_app == NKS_APP_ESIGN)
tagstr = "ESIGN";
@@ -2348,7 +2346,8 @@ do_with_keygrip (app_t app, ctrl_t ctrl, int action,
snprintf (idbuf, sizeof idbuf, "NKS-%s.%04X",
tagstr, filelist[idx].fid);
- send_keyinfo (ctrl, data, keygripstr, serialno, idbuf);
+ set_usage_string (usagebuf, idx);
+ send_keyinfo (ctrl, data, keygripstr, serialno, idbuf, usagebuf);
}
}