pub struct DualLayerHandshake<Outer, Inner, C, H, const BUF: usize>{ /* private fields */ }Expand description
Dual layer handshake
An “outer-encrypts-inner” dual layer handshake with fully independent layers. The outer handshake is completed first, after which the inner handshake starts and all the related handshake messages are encrypted using the outer layers resulting transport encryption.
Warning: this is a naive approach which does NOT cryptographically bind the layers together. Use this handshake type only if you know what you are doing and absolutely require the handshake layers to remain independent.
Dual layer handshakes require an additional intermediate buffer
for decrypting outer layer handshake messages. The buffer size
is controlled by the generic parameter BUF.
§Message Sequences
With dual layer handshakes it is possible to construct handshake pattern
combinations which result in one party having to send two handshake
messages in a row. Take care when implementing your handshaking logic and
always use Self::is_write_turn to check who should send next.
Implementations§
Source§impl<Outer, Inner, C, H, const BUF: usize> DualLayerHandshake<Outer, Inner, C, H, BUF>
impl<Outer, Inner, C, H, const BUF: usize> DualLayerHandshake<Outer, Inner, C, H, BUF>
Sourcepub fn new(outer: Outer, inner: Inner) -> Self
pub fn new(outer: Outer, inner: Inner) -> Self
Initialize a new dual layer handshake
§Arguments
outer- Outer handshake, which is completed firstinnter- Inner handshake, which benefits from the security of the outer layer
§Generic parameters
const BUF- Intermediate decrypt buffer size - Must be large enough to fit all inner handshake messages
§Panics
- If
outerandinneraren’t both either initiators or responders - If outer handshake is a one-way pattern
Sourcepub fn outer_completed(&self) -> bool
pub fn outer_completed(&self) -> bool
Check if outer handshake is completed
Sourcepub fn inner_mut(&mut self) -> &mut Inner
pub fn inner_mut(&mut self) -> &mut Inner
Get mutable reference to inner handshake
Sourcepub fn outer_mut(&mut self) -> Option<&mut Outer>
pub fn outer_mut(&mut self) -> Option<&mut Outer>
Get mutable reference to outer handshake
Trait Implementations§
Source§impl<Outer, Inner, C, H, const BUF: usize> Handshaker<C, H> for DualLayerHandshake<Outer, Inner, C, H, BUF>
impl<Outer, Inner, C, H, const BUF: usize> Handshaker<C, H> for DualLayerHandshake<Outer, Inner, C, H, BUF>
Source§fn get_remote_static(&self) -> Option<Self::S>
fn get_remote_static(&self) -> Option<Self::S>
Get remote static key of the inner handshake (if available)
Source§fn get_remote_ephemeral(&self) -> Option<Self::E>
fn get_remote_ephemeral(&self) -> Option<Self::E>
Get remote ephemeral key of the inner handshake (if available)
Source§fn get_state(&self) -> SymmetricState<C, H>
fn get_state(&self) -> SymmetricState<C, H>
Get a copy of the inner handshakers current SymmetricState
Source§fn get_state_mut(&mut self) -> &mut SymmetricState<C, H>
fn get_state_mut(&mut self) -> &mut SymmetricState<C, H>
Get a mutable reference of the inner handshakers current SymmetricState