Chip firmware verification method and device
By setting multiple check times in the chip, including during operation, multiple firmware hash value comparisons are solved, and the problem of firmware verification in the prior art cannot be continuously monitored only at startup, realizing the chip firmware Continuous protection and safety improvement.
Patent Information
- Application Number
- CN202411156541.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-21
- Publication Date
- 2024-11-05
AI Technical Summary
In the prior art, the chip firmware is only verified at startup, and cannot continuously monitor the integrity of the firmware during the chip operation, resulting in a risk of tampering during subsequent runs.
Using the method of multiple verification of firmware, determine multiple verification times, at least one of which is used to calculate the hash value to compare the legal hash value during chip operation, to ensure the integrity of the firmware at each time, and when tampering is discovered Stop the chip running.
It improves the protection of firmware during chip operation, increases the difficulty of attackers to evade detection, and effectively avoids the security risks of firmware being illegally tampered with.
Smart Images

Figure CN118898062A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of chip technology, and in particular to a chip firmware verification method and device. Background Art
[0002] Chip firmware verification refers to the process of verifying that the firmware on the chip is complete, has not been tampered with, and is as expected. Firmware is a program embedded on the chip that is responsible for controlling and managing the operation of the hardware. The main purpose of firmware verification is to ensure the integrity and correctness of the firmware to prevent accidental or malicious modifications.
[0003] Currently, when verifying chip firmware, the firmware is only verified when the chip is started, and the firmware is no longer verified after the verification passes. This method still brings risks in the subsequent chip operation process. Summary of the invention
[0004] The present invention provides a chip firmware verification method and device to solve the defects existing in the related technology.
[0005] The present invention provides a chip firmware verification method, comprising the following steps: Determine multiple verification moments of firmware to be verified in the chip, at least one of which is during the operation of the chip; At each verification time, determining a calculated hash value of the firmware to be verified at each verification time; Compare the calculated hash value at each verification time with the legal hash value of the firmware to be verified to determine the verification result of the firmware to be verified at each verification time.
[0006] According to a chip firmware verification method provided by the present invention, the period of the verification moment is determined based on a random number each time the chip is started.
[0007] According to a chip firmware verification method provided by the present invention, the verification time is determined based on the task type corresponding to the firmware to be verified.
[0008] According to a chip firmware verification method provided by the present invention, the verification time is determined based on the importance of the firmware to be verified.
[0009] According to a chip firmware verification method provided by the present invention, the legal hash value is a hash value that passes the signature verification when the firmware to be verified is started, and the legal hash value is stored in the security core of the chip.
[0010] According to a chip firmware verification method provided by the present invention, the verification result of the firmware to be verified at each verification time is determined, and then the method further includes: When the verification result of the firmware to be verified at any verification time is that there is a security risk, the chip is stopped from running.
[0011] The present invention also provides a chip firmware verification device, comprising the following modules: A determination unit, used to determine a plurality of verification moments of the firmware to be verified in the chip, at least one of which is during the operation of the chip; A calculation unit, used to determine, at each verification moment, a calculated hash value of the firmware to be verified at each verification moment; The verification unit is used to compare the calculated hash value at each verification time with the legal hash value of the firmware to be verified, and determine the verification result of the firmware to be verified at each verification time.
[0012] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, any of the chip firmware verification methods described above is implemented.
[0013] The present invention also provides a non-transitory computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the chip firmware verification method as described in any one of the above is implemented.
[0014] The present invention also provides a computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the chip firmware verification method as described above is implemented.
[0015] The chip firmware verification method and device provided by the present invention determine multiple verification moments of the firmware to be verified, that is, the present invention does not verify the firmware to be verified only once, but performs multiple verifications, and at least one verification moment is during the operation of the chip, thereby avoiding increasing the difficulty for an attacker to evade detection when the chip is running, further improving the protection capability of the firmware to be verified when the chip is running, and avoiding the security risks brought about by illegal tampering of the firmware to be verified. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] In order to more clearly illustrate the technical solutions in the present invention or related technologies, the following briefly introduces the drawings required for use in the embodiments or related technical descriptions. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0017] Figure 1 This is one of the flow charts of the chip firmware verification method provided by the present invention.
[0018] Figure 2This is the second flow chart of the chip firmware verification method provided by the present invention.
[0019] Figure 3 It is a structural schematic diagram of the chip firmware verification device provided by the present invention.
[0020] Figure 4 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION
[0021] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0022] At present, when verifying the firmware of a chip (such as System on Chip, SOC), the firmware is only verified when the chip is started, and the firmware is no longer verified after the verification passes. Then, during the subsequent operation of the chip, the firmware may still be at risk of being tampered with, thereby bringing security risks to the operation of the chip.
[0023] Figure 1 This is one of the flow charts of the chip firmware verification method provided by the present invention, such as Figure 1 As shown, the method includes step 110 , step 120 and step 130 .
[0024] Step 110: Determine multiple verification moments of the firmware to be verified in the chip, at least one of which is during the operation of the chip.
[0025] Here, the firmware to be verified refers to the firmware (Firmware, FW) running on the chip, and the firmware to be verified may include a boot loader, an operating system firmware, a device driver, an application firmware, etc. The chip may be an artificial intelligence chip, and the artificial intelligence chip may include a graphics processing unit (Graphics Processing Unit, GPU), a general-purpose graphics processing unit (General-Purpose Graphics Processing Unit, GPGPU), a tensor processing unit (TensorProcessing Unit, TPU), etc.
[0026] The multiple verification moments of the firmware to be verified can be understood as multiple specific time points for verifying the firmware to be verified. For example, the verification moment can be when the chip is started, at a regular inspection time, or when a specific event occurs.
[0027] It should be noted that the verification time of different firmwares to be verified may be different, so as to avoid the problem that the verification time of other firmwares to be verified is leaked after the verification time of any firmware to be verified is illegally obtained. In addition, the verification time corresponding to the same firmware to be verified at each chip startup may also be different, so as to avoid the problem that the verification time corresponding to the same firmware to be verified at any time when the chip is started is illegally obtained, which leads to the leakage of the verification time corresponding to other times when the chip is started.
[0028] In addition, the embodiment of the present invention determines multiple verification moments of the firmware to be verified, that is, the embodiment of the present invention does not verify the firmware to be verified only once, but performs multiple verifications, and at least one verification moment is during the operation of the chip, thereby avoiding the security risks caused by the firmware to be verified being illegally tampered with when the chip is running.
[0029] Step 120: At each verification time, determine the calculated hash value of the firmware to be verified at each verification time.
[0030] Usually, when the chip is started, the firmware to be verified will be loaded into the memory. At the verification moment, the data of the firmware to be verified can be read from the memory, and the calculated hash value at the corresponding verification moment can be calculated based on the read data. Optionally, a hash algorithm (such as SHA-256, SHA-3, etc.) can be used for hash calculation.
[0031] Among them, the calculated hash value at each verification time is used to represent the data information of the firmware to be verified stored in the memory at each verification time. That is, if the data of the firmware to be verified stored in the memory is tampered with, the tampered content will be reflected in the calculated hash value.
[0032] As an optional embodiment, the verification time may include the startup time (i.e., performing firmware verification when the chip is started), the periodic verification time (i.e., performing firmware verification periodically during chip operation), the event triggering time (i.e., performing firmware verification when a specific event occurs), the manual verification time (i.e., performing firmware verification manually during maintenance or updating), etc.
[0033] Step 130: Compare the calculated hash value at each verification time with the legal hash value of the firmware to be verified, and determine the verification result of the firmware to be verified at each verification time.
[0034] Specifically, the legal hash value refers to the hash value of the firmware to be verified in a state that is considered not to have been tampered with. The calculated hash value at each verification time is compared with the legal hash value of the firmware to be verified to determine the verification result of the firmware to be verified at each verification time. Among them, the verification result at each verification time is used to indicate whether the data of the firmware to be verified at each verification time has been tampered with.
[0035] If the calculated hash value at any verification time is inconsistent with the legal hash value, it indicates that the firmware to be verified at any verification time has been tampered with, that is, there is a security risk in the firmware to be verified. If the calculated hash value at any verification time is consistent with the legal hash value, it indicates that the firmware to be verified at any verification time has not been tampered with, that is, the data of the firmware to be verified is complete and reliable data.
[0036] Optionally, the calculated hash value at each verification moment can be compared with the legal hash value of the firmware to be verified in the security core of the chip, thereby ensuring that the verification process is carried out in a protected environment and is difficult to be interfered with by external malicious code.
[0037] The chip firmware verification method provided by the embodiment of the present invention determines multiple verification moments of the firmware to be verified, that is, the embodiment of the present invention does not verify the firmware to be verified only once, but performs multiple verifications, and at least one verification moment is during the operation of the chip, thereby avoiding the security risks caused by the firmware to be verified being illegally tampered with when the chip is running.
[0038] Based on the above embodiment, the period of the verification time is determined based on a random number each time the chip is started.
[0039] Specifically, the period of the verification moment can be understood as the verification time interval of the chip to be verified, that is, the chip to be verified can be verified regularly.
[0040] Optionally, each time the chip is started, a random number is obtained, and a corresponding verification time period is generated based on the random number. The timing watchdog of the security core initiates polling according to the verification time period, thereby realizing the timed verification of the firmware to be verified.
[0041] It should be noted that since the period of the verification moment is determined based on a random number each time the chip is started, and the random number corresponding to each time the chip is started may be different, the period of the verification moment corresponding to each time the chip is started is different, that is, the verification moment corresponding to each time the chip is started is random, and it is difficult for an attacker to predict the next verification time of the firmware to be verified, thereby increasing the difficulty of bypassing the verification and further improving the security of the firmware to be verified.
[0042] Based on any of the above embodiments, the time to be verified is determined based on the task type corresponding to the firmware to be verified.
[0043] Optionally, the task priority can be determined based on the task type corresponding to the firmware to be verified, and the time to be verified can be determined according to the task priority. For example, critical tasks (such as safety-related functions) may require more frequent verification (not only verifying the firmware at startup, but also periodically verifying during chip operation to improve safety), while non-critical tasks may require less frequent verification.
[0044] Optionally, task characteristics (such as processing speed, data sensitivity) may be determined based on the task type corresponding to the firmware to be verified, and the time to be verified may be determined based on the task characteristics. For example, a task that processes sensitive data may need to be verified immediately at each startup to ensure the integrity of the firmware.
[0045] Optionally, the verification time can be dynamically adjusted according to the system load and task type. For example, more frequent verification can be performed when the system load is low, while the verification frequency can be reduced during peak load periods to balance system performance and security, thereby ensuring that the verification process can protect the integrity of the system without having an excessive impact on system performance.
[0046] It can be seen that the embodiment of the present invention determines the verification time based on the task type of the firmware to be verified, which can improve the security and performance of the system.
[0047] Based on any of the above embodiments, the time to be verified is determined based on the importance of the firmware to be verified.
[0048] Optionally, based on the importance of the firmware, the firmware can be divided into two categories: critical firmware and auxiliary firmware. Critical firmware refers to firmware related to the core functions or security of the system (such as the operating system kernel, security module, etc.), and auxiliary firmware refers to firmware with less impact on system functions (such as drivers or applications, etc.).
[0049] For critical firmware, which directly affects the security and stability of the system, it needs to be checked first, and a higher check frequency can be set. For auxiliary firmware, which has a relatively small impact on system functions, a lower check frequency can be set.
[0050] Based on any of the above embodiments, the legal hash value is a hash value that passes the signature verification when the firmware to be verified is started, and the legal hash value is stored in the security core of the chip.
[0051] Specifically, the legal hash value is pre-stored in the security core of the chip. The security core provides an isolated and protected environment to prevent illegal access and tampering, thereby protecting the legal hash value from being modified or misused. The legal hash value is the hash value that passes the signature verification when the firmware to be verified is started, that is, the legal hash value is the hash value corresponding to the data of the firmware to be verified when it is intact and has not been tampered with. If the calculated hash value is consistent with the legal hash value, it indicates that the firmware to be verified has not been tampered with; if the calculated hash value is inconsistent with the legal hash value, it indicates that the firmware to be verified has been tampered with.
[0052] Based on any of the above embodiments, determining the verification result of the firmware to be verified at each verification time, and then further comprising: If the verification result of the firmware to be verified at any verification time is that there is a security risk, the chip is stopped from running.
[0053] Specifically, at any verification moment, if the verification result of the firmware to be verified shows that there is a security risk, the operation of the firmware will be stopped immediately, thereby preventing potential security threats or vulnerabilities from causing further damage to the system and ensuring the security and stability of the system.
[0054] If the verification result of the firmware to be verified at any verification time is that there is no security risk, it means that there is no security threat or vulnerability in the firmware to be verified, and the chip can continue to run.
[0055] Figure 2 This is the second flow chart of the chip firmware verification method provided by the present invention, such as Figure 2 As shown, the method includes: After the chip is initialized, the chip is started. The firmware to be verified is verified in the security core of the chip, and the hash value that passes the verification is stored in the security core as a legal hash value.
[0056] During the operation of the chip, multiple verification moments of the firmware to be verified are determined according to the verification strategy of the firmware to be verified, and the calculated hash value of the firmware to be verified is determined at each verification moment. The calculated hash value is compared with the legal hash value in the security core. If they are consistent, the verification passes, and the chip continues to run. If they are inconsistent, the verification fails, the chip stops running and an error is reported.
[0057] The chip firmware verification method provided by the embodiment of the present invention determines multiple verification moments of the firmware to be verified, that is, the embodiment of the present invention does not verify the firmware to be verified only once, but performs multiple verifications, and at least one verification moment is during the operation of the chip, thereby avoiding increasing the difficulty for attackers to evade detection when the chip is running, further improving the protection capability of the firmware to be verified when the chip is running, and avoiding the security risks brought about by illegal tampering of the firmware to be verified.
[0058] The chip firmware verification device provided by the present invention is described below. The chip firmware verification device described below and the chip firmware verification method described above can be referenced to each other.
[0059] Based on any of the above embodiments, Figure 3 is a schematic diagram of the structure of the chip firmware verification device provided by the present invention, such as Figure 3 As shown, the device comprises: The determination unit 310 is used to determine a plurality of verification moments of the firmware to be verified in the chip, at least one of which is during the operation of the chip; The calculation unit 320 is used to determine the calculated hash value of the firmware to be verified at each verification time. The verification unit 330 is used to compare the calculated hash value at each verification time with the legal hash value of the firmware to be verified, and determine the verification result of the firmware to be verified at each verification time.
[0060] The chip firmware verification device provided by the embodiment of the present invention determines multiple verification moments of the firmware to be verified, that is, the embodiment of the present invention does not verify the firmware to be verified only once, but performs multiple verifications, and at least one verification moment is during the operation of the chip, thereby avoiding increasing the difficulty for attackers to evade detection when the chip is running, further improving the protection capability of the firmware to be verified when the chip is running, and avoiding the security risks brought about by illegal tampering of the firmware to be verified.
[0061] Based on any of the above embodiments, the period of the verification moment is determined based on a random number each time the chip is started.
[0062] Based on any of the above embodiments, the time to be verified is determined based on the task type corresponding to the firmware to be verified.
[0063] Based on any of the above embodiments, the time to be verified is determined based on the importance of the firmware to be verified.
[0064] Based on any of the above embodiments, the legal hash value is a hash value that passes the signature verification when the firmware to be verified is started, and the legal hash value is stored in the security core of the chip.
[0065] Based on any of the above embodiments, determining the verification result of the firmware to be verified at each verification time, and then further comprising: If the verification result of the firmware to be verified at any verification time is that there is a security risk, the chip is stopped from running.
[0066] Figure 4 is a schematic diagram of the structure of the electronic device provided by the present invention, such as Figure 4 As shown, the electronic device may include: a processor 410, a communication interface 420, a memory 430 and a communication bus 440, wherein the processor 410, the communication interface 420 and the memory 430 communicate with each other through the communication bus 440. The processor 410 may call the logic instructions in the memory 430 to execute the chip firmware verification method, which includes: determining multiple verification moments of the firmware to be verified in the chip, at least one verification moment is during the operation of the chip; at each verification moment, determining the calculated hash value of the firmware to be verified at each verification moment; comparing the calculated hash value at each verification moment with the legal hash value of the firmware to be verified, and determining the verification result of the firmware to be verified at each verification moment.
[0067] In addition, the logic instructions in the above-mentioned memory 430 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the relevant technology or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.
[0068] On the other hand, the present invention also provides a computer program product, which includes a computer program. The computer program can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the chip firmware verification method provided by the above methods, and the method includes: determining multiple verification moments of the firmware to be verified in the chip, at least one verification moment is during the operation of the chip; at each verification moment, determining the calculated hash value of the firmware to be verified at each verification moment; comparing the calculated hash value at each verification moment with the legal hash value of the firmware to be verified, and determining the verification result of the firmware to be verified at each verification moment.
[0069] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, it is implemented to execute the chip firmware verification method provided by the above-mentioned methods, the method comprising: determining multiple verification moments of the firmware to be verified in the chip, at least one verification moment being during the operation of the chip; at each verification moment, determining the calculated hash value of the firmware to be verified at each verification moment; comparing the calculated hash value at each verification moment with the legal hash value of the firmware to be verified, and determining the verification result of the firmware to be verified at each verification moment.
[0070] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0071] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the relevant technology can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiment.
[0072] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A chip firmware verification method, characterized in that: include: Determine multiple verification moments of firmware to be verified in the chip, at least one of which is during the operation of the chip; At each verification time, determining a calculated hash value of the firmware to be verified at each verification time; Compare the calculated hash value at each verification time with the legal hash value of the firmware to be verified to determine the verification result of the firmware to be verified at each verification time.
2. The chip firmware verification method according to claim 1, characterized in that: The period of the verification moment is determined based on a random number each time the chip is started.
3. The chip firmware verification method according to claim 1, characterized in that: The time to be verified is determined based on the task type corresponding to the firmware to be verified.
4. The chip firmware verification method according to claim 1, characterized in that: The time to be verified is determined based on the importance of the firmware to be verified.
5. The chip firmware verification method according to claim 1, characterized in that: The legal hash value is a hash value that passes the signature verification when the firmware to be verified is started, and the legal hash value is stored in the security core of the chip.
6. The chip firmware verification method according to claim 1, characterized in that: The step of determining the verification result of the firmware to be verified at each verification time further includes: When the verification result of the firmware to be verified at any verification time is that there is a security risk, the chip is stopped from running.
7. A chip firmware verification device, characterized in that: include: A determination unit, used to determine a plurality of verification moments of the firmware to be verified in the chip, at least one of which is during the operation of the chip; A calculation unit, used to determine, at each verification moment, a calculated hash value of the firmware to be verified at each verification moment; The verification unit is used to compare the calculated hash value at each verification time with the legal hash value of the firmware to be verified, and determine the verification result of the firmware to be verified at each verification time.
8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the chip firmware verification method according to any one of claims 1 to 6 is implemented.
9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the chip firmware verification method according to any one of claims 1 to 6 is implemented.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the chip firmware verification method according to any one of claims 1 to 6 is implemented.
