Vehicle FlexRay bus data communication method and device and vehicle
By using timestamps to generate keys and adding random numbers and fixed bytes in the FlexRay bus protocol, the problem of high encryption cost and insufficient encryption strength in FlexRay bus data transmission is solved, and effective security for vehicle data transmission is achieved Protect.
Patent Information
- Application Number
- CN202310494586.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-05
- Publication Date
- 2024-11-05
AI Technical Summary
The existing FlexRay bus protocol lacks encryption function, which leads to the risk of hacker replay attacks in vehicle data transmission. The existing encryption solutions are costly, difficult to deploy and limited encryption strength.
By obtaining the timestamp when the vehicle starts, generating a key, and adding random numbers and fixed bytes to the plaintext data to be sent, the data is encrypted and decrypted using a symmetric encryption algorithm, and random numbers and fixed bytes are detected to identify repetitions Release the attack to avoid decryption failure.
It reduces the cost of FlexRay bus data transmission, enhances encryption strength, effectively prevents playback attacks, and improves the security of data transmission.
Smart Images

Figure CN118900174A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of vehicle information security technology, and in particular to a vehicle FlexRay bus data communication method, device and vehicle. Background Art
[0002] With the increasing complexity of automotive electronic architecture, especially the rapid development of current assisted driving systems and unmanned driving technology, the traditional Local Interconnect Network (LIN) bus and Controller Area Network (CAN) bus have been overwhelmed and cannot meet the future high bandwidth requirements, so the FlexRay bus protocol came into being. FlexRay has a faster data transmission rate, more flexible data communication methods and more comprehensive topology options. However, the FlexRay bus protocol lacks encryption function, and there is a possibility of replay attacks by hackers during in-vehicle communication.
[0003] In the prior art, in order to cope with the increasingly serious hacker attacks on vehicles, many experts have implemented various forms of encryption on the FlexRay bus, such as using a hardware encryption solution based on a Field Programmable Gate Array (FPGA) for the FlexRay bus, or using a distributed encryption storage method for the FlexRay bus, or using a simple encryption solution that adds random numbers to the bus transmission data.
[0004] However, the above solution has high hardware requirements, high cost, difficult deployment, and a certain limit to the strength of encryption, and cannot fundamentally solve the threat of replay attacks on the bus. Summary of the invention
[0005] The present application provides a vehicle FlexRay bus data communication method, device and vehicle, which are used to solve the problems of high cost, difficult deployment and limited encryption strength of the prior art FlexRay bus data communication solution.
[0006] In a first aspect, the present application provides a vehicle FlexRay bus data communication method, which is applied to any electronic control unit ECU in a vehicle, comprising:
[0007] When the vehicle is started, obtaining a timestamp;
[0008] Shifting and extending the timestamp to generate a key;
[0009] Adding a random number and a preset fixed byte to the plaintext data to be sent to obtain target plaintext data, wherein the random number is generated according to the timestamp and has not been used since the vehicle was started this time;
[0010] Encrypting the target plaintext data according to the key to obtain ciphertext data;
[0011] The encrypted data is sent to the target ECU via the FlexRay bus.
[0012] In combination with the first aspect, in some embodiments, adding a random number and a preset fixed byte to the plaintext data to be sent to obtain the target plaintext data includes:
[0013] Using the timestamp as a seed, a random number generation function is used to generate a random number;
[0014] Determine whether the random number is the same as a random number that has been used after the vehicle is started this time;
[0015] If the random number is not repeated with a random number that has been used after the vehicle is started this time, the random number is determined as the random number to be added to the plaintext data;
[0016] The random number and the preset fixed bytes are sequentially added to the back of the plaintext data to obtain the target plaintext data.
[0017] In combination with the first aspect, in some embodiments, the method further includes:
[0018] If the random number is the same as the random number that has been used after the vehicle is started this time, a random number is regenerated according to the timestamp until a random number that is not the same as the random number that has been used after the vehicle is started this time is obtained.
[0019] In combination with the first aspect, in some embodiments, the shifting and extending the timestamp to generate a key includes:
[0020] The timestamp is shifted and expanded to obtain the key of sixteen bytes, and the key is used to encrypt or decrypt the data sent through the FlexRay bus during the current driving process of the vehicle.
[0021] In a second aspect, the present application provides a vehicle FlexRay bus data communication method, which is applied to any electronic control unit ECU in a vehicle, comprising:
[0022] When the vehicle is started, obtaining a timestamp;
[0023] Shifting and extending the timestamp to generate a key;
[0024] Receive encrypted data sent by other ECUs through the FlexRay bus;
[0025] Decrypting the ciphertext data according to the key to obtain target plaintext data;
[0026] Determine whether the last byte of the target plaintext data is a preset byte, and determine whether the random number before the preset byte is the same as the random number used after the vehicle is started this time;
[0027] If the last byte of the target plaintext data is a preset byte, and the random number before the preset byte is not repeated with the random number used after the vehicle is started this time, the plaintext data is obtained according to the target plaintext data.
[0028] In conjunction with the second aspect, in some embodiments, the method further includes:
[0029] If the last byte of the target plaintext data is not the preset byte, it is determined that the decryption fails;
[0030] Sending a decryption failure message to the other ECU, wherein the decryption failure message is used to request the other ECU to resend data;
[0031] or,
[0032] If the random number before the preset byte is the same as the random number used after the vehicle is started this time, it is determined that the current transmission is subject to a replay attack, and the target plaintext data is refused to be processed.
[0033] In combination with the second aspect, in some embodiments, the shifting and extending the timestamp to generate a key includes:
[0034] The timestamp is shifted and expanded to obtain the key of sixteen bytes, and the key is used to encrypt or decrypt the data sent through the FlexRay bus during the current driving process of the vehicle.
[0035] In a third aspect, the present application provides a vehicle FlexRay bus data communication device, comprising:
[0036] A first acquisition module, used for acquiring a timestamp when the vehicle is started;
[0037] A key generation module, used for shifting and extending the timestamp to generate a key;
[0038] A data updating module, used for adding a random number and a preset fixed byte to the plaintext data to be sent to obtain target plaintext data, wherein the random number is generated according to the timestamp and has not been used since the vehicle was started this time;
[0039] A data encryption module, used to encrypt the target plaintext data according to the key to obtain ciphertext data;
[0040] The data sending module is used to send the encrypted data to the target ECU via the FlexRay bus.
[0041] In conjunction with the third aspect, in some embodiments, the data updating module includes:
[0042] A data generation unit, configured to use the timestamp as a seed and adopt a random number generation function to generate a random number;
[0043] A first judgment unit is used to determine whether the random number is the same as a random number that has been used after the vehicle is started this time;
[0044] a second determination unit, configured to determine the random number as a random number to be added to the plaintext data if the random number is not repeated with a random number that has been used after the vehicle is started this time;
[0045] The data updating unit is used to sequentially add the random number and the preset fixed bytes to the end of the plaintext data to obtain the target plaintext data.
[0046] In conjunction with the third aspect, in some embodiments, the device further includes:
[0047] The second acquisition module is used to regenerate a random number according to the timestamp if the random number is repeated with the random number used after the vehicle is started this time, until a random number that is not repeated with the random number used after the vehicle is started this time is obtained.
[0048] In conjunction with the third aspect, in some embodiments, the key generation module includes:
[0049] The key generation unit is used to shift and expand the timestamp to obtain the key of sixteen bytes, and the key is used to encrypt or decrypt the data sent through the FlexRay bus during the current driving of the vehicle.
[0050] In a fourth aspect, the present application provides a vehicle FlexRay bus data communication device, comprising:
[0051] A first acquisition module, used for acquiring a timestamp when the vehicle is started;
[0052] A key generation module, used for shifting and extending the timestamp to generate a key;
[0053] Data receiving module, used to receive encrypted data sent by other ECUs through FlexRay bus;
[0054] A data decryption module, used to decrypt the ciphertext data according to the key to obtain target plaintext data;
[0055] A data judgment module, used to determine whether the last byte of the target plaintext data is a preset byte, and to determine whether the random number before the preset byte is the same as the random number used after the vehicle is started this time;
[0056] The second acquisition module is used to acquire plaintext data according to the target plaintext data if the last byte of the target plaintext data is a preset byte and the random number before the preset byte is not repeated with the random number used after the vehicle is started this time.
[0057] In conjunction with the fourth aspect, in some embodiments, the device further includes:
[0058] A judgment processing module, configured to determine that decryption fails if the last byte of the target plaintext data is not the preset byte;
[0059] Sending a decryption failure message to the other ECU, wherein the decryption failure message is used to request the other ECU to resend data;
[0060] or,
[0061] If the random number before the preset byte is the same as the random number used after the vehicle is started this time, it is determined that the current transmission is subject to a replay attack, and the target plaintext data is refused to be processed.
[0062] In conjunction with the fourth aspect, in some embodiments, the key generation module includes:
[0063] The key generation unit is used to shift and expand the timestamp to obtain the key of sixteen bytes, and the key is used to encrypt or decrypt the data sent through the FlexRay bus during the current driving of the vehicle.
[0064] In a fifth aspect, the present application further provides a vehicle, comprising: a vehicle body, a storage unit disposed in the vehicle body, and a plurality of electronic control units ECU;
[0065] The storage unit stores computer-executable instructions;
[0066] The arbitrary ECU executes the computer-executable instructions stored in the storage unit to implement the methods described in the first and second aspects above.
[0067] In a sixth aspect, the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are executed by a processor, they are used to implement the methods described in the first and second aspects above.
[0068] The present application provides a method, device and vehicle for communicating vehicle FlexRay bus data. By utilizing the consistency of the timestamp obtained by each ECU after error elimination each time the vehicle is started, the same symmetric encryption key is generated, and the communication channel of the FlexRay bus is encrypted and decrypted using the key. Then, the freshness of the plaintext data is maintained by adding a random number to each plaintext data, and finally a fixed byte is added to prevent decryption failure. Not only does it not require additional hardware modules, but it also increases the encryption strength, fundamentally solving the threat of replay attacks on the FlexRay bus. BRIEF DESCRIPTION OF THE DRAWINGS
[0069] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0070] Figure 1 An application scenario diagram of the vehicle FlexRay bus data communication method provided in an embodiment of the present application;
[0071] Figure 2 A flow chart of a first embodiment of a method for communicating vehicle FlexRay bus data provided by an embodiment of the present application;
[0072] Figure 3 A flow chart of a second embodiment of a method for communicating vehicle FlexRay bus data provided in an embodiment of the present application;
[0073] Figure 4 A flowchart of a third embodiment of a method for communicating vehicle FlexRay bus data provided by an embodiment of the present application;
[0074] Figure 5 A flowchart of a fourth embodiment of a method for communicating vehicle FlexRay bus data provided by an embodiment of the present application;
[0075] Figure 6 A flowchart of a fifth embodiment of a method for communicating vehicle FlexRay bus data provided by an embodiment of the present application;
[0076] Figure 7 A flow chart of a specific example of a method for communicating vehicle FlexRay bus data provided in an embodiment of the present application;
[0077] Figure 8A schematic diagram of the structure of a first embodiment of a communication device for vehicle FlexRay bus data provided in an embodiment of the present application;
[0078] Fig. 9 A schematic diagram of the structure of a second embodiment of a communication device for vehicle FlexRay bus data provided in an embodiment of the present application;
[0079] Fig.10 A schematic diagram of the structure of a third embodiment of a communication device for vehicle FlexRay bus data provided in an embodiment of the present application;
[0080] Fig.11 A schematic diagram of the structure of a fourth embodiment of a communication device for vehicle FlexRay bus data provided in an embodiment of the present application;
[0081] Fig.12 A schematic diagram of the structure of a fifth embodiment of a communication device for vehicle FlexRay bus data provided in an embodiment of the present application;
[0082] Fig.13 A schematic diagram of the structure of a sixth embodiment of a communication device for vehicle FlexRay bus data provided in an embodiment of the present application;
[0083] Fig.14 A schematic diagram of the structure of a vehicle provided in an embodiment of the present application.
[0084] The above drawings have shown clear embodiments of the present application, which will be described in more detail later. These drawings and text descriptions are not intended to limit the scope of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION
[0085] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.
[0086] As more and more functions are added to cars to enhance safety and comfort, the number of sensors, transmission devices, and electronic control units (ECUs) used to implement these functions is also increasing. The increasingly complex operation of ECUs and the coordination of many vehicle buses have seriously hindered the development of wire control technology. Even if the complexity problem can be solved, traditional vehicle buses lack the determinism and fault tolerance required for wire control. Therefore, the FlexRay bus protocol came into being. FlexRay has high transmission rate, high fault tolerance and greater flexibility. Gradually, FlexRay has been adopted worldwide, but the FlexRay bus protocol does not have encryption function, and data transmission through the FlexRay bus lacks certain security. Usually, the FlexRay bus adopts a hardware encryption method based on the Field Programmable Gate Array (FPGA) or a distributed encryption storage method, but the above hardware-based encryption method increases the cost and is difficult to deploy. If a fault occurs, it is very difficult to maintain or replace the in-vehicle module.
[0087] In response to the above problems, the present application provides a vehicle FlexRay bus data communication method, which realizes simple and strong encryption of FlexRay bus data transmission. Specifically, when the FlexRay bus is used for data transmission between vehicle ECUs, FPGA or distributed encryption methods are usually used for the FlexRay bus. During the research process, the inventor found that the FlexRay bus lacks encryption function during data transmission and cannot guarantee the security of data. If the FlexRay bus is encrypted by FPGA or distributed encryption method, it is necessary to add hardware, which is relatively costly and difficult to deploy. The requirements for FPGA technology are also relatively high, and it is difficult to promote its use. If the data transmitted by the bus is encrypted by adding random numbers, the encryption strength is limited. Attackers can use a variety of methods to reverse the encryption logic for replay attacks, which cannot fundamentally solve the replay attack threat to the bus. Taking these issues into consideration, the inventor studied whether it is possible to obtain the key and the random number that has not been used since the vehicle was started based on the timestamp obtained when the vehicle was started, and to add random numbers and fixed bytes to the plaintext data to be sent, encrypt the target plaintext data through a symmetric encryption algorithm, and detect the random numbers and fixed bytes of the target plaintext data during the decryption process to make a corresponding response, thereby reducing costs and enhancing encryption strength. Based on this, the technical solution of the present application is proposed.
[0088] Figure 1 The application scenario diagram of the vehicle FlexRay bus data communication method provided in the embodiment of the present application is as follows: Figure 1As shown, the vehicle FlexRay bus data communication method provided by the present application is mainly used in the scenario of ECU data transmission in the vehicle. The scenario of ECU data transmission in the vehicle mainly includes a vehicle, multiple ECUs, and a FlexRay bus for data transmission between ECUs, wherein the vehicle is a vehicle of any form and model, and the vehicle contains multiple ECUs, data can be transmitted between multiple ECUs, the ECU can be of any form, and data is transmitted between ECUs via the FlexRay bus.
[0089] This application does not limit the specific form of each device.
[0090] The technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems are described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.
[0091] Figure 2 The flowchart of the first embodiment of the method for communicating vehicle FlexRay bus data provided by the present application is as follows: Figure 2 As shown, the vehicle FlexRay bus data communication method provided in the embodiment of the present application is applied to any electronic control unit ECU in the vehicle, and specifically includes the following steps:
[0092] S101: When the vehicle is started, a timestamp is obtained.
[0093] In this step, when the vehicle is started, the ECU in the vehicle is powered on. In order to enhance the security of data transmission between ECUs through the FlexRay bus, the ECU in the vehicle obtains a timestamp from a timestamp server.
[0094] Specifically, the ECU in the vehicle encrypts the file that needs to be timed using a hash code to form a summary, and then sends the summary to the Decode Time Stamp (DTS). After adding the date and time information of the received file summary, the DTS adds a digital signature to the file to form a timestamp, and finally sends the timestamp back to the ECU in the vehicle. The vehicle contains multiple ECUs, and each ECU obtains its own timestamp and then performs error elimination to obtain a unified timestamp. The error elimination adopts the rounding method, and there is an error range when the error is eliminated. This solution does not specifically limit the error range and can be set according to the needs of the actual scenario.
[0095] S102: Shift and extend the timestamp to generate a key.
[0096] In this step, since the use of the vehicle is irregular, the timestamp obtained in the above steps also changes with the time the vehicle is used. In order to enhance the encryption level of subsequent data transmission, the timestamp obtained in the above steps is shifted and extended to generate a secret key for encryption or decryption.
[0097] Specifically, the timestamp obtained is a two-byte hexadecimal number, which is shifted and expanded to obtain a sixteen-byte key. For example, if the timestamp is T, the specific shift expansion is:
[0098] T1 = (T + 0x71) & 0xFF;
[0099] T2 = (T1 + 0x57) & 0xFF;
[0100] T3 = (T2 + 0x33) & 0xFF.
[0101] After the above processing, we get two-byte hexadecimal numbers T, T1, T2, and T3 respectively, and continue to calculate using the following formula:
[0102] T'=T*0x1000000+T1*0x10000+T2*0x100+T3
[0103] Where T' is an eight-byte hexadecimal integer, and the shift operation on T' is continued:
[0104] T"=T'*0x100000000+T3*0x1000000+T2*0x10000+T1*0x100+T'
[0105] At this time, "T" is the final sixteen-byte key.
[0106] S103: Add a random number and a preset fixed byte to the plaintext data to be sent to obtain target plaintext data.
[0107] In this step, in order to keep the plaintext data to be sent fresh, a random number and a preset fixed byte are added to the plaintext data to be sent to obtain the target plaintext data. The random number is generated according to the timestamp in the above step, and the fixed byte is used as an identifier of the plaintext data to be sent to identify the correctness of the subsequent decrypted ciphertext file.
[0108] Specifically, the random number is generated by a random number generation function using the timestamp as a seed, such as the Srand function in the C language. The random seed is first initialized, and then the timestamp is used as a seed to generate a two-byte random number corresponding to the timestamp, and the random number has not been used since the vehicle was started this time.
[0109] S104: Encrypt the target plaintext data according to the key to obtain ciphertext data.
[0110] In this step, after the target plaintext data is obtained in the above step, the target plaintext data is encrypted using a symmetric encryption algorithm according to a key, thereby obtaining ciphertext data.
[0111] Specifically, the target plaintext data and key are processed by a special encryption algorithm to generate ciphertext data. Commonly used symmetric encryption algorithms include data encryption algorithm, triple data encryption algorithm and advanced encryption standard, etc. The specific encryption algorithm can be selected according to the actual scenario, and this scheme does not make specific limitations.
[0112] S105: Send the encrypted data to the target ECU via the FlexRay bus.
[0113] In this step, after the ciphertext data is generated in the above step, the ciphertext data is sent to the target ECU via the FlexRay bus.
[0114] The vehicle FlexRay bus data communication method provided in this embodiment is that the vehicle ECU obtains the timestamp after power-on, obtains the random number and key according to the timestamp, and adds the random number and fixed bytes to the plaintext data to be sent, thereby generating the target plaintext data, and encrypts the target plaintext data using a symmetric encryption algorithm according to the key to generate ciphertext data, and sends the ciphertext data to the target ECU through the FlexRay bus. Obtaining the key through the timestamp increases the randomness of the key, and using non-repeated random numbers and fixed bytes to ensure the freshness of the plaintext data, reduces costs, facilitates promotion, and increases encryption strength.
[0115] Figure 3 The flowchart of the second embodiment of the method for communicating vehicle FlexRay bus data provided by the present application is as follows: Figure 3 As shown, based on the above embodiment, in step S103, a random number and a preset fixed byte are added to the plaintext data to be sent to obtain the target plaintext data, which specifically includes:
[0116] S1031: Use the timestamp as a seed and use a random number generation function to generate a random number.
[0117] In this step, in order to ensure the randomness of the random number, the timestamp obtained when the vehicle is started is used as a seed, and a random number generation function is used to generate the random number, such as the Srand function and the rand function in the C language.
[0118] Specifically, taking the Srand function in C language as an example, the process of generating random numbers includes first initializing a random seed, then using the timestamp as a seed, generating a two-byte random number corresponding to the timestamp, and the random number has not been used since the vehicle was started this time.
[0119] S1032: Determine whether the random number is the same as the random number that has been used after the vehicle is started this time.
[0120] In this step, in order to accurately identify replay attacks, the random number generated in the above step is compared with the historical data of random numbers used after the vehicle is started this time, so as to determine whether the generated random number is the same as the random number used after the vehicle is started this time.
[0121] Specifically, if the random number is not repeated with the random number that has been used after the vehicle is started this time, the threat of replay attack can be avoided. If the random number is repeated with the random number that has been used after the vehicle is started this time, the recognition of replay attack will be reduced. The repeated random number will be discarded and a new random number will be generated until a random number that is not repeated with the random number that has been used after the vehicle is started this time is obtained.
[0122] S1033: If the random number is not repeated with the random number that has been used after the vehicle is started this time, the random number is determined as the random number to be added to the plaintext data.
[0123] In this step, the random number is compared with the random number that has been used after the vehicle is started this time through the above steps. If the random number is not repeated with the random number that has been used after the vehicle is started this time, it means that the random number has not been used after the vehicle is started this time. Therefore, the random number is determined to be added to the plaintext data, so that the random number can be avoided as a replay attack in the subsequent processing process.
[0124] S1034: Add the random number and the preset fixed bytes to the end of the plaintext data in sequence to obtain the target plaintext data.
[0125] In this step, it is determined in the above step that the random number is not repeated with the random number used after the vehicle is started this time. In order to accurately identify the plaintext data in subsequent processing, a random number and a preset fixed byte are added after the plaintext data to obtain the target plaintext data.
[0126] Specifically, the fixed bytes are used to identify the correctness of the plaintext data. In the subsequent decryption process, if the target plaintext data is detected to end with the fixed bytes, it means that the decryption is successful. If not, the decryption fails. The fixed bytes can be set arbitrarily, and this scheme does not make specific restrictions. Adding a random number after the plaintext data can ensure the freshness of the plaintext data. By testing the decrypted target plaintext data, if the random number is not repeated, the replay attack on the plaintext data is avoided, thereby ensuring the encryption strength.
[0127] The vehicle FlexRay bus data communication method provided in this embodiment obtains target plaintext data by adding a non-repeating random number and a fixed byte that have been used since the vehicle was started this time to the end of the plaintext data, thereby ensuring the freshness of the plaintext data, and using fixed bytes as identifiers of the plaintext data to increase the difficulty of cracking and enhance the encryption strength.
[0128] Figure 4 The flowchart of the third embodiment of the method for communicating vehicle FlexRay bus data provided by the present application is as follows: Figure 4 As shown, based on the above-mentioned embodiment 1, the vehicle FlexRay bus data communication method provided by the present application further includes the following steps:
[0129] S106: If the random number is the same as the random number that has been used after the vehicle is started this time, a new random number is generated according to the timestamp until a random number that is not the same as the random number that has been used after the vehicle is started this time is obtained.
[0130] In this step, the random number is compared with the random number that has been used after the vehicle was started this time. If the random number is repeated with the random number that has been used after the vehicle was started this time, it means that the random number has been used after the vehicle was started this time. In order to avoid confusion and replay attacks in the subsequent decryption process, the random number is regenerated according to the timestamp, and then continued to be compared with the random number that has been used after the vehicle was started this time until the obtained random number is not repeated with the random number that has been used after the vehicle was started this time.
[0131] The vehicle FlexRay bus data communication method provided in this embodiment maintains the freshness of the plaintext data by using a random number that is not repeated with the random number used after the vehicle is started this time, and fundamentally avoids replay attacks in subsequent processing.
[0132] Figure 5 The flowchart of the fourth embodiment of the method for communicating vehicle FlexRay bus data provided by the present application is as follows: Figure 5 As shown, the vehicle FlexRay bus data communication method provided in the embodiment of the present application is applied to any electronic control unit ECU in the vehicle, specifically comprising:
[0133] S201: When the vehicle is started, a timestamp is obtained.
[0134] In this step, when the vehicle is started, the ECU in the vehicle is powered on. In order to enhance the security of data transmission between ECUs through the FlexRay bus, the ECU in the vehicle obtains a timestamp from a timestamp server.
[0135] Specifically, the ECU in the vehicle encrypts the file that needs to be timed using a hash code to form a summary, and then sends the summary to the Decode Time Stamp (DTS). After adding the date and time information of the received file summary, the DTS adds a digital signature to the file to form a timestamp, and finally sends the timestamp back to the ECU in the vehicle. The vehicle contains multiple ECUs, and each ECU obtains its own timestamp and then performs error elimination to obtain a unified timestamp. The error elimination adopts the rounding method, and there is an error range when the error is eliminated. This solution does not specifically limit the error range and can be set according to the needs of the actual scenario.
[0136] S202: Shift and extend the timestamp to generate a key.
[0137] In this step, since the use of the vehicle is irregular, the timestamp obtained in the above steps also changes with the time the vehicle is used. In order to enhance the encryption level of subsequent data transmission, the timestamp obtained in the above steps is shifted and extended to generate a secret key for encryption or decryption.
[0138] Specifically, the timestamp obtained is a two-byte hexadecimal number, which is shifted and expanded to obtain a sixteen-byte key. For example, if the timestamp is T, the specific shift expansion is:
[0139] T1 = (T + 0x71) & 0xFF;
[0140] T2 = (T1 + 0x57) & 0xFF;
[0141] T3 = (T2 + 0x33) & 0xFF.
[0142] After the above processing, we get two-byte hexadecimal numbers T, T1, T2, and T3 respectively, and continue to calculate using the following formula:
[0143] T'=T*0x1000000+T1*0x10000+T2*0x100+T3
[0144] Where T' is an eight-byte hexadecimal integer, and the shift operation on T' is continued:
[0145] T"=T'*0x100000000+T3*0x1000000+T2*0x10000+T1*0x100+T'
[0146] At this time, "T" is the final sixteen-byte key.
[0147] S203: Receive encrypted data sent by other ECUs through the FlexRay bus.
[0148] In this step, data is transmitted between ECUs via the FlexRay bus. After other ECUs encrypt the target plaintext data to generate ciphertext data, they transmit the ciphertext data to the target ECU via the FlexRay bus, and the target ECU receives the ciphertext data sent by other ECUs via the FlexRay bus.
[0149] Specifically, the ECU is mainly composed of a power supply system, a main processor, a solidified FlexRay communication controller, an optional bus monitor and a bus driver. When the main processor in other ECUs sends the ciphertext data to the solidified FlexRay communication controller, it is encoded in the solidified FlexRay communication controller to form a data bit stream, and then sent to the corresponding channel through the bus driver, the data bit stream is transmitted to the corresponding channel of the target ECU, and then transmitted to the bus driver of the target ECU through the corresponding channel of the target ECU. The bus driver accesses the stack and sends the data bit stream to the solidified FlexRay communication controller of the target ECU for decoding. After decoding generates ciphertext data, the ciphertext data is transmitted to the main processor of the target ECU through the solidified FlexRay communication controller of the target ECU.
[0150] S204: Decrypt the ciphertext data according to the key to obtain the target plaintext data.
[0151] In this step, after receiving the ciphertext data sent by other ECUs in the above steps, the target ECU uses the characteristics of the symmetric encryption algorithm to decrypt the ciphertext data with its own key, thereby obtaining the target plaintext data.
[0152] Specifically, the symmetric encryption algorithm mainly includes data encryption algorithm, triple data encryption algorithm and advanced encryption standard methods. When decrypting ciphertext data, the corresponding decryption is performed according to the algorithm selected for encryption. This solution does not specifically limit the specific encryption and decryption algorithms.
[0153] S205: Determine whether the last byte of the target plaintext data is a preset byte, and determine whether the random number before the preset byte is the same as the random number used after the vehicle is started this time.
[0154] In this step, the target plaintext data is obtained through decryption in the above steps. In order to ensure information security, it is detected whether the last fixed byte of the target plaintext data obtained after decryption is the same as the fixed byte added to the plaintext data during encryption, and it is detected whether the random number before the fixed byte of the target plaintext data obtained after decryption is repeated with the random number used after the vehicle was started this time.
[0155] Specifically, if it is detected that the last byte of the target plaintext data is a preset fixed byte, the decryption is successful and the subsequent processing continues. If it is detected that the last byte of the target plaintext data is different from the preset fixed byte, the decryption fails, and then a decryption failure message is sent to other ECUs via the FlexRay bus, where the decryption failure message is used to request other ECUs to resend the encrypted data. If it is detected that the random number before the fixed byte of the target plaintext data is repeated with the random number that has been used since the vehicle was started this time, the target plaintext data is determined to be an attack file and is not processed. If it is detected that the random number before the fixed byte of the target plaintext data is not repeated with the random number that has been used since the vehicle was started this time, it is determined that the target plaintext data does not have the risk of replay attack, and the fixed byte and random number are deleted to obtain the plaintext data, and a corresponding response is made to the content of the plaintext data.
[0156] S206: If the last byte of the target plaintext data is a preset byte, and the random number before the preset byte is not repeated with the random number used after the vehicle is started this time, then the plaintext data is obtained according to the target plaintext data.
[0157] In this step, in order to avoid replay attacks, the last fixed byte of the target plaintext data is compared with the preset byte in the above steps, and the random number before the fixed byte is compared with the random number used after the vehicle is started this time. If the last byte of the target plaintext data is the preset byte, and the random number before the preset byte is not repeated with the random number used after the vehicle is started this time, it means that the decrypted target plaintext data is the target plaintext data transmitted by other ECUs, and there is no replay attack. The fixed byte and the random number are removed to obtain the plaintext data.
[0158] Specifically, since the attacker will steal the target plaintext data sent by other ECUs through eavesdropping or other means, and send the stolen data to the target ECU, in order to launch an attack, in order to avoid being attacked, the target ECU decrypts the received ciphertext data and then detects the fixed bytes and random numbers in the target plaintext data. If it is found that the fixed bytes are the same as the preset bytes, and the random numbers have not been used since the vehicle was started this time, it is determined to be the correct data transmitted by other ECUs, and the fixed bytes and random numbers are removed to obtain the plaintext data, and the plaintext data is processed.
[0159] In the vehicle FlexRay bus data communication method provided in this embodiment, the target ECU uses the characteristics of the symmetric encryption algorithm to use its own key to decrypt the ciphertext data to obtain the target plaintext data, and double-verifies the target plaintext data, so that the attacker cannot obtain the encryption rules by simply analyzing the plaintext data, thereby increasing the difficulty of cracking. At the same time, the encryption of the ciphertext will also prevent the attacker from obtaining the privacy information of the driver and passengers through the analysis of the plaintext data.
[0160] Figure 6 The flowchart of the fifth embodiment of the vehicle FlexRay bus data communication method provided in the present application is as follows: Figure 6 As shown, based on the above embodiment, the vehicle FlexRay bus data communication method provided by the embodiment of the present application further includes:
[0161] S207: If the last byte of the target plaintext data is not a preset byte, it is determined that the decryption fails.
[0162] In this step, in order to increase the difficulty of cracking the ciphertext data, a fixed byte is added to the end of the plaintext data. When the target ECU decrypts the ciphertext data, the target plaintext data is obtained, and the fixed bytes in the target plaintext data are compared with the preset bytes. If the last byte of the target plaintext data is not the preset byte, it means that the decrypted target plaintext data is different from the target plaintext data sent by other ECUs, and the decryption is determined to have failed.
[0163] S208: Send a decryption failure message to other ECUs.
[0164] In this step, if the above step detects that the fixed bytes in the decrypted target plaintext data are not the preset bytes, then the decryption fails. In order to efficiently transmit data, the target ECU sends a decryption failure message to other ECUs. Specifically, the decryption failure message is used to request other ECUs to resend data.
[0165] or,
[0166] S209: If the random number before the preset byte is the same as the random number used after the vehicle is started this time, it is determined that the current transmission is subject to a replay attack, and the target plaintext data is refused to be processed.
[0167] In this step, after decrypting the ciphertext data, the target plaintext data is obtained. In order to avoid replay attacks, the random numbers in the target plaintext data are detected to see if they are repeated with the random numbers used after the vehicle was started this time. If it is found that the random number is repeated with the random number used after the vehicle was started this time, it means that there is a problem with the target plaintext data this time, and it is determined to be subject to a replay attack, and the target plaintext data is refused to be processed.
[0168] The vehicle FlexRay bus data communication method provided in this embodiment determines the response to the plaintext data by performing dual detection of fixed bytes and random numbers on the decrypted target plaintext data, thereby increasing the difficulty of cracking, ensuring the security of vehicle transmission data, and fundamentally avoiding replay attacks.
[0169] The following takes a specific process of data transmission between a vehicle source ECU and a target ECU via a FlexRay bus as an example to illustrate the vehicle FlexRay bus data communication method proposed in this application. Figure 7 A specific example flow chart of the vehicle FlexRay bus data communication method provided in the embodiment of the present application is as follows: Figure 7 As shown, specifically including:
[0170] S301: The vehicle is started, and the timestamp T and the dynamic key K are obtained.
[0171] In this step, after the vehicle is started, the ECU in the vehicle is powered on. In order to ensure the security of the key, the vehicle ECU obtains its own timestamp from the timestamp server, and obtains a unified timestamp T through error elimination, and finally generates the key K based on T.
[0172] Specifically, the ECU in the vehicle encrypts the file that needs to be timed using hash coding to form a summary, and then sends the summary to DTS. DTS adds a digital signature to the file to form a timestamp after adding the date and time information of the received file summary. Finally, the timestamp is sent back to each ECU in the vehicle, and the timestamp of each ECU is processed using the rounding method, and the allowable error range is 50-100 milliseconds. Finally, a unified timestamp T is obtained, and shift expansion is performed to obtain a sixteen-byte key K.
[0173] S302: The source ECU obtains a random number according to the timestamp, and determines whether it is the same as the random number used after the vehicle is started this time.
[0174] In this step, in order to maintain the freshness of the plaintext data and enhance the encryption strength, the source ECU uses T as the seed and a random number generation function to generate a random number R, and compares R with the random number used after the vehicle was started this time to determine that R has not been used since the vehicle was started this time.
[0175] Specifically, the Srand function in the C language is used to first initialize the random seed, and then use T as a seed to generate a two-byte random number R corresponding to T.
[0176] S303: If the random number is repeated, a new random number is obtained until it is no longer repeated with the random number used after the vehicle is started this time.
[0177] In this step, the above step compares the generated R with the random number used since the vehicle was started this time. If R is repeated with the random number used after the vehicle was started this time, it means that R has been used since the vehicle was started this time. When the target ECU subsequently detects the plaintext data, it will judge the plaintext data as being subject to a replay attack. At this time, R will be discarded and a new random number will be generated until the generated random number is not repeated with the random number used since the vehicle was started this time.
[0178] S304: If the random number is not repeated, the random number and the preset fixed bytes are added to the end of the plaintext data to generate the target plaintext data.
[0179] In this step, if R is compared with the random number used since the vehicle was started this time and it is found that R has not been used since the vehicle was started this time, there will be no misjudgment in the subsequent target ECU detection. Therefore, R is retained and a fixed byte is set in advance. The random number and the fixed byte are added to the end of the plaintext data to generate the target plaintext data.
[0180] Specifically, the fixed byte is selected as 0x80, wherein the fixed byte is mainly used to identify the correctness of the plaintext data. When the target ECU subsequently detects the decrypted target plaintext data, if it is found that the last fixed byte of the decrypted target plaintext data is not 0x80, it means that the decryption has failed. If it is 0x80, it means that the decryption is successful.
[0181] S305: The source ECU encrypts the target plaintext data, generates encrypted data, and sends the encrypted data to the target ECU.
[0182] In this step, the source ECU encrypts the target plaintext data using a symmetric encryption algorithm based on the key K, generates ciphertext data, and sends the ciphertext data to the target ECU via the FlexRay bus.
[0183] Specifically, the source ECU uses the AES encryption algorithm to encrypt the target plaintext data according to the key. The encryption formula is:
[0184] C=E(K,P)
[0185] Among them, P is the target plaintext data, K is the key, and C is the ciphertext data.
[0186] S306: The target ECU receives the ciphertext data and decrypts it to obtain the target plaintext data.
[0187] In this step, after the target ECU receives the ciphertext data sent by the source ECU, it decrypts the ciphertext data according to the key K and the characteristics of the AES encryption algorithm to obtain the target plaintext data.
[0188] Specifically, the key used in the encryption and decryption process of the AES encryption algorithm is the same, so the ciphertext data can be decrypted according to the decryption formula. The specific formula is:
[0189] P=D(K,C)
[0190] Among them, P is the target plaintext data, K is the key, and C is the ciphertext data.
[0191] S307: The target ECU performs a double judgment on the target plaintext data to determine whether the plaintext data is correct.
[0192] In this step, after the target ECU decrypts and obtains the target plaintext data, in order to avoid replay attacks, a double judgment is performed on the random numbers and fixed bytes in the target plaintext data to determine whether the plaintext data is correct.
[0193] Specifically, the target ECU detects whether the fixed byte at the end of the decrypted target plaintext data is 0x80, and compares the random number before the fixed byte with the random number used after the vehicle is started this time. If the fixed byte at the end of the target plaintext data is 0x80 and the random number has not been used after the vehicle is started this time, the plaintext data is determined to be correct. If the fixed byte at the end of the target plaintext data is not 0x80, or the random number is repeated with the random number used after the vehicle is started this time, the plaintext data is determined to be incorrect.
[0194] S308: If the plaintext data is correct, it is processed normally and a corresponding response is made to the plaintext data content.
[0195] In this step, through the double judgment of the above steps, if the fixed byte at the end of the target plaintext data is 0x80, and the random number has not been used since the vehicle was started this time, the plaintext data is determined to be correct, the random number and the fixed byte are removed to obtain the plaintext data, and a corresponding response is made to the content of the plaintext data.
[0196] S309: If the plaintext data is incorrect, the processing is rejected.
[0197] In this step, through double judgment, if the last fixed byte of the target plaintext data is not 0x80, it means that the decrypted target plaintext data is different from the target plaintext data sent by the source ECU, and the decryption fails. The target ECU sends a decryption failure message to the source ECU, requesting the source ECU to resend the data. Or, if the random number is repeated with the random number used after the vehicle is started this time, it means that the decrypted target plaintext data does not match the target plaintext data sent by the source ECU, and it has been replayed. The target ECU refuses to process the plaintext data.
[0198] The vehicle FlexRay bus data communication method provided in this embodiment adopts a software encryption scheme to obtain the timestamp of vehicle startup, and generates a key and a random number according to the timestamp, and adds the random number and fixed bytes to the end of the plaintext data to generate the target plaintext data, thereby ensuring the freshness of the plaintext data, and encrypts the target plaintext data using a symmetric encryption algorithm. Compared with hardware module encryption, it is easy to promote and reduce costs and development cycles. Compared with ordinary software encryption schemes, a timestamp is added as a seed, so that the key and the random number are more random, which not only has high encryption strength and is difficult to crack, but also can solve the threat of replay attacks on the FlexRay bus. The attacker can protect the driving safety of the driver and passengers by monitoring the privacy leakage caused by the plaintext data, and the strength of the key is protected by using the random number of the key generated at each vehicle startup time.
[0199] The present application also provides a vehicle FlexRay bus data communication device, Figure 8 The structure diagram of the first embodiment of the communication device for vehicle FlexRay bus data provided by the embodiment of the present application is as follows Figure 8 As shown, the vehicle FlexRay bus data communication device 400 includes:
[0200] The first acquisition module 401 is used to acquire a timestamp when the vehicle is started.
[0201] The key generation module 402 is used to shift and expand the timestamp to generate a key.
[0202] The data updating module 403 is used to add a random number and a preset fixed byte to the plain text data to be sent to obtain the target plain text data. The random number is generated according to the timestamp, and the random number has not been used since the vehicle was started this time.
[0203] The data encryption module 404 is used to encrypt the target plaintext data according to the key to obtain ciphertext data.
[0204] The data sending module 405 is used to send the encrypted data to the target ECU via the FlexRay bus.
[0205] Fig. 9 The structural diagram of the second embodiment of the communication device for vehicle FlexRay bus data provided by the embodiment of the present application is as follows Fig. 9 As shown, the data updating module 403 includes:
[0206] The data generating unit 4031 is used to use the timestamp as a seed and adopt a random number generating function to generate a random number.
[0207] The first judgment unit 4032 is used to determine whether the random number is the same as the random number that has been used after the vehicle is started this time.
[0208] The second judgment unit 4033 is used to determine the random number as the random number to be added to the plaintext data if the random number is not repeated with the random number that has been used after the vehicle is started this time.
[0209] The data updating unit 4034 is used to sequentially add the random number and the preset fixed bytes to the end of the plaintext data to obtain the target plaintext data.
[0210] Fig.10 The structure diagram of the third embodiment of the communication device for vehicle FlexRay bus data provided by the embodiment of the present application is as follows Fig.10 As shown, the vehicle FlexRay bus data communication device 400 also includes:
[0211] The second acquisition module 406 is used to regenerate a random number according to the timestamp if the random number is repeated with the random number used after the vehicle is started this time, until a random number that is not repeated with the random number used after the vehicle is started this time is obtained.
[0212] Fig.11 The structure diagram of the fourth embodiment of the communication device for vehicle FlexRay bus data provided by the embodiment of the present application is as follows Fig.11 As shown, the key generation module 402 includes:
[0213] The key generation unit 4021 is used to shift and expand the timestamp to obtain a sixteen-byte key, which is used to encrypt or decrypt data sent via the FlexRay bus during the current driving process of the vehicle.
[0214] Fig.12 The structure diagram of the fifth embodiment of the communication device for vehicle FlexRay bus data provided by the embodiment of the present application is as follows: Fig.12 As shown, the vehicle FlexRay bus data communication device 500 includes:
[0215] The first acquisition module 501 is used to acquire a timestamp when the vehicle is started.
[0216] The key generation module 502 is used to shift and expand the timestamp to generate a key.
[0217] The data receiving module 503 is used to receive encrypted data sent by other ECUs through the FlexRay bus.
[0218] The data decryption module 504 is used to decrypt the ciphertext data according to the key to obtain the target plaintext data.
[0219] The data judgment module 505 is used to determine whether the last byte of the target plaintext data is a preset byte, and to determine whether the random number before the preset byte is the same as the random number used after the vehicle is started this time.
[0220] The second acquisition module 506 is used to acquire plaintext data according to the target plaintext data if the last byte of the target plaintext data is a preset byte and the random number before the preset byte is not repeated with the random number used after the vehicle is started this time.
[0221] A judgment processing module 507, configured to determine that decryption fails if the last byte of the target plaintext data is not a preset byte;
[0222] Send a decryption failure message to other ECUs, which is used to request other ECUs to resend data;
[0223] or,
[0224] If the random number before the preset byte is the same as the random number that has been used after the vehicle was started this time, it is determined that the current transmission has been subjected to a replay attack, and the target plaintext data will be refused to be processed.
[0225] Fig.13 The structure diagram of the sixth embodiment of the communication device for vehicle FlexRay bus data provided by the embodiment of the present application is as follows Fig.13 As shown, the key generation module 502 includes:
[0226] The key generation unit 5021 is used to shift and expand the timestamp to obtain a 16-byte key, which is used to encrypt or decrypt data sent via the FlexRay bus during the current driving process of the vehicle.
[0227] The embodiment of the present application also provides a vehicle, Fig.14 A schematic diagram of the structure of a vehicle provided in an embodiment of the present application, such as Fig.14 As shown, the vehicle includes: a vehicle body 600, a storage unit 601, and a plurality of electronic control units ECU602;
[0228] The storage unit 601 stores computer-executable instructions.
[0229] Any ECU 602 executes computer-executable instructions stored in the memory to implement the method in any one of the embodiments.
[0230] An embodiment of the present application further provides a computer-readable storage medium, in which computer-executable instructions are stored. When the computer-executable instructions are executed by a processor, they are used to implement the method in any one of the embodiments.
[0231] The computer-readable storage medium mentioned above can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory, electrically erasable programmable read-only memory, erasable programmable read-only memory, programmable read-only memory, read-only memory, magnetic memory, flash memory, magnetic disk or optical disk. The readable storage medium can be any available medium that can be accessed by a general or special-purpose computer.
[0232] Optionally, a readable storage medium is coupled to a processor so that the processor can read information from the readable storage medium and write information to the readable storage medium. Of course, the readable storage medium can also be a component of the processor. The processor and the readable storage medium can be located in an application specific integrated circuit (ASIC). Of course, the processor and the readable storage medium can also exist in the device as discrete components.
[0233] An embodiment of the present application also provides a computer program product, which includes a computer program. The computer program is stored in a computer-readable storage medium. At least one processor can read the computer program from the computer-readable storage medium. When at least one processor executes the computer program, the technical solution provided by any of the above method embodiments can be implemented.
[0234] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the invention disclosed herein. The present application is intended to cover any modification, use or adaptation of the present application, which follows the general principles of the present application and includes common knowledge or customary techniques in the art that are not disclosed in the present application. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present application are indicated by the following claims.
[0235] It should be understood that the present application is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.
Claims
1. A vehicle FlexRay bus data communication method, characterized in that: Applicable to any electronic control unit ECU in the vehicle, including: When the vehicle is started, obtaining a timestamp; Shifting and extending the timestamp to generate a key; Adding a random number and a preset fixed byte to the plaintext data to be sent to obtain target plaintext data, wherein the random number is generated according to the timestamp and has not been used since the vehicle was started this time; Encrypting the target plaintext data according to the key to obtain ciphertext data; The encrypted data is sent to the target ECU via the FlexRay bus.
2. The method according to claim 1, characterized in that The step of adding a random number and a preset fixed byte to the plaintext data to be sent to obtain the target plaintext data includes: Using the timestamp as a seed, a random number generation function is used to generate a random number; Determine whether the random number is the same as a random number that has been used after the vehicle is started this time; If the random number is not repeated with a random number that has been used after the vehicle is started this time, the random number is determined as the random number to be added to the plaintext data; The random number and the preset fixed bytes are sequentially added to the back of the plaintext data to obtain the target plaintext data.
3. The method according to claim 2, characterized in that The method further comprises: If the random number is the same as the random number that has been used after the vehicle is started this time, a random number is regenerated according to the timestamp until a random number that is not the same as the random number that has been used after the vehicle is started this time is obtained.
4. The method according to any one of claims 1 to 3, characterized in that: The step of shifting and extending the timestamp to generate a key includes: The timestamp is shifted and expanded to obtain the key of sixteen bytes, and the key is used to encrypt or decrypt the data sent through the FlexRay bus during the current driving process of the vehicle.
5. A vehicle FlexRay bus data communication method, characterized in that: Applicable to any electronic control unit ECU in the vehicle, including: When the vehicle is started, obtaining a timestamp; Shifting and extending the timestamp to generate a key; Receive encrypted data sent by other ECUs through the FlexRay bus; Decrypting the ciphertext data according to the key to obtain target plaintext data; Determine whether the last byte of the target plaintext data is a preset byte, and determine whether the random number before the preset byte is the same as the random number used after the vehicle is started this time; If the last byte of the target plaintext data is a preset byte, and the random number before the preset byte is not repeated with the random number used after the vehicle is started this time, the plaintext data is obtained according to the target plaintext data.
6. The method according to claim 5, characterized in that The method further comprises: If the last byte of the target plaintext data is not the preset byte, it is determined that the decryption fails; Sending a decryption failure message to the other ECU, wherein the decryption failure message is used to request the other ECU to resend data; or, If the random number before the preset byte is the same as the random number used after the vehicle is started this time, it is determined that the current transmission is subject to a replay attack, and the target plaintext data is refused to be processed.
7. The method according to claim 5 or 6, characterized in that: The step of shifting and extending the timestamp to generate a key includes: The timestamp is shifted and expanded to obtain the key of sixteen bytes, and the key is used to encrypt or decrypt the data sent through the FlexRay bus during the current driving process of the vehicle.
8. A vehicle FlexRay bus data communication device, characterized in that: include: A first acquisition module, used for acquiring a timestamp when the vehicle is started; A key generation module, used for shifting and extending the timestamp to generate a key; A data updating module, used for adding a random number and a preset fixed byte to the plaintext data to be sent to obtain target plaintext data, wherein the random number is generated according to the timestamp and has not been used since the vehicle was started this time; A data encryption module, used to encrypt the target plaintext data according to the key to obtain ciphertext data; The data sending module is used to send the encrypted data to the target ECU via the FlexRay bus.
9. The device according to claim 8, characterized in that The data updating module comprises: A data generation unit, configured to use the timestamp as a seed and adopt a random number generation function to generate a random number; A first judgment unit, used to determine whether the random number is the same as a random number that has been used after the vehicle is started this time; a second determination unit, configured to determine the random number as a random number to be added to the plaintext data if the random number is not repeated with a random number that has been used after the vehicle is started this time; The data updating unit is used to sequentially add the random number and the preset fixed bytes to the end of the plaintext data to obtain the target plaintext data.
10. The device according to claim 9, characterized in that The device also includes: The second acquisition module is used to regenerate a random number according to the timestamp if the random number is repeated with the random number used after the vehicle is started this time, until a random number that is not repeated with the random number used after the vehicle is started this time is obtained.
11. The device according to any one of claims 8 to 10, characterized in that The key generation module comprises: The key generation unit is used to shift and expand the timestamp to obtain the key of sixteen bytes, and the key is used to encrypt or decrypt the data sent through the FlexRay bus during the current driving of the vehicle.
12. A vehicle FlexRay bus data communication device, characterized in that: include: A first acquisition module, used for acquiring a timestamp when the vehicle is started; A key generation module, used for shifting and extending the timestamp to generate a key; Data receiving module, used to receive encrypted data sent by other ECUs through FlexRay bus; A data decryption module, used to decrypt the ciphertext data according to the key to obtain target plaintext data; A data judgment module, used to determine whether the last byte of the target plaintext data is a preset byte, and to determine whether the random number before the preset byte is the same as the random number used after the vehicle is started this time; The second acquisition module is used to acquire plaintext data according to the target plaintext data if the last byte of the target plaintext data is a preset byte and the random number before the preset byte is not repeated with the random number used after the vehicle is started this time.
13. The device according to claim 12, characterized in that The device also includes: A judgment processing module, configured to determine that decryption fails if the last byte of the target plaintext data is not the preset byte; Sending a decryption failure message to the other ECU, wherein the decryption failure message is used to request the other ECU to resend data; or, If the random number before the preset byte is the same as the random number used after the vehicle is started this time, it is determined that the current transmission is subject to a replay attack, and the target plaintext data is refused to be processed.
14. The device according to claim 12 or 13, characterized in that The key generation module comprises: The key generation unit is used to shift and expand the timestamp to obtain the key of sixteen bytes, and the key is used to encrypt or decrypt the data sent through the FlexRay bus during the current driving of the vehicle.
15. A vehicle, characterized in that: include: A vehicle body, a storage unit and a plurality of electronic control units ECU disposed in the vehicle body; The storage unit stores computer-executable instructions; The arbitrary ECU executes the computer-executable instructions stored in the storage unit to implement the method according to any one of claims 1 to 7.
16. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, which are used to implement any method according to any one of claims 1 to 7 when executed by a processor.
Citation Information
Cited By
Method for generating default password, method, device and equipment for carrying out user verification
CN120750634A
Method for generating a default password, method for performing user authentication, apparatus and device
CN120750634B
