CAN bus address transition methods, devices, vehicles, and storage media
By dynamically changing the identifier and address partitioning management of CAN bus messages, the receiving node calculates the target virtual address and authentication tag, solving the problem that the CAN bus is difficult to resist denial-of-service attacks and realizing enhanced security in the vehicle environment.
Patent Information
- Application Number
- CN202611382756.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-07
- Publication Date
- 2026-11-17
AI Technical Summary
Existing security enhancement schemes for the CAN bus are insufficient to effectively defend against denial-of-service attacks, static ID filtering methods cannot distinguish the authenticity of data, traditional cryptographic algorithms have high computational overhead, and rule-based intrusion detection systems have a high false alarm rate.
By dynamically changing the identifier and address partitioning of messages, the receiving node calculates the target virtual address and authentication label, intercepts and discards abnormal messages, and achieves synchronization by correcting global and local counter values.
It effectively resists denial-of-service attacks, meets the security requirements of the vehicle environment, and improves the communication security of the CAN bus.
Smart Images

Figure CN123122948A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of vehicle communication technology, and in particular to a CAN bus address switching method, device, vehicle, and storage medium. Background Technology
[0002] As the connectivity and intelligence of vehicles continue to improve, the CAN bus is increasingly exposed to complex network threats.
[0003] Existing technologies have proposed several security enhancement schemes, including firewalls based on static identifier (ID) filtering, traditional cryptographic applications, and rule-based intrusion detection systems.
[0004] However, they are difficult to effectively defend against denial-of-service attacks. Static ID filtering methods (firewalls) are too crude and cannot distinguish the authenticity of the data itself. Directly applying traditional cryptographic algorithms generates huge computational overhead. Rule-based intrusion detection systems rely on known attack characteristics and have a high false alarm rate, which urgently need to be addressed. Summary of the Invention
[0005] This application provides a CAN bus address switching method, device, vehicle, and storage medium to solve the problem that current security enhancement schemes for CAN buses are difficult to effectively resist denial-of-service attacks. By dynamically changing the identifier and address partitioning management of messages, denial-of-service attacks are effectively resisted, meeting the application requirements of the vehicle environment.
[0006] The first aspect of this application provides a method for hopping a CAN bus address, comprising the following steps: a receiving node calculates the domain number and area number corresponding to the original message sent by the sending node, and calculates the target virtual address and target authentication tag corresponding to the original message based on the domain number and area number; the receiving node intercepts and discards abnormal messages in the original message sent by the sending node based on the target virtual address and target authentication tag corresponding to the original message; the receiving node corrects its global counter value based on the global counter value broadcast by the gateway, and corrects its local counter value based on the local counter value broadcast by the sending node.
[0007] Optionally, the calculation of the domain number and area number corresponding to the original message includes: counting all protected messages of the receiving node and the unique index number of all protected messages; dividing all protected messages into domains and partitions to obtain the number of domains and the number of partitions of the receiving node; and obtaining the domain number and area number corresponding to the original message of the receiving node based on the number of domains, the number of partitions, and the unique index number of all protected messages of the receiving node.
[0008] Optionally, calculating the target virtual address corresponding to the original message based on the domain number and area number corresponding to the original message includes: calculating a first hash value based on the global counter of the receiving node, a first temporary key, and a first temporary seed; generating a target domain address based on the first hash value and the domain number of the original message; generating and calculating a second hash value based on the global counter, a second temporary key, and a second temporary seed; generating a target area address based on the second hash value and the domain number and area number of the original message; calculating a third hash value based on a third temporary key, a third temporary seed, and a local counter; generating a target service address based on the third hash value, the domain number and area number of the original message; and concatenating the target domain address, the target area address, and the target service address to obtain the target virtual address.
[0009] Optionally, determining the first temporary key and the first temporary seed, the second temporary key, the second temporary seed, the third temporary key, and the third temporary seed includes: the receiving node receiving an initial random number broadcast by the gateway; deriving the first temporary key and the first temporary seed based on the initial random number and the global shared key of the receiving node; deriving the second temporary key and the second temporary seed based on the initial random number, the global shared key of the receiving node, and the domain number corresponding to the original message; and deriving the third temporary key and the third temporary seed based on the initial random number and the private key of the receiving node.
[0010] Optionally, calculating the target authentication tag corresponding to the original message based on the domain number and area code corresponding to the original message further includes: the receiving node receiving the original message data packet sent by the sending node; and performing a hash encryption operation on the message authentication code algorithm based on the local counter of the receiving node, the third temporary key, and the original message data packet to obtain the target authentication tag corresponding to the original message.
[0011] Optionally, the receiving node intercepts and discards abnormal messages in the messages sent by the sending node based on the target virtual address and target authentication label corresponding to the original message, including: receiving the initial virtual address and initial authentication label carried in the original message data packet sent by the sending node; identifying a first abnormal message in the original message whose initial virtual address is inconsistent with the target virtual address, intercepting and discarding the first abnormal message to obtain the remaining message; identifying a second abnormal message in the remaining message whose initial authentication label is inconsistent with the target authentication label, intercepting and discarding the second abnormal message.
[0012] Optionally, the global counter value of the receiving node is corrected based on the global counter value broadcast by the gateway, and the local counter value of the receiving node is corrected based on the local counter value broadcast by the sending node. This includes: the receiving node receiving the global counter broadcast by the gateway and the local counter broadcast by the sending node; in response to a discrepancy between the global counter value broadcast by the gateway and the global counter value of the receiving node, the global counter of the receiving node is corrected based on the global counter broadcast by the gateway; in response to a discrepancy between the local counter value broadcast by the sending node and the local counter value of the receiving node, the local counter of the receiving node is corrected based on the local counter broadcast by the sending node.
[0013] A second aspect of this application provides a CAN bus address switching device, comprising: a calculation module, configured to calculate the domain number and area number corresponding to the original message, and calculate the target virtual address and target authentication tag corresponding to the original message based on the domain number and area number corresponding to the original message; an inspection module, configured to intercept and discard abnormal messages in messages sent by the sending node based on the target virtual address and target authentication tag corresponding to the original message; and a synchronization module, configured to correct the global counter value of the receiving node based on the global counter value broadcast by the gateway, and correct the local counter value of the receiving node based on the local counter value broadcast by the sending node.
[0014] Optionally, the calculation module is configured to: count all protected messages and unique index numbers of all protected messages of the receiving node; divide all protected messages into domains and partitions to obtain the number of domains and partitions of the receiving node; and obtain the domain number and partition number corresponding to the original message of the receiving node based on the number of domains, the number of partitions, and the unique index numbers of all protected messages of the receiving node.
[0015] Optionally, the calculation module is configured to: calculate a first hash value based on the global counter of the receiving node, a first temporary key, and a first temporary seed; generate a target domain address based on the first hash value and the domain number of the original message; generate and calculate a second hash value based on the global counter, a second temporary key, and a second temporary seed; generate a target area address based on the second hash value and the domain number and area number of the original message; calculate a third hash value based on a third temporary key, a third temporary seed, and a local counter; generate a target service address based on the third hash value, the domain number and area number of the original message; and concatenate the target domain address, the target area address, and the target service address to obtain the target virtual address.
[0016] Optionally, the calculation module is configured to: receive an initial random number broadcast by the gateway; derive a first temporary key and a first temporary seed based on the initial random number and the global shared key of the receiving node; derive a second temporary key and a second temporary seed based on the initial random number, the global shared key of the receiving node, and the domain number corresponding to the original message; and derive a third temporary key and a third temporary seed based on the initial random number and the private key of the receiving node.
[0017] Optionally, the calculation module is configured to: the receiving node receive the original message data packet sent by the sending node; and based on the local counter of the receiving node, the third temporary key, and the original message data packet, perform a hash encryption operation using a message authentication code algorithm to obtain the target authentication tag corresponding to the original message.
[0018] Optionally, the inspection module is configured to: receive the initial virtual address and initial authentication tag carried in the original message data packet sent by the sending node; identify a first abnormal message in the original message whose initial virtual address is inconsistent with the target virtual address, intercept and discard the first abnormal message to obtain the remaining message; identify a second abnormal message in the remaining message whose initial authentication tag is inconsistent with the target authentication tag, intercept and discard the second abnormal message.
[0019] Optionally, the synchronization module is configured to: receive a global counter broadcast by the gateway and a local counter broadcast by the sending node; in response to a discrepancy between the global counter value broadcast by the gateway and the global counter value of the receiving node, correct the global counter of the receiving node according to the global counter broadcast by the gateway; and in response to a discrepancy between the local counter value broadcast by the sending node and the local counter value of the receiving node, correct the local counter of the receiving node according to the local counter broadcast by the sending node.
[0020] A third aspect of this application provides a vehicle, including: a memory, a processor, and a computer program stored in the memory and capable of running on the processor, wherein the processor executes the program to implement the CAN bus address transition method as described in the above embodiments.
[0021] A fourth aspect of this application provides a non-volatile computer-readable storage medium having a computer program stored thereon, which is executed by a processor to implement the CAN bus address transition method as described in the above embodiments.
[0022] In the above implementation, the receiving node calculates the domain number and area code corresponding to the original message sent by the sending node, and calculates the target virtual address and target authentication tag corresponding to the original message based on the domain number and area code. The receiving node intercepts and discards abnormal messages in the original message sent by the sending node based on the target virtual address and target authentication tag. The receiving node corrects its global counter value based on the global counter value broadcast by the gateway, and corrects its local counter value based on the local counter value broadcast by the sending node. This solves the problem that current security enhancement schemes for the CAN bus are difficult to effectively resist denial-of-service attacks. By dynamically changing the identifier and address partition management of the message, denial-of-service attacks are effectively resisted, meeting the application requirements of the automotive environment.
[0023] Additional aspects and advantages of this application will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of this application. Attached Figure Description
[0024] The above and / or additional aspects and advantages of this application will become apparent and readily understood from the following description of the embodiments taken in conjunction with the accompanying drawings, wherein: Figure 1 This is a flowchart illustrating a CAN bus address transition method according to an embodiment of this application; Figure 2 This is a flowchart illustrating the communication node interaction process according to an embodiment of this application; Figure 3 This is a flowchart of an order-preserving random number generation algorithm according to an embodiment of this application; Figure 4 This is a flowchart of a CAN bus address transition method according to an embodiment of this application; Figure 5 This is a schematic diagram of a CAN bus address switching device according to an embodiment of this application; Figure 6 This is a schematic diagram of a vehicle according to an embodiment of this application. Detailed Implementation
[0025] The embodiments of this application are described in detail below. Examples of these embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and intended to explain this application, and should not be construed as limiting this application.
[0026] The following description, with reference to the accompanying drawings, outlines a CAN bus address transition method, apparatus, vehicle, and storage medium according to embodiments of this application. Addressing the problem mentioned in the background art that current security enhancement schemes for the CAN bus are ineffective in resisting denial-of-service attacks, this application provides a CAN bus address transition method. In this method, the receiving node calculates the domain number and area number corresponding to the original message sent by the sending node, and calculates the target virtual address and target authentication tag corresponding to the original message based on the domain number and area number. The receiving node intercepts and discards abnormal messages in the original message sent by the sending node based on the target virtual address and target authentication tag. The receiving node corrects its global counter value based on the global counter value broadcast by the gateway, and corrects its local counter value based on the local counter value broadcast by the sending node. This solves the problem that current security enhancement schemes for the CAN bus are ineffective in resisting denial-of-service attacks. By dynamically changing the message identifier and address partition management, denial-of-service attacks are effectively resisted, meeting the application requirements of the automotive environment.
[0027] Specifically, Figure 1 This is a flowchart illustrating a CAN bus address transition method provided in an embodiment of this application.
[0028] like Figure 1 As shown, the CAN bus address transition method includes the following steps: In step S101, the receiving node calculates the domain number and area number corresponding to the original message sent by the sending node, and calculates the target virtual address and target authentication tag corresponding to the original message based on the domain number and area number corresponding to the original message.
[0029] Optionally, in some embodiments, calculating the domain number and area number corresponding to the original message includes: counting all protected messages of the receiving node and the unique index number of all protected messages, dividing all protected messages into domains and partitions to obtain the number of domains and the number of partitions of the receiving node; and obtaining the domain number and area number corresponding to the original message of the receiving node based on the number of domains, the number of partitions, and the unique index number of all protected messages of the receiving node.
[0030] Specifically, the process involves counting all protected messages and their unique index numbers at the receiving node, then dividing the protected message IDs into domains and partitions to determine the number of domains and partitions within each subspace. Given the number of IDs n, and using k IDs as a domain, k can be calculated as follows:
[0031] The number of domains can be calculated as follows: ; At the same time, the number of regions contained under the same DID (Domain ID) can be determined.
[0032] The domain number corresponding to the i-th original message ID for:
[0033] The area code corresponding to the i-th original message ID for:
[0034] Taking 11 original message IDs as an example, based on the above design, the number of domains is calculated to be 4, resulting in the following domain partitioning results: The domain number and area code corresponding to the original message ID involved in this application are shown in Table 1.
[0035] Table 1
[0036] Optionally, in some embodiments, calculating the target virtual address corresponding to the original message based on the domain number and area number corresponding to the original message includes: calculating a first hash value based on the global counter of the receiving node, a first temporary key, and a first temporary seed; generating a target domain address based on the first hash value and the domain number of the original message; generating and calculating a second hash value based on the global counter, a second temporary key, and a second temporary seed; generating a target area address based on the second hash value and the domain number and area number of the original message; calculating a third hash value based on a third temporary key, a third temporary seed, and a local counter; generating a target service address based on the third hash value, the domain number and area number of the original message; and concatenating the target domain address, the target area address, and the target service address to obtain the target virtual address.
[0037] Specifically, in the process of calculating the target virtual address of the i-th ID, the receiving node uses two types of counters: the global counter GCTR (used to count the trees of all messages on the bus) and a local counter. (Used to count the number of the i-th ID). The global counter is used to calculate the area address and domain address, and the local counter is used to calculate the service address.
[0038] Explanation of the calculation of the target virtual address for the i-th original message ID: First, calculate the domain address DID. Let H be the hash function, using the first temporary seed. First temporary key Generate the first hash value with the global counter GCTR :
[0039] Let F be the proposed "order-preserving random number generation algorithm based on hash function". This algorithm truncates a string to a specific length k, repeats the operation until a target set of n numbers is generated, and then sorts the results. The candidate address set can then be calculated. for:
[0040] The DID of the i-th original message ID can be used to obtain the target domain address based on its priority position (domain number):
[0041] in, This means extracting the x-th element from set a.
[0042] Similarly, based on the domain number corresponding to the i-th ID and area code Calculate the RID (Region Address, Reign ID). Use the second temporary seed. Second temporary key Generate a second hash value with the global counter GCTR
[0043]
[0044] Calculate the candidate address set for:
[0045] The RID of the i-th original message ID can be determined based on its priority position (domain number). The target area address is obtained:
[0046] Next, calculate the SID (Service ID) of the i-th original message ID. Use the third temporary seed. Third temporary key and local counter Generate a third hash value
[0047]
[0048] Since SID generation does not involve sorting, extracting one element from the hash value is sufficient to meet the requirement, i.e., the candidate service address. for:
[0049] The SID of the i-th ID can be determined based on its priority position (domain number). Obtain the target service address:
[0050] Finally, the connection , , The target virtual address can then be obtained. :
[0051] It should be noted that there are many methods for determining the first temporary key and the first temporary seed, the second temporary key, the second temporary seed, the third temporary key, and the third temporary seed. These methods will be explained in detail below with reference to specific embodiments.
[0052] In one possible implementation, in some embodiments, determining the first temporary key and the first temporary seed, the second temporary key, the second temporary seed, the third temporary key, and the third temporary seed includes: the receiving node receiving an initial random number broadcast by the gateway; deriving the first temporary key and the first temporary seed based on the initial random number and the receiving node's global shared key; deriving the second temporary key and the second temporary seed based on the initial random number, the receiving node's global shared key, and the domain number corresponding to the original message; and deriving the third temporary key and the third temporary seed based on the initial random number and the receiving node's private key.
[0053] Specifically, temporary keys and seed derivation are performed based on the long-term key. A specific trusted ECU node (e.g., a gateway) generates a 32-bit random number. The message is then broadcast to the bus. A secure MAC algorithm is used to ensure authenticity. Considering the limited payload of CAN messages, the authentication tag is 32 bits long, the message ID is 0x00, and the data m is:
[0054] in, For global keys, This is a global counter.
[0055] After receiving the message, other nodes on the bus extract the initial random number. and using a global shared key and counter Recalculate the authentication tag to verify the message's authenticity. After confirming the message's legitimacy, use the seed tag respectively. Using its own key as a parameter, multiple temporary seeds and keys are derived through a secure KDF function. Specifically, these include: (1) a first temporary key used to control the DID transformation. and the first temporary seed (2) A second temporary key used to control the RID transformation Second temporary seed (3) The third temporary seed used to control the SID transformation and the third key used for each ID authentication The specific calculation method is as follows:
[0056]
[0057]
[0058] in, It is the first Domain number of each ID.
[0059] Optionally, in some embodiments, calculating the target authentication tag corresponding to the original message based on the domain number and area code corresponding to the original message further includes: the receiving node receiving the original message data packet sent by the sending node; and based on the local counter of the receiving node, the third temporary key, and the original message data packet, performing a hash encryption operation through a message authentication code algorithm to obtain the target authentication tag corresponding to the original message.
[0060] The message sender uses a MAC method to calculate an authentication tag to ensure the message's authenticity and integrity. Specifically, the proposed method uses the 8th byte of the message to fill the authentication tag, employing the classic HMAC algorithm. Furthermore, to defend against replay attacks, a counter is used as one of the input parameters when calculating the authentication tag. The authentication tag MAC calculation method is as follows:
[0061] in, It is the raw message data. For the third temporary key, This is a local counter.
[0062] The 8-byte payload 'm' of the data packet to be sent is the concatenation of the original message data and the authentication tag:
[0063] Similarly, the message recipient also... Calculate the target authentication tag corresponding to the original message to obtain the target authentication tag. .
[0064] In step S102, the receiving node intercepts and discards abnormal messages in the original message sent by the sending node based on the target virtual address and target authentication tag corresponding to the original message.
[0065] Optionally, in some embodiments, the receiving node intercepts and discards abnormal messages in the message sent by the sending node based on the target virtual address and target authentication label corresponding to the original message, including: receiving the initial virtual address and initial authentication label carried in the original message data packet sent by the sending node; identifying a first abnormal message in the original message whose initial virtual address is inconsistent with the target virtual address, intercepting and discarding the first abnormal message to obtain the remaining message; identifying a second abnormal message in the remaining message whose initial authentication label is inconsistent with the target authentication label, intercepting and discarding the second abnormal message.
[0066] Specifically, the receiver performs ID and load checks on received messages based on the target virtual address and target authentication tag corresponding to the original message, detecting and discarding malicious messages. Although virtual addresses change dynamically, attackers still have the opportunity to break through the address hopping mechanism (or low-probability collisions) by brute force when the address space is limited. Therefore, by combining message authentication code technology to construct a load check mechanism, the authenticity of messages is further protected.
[0067] If the initial virtual address (VID) carried by the current message matches the calculated target virtual address (VID), the message is considered normal and the data is received. Otherwise, the message is considered abnormal and is discarded.
[0068] If the target authentication label is calculated If the MAC address matches the initial authentication tag (MAC) carried in the message, it is considered a normal message and processed accordingly. If they do not match, it is considered an anomaly and the message is discarded.
[0069] In step S103, the receiving node corrects its global counter value based on the global counter value broadcast by the gateway, and corrects its local counter value based on the local counter value broadcast by the sending node.
[0070] Optionally, in some embodiments, the global counter value of the receiving node is corrected based on the global counter value broadcast by the gateway, and the local counter value of the receiving node is corrected based on the local counter value broadcast by the sending node. This includes: the receiving node receiving the global counter broadcast by the gateway and the local counter broadcast by the sending node; in response to a discrepancy between the global counter value broadcast by the gateway and the global counter value of the receiving node, the global counter of the receiving node is corrected based on the global counter broadcast by the gateway; in response to a discrepancy between the local counter value broadcast by the sending node and the local counter value of the receiving node, the local counter of the receiving node is corrected based on the local counter broadcast by the sending node.
[0071] Specifically, for the global counter GCTR, it is assumed that a trusted node (e.g., a gateway) on the bus periodically sends a message GSync containing the global counter value for synchronization. For local counters... The message sender will also periodically send messages containing local counter values. To perform synchronization. At the same time, the synchronization messages GSync and... Integrity is ensured using the MAC method. The ECU on the bus receives a message containing the global counter value (GSync) and a message containing the local counter value. Next, verify the authenticity and completeness of the message. Once it is confirmed to be a legitimate message, observe whether there is a discrepancy between the counter value it carries and the local counter. If there is a discrepancy, update its own counter to the correct value.
[0072] To prevent attackers from manipulating synchronization messages, the IDs of synchronization messages are randomized during the initialization phase. Specifically, when the gateway broadcasts a random number... Subsequently, each ECU calculates a random domain address RZ based on the random number and the shared GK according to the following formula. The first ID address under this domain address is used as the virtual ID of the global counter synchronization message GSync, and the local counter synchronization message of the i-th real ID is used as the virtual ID. The virtual ID is the (i+1)th ID address under that domain address.
[0073]
[0074] For example, in the ID confirmation process of a synchronization message, assuming the address length is 11 bits, and the domain address, zone address, and service address are generated using a 4:4:3 partitioning method, the random value RZ calculated by the above formula is "0010" (binary form). Then, "00100000000" (binary form) is the virtual ID of the global counter synchronization message GSync, and "00100000001" (binary form) is the synchronization message with the first real ID. The virtual ID, "00100000010" (in binary form), is the synchronization message for the second real ID. The virtual ID is assigned to each ID, and subsequent IDs follow the same pattern.
[0075] The communication node interaction flowchart involved in the embodiments of this application is as follows: Figure 2 As shown.
[0076] The process includes an initialization phase and a transmission phase. The initialization phase comprises two sub-steps: ID classification and temporary key and seed generation. The transmission phase comprises three sub-steps: message sending, message receiving, and node synchronization. During initialization, each ECU node classifies the protected IDs according to an algorithm, calculates the domain number and area number of the ID, and determines the transition subspace for each ID. Simultaneously, with the assistance of the gateway node, it generates the temporary key and seed required for address transitions, ensuring the randomness and unpredictability of ID transitions. During transmission, message senders perform random ID transitions based on their respective temporary keys and seeds. Specifically, the sending node calculates the virtual address and authentication tag according to a predetermined algorithm. Simultaneously, the receiving node calculates the expected virtual address using the shared key and seed, and performs ID and payload checks on received data packets, detecting and discarding malicious data packets. To prevent communication failures due to node asynchrony, each node performs counter correction with the assistance of the gateway node, thereby achieving communication synchronization.
[0077] During the initialization phase, each communication node classifies the protected IDs and determines the subspace for each ID transition. The original ID of a message is designated as the "real ID," and the ID transmitted on the bus is called the "virtual ID." The virtual ID consists of three parts: Domain ID (DID), Region ID (RID), and Service ID (SID). The Domain ID and Region ID (RID) control message priority and are continuously changed to maintain the long-term dynamism of the virtual ID. The Service ID (SID) changes randomly within a certain boundary range to ensure one ID per message.
[0078]
[0079] Parallel symbol This indicates a series connection.
[0080] Meanwhile, with the assistance of independent trusted nodes (gateways), each ECU generates the key and seed required for the ID transition, ensuring the randomness and unpredictability of the ID transition. Pre-installed long-term symmetric keys include GK (Global Key) and LK (Local Key), where GK is shared by all IDs, and LK is unique to each ID. GK serves two purposes: (1) indicating legitimate identity; (2) subsequent DID and RID transformations. LK serves two purposes: (1) SID transformation; (2) guaranteeing the authenticity of the message payload. Furthermore, the ECU knows the ID's index number. and the total number of IDs .
[0081] During the transmission phase, the sender dynamically transforms the ID based on its own temporary key and temporary seed, and calculates the virtual address and authentication tag according to a predetermined algorithm. The predetermined algorithm uses three different temporary seeds. , , To dynamically transform the first Each ID has a DID, RID, and SID. Since the generation processes for these three address parts are independent, they are calculated using the same algorithm.
[0082] The predetermined algorithm is an order-preserving random number generation algorithm based on a hash function, whose function is to generate random numbers from... The address space selects n unique k-bit random numbers, sorted in ascending order. The basic operation steps are as follows: Figure 3 As shown: (1) Truncate the hash value to generate multiple non-repeating candidate addresses (2) Deduplicate and sort the candidate addresses (3) Output the results.
[0083] With the assistance of an independent trusted node (gateway), each ECU synchronizes via counters and a broadcast mechanism on the CAN bus. This includes the global counter GCTR and local counters. Initially, all values are 0. After the sender sends the data packet with the i-th ID, the local counter... Both the global counter (GCTR) and the local counter (GCTR) are incremented by 1. After the receiver receives a valid data packet with the i-th ID, its local counter is incremented. It will increment by 1. Furthermore, the global counter GCTR will increment by 1 regardless of what data the receiver receives. Through this design, the two counters on both the sender and receiver will always remain synchronized.
[0084] To enable those skilled in the art to further understand the CAN bus address transition method of the embodiments of this application, the following detailed description is provided in conjunction with specific embodiments, such as... Figure 4 As shown.
[0085] This method consists of four main steps: ID hierarchical and configuration parameter generation, temporary key and seed generation, secure communication, and synchronization of each node's dependency counter.
[0086] S401, regional classification, splits the ID address space of CAN messages into domain address, zone address, and service address, and calculates the domain level and zone level of each ID based on the total number of IDs on the bus and the index number of each ID. S402, Temporary key and temporary seed derivation: The communication node derives a temporary key and a temporary seed for address transformation based on the random seed issued by the trusted node and in combination with pre-injected or calculated security elements. S403, Secure Data Transmission and Anomaly Detection: The data sender calculates a virtual ID based on elements such as ID level, temporary key, and counter, and generates a corresponding authentication tag based on message authentication code technology; the data receiver calculates the virtual address and authentication tag in the same way, and detects whether the data packet is abnormal by performing "ID check" and "load check" on the received message; S404, node synchronization, where each communication node achieves synchronization by broadcasting global and local counter values on the bus.
[0087] Furthermore, in S401, the domain level and zone level of each ID are automatically calculated and generated based on the total number of IDs and the ID index sequence number; the virtual address is jointly represented by the domain address, zone address, and service address, and does not change the priority order of the actual ID.
[0088] Furthermore, in S402, the temporary key and temporary seed derivation uses security parameters including a pre-injected long-term symmetric key, the domain level and zone level of the ID, the ID index number, and the bus counter value. Each ID has three keys k1, k2, k3 and three temporary seeds s1, s2, s3. All IDs share the same k1 and s1, and IDs in the same domain have the same k2 and s2. During the S403 transmission phase, the sender and receiver use the ID area number, domain number, counter, temporary long-term key, and temporary zone key as input parameters to calculate the virtual ID address using a hash function and sorting algorithm. During the ID check, the receiver filters received packets based on the expected calculated virtual ID. If the ID of the received packet does not match the expected calculated ID, it is deemed abnormal and discarded. If the ID check passes, a payload check is performed, whereby the receiver recalculates an authentication tag and compares it with the authentication tag carried in the packet payload. If they do not match, the packet is deemed abnormal and discarded; otherwise, it is considered normal.
[0089] During the S404 synchronization phase, node synchronization is implemented based on two types of counters: a global counter and a local counter. The global counter is broadcast with its true value by a trusted node, while the local counter is broadcast with its true value by an ID-sending node. The synchronization message used during the synchronization process has a message ID that changes dynamically based on a random number broadcast by a trusted node, and its payload is protected using message authentication code technology.
[0090] According to the CAN bus address transition method proposed in this application, the receiving node calculates the domain number and area number corresponding to the original message sent by the sending node, and calculates the target virtual address and target authentication tag corresponding to the original message based on the domain number and area number. The receiving node intercepts and discards abnormal messages in the original message sent by the sending node based on the target virtual address and target authentication tag. The receiving node corrects its global counter value based on the global counter value broadcast by the gateway, and corrects its local counter value based on the local counter value broadcast by the sending node. This solves the problem that current security enhancement schemes for the CAN bus are difficult to effectively resist denial-of-service attacks. By dynamically changing the message identifier and address partitioning management, denial-of-service attacks are effectively resisted, meeting the application requirements of the automotive environment.
[0091] Next, the CAN bus address switching device according to the embodiments of this application is described with reference to the accompanying drawings.
[0092] Figure 5 This is a block diagram of a CAN bus address switching device according to an embodiment of this application.
[0093] like Figure 5 As shown, the CAN bus address switching device 10 includes: a calculation module 100, a checking module 200, and a synchronization module 300.
[0094] The calculation module 100 is used to calculate the domain number and area number corresponding to the original message, and calculate the target virtual address and target authentication tag corresponding to the original message based on the domain number and area number corresponding to the original message; the inspection module 200 is used to intercept and discard abnormal messages in the messages sent by the sending node based on the target virtual address and target authentication tag corresponding to the original message; the synchronization module 300 is used to correct the global counter value of the receiving node based on the global counter value broadcast by the gateway, and correct the local counter value of the receiving node based on the local counter value broadcast by the sending node.
[0095] Optionally, in some embodiments, the calculation module 100 is used to: count all protected messages of the receiving node and the unique index number of all protected messages; divide all protected messages into domains and partitions to obtain the number of domains and the number of partitions of the receiving node; and obtain the domain number and partition number corresponding to the original message of the receiving node based on the number of domains, the number of partitions, and the unique index number of all protected messages.
[0096] Optionally, in some embodiments, the calculation module 100 is configured to: calculate a first hash value based on the global counter of the receiving node, a first temporary key, and a first temporary seed; generate a target domain address based on the first hash value and the domain number of the original message; generate and calculate a second hash value based on the global counter, a second temporary key, and a second temporary seed; generate a target area address based on the second hash value and the domain number and area number of the original message; calculate a third hash value based on a third temporary key, a third temporary seed, and a local counter; generate a target service address based on the third hash value, the domain number and area number of the original message; and concatenate the target domain address, the target area address, and the target service address to obtain a target virtual address.
[0097] Optionally, in some embodiments, the calculation module 100 is configured to: receive an initial random number broadcast by the gateway; derive a first temporary key and a first temporary seed based on the initial random number and the global shared key of the receiving node; derive a second temporary key and a second temporary seed based on the initial random number, the global shared key of the receiving node, and the domain number corresponding to the original message; and derive a third temporary key and a third temporary seed based on the initial random number and the private key of the receiving node.
[0098] Optionally, in some embodiments, the calculation module 100 is configured to: receive the original message data packet sent by the sending node; and, based on the local counter and third temporary key of the receiving node and the original message data packet, perform hash encryption operation through a message authentication code algorithm to obtain the target authentication tag corresponding to the original message.
[0099] Optionally, in some embodiments, the inspection module 200 is configured to: receive the initial virtual address and initial authentication tag carried in the original message data packet sent by the sending node; identify a first abnormal message in the original message where the initial virtual address and the target virtual address are inconsistent, intercept and discard the first abnormal message to obtain the remaining message; identify a second abnormal message in the remaining message where the initial authentication tag and the target authentication tag are inconsistent, intercept and discard the second abnormal message.
[0100] Optionally, in some embodiments, the synchronization module 300 is configured to: receive a global counter broadcast by the gateway and a local counter broadcast by the sending node; in response to a discrepancy between the global counter value broadcast by the gateway and the global counter value broadcast by the receiving node, correct the global counter of the receiving node according to the global counter broadcast by the gateway; and in response to a discrepancy between the local counter value broadcast by the sending node and the local counter value broadcast by the receiving node, correct the local counter of the receiving node according to the local counter broadcast by the sending node.
[0101] It should be noted that the explanation of the CAN bus address transition method embodiment described above also applies to the CAN bus address transition device of this embodiment, and will not be repeated here.
[0102] The CAN bus address switching device proposed in this application includes a calculation module that calculates the domain number and area number corresponding to the original message, and calculates the target virtual address and target authentication tag corresponding to the original message based on the domain number and area number; an inspection module that intercepts and discards abnormal messages in the messages sent by the sending node based on the target virtual address and target authentication tag corresponding to the original message; and a synchronization module that corrects the global counter value of the receiving node based on the global counter value broadcast by the gateway, and corrects the local counter value of the receiving node based on the local counter value broadcast by the sending node. This solves the problem of effectively resisting denial-of-service attacks. By dynamically changing the identifier and address partition management of the message, denial-of-service attacks are effectively resisted, meeting the application requirements of the vehicle environment.
[0103] Figure 6 A schematic diagram of the structure of an electronic device provided in an embodiment of this application. The electronic device may include: The memory 601, the processor 602, and the computer program stored on the memory 601 and capable of running on the processor 602.
[0104] When the processor 602 executes the program, it implements the CAN bus address transition method provided in the above embodiments.
[0105] Furthermore, electronic devices also include: Communication interface 603 is used for communication between memory 601 and processor 602.
[0106] The memory 601 is used to store computer programs that can run on the processor 602.
[0107] The memory 601 may include high-speed RAM memory, and may also include non-volatile memory, such as at least one disk storage device.
[0108] If the memory 601, processor 602, and communication interface 603 are implemented independently, then the communication interface 603, memory 601, and processor 602 can be interconnected via a bus to complete communication between them. The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. The bus can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 6The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.
[0109] Optionally, in a specific implementation, if the memory 601, processor 602, and communication interface 603 are integrated on a single chip, then the memory 601, processor 602, and communication interface 603 can communicate with each other through an internal interface.
[0110] The processor 602 may be a central processing unit (CPU), an application specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of this application.
[0111] This application also provides a non-volatile computer-readable storage medium storing a computer program that, when executed by a processor, implements the above-described CAN bus address transition method.
[0112] In the description of this specification, the references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of this application. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples. Moreover, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification, as well as the features of different embodiments or examples.
[0113] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of that feature. In the description of this application, "N" means at least two, such as two, three, etc., unless otherwise explicitly specified.
[0114] Any process or method described in the flowchart or otherwise herein can be understood as representing a module, segment, or portion of code comprising one or more N executable instructions for implementing custom logic functions or processes, and the scope of the preferred embodiments of this application includes additional implementations in which functions may be performed not in the order shown or discussed, including substantially simultaneously or in reverse order depending on the functions involved, as should be understood by those skilled in the art to which embodiments of this application pertain.
[0115] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as a sequenced list of executable instructions for implementing logical functions, and can be specifically implemented in any non-volatile computer-readable storage medium for use by, or in conjunction with, an instruction execution system, apparatus, or device (such as a computer-based system, a processor-including system, or other system that can fetch and execute instructions from, an instruction execution system, apparatus, or device). For the purposes of this specification, "non-volatile computer-readable storage medium" can be any means that can contain, store, communicate, propagate, or transmit programs for use by, or in conjunction with, an instruction execution system, apparatus, or device. More specific examples (a non-exhaustive list) of non-volatile computer-readable storage media include: an electrical connection having one or N wires (electronic device), a portable computer disk drive (magnetic device), random access memory (RAM), read-only memory (ROM), erasable and editable read-only memory (EPROM or flash memory), fiber optic devices, and portable optical disc read-only memory (CDROM). In addition, non-volatile computer-readable storage media can even be paper or other suitable media on which programs can be printed, because programs can be obtained electronically, for example, by optically scanning the paper or other media, followed by editing, interpreting or otherwise processing as necessary, and then stored in computer memory.
[0116] It should be understood that the various parts of this application can be implemented using hardware, software, firmware, or a combination thereof. In the above embodiments, the N steps or methods can be implemented using software or firmware stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware as in another embodiment, it can be implemented using any one or a combination of the following techniques known in the art: discrete logic circuits having logic gates for implementing logical functions on data signals, application-specific integrated circuits (ASICs) having suitable combinational logic gates, programmable gate arrays (PGAs), field-programmable gate arrays (FPGAs), etc.
[0117] Those skilled in the art will understand that all or part of the steps of the methods in the above embodiments can be implemented by a program instructing related hardware, and the program can be stored in a non-volatile computer-readable storage medium. When executed, the program includes one or a combination of the steps of the method embodiments.
[0118] Furthermore, the functional units in the various embodiments of this application can be integrated into a processing module, or each unit can exist physically separately, or two or more units can be integrated into a module. The integrated module can be implemented in hardware or as a software functional module. If the integrated module is implemented as a software functional module and sold or used as an independent product, it can also be stored in a non-volatile computer-readable storage medium.
[0119] The aforementioned non-volatile computer-readable storage medium may be a read-only memory, a magnetic disk, or an optical disk, etc. Although embodiments of this application have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting this application. Those skilled in the art can make changes, modifications, substitutions, and variations to the above embodiments within the scope of this application.
Claims
1. A method for hopping CAN bus addresses, characterized in that, Includes the following steps: The receiving node calculates the domain number and area number corresponding to the original message sent by the sending node, and calculates the target virtual address and target authentication tag corresponding to the original message based on the domain number and area number corresponding to the original message; The receiving node intercepts and discards abnormal messages in the original message sent by the sending node based on the target virtual address and target authentication tag corresponding to the original message; The receiving node corrects its global counter value based on the global counter value broadcast by the gateway, and corrects its local counter value based on the local counter value broadcast by the sending node.
2. The method according to claim 1, characterized in that, The calculation of the domain number and area number corresponding to the original message includes: Count all protected messages and unique index numbers of all protected messages of the receiving node, and divide all protected messages into domains and partitions to obtain the number of domains and partitions of the receiving node; The domain number and area number corresponding to the original message of the receiving node are obtained based on the number of domains, the number of areas, and the unique index number of all protected messages of the receiving node.
3. The method according to claim 1, characterized in that, The step of calculating the target virtual address corresponding to the original message based on the domain number and area code corresponding to the original message includes: The first hash value is calculated based on the global counter of the receiving node, the first temporary key, and the first temporary seed. The target domain address is generated based on the first hash value and the domain number of the original message. The second hash value is calculated based on the global counter, the second temporary key, and the second temporary seed. The target area address is then generated based on the second hash value and the domain number and area number of the original message. The third hash value is calculated based on the third temporary key, the third temporary seed, and the local counter. The target service address is generated based on the third hash value, the domain number and the area number of the original message. The target virtual address is obtained by concatenating the target domain address, the target area address, and the target service address.
4. The method according to claim 3, characterized in that, Determine the first temporary key and the first temporary seed, the second temporary key, the second temporary seed, the third temporary key, and the third temporary seed, including: The receiving node receives the initial random number broadcast by the gateway; The first temporary key and the first temporary seed are derived based on the initial random number and the global shared key of the receiving node; The second temporary key and the second temporary seed are derived based on the initial random number, the global shared key of the receiving node, and the domain number corresponding to the original message; The third temporary key and the third temporary seed are derived based on the initial random number and the private key of the receiving node.
5. The method according to claim 3, characterized in that, The calculation of the target authentication tag corresponding to the original message based on the domain number and area code corresponding to the original message also includes: The receiving node receives the original message data packet sent by the sending node; Based on the local counter of the receiving node, the third temporary key, and the original message data packet, a hash encryption operation is performed using a message authentication code algorithm to obtain the target authentication tag corresponding to the original message.
6. The method according to claim 5, characterized in that, The receiving node intercepts and discards abnormal messages in the messages sent by the sending node based on the target virtual address and target authentication tag corresponding to the original message, including: Receive the initial virtual address and initial authentication tag carried in the original message data packet sent by the sending node; Identify a first abnormal message in the original message whose initial virtual address is inconsistent with the target virtual address, intercept and discard the first abnormal message to obtain the remaining message; Identify a second abnormal message in the remaining messages where the initial authentication label does not match the target authentication label, and intercept and discard the second abnormal message.
7. The method according to claim 1, characterized in that, The global counter value of the receiving node is corrected based on the global counter value broadcast by the gateway, and the local counter value of the receiving node is corrected based on the local counter value broadcast by the sending node, including: The receiving node receives the global counter broadcast by the gateway and the local counter broadcast by the sending node; If the global counter value broadcast by the gateway is inconsistent with the global counter value of the receiving node, the global counter of the receiving node is corrected according to the global counter broadcast by the gateway. If the local counter value broadcast by the sending node is inconsistent with the local counter value of the receiving node, the local counter of the receiving node is corrected according to the local counter broadcast by the sending node.
8. A CAN bus address switching device, characterized in that, include: The calculation module is used to calculate the domain number and area number corresponding to the original message, and to calculate the target virtual address and target authentication tag corresponding to the original message based on the domain number and area number corresponding to the original message; The inspection module is used to intercept and discard abnormal messages in the messages sent by the sending node based on the target virtual address and target authentication tag corresponding to the original message; The synchronization module is used to correct the global counter value of the receiving node based on the global counter value broadcast by the gateway, and to correct the local counter value of the receiving node based on the local counter value broadcast by the sending node.
9. A vehicle, characterized in that, It includes a memory, a processor, and a computer program stored in the memory and executable on the processor, the processor executing the program to implement the CAN bus address transition method as described in any one of claims 1-7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, The program is executed by the processor to implement the CAN bus address transition method as described in any one of claims 1-7.
