mirror of
https://github.com/rustdesk/hbb_common.git
synced 2026-10-11 19:23:59 +00:00
stream: set_negotiated_key, one place that maps the picked version to a key
Every handshake picked a version and then repeated the same choice: at least 1 splits the key, 0 sets it as before. Stream now makes that choice from the transcript it is already given, so callers make one call and a later version is handled here rather than at each of them. Version 0 still goes through set_key. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019aokqJuhjvB3kijXtAg5Ns
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
26582e163d
commit
cbc8772d4a
+8
-3
@@ -80,15 +80,20 @@ impl Stream {
|
||||
}
|
||||
}
|
||||
|
||||
/// Per-direction keys bound to the handshake; see `tcp::KX_VERSION_LATEST`. `is_initiator`
|
||||
/// is the side that sent the sealed key.
|
||||
/// The stream key for the key exchange version in `t.picked`: version 0 is `set_key`, and
|
||||
/// later versions derive one key per direction from the transcript. `is_initiator` is the
|
||||
/// side that sent the sealed key.
|
||||
#[inline]
|
||||
pub fn set_key_split(
|
||||
pub fn set_negotiated_key(
|
||||
&mut self,
|
||||
key: Key,
|
||||
is_initiator: bool,
|
||||
t: &tcp::KxTranscript,
|
||||
) -> ResultType<()> {
|
||||
if t.picked == 0 {
|
||||
self.set_key(key);
|
||||
return Ok(());
|
||||
}
|
||||
match self {
|
||||
#[cfg(feature = "webrtc")]
|
||||
Stream::WebRTC(s) => {
|
||||
|
||||
Reference in New Issue
Block a user