pub struct Protocol;
Expand description

Lower-level abstraction around the protocol. Use this directly if you’d like more control than what the higher-level Portal interface provides

Implementations§

source§

impl Protocol

source

pub fn connect<P: Read + Write>( peer: &mut P, id: &str, direction: Direction, msg: PortalKeyExchange ) -> Result<PortalKeyExchange, Box<dyn Error>>

Connect to a peer & receive the initial exchange data

source

pub fn derive_key( state: Spake2<Ed25519Group>, peer_data: &PortalKeyExchange ) -> Result<Vec<u8>, Box<dyn Error>>

Derive a shared key with the exchanged PortalConfirmation data. After this point in the exchange we have not verified that our peer has derived the same key as us, just derived the key for ourselves.

source

pub fn confirm_peer<P: Read + Write>( peer: &mut P, id: &str, direction: Direction, key: &[u8] ) -> Result<(), Box<dyn Error>>

Use the derived session key to verify that our peer has derived the same key as us. After this the peer will be fully confirmed.

source

pub fn read_encrypted_from<R, D>( reader: &mut R, key: &[u8] ) -> Result<D, Box<dyn Error>>where R: Read, D: DeserializeOwned,

Read an encrypted owned & deserialize-able object from the peer.

source

pub fn read_encrypted_zero_copy<R>( reader: &mut R, key: &[u8], storage: &mut [u8] ) -> Result<usize, Box<dyn Error>>where R: Read,

Read an encrypted message from the peer, writing the resulting decrypted data into the provided storage region. This allows for the ability to receive an encrypted chunk and decrypt it entirely in-place without extra copies.

source

pub fn encrypt_and_write_object<W, S>( writer: &mut W, key: &[u8], nseq: &mut NonceSequence, msg: &S ) -> Result<usize, Box<dyn Error>>where W: Write, S: Serialize,

Encrypt & send an EncryptedDataHeader + the entire object to the peer

source

pub fn encrypt_and_write_header_only<W>( writer: &mut W, key: &[u8], nseq: &mut NonceSequence, data: &mut [u8] ) -> Result<usize, Box<dyn Error>>where W: Write,

Encrypt & send the EncryptedDataHeader to the peer

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V