clatter

Struct PqHandshake

Source
pub struct PqHandshake<'a, EKEM, SKEM, C, H, RNG>
where EKEM: Kem, SKEM: Kem, C: Cipher, H: Hash, RNG: RngCore + CryptoRng,
{ /* private fields */ }
Expand description

Post-quantum Noise handshake

Implementations§

Source§

impl<'a, EKEM, SKEM, C, H, RNG> PqHandshake<'a, EKEM, SKEM, C, H, RNG>
where EKEM: Kem, SKEM: Kem, C: Cipher, H: Hash, RNG: RngCore + CryptoRng,

Source

pub fn new( pattern: HandshakePattern, prologue: &[u8], initiator: bool, s: Option<SKEM::SecretKey>, e: Option<EKEM::SecretKey>, rs: Option<SKEM::PubKey>, re: Option<EKEM::PubKey>, rng: &'a mut RNG, ) -> Result<PqHandshake<'a, EKEM, SKEM, C, H, RNG>, HandshakeError>

Initialize new post-quantum handshake

§Arguments:
  • pattern - Handshake pattern
  • prolopgue - Optional prologue data for the handshake
  • initiator - True if we are the initiator
  • s - Our static secret key
  • e - Our ephemeral secret key - Shouldn’t usually be provided manually
  • rs - Peer public static key
  • re - Peer public ephemeral key - Shouldn’t usually be provided manually
  • rng - RNG to use during the handshake
§Generic parameters:
  • EKEM - KEM algorithm to use for ephemeral key encapsulation
  • SKEM - KEM algorithm to use for static key encapsulation
  • C - Cipher algorithm to use
  • H - Hashing algorithm to use

Trait Implementations§

Source§

impl<'a, EKEM, SKEM, C, H, RNG> Handshaker<C, H> for PqHandshake<'a, EKEM, SKEM, C, H, RNG>
where EKEM: Kem, SKEM: Kem, C: Cipher, H: Hash, RNG: RngCore + CryptoRng,

Source§

fn is_write_turn(&self) -> bool

Is it our turn to send
Source§

fn is_initiator(&self) -> bool

Are we the initiator
Source§

fn get_next_message_overhead(&self) -> HandshakeResult<usize>

Get next message overhead in bytes
Source§

fn build_name(pattern: &HandshakePattern) -> ArrayString<128>

Build full name of the protocol with the given pattern
Source§

fn write_message( &mut self, payload: &[u8], out: &mut [u8], ) -> HandshakeResult<usize>

Write next handshake message to the given buffer Read more
Source§

fn read_message( &mut self, message: &[u8], out: &mut [u8], ) -> HandshakeResult<usize>

Read and process next handshake message from given buffer Read more
Source§

fn is_finished(&self) -> bool

Is the handshake finished
Source§

fn get_name(&self) -> ArrayString<128>

Get full name of the selected protocol
Source§

fn finalize(self) -> HandshakeResult<TransportState<C, H>>
where Self: Sized,

Transition into transport mode Read more

Auto Trait Implementations§

§

impl<'a, EKEM, SKEM, C, H, RNG> Freeze for PqHandshake<'a, EKEM, SKEM, C, H, RNG>
where <H as Hash>::Output: Freeze, <SKEM as Kem>::SecretKey: Freeze, <EKEM as Kem>::SecretKey: Freeze, <SKEM as Kem>::PubKey: Freeze, <EKEM as Kem>::PubKey: Freeze, <C as Cipher>::Key: Freeze,

§

impl<'a, EKEM, SKEM, C, H, RNG> RefUnwindSafe for PqHandshake<'a, EKEM, SKEM, C, H, RNG>
where <H as Hash>::Output: RefUnwindSafe, <SKEM as Kem>::SecretKey: RefUnwindSafe, <EKEM as Kem>::SecretKey: RefUnwindSafe, <SKEM as Kem>::PubKey: RefUnwindSafe, <EKEM as Kem>::PubKey: RefUnwindSafe, RNG: RefUnwindSafe, <C as Cipher>::Key: RefUnwindSafe,

§

impl<'a, EKEM, SKEM, C, H, RNG> Send for PqHandshake<'a, EKEM, SKEM, C, H, RNG>
where <H as Hash>::Output: Send, <SKEM as Kem>::SecretKey: Send, <EKEM as Kem>::SecretKey: Send, <SKEM as Kem>::PubKey: Send, <EKEM as Kem>::PubKey: Send, RNG: Send, <C as Cipher>::Key: Send,

§

impl<'a, EKEM, SKEM, C, H, RNG> Sync for PqHandshake<'a, EKEM, SKEM, C, H, RNG>
where <H as Hash>::Output: Sync, <SKEM as Kem>::SecretKey: Sync, <EKEM as Kem>::SecretKey: Sync, <SKEM as Kem>::PubKey: Sync, <EKEM as Kem>::PubKey: Sync, RNG: Sync, <C as Cipher>::Key: Sync,

§

impl<'a, EKEM, SKEM, C, H, RNG> Unpin for PqHandshake<'a, EKEM, SKEM, C, H, RNG>
where <H as Hash>::Output: Unpin, <SKEM as Kem>::SecretKey: Unpin, <EKEM as Kem>::SecretKey: Unpin, <SKEM as Kem>::PubKey: Unpin, <EKEM as Kem>::PubKey: Unpin, <C as Cipher>::Key: Unpin,

§

impl<'a, EKEM, SKEM, C, H, RNG> !UnwindSafe for PqHandshake<'a, EKEM, SKEM, C, H, RNG>

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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 T
where 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

Source§

type Output = T

Should always be Self
Source§

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

Source§

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 T
where U: TryFrom<T>,

Source§

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.