summaryrefslogtreecommitdiffstats
path: root/Tools/ProtoProxy/Connection.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Tools/ProtoProxy/Connection.cpp')
-rw-r--r--Tools/ProtoProxy/Connection.cpp42
1 files changed, 39 insertions, 3 deletions
diff --git a/Tools/ProtoProxy/Connection.cpp b/Tools/ProtoProxy/Connection.cpp
index d9b8e3dd1..c5916c1ca 100644
--- a/Tools/ProtoProxy/Connection.cpp
+++ b/Tools/ProtoProxy/Connection.cpp
@@ -7,6 +7,7 @@
#include "Connection.h"
#include "Server.h"
#include <iostream>
+#include "PolarSSL++/CryptoKey.h"
#ifdef _WIN32
#include <direct.h> // For _mkdir()
@@ -471,7 +472,7 @@ bool cConnection::SendData(SOCKET a_Socket, cByteBuffer & a_Data, const char * a
-bool cConnection::SendEncryptedData(SOCKET a_Socket, cAESCFBEncryptor & a_Encryptor, const char * a_Data, size_t a_Size, const char * a_Peer)
+bool cConnection::SendEncryptedData(SOCKET a_Socket, cAesCfb128Encryptor & a_Encryptor, const char * a_Data, size_t a_Size, const char * a_Peer)
{
DataLog(a_Data, a_Size, "Encrypting %d bytes to %s", a_Size, a_Peer);
const Byte * Data = (const Byte *)a_Data;
@@ -495,7 +496,7 @@ bool cConnection::SendEncryptedData(SOCKET a_Socket, cAESCFBEncryptor & a_Encryp
-bool cConnection::SendEncryptedData(SOCKET a_Socket, cAESCFBEncryptor & a_Encryptor, cByteBuffer & a_Data, const char * a_Peer)
+bool cConnection::SendEncryptedData(SOCKET a_Socket, cAesCfb128Encryptor & a_Encryptor, cByteBuffer & a_Data, const char * a_Peer)
{
AString All;
a_Data.ReadAll(All);
@@ -2197,11 +2198,39 @@ bool cConnection::HandleServerSpawnMob(void)
+struct sSpawnData
+{
+ AString m_Name;
+ AString m_Value;
+ AString m_Signature;
+ sSpawnData(const AString & a_Name, const AString & a_Value, const AString & a_Signature) :
+ m_Name(a_Name),
+ m_Value(a_Value),
+ m_Signature(a_Signature)
+ {
+ }
+};
+
+typedef std::vector<sSpawnData> sSpawnDatas;
+
+
+
+
+
bool cConnection::HandleServerSpawnNamedEntity(void)
{
HANDLE_SERVER_PACKET_READ(ReadVarInt, UInt32, EntityID);
HANDLE_SERVER_PACKET_READ(ReadVarUTF8String, AString, EntityUUID);
HANDLE_SERVER_PACKET_READ(ReadVarUTF8String, AString, EntityName);
+ HANDLE_SERVER_PACKET_READ(ReadVarInt, UInt32, DataCount);
+ sSpawnDatas Data;
+ for (UInt32 i = 0; i < DataCount; i++)
+ {
+ HANDLE_SERVER_PACKET_READ(ReadVarUTF8String, AString, Name)
+ HANDLE_SERVER_PACKET_READ(ReadVarUTF8String, AString, Value)
+ HANDLE_SERVER_PACKET_READ(ReadVarUTF8String, AString, Signature)
+ Data.push_back(sSpawnData(Name, Value, Signature));
+ }
HANDLE_SERVER_PACKET_READ(ReadBEInt, int, PosX);
HANDLE_SERVER_PACKET_READ(ReadBEInt, int, PosY);
HANDLE_SERVER_PACKET_READ(ReadBEInt, int, PosZ);
@@ -2219,6 +2248,13 @@ bool cConnection::HandleServerSpawnNamedEntity(void)
Log(" EntityID = %u (0x%x)", EntityID, EntityID);
Log(" UUID = \"%s\"", EntityUUID.c_str());
Log(" Name = \"%s\"", EntityName.c_str());
+ Log(" NumData = %u", DataCount);
+ for (sSpawnDatas::const_iterator itr = Data.begin(), end = Data.end(); itr != end; ++itr)
+ {
+ Log(" Name = \"%s\", Value = \"%s\", Signature = \"%s\"",
+ itr->m_Name.c_str(), itr->m_Value.c_str(), itr->m_Signature.c_str()
+ );
+ } // for itr - Data[]
Log(" Pos = %s", PrintableAbsIntTriplet(PosX, PosY, PosZ).c_str());
Log(" Rotation = <yaw %d, pitch %d>", Yaw, Pitch);
Log(" CurrentItem = %d", CurrentItem);
@@ -2864,7 +2900,7 @@ void cConnection::SendEncryptionKeyResponse(const AString & a_ServerPublicKey, c
Byte SharedSecret[16];
Byte EncryptedSecret[128];
memset(SharedSecret, 0, sizeof(SharedSecret)); // Use all zeroes for the initial secret
- cPublicKey PubKey(a_ServerPublicKey);
+ cCryptoKey PubKey(a_ServerPublicKey);
int res = PubKey.Encrypt(SharedSecret, sizeof(SharedSecret), EncryptedSecret, sizeof(EncryptedSecret));
if (res < 0)
{