[−][src]Enum snow::Session
A state machine for the entire Noise session.
Enums provide a convenient interface as it's how Rust implements union structs, meaning this is a sized object.
Variants
Handshake(HandshakeState)
A session in the handshake stage (the starting state).
Transport(TransportState)
A session after having completed a handshake, in general-purpose trasport mode.
StatelessTransport(StatelessTransportState)
A session after having completed a handshake, in explicit-nonce trasport mode.
Methods
impl Session
[src]
impl Session
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 is_handshake_finished(&self) -> bool | [src] |
True if the handshake is finished and the Session state machine is ready to be transitioned to transport mode. This function also returns a vacuous true if already in transport mode.
Examples
let mut session = Builder::new("Noise_NN_25519_AESGCM_SHA256".parse()?) .build_initiator()?; if (session.is_handshake_finished()) { session = session.into_transport_mode()?; }
pub fn is_initiator(&self) -> bool | [src] |
Will report if the session has the initiator role (i.e. was built with Builder.build_initiator()
).
| [src] |
Construct a message from payload
(and pending handshake tokens if in handshake state),
and writes it to the output
buffer.
Returns the size of the written payload.
Errors
Will result in SnowError::Input
if the size of the output exceeds the max message
length in the Noise Protocol (65535 bytes).
| [src] |
Construct a message from payload
with an explicitly provided nonce and write it to the
output
buffer.
Returns the size of the written payload.
Errors
Will result in SnowError::Input
if the size of the output exceeds the max message
length in the Noise Protocol (65535 bytes).
Will result in SnowError::StateProblem
if not in stateless transport mode.
| [src] |
Reads a noise message from input
Returns the size of the payload written to payload
.
Errors
Will result in SnowError::Decrypt
if the contents couldn't be decrypted and/or the
authentication tag didn't verify.
Panics
This function will panic if there is no key, or if there is a nonce overflow.
| [src] |
Construct a message from payload
(and pending handshake tokens if in handshake state),
and writes it to the output
buffer.
Returns the size of the written payload.
Errors
Will result in SnowError::Input
if the size of the output exceeds the max message
length in the Noise Protocol (65535 bytes).
Will result in SnowError::StateProblem
if not in stateless transport mode.
| [src] |
Generates a new key for the egress symmetric cipher according to Section 4.2 of the Noise Specification. Synchronizing timing of rekey between initiator and responder is the responsibility of the application, as described in Section 11.3 of the Noise Specification.
Errors
Will result in SnowError::State
if not in transport mode.
| [src] |
Generates a new key for the ingress symmetric cipher according to Section 4.2 of the Noise Specification. Synchronizing timing of rekey between initiator and responder is the responsibility of the application, as described in Section 11.3 of the Noise Specification.
Errors
Will result in SnowError::State
if not in transport mode.
| [src] |
Set a new key for the one or both of the initiator-egress and responder-egress symmetric ciphers.
Errors
Will result in SnowError::State
if not in transport mode.
pub fn receiving_nonce(&self) -> Result<u64, SnowError> | [src] |
Get the forthcoming inbound nonce value.
Errors
Will result in SnowError::State
if not in transport mode.
pub fn sending_nonce(&self) -> Result<u64, SnowError> | [src] |
Get the forthcoming outbound nonce value.
Errors
Will result in SnowError::State
if not in transport mode.
pub fn get_remote_static(&self) -> Option<&[u8]> | [src] |
Get the remote static key that was possibly encrypted in the first payload.
Returns a slice of length Dh.pub_len()
(i.e. DHLEN for the chosen DH function).
pub fn get_handshake_hash(&self) -> Result<&[u8], SnowError> | [src] |
Get the handshake hash.
Returns a slice of length Hasher.hash_len()
(i.e. HASHLEN for the chosen Hash function).
| [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 SnowError::Input
if the PSK is not the right length or the location is out of bounds.
Will result in SnowError::State
if in transport mode.
pub fn into_transport_mode(self) -> Result<Self, SnowError> | [src] |
Transition the session into transport mode. This can only be done once the handshake has finished.
Consumes the previous state, and returns the new transport state object, thereby freeing any material only used during the handshake phase.
Errors
Will result in SnowError::State
if the handshake is not finished.
Examples
let mut session = Builder::new("Noise_NN_25519_AESGCM_SHA256".parse()?) .build_initiator()?; // ... complete handshake ... session = session.into_transport_mode()?;
pub fn into_stateless_transport_mode(self) -> Result<Self, SnowError> | [src] |
Transition the session into stateless (explicit nonce) transport mode.
This is useful when using Noise over lossy transports.
Like into_transport_mode()
, this can only be done once the handshake has finished.
Consumes the previous state, and returns the new transport state object, thereby freeing any material only used during the handshake phase.
Errors
Will result in SnowError::State
if the handshake is not finished.
Examples
let mut session = Builder::new("Noise_NN_25519_AESGCM_SHA256".parse()?) .build_initiator()?; // ... complete handshake ... session = session.into_stateless_transport_mode()?;
Trait Implementations
Auto Trait Implementations
Blanket Implementations
impl<T> From for T
[src]
impl<T> From for T
impl<T, U> Into for T where
U: From<T>,
[src]
impl<T, U> Into for T where
U: From<T>,
impl<T, U> TryFrom for T where
T: From<U>,
[src]
impl<T, U> TryFrom for T where
T: From<U>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error> | [src] |
impl<T> Borrow for T where
T: ?Sized,
[src]
impl<T> Borrow for T where
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
impl<T> BorrowMut for T where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T | [src] |
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error> | [src] |
impl<T> Any for T where
T: 'static + ?Sized,
[src]
impl<T> Any for T where
T: 'static + ?Sized,
fn get_type_id(&self) -> TypeId | [src] |
impl<T> Same for T
impl<T> Same for T
type Output = T
Should always be Self