How to read EF-DIR using Linux QMI SDK api function

Is it possible to read the EF-DIR file (part of a USIM file system) using a Linux QMI SDK API?

I am able to access ‘Transparent files’ (e.g. MF->EF-ICCID, MF->DF-GSM->IMSI) using the SLQSUIMReadTransparent() API, but this does not seem to work for accessing EF-DIR.

According to ETSI TS 102 221, EF-DIR is a mandatory file, so it should be present on the USIM, though it does state that it is a ‘Linear fixed’ file, as opposed to a ‘Transparent file’.

Should I be using a different API?

Were you able to read the file with AT command (AT+CRSM)?

Hi ajoseph

I have to admit I hadn’t tried, as I was concentrated on using the SLQS SDK, but good suggestion.

I’ve tried it this morning and it seems to work:

at+crsm=178,12032,1,4,0
;178 for read record
;12032 = EF-DIR = 2F00
;P1 = 1 = record number 1
;P2 = 4 = current mode
;P3 = 0 = any read length
Response:
+CRSM: 144,0,"61184F10A0000000871002FF44FF12890000010050045553494DFFFFFFFFFFFFF"

It seems that there isn’t an API within the SLQS SDK that supports reading ‘linear’ SIM files?

I seem to be able to access EF-DIR using read-transparent with libqmi with an EM7455. So I believe this should work with the QMI SDK and SLQSUIMReadTransparent too

# qmicli -p  --device-open-mbim -d /dev/cdc-wdm0  --uim-read-transparent=0x3F00,0x2F00
[/dev/cdc-wdm0] Successfully read information from the UIM:
Card result:
        SW1: '0x90'
        SW2: '0x00'
Read result:
        61:1C:4F:0C:A0:00:00:00:87:10:02:FF:49:FF:05:89:50:0C:54:65:6C:65:6E:6F:72:20:
        55:53:49:4D:FF:FF:FF:FF:FF:FF:FF

I’ve tried again this morning but without success! Here’s what I’ve tried:

ULONG slqsRetCode;
int err = 0;
UIMReadTransparentReq  UIMReadTransReq;
UIMReadTransparentResp UIMReadTransResp;
cardResult   CardResult;
readResult   ReadResult;
ULONG        IndicationToken;
BYTE         EncryptedData;

//Initialise API
UIMReadTransReq.sessionInfo = (UIMSessionInformation){ 0x00, 0x01, "1" };
UIMReadTransReq.fileIndex   = (fileInfo){ 0x2F00, 0x02, {0x3F00} };
UIMReadTransReq.readTransparent = (readTransparentInfo){ 0, 0 };
UIMReadTransReq.pEncryptData     = NULL;
UIMReadTransReq.pIndicationToken = NULL;
UIMReadTransResp.pCardResult      = &CardResult;
UIMReadTransResp.pEncryptedData   = &EncryptedData;
UIMReadTransResp.pIndicationToken = &IndicationToken;
UIMReadTransResp.pReadResult      = &ReadResult;

//..call the API
slqsRetCode = SLQSUIMReadTransparent( &UIMReadTransReq, &UIMReadTransResp );
if (slqsRetCode != eQCWWAN_ERR_NONE) {
  printf("[SLQS] %s -> Failed to get UIM-DIR %d\n", __func__, slqsRetCode);
  err = 1;
}

With the above I get error code 1003 “Unexpected error occurred during processing”.

Strange. I cannot test your code right now, but it looks correct to me when comparing it with the example in SampleApps/Connection_Manager/src/connectionmgr.c

I should have mentioned that I can successfully access other files on the SIM using the same API…

e.g. EF-UICC using:

//..initialise API
UIMReadTransReq.sessionInfo = (UIMSessionInformation){ 0x00, 0x01, "1" };
UIMReadTransReq.fileIndex   = (fileInfo){ 0x2FE2, 0x02, {0x3F00} };
UIMReadTransReq.readTransparent = (readTransparentInfo){ 0, 0 };
UIMReadTransReq.pEncryptData     = NULL;
UIMReadTransReq.pIndicationToken = NULL;
UIMReadTransResp.pCardResult      = &CardResult;
UIMReadTransResp.pEncryptedData   = &EncryptedData;
UIMReadTransResp.pIndicationToken = &IndicationToken;
UIMReadTransResp.pReadResult      = &ReadResult;

//..call the API
slqsRetCode = SLQSUIMReadTransparent( &UIMReadTransReq, &UIMReadTransResp );
if (slqsRetCode != eQCWWAN_ERR_NONE) {
  printf("[SLQS] %s -> Failed to get ICCID %d\n", __func__, slqsRetCode);
  err = 1;
}

It appears to be just EF-DIR that fails. I’ve tried a few different SIM cards from various MNO, but all fail.

When I use AT+CRSM to successfully read EF-DIR I have to perform ‘178’ = ‘read record’. Using AT+CRSM to read other SIM files e.g. EF-UICC (2FE2) then I have to use ‘176’ = ‘read binary’.

But there doesn’t seem to be any way of ‘telling’ the SLQSUIMReadTransparent() whether to perform a ‘record’ read or a ‘binary’ read ???

Hi,

since EF-DIR is of type linear fixed it should be read with ‘READ RECORD’ for portability. The Gobi API and libqmi provide a specific UIMReadRecord method for this which maps to a different T0 APDU. If the Linux QMI SDK does not provide a corresponding SLQUIMReadRecord() API function you would have to open a feature request with Sierra Wireless.

Regards,
Reinhard

Hi rspmn

That fully answers my question.
I’ve checked the Sierra Wireless QMI SDK and it doesn’t provide a ‘SLQS UIM ReadRecord’ API function.

Many thanks,
dh29