SimProbe

Debugging SIM OTA failures in SMS-PP and PoR

Why a SIM OTA campaign fails silently or returns a PoR error: TP-PID/DCS, EF_UST, TAR, counters, MSL, and a byte-level command packet and PoR decode.

  • IDNTEQ
  • Classic SIM
  • OTA
  • SMS-PP
  • PoR
  • ETSI TS 102 225
  • 3GPP TS 31.115

If no Proof of Receipt (PoR) arrives, the command may not have reached the OTA application, or authentication may have failed (3GPP TS 31.115 §4). Identify where processing stopped before checking keys. A non-zero PoR status reports a packet-level condition; with PoR 00, check the remote command result too. (ETSI TS 102 225 §5.2; ETSI TS 102 226 §5.1.2.)

To follow a command packet and its PoR through every step, from the OTA server to the file on the card, see the interactive SIM OTA walkthrough.

Find where message processing stopped

An SMSC delivery acknowledgement does not mean the update ran. For SMS-PP DOWNLOAD, the handset (ME) sends RP-ACK when the card answers ENVELOPE with 90 00, 62 XX, 63 XX or 6F XX. Any response data accompanies that acknowledgement. (TS 31.111 §7.1.1.1.)

What you seePossible stopping pointWhat to check firstSpec
Message displayed or stored as an ordinary SMSHandset routingTP-PID and TP-DCSTS 23.040 §9.2.3.9
Delivered, no PoR, UST service 28 unavailableStorage in EF_SMSService bit and ENVELOPE traceTS 31.111 §7.1.1.1
Delivered, no PoR after authentication failureCard security processingKey version, algorithm and packet bytesTS 31.115 §4.2
RP-ERROR with TP-FCS D4Toolkit busyENVELOPE response 93 00 and retry handlingTS 31.111 §7.1.1.1; TS 23.040 §9.2.3.22
PoR status other than 00Packet processing or response deliveryStatus table belowTS 102 225 Table 5; TS 31.115 §7
PoR 00, command error in additional dataRemote APDU executionCommand count and last status wordTS 102 226 Table 5.1

Check TP-PID, TP-DCS and EF_UST service 28

For this SMS-PP path, TP-PID is 7F and TP-DCS specifies class 2. With a different class, the ME handles the message normally. Compare the platform configuration with the received TPDU. TS 23.040 §9.2.3.9 also notes that pre-Release-5 MEs may accept only F6 or 16 for this download.

Both values specify 8-bit, class-2 data. Using the bit numbering in TS 23.038 §4, F6 = 1111 0110 selects group 1111, bit 2 selects 8-bit data and bits 1–0 select class 2. For 16 = 0001 0110, group 00xx applies: bit 5 says uncompressed, bit 4 makes the class meaningful, bits 3–2 are 01 for 8-bit data, and bits 1–0 are 10 for class 2.

On a USIM, check EF_UST (6F38), service 28, data download via SMS-PP. It is byte 4, bit b4, mask 08; a set bit means available. The file-system reference includes EF_UST. (TS 31.102 §4.2.8.)

When that service is available, the ME passes the message through ENVELOPE (SMS-PP DOWNLOAD), BER tag D1. If unavailable, the ME stores it in EF_SMS instead of invoking SMS-PP DOWNLOAD. The bytes can therefore reach card storage without reaching OTA processing. If ENVELOPE returns 93 00, the ME retries or sends RP-ERROR with TP-FCS D4, toolkit busy. (TS 31.111 §7.1.1.1; TS 101 220 Table 7.17; TS 23.040 §9.2.3.22.)

Check the command packet fields, lengths and padding

Set UDHI and use 8-bit data. With no other UDH elements, the user data starts 02 70 00: UDHL 02, command-packet IEI 70, IE data length 00. CPL follows in two bytes, then CHL in one byte; neither length uses BER-TLV encoding here. The remaining fields are SPI, KIc, KID, TAR, CNTR, PCNTR, RC/CC/DS and application data. (TS 31.115 §§4.1–4.2; TS 102 225 §5.1.)

SPI is the Security Parameters Indication. RC is a redundancy check, CC a cryptographic checksum and DS a digital signature. The bit map below uses b1 for the least significant bit. (TS 102 225 §5.1.1; TS 31.115 §4.2.)

Octet and bitsCoding
SPI1 b2b100 none; 01 RC; 10 CC; 11 reserved for DS
SPI1 b30 unciphered; 1 ciphered
SPI1 b5b400 no counter; 01 counter unchecked; 10 higher; 11 exactly one higher
SPI1 b8–b6Reserved, set to zero
SPI2 b2b100 no PoR; 01 PoR required; 10 on error only; 11 reserved
SPI2 b4b300 no check; 01 RC; 10 CC; 11 reserved for DS
SPI2 b50 plaintext PoR; 1 ciphered PoR
SPI2 b60 SMS-DELIVER-REPORT; 1 SMS-SUBMIT
SPI2 b8–b7Reserved, set to zero

The example uses compact ADF Remote File Management (RFM) to clear a 12-byte EF_FPLMN. Assume TAR B0 00 01 is assigned to the USIM’s ADF RFM application, with sufficient access rights. The ADF is implicitly selected at session start without Script Chaining. EF_FPLMN (6F7B) has length 3n, n ≥ 4, and unused bytes are FF; a larger file needs a longer update to clear it fully. (TS 102 226 §§6.2, 7.3; TS 101 220 Annex D; TS 31.102 §4.2.16.)

00 A4 00 0C 02 6F 7B
00 D6 00 00 0C FF FF FF FF FF FF FF FF FF FF FF FF

The seven-byte SELECT chooses 6F7B by FID and requests no response data. UPDATE BINARY is 17 bytes: five header bytes and twelve FF bytes, starting at offset zero. Together they occupy 24 bytes. These are compact T=0 command forms. (TS 102 226 §5.1.1; TS 102 221 §§11.1.1, 11.1.4.) EF_FPLMN is also in the file-system reference.

FieldValueInterpretation
SPI16 01CC, ciphering, higher counter; plaintext PoR in DELIVER-REPORT without RC/CC/DS
KIc15Two-key triple DES, key version 1
KID15Two-key triple DES for CC, key version 1
TARB0 00 01Compact ADF RFM
CNTR00 00 00 00 05Sent counter value 5

KIc and KID use the coding in TS 102 225 §§5.1.2–5.1.3.1 and Annex A.2 for a GlobalPlatform security domain. SPI2 01 is used here to make the response readable; it supplies no cryptographic authentication of the PoR. The example shows the packet layout only, without keys or a computed CC.

Before ciphering, the protected portion is CNTR (5 bytes), PCNTR (1), <CC, 8 bytes> and the script (24): 38 bytes. Two padding bytes bring it to 40, a multiple of eight, so PCNTR is 02. CHL is 2 + 1 + 1 + 3 + 5 + 1 + 8 = 21, hex 15. CPL counts the CHL byte plus header, script and padding: 1 + 21 + 24 + 2 = 48, hex 0030. (TS 102 225 §5.1.)

The transmitted TP-UD is 02 70 00 00 30 15 16 01 15 15 B0 00 01 followed by 40 ciphered bytes. TP-UDL is 3 + 2 + 48 = 53, hex 35; TP-PID is 7F and TP-DCS is F6. Compute the CC before ciphering. CPL and CHL participate in the checksum but remain plaintext. (TS 102 225 §5.1; TS 31.115 §4.2.)

For larger packets, respect the 140-octet SMS user-data limit, including UDH overhead. Concatenation carries CPI, CPL and the command header only in the first segment. An unrecognisable command header is discarded without further action. (TS 23.038 §4; TS 31.115 §4.3; TS 102 225 §4.1 item 5.)

Failures the card reports in the PoR

Decode the PoR byte by byte

The response below uses the example’s plaintext, unchecked PoR setting. Vertical bars separate fields; the second line shows a counter rejection.

02 71 00 | 00 0E | 0A | B0 00 01 | 00 00 00 00 05 | 00 | 00 | 02 90 00
02 71 00 | 00 0B | 0A | B0 00 01 | 00 00 00 00 05 | 00 | 02

The fields are UDH, RPL, RHL, TAR, CNTR, PCNTR, status and optional additional data. 02 71 00 identifies the response packet. RHL counts 3 + 5 + 1 + 1 = 10 bytes (0A). In the first line, status 00 is PoR OK and additional data 02 90 00 reports two commands executed with last status 90 00. RPL is 1 + 10 + 3 = 14 (000E). (TS 31.115 §4.4; TS 102 225 §5.2; TS 102 226 Table 5.1.)

The second line reports CNTR low, status 02. There is no additional data for a standardized non-zero status, so RPL is 1 + 10 = 11 (000B). The counter still copies the sent value 0000000005. (TS 102 225 §5.2.)

For a UICC response in SMS-DELIVER-REPORT, the ME cannot be told to set UDHI. TS 31.115 §4.1 requires the sending entity to treat the response as though UDHI were set. A parser that skips UDH parsing because the bit is clear will decode these bytes at the wrong offsets.

Status codes and the next check

The meanings follow TS 102 225 Table 5, with the SMS-specific extension from TS 31.115 §7. Start with the check in the last column.

CodeMeaningCampaign condition to investigateWhat to check
00PoR OKRemote command may still have failedAdditional response data
01RC/CC/DS failedPacket check failedCovered bytes and KID; SMS-PP authentication failures can be silent
02CNTR lowCounter does not advance the stored valueDuplicate send or stale counter on the sending entity
03CNTR highGap under the exactly-one-higher ruleSPI1 b5b4 and send sequence
04CNTR blockedCounter reached its maximumIssuer’s counter/key management procedure
05Ciphering errorCiphering could not be processedKIc, algorithm and ciphered length
06Unidentified security errorHeader/security parameters cannot be interpretedField coding and non-zero key versions; Table 5 specifies an unsecured response
07Insufficient memoryIncoming message cannot be processed in available memoryPacket size and card resources
08More timeProcessing exceeds the response timingLater response; do not count this as completion
09TAR unknownTarget reference is not recognisedProvisioned TAR; for applets, INSTALL parameters (TS 102 226 §8.2.1.3.2.2.1)
0AInsufficient security levelPacket falls below application MSLRequired security settings
0BReserved for 3GPPActual response follows by SMS-SUBMITReturn SMS path (TS 31.115 §§4.1, 7)
0CReserved for 3GPPDefined for another bearerCheck transport and decoding against TS 31.115 §7

Check counter progression for statuses 02, 03 and 04

SPI1 b5b4 10 accepts a higher counter; 11 requires exactly one higher. Resending value 5 after it was accepted fails the example’s 10 check. The sending entity sets and increments CNTR. The receiving entity adopts the incoming value after RC/CC/DS and counter checks pass; reaching the maximum blocks the counter. (TS 102 225 §§5.1.1, 5.1.4.)

The PoR’s CNTR is copied from the command, so it cannot reveal the card’s stored value. For cards using the GlobalPlatform security architecture, each security domain has a counter per key version 01–0F. If two platforms or a test bench share that key version, compare their send histories: §5.1.4 requires synchronization across sending entities. (TS 102 225 §5.2, Annex A.1.)

Compare SPI1 with the installed MSL for status 0A

An application’s Minimum Security Level can be set at INSTALL [for install]. The card checks MSL before processing the packet’s security. Parameter 01, Minimum SPI1, contains one data byte; the check compares its integrity, ciphering and counter fields with SPI1 separately. RAM requires at least CC or DS integrity protection. Compare those fields with the installed MSL before changing keys. (TS 102 226 §§6.1, 8.0, 8.2.1.3.2.4.)

No PoR even though one was requested

Over SMS-PP, a card that cannot authenticate the sending entity discards the command and sends no response packet. This includes authentication failures caused by a wrong key, key version or algorithm, so do not wait for status 01 to confirm the failure. (TS 31.115 §4.2; TS 31.111 §7.1.1.1.) The “Wrong KID key” and “Unknown TAR” scenarios of the SIM OTA walkthrough show this byte by byte.

Check SPI2 too. If b4b3 requests RC or CC, it must match SPI1 b2b1. A ciphered response is allowed only after successful command authentication and only when the command was ciphered. If either requirement is violated, the card discards the command and sends no response packet. For GlobalPlatform cards, different non-zero KIc and KID key versions cause rejection as an unidentified security error. Annex A.2 requires matching version nibbles; the algorithm nibbles describe their respective keys. (TS 102 225 §5.1.1, Annex A.2.)

Then check where the response should arrive. SPI2 b6 0 selects SMS-DELIVER-REPORT; 1 selects SMS-SUBMIT through the proactive SEND SHORT MESSAGE command. If a requested DELIVER-REPORT cannot hold the response, the card returns 0B without additional data, then sends the complete response by SMS-SUBMIT. (TS 31.115 §§4.1–4.2, 4.4, 7.)

OTA platform consulting by IDNTEQ includes SMSC integration and PoR troubleshooting.

PoR OK but the file did not change

Table 5.1 defines compact additional response data as the command count, the last executed command’s status word and any returned data. An error in SW1 stops the script; warnings do not. Replacing 02 90 00 with 02 69 82 in the example leaves PoR status 00 and reports that the second command was refused. (TS 102 226 §4 item 3, §5.1.2.)

Paste 00D600000CFFFFFFFFFFFFFFFFFFFFFFFF into the APDU decoder with status 6982. That status means the security condition was not satisfied; it can also mean the card could not determine the file’s access condition. For RFM, inspect the application’s access domain, whose rights are independent of PIN status at the terminal. (TS 102 221 §9.2.0, Table 10.13; TS 102 226 §6.2.)

For a compact script that reads data, the case-2 command must come last. P3 00 requests all available data; 62 F1 in this remote response means truncation, with the remaining bytes lost. (TS 102 226 §5.1.1.)

Check the TAR-to-ADF assignment before reading the file back. ADF RFM starts in its associated ADF without Script Chaining; shared-file-system RFM starts at MF and cannot access an ADF. RFM cannot SELECT by DF name (P1=04). Compact and expanded scripts use different TARs unless automatic format detection is configured. (TS 102 226 §§7.0–7.3.)

These allocations come from TS 101 220 Annex D, Table D.1. A TAR being allocated does not mean a given card implements that application.

ApplicationCompact TARsExpanded or automatic-detection TARs
Issuer Security Domain (RAM)00 00 00B2 01 00
UICC shared-file-system RFMB0 00 00, B0 00 02–B0 00 0FB0 01 20–B0 01 2F
SIM-file-system RFMB0 00 10–B0 00 1FB0 01 30–B0 01 3F
ADF RFMB0 00 01, B0 00 20–B0 01 1FB0 01 40–B0 01 FF

Related

The tool this article refers to, and the related consulting service.