Message verification method based on anti-replay window
By using monotonic incremental sequence encoding and synchronous anti-playback window detection in multi-received scenes, the window state synchronization problem in multi-received scenes is solved, and efficient and secure message transmission and terminal state synchronization are achieved.
Patent Information
- Application Number
- CN202510560113.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-30
- Publication Date
- 2025-07-11
AI Technical Summary
The existing anti-replay attack mechanism is difficult to maintain the window state synchronization in multiple receiving end scenarios, resulting in message missed or repeated detection. Incorrect users can attack other terminals by replaying messages, occupying system resources and reducing processing efficiency.
Monotonically increasing sequence encoding is generated based on timestamps and port numbers. The server sends messages and encodes them simultaneously to multiple terminals. The terminal generates an initial anti-playback window and performs playback detection, and updates the window status to ensure the consistency and security of the message sequence.
It improves the reliability and efficiency of message transmission, reduces network overhead, enhances security, avoids unnecessary key consumption, and optimizes system processing efficiency.
Smart Images

Figure CN120301675A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of network security technologies, and in particular, to a message verification method based on an anti-replay window. Background Art
[0002] In the field of network security communication, the anti-replay attack mechanism is a key technology to ensure the integrity and timeliness of data transmission. Currently, there are mainly three anti-replay mechanisms commonly used in the industry, namely challenge, timestamp, and sliding window mechanisms. The traditional sliding window determination scheme is often for the case of a single sender and a single receiver. The receiver maintains a fixed or sliding window and only receives new data packets that fall within the window range, discarding duplicate or expired data packets. The case of a single sender and a single receiver is only applicable to point-to-point communication and cannot adapt to the multi-receiver scenario. If a certain receiver fails to update the window in a timely manner due to network latency, legitimate packets may be misjudged as replay attacks. Therefore, the anti-replay attack mechanism faces significant technical limitations in a multi-receiver architecture.
[0003] If multiple terminals want to be accessed, in the case of multiple senders and multiple receivers, due to the differences in the network conditions and processing capabilities of each receiver, it is difficult to keep the anti-replay window states synchronized, resulting in problems such as message omission or duplicate detection. The sender needs to maintain the states of a large number of messages, resulting in a large memory overhead. If there are network state jitters or delays, packet loss often occurs. At the same time, criminals capture a series of packets and directly replay them to other terminals without any modification, and still can forward relay messages. Moreover, the receiver will consider the message legal, thereby consuming the receiver's key. In fact, the packet is not the message that the receiver needs to receive, which will bring unnecessary key stock usage problems to the receiver of the relay message.
[0004] In the actual application process, for the application scenario of multiple senders and multiple receivers, the communicating sender and receiver are often separated and turned into a scenario of a single sender and a single receiver to perform anti-replay strategy processing. Such a practice requires that for each communication, a single terminal network element device establishes an anti-replay window for this communication. When this communication ends and a new communication is to be established next time, a new anti-replay window needs to be created for the next communication. Then, for multiple communications, multiple anti-replay windows need to be established for processing, and these multiple windows are separate. The number of anti-replay windows corresponds to the number of times the server communicates with it. In the case of a large number of communication interruptions, it will seriously occupy the system processing memory and reduce the system processing efficiency; moreover, it cannot effectively avoid the situation where illegal users replay the messages sent by the server to other receiving terminals. Therefore, there is an urgent need for a message verification method that can adapt to a multi-receiver environment and ensure detection accuracy and efficiency. Summary of the Invention
[0005] Objective of the Invention: This application provides a message verification method based on an anti-replay window to solve the problems existing in the background art.
[0006] Technical Solution: The present invention provides a message verification method based on an anti-replay window. The participants in the method include a server and a set of terminals. The set of terminals includes a first terminal and a second terminal. The method includes the following steps:
[0007] Step 1: The server performs non-repetitive sequence encoding on the messages to be sent, and transmits the messages with different sequence encodings to the first terminal and the second terminal respectively;
[0008] Step 2: After receiving the message, the first terminal generates an initial anti-replay window locally;
[0009] Step 3: The first terminal performs a replay detection operation on the received message and updates the local anti-replay window during message processing.
[0010] As an improvement of the present invention, in Step 1, the server's non-repetitive sequence encoding of the messages to be sent includes:
[0011] The server generates a monotonically increasing sequence encoding based on the timestamp, source port number, and destination port number included in each message; the sequence encoding is the basis for the server's message transmission data order.
[0012] As an improvement of the present invention, in Step 1, the transmitting of the messages with different sequence encodings to the first terminal and the second terminal respectively specifically includes:
[0013] The server sequentially sends the messages to the corresponding terminals in ascending order of the sequence encoding based on the destination port number in the message;
[0014] The server synchronously sends the sequence encoding of the message sent to the second terminal to the first terminal, and synchronously sends the sequence encoding of the message sent to the first terminal to the second terminal.
[0015] As an improvement of the present invention, the specific process of Step 2 is:
[0016] When the first terminal receives the message for the first time, it reads the sequence encoding Seq in the message, and constructs a closed interval [Seq, Seq + L - 1] as the valid range of the initial anti-replay window based on the sequence encoding Seq and the anti-replay window size L;
[0017] The message status in the initial anti-replay window is all 0.
[0018] As an improvement of the present invention, the specific process of step 2 may be:
[0019] When the first terminal receives a message for the Nth time, obtain the sequence code lasSeq of the message received for the (N - 1)th time, and calculate the boundaries of the initial anti-replay window based on the sequence code lasSeq and the anti-replay window length L:
[0020]
[0021] Check the validity of the boundaries: Check the value of the left boundary. If the left boundary value < 0, construct the closed interval [0, L - 1] as the valid range of the initial anti-replay window; otherwise, construct the closed interval as the valid range of the initial anti-replay window;
[0022] The message status in the initial anti-replay window is all 0.
[0023] As an improvement of the present invention, the specific process of step 3 is:
[0024] When the first terminal receives a new message, confirm whether the new message carries message content:
[0025] If not, update the status of the new message in the anti-replay window to 1 based on the sequence code of the new message;
[0026] If it carries, judge whether the new message is a replay packet according to the following operations:
[0027] If the sequence code Seq of the new message < the left boundary value, it is a replay message, and discard the new message;
[0028] If the left boundary value ≤ the sequence code Seq of the new message < the right boundary value, check whether the status of the new message in the anti-replay window is 1. If so, discard the message; otherwise, the first terminal processes the new message and updates the status of the new message in the anti-replay window to 1;
[0029] If the sequence code Seq of the new message ≥ the right boundary value, the first terminal updates the local anti-replay window boundary, processes the message with the sequence code Seq, and updates the status of the sequence code Seq in the updated anti-replay window to 1.
[0030] As an improvement of the present invention, the specific process for the first terminal to update the local anti-replay window boundary is:
[0031] Using the sequence encoding of the new message as the middle position of the replay protection window to be updated, calculate the boundaries of the replay protection window to be updated:
[0032]
[0033] Construct a closed interval as the valid range of the updated replay protection window.
[0034] As an improvement of the present invention, there is also provided an electronic device, including: at least one processor; and a memory communicatively connected to the at least one processor; wherein, the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute the message verification method based on the replay protection window described above.
[0035] As an improvement of the present invention, there is also provided a computer-readable storage medium storing a computer program, and when the computer program is executed by a processor, it implements the message verification method based on the replay protection window described above.
[0036] Advantageous effects:
[0037] 1. When the server of the present invention distributes messages to each terminal, it not only sends the message content, but also synchronously sends the sequence encoding of the messages sent to other terminals to ensure that each terminal can perceive and synchronize the receiving status of all parties. Even when the network is unstable, the message sequence consistency and status synchronization can be maintained between different terminals, thereby improving the reliability and orderliness of message transmission, and also maintaining the coherence of the replay protection window during the terminal processing.
[0038] 2. Each terminal can perceive the latest receiving progress of all parties in real time. For messages not processed by this terminal, only the sequence encoding needs to be received, without additional ACK packets and without processing the message content. While reducing the occupied network overhead, it optimizes the utilization rate of network resources, enables the transmission of messages to be more efficient and fast, and reduces the delay caused by transmission.
[0039] 3. The sequence encoding provided by the present invention is unique, so that different messages corresponding to different sequence encodings are also unique, and the uniqueness of the messages effectively improves the security during the transmission process.
[0040] 4. The replay protection detection efficiency is high. It can implement the function of replay protection detection for all messages of all terminals in this terminal group, which can reduce the consumption of keys at the receiving end, avoid the problem of using unnecessary key stocks, reduce the number of key replenishments, and thus improve the data processing efficiency of the system. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] To more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the accompanying drawings required for the description of the embodiments. Obviously, the accompanying drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, without creative efforts, other accompanying drawings can be obtained based on these drawings.
[0042] Figure 1 Structural schematic diagram of the participants in the method of the present application;
[0043] Figure 2 Flow schematic diagram of the method of the present application;
[0044] Figure 3 Exemplary schematic diagram of step 1 of the method of the present application. Detailed implementation manners
[0045] In order to make the objectives, technical solutions and advantages of the present application clearer, the following further describes the present application in detail with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, rather than all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts belong to the scope of protection of the present application.
[0046] The present invention provides a message verification method based on an anti-replay window, as Figure 1 shown. The participants in the method include a server and a set of terminals. Each terminal in the set of terminals is connected to the server and is under the jurisdiction of the server. The set of terminals includes a first terminal and a second terminal. In the embodiments of the present invention, the set of terminals of course further includes other terminals other than the first terminal and the second terminal. However, taking the first terminal and the second terminal as examples is sufficient to illustrate the solution described in the present application. The processing of other terminals can be carried out by referring to the first terminal and the second terminal here.
[0047] In the embodiments of the present invention, as Figure 2 shown, the method of the present invention includes the following steps:
[0048] Step 1: The server performs non-repetitive sequence encoding on the messages to be sent, and transmits the messages carrying different sequence encodings to the first terminal and the second terminal respectively;
[0049] Specifically, the server performs sequence encoding on all the messages to be sent, and the sequence encodings of all the generated messages are non-repetitive, for example, monotonically increasing. More specifically, the server can generate a monotonically increasing sequence encoding based on the timestamp, source port number, destination port number, etc. included in each message.
[0050] For example, among all messages, a monotonically increasing sequence code is first generated according to the chronological characteristics of the timestamps. If the timestamps are the same, the sequence code is generated according to the order of the source port number and the destination port number. For example, among messages with the same timestamp, the message sequence number with the destination port number of the first terminal is prior. Another example is to combine the timestamp and the port number to ensure that the sequence numbers of messages on the same connection are monotonically increasing. At the same timestamp, the IDs of different port connections are distinguished by the port part, such as by extending the number of digits of the sequence code. In short, when the sequence code at the same timestamp is exhausted, the message can be blocked and wait for the next time unit to generate a new sequence code for the message; or extend the number of digits of the sequence code, such as 1-1, 1-2; this ensures that the generated sequence code is monotonically increasing. The generated sequence code is the basis for the server to transmit message data in order, so that all messages can be transmitted orderly among different terminals, effectively ensuring the orderliness and uniqueness of the messages.
[0051] In step 1, the step of respectively transmitting messages with different sequence codes to the first terminal and the second terminal specifically includes:
[0052] Based on the destination port number in the message, the server sequentially sends the messages to the corresponding terminals in the order of increasing sequence code; for example, as Figure 3 shown, based on the sequence codes generated according to the destination port number and the timestamp in the message, the server sends the messages with sequence codes 1, 2, and 6 to the first terminal, and sends the messages with sequence codes 3, 4, 5, and 9 to the second terminal.
[0053] The server synchronously sends the sequence codes of the messages sent to the second terminal to the first terminal, and synchronously sends the sequence codes of the messages sent to the first terminal to the second terminal. Still taking the above example, while the first terminal processes the messages with sequence codes 1, 2, and 6, it will also synchronously receive the sequence codes of the messages 3, 4, 5, and 9 sent to the second terminal; similarly, while the second terminal processes the messages with sequence codes 3, 4, 5, and 9, it will also synchronously receive the sequence codes of the messages 1, 2, and 6 sent to the first terminal.
[0054] The present invention can also adopt a composite coding structure to generate a non-repetitive and reliable sequence code based on a timestamp, source port number, destination port number, checksum, hash check value (not mentioned in this article), etc., establish an independent message sequence control system, and adopt a distributed mechanism to ensure sequence code synchronization. Specifically, when the server distributes messages to each terminal, it not only sends the message content but also synchronizes the sequence code of the message to ensure that each terminal can perceive the receiving status of each party, and the message order consistency and status synchronization can also be maintained between different terminals, thereby improving the reliability and orderliness of message transmission. Each terminal can perceive the latest receiving progress of each party in real time. For the messages not processed by the local terminal, only the sequence code needs to be received, without additional ACK packets, nor the need to process the message content, reducing the occupied network overhead while optimizing the utilization rate of network resources, enabling the transmission of messages to be more efficient and fast, and reducing the delay caused by transmission. The uniqueness given to the sequence code by the timestamp, source port number, destination port number, checksum, hash check value, etc. makes the different messages corresponding to different sequence codes also unique, and the uniqueness of the messages effectively improves the security during the transmission process.
[0055] Step 2: After receiving the message, the first terminal generates an initial anti-replay window locally;
[0056] In some scenarios, each terminal can generate an initial anti-replay window based on information such as the message number Seq, window bitmap bitset, window size L, etc. when receiving the first message for the first time. The left boundary of the initial anti-replay window is the sequence code Seq of the first message received, and the right boundary of the window is Seq + L. In the embodiment of the present invention, when the first terminal receives the message for the first time, it reads the sequence code Seq in the message and constructs a closed interval [Seq, Seq + L - 1] based on the sequence code Seq and the anti-replay window size L as the effective range of the initial anti-replay window. It should be noted that the message status in the initial anti-replay window is all 0.
[0057] Among them, the window bitmap bitset indicates the data structure of the window, uses a bitmap to mark the window space, and is used to efficiently represent and operate on a set of binary bits (0 or 1). Each bitmap can be accessed or modified independently. In the embodiment of the present invention, a message status of 0 means that the window bitmap corresponding to the message is 0. The window length L is the width of the sliding window maintained in the anti-replay mechanism, indicating the number of messages that the window can include. For example, L being 10 indicates that the initial anti-replay window can accommodate at most 10 messages.
[0058] In some other scenarios, each terminal can generate an anti-replay window based on information such as the last message number lastSeq, window bitmap bitset, window size L, etc. during the process of receiving messages. For example, when receiving the 7th message, or when receiving an instruction for anti-replay message detection. The left boundary of the anti-replay window is [last message number - [window size / 2]], and the right boundary is [last message number + [window size / 2]]; if [last message number - [window size / 2]] < 0, then adjust the window so that the left boundary is 0 and the right boundary is L. In this scenario, the specific process for the first terminal to generate the initial anti-replay window is as follows: When the first terminal receives a message for the Nth time, obtain the sequence code lasSeq of the message received for the (N - 1)th time, and calculate the boundaries of the initial anti-replay window based on the sequence code lasSeq and the anti-replay window length L:
[0059]
[0060] Verify the validity of the boundaries: Check the value of the left boundary. If the left boundary value < 0, then construct the closed interval [0, L - 1] as the valid range of the initial anti-replay window; otherwise, construct the closed interval as the valid range of the initial anti-replay window;
[0061] The message status in the initial anti-replay window is all 0.
[0062] Step 3: The first terminal performs a replay detection operation on the received message and updates the local anti-replay window during message processing.
[0063] In an embodiment of the present invention, after the server sends a message to the first terminal once, it will send messages to other terminals (for example: the second terminal) subsequently. At this time, the server will synchronously send the sequence code of the message sent to other terminals to the first terminal. The first terminal updates the message status in the initial anti-replay window based on the sequence code of the received message within its own initial anti-replay window, and updates the "unprocessed" flag to the "processed" flag. For example, use 0 to represent unprocessed and 1 to represent processed to record that the message corresponding to the sequence code has been processed by this terminal or other terminals.
[0064] Specifically, when the first terminal receives a new message, confirm whether the new message carries message content:
[0065] If not, that is, the new message only has a sequence code, then trigger the update operation of the "unprocessed" flag: Update the status of the new message in the anti-replay window to 1 based on the sequence code of the new message;
[0066] If carried, that is, the new message has both a message sequence code and a message content, indicating that the message is the content to be processed by this first terminal, then it is necessary to use the initial anti-replay window to perform anti-replay detection on the new message, that is, to determine whether the new message is a replayed packet according to the following operations:
[0067] If the sequence code Seq of the new message < left boundary value, it is a replayed message, and a discard operation is performed on the new message;
[0068] If the left boundary value ≤ the sequence code Seq of the new message < right boundary value, check whether the status of the new message in the anti-replay window is 1. If so, it means that the message is in the "processed" state, and a discard operation is performed on the message; otherwise, it means that the message is in the "unprocessed" state. The first terminal processes the new message and updates the status of the new message in the anti-replay window to 1 to avoid repeated execution and occupying system resources if the same message comes in next time;
[0069] If the sequence code Seq of the new message ≥ right boundary value, the first terminal updates the local anti-replay window boundary: use the sequence code of the new message as the middle position of the anti-replay window to be updated, and calculate the boundaries of the anti-replay window to be updated:
[0070]
[0071] Construct a closed interval As the effective range of the updated anti-replay window;
[0072] Process the message with sequence code Seq, and at the same time update the status of sequence code Seq in the updated anti-replay window to 1.
[0073] Through the method in the above embodiments, the first terminal can receive not only the sequence codes of all messages that the terminal itself needs to process, but also synchronously receive the sequence codes of the messages processed by other terminals connected to the server. In order to communicate with the server, each terminal in the terminal set must have a symmetric key file with the server. Moreover, in order to avoid having too many key files in the server, when the key file is sufficient to process communication information, there can be only one key file in the server, and each terminal has the same key file as the server. In such a case, however, malicious users may replay the messages sent to the second terminal to the first terminal to consume the keys of the first terminal, achieving the purpose of replay attack. But by using the method described in this application, the first terminal also synchronously records the sequence codes of the messages sent to other terminals, which can effectively resist the aforementioned replay attack. The first terminal can effectively detect the messages sent to other terminals in the anti-replay window, reducing the consumption of keys at the receiving end, avoiding the problem of using unnecessary key stocks, reducing the number of key replenishments, and thus improving the data processing efficiency of the system.
[0074] In an embodiment of the present invention, the present invention also provides an electronic device, including: at least one processor; and a memory communicatively connected to the at least one processor; wherein, the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute the message verification method based on an anti-replay window as described above.
[0075] In an embodiment of the present invention, the present invention also provides a computer-readable storage medium storing a computer program, and when the computer program is executed by a processor, it implements the message verification method based on an anti-replay window as described above.
Claims
1. A message verification method based on an anti-replay window, characterized in that, The participants in the method include a server and a set of terminals. The set of terminals includes a first terminal and a second terminal. The method includes the following steps: Step 1: The server performs non-repetitive sequence encoding on the messages to be sent, and transmits the messages carrying different sequence encodings to the first terminal and the second terminal respectively; Step 2: After receiving the message, the first terminal generates an initial anti-replay window locally; Step 3: The first terminal performs a replay detection operation on the received message and updates the local anti-replay window during message processing.
2. The message authentication method based on an anti-replay window according to claim 1, wherein In Step 1, the server's non-repetitive sequence encoding of the messages to be sent includes: The server generates a monotonically increasing sequence encoding based on the timestamp, source port number, and destination port number included in each message; the sequence encoding is the basis for the server's order of message transmission data.
3. The message authentication method based on an anti-replay window according to claim 1, wherein In Step 1, the specific process of transmitting the messages carrying different sequence encodings to the first terminal and the second terminal respectively includes: The server sequentially sends the messages to the corresponding terminals in ascending order of the sequence encoding based on the destination port number in the message; The server synchronously sends the sequence encoding of the message sent to the second terminal to the first terminal, and synchronously sends the sequence encoding of the message sent to the first terminal to the second terminal.
4. The message authentication method based on an anti-replay window according to claim 3, wherein, The specific process of Step 2 is: When the first terminal receives a message for the first time, it reads the sequence encoding Seq in the message, and constructs a closed interval [Seq, Seq + L - 1] based on the sequence encoding Seq and the anti-replay window size L as the effective range of the initial anti-replay window; The message status in the initial anti-replay window is all 0.
5. The message authentication method based on an anti-replay window according to claim 3, wherein The specific process of Step 2 may also be: When the first terminal receives a message for the Nth time, it obtains the sequence encoding lasSeq of the message received for the (N - 1)th time, and calculates the boundary of the initial anti-replay window based on the sequence encoding lasSeq and the anti-replay window length L: Verify the validity of the boundary: Check the value of the left boundary. If the left boundary value < 0, then construct a closed interval [0, L - 1] as the valid range of the initial anti-replay window; otherwise, construct a closed interval as the valid range of the initial anti-replay window; The message status in the initial anti-replay window is all 0.
6. The message authentication method based on an anti-replay window according to claim 4 or 5, wherein In the specific process of Step 3: When the first terminal receives a new message, it confirms whether the new message carries message content: If not, it updates the status of the new message in the anti-replay window to 1 based on the sequence encoding of the new message; If it carries, the following operations are used to determine whether the new message is a replay packet: If the sequence encoding Seq of the new message < the left boundary value, it is a replay message, and the new message is discarded; If the left boundary value ≤ the sequence encoding Seq of the new message < the right boundary value, it is checked whether the status of the new message in the anti-replay window is 1. If so, the message is discarded; otherwise, the first terminal processes the new message and updates the status of the new message in the anti-replay window to 1; If the sequence encoding Seq of the new message ≥ the right boundary value, the first terminal updates the local anti-replay window boundary, processes the message with the sequence encoding Seq, and updates the status of the sequence encoding Seq in the updated anti-replay window to 1.
7. The message authentication method based on an anti-replay window according to claim 6, wherein The specific process for the first terminal to update the local anti-replay window boundary is as follows: Using the sequence encoding of the new message as the middle position of the anti-replay window to be updated, calculate the boundaries of the anti-replay window to be updated: Construct a closed interval As the effective range of the updated anti-replay window.
8. An electronic device, characterized in that, Including: At least one processor; And a memory communicatively connected to the at least one processor; wherein, the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute the message verification method based on an anti-replay window according to any one of claims 1 to 7.
9. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the message verification method based on an anti-replay window according to any one of claims 1 to 7.