Long instruction processing method and device, equipment, medium and product
By using a long instruction processing module and card application that work collaboratively between the terminal device and the SIM card, long instruction processing of the SIM card in T0 transmission mode is realized, solving the problem that the SIM card cannot handle instructions exceeding 256 bytes, and improving the compatibility and efficiency of the SIM card.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-15
- Publication Date
- 2026-04-07
AI Technical Summary
In existing technologies, SIM cards cannot process long instructions exceeding 256 bytes in T0 transmission mode, making them incompatible with card applications that require long instruction interactions.
By splitting and encapsulating long commands in the long command processing module on the terminal device side, and then splicing them together in the long command processing card application on the SIM card side, the complete transmission of long commands can be achieved.
It enables the complete transmission of long commands by the SIM card in T0 transmission mode, solves the problem that the SIM card cannot handle long commands in T0 mode, and improves the compatibility and efficiency of the SIM card.
Smart Images

Figure CN121815242A_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of secure communication technology, and in particular to a method, apparatus, device, medium, and product for processing long instructions. Background Technology
[0002] A SIM (Subscriber Identity Module) card is a smart card with a built-in integrated circuit chip. Its core functions are to identify mobile users, store user information, and encrypt communications. As a critical national information security carrier in the digital economy era, the SIM card provides fundamental support and protection for information security across various industries. It is widely used in scenarios such as digital identity, digital RMB, public transportation cards, campus cards, and access control, providing users with functions such as identity authentication, digital signatures, encryption / decryption, and dynamic passwords. These scenarios all require the SIM card to interact with external devices, such as mobile phones and card readers, involving the transmission of APDU (Application Protocol Data Unit) commands.
[0003] APDU is the command unit used for interaction between external devices and the SIM card. The external device sends commands to the card via C-APDU (Command Application Protocol Data Unit). Upon receiving the command, the card performs corresponding operations and returns the results to the external device via R-APDU (Response Application Protocol Data Unit). According to the ISO 7816 standard, SIM cards use two transmission modes: T=0 and T=1. T0 mode transmits data in character units, while T1 mode transmits data in data blocks. T0 mode requires converting APDUs to TPDU (Transfer Protocol Data Unit) format, while T1 mode only requires placing the APDU in the information field of the data frame without format conversion.
[0004] In current technology, long command (data field length greater than 255 bytes) transmission in T0 mode presents several problems: During APDU format conversion, the TPDU commands are identical in both 2S and 2E.2 cases, making it impossible for the transport layer to differentiate them; if the transport layer does not support the envelope command, long commands cannot be sent in 3E.2 and 4E.2 cases; and the padding alignment method used by card applications introduces a large amount of redundant information. Furthermore, many SIM cards only support T0 mode, which cannot meet the demands of real-world applications such as smart keys and quantum messaging for long commands. Summary of the Invention
[0005] To address the aforementioned technical problems, this disclosure provides a method, apparatus, device, medium, and product for processing long commands, thus resolving the issue of long command transmission in SIM cards under T0 transmission mode.
[0006] A first aspect of this disclosure provides a method for long instruction processing, which is collaboratively implemented by a long instruction processing card application running on a SIM card and a terminal-side long instruction processing module deployed on a terminal device. The method includes: The terminal-side long command processing module splits the long command received from the terminal device APP into short command segments, and encapsulates the short command segments into encapsulated commands and sends them to the target card application running on the SIM card; The long instruction processing card application receives the encapsulation instruction forwarded by the target card application, concatenates the encapsulation instruction into a long command instruction, and sends it to the target card application; Long instruction processing card applications split long response instructions generated by the target card application into short data segments; In response to the pull information sent by the terminal-side long command processing module, the long command processing card application sends all short data segments to the terminal-side long command processing module; The terminal-side long command processing module concatenates all short data segments into a response long command and returns the response long command to the terminal device APP.
[0007] A second aspect of this disclosure provides a long instruction processing method applied to a SIM card, wherein the SIM card runs a long instruction processing card application, the method comprising: The target card application running on the SIM card receives the encapsulation instruction sent by the terminal-side long instruction processing module. The encapsulation instruction is obtained by the terminal-side long instruction processing module splitting the long command received from the terminal device APP into short instruction segments and encapsulating the short instruction segments. The long instruction processing card application receives the encapsulation instruction forwarded by the target card application, concatenates the encapsulation instruction into a long command instruction, and sends it to the target card application; Long instruction processing card applications split long response instructions generated by the target card application into short data segments; In response to the pull request sent by the terminal-side long command processing module, the long command processing card application sends all short data segments to the terminal-side long command processing module.
[0008] A third aspect of this disclosure provides a method for processing long instructions, applied to a terminal device, wherein the terminal device has a terminal-side long instruction processing module deployed thereon, the method comprising: The terminal-side long command processing module splits the long command received from the terminal device APP into short command segments, encapsulates them into encapsulated commands, and sends them to the target card application running on the SIM card. The terminal-side long command processing module sends a pull message to the long command processing card application to obtain all short data segments; The terminal-side long command processing module concatenates all short data segments into a response long command and returns the response long command to the terminal device APP.
[0009] A fourth aspect of this disclosure provides a long instruction processing apparatus for a SIM card, the apparatus comprising: The receiving module is configured to run on the SIM card to receive encapsulation instructions sent by the terminal-side long instruction processing module. The encapsulation instructions are obtained by the terminal-side long instruction processing module splitting the long command received from the terminal device APP into short instruction segments and encapsulating the short instruction segments. The splicing module is configured to receive the encapsulated instructions forwarded by the target card application from the long instruction processing card application, splice the encapsulated instructions into a long command instruction, and send it to the target card application. The splitting module is configured to allow the long instruction processing card application to split the long response instruction generated by the target card application into short data segments. The response module is configured to respond to pull information sent by the terminal-side long command processing module. The long command processing card application sends all short data segments to the terminal-side long command processing module.
[0010] A fifth aspect of this disclosure provides a long instruction processing apparatus applied to a terminal device, the apparatus comprising: The encapsulation module is configured to split long command received from the terminal device APP into short command segments and encapsulate them into encapsulated commands to be sent to the target card application running on the SIM card. The sending module is configured to send pull information from the terminal-side long command processing module to the long command processing card application to obtain all short data segments; The recovery module is configured as a long command processing module on the terminal side to concatenate all short data segments into a long response command and return the long response command to the terminal device APP.
[0011] A sixth aspect of this disclosure provides an electronic device, including: At least one processor; Memory for storing the at least one processor-executable instruction; The at least one processor is used to execute the instructions to implement the above-described method.
[0012] A seventh aspect of this disclosure provides a computer-readable storage medium that, when instructions in the computer-readable storage medium are executed by a processor of an electronic device, enables the electronic device to perform the method described above.
[0013] An eighth aspect of this disclosure provides a computer program product including a computer program that, when executed by a processor, implements the steps of the long instruction processing method described above.
[0014] The above-mentioned at least one technical solution adopted in the embodiments of this disclosure can achieve the following beneficial effects: In view of the problem that the SIM card in the T0 transmission mode is limited by the protocol in the prior art and cannot directly process long instructions exceeding 256 bytes, resulting in the incompatibility of card applications that require long instruction interaction on the T0 card, the embodiments of this disclosure combine the long instruction processing card application and the terminal-side long instruction processing module. By splitting the long instruction in the terminal-side long instruction processing module on the terminal device side and then splicing and restoring it in the card-side long instruction processing card application, the complete transmission of long instructions by the SIM card in the T0 transmission mode is realized. Attached Figure Description
[0015] The accompanying drawings, which are incorporated in and form a part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure.
[0016] To more clearly illustrate the technical solutions in the embodiments of this disclosure or the prior art, the accompanying drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0017] Figure 1 A schematic diagram of a system architecture for long instruction processing provided in an embodiment of this disclosure; Figure 2 This is a schematic flowchart of a long instruction processing method provided in an embodiment of the present disclosure; Figure 3 This is a schematic flowchart of a method for processing long instructions applied to a SIM card, provided by an embodiment of the present disclosure. Figure 4 This is a schematic flowchart of a method for processing long instructions applied to a terminal device, provided by an embodiment of the present disclosure. Figure 5 A flowchart illustrating another long command processing method provided in this embodiment of the present disclosure; Figure 6 A flowchart illustrating a method for handling long commands provided in an embodiment of this disclosure; Figure 7A schematic diagram of a device for long instruction processing applied to a SIM card, provided in an embodiment of this disclosure; Figure 8 This disclosure provides a schematic diagram of the structure of a device for long instruction processing applied to a terminal; Figure 9 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present disclosure; Figure 10 This is a schematic diagram of the structure of an exemplary computer system provided in an embodiment of the present disclosure. Detailed Implementation
[0018] To better understand the above-mentioned objectives, features, and advantages of this disclosure, the solutions disclosed herein will be further described below. It should be noted that, unless otherwise specified, the embodiments and features described herein can be combined with each other.
[0019] Numerous specific details are set forth in the following description in order to provide a full understanding of this disclosure, but this disclosure may also be implemented in other ways different from those described herein; obviously, the embodiments in the specification are only some, and not all, of the embodiments of this disclosure.
[0020] It should be understood that the steps described in the method embodiments of this disclosure may be performed in different orders and / or in parallel. Furthermore, the method embodiments may include additional steps and / or omit the steps shown. The scope of this disclosure is not limited in this respect.
[0021] It should be noted that the concepts of "first" and "second" mentioned in this disclosure are used only to distinguish different devices, modules or units, and are not used to limit the order of functions performed by these devices, modules or units or their interdependencies.
[0022] It should be noted that the terms "a" and "a plurality of" used in this disclosure are illustrative rather than restrictive, and those skilled in the art should understand that, unless otherwise expressly indicated in the context, they should be understood as "one or more".
[0023] The following is combined Figures 1-10 The present disclosure describes the methods, apparatus, devices, media, and products for long instruction processing provided in the embodiments of this disclosure.
[0024] Figure 1 This is a schematic diagram of a system architecture for long instruction processing provided by an embodiment of the present disclosure. For ease of explanation, only the parts related to the embodiments of the present disclosure are shown.
[0025] like Figure 1As shown, the long command processing system 100 includes a SIM card 101 and a terminal device 102. A long command processing card application 1011 runs on the SIM card, and a terminal-side long command processing module 1021 is deployed on the terminal device. Long command processing card application 1011 is an SIO (ShareableInterface Object) object that implements the Shareable interface. Its function is to provide command concatenation and splitting functionality for other ordinary SIM card applications. It implements the Shareable interface, which defines two methods: processEnvelope(APDU apdu) and response(APDU apdu). The processEnvelope method concatenates and decompresses the data fields in short commands. The response method compresses and splits long commands. The long command processing card application returns its own proxy application object to the target card application via the getShareableInterfaceObject(AID clientAID, byte param) method.
[0026] The SIO object within the SIM card provides long command concatenation, splitting, compression / decompression services for other applications within the SIM card. It is specifically designed to help other ordinary card applications (such as SIM Shield application and quantum communication application) handle long commands. It encapsulates the complex command concatenation / splitting, compression / decompression logic, so other applications do not need to develop it themselves and can directly call it.
[0027] Regular SIM card applications: All SIM card applications except for "long command processing card applications" (such as SIM shield application, quantum communication application, quick authentication application).
[0028] Terminal-side long instruction processing module 1021: A "long instruction processing toolkit" on the terminal side, providing terminal device APP with instruction compression, decompression, splicing and splitting functions, and is compatible with Android / Windows systems.
[0029] For example, the terminal-side long instruction processing module 1021 is a long instruction processing SDK (Software Development Kit) running on a mobile phone or a DLL (Dynamic Link Library) running on a Windows computer.
[0030] Terminal device APP: The service initiator is the application directly operated by the user (such as SIM Shield APP, quantum communication service APP), which needs to interact with the SIM card with long commands.
[0031] Figure 2 This is a flowchart illustrating a method for processing long instructions according to an embodiment of the present disclosure, as shown below. Figure 2 As shown, this embodiment of the present disclosure provides a method for processing long commands, which is collaboratively implemented by a long command processing card application running on the SIM card and a terminal-side long command processing module deployed on the terminal device. The method includes: S201, The terminal-side long command processing module splits the long command received from the terminal device APP into short command segments, and encapsulates the short command segments into encapsulated commands and sends them to the target card application running on the SIM card; S202. The long instruction processing card application receives the encapsulation instruction forwarded by the target card application, concatenates the encapsulation instruction into a long command instruction, and sends it to the target card application. S203, The long instruction processing card application splits the long response instruction generated by the target card application into short data segments; S204. In response to the pull information sent by the long command processing module on the terminal side, the long command processing card application sends all short data segments to the long command processing module on the terminal side. The information retrieved is GET RESPONSE(C0).
[0032] S205 The terminal-side long command processing module concatenates all short data segments into a response long command and returns the response long command to the terminal device APP.
[0033] To address the issue that existing SIM cards in T0 transmission mode are limited by protocol and cannot directly process long commands exceeding 256 bytes, resulting in incompatibility between SIM card applications requiring long command interaction and T0 cards, this disclosure provides an embodiment that achieves complete transmission of long commands by the SIM card in T0 transmission mode by splitting long commands in the terminal-side long command processing module on the terminal device side and then splicing and restoring them in the card-side long command processing card application.
[0034] Figure 3 This is a flowchart illustrating a method for processing long commands applied to a SIM card, as provided in an embodiment of this disclosure. Figure 3 As shown, the SIM card runs a long command processing card application, and the methods applied to long command processing on the SIM card include: S301, The target card application running on the SIM card receives the encapsulation instruction sent by the terminal-side long instruction processing module; The above encapsulation instruction is obtained by the terminal-side long instruction processing module splitting the long command received from the terminal device APP into short instruction segments and then encapsulating the short instruction segments.
[0035] S302. The long instruction processing card application receives the encapsulation instruction forwarded by the target card application, concatenates the encapsulation instruction into a long command instruction, and sends it to the target card application. S303, The long instruction processing card application splits the long response instruction generated by the target card application into short data segments; S304. In response to the pull information sent by the terminal-side long command processing module, the long command processing card application sends all short data segments to the terminal-side long command processing module.
[0036] This embodiment of the SIM card based on T0 transmission mode does not support long commands. When long commands need to be processed, the long command is compressed and split before being sent by the terminal device APP. After splitting, it is encapsulated into encapsulated commands and sent to the target card application one by one. After receiving the encapsulated commands, the target card application forwards them to the long command processing card application for processing. The long command processing card application concatenates the commands one by one into a long command and returns it to the target card application for execution. When long response commands need to be processed, the long command processing card application compresses and splits the response long commands and sends them one by one. The terminal-side long command processing module retrieves and concatenates the response long commands one by one by pulling information. If decompression is required, it is decompressed and returned to the terminal device APP all at once, realizing the complete transmission of long commands by the SIM card in T0 transmission mode.
[0037] Figure 4 This is a flowchart illustrating a method for processing long instructions in a terminal device according to an embodiment of this disclosure. The terminal device is equipped with a terminal-side long instruction processing module, such as... Figure 4 As shown, the methods for long instruction processing applied to terminal devices include: S401, The terminal-side long command processing module splits the long command received from the terminal device APP into short command segments, encapsulates them into encapsulated commands, and sends them to the target card application running on the SIM card. S402, The terminal-side long command processing module sends a pull message to the long command processing card application to obtain all short data segments; S403: The terminal-side long command processing module concatenates all short data segments into a response long command and returns the response long command to the terminal device APP.
[0038] This embodiment of the SIM card based on T0 transmission mode does not support long commands. When long commands need to be processed, the long command is compressed and split before being sent by the terminal device APP. After splitting, it is encapsulated into encapsulated commands and sent to the target card application one by one. After receiving the encapsulated commands, the target card application forwards them to the long command processing card application for processing. The long command processing card application concatenates the commands one by one into a long command and returns it to the target card application for execution. When long response commands need to be processed, the long command processing card application compresses and splits the response long commands and sends them one by one. The terminal-side long command processing module retrieves and concatenates the response long commands one by one by pulling information. If decompression is required, it is decompressed and returned to the terminal device APP all at once, realizing the complete transmission of long commands by the SIM card in T0 transmission mode.
[0039] This disclosure provides a method for processing long instructions based on SIM card applications, including a long instruction compression and splitting process for sending a command (C-APDU) long instruction to the SIM card and returning a response (R-APDU) long instruction.
[0040] The compression and splitting of long instructions (C-APDU) are as follows: Since SIM cards in T0 transmission mode do not support long commands, to process long commands, the terminal device APP needs to compress and split the long command before sending it. After splitting, the command is sent to the target card application one by one via the envelope (C2) command. After receiving the envelope command, the target card application forwards it to the long command processing card application for processing. The long command processing card application concatenates the commands one by one into a long command and returns it to the target card application for execution.
[0041] Figure 5 This is a flowchart illustrating another long command processing method provided in an embodiment of the present disclosure, as shown below. Figure 5 As shown, in some embodiments, the long command processing method includes: S501, The terminal device APP sends a long command to the terminal-side long command processing module; The command long instruction is a C-APDU long instruction.
[0042] For example, an Android or Windows application sends a C-APDU long instruction to the SDK or DLL.
[0043] S502, The terminal-side long command processing module parses long command commands and compresses long command commands that need to be compressed; The SDK or DLL parses the C-APDU long instructions and determines whether compression is needed based on the compression rules. If compression is needed, it is performed.
[0044] Because Huffman coding is simple and efficient, it is used for data compression in some embodiments.
[0045] S5021. Determine whether compression is required based on the compression determination rules; Specifically, the compression determination rule is obtained through the following calculation: (1) Calculate the number N1 of long instructions that are directly split into short instruction segments; N1= L / 255 ( (This is the integer part of the instruction), where L is the number of bytes in the data field of the command-length instruction.
[0046] (2) Calculate the number N2 of short instruction segments after compression; Calculate the information entropy H of the instruction data, H(information entropy) = -∑ Pi log2(Pi); Where Pi represents the probability of the ASCII character corresponding to each byte appearing in the instruction; Calculate the compression ratio R based on the information entropy H of the calculated instruction data; A character is 8 bits. If the information entropy of the instruction data is H, the compression ratio R = 8:H.
[0047] Based on the compression ratio R, calculate the number of instruction segments N2 that the compressed long instruction can be split into, where N2 = (L / R) / 255 ( (This is the integer part of the rounding operator).
[0048] (3) Calculate the number of commands N3 that need to be sent after compression; Based on the number of short instruction segments N1 directly split into and the number of short instruction segments N2 after compression, calculate the number of instructions N3 that need to be sent after compression.
[0049] Because the Huffman compression algorithm relies on a "Huffman tree" for decompression and needs to inform the card side of the "original length before compression", these two types of key information need to be transmitted with an extra instruction. Therefore, the total number of instructions sent after compression = the number of short instruction segments after compression + 1 (instruction to transmit the Huffman tree / original length). Therefore, the number of instructions to be sent after compression is N3 = N2 + 1.
[0050] (4) Set compression judgment rules; Considering the impact of using compression algorithms on performance, the compression decision rule is set as follows: compression is performed when N3+1≤N1, otherwise no compression is performed.
[0051] S5022. If a long command meets the compression judgment rules, then Huffman coding is used for compression. In some embodiments, the compression process includes: S50221, Count the frequency of characters and construct an instruction character frequency array; To count the number of times different characters appear in the instruction data, an array is used to store the character frequencies, with the array index being the character.
[0052] S50222, Construct a Huffman tree; Create a priority queue based on character frequency, and add characters and their frequencies as nodes to the queue. Then, each time, take the two nodes with the lowest frequencies from the queue and merge them into a new node. The frequency of the new node is the sum of the frequencies of its two child nodes, and then put the new node back into the queue. Repeat this process until only one node remains in the queue; this node is the root node of the Huffman tree.
[0053] 1) First, define a Huffman node (Node). Each node has a byte member variable `data` to store characters and a short member variable `freq` to represent the frequency of each character. It also has two child node member variables (left and right). Since the nodes need to be sorted according to frequency, they must implement the `Comparable` interface.
[0054] 2) Based on the instruction character frequency array obtained in step S50221, create a Huffman tree using a priority queue.
[0055] 3) Generate the Huffman coding table.
[0056] Starting from the root node of the Huffman tree, record the left and right branches along the path to each leaf node (representing a specific character), marking the left branch as 0 and the right branch as 1. In this way, each character corresponds to a path from the root node to the leaf node containing that character, and the sequence of 0s and 1s along this path is the Huffman code for that character. Record the codes corresponding to all characters to generate a Huffman code table.
[0057] 4) Encode and compress: Encode the instruction data according to the Huffman coding table.
[0058] 5) Output the byte array of the Huffman tree for decompression.
[0059] 6) Send the Huffman tree and the number of bytes before compression, along with the compressed data, to the card application.
[0060] It should be noted that since the SIM card COS does not support data types such as String, StringBuilder, and MinPQ, it is necessary to refer to the JDK and use byte arrays to implement String and StringBuilder, and use arrays (heaps) to implement priority queues and compression algorithm-related APIs. In other words, the SIM card COS does not support advanced data types / APIs, so the most basic byte array must be used. Referring to the underlying implementation logic of the JDK, the character concatenation function of String / StringBuilder and the heap structure of the MinPQ priority queue must be manually replicated. Finally, the Huffman compression / decompression algorithm is implemented on the card side to meet the requirements of long instruction processing.
[0061] This disclosure reduces the number of transmitted instructions and the total amount of data for long instructions by combining compression judgment with Huffman coding compression. The compression judgment rule based on information entropy (N3+1≤N1) ensures that the compression operation is triggered only in scenarios where the number of transmitted instructions can be reduced after compression, avoiding ineffective compression consumption. Huffman coding achieves efficient compression based on the character frequency characteristics of instruction data. Combined with segmented transmission (every 255 bytes per segment), it significantly reduces the number of interactions between the SIM card and the terminal device, reducing transmission latency and communication bandwidth usage. When the card receives long instructions, the logic of decompressing before execution avoids directly storing uncompressed long instruction data, reducing the temporary storage usage of the SIM card.
[0062] S503, The terminal-side long instruction processing module splits long command instructions or compressed long command instructions into short instruction segments. After the SDK or DLL parses the C-APDU long instruction (or the compressed C-APDU long instruction), it splits it into a short instruction segment every 255 bytes, starting from the instruction command header.
[0063] S504, The terminal-side long instruction processing module encapsulates short instruction segments into encapsulated instructions; SDKs or DLLs use the envelope directive to encapsulate instructions.
[0064] If compression is performed, parameter P1 is set to 01; otherwise, it is 00. If it is the last instruction (sending Huffman tree information), then P2 is 01; otherwise, it is 00.
[0065] Table 1
[0066] For example, as shown in Table 1, 00C20100FFXXXXXX (represents 255 bytes of compressed data, where XX represents the split instruction segment), and for another example, 00C20001AAXXXXXX represents the last envelope instruction, which contains an AA-byte Huffman tree.
[0067] S504.1-S504.n, the terminal-side long instruction processing module sends the encapsulation instructions to the target card application one by one; S505: The target card application will pass through all encapsulation instructions received from the terminal-side long instruction processing module to the long instruction processing card application. After receiving the envelope instruction, the target card application calls the processEnvelope(APDU) method of the long instruction processing card application to forward the long instruction to the long instruction processing card application for processing.
[0068] Long instruction processing card applications provide a shared interface, eliminating the need for repeated development of split / assemble / compress logic for each target card application. This reduces code redundancy in card applications and indirectly saves program storage resources on the SIM card.
[0069] S506: Long instruction processing card applications concatenate all packaged instructions to restore them into long command instructions; Long instruction processing card applications use a larger buffer (e.g., 2KB, which can handle long instructions under 2KB) to concatenate the data fields of envelope instructions into a complete long instruction.
[0070] S507: If decompression is required, then perform decompression; If decompression is required, the long instruction processing card application uses the received Huffman tree to decompress the long instruction. This includes the following steps: S5071. Convert the received Huffman tree array into a String. Since cos does not support the String type, you need to implement it yourself.
[0071] S5072. Use the helper class StringUtil to traverse the Huffman tree string and construct the Huffman tree; StringUtil provides methods for reading strings by 1 bit and by 8 bits.
[0072] S5073, Decompress long command according to Huffman tree; S508: The long instruction processing card application returns the long instruction buffer to the target card application; The buffer here is a dedicated byte array space (usually 2KB) pre-allocated in the COS layer of the SIM card by the long instruction processing card application.
[0073] The long instruction processing card application will use the processEnvelope method to concatenate and decompress the complete C-APDU long instruction, extract it from the dedicated 2KB buffer, and return it to the target card application, so that it can obtain the complete long instruction that can be executed directly.
[0074] S509: Target card application processing long instructions.
[0075] Compression and splitting of long commands in response (R-APDU): For SIM cards in T0 transmission mode, the long instruction processing card application needs to compress and split the R-APDU long instructions before sending them one by one. The last instruction, if the data is compressed, consists of a 1-byte compression identifier plus a Huffman tree byte array; otherwise, it is just an identifier. The SDK / DLL retrieves the R-APDUs one by one via GET RESPONSE (C0), concatenates the data fields, and if decompression is required, returns the decompressed data to the terminal device APP all at once. Figure 6 This is a flowchart illustrating a method for handling long instructions according to an embodiment of the present disclosure, as shown below. Figure 6 As shown, in some embodiments, the response long command processing method includes: S601, The target card application will send the response long command to the long command processing card application; The target card application calls the response (APDU apdu) method of the long instruction processing card application to process the response long instruction, which is an R-APDU long instruction.
[0076] S602: The long instruction processing card parses and responds to long instructions, and determines whether compression is needed according to the compression judgment rules. If compression is needed, compression is performed. The long instruction processing card parses R-APDU long instructions and compresses them according to compression rules.
[0077] The compression determination rules and compression methods for R-APDU long instructions are the same as those for C-APDU long instructions. For details, please refer to steps S5021-S5022.
[0078] S603, Long Instruction Processing Card Applications split long instruction responses or compressed long instruction responses into short data segments; After parsing the R-APDU long instruction (or compressed R-APDU long instruction), the long instruction processing card application splits it into short data segments of 255 bytes each, starting from the instruction command header.
[0079] S604: The long instruction processing card application sends data retrieval trigger information to the long instruction processing module on the terminal side. Long instruction processing card applications send 61XX status codes to the SDK or DLL. The XX value varies depending on the length of the data to be sent; for example, if it exceeds 256 bytes, XX is 00.
[0080] S605: The terminal-side long command processing module sends a pull message to the long command processing card application to obtain all short data segments. The SDK / DLL retrieves data by pulling information via GET RESPONSE (C0).
[0081] S606: The long instruction processing card application sends short data segments one by one to the long instruction processing module on the terminal side based on the received pull information. The long instruction processing card application processes the C0 instruction and responds with "data + status code 61XX".
[0082] S607, The terminal-side long command processing module continues to send pull information to the long command processing card application; The SDK / DLL continues to retrieve data by pulling information via GET RESPONSE (C0).
[0083] S608: The long instruction processing card sends the last short data segment to the long instruction processing module. The last data transmission is indicated by the long instruction processing card application responding with "data + status code 9000", signifying that data transmission has been completed. It should be noted that if compression is used, the last data transmission will be '0x01' + Huffman tree data; otherwise, it will be '0x00'.
[0084] S609, The terminal-side long instruction processing module splices the received short data segments; The SDK / DLL reassembles the received short data segments into a C-APDU long instruction.
[0085] S610, if decompression is required, the terminal-side long command processing module will perform decompression; If decompression is required, the SDK / DLL will decompress the received data according to the Huffman tree. The decompression method is the same as the C-APDU long instruction decompression method; please refer to step S507 for details.
[0086] S611, the terminal-side long command processing module will return the response long command to the terminal device APP.
[0087] The SDK / DLL returns the concatenated and restored R-APDU long instruction to the terminal device APP.
[0088] In this implementation, the SIM card based on T0 transmission mode does not support long commands. When long commands need to be processed, the long command is compressed and split before being sent by the terminal device APP. After splitting, it is encapsulated into encapsulated commands and sent to the target card application one by one. After receiving the encapsulated commands, the target card application forwards them to the long command processing card application for processing. The long command processing card application concatenates the commands one by one into a long command and returns it to the target card application for execution. When long response commands need to be processed, the long command processing card application compresses and splits the response long commands and sends them one by one. The terminal-side long command processing module retrieves and concatenates the response long commands one by one by pulling information. If decompression is required, it is decompressed and returned to the terminal device APP all at once, thus realizing the complete transmission of long commands by the SIM card in T0 transmission mode.
[0089] The above description is only a preferred embodiment of the present invention. It should be noted that, for those skilled in the art, several improvements, optimizations and modifications can be made without departing from the principle of the present invention, and these should also be considered within the scope of protection of the present invention.
[0090] Figure 7 This is a schematic diagram of a device for long instruction processing applied to a SIM card, provided in an embodiment of the present disclosure. Figure 7 As shown, the device 700 includes: The receiving module 701 is configured to receive encapsulation instructions sent by the terminal-side long instruction processing module of the target card application running on the SIM card. The encapsulation instructions are obtained by the terminal-side long instruction processing module splitting the command long instruction received from the terminal device APP into short instruction segments and encapsulating the short instruction segments. The splicing module 702 is configured to receive the encapsulation instruction forwarded by the target card application from the long instruction processing card application, splice the encapsulation instruction into a long command instruction and send it to the target card application. The splitting module 703 is configured to split the long instruction response generated by the target card application into short data segments for the long instruction processing card application. The response module 704 is configured to respond to the pull information sent by the terminal-side long command processing module, and the long command processing card application sends all short data segments to the terminal-side long command processing module.
[0091] Figure 8 A schematic diagram of a device for long instruction processing applied to a terminal, provided in an embodiment of this disclosure, is shown below. Figure 8 As shown, the device 800 includes: The encapsulation module 801 is configured to split the long command received from the terminal device APP into short command segments and encapsulate them into encapsulated commands to be sent to the target card application running on the SIM card. The sending module 802 is configured to send pull information from the terminal-side long command processing module to the long command processing card application to obtain all short data segments; The recovery module 803 is configured as a terminal-side long command processing module to concatenate all short data segments into a response long command and return the response long command to the terminal device APP.
[0092] Figure 9 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present disclosure, such as... Figure 9 As shown, this disclosure also provides an electronic device 900, which includes at least one processor 901 and a memory 902 coupled to the processor 901. The memory 902 is used to store at least one processor 901 executable instructions, wherein the at least one processor 901 is used to execute the instructions to implement the steps of the method described above in this disclosure.
[0093] The processor 901 described above can also be called a Central Processing Unit (CPU), which can be an integrated circuit chip with signal processing capabilities. Each step in the method described in this embodiment can be implemented by the integrated logic circuitry in the processor 901 or by software instructions. The processor 901 can be a general-purpose processor, a digital signal processor (DSP), an ASIC, a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the method in this embodiment can be directly implemented by a hardware decoding processor, or implemented by a combination of hardware and software modules in the decoding processor. The software modules can be located in the memory 902, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, or other mature storage media in the art. The processor 901 reads information from the memory 902 and, in conjunction with its hardware, completes the steps of the method described above.
[0094] Figure 10This is a schematic diagram of an exemplary computer system provided by an embodiment of the present disclosure. Various operations / processes according to embodiments of the present disclosure, implemented via software and / or firmware, can be transmitted from a storage medium or network to a computer system with a dedicated hardware architecture, for example... Figure 10 The computer system 1000 shown is equipped with the programs that constitute the software. When various programs are installed, the computer system is able to perform various functions, including those described above.
[0095] Computer system 1000 is intended to represent various forms of digital electronic computer devices, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. Electronic devices may also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the present disclosure described and / or claimed herein.
[0096] like Figure 10 As shown, the computer system 1000 includes a computing unit 1001, which can perform various appropriate actions and processes based on a computer program stored in a read-only memory (ROM) 1002 or a computer program loaded from a storage unit 1008 into a random access memory (RAM) 1003. The RAM 1003 may also store various programs and data required for the operation of the computer system 1000. The computing unit 1001, ROM 1002, and RAM 1003 are interconnected via a bus 1004. An input / output (I / O) interface 1005 is also connected to the bus 1004.
[0097] Multiple components in the computer system 1000 are connected to the I / O interface 1005, including: an input unit 1006, an output unit 1007, a storage unit 1008, and a communication unit 1009. The input unit 1006 can be any type of device capable of inputting information into the computer system 1000. The input unit 1006 can receive input numerical or character information and generate key signal inputs related to user settings and / or function control of the electronic device. The output unit 1007 can be any type of device capable of presenting information and may include, but is not limited to, a monitor, speaker, video / audio output terminal, vibrator, and / or printer. The storage unit 1008 may include, but is not limited to, a hard disk and an optical disk. The communication unit 1009 allows the computer system 1000 to exchange information / data with other devices via a network such as the Internet, and may include, but is not limited to, modems, network interface cards, infrared communication devices, wireless communication transceivers, and / or chipsets, such as Bluetooth™ devices, Wi-Fi devices, WiMax devices, cellular communication devices, and / or the like.
[0098] The computing unit 1001 can be various general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the computing unit 1001 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 1001 performs the various methods and processes described above. For example, in some embodiments, the methods described above in the embodiments of this disclosure can be implemented as a computer software program tangibly contained in a machine-readable medium, such as storage unit 1008. In some embodiments, part or all of the computer program can be loaded and / or installed on an electronic device via ROM 1002 and / or communication unit 1009. In some embodiments, the computing unit 1001 can be configured to perform the methods described above in the embodiments of this disclosure by any other suitable means (e.g., by means of firmware).
[0099] This disclosure provides a computer-readable storage medium storing one or more programs that can be executed by one or more processors to implement the methods described in this disclosure.
[0100] Computer-readable storage media can be volatile memory, such as random-access memory (RAM); or non-volatile memory, such as read-only memory (ROM), flash memory, hard disk drive (HDD), or solid-state drive (SSD); or devices that include one or any combination of the above-mentioned memories, such as mobile phones, computers, tablet devices, personal digital assistants, etc.
[0101] It should be noted that the computer-readable storage medium described in this disclosure can be a computer-readable signal medium, a computer-readable storage medium, or any combination thereof. A computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this disclosure, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In this disclosure, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium may be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wires, optical fibers, RF (radio frequency), or any suitable combination thereof.
[0102] Embodiments of this disclosure provide a computer program product, including a computer program that, when executed by a processor, implements the steps of the long instruction processing method described above.
[0103] In embodiments of this disclosure, computer program code for performing the operations of this disclosure can be written in one or more programming languages or a combination thereof. These programming languages include, but are not limited to, object-oriented programming languages such as Java, Smalltalk, and C++, as well as conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on a computer, partially on a computer, as a standalone software package, partially on a computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0104] The modules, components, or units described in the embodiments of this disclosure can be implemented in software or hardware. The names of the modules, components, or units do not necessarily constitute a limitation on the module, component, or unit itself.
[0105] The functions described above in this document can be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary hardware logic components that can be used include: field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), system-on-a-chip (SoCs), complex programmable logic devices (CPLDs), etc.
[0106] It should be noted that, in this document, terms such as "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0107] The above description is merely a specific embodiment of this disclosure, enabling those skilled in the art to understand or implement it. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this disclosure. Therefore, this disclosure is not to be limited to the embodiments described herein, but is to be accorded the widest scope consistent with the principles and novel features claimed herein.
Claims
1. A method for processing long instructions, characterized in that, The method, implemented collaboratively by a long command processing card application running on the SIM card and a terminal-side long command processing module deployed on the terminal device, includes: The terminal-side long command processing module splits the long command received from the terminal device APP into short command segments, and encapsulates the short command segments into encapsulated commands and sends them to the target card application running on the SIM card; The long instruction processing card application receives the encapsulation instruction forwarded by the target card application, concatenates the encapsulation instruction into a long command instruction, and sends it to the target card application; Long instruction processing card applications split long response instructions generated by the target card application into short data segments; In response to the pull information sent by the terminal-side long command processing module, the long command processing card application sends all short data segments to the terminal-side long command processing module; The terminal-side long command processing module concatenates all short data segments into a response long command and returns the response long command to the terminal device APP.
2. The method according to claim 1, characterized in that, Before the terminal-side long command processing module splits the long command received from the terminal device APP into short command segments, and encapsulates the short command segments into encapsulated commands to send to the target card application running on the SIM card, the method further includes: The terminal device APP sends the long command to the terminal-side long command processing module.
3. The method according to claim 2, characterized in that, The terminal-side long command processing module splits long commands received from the terminal device APP into short command segments, and encapsulates the short command segments into encapsulated commands to send to the target card application running on the SIM card, including: The terminal-side long command processing module receives long command commands sent by the terminal device APP; The terminal-side long command processing module determines whether a long command needs to be compressed according to the compression judgment rules. If compression is required, the long command is compressed. The terminal-side long command processing module splits long command commands or compressed long command commands into short command segments; The terminal-side long instruction processing module encapsulates short instruction segments into encapsulated instructions; The terminal-side long instruction processing module sends the encapsulation instruction to the target card application running on the SIM card.
4. The method according to claim 3, characterized in that, The terminal-side long command processing module determines whether a long command needs to be compressed according to compression rules. If compression is required, the long command is compressed, including: The terminal-side long command processing module parses the command long command and extracts the number of bytes L in the data field of the command long command; Calculate the number N1 of long instructions that can be directly split into short instruction segments. L / 255 , This is the integer part for rounding up. Calculate the probability Pi of the occurrence of the corresponding ASCII character in each byte of the statistical data field, calculate the information entropy H = -∑ Pilog2 (Pi), and calculate the compression ratio R=8:H; Calculate the number of short instruction segments N2 that can be split after compression. (L / R) / 255 And the total number of instructions to be sent after compression is N3 = N2 + 1; If N3+1≤N1, then compression is required, and the long command is compressed.
5. The method according to claim 4, characterized in that, The compression of the long command instruction is achieved by using Huffman coding to compress the long command instruction.
6. The method according to claim 1, characterized in that, The long instruction processing card application receives the encapsulation instruction forwarded by the target card application, and concatenates the encapsulation instruction into a long command instruction to return to the target card application, including: The target card application will pass through all encapsulation instructions received from the terminal-side long instruction processing module to the long instruction processing card application; Long instruction processing card applications concatenate all encapsulated instructions to restore them into long command instructions; The long command processing card application sends the concatenated and restored command long command to the target card application.
7. The method according to claim 6, characterized in that, The long instruction processing card application receives the encapsulation instruction forwarded by the target card application, and concatenates the encapsulation instruction into a long command instruction to return to the target card application. This also includes: If the long command for splicing and restoring needs to be decompressed, then decompression will be performed.
8. The method according to claim 1, characterized in that, The long instruction processing card application splits the long response instruction generated by the target card application into short data segments, including: The long command processing card application receives a response long command sent by the target card application; The long instruction processing card application determines whether the response to a long instruction needs to be compressed according to the compression judgment rules. If compression is required, the response to the long instruction will be compressed. Long instruction processing card applications split long instruction responses or compressed long instruction responses into short data segments.
9. The method according to claim 8, characterized in that, The long command processing card application determines whether the response to a long command needs to be compressed according to compression judgment rules. If compression is required, the long command response is compressed, including: The long instruction processing card application parses the response long instruction and extracts the number of bytes L of the data field of the response long instruction; Calculate the number N1 that can be directly split into short data segments in response to a long command. L / 255 , This is the integer part for rounding up. Calculate the probability Pi of the occurrence of the corresponding ASCII character in each byte of the statistical data field, calculate the information entropy H = -∑ Pilog2 (Pi), and calculate the compression ratio R=8:H; Calculate the number of short data segments N2 after compression. (L / R) / 255 The total number of commands to be sent after compression is N3 = N2 + 1; If N3+1≤N1, then compression is required, and a long command will be executed to perform compression.
10. The method according to claim 9, characterized in that, The compression of long response instructions is achieved by using Huffman coding to compress the long response instructions.
11. The method according to claim 1, characterized in that, In response to the pull information sent by the terminal-side long command processing module, the long command processing card application sends all short data segments to the terminal-side long command processing module, including: The long command processing card application sends data retrieval trigger information to the long command processing module on the terminal side; The terminal-side long command processing module sends a pull message to the long command processing card application to obtain all short data segments; The long instruction processing card application sends all short data segments to the terminal-side long instruction processing module based on the fetched information.
12. A method for long instruction processing, applied to a SIM card, wherein the SIM card runs a long instruction processing card application, characterized in that, The method includes: The target card application running on the SIM card receives the encapsulation instruction sent by the terminal-side long instruction processing module. The encapsulation instruction is obtained by the terminal-side long instruction processing module splitting the long command received from the terminal device APP into short instruction segments and encapsulating the short instruction segments. The long instruction processing card application receives the encapsulation instruction forwarded by the target card application, concatenates the encapsulation instruction into a long command instruction, and sends it to the target card application; Long instruction processing card applications split long response instructions generated by the target card application into short data segments; In response to the pull request sent by the terminal-side long command processing module, the long command processing card application sends all short data segments to the terminal-side long command processing module.
13. The method according to claim 12, characterized in that, The long instruction processing card application receives the encapsulation instruction forwarded by the target card application, concatenates the encapsulation instruction into a long command instruction, and sends it to the target card application, including: The target card application will pass through all encapsulation instructions received from the terminal-side long instruction processing module to the long instruction processing card application; Long instruction processing card applications concatenate all encapsulated instructions to restore them into long command instructions; The long command processing card application sends the concatenated and restored command long command to the target card application.
14. The method according to claim 13, characterized in that, The long instruction processing card application receives the encapsulation instruction forwarded by the target card application, concatenates the encapsulation instruction into a long command instruction, and sends it to the target card application, which also includes: If the long command for splicing and restoring needs to be decompressed, then decompression will be performed.
15. The method according to claim 12, characterized in that, The long instruction processing card application splits the long response instruction generated by the target card application into short data segments, including: The long command processing card application receives a response long command sent by the target card application; The long instruction processing card application determines whether the response long instruction needs to be compressed according to the compression judgment rules. If compression is required, the response long instruction is compressed. Long instruction processing card applications split long instruction responses or compressed long instruction responses into short data segments.
16. The method according to claim 12, characterized in that, In response to the pull information sent by the terminal-side long command processing module, the long command processing card application sends all short data segments to the terminal-side long command processing module, including: The long command processing card application sends a data retrieval trigger message (61XX status code) to the long command processing module on the terminal side; The long command processing card application receives pull information sent by the long command processing module on the terminal side; The long instruction processing card application sends all short data segments to the terminal-side long instruction processing module based on the fetched information.
17. A method for processing long instructions, characterized in that, Applied to a terminal device, wherein the terminal device has a terminal-side long instruction processing module, the method includes: The terminal-side long command processing module splits the long command received from the terminal device APP into short command segments, encapsulates them into encapsulated commands, and sends them to the target card application running on the SIM card. The terminal-side long command processing module sends a pull message to the long command processing card application to obtain all short data segments; The terminal-side long command processing module concatenates all short data segments into a response long command and returns the response long command to the terminal device APP.
18. The method according to claim 17, characterized in that, The terminal-side long command processing module splits the long command received from the terminal device APP into short command segments, encapsulates them into encapsulated commands, and sends them to the target card application running on the SIM card, including: The terminal-side long command processing module receives long command commands sent by the terminal device APP; The terminal-side long command processing module determines whether the command-long command needs to be compressed according to the compression judgment rules. If compression is required, the command-long command is compressed. The terminal-side long command processing module splits long command commands or compressed long command commands into short command segments; The terminal-side long instruction processing module encapsulates short instruction segments into encapsulated instructions; The terminal-side long instruction processing module sends the encapsulation instruction to the target card application running on the SIM card.
19. The method according to claim 18, characterized in that, The terminal-side long command processing module determines whether the long command needs to be compressed according to compression rules. If compression is required, the long command is compressed, including: The terminal-side long command processing module parses the command long command and extracts the number of bytes L in the data field of the command long command; Calculate the number N1 of long instructions that can be directly split into short instruction segments. L / 255 , This is the integer part for rounding up. Calculate the probability Pi of the occurrence of the corresponding ASCII character in each byte of the statistical data field, calculate the information entropy H = -∑ Pilog2 (Pi), and calculate the compression ratio R=8:H; Calculate the number of short instruction segments N2 that can be split after compression. (L / R) / 255 And the total number of instructions to be sent after compression is N3 = N2 + 1; If N3+1≤N1, then compression is required, and the long command is compressed.
20. The method according to claim 17, characterized in that, The compression of the long command instruction is achieved by using Huffman coding to compress the long command instruction.
21. The method according to claim 17, characterized in that, Before sending pull information to the long instruction processing card application to retrieve all short data segments, the method further includes: The terminal-side long command processing module receives data retrieval trigger information sent by the long command processing card application.
22. The method according to claim 21, characterized in that, The step of sending a pull message to the long instruction processing card application to obtain all short data segments includes: In response to the data retrieval trigger information, the terminal-side long command processing module sends multiple retrieval messages to the long command processing card application to obtain all short data segments.
23. The method according to claim 17, characterized in that, The terminal-side long command processing module concatenates all short data segments into a response long command and returns the response long command to the terminal device APP, including: The terminal-side long command processing module concatenates all short data segments into a response long command. If decompression is required, the terminal-side long command processing module decompresses the received data according to the Huffman tree; The terminal-side long command processing module will return the response long command to the terminal device APP.
24. The method according to any one of claims 17-23, characterized in that, The terminal-side long instruction processing module is an SDK or DLL.
25. A long instruction processing apparatus, applied to a SIM card, characterized in that, The device includes: The receiving module is configured to run on the SIM card to receive encapsulation instructions sent by the terminal-side long instruction processing module. The encapsulation instructions are obtained by the terminal-side long instruction processing module splitting the long command received from the terminal device APP into short instruction segments and encapsulating the short instruction segments. The splicing module is configured to receive the encapsulated instructions forwarded by the target card application from the long instruction processing card application, splice the encapsulated instructions into a long command instruction, and send it to the target card application. The splitting module is configured to allow the long instruction processing card application to split the long response instruction generated by the target card application into short data segments. The response module is configured to respond to pull information sent by the terminal-side long command processing module. The long command processing card application sends all short data segments to the terminal-side long command processing module.
26. A long instruction processing apparatus, applied to a terminal device, characterized in that, The device includes: The encapsulation module is configured to split long command received from the terminal device APP into short command segments and encapsulate them into encapsulated commands to be sent to the target card application running on the SIM card. The sending module is configured to send pull information from the terminal-side long command processing module to the long command processing card application to obtain all short data segments; The recovery module is configured as a long command processing module on the terminal side to concatenate all short data segments into a long response command and return the long response command to the terminal device APP.
27. An electronic device, characterized in that, include: At least one processor; Memory for storing the at least one processor-executable instruction; The at least one processor is configured to execute the instructions to implement the method as described in any one of claims 1-11, 12-16, or 17-24.
28. A computer-readable storage medium, characterized in that, When the instructions in the computer-readable storage medium are executed by the processor of the electronic device, the electronic device is able to perform the method as described in any one of claims 1-11, 12-16, or 17-24.
29. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the long instruction processing method as described in any one of claims 1-11, 12-16, or 17-24.