CN117955653A - ECU identity authentication method of CAN bus and storage medium - Google Patents

ECU identity authentication method of CAN bus and storage medium Download PDF

Info

Publication number
CN117955653A
CN117955653A CN202211328467.XA CN202211328467A CN117955653A CN 117955653 A CN117955653 A CN 117955653A CN 202211328467 A CN202211328467 A CN 202211328467A CN 117955653 A CN117955653 A CN 117955653A
Authority
CN
China
Prior art keywords
message
messages
hash
exclusive
authentication
Prior art date
Legal status (The legal status 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 status listed.)
Pending
Application number
CN202211328467.XA
Other languages
Chinese (zh)
Inventor
涂岩恺
陈青溪
叶旭辉
姚亮
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Xiamen Yaxon Networks Co Ltd
Original Assignee
Xiamen Yaxon Networks Co Ltd
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 Xiamen Yaxon Networks Co Ltd filed Critical Xiamen Yaxon Networks Co Ltd
Priority to CN202211328467.XA priority Critical patent/CN117955653A/en
Publication of CN117955653A publication Critical patent/CN117955653A/en
Pending legal-status Critical Current

Links

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses an ECU identity authentication method of a CAN bus and a storage medium, wherein a sender obtains a message to be sent currently and j-1 messages to be sent later, obtains j messages, calculates hash message authentication codes of the j messages respectively according to a preset agreed key, and j is a preset numerical value; equally dividing hash message authentication codes of the j messages respectively; selecting a segmentation value from hash message authentication codes of the j messages respectively, and performing exclusive-or operation on the j segmentation values obtained by selection to obtain a first exclusive-or sum; the first exclusive OR sum is used as a verification message of the message to be sent currently, and the message to be sent currently and the verification message thereof are sent to a receiver; the receiving side carries out identity authentication on the sending side according to the received j continuous messages and the verification message of the first message. The invention can reduce bus broadband occupation and achieve the effect of safety authentication.

Description

ECU identity authentication method of CAN bus and storage medium
Technical Field
The invention relates to the technical field of vehicle safety, in particular to an ECU identity authentication method of a CAN bus and a storage medium.
Background
The automobile electronic system is composed of a plurality of ECUs (Electronic Control Unit, electronic control units), and at present, the ECUs in the automobile are in message communication through a CAN bus, and the CAN bus is characterized by high real-time performance, but lacks information security, is in a broadcasting mode and lacks identification card of information sources.
The traditional method is to carry out authentication on the sender identity of a single frame message by attaching HMAC (Hash-based Message Authentication Code, hash operation message authentication code) and other encryption summary information to the message. Specifically, between the sending ECU and the receiving ECU, there is a secret key k, by which the HMAC value h=hmac (k, ci) of each message can be calculated, ci representing the content of the message i. The sending ECU adds the H value of the message into the CAN bus message data field for transmission, and the receiving ECU takes out the H value after receiving the message. Then, the receiving ECU locally calculates HMAC value H' =hmac (k, ci) according to the message sequence number i and the constraint key k; judging whether H' =H is true or not, if so, the message is sent by a legal ECU, and the content of the message can be trusted; if not, the message is indicated to be forged by the illegal identity ECU.
However, this method has a certain defect that the result of the general HMAC algorithm occupies 16 to 32 bytes, and has a longer length, and because the total bandwidth of the CAN bus of the automobile is lower, directly attaching the HMAC value to the message will transmit excessive redundant security information, and occupy more bus bandwidth, and if the HMAC digest is directly truncated (e.g. only a few bytes are taken) or compressed, the security of the algorithm will be affected, and the security authentication effect will not be achieved.
Disclosure of Invention
The technical problems to be solved by the invention are as follows: the ECU identity authentication method and the storage medium for the CAN bus CAN reduce the occupation of the bus broadband and achieve the safety authentication effect.
In order to solve the technical problems, the invention adopts the following technical scheme: an ECU identity authentication method of a CAN bus comprises the following steps:
the method comprises the steps that a sender obtains a message to be sent currently and j-1 messages to be sent later to obtain j messages, hash message authentication codes of the j messages are calculated respectively according to a preset agreed key, and j is a preset numerical value;
Equally dividing hash message authentication codes of the j messages respectively, wherein the hash message authentication codes of the divided messages comprise j dividing values;
selecting a segmentation value from hash message authentication codes of the j messages respectively, and performing exclusive-or operation on the j segmentation values obtained by selection to obtain a first exclusive-or sum;
The first exclusive or sum is used as the verification message of the message to be sent currently, and the message to be sent currently and the verification message thereof are sent to a receiver;
the receiving side carries out identity authentication on the sending side according to the received j continuous messages and the verification message of the first message.
The invention also proposes a computer-readable storage medium, on which a computer program is stored, which program, when being executed by a processor, implements a method as described above.
The invention has the beneficial effects that: because CAN bus messages are always sent continuously according to the period, the invention utilizes the characteristic to realize the compression transmission and accumulation verification of HMAC values on the CAN bus, thereby achieving the purposes of carrying verification information in compression and real-time authentication. The invention can reduce bus broadband occupation and achieve the effect of safety authentication.
Drawings
FIG. 1 is a flow chart of an ECU identity authentication method for a CAN bus of the present invention;
Fig. 2 is a flowchart of a sender processing according to a first embodiment of the present invention;
Fig. 3 is a flowchart illustrating a process of a receiving side according to a first embodiment of the present invention.
Detailed Description
In order to describe the technical contents, the achieved objects and effects of the present invention in detail, the following description will be made with reference to the embodiments in conjunction with the accompanying drawings.
Referring to fig. 1, an ECU identity authentication method for a CAN bus includes:
the method comprises the steps that a sender obtains a message to be sent currently and j-1 messages to be sent later to obtain j messages, hash message authentication codes of the j messages are calculated respectively according to a preset agreed key, and j is a preset numerical value;
Equally dividing hash message authentication codes of the j messages respectively, wherein the hash message authentication codes of the divided messages comprise j dividing values;
selecting a segmentation value from hash message authentication codes of the j messages respectively, and performing exclusive-or operation on the j segmentation values obtained by selection to obtain a first exclusive-or sum;
The first exclusive or sum is used as the verification message of the message to be sent currently, and the message to be sent currently and the verification message thereof are sent to a receiver;
the receiving side carries out identity authentication on the sending side according to the received j continuous messages and the verification message of the first message.
From the above description, the beneficial effects of the invention are as follows: by utilizing the characteristic that the CAN bus report is periodically and continuously sent, the compression transmission and accumulation verification of the HMAC value on the CAN bus are realized, and the purposes of carrying verification information in compression and real-time authentication are achieved.
Further, the receiving side performs identity authentication on the sending side according to the received j continuous messages and the verification message of the first message, specifically:
After receiving continuous j messages and verification messages thereof, a receiver calculates hash message authentication codes of the j messages respectively according to preset agreed keys, and equally divides the hash message authentication codes of the j messages into j division values respectively;
Selecting a segmentation value from hash message authentication codes of the j messages respectively, and performing exclusive-or operation on the j segmentation values obtained by selection to obtain a second exclusive-or sum;
and if the verification message of the first message in the j messages is consistent with the second exclusive OR, judging that the identity authentication is passed.
Further, the selecting a split value from the hash message authentication codes of the j messages respectively specifically includes:
And acquiring a t segmentation value from the hash message authentication code of one message, wherein t is the sequence of the one message in the j messages.
From the above description, it can be seen that the verification message of the first message in the j messages is generated by selecting a split value from the hash message authentication codes of the j messages, so that the length of the verification message can be reduced, and the security can be effectively ensured.
Further, the value of j is the same as the byte number of the hash message authentication code.
From the above description, the last verification message is made to be 1 byte in length, so as to maximize the compression effect of the HMAC value and minimize the occupied bus bandwidth.
The invention also proposes a computer-readable storage medium, on which a computer program is stored, which program, when being executed by a processor, implements a method as described above.
Example 1
Referring to fig. 2-3, a first embodiment of the present invention is as follows: an ECU identity authentication method of a CAN bus CAN be applied to an automobile electronic system.
As shown in fig. 2, the sender performs the steps of:
S101: obtaining a current message to be sent and j-1 messages to be sent after the current message to be sent, obtaining j messages, and respectively calculating hash message authentication codes of the j messages according to a preset agreed key, wherein j is a preset numerical value.
For example, assuming that the sequence number of the message to be currently transmitted is i, the hash message authentication code H i=HMAC(k,Ci thereof is calculated), HMAC () represents an operation of calculating the hash message authentication code, for example, an MD5 algorithm may be adopted, k represents a contract key, and C i represents a message with the sequence number i.
Similarly, the sequence numbers of j-1 messages to be sent after the message are i+1, i+2 … … i+j-1 respectively, and hash message authentication codes H i+1=HMAC(k,Ci+1),Hi+2=HMAC(k,Ci+2),……,Hij==HMAC(k,Ci+j-1 are calculated respectively.
S102: and equally dividing the hash message authentication codes of the j messages respectively, wherein the hash message authentication codes of each divided message comprise j dividing values.
For example, the hash authentication code H i of the message C i to be sent currently is divided into equal length segments, and j segments are obtained by total segmentation, and are respectively D i1,Di2,……,Dij, and the j segments are sequentially combined together to form H i. In this embodiment, for a hash message authentication code employing the MD5 algorithm, the length of the hash message authentication code is 16 bytes, and j=16 is preferable, and at this time, the length of each split value is 1 byte.
Similarly, for the message C i+1, dividing the hash message authentication code H i+1 to obtain j divided values D (i+1)1,D(i+1)2,……,D(i+1)j respectively; for the message C i+2, dividing the hash message authentication code H i+2 to obtain j divided values D (i+2)1,D(i+2)2,……,D(i+2)j respectively; and so on.
S103: and selecting a segmentation value from the hash message authentication codes of the j messages respectively, and performing exclusive-or operation on the j segmentation values obtained by the selection to obtain a first exclusive-or sum.
Specifically, in this embodiment, a segmentation value is selected from the hash authentication codes of a message according to the sequence of the message in the j messages. For each message in j messages, the t-th segmentation value is obtained from the hash message authentication code, and t is the sequence of the message in the j messages.
For example, for a first message C i of the j messages, a first split D i1 of the j split values of the hash message authentication code H i is obtained, for a second message C i+1 of the j messages, a second split D (i+1)2 of the j split values of the hash message authentication code H i+1 is obtained, for a third message C i+2 of the j messages, a third split D (i+2)3 of the j split values of the hash message authentication code H i+2 is obtained, and so on.
One segmentation value is selected from the hash message authentication codes of each message, j segmentation values can be selected from the hash message authentication codes of j messages, and exclusive or operation is carried out on the j segmentation values selected, so that a first exclusive or sum A i, namely A i=Di1⊕D(i+1)2⊕D(i+2)3⊕……⊕D(i+j-1)j, is obtained.
S104: and taking the first exclusive OR as a verification message of the message to be sent currently, and sending the message to be sent currently and the verification message thereof to a receiver. I.e. the first exclusive or sum a i is used as the authentication message of the message C i, and then the message C i and its authentication message a i are sent together to the receiver.
Further, when the next message C i+1 is to be sent, since the hash authentication codes of the messages with sequence numbers i+1 to i+j-1 and the segmentation values thereof have been calculated before, only the hash authentication code H i+j=HMAC(k,Ci+j of the message C i+j with sequence number i+j needs to be calculated again, and equal-length segmentation is performed on H i+j to obtain D (i+j)1,D(i+j)2,……,D(i+j)j. And then selecting a segmentation value from the j hash message authentication codes of H i+1,Hi+2,……,Hi+j respectively for exclusive OR operation, namely A i+1=D(i+1)1⊕D(i+2)2⊕D(i+2)3⊕……⊕D(i+j)j, and finally putting A i+1 as a verification message of the message C i+1 into the data of the message C i+1 to be sent to a receiver together. For subsequent messages, and so on.
For the last j-1 messages in the messages sent continuously, as the number of the messages sent later is less than j-1, a segmentation value is selected from hash message authentication codes of all the messages after the last j-1 messages to carry out exclusive OR operation. For example, for the j-1 last message, selecting a segmentation value from the hash message authentication code of the j-1 last message, performing exclusive-or operation on the selected j-1 segmentation values, and taking the obtained exclusive-or sum as the authentication message of the j-1 last message; for the j-2 messages of the reciprocal, selecting a segmentation value from hash message authentication codes of the last j-2 messages, performing exclusive OR operation on the selected j-2 segmentation values, and taking the obtained exclusive OR sum as authentication information of the j-2 messages of the reciprocal; and by analogy, when the last message is reached, the first segmentation value is directly obtained from the hash message authentication code of the last message to serve as the verification message of the last segmentation value.
As shown in fig. 3, the receiving side performs the steps of:
s201: the receiving party receives messages sent by the sending party, calculates hash message authentication codes of j messages respectively according to preset agreed keys after receiving continuous j messages and verification messages thereof, and divides the hash message authentication codes of the j messages into j division values respectively.
This step can be referred to as steps S101-102.
S202: and selecting a segmentation value from the hash message authentication codes of the j messages respectively, and performing exclusive-or operation on the j segmentation values obtained by the selection to obtain a second exclusive-or sum.
The process of selecting the segmentation value may refer to step S103, that is, the selection rule of the receiving party is consistent with the selection rule of the transmitting party. And then carrying out exclusive or operation on the j selected segmentation values to obtain a second exclusive or sum. For example, assuming that the sequence numbers of j messages received consecutively are i, i+1, … …, i+j-1, respectively, the second exclusive-or sum calculated at this timeWherein D 'i1 is the first split value of the hash authentication code of the first message of the received consecutive j messages, D' (i+1)2 is the second split value of the hash authentication code of the second message of the received consecutive j messages, and so on.
S203: and judging whether the verification message of the first message in the j continuous messages is consistent with the second exclusive OR sum, if so, executing the step S204, and if not, executing the step S205.
S204: and judging that the identity authentication of the sender passes.
S205: and judging that the identity authentication of the sender is not passed.
Further, when the receiving side continues to receive the subsequent continuous message, for example, receives the message C ' i+1 with the sequence number i+j, since the hash message authentication codes and the segmentation values of the messages with the sequence numbers i+1 to i+j-1 have been calculated before, only the hash message authentication code H ' i+j=HMAC(k,Ci+j of the message C ' i+j with the sequence number i+j needs to be calculated again, and the equal-length segmentation is performed on the H ' i+j, so as to obtain D ' (i+j)1,D'(i+j)2,……,D'(i+j)j. Then selecting a segmentation value from hash message authentication codes of j messages with serial numbers of i+1 to i+j for exclusive OR operation, namelyAnd finally judging whether the A' i+1 is consistent with the verification message of the received message with the sequence number of i+1, if so, judging that the identity authentication of the sending ECU passes, and otherwise, judging that the authentication does not pass. And the method and the device are used for realizing the real-time authentication of the identity of the sender by analogy for the subsequently received messages.
After the continuous message is sent, the final j-1 messages in the continuous message are correspondingly verified by referring to the processing of the sender. For example, after receiving the last message and verifying according to the verification message of the last j-th message, selecting a segmentation value from hash message authentication codes of the last j-1 messages in the received continuous messages, performing exclusive-or operation on the selected j-1 segmentation values, and comparing the obtained exclusive-or sum with the verification message of the last j-1 messages; then, selecting a segmentation value from hash message authentication codes of the last j-2 messages in the received continuous messages, performing exclusive OR operation on the selected j-2 segmentation values, and comparing the obtained exclusive OR sum with verification messages of the j-2 messages at the last; and by analogy, when the last message is reached, the first segmentation value in the hash message authentication code of the last received message is directly compared with the verification message of the last received message.
The CAN bus message of the embodiment has the characteristic of periodic continuous transmission, so that verification messages of other messages except the last j-1 messages all contain HMAC values of the j messages, the security influence is limited to the last j-1 messages, but the influence on the security is very limited because the identity authentication CAN be effectively realized in the previous messages.
The embodiment effectively compresses the HMAC value, reduces the occupation of bus bandwidth and effectively ensures the safety.
Example two
This embodiment is a computer-readable storage medium corresponding to the above embodiment, on which a computer program is stored, which when executed by a processor, implements the steps of the ECU identity authentication method of the CAN bus in the above embodiment, and CAN achieve the same technical effects, which will not be described here.
In summary, the method and the storage medium for authenticating the identity of the ECU of the CAN bus provided by the invention realize compression transmission and accumulation verification of the HMAC value on the CAN bus by utilizing the characteristic that the CAN bus message is periodically and continuously transmitted, thereby achieving the purposes of carrying verification information in compression and real-time authentication.
The foregoing description is only illustrative of the present invention and is not intended to limit the scope of the invention, and all equivalent changes made by the specification and drawings of the present invention, or direct or indirect application in the relevant art, are included in the scope of the present invention.

Claims (5)

1. An ECU identity authentication method of a CAN bus is characterized by comprising the following steps:
the method comprises the steps that a sender obtains a message to be sent currently and j-1 messages to be sent later to obtain j messages, hash message authentication codes of the j messages are calculated respectively according to a preset agreed key, and j is a preset numerical value;
Equally dividing hash message authentication codes of the j messages respectively, wherein the hash message authentication codes of the divided messages comprise j dividing values;
selecting a segmentation value from hash message authentication codes of the j messages respectively, and performing exclusive-or operation on the j segmentation values obtained by selection to obtain a first exclusive-or sum;
The first exclusive or sum is used as the verification message of the message to be sent currently, and the message to be sent currently and the verification message thereof are sent to a receiver;
the receiving side carries out identity authentication on the sending side according to the received j continuous messages and the verification message of the first message.
2. The ECU identity authentication method of the CAN bus according to claim 1, wherein the receiving side performs identity authentication on the sending side according to the received continuous j messages and the authentication message of the first message, specifically:
After receiving continuous j messages and verification messages thereof, a receiver calculates hash message authentication codes of the j messages respectively according to preset agreed keys, and equally divides the hash message authentication codes of the j messages into j division values respectively;
Selecting a segmentation value from hash message authentication codes of the j messages respectively, and performing exclusive-or operation on the j segmentation values obtained by selection to obtain a second exclusive-or sum;
and if the verification message of the first message in the j messages is consistent with the second exclusive OR, judging that the identity authentication is passed.
3. The ECU identity authentication method of the CAN bus according to claim 1 or 2, wherein each of the hash message authentication codes of the j messages selects a split value specifically:
And acquiring a t segmentation value from the hash message authentication code of one message, wherein t is the sequence of the one message in the j messages.
4. The ECU identity authentication method of the CAN bus according to claim 1 or 2, characterized in that the value of j is the same as the number of bytes of the hash message authentication code.
5. A computer readable storage medium, on which a computer program is stored, characterized in that the program, when being executed by a processor, implements the method according to any of claims 1-4.
CN202211328467.XA 2022-10-27 2022-10-27 ECU identity authentication method of CAN bus and storage medium Pending CN117955653A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211328467.XA CN117955653A (en) 2022-10-27 2022-10-27 ECU identity authentication method of CAN bus and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211328467.XA CN117955653A (en) 2022-10-27 2022-10-27 ECU identity authentication method of CAN bus and storage medium

Publications (1)

Publication Number Publication Date
CN117955653A true CN117955653A (en) 2024-04-30

Family

ID=90802032

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211328467.XA Pending CN117955653A (en) 2022-10-27 2022-10-27 ECU identity authentication method of CAN bus and storage medium

Country Status (1)

Country Link
CN (1) CN117955653A (en)

Similar Documents

Publication Publication Date Title
CN111628868B (en) Digital signature generation method and device, computer equipment and storage medium
US7512801B1 (en) Authentication system, authentication method, signing apparatus, signing method, certifying apparatus, certifying method, and a computer-readable recording medium with a program making a computer execute the method recording therein
US20100005309A1 (en) Method and apparatus for authentication of data streams with adaptively controlled losses
CN107113180B (en) Packet transmission device, packet reception device, and storage medium
US20040123102A1 (en) Method and system for data integrity protection
CN111262876B (en) Data processing method, device and equipment based on block chain and storage medium
CN110380842B (en) CAN bus message signature method, device and system suitable for intelligent network-connected automobile
CN114205133B (en) Information security enhancement method for vehicle-mounted CAN network and electronic equipment
CN101647229B (en) Compressed ecdsa signatures
CN111865557B (en) Verification code generation method and device
CN114205142A (en) Data transmission method and device, electronic equipment and storage medium
CN102325025A (en) Data processing method and system for verifying provision source authenticity
CN117955653A (en) ECU identity authentication method of CAN bus and storage medium
CN111931194A (en) Security monitoring big data processing method and device based on cloud computing
US9438425B2 (en) Robust MAC aggregation with short MAC tags
US11336456B2 (en) Message authentication system, apparatus, and message verification method
CN116112186B (en) Electronic signature anti-counterfeiting method and system
CN114978603B (en) Data merging and transmitting method with receiving and judging capability and system thereof
CN109657447B (en) Equipment fingerprint generation method and device
CN114245183B (en) Push data authentication method and device
CN117040913B (en) Cloud resource sharing data security transmission method and system
CN116827553A (en) Authentication code generation method, device, equipment and storage medium based on SM3 algorithm
CN116132059A (en) Communication method and device, electronic equipment and storage medium
KR102291462B1 (en) Method for Managing Channel for Transmission of Chunk Data, Parallel Transmission Method and Reception Method of Chunk Data
CN118138241A (en) Elliptic curve-based encryption method, apparatus, device, medium, and program product

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication