WO2021136072A1 - 通信方法和电子设备 - Google Patents

通信方法和电子设备 Download PDF

Info

Publication number
WO2021136072A1
WO2021136072A1 PCT/CN2020/139121 CN2020139121W WO2021136072A1 WO 2021136072 A1 WO2021136072 A1 WO 2021136072A1 CN 2020139121 W CN2020139121 W CN 2020139121W WO 2021136072 A1 WO2021136072 A1 WO 2021136072A1
Authority
WO
WIPO (PCT)
Prior art keywords
key
value
authentication
ecu
data
Prior art date
Application number
PCT/CN2020/139121
Other languages
English (en)
French (fr)
Inventor
杨艳江
杨思源
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Priority to EP20909121.4A priority Critical patent/EP4080813B1/en
Publication of WO2021136072A1 publication Critical patent/WO2021136072A1/zh

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/08Key distribution or management, e.g. generation, sharing or updating, of cryptographic keys or passwords
    • H04L9/0816Key establishment, i.e. cryptographic processes or cryptographic protocols whereby a shared secret becomes available to two or more parties, for subsequent use
    • H04L9/085Secret sharing or secret splitting, e.g. threshold schemes
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/06Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols the encryption apparatus using shift registers or memories for block-wise or stream coding, e.g. DES systems or RC4; Hash functions; Pseudorandom sequence generators
    • H04L9/0618Block ciphers, i.e. encrypting groups of characters of a plain text message using fixed encryption transformation
    • H04L9/0631Substitution permutation network [SPN], i.e. cipher composed of a number of stages or rounds each involving linear and nonlinear transformations, e.g. AES algorithms
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L1/00Arrangements for detecting or preventing errors in the information received
    • H04L1/004Arrangements for detecting or preventing errors in the information received by using forward error control
    • H04L1/0056Systems characterized by the type of code used
    • H04L1/0061Error detection codes
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/28Data switching networks characterised by path configuration, e.g. LAN [Local Area Networks] or WAN [Wide Area Networks]
    • H04L12/40Bus networks
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/04Network architectures or network communication protocols for network security for providing a confidential data exchange among entities communicating through data packet networks
    • H04L63/0428Network architectures or network communication protocols for network security for providing a confidential data exchange among entities communicating through data packet networks wherein the data content is protected, e.g. by encrypting or encapsulating the payload
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/12Applying verification of the received information
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/12Applying verification of the received information
    • H04L63/123Applying verification of the received information received data contents, e.g. message integrity
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/08Key distribution or management, e.g. generation, sharing or updating, of cryptographic keys or passwords
    • H04L9/0816Key establishment, i.e. cryptographic processes or cryptographic protocols whereby a shared secret becomes available to two or more parties, for subsequent use
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/08Key distribution or management, e.g. generation, sharing or updating, of cryptographic keys or passwords
    • H04L9/0861Generation of secret information including derivation or calculation of cryptographic keys or passwords
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/12Transmitting and receiving encryption devices synchronised or initially set up in a particular manner
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/32Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/28Data switching networks characterised by path configuration, e.g. LAN [Local Area Networks] or WAN [Wide Area Networks]
    • H04L12/40Bus networks
    • H04L12/40006Architecture of a communication node
    • H04L12/40013Details regarding a bus controller
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/28Data switching networks characterised by path configuration, e.g. LAN [Local Area Networks] or WAN [Wide Area Networks]
    • H04L12/40Bus networks
    • H04L2012/40208Bus networks characterized by the use of a particular bus standard
    • H04L2012/40215Controller Area Network CAN
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/28Data switching networks characterised by path configuration, e.g. LAN [Local Area Networks] or WAN [Wide Area Networks]
    • H04L12/40Bus networks
    • H04L2012/40267Bus for use in transportation systems
    • H04L2012/40273Bus for use in transportation systems the transportation system being a vehicle
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L2209/00Additional information or applications relating to cryptographic mechanisms or cryptographic arrangements for secret or secure communication H04L9/00
    • H04L2209/84Vehicles
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L2463/00Additional details relating to network architectures or network communication protocols for network security covered by H04L63/00
    • H04L2463/061Additional details relating to network architectures or network communication protocols for network security covered by H04L63/00 applying further key derivation, e.g. deriving traffic keys from a pair-wise master key

Definitions

  • the embodiments of the present application relate to the field of in-vehicle communication technology, and in particular to a communication method and electronic equipment.
  • ECU Electronic Control Unit
  • CAN Controller Area Network
  • the ECU in the in-vehicle system authenticates the CAN message through a fixed key.
  • CANAuth uses HMAC to authenticate messages. This authentication method requires the ECU to derive the authentication key from a fixed key, a counter, and a random number sent from the CAN+ channel.
  • the embodiments of the present application provide a communication method and electronic equipment, which improve the security of information transmission.
  • an embodiment of the present application provides a communication method, including:
  • the CAN frame is assembled by the first key and the second key; the first key is used to encrypt the payload of the effective data, and the second key is used to randomize the CRC bits in the data payload field s position;
  • the CAN frame is sent to the second ECU via the CAN bus; wherein, the first value is a value broadcast by the manager according to the time period, and the shared key is a key shared by all ECUs in the vehicle.
  • the determining the authentication key according to the first value and the shared key includes:
  • the authentication key is generated through a block encryption algorithm.
  • the splitting the authentication key to obtain the first key and the second key includes:
  • a first initial key is generated through a block encryption algorithm;
  • the first count value is the value corresponding to the first counter;
  • the first initial key is decomposed into the first key and the second key.
  • the assembling a CAN frame by using the first key and the second key includes:
  • it also includes:
  • the value of the bit in the second key can only determine the position of the part of the CRC bit in the data load field, then the finally determined CRC bit is used as the starting point, and the remaining CRC bits are placed in sequence. Enter the subsequent load bit.
  • the determining the position of the CRC in the data payload field according to the value of the bit in the second key includes:
  • an embodiment of the present application provides a communication method, including:
  • the first count value is the value corresponding to the first counter
  • the CAN frame is sent to the second ECU via the CAN bus; wherein, the first value is a value broadcast by the manager according to the time period, and the shared key is a key shared by all ECUs in the vehicle.
  • the determining the authentication key according to the first value and the shared key includes:
  • the authentication key is generated through a block encryption algorithm.
  • obtaining the third key through the authentication key and the first count value includes:
  • the length of the first initial key is tailored to obtain the third key.
  • the assembling of the CAN frame by using the first count value and the third key includes:
  • the first count value is put into the first counter field of the CAN frame, and the encrypted data is put into the data load field to obtain the assembled CAN frame.
  • an embodiment of the present application provides a communication method, including:
  • splitting the authentication key to obtain a fourth key and a fifth key; the fourth key is used to decrypt the effective data payload, and the fifth key is used to restore the effective data payload and restore the CRC;
  • the CAN frame is authenticated by the fourth key and the fifth key; wherein, the first value is the value broadcast by the manager according to the time period, and the shared key is shared by all ECUs in the vehicle Key.
  • the determining the authentication key according to the first value and the shared key includes:
  • the authentication key is generated through a block encryption algorithm.
  • the method before the authentication of the CAN frame by the authentication key, the method further includes:
  • the second count value is compared with the first count value, and if the second count value is greater than the first count value, it is determined that authentication has failed; wherein, the first count value is the value of the first ECU The value corresponding to the first counter.
  • the authentication of the CAN frame through the fourth key and the fifth key includes:
  • the restored payload and the restored CRC are verified through the CRC algorithm, and if the verification fails, it is determined that the authentication fails.
  • an embodiment of the present application provides a communication method, including:
  • the second count value is the value corresponding to the second counter
  • the sixth key and the third key are compared, and if they are inconsistent, it is determined that the authentication has failed.
  • obtaining the sixth key through the authentication key and the second count value includes:
  • the length of the second initial key is tailored to obtain the sixth key.
  • an embodiment of the present application provides a communication method, which is applied in a communication system including a first ECU and a second ECU, and the method includes:
  • the first ECU determines the authentication key according to the first value and the shared key
  • the CAN frame is assembled by the first key and the second key; the first key is used to encrypt the payload of the effective data, and the second key is used to randomize the CRC bits in the data payload field s position;
  • the first value is a value broadcast by the manager according to the time period
  • the shared key is a key shared by all ECUs in the vehicle
  • the second ECU receives the CAN frame sent by the first ECU; splits the authentication key to obtain a fourth key and a fifth key; the fourth key is used to decrypt the effective data payload, and the fifth key The key is used to restore the effective data load and restore the CRC; the CAN frame is authenticated by the fourth key and the fifth key.
  • the determining the authentication key according to the first value and the shared key includes:
  • the authentication key is generated through a block encryption algorithm.
  • the splitting the authentication key to obtain the first key and the second key includes:
  • a first initial key is generated through a block encryption algorithm;
  • the first count value is the value corresponding to the first counter;
  • the first initial key is decomposed into the first key and the second key.
  • the assembling a CAN frame by using the first key and the second key includes:
  • the value of the bit in the second key can only determine the position of a part of the CRC bit in the data payload field, then the finally determined CRC bit is used as the starting point, and the The bits of the remaining part of the CRC are sequentially put into the subsequent load bits.
  • the determining the position of the CRC in the data payload field according to the value of the bit in the second key includes:
  • the method before the authentication of the CAN frame by the authentication key, the method further includes:
  • the second count value is compared with the first count value, and if the second count value is greater than the first count value, it is determined that authentication has failed; wherein, the first count value is the value of the first ECU The value corresponding to the first counter.
  • the authentication of the CAN frame through the fourth key and the fifth key includes:
  • the restored payload and the restored CRC are verified through the CRC algorithm, and if the verification fails, it is determined that the authentication fails.
  • an embodiment of the present application provides a communication method, which is applied in a communication system including a first ECU and a second ECU, and the method includes:
  • the first ECU determines the authentication key according to the first value and the shared key
  • the first count value is the value corresponding to the first counter
  • the first value is a value broadcast by the manager according to the time period
  • the shared key is a key shared by all ECUs in the vehicle
  • the second ECU receives the CAN frame sent by the first ECU
  • the second count value is the value corresponding to the second counter
  • the sixth key and the third key are compared, and if they are inconsistent, it is determined that the authentication has failed.
  • the determining the authentication key according to the first value and the shared key includes:
  • the authentication key is generated through a block encryption algorithm.
  • obtaining the third key through the authentication key and the first count value includes:
  • the length of the first initial key is tailored to obtain the third key.
  • the assembling of the CAN frame by using the first count value and the third key includes:
  • obtaining the sixth key through the authentication key and the second count value includes:
  • the length of the second initial key is tailored to obtain the sixth key.
  • an embodiment of the present application provides a first ECU, including:
  • the processing module is used to determine the authentication key according to the first value and the shared key; split the authentication key to obtain the first key and the second key; pass the first key and the shared key
  • the second key is used to assemble the CAN frame; the first key is used to encrypt the effective data payload, and the second key is used to randomize the position of the CRC bit in the data payload field;
  • the sending module is configured to send the CAN frame to the second ECU via the CAN bus; wherein the first value is a value broadcast by the manager according to the time period, and the shared key is a key shared by all ECUs in the vehicle.
  • the processing module is specifically used for:
  • the authentication key is generated through a block encryption algorithm.
  • the processing module is specifically used for:
  • a first initial key is generated through a block encryption algorithm;
  • the first count value is the value corresponding to the first counter;
  • the first initial key is decomposed into the first key and the second key.
  • the processing module is specifically used for:
  • the processing module is specifically used for:
  • the value of the bit in the second key can only determine the position of the part of the CRC bit in the data load field, then the finally determined CRC bit is used as the starting point, and the remaining CRC bits are placed in sequence. Enter the subsequent load bit.
  • the processing module is specifically used for:
  • an embodiment of the present application provides a first ECU, including:
  • the processing module is configured to determine the authentication key according to the first value and the shared key; obtain the third key through the authentication key and the first count value; the first count value is the value corresponding to the first counter Assemble a CAN frame through the first count value and the third key; the third key is used to encrypt the effective data payload;
  • the sending module is configured to send the CAN frame to the second ECU via the CAN bus; wherein the first value is a value broadcast by the manager according to the time period, and the shared key is a key shared by all ECUs in the vehicle.
  • the processing module is specifically used for:
  • the authentication key is generated through a block encryption algorithm.
  • the processing module is specifically used for:
  • the length of the first initial key is tailored to obtain the third key.
  • the processing module is specifically used for:
  • the first count value is put into the first counter field of the CAN frame, and the encrypted data is put into the data load field to obtain the assembled CAN frame.
  • an embodiment of the present application provides a second ECU, including:
  • the processing module is used to determine the authentication key according to the first value and the shared key
  • the receiving module is used to receive the CAN frame sent by the first ECU;
  • the processing module is configured to split the authentication key to obtain a fourth key and a fifth key; the fourth key is used to decrypt the effective data payload, and the fifth key is used to restore the effective data Load and restore CRC;
  • the processing module is configured to authenticate the CAN frame by using the fourth key and the fifth key; wherein, the first value is a value broadcast by the manager according to a time period, and the shared key is The key shared by all ECUs in the vehicle.
  • the processing module is specifically configured to: determine the authentication key according to the first value and the shared key, including:
  • the authentication key is generated through a block encryption algorithm.
  • the processing module is specifically configured to: before the CAN frame is authenticated by the authentication key, the processing module further includes:
  • the second count value is compared with the first value, and if the second count value is greater than the first count value, it is determined that authentication has failed; wherein, the first count value is the first value of the first ECU The value corresponding to a counter.
  • the processing module is specifically configured to: authenticate the CAN frame through the fourth key and the fifth key, including:
  • the restored payload and the restored CRC are verified through the CRC algorithm, and if the verification fails, it is determined that the authentication fails.
  • an embodiment of the present application provides a second ECU, including:
  • the processing module is used to determine the authentication key according to the first value and the shared key
  • the receiving module is used to receive the CAN frame sent by the first ECU;
  • a processing module configured to obtain a sixth key through the authentication key and a second count value; the second count value is a value corresponding to a second counter;
  • the processing module is used to decompose the data load field of the read CAN frame to obtain the third key and the effective data load;
  • the processing module is configured to compare the sixth key and the third key, and if they are inconsistent, determine that the authentication fails.
  • the processing module is specifically used for:
  • the length of the second initial key is tailored to obtain the sixth key.
  • an embodiment of the present application provides an electronic device including: a processor and a transceiver, the processor is configured to execute instructions in a computer executable program code; when the processor executes the instructions, the The instructions cause the electronic device to perform the method of any one of the first aspects.
  • an embodiment of the present application provides an electronic device including: a processor and a transceiver, the processor is configured to execute instructions in a computer executable program code; when the processor executes the instructions, the The instructions cause the electronic device to perform the method described in any one of the second aspects.
  • an embodiment of the present application provides an electronic device including: a processor and a transceiver, the processor is configured to execute instructions in a computer executable program code; when the processor executes the instructions, the The instructions cause the electronic device to perform the method described in any one of the third aspects.
  • an embodiment of the present application provides an electronic device including: a processor and a transceiver, the processor is configured to execute instructions in a computer executable program code; when the processor executes the instructions, the The instructions cause the electronic device to perform the method described in any one of the fourth aspect.
  • an embodiment of the present application provides a communication system including a first ECU and a second ECU, and the communication system is configured to execute the method described in any one of the fifth aspect.
  • an embodiment of the present application provides a communication system including a first ECU and a second ECU, and the communication system is configured to execute the method according to any one of the sixth aspects.
  • an embodiment of the present application provides a chip, including a memory and a processor, the memory is used to store program instructions, and the processor is used to call the program instructions in the memory to execute the first aspect or the second aspect described in the embodiments of the present application.
  • an embodiment of the present application provides a chip, including a memory and a processor, the memory is used to store program instructions, and the processor is used to call the program instructions in the memory to execute the third aspect or the fourth aspect described in the embodiments of the present application.
  • an embodiment of the present application provides a readable storage medium on which a computer program is stored; when the computer program is executed, the embodiment of the present application of the first aspect or the second aspect is implemented The communication method described.
  • an embodiment of the present application provides a readable storage medium on which a computer program is stored; when the computer program is executed, it implements the third aspect or the fourth aspect.
  • an embodiment of the present application provides a program product, the program product includes a computer program, the computer program is stored in a readable storage medium, and at least one processor of a communication device can read from the readable storage The medium reads the computer program, and the at least one processor executes the computer program to enable the communication device to implement the communication method according to any one of the embodiments of the present application in the first aspect or the second aspect.
  • an embodiment of the present application provides a program product, the program product includes a computer program, the computer program is stored in a readable storage medium, and at least one processor of a communication device can read from the readable storage The medium reads the computer program, and the at least one processor executes the computer program to enable the communication device to implement the communication method according to any one of the embodiments of the present application in the third aspect or the fourth aspect.
  • the manager broadcasts the first value to each electronic control unit according to the time period, so that when CAN messages are sent between each electronic control unit, the first value and the shared key can be used for encryption and authentication, thereby improving This improves the security of information transmission in the on-board system.
  • FIG. 1 is a schematic diagram of a communication system provided by an embodiment of this application.
  • Figure 2 is a schematic diagram of the structure of an electronic control unit
  • FIG. 3 is a first flowchart of a communication method provided by an embodiment of this application.
  • Figure 4 is a schematic diagram 1 of the principle of generating M * according to c 1;
  • Figure 5 is a schematic diagram of the second principle of generating M * according to c 1;
  • FIG. 6 is a second flowchart of a communication method provided by an embodiment of this application.
  • FIG. 7 is a third flowchart of a communication method provided by an embodiment of this application.
  • FIG. 8 is a fourth flowchart of a communication method provided by an embodiment of this application.
  • Fig. 9 is a first structural diagram of a first ECU provided by an embodiment of the application.
  • FIG. 10 is a second structural diagram of a first ECU according to an embodiment of the application.
  • FIG. 11 is a first structural diagram of a second ECU provided by an embodiment of the application.
  • FIG. 12 is a second structural diagram of a second ECU provided by an embodiment of the application.
  • FIG. 13 is a schematic structural diagram of an electronic device provided by an embodiment of the application.
  • FIG. 14 is a schematic structural diagram of a communication system provided by an embodiment of this application.
  • FIG. 1 is a schematic diagram of a communication system provided by an embodiment of the application.
  • the communication system 10 includes an electronic control unit 11, a manager 12, and a bus 13 connecting the electronic control unit 11 and the manager 12.
  • FIG. 2 is a schematic diagram of the structure of the electronic control unit.
  • the electronic control unit 11 includes: a microcontroller 1101, a CAN controller 1102, a transceiver 1103, a memory 1104, a computer program stored in the memory 1104, a microcontroller 1101 loads the calculation program from the memory 1104, executes the corresponding program flow, generates control instructions, and sends the control instructions to the CAN controller 1102, so that the CAN controller 1102 receives or transmits through the transceiver 1103 that is in communication with the bus 13 CAN message.
  • CAN network through a bus
  • any electronic control unit can send CAN messages to other electronic control units through the bus.
  • the on-board system is vulnerable to network attacks. Attackers or compromised electronic control units can freely send CAN messages, thereby seriously threatening the vehicle. System security.
  • CAN messages are transmitted on the bus in the form of CAN frames, and CAN frames generally adopt CAN2.0A standard frames and CAN2.0B standard frames.
  • CAN frame includes ID domain, CRC domain, DATA domain, among them, ID domain is used for distinguishing CAN frame, CRC domain is used for loading the CRC code of data, DATA domain is used for loading data.
  • the CRC code is used to check errors in data transmission, but it does not have the key learning function. Therefore, the additional information generated by the authentication of the CAN message needs to be borne by the DATA domain.
  • the ECU in the in-vehicle system authenticates the CAN message through a fixed key.
  • CANAuth uses HMAC to authenticate messages.
  • This authentication method requires the ECU to derive the authentication key from a fixed key, a counter, and a random number sent from the CAN+ channel.
  • the CAN message can be encrypted through the DATA domain, this encryption method will add extra load, and the fixed key is easy to be cracked, resulting in an attack on the vehicle system.
  • the communication method provided by the embodiments of the present application aims to realize the encryption and authentication of CAN messages without adding additional load, thereby improving the security of information transmission of the vehicle system.
  • the effect of this embodiment is to perform encryption and authentication on the CAN frame at the same time.
  • CAN messages authentication or encryption
  • one of the most basic security requirements is to prevent replay attacks.
  • counters can be used, that is, it is assumed that the sending ECU (sender) and the receiving ECU (receiver) each maintain a synchronized counter (in order to facilitate synchronization and verification of CAN messages, the counter value usually needs to be sent along with the CAN message ). Due to the limited length of the data field of the CAN frame, the counter cannot be very large.
  • the time can be divided into time periods (each time period is a session), and a different value (Global Sessional Number, GSN) is broadcast to all ECUs at the beginning of each time period through the manager (such as gateway) .
  • the ECU can use the value and the shared key to generate an authentication key for encrypting and authenticating CAN messages.
  • This encryption and authentication method can realize the encryption and authentication of CAN messages without adding additional load, thereby improving the security of information transmission in the vehicle system.
  • FIG. 3 is a first flowchart of a communication method provided by an embodiment of this application. Referring to FIG. 3, the method in this embodiment includes:
  • Step S101 Determine an authentication key according to the first value and the shared key.
  • Step S102 Split the authentication key to obtain the first key and the second key.
  • Step S103 Assemble the CAN frame by using the first key and the second key.
  • Step S104 Send a CAN frame to the second ECU via the CAN bus.
  • the first ECU and the second ECU are connected through a bus communication, and the first ECU can send a CAN message to the second ECU.
  • the first value is the value broadcast by the manager according to the time period
  • the shared key is a key shared by all ECUs in the vehicle. The first key is used to encrypt the effective data payload, and the second key is used to randomize the position of the CRC bit in the data payload field.
  • the authentication key may be generated through a block encryption algorithm according to the first value and the shared key.
  • the manager broadcasts the first value to all ECUs. Because each time period corresponds to a different time, the first value is also different, so there is no need to use a random number for the first value here.
  • the first value can also be sent in a CAN frame, and the length of the data field of a CAN frame is generally 64 bits.
  • the first value broadcast by the manager to all ECUs is similar in function to a time stamp, and its value is determined by the manager's own clock or counter.
  • the first value broadcast by the manager is GSN i
  • the shared key between the first ECU and the second ECU is K.
  • the calculation method of the authentication key K i is as follows:
  • K i AES128(K,GSNi
  • AES128 is used to generate K i , and its encryption efficiency is higher. Because GSNi
  • this embodiment takes ASE as an example for description, but does not limit the block encryption algorithm, and all existing encryption algorithms can be applied in this embodiment.
  • the CAN message can be encrypted and authenticated by the authentication key. Therefore, the role of the CRC field is not necessary.
  • the original CRC field and the original DATA field in the CAN frame can be merged as a new one.
  • the length of the CRC field is 15 bits, and the length of the DATA field is 64, so the combined data field has a length of 81 bits.
  • the first ECU and the second ECU each need to maintain a synchronized counter called a local counter (relative to the ground, the GSN generated by the manager can be regarded as a global counter).
  • a local counter relative to the ground, the GSN generated by the manager can be regarded as a global counter.
  • the first ECU and the second ECU reset the local counter to 0 at the same time when calculating the authentication key, and then count again.
  • the local counter value is preferably carried in the CAN frame. Therefore, the DATA domain (data domain) can be a local counter domain and a data load domain. If the length of the local counter field is 11 bits, the length of the data payload field may be 70 bits or 53 bits.
  • step S102 the first count value corresponding to the local counter of the first ECU (hereinafter referred to as the first counter) may be obtained first, and then the first initial secret is generated through the block encryption algorithm according to the authentication key and the first count value. Key, and finally the first initial key is decomposed into the first key and the second key.
  • the first counter the first count value corresponding to the local counter of the first ECU
  • the first ECU when the first ECU receives the CAN frame sent by the manager, it extracts the first value corresponding to the i-th time period from the CAN frame. Then, the first ECU reads the first count value LC i corresponding to the i-th time period from the first counter.
  • the first initial key c is calculated by the AES128 encryption algorithm, and the calculation formula of the first initial key c is as follows:
  • LC i is less than 128 bits, it needs to be made up to 128 bits.
  • the first initial key is decomposed into the first key and the second key.
  • a key stream is generated; an exclusive OR operation is performed on the key stream and the data corresponding to the effective data payload to obtain encrypted data.
  • the value of the bit in the second key determine the position of the CRC in the data payload field; according to the position of the CRC in the data payload field, put all the CRC bits into the corresponding payload; put the encrypted data into The remaining load bits of the data load domain.
  • Figure 4 is a schematic diagram 1 of the principle of generating M * based on c 1.
  • the value of the 3rd, 5th, 9th, and 10th bits of c 1 is 1, so the 3rd and 5th bits of the data payload domain (payload),
  • the 9, 10 bits are the first 4 bits of crc, and so on, until all the CRC bits are put into the data load bits. Then put the bits of M into the remaining positions in sequence.
  • M* It is worth noting that
  • ⁇ 128-81 47.
  • c 1 has about 23 bits 1, which is enough to completely determine the position of the CRC in the data load domain.
  • the value of the bit in the second key can only determine the position of a part of the CRC bit in the data load field, then the finally determined CRC bit is used as the starting point, and the remaining CRC bit Put the subsequent load bits in sequence.
  • Figure 5 is a schematic diagram of the second principle of generating M * according to c 1. As shown in Figure 5, if the first digit value of the bit in the second key is 1, then according to the order of the data load field from right to left, according to the second The value of the bit in the key, put the CRC into the corresponding load bit in the data load field. If the value of the first digit of the bit in the second key is 0, then according to the order of the data load field from left to right, according to the value of the bit in the second key, put the CRC into the corresponding load bit in the data load field. .
  • c 1 is used to randomize the position of the CRC in the data load domain, thereby breaking the linearity of the CRC.
  • the manager broadcasts the first value to each electronic control unit according to the time period, so that when CAN messages are sent between each electronic control unit, the first value and the shared key can be used for encryption and authentication, thereby improving This improves the security of information transmission in the on-board system.
  • FIG. 6 is a second flowchart of a communication method provided by an embodiment of this application. Referring to FIG. 6, the method in this embodiment includes:
  • Step S201 Determine an authentication key according to the first value and the shared key.
  • Step S202 Obtain a third key through the authentication key and the first count value.
  • Step S203 Assemble the CAN frame through the first count value and the third key.
  • Step S204 Send a CAN frame to the second ECU via the CAN bus.
  • the first ECU and the second ECU are connected through a bus communication, and the first ECU can send a CAN message to the second ECU.
  • the first value is the value broadcast by the manager according to the time period
  • the shared key is the key shared by all ECUs in the vehicle.
  • the first key is used to encrypt the effective data payload
  • the second key is used to randomize the position of the CRC bit in the data payload field.
  • the authentication key may be generated through a block encryption algorithm according to the first value and the shared key.
  • the manager broadcasts the first value to all ECUs. Because each time period corresponds to a different time, the first value is also different, so there is no need to use a random number for the first value here.
  • the first value can also be sent in a CAN frame, and the length of the data field of a CAN frame is generally 64 bits.
  • the first value broadcast by the manager to all ECUs is similar in function to a time stamp, and its value is determined by the manager's own clock or counter.
  • the first value broadcast by the manager is GSN i
  • the shared key between the first ECU and the second ECU is K.
  • the calculation method of the authentication key K i is as follows:
  • K i AES128(K,GSNi
  • AES128 is used to generate K i , and its encryption efficiency is higher. Because GSNi
  • this embodiment takes ASE as an example for description, but does not limit the block encryption algorithm, and all existing encryption algorithms can be applied in this embodiment.
  • step S202 the first count value corresponding to the local counter of the first ECU (hereinafter referred to as the first counter) can be obtained first, and then the first initial key is generated according to the authentication key and the first count value;
  • the length of the authenticated data is tailored to the length of the first initial key to obtain the third key.
  • a key stream can be generated according to the third key; the encrypted data is obtained by performing an exclusive OR operation between the key stream and the data corresponding to the effective data payload.
  • LC i is placed in the local counter domain
  • vd is placed in the data load domain, and the assembled CAN frame is obtained.
  • the manager broadcasts the first value to each electronic control unit according to the time period, so that when CAN messages are sent between each electronic control unit, the first value and the shared key can be used for encryption and authentication, thereby improving This improves the security of information transmission in the on-board system.
  • FIG. 7 is the third flowchart of the communication method provided by the embodiment of this application. Referring to FIG. 7, the method of this embodiment includes:
  • Step S301 Determine an authentication key according to the first value and the shared key.
  • Step S302 Receive the CAN frame sent by the first ECU.
  • Step S303 Split the authentication key to obtain the fourth key and the fifth key.
  • Step S304 The CAN frame is authenticated through the fourth key and the fifth key.
  • the first ECU and the second ECU are connected through a bus communication, and the second ECU can receive the CAN message sent by the first ECU.
  • the first value is the value broadcast by the manager according to the time period
  • the shared key is a key shared by all ECUs in the vehicle. The first key is used to encrypt the effective data payload, and the second key is used to randomize the position of the CRC bit in the data payload field.
  • the authentication key may be generated through a block encryption algorithm according to the first value and the shared key.
  • the manager broadcasts the first value to all ECUs. Because each time period corresponds to a different time, the first value is also different, so there is no need to use a random number for the first value here.
  • the first value can also be sent in a CAN frame, and the length of the data field of a CAN frame is generally 64 bits.
  • the first value broadcast by the manager to all ECUs is similar in function to a time stamp, and its value is determined by the manager's own clock or counter.
  • the first value broadcast by the manager is GSN i
  • the shared key between the first ECU and the second ECU is K.
  • the calculation method of the authentication key K i is as follows:
  • K i AES128(K,GSNi
  • AES128 is used to generate K i , and its encryption efficiency is higher. Because GSNi
  • this embodiment takes ASE as an example for description, but does not limit the block encryption algorithm, and all existing encryption algorithms can be applied in this embodiment.
  • step S304 after receiving the CAN frame sent by the first ECU, the data load field of the CAN frame is read, and the data load field is decrypted by the fourth key to obtain intermediate data; the intermediate data is processed by the fifth key
  • the decryption process obtains the recovered effective data load and the recovered CRC; the recovered effective data load and the recovered CRC are verified through the CRC algorithm. If the verification fails, it is determined that the authentication has failed.
  • Padding). Decompose c* into two parts c* c* 1
  • the data payload field of the read CAN frame is payload.
  • the decrypted payload is Use the fifth key c* 1 . Recover M and CRC from the payload*. If the recovered M and CRC meet the CRC algorithm, the authentication is passed, otherwise the authentication fails.
  • the second count value corresponding to the second counter is first obtained; the second count value is compared with the first count value, if the second count value is If the count value is greater than the first count value, it is determined that the authentication has failed; where the first count value is the value corresponding to the first counter of the first ECU.
  • the value of the second counter of the second ECU is greater than the value of the first counter of the first ECU, it means that the time when the first ECU sends the CAN frame is inconsistent with the time when the second ECU receives the CAN frame, and authentication fails.
  • the manager broadcasts the first value to each electronic control unit according to the time period, so that when CAN messages are sent between each electronic control unit, the first value and the shared key can be used for encryption and authentication, thereby improving This improves the security of information transmission in the on-board system.
  • FIG. 8 is a fourth flowchart of a communication method provided by an embodiment of this application. Referring to FIG. 8, the method in this embodiment includes:
  • Step S401 Determine an authentication key according to the first value and the shared key.
  • Step S402 Receive the CAN frame sent by the first ECU.
  • Step S403 Obtain the sixth key through the authentication key and the second count value.
  • Step S404 Decompose the read data load field of the CAN frame to obtain the third key and the effective data load.
  • Step S405 The sixth key and the third key are compared, and if they are inconsistent, it is determined that the authentication has failed.
  • the first ECU and the second ECU are connected by bus communication, the first ECU can send a CAN message to the second ECU, and the second ECU authenticates the received CAN message.
  • the first value is the value broadcast by the manager according to the time period, and the shared key is a key shared by all ECUs in the vehicle.
  • the second initial key can be generated through the authentication key and the second count value; according to the data length required for authentication, the length of the second initial key is tailored to obtain the sixth key.
  • vd. Compare vd and vd*: if vd vd*, the authentication is successful, otherwise the authentication fails.
  • the manager broadcasts the first value to each electronic control unit according to the time period, so that when CAN messages are sent between each electronic control unit, the first value and the shared key can be used for encryption and authentication, thereby improving This improves the security of information transmission in the on-board system.
  • FIG. 9 is a first structural diagram of a first ECU provided by an embodiment of this application.
  • the first ECU in this embodiment includes: a processing module 21, a sending module 22, a storage module 23, and a receiving module 24;
  • the processing module 21 is used to determine the authentication key according to the first value and the shared key; split the authentication key to obtain the first key and the second key; and obtain the first key and the second key through the first key and the second key. Assemble the CAN frame; the first key is used to encrypt the effective data payload, and the second key is used to randomize the position of the CRC bit in the data payload field;
  • the sending module 22 is used to send CAN frames to the second ECU via the CAN bus; where the first value is a value broadcast by the manager according to the time period, and the shared key is a key shared by all ECUs in the vehicle.
  • the processing module 21 may be a processor, and the sending module 22 may be a transmitter.
  • the first ECU is communicatively connected with the second ECU through a bus. It should be noted that this embodiment does not limit the number of the first ECU and the second ECU, the number of the first ECU may be one or more, and the number of the second ECU may be one or more.
  • this embodiment can also be applied to information transmission between other devices forming a CAN network.
  • processing module 21 is specifically used for:
  • an authentication key is generated through a block encryption algorithm.
  • processing module 21 is specifically used for:
  • the first initial key is generated through the block encryption algorithm;
  • the first count value is the value corresponding to the first counter;
  • the first initial key is decomposed into a first key and a second key.
  • processing module 21 is specifically used for:
  • a key stream is generated
  • processing module 21 is specifically used for:
  • the value of the bit in the second key can only determine the position of part of the CRC bit in the data load field, then the finally determined CRC bit is used as the starting point, and the remaining CRC bits are sequentially placed in the subsequent The load bit.
  • processing module 21 is specifically used for:
  • the manager broadcasts the first value to each electronic control unit according to the time period, so that when CAN messages are sent between each electronic control unit, the first value and the shared key can be used for encryption and authentication, thereby improving This improves the security of information transmission in the on-board system.
  • the specific implementation process and implementation principle please refer to the related description in the embodiment shown in FIG. 3, which will not be repeated here.
  • FIG. 10 is a second structural diagram of the first ECU provided by an embodiment of the application.
  • the first ECU in this embodiment includes: a processing module 31 and a sending module 32;
  • the processing module 31 is configured to determine the authentication key according to the first value and the shared key; obtain the third key through the authentication key and the first count value; the first count value is the value corresponding to the first counter; A counter value and a third key are used to assemble the CAN frame; the third key is used to encrypt the payload of the effective data;
  • the sending module 32 is used to send a CAN frame to the second ECU via the CAN bus; where the first value is a value broadcast by the manager according to the time period, and the shared key is a key shared by all ECUs in the vehicle.
  • the processing module 31 may be a processor, and the sending module 32 may be a transmitter.
  • the first ECU is communicatively connected with the second ECU through a bus. It should be noted that this embodiment does not limit the number of the first ECU and the second ECU, the number of the first ECU may be one or more, and the number of the second ECU may be one or more.
  • this embodiment can also be applied to information transmission between other devices forming a CAN network.
  • the processing module 31 is specifically used for:
  • an authentication key is generated through a block encryption algorithm.
  • the processing module 31 is specifically used for:
  • the length of the first initial key is tailored to obtain the third key.
  • the processing module 31 is specifically used for:
  • the first count value is put into the first counter field of the CAN frame, and the encrypted data is put into the data load field to obtain the assembled CAN frame.
  • the manager broadcasts the first value to each electronic control unit according to the time period, so that when CAN messages are sent between each electronic control unit, the first value and the shared key can be used for encryption and authentication, thereby improving This improves the security of information transmission in the on-board system.
  • the specific implementation process and implementation principle please refer to the related description in the embodiment shown in FIG. 6, which will not be repeated here.
  • FIG. 11 is a first structural diagram of a second ECU provided by an embodiment of the application.
  • the second ECU in this embodiment includes: a processing module 41, a receiving module 42, a storage module 43, and a sending module 44;
  • the processing module 41 is configured to determine the authentication key according to the first value and the shared key
  • the receiving module 42 is used to receive the CAN frame sent by the first ECU;
  • the processing module 41 is configured to split the authentication key to obtain the fourth key and the fifth key; the fourth key is used to decrypt the effective data payload, and the fifth key is used to restore the effective data payload and restore the CRC;
  • the processing module 41 is configured to authenticate the CAN frame through the fourth key and the fifth key; where the first value is a value broadcast by the manager according to the time period, and the shared key is a key shared by all ECUs in the vehicle.
  • the processing module 41 may be a processor
  • the receiving module 42 may be a receiver
  • the first ECU is communicatively connected with the second ECU through a bus. It should be noted that this embodiment does not limit the number of the first ECU and the second ECU, the number of the first ECU may be one or more, and the number of the second ECU may be one or more.
  • this embodiment can also be applied to information transmission between other devices forming a CAN network.
  • the processing module 41 is specifically configured to: determine the authentication key according to the first value and the shared key, including:
  • an authentication key is generated through a block encryption algorithm.
  • the processing module 41 is specifically configured to: before the CAN frame is authenticated by the authentication key, it further includes:
  • the second count value is compared with the first value, and if the second count value is greater than the first count value, it is determined that the authentication has failed; where the first count value is the value corresponding to the first counter of the first ECU.
  • the processing module 41 is specifically configured to: authenticate the CAN frame through the fourth key and the fifth key, including:
  • the restored payload and the restored CRC are verified through the CRC algorithm. If the verification fails, it is determined that the authentication has failed.
  • the manager broadcasts the first value to each electronic control unit according to the time period, so that when CAN messages are sent between each electronic control unit, the first value and the shared key can be used for encryption and authentication, thereby improving This improves the security of information transmission in the on-board system.
  • the specific implementation process and implementation principle please refer to the related description in the embodiment shown in FIG. 7, which will not be repeated here.
  • FIG. 12 is a second structural diagram of a second ECU provided by an embodiment of this application.
  • the second ECU in this embodiment includes: a processing module 51 and a receiving module 52;
  • the processing module 51 is configured to determine the authentication key according to the first value and the shared key
  • the receiving module 52 is configured to receive the CAN frame sent by the first ECU;
  • the processing module 51 is configured to obtain the sixth key through the authentication key and the second count value; the second count value is the value corresponding to the second counter;
  • the processing module 51 is configured to decompose the data load field of the read CAN frame to obtain the third key and the effective data load;
  • the processing module 51 is configured to compare the sixth key and the third key, and if they are inconsistent, it is determined that the authentication has failed.
  • the processing module 51 is specifically used for:
  • the length of the second initial key is tailored to obtain the sixth key.
  • the manager broadcasts the first value to each electronic control unit according to the time period, so that when CAN messages are sent between each electronic control unit, the first value and the shared key can be used for encryption and authentication, thereby improving This improves the security of information transmission in the on-board system.
  • the specific implementation process and implementation principle please refer to the related description in the embodiment shown in FIG. 8, which will not be repeated here.
  • FIG. 13 is a schematic structural diagram of an electronic device provided by an embodiment of this application.
  • the electronic device of this embodiment includes a processor 61 and a transceiver 62, and the processor 61 is configured to execute instructions in a computer executable program code; When the processor 61 executes the instruction, the instruction causes the electronic device to execute the method in any one of FIGS. 3 and 6 to 8.
  • the manager broadcasts the first value to each electronic device according to the time period, so that when CAN messages are sent between each electronic control unit, the first value and the shared key can be used for encryption and authentication, thereby improving This improves the security of information transmission in the on-board system.
  • the specific implementation process and implementation principle please refer to related descriptions in the embodiments shown in FIG. 3 and FIG. 6 to FIG. 8, which will not be repeated here.
  • Fig. 14 is a schematic structural diagram of a communication system provided by an embodiment of the application.
  • the communication system of this embodiment includes: a first ECU 71 and a second ECU 72.
  • the first ECU 71 communicates with the second ECU 72 via the CAN bus 73 Communication connection.
  • the first ECU 71 executes the method shown in FIG. 3; the second ECU executes the method shown in FIG.
  • the first ECU 71 executes the method shown in FIG. 6; the second ECU executes the method shown in FIG. 8.
  • the manager broadcasts the first value to the first ECU and the second ECU according to the time period, so that when the first ECU sends a CAN message to the second ECU, the first value and the shared key can be used for encryption and
  • the authentication process improves the security of information transmission in the vehicle system.
  • the embodiment of the present application provides a computer-readable storage medium, and the computer-readable storage medium stores instructions.
  • the computer executes the method performed by the terminal device in the above-mentioned embodiment of the present application.
  • the embodiment of the present application provides a computer-readable storage medium, and the computer-readable storage medium stores instructions.
  • the computer executes the method performed by the network device in the foregoing embodiment of the present application.
  • the disclosed device and method may be implemented in other ways.
  • the device embodiments described above are merely illustrative, for example, the division of units is only a logical function division, and there may be other divisions in actual implementation, for example, multiple units or components can be combined or integrated. To another system, or some features can be ignored, or not implemented.
  • the displayed or discussed mutual coupling or direct coupling or communication connection may be indirect coupling or communication connection through some interfaces, devices or units, and may be in electrical, mechanical or other forms.
  • the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the objectives of the solutions of the embodiments.
  • the functional units in the various embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units may be integrated into one unit.
  • the above-mentioned integrated unit can be realized in the form of hardware, or in the form of hardware plus software functional unit.
  • modules in the embodiments of the present application is illustrative, and is only a logical function division, and there may be other division methods in actual implementation.
  • the functional modules in the embodiments of the present application may be integrated into one processing module, or each module may exist alone physically, or two or more modules may be integrated into one module.
  • the above-mentioned integrated modules can be implemented in the form of hardware or software functional modules.
  • the integrated module is implemented in the form of a software function module and sold or used as an independent product, it can be stored in a computer readable storage medium.
  • the technical solution of the present application essentially or the part that contributes to the existing technology or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium , Including several instructions to make a computer device (which may be a personal computer, a server, or a network device, etc.) or a processor execute all or part of the steps of the methods in the various embodiments of the present application.
  • the aforementioned storage media include: U disk, mobile hard disk, read-only memory (Read-Only Memory, ROM), random access memory (Random Access Memory, RAM), magnetic disks or optical disks and other media that can store program codes. .
  • the above embodiments it may be implemented in whole or in part by software, hardware, firmware, or any combination thereof.
  • software it can be implemented in the form of a computer program product in whole or in part.
  • the computer program product includes one or more computer instructions.
  • the computer program instructions When the computer program instructions are loaded and executed on the computer, the processes or functions according to the embodiments of the present application are generated in whole or in part.
  • the computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices.
  • Computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium.
  • computer instructions may be transmitted from a website, computer, server, or data center through a cable (such as Coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (such as infrared, wireless, microwave, etc.) to transmit to another website site, computer, server or data center.
  • the computer-readable storage medium may be any available medium that can be accessed by a computer or a data storage device such as a server or a data center integrated with one or more available media.
  • the usable medium may be a magnetic medium (for example, a floppy disk, a hard disk, and a magnetic tape), an optical medium (for example, a DVD), or a semiconductor medium (for example, a solid state disk (SSD)).

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer Hardware Design (AREA)
  • Computing Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Small-Scale Networks (AREA)
  • Mobile Radio Communication Systems (AREA)

Abstract

本申请公开一种通信方法和电子设备,以提高信息传输的安全性,属于车载通信技术领域。所述方法包括:根据第一数值和共享密钥,确定认证密钥;对所述认证密钥进行拆分,得到第一密钥和第二密钥;通过所述第一密钥和所述第二密钥来组装CAN帧;所述第一密钥用于加密有效数据载荷,所述第二密钥用于随机化CRC比特位在数据负载域里的位置;通过CAN总线向第二ECU发送所述CAN帧;其中,所述第一数值为管理器根据时间段广播的数值,所述共享密钥为车载中所有ECU共用的密钥。用于对车载系统中电子控制单元ECU间发送的CAN消息进行认证。

Description

通信方法和电子设备
本申请要求于2019年12月31日提交中国专利局、申请号为201911417603.0、申请名称为“通信方法和电子设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请实施例涉及车载通信技术领域,尤其涉及一种通信方法和电子设备。
背景技术
随着社会的发展,汽车的使用量也越来越大。在汽车的车载系统中,配置有多个称为电子控制单元(ECU:Electronic Control Unit)的装置。而连接这些ECU的网络称为车载网络。目前最常见额车载网络一般满足控制器局域网络(Controller Area Network,CAN)的相关协议。
现有技术中,车载系统内的ECU通过固定的密钥对CAN消息进行认证。例如CANAuth使用HMAC对消息进行认证。这种认证方式,需要ECU从一个固定密钥,计数器和从CAN+通道发送的随机数推衍出认证密钥。
但是,上述方式不能直接用于标准的CAN网络中,且固定密钥容易被破解,从而导致车载系统被攻击。
发明内容
本申请实施例提供一种通信方法和电子设备,提高了信息传输的安全性。
第一方面,本申请实施例提供一种通信方法,包括:
根据第一数值和共享密钥,确定认证密钥;
对所述认证密钥进行拆分,得到第一密钥和第二密钥;
通过所述第一密钥和所述第二密钥来组装CAN帧;所述第一密钥用于加密有效数据载荷,所述第二密钥用于随机化CRC比特位在数据负载域里的位置;
通过CAN总线向第二ECU发送所述CAN帧;其中,所述第一数值为管理器根据时间段广播的数值,所述共享密钥为车载中所有ECU共用的密钥。
在一种可能的设计中,所述根据第一数值和共享密钥,确定认证密钥,包括:
根据所述第一数值和所述共享密钥,通过分组加密算法,生成所述认证密钥。
在一种可能的设计中,所述对所述认证密钥进行拆分,得到第一密钥和第二密钥,包括:
根据所述认证密钥和第一计数值,通过分组加密算法,生成第一初始密钥;所述第一计数值是第一计数器对应的数值;
将所述第一初始密钥分解为所述第一密钥和所述第二密钥。
在一种可能的设计中,所述通过所述第一密钥和所述第二密钥来组装CAN帧,包括:
根据所述第一密钥,生成密钥流;
通过所述密钥流与所述有效数据载荷对应的数据进行异或运算,得到加密后的数据;
根据所述第二密钥中比特位的值,确定CRC在数据负载域里的位置;
根据所述CRC在数据负载域里的位置,将所有CRC的比特放入对应的负载位;
将所述加密后的数据放入所述数据负载域剩余的负载位,得到组装的CAN帧。
在一种可能的设计中,还包括:
若所述第二密钥中比特位的值只能确定部分CRC的比特位在数据负载域里的位置,则以最后确定的CRC的比特位为起始点,将剩余部分CRC的比特位依次放入后续的负载位。
在一种可能的设计中,所述根据所述第二密钥中比特位的值,确定CRC在数据负载域里的位置,包括:
若所述第二密钥中比特位的首位数值为1,则按照数据负载域从右向左的顺序,依次根据所述第二密钥中比特位的值,将CRC放入数据负载域里对应的负载位;
若所述第二密钥中比特位的首位数值为0,则按照数据负载域从左向右的顺序,依次根据所述第二密钥中比特位的值,将CRC放入数据负载域里对应的负载位。
第二方面,本申请实施例提供一种通信方法,包括:
根据第一数值和共享密钥,确定认证密钥;
通过所述认证密钥和第一计数值,得到第三密钥;所述第一计数值是第一计数器对应的数值;
通过所述第一计数值和所述第三密钥来组装CAN帧;所述第三密钥用于加密有效数据载荷;
通过CAN总线向第二ECU发送所述CAN帧;其中,所述第一数值为管理器根据时间段广播的数值,所述共享密钥为车载中所有ECU共用的密钥。
在一种可能的设计中,所述根据第一数值和共享密钥,确定认证密钥,包括:
根据所述第一数值和所述共享密钥,通过分组加密算法,生成所述认证密钥。
在一种可能的设计中,通过所述认证密钥和第一计数值,得到第三密钥,包括:
通过所述认证密钥和所述第一计数值,生成第一初始密钥;
根据所需认证的数据长度,对所述第一初始密钥的长度进行裁剪,得到第三密钥。
在一种可能的设计中,所述通过所述第一计数值和所述第三密钥来组装CAN帧,包括:
根据所述第三密钥,生成密钥流;
通过所述密钥流与所述有效数据载荷对应的数据进行异或运算,得到加密后的数据;
所述第一计数值放入CAN帧的第一计数器域,以及将所述加密后的数据放入数据负载域,得到组装的CAN帧。
第三方面,本申请实施例提供一种通信方法,包括:
根据第一数值和共享密钥,确定认证密钥;
接收第一ECU发送的CAN帧;
对所述认证密钥进行拆分,得到第四密钥和第五密钥;所述第四密钥用于解密有效数据载荷,所述第五密钥用于恢复有效数据载荷和恢复CRC;
通过所述第四密钥和所述第五密钥对所述CAN帧进行认证;其中,所述第一数值为管理器根据时间段广播的数值,所述共享密钥为车载中所有ECU共用的密钥。
在一种可能的设计中,所述根据第一数值和共享密钥,确定认证密钥,包括:
根据所述第一数值和所述共享密钥,通过分组加密算法,生成所述认证密钥。
在一种可能的设计中,在所述通过所述认证密钥对所述CAN帧进行认证之前,还包括:
获取第二计数器对应的第二计数值;
将所述第二计数值与第一计数值进行比较,若所述第二计数值大于所述第一计数值,则确定认证失败;其中,所述第一计数值是所述第一ECU的第一计数器对应的数值。
在一种可能的设计中,所述通过所述第四密钥和所述第五密钥对所述CAN帧进行认证,包括:
读取所述CAN帧的数据负载域,并通过所述第四密钥解密所述数据负载域,得到中间数据;
通过所述第五密钥对所述中间数据进行解密处理,得到恢复的有效数据载荷和恢复的CRC;
通过CRC算法对所述恢复的有效数据载荷和所述恢复的CRC进行验证,若验证不通过,则确定认证失败。
第四方面,本申请实施例提供一种通信方法,包括:
根据第一数值和共享密钥,确定认证密钥;
接收第一ECU发送的CAN帧;
通过所述认证密钥和第二计数值,得到第六密钥;所述第二计数值是第二计数器对应的数值;
对读取到的CAN帧的数据负载域进行分解,得到第三密钥和有效数据载荷;
将所述第六密钥和所述第三密钥进行比较,若不一致,则确定认证失败。
在一种可能的设计中,通过所述认证密钥和第二计数值,得到第六密钥,包括:
通过所述认证密钥和所述第二计数值,生成第二初始密钥;
根据所需认证的数据长度,对所述第二初始密钥的长度进行裁剪,得到第六密钥。
第五方面,本申请实施例提供一种通信方法,应用在包含第一ECU和第二ECU的通信系统中,所述方法包括:
第一ECU根据第一数值和共享密钥,确定认证密钥;
对所述认证密钥进行拆分,得到第一密钥和第二密钥;
通过所述第一密钥和所述第二密钥来组装CAN帧;所述第一密钥用于加密有效数据载荷,所述第二密钥用于随机化CRC比特位在数据负载域里的位置;
通过CAN总线向第二ECU发送所述CAN帧;其中,所述第一数值为管理器根据时间段广播的数值,所述共享密钥为车载中所有ECU共用的密钥;
第二ECU接收第一ECU发送的CAN帧;对所述认证密钥进行拆分,得到第四密钥和第五密钥;所述第四密钥用于解密有效数据载荷,所述第五密钥用于恢复有效数据载荷和恢复CRC;通过所述第四密钥和所述第五密钥对所述CAN帧进行认证。
在一种可能的设计中,所述根据第一数值和共享密钥,确定认证密钥,包括:
根据所述第一数值和所述共享密钥,通过分组加密算法,生成所述认证密钥。
在一种可能的设计中,所述对所述认证密钥进行拆分,得到第一密钥和第二密钥,包括:
根据所述认证密钥和第一计数值,通过分组加密算法,生成第一初始密钥;所述第一计数值是第一计数器对应的数值;
将所述第一初始密钥分解为所述第一密钥和所述第二密钥。
在一种可能的设计中,所述通过所述第一密钥和所述第二密钥来组装CAN帧,包括:
根据所述第一密钥,生成密钥流;
通过所述密钥流与所述有效数据载荷对应的数据进行异或运算,得到加密后的数据;
根据所述第二密钥中比特位的值,确定CRC在数据负载域里的位置;
根据所述CRC在数据负载域里的位置,将所有CRC的比特放入对应的负载位;
将所述加密后的数据放入所述数据负载域剩余的负载位,得到组装的CAN帧。
在一种可能的设计中,若所述第二密钥中比特位的值只能确定部分CRC的比特位在数据负载域里的位置,则以最后确定的CRC的比特位为起始点,将剩余部分CRC的比特位依次放入后续的负载位。
在一种可能的设计中,所述根据所述第二密钥中比特位的值,确定CRC在数据负载域里的位置,包括:
若所述第二密钥中比特位的首位数值为1,则按照数据负载域从右向左的顺序,依次根据所述第二密钥中比特位的值,将CRC放入数据负载域里对应的负载位;
若所述第二密钥中比特位的首位数值为0,则按照数据负载域从左向右的顺序,依次根据所述第二密钥中比特位的值,将CRC放入数据负载域里对应的负载位。
在一种可能的设计中,在所述通过所述认证密钥对所述CAN帧进行认证之前,还包括:
获取第二计数器对应的第二计数值;
将所述第二计数值与第一计数值进行比较,若所述第二计数值大于所述第一计数值,则确定认证失败;其中,所述第一计数值是所述第一ECU的第一计数器对应的数值。
在一种可能的设计中,所述通过所述第四密钥和所述第五密钥对所述CAN帧进行认证,包括:
读取所述CAN帧的数据负载域,并通过所述第四密钥解密所述数据负载域,得到中间数据;
通过所述第五密钥对所述中间数据进行解密处理,得到恢复的有效数据载荷和恢复的CRC;
通过CRC算法对所述恢复的有效数据载荷和所述恢复的CRC进行验证,若验证不通过,则确定认证失败。
第六方面,本申请实施例提供一种通信方法,应用在包含第一ECU和第二ECU的通信系统中,所述方法包括:
第一ECU根据第一数值和共享密钥,确定认证密钥;
通过所述认证密钥和第一计数值,得到第三密钥;所述第一计数值是第一计数器对应的数值;
通过所述第一计数值和所述第三密钥来组装CAN帧;所述第三密钥用于加密有效数据载荷;
通过CAN总线向第二ECU发送所述CAN帧;其中,所述第一数值为管理器根据时间段广播的数值,所述共享密钥为车载中所有ECU共用的密钥;
第二ECU接收第一ECU发送的CAN帧;
通过所述认证密钥和第二计数值,得到第六密钥;所述第二计数值是第二计数器对应的数值;
对读取到的CAN帧的数据负载域进行分解,得到第三密钥和有效数据载荷;
将所述第六密钥和所述第三密钥进行比较,若不一致,则确定认证失败。
在一种可能的设计中,所述根据第一数值和共享密钥,确定认证密钥,包括:
根据所述第一数值和所述共享密钥,通过分组加密算法,生成所述认证密钥。
在一种可能的设计中,通过所述认证密钥和第一计数值,得到第三密钥,包括:
通过所述认证密钥和所述第一计数值,生成第一初始密钥;
根据所需认证的数据长度,对所述第一初始密钥的长度进行裁剪,得到第三密钥。
在一种可能的设计中,所述通过所述第一计数值和所述第三密钥来组装CAN帧,包括:
根据所述第三密钥,生成密钥流;
通过所述密钥流与所述有效数据载荷对应的数据进行异或运算,得到加密后的数据;
将所述第一计数值放入CAN帧的第一计数器域,以及将所述加密后的数据放入数据负载域,得到组装的CAN帧。
在一种可能的设计中,通过所述认证密钥和第二计数值,得到第六密钥,包括:
通过所述认证密钥和所述第二计数值,生成第二初始密钥;
根据所需认证的数据长度,对所述第二初始密钥的长度进行裁剪,得到第六密钥。
第七方面,本申请实施例提供一种第一ECU,包括:
处理模块,用于根据第一数值和共享密钥,确定认证密钥;对所述认证密钥进行拆分,得到第一密钥和第二密钥;通过所述第一密钥和所述第二密钥来组装CAN帧;所述第一密钥用于加密有效数据载荷,所述第二密钥用于随机化CRC比特位在数据负载域里的位置;
发送模块,用于通过CAN总线向第二ECU发送所述CAN帧;其中,所述第一数值为管理器根据时间段广播的数值,所述共享密钥为车载中所有ECU共用的密钥。
在一种可能的设计中,所述处理模块,具体用于:
根据所述第一数值和所述共享密钥,通过分组加密算法,生成所述认证密钥。
在一种可能的设计中,所述处理模块,具体用于:
根据所述认证密钥和第一计数值,通过分组加密算法,生成第一初始密钥;所述第一计数值是第一计数器对应的数值;
将所述第一初始密钥分解为所述第一密钥和所述第二密钥。
在一种可能的设计中,所述处理模块,具体用于:
根据所述第一密钥,生成密钥流;
通过所述密钥流与所述有效数据载荷对应的数据进行异或运算,得到加密后的数据;
根据所述第二密钥中比特位的值,确定CRC在数据负载域里的位置;
根据所述CRC在数据负载域里的位置,将所有CRC的比特放入对应的负载位;
将所述加密后的数据放入所述数据负载域剩余的负载位,得到组装的CAN帧。
在一种可能的设计中,所述处理模块,具体用于:
若所述第二密钥中比特位的值只能确定部分CRC的比特位在数据负载域里的位置,则以最后确定的CRC的比特位为起始点,将剩余部分CRC的比特位依次放入后续的负载位。
在一种可能的设计中,所述处理模块,具体用于:
若所述第二密钥中比特位的首位数值为1,则按照数据负载域从右向左的顺序,依次根据所述第二密钥中比特位的值,将CRC放入数据负载域里对应的负载位;
若所述第二密钥中比特位的首位数值为0,则按照数据负载域从左向右的顺序,依次根据所述第二密钥中比特位的值,将CRC放入数据负载域里对应的负载位。
第八方面,本申请实施例提供一种第一ECU,包括:
处理模块,用于根据第一数值和共享密钥,确定认证密钥;通过所述认证密钥和第一计数值,得到第三密钥;所述第一计数值是第一计数器对应的数值;通过所述第一计数值和所述第三密钥来组装CAN帧;所述第三密钥用于加密有效数据载荷;
发送模块,用于通过CAN总线向第二ECU发送所述CAN帧;其中,所述第一数值为管理器根据时间段广播的数值,所述共享密钥为车载中所有ECU共用的密钥。
在一种可能的设计中,所述处理模块,具体用于:
根据所述第一数值和所述共享密钥,通过分组加密算法,生成所述认证密钥。
在一种可能的设计中,所述处理模块,具体用于:
通过所述认证密钥和所述第一计数值,生成第一初始密钥;
根据所需认证的数据长度,对所述第一初始密钥的长度进行裁剪,得到第三密钥。
在一种可能的设计中,所述处理模块,具体用于:
根据所述第三密钥,生成密钥流;
通过所述密钥流与所述有效数据载荷对应的数据进行异或运算,得到加密后的数据;
所述第一计数值放入CAN帧的第一计数器域,以及将所述加密后的数据放入数据负载域,得到组装的CAN帧。
第九方面,本申请实施例提供一种第二ECU,包括:
处理模块,用于根据第一数值和共享密钥,确定认证密钥;
接收模块,用于接收第一ECU发送的CAN帧;
处理模块,用于对所述认证密钥进行拆分,得到第四密钥和第五密钥;所述第四密钥用于解密有效数据载荷,所述第五密钥用于恢复有效数据载荷和恢复CRC;
处理模块,用于通过所述第四密钥和所述第五密钥对所述CAN帧进行认证;其中,所述第一数值为管理器根据时间段广播的数值,所述共享密钥为车载中所有ECU共用的密钥。
在一种可能的设计中,所述处理模块,具体用于:所述根据第一数值和共享密钥,确定认证密钥,包括:
根据所述第一数值和所述共享密钥,通过分组加密算法,生成所述认证密钥。
在一种可能的设计中,所述处理模块,具体用于:在所述通过所述认证密钥对所述CAN帧进行认证之前,还包括:
获取第二计数器对应的第二计数值;
将所述第二计数值与第一数值进行比较,若所述第二计数值大于所述第一计数值,则确定认证失败;其中,所述第一计数值是所述第一ECU的第一计数器对应的数值。
在一种可能的设计中,所述处理模块,具体用于:所述通过所述第四密钥和所述第五密钥对所述CAN帧进行认证,包括:
读取所述CAN帧的数据负载域,并通过所述第四密钥解密所述数据负载域,得到中间数据;
通过所述第五密钥对所述中间数据进行解密处理,得到恢复的有效数据载荷和恢复的CRC;
通过CRC算法对所述恢复的有效数据载荷和所述恢复的CRC进行验证,若验证不通过,则确定认证失败。
第十方面,本申请实施例提供一种第二ECU,包括:
处理模块,用于根据第一数值和共享密钥,确定认证密钥;
接收模块,用于接收第一ECU发送的CAN帧;
处理模块,用于通过所述认证密钥和第二计数值,得到第六密钥;所述第二计数值是第二计数器对应的数值;
处理模块,用于对读取到的CAN帧的数据负载域进行分解,得到第三密钥和有效数据载荷;
处理模块,用于将所述第六密钥和所述第三密钥进行比较,若不一致,则确定认证失败。
在一种可能的设计中,所述处理模块,具体用于:
通过所述认证密钥和所述第二计数值,生成第二初始密钥;
根据所需认证的数据长度,对所述第二初始密钥的长度进行裁剪,得到第六密钥。
第十一方面,本申请实施例提供一种电子设备包括:处理器和收发器,所述处理器用于执行计算机可执行程序代码中的指令;当所述处理器执行所述指令时,所述指令使所述电子设备执行第一方面中任一项所述的方法。
第十二方面,本申请实施例提供一种电子设备包括:处理器和收发器,所述处理器用于执行计算机可执行程序代码中的指令;当所述处理器执行所述指令时,所述指令使所述电子设备执行第二方面中任一项所述的方法。
第十三方面,本申请实施例提供一种电子设备包括:处理器和收发器,所述处理器用于执行计算机可执行程序代码中的指令;当所述处理器执行所述指令时,所述指令使所述电子设备执行第三方面中任一项所述的方法。
第十四方面,本申请实施例提供一种电子设备包括:处理器和收发器,所述处理器用于执行计算机可执行程序代码中的指令;当所述处理器执行所述指令时,所述指令使所述电子设备执行第四方面中任一项所述的方法。
第十五方面,本申请实施例提供一种通信系统,包括第一ECU和第二ECU,所述通信系统用于执行第五方面中任一项所述的方法。
第十六方面,本申请实施例提供一种通信系统,包括第一ECU和第二ECU,所述通信系统用于执行如第六方面中任一项所述的方法。
第十七方面,本申请实施例提供一种芯片,包括:存储器和处理器,存储器用于存储程序指令,处理器用于调用存储器中的程序指令执行第一方面或第二方面本申请实施例所述的通信方法。
第十八方面,本申请实施例提供一种芯片,包括:存储器和处理器,存储器用于存储程序指令,处理器用于调用存储器中的程序指令执行第三方面或第四方面本申请实施例所述的通信方法。
第十九方面,本申请实施例提供一种可读存储介质,所述可读存储介质上存储有计算机程序;所述计算机程序在被执行时,实现第一方面或第二方面本申请实施例所述的通信方法。
第二十方面,本申请实施例提供一种可读存储介质,所述可读存储介质上存储有计算机程序;所述计算机程序在被执行时,实现第三方面或第四方面本申请实施例所述的通信方法。
第二十一方面,本申请实施例提供一种程序产品,所述程序产品包括计算机程序,所述计算机程序存储在可读存储介质中,通信装置的至少一个处理器可以从所述可读存储介质读取所述计算机程序,所述至少一个处理器执行所述计算机程序使得通信装置实施第一方面或第二方面本申请实施例任一所述的通信方法。
第二十二方面,本申请实施例提供一种程序产品,所述程序产品包括计算机程序,所述计算机程序存储在可读存储介质中,通信装置的至少一个处理器可以从所述可读存储介质读取所述计算机程序,所述至少一个处理器执行所述计算机程序使得通信装置实施第三方面或第四方面本申请实施例任一所述的通信方法。
本申请中,通过管理器向各个电子控制单元按照时间段广播第一数值,以使得各个电子控制单元之间发送CAN消息时,可以利用第一数值和共享密钥进行加密和认证处理,从而提高了车载系统信息传输的安全性。
附图说明
图1为本申请实施例提供的通信系统的示意图;
图2为电子控制单元的结构示意图;
图3为本申请实施例提供的通信的方法的流程图一;
图4为根据c 1生成M *的原理示意图一;
图5为根据c 1生成M *的原理示意图二;
图6为本申请实施例提供的通信的方法的流程图二;
图7为本申请实施例提供的通信的方法的流程图三;
图8为本申请实施例提供的通信的方法的流程图四;
图9为本申请实施例提供的一种第一ECU的结构示意图一;
图10为本申请实施例提供的一种第一ECU的结构示意图二;
图11为本申请实施例提供的一种第二ECU的结构示意图一;
图12为本申请实施例提供的一种第二ECU的结构示意图二;
图13为本申请实施例提供的电子设备的结构示意图;
图14为本申请实施例提供的通信系统的结构示意图。
具体实施方式
图1为本申请实施例提供的通信系统的示意图,如图1所示,通信系统10包括电子控制单元11、管理器12,以及连接电子控制单元11和管理器12的总线13。
图2为电子控制单元的结构示意图,如图2所示,电子控制单元11包括:微控制器1101、CAN控制器1102、收发器1103、存储器1104,存储器1104中存储有计算机程序,微控制器1101从存储器1104中加载计算程序,执行相应的程序流程之后生成控制指令,并将控制指令发送给CAN控制器1102,以使的CAN控制器1102通过与总线13通信连接的收发器1103接收或者发送CAN消息。
以汽车为例,车内的多个电子控制单元通过总线组成CAN网络,任一个电子控制单元均可以通过总线向其他的电子控制单元发送CAN消息。在实际应用中,如果不对电子控制单元之间传输的CAN消息进行加密或认证处理,则车载系统容易受到网络攻击,攻击者或者被攻破的电子控制单元可以自由地发送CAN消息,从而严重威胁车载系统的安全。
具体地,CAN消息是以CAN帧的形式在总线上进行传输,CAN帧一般采用CAN2.0A标准帧、CAN2.0B标准帧。CAN帧包括ID域、CRC域、DATA域,其中,ID域用于区分CAN帧,CRC域用于装载数据的CRC码,DATA域用于装载数据。其中,CRC码用于查验数据传输中的错误,但是其不具备密钥学功能,因此,对CAN消息进行认证所产生的额外信息需要由DATA域来承担。例如,现有技术中,车载系统内的ECU通过固定的密钥对CAN消息进行认证。例如CANAuth使用HMAC对消息进行认证。这种认证方式,需要ECU从一个固定密钥,计数器和从CAN+通道发送的随机数推衍出认证密钥。虽然可以通过DATA域来进行CAN消息的加密,但是这种加密方式会增加额外的负载,且固定密钥容易被破解,从而导致车载系统被攻击。
针对现有技术中存在的问题,本申请实施例提供的通信方法,旨在实现在不增加额外负载的前提下,对CAN消息进行加密和认证,从而提高了车载系统信息传输的安全性。
本实施例的效果是对CAN帧同时进行加密和认证。对CAN消息的保护(认证或加密)来说,一个最基本的安全需求就是防止重放攻击。针对重放攻击,可以使用计数器,即假设发送ECU(发送者)和接受ECU(接收者)各自维护一个同步的计数器(为了便于同步和对CAN消息的验证,计数器值通常需随CAN消息一起发送)。由于CAN帧的数据域长度有限,因此计数器不能很大。因此,可以将时间分成时间段(每一时间段为一个session),通过管理器(如gateway)在每个时间段的起始时,向所有ECU广播一个不同的数值(Global Sessional Number,GSN)。ECU可以通过该数值和共享密钥生成用于加密和认证CAN消息的认证密钥。这种加密和认证方式可以实现在不增加额外负载的前提下,对CAN消息进行加密和认证,从而提高了车载系统信息传输的安全性。
下面采用具体的实施例对本申请的通信的方法进行详细说明,需要说明的是,下面几个具体实施例可以相互结合,对于相同或相似的内容,在不同的实施例中不再进行重复说 明。
图3为本申请实施例提供的通信的方法的流程图一,参见图3,本实施例的方法包括:
步骤S101、根据第一数值和共享密钥,确定认证密钥。
步骤S102、对认证密钥进行拆分,得到第一密钥和第二密钥。
步骤S103、通过第一密钥和第二密钥来组装CAN帧。
步骤S104、通过CAN总线向第二ECU发送CAN帧。
本实施例中,第一ECU和第二ECU通过总线通信连接,第一ECU可以向第二ECU发送CAN消息。其中,第一数值为管理器根据时间段广播的数值,共享密钥为车载中所有ECU共用的密钥。第一密钥用于加密有效数据载荷,第二密钥用于随机化CRC比特位在数据负载域里的位置。
示例性的,可以根据第一数值和共享密钥,通过分组加密算法,生成认证密钥。在每个时间段的起始时刻,管理器向所有ECU广播第一数值,因为每个时间段对应的时间不同,因此,第一数值也不同,因此这里的第一数值无需使用随机数。第一数值也可以是通过CAN帧的方式发送,一个CAN帧的数据域的长度一般为64比特。
具体地,管理器向所有ECU广播的第一数值,在功能上类似于一个时间戳,其数值由管理器自身的时钟或者计数器决定。假设在第i个时间段,管理器广播的第一数值为GSN i,,第一ECU和第二ECU之间的共享密钥为K。示例性的,以ASE加密算法为例,假设共享密钥的数据长度为128比特,则认证密钥K i的计算方式如下:
K i=AES128(K,GSNi||Padding)
本实施例中,使用AES128生成K i,其加密效率更高。因为GSNi||Padding是定长且是单分组,因此使用分组加密作为KDF是安全的。由于第一ECU和第二ECU均不直接使用共享密钥进行CAN消息的加密,可以提高CAN消息被破解的难度,保证信息传输的安全。
需要说明的是,本实施例以ASE为例进行说明,但是不限定分组加密算法,现有的加密算法均可以应用在本实施例中。
示例性的,本实施例中可以通过认证密钥进行CAN消息的加密和认证,因此CRC域的作用不是必须的,可以将CAN帧中原有的CRC域和原有的DATA域合并,作为新的数据域。CRC域的长度为15比特,DATA域的长度为64,则合并的数据域长度为81比特。
本实施例中,为了防止重放攻击,第一ECU和第二ECU需各自维护一个同步的计数器,叫本地计数器(相对于地,由管理器生成的GSN可以看作是全局计数器)。在每个时间段的起始时刻,第一ECU和第二ECU在计算认证密钥时,同时重置本地计数器为0,重新计数。
示例性的,为了便于CAN帧认证及发送者/接收者同步本地计算器,本地计数器值最好携带于CAN帧内。因此,可以将DATA域(数据域)为本地计数器域和数据负载域。如果本地计数器域的长度是11比特,那么数据负载域的长度可能是70比特或是53比特。
在步骤S102中,可以首先获取第一ECU的本地计数器(后续称为第一计数器)对应的第一计数值,然后根据认证密钥和第一计数值,通过分组加密算法,生成第一初始密钥,最后将第一初始密钥分解为第一密钥和第二密钥。
示例性的,当第一ECU接收管理器发送的CAN帧,从该CAN帧中提取出第i时间 段对应的第一数值。然后,第一ECU从第一计数器中读取出第i时间段对应的第一计数值LC i。通过AES128加密算法计算出第一初始密钥c,第一初始密钥c的计算公式如下:
c:=AES128(Ki,LCi||Padding)。
若,LC i不足128比特,需补足至128比特。
示例性的,将第一初始密钥分解为第一密钥和第二密钥。根据第一密钥,生成密钥流;通过密钥流与有效数据载荷对应的数据进行异或运算,得到加密后的数据。根据第二密钥中比特位的值,确定CRC在数据负载域里的位置;根据CRC在数据负载域里的位置,将所有CRC的比特放入对应的负载位;将加密后的数据放入数据负载域剩余的负载位。
具体地,分解第一初始密钥c为两部分c=c 1||c 0,s.t.,|c 0|=|M|+|CRC|,其中:M为本CAN帧的有效数据载荷,|M|为M的长度,|CRC|=15。c 0为第一密钥,c 1为第二密钥。c 0将作为密钥流进行数据加密,而c 1将用于随机化CRC比特位在数据负载域里的位置。将LC i值置于本地计数器域,根据c 1中的比特1(或0)来决定crc的比特在数据负载域的位置,得到M *
图4为根据c 1生成M *的原理示意图一,如图4所示,c 1的第3,5,9,10位的数值为1,因此数据负载域(payload)的第3,5,9,10位依次为crc的前4位,以此类推,直到将所有CRC的比特放入数据负载位。接着将M的比特依次放入其余的位置。结果为M*。值得注意的是,|M|小于64,因此|c1|≥128-81=47。理论上,c 1有大概23个比特1,足够完全决定CRC在数据负载域的位置。
示例性的,若第二密钥中比特位的值只能确定部分CRC的比特位在数据负载域里的位置,则以最后确定的CRC的比特位为起始点,将剩余部分CRC的比特位依次放入后续的负载位。
图5为根据c 1生成M *的原理示意图二,如图5所示,若第二密钥中比特位的首位数值为1,则按照数据负载域从右向左的顺序,依次根据第二密钥中比特位的值,将CRC放入数据负载域里对应的负载位。若第二密钥中比特位的首位数值为0,则按照数据负载域从左向右的顺序,依次根据第二密钥中比特位的值,将CRC放入数据负载域里对应的负载位。
本实施例中,利用c 1来随机化CRC在数据负载域的位置,从而打破CRC的线性。
进一步地,将
Figure PCTCN2020139121-appb-000001
置于数据负载域,
Figure PCTCN2020139121-appb-000002
表示异或操作。即用c 0加密M*,并将密钥放置于数据负载域。
本实施例,通过管理器向各个电子控制单元按照时间段广播第一数值,以使得各个电子控制单元之间发送CAN消息时,可以利用第一数值和共享密钥进行加密和认证处理,从而提高了车载系统信息传输的安全性。
图6为本申请实施例提供的通信的方法的流程图二,参见图6,本实施例的方法包括:
步骤S201、根据第一数值和共享密钥,确定认证密钥。
步骤S202、通过认证密钥和第一计数值,得到第三密钥。
步骤S203、通过第一计数值和第三密钥来组装CAN帧。
步骤S204、通过CAN总线向第二ECU发送CAN帧。
本实施例中,第一ECU和第二ECU通过总线通信连接,第一ECU可以向第二ECU发送CAN消息。其中,第一数值为管理器根据时间段广播的数值,共享密钥为车载中所 有ECU共用的密钥。第一密钥用于加密有效数据载荷,第二密钥用于随机化CRC比特位在数据负载域里的位置。
示例性的,可以根据第一数值和共享密钥,通过分组加密算法,生成认证密钥。在每个时间段的起始时刻,管理器向所有ECU广播第一数值,因为每个时间段对应的时间不同,因此,第一数值也不同,因此这里的第一数值无需使用随机数。第一数值也可以是通过CAN帧的方式发送,一个CAN帧的数据域的长度一般为64比特。
具体地,管理器向所有ECU广播的第一数值,在功能上类似于一个时间戳,其数值由管理器自身的时钟或者计数器决定。假设在第i个时间段,管理器广播的第一数值为GSN i,,第一ECU和第二ECU之间的共享密钥为K。示例性的,以ASE加密算法为例,假设共享密钥的数据长度为128比特,则认证密钥K i的计算方式如下:
K i=AES128(K,GSNi||Padding)
本实施例中,使用AES128生成K i,其加密效率更高。因为GSNi||Padding是定长且是单分组,因此使用分组加密作为KDF是安全的。由于第一ECU和第二ECU均不直接使用共享密钥进行CAN消息的加密,可以提高CAN消息被破解的难度,保证信息传输的安全。
需要说明的是,本实施例以ASE为例进行说明,但是不限定分组加密算法,现有的加密算法均可以应用在本实施例中。
在步骤S202中,可以首先获取第一ECU的本地计数器(后续称为第一计数器)对应的第一计数值,然后根据认证密钥和第一计数值,生成第一初始密钥;根据所需认证的数据长度,对第一初始密钥的长度进行裁剪,得到第三密钥。
在步骤S203中,可以根据第三密钥,生成密钥流;通过密钥流与有效数据载荷对应的数据进行异或运算,得到加密后的数据。
示例性的,在步骤S203中,令第三密钥vd:=Truncate(c)。裁剪第一初始密钥c到需要的长度。其中,第三密钥vd的长度和要达到的认证强度有关。LC i置于本地计数器域,M||vd置于数据负载域,得到组装完成的CAN帧。
本实施例,通过管理器向各个电子控制单元按照时间段广播第一数值,以使得各个电子控制单元之间发送CAN消息时,可以利用第一数值和共享密钥进行加密和认证处理,从而提高了车载系统信息传输的安全性。
图7为本申请实施例提供的通信的方法的流程图三,参见图7,本实施例的方法包括:
步骤S301、根据第一数值和共享密钥,确定认证密钥。
步骤S302、接收第一ECU发送的CAN帧。
步骤S303、对认证密钥进行拆分,得到第四密钥和第五密钥。
步骤S304、通过第四密钥和第五密钥对CAN帧进行认证。
本实施例中,第一ECU和第二ECU通过总线通信连接,第二ECU可以接收第一ECU发送的CAN消息。其中,第一数值为管理器根据时间段广播的数值,共享密钥为车载中所有ECU共用的密钥。第一密钥用于加密有效数据载荷,第二密钥用于随机化CRC比特位在数据负载域里的位置。
示例性的,可以根据第一数值和共享密钥,通过分组加密算法,生成认证密钥。在每个时间段的起始时刻,管理器向所有ECU广播第一数值,因为每个时间段对应的时间不 同,因此,第一数值也不同,因此这里的第一数值无需使用随机数。第一数值也可以是通过CAN帧的方式发送,一个CAN帧的数据域的长度一般为64比特。
具体地,管理器向所有ECU广播的第一数值,在功能上类似于一个时间戳,其数值由管理器自身的时钟或者计数器决定。假设在第i个时间段,管理器广播的第一数值为GSN i,,第一ECU和第二ECU之间的共享密钥为K。示例性的,以ASE加密算法为例,假设共享密钥的数据长度为128比特,则认证密钥K i的计算方式如下:
K i=AES128(K,GSNi||Padding)
本实施例中,使用AES128生成K i,其加密效率更高。因为GSNi||Padding是定长且是单分组,因此使用分组加密作为KDF是安全的。由于第一ECU和第二ECU均不直接使用共享密钥进行CAN消息的加密,可以提高CAN消息被破解的难度,保证信息传输的安全。
需要说明的是,本实施例以ASE为例进行说明,但是不限定分组加密算法,现有的加密算法均可以应用在本实施例中。
在步骤S304中,在接收到第一ECU发送的CAN帧之后,读取CAN帧的数据负载域,并通过第四密钥解密数据负载域,得到中间数据;通过第五密钥对中间数据进行解密处理,得到恢复的有效数据载荷和恢复的CRC;通过CRC算法对恢复的有效数据载荷和恢复的CRC进行验证,若验证不通过,则确定认证失败。
示例性的,读取第i时间段第二计数器的第二计数值LC i*,并从第i时间段接收到的CAN帧中提取出LC i。如果LC i*>LC i,则认证失败。若LC i*不大于LC i,则计算第二初始密钥c*,c*:=AES128(Ki,LC i||Padding)。分解c*为两部分c*=c* 1||c* 0,c* 1为第四密钥,c* 0为第五密钥。读取CAN帧的数据负载域为payload。解密payload为
Figure PCTCN2020139121-appb-000003
Figure PCTCN2020139121-appb-000004
利用第五密钥c* 1。从payload*中恢复M和CRC,若恢复的M和CRC满足CRC算法,则认证通过,否则认证失败。
在一种可选的实施方式中,在通过认证密钥对CAN帧进行认证之前,首先获取第二计数器对应的第二计数值;将第二计数值与第一计数值进行比较,若第二计数值大于第一计数值,则确定认证失败;其中,第一计数值是第一ECU的第一计数器对应的数值。
本实施例中,若第二ECU的第二计数器的数值大于第一ECU的第一计数器的数值,则说明第一ECU发送CAN帧的时间和第二ECU接收CAN帧的时间不一致,认证失败。
本实施例,通过管理器向各个电子控制单元按照时间段广播第一数值,以使得各个电子控制单元之间发送CAN消息时,可以利用第一数值和共享密钥进行加密和认证处理,从而提高了车载系统信息传输的安全性。
图8为本申请实施例提供的通信的方法的流程图四,参见图8,本实施例的方法包括:
步骤S401、根据第一数值和共享密钥,确定认证密钥。
步骤S402、接收第一ECU发送的CAN帧。
步骤S403、通过认证密钥和第二计数值,得到第六密钥。
步骤S404、对读取到的CAN帧的数据负载域进行分解,得到第三密钥和有效数据载荷。
步骤S405、将第六密钥和第三密钥进行比较,若不一致,则确定认证失败。
本实施例中,第一ECU和第二ECU通过总线通信连接,第一ECU可以向第二ECU 发送CAN消息,由第二ECU对接收到的CAN消息进行认证。其中,第一数值为管理器根据时间段广播的数值,共享密钥为车载中所有ECU共用的密钥。
在步骤S403中,可以通过认证密钥和第二计数值,生成第二初始密钥;根据所需认证的数据长度,对第二初始密钥的长度进行裁剪,得到第六密钥。
示例性的,读取第i时间段第二计数器的第二计数值LC i*,并从第i时间段接收到的CAN帧中提取出LC i。如果LC i*>LC i,则认证失败。若LC i*不大于LC i,则计算第二初始密钥c*,c*:=AES128(Ki,LC i||Padding)。令vd*:=Truncate(c*),裁剪第二初始密钥c*到需要的长度。其中,vd*的长度和要达到的认证强度有关。读取CAN帧的数据负载域payload。分解payload为payload:=M||vd。比较vd和vd*:如果vd=vd*,则认证成功,否则认证失败。
本实施例,通过管理器向各个电子控制单元按照时间段广播第一数值,以使得各个电子控制单元之间发送CAN消息时,可以利用第一数值和共享密钥进行加密和认证处理,从而提高了车载系统信息传输的安全性。
图9为本申请实施例提供的第一ECU的结构示意图一,参见图9,本实施例的第一ECU包括:处理模块21、发送模块22、存储模块23、接收模块24;
处理模块21,用于根据第一数值和共享密钥,确定认证密钥;对认证密钥进行拆分,得到第一密钥和第二密钥;通过第一密钥和第二密钥来组装CAN帧;第一密钥用于加密有效数据载荷,第二密钥用于随机化CRC比特位在数据负载域里的位置;
发送模块22,用于通过CAN总线向第二ECU发送CAN帧;其中,第一数值为管理器根据时间段广播的数值,共享密钥为车载中所有ECU共用的密钥。
示例性的,处理模块21可以是处理器,发送模块22可以是发射器。
示例性的,第一ECU通过总线与第二ECU通信连接。需要说明的是,本实施例不限定第一ECU和第二ECU的数量,第一ECU的数量可以是一个或者多个,第二ECU的数量可以是一个或者多个。
需要说明的是,本实施例除了应用在汽车领域之外,还可以应用在其他组成CAN网络的设备之间的信息传输。
在一种可能的设计中,处理模块21,具体用于:
根据第一数值和共享密钥,通过分组加密算法,生成认证密钥。
在一种可能的设计中,处理模块21,具体用于:
根据认证密钥和第一计数值,通过分组加密算法,生成第一初始密钥;第一计数值是第一计数器对应的数值;
将第一初始密钥分解为第一密钥和第二密钥。
在一种可能的设计中,处理模块21,具体用于:
根据第一密钥,生成密钥流;
通过密钥流与有效数据载荷对应的数据进行异或运算,得到加密后的数据;
根据第二密钥中比特位的值,确定CRC在数据负载域里的位置;
根据CRC在数据负载域里的位置,将所有CRC的比特放入对应的负载位;
将加密后的数据放入数据负载域剩余的负载位,得到组装的CAN帧。
在一种可能的设计中,处理模块21,具体用于:
若第二密钥中比特位的值只能确定部分CRC的比特位在数据负载域里的位置,则以最后确定的CRC的比特位为起始点,将剩余部分CRC的比特位依次放入后续的负载位。
在一种可能的设计中,处理模块21,具体用于:
若第二密钥中比特位的首位数值为1,则按照数据负载域从右向左的顺序,依次根据第二密钥中比特位的值,将CRC放入数据负载域里对应的负载位;
若第二密钥中比特位的首位数值为0,则按照数据负载域从左向右的顺序,依次根据第二密钥中比特位的值,将CRC放入数据负载域里对应的负载位。
本实施例,通过管理器向各个电子控制单元按照时间段广播第一数值,以使得各个电子控制单元之间发送CAN消息时,可以利用第一数值和共享密钥进行加密和认证处理,从而提高了车载系统信息传输的安全性。其具体实现过程和实现原理请参见图3所示实施例中的相关描述,此处不再赘述。
图10为本申请实施例提供的第一ECU的结构示意图二,参见图10,本实施例的第一ECU包括:处理模块31、发送模块32;
处理模块31,用于根据第一数值和共享密钥,确定认证密钥;通过认证密钥和第一计数值,得到第三密钥;第一计数值是第一计数器对应的数值;通过第一计数值和第三密钥来组装CAN帧;第三密钥用于加密有效数据载荷;
发送模块32,用于通过CAN总线向第二ECU发送CAN帧;其中,第一数值为管理器根据时间段广播的数值,共享密钥为车载中所有ECU共用的密钥。
示例性的,处理模块31可以是处理器,发送模块32可以是发射器。
示例性的,第一ECU通过总线与第二ECU通信连接。需要说明的是,本实施例不限定第一ECU和第二ECU的数量,第一ECU的数量可以是一个或者多个,第二ECU的数量可以是一个或者多个。
需要说明的是,本实施例除了应用在汽车领域之外,还可以应用在其他组成CAN网络的设备之间的信息传输。
在一种可能的设计中,处理模块31,具体用于:
根据第一数值和共享密钥,通过分组加密算法,生成认证密钥。
在一种可能的设计中,处理模块31,具体用于:
通过认证密钥和第一计数值,生成第一初始密钥;
根据所需认证的数据长度,对第一初始密钥的长度进行裁剪,得到第三密钥。
在一种可能的设计中,处理模块31,具体用于:
根据第三密钥,生成密钥流;
通过密钥流与有效数据载荷对应的数据进行异或运算,得到加密后的数据;
第一计数值放入CAN帧的第一计数器域,以及将加密后的数据放入数据负载域,得到组装的CAN帧。
本实施例,通过管理器向各个电子控制单元按照时间段广播第一数值,以使得各个电子控制单元之间发送CAN消息时,可以利用第一数值和共享密钥进行加密和认证处理,从而提高了车载系统信息传输的安全性。其具体实现过程和实现原理请参见图6所示实施例中的相关描述,此处不再赘述。
图11为本申请实施例提供的第二ECU的结构示意图一,参见图11,本实施例的第二 ECU包括:处理模块41、接收模块42、存储模块43、发送模块44;
处理模块41,用于根据第一数值和共享密钥,确定认证密钥;
接收模块42,用于接收第一ECU发送的CAN帧;
处理模块41,用于对认证密钥进行拆分,得到第四密钥和第五密钥;第四密钥用于解密有效数据载荷,第五密钥用于恢复有效数据载荷和恢复CRC;
处理模块41,用于通过第四密钥和第五密钥对CAN帧进行认证;其中,第一数值为管理器根据时间段广播的数值,共享密钥为车载中所有ECU共用的密钥。
示例性的,处理模块41可以是处理器,接收模块42可以是接收器。
示例性的,第一ECU通过总线与第二ECU通信连接。需要说明的是,本实施例不限定第一ECU和第二ECU的数量,第一ECU的数量可以是一个或者多个,第二ECU的数量可以是一个或者多个。
需要说明的是,本实施例除了应用在汽车领域之外,还可以应用在其他组成CAN网络的设备之间的信息传输。
在一种可能的设计中,处理模块41,具体用于:根据第一数值和共享密钥,确定认证密钥,包括:
根据第一数值和共享密钥,通过分组加密算法,生成认证密钥。
在一种可能的设计中,处理模块41,具体用于:在通过认证密钥对CAN帧进行认证之前,还包括:
获取第二计数器对应的第二计数值;
将第二计数值与第一数值进行比较,若第二计数值大于第一计数值,则确定认证失败;其中,第一计数值是第一ECU的第一计数器对应的数值。
在一种可能的设计中,处理模块41,具体用于:通过第四密钥和第五密钥对CAN帧进行认证,包括:
读取CAN帧的数据负载域,并通过第四密钥解密数据负载域,得到中间数据;
通过第五密钥对中间数据进行解密处理,得到恢复的有效数据载荷和恢复的CRC;
通过CRC算法对恢复的有效数据载荷和恢复的CRC进行验证,若验证不通过,则确定认证失败。
本实施例,通过管理器向各个电子控制单元按照时间段广播第一数值,以使得各个电子控制单元之间发送CAN消息时,可以利用第一数值和共享密钥进行加密和认证处理,从而提高了车载系统信息传输的安全性。其具体实现过程和实现原理请参见图7所示实施例中的相关描述,此处不再赘述。
图12为本申请实施例提供的第二ECU的结构示意图二,参见图12,本实施例的第二ECU包括:处理模块51、接收模块52;
处理模块51,用于根据第一数值和共享密钥,确定认证密钥;
接收模块52,用于接收第一ECU发送的CAN帧;
处理模块51,用于通过认证密钥和第二计数值,得到第六密钥;第二计数值是第二计数器对应的数值;
处理模块51,用于对读取到的CAN帧的数据负载域进行分解,得到第三密钥和有效数据载荷;
处理模块51,用于将第六密钥和第三密钥进行比较,若不一致,则确定认证失败。
在一种可能的设计中,处理模块51,具体用于:
通过认证密钥和第二计数值,生成第二初始密钥;
根据所需认证的数据长度,对第二初始密钥的长度进行裁剪,得到第六密钥。
本实施例,通过管理器向各个电子控制单元按照时间段广播第一数值,以使得各个电子控制单元之间发送CAN消息时,可以利用第一数值和共享密钥进行加密和认证处理,从而提高了车载系统信息传输的安全性。其具体实现过程和实现原理请参见图8所示实施例中的相关描述,此处不再赘述。
图13为本申请实施例提供的电子设备的结构示意图,参见图13,本实施例的电子设备包括:处理器61和收发器62,处理器61用于执行计算机可执行程序代码中的指令;当处理器61执行指令时,指令使电子设备执行图3、图6~图8中任一项的方法。
本实施例中,通过管理器向各个电子设备按照时间段广播第一数值,以使得各个电子控制单元之间发送CAN消息时,可以利用第一数值和共享密钥进行加密和认证处理,从而提高了车载系统信息传输的安全性。其具体实现过程和实现原理请参见图3、图6~图8所示实施例中的相关描述,此处不再赘述。
图14为本申请实施例提供的通信系统的结构示意图,参见图14,本实施例的通信系统包括:第一ECU 71和第二ECU 72,第一ECU 71通过CAN总线73与第二ECU 72通信连接。
示例性的,第一ECU 71执行图3所示的方法;第二ECU执行图7所示的方法。
示例性的,第一ECU 71执行图6所示的方法;第二ECU执行图8所示的方法。
本实施例中,通过管理器向第一ECU和第二ECU按照时间段广播第一数值,以使得第一ECU向第二ECU发送CAN消息时,可以利用第一数值和共享密钥进行加密和认证处理,从而提高了车载系统信息传输的安全性。其具体实现过程和实现原理请参见图3、图6~图8所示实施例中的相关描述,此处不再赘述。
本申请实施例提供一种计算机可读存储介质,计算机可读存储介质存储有指令,当指令被执行时,使得计算机执行如本申请上述实施例中终端设备执行的方法。
本申请实施例提供一种计算机可读存储介质,计算机可读存储介质存储有指令,当指令被执行时,使得计算机执行如本申请上述实施例中网络设备执行的方法。
在本申请所提供的几个实施例中,应该理解到,所揭露的装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。
作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。
另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既 可以采用硬件的形式实现,也可以采用硬件加软件功能单元的形式实现。
需要说明的是,本申请实施例中对模块的划分是示意性的,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式。在本申请的实施例中的各功能模块可以集成在一个处理模块中,也可以是各个模块单独物理存在,也可以两个或两个以上模块集成在一个模块中。上述集成的模块既可以采用硬件的形式实现,也可以采用软件功能模块的形式实现。
集成的模块如果以软件功能模块的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)或处理器(processor)执行本申请各个实施例方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(Read-Only Memory,ROM)、随机存取存储器(Random Access Memory,RAM)、磁碟或者光盘等各种可以存储程序代码的介质。
在上述实施例中,可以全部或部分地通过软件、硬件、固件或者其任意组合来实现。当使用软件实现时,可以全部或部分地以计算机程序产品的形式实现。计算机程序产品包括一个或多个计算机指令。在计算机上加载和执行计算机程序指令时,全部或部分地产生按照本申请实施例的流程或功能。计算机可以是通用计算机、专用计算机、计算机网络、或者其他可编程装置。计算机指令可以存储在计算机可读存储介质中,或者从一个计算机可读存储介质向另一个计算机可读存储介质传输,例如,计算机指令可以从一个网站站点、计算机、服务器或数据中心通过有线(例如同轴电缆、光纤、数字用户线(DSL))或无线(例如红外、无线、微波等)方式向另一个网站站点、计算机、服务器或数据中心进行传输。计算机可读存储介质可以是计算机能够存取的任何可用介质或者是包含一个或多个可用介质集成的服务器、数据中心等数据存储设备。可用介质可以是磁性介质,(例如,软盘、硬盘、磁带)、光介质(例如,DVD)、或者半导体介质(例如固态硬盘Solid State Disk(SSD))等。

Claims (22)

  1. 一种通信方法,其特征在于,所述方法包括:
    根据第一数值和共享密钥,确定认证密钥;
    对所述认证密钥进行拆分,得到第一密钥和第二密钥;
    通过所述第一密钥和所述第二密钥来组装CAN帧;所述第一密钥用于加密有效数据载荷,所述第二密钥用于随机化CRC比特位在数据负载域里的位置;
    通过CAN总线向第二ECU发送所述CAN帧;其中,所述第一数值为管理器根据时间段广播的数值,所述共享密钥为车载中所有ECU共用的密钥。
  2. 根据权利要求1所述的方法,其特征在于,所述根据第一数值和共享密钥,确定认证密钥,包括:
    根据所述第一数值和所述共享密钥,通过分组加密算法,生成所述认证密钥。
  3. 根据权利要求1所述的方法,其特征在于,所述对所述认证密钥进行拆分,得到第一密钥和第二密钥,包括:
    根据所述认证密钥和第一计数值,通过分组加密算法,生成第一初始密钥;所述第一计数值是第一计数器对应的数值;
    将所述第一初始密钥分解为所述第一密钥和所述第二密钥。
  4. 根据权利要求1所述的方法,其特征在于,所述通过所述第一密钥和所述第二密钥来组装CAN帧,包括:
    根据所述第一密钥,生成密钥流;
    通过所述密钥流与所述有效数据载荷对应的数据进行异或运算,得到加密后的数据;
    根据所述第二密钥中比特位的值,确定CRC在数据负载域里的位置;
    根据所述CRC在数据负载域里的位置,将所有CRC的比特放入对应的负载位;
    将所述加密后的数据放入所述数据负载域剩余的负载位,得到组装的CAN帧。
  5. 根据权利要求4所述的方法,其特征在于,还包括:
    若所述第二密钥中比特位的值只能确定部分CRC的比特位在数据负载域里的位置,则以最后确定的CRC的比特位为起始点,将剩余部分CRC的比特位依次放入后续的负载位。
  6. 根据权利要求4所述的方法,其特征在于,所述根据所述第二密钥中比特位的值,确定CRC在数据负载域里的位置,包括:
    若所述第二密钥中比特位的首位数值为1,则按照数据负载域从右向左的顺序,依次根据所述第二密钥中比特位的值,将CRC放入数据负载域里对应的负载位;
    若所述第二密钥中比特位的首位数值为0,则按照数据负载域从左向右的顺序,依次根据所述第二密钥中比特位的值,将CRC放入数据负载域里对应的负载位。
  7. 一种通信方法,其特征在于,所述方法包括:
    根据第一数值和共享密钥,确定认证密钥;
    通过所述认证密钥和第一计数值,得到第三密钥;所述第一计数值是第一计数器对应的数值;
    通过所述第一计数值和所述第三密钥来组装CAN帧;所述第三密钥用于加密有效数据载荷;
    通过CAN总线向第二ECU发送所述CAN帧;其中,所述第一数值为管理器根据时间段广播的数值,所述共享密钥为车载中所有ECU共用的密钥。
  8. 根据权利要求7所述的方法,其特征在于,所述根据第一数值和共享密钥,确 定认证密钥,包括:
    根据所述第一数值和所述共享密钥,通过分组加密算法,生成所述认证密钥。
  9. 根据权利要求7所述的方法,其特征在于,通过所述认证密钥和第一计数值,得到第三密钥,包括:
    通过所述认证密钥和所述第一计数值,生成第一初始密钥;
    根据所需认证的数据长度,对所述第一初始密钥的长度进行裁剪,得到第三密钥。
  10. 根据权利要求7所述的方法,其特征在于,所述通过所述第一计数值和所述第三密钥来组装CAN帧,包括:
    根据所述第三密钥,生成密钥流;
    通过所述密钥流与所述有效数据载荷对应的数据进行异或运算,得到加密后的数据;
    将所述第一计数值放入CAN帧的第一计数器域,以及将所述加密后的数据放入数据负载域,得到组装的CAN帧。
  11. 一种通信方法,其特征在于,所述方法包括:
    根据第一数值和共享密钥,确定认证密钥;
    接收第一ECU发送的CAN帧;
    对所述认证密钥进行拆分,得到第四密钥和第五密钥;所述第四密钥用于解密有效数据载荷,所述第五密钥用于恢复有效数据载荷和恢复CRC;
    通过所述第四密钥和所述第五密钥对所述CAN帧进行认证;其中,所述第一数值为管理器根据时间段广播的数值,所述共享密钥为车载中所有ECU共用的密钥。
  12. 根据权利要求11所述的方法,其特征在于,所述根据第一数值和共享密钥,确定认证密钥,包括:
    根据所述第一数值和所述共享密钥,通过分组加密算法,生成所述认证密钥。
  13. 根据权利要求11所述的方法,其特征在于,在所述通过所述认证密钥对所述CAN帧进行认证之前,还包括:
    获取第二计数器对应的第二计数值;
    将所述第二计数值与第一计数值进行比较,若所述第二计数值大于所述第一计数值,则确定认证失败;其中,所述第一计数值是所述第一ECU的第一计数器对应的数值。
  14. 根据权利要求11所述的方法,其特征在于,所述通过所述第四密钥和所述第五密钥对所述CAN帧进行认证,包括:
    读取所述CAN帧的数据负载域,并通过所述第四密钥解密所述数据负载域,得到中间数据;
    通过所述第五密钥对所述中间数据进行解密处理,得到恢复的有效数据载荷和恢复的CRC;
    通过CRC算法对所述恢复的有效数据载荷和所述恢复的CRC进行验证,若验证不通过,则确定认证失败。
  15. 一种通信方法,其特征在于,所述方法包括:
    根据第一数值和共享密钥,确定认证密钥;
    接收第一ECU发送的CAN帧;
    通过所述认证密钥和第二计数值,得到第六密钥;所述第二计数值是第二计数器对应的数值;
    对读取到的CAN帧的数据负载域进行分解,得到第三密钥和有效数据载荷;
    将所述第六密钥和所述第三密钥进行比较,若不一致,则确定认证失败。
  16. 根据权利要求15所述的方法,其特征在于,通过所述认证密钥和第二计数值,得到第六密钥,包括:
    通过所述认证密钥和所述第二计数值,生成第二初始密钥;
    根据所需认证的数据长度,对所述第二初始密钥的长度进行裁剪,得到第六密钥。
  17. 一种电子设备,其特征在于,包括:处理器和收发器,所述处理器用于执行计算机可执行程序代码中的指令;当所述处理器执行所述指令时,所述指令使所述电子设备执行权利要求1至6中任一项所述的方法。
  18. 一种电子设备,其特征在于,包括:处理器和收发器,所述处理器用于执行计算机可执行程序代码中的指令;当所述处理器执行所述指令时,所述指令使所述电子设备执行权利要求7至10中任一项所述的方法。
  19. 一种电子设备,其特征在于,包括:处理器和收发器,所述处理器用于执行计算机可执行程序代码中的指令;当所述处理器执行所述指令时,所述指令使所述电子设备执行权利要求11至14中任一项所述的方法。
  20. 一种电子设备,其特征在于,包括:处理器和收发器,所述处理器用于执行计算机可执行程序代码中的指令;当所述处理器执行所述指令时,所述指令使所述电子设备执行权利要求15至16中任一项所述的方法。
  21. 一种通信系统,其特征在于,包括:第一ECU和第二ECU,所述第一ECU通过CAN总线与所述第二ECU通信连接,所述第一ECU执行权利要求1至6中任一项所述的方法;所述第二ECU执行权利要求11至14中任一项所述的方法。
  22. 一种通信系统,其特征在于,包括:第一ECU和第二ECU,所述第一ECU通过CAN总线与所述第二ECU通信连接,所述第一ECU执行权利要求7至10中任一项所述的方法;所述第二ECU执行权利要求15至16中任一项所述的方法。
PCT/CN2020/139121 2019-12-31 2020-12-24 通信方法和电子设备 WO2021136072A1 (zh)

Priority Applications (1)

Application Number Priority Date Filing Date Title
EP20909121.4A EP4080813B1 (en) 2019-12-31 2020-12-24 Communication method and electronic device

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201911417603.0 2019-12-31
CN201911417603.0A CN113132092B (zh) 2019-12-31 2019-12-31 通信方法和电子设备

Publications (1)

Publication Number Publication Date
WO2021136072A1 true WO2021136072A1 (zh) 2021-07-08

Family

ID=76686484

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/139121 WO2021136072A1 (zh) 2019-12-31 2020-12-24 通信方法和电子设备

Country Status (3)

Country Link
EP (1) EP4080813B1 (zh)
CN (1) CN113132092B (zh)
WO (1) WO2021136072A1 (zh)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2013065689A1 (ja) * 2011-10-31 2013-05-10 株式会社トヨタIt開発センター 通信システムにおけるメッセージ認証方法および通信システム
CN106549940A (zh) * 2016-10-13 2017-03-29 北京奇虎科技有限公司 车辆数据传输方法及系统
CN106790053A (zh) * 2016-12-20 2017-05-31 江苏大学 一种can总线中ecu安全通信的方法
CN109672538A (zh) * 2019-02-13 2019-04-23 北京仁信证科技有限公司 一种轻量级车载总线安全通信方法及安全通信系统

Family Cites Families (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP5880898B2 (ja) * 2014-05-08 2016-03-09 パナソニックIpマネジメント株式会社 送信装置
CN110377310B (zh) * 2014-11-12 2023-04-07 松下电器(美国)知识产权公司 更新管理方法、更新管理装置以及计算机可读取的记录介质
CN105794146A (zh) * 2014-11-13 2016-07-20 松下电器(美国)知识产权公司 密钥管理方法、车载网络系统以及密钥管理装置
GB2561256A (en) * 2017-04-05 2018-10-10 Stmicroelectronics Grenoble2 Sas Apparatus for use in a can system
WO2018214487A1 (zh) * 2017-05-25 2018-11-29 华为技术有限公司 一种控制器区域网总线安全通信方法、装置及系统
CN108965218B (zh) * 2017-05-25 2020-09-29 华为技术有限公司 一种控制器区域网总线安全通信方法、装置及系统
US10701102B2 (en) * 2017-10-03 2020-06-30 George Mason University Hardware module-based authentication in intra-vehicle networks
CN108123805A (zh) * 2017-12-15 2018-06-05 上海汽车集团股份有限公司 车载ecu间通讯安全认证方法
US10943416B2 (en) * 2018-05-09 2021-03-09 Strattec Security Corporation Secured communication in passive entry passive start (PEPS) systems

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2013065689A1 (ja) * 2011-10-31 2013-05-10 株式会社トヨタIt開発センター 通信システムにおけるメッセージ認証方法および通信システム
CN106549940A (zh) * 2016-10-13 2017-03-29 北京奇虎科技有限公司 车辆数据传输方法及系统
CN106790053A (zh) * 2016-12-20 2017-05-31 江苏大学 一种can总线中ecu安全通信的方法
CN109672538A (zh) * 2019-02-13 2019-04-23 北京仁信证科技有限公司 一种轻量级车载总线安全通信方法及安全通信系统

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
See also references of EP4080813A4

Also Published As

Publication number Publication date
EP4080813A4 (en) 2023-01-25
CN113132092B (zh) 2022-04-22
EP4080813B1 (en) 2024-05-22
CN113132092A (zh) 2021-07-16
EP4080813A1 (en) 2022-10-26

Similar Documents

Publication Publication Date Title
US20230224145A1 (en) End-to-end communication security
EP3297247B1 (en) In-vehicle encrypted networking
CN109600350B (zh) 用于车辆网络中的控制器间的安全通信的系统和方法
US11245535B2 (en) Hash-chain based sender identification scheme
CN111049803A (zh) 基于车载can总线通讯系统数据加密及平台安全访问的方法
CN105227566A (zh) 密钥处理方法、密钥处理装置及密钥处理系统
CN111884811B (zh) 一种基于区块链的数据存证方法和数据存证平台
WO2019019593A1 (zh) 无状态通信安全签名方法、终端及服务器端
CN106789928B (zh) 基于系统双向认证的解锁方法及装置
CN111901116B (zh) 一种基于eap-md5改进协议的身份认证方法及系统
CN114095277A (zh) 配电网安全通信方法、安全接入设备及可读存储介质
CN111291398B (zh) 基于区块链的认证方法、装置、计算机设备及存储介质
CN107786338B (zh) 动态密码校验中的共享平台
CN111835691B (zh) 一种认证信息处理方法、终端和网络设备
WO2021136072A1 (zh) 通信方法和电子设备
Ansari et al. IntelliCAN: Attack-resilient controller area network (CAN) for secure automobiles
CN111836260A (zh) 一种认证信息处理方法、终端和网络设备
CN111541642B (zh) 基于动态秘钥的蓝牙加密通信方法和装置
CN114650181A (zh) 电子邮件加解密方法、系统、设备及计算机可读存储介质
CN113014391A (zh) 嵌入式系统的鉴权方法、终端设备及计算机可读存储介质
Wang et al. An OTA-oriented Protocol for Security Protection
CN111555873B (zh) 一种远程鉴权方法、装置及系统
CN116669019B (zh) 一种无人驾驶车辆轨道通信加密方法
CN113904789B (zh) 一种铁路安全通信协议的加密方法、设备以及存储介质
CN114374519A (zh) 一种数据传输的方法、系统及设备

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 20909121

Country of ref document: EP

Kind code of ref document: A1

ENP Entry into the national phase

Ref document number: 2020909121

Country of ref document: EP

Effective date: 20220719

NENP Non-entry into the national phase

Ref country code: DE