pub struct NoiseChannel { /* private fields */ }Expand description
Real Noise Protocol encrypted channel using snow.
Performs a Noise XX handshake over the underlying MeshStream,
then encrypts/decrypts all subsequent messages using the established
session keys. Uses Noise_XX_25519_ChaChaPoly_SHA256.
Implementations§
Source§impl NoiseChannel
impl NoiseChannel
Sourcepub fn handshake_hash(&self) -> &[u8] ⓘ
pub fn handshake_hash(&self) -> &[u8] ⓘ
The session’s Noise handshake hash (32 bytes for SHA-256). Equal on both ends of one session, different on every other session.
Sourcepub async fn initiate(
stream: Box<dyn MeshStream>,
config: &NoiseConfig,
) -> Result<Self, MeshError>
pub async fn initiate( stream: Box<dyn MeshStream>, config: &NoiseConfig, ) -> Result<Self, MeshError>
Perform a Noise XX handshake as the initiator and return an encrypted channel.
Sourcepub async fn respond(
stream: Box<dyn MeshStream>,
config: &NoiseConfig,
) -> Result<Self, MeshError>
pub async fn respond( stream: Box<dyn MeshStream>, config: &NoiseConfig, ) -> Result<Self, MeshError>
Perform a Noise XX handshake as the responder and return an encrypted channel.
Trait Implementations§
Source§impl EncryptedChannel for NoiseChannel
impl EncryptedChannel for NoiseChannel
Source§fn send_encrypted<'life0, 'life1, 'async_trait>(
&'life0 mut self,
plaintext: &'life1 [u8],
) -> Pin<Box<dyn Future<Output = Result<(), MeshError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn send_encrypted<'life0, 'life1, 'async_trait>(
&'life0 mut self,
plaintext: &'life1 [u8],
) -> Pin<Box<dyn Future<Output = Result<(), MeshError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Send encrypted data (plaintext in, ciphertext on the wire).
Source§fn recv_encrypted<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, MeshError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn recv_encrypted<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, MeshError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Receive and decrypt data (ciphertext from wire, plaintext out). Read more
Source§fn remote_static_key(&self) -> Option<&[u8]>
fn remote_static_key(&self) -> Option<&[u8]>
Get the remote peer’s static public key (after handshake).
Source§fn handshake_hash(&self) -> Option<&[u8]>
fn handshake_hash(&self) -> Option<&[u8]>
The Noise handshake hash of this session, when the channel has
one. Both sides of a session compute the same value; admission
signs it to bind a node identity to this exact session (P3-K1).
None for channels without a handshake (plaintext passthrough).Auto Trait Implementations§
impl !RefUnwindSafe for NoiseChannel
impl !UnwindSafe for NoiseChannel
impl Freeze for NoiseChannel
impl Send for NoiseChannel
impl Sync for NoiseChannel
impl Unpin for NoiseChannel
impl UnsafeUnpin for NoiseChannel
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more