diff options
author | Eric Wild <ewild@sysmocom.de> | 2020-04-03 21:21:27 +0200 |
---|---|---|
committer | Harald Welte <laforge@osmocom.org> | 2021-04-04 19:54:19 +0200 |
commit | 0b1a3b41055ab6de3ef94a0c8f936c6096d41b5a (patch) | |
tree | 3ebfa36420b63e118cda1148aa27639fa9f55e60 | |
parent | 9316890a39a3f0ae5015e9cf17cd31c8a03a44af (diff) |
cardem: choose a more reasonable default ATR
PCSCd does not like invalid ATRs
Change-Id: I1eebfdc06be55931c2e80e2b515ac3a559737c38
-rw-r--r-- | firmware/libcommon/source/card_emu.c | 19 | ||||
-rw-r--r-- | host/src/simtrace2-cardem-pcsc.c | 22 |
2 files changed, 38 insertions, 3 deletions
diff --git a/firmware/libcommon/source/card_emu.c b/firmware/libcommon/source/card_emu.c index cad24b8..269c7c6 100644 --- a/firmware/libcommon/source/card_emu.c +++ b/firmware/libcommon/source/card_emu.c @@ -1179,8 +1179,23 @@ void tc_etu_wtime_expired(void *handle) } } -/* shortest ATR possible (uses default speed and no options) */ -static const uint8_t default_atr[] = { 0x3B, 0x00 }; +/* reasonable ATR offering all protocols and voltages + * smartphones might not care, but other readers do + * + * TS = 0x3B Direct Convention + * T0 = 0x80 Y(1): b1000, K: 0 (historical bytes) + * TD(1) = 0x80 Y(i+1) = b1000, Protocol T=0 + * ---- + * TD(2) = 0x81 Y(i+1) = b1000, Protocol T=1 + * ---- + * TD(3) = 0x1F Y(i+1) = b0001, Protocol T=15 + * ---- + * TA(4) = 0xC7 Clock stop: no preference - Class accepted by the card: (3G) A 5V B 3V C 1.8V + * ---- + * Historical bytes + * TCK = 0x59 correct checksum + */ +static const uint8_t default_atr[] = { 0x3B, 0x80, 0x80, 0x81 , 0x1F, 0xC7, 0x59 }; static struct card_handle card_handles[NUM_SLOTS]; diff --git a/host/src/simtrace2-cardem-pcsc.c b/host/src/simtrace2-cardem-pcsc.c index 883bad1..f11330c 100644 --- a/host/src/simtrace2-cardem-pcsc.c +++ b/host/src/simtrace2-cardem-pcsc.c @@ -52,6 +52,26 @@ #define ATR_MAX_LEN 33 + +/* reasonable ATR offering all protocols and voltages + * smartphones might not care, but other readers do + * + * TS = 0x3B Direct Convention + * T0 = 0x80 Y(1): b1000, K: 0 (historical bytes) + * TD(1) = 0x80 Y(i+1) = b1000, Protocol T=0 + * ---- + * TD(2) = 0x81 Y(i+1) = b1000, Protocol T=1 + * ---- + * TD(3) = 0x1F Y(i+1) = b0001, Protocol T=15 + * ---- + * TA(4) = 0xC7 Clock stop: no preference - Class accepted by the card: (3G) A 5V B 3V C 1.8V + * ---- + * Historical bytes + * TCK = 0x59 correct checksum + */ +#define DEFAULT_ATR_STR "3B8080811FC759" + + static void atr_update_csum(uint8_t *atr, unsigned int atr_len) { uint8_t csum = 0; @@ -274,7 +294,7 @@ int main(int argc, char **argv) int rc; int c, ret = 1; int skip_atr = 0; - char *atr = "3b00"; + char *atr = DEFAULT_ATR_STR; uint8_t real_atr[ATR_MAX_LEN]; int atr_len; int keep_running = 0; |