Trait async_psec::PsecWriter[][src]

pub trait PsecWriter {
    #[must_use]
    fn encrypt_and_send<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        plain_text: &'life1 [u8],
        use_padding: bool
    ) -> Pin<Box<dyn Future<Output = Result<(), PsecError>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        Self: 'async_trait
;
fn encrypt(&mut self, plain_text: &[u8], use_padding: bool) -> Vec<u8>;
#[must_use] fn send<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        cipher_text: &'life1 [u8]
    ) -> Pin<Box<dyn Future<Output = Result<(), PsecError>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        Self: 'async_trait
; }
Expand description

Write to a PSEC session.

Required methods

#[must_use]
fn encrypt_and_send<'life0, 'life1, 'async_trait>(
    &'life0 mut self,
    plain_text: &'life1 [u8],
    use_padding: bool
) -> Pin<Box<dyn Future<Output = Result<(), PsecError>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    Self: 'async_trait, 
[src]

Encrypt then send through a PSEC session.

use_padding specifies whether or not the plain text length should be obfuscated with padding. Enabling padding will use more network bandwidth: all messages below 1KB will be padded to 1KB and then the padded length doubles at each step (2KB, 4KB, 8KB…). When sending a buffer of 17MB, it will padded to 32MB.

Panic

Panics if the PSEC handshake is not finished and successful.

fn encrypt(&mut self, plain_text: &[u8], use_padding: bool) -> Vec<u8>[src]

Encrypt a buffer but return it instead of sending it.

All encrypted buffers must be sent in the same order they have been encrypted otherwise the remote peer won’t be able to decrypt them and should close the connection.

Panic

Panics if the PSEC handshake is not finished and successful.

let buffer1 = psec_session.encrypt(b"Hello ", false);
let buffer2 = psec_session.encrypt(b" world!", false);
psec_session.send(&buffer1).await?;
psec_session.send(&buffer2).await?;

#[must_use]
fn send<'life0, 'life1, 'async_trait>(
    &'life0 mut self,
    cipher_text: &'life1 [u8]
) -> Pin<Box<dyn Future<Output = Result<(), PsecError>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    Self: 'async_trait, 
[src]

Send a previously encrypted buffer.

All encrypted buffers must be sent in the same order they have been encrypted otherwise the remote peer won’t be able to decrypt them and should close the connection.

Implementors

impl PsecWriter for Session[src]

fn encrypt_and_send<'life0, 'life1, 'async_trait>(
    &'life0 mut self,
    plain_text: &'life1 [u8],
    use_padding: bool
) -> Pin<Box<dyn Future<Output = Result<(), PsecError>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    Self: 'async_trait, 
[src]

fn encrypt(&mut self, plain_text: &[u8], use_padding: bool) -> Vec<u8>[src]

fn send<'life0, 'life1, 'async_trait>(
    &'life0 mut self,
    cipher_text: &'life1 [u8]
) -> Pin<Box<dyn Future<Output = Result<(), PsecError>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    Self: 'async_trait, 
[src]

impl PsecWriter for SessionWriteHalf[src]

fn encrypt_and_send<'life0, 'life1, 'async_trait>(
    &'life0 mut self,
    plain_text: &'life1 [u8],
    use_padding: bool
) -> Pin<Box<dyn Future<Output = Result<(), PsecError>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    Self: 'async_trait, 
[src]

fn encrypt(&mut self, plain_text: &[u8], use_padding: bool) -> Vec<u8>[src]

fn send<'life0, 'life1, 'async_trait>(
    &'life0 mut self,
    cipher_text: &'life1 [u8]
) -> Pin<Box<dyn Future<Output = Result<(), PsecError>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    Self: 'async_trait, 
[src]