Struct snow::StatelessTransportState
source · pub struct StatelessTransportState { /* private fields */ }
Expand description
A state machine encompassing the transport phase of a Noise session, using the two
CipherState
s (for sending and receiving) that were spawned from the SymmetricState
’s
Split()
method, called after a handshake has been finished.
See: http://noiseprotocol.org/noise.html#the-handshakestate-object
Implementations§
source§impl StatelessTransportState
impl StatelessTransportState
sourcepub fn get_remote_static(&self) -> Option<&[u8]>
pub fn get_remote_static(&self) -> Option<&[u8]>
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).
sourcepub fn write_message(
&self,
nonce: u64,
payload: &[u8],
message: &mut [u8]
) -> Result<usize, Error>
pub fn write_message( &self, nonce: u64, payload: &[u8], message: &mut [u8] ) -> Result<usize, Error>
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 Error::Input
if the size of the output exceeds the max message
length in the Noise Protocol (65535 bytes).
sourcepub fn read_message(
&self,
nonce: u64,
payload: &[u8],
message: &mut [u8]
) -> Result<usize, Error>
pub fn read_message( &self, nonce: u64, payload: &[u8], message: &mut [u8] ) -> Result<usize, Error>
Reads a noise message from input
Returns the size of the payload written to payload
.
Errors
Will result in Error::Decrypt
if the contents couldn’t be decrypted and/or the
authentication tag didn’t verify.
Will result in StateProblem::Exhausted
if the max nonce overflows.
sourcepub fn rekey_outgoing(&mut self)
pub fn rekey_outgoing(&mut self)
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.
sourcepub fn rekey_incoming(&mut self)
pub fn rekey_incoming(&mut self)
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.
sourcepub fn rekey_manually(
&mut self,
initiator: Option<&[u8]>,
responder: Option<&[u8]>
)
pub fn rekey_manually( &mut self, initiator: Option<&[u8]>, responder: Option<&[u8]> )
Set a new key for the one or both of the initiator-egress and responder-egress symmetric ciphers.
sourcepub fn rekey_initiator_manually(&mut self, key: &[u8])
pub fn rekey_initiator_manually(&mut self, key: &[u8])
Set a new key for the initiator-egress symmetric cipher.
sourcepub fn rekey_responder_manually(&mut self, key: &[u8])
pub fn rekey_responder_manually(&mut self, key: &[u8])
Set a new key for the responder-egress symmetric cipher.
sourcepub fn is_initiator(&self) -> bool
pub fn is_initiator(&self) -> bool
Check if this session was started with the “initiator” role.