Trait async_psec::PsecWriter[][src]

pub trait PsecWriter {
    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>;
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

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.

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

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