aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Wild <ewild@sysmocom.de>2020-04-03 21:21:27 +0200
committerEric Wild <ewild@sysmocom.de>2020-04-10 02:09:40 +0200
commitccceb0ffba8947af35545166141bbbb908ff409d (patch)
tree596a3f730f0d16e7482ecc7424453ac1a340d10f
parente0f4d9216eac4e8848e1b405748196aed43e03e0 (diff)
cardem: choose a more reasonable default ATRhoernchen/simtrace_cardem
PCSCd does not like invalid ATRs Change-Id: I1eebfdc06be55931c2e80e2b515ac3a559737c38
-rw-r--r--firmware/libcommon/source/card_emu.c20
-rw-r--r--host/src/simtrace2-remsim.c22
2 files changed, 38 insertions, 4 deletions
diff --git a/firmware/libcommon/source/card_emu.c b/firmware/libcommon/source/card_emu.c
index 16babf4..1a40d6e 100644
--- a/firmware/libcommon/source/card_emu.c
+++ b/firmware/libcommon/source/card_emu.c
@@ -1297,8 +1297,24 @@ void card_emu_wt_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-remsim.c b/host/src/simtrace2-remsim.c
index 053ee63..d8080b0 100644
--- a/host/src/simtrace2-remsim.c
+++ b/host/src/simtrace2-remsim.c
@@ -50,6 +50,26 @@
#include <osmocom/sim/class_tables.h>
#include <osmocom/sim/sim.h>
+/*
+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 uint8_t real_atr[] = { 0x3B, 0x80, 0x80, 0x81 , 0x1F, 0xC7, 0x59};
+
+
static void atr_update_csum(uint8_t *atr, unsigned int atr_len)
{
uint8_t csum = 0;
@@ -437,8 +457,6 @@ int main(int argc, char **argv)
osmo_st2_modem_sim_select_remote(ci->slot);
if (!skip_atr) {
- /* set the ATR */
- uint8_t real_atr[] = { 0x3B, 0x00 }; // the simplest ATR
atr_update_csum(real_atr, sizeof(real_atr));
osmo_st2_cardem_request_set_atr(ci, real_atr, sizeof(real_atr));
}