Project

General

Profile

Actions

Bug #5274

closed

"export" doesn't save EF in MF

Added by laforge over 2 years ago. Updated over 2 years ago.

Status:
Resolved
Priority:
Normal
Assignee:
Category:
-
Target version:
-
Start date:
10/20/2021
Due date:
% Done:

100%

Spec Reference:

Description

################################################################################
# MF/EF.DIR                                                                    #
################################################################################
# directory: MF (3f00)
# file: EF.DIR (2f00)
# bad file: MF/EF.DIR, string indices must be integers
#
################################################################################
# MF/EF.ICCID                                                                  #
################################################################################
# directory: MF (3f00)
# file: EF.ICCID (2fe2)
# bad file: MF/EF.ICCID, string indices must be integers
#
################################################################################
# MF/EF.PL                                                                     #
################################################################################
# directory: MF (3f00)
# file: EF.PL (2f05)
# bad file: MF/EF.PL, string indices must be integers
#
################################################################################
# MF/EF.ARR                                                                    #
################################################################################
# directory: MF (3f00)
# file: EF.ARR (2f06)
# bad file: MF/EF.ARR, string indices must be integers
#
################################################################################
# MF/EF.UMPC                                                                   #
################################################################################
# directory: MF (3f00)
# file: EF.UMPC (2f08)
# bad file: MF/EF.UMPC, string indices must be integers
#

I suspect this relates to the fact that we currently don't use the FCP decoder of UICC (TS 102 221) until we have selected an application like ISIM/USIM.

So the question boils down to: From which point onwards do we know we deal with an UICC, and hence can use that decoder?

Actions #1

Updated by dexter over 2 years ago

  • Status changed from New to In Progress
Actions #2

Updated by dexter over 2 years ago

  • % Done changed from 0 to 10

I have the feeling that as long as we do not select files that are in ADF.USIM or ADF.ISIM, that in those cases we get a select response back that is encoded by ts 51.011. I have had a patch some time ago that fixes that problem (https://gerrit.osmocom.org/c/pysim/+/23209/6/pySim/filesystem.py).

In any case, I think we need a reliable method to tell apart UICC from regular SIMs to pick the correct profile etc. I have pushed a patch along with other fixes that addresses this problem:
https://gerrit.osmocom.org/c/pysim/+/26043

What I also noticed is that when I approach a card with SIM APDUs first, then UICC APDUs seem not to work anymore. I guess this behavior has something to do with backward compatibility. Only ancient modems would use SIM APDUs.

What I can also say is that the broken lyca mobile SIM I was using for testing now behaves normally. I guess using SIM APDUs first made it fall back to SIM-Only mode, and then selecting ADF.USIM made it become an UICC again. In any case, when it is approached with UICC APDUs it works fine.

Actions #3

Updated by dexter over 2 years ago

  • % Done changed from 10 to 50

I think I have now fixed some of the root causes of the problem. Basically there are two things that are problematic. One is to distinguish between UICC and SIM to know which profile to use. The profile should then define the APDU parameters and it also should define a select response decoder that is used when it its not overloaded by a an ADF. This was basically the main problem here. Until ADF.USIM or ADF.ISIM was selected, pySim-shell had no idea how to decode the select response. Now it can fallback to the definition in the profile to decode anything above ADF.USIM and ADF.ISIM.

https://gerrit.osmocom.org/c/pysim/+/26160 ts_102_221: put select response decoder into separate file
https://gerrit.osmocom.org/c/pysim/+/26161 filesystem: fix decode_select_response
https://gerrit.osmocom.org/c/pysim/+/26162 filesystem: do not read AIDs when no apps are defined
https://gerrit.osmocom.org/c/pysim/+/26163 filesystem: make sure the card is in a defined state
https://gerrit.osmocom.org/c/pysim/+/26164 filesystem: define class byte and select control bytes in profile
https://gerrit.osmocom.org/c/pysim/+/26165 pySim-shell: add method to match card profile to card

For ISIM and USIM the problem is fixed, but for SIM there is another decoding problem. The cause of this is that the select response of 2G sims are now decoded, but they have different items. The export command relys on some UICC specific items, so it needs to be extended with some flexibility as well

################################################################################
# MF/DF.GSM/EF.Phase                                                           #
################################################################################
# directory: MF/DF.GSM (3f00/7f20)
# bad file: MF/DF.GSM/EF.Phase, 'list' object has no attribute 'items'
Actions #4

Updated by dexter over 2 years ago

  • % Done changed from 50 to 90

The problems with export on normal sims should now also be fixed:

https://gerrit.osmocom.org/c/pysim/+/26202 filesystem: CardProfile: initialize empty sw table as empty dict
https://gerrit.osmocom.org/c/pysim/+/26203 ts_51_011: add status word definition
https://gerrit.osmocom.org/c/pysim/+/26204 pySim-shell: guess number of records when not specified

Actions #5

Updated by dexter over 2 years ago

  • Status changed from In Progress to Resolved
  • % Done changed from 90 to 100

All related patches are merged. I gave it i quick test with current master. All looks good now, so we can close this now.

Actions

Also available in: Atom PDF

Add picture from clipboard (Maximum size: 48.8 MB)