Message transmission method and device
By generating freshness values and encrypting messages in the vehicular network, the problems of easy forgery, tampering and replay of messages in the vehicular network are solved, realizing a message transmission method with high compatibility and low modification cost, which can adapt to the complex environment of the vehicular network.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- CHINA AUTOMOTIVE INNOVATION CORP
- Filing Date
- 2025-12-29
- Publication Date
- 2026-05-12
AI Technical Summary
Existing technologies lack a unified message authentication and freshness verification mechanism in vehicular networks, making messages easy to forge, tamper with, and replay, which makes it difficult to meet the requirements of vehicle functional safety and network security. Furthermore, existing security enhancement solutions suffer from poor compatibility, high modification costs, and large bandwidth and latency overhead.
By determining the time slice number and request number of the business data, a freshness value is generated. The message header, data, and freshness value are then encrypted with a derived key to construct the message and send it. The receiving end parses the message and compares the authentication code to ensure the integrity and freshness of the message.
It improves the message's resistance to forgery and tampering, while also possessing the advantages of high compatibility, low modification cost, and easy deployment, adapting to the real-world conditions of vehicle networks such as high frequency, out-of-order delivery, and power outages.
Smart Images

Figure CN122027201A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology, and in particular to a method and apparatus for transmitting messages. Background Technology
[0002] In terms of in-vehicle communication, the Controller Area Network (CAN) in the vehicle has Automotive Open System Architecture Secure Onboard Communication (AUTOSAR SecOC) to perform integrity and source authentication of messages, while the in-vehicle Ethernet does not have corresponding integrity and source authentication.
[0003] The "trusted bus" assumption no longer holds true. Attackers possess the capabilities for passive eavesdropping, active tampering, and cross-time / cross-source replay, rendering link-layer isolation insufficient for functional and security requirements. The hardware costs and resource consumption required for asymmetric encryption and digital signatures used in the mainstream internet are too burdensome for the various controllers within the vehicle, and thus have not yet been widely adopted. The industry mainstream approach is to overlay message-level integrity and freshness protection (such as AUTOSAR SecOC) on top of the transport layer to combat tampering and replay; however, the high frequency, out-of-order delivery, power outages, and multi-source concurrency of in-vehicle networks make simply "adding a MAC address" far from sufficient for practical implementation.
[0004] Although the existing SOME / IP protocol is widely used in vehicle networks, it lacks a unified message authentication and freshness verification mechanism, making messages easy to forge, tamper with, and replay, which makes it difficult to meet the functional safety and network security requirements of vehicles. At the same time, existing security enhancement solutions often require modification of protocol header fields or the introduction of additional encapsulation and connection-state mechanisms, resulting in poor compatibility, high modification costs, large bandwidth and latency overhead, and insufficient adaptability to out-of-order delivery and packet loss. Summary of the Invention
[0005] To address the problems of the prior art, embodiments of this application provide a method and apparatus for transmitting messages. The technical solution is as follows: On the one hand, a message transmission method is provided, which is applied at the sending end, the method comprising: Determine the business data and the time slice number corresponding to the business data, and obtain the historical time slice number and the corresponding historical request number; The request number corresponding to the business data is determined based on the time slice number corresponding to the business data, the historical time slice number, and the corresponding historical request number. The freshness value is determined based on the time slice number and request number corresponding to the business data. The time slice number corresponding to the business data is encrypted to generate a derived key; Using the derived key as the key, the business data, the message header corresponding to the business data, and the freshness value are encrypted to obtain the first message authentication code; The message is constructed according to the order of the message header corresponding to the business data, the business data, the freshness value and the message authentication code, and sent to the corresponding receiving end.
[0006] In one exemplary implementation, determining the request number corresponding to the business data based on the time slice number corresponding to the business data, the historical time slice number, and the corresponding historical request number includes: If a target historical time slot number exists in the historical time slot number that matches the time slot number corresponding to the business data, the target historical request number corresponding to the target historical time slot number is determined from the request number corresponding to the historical time slot number based on the target historical time slot number. Determine whether the target historical request number is less than a preset request number; if so, determine the sum of the target historical request number and the preset step size as the request number corresponding to the business data; if not, generate an alarm message. If there is no target historical time slot number in the historical time slot numbers that matches the time slot number corresponding to the business data, the preset initial number will be determined as the request number corresponding to the business data.
[0007] In one exemplary implementation, a method for determining the time slice number corresponding to the business data includes: Obtain the global time corresponding to the business data; The ratio of the global time to the time slice length corresponding to the business data is determined as the intermediate time slice value; The intermediate time slice value is rounded down to the nearest integer to obtain the time slice number corresponding to the service data.
[0008] In an exemplary implementation, the step of encrypting the business data, the message header corresponding to the business data, and the freshness value using the derived key as the key to obtain the first message authentication code includes: Using the derived key as the key, the business data, the message header corresponding to the business data, and the freshness value are encrypted to generate an initial message authentication code. The initial message authentication code is truncated to obtain the first message authentication code with a preset byte capacity.
[0009] On the other hand, a message transmission method is provided, which is applied at the receiving end; including: The message is acquired, and the message is parsed and extracted to generate the corresponding business data, message header and freshness value. Determine the current time slice number; Based on the freshness value, the current time slice number, and the preset time threshold, a time filtering result is generated; If the time filtering result indicates that the freshness value is a valid value, the time slice number in the freshness value is encrypted to generate a derived key; Using the derived key as the key, the business data, the message header corresponding to the business data, and the freshness value are encrypted to obtain the second message authentication code; Determine whether the second message authentication code matches the first message authentication code in the message; if yes, then process the transmission of the service data; if no, then discard the message.
[0010] In one exemplary implementation, the transmission processing of the service data includes: Determine whether the time slice number in the freshness value is greater than the historical time slice number; if yes, update the sliding window corresponding to the time slice number; if no, do not update the sliding window corresponding to the time slice number. Determine whether the request number in the freshness value is less than a preset threshold; if so, perform bitmap setting on the request number; otherwise, discard the message.
[0011] In one exemplary implementation, the preset time threshold includes a first time threshold and a second time threshold; generating time filtering results based on the freshness value, the current time slice number, and the preset time threshold includes: The time slice number is determined from the freshness value; The sum of the current time slice number and the first time threshold is determined as the first time slice number; The difference between the current time slice number and the first time threshold is determined as the second time slice number; If the time slice number is less than the first time slice number and greater than or equal to the second time slice number; or if the time slice number is equal to the second time slice number, a first filtering result is generated; the first filtering result indicates that the freshness value is a valid value. If the time slice number is greater than the first time slice number or less than the second time slice number, a second filtering result is generated; the second filtering result indicates that the freshness value is not a valid value.
[0012] In one exemplary implementation, before generating the time filtering result based on the freshness value, the current time slice number, and the preset time threshold, the method further includes: The message body length corresponding to the message is determined from the message header; Determine whether the message body length corresponding to the message is greater than a first length value and less than or equal to a second length value; if yes, then execute the subsequent step of generating a time filtering result based on the freshness value, the current time slice number, and a preset time threshold; if no, then discard the message; the first length value is equal to the length of the freshness value and the length of the first message authentication code in the message.
[0013] On the other hand, a message transmission device is provided, which is deployed at the sending end; including: The first determining module is used to determine the business data and the time slice number corresponding to the business data, and to obtain the historical time slice number and the corresponding historical request number. The second determining module is used to determine the request number corresponding to the business data based on the time slice number corresponding to the business data, the historical time slice number, and the corresponding historical request number. The third determining module is used to determine the freshness value based on the time slice number and request number corresponding to the business data; The first generation module is used to encrypt the time slice number corresponding to the business data and generate a derived key. The first encryption module is used to encrypt the business data, the message header corresponding to the business data and the freshness value using the derived key as the key, to obtain the first message authentication code. The construction module is used to construct a message in the order of the message header corresponding to the business data, the business data, the freshness value and the message authentication code, and send it to the corresponding receiving end.
[0014] On the other hand, a message transmission device is provided, which is deployed at the receiving end; including: The acquisition module is used to acquire messages, parse and extract the messages, and generate the corresponding business data, message header and freshness value of the messages; The fourth module is used to determine the current time slice number; The second generation module is used to generate time filtering results based on the freshness value, the current time slice number, and the preset time threshold; The second encryption module is used to encrypt the time slice number in the freshness value and generate a derived key when the time filtering result indicates that the freshness value is a valid value. The third encryption module is used to encrypt the business data, the message header corresponding to the business data and the freshness value using the derived key as the key, to obtain the second message authentication code. The judgment module is used to determine whether the second message authentication code is consistent with the first message authentication code in the message; if yes, the service data is transmitted; if no, the message is discarded.
[0015] This application embodiment determines business data and its corresponding time slice number, and obtains historical time slice numbers and corresponding historical request numbers; determines the request number corresponding to the business data based on the time slice number, historical time slice number, and corresponding historical request number; determines a freshness value based on the time slice number and request number; encrypts the time slice number corresponding to the business data to generate a derived key; uses the derived key as the key to encrypt the business data, the message header corresponding to the business data, and the freshness value to obtain a first message authentication code; constructs a message according to the order of the message header, the business data, the freshness value, and the message authentication code, and sends it to the corresponding receiving end. This effectively improves the message's anti-forgery and anti-tampering capabilities, and also has the advantages of high compatibility, low modification cost, and easy deployment.
[0016] Figure caption To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0017] Figure 1 This is a schematic diagram of an implementation environment provided in an embodiment of this application; Figure 2 This is a flowchart illustrating a message transmission method provided in an embodiment of this application; Figure 3 This is a message structure diagram provided in an embodiment of this application; Figure 4 This is a flowchart illustrating another message transmission method provided in an embodiment of this application; Figure 5 This is a structural block diagram of a message transmission device provided in an embodiment of this application; Figure 6 This is a structural block diagram of another message transmission device provided in the embodiments of this application. Detailed Implementation
[0018] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this application.
[0019] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or server that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or devices.
[0020] It is understood that in the specific embodiments of this application, data such as user information are involved. When the above embodiments of this application are applied to specific products or technologies, user permission or consent is required, and the collection, use and processing of related data must comply with the relevant laws, regulations and standards of the relevant countries and regions.
[0021] Please see Figure 1 The diagram illustrates an implementation environment provided in this application. The message transmission system can be applied in a vehicle and includes a sender and a receiver, with the sender and receiver communicatively connected. The sender generates a message with a freshness value and an authentication code based on received service data and sends this message to the receiver.
[0022] The receiving end is used to parse and extract received messages, and to verify the integrity and reliability of the messages.
[0023] For example, the message is in the SOME / IP protocol; the sending end and the receiving end are located in the same controller area network.
[0024] For example, the sending end and the receiving end can be any two nodes in the controller local area network.
[0025] Please see Figure 2 The diagram illustrates a flowchart of a message transmission method provided in an embodiment of this application. The transmission method is applied at the sending end and may specifically include: S201: Determine the business data and the time slice number corresponding to the business data, and obtain the historical time slice number and the corresponding historical request number.
[0026] In an exemplary implementation, determining the time slice number corresponding to the service data in step S201 may specifically include: obtaining the global time corresponding to the service data; determining the ratio of the global time corresponding to the service data to the time slice length as the intermediate time slice value; and rounding down the intermediate time slice value to obtain the time slice number corresponding to the service data.
[0027] For example, the GlobalTimeUs() field can return the global time (in microseconds), and the time slice length is a definable parameter, such as 1 millisecond. For instance, if the global time is 654321 microseconds, the intermediate time slice value = 654321 / 1000 = 654.321. Rounding down from 654.321 gives 654, meaning the time slice number is 654. In reality, the time slice number is a 64-bit numeric string; this is just an example.
[0028] For example, the historical time slice number may specifically include multiple historical time slice numbers, and each historical time slice number has multiple historical request codes. Optionally, the request number can be a 16-bit numeric string.
[0029] S203: Determine the request number corresponding to the business data based on the time slice number corresponding to the business data, the historical time slice number, and the corresponding historical request number.
[0030] In an exemplary implementation, step S203 can be specifically described as follows: If a target historical time slot number exists in the historical time slot numbers that matches the time slot number corresponding to the service data; determine the target historical request number corresponding to the target historical time slot number from the request numbers corresponding to the historical time slot number; determine whether the target historical request number is less than a preset request number; if so, determine the sum of the target historical request number and the preset step size as the request number corresponding to the service data; if not, generate an alarm message; if no target historical time slot number exists in the historical time slot numbers that matches the time slot number corresponding to the service data; determine the preset initial number as the request number corresponding to the service data.
[0031] Continuing the example above, we can first determine if time slice number 654 exists in the historical time slice numbers. If it does, it means they belong to the same time slice. We then determine the request numbers contained within time slice number 654. Assuming request numbers are 0, 1, and 2, and the default request number is set to 10 with a default step size of 1, since 2 is less than 10, the request number corresponding to the service data is 3. If the default request number is set to 2, it means the request limit for that time slice is reached. To control the transmission volume, an alarm message can be generated, such as discarding the alarm message or throttling and waiting to proceed to the next time slice. If time slice number 654 does not exist in the historical time slice numbers, it means this service data is the first data in that time slice. The default initial number is 0 or 1, so the request number corresponding to the service data is either 0 or 1.
[0032] For example, the pseudocode can be represented as follows: If slot != last_slot; last_slot=slot; seq_in_slot=0 Otherwise: seq_in_slot++ Here, the time slice number is represented as slot; the previous time slice number is last_slot; and seq_in_slot represents the request number within a time slice.
[0033] S205: Determine the freshness value based on the time slice number and request number corresponding to the business data.
[0034] For example, the freshness value FV = slot(48-bit) || seq(16-bit), where seq represents the request number; FV is a 64-bit numeric string with a capacity of 8 bytes.
[0035] This timecode-based FV construction method can fix the FV to 64-bit and define it as the concatenation of slot and seq to support time window verification and in-window deduplication / out-of-order tolerance.
[0036] Specifically, the method further includes: obtaining the length of the parameter after the message body length in the message header; determining the length of the business data, the length of the freshness value, and the length of the first message authentication code; and determining the sum of the length of the parameter after the message body length in the message header, the length of the business data, the length of the freshness value, and the length of the first message authentication code as the message body length.
[0037] Typically, please refer to Figure 3Taking a message using the SOME / IP protocol as an example, the message header is 16 bytes long, which includes the following concatenated information: Service ID, Method ID, Message Body Length (4 bytes), Request ID (4 bytes), Protocol Version (1 byte), Interface Type (1 byte), Message Type (1 byte), and Return Code (1 byte). At the sending end, the return code can be 0.
[0038] The length of the parameter after the message body length in the message header = RequestID + ProtoVer + IfaceVer + MsgType + RetCode = 8; then Length = 8 + PayloadLen (i.e. the length of the business data) + AuthInfoLen (the sum of the length of the freshness value and the length of the first message authentication code).
[0039] Following Figure 3 The message structure shown is formed by filling the message header.
[0040] Since the freshness value is composed of the time slice number and the request number, it can be managed based on a sliding window, which can achieve engineering feasibility of resisting replay and taking into account out-of-order / jitter.
[0041] S207: Encrypt the time slice number corresponding to the business data to generate a derived key.
[0042] For example, the time slice number can be encrypted using K_master (the master key) to generate a fixed-length string, the derived key K_slot. Optionally, the encryption algorithm used to generate the derived key can be a CMAC function (such as AES-CMAC-128), a symmetric encryption algorithm. For the same time slice, the sender and receiver use the same K_master and the same time slice number, and the independently calculated K_slot will be completely identical.
[0043] It should be noted that when encrypting the time-slice encoding, the time-slice encoding is input into the CMAC function as a fixed 8-byte big-endian sequence, even though only 48 bits of the time-slice encoding are actually used, thus generating a 16-byte derived key. This simplifies the encryption process and avoids complex calculations caused by inconsistent input lengths.
[0044] This time-slice-coded subkey derivation mechanism uses CMAC to derive keys on a time-slice basis, enabling keys to roll over time and limiting the effectiveness of replay attacks. This achieves source authentication and integrity protection for messages, significantly improving anti-forgery and anti-tampering capabilities. Compared to MAC schemes with long-term fixed keys, this method allows authentication keys to roll over time, achieving key isolation and reducing the impact of leaks.
[0045] S209: Using the derived key as the key, encrypt the business data, the message header corresponding to the business data, and the freshness value to obtain the first message authentication code.
[0046] In an exemplary implementation, step S209 can be specifically described as follows: using the derived key as the key, encrypting the business data, the message header corresponding to the business data, and the freshness value to generate an initial message authentication code; truncating the initial message authentication code to obtain a first message authentication code with a preset byte capacity.
[0047] For example, encryption can be performed based on CMAC functions (such as AES-CMAC-128). The input for encryption is MAC_Input = BaseHeader || payload || FV, where the || symbol indicates that all these fields are concatenated in exact order into a complete byte stream; any difference in the order, length, or content of the fields will result in a different final MAC. BaseHeader represents the message header; payload represents the business data; then, the generated first message authentication code MAC1 is truncated, i.e., MAC1 = Truncate_t( CMAC(K_slot, MAC_Input) ), thus generating an 8-byte or 16-byte MAC1. Compared with encrypted tunneling schemes, this AES-CMAC scheme only authenticates and supports truncation, which has the positive effects of low latency, low bandwidth overhead, and adaptability to real-time vehicle communication; and by using BaseHeader, payload, and FV as authentication inputs, the integrity of the header semantics and payload content can be protected without changing the header format. It offers configurable MAC truncation lengths (8B / 16B), achieving an engineering-feasible trade-off between security strength and onboard real-time communication bandwidth.
[0048] The encrypted input in step S209 may also include a data identifier AAD and additional authentication data. Therefore, MAC_Input = [AAD]|| BaseHeader || payload || FV. The CMAC function is used to encrypt MAC_Input and K_slot to obtain the first message authentication code MAC1.
[0049] S211: Construct a message according to the order of the message header corresponding to the business data, the business data, the freshness value and the message authentication code, and send it to the corresponding receiving end.
[0050] Please continue reading. Figure 3 The message constructed in this scheme is: BaseHeader || payload || FV || MAC. It can then be sent (UDP / TCP).
[0051] This solution works based on the premise that the entire vehicle has already been fully deployed with Time-Sensitive Networking (TSN). It generates a freshness value using a time-slice encoding + request number structure, and uses this freshness value as input to a derived key. An authentication code is generated based on global data and the derived key, effectively improving the message's resistance to tampering and forgery. The message transmission method provided in this application can achieve end-to-end authentication and anti-replay protection without modifying any fields in the protocol header. This is achieved by appending a freshness value containing a time-slice encoding and MAC authentication information to the end of the business data, where the freshness value uses a time-slice structure. Furthermore, since it does not change the SOME / IP header fields and only appends a fixed length of authentication information, it achieves high compatibility, low modification costs, and easy deployment.
[0052] On the other hand, please see Figure 4 The diagram illustrates a flowchart of a message transmission method provided in an embodiment of this application. The transmission method is applied at the receiving end and may specifically include: S401: Obtain the message, and perform parsing and extraction operations on the message to generate the corresponding business data, message header and freshness value.
[0053] For example, the message structure can be specifically as follows: Figure 3 As shown above, see the detailed explanation.
[0054] S403: Determine the current time slice number.
[0055] In an exemplary embodiment, before step S405, the method further includes: determining the message body length corresponding to the message from the message header; determining whether the message body length corresponding to the message is greater than a first length value and less than or equal to a second length value; if so, then executing the subsequent step of generating a time filtering result based on the freshness value, the current time slice number, and a preset time threshold; if not, then discarding the message; the first length value is equal to the length of the freshness value and the length of the first message authentication code in the message. That is, checking the validity of the message body length Length; if invalid, the message is directly discarded; if valid, steps S405-S411 are continued.
[0056] For example, the first length value can be calculated based on FV and MAC, and the second length value can be preset. When the length is valid, it indicates that the message contains FV and MAC.
[0057] S405: Generate time filtering results based on the freshness value, the current time slice number, and the preset time threshold.
[0058] In an exemplary implementation, the preset time threshold includes a first time threshold and a second time threshold; step S405 can be specifically described as follows: determining a time slice number from the freshness value; determining the first time slice number as the sum of the current time slice number and the first time threshold; determining the second time slice number as the difference between the current time slice number and the first time threshold; generating a first filtering result when the time slice number is less than the first time slice number and greater than or equal to the second time slice number; or when the time slice number is equal to the second time slice number; the first filtering result indicates that the freshness value is a valid value; generating a second filtering result when the time slice number is greater than the first time slice number or less than the second time slice number; the second filtering result indicates that the freshness value is not a valid value.
[0059] Continuing with the above example, the freshness value here is the complete FV. The specific process for determining the current time slice number can be obtained as in step S201 above, i.e., obtaining the current global time; determining the ratio of the current global time to the time slice length as the intermediate time slice value; and rounding down the intermediate time slice value to obtain the current time slice number. Optionally, the current global time here is the global time that the receiving end considers to be "now" based on its own clock.
[0060] For example, if the time slice number is greater than the first time slice number, it means that the message is future data; if the time slice number is less than the second time slice number, it means that the message is too old and both need to be discarded.
[0061] S407: If the time filtering result indicates that the freshness value is a valid value, the time slice number in the freshness value is encrypted to generate a derived key.
[0062] For details on the process of generating the derived key, please refer to step S207, which will not be elaborated here.
[0063] S409: Using the derived key as the key, encrypt the business data, the message header corresponding to the business data, and the freshness value to obtain the second message authentication code.
[0064] Exemplarily, the encrypted input in step S409 may further include data identifier AAD, an additional authentication data. Therefore, MAC_Input = [AAD] || BaseHeader || payload || FV, and the CMAC function is used to encrypt MAC_Input and K_slot to obtain the second message authentication code MAC2.
[0065] S411: Determine whether the second message authentication code is consistent with the first message authentication code in the message; if so, perform transmission processing on the service data; if not, discard the message.
[0066] In step S411, the first message authentication code and the second message authentication code can be compared based on the constant-time comparison principle to determine whether they are consistent.
[0067] In an exemplary embodiment, the transmission processing of the service data in step S411 may specifically include: determining whether the time slice number in the freshness value is greater than the historical time slice number; if so, update the sliding window corresponding to the time slice number; if not, do not update the sliding window corresponding to the time slice number; determining whether the request number in the freshness value is less than a preset threshold; if so, perform bit setting processing on the request number in the bitmap; otherwise, discard the message.
[0068] When the time slice number slot_rx in the freshness value > highest_slot (the latest legal time slice number seen by the current receiver, which is the front edge of the sliding window), it means that a message of an updated time slice is received. At this time, slide the window forward to update highest_slot to slot_rx; clear all the seq bitmaps corresponding to the time slices that have moved out of the current sliding window (i.e., slot < highest_slot - PastAllowanceSlots). This step reclaims memory and ensures that messages of old slots cannot be accepted again.
[0069] If the request number seq_rx in the freshness value >= SeqWindow (preset threshold), SeqWindow may specifically be a predefined constant representing the maximum sequence number range allowed within each time slice (e.g., 256), which defines the size of the seq bitmap within each slot. If seq_rx >= SeqWindow, it means that the sequence number sent by the sender exceeds the record range reserved by the receiver for this slot, which usually means a protocol synchronization error or a malicious attack. Therefore, directly discard and record the error. Otherwise, set the request number in the bitmap corresponding to this slot.
[0070] It should be noted that the system maintains a bitmap of size SeqWindow for each slot within the sliding window. Each bit corresponds to a seq number (e.g., seq=0 corresponds to bit 0). If the bit value is 1: it indicates that this (slot, seq) combination has been completely received. The system ultimately determines this to be a replay message, discards it, and records it. If the bit value is 0: it indicates that this is a new, first-time occurrence of a sequence number within this slot. The system accepts the message, sets this bit to 1, and then the message can be passed to the upper-layer application. Under the same "protected flow + sender identity": within the same slot: deduplication is achieved using seq, and some out-of-order delivery is allowed. Across slots: slots are used for time window and sliding window control, allowing for delays and out-of-order delivery within the configured range.
[0071] This solution is a receiver verification process based on TSN global time synchronization. It combines time window filtering and seq bitmap deduplication to achieve configurable robustness against delay, out-of-order delivery, and replay.
[0072] This embodiment of the application presents a timecode freshness and message authentication method based on global time synchronization. By appending a fixed-length authentication information to the end of the payload and combining it with a derived key that rolls over time slices and a message authentication code, it achieves sender authentication, integrity protection, and anti-replay capability for SOME / IP messages. It also tolerates a certain amount of network out-of-order delivery and latency jitter within a configurable time window, thus ensuring security while also taking into account the low overhead and engineering deployability of in-vehicle real-time communication.
[0073] Corresponding to the message transmission methods provided in the above embodiments, this application also provides a message transmission device. Since the message transmission device provided in this application corresponds to the message transmission methods provided in the above embodiments, the implementation methods of the aforementioned message transmission methods are also applicable to the message transmission device provided in this embodiment, and will not be described in detail in this embodiment.
[0074] Please see Figure 5 The diagram shows a schematic representation of a message transmission device according to an embodiment of this application. This device has the function of implementing the message transmission method described in the above-described method embodiments. This function can be implemented in hardware or by hardware executing corresponding software. Figure 5 As shown, the message transmission device 500 is deployed at the sending end; it may include: The first determining module 501 is used to determine the business data and the time slice number corresponding to the business data, and to obtain the historical time slice number and the corresponding historical request number. The second determining module 503 is used to determine the request number corresponding to the business data based on the time slice number corresponding to the business data, the historical time slice number, and the corresponding historical request number. The third determining module 505 is used to determine the freshness value based on the time slice number and request number corresponding to the business data; The first generation module 507 is used to encrypt the time slice number corresponding to the business data and generate a derived key. The first encryption module 509 is used to encrypt the business data, the message header corresponding to the business data and the freshness value using the derived key as the key, to obtain the first message authentication code. The construction module 511 is used to construct a message in the order of the message header corresponding to the business data, the business data, the freshness value and the message authentication code, and send it to the corresponding receiving end.
[0075] In an exemplary embodiment, the second determining module is configured to, when there is a target historical time number in the historical time slot numbers that matches the time slot number corresponding to the business data, determine the target historical request number corresponding to the target historical time number from the request numbers corresponding to the historical time number based on the target historical time number; Determine whether the target historical request number is less than a preset request number; if so, determine the sum of the target historical request number and the preset step size as the request number corresponding to the business data; if not, generate an alarm message. If there is no target historical time slot number in the historical time slot numbers that matches the time slot number corresponding to the business data, the preset initial number will be determined as the request number corresponding to the business data.
[0076] In one exemplary implementation, the first determining module is used to obtain the global time corresponding to the business data; The ratio of the global time to the time slice length corresponding to the business data is determined as the intermediate time slice value; The intermediate time slice value is rounded down to the nearest integer to obtain the time slice number corresponding to the service data.
[0077] In an exemplary embodiment, the first encryption module is used to encrypt the business data, the message header corresponding to the business data, and the freshness value using the derived key as the key, and generate an initial message authentication code. The initial message authentication code is truncated to obtain the first message authentication code with a preset byte capacity.
[0078] On the other hand, please see Figure 6 The diagram shows a structural schematic of another message transmission device provided in an embodiment of this application. This application provides a message transmission device deployed at a receiving end; the message transmission device 600 includes: The acquisition module 601 is used to acquire messages, parse and extract messages, and generate business data, message header and freshness value corresponding to the message. The fourth determining module 603 is used to determine the current time slice number; The second generation module 605 is used to generate time filtering results based on the freshness value, the current time slice number, and the preset time threshold; The second encryption module 607 is used to encrypt the time slice number in the freshness value and generate a derived key when the time filtering result indicates that the freshness value is a valid value. The third encryption module 609 is used to encrypt the business data, the message header corresponding to the business data and the freshness value using the derived key as the key, to obtain the second message authentication code. The judgment module 611 is used to determine whether the second message authentication code is consistent with the first message authentication code in the message; if yes, the service data is transmitted; if no, the message is discarded.
[0079] In one exemplary implementation, the judgment module is used to determine whether the time slice number in the freshness value is greater than the historical time slice number; if yes, then the sliding window corresponding to the time slice number is updated; if no, then the sliding window corresponding to the time slice number is not updated. Determine whether the request number in the freshness value is less than a preset threshold; if so, perform bitmap setting on the request number; otherwise, discard the message.
[0080] In one exemplary embodiment, the preset time threshold includes a first time threshold and a second time threshold; the second generation module is used to determine the time slice number from the freshness value; The sum of the current time slice number and the first time threshold is determined as the first time slice number; The difference between the current time slice number and the first time threshold is determined as the second time slice number; If the time slice number is less than the first time slice number and greater than or equal to the second time slice number; or if the time slice number is equal to the second time slice number, a first filtering result is generated; the first filtering result indicates that the freshness value is a valid value. If the time slice number is greater than the first time slice number or less than the second time slice number, a second filtering result is generated; the second filtering result indicates that the freshness value is not a valid value.
[0081] In one exemplary embodiment, the apparatus further includes: The fifth determining module is used to determine the message body length corresponding to the message from the message header; The third generation module is used to determine whether the message body length corresponding to the message is greater than the first length value and less than or equal to the second length value; if so, the subsequent step of generating a time filtering result based on the freshness value, the current time slice number and the preset time threshold is executed; if not, the message is discarded; the first length value is equal to the length of the freshness value and the length of the first message authentication code in the message.
[0082] It should be noted that the apparatus provided in the above embodiments is only illustrated by the division of the above functional modules when implementing its functions. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. In addition, the apparatus and method embodiments provided in the above embodiments belong to the same concept, and the specific implementation process can be found in the method embodiments, which will not be repeated here.
[0083] This application provides an electronic device including a processor and a memory. The memory stores at least one instruction or at least one program, which is loaded and executed by the processor to implement any of the message transmission methods provided in the above method embodiments.
[0084] Memory can be used to store software programs and modules. The processor executes various functional applications and data processing by running the software programs and modules stored in the memory. Memory can primarily include a program storage area and a data storage area. The program storage area can store the operating system, application programs required for the functions, etc.; the data storage area can store data created based on the use of the device, etc. Furthermore, memory can include high-speed random access memory, and can also include non-volatile memory, such as at least one disk storage device, flash memory device, or other volatile solid-state storage device. Accordingly, memory can also include a memory controller to provide the processor with access to the memory.
[0085] Embodiments of this application also provide a computer-readable storage medium, which can be disposed in an electronic device to store at least one instruction or at least one program related to implementing a message transmission method, wherein the at least one instruction or the at least one program is loaded and executed by the processor to implement any of the message transmission methods provided in the above-described method embodiments.
[0086] Embodiments of this application also provide a computer program product or computer program, which includes computer instructions stored in a computer-readable storage medium. A processor of an electronic device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the electronic device to perform any of the message transmission methods provided in the above-described method embodiments.
[0087] Optionally, in this embodiment, the storage medium may include, but is not limited to, various media capable of storing program code, such as USB flash drives, read-only memory (ROM), random access memory (RAM), portable hard drives, magnetic disks, or optical disks.
[0088] It should be noted that the order of the embodiments described above is merely for descriptive purposes and does not represent the superiority or inferiority of the embodiments. Furthermore, specific embodiments have been described above. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps described in the claims can be performed in a different order than that shown in the embodiments and still achieve the desired result. Additionally, the processes depicted in the drawings do not necessarily require a specific or sequential order to achieve the desired result. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0089] The various embodiments in this specification are described in a progressive manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the apparatus embodiments are basically similar to the method embodiments, so the description is relatively simple; relevant parts can be referred to the descriptions of the method embodiments.
[0090] Those skilled in the art will understand that all or part of the steps of the above embodiments can be implemented by hardware or by a program instructing related hardware. The program can be stored in a computer-readable storage medium, such as a read-only memory, a disk, or an optical disk.
[0091] The above description is only a preferred embodiment of this application and is not intended to limit this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.
Claims
1. A method for transmitting a message, characterized in that, Applied to the sending end; including: Determine the business data and the time slice number corresponding to the business data, and obtain the historical time slice number and the corresponding historical request number; The request number corresponding to the business data is determined based on the time slice number corresponding to the business data, the historical time slice number, and the corresponding historical request number. The freshness value is determined based on the time slice number and request number corresponding to the business data. The time slice number corresponding to the business data is encrypted to generate a derived key; Using the derived key as the key, the business data, the message header corresponding to the business data, and the freshness value are encrypted to obtain the first message authentication code; The message is constructed according to the order of the message header corresponding to the business data, the business data, the freshness value and the message authentication code, and sent to the corresponding receiving end.
2. The transmission method according to claim 1, characterized in that, The step of determining the request number corresponding to the business data based on the time slice number corresponding to the business data, the historical time slice number, and the corresponding historical request number includes: If a target historical time slot number exists in the historical time slot number that matches the time slot number corresponding to the business data, the target historical request number corresponding to the target historical time slot number is determined from the request number corresponding to the historical time slot number based on the target historical time slot number. Determine whether the target historical request number is less than a preset request number; if so, determine the sum of the target historical request number and the preset step size as the request number corresponding to the business data; if not, generate an alarm message. If there is no target historical time slot number in the historical time slot numbers that matches the time slot number corresponding to the business data, the preset initial number will be determined as the request number corresponding to the business data.
3. The transmission method according to claim 1, characterized in that, The method for determining the time slice number corresponding to the business data includes: Obtain the global time corresponding to the business data; The ratio of the global time to the time slice length corresponding to the business data is determined as the intermediate time slice value; The intermediate time slice value is rounded down to the nearest integer to obtain the time slice number corresponding to the service data.
4. The transmission method according to any one of claims 1-3, characterized in that, The step of encrypting the business data, the corresponding message header, and the freshness value using the derived key to obtain the first message authentication code includes: Using the derived key as the key, the business data, the message header corresponding to the business data, and the freshness value are encrypted to generate an initial message authentication code. The initial message authentication code is truncated to obtain the first message authentication code with a preset byte capacity.
5. A method for transmitting a message, characterized in that, Applied to the receiving end; including: The message is acquired, and the message is parsed and extracted to generate the corresponding business data, message header and freshness value. Determine the current time slice number; Based on the freshness value, the current time slice number, and the preset time threshold, a time filtering result is generated; If the time filtering result indicates that the freshness value is a valid value, the time slice number in the freshness value is encrypted to generate a derived key; Using the derived key as the key, the business data, the message header corresponding to the business data, and the freshness value are encrypted to obtain the second message authentication code; Determine whether the second message authentication code matches the first message authentication code in the message; if yes, then process the transmission of the service data; if no, then discard the message.
6. The transmission method according to claim 5, characterized in that, The transmission processing of the service data includes: Determine whether the time slice number in the freshness value is greater than the historical time slice number; if yes, update the sliding window corresponding to the time slice number; if no, do not update the sliding window corresponding to the time slice number. Determine whether the request number in the freshness value is less than a preset threshold; if so, perform bitmap setting on the request number; otherwise, discard the message.
7. The transmission method according to claim 5, characterized in that, The preset time threshold includes a first time threshold and a second time threshold; the generation of time filtering results based on the freshness value, the current time slice number, and the preset time threshold includes: The time slice number is determined from the freshness value; The sum of the current time slice number and the first time threshold is determined as the first time slice number; The difference between the current time slice number and the first time threshold is determined as the second time slice number; If the time slice number is less than the first time slice number and greater than or equal to the second time slice number; or if the time slice number is equal to the second time slice number, a first filtering result is generated; the first filtering result indicates that the freshness value is a valid value. If the time slice number is greater than the first time slice number or less than the second time slice number, a second filtering result is generated; the second filtering result indicates that the freshness value is not a valid value.
8. The transmission method according to any one of claims 5-7, characterized in that, Before generating the time filtering result based on the freshness value, the current time slice number, and the preset time threshold, the method further includes: The message body length corresponding to the message is determined from the message header; Determine whether the message body length corresponding to the message is greater than a first length value and less than or equal to a second length value; if yes, then execute the subsequent step of generating a time filtering result based on the freshness value, the current time slice number, and a preset time threshold; if no, then discard the message; the first length value is equal to the length of the freshness value and the length of the first message authentication code in the message.
9. A message transmission device, characterized in that, Deployed on the sending end; includes: The first determining module is used to determine the business data and the time slice number corresponding to the business data, and to obtain the historical time slice number and the corresponding historical request number. The second determining module is used to determine the request number corresponding to the business data based on the time slice number corresponding to the business data, the historical time slice number, and the corresponding historical request number. The third determining module is used to determine the freshness value based on the time slice number and request number corresponding to the business data; The first generation module is used to encrypt the time slice number corresponding to the business data and generate a derived key. The first encryption module is used to encrypt the business data, the message header corresponding to the business data and the freshness value using the derived key as the key, to obtain the first message authentication code. The construction module is used to construct a message in the order of the message header corresponding to the business data, the business data, the freshness value and the message authentication code, and send it to the corresponding receiving end.
10. A message transmission apparatus, characterized in that, Deployed at the receiving end; including: The acquisition module is used to acquire messages, parse and extract the messages, and generate the corresponding business data, message header and freshness value of the messages; The fourth module is used to determine the current time slice number; The second generation module is used to generate time filtering results based on the freshness value, the current time slice number, and the preset time threshold; The second encryption module is used to encrypt the time slice number in the freshness value and generate a derived key when the time filtering result indicates that the freshness value is a valid value. The third encryption module is used to encrypt the business data, the message header corresponding to the business data and the freshness value using the derived key as the key, to obtain the second message authentication code. The judgment module is used to determine whether the second message authentication code is consistent with the first message authentication code in the message; if yes, the service data is transmitted; if no, the message is discarded.