Updating EF files in pysim

How does one update EF files in a SIM using pysim? I know the edit_binary_decoded command exists but I keep running into security permissions not being satisfied. Do I need to verify_chv first? For the test eUICC with SGP.26 on sysmocom, is the pin documented somewhere?

@laforge

This question can not be answered in a generic way. Every EF has access conditions associated with it, and those define which user using which credentials can perform which operation (read/update/delete/deactivate/…).

The response of the “select” command on an EF will tell you the details; possibly you need to consult the linked EF.ACC record, too.

Once you know which identity has the desired permission (if the file is writable by anyone, at all), then you need to authenticate using it. For most UICC like the sysmoUSIM/sysmoISIM products, it’s the ADM1 PIN which is provided at time of purchase.

None of this is specific to pySim, it is a general aspect of all smart cards within the ISO 7816 family.

There are no files on the eUICC itself that you could modify, and hence there is no related PIN.

The files you refer to are likely files of an eSIM profile installed on the eUICC, not the eUICC, right? And that eSIM profile defines the access control conditions as well as PINs (ADM1, etc.) along with them. If you’re using a TS.48 test profile, then you need to consult TS.48 for it.

In general I suggest to learn to work with normal classic SIM/USIM first, before taking the step to eUICC and eSIM profiles. Otherwise it’s just another layer of complexity…

1 Like

@laforge

So I’m trying to write values onto a writable SIM card using pysim. But when I use any of the write commands, like edit_binary_decoded and the vim editor pops up, I get this error:

File "/pysim/pySim/commands.py", line 395, in update_binary

    raise ValueError('%s, failed to write chunk (chunk_offset %d, chunk_len %d)' %

ValueError: SW match failed! Expected 9000 and got 6982: Command not allowed - Security status not satisfied, failed to write chunk (chunk_offset 0, chunk_len 9)

EXCEPTION of type 'ValueError' occurred with message: SW match failed! Expected 9000 and got 6982: Command not allowed - Security status not satisfied, failed to write chunk (chunk_offset 0, chunk_len 9)

Any advice on what I should do?