Method for detecting a smart card program, detection system and electronic device

CN121785917BActive Publication Date: 2026-09-22GUANGDONG CHUTIAN DRAGON SMART CARD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511905206.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-12-17
Publication Date
2026-09-22
Estimated Expiration
2045-12-17

AI Technical Summary

Technical Problem

[0003]现有技术中,通常采用的方法是通过比对商用卡与认证样卡的功能及性能来判断程序是否被修改,但这种方法难以发现那些内部逻辑已被篡改但外部行为保持一致的恶意程序

Benefits of technology

[0032]本申请实施例提供了一种智能卡程序的检测方法、检测系统以及电子设备,通过引入随机数并指定卡内任意范围和任意长度的程序进行摘要计算,可以灵活地在产品入库阶段对卡片进行全面校验,以及在卡片商用阶段对核心代码进行针对性校验,从而避免智能卡生产厂家对产品程序的预先更改并有效防止黑客的恶意破坏,进而解决了监管机构无法有效监控商用智能卡程序与认证程序一致性的问题,保证了智能卡在生命周期内的程序安全。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121785917B_ABST
    Figure CN121785917B_ABST
Patent Text Reader

Abstract

The application provides a smart card program detection method, a detection system and an electronic device, including: a transmission module obtains an identity of a smart card and sends the identity to a detection module; the detection module generates a detection strategy according to the identity, determines a target standard card program file, and calculates first digest information corresponding to the target standard card program file; the detection module generates a detection instruction based on the detection strategy, and sends the detection instruction to a smart card detection program through the transmission module; the smart card detection program calculates second digest information corresponding to a current smart card program based on the received detection instruction, and sends the second digest information to the detection module through the transmission module; and the detection module judges whether the first digest information and the second digest information are consistent, and if so, determines that the current smart card program is a legal program. In this way, unpredictable verification can be performed on the smart card program, so that the program is prevented from being maliciously tampered with, and the security of the smart card is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of smart card technology, and in particular to a method, system and electronic device for detecting smart card programs. Background Technology

[0002] Smart cards, due to their high security, are widely used in financial payments, communication authentication, transportation, and social security services. In these application scenarios, commercially issued smart card programs must adhere to standard programs that have passed testing and certification to ensure transaction security and protect user rights.

[0003] In existing technologies, a common method to determine whether a program has been modified is by comparing the functionality and performance of commercial cards with those of authentication sample cards. However, this method struggles to detect malicious programs whose internal logic has been altered while maintaining consistent external behavior. Some methods also involve pre-installing verification programs within the smart card to validate code integrity through self-verification. However, the verification logic itself can be tampered with by attackers or malicious vendors, rendering the detection mechanism ineffective. Summary of the Invention

[0004] In view of this, the purpose of this application is to provide a method, system and electronic device for detecting smart card programs, which generates dynamic and random detection instructions through an external system to perform unpredictable verification of the smart card program, thereby preventing the program from being maliciously tampered with and improving the security of the smart card.

[0005] In a first aspect, the present invention provides a method for detecting a smart card program, applied to a detection system, the detection system including a smart card detection program, a transmission module, and a detection module; the smart card detection program is pre-installed on the smart card; the detection module is communicatively connected to the transmission module; the detection module pre-stores at least one standard card program file; the method includes: The transmission module obtains the smart card's identification identifier and sends it to the detection module.

[0006] The detection module generates a detection strategy based on the received identity identifier, determines the target standard card program file corresponding to the identity identifier from the standard card program file, and calculates the first digest information corresponding to the target standard card program file based on the detection strategy.

[0007] The detection module generates detection instructions based on the detection strategy and sends the detection instructions to the smart card detection program through the transmission module.

[0008] Based on the received detection command, the smart card detection program calculates the second digest information corresponding to the current smart card program of the smart card, and sends the second digest information to the detection module through the transmission module.

[0009] The detection module determines whether the first digest information and the second digest information are consistent. If they are consistent, the current smart card program is determined to be a legitimate program.

[0010] In an optional implementation, the detection module includes a sampling detection generation unit and a sample card archive unit.

[0011] The steps of the detection module generating a detection strategy based on the received identity identifier include: Based on the received identity identifier, the sample card file unit traverses the standard card program file, determines the target standard card program file corresponding to the identity identifier, and sends the boundary information corresponding to the standard card program file to the sampling and testing generation unit.

[0012] The sampling detection generation unit generates a detection strategy based on a preset random number algorithm and the received boundary information, and sends the detection strategy and identity identifier to the sample card file unit; the detection strategy includes at least one program start address and detection length.

[0013] In an optional implementation, the step of determining the target standard card program file corresponding to the identity identifier from the standard card program file, and calculating the first digest information corresponding to the target standard card program file based on the detection strategy, includes: Based on the detection strategy and identity identifier, as well as the program start address and detection length in the detection strategy, the sample card file unit determines the target code segment corresponding to the standard card program file, and calculates the first digest information corresponding to the target code segment based on the preset digest algorithm.

[0014] The sample card file unit sends the first summary information to the sampling test generation unit.

[0015] In an optional implementation, the step of the detection module generating a detection command based on a detection strategy and sending the detection command to the smart card detection program via a transmission module includes: The sampling detection generation unit generates detection instructions based on the detection strategy; the detection instructions are used to instruct the smart card detection program to calculate the summary information corresponding to the program start address and detection length.

[0016] The sampling detection generation unit encrypts the detection command based on a preset encryption algorithm to obtain the encrypted detection command.

[0017] The sampling detection generation unit transmits the encrypted detection instructions to the smart card detection program via the transmission module.

[0018] In an optional implementation, the detection module includes a sampling detection generation unit and a detection result notification unit.

[0019] After the detection module determines whether the first digest information and the second digest information are consistent, the method further includes: If the first summary information is inconsistent with the second summary information, the sampling detection generation unit will send the inconsistency judgment result to the detection result notification unit.

[0020] The detection result notification unit generates an anomaly notification based on the inconsistent judgment result and sends the anomaly notification to the preset business system so that the preset business system terminates the current transaction.

[0021] In an optional implementation, the detection module includes a sampling detection generation unit and a detection result notification unit; after the step of determining whether the first digest information and the second digest information are consistent, and if they are consistent, determining that the current smart card program is a legitimate program, the method further includes: The sampling inspection generation unit sends the consistent judgment results to the inspection result notification unit.

[0022] The detection result notification unit generates a normal notification based on the consistent judgment result and sends the normal notification to the preset business system so that the preset business system can continue the current transaction.

[0023] In an optional implementation, the step of the transmission module obtaining the smart card's identity identifier includes: The transmission module reads at least one of the serial number, user identification code, and chip identifier stored in the smart card as an identity identifier.

[0024] Secondly, the present invention provides a detection system, including a smart card detection program, a transmission module, and a detection module; the smart card detection program is pre-installed on the smart card; the detection module is communicatively connected to the transmission module; and a standard card program file is pre-stored in the detection module.

[0025] The transmission module is used to acquire the smart card's identification identifier and send it to the detection module.

[0026] The detection module is used to generate a detection strategy based on the received identity identifier, determine the target standard card program file corresponding to the identity identifier from the standard card program file, and calculate the first digest information corresponding to the target standard card program file based on the detection strategy.

[0027] The detection module is used to generate detection instructions based on the detection strategy and send the detection instructions to the smart card detection program through the transmission module.

[0028] The smart card detection program is used to calculate the second digest information corresponding to the current smart card program of the smart card based on the received detection command, and send the second digest information to the detection module through the transmission module.

[0029] The detection module is used to determine whether the first digest information and the second digest information are consistent. If they are consistent, the current smart card program is determined to be a legitimate program.

[0030] Thirdly, the present invention provides an electronic device, including a memory and a processor, wherein the memory stores computer-executable commands that can run on the processor, and the processor executes the computer-executable commands to implement the detection method of the smart card program of any of the foregoing embodiments.

[0031] Fourthly, the present invention provides a computer-readable storage medium storing computer instructions, which, when executed by a processor, implement a detection method for a smart card program as described in any of the foregoing embodiments.

[0032] This application provides a method, system, and electronic device for detecting smart card programs. By introducing random numbers and specifying a program of arbitrary range and length within the card for digest calculation, it is possible to flexibly perform comprehensive verification of cards during the product warehousing stage and targeted verification of core code during the card commercialization stage. This avoids smart card manufacturers from making pre-modifications to the product program and effectively prevents malicious damage by hackers. It also solves the problem that regulatory agencies cannot effectively monitor the consistency between commercial smart card programs and authentication programs, ensuring the program security of smart cards throughout their lifecycle.

[0033] Other features and advantages of this application will be set forth in the following description and will be apparent in part from the description or may be learned by practicing the application. The objectives and other advantages of this application are realized and obtained through the structures particularly pointed out in the description, claims and drawings.

[0034] To make the above-mentioned objectives, features and advantages of this application more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description

[0035] To more clearly illustrate the technical solutions in the specific embodiments of this application or the prior art, the drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.

[0036] Figure 1 This is a schematic diagram of the detection system provided in an embodiment of this application; Figure 2 This is a schematic diagram of a smart card partition provided in an embodiment of this application; Figure 3 This is a schematic diagram of the detection module provided in an embodiment of this application; Figure 4 A flowchart of a smart card program detection method provided in an embodiment of this application; Figure 5 A schematic diagram of an electronic device provided in an embodiment of this application.

[0037] Icons: 1-Smart card testing program; 2-Transmission module; 3-Detection module; 31-Sampling test generation unit; 32-Sample card file unit; 33-Detection result notification unit; 4-Smart card function program area; 5-Smart card testing program area; 6-Smart card data area; 71-Processor; 72-Memory; 73-Bus; 74-Communication interface. Detailed Implementation

[0038] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0039] To facilitate understanding of this embodiment, the embodiments of this application will be described in detail below.

[0040] This application provides a detection system, referring to... Figure 1 The detection system includes a smart card detection program 1, a transmission module 2, and a detection module 3; the smart card detection program 1 is pre-installed on the smart card; the detection module 3 is communicatively connected to the transmission module 2; and the detection module 3 pre-stores a standard card program file.

[0041] Here, smart card detection program 1 is a verification program pre-installed and running on the smart card. (Refer to...) Figure 2 In one optional implementation, the internal storage area of ​​the smart card can be divided into a smart card function program area 4, a smart card detection program area 5, and a smart card data area 6. The smart card detection program 1 is the verification program running in the smart card detection program area 5.

[0042] Specifically, the smart card detection program 1 can calculate the digest information of any specified range and length of program within the smart card based on the calculation instructions generated by the detection module 3. Optionally, the specific digest information algorithm can be SHA1 (Secure Hash Algorithm 1), MD5 (Message-Digest Algorithm 5), HASH (hash function), CRC (Cyclic Redundancy Check), etc.

[0043] The detection module 3 is communicatively connected to the transmission module 2.

[0044] The transmission module 2 is an interactive device that connects the smart card and the detection module 3. In different scenarios, the transmission module 2 can be a POS machine, a bank ATM, a card reader on a personal computer, a dedicated card acceptance terminal, or a smartphone with NFC functionality. Its core function is to achieve contact or contactless connection with the smart card and to communicate with the detection module 3 via the network.

[0045] The detection module 3 is the back-end processing center, which can be a single server or a distributed system in the cloud. The detection module 3 pre-stores at least one standard card program file, that is, an image file of a smart card program that has been tested and certified by an authoritative institution and is considered legitimate.

[0046] The transmission module 2 is used to obtain the identity identifier of the smart card and send the identity identifier to the detection module 3.

[0047] Detection module 3 is used to generate a detection strategy based on the received identity identifier, determine the target standard card program file corresponding to the identity identifier from the standard card program file, and calculate the first digest information corresponding to the target standard card program file based on the generated detection strategy.

[0048] The detection module 3 is also used to generate detection instructions based on the detection strategy and send the detection instructions to the smart card detection program 1 through the transmission module 2.

[0049] The smart card detection program 1 is used to calculate the second digest information corresponding to the current smart card program of the smart card based on the received detection command, and send the second digest information to the detection module 3 through the transmission module 2.

[0050] The detection module 3 is used to determine whether the first digest information and the second digest information are consistent. If they are consistent, the current smart card program is determined to be a legitimate program.

[0051] Here, the smart card detection program 1 receives detection instructions from the transmission module 2, uses preset algorithms such as SHA1 and MD5, and calculates the second digest information of the code segment corresponding to the current function program of the smart card based on any range and length specified in the detection instructions. After the calculation is completed, the second digest information is fed back to the detection module 3 through the transmission module 2.

[0052] The transmission module 2 is used to obtain the smart card's identification (such as serial number) and send it to the detection module 3; send or transmit the detection instructions (containing the detection program range) generated by the detection module 3 to the detection program on the smart card; and also to receive the second digest information calculated and returned by the smart card detection program 1, and feed it back or send it to the detection module 3.

[0053] The detection module 3 receives the smart card identification identifier, generates a detection strategy based on the identifier, locates the corresponding standard card program file according to the identifier, and calculates the first digest information of the standard file within the policy scope. Simultaneously, it generates a detection command based on the strategy and sends it to the smart card. After receiving the second digest information returned by the smart card, it determines whether the two are consistent. If they are consistent, the current smart card program is determined to be a legitimate program.

[0054] In an optional implementation, refer to Figure 3 The detection module 3 includes: a sampling detection generation unit 31, a sample card file unit 32, and a detection result notification unit 33.

[0055] The sample card archive unit 32 is used to reserve and store various standard card program files (i.e., sample card programs) that have passed testing. The sampling test generation unit 31 and the test result notification unit 33 are both communicatively connected to the sample card archive unit 32.

[0056] The sample card file unit 32 is used to traverse the standard card program file based on the received identity identifier, determine the target standard card program file corresponding to the identity identifier, and send the boundary information corresponding to the standard card program file to the sampling detection generation unit 31.

[0057] The sampling detection generation unit 31 is used to generate a detection strategy based on a preset random number algorithm and the received boundary information, and send the detection strategy and identity identifier to the sample card file unit 32; the detection strategy includes at least one program start address and detection length.

[0058] In an optional implementation, the sample card file unit 32 is used to determine the target code segment corresponding to the standard card program file based on the detection strategy and identity identifier, based on the program start address and detection length in the detection strategy, and to calculate the first digest information corresponding to the target code segment based on a preset digest algorithm.

[0059] Sample card file unit 32 is used to send the first summary information to the sampling detection generation unit 31.

[0060] In an optional implementation, the sampling detection generation unit 31 is used to generate a detection instruction based on the detection strategy; the detection instruction is used to instruct the smart card detection program 1 to calculate the summary information corresponding to the program start address and the detection length.

[0061] The sampling detection generation unit 31 is used to encrypt the detection command based on a preset encryption algorithm to obtain the encrypted detection command.

[0062] The sampling detection generation unit 31 is used to transmit the encrypted detection command to the smart card detection program 1 via the transmission module 2.

[0063] In an optional implementation, the sampling detection generation unit 31 is used to send the inconsistency judgment result to the detection result notification unit 33 when the first summary information and the second summary information are inconsistent.

[0064] The detection result notification unit 33 is used to generate an abnormal notification based on the inconsistent judgment result and send the abnormal notification to the preset business system so that the preset business system terminates the current transaction.

[0065] In an optional implementation, the sampling detection generation unit 31 is used to send the consistent judgment result to the detection result notification unit 33.

[0066] The detection result notification unit 33 is used to generate a normal notification based on the consistent judgment result and send the normal notification to the preset business system so that the preset business system can continue the current transaction.

[0067] In an optional implementation, the transmission module 2 is used to read at least one of the serial number, user identification code, and chip identifier stored in the smart card as an identity identifier.

[0068] Here, the sampling inspection generation unit 31 is the core control unit of the inspection module 3, responsible for generating inspection strategies, initiating comparisons, and managing the process. The sample card file unit 32 is the database for storing programs in the inspection module 3; it pre-stores various standard card program files that have passed testing. The inspection result notification unit 33 is the output of the inspection module 3, responsible for processing and issuing inspection conclusions.

[0069] Based on the above embodiments, this application provides a method for detecting smart card programs, applied to a detection system, with reference to... Figure 4 The detection method of the smart card program includes: Step S101: The transmission module obtains the smart card's identity identifier and sends the identity identifier to the detection module.

[0070] Here, when the smart card establishes a connection with the transmission module (for example, when a user swipes the card on a POS machine or places the card on a card reader), the transmission module first sends a request to the smart card to read the identity identifier.

[0071] In an optional implementation, step S101, where the transmission module obtains the smart card's identity identifier, includes: The transmission module reads at least one of the serial number, user identification code, and chip identifier stored in the smart card as an identity identifier.

[0072] After the transmission module reads the identity identifier, it sends the identity identifier to the detection module through a secure network connection (such as HTTPS (Hypertext Transfer Protocol), VPN (Virtual Private Network), or financial private network).

[0073] In step S102, the detection module generates a detection strategy based on the received identity identifier, determines the target standard card program file corresponding to the identity identifier from the standard card program file, and calculates the first digest information corresponding to the target standard card program file based on the detection strategy.

[0074] Here, after receiving the identity identifier, the detection module uses the received identity identifier as an index to search in the pre-stored standard card program file library to determine the unique target standard card program file corresponding to the identity identifier.

[0075] The detection module generates a detection strategy based on the received identity identifier. The detection strategy defines the specific location and scope within the smart card program to be verified in this detection.

[0076] In one implementation, the detection strategy can be randomly generated. For example, the detection module generates one or more random program start addresses (M1, ..., Mn) and corresponding detection lengths (L1, ..., Ln) based on a preset random number algorithm and combined with program boundary information obtained from the standard card program file. This program address range can include the reserved patch upgrade program area range.

[0077] In another implementation, the detection strategy can be preset or dynamically determined based on the scenario. For example, during the product acceptance phase, the detection strategy can be set to more comprehensive and complex rules to cover as much program code as possible. However, during the commercial transaction phase, to improve performance, the detection strategy can be configured to verify only core critical programs (such as the payment kernel, security algorithm library, etc.).

[0078] The detection strategy may include at least a program start address and a detection length.

[0079] The scope of the detection strategy is not limited to the pre-installed firmware on the smart card at the factory. In practical applications, smart cards often have full lifecycle maintenance and upgrade capabilities. That is, after the card is issued, new program code, functional modules, or repair packages can be downloaded to the card through patching mechanisms, over-the-air downloads, or script downloads.

[0080] Therefore, the target standard card program file should not only contain the basic version program at the factory, but also subsequent patches, update packages, or new applications loaded into the card via download. Correspondingly, when generating the detection strategy, the detection module dynamically updates the storage address area where the patch program is located to the detectable boundary information. The starting address and detection length of the program generated by the detection strategy can fall within the storage space of the patch program, thereby ensuring that subsequent patched, attached, or added code logic can also be subjected to equally effective anti-tampering verification.

[0081] In addition to the aforementioned patches, the detection scope of this application can also cover the following situations to adapt to different smart card software architectures and business needs: For smart cards that support multiple application management platforms or open operating systems, the card issuer or third-party service provider may dynamically download and install new applications after the card is issued. These dynamically loaded bytecode or executable files also fall within the scope of the smart card program in this application.

[0082] When a smart card operating system uses a shared library mechanism, multiple upper-layer applications may call the same piece of common code. Detection strategies can perform high-frequency sampling on these shared areas.

[0083] Based on the detection strategy, the detection module extracts the corresponding code segment (i.e., the target code segment) specified by the detection strategy from the established standard card program file, and calculates the digest corresponding to the target code segment using the same digest algorithm preset on the smart card. This digest is the first digest information (B1). The first digest information is the expected correct result of this detection.

[0084] In step S103, the detection module generates a detection command based on the detection strategy and sends the detection command to the smart card detection program through the transmission module.

[0085] Here, the detection module encapsulates the detection strategy into one or more detection instructions. A detection instruction is a specific command that the smart card detection program can recognize and execute.

[0086] In a preferred embodiment, in order to prevent attackers from intercepting or tampering with the instructions during transmission, the detection module can encrypt the detection instructions based on a preset encryption algorithm (such as using a symmetric key or an asymmetric key) to obtain the encrypted detection instructions.

[0087] The detection module sends the detection command (encrypted or unencrypted) to the transmission module, which then transmits the command to the smart card, where it is received by the smart card detection program.

[0088] In step S104, the smart card detection program calculates the second digest information corresponding to the current smart card program based on the received detection command, and sends the second digest information to the detection module through the transmission module.

[0089] Here, after receiving the detection command, the smart card detection program parses the command content and obtains the starting address and length of the program to be detected.

[0090] The smart card detection program accesses the smart card's own program storage area, reads the code segment of the currently running smart card program within the specified range, and calculates the digest information of the code segment using a preset digest algorithm (consistent with the algorithm used by the detection module). This digest is the second digest information (B2). The second digest information is the calculation result of the actual smart card program.

[0091] After the calculation is completed, the smart card detection program returns the second digest information as response data to the transmission module, which then forwards it to the detection module.

[0092] Step S105: The detection module determines whether the first digest information and the second digest information are consistent. If they are consistent, the current smart card program is determined to be a legitimate program.

[0093] Here, after receiving the second digest information returned from the smart card, the detection module compares it with the first digest information that it has calculated and stored itself.

[0094] If the judgment result is that B1 equals B2, the detection module determines that the current smart card program of the smart card is legal and consistent with the standard program file that has passed the test and certification.

[0095] If the result is that B1 is not equal to B2, the detection module determines that the current smart card program is abnormal and may have been tampered with by the manufacturer or implanted with malicious programs by hackers.

[0096] In an optional implementation, the testing module includes a sampling test generation unit and a sample card archive unit. The sample card archive unit is used to pre-store various sample card programs that have passed the tests, i.e., standard card program files.

[0097] In step S102, the step of the detection module generating a detection strategy based on the received identity identifier includes the following steps S201-S202.

[0098] In step S201, the sample card file unit, based on the received identity identifier, traverses the standard card program file, determines the target standard card program file corresponding to the identity identifier, and sends the boundary information corresponding to the standard card program file to the sampling detection generation unit.

[0099] Here, the sample card file unit, based on the identity identifier received from the transmission module (e.g., the unique serial number of the smart card), traverses its internally stored standard card program files (i.e., various tested sample card programs) to find and determine the target standard card program file corresponding to the identity identifier. After determining the corresponding target standard card program file, the sample card file unit also obtains the boundary information corresponding to the standard card program file, such as the total length of the program file or the range of legal program code start and end addresses. The sample card file unit then sends the boundary information to the sampling inspection generation unit.

[0100] In step S202, the sampling detection generation unit generates a detection strategy based on a preset random number algorithm and the received boundary information, and sends the detection strategy and identity identifier to the sample card file unit; the detection strategy includes at least one program start address and detection length.

[0101] Here, the sampling detection generation unit generates a detection strategy based on a preset random number algorithm and the received boundary information. Specifically, the sampling detection generation unit can generate a random number of a certain length and use this random number to select one or more detection segments in the card program within the range defined by the boundary information. Therefore, the detection strategy specifically includes at least one program start address (e.g., M1) and a corresponding detection length (e.g., L1), and may also include multiple start addresses and detection lengths (e.g., start address M1, length L1, ..., start address Mn, length Ln), and the number of detection segments can be determined by the sampling detection generation unit.

[0102] In one specific embodiment, the detection strategy can be generated in different ways based on the card's lifecycle. For example, during the smart card product's warehousing and acceptance phase, more complex and comprehensive inspection rules can be generated to perform segment-by-segment program verification on the card, achieving comprehensive detection. However, during the commercialization phase of the card, to improve performance, it can be configured to perform targeted verification only on core and critical programs.

[0103] After generating the detection strategy, the sampling detection generation unit sends the detection strategy and identification to the sample card file unit.

[0104] In an optional implementation, step S102, which involves determining the target standard card program file corresponding to the identity identifier from the standard card program file and calculating the first digest information corresponding to the target standard card program file based on the detection strategy, includes the following steps S301-S302.

[0105] In step S301, the sample card file unit determines the target code segment corresponding to the standard card program file based on the detection strategy and identity identifier, as well as the program start address and detection length in the detection strategy, and calculates the first digest information corresponding to the target code segment based on the preset digest algorithm.

[0106] Here, after receiving the detection strategy and identification from the sampling detection generation unit, the sample card file unit locates the unique target standard card program file based on the identification. Then, based on the program start address and detection length contained in the detection strategy, the sample card file unit extracts the corresponding target code segment from the target standard card program file.

[0107] The selection of target code segments has broad applicability and flexibility, and its content is not limited to a single application code.

[0108] The target code segment can include the initial program code pre-installed in the original sample card, or it can include program code segments that have been modified or upgraded subsequently through over-the-air downloads or patching mechanisms. Whether it's compliance testing for the factory version or incremental code testing for version iterations of already issued cards, the embodiments provided in this application can effectively cover both.

[0109] In addition, to ensure comprehensive detection and prevent the covert implantation of malicious code, the target code segment may also include the following or a combination thereof: 1. Smart card operating system code and underlying driver library: It not only detects upper-layer applications, but also performs integrity verification on the underlying environment that supports the application's operation.

[0110] 2. Static configuration data and parameter tables: including but not limited to file system structure information, preset communication parameters, encryption algorithm configuration tables, etc., to prevent attackers from changing the program execution logic by tampering with key configuration parameters.

[0111] 3. Reserved storage areas or blank filling areas: Attackers often tend to use gaps between program code or unused storage space to hide malicious instructions. Performing digest calculations on these non-functional areas can effectively discover hidden malicious code.

[0112] 4. Interrupt vector table or jump table: Prevent attackers from hijacking the control flow by modifying the program entry address.

[0113] Any standard card program file containing definite and predictable baseline data can be included in the target code segment, thereby enabling comprehensive monitoring of the smart card's storage space.

[0114] After determining the target code segment, the sample card file unit calculates the first digest information (B1) corresponding to the target code segment based on a preset digest algorithm. The preset digest algorithm used here should be consistent with the digest algorithm used by the smart card detection program, such as SHA1, MD5, HASH, or CRC algorithms.

[0115] In step S302, the sample card file unit sends the first summary information to the sampling detection generation unit.

[0116] Here, after the calculation is completed, the sample card file unit sends the first summary information to the sampling inspection generation unit. Upon receiving the first summary information, the sampling inspection generation unit stores it.

[0117] In an optional implementation, step S103 includes the following steps S401-S403.

[0118] Step S401: The sampling detection generation unit generates a detection instruction based on the detection strategy; the detection instruction is used to instruct the smart card detection program to calculate the summary information corresponding to the program start address and detection length.

[0119] Here, the sampling detection generation unit generates detection instructions based on the detection strategy. A detection instruction is a specific formatted command used to instruct the smart card detection program to calculate the digest information corresponding to the program's starting address and detection length.

[0120] In step S402, the sampling detection generation unit encrypts the detection command based on a preset encryption algorithm to obtain the encrypted detection command.

[0121] Here, in order to ensure the security of instruction transmission and prevent the instruction from being intercepted or tampered with during transmission, the sampling detection generation unit can encrypt the detection instruction based on a preset encryption algorithm to obtain the encrypted detection instruction.

[0122] In step S403, the sampling detection generation unit transmits the encrypted detection command to the smart card detection program via the transmission module.

[0123] Here, the sampling detection generation unit sends the encrypted detection command to the transmission module (such as a POS machine or card reader), and the transmission module then transmits the command to the smart card detection program running on the smart card.

[0124] In an optional implementation, the detection module includes a detection result notification unit.

[0125] After step S105, in which the detection module determines whether the first digest information and the second digest information are consistent, the method further includes: If the first summary information is inconsistent with the second summary information, the sampling detection generation unit will send the inconsistency judgment result to the detection result notification unit.

[0126] The detection result notification unit generates an anomaly notification based on the inconsistent judgment result and sends the anomaly notification to the preset business system so that the preset business system terminates the current transaction.

[0127] Here, the detection result notification unit generates an anomaly notification based on the inconsistent judgment result and sends the anomaly notification to the preset business system, so that the preset business system terminates the current transaction or executes other preset anomaly handling procedures. At the same time, the smart card's identity can be added to the blacklist for further investigation.

[0128] In an optional implementation, after step S105, the method further includes: The sampling inspection generation unit sends the consistent judgment results to the inspection result notification unit.

[0129] The detection result notification unit generates a normal notification based on the consistent judgment result and sends the normal notification to the preset business system so that the preset business system can continue the current transaction.

[0130] Here, the detection result notification unit generates a normal notification based on the consistent judgment result and sends the normal notification to the preset business system. Based on the normal notification (i.e., the inspection result is normal), the business system allows subsequent business processes to continue normally.

[0131] This application provides a specific application of a smart card program detection method in a normal transaction process. In this scenario, the smart card is card A, and the transmission module is a POS machine.

[0132] A user uses card A to make a transaction on a POS machine. The POS machine interacts with card A to obtain the card's identification (e.g., a unique serial number) and sends this identification to the detection module.

[0133] After receiving the identity identifier, the sampling detection generation unit generates a detection strategy. The detection strategy may include generating a random number of a certain length and selecting one or more program start addresses (M1, ..., Mn) and corresponding detection lengths (L1, ..., Ln) from the card accordingly. The sampling detection generation unit then sends this detection strategy and the identity identifier to the sample card file unit.

[0134] Based on the received identity identifier, the sample card file unit locates and determines the corresponding standard card program file. Subsequently, based on the calculation range defined in the detection strategy, the sample card file unit calculates the first digest information (B1) of the code segment corresponding to the standard card program file and sends the first digest information to the sampling detection generation unit.

[0135] At the same time, the sampling detection generation unit generates a detection instruction based on the detection strategy and sends the detection instruction to the POS machine.

[0136] The POS machine transmits the detection command to card A. The smart card detection program pre-installed on card A executes the command, calculates the second digest information (B2) of its current smart card program within the same range, and feeds back the second digest information (B2) to the POS machine.

[0137] The POS machine sends the received second summary information (B2) to the sampling detection generation unit.

[0138] The sampling detection generation unit compares the received second summary information (B2) with the previously stored first summary information (B1) and feeds back the comparison result (match or inconsistency) to the detection result notification unit.

[0139] The detection result notification unit notifies the preset business system based on the received comparison result. If the comparison result matches, the business system continues the subsequent transaction process; if the comparison result does not match, the business system terminates the current transaction process and may optionally add card A to the blacklist.

[0140] This application provides a specific application of a smart card program detection method in the card acceptance process. In this scenario, the smart card is card B, and the transmission module is a card reader and supporting detection software used by industry customers (such as banks and operators).

[0141] The card supplier delivers the smart card products it produces to industry customers.

[0142] Industry customers randomly select one smart card (card B) from the delivered products, place it on the card reader, and run the detection software.

[0143] The detection software obtains the identification identifier (e.g., unique serial number) of card B through the card reader and sends the identification identifier to the detection module.

[0144] After receiving the identity identifier, the sampling detection generation unit generates a detection strategy. The detection strategy generates a random number of a certain length and selects one or more program start addresses (M1, ..., Mn) and corresponding detection lengths (L1, ..., Ln) from the card accordingly. The sampling detection generation unit sends the detection strategy and the identity identifier to the sample card file unit.

[0145] Based on the received identity identifier, the sample card file unit locates and determines the corresponding standard card program file. Subsequently, based on the calculation range defined in the detection strategy, the sample card file unit calculates the first digest information (B1) of the code segment corresponding to the standard card program file and sends the first digest information to the sampling detection generation unit.

[0146] At the same time, the sampling detection generation unit generates detection instructions based on the detection strategy and sends the detection instructions to the detection software and card reader.

[0147] The detection software transmits the detection command to card B via the card reader. The smart card detection program pre-installed on card B executes the command, calculates the second digest information (B2) of its current smart card program within the same range, and feeds back the second digest information (B2) to the detection software.

[0148] The detection software sends the received second summary information (B2) to the sampling detection generation unit.

[0149] The sampling detection generation unit compares the received second summary information (B2) with the previously stored first summary information (B1) and feeds back the comparison result to the detection result notification unit.

[0150] The detection result notification unit notifies the pre-set business system (e.g., warehouse management system) based on the received comparison results. If the comparison results match, the business system continues to execute the qualified warehousing process for that batch of products; if the comparison results do not match, the business system prompts that the products are inconsistent and stops receiving goods into the warehouse.

[0151] This application provides a method for detecting smart card programs. By generating dynamic and random detection instructions through an external system, the smart card program is subjected to unpredictable verification, thereby preventing malicious tampering and improving the security of the smart card.

[0152] This application also provides an electronic device, such as... Figure 5 The diagram shows the structure of the electronic device, which includes a processor 71 and a memory 72. The memory 72 stores computer-executable instructions that can be executed by the processor 71. The processor 71 executes the computer-executable instructions to implement the above-mentioned method for identifying the planned path.

[0153] exist Figure 5 In the illustrated embodiment, the electronic device further includes a bus 73 and a communication interface 74, wherein the processor 71, the communication interface 74, and the memory 72 are connected via the bus 73.

[0154] The memory 72 may include high-speed random access memory (RAM) and may also include non-volatile memory, such as at least one disk storage device. Communication between this system network element and at least one other network element is achieved through at least one communication interface 74 (which can be wired or wireless), such as the Internet, wide area network, local area network, metropolitan area network, etc. The bus 73 may be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus, or an EISA (Extended Industry Standard Architecture) bus, etc. The bus 73 can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 5 The symbol is represented by a single double-headed arrow, but this does not mean that there is only one bus or one type of bus.

[0155] The processor 71 may be an integrated circuit chip with signal processing capabilities. In implementation, each step of the above method can be completed by the integrated logic circuitry in the hardware of the processor 71 or by instructions in software form. The processor 71 can be a general-purpose processor, including a Central Processing Unit (CPU), a Network Processor (NP), etc.; it can also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (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 disclosed in the embodiments of this application can be directly embodied in the execution of a hardware decoding processor, or can be executed by a combination of hardware and software modules in the decoding processor. The software modules can reside in 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 storage medium is located in the memory. The processor 71 reads the information in the memory 72 and, in conjunction with its hardware, completes the steps of the smart card program detection method of the aforementioned embodiment.

[0156] This application also provides a computer-readable storage medium storing a computer program. The computer program stored on the computer-readable medium executes the steps of the smart card program detection method described above when the computer program is run by a processor.

[0157] The computer program product provided in this application includes a computer-readable storage medium storing program code. The instructions included in the program code can be used to execute the methods described in the preceding method embodiments. For specific implementation details, please refer to the method embodiments, which will not be repeated here.

[0158] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working process of the system and apparatus described above can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.

[0159] Furthermore, in the description of the embodiments of this application, unless otherwise expressly specified and limited, the terms "installation," "connection," and "linking" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral connection; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; and they can refer to the internal connection of two components. Those skilled in the art can understand the specific meaning of the above terms in this application based on the specific circumstances.

[0160] In the description of this application, it should be noted that the terms "center," "upper," "lower," "left," "right," "vertical," "horizontal," "inner," and "outer," etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings. They are used only for the convenience of describing this application and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limitations on this application. Furthermore, the terms "first," "second," and "third" are used for descriptive purposes only and should not be construed as indicating or implying relative importance.

[0161] Finally, it should be noted that the above-described embodiments are merely specific implementations of this application, used to illustrate the technical solutions of this application, and not to limit them. The scope of protection of this application is not limited thereto. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that any person skilled in the art can still modify or easily conceive of changes to the technical solutions described in the foregoing embodiments, or make equivalent substitutions for some of the technical features, within the scope of the technology disclosed in this application. Such modifications, changes, or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application, and should all be covered within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of protection of the claims.

Claims

1. A method for detecting a smart card program, characterized in that, This invention is applied to a detection system, which includes a smart card detection program, a transmission module, and a detection module; the smart card detection program is pre-installed on the smart card; and the detection module is communicatively connected to the transmission module. The detection module pre-stores at least one standard card program file; the method includes: The transmission module acquires the smart card's identity identifier and sends the identity identifier to the detection module; The detection module generates a detection strategy based on the received identity identifier, determines the target standard card program file corresponding to the identity identifier from the standard card program file, and calculates the first digest information corresponding to the target standard card program file based on the detection strategy. The detection module generates a detection command based on the detection strategy and sends the detection command to the smart card detection program through the transmission module; The smart card detection program calculates the second digest information corresponding to the current smart card program of the smart card based on the received detection instruction, and sends the second digest information to the detection module through the transmission module; The detection module determines whether the first digest information and the second digest information are consistent. If they are consistent, the current smart card program is determined to be a legitimate program. The detection module includes a sampling detection generation unit and a sample card archive unit; The step of the detection module generating a detection strategy based on the received identity identifier includes: Based on the received identity identifier, the sample card file unit traverses the standard card program file, determines the target standard card program file corresponding to the identity identifier, and sends the boundary information corresponding to the standard card program file to the sampling detection generation unit. The sampling detection generation unit generates the detection strategy based on a preset random number algorithm and the received boundary information, and sends the detection strategy and the identity identifier to the sample card file unit; the detection strategy includes at least one program start address and detection length.

2. The method for detecting smart card programs according to claim 1, characterized in that, The steps of determining the target standard card program file corresponding to the identity identifier from the standard card program file, and calculating the first digest information corresponding to the standard card program file based on the detection strategy, include: The sample card file unit determines the target code segment corresponding to the standard card program file based on the detection strategy, the identity identifier, the program start address and the detection length in the detection strategy, and calculates the first digest information corresponding to the target code segment based on a preset digest algorithm. The sample card file unit sends the first summary information to the sampling detection generation unit.

3. The method for detecting smart card programs according to claim 2, characterized in that, The step of the detection module generating a detection command based on the detection strategy and sending the detection command to the smart card detection program through the transmission module includes: The sampling detection generation unit generates the detection instruction based on the detection strategy; the detection instruction is used to instruct the smart card detection program to calculate the summary information corresponding to the program start address and the detection length; The sampling detection generation unit encrypts the detection command based on a preset encryption algorithm to obtain the encrypted detection command; The sampling detection generation unit transmits the encrypted detection command to the smart card detection program via the transmission module.

4. The method for detecting smart card programs according to claim 1, characterized in that, The detection module includes a sampling detection generation unit and a detection result notification unit; After the detection module determines whether the first digest information and the second digest information are consistent, the method further includes: If the first summary information is inconsistent with the second summary information, the sampling detection generation unit sends the inconsistency judgment result to the detection result notification unit; The detection result notification unit generates an anomaly notification based on the inconsistent judgment result and sends the anomaly notification to the preset business system so that the preset business system terminates the current transaction.

5. The method for detecting smart card programs according to claim 1, characterized in that, The detection module includes a sampling detection generation unit and a detection result notification unit; after the step of determining whether the first digest information and the second digest information are consistent, and if they are consistent, determining that the current smart card program is a legitimate program, the method further includes: The sampling detection generation unit sends the consistent judgment result to the detection result notification unit; The detection result notification unit generates a normal notification based on the consistent judgment result and sends the normal notification to the preset business system so that the preset business system can continue the current transaction.

6. The method for detecting smart card programs according to claim 1, characterized in that, The step of the transmission module obtaining the smart card's identity identifier includes: The transmission module reads at least one of the serial number, user identification code, and chip identifier stored in the smart card as the identity identifier.

7. A detection system, characterized in that, It includes a smart card detection program, a transmission module, and a detection module; the smart card detection program is pre-installed on the smart card; the detection module is communicatively connected to the transmission module; and the detection module pre-stores a standard card program file. The transmission module is used to acquire the smart card's identity identifier and send the identity identifier to the detection module; The detection module is used to generate a detection strategy based on the received identity identifier, determine the target standard card program file corresponding to the identity identifier from the standard card program file, and calculate the first digest information corresponding to the target standard card program file based on the detection strategy. The detection module is used to generate a detection command based on the detection strategy and send the detection command to the smart card detection program through the transmission module. The smart card detection program is used to calculate the second digest information corresponding to the current smart card program of the smart card based on the received detection instruction, and send the second digest information to the detection module through the transmission module; The detection module is used to determine whether the first digest information and the second digest information are consistent. If they are consistent, the current smart card program is determined to be a legitimate program. The detection module includes a sampling detection generation unit and a sample card archive unit; The sample card file unit is used to traverse the standard card program file based on the received identity identifier, determine the target standard card program file corresponding to the identity identifier, and send the boundary information corresponding to the standard card program file to the sampling detection generation unit. The sampling detection generation unit is used to generate the detection strategy based on a preset random number algorithm and the received boundary information, and send the detection strategy and the identity identifier to the sample card file unit; the detection strategy includes at least one program start address and detection length.

8. An electronic device, characterized in that, The device includes a memory and a processor, wherein the memory stores computer-executable commands that can run on the processor, characterized in that the processor executes the computer-executable commands to implement the detection method of the smart card program according to any one of claims 1-6.

9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions that, when executed by a processor, implement the detection method of the smart card program as described in any one of claims 1-6.

Citation Information

Patent Citations

  • Data storage and verification method and device of intelligent card and medium

    CN112965853A

  • User identification card security detection method and device, and computer readable storage medium

    CN117951036A