Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support SQLcipher #72

Open
talmeme opened this issue Jul 29, 2024 · 6 comments
Open

Support SQLcipher #72

talmeme opened this issue Jul 29, 2024 · 6 comments
Labels
enhancement New feature or request

Comments

@talmeme
Copy link

talmeme commented Jul 29, 2024

SQLcipher is a standalone fork of the SQLite database library that adds 256 bit AES encryption of database files and other security features like:

  • on-the-fly encryption
  • tamper detection
  • memory sanitization
  • strong key derivation

SQLcipher uses one of CommonCrypto, libtomcrypt, NSS and OpenSSL for crypto functionality.

@talmeme talmeme added the enhancement New feature or request label Jul 29, 2024
@talmeme
Copy link
Author

talmeme commented Jul 29, 2024

I have a working integration, with corresponding SQLite-Kit and Fluent SQLite driver.

And a demo. Tested working on macOS Sonoma aarch64 and Ubuntu 22.04 aarch64 with Swift v5.10.

@0xTim
Copy link
Member

0xTim commented Jul 29, 2024

If this can be achieved using Swift Crypto we can probably looking at merging it. Otherwise it's probably a no go

@talmeme
Copy link
Author

talmeme commented Jul 29, 2024

If this can be achieved using Swift Crypto we can probably looking at merging it. Otherwise it's probably a no go

SQLcipher is implemented in C using SQLite's deprecated codec hooks and compiled together with SQLite's C source. This likely precludes using Swift Crypto to implement an SQLcipher crypto provider.

An alternative approach is to use SQLite's VFS mechanism, as is done by SQLite3MultipleCiphers. Not sure how feasible to implement an SQLite VFS in Swift.

@0xTim
Copy link
Member

0xTim commented Jul 29, 2024

I'll let Gwynne chime in when she's back as she knows this far better than I do. The main issue is the inclusion of a system dependency on tomcrypt which complicates a number of things, including the fact that it hasn't had a release in 6 years and I find it very hard to believe there haven't been any security issues in that time.

OpenSSL is probably the only possibility if we need to link against something, but again, its a bulky library and another dependency that's required regardless of whether you're using it or not

@talmeme
Copy link
Author

talmeme commented Jul 30, 2024

I agree on tomcrypt. I use it because that's what Skip does, so I started with something known working.

I now see that it is easy to link SQLcipher with OpenSSL. BoringSSL works too, although, as you have mentioned, BoringSSL doesn't have stable API and usually needs to be built from source.

@talmeme
Copy link
Author

talmeme commented Aug 9, 2024

Updates:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants