Communication method and device for preventing replay attack
By introducing a mechanism of random values and time windows in wireless communication of the ESB protocol, the problem of lack of security measures in the ESB protocol is solved, and safe communication and playback attack protection for devices without timekeeping functions are achieved.
Patent Information
- Application Number
- CN202311153422.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-07
- Publication Date
- 2025-03-07
AI Technical Summary
The ESB protocol lacks security measures in wireless communications, which cannot prevent replay attacks, resulting in low communication security.
The effectiveness of the data frame is confirmed by introducing random values and time windows between devices without timer function to prevent replay attacks. Specific steps include request and reply frame transmission between devices, confirmation of data frames and transmission of end frames, and synchronization and verification using random values and time windows.
It realizes secure communication between timeless devices, prevents playback attacks, reduces computing complexity and maintains low latency, and is suitable for microcontrollers with strictly limited computing resources.
Smart Images

Figure CN119583086A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of communication technology, and in particular to a communication method, device and computer storage medium for preventing replay attacks. Background Art
[0002] The Enhanced ShockBurst (ESB) protocol is a basic protocol that supports bidirectional packet communication, including packet buffering, packet confirmation, and automatic retransmission of lost packets. ESB enables ultra-low power and high-performance communication with low-cost host microcontrollers, which can significantly improve the power efficiency of bidirectional and unidirectional systems without increasing the complexity of the host controller side.
[0003] Currently, the ESB protocol is mostly used in various wireless communication chips of Nordic. The ESB data packet contains a preamble (1 byte), an address (3-5 bytes), a data packet control (9 bits), a payload (0-32 bytes) and a CRC field (1-2 bytes).
[0004] However, the ESB protocol has no security measures. It only ensures that data is sent and received correctly, and has low security. Summary of the invention
[0005] An embodiment of the present application provides a communication method for preventing replay attacks, the method being used for data frame transmission between a first device without a timing function and a second device, the data frame structure including a random value and a time window, the method including:
[0006] The first device sends a request frame for establishing communication to the second device;
[0007] When the first device receives the response frame sent by the second device within the time window, the first device confirms whether the response frame is valid according to the random value;
[0008] If the response frame is valid, the first device sends a data frame to the second device;
[0009] The first device receives a confirmation frame sent by the second device;
[0010] The first device continues to send data frames to the second device until data sending is completed, and the first device sends an end frame to the second device.
[0011] In some embodiments, the request frame includes an initial random value, and after the first device sends a request frame to establish communication to the second device, the step further includes:
[0012] The first device calculates the time window, and counts the initial random value according to the time interval until the response frame is received, to obtain a first random value.
[0013] In some embodiments, the response frame includes a second random value, and the step of the first device confirming whether the response frame is valid according to the random value includes:
[0014] determining an error between the first random value and the second random value;
[0015] If the error is not greater than the maximum error value, the response frame is confirmed to be valid.
[0016] In some embodiments, it also includes:
[0017] When the random value reaches a predetermined threshold, the first device resends a request to establish communication.
[0018] The embodiment of the present application also provides a communication method for preventing replay attacks, the method is used for data frame transmission between a first device without a timing function and a second device, the data frame structure includes a random value and a time window, and the method includes:
[0019] The second device receives a request frame for establishing communication sent by the first device;
[0020] The second device sends a response frame within the time window and calculates the time window;
[0021] When the second device receives the data frame sent by the first device within the time window, confirming whether the data frame is normal according to the random value;
[0022] If the data frame is normal, the second device sends a confirmation frame within the time window;
[0023] Continue to receive the data frame sent by the first device until an end frame sent by the first device is received.
[0024] In some embodiments, before sending the response frame within the time window, the method further includes:
[0025] Before the step of receiving the response frame sent by the second device, the method further includes:
[0026] After receiving the request frame, the second device counts the initial random value according to the time interval to obtain a second random value;
[0027] The second device sends a response frame including the second random value to the first device within the time window.
[0028] In some embodiments, the data frame includes a third random value, the second device includes a fourth random value, and the step of confirming whether the data frame is normal according to the random value includes:
[0029] Obtaining an error between the third random value and the fourth random value;
[0030] If the error is not greater than the maximum error value, and the time of receiving the data frame does not exceed the time window, then the data frame is confirmed to be normal;
[0031] Otherwise, it is confirmed that the data frame is abnormal.
[0032] In some embodiments, if the error is not greater than the maximum error value, the second device replaces the fourth random value with the third random value.
[0033] The embodiment of the present application further provides a communication device for preventing replay attacks, the device being used for data frame transmission between a first device without a timing function and a second device, the data frame structure comprising a random value and a time window, the device comprising:
[0034] A first sending module, used for sending a request frame for establishing communication to the second device;
[0035] A first receiving module, configured to, when receiving a response frame sent by the second device within the time window, confirm whether the response frame is valid according to the random value;
[0036] The first sending module is further configured to send a data frame to the second device if the response frame is valid;
[0037] The first receiving module is further used to receive a confirmation frame sent by the second device;
[0038] The first sending module is further used to continue sending data frames until the data sending is completed and send an end frame.
[0039] The embodiment of the present application further provides a communication device for preventing replay attacks, the device being used for data frame transmission between a first device without a timing function and a second device, the data frame structure including a random value and a time window, the device including:
[0040] A second receiving module, used to receive a request frame for establishing communication sent by the first device;
[0041] A second sending module, used for sending a response frame within the time window and calculating the time window;
[0042] The second receiving module is further configured to, when receiving a data frame sent by the first device within the time window, confirm whether the data frame is normal according to the random value;
[0043] The second sending module is further configured to cause the second device to send a confirmation frame within a time window if the data frame is normal;
[0044] The second receiving module is further used to continuously receive the data frames sent by the first device until an end frame sent by the first device is received.
[0045] An embodiment of the present application also provides an electronic device, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program implements the steps of any one of the methods described in the above embodiments when executed by the processor.
[0046] An embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the method described in any one of the above embodiments are implemented.
[0047] At least one of the above technical solutions adopted in the embodiments of the present application can achieve the following beneficial effects:
[0048] The synchronization problem of the communicating parties is solved by comparing the random values of the first device and the second device within the same time window without adding new hardware. It can not only achieve the security of devices without time functions in communication and prevent replay attacks, but also reduce the calculation complexity due to the simple structure, thereby maintaining a low delay. The method of the above embodiment can be deployed on a single-chip microcomputer with extremely strict computing resource control, thereby improving versatility. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0050] Figure 1 A flowchart of a communication method for preventing replay attacks according to some embodiments of the present application;
[0051] Figure 2 A flowchart of a communication method for preventing replay attacks according to some embodiments of the present application;
[0052] Figure 3 A flowchart of a communication method for preventing replay attacks according to some embodiments of the present application;
[0053] Figure 4A flowchart after the step of sending a request frame for establishing communication in some embodiments of the present application;
[0054] Figure 5 A schematic diagram of a process of confirming whether a data frame is normal in some embodiments of the present application;
[0055] Figure 6 A structural block diagram of a communication device for preventing replay attacks in some embodiments of the present application;
[0056] Figure 7 A structural block diagram of a communication device for preventing replay attacks in some embodiments of the present application;
[0057] Figure 8 This is a schematic diagram of the structure of an electronic device according to some embodiments of the present application. DETAILED DESCRIPTION
[0058] In order to make the purpose, technical solution and advantages of the present application clearer, the technical solution of the present application will be clearly and completely described below in combination with the specific embodiments of the present application and the corresponding drawings. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present application.
[0059] Communication chips based on the ESB protocol usually have functions such as CRC check, preamble, and signal encoding. These functions only ensure the accuracy of wireless communication, but cannot prevent replay attacks. For example, the signal of sending the letter A is exactly the same as the signal of sending the letter A every time. This means that the attacker can record the signal of sending the letter A and repeatedly send the letter A, thus interfering with the communication.
[0060] Because the module or chip based on the ESB protocol itself does not have the function of calculating time, in order to reduce the demand for hardware and reduce costs, the present application proposes a communication method to prevent replay attacks. The method is used for data frame transmission between a first device and a second device without a timing function, and the first device and the second device are, for example, modules or chips based on the ESB protocol class. The type and model of the first device can be the same or different, and "first" and "second" are only used for the convenience of explaining the solution of the present application and cannot be used as a limitation of the present application.
[0061] In addition, in an embodiment of the present application, the first device and the second device are both integrated or connected to a random number generator for generating a random value. In some examples, the random value is in hexadecimal, or in other formats, which are not limited here. The data frame structure of the transmission includes a random value, a time interval, a time window, a maximum error value, and a frame type. The frame length is 32 bits (bite), the time interval is a predetermined time length in milliseconds, and the time window can also be a predetermined time length, such as 10ms, which is not specifically limited here.
[0062] The following uses hexadecimal numbers as an example to supplement the data format, but it is not intended to limit this application:
[0063] Random value (4 bytes): range 0x00000000~0xfffffff, used to verify whether the time synchronization of both communicating parties is correct. It is increased by 1 after each time interval, and resynchronization is required after it is full. The synchronization method is based on the requesting end (the first device).
[0064] Time window (4 bits): 0x0~0xf, unit: milliseconds. After sending a data message, if no correct reply is received within the time window, the communication is considered to be over.
[0065] Maximum error value (4 bits): 0x0~0xf, the difference between the random values of the communicating parties. If the difference between the random values is not greater than the maximum error value, the synchronization between the first device and the second device is normal. Otherwise, it is regarded as an error frame and the communication ends.
[0066] Time interval (4 bits): 0x0~0xf, unit: milliseconds ms, the time interval for random value accumulation.
[0067] Frame type (4 bits): Request frame: 0000, Response frame: 0001, Data frame: 0010, End frame: 0011. Synchronization (large random value error) error: 1000, Time window expired: 1001, Error response: 1010.
[0068] The technical solutions provided by various embodiments of the present application are described in detail below in conjunction with the accompanying drawings.
[0069] In some embodiments, Figure 1 and Figure 2 As shown, the present application proposes a communication method for preventing replay attacks, the method comprising:
[0070] Step 101: The first device sends a request frame for establishing communication to the second device.
[0071] The first device sends a request frame for establishing communication to the second device. In this embodiment, the request frame includes a random value (4 bytes) and a frame type (4 bits) in addition to a time window (4 bits), a maximum error value (4 bits), and a time interval (4 bits). The random value is a first initial random value generated by a random number generator of the first device, and the frame type is a request frame.
[0072] Step 102: When the first device receives a response frame sent by the second device within the time window, the first device confirms whether the response frame is valid according to the random value.
[0073] After receiving the request for establishing communication sent by the first device, the second device will send a response frame within the time window to establish a link.
[0074] In this embodiment, the response frame includes a random value (4 bytes) and a frame type (4 bits) in addition to a time window (4 bits), a maximum error value (4 bits) and a time interval (4 bits). The second initial random value is generated by a random number generator of the second device, and after receiving the request frame, the second initial random value is counted at each time interval to obtain a random value, and the frame type is a response frame.
[0075] When the first device receives the response frame within the time window, it compares the random value received from the second device with the random value of the first device to obtain a comparison result. If the comparison result meets the predetermined condition, the received response frame is determined to be valid, otherwise, the response frame is confirmed to be invalid.
[0076] When the response frame is invalid, the communication is re-established, that is, step 101 is re-executed.
[0077] Step 103: If the response frame is valid, the first device sends a data frame to the second device.
[0078] When the response frame is valid, the first device sends a data frame to the second device. In this embodiment, the data frame includes a time window (4 bits), a maximum error value (4 bits), and a time interval (4 bits), as well as a random value (4 bytes), a frame type (4 bits), and data (0 to 26 bytes). The frame type is a data frame.
[0079] Step 104: The first device receives a confirmation frame sent by the second device.
[0080] After the first device sends a data frame to the second device, the second device will confirm whether the received data frame is normal. If the data frame is normal, the second device will send a confirmation frame to the first device.
[0081] Step 105: The first device continues to send data frames until data sending is completed, and the first device sends an end frame to the second device.
[0082] After receiving the confirmation frame, the first device continues to send data frames, that is, repeatedly executes step 103 and step 104 until the data sending is completed.
[0083] During the data transmission process, when the random value reaches a predetermined threshold, step 101 is executed again.
[0084] In this embodiment, the value range of the random value (4 bytes) is: 0x00000000-0xffffffff, and when the random value reaches 0xffffffff, step 101 is executed again.
[0085] When the data transmission is completed, the first device sends an end frame to the second device to end the communication. The second device does not need to reply to confirm, and the communication ends.
[0086] The communication method of the above embodiment is to send a request frame to establish communication; when a response frame is received within the time window, confirm whether the response frame is valid according to the random value; if the response frame is valid, send a data frame; after receiving a confirmation frame within the time window, continue to send data frames; after the data is sent, send an end frame. The above method solves the synchronization problem of the two communicating parties based on the comparison of the random values of the first device and the second device within the same time window, without adding new hardware. It can not only achieve the security of devices without time functions in communication and prevent replay attacks, but also reduce the computational complexity due to the simple structure, thereby maintaining a low latency. The method of the above embodiment can be deployed on a single-chip microcomputer with extremely strict computing resource control, thereby improving versatility.
[0087] In some embodiments, Figure 2 and Figure 3 As shown, the present application also proposes a communication method for preventing replay attacks, which is used for data frame transmission between a first device without a timing function and a second device, wherein the data frame structure includes a random value, a time interval, a time window, and a maximum error value, including:
[0088] Step 301: The second device receives a request frame for establishing communication sent by the first device.
[0089] The first device sends a request frame for establishing communication so as to establish a communication link, and the second device receives the request frame and responds to the request frame.
[0090] In some embodiments, the method also includes: when the first device directly sends a data frame to the second device, the second device replies with an error response after receiving the data frame, and the data structure of the error response frame includes a random value (4 bytes), a time window (4 bits), a maximum error value (4 bits), a time interval (4 bits), and a frame type (4 bits). The frame type is an error response frame, such as 1010 mentioned in the above embodiment.
[0091] Step 302: The second device sends a response frame within the time window and calculates the time window.
[0092] In this embodiment, after receiving the request frame, the second device counts its own initial random value, that is, the random value is increased by 1 after each time interval. If a link can be established, the second device sends a response frame within the time window, and the response frame includes the second random value of the second device. While sending the response frame, the time window is calculated to determine whether the first device sends the data frame in time.
[0093] Step 303: When the second device receives the data frame sent by the first device within the time window, it confirms whether the data frame is normal according to the random value.
[0094] After receiving the response frame sent by the second device, the first device determines whether the response frame is valid, and sends the data frame when the response frame is valid.
[0095] The second device receives the data frame within the time window, compares the random value of the received data frame with the random value of the second device to obtain a comparison result, and determines whether the data frame is normal based on the comparison result.
[0096] Step 304: If the data frame is normal, the second device sends a confirmation frame within the time window.
[0097] In this embodiment, when the data frame is determined to be normal according to step 303, the second device sends a confirmation frame to the first device. If the confirmation data frame is abnormal, the second device sends an error frame to the first device.
[0098] Step 305: Continue to receive data frames sent by the first device until an end frame sent by the first device is received.
[0099] In this embodiment, steps 303 and 304 are repeatedly performed until the data transmission is completed, that is, after the first device sends an end frame, the communication link is disconnected.
[0100] The communication method of the above embodiment is to receive a request frame for establishing communication; send a response frame within a time window and calculate the time window at the same time; when a data frame is received within the time window, confirm whether the data frame is normal according to a random value; if the data frame is normal, send a confirmation frame within the time window; and continue to receive data frames until an end frame is received. The above method solves the synchronization problem of the two communicating parties based on the comparison of the random values of the first device and the second device within the same time window, without adding new hardware. It can not only achieve the security of devices without time functions in communication and prevent replay attacks, but also reduce the computational complexity due to the simple structure, thereby maintaining a low latency. The method of the above embodiment can be deployed on a single-chip microcomputer with extremely strict computing resource control, thereby improving versatility.
[0101] In some embodiments, Figure 4 As shown, the request frame includes an initial random value, and after the first device sends a request frame for establishing communication to the second device, it also includes:
[0102] The time window is calculated, and the initial random value is counted according to the time interval until the response frame is received to obtain a first random value.
[0103] In this embodiment, after the first device sends the request frame, the initial random value is increased by 1 at every time interval (in milliseconds), and the time window is calculated at the same time, so as to prevent the error of the random value between the first device and the second device from being too large.
[0104] Before the step of the first device receiving the response frame sent by the second device within the time window, the method further includes:
[0105] 1) After receiving the request frame, the second device counts the initial random value according to the time interval to obtain a second random value.
[0106] In this embodiment, after receiving the request frame, the second device increases the initial random value by 1 after each time interval (in milliseconds) until the second device sends a response frame, thereby obtaining a second random value.
[0107] 2) Within the time window, the second device sends a response frame including the second random value to the first device.
[0108] Within the time window, the second device sends a response frame including a second random value to the first device, and the frame type is a response frame.
[0109] Furthermore, in some embodiments, the second device starts calculating the time window while sending a response frame to the first device. This can prevent the first device from failing to send a data frame in a timely manner, which not only ensures the synchronization of the communicating parties, but also ensures the continuity of the communication link, thereby improving the security of communication.
[0110] Further, in some embodiments, the step of the first device confirming whether the response frame is valid includes:
[0111] 1) Determine the error between the first random value and the second random value.
[0112] In this embodiment, the absolute value of the difference between the first random value and the second random value is the error between the first random value and the second random value.
[0113] 2) If the error is not greater than the maximum error value, confirm that the response frame is valid.
[0114] In this embodiment, when the error is not greater than the maximum error value, the response frame is confirmed to be valid, which can prevent serious asynchrony problems between the first device and the second device, more effectively prevent replay attacks, and ensure the security of both communicating parties.
[0115] In some embodiments, Figure 5 As shown, the data frame includes a third random value, the second device includes a fourth random value, and after the step of sending the data frame from the first device to the second device and before the step of the first device receiving a confirmation frame from the second device, it also includes:
[0116] 1) The second device confirms whether the data frame is normal.
[0117] The second device confirms whether the communication link has been attacked by a replay attack by confirming whether the data frame is normal, thereby ensuring that the communication data is not lost or mis-transmitted, thereby improving security.
[0118] In this embodiment, the step of the second device confirming whether the data frame is normal includes:
[0119] a) Obtaining an error between the third random value and the fourth random value.
[0120] An absolute value of a difference between the third random value and the fourth random value is calculated, and the absolute value is used as an error between the third random value and the fourth random value.
[0121] b) If the error is not greater than the maximum error value and the time for receiving the data frame does not exceed the time window, the data frame is confirmed to be normal.
[0122] When the error in step a) is not greater than the maximum error value, and the time length for the second device to receive the data frame does not exceed the time window, the data frame is confirmed to be normal. Otherwise, the data frame is confirmed to be abnormal. The time window here refers to the time window from the second device sending the confirmation frame to the receiving of the data frame.
[0123] c) if the data frame is confirmed to be normal, using the third random value as the random value of the second device, and sending a confirmation frame including the third random value to the first device.
[0124] In this embodiment, when the error and time window are normal, the second device corrects its own random value, that is, replaces the fourth random value of the second device with the third random value received from the first device, and sends a confirmation frame containing the third random value. The data structure of the confirmation frame includes a random value (4 bytes), a time window (4 bits), a maximum error value (4 bits), a time interval (4 bits), and a frame type (4 bits). The frame type is a data frame.
[0125] d) If it is confirmed that the data frame is abnormal, the second device sends an error frame to the first device.
[0126] When the error is not less than the maximum error value, and / or the time window has passed, the second device replies with an error frame to the first device. The data structure of the error frame includes a random value (4 bytes), a time window (4 bits), a maximum error value (4 bits), a time interval (4 bits), and a frame type (4 bits). The frame type is a synchronous error frame, such as 1000 mentioned in the above embodiment.
[0127] In some embodiments, the method further comprises: when the random number reaches a predetermined threshold, the first device resending the request to establish communication.
[0128] For example, taking 4-bit hexadecimal as an example, when the random value involved in any of the above embodiments reaches 0xff 0xff 0xff 0xff, the communication link is re-established.
[0129] For example, the communication process of the first device (module a) sending data hello to the second device (module b) to prevent replay attacks:
[0130] Module a sends a request frame: 0x11 0x22 0x33 0x44 0xa5 0x20
[0131] Module b sends a response frame: 0x11 0x22 0x33 0x45 0xa5 0x21
[0132] Module a sends a data frame: 0x11 0x22 0x33 0x46 0xa5 0x22 0x68 0x65 0x6c 0x6c0x6fb module sends a response frame: 0x11 0x22 0x33 0x47 0xa5 0x21
[0133] Module a sends the end frame: 0x11 0x22 0x33 0x48 0xa5 0x23.
[0134] In some embodiments, Figure 6 As shown, a communication device 600 for preventing replay attacks is also provided. The device 600 is used for data frame transmission between a first device without a timing function and a second device. The data frame structure includes a random value and a time window. The device 600 includes:
[0135] A first sending module 601, configured to send a request frame for establishing communication to a second device;
[0136] A first receiving module 602 is configured to, when receiving a response frame sent by the second device within the time window, confirm whether the response frame is valid according to the random value;
[0137] The first sending module 601 is further configured to send a data frame to the second device if the response frame is valid;
[0138] The first receiving module 602 is further configured to receive a confirmation frame sent by the second device;
[0139] The first sending module 601 is further configured to continue sending data frames until data sending is completed and to send an end frame.
[0140] The specific implementation process of the communication device for preventing replay attacks in this embodiment can refer to the description of each embodiment of the above method part, which will not be repeated here.
[0141] In some embodiments, Figure 7 As shown, a communication device 700 for preventing replay attacks is also provided. The device 700 is used for data frame transmission between a first device without a timing function and a second device. The data frame structure includes a random value and a time window. The device 700 includes:
[0142] The second receiving module 701 is used to receive a request frame for establishing communication sent by the first device;
[0143] A second sending module 702 is used to send a response frame within the time window and calculate the time window;
[0144] The second receiving module 701 is further configured to, when receiving a data frame sent by the first device within the time window, confirm whether the data frame is normal according to the random value;
[0145] The second sending module 702 is further configured to, if the data frame is normal, cause the second device to send a confirmation frame within a time window;
[0146] The second receiving module 701 is further configured to continuously receive data frames sent by the first device until an end frame sent by the first device is received.
[0147] Similarly, the specific implementation process of the communication device for preventing replay attacks in this embodiment can refer to the description of each embodiment of the above method part, which will not be repeated here.
[0148] Some embodiments of the present application relate to an electronic device, such as Figure 8 As shown. At the hardware level, the electronic device includes a processor, and optionally also includes an internal bus, a network interface, and a memory. Among them, the memory may include a memory, such as a high-speed random access memory (RAM), and may also include a non-volatile memory (non-volatile memory), such as at least one disk storage, etc. Of course, the electronic device may also include hardware required for other services.
[0149] The processor, network interface and memory can be interconnected through an internal bus, which can be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 8 It is represented by only one bidirectional arrow, but it does not mean that there is only one bus or one type of bus.
[0150] The memory is used to store the program. Specifically, the program may include a program code, and the program code includes a computer operation instruction. The memory may include a memory and a non-volatile memory, and provides instructions and data to the processor.
[0151] The processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it, forming a communication device that is resistant to replay attacks at the logical level. The processor executes the program stored in the memory and is specifically used to perform the following operations:
[0152] The first device sends a request frame for establishing communication to the second device;
[0153] When the first device receives the response frame sent by the second device within the time window, the first device confirms whether the response frame is valid according to the random value;
[0154] If the response frame is valid, the first device sends a data frame to the second device;
[0155] The first device receives a confirmation frame sent by the second device;
[0156] The first device continues to send data frames to the second device until data sending is completed, and the first device sends an end frame to the second device.
[0157] Some embodiments of the present application relate to an electronic device, such as Figure 8 , and is also used to perform the following operations:
[0158] The second device receives a request frame for establishing communication sent by the first device;
[0159] The second device sends a response frame within the time window and calculates the time window;
[0160] When the second device receives the data frame sent by the first device within the time window, confirming whether the data frame is normal according to the random value;
[0161] If the data frame is normal, the second device sends a confirmation frame within the time window;
[0162] Continue to receive the data frame sent by the first device until an end frame sent by the first device is received.
[0163] The communication method for preventing replay attacks provided in the above implementation can be applied to a processor or implemented by a processor. The processor may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by an integrated logic circuit of hardware in the processor or instructions in the form of software. The above processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The various methods, steps and logic block diagrams disclosed in the embodiments of this specification can be implemented or executed. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc.
[0164] The steps of the method disclosed in the embodiments of the present application can be directly embodied as being executed by a hardware decoding processor, or can be executed by a combination of hardware and software modules in the decoding processor. The software module can be located in a storage medium mature in the art such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. The storage medium is located in a memory, and the processor reads the information in the memory and completes the steps of the above method in combination with its hardware.
[0165] Some embodiments of the present application further provide a computer-readable storage medium, which stores one or more programs, wherein the one or more programs include instructions, which, when executed by an electronic device including multiple application programs, enable the electronic device to perform a communication method for preventing replay attacks, and are specifically used to perform:
[0166] Sending a request frame for establishing communication to the second device;
[0167] When receiving a response frame sent by the second device within the time window, the first device confirms whether the response frame is valid according to the random value;
[0168] If the response frame is valid, sending a data frame to the second device;
[0169] receiving a confirmation frame sent by the second device;
[0170] The data frame continues to be sent to the second device until the data sending is completed, and the first device sends an end frame to the second device.
[0171] Some embodiments of the present application further provide a computer-readable storage medium, which stores one or more programs, wherein the one or more programs include instructions, which, when executed by an electronic device including multiple application programs, enable the electronic device to perform a communication method for preventing replay attacks, and are specifically used to perform:
[0172] Receiving a request frame for establishing communication sent by the first device;
[0173] Sending a response frame within the time window and calculating the time window;
[0174] When receiving a data frame sent by the first device within the time window, confirming whether the data frame is normal according to the random value;
[0175] If the data frame is normal, a confirmation frame is sent within the time window;
[0176] Continue to receive the data frame sent by the first device until an end frame sent by the first device is received.
[0177] The systems, devices, modules or units described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer.
[0178] For the convenience of description, the above device is described in various units according to their functions. Of course, when implementing this specification, the functions of each unit can be implemented in the same or multiple software and / or hardware.
[0179] Those skilled in the art will appreciate that the embodiments of this specification may be provided as methods, devices, or computer program products. Therefore, this specification may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, this specification may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.
[0180] This specification is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of this specification. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0181] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0182] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0183] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0184] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0185] Computer readable media include permanent and non-permanent, removable and non-removable media and can store information by any method or technology. The information can be computer readable instructions, data structures, program modules or other data.
[0186] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0187] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
Claims
1. A communication method for preventing replay attacks, characterized in that: The method is used for data frame transmission between a first device without a timing function and a second device, the data frame structure includes a random value, a time interval and a time window, and the method includes: The first device sends a request frame for establishing communication to the second device; When the first device receives the response frame sent by the second device within the time window, the first device confirms whether the response frame is valid according to the random value; If the response frame is valid, the first device sends a data frame to the second device; The first device receives a confirmation frame sent by the second device; The first device continues to send data frames to the second device until data sending is completed, and the first device sends an end frame to the second device.
2. The method according to claim 1, characterized in that The request frame includes an initial random value, and after the first device sends a request frame for establishing communication to the second device, the step further includes: The first device calculates the time window, and counts the initial random value according to the time interval until the response frame is received, to obtain a first random value.
3. The method according to claim 2, characterized in that The response frame includes a second random value, and the step of the first device confirming whether the response frame is valid according to the random value includes: determining an error between the first random value and the second random value; If the error is not greater than the maximum error value, the response frame is confirmed to be valid.
4. The method according to any one of claims 1 to 3, characterized in that: Also includes: When the random value reaches a predetermined threshold, the first device resends a request to establish communication.
5. A communication method for preventing replay attacks, characterized in that: The method is used for data frame transmission between a first device without a timing function and a second device, the data frame structure includes a random value, a time interval and a time window, and the method includes: The second device receives a request frame for establishing communication sent by the first device; The second device sends a response frame within the time window and calculates the time window; When the second device receives the data frame sent by the first device within the time window, confirming whether the data frame is normal according to the random value; If the data frame is normal, the second device sends a confirmation frame within the time window; Continue to receive the data frame sent by the first device until an end frame sent by the first device is received.
6. The method according to claim 5, characterized in that Before sending the response frame within the time window, the method further includes: Before the step of receiving the response frame sent by the second device, the method further includes: After receiving the request frame, the second device counts the initial random value according to the time interval to obtain a second random value; The second device sends a response frame including the second random value to the first device within the time window.
7. The method according to claim 5, characterized in that The data frame includes a third random value, the second device includes a fourth random value, and the step of confirming whether the data frame is normal according to the random value includes: Obtaining an error between the third random value and the fourth random value; If the error is not greater than the maximum error value, and the time of receiving the data frame does not exceed the time window, then the data frame is confirmed to be normal; Otherwise, it is confirmed that the data frame is abnormal.
8. The method according to claim 7, characterized in that If the error is not greater than the maximum error value, the second device replaces the fourth random value with the third random value.
9. A communication device for preventing replay attacks, characterized in that: The device is used for data frame transmission between a first device without a timing function and a second device, the data frame structure includes a random value and a time window, and the device includes: A first sending module, used for sending a request frame for establishing communication to the second device; A first receiving module, configured to, when receiving a response frame sent by the second device within the time window, confirm whether the response frame is valid according to the random value; The first sending module is further configured to send a data frame to the second device if the response frame is valid; The first receiving module is further used to receive a confirmation frame sent by the second device; The first sending module is further used to continue sending data frames until the data sending is completed and send an end frame.
10. A communication device for preventing replay attacks, characterized in that: The device is used for data frame transmission between a first device without a timing function and a second device, the data frame structure includes a random value and a time window, and the device includes: A second receiving module, used to receive a request frame for establishing communication sent by the first device; A second sending module, used for sending a response frame within the time window and calculating the time window; The second receiving module is further configured to, when receiving a data frame sent by the first device within the time window, confirm whether the data frame is normal according to the random value; The second sending module is further configured to cause the second device to send a confirmation frame within a time window if the data frame is normal; The second receiving module is further used to continuously receive the data frames sent by the first device until an end frame sent by the first device is received.
11. An electronic device, characterized in that: include: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program implements the steps of the method according to any one of claims 1 to 4 when executed by the processor.
12. An electronic device, characterized in that: include: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program implements the steps of the method according to any one of claims 5 to 8 when executed by the processor.
13. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 4 are implemented.
14. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, which implements the steps of the method according to any one of claims 5 to 8 when executed by a processor.