Firmware download link protection method, device, equipment and storage medium
By using random numbers and preset fixed keys to perform handshake operations in the chip firmware download link, the firmware information is dynamically encrypted, solving the problem of the firmware information being copied and stolen, and improving the security of data transmission.
Patent Information
- Application Number
- CN202411347059.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-26
- Publication Date
- 2025-01-07
- Estimated Expiration
- 2044-09-26
AI Technical Summary
In the chip firmware download link, when using a fixed key to encrypt transmission, it is difficult to prevent the firmware information from being copied and stolen, which poses data security risks, and the fixed key is easily brute-forced.
The device generates a random number on the receiving end, and performs a handshake operation through the random number and the preset fixed key, and completes the decryption of dynamic encryption firmware information, generates plain text firmware data, and ensures the security of the download link.
Transmitting firmware information through dynamic encryption avoids the copying of data content and the cracking of keys, improves the security of the download link, and enhances the integrity and security of data transmission.
Smart Images

Figure CN118862134B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data security technology, and in particular to a method, device, equipment and storage medium for protecting a firmware download link. Background Art
[0002] In the chip firmware burning and downloading scenarios, chip manufacturers usually provide dedicated download tools and host computer software to download the firmware to the chip. The download tool implements firmware download through communication interfaces such as IIC / UART / SPI. The download link diagram is as follows: Figure 1 shown.
[0003] Chip firmware may contain important information, such as device configuration, user data, algorithm logic, etc. If this information is intercepted or stolen during transmission, it may lead to serious consequences such as illegal control of the device and leakage of user privacy. In order to prevent product solutions from being copied or stolen, chip manufacturers or solution manufacturers usually adopt a ciphertext download method for download links, which are encrypted and transmitted using a fixed key.
[0004] However, when the download link uses a fixed key for encrypted transmission, by grabbing the data content on the link, the same content can be copied through the download interface and transmitted to the chip. It is difficult to prevent the transmitted firmware information from being copied, resulting in the firmware information being stolen or copied, posing a data security risk. Summary of the invention
[0005] In order to help solve the problem that when a download link uses a fixed key for encrypted transmission, by grabbing the data content on the link, the same content can be copied through the download interface and transmitted to the chip, but it is difficult to prevent the transmitted firmware information from being copied, resulting in the firmware information being stolen or plagiarized, and there is a data security risk, the present application provides a firmware download link protection method, device, equipment and storage medium.
[0006] In a first aspect, the present application provides a method for protecting a firmware download link, which adopts the following technical solution: the method is applied to a receiving device, and the method includes:
[0007] When powering on, generating a random number, the random number being randomly generated by the receiving end device;
[0008] Complete the handshake operation with the downloader using the random number, the preset fixed key and the preset handshake confirmation information;
[0009] Receive dynamically encrypted firmware information and decrypt the dynamically encrypted firmware information to generate plaintext firmware data, wherein the dynamically encrypted firmware information is generated after the downloader dynamically encrypts the firmware information to be transmitted, and the encryption method of the firmware information to be transmitted by the downloader corresponds to the decryption method of the dynamically encrypted firmware information by the receiving device.
[0010] In a specific implementation scheme, the use of the random number, the preset fixed key and the preset handshake confirmation information to complete the handshake operation with the downloader includes:
[0011] Encrypting the random number using the preset fixed key to generate an encrypted random number, and transmitting the encrypted random number to a downloader;
[0012] Receiving encrypted handshake confirmation information, and decrypting the encrypted handshake confirmation information to generate plaintext handshake confirmation information, wherein the encrypted handshake confirmation information is generated by the downloader decrypting the encrypted random number to generate a plaintext random number and then encrypting the preset handshake confirmation information according to a first encryption rule;
[0013] Comparing the decrypted plaintext handshake confirmation information with the preset handshake confirmation information;
[0014] If the plaintext handshake confirmation information is consistent with the preset handshake confirmation information, the handshake with the downloader is completed.
[0015] In a specific implementation scheme, the using the preset fixed key to encrypt the random number to generate the encrypted random number includes:
[0016] Splitting the preset fixed key into two data blocks to generate a high-order fixed key and a low-order fixed key;
[0017] Performing an XOR calculation on the random number and the high-bit fixed key to generate a first intermediate ciphertext;
[0018] The first intermediate ciphertext is XORed with the low-bit fixed key to generate an encrypted random number.
[0019] In a specific implementation scheme, the first encryption rule includes:
[0020] The decrypted plaintext random number, the preset fixed key and the value 0 are concatenated to generate a handshake confirmation key;
[0021] An XOR operation is performed on the handshake confirmation key and the preset handshake confirmation information.
[0022] In a specific implementation scheme, the firmware information to be transmitted includes a sequence value, firmware data and verification information, wherein the sequence value is determined according to the number of communications between the downloader and the receiving device, and the sequence value is increased by one each time the downloader and the receiving device communicate once;
[0023] The dynamically encrypted firmware information includes a ciphertext sequence value, ciphertext firmware data and ciphertext verification information, wherein the ciphertext sequence value, the ciphertext firmware data and the ciphertext verification information are generated by the downloader encrypting the firmware information to be transmitted.
[0024] In a specific implementation scheme, decrypting the dynamically encrypted firmware information to generate plaintext firmware data includes:
[0025] Splitting the ciphertext firmware data according to a preset data size to generate a plurality of ciphertext firmware data blocks;
[0026] Performing a preset ciphertext verification calculation on the plurality of ciphertext firmware data blocks to generate ciphertext firmware verification data;
[0027] Comparing the ciphertext firmware verification data with the ciphertext verification information sent by the downloader;
[0028] If the comparison results are consistent, the ciphertext sequence value is decrypted to generate a plaintext sequence value;
[0029] Determine whether the plaintext sequence value after decryption and the sequence value of the currently processed record are greater than 1;
[0030] If the decrypted plaintext sequence value and the sequence value of the current processing record are not greater than 1, concatenating the random number, the preset fixed key and the plaintext sequence value to generate a firmware data key;
[0031] The firmware data key is used to decrypt the ciphertext firmware data to generate plaintext firmware data.
[0032] In a specific implementation scheme, the using the firmware data key to decrypt the ciphertext firmware data to generate plaintext firmware data includes:
[0033] Performing XOR calculation on adjacent ciphertext firmware data blocks in order to generate a plurality of plaintext firmware data blocks corresponding to the ciphertext firmware data blocks, wherein a first ciphertext data block in the ciphertext firmware data blocks is XOR-calculated with the firmware data key to generate a first plaintext firmware data block;
[0034] Several of the plaintext firmware data blocks are concatenated to generate plaintext firmware data.
[0035] In a second aspect, the present application provides a firmware download link protection device, which adopts the following technical solution: decrypting the ciphertext sequence value to generate a plaintext sequence value includes:
[0036] Splitting the preset fixed key into two data blocks to generate a high-order fixed key and a low-order fixed key;
[0037] Performing an XOR calculation on the ciphertext sequence value and the low-order fixed key to generate a first intermediate plaintext;
[0038] The first intermediate plaintext is XORed with the high-order fixed key to generate a plaintext sequence value.
[0039] In a third aspect, the present application provides a computer device, which adopts the following technical solution: it includes a memory and a processor, and the memory stores a computer program that can be loaded by the processor and executes any of the above-mentioned firmware download link protection methods.
[0040] In a fourth aspect, the present application provides a computer-readable storage medium, which adopts the following technical solution: a computer program that can be loaded by a processor and execute any of the above-mentioned firmware download link protection methods is stored.
[0041] In summary, this application has the following beneficial technical effects:
[0042] A random number is generated by a receiving device, such as a chip, and the random number is used to implement handshake communication between the downloader and the receiving device to ensure normal communication and data transmission between the downloader and the chip. After the handshake between the downloader and the receiving device is completed, the firmware information is encrypted and transmitted using dynamic encryption, and the chip decrypts it according to the corresponding encryption method, thereby avoiding the data content on the download link from being copied and the key from being cracked by brute force as much as possible, thereby improving the security of the data link during data transmission. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] Figure 1 is a schematic diagram for explaining the firmware download process;
[0044] Figure 2 is a flowchart of a firmware download link protection method in an embodiment of the present application;
[0045] Figure 3 This is a schematic diagram of a random number encryption method in an embodiment of the present application;
[0046] Figure 4 This is a schematic diagram of a random number decryption method in an embodiment of the present application;
[0047] Figure 5 This is a schematic diagram of a firmware data decryption method in an embodiment of the present application;
[0048] Figure 6 This is a schematic diagram of the firmware data encryption method in an embodiment of the present application;
[0049] Figure 7 is a schematic diagram of a protection device for a firmware download link in an embodiment of the present application;
[0050] Figure 8 It is a schematic diagram used to embody a computer device in an embodiment of the present application.
[0051] Reference numerals: 701, random number generation module; 702, handshake confirmation module; 703, dynamic decryption module. DETAILED DESCRIPTION
[0052] The following combination Figure 1-Figure 8 This application is described in further detail.
[0053] The embodiment of the present application discloses a method for protecting a firmware download link, which is mainly used in the process of a download tool downloading firmware to a receiving hardware device, and the hardware device can be a chip, an MCU or other computers, hardware circuit boards, etc. Firmware refers to program code embedded in an electronic device. In the driving process, firmware plays an important role. The operating system uses firmware to implement the operation of a specific machine according to standard device drivers. Therefore, the firmware contains important information, such as device configuration, user data, algorithm logic, etc. If this information is intercepted or stolen during the transmission process, it may lead to serious consequences such as illegal control of the device and leakage of user privacy. In order to prevent product solutions from being copied or stolen, chip manufacturers or solution manufacturers usually adopt a ciphertext download method for the download link, which is encrypted and transmitted using a fixed key.
[0054] However, when the download link uses a fixed key for encrypted transmission, by grabbing the data content on the link, the same content can be copied through the download interface and transmitted to the chip, which makes it difficult to prevent the transmitted firmware information from being copied, resulting in the firmware information being stolen or copied, and posing a data security risk; in addition, the use of a fixed key has the risk of being cracked by brute force. Therefore, in order to help improve the security of the firmware download link, prevent the firmware from being stolen or copied, and ensure the security of data during the transmission process, the present application provides a firmware download link protection method.
[0055] Reference Figure 2 The method is applied to a receiving device and comprises the following steps:
[0056] S10, when powering on, generating a random number, the random number is randomly generated by the receiving device.
[0057] Specifically, the receiving device of the method can be a chip, MCU, computer or other hardware circuit, etc., and the application scenarios are wide. In the embodiment of the present application, the chip is used as an example for explanation. In the embodiment of the present application, the firmware source file is downloaded to the chip through a downloader. At the receiving end device, that is, after the chip is powered on, the chip randomly generates a 32-bit random number. The generation method can be randomly generated by software such as a random number generator, systick (System Timer, system timer), etc. The specific generation method is not limited here, and users can choose according to actual needs.
[0058] S20, completing a handshake operation with the downloader using a random number, a preset fixed key, and preset handshake confirmation information.
[0059] Specifically, the handshake operation is completed with the downloader using the generated 32-bit random number, the preset fixed key, and the preset handshake confirmation information. The preset fixed key is designed to be 64 bits, and the specific key content has been set in advance by the chip manufacturer or solution manufacturer, and is known to the downloader and the chip boot program; the preset handshake confirmation information, that is, the ACK information, the content of the ACK information is also set in advance by the chip manufacturer or solution manufacturer.
[0060] S30, receiving dynamically encrypted firmware information, and decrypting the dynamically encrypted firmware information to generate plaintext firmware data, wherein the dynamically encrypted firmware information is generated after the downloader dynamically encrypts the firmware information to be transmitted, and the encryption method of the firmware information to be transmitted by the downloader corresponds to the decryption method of the dynamically encrypted firmware information by the receiving device.
[0061] Specifically, after the handshake between the chip and the downloader is completed, the downloader encrypts the firmware information to be transmitted, the chip receives the encrypted firmware information, and decrypts the firmware information to generate plaintext firmware data, and then downloads the plaintext firmware data to the corresponding position in the chip to realize firmware download. It should be noted that downloading firmware to the chip through the downloader generally requires multiple communications between the downloader and the chip to complete the entire download process. During multiple communications, using a fixed key to encrypt the firmware may cause the data content on the download link to be copied, thereby causing the data to be stolen or plagiarized. In addition, the use of a fixed key may be cracked by brute force, and the security is low. Therefore, a dynamic key is used to dynamically encrypt the data transmitted on the download link during each communication process, and the chip end decrypts the received dynamic encrypted data to obtain the plaintext firmware data.
[0062] The firmware information to be transmitted includes a sequence value, firmware data and check information, that is, the communication format of the data transmission can be designed as: 32-bit sequence value, N-bit firmware data, 32-bit check information, and the check information can be a CRC check; the sequence value starts from 1 and is determined according to the number of communications between the downloader and the receiving device. The sequence value increases by one each time the downloader and the receiving device communicate. The dynamically encrypted firmware information includes a ciphertext sequence value, ciphertext firmware data and ciphertext check information, wherein the ciphertext sequence value, ciphertext firmware data and ciphertext check information are generated by the downloader to encrypt the firmware information to be transmitted.
[0063] In the present application scheme, a random number is generated by a receiving device, such as a chip, and the random number is used to implement handshake communication between the downloader and the receiving device to ensure normal communication and data transmission between the downloader and the chip end; after the handshake between the downloader and the receiving device is completed, the firmware information is encrypted and transmitted by dynamic encryption, and the chip end decrypts it according to the corresponding encryption method, thereby avoiding the data content on the download link from being copied and the key from being brute force cracked as much as possible, thereby improving the security of the data link during data transmission.
[0064] In one embodiment, the step of completing the handshake operation with the downloader using the random number, the preset fixed key, and the preset handshake confirmation information can be specifically performed as follows:
[0065] The chip uses a preset fixed key to encrypt the random number, generate an encrypted random number, and transmit the encrypted random number to the downloader; refer to Figure 3 The specific encryption method can be: split the preset fixed key into two data blocks, where the preset fixed key is 64 bits, and split it to generate a high-order fixed key (bit[63: 32]) and a low-order fixed key (bit[31: 0]); perform an XOR calculation on the generated 32-bit random number and the high-order fixed key to generate a first intermediate ciphertext, and then perform an XOR calculation on the first intermediate ciphertext and the low-order fixed key to generate an encrypted random number.
[0066] Afterwards, the chip receives the encrypted handshake confirmation information and decrypts the encrypted handshake confirmation information to generate plaintext handshake confirmation information, wherein the encrypted handshake confirmation information is generated by the downloader decrypting the encrypted random number to generate a plaintext random number, and then encrypting the preset handshake confirmation information according to the first encryption rule. Specifically, the encryption and decryption of the random number adopts a symmetric encryption and decryption method. After receiving the encrypted random number, the downloader uses a decryption method corresponding to the random number encryption method to decrypt the encrypted random number. Figure 4, the specific decryption method is: the downloader performs XOR calculation on the generated 32-bit encrypted random number and the low-order fixed key (bit[31: 0]) to generate the first intermediate plaintext, and performs XOR calculation on the first intermediate plaintext and the high-order fixed key (bit[63: 32]) to generate a plaintext random number. After that, the downloader encrypts the preset handshake confirmation information, that is, the ACK information, according to the first encryption rule, wherein the first encryption rule includes: splicing the decrypted plaintext random number, the preset fixed key and the value 0, the splicing method can be expressed as "rand_dev_info (plaintext random number) || key_handshake (preset fixed key) || 0x00000000 (0 value)", generating a 128-bit handshake confirmation key; performing XOR calculation on the generated 128-bit handshake confirmation key and the preset handshake confirmation information. The chip side generates the same handshake confirmation key as the downloader, "rand_dev_info (random number) || key_handshake (preset fixed key) || 0x00000000 (0 value)", decrypts the received encrypted handshake confirmation information, and generates plaintext handshake confirmation information.
[0067] Finally, the decrypted plaintext handshake confirmation information is compared with the preset handshake confirmation information. If the plaintext handshake confirmation information is consistent with the preset handshake confirmation information, the handshake with the downloader is completed. If the comparison result is inconsistent, it is necessary to handshake with the downloader again to ensure normal communication between the downloader and the chip.
[0068] In the present application, random numbers are generated, and the chip and downloader encrypt and decrypt the random numbers respectively, ensuring that the two devices can communicate normally and transmit data accurately. The encryption and decryption of the handshake information ensures that the handshake between the two devices is successful.
[0069] In one embodiment, the step of decrypting the dynamically encrypted firmware information to generate plaintext firmware data may be specifically performed as follows:
[0070] At the chip end, the ciphertext firmware data is split according to a preset data size to generate a number of ciphertext firmware data blocks. For example, the ciphertext firmware data is divided into m data blocks with 128 bits as a unit, recorded as C(1), C(2), C(3), ..., C(m); then, a preset ciphertext verification calculation is performed on the several ciphertext firmware data blocks at the chip end to generate ciphertext firmware verification data. For example, CRC calculation is performed on the ciphertext data C1||C2||C3|| ...||C(m) to generate ciphertext firmware verification data; then, the ciphertext firmware verification data is compared with the ciphertext verification information sent by the downloader. If the comparison results are consistent, the ciphertext sequence value is decrypted to generate a plaintext sequence value. If the comparison results are inconsistent, the data is not processed. The purpose of checking the ciphertext data, such as CRC check, is to verify whether the transmitted firmware data has been tampered with. If the ciphertext firmware check data is consistent with the ciphertext check information sent by the downloader, it means that the data has not been tampered with, and the decrypted plaintext firmware data is valid. If the check information is inconsistent, it means that the data may have been tampered with, and the decrypted plaintext firmware data is invalid. Among them, the check method can be selected according to the actual needs of the user, and CRC check, CRC32 check, etc. can be used. For example, the polynomial of the CRC32 check method can be expressed as:
[0071] x 32 +x 26 +x 23 +x 22 +x 16 +x 12 +x 11 +x 10 +x 8 +x 7 +x 5 +x 4 +x 2 +x+1;
[0072] Among them, the initial value is 0xFFFFFFFF.
[0073] After decrypting to obtain the plaintext sequence value, determine whether the decrypted plaintext sequence value is greater than 1 compared to the sequence value of the current processing record. Each time the communication chip and the downloader record the sequence value after each decryption, and compare the current decrypted plaintext sequence value with the current recorded value. If the difference between the two values is greater than 1, it means that the data may be stolen or copied, resulting in continuous reception of firmware data under the same sequence value. At this time, the transmitted data is not processed; if the decrypted plaintext sequence value is not greater than 1 compared to the sequence value of the current processing record, the random number, the preset fixed key and the plaintext sequence value are concatenated to generate the firmware data key. The firmware data key can be expressed as KEY_Initial = "rand_dev_info (random number) || key_handshake (preset fixed key) || seq (sequence value)"; the firmware data key is used to decrypt the ciphertext firmware data to generate plaintext firmware data.
[0074] In one embodiment, the steps of decrypting the ciphertext firmware data using the firmware data key to generate the plaintext firmware data may be specifically performed as follows:
[0075] XOR calculations are performed on adjacent ciphertext firmware data blocks in sequence to generate a number of plaintext firmware data blocks corresponding to the ciphertext firmware data blocks, wherein the first ciphertext data block in the ciphertext firmware data block is XOR-calculated with the firmware data key to generate a first plaintext firmware data block; and a number of plaintext firmware data blocks are concatenated to generate plaintext firmware data. Specifically, refer to Figure 5 , the generated fixed key "KEY_Initial = rand_dev_info || key_handshake ||seq" is XORed with the first ciphertext firmware data block C(1) to generate the first plaintext firmware data block S(1); then, the first ciphertext firmware data block C(1) is XORed with the second ciphertext firmware data block C(2) to generate the second plaintext firmware data block S(2), and so on, to obtain m plaintext firmware data blocks, and the m plaintext firmware data blocks are concatenated, S1||S2||S3||…||S(m) to obtain the final complete firmware data.
[0076] It should be noted that the sequence value, firmware data, and check information are spliced to generate the firmware information to be transmitted, and the firmware information to be transmitted is encrypted on the downloader side and then transmitted to the chip side. The downloader side encrypts the firmware information to be transmitted by first generating a key for encrypting the firmware data according to the plaintext random number decrypted by the downloader, the preset fixed key, and the sequence value, that is, the firmware data key. The generated firmware data key can be expressed as "rand_dev_info (plaintext random number) || key_handshake (preset fixed key) || seq (sequence value)", using the firmware data key to encrypt the firmware data to generate ciphertext firmware data; then encrypting the sequence value to generate a ciphertext sequence value, using CRC check to generate ciphertext check information, splicing the ciphertext sequence value, ciphertext firmware data, and ciphertext check information to generate dynamically encrypted firmware information. Since the sequence value is different for each communication, the encrypted ciphertext sequence value and ciphertext firmware data are dynamically changing, thereby achieving dynamic encryption. The method for encrypting and decrypting the sequence value is to use a preset fixed key to encrypt and decrypt the sequence value, and the symmetric encryption and decryption method is also used. The encryption and decryption method is consistent with the random number encryption and decryption method. For details, please refer to the random number encryption and decryption calculation method, which will not be repeated here.
[0077] The downloader uses the firmware data key ("rand_dev_info || key_handshake || seq", which can be recorded as KEY_Initial) to encrypt the firmware data, which corresponds to the above decryption method. Figure 6 , the downloader splits the firmware data to be transmitted into units of 128 bits, which can be recorded as S(1), S(2), S(3), ..., S(m-1), S(m); the first plaintext data block, that is, S(1), is XORed with the firmware data key KEY_Initial to obtain the first ciphertext data block, and the first ciphertext data block is used as a new key to perform XOR calculation with the second plaintext data block to obtain the second ciphertext data block, and so on, until the mth ciphertext data block C(m) is calculated, the m ciphertext data blocks are spliced to generate a whole segment of ciphertext firmware data, and the spliced ciphertext data is CRC calculated to obtain ciphertext check information, which is used for data content verification and comparison.
[0078] In the present application scheme, the firmware data is transmitted and communicated from the downloader to the chip end by encrypting and decrypting the firmware data, encrypting and decrypting the sequence value, and generating ciphertext verification information. Encrypting the sequence value can prevent the data from being stolen or copied. Encrypting the firmware data can improve the security of the data. Since the sequence value is dynamically updated, the data information transmitted in each communication is different and is also dynamically updated, thereby preventing the data from being brute-force cracked. Ciphertext verification information, such as CRC ciphertext, is used to verify the data content, and can check whether the data has been tampered with during the transmission process. The whole process enhances the security and integrity of data transmission, thereby making it difficult to steal and copy the firmware content even if the data is directly captured and copied. In addition, the encryption method of XOR calculation is simple to calculate, and it is convenient to decrypt the encrypted content later, avoiding the situation where the encrypted content is irreversible.
[0079] In summary, in the embodiment of the present application, the complete interactive process of the downloader and the chip to realize firmware transmission and download is as follows: after the chip is powered on, a 32-bit random number is randomly generated, and the random number is encrypted using a preset fixed key key_handshake. For the specific encryption method, refer to Figure 3 As shown, the encrypted random number is transmitted to the downloader, and the downloader receives the encrypted random number and uses Figure 4 The decryption method shown decrypts the encrypted random number to obtain a plaintext random number (rand_dev_info). The downloader concatenates the plaintext random number, key_handshake, and 0 to generate the handshake confirmation key "rand_dev_info || key_handshake || 0x00000000", encrypts the confirmation information ACK, and transmits the encrypted ACK information to the chip end. The chip end decrypts the encrypted ACK information and compares the decrypted ACK information with the original ACK information. If the comparison is consistent, the handshake is successful.
[0080] During each firmware download communication, the downloader generates a firmware data key "rand_dev_info || key_handshake || seq", where seq refers to the sequence value, which is dynamically updated according to the number of communications. The firmware data key is used to encrypt the firmware data. For specific encryption methods, refer to Figure 6As shown, the encrypted ciphertext firmware data is verified and calculated to generate ciphertext verification information; then, the sequence value is encrypted. The encryption method can refer to the encryption method of random numbers to generate a ciphertext sequence value. The ciphertext sequence value, ciphertext firmware data and ciphertext verification information are sequentially concatenated to generate dynamic encrypted firmware information, and the dynamic encrypted firmware information is transmitted to the chip. When the chip receives the dynamic encrypted firmware information, it first decrypts the encrypted sequence value. The decryption method can refer to the decryption method of random numbers to obtain the plaintext sequence value; then the CRC verification calculation is performed on the received ciphertext firmware data to ensure that the data has not been tampered with; then the plaintext sequence value, key_handshake and random number are used to generate the firmware data key "rand_dev_info || key_handshake || seq" for decryption. For specific decryption methods, refer to Figure 5 As shown, the plaintext firmware data required by the user is finally generated, and then the plaintext firmware data is downloaded to the corresponding position of the chip.
[0081] Figure 2 FIG. 1 is a flowchart of a method for protecting a firmware download link in an embodiment. It should be understood that although Figure 2 The steps in the flowchart are shown in sequence as indicated by the arrows, but the steps are not necessarily executed in the order indicated by the arrows; unless otherwise specified in this document, there is no strict order restriction for the execution of the steps, and the steps may be executed in other orders; and Figure 2 At least part of the steps may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps.
[0082] Based on the above method, an embodiment of the present application also discloses a protection device for a firmware download link.
[0083] Reference Figure 7 , the device includes the following modules:
[0084] A random number generation module 701 is used to generate a random number when starting up and powering on, and the random number is randomly generated by the receiving end device;
[0085] A handshake confirmation module 702, used to complete a handshake operation with the downloader using a random number, a preset fixed key and preset handshake confirmation information;
[0086] The dynamic decryption module 703 is used to receive dynamically encrypted firmware information and decrypt the dynamically encrypted firmware information to generate plaintext firmware data, wherein the dynamically encrypted firmware information is generated after the downloader dynamically encrypts the firmware information to be transmitted, and the encryption method of the firmware information to be transmitted by the downloader corresponds to the decryption method of the dynamically encrypted firmware information by the receiving device.
[0087] In one embodiment, the handshake confirmation module 702 is specifically used to encrypt a random number using a preset fixed key, generate an encrypted random number, and transmit the encrypted random number to the downloader; receive encrypted handshake confirmation information, and decrypt the encrypted handshake confirmation information to generate plaintext handshake confirmation information, wherein the encrypted handshake confirmation information is generated after the downloader decrypts the encrypted random number to generate a plaintext random number, and then encrypts the preset handshake confirmation information according to a first encryption rule; compare the decrypted plaintext handshake confirmation information with the preset handshake confirmation information; if the plaintext handshake confirmation information is consistent with the preset handshake confirmation information, the handshake with the downloader is completed.
[0088] In one embodiment, the handshake confirmation module 702 is specifically used to split the preset fixed key into two data blocks to generate a high-order fixed key and a low-order fixed key; perform an XOR calculation on the random number and the high-order fixed key to generate a first intermediate ciphertext; and perform an XOR calculation on the first intermediate ciphertext and the low-order fixed key to generate an encrypted random number.
[0089] In one embodiment, in the handshake confirmation module 702, the first encryption rule specifically includes concatenating the decrypted plaintext random number, the preset fixed key and the value 0 to generate a handshake confirmation key; and performing an XOR operation on the handshake confirmation key and the preset handshake confirmation information.
[0090] In one embodiment, in the dynamic decryption module 703, the firmware information to be transmitted includes a sequence value, firmware data and verification information, wherein the sequence value is determined according to the number of communications between the downloader and the receiving device, and the sequence value is increased by one each time the downloader and the receiving device communicate; the dynamically encrypted firmware information includes a ciphertext sequence value, ciphertext firmware data and ciphertext verification information, wherein the ciphertext sequence value, ciphertext firmware data and ciphertext verification information are generated by the downloader to encrypt the firmware information to be transmitted.
[0091] In one embodiment, the dynamic decryption module 703 is specifically used to decrypt the dynamically encrypted firmware information, and the generation of plaintext firmware data includes: splitting the ciphertext firmware data according to a preset data size to generate a number of ciphertext firmware data blocks; performing a preset ciphertext verification calculation on the several ciphertext firmware data blocks to generate ciphertext firmware verification data; comparing the ciphertext firmware verification data with the ciphertext verification information sent by the downloader; if the comparison result is consistent, decrypting the ciphertext sequence value to generate a plaintext sequence value; determining whether the decrypted plaintext sequence value and the sequence value of the current processing record are greater than 1; if the decrypted plaintext sequence value and the sequence value of the current processing record are not greater than 1, concatenating the random number, the preset fixed key and the plaintext sequence value to generate a firmware data key; using the firmware data key to decrypt the ciphertext firmware data to generate plaintext firmware data.
[0092] In one embodiment, the dynamic decryption module 703 is specifically used to decrypt the ciphertext firmware data using the firmware data key to generate the plaintext firmware data, including: performing XOR calculations on adjacent ciphertext firmware data blocks in sequence to generate a number of plaintext firmware data blocks corresponding to the ciphertext firmware data blocks, wherein the first ciphertext data block in the ciphertext firmware data block is XORed with the firmware data key to generate the first plaintext firmware data block; and splicing a number of plaintext firmware data blocks to generate the plaintext firmware data.
[0093] In one embodiment, the dynamic decryption module 703 is specifically used to decrypt the ciphertext sequence value, and generating a plaintext sequence value includes: splitting the preset fixed key into two data blocks to generate a high-order fixed key and a low-order fixed key; performing an XOR calculation on the ciphertext sequence value and the low-order fixed key to generate a first intermediate plaintext; performing an XOR calculation on the first intermediate plaintext and the high-order fixed key to generate a plaintext sequence value.
[0094] The firmware download link protection device provided in the embodiment of the present application can be applied to the firmware download link protection method provided in the above embodiment. For relevant details, refer to the above method embodiment. The implementation principle and technical effect are similar and will not be repeated here.
[0095] It should be noted that: the firmware download link protection device provided in the embodiment of the present application only uses the division of the above-mentioned functional modules / functional units as an example when protecting the firmware download link. In actual applications, the above-mentioned functions can be assigned to different functional modules / functional units as needed, that is, the internal structure of the firmware download link protection device is divided into different functional modules / functional units to complete all or part of the functions described above. In addition, the implementation method of the firmware download link protection method provided in the above method embodiment and the implementation method of the firmware download link protection device provided in this embodiment belong to the same concept. The specific implementation process of the firmware download link protection device provided in this embodiment is detailed in the above method embodiment, which will not be repeated here.
[0096] The embodiment of the present application also discloses a computer device.
[0097] Specifically, if Figure 8 As shown, the computer device can be a computer device such as a desktop computer, a laptop computer, a PDA, and a cloud server. The computer device may include, but is not limited to, a processor and a memory. The processor and the memory may be connected via a bus or other means. The processor may be a central processing unit (CPU). The processor may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, graphics processors (GPU), embedded neural network processors (NPU) or other dedicated deep learning coprocessors, discrete gates or transistor logic devices, discrete hardware components and other chips, or a combination of the above chips.
[0098] As a non-transient computer-readable storage medium, the memory can be used to store non-transient software programs, non-transient computer executable programs and modules, such as program instructions / modules corresponding to the methods in the above-mentioned embodiments of the present application. The processor executes various functional applications and data processing of the processor by running the non-transient software programs, instructions and modules stored in the memory, that is, the method in the above-mentioned method implementation is realized. The memory may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created by the processor, etc. In addition, the memory may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory may optionally include a memory remotely arranged relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network and a combination thereof.
[0099] The embodiment of the present application also discloses a computer-readable storage medium.
[0100] Specifically, the computer-readable storage medium is used to store a computer program, and when the computer program is executed by the processor, the method in the above-mentioned method implementation is implemented. Those skilled in the art can understand that the implementation of all or part of the process in the above-mentioned implementation method of the present application can be completed by instructing the relevant hardware through a computer program, and the program can be stored in a computer-readable storage medium. When the program is executed, it may include the process of the implementation of the above-mentioned methods. Among them, the storage medium can be a disk, an optical disk, a read-only memory (ROM), a random access memory (RAM), a flash memory (Flash Memory), a hard disk (Hard Disk Drive, abbreviated: HDD) or a solid-state drive (SSD), etc.; the storage medium can also include a combination of the above-mentioned types of memory.
[0101] This specific embodiment is merely an explanation of the present invention and is not a limitation of the present invention. After reading this specification, those skilled in the art may make non-creative modifications to the present embodiment as needed. However, as long as they are within the scope of the claims of the present invention, they are protected by the patent law.
Claims
1. A method for protecting a firmware download link, characterized in that: The method is applied to a receiving end device, and the method comprises: When powering on, generating a random number, the random number being randomly generated by the receiving end device; Complete the handshake operation with the downloader using the random number, the preset fixed key and the preset handshake confirmation information; Receiving dynamically encrypted firmware information, and decrypting the dynamically encrypted firmware information to generate plaintext firmware data, wherein the dynamically encrypted firmware information is generated after the downloader dynamically encrypts the firmware information to be transmitted, and the downloader encrypts the firmware information to be transmitted in a manner corresponding to the receiving end device's decryption manner of the dynamically encrypted firmware information; The firmware information to be transmitted includes a sequence value, firmware data and verification information, wherein the sequence value is determined according to the number of communications between the downloader and the receiving device, and the sequence value is increased by one each time the downloader and the receiving device communicate once; The dynamically encrypted firmware information includes a ciphertext sequence value, ciphertext firmware data, and ciphertext verification information, wherein the ciphertext sequence value, the ciphertext firmware data, and the ciphertext verification information are generated by the downloader encrypting the firmware information to be transmitted; The decrypting the dynamically encrypted firmware information to generate plaintext firmware data includes: Splitting the ciphertext firmware data according to a preset data size to generate a plurality of ciphertext firmware data blocks; Performing a preset ciphertext verification calculation on the plurality of ciphertext firmware data blocks to generate ciphertext firmware verification data; Comparing the ciphertext firmware verification data with the ciphertext verification information sent by the downloader; If the comparison results are consistent, the ciphertext sequence value is decrypted to generate a plaintext sequence value; Determine whether the plaintext sequence value after decryption and the sequence value of the currently processed record are greater than 1; If the decrypted plaintext sequence value and the sequence value of the current processing record are not greater than 1, concatenating the random number, the preset fixed key and the plaintext sequence value to generate a firmware data key; The firmware data key is used to decrypt the ciphertext firmware data to generate plaintext firmware data.
2. The method according to claim 1, characterized in that: The use of the random number, the preset fixed key and the preset handshake confirmation information to complete the handshake operation with the downloader includes: Encrypting the random number using the preset fixed key to generate an encrypted random number, and transmitting the encrypted random number to a downloader; Receiving encrypted handshake confirmation information, and decrypting the encrypted handshake confirmation information to generate plaintext handshake confirmation information, wherein the encrypted handshake confirmation information is generated by the downloader decrypting the encrypted random number to generate a plaintext random number and then encrypting the preset handshake confirmation information according to a first encryption rule; Comparing the decrypted plaintext handshake confirmation information with the preset handshake confirmation information; If the plaintext handshake confirmation information is consistent with the preset handshake confirmation information, the handshake with the downloader is completed.
3. The method according to claim 2, characterized in that: The step of encrypting the random number by using the preset fixed key to generate the encrypted random number comprises: Splitting the preset fixed key into two data blocks to generate a high-order fixed key and a low-order fixed key; Performing an XOR calculation on the random number and the high-bit fixed key to generate a first intermediate ciphertext; The first intermediate ciphertext is XORed with the low-bit fixed key to generate an encrypted random number.
4. The method according to claim 2, characterized in that: The first encryption rule includes: The decrypted plaintext random number, the preset fixed key and the value 0 are concatenated to generate a handshake confirmation key; An XOR operation is performed on the handshake confirmation key and the preset handshake confirmation information.
5. The method according to claim 1, characterized in that: The using the firmware data key to decrypt the ciphertext firmware data to generate plaintext firmware data comprises: Performing XOR calculation on adjacent ciphertext firmware data blocks in order to generate a plurality of plaintext firmware data blocks corresponding to the ciphertext firmware data blocks, wherein a first ciphertext data block in the ciphertext firmware data blocks is XOR-calculated with the firmware data key to generate a first plaintext firmware data block; Several of the plaintext firmware data blocks are concatenated to generate plaintext firmware data.
6. The method according to claim 1, characterized in that: Decrypting the ciphertext sequence value to generate a plaintext sequence value includes: Splitting the preset fixed key into two data blocks to generate a high-order fixed key and a low-order fixed key; Performing an XOR calculation on the ciphertext sequence value and the low-order fixed key to generate a first intermediate plaintext; The first intermediate plaintext is XORed with the high-order fixed key to generate a plaintext sequence value.
7. A firmware download link protection device, applied to the firmware download link protection method according to any one of claims 1 to 6, characterized in that: The device is applied to a receiving end device, and the device includes: A random number generation module (701) is used to generate a random number when power is turned on, wherein the random number is randomly generated by the receiving end device; A handshake confirmation module (702) is used to complete a handshake operation with the downloader using the random number, a preset fixed key and preset handshake confirmation information; The dynamic decryption module (703) is used to receive dynamically encrypted firmware information and decrypt the dynamically encrypted firmware information to generate plaintext firmware data, wherein the dynamically encrypted firmware information is generated after the downloader dynamically encrypts the firmware information to be transmitted, and the encryption method of the firmware information to be transmitted by the downloader corresponds to the decryption method of the dynamically encrypted firmware information by the receiving device.
8. A computer device, characterized in that: The method comprises a memory and a processor, wherein the memory stores a computer program that can be loaded by the processor and execute the method according to any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that: A computer program is stored which can be loaded by a processor and execute the method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Solid state disk controller safe loading method and device and storage medium
CN110008724A
Information encryption method, decryption method, device and electronic equipment
CN113515752A