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

innodb_encryption_rotate_key_age behaviour is misleading

    XMLWordPrintable

Details

    Description

      The documentation states:

      Re-encrypt in background any page having a key older than this number of key versions.

      This would normally mean that reencryption would occur for any table for which

      MIN_KEY_VERSION + innodb_encryption_rotate_key_age <= CURRENT_KEY_VERSION


      Since innodb_encryption_rotate_key_age cannot be 0 when rotation is enabled, "<=" (less equal) is safe. Unfortunately, that's not how it works. The check in the code is using "<" (less):

      if (key_version + rotate_key_age < latest_key_version) { return true; }

      The outcome is that when

      innodb_encryption_rotate_key_age = 1

      , the tables won't be reencrypted when I update my encryption key once. I must update it twice, which introduces various difficulties to our external key rotation mechanism.

      In the following scenario, It's not possible to have my tables encrypted with key version 2:

      #config
      innodb_encrypt_tables = ON
      innodb_default_encryption_key_id = 1
      innodb_encryption_rotate_key_age = 1
      ----
      | NAME                       | ENCRYPTION_SCHEME | MIN_KEY_VERSION | CURRENT_KEY_VERSION |
      +----------------------------+-------------------+-----------------+---------------------+
      | my_db/my_tabl              |                 1 |               1 |                   1 |
       
      # Update Key
       
      | NAME                       | ENCRYPTION_SCHEME | MIN_KEY_VERSION | CURRENT_KEY_VERSION |
      +----------------------------+-------------------+-----------------+---------------------+
      | my_db/my_tabl              |                 1 |               1 |                   2 |
       
      # Update Key
       
      | NAME                       | ENCRYPTION_SCHEME | MIN_KEY_VERSION | CURRENT_KEY_VERSION |
      +----------------------------+-------------------+-----------------+---------------------+
      | my_db/my_tabl              |                 1 |               3 |                   3 |
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            Sebieee Sebastian
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Git Integration

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