From b35ef2b62421b12b67828f4ba047ae361a6642ed Mon Sep 17 00:00:00 2001 From: TheTank20 Date: Fri, 25 Jul 2025 00:16:15 -0500 Subject: [PATCH] Free the SHA1 implementation --- CMakeLists.txt | 4 ++-- build/.gitkeep | 0 src/libumskt/libumskt.h | 3 +-- src/libumskt/pidgen3/BINK1998.cpp | 4 ++-- src/libumskt/pidgen3/BINK2002.cpp | 8 ++++---- 5 files changed, 9 insertions(+), 10 deletions(-) delete mode 100644 build/.gitkeep diff --git a/CMakeLists.txt b/CMakeLists.txt index 7bcc8bb..6609ecc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -240,7 +240,7 @@ CPMAddPackage( ### Resource compilation CMRC_ADD_RESOURCE_LIBRARY(umskt-rc ALIAS umskt::rc NAMESPACE umskt keys.json) -SET(LIBUMSKT_SRC src/libumskt/libumskt.cpp src/libumskt/pidgen3/BINK1998.cpp src/libumskt/pidgen3/BINK2002.cpp src/libumskt/pidgen3/key.cpp src/libumskt/pidgen3/util.cpp src/libumskt/confid/confid.cpp src/libumskt/pidgen2/PIDGEN2.cpp src/libumskt/debugoutput.cpp) +SET(LIBUMSKT_SRC src/libumskt/libumskt.cpp src/libumskt/sha1/sha1.cpp src/libumskt/pidgen3/BINK1998.cpp src/libumskt/pidgen3/BINK2002.cpp src/libumskt/pidgen3/key.cpp src/libumskt/pidgen3/util.cpp src/libumskt/confid/confid.cpp src/libumskt/pidgen2/PIDGEN2.cpp src/libumskt/debugoutput.cpp) #### Separate Build Path for emscripten IF (EMSCRIPTEN) @@ -298,4 +298,4 @@ ELSE() message(STATUS "[UMSKT] CWSDSTUB_LOCATION set to: ${CWSDSTUB_LOCATION}") message(STATUS "[UMSKT] DJGPP_BIN_LOCATION set to: ${DJGPP_BIN_LOCATION}") ENDIF() -ENDIF() +ENDIF() \ No newline at end of file diff --git a/build/.gitkeep b/build/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/src/libumskt/libumskt.h b/src/libumskt/libumskt.h index d30cf89..bc91ac9 100644 --- a/src/libumskt/libumskt.h +++ b/src/libumskt/libumskt.h @@ -35,10 +35,9 @@ #include #include -#include #include -// Remove openssl/rand.h since we're replacing it +#include "sha1/sha1.h" #include #include diff --git a/src/libumskt/pidgen3/BINK1998.cpp b/src/libumskt/pidgen3/BINK1998.cpp index 81c1736..5797c2e 100644 --- a/src/libumskt/pidgen3/BINK1998.cpp +++ b/src/libumskt/pidgen3/BINK1998.cpp @@ -154,7 +154,7 @@ bool PIDGEN3::BINK1998::Verify( memcpy((void *)&msgBuffer[4 + FIELD_BYTES], (void *)yBin, FIELD_BYTES); // compHash = SHA1(pSerial || P.x || P.y) - SHA1(msgBuffer, SHA_MSG_LENGTH_XP, msgDigest); + SHA1_DIGEST(msgBuffer, SHA_MSG_LENGTH_XP, msgDigest); // Translate the byte digest into a 32-bit integer - this is our computed hash. // Truncate the hash to 28 bits. @@ -226,7 +226,7 @@ void PIDGEN3::BINK1998::Generate( memcpy((void *)&msgBuffer[4 + FIELD_BYTES], (void *)yBin, FIELD_BYTES); // pHash = SHA1(pSerial || R.x || R.y) - SHA1(msgBuffer, SHA_MSG_LENGTH_XP, msgDigest); + SHA1_DIGEST(msgBuffer, SHA_MSG_LENGTH_XP, msgDigest); // Translate the byte digest into a 32-bit integer - this is our computed pHash. // Truncate the pHash to 28 bits. diff --git a/src/libumskt/pidgen3/BINK2002.cpp b/src/libumskt/pidgen3/BINK2002.cpp index 73b6e07..8355dc6 100644 --- a/src/libumskt/pidgen3/BINK2002.cpp +++ b/src/libumskt/pidgen3/BINK2002.cpp @@ -127,7 +127,7 @@ bool PIDGEN3::BINK2002::Verify( msgBuffer[0x0A] = 0x00; // newSignature = SHA1(5D || Channel ID || Hash || AuthInfo || 00 00) - SHA1(msgBuffer, 11, msgDigest); + SHA1_DIGEST(msgBuffer, 11, msgDigest); // Translate the byte digest into a 64-bit integer - this is our computed intermediate signature. // As the signature is only 62 bits long at most, we have to truncate it by shifting the high DWORD right 2 bits (per spec). @@ -185,7 +185,7 @@ bool PIDGEN3::BINK2002::Verify( memcpy((void *)&msgBuffer[3 + FIELD_BYTES_2003], (void *)yBin, FIELD_BYTES_2003); // compHash = SHA1(79 || Channel ID || p.x || p.y) - SHA1(msgBuffer, SHA_MSG_LENGTH_2003, msgDigest); + SHA1_DIGEST(msgBuffer, SHA_MSG_LENGTH_2003, msgDigest); // Translate the byte digest into a 32-bit integer - this is our computed hash. // Truncate the hash to 31 bits. @@ -263,7 +263,7 @@ void PIDGEN3::BINK2002::Generate( memcpy((void *)&msgBuffer[3 + FIELD_BYTES_2003], (void *)yBin, FIELD_BYTES_2003); // pHash = SHA1(79 || Channel ID || R.x || R.y) - SHA1(msgBuffer, SHA_MSG_LENGTH_2003, msgDigest); + SHA1_DIGEST(msgBuffer, SHA_MSG_LENGTH_2003, msgDigest); // Translate the byte digest into a 32-bit integer - this is our computed hash. // Truncate the hash to 31 bits. @@ -283,7 +283,7 @@ void PIDGEN3::BINK2002::Generate( msgBuffer[0x0A] = 0x00; // newSignature = SHA1(5D || Channel ID || Hash || AuthInfo || 00 00) - SHA1(msgBuffer, 11, msgDigest); + SHA1_DIGEST(msgBuffer, 11, msgDigest); // Translate the byte digest into a 64-bit integer - this is our computed intermediate signature. // As the signature is only 62 bits long at most, we have to truncate it by shifting the high DWORD right 2 bits (per spec).