Encryption method and device for burnt firmware, storage medium and computer equipment

By using the unique feature values ​​of the microcontroller chip to generate a virtual key matrix, the problems of key visibility and cracking risks in the prior art are solved, and higher data security and firmware protection in the production process are achieved.

CN118981784AInactive Publication Date: 2024-11-19SHENZHEN HANGSHUN CHIP TECH DEV CO LTD

Patent Information

Application Number
CN202411474206.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-22
Publication Date
2024-11-19
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

The encryption and decryption methods of existing microcontroller chips have the risk of key visibility and cracking, and are weak in security, making it difficult to effectively protect the security of firmware during production.

Method used

Use the unique characteristic values ​​of the microcontroller chip to generate a virtual key matrix, calculate the key position by extracting the high 4-bit values ​​and the low 4-bit values ​​of bytes, establish a complex and variable target key, and encrypt the firmware to be burned. Ensure that the keys generated each time are different, thereby improving data security.

Benefits of technology

Through invisible input keys and dynamically generated keys, the cracking difficulty is increased, and the security of the microcontroller chip firmware is significantly improved, preventing the key from being brute-forced, and ensuring the security of the data during the production process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118981784A_ABST
    Figure CN118981784A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses an encryption method and device for burnt firmware, a storage medium and computer equipment. The method comprises the steps of obtaining a unique feature value of the micro-control chip, generating a virtual key matrix according to the unique feature value, extracting a high 4-bit value and a low 4-bit value of each byte in the unique feature value, calculating a key position according to the high 4-bit value and the low 4-bit value, determining a target key in the virtual key matrix according to the key position, and sending the target key to the micro-control chip according to the target key. And encrypting the to-be-burnt firmware according to the target key to obtain a ciphertext. According to the scheme provided by the embodiment of the invention, the virtual key matrix can be generated by utilizing the unique characteristic value of the chip, the keys generated each time are different, and the cracking difficulty is improved by establishing the complex and variable keys, so that the data security is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of chip technology, and in particular to an encryption method, device, storage medium and computer equipment for burning firmware. Background Art

[0002] Microcontroller Unit (MCU), also known as a single-chip microcomputer or single-chip microcomputer. Microcontroller chips generally contain non-volatile memory for storing program instructions and data. In order to update the firmware of the microcontroller chip of an electronic device, the firmware of the microcontroller chip is generally burned through a host computer connected to a burner. With the continuous expansion of the application field of microcontroller chips, the use of microcontroller chips is increasing. How to ensure that the firmware of the microcontroller chip is not leaked during the production process is an urgent problem to be solved.

[0003] In the prior art, the MCU itself supports encryption and decryption functions, so the user usually inputs the key. After the chip is powered on, the encryption and decryption functions are configured first, and then the firmware is burned. The MCU stores the ciphertext, and when the chip runs the program, it automatically decrypts the ciphertext and then runs the program. However, the disadvantages of this encryption and decryption method are also obvious. The first is that the key is input by the user and is visible. The second is that this method may be decrypted by brute force, so the security of this encryption and decryption method in the prior art is weak. Summary of the invention

[0004] The embodiments of the present application provide an encryption method, apparatus, storage medium and computer equipment for burning firmware, which utilize the unique characteristic value of the chip to generate a virtual key matrix, and make the key generated each time different. By establishing a complex and variable key, the difficulty of cracking is increased, thereby improving the security of data.

[0005] The embodiment of the present application provides an encryption method for burning firmware, which is applied to a microcontroller chip, including: Acquire a unique characteristic value of the microcontroller chip, and generate a virtual key matrix according to the unique characteristic value; Extracting the high 4-bit value and the low 4-bit value of each byte in the unique characteristic value, and calculating the key position according to the high 4-bit value and the low 4-bit value; Determining a target key in the virtual key matrix according to the key position; The firmware to be burned is encrypted according to the target key to obtain a ciphertext.

[0006] In one embodiment, generating a virtual key matrix according to the unique eigenvalue includes: Initializing a random number generator using the unique characteristic value as a random seed; Create a 16*16 byte matrix, traverse each element of the matrix, call the random number generator to generate a random number, and store the random number at the corresponding element position of the matrix.

[0007] In one embodiment, calculating the key position according to the upper 4-bit value and the lower 4-bit value includes: Determine the position index of the Nth key according to the high 4-bit value and the low 4-bit value of the Nth byte in the unique characteristic value, where N is an integer greater than 1; The key position of the Nth key is confirmed according to the position index.

[0008] In one embodiment, the step of determining the position index according to the upper 4-bit value and the lower 4-bit value includes: Convert the upper 4-bit value into a row index and convert the lower 4-bit value into a column index according to the index type of the virtual key matrix; The row index and the column index are used as the position index.

[0009] In one embodiment, encrypting the firmware to be burned according to the target key to obtain a ciphertext includes: Obtaining the current number of times the firmware to be burned is burned, and determining the number of times of burning as a variable value; The firmware to be burned is encrypted according to the variable value and the target key to obtain a ciphertext.

[0010] In one embodiment, the method further comprises: When decrypting the ciphertext, the target key is calculated again using the unique characteristic value of the microcontroller chip to obtain the plaintext; Obtain the maximum number of times the firmware to be burned is burned; If the current number of burning times is less than the maximum number of burning times, burning the firmware according to the plain text; If the current number of burning times is not less than the maximum number of burning times, the firmware burning is stopped.

[0011] In one embodiment, encrypting the firmware to be burned according to the variable value and the target key to obtain a ciphertext includes: Combining the variable value and the target key to generate a key parameter; Dividing the firmware to be burned into multiple data blocks, and encrypting each data block using the key parameter; Merge all encrypted data blocks to get the complete ciphertext file.

[0012] The embodiment of the present application also provides an encryption device for burning firmware, which is applied to a microcontroller chip, including: An acquisition unit, used for acquiring a unique characteristic value of the microcontroller chip and generating a virtual key matrix according to the unique characteristic value; A calculation unit, used to extract the high 4-bit value and the low 4-bit value of each byte in the unique characteristic value, and calculate the key position according to the high 4-bit value and the low 4-bit value; a determination unit, configured to determine a target key in the virtual key matrix according to the key position; The encryption unit is used to encrypt the firmware to be burned according to the target key to obtain a ciphertext.

[0013] The embodiment of the present application also provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed on a computer, the computer executes the encryption method for burning firmware as described above.

[0014] An embodiment of the present application further provides a computer device, including a memory and a processor, wherein the processor executes the encryption method for burning firmware as described above by calling a computer program stored in the memory.

[0015] The encryption method, device, storage medium and computer equipment for burning firmware provided by the embodiments of the present application can obtain the unique eigenvalue of the microcontroller chip, and generate a virtual key matrix based on the unique eigenvalue, extract the high 4-bit value and the low 4-bit value of each byte in the unique eigenvalue, and calculate the key position based on the high 4-bit value and the low 4-bit value, determine the target key in the virtual key matrix according to the key position, and encrypt the firmware to be burned according to the target key to obtain the ciphertext. The scheme provided by the embodiments of the present application can generate a virtual key matrix using the unique eigenvalue of the chip, and make the key generated each time different, increase the difficulty of cracking by establishing complex and variable keys, and thus improve the security of data. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.

[0017] Figure 1 A flowchart of an encryption method for burning firmware provided in an embodiment of the present application.

[0018] Figure 2 Another flowchart of an encryption method for burning firmware provided in an embodiment of the present application.

[0019] Figure 3A schematic diagram of a flow chart of an encryption device for burning firmware provided in an embodiment of the present application.

[0020] Figure 4 A schematic diagram of the computer device structure provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0021] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of this application.

[0022] It should be noted that, in this article, the terms "include", "comprises" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "includes a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element. In addition, components, features, and elements with the same name in different embodiments of the present application may have the same meaning or different meanings, and their specific meanings need to be determined by their explanation in the specific embodiment or further combined with the context of the specific embodiment.

[0023] The embodiments of the present application provide an encryption method, device, storage medium and computer equipment for burning firmware. Specifically, the encryption method for burning firmware in the embodiments of the present application can be executed by a computer device or a server, wherein the computer device can be a terminal. The terminal can be a smart phone, a tablet computer, a laptop computer, a touch screen, a game console, a personal computer (PC, Personal Computer), a personal digital assistant (Personal Digital Assistant, PDA), a smart home and other devices, and the terminal can also include a client, which can be a media playback client or an instant messaging client, etc.

[0024] See also Figure 1 The specific process of the encryption method for burning firmware can be as follows: Step 101, obtaining a unique eigenvalue of a microcontroller chip, and generating a virtual key matrix according to the unique eigenvalue.

[0025] In one embodiment, the unique characteristic value of the microcontroller chip is fixed and unique for each chip, and the chip's UID (Unique Identification) or the ID code built into the Flash memory can be used as the above-mentioned unique characteristic value. Taking UID as an example, the UID is usually a unique identifier used to distinguish different users or entities. When generating a virtual key matrix, random numbers can be generated based on the UID and then combined into a matrix. Among them, when generating random numbers, the UID can be used as a seed of the random number generation algorithm or as an input factor in the generation process to ensure that the generated random number is associated with the UID to some extent, thereby possibly increasing its uniqueness.

[0026] In one embodiment, the above-mentioned random number generation types may include true random numbers and pseudo-random numbers. Among them, true random numbers usually come from physical processes (such as radioactive decay, thermal noise, etc.), which are essentially unpredictable. However, in ordinary programming environments, it is usually impractical to directly generate true random numbers because they require special hardware support. Pseudo-random numbers are generated by algorithms, which look random but are actually predictable. As long as the seed and algorithm are known, they can be generated using a pseudo-random number generator (PRNG, Pseudo-Random Number Generator).

[0027] The embodiment of the present application uses a pseudo-random number generator and uses the UID as a random seed. It should be noted that the random seed is a value used to initialize the pseudo-random number generator. In this embodiment, a pseudo-random number generator can be used to simulate randomness, and these generators are actually deterministic algorithms. Given the same initial seed, the same random number sequence will be generated.

[0028] Furthermore, the present embodiment can also process the seed in advance, that is, convert the UID into a numerical value suitable as a PRNG seed. For example, if the UID is in the form of a string, it can be first converted into a numerical value of a fixed length through a hash function (such as SHA-256). Then initialize the PRNG, that is, use the numerical value obtained in the previous step as the seed to initialize the PRNG. When generating random numbers, you can first initialize a 16*16 byte matrix (or an equivalent data structure, such as a two-dimensional byte array). Then traverse each element of the matrix, use the PRNG to generate a byte of random number, and store it in the corresponding matrix position to obtain a virtual key matrix. Among them, since most PRNGs generate integer values ​​(usually 32 bits or 64 bits), the generated integer can be converted into a byte sequence (for example, through bit operations or directly using library functions).

[0029] Step 102, extract the high 4-bit value and the low 4-bit value of each byte in the unique characteristic value, and calculate the key position based on the high 4-bit value and the low 4-bit value.

[0030] Specifically, for each byte in the UID, this embodiment can divide it into a high 4-bit value and a low 4-bit value. This can be achieved through bit operations or simple mathematical operations. For example, when calculating the high 4-bit value, the bit operation byte>>4 can be used to obtain it, where >> is a right shift operator, which shifts the byte 4 bits to the right, discards the low 4 bits, and leaves the high 4 bits. Correspondingly, when calculating the low 4-bit value, it can be obtained through byte&0x0F, where & is a bitwise AND operator, 0x0F (or 00001111 in binary) is bitwise ANDed with the byte, and only the low 4 bits are retained. The above-mentioned high 4-bit value and low 4-bit value can be used as the position index information of the target key, so as to facilitate the subsequent finding of the bit value of the target key in the virtual key matrix according to the index.

[0031] Step 103: determine the target key in the virtual key matrix according to the key position.

[0032] According to the position index determined by the above-mentioned high 4-bit value and the low 4-bit value, the target key can be determined in the virtual key matrix, for example, by accessing the corresponding position in the virtual key matrix through the access mechanism. In one embodiment, considering the security issue, it is also possible to ensure that only authorized users can access the key through permission information, and to prevent the key from being copied or tampered with without authorization. After locating the position of the target key in the virtual key matrix, the key can be extracted, wherein the extracted key can also undergo a further verification process to ensure its integrity and correctness, which is not further limited in this embodiment.

[0033] Step 104, encrypt the firmware to be burned according to the target key to obtain a ciphertext.

[0034] In one embodiment, the encryption algorithm used may be AES (symmetric encryption) or RSA (asymmetric encryption). For AES encryption, a key length of 64 bits, 128 bits, 192 bits or 256 bits is generally used to ensure the security of the key storage and transmission process.

[0035] In one embodiment, before encrypting the firmware to be burned, the firmware to be burned can also be compressed by a preset compression algorithm to reduce the amount of data to be transmitted, thereby improving the transmission efficiency. For example, the principle of the compression algorithm can be that the original data {aabbbcccccaaa}, a total of 13 data, can be converted into {a2b3c5a3} to indicate that the data is composed of 2 a's, 3 b's, 5 c's, and 3 a's, and after compression it becomes 8 data. For another example, the principle of the compression algorithm can be that according to the obtained n*n array set, compression is performed in a diagonal manner, that is, the data above the diagonal can be deleted to reduce the amount of data.

[0036] In one implementation, a compression algorithm may be randomly selected. Alternatively, two or more compression algorithms may be randomly selected and randomly combined, that is, the order in which the compression algorithms are executed is not required, so as to increase the difficulty of cracking. For example, in the first method, the first compression algorithm, the second compression algorithm, and the third compression algorithm are selected, and the target compression algorithm obtained may be to first execute the third compression algorithm on the file, then execute the second compression algorithm on the file, and finally execute the first compression algorithm on the file.

[0037] In one implementation, the compression algorithm used and the order in which compression is performed using the compression algorithm can be recorded, so that when the compressed file is subsequently decompressed, the decompression operation can be performed in sequence in the reverse order of the compression algorithm arrangement order to obtain the firmware file.

[0038] In one implementation, the encryption operation may be performed first and then the compression operation, or the compression operation may be performed first and then the encryption operation. The encryption operation may also be performed separately on the compressed files obtained each time using the compression algorithm. For example, in the process of performing the compression operation using the target compression algorithm, a first compressed file and a second compressed file may be obtained. The encryption operation may be performed on the first compressed file to obtain a first encrypted compressed file, and then the compression operation may be performed on the first encrypted compressed file to obtain a second compressed file.

[0039] The encryption method provided in this embodiment increases the security level because the input key is invisible and is a black box to both the user and the cracker. In addition, the virtual matrix key method makes the key burned each time different, so decrypting the ciphertext becomes extremely difficult, further improving security.

[0040] As can be seen from the above, the encryption method for burning firmware provided by the embodiment of the present application can obtain the unique eigenvalue of the microcontroller chip, and generate a virtual key matrix based on the unique eigenvalue, extract the high 4-bit value and the low 4-bit value of each byte in the unique eigenvalue, and calculate the key position based on the high 4-bit value and the low 4-bit value, determine the target key in the virtual key matrix according to the key position, and encrypt the firmware to be burned according to the target key to obtain a ciphertext. The solution provided by the embodiment of the present application can generate a virtual key matrix using the unique eigenvalue of the chip, and make the key generated each time different, and improve the difficulty of cracking by establishing a complex and variable key, thereby improving the security of the data.

[0041] See also Figure 2 , is another flow chart of the encryption method for burning firmware provided by the embodiment of the present application. The specific flow of the method can be as follows: Step 201, obtaining a unique eigenvalue of a microcontroller chip, and generating a virtual key matrix according to the unique eigenvalue.

[0042] In one embodiment, the unique characteristic value of the above-mentioned microcontroller chip may be UID, and the step of generating a virtual key matrix according to the unique characteristic value may include: initializing the random number generator using the unique characteristic value as a random seed, creating a 16*16 byte matrix, traversing each element of the matrix, calling the random number generator to generate a random number, and storing the random number at the corresponding element position of the matrix.

[0043] Specifically, the UID can be a string, an integer, or other forms of data. If the UID is not in a format that can be directly used as a seed for a random number generator (for example, it is a very long string), it can be converted into a value suitable as a seed. The above conversion process can be performed by using a hash function, such as SHA-256, which can convert an input of any length into an output of a fixed length (for example, 256 bits). However, for most random number generators, the seed they need may be a smaller integer (such as 32 bits or 64 bits). Therefore, this embodiment can also intercept a portion of the output of the hash function as a seed, or use the output of the hash function to generate a seed (for example, by mapping the hash value to an integer range in some way).

[0044] Furthermore, the seed obtained in the previous step can be used to initialize the random number generator. Then create a 16*16 byte matrix (or an equivalent data structure, such as a two-dimensional byte array), traverse each element of the matrix (that is, the position of each byte), and then call the random number generator to generate a random number. If you need to use byte-level random numbers, you need to ensure that the random number generator can generate sufficiently small random numbers (such as integers between 0 and 255), or truncate or convert the generated larger random numbers into bytes. Finally, store the generated random number (or its byte representation) at the current position of the matrix to obtain the virtual key matrix.

[0045] Step 202: Determine the position index of the Nth key according to the high 4-bit value and the low 4-bit value of the Nth byte in the unique characteristic value, where N is an integer greater than 1.

[0046] In one embodiment, each byte in the UID can be divided into a high 4-bit value and a low 4-bit value through bit operation, and the step of determining the position index based on the high 4-bit value and the low 4-bit value may include: converting the high 4-bit value into a row index according to the index type of the virtual key matrix, and converting the low 4-bit value into a column index, and using the row index and the column index as the position index.

[0047] Specifically, in this embodiment, the upper 4 bits (converted to decimal or kept in hexadecimal, depending on the index type of the key matrix) can be used as the index of a certain dimension in the key matrix, such as the row index. The lower 4 bits are used as the index of another dimension in the key matrix, such as the column index. For example, based on the 96-bit or 64-bit UID, the position index is generated according to the following rules and algorithms: take the upper 4-bit value of the first byte of the UID as the row index of the first key in the key matrix, take the lower 4-bit value of the first byte of the UID as the column index of the first key in the key matrix, take the upper 4-bit value of the second byte of the UID as the row index of the second key in the key matrix, take the lower 4-bit value of the second byte of the UID as the column index of the second key in the key matrix, ..., take the upper 4-bit value of the last byte of the UID as the row index of the last key in the key matrix, take the lower 4-bit value of the last byte of the UID as the column index of the last key in the key matrix, ..., take the upper 4-bit value of the last byte of the UID as the row index of the last key in the key matrix, and take the lower 4-bit value of the last byte of the UID as the column index of the last key in the key matrix.

[0048] Step 203: confirm the key position of the Nth key according to the position index.

[0049] Step 204: determine the target key in the virtual key matrix according to the key position.

[0050] In the virtual key matrix, the above two index values ​​are used to locate and obtain the corresponding key value. For example, assume that one byte of the UID is 0xAB (hexadecimal), and the key matrix is ​​a two-dimensional array. The upper 4 bits are 0xA (10 in decimal), which is used as the row index. The lower 4 bits are 0xB (11 in decimal), which is used as the column index. In the virtual key matrix, the key value of the 10th row and 11th column can be found as the target key.

[0051] Step 205, obtaining the current number of burning times of the firmware to be burned, and determining the number of burning times as a variable value.

[0052] In one embodiment, the number of burning times is introduced as a variable variable, that is, the variable changes once each time the program is burned, wherein the variable value can also be a firmware version number, a timestamp, a random number, etc., to increase the randomness and security of encryption. The specific content and format of the variable value depends on the actual application scenario, and this application does not further limit this.

[0053] Step 206, combining the variable value and the target key to generate key parameters.

[0054] Step 207, dividing the firmware to be burned into multiple data blocks, and encrypting each data block using the key parameters.

[0055] Step 208: merge all encrypted data blocks to obtain a complete ciphertext file.

[0056] In the embodiment of the present application, a symmetric encryption algorithm can be used to encrypt the firmware data. This type of algorithm uses the same key for encryption and decryption and has a high encryption efficiency. Common symmetric encryption algorithms include AES (Advanced Encryption Standard), DES (Data Encryption Standard), etc.

[0057] Furthermore, the present embodiment can combine the target key and the variable value to form a complete key or key parameter for encryption. This combination can be a simple splicing or a more complex processing (such as hashing, XOR, etc.), depending on the requirements of the encryption algorithm and security requirements. Then the firmware file to be burned is read into the memory or processing device, and the firmware data can be divided into multiple fixed-size data blocks (such as the data block size in AES encryption is 128bit) as needed. Each data block is encrypted using the key or key parameter obtained by the previous combination. The encryption process generally includes steps such as initializing the encryption algorithm, processing the data block, and generating the ciphertext. All encrypted data blocks are merged into a complete ciphertext file. It should be noted that when segmenting the firmware data, if the total size of the firmware data is not an integer multiple of the encryption algorithm block size, the last data block needs to be padded (such as PKCS#7 padding) to meet the requirements of the encryption algorithm before encryption.

[0058] After encryption is complete, you can verify that the encryption process is correct by decrypting a small portion of the ciphertext. Store the encrypted firmware ciphertext in an appropriate medium for subsequent flashing to the device.

[0059] The present embodiment uses a virtual matrix key calculated by UID, and introduces the burning number as a variable variable, that is, each time a program is burned, the variable changes once, and the key and the variable variable are used as one of the inputs of the encryption and decryption module to complete the encryption and decryption of the burning firmware. After each burning is completed, the variable variable changes once. After the variable variable reaches the maximum value, the chip cannot be burned again, and after the encryption function is completed, the ciphertext cannot be obtained through the debugging interface, and only a fixed 0xAA is obtained to ensure data security. Correspondingly, when decrypting, before the MCU takes the value to run the program, it is also necessary to access the virtual key matrix, use rules and algorithms to calculate the key, combine the variable variable burning number, decrypt to obtain plaintext, and thus run the firmware. That is, the encryption method for burning firmware also includes: when decrypting the ciphertext, the unique characteristic value of the microcontroller chip is used again to calculate the target key to obtain the plaintext, obtain the maximum burning number of the firmware to be burned, if the current burning number is less than the maximum burning number, then the firmware is burned according to the plaintext, if the current burning number is not less than the maximum burning number, then the firmware is stopped.

[0060] In the embodiment of the present application, a UID with a unique characteristic value of the chip is used to generate a key according to rules and algorithms, and finally a variable variable (that is, the number of firmware burn times) is introduced to participate in the encryption process. After each encryption is completed, the key and variable variable are stored in a space that is invisible to the user. Each time the program is run, the CPU takes the variable through the bus for decryption operations, thereby ensuring the normal operation of the chip and greatly improving the security of the data.

[0061] All of the above technical solutions can be arbitrarily combined to form optional embodiments of the present application, which will not be described in detail here.

[0062] As can be seen from the above, the encryption method for burning firmware provided by the embodiment of the present application can obtain the unique eigenvalue of the microcontroller chip, and generate a virtual key matrix according to the unique eigenvalue, determine the position index of the Nth key according to the high 4-bit value and the low 4-bit value of the Nth byte in the unique eigenvalue, N is an integer greater than 1, confirm the key position of the Nth key according to the position index, determine the target key in the virtual key matrix according to the key position, obtain the current number of burning times of the firmware to be burned, determine the number of burning times as a variable value, combine the variable value and the target key, generate key parameters, divide the firmware to be burned into multiple data blocks, and use the key parameters to encrypt each data block, merge all encrypted data blocks to obtain a complete ciphertext file. The scheme provided by the embodiment of the present application can generate a virtual key matrix using the unique eigenvalue of the chip, and make the key generated each time different, improve the difficulty of cracking by establishing a complex and variable key, and then improve the security of the data.

[0063] In order to implement the above method, an embodiment of the present invention further provides an encryption device for burning firmware, and the encryption device for burning firmware can be specifically integrated in a computer device such as a mobile phone, a personal computer, a tablet computer and the like.

[0064] For example, Figure 3 FIG. 1 is a schematic diagram of a first structure of an encryption device for burning firmware provided by an embodiment of the present invention. The encryption device for burning firmware may include: An acquisition unit 301 is used to acquire a unique characteristic value of the microcontroller chip and generate a virtual key matrix according to the unique characteristic value; A calculation unit 302 is used to extract the high 4-bit value and the low 4-bit value of each byte in the unique characteristic value, and calculate the key position according to the high 4-bit value and the low 4-bit value; A determination unit 303, configured to determine a target key in the virtual key matrix according to the key position; The encryption unit 304 is used to encrypt the firmware to be burned according to the target key to obtain a ciphertext.

[0065] The encryption device for burning firmware proposed in the embodiment of the present invention can obtain the unique eigenvalue of the microcontroller chip, and generate a virtual key matrix according to the unique eigenvalue, extract the high 4-bit value and the low 4-bit value of each byte in the unique eigenvalue, and calculate the key position according to the high 4-bit value and the low 4-bit value, determine the target key in the virtual key matrix according to the key position, and encrypt the firmware to be burned according to the target key to obtain a ciphertext. The solution provided in the embodiment of the present application can generate a virtual key matrix using the unique eigenvalue of the chip, and make the key generated each time different, thereby increasing the difficulty of cracking by establishing a complex and variable key, thereby increasing the security of the data.

[0066] All of the above technical solutions can be arbitrarily combined to form optional embodiments of the present application, which will not be described in detail here.

[0067] An embodiment of the present application further provides a computer device, including a memory and a processor, wherein the processor is used to execute the process in the encryption method for burning firmware provided in this embodiment by calling a computer program stored in the memory.

[0068] For example, the computer device mentioned above may be a terminal device with corresponding functions such as a mobile phone, a tablet computer, a personal computer, a cloud computer, etc. Figure 4 , Figure 4 A schematic diagram of the structure of a computer provided in an embodiment of the present application.

[0069] The computer device 400 may include components such as a memory 401 and a processor 402. Those skilled in the art will appreciate that Figure 4 The computer device structure shown in the figure does not constitute a limitation on the computer device, and may include more or less components than shown in the figure, or combine certain components, or arrange the components differently.

[0070] The memory 401 may be used to store applications and data. The applications stored in the memory 401 include executable codes. The applications may be composed of various functional modules. The processor 402 executes various functional applications and data processing by running the applications stored in the memory 401.

[0071] Processor 402 is the control center of the computer device. It uses various interfaces and lines to connect the various parts of the entire computer device. By running or executing applications stored in memory 401 and calling data stored in memory 401, it executes various functions of the computer device and processes data, thereby monitoring the computer device as a whole.

[0072] In this embodiment, the processor 402 in the computer device will load the executable code corresponding to the process of one or more application programs into the memory 401 according to the following instructions, and the processor 402 will run the application program stored in the memory 401 to execute: Acquire a unique characteristic value of the microcontroller chip, and generate a virtual key matrix according to the unique characteristic value; Extracting the high 4-bit value and the low 4-bit value of each byte in the unique characteristic value, and calculating the key position according to the high 4-bit value and the low 4-bit value; Determining a target key in the virtual key matrix according to the key position; The firmware to be burned is encrypted according to the target key to obtain a ciphertext.

[0073] A person of ordinary skill in the art will appreciate that all or part of the steps in the various methods of the above embodiments may be completed by instructions, or by controlling related hardware through instructions. The instructions may be stored in a computer-readable storage medium and loaded and executed by a processor.

[0074] To this end, an embodiment of the present application provides a storage medium in which a plurality of instructions are stored, and the instructions can be loaded by a processor to execute the steps in any data calculation method provided in the embodiment of the present application. For example, the instructions can execute the following steps: Acquire a unique characteristic value of the microcontroller chip, and generate a virtual key matrix according to the unique characteristic value; Extracting the high 4-bit value and the low 4-bit value of each byte in the unique characteristic value, and calculating the key position according to the high 4-bit value and the low 4-bit value; Determining a target key in the virtual key matrix according to the key position; The firmware to be burned is encrypted according to the target key to obtain a ciphertext.

[0075] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.

[0076] The storage medium may include: a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.

[0077] Since the instructions stored in the storage medium can execute the steps in any data calculation method provided in the embodiments of the present application, the beneficial effects that can be achieved by any data calculation method provided in the embodiments of the present application can be achieved. Please refer to the previous embodiments for details and will not be repeated here.

[0078] In the embodiments of the computer device and the readable storage medium provided in the present application, all the technical features of the embodiments of the above-mentioned method are included. The expansion and explanation content of the specification are the same as the adaptability of the embodiments of the above-mentioned positioning method, and will not be repeated here.

[0079] In the above embodiments, the description of each embodiment has its own emphasis. For the part that is not described in detail in a certain embodiment, please refer to the detailed description of the encryption device for burning firmware above, which will not be repeated here.

[0080] The encryption method for burning firmware provided in the embodiment of the present application and the encryption device for burning firmware in the above embodiment belong to the same concept. The specific implementation process is detailed in the embodiment of the encryption device for burning firmware, which will not be repeated here.

[0081] It should be noted that, for the encryption method for burning firmware described in the embodiment of the present application, a person of ordinary skill in the art can understand that the whole or part of the process of implementing the encryption method for burning firmware described in the embodiment of the present application can be completed by controlling the relevant hardware through a computer program, and the computer program can be stored in a computer-readable storage medium, such as a memory, and executed by at least one processor, and the execution process may include the process of the embodiment of the encryption method for burning firmware. Among them, the storage medium can be a disk, an optical disk, a read-only memory, a random access memory (RAM), etc.

[0082] The above is a detailed introduction to an encryption method, device, storage medium and computer equipment for burning firmware provided by the embodiments of the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea; at the same time, for technical personnel in this field, according to the ideas of the present application, there will be changes in the specific implementation methods and application scopes. In summary, the content of this specification should not be understood as a limitation on the present application.

[0083] The above descriptions are merely embodiments of the present application and are not intended to limit the patent scope of the present application. Any equivalent structural or equivalent process transformations made using the contents of the specification and drawings of the present application, such as the mutual combination of technical features between the embodiments, or direct or indirect application in other related technical fields, are also included in the patent protection scope of the present application.

Claims

1. An encryption method for burning firmware, applied to a microcontroller chip, characterized in that: include: Acquire a unique characteristic value of the microcontroller chip, and generate a virtual key matrix according to the unique characteristic value; Extracting the high 4-bit value and the low 4-bit value of each byte in the unique characteristic value, and calculating the key position according to the high 4-bit value and the low 4-bit value; Determining a target key in the virtual key matrix according to the key position; The firmware to be burned is encrypted according to the target key to obtain a ciphertext.

2. The encryption method for burning firmware according to claim 1, characterized in that: Generating a virtual key matrix according to the unique eigenvalue includes: Initializing a random number generator using the unique characteristic value as a random seed; Create a 16*16 byte matrix, traverse each element of the matrix, call the random number generator to generate a random number, and store the random number at the corresponding element position of the matrix.

3. The encryption method for burning firmware as claimed in claim 1, characterized in that: Calculating the key position according to the upper 4-bit value and the lower 4-bit value includes: Determine the position index of the Nth key according to the high 4-bit value and the low 4-bit value of the Nth byte in the unique characteristic value, where N is an integer greater than 1; The key position of the Nth key is confirmed according to the position index.

4. The encryption method for burning firmware as claimed in claim 3, characterized in that: The step of determining the position index according to the upper 4-bit value and the lower 4-bit value comprises: Convert the upper 4-bit value into a row index and convert the lower 4-bit value into a column index according to the index type of the virtual key matrix; The row index and the column index are used as the position index.

5. The encryption method for burning firmware according to claim 1, characterized in that: The firmware to be burned is encrypted according to the target key to obtain a ciphertext, including: Obtaining the current number of times the firmware to be burned is burned, and determining the number of times of burning as a variable value; The firmware to be burned is encrypted according to the variable value and the target key to obtain a ciphertext.

6. The encryption method for burning firmware as claimed in claim 5, characterized in that: The method further comprises: When decrypting the ciphertext, the target key is calculated again using the unique characteristic value of the microcontroller chip to obtain the plaintext; Obtain the maximum number of times the firmware to be burned is burned; If the current number of burning times is less than the maximum number of burning times, burning the firmware according to the plain text; If the current number of burning times is not less than the maximum number of burning times, the firmware burning is stopped.

7. The encryption method for burning firmware as claimed in claim 5, characterized in that: Encrypting the firmware to be burned according to the variable value and the target key to obtain a ciphertext, including: Combining the variable value and the target key to generate a key parameter; Dividing the firmware to be burned into multiple data blocks, and encrypting each data block using the key parameter; Merge all encrypted data blocks to get the complete ciphertext file.

8. An encryption device for burning firmware, applied to a microcontroller chip, characterized in that: include: An acquisition unit, used for acquiring a unique characteristic value of the microcontroller chip and generating a virtual key matrix according to the unique characteristic value; A calculation unit, used to extract the high 4-bit value and the low 4-bit value of each byte in the unique characteristic value, and calculate the key position according to the high 4-bit value and the low 4-bit value; a determination unit, configured to determine a target key in the virtual key matrix according to the key position; The encryption unit is used to encrypt the firmware to be burned according to the target key to obtain a ciphertext.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed on a computer, the computer is caused to execute the method according to any one of claims 1 to 7.

10. A computer device comprising a memory and a processor, characterized in that: The processor executes the method according to any one of claims 1 to 7 by calling the computer program stored in the memory.

Citation Information

Patent Citations

  • Network identification card realizing method

    CN101022337A

  • Encryption and decryption method, and PLC system using the same

    CN101329658A

  • Data encryption method and device, data decryption method and device, storage medium and electronic equipment

    CN112019323A

  • Firmware burning method, device and system for micro-control chip and storage medium

    CN115544464A

  • Memory system and encryption method in memory system

    US20140032935A1

Cited By

  • Device data encryption method, computer device, storage medium and program product

    CN119740245A

  • Device data encryption method, computer device, storage medium and program product

    CN119740247A