A firmware security protection and upgrade method, system, device and medium

By performing authentication checksum encryption before firmware loading and two-way authentication during the upgrade process, the problems of malicious tampering and high cost during firmware loading and upgrading are solved, and the security and accuracy of the firmware are achieved.

CN118656841BActive Publication Date: 2024-11-12SHANDONG ZHONGFU INFORMATION IND
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411141258.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-08-20
Publication Date
2024-11-12
Estimated Expiration
2044-08-20

AI Technical Summary

Technical Problem

The prior art poses a risk of malicious tampering during firmware loading and upgrading, and the upgrade cost is high and the accuracy is difficult to guarantee, resulting in storage security issues.

Method used

Before the firmware is loaded, the new firmware is encrypted through encryption tools, and two-way authentication is performed during the upgrade process to ensure the integrity and accuracy of the firmware and ensure the reliability of the upgrade through multiple verifications.

Benefits of technology

Effectively prevent malicious tampering of firmware, ensure information security, reduce upgrade costs, and improve the accuracy and security of firmware transmission.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118656841B_ABST
    Figure CN118656841B_ABST
Patent Text Reader

Abstract

The present application discloses a firmware security protection and upgrade method, system, device and medium, which mainly relates to the field of firmware security technology, and is used to solve the problems of malicious tampering of existing firmware protection, high firmware upgrade costs or the risk of difficulty in ensuring accuracy and tampering. It includes: adding a preset authentication verification algorithm to the BOOT of the preset loading device corresponding to the firmware; encrypting the new version of the firmware file through an encryption tool to obtain encrypted data in a preset encrypted file format; verifying the encrypted data through an upgrade tool, and the upgrade tool sends the ciphertext firmware file check value and the ciphertext firmware file in the encrypted data to the preset upgrade program; obtaining the new version of the firmware file, writing the new version of the firmware file to the preset backup area, reading back the written new version of the firmware file, and generating a secondary verification code; when the secondary verification code is consistent with the ciphertext firmware file check value, rewriting the flag bit to complete the upgrade.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of firmware security technology, and in particular to a firmware security protection and upgrade method, system, device and medium. Background Art

[0002] Secure storage devices are a type of embedded devices used to store important security information, such as password keys, special USB flash drives for confidential information, password cards, encryption cards, etc. These devices need to ensure the authenticity, confidentiality, integrity, availability and reliability of data. Before working normally, secure storage devices will undergo firmware loading. Only after the firmware required by the device is loaded can the device work normally; during operation or when shutting down, it will also involve the operation of upgrading the new firmware.

[0003] The prior art solution usually does not do any processing when loading the firmware, directly boots and loads the firmware stored in the flash, and loads the firmware into the RAM for execution. When upgrading the new firmware, the chip is usually re-burned or an upgrade tool is used to burn the plaintext firmware directly into a specific area.

[0004] However, if the firmware content of the storage flash is maliciously tampered with, the device will cause unknown errors after loading the maliciously tampered firmware, such as information leakage, information destruction, information loss, etc., which will cause very serious storage security problems. In addition, when upgrading the new firmware, if the device is in the hands of the customer, it needs to be returned to the factory for burning, which will increase the cost of the upgrade. The use of special upgrade tools can greatly save the upgrade cost, but the existing solution cannot ensure the accuracy of firmware transmission. The distribution of new firmware also has a certain risk of tampering. Summary of the invention

[0005] In view of the above-mentioned deficiencies in the prior art, the present application provides a firmware security protection and upgrade method, system, device and medium to solve the problems of malicious tampering of existing firmware protection, high firmware upgrade costs or difficulty in ensuring accuracy and the risk of tampering.

[0006] In a first aspect, the present application provides a firmware security protection and upgrade method, the method comprising: adding a preset authentication verification algorithm to the BOOT of a preset loading device corresponding to the firmware, and verifying the firmware with the preset authentication verification algorithm before loading the firmware; when encrypting a new version of the firmware file, the preset loading device runs the encryption tool in the host computer software, and encrypts the new version of the firmware file through the encryption tool to obtain encrypted data in a preset encrypted file format; when the verification is successful and the new version of the firmware file is installed, the preset loading device runs the upgrade tool in the host computer software, and verifies the encrypted data through the upgrade tool. When the verification is successful, the upgrade tool performs two-way authentication with the hardware device corresponding to the original firmware. When the authentication is successful, the upgrade tool sends the ciphertext firmware file verification value and the ciphertext firmware file in the encrypted data to a preset upgrade program; decrypting the ciphertext firmware file through the preset upgrade program to obtain a new version of the firmware file, writing the new version of the firmware file into a preset backup area, reading back the written new version of the firmware file, and generating a secondary verification code; when the secondary verification code is consistent with the ciphertext firmware file verification value, feedback is given to the upgrade tool to indicate that the verification is successful; and at the same time, the flag bit is rewritten to complete the upgrade.

[0007] Furthermore, the firmware is verified using a preset authentication verification algorithm, specifically including: inputting the firmware version information corresponding to the firmware into the preset authentication verification algorithm to obtain an output first verification value; reading a second verification value stored in a preset area of ​​the firmware; when the first verification value is consistent with the second verification value, the verification is successful; otherwise, the verification fails.

[0008] Furthermore, the encrypted data also includes a plaintext file header and a plaintext file check value; the new version of the firmware file is encrypted by an encryption tool to obtain encrypted data in a preset encrypted file format, specifically including: obtaining configuration information of the new version of the firmware file; wherein the configuration information at least includes: firmware version information, matching product information; using the configuration information as the plaintext file header of the encrypted data; using a preset encryption algorithm to encrypt the new version of the firmware file to obtain a ciphertext firmware file; inputting the new version of the firmware file into a preset check algorithm to obtain a ciphertext firmware file check value; inputting the plaintext file header, the ciphertext firmware file, and the ciphertext firmware file check value as a whole into the preset check algorithm to obtain a plaintext file check value.

[0009] Furthermore, the encrypted data is verified through the upgrade tool, specifically including: reading the plaintext file header and plaintext file verification value in the encrypted data; determining whether the version information corresponding to the current firmware is lower than the firmware version information in the plaintext file header; determining whether the product corresponding to the current firmware belongs to the matching product information in the plaintext file header; when it is lower than the firmware version information in the plaintext file header and belongs to the matching product information in the plaintext file header, the preliminary match is successful; otherwise, the preliminary match fails and the process ends; after the preliminary match is successful, the non-plaintext file verification value part in the encrypted data is input into a preset verification algorithm to obtain a first verification code; when the first verification code is consistent with the plaintext file verification value, it is determined that the verification is successful; otherwise, the verification fails.

[0010] Furthermore, the upgrade tool performs two-way authentication with the hardware device corresponding to the original firmware, specifically including: the upgrade tool generates a random number , sent to the hardware device along with the first instruction; when the hardware device receives RB, it generates a random number RA and obtains the string RA||RB; through the first preset authentication key Encrypt the string RA||RB and get ; Among them, || represents connection; Return to the upgrade tool, the upgrade tool passes the first preset authentication key Decryption Get the first decrypted string; when the first decrypted string does not contain RB, generate a random number again , sent to the hardware device along with the first instruction; when the decrypted string contains RB, the upgrade tool obtains RA⊕RB; where ⊕ represents an XOR operation; and passes the second preset authentication key Encrypt RA⊕RB and obtain ; The second instruction is sent to the hardware device; the hardware device passes the second preset authentication key right Decryption is performed to obtain a second decrypted string; when the hardware device determines that the second decrypted string is RA⊕RB, the two-way authentication succeeds; otherwise, the two-way authentication fails.

[0011] Furthermore, the ciphertext firmware file is decrypted by a preset upgrade program to obtain a new version of the firmware file, the new version of the firmware file is written into a preset backup area, the written new version of the firmware file is read back, and a secondary verification code is generated, which specifically includes: the preset upgrade program calls the decryption algorithm corresponding to the preset encryption algorithm, decrypts the ciphertext firmware file, and obtains the new version of the firmware file; writes the new version of the firmware file into the preset backup area, and reads back the written new version of the firmware file; and inputs the read back new version of the firmware file into the preset verification algorithm to obtain a secondary verification code.

[0012] On the second aspect, the present application provides a firmware security protection and upgrade system, the system includes: a loading verification component, which is used to add a preset authentication verification algorithm to the BOOT of a preset loading device corresponding to the firmware, and verify the preset authentication verification algorithm of the firmware before loading the firmware; a host computer software, and the host computer software includes an encryption tool and an upgrade tool; the encryption tool is used for when the verification is successful and the new version of the firmware file is encrypted, the preset loading device runs the encryption tool in the host computer software, and the new version of the firmware file is encrypted by the encryption tool to obtain encrypted data in a preset encrypted file format; the upgrade tool is used for when the verification is successful and the new version of the firmware file is encrypted During installation, the preset loading device runs the upgrade tool in the upper computer software, and verifies the encrypted data through the upgrade tool. When the verification is successful, the upgrade tool performs two-way authentication with the hardware device corresponding to the original firmware. When the authentication is successful, the upgrade tool sends the ciphertext firmware file verification value and the ciphertext firmware file in the encrypted data to the preset upgrade component; the preset upgrade component is used to decrypt the ciphertext firmware file, obtain the new version of the firmware file, write the new version of the firmware file into the preset backup area, read back the written new version of the firmware file, and generate a secondary verification code; when the secondary verification code is consistent with the ciphertext firmware file verification value, the verification success is fed back to the upgrade tool; at the same time, the flag bit is rewritten to complete the upgrade.

[0013] Furthermore, the upgrade tool includes a two-way authentication unit for generating a random number , sent to the hardware device along with the first instruction; when the hardware device receives RB, it generates a random number RA and obtains the string RA||RB; through the first preset authentication key Encrypt the string RA||RB and get ; Among them, || indicates connection; get the returned , through the first preset authentication key Decryption Get the first decrypted string; when the first decrypted string does not contain RB, generate a random number again , sent to the hardware device along with the first instruction; when the decrypted string contains RB, RA⊕RB is obtained; where ⊕ represents an XOR operation; and the second preset authentication key is passed Encrypt RA⊕RB and obtain ; The second instruction is sent to the hardware device; the hardware device passes the second preset authentication key right Decryption is performed to obtain a second decrypted string; when the hardware device determines that the second decrypted string is RA⊕RB, the two-way authentication succeeds; otherwise, the two-way authentication fails.

[0014] In a third aspect, the present application provides a firmware security protection and upgrade device, the device comprising: a processor; and a memory on which executable code is stored, and when the executable code is executed, the processor executes a firmware security protection and upgrade method such as any one of the above.

[0015] In a fourth aspect, the present application provides a non-volatile computer storage medium on which computer instructions are stored, and when the computer instructions are executed, a firmware security protection and upgrade method such as any of the above items is implemented.

[0016] Those skilled in the art can understand that the present application has at least the following beneficial effects:

[0017] This application adds an authentication verification algorithm to BOOT. The firmware will be read for verification before startup. If the verification fails, it will not be loaded and the device will not start. This can effectively prevent malicious tampering of the firmware, prevent malicious firmware from running or important information from being leaked.

[0018] This application uses the encryption tool in the host computer software to encrypt the new version of the firmware file; in addition, the verification algorithm involved in the encryption tool also exists in the upgrade tool, and the data involved in the upgrade tool is verified to ensure the integrity and accuracy of the obtained upgrade file.

[0019] In addition, the upgrade process involves the introduction of a two-way identity authentication method to ensure the security of the upgrade channel; the firmware file does not transmit plain text information, ensuring that the firmware is not maliciously tampered with; the present application has built-in multiple checks in the upgrade process to ensure the reliability of the upgrade; among them, the firmware file is encrypted and distributed to ensure the security of the distributed firmware; it solves the problem of high firmware upgrade costs or the difficulty in ensuring accuracy and the risk of tampering. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] Some embodiments of the present disclosure are described below with reference to the accompanying drawings, in which:

[0021] Figure 1 It is a flowchart of a firmware security protection and upgrade method provided in an embodiment of the present application.

[0022] Figure 2 It is a schematic diagram of encrypted data in a preset encrypted file format provided in an embodiment of the present application.

[0023] Figure 3 It is a schematic diagram of the internal structure of a firmware security protection and upgrade system provided in an embodiment of the present application.

[0024] Figure 4 It is a schematic diagram of the internal structure of a firmware security protection and upgrade device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0025] It should be understood by those skilled in the art that the embodiments described below are only preferred embodiments of the present disclosure, and do not mean that the present disclosure can only be implemented through the preferred embodiments. The preferred embodiments are only used to explain the technical principles of the present disclosure, and are not used to limit the protection scope of the present disclosure. Based on the preferred embodiments provided by the present disclosure, all other embodiments obtained by ordinary technicians in this field without creative work should still fall within the protection scope of the present disclosure.

[0026] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.

[0027] The technical solution proposed in the embodiments of the present application is described in detail below with reference to the accompanying drawings.

[0028] The present application embodiment provides a firmware security protection and upgrade method, such as Figure 1 As shown, the method provided in the embodiment of the present application mainly includes the following steps:

[0029] Step 110: Add a preset authentication verification algorithm to the BOOT of the preset loading device corresponding to the firmware, and verify the firmware with the preset authentication verification algorithm before loading the firmware for execution.

[0030] It should be noted that an authentication verification algorithm is added to BOOT, and the firmware will be read for verification before startup. The preset authentication verification algorithm is not limited to MD5, HAS, HMAC and other algorithms. It is compared with the verification value stored in a specific area of ​​​​the flash. If the comparison passes, the firmware is loaded normally. If the verification fails, it will not be loaded and the device will not start. In this way, malicious tampering of the firmware can be effectively prevented, and malicious firmware can be prevented from running or important information can be leaked.

[0031] Among them, the firmware is verified by a preset authentication verification algorithm, which can be specifically: inputting the firmware version information corresponding to the firmware into the preset authentication verification algorithm to obtain an output first verification value; reading a second verification value stored in the firmware in a preset area (for example, a specific area of ​​flash); when the first verification value is consistent with the second verification value, the verification is successful; otherwise, the verification fails.

[0032] Step 120: When encrypting the new version of the firmware file, the preset loading device runs the encryption tool in the upper computer software, encrypts the new version of the firmware file through the encryption tool, and obtains encrypted data in a preset encrypted file format.

[0033] It should be noted that the encryption tool uses encryption algorithms and verification algorithms; verification algorithms, such as HMAC-SM3, etc.; firmware encryption algorithms, such as SM4-CBC, etc.; the keys involved are uniformly managed, generated, and distributed by the key administrator according to the product to avoid leakage. In addition to being built into the firmware encryption tool to process new firmware, the keys are also distributed to R&D and upgrade core component personnel. In addition, the verification algorithm involved in the encryption tool also exists in the upgrade tool, which verifies the data involved in the upgrade tool to ensure the integrity and accuracy of the upgrade file obtained. In addition, the encryption tool is an independently running tool that is not embedded in any process and exists only as a tool for encrypting and upgrading firmware.

[0034] In addition, if Figure 2 As shown, the encrypted data includes a file header, a firmware file check value, a firmware file, and a file check value;

[0035] Among them, the new version of the firmware file is encrypted by an encryption tool to obtain encrypted data in a preset encrypted file format, which can be specifically: obtaining configuration information of the new version of the firmware file; wherein the configuration information at least includes: firmware version information, matching product information; using the configuration information as the plaintext file header of the encrypted data; using a preset encryption algorithm to encrypt the new version of the firmware file to obtain a ciphertext firmware file; inputting the new version of the firmware file into a preset verification algorithm to obtain a ciphertext firmware file verification value; inputting the plaintext file header, the ciphertext firmware file, and the ciphertext firmware file verification value as a whole into the preset verification algorithm to obtain a plaintext file verification value.

[0036] Step 130, when the verification is successful and the new version of the firmware file is installed, the preset loading device runs the upgrade tool in the upper computer software, and the encrypted data is verified by the upgrade tool. When the verification is successful, the upgrade tool and the hardware device corresponding to the original firmware perform two-way authentication. When the authentication is successful, the upgrade tool sends the ciphertext firmware file verification value and the ciphertext firmware file in the encrypted data to the preset upgrade program.

[0037] The encrypted data is verified by the upgrade tool, which can be specifically:

[0038] Read the plaintext file header and plaintext file check value in the encrypted data; determine whether the version information corresponding to the current firmware is lower than the firmware version information in the plaintext file header; determine whether the product corresponding to the current firmware belongs to the matching product information in the plaintext file header; when it is lower than the firmware version information in the plaintext file header and belongs to the matching product information in the plaintext file header, the preliminary match is successful; otherwise, the preliminary match fails and the process ends; after the preliminary match is successful, input the non-plaintext file check value part in the encrypted data into the preset check algorithm to obtain the first check code; when the first check code is consistent with the plaintext file check value, it is determined that the check is successful; otherwise, the check fails.

[0039] The upgrade tool and the hardware device corresponding to the original firmware perform two-way authentication, which can be specifically:

[0040] Upgrade tool to generate random numbers , sent to the hardware device along with the first instruction; when the hardware device receives RB, it generates a random number RA and obtains the string RA||RB; through the first preset authentication key Encrypt the string RA||RB and get ; Among them, || represents connection.

[0041] Will Return to the upgrade tool, the upgrade tool passes the first preset authentication key Decryption Get the first decrypted string; when the first decrypted string does not contain RB, generate a random number again , sent to the hardware device along with the first instruction; when the decrypted string contains RB, the upgrade tool obtains RA⊕RB; where ⊕ represents an XOR operation; and passes the second preset authentication key Encrypt RA⊕RB and obtain ; The second instruction is sent to the hardware device; the hardware device passes the second preset authentication key right Decryption is performed to obtain a second decrypted string; when the hardware device determines that the second decrypted string is RA⊕RB, the two-way authentication succeeds; otherwise, the two-way authentication fails.

[0042] Step 140, decrypt the ciphertext firmware file through the preset upgrade program to obtain the new version firmware file, write the new version firmware file into the preset backup area, read back the written new version firmware file, and generate a secondary verification code; when the secondary verification code is consistent with the verification value of the ciphertext firmware file, feedback the verification success to the upgrade tool; at the same time, rewrite the flag bit to complete the upgrade.

[0043] Among them, the ciphertext firmware file is decrypted by a preset upgrade program to obtain a new version of the firmware file, the new version of the firmware file is written into a preset backup area, the written new version of the firmware file is read back, and a secondary verification code is generated, which can be specifically:

[0044] The preset upgrade program calls the decryption algorithm corresponding to the preset encryption algorithm, decrypts the ciphertext firmware file, and obtains the new version firmware file; writes the new version firmware file into the preset backup area, and reads back the written new version firmware file; inputs the read back new version firmware file into the preset verification algorithm to obtain a secondary verification code.

[0045] besides, Figure 3 A firmware security protection and upgrade system is provided in the embodiment of the present application. Figure 3 As shown, the system provided in the embodiment of the present application mainly includes:

[0046] The loading verification component 210 is used to add a preset authentication verification algorithm to the BOOT of the preset loading device corresponding to the firmware, and verify the firmware with the preset authentication verification algorithm before the loaded firmware is run.

[0047] The host computer software 220 includes an encryption tool and an upgrade tool.

[0048] The encryption tool 221 is used to encrypt the new version of the firmware file. The preset loading device runs the encryption tool 221 in the host computer software 220, and the encryption tool 221 encrypts the new version of the firmware file to obtain encrypted data in a preset encrypted file format.

[0049] It should be noted that after the verification is successful, it will only work normally or upgrade. The encryption tool 221 is an independent tool. It is not started once when the upgrade is started. The encryption tool 221 is only placed in the hands of a person who distributes the upgrade firmware to make formatted encrypted firmware.

[0050] The upgrade tool 222 is used for when the verification is successful and the new version of the firmware file is installed. The preset loading device runs the upgrade tool 222 in the upper computer software 220, and the encrypted data is verified by the upgrade tool 222. When the verification is successful, the upgrade tool 222 performs two-way authentication with the hardware device corresponding to the original firmware. When the authentication is successful, the upgrade tool 222 sends the ciphertext firmware file verification value and the ciphertext firmware file in the encrypted data to the preset upgrade component 230.

[0051] The upgrade tool 222 includes a two-way authentication unit for generating a random number , sent to the hardware device along with the first instruction; when the hardware device receives RB, it generates a random number RA and obtains the string RA||RB; through the first preset authentication key Encrypt the string RA||RB and get ; Among them, || indicates connection; get the returned , through the first preset authentication key Decryption Get the first decrypted string; when the first decrypted string does not contain RB, generate a random number again , sent to the hardware device along with the first instruction; when the decrypted string contains RB, RA⊕RB is obtained; where ⊕ represents an XOR operation; and the second preset authentication key is passed Encrypt RA⊕RB and obtain ; The second instruction is sent to the hardware device; the hardware device passes the second preset authentication key right Decryption is performed to obtain a second decrypted string; when the hardware device determines that the second decrypted string is RA⊕RB, the two-way authentication succeeds; otherwise, the two-way authentication fails.

[0052] The preset upgrade component 230 is used to decrypt the ciphertext firmware file, obtain the new version firmware file, write the new version firmware file into the preset backup area, read back the written new version firmware file, and generate a secondary verification code; when the secondary verification code is consistent with the verification value of the ciphertext firmware file, feedback the verification success to the upgrade tool 222; at the same time, rewrite the flag bit to complete the upgrade.

[0053] The above is a method embodiment of the present application. Based on the same inventive concept, the present application embodiment also provides a firmware security protection and upgrade device. Figure 4 As shown, the device includes: a processor; and a memory, on which executable code is stored. When the executable code is executed, the processor executes a firmware security protection and upgrade method as described in the above embodiment.

[0054] Specifically, the server side adds a preset authentication verification algorithm to the BOOT of the preset loading device corresponding to the firmware, and verifies the firmware with the preset authentication verification algorithm before loading the firmware for operation; when encrypting the new version of the firmware file, the preset loading device runs the encryption tool in the upper computer software, encrypts the new version of the firmware file through the encryption tool, and obtains encrypted data in the preset encrypted file format; when the verification is successful and the new version of the firmware file is installed, the preset loading device runs the upgrade tool in the upper computer software, and verifies the encrypted data through the upgrade tool. When the verification is successful, the upgrade tool performs two-way authentication with the hardware device corresponding to the original firmware. When the authentication is successful, the upgrade tool sends the ciphertext firmware file verification value and the ciphertext firmware file in the encrypted data to the preset upgrade program; decrypts the ciphertext firmware file through the preset upgrade program to obtain the new version of the firmware file, writes the new version of the firmware file into the preset backup area, reads back the written new version of the firmware file, and generates a secondary verification code; when the secondary verification code is consistent with the ciphertext firmware file verification value, feedbacks the verification success to the upgrade tool; at the same time, rewrites the flag bit to complete the upgrade.

[0055] In addition, an embodiment of the present application further provides a non-volatile computer storage medium on which executable instructions are stored. When the executable instructions are executed, a firmware security protection and upgrade method as described above is implemented.

[0056] So far, the technical solutions of the present disclosure have been described in combination with the above multiple embodiments, but it is easy for those skilled in the art to understand that the protection scope of the present disclosure is not limited to these specific embodiments. Without departing from the technical principles of the present disclosure, those skilled in the art can split and combine the technical solutions in the above-mentioned various embodiments, and can also make equivalent changes or replacements to the relevant technical features. Any changes, equivalent replacements, improvements, etc. made within the technical concept and / or technical principle of the present disclosure will fall within the protection scope of the present disclosure.

Claims

1. A firmware security protection and upgrade method, It is characterized in that The method comprises: Add a preset authentication verification algorithm to the BOOT of the preset loading device corresponding to the firmware, and verify the firmware with the preset authentication verification algorithm before loading the firmware for operation; When encrypting a new version of the firmware file, the preset loading device runs the encryption tool in the upper computer software, encrypts the new version of the firmware file through the encryption tool, and obtains encrypted data in a preset encryption file format; When the verification is successful and the new version of the firmware file is installed, the preset loading device runs the upgrade tool in the upper computer software, and the encrypted data is verified by the upgrade tool. When the verification is successful, the upgrade tool and the hardware device corresponding to the original firmware perform two-way authentication. When the authentication is successful, the upgrade tool sends the ciphertext firmware file check value and the ciphertext firmware file in the encrypted data to the preset upgrade program; The ciphertext firmware file is decrypted through the preset upgrade program to obtain the new version of the firmware file, which is written into the preset backup area. The written new version of the firmware file is read back to generate a secondary verification code. When the secondary verification code is consistent with the verification value of the ciphertext firmware file, the verification success is fed back to the upgrade tool; at the same time, the flag bit is rewritten to complete the upgrade.

2. The firmware security protection and upgrade method according to claim 1, It is characterized in that Verify the firmware using the preset authentication verification algorithm, including: Input the firmware version information corresponding to the firmware into a preset authentication verification algorithm to obtain an output first verification value; Read the second check value stored in the preset area of ​​the firmware; When the first verification value is consistent with the second verification value, the verification succeeds; otherwise, the verification fails.

3. The firmware security protection and upgrade method according to claim 1, It is characterized in that The encrypted data also includes the plaintext file header and the plaintext file check value; The new version of the firmware file is encrypted using an encryption tool to obtain encrypted data in a preset encrypted file format, including: Obtain configuration information of a new version of the firmware file; wherein the configuration information at least includes: firmware version information and matching product information; and use the configuration information as a plaintext file header of encrypted data; Use the preset encryption algorithm to encrypt the new version of the firmware file to obtain the ciphertext firmware file; Input the new version of the firmware file into the preset verification algorithm to obtain the verification value of the ciphertext firmware file; The plaintext file header, the ciphertext firmware file, and the ciphertext firmware file check value are input as a whole into a preset check algorithm to obtain the plaintext file check value.

4. The firmware security protection and upgrade method according to claim 1, It is characterized in that Use the upgrade tool to verify the encrypted data, including: Read the plaintext file header and plaintext file checksum in the encrypted data; Determine whether the version information corresponding to the current firmware is lower than the firmware version information in the plaintext file header; Determine whether the product corresponding to the current firmware belongs to the matching product information in the plain text file header; If the firmware version is lower than the firmware version information in the plain text file header and belongs to the matching product information in the plain text file header, the preliminary match is successful; otherwise, the preliminary match fails and the process ends; After the initial match is successful, the non-plaintext file check value portion of the encrypted data is input into a preset check algorithm to obtain a first check code; When the first verification code is consistent with the plaintext file verification value, it is determined that the verification is successful; otherwise, the verification fails.

5. The firmware security protection and upgrade method according to claim 1, It is characterized in that The upgrade tool and the hardware device corresponding to the original firmware perform two-way authentication, including: Upgrade tool to generate random numbers , sent to the hardware device along with the first instruction; When the hardware device receives RB, it generates a random number RA and obtains the string RA||RB; through the first preset authentication key Encrypt the string RA||RB and get ; Among them, || indicates connection; Will Return to the upgrade tool, the upgrade tool passes the first preset authentication key Decryption Get the first decrypted string; when the first decrypted string does not contain RB, generate a random number again , sent to the hardware device along with the first instruction; When the decrypted string contains RB, the upgrade tool obtains RA⊕RB, where ⊕ represents an XOR operation, and passes the second preset authentication key Encrypt RA⊕RB and obtain ; The second instruction is sent to the hardware device; the hardware device passes the second preset authentication key right Decryption is performed to obtain a second decrypted string; when the hardware device determines that the second decrypted string is RA⊕RB, the two-way authentication succeeds; otherwise, the two-way authentication fails.

6. The firmware security protection and upgrade method according to claim 1, It is characterized in that Decrypt the ciphertext firmware file through the preset upgrade program to obtain the new version of the firmware file, write the new version of the firmware file into the preset backup area, read back the written new version of the firmware file, and generate a secondary verification code, specifically including: The preset upgrade program calls the decryption algorithm corresponding to the preset encryption algorithm, decrypts the ciphertext firmware file, and obtains the new version of the firmware file; Write the new version of the firmware file into the preset backup area, and read back the written new version of the firmware file; The read-back new version firmware file is input into the preset verification algorithm to obtain a secondary verification code.

7. A firmware security protection and upgrade system, It is characterized in that The system comprises: The loading verification component is used to add a preset authentication verification algorithm to the BOOT of the preset loading device corresponding to the firmware, and verify the firmware with the preset authentication verification algorithm before the loaded firmware runs; Host computer software, including encryption tools and upgrade tools; The encryption tool is used to encrypt the new version of the firmware file, and the encryption tool in the upper computer software is run by the preset loading device to encrypt the new version of the firmware file through the encryption tool to obtain encrypted data in a preset encryption file format; The upgrade tool is used to preset the loading device to run the upgrade tool in the upper computer software when the verification is successful and the new version of the firmware file is installed. The encrypted data is verified by the upgrade tool. When the verification is successful, the upgrade tool performs two-way authentication with the hardware device corresponding to the original firmware. When the authentication is successful, the upgrade tool sends the ciphertext firmware file check value and the ciphertext firmware file in the encrypted data to the preset upgrade component; The preset upgrade component is used to decrypt the ciphertext firmware file, obtain the new version firmware file, write the new version firmware file into the preset backup area, read back the written new version firmware file, and generate a secondary verification code; when the secondary verification code is consistent with the verification value of the ciphertext firmware file, the verification success is fed back to the upgrade tool; at the same time, the flag bit is rewritten to complete the upgrade.

8. The firmware security protection and upgrade system according to claim 7, It is characterized in that The upgrade tool includes a two-way authentication unit, Used to generate random numbers , sent to the hardware device along with the first instruction; When the hardware device receives RB, it generates a random number RA and obtains the string RA||RB; By first preset authentication key Encrypt the string RA||RB and get ; Among them, || indicates connection; Get the returned , through the first preset authentication key Decryption Get the first decrypted string; when the first decrypted string does not contain RB, generate a random number again , sent to the hardware device along with the first instruction; When the decrypted string contains RB, RA⊕RB is obtained; wherein ⊕ represents an XOR operation; and the second preset authentication key is used Encrypt RA⊕RB and obtain ; The second instruction is sent to the hardware device; the hardware device passes the second preset authentication key right Decryption is performed to obtain a second decrypted string; when the hardware device determines that the second decrypted string is RA⊕RB, the two-way authentication succeeds; otherwise, the two-way authentication fails.

9. A firmware security protection and upgrade device, It is characterized in that The device comprises: processor; and a memory having executable code stored thereon, which, when the executable code is executed, enables the processor to execute a firmware security protection and upgrade method as described in any one of claims 1-6.

10. A non-volatile computer storage medium, It is characterized in that Computer instructions are stored thereon, and when the computer instructions are executed, a firmware security protection and upgrade method as described in any one of claims 1-6 is implemented.