[S] Change in libosmocore[master]: libosmosim: Support Microsoft smart card discovery process

2023-11-28 Thread laforge
laforge has submitted this change. ( 
https://gerrit.osmocom.org/c/libosmocore/+/35154?usp=email )

Change subject: libosmosim: Support Microsoft smart card discovery process
..

libosmosim: Support Microsoft smart card discovery process

Our class/instruction tables (used mainly by simtrace cardem host
software) only contain support for those instructions permitted
in the related card specification.

Microsoft blindly tries CLA=0xCA with INS=0x00 which is not somethin
that the GSM SIM, ETSI UICC or 3GPP USIM specs specify, and which
hence results in log output like this:

DLINP DEBUG [0] <= osmo_st2_cardem_request_sw_tx(sw=6a88)
DLGLOBAL INFO => DATA: flags=0x01 (HDR ), 00 ca 7f 68 00
DLGLOBAL ERROR Unknown APDU case 0
DLGLOBAL FATAL Failed to recognize APDU, terminating

Let's adjust to microsoft and *always* support their instructions
no matter which osim_cla_ins_card_profile was used.

Special thanks to Eric Wild for pointing me to this unexpected
behaviour of PC/SC on modern Windows.

Change-Id: I424964c0afab643e6a5d7824d91c2c86b0d3f25b
Related: SYS#6617
---
M src/sim/class_tables.c
1 file changed, 47 insertions(+), 0 deletions(-)

Approvals:
  Jenkins Builder: Verified
  Hoernchen: Looks good to me, approved
  fixeria: Looks good to me, but someone else must approve




diff --git a/src/sim/class_tables.c b/src/sim/class_tables.c
index 6d05ede..29c1e40 100644
--- a/src/sim/class_tables.c
+++ b/src/sim/class_tables.c
@@ -350,6 +350,13 @@
[0x88]  = 4,/* AUTHENTICATE */
 };

+/* 
https://learn.microsoft.com/en-us/windows-hardware/drivers/smartcard/discovery-process
 */
+static const uint8_t microsoft_discovery_ins_tbl[256] = {
+   [0xA4]  = 4,/* SELECT FILE */
+   [0xCA]  = 2,/* GET DATA */
+   [0xC0]  = 2,/* GET RESPONSE */
+};
+
 int osim_determine_apdu_case(const struct osim_cla_ins_card_profile *prof,
 const uint8_t *hdr)
 {
@@ -374,5 +381,16 @@
return rc;
}
}
+   /* special handling for Microsoft who insists to use INS=0xCA in 
CLA=0x00 which is not
+* really part of GSM SIM, ETSI UICC or 3GPP USIM specifications, but 
only ISO7816. Rather than adding
+* it to each and every card profile, let's add the instructions listed 
at
+* 
https://learn.microsoft.com/en-us/windows-hardware/drivers/smartcard/discovery-process
 explicitly
+* here. They will only be used in case no more specific match was 
found in the actual profile above. */
+   if (cla == 0x00) {
+   rc = microsoft_discovery_ins_tbl[ins];
+   if (rc)
+   return rc;
+   }
+
return 0;
 }

--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/35154?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I424964c0afab643e6a5d7824d91c2c86b0d3f25b
Gerrit-Change-Number: 35154
Gerrit-PatchSet: 4
Gerrit-Owner: laforge 
Gerrit-Reviewer: Hoernchen 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter 
Gerrit-Reviewer: fixeria 
Gerrit-Reviewer: laforge 
Gerrit-MessageType: merged


[S] Change in libosmocore[master]: libosmosim: Support Microsoft smart card discovery process

2023-11-28 Thread laforge
Attention is currently required from: dexter.

laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/libosmocore/+/35154?usp=email )

Change subject: libosmosim: Support Microsoft smart card discovery process
..


Patch Set 4:

(1 comment)

Patchset:

PS4:
> It would probably be useful to add the msdn links to the commit message that 
> explain what MS does?
the links are in the code comments, not sure we need them also in the commit 
message?



--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/35154?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I424964c0afab643e6a5d7824d91c2c86b0d3f25b
Gerrit-Change-Number: 35154
Gerrit-PatchSet: 4
Gerrit-Owner: laforge 
Gerrit-Reviewer: Hoernchen 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter 
Gerrit-Reviewer: fixeria 
Gerrit-Attention: dexter 
Gerrit-Comment-Date: Tue, 28 Nov 2023 22:24:48 +
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Hoernchen 
Gerrit-MessageType: comment


[S] Change in libosmocore[master]: libosmosim: Support Microsoft smart card discovery process

2023-11-28 Thread Hoernchen
Attention is currently required from: dexter, laforge.

Hoernchen has posted comments on this change. ( 
https://gerrit.osmocom.org/c/libosmocore/+/35154?usp=email )

Change subject: libosmosim: Support Microsoft smart card discovery process
..


Patch Set 4: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/35154?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I424964c0afab643e6a5d7824d91c2c86b0d3f25b
Gerrit-Change-Number: 35154
Gerrit-PatchSet: 4
Gerrit-Owner: laforge 
Gerrit-Reviewer: Hoernchen 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter 
Gerrit-Reviewer: fixeria 
Gerrit-Attention: laforge 
Gerrit-Attention: dexter 
Gerrit-Comment-Date: Tue, 28 Nov 2023 22:09:56 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


[S] Change in libosmocore[master]: libosmosim: Support Microsoft smart card discovery process

2023-11-28 Thread Hoernchen
Attention is currently required from: dexter, laforge.

Hoernchen has posted comments on this change. ( 
https://gerrit.osmocom.org/c/libosmocore/+/35154?usp=email )

Change subject: libosmosim: Support Microsoft smart card discovery process
..


Patch Set 4:

(1 comment)

Patchset:

PS4:
It would probably be useful to add the msdn links to the commit message that 
explain what MS does?



--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/35154?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I424964c0afab643e6a5d7824d91c2c86b0d3f25b
Gerrit-Change-Number: 35154
Gerrit-PatchSet: 4
Gerrit-Owner: laforge 
Gerrit-Reviewer: Hoernchen 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter 
Gerrit-Reviewer: fixeria 
Gerrit-Attention: laforge 
Gerrit-Attention: dexter 
Gerrit-Comment-Date: Tue, 28 Nov 2023 22:07:23 +
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment


[S] Change in libosmocore[master]: libosmosim: Support Microsoft smart card discovery process

2023-11-28 Thread fixeria
Attention is currently required from: Hoernchen, dexter, laforge.

fixeria has posted comments on this change. ( 
https://gerrit.osmocom.org/c/libosmocore/+/35154?usp=email )

Change subject: libosmosim: Support Microsoft smart card discovery process
..


Patch Set 3: Code-Review+1


--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/35154?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I424964c0afab643e6a5d7824d91c2c86b0d3f25b
Gerrit-Change-Number: 35154
Gerrit-PatchSet: 3
Gerrit-Owner: laforge 
Gerrit-Reviewer: Hoernchen 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter 
Gerrit-Reviewer: fixeria 
Gerrit-Attention: Hoernchen 
Gerrit-Attention: laforge 
Gerrit-Attention: dexter 
Gerrit-Comment-Date: Tue, 28 Nov 2023 21:54:10 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


[S] Change in libosmocore[master]: libosmosim: Support Microsoft smart card discovery process

2023-11-28 Thread laforge
Attention is currently required from: Hoernchen, dexter.

Hello Hoernchen, Jenkins Builder, dexter,

I'd like you to reexamine a change. Please visit

https://gerrit.osmocom.org/c/libosmocore/+/35154?usp=email

to look at the new patch set (#3).

The following approvals got outdated and were removed:
Verified+1 by Jenkins Builder


Change subject: libosmosim: Support Microsoft smart card discovery process
..

libosmosim: Support Microsoft smart card discovery process

Our class/instruction tables (used mainly by simtrace cardem host
software) only contain support for those instructions permitted
in the related card specification.

Microsoft blindly tries CLA=0xCA with INS=0x00 which is not somethin
that the GSM SIM, ETSI UICC or 3GPP USIM specs specify, and which
hence results in log output like this:

DLINP DEBUG [0] <= osmo_st2_cardem_request_sw_tx(sw=6a88)
DLGLOBAL INFO => DATA: flags=0x01 (HDR ), 00 ca 7f 68 00
DLGLOBAL ERROR Unknown APDU case 0
DLGLOBAL FATAL Failed to recognize APDU, terminating

Let's adjust to microsoft and *always* support their instructions
no matter which osim_cla_ins_card_profile was used.

Special thanks to Eric Wild for pointing me to this unexpected
behaviour of PC/SC on modern Windows.

Change-Id: I424964c0afab643e6a5d7824d91c2c86b0d3f25b
Related: SYS#6617
---
M src/sim/class_tables.c
1 file changed, 47 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/54/35154/3
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/35154?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I424964c0afab643e6a5d7824d91c2c86b0d3f25b
Gerrit-Change-Number: 35154
Gerrit-PatchSet: 3
Gerrit-Owner: laforge 
Gerrit-Reviewer: Hoernchen 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter 
Gerrit-Attention: Hoernchen 
Gerrit-Attention: dexter 
Gerrit-MessageType: newpatchset


[S] Change in libosmocore[master]: libosmosim: Support Microsoft smart card discovery process

2023-11-28 Thread laforge
Attention is currently required from: Hoernchen, dexter.

Hello Hoernchen, dexter,

I'd like you to reexamine a change. Please visit

https://gerrit.osmocom.org/c/libosmocore/+/35154?usp=email

to look at the new patch set (#2).


Change subject: libosmosim: Support Microsoft smart card discovery process
..

libosmosim: Support Microsoft smart card discovery process

Our class/instruction tables (used mainly by simtrace cardem host
software) only contain support for those instructions permitted
in the related card specification.

Microsoft blindly tries CLA=0xCA with INS=0x00 which is not somethin
that the GSM SIM, ETSI UICC or 3GPP USIM specs specify, and which
hence results in log output like this:

DLINP DEBUG [0] <= osmo_st2_cardem_request_sw_tx(sw=6a88)
DLGLOBAL INFO => DATA: flags=0x01 (HDR ), 00 ca 7f 68 00
DLGLOBAL ERROR Unknown APDU case 0
DLGLOBAL FATAL Failed to recognize APDU, terminating

Let's adjust to microsoft and *always* support their instructions
no matter which osim_cla_ins_card_profile was used.

Special thanks to Eric Wild for pointing me to this unexpected
behaviour of PC/SC on modern Windows.

Change-Id: I424964c0afab643e6a5d7824d91c2c86b0d3f25b
Related: SYS#6617
---
M src/sim/class_tables.c
1 file changed, 45 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/54/35154/2
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/35154?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I424964c0afab643e6a5d7824d91c2c86b0d3f25b
Gerrit-Change-Number: 35154
Gerrit-PatchSet: 2
Gerrit-Owner: laforge 
Gerrit-Reviewer: Hoernchen 
Gerrit-Reviewer: dexter 
Gerrit-CC: Jenkins Builder
Gerrit-Attention: Hoernchen 
Gerrit-Attention: dexter 
Gerrit-MessageType: newpatchset