Problem using QSQLCIPHER Qt driver

405 views
Skip to first unread message

doublebyte1

unread,
Oct 1, 2013, 10:19:06 AM10/1/13
to sqlc...@googlegroups.com
Hi,
First of all, thank you very much for this project that brings encryption to SQLite databases: a feature longing awaited.

I compiled the driver from source, and use it to encrypt/decrypt databases: it works as charm.

I am working in a project using Qt, and I interface the databases through the various Qt SQL drivers, so I as happy to find out that there was a QSQLCIPHER driver available :-)

I have built the driver, following these instructions:

http://www.qtcentre.org/wiki/index.php?title=Building_QSQLITE_driver_with_AES-256_encryption_support_%28Linux%29

Everything seemed to work fine.

I am using Qt 4.8.6, built from source and the plugins are located in the $QTDIR/plugins/sqldrivers directory.

libqsqlcipher.so is one of the libraries present in this directory, as an output of the previously successful installation.

I wrote an application to test if everything is fine, and the output of  QSqlDatabase::drivers() is:

("QSQLCIPHER", "QSQLITE", "QMYSQL3", "QMYSQL", "QODBC3", "QODBC", "QPSQL7", "QPSQL")

Then I wrote another application, to open a previously encrypted database;

   QSqlDatabase db = QSqlDatabase::addDatabase("QSQLCIPHER");


    db.setDatabaseName("/home/joana/projects/CAS_upgrade/code/test.db");
    if (!db.open())
      qFatal("Could not access database.");

    QSqlQuery query(db);

    query.exec("PRAGMA key = 'testkey';");

    if (query.lastError().type() != QSqlError::NoError)
        qDebug() << query.lastError().text();
    else
        qDebug() << "ok!" << endl;


    query.exec("select * from pt_shop;");

    if (query.lastError().type() != QSqlError::NoError)
        qDebug() << query.lastError().text();
    else
        qDebug() << "ok!" << endl;

There is no error in opening the database using the sqlcipher driver, and in applying the PRAGMA. However, when I try to make a select, I get an error stating that the database is "encrypted or not valid"

I re-wrote the application, and applied this query

   query.exec("SELECT sqlcipher_export('encrypted');");

for which I got this error:

 "no such function: sqlcipher_export Unable to execute statement"

My guess, is that QT is using the normal SQLite driver, rather than the SQLCIPHER one, since this is exactly the same behaviour that I get in the command line, if I use plain sqlite3... :-/

Anybody has any idea, why this is happening?

These are my library versions:

SQLite version 3.7.13 2012-06-11 02:05:22 (from ubuntu package)
SQLCipher version 3.7.17 2013-05-20 00:56:22 (compiled from source)

SQLCipher was compiled both as a shared library, and as a Qt plugin and libsqlcipher.so
 is present in /usr/local/lib/ and in $QTDIR_PLUGINS

I really appreciate any suggestions or thoughts about this, because I don't know where else to look!
           Thanks in advance,
                                  Joana










Reply all
Reply to author
Forward
0 new messages