From 8ee359108336f96ae0bac5f0dde998db54cd821f Mon Sep 17 00:00:00 2001 From: RD42 <42702181+dashr9230@users.noreply.github.com> Date: Fri, 1 Dec 2023 20:53:12 +0800 Subject: [PATCH] [raknet] Implement TEABlockEncryptor ctor --- raknet/TEABlockEncryptor.cpp | 16 ++++++++++++++++ raknet/TEABlockEncryptor.h | 25 +++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 raknet/TEABlockEncryptor.cpp create mode 100644 raknet/TEABlockEncryptor.h diff --git a/raknet/TEABlockEncryptor.cpp b/raknet/TEABlockEncryptor.cpp new file mode 100644 index 0000000..bafe558 --- /dev/null +++ b/raknet/TEABlockEncryptor.cpp @@ -0,0 +1,16 @@ +// TODO: Implement TEABlockEncryptor.cpp + +#include "TEABlockEncryptor.h" + +#define TEA_ROUNDS 32 +#define TEA_XOR_MASK 0x5E94A3CF + +unsigned int TEABlockEncryptor::initObsDelta = (0x9E3779B9 ^ TEA_XOR_MASK); + +TEABlockEncryptor::TEABlockEncryptor() +{ + initDelta = initObsDelta ^ TEA_XOR_MASK; + initSum = initDelta * TEA_ROUNDS; + + keySet = false; +} diff --git a/raknet/TEABlockEncryptor.h b/raknet/TEABlockEncryptor.h new file mode 100644 index 0000000..75dc341 --- /dev/null +++ b/raknet/TEABlockEncryptor.h @@ -0,0 +1,25 @@ +// TODO: Implement TEABlockEncryptor.h + +#ifndef __TEA_BLOCK_ENCRYPTOR_H +#define __TEA_BLOCK_ENCRYPTOR_H + +#include "DataBlockEncryptor.h" + +class TEABlockEncryptor : + public DataBlockEncryptor +{ + +public: + + TEABlockEncryptor(); + +protected: + + unsigned int initSum; + unsigned int initDelta; + + static unsigned int initObsDelta; + +}; + +#endif