summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--context.h39
-rw-r--r--include/pso/PSOV3EncryptionTCP.h24
-rw-r--r--obj_files.mk1
-rw-r--r--src/pso/PSOV3EncryptionTCP.cpp29
4 files changed, 81 insertions, 12 deletions
diff --git a/context.h b/context.h
index 2fcdc7f..52f9bb8 100644
--- a/context.h
+++ b/context.h
@@ -541,8 +541,34 @@ static inline void operator^=(object_flags &a, object_flags b) { a = a ^ b; };
static inline void operator&=(object_flags &a, object_flags b) { a = a & b; };
static inline void operator|=(object_flags &a, object_flags b) { a = a | b; };
-// pso/TSocket.h
+// pso/TPlyGuildCardTag.h
// Class defs.
+
+class TPlyGuildCardTag {
+ public:
+ u8 tag0;
+ u8 tag1;
+ u16 tag2;
+ u32 guildcard_number;
+ TPlyGuildCardTag &operator=(const TPlyGuildCardTag &src);
+ void bswap();
+} __packed__;
+
+// pso/PSOV3EncryptionTCP.h
+class PSOV3EncryptionTCP : public PSOV3Encryption {
+public:
+ PSOV3EncryptionTCP();
+ ~PSOV3EncryptionTCP();
+
+ void reset(u32 seed);
+ void encrypt(void *void_data, int size);
+
+ PRIVATE_MEMBER_ACCESSORS(u32, seed);
+private:
+ u32 m_seed;
+};
+
+// pso/TSocket.h
class TSocket : public TObject {
private:
void set_flags(u8 flags) {
@@ -613,17 +639,6 @@ public:
PRIVATE_MEMBER_ACCESSORS_FUNC(void, callback, TSocket *socket);
};
-// pso/TPlyGuildCardTag.h
-class TPlyGuildCardTag {
- public:
- u8 tag0;
- u8 tag1;
- u16 tag2;
- u32 guildcard_number;
- TPlyGuildCardTag &operator=(const TPlyGuildCardTag &src);
- void bswap();
-} __packed__;
-
// pso/THeap.h
class THeap {
public:
diff --git a/include/pso/PSOV3EncryptionTCP.h b/include/pso/PSOV3EncryptionTCP.h
new file mode 100644
index 0000000..da3208d
--- /dev/null
+++ b/include/pso/PSOV3EncryptionTCP.h
@@ -0,0 +1,24 @@
+#ifndef PSOV3ENCRYPTIONTCP_H
+#define PSOV3ENCRYPTIONTCP_H
+
+#include <global_types.h>
+#include <string.h>
+#include <pso/macros.h>
+#include <pso/protocol.h>
+#include <pso/PSOV3Encryption.h>
+#include <pso/TArray.h>
+
+class PSOV3EncryptionTCP : public PSOV3Encryption {
+public:
+ PSOV3EncryptionTCP();
+ ~PSOV3EncryptionTCP();
+
+ void reset(u32 seed);
+ void encrypt(void *void_data, int size);
+
+ PRIVATE_MEMBER_ACCESSORS(u32, seed);
+private:
+ u32 m_seed;
+};
+
+#endif
diff --git a/obj_files.mk b/obj_files.mk
index 522cf50..1f9de57 100644
--- a/obj_files.mk
+++ b/obj_files.mk
@@ -1,6 +1,7 @@
O_FILES := $(BUILD_DIR)/src/main.o \
$(BUILD_DIR)/src/pso/TPlyGuildCardTag.o \
$(BUILD_DIR)/src/pso/TSocket.o \
+ $(BUILD_DIR)/src/pso/PSOV3EncryptionTCP.o \
$(BUILD_DIR)/src/pso/THeap.o \
$(BUILD_DIR)/src/pso/protocol.o \
$(BUILD_DIR)/src/pso/TMainTask.o \
diff --git a/src/pso/PSOV3EncryptionTCP.cpp b/src/pso/PSOV3EncryptionTCP.cpp
new file mode 100644
index 0000000..737c510
--- /dev/null
+++ b/src/pso/PSOV3EncryptionTCP.cpp
@@ -0,0 +1,29 @@
+#include <global_types.h>
+#include <string.h>
+#include "pso/macros.h"
+#include "pso/PSOV3EncryptionTCP.h"
+#include "pso/TArray.h"
+
+void PSOV3EncryptionTCP::encrypt(void *void_data, int size) {
+ u32 *data = reinterpret_cast<u32 *>(void_data);
+ size = (size + 3) / 4;
+ for (int i = 0; i < size; ++i) {
+ bswap_32(&data[i]);
+ data[i] ^= next();
+ bswap_32(&data[i]);
+ }
+}
+
+void PSOV3EncryptionTCP::reset(u32 seed) {
+ m_seed = seed;
+ init(seed);
+}
+
+PSOV3EncryptionTCP::~PSOV3EncryptionTCP() {
+
+}
+
+PSOV3EncryptionTCP::PSOV3EncryptionTCP() : PSOV3Encryption() {
+ reset(0);
+}
+