Closed topmin closed 8 months ago
SQLite3MultipleCiphers supports 6 types of CODEC, Can used to reduce the size of the compiled library by omitting unused CODEC_TYPE?
Yes, this can be achieved by defining preprocessor symbols with value 0
for the unwanted cipher schemes:
/* Define one or more of the following symbols to disable the corresponding cipher scheme */
#define HAVE_CIPHER_AES_128_CBC 0
#define HAVE_CIPHER_AES_256_CBC 0
#define HAVE_CIPHER_CHACHA20 0
#define HAVE_CIPHER_SQLCIPHER 0
#define HAVE_CIPHER_RC4 0
#define HAVE_CIPHER_ASCON128 0
However, don't forget to set the symbol CODEC_TYPE
to the new desired default cipher scheme, if you disable CHACHA20
.
How much the size of the library shrinks, will depend on the selected ciphers.
You can reduce the size much more by disabling extensions you don't need. Look out for symbols SQLITE_ENABLE_???
and undefine the symbols for the extensions you want to exclude.
Very good, I used the following lines and the size of compiled library decreased by 194 kb.
define HAVE_CIPHER_AES_128_CBC 0
define HAVE_CIPHER_AES_256_CBC 0
define HAVE_CIPHER_CHACHA20 0
define HAVE_CIPHER_SQLCIPHER 0
define HAVE_CIPHER_RC4 0
define HAVE_CIPHER_ASCON128 0
define CODEC_TYPE CODEC_TYPE_CHACHA20
As for the symbols SQLITEENABLE???, it was originally undefine.
Thank you!
Very good, I used the following lines and the size of compiled library decreased by 194 kb.
#define HAVE_CIPHER_AES_128_CBC 0 #define HAVE_CIPHER_AES_256_CBC 0 #define HAVE_CIPHER_CHACHA20 0 #define HAVE_CIPHER_SQLCIPHER 0 #define HAVE_CIPHER_RC4 0 #define HAVE_CIPHER_ASCON128 0 #define CODEC_TYPE CODEC_TYPE_CHACHA20
Well, if you want to keep the CHACHA20
cipher scheme, you must enable it (by using value 1
):
#define HAVE_CIPHER_CHACHA20 1
Otherwise you get a library without encryption support, if you disable all cipher schemes.
As for the symbols SQLITEENABLE???, it was originally undefine.
Sorry, I should have been more explicit. The part ???
is just a placeholder for the extension names.
Here is a (incomplete) list of extensions that could be disabled:
#undef SQLITE_ENABLE_CARRAY /* Disable extension 'carray' */
#undef SQLITE_ENABLE_CSV /* Disable extension 'csv' */
#undef SQLITE_ENABLE_EXTFUNC /* Disable extension 'extfunc' */
#undef SQLITE_ENABLE_UUID /* Disable extension 'uuid' */
#undef SQLITE_ENABLE_SESSION /* Disable session extension */
#undef SQLITE_ENABLE_FILEIO /* Disable extension 'fileio' */
#undef SQLITE_ENABLE_REGEXP /* Disable extension 'regexp' */
#undef SQLITE_ENABLE_SERIES /* Disable extension 'series' */
#undef SQLITE_ENABLE_SHA3 /* Disable extension 'sha3' */
#undef SQLITE_ENABLE_COMPRESS /* Disable extension 'compress' */
#undef SQLITE_ENABLE_SQLAR /* Disable extension 'sqlar' */
#undef SQLITE_ENABLE_ZIPFILE /* Disable extension 'zipfile' */
#undef SQLITE_USER_AUTHENTICATION /* Disable extension 'user authentication' */
You should undefine only those symbols for extensions which you actually don't need.
Well, if you want to keep the CHACHA20 cipher scheme, you must enable it (by using value 1):
#define HAVE_CIPHER_CHACHA20 1
Otherwise you get a library without encryption support, if you disable all cipher schemes.
As for the symbols SQLITEENABLE???, it was originally undefine.
Sorry, I should have been more explicit. The part ??? is just a placeholder for the extension names.
You said it very clearly, I can understand that ??? is just a placeholder for the extension names. For example, SQLITE-ENABLE-CARRAY, etc., are originally undefined in sqlite3mc.c.
Thank you again.
Well, if you want to keep the CHACHA20 cipher scheme, you must enable it (by using value 1):
#define HAVE_CIPHER_CHACHA20 1
define HAVE_CIPHER_CHACHA20 1 is not necessary,
You are right, IF the symbol HAVE_CIPHER_CHACHA20
is not defined at all.
in fact, only #define CODEC_TYPE CODEC_TYPE_CHACHA20 is enough.
No, defining the symbol CODEC_TYPE
is only necessary, if you disable the cipher scheme CHACHA20
with HAVE_CIPHER_CHACHA20=0
or if you want to select a different default cipher scheme.
You said it very clearly, I can understand that ??? is just a placeholder for the extension names. For example, SQLITE-ENABLE-CARRAY, etc., are originally undefined in sqlite3mc.c.
Yes, many symbols are not defined at all in the source code. The reason is that the original SQLite source code checks only whether a symbol is defined or not, but not the value.
SQLite can be configured in many ways and it is up to the developer to choose the set of options meeting the requirements of his/her project. A list of options with explanations can be found here: SQLite Compile-time Options.
Regarding SQLite3 Multiple Ciphers there are several options that should be set to non-default values. The build files coming with the project show you which options I chose as defaults, but of course it is up to the individual developer to use the defaults or not. The options and default values can be seen here or here.
I strongly recommend to use SQLITE_SECURE_DELETE=1
and SQLITE_TEMP_STORE=2
for security reasons, and SQLITE_USE_URI=1
to be able to configure a database connection via URI parameters.
Understood. I directly used Sqlite3mc.c and Sqlite3mc.h for compilation without using a make file, so these options and default values for the make file are meaningless. Thank you again.
I guess the issue can now be closed. Feel free to reopen it, if further related questions arise.
SQLite3MultipleCiphers supports 6 types of CODEC, Can used to reduce the size of the compiled library by omitting unused CODEC_TYPE?