Elektra
0.9.1
|
This plugin is a filter plugin allowing Elektra to encrypt values before they are persisted and to decrypt values after they have been read from a backend.
The idea is to provide protection of sensible values before they are persisted. This means the value of a key needs to be encrypted before it is written to a file or a database. It also needs to be decrypted whenever an admissible access (read) is being performed.
The users of Elektra should not be bothered too much with the internals of the cryptographic operations. Also the cryptographic keys must never be exposed to the outside of the crypto module.
The crypto plugin supports different libraries as provider for the cryptographic operations. At the moment the following crypto APIs are supported:
libcrypto
)#ifdef ELEKTRA_CRYPTO_API_GCRYPT
libgcrypt20-dev
or libgcrypt-devel
#endif
#ifdef ELEKTRA_CRYPTO_API_OPENSSL
libssl-dev
or openssl-devel
#endif
#ifdef ELEKTRA_CRYPTO_API_BOTAN
libbotan1.10-dev
or botan-devel
#endif
GPG is a run-time dependency for all crypto plugin variants. Either the gpg
or the gpg2
binary should be installed when using the plugin. Note that gpg2
will be preferred if both versions are available. The GPG binary can be configured in the plugin configuration as /gpg/bin
(see GPG Configuration below). If no such configuration is provided, the plugin will look at the PATH environment variable to find the GPG binaries.
The following compilation variants are available:
Add "crypto" and the variants, that you want (you can add one of them or all), to the PLUGINS
variable in CMakeCache.txt
and re-run cmake
.
In order to add all compile variants you can add "CRYPTO" to the PLUGINS
variable.
An example CMakeCache.txt
may contain the following variable:
or it may look like:
All variants of the plugin work under macOS Sierra (Version 10.12.3 (16D32)).
To set up the build environment on macOS Sierra we recommend using Homebrew. Follow these steps to get everything up and running:
Also a GPG installation is required. The GPG Tools work fine for us.
At the moment the plugin will only run on Unix/Linux-like systems, that provide implementations for fork ()
and execv ()
.
To mount a backend with the gcrypt plugin variant that uses the GPG key 9CCC3B514E196C6308CCD230666260C14A525406, use:
Now you can specify a key user/t/a
and protect its content by using:
The value of user/t/a
will be stored encrypted. But you can still access the original value using kdb get
:
The path to the gpg binary can be specified in
The GPG recipient keys can be specified as encrypt/key
directly. If you want to use more than one key, just enumerate like:
If more than one key is defined, every owner of the corresponding private key can decrypt the values of the backend. This might be useful if applications run with their own user but the administrator has to update the configuration. The administrator then only needs the public key of the application user in her keyring, set the values and the application will be able to decrypt the values.
If you are not sure which keys are available to you, the kdb
program will give you suggestions in the error description. For example you can type:
In the error description you should see something like:
This means that the following keys are available:
So the full mount command could look like this:
Please note that these options are meant for experts only. If you do not provide these configuration options, secure defaults are being used.
The length of the master password that protects all the other keys can be set in:
The number of iterations that are to be performed in the PBKDF2 call can be set in:
The following key must be set to "1"
within the plugin configuration, if the plugin should shut down the crypto library:
Per default shutdown is disabled to prevent applications like the qt-gui from crashing. Shutdown is enabled in the unit tests to prevent memory leaks.
All of the plugin variants use the Advanced Encryption Standard (AES) in Cipher Block Chaining Mode (CBC) with a key size of 256 bit.
The ciphers and modes of operations are defined in the corresponding <plugin_variant>_operations.c
or <plugin_variant>_operations.h
file.