There is a bug with the way the fortuna rng is used in the libtomcrypt integration.
sqlcipher_ltc_activate initialises the global prng state when ltc_init is zero. That is, once only.
After a call to sqlcipher_ltc_deactivate where the ref reaches zero, the state is closed and cleared.
Subsequent calls to sqlcipher_ltc_activate will not re-initialise the prng state, resulting in a segfault in sqlcipher_ltc_random on the call to fortuna_read.
As a workaround, I pulled the call to fortuna_start out of the ltc_init check, and into one where it checks the ref count. eg
if(ltc_ref_count == 0) {
if(fortuna_start(&prng) != CRYPT_OK) {
return SQLITE_ERROR;
}
}
That stops the segfaults for me.
I can only assume no one else is using libtomcrypt ![]()