A hardware anti-copying encryption method and device based on TEE and encryption chip

By employing a hardware anti-copying encryption method based on TEE and encryption chips, and utilizing secure boot technology and the security of encryption chips, the method addresses the security shortcomings of hardware anti-copying solutions when facing intrusive attacks, achieving high security and fast decryption and mounting.

CN115357948BActive Publication Date: 2026-07-17SHENZHEN QIXIN INFORMATION TECH CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
SHENZHEN QIXIN INFORMATION TECH CO LTD
Filing Date
2022-08-30
Publication Date
2026-07-17

AI Technical Summary

Technical Problem

Existing hardware anti-copying solutions are not secure enough against intrusive chip-splitting attacks, are easily cracked, cannot effectively prevent copying, and the encryption chip cannot defend against rewriting of the main control program.

Method used

A hardware-based anti-copying encryption method using TEE and encryption chips is adopted. By combining secure boot technology and encryption chips, the security of encryption chips is utilized to achieve comparison authentication and integrity verification, ensuring the security and complexity of the system program. The core code runs in the encryption chip to prevent copying.

Benefits of technology

It increases the difficulty of hardware anti-copying and system security, prevents hacker attacks and re-flashing, protects user data from being easily obtained, and ensures that the system can quickly decrypt and mount the file system without affecting the boot speed.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115357948B_ABST
    Figure CN115357948B_ABST
Patent Text Reader

Abstract

This invention provides a hardware anti-copying encryption method and apparatus based on TEE and an encryption chip. The method includes executing boot code to configure and verify the encryption chip; obtaining master control parameter information, performing registration and authorization;, with authorization, comparing and authenticating the encryption chip based on a preset key; if authentication is successful, reading the kernel certificate stored in external memory, using the kernel certificate to verify the integrity of the kernel image, and if verification is successful, starting the kernel; and after kernel startup, mounting the decrypted root file system. This invention, by fully utilizing secure boot technology and the high security of the encryption chip, increases the security of the system program, enhances the complexity of the anti-copying process, and increases the difficulty of cracking. It has the advantages of unique encrypted data, complex anti-copying process, difficulty in cracking, high confidentiality, and reliability, achieving a good anti-copying effect.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of secure storage technology, specifically to a hardware anti-copying encryption method based on TEE and encryption chip, and an apparatus applied to the method. Background Technology

[0002] Hardware products consist of hardware and software code embedded in the hardware's memory. Currently, PCB copying is rampant, harming not only the interests of original manufacturers, suppliers, and design companies, but also hindering the healthy development of the industry.

[0003] Generally, hardware products can be copied using reverse engineering. A common method is to remove the non-volatile memory of the original product, place it on a specific card reader, read out all the data stored in the memory, and then burn the read data into the cloned hardware memory to complete the copying of the entire hardware product.

[0004] To combat PCB copying, most mainstream hardware anti-copying solutions on the market currently use encrypted chips for comparison and authentication. This solution offers limited security, providing only basic defense against non-intrusive line attacks and replay attacks. However, invasive chip-splitting attacks targeting the main controller can still effectively bypass the authentication comparison point, read the main controller program, and rewrite it. Once the comparison and authentication function in the main controller fails, PCB copying can still be completed even if the encrypted chip is not cracked. Summary of the Invention

[0005] This invention provides a hardware anti-copying encryption method and device based on TEE and encryption chip, which solves various problems existing in current hardware anti-copying methods, such as serious copying phenomenon, low anti-copying capability, easy cracking, low security, and inability to meet user needs. Therefore, compared with traditional anti-copying methods in the prior art, the hardware anti-copying encryption method and device provided by this invention, by making full use of secure boot technology and the high security of encryption chip, increases the security of system program, improves the complexity of the anti-copying process and the difficulty of cracking, and has the advantages of unique encrypted data, complex anti-copying process and difficulty of cracking. It has high confidentiality and reliability and can achieve better anti-copying effect.

[0006] In a first aspect, the present invention provides a hardware anti-copying encryption method based on TEE and an encryption chip, comprising:

[0007] Execute the boot code to configure and verify the encryption chip;

[0008] Obtain master control parameter information, and perform registration and authorization;

[0009] With authorization, the encryption chip is compared and authenticated based on a pre-set key;

[0010] If authentication is successful, the kernel certificate stored in external storage is read, and the integrity of the kernel image is verified using the kernel certificate. If the verification is successful, the kernel is started.

[0011] After the kernel boots up, the decrypted root file system is mounted.

[0012] According to the present invention, a hardware anti-copying encryption method based on TEE and encryption chip is provided, wherein configuring and verifying the encryption chip includes:

[0013] Obtain root certificate information, execute the code embedded in the secure boot ROM, load and verify the root certificate, thereby verifying the legitimacy of the public key in the root certificate;

[0014] The secure boot code from external storage is loaded and verified, and its legitimacy is verified using the public key and the hash value of the secure boot code stored in the root certificate.

[0015] After verification is complete, load, verify, and start the security system;

[0016] Exit the secure boot mode and enter the normal boot process.

[0017] According to the hardware anti-copying encryption method based on TEE and encryption chip provided by the present invention, when executing the code embedded in the secure boot ROM, the code is written in standard C language, and compiled and downloaded to the encryption chip by KEIL C compiler, and some key code in the boot program is ported to the encryption chip for execution.

[0018] In actual operation, the program segment inside the encryption chip is run by calling functions to obtain the running result, and this result is used as input data for further running of the user program.

[0019] According to the present invention, a hardware anti-copying encryption method based on TEE and encryption chip is provided, wherein the step of obtaining master control parameter information, performing registration and authorization includes;

[0020] The system obtains the chip identification number (CHIP ID) and MAC address from the main control terminal, and transmits the chip identification number (CHIP ID), MAC address, and key parameters stored in the encrypted chip to the database server. The database server decrypts the CHIP ID, MAC address, and key parameters, performs registration, and then generates a unique activation code based on this information, encrypts it, and returns it to the main control terminal for authorization.

[0021] According to the present invention, a hardware anti-copying encryption method based on TEE and encryption chip is provided, wherein the comparison and authentication of the encryption chip includes:

[0022] The same set of keys is preset in the main control terminal and the encryption chip. During the operation phase, the main control terminal sends a set of random numbers to the encryption chip. After receiving the random number, the encryption chip uses the preset key to symmetrically encrypt the random number to generate two sets of ciphertext. The main control terminal compares the two sets of ciphertext to confirm whether the encryption chip is legitimate.

[0023] According to the hardware anti-copying encryption method based on TEE and encryption chip provided by the present invention, after the kernel is started, it also executes a reverse verification process: calling the verification module to verify the ordinary startup code data, and at the same time continuously detecting the verification pass mark through the monitoring code in the first CPU core of the main control terminal until the verification is successful or the timeout is exited; if the verification fails, the device is restarted.

[0024] According to the present invention, a hardware anti-copying encryption method based on TEE and encryption chip is provided, wherein the loading, verification, and startup of the security system includes:

[0025] The security system and the corresponding Secure OS certificate stored in the external storage are loaded. The validity of the certificate and Secure OS is verified by using the hash value of Secure OS and the corresponding public key. The Secure OS certificate contains the hash value of Secure OS and the corresponding public key.

[0026] According to the hardware anti-copying encryption method based on TEE and encryption chip provided by the present invention, after the verification is passed, the normal startup code data continues to be loaded and verified.

[0027] Load the ordinary boot code data and the corresponding UBOOT certificate stored in the external storage, and verify the legitimacy of the certificate and UBOOT using the UBOOT public key and hash value respectively. The UBOOT certificate stores the hash value of the ordinary boot code and the corresponding public key.

[0028] Once the verification passes, continue executing the normal startup code until the normal startup process begins.

[0029] According to the present invention, a hardware anti-copying encryption method based on TEE and encryption chip is provided. The mounting of the decrypted root file system includes: a Devicemapper provided by the system kernel to map from logical device to physical device. The mapping includes a mapping device, a mapping table and a target device. The root file system is mapped to the / dev / dm-0 device through the Device mapper. The / dev / dm-0 device is formatted with a file system and then mounted to the system root directory. The mapping device is a logical abstraction, which establishes a mapping with the target device through the mapping relationship described by the mapping table.

[0030] Secondly, the present invention also provides a hardware anti-copying encryption device based on TEE and encryption chip, comprising:

[0031] The secure boot unit is used to execute boot code to configure and verify the encryption chip;

[0032] The registration and authorization unit is used to obtain master control parameter information and perform registration and authorization.

[0033] The comparison and authentication unit, with authorization, performs comparison and authentication of the encryption chip based on a preset key;

[0034] Load and verify the kernel unit. If authentication is successful, read the kernel certificate stored in external storage, use the kernel certificate to verify the integrity of the kernel image, and if the verification is successful, start the kernel.

[0035] The mount system unit is used to mount the decrypted root file system after the kernel has booted.

[0036] Therefore, the present invention has the following beneficial effects:

[0037] 1. Strong Anti-Copying Capability: Compared to traditional anti-copying solutions, this invention's firmware anti-tampering function based on TEE effectively prevents intrusive attacks on the main control unit, thus ensuring that the comparison and authentication process on the main control unit cannot be cracked. Simultaneously, it maximizes the security features of the encryption chip, allowing the encryption chip and the main control unit to work together. Even if the main control unit is cracked alone, it will be impossible to obtain all the core critical code, greatly increasing the difficulty of cracking and improving the security of system data.

[0038] 2. High system security: The firmware anti-tampering function of this invention effectively prevents hacker attacks and re-flashing, ensuring that the hardware can only run authorized system software, thereby improving system security.

[0039] 3. High user data confidentiality: The hardware system is encrypted to protect sensitive user data from being easily obtained.

[0040] 4. High speed: TEE implements commonly used cryptographic algorithm frameworks for encryption / decryption, signature verification, and digest calculation. Therefore, the method of this invention takes less time and can quickly decrypt and mount the encrypted root file system without affecting the system startup speed.

[0041] 5. Easy to implement: Based on the secure boot architecture definition, by establishing a complete trust chain, it ensures that the system program loaded by the device is not tampered with, and prevents intrusive fragmentation attacks on the main controller.

[0042] Thirdly, the present invention also provides an electronic device, comprising:

[0043] Memory, which stores computer-executable instructions;

[0044] The processor is configured to run computer-executable instructions.

[0045] The computer-executable instructions, when executed by the processor, implement the steps of any of the above-mentioned hardware anti-copying encryption methods based on TEE and encryption chips.

[0046] Fourthly, the present invention also provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions, which, when executed by a processor, implement the steps of any of the above-described hardware anti-copying encryption methods based on TEE and encryption chips.

[0047] Therefore, this invention provides an electronic device and storage medium based on a TEE and an encryption chip for hardware anti-copying encryption, comprising: one or more memories and one or more processors. The memories are used to store program code and intermediate data generated during program execution, storage of model output results, and storage of the model and model parameters; the processors are used for the processor resources occupied by the code execution and multiple processor resources occupied during model training.

[0048] The present invention will now be described in further detail with reference to the accompanying drawings and specific embodiments. Attached Figure Description

[0049] Figure 1 This is a flowchart of an embodiment of a hardware anti-copying encryption method based on TEE and encryption chip according to the present invention.

[0050] Figure 2 This is a flowchart illustrating the configuration and verification of the encryption chip in an embodiment of a hardware anti-copying encryption method based on TEE and encryption chip according to the present invention.

[0051] Figure 3 This is a flowchart of key code execution in an embodiment of a hardware anti-copying encryption method based on TEE and encryption chip according to the present invention.

[0052] Figure 4 This is a flowchart regarding registration and authorization in an embodiment of a hardware anti-copying encryption method based on TEE and encryption chip according to the present invention.

[0053] Figure 5 This is a flowchart illustrating the protection of key parameters in an embodiment of a hardware anti-copying encryption method based on TEE and encryption chip according to the present invention.

[0054] Figure 6This is a flowchart illustrating the comparison and authentication of encryption chips in an embodiment of a hardware anti-copying encryption method based on TEE and encryption chips according to the present invention.

[0055] Figure 7 This is a flowchart of the reverse verification process in an embodiment of a hardware anti-copying encryption method based on TEE and encryption chip according to the present invention.

[0056] Figure 8 This is a schematic diagram of an embodiment of a hardware anti-copying encryption device based on TEE and encryption chip according to the present invention. Detailed Implementation

[0057] 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.

[0058] See Figure 1 A hardware anti-copying encryption method based on TEE and encryption chip includes the following steps:

[0059] Step S1: Execute the boot code to configure and verify the encryption chip.

[0060] Step S2: Obtain master control parameter information, and perform registration and authorization.

[0061] Step S3: With authorization, the encryption chip is compared and authenticated based on the preset key.

[0062] Step S4: If authentication is successful, read the kernel certificate stored in external storage and use the kernel certificate to verify the integrity of the kernel image. If the verification is successful, start the kernel. In this embodiment, the kernel certificate contains a public key and a hash value of the kernel image. When verifying the integrity of the kernel image using the kernel certificate, the validity of the kernel certificate is first verified using the public key, and then the hash value of the kernel image is compared to determine whether the image is complete.

[0063] Step S5: After the kernel boots up, mount the decrypted root file system.

[0064] In step S1 above, the main function is to perform secure boot and startup verification. The secure boot ROM is code embedded within the main control unit and cannot be modified once the main control unit is created. Its function is to read and verify the boot code stored on external storage.

[0065] In step S1 above, the encryption chip is configured and verified, including:

[0066] The system obtains root certificate information, executes the code embedded in the secure boot ROM, loads and verifies the root certificate, and uses the hash value of the RSA public key stored in the one-time programmable memory to verify the legality of the public key in the root certificate, thereby verifying the legality of the public key in the root certificate.

[0067] The secure boot code on external storage is loaded and verified. At the same time, the legality of the secure boot code is verified by using the public key and the hash value of the secure boot code stored in the root certificate to prevent tampering.

[0068] After verification is complete, load, verify, and start the security system;

[0069] Exit the secure boot mode and enter the normal boot process to initialize peripherals and power management.

[0070] In this embodiment, when executing the code embedded in the secure boot ROM, the code is written in standard C language, compiled using the KEIL C compiler, and downloaded to the encryption chip. Some key code from the boot program is ported to the encryption chip for execution. This key code includes the program's boot code and core code.

[0071] In actual operation, the program segment within the encryption chip is executed by calling functions to obtain the execution result, which is then used as input data for further execution of the user program. Therefore, the encryption chip becomes an integral part of the product, and since the code runs internally within the encryption chip, pirates cannot crack it, fundamentally eliminating the possibility of program decryption.

[0072] In step S2 above, obtaining the master control parameter information, performing registration and authorization includes:

[0073] The system obtains the chip identification number (CHIP ID) and MAC address from the main control unit, and transmits these information, along with key parameters stored in the encrypted chip, to the database server. The database server decrypts the CHIP ID, MAC address, and key parameters, performs registration, and then generates a unique activation code based on this information. This code is then encrypted and returned to the main control unit for authorization. During the normal startup phase, the chip identification number (CHIP ID), MAC address, and key parameters stored in the encrypted chip are uploaded to the database server via Ethernet. The database server generates a unique activation code based on the CHIP ID, MAC address, and key parameters and returns it to the device for authorization. These key parameters are core customized parameters, such as the key. The key parameters are obtained as follows: Figure 5 As shown.

[0074] In step S3 above, the encryption chip is compared and authenticated, including:

[0075] Both the main control unit and the encryption chip have the same set of keys pre-installed. During operation, the main control unit sends a generated random number to the encryption chip. Upon receiving the random number, the encryption chip uses the pre-installed key to simultaneously perform symmetric encryption on the random number, generating two sets of ciphertext. The main control unit then compares the two sets of ciphertext to verify the encryption chip's legitimacy. Therefore, the encryption chip's authentication relies on encrypting the same random number using a common symmetric encryption algorithm (3DES, AES, etc.) and comparing the results. Due to the characteristics of symmetric algorithms, only when both parties use the same key can they obtain the same encryption result, thus determining the other party's legitimacy. Its security depends heavily on the inherent strength of the symmetric encryption algorithm and the secure storage of the key. Using a symmetric key to encrypt plaintext data before transmission prevents line attacks and ensures that the key cannot be obtained by intercepting communication data over the line.

[0076] In step S4 above, after the kernel is started, it also performs a reverse verification process: calling the verification module to verify the normal startup code data, and at the same time continuously detecting the verification pass mark through the monitoring code in the first CPU core of the main control terminal until the verification is successful or the timeout occurs; if the verification fails, the device is restarted.

[0077] In step S5 above, after kernel verification and boot are complete, the root file system is mounted. Before mounting, the root file system needs to be decrypted. The system kernel provides a Device mapper that maps logical devices to physical devices. This mapping includes the mapping device, the mapping table, and the target device. The root file system is mapped to the / dev / dm-0 device via the Device mapper. After formatting the / dev / dm-0 device, it is mounted to the system root directory. The mapping device is a logical abstraction; it establishes a mapping with the target device through the mapping relationship described in the mapping table.

[0078] In step S1 above, after verification is completed, the loading, verification, and startup of the security system includes:

[0079] The security system and the corresponding Secure OS certificate stored in the external storage are loaded. The validity of the certificate and Secure OS is verified by using the hash value of Secure OS and the corresponding public key. The Secure OS certificate contains the hash value of Secure OS and the corresponding public key.

[0080] Once the verification passes, continue loading and verifying the normal startup code data.

[0081] Load the ordinary boot code data and the corresponding UBOOT certificate stored in the external storage, and verify the legitimacy of the certificate and UBOOT using the UBOOT public key and hash value respectively. The UBOOT certificate stores the hash value of the ordinary boot code and the corresponding public key.

[0082] Once the verification passes, continue executing the normal startup code until the normal startup process begins.

[0083] The hardware anti-copying encryption method implemented in this embodiment is a novel security technology. It establishes a secure boot architecture applied to the main control unit and the encryption chip. The key components included in the main control unit include:

[0084] 1. The Secure Boot ROM is a piece of circuit logic inside the secure chip. It is executed every time the chip boots up. Together with the RSA public key stored in the one-time programmable memory, it verifies the integrity of the boot program on the external storage device (NAND / EMMC). The unmodifiable nature and enforceable execution of the Secure Boot ROM ensure the entire secure boot process.

[0085] 2. One-time programmable memory (IPM) stores the root RSA public key required for verification. Each manufacturer stores its own root RSA private key and writes the corresponding root RSA public key into a designated area of ​​the chip's IPM during mass production. The IPM's one-time write capability means that after mass production and flashing, the chip's root RSA public key is controlled by the manufacturer and can never be modified by a third party. In other words, control of the chip firmware rests with the manufacturer who possesses the root RSA key.

[0086] 3. Encryption engine, which provides support and acceleration for firmware verification algorithms. Currently, the hardware acceleration algorithms used are RSA asymmetric decryption algorithm and SHA digital digest algorithm.

[0087] In this embodiment, the secure boot architecture integrates security features within the main control unit itself. By establishing a complete trust chain, it ensures that the system program loaded on the device is not tampered with, preventing intrusive chip-splitting attacks on the main control unit. Simultaneously, it maximizes the security features of the encryption chip, allowing the encryption chip and the main control unit to work together. Core code is stored and executed separately in the main control unit and the encryption chip, meaning that even if the main control unit is cracked, it cannot obtain all the core critical code. This significantly enhances the overall system security level, achieving a qualitative leap in system security and making it impossible for pirates and cracking teams to analyze the system, thus preventing product piracy.

[0088] In practical applications, the TEE (Trusted Execution Environment) is a software and hardware functional unit integrated within the main controller. The first step is secure boot and startup verification, which is crucial for this invention to effectively prevent invasive chip-splitting attacks on the main controller. It fully utilizes the TEE to prevent system program tampering and lays the environmental foundation for the subsequent implementation of encryption chips.

[0089] like Figure 2 As shown, Figure 2 The startup verification process of this invention is described. First, the code embedded in the secure boot ROM is executed to load and verify the root certificate. If the verification passes, the secure boot code is loaded and verified again; otherwise, the startup process exits.

[0090] Since the root certificate stores the public key and the hash value of the secure boot code, verifying the public key in the root certificate and the validity of the root certificate is accomplished by using the hash value of the root public key pre-installed in the one-time programmable memory. After verifying the public key, the validity of the secure boot code can be verified using the hash value of the root public key and the secure boot code. Then, the secure system (Secure OS) and its corresponding Secure OS certificate, stored in external storage, are loaded. The certificate stores the hash value of the Secure OS and its corresponding public key. The validity of the certificate and the Secure OS is verified using the Secure OS public key and its hash value, respectively. If the verification passes, the normal boot code (UBOOT) is loaded and verified; otherwise, the boot process exits.

[0091] Next, the UBOOT and its corresponding certificate stored in external storage are loaded. The certificate contains the hash value of UBOOT and its corresponding public key. The validity of the certificate and UBOOT is verified using the UBOOT public key and hash value, respectively. If the verification passes, the UBOOT startup code continues to execute; otherwise, the startup process terminates.

[0092] Finally, the normal boot process begins, during which some core code has been ported to the encryption chip, such as... Figure 3 As shown. When the master control unit executes critical code, it notifies the encryption chip to execute it via command. After the encryption chip completes its execution, it sends the result back to the master control unit. If the result returned by the encryption chip is correct, the master control unit continues to execute the startup process; otherwise, the startup is terminated.

[0093] Then, the second step is performed: registration and authorization. In this step, the CHIP ID and MAC address of the main control terminal, as well as a set of parameters stored in the encryption chip, are transmitted to the database server via Ethernet. The server calculates a unique activation code and then sends it to the main control terminal. The data is encrypted throughout the Ethernet transmission process to ensure data security.

[0094] like Figure 4 As shown, Figure 4 The registration and authorization process is described. First, the master controller obtains its CHIP ID and MAC address for registration. Then, it retrieves a set of key parameters stored in the encryption chip. Specifically, the master controller sends an 8-byte random number RND1 to the encryption chip, while the encryption chip generates an 8-byte random number RND2. At the encryption chip, RND1 and RND2 are processed (e.g., XORed) to obtain a random initialization vector IV. The stored key parameters are then encrypted using AES with a preset key KEY and the random initialization vector and sent to the master controller, along with RND2. At the master controller, RND2 and its own generated RND1 are processed using the same method to obtain the initialization vector IV. The key parameters from the encryption chip are then decrypted using the preset key and the initialization vector to obtain the original key parameters. Next, the master controller encrypts the CHIP ID, MAC address, and key parameters and sends them to the database server via Ethernet. On the database server, the CHIP ID, MAC address, and key parameters are decrypted, registration is performed, and a unique activation code is generated, encrypted, and sent to the master controller. Finally, the main control unit decrypts the unique activation code for authorization (e.g., by comparing the unique activation code for authorization). If authorization fails, the startup process is terminated.

[0095] Next, proceed to the third step: encryption chip comparison and authentication, such as... Figure 6 As shown, in this step, the 3DES symmetric algorithm is ported to the master control unit, and the same set of keys (KEY) is pre-installed on both the master control unit and the encryption chip during the factory release stage. During the operation phase, the master control unit generates a random number RND and sends it to the encryption chip. Then, both ends of the encryption chip simultaneously perform 3DES symmetric encryption on RND using the pre-installed keys (KEY) to generate ciphertexts C1 and C2. Finally, the master control unit compares C1 and C2. If they are the same, it proves that the encryption chip is legitimate, and the master control program continues to run; if they are different, it proves that the encryption chip is illegitimate, and the master control program exits.

[0096] Then, the fourth step is executed: loading and verifying the kernel, which involves reading the kernel certificate stored in external storage to verify the integrity of the kernel image. If the verification passes, the kernel is started; otherwise, the startup process is exited.

[0097] Furthermore, to enhance the security level of the verification process, in addition to the one-way verification during startup, a reverse verification process has been added, such as... Figure 7As shown, it includes a CPU verification module and a CPUs monitoring module. After the kernel boots up, it loads the CPU verification module, which calls the verification interface to verify the U-Boot data. Simultaneously, the monitoring code in the main control's small CPU cores (CPUs) continuously checks the verification pass flag until verification is successful or a timeout occurs. If verification fails, the device is restarted. Specifically, Netlink sends the public key, U-Boot, and signature to the kernel module. Netlink receives the data, verifies the firmware's legitimacy code, and if verification is successful, sets the verification flag to TRUE. It then checks if the verification flag is TRUE; if so, the verification passes. The verification flag is checked repeatedly for N times, and if a timeout occurs, the verification flag is checked again; if so, the verification passes. If verification fails, the chip is reset.

[0098] Finally, the fifth step is executed: mounting the root file system. Once the kernel has booted, it begins mounting the root file system. To enhance user data security, the root file system is encrypted; therefore, it needs to be decrypted during boot before it can be mounted.

[0099] An embodiment of a hardware anti-copying encryption device based on TEE and encryption chip:

[0100] like Figure 8 As shown, the present invention also provides a hardware anti-copying encryption device based on TEE and encryption chip, comprising:

[0101] The secure boot unit 10 is used to execute boot code to configure and verify the encryption chip.

[0102] Registration and authorization unit 20 is used to obtain master control parameter information and perform registration and authorization.

[0103] The comparison authentication unit 30, with authorization, performs comparison authentication on the encryption chip based on a preset key.

[0104] Load and verify kernel unit 40. If authentication is successful, read the kernel certificate stored in external storage, use the kernel certificate to verify the integrity of the kernel image, and if the verification is successful, start the kernel.

[0105] Mount system unit 50 is used to mount the decrypted root file system after the kernel has started.

[0106] In the secure boot unit 10, the main function is to perform secure boot and startup verification. The secure boot ROM is code embedded in the main control unit and cannot be changed once the main control unit is created. Its responsibility is to read and verify the boot code stored in the external storage device.

[0107] In the secure boot unit 10, the encryption chip is configured and verified, including:

[0108] The system obtains root certificate information, executes the code embedded in the secure boot ROM, loads and verifies the root certificate, and uses the hash value of the RSA public key stored in the one-time programmable memory to verify the legality of the public key in the root certificate, thereby verifying the legality of the public key in the root certificate.

[0109] The secure boot code on external storage is loaded and verified. At the same time, the legality of the secure boot code is verified by using the public key and the hash value of the secure boot code stored in the root certificate to prevent tampering.

[0110] After verification is complete, load, verify, and start the security system;

[0111] Exit the secure boot mode and enter the normal boot process to initialize peripherals and power management.

[0112] In this embodiment, when executing the code embedded in the secure boot ROM, the code is written in standard C language, compiled by the KEIL C compiler, and downloaded to the encryption chip. Some key code in the boot program is then ported to the encryption chip for execution.

[0113] In actual operation, the program segment within the encryption chip is executed by calling functions to obtain the execution result, which is then used as input data for further execution of the user program. Therefore, the encryption chip becomes an integral part of the product, and since the code runs internally within the encryption chip, pirates cannot crack it, fundamentally eliminating the possibility of program decryption.

[0114] In the registration and authorization unit 20, master control parameter information is obtained, and registration and authorization are performed, including:

[0115] The system obtains the chip identification number (CHIP ID) and MAC address from the main control unit, and transmits these information, along with key parameters stored in the encrypted chip, to the database server. The database server decrypts the CHIP ID, MAC address, and key parameters, performs registration, and then generates a unique activation code based on this information. This code is then encrypted and returned to the main control unit for authorization. Specifically, during the normal startup phase, the chip identification number (CHIP ID), MAC address, and key parameters stored in the encrypted chip are uploaded to the database server via Ethernet. The database server generates a unique activation code based on the CHIP ID, MAC address, and key parameters and returns it to the device for authorization.

[0116] In the comparison and authentication unit 30, the encryption chip is compared and authenticated, including:

[0117] Both the main control unit and the encryption chip have the same set of keys pre-installed. During operation, the main control unit sends a generated random number to the encryption chip. Upon receiving the random number, the encryption chip uses the pre-installed key to simultaneously perform symmetric encryption on the random number, generating two sets of ciphertext. The main control unit then compares the two sets of ciphertext to verify the encryption chip's legitimacy. Therefore, the encryption chip's authentication relies on encrypting the same random number using a common symmetric encryption algorithm (3DES, AES, etc.) and comparing the results. Due to the characteristics of symmetric algorithms, only when both parties use the same key can they obtain the same encryption result, thus determining the other party's legitimacy. Its security depends heavily on the inherent strength of the symmetric encryption algorithm and the secure storage of the key. Using a symmetric key to encrypt plaintext data before transmission prevents line attacks and ensures that the key cannot be obtained by intercepting communication data over the line.

[0118] In the kernel loading and verification unit 40, after the kernel is started, it also performs a reverse verification process: calling the verification module to verify the normal startup code data, and continuously checking the verification pass flag through the monitoring code in the first CPU core of the main control terminal until the verification is successful or the timeout occurs; if the verification fails, the device is restarted.

[0119] In the mounting system unit 50, the root file system is mounted after the kernel verification and startup are completed. The root file system needs to be decrypted before mounting.

[0120] Therefore, the present invention has the following beneficial effects:

[0121] 1. Strong Anti-Copying Capability: Compared to traditional anti-copying solutions, this invention's firmware anti-tampering function based on TEE effectively prevents intrusive attacks on the main control unit, thus ensuring that the comparison and authentication process on the main control unit cannot be cracked. Simultaneously, it maximizes the security features of the encryption chip, allowing the encryption chip and the main control unit to work together. Even if the main control unit is cracked alone, it will be impossible to obtain all the core critical code, greatly increasing the difficulty of cracking and improving the security of system data.

[0122] 2. High system security: The firmware anti-tampering function of this invention effectively prevents hacker attacks and re-flashing, ensuring that the hardware can only run authorized system software, thereby improving system security.

[0123] 3. High user data confidentiality: The hardware system is encrypted to protect sensitive user data from being easily obtained.

[0124] 4. High speed: TEE implements commonly used cryptographic algorithm frameworks for encryption / decryption, signature verification, and digest calculation. Therefore, the method of this invention takes less time and can quickly decrypt and mount the encrypted root file system without affecting the system startup speed.

[0125] 5. Easy to implement: Based on the secure boot architecture definition, by establishing a complete trust chain, it ensures that the system program loaded by the device is not tampered with, and prevents intrusive fragmentation attacks on the main controller.

[0126] In one embodiment, an electronic device is provided, which may be a server. The computer device includes a processor, memory, and a network interface connected via a system bus. The processor provides computing and control capabilities. The memory includes a non-volatile storage medium and internal memory. The non-volatile storage medium stores an operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage medium. The database stores data. The network interface communicates with external terminals via a network connection. When the computer program is executed by the processor, it implements a hardware anti-copying encryption method based on a TEE and an encryption chip.

[0127] Those skilled in the art will understand that the electronic device structure shown in this embodiment is only a partial structure related to the solution of this application and does not constitute a limitation on the electronic device to which the solution of this application is applied. The specific electronic device may include more or fewer components than shown in this embodiment, or combine certain components, or have different component arrangements.

[0128] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon that, when executed by a processor, implements the steps in the above method embodiments.

[0129] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the methods described above. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, or optical storage, etc. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc.

[0130] Furthermore, the logical instructions in the aforementioned memory can be implemented as software functional units and sold or used as independent products, and can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0131] Therefore, this invention provides an electronic device and storage medium based on a TEE and an encryption chip for hardware anti-copying encryption, comprising: one or more memories and one or more processors. The memories are used to store program code and intermediate data generated during program execution, storage of model output results, and storage of the model and model parameters; the processors are used for the processor resources occupied by the code execution and multiple processor resources occupied during model training.

[0132] 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.

[0133] 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 hardware anti-copying encryption method based on TEE and encryption chip, characterized in that, include: Execute the boot code to configure and verify the encryption chip; Obtain master control parameter information, and perform registration and authorization; With authorization, the encryption chip is compared and authenticated based on a pre-set key; If authentication is successful, the kernel certificate stored in external storage is read, and the integrity of the kernel image is verified using the kernel certificate. If the verification is successful, the kernel is started. After the kernel boots up, mount the decrypted root file system; The configuration and verification of the encryption chip includes: Obtain root certificate information, execute the code embedded in the secure boot ROM, load and verify the root certificate, thereby verifying the legitimacy of the public key in the root certificate; The secure boot code from external storage is loaded and verified, and its legitimacy is verified using the public key and the hash value of the secure boot code stored in the root certificate. After verification is complete, load, verify, and start the security system; Exit the secure boot mode and enter the normal boot process; When executing the code embedded in the secure boot ROM, the code is written in standard C language, compiled by the KEIL C compiler, and downloaded to the encryption chip. Some key code in the boot program is ported to the encryption chip for execution. In actual operation, the program segment inside the encryption chip is run by calling functions to obtain the running result, and this result is used as input data for further running of the user program; The process of obtaining master control parameter information, registering, and authorizing includes: The system obtains the chip identification number (CHIP ID) and MAC address from the main control terminal, and transmits the chip identification number (CHIP ID), MAC address, and key parameters stored in the encrypted chip to the database server. The database server decrypts the CHIP ID, MAC address, and key parameters, registers the chip, and then generates a unique activation code based on this information, encrypts it, and returns it to the main control terminal for authorization. The comparison and authentication of the encryption chip includes: The same set of keys is preset in the main control terminal and the encryption chip. During the operation phase, the main control terminal sends a set of random numbers to the encryption chip. After receiving the random number, the encryption chip uses the preset key to symmetrically encrypt the random number to generate two sets of ciphertext. The main control terminal compares the two sets of ciphertext to confirm whether the encryption chip is legitimate.

2. The method according to claim 1, characterized in that: After the kernel completes startup, it also performs a reverse verification process: calling the verification module to verify the normal startup code data, and continuously checking the verification pass flag through the monitoring code in the first CPU core of the main control terminal until the verification passes or times out; if the verification fails, the device is restarted.

3. The method according to claim 1, characterized in that, Loading, verifying, and starting the security system, including: The security system and the corresponding Secure OS certificate stored in the external storage are loaded. The validity of the certificate and Secure OS is verified by using the hash value of Secure OS and the corresponding public key. The Secure OS certificate contains the hash value of Secure OS and the corresponding public key.

4. The method according to claim 3, characterized in that: Once the verification passes, continue loading and verifying the normal startup code data; Load the ordinary boot code data and the corresponding UBOOT certificate stored in the external storage, and verify the legitimacy of the certificate and UBOOT using the UBOOT public key and hash value respectively. The UBOOT certificate stores the hash value of the ordinary boot code and the corresponding public key. Once the verification passes, continue executing the normal startup code until the normal startup process begins.

5. The method according to any one of claims 1 to 4, characterized in that, The mounted and decrypted root file system includes: The system kernel provides a Device mapper that maps logical devices to physical devices. This mapping includes a mapping device, a mapping table, and a target device. The root file system is mapped to the / dev / dm-0 device through the Device mapper. After the / dev / dm-0 device is formatted as a file system, it is mounted to the system root directory. The mapping device is a logical abstraction that establishes a mapping with the target device through the mapping relationship described by the mapping table.

6. A hardware anti-copying encryption device based on TEE and encryption chip, characterized in that, include: The secure boot unit is used to execute boot code to configure and verify the encryption chip; The registration and authorization unit is used to obtain master control parameter information and perform registration and authorization. The comparison and authentication unit, with authorization, performs comparison and authentication of the encryption chip based on a preset key; Load and verify the kernel unit. If authentication is successful, read the kernel certificate stored in external storage, use the kernel certificate to verify the integrity of the kernel image, and if the verification is successful, start the kernel. The system unit is used to mount the decrypted root file system after the kernel has booted up. The configuration and verification of the encryption chip includes: Obtain root certificate information, execute the code embedded in the secure boot ROM, load and verify the root certificate, thereby verifying the legitimacy of the public key in the root certificate; The secure boot code from external storage is loaded and verified, and its legitimacy is verified using the public key and the hash value of the secure boot code stored in the root certificate. After verification is complete, load, verify, and start the security system; Exit the secure boot mode and enter the normal boot process; When executing the code embedded in the secure boot ROM, the code is written in standard C language, compiled by the KEIL C compiler, and downloaded to the encryption chip. Some key code in the boot program is ported to the encryption chip for execution. In actual operation, the program segment inside the encryption chip is run by calling functions to obtain the running result, and this result is used as input data for further running of the user program; The process of obtaining master control parameter information, registering, and authorizing includes: The system obtains the chip identification number (CHIP ID) and MAC address from the main control terminal, and transmits the chip identification number (CHIP ID), MAC address, and key parameters stored in the encrypted chip to the database server. The database server decrypts the CHIP ID, MAC address, and key parameters, registers the chip, and then generates a unique activation code based on this information, encrypts it, and returns it to the main control terminal for authorization. The comparison and authentication of the encryption chip includes: The same set of keys is preset in the main control terminal and the encryption chip. During the operation phase, the main control terminal sends a set of random numbers to the encryption chip. After receiving the random number, the encryption chip uses the preset key to symmetrically encrypt the random number to generate two sets of ciphertext. The main control terminal compares the two sets of ciphertext to confirm whether the encryption chip is legitimate.