aboutsummaryrefslogtreecommitdiffstats
path: root/scd/iso7816.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2021-03-19 17:26:03 +0000
committerWerner Koch <[email protected]>2021-03-19 17:26:03 +0000
commit37b1c5c2004c1147a13b388863aaa8f0caf7d71f (patch)
treeb1cfd3273c9b8cd45f7c213952fb673c88e7351e /scd/iso7816.c
parentscd:openpgp: Rename an internal variable. (diff)
downloadgnupg-37b1c5c2004c1147a13b388863aaa8f0caf7d71f.tar.gz
gnupg-37b1c5c2004c1147a13b388863aaa8f0caf7d71f.zip
scd:openpgp: Allow reading and writing user certs for keys 1 and 2
* scd/iso7816.c (CMD_SELECT_DATA): New. (iso7816_select_data): New. * scd/app-openpgp.c (do_readcert): Allow OpenPGP.1 and OPENPGP.2 (do_writecert): Ditto. (do_setattr): Add CERT-1 and CERT-2. -- This has been tested with a Zeitcontrol 3.4 card. A test with a Yubikey 5 (firmware 5.2.6) claiming to support 3.4 failed. Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to 'scd/iso7816.c')
-rw-r--r--scd/iso7816.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/scd/iso7816.c b/scd/iso7816.c
index 19464eab7..8896486b8 100644
--- a/scd/iso7816.c
+++ b/scd/iso7816.c
@@ -32,6 +32,7 @@
#define CMD_SELECT_FILE 0xA4
+#define CMD_SELECT_DATA 0xA5
#define CMD_VERIFY ISO7816_VERIFY
#define CMD_CHANGE_REFERENCE_DATA ISO7816_CHANGE_REFERENCE_DATA
#define CMD_RESET_RETRY_COUNTER ISO7816_RESET_RETRY_COUNTER
@@ -470,6 +471,44 @@ iso7816_reset_retry_counter (int slot, int chvno,
}
+/* Perform a SELECT DATA command to OCCURANCE of TAG. */
+gpg_error_t
+iso7816_select_data (int slot, int occurrence, int tag)
+{
+ int sw;
+ int datalen;
+ unsigned char data[7];
+
+ data[0] = 0x60;
+ data[2] = 0x5c;
+ if (tag <= 0xff)
+ {
+ data[3] = 1;
+ data[4] = tag;
+ datalen = 5;
+ }
+ else if (tag <= 0xffff)
+ {
+ data[3] = 2;
+ data[4] = (tag >> 8);
+ data[5] = tag;
+ datalen = 6;
+ }
+ else
+ {
+ data[3] = 3;
+ data[4] = (tag >> 16);
+ data[5] = (tag >> 8);
+ data[6] = tag;
+ datalen = 7;
+ }
+ data[1] = datalen - 2;
+
+ sw = apdu_send_le (slot, 0, 0x00, CMD_SELECT_DATA,
+ occurrence, 0x04, datalen, data, 0, NULL, NULL);
+ return map_sw (sw);
+}
+
/* Perform a GET DATA command requesting TAG and storing the result in
a newly allocated buffer at the address passed by RESULT. Return