Secure starting method and device of embedded system, equipment and storage medium
Through sharding processing and digest chain verification, the security and transmission efficiency problems of embedded systems during partition startup are solved, and fast and secure system image data transmission and recovery are achieved.
Patent Information
- Application Number
- CN202411105577.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-13
- Publication Date
- 2024-11-26
AI Technical Summary
The embedded system has poor security, large transmission overhead and long recovery time when the partition is started.
The system image data is sharded through the host and a summary chain is generated, including the shard number, the digest intermediate value and signature. The embedded device reads and verifies the data sharding through multiple threads, generates and repairs the image data for partitioning and secure startup.
Improve data transmission speed and efficiency, ensure data integrity, reduce calculation steps and hardware resource usage, early detection of inconsistency integration, improve system performance, and reduce the number of rewritten times during data recovery, ensuring system security and stability.
Smart Images

Figure CN119026137A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of embedded systems, and in particular to a secure startup method, device, equipment and storage medium for an embedded system. Background Art
[0002] The system image in the boot partition is not only a general system, but also a key component supporting the embedded information system. Due to the limitations of performance and resources in embedded systems, integrity verification must be performed on the system image loading when the partition is started. However, the use of soft algorithms is not secure enough, and the use of security chips has insufficient computing performance, which has a significant impact on the security and startup performance of embedded systems.
[0003] Conventional solutions install hardware security chips in embedded devices to ensure security. The summary value of the corresponding system image is stored in the security chip. When the system image is started and loaded, the binary stream of the system image is sent to the security chip for summary calculation and consistency comparison, or signature verification to verify the integrity of the system image. The use of security chips for hardware calculations will result in high transmission overhead when the system image data volume is large. Once an abnormality is found during the transmission process, all files need to be retransmitted, which has high hardware requirements and large computing resources. When restoring the system image, all images need to be rewritten, the flash erase rate is high, and the recovery time is long. Summary of the invention
[0004] The present invention provides a secure startup method, device, equipment and storage medium for an embedded system, so as to solve the problems of poor security of system image data, large transmission overhead and long recovery time when the embedded device is started in partitions.
[0005] According to one aspect of the present invention, a secure boot method for an embedded system is provided, the embedded system comprising: a host and an embedded device, the method comprising:
[0006] Obtaining system image data to be transmitted through the host, and slicing the system image data according to a specified data length to generate data slices;
[0007] Performing hash fragmentation processing on each data shard through the host to generate a digest chain, wherein the digest chain includes a shard sequence number, a digest intermediate value, and a signature of the data shard;
[0008] When the verification result of the summary chain is successful, each data shard is read through the embedded device multi-threading, and the intermediate value verification result of each data shard is determined according to the summary chain;
[0009] The system image is repaired according to the verification results of each intermediate value through the embedded device to generate repair image data, and the partition is safely started according to the repair image data.
[0010] Optionally, each data shard is hashed and fragmented by the host to generate a summary chain, including: performing hash calculation on each data shard to determine the summary intermediate value of each data shard, and numbering each data shard in sequence to generate each shard serial number; splicing the shard serial number and the summary intermediate value corresponding to each data shard to generate spliced data, and splicing each spliced data according to the shard serial number to generate summary chain main data; using a specified key to sign the summary chain main data to generate a summary chain.
[0011] Optionally, after the host performs hash fragmentation processing on each data shard to generate a summary chain, the method also includes: obtaining the summary chain through an embedded device, and using a public key to verify the signature of the summary chain to generate a verification result of the summary chain, wherein the verification result includes a successful verification and a failed verification.
[0012] Optionally, determining the intermediate value verification result of each data shard according to the summary chain includes: determining the target shard sequence number corresponding to the data shard processed by the current thread; performing hash calculation on the data shard corresponding to the target shard sequence number to determine the data summary value; obtaining the target summary intermediate value corresponding to the target shard sequence number and the historical summary intermediate value corresponding to the previous shard sequence number adjacent to the target shard sequence number from the summary chain; adding the data summary value and the historical summary intermediate value to generate a calculated summary intermediate value; determining the intermediate value verification result of the current thread according to the calculated summary intermediate value and the target summary intermediate value; integrating the intermediate value verification results of each thread to generate an intermediate value verification result of each data shard.
[0013] Optionally, determining the intermediate value verification result of the current thread based on the calculated digest intermediate value and the target digest intermediate value includes: judging whether the calculated digest intermediate value and the target digest intermediate value are consistent; if so, determining that the intermediate value verification result of the current thread is a verification success; otherwise, determining that the intermediate value verification result of the current thread is a verification failure.
[0014] Optionally, the system image is repaired according to the intermediate value verification results to generate repair image data through an embedded device, including: taking the data slice for which the intermediate value verification result is a verification failure as an abnormal data slice, and taking the slice sequence number corresponding to the abnormal data slice as the abnormal slice sequence number; determining the offset address of the system image corresponding to the abnormal slice sequence number; burning the system image data of a specified data length from the offset address as repair data through an image burning tool; and replacing the abnormal data slice with the repair data according to the abnormal slice sequence number to generate repair image data.
[0015] Optionally, performing partition secure booting according to the repair image data includes: performing summary intermediate value verification on each data slice of the repair image data to generate each intermediate value verification result; when each intermediate value verification result is successfully verified, loading the repair image data to perform partition secure booting.
[0016] According to another aspect of the present invention, a secure boot device for an embedded system is provided, the device comprising:
[0017] The system image data slicing module is used to obtain the system image data to be transmitted through the host, and to slice the system image data according to the specified data length to generate each data slice;
[0018] A summary chain generation module, used for performing hash fragmentation processing on each data shard through a host to generate a summary chain, wherein the summary chain includes a shard sequence number, a summary intermediate value and a signature of the data shard;
[0019] The data shard intermediate value verification module is used to read each data shard through the embedded device multi-thread when the verification result of the summary chain is successful, and determine the intermediate value verification result of each data shard according to the summary chain;
[0020] The data repair and secure boot module is used to perform system image repair according to the intermediate value verification results through the embedded device to generate repair image data, and perform partition secure boot according to the repair image data.
[0021] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising:
[0022] at least one processor;
[0023] and a memory communicatively coupled to the at least one processor;
[0024] The memory stores a computer program that can be executed by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute a secure startup method for an embedded system described in any embodiment of the present invention.
[0025] According to another aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement a secure startup method for an embedded system described in any embodiment of the present invention when executed.
[0026] The technical solution of the embodiment of the present invention can improve the speed and efficiency of data transmission by sharding the system image data and transmitting it in blocks. The hash fragmentation process generates a summary chain, which includes the fragmentation sequence number, the summary intermediate value and the signature, which can effectively verify the integrity and authenticity of the data and ensure that the data has not been tampered with during the transmission process. In the event of a transmission anomaly, it is only necessary to retransmit and calculate the abnormal data fragments to improve error redundancy; compared with repeating the summary calculation of the system image fragments, the summary process is fragmented in the form of summary relay, the calculation steps are greatly reduced, the performance is higher, and the hardware resources are less occupied; when the summary relay is used for integrity comparison, it is not necessary to wait for the final summary value of the entire system image data to be calculated before verification, and the integrity inconsistency can be detected early, further improving the system performance; when the data is restored, the offset address can be determined according to the abnormal data fragment, and the corresponding system image can be reburned and written, and the flash read and write life is improved with less erasure. The partition is securely started using the repaired image data to ensure the security and stability of the system startup and reduce security risks.
[0027] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0029] Figure 1 is a flow chart of a secure startup method for an embedded system provided according to Embodiment 1 of the present invention;
[0030] Figure 2 is a schematic diagram of a structure of a summary chain provided according to Embodiment 1 of the present invention;
[0031] Figure 3 is a flow chart of another method for securely starting an embedded system provided according to Embodiment 2 of the present invention;
[0032] Figure 4 is a schematic diagram of the structure of a secure boot device for an embedded system provided according to Embodiment 3 of the present invention;
[0033] Figure 5 It is a structural schematic diagram of an electronic device for implementing a secure startup method for an embedded system provided in a fourth embodiment of the present invention. DETAILED DESCRIPTION
[0034] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the 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 creative work should fall within the scope of protection of the present invention.
[0035] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. 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 that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0036] Embodiment 1
[0037] Figure 1 A flowchart of a secure boot method for an embedded system is provided for the first embodiment of the present invention. This embodiment is applicable to the case where an embedded device performs partition booting. The method can be applied to an embedded system, and the embedded system includes: a host and an embedded device. Figure 1 As shown, the method includes:
[0038] S110 , obtaining system image data to be transmitted through a host, and segmenting the system image data according to a specified data length to generate data segments.
[0039] The host can be a computing device or a server. System image data refers to a complete copy of the operating system and related configurations, files, etc., which can be used for system installation, recovery or backup. Sharding refers to dividing a large system image data into smaller parts according to certain rules for easy processing, transmission and storage. Data sharding refers to the smaller data unit obtained after the sharding operation.
[0040] Specifically, the host first obtains the entire system image data to be transmitted. Due to the large amount of data, in order to facilitate processing and transmission, the host will divide the system image data into multiple smaller data slices according to the specified data length. For example, the specified data length can be 1M. When the system image data is 1024 bytes, 1024 data slices can be obtained.
[0041] S120. Perform hash fragmentation processing on each data shard through the host to generate a digest chain, wherein the digest chain includes a shard sequence number, a digest intermediate value, and a signature of the data shard.
[0042] Hash fragmentation refers to the process of transforming data of any length into a summary value through a hash function. The summary intermediate value refers to a fixed-length value obtained through hash calculation, which is used to represent the characteristics of the original data and can be used to verify the integrity and consistency of the data. The fragment sequence number refers to the unique number assigned to each data fragment, which is used to identify the position and order of the fragment in the overall data. The host can use a hardware security chip to perform hash fragment calculation, which is more secure.
[0043] Optionally, each data shard is hashed and fragmented by the host to generate a summary chain, including: performing hash calculation on each data shard to determine the summary intermediate value of each data shard, and numbering each data shard in sequence to generate each shard serial number; splicing the shard serial number and the summary intermediate value corresponding to each data shard to generate spliced data, and splicing each spliced data according to the shard serial number to generate summary chain main data; using a specified key to sign the summary chain main data to generate a summary chain.
[0044] Among them, the spliced data refers to the new data formed by connecting different data parts such as the fragmentation sequence number and the summary intermediate value. The summary chain main data refers to the main data part composed of spliced data spliced in a certain order. The designated key refers to the secret information used for encryption or signing operations. Only the party with the corresponding key can perform the corresponding encryption or verification operation. The designated key can be an SM2 key. Signature refers to the process of processing data using a key to prove the source and integrity of the data and prevent the data from being tampered with.
[0045] Specifically, each data slice is processed by a specific hash algorithm to obtain a unique summary intermediate value. The summary intermediate value can be used to verify the integrity of the data slice. If the data slice changes during transmission or storage, its summary intermediate value will also change. The host will assign a unique slice serial number to each data slice to identify and distinguish different data slices, so that the corresponding slice can be accurately found and operated in subsequent processing. Then the slice serial number and the corresponding summary intermediate value are combined to form spliced data. Each spliced data includes the identification of a specific data slice (slice serial number) and its integrity verification information (summary intermediate value). The host will connect each spliced data in sequence according to the order of the slice serial number to form the main part of the summary chain, and use the specified key to digitally sign the summary chain main data. Digital signature is a technology used to verify the non-repudiation and integrity of the data source. Only the host with the corresponding private key can generate a valid signature, and the receiver (embedded device) can use the corresponding public key to verify the legitimacy of the signature. The signature in the summary chain can ensure that the source of the summary chain is credible and has not been tampered with.
[0046] It should be noted that the present application is customized and developed in the security chip, and specifically based on the SM3 digest algorithm, the intermediate value generated in the SM3 digest process is output. Exemplarily, for a data block, in the process of calculating its digest value, an intermediate value can be generated according to a specified amount of data, and the specified amount of data can be 1024 bytes, that is, when performing SM3 calculation on the data block, a digest intermediate value can be generated for each 1024 bytes of data calculated, and all the digest intermediate values can be spliced to obtain the digest value of the data block. Therefore, when designing a security chip, the i-1th intermediate digest value can be output, for example, H i-1 =(H1 i-1 +H2 i-1 +H3 i-1 +H4 i-1 +H5 i-1 +H6 i-1 +H7 i-1 +H8 i-1 ), where H i-1 Indicates the intermediate summary value of the i-1th data block, H1 i-1 To H8 i-1 Indicates the intermediate value of each summary. In addition, the i-1 intermediate summary value H (i-1) The i-th block of data is divided into original text M(i) and the i-th intermediate summary value H is output (i) =H (i-1) ±C M (i-1) (H (i-1)). That is, the current block intermediate value is equal to the previous block intermediate value ± the current block original text. At the same time, you can also specify whether the summary calculation is finished, that is, whether the current is the last packet of data. If it is not finished, you can output the i-th intermediate summary value H (i) , if finished, the final summary value SM3_HASH(DATA_M) of the message body can be output.
[0047] In a specific embodiment, Figure 2 This is a schematic diagram of the structure of a summary chain provided according to Embodiment 1 of the present invention. Figure 2 Taking the example of 1024 data shards, the summary chain includes summary chain main data and signature data, where the summary chain main data is composed of the shard sequence number and summary intermediate value of each data shard, and Hash represents the summary intermediate value of the data shard.
[0048] S130. When the verification result of the summary chain is successful, each data shard is read by the embedded device through multi-threading, and the intermediate value verification result of each data shard is determined according to the summary chain.
[0049] Among them, signature verification refers to the process of verifying the legitimacy and validity of the signature. Embedded devices refer to computing devices with specific functions that are embedded in other devices or systems, and have the characteristics of small size and low power consumption.
[0050] Specifically, when the verification result of the summary chain is successful, it means that the summary chain is generated by a legitimate host and has not been tampered with during the transmission process. At this time, the embedded device can use multi-threading to read multiple data shards at the same time. Multi-threading can make full use of the processing power of the device, increase the speed of data reading, and reduce the overall data processing time. By referring to the shard sequence number and summary intermediate value information contained in the summary chain, the embedded device can perform intermediate value verification on each data shard read, that is, the read data shard is hashed again to obtain a new summary intermediate value, and compared with the summary intermediate value of the corresponding shard in the summary chain. If the two are consistent, it means that the data shard is complete and correct.
[0051] Optionally, after the host performs hash fragmentation processing on each data shard to generate a summary chain, the method also includes: obtaining the summary chain through an embedded device, and using a public key to verify the signature of the summary chain to generate a verification result of the summary chain, wherein the verification result includes a successful verification and a failed verification.
[0052] Specifically, the host will first transmit the summary chain to the embedded device, and the embedded device will use the public key to verify the signature of the summary chain. The public key is the key corresponding to the private key used by the host to generate the signature. During the verification process, the embedded device will calculate and compare the signature information in the summary chain. If the signature can be decrypted correctly and the decrypted information matches the data in the summary chain, then the signature verification is considered successful, and the generated signature verification result is a successful signature verification. However, if there is any mismatch or the signature cannot be decrypted correctly during the verification process, it means that the summary chain may have been tampered with during the transmission process, or its source is unreliable. At this time, the embedded device will determine that the signature verification result is a failed signature verification.
[0053] Furthermore, if the signature verification fails, corresponding security measures need to be taken, such as stopping data processing, issuing an alarm, or re-obtaining the summary chain, to prevent possible security risks and data errors.
[0054] Optionally, determining the intermediate value verification result of each data shard according to the summary chain includes: determining the target shard sequence number corresponding to the data shard processed by the current thread; performing hash calculation on the data shard corresponding to the target shard sequence number to determine the data summary value; obtaining the target summary intermediate value corresponding to the target shard sequence number and the historical summary intermediate value corresponding to the previous shard sequence number adjacent to the target shard sequence number from the summary chain; adding the data summary value and the historical summary intermediate value to generate a calculated summary intermediate value; determining the intermediate value verification result of the current thread according to the calculated summary intermediate value and the target summary intermediate value; integrating the intermediate value verification results of each thread to generate an intermediate value verification result of each data shard.
[0055] Specifically, after the signature verification succeeds, the embedded device will read each data shard according to the corresponding offset in multiple threads, and determine the intermediate value verification result of each data shard according to the summary chain. When performing intermediate value verification, the target shard serial number corresponding to the data shard processed by the current thread can be determined, and then the data shard corresponding to the target shard serial number can be hashed to determine the data summary value of the data shard, and the target summary intermediate value corresponding to the target shard serial number and the historical summary intermediate value corresponding to the previous shard serial number adjacent to the target shard serial number are obtained from the summary chain. The embedded device will add the calculated data summary value and the historical summary intermediate value to generate a calculated summary intermediate value, and then determine the intermediate value verification result of the current thread based on the calculated summary intermediate value and the target summary intermediate value.
[0056] In a specific implementation, it is assumed that the summary chain contains a series of summary intermediate values of shards, and each data shard has a unique shard serial number. For the data shard that the current thread is processing, the corresponding target summary intermediate value and the historical summary intermediate value corresponding to the previous shard serial number can be found through its target shard serial number. The summary value obtained by the hash calculation of the current shard is added to the historical summary intermediate value, and the calculated summary intermediate value is compared with the target summary intermediate value. If the verification results of the data shards processed by all threads are integrated without problems, then it can be considered that these data shards are complete and correct and can be used for system image repair and secure startup; if there is a mismatch in the verification results of one or some data shards, these shards need to be further checked and processed, and the data may need to be re-acquired or repaired to ensure the correctness and reliability of the system image.
[0057] For example, there are three data shards, and the shard numbers are 1, 2, and 3. The current thread processes the data shard with shard number 2. First, the summary value of the shard is calculated, and then the target summary intermediate value corresponding to shard number 2 and the historical summary intermediate value corresponding to shard number 1 are obtained from the summary chain. The summary value and the historical summary intermediate value are added to obtain the calculated summary intermediate value, which is compared with the target summary intermediate value to determine the intermediate value verification result of shard 2. Other threads also process their respective shards in a similar manner. Finally, the verification results of all threads are integrated to obtain the overall intermediate value verification results of the three data shards.
[0058] Optionally, determining the intermediate value verification result of the current thread based on the calculated digest intermediate value and the target digest intermediate value includes: judging whether the calculated digest intermediate value and the target digest intermediate value are consistent; if so, determining that the intermediate value verification result of the current thread is a verification success; otherwise, determining that the intermediate value verification result of the current thread is a verification failure.
[0059] Specifically, if the calculated summary intermediate value is consistent with the target summary intermediate value, it indicates that the data slice processed by the current thread maintains integrity and accuracy during the transmission and processing process, and no data changes or damage occur. In this case, it can be determined that the intermediate value verification result of the current thread is successful. However, if the calculated summary intermediate value is inconsistent with the target summary intermediate value, for example, the value of a certain bit is different, or the overall value is deviated, it indicates that the data slice may have a problem in a certain link of transmission, storage or processing, and the data may be tampered with, some information is lost, or other unexpected errors occur. At this time, it can be determined that the intermediate value verification result of the current thread is a verification failure.
[0060] For example, assuming that the calculated digest intermediate value is "10101010", and the target digest intermediate value is also "10101010", then because the two are completely consistent, it is determined that the intermediate value verification of the current thread succeeds. However, if the target digest intermediate value is "11001100", which is different from the calculated value, then it is determined that the intermediate value verification of the current thread fails.
[0061] S140, repairing the system image according to the verification results of each intermediate value through the embedded device to generate repair image data, and performing partition security booting according to the repair image data.
[0062] Specifically, the embedded device can repair the abnormal data slices according to the verification results of each intermediate value and generate the repaired image data. Finally, the partition is safely started according to the repaired image data. During the startup process, the system will load and initialize the image data of each partition according to the predetermined rules and processes, so that the system enters an operational state.
[0063] Optionally, performing partition secure booting according to the repair image data includes: performing summary intermediate value verification on each data slice of the repair image data to generate each intermediate value verification result; when each intermediate value verification result is successfully verified, loading the repair image data to perform partition secure booting.
[0064] Specifically, before the embedded device performs partition security boot based on the repaired image data, it will verify the summary intermediate value of each data shard of the repaired image data again. Verification refers to re-hashing each data shard to obtain a new summary intermediate value. The calculated summary intermediate value is then verified in the same steps as before. If all the intermediate value verification results indicate that the verification is successful, that is, the newly generated summary intermediate value of each data shard is consistent with the summary intermediate value in the summary chain, it indicates that the repaired system image data is correct. At this time, the embedded device will load the repaired image data and perform partition security boot according to the predetermined partition rules and security policies.
[0065] The technical solution of the embodiment of the present invention can improve the speed and efficiency of data transmission by sharding the system image data and transmitting it in blocks. The hash fragmentation process generates a summary chain, which includes the shard sequence number, the intermediate summary value and the signature, which can effectively verify the integrity and authenticity of the data and ensure that the data has not been tampered with during the transmission process. In the event of a transmission anomaly, it is only necessary to retransmit and calculate the abnormal data shard, thereby improving error redundancy; compared with repeating the summary calculation of the system image shards, the summary process is fragmented in the form of summary relay, which greatly reduces the calculation steps, has higher performance and occupies less hardware resources; when the summary relay is used for integrity comparison, it is not necessary to wait for the final summary value of the entire system image data to be calculated before verification, and integrity inconsistencies can be detected early, further improving system performance.
[0066] Embodiment 2
[0067] Figure 3 This is a flowchart of a secure boot method for an embedded system provided in the second embodiment of the present invention. This embodiment adds a specific process of generating repair image data by using an embedded device to repair the system image according to the verification results of each intermediate value on the basis of the above-mentioned first embodiment. Among them, the specific contents of steps S210-S230 are roughly the same as steps S110-S130 in the first embodiment, so they will not be repeated in this embodiment. Figure 3 As shown, the method includes:
[0068] S210 , obtaining system image data to be transmitted through a host, and slicing the system image data according to a specified data length to generate data slices.
[0069] S220. Perform hash fragmentation processing on each data shard through the host to generate a digest chain, wherein the digest chain includes a shard sequence number, a digest intermediate value, and a signature of the data shard.
[0070] Optionally, each data shard is hashed and fragmented by the host to generate a summary chain, including: performing hash calculation on each data shard to determine the summary intermediate value of each data shard, and numbering each data shard in sequence to generate each shard serial number; splicing the shard serial number and the summary intermediate value corresponding to each data shard to generate spliced data, and splicing each spliced data according to the shard serial number to generate summary chain main data; using a specified key to sign the summary chain main data to generate a summary chain.
[0071] S230: When the verification result of the summary chain is successful, each data shard is read by the embedded device through multi-threading, and the intermediate value verification result of each data shard is determined according to the summary chain.
[0072] Optionally, after the host performs hash fragmentation processing on each data shard to generate a summary chain, the method also includes: obtaining the summary chain through an embedded device, and using a public key to verify the signature of the summary chain to generate a verification result of the summary chain, wherein the verification result includes a successful verification and a failed verification.
[0073] Optionally, determining the intermediate value verification result of each data shard according to the summary chain includes: determining the target shard sequence number corresponding to the data shard processed by the current thread; performing hash calculation on the data shard corresponding to the target shard sequence number to determine the data summary value; obtaining the target summary intermediate value corresponding to the target shard sequence number and the historical summary intermediate value corresponding to the previous shard sequence number adjacent to the target shard sequence number from the summary chain; adding the data summary value and the historical summary intermediate value to generate a calculated summary intermediate value; determining the intermediate value verification result of the current thread according to the calculated summary intermediate value and the target summary intermediate value; integrating the intermediate value verification results of each thread to generate an intermediate value verification result of each data shard.
[0074] Optionally, determining the intermediate value verification result of the current thread based on the calculated digest intermediate value and the target digest intermediate value includes: judging whether the calculated digest intermediate value and the target digest intermediate value are consistent; if so, determining that the intermediate value verification result of the current thread is a verification success; otherwise, determining that the intermediate value verification result of the current thread is a verification failure.
[0075] S240: The data shard for which the intermediate value verification result is verification failure is regarded as an abnormal data shard, and the shard sequence number corresponding to the abnormal data shard is regarded as the abnormal shard sequence number.
[0076] S250: Determine the offset address of the system image corresponding to the abnormal shard sequence number.
[0077] Specifically, the embedded device will carry out system image repair work based on each intermediate value verification result and generate corresponding repair image data. Specifically, the data slice that shows the intermediate value verification result as verification failure can be regarded as an abnormal data slice, and the slice sequence number corresponding to the abnormal data slice can be marked as the abnormal slice sequence number. Then, the embedded device flash offset is calculated as the offset address according to the abnormal slice sequence number. Finally, with the help of the image burning tool, starting from the determined offset address, the system image data of the specified data length is burned and regarded as the repair data. The specified data length is determined according to the data slicing.
[0078] S260 , using an image burning tool to burn system image data of a specified data length from an offset address as repair data.
[0079] Specifically, the image burning tool is a tool specifically used to write image data. The image burning tool can start from the determined offset address and burn the system image data of the specified data length as the repair data according to the size and characteristics of the abnormal data fragment.
[0080] S270: Replace the abnormal data fragment with the repair data according to the abnormal fragment sequence number to generate repair mirror data.
[0081] Specifically, the embedded device will replace the abnormal data slice with the repair data just burned according to the abnormal slice sequence number previously determined, thereby generating repaired mirror data, so that the system can resume normal operation and avoid failures or errors caused by data errors.
[0082] S280, performing partition security booting according to the repaired image data.
[0083] Optionally, performing partition secure booting according to the repair image data includes: performing summary intermediate value verification on each data slice of the repair image data to generate each intermediate value verification result; when each intermediate value verification result is successfully verified, loading the repair image data to perform partition secure booting.
[0084] The technical solution of the embodiment of the present invention can determine the offset address according to the abnormal data fragmentation during data recovery, and re-burn and write the corresponding system image, which reduces the number of erases and improves the read and write life of the flash. The partition is safely started using the repaired image data, which ensures the security and stability of the system startup and reduces security risks.
[0085] Embodiment 3
[0086] Figure 4 This is a schematic diagram of the structure of a secure boot device for an embedded system provided by Embodiment 3 of the present invention. Figure 4 As shown, the device includes: a system image data slicing module 310, which is used to obtain the system image data to be transmitted through the host, and to slice the system image data according to the specified data length to generate each data slice;
[0087] A digest chain generation module 320 is used to perform hash fragmentation processing on each data shard through the host to generate a digest chain, wherein the digest chain includes a shard sequence number, a digest intermediate value and a signature of the data shard;
[0088] The data shard intermediate value verification module 330 is used to read each data shard through the embedded device multi-thread when the verification result of the summary chain is successful, and determine the intermediate value verification result of each data shard according to the summary chain;
[0089] The data repair and safe boot module 340 is used to perform system image repair according to the intermediate value verification results through the embedded device to generate repair image data, and perform partition safe boot according to the repair image data.
[0090] Optionally, the summary chain generation module 320 is specifically used to: perform hash calculations on each data shard to determine the summary intermediate value of each data shard, and number each data shard in turn to generate a shard serial number; concatenate the shard serial number and the summary intermediate value corresponding to each data shard to generate concatenated data, and concatenate each concatenated data according to the shard serial number to generate summary chain main data; and use a specified key to sign the summary chain main data to generate a summary chain.
[0091] Optionally, the device also includes: a summary chain verification module, which is used to obtain the summary chain through an embedded device after the host performs hash fragmentation processing on each data shard to generate a summary chain, and use a public key to verify the signature of the summary chain to generate a verification result of the summary chain, wherein the verification result includes a successful verification and a failed verification.
[0092] Optionally, the data shard intermediate value verification module 330 specifically includes: a thread target shard sequence number determination unit, used to: determine the target shard sequence number corresponding to the data shard processed by the current thread; a data summary value determination unit, used to: perform hash calculation on the data shard corresponding to the target shard sequence number to determine the data summary value; a summary intermediate value extraction unit, used to: obtain from the summary chain the target summary intermediate value corresponding to the target shard sequence number and the historical summary intermediate value corresponding to the previous shard sequence number adjacent to the target shard sequence number; add the data summary value and the historical summary intermediate value to generate a calculated summary intermediate value; a thread verification result determination unit, used to: determine the intermediate value verification result of the current thread according to the calculated summary intermediate value and the target summary intermediate value; an intermediate value verification result determination unit, used to: integrate the intermediate value verification results of each thread to generate an intermediate value verification result of each data shard.
[0093] Optionally, the thread verification result determination unit is specifically used to: determine whether the calculated summary intermediate value and the target summary intermediate value are consistent, if so, determine that the intermediate value verification result of the current thread is a verification success; otherwise, determine that the intermediate value verification result of the current thread is a verification failure.
[0094] Optionally, the data repair and secure boot module 340 specifically includes: a data repair unit, used to: treat the data slice whose intermediate value verification result is a verification failure as an abnormal data slice, and treat the slice sequence number corresponding to the abnormal data slice as the abnormal slice sequence number; determine the offset address of the system image corresponding to the abnormal slice sequence number; burn the system image data of a specified data length from the offset address as repair data through an image burning tool; replace the abnormal data slice with the repair data according to the abnormal slice sequence number to generate repair image data.
[0095] Optionally, the data repair and secure boot module 340 specifically includes: a secure boot unit, used to: perform summary intermediate value verification on each data slice of the repair image data to generate each intermediate value verification result; when each intermediate value verification result is successfully verified, load the repair image data to perform partition secure boot.
[0096] The technical solution of the embodiment of the present invention can improve the speed and efficiency of data transmission by sharding the system image data and transmitting it in blocks. The hash fragmentation process generates a summary chain, which includes the shard sequence number, the intermediate summary value and the signature, which can effectively verify the integrity and authenticity of the data and ensure that the data has not been tampered with during the transmission process. In the event of a transmission anomaly, it is only necessary to retransmit and calculate the abnormal data shard, thereby improving error redundancy; compared with repeating the summary calculation of the system image shards, the summary process is fragmented in the form of summary relay, which greatly reduces the calculation steps, has higher performance and occupies less hardware resources; when the summary relay is used for integrity comparison, it is not necessary to wait for the final summary value of the entire system image data to be calculated before verification, and integrity inconsistencies can be detected early, further improving system performance.
[0097] A secure boot device for an embedded system provided by an embodiment of the present invention can execute a secure boot method for an embedded system provided by any embodiment of the present invention, and has functional modules and beneficial effects corresponding to the execution method.
[0098] Embodiment 4
[0099] Figure 5 A schematic diagram of the structure of an electronic device 10 that can be used to implement an embodiment of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital assistants, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or required herein.
[0100] like Figure 5As shown, the electronic device 10 includes at least one processor 11, and a memory connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 to the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0101] A number of components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0102] The processor 11 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 11 executes the various methods and processes described above, such as a secure boot method for an embedded system.
[0103] In some embodiments, a secure boot method for an embedded system may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the secure boot method for an embedded system described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to execute a secure boot method for an embedded system in any other appropriate manner (e.g., by means of firmware).
[0104] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0105] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0106] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in combination with an instruction execution system, device or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0107] To provide interaction with a user, the systems and techniques described herein may be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).
[0108] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.
[0109] A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and server relationship is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services.
[0110] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.
[0111] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A secure boot method for an embedded system, characterized in that: The embedded system comprises: a host and an embedded device, and the method comprises: Acquire system image data to be transmitted through the host, and slice the system image data according to a specified data length to generate data slices; Performing hash fragmentation processing on each of the data shards through a host to generate a digest chain, wherein the digest chain includes a shard sequence number, a digest intermediate value, and a signature of the data shard; When the verification result of the summary chain is successful, each of the data shards is read by the embedded device through multiple threads, and the verification result of the intermediate value of each data shard is determined according to the summary chain; The embedded device performs system image repair according to each of the intermediate value verification results to generate repair image data, and performs partition security boot according to the repair image data.
2. The method according to claim 1, characterized in that The process of performing hash fragmentation processing on each of the data fragments by the host to generate a digest chain includes: Performing hash calculation on each of the data slices to determine the digest intermediate value of each data slice, and sequentially numbering each of the data slices to generate a sequence number for each slice; The fragment sequence number and the digest intermediate value corresponding to each of the data fragments are spliced to generate spliced data, and each spliced data is spliced according to the fragment sequence number to generate the digest chain main body data; The digest chain main data is signed using a designated key to generate a digest chain.
3. The method according to claim 1, characterized in that After the host performs hash fragmentation processing on each of the data shards to generate a digest chain, the method further includes: The summary chain is obtained through an embedded device, and a public key is used to perform signature verification on the summary chain to generate a signature verification result of the summary chain, wherein the signature verification result includes a signature verification success and a signature verification failure.
4. The method according to claim 2, characterized in that: Determining the intermediate value verification result of each data shard according to the summary chain includes: Determine the target shard sequence number corresponding to the data shard processed by the current thread; Perform hash calculation on the data shard corresponding to the target shard sequence number to determine the data summary value; Obtaining from the digest chain a target digest intermediate value corresponding to the target shard sequence number and a historical digest intermediate value corresponding to a previous shard sequence number adjacent to the target shard sequence number; adding the data summary value and the historical summary intermediate value to generate a calculation summary intermediate value; Determine an intermediate value verification result of the current thread according to the calculated digest intermediate value and the target digest intermediate value; The intermediate value verification results of each thread are integrated to generate the intermediate value verification results of each data shard.
5. The method according to claim 4, characterized in that The determining the intermediate value verification result of the current thread according to the calculated digest intermediate value and the target digest intermediate value includes: Determine whether the calculated digest intermediate value is consistent with the target digest intermediate value, and if so, determine that the intermediate value verification result of the current thread is successful; Otherwise, it is determined that the intermediate value verification result of the current thread is verification failure.
6. The method according to claim 1, characterized in that The method of repairing the system image according to the intermediate value verification results by the embedded device to generate the repair image data includes: The data shard for which the intermediate value verification result fails is used as an abnormal data shard, and the shard sequence number corresponding to the abnormal data shard is used as the abnormal shard sequence number; Determine the offset address of the system image corresponding to the abnormal slice sequence number; Burn the system image data of the specified data length from the offset address as the repair data by using an image burning tool; The abnormal data slice is replaced with the repair data according to the abnormal slice sequence number to generate repair mirror data.
7. The method according to claim 6, characterized in that The step of performing partition secure booting according to the repaired image data comprises: Performing summary intermediate value verification on each data slice of the repaired image data to generate each intermediate value verification result; When the verification results of each intermediate value are all successful, the repair image data is loaded to perform partition security boot.
8. A secure boot device for an embedded system, characterized in that: include: A system image data slicing module, used for acquiring the system image data to be transmitted through the host, and slicing the system image data according to the specified data length to generate each data slice; A summary chain generation module, used for performing hash fragmentation processing on each of the data shards through a host to generate a summary chain, wherein the summary chain includes a shard sequence number, a summary intermediate value and a signature of the data shard; The data shard intermediate value verification module is used to read each data shard through the embedded device multi-thread when the verification result of the summary chain is successful, and determine the intermediate value verification result of each data shard according to the summary chain; The data repair and safe boot module is used to perform system image repair according to the intermediate value verification results through an embedded device to generate repair image data, and perform partition safe boot according to the repair image data.
9. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively coupled to the at least one processor; The memory stores a computer program that can be executed by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the method according to any one of claims 1 to 7.
10. A computer storage medium, characterized in that: The computer storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the method according to any one of claims 1 to 7 when executed.
