Encryption Key Management
MariaDB's data-at-rest encryption requires the use of a key management and encryption plugin. These plugins are responsible both for the management of encryption keys and for the actual encryption and decryption of data.
MariaDB supports the use of multiple encryption keys. Each encryption key uses a 32-bit integer as a key identifier. If the specific plugin supports key rotation, then encryption keys can also be rotated, which creates a new version of the encryption key.
Choosing an Encryption Key Management Solution
How MariaDB manages encryption keys depends on which encryption key management solution you choose. Currently, MariaDB has three options:
File Key Management Plugin
The File Key Management plugin that ships with MariaDB is a basic key management and encryption plugin that reads keys from a plain-text file. It can also serve as example and as a starting point when developing a key management plugin.
For more information, see File Key Management Plugin.
AWS Key Management Plugin
The AWS Key Management plugin is a key management and encryption plugin that uses the Amazon Web Services (AWS) Key Management Service (KMS). The plugin supports MariaDB 10.1 and later, but it is not provided in packages for MariaDB 10.1. It is provided in packages for MariaDB 10.2 and later, at least for environments where the plugin is supported. The plugin was first included in MariaDB 10.2.6.
For more information, see AWS Key Management Plugin.
eperi Gateway for Databases
The File Key Management plugin is intended as an example and a starting point for anyone developing an encryption plugin. It is not the most secure option, since it requires you to store your encryption keys on the same machine that's running MariaDB.
The eperi Gateway for Databases provides an alternative. With the eperi Gateway, your keys are stored on a key server. You can, optionally, perform all encryption on the key server as well. This prevents an attacker with file system access from unauthorized reading of the database files.
It also provides the following benefits:
- Key management outside the database
- No keys on database server hard disk
- Graphical user interface for configuration
- Encryption and decryption outside the database, supporting HSM's for maximum security.
Using Multiple Encryption Keys
Key management and encryption plugins support using multiple encryption keys. Each encryption key can be defined with a different 32-bit integer as a key identifier.
The support for multiple keys opens up some potential use cases. For example, let's say that a hypothetical key management and encryption plugin is configured to provide two encryption keys. One encryption key might be intended for "low security" tables. It could use short keys, which might not be rotated, and data could be encrypted with a fast encryption algorithm. Another encryption key might be intended for "high security" tables. It could use long keys, which are rotated often, and data could be encrypted with a slower, but more secure encryption algorithm. The user would specify the identifier of the key that they want to use for different tables, only using high level security where it's needed.
There are two encryption key identifiers that have special meanings in MariaDB. Encryption key
1 is intended for encrypting system data, such as InnoDB redo logs, binary logs, and so on. It must always exist when data-at-rest encryption is enabled. Encryption key
2 is intended for encrypting temporary data, such as temporary files and temporary tables. It is optional. If it doesn't exist, then MariaDB uses encryption key
1 for these purposes instead.
When an key management and encryption plugin provides support for key rotation, encryption keys can be rotated, which creates a new version of the encryption key. For example, the AWS key management plugin supports key rotation, but the file key management plugin does not.
Key rotation allows users to improve data security in the following ways:
- If the server is configured to automatically re-encrypt table data with the newer version of the encryption key after the key is rotated, then that prevents an encryption key from being used for long periods of time.
- If the server is configured to simultaneously encrypt table data with multiple versions of the encryption key after the key is rotated, then that prevents all data from being leaked if a single encryption key version is compromised.
The Aria storage engine does not currently have a similar mechanism to re-encrypt pages in the background when key rotations occur.
Encryption Plugin API
New key management and encryption plugins can be developed using the encryption plugin API.