Automobile CAN message data security processing method and device and vehicle
By using dynamic encryption methods in vehicle network communication, using S-box matrix and cyclic shifting, nonlinear permutation and other technologies, the problem of CAN bus data being easily monitored and cracked is solved, and efficient data security processing is achieved.
Patent Information
- Application Number
- CN202411832887.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-12
- Publication Date
- 2025-04-25
AI Technical Summary
In existing in-vehicle network communication, data on the CAN bus is susceptible to malicious monitoring and compilation, and the existing message encryption algorithm is unreliable, which poses the risk of key management being difficult and brute-force cracking.
By pre-programming the S-box matrix, storing the encrypted S-boxes of each CAN message, matching the target encrypted S-box according to the ID of the message to be encrypted, dynamic encryption is performed in combination with the data field and ID, and encryption is achieved using technologies such as cyclic shift and nonlinear permutation.
It significantly reduces the possibility of vehicle communication data leakage, improves data security, and is difficult to crack. Even if the S box is cracked, you only need to replace the S box of the corresponding message, and other messages will not be affected.
Smart Images

Figure CN119892404A_ABST
Abstract
Description
[Technical field]
[0001] The embodiments of the present application relate to the field of vehicle network communication technology, and in particular to a method, device and vehicle for securely processing automobile CAN message data. [Background technology]
[0002] At present, the in-vehicle network is the nerve network that connects various electrical appliances in the car, transmitting various operating information of the vehicle. The CAN bus is a widely used communication protocol in today's cars, responsible for transmitting important information during the car's driving process, such as the car's operating status, the driver's operating status, and the perception of the external environment. However, since the data on the CAN bus is broadcasted in plain text, any device connected to the bus can receive the sent data, which is vulnerable to malicious monitoring and tampering; and the message encryption algorithm currently used in the industry for this purpose is not reliable. [Summary of the invention]
[0003] The embodiments of the present application propose a method, device and vehicle for securely processing automobile CAN message data, which relate to the field of vehicle-mounted network communication technology, in order to solve the problems of difficulty in key management and easy brute force cracking.
[0004] In a first aspect, an embodiment of the present application provides a method for securely processing automobile CAN message data, the method comprising:
[0005] Pre-compile an S-box matrix to store the encrypted S-box of each CAN message;
[0006] Match the corresponding target encryption S-box from the S-box matrix according to the ID of the message to be encrypted;
[0007] The message to be encrypted is dynamically encrypted using the data field, ID and the target encryption S-box of the message to be encrypted.
[0008] In this embodiment, an S-box matrix storing each CAN message encryption S-box is pre-configured. When a CAN message needs to be encrypted, the corresponding target encryption S-box is matched from the S-box matrix, and dynamic encryption is performed in combination with the data field and ID of the message to be encrypted. The encryption process changes when the data field changes, so it is difficult for outsiders to find its rules and crack it, which significantly reduces the possibility of vehicle communication data leakage.
[0009] In at least one possible implementation, the dynamic encryption includes: utilizing characteristics of the data field and the ID to determine a dynamic encryption algorithm.
[0010] In this embodiment, when executing the aforementioned dynamic encryption process, the current specific encryption method can be flexibly determined as needed based on the data field characteristics and ID characteristics of the message.
[0011] In at least one possible implementation, the dynamic encryption algorithm includes: utilizing the characteristics of the data field of the message to be encrypted to perform a cyclic shift to obtain a first ciphertext; combining the characteristics of the ID and the target encryption S-box, performing a nonlinear permutation on the data field of the first ciphertext to obtain a second ciphertext.
[0012] In this embodiment, a selected dynamic encryption algorithm is provided. The main idea is to first use the characteristics of the data field of the message to be encrypted to perform cyclic shift to obtain an intermediate ciphertext, and then use the ID characteristics and the previously matched target encryption S box to perform nonlinear permutation on the intermediate ciphertext to obtain the final ciphertext.
[0013] In at least one possible implementation, the dynamic encryption algorithm specifically includes:
[0014] Obtaining the number m of preset characters in the count representation of the data field of the message to be encrypted, and determining the parity of m;
[0015] According to the parity of m, the direction of the data field cyclic shift is determined;
[0016] After the data field is cyclically shifted by m bits in the direction, a first ciphertext is obtained;
[0017] In combination with the number n of preset characters in the numeric representation of the ID and the target encryption S-box corresponding to the current ID, the data field of the first ciphertext is nonlinearly permuted n times to obtain the second ciphertext.
[0018] In this embodiment, the data field feature is set to the number of a specific character in a given number representation and the parity of the number, thereby determining the direction of the data field's cyclic movement and the number of bits moved, and the ID feature is set to the number of nonlinear permutations using the S box, thereby achieving dynamic encryption that is difficult to crack.
[0019] In at least one possible implementation, the data security processing method further includes a decryption process:
[0020] According to the decryption S-box corresponding to the target encryption S-box, nonlinearly recover the data field of the second ciphertext to obtain the first ciphertext;
[0021] Based on the characteristics of the data field of the first ciphertext, a cyclic shift is performed inversely to the encryption process to obtain the restored original message.
[0022] This embodiment supplements the decryption process, which is mainly a reverse operation relative to the encryption process, thereby formulating a complete CAN message encryption and decryption process.
[0023] In at least one possible implementation, the S-box matrix compilation includes: generating a unique encryption S-box for each CAN message, which is only used to perform nonlinear permutation on the corresponding current message until it is cracked; and after cracking, only generating a new encryption S-box for the current message and updating the S-box matrix.
[0024] This embodiment reflects the uniqueness of the S-box. Even if it is cracked, only the S-box of the corresponding message needs to be replaced, and the other messages will not be affected, which greatly enhances the communication security.
[0025] In a second aspect, an embodiment of the present application provides a device for securely processing automobile CAN message data, the device comprising:
[0026] An S-box architecture setting module, used to pre-compile an S-box matrix for storing encrypted S-boxes of each CAN message;
[0027] An S-box matching module is used to match the corresponding target encryption S-box from the S-box matrix according to the ID of the message to be encrypted;
[0028] The dynamic encryption module is used to dynamically encrypt the message to be encrypted by using the data field, ID and the target encryption S box of the message to be encrypted.
[0029] In a third aspect, an embodiment of the present application provides an electronic device, comprising: one or more processors, a memory, and one or more computer programs, wherein the memory may adopt a non-volatile storage medium, wherein the one or more computer programs are stored in the memory, and the one or more computer programs include instructions, and when the instructions are executed by the device, the electronic device performs the method as described in the first aspect or any possible implementation manner of the first aspect.
[0030] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program. When the computer-readable storage medium is run on a computer, the computer executes the method as described in the first aspect or any possible implementation of the first aspect.
[0031] In a fifth aspect, an embodiment of the present application provides a vehicle, comprising the electronic device in the embodiment of the third aspect and the computer-readable storage medium in the embodiment of the fourth aspect.
[0032] It should be understood that the second to fifth aspects of the embodiments of the present application are consistent with the technical solutions of the first aspect of the embodiments of the present application, and the beneficial effects achieved by each aspect and the corresponding feasible implementation methods are similar and will not be repeated here.
Brief Description of the Drawings
[0033] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this specification. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0034] Figure 1 A flowchart of a method for securely processing automobile CAN message data provided by an embodiment of the present application;
[0035] Figure 2 A schematic diagram of an S-box matrix of a vehicle model architecture provided in an embodiment of the present application;
[0036] Figure 3 A schematic diagram of a flow chart of a dynamic encryption method provided in an embodiment of the present application;
[0037] Figure 4 A schematic diagram of the structure of a device for securely processing automobile CAN message data provided in an embodiment of the present application. [Specific implementation method]
[0038] In order to better understand the technical solution of this specification, the embodiments of the present application are described in detail below with reference to the accompanying drawings.
[0039] It should be clear that the described embodiments are only part of the embodiments of this specification, not all of the embodiments. Based on the embodiments in this specification, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this specification.
[0040] The terms used in the embodiments of the present application are only for the purpose of describing specific embodiments, and are not intended to limit this specification. The singular forms of "a", "said" and "the" used in the embodiments of the present application and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings.
[0041] In order to reduce the success rate of data monitoring and tampering, CAN messages need to be encrypted. Existing message encryption algorithms, such as AES, SM4 and other symmetric encryption algorithms, have the risk of difficult key management and easy brute force cracking due to their fixed key conversion relationship and key length.
[0042] In view of this, an embodiment of the present application provides a method for securely processing automobile CAN message data, in which an S-box (Substitution box, in cryptography, is a basic structure for substitution calculation of symmetric key algorithms, an S-box is usually a table of fixed size, used to map an input bit sequence to an output bit sequence, for example, in the AES algorithm, the S-box is a 16×16 table, each element is a byte of data, used for byte substitution operations) for nonlinear substitution of the data field of each message is combined, and a data field dynamic encryption method. Specifically, an S-box matrix for storing each CAN message encryption S-box is pre-configured. When a CAN message needs to be encrypted, the corresponding target encryption S-box is matched from the S-box matrix, and dynamic encryption is performed in combination with the data field and ID of the message to be encrypted. The encryption process changes when the data field changes, so it is difficult for the outside to explore its rules and crack it, which significantly reduces the possibility of vehicle communication data leakage.
[0043] The technical solution protected by the embodiments of the present application is described in detail below with reference to the accompanying drawings.
[0044] See also Figure 1 , is a flow chart of a method for securely processing automobile CAN message data provided by an embodiment of the present application. The flow of the method is described as follows:
[0045] Step 101: pre-compile an S-box matrix for storing the encrypted S-box of each message.
[0046] refer to Figure 2 As shown in the figure, the S-box matrix used for nonlinear permutation is similar to the communication matrix, and each vehicle model communication architecture has an S-box matrix for storing the S-box permutation diagram of each message, where the S-box of each message can be randomly generated and unique. After generation, it will continue to be used for nonlinear permutation of the message until the S-box is cracked. For example, after the message 0x279 matches its corresponding S-box, the data field of 0x279 can be nonlinearly permuted through the corresponding S-box, for example: 4C6A 5812338000 becomes 7F 663850B3 C2 D6 after permutation; and in the structured S-box matrix, if the S-box is cracked, only the S-box of the corresponding message needs to be replaced, and the rest of the messages will not be affected, which greatly enhances security. Figure 2 As shown, each ECU (n in total) on the vehicle has an S-box with the number of messages it sends (m).
[0047] Step 102: Match the corresponding target encryption S-box from the S-box matrix according to the ID of the message to be encrypted.
[0048] Step 103: Dynamically encrypt the message to be encrypted using the data field, ID and the target encryption S-box of the message to be encrypted.
[0049] In actual operation, the dynamic encryption mentioned here may include using the characteristics of the data field and the ID to determine the dynamic encryption algorithm. In some embodiments, the determined dynamic encryption algorithm may be: using the characteristics of the data field of the message to be encrypted to perform a cyclic shift to obtain a first ciphertext; combining the characteristics of the ID and the target encryption S box, performing a nonlinear permutation on the first ciphertext to obtain a second ciphertext. Based on this embodiment, it can be combined with Figure 3 The following diagram shows a more specific dynamic encryption algorithm:
[0050] Step 301: Obtain the number m of 1s in the binary representation of the data field of the message to be encrypted (A), and determine the parity of m;
[0051] Step 302: if m is an odd number, the data field is cyclically shifted left by m bits; if m is an even number, the data field is cyclically shifted right by m bits;
[0052] Step 303: The data field is shifted to obtain a first ciphertext (B);
[0053] Step 304: Based on the number n of 1s in the binary representation of the ID and the corresponding target encryption S-box, perform n nonlinear permutations on the data field of the first ciphertext (B) to obtain a second ciphertext (C).
[0054] It can be understood that the binary, number of 1s, and parity involved are all exemplary characteristics of the message data field and its ID, and different characteristics can be set in other embodiments to achieve this; and the left and right movement directions, number of moving bits, number of permutations, etc. involved are also exemplary dynamic rules, and can be changed as needed in other embodiments.
[0055] For ease of understanding, here is an example for additional explanation: the AC control unit of the air conditioner sends a message of 0x279, whose data field is 61002C 44000B 8864, and the corresponding binary representation is 0110 00010000000000101100010001000000000000001000111000100001100100. The number of 1s m = 16, so after cyclic right shift of 16 bits, we get: 100010000110 01000110 0001000000000010110001000100000000000001011, which corresponds to hexadecimal 88646100 2C 44000B, which is the data field of ciphertext B. The binary representation of the message ID (arbitration field) of 0x279 is 00101111001, and the number of 1s n=6. Then, the data field of the aforementioned ciphertext B is nonlinearly permuted six times according to the target encryption S-box of 0x279: 886461002C 44000B→CE 73BE D692BA D6 D5→84C965780B C0 789D→19E36440D50540D0→5D 8F73B7 9D 68B7 2C→7B 3E C9 4C D0 C7 4C 92→DE 69E3 7F2C 9E 7F 0B, that is, the data field of the ciphertext C is DE 69E3 7F 2C 9E 7F 0B.
[0056] It can be further pointed out that the data security processing method can include decryption in addition to the encryption process, and the decryption process can be roughly understood as the inverse process of encryption. Of course, the decryption S box used therein is the transposition of the target encryption S box, and the circular shift method is opposite to the aforementioned encryption embodiment. Here is a reference implementation method: according to the corresponding decryption S box, the data field of the second ciphertext C is nonlinearly restored to obtain the first ciphertext B; the number of 1s in the data field of the first ciphertext B is m, if m is an odd number, the data field is circularly shifted right by m places; if m is an even number, the data field is circularly shifted left by m places, and finally the restored original message A is obtained.
[0057] Finally, it can be added that the hardware involved in the dynamic encryption method can be the memory and central processing unit in the microprocessor of the vehicle. Among them, the data storage part of the memory stores the encryption S box of all sent messages and the decryption S box of all received messages of a certain ECU of the vehicle, and the program storage part stores the dynamic encryption program and the aforementioned decryption program. The execution process of the dynamic encryption program, such as the aforementioned processes of calculating the number of 1s in the data field, cyclic shift, nonlinear replacement, etc., can be performed on the central processing unit, and the encrypted data is packaged by the CAN controller to form a ciphertext C, and then the ciphertext C is sent to the CAN bus by the CAN transceiver.
[0058] Next, after the receiving node captures the ciphertext C through the CAN transceiver, it is first decoded by the CAN controller, and finally the decryption program is executed in the microprocessor to obtain the original message data.
[0059] See also Figure 4 Based on the same inventive concept, the embodiment of the present application also provides a device for securely processing automobile CAN message data, the device comprising:
[0060] An S-box architecture setting module 401 is used to pre-compile an S-box matrix for storing encrypted S-boxes of each CAN message;
[0061] An S-box matching module 402 is used to match a corresponding target encryption S-box from the S-box matrix according to the ID of the message to be encrypted;
[0062] The dynamic encryption module 403 is used to dynamically encrypt the message to be encrypted by using the data field, ID and the target encryption S-box of the message to be encrypted.
[0063] Based on the same inventive concept, an embodiment of the present application also provides an electronic device, comprising at least one processor, the processor being used to execute a computer program stored in a memory to implement the flow chart steps of the above-mentioned automobile CAN message data security processing method provided in an embodiment of the present application.
[0064] Optionally, the processor may specifically be a central processing unit, a specific ASIC, or one or more integrated circuits for controlling program execution.
[0065] Optionally, the electronic device may further include a memory connected to at least one processor, and the memory may include ROM, RAM, and disk storage. The memory is used to store data required by the processor when it is running, that is, it stores instructions that can be executed by at least one processor, and at least one processor executes the methods mentioned in the above embodiments by executing the instructions stored in the memory. Among them, the number of memories is one or more. Among them, the number of memories is one or more.
[0066] An embodiment of the present application also provides a computer storage medium, wherein the computer storage medium stores computer instructions. When the computer instructions are executed on a computer, the computer executes the methods mentioned in the above embodiments.
[0067] Based on the same inventive concept, the embodiment of the present application further provides a vehicle, comprising at least the above electronic device and / or computer-readable storage medium. The selection of the vehicle can be determined based on the correct understanding and reasonable implementation of the above solution by those skilled in the art.
[0068] The above description is only a preferred embodiment of this specification and is not intended to limit this specification. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of this specification should be included in the scope of protection of this specification.
Claims
1. A method for securely processing automobile CAN message data, characterized in that: The method comprises: Pre-compile an S-box matrix to store the encrypted S-box of each CAN message; Match the corresponding target encryption S-box from the S-box matrix according to the ID of the message to be encrypted; The message to be encrypted is dynamically encrypted using the data field, ID and the target encryption S-box of the message to be encrypted.
2. The method for securely processing automobile CAN message data according to claim 1, characterized in that: The dynamic encryption includes: utilizing the characteristics of the data field and the ID to determine the dynamic encryption algorithm.
3. The method for securely processing automobile CAN message data according to claim 2, characterized in that: The dynamic encryption algorithm includes: using the characteristics of the data field of the message to be encrypted to perform cyclic shift to obtain a first ciphertext; combining the characteristics of the ID and the target encryption S box, performing nonlinear permutation on the data field of the first ciphertext to obtain a second ciphertext.
4. The method for securely processing automobile CAN message data according to claim 3, characterized in that: The dynamic encryption algorithm specifically includes: Obtaining the number m of preset characters in the count representation of the data field of the message to be encrypted, and determining the parity of m; According to the parity of m, the direction of the data field cyclic shift is determined; After the data field is cyclically shifted by m bits in the direction, a first ciphertext is obtained; In combination with the number n of preset characters in the numeric representation of the ID and the target encryption S-box corresponding to the current ID, the data field of the first ciphertext is nonlinearly permuted n times to obtain the second ciphertext.
5. The method for securely processing automobile CAN message data according to claim 3, characterized in that: The data security processing method also includes a decryption process: According to the decryption S-box corresponding to the target encryption S-box, nonlinearly recover the data field of the second ciphertext to obtain the first ciphertext; Based on the characteristics of the data field of the first ciphertext, a cyclic shift is performed inversely to the encryption process to obtain the restored original message.
6. The method for securely processing automobile CAN message data according to any one of claims 1 to 5, characterized in that: The preparation of the S-box matrix includes: generating a unique encryption S-box for each CAN message, which is only used to perform nonlinear permutation on the corresponding current message until it is cracked; and after cracking, generating a new encryption S-box only for the current message, and updating the S-box matrix.
7. A vehicle CAN message data security processing device, characterized in that: The device comprises: An S-box architecture setting module, used to pre-compile an S-box matrix for storing encrypted S-boxes of each CAN message; An S-box matching module is used to match the corresponding target encryption S-box from the S-box matrix according to the ID of the message to be encrypted; The dynamic encryption module is used to dynamically encrypt the message to be encrypted by using the data field, ID and the target encryption S box of the message to be encrypted.
8. An electronic device, characterized in that: include: One or more processors, a memory and one or more computer programs, wherein the one or more computer programs are stored in the memory, and the one or more computer programs include instructions, which, when executed by the electronic device, enable the electronic device to execute the automotive CAN message data security processing method according to any one of claims 1 to 6.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method for securely processing automobile CAN message data as claimed in any one of claims 1 to 6 is implemented.
10. A vehicle, characterized in that: The vehicle is provided with the electronic device of claim 8 or the computer-readable storage medium of claim 9.