I installed an STK applet on a on a SysmoISIM-SJA5-S17, using these instructions. Everything installs and runs as expected. However, I am having an issue accessing files within the USIM ADF:
The applet is executes this code:
private static final byte[ ] usimAid = {
(byte)0xa0, (byte)0x00, (byte)0x00, (byte)0x00,
(byte)0x87, (byte)0x10, (byte)0x02, (byte)0xff,
(byte)0xff, (byte)0xff, (byte)0xff, (byte)0x89,
(byte)0x07, (byte)0x09, (byte)0x00, (byte)0x00
};
FileView file = UICCSystem.getTheFileView(
usimAid,
(short)0,
(byte)(usimAid.length),
JCSystem.CLEAR_ON_RESET);
file.select(USIMConstants.FID_EF_IMSI);
file.readBinary((short)1, imsiBuf, imsiOff, (short)8);
However, the readBinary() method throws a UICCException (SECURITY_STATUS_NOT_SATISFIED).
I am able to access files in the MF, but not in USIM. I’m sure it’s an issue with how I installed the applet. Is there a good reference on this, installing applets that can read/write USIM files?
Thanks.
1 Like
Looking at ETSI TS 102 226 and TCA Stepping Stones, pySIM’s install-parameters-stk 0xCA tag needs to be replaced with the UICC-specific 0xEA tag (and its composite tags 0x80, 0xC3, 0x81, and 0x82). Then it seems the UICCSystem FileView can be configured to access the USIM filesystem.
Is this possible with pySIM, specifying install-parameters-usat or the equivalent?
I don’t think it is at the moment, but it sounds like it would be a rather simple change to add this functionality. We’re always very much looking forward to contributions to the pySim codebase, whose development is sadly almost entirely supported by sysmocom, despite 99% of its features not being specific to sysmocom products.
I added this, and I’m happy to contribute, but in testing I’m wondering if SJA5 supports the 0xea tag?
For example below, when I specify both the 0xca and 0xea tags, the card seems okay with it instead of reporting 0x6a80 as required in ETSI TS 102 226 8.2.1.3.2.2. Below you can see
ca 12 010001001505000000000000000000000000
ea 24 8008010000000000000081180001000010a0000000871002ffffffff8907090000010000
install_cap TestApplet0.cap --install-parameters-non-volatile-memory-quota 255 --install-parameters-volatile-memory-quota 255 --install-parameters-usat 8008010000000000000081180001000010a0000000871002ffffffff8907090000010000 --install-parameters-stk 010001001505000000000000000000000000*
*loading cap file: TestApplet0.cap ...*
*parameters:*
*security-domain-aid: a000000003000000*
*load-file: 5401 bytes*
*load-file-aid: f000000003*
*module-aid: f00000000300123420230709*
*application-aid: f00000000300123420230709*
*install-parameters:* *c900ef42c80200ffc70200ffca12010001001505000000000000000000000000ea248008010000000000000081180001000010a0000000871002ffffffff8907090000010000*
*step #1: install for load...*
*-> 84e602001a 05f00000000308a0000000030000000000005e92c2e27601733f00*
*<- 9000: 00*
*step #2: load...*
.
.
*Loaded a total of 5405 bytes in 23 blocks. Don't forget install_for_install (and make selectable) now!*
*step #3: install_for_install (and make selectable)...*
*-> 84e60c0072 05f0000000030cf000000003001234202307090cf00000000300123420230709010046c900ef42c80200ffc70200ffca12010001001505000000000000000000000000ea248008010000000000000081180001000010a0000000871002ffffffff890709000001000000104d95e56eb8af1600*
*<- 9000: 00*
There are a lot of ways I could be messing up here. I really don’t know what I’m doing. But just looking at the last packet in the trace, where both tags are present, I would expect to see 6A80 instead of 9000.
The test applet does seem to be loaded correctly. It responds to APDUs as expected. It just can’t access the USIM filesystem with FileView.
For posterity, I was wrong here in a fundamental way. The 0xEA tag (the “UICC” tag) is one level up in the TLV herarchy compared to the 0xCA tag (the “STK”) tag. So that’s why the card was ignoring it. You can see this clearly in GlobalPlatform table 11-49, although it is also explained in ETSI TS 102 226 if you read through all of 8.2.1.3.1 and 8.2.1.3.2.
I did hack up an –install-parameters-usat capability for pySIM while working this out, and I’ll contribute the (minor) changes for it. However, it doesn’t pass the tests yet. When I call UICCSystem.getTheFileView() it’s throwing a NO_RESOURCE SystemException. I’m still working this out.
1 Like