PsecWriter

Trait PsecWriter 

Source
pub trait PsecWriter {
    // Required methods
    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 Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn encrypt(&mut self, plain_text: &[u8], use_padding: bool) -> Vec<u8> ;
    fn send<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        cipher_text: &'life1 [u8],
    ) -> Pin<Box<dyn Future<Output = Result<(), PsecError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

Write to a PSEC session.

Required Methods§

Source

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 Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

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…). For example, a buffer of 1.5KB will be padded to 2KB, and a buffer of 3KB will be padded to 4KB.

§Panic

Panics if the PSEC handshake is not finished and successful.

Source

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

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?;
Source

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

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§