From 8317b5b28153794770a8c7b84a1b6dd50eaa3f80 Mon Sep 17 00:00:00 2001 From: mat Date: Fri, 29 Apr 2022 20:20:56 -0500 Subject: upgrade aes and cfb8 --- azalea-protocol/src/connect.rs | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'azalea-protocol/src/connect.rs') diff --git a/azalea-protocol/src/connect.rs b/azalea-protocol/src/connect.rs index e81bc368..c55f2e90 100755 --- a/azalea-protocol/src/connect.rs +++ b/azalea-protocol/src/connect.rs @@ -7,7 +7,7 @@ use crate::packets::status::StatusPacket; use crate::read::read_packet; use crate::write::write_packet; use crate::ServerIpAddress; -use azalea_auth::encryption::Aes128Cfb; +use azalea_auth::encryption::{Aes128CfbDec, Aes128CfbEnc}; use tokio::net::TcpStream; pub enum PacketFlow { @@ -26,7 +26,8 @@ pub struct GameConnection { /// The buffered writer pub stream: TcpStream, pub compression_threshold: Option, - pub cipher: Option, + pub enc_cipher: Option, + pub dec_cipher: Option, } pub struct StatusConnection { @@ -40,7 +41,8 @@ pub struct LoginConnection { /// The buffered writer pub stream: TcpStream, pub compression_threshold: Option, - pub cipher: Option, + pub enc_cipher: Option, + pub dec_cipher: Option, } impl HandshakeConnection { @@ -68,7 +70,8 @@ impl HandshakeConnection { flow: self.flow, stream: self.stream, compression_threshold: None, - cipher: None, + enc_cipher: None, + dec_cipher: None, } } @@ -95,7 +98,7 @@ impl GameConnection { &self.flow, &mut self.stream, self.compression_threshold, - &mut self.cipher, + &mut self.dec_cipher, ) .await } @@ -106,7 +109,7 @@ impl GameConnection { packet, &mut self.stream, self.compression_threshold, - &mut self.cipher, + &mut self.enc_cipher, ) .await; } @@ -129,7 +132,7 @@ impl LoginConnection { &self.flow, &mut self.stream, self.compression_threshold, - &mut self.cipher, + &mut self.dec_cipher, ) .await } @@ -140,7 +143,7 @@ impl LoginConnection { packet, &mut self.stream, self.compression_threshold, - &mut self.cipher, + &mut self.enc_cipher, ) .await; } @@ -156,8 +159,9 @@ impl LoginConnection { pub fn set_encryption_key(&mut self, key: [u8; 16]) { // minecraft has a cipher decoder and encoder, i don't think it matters though? - let cipher = azalea_auth::encryption::create_cipher(&key); - self.cipher = Some(cipher); + let (enc_cipher, dec_cipher) = azalea_auth::encryption::create_cipher(&key); + self.enc_cipher = Some(enc_cipher); + self.dec_cipher = Some(dec_cipher); } pub fn game(self) -> GameConnection { @@ -165,7 +169,8 @@ impl LoginConnection { flow: self.flow, stream: self.stream, compression_threshold: self.compression_threshold, - cipher: self.cipher, + enc_cipher: self.enc_cipher, + dec_cipher: self.dec_cipher, } } } -- cgit v1.2.3