This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Add support for SQLCipher
Type: Stage:
Components: Versions:
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Manjusaka, Sebastian.Noack, benjamin.peterson, berker.peksag, ghaering, serhiy.storchaka
Priority: normal Keywords:

Created on 2020-01-21 09:32 by Sebastian.Noack, last changed 2022-04-11 14:59 by admin.

Messages (7)
msg360373 - (view) Author: Sebastian Noack (Sebastian.Noack) Date: 2020-01-21 09:32
SQLCipher is industry-standard technology for managing an encrypting SQLite databases. It has been implemented as a fork of SQLite3. So the sqlite3 corelib module would build as-is against it. But rather than a fork (of this module), I'd rather see integration of SQLCiper in upstream Python. I'm happy to volunteer if this changes have any chance of landing.

By just adding 2 lines to the cpython repository (and changing ~10 lines), I could make SQLCipher (based on the current sqlite3 module) available as a separate module (e.g. sqlcipher or sqlite3.cipher). However, IMO the ideal interface would be sqlilte3.connect(..., sqlcipher=True).

Any thoughts?
msg360396 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2020-01-21 13:14
What exactly do you need to add and change in the sqlite module? The stdlib cannot depend on a third-party module. Ideally, you just create a subclass of some standard class and overrides a constructor and few methods.
msg360430 - (view) Author: Sebastian Noack (Sebastian.Noack) Date: 2020-01-21 20:13
Well, the stdlib already depends on a third-party library here, i.e. SQLite3. SQLCipher is a drop-in replacement for SQLite3 that adds support for encrypted databases. In order to use SQLCipher, I'd have to build the sqlite3 module against SQLCipher (instead of SQLite3). As it's a drop-in replacement, no further changes are required (unless rather than having SQLCipher bindings exposed as a separate module, we want enable it through an argument in sqlite3.connect).
msg360432 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2020-01-21 20:33
If SQLCipher is a drop-in replacement, perhaps the simplest way is to use LD_LIBRARY_PATH to replace libsqlite3.

You can also insert a path to your build of the _sqlite module in sys.path before standard paths.
msg360438 - (view) Author: Sebastian Noack (Sebastian.Noack) Date: 2020-01-21 23:30
Yes, I could use LD_LIBRARY_PATH (after copying /usr/lib/libsqlcipher.so.0 to /some/folder/libsqlite3.so), or alternatively LD_PRELOAD, and the sqlite3 stdlib module will just work as-is with SQLCipher. The latter is in fact what I'm doing at the moment, but this is quite a hack, and it's not portable to macOS or Windows.

Alternatively, I could fork the sqlite3 stdlib module, have it built against SQLCipher, and redistribute it. But I'd rather not go there.

That's why I'd love to see built-in support for SQLCipher in upstream Python, and as it is a drop-in replacement for SQLite3 which the stdlib already comes with bindings for, it seems to be a fairly small change on your end.
msg360443 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2020-01-22 02:38
It might help if you show the change you actually propose.
msg360476 - (view) Author: Manjusaka (Manjusaka) * Date: 2020-01-22 15:37
To be serious, I don't think using SQLCipher is a good idea for CPython

Cause, SQLCipher is always released by the source code, not the binary. That means we should compile and manage the binary on different platforms, sush as ffi on windows, Openssl on Windows.


I think that will bring in some substantial compatibility problems.

I think the ROI is not enough to make this change.
History
Date User Action Args
2022-04-11 14:59:25adminsetgithub: 83589
2020-01-22 15:37:38Manjusakasetnosy: + Manjusaka
messages: + msg360476
2020-01-22 02:38:40benjamin.petersonsetnosy: + benjamin.peterson
messages: + msg360443
2020-01-21 23:30:02Sebastian.Noacksetmessages: + msg360438
2020-01-21 20:33:51serhiy.storchakasetmessages: + msg360432
2020-01-21 20:13:46Sebastian.Noacksetmessages: + msg360430
2020-01-21 13:14:50serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg360396
2020-01-21 11:30:45xtreaksetnosy: + ghaering, berker.peksag
2020-01-21 09:32:50Sebastian.Noackcreate