A method for improving the efficiency of smart card production
By employing mirror writing technology and encryption/decryption processing, the problems of low smart card production efficiency and high data security risks have been solved, enabling rapid mass production and data security, extending chip lifespan, and improving product quality.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- EASTCOMPEACE TECH
- Filing Date
- 2025-08-13
- Publication Date
- 2026-07-24
AI Technical Summary
The existing smart card production process suffers from low production efficiency and high data security risks. This is mainly due to the long time required for logical judgment and data parsing, which leads to a high number of chip erase and write cycles. Furthermore, outsourced production can easily result in the leakage of customer data.
By employing mirror writing technology, image data is created on the mother card and encrypted/decrypted on the daughter card, reducing data parsing and logic judgment time, optimizing chip erasure and writing strategies, and enhancing data security.
It significantly shortens smart card production time, reduces the number of chip erase/write cycles, extends chip lifespan, effectively prevents data leakage, and improves product quality and data consistency.
Smart Images

Figure CN121031638B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of smart card manufacturing technology, specifically to a method for improving smart card production efficiency, which aims to improve smart card production efficiency by optimizing the data writing process and enhancing data security processing. Background Technology
[0002] In the smart card manufacturing process, traditional methods primarily rely on standard instructions for creating the file system and installing applications. The typical smart card manufacturing process involves downloading the COS (Cybernetic Operating System) through the chip's BootLoader, then using standard instructions (defined in the ETSI TS 102 221 specification) to begin creating the file system (standard files and application-related private files). Then, applications are installed using standard instructions (the INSTALLCommand and LOAD Command defined in the GPC Specification-2.2.1.pdf specification).
[0003] Creating files involves numerous logical checks, such as determining required tags (0x62, 0x82, etc.), file size, FID duplication, and permissions, which slows down file system creation. Installing applications requires executing bytecode, checking installation parameters, importing components, creating objects, and managing memory, also involving many logical checks and impacting production efficiency. Furthermore, a single page on a chip is typically 0x200 bytes, while most individual files or application objects are smaller than 0x200 bytes. Multiple files or application objects may reside on the same page, leading to multiple write / erase operations per page during file creation and application installation, further reducing production efficiency.
[0004] Therefore, smart cards create file systems and install applications using standard instructions, which involves a lot of logical judgments and data parsing. The bytecode executed during the installation process takes extra time, which can slow down the production process. At the same time, if the standard instruction set is used and production is outsourced, it can easily lead to the leakage of customer data. Summary of the Invention
[0005] This invention provides a method to improve the production efficiency of smart cards by using mirror writing technology to reduce data parsing and logic judgment time, reduce the number of chip erase / write cycles, and enhance data security, thereby solving the problems of low production efficiency and high data security risks in the prior art.
[0006] The present invention achieves the above objectives through the following technical solutions: A method for improving smart card production efficiency includes: Step S1: Download the card operating system (COS) to the smart card chip via the chip's BootLoader; Step S2: Create a file system and application objects on a master card A that has already downloaded COS, according to predefined standard instructions; Step S3: Using a privately defined instruction set, read the valid data area of the master card A as image data, and during the reading process, select whether to encrypt the image data according to the configuration to form ciphertext image data; Step S4: Download the same COS as the mother card A to the daughter card to be produced through the BootLoader provided by the chip; Step S5: Write the image data of the mother card A to the daughter card using a privately defined instruction set. If the image data is encrypted, decryption is performed during the writing process to restore the original data and write it to the daughter card. Step S6: Update the post-personalized data of the daughter card using standard instructions; Step S7: Repeat steps S4 to S6 to achieve rapid mass production of smart cards.
[0007] According to a method for improving smart card production efficiency provided by the present invention, the FLASH storage area of the smart card is divided into the following areas according to function: Code area: The core code of the card operating system (COS) is downloaded using the standard loader program provided by the chip manufacturer. This area remains fixed and unmodifiable during the production process. Configuration area, file system and application object area: In the mother card A, configuration parameters, standard file structure and private application objects are pre-created through standard instruction set; the data structure of the same mother card can be reused to batch of daughter cards, and only the differentiated personalized data needs to be replaced during the daughter card production stage; Image data area: The valid data area is read from the FLASH of the master card A through COS's custom private instructions to form a complete image file containing the configuration area, file system and application objects; if COS is configured with encryption function, the image data is encrypted during reading to generate ciphertext image data.
[0008] According to a method for improving smart card production efficiency provided by the present invention, when using standard instructions for card production, the method includes the following steps: When the host computer is powered on, it automatically loads the preset card production script, which includes an instruction sequence and reset control parameters. During the execution of the script, when a reset instruction is detected, the host computer triggers a smart card reset operation through the hardware interface to ensure that each card is in a consistent and standard initial state before the card production process begins. The host computer receives APDU commands from the card reader and distributes the commands to the currently active applications. After receiving the data, the current application parses the command data according to predefined data interpretation rules to obtain the key information of the command. At the same time, it performs validity verification and logical processing on the parsed information. During the file creation or application installation phase, the mirror data pre-verification technology is used to identify the storage needs of multiple files / objects within the same page by parsing the structure and content of the data. When it is detected that the total amount of data to be written does not exceed the chip page capacity, the multiple file creation or object installation operations that originally needed to be executed in steps are merged into a single page erase command and executed uniformly, avoiding repeated erasing and writing of the same page due to step-by-step operations in the traditional method. The host computer dynamically adjusts the instruction stream based on the response code returned by the smart card. When a successful response is received, the host computer automatically proceeds to the next instruction according to the instruction sequence in the card production script. When an error is detected, the current card production process is paused and error location information is output to replace the traditional item-by-item debugging mode.
[0009] According to a method for improving smart card production efficiency provided by the present invention, when the application is USIM, the process of determining the current instruction type specifically includes the following steps: If the current instruction is determined to be a file creation instruction, then further analyze the specific tag information in the data: Parse the 0x82 tag in the data to determine whether the currently created file is a DF or EF file; Parse the 0x83 tag in the data to extract the current file identifier (FID); Based on the parsed file identifier FID, and combined with the file information under the current DF, determine whether the file identifier FID is duplicated under the current DF; At the same time, the parameters required for file creation are judged. If a situation does not meet the preset conditions during the judgment process, the corresponding error message is generated and the current file creation operation is stopped. In addition, when the file creation process requires moving FLASH, the additional time consumed by the operation is recorded. If the current instruction is determined to be a file update instruction, the relevant data of the target file will be updated according to the preset file update rules. During the update process, the data update status will be monitored in real time. If an update anomaly occurs, an error message will be generated in a timely manner and corresponding recovery measures will be taken.
[0010] If the current instruction is determined to be a file read instruction, the corresponding data is read from the target file, and the read data is encapsulated in the specified format and returned to the requester.
[0011] According to a method for improving smart card production efficiency provided by the present invention, when the application is ISD, the process of determining the current instruction type specifically includes the following steps: If the current command is determined to be an application installation command, a permission check is first performed. If the permission check fails, an insufficient permission message is generated and the application installation operation is stopped. If the permission check passes, when loading the installation package, the various component information in the package is parsed. The imported package components are parsed to obtain the relevant data and resource information that need to be imported; The method components are parsed to determine the methods and related parameters that need to be called during the application installation process; Based on the parsed component information, perform logical judgments and allocate NEW object space according to the application installation requirements; If the current instruction is determined to be a key management instruction, then the key is operated accordingly according to the key management rules, and the key data is encrypted during the operation. If the current instruction is determined to be a data update instruction, the specified data will be updated according to the data update strategy. The data will be backed up before the update. After the update is completed, the updated data will be verified.
[0012] According to a method for improving smart card production efficiency provided by the present invention, when reading the mirror data of master card A, the method includes the following steps: After the mother card A is powered on, it directly and continuously sends private instruction requests to the host computer. The host computer responds and continuously sends private instructions for reading image data. The chip continuously receives and processes these private instructions to read image area data until the end marker is reached or the image area data storage boundary is reached, thus completing the entire image area data reading process.
[0013] According to a method for improving smart card production efficiency provided by the present invention, during the data reading process in the mirror area, permission verification and address validity judgment are performed simultaneously: After receiving a read command, the mother card A first verifies the permission identifier carried in the read command to determine whether it has the permission to read data in the mirror area. At the same time, it performs a validity check on the address offset value specified in the command and the set Bank address. It calculates the address offset value + Bank × 0x10000 and compares it with the valid address range. If the calculation result is not within the valid address range, it is determined that the address is invalid, the data read operation is immediately terminated, and an error message is returned to the sender to ensure that the data read operation is performed within a safe address space.
[0014] According to a method for improving smart card production efficiency provided by the present invention, when writing mirror data of mother card A into daughter card, the method includes the following steps: After the chip is powered on, the daughter card directly and continuously sends private instruction requests to the host computer. The host computer responds and continuously sends private instructions for writing image data. The chip continuously receives and processes these private instructions until it receives a preset data writing end flag or reaches the chip's storage capacity limit, thus completing the entire image data writing process.
[0015] According to a method for improving smart card production efficiency provided by the present invention, during the mirror data writing process, permission verification and address validity judgment are performed simultaneously: After the chip receives the write command, the daughter card first verifies the permission identifier carried in the command; at the same time, it performs a validity check on the write address specified in the command by comparing the current address with the range of valid addresses. If the calculation result is not within the range of valid addresses, the address is determined to be invalid, the data write operation is immediately terminated, and an error message is returned to the sender to ensure that the data write operation is performed within a safe address space.
[0016] According to a method for improving smart card production efficiency provided by the present invention, during the system initialization phase or by sending a specific configuration command through a host computer, it is possible to dynamically set whether to enable the mirror encryption function; when the mirror encryption function is enabled, the chip of the daughter card obtains the encryption key from the preset COS area or other secure storage area; after obtaining the key, the key is used to decrypt the received FLASH data. The chip copies the received decrypted FLASH data to COS global RAM1; it determines whether the current address is the page start address; if the current address is the page start address, it copies the data to the start address of RAM1; if the current address is not the page start address, it copies the data to the starting address of RAM1 at offset 0x100.
[0017] During the data caching process, the amount of data in RAM1 is monitored in real time. If a page of data is received, a FLASH update operation is immediately triggered. Using a page erase and write method, a page of data in RAM1 is written to the corresponding address in the mirror area at once, ensuring that the data in the mirror area is erased and written only once during the card making process. If a page of data is not received, a success response is returned to the sender, and subsequent data is received. The newly received data is decrypted and cached until a page of data is received before a FLASH update is performed.
[0018] Therefore, compared with the prior art, the method for improving smart card production efficiency proposed in this invention has the following beneficial effects: 1. This invention reduces the time required for data parsing and logical judgment when creating files and installing applications by using a mirror writing method, which greatly shortens the time required for the card making process.
[0019] 2. In the process of creating a daughter card from a mirror image, the present invention erases and writes the same page of the chip only once, reducing the number of times the chip is erased and written and extending the chip's lifespan.
[0020] 3. This invention effectively prevents the risk of data leakage during outsourced production through data encryption and access control mechanisms.
[0021] 4. This invention ensures data consistency and improves product quality through CRC verification of the mother card and daughter card in the mirror area.
[0022] The present invention will now be described in further detail with reference to the accompanying drawings and specific embodiments. Attached Figure Description
[0023] Figure 1 This is a flowchart of an embodiment of a method for improving smart card production efficiency according to the present invention.
[0024] Figure 2 This is a schematic diagram illustrating the principle of FLASH storage area division in an embodiment of a method for improving smart card production efficiency according to the present invention.
[0025] Figure 3 This is a flowchart illustrating the principle of card production using standard instructions in an embodiment of a method for improving smart card production efficiency according to the present invention.
[0026] Figure 4 This is a flowchart illustrating the process of reading mirror data from master card A in an embodiment of a method for improving smart card production efficiency according to the present invention.
[0027] Figure 5 This is a flowchart illustrating the process of writing mirror data of the mother card A into the daughter card, as described in an embodiment of a method for improving smart card production efficiency according to the present invention.
[0028] Figure 6 This is a schematic diagram illustrating the card production time of a traditional card production method in an embodiment of a method for improving smart card production efficiency according to the present invention.
[0029] Figure 7 This is a schematic diagram illustrating the card production time for sub-cards produced using the mirror writing method in an embodiment of a method for improving smart card production efficiency according to the present invention. Detailed Implementation
[0030] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.
[0031] In this document, the term "embodiment" means that a particular feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of this application. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a separate or alternative embodiment mutually exclusive with other embodiments. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.
[0032] See Figures 3 to 7 This embodiment provides a method for improving smart card production efficiency, including: Step S1: Download the card operating system (COS) to the smart card chip via the chip's BootLoader; Step S2: Create a file system and application objects on a master card A that has already downloaded COS, according to predefined standard instructions; Step S3: Using a privately defined instruction set, read the valid data area of the master card A as image data, and during the reading process, select whether to encrypt the image data according to the configuration to form ciphertext image data; Step S4: Download the same COS as the mother card A to the daughter card to be produced through the BootLoader provided by the chip; Step S5: Write the image data of the mother card A to the daughter card using a privately defined instruction set. If the image data is encrypted, decryption is performed during the writing process to restore the original data and write it to the daughter card. Step S6: Update the post-personalized data of the sub-card using standard instructions, including but not limited to key (KI), operation code control parameters (OPC), and personal identification number (PIN) information; Step S7: Repeat steps S4 to S6 to achieve rapid mass production of smart cards.
[0033] In this embodiment, as Figure 2 As shown, the FLASH storage area of the smart card is divided into the following areas according to function: Code area: The core code of the card's operating system (COS) is downloaded using the standard loader program provided by the chip manufacturer. This area remains fixed and unmodifiable during the production process.
[0034] Configuration area, file system, and application object area: In the master card A, configuration parameters, standard file structure, and private application objects are pre-created using standard instruction sets such as ETSI TS 102 221 or GPC Specification-2.2.1. The data structure of the same master card can be reused to a batch of daughter cards, and only the differentiated personalized data needs to be replaced during the daughter card production stage. Since each card only has some different personalized data, the configuration area, file system, and application objects of the master card A can be created using standard instructions.
[0035] Image data area: The valid data area is read from the FLASH of the mother card A through COS's custom private instructions (instruction type code is 0xC0) to form a complete image file containing the configuration area, file system and application objects; if COS is configured with encryption function, the image data is encrypted during reading to generate ciphertext image data.
[0036] The private instructions include address offset parameters (P1P2) and data length parameters (P3), which support reading the master card data in blocks and verifying the address validity to ensure the integrity and security of the mirrored data.
[0037] When using standard instructions to create cards, such as Figure 3 As shown, it includes the following steps: When the host computer is powered on, it automatically loads the preset card production script, which includes an instruction sequence and reset control parameters. During the execution of the script, when a reset instruction is detected, the host computer triggers the smart card reset operation through a hardware interface, such as a specific serial port, USB interface, or a dedicated interface that conforms to the smart card communication protocol, thereby ensuring that each card is in a consistent and standard initial state before the card production process begins. The host computer receives the APDU command sent by the card reader and distributes the command to the currently active application, such as the UISM application of the USIM card, ISD, or the PBOC application of the bank card. This invention can eliminate the process judgment such as application distribution during the card making process on the production line. After receiving the data, the current application parses the instruction data according to predefined data interpretation rules to obtain key information about the instruction, such as operation type (file creation, update, read, application installation, uninstallation, etc.), operation object (file identifier, application identifier, etc.), and operation data; at the same time, it performs validity verification and logical processing on the parsed information. During the file creation or application installation phase, the mirror data pre-verification technology is used to identify the storage needs of multiple files / objects within the same page by parsing the structure and content of the data. When it is detected that the total amount of data to be written does not exceed the chip page capacity, the multiple file creation or object installation operations that originally needed to be executed in steps are merged into a single page erase command and executed uniformly, avoiding repeated erasing and writing of the same page due to step-by-step operations in the traditional method. The host computer dynamically adjusts the instruction stream based on the response code returned by the smart card. When a successful response is received, the host computer automatically proceeds to the next instruction according to the instruction sequence in the card production script. When an error is detected, the current card production process is paused and error location information is output to replace the traditional item-by-item debugging mode.
[0038] When the application is USIM, the process of determining the current instruction type includes the following steps: If the current instruction is determined to be a file creation instruction, then further analyze the specific tag information in the data: Parse the 0x82 tag in the data to determine whether the currently created file is a DF (dedicated file) or an EF (basic file). Parse the 0x83 tag in the data to extract the current file identifier (FID); Based on the parsed file identifier FID, and combined with the file information under the current DF, determine whether the file identifier FID is duplicated under the current DF; At the same time, the system checks parameters such as file size and permissions required for file creation. If any conditions are not met during the check, the system generates an error message and stops the current file creation operation. Furthermore, when the file creation process requires moving the FLASH, the system records the additional time consumed by this operation. If the current instruction is determined to be a file update instruction, the relevant data of the target file will be updated according to the preset file update rules. During the update process, the data update status will be monitored in real time. If an update anomaly occurs, an error message will be generated in a timely manner and corresponding recovery measures will be taken.
[0039] If the current instruction is determined to be a file read instruction, the corresponding data is read from the target file, and the read data is encapsulated in the specified format and returned to the requester.
[0040] When the application is ISD, the process of determining the current instruction type includes the following steps: If the current command is determined to be an application installation command (INSTALL Command / LOAD Command), a permission check is first performed to verify whether it has passed a preset permission check method such as SCP02 or SCP03. If the permission check fails, an insufficient permission message is generated and the application installation operation is stopped. If the permission check passes, when loading the installation package, the various component information in the package is parsed. The import package component (COMPONENT_Import) is parsed to obtain the relevant data and resource information that need to be imported; The method component (COMPONENT_Method) is parsed to determine the methods and related parameters that need to be called during the application installation process; Based on the parsed component information, logical judgments are made, and NEW object space allocation is performed according to application installation requirements. During the entire application installation instruction processing, the time consumption information of each step is recorded to analyze the impact of application installation operations on production line card processing time.
[0041] If the current command is determined to be a key management command (PUT KEY Command), then the key is operated accordingly according to the key management rules, including key storage, updating, and deletion, and the key data is encrypted during the operation. If the current command is determined to be a STORE DATA Command, the specified data will be updated according to the data update strategy. The data will be backed up before the update. After the update is completed, the updated data will be verified.
[0042] Specifically, after receiving data, the current application needs to interpret and logically judge the data. Assuming the current application is USIM, USIM needs to determine what the current instruction is: is it a file creation instruction defined by the TS_102222 specification, a file update instruction, or a file read instruction, etc.? These instructions are all required during the card creation process. If it's a file creation instruction, it needs to parse the 0x82 tag in the data to know whether a DF or EF file is being created. By parsing the 0x83 tag, it needs to parse the current FID and determine if the FID is duplicated under the current DF. It also needs to determine the file size and permissions, etc. These judgments add extra time during the card creation process on the production line. If the file creation process requires moving FLASH, it requires even more additional time. For example, assuming the current application is ISD, ISD needs to determine the current command, such as INSTALL Command / LOAD Command (application installation), PUT KEY Command (key management), or STORE DATA Command (data update). These commands are required during card creation. If the current command is to install an application, it needs to first determine whether permission verification, such as SCP02 or SCP03, has been performed. When loading the installation package, it needs to parse various components of the package, such as COMPONENT_Import and COMPONENT_Method, and perform logical judgments and space allocation for NEW objects. These operations consume a lot of time during card creation. This invention can eliminate these operations on the production line. After the application judgment and parsing are completed, data updates need to be performed and saved to FLASH.
[0043] Because smart card chip erasure and writing (erasing and writing one page of data takes milliseconds) typically performs page-to-word or page-to-page erasure and writing, and since most file sizes or NEW objects from applications are usually smaller than the chip's page size (0x200, hereinafter referred to as 0x200 as one chip page), a single page of the chip can store multiple files or multiple objects from applications. This leads to the possibility of the same page being repeatedly erased and written multiple times during file creation or application installation. In this embodiment, during the mirroring process to create a daughter card, the same page of the chip is erased and written only once, reducing the number of times the chip is erased and written.
[0044] After receiving the response, the host computer judges the response value and then sends the next card-making instruction or terminates the process.
[0045] In step S2 above, a master card A is first made using the standard instruction card making steps described above (personalized data KI, OPC, PIN, etc. are not executed). Then, the mirror data of the master card A is read and written to the daughter card using the mirror data of the master card A. Then, the daughter card updates the personalized data by selecting a file, etc., using standard instructions.
[0046] In this implementation, the private instructions for reading image data are defined as shown in Table 1: Table 1: Private Instruction Table for Reading Image Data
[0047] In Table 1, P1P2 represents the address offset, starting from 0x0000 and increasing in increments of P3, reading data from the master card as mirror data. If the mirror data exceeds one bank (64K), the next bank needs to be set, and then P1P2 starts from 0x0000 again. The read mirror data is converted according to the mirror writing format (the writing instruction format). If a consecutive page of data contains values erased from the chip, then this page does not need to be re-mirrored and written to the daughter card.
[0048] In this implementation, the private instruction format for image writing is defined as shown in Table 2: Table 2: Private Instruction Table for Writing Image Data
[0049] In Table 2, P1 points to the nth 0x100, incrementing from 0x00. If it reaches 0xFF, which exceeds one bank, the next bank needs to be set, and then P1 starts incrementing from 0x00 again. P2 is the first byte of the 0x100 data area pointed to by P1, which is the 0x100 data read by the two read instructions (INS is 0xB0). The first byte is stored in P2, and the remaining 0xFF data is in the APDU body. P3 is fixed at 0xFF, which is the 0xFF data after the 0x100 data of the P1 instruction.
[0050] When reading the image data of master card A, such as Figure 4 As shown, it includes the following steps: After the mother card A powers on, it abandons the conventional instruction dispatch logic, i.e., it does not check whether the first instruction after the PPS instruction is a privately defined CLASS (such as 0xC0). Instead, it directly and continuously sends private instruction requests to the host computer. The host computer responds and continuously sends private instructions for reading image data. The chip continuously receives and processes these private instructions to read image area data until it reaches the end marker or the image area data storage boundary, completing the entire image area data reading process. Specifically, after the chip powers on, unless the first instruction after the PPS instruction is a privately defined CLASS (such as 0xC0), it continues to the virtual machine for instruction dispatch. If it is a private instruction, it continuously receives and processes private instructions until it receives a non-private instruction, at which point it exits the private instruction processing flow and returns to the virtual machine for instruction dispatch. In this embodiment, private instructions are continuously sent to read image area data after power-on until the reading is complete. This method avoids the time loss caused by instruction dispatch judgment in the conventional process and improves data reading efficiency.
[0051] During the data reading process in the mirror area, permission verification and address validity checks are performed simultaneously: After receiving a read command, the mother card A first verifies the permission identifier carried in the read command to determine whether it has the permission to read data in the mirror area. At the same time, it performs a validity check on the address offset value P1P2 specified in the command and the set Bank address. It calculates the value of P1P2 + Bank × 0x10000 and compares it with the valid address range. If the calculation result is not within the valid address range, it is determined that the address is invalid, the data read operation is immediately terminated, and an error message is returned to the sender to ensure that the data read operation is performed within a safe address space.
[0052] Based on actual production needs, flexible encryption configuration options are provided; during the system initialization phase or by sending specific configuration commands through the host computer, the data encryption function can be dynamically set to be enabled or disabled; when in outsourced production or other scenarios with high data security requirements, the encryption function can be enabled to meet the data encryption needs; while in internal production or scenarios with relatively low data security requirements, the encryption function can be disabled to reduce data processing overhead and improve production efficiency.
[0053] After successfully reading FLASH data, if the system has enabled encryption, it will immediately encrypt the read data. The encryption process uses a pre-set encryption algorithm and key to encrypt the data byte by byte or block by block, generating encrypted ciphertext data. The encrypted data can be stored in a designated secure storage area or directly transmitted to the host computer for further processing, ensuring the security of the data during transmission and storage and preventing data leakage and tampering.
[0054] When writing the image data of the mother card A to the daughter card, such as Figure 5 As shown, it includes the following steps: After the chip powers on, the daughter card abandons the conventional instruction dispatch logic, i.e., it does not check whether the first instruction after the PPS instruction is a privately defined CLASS (such as 0xC0). Instead, it directly and continuously sends private instruction requests to the host computer. The host computer responds and continuously sends private instructions for writing image data. The chip continuously receives and processes these private instructions until it receives a preset data write end flag or reaches the chip's storage capacity limit, completing the entire image data writing process. Specifically, after the chip powers on, the conventional instruction dispatch logic is abandoned. Except for the case where the first instruction after the PPS instruction is not a privately defined CLASS (such as 0xC0), instruction dispatch continues to the virtual machine. If it is a private instruction, it continuously receives and processes private instructions until it receives a non-private instruction, at which point it exits the private instruction processing flow and resumes instruction dispatch to the virtual machine. In this embodiment, the daughter card continuously sends private instructions for image data writing after power-on until the data writing is complete. This method avoids the time loss caused by instruction dispatch judgment in the conventional process, significantly improving data writing efficiency.
[0055] During the image data writing process, permission verification and address validity checks are performed synchronously: After the chip receives the write command, the daughter card first verifies the permission identifier carried in the command; at the same time, it performs a validity check on the write address specified in the command by calculating the current address (Addr = (P1×0x100+ Bank×0x10000)) and comparing it with the valid address range. If the calculation result is not within the valid address range, it is determined that the address is invalid, the data write operation is immediately terminated, and an error message is returned to the sender to ensure that the data write operation is performed within a safe address space.
[0056] Based on actual production needs, flexible encryption configuration options are provided; during the system initialization phase or by sending specific configuration commands through the host computer, the mirror encryption function can be dynamically set to enable or disable; when the mirror encryption function is enabled, the chip of the daughter card obtains the encryption key from the preset COS area or other secure storage area; after obtaining the key, the received FLASH data is decrypted using the key to ensure the security of the data before it is written. The chip copies the received decrypted FLASH data to COS global RAM1 (one page size); it then checks if the current address (Addr = (P1 × 0x100 + Bank × 0x10000)) is the page start address (Addr & 0x1FF == 0 indicates the page start address); if the current address is the page start address, the data is copied to the start address of RAM1; otherwise, the data is copied to the starting address at offset 0x100 in RAM1. This method implements intelligent data caching and address alignment, improving the efficiency and accuracy of data storage.
[0057] During the data caching process, the amount of data in RAM1 is monitored in real time. If a page of data is received, a FLASH update operation is immediately triggered, using a page erase and write method to write the entire page of data in RAM1 to the corresponding address in the mirror area at once, ensuring that the data in the mirror area is erased and written only once during the same page card-making process. If a page of data is not received, a success response is returned to the sender, and subsequent data continues to be received. The newly received data is decrypted and cached until a page of data is received before a FLASH update is performed. Finally, a data update is performed, which directly uses a page erase and write method, meaning that the data in the mirror area is erased and written only once during the same page mirror card-making process.
[0058] In practical applications, a comparison of the card processing speed of the same product's 128K card: Use the same host computer software and the same card reader: such as Figure 6 As shown, the traditional standard takes 3 minutes and 7 seconds to create a file and install an application; Figure 7 As shown, in this embodiment, the time required to create a daughter card using the mirroring method is 1 minute and 30 seconds.
[0059] In summary, this invention, through mirror writing technology, eliminates redundant logical judgments, optimizes erasure and writing strategies, and enhances data security mechanisms. In actual production, it can improve time efficiency, reduce erasure and writing costs, and achieve 100% data consistency, which is significantly better than traditional standard instruction processes. It is especially suitable for large-scale smart card production and outsourced processing scenarios.
[0060] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0061] The above embodiments are merely preferred embodiments of the present invention and should not be construed as limiting the scope of protection of the present invention. Any non-substantial changes and substitutions made by those skilled in the art based on the present invention shall fall within the scope of protection claimed by the present invention.
Claims
1. A method for improving smart card production efficiency, characterized in that, include: Step S1: Download the card operating system (COS) to the smart card chip via the chip's BootLoader; Step S2: Create a file system and application objects on a master card A that has already downloaded COS, according to predefined standard instructions; Step S3: Using a privately defined instruction set, read the valid data area of the master card A as image data, and during the reading process, select whether to encrypt the image data according to the configuration to form ciphertext image data; Step S4: Download the same COS as the mother card A to the daughter card to be produced through the BootLoader provided by the chip; Step S5: Write the image data of the mother card A to the daughter card using a privately defined instruction set. If the image data is encrypted, decryption is performed during the writing process to restore the original data and write it to the daughter card. Step S6: Update the post-personalized data of the daughter card using standard instructions; Step S7: Repeat steps S4 to S6 to achieve rapid mass production of smart cards; The process of reading the image data from mother card A includes the following steps: After the mother card A is powered on, it directly and continuously sends private instruction requests to the host computer. The host computer responds and continuously sends private instructions for reading image data. The chip continuously receives and processes these private instructions to read image area data until the end marker is reached or the image area data storage boundary is reached, thus completing the entire image area data reading process.
2. The method according to claim 1, characterized in that, The FLASH storage area of a smart card is divided into the following areas according to function: Code area: The core code of the card operating system (COS) is downloaded using the standard loader program provided by the chip manufacturer. This area remains fixed and unmodifiable during the production process. Configuration area, file system and application object area: In the mother card A, configuration parameters, standard file structure and private application objects are pre-created through standard instruction set; the data structure of the same mother card can be reused to batch of daughter cards, and only the differentiated personalized data needs to be replaced during the daughter card production stage; Image data area: The valid data area is read from the FLASH of the master card A through COS's custom private instructions to form a complete image file containing the configuration area, file system and application objects; if COS is configured with encryption function, the image data is encrypted during reading to generate ciphertext image data.
3. The method according to claim 1, characterized in that, When using standard instructions to create a card, the following steps are included: When the host computer is powered on, it automatically loads the preset card production script, which includes an instruction sequence and reset control parameters. During the execution of the script, when a reset instruction is detected, the host computer triggers a smart card reset operation through the hardware interface to ensure that each card is in a consistent and standard initial state before the card production process begins. The host computer receives APDU commands from the card reader and distributes the commands to the currently active applications. After receiving the data, the current application parses the command data according to predefined data interpretation rules to obtain the key information of the command. At the same time, it performs validity verification and logical processing on the parsed information. During the file creation or application installation phase, the mirror data pre-verification technology is used to identify the storage needs of multiple files / objects within the same page by parsing the structure and content of the data. When it is detected that the total amount of data to be written does not exceed the chip page capacity, the multiple file creation or object installation operations that originally needed to be executed in steps are merged into a single page erase command and executed uniformly, avoiding repeated erasing and writing of the same page due to step-by-step operations in the traditional method. The host computer dynamically adjusts the instruction stream based on the response code returned by the smart card. When a successful response is received, the host computer automatically proceeds to the next instruction according to the instruction sequence in the card production script. When an error is detected, the current card production process is paused and error location information is output to replace the traditional item-by-item debugging mode.
4. The method according to claim 3, characterized in that: When the application is USIM, the process of determining the current instruction type specifically includes the following steps: If the current instruction is determined to be a file creation instruction, then further analyze the specific tag information in the data: Parse the 0x82 tag in the data to determine whether the currently created file is a DF or EF file; Parse the 0x83 tag in the data to extract the current file identifier (FID); Based on the parsed file identifier FID, and combined with the file information under the current DF, determine whether the file identifier FID is duplicated under the current DF; At the same time, the parameters required for file creation are judged. If a situation does not meet the preset conditions during the judgment process, the corresponding error message is generated and the current file creation operation is stopped. In addition, when the file creation process requires moving FLASH, the additional time consumed by the operation is recorded. If the current instruction is determined to be a file update instruction, the relevant data of the target file will be updated according to the preset file update rules. The data update status will be monitored in real time during the update process. If an update anomaly occurs, an anomaly prompt message will be generated in a timely manner and corresponding recovery measures will be taken. If the current instruction is determined to be a file read instruction, the corresponding data is read from the target file, and the read data is encapsulated in the specified format and returned to the requester.
5. The method according to claim 3, characterized in that: When the application is ISD, the process of determining the current instruction type includes the following steps: If the current command is determined to be an application installation command, a permission check is first performed. If the permission check fails, an insufficient permission message is generated and the application installation operation is stopped. If the permission check passes, when loading the installation package, the various component information in the package is parsed. The imported package components are parsed to obtain the relevant data and resource information that need to be imported; The method components are parsed to determine the methods and related parameters that need to be called during the application installation process; Based on the parsed component information, perform logical judgments and allocate NEW object space according to the application installation requirements; If the current instruction is determined to be a key management instruction, then the key is operated accordingly according to the key management rules, and the key data is encrypted during the operation. If the current instruction is determined to be a data update instruction, the specified data will be updated according to the data update strategy. The data will be backed up before the update. After the update is completed, the updated data will be verified.
6. The method according to claim 1, characterized in that, During the data reading process in the mirror area, permission verification and address validity checks are performed simultaneously: After receiving a read command, the mother card A first verifies the permission identifier carried in the read command to determine whether it has the permission to read data in the mirror area. At the same time, it performs a validity check on the address offset value specified in the command and the set Bank address. It calculates the address offset value + Bank × 0x10000 and compares it with the valid address range. If the calculation result is not within the valid address range, it is determined that the address is invalid, the data read operation is immediately terminated, and an error message is returned to the sender to ensure that the data read operation is performed within a safe address space.
7. The method according to any one of claims 1 to 6, characterized in that, When writing the image data of the master card A to the daughter card, the following steps are included: After the chip is powered on, the daughter card directly and continuously sends private instruction requests to the host computer. The host computer responds and continuously sends private instructions for writing image data. The chip continuously receives and processes these private instructions until it receives a preset data writing end flag or reaches the chip's storage capacity limit, thus completing the entire image data writing process.
8. The method according to claim 7, characterized in that, During the image data writing process, permission verification and address validity checks are performed synchronously: After the chip receives the write command, the daughter card first verifies the permission identifier carried in the command; at the same time, it performs a validity check on the write address specified in the command by comparing the current address with the range of valid addresses. If the calculation result is not within the range of valid addresses, the address is determined to be invalid, the data write operation is immediately terminated, and an error message is returned to the sender to ensure that the data write operation is performed within a safe address space.
9. The method according to claim 8, characterized in that: During system initialization or by sending specific configuration commands from the host computer, the image encryption function can be dynamically set to be enabled or disabled. When the image encryption function is enabled, the chip of the daughter card obtains the encryption key from the preset COS area or other secure storage area. After obtaining the key, the key is used to decrypt the received FLASH data. The chip copies the received decrypted FLASH data to COS global RAM1; it determines whether the current address is the page start address; if the current address is the page start address, it copies the data to the start address of RAM1; if the current address is not the page start address, it copies the data to the starting address of RAM1 at offset 0x100. During the data caching process, the amount of data in RAM1 is monitored in real time. If a page of data is received, a FLASH update operation is immediately triggered. Using a page erase and write method, a page of data in RAM1 is written to the corresponding address in the mirror area at once, ensuring that the data in the mirror area is erased and written only once during the card making process. If a page of data is not received, a success response is returned to the sender, and subsequent data is received. The newly received data is decrypted and cached until a page of data is received before a FLASH update is performed.