Executable file encryption method, system, device and medium for programmable chip

By compiling multiple keys into the executable file of the programmable chip and binding the encryption process with the chip ID address, the problem of programmable chips being easily cracked and copied is solved, achieving highly difficult file protection and unique operation.

CN116578998BActive Publication Date: 2026-07-31HUNAN NEXT GENERATION INSTRUMENTAL T&C TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
HUNAN NEXT GENERATION INSTRUMENTAL T&C TECH CO LTD
Filing Date
2023-03-30
Publication Date
2026-07-31

AI Technical Summary

Technical Problem

In existing technologies, the executable files of programmable chips are easily cracked and copied, leading to product plagiarism. Adding external encryption chips increases costs and design complexity.

Method used

Multiple keys are compiled into the executable file of the programmable chip. By judging the validity of the key position and using the encryption algorithm to calculate the encryption field to replace the key field, the encryption process is bound by the unique ID address of the programmable chip, which increases the difficulty of cracking.

Benefits of technology

This effectively prevents products from being copied after the programmable chip is cracked, increases the difficulty of cracking the executable file, and ensures that the executable file can only run on a specific chip.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116578998B_ABST
    Figure CN116578998B_ABST
Patent Text Reader

Abstract

This invention discloses a method, system, device, and medium for encrypting executable files of programmable chips. The method compiles multiple keys into the executable file of the programmable chip; upon entering the bootloader, it checks the validity of the first position of each first key; if the first position of the first key is valid, the application file is authenticated; if the first position of the first key is invalid, a first encryption field is calculated based on the ID address of the programmable chip, and this first encryption field replaces the first key field corresponding to the first key; upon entering the application, it checks the validity of the second position of each second key; if the second position of the second key is valid, the bootloader file is authenticated; if the second position of the second key is invalid, a second encryption field is calculated based on the ID address of the programmable chip, and this second encryption field replaces the second key field corresponding to the second key. This invention can prevent the product from being copied after the programmable chip has been cracked.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer technology, and in particular to a method, system, device, and medium for encrypting executable files of a programmable chip. Background Technology

[0002] An executable file describes the functions, operations, logic, and data processing that a programmable chip needs to perform. Essentially, the content of the executable file is a combination of machine instructions. Once powered on, all the work of the programmable chip is performed according to the instructions in the executable file. Any product containing a programmable chip downloads the executable file into its memory, and the actions and logic performed by the chip after power-on are based on the instructions in the executable file. The executable file is compiled from code written by researchers. Therefore, the executable file is a confidential data file for any product; if leaked, the product can be easily copied by others.

[0003] Currently, numerous methods and techniques exist for reading executable files from memory, making product copying very common. For example, locking the chip's external interface (debugging interface) can prevent the normal reading of executable files, but this cannot be completely achieved using specialized methods by skilled hackers. External encryption chips can prevent product copying, but they incur additional costs and increase design workload and complexity, especially when hardware PCB size requirements are limited. Summary of the Invention

[0004] This invention aims to at least solve one of the technical problems existing in the prior art. To this end, this invention proposes a method, system, device, and medium for encrypting the executable file of a programmable chip, which can prevent the product from being copied after the programmable chip has been cracked.

[0005] In a first aspect, embodiments of the present invention provide an executable file encryption method for a programmable chip, the executable file encryption method for the programmable chip comprising:

[0006] Multiple keys are compiled into the executable file of the programmable chip; the executable file includes a bootloader file and an application file;

[0007] Upon entering the boot program, the first position of each first key in the application file is read, and it is determined whether the first position of each first key is valid. If the first position of the first key is valid, the application file is authenticated. If the first position of the first key is invalid, the first encryption field is calculated using an encryption algorithm based on the ID address of the programmable chip, and the first encryption field replaces the first key field corresponding to the first key to complete the encryption of the application file.

[0008] After the application file is authenticated or encrypted, the application is entered, and the second position of each second key in the bootloader file is read. The validity of the second position of each second key is determined. If the second position of the second key is valid, the bootloader file is authenticated. If the second position of the second key is invalid, the second encryption field is calculated using an encryption algorithm based on the ID address of the programmable chip, and the second encryption field replaces the second key field corresponding to the second key to complete the encryption of the bootloader file.

[0009] Compared with the prior art, the first aspect of the present invention has the following beneficial effects:

[0010] This method compiles multiple keys into the executable file of the programmable chip. Because multiple keys are compiled into the executable file, cracking requires cracking the algorithm corresponding to each key to obtain the executable file, thus increasing the difficulty of cracking the executable file. Upon entering the bootloader, it reads the first position of each first key in the application file and determines whether the first position of each first key is valid. If the first position of the first key is valid, the application file is authenticated. If the first position of the first key is invalid, the first encryption field is calculated using the encryption algorithm based on the ID address of the programmable chip, and this first encryption field replaces the first key field corresponding to the first key to complete the encryption of the application file. After completing the authentication or encryption of the application file, it enters the application and reads the bootloader. The second position of each second key in the file is checked to determine its validity. If the second position of the second key is valid, the bootloader file is authenticated. If the second position of the second key is invalid, a second encrypted field is calculated using an encryption algorithm based on the programmable chip's ID address. This second encrypted field replaces the second key field corresponding to the second key, thus completing the encryption of the bootloader file. Calculating the encrypted field using the programmable chip's ID address uniquely binds the executable file to the programmable chip. Since the programmable chip's ID address is unique, downloading the executable file to different programmable chips for cracking is unsuccessful. This increases the difficulty of cracking the executable file and prevents the product from being copied after the programmable chip is cracked.

[0011] According to some embodiments of the present invention, the step of authenticating the application file if the first position of the first key is valid includes:

[0012] The information at each of the first positions is decrypted, and the data at each of the first positions is obtained based on the decrypted information.

[0013] The encryption algorithm corresponding to each of the first positions is used to perform encryption calculations based on the ID address of the first position to obtain the calculation result;

[0014] The calculation result is compared with the data. If the calculation result and the data are consistent, the authentication of the application file is completed; if the calculation result and the data are inconsistent, the memory storing the application file is self-erased.

[0015] According to some embodiments of the present invention, if the first position of the first key is invalid, then calculating the first encrypted field using an encryption algorithm based on the ID address of the programmable chip, and replacing the first key field corresponding to the first key with the first encrypted field to complete the encryption of the application file, includes:

[0016] Retrieve the first key field corresponding to the first key in the application file, and save the first location of the first key field to the area for recording location information;

[0017] The ID address of the programmable chip is calculated using the encryption algorithm corresponding to the first key to obtain the first encryption field, and the first encryption field replaces the first key field corresponding to the first key.

[0018] Replace the first key field in the entire application file to complete the encryption of the application file.

[0019] According to some embodiments of the present invention, the step of authenticating the bootloader file if the second position of the second key is valid includes:

[0020] Decrypt the information at each of the second positions, and obtain the data at each of the second positions based on the decrypted information.

[0021] The encryption algorithm corresponding to each of the second positions is used to perform encryption calculations based on the ID address of the second position to obtain the calculation result;

[0022] The calculation result is compared with the data. If the calculation result and the data are consistent, the authentication of the bootloader file is completed. If the calculation result and the data are inconsistent, the memory storing the bootloader file is self-erased.

[0023] According to some embodiments of the present invention, if the second position of the second key is invalid, a second encrypted field is calculated using an encryption algorithm based on the ID address of the programmable chip, and the second encrypted field replaces the second key field corresponding to the second key to complete the encryption of the bootloader file, including:

[0024] The second key field corresponding to the second key is retrieved from the bootloader file, and the area where the second key field is located is saved to the area for recording location information.

[0025] The ID address of the programmable chip is calculated using the encryption algorithm corresponding to the second key to obtain the second encryption field, and the second encryption field replaces the second key field corresponding to the second key.

[0026] Replace the second key field in the entire bootloader file to complete the encryption of the bootloader file.

[0027] According to some embodiments of the present invention, the executable file encryption method for the programmable chip further includes:

[0028] Different encryption algorithms are used for keys located in different positions within the executable file.

[0029] According to some embodiments of the present invention, determining whether the first position of each first key is valid includes:

[0030] The executable file is stored in memory;

[0031] If the information in the first position of the first key is the default or erased value in the memory, then the first position is invalid;

[0032] If the information at the first position of the first key is the value after the first encryption field replaces the first key field corresponding to the first key, then the first position is valid.

[0033] Secondly, embodiments of the present invention also provide an executable file encryption system for a programmable chip, the executable file encryption system for the programmable chip comprising:

[0034] The file compilation unit is used to compile multiple keys into an executable file of the programmable chip; the executable file includes a bootloader file and an application file;

[0035] The first judgment unit is used to enter the boot program, read the first position of each first key in the application file, and judge whether the first position of each first key is valid; if the first position of the first key is valid, the application file is authenticated; if the first position of the first key is invalid, the first encryption field is calculated according to the ID address of the programmable chip using an encryption algorithm, and the first encryption field replaces the first key field corresponding to the first key to complete the encryption of the application file.

[0036] The second judgment unit is used to enter the application after completing the authentication or encryption of the application file, read the second position of each second key in the bootloader file, and determine whether the second position of each second key is valid; if the second position of the second key is valid, the bootloader file is authenticated; if the second position of the second key is invalid, the second encryption field is calculated according to the ID address of the programmable chip using an encryption algorithm, and the second encryption field replaces the second key field corresponding to the second key to complete the encryption of the bootloader file.

[0037] Thirdly, embodiments of the present invention also provide an executable file encryption device for a programmable chip, including at least one control processor and a memory for communicatively connecting to the at least one control processor; the memory stores instructions that can be executed by the at least one control processor, the instructions being executed by the at least one control processor to enable the at least one control processor to execute an executable file encryption method for a programmable chip as described above.

[0038] Fourthly, embodiments of the present invention also provide a computer-readable storage medium storing computer-executable instructions for causing a computer to execute an executable file encryption method for a programmable chip as described above.

[0039] It is understood that the beneficial effects of the second to fourth aspects compared with the related technologies are the same as the beneficial effects of the first aspect compared with the related technologies. Please refer to the relevant description in the first aspect above, which will not be repeated here. Attached Figure Description

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

[0041] Figure 1 This is a flowchart of an executable file encryption method for a programmable chip according to an embodiment of the present invention;

[0042] Figure 2 This is a schematic diagram of a custom key in the code of an embodiment of the present invention;

[0043] Figure 3 This is a schematic diagram of a custom key in an executable file according to an embodiment of the present invention;

[0044] Figure 4 This is a structural diagram of an executable file encryption system for a programmable chip according to an embodiment of the present invention. Detailed Implementation

[0045] Embodiments of the present invention are described in detail below. Examples of these embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and should not be construed as limiting the present invention.

[0046] In the description of this invention, the use of terms such as "first," "second," etc., is for the purpose of distinguishing technical features only and should not be construed as indicating or implying relative importance, or implicitly indicating the number of technical features indicated, or implicitly indicating the order of the technical features indicated.

[0047] In the description of this invention, it should be understood that the orientation descriptions, such as up, down, etc., are based on the orientation or positional relationship shown in the drawings and are only for the convenience of describing this invention and simplifying the description, and are not intended to indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation, and therefore should not be construed as a limitation of this invention.

[0048] In the description of this invention, it should be noted that, unless otherwise explicitly defined, terms such as "setting," "installation," and "connection" should be interpreted broadly, and those skilled in the art can reasonably determine the specific meaning of the above terms in this invention in conjunction with the specific content of the technical solution.

[0049] An executable file describes the functions, operations, logic, and data processing that a programmable chip needs to perform. Essentially, the content of the executable file is a combination of machine instructions. Once powered on, all the work of the programmable chip is performed according to the instructions in the executable file. Any product containing a programmable chip downloads the executable file into its memory, and the actions and logic performed by the chip after power-on are based on the instructions in the executable file. The executable file is compiled from code written by researchers. Therefore, the executable file is a confidential data file for any product; if leaked, the product can be easily copied by others.

[0050] Currently, numerous methods and techniques exist for reading executable files from memory, making product copying very common. For example, locking the chip's external interface (debugging interface) can prevent the normal reading of executable files, but this cannot be completely achieved using specialized methods by skilled hackers. External encryption chips can prevent product copying, but they incur additional costs and increase design workload and complexity, especially when hardware PCB size requirements are limited.

[0051] To address the aforementioned issues, this invention compiles multiple keys into the executable file of the programmable chip. By compiling multiple keys into the executable file, cracking requires breaking the algorithm corresponding to each key to obtain the executable file, thus increasing the difficulty of cracking the executable file. Upon entering the bootloader, the first position of each first key in the application file is read, and its validity is determined. If the first position of the first key is valid, the application file is authenticated. If the first position of the first key is invalid, a first encryption field is calculated based on the programmable chip's ID address using an encryption algorithm, and this first encryption field replaces the first key field corresponding to the first key, thus completing the encryption of the application file. After completing the authentication or encryption of the application file, the application is entered, and the... The second position of each second key in the bootloader file is checked for validity. If the second position of the second key is valid, the bootloader file is authenticated. If the second position of the second key is invalid, a second encrypted field is calculated using an encryption algorithm based on the programmable chip's ID address. This second encrypted field replaces the second key field corresponding to the second key, thus completing the encryption of the bootloader file. Calculating the encrypted field using the programmable chip's ID address uniquely binds the executable file to the programmable chip. Since the programmable chip's ID address is unique, downloading the executable file to different programmable chips for cracking is unsuccessful. This increases the difficulty of cracking the executable file and prevents the product from being copied after the programmable chip is cracked.

[0052] Reference Figure 1 This invention provides a method for encrypting the executable file of a programmable chip. This method includes, but is not limited to, steps S100 to S300, wherein:

[0053] Step S100: Compile multiple keys into the executable file of the programmable chip; the executable file includes a bootloader file and an application file;

[0054] Step S200: Enter the boot program, read the first position of each first key in the application file, and determine whether the first position of each first key is valid; if the first position of the first key is valid, then authenticate the application file; if the first position of the first key is invalid, then calculate the first encryption field according to the ID address of the programmable chip using an encryption algorithm, and replace the first key field corresponding to the first key with the first encryption field to complete the encryption of the application file.

[0055] Step S300: After completing the authentication or encryption of the application file, enter the application, read the second position of each second key in the bootloader file, and determine whether the second position of each second key is valid; if the second position of the second key is valid, then authenticate the bootloader file; if the second position of the second key is invalid, then calculate the second encryption field according to the ID address of the programmable chip using an encryption algorithm, and replace the second key field corresponding to the second key with the second encryption field to complete the encryption of the bootloader file.

[0056] In steps S100 to S300 of some embodiments, to increase the difficulty of cracking the executable file, this embodiment compiles multiple keys into the executable file of the programmable chip; to prevent the product from being copied after the programmable chip is cracked, this embodiment enters the boot program, reads the first position of each first key in the application file, and determines whether the first position of each first key is valid; if the first position of the first key is valid, the application file is authenticated; if the first position of the first key is invalid, a first encrypted field is calculated using an encryption algorithm based on the ID address of the programmable chip, and the first encrypted field replaces the first key field corresponding to the first key to complete the encryption of the application file; after completing the authentication or encryption of the application file, the application is entered, the second position of each second key in the boot program file is read, and the second position of each second key is determined to be valid; if the second position of the second key is valid, the boot program file is authenticated; if the second position of the second key is invalid, a second encrypted field is calculated using an encryption algorithm based on the ID address of the programmable chip, and the second encrypted field replaces the second key field corresponding to the second key to complete the encryption of the boot program file.

[0057] In some embodiments, if the first position of the first key is valid, then the application file is authenticated, including:

[0058] Decrypt the information at each first position, and obtain the data at each first position based on the decrypted information.

[0059] The encryption algorithm corresponding to each first position is used to perform encryption calculation based on the ID address of the first position to obtain the calculation result;

[0060] The system compares the calculation results with the data. If the results match, the application file authentication is complete; otherwise, it self-erases the storage where the application file is stored.

[0061] In this embodiment, if the application file is read from programmable chip A and downloaded to programmable chip B for execution, the results calculated by the same encryption algorithm will be different because the unique IDs of programmable chips A and B are different. At this time, the comparison authentication will fail. Only by using the same encryption algorithm on the same programmable chip can the authentication be passed. Therefore, this embodiment can increase the difficulty of cracking the application file, thereby preventing the product from being copied after the programmable chip is cracked.

[0062] In some embodiments, if the first position of the first key is invalid, a first encrypted field is calculated using an encryption algorithm based on the ID address of the programmable chip, and the first encrypted field replaces the first key field corresponding to the first key to complete the encryption of the application file, including:

[0063] Retrieve the first key field corresponding to the first key in the application file, and save the first location of the first key field to the area where the location information is recorded;

[0064] The ID address of the programmable chip is calculated using the encryption algorithm corresponding to the first key to obtain the first encryption field, and the first encryption field replaces the first key field corresponding to the first key.

[0065] Replace the first key field in the entire application file to complete the encryption of the application file.

[0066] In this embodiment, the first encrypted field is calculated using the ID address of the programmable chip. Since the ID address of each programmable chip is different, the encryption process of the application file can increase the difficulty of cracking the application file.

[0067] In some embodiments, if the second position of the second key is valid, then the bootloader file is authenticated, including:

[0068] Decrypt the information at each second position, and retrieve the data at each second position based on the decrypted information.

[0069] The encryption algorithm corresponding to each second position is used to perform encryption calculation based on the ID address of the second position to obtain the calculation result;

[0070] The system compares the calculation results with the data. If the results match, the bootloader file authentication is complete; otherwise, it self-erases the memory that stored the bootloader file.

[0071] In this embodiment, if the bootloader file is read from programmable chip A and downloaded to programmable chip B for execution, the results calculated by the same encryption algorithm will be different because the unique IDs of programmable chips A and B are different. At this time, the comparison authentication will fail. Only by using the same encryption algorithm on the same programmable chip can the authentication be passed. Therefore, this embodiment can increase the difficulty of cracking the bootloader file, thereby preventing the product from being copied after the programmable chip is cracked.

[0072] In some embodiments, if the second position of the second key is invalid, a second encrypted field is calculated using an encryption algorithm based on the ID address of the programmable chip, and the second encrypted field replaces the second key field corresponding to the second key to complete the encryption of the bootloader file, including:

[0073] The bootloader file retrieves the second key field corresponding to the second key and saves the area containing the second key field from the second location to the recording location information area.

[0074] The ID address of the programmable chip is calculated using the encryption algorithm corresponding to the second key to obtain the second encryption field, and the second encryption field replaces the second key field corresponding to the second key.

[0075] Replace the second key field in the entire bootloader file to complete the encryption of the bootloader file.

[0076] In this embodiment, the first encrypted field is calculated using the ID address of the programmable chip. Since the ID address of each programmable chip is different, the encryption process of the bootloader file can increase the difficulty of cracking the bootloader file.

[0077] In some embodiments, the executable file encryption method for a programmable chip further includes:

[0078] Different encryption algorithms are used for keys located in different positions within the executable file.

[0079] In this embodiment, different encryption algorithms are used for the keys in different locations. If the original executable file needs to be restored, all encryption algorithms must be cracked, thus increasing the difficulty of cracking the executable file.

[0080] In some embodiments, determining whether the first position of each first key is valid includes:

[0081] The executable file is stored in memory;

[0082] If the information in the first position of the first key is the default or erased value in memory, then the first position is invalid;

[0083] If the information in the first position of the first key is the value after replacing the first key field corresponding to the first key with the first encryption field, then the first position is valid.

[0084] To facilitate understanding by those skilled in the art, a set of preferred embodiments is provided below:

[0085] 1. Define a custom key randomly as an array in the ROM in the code. The compiler will then compile the key into the executable file during compilation. Because the data in the compiled executable file is unknown, theoretically, it's possible for the compiled executable file to contain fields identical to the custom key. Therefore, the longer the key, the lower the probability of this happening. This embodiment recommends a key length greater than or equal to 16 bytes. (Refer to...) Figures 2 to 3 The 32 bytes of the self-defined key, "ABC DEFGHIJKLMNOPQRSTUVWXYZ123456", are randomly defined in two places in the code. Figure 2 After compiling Figures a and b, you can see two places in the executable file. Figure 3 The location of the key is shown in Figures a and b.

[0086] It should be noted that this embodiment allows for the customization of multiple keys in the code. The more keys defined, the greater the difference in the actual executable file. The number of custom keys can be changed according to actual needs, and this embodiment does not impose a specific limit.

[0087] The purpose of defining multiple custom keys in this embodiment is to instruct the compiler to include the defined key fields in the executable file during generation. This allows the encryption process to retrieve the key locations. Developers who define multiple keys in their code will end up with multiple fields in the compiled executable file that are identical to the keys. However, the locations of these keys are uncertain and determined by the compiler. Therefore, identical code can generate different executable files under different compilers, thus increasing the difficulty of cracking the executable file.

[0088] 2. After power-on, the boot program enters and reads the information of the location of the saved application file key. It then determines whether the information of the location of the application file key is valid. The chip's executable files are stored in non-volatile memory (memory that will not lose data even without power). The validity of the location information is determined based on the characteristics of the non-volatile memory used by the chip to store the executable file. Taking the entire STM32F series as an example, the internal non-volatile memory used by the entire STM32F series to store the executable file has each bit set to 1 by default or after erasure. If the location information read by the program is the default or erased value of the non-volatile memory, it means that the information at that location is invalid.

[0089] If the obtained location information is valid, it means that the encryption of the application file has been completed and authentication can proceed directly. The application file authentication process is as follows:

[0090] (1) Decrypt the information at each location and obtain the data at each location based on the decrypted information;

[0091] (2) The encryption algorithm corresponding to each position is used to perform encryption calculation based on the ID address of that position to obtain the calculation result;

[0092] (3) Compare whether the calculation results and data are consistent. If the calculation results and data are consistent, the application file authentication is completed; if the calculation results and data are inconsistent, the storage of the application file is self-erased.

[0093] If the obtained location information is invalid, encryption is performed (taking an STM32 microcontroller as an example, the default value of flash memory is 0xff; if the obtained key location information is the default value of flash memory, it indicates that this is the first power-on). At this time, the bootloader will traverse the entire application file to find the field that matches the key and write the location information to the location used to store that information. The application file encryption process is as follows:

[0094] (1) Search for the key field that is the same as the key in the application file and save the location of the key field to the area for recording location information. The area for recording location information is as follows: The encryption process sequentially searches the entire executable file for a field that is exactly the same as the custom key. After the key is found, it will save information such as which time it was searched, its specific location (in professional terms, the address of the key), and how many keys were searched in total after the entire executable file was searched. After saving, when the location information is read again, it will not be the default value of the non-volatile memory. The next time the program is powered on, it can directly authenticate the executable file based on the information in it.

[0095] (2) The ID address of the programmable chip is calculated using the encryption algorithm corresponding to the key to obtain the encrypted field, and the encrypted field replaces the key field corresponding to the key; the calculation process is as follows:

[0096] After the bootloader records the location matching the key, it uses the unique ID of the programmable chip and a custom encryption algorithm to calculate an encrypted field of the same size as the key for each location. Taking the STM32 microcontroller as an example, the controller's unique ID is 12 bytes. Assuming the unique ID is "123456789abc", the first location is padded with '5' to make it 32 bits, the same as the key size (after padding, it becomes "55555555555555555555123456789abc"). Then, the key field is inverted and replaced. The second location is padded with '6' to make it 10 bytes before and after (after padding, it becomes "6666666666123456789abc66666666666"). Then, it is XORed with "1a2b3c4d5e6f7g8h9i0j1k2l3m4n5o6p" and replaced.

[0097] (3) Replace the key field in the entire application file to complete the encryption of the application file.

[0098] It should be noted that the custom encryption algorithm used for each key replacement can be different, and the more complex the encryption algorithm, the higher the security. The encryption algorithm used is an existing algorithm, which will not be described in detail in this embodiment.

[0099] In this embodiment, all encryption algorithms require the participation of a unique ID, but the encryption algorithms can be different; the specific algorithm used is determined by the developers. Encrypting this data is to improve security. If someone cracks the executable file, they won't know what this data segment is for unless they crack the algorithm. However, in this embodiment, each key uses a different encryption algorithm. Since N keys are defined in the code, there will be N encryption algorithms. Therefore, to restore the original executable file, all encryption algorithms must be cracked, which is virtually impossible.

[0100] 3. After the bootloader completes the encryption of the application or the authentication of the application file, it enters the application and encrypts or authenticates the bootloader file in the same way as in step 2. After both the application file and the bootloader file are authenticated or encrypted, the user logic is executed.

[0101] In this embodiment, after the executable file generated by the compiled code is downloaded to the programmable chip, it is modified based on the unique ID of each chip (a unique ID exists in almost every programmable device and cannot be changed), combined with a custom key and the result calculated by multiple encryption algorithms. This self-modifies the internal executable file, binding it to that chip and allowing it to run only on that chip. There are no restrictions on the degree of self-modification, the type of algorithms, or the number of algorithms; it is mainly determined by the developers based on the actual situation. Using this embodiment, after downloading the executable file to the programmable chip, the encryption process will automatically run once before leaving the factory. At this time, the internal executable file will be automatically modified by the encryption algorithm and bound to the chip. Therefore, the executable file inside the chip can only run normally on that chip and cannot pass authentication on any other chip. Therefore, the technical solution of this embodiment can prevent the product from being copied after the programmable chip is cracked. Furthermore, the key in this embodiment is only defined in the code and not used in the business logic; it is only used for authentication. Therefore, replacing the result calculated by the encryption algorithm will not affect the normal operation of the code.

[0102] Reference Figure 4 This invention also provides an executable file encryption system for a programmable chip. The executable file encryption system includes a file compilation unit 100, a first judgment unit 200, and a second judgment unit 300, wherein:

[0103] The file compilation unit 100 is used to compile multiple keys into an executable file of the programmable chip; the executable file includes a bootloader file and an application file;

[0104] The first judgment unit 200 is used to enter the boot program, read the first position of each first key in the application file, and judge whether the first position of each first key is valid. If the first position of the first key is valid, the application file is authenticated. If the first position of the first key is invalid, the first encryption field is calculated according to the ID address of the programmable chip using an encryption algorithm, and the first encryption field replaces the first key field corresponding to the first key to complete the encryption of the application file.

[0105] The second judgment unit 300 is used to enter the application after completing the authentication or encryption of the application file, read the second position of each second key in the boot program file, and determine whether the second position of each second key is valid; if the second position of the second key is valid, the boot program file is authenticated; if the second position of the second key is invalid, the second encryption field is calculated according to the ID address of the programmable chip using an encryption algorithm, and the second encryption field replaces the second key field corresponding to the second key to complete the encryption of the boot program file.

[0106] It should be noted that since the executable file encryption system for a programmable chip in this embodiment is based on the same inventive concept as the executable file encryption method for a programmable chip described above, the corresponding content in the method embodiment is also applicable to this system embodiment, and will not be described in detail here.

[0107] This invention also provides an executable file encryption device for a programmable chip, comprising: at least one control processor and a memory for communicatively connecting to the at least one control processor.

[0108] Memory, as a non-transitory computer-readable storage medium, can be used to store non-transitory software programs and non-transitory computer-executable programs. Furthermore, memory may include high-speed random access memory, and may also include non-transitory memory, such as at least one disk storage device, flash memory device, or other non-transitory solid-state storage device. In some embodiments, memory may optionally include memory remotely located relative to the processor, and these remote memories can be connected to the processor via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.

[0109] The non-transitory software program and instructions required to implement the executable file encryption method for a programmable chip according to the above embodiments are stored in memory. When executed by a processor, the executable file encryption method for a programmable chip according to the above embodiments is executed, for example, the method described above is executed. Figure 1 The method steps S100 to S300.

[0110] The system embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0111] This invention also provides a computer-readable storage medium storing computer-executable instructions. These instructions, when executed by one or more control processors, enable the processors to perform an executable file encryption method for a programmable chip as described in the above method embodiments. For example, they can execute the methods described above. Figure 1 The functions of steps S100 to S300 in the method.

[0112] It will be understood by those skilled in the art that all or some of the steps and systems in the methods disclosed above can be implemented as software, firmware, hardware, and suitable combinations thereof. Some or all of the physical components can be implemented as software executed by a processor, such as a central processing unit, digital signal processor, or microprocessor, or as hardware, or as an integrated circuit, such as an application-specific integrated circuit. Such software can be distributed on a computer-readable medium, which can include computer storage media (or non-transitory media) and communication media (or transient media). As is known to those skilled in the art, the term computer storage media includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information (such as computer-readable instructions, data structures, program modules, or other data). Computer storage media includes, but is not limited to, RAM, ROM, EEPROM, flash memory or other memory technologies, CD-ROM, digital versatile disc (DVD) or other optical disc storage, magnetic cartridges, magnetic tape, disk storage or other magnetic storage devices, or any other medium that can be used to store desired information and is accessible to a computer. Furthermore, as is known to those skilled in the art, communication media typically contain computer-readable instructions, data structures, program modules, or other data in modulated data signals such as carrier waves or other transmission mechanisms, and may include any information delivery medium.

[0113] The embodiments of the present invention have been described in detail above with reference to the accompanying drawings. However, the present invention is not limited to the above embodiments. Within the scope of knowledge possessed by those skilled in the art, various changes can be made without departing from the spirit of the present invention.

Claims

1. An executable encryption method of a programmable chip, characterized by, The executable file encryption method of the programmable chip includes: Multiple keys are compiled into the executable file of the programmable chip; the executable file includes a bootloader file and an application file; Upon entering the boot program, the first position of each first key in the application file is read, and it is determined whether the first position of each first key is valid. If the first position of the first key is valid, the application file is authenticated. If the first position of the first key is invalid, the first encryption field is calculated using an encryption algorithm based on the ID address of the programmable chip, and the first encryption field replaces the first key field corresponding to the first key to complete the encryption of the application file. After the application file is authenticated or encrypted, the application is entered, and the second position of each second key in the bootloader file is read. The validity of the second position of each second key is determined. If the second position of the second key is valid, the bootloader file is authenticated. If the second position of the second key is invalid, the second encryption field is calculated using an encryption algorithm based on the ID address of the programmable chip, and the second encryption field replaces the second key field corresponding to the second key to complete the encryption of the bootloader file.

2. The executable file encryption method for a programmable chip according to claim 1, characterized in that, If the first position of the first key is valid, then the application file is authenticated, including: The information at each of the first positions is decrypted, and the data at each of the first positions is obtained based on the decrypted information. The encryption algorithm corresponding to each of the first positions is used to perform encryption calculations based on the ID address of the first position to obtain the calculation result; The calculation result is compared with the data. If the calculation result and the data are consistent, the authentication of the application file is completed; if the calculation result and the data are inconsistent, the memory storing the application file is self-erased.

3. The executable file encryption method for a programmable chip according to claim 1, characterized in that, If the first position of the first key is invalid, then a first encrypted field is calculated using an encryption algorithm based on the ID address of the programmable chip, and the first encrypted field replaces the first key field corresponding to the first key to complete the encryption of the application file, including: Retrieve the first key field corresponding to the first key in the application file, and save the first location of the first key field to the area for recording location information; The ID address of the programmable chip is calculated using the encryption algorithm corresponding to the first key to obtain the first encryption field, and the first encryption field replaces the first key field corresponding to the first key. Replace the first key field in the entire application file to complete the encryption of the application file.

4. The executable file encryption method for a programmable chip according to claim 1, characterized in that, If the second position of the second key is valid, then the bootloader file is authenticated, including: Decrypt the information at each of the second positions, and obtain the data at each of the second positions based on the decrypted information. The encryption algorithm corresponding to each of the second positions is used to perform encryption calculations based on the ID address of the second position to obtain the calculation result; The calculation result is compared with the data. If the calculation result and the data are consistent, the authentication of the bootloader file is completed. If the calculation result and the data are inconsistent, the memory storing the bootloader file is self-erased.

5. The executable file encryption method for a programmable chip according to claim 1, characterized in that, If the second position of the second key is invalid, a second encrypted field is calculated using an encryption algorithm based on the ID address of the programmable chip, and the second encrypted field replaces the second key field corresponding to the second key to complete the encryption of the bootloader file, including: The second key field corresponding to the second key is retrieved from the bootloader file, and the area where the second key field is located is saved to the area for recording location information. The ID address of the programmable chip is calculated using the encryption algorithm corresponding to the second key to obtain the second encryption field, and the second encryption field replaces the second key field corresponding to the second key. Replace the second key field in the entire bootloader file to complete the encryption of the bootloader file.

6. The executable file encryption method for a programmable chip according to claim 1, characterized in that, The executable file encryption method for the programmable chip also includes: Different encryption algorithms are used for keys located in different positions within the executable file.

7. The executable file encryption method for a programmable chip according to claim 1, characterized in that, The determination of whether the first position of each of the first keys is valid includes: The executable file is stored in the memory; If the information in the first position of the first key is the default or erased value in the memory, then the first position is invalid; If the information at the first position of the first key is the value after the first encryption field replaces the first key field corresponding to the first key, then the first position is valid.

8. An executable file encryption system for a programmable chip, characterized in that, The executable file encryption system of the programmable chip includes: The file compilation unit is used to compile multiple keys into an executable file of the programmable chip; the executable file includes a bootloader file and an application file; The first judgment unit is used to enter the boot program, read the first position of each first key in the application file, and judge whether the first position of each first key is valid; if the first position of the first key is valid, the application file is authenticated; if the first position of the first key is invalid, the first encryption field is calculated according to the ID address of the programmable chip using an encryption algorithm, and the first encryption field replaces the first key field corresponding to the first key to complete the encryption of the application file. The second judgment unit is used to enter the application after completing the authentication or encryption of the application file, read the second position of each second key in the bootloader file, and determine whether the second position of each second key is valid; if the second position of the second key is valid, the bootloader file is authenticated; if the second position of the second key is invalid, the second encryption field is calculated according to the ID address of the programmable chip using an encryption algorithm, and the second encryption field replaces the second key field corresponding to the second key to complete the encryption of the bootloader file.

9. A programmable chip executable file encryption device, characterized in that, It includes at least one control processor and a memory for communicatively connecting to the at least one control processor; the memory stores instructions executable by the at least one control processor, which, when executed by the at least one control processor, enable the at least one control processor to perform an executable file encryption method for a programmable chip as described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions for causing a computer to execute the executable file encryption method for a programmable chip as described in any one of claims 1 to 7.