Creating linked files on sysmoISIM-SJA5

Just like SJA2 predecessor, sysmoISIM-SJA5 cards allow you to use CREATE FILE command of ETSI TS 102 222 section 6.3 to create new files and directories almost anywhere in the card file system. In a sane world this operation would require authentication with ADM1, but on these Sysmocom cards the relevant permissions are set wrong, and anyone can create new files with this APDU command without any authentication, i.e., without needing ADM1 at all. I already reported this bug to Sysmocom and we can only hope that they’ll get it fixed in future card batches - but my present question is about a different aspect of new file creation.

Many commercial operators still issue SIM+USIM cards that work as both GSM 11.11 SIM and 3GPP USIM, and all Sysmocom cards likewise support such operation. GSM 11.11 and 3GPP TS 31.102 define many of the same files, but put them in different locations in the file system. Most SIM+USIM cards implement a solution that works just like hard links in a UNIX file system: when you explore the file system of a SIM+USIM card, you will see - for example - EF.SMS appearing under both DF.TELECOM and ADF.USIM, and they will look like separate files. But when you write anything to one of these “separate” files, it appears in both “copies”, revealing that they are actually invisible links to the same byte store.

I seek to create new links of this type in SJA5 file system. Before anyone tells me to “just use pySim-shell”, I looked and it does not support link creation: it can create new DFs and non-linked EFs, but not links. Instead of pySim, I maintain my own alternative software for SIM and UICC programming, and I can implement whatever functionality is needed - but I need to know what magic APDU bits to send to the card. The definition of CREATE FILE command in TS 102 222 does not say anything about links, i.e., they are a proprietary feature of many/most CardOS that is not covered by the spec. I reason that SJA5 CardOS probably implements some proprietary extension to CREATE FILE command that causes it to create a link, and I asked Sysmocom about it in the context of a sales inquiry about making a custom batch of cards. I was told this one-liner:

D1 is the file linking path, if the file is linked to another file.

I was asking about proprietary IE tags 0xD0 and 0xD2 that appear inside the “Proprietary information” IE of TS 102 221 section 11.1.1.4.6 (seen in SELECT responses), thus when I was given that one-liner about D1, I naturally concluded that tag 0xD1 needs to go inside that “Proprietary info” IE with tag 0xA5. I further assumed, in the absence of other clarification, that the file path needs to be in the form defined in TS 102 221 section 8.4.2.

Then it was time for an experiment. I created EF.ADN under DF.TELECOM (the standard location of this file in GSM 11.11) with this FCP structure - the quoted block is SELECT output on this file after I created it successfully:

82 05 42 21 00 2C FA
83 02 6F 3A
A5 06 D0 01 30 D2 01 0F
8A 01 05
8B 03 6F 06 03
80 02 2A F8
88 00

Then changed the current directory (with SELECT) to /DF.TELECOM/DF.PHONEBOOK (the location for USIM) and tried to create a link by feeding this FCP to CREATE FILE:

82 05 42 21 00 2C FA
83 02 4F 3A
8A 01 05
8B 03 6F 06 03
80 02 2A F8
88 00
A5 06 D1 04 7F 10 6F 3A

Basically I sent the same FCP as would be correct for creation of another unrelated file of the same geometry, but including that tag 0xD1 inside 0xA5 - see the last line. But no joy - the card replies with SW 0x6985, which means (per ISO 7816-4) “Conditions of use not satisfied”. But then I am flying blind here - no one gave me a complete example of a working CREATE FILE APDU for creation of links, just that one-liner I quoted, which is not sufficient info to deduce the full APDU.

I would really appreciate it if someone could share a complete working example of link creation, using whatever extension to CREATE FILE is implemented on SJA5. In the example, please indicate the source location of the file that exists before link creation, the destination directory for the link, which directory (source or destination) needs to be SELECTed before sending CREATE FILE, and either the complete APDU to be sent to the card or just the FCP portion of this APDU like the ones I showed.

The definitive D1 encoding is proprietary SJA5 CardOS, not in TS 102 222, so don’t try to deduce it from the spec — but you already have a verified reference sitting on the card itself. Your SJA5 ships with factory SIM+USIM links (you cited EF.SMS appearing under both DF.TELECOM and ADF.USIM over one store). SELECT one of those factory-linked files on the SJA5 and read its full FCP. That is the card’s own authoritative output for a link it considers valid, and it settles the one thing the sysmocom one-liner didn’t: which allocation IEs a link carries and how D1 is actually encoded.

That points straight at your 6985. Your destination FCP declares a fresh body — 82 (linear fixed, 44 × 250) and 80 02 2AF8 (11000 bytes) — while also giving D1. A hard link must not allocate its own store; its geometry is inherited from the target. Declaring both a body and a link is exactly a “conditions of use not satisfied” case. Drop 80 (file size), and most likely the 82 descriptor as well, keeping 83 (4F3A), 8A, 8B, 88 and A5/D1. Confirm the exact minimal set against the factory link’s FCP.

Two more things that FCP will resolve, both left open by the one-liner:

  • whether D1’s path is MF-relative as you assumed (7F 10 6F 3A) or needs a 3F00 prefix / a different reference form.
  • your sequence is already right — master created first (EF.ADN 6F3A under DF.TELECOM), destination DF selected, then CREATE FILE the link there. The FCP contents are the problem, not the ordering.

If reading the factory link still doesn’t disambiguate it, the only authoritative source is sysmocom’s card team — the same channel that gave you the D1 line. Ask them for a complete link FCP example and explicit confirmation of whether 80/82 must be omitted. That’s proprietary COS behaviour no one outside can hand you reliably, so pin them to a full working APDU rather than another one-liner.

Except that it does not work this way: for each “instance” of a linked file, SELECT response is exactly the same as it would be in the absence of a link, and the only way to know that the two “separate” files are linked is to modify one and see if the changes also show up in the other. Thus there are absolutely no clues in SELECT responses for how to make links.

I tried dropping tag 80, tag 82 or both (3 combinations in total), and each time the card returned SW 0x6A80: “Incorrect parameters in the command data field”.

Yes, these are valid questions, but because FCP responses to SELECT show no traces of link existence (the links are truly invisible until you hit one of the files with an UPDATE BINARY or UPDATE RECORD that actually changes it), they are of no help toward answering these questions.

Yes, Sysmocom card team is indeed the only entity on the planet that holds the necessary secret info - but I have been advised to make my inquiry public, as there is nothing private here and it is vital technical info that deserves to be public.