remove fantacrypt
This commit is contained in:
parent
2c6a690d47
commit
c0316ded85
@ -63,9 +63,6 @@ public:
|
|||||||
|
|
||||||
/////////////////server metadata//////////////////
|
/////////////////server metadata//////////////////
|
||||||
|
|
||||||
unsigned int s_decryptor = 5;
|
|
||||||
bool encryption_needed = true;
|
|
||||||
|
|
||||||
bool yellow_text_enabled = false;
|
bool yellow_text_enabled = false;
|
||||||
bool prezoom_enabled = false;
|
bool prezoom_enabled = false;
|
||||||
bool flipping_enabled = false;
|
bool flipping_enabled = false;
|
||||||
|
@ -15,14 +15,10 @@ public:
|
|||||||
QStringList &get_contents() { return m_contents; }
|
QStringList &get_contents() { return m_contents; }
|
||||||
QString to_string();
|
QString to_string();
|
||||||
|
|
||||||
void encrypt_header(unsigned int p_key);
|
|
||||||
void decrypt_header(unsigned int p_key);
|
|
||||||
|
|
||||||
void net_encode();
|
void net_encode();
|
||||||
void net_decode();
|
void net_decode();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool encrypted = false;
|
|
||||||
|
|
||||||
QString m_header;
|
QString m_header;
|
||||||
QStringList m_contents;
|
QStringList m_contents;
|
||||||
|
@ -31,26 +31,10 @@ QString AOPacket::to_string()
|
|||||||
|
|
||||||
f_string += "#%";
|
f_string += "#%";
|
||||||
|
|
||||||
if (encrypted)
|
|
||||||
return "#" + f_string;
|
|
||||||
else
|
|
||||||
return f_string;
|
return f_string;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AOPacket::encrypt_header(unsigned int p_key)
|
|
||||||
{
|
|
||||||
m_header = fanta_encrypt(m_header, p_key);
|
|
||||||
|
|
||||||
encrypted = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AOPacket::decrypt_header(unsigned int p_key)
|
|
||||||
{
|
|
||||||
m_header = fanta_decrypt(m_header, p_key);
|
|
||||||
|
|
||||||
encrypted = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AOPacket::net_encode()
|
void AOPacket::net_encode()
|
||||||
{
|
{
|
||||||
for (int n_element = 0; n_element < m_contents.size(); ++n_element) {
|
for (int n_element = 0; n_element < m_contents.size(); ++n_element) {
|
||||||
|
@ -1,58 +0,0 @@
|
|||||||
#include "encryption_functions.h"
|
|
||||||
|
|
||||||
#include "hex_functions.h"
|
|
||||||
|
|
||||||
QString fanta_encrypt(QString temp_input, unsigned int p_key)
|
|
||||||
{
|
|
||||||
// using standard stdlib types is actually easier here because of implicit
|
|
||||||
// char<->int conversion which in turn makes encryption arithmetic easier
|
|
||||||
|
|
||||||
unsigned int key = p_key;
|
|
||||||
unsigned int C1 = 53761;
|
|
||||||
unsigned int C2 = 32618;
|
|
||||||
|
|
||||||
QVector<uint_fast8_t> temp_result;
|
|
||||||
std::string input = temp_input.toUtf8().constData();
|
|
||||||
|
|
||||||
for (unsigned int pos = 0; pos < input.size(); ++pos) {
|
|
||||||
uint_fast8_t output = input.at(pos) ^ (key >> 8) % 256;
|
|
||||||
temp_result.append(output);
|
|
||||||
key = (temp_result.at(pos) + key) * C1 + C2;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string result = "";
|
|
||||||
|
|
||||||
for (uint_fast8_t i_int : temp_result) {
|
|
||||||
result += omni::int_to_hex(i_int);
|
|
||||||
}
|
|
||||||
|
|
||||||
QString final_result = QString::fromStdString(result);
|
|
||||||
|
|
||||||
return final_result;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString fanta_decrypt(QString temp_input, unsigned int key)
|
|
||||||
{
|
|
||||||
std::string input = temp_input.toUtf8().constData();
|
|
||||||
|
|
||||||
QVector<unsigned int> unhexed_vector;
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < input.length(); i += 2) {
|
|
||||||
std::string byte = input.substr(i, 2);
|
|
||||||
unsigned int hex_int = strtoul(byte.c_str(), nullptr, 16);
|
|
||||||
unhexed_vector.append(hex_int);
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int C1 = 53761;
|
|
||||||
unsigned int C2 = 32618;
|
|
||||||
|
|
||||||
std::string result = "";
|
|
||||||
|
|
||||||
for (int pos = 0; pos < unhexed_vector.size(); ++pos) {
|
|
||||||
unsigned char output = unhexed_vector.at(pos) ^ (key >> 8) % 256;
|
|
||||||
result += output;
|
|
||||||
key = (unhexed_vector.at(pos) + key) * C1 + C2;
|
|
||||||
}
|
|
||||||
|
|
||||||
return QString::fromStdString(result);
|
|
||||||
}
|
|
@ -1,17 +0,0 @@
|
|||||||
#include "hex_functions.h"
|
|
||||||
|
|
||||||
namespace omni {
|
|
||||||
std::string int_to_hex(unsigned int input)
|
|
||||||
{
|
|
||||||
if (input > 255)
|
|
||||||
return "FF";
|
|
||||||
|
|
||||||
std::stringstream stream;
|
|
||||||
stream << std::setfill('0') << std::setw(sizeof(char) * 2) << std::hex
|
|
||||||
<< input;
|
|
||||||
std::string result(stream.str());
|
|
||||||
std::transform(result.begin(), result.end(), result.begin(), ::toupper);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
} // namespace omni
|
|
@ -120,11 +120,7 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
|
|||||||
if (f_contents.size() == 0)
|
if (f_contents.size() == 0)
|
||||||
goto end;
|
goto end;
|
||||||
|
|
||||||
// you may ask where 322 comes from. that would be a good question.
|
|
||||||
s_decryptor = fanta_decrypt(f_contents.at(0), 322).toUInt();
|
|
||||||
|
|
||||||
// default(legacy) values
|
// default(legacy) values
|
||||||
encryption_needed = true;
|
|
||||||
yellow_text_enabled = false;
|
yellow_text_enabled = false;
|
||||||
prezoom_enabled = false;
|
prezoom_enabled = false;
|
||||||
flipping_enabled = false;
|
flipping_enabled = false;
|
||||||
@ -140,10 +136,6 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
|
|||||||
additive_enabled = false;
|
additive_enabled = false;
|
||||||
effects_enabled = false;
|
effects_enabled = false;
|
||||||
|
|
||||||
// workaround for tsuserver4
|
|
||||||
if (f_contents.at(0) == "NOENCRYPT")
|
|
||||||
encryption_needed = false;
|
|
||||||
|
|
||||||
QString f_hdid;
|
QString f_hdid;
|
||||||
f_hdid = get_hdid();
|
f_hdid = get_hdid();
|
||||||
|
|
||||||
@ -201,8 +193,6 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
|
|||||||
custom_objection_enabled = true;
|
custom_objection_enabled = true;
|
||||||
if (f_packet.contains("fastloading", Qt::CaseInsensitive))
|
if (f_packet.contains("fastloading", Qt::CaseInsensitive))
|
||||||
improved_loading_enabled = true;
|
improved_loading_enabled = true;
|
||||||
if (f_packet.contains("noencryption", Qt::CaseInsensitive))
|
|
||||||
encryption_needed = false;
|
|
||||||
if (f_packet.contains("deskmod", Qt::CaseInsensitive))
|
if (f_packet.contains("deskmod", Qt::CaseInsensitive))
|
||||||
desk_mod_enabled = true;
|
desk_mod_enabled = true;
|
||||||
if (f_packet.contains("evidence", Qt::CaseInsensitive))
|
if (f_packet.contains("evidence", Qt::CaseInsensitive))
|
||||||
@ -750,19 +740,9 @@ void AOApplication::send_server_packet(AOPacket *p_packet, bool encoded)
|
|||||||
|
|
||||||
QString f_packet = p_packet->to_string();
|
QString f_packet = p_packet->to_string();
|
||||||
|
|
||||||
if (encryption_needed) {
|
|
||||||
#ifdef DEBUG_NETWORK
|
|
||||||
qDebug() << "S(e):" << f_packet;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
p_packet->encrypt_header(s_decryptor);
|
|
||||||
f_packet = p_packet->to_string();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
#ifdef DEBUG_NETWORK
|
#ifdef DEBUG_NETWORK
|
||||||
qDebug() << "S:" << f_packet;
|
qDebug() << "S:" << f_packet;
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
|
|
||||||
net_manager->ship_server_packet(f_packet);
|
net_manager->ship_server_packet(f_packet);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user