Struct internet2::session::noise::NoiseTranscoder
source · pub struct NoiseTranscoder<const LEN_SIZE: usize> {
pub encryptor: NoiseEncryptor<LEN_SIZE>,
pub decryptor: NoiseDecryptor<LEN_SIZE>,
}
Expand description
Returned after a successful handshake to encrypt and decrypt communication
with peer nodes. It should not normally be manually instantiated.
Automatically handles key rotation.
For decryption, it is recommended to call decrypt_message_stream
for
automatic buffering.
Fields§
§encryptor: NoiseEncryptor<LEN_SIZE>
§decryptor: NoiseDecryptor<LEN_SIZE>
Implementations§
source§impl<const LEN_SIZE: usize> NoiseTranscoder<LEN_SIZE>
impl<const LEN_SIZE: usize> NoiseTranscoder<LEN_SIZE>
sourcepub fn with(
sending_key: [u8; 32],
receiving_key: [u8; 32],
chaining_key: [u8; 32],
remote_pubkey: PublicKey
) -> Self
pub fn with(
sending_key: [u8; 32],
receiving_key: [u8; 32],
chaining_key: [u8; 32],
remote_pubkey: PublicKey
) -> Self
Instantiate a new Conduit with specified sending and receiving keys
pub fn remote_pubkey(&self) -> PublicKey
sourcepub fn encrypt_buf(&mut self, buffer: &[u8]) -> Result<Vec<u8>, EncryptionError>
pub fn encrypt_buf(&mut self, buffer: &[u8]) -> Result<Vec<u8>, EncryptionError>
Encrypt data to be sent to peer
pub fn read_buf(&mut self, data: &[u8])
sourcepub fn decrypt_single_message(
&mut self,
new_data: Option<&[u8]>
) -> Result<Option<Vec<u8>>, EncryptionError>
pub fn decrypt_single_message(
&mut self,
new_data: Option<&[u8]>
) -> Result<Option<Vec<u8>>, EncryptionError>
Decrypt a single message. If data containing more than one message has been received, only the first message will be returned, and the rest stored in the internal buffer. If a message pending in the buffer still hasn’t been decrypted, that message will be returned in lieu of anything new, even if new data is provided.
Trait Implementations§
source§impl<const LEN_SIZE: usize> Bipolar for NoiseTranscoder<LEN_SIZE>
impl<const LEN_SIZE: usize> Bipolar for NoiseTranscoder<LEN_SIZE>
§type Left = <NoiseTranscoder<LEN_SIZE> as Transcode>::Decryptor
type Left = <NoiseTranscoder<LEN_SIZE> as Transcode>::Decryptor
First separable type (like reader)
§type Right = <NoiseTranscoder<LEN_SIZE> as Transcode>::Encryptor
type Right = <NoiseTranscoder<LEN_SIZE> as Transcode>::Encryptor
Second separable type (like writer)