Reference: https://github.com/polserver/polserver/blob/5c747bb88123945bb892d3d793b89afcb1dc645a/pol-core/pol/crypt/cryptkey.cpp
| 240 | |
| 241 | // Reference: https://github.com/polserver/polserver/blob/5c747bb88123945bb892d3d793b89afcb1dc645a/pol-core/pol/crypt/cryptkey.cpp |
| 242 | static void SetClientCrypt(uint32_t version) |
| 243 | { |
| 244 | if (version == CV_200X) |
| 245 | { |
| 246 | if (!g_Config.ClientKeysSet) |
| 247 | { |
| 248 | g_Config.Key1 = 0x2D13A5FC; |
| 249 | g_Config.Key2 = 0x2D13A5FD; |
| 250 | g_Config.Key3 = 0xA39D527F; |
| 251 | } |
| 252 | g_Config.EncryptionType = ET_203; |
| 253 | return; |
| 254 | } |
| 255 | |
| 256 | if (!g_Config.ClientKeysSet) |
| 257 | { |
| 258 | int a = (version >> 24) & 0xff; |
| 259 | int b = (version >> 16) & 0xff; |
| 260 | int c = (version >> 8) & 0xff; |
| 261 | |
| 262 | int temp = ((a << 9 | b) << 10 | c) ^ ((c * c) << 5); |
| 263 | g_Config.Key2 = (temp << 4) ^ (b * b) ^ (b * 0x0B000000) ^ (c * 0x380000) ^ 0x2C13A5FD; |
| 264 | temp = (((a << 9 | c) << 10 | b) * 8) ^ (c * c * 0x0c00); |
| 265 | g_Config.Key3 = temp ^ (b * b) ^ (b * 0x6800000) ^ (c * 0x1c0000) ^ 0x0A31D527F; |
| 266 | |
| 267 | // Configurator does this, not sure why |
| 268 | // lets keep compatibility until we understand more |
| 269 | g_Config.Key1 = g_Config.Key2 - 1; |
| 270 | } |
| 271 | |
| 272 | if (version < VERSION(1, 25, 35, 0)) |
| 273 | { |
| 274 | g_Config.EncryptionType = ET_OLD_BFISH; |
| 275 | } |
| 276 | else if (version == VERSION(1, 25, 36, 0)) |
| 277 | { |
| 278 | g_Config.EncryptionType = ET_1_25_36; |
| 279 | } |
| 280 | else if (version < CV_200) |
| 281 | { |
| 282 | g_Config.EncryptionType = ET_BFISH; |
| 283 | } |
| 284 | else if (version <= VERSION(2, 0, 3, 0)) |
| 285 | { |
| 286 | g_Config.EncryptionType = ET_203; |
| 287 | } |
| 288 | else |
| 289 | { |
| 290 | g_Config.EncryptionType = ET_TFISH; |
| 291 | } |
| 292 | } |
| 293 | |
| 294 | static void ClientVersionFixup(bool overrideProtocolVersion) |
| 295 | { |
no outgoing calls
no test coverage detected