SQLite Encryption Extension - PRAGMA activate_extensions= not working



  • I've got a good working application that uses SQLite. I've cross-compiled the Android SQLite lib, and gotten it to load on Android .

    But, the problem now is that to actually encrypt the data (it all continues to work fine un-encrypted) According to the SQLite Encryption Extension docs, I'm supposed to execute thes PRAGMAs ont he db IMMEDIATELY AFTER the db .open()... I do it like this:

    void DataStore::lock()
    {
        QSqlQuery active(sqlite);
        active.exec("PRAGMA activate_extensions='see-7bb07b8d471d642e';");
        qDebug() << "active last error: " << active.lastError();
    //no errors occurred
    
        QSqlQuery key(sqlite);
        key.exec("PRAGMA key='sqlite3';");
        qDebug() << "key last error: " << key.lastError();
    //no errors occurred
    }
    

    which is what I have confirmed is the correct PRAGMAs from the SQLite encryption extension folks. I get no errors, nor do I get encryption.

    Has anyone any done this before? any ideas?
    Could there be something internally to the Qt code that executes between the PRAGMAs and the actual SQLite open()?


  • Lifetime Qt Champion

    Hi,

    What version of SQLite are you using ?



  • @SGaist SQLite source code version-3.21.0 specifically the "see" (SQLite Encryption Extension) purchased & Qt 5.91


  • Lifetime Qt Champion

    Did you rebuild the SQLite plugin to use your custom version of SQLite ?



  • @SGaist I'm not sure what you mean. the Qt\5.9.1\android_armv7\plugins\sqldrivers\qsqlite.so file?


  • Lifetime Qt Champion

    For example, yes. I mean that if you are building your application for different targets, you need to build/re-build the QSQLite plugin for each of them.



  • @SGaist ? my application continues to run on windows and linux and Android and iOS - all hitting the SQLite db. I never once rebuilt that file, or any of Qt specifically.

    I believe that my app is linking to the actual binary libsqlite.so (that the libqsqlite.so plugin would link to) because, when I (with a hex editor) change the few bytes at the beginning of my libsqlite.so, then the db does fail on Android - I see that it fails to link on the console output. When I restore the bytes, it works again. But, I could be misinterpreting that somehow.

    I'd never heard of compiling this plugin separately: qsql_sqlite.cpp. Is that what you mean?


  • Lifetime Qt Champion

    AFAIR, if you don't use your system provided SQLite library, the plugin is built with Qt's internally provided SQLite which is built statically for that matter. Hence my question about re-building the QSQLite plugin using your custom version.



  • @SGaist thank you for steering me in that direction. I'm investigating that stuff now.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.