From d1ff9537178b7ad3e2a4ba39b0c7dab07360babc Mon Sep 17 00:00:00 2001 From: zontreck Date: Thu, 29 Aug 2024 16:25:28 -0700 Subject: [PATCH] Fix sha56 byte count in protocol --- lib/consts.dart | 2 +- lib/packets/packets.dart | 4 ++-- pubspec.yaml | 2 +- test/hash_test.dart | 10 ++++++++++ test/io_test.dart | 2 +- 5 files changed, 15 insertions(+), 5 deletions(-) diff --git a/lib/consts.dart b/lib/consts.dart index 8f39773..ebe62f4 100644 --- a/lib/consts.dart +++ b/lib/consts.dart @@ -1,3 +1,3 @@ class Constants { - static const VERSION = "1.2.082924+1513"; + static const VERSION = "1.2.082924+1625"; } diff --git a/lib/packets/packets.dart b/lib/packets/packets.dart index 803b898..4b6a878 100644 --- a/lib/packets/packets.dart +++ b/lib/packets/packets.dart @@ -41,7 +41,7 @@ class PacketServer { layer.resetPosition(); layer.readLong(); // This is unused outside of the above sanity check. try { - List dataHash = layer.readBytes(256); + List dataHash = layer.readBytes(32); // Sha256 int sequenceID = layer.readLong(); print("Sequence ID in request: $sequenceID"); @@ -196,7 +196,7 @@ class PacketClient { reply.readLong(); // This is unused outside of the sanity check above. int sequence = reply.readLong(); int successReceipt = reply.readByte(); - List serverHash = reply.readBytes(256); + List serverHash = reply.readBytes(32); String srvHashStr = Hashing.bytes2Hash(serverHash); int numBytes = reply.readLong(); List pktBytes = reply.readBytes(numBytes); diff --git a/pubspec.yaml b/pubspec.yaml index ffb6e19..52cea17 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: libac_dart description: "Aria's Creations code library" -version: 1.2.082924+1513 +version: 1.2.082924+1625 homepage: "https://zontreck.com" diff --git a/test/hash_test.dart b/test/hash_test.dart index 9539fa7..1ec7fdf 100644 --- a/test/hash_test.dart +++ b/test/hash_test.dart @@ -6,4 +6,14 @@ void main() { test("Test md5", () { expect(Hashing.md5Hash("Hello World"), "b10a8db164e0754105b7a99be72e3fe5"); }); + + test("Test sha256", () { + List hsh = Hashing.sha256Sum([0x0A, 0x0B]); + print("Sha256 Length: ${hsh.length}"); + + print("Sha256 Hash: ${Hashing.bytes2Hash(hsh)}"); + + expect(Hashing.bytes2Hash(hsh), + "bea0b72e71bfe7f15a88c25305bf96a9681e34d3aabe0c9a1b7093cb32d8ff05"); + }); } diff --git a/test/io_test.dart b/test/io_test.dart index e86458f..57f9aaf 100644 --- a/test/io_test.dart +++ b/test/io_test.dart @@ -11,7 +11,7 @@ Future main() async { }); test("Test directory size checking", () async { - expect(await getDirectorySize("test"), 12819); + expect(await getDirectorySize("test"), 13118); }); test("Test file info methods", () async {