aboutsummaryrefslogtreecommitdiffstats
path: root/tools/card-call-scd.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2020-11-27 10:28:16 +0000
committerWerner Koch <[email protected]>2020-11-27 10:28:16 +0000
commitad469609b101fe6c1128135180fef8eae13279ff (patch)
treeb186b061f08e93b8d76f9767f52fdff2c0a409ce /tools/card-call-scd.c
parentscd: New getinfo sub-command apdu_strerror. (diff)
downloadgnupg-ad469609b101fe6c1128135180fef8eae13279ff.tar.gz
gnupg-ad469609b101fe6c1128135180fef8eae13279ff.zip
card: Let the APDU command prints a description of the status word.
* tools/card-call-scd.c (scd_apdu_strerror): New. * tools/gpg-card.c (cmd_apdu): Print a description. -- Pretty convenient to explore smartcards.
Diffstat (limited to 'tools/card-call-scd.c')
-rw-r--r--tools/card-call-scd.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/tools/card-call-scd.c b/tools/card-call-scd.c
index 1f7008902..bb739e684 100644
--- a/tools/card-call-scd.c
+++ b/tools/card-call-scd.c
@@ -1709,3 +1709,33 @@ agent_get_s2k_count (void)
return count;
}
+
+
+/* Return a malloced string describing the statusword SW. On error
+ * NULL is returned. */
+char *
+scd_apdu_strerror (unsigned int sw)
+{
+ gpg_error_t err;
+ char line[ASSUAN_LINELENGTH];
+ membuf_t data;
+ char *buf;
+
+ err = start_agent (0);
+ if (err)
+ return NULL;
+
+ init_membuf (&data, 64);
+ snprintf (line, sizeof line, "SCD GETINFO apdu_strerror 0x%x", sw);
+ err = assuan_transact (agent_ctx, line, put_membuf_cb, &data,
+ NULL, NULL, NULL, NULL);
+ if (err)
+ {
+ xfree (get_membuf (&data, NULL));
+ return NULL;
+ }
+
+ put_membuf (&data, "", 1);
+ buf = get_membuf (&data, NULL);
+ return buf;
+}