diff --git a/README.md b/README.md index cb3324f..2ed2cac 100644 --- a/README.md +++ b/README.md @@ -431,6 +431,10 @@ PoR confirms the card received and executed the secured packet. Two modes: Delivery PoR (SPI2 `01`) is simpler — the card returns the PoR directly in the ENVELOPE response. Submit PoR (SPI2 `21`) is used when the card cannot respond inline (e.g. during ELF operations where the ENVELOPE response space is limited). +#### SMS delivery + +A secured packet is delivered in an SMS-PP-DOWNLOAD ENVELOPE. Its size in bytes and the number of SMS it takes are shown under the packet field; a packet that does not fit one SMS is delivered as a **concatenated** SMS-PP download (TS 31.115 §4.3): the packet is split into SMS user-data parts (first SM 132 octets, following ones 134 — the first one additionally carries the concatenation and CPI information elements) and the segments are sent in order. A packet that would need more than 5 segments is refused — that is the practical limit of the card's concatenation buffer. + #### References - ETSI TS 102 225 V18.1.0: Secured packet structure for UICC based applications @@ -449,7 +453,7 @@ The RAM subtab offers two operations selected from the **Operation** dropdown: | Operation | Description | |---|---| | **Explore Card (all GP data)** | Queries GET STATUS for ISD, Applications, ELFs, and ELF Modules, plus GET DATA FF21 for memory info. Results appear in an explorer view with per-item **Delete** buttons. | -| **Install Package (.cap file)** | Sends a `.cap` file to the card via the server: INSTALL\[for load\] → LOAD ×N → INSTALL\[for install (+make selectable)\]. | +| **Install Package (.cap file)** | Sends a `.cap` file to the card via the server: INSTALL\[for load\] → LOAD ×N → INSTALL\[for install (+make selectable)\]. The load file is split into LOAD APDUs of 1–240 bytes of payload (240 by default, editable in **LOAD block size**); a secured packet larger than one SMS is delivered as a concatenated SMS-PP download of up to 5 segments. | #### Explorer View diff --git a/README_RUS.md b/README_RUS.md index 45a0a78..38ce7e9 100644 --- a/README_RUS.md +++ b/README_RUS.md @@ -405,6 +405,10 @@ PoR подтверждает, что карта получила и выполн Delivery PoR (SPI2 `01`) проще — карта возвращает PoR напрямую в ответе ENVELOPE. Submit PoR (SPI2 `21`) используется, когда карта не может ответить inline (ограничено пространство ответа ENVELOPE). +#### Доставка SMS + +Защищённый пакет доставляется в ENVELOPE SMS-PP-DOWNLOAD. Его размер в байтах и число необходимых SMS показываются под полем пакета; пакет, не помещающийся в одно SMS, доставляется **конкатенированной** SMS-PP загрузкой (TS 31.115 §4.3): пакет делится на части SMS-пользовательских данных (первое SMS 132 октета, последующие по 134 — первое дополнительно несёт информационные элементы конкатенации и CPI), и сегменты отправляются по порядку. Пакет, которому нужно больше 5 сегментов, отклоняется — это практический предел буфера конкатенации карты. + #### Ссылки - ETSI TS 102 225 V18.1.0 @@ -423,7 +427,7 @@ Delivery PoR (SPI2 `01`) проще — карта возвращает PoR на | Операция | Описание | |---|---| | **Explore Card (all GP data)** | Запрос GET STATUS для ISD, приложений, ELF и модулей ELF, а также GET DATA FF21 для информации о памяти. Результаты отображаются в обзоре с кнопками **Delete** для каждого элемента. | -| **Install Package (.cap file)** | Отправка `.cap` файла на карту через сервер: INSTALL\[for load\] → LOAD ×N → INSTALL\[for install (+make selectable)\]. | +| **Install Package (.cap file)** | Отправка `.cap` файла на карту через сервер: INSTALL\[for load\] → LOAD ×N → INSTALL\[for install (+make selectable)\]. Load-файл делится на LOAD APDU по 1–240 байт полезной нагрузки (по умолчанию 240, изменяется в **размер блока LOAD**); защищённый пакет больше одного SMS доставляется конкатенированной SMS-PP загрузкой до 5 сегментов. | #### Обзор карты (Explorer View) diff --git a/docs/api.md b/docs/api.md index 5ff5de9..a773a8e 100644 --- a/docs/api.md +++ b/docs/api.md @@ -275,8 +275,15 @@ Returns: ### `POST /api/send-ota` -Send an OTA command (SCP80) to the card via SMS-PP-DOWNLOAD ENVELOPE. -The secured packet is delivered in an SMS-DELIVER TPDU wrapped in an ENVELOPE command. +Send an OTA command (SCP80) to the card via SMS-PP-DOWNLOAD ENVELOPE +(one ENVELOPE per SMS). With `apdu` the secured packet is built +server-side (no single-SMS limit); a packet that does not fit one SMS is +sent as a **concatenated** download per TS 31.115 §4.3: the packet is +split into SMS user-data parts (first SM 132 octets, following ones 134 — +the first one additionally carries the concatenation and CPI IEs) and the +segments are sent in order. A packet that would need more than 5 segments +is refused (the card's concatenation buffer is the limit). With `sp` a +pre-built packet is delivered the same way. **Request body:** ```json @@ -296,11 +303,16 @@ The secured packet is delivered in an SMS-DELIVER TPDU wrapped in an ENVELOPE co **Response (delivery PoR):** ```json {"success": true, "sw": "9000", "response_data": "027100000e0a...", + "bytes": 36, "segments": 1, "por": {"response_status": "por_ok", "tar": "B00000", "pcntr": 0, "decoded": {"number_of_commands": 1, "last_status_word": "6e00", "last_response_data": ""}}} ``` +`bytes` is the secured packet size and `segments` the number of SMS +segments sent (1 = single SMS, >1 = concatenated download; the failure +response carries them too, plus an `error`). + **Response (submit PoR):** PoR is extracted from the SMS-SUBMIT TPDU fetched via a proactive command (FETCH). The response contains the same `por` structure if decoding succeeds. @@ -338,27 +350,28 @@ Install a Java Card `.cap` file on the card via GlobalPlatform commands (INSTALL | `stk_params` | no | Hex CA TLV (TS 102 226 §8.2.1.3.2.1) for SIM toolkit app-specific params | | `nv_quota` / `volatile_quota` | no | Integer memory quotas (bytes) for `gen_install_parameters()` | | `make_selectable` | no | If true (default), final INSTALL uses P1=`0C` (install + make selectable) | -| `load_block_size` | no | Bytes of load-file payload per LOAD APDU, 1–240. When empty/omitted the server auto-fits: the largest size whose SCP80 secured packet still encodes into one SMS (140 octets; e.g. 107 for the 3DES `spi1=16/spi2=01` configuration). An explicit value larger than the fitting size is clamped; over SCP80 the default 240 does **not** fit and used to fail with pySim's "Cannot encode command in a single SMS". | +| `load_block_size` | no | Bytes of load-file payload per LOAD APDU, 1–240 (default 240 when omitted). SCP80 concatenation carries a secured packet larger than one SMS over up to 5 SMs, so the block size is no longer clamped to fit a single SMS. | **Response (success):** ```json {"success": true, "failed_step": null, - "steps": [{"name": "install_for_load", "apdu": "80E60200...", "por_status": "por_ok", "sw": "9000"}, - {"name": "load_0", "apdu": "80E80000...", "por_status": "por_ok", "sw": "9000"}, - {"name": "install_for_install", "apdu": "80E60C00...", "por_status": "por_ok", "sw": "9000"}], + "steps": [{"name": "install_for_load", "apdu": "80E60200...", "por_status": "por_ok", "sw": "9000", "bytes": 58, "segments": 1}, + {"name": "load_0", "apdu": "80E80000...", "por_status": "por_ok", "sw": "9000", "bytes": 274, "segments": 3}, + {"name": "install_for_install", "apdu": "80E60C00...", "por_status": "por_ok", "sw": "9000", "bytes": 66, "segments": 1}], "final_cntr": "0000000004", "load_file_aid": "A000000003000000", "module_aid": "A000000003000000", "application_aid": "A000000003000000", - "load_block_size": 107, + "load_block_size": 240, "load_block_size_requested": null, - "load_block_size_clamped": false} + "load_block_size_auto": true} ``` -`load_block_size` is the effective size used for the LOAD blocks, -`load_block_size_requested` echoes an explicit `load_block_size` (null = -auto-fit) and `load_block_size_clamped` is true when the requested size was -reduced to fit one SMS. +`load_block_size` is the effective size used for the LOAD blocks (240 by +default), `load_block_size_requested` echoes an explicit `load_block_size` +(null = the default was used) and `load_block_size_auto` marks that default. +Each step reports the secured packet size `bytes` and the number of SMS +`segments` it took. **Response (failure):** ```json diff --git a/frontend/help-ru.html b/frontend/help-ru.html index 9b0dd90..106ca7c 100644 --- a/frontend/help-ru.html +++ b/frontend/help-ru.html @@ -273,7 +273,7 @@
  • AES требует счётчик с защитой от повтора: биты SPI1 b5 b4 должны быть 10 (счётчик больше) или 11 (счётчик +1) согласно TS 102 225 §5.1.2/§5.1.3.1
  • Байт паддинга настраивается (00 по умолчанию или FF)
  • -

    Кнопка Проверить в pySim сверяет собранный пакет с эталонной реализацией OtaDialectSms.encode_cmd. Кнопка Отправить на карту доставляет пакет через ENVELOPE SMS-PP-DOWNLOAD (при подключении к серверу). Полученный Proof of Receipt декодируется и показывается строкой статуса PoR (статус, TAR, счётчик, сырой PoR); статусное слово и данные ответа последней команды подставляются в подвкладку «Парсер ответов» (Remote APDU), а успешный PoR увеличивает счётчик повторов и очищает пакет.

    +

    Кнопка Проверить в pySim сверяет собранный пакет с эталонной реализацией OtaDialectSms.encode_cmd. Кнопка Отправить на карту доставляет пакет через ENVELOPE SMS-PP-DOWNLOAD (при подключении к серверу). Под полем пакета показывается его размер и число SMS; пакет, не помещающийся в одно SMS, отправляется конкатенированной загрузкой (TS 31.115 §4.3) — пакет делится на части SMS-пользовательских данных (первое SMS 132 октета, последующие по 134; первое дополнительно несёт информационные элементы конкатенации и CPI), и сегменты отправляются по порядку. Более 5 сегментов отклоняется: это практический предел буфера конкатенации карты. Полученный Proof of Receipt декодируется и показывается строкой статуса PoR (статус, TAR, счётчик, сырой PoR); статусное слово и данные ответа последней команды подставляются в подвкладку «Парсер ответов» (Remote APDU), а успешный PoR увеличивает счётчик повторов и очищает пакет.

    3.2 RAM

    Выполняет операции удалённого управления приложениями (Remote Application Management) как защищённые пакеты SCP80 через SMS-PP-DOWNLOAD ENVELOPE. Карта должна поддерживать SCP03 (AES или 3DES). Предустановка карты со вкладки Карты обеспечивает SPI, ключи, TAR и счётчик (RAM использует ISD TAR предустановки, по умолчанию 000000).

    @@ -283,7 +283,7 @@ ОперацияОписание Обзор карты (все данные GP)Запрос GET STATUS для ISD, приложений, ELF и модулей ELF, а также GET DATA FF21 для информации о памяти. Результаты отображаются в обзоре с кнопками Удалить для каждого элемента. - Установка пакета (.cap файл)Отправка .cap файла на карту через сервер: INSTALL[for load] → LOAD ×N → INSTALL[for install (+make selectable)]. Load-файл делится на LOAD APDU, каждый из которых помещается в один SMS SCP80; поле размер блока LOAD переопределяет авто-подобранный размер (пусто = максимальный размер, чей secured-пакет укладывается в 140 октетов), так что большой .cap просто занимает несколько SMS. + Установка пакета (.cap файл)Отправка .cap файла на карту через сервер: INSTALL[for load] → LOAD ×N → INSTALL[for install (+make selectable)]. Load-файл делится на LOAD APDU размера размер блока LOAD (1–240 байт полезной нагрузки, по умолчанию 240); каждый защищённый пакет доставляется одним SMS или, если он больше, конкатенированной SMS-PP загрузкой до 5 сегментов, так что большой .cap просто занимает несколько SMS. diff --git a/frontend/help.html b/frontend/help.html index 3c68337..3884861 100644 --- a/frontend/help.html +++ b/frontend/help.html @@ -273,7 +273,7 @@
  • AES requires a replay-protected counter: SPI1 bits b5 b4 must be 10 (counter higher) or 11 (counter +1) per TS 102 225 §5.1.2/§5.1.3.1
  • Padding byte configurable (00 default, or FF)
  • -

    A “Verify vs pySim” button cross-checks the assembled packet against pySim’s reference OtaDialectSms.encode_cmd. A “Send to Card” button delivers it via SMS-PP-DOWNLOAD ENVELOPE (when connected to the server). The returned Proof of Receipt is decoded and shown as a PoR status line (status, TAR, counter, raw PoR); the last command’s status word and response data are filled into the Response parser tab, and a successful PoR advances the replay counter and clears the packet.

    +

    A “Verify vs pySim” button cross-checks the assembled packet against pySim’s reference OtaDialectSms.encode_cmd. A “Send to Card” button delivers it via SMS-PP-DOWNLOAD ENVELOPE (when connected to the server). Under the packet field the app reports its size and how many SMS it takes; a packet that does not fit one SMS is sent as a concatenated download (TS 31.115 §4.3) — the packet is split into SMS user-data parts (first SM 132 octets, following ones 134; the first one additionally carries the concatenation and CPI information elements) and the segments are sent in order. More than 5 segments is refused, that being the practical limit of the card’s concatenation buffer. The returned Proof of Receipt is decoded and shown as a PoR status line (status, TAR, counter, raw PoR); the last command’s status word and response data are filled into the Response parser tab, and a successful PoR advances the replay counter and clears the packet.

    3.2 RAM

    Delivers Remote Application Management operations as SCP80 secured packets via SMS-PP-DOWNLOAD ENVELOPE. The card must support SCP03 (AES or 3DES). A saved card preset from the Cards tab provides the SPI, keys, TAR, and counter (RAM uses the preset's ISD TAR, 000000 by default).

    @@ -283,7 +283,7 @@ OperationDescription Explore Card (all GP data)Queries GET STATUS for ISD, Applications, ELFs, and ELF Modules, plus GET DATA FF21 for memory info. Results appear in an explorer view with per-item Delete buttons. - Install Package (.cap file)Sends a .cap file to the card via the server: INSTALL[for load] → LOAD ×N → INSTALL[for install (+make selectable)]. The load file is split into LOAD APDUs that each fit one SCP80 SMS; the LOAD block size field overrides the auto-fitted size (empty = largest size whose secured packet still encodes into 140 octets), so a large .cap simply takes several SMS. + Install Package (.cap file)Sends a .cap file to the card via the server: INSTALL[for load] → LOAD ×N → INSTALL[for install (+make selectable)]. The load file is split into LOAD APDUs of the LOAD block size (1–240 bytes of payload, 240 by default); each secured packet is delivered as a single SMS or, when larger, as a concatenated SMS-PP download of up to 5 segments, so a large .cap simply takes several SMS. diff --git a/frontend/index.html b/frontend/index.html index 4a233b0..7e70899 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -550,6 +550,7 @@ +
    @@ -693,9 +694,9 @@ - - -
    Splits the load file into LOAD APDUs that fit one SCP80 SMS; auto-fit picks the largest size that encodes into 140 octets.
    + + +
    Splits the load file into LOAD APDUs (1-240 bytes of payload). A secured packet larger than one SMS is sent as a concatenated SMS-PP download (up to 5 SMs).