Re: [sqlite3-ruby] sqlcipher gem

518 views
Skip to first unread message

Luis Lavena

unread,
May 21, 2013, 11:10:07 AM5/21/13
to sqlite...@googlegroups.com
Hello,

On Tue, May 21, 2013 at 6:56 AM, Thomas Buschhardt <busch...@gmail.com> wrote:
Hallo,

I installed sqlcipher on my system and it would nice to use it with ruby. Its based on sqlite3 and the remakable difference is to give a password:

PRAGMA key='password';
SELECT * from something;

How can I run this through the sqlite3 gem?



Is sqlcipher a custom build of SQLite3?

From the documentation:


It seems so. And it seems it generates sqlite3 shared/static libraries too, and not a custom name

If that is the case, you will need to compile sqlite3 gem using that set of headers/libraries, something like:

gem install sqlite3 --platform=ruby -- --with-opt-dir=/path/to/compiled_sqlcipher

where `compiled_sqlcipher` have the normal structure `bin`, `lib` and `include`

You can try that and let us know.

--
Luis Lavena
AREA 17
-
Perfection in design is achieved not when there is nothing more to add,
but rather when there is nothing more to take away.
Antoine de Saint-Exupéry

Thomas Buschhardt

unread,
May 23, 2013, 3:56:22 AM5/23/13
to sqlite...@googlegroups.com
Hallo Luis,

gem install sqlite3 --platform=ruby -- --with-opt-dir=/blabla/sqlcipher
Building native extensions.  This could take a while...
Successfully installed sqlite3-1.3.7
1 gem installed

I dont know these process take the crypto-library or not...

Test (is running with sqlcipher-console successfully):
require 'sqlite3'
=> true
db = SQLite3::Database.new("/blabla/testcipher.db")
=> #<SQLite3::Database:0x91e7554>
db.execute("PRAGMA key='passwort';")
=> []
db.execute("SELECT * FROM plants;")
SQLite3::NotADatabaseException: file is encrypted or is not a database
        from /var/lib/gems/1.9.1/gems/sqlite3-1.3.7/lib/sqlite3/database.rb:91:in `initialize'
        from /var/lib/gems/1.9.1/gems/sqlite3-1.3.7/lib/sqlite3/database.rb:91:in `new'
        from /var/lib/gems/1.9.1/gems/sqlite3-1.3.7/lib/sqlite3/database.rb:91:in `prepare'
        from /var/lib/gems/1.9.1/gems/sqlite3-1.3.7/lib/sqlite3/database.rb:134:in `execute'
        from (irb):4
        from /usr/bin/irb:12:in `<main>'

It looks like I have no luck (and little knowledge). I use debian 7.0 i386.

Greets Thomas

Luis Lavena

unread,
May 23, 2013, 9:58:10 AM5/23/13
to sqlite...@googlegroups.com
On Thu, May 23, 2013 at 4:56 AM, Thomas Buschhardt <busch...@gmail.com> wrote:
Hallo Luis,

gem install sqlite3 --platform=ruby -- --with-opt-dir=/blabla/sqlcipher
Building native extensions.  This could take a while...
Successfully installed sqlite3-1.3.7
1 gem installed


Does /blabla/sqlcipher contains the compiled artifacts of sqlcipher? can you tell me if the values of the following:

SQLite3::SQLITE_VERSION
SQLite3::SQLITE_VERSION_NUMBER
SQLite3.libversion

Matches the version of sqlcipher?

Can you tell me if sqlcipher was build statically or dynamically? If dynamic is the answer, can you tell me if the shared object of sqlcipher is placed in the lookup path of LD?

How you built sqlcipher? did you force dynamic or just static options?

Can you tell me if sqlite3_native.so (inside the gem installation directory) is linked to sqlcipher shared library?

I have zero experience with sqlcipher, so I'm guessing all the above based on default sqlite3 behavior.

Reply all
Reply to author
Forward
0 new messages