diff options
| author | mat <github@matdoes.dev> | 2022-06-25 14:25:56 -0500 |
|---|---|---|
| committer | mat <github@matdoes.dev> | 2022-06-25 14:25:56 -0500 |
| commit | c46eb556e2e7964f0709572a0151c181752c3182 (patch) | |
| tree | da65427d74aaa66e002385989faee04c7bac6cbd /azalea-crypto | |
| parent | 8755f18c2b0c11a51a81f60b5501d9d57d0c370e (diff) | |
| parent | 77980f0018eca3a192994021b76ad5d05bff88ea (diff) | |
| download | azalea-drasl-c46eb556e2e7964f0709572a0151c181752c3182.tar.xz | |
Merge branch 'main' into 1.19.1
Diffstat (limited to 'azalea-crypto')
| -rw-r--r-- | azalea-crypto/Cargo.toml | 1 | ||||
| -rw-r--r-- | azalea-crypto/src/signing.rs | 19 |
2 files changed, 20 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/signing.rs b/azalea-crypto/src/signing.rs index 21cd813a..535f9f1d 100644 --- a/azalea-crypto/src/signing.rs +++ b/azalea-crypto/src/signing.rs @@ -1,5 +1,24 @@ +use azalea_buf::{McBufReadable, McBufWritable}; +use std::io::{Read, Write}; + #[derive(Debug, Clone)] pub struct SaltSignaturePair { pub salt: u64, pub signature: Vec<u8>, } + +impl McBufReadable for SaltSignaturePair { + fn read_from(buf: &mut impl Read) -> Result<Self, String> { + let salt = u64::read_from(buf)?; + let signature = Vec::<u8>::read_from(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(()) + } +} |
