Struct snow::HandshakeState [−][src]
pub struct HandshakeState { /* fields omitted */ }
Expand description
A state machine encompassing the handshake phase of a Noise session.
Note: you are probably looking for Builder
to
get started.
See: http://noiseprotocol.org/noise.html#the-handshakestate-object
Implementations
impl HandshakeState
[src]
impl HandshakeState
[src]pub fn was_write_payload_encrypted(&self) -> bool
[src]
pub fn was_write_payload_encrypted(&self) -> bool
[src]This method will return true
if the previous write payload was encrypted.
See Payload Security Properties for more information on the specific properties of your chosen handshake pattern.
Examples
let mut session = Builder::new("Noise_NN_25519_AESGCM_SHA256".parse()?) .build_initiator()?; // write message... assert!(session.was_write_payload_encrypted());
pub fn write_message(
&mut self,
payload: &[u8],
message: &mut [u8]
) -> Result<usize, Error>
[src]
pub fn write_message(
&mut self,
payload: &[u8],
message: &mut [u8]
) -> Result<usize, Error>
[src]Construct a message from payload
(and pending handshake tokens if in handshake state),
and writes it to the message
buffer.
Returns the size of the written payload.
Errors
Will result in Error::Input
if the size of the output exceeds the max message
length in the Noise Protocol (65535 bytes).
pub fn set_psk(&mut self, location: usize, key: &[u8]) -> Result<(), Error>
[src]
pub fn set_psk(&mut self, location: usize, key: &[u8]) -> Result<(), Error>
[src]Set the preshared key at the specified location. It is up to the caller to correctly set the location based on the specified handshake - Snow won’t stop you from placing a PSK in an unused slot.
Errors
Will result in Error::Input
if the PSK is not the right length or the location is out of bounds.
pub fn get_remote_static(&self) -> Option<&[u8]>
[src]
pub fn get_remote_static(&self) -> Option<&[u8]>
[src]Get the remote party’s static public key, if available.
Note: will return None
if either the chosen Noise pattern
doesn’t necessitate a remote static key, or if the remote
static key is not yet known (as can be the case in the XX
pattern, for example).
pub fn get_handshake_hash(&self) -> &[u8]
[src]
pub fn get_handshake_hash(&self) -> &[u8]
[src]Get the handshake hash.
Returns a slice of length Hasher.hash_len()
(i.e. HASHLEN for the chosen Hash function).
pub fn is_initiator(&self) -> bool
[src]
pub fn is_initiator(&self) -> bool
[src]Check if this session was started with the “initiator” role.
pub fn is_handshake_finished(&self) -> bool
[src]
pub fn is_handshake_finished(&self) -> bool
[src]Check if the handshake is finished and into_transport_mode()
can now be called.
pub fn is_my_turn(&self) -> bool
[src]
pub fn is_my_turn(&self) -> bool
[src]Check whether it is our turn to send in the handshake state machine
pub fn into_transport_mode(self) -> Result<TransportState, Error>
[src]
pub fn into_transport_mode(self) -> Result<TransportState, Error>
[src]Convert this HandshakeState
into a TransportState
with an internally stored nonce.
pub fn into_stateless_transport_mode(
self
) -> Result<StatelessTransportState, Error>
[src]
pub fn into_stateless_transport_mode(
self
) -> Result<StatelessTransportState, Error>
[src]Convert this HandshakeState
into a StatelessTransportState
without an internally stored nonce.
Trait Implementations
impl Debug for HandshakeState
[src]
impl Debug for HandshakeState
[src]impl TryFrom<HandshakeState> for TransportState
[src]
impl TryFrom<HandshakeState> for TransportState
[src]Auto Trait Implementations
impl !RefUnwindSafe for HandshakeState
impl Send for HandshakeState
impl Sync for HandshakeState
impl Unpin for HandshakeState
impl !UnwindSafe for HandshakeState
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<T> Same<T> for T
impl<T> Same<T> for T
type Output = T
type Output = T
Should always be Self
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,