Fix cached Noise reconnects atomically

This commit is contained in:
jack
2026-07-26 12:21:38 +02:00
committed by jack
parent 2d96fd99a1
commit 3b7c590df4
11 changed files with 1011 additions and 111 deletions
@@ -70,8 +70,8 @@ final class BLENoisePacketHandler {
}
/// Returns true when the handshake message was processed successfully.
/// Callers use this to distinguish an authenticated replacement completion
/// from a rejected candidate while an older session remains established.
/// Callers use this to distinguish an authenticated reconnect completion
/// from a rejected ordinary responder while rollback state is restored.
@discardableResult
func handleHandshake(_ packet: BitchatPacket, from peerID: PeerID) -> Bool {
handleHandshakeWithResult(packet, from: peerID).processed
@@ -113,7 +113,7 @@ final class BLENoisePacketHandler {
result.didEstablishAuthenticatedSession
)
} catch NoiseSessionError.peerIdentityMismatch {
// The candidate was already discarded by the session manager.
// The responder was already discarded by the session manager.
// Do not let a spoofed claimed ID trigger a fresh outbound
// handshake or recreate state for the attacker-selected ID.
SecureLogger.warning(