summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Levy <alevy@redhat.com>2010-09-08 12:24:18 +0300
committerAlon Levy <alevy@redhat.com>2010-09-08 12:24:18 +0300
commiteb6a437d8d356026db180bf5d9830032ad01a37d (patch)
tree2558c4afef3f9d4f8c04af6200337883ba201841
parent2019f6bf4006063ff7b5fbaa9a4c27b50ad8d432 (diff)
fix ATR for windows usbccid.sys compat: correct length of historical bytes, and send TA1==0x13
-rw-r--r--vcard_emul_nss.c3
-rw-r--r--vcardt.h5
2 files changed, 7 insertions, 1 deletions
diff --git a/vcard_emul_nss.c b/vcard_emul_nss.c
index 21da5f2..906f97b 100644
--- a/vcard_emul_nss.c
+++ b/vcard_emul_nss.c
@@ -354,6 +354,9 @@ vcard_emul_get_atr(VCard *card, unsigned char *atr, int *atr_len)
ASSERT(atr != NULL);
memcpy(atr, nss_atr, len);
+ // set the hb_length correctly (length of historical bytes), second byte, T1
+ // last nibble. Windows usbccid.sys needs this to be correct.
+ atr[1] = (atr[1] & 0xf0) + sizeof(nss_atr) - VCARD_ATR_MAIN_LENGTH;
*atr_len = len;
return;
}
diff --git a/vcardt.h b/vcardt.h
index 44f41f8..885f2d1 100644
--- a/vcardt.h
+++ b/vcardt.h
@@ -28,7 +28,10 @@ typedef struct VCardEmulStruct VCardEmul;
#define MAX_CHANNEL 4
/* create an ATR with appropriate historical bytes */
-#define VCARD_ATR_PREFIX 0x3b, 0x6f, 0x00, 0xff, 'V', 'C', 'A', 'R', 'D', '_'
+#define VCARD_ATR_PREFIX 0x3b, 0x7f, 0x13, 0x00, 0xff, 'V', 'C', 'A', 'R', 'D', '_'
+
+/* length of non historical bytes part */
+#define VCARD_ATR_MAIN_LENGTH 5
typedef enum {
VCARD_DONE,