134 lines
4.1 KiB
Plaintext
134 lines
4.1 KiB
Plaintext
1. Encryption
|
|
|
|
The Lua files can be encrypted using the 256 bit variant of the AES encryption algorithm.
|
|
|
|
The AES key is file name dependent, and is built using eight keys and eight prime numbers
|
|
defined in "adel/src/encryption_data.h".
|
|
|
|
#define ENCRYPTION_KEY_0 0x01234567
|
|
#define ENCRYPTION_KEY_1 0x01234567
|
|
#define ENCRYPTION_KEY_2 0x01234567
|
|
#define ENCRYPTION_KEY_3 0x01234567
|
|
#define ENCRYPTION_KEY_4 0x01234567
|
|
#define ENCRYPTION_KEY_5 0x01234567
|
|
#define ENCRYPTION_KEY_6 0x01234567
|
|
#define ENCRYPTION_KEY_7 0x01234567
|
|
#define ENCRYPTION_PRIME_0 0x01234567
|
|
#define ENCRYPTION_PRIME_1 0x01234567
|
|
#define ENCRYPTION_PRIME_2 0x01234567
|
|
#define ENCRYPTION_PRIME_3 0x01234567
|
|
#define ENCRYPTION_PRIME_4 0x01234567
|
|
#define ENCRYPTION_PRIME_5 0x01234567
|
|
#define ENCRYPTION_PRIME_6 0x01234567
|
|
#define ENCRYPTION_PRIME_7 0x01234567
|
|
|
|
Of course, the above values must be changed, if needed on a customer basis, and the version
|
|
of "encryption_data.h" which contains the actual keys and prime numbers used for encryption
|
|
must absolutely be kept secret, and thus should NEVER be put on a Github repository.
|
|
|
|
Be aware that when any key or prime number is changed in "encryption_data.h" :
|
|
- the encryption tool, the game client and the game server must be rebuilt so that they all
|
|
use the same keys.
|
|
- the decrypted Lua files must be encrypted with the new encryption tool.
|
|
- the server, the game and the encrypted Lua files must be deployed again.
|
|
|
|
Big 32-bit prime numbers can be generated here :
|
|
|
|
https://asecuritysite.com/encryption/random3?val=32
|
|
|
|
There is also a list with all the 32-bit prime numbers here :
|
|
|
|
http://www.fukudat.com/prime/prime.dat.gz
|
|
|
|
Sample data :
|
|
|
|
#define ENCRYPTION_KEY_0 0x9534A53F
|
|
#define ENCRYPTION_KEY_1 0xE53823C4
|
|
#define ENCRYPTION_KEY_2 0x31986584
|
|
#define ENCRYPTION_KEY_3 0x3919F129
|
|
#define ENCRYPTION_KEY_4 0x81683587
|
|
#define ENCRYPTION_KEY_5 0x16E81A34
|
|
#define ENCRYPTION_KEY_6 0xC9835185
|
|
#define ENCRYPTION_KEY_7 0x246D32F5
|
|
#define ENCRYPTION_PRIME_0 1977777259u
|
|
#define ENCRYPTION_PRIME_1 3392428841u
|
|
#define ENCRYPTION_PRIME_2 293353289u
|
|
#define ENCRYPTION_PRIME_3 891334331u
|
|
#define ENCRYPTION_PRIME_4 1926494413u
|
|
#define ENCRYPTION_PRIME_5 1460369081u
|
|
#define ENCRYPTION_PRIME_6 3938039173u
|
|
#define ENCRYPTION_PRIME_7 1340222629u
|
|
|
|
|
|
2. Encryption tool
|
|
|
|
Lua files can be encrypted/decrypted using a dedicated tool in the "adel/util/crypt/" folder.
|
|
|
|
The "-e" option is used to encrypt the files, and the "-d" option to decrypt them.
|
|
|
|
Only files which aren't already encrypted/decrypted are processed.
|
|
|
|
Files can be encrypted/decrypted manually, by providing their paths as additional arguments :
|
|
|
|
crypt -e *.lua
|
|
crypt -d *.lua
|
|
|
|
The recommended way to use the tool is to create a "CryptList.txt" file in the current folder
|
|
and call the tool without arguments :
|
|
|
|
crypt -e
|
|
crypt -d
|
|
|
|
This file should contain the paths of all the Lua files to encrypt or decrypt.
|
|
|
|
The "CryptList.txt" file can be generated automatically using the following Linux command :
|
|
|
|
find . -name "*.lua" > CryptList.txt
|
|
|
|
This command will create a "CryptList.txt" file with the paths of the Lua files of this folder
|
|
and its subfolder.
|
|
|
|
|
|
3. Compilation
|
|
|
|
Encryption tool :
|
|
|
|
cd adel/util/crypt/
|
|
rm CMakeCache.txt
|
|
cmake .
|
|
make
|
|
|
|
Game and server :
|
|
|
|
cd adel/
|
|
rm CMakeCache.txt
|
|
cmake . -DBUILD_CLIENT=1 -DBUILD_SERVER=1 -DRUN_IN_PLACE=TRUE
|
|
make
|
|
|
|
or
|
|
|
|
cd adel/
|
|
rm CMakeCache.txt
|
|
cmake . -DBUILD_CLIENT=1 -DBUILD_SERVER=1 -DRUN_IN_PLACE=TRUE -DENABLE_CURL=1 -DENABLE_CURSES=1 -DENABLE_LUAJIT=1
|
|
make
|
|
|
|
|
|
4. Usage
|
|
|
|
At any time, the Lua files can be decrypted and encrypted in place in the development folder.
|
|
|
|
A safer approach is to copy the Lua files to deploy in a temporary folder and encrypt them there
|
|
before deployment.
|
|
|
|
|
|
5. Signature tool
|
|
|
|
The "md5.sh" shell script in the "adel/util/md5/" allows to update the production database,
|
|
by generating an SQL script file with the required commands.
|
|
|
|
It will scan all Lua files in the current folder and generate SQL commands like this one :
|
|
|
|
update maps
|
|
set mods_hash_md5 = "c50f510b0072cb9467e0d4c43f96fcae"
|
|
where url_download = "http://assets.kidscode.com/master/test/x.lua";
|