Method, device, vehicle and storage medium for testing electronic control unit
The cyclic redundancy checksum hashing algorithm is used to verify the application code data of the electronic control unit, which solves the problem that the MCU chip cannot meet the sending time requirements of the first frame of the message when verifying the big data, and achieves faster and Efficient verification process.
Patent Information
- Application Number
- CN202210710932.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-22
- Publication Date
- 2025-02-07
- Estimated Expiration
- 2042-06-22
AI Technical Summary
The security engine of the existing MCU chip may not be able to meet the demand for sending time of the first frame network management packet of the electronic control unit when the verification data is large.
By reading all the information of the application code information block, the application code information block is checked using a cyclic redundancy verification algorithm. If successful, the project key information of the application code data and the first and last of the multiple data blocks are used. A data block is checked to determine that the electronic control unit is successfully inspected.
The verification speed is improved, the amount of verification data is reduced, and the problem that the first frame message transmission time of the electronic control unit cannot be satisfied when the application code data is large.
Smart Images

Figure CN115033857B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of electronics, and in particular to a method, a device, a vehicle and a storage medium for testing an electronic control unit. Background Art
[0002] With the development of automotive electronic technology, the functional safety requirements of each ECU (Electronic Control Unit) in the car are getting higher and higher, and ECU safe startup has become an increasingly important technical requirement. However, most MCU (Motor Control Unit) chip security engines may not be able to meet the requirements of the first frame network management message sending time when the verification data is large. Summary of the invention
[0003] In a first aspect, the present invention provides a method for inspecting an electronic control unit, wherein a memory in the electronic control unit contains application code data and an application code information block, wherein the application code data is divided into a plurality of data blocks, and the method comprises:
[0004] Read all information of the application code information block;
[0005] Verifying the application code information block using a cyclic redundancy check algorithm based on all the information;
[0006] If the application code information block is successfully verified, verifying the project key information corresponding to the application code data based on a first preset method;
[0007] If the verification of the project key information succeeds, verifying the first data block and the last data block of the multiple data blocks based on a second preset method;
[0008] If the first data block and the last data block are successfully verified, it is determined that the electronic control unit is successfully verified.
[0009] In an optional implementation manner, the all information includes a preset cyclic redundancy check code, and the checking the application code information block using a cyclic redundancy check algorithm based on the all information includes:
[0010] Using a cyclic redundancy check algorithm to calculate the information in the application code information block except the preset cyclic redundancy check code to obtain a cyclic redundancy check code;
[0011] Based on the comparison between the cyclic redundancy check code and the preset cyclic redundancy check code;
[0012] When the cyclic redundancy check code is the same as the preset cyclic redundancy check code, it is determined that the application code information block is successfully checked.
[0013] In an optional implementation manner, the all information includes preset project key information, and the verifying the project key information corresponding to the application code data based on the first preset method includes:
[0014] Read the preset project key information and the project key information corresponding to the application code data;
[0015] Comparing the preset project key information with the project key information;
[0016] When the preset project key information is the same as the project key information, it is determined that the verification of the project key information is successful.
[0017] In an optional implementation manner, the all information includes a preset check value, and the checking the first data block and the last data block of the multiple data blocks based on the second preset method includes:
[0018] Calculate the first data block and the last data block by using a hash algorithm to obtain a fused hash value;
[0019] Calculate the fused hash value based on the AES algorithm to obtain a first check value;
[0020] Comparing the first verification value with the preset verification value;
[0021] When the first check value is the same as the preset check value, it is determined that the first data block and the last data block are checked successfully.
[0022] In an optional implementation manner, the calculating the first data block and the last data block by using a hash algorithm includes:
[0023] Reading first related information corresponding to the first data block and second related information corresponding to the last data block in the application code information block;
[0024] Calculate the first relevant information and the second relevant information using a hash algorithm to obtain a first hash value and a second hash value;
[0025] The first Hash value and the second Hash value are concatenated to obtain a fused Hash value.
[0026] In an optional implementation, the multiple data blocks include an intermediate data block, the application code information block includes third related information corresponding to the intermediate data block, and the method further includes:
[0027] Reading the third relevant information;
[0028] Verifying the intermediate data block based on the second preset method;
[0029] When the intermediate data block verification succeeds, it is determined that the application code data has not been tampered with.
[0030] In a second aspect, the present invention provides a device for inspecting an electronic control unit, wherein a memory in the electronic control unit contains application code data and an application code information block, wherein the application code data is divided into a plurality of data blocks, and the device comprises:
[0031] A reading module, used for reading all information of the application code information block;
[0032] A cyclic redundancy check module, configured to check the application code information block using a cyclic redundancy check algorithm based on all the information;
[0033] A key information verification module, configured to verify the project key information corresponding to the application code data based on a first preset method if the application code information block verification succeeds;
[0034] A data block verification module, configured to verify the first data block and the last data block of the plurality of data blocks based on a second preset method if the verification of the project key information succeeds;
[0035] The safety boot module is used to determine that the electronic control unit is successfully verified if the first data block and the last data block are successfully verified.
[0036] In a third aspect, the present invention provides a vehicle-mounted control unit, the vehicle-mounted control unit comprising:
[0037] The method for inspecting the electronic control unit is used to perform safety inspection.
[0038] In a fourth aspect, the present invention provides a vehicle, comprising a memory and a processor, wherein the memory stores a computer program, and when the computer program is run on the processor, the method for inspecting an electronic control unit is executed.
[0039] In a fifth aspect, the present invention provides a storage medium storing a computer program, wherein the computer program executes the method for inspecting an electronic control unit when running on a processor.
[0040] The embodiments of the present application have the following beneficial effects:
[0041] The embodiment of the present application provides a method for verifying an electronic control unit by reading all the information of the application code information block, verifying the application code information block based on all the information using a cyclic redundancy check algorithm, if the application code information block is successfully verified, then verifying the project key information corresponding to the application code data based on a first preset method, if the project key information is successfully verified, then verifying the first data block and the last data block in multiple data blocks based on a second preset method, if the first data block and the last data block are successfully verified, then determining that the electronic control unit is successfully verified, reading all the information of the application code information block, verifying the application code information block based on all the information using a cyclic redundancy check algorithm, if the application code information block is successfully verified, then verifying the project key information corresponding to the application code data based on the first preset method, if the project key information is successfully verified, then verifying the first data block and the last data block in multiple data blocks based on a second preset method, if the first data block and the last data block are successfully verified, then determining that the electronic control unit is successfully verified. The present application can not only reduce the amount of application code data to be verified, thereby improving the verification speed, but also effectively solve the problem that the first frame message sending time of the electronic control unit cannot be met when the amount of application code data is large.
[0042] In order to make the above-mentioned objects, features and advantages of the present application more obvious and easy to understand, preferred embodiments are specifically cited below and described in detail with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] In order to more clearly illustrate the technical solution of the present invention, the following is a brief introduction to the drawings required for use in the embodiments. It should be understood that the following drawings only illustrate certain embodiments of the present invention and should not be regarded as limiting the scope of protection of the present invention. In each of the drawings, similar components are numbered similarly.
[0044] Figure 1 A first flow chart of a method for testing an electronic control unit proposed in an embodiment of the present application is shown;
[0045] Figure 2 A schematic diagram of a cyclic redundancy check process in a method for checking an electronic control unit proposed in an embodiment of the present application is shown;
[0046] Figure 3 A schematic diagram of a process for verifying key information of an item in a method for inspecting an electronic control unit proposed in an embodiment of the present application is shown;
[0047] Figure 4 A schematic diagram of a flow chart of data block verification in a method for verifying an electronic control unit proposed in an embodiment of the present application is shown;
[0048] Figure 5 A schematic diagram of a process for calculating a fused hash value in a method for inspecting an electronic control unit proposed in an embodiment of the present application is shown;
[0049] Figure 6 A second flow chart of a method for testing an electronic control unit proposed in an embodiment of the present application is shown;
[0050] Figure 7 A schematic structural diagram of an inspection electronic control unit device proposed in an embodiment of the present application is shown.
[0051] Description of main component symbols:
[0052] 10-inspection electronic control unit device; 11-reading module; 12-cyclic redundancy check module; 13-key information verification module; 14-data block verification module; 15-safe start module. DETAILED DESCRIPTION
[0053] The technical solutions in the embodiments of the present invention will be described clearly and completely below in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments.
[0054] The components of the embodiments of the present invention generally described and shown in the drawings herein may be arranged and designed in a variety of different configurations. Therefore, the following detailed description of the embodiments of the present invention provided in the drawings is not intended to limit the scope of the claimed invention, but merely represents selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0055] Hereinafter, the terms "including", "having" and their cognates, which may be used in various embodiments of the present invention, are intended only to indicate specific features, numbers, steps, operations, elements, components or combinations of the foregoing items, and should not be understood as first excluding the existence of one or more other features, numbers, steps, operations, elements, components or combinations of the foregoing items or adding the possibility of one or more features, numbers, steps, operations, elements, components or combinations of the foregoing items.
[0056] Furthermore, the terms “first”, “second”, “third”, etc. are merely used for distinguishing descriptions and are not to be understood as indicating or implying relative importance.
[0057] Unless otherwise defined, all terms (including technical terms and scientific terms) used herein have the same meanings as those generally understood by those skilled in the art to which the various embodiments of the present invention belong. The terms (such as those defined in generally used dictionaries) will be interpreted as having the same meanings as the contextual meanings in the relevant technical field and will not be interpreted as having idealized meanings or overly formal meanings unless clearly defined in the various embodiments of the present invention.
[0058] Example 1
[0059] The embodiment of the present application provides a method for inspecting an electronic control unit, wherein the memory of the electronic control unit includes application code data and application code information blocks, and the application code data is divided into multiple data blocks. The electronic control unit (ECU) is composed of a microcontroller (MCU), a memory, an input / output interface (I / O), and large-scale integrated circuits such as shaping and driving, and the memory can be divided into a read-only memory (ROM) and a random access memory (RAM).
[0060] In this embodiment, the storage space of the memory of the electronic control unit is divided into two parts, one part is used to store the application code data, and the other part is used to store the application code information block. In other words, the storage space of the other part is used to store the relevant information of multiple data blocks. Among them, the application code information block is stored before the application code data of the electronic control unit, that is, the front end of the application code data. The application code data is divided into multiple data blocks, and the multiple data blocks are the first data block, the second data block, the third data block, ..., and the last data block in sequence.
[0061] The application code information block includes relevant information of the above-mentioned multiple data blocks, for example, including but not limited to the starting address of the first data block, the length of the first data block, the starting address of the last data block, the length of the last data block, the check value of the first data block and the last data block, the preset cyclic redundancy check code, the starting address of the second data block, the length of the second data block, the check value of the second data block, and the preset project key information. The application code information block may also include a reserved space, and the reserved space may be used to add corresponding information according to actual needs.
[0062] The content of all information in the application code information block is generated by the host computer after the application code data is edited and generated, and is inserted into the application code information block in the memory. The host computer is a computer that can directly issue control commands.
[0063] Please refer to Figure 1, exemplary, the method for testing the electronic control unit specifically includes steps S100 to S500:
[0064] Step S100: Read all information of the application code information block.
[0065] In this embodiment, after the electronic control unit is started, all information of the application code information block stored in the memory of the electronic control unit will be read, as shown in Table 1 below, including but not limited to the starting address of the first data block, the length of the first data block, the starting address of the last data block, the length of the last data block, the check values of the first data block and the last data block, the preset cyclic redundancy check code and the project key information.
[0066]
[0067] Step S200: Verify the application code information block using a cyclic redundancy check algorithm based on all information.
[0068] After reading all the information of the application code information block stored in the electronic control unit memory, a cyclic redundancy check algorithm is used to check all the information in the application code information block, that is, to determine whether the cyclic redundancy check code obtained by the cyclic redundancy check algorithm matches the preset cyclic redundancy check code stored in the application code information block.
[0069] Among them, Cyclic Redundancy Check (CRC) is a channel coding technology that generates a short fixed-bit check code based on data such as network data packets or computer files. It is mainly used to detect or check errors that may occur after data transmission or storage. It is a commonly used check code with error detection and correction capabilities. Cyclic redundancy check codes use certain mathematical operations to establish a predetermined relationship between data bits and check bits, and are often used for data verification of external storage and computer synchronous communication.
[0070] If the application code information block verification succeeds, step S300 is executed; if the application code information block verification fails, step S600 is executed.
[0071] In one embodiment, Figure 2 As shown, step S200 includes sub-steps S210 to S230.
[0072] Sub-step S210: using a cyclic redundancy check algorithm to calculate the information in the application code information block except for the preset cyclic redundancy check code to obtain a cyclic redundancy check code.
[0073] After reading all the information in the application code information block, the other information in the application code information block except the preset cyclic redundancy check code is calculated by a cyclic redundancy check algorithm to obtain a corresponding cyclic redundancy check code.
[0074] Sub-step S220: comparing the cyclic redundancy check code with a preset cyclic redundancy check code.
[0075] The calculated cyclic redundancy check code is compared with a preset cyclic redundancy check code that has been stored in the application code information block to determine whether the cyclic redundancy check code is the same as the preset cyclic redundancy check code.
[0076] Sub-step S230: When the cyclic redundancy check code is the same as the preset cyclic redundancy check code, it is determined that the application code information block is successfully checked.
[0077] If the result of the comparison is that the calculated cyclic redundancy check code is the same as the preset cyclic redundancy check code, it is determined that the cyclic redundancy check of the application code information block passes. If the result of the comparison is that the calculated cyclic redundancy check code is different from the preset cyclic redundancy check code, it is determined that the application code information block fails the check.
[0078] Step S300: verifying the project key information corresponding to the application code data based on a first preset method.
[0079] It is understandable that when the application code information block is successfully verified, the preset project key information pre-stored in the application code information block is read to determine the project key information corresponding to the application code data, and the project key information is verified by a first preset method to determine whether the preset project key information matches the project key information corresponding to the application code data. The preset project key information may be the project name of the electronic control unit pre-stored in the memory or the file name corresponding to the application code data.
[0080] If the verification of the key information of the project succeeds, step S400 is executed; if the verification of the key information of the project fails, step S600 is executed.
[0081] In one embodiment, Figure 3 As shown, step S300 includes sub-steps S310 to S330.
[0082] Sub-step S310: Reading preset project key information and project key information corresponding to the application code data.
[0083] It can be understood that all information in the application code information block includes preset project key information, and the preset project key information and project key information corresponding to the application code data are read, wherein the project key information corresponding to the application code data may be a project name or file name corresponding to the application code data of the electronic control unit, etc. In this implementation, reading the project key information is conducive to further identifying the authenticity of the application code data of the electronic control unit.
[0084] Sub-step S320: Compare the preset project key information with the project key information.
[0085] There is also corresponding project key information in the application code data of the electronic control unit. The preset project key information in the application code information block is compared with the project key information corresponding to the application code data to determine whether the preset project key information is consistent with the project key information.
[0086] Sub-step S330: When the preset project key information is the same as the project key information, it is determined that the verification of the project key information is successful.
[0087] When the preset project key information is the same as the project key information of the application code data, it is determined that the verification of the project key information is successful, that is, the authenticity of the application code data of the electronic control unit is initially identified successfully. When the preset project key information is different from the project key information corresponding to the application code data, it is determined that the verification of the project key information has failed.
[0088] Step S400: verifying the first data block and the last data block among the multiple data blocks based on a second preset method.
[0089] In this embodiment, when the above-mentioned project key information verification is successful, the first data block and the last data block of the multiple data blocks will be verified by a second preset method to further verify the application code data that is not completely burned.
[0090] If the verification of the first data block and the last data block succeeds, step S500 is executed; if the verification of the first data block and the last data block fails, step S600 is executed.
[0091] In one embodiment, Figure 4 As shown, the first data block and the last data block among the multiple data blocks are verified based on the second preset method, including sub-steps S410 to S440.
[0092] Sub-step S410: Calculate the first data block and the last data block using a hash algorithm to obtain a fused hash value.
[0093] It is understandable that after the project key information corresponding to the application code data is successfully matched, multiple data blocks in the electronic control unit will be further verified. During the verification, the relevant information of the first data block and the last data block will be determined, and the fused hash value corresponding to the first data block and the last data block will be calculated in sequence using a hash algorithm.
[0094] Among them, the hash algorithm (i.e., Hash algorithm) transforms an input of arbitrary length (also called pre-image) into an output of fixed length through a hash algorithm, and the output is the hash value. This conversion is a compression mapping, that is, the space of hash values is usually much smaller than the space of inputs, and different inputs may hash to the same output, so it is impossible to determine the unique input value from the hash value. Simply put, it is a function that compresses a message of arbitrary length into a message digest of a fixed length. In addition, hash algorithms include MD4, MD5, SHA-1 and others.
[0095] In one embodiment, Figure 5 As shown, sub-step S410 includes sub-steps S411 to S413.
[0096] Sub-step S411: Read the first relevant information corresponding to the first data block and the second relevant information corresponding to the last data block in the application code information block.
[0097] Read the first related information corresponding to the first data block and the second related information corresponding to the last data block stored in the application code information block, the first related information includes the starting address of the first data block and the length of the first data block, and the second related information includes the starting address of the last data block and the length of the last data block.
[0098] Sub-step S412: using a hash algorithm to calculate the first related information and the second related information to obtain a first hash value and a second hash value.
[0099] In this embodiment, a hash algorithm may be used to calculate the first relevant information of the first data block to obtain a corresponding first hash value, and to calculate the second relevant information of the second data block to obtain a second hash value.
[0100] Sub-step S413: concatenate the first hash value and the second hash value to obtain a fused hash value.
[0101] After obtaining the first hash value and the second hash value, the first hash value and the second hash value are concatenated and merged in a preset order to obtain a fused hash value. The first hash value can be in front and the second hash value can be in the back, and the fused hash value can be obtained; or the second hash value can be in front and the first hash value can be in the back, and the fused hash value can be obtained in order.
[0102] Sub-step S420: Calculate the fused hash value based on the AES algorithm to obtain a first check value.
[0103] After obtaining the fused hash value, the fused hash value will be calculated by the AES algorithm to obtain the first check value. When encrypting by the AES algorithm, the fused hash value will be calculated by the AES algorithm to generate independent ciphertext blocks, and these ciphertext blocks will be spliced together to obtain the fused AES encryption result, that is, the first check value. Verifying the fused hash value by the AES algorithm can ensure the validity of the application code data.
[0104] Among them, the AES (Advanced Encryption Standard) algorithm is also known as the Rijndael encryption method, which is a block encryption standard. AES supports three key lengths: 128 bits, 192 bits, and 256 bits, commonly known as AES128, AES192, AES256, which actually refers to the use of different key lengths by the AES algorithm.
[0105] Sub-step S430: Compare the first verification value with a preset verification value.
[0106] It is understandable that after the first check value is calculated, the first check value will be compared with the preset check value stored in the application code information block, that is, it is determined whether the preset check value is the same as the first check value to determine whether the safe startup of the electronic control unit is successful. The preset check value is the check value corresponding to the first data block and the last data block pre-stored in the application code information block.
[0107] Sub-step S440: When the first verification value is the same as the preset verification value, it is determined that the verification of the first data block and the last data block is successful.
[0108] If the first check value is the same as the preset check value, it is determined that the check is passed, in other words, it is determined that the check of the first data block and the last data block based on the second preset method is successful.
[0109] Step S500: Determine whether the electronic control unit inspection is successful.
[0110] When the verification of the first data block and the last data block based on the second preset method is successful, it is determined that the electronic control unit is successfully verified. After the electronic control unit is successfully verified, it is determined that the electronic control unit is safely started successfully. The content in the application code data of the electronic control unit will be executed immediately, thereby meeting the time requirement for the network management to send the first frame message.
[0111] Step S600: Determine whether the electronic control unit inspection fails.
[0112] When the application code information block or the project key information or the first data block and the last data block fail to be verified, it is determined that the electronic control unit verification has failed, the safe startup verification of the electronic control unit will be ended, and the electronic control unit will be prohibited from entering the application program.
[0113] In this embodiment, not only can the verification speed be improved, but also the incomplete application code data can be verified, thus meeting the requirements of secure booting for data integrity.
[0114] In one embodiment, Figure 6 As shown, the method for testing the electronic control unit also includes the following steps:
[0115] Step S700: Read the third relevant information.
[0116] In this embodiment, the application code information block includes third related information corresponding to the intermediate data block, and the third related information is related information of the intermediate data block, including the length of the intermediate data block, the start address of the intermediate data block, and the check value of the intermediate data block. The check value of the intermediate data block is a pre-stored check value, and the intermediate data block can be any data block from the second data block to the second to last data block in the multiple data blocks, or can be all data blocks from the second data block to the second to last data block in the application code data.
[0117] It can be understood that after the electronic control unit is successfully verified, the intermediate data block in the application code data will continue to be verified, and during the verification, the third relevant information in the application code information block will be read.
[0118] Step S800: verifying the intermediate data block based on a second preset method.
[0119] The length of the intermediate data block and the starting address of the intermediate data block are calculated by a hash algorithm to obtain a third hash value, and the third hash value is calculated by an AES algorithm to obtain a corresponding second check value.
[0120] The second check value is compared with the check value of the intermediate data block read from the application code information block to determine whether the second check value is the same as the check value of the intermediate data block.
[0121] Exemplarily, when the third relevant information in the application code information block is set to the relevant information of the third data block, that is, including the length of the third data block, the starting address of the third data block and the check value of the third data block, the intermediate data block is the third data block, and the second preset method is used to check the third data block.
[0122] Step S900: When the intermediate data block verification succeeds, it is determined that the application code data has not been tampered with.
[0123] When the second check value is the same as the check value of the intermediate data block, it is determined that the application message has not been tampered with. When the second check value is different from the check value of the intermediate data block, it is determined that the application message has been tampered with.
[0124] In the embodiment of the present application, not only the requirements of the first frame network management of the electronic control unit are met, but also the requirements of verifying the authenticity and validity of the data during secure startup are met.
[0125] The present application can not only reduce the amount of application code data to be verified, thereby increasing the verification speed, but can also effectively solve the problem that when the amount of application code data is large, the time for sending the first frame message of the electronic control unit cannot be met.
[0126] Based on the method for testing the electronic control unit of the above embodiment, Figure 7 The structure diagram of a test electronic control unit device 10 provided in an embodiment of the present application is shown. The memory of the electronic control unit includes application code data and application code information blocks. The application code data is divided into multiple data blocks. The test electronic control unit device 10 includes:
[0127] The reading module 11 is used to read all the information of the application code information block.
[0128] The cyclic redundancy check module 12 is used to check the application code information block based on all the information using a cyclic redundancy check algorithm.
[0129] The project key information verification module 13 is used to verify the project key information corresponding to the application code data based on a first preset method if the application code information block verification succeeds.
[0130] The data block verification module 14 is configured to verify the first data block and the last data block of the multiple data blocks based on a second preset method if the verification of the project key information succeeds.
[0131] The safety startup module 15 is used to determine that the electronic control unit is successfully verified if the first data block and the last data block are successfully verified.
[0132] The implementation schemes and beneficial effects involved in the above embodiments are also applicable to this embodiment and will not be described in detail here.
[0133] In addition, the present application also provides a vehicle-mounted control unit, which includes:
[0134] The safety check is performed by executing the method for checking the electronic control unit in the above embodiment.
[0135] This embodiment further provides a vehicle, including a memory and a processor, wherein the memory stores a computer program, and when the computer program runs on the processor, the method for inspecting an electronic control unit in the above embodiment is executed.
[0136] This embodiment further provides a storage medium storing a computer program. When the computer program is run on a processor, the method for inspecting an electronic control unit in the above embodiment is executed.
[0137] In several embodiments provided in the present application, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely schematic. For example, the flowcharts and structure diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, methods and computer program products according to multiple embodiments of the present invention. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and the module, a program segment or a part of a code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in an alternative implementation, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the structure diagram and / or the flow chart, and the combination of boxes in the structure diagram and / or the flow chart, can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.
[0138] In addition, the functional modules or units in the various embodiments of the present invention may be integrated together to form an independent part, or each module may exist independently, or two or more modules may be integrated to form an independent part.
[0139] If the functions are implemented in the form of software function modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a smart phone, a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0140] The above description is only a specific implementation mode of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be covered by the protection scope of the present invention.
Claims
1. A method for testing an electronic control unit, characterized in that: The electronic control unit has a memory containing application code data and an application code information block, wherein the application code data is divided into a plurality of data blocks, and the method comprises: Read all information of the application code information block; Verifying the application code information block using a cyclic redundancy check algorithm based on all the information; If the verification of the application code information block succeeds, verifying the project key information corresponding to the application code information block based on a first preset method; If the verification of the project key information succeeds, verifying the first data block and the last data block of the multiple data blocks based on a second preset method; If the first data block and the last data block are successfully verified, it is determined that the electronic control unit is successfully verified; The all information includes a preset check value, and the checking of the first data block and the last data block among the multiple data blocks based on the second preset method includes: Calculate the first data block and the last data block by using a hash algorithm to obtain a fused hash value; Calculate the fused hash value based on the AES algorithm to obtain a first check value; Comparing the first verification value with the preset verification value; When the first check value is the same as the preset check value, it is determined that the first data block and the last data block are checked successfully.
2. The method for testing an electronic control unit according to claim 1, characterized in that: The all information includes a preset cyclic redundancy check code, and the checking the application code information block by using a cyclic redundancy check algorithm based on the all information includes: Using a cyclic redundancy check algorithm to calculate the information in the application code information block except the preset cyclic redundancy check code to obtain a cyclic redundancy check code; Based on the comparison between the cyclic redundancy check code and the preset cyclic redundancy check code; When the cyclic redundancy check code is the same as the preset cyclic redundancy check code, it is determined that the application code information block is successfully checked.
3. The method for testing an electronic control unit according to claim 1, characterized in that: The all information includes preset project key information, and the verifying the project key information corresponding to the application code information block based on the first preset method includes: Read the preset project key information and the project key information corresponding to the application code information block; Comparing the preset project key information with the project key information; When the preset project key information is the same as the project key information, it is determined that the verification of the project key information is successful.
4. The method for testing an electronic control unit according to claim 1, characterized in that: The calculating the first data block and the last data block by using a hash algorithm includes: Reading first related information corresponding to the first data block and second related information corresponding to the last data block in the application code information block; Calculate the first relevant information and the second relevant information using a hash algorithm to obtain a first hash value and a second hash value; The first Hash value and the second Hash value are concatenated to obtain a fused Hash value.
5. The method for testing an electronic control unit according to claim 1, characterized in that: The multiple data blocks include an intermediate data block, the application code information block includes third related information corresponding to the intermediate data block, and the method further includes: Reading the third relevant information; Verifying the intermediate data block based on the second preset method; When the intermediate data block verification succeeds, it is determined that the application code data has not been tampered with.
6. A device for testing an electronic control unit, characterized in that: The electronic control unit has application code data and application code information blocks in its memory, wherein the application code data is divided into a plurality of data blocks, and the device comprises: A reading module, used for reading all information of the application code information block; A cyclic redundancy check module, configured to check the application code information block using a cyclic redundancy check algorithm based on all the information; A key information verification module, configured to verify the project key information corresponding to the application code information block based on a first preset method if the application code information block verification succeeds; A data block verification module, configured to verify the first data block and the last data block of the plurality of data blocks based on a second preset method if the verification of the project key information succeeds; A safety boot module, configured to determine that the electronic control unit has been successfully verified if the first data block and the last data block have been successfully verified; The all information includes a preset check value, and the checking the first data block and the last data block of the multiple data blocks based on the second preset method includes: calculating the first data block and the last data block by a hash algorithm to obtain a fused hash value; Calculate the fused hash value based on the AES algorithm to obtain a first check value; Comparing the first verification value with the preset verification value; When the first check value is the same as the preset check value, it is determined that the first data block and the last data block are checked successfully.
7. A vehicle-mounted control unit, characterized in that: The vehicle-mounted control unit comprises: A safety check is performed using the method for checking an electronic control unit as described in any one of claims 1 to 5.
8. A vehicle, characterized in that: The method comprises a memory and a processor, wherein the memory stores a computer program, and when the computer program is run on the processor, the method for inspecting an electronic control unit according to any one of claims 1 to 5 is executed.
9. A storage medium, characterized in that: The computer program stores a computer program, which executes the method for inspecting an electronic control unit according to any one of claims 1 to 5 when running on a processor.
Citation Information
Patent Citations
Application program integrity checking method and equipment
CN110334486A
A method for verifying application program of electronic control unit
CN112417433A
Method and device for checking program integrity of electronic controller and electronic controller
CN113778061A