mirror of
https://github.com/mat-1/azalea.git
synced 2024-09-19 14:42:32 +00:00
azalea_auth::encryption -> azalea_crypto
This commit is contained in:
parent
cc70d80932
commit
80d49a7607
13 changed files with 49 additions and 27 deletions
36
Cargo.lock
generated
36
Cargo.lock
generated
|
@ -75,12 +75,7 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
|
|||
name = "azalea-auth"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"aes",
|
||||
"cfb8",
|
||||
"num-bigint",
|
||||
"rand",
|
||||
"rsa_public_encrypt_pkcs1",
|
||||
"sha-1",
|
||||
"uuid",
|
||||
]
|
||||
|
||||
|
@ -102,6 +97,7 @@ name = "azalea-client"
|
|||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"azalea-auth",
|
||||
"azalea-crypto",
|
||||
"azalea-protocol",
|
||||
"tokio",
|
||||
]
|
||||
|
@ -115,6 +111,18 @@ dependencies = [
|
|||
"uuid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "azalea-crypto"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"aes",
|
||||
"cfb8",
|
||||
"num-bigint",
|
||||
"rand",
|
||||
"rsa_public_encrypt_pkcs1",
|
||||
"sha-1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "azalea-nbt"
|
||||
version = "0.1.0"
|
||||
|
@ -140,6 +148,7 @@ dependencies = [
|
|||
"azalea-brigadier",
|
||||
"azalea-chat",
|
||||
"azalea-core",
|
||||
"azalea-crypto",
|
||||
"azalea-nbt",
|
||||
"byteorder",
|
||||
"bytes",
|
||||
|
@ -163,9 +172,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
|||
|
||||
[[package]]
|
||||
name = "block-buffer"
|
||||
version = "0.10.0"
|
||||
version = "0.10.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f1d36a02058e76b040de25a4464ba1c80935655595b661505c8b39b664828b95"
|
||||
checksum = "0bf7fe51849ea569fd452f37822f606a5cabb684dc918707a0193fd4664ff324"
|
||||
dependencies = [
|
||||
"generic-array",
|
||||
]
|
||||
|
@ -404,13 +413,12 @@ checksum = "3ee2393c4a91429dffb4bedf19f4d6abf27d8a732c8ce4980305d782e5426d57"
|
|||
|
||||
[[package]]
|
||||
name = "digest"
|
||||
version = "0.10.1"
|
||||
version = "0.10.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b697d66081d42af4fba142d56918a3cb21dc8eb63372c6b85d14f44fb9c5979b"
|
||||
checksum = "f2fb860ca6fafa5552fb6d0e816a69c8e49f0908bf524e30a90d97c85892d506"
|
||||
dependencies = [
|
||||
"block-buffer",
|
||||
"crypto-common",
|
||||
"generic-array",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -784,9 +792,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "num-complex"
|
||||
version = "0.4.0"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "26873667bbbb7c5182d4a37c1add32cdf09f841af72da53318fdb81543c15085"
|
||||
checksum = "97fbc387afefefd5e9e39493299f3069e14a140dd34dc19b4c1c1a8fddb6a790"
|
||||
dependencies = [
|
||||
"num-traits",
|
||||
]
|
||||
|
@ -814,9 +822,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "num-iter"
|
||||
version = "0.1.42"
|
||||
version = "0.1.43"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b2021c8337a54d21aca0d59a92577a029af9431cb59b909b03252b9c164fad59"
|
||||
checksum = "7d03e6c028c5dc5cac6e2dec0efda81fc887605bb3d884578bb6d6bf7514e252"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"num-integer",
|
||||
|
|
|
@ -9,6 +9,7 @@ members = [
|
|||
"azalea-auth",
|
||||
"azalea-nbt",
|
||||
"azalea-brigadier",
|
||||
"azalea-crypto",
|
||||
]
|
||||
|
||||
[profile.release]
|
||||
|
|
|
@ -6,10 +6,5 @@ version = "0.1.0"
|
|||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
aes = "0.8.1"
|
||||
cfb8 = "0.8.1"
|
||||
num-bigint = "^0.4.3"
|
||||
rand = {version = "^0.8.4", features = ["getrandom"]}
|
||||
rsa_public_encrypt_pkcs1 = "0.4.0"
|
||||
sha-1 = "^0.10.0"
|
||||
uuid = "^0.8.2"
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
//! Handle Minecraft authentication.
|
||||
|
||||
pub mod encryption;
|
||||
pub mod game_profile;
|
||||
|
|
|
@ -7,5 +7,6 @@ version = "0.1.0"
|
|||
|
||||
[dependencies]
|
||||
azalea-auth = {path = "../azalea-auth"}
|
||||
azalea-crypto = {path = "../azalea-crypto"}
|
||||
azalea-protocol = {path = "../azalea-protocol"}
|
||||
tokio = {version = "1.18.0", features = ["sync"]}
|
||||
|
|
|
@ -74,7 +74,7 @@ impl Client {
|
|||
Ok(packet) => match packet {
|
||||
LoginPacket::ClientboundHelloPacket(p) => {
|
||||
println!("Got encryption request");
|
||||
let e = azalea_auth::encryption::encrypt(&p.public_key, &p.nonce).unwrap();
|
||||
let e = azalea_crypto::encrypt(&p.public_key, &p.nonce).unwrap();
|
||||
|
||||
// TODO: authenticate with the server here (authenticateServer)
|
||||
|
||||
|
|
14
azalea-crypto/Cargo.toml
Normal file
14
azalea-crypto/Cargo.toml
Normal file
|
@ -0,0 +1,14 @@
|
|||
[package]
|
||||
edition = "2021"
|
||||
name = "azalea-crypto"
|
||||
version = "0.1.0"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
aes = "0.8.1"
|
||||
cfb8 = "0.8.1"
|
||||
num-bigint = "^0.4.3"
|
||||
rand = {version = "^0.8.4", features = ["getrandom"]}
|
||||
rsa_public_encrypt_pkcs1 = "0.4.0"
|
||||
sha-1 = "^0.10.0"
|
3
azalea-crypto/README.md
Normal file
3
azalea-crypto/README.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
# Azalea Crypto
|
||||
|
||||
Cryprography features used in Minecraft.
|
|
@ -13,6 +13,7 @@ azalea-auth = {path = "../azalea-auth"}
|
|||
azalea-brigadier = {path = "../azalea-brigadier"}
|
||||
azalea-chat = {path = "../azalea-chat"}
|
||||
azalea-core = {path = "../azalea-core"}
|
||||
azalea-crypto = {path = "../azalea-crypto"}
|
||||
azalea-nbt = {path = "../azalea-nbt"}
|
||||
byteorder = "^1.4.3"
|
||||
bytes = "^1.1.0"
|
||||
|
|
|
@ -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::{Aes128CfbDec, Aes128CfbEnc};
|
||||
use azalea_crypto::{Aes128CfbDec, Aes128CfbEnc};
|
||||
use tokio::net::TcpStream;
|
||||
|
||||
pub enum PacketFlow {
|
||||
|
@ -159,7 +159,7 @@ 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 (enc_cipher, dec_cipher) = azalea_auth::encryption::create_cipher(&key);
|
||||
let (enc_cipher, dec_cipher) = azalea_crypto::create_cipher(&key);
|
||||
self.enc_cipher = Some(enc_cipher);
|
||||
self.dec_cipher = Some(dec_cipher);
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ use std::{
|
|||
|
||||
use crate::{connect::PacketFlow, mc_buf::Readable, packets::ProtocolPacket};
|
||||
use async_compression::tokio::bufread::ZlibDecoder;
|
||||
use azalea_auth::encryption::Aes128CfbDec;
|
||||
use azalea_crypto::Aes128CfbDec;
|
||||
use tokio::io::{AsyncRead, AsyncReadExt};
|
||||
|
||||
async fn frame_splitter<R: ?Sized>(mut stream: &mut R) -> Result<Vec<u8>, String>
|
||||
|
@ -122,7 +122,7 @@ where
|
|||
// (but only on linux and release mode for some reason LMAO)
|
||||
if buf.remaining() == 0 {
|
||||
if let Some(cipher) = self.as_mut().cipher.get_mut() {
|
||||
azalea_auth::encryption::decrypt_packet(cipher, buf.filled_mut());
|
||||
azalea_crypto::decrypt_packet(cipher, buf.filled_mut());
|
||||
}
|
||||
}
|
||||
match r {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::{mc_buf::Writable, packets::ProtocolPacket, read::MAXIMUM_UNCOMPRESSED_LENGTH};
|
||||
use async_compression::tokio::bufread::ZlibEncoder;
|
||||
use azalea_auth::encryption::Aes128CfbEnc;
|
||||
use azalea_crypto::Aes128CfbEnc;
|
||||
use std::fmt::Debug;
|
||||
use tokio::{
|
||||
io::{AsyncReadExt, AsyncWrite, AsyncWriteExt},
|
||||
|
@ -67,7 +67,7 @@ pub async fn write_packet<P, W>(
|
|||
}
|
||||
// if we were given a cipher, encrypt the packet
|
||||
if let Some(cipher) = cipher {
|
||||
azalea_auth::encryption::encrypt_packet(cipher, &mut buf);
|
||||
azalea_crypto::encrypt_packet(cipher, &mut buf);
|
||||
}
|
||||
buf = frame_prepender(&mut buf).unwrap();
|
||||
stream.write_all(&buf).await.unwrap();
|
||||
|
|
Loading…
Reference in a new issue