- infos = Information about crypto plugin is in keys below
- infos/author = Peter Nirschl email@example.com
- infos/licence = BSD
- infos/provides = crypto
- infos/needs =
- infos/recommends =
- infos/placements = postgetstorage presetstorage
- infos/status = unittest configurable memleak unfinished discouraged
- infos/metadata = crypto/encrypt
- infos/description = Cryptographic operations
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:
- OpenSSL (
GPG is a run-time dependency for all crypto plugin variants.
gpg or the
gpg2 binary should be installed when using the plugin.
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.
How to compile
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
In order to add all compile variants you can add "CRYPTO" to the
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:
brew install openssl botan libgcrypt pkg-config cmake # The next step is required for pkg-config to find the include files of OpenSSL ln -s /usr/local/opt/openssl/include/openssl/ /usr/local/include/openssl
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
To mount a backend with the gcrypt plugin variant that uses the GPG key 9CCC3B514E196C6308CCD230666260C14A525406, use:
kdb mount test.ecf user/t crypto_gcrypt "crypto/key=9CCC3B514E196C6308CCD230666260C14A525406"
Now you can specify a key
user/t/a and protect its content by using:
kdb set user/t/a kdb setmeta user/t/a crypto/encrypt 1 kdb set user/t/a "secret"
The value of
user/t/a will be stored encrypted.
But you can still access the original value using
kdb get user/t/a
The path to the gpg binary can be specified in
The GPG recipient keys can be specified as
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:
kdb mount test.ecf user/t crypto_gcrypt
In the error description you should see something like:
The command ./bin/kdb mount terminated unsuccessfully with the info: The provided plugin configuration is not valid! Errors/Warnings during the check were: Sorry, module crypto issued the error 130: the configuration is invalid or incomplete: Missing GPG key (specified as encrypt/key) in plugin configuration. Available key IDs are: B815F1334CF4F830187A784256CFA3A5C54DF8E4,847378ABCF0A552B48082A80C52E8E92F785163F Please report the issue at https://issues.libelektra.org/
This means that the following keys are available:
So the full mount command could look like this:
kdb mount test.ecf user/t crypto_gcrypt "crypto/key=847378ABCF0A552B48082A80C52E8E92F785163F"
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.
Ciphers and Mode of Operation
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