Method and system for inquiring balance of intelligent card based on terminal equipment
Through NFC communication between smart cards and terminal devices, the encrypted transmission of NDEF data storage area and security chips is used to solve the portability and network dependence problems of smart card balance query, and achieve safe and convenient query in a network-free environment.
Patent Information
- Application Number
- CN202510976288.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-16
- Publication Date
- 2025-08-12
- Estimated Expiration
- 2045-07-16
AI Technical Summary
The existing smart card balance query method requires special equipment or relies on public communication networks, resulting in inconvenience in carrying and network delay problems, and the balance cannot be queried in a networkless environment.
Through NFC communication between smart cards and terminal devices, NDEF data storage area and security chips are used to realize encrypted transmission and analysis of smart card balances and transaction records. Terminal devices can query balances without special equipment and network connections.
It realizes the self-query of smart card balance and transaction records without public communication networks, ensuring data security and convenience, and is suitable for most smartphones.
Smart Images

Figure CN120471620A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of smart card data processing, in particular to a method for querying smart card balance based on a terminal device and a system for implementing the method. Background Art
[0002] A smart card is a card equipped with a security chip that stores encrypted data. Because the security chip incorporates security measures to protect the data stored, it is difficult to tamper with. Therefore, smart cards are widely used in the financial sector, such as bus and bank cards.
[0003] When people use smart cards for transactions, they often don't know the balance on their smart cards. For example, when using a bus card, the card's appearance doesn't reveal the balance. If the card's balance is low but the user doesn't know it and needs to use the card immediately, they won't be able to pay for the fare, hindering their use. Currently, there are three ways to check smart card balances. The first is to use a dedicated terminal device. Users must use a dedicated device such as a POS machine or recharge terminal to read the data on the smart card. However, such dedicated terminals are inconvenient to carry and have high production costs, making them inconvenient for personal use. The second method is to use an online app to check the balance. This requires the user to connect to a backend server using the terminal device for authentication and then run a specific app, such as a bank app, on the terminal device to check the balance. However, this method relies on the public communication network, which can lead to network response delays. Furthermore, if the public communication network is unstable, this can affect the balance query operation. The third method is to check the balance via text message. Users must edit a specific text message and send it to a specific number. This method is cumbersome and may incur communication fees. Most existing contactless smart cards are equipped with NFC chips, which communicate with terminal devices. NFC, as a short-range wireless communication technology, has gained widespread adoption in recent years. NDEF, the NFC data exchange format, is a lightweight data format specification for efficiently transferring data between NFC devices. With the increasing popularity of smartphones, NFC functionality is becoming increasingly powerful, allowing smartphones to act as active or passive NFC devices to communicate with other NFC tags or devices.
[0004] Chinese invention patent application publication number CN102737308A discloses a mobile terminal and a method and system for querying smart card information. The mobile terminal includes: a SIM card identity registration module, a security management module, and a near-field wireless communication (NFC) authentication module. The security management module decrypts the encrypted registration information, obtains the decrypted information, and matches the relevant information of the smart card with the decrypted information. If the match is successful, the balance and / or transaction information of the smart card is output.
[0005] However, this method still needs to rely on the public communication network during the process of transmitting the balance and / or transaction information of the smart card, and it is impossible to query the balance of the smart card without connecting to the public communication network. Summary of the Invention
[0006] The first object of the present invention is to provide a method for querying the balance of a smart card based on a terminal device, which does not require the use of special equipment and does not rely on a public communication network.
[0007] A second object of the present invention is to provide a system for querying the balance of a smart card based on a terminal device, which implements the above-mentioned method for querying the balance of a smart card based on a terminal device.
[0008] To achieve the above-mentioned first purpose, the method for querying the balance of a smart card based on a terminal device provided by the present invention includes placing the smart card close to the terminal device; the smart card is provided with a security chip and an NDEF data storage area, and the NDEF data storage area stores the first fee information of the smart card and a query instruction in NDEF format; the smart card sends the first fee information and the query instruction to the terminal device, the terminal device parses the query instruction and sends an APDU command to the smart card, the APDU command includes a command to query the second fee information of the smart card; after the security chip of the smart card receives the APDU command, it obtains the second fee information of the smart card and sends it to the terminal device, and the terminal device displays the received second fee information.
[0009] It can be seen from the above scheme that after the smart card is placed close to the terminal device, the smart card can automatically send the first fee information and the query instruction in NDEF format to the terminal device. In this way, the terminal device can parse the query instruction in NDEF format and convert it into an APDU command that the security chip can recognize, and then send the APDU command to the smart card. The security chip of the smart card obtains the second fee information according to the received APDU command and sends the second fee information to the terminal device.
[0010] In this way, the terminal device can display information such as the smart card balance and transaction history. The entire process does not transmit data through the public communication network, but only relies on the NFC chip between the smart card and the terminal device for communication. Therefore, the balance can be queried even without a public communication network. In addition, since the present invention can query the balance using only a terminal device with NFC function, there is no need to use a dedicated terminal device. Since most smart phones now have NFC function, users can conveniently query the balance of the smart card through the terminal device.
[0011] A preferred solution is that after each transaction of the smart card is completed, the security chip updates the current balance information and the most recent transaction record information to the NDEF data storage area in an atomic operation.
[0012] It can be seen that the data stored in the NDEF data storage area of the smart card already includes the balance of the smart card and several transaction record information. When the smart card sends the first fee information to the terminal device, the terminal device can obtain the balance of the smart card and the transaction record information of the most recent times.
[0013] A further solution is that when the security chip updates the current balance information and the most recent transaction record information to the NDEF data storage area in an atomic operation, it uses a temporary session key to encrypt the first fee information, so that the first fee information stored in the NDEF data storage area is encrypted information.
[0014] As can be seen from this, the first fee information is encrypted. Therefore, after receiving this information, the terminal device needs to decrypt it. In this way, even if the first fee information stored in the NDEF data storage area sent by the smart card is intercepted, without knowing the decryption key, the smart card balance and other information will not be available, thus ensuring the security of data transmission.
[0015] A further solution is to generate a temporary session key using a dynamic random number, UID information during the card life cycle, and a count value.
[0016] It can be seen from this that the temporary session key generated using the above factors is not fixed. Even if a temporary session key is illegally intercepted, the next temporary session key will not be obtained, which can ensure the security of encryption.
[0017] A further solution is that when the smart card sends the encrypted first fee information to the terminal device, it also sends the dynamic random number and the count value.
[0018] It can be seen from this that after receiving the first fee information, the terminal device can use the received dynamic random number and the count value as factors to generate a corresponding temporary session key, thereby correctly decrypting the first fee information.
[0019] A further solution is that after the terminal device obtains the first fee information, it decrypts the first fee information; if the terminal device fails to decrypt the first fee information, the query instruction in the NDEF format is not parsed.
[0020] It can be seen from this that if the terminal device cannot correctly decrypt the first fee information, it means that the terminal device does not match the smart card, or the terminal device is an illegal terminal device. Therefore, the terminal device does not parse the query instruction in NDEF format, that is, it will not send APDU instructions to the smart card, and the smart card will not send the second fee information.
[0021] A further solution is that the second fee information sent by the security chip of the smart card to the terminal device is also information encrypted using the temporary session key.
[0022] It can be seen from this that the second fee information is also encrypted using the same temporary session key as the first fee information. In this way, after the terminal device receives the encrypted second fee information, it can use the same temporary session key to decrypt it, which can improve the security of the transmission of the second fee information.
[0023] A further solution is that the first fee information includes the current balance and a preset number of transaction record information; and the second fee information includes the remaining transaction record information.
[0024] To achieve the above-mentioned second purpose, the system for querying the smart card balance based on the terminal device provided by the present invention includes a smart card and a terminal device, the smart card is provided with a security chip and an NDEF data storage area, the NDEF data storage area stores the first fee information of the smart card and the query instruction in NDEF format; the smart card is used to send the first fee information and the query instruction to the terminal device, the terminal device is used to parse the query instruction and send an APDU command to the smart card, the APDU command includes a command to query the second fee information of the smart card; after the security chip of the smart card receives the APDU command, it obtains the second fee information of the smart card and sends it to the terminal device, and the terminal device displays the received second fee information.
[0025] As can be seen from the above scheme, when the smart card is close to the terminal device, the smart card can automatically send the first fee information and the query instruction in NDEF format to the terminal device. The terminal device decrypts the first fee information and displays it on the terminal device, allowing the user to easily view the balance information of the smart card. In addition, after decrypting the first fee information, the terminal device will also parse the query instruction in NDEF format and convert it into an APDU command that the security chip can recognize. The APDU command is then sent to the smart card. The security chip of the smart card obtains the second fee information based on the received APDU command and sends the second fee information to the terminal device.
[0026] Since the terminal device can display information such as the smart card balance and transaction history, the entire process does not transmit data through the public communication network, but relies solely on the NFC chip between the smart card and the terminal device for communication. Therefore, balance inquiry can be achieved even without a public communication network. In addition, since the present invention can query the balance using only a terminal device with NFC functionality, there is no need for a dedicated terminal device. Since most smartphones now have NFC functionality, users can conveniently query the balance of their smart cards through the terminal device.
[0027] In a preferred solution, the first fee information of the smart card stored in the NDEF data storage area is information encrypted using a temporary session key. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] Figure 1 It is a structural block diagram of an embodiment of a system for querying smart card balance based on a terminal device according to the present invention.
[0029] Figure 2 The present invention is a flowchart of a method for querying a smart card balance based on a terminal device according to an embodiment of the present invention.
[0030] The present invention will be further described below with reference to the accompanying drawings and embodiments. DETAILED DESCRIPTION
[0031] The method for querying the balance of a smart card based on a terminal device of the present invention enables users to query the balance of a smart card using a terminal device such as a smartphone. During the balance query process, no dedicated terminal device is required, nor is reliance on a public communication network. The balance query can be completed only through NFC communication between the smart card and the terminal device.
[0032] System embodiment for querying smart card balance based on terminal device: See also Figure 1In this embodiment, the system for querying the balance of a smart card based on a terminal device includes a smart card 10 and a terminal device 15. Both the smart card 10 and the terminal device 15 have NFC chips and communicate based on their respective NFC chips, that is, the smart card 10 and the terminal device 15 communicate via NFC.
[0033] The smart card 10 is provided with a security chip 11 and an NDEF data storage area 12. The security chip 11 records the balance and transaction history of the smart card 10. Because the security chip 11 adopts security specifications, the data in the security chip 11 is not easily tampered with. Preferably, the security chip 11 is provided with an offline data area for storing offline data. Offline data is data that can be read without security authentication, but offline data can only be read but not modified. In this embodiment, the balance and transaction history of the smart card 10 are stored in the offline data area, and the data in the offline data area can be read by the terminal device 15.
[0034] The NDEF data storage area 12 is used to store data in the NDEF format, which is the NFC data exchange format. In this embodiment, the NDEF data storage area 12 stores encrypted first fee information, which can be transmitted directly from the NDEF data storage area 12 to the terminal device 15. Due to the limited amount of data transmitted between the smart card 10 and the terminal device 15, the first fee information only includes the balance information of the smart card 10 and a small amount of transaction record information, such as only the most recent transaction record information. More transaction record information is stored in the security chip 11. Therefore, the remaining transaction record information recorded by the security chip 11 is referred to as the second fee information.
[0035] Since the first fee information can be directly transmitted to the terminal device 15, in order to ensure the security of data transmission, the security chip 11 needs to encrypt the first fee information. Specifically, the first fee information is encrypted using a preset algorithm and a temporary session key. In this embodiment, the temporary session key is generated using three factors, including a dynamic random number, the UID information during the card's life cycle, and a count value. The dynamic random number is a random number dynamically generated by the security chip 11, the UID information during the card's life cycle is the identity identification code recorded by the security chip 11 and does not change, and the calculated value is the count value generated by the counter inside the security chip 11. Each time the smart card 10 successfully sends the first fee information to the terminal device 15, the count value will automatically increase by 1 and can only increase monotonically and cannot decrease.
[0036] In addition to recording the encrypted first fee information, the NDEF data storage area 12 will also record a dynamic random number and a count value, but will not record the UID information within the card life cycle. In addition, the NDEF data storage area 12 will also store query instructions in NDEF format.
[0037] The terminal device 15 can receive the first fee information from the NDEF data storage area 12 and decrypt the first fee information to obtain the balance of the smart card 10 and the most recent transaction records. Furthermore, the terminal device 15 can receive and parse the query instructions in NDEF format to obtain an APDU command, which can be recognized by the security chip 11. Furthermore, the terminal device 15 can also obtain the second fee information, that is, the remaining transaction record information, from the security chip 11. After obtaining the balance and transaction record information, the terminal device 15 can display the balance and transaction record information, for example, on a display screen or by voice announcement through a speaker.
[0038] Method embodiment for querying smart card balance based on terminal device: The following combination Figure 2 This article introduces a method for displaying the balance of a smart card based on a system that queries the balance of a terminal device. Since the first fee information needs to be decrypted between the smart card and the terminal device, in order to ensure that the terminal device can accurately generate the key required for decryption, before using the terminal device to obtain the balance of the smart card, authentication between the smart card and the terminal device is first required. For example, the smart card authenticates the terminal device, and after the terminal device passes the authentication, it sends the UID information of the smart card within its life cycle to the terminal device, and sends the generation rules of the temporary session key to the terminal device. It should be noted that the authentication between the smart card and the terminal device only needs to be performed once. Once the smart card and the terminal device complete the authentication, no authentication operation is required before each subsequent balance query operation.
[0039] Of course, the identity authentication operation can also be implemented in advance by the smart card issuer through a background program, for example, by pre-binding the terminal device and the smart card through the background program, and pre-writing the UID information of the smart card during its life cycle and the temporary session key generation rules into the terminal device.
[0040] Each time the smart card is used, that is, each time the balance changes, the security chip will record the current balance information and the latest transaction record information, and will also update the current balance information and the latest transaction record information to the NDEF data storage area in an atomic operation. Preferably, when updating the data in the NDEF data storage area, the security chip will use the temporary session key to encrypt the first fee information and store the encrypted first fee information in the NDEF data storage area. Therefore, the NDEF data storage area does not store the plaintext balance information and transaction record information.
[0041] When a user needs to check their balance, they first perform step S1 and place the smart card near the terminal. At this point, the terminal's NFC chip is activated, establishing NFC communication with the smart card. The smart card then performs step S2, sending the encrypted first fee information, dynamic random number, count value, and NDEF-formatted query command stored in the NDEF data storage area to the terminal.
[0042] Next, the terminal device executes step S3 to decrypt the received encrypted first fee information. Since the smart card has already sent the dynamic random number and count value in step S2, and the terminal device has already recorded the UID information of the smart card throughout its lifecycle, the terminal device uses a pre-set temporary session key generation rule to generate a temporary session key based on three factors: the dynamic random number, the UID information throughout the card's lifecycle, and the count value. The terminal device then uses this temporary session key to decrypt the encrypted first fee information, thereby obtaining the plaintext first fee information.
[0043] In addition, the terminal device itself will also record the count value. Since the terminal device records the UID information of the smart card during its life cycle, the count value will automatically increase once each time the terminal device successfully reads the first fee information of the smart card, and the count value can only increase monotonically. In this way, it can ensure that the count value recorded by the terminal device is synchronized with the count value recorded by the security chip. If in step S2, the count value sent from the smart card received by the terminal device is inconsistent with the count value recorded by the terminal device itself, it means that the data sent by the smart card may have been illegally migrated. For example, criminals intercepted the data to be transmitted in the NDEF data storage area of the legal smart card and copied it to an illegal smart card. In this way, since the count value in the intercepted data has not changed, the count value in the intercepted data is not equal to the count value recorded by the terminal device. At this time, the terminal device will not decrypt the first fee information to prevent criminals from illegally obtaining the balance information of the smart card.
[0044] The terminal device also needs to execute step S4 to determine whether the encrypted first fee information is successfully decrypted. If the decryption is unsuccessful, it means that the generated temporary session key is incorrect. It may be that the UID information of the smart card during the card life cycle is inconsistent with the UID information of the card life cycle recorded by the terminal device. In this case, it means that the terminal device is not the terminal device bound to the smart card, that is, the terminal device has not been authenticated with the smart card, and there is a problem of illegal terminal devices reading smart card data. Therefore, if the terminal device cannot correctly decrypt the first fee information, the terminal device will not obtain the first fee information, and the terminal device will not perform the operation of parsing the query instruction in NDEF format.
[0045] If the judgment result of step S4 is yes, indicating that the terminal device can correctly decrypt the first fee information, step S5 is executed, and the terminal device displays the first fee information and parses the query instruction in NDEF format. Since the terminal device provided with an NFC chip can parse data in NDEF format, the terminal device can parse the query instruction in NDEF format without the need for additional installation of an application program, thereby obtaining an APDU command. In this embodiment, the APDU command is a command for querying the second fee information of the smart card, and the APDU command is recognized by the security chip. Preferably, the APDU command is a command that only needs to read the second fee information in the offline data area of the security chip.
[0046] The terminal device then executes step S6 and sends the parsed APDU command to the smart card. The smart card's security chip receives the APDU command. Since this APDU command only reads the second fee information in the offline data area of the security chip, it cannot perform other operations, namely, it cannot read other data, let alone modify the data in the security chip. Therefore, the terminal device cannot rewrite the data in the security chip and can only read the second fee information.
[0047] After receiving the APDU command, the security chip executes step S7 to obtain the second fee information in the offline data area based on the APDU command and send the second fee information to the terminal device. Preferably, before sending the second fee information, the security chip encrypts the second fee information, for example, using the same temporary session key as used to encrypt the first fee information in step S2. That is, the encryption key for the first fee information and the encryption key for the second fee information are the same. In this way, the security chip does not need to generate a new temporary session key, and the terminal device also does not need to generate an additional temporary session key.
[0048] Finally, the terminal device executes step S8, receives the encrypted second fee information sent by the security chip, and decrypts the second fee information using the same temporary session key as in step S3, thereby obtaining the plaintext second fee information, and displays the second fee information on the display screen.
[0049] Through the method of the present invention, users only need to use a terminal device with NFC function to check the balance of the smart card, without using a dedicated device. Moreover, during the entire query process, neither the smart card nor the terminal device needs to be connected to the public communication network. In other words, the balance can be queried even in scenarios where there is no public communication network, providing great convenience for balance query. Because the terminal device does not need to be connected to the public communication network during the balance query process, it can also ensure that the balance and transaction record information of the smart card will not be leaked through the public communication network.
[0050] In addition, since the first fee information and the second fee information sent by the smart card to the terminal device are encrypted, even if the data sent by the smart card is illegally intercepted, or an illegal terminal device reads the balance of the smart card, the illegal smart card cannot decrypt the first fee information and cannot obtain the balance information and transaction record information of the smart card, thereby ensuring that the balance information of the smart card will not be illegally read.
[0051] Finally, it should be emphasized that the above are only preferred embodiments of the present invention and are not intended to limit the present invention. For those skilled in the art, the present invention may have various changes and modifications. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. A method for querying a smart card balance based on a terminal device, comprising: Place the smart card close to the terminal device; Its characteristics are: The smart card is provided with a security chip and an NDEF data storage area, wherein the NDEF data storage area stores the first fee information of the smart card and a query instruction in NDEF format; The smart card sends the first fee information and the query instruction to the terminal device, the terminal device parses the query instruction and sends an APDU command to the smart card, the APDU command including a command for querying the second fee information of the smart card; After receiving the APDU command, the security chip of the smart card obtains the second fee information of the smart card and sends it to the terminal device, and the terminal device displays the received second fee information.
2. The method for querying the smart card balance based on a terminal device according to claim 1, characterized in that: After each transaction of the smart card is completed, the security chip updates the current balance information and the most recent transaction record information to the NDEF data storage area in an atomic operation manner.
3. The method for querying the smart card balance based on a terminal device according to claim 2, characterized in that: When the security chip updates the current balance information and the most recent transaction record information to the NDEF data storage area in an atomic operation, the security chip uses the temporary session key to encrypt the first fee information, so that the first fee information stored in the NDEF data storage area is encrypted information.
4. The method for querying the smart card balance based on a terminal device according to claim 3, characterized in that: The temporary session key is generated using a dynamic random number, UID information within the card life cycle, and a count value.
5. The method for querying the smart card balance based on a terminal device according to claim 4, characterized in that: When the smart card sends the encrypted first fee information to the terminal device, it sends the dynamic random number and the count value together.
6. The method for querying the smart card balance based on a terminal device according to claim 3, characterized in that: After obtaining the first fee information, the terminal device decrypts the first fee information; If the terminal device fails to decrypt the first fee information, the terminal device does not parse the query instruction in the NDEF format.
7. The method for querying the balance of a smart card based on a terminal device according to any one of claims 3 to 6, characterized in that: The second fee information sent by the security chip of the smart card to the terminal device is also information encrypted using the temporary session key.
8. The method for querying a smart card balance based on a terminal device according to any one of claims 1 to 6, characterized in that: The first fee information includes the current balance and a preset number of transaction record information; The second fee information includes remaining transaction record information.
9. A system for querying smart card balance based on a terminal device, comprising a smart card and a terminal device, characterized in that: The smart card is provided with a security chip and an NDEF data storage area, wherein the NDEF data storage area stores the first fee information of the smart card and a query instruction in NDEF format; The smart card is used to send the first fee information and the query instruction to the terminal device, and the terminal device is used to parse the query instruction and send an APDU command to the smart card, where the APDU command includes a command to query the second fee information of the smart card; After receiving the APDU command, the security chip of the smart card obtains the second fee information of the smart card and sends it to the terminal device, and the terminal device displays the received second fee information.
10. The system for querying smart card balance based on a terminal device according to claim 9, characterized in that: The first fee information of the smart card stored in the NDEF data storage area is information encrypted using a temporary session key.
Citation Information
Patent Citations
Mobile terminal and method and system for inquiring information of intelligent card
CN102737308A
Method and apparatus for realizing peer-to-peer communication of near field communication
CN106845974A
NFC-SIM card supporting electronic wallet, system and transaction processing method
CN115796850A
SAM card control system and method
CN119483960A
System and method for manufacturing retort pouch food
KR102623725B1