From 3b345cf86819d5e65c68c28b7120c0978f490348 Mon Sep 17 00:00:00 2001 From: Henrique Date: Wed, 1 Aug 2012 21:24:54 -0300 Subject: [PATCH] Add setXteaKey function --- src/framework/luafunctions.cpp | 1 + src/framework/net/protocol.cpp | 8 ++++++++ src/framework/net/protocol.h | 1 + 3 files changed, 10 insertions(+) diff --git a/src/framework/luafunctions.cpp b/src/framework/luafunctions.cpp index e664d8ad..915f2ba4 100644 --- a/src/framework/luafunctions.cpp +++ b/src/framework/luafunctions.cpp @@ -645,6 +645,7 @@ void Application::registerLuaFunctions() g_lua.bindClassMemberFunction("setConnection", &Protocol::setConnection); g_lua.bindClassMemberFunction("send", &Protocol::send); g_lua.bindClassMemberFunction("recv", &Protocol::recv); + g_lua.bindClassMemberFunction("setXteaKey", &Protocol::setXteaKey); g_lua.bindClassMemberFunction("getXteaKey", &Protocol::getXteaKey); g_lua.bindClassMemberFunction("generateXteaKey", &Protocol::generateXteaKey); g_lua.bindClassMemberFunction("enableXteaEncryption", &Protocol::enableXteaEncryption); diff --git a/src/framework/net/protocol.cpp b/src/framework/net/protocol.cpp index 321fe8ad..66bb50a5 100644 --- a/src/framework/net/protocol.cpp +++ b/src/framework/net/protocol.cpp @@ -151,6 +151,14 @@ void Protocol::generateXteaKey() m_xteaKey[3] = unif(eng); } +void Protocol::setXteaKey(uint32 a, uint32 b, uint32 c, uint32 d) +{ + m_xteaKey[0] = a; + m_xteaKey[1] = b; + m_xteaKey[2] = c; + m_xteaKey[3] = d; +} + std::vector Protocol::getXteaKey() { std::vector xteaKey; diff --git a/src/framework/net/protocol.h b/src/framework/net/protocol.h index 468f8cef..139cefed 100644 --- a/src/framework/net/protocol.h +++ b/src/framework/net/protocol.h @@ -46,6 +46,7 @@ public: void setConnection(const ConnectionPtr& connection) { m_connection = connection; } void generateXteaKey(); + void setXteaKey(uint32 a, uint32 b, uint32 c, uint32 d); std::vector getXteaKey(); void enableXteaEncryption() { m_xteaEncryptionEnabled = true; }