Method and system for SIM card to communicate with terminal application as TCP client

Using the SIM card as a method of communicating between the TCP client and the terminal application solves the problems of limited data volume, poor compatibility and network instability in the communication between the SIM card and the mobile terminal, achieves full business scenario coverage and efficient data transmission, and improves the system stability and security.

CN117041918BActive Publication Date: 2024-10-29CHINA MOBILE INTERNET CO LTD +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310957677.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-07-31
Publication Date
2024-10-29
Estimated Expiration
2043-07-31

AI Technical Summary

Technical Problem

The existing communication methods between SIM cards and mobile terminals have problems such as limited data volume, compatibility issues, network instability, data packet loss, and inability to cover all terminals and all business scenarios, which limits the expansion of SIM card capabilities.

Method used

The SIM card is used as a method of communication between the TCP client and the terminal application. The TCP service ready message is sent through the terminal application. The SIM card receives and parses the information security check, establishes a TCP connection, and realizes two-way data interaction with the terminal. Utilize SMS channels and secure transmission channels improve data transmission efficiency and stability.

Benefits of technology

It solves the problems of low two-way communication coverage, unstable indirect communication network, and limited data transmission volume, realizes full-service scenario communication between SIM cards and mobile terminals, and improves data transmission rate and system security.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117041918B_ABST
    Figure CN117041918B_ABST
Patent Text Reader

Abstract

The present invention discloses a method and system for a SIM card to communicate with a terminal application as a TCP client, wherein the method comprises: the terminal application sends a TCP service ready message to the platform end; the SIM card in the terminal receives the SMS data sent after the platform end parses the TCP service ready message; the SIM card application in the terminal performs information security verification based on the SMS data to obtain the information security verification result; the terminal application establishes a TCP connection based on the information security verification result, and obtains the data interaction result with the SIM card according to the TCP connection. The present invention can effectively solve the problems of low coverage of two-way communication terminals, unstable network of indirect communication mode, and limited amount of transmitted data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of infrastructure and IT support technology, and in particular to a method, system, device and storage medium for a SIM card to communicate with a terminal application as a TCP client. Background Art

[0002] Since 2016, SIM cards have entered the era of super SIM, which has given SIM cards more and more functions, and gradually added security chips, national secret algorithms and other capabilities. China Mobile Internet has also launched a wide variety of SIM card applications and other data value-added services. It is particularly important to establish communication between SIM cards and mobile terminals and use the rich capabilities of SIM cards. The existing communication methods between SIM cards and mobile terminals mainly depend on the terminal type and SIM card version. The SIM cards discussed are all smart cards that support ISO / IEC7816-4 specifications and 3GPPTS 31.111 specifications. The specific form is to support APDU instructions and support the connection-oriented bearer independent transmission protocol BIP. The current mainstream terminal systems include Android and iOS systems. Apple's iOS system has not yet opened APDU instruction support, and it is currently impossible to achieve direct communication between SIM cards and mobile terminals; some Android systems have implemented support for the above specifications, mainly in the form of Android system-level TelephonyManager service or SEService based on SIMalliance OpenMobile API. The existing communication methods between SIM cards and terminals and the existing problems are as follows:

[0003] Google API communicates with the terminal: This method is limited by the operating system and is currently only applicable to Android phones. In addition, this method requires the terminal App's certificate signature information to be pre-set into the SIM card. It cannot cover iOS devices, which is not conducive to the product's business promotion. The air SMS channel communicates with the terminal: The amount of application data it carries is small and the latency is long. For example, the SIMeID activation process requires downloading identity information, which reaches 3KB. It is obviously unrealistic to use the SMS channel communication method. The BIP gateway communicates with the terminal: Due to the unstable network, the success rate of data contact is affected, and the data packet loss leads to incomplete data reception. Summary of the invention

[0004] The present invention aims to solve one of the technical problems in the related art at least to a certain extent.

[0005] To this end, the first purpose of the present invention is to propose a method for using a SIM card as a TCP client to communicate with a terminal application, thereby solving problems such as limited data volume, compatibility issues, network instability, data packet loss, and inability to cover all terminal and all business scenarios in existing communication solutions, and facilitating the expansion of SIM card capabilities in terminal applications.

[0006] The second object of the present invention is to provide a system in which a SIM card acts as a TCP client to communicate with a terminal application.

[0007] A third object of the present invention is to provide a computer device.

[0008] A fourth object of the present invention is to provide a non-transitory computer-readable storage medium.

[0009] To achieve the above object, a first aspect of the present invention provides a method for a SIM card to communicate with a terminal application as a TCP client, comprising:

[0010] The terminal application sends a TCP service ready message to the platform;

[0011] The SIM card in the terminal receives the SMS data sent by the platform after parsing the TCP service ready message;

[0012] The SIM card application in the terminal performs information security verification based on the SMS data to obtain an information security verification result;

[0013] The terminal application establishes a TCP connection based on the information security verification result, and obtains the data interaction result with the SIM card according to the TCP connection.

[0014] The method for the SIM card in the embodiment of the present invention to communicate with the terminal application as a TCP client may also have the following additional technical features:

[0015] In one embodiment of the present invention, the terminal application sends a TCP service ready message to the platform end, including:

[0016] Acquire configuration data and perform TCP client connection processing to obtain a TCP client connection processing result; wherein the configuration data includes a target SIM card mobile phone number, a TCP service port number, and an authentication token;

[0017] Based on the TCP client connection processing result, encapsulating the configuration data into a TCP service ready message according to a preset encapsulation format;

[0018] The terminal application sends the TCP service ready message to the platform end through a secure transmission channel.

[0019] In one embodiment of the present invention, the platform side includes a message processing module and a short message gateway; the SIM card in the terminal receives the short message data sent by the platform side after parsing the TCP service ready message, including:

[0020] Obtain the target SIM card phone number and authentication Token obtained by parsing the TCP service ready message by the message processing module;

[0021] Encapsulate the SMS message based on the target SIM card phone number and the authentication Token, and call the SMS service to send the encapsulated SMS message to the SMS gateway;

[0022] The SIM card in the terminal receives the SMS data sent by the SMS gateway using the full SMS protocol after the SMS gateway authenticates the encapsulated SMS message.

[0023] In one embodiment of the present invention, the application on the SIM card in the terminal performs information security verification based on the SMS data to obtain an information security verification result, including:

[0024] Receive SMS data sent by the SMS gateway, and encapsulate the SMS data into ENVELOPE command according to the preset SMS protocol parameters TP-PID and TP-DCS;

[0025] The SIM card in the terminal receives the ENVELOPE command, parses and extracts the target application identifier in the SMS data, and matches it with the identifiers of each application on the SIM card to obtain an identifier matching result;

[0026] The card application is triggered based on the identification matching result to perform security verification on the SMS user data to obtain an information security verification result.

[0027] In one embodiment of the present invention, the terminal application establishes a TCP connection based on the information security verification result, including:

[0028] Obtaining an OPEN CHANNEL command based on the information security verification result, and determining that the port number of the target address parameter of the OPEN CHANNEL command is the port number in the received SMS data;

[0029] A request for establishing a TCP connection with the port specified in the port number in the received SMS data is obtained, and corresponding processing is performed according to the command execution result of the terminal response request to establish the TCP connection.

[0030] In one embodiment of the present invention, obtaining the data interaction result with the SIM card according to the TCP connection includes:

[0031] Receive the SEND DATA command sent by the card application, obtain the corresponding TCP connection according to the channel identifier of the command, and use the corresponding TCP connection to send the authentication Token to the TCP client;

[0032] Obtain the consistency comparison result between the authentication token obtained by the TCP client based on TCP data processing and the locally cached token;

[0033] TCP data notification information is sent to the SIM card based on the consistency comparison result and the ENVELOPE command, and TCP data is sent to the SIM card according to the TCP data notification information and the RECEIVE DATA command to obtain a data interaction result with the SIM card.

[0034] In one embodiment of the present invention, after obtaining the data interaction result with the SIM card, the method further includes:

[0035] Obtaining TCP data notification information and a TCP connection closing message based on the data interaction result;

[0036] Based on the closing message, a CLOSE CHANNEL command sent by the card application is received to obtain a request to close the TCP connection of the specified channel identifier.

[0037] In one embodiment of the present invention, a random number generator is used to generate an ASCII character string with a length of 16 as an authentication Token.

[0038] In one embodiment of the present invention, the SMS message encapsulation is performed, including: a field Msg_Fmt, configured as binary, to identify the message format; a field Msg_Content, to identify the message content; and a field Dest_terminal_Id filled with the target mobile phone number obtained in the previous process.

[0039] In one embodiment of the present invention, encapsulating the SMS data into an ENVELOPE command according to the values ​​of preset SMS protocol parameters TP-PID and TP-DCS includes:

[0040] According to the values ​​of the SMS protocol parameters TP-PID and TP-DCS, determine whether to send the SMS data to the SIM card to obtain a determination result;

[0041] If the SMS protocol parameter TP-PID parameter value is 0x7F, and the bit1 of the TP-DCS parameter value is 1 and the bit0 is 0, the judgment result is that the SMS data needs to be transmitted, and the terminal encapsulates the received SMS data into an ENVELOPE command and sends it to the SIM card.

[0042] In one embodiment of the present invention, the triggering of the card application to perform security verification on the SMS user data based on the identification matching result to obtain the information security verification result includes:

[0043] Based on the identification matching result and the security parameter SPI value, it is determined whether the SMS user data is encrypted. If it is determined to be encrypted, the card application uses the preset key to decrypt the data between CNTR and Secured Data, which are all ciphertext, to obtain the plaintext message authentication code CC;

[0044] MAC calculation is performed on SMS user data, and the calculated MAC value is compared with the plaintext message authentication code CC to obtain an information security verification result with comparison consistency.

[0045] The method for the SIM card in the embodiment of the present invention to communicate with the terminal application as a TCP client can effectively solve the problems of low coverage of two-way communication terminals, unstable indirect communication network, and limited transmission data volume.

[0046] To achieve the above object, a second embodiment of the present invention provides a system in which a SIM card acts as a TCP client to communicate with a terminal application, comprising:

[0047] The message sending module is used for the terminal application to send the TCP service ready message to the platform end;

[0048] A message parsing module, used for a SIM card in a terminal to receive SMS data sent after the platform parses the TCP service ready message;

[0049] An information security verification module, used for the SIM card application in the terminal to perform information security verification based on the SMS data to obtain an information security verification result;

[0050] The data connection interaction module is used for the terminal application to establish a TCP connection based on the information security verification result, and obtain the data interaction result with the SIM card according to the TCP connection.

[0051] The SIM card of the embodiment of the present invention is used as a system for communicating with terminal applications via a TCP client, which can effectively solve the problems of low coverage of two-way communication terminals, unstable indirect communication network, and limited transmission data volume.

[0052] To achieve the above-mentioned purpose, the third aspect embodiment of the present application proposes a computer device, comprising: a processor and a memory; wherein the processor runs a program corresponding to the executable program code by reading the executable program code stored in the memory, so as to implement the method of the SIM card as a TCP client communicating with the terminal application as described in the first aspect embodiment.

[0053] To achieve the above-mentioned purpose, the fourth aspect embodiment of the present application proposes a non-temporary computer-readable storage medium, on which a computer program is stored. When the program is executed by a processor, the method in which the SIM card as a TCP client communicates with a terminal application as described in the first aspect embodiment is implemented.

[0054] Additional aspects and advantages of the present invention will be given in part in the following description and in part will be obvious from the following description, or will be learned through practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS

[0055] The above and / or additional aspects and advantages of the present invention will become apparent and easily understood from the following description of the embodiments in conjunction with the accompanying drawings, in which:

[0056] Figure 1 A flowchart of a method for a SIM card to communicate with a terminal application as a TCP client according to an embodiment of the present invention;

[0057] Figure 2 A schematic diagram of a scenario of a method in which a SIM card acts as a TCP client and communicates with a terminal application according to an embodiment of the present invention;

[0058] Figure 3 A flowchart of another method for a SIM card to communicate with a terminal application as a TCP client according to an embodiment of the present invention;

[0059] Figure 4 A schematic diagram of the structure of a system in which a SIM card acts as a TCP client and communicates with a terminal application according to an embodiment of the present invention;

[0060] Figure 5 FIG. 4 is a schematic diagram of the structure of a computer device according to an embodiment of the present invention. DETAILED DESCRIPTION

[0061] It should be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present application can be combined with each other. The present invention will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.

[0062] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.

[0063] The following describes a method, system, computer device and storage medium for communicating between a SIM card as a TCP client and a terminal application according to an embodiment of the present invention with reference to the accompanying drawings.

[0064] Before describing the method for communicating between a SIM card as a TCP client and a terminal application in an embodiment of the present invention, the technical terms used in the present invention are first explained as shown in Table 1:

[0065] Table 1

[0066]

[0067]

[0068] Embodiment 1:

[0069] Figure 1 The present invention is a flowchart of a method in which a SIM card acts as a TCP client to communicate with a terminal application.

[0070] like Figure 1 As shown, the method includes but is not limited to the following steps:

[0071] S1, the terminal application sends a TCP service ready message to the platform;

[0072] S2, the SIM card in the terminal receives the SMS data sent by the platform after parsing the TCP service ready message;

[0073] S3, the SIM card application in the terminal performs information security verification based on the SMS data to obtain an information security verification result;

[0074] S4, the terminal application establishes a TCP connection based on the information security verification result, and obtains the data interaction result with the SIM card according to the TCP connection.

[0075] In the embodiment of the present invention, the SIM card is used as a TCP client to communicate with the terminal application. The terminal application starts the TCP service and reports the TCP service ready message to the platform. The platform message processing module parses the message message, calls the SMS service, and forwards the terminal TCP service ready message to the super SIM card. The terminal receives the SMS and transparently transmits it to the super SIM card. The super SIM card triggers the card application to process it, completes the message authentication code verification and decrypts the ciphertext. The super SIM card uses the received port number to request the terminal to establish a TCP connection: the card application sends an OPEN CHANNEL instruction to the terminal, requests to establish a TCP connection with the specified port, and performs corresponding processing according to the command execution result responded by the terminal. If the terminal is currently busy and cannot process the command in time, the response result status value is 0x20, and the card application resends the command to retry. After accumulating 3 failures, no more retries will be performed. If the terminal successfully establishes a TCP connection with the client listening port, the response result status value is 0x00, and the card application parses the response result to obtain the channel identifier ChannelID, and subsequently uses the channel identifier to use and manage the TCP connection. The SIM card uses the established TCP connection to interact with the client application for data.

[0076] The method of the SIM card of the embodiment of the present invention as a TCP client to communicate with the terminal application, the application includes a system of the terminal application, the platform end and the SIM card, the platform end includes a message processing module and a short message gateway; the terminal application is loaded in the user terminal, and includes a specific interface for SIM communication related operations. Its application scenarios are as follows: Figure 2 shown.

[0077] Embodiment 2:

[0078] Figure 3 FIG. 1 is a flow chart of another method for a SIM card to communicate with a terminal application as a TCP client according to an embodiment of the present invention. Figure 3 As shown, including:

[0079] Step 1: The terminal application starts the TCP service and reports the TCP service ready message to the platform.

[0080] In one embodiment of the present invention, configuration data is obtained and the TCP client connection is processed to obtain a TCP client connection processing result; wherein the configuration data includes the target SIM card mobile phone number, the TCP service port number and the authentication Token; based on the TCP client connection processing result, the configuration data is encapsulated into a TCP service ready message packet according to a preset encapsulation format; the terminal application sends the TCP service ready message packet to the platform end through a secure transmission channel.

[0081] Specifically, the main purpose of this step is to start and configure the terminal TCP service, and notify the SIM card of the terminal TCP service readiness message through the platform middleware. The design of random authentication token and random TCP port ensures the security of the connection. The specific execution process of step 1 is as follows:

[0082] 101) The target terminal loads the terminal application provided by the present invention, inputs the SIM card phone number to be connected in the input box control, and clicks to start the connection.

[0083] Among them, the target mobile phone number must be a valid mobile phone number in the SIM card slot of this terminal.

[0084] 102) The terminal application establishes a standard TCP service and randomly selects a port number from the integer range of 1-65535 as the TCP service listening port. If the port number is not available, the next port number is selected.

[0085] 103) The terminal application uses a software pseudo-random number generator to generate an ASCII string of length 16, which is the authentication Token.

[0086] Among them, the authentication Token is used for TCP client access verification. In this step, the terminal hardware-level random number generator can also be used to replace the software pseudo-random number generator to improve the security level.

[0087] 104) The terminal application starts a thread, cyclically waits for processing of TCP client connection, and the service works in a single connection model, that is, after receiving the SIM card client connection, the connection state is cached, other client connections are blocked, and the next connection is processed after the connection is processed.

[0088] 105) The target SIM card phone number input in 101), 102) the terminal TCP service port number and 103) the authentication token are encapsulated into a TCP service ready message according to the following example.

[0089] TCP service ready message example:

[0090] {

[0091] "phoneNumber":"1xxxxxxxxxx",

[0092] "tcpPort":8888,

[0093] "token":"xxxxxxxxx"

[0094] }.

[0095] 106) The terminal application sends the message message 105) to the platform-side TCP message processing module through a secure transmission channel (such as HTTPS).

[0096] Step 2: The platform message processing module parses the message, calls the SMS service, and forwards the terminal TCP service ready message to the SIM card.

[0097] In a trial example of the present invention, the message processing module parses the TCP service ready message to obtain the target SIM card mobile phone number and authentication Token; the SMS message is encapsulated based on the target SIM card mobile phone number and the authentication Token, and the SMS service is called to send the encapsulated SMS message to the SMS gateway; the SIM card in the terminal receives the SMS data sent by the SMS gateway using the full SMS protocol after authenticating the encapsulated SMS message.

[0098] It is understandable that there are two main ways for the platform to reach the SIM card through messages: air text messages and BIP gateways. Both methods can ensure point-to-point contact between the platform and the SIM card. The air text message has a small data carrying capacity, and the message channel has a high arrival rate; the BIP gateway has a strong data carrying capacity, but there is network instability that affects the message reach rate. The TCP service ready message body is relatively small and the communication success rate between the terminal and the SIM card is an important performance indicator. Therefore, the present invention uses the SMS channel as the SIM card TCP connection notification method. The specific implementation method of this step is:

[0099] 201) The message processing module parses the TCP service ready message reported by the terminal application to obtain the target SIM card phone number and authentication Token.

[0100] 202) SMS message encapsulation, field Msg_Fmt, configured as binary to identify the message format, the binary message will be sent directly to the SIM card application and will not be explicitly sent to the terminal as a SMS; field Msg_Content, message content, the present invention mainly includes the terminal application TCP service port information and authentication Token; field Dest_terminal_Id is filled with the target mobile phone number obtained in the previous process.

[0101] 203) The SMS interface adopts the CMPP3.0 protocol, and the platform side calls the SMS service to send the 202) message message to the SMS gateway.

[0102] When the platform calls the SMS service to send SMS to the target mobile phone number, it first needs to register the source_id with the target SMS gateway and open the IP whitelist. This data will be attached to the message as the key data for SMS gateway authentication.

[0103] 204) The SMS gateway authenticates the platform-side SMS message. After successful authentication, the specific message is sent to the target SIM card using the GSM03.48 secure SMS protocol. The protocol has security features such as confidentiality, integrity, anti-counterfeiting, and anti-replay to ensure the security of the communication process.

[0104] Step 3: The terminal receives the SMS and transmits it transparently to the SIM card. The SIM card triggers the application on the card to process and complete the message authentication code verification and decryption of the ciphertext.

[0105] In one embodiment of the present invention, SMS data sent by the SMS gateway is received, and the SMS data is encapsulated into an ENVELOPE command according to the values ​​of the preset SMS protocol parameters TP-PID and TP-DCS; the SIM card in the terminal receives the ENVELOPE command, parses and extracts the target application identifier in the SMS data, matches it with the identifiers of each application on the SIM card to obtain an identifier matching result; based on the identifier matching result, the card application is triggered to perform security verification on the SMS user data to obtain an information security verification result. The specific implementation method of this step is:

[0106] 301) The terminal receives the SMS sent by the SMS gateway, and decides whether to transparently pass the SMS to the SIM card for processing based on the values ​​of the SMS protocol parameters TP-PID and TP-DCS. If the SMS TP-PID parameter value is 0x7F, and the bit1 of the TP-DCS parameter value is 1 and the bit0 is 0, it means that the SMS needs to be passed to the SIM card for processing. The terminal encapsulates the received SMS data into an ENVELOPE command and sends it to the SIM card. The SMS-DELIVER SMS structure is shown in Table 1, and the ENVELOPE command (SMS download) structure is shown in Table 2:

[0107] Table 1

[0108]

[0109] Table 2

[0110] Description Length SMS-PP download tag 1 Length(A+B+C) 1or 2 Device identities A Address B URI truncated 2 SMS TPDU(SMS-DELIVER) C Originating Address D

[0111] 302) The SIM card receives the ENVELOPE command sent by the terminal, parses and obtains the SMS data, further extracts the target application identifier in the SMS data, and matches it with the identifiers of each application on the SIM card. If the match is consistent, it means that the target application of the SMS is found, and the application is triggered to process the SMS data.

[0112] 303) The triggered card application performs security verification on the SMS user data (TP-UD). The specific structure of the SMS user data is shown in Table 3:

[0113] Table 3

[0114]

[0115]

[0116] Furthermore, based on the identification matching result and the security parameter SPI value, it is determined whether the SMS user data is encrypted. If it is determined to be encrypted, the card application uses a preset key to decrypt the data between CNTR and Secured Data, which are all ciphertext, to obtain the plaintext message authentication code CC; MAC calculation is performed on the SMS user data, and the calculated MAC value is compared with the plaintext message authentication code CC to obtain an information security verification result of comparison consistency.

[0117] Specifically, the card application determines whether the SMS is encrypted based on the security parameter SPI value. If encrypted, the data between the CNTR parameter and the Secured Data parameter are all ciphertext. The card application uses the key pre-shared with the platform to decrypt and obtain the plaintext message authentication code CC. It further calculates the MAC for the entire SMS user data and compares the calculated MAC value with the CC. If they are consistent, the SMS data is considered legal, and the port number and authentication Token are parsed from the plaintext data Secured Data. The port number and authentication Token are included in the Secured Data. The specific encoding format is not explained here.

[0118] Step 4: The SIM card uses the received port number to request the terminal to establish a TCP connection.

[0119] In one embodiment of the present invention, an OPEN CHANNEL command is obtained based on the information security verification result, and the port number of the target address parameter of the OPEN CHANNEL command is determined to be the port number in the received SMS data; a request to establish a TCP connection with the port specified in the port number in the received SMS data is obtained, and corresponding processing is performed according to the command execution result of the terminal response request to establish a TCP connection. The specific process of this step is:

[0120] 401) The card application constructs an OPEN CHANNEL command, sets the port number of the command's target address parameter Data destination address to the port number in the received SMS message, and the IP address to the local IP 127.0.0.1. The OPEN CHANNEL command structure is shown in Table 4:

[0121] Table 4

[0122] Description Length Proactive UICC command Tag 1 Length(A+B+C+D+E+F+G+H+I+J+K+L+M+N) 1or 2 Command details A Device identities B Alpha identifier C Icon identifier D Bearer description E Buffer size F Network Access Name G Other address(local address) H Text String(User login) I Text String(User password) J UICC / terminal interface transport level K Data destination address L Text Attribute M Frame Identifier N

[0123] 402) The card application sends an OPEN CHANNEL command to the terminal, requesting to establish a TCP connection with the specified port, and performs corresponding processing according to the command execution result responded by the terminal. If the terminal is currently busy and cannot process the command in time, the response result status value is 0x20, and the card application resends the command to retry. After accumulating 3 failures, no more retries will be made. If the terminal successfully establishes a TCP connection with the client listening port, the response result status value is 0x00, and the card application parses the response result to obtain the channel identifier ChannelID, and subsequently uses the channel identifier to use and manage the TCP connection.

[0124] Step 5: The SIM card uses the established TCP connection to exchange data with the client application.

[0125] In one embodiment of the present invention, a SEND DATA command sent by a receiving card application is obtained, and a corresponding TCP connection is obtained according to the channel identifier of the command, and an authentication token is sent to a TCP client using the corresponding TCP connection; a consistency comparison result of the authentication token obtained by the TCP client based on TCP data processing and the locally cached token is obtained; TCP data notification information is sent to the SIM card based on the consistency comparison result and the ENVELOPE command, and TCP data is sent to the SIM card according to the TCP data notification information and the RECEIVE DATA command to obtain a data interaction result with the SIM card. The specific implementation process of this step is:

[0126] 501) The card application constructs a SEND DATA command, sets the channel identifier of the command's device identification parameter Device identities to the ChannelID returned by the terminal when establishing a TCP connection, and sets the channel data parameter Channel data of the command to the authentication Token. The SEND DATA command structure is shown in Table 5:

[0127] Table 5

[0128] Description Length Proactive UICC command Tag 1 Length(A+B+C+D+E+F+G) 1or 2 Command details A Device identities B Alpha identifier C Icon identifier D Channel data E Text Attribute F Frame Identifier G

[0129] 502) The card application sends SEND DATA to the terminal. The terminal finds the corresponding TCP connection according to the channel identifier of the command and uses the TCP connection to send the authentication Token to the client.

[0130] 503) The client application receives and processes the TCP data of the listening port, obtains the authentication Token, and compares it with the locally cached Token. If they are consistent, it returns an authentication pass result, indicating that the connection is legal. If they are inconsistent, it returns an authentication fail result and closes the TCP connection, indicating that the connection is illegal.

[0131] 504) After judging that the connection is legitimate, the client application responds with authentication success result data. The terminal notifies the SIM card through the ENVELOPE command that there is TCP data to be received, and informs the SIM card of the corresponding channel identifier and the length of the data to be received. After receiving the notification, the SIM card uses the RECEIVE DATA command to obtain TCP data from the terminal. The RECEIVE DATA command structure is shown in Table 6:

[0132] Table 6

[0133] Description Length Proactive UICC command Tag 1 Length(A+B+C+D+E+F+G) 1or 2 Command details A Device identities B Alpha identifier C Icon identifier D Channel data length E Text Attribute F Frame Identifier G

[0134] 505) The card application parses and obtains a successful authentication result, indicating that the client has authenticated the legal identity of the SIM card, and subsequent service data requests can be made between the SIM card and the client application.

[0135] Step 6: Close the TCP connection between the SIM card and the client application.

[0136] Specifically, the client application completes the data interaction with the SIM card, sends the close notification data to the SIM card application, closes the TCP connection, and releases the client connection resources. After receiving the close notification, the card application sends a CLOSE CHANNEL command to the terminal, requesting to close the TCP connection of the specified channel identifier and release the connection resources of the SIM card. The CLOSE CHANNEL command structure is shown in Table 7:

[0137] Table 7

[0138] Description Length Proactive UICC command Tag 1 Length(A+B+C+D+E+F) 1or 2 Command details A Device identities B Alpha identifier C Icon identifier D Text Attribute E Frame Identifier F

[0139] In summary, the method of the SIM card of the present invention as a TCP client communicating with the terminal application is not limited by the mobile terminal and the system, covers all business scenarios, and realizes the communication needs between the SIM card and the mobile terminal; it can effectively solve the problem of small data transmission volume of the SMS channel, effectively increase the length of the transmitted data, and reduce the number of communications required for business communications with the same amount of data. The mobile terminal acts as a TCP server, the network is more stable, the data transmission rate is higher, and the packet loss rate is reduced. Using connection-oriented transmission, data is transmitted in real time, which improves system security and data integrity.

[0140] The method for the SIM card in the embodiment of the present invention to communicate with the terminal application as a TCP client can effectively solve the problems of low coverage of two-way communication terminals, unstable indirect communication network, and limited transmission data volume.

[0141] Embodiment 3:

[0142] In order to implement the above embodiment, Figure 4As shown, this embodiment also provides a system 10 for the SIM card to communicate with the terminal application as a TCP client, and the system 10 includes: a message message sending module 100, a message message parsing module 200, an information security verification module 300 and a data connection interaction module 400;

[0143] The message packet sending module 100 is used for the terminal application to send a TCP service ready message packet to the platform end;

[0144] The message parsing module 200 is used for the SIM card in the terminal to receive the SMS data sent by the platform after parsing the TCP service ready message;

[0145] An information security verification module 300, used for a SIM card application in a terminal to perform information security verification based on the SMS data to obtain an information security verification result;

[0146] The data connection interaction module 400 is used for the terminal application to establish a TCP connection based on the information security verification result, and obtain the data interaction result with the SIM card according to the TCP connection.

[0147] The SIM card of the embodiment of the present invention is used as a system for TCP client to communicate with terminal applications. The terminal application starts the TCP service and reports the TCP service ready message to the platform. The platform message processing module parses the message message, calls the SMS service, and forwards the terminal TCP service ready message to the super SIM card. The terminal receives the SMS and transparently transmits it to the super SIM card. The super SIM card triggers the card application to process it, completes the message authentication code verification and decrypts the ciphertext. The SIM card uses the received port number to request the terminal to establish a TCP connection: the card application sends an OPEN CHANNEL instruction to the terminal, requests to establish a TCP connection with the specified port, and performs corresponding processing according to the command execution result responded by the terminal. If the terminal is currently busy and cannot process the command in time, the response result status value is 0x20, and the card application resends the command to retry. After accumulating 3 failures, no more retries will be performed. If the terminal successfully establishes a TCP connection with the client listening port, the response result status value is 0x00, and the card application parses the response result to obtain the channel identifier ChannelID, and subsequently uses the channel identifier to use and manage the TCP connection. The SIM card uses the established TCP connection to interact with the client application for data.

[0148] The method for the SIM card in the embodiment of the present invention to communicate with the terminal application as a TCP client can effectively solve the problems of low coverage of two-way communication terminals, unstable indirect communication network, and limited transmission data volume.

[0149] Embodiment 4:

[0150] In order to implement the method of the above embodiment, the present invention also provides a computer device, such as Figure 5 As shown, the computer device 600 includes a memory 601 and a processor 602; wherein the processor 602 runs a program corresponding to the executable program code by reading the executable program code stored in the memory 601, so as to implement each step of the method described above.

[0151] In order to implement the above embodiments, the present application also proposes a non-temporary computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the method described in the above embodiments is implemented.

[0152] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present application. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, without contradiction.

[0153] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In the description of this application, the meaning of "plurality" is at least two, such as two, three, etc., unless otherwise clearly and specifically defined.

Claims

1. A method for a SIM card to communicate with a terminal application as a TCP client, characterized in that: The method comprises: The terminal application sends a TCP service ready message to the platform end; wherein the TCP service ready message includes the target SIM card mobile phone number, TCP service port number and authentication Token; The SIM card in the terminal receives the SMS data sent by the platform after parsing the TCP service ready message; wherein the SMS data includes the TCP service port and the authentication token; The SIM card application in the terminal performs information security verification based on the SMS data to obtain an information security verification result; After the SMS data is verified for information security, the SIM card uses the received port number to request the terminal to establish a TCP connection and uses the established TCP connection to interact with the terminal application; The terminal application sends a TCP service ready message to the platform end, including: The terminal application starts the TCP service and obtains configuration data including the target SIM card mobile phone number, TCP service port number and authentication token. The target SIM card mobile phone number is the valid mobile phone number of the SIM card slot of the terminal. The configuration data is encapsulated into a TCP service ready message according to a preset encapsulation format; The terminal application sends the TCP service ready message to the platform end through a secure transmission channel; The platform side includes a message processing module and a short message gateway; the SIM card in the terminal receives the short message data sent by the platform side after parsing the TCP service ready message, including: The target SIM card phone number and authentication token are obtained by parsing the TCP service ready message using a message processing module; Encapsulating the SMS message based on the message processing module, and calling the SMS service to send the encapsulated SMS message to the SMS gateway; The SIM card in the terminal receives the SMS data sent by the SMS gateway using the full SMS protocol after the SMS gateway authenticates the encapsulated SMS message.

2. The method according to claim 1, characterized in that The SIM card application in the terminal performs information security verification based on the SMS data to obtain an information security verification result, including: The terminal receives the SMS data sent by the SMS gateway and encapsulates the SMS data into an ENVELOPE command according to the values ​​of the preset SMS protocol parameters TP-PID and TP-DCS; The SIM card in the terminal receives the ENVELOPE command, parses and extracts the target application identifier in the SMS data, and matches it with the identifiers of each application on the SIM card to obtain an identifier matching result; The card application is triggered to perform security verification on the SMS data based on the identification matching result to obtain an information security verification result.

3. The method according to claim 2, characterized in that The SIM card uses the received port number to request the terminal to establish a TCP connection, including: The SIM card constructs an OPEN CHANNEL command and determines that the port number of the target address parameter of the OPEN CHANNEL command is the port number in the received SMS data. The card application sends an OPEN CHANNEL instruction to the terminal, requesting to establish a TCP connection with the specified port. Perform corresponding processing according to the command execution result of the terminal response request to establish a TCP connection.

4. The method according to claim 3, characterized in that The SIM card uses the established TCP connection to interact with the terminal application for data, including: The card application constructs a SEND DATA command and sends it to the terminal. The terminal finds the corresponding TCP connection based on the channel identifier of the command and uses the TCP connection to send the authentication Token to the card application. The card application receives and processes the TCP data from the listening port, obtains the authentication Token, and compares it with the locally cached Token. If they are consistent, it returns the authentication result, indicating that the connection is legal; After determining that the connection is legitimate, the card application responds with authentication success result data, and the terminal sends TCP data notification information to the SIM card through the ENVELOPE command. After receiving the TCP data notification information, the SIM card uses the RECEIVE DATA command to obtain TCP data from the terminal.

5. The method according to claim 4, characterized in that After the SIM card receives the TCP data notification information and uses the RECEIVE DATA command to obtain the TCP data from the terminal, the method further includes: The terminal application completes the data interaction with the SIM card, sends the close notification data to the SIM card application, closes the TCP connection, and releases the terminal connection resources; The card application receives the close notification and sends a CLOSE CHANNEL command to the terminal, requesting to close the TCP connection with the specified channel identifier and release the connection resources of the SIM card.

6. The method according to claim 1, characterized in that Use a random number generator to generate a 16-character ASCII string as the authentication token.

7. The method according to claim 1, characterized in that The SMS message encapsulation includes: a field Msg_Fmt configured as binary to identify the message format; a field Msg_Content to identify the message content; and a field Dest_terminal_Id filled with the target SIM card mobile phone number.

8. The method according to claim 2, characterized in that: The method of encapsulating the SMS data into an ENVELOPE command according to the preset values ​​of the SMS protocol parameters TP-PID and TP-DCS includes: According to the values ​​of the SMS protocol parameters TP-PID and TP-DCS, determine whether to send the SMS data to the SIM card to obtain a determination result; If the SMS protocol parameter TP-PID parameter value is 0x7F, and the bit1 of the TP-DCS parameter value is 1 and the bit0 is 0, the judgment result is that the SMS data needs to be transmitted, and the terminal encapsulates the received SMS data into an ENVELOPE command and sends it to the SIM card.

9. The method according to claim 2, characterized in that: The triggering of the card application to perform security verification on the SMS data based on the identification matching result to obtain the information security verification result includes: The card application determines whether the SMS data is encrypted based on the security parameter SPI value. If it is encrypted, the card application uses a preset key to decrypt the data between CNTR and Secured Data, which are all ciphertext, to obtain a plaintext message authentication code CC; wherein the structure of the SMS data at least includes CNTR and Secured Data; MAC is calculated for the SMS data, and the calculated MAC value is compared with the plaintext message authentication code CC to obtain an information security verification result with comparison consistency.

10. A system in which a SIM card acts as a TCP client and communicates with a terminal application, characterized in that: include: A message sending module, used for the terminal application to send a TCP service ready message to the platform end; wherein the TCP service ready message includes the target SIM card mobile phone number, TCP service port number and authentication Token; A message parsing module, used for the SIM card in the terminal to receive the SMS data sent by the platform after parsing the TCP service ready message; wherein the SMS data includes the TCP service port and the authentication Token; An information security verification module, used for the SIM card application in the terminal to perform information security verification based on the SMS data to obtain an information security verification result; The data connection interaction module is used to, after information security verification of the SMS data, use the received port number to request the terminal to establish a TCP connection and use the established TCP connection to interact with the terminal application; The message sending module is also used for: The terminal application starts the TCP service and obtains configuration data including the target SIM card mobile phone number, TCP service port number and authentication token. The target SIM card mobile phone number is the valid mobile phone number of the SIM card slot of the terminal. The configuration data is encapsulated into a TCP service ready message according to a preset encapsulation format; The terminal application sends the TCP service ready message to the platform end through a secure transmission channel; The platform side includes a message processing module and a short message gateway; the SIM card in the terminal receives the short message data sent by the platform side after parsing the TCP service ready message, including: The message processing module parses the TCP service ready message to obtain the target SIM card mobile phone number and authentication token; the message processing module encapsulates the SMS message, and calls the SMS service to send the encapsulated SMS message to the SMS gateway; The SIM card in the terminal receives the SMS data sent by the SMS gateway using the full SMS protocol after the SMS gateway authenticates the encapsulated SMS message.

11. A computer device, characterized in that: including a processor and a memory; The processor runs a program corresponding to the executable program code by reading the executable program code stored in the memory, so as to implement the method for the SIM card as a TCP client to communicate with a terminal application according to any one of claims 1 to 9.

12. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method for a SIM card as a TCP client to communicate with a terminal application according to any one of claims 1 to 9 is implemented.

Citation Information

Patent Citations

  • Method, mobile terminal and computer program product for interworking via a card application toolkit

    CN101401068A

  • Method for carrying out data interaction with subscriber identification card and mobile terminal

    CN101835281A