首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >在Botan中,什么是最高性能的SQLite加密编解码器?

在Botan中,什么是最高性能的SQLite加密编解码器?
EN

Stack Overflow用户
提问于 2013-10-15 18:56:35
回答 1查看 852关注 0票数 2

在使用Botan加密和botansqlite3时,性能的最佳配置设置是什么?

如何配置Botansqlite3以使用CAST5?

我目前正在使用AES,它太慢了。我的用例是个游戏。

我正在寻找弱的或温和的加密来保护我的游戏的数据(而不是最终用户数据),所以安全性比性能更少考虑。

这是我现在的BotanSqlite3代码

代码语言:javascript
运行
复制
/*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似乎是一个很好的候选者。

  • 所讨论的数据库是300 in,主要是带有一些文本块的整数字段。
  • 我按照OlivierJG of botansqlite3名声的建议配置Botan,使用合并 ‘./figre.py-no-autoload-启用-模块=twofish,xts,pbkdf2,cmac,sha1 -gen合并-cc=msvc-os=win32 32-cpu=x86-disable-win32 asm’

参考文献:

http://github.com/OlivierJG/botansqlite3 - botansqlite3是一种用于SQLite3的加密编解码器,可以使用Botan中的任何算法进行加密。

http://www.sqlite.org - sqlite3是一个跨平台的SQL数据库。

http://botan.randombit.net/ - botan是一个支持多个编解码器的C++加密库。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-11-02 19:52:28

你可以让CAST-128 (或者像我所说的那样,CAST5)工作,它是一个分组密码。

最好的选择是以上不同配置的密钥大小。

两个人走得很快。

感谢'Olivier JG‘的所有优秀代码。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19388930

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档