Method for generating software package, method for flashing and updating software package, and signature method
By chunking the software and mixing it with non-flashing data blocks, and using irreversible and asymmetric algorithms to generate signatures, the problem of insufficient security during the software upgrade process in the prior art is solved, safe flashing and preventing information leakage are achieved, and the security and stability of the system are improved.
Patent Information
- Application Number
- CN202111350757.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-15
- Publication Date
- 2025-08-05
- Estimated Expiration
- 2041-11-15
AI Technical Summary
The existing technology lacks a complete mechanism for safe writing and information leakage during the software upgrade process, resulting in the automotive industry's electronic device firmware being easily reversely analyzed and tampered with, and the system security and reliability are insufficient.
The software is divided into blocks and mixed into non-flash data blocks, and the sub-summary and root digest are generated using an irreversible algorithm. Signing through an asymmetric algorithm, and inserting the signature data into a non-program address segment to achieve safe flashing of signature data sources with non-continuous addresses.
It improves the security and reliability of software packages, effectively prevents information leakage and tampering, and enhances the security of signed data sources.
Smart Images

Figure CN115840944B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of software package generation and flashing, and in particular to a method for generating a software package, a flashing and updating method for a software package, and a signing method. Background Art
[0002] During the software upgrade process or the process of generating a software package, a hash digest is generally calculated for software data blocks with consecutive addresses, and a software signature is generated by calling the signature service and applying a signature algorithm to the hash digest. The software signature is then appended to the end of the program segment to generate a software package for updating and flashing.
[0003] However, the above-mentioned existing technologies cannot meet the requirements for the strength of security protection in certain application scenarios. For example, in the binary firmware of electronic devices in the automotive industry, as a large number of security researchers are deeply studying reverse engineering technology and the security vulnerabilities of automobiles are increasingly attracting the attention of hackers, hackers can easily use reverse engineering technology to test the business logic of the firmware, resulting in information leakage and easy tampering with the firmware, greatly reducing the security and reliability of the system. Summary of the Invention
[0004] The purpose of the embodiments of the present application is to provide a method for generating a software package, a flashing and updating method for a software package, and a signing method, so as to solve the problem of low security and reliability and stability caused by the lack of a complete secure flashing and information leakage prevention mechanism in the prior art.
[0005] An embodiment of the present application provides a method for generating a software package, including:
[0006] Divide the software for updating and flashing into blocks to obtain at least one software data block with a non-continuous address;
[0007] filling non-flash data blocks between at least one software data block;
[0008] An irreversible algorithm is used for each software data block to generate a sub-summary;
[0009] Generate a summary combination table based on the sub-summaries of all software data blocks;
[0010] An irreversible algorithm is used on the summary combination table to generate a root summary;
[0011] An asymmetric algorithm is used on the root digest to generate signature data;
[0012] Through the insertion logic, the signature data is inserted into the address segment of the non-flash data block or the unused address segment to obtain the software package for packaging and release.
[0013] In the above technical solution, the software is divided into blocks and mixed with non-flash data blocks. During flashing, only the software data blocks are flashed to the flash memory, providing a secure flashing mechanism and enhancing the security of the signature data source. Sub-digests are calculated for at least one non-contiguous software data block, and the sub-digests are combined to generate a digest combination table. A root digest is then generated from the digest combination table and signed, thus signing the signature data source for the non-contiguous address. Finally, the signature data is inserted into the non-program address segment, further improving security. In general, the method of this embodiment has a complete secure flashing and information leakage prevention mechanism, which can effectively prevent information leakage and tampering with the software package, greatly improving the security and reliability of the system.
[0014] In some optional implementations, a summary combination table is generated based on the sub-summaries of all software data blocks, including:
[0015] Generates a summary combination table based on the address information, valid data block counts, and sub-summaries of all software data blocks.
[0016] In the above technical solution, the summary combination table, in addition to including the sub-summaries of all software data blocks, also includes the address information and valid data block count of each software data block, so that the root summary generated by the summary combination table further reduces the possibility of software tampering during signature decryption.
[0017] In some optional implementations, the irreversible algorithm uses a hash algorithm, such as the MD5 algorithm, the SHA256 algorithm, etc.
[0018] In the above technical solution, the MD5 algorithm and SHA256 algorithm used are both highly reliable and irreversible in encryption, and can realize encryption of any object.
[0019] In some optional implementations, a digest combination table is generated based on the address information, valid data block counts, and sub-digests of all software data blocks, including:
[0020] The address information, valid data block count and sub-summary of each software data block are concatenated respectively and summarized to obtain a summary combination table.
[0021] In the above technical solution, the address information, valid data block count and sub-digest of the software data block are combined in the simplest splicing method to generate a digest combination table, so that the root digest generated by the digest combination table can further reduce the possibility of software tampering when the signature is decrypted.
[0022] An embodiment of the present application provides a method for flashing and updating a software package, comprising:
[0023] Write all software data blocks in the software package into the designed address segment;
[0024] An irreversible algorithm is used for each software data block to generate the actual sub-digest;
[0025] Generate an actual summary combination table based on all actual sub-summaries;
[0026] An irreversible algorithm is used on the actual summary combination table to generate the actual root summary;
[0027] Obtain the address information of the signature data in the software package through the insertion logic adopted in the signature method;
[0028] Obtain the signature data according to the address information of the signature data in the software package, and parse the signature data to obtain the root digest for verification;
[0029] Compare the actual root digest with the root digest used for verification to see if they are consistent: if so, the flash update is completed; otherwise, the flash update fails.
[0030] In the above technical solution, during flashing, only the software data blocks at the non-contiguous addresses used for updating and flashing within the software package are flashed to the flash memory, providing a secure flashing mechanism and enhancing the security of the signature data source. Actual sub-digests are calculated for each of the at least one non-contiguous software data block, and these sub-digests are combined to generate an actual digest combination table. The actual root digest is then generated from the actual digest combination table, and finally, the actual root digest signature is compared with the root digest used for verification. This method, with its comprehensive secure flashing and information leakage prevention mechanisms, effectively prevents information leakage and software package tampering, significantly improving system security and reliability.
[0031] In some optional implementations, an actual summary combination table is generated based on all actual sub-summaries, including:
[0032] An actual summary combination table is generated based on the address information of all software data blocks, valid data block counts, and actual sub-summaries.
[0033] In the above technical solution, the actual summary combination table includes not only the actual sub-digests of all software data blocks, but also the actual address information and actual valid data block count of each software data block, so that when the actual root summary signature is compared with the root summary used for verification, the possibility of software tampering is further reduced.
[0034] In some optional implementations, the irreversible algorithm uses a hash algorithm, such as the MD5 algorithm or the SHA256 algorithm.
[0035] In the above technical solution, the MD5 algorithm and SHA256 algorithm used are both highly reliable and irreversible in encryption, and can realize encryption of any object.
[0036] An embodiment of the present application provides a signature method for updating and flashing software, including:
[0037] Divide the software for updating and flashing into blocks to obtain at least one software data block with a non-continuous address;
[0038] filling non-flash data blocks between at least one software data block;
[0039] An irreversible algorithm is used for each software data block to generate a sub-summary;
[0040] Generate a summary combination table based on the sub-summaries of all software data blocks;
[0041] An irreversible algorithm is used on the summary combination table to generate a root summary;
[0042] An asymmetric algorithm is used on the root digest to generate signature data.
[0043] In the above technical solution, the software is divided into blocks and mixed with non-flashed data blocks. During flashing, only the software data blocks are written to the flash memory, providing a secure flashing mechanism and enhancing the security of the signature data source. Subdigests are calculated for at least one non-contiguous software data block, combined to form a digest combination table. A root digest is then generated from the digest combination table and signed, enabling the signature of signature data sources with non-contiguous addresses. The method of this embodiment provides a comprehensive secure flashing and information leakage prevention mechanism, effectively preventing information leakage and software package tampering, significantly improving the security, reliability and stability of the system.
[0044] An electronic device provided in an embodiment of the present application includes: a processor and a memory, wherein the memory stores machine-readable instructions executable by the processor, and when the machine-readable instructions are executed by the processor, any of the above methods is performed.
[0045] An embodiment of the present application provides an apparatus for generating a software package, comprising:
[0046] A block division module is used to divide the software for updating and flashing into blocks to obtain at least one software data block with a non-continuous address;
[0047] A filling module, configured to fill non-flash data blocks between at least one software data block;
[0048] A sub-summary module, configured to generate a sub-summary for each software data block using an irreversible algorithm;
[0049] A combination module, used for generating a summary combination table according to the sub-summaries of all software data blocks;
[0050] A root summary module is used to generate a root summary by applying an irreversible algorithm to the summary combination table;
[0051] A signature module, used to generate signature data by applying an asymmetric algorithm to the root digest;
[0052] The signature insertion module is used to insert the signature data into the address segment of the non-flash data block or the unused address segment through the insertion logic to obtain the software package for packaging and release.
[0053] In the above-mentioned technical solution, a device for generating a software package in this embodiment utilizes a block partitioning module and a padding module to partition the software into blocks and intermix non-flashable data blocks. During flashing, only the software data blocks are flashed to the flash memory, providing a secure flashing mechanism and enhancing the security of the signature data source. A sub-digest module, a combination module, a root digest module, and a signature module are used to calculate sub-digests for at least one non-contiguous software data block. The sub-digests are then combined to generate a digest combination table. A root digest is then generated from the digest combination table and signed, thus enabling the signature data source of non-contiguous addresses to be signed. Finally, a signature insertion module is used to insert signature data into non-program address segments, further enhancing security.
[0054] In some optional embodiments, the combination module is further configured to:
[0055] Generates a summary combination table based on the address information, valid data block counts, and sub-summaries of all software data blocks.
[0056] In the above technical solution, the summary combination table generated by the combination module includes not only the sub-digests of all software data blocks, but also the address information and valid data block count of each software data block, so that the root summary generated by the summary combination table further reduces the possibility of software tampering during signature decryption.
[0057] An embodiment of the present application provides a flash update device for a software package, comprising:
[0058] A writing module is used to write all software data blocks in the software package into the designed address segment;
[0059] An actual sub-summary module, configured to generate an actual sub-summary for each software data block using an irreversible algorithm;
[0060] An actual combination module, used for generating an actual summary combination table according to all actual sub-summaries;
[0061] An actual root summary module, configured to generate an actual root summary by applying an irreversible algorithm to the actual summary combination table;
[0062] An address acquisition module, used to obtain the address information of the signature data in the software package through the insertion logic adopted in the signature method;
[0063] The decryption module is used to obtain the signature data according to the address information of the signature data in the software package, and parse the signature data to obtain the root digest for verification;
[0064] The comparison module is used to compare whether the actual root digest is consistent with the root digest used for verification: if so, the flash update is completed; if not, the flash update fails.
[0065] In the above-mentioned technical solution, a software package flashing and updating device of this embodiment utilizes a writing module to flash software data blocks at non-contiguous addresses in the software package for flashing and updating to a flash memory, providing a secure flashing mechanism and enhancing the security of the signature data source. The actual sub-digest module, the actual combination module, and the actual root digest module are used to calculate actual sub-digests for at least one non-contiguous software data block, combine the actual sub-digests to generate an actual digest combination table, and then generate an actual root digest from the actual digest combination table. The decryption module is used to obtain a root digest for verification. Finally, the comparison module is used to compare the actual root digest signature with the root digest for verification, effectively preventing information leakage and tampering with the software package, thereby significantly improving the security, reliability, and stability of the system.
[0066] In some optional implementations, the actual combination module is further configured to:
[0067] An actual summary combination table is generated based on the address information of all software data blocks, valid data block counts, and actual sub-summaries.
[0068] In the above technical solution, the actual summary combination table generated by the actual combination module includes, in addition to the actual sub-digests of all software data blocks, the actual address information and the actual valid data block count of each software data block, so that when the actual root summary signature is compared with the root summary used for verification, the possibility of software tampering is further reduced.
[0069] In summary, the present application provides a method for generating a software package, a flash update method for the software package, and a signature method. The software is divided into blocks and mixed with non-flash data blocks. During flashing, only the software data blocks are flashed to the flash memory, providing a secure flashing mechanism and enhancing the security of the signature data source. Sub-digests are calculated for at least one non-continuous software data block, and the sub-digests are combined to generate a digest combination table. A root digest is then generated for the digest combination table, and the root digest is signed, thus realizing the signature of the signature data source of the non-continuous address. Finally, the signature data is inserted into the non-program address segment, further improving security. The method provided by the present application has a complete secure flashing and anti-information leakage mechanism, which can effectively prevent information leakage and tampering with the software package, greatly improving the security and reliability of the system. BRIEF DESCRIPTION OF THE DRAWINGS
[0070] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments of the present application. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other relevant drawings can be obtained based on these drawings without creative work.
[0071] Figure 1 A flowchart of the steps of a method for generating a software package provided in an embodiment of the present application;
[0072] Figure 2 A schematic diagram of a possible structure of at least one software data block with non-contiguous addresses provided in an embodiment of the present application;
[0073] Figure 3 A flowchart of the steps of a flash update method for a software package provided in an embodiment of the present application;
[0074] Figure 4 A flowchart of the steps of a signature method for updating and flashing software provided in an embodiment of the present application;
[0075] Figure 5 A schematic diagram of a preferred structure of an electronic device provided in an embodiment of the present application;
[0076] Figure 6 A functional module diagram of a device for generating a software package provided in an embodiment of the present application;
[0077] Figure 7 This is a functional module diagram of a flash update device for a software package provided in an embodiment of the present application.
[0078] Icons: 11-processor, 12-memory, 13-communication interface, 14-communication bus, 21-blocking module, 22-filling module, 23-sub-digest module, 24-combination module, 25-root digest module, 26-signature module, 27-insert signature module, 31-write module, 32-actual sub-digest module, 33-actual combination module, 34-actual root digest module, 35-address acquisition module, 36-decryption module, 37-comparison module. DETAILED DESCRIPTION
[0079] The technical solutions in the embodiments of the present application will be described below in conjunction with the drawings in the embodiments of the present application.
[0080] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those skilled in the art to which this application belongs; the terms used herein are only for the purpose of describing specific embodiments and are not intended to limit this application; the terms "including" and "having" and any variations thereof in the specification and claims of this application and the above-mentioned figure descriptions are intended to cover non-exclusive inclusions.
[0081] In the description of the embodiments of this application, the technical terms "first" and "second" are used only to distinguish different objects and should not be understood to indicate or imply relative importance or implicitly specify the quantity, specific order, or primary and secondary relationship of the indicated technical features. In the description of the embodiments of this application, the meaning of "plurality" is more than two, unless otherwise clearly and specifically defined.
[0082] References herein to "embodiments" mean that a particular feature, structure, or characteristic described in connection with the embodiments may be included in at least one embodiment of the present application. The appearance of this phrase in various places in the specification does not necessarily refer to the same embodiment, nor does it constitute an independent or alternative embodiment that is mutually exclusive of other embodiments. It is understood, both explicitly and implicitly, by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0083] In the description of the embodiments of the present application, the term "and / or" is merely a description of the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B may represent three situations: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the previous and subsequent associated objects are in an "or" relationship. In the description of the embodiments of the present application, the term "multiple" refers to more than two (including two). Similarly, "multiple groups" refers to more than two groups (including two groups), and "multiple pieces" refers to more than two pieces (including two pieces).
[0084] In the description of the embodiments of the present application, unless otherwise expressly specified or limited, technical terms such as "installed," "connected," "connected," and "fixed" should be understood in a broad sense. For example, they can refer to fixed connections, detachable connections, or integration; mechanical connections or electrical connections; direct connections or indirect connections through an intermediate medium; internal connections between two components or interactions between two components. Those skilled in the art can understand the specific meanings of the above terms in the embodiments of the present application based on specific circumstances.
[0085] At present, the existing software upgrade process generally calculates the summary of software data blocks with consecutive addresses, generates a software signature by calling the signature service using the signature algorithm on the summary, and appends the software signature to the end of the program segment to generate a software package for updating and flashing.
[0086] In order to ensure the calculation of the complete program segment summary, the signature information is attached to the program header or tail, which has regularity and can be deduced from the signature data segment through the signature algorithm. Therefore, it is difficult to avoid illegal flashing. To this end, the applicant found that the software used for updating and flashing can be divided into blocks and non-flash data blocks can be mixed between the software data blocks to provide a secure flashing mechanism to improve security. However, when signing the software, the existing technology will flash the non-flash data blocks to delete them, and it is impossible to sign the software data blocks with non-continuous addresses obtained by software segmentation. In addition, if the existing technology is used to sign each software data block separately, a large amount of signature data will be generated, and the storage space of the electronic control unit is limited. There is not enough space to store the independently calculated signature data. At the same time, a large number of signature generation and signature verification processes will cause the electronic control unit program update process to seriously time out, and it is impossible to meet the time requirement for the first frame message of the electronic control unit to be sent.
[0087] Based on the above considerations, in order to improve security and solve the problem of limited space for storing independently calculated signature data, the inventors conducted in-depth research and provided a method for generating a software package, a flashing and updating method for the software package, and a signing method for software package segmentation and obfuscation of non-flashed data blocks.
[0088] The embodiments disclosed in this application are applicable to various situations of software flashing and updating, including but not limited to binary firmware of electronic devices in the automotive industry.
[0089] Please refer to Figure 1 , Figure 1 A flowchart of the steps of a method for generating a software package provided in an embodiment of the present application specifically includes:
[0090] Step 101: Divide the software for updating and flashing into blocks to obtain at least one software data block with a non-continuous address;
[0091] Step 102: Fill non-flash data blocks between at least one software data block;
[0092] Step 103: Generate a sub-digest for each software data block using an irreversible algorithm;
[0093] Step 104: Generate a summary combination table based on the sub-summaries of all software data blocks;
[0094] Step 105: Use an irreversible algorithm on the digest combination table to generate a root digest;
[0095] Step 106: Use an asymmetric algorithm on the root digest to generate signature data;
[0096] Step 107: Insert the signature data into the address segment of the non-flash data block or the unused address segment through the insertion logic to obtain a software package for packaging and publishing.
[0097] Among them, the software data block is a data block obtained by dividing the software blocks used for updating and flashing. The non-flash data block is a padded data block that is not used for updating and flashing, and the non-flash data block can also be empty. The irreversible algorithm does not require the use of a key in the encryption process. After the plaintext is input, the system directly processes it into ciphertext through the encryption algorithm. This encrypted data cannot be decrypted. Only when the plaintext is re-entered and processed again by the same irreversible encryption algorithm, the same encrypted ciphertext is obtained and it is re-identified by the system, can it be truly decrypted. The sub-summary is the summary information obtained by encrypting each software data block using an irreversible algorithm. The root digest is the summary information obtained by encrypting the summary combination table using an irreversible algorithm. The summary combination table is a table composed of the sub-summaries of all software data blocks. The asymmetric algorithm is a method for keeping the key confidential. The signature data is a string of numbers that can only be generated by the sender of the information and cannot be forged by others. This string of numbers is also a valid proof of the authenticity of the information sent by the sender.
[0098] In the embodiment of the present application, the software is divided into blocks and mixed with non-flash data blocks, that is, Figure 2 At least one software data block of the non-contiguous addresses of the example, according to Figure 2As shown, the addresses of multiple software data blocks are discontinuous, and non-flash data blocks can be filled between two software data blocks. Non-flash data blocks may not be filled between some software data blocks. The signature data can be inserted into the address segment of the non-flash data block, or into an unused address segment. During flashing, only the software data blocks are flashed to the flash memory, which provides a secure flashing mechanism and enhances the security of the signature data source. Sub-digests are calculated for at least one non-continuous software data block, and the sub-digests are combined to generate a summary combination table. A root digest is generated for the summary combination table, and the root digest is signed to implement the signature of the signature data source of the non-continuous address. Finally, the signature data is inserted into the non-program address segment to further improve security. In general, the method of this embodiment has a complete secure flashing and anti-information leakage mechanism, which can effectively prevent information leakage and tampering with the software package, greatly improving the security and reliability of the system.
[0099] In some optional embodiments, generating a digest combination table based on the sub-digests of all software data blocks includes generating the digest combination table based on the address information, valid data block count, and sub-digests of all software data blocks, wherein the address information is the starting address and data length of the software data block, and the valid data block count is the count information of the software data blocks.
[0100] In the embodiment of the present application, the summary combination table includes, in addition to the sub-summaries of all software data blocks, the address information and valid data block count of each software data block. The address information, valid data block count and sub-summary are combined into a summary combination table through an arbitrary algorithm, so that the root summary generated by the summary combination table further reduces the possibility of software tampering when the signature is decrypted.
[0101] In some optional implementations, the address information, the valid data block count, and the sub-digest are combined into a digest combination table, and a splicing method may be used, including but not limited to the following splicing methods:
[0102] The first concatenation method combines the address information, valid block count, and sub-digest of each software data block to generate a summary combination table. Table 1 shows the summary combination table obtained in this embodiment for three software data blocks. A1, A2, and A3 represent the address information of the three software data blocks, B1, B2, and B3 represent the valid block counts of the three software data blocks, and C1, C2, and C3 represent the sub-digests of the three software data blocks.
[0103] Table 1. Summary combination table obtained by the first splicing method
[0104] <![CDATA[A1 B1 C1]]> <![CDATA[A2 B2 C2]]> <![CDATA[A3 B3 C3]]>
[0105] The second concatenation method: For all software data blocks, the three categories of information, address information, valid data block count, and sub-summaries, are concatenated and summarized into a summary combination table. Table 2 shows the summary combination table obtained in this embodiment for three software data blocks. A1, A2, and A3 represent the address information of the three software data blocks, B1, B2, and B3 represent the valid data block counts of the three software data blocks, and C1, C2, and C3 represent the sub-summaries of the three software data blocks.
[0106] Table 2. Summary combination table obtained by the second splicing method
[0107] <![CDATA[A1 A2 A3]]> <![CDATA[B1 B2 B3]]> <![CDATA[C1 C2 C3]]>
[0108] In the above technical solution, the address information, valid data block count and sub-digest of the software data block are combined in the simplest splicing method to generate a digest combination table, so that the root digest generated by the digest combination table can further reduce the possibility of software tampering when the signature is decrypted.
[0109] In some optional implementations, the irreversible algorithm uses a hash algorithm, such as the MD5 algorithm, the SHA256 algorithm, etc. In the embodiment of the present application, the MD5 algorithm and the SHA256 algorithm used are both highly reliable and irreversible in encryption, and can achieve encryption of any object.
[0110] Please refer to Figure 3 , Figure 3 A flowchart of the steps of a flash update method for a software package provided in an embodiment of the present application specifically includes:
[0111] Step 201: Write all software data blocks in the software package into the designed address segment;
[0112] Step 202: Using an irreversible algorithm for each software data block, generate an actual sub-digest;
[0113] Step 203: Generate an actual summary combination table based on all actual sub-summaries;
[0114] Step 204: Using an irreversible algorithm on the actual digest combination table to generate an actual root digest;
[0115] Step 205: Obtain the address information of the signature data in the software package through the insertion logic used in the signature method;
[0116] Step 206: Obtain the signature data according to the address information of the signature data in the software package, and parse the signature data to obtain a root digest for verification;
[0117] Step 207: Compare the actual root digest with the root digest used for verification to see if they are consistent: if so, the flash update is completed; if not, the flash update fails.
[0118] In an embodiment of the present application, during flashing, only the software data blocks at the non-continuous addresses used for updating the flashing in the software package are flashed to the flash memory, providing a secure flashing mechanism and enhancing the security of the signature data source. Actual sub-digests are calculated for each of the at least one non-continuous software data blocks, and the actual sub-digests are combined to generate an actual digest combination table. The actual root digest is then generated from the actual digest combination table. Finally, the actual root digest signature is compared with the root digest used for verification. If they are inconsistent, a negative response is fed back, requiring the flashing process to be restarted. The method of this embodiment has a comprehensive secure flashing and information leakage prevention mechanism, which can effectively prevent information leakage and tampering with the software package, greatly improving the security and reliability of the system.
[0119] In some optional implementations, generating an actual digest combination table according to all actual sub-digests includes generating an actual digest combination table according to address information of all software data blocks, valid data block counts, and actual sub-digests.
[0120] In the embodiment of the present application, the actual digest combination table includes, in addition to the actual sub-digests of all software data blocks, the actual address information and the actual valid data block count of each software data block. The actual digest combination table is obtained using the same algorithm used to generate the combined address information, valid data block count, and sub-digests of the software package. This further reduces the possibility of software tampering when the actual root digest signature is compared with the root digest used for verification.
[0121] In some optional implementations, the irreversible algorithm uses a hash algorithm, such as the MD5 algorithm or the SHA256 algorithm. In the embodiments of the present application, the MD5 algorithm and the SHA256 algorithm used are both highly reliable and irreversible in encryption, and can achieve the characteristics of encrypting any object.
[0122] Please refer to Figure 4 , Figure 4 A flowchart of a signing method for updating and flashing software provided in an embodiment of the present application includes:
[0123] Step 301: Divide the software for updating and flashing into blocks to obtain at least one software data block with a non-continuous address;
[0124] Step 302: Fill non-flash data blocks between at least one software data block;
[0125] Step 303: Generate a sub-digest for each software data block using an irreversible algorithm;
[0126] Step 304: Generate a summary combination table based on the sub-summaries of all software data blocks;
[0127] Step 305: Use an irreversible algorithm on the digest combination table to generate a root digest;
[0128] Step 306: Use an asymmetric algorithm on the root digest to generate signature data.
[0129] In this embodiment, the software is divided into blocks and intermixed with non-flashable data blocks. During flashing, only the software blocks are written to the flash memory, providing a secure flashing mechanism and enhancing the security of the signature data source. Subdigests are calculated for at least one non-contiguous software data block, combined to form a digest combination table. A root digest is then generated from the digest combination table and signed, enabling the signature of a signature data source with non-contiguous addresses. This method provides a comprehensive secure flashing and information leakage prevention mechanism, effectively preventing information leakage and software package tampering, significantly improving the security, reliability, and stability of the system.
[0130] Figure 5 A possible structure of the electronic device provided by the embodiment of the present application is shown. Figure 5 The electronic device includes: a processor 11, a memory 12 and a communication interface 13. These components are interconnected and communicate with each other through a communication bus 14 and / or other forms of connection mechanisms (not shown).
[0131] The memory 12 includes one or more (only one is shown in the figure), which can be, but is not limited to, random access memory (RAM), read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), etc. The processor 11 and other possible components can access the memory 12 and read and / or write data therein.
[0132] The processor 11 includes one or more (only one is shown in the figure), which can be an integrated circuit chip with signal processing capabilities. The above-mentioned processor 11 can be a general-purpose processor, including a central processing unit (CPU), a micro control unit (MCU), a network processor (NP) or other conventional processors; it can also be a special-purpose processor, including a neural network processor (NPU), a graphics processing unit (GPU), a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. Moreover, when there are multiple processors 11, some of them can be general-purpose processors and the other part can be special-purpose processors.
[0133] The communication interface 13 includes one or more (only one is shown in the figure) interfaces, which can be used to communicate directly or indirectly with other devices to exchange data. The communication interface 13 can include interfaces for wired and / or wireless communication.
[0134] One or more computer program instructions may be stored in the memory 12 , and the processor 11 may read and execute these computer program instructions to implement the method provided in the embodiment of the present application.
[0135] Understandably, Figure 4 The structure shown is only for illustration, and the electronic device may also include Figure 4 More or fewer components than shown, or with Figure 4 Different structures are shown. Figure 4 The components shown in the figure can be implemented using hardware, software, or a combination thereof. The electronic device can be a physical device, such as a PC, laptop, tablet, mobile phone, server, embedded device, etc., or a virtual device, such as a virtual machine or virtualized container. Furthermore, the electronic device is not limited to a single device and can also be a combination of multiple devices or a cluster consisting of a large number of devices.
[0136] The present application also provides a computer-readable storage medium having computer program instructions stored thereon. When the computer program instructions are read and executed by a computer processor, the method provided by the present application is executed. For example, the computer-readable storage medium can be implemented as Figure 5 The memory 12 in the electronic device.
[0137] Please refer to Figure 6 , Figure 6 A functional module diagram of a device for generating a software package provided in an embodiment of the present application includes a block segmentation module 21, a filling module 22, a sub-digest module 23, a combination module 24, a root digest module 25, a signature module 26 and an insertion signature module 27.
[0138] Among them, the block module 21 is used to: divide the software for updating and flashing into blocks to obtain at least one software data block with non-continuous addresses. The filling module 22 is used to fill non-flash data blocks between at least one software data block. The sub-summary module 23 is used to generate a sub-summary for each software data block using an irreversible algorithm. The combination module 24 is used to generate a summary combination table based on the sub-summaries of all software data blocks. The root summary module 25 is used to generate a root summary using an irreversible algorithm for the summary combination table. The signature module 26 is used to generate signature data using an asymmetric algorithm for the root summary. The signature insertion module 27 is used to insert the signature data into the address segment or unused address segment of the non-flash data block through insertion logic to obtain a software package for packaging and release.
[0139] In an embodiment of the present application, a device for generating a software package utilizes a block splitting module 21 and a padding module 22 to split the software into blocks and mix in non-flashable data blocks. During flashing, only the software data blocks are flashed to the flash memory, providing a secure flashing mechanism and enhancing the security of the signature data source. Sub-digests are calculated for at least one non-contiguous software data block using a sub-digest module 23, a combination module 24, a root digest module 25, and a signature module 26. These sub-digests are combined to generate a digest combination table, which is then used to generate a root digest. This root digest is then signed, thus enabling the signature of a signature data source with non-contiguous addresses. Finally, a signature insertion module 27 inserts the signature data into a non-program address segment, further enhancing security.
[0140] In some optional implementations, the combining module 24 is further configured to generate a summary combination table according to the address information, valid data block counts, and sub-summaries of all software data blocks.
[0141] In the embodiment of the present application, the summary combination table generated by the combination module 24 includes, in addition to the sub-digests of all software data blocks, the address information and valid data block count of each software data block, so that the root summary generated by the summary combination table further reduces the possibility of software tampering when the signature is decrypted.
[0142] Please refer to Figure 7 , Figure 7 This is a functional module diagram of a flash update device for a software package provided in an embodiment of the present application, including a writing module 31, an actual sub-digest module 32, an actual combination module 33, an actual root digest module 34, an address acquisition module 35, a decryption module 36 and a comparison module 37.
[0143] Among them, the writing module 31 is used to write all software data blocks in the software package into the designed address segment. The actual sub-digest module 32 is used to generate the actual sub-digest for each software data block using an irreversible algorithm. The actual combination module 33 is used to generate the actual digest combination table based on all actual sub-digests. The actual root digest module 34 is used to generate the actual root digest using an irreversible algorithm on the actual digest combination table. The address acquisition module 35 is used to obtain the address information of the signature data in the software package through the insertion logic used in the signature method. The decryption module 36 is used to obtain the signature data based on the address information of the signature data in the software package, and parse the signature data to obtain the root digest for verification. The comparison module 37 is used to compare whether the actual root digest is consistent with the root digest used for verification: if so, the flash update is completed; if not, the flash update fails.
[0144] In an embodiment of the present application, a flash update device for a software package of this embodiment utilizes a write module 31 to flash software data blocks at non-continuous addresses in the software package for flashing to a flash memory, providing a secure flashing mechanism and enhancing the security of the signature data source. The actual sub-digest module 32, the actual combination module 33, and the actual root digest module 34 are utilized to calculate actual sub-digests for at least one non-continuous software data block, and the actual sub-digests are combined to generate an actual digest combination table, and then the actual root digest is generated from the actual digest combination table. The root digest for verification is obtained using a decryption module 36. Finally, the actual root digest signature is compared with the root digest for verification using a comparison module 37, effectively preventing information leakage and tampering with the software package, thereby greatly improving the security and reliability of the system.
[0145] In some optional implementations, the actual combination module 33 is further configured to generate an actual digest combination table according to the address information of all software data blocks, the valid data block count, and the actual sub-digests.
[0146] In the embodiment of the present application, the actual summary combination table generated by the actual combination module 33 includes, in addition to the actual sub-digests of all software data blocks, the actual address information and the actual valid data block count of each software data block, so that when the actual root summary signature is compared with the root summary used for verification, the possibility of software tampering is further reduced.
[0147] In the embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interface, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0148] In addition, the units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0149] Furthermore, the functional modules in each embodiment of the present application can be integrated together to form an independent part, or each module can exist independently, or two or more modules can be integrated to form an independent part.
[0150] In this document, relational terms such as first and second, etc. are used merely to distinguish one entity or operation from another entity or operation, but do not necessarily require or imply any actual relationship or order between these entities or operations.
[0151] The above description is merely an embodiment of the present application and is not intended to limit the scope of protection of the present application. For those skilled in the art, various modifications and variations of the present application are possible. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application shall be included in the scope of protection of the present application.
Claims
1. A method for generating a software package, characterized in that: include: Divide the software for updating and flashing into blocks to obtain at least one software data block with a non-continuous address; filling non-flash data blocks between at least one software data block; An irreversible algorithm is used for each software data block to generate a sub-summary; Generate a summary combination table based on the sub-summaries of all software data blocks; Generates summary combination tables based on the sub-summaries of all software data blocks, including: Separately concatenate the address information, valid data block count, and sub-summary of each software data block, and summarize them to obtain a summary combination table; An irreversible algorithm is used on the summary combination table to generate a root summary; Applying an asymmetric algorithm to the root digest to generate signature data; and Inserting the signature data into an address segment of a non-flash data block or an unused address segment through insertion logic to obtain a software package for packaging and publishing; The software data block is a data block obtained by dividing the software into blocks for updating and flashing. The non-flash data block is a padded data block that is not used for updating and flashing. The irreversible algorithm encryption process does not use a key. The encrypted data cannot be decrypted. The plaintext is re-entered and processed again by the irreversible encryption algorithm to obtain the same encrypted ciphertext and be re-recognized by the system before it can be decrypted. The sub-digest is the summary information obtained by encrypting each software data block using the irreversible algorithm. The root digest is the summary information obtained by encrypting the digest combination table using the irreversible algorithm. The digest combination table is a table composed of the sub-summaries of all software data blocks. The signature data is a string of numbers generated by the sender of the information that cannot be forged. The software is divided into blocks and mixed with non-flash data blocks to obtain at least one software data block with a non-continuous address. The addresses of multiple software data blocks are discontinuous, and non-flash data blocks are filled between two software data blocks. Signature data can be inserted into the address segment of the non-flash data block or into an unused address segment. During flashing, only the software data blocks are flashed to the flash memory, sub-digests are calculated for the at least one non-continuous software data block, and the sub-digests are combined to generate a digest combination table. A root digest is generated for the digest combination table, the root digest is signed, and the signature data is inserted into the non-program address segment.
2. The method according to claim 1, wherein The summary combination table is generated based on the sub-summaries of all software data blocks, including: Generates a summary combination table based on the address information, valid data block counts, and sub-summaries of all software data blocks.
3. The method according to claim 1, wherein The irreversible algorithm adopts a hash algorithm.
4. A flash update method for a software package, characterized in that: include: Write all software data blocks in the software package into the designed address segment; An irreversible algorithm is used for each software data block to generate the actual sub-digest; Generate an actual summary combination table based on all actual sub-summaries; Generates a table of actual summary combinations based on all actual sub-summaries, including: Separately concatenate the address information, valid data block count, and sub-summary of each software data block, and summarize them to obtain a summary combination table; An irreversible algorithm is used on the actual summary combination table to generate the actual root summary; Obtain the address information of the signature data in the software package through the insertion logic adopted in the signature method; Obtaining the signature data according to the address information of the signature data in the software package, and parsing the signature data to obtain a root digest for verification; and Compare the actual root digest with the root digest used for verification to see if they are consistent: if so, the flash update is completed; if not, the flash update fails; The software data block is a data block obtained by dividing the software into blocks for updating and flashing. The non-flash data block is a padded data block that is not used for updating and flashing. The irreversible algorithm encryption process does not use a key. The encrypted data cannot be decrypted. The plaintext is re-entered and processed again by the irreversible encryption algorithm to obtain the same encrypted ciphertext and be re-recognized by the system before it can be decrypted. The sub-digest is the summary information obtained by encrypting each software data block using the irreversible algorithm. The root digest is the summary information obtained by encrypting the digest combination table using the irreversible algorithm. The digest combination table is a table composed of the sub-summaries of all software data blocks. The signature data is a string of numbers generated by the sender of the information that cannot be forged. The software is divided into blocks and mixed with non-flash data blocks to obtain at least one software data block with a non-continuous address. The addresses of multiple software data blocks are discontinuous, and non-flash data blocks are filled between two software data blocks. Signature data can be inserted into the address segment of the non-flash data block or into an unused address segment. During flashing, only the software data blocks are flashed to the flash memory, sub-digests are calculated for the at least one non-continuous software data block, and the sub-digests are combined to generate a digest combination table. A root digest is generated for the digest combination table, the root digest is signed, and the signature data is inserted into the non-program address segment.
5. The method according to claim 4, wherein According to all the actual sub-abstracts, an actual summary combination table is generated, including: An actual summary combination table is generated based on the address information of all software data blocks, valid data block counts, and actual sub-summaries.
6. A signature method for updating flashed software, characterized in that: include: Divide the software for updating and flashing into blocks to obtain at least one software data block with a non-continuous address; filling non-flash data blocks between at least one software data block; An irreversible algorithm is used for each software data block to generate a sub-summary; Generate a summary combination table based on the sub-summaries of all software data blocks; Generates summary combination tables based on the sub-summaries of all software data blocks, including: Separately concatenate the address information, valid data block count, and sub-summary of each software data block, and summarize them to obtain a summary combination table; Applying an irreversible algorithm to the digest combination table to generate a root digest; and An asymmetric algorithm is used on the root digest to generate signature data; The software data block is a data block obtained by dividing the software into blocks for updating and flashing. The non-flash data block is a padded data block that is not used for updating and flashing. The irreversible algorithm encryption process does not use a key. The encrypted data cannot be decrypted. The plaintext is re-entered and processed again by the irreversible encryption algorithm to obtain the same encrypted ciphertext and be re-recognized by the system before it can be decrypted. The sub-digest is the summary information obtained by encrypting each software data block using the irreversible algorithm. The root digest is the summary information obtained by encrypting the digest combination table using the irreversible algorithm. The digest combination table is a table composed of the sub-summaries of all software data blocks. The signature data is a string of numbers generated by the sender of the information that cannot be forged. The software is divided into blocks and mixed with non-flash data blocks to obtain at least one software data block with a non-continuous address. The addresses of multiple software data blocks are discontinuous, and non-flash data blocks are filled between two software data blocks. Signature data can be inserted into the address segment of the non-flash data block or into an unused address segment. During flashing, only the software data blocks are flashed to the flash memory, sub-digests are calculated for the at least one non-continuous software data block, and the sub-digests are combined to generate a digest combination table. A root digest is generated for the digest combination table, the root digest is signed, and the signature data is inserted into the non-program address segment.
7. An electronic device, characterized in that: include: A processor and a memory, wherein the memory stores machine-readable instructions executable by the processor, and when the machine-readable instructions are executed by the processor, the method according to any one of claims 1 to 6 is performed.
8. A device for generating a software package implemented using the method according to any one of claims 1 to 3, characterized in that: include: A block division module is used to divide the software for updating and flashing into blocks to obtain at least one software data block with a non-continuous address; A filling module, configured to fill non-flash data blocks between at least one software data block; A sub-summary module, configured to generate a sub-summary for each software data block using an irreversible algorithm; A combination module, used for generating a summary combination table according to the sub-summaries of all software data blocks; A root summary module is used to generate a root summary by applying an irreversible algorithm to the summary combination table; A signature module, used to generate signature data by applying an asymmetric algorithm to the root digest; as well as The signature insertion module is used to insert the signature data into the address segment of the non-flash data block or the unused address segment through insertion logic to obtain a software package for packaging and release.
9. A software package flash update device implemented using the method according to any one of claims 4-5, characterized in that: include: A writing module is used to write all software data blocks in the software package into the designed address segment; An actual sub-summary module, configured to generate an actual sub-summary for each software data block using an irreversible algorithm; An actual combination module, used for generating an actual summary combination table according to all actual sub-summaries; An actual root summary module, configured to generate an actual root summary by applying an irreversible algorithm to the actual summary combination table; An address acquisition module, used to obtain the address information of the signature data in the software package through the insertion logic adopted in the signature method; The decryption module is used to obtain the signature data according to the address information of the signature data in the software package, and parse the signature data to obtain the root digest for verification; as well as The comparison module is used to compare whether the actual root digest is consistent with the root digest used for verification: if so, the flash update is completed; if not, the flash update fails.
Citation Information
Patent Citations
Firmware tamper-proofing method and system based on security chip
CN114640461A