Information message generation method and device, program product and storage medium
By truncating message messages and generating message authentication codes in secure on-board communication, the problem of easy cracking of message messages is solved, and the security and integrity of message messages are enhanced.
Patent Information
- Application Number
- CN202411403066.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-09
- Publication Date
- 2025-01-10
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
In the existing secure on-vehicle communication mechanism, the problem that message messages are easily forced to be cracked is mainly due to the complete exposure of freshness values and the difficulty of adding truncated message authentication codes, which makes it difficult to guarantee the security and integrity of message messages.
By obtaining the original message message, data transmission resources and fresh values, performing truncation operations to generate the target fresh value, and generating the target message authentication code based on the original message message, identification and fresh value, inserting it into the message message to form the target message message, and then splice fresh values to enhance the security of message messages.
It effectively increases the difficulty of forced cracking of message packets, and improves the security and integrity of message packets by changing the generation method and inserting position of fresh values and message authentication codes.
Smart Images

Figure CN119300040A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of communications, and specifically, to a method and device for generating a message message, a program product, and a storage medium. Background Art
[0002] The Security Onboard Communication (SecOC) mechanism is used to protect the integrity, authenticity, and anti-replay of sensitive information in the in-vehicle network. The protected object is transmitted in the form of a protocol data unit (PDU), and the freshness value and integrity check value are added to the end of the protected PDU message. When the related technology is communicating, the freshness value is completely exposed, and it is difficult to have more bytes to append the truncated message authentication code (MAC value), which results in the message being easily cracked. Summary of the invention
[0003] The embodiments of the present application provide a method and device for generating a message message, a program product, and a storage medium, so as to at least solve the problem in the related art that the message message can be easily cracked by force.
[0004] According to an embodiment of the present application, a method for generating a message message is provided, comprising: obtaining an original message message, a data transmission resource, a first freshness value and an original identifier of the original message message, wherein the first freshness value is used to indicate the timeliness of the original message message, the original identifier is used to uniquely identify the original message message, and the data transmission resource is used to indicate the communication capability of the data transmission bus; performing a first truncation operation on the first freshness value based on the message byte length of the original message message and the data transmission resource to obtain a target freshness value, wherein the byte length of the target freshness value is less than the first freshness value. The byte length of the fresh value; based on the above-mentioned original message message, the above-mentioned original identifier, the above-mentioned first fresh value and the message byte length of the above-mentioned original message message, generate target message authentication data, wherein the above-mentioned target message authentication data includes a target message authentication code and the above-mentioned target message authentication code to be inserted into the insertion position of the above-mentioned original message message, and the above-mentioned target message authentication code is used to verify the security and integrity of the above-mentioned original message message; based on the above-mentioned insertion position, the above-mentioned target message authentication code is inserted into the above-mentioned original message message to obtain a first message message; splicing the above-mentioned target fresh value and the above-mentioned first message message to obtain the target message message.
[0005] In an exemplary embodiment, obtaining an original message message, a data transmission resource, a first freshness value and an original identifier of the original message message includes: sending a first request instruction to a first message component, wherein the first message component is used to generate the original identifier when the original message message is obtained, and store the original message message and the original identifier; receiving the original message message and the original identifier sent by the first message component in response to the first request instruction; sending a second request instruction to a second message component, wherein the second message component includes the stored data transmission resource; receiving the data transmission resource sent by the second message component in response to the second request; sending a third request instruction to a third message component, wherein the third message component includes storing the first freshness value, wherein the first freshness value is a timestamp generated by a timer when the original message message is generated; receiving the first freshness value sent by the third message component in response to the third request instruction; wherein the first message component, the second message component and the third message component are all integrated in the same electronic control device.
[0006] In an exemplary embodiment, a first truncation operation is performed on the first freshness value based on the message byte length of the original message message and the data transmission resources to obtain a target freshness value, including: determining resource limitations in the data transmission resources, wherein the resource limitations include transmission bandwidth limitations and network load limitations, the transmission bandwidth limitations are used to limit the data transmission rate of the data transmission bus, and the network load limitations are used to limit the amount of data transmitted by the data transmission bus; obtaining the bandwidth limitation byte length included in the transmission bandwidth limitation and the load limitation byte length included in the network load limitation, and calculating the first target truncation length of the first freshness value according to the bandwidth limitation byte length, the load limitation byte length and the message byte length of the original message message; and truncating the byte length matching the first target truncation length from the first preset byte position of the first freshness value to obtain the target freshness value.
[0007] In an exemplary embodiment, the first target truncation length of the first fresh value is calculated according to the bandwidth limit byte length, the load limit byte length and the message byte length of the original message message, including one of the following: when the load limit byte length is less than the first preset length and the first sum value between the message byte length and the byte length of the first fresh value satisfies the bandwidth limit byte length, the first truncation length is determined as the first target truncation length, wherein the first truncation length is a truncation length corresponding to the first preset length and the first sum value; when the load limit byte length is greater than the second preset length and the second sum value between the message byte length and the byte length of the first fresh value satisfies the bandwidth limit byte length, the second truncation length is determined as the first target truncation length, wherein the second truncation length is a truncation length corresponding to the second preset length and the second sum value; wherein the first truncation length is less than the second truncation length.
[0008] In an exemplary embodiment, based on the original message message, the original identifier, the first freshness value and the message byte length of the original message message, target message authentication data is generated, including: determining the byte length of the target freshness value, the message byte length of the original message message, and the byte length of the first freshness value, and performing an XOR operation on the original message message, the original identifier and the first freshness value to obtain an original message authentication code; performing an encoding operation on the original message authentication code to obtain a message authentication code, wherein the encoding operation includes an operation of encrypting the original message authentication code; performing a quotient operation on the byte length of the target freshness value and the byte length of the message authentication code, and performing a remainder operation on the obtained first operation result, and determining the obtained first remainder as the first interception position of the message authentication code; intercepting and a first preset byte length from the first interception position of the message authentication code to obtain the target message authentication code, wherein the byte length of the target message authentication code is less than the byte length of the message authentication code.
[0009] In an exemplary embodiment, target message authentication data is generated based on the original message message, the original identifier, the first fresh value and the byte length of the original message message, including: performing a quotient operation on the byte length of the first fresh value and the message byte length of the original message message, and performing a remainder operation on the second operation result to obtain a second remainder; determining the insertion position included in the target message authentication data according to the second remainder.
[0010] According to an embodiment of the present application, a device for generating a message message is provided, comprising: a first acquisition module, used to acquire an original message message, a data transmission resource, a first freshness value and an original identifier of the original message message, wherein the first freshness value is used to indicate the timeliness of the original message message, the original identifier is used to uniquely identify the original message message, and the data transmission resource is used to indicate the communication capability of a data transmission bus; a first execution module, used to perform a first truncation operation on the first freshness value based on the message byte length of the original message message and the data transmission resource to obtain a target freshness value, wherein the byte length of the target freshness value is less than the byte length of the first freshness value. Section length; a first generation module, used to generate target message authentication data based on the above-mentioned original message message, the above-mentioned original identifier, the above-mentioned first freshness value and the message byte length of the above-mentioned original message message, wherein the above-mentioned target message authentication data includes a target message authentication code and the above-mentioned target message authentication code to be inserted into the insertion position of the above-mentioned original message message, and the above-mentioned target message authentication code is used to verify the security and integrity of the above-mentioned original message message; a first insertion module, used to insert the above-mentioned target message authentication code into the above-mentioned original message message based on the above-mentioned insertion position to obtain a first message message; a first splicing module, used to splice the above-mentioned target freshness value and the above-mentioned first message message to obtain a target message message.
[0011] In an exemplary embodiment, the first acquisition module includes: a first sending submodule, used to send a first request instruction to a first message component, wherein the first message component is used to generate the original identifier when acquiring the original message message, and store the original message message and the original identifier; a first receiving submodule, used to receive the original message message and the original identifier sent by the first message component in response to the first request instruction; a second sending submodule, used to send a second request instruction to a second message component, wherein the second message component includes the stored data transmission resources; a second receiving submodule, used to receive the data transmission resources sent by the second message component in response to the second request; a third sending submodule, used to send a third request instruction to a third message component, wherein the third message component includes storing the first fresh value, wherein the first fresh value is a timestamp generated by a timer when the original message message is generated; a third receiving submodule, used to receive the first fresh value sent by the third message component in response to the third request instruction; wherein the first message component, the second message component and the third message component are all integrated in the same electronic control device.
[0012] In an exemplary embodiment, the first execution module includes: a first determination submodule, used to determine the resource limitations in the data transmission resources, wherein the resource limitations include transmission bandwidth limitations and network load limitations, the transmission bandwidth limitations are used to limit the data transmission rate of the data transmission bus, and the network load limitations are used to limit the amount of data transmitted by the data transmission bus; a first calculation submodule, used to obtain the bandwidth limitation byte length included in the transmission bandwidth limitation and the load limitation byte length included in the network load limitation, and calculate the first target truncation length of the first fresh value according to the bandwidth limitation byte length, the load limitation byte length and the message byte length of the original message message; a first interception submodule, used to intercept the byte length matching the first target truncation length from the first preset byte position of the first fresh value to obtain the target fresh value.
[0013] In an exemplary embodiment, the first calculation submodule includes one of the following: a first determination unit, used to determine the first truncation length as the first target truncation length when the load limit byte length is less than the first preset length and the first sum of the message byte length and the byte length of the first fresh value satisfies the bandwidth limit byte length, wherein the first truncation length is a truncation length corresponding to the first preset length and the first sum; a second determination unit, used to determine the second truncation length as the first target truncation length when the load limit byte length is greater than the second preset length and the second sum of the message byte length and the byte length of the first fresh value satisfies the bandwidth limit byte length, wherein the second truncation length is a truncation length corresponding to the second preset length and the second sum; wherein the first truncation length is less than the second truncation length.
[0014] In an exemplary embodiment, the first generation module includes: a second determination submodule, which is used to determine the byte length of the target fresh value, the message byte length of the original message message, and the byte length of the first fresh value, and perform an XOR operation on the original message message, the original identifier and the first fresh value to obtain an original message authentication code; a first execution submodule, which is used to perform an encoding operation on the original message authentication code to obtain a message authentication code, wherein the encoding operation includes an operation of encrypting the original message authentication code; a second execution submodule, which is used to perform a quotient operation on the byte length of the target fresh value and the byte length of the message authentication code, and perform a remainder operation on the first operation result obtained, and determine the obtained first remainder as the first interception position of the message authentication code; from the first interception position of the message authentication code, intercept a first preset byte length to obtain the target message authentication code, wherein the byte length of the target message authentication code is less than the byte length of the message authentication code.
[0015] In an exemplary embodiment, the above-mentioned first generation module includes: a third execution sub-module, used to perform a quotient operation on the byte length of the above-mentioned first fresh value and the message byte length of the above-mentioned original message message, and perform a remainder operation on the second operation result obtained to obtain a second remainder; a third determination sub-module, used to determine the above-mentioned insertion position included in the above-mentioned target message authentication data according to the above-mentioned second remainder.
[0016] According to another embodiment of the present application, a computer program product is provided, including a computer program, wherein the computer program is configured for a processor to execute the steps of any of the above method embodiments.
[0017] According to another embodiment of the present application, a computer-readable storage medium is provided, in which a computer program is stored, wherein the computer program is configured to enable a processor to execute the steps in any of the above method embodiments.
[0018] According to another embodiment of the present application, an electronic device is provided, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, wherein the processor is configured to execute the computer program to perform the steps in any one of the method embodiments.
[0019] Through the present application, a first truncation operation is performed on the first freshness value based on the message byte length and data transmission resources of the original message message, and a target freshness value whose byte length is less than the first freshness value is obtained. Based on the original message message, the original identifier, the first freshness value and the message byte length of the original message message, a target message authentication code and an insertion position of the target message authentication code to be inserted into the original message message are generated. Based on the insertion position, the target message authentication code is inserted into the original message message to obtain a first message message; the target freshness value and the first message message are concatenated to obtain a target message message. Since the present application changes the generation method of the freshness value and the message authentication code and the insertion position in the original message message, the problem that the message message is easily cracked by force in the related art is solved, and the effect of increasing the difficulty of the message message being cracked by force is achieved. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] Figure 1 It is a hardware structure block diagram of a mobile terminal of a method for generating a message message in an embodiment of the present application;
[0021] Figure 2 It is a flowchart of a method for generating a message according to an embodiment of the present application;
[0022] Figure 3 It is an architecture diagram of a method for generating a message message in a specific embodiment of the present application;
[0023] Figure 4 It is a flow chart of a method for generating a message message according to a specific embodiment of the present application;
[0024] Figure 5 This is a structural diagram of a target message message in a specific embodiment of the present application;
[0025] Figure 6 It is a structural block diagram of a message generation device according to an embodiment of the present application. DETAILED DESCRIPTION
[0026] The embodiments of the present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0027] It should be noted that the terms "first", "second", etc. in the specification and claims of this application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.
[0028] The method embodiments provided in the embodiments of the present application can be executed in a mobile terminal, a computer terminal or a similar computing device. Taking running on a mobile terminal as an example, Figure 1 1 is a hardware structure block diagram of a mobile terminal of a method for generating a message message in an embodiment of the present application. Figure 1 As shown, the mobile terminal may include one or more ( Figure 1 Only one is shown in the figure) a processor 102 (the processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA) and a memory 104 for storing data, wherein the mobile terminal may also include a transmission device 106 and an input / output device 108 for communication functions. It can be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the mobile terminal. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations are shown.
[0029] The memory 104 can be used to store computer programs, for example, software programs and modules of application software, such as a computer program corresponding to a method for generating a message message in an embodiment of the present application. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, to implement the above method. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the mobile terminal via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0030] The transmission device 106 is used to receive or send data via a network. The specific example of the above network may include a wireless network provided by a communication provider of the mobile terminal. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, referred to as NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0031] In this embodiment, a method for generating a message is provided. Figure 2 is a flow chart of a method for generating a message according to an embodiment of the present application, such as Figure 2 As shown, the process includes the following steps:
[0032] Step S202, obtaining an original message message, a data transmission resource, a first freshness value, and an original identifier of the original message message, wherein the first freshness value is used to indicate the timeliness of the original message message, the original identifier is used to uniquely identify the original message message, and the data transmission resource is used to indicate the communication capability of the data transmission bus;
[0033] Optionally, the first freshness value is a security mechanism used to ensure the timeliness of the message during transmission and to prevent replay attacks. The first freshness value is generated by an 8-byte monotonically increasing counter and sent together with the message to prove that the message is the latest one sent, not the old one or the one being replayed. It is an important part of the in-vehicle communication security and improves the security of the vehicle network.
[0034] Optionally, the data transmission resource may be a bus resource for message transmission, such as a controller area network (Controller Area Network, CAN for short) bus resource.
[0035] Optionally, the original identifier (Controller Area Network Identifier, referred to as CAN ID) of the original message is an identifier used in the CAN bus protocol to identify each message on the communication network.
[0036] Step S204, performing a first truncation operation on the first freshness value based on the message byte length and data transmission resources of the original message message to obtain a target freshness value, wherein the byte length of the target freshness value is less than the byte length of the first freshness value;
[0037] Step S206, generating target message authentication data based on the original message, the original identifier, the first freshness value, and the message byte length of the original message, wherein the target message authentication data includes a target message authentication code and an insertion position of the target message authentication code to be inserted into the original message, and the target message authentication code is used to verify the security and integrity of the original message;
[0038] Optionally, a message authentication code (MAC) is an encryption method used to ensure the integrity of a message and verify the authenticity of the source of the message. MAC is usually used in conjunction with encryption technology to provide higher security for messages.
[0039] Step S208, inserting the target message authentication code into the original message based on the insertion position to obtain a first message;
[0040] Step S210, concatenate the target freshness value and the first message message to obtain a target message message.
[0041] Optionally, the splicing rule may be target freshness value+first message packet, or first message packet+target freshness value.
[0042] In this embodiment, the execution subject of the above steps can be a terminal, a server, a specific processor set in the terminal or server, or a processor or processing device set relatively independently from the terminal or server, but is not limited thereto.
[0043] Through the above steps, a first truncation operation is performed on the first freshness value based on the message byte length and data transmission resources of the original message message to obtain a target freshness value whose byte length is less than the first freshness value. Based on the original message message, the original identifier, the first freshness value and the message byte length of the original message message, a target message authentication code and an insertion position of the target message authentication code to be inserted into the original message message are generated. Based on the insertion position, the target message authentication code is inserted into the original message message to obtain a first message message; the target freshness value and the first message message are concatenated to obtain the target message message. Since the present application changes the generation method of the freshness value and the message authentication code and the insertion position in the original message message, the problem that the message message is easily cracked by force in the related art is solved, and the effect of increasing the difficulty of the message message being cracked by force is achieved.
[0044] In an exemplary embodiment, obtaining an original message message, a data transmission resource, a first freshness value and an original identifier of the original message message includes: sending a first request instruction to a first message component, wherein the first message component is used to generate the original identifier when the original message message is obtained, and store the original message message and the original identifier; receiving the original message message and the original identifier sent by the first message component in response to the first request instruction; sending a second request instruction to a second message component, wherein the second message component includes the stored data transmission resource; receiving the data transmission resource sent by the second message component in response to the second request; sending a third request instruction to a third message component, wherein the third message component includes storing the first freshness value, wherein the first freshness value is a timestamp generated by a timer when the original message message is generated; receiving the first freshness value sent by the third message component in response to the third request instruction; wherein the first message component, the second message component and the third message component are all integrated in the same electronic control device.
[0045] Optionally, the communication network is composed of two or more ECUs, including one or more message sender ECU components and one or more message receiver ECU components. The main control unit ECU component and the message sender ECU component can be the same ECU, or the main control unit ECU component can be a separate ECU, wherein the main control unit ECU component is used to send synchronization messages, including but not limited to the synchronization of the first fresh value during the maintenance communication process. Figure 3 As shown, Figure 3 It is an architecture diagram of a method for generating a message message in a specific embodiment of the present application. The message sender electronic control unit component sends a first request instruction to the first message component: the original message message electronic control unit component (Electronic Control Unit, referred to as ECU), requesting to obtain the original message message and the original identifier. The message sender electronic control unit component sends a second request instruction to the second message component: the data transmission resource ECU component, requesting to obtain the data transmission resource. The message sender electronic control unit component sends a third request instruction to the third message component: the first fresh value ECU component, requesting to obtain the first fresh value. For example, assuming that an autonomous driving car is driving, the first message component detects the congestion of the road ahead through its sensor and generates a 100-byte original message message containing congestion information. At the same time, the system of the autonomous driving car generates a 20-byte original identifier for uniquely identifying the original message message. The second message component stores the CAN bus resources of the current autonomous driving car system. The third message component generates a timestamp based on an 8-byte monotonically increasing counter at the same time as the original message message is generated. This timestamp represents the exact time when the message is generated, as the first fresh value. The message sender ECU component sends request instructions to the first message component, the second message component and the third message component respectively to obtain the original message message, the original identifier, the data transmission resource and the first fresh value. This embodiment reduces hardware requirements and reduces costs by integrating multiple components into the same electronic control device. At the same time, the integrated components can respond to requests quickly, thereby reducing the information processing and transmission time in the communication network.
[0046] In an exemplary embodiment, a first truncation operation is performed on the first freshness value based on the message byte length of the original message message and the data transmission resources to obtain a target freshness value, including: determining resource limitations in the data transmission resources, wherein the resource limitations include transmission bandwidth limitations and network load limitations, the transmission bandwidth limitations are used to limit the data transmission rate of the data transmission bus, and the network load limitations are used to limit the amount of data transmitted by the data transmission bus; obtaining the bandwidth limitation byte length included in the transmission bandwidth limitation and the load limitation byte length included in the network load limitation, and calculating the first target truncation length of the first freshness value according to the bandwidth limitation byte length, the load limitation byte length and the message byte length of the original message message; and truncating the byte length matching the first target truncation length from the first preset byte position of the first freshness value to obtain the target freshness value.
[0047] In an exemplary embodiment, the first target truncation length of the first fresh value is calculated according to the bandwidth limit byte length, the load limit byte length and the message byte length of the original message message, including one of the following: when the load limit byte length is less than the first preset length and the first sum value between the message byte length and the byte length of the first fresh value satisfies the bandwidth limit byte length, the first truncation length is determined as the first target truncation length, wherein the first truncation length is a truncation length corresponding to the first preset length and the first sum value; when the load limit byte length is greater than the second preset length and the second sum value between the message byte length and the byte length of the first fresh value satisfies the bandwidth limit byte length, the second truncation length is determined as the first target truncation length, wherein the second truncation length is a truncation length corresponding to the second preset length and the second sum value; wherein the first truncation length is less than the second truncation length.
[0048] Optionally, when the data transmission resources in the communication network are tight, the byte length of the first fresh value can be reduced and the byte length of the first fresh value can be retained; when the data transmission resources in the communication network are not tight, the byte length of the first fresh value can be increased and the byte length of the first fresh value can be retained. For example, assuming that the data transmission resources have the following restrictions: transmission bandwidth limit: 100Mbps, network load limit: a maximum of 300 bytes per second, where bandwidth limit byte length: 6.25*10 6Bytes, load limit byte length: 300 bytes. The message byte length of the original message message is 100 bytes, and the byte length of the first fresh value is 8 bytes. Since the byte length and value of the original message message and the first fresh value (108 bytes) meet the bandwidth limit byte length and load limit 6.25*10 6 Bytes, but the load limit byte length is 300 bytes, which is less than the first preset length of 500 bytes. The data transmission resources in the current communication network are tight. 5 bytes (first truncation length) can be intercepted from the first preset byte position of the 8-byte first fresh value with higher importance to obtain the target fresh value. For example, in the 8-byte first fresh value, the year occupies 3 bytes, and the month, day, hour, minute, and second each occupy 1 byte. Due to the tight data transmission resources in the communication network, the complete year can be not stored. A length of 5 bytes can be intercepted from the month, and 5 bytes of month, day, hour, minute, and second are retained to obtain the target fresh value. This embodiment is only an example for illustration, and does not limit the first preset byte position, the first preset length, the first truncation length, etc. In specific applications, it can be dynamically adjusted and set according to the actual communication network. Through the truncation operation, this embodiment can ensure that data is efficiently transmitted under limited network resources and avoid network congestion. At the same time, through reasonable truncation of data, it achieves the purpose of reducing unnecessary data transmission, improving transmission efficiency, ensuring the transmission of truncated fresh values, and ensuring the timeliness of message messages.
[0049] In an exemplary embodiment, based on the original message message, the original identifier, the first freshness value and the message byte length of the original message message, target message authentication data is generated, including: determining the byte length of the target freshness value, the message byte length of the original message message, and the byte length of the first freshness value, and performing an XOR operation on the original message message, the original identifier and the first freshness value to obtain an original message authentication code; performing an encoding operation on the original message authentication code to obtain a message authentication code, wherein the encoding operation includes an operation of encrypting the original message authentication code; performing a quotient operation on the byte length of the target freshness value and the byte length of the message authentication code, and performing a remainder operation on the obtained first operation result, and determining the obtained first remainder as the first interception position of the message authentication code; intercepting a first preset byte length from the first interception position of the message authentication code to obtain the target message authentication code, wherein the byte length of the target message authentication code is less than the byte length of the message authentication code.
[0050] In an exemplary embodiment, target message authentication data is generated based on the original message message, the original identifier, the first fresh value and the byte length of the original message message, including: performing a quotient operation on the byte length of the first fresh value and the message byte length of the original message message, and performing a remainder operation on the second operation result to obtain a second remainder; determining the insertion position included in the target message authentication data according to the second remainder.
[0051] Optionally, the first preset byte length can be dynamically adjusted according to data transmission resources. For example, when data transmission resources in the communication network are tight, the byte length of the message authentication code can be reduced and the byte length of the message authentication code can be retained; when data transmission resources in the communication network are not tight, the byte length of the message authentication code can be increased and the byte length of the message authentication code can be retained. Figure 3As shown, the message sender ECU component calls the soft algorithm ECU component, and uses the encryption algorithm such as the secure hash algorithm to first perform an XOR operation on the original message message, the original identifier, and the first fresh value to obtain the original message authentication code, and then performs an encoding operation on the original message authentication code to obtain the message authentication code. Then the message sender ECU component calls the authentication code embedding algorithm ECU component to determine the first interception position of the message authentication code, and intercepts the message authentication code to obtain the target message authentication code. Taking the secure hash algorithm 256 ("Secure Hash Algorithm 256", abbreviated as SHA256) as an example, SHA256 performs an XOR operation on the original message message, the original identifier, and the first fresh value in binary to obtain the original message authentication code, and then performs an encoding operation on the original message authentication code to obtain a 256-bit, 32-byte message authentication code. The authentication code embedding algorithm ECU component selects the message authentication code content according to the result of the remainder of 32 of the byte length of the target fresh value, where the remainder result is the first interception position. For example, if the byte length of the target fresh value is 4 bytes and the first preset byte length is 3, the remainder result is 4, the first interception position is 4, and the required byte numbers are 3, 4, and 5. The data of these three byte positions are the target message authentication code; for another example, if the byte length of the target fresh value is 30 bytes and the first preset byte length is 5, the remainder result is 30, the first interception position is 30, and the required byte numbers are 29, 30, 31, 0, and 1. The data of these 5 byte positions are the target message authentication code. Finally, the insertion position of the target message authentication code in the original message is determined by the remainder of the byte length of the first fresh value and the message byte length of the original message message. For example, if the remainder is 0, the target message authentication code is completely located before the original message message; Example 2: If the remainder is 3, the target message authentication code is inserted after the third byte of the original message message. This embodiment, based on the standard SecOC, achieves the purpose of increasing the difficulty of forced cracking of message messages by changing the algorithm for generating the target message authentication code and the selection of the truncated content of the target message authentication code.
[0052] The present invention will be described below in conjunction with specific embodiments:
[0053] Figure 4 is a flowchart of a method for generating a message message according to a specific embodiment of the present application, such as Figure 4 As shown, the following steps are included:
[0054] S402, when an autonomous vehicle is driving, the first message component detects the congestion of the road ahead through its sensor and generates a 100-byte original message message containing congestion information. At the same time, the system of the autonomous vehicle generates a 20-byte original identifier for uniquely identifying the original message message. The second message component stores the CAN bus resources of the current autonomous vehicle system. The third message component generates a timestamp based on an 8-byte monotonically increasing counter at the same time as the original message message is generated. This timestamp represents the precise time when the message is generated as the first fresh value.
[0055] The message sender ECU component sends request instructions to the first message component, the second message component and the third message component respectively to obtain the original message message, the original identifier, the data transmission resource and the first fresh value. And based on the restrictions in the CAN bus resources: transmission bandwidth limit: 100Mbps, network load limit: a maximum of 300 bytes per second, where the bandwidth limit byte length: 6.25*10 6 Bytes, load limit byte length: 300 bytes, the byte length and value of the original message and the first fresh value (108 bytes) meet the bandwidth limit byte length and load limit 6.25*10 6 Bytes, but the load limit byte length is 300 bytes, which is less than the first preset length of 500 bytes. It is determined that the data transmission resources in the current communication network are tight, and the first fresh value truncation length (first target truncation length) is determined to be 5 bytes and the message authentication code truncation length (first preset byte length) is determined to be 3 bytes.
[0056] The message sender ECU component intercepts 5 bytes (first truncation length) from the first preset byte position of higher importance in the 8-byte first fresh value to obtain the target fresh value. For example, in the 8-byte first fresh value, the year occupies 3 bytes, and the month, day, hour, minute, and second each occupy 1 byte. Due to the limited data transmission resources in the communication network, the complete year may not be stored. A length of 5 bytes is intercepted from the month, and 5 bytes of month, day, hour, minute, and second are retained to obtain the target fresh value.
[0057] S404, the message sender ECU component calls the soft algorithm ECU component, and uses SHA256 to perform an XOR operation on the original message message, the original identifier, and the first fresh value in binary to obtain the original message authentication code, and then performs an encoding operation on the original message authentication code to obtain a 256-bit, 32-byte message authentication code. The authentication code embedding algorithm ECU component selects the message authentication code content according to the result of taking the remainder of 32 by the byte length of the target fresh value, where the remainder result is the first interception position. For example, if the byte length of the target fresh value is 5 bytes and the first preset byte length is 3, then the remainder result is 5, the first interception position is 4, and the required byte numbers are 4, 5, and 6. The data at these three byte positions is the target message authentication code. Then, the insertion position of the target message authentication code in the original message message is determined by using the remainder 8 of the byte length 8 of the first fresh value and the message byte length 100 of the original message message: the target message authentication code is inserted after the 8th byte of the original message message;
[0058] S406, finally concatenate the target freshness value and the first message to obtain the target message, such as Figure 5 shown.
[0059] This embodiment, based on the standard SecOC, achieves the purpose of increasing the difficulty of forced cracking of message messages by changing the algorithm for generating the target message authentication code and the selection of the truncated content of the target message authentication code.
[0060] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods of each embodiment of the present application.
[0061] In the present embodiment, a message message generation device is also provided, and the device is used to implement the above-mentioned embodiment and preferred implementation mode, and the description has been made no further. As used below, the term "module" can implement a combination of software and / or hardware of a predetermined function. Although the system described in the following embodiments is preferably implemented in software, the implementation of hardware, or a combination of software and hardware is also possible and conceived.
[0062] Figure 6 is a structural block diagram of a message generation device according to an embodiment of the present application, such as Figure 6As shown, the device comprises:
[0063] A first acquisition module 602 is used to acquire an original message message, a data transmission resource, a first freshness value, and an original identifier of the original message message, wherein the first freshness value is used to indicate the timeliness of the original message message, the original identifier is used to uniquely identify the original message message, and the data transmission resource is used to indicate the communication capability of the data transmission bus;
[0064] A first execution module 604 is configured to perform a first truncation operation on the first fresh value based on the message byte length of the original message message and the data transmission resource to obtain a target fresh value, wherein the byte length of the target fresh value is less than the byte length of the first fresh value;
[0065] A first generating module 606 is configured to generate target message authentication data based on the original message message, the original identifier, the first freshness value, and the message byte length of the original message message, wherein the target message authentication data includes a target message authentication code and an insertion position of the target message authentication code to be inserted into the original message message, and the target message authentication code is used to verify the security and integrity of the original message message;
[0066] A first inserting module 608, configured to insert the target message authentication code into the original message based on the insertion position to obtain a first message;
[0067] The first splicing module 610 is used to splice the target freshness value and the first message message to obtain a target message message.
[0068] In an exemplary embodiment, the first acquisition module includes: a first sending submodule, used to send a first request instruction to a first message component, wherein the first message component is used to generate the original identifier when acquiring the original message message, and store the original message message and the original identifier; a first receiving submodule, used to receive the original message message and the original identifier sent by the first message component in response to the first request instruction; a second sending submodule, used to send a second request instruction to a second message component, wherein the second message component includes the stored data transmission resources; a second receiving submodule, used to receive the data transmission resources sent by the second message component in response to the second request; a third sending submodule, used to send a third request instruction to a third message component, wherein the third message component includes storing the first fresh value, wherein the first fresh value is a timestamp generated by a timer when the original message message is generated; a third receiving submodule, used to receive the first fresh value sent by the third message component in response to the third request instruction; wherein the first message component, the second message component and the third message component are all integrated in the same electronic control device.
[0069] In an exemplary embodiment, the first execution module includes: a first determination submodule, used to determine the resource limitations in the data transmission resources, wherein the resource limitations include transmission bandwidth limitations and network load limitations, the transmission bandwidth limitations are used to limit the data transmission rate of the data transmission bus, and the network load limitations are used to limit the amount of data transmitted by the data transmission bus; a first calculation submodule, used to obtain the bandwidth limitation byte length included in the transmission bandwidth limitation and the load limitation byte length included in the network load limitation, and calculate the first target truncation length of the first fresh value according to the bandwidth limitation byte length, the load limitation byte length and the message byte length of the original message message; a first interception submodule, used to intercept the byte length matching the first target truncation length from the first preset byte position of the first fresh value to obtain the target fresh value.
[0070] In an exemplary embodiment, the first calculation submodule includes one of the following: a first determination unit, used to determine the first truncation length as the first target truncation length when the load limit byte length is less than the first preset length and the first sum of the message byte length and the byte length of the first fresh value satisfies the bandwidth limit byte length, wherein the first truncation length is a truncation length corresponding to the first preset length and the first sum; a second determination unit, used to determine the second truncation length as the first target truncation length when the load limit byte length is greater than the second preset length and the second sum of the message byte length and the byte length of the first fresh value satisfies the bandwidth limit byte length, wherein the second truncation length is a truncation length corresponding to the second preset length and the second sum; wherein the first truncation length is less than the second truncation length.
[0071] In an exemplary embodiment, the first generation module includes: a second determination submodule, which is used to determine the byte length of the target fresh value, the message byte length of the original message message, and the byte length of the first fresh value, and perform an XOR operation on the original message message, the original identifier and the first fresh value to obtain an original message authentication code; a first execution submodule, which is used to perform an encoding operation on the original message authentication code to obtain a message authentication code, wherein the encoding operation includes an operation of encrypting the original message authentication code; a second execution submodule, which is used to perform a quotient operation on the byte length of the target fresh value and the byte length of the message authentication code, and perform a remainder operation on the first operation result obtained, and determine the obtained first remainder as the first interception position of the message authentication code; from the first interception position of the message authentication code, intercept a first preset byte length to obtain the target message authentication code, wherein the byte length of the target message authentication code is less than the byte length of the message authentication code.
[0072] In an exemplary embodiment, the above-mentioned first generation module includes: a third execution sub-module, used to perform a quotient operation on the byte length of the above-mentioned first fresh value and the message byte length of the above-mentioned original message message, and perform a remainder operation on the second operation result obtained to obtain a second remainder; a third determination sub-module, used to determine the above-mentioned insertion position included in the above-mentioned target message authentication data according to the above-mentioned second remainder.
[0073] An embodiment of the present application provides a computer program product, including a computer program, and when the computer program is executed by a processor, the steps in any one of the above method embodiments are implemented.
[0074] An embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored, wherein the computer program is configured to execute the steps of any of the above method embodiments when running.
[0075] In an exemplary embodiment, the computer-readable storage medium may include, but is not limited to, various media that can store computer programs, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk.
[0076] An embodiment of the present application further provides an electronic device, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.
[0077] In an exemplary embodiment, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.
[0078] For specific examples in this embodiment, reference may be made to the examples described in the above embodiments and exemplary implementation modes, and this embodiment will not be described in detail herein.
[0079] Obviously, those skilled in the art should understand that the above modules or steps of the present application can be implemented by a general computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be executed in a different order from that herein, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. Thus, the present application is not limited to any specific combination of hardware and software.
[0080] The above are only preferred embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the principles of the present application shall be included in the protection scope of the present application.
Claims
1. A method for generating a message, characterized in that: include: Acquire an original message message, a data transmission resource, a first freshness value, and an original identifier of the original message message, wherein the first freshness value is used to indicate the timeliness of the original message message, the original identifier is used to uniquely identify the original message message, and the data transmission resource is used to indicate the communication capability of the data transmission bus; Performing a first truncation operation on the first fresh value based on the message byte length of the original message message and the data transmission resource to obtain a target fresh value, wherein the byte length of the target fresh value is less than the byte length of the first fresh value; Generate target message authentication data based on the original message message, the original identifier, the first freshness value, and the message byte length of the original message message, wherein the target message authentication data includes a target message authentication code and an insertion position of the target message authentication code to be inserted into the original message message, and the target message authentication code is used to verify the security and integrity of the original message message; Inserting the target message authentication code into the original message based on the insertion position to obtain a first message; The target freshness value and the first message are concatenated to obtain a target message.
2. The method according to claim 1, characterized in that Acquiring an original message message, a data transmission resource, a first freshness value, and an original identifier of the original message message, including: Sending a first request instruction to a first message component, wherein the first message component is used to generate the original identifier when obtaining the original message message, and store the original message message and the original identifier; Receive the original message message and the original identifier sent by the first message component in response to the first request instruction; Sending a second request instruction to a second message component, wherein the second message component includes the stored data transmission resource; receiving the data transmission resource sent by the second message component in response to the second request; Sending a third request instruction to a third message component, wherein the third message component includes storing the first freshness value, wherein the first freshness value is a timestamp generated by a timer when the original message is generated; receiving the first fresh value sent by the third message component in response to the third request instruction; The first message component, the second message component and the third message component are all integrated in the same electronic control device.
3. The method according to claim 1, characterized in that Performing a first truncation operation on the first fresh value based on the message byte length of the original message message and the data transmission resource to obtain a target fresh value includes: Determine resource limitations in the data transmission resources, wherein the resource limitations include transmission bandwidth limitations and network load limitations, the transmission bandwidth limitations are used to limit the data transmission rate of the data transmission bus, and the network load limitations are used to limit the amount of data transmitted by the data transmission bus; Obtaining a bandwidth limit byte length included in the transmission bandwidth limit and a load limit byte length included in the network load limit, and calculating a first target truncation length of the first freshness value according to the bandwidth limit byte length, the load limit byte length, and the message byte length of the original message message; From a first preset byte position of the first fresh value, a byte length matching the first target truncation length is truncated to obtain the target fresh value.
4. The method according to claim 3, characterized in that Calculating a first target truncation length of the first fresh value according to the bandwidth limit byte length, the load limit byte length, and the message byte length of the original message message includes one of the following: When the load limit byte length is less than a first preset length and a first sum of the message byte length and the byte length of the first fresh value satisfies the bandwidth limit byte length, a first truncation length is determined as the first target truncation length, wherein the first truncation length is a truncation length corresponding to the first preset length and the first sum; When the load limit byte length is greater than a second preset length and a second sum of the message byte length and the byte length of the first fresh value satisfies the bandwidth limit byte length, a second truncation length is determined as the first target truncation length, wherein the second truncation length is a truncation length corresponding to the second preset length and the second sum; The first truncation length is smaller than the second truncation length.
5. The method according to claim 1, characterized in that Generating target message authentication data based on the original message message, the original identifier, the first freshness value, and the message byte length of the original message message includes: Determine the byte length of the target freshness value, the message byte length of the original message message, and the byte length of the first freshness value, and perform an XOR operation on the original message message, the original identifier, and the first freshness value to obtain an original message authentication code; Performing an encoding operation on the original message authentication code to obtain a message authentication code, wherein the encoding operation includes an operation of encrypting the original message authentication code; Performing a quotient operation on the byte length of the target fresh value and the byte length of the message authentication code, performing a remainder operation on the obtained first operation result, and determining the obtained first remainder as the first interception position of the message authentication code; A first preset byte length is intercepted from a first interception position of the message authentication code to obtain the target message authentication code, wherein the byte length of the target message authentication code is less than the byte length of the message authentication code.
6. The method according to claim 1, characterized in that Generating target message authentication data based on the original message message, the original identifier, the first freshness value, and the byte length of the original message message, including: Performing a quotient operation on the byte length of the first fresh value and the message byte length of the original message message, and performing a remainder operation on the obtained second operation result to obtain a second remainder; The insertion position included in the target message authentication data is determined according to the second remainder.
7. A message generation device, characterized in that: include: A first acquisition module, used to acquire an original message message, a data transmission resource, a first freshness value, and an original identifier of the original message message, wherein the first freshness value is used to indicate the timeliness of the original message message, the original identifier is used to uniquely identify the original message message, and the data transmission resource is used to indicate the communication capability of the data transmission bus; a first execution module, configured to perform a first truncation operation on the first fresh value based on a message byte length of the original message message and the data transmission resource to obtain a target fresh value, wherein the byte length of the target fresh value is less than the byte length of the first fresh value; A first generating module, configured to generate target message authentication data based on the original message message, the original identifier, the first freshness value, and the message byte length of the original message message, wherein the target message authentication data includes a target message authentication code and an insertion position of the target message authentication code to be inserted into the original message message, and the target message authentication code is used to verify the security and integrity of the original message message; A first insertion module, configured to insert the target message authentication code into the original message based on the insertion position to obtain a first message; The first splicing module is used to splice the target freshness value and the first message message to obtain a target message message.
8. The device according to claim 7, characterized in that The first execution module includes: A first determination submodule is used to determine resource limitations in the data transmission resources, wherein the resource limitations include transmission bandwidth limitations and network load limitations, the transmission bandwidth limitations are used to limit the data transmission rate of the data transmission bus, and the network load limitations are used to limit the amount of data transmitted by the data transmission bus; a first calculation submodule, configured to obtain a bandwidth limit byte length included in the transmission bandwidth limit and a load limit byte length included in the network load limit, and calculate a first target truncation length of the first fresh value according to the bandwidth limit byte length, the load limit byte length and the message byte length of the original message message; The first interception submodule is used to intercept a byte length matching the first target truncation length from a first preset byte position of the first fresh value to obtain the target fresh value.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program implements the steps of the method described in any one of claims 1 to 6 when executed by a processor.
10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method described in any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Controller area network message authentication
CN108075897A
In-vehicle network safety communication sending and receiving method and device
CN112134702A
Communication method, device and system based on communication network
CN112636898A
In-vehicle message authentication fresh value management method and system
CN113472620A