Change in simtrace2[master]: cardem: choose a more reasonable default ATR
laforge has submitted this change. ( https://gerrit.osmocom.org/c/simtrace2/+/23611 ) Change subject: cardem: choose a more reasonable default ATR .. cardem: choose a more reasonable default ATR PCSCd does not like invalid ATRs Change-Id: I1eebfdc06be55931c2e80e2b515ac3a559737c38 --- M firmware/libcommon/source/card_emu.c M host/src/simtrace2-cardem-pcsc.c 2 files changed, 38 insertions(+), 3 deletions(-) Approvals: Jenkins Builder: Verified fixeria: Looks good to me, but someone else must approve laforge: Looks good to me, approved 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 @@ } } -/* 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 =0x3BDirect Convention + * T0 =0x80Y(1): b1000, K: 0 (historical bytes) + * TD(1) = 0x80Y(i+1) = b1000, Protocol T=0 + * + * TD(2) = 0x81Y(i+1) = b1000, Protocol T=1 + * + * TD(3) = 0x1FY(i+1) = b0001, Protocol T=15 + * + * TA(4) = 0xC7Clock stop: no preference - Class accepted by the card: (3G) A 5V B 3V C 1.8V + * + * Historical bytes + * TCK = 0x59correct 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 =0x3BDirect Convention + * T0 =0x80Y(1): b1000, K: 0 (historical bytes) + * TD(1) = 0x80Y(i+1) = b1000, Protocol T=0 + * + * TD(2) = 0x81Y(i+1) = b1000, Protocol T=1 + * + * TD(3) = 0x1FY(i+1) = b0001, Protocol T=15 + * + * TA(4) = 0xC7Clock stop: no preference - Class accepted by the card: (3G) A 5V B 3V C 1.8V + * + * Historical bytes + * TCK = 0x59correct 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 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; -- To view, visit https://gerrit.osmocom.org/c/simtrace2/+/23611 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: simtrace2 Gerrit-Branch: master Gerrit-Change-Id: I1eebfdc06be55931c2e80e2b515ac3a559737c38 Gerrit-Change-Number: 23611 Gerrit-PatchSet: 2 Gerrit-Owner: laforge Gerrit-Reviewer: Hoernchen Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria Gerrit-Reviewer: laforge Gerrit-MessageType: merged
Change in simtrace2[master]: cardem: choose a more reasonable default ATR
laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/simtrace2/+/23611 ) Change subject: cardem: choose a more reasonable default ATR .. Patch Set 2: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/c/simtrace2/+/23611 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: simtrace2 Gerrit-Branch: master Gerrit-Change-Id: I1eebfdc06be55931c2e80e2b515ac3a559737c38 Gerrit-Change-Number: 23611 Gerrit-PatchSet: 2 Gerrit-Owner: laforge Gerrit-Reviewer: Hoernchen Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria Gerrit-Reviewer: laforge Gerrit-Comment-Date: Sun, 04 Apr 2021 17:56:31 + Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
Change in simtrace2[master]: cardem: choose a more reasonable default ATR
fixeria has posted comments on this change. ( https://gerrit.osmocom.org/c/simtrace2/+/23611 ) Change subject: cardem: choose a more reasonable default ATR .. Patch Set 2: Code-Review+1 Looks good to me now. -- To view, visit https://gerrit.osmocom.org/c/simtrace2/+/23611 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: simtrace2 Gerrit-Branch: master Gerrit-Change-Id: I1eebfdc06be55931c2e80e2b515ac3a559737c38 Gerrit-Change-Number: 23611 Gerrit-PatchSet: 2 Gerrit-Owner: laforge Gerrit-Reviewer: Hoernchen Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria Gerrit-Comment-Date: Sun, 04 Apr 2021 17:56:15 + Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
Change in simtrace2[master]: cardem: choose a more reasonable default ATR
laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/simtrace2/+/23611 ) Change subject: cardem: choose a more reasonable default ATR .. Patch Set 1: (2 comments) https://gerrit.osmocom.org/c/simtrace2/+/23611/1/firmware/libcommon/source/card_emu.c File firmware/libcommon/source/card_emu.c: https://gerrit.osmocom.org/c/simtrace2/+/23611/1/firmware/libcommon/source/card_emu.c@1199 PS1, Line 1199: 0x59}; > missing space Done https://gerrit.osmocom.org/c/simtrace2/+/23611/1/host/src/simtrace2-cardem-pcsc.c File host/src/simtrace2-cardem-pcsc.c: https://gerrit.osmocom.org/c/simtrace2/+/23611/1/host/src/simtrace2-cardem-pcsc.c@56 PS1, Line 56: reasonable ATR offering all protocols and voltages > Weird comment formatting. I would prefer to have it consistent with the GPL > license header. Done -- To view, visit https://gerrit.osmocom.org/c/simtrace2/+/23611 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: simtrace2 Gerrit-Branch: master Gerrit-Change-Id: I1eebfdc06be55931c2e80e2b515ac3a559737c38 Gerrit-Change-Number: 23611 Gerrit-PatchSet: 1 Gerrit-Owner: laforge Gerrit-Reviewer: Hoernchen Gerrit-Reviewer: Jenkins Builder Gerrit-CC: fixeria Gerrit-Comment-Date: Sun, 04 Apr 2021 17:55:00 + Gerrit-HasComments: Yes Gerrit-Has-Labels: No Comment-In-Reply-To: fixeria Gerrit-MessageType: comment
Change in simtrace2[master]: cardem: choose a more reasonable default ATR
Hello Jenkins Builder, Hoernchen, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/c/simtrace2/+/23611 to look at the new patch set (#2). Change subject: cardem: choose a more reasonable default ATR .. cardem: choose a more reasonable default ATR PCSCd does not like invalid ATRs Change-Id: I1eebfdc06be55931c2e80e2b515ac3a559737c38 --- M firmware/libcommon/source/card_emu.c M host/src/simtrace2-cardem-pcsc.c 2 files changed, 38 insertions(+), 3 deletions(-) git pull ssh://gerrit.osmocom.org:29418/simtrace2 refs/changes/11/23611/2 -- To view, visit https://gerrit.osmocom.org/c/simtrace2/+/23611 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: simtrace2 Gerrit-Branch: master Gerrit-Change-Id: I1eebfdc06be55931c2e80e2b515ac3a559737c38 Gerrit-Change-Number: 23611 Gerrit-PatchSet: 2 Gerrit-Owner: laforge Gerrit-Reviewer: Hoernchen Gerrit-Reviewer: Jenkins Builder Gerrit-CC: fixeria Gerrit-MessageType: newpatchset
Change in simtrace2[master]: cardem: choose a more reasonable default ATR
fixeria has posted comments on this change. ( https://gerrit.osmocom.org/c/simtrace2/+/23611 ) Change subject: cardem: choose a more reasonable default ATR .. Patch Set 1: (2 comments) https://gerrit.osmocom.org/c/simtrace2/+/23611/1/firmware/libcommon/source/card_emu.c File firmware/libcommon/source/card_emu.c: https://gerrit.osmocom.org/c/simtrace2/+/23611/1/firmware/libcommon/source/card_emu.c@1199 PS1, Line 1199: 0x59}; missing space https://gerrit.osmocom.org/c/simtrace2/+/23611/1/host/src/simtrace2-cardem-pcsc.c File host/src/simtrace2-cardem-pcsc.c: https://gerrit.osmocom.org/c/simtrace2/+/23611/1/host/src/simtrace2-cardem-pcsc.c@56 PS1, Line 56: reasonable ATR offering all protocols and voltages Weird comment formatting. I would prefer to have it consistent with the GPL license header. -- To view, visit https://gerrit.osmocom.org/c/simtrace2/+/23611 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: simtrace2 Gerrit-Branch: master Gerrit-Change-Id: I1eebfdc06be55931c2e80e2b515ac3a559737c38 Gerrit-Change-Number: 23611 Gerrit-PatchSet: 1 Gerrit-Owner: laforge Gerrit-Reviewer: Hoernchen Gerrit-Reviewer: Jenkins Builder Gerrit-CC: fixeria Gerrit-Comment-Date: Sun, 04 Apr 2021 15:08:19 + Gerrit-HasComments: Yes Gerrit-Has-Labels: No Gerrit-MessageType: comment
Change in simtrace2[master]: cardem: choose a more reasonable default ATR
Hello Hoernchen, I'd like you to do a code review. Please visit https://gerrit.osmocom.org/c/simtrace2/+/23611 to review the following change. Change subject: cardem: choose a more reasonable default ATR .. cardem: choose a more reasonable default ATR PCSCd does not like invalid ATRs Change-Id: I1eebfdc06be55931c2e80e2b515ac3a559737c38 --- M firmware/libcommon/source/card_emu.c M host/src/simtrace2-cardem-pcsc.c 2 files changed, 39 insertions(+), 3 deletions(-) git pull ssh://gerrit.osmocom.org:29418/simtrace2 refs/changes/11/23611/1 diff --git a/firmware/libcommon/source/card_emu.c b/firmware/libcommon/source/card_emu.c index cad24b8..099fed1 100644 --- a/firmware/libcommon/source/card_emu.c +++ b/firmware/libcommon/source/card_emu.c @@ -1179,8 +1179,24 @@ } } -/* 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..ad3e0f3 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 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; -- To view, visit https://gerrit.osmocom.org/c/simtrace2/+/23611 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: simtrace2 Gerrit-Branch: master Gerrit-Change-Id: I1eebfdc06be55931c2e80e2b515ac3a559737c38 Gerrit-Change-Number: 23611 Gerrit-PatchSet: 1 Gerrit-Owner: laforge Gerrit-Reviewer: Hoernchen Gerrit-MessageType: newchange