Struct diem_crypto::noise::NoiseSession
source · pub struct NoiseSession { /* private fields */ }
Expand description
A NoiseSession is produced after a successful Noise handshake, and can be use to encrypt and decrypt messages to the other peer.
Implementations§
source§impl NoiseSession
impl NoiseSession
sourcepub fn new_for_testing() -> Self
pub fn new_for_testing() -> Self
create a dummy session with 0 keys
sourcepub fn get_remote_static(&self) -> PublicKey
pub fn get_remote_static(&self) -> PublicKey
obtain remote static public key
sourcepub fn write_message_in_place(
&mut self,
message: &mut [u8]
) -> Result<Vec<u8>, NoiseError>
pub fn write_message_in_place( &mut self, message: &mut [u8] ) -> Result<Vec<u8>, NoiseError>
encrypts a message for the other peers (post-handshake) the function encrypts in place, and returns the authentication tag as result
sourcepub fn read_message_in_place<'a>(
&mut self,
message: &'a mut [u8]
) -> Result<&'a [u8], NoiseError>
pub fn read_message_in_place<'a>( &mut self, message: &'a mut [u8] ) -> Result<&'a [u8], NoiseError>
decrypts a message from the other peer (post-handshake) the function decrypts in place, and returns a subslice without the auth tag