pub fn encrypt_message(&mut self, msg: &[u8]) -> Vec<u8> {
		if msg.len() > 65535 {
			panic!("Attempted to encrypt message longer than 65535 bytes!");
		}

		let mut res = Vec::with_capacity(msg.len() + 16 * 2 + 2);
		res.resize(msg.len() + 16 * 2 + 2, 0);

		match self.noise_state {
			Finished {
				ref mut sk,
				ref mut sn,
				ref mut sck,
				rk: _,
				rn: _,
				rck: _,
			} => {
				if *sn >= 1000 {
					let (new_sck, new_sk) = Self::hkdf_extract_expand(sck, sk);
					*sck = new_sck;
					*sk = new_sk;
					*sn = 0;
				}

				Self::encrypt_with_ad(
					&mut res[0..16 + 2],
					*sn,
					sk,
					&[0; 0],
					&byte_utils::be16_to_array(msg.len() as u16),
				);
				*sn += 1;

				Self::encrypt_with_ad(&mut res[16 + 2..], *sn, sk, &[0; 0], msg);
				*sn += 1;
			}
		}

		res
	}
/// Encrypts the given message, returning the encrypted version
/// panics if msg.len() > 65535.
Encrypts the given message, returning the encrypted version
panics if msg.len() > 65535.
Encrypts the given message returning the encrypted version panics if msg . len () > 65535 .
pub fn encrypt_message(&mut self, msg: &[u8]) -> Vec<u8> {
		if msg.len() > 65535 {
			panic!("Attempted to encrypt message longer than 65535 bytes!");
		}
		let mut res = Vec::with_capacity(msg.len() + 16 * 2 + 2);
		res.resize(msg.len() + 16 * 2 + 2, 0);
		match self.noise_state {
			Finished {
				ref mut sk,
				ref mut sn,
				ref mut sck,
				rk: _,
				rn: _,
				rck: _,
			} => {
				if *sn >= 1000 {
					let (new_sck, new_sk) = Self::hkdf_extract_expand(sck, sk);
					*sck = new_sck;
					*sk = new_sk;
					*sn = 0;
				}
				Self::encrypt_with_ad(
					&mut res[0..16 + 2],
					*sn,
					sk,
					&[0; 0],
					&byte_utils::be16_to_array(msg.len() as u16),
				);
				*sn += 1;
				Self::encrypt_with_ad(&mut res[16 + 2..], *sn, sk, &[0; 0], msg);
				*sn += 1;
			}
		}
		res
	}
pub fn encrypt_message ( & mut self , msg : & [ u8 ] ) -> Vec < u8 > { if msg . len ( ) > 65535 { panic ! ( " " ) ; } let mut res = Vec :: with_capacity ( msg . len ( ) + 16 * 2 + 2 ) ; res . resize ( msg . len ( ) + 16 * 2 + 2 , 0 ) ; match self . noise_state { Finished { ref mut sk , ref mut sn , ref mut sck , rk : _ , rn : _ , rck : _ , } => { if * sn >= 1000 { let ( new_sck , new_sk ) = Self :: hkdf_extract_expand ( sck , sk ) ; * sck = new_sck ; * sk = new_sk ; * sn = 0 ; } Self :: encrypt_with_ad ( & mut res [ 0 .. 16 + 2 ] , * sn , sk , & [ 0 ; 0 ] , & byte_utils :: be16_to_array ( msg . len ( ) as u16 ) , ) ; * sn += 1 ; Self :: encrypt_with_ad ( & mut res [ 16 + 2 .. ] , * sn , sk , & [ 0 ; 0 ] , msg ) ; * sn += 1 ; } } res }
Encrypts the given message, returning the encrypted version
panics if msg.len() > 65535.
Encrypts the given message returning the encrypted version panics if msg . len () > 65535 .
&mut self
msg
&[u8]