Commit Graph

13 Commits

Author SHA1 Message Date
Martin Kleusberg
ba1270cedb Clean up the code and make some more minor optimisations
This also includes replacing some more Qt containers by their STL
counterparts.
2019-11-06 20:25:18 +01:00
Martin Kleusberg
9d9e92e5ee Convert some QRegExp usages to QRegularExpression 2019-10-02 12:00:20 +02:00
Martin Kleusberg
c224d04607 sqlcipher: Fix editing the encryption for SQLCipher4
With SQLCipher4 the encryption was not working as expected because the
KDF and HMAC algorithms were not set properly. This is fixed in this
commit so it should work now with SQLCipher4 as well as SQLCipher3.

See issues #1690 and #1732.
2019-02-12 10:42:51 +01:00
Martin Kleusberg
88ce4acf97 sqlcipher: Add new encryption settings to improve support for SQLCipher4
This adds three new settings to the cipher dialog: KDF iterations, HMAC
algorithm, and KDF algorithm. To simplify things we also add two presets
for all the encryption settings: SQLCipher3 defaults and SQLCipher4
defaults. The preselected default is chosen depending on the SQLCipher
version which we use.

This should work with any combination of SQLCipher3 and SQLCipher4 and
any database created by either. It should also work with DotEnv files as
expected. Again, the defaults which are used for missing values in the
DotEnv files are chosen depending on the SQLCipher version we use.
2018-12-12 13:41:47 +01:00
Iulian Onofrei
3cdc65a63f Add automatic crypted databases open via dotenvs (#1404)
* Rename confusing variables

* Fix some project warnings

* Fix code style

* Add constant for the default page size

* Move KeyFormats enum to CipherSettings

* Fix code style

* Fix memory leak

* Stop relying on CipherDialog for encryption settings management

* Fix code style

* Add .env format for QSettings

* Add automatic crypted databases open via dotenvs

This adds support for `.env` files next to the crypted databases that
are to be opened that contains the needed cipher settings.

The only required one is the plain-text password as a value for the key
with the name of the database like this:

    myCryptedDatabase.sqlite = MyPassword

This way, databases with a different extension are supported too:

    myCryptedDatabase.db = MyPassword

You can also specify a custom page size adding a different line
(anywhere in the file) like this:

    myCryptedDatabase.db_pageSize = 2048

If not specified, `1024` is used.

You can also specify the format of the specified key using the
associated integer id:

    anotherCryptedDatabase.sqlite = 0xCAFEBABE
    anotherCryptedDatabase.sqlite_keyFormat = 1

where `1` means a Raw key. If not specified, `0` is used, which means a
simple text Passphrase.

Dotenv files (`.env`) are already used on other platforms and by
different tools to manage environment variables, and it's recommended
to be ignored from version control systems, so they won't leak.

* Add new files to CMakeLists

* Move DotenvFormat include to the implementation

* Fix build error

* Remove superfluous method

(related to ac51c23)

* Remove superfluous checks

* Fix memory leaks

(introduced by 94bbb46)

* Fix code style

* Make dotenv related variable and comment clearer

* Remove duplicated code

* Remove unused forward declaration

(introduced by e5a0293)
2018-07-10 20:46:17 +02:00
Iulian Onofrei
9c2cec628b Make sure only powers of two are entered for the page size (#1405)
* Make sure only powers of two are entered for the page size

* Replace QSpinBox with QComboBox

Having a QSpinBox didn't make too much sense when we only have 8 valid
values. Forcing the user to type a valid value would have required a
warning message too, along with translations.

Having a QComboBox makes it clear (obviously) what values we are
expecting, without any risk of invalid values or confusion.

* Add thousands separator for page size values
2018-06-08 16:31:11 +02:00
Martin Kleusberg
ee32b3e4e1 Use nullptr where possible 2017-10-30 21:20:02 +01:00
Martin Kleusberg
5a922fff83 cipher: Fix passphrases containing single quotes
This fixes a regression introduced in d1e3e98006 which makes it
impossible to open encrypted databases with single quote characters in
their passphrase.

See issue #1105.
2017-09-01 10:12:54 +02:00
Martin Kleusberg
d1e3e98006 cipher: Add support for encryption using the raw key format
See issue #264.
2017-01-22 15:36:54 +01:00
Bernardo Sulzbach
abc432fcd6 Fixed a few typos. 2015-05-20 10:17:52 -03:00
Martin Kleusberg
a22ed6f9d3 cipher: Add option for changing the encryption used for the current file
Add a new menu option to the main window (only visible when built with
the sqlcipher option enabled) which opens a dialog asking for new
encryption settings. These are then applied to a new database to which
all contents of the current one are exported. The old database is then
replaced by the new one.

This adds support for encrypting plaintext databases, decrypting
encrypted databases and changing the password or other settings of
encrypted databases.

If this turns out to work well enough we have functional SQLCipher
encryption support with only details missing.
2014-11-02 19:06:06 +01:00
Martin Kleusberg
8fb9176f99 cipher: Show encryption status in the main window statusbar
Add a note to the status bar of the main window when an encrpyted
database is opened.

Also make some methods in the CipherDialog class const.
2014-11-02 18:15:13 +01:00
Martin Kleusberg
167d8cbd74 cipher: Fix build option and use a dialog for entering the password
Fix the sqlcipher build option in the qmake project to actually enable
the SQLCipher support.

Add a new dialog called CipherDialog which is used to ask the user for
the password and other encryption details instead of using standard Qt
input dialogs.
2014-11-02 13:12:31 +01:00