Secure starting system for firmware and related method

By encrypting the firmware on the electronic device side and decrypting it before the chip starts, the problem of the firmware being easily maliciously damaged is solved, achieving safe and efficient firmware startup and data protection.

CN119830362AActive Publication Date: 2025-04-15HONOR DEVICE CO LTD
View PDF 7 Cites 0 Cited by

Patent Information

Application Number
CN202311304814.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-10-08
Publication Date
2025-04-15
Estimated Expiration
2043-10-08

AI Technical Summary

Technical Problem

In the prior art, firmware in electronic devices is susceptible to malicious damage, resulting in the firmware being unable to operate, the chip function is damaged, and even data leakage in the chip.

Method used

By encrypting part of the firmware data on the electronic device side, the encrypted firmware is generated, and the encrypted firmware is decrypted before the chip starts up, to achieve a safe and efficient firmware startup.

Benefits of technology

It improves the security of the firmware, ensures the normal operation of chip functions, avoids data leakage in chips, and improves the speed and efficiency of encryption and decryption.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119830362A_ABST
    Figure CN119830362A_ABST
Patent Text Reader

Abstract

The invention provides a secure startup system for firmware and a related method.The secure startup system for firmware comprises an electronic device and a chip; the electronic equipment is used for encrypting part of data in firmware to obtain encrypted firmware; under the condition that the firmware in the chip meets a preset downloading condition, sending the encrypted firmware to the chip; the chip is used for receiving encrypted firmware sent by the electronic equipment; the encrypted firmware is decrypted, and the decrypted firmware is obtained; and starting the decrypted firmware. By implementing the embodiment of the invention, the firmware can be safely and efficiently started, and the firmware is prevented from being maliciously damaged.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the field of terminal technology, and more particularly to a secure boot system for firmware and related methods. Background Art

[0002] During the startup process of the chip, the corresponding firmware is usually loaded from the electronic device outside the chip (the firmware can be a basic operating software of a chip, which can be upgraded through a specific refresh program). After the firmware is loaded, the chip can jump to the main function of the firmware (for example: main function) to start executing the firmware's operating process.

[0003] However, the firmware in electronic devices is currently vulnerable to malicious damage, for example: implanting other third-party programs in the firmware to maliciously obtain user information or operating data in the chip; for example: destroying the operating logic of the firmware, making the firmware unable to operate normally, causing the chip to have functional errors and unable to work normally.

[0004] Therefore, how to implement safe and efficient boot firmware is an urgent problem to be solved. Summary of the invention

[0005] The present application provides a secure boot system and related methods for firmware, which can safely and efficiently boot the firmware and prevent the firmware from being maliciously damaged.

[0006] In a first aspect, an embodiment of the present application provides a secure boot system for firmware, the system comprising: an electronic device and a chip;

[0007] The electronic device is used to: encrypt part of the data in the firmware to obtain the encrypted firmware; and send the encrypted firmware to the chip when the firmware in the chip meets the preset download condition;

[0008] The chip is used for: receiving the encrypted firmware sent by the electronic device; decrypting the encrypted firmware to obtain the decrypted firmware; and starting the decrypted firmware.

[0009] In the prior art, the firmware in the electronic device is easily subject to malicious damage, causing the firmware to be unable to run, the chip function to be damaged, and even the data in the chip to be leaked. In this regard, the embodiment of the present application provides a secure boot system for firmware, which can safely and efficiently boot the firmware, ensure the normal function of the chip, and avoid data leakage in the chip. Among them, the secure boot system for firmware includes an electronic device and a chip. Specifically, the electronic device can be used to: encrypt part of the data in the firmware to obtain the encrypted firmware; when the firmware in the chip meets the preset download conditions, send the encrypted firmware to the chip. When the firmware in the chip meets the preset download conditions (that is, the firmware in the chip needs to be updated, downloaded, upgraded or burned), the encrypted firmware sent by the electronic device can be received, the encrypted firmware is decrypted, and the decrypted firmware is obtained; after the decrypted firmware is decrypted, the decrypted firmware can be started to implement the corresponding function. By encrypting the firmware on the electronic device side and decrypting the encrypted firmware before the chip is started, the security of the firmware can be greatly improved, the chip function can be guaranteed to be normal, and data leakage in the chip can be avoided. Moreover, encrypting and decrypting part of the data in the firmware can not only help to increase the speed of encryption and decryption, reduce the time of encryption and decryption, and improve the efficiency of firmware secure boot, but also increase the cost of cracking the encrypted firmware, further improving the security of the firmware.

[0010] In one possible implementation, the electronic device is specifically used to: randomly sample the firmware to obtain first random data in the firmware; based on a preset encryption rule and the first random data, obtain encrypted data corresponding to the first random data; replace the first random data in the firmware with the encrypted data to obtain the encrypted firmware.

[0011] In an embodiment of the present application, the electronic device can randomly sample the firmware to obtain the first random data in the firmware, and the first random data can be a randomly determined part of the data in the firmware. Then the electronic device can encrypt the first random data based on a preset encryption rule to obtain the encrypted data corresponding to the first random data. After the encryption is completed, the electronic device can replace the first random data in the firmware with the encrypted data to obtain the encrypted firmware. This method of determining the first random data by random sampling and then encrypting it can greatly improve the security of the encrypted firmware and reduce the probability of the firmware being started after being implanted into other programs.

[0012] In one possible implementation, the electronic device is specifically used to: when the firmware in the chip meets the preset download condition, send firmware information to the chip, the firmware information including header information and the encrypted firmware, the header information including the location information, and the location information is used to indicate the location of the encrypted data in the firmware.

[0013] In an embodiment of the present application, the electronic device sends the location information indicating the location of the encrypted data in the firmware together with the encrypted firmware to the chip, which helps the chip to quickly determine the encrypted data when decrypting the encrypted firmware, thereby increasing the decryption speed, reducing the decryption time, and improving the efficiency of firmware secure booting.

[0014] In one possible implementation, the electronic device is specifically used to: obtain current version information corresponding to the firmware in the chip; compare the current version information with target version information corresponding to the firmware in the electronic device, and when the current version information is inconsistent with the latest version information, determine that the firmware meets the preset download conditions.

[0015] In an embodiment of the present application, when the current version information is inconsistent with the latest version information, it indicates that the firmware in the chip needs to be updated, upgraded or downloaded, that is, the firmware meets the preset download conditions. At this time, the electronic device can send the encrypted firmware to the chip in order to update, upgrade or download the corresponding firmware.

[0016] In one possible implementation, the electronic device is also used to: encrypt part of the data in the firmware and before obtaining the encrypted firmware, obtain the first verification code corresponding to the firmware based on a preset integrity verification rule, and the first verification code is used to verify the integrity of the firmware.

[0017] In an embodiment of the present application, in order to prevent a third party from inferring the encryption method in the firmware and the location of the encrypted data in the firmware, the firmware is integrity checked using a first verification code to increase the probability of secure firmware startup and further reduce the risk of the firmware being started after being damaged.

[0018] In one possible implementation, the chip is specifically used to: receive the firmware information sent by the electronic device; determine the encrypted data from the encrypted firmware based on the location information in the header information; decrypt the encrypted firmware based on the encrypted data and the preset decryption rules to obtain the decrypted firmware.

[0019] In an embodiment of the present application, the chip determines the encrypted data from the encrypted firmware based on the location information carried by the header information in the firmware information sent by the electronic device; and then decrypts the encrypted firmware based on the encrypted data. By carrying the location information of the encrypted data in the firmware information, the chip can quickly determine the encrypted data when decrypting the encrypted firmware, thereby increasing the speed of decryption, reducing the time of decryption, and improving the efficiency of firmware secure booting.

[0020] In one possible implementation, the chip is specifically used to: decrypt the encrypted data in the encrypted firmware based on preset decryption rules to obtain second random data; replace the encrypted data in the encrypted firmware with the second random data to obtain the decrypted firmware.

[0021] In the embodiment of the present application, the chip can decrypt the encrypted data in the encrypted firmware based on a preset decryption rule to obtain second random data, which is the data obtained after the encrypted data is decrypted, and replace the encrypted data in the encrypted firmware with the second random data to obtain the decrypted firmware. This decryption method can increase the speed of decryption, reduce the time of decryption, and improve the efficiency of firmware secure booting.

[0022] In one possible implementation, the firmware information also includes the first verification code; the chip is also used to: obtain a second verification code corresponding to the decrypted firmware based on the preset integrity verification rule; compare the first verification code and the second verification code, and when the second verification code is consistent with the first verification code, start the decrypted firmware.

[0023] In the embodiment of the present application, in order to prevent a third party from inferring the encryption method in the firmware and the location of the encrypted data in the firmware, the firmware is decrypted and integrity checked to increase the probability of secure booting of the firmware and further reduce the risk of the firmware being started after being damaged. When the second check code is consistent with the first check code, it can be determined that the decrypted firmware has passed the integrity check and can be started.

[0024] In a second aspect, an embodiment of the present application provides a secure boot method for firmware, which is applied to a secure boot system, wherein the secure boot system includes an electronic device and a chip; the method includes:

[0025] Encrypting part of the data in the firmware by the electronic device to obtain the encrypted firmware; sending the encrypted firmware to the chip when the firmware in the chip meets the preset download condition;

[0026] The encrypted firmware sent by the electronic device is received through the chip; the encrypted firmware is decrypted to obtain the decrypted firmware; and the decrypted firmware is started.

[0027] In one possible implementation, encrypting part of the data in the firmware by the electronic device to obtain the encrypted firmware includes: randomly sampling the firmware by the electronic device to obtain first random data in the firmware; based on a preset encryption rule and the first random data, obtaining encrypted data corresponding to the first random data; replacing the first random data in the firmware with the encrypted data to obtain the encrypted firmware.

[0028] In one possible implementation, when the firmware in the chip meets a preset download condition, sending encrypted firmware to the chip includes: when the firmware in the chip meets the preset download condition, sending firmware information to the chip, the firmware information including header information and the encrypted firmware, the header information including the location information, and the location information is used to indicate the location of the encrypted data in the firmware.

[0029] In one possible implementation, the method also includes: obtaining, through the electronic device, current version information corresponding to the firmware in the chip; comparing the current version information with the target version information corresponding to the firmware in the electronic device, and when the current version information is inconsistent with the latest version information, determining that the firmware meets the preset download conditions.

[0030] In one possible implementation, before encrypting part of the data in the firmware to obtain the encrypted firmware, the method further includes: obtaining, through the electronic device based on a preset integrity verification rule, the first verification code corresponding to the firmware, wherein the first verification code is used to verify the integrity of the firmware.

[0031] In one possible implementation, decrypting the encrypted firmware to obtain the decrypted firmware includes: receiving the firmware information sent by the electronic device; determining the encrypted data from the encrypted firmware based on the location information in the header information; and decrypting the encrypted firmware based on the encrypted data and the preset decryption rule to obtain the decrypted firmware.

[0032] In one possible implementation, the encrypted firmware is decrypted based on the encrypted data and the preset decryption rule to obtain the decrypted firmware, including: decrypting the encrypted data in the encrypted firmware based on the preset decryption rule to obtain second random data; replacing the encrypted data in the encrypted firmware with the second random data to obtain the decrypted firmware.

[0033] In one possible implementation, the firmware information also includes the first verification code; the method also includes: obtaining, through the chip based on the preset integrity verification rule, a second verification code corresponding to the decrypted firmware; comparing the first verification code and the second verification code, and when the second verification code is consistent with the first verification code, starting the decrypted firmware.

[0034] In a third aspect, an embodiment of the present application provides an encryption method for secure booting of firmware, characterized in that the method includes: randomly sampling the firmware to obtain first random data in the firmware, where the first random data is part of the data in the firmware; based on a preset encryption rule and the first random data, obtaining encrypted data corresponding to the first random data; replacing the first random data in the firmware with the encrypted data to obtain the encrypted firmware.

[0035] In a fourth aspect, an embodiment of the present application provides a decryption method for secure booting of firmware, characterized in that the method includes: obtaining an encrypted firmware; determining the encrypted data in the encrypted firmware; based on the encrypted data and the preset decryption rules, decrypting the encrypted data in the encrypted firmware to obtain second random data; replacing the encrypted data in the encrypted firmware with the second random data to obtain decrypted firmware.

[0036] In a fifth aspect, an embodiment of the present application provides an electronic device, which includes one or more processors and one or more memories; wherein the one or more memories are coupled to the one or more processors, and the one or more memories are used to store computer program codes, and the computer program codes include computer instructions, and when the one or more processors execute the computer instructions, the electronic device executes the encryption method for firmware secure boot as in the third aspect.

[0037] In a sixth aspect, a chip is provided, characterized in that the chip comprises a logic circuit, and the logic circuit is used to support the chip to implement the decryption method for firmware secure boot as in the fourth aspect above.

[0038] In a seventh aspect, the present application provides a computer storage medium comprising computer instructions, which, when executed on an electronic device, enables the electronic device to execute a method in any possible implementation of the third aspect or the fourth aspect.

[0039] In an eighth aspect, the present application provides a computer program product, which, when executed on a computer, enables the computer to execute a method in any possible implementation of the third aspect or the fourth aspect.

[0040] It is understandable that the methods provided in the second to fourth aspects, the electronic device provided in the fifth aspect, the chip provided in the sixth aspect, the computer-readable storage medium provided in the seventh aspect, and the computer program product provided in the eighth aspect are all used to implement the secure boot system for firmware provided in the embodiment of the present application. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects involved in the corresponding first aspect, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0041] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the background technology, the drawings required for use in the embodiments of the present application or the background technology will be described below.

[0042] Figure 1 It is a set of application scenario schematic diagrams provided by the embodiments of the present application.

[0043] Figure 2 It is a schematic diagram of a secure boot system architecture for firmware provided in an embodiment of the present application.

[0044] Figure 3 It is a schematic diagram of encrypting part of the firmware data provided by an embodiment of the present application.

[0045] Figure 4 It is a structural diagram of firmware information provided in an embodiment of the present application.

[0046] Figure 5 It is a flowchart of an encryption method for firmware secure booting provided in an embodiment of the present application.

[0047] Figure 6 It is a flowchart of a decryption method for firmware secure booting provided in an embodiment of the present application. DETAILED DESCRIPTION

[0048] The technical solutions in the embodiments of the present application will be described clearly and in detail below with reference to the accompanying drawings.

[0049] The terms "first" and "second" and the like in the specification and claims of the present application and the drawings are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device comprising a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to these processes, methods, products or devices.

[0050] It should be understood that in the present application, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.

[0051] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.

[0052] The terms "component", "module", "system", etc. used in this specification are used to represent computer-related entities, hardware, firmware, a combination of hardware and software, software, or software in execution. For example, a component can be, but is not limited to, a process running on a processor, a processor, an object, an executable file, an execution thread, a program and / or a computer. By way of illustration, both applications running on a computing device and a computing device can be components. One or more components may reside in a process and / or an execution thread, and a component may be located on a computer and / or distributed between two or more computers. In addition, these components may be executed from various computer-readable media having various data structures stored thereon. Components may, for example, communicate through local and / or remote processes according to signals having one or more data packets (e.g., data from two components interacting with another component between a local system, a distributed system and / or a network, such as the Internet interacting with other systems through signals).

[0053] To facilitate understanding of the embodiments of the present application, the application scenarios involved in the embodiments of the present application are analyzed in detail below, especially the scenario of securely starting the firmware when the chip downloads or upgrades the firmware.

[0054] Please refer to the attached Figure 1 , Figure 1 It is a set of application scenario schematic diagrams provided by the embodiments of the present application.

[0055] In some application scenarios, the chip can securely boot the firmware after upgrading or updating it. For example, current electronic devices can all be equipped with corresponding chips, which can provide data processing related functions to the electronic devices based on the firmware in the chip. The firmware in the chip can be updated or upgraded by the electronic device. After the chip updates or upgrades the firmware, it can securely boot the firmware to run the functions corresponding to the firmware.

[0056] For example, the electronic device may be Figure 1 The laptop computer and mobile phone shown in the figure may also be a portable electronic device, a tablet computer, a wearable electronic device with wireless communication function (such as a smart watch), etc. Exemplary embodiments of portable electronic devices include but are not limited to Or a portable electronic device with other operating systems. The portable electronic device may also be other portable electronic devices, such as a laptop computer with a touch-sensitive surface or a touch panel. It should also be understood that in some other embodiments, the electronic device may not be a portable electronic device, but a desktop computer, a car computer, etc. with a touch-sensitive surface or a touch panel.

[0057] In other application scenarios, the chip can perform a secure boot after downloading the initial firmware. For example, the chip is set before the above electronic device, and another electronic device is required to burn the firmware on the chip. After the chip is burned, the firmware in the burned chip can be securely booted to ensure the basic operating functions of the chip. The electronic device used to burn the chip can be such as Figure 1 The host computer or burning machine shown is not specifically limited to this embodiment of the present application.

[0058] In other application scenarios, the chip can securely boot the firmware stored in the chip's internal memory. For example, the firmware obtained by the chip from the electronic device can be stored in the flash memory in the chip. During operation, the chip can directly obtain the corresponding firmware from the flash memory for secure booting.

[0059] It should be noted that the three different scenarios shown above are only illustrative and all involve secure boot scenarios implemented by firmware in a chip, and should not constitute limitations on the embodiments of the present application.

[0060] Based on the application scenarios proposed above and to facilitate understanding of the embodiments of the present application, the following first describes a secure boot system architecture for firmware based on the embodiments of the present application.

[0061] Please refer to the attached Figure 2 , Figure 2 Schematic diagram of a secure boot system architecture for firmware provided by an embodiment of the present application. Figure 2 As shown, the secure boot system for firmware includes an electronic device (host) and a chip.

[0062] The electronic device may be the above-mentioned Figure 1 Any electronic device in the embodiments shown. The electronic device may include one or more firmwares, each of which may also run in a chip corresponding to the electronic device. Figure 2 As shown, the current firmware is easily subject to malicious damage on the electronic device side, for example: implanting other programs in the firmware, which may obtain user information or operating data in the chip when running in the chip; another example: destroying the operating logic of the firmware, making it unable to run normally in the chip, causing functional errors in the chip and unable to work normally. Therefore, in order to ensure that the firmware can run normally after being downloaded, the electronic device can encrypt one or more firmwares to improve the security of firmware startup and reduce the risk of malicious damage.

[0063] Exemplarily, the electronic device can be used to: encrypt part of the data in the firmware to obtain the encrypted firmware; and send the encrypted firmware to the chip when the firmware in the chip meets the preset download conditions. After the electronic device encrypts the firmware, it can be stored in the electronic device first, and after determining that the firmware in the chip meets the preset download conditions, the encrypted firmware is sent to the chip to reduce the risk of the chip running being damaged or maliciously implanted with other codes.

[0064] For example, please refer to the attached Figure 3 , Figure 3 FIG. 1 is a schematic diagram of encrypting part of the firmware data provided by an embodiment of the present application. Figure 3 As shown, the electronic device can encrypt part of the data in the firmware to obtain the encrypted firmware. It can be understood that the part of the data can be any part of the data in the firmware, the part of the data in the firmware can be a continuous piece of data or a plurality of scattered pieces of data, and the acquisition method of the part of the data in the firmware can be random acquisition or acquisition according to corresponding acquisition rules.

[0065] In some embodiments, the embodiments of the present application do not specifically limit the size of the partial data or the proportion of the partial data in the entire firmware data. For example, the partial data in the firmware can be a random portion of data obtained from data of a preset threshold size as the encrypted partial data in the firmware, such as the above Figure 3 As shown, the partial data in the firmware is 1 byte of data randomly obtained for every 1 KB of data as the encrypted partial data. Exemplarily: the partial data in the firmware can also be data of a preset threshold size (such as: initial data 10 bytes, intermediate data 200 bytes, last data 1KB, etc.) at a preset position in the firmware as the encrypted partial data. Exemplarily: the partial data in the firmware can also be data of any preset proportion (such as: 30%, 20%, etc.) of the total data of the firmware as the encrypted partial data.

[0066] It should be noted that the higher the proportion of some data in the firmware in the total firmware data, the more dispersed the distribution, the higher the security of the firmware after encryption, but at the same time, the longer the encryption time. In the case of the same proportion, the more dispersed the some data in the firmware, the higher the security of the firmware after encryption, but at the same time, the longer the encryption time.

[0067] It should also be noted that encrypting part of the data in the firmware is more secure than encrypting all the data in the firmware. For example, after a third party obtains the encryption method of an electronic device, the third party can really replace all the data in the firmware, but if part of the firmware data is encrypted, even if the third party obtains the encryption method of the electronic device, it still cannot replace or decrypt the firmware without obtaining the encrypted data of the firmware part.

[0068] The chip can be any integrated circuit that can run firmware, for example, an integrated circuit chip, a memory chip, etc. Exemplarily, the chip can send the download request for the firmware to the electronic device when the firmware needs to be updated, downloaded, upgraded or burned, and the download request is used to request firmware update, download, upgrade or burn. After receiving the encrypted firmware sent by the electronic device, the encrypted firmware is decrypted to obtain the decrypted firmware; after the decrypted firmware is decrypted, the decrypted firmware can be started to implement the corresponding function.

[0069] Among them, it can be understood that when the chip decrypts the encrypted firmware, the decryption method used corresponds to the encryption method of the firmware in the electronic device, and the chip only needs to decrypt part of the data in the firmware during the decryption process, which can greatly reduce the time consumption of firmware decryption, while also taking into account the security of firmware startup, so that the maliciously damaged firmware cannot be successfully decrypted and run. In the case of decryption failure or error, it means that the firmware has been maliciously damaged, and the chip can not run the decrypted firmware.

[0070] In some embodiments, as described above Figure 2As shown, the chip may include a logic circuit (boot), a random access memory (RAM) and a flash memory. Among them, the logic circuit is a hardware circuit composed of a direct or indirect combination of an AND gate, a NOT gate and an OR gate, etc., which can be used to implement the corresponding operation logic or program. For example, the firmware can be understood as a program code solidified inside the integrated circuit, and the logic circuit is responsible for running the firmware to control and coordinate the functions of the integrated circuit. For another example, the logic circuit can decrypt and run the encrypted firmware. Among them, it should be noted that the logic running in the logic circuit can also be stored in the chip's electrically erasable programmable read only memory (Electrically Erasable Programmable Read Only Memory, EEPROM). In addition, the flash memory is a long-life non-volatile memory (which can still maintain the stored data information in the case of power failure), which can be used to receive and save the encrypted firmware obtained from the electronic device. For example, the encrypted firmware sent by the electronic device can be stored in the flash memory. The random access memory can be used to store the decrypted firmware, and can also be used to store the relevant data after the decrypted firmware is loaded or started, which is not specifically limited in the embodiments of the present application.

[0071] Exemplarily, in an embodiment of the present application, the logic circuit can be used to obtain the encrypted firmware sent by the electronic device from a flash memory, decrypt the encrypted firmware, obtain the decrypted firmware, and start the decrypted firmware to implement the corresponding functions of the firmware.

[0072] In some embodiments, the electronic device is specifically used to: obtain current version information corresponding to the firmware in the chip; compare the current version information with the target version information corresponding to the firmware in the electronic device, and when the current version information is inconsistent with the latest version information, determine that the firmware meets the preset download conditions.

[0073] It is understandable that the target version information can be the latest version information corresponding to the firmware in the electronic device. When the current version information of the firmware in the chip is inconsistent with the latest version information (i.e., the target version information), it means that the firmware in the chip needs to be updated, upgraded, downloaded, or burned, that is, the firmware meets the preset download conditions. At this time, the electronic device can send the encrypted firmware to the chip to update, upgrade, download, or burn the corresponding firmware. Among them, the version information can include one or more of the version number, firmware size, and firmware name corresponding to the firmware, and this embodiment of the application does not make specific limitations on this.

[0074] For example: when the current version information of the firmware in the chip is A, and the target version information of the firmware in the electronic device is B, and the two are inconsistent, it means that the firmware in the chip meets the preset download conditions, and the electronic device can send the encrypted firmware corresponding to the target version information to the chip. Another example: when the current version information of the firmware in the chip is empty (that is, when the firmware is not stored in the chip, the current version information corresponding to the firmware is empty), and the target version information of the firmware in the electronic device is A, and the two are inconsistent, it means that the firmware in the chip meets the preset download conditions, and the electronic device can send the encrypted firmware corresponding to the target version information to the chip.

[0075] In some embodiments, the electronic device is specifically used to: randomly sample the firmware to obtain first random data in the firmware; based on a preset encryption rule and the first random data, obtain encrypted data corresponding to the first random data; replace the first random data in the firmware with the encrypted data to obtain the encrypted firmware.

[0076] Among them, the electronic device can randomly sample the firmware to obtain the first random data in the firmware, and the first random data can be a randomly determined part of the data in the firmware. It should be noted that the size of the first random data after random sampling or the proportion of the total firmware data in the embodiment of the present application is not specifically limited. It should also be noted that in the embodiment of the present application, random sampling can be random sampling of all the data in the entire firmware, or random sampling of the data of each unit in the entire firmware (for example: randomly sampling 1KB of data for every 1M of data). Then the electronic device can encrypt the first random data based on the preset encryption rule to obtain the encrypted data corresponding to the first random data. It can be understood that the preset encryption rule can be the default security encryption rule in the electronic device (such as: SHA256 encryption method), or it can be a security encryption rule set by the user or set separately later (such as: encryption method of mapping relationship), which is not specifically limited in the embodiment of the present application. After the encryption is completed, the electronic device can replace the first random data in the firmware with the encrypted data to obtain the encrypted firmware. This method of determining the first random data by random sampling and then encrypting can greatly improve the security of the encrypted firmware and reduce the probability of the firmware being started after being implanted into other programs.

[0077] In some embodiments, the chip is specifically used to: decrypt the encrypted data in the encrypted firmware based on preset decryption rules to obtain second random data; replace the encrypted data in the encrypted firmware with the second random data to obtain the decrypted firmware.

[0078] Among them, it can be understood that the preset decryption rules of the chip correspond to the preset encryption rules in the electronic device. The chip can decrypt the encrypted data in the encrypted firmware based on the preset decryption rules to obtain the second random data, which is the data obtained after the encrypted data is decrypted, and replace the encrypted data in the encrypted firmware with the second random data to obtain the decrypted firmware. This decryption method can increase the speed of decryption, reduce the time of decryption, and improve the efficiency of firmware secure boot.

[0079] In some embodiments, the electronic device is specifically used to: when the firmware in the chip meets the preset download condition, send firmware information to the chip, the firmware information including header information and the encrypted firmware, the header information including the location information, and the location information is used to indicate the location of the encrypted data in the firmware.

[0080] Please refer to the attached Figure 4 , Figure 4 Schematic diagram of the structure of firmware information provided by the embodiment of the present application. Figure 4 As shown, the firmware information includes header information and the encrypted firmware. The header information includes the location information, and the location information is used to indicate the location of the encrypted data in the firmware, that is, to indicate the location of part of the data in the encrypted firmware. For example: Figure 4 As shown, the encrypted data has a total of mKB of data, wherein 1 byte of data is determined as part of the data to be encrypted in every n KB of data, and the position information in the header information can be used to indicate the position of the 1 byte of data in every n KB of data. The position of the 1 byte of data in every n KB of data can be the same or different, and the embodiment of the present application does not make specific limitations on this. Moreover, carrying the location information of the encrypted data in the firmware information can help the chip quickly determine the encrypted data when decrypting the encrypted firmware, thereby increasing the speed of decryption, reducing the time of decryption, and improving the efficiency of firmware secure boot.

[0081] In some embodiments, the chip is specifically used to: receive the firmware information sent by the electronic device; determine the encrypted data from the encrypted firmware based on the header information in the firmware information; and decrypt the encrypted firmware based on the encrypted data to obtain the decrypted firmware.

[0082] The chip is specifically used to receive the firmware information sent by the electronic device, and based on the location information carried by the header information in the firmware information, determine the encrypted data (such as the above-mentioned Figure 4The encrypted firmware is decrypted based on the encrypted data to obtain the decrypted firmware. By carrying the location information of the encrypted data in the firmware information, the chip can quickly determine the encrypted data when decrypting the encrypted firmware, thereby increasing the decryption speed, reducing the decryption time, and improving the efficiency of firmware secure booting.

[0083] In some embodiments, the electronic device is also used to: encrypt part of the data in the firmware and before obtaining the encrypted firmware, obtain the first verification code corresponding to the firmware based on a preset integrity verification rule, and the first verification code is used to verify the integrity of the firmware.

[0084] Before the electronic device encrypts the firmware, the electronic device can also be used to obtain the first verification code corresponding to the firmware based on a preset integrity verification rule, and the first verification code can be used together with the verification code corresponding to the decrypted firmware to implement integrity verification of the firmware. In order to prevent a third party from inferring the encryption method in the firmware and the location of the encrypted data in the firmware, the first verification code is used to increase the probability of secure startup of the firmware, and further reduce the risk of the firmware being started after being damaged.

[0085] In other embodiments, the firmware information also includes the first verification code; the chip is also used to: obtain a second verification code corresponding to the decrypted firmware based on the preset integrity verification rule; compare the first verification code and the second verification code, and when the second verification code is consistent with the first verification code, start the decrypted firmware.

[0086] For example, as mentioned above Figure 4 As shown, the firmware information also includes a first check code for verifying the integrity of the firmware. It is understandable that in order to prevent a third party from inferring the encryption method in the firmware and the location of the encrypted data in the firmware, the embodiment of the present application can also perform an integrity check on the firmware after decryption, for example: based on a preset integrity check rule, obtain the second check code corresponding to the decrypted firmware; compare the first check code and the second check code, and when the second check code is consistent with the first check code, start the decrypted firmware. Performing an integrity check can increase the probability of secure startup of the firmware and further reduce the risk of the firmware being started after being damaged. For example: a cyclic redundancy check (CRC) can be performed.

[0087] It is understandable that the chip performs an integrity check on the decrypted firmware based on the first check code, and starts the decrypted firmware after the check passes, that is, runs the decrypted firmware. In the case of failure to pass the check, the decrypted firmware is not started. Exemplarily, when the second check code is consistent with the first check code corresponding to the firmware before encryption, that is, it indicates that the firmware has not been tampered with, and it is determined that the firmware passes the integrity check, and a safe startup can be performed. When the second check code is inconsistent with the first check code corresponding to the firmware before encryption, it is determined that the firmware has not passed the integrity check, that is, it indicates that the firmware has been tampered with or maliciously damaged, and the startup of the decrypted firmware can be suspended to ensure the safe operation of the chip. This verification method cooperates with the encryption of part of the data in the firmware in the embodiment of the present application, which not only reduces the probability of a third party inferring the encryption method in the firmware and the position of the encrypted data in the firmware, but also prevents a third party from tampering with the encrypted data after inferring the encrypted data, which can further improve the probability of firmware safe startup and greatly reduce the risk of the firmware being started after being damaged.

[0088] In the prior art, the firmware in the electronic device is easily subject to malicious damage, causing the firmware to be unable to run, the chip function to be damaged, and even the data in the chip to be leaked. In this regard, the embodiment of the present application provides a secure boot system for firmware, which can safely and efficiently boot the firmware, ensure the normal function of the chip, and avoid data leakage in the chip. Among them, the secure boot system for firmware includes an electronic device and a chip. Specifically, the electronic device can be used to: encrypt part of the data in the firmware to obtain the encrypted firmware; when the firmware in the chip meets the preset download conditions, send the encrypted firmware to the chip. When the firmware in the chip meets the preset download conditions (that is, the firmware in the chip needs to be updated, downloaded, upgraded or burned), the encrypted firmware sent by the electronic device can be received, the encrypted firmware is decrypted, and the decrypted firmware is obtained; after the decrypted firmware is decrypted, the decrypted firmware can be started to implement the corresponding function. By encrypting the firmware on the electronic device side and decrypting the encrypted firmware before the chip is started, the security of the firmware can be greatly improved, the chip function can be guaranteed to be normal, and data leakage in the chip can be avoided. Moreover, encrypting and decrypting part of the data in the firmware can not only help to increase the speed of encryption and decryption, reduce the time of encryption and decryption, and improve the efficiency of firmware secure boot, but also increase the cost of cracking the encrypted firmware, further improving the security of the firmware.

[0089] Next, based on the above Figure 2-Figure 4 The system structure for firmware secure boot is shown, and an encryption method for firmware secure boot and a decryption method for firmware secure boot are introduced by way of example, and the technical problems raised in this application are specifically analyzed and solved.

[0090] The present application embodiment provides a secure boot method for firmware, which is applied to the above Figure 2-Figure 4 The system for firmware secure booting shown in the figure includes an electronic device and a chip; the method includes:

[0091] Encrypting part of the data in the firmware by the electronic device to obtain the encrypted firmware; sending the encrypted firmware to the chip when the firmware in the chip meets the preset download condition;

[0092] The encrypted firmware sent by the electronic device is received through the chip; the encrypted firmware is decrypted to obtain the decrypted firmware; and the decrypted firmware is started.

[0093] In some embodiments, encrypting part of the data in the firmware by the electronic device to obtain the encrypted firmware includes: randomly sampling the firmware by the electronic device to obtain first random data in the firmware; based on a preset encryption rule and the first random data, obtaining encrypted data corresponding to the first random data; replacing the first random data in the firmware with the encrypted data to obtain the encrypted firmware.

[0094] In some embodiments, when the firmware in the chip meets the preset download conditions, sending encrypted firmware to the chip includes: when the firmware in the chip meets the preset download conditions, sending firmware information to the chip, the firmware information including header information and the encrypted firmware, the header information including the location information, and the location information is used to indicate the location of the encrypted data in the firmware.

[0095] In some embodiments, the method also includes: obtaining, through the electronic device, current version information corresponding to the firmware in the chip; comparing the current version information with the target version information corresponding to the firmware in the electronic device, and when the current version information is inconsistent with the latest version information, determining that the firmware meets the preset download conditions.

[0096] In some embodiments, before encrypting part of the data in the firmware to obtain the encrypted firmware, the method also includes: obtaining, through the electronic device based on a preset integrity verification rule, the first verification code corresponding to the firmware, wherein the first verification code is used to verify the integrity of the firmware.

[0097] In some embodiments, decrypting the encrypted firmware to obtain the decrypted firmware includes: receiving the firmware information sent by the electronic device; determining the encrypted data from the encrypted firmware based on the location information in the header information; and decrypting the encrypted firmware based on the encrypted data and the preset decryption rules to obtain the decrypted firmware.

[0098] In some embodiments, decrypting the encrypted firmware based on the encrypted data and the preset decryption rules to obtain the decrypted firmware includes: decrypting the encrypted data in the encrypted firmware based on the preset decryption rules to obtain second random data; replacing the encrypted data in the encrypted firmware with the second random data to obtain the decrypted firmware.

[0099] In some embodiments, the firmware information also includes the first verification code; the method also includes: obtaining, through the chip based on the preset integrity verification rule, a second verification code corresponding to the decrypted firmware; comparing the first verification code and the second verification code, and when the second verification code is consistent with the first verification code, starting the decrypted firmware.

[0100] It should be noted that the relevant implementation methods in the method embodiments described in the embodiments of the present application can be found in the above Figure 2-Figure 4 The relevant description about the electronic device in the system architecture embodiment shown is not repeated here in the embodiment of the present application.

[0101] Based on the above Figure 2-Figure 4 The system structure for secure booting of firmware shown and the secure booting method for firmware described above are combined with the encryption method for secure booting of firmware provided in this application.

[0102] See also Figure 5 , Figure 5 This is a schematic diagram of a flow chart of an encryption method for firmware secure booting provided by an embodiment of the present application. Figure 5 The encryption method shown for firmware secure boot can be applied to the above Figure 2 In the electronic device described in, the specific description of each step is as follows:

[0103] Step S201: Obtain a first verification code corresponding to the firmware.

[0104] Specifically, the electronic device can be used to obtain a first check code corresponding to the firmware based on a preset integrity check rule (e.g., a preset check function) before encrypting the firmware, and the first check code is used to verify the integrity of the firmware. It is understandable that in order to prevent a third party from inferring the encryption method in the firmware and the location of the encrypted data in the firmware, the embodiment of the present application can also perform an integrity check on the firmware after decryption to increase the probability of secure startup of the firmware and further reduce the risk of the firmware being started after being damaged. For example: the first check code corresponding to the firmware can be obtained based on a cyclic redundancy check (CRC) rule.

[0105] Step S202: encrypt part of the data in the firmware to obtain the encrypted firmware.

[0106] Specifically, the electronic device may encrypt part of the data in the firmware to obtain the encrypted firmware. The part of the data in the firmware may be a continuous segment of data or a dispersed plurality of segments of data, and the acquisition method of the part of the data in the firmware may be random acquisition or acquisition according to corresponding acquisition rules. In addition, the size of the part of the data in the firmware or the proportion of the part of the data in the firmware is not specifically limited.

[0107] In some embodiments, the electronic device is specifically used to: randomly sample the firmware to obtain first random data in the firmware; based on a preset encryption rule and the first random data, obtain encrypted data corresponding to the first random data; replace the first random data in the firmware with the encrypted data to obtain the encrypted firmware.

[0108] Step S203: When the firmware in the chip meets the preset downloading conditions, the encrypted firmware is sent to the chip.

[0109] Specifically, the electronic device can send the encrypted firmware to the chip when the firmware in the chip meets the preset download conditions. Decrypting the encrypted firmware before the chip is started can greatly improve the security of the firmware, ensure the normal function of the chip, and avoid data leakage in the chip.

[0110] In some embodiments, the electronic device is specifically used to: when the firmware in the chip meets a preset download condition, send firmware information to the chip, the firmware information including header information and the encrypted firmware, the header information including the location information, and the location information is used to indicate the location of the encrypted data in the firmware.

[0111] In some other embodiments, the firmware information further includes a first verification code. The first verification code can be used to verify the integrity of the firmware to increase the probability of firmware secure startup and further reduce the risk of firmware being started after being damaged.

[0112] In some embodiments, the electronic device is specifically used to: obtain current version information corresponding to the firmware in the chip; compare the current version information with the target version information corresponding to the firmware in the electronic device, and when the current version information is inconsistent with the latest version information, determine that the firmware meets the preset download conditions.

[0113] It should be noted that the description of steps S201 to S203 in the method embodiment described in the embodiment of the present application can be found in the above Figure 2-Figure 4 The relevant description about the electronic device in the system architecture embodiment shown is not repeated here in the embodiment of the present application.

[0114] Based on the above Figure 2-Figure 4 The system structure for secure booting of firmware shown and the secure booting method for firmware described above are combined with the decryption method for secure booting of firmware provided in this application.

[0115] See also Figure 6 , Figure 6 This is a flowchart of a decryption method for firmware secure booting provided by an embodiment of the present application. Figure 6 The decryption method for firmware secure boot shown above can be applied to Figure 2 In the chip described in, the specific description of each step is as follows:

[0116] Step S301: Obtain the encrypted firmware.

[0117] Specifically, when the firmware needs to be updated, downloaded, upgraded or burned, the chip can obtain the encrypted firmware, such as receiving the encrypted firmware sent by the electronic device, to achieve the update, download, upgrade or burning of the firmware.

[0118] Step S302: decrypt the encrypted firmware to obtain the decrypted firmware.

[0119] Specifically, the encrypted data in the encrypted firmware is determined; based on the encrypted data and the preset decryption rule, the encrypted data in the encrypted firmware is decrypted to obtain second random data; the encrypted data in the encrypted firmware is replaced with the second random data to obtain the decrypted firmware.

[0120] In some embodiments, the chip is specifically used to: receive the firmware information sent by the electronic device; determine the encrypted data from the encrypted firmware based on the header information in the firmware information, and the position information in the header information can be used to indicate the position of the encrypted data in the encrypted firmware; based on the encrypted data, decrypt the encrypted firmware to obtain the decrypted firmware.

[0121] Step S303: Perform integrity check on the decrypted firmware, and start the decrypted firmware after the check passes.

[0122] Specifically, the chip can also perform integrity check on the decrypted firmware, start the decrypted firmware after the check passes, and suspend starting the decrypted firmware when the check fails. For example: perform integrity check on the decrypted firmware based on the second check code and the first check code sent by the electronic device, and start the decrypted firmware when the second check code is consistent with the first check code.

[0123] It should be noted that the description of steps S301 to S303 in the method embodiment described in the embodiment of the present application can be found in the above Figure 2-Figure 4 The relevant description about the chip in the system architecture embodiment shown will not be repeated here in the embodiment of the present application.

[0124] The embodiment of the present application also provides an electronic device, the electronic device includes one or more processors and one or more memories; wherein the one or more memories are coupled to the one or more processors, the one or more memories are used to store computer program codes, the computer program codes include computer instructions, when the one or more processors execute the computer instructions, the electronic device executes the above Figure 5 The illustrated embodiments describe the method.

[0125] The present application also provides a chip, wherein the chip includes a logic circuit, wherein the logic circuit is used to support the chip to implement the above Figure 6 The illustrated embodiments describe the method.

[0126] The embodiments of the present application also provide a computer program product including instructions. When the computer program product runs on an electronic device or a chip, the electronic device or the chip executes the method described in the above embodiments.

[0127] An embodiment of the present application also provides a computer-readable storage medium, including instructions, which, when executed on an electronic device or a chip, enables the electronic device or the chip to execute the method described in the above embodiment.

[0128] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in this application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) mode. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integration. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk Solid State Disk), etc.

[0129] Those skilled in the art can understand that to implement all or part of the processes in the above-mentioned embodiments, the processes can be completed by computer programs to instruct related hardware, and the programs can be stored in computer-readable storage media. When the programs are executed, they can include the processes of the above-mentioned method embodiments. The aforementioned storage media include: ROM or random access memory RAM, magnetic disk or optical disk and other media that can store program codes.

[0130] In short, the above is only an embodiment of the technical solution of this application, and is not intended to limit the protection scope of this application. Any modification, equivalent replacement, improvement, etc. made according to the disclosure of this application shall be included in the protection scope of this application.

Claims

1. A secure boot system for firmware, characterized in that: The system comprises: an electronic device and a chip; The electronic device is used to: encrypt part of the data in the firmware to obtain the encrypted firmware; and send the encrypted firmware to the chip when the firmware in the chip meets the preset download condition; The chip is used for: receiving the encrypted firmware sent by the electronic device; decrypting the encrypted firmware to obtain the decrypted firmware; and starting the decrypted firmware.

2. The system according to claim 1, characterized in that: The electronic device is specifically used for: Randomly sampling the firmware to obtain first random data in the firmware; Based on a preset encryption rule and the first random data, obtaining encrypted data corresponding to the first random data; The first random data in the firmware is replaced with the encrypted data to obtain the encrypted firmware.

3. The system according to claim 2, characterized in that: The electronic device is specifically used for: When the firmware in the chip meets the preset download condition, firmware information is sent to the chip, the firmware information includes header information and the encrypted firmware, the header information includes the location information, and the location information is used to indicate the location of the encrypted data in the firmware.

4. The system according to any one of claims 1 to 3, characterized in that: The electronic device is specifically used for: Obtaining current version information corresponding to the firmware in the chip; The current version information is compared with the target version information corresponding to the firmware in the electronic device, and when the current version information is inconsistent with the latest version information, it is determined that the firmware meets the preset download condition.

5. The system according to any one of claims 1 to 4, characterized in that: The electronic device is also used for: Before encrypting part of the data in the firmware to obtain the encrypted firmware, the first verification code corresponding to the firmware is obtained based on a preset integrity verification rule, and the first verification code is used to verify the integrity of the firmware.

6. The system according to any one of claims 3 to 5, characterized in that: The chip is specifically used for: Receiving the firmware information sent by the electronic device; determining the encrypted data from the encrypted firmware based on the position information in the header information; Based on the encrypted data and the preset decryption rule, the encrypted firmware is decrypted to obtain the decrypted firmware.

7. The system according to claim 6, characterized in that: The chip is specifically used for: Decrypting the encrypted data in the encrypted firmware based on a preset decryption rule to obtain second random data; The encrypted data in the encrypted firmware is replaced with the second random data to obtain the decrypted firmware.

8. The system according to claim 7, characterized in that: The firmware information also includes the first verification code; and the chip is further used for: Based on the preset integrity verification rule, obtaining a second verification code corresponding to the decrypted firmware; The first verification code and the second verification code are compared, and when the second verification code is consistent with the first verification code, the decrypted firmware is started.

9. A secure boot method for firmware, characterized in that: Applied to a secure boot system, the secure boot system includes an electronic device and a chip; the method includes: Encrypting part of the data in the firmware by the electronic device to obtain the encrypted firmware; sending the encrypted firmware to the chip when the firmware in the chip meets the preset download condition; The encrypted firmware sent by the electronic device is received through the chip; the encrypted firmware is decrypted to obtain the decrypted firmware; and the decrypted firmware is started.

10. An encryption method for firmware secure boot, characterized in that: The method comprises: Randomly sampling the firmware to obtain first random data in the firmware, where the first random data is part of the data in the firmware; Based on a preset encryption rule and the first random data, obtaining encrypted data corresponding to the first random data; The first random data in the firmware is replaced with the encrypted data to obtain the encrypted firmware.

11. A decryption method for firmware secure boot, characterized in that: The method comprises: Obtaining the encrypted firmware; determining the encrypted data in the encrypted firmware; Based on the encrypted data and the preset decryption rule, decrypting the encrypted data in the encrypted firmware to obtain second random data; The encrypted data in the encrypted firmware is replaced with the second random data to obtain the decrypted firmware.

12. An electronic device, characterized in that: The electronic device includes one or more processors and one or more memories; wherein the one or more memories are coupled to the one or more processors, and the one or more memories are used to store computer program code, and the computer program code includes computer instructions, and when the one or more processors execute the computer instructions, the electronic device executes the method as claimed in claim 9 or 10.

13. A chip, characterized in that: The chip comprises a logic circuit, and the logic circuit is used to support the chip to implement the method according to claim 9 or 11.

14. A computer-readable storage medium comprising instructions, characterized in that: When the instruction is executed on an electronic device, the electronic device executes the method as described in any one of claims 9 to 11.

15. A computer program product, characterized in that The computer program product comprises a computer program, and when the computer program is executed by a computer or a processor, the computer or the processor is caused to execute the method according to any one of claims 9 to 11.

Citation Information

Patent Citations

  • Fixed algorithm-free key encryption technology

    CN104125060A

  • Protection method and system for APK program file

    CN108090368A

  • Firmware protection method and device and terminal equipment

    CN112100624A

  • Chip data acquisition method, device and system, chip and storage medium

    CN115935392A

  • Safe starting system for chip module and starting method thereof

    CN116070217A