diff options
| author | mat <27899617+mat-1@users.noreply.github.com> | 2022-06-25 05:09:26 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-06-25 05:09:26 +0000 |
| commit | 7d3e57763e32ac9cf94180b1c714704cfbc3034d (patch) | |
| tree | 2dcfe72bf09a42f6614f9dc988dc0254162ea0bf /azalea-crypto | |
| parent | 69c47eda4c496b13dadd80976bffd2fab7ea5894 (diff) | |
| parent | ca7067e173129f3044ebc8c77634f06da29a086e (diff) | |
| download | azalea-drasl-7d3e57763e32ac9cf94180b1c714704cfbc3034d.tar.xz | |
Merge pull request #10 from mat-1/azalea-entity
azalea-entity
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..4fc07d30 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_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(()) + } +} |
