Processor secure boot method and processor
Through the method of overall verification information calculation and random number generation, the problem of low efficiency of multiple firmware legality checks during processor startup is solved, and efficient and secure firmware legality verification is achieved, ensuring the legality and security of the firmware at each stage.
Patent Information
- Application Number
- CN202210755857.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-29
- Publication Date
- 2025-08-29
- Estimated Expiration
- 2042-06-29
AI Technical Summary
In the prior art, the processor has low efficiency in verifying the legality of multiple firmware during startup, and there is a risk that the firmware will be tampered with.
The overall verification information calculation method is used to generate random numbers and calculate the verification code of each firmware. The legality of all firmware is determined through one overall verification. The firmware verification code is used for separate verification during loading in subsequent stages.
Improves the efficiency of legality verification, reduces calculation time, ensures the legality of the firmware at every execution time, and reduces the risk of firmware being tampered with.
Smart Images

Figure CN115168866B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of information security technology, and in particular to a processor secure startup method and a processor. Background Art
[0002] During the startup of the processor, firmware is usually loaded from an off-chip storage device. To ensure the safe startup of the processor, the security of the firmware stored off-chip needs to be verified during loading. The security verification of the firmware can usually be achieved by encryption and decryption or signing and verification. As the functional requirements continue to increase, the number of firmware required during the startup of the processor also gradually increases. When the firmware storage area inside the processor is smaller than the actual off-chip firmware, the actual off-chip firmware is usually split into multiple segments, and then loaded and executed in stages during the startup of the processor. In this case, the prior art usually adopts a separate signature verification of the legitimacy of each firmware to ensure the security of each firmware. However, the separate signature verification of the legitimacy of each firmware requires a large amount of computation, and its efficiency is extremely low. Summary of the Invention
[0003] The processor secure boot method and processor provided by the present invention can efficiently verify the legitimacy of multiple firmwares and prevent the firmware from being tampered with during the stage loading and execution process.
[0004] In a first aspect, the present invention provides a processor secure boot method, comprising:
[0005] Randomly generate random numbers;
[0006] Calculating overall verification information for multiple firmware in the off-chip firmware storage device, and obtaining first intermediate data corresponding to each firmware in the overall verification information calculation process;
[0007] Calculating a firmware check code corresponding to each firmware according to the random number and the first intermediate data;
[0008] Acquire the overall identification information of the plurality of firmwares from an off-chip firmware storage device, and verify the overall identification information using the overall verification information;
[0009] When the overall identification information passes verification, recalculating the second intermediate data corresponding to each firmware according to the calculation method of the overall verification information;
[0010] Calculating a firmware identification code corresponding to each firmware according to the second intermediate data and the random number;
[0011] The firmware verification code is used to verify the firmware identification code.
[0012] Optionally, calculating overall verification information for multiple firmware in the off-chip firmware storage device includes:
[0013] When the current firmware is the first firmware, perform an overall validity check calculation on the current firmware to obtain temporary data corresponding to the current firmware;
[0014] When the current firmware is a firmware subsequent to the first firmware, the current firmware is subjected to an overall validity check calculation based on the temporary data corresponding to the previous firmware to obtain the temporary data corresponding to the current firmware;
[0015] The temporary data of the last firmware is used as the overall verification information.
[0016] Optionally, calculating a firmware check code corresponding to each firmware according to the random number and the first intermediate data includes:
[0017] Hash the first intermediate data corresponding to the current firmware to obtain a first hash value;
[0018] Concatenating the first Hash value and the random number to form first concatenated data;
[0019] The first spliced data is hashed to determine a firmware verification code corresponding to the current firmware.
[0020] Optionally, calculating a firmware check code corresponding to each firmware according to the random number and the first intermediate data includes:
[0021] The random number is used as a key to calculate a key-based hash operation message authentication code of the first intermediate data corresponding to the current firmware, and a firmware verification code corresponding to the current firmware is determined.
[0022] Optionally, calculating a firmware check code corresponding to each firmware according to the random number and the first intermediate data includes:
[0023] Hash the first intermediate data corresponding to the current firmware to obtain a first hash value;
[0024] The first Hash value is encrypted using the random number to determine a firmware verification code corresponding to the current firmware.
[0025] Optionally, verifying the overall identification information using the overall verification information includes:
[0026] The pre-acquired public key is used to verify whether the overall identification information is a legal signature of the overall verification information.
[0027] In a second aspect, the present invention provides a processor, comprising:
[0028] Random number generation module, used to randomly generate random numbers;
[0029] a verification code generation module configured to calculate overall verification information for multiple firmware in an off-chip firmware storage device, and obtain first intermediate data corresponding to each firmware during the overall verification information calculation process; calculate a firmware verification code corresponding to each firmware based on the random number and the first intermediate data; and, when the overall identification information passes verification, recalculate second intermediate data corresponding to each firmware based on a calculation method for the overall verification information; and calculate a firmware identification code corresponding to each firmware based on the second intermediate data and the random number;
[0030] A verification code storage module, used to store the firmware verification code corresponding to each firmware;
[0031] The firmware verification module is used to obtain the overall identification information of the plurality of firmwares from the off-chip firmware storage device, verify the overall identification information using the overall verification information; and verify the firmware identification code using the firmware verification code.
[0032] Optionally, the verification code generation module includes:
[0033] A first calculation unit is configured to perform an overall validity check calculation on the current firmware when the current firmware is the first firmware, so as to obtain temporary data corresponding to the current firmware;
[0034] The second calculation unit is used to perform an overall validity check calculation on the current firmware based on the temporary data corresponding to the previous firmware when the current firmware is the firmware after the first firmware, so as to obtain the temporary data corresponding to the current firmware.
[0035] The information determination unit is used to use the temporary data of the last firmware as the overall verification information.
[0036] Optionally, the verification code generation module includes:
[0037] A first hash unit, configured to hash first intermediate data corresponding to the current firmware to obtain a first hash value;
[0038] a splicing unit, configured to splice the first hash value and the random number to form first spliced data;
[0039] The second hash unit is configured to hash the first spliced data to determine a firmware check code corresponding to the current firmware.
[0040] Optionally, the verification code generation module includes:
[0041] The authentication code unit is used to use the random number as a key to calculate a key-based hash operation message authentication code of the first intermediate data corresponding to the current firmware, and determine a firmware check code corresponding to the current firmware.
[0042] Optionally, the verification code generation module includes:
[0043] a hash value unit, configured to hash first intermediate data corresponding to the current firmware to obtain a first hash value;
[0044] An encryption unit is configured to encrypt the first hash value using the random number to determine a firmware verification code corresponding to the current firmware.
[0045] Optionally, the firmware verification module includes:
[0046] The signature verification unit is used to use the pre-acquired public key to verify whether the overall identification information is a legal signature of the overall verification information.
[0047] In the technical solution provided by the present invention, by calculating the overall verification information of multiple firmwares, the security of all firmwares can be determined through a single verification. Since the first intermediate data is saved during the calculation of the overall verification information of multiple firmwares, and the verification code of each firmware is calculated according to a random number based on the first intermediate data, when the multiple firmwares are subsequently started in multiple stages, the verification code of each firmware can be used to perform a separate verification on each firmware, thereby ensuring the legitimacy of each firmware at the time of execution. At the same time, since the calculation time of the verification information of the firmware is much shorter than the verification time of the verification information, in the present invention, by verifying the overall verification information after calculating the overall verification information, that is, only performing a single verification, the time of the entire legitimacy verification can be greatly saved, thereby improving the efficiency of the legitimacy verification. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] Figure 1 This is a flowchart of a processor secure boot method according to an embodiment of the present invention;
[0049] Figure 2 This is a flowchart of overall verification information calculation of a processor secure boot method according to an embodiment of the present invention;
[0050] Figure 3 This is a flowchart of firmware verification code calculation in a processor secure boot method according to an embodiment of the present invention;
[0051] Figure 4 This is a flowchart of firmware verification code calculation in a processor secure boot method according to an embodiment of the present invention;
[0052] Figure 5 A schematic diagram of a processor according to an embodiment of the present invention;
[0053] Figure 6 A schematic diagram of a check code generation module of a processor according to an embodiment of the present invention;
[0054] Figure 7 A schematic diagram of a check code generation module of a processor according to an embodiment of the present invention;
[0055] Figure 8 Schematic diagram of a check code generation module of a processor according to an embodiment of the present invention. DETAILED DESCRIPTION
[0056] To make the objectives, technical solutions, and advantages of the embodiments of the present invention more clear, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only 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 making creative efforts shall fall within the scope of protection of the present invention.
[0057] The embodiment of the present invention provides a processor secure startup method, such as Figure 1 As shown, including:
[0058] Step 100: Randomly generate a random number. In some embodiments, the random number can be generated by software or hardware.
[0059] Step 200 calculates overall verification information for multiple firmware files in an off-chip firmware storage device, and obtains first intermediate data corresponding to each firmware file during the overall verification information calculation process. In some embodiments, during the overall verification information calculation process, the multiple firmware files can be calculated one by one according to the overall verification information calculation method. To ensure that the overall verification information includes information from all firmware files, when calculating the current firmware file, the calculation result of the previous firmware file can be combined with the current firmware file using the overall verification information calculation method. In this way, the calculation result of each firmware file includes information from the previously calculated firmware file. For example, when using an elliptic curve signature and verification mechanism as the overall verification information calculation method, a hash value needs to be calculated for the entire firmware file. During the calculation process, the first firmware file can be hashed to obtain a temporary calculation result. The hashing process for the firmware files after the first firmware file is based on the temporary calculation result of the previous firmware file and the hash value is continued using the current firmware file. The first intermediate data can be selected based on different requirements. For example, it can be selected from the firmware file itself or from temporary information used to calculate the overall verification information for the firmware file itself. In some embodiments, the overall verification information can be calculated by software or hardware.
[0060] Step 300: Calculate a firmware verification code corresponding to each firmware file based on the random number and the first intermediate data. In some embodiments, using the first intermediate data and the random number to calculate the firmware verification code can enhance the confidentiality of the firmware verification code, preventing it from being obtained by others. In some embodiments, the firmware verification code can be calculated by software or hardware.
[0061] Step 400: Obtain overall identification information of the plurality of firmware files from an off-chip firmware storage device, and verify the overall identification information using the overall verification information. In some embodiments, the overall identification information is stored together with the firmware files in the off-chip storage device. During the verification process, the overall verification information is used to verify the legitimacy of the overall identification information. For example, using the signature verification mechanism of an asymmetric encryption algorithm, when verifying the overall identification information, a pre-acquired public key is used to verify whether the overall identification information is a legitimate signature of the overall verification information. In some embodiments, the verification process of the overall verification information against the overall identification information can be performed by software or hardware.
[0062] Step 500, when the overall identification information is verified, the second intermediate data corresponding to each firmware is recalculated based on the calculation method of the overall verification information; in some embodiments, the second intermediate data is the basis for calculating the firmware identification code, so the calculation process of the second intermediate data should be the same as the acquisition method of the first intermediate data.
[0063] Step 600, calculate the firmware identification code corresponding to each firmware based on the second intermediate data and the random number; in some embodiments, the calculation process of the firmware identification code should be the same as the calculation process of the firmware verification code, so that when the second intermediate data is the same as the first intermediate data and the random number remains unchanged, the firmware identification code and the firmware verification code can be the same; conversely, when the second intermediate data is different from the first intermediate data, the firmware identification code and the firmware verification code are different.
[0064] Step 700: Verify the firmware identification code using the firmware verification code. In some embodiments, when the firmware verification code is identical to the firmware identification code, it indicates that the current firmware data is identical to the firmware data during the overall verification process, i.e., after the overall verification, the firmware data has not been tampered with until the current time.
[0065] In the technical solution provided by the embodiment of the present invention, by calculating the overall verification information of multiple firmwares, the security of all firmwares can be determined through a single verification. Since the first intermediate data is saved during the calculation of the overall verification information of multiple firmwares, and the verification code of each firmware is calculated according to a random number based on the first intermediate data, when the multiple firmwares are subsequently started in multiple stages, the verification code of each firmware can be used to perform a separate verification on each firmware, thereby ensuring the legitimacy of each firmware at the time of execution. At the same time, since the calculation time of the verification information of the firmware is much shorter than the verification time of the verification information, in this patent application, by calculating the overall verification information and then verifying the overall verification information, that is, only performing a single verification, the time of the entire legitimacy verification can be greatly saved, thereby improving the efficiency of the legitimacy verification. In some embodiments, after the overall firmware legitimacy check passes, the first firmware is loaded into the processor, and then the firmware verification module calculates the second intermediate data corresponding to the first firmware according to the same calculation method as the first intermediate data, and calculates the firmware identification code of the first firmware according to the second intermediate data and the same random number in the same calculation method as the firmware verification code. The firmware verification code corresponding to the first firmware is used to verify the firmware identification code corresponding to the first firmware. After the verification passes, the execution is switched to the first firmware. After the first firmware starts executing, the identification and verification of the firmware identification codes corresponding to the subsequent firmware can be performed by the firmware verification code module or by the first firmware. In some preferred embodiments, the first firmware is responsible for loading other firmwares except the first firmware according to the system startup process, and calculating the firmware identification code corresponding to each firmware in the processor based on the random number using the same calculation method as the firmware verification code; and obtaining the corresponding firmware verification code from the verification code storage area, comparing the firmware verification code and the firmware identification code. If the firmware verification code is equal to the firmware identification code, the execution is switched to the corresponding firmware, otherwise the corresponding firmware is suspended. The loading of other firmwares can be carried out one at a time and verified, or all at once and verified one by one.
[0066] As an optional implementation, Figure 2 As shown, in step 200, calculating overall verification information for multiple firmware in the off-chip firmware storage device includes:
[0067] In step 210, when the current firmware is the first firmware, an overall legitimacy verification calculation is performed on the current firmware to obtain temporary data corresponding to the current firmware. In some embodiments, the temporary data of the current firmware refers to the calculation result obtained when the current firmware is calculated using the overall legitimacy verification calculation method. For example, when the signature and verification mechanism based on the elliptic curve is used as the overall legitimacy verification calculation method, the temporary data can be a hash value of the current firmware data.
[0068] In step 220, when the current firmware is the firmware after the first firmware, the current firmware is subjected to an overall legitimacy verification calculation based on the temporary data corresponding to the previous firmware to obtain the temporary data corresponding to the current firmware. In some embodiments, the overall legitimacy verification calculation based on the temporary data corresponding to the previous firmware refers to calculating the temporary data corresponding to the previous firmware together with the current firmware data, so that the temporary data of the current firmware contains the information of the previous firmware. For example, when the signature and verification mechanism based on the elliptic curve is used as the overall legitimacy verification calculation method, the temporary data of the previous firmware can be hashed together with the current firmware data. For example, the temporary data of the previous firmware can be spliced with the current firmware data, and the spliced data can be hashed.
[0069] Step 230: Use the temporary data of the last firmware as the overall verification information.
[0070] In this embodiment, the temporary data of the previous firmware is used to participate in the calculation of the temporary data of the current firmware. This allows the temporary data in the current firmware to include the verification information of the previous firmware. That is, when the temporary data of the current firmware passes the verification, the legitimacy of all previous firmwares is also verified. Those skilled in the art will understand that in this embodiment, the temporary data of the last firmware represents the overall verification information of multiple firmwares.
[0071] As an optional implementation, Figure 3 As shown, in step 300, calculating the firmware verification code corresponding to each firmware according to the random number and the first intermediate data includes:
[0072] Step 311: Hash the first intermediate data corresponding to the current firmware to obtain a first hash value;
[0073] Step 312: concatenate the first hash value and the random number to form first concatenated data;
[0074] Step 313: Hash the first spliced data to determine a firmware verification code corresponding to the current firmware.
[0075] In this embodiment, a specific firmware verification code calculation process is provided. By concatenating a hash value and a random number, the firmware verification code can be calculated quickly, accurately, and confidentially. The calculation formula is as follows: ID = Hash(Hash(first intermediate data)||random number R), where the symbol "||" represents data concatenation, Hash represents a hash operation, and ID represents the firmware verification code.
[0076] As an optional implementation, in step 300, calculating the firmware verification code corresponding to each firmware according to the random number and the first intermediate data includes:
[0077] The random number is used as a key to calculate a key-based hash operation message authentication code of the first intermediate data corresponding to the current firmware, and a firmware verification code corresponding to the current firmware is determined.
[0078] In this embodiment, a method for calculating a firmware verification code is provided, which can ensure accurate and secret firmware verification code with less computational effort. The calculation formula is as follows: ID = HMAC (first intermediate data, random number R).
[0079] As an optional implementation, Figure 4 As shown, in step 300, calculating the firmware verification code corresponding to each firmware according to the random number and the first intermediate data includes:
[0080] Step 321: Hash the first intermediate data corresponding to the current firmware to obtain a first hash value;
[0081] Step 322: Use the random number to encrypt the first Hash value to determine a firmware verification code corresponding to the current firmware.
[0082] In this embodiment, a method for calculating a firmware check code is provided, in which a random number is used to encrypt the hash value of the intermediate data to obtain the firmware check code. The calculation formula is as follows: ID = encryption algorithm (Hash (firmware data), random number R).
[0083] As an optional implementation manner, using the overall verification information to verify the overall identification information includes:
[0084] The pre-acquired public key is used to verify whether the overall identification information is a legitimate signature of the overall verification information. In some embodiments, the pre-acquired public key corresponds to the private key used to sign the firmware, and the overall identification information is information signed with the private key. The public key can verify the legitimacy of the signature information.
[0085] The embodiment of the present invention further provides a processor, such as Figure 5 As shown, including:
[0086] The random number generation module is used to randomly generate random numbers. In some embodiments, the random number generation module can be a software module or a hardware module.
[0087] a verification code generation module configured to calculate overall verification information for multiple firmware in an off-chip firmware storage device, and obtain first intermediate data corresponding to each firmware during the overall verification information calculation process; calculate a firmware verification code corresponding to each firmware based on the random number and the first intermediate data; and, when the overall identification information passes verification, recalculate second intermediate data corresponding to each firmware based on a calculation method for the overall verification information; and calculate a firmware identification code corresponding to each firmware based on the second intermediate data and the random number;
[0088] In some embodiments, during the calculation of the overall verification information, multiple firmware data can be calculated one by one based on the calculation method of the overall verification information. In order to ensure that the overall verification information can contain all the information of the firmware, when calculating the current firmware data, the calculation result of the previous firmware data can be calculated together with the current firmware data using the calculation method of the overall verification information. In this way, the calculation result of each firmware data includes the information of the previously calculated firmware data. For example, when the signature and verification mechanism based on the elliptic curve is used as the calculation method of the overall verification information, it is necessary to calculate a hash value for the entire firmware. During the calculation process, the first firmware data can be hashed to obtain a temporary calculation result. The hash process of the firmware data after the first firmware is based on the temporary calculation result of the previous firmware data and the hash value is continued to be calculated using the current firmware data. The first intermediate data can be selected according to different needs. For example, firmware data can be selected, or temporary information for calculating the overall verification information of the firmware data can be selected.
[0089] In some embodiments, the firmware verification code is calculated using the first intermediate data and a random number, which can improve the confidentiality of the firmware verification code and prevent the firmware verification code from being obtained by others.
[0090] In some embodiments, the second intermediate data is the basis for calculating the firmware identification code, and therefore, the calculation process of the second intermediate data should be the same as the acquisition method of the first intermediate data.
[0091] In some embodiments, the calculation process of the firmware identification code should be the same as the calculation process of the firmware verification code, so that when the second intermediate data is the same as the first intermediate data and the random number remains unchanged, the firmware identification code and the firmware verification code can be made the same; conversely, when the second intermediate data is different from the first intermediate data, the firmware identification code and the firmware verification code are different.
[0092] In some embodiments, the verification code generation module may be a software module or a hardware module.
[0093] A verification code storage module, used to store the firmware verification code corresponding to each firmware;
[0094] The firmware verification module is used to obtain the overall identification information of the plurality of firmwares from the off-chip firmware storage device, verify the overall identification information using the overall verification information; and verify the firmware identification code using the firmware verification code.
[0095] In some embodiments, the overall identification information is stored together with the firmware when it is stored in an off-chip storage device. During the verification process, the overall verification information is used to verify the legitimacy of the overall identification information. For example, using the signature verification mechanism of an asymmetric encryption algorithm, the overall identification information is verified using a pre-acquired public key to verify whether the signature of the overall identification information is a legitimate signature of the overall verification information.
[0096] In some embodiments, when the firmware verification code is the same as the firmware identification code, it indicates that the current firmware data is the same as the firmware data in the overall verification process, that is, after the overall verification, until the current time, the firmware data has not been tampered with.
[0097] In some embodiments, the firmware verification module may be a software module or a hardware module.
[0098] In the technical solution provided by the embodiments of the present invention, by calculating the overall verification information for multiple firmwares, the security of all firmwares can be determined through a single verification. Since first intermediate data is saved during the calculation of the overall verification information for the multiple firmwares, and a verification code for each firmware is calculated based on a random number based on the first intermediate data, when the multiple firmwares are subsequently started in multiple stages, each firmware can be individually verified using the verification code of each firmware, ensuring the legitimacy of each firmware at the time of execution. At the same time, since the calculation time of the firmware verification information is much shorter than the verification time of the verification information, in this patent application, by calculating the overall verification information and then verifying the overall verification information, that is, performing only one verification, the time of the entire legitimacy verification can be greatly saved and the efficiency of the legitimacy verification can be improved. In some embodiments, after the overall firmware legitimacy verification passes, the first firmware is loaded and the firmware verification module calculates and verifies the firmware identification code corresponding to the first firmware. After the first firmware begins execution, the identification and verification of the firmware identification code corresponding to the subsequent firmware can be performed by the firmware verification code module or by the first firmware.
[0099] As an optional implementation, Figure 6 As shown, the verification code generation module includes:
[0100] The first calculation unit is used to perform an overall legitimacy verification calculation on the current firmware when the current firmware is the first firmware, so as to obtain temporary data corresponding to the current firmware; in some embodiments, the temporary data of the current firmware refers to the calculation result obtained when the current firmware is calculated using the overall legitimacy verification calculation method. For example, when the signature and verification mechanism based on the elliptic curve is used as the overall legitimacy verification calculation method, the temporary data can be a hash value of the current firmware data.
[0101] The second calculation unit is used to perform an overall legitimacy verification calculation on the current firmware based on the temporary data corresponding to the previous firmware when the current firmware is the firmware after the first firmware, so as to obtain the temporary data corresponding to the current firmware. In some embodiments, performing an overall legitimacy verification calculation on the current firmware based on the temporary data corresponding to the previous firmware means calculating the temporary data corresponding to the previous firmware together with the current firmware data, so that the temporary data of the current firmware contains the information of the previous firmware. For example, when the signature and verification mechanism based on the elliptic curve is used as the overall legitimacy verification calculation method, the temporary data of the previous firmware can be hashed together with the current firmware data. For example, the temporary data of the previous firmware can be spliced with the current firmware data, and the spliced data can be hashed.
[0102] The information determination unit is used to use the temporary data of the last firmware as the overall verification information.
[0103] In this embodiment, the temporary data of the previous firmware is used to participate in the calculation of the temporary data of the current firmware. This allows the temporary data in the current firmware to include the verification information of the previous firmware. That is, when the temporary data of the current firmware passes the verification, the legitimacy of all previous firmwares is also verified. Those skilled in the art will understand that in this embodiment, the temporary data of the last firmware represents the overall verification information of multiple firmwares.
[0104] As an optional implementation, Figure 7 As shown, the verification code generation module includes:
[0105] A first hash unit, configured to hash first intermediate data corresponding to the current firmware to obtain a first hash value;
[0106] a splicing unit, configured to splice the first hash value and the random number to form first spliced data;
[0107] The second hash unit is configured to hash the first spliced data to determine a firmware check code corresponding to the current firmware.
[0108] In this embodiment, a specific firmware verification code calculation process is provided. By concatenating a hash value and a random number, the firmware verification code can be calculated quickly, accurately, and confidentially. The calculation formula is as follows: ID = Hash(Hash(first intermediate data)||random number R), where the symbol "||" represents data concatenation, Hash represents a hash operation, and ID represents the firmware verification code.
[0109] As an optional implementation, the verification code generation module includes:
[0110] The authentication code unit is used to use the random number as a key to calculate a key-based hash operation message authentication code of the first intermediate data corresponding to the current firmware, and determine a firmware check code corresponding to the current firmware.
[0111] In this embodiment, a method for calculating a firmware verification code is provided, which can ensure accurate and secret firmware verification code with less computational effort. The calculation formula is as follows: ID = HMAC (first intermediate data, random number R).
[0112] As an optional implementation, Figure 8 As shown, the verification code generation module includes:
[0113] a hash value unit, configured to hash first intermediate data corresponding to the current firmware to obtain a first hash value;
[0114] An encryption unit is configured to encrypt the first hash value using the random number to determine a firmware verification code corresponding to the current firmware.
[0115] In this embodiment, a method for calculating a firmware check code is provided, in which a random number is used to encrypt the hash value of the intermediate data to obtain the firmware check code. The calculation formula is as follows: ID = encryption algorithm (Hash (firmware data), random number R).
[0116] As an optional implementation, the firmware verification module includes:
[0117] A signature verification unit is configured to verify, using a pre-acquired public key, whether the overall identification information is a legitimate signature of the overall verification information. In some embodiments, the pre-acquired public key corresponds to a private key used to sign the firmware, and the overall identification information is signed with the private key. The public key can verify the legitimacy of the signature.
[0118] Those skilled in the art will appreciate that all or part of the processes in the above method embodiments can be implemented by instructing related hardware through a computer program. The program can be stored in a computer-readable storage medium, and when executed, the program can include the processes in the above method embodiments. The storage medium can be a magnetic disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM).
[0119] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any changes or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in the present invention should be included in the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be based on the scope of protection of the claims.
Claims
1. A processor secure boot method, characterized in that: include: Randomly generate random numbers; Calculating overall verification information for multiple firmware in the off-chip firmware storage device, and obtaining first intermediate data corresponding to each firmware in the overall verification information calculation process; Calculating a firmware check code corresponding to each firmware according to the random number and the first intermediate data; Acquire the overall identification information of the plurality of firmwares from an off-chip firmware storage device, and verify the overall identification information using the overall verification information; When the overall identification information passes verification, recalculating the second intermediate data corresponding to each firmware according to the calculation method of the overall verification information; Calculating a firmware identification code corresponding to each firmware according to the second intermediate data and the random number; The firmware verification code is used to verify the firmware identification code.
2. The method according to claim 1, characterized in that Calculating overall verification information for multiple firmware in an off-chip firmware storage device includes: When the current firmware is the first firmware, perform an overall validity check calculation on the current firmware to obtain temporary data corresponding to the current firmware; When the current firmware is a firmware subsequent to the first firmware, the current firmware is subjected to an overall validity check calculation based on the temporary data corresponding to the previous firmware to obtain the temporary data corresponding to the current firmware; The temporary data of the last firmware is used as the overall verification information.
3. The method according to claim 1, characterized in that Calculating a firmware check code corresponding to each firmware according to the random number and the first intermediate data includes: Hash the first intermediate data corresponding to the current firmware to obtain a first hash value; Concatenating the first Hash value and the random number to form first concatenated data; The first spliced data is hashed to determine a firmware verification code corresponding to the current firmware.
4. The method according to claim 1, wherein Calculating a firmware check code corresponding to each firmware according to the random number and the first intermediate data includes: The random number is used as a key to calculate a key-based hash operation message authentication code of the first intermediate data corresponding to the current firmware, and a firmware verification code corresponding to the current firmware is determined.
5. The method according to claim 1, wherein Calculating a firmware check code corresponding to each firmware according to the random number and the first intermediate data includes: Hash the first intermediate data corresponding to the current firmware to obtain a first hash value; The first Hash value is encrypted using the random number to determine a firmware verification code corresponding to the current firmware.
6. The method according to claim 1, characterized in that Verifying the overall identification information using the overall verification information includes: The pre-acquired public key is used to verify whether the overall identification information is a legal signature of the overall verification information.
7. A processor, characterized in that: include: Random number generation module, used to randomly generate random numbers; A check code generation module is used to calculate overall check information for multiple firmware in the off-chip firmware storage device, and obtain first intermediate data corresponding to each firmware in the process of calculating the overall check information; Calculating a firmware check code corresponding to each firmware according to the random number and the first intermediate data; When the overall identification information is verified, the second intermediate data corresponding to each firmware is recalculated according to the calculation method of the overall verification information; and the firmware identification code corresponding to each firmware is calculated based on the second intermediate data and the random number; A verification code storage module, used to store the firmware verification code corresponding to each firmware; a firmware verification module, configured to obtain overall identification information of the plurality of firmwares from an off-chip firmware storage device, and verify the overall identification information using the overall verification information; And the firmware identification code is verified using the firmware verification code.
8. The processor according to claim 7, wherein: The verification code generation module includes: A first calculation unit is configured to perform an overall validity check calculation on the current firmware when the current firmware is the first firmware, so as to obtain temporary data corresponding to the current firmware; a second calculation unit, configured to, when the current firmware is a firmware subsequent to the first firmware, perform an overall validity check calculation on the current firmware based on the temporary data corresponding to the previous firmware, so as to obtain the temporary data corresponding to the current firmware; The information determination unit is used to use the temporary data of the last firmware as the overall verification information.
9. The processor according to claim 7, wherein: The verification code generation module includes: A first hash unit, configured to hash first intermediate data corresponding to the current firmware to obtain a first hash value; a splicing unit, configured to splice the first hash value and the random number to form first spliced data; The second hash unit is configured to hash the first spliced data to determine a firmware check code corresponding to the current firmware.
10. The processor according to claim 7, wherein: The verification code generation module includes: The authentication code unit is used to use the random number as a key to calculate a key-based hash operation message authentication code of the first intermediate data corresponding to the current firmware, and determine a firmware check code corresponding to the current firmware.
11. The processor according to claim 7, wherein: The verification code generation module includes: a hash value unit, configured to hash first intermediate data corresponding to the current firmware to obtain a first hash value; An encryption unit is configured to encrypt the first hash value using the random number to determine a firmware verification code corresponding to the current firmware.
12. The processor according to claim 7, wherein: The firmware verification module includes: The signature verification unit is used to use the pre-acquired public key to verify whether the overall identification information is a legal signature of the overall verification information.
Citation Information
Patent Citations
Multi-firmware upgrading method and system, and readable storage medium
CN107291497A
Firmware protection method and apparatus
CN108491289A