key exchange: one call sets the negotiated key

bump hbb_common cbc8772: Stream::set_negotiated_key.

The rendezvous client, the controller and the controlled side each
branched on the picked version to choose between split and single keys.
They now hand the transcript to Stream, which makes that choice once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019aokqJuhjvB3kijXtAg5Ns
This commit is contained in:
rustdesk
2026-09-23 09:53:34 +08:00
co-authored by Claude Opus 5.5
parent 67635235a7
commit b6897cb1d7
4 changed files with 31 additions and 43 deletions
+10 -14
View File
@@ -1727,20 +1727,16 @@ impl Client {
..Default::default()
});
timeout(CONNECT_TIMEOUT, conn.send(&msg_out)).await??;
if picked >= 1 {
conn.set_key_split(
key,
true,
&hbb_common::tcp::KxTranscript {
initiator_pk: &asymmetric_value,
responder_pk: &their_pk_b,
advertised: kx_version,
picked,
},
)?;
} else {
conn.set_key(key);
}
conn.set_negotiated_key(
key,
true,
&hbb_common::tcp::KxTranscript {
initiator_pk: &asymmetric_value,
responder_pk: &their_pk_b,
advertised: kx_version,
picked,
},
)?;
} else {
if is_webrtc {
bail!("WebRTC handshake id mismatch (possible MITM)");
+10 -14
View File
@@ -2128,20 +2128,16 @@ async fn key_exchange(conn: &mut Stream, key: &str, log_on_success: bool) -> Res
..Default::default()
});
timeout(CONNECT_TIMEOUT, conn.send(&msg_out)).await??;
if version >= 1 {
conn.set_key_split(
key,
true,
&hbb_common::tcp::KxTranscript {
initiator_pk: &asymmetric_value,
responder_pk: &their_pk_b,
advertised: ex.version,
picked: version,
},
)?;
} else {
conn.set_key(key);
}
conn.set_negotiated_key(
key,
true,
&hbb_common::tcp::KxTranscript {
initiator_pk: &asymmetric_value,
responder_pk: &their_pk_b,
advertised: ex.version,
picked: version,
},
)?;
if log_on_success {
log::info!("Connection secured");
}
+10 -14
View File
@@ -318,20 +318,16 @@ async fn identity_handshake(stream: &mut Stream, secure: bool) -> ResultType<()>
pk.kx_version
);
}
if pk.kx_version >= 1 {
stream.set_key_split(
key,
false,
&tcp::KxTranscript {
initiator_pk: &pk.asymmetric_value,
responder_pk: &our_pk_b.0,
advertised,
picked: pk.kx_version,
},
)?;
} else {
stream.set_key(key);
}
stream.set_negotiated_key(
key,
false,
&tcp::KxTranscript {
initiator_pk: &pk.asymmetric_value,
responder_pk: &our_pk_b.0,
advertised,
picked: pk.kx_version,
},
)?;
} else if pk.asymmetric_value.is_empty() {
Config::set_key_confirmed(false);
log::info!("Force to update pk");