From bd3a6a04601749cbde007eaabf803fb602ee2783 Mon Sep 17 00:00:00 2001 From: fusion32 Date: Thu, 19 Jun 2025 03:13:48 -0300 Subject: beginning of `communication.cc` --- src/crypto.hh | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 src/crypto.hh (limited to 'src/crypto.hh') diff --git a/src/crypto.hh b/src/crypto.hh new file mode 100644 index 0000000..e90996c --- /dev/null +++ b/src/crypto.hh @@ -0,0 +1,58 @@ +#ifndef TIBIA_CRYPTO_HH_ +#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; +}; + +struct TRSAPrivateKey{ + TRSAPrivateKey(void); + ~TRSAPrivateKey(void); + void decrypt(uint8 *Data); // single 128 bytes block + + // DATA + // ================= + vlong m_PrimeP; + vlong m_PrimeQ; + vlong m_U; + vlong m_DP; + vlong m_DQ; +}; + +struct TXTEASymmetricKey{ + TXTEASymmetricKey(void); + ~TXTEASymmetricKey(void); + void encrypt(uint8 *Data); // single 8 bytes block + void decrypt(uint8 *Data); // single 8 bytes block + + // DATA + // ================= + uint32 m_SymmetricKey[4]; +}; + +#endif //TIBIA_CRYPTO_HH_ -- cgit v1.2.3