aboutsummaryrefslogtreecommitdiff
path: root/azalea-crypto
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2022-06-23 15:12:17 -0500
committermat <github@matdoes.dev>2022-06-23 15:12:17 -0500
commit5ca49e680ed8519456dc9a9af84321d4b69dcbb3 (patch)
tree0f727c3e862f60eb227db69c87946a0f629a397d /azalea-crypto
parentc7b0c51274b5d8548c8a2f829b75dfbec4038be2 (diff)
downloadazalea-drasl-5ca49e680ed8519456dc9a9af84321d4b69dcbb3.tar.xz
azalea-buf
Diffstat (limited to 'azalea-crypto')
-rw-r--r--azalea-crypto/Cargo.toml1
-rw-r--r--azalea-crypto/src/lib.rs2
-rw-r--r--azalea-crypto/src/signing.rs16
3 files changed, 19 insertions, 0 deletions
diff --git a/azalea-crypto/Cargo.toml b/azalea-crypto/Cargo.toml
index 2532bff9..ee652565 100644
--- a/azalea-crypto/Cargo.toml
+++ b/azalea-crypto/Cargo.toml
@@ -7,6 +7,7 @@ version = "0.1.0"
[dependencies]
aes = "0.8.1"
+azalea-buf = {path = "../azalea-buf"}
cfb8 = "0.8.1"
num-bigint = "^0.4.3"
rand = {version = "^0.8.4", features = ["getrandom"]}
diff --git a/azalea-crypto/src/lib.rs b/azalea-crypto/src/lib.rs
index a5e797e8..85705883 100644
--- a/azalea-crypto/src/lib.rs
+++ b/azalea-crypto/src/lib.rs
@@ -79,6 +79,8 @@ pub fn decrypt_packet(cipher: &mut Aes128CfbDec, packet: &mut [u8]) {
cipher.decrypt_blocks_inout_mut(chunks);
}
+
+
#[cfg(test)]
mod tests {
use super::*;
diff --git a/azalea-crypto/src/signing.rs b/azalea-crypto/src/signing.rs
index 21cd813a..a5280a18 100644
--- a/azalea-crypto/src/signing.rs
+++ b/azalea-crypto/src/signing.rs
@@ -3,3 +3,19 @@ pub struct SaltSignaturePair {
pub salt: u64,
pub signature: Vec<u8>,
}
+
+impl McBufReadable for SaltSignaturePair {
+ fn read_into(buf: &mut impl Read) -> Result<Self, String> {
+ let salt = u64::read_into(buf)?;
+ let signature = Vec::<u8>::read_into(buf)?;
+ Ok(SaltSignaturePair { salt, signature })
+ }
+}
+
+impl McBufWritable for SaltSignaturePair {
+ fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
+ self.salt.write_into(buf)?;
+ self.signature.write_into(buf)?;
+ Ok(())
+ }
+}