From e65dc561acab7a9e49f59777f16cb040c574c64d Mon Sep 17 00:00:00 2001 From: fusion32 Date: Thu, 3 Jul 2025 10:10:27 -0300 Subject: implement `crypto.cc` with OpenSSL + fix config loading I considered reversing the original `vlong` implementation but OpenSSL is just simpler, more secure, and most importantly, is already there. I also made it so the key is now stored in a PEM file (`tibia.pem`) so it can be easily swapped without re-compiling. This was the last piece to build and run a working executable, except that we now need to implement a query manager for the server to communicate with. I was able to fix a small problem with loading the config before hitting the problem with the query manager, which was expected. The next task should be getting a query manager up and running before starting phase two of upgrading and fixing the server itself. --- src/communication.cc | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'src/communication.cc') diff --git a/src/communication.cc b/src/communication.cc index 9f0e6e5..a15e20a 100644 --- a/src/communication.cc +++ b/src/communication.cc @@ -23,16 +23,6 @@ #define MAX_COMMUNICATION_THREADS 1100 #define COMMUNICATION_THREAD_STACK_SIZE ((int)KB(64)) -static const char RSA_PRIME_P[] = - "1201758001370723323398753778257470257713354828752713123415294815" - "0506251412291888866940292054989907714155267326586216043845592229" - "084368540020196135619327879"; - -static const char RSA_PRIME_Q[] = - "1189892136861686835188050824611210139447876026576932541274639840" - "5473436969889506919017477758618276066588858607419440134394668095" - "105156501566867770737187273"; - static int TERMINALVERSION[3] = {770, 770, 770}; static int TCPSocket; static ThreadHandle AcceptorThread; @@ -1533,7 +1523,9 @@ void InitCommunication(void){ AcceptorThreadPID = 0; ActiveConnections = 0; QueryManagerConnectionPool.init(); - PrivateKey.init(RSA_PRIME_P, RSA_PRIME_Q); + + // TODO(fusion): This is arbitrary, should probably be set in the config. + PrivateKey.initFromFile("tibia.pem"); OpenSocket(); if(TCPSocket == -1){ -- cgit v1.2.3