Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-20713

Implement key rotation for file_key_management plugin




      Some users are requesting that we implement key rotation for file_key_management plugin.

      I'm not sure that it's practical. How would key rotation work in file_key_management plugin? The plugin has some serious limitations that would likely make it impractical to implement key rotation. Some open questions are listed below.

      Generation of New Key Versions

      How would new key versions be generated?

      The file_key_management plugin currently doesn't generate any encryption keys itself, and it doesn't even have a backend KMS to generate encryption keys for it either.

      With file_key_management plugin, any encryption keys currently need to be generated by the user with external tools, such as openssl. For example:

      -- Generate a new 256-bit key
      openssl rand -hex 32

      And then the keys currently need to be manually saved to the key file.

      See here:


      Some possibilities:

      • Would the user still have to manually generate the new key versions, and then manually save them to the key file?
      • Would we implement a UDF in the file_key_management plugin that can be used to generate random keys, and a UDF that can save a key version to a key file? For example:

      -- Generate a new 256-bit key
      SELECT file_key_management_generate_key(256);
      -- Write key to key file as key_version 2 of key ID 1
      SELECT file_key_management_save_key_version(1, 2, '8ceb3336fa2a4bfacced7ea5dae17f246d93da44890386e2ce178453c4e9ba9e');

      Format of Key File

      How would the format of the key file change to allow different key versions of the same key ID?

      The format of file_key_management plugin's key file is pretty simplistic. It simply stores encryption keys in a plain-text file that uses the format.


      For example, if we had two keys with key ID 1 and 2, then the key file could look like this:


      This format currently has no way to store different versions of the same encryption key. However, this is something that it would need to support in order to support key rotation.

      It's possible that we could extend the format, but it could get very ugly. For example:


      For example, if we had two key versions of two different keys with key ID 1 and 2, then the key file could look like this:


      Reloading Key Versions

      If we decide that new key versions need to be manually generated, then how would the file_key_management plugin reload the new key versions?

      Some possibilities:

      • file_key_management plugin currently only parses the key file at startup. Would we still want to require a server restart to reload keys?
      • Would we want to implement some FLUSH command? For example:


      • Would we want to implement some UDF? For example:

      SELECT file_key_management_reload_keys();

      Similar functionality in other databases?

      Is there similar functionality in other databases that we could use as inspiration?

      Users migrating from Oracle might have used Oracle Wallet:



        Issue Links



              Unassigned Unassigned
              GeoffMontee Geoff Montee (Inactive)
              1 Vote for this issue
              6 Start watching this issue



                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.