Keep the live tunnel PSK in sync in modify_peer() / update_peer()#124
Open
lurenjia534 wants to merge 2 commits into
Open
Keep the live tunnel PSK in sync in modify_peer() / update_peer()#124lurenjia534 wants to merge 2 commits into
lurenjia534 wants to merge 2 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Device::modify_peer()andDevice::update_peer()updated the stored peer PSK, but left the live tunnel / handshake state unchanged.That allowed the configured PSK and the runtime PSK to diverge, and could leave sessions / in-flight handshake state derived from the previous PSK usable after a PSK change.
Fix
This patch makes PSK updates affect the live tunnel immediately:
set_preshared_key()on the live tunnel when a peer's configured PSK changesTunn::set_preshared_key()to:Handshake::set_preshared_key()to:state,previous,last_rtt)Why this approach
Changing the PSK is not just a config update; it invalidates crypto state derived from the previous PSK.
The library peer-update APIs are expected to affect subsequent handshakes, not only the values returned by configuration / inspection APIs. Updating the live tunnel in place keeps that behavior local to the affected crypto state and avoids rebuilding the whole peer object.
Scope
This change is limited to the library peer-update path.
The UAPI
Setpath already removes and recreates peers, so its behavior is unchanged.Tests
This PR adds regression coverage for the affected paths:
modify_peer_updates_live_preshared_keyupdate_peer_updates_live_preshared_keyset_preshared_key_invalidates_existing_sessionsThe new tests verify that:
modify_peer()orupdate_peer()affects the live handshake stateThis change is