在使用Botan加密和botansqlite3时,性能的最佳配置设置是什么?
或
如何配置Botansqlite3以使用CAST5?
我目前正在使用AES,它太慢了。我的用例是个游戏。
我正在寻找弱的或温和的加密来保护我的游戏的数据(而不是最终用户数据),所以安全性比性能更少考虑。
这是我现在的BotanSqlite3代码
/*These constants can be used to tweak the codec behavior as follows */
//BLOCK_CIPHER_STR: Cipher and mode used for encrypting the database
//make sure to add "/NoPadding" for modes that use padding schemes
const string BLOCK_CIPHER_STR = "Twofish/XTS";
//PBKDF_STR: Key derivation function used to derive both the encryption
//and IV derivation keys from the given database passphrase
const string PBKDF_STR = "PBKDF2(SHA-160)";
//SALT_STR: Hard coded salt used to derive the key from the passphrase.
const string SALT_STR = "&g#nB'9]";
//SALT_SIZE: Size of the salt in bytes (as given in SALT_STR)
const int SALT_SIZE = 64/8; //64 bit, 8 byte salt
//MAC_STR: CMAC used to derive the IV that is used for db page
//encryption
const string MAC_STR = "CMAC(Twofish)";
//PBKDF_ITERATIONS: Number of hash iterations used in the key derivation
//process.
const int PBKDF_ITERATIONS = 10000;
//KEY_SIZE: Size of the encryption key. Note that XTS splits the key
//between two ciphers, so if you're using XTS, double the intended key
//size. (ie, "AES-128/XTS" should have a 256 bit KEY_SIZE)
const int KEY_SIZE = 512/8; //512 bit, 64 byte key. (256 bit XTS key)
//IV_DERIVATION_KEY_SIZE: Size of the key used with the CMAC (MAC_STR)
//above.
const int IV_DERIVATION_KEY_SIZE = 256/8; //256 bit, 32 byte key
//This is definited in sqlite.h and very unlikely to change
#define SQLITE_MAX_PAGE_SIZE 32768
我认为我需要找到BLOCK_CIPHER_STR、PBKDF_STR、MAC_STR、KEY_SIZE和IV_DERIVATION_KEY_SIZE的替代品,以重新配置BotanSqlite3以使用不同的编解码器。
我在这里发现了对Botan编解码器性能的广泛比较测试:http://panthema.net/2008/0714-cryptography-speedtest-comparison/crypto-speedtest-0.1/results/cpu-sidebyside-comparison-3x2.pdf#page=5
但是,测试是直接用Botan完成的,而不是我打算使用的botansqlite3。从性能的角度来看,从性能角度看,CAST5似乎是一个很好的候选者。
参考文献:
http://github.com/OlivierJG/botansqlite3 - botansqlite3是一种用于SQLite3的加密编解码器,可以使用Botan中的任何算法进行加密。
http://www.sqlite.org - sqlite3是一个跨平台的SQL数据库。
http://botan.randombit.net/ - botan是一个支持多个编解码器的C++加密库。
发布于 2013-11-02 19:52:28
你可以让CAST-128 (或者像我所说的那样,CAST5)工作,它是一个分组密码。
最好的选择是以上不同配置的密钥大小。
两个人走得很快。
感谢'Olivier JG‘的所有优秀代码。
https://stackoverflow.com/questions/19388930
复制相似问题