A key update method and communication device based on two-phase retransmission switching
The key update method with two-stage retransmission switching solves the connection anomaly problem caused by key state divergence, improves connection stability and reduces hardware overhead, and is applicable to a variety of secure communication systems.
Patent Information
- Application Number
- CN202611527930.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-29
- Publication Date
- 2026-11-17
AI Technical Summary
In communication systems, existing technologies can cause key state discrepancies during key updates due to the loss of the last negotiation message, leading to abnormal connection termination. Furthermore, the Extended Key ID scheme cannot be effective in many real-world scenarios, resulting in increased hardware overhead and compatibility issues.
The key update method adopts a two-stage retransmission switching. After the count reaches the threshold, the first communicating party switches to retransmitting the second-to-last negotiation message with the new key, ensuring that the second communicating party, which has installed the new key, can successfully decrypt and complete the handshake recovery. Only the software logic of the first communicating party needs to be modified, without relying on the hardware capabilities of both parties.
It avoids abnormal connection drops, improves connection stability, reduces service interruption time, is suitable for various secure communication systems, requires no modification to the second communication party, and does not increase hardware overhead. It is suitable for Wi-Fi, TLS, IPsec and other systems.
Smart Images

Figure CN123122830A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of secure communication system technology, specifically to a key update method and communication device based on two-stage retransmission switching. Background Technology
[0002] In secure communication systems, key renewal (also known as key rekeying) is a crucial mechanism for ensuring forward confidentiality and key lifecycle management. Key renewal typically involves the communicating parties exchanging key materials through multiple negotiation messages, each generating a new key (K_new), and then switching to the new key for data protection after the negotiation is complete, provided an existing valid old key (K_old) is already in place. The following uses the WPA2 / WPA3 four-way handshake PTK (Pairwise Transient Key) update in a Wi-Fi (IEEE 802.11) system as an example, and combines it with similar mechanisms in other communication systems to illustrate existing implementation methods.
[0003] (1) Wi-Fi four-way handshake and PTK update In the IEEE 802.11-2024 standard (§12.7.6 Four-Way Handshake, §12.7.10 State Machine), the Access Point (AP, acting as the Authenticator) and the Station (STA, acting as the Supplemental Device) negotiate the PTK through a four-way handshake. The four-way handshake consists of four EAPOL-Key messages: M1: AP sends a message carrying ANOnce to initiate a handshake; M2: STA sends, carrying SNonce, derived PTK, and includes MIC; M3: Sent by AP, carrying GTK, Key ID KDE, etc., including MIC, and is the second to last message; M4: Sent by STA as a final confirmation of M3, and is the last message. In the PTK rekeying scenario, both parties already have a valid old PTK (Key ID 0), and the MAC layer port is protected. M2 / M3 / M4 use the old PTK for encrypted transmission at the MAC layer, while the MIC and Key Data fields inside the EAPOL-Key PDU are calculated using the subkeys (KCK, KEK) of the new PTK.
[0004] The timing for enabling the new PTK is specified by the standard: the STA installs the new PTK (overwriting the old PTK) via MLME-SETKEYS.request after sending M4; the AP installs the new PTK after receiving M4. That is: the party that sends the last message (M4) (STA) enables the new key after sending, and the party that receives the last message (AP) enables the new key after receiving.
[0005] (2) Extended Key ID mechanism The IEEE 802.11-2024 standard, §9.4.2.23.4, defines the Extended Key ID for Individually Addressed Frames capability bit (bit 13=1) in section 13. When both the AP and STA support this capability, the new PTKSA is assigned a different Key ID (alternating between 0 and 1), and the old and new PTKSAs coexist in parallel at the MAC layer using different Key IDs. The receiver distinguishes between the old and new keys frame by frame using the Key ID field in the CCMP / GCMP Header, achieving zero-packet-loss handover.
[0006] (3) Similar mechanisms in other communication systems Similar mechanisms for switching between old and new keys exist in other communication protocols, such as TLS, IPSec, and Bluetooth BLE. Although these protocols differ in message format, they all involve the common issue of "negotiating a new key under the protection of the old key and defining when to enable the new key."
[0007] (4) M3 retransmission and timeout mechanism The IEEE 802.11-2024 standard §12.7.10 defines the TimeoutCtr counter in the Authenticator state machine. After sending M3 in the PTKINITNEGOTIATING state, the AP starts the EAPOL layer timeout timer. If M4 is not received within the timeout period, TimeoutCtr is incremented and M3 is retransmitted (each retransmission uses an incrementing Key Replay Counter). When TimeoutCtr exceeds dot11RSNAConfigPairwiseUpdateCount, the state machine transitions to KEYERROR, and the AP performs a Deauthentication operation on the STA.
[0008] (5) Dependence on high-speed data encryption and decryption and hardware acceleration In high-speed data communication scenarios such as VPN encryption and Wi-Fi data encryption, the encryption and decryption operations of data frames (such as AES-CCM / AES-GCM operations in CCMP / GCMP) need to reach line-rate processing capabilities. Taking 802.11ax (Wi-Fi 6) as an example, the maximum rate can reach 9.6 Gbps, requiring the processing of hundreds of thousands of data frames per second. Such high throughput cannot be completed in real time by software on a general-purpose CPU and must rely on a dedicated hardware encryption engine (hardware accelerator) for encryption and decryption.
[0009] This means that key storage, lookup, and loading all occur at the hardware level: the key table is stored in the chip's internal SRAM (Key RAM), and the encryption engine uses hardware lookup logic to index the key slot based on (sender address, Key ID), reads the temporary key (TK), and then performs encryption and decryption operations. Key installation, overwriting, and parallel coexistence all involve modifications to the hardware key table.
[0010] In key update scenarios that do not support the coexistence of old and new keys (i.e., Extended Key ID is not enabled), when the last negotiation message (such as M4 in Wi-Fi) is not successfully received by the initiator due to reasons such as air interface packet loss, the existing technology has the following technical defects: 1) The loss of the last message caused a key state divergence, and the retransmitted message was discarded by the other end. According to the standard, the party sending the last negotiation message (such as the STA in Wi-Fi) immediately activates the new key (overwriting the old key) after sending it. If the initiator (such as the AP) does not receive the last message, the initiator will retransmit the penultimate message (such as M3) using the old key as specified in the standard. However, at this time, the responder's transport encryption layer only has the new key left (the old key has been overwritten). The retransmitted message encrypted with the old key cannot be decrypted by the transport encryption layer and is directly discarded without being sent to the upper-layer software for processing.
[0011] The root cause of the problem is that the initiator retransmits using the old key, but the responder no longer has the old key to decrypt it. The two parties have a key discrepancy that cannot be recovered using standard retransmission mechanisms. This flaw exists in any communication system where a new key is immediately activated after the last message is sent, overwriting the old key.
[0012] 2) The initiator cannot distinguish the cause of packet loss, resulting in continuous invalid retransmissions: The initiator's timeout detection is based on the absence of upper-layer protocol responses (such as M4 in Wi-Fi), rather than the absence of link-layer acknowledgments (such as MAC ACK). Taking Wi-Fi as an example, when the AP receives a MAC layer ACK from M3, it only confirms the physical arrival and CRC integrity of the frame, not that the frame content has been correctly processed. The AP cannot distinguish between the following situations: the second-to-last message is lost (the responder still has the old key, and retransmission can recover it), the last message is lost (the responder has installed a new key, the old key is overwritten, and retransmission will inevitably fail), message decryption failure, MIC verification failure, etc.
[0013] In the scenario where the last message is lost, the initiator continuously retransmits the penultimate message using the old key. Each retransmission is discarded at the responder's transmission encryption layer, forming an invalid retransmission loop.
[0014] 3) The responder is abnormally kicked out, and the connection is interrupted: When the number of retransmissions exceeds the protocol's tolerance limit (typically 3-4 times in Wi-Fi), the initiator's state machine transitions to an error state (e.g., KEYERROR in Wi-Fi), and performs a disconnection operation on the responder (e.g., Deauthentication in Wi-Fi), forcibly disconnecting the connection. After the responder is removed, the association and authentication process must be re-executed, causing service interruption (typical recovery time in Wi-Fi scenarios is 100-500ms), significantly impacting real-time services (such as VoWiFi and industrial control) and user experience.
[0015] 4) Limitations of the Extended Key ID scheme – It cannot be used as a universal solution. While the Extended Key ID mechanism (Standard §9.4.2.23.4 Bit13) can fundamentally solve the key state disagreement problem—achieving parallel coexistence and zero-packet-loss switching by assigning different Key IDs to the old and new keys—this scheme has the following serious limitations in actual deployment, making it unable to replace the switching scheme in all scenarios. Therefore, the aforementioned drawbacks 1)-3) still exist in many real-world scenarios: (a) Bilateral capability support requirements – Incompatibility with a large number of existing client devices: Extended Key ID requires both communicating parties to support this capability. It cannot be enabled if only one party supports it. See Table 1 for details. Table 1
[0016] In practical deployments, the AP, acting as a server-side device providing one-to-many services, needs to simultaneously connect to a large number of STAs (client devices) of different models and eras. Many deployed STAs (especially IoT terminals, embedded devices, and older mobile phones) do not support Extended Key ID capabilities. For these devices, the Extended Key ID scheme is ineffective, and the key update packet loss problem persists.
[0017] (b) Hardware overhead doubles – especially severe for server-side equipment: The parallel coexistence of old and new keys requires the system to maintain two sets of keys and their related states simultaneously, resulting in a significant increase in hardware resource overhead, as shown in Table 2: Table 2
[0018] High-speed data encryption and decryption rely on hardware acceleration, with the key table stored in the chip's internal SRAM and the lookup logic fixed in the hardware. The increased hardware overhead due to parallel coexistence is particularly severe for server-side devices such as APs that provide one-to-many services: the AP needs to maintain key tables for dozens to hundreds of STAs simultaneously, with resource overhead increasing linearly with the number of STAs. For example, a high-density AP with 128 STAs is unacceptable for cost-sensitive consumer and enterprise-level AP devices.
[0019] In addition, the requirement for dual-port key RAM increases the complexity of chip design and manufacturing costs. During the transition period, reading the old key (RX) and the new key (TX) simultaneously requires the key RAM to support dual read ports or a multi-bank structure, which further increases hardware costs.
[0020] (c) Transition period frame processing complexity: In parallel coexistence mode, frames with new and old keys may arrive interleaved during the transition, introducing the following complexity: PN (Packet Sequence Number) Spatial Transition: The old and new keys each have independent PN counters, with the new key's PN starting from a pre-defined value. When the receiver switches from an old key frame to a new key frame, the PN value may suddenly decrease. If the reordering mechanism does not handle this transition correctly, the new key frame may be mistakenly identified as a replay and discarded.
[0021] Late Frame Handling: During the transition period, after the sender switches to the new key, frames encrypted with the old key may arrive at the receiver late due to delay. The receiver needs to maintain two sets of PN windows simultaneously and correctly distinguish between old and new key frames. If not handled properly, old key frames may be misjudged as replays and discarded, triggering an unnecessary retransmission storm.
[0022] Key offloading timing: Old keys must be offloaded after a timeout period. The timing of offloading must be carefully chosen—offloading too early will result in late frames being unable to be decrypted, while offloading too late wastes resources and increases security risks. The standard does not specify a specific timeout value, and different implementations may have different behaviors.
[0023] (d) Complexity of alternating key identification management: Extended Key ID requires that a different Key ID be assigned to the new key each time the key is updated (alternating between 0 and 1). The system must correctly track the "last used Key ID" and alternate it with each update. If a software defect causes an incorrect Key ID assignment (such as the same as the last one), the receiving end will search for the key in the wrong key slot, resulting in decryption failure. This state management requires special handling in scenarios such as device restarts and state recovery.
[0024] (e) Existing equipment issues cannot be resolved through software upgrades: Extended Key ID is a capability that needs to be supported at the time of device manufacturing (involving hardware key table design, dual-port storage, and other hardware structures). For deployed devices that do not support this capability: it cannot be acquired through software upgrades (parallel coexistence depends on hardware support), and it cannot be enabled through configuration (if the capability bit is not supported by the hardware, forcibly setting it will cause key installation to fail).
[0025] In summary, while the Extended Key ID scheme represents a fundamental solution at the protocol level, its limitations—such as the requirement for bilateral capability support, significantly increased hardware overhead (especially for server-side devices like APs), and incompatibility with a large number of existing client devices—make it ineffective in scenarios with existing equipment. Therefore, there is an urgent need for a technical solution that does not rely on the hardware capabilities of either party and only requires modification of the first communicating party's software logic to resolve the aforementioned key state discrepancies. Summary of the Invention
[0026] To address the shortcomings of existing technologies, this invention aims to provide a key update method and communication device based on two-stage retransmission switching. This method solves the problem of how, when the last negotiation message is lost, the first communicating party automatically switches to retransmitting the penultimate negotiation message with the new key after a set threshold is reached during retransmission. This allows the second communicating party, which has already installed the new key, to successfully decrypt and complete the handshake recovery, thus avoiding abnormal connection drops. Furthermore, this method does not rely on the hardware capabilities of either party; it only requires modification of the first communicating party's software logic to take effect.
[0027] To achieve the above objectives, the present invention adopts the following technical solution: A key update method based on two-phase retransmission switching includes the following steps: S1. Key Negotiation and Generation: On a channel protected by an existing session key K_old, the first and second communicating parties exchange key materials through a negotiation message sequence and each generate a new session key K_new. K_old includes at least the transmission encryption subkey TK_old, and K_new includes at least the transmission encryption subkey TK_new. The negotiation message sequence includes at least two messages: the penultimate negotiation message M_penultimate and the last negotiation message M_last. M_penultimate is sent by the first communicating party, and M_last is sent by the second communicating party. From the moment K_new is generated, in subsequent negotiation messages between the two communicating parties, the second communicating party still uses TK_old for transmission encryption before sending M_last, and installs a new transmission encryption subkey TK_new in the transmission encryption layer after sending M_last, overwriting the old transmission encryption subkey TK_old; the first communicating party still uses TK_old for transmission encryption before receiving M_last, and installs a new transmission encryption subkey TK_new in the transmission encryption layer after successfully receiving M_last, overwriting the old transmission encryption subkey TK_old. Under normal circumstances, the second communicating party successfully receives M_penultimate, and after passing the integrity verification, sends M_last to the first communicating party. The first communicating party successfully receives M_last, and after passing the integrity verification, completes the key update. If the first communicating party does not receive M_last within the timeout period, it proceeds to step S2. S2. Retransmission of the old transmission encryption subkey: After the first communication party detects a timeout, it retransmits M_penultimate using the old transmission encryption subkey TK_old after encryption. The first counting threshold for retransmission using the old transmission encryption subkey is N1. The count is accumulated based on the number of times the first communication party sends M_penultimate, including the first transmission. If the first communication party receives M_last before the count of retransmitting M_penultimate using TK_old reaches N1, and completes the key update after the integrity verification is passed, the process terminates. If the first communication party still does not receive M_last when the count of retransmitting M_penultimate using TK_old reaches N1, then proceed to step S3. S3. New Transmission Encryption Subkey Switching and Retransmission: When the count of the first communicating party retransmitting M_penultimate using the old transmission encryption subkey reaches N1 and M_last has not yet been received, the process switches to the new transmission encryption subkey retransmission stage: The first communicating party enables the new transmission encryption subkey TK_new, installs the generated TK_new into the transmission encryption layer, overwrites TK_old, and uses TK_new to encrypt M_penultimate before retransmission. The count threshold for retransmitting M_penultimate using TK_new is N2, where the count is an independent count of retransmissions using TK_new after the switch, and the total retransmission threshold, including the first transmission, is N1+N2. At this time, the second communicating party, which has installed TK_new in the transmission encryption layer, can successfully decrypt the retransmitted M_penultimate using TK_new in the transmission encryption layer. After the integrity verification is passed, it uses TK_new to encrypt M_last before retransmitting. If the first communicating party receives M_last before the count of retransmitting M_penultimate using TK_new reaches N2, then it uses TK_new. If M_last is successfully decrypted and the integrity verification is passed, the key update is completed. If the first communicating party still has not received M_last when the count of retransmitting M_penultimate using TK_new reaches N2, the key update is deemed to have failed, and the connection with the second communicating party is disconnected.
[0028] It should be noted that the "count of retransmissions of M_penultimate" or "number of retransmissions" or "retransmission count" mentioned in this invention refers to the cumulative count of the number of times M_penultimate is sent, including the first transmission; correspondingly, the "total number of retransmissions" refers to the total count of the number of times M_penultimate is sent during the old transmission encryption subkey retransmission stage and the new transmission encryption subkey switching retransmission stage, also including the first transmission.
[0029] Furthermore, in step S1, for scenarios where the negotiation message independently carries an integrity verification field, K_old also includes an acknowledgment subkey KCK_old, and K_new also includes an acknowledgment subkey KCK_new; the integrity verification value ICV carried in the negotiation message is calculated using the acknowledgment subkey KCK_new of the new session key from the moment the two communicating parties generate the new session key K_new, and is used to verify that the message has not been tampered with; the integrity verification in steps S2 and S3 is the verification of the ICV.
[0030] Furthermore, when the integrity verification value (ICV) is calculated using the Authentication Encryption Algorithm (AEAD), it is implemented in the form of an authentication tag (Tag) output by the AEAD algorithm, and the authentication tag is carried in an independent integrity verification field within the negotiation message; the integrity verification in steps S2 and S3 specifically involves verifying the authentication tag.
[0031] Further, in step S3, when the count of the first communication party retransmitting M_penultimate using the old transmission encryption subkey reaches N1 and M_last has not yet been received, it first determines whether the switching trigger condition is met. If the switching trigger condition is met, it switches to the new transmission encryption subkey retransmission stage; if the switching trigger condition is not met, the first communication party determines that the key update has failed, disconnects the connection with the second communication party, and does not switch to the new transmission encryption subkey retransmission stage.
[0032] Furthermore, the switching triggering conditions include: (1) the current negotiation is being conducted on a channel protected by an existing session key; (2) the system does not support the coexistence of the old and new transmission encryption subkeys; (3) the count of retransmissions using the old transmission encryption subkey reaches the first threshold N1; (4) no switching has been performed; (5) the system is currently in a negotiation state waiting for M_last; the new transmission encryption subkey retransmission stage is only entered when all switching triggering conditions are met.
[0033] Furthermore, the key update state machine of the first communicating party includes the following states and transitions: Initial state IDLE: After triggering a key update, it enters the key negotiation state KEY_NEG; KEY_NEG: Exchange key materials through pre-negotiation messages to generate K_new; after pre-negotiation is completed and integrity verification is passed, send TK_old encrypted M_penultimate, set the switching flag = false, retransmission count = 0 and immediately increment it to 1, and enter the waiting M_last state WAIT_LAST_OLD in the old transmission encryption subkey retransmission stage. WAIT_LAST_OLD: When M_last is received but the integrity verification fails, discard it silently, remain in WAIT_LAST_OLD, and continue waiting for timeout; when M_last is received and the integrity verification passes, install TK_new and transition to the key update completion state KEY_DONE; when timeout occurs and the count is less than N1, retransmit M_penultimate using TK_old, increment the count by 1, and remain in WAIT_LAST_OLD; if timeout occurs and the count equals N1 and all handover trigger conditions are met, transition to the transmission encryption subkey handover state KEY_SWITCHING; if timeout occurs and the count equals N1 and the handover trigger conditions are not met, transition to the key update failure state KEY_ERROR to terminate the key update in advance; KEY_SWITCHING: Install TK_new and overwrite TK_old, set the handover flag to true, increment the retransmission count by 1, retransmit M_penultimate using TK_new, and transition to the M_last waiting state WAIT_LAST_NEW in the new transmission encryption subkey retransmission phase; WAIT_LAST_NEW: If M_last is received and the integrity verification passes, transition to KEY_DONE; if timeout occurs and the total retransmission count is less than N1+N2, retransmit M_penultimate using TK_new, increment the count by 1, and remain in WAIT_LAST_NEW; if timeout occurs and the total retransmission count is greater than or equal to N1+N2, transition to KEY_ERROR and abandon the key update; if M_last is received but the integrity verification fails, discard it silently, remain in WAIT_LAST_NEW, and continue waiting for timeout; KEY_DONE: Both communication parties use K_new; KEY_ERROR: Disconnect the connection; The key update state machine of the second communication party includes the following states and transitions: Initial state IDLE: After the key update negotiation is initiated, exchange preamble messages and generate K_new, then transition to the M_penultimate waiting state KEY_RESPONDING; KEY_RESPONDING: After M_penultimate is received and the integrity verification passes, send M_last, install TK_new and overwrite TK_old, then transition to the key update confirmation waiting state WAIT_CONFIRM; WAIT_CONFIRM: If M_penultimate is received but integrity verification fails, it is silently discarded, WAIT_CONFIRM is maintained, and the system continues to wait for the timeout; if M_penultimate is received and TK_new is successfully decrypted and integrity verification passes, M_last encrypted with TK_new is retransmitted, and WAIT_CONFIRM is maintained; if subsequent TK_new encrypted data is received and decryption is successful, the system transitions to the key update complete state KEY_DONE. KEY_DONE: Both parties use K_new.
[0034] Furthermore, when the first communicating party retransmits M_penultimate, it must ensure that the second communicating party does not discard the retransmitted message after the handover due to the anti-replay mechanism. For scenarios where the negotiation message does not independently carry an integrity verification field (i.e., implicit integrity protection), the anti-replay strategy is entirely handled by the monotonically increasing sequence number PN mechanism of the transmission encryption layer. Each retransmission is a new transmission layer frame with a new sequence number, and will not be misjudged as a replay by the peer's sequence number replay window mechanism. For scenarios where the negotiation message independently carries an integrity verification field (i.e., explicit integrity protection), the anti-replay strategy includes at least one of the following: Incremental replay counter mechanism: The first communicating party updates the replay counter value in the replay counter field of the integrity check value each time it retransmits M_penultimate. The second communicating party will not determine it as a replay because it receives a different replay counter value each time. Timestamp mechanism: A timestamp field is carried in the negotiation message. The second communicating party verifies whether the difference between the timestamp and the local clock is within the preset acceptance window. If it exceeds the preset acceptance window, it is determined to be a replay message and is discarded. The timestamp is generated by the first communicating party when constructing the message and is protected by an integrity check value to prevent tampering. Random number mechanism: During the key negotiation process, the two communicating parties exchange their respective random numbers, which are used as input materials for key derivation to participate in the derivation of the new session key and its confirmation subkey.
[0035] Furthermore, the anti-replay strategy also includes a message caching mechanism: the first communicating party caches the complete content of M_penultimate after sending it for the first time; during subsequent retransmissions, it directly retrieves the message from the cache and encrypts it using the current transmission encryption subkey before sending; after receiving M_penultimate for the first time, the second communicating party successfully decrypts it and saves or caches the content of the M_penultimate message locally; subsequently, the second communicating party sends M_last and saves or caches the M_last message locally after sending; during subsequent M_penultimate retransmissions, after the second communicating party receives the retransmitted message and successfully decrypts it, it compares it with the content of the locally saved or cached M_penultimate. If the comparison matches, it directly retrieves the corresponding last negotiation message M_last from the saved or cached message and sends it; if the comparison does not match, it reprocesses according to the standard procedure: after the second communicating party successfully verifies the integrity and passes the anti-replay check, it recalculates the integrity check value of M_last and constructs and sends M_last, without retrieving it from the cache; if the integrity check value verification fails, it silently discards the M_penultimate message and continues to wait in the original state.
[0036] Furthermore, the negotiation message sequence does not carry an independent integrity verification field; the integrity protection of the negotiation message is implicitly provided by the authentication tag generated by the transmission encryption layer based on the authentication encryption algorithm; the integrity verification in steps S2 and S3 is the verification of the transmission encryption layer authentication tag.
[0037] This invention also provides a key update method based on two-stage retransmission switching, applied to a first communication party, comprising the following steps: S1, Key negotiation and generation: The first communication party and the second communication party exchange key materials through a negotiation message sequence on a channel protected by an existing session key K_old; the first communication party generates a new session key K_new; K_old includes at least the transmission encryption subkey TK_old, and K_new includes at least the transmission encryption subkey TK_new; the negotiation message sequence includes at least the penultimate negotiation message M_penultimate sent by the first communication party and the last negotiation message M_last sent by the second communication party; S2, Retransmission of the old transmission encryption subkey: When the first communication party does not receive M_last within a timeout period, it uses the old transmission encryption subkey TK_old. After encrypting M_penultimate, _old retransmits it. The count is accumulated based on the number of times the first communicating party sends M_penultimate, including the first transmission. The first counting threshold is N1. S3, New transmission encryption subkey switching and retransmission: When the count reaches N1 and M_last is still not received, the first communicating party installs the generated TK_new onto the transmission encryption layer to overwrite TK_old, and uses TK_new to encrypt M_penultimate before retransmitting it. The independent counting threshold for retransmitting using TK_new after switching is N2, and the total retransmission threshold including the first transmission is N1+N2. If M_last is still not received when the total retransmission count reaches N1+N2, the key update is determined to have failed, and the connection with the second communicating party is disconnected.
[0038] The present invention also provides a communication device for acting as a first or second communication party to implement the steps performed by the corresponding communication party in the above method.
[0039] The beneficial effects of this invention are as follows: 1. Prevent abnormal connection drops and improve connection stability. In scenarios where the last negotiation message is lost, existing technologies often fail to retransmit using the old key, ultimately leading to a connection termination. This invention addresses this by employing a two-stage retransmission key switching mechanism. After N1 retransmissions, the system switches to sending the new key, enabling the second communicating party (which has the new key installed) to successfully decrypt and complete the handshake, thus preventing abnormal connection termination. For example, in a Wi-Fi scenario, the service interruption time is reduced from 00-500ms (re-authentication) to a single timeout period (approximately 100-200ms).
[0040] 2. Transparently compatible with existing second communication parties, requiring no cooperation from the second communication party. Implementing this invention requires only modifications to the logic of the first communication party; no modifications or additional capabilities are required from the second communication party. The behavior of the second communication party fully complies with the standard: after sending the last message, it installs the new key, and upon receiving a retransmission message encrypted with the new key, it decrypts it using the new key. Therefore, it is transparently compatible with existing devices that do not support the coexistence of old and new keys, and software upgrades on the first communication party side are sufficient for the changes to take effect.
[0041] 3. Precise scene isolation, no side effects This invention ensures that the switching logic is triggered only in the target scenario through multiple condition detections. For non-target scenarios such as the first loss of the penultimate message, the first key negotiation on the plaintext channel, and support for parallel coexistence, the switching logic is not triggered and the standard path is followed without any side effects.
[0042] 4. Low implementation overhead In this invention, triggering the switch requires only one key installation primitive call and one Boolean flag, resulting in extremely low consumption of computing and storage resources.
[0043] 5. Risk of misjudgment is controllable. In this invention, the first communicating party cannot determine the specific reason for the retransmission failure, but controls the risk of misjudgment by setting a reasonable threshold for the number of N1 retransmissions. Even if a misjudgment occurs, the worst-case scenario is that the connection still fails after switching, ultimately resulting in a disconnection—consistent with the results of existing technologies, and no worse.
[0044] 6. No additional hardware overhead, compatible with server-side devices. Unlike the Extended Key ID scheme, which requires dual key storage, dual-port key RAM, and dual-amplifier counters, significantly increasing hardware overhead, this invention only requires a single Boolean flag and a single key installation primitive call, without adding any hardware resource overhead. For server-side devices such as APs that provide one-to-many services, even when maintaining key tables for hundreds of STAs simultaneously, the storage increment of this scheme is only one Boolean flag per STA, making the hardware overhead negligible.
[0045] 7. Highly applicable The general solution does not depend on any specific communication protocol and is applicable to any secure communication system that "negotiates a new key on the old key-protected channel and enables the new key when the last message is sent / received," including but not limited to Wi-Fi, TLS, IPsec, Bluetooth, etc.
[0046] 8. Terminate non-target scenarios early to avoid unnecessary retransmissions. When the retransmission count reaches or exceeds the first threshold N1 and the handover triggering condition is not met (such as the first key negotiation on a plaintext channel, or non-target scenarios such as supporting the coexistence of old and new keys), this scheme immediately determines that the key update has failed and disconnects the connection, and does not continue to perform N2 retransmissions of the new key. This early termination mechanism avoids performing N2 retransmission attempts that will inevitably fail in scenarios that cannot be recovered through handover, reduces the waste of transmission resources and invalid waiting time, and allows the first communicating party to release negotiation resources more quickly.
[0047] 9. Flexible forms of integrity protection The switching mechanism of this invention does not limit the integrity protection form of the negotiation message. The negotiation message may carry an integrity verification field (i.e., explicit integrity protection form) or may not carry an integrity verification field (i.e., implicit integrity protection form), and its integrity protection is implicitly provided by the authentication tag generated by the transmission encryption layer based on the authentication encryption algorithm. In the implicit integrity protection form, the negotiation message retransmitted after the switch is encrypted by the transmission encryption subkey of the new key and an authentication tag is generated. The second communication party that has installed the new key can implicitly confirm that the first communication party has generated the new key by verifying the authentication tag. The evidence carrier for key confirmation is replaced by the integrity verification value of the negotiation layer and the authentication tag of the transmission encryption layer. This form is suitable for key-completely derived protocols where the transmission encryption layer locks a strong authentication encryption algorithm and cannot be downgraded, and the new key is derived from a key derivation function bound to the unique material of the session. Attached Figure Description
[0048] Figure 1 This is the system architecture for key negotiation between the two communicating parties on a channel protected by the old session key K_old in the method of Embodiment 1 of the present invention; Figure 2 This is an overall flowchart of the method implementation in Embodiment 1 of the present invention; Figure 3 This is the complete message interaction process in Embodiment 1 of the present invention for restoring key state consistency through a two-stage retransmission key switching mechanism after the last negotiation message is lost. Figure 4 This is a flowchart illustrating the message caching mechanism in the method of Embodiment 1 of the present invention; Figure 5 This is a flowchart illustrating the normal completion of the Wi-Fi PTK update in the method of Embodiment 2 of the present invention when M4 is successfully delivered; Figure 6 This is a complete message interaction flowchart of the switching and recovery process in the case of M4 loss in the method of Embodiment 2 of the present invention; Figure 7 This is a flowchart of the method in Embodiment 3 of the present invention; Figure 8 This is a flowchart of the method in Embodiment 4 of the present invention; Figure 9 This is a flowchart of the method in Embodiment 5 of the present invention. Detailed Implementation
[0049] The present invention will be further described below with reference to the accompanying drawings. It should be noted that this embodiment is based on the present technical solution and provides detailed implementation methods and specific operation processes, but the protection scope of the present invention is not limited to this embodiment.
[0050] Example 1 This embodiment provides a key update method based on two-stage retransmission switching.
[0051] Figure 1 The diagram illustrates a system architecture for key negotiation between two communicating parties (Party A and Party B) on a session key-protected channel. The session key K refers to the overall key generated by the two parties through key distribution or key negotiation, used to protect subsequent communication, such as a pairwise temporary key (PTK) in Wi-Fi, a session key in TLS, or an SA key in IPsec. The session key includes one or more specific functional subkeys, including at least a transport encryption subkey (TK) used for encrypted protection of negotiated messages and subsequent service data transmission.
[0052] This embodiment is primarily based on a scenario where the negotiation message carries an independent integrity verification field. Therefore, the session key also includes a Key Confirmation Key (KCK) for calculating the integrity verification value (ICV) of the negotiation message; additionally, it may include a Key Encryption Key (KEK) for encrypting the key data field in the negotiation message. Figure 1 As shown, in this embodiment, both communicating parties (first communicating party A and second communicating party B) have installed the old session key K_old, and the channel is protected by K_old. K_old includes the transmission encryption subkey TK_old, the confirmation subkey KCK_old, and the encryption subkey KEK_old.
[0053] Both parties exchange key materials through a negotiation message sequence (..., M_penultimate, M_last), and each generates a new session key K_new. M_penultimate may contain zero or more preceding negotiation messages, and M_last is the last negotiation message. The transmission encryption of the negotiation messages uses the transmission encryption subkey currently installed by the sender. The party sending M_last (the second communicating party B) activates K_new after sending M_last. K_new includes the transmission encryption subkey TK_new, the acknowledgment subkey KCK_new, and the encryption subkey KEK_new, and installs TK_new into the transmission encryption layer, overwriting TK_old. The party receiving M_last (the first communicating party A) installs TK_new into the transmission encryption layer after receiving M_last and overwrites TK_old.
[0054] In this embodiment, the transport encryption layer does not support the parallel coexistence of old and new transport encryption subkeys: the hardware key table maintains only a single transport encryption subkey slot. When TK_new is installed into the transport encryption layer, it overwrites TK_old, and only one transport encryption subkey is available at any given time. Therefore, the system cannot simultaneously maintain two sets of transport encryption subkeys and their associated states to achieve zero-packet-loss switching (as supported by Wi-Fi's Extended Key ID mechanism). This limitation only applies to the usage of transport encryption subkeys within the transport encryption layer, not to the usage of all subkeys throughout the entire session key lifecycle. K_old refers to the valid session key installed before the current negotiation begins, used to protect the current channel transport encryption, including keys generated through previous key negotiations (key update scenario) and keys derived from the preset key (PSK) (first key negotiation scenario using the preset key for protection).
[0055] It should be noted that during the key update negotiation process, the negotiation message involves two independent protection mechanisms.
[0056] The first protection mechanism is transmission encryption. During transmission, messages are encrypted and decrypted by the transmission encryption layer using the sender's currently installed transmission encryption subkey (either the old transmission encryption subkey TK_old or the new transmission encryption subkey TK_new), ensuring transmission confidentiality. Before the new transmission encryption subkey is enabled (i.e., installed into the transmission encryption layer), all negotiated messages use the old transmission encryption subkey TK_old for transmission encryption; after the new transmission encryption subkey is enabled, it switches to TK_new. The transmission encryption layer maintains only one transmission encryption subkey at a time; TK_new overwrites TK_old upon installation, and there is no transitional phase where the old and new transmission encryption subkeys are used concurrently.
[0057] The second protection mechanism is the negotiation layer integrity check and key data protection. The integrity check value (ICV) carried in the negotiation message is calculated using the confirmation subkey KCK_new of the new session key from the moment the two communicating parties generate the new session key K_new. The key data to be transmitted is encrypted using the encryption subkey KEK_new of the new session key from the same point in time. This is used to verify that the message has not been tampered with and that the sender has the correct new session key.
[0058] As can be seen from the independent operation of the two protection mechanisms described above, there is a transition phase during the key update negotiation process: the transmission encryption still uses the old transmission encryption subkey (TK_old), while the integrity verification and key data protection of the negotiation layer have switched to using the acknowledgment subkey KCK_new and encryption subkey KEK_new of the new session key. That is, from the generation of the new session key until the transmission encryption subkey of the new session key is installed in the transmission encryption layer, the acknowledgment and encryption subkeys of the new session key are used in parallel with the old transmission encryption subkey TK_old. This phenomenon is an inherent characteristic of the protocol design.
[0059] To address the aforementioned characteristics, the key update method in this embodiment employs a two-stage retransmission key switching strategy, comprising the following steps: S1. Key Negotiation and Generation: On a channel protected by an existing session key K_old, the first and second communicating parties exchange key materials through a negotiation message sequence, and each generate a new session key K_new. The negotiation message sequence includes at least two messages: the penultimate negotiation message M_penultimate and the last negotiation message M_last, where M_penultimate is sent by the first communicating party and M_last is sent by the second communicating party. From the moment K_new is generated, in subsequent negotiation messages, the second communicating party continues to use TK_old for transmission encryption before sending M_last, and installs a new transmission encryption subkey TK_new in the transmission encryption layer after sending M_last, overwriting the old transmission encryption subkey TK_old; the first communicating party continues to use TK_old for transmission encryption before receiving M_last, and installs a new transmission encryption subkey TK_new in the transmission encryption layer after successfully receiving M_last, overwriting the old transmission encryption subkey TK_old. At this point, the key update between the two communicating parties is complete.
[0060] Under normal circumstances, the second communicating party successfully receives M_penultimate, and after passing the integrity verification, sends M_last to the first communicating party. The first communicating party successfully receives M_last, and after passing the integrity verification, completes the key update. If the first communicating party does not receive M_last within the timeout period, it proceeds to step S2.
[0061] This embodiment does not impose any limit on the number of negotiation messages before M_penultimate, and can contain zero or more negotiation messages: When it contains zero pre-negotiation messages, M_penultimate is the first negotiation message in the sequence and also the second to last negotiation message, and the sequence contains only two negotiation messages, M_penultimate and M_last (i.e., a two-way handshake protocol); when it contains one pre-negotiation message (M1), the sequence contains three negotiation messages, M1, M_penultimate, and M_last (i.e., a three-way handshake protocol, where M1 is sent by the second communicating party to initiate key negotiation); when it contains two pre-negotiation messages (M1 and M2), the sequence contains four negotiation messages, M1, M2, M_penultimate, and M_last (i.e., a four-way handshake protocol, where M1 is sent by the first communicating party to initiate key negotiation, such as a Wi-Fi four-way handshake); more pre-negotiation messages can also be included before M_penultimate. Regardless of the number of preceding negotiation messages, M_penultimate is always the second-to-last negotiation message sent by the first communicating party, and M_last is always the last negotiation message sent by the second communicating party.
[0062] Specifically, in this embodiment, for scenarios where the negotiation message independently carries an integrity verification field (such as the MIC field in the Wi-FiEAPOL-Key frame) (i.e., the independent ICV implementation), the integrity verification value ICV carried in the negotiation message is calculated using the confirmation subkey KCK_new of the new session key from the moment the two communicating parties generate the new session key K_new. The key data to be encrypted is encrypted using the encryption subkey KEK_new of the new session key from the same point in time, which is used to verify that the message has not been tampered with and that the sender has the correct new session key.
[0063] In this embodiment, the negotiation message sequence can be used to exchange key materials such as random numbers, public keys, key encapsulation data, device identifiers, or authentication information. New session keys can be generated directly based on these materials, or further derived by combining existing session keys, context information, and message sequence digests, for example, through key derivation algorithms such as KDF, PRF, HMAC, or other pseudo-random functions. Specific implementations may include lightweight refresh using only the old key and random information, or the introduction of temporary public key negotiation to obtain forward secrecy capabilities; pre-shared keys, device-embedded keys, certificate signing, or challenge-response mechanisms can also be combined to enhance authentication and replay resistance; for higher security requirements, a hybrid approach combining classical algorithms and post-quantum cryptography can be adopted.
[0064] S2, Retransmission of old transmission encryption subkey: (e.g.) Figure 2-3As shown, if the last negotiation message M_last is lost in transmission, after the first communicating party detects a timeout, it retransmits M_penultimate using the old transmission encryption subkey TK_old after encryption. The first counting threshold for retransmitting using the old transmission encryption subkey is N1 (including the first communicating party's initial transmission of M_penultimate). If the first communicating party receives M_last before the count of retransmitting M_penultimate using TK_old reaches N1, and completes the key update after the integrity verification is passed, the process terminates; if the first communicating party still has not received M_last when the count of retransmitting M_penultimate using TK_old reaches N1, then proceed to step S3. S3, New transmission encryption subkey switching and retransmission: (e.g.) Figure 2-3 As shown, when the count of the first communication party retransmitting M_penultimate using the old transmission encryption subkey reaches N1 and M_last has not yet been received (the first communication party judges that it is likely in the scenario of "M_last is lost and the second communication party has installed a new transmission encryption subkey to overwrite the old transmission encryption subkey"), it is determined whether the switching trigger condition is met. If the switching trigger condition is met, the system switches to the new transmission encryption subkey retransmission stage: The first communicating party enables the new transmission encryption subkey TK_new, installs the generated TK_new into the transmission encryption layer, overwrites TK_old, and uses TK_new to encrypt M_penultimate before retransmission. The threshold for retransmitting M_penultimate using TK_new is N2, where the count is an independent count of retransmissions using TK_new after the switch, and the threshold for the total number of retransmissions, including the initial transmission, is N1+N2. At this time, the second communicating party, which has installed TK_new in the transmission encryption layer, can successfully decrypt the retransmitted M_penultimate using TK_new in the transmission encryption layer, and then verify the ICV (Independent Verification Field Verification or AEAD Authentication Tag Verification) carried therein. After successful verification, it uses TK_new to encrypt M_last before retransmission. If the first communicating party receives M_last before the count of retransmitting M_penultimate using TK_new reaches N2, then it successfully decrypts M_last using TK_new, verifies the ICV carried within, and completes the key update. If the first communicating party still does not receive M_last when the count of retransmitting M_penultimate using TK_new reaches N2, then it determines that the key update has failed and disconnects from the second communicating party.
[0065] If the switching trigger condition is not met (the first communicating party determines that it does not belong to the target scenario of "M_last lost, the second communicating party has installed a new transmission encryption subkey"), continuing retransmission is meaningless. The first communicating party determines that the key update has failed, disconnects from the second communicating party, and does not switch to the retransmission stage of the new transmission encryption subkey. This early termination mechanism avoids unnecessary retransmission attempts in non-target scenarios.
[0066] Specifically, in this embodiment, the switching triggering conditions include: (1) the current negotiation is being conducted on a channel protected by an existing session key; (2) the system does not support the parallel coexistence of old and new transmission encryption subkeys; (3) the count of retransmissions using the old transmission encryption subkey reaches a first threshold N1; (4) no switching has been performed (switching flag = false); and (5) the system is currently in a negotiation state waiting for M_last. Only when all switching triggering conditions are met will the new transmission encryption subkey retransmission stage begin.
[0067] It should be noted that condition (1) in the switching triggering conditions covers two scenarios: the first is the key update scenario, that is, both communicating parties already have a valid old transmission encryption subkey generated through the previous key negotiation; the second is the first key negotiation scenario using a preset key for encryption, such as the handshake message in TLS 1.3 mode using a key derived from the preset key for protection. Both scenarios have the defect that "after the last message is lost, the first communicating party retransmits with the old transmission encryption subkey, but the second communicating party no longer has the old transmission encryption subkey to decrypt it", so the switching strategy of this embodiment can be adopted in both scenarios. Conversely, for the scenario of the first key negotiation on the plaintext channel, there is no installed old transmission encryption subkey, and there is no problem of the old transmission encryption subkey being overwritten and causing decryption failure, so the switching is not triggered.
[0068] It should be noted that if any of the switching trigger conditions (1)-(5) above are not met, the switching will not be triggered. Therefore, the following scenarios do not meet the switching trigger conditions: (i) Initial loss of M_penultimate (no handover trigger): M_penultimate is lost during its initial transmission, but B still holds TK_old. After A times out, it retransmits M_penultimate using TK_old. B successfully decrypts it using TK_old and replies with M_last. The key update is completed within phase 1. The handover logic is not triggered, and there are no side effects on normal packet loss scenarios.
[0069] (ii) M_penultimate continues to be lost (failure after handover): When M_penultimate continues to be lost, A triggers a handover and installs TK_new after the retransmission count reaches N1, but B still holds TK_old (because B has never received M_penultimate and has not installed TK_new), and cannot decrypt the retransmission frames encrypted by TK_new. After the total retransmission count reaches N1+N2, A determines the connection has failed and disconnects. This is the correct behavior when continuous packet loss exceeds the tolerance range.
[0070] (III) Initial key negotiation on the plaintext channel (no handover trigger, terminated early after reaching N1): There is no old transmission encryption subkey to cover, and there is no mismatch between the old and new transmission encryption subkeys. When the retransmission count reaches N1, since the handover trigger condition "the current negotiation is conducted on a channel protected by an existing key" is not met, the first communicating party determines that the key update has failed and disconnects the connection, and does not continue to perform the N2th retransmission of the new transmission encryption subkey.
[0071] (iv) Support for the parallel coexistence of old and new transmission encryption subkeys (switching does not trigger, termination occurs early after N1 is reached): The system supports the parallel coexistence of old and new transmission encryption subkeys, the old transmission encryption subkey is retained, and retransmitted messages can be decrypted normally. When the retransmission count reaches or exceeds N1, since the switching trigger condition "the system does not support the parallel coexistence of old and new transmission encryption subkeys" is not met, the first communicating party determines that the key update has failed and disconnects the connection, and will not continue to perform N2 retransmissions of the new transmission encryption subkey.
[0072] As can be seen, the switching mechanism of this embodiment only takes effect in the target scenario where "M_last is lost and the second communication party has installed a new transmission encryption subkey to overwrite the old transmission encryption subkey". In other scenarios, there will be no unnecessary retransmission attempts of the new transmission encryption subkey, thus ensuring the accuracy and security of the switching logic.
[0073] It should be noted that, regarding the exceptional case where M_last is lost during transmission, such as... Figure 2-3 As shown, this embodiment employs a two-stage retransmission key switching strategy, with two retransmission stages as its core: retransmission of the old transmission encryption subkey (step S2) and retransmission of the new transmission encryption subkey (step S3). After the old transmission encryption subkey retransmission stage ends, two failure branches are introduced based on the evaluation results of the switching triggering conditions: early termination and abandonment due to exceeding the total retransmission threshold. The stage division is summarized in Table 3: Table 3
[0074] The key update state machine of the first communicating party includes the following states and transitions: IDLE (initial state): Enter KEY_NEG (key negotiation state) after key update is triggered; KEY_NEG: Exchange key materials through pre-negotiation messages to generate K_new; after the pre-negotiation is completed and the ICV verification is passed, send M_penultimate (encrypted with TK_old), set the switch flag=false, retransmission count=0 and immediately increment it to 1, then transition to WAIT_LAST_OLD (waiting for M_last, retransmission phase with old transport encryption subkey); WAIT_LAST_OLD: When M_last is received but the ICV verification fails, silently discard it, remain in WAIT_LAST_OLD and continue waiting for timeout; when M_last is received and the ICV verification is passed, install TK_new and transition to KEY_DONE (key update completed); when a timeout occurs and the count is less than N1, retransmit M_penultimate with TK_old, increment the count by 1, and remain in WAIT_LAST_OLD; if a timeout occurs and the count is equal to N1 and all switch trigger conditions are met, transition to KEY_SWITCHING (transport encryption subkey switching); if a timeout occurs and the count is equal to N1 and the switch trigger conditions are not met, transition to KEY_ERROR (key update failed) to terminate the key update in advance.
[0075] KEY_SWITCHING: Install TK_new (overwriting TK_old), set the switch flag=true, increment the retransmission count by 1, retransmit M_penultimate with TK_new, and transition to WAIT_LAST_NEW (waiting for M_last, retransmission phase with new transport encryption subkey); WAIT_LAST_NEW: If M_last is received and the ICV verification is passed, transition to KEY_DONE; if a timeout occurs and the total retransmission count is less than N1+N2, retransmit M_penultimate with TK_new, increment the count by 1, and remain in WAIT_LAST_NEW; if a timeout occurs and the total retransmission count is greater than or equal to N1+N2, transition to KEY_ERROR and abandon the key update; if M_last is received but the ICV verification fails, silently discard it, remain in WAIT_LAST_NEW and continue waiting for timeout.
[0076] KEY_DONE: Both communication parties use K_new; KEY_ERROR: Disconnect the connection.
[0077] In this embodiment, the key update state machine of the second communication party includes the following states and transitions: IDLE (Initial State): After the key update negotiation starts, the preconditions are exchanged and K_new is generated, and then KEY_RESPONDING (waiting for M_penultimate) is entered. KEY_RESPONDING: After receiving M_penultimate and ICV verification is successful, send M_last, install TK_new (overwrite TK_old), and enter WAIT_CONFIRM (waiting for key update confirmation). WAIT_CONFIRM: If M_penultimate is received but ICV verification fails, discard it silently, maintain WAIT_CONFIRM, and continue waiting for timeout; if M_penultimate is received as a retransmission (TK_new decryption successful, ICV verification passed), retransmit M_last (TK_new encryption), and maintain WAIT_CONFIRM; if subsequent TK_new encrypted data is received and decryption is successful, proceed to KEY_DONE (key update complete). KEY_DONE: Both parties use K_new.
[0078] The key actions of the second communicating party after installing TK_new and overwriting TK_old are as follows: retransmission frames encrypted with TK_old cannot be decrypted and are discarded by the MAC layer; only M_penultimate retransmission frames encrypted with TK_new can be decrypted; upon receipt, M_last (encrypted with TK_new) is retransmitted.
[0079] In this embodiment, when the first communicating party retransmits M_penultimate, it must ensure that the second communicating party does not discard the retransmitted message after the handover due to the anti-replay mechanism. The anti-replay strategy includes at least one of the following: Incremental replay counter method: The first communicating party updates the replay counter value in the replay counter field of the integrity check value each time it retransmits M_penultimate. The second communicating party will not determine it as a replay because it receives a different replay counter value each time. Since the integrity check value covers the entire negotiation message frame including the replay counter field, the incrementing of the replay counter causes changes in the message content, and the integrity check value needs to be recalculated accordingly. However, the key material content protected by the encrypted key data remains unchanged and does not need to be re-encrypted.
[0080] Timestamp mechanism: A timestamp field is included in the negotiation message. The second communicating party verifies whether the difference between the timestamp and the local clock is within a preset acceptance window. If it exceeds the preset acceptance window, the message is considered a replay and discarded. The timestamp is generated by the first communicating party during message construction and is protected by an integrity check value to prevent tampering.
[0081] Random number mechanism: During key negotiation, both communicating parties exchange their respective nonces. These nonces serve as input material for key derivation, contributing to the generation of the new session key and its acknowledgment subkey (KCK_new). Since each key update negotiation uses a different combination of random numbers, the derived KCK_new is session-unique. Under this mechanism, the Integrity Check Value (ICV) is calculated from the KCK_new derived in this session, implicitly containing session freshness information—even if an attacker replays a negotiation message from a previous session, the ICV in that message, calculated based on the key from the previous session, cannot pass the ICV verification of the current session, thus achieving replay protection.
[0082] In this embodiment, the anti-replay strategy also includes a message caching mechanism. For example... Figure 4 As shown, after the first communicating party sends M_penultimate for the first time, it caches the complete content of M_penultimate (including the integrity check value calculated during the first transmission and the encrypted key data, i.e., the part of the message that does not change with the transmission encryption subkey). During subsequent retransmissions, it directly retrieves the cached content and uses the current transmission encryption subkey (TK_old or TK_new) for transmission encryption before sending. The replay counter field remains the same as the initial transmission value and does not increment. Since the message content remains completely unchanged, the integrity check value and encrypted key data can be directly reused without recalculation or re-encryption. After receiving M_penultimate for the first time, the second communicating party locally saves (caches) the content of the M_penultimate message. The cached content of M_penultimate includes the successfully decrypted message content (including ICV and encrypted key data). Subsequently, the second communicating party sends M_last and saves (caches) the M_last message locally after sending. The cached content of M_last includes the ICV calculated using KCK_new. During the subsequent retransmission of M_penultimate, after the second communicating party receives the retransmitted message and successfully decrypts it, it compares it with the content of M_penultimate in its local cache. If they match, it directly retrieves the corresponding last negotiation message M_last from the cache and sends it, without needing to recalculate ICV using KCK_new. If they do not match, it reprocesses according to the standard procedure. A non-incrementing replay counter indicates that the retransmitted data is completely identical to the previous one, and is not a replay attack. The second communicating party does not perform redundant secondary processing, thus avoiding any security impact.
[0083] The standard procedure is as follows: The second communicating party verifies the integrity check value (calculated using the confirmation subkey KCK_new of the new session key) and, after passing the anti-replay check, recalculates the integrity check value of M_last and constructs and sends M_last, without retrieving it from the cache; if the integrity check value verification fails, the message is silently discarded, and the original state is maintained to continue waiting (the processing logic of the second communicating party's state machine WAIT_CONFIRM state is consistent).
[0084] It should be noted that the above message caching method can achieve the following: 1. Reduced computational overhead for the first communicating party The ICV (calculated using KCK_new) and encryption key data (encrypted using KEK_new) in M_penultimate are calculated once and cached during the first transmission. All subsequent retransmissions (including N1 retransmissions of the old transmission encryption subkey and up to N2 retransmissions of the new transmission encryption subkey) are directly retrieved from the cache without recalculation.
[0085] 2. Reduced computational overhead for the second communicating party The ICV in M_last (calculated using KCK_new) is calculated once and cached during the initial transmission. When the retransmitted M_penultimate is received and its consistency is confirmed by comparison with the cache, the second communicating party directly retrieves M_last from the cache, encrypts it for transmission, and then sends it without recalculating it.
[0086] 3. Decoupling computational overhead from retransmission count Without a caching mechanism, the more retransmissions there are, the greater the overhead of repeated computations. With a caching mechanism, the cryptographic computation overhead depends only on the number of message types (fixed to the computation of two messages, M_penultimate and M_last), and is unrelated to the number of retransmissions.
[0087] Example 2 This embodiment aims to provide an application example of the method of Embodiment 1 in the Wi-Fi 802.11 four-way handshake PTK rekeying scenario, illustrating the application of the method of Embodiment 1 in a specific protocol. It should be noted that in the Wi-Fi four-way handshake, the first communicating party (AP) plays the role of the initiator (sending M1 to initiate negotiation), and the second communicating party (STA) plays the role of the responder.
[0088] In this embodiment, the message mapping is shown in Table 4: Table 4
[0089] like Figure 5As shown, with M4 successfully delivered, the Wi-Fi PTK update completes normally. The process is as follows: 1. The AP generates ANonce in the PTKSTART state and sends M1 (ANonce, Secure=1, Key ReplayCounter=n), which is encrypted by the MAC layer using the old PTK-TK; after receiving it, the STA generates SNonce, derives a new PTK, and sends M2 (SNonce, RSNE, MIC, Secure=1, cnt=n), which is calculated using the new PTK-KCK and encrypted by the MAC layer using the old PTK-TK; 2. The AP derives a new PTK in the PTKCALCNEGOTIATING state. After verifying the MIC (new PTK-KCK) of M2, it transitions to the PTKCALCNEGOTIATING2 state, resets TimeoutCtr to 0, and then unconditionally transitions to the PTKINITNEGOTIATING state to send M3 (EAPOL-Key frame: GTK, MIC, Key Data, Secure=1, cnt=n+1). The MIC is calculated using the new PTK-KCK, the Key Data is encrypted using the new PTK-KEK, and the MAC layer is encrypted using the old PTK-TK. Immediately after sending M3, TimeoutCtr++ (TimeoutCtr=1) is executed, and then it waits for M4. 3. STA decrypts M3 using the old PTK-TK, verifies that MIC (new PTK-KCK) and decrypts Key Data (new PTK-KEK) successfully, and sends M4 (MIC, Secure=1, cnt=n+1). MIC is calculated using the new PTK-KCK, and the MAC layer is encrypted using the old PTK-TK. 4. After STA sends M4, execute MLME-SETKEYS.request to install the new PTK-TK (overwriting the old PTK-TK); 5. After the AP decrypts the M4 with the old PTK-TK and verifies the MIC (new PTK-KCK), it executes MLME-SETKEYS.request in the PTKINITDONE state to install the new PTK-TK (overwriting the old PTK-TK).
[0090] Under normal procedures, from the moment when a new PTK is derived by both parties, the MICs of M2 to M4 have been calculated using the new PTK-KCK, and the KeyData has been encrypted using the new PTK-KEK, while the MAC layer transmission encryption still uses the old PTK-TK, which reflects the independence of the two protection mechanisms and the transition phase. Within the "divergence window" after M4 is sent and before it is received by the AP, the AP still uses the old PTK-TK while the STA has already used the new PTK-TK, but this window lasts for an extremely short time (one-way transmission delay), and there is no data interaction demand between the two parties, so no practical problem arises.
[0091] In the event that M4 is lost, the complete message interaction procedure for handover recovery is as Figure 6 shown (taking N1=2 and N2=2 as an example): 1. The AP sends M3 (EAPOL-Key frame: GTK, MIC, Key Data, encrypted with old PTK-TK, cnt=n+1) in the PTKINITNEGOTIATING state, the MIC is calculated with the new PTK-KCK, the Key Data is encrypted with the new PTK-KEK, and TimeoutCtr++ (TimeoutCtr=1) is executed immediately after sending; 2. The STA decrypts M3 with the old PTK-TK, passes the MIC verification (new PTK-KCK), and passes the Key Data decryption (new PTK-KEK); 3. The STA sends M4 (MIC, encrypted with old PTK-TK, cnt=n+1), and M4 is lost during transmission; 4. After sending M4, the STA executes MLME-SETKEYS.request to install the new PTK-TK (overwriting the old PTK-TK); 5. The AP detects a timeout, at this time TimeoutCtr=1<N1 (Phase 1: retransmission with old transmission encryption subkey), retransmits M3 (cnt=n+2) encrypted with the old PTK-TK, and executes TimeoutCtr++ (TimeoutCtr=2) after retransmission; 6. After receiving the frame, the STA fails to decrypt it using the new PTK-TK because the old PTK-TK has been overwritten by the new PTK-TK, and the frame is discarded; 7. The AP continues to retransmit upon timeout, TimeoutCtr=2==N1 and all handover conditions are satisfied; 8. AP switchover: Execute MLME-SETKEYS.request to install the new PTK-TK (overwriting the old PTK-TK), set PtkSwitchDone=true, enter stage 2, retransmit M3 with the new PTK-TK (cnt=n+3), and execute TimeoutCtr++ (TimeoutCtr=3) after retransmission. 9. STA successfully decrypted using the new PTK-TK, verified MIC (new PTK-KCK), and Key Replay Counter n+3>n+1. 10.STA retransmits M4 (MIC, new PTK-TK encryption, cnt=n+3); 11. AP successfully decrypted M4 using the new PTK-TK, and MIC verification passed. Since the new PTK-TK was already installed during the switch, no reinstallation is necessary. 12. AP enters PTKINITDONE state, key update complete, both parties use the new PTK-TK, and the consistency state is restored.
[0092] The switching logic is triggered only when all the conditions shown in Table 5 are met: Table 5
[0093] In the first condition above, Secure bit=1 corresponds to the PTK Rekeying scenario, meaning that both parties already have a valid old PTK derived from the previous four-way handshake. Conversely, if Secure bit=0 during the initial four-way handshake (M1 / M2 stage), the defect of "AP retransmitting M3 with old PTK-TK after M4 is lost, but STA no longer has old PTK-TK to decrypt" does not exist in this scenario, and the handover condition is not met.
[0094] If any of the above conditions are not met, a handover will not be triggered. Specifically, the following scenarios do not meet the triggering conditions: Extended Key ID is enabled (new and old PTKs use different Key IDs and coexist in parallel, retransmissions can be decrypted normally), and the initial four-way handshake (Secure bit=0). When M4 has been received and the PTK-TK update is completed, the AP has entered the PTKINITDONE state, the negotiation process terminates normally, and the retransmission and handover logic is not entered. In the above scenarios where a handover is not triggered, if TimeoutCtr reaches or exceeds N1 and M4 has not yet been received, the AP determines that the key update has failed, enters the KEYERROR state and performs Deauthentication, and will not continue to perform N2 retransmissions of the new encrypted subkey (early termination). This mechanism ensures that the handover logic only takes effect in the target scenario and will not make unnecessary retransmission attempts in non-target scenarios.
[0095] Based on the standard Authenticator state machine (IEEE 802.11-2024 §12.7.10), this embodiment modifies the timeout handling logic of the PTKINITNEGOTIATING state. In the standard state machine, after the AP resets TimeoutCtr to 0 in the PTKCALCNEGOTIATING2 state, it unconditionally transitions to the PTKINITNEGOTIATING state, sends M3 (EAPOL-Key frame), and immediately executes TimeoutCtr++, then waits for M4; after the timeout, it checks whether TimeoutCtr exceeds dot11RSNAConfigPairwiseUpdateCount (i.e., N). If it does, it enters KEYERROR and executes Deauthentication; otherwise, it retransmits M3 using the old PTK-TK and executes TimeoutCtr++ again. This embodiment splits the single threshold N in the standard into a stage 1 retransmission count threshold N1 and a total retransmission count threshold N1+N2. It retains the standard behavior of "execute TimeoutCtr++ immediately after sending M3". In the condition judgment branch after timeout, a switching condition judgment is inserted at TimeoutCtr==N1, and a new switching flag PtkSwitchDone (initially false) is added.
[0096] It should be noted that the Wi-Fi standard retains the behavior of "executing TimeoutCtr++ immediately after sending M3". The value of TimeoutCtr is 1 after the first M3 transmission. Therefore, the semantics of N1 is "the counting threshold including the first transmission" rather than "the number of retransmissions of the old transmission encryption subkey". Specifically, N1=2 corresponds to 1 retransmission of the old transmission encryption subkey (the first timeout retransmission after the first transmission), and N1=3 corresponds to 2 retransmissions of the old transmission encryption subkey.
[0097] (1) AP-side state machine The modified key update state machine at the AP includes the following states and transitions: PTKSTART (Initial state, corresponding to IDLE → KEY_NEG): After triggering PTK Rekeying, an ANOnce is generated, M1 (Secure=1) is sent, and PTKCALCNEGOTIATING is entered; PTKCALCNEGOTIATING (in key negotiation, corresponding to KEY_NEG): Receive M2, derive a new PTK, verify M2MIC (new PTK-KCK) and then proceed to PTKCALCNEGOTIATING2; PTKCALCNEGOTIATING2 (transitional state, corresponding to the latter part of KEY_NEG): reset TimeoutCtr to 0, reset PtkSwitchDone to false, and unconditionally transition to PTKINITNEGOTIATING; PTKINITNEGOTIATING (waiting for M4, corresponding to WAIT_LAST_OLD / WAIT_LAST_NEW): immediately increment TimeoutCtr by 1 after transmitting M3 (EAPOL-Key frame), then wait for M4. The subsequent processing logic is as follows: M4 is received but MIC verification fails → silently discard, remain in PTKINITNEGOTIATING; M4 is received and MIC verification passes → if switching is not completed, execute MLME-SETKEYS.request to install the new PTK-TK, and transition to PTKINITDONE (corresponding to KEY_DONE); if switching is completed, the new PTK-TK has been installed during switching, and directly transition to PTKINITDONE; When a timeout occurs, directly check the current TimeoutCtr value (no further increment), and judge in sequence: TimeoutCtr>=N1+N2 → transition to KEYERROR, abandon key update, and execute Deauthentication; TimeoutCtr==N1 and all switching conditions are satisfied → execute MLME-SETKEYS.request to install the new PTK-TK (overwrite the old PTK-TK), set PtkSwitchDone=true, retransmit M3 with the new PTK-TK, increment TimeoutCtr by 1, and remain in PTKINITNEGOTIATING (new transmission encryption subkey retransmission phase); TimeoutCtr>=N1 and PtkSwitchDone==false → transition to KEYERROR, terminate the key update in advance, and execute Deauthentication; PtkSwitchDone==true → retransmit M3 with the new PTK-TK (Key Replay Counter++), increment TimeoutCtr by 1, and remain in PTKINITNEGOTIATING (new transmission encryption subkey retransmission phase); TimeoutCtr<N1 → retransmit M3 with the old PTK-TK (Key Replay Counter++), increment TimeoutCtr by 1, and remain in PTKINITNEGOTIATING (old transmission encryption subkey retransmission phase); PTKINITDONE (key update completed, corresponding to KEY_DONE): both parties use the new PTK-TK; KEYERROR (failure to authenticate, corresponding to KEY_ERROR): Executes Deauthentication and disconnects from the STA.
[0098] (2) STA-side state machine The state machine on the STA side does not require modification, and its standard behavior is consistent with the state machine of the second communication party in Example 1: KEY_RESPONDING (waiting for M3, corresponding to KEY_RESPONDING): After swapping M1 / M2 and deriving a new PTK, wait to receive M3; after receiving M3 and the MIC verification is successful, send M4, execute MLME-SETKEYS.request to install the new PTK-TK (overwriting the old PTK-TK), and switch to WAIT_CONFIRM; WAIT_CONFIRM (Waiting for key update confirmation, corresponding to WAIT_CONFIRM): Receive M3 retransmission (new PTK-TK decryption successful, MIC verification passed, Key Replay Counter incremented) → retransmit M4 (new PTK-TK encryption), maintaining WAIT_CONFIRM; Receive subsequent new PTK-TK encrypted data and decrypt successfully → proceed to KEY_DONE; KEY_DONE (Key update complete, corresponding to KEY_DONE): Both parties are using the new PTK-TK.
[0099] The key behavior of the STA after installing the new PTK-TK and overwriting the old PTK-TK is as follows: M3 retransmission frames encrypted by the old PTK-TK cannot be decrypted and are discarded by the MAC layer; only M3 retransmission frames encrypted by the new PTK-TK can be decrypted; upon receipt, M4 (encrypted by the new PTK-TK) is retransmitted. This behavior requires no modification to the STA, and this embodiment is completely transparent and compatible with the STA.
[0100] In this embodiment, the AP device configuration parameters are shown in Table 6: Table 6
[0101] Taking N1=2 and N2=2 as examples, the results in the M4 loss scenario are shown in Table 7: Table 7
[0102] Example 3 This embodiment aims to provide an application example of the method of Embodiment 1 in a two-way handshake protocol scenario, illustrating the application of Embodiment 1 when the negotiation message sequence contains only two messages (M_penultimate and M_last, with no preceding message).
[0103] The two-way handshake protocol is the simplest form of key update for message exchange. Since it does not contain any preamble messages, M_penultimate is the first message in the negotiation message sequence. The first communicating party (A) directly initiates the key update, sending its own key derivation material (random number N_A) in M_penultimate; the second communicating party (B) receives it, derives the same new session key, and replies with M_last as final confirmation.
[0104] The message mapping in this embodiment is shown in Table 8: Table 8
[0105] The process of the method in this embodiment is as follows: Figure 7 As shown. Figure 7 The first part is the normal interaction process (including the timing of new key derivation, the usage of ICV (KCK_new calculation) and encrypted key data (KEK_new encryption), the timing of message caching, and the timing of installing the new transmission encryption key TK_new). The second part is the recovery process of the two-stage retransmission key switching after Msg-2 is lost, including the failure of old key retransmission, switching trigger, successful retransmission of new key, and the complete interaction process under the message caching optimization mechanism where Msg-1 and Msg-2 are calculated only once.
[0106] The core difference between the two handshake protocols lies in the fact that the new session key K_new = KDF(K_old, N_A, "key_update") depends only on A's random number N_A, and not on B's random number N_B. Therefore, A can derive K_new before sending Msg-1, allowing the ICV carried in Msg-1 to be calculated using KCK_new and the encryption key data to be encrypted using KEK_new. After receiving and decrypting Msg-1, B extracts N_A and derives the same K_new using the same KDF.
[0107] The purpose of B carrying N_B in Msg-2 is to provide session freshness and replay protection, not to participate in the derivation of K_new. From the time A derives K_new, the ICV in Msg-1 has been calculated using KCK_new, the key data has been encrypted using KEK_new, and the transport encryption still uses TK_old—that is, a transitional phase in which the confirmation subkey of the new session key and the old transport encryption subkey are used in parallel.
[0108] When Msg-2 is successfully delivered, the key update is completed normally. A sends Msg-1 (encrypted with TK_old), B decrypts it, derives K_new, verifies ICV, replies with Msg-2, and installs TK_new; A receives Msg-2, verifies ICV, and installs TK_new.
[0109] When Msg-2 is lost, B has installed TK_new while A is still using TK_old, triggering the core fault-tolerance scenario of this invention. This embodiment adopts the two-stage retransmission key switching strategy described in Embodiment 1, as shown in Table 9: Table 9
[0110] The switching trigger condition is the same as in Example 1. The condition "the current negotiation is conducted on a channel protected by an existing key" is satisfied by K_old (derived from the previous negotiation or PSK). The parameter values are the same as in Example 2 (N1=2, N2=2).
[0111] This embodiment applies the message caching mechanism described in Embodiment 1. Since each party only sends one negotiation message in the two-way handshake protocol, the implementation of the caching mechanism is the simplest, as shown in Table 10: Table 10
[0112] When A retransmits Msg-1, it directly retrieves it from the cache, only switching the transmission encryption subkey; after B successfully decrypts the retransmitted Msg-1 and compares it with the cache, it directly retrieves Msg-2 from the cache and sends it. The cryptographic computation overhead for both parties is independent of the number of retransmissions.
[0113] Example 4 This embodiment aims to provide an application example of the method of Embodiment 1 in the three-way handshake protocol scenario, illustrating the application of the method of Embodiment 1 when the negotiation message sequence contains three messages (one pre-message M1, M_penultimate, and M_last).
[0114] The three-way handshake protocol adds a preamble message M1 to the two-way handshake protocol (Example 3), enabling both communicating parties to contribute random number materials for key derivation. This embodiment describes a general three-way handshake process that is not bound to a specific protocol, focusing on demonstrating the essential difference brought about by the preamble message: "random numbers from both parties jointly participate in key derivation."
[0115] In this embodiment, the message mapping is shown in Table 11: Table 11
[0116] The process of the method in this embodiment is as follows: Figure 8 As shown. Figure 8The first part is the normal interaction process (including the exchange of random numbers (N_B, N_A) between the two parties, the timing of new key derivation (K_new depends on both N_A and N_B), the usage of ICV (KCK_new calculation) and encrypted key data (KEK_new encryption), the timing of message caching, and the timing of installing the new transmission encryption key TK_new). The second part is the recovery process of the two-stage retransmission key switching after Msg-3 is lost, including the failure of old key retransmission, switching trigger, successful retransmission of new key, and the complete interaction process under the message caching optimization mechanism where Msg-2 and Msg-3 are calculated only once.
[0117] The core difference in the three-way handshake protocol lies in this: B arrives at A before A's key derivation, carrying its random number N_B in a preamble message Msg-1, ensuring that the new session key K_new = KDF(K_old, N_A, N_B, "key_update") depends on the random numbers from both parties. After receiving Msg-1, A obtains N_B, generates its own random number N_A, and derives K_new; after receiving Msg-2, B extracts N_A and derives the same K_new using the same KDF.
[0118] Compared to Example 3 (two-way handshake), the new key derivation in this example depends on both N_A and N_B. Neither party can predict or control the value of the new key alone, providing stronger key freshness assurance than the two-way handshake. This is the essential security advantage of the three-way handshake protocol over the two-way handshake protocol—the introduction of the preamble message M1 allows the random number of B to participate in key derivation, rather than just being used for session freshness identification.
[0119] After K_new is derived from A and before Msg-2 is sent, it has the ability to use KCK_new to calculate ICV and use KEK_new to encrypt key data, while transmission encryption still uses TK_old.
[0120] When Msg-3 is successfully delivered, the key update is completed normally. B sends Msg-1 (carrying N_B), A decrypts it, derives K_new, and sends Msg-2 (ICV is calculated using KCK_new). B decrypts it, derives K_new, verifies ICV, replies with Msg-3, and installs TK_new. A receives Msg-3, verifies ICV, and installs TK_new. The branch window characteristics are consistent with those in Examples 2 and 3.
[0121] When Msg-3 is lost, B has installed TK_new while A is still using TK_old, triggering the core fault-tolerance scenario of this invention. This embodiment adopts the two-stage retransmission key switching strategy described in Embodiment 1, the difference being that it does not perform the switching trigger condition judgment, as shown in Table 12: Table 12
[0122] In this embodiment, when the count of A retransmitting Msg-2 using TK_old reaches N1 and Msg-3 has still not been received, the system switches to the retransmission stage of the new transmission encryption subkey: A installs the generated TK_new onto the transmission encryption layer to overwrite TK_old, and uses TK_new to encrypt Msg-2 before retransmitting it. There is no switchover trigger condition judgment. The parameter values are the same as in Embodiments 2 and 3 (N1=2, N2=2).
[0123] This embodiment applies the message caching mechanism described in Embodiment 1. Similar to Embodiment 2, A only needs to cache Msg-2, and B only needs to cache Msg-3 and the content of the received Msg-2 for comparison. The preceding message Msg-1 does not need to be cached—Msg-1 is sent by B and is not within the retransmission range, and B has already stored N_B locally. As shown in Table 13: Table 13
[0124] When A retransmits Msg-2, it directly retrieves it from the cache, only switching the transmission encryption subkey; after B successfully decrypts the retransmitted Msg-2 and compares it with the cache, it directly retrieves Msg-3 from the cache and sends it. The cryptographic computation overhead for both parties is independent of the number of retransmissions.
[0125] In this embodiment, under the three-way handshake protocol scenario, the security of key derivation is enhanced by the joint participation of random numbers from both parties. This embodiment uses a pre-message M1 to ensure that B's random number N_B arrives at A before A's key derivation. The new session key K_new = KDF(K_old, N_A, N_B, "key_update") simultaneously depends on the random numbers from both parties. Neither party can predict or control the value of the new key independently, providing stronger key freshness protection than a two-way handshake protocol. This security enhancement stems from the inherent design of the three-way handshake protocol itself. The two-stage retransmission key switching strategy and message caching mechanism of the method in Embodiment 1 provide fault tolerance while ensuring this security design.
[0126] This embodiment, together with Embodiment 3 (zero pre-construction messages) and Embodiment 2 (two pre-construction messages), constitutes a complete coverage from zero to two pre-construction messages. Regardless of whether the negotiation message sequence contains zero, one, two, or more pre-construction messages, and regardless of whether the protocol is bound to a specific cryptographic protocol, the two-stage retransmission key switching strategy and message caching mechanism can be applied without modification, further confirming the protocol independence of the method in Embodiment 1.
[0127] Example 5 This embodiment describes a variant of the explicit integrity protection form used in the aforementioned embodiments—the implicit integrity protection form: the negotiation message sequence (including the penultimate negotiation message and the last negotiation message) does not carry an integrity check value (ICV) or encrypted key data. The key is entirely derived from the old key and negotiation material by the key derivation function. The negotiation message is transmitted as the payload of the transmission encryption layer, and its integrity protection is implicitly provided by the transmission encryption layer based on the authentication encryption algorithm.
[0128] The applicable conditions for this embodiment include: 1. The transmission encryption layer uses an authentication encryption algorithm (such as CCMP / GCMP in Wi-Fi, AEAD in the TLS record layer, etc.), and is locked through capability negotiation and cannot be downgraded to an unauthenticated or weak integrity algorithm; 2. The current negotiation is being conducted on a channel that is already protected by a key; 3. The new key is derived from a key derivation function containing a session-unique random number (e.g., K_new=KDF(K_old, N_A, "key_update")), ensuring that the transmitted encryption subkey TK_new is session-unique; 4. The protocol itself does not require negotiation messages to carry an independent integrity verification field.
[0129] This embodiment uses a two-way handshake protocol as its carrier. The message mapping is shown in Table 14: Table 14
[0130] The method process in this embodiment is as follows: Figure 9 As shown. Figure 9 In the first part, the normal interaction process takes place. The negotiation message contains only a plaintext random number and replay counter field, without integrity check value or encrypted key data. Integrity protection is provided by the authentication tag generated by the transmission encryption layer based on the authentication encryption algorithm. The second part is the recovery process after the Msg-2 is lost, involving a two-stage retransmission key switch: In stage 1, the retransmission of TK_old authentication encryption fails to authenticate and decrypt because the second communicating party has installed TK_new, and the frame is discarded; after the switch is triggered, the authentication tag of the retransmission message of TK_new authentication encryption in stage 2 passes the verification. The second communicating party thus implicitly confirms that the first communicating party has derived a new key and retransmits Msg-2. Similarly, the first communicating party obtains implicit key confirmation of the second communicating party. There are no negotiation layer cryptographic operations throughout the process, and the message cache content is only the plaintext message body.
[0131] The key derivation is consistent with Example 3 (K_new=KDF(K_old, N_A, "key_update"), relying only on the random number N_A of A. A completes the derivation before sending Msg-1, and B extracts N_A after receiving, authenticating, and decrypting Msg-1, and derives the same K_new using the same KDF). The only difference from Example 3 is that Msg-1 does not carry the ICV calculated using KCK_new and the confirmation subkey and encryption subkey of the key data encrypted using KEK_new. In this example, they are not used, and the new key is only used to derive and transmit the encryption subkey TK_new; N_B carried in Msg-2 is only used as a session freshness identifier and does not participate in the derivation of K_new.
[0132] The key update was completed normally upon successful delivery of Msg-2. The normal interaction process is shown in the attached figure. Figure 9 As shown in the previous section, A sends Msg-1 (TK_old authentication encryption), B authenticates and decrypts, derives K_new, replies with Msg-2 and installs TK_new (overwriting TK_old); A successfully authenticates and decrypts, then installs TK_new. The branch window characteristics are consistent with those in Example 3.
[0133] It should be noted that under normal circumstances, neither party can confirm through the negotiation process itself that the other party has derived the correct new key—Msg-1 and Msg-2 are both encrypted by TK_old, and their authentication tags only prove that the sender holds TK_old (which is the old key known to both parties), without providing evidence of confirmation of the new key.
[0134] When Msg-2 is lost, B has installed TK_new while A is still using TK_old, triggering the core fault-tolerance scenario of this invention. This embodiment adopts the two-stage retransmission key switching strategy described in Embodiment 1: Stage 1 (retransmission count 1-N1) uses TK_old for authentication and encryption to retransmit Msg-1. Since B no longer has TK_old, authentication and decryption fail; Stage 2 (N1+1-N1+N2, switching) uses TK_new for authentication and encryption to retransmit Msg-1. After B successfully authenticates and decrypts, it retransmits Msg-2.
[0135] The switching trigger conditions are the same as in Example 1, where condition 1, "the current negotiation is conducted on a channel protected by an existing key," is satisfied by K_old (derived from the previous negotiation or PSK). The parameter values are the same as in Examples 2-4 (N1=2, N2=2). The complete recovery process is as follows: Figure 9 As shown.
[0136] The key difference between this embodiment and the explicit integrity protection approach lies in the acceptance conditions and key confirmation method of the second communicating party for retransmitted messages after handover: In stage 2, after B receives the retransmission of Msg-1 encrypted with TK_new authentication, its acceptance condition is simplified from "TK_new decryption successful and ICV verification passed" in the explicit integrity protection approach to "TK_new authentication tag verification passed". Implicit key confirmation is implemented here: successful authentication tag verification proves that the sender holds TK_new, and TK_new is derived from the key derivation function bound to the random number N_A of this session. Therefore, B confirms that A has correctly derived K_new. The evidence carrier for key confirmation is replaced by the negotiation layer ICV and the transmission encryption layer authentication tag. Under the premise that the security of the authentication encryption algorithm is established, the cryptographic effect is equivalent. The same applies to the A side: when A receives the retransmission of Msg-2 encrypted with TK_new authentication from B and the authentication tag verification passes, it confirms that B has derived K_new; since TK_new has already been installed during handover, there is no need to install it again.
[0137] Regarding the state machines, the state sets, structures, and two-phase transition logic of state machines A and B in Implementation Example 1 remain unchanged. Only the phrase "ICV verification passed" in each transition condition is uniformly replaced with "transmission encryption layer authentication tag verification passed". For example, in state machine A, "receive M_last [ICV verification passed] → install TK_new" is replaced with "receive M_last [authentication tag verification passed] → install TK_new"; in state machine B, "receive M_penultimate retransmission [TK_new decryption successful, ICV verification passed] → resend M_last (TK_new encryption)" is replaced with "receive M_penultimate retransmission [TK_new authentication tag verification passed] → resend M_last (TK_new authentication encryption)".
[0138] In this embodiment, replay protection is handled entirely by the monotonically increasing sequence number (PN) mechanism of the transport encryption layer. Each retransmission is a new transport layer frame with a new sequence number, and will not be mistaken for a replay by the peer's sequence number replay window mechanism. Accordingly, the peer's acceptance logic should not rely on the monotonicity of the negotiation layer replay counter; if the negotiation message still retains the replay counter field (such as RC in Msg-1), it only serves as a message instance identifier and does not perform the function of preventing replay.
[0139] This embodiment applies the message caching mechanism described in Embodiment 1, and its implementation is simpler—the cached content is only the plaintext message body and does not contain any cryptographic operation products: A only caches the sent Msg-1 (plaintext message body, including N_A, RC, etc.), and B only caches the sent Msg-2 (plaintext message body, including N_B, etc.) and the authenticated and decrypted Msg-1 content for comparison.
[0140] When A retransmits Msg-1, it directly retrieves the plaintext message body from the cache, performs authentication and encryption only based on the key used for the current transmission encryption, and then sends it. After B receives the retransmitted Msg-1 and successfully authenticates and decrypts it, it compares it with the cache and directly retrieves Msg-2 from the cache and sends it. Compared with Example 4, all cryptographic operations on the retransmission path are only authentication and encryption of the transmission encryption layer, and the computational overhead for both parties is independent of the number of retransmissions and is lower.
[0141] It should be noted that the security of the negotiation message is entirely guaranteed by the security of the authentication encryption algorithm of the transport encryption layer. There is no second line of defense independent of the transport layer in the explicit form (in the explicit form, even if the old transport encryption key TK_old is leaked, the attacker cannot forge the negotiation message verified by ICV because he does not know K_new). Therefore, the applicable premise (1) requires that the transport encryption layer locks the strong authentication encryption algorithm and cannot be downgraded. Under this premise, the attacker forging an acceptable negotiation message is equivalent to breaking the transport layer authentication encryption algorithm itself. If this premise cannot be guaranteed, an explicit integrity protection form should be adopted.
[0142] For those skilled in the art, various corresponding changes and modifications can be made based on the above technical solutions and concepts, and all such changes and modifications should be included within the protection scope of the claims of this invention.
Claims
1. A key update method based on two-phase retransmission switching, characterized in that, Includes the following steps: S1. Key Negotiation and Generation: On a channel protected by an existing session key K_old, the first and second communicating parties exchange key materials through a negotiation message sequence and each generate a new session key K_new. K_old includes at least the transmission encryption subkey TK_old, and K_new includes at least the transmission encryption subkey TK_new. The negotiation message sequence includes at least two messages: the penultimate negotiation message M_penultimate and the last negotiation message M_last. M_penultimate is sent by the first communicating party, and M_last is sent by the second communicating party. From the moment K_new is generated, in subsequent negotiation messages between the two communicating parties, the second communicating party still uses TK_old for transmission encryption before sending M_last, and installs a new transmission encryption subkey TK_new in the transmission encryption layer after sending M_last, overwriting the old transmission encryption subkey TK_old; the first communicating party still uses TK_old for transmission encryption before receiving M_last, and installs a new transmission encryption subkey TK_new in the transmission encryption layer after successfully receiving M_last, overwriting the old transmission encryption subkey TK_old. Under normal circumstances, the second communicating party successfully receives M_penultimate, and after passing the integrity verification, sends M_last to the first communicating party. The first communicating party successfully receives M_last, and after passing the integrity verification, completes the key update. If the first communicating party does not receive M_last within the timeout period, it proceeds to step S2. S2. Retransmission of the old transmission encryption subkey: After the first communication party detects a timeout, it retransmits M_penultimate using the old transmission encryption subkey TK_old after encryption. The first counting threshold for retransmission using the old transmission encryption subkey is N1. The count is accumulated based on the number of times the first communication party sends M_penultimate, including the first transmission. If the first communication party receives M_last before the count of retransmitting M_penultimate using TK_old reaches N1, and completes the key update after the integrity verification is passed, the process terminates. If the first communication party still does not receive M_last when the count of retransmitting M_penultimate using TK_old reaches N1, then proceed to step S3. S3. New Transmission Encryption Subkey Switching and Retransmission: When the count of the first communicating party retransmitting M_penultimate using the old transmission encryption subkey reaches N1 and M_last has not yet been received, the process switches to the new transmission encryption subkey retransmission stage: The first communicating party enables the new transmission encryption subkey TK_new, installs the generated TK_new into the transmission encryption layer, overwrites TK_old, and uses TK_new to encrypt M_penultimate before retransmission. The count threshold for retransmitting M_penultimate using TK_new is N2, where the count is an independent count of retransmissions using TK_new after the switch, and the total retransmission threshold, including the first transmission, is N1+N2. At this time, the second communicating party, which has installed TK_new in the transmission encryption layer, can successfully decrypt the retransmitted M_penultimate using TK_new in the transmission encryption layer. After the integrity verification is passed, it uses TK_new to encrypt M_last before retransmitting. If the first communicating party receives M_last before the count of retransmitting M_penultimate using TK_new reaches N2, then it uses TK_new. If M_last is successfully decrypted and the integrity verification is passed, the key update is completed. If the first communicating party still has not received M_last when the count of retransmitting M_penultimate using TK_new reaches N2, the key update is deemed to have failed, and the connection with the second communicating party is disconnected.
2. The method according to claim 1, characterized in that, In step S1, for scenarios where the negotiation message independently carries an integrity verification field, K_old also includes an acknowledgment subkey KCK_old, and K_new also includes an acknowledgment subkey KCK_new. The integrity verification value ICV carried in the negotiation message is calculated using the acknowledgment subkey KCK_new of the new session key from the moment the two communicating parties generate the new session key K_new, and is used to verify that the message has not been tampered with. The integrity verification in steps S2 and S3 is the verification of the ICV.
3. The method according to claim 2, characterized in that, When the integrity verification value (ICV) is calculated using the Authentication Encryption Algorithm (AEAD), it is implemented in the form of an authentication tag (Tag) output by the AEAD algorithm, and the authentication tag (Tag) is carried in an independent integrity verification field within the negotiation message; the integrity verification in steps S2 and S3 specifically involves verifying the authentication tag (Tag).
4. The method according to claim 1, characterized in that, In step S3, when the count of the first communication party retransmitting M_penultimate using the old transmission encryption subkey reaches N1 and M_last has not yet been received, it first determines whether the switching trigger condition is met. If the switching trigger condition is met, it switches to the new transmission encryption subkey retransmission stage; if the switching trigger condition is not met, the first communication party determines that the key update has failed, disconnects the connection with the second communication party, and does not switch to the new transmission encryption subkey retransmission stage. The switching triggering conditions include: (1) the current negotiation is being conducted on a channel protected by an existing session key; (2) the system does not support the coexistence of the old and new transmission encryption subkeys; (3) the count of retransmissions using the old transmission encryption subkey reaches the first threshold N1; (4) no switching has been performed; (5) the system is currently in a negotiation state waiting for M_last; the new transmission encryption subkey retransmission stage will only begin when all switching triggering conditions are met.
5. The method according to claim 4, characterized in that, The key update state machine of the first communicating party includes the following states and transitions: Initial state IDLE: After triggering a key update, it enters the key negotiation state KEY_NEG; KEY_NEG: Exchange key materials through pre-negotiation messages to generate K_new; after pre-negotiation is completed and integrity verification is passed, send TK_old encrypted M_penultimate, set the switching flag = false, retransmission count = 0 and immediately increment it to 1, and enter the waiting M_last state WAIT_LAST_OLD in the old transmission encryption subkey retransmission stage; WAIT_LAST_OLD: If M_last is received but integrity verification fails, it is silently discarded, and WAIT_LAST_OLD is maintained while waiting for timeout. If M_last is received and integrity verification passes, TK_new is installed, and the key update is completed in the KEY_DONE state. If timeout occurs and the count is < N1, M_penultimate is retransmitted using TK_old, the count is incremented, and WAIT_LAST_OLD is maintained. If timeout occurs and the count is == N1 and all switching trigger conditions are met, the key update is terminated in the KEY_SWITCHING state. If timeout occurs and the count is == N1 and the switching trigger conditions are not met, the key update is terminated in the KEY_ERROR state. KEY_SWITCHING: Install TK_new and overwrite TK_old, set the switching flag to true, increment the retransmission count, retransmit M_penultimate using TK_new, and enter the waiting state WAIT_LAST_NEW for the retransmission of the new encryption subkey. WAIT_LAST_NEW: If M_last is received and integrity verification passes, proceed to KEY_DONE; if timeout occurs and total retransmission count < N1+N2, retransmit M_penultimate using TK_new, increment the count, and maintain WAIT_LAST_NEW; if timeout occurs and total retransmission count >= N1+N2, proceed to KEY_ERROR and abandon key update; if M_last is received but integrity verification fails, discard it silently, maintain WAIT_LAST_NEW, and continue waiting for timeout. KEY_DONE: Both communicating parties use K_new; KEY_ERROR: Disconnection; The key update state machine of the second communicating party includes the following states and transitions: Initial state IDLE: After the key update negotiation starts, the preconditions are exchanged and K_new is generated, and then the process enters the waiting state KEY_RESPONDING (M_penultimate). KEY_RESPONDING: After receiving M_penultimate and verifying its integrity, send M_last, install TK_new and overwrite TK_old, and enter the WAIT_CONFIRM state to wait for key update confirmation; WAIT_CONFIRM: If M_penultimate is received but integrity verification fails, it is silently discarded, WAIT_CONFIRM is maintained, and the system continues to wait for the timeout; if M_penultimate is received and TK_new is successfully decrypted and integrity verification passes, M_last encrypted with TK_new is retransmitted, and WAIT_CONFIRM is maintained; if subsequent TK_new encrypted data is received and decryption is successful, the system transitions to the key update complete state KEY_DONE. KEY_DONE: Both parties use K_new.
6. The method according to claim 1, characterized in that, When the first communicating party retransmits M_penultimate, it must ensure that the second communicating party does not discard the retransmitted message after the switchover due to the anti-replay mechanism. For scenarios where the negotiation message does not independently carry an integrity verification field (i.e., implicit integrity protection), the anti-replay strategy is entirely handled by the monotonically increasing sequence number PN mechanism of the transmission encryption layer. Each retransmission is a new transmission layer frame with a new sequence number, and will not be misjudged as a replay by the peer's sequence number replay window mechanism. For scenarios where the negotiation message independently carries an integrity verification field (i.e., explicit integrity protection), the anti-replay strategy includes at least one of the following: Incremental replay counter mechanism: The first communicating party updates the replay counter value in the replay counter field of the integrity check value each time it retransmits M_penultimate. The second communicating party will not determine it as a replay because it receives a different replay counter value each time. Timestamp mechanism: A timestamp field is carried in the negotiation message. The second communicating party verifies whether the difference between the timestamp and the local clock is within the preset acceptance window. If it exceeds the preset acceptance window, it is determined to be a replay message and is discarded. The timestamp is generated by the first communicating party when the message is constructed and is protected by an integrity check value to prevent tampering; Random number mechanism: During the key negotiation process, the two communicating parties exchange their respective random numbers, which are used as input materials for key derivation to participate in the derivation of the new session key and its confirmation subkey.
7. The method according to claim 6, characterized in that, The anti-replay strategy also includes a message caching mechanism: the first communicating party caches the complete content of M_penultimate after sending it for the first time; during subsequent retransmissions, it directly retrieves the message from the cache and uses the current transmission encryption subkey to encrypt the transmission before sending. After the second communicating party receives the M_penultimate message for the first time, it successfully decrypts it and saves or caches the content of the M_penultimate message locally. Subsequently, the second communicating party sends M_last and saves or caches the M_last message locally after sending. During the subsequent retransmission of M_penultimate, after the second communicating party receives the retransmitted message and successfully decrypts it, it compares it with the content of the locally saved or cached M_penultimate. If the comparison matches, it directly retrieves the corresponding last negotiation message M_last from the saved or cached message and sends it. If the comparison does not match, it reprocesses according to the standard procedure: after the second communicating party successfully verifies the integrity and passes the anti-replay check, it recalculates the integrity check value of M_last and constructs and sends M_last, without retrieving it from the cache. If the integrity check value verification fails, it silently discards the M_penultimate message and continues to wait in the original state.
8. The method according to claim 1, characterized in that, The negotiation message sequence does not carry an independent integrity verification field. The integrity protection of the negotiation message is implicitly provided by the authentication tag generated by the transmission encryption layer based on the authentication encryption algorithm. The integrity verification in steps S2 and S3 is the verification of the transmission encryption layer authentication tag.
9. A key update method based on two-stage retransmission switching, applied to a first communicating party, characterized in that, The process includes the following steps: S1, Key Negotiation and Generation: On a channel protected by an existing session key K_old, the first and second communicating parties exchange key materials through a negotiation message sequence. The first communicating party generates a new session key K_new. K_old includes at least the transmission encryption subkey TK_old, and K_new includes at least the transmission encryption subkey TK_new. The negotiation message sequence includes at least the penultimate negotiation message M_penultimate sent by the first communicating party and the last negotiation message M_last sent by the second communicating party. S2, Retransmission of the Old Transmission Encryption Subkey: If the first communicating party does not receive M_last within a timeout period, it uses the old transmission encryption subkey TK_old to retransmit M_penultimate. After e performs transmission encryption and retransmission, the count is accumulated based on the number of times the first communicating party sends M_penultimate, including the first transmission, and the first counting threshold is N1; S3, new transmission encryption subkey switching and retransmission: when the count reaches N1 and M_last is still not received, the first communicating party installs the generated TK_new onto the transmission encryption layer to overwrite TK_old, and uses TK_new to encrypt M_penultimate before retransmission. The independent counting threshold for retransmission using TK_new after switching is N2, and the total retransmission threshold including the first transmission is N1+N2; if M_last is still not received when the total retransmission count reaches N1+N2, the key update is determined to have failed, and the connection with the second communicating party is disconnected.
10. A communication device, characterized in that, Used as a first or second communication party to implement the steps performed by the respective communication party in the method of any one of claims 1 to 9.
