diff options
| author | fusion32 <marcopuzziello@gmail.com> | 2025-07-03 10:10:27 -0300 |
|---|---|---|
| committer | fusion32 <marcopuzziello@gmail.com> | 2025-07-03 10:46:43 -0300 |
| commit | e65dc561acab7a9e49f59777f16cb040c574c64d (patch) | |
| tree | 2206c066b97b1948a4b98647c91a369d3b9863c8 /src/crypto.hh | |
| parent | e782274ade8d7307e157a997d6ac3bcaa4130024 (diff) | |
| download | game-e65dc561acab7a9e49f59777f16cb040c574c64d.tar.gz game-e65dc561acab7a9e49f59777f16cb040c574c64d.zip | |
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.
Diffstat (limited to 'src/crypto.hh')
| -rw-r--r-- | src/crypto.hh | 38 |
1 files changed, 3 insertions, 35 deletions
diff --git a/src/crypto.hh b/src/crypto.hh index 7159a37..b649ad8 100644 --- a/src/crypto.hh +++ b/src/crypto.hh @@ -2,52 +2,20 @@ #define TIBIA_CRYPTO_HH_ 1 #include "common.hh" - -// TODO(fusion): We might want to scrap this implementation and use OpenSSL instead. - -struct vlong_flex_unit{ - uint32 n; - uint32 *a; - uint32 z; -}; - -struct vlong_value: vlong_flex_unit { - uint32 share; -}; - -struct vlong{ - vlong_value *value; - int negative; -}; - -struct vlong_montgomery{ - vlong R; - vlong R1; - vlong m; - vlong n1; - vlong T; - vlong k; - uint32 N; -}; +#include <openssl/rsa.h> struct TRSAPrivateKey{ TRSAPrivateKey(void); ~TRSAPrivateKey(void); - void init(const char *PrimeP, const char *PrimeQ); + void initFromFile(const char *FileName); void decrypt(uint8 *Data); // single 128 bytes block // DATA // ================= - vlong m_PrimeP; - vlong m_PrimeQ; - vlong m_U; - vlong m_DP; - vlong m_DQ; + RSA *m_RSA; }; struct TXTEASymmetricKey{ - TXTEASymmetricKey(void); - ~TXTEASymmetricKey(void); void init(TReadBuffer *Buffer); void encrypt(uint8 *Data); // single 8 bytes block void decrypt(uint8 *Data); // single 8 bytes block |
