Skip to content

PBS-39 feature: Add binlog encryption config and keyring support (part 7) - #170

Merged
percona-ysorokin merged 1 commit into
Percona-Lab:0.4from
percona-ysorokin:encryption_diagnostics
Aug 7, 2026
Merged

PBS-39 feature: Add binlog encryption config and keyring support (part 7)#170
percona-ysorokin merged 1 commit into
Percona-Lab:0.4from
percona-ysorokin:encryption_diagnostics

Conversation

@percona-ysorokin

Copy link
Copy Markdown
Collaborator

https://perconadev.atlassian.net/browse/PBS-39

Added more diagnostics for keyring data, encryption configuration parameter and their combinations

  • We now check that 'cipher' parameter in the keyring record is known to OpenSSL and is of 'ECB', 'CBC', 'CRT', or 'GCM' mode.
  • We now check that the actual length of the 'data_hex' matches the one derived from the 'cipher' (i.g., 256 bit / 32 bytes / 64 hexadecimal characters for 'AES-256-CTR').
  • We now check the uniqueness of the key IDs ('id' field) amongst keyring records.
  • We also make sure that random file keys (of length that corresponds to the '<storage.encryption.cipher>' configuration parameter) can be encrypted with the active KEK ('<storage.encryption.kek_id>' configuration parameter). For instance, if active data cipher is 'AES-192-CRT' (key length 24 bytes), then the active KEK cannot be of 'ECB' or 'CBC' mode as these ciphers can only encrypt data of length that is a multiple of the block size (16 bytes).

'opensslpp::cipher_context' class extended with:

  • 'get_mode()' (both static and non-static versions) that returns the cipher mode ('ECB', 'CBC', 'CRT', or 'GCM').
  • 'is_cipher_name_known()' (static) - returns true if this cipher name is known to OpenSSL.
  • 'is_mode_supported()' (static) - returns true if the mode is one of the 'ECB', 'CBC', 'CRT', or 'GCM'.
  • 'is_cipher_name_supported()' (static) - returns true if this cipher name is known to OpenSSL and its mode is supported.

'cipher_context_test.cpp' (BOOST_TEST_MODULE CipherContextTests) unit test extended with the following test cases.

  • 'CipherContextGetModeStatic' / 'CipherContextGetMode' that check for the behavior of the 'opensslpp::cipher_context::get_mode()' methods (both static and non-static).
  • 'CipherContextCTRResume' that checks for "resume streaming" operation for 'XXX-NNN-CTR' ciphers - creating a new encryption context, updating it with some data, finalizing, creating a new context with offset, updating it with more data, and finalizing. The result of this operation should be identical to simple encryption of the concatenated data blocks from the first and the second updates.

…t 7)

https://perconadev.atlassian.net/browse/PBS-39

Added more diagnostics for keyring data, encryption configuration parameter and
their combinations
- We now check that 'cipher' parameter in the keyring record is known to OpenSSL and
  is of 'ECB', 'CBC', 'CRT', or 'GCM' mode.
- We now check that the actual length of the 'data_hex' matches the one derived from
  the 'cipher' (i.g., 256 bit / 32 bytes / 64 hexadecimal characters for 'AES-256-CTR').
- We now check the uniqueness of the key IDs ('id' field) amongst keyring records.
- We also make sure that random file keys (of length that corresponds to the
  '<storage.encryption.cipher>' configuration parameter) can be encrypted with the
  active KEK ('<storage.encryption.kek_id>' configuration parameter). For instance, if
  active data cipher is 'AES-192-CRT' (key length 24 bytes), then the active KEK cannot
  be of 'ECB' or 'CBC' mode as these ciphers can only encrypt data of length that is a
  multiple of the block size (16 bytes).

'opensslpp::cipher_context' class extended with:
- 'get_mode()' (both static and non-static versions) that returns the cipher mode
  ('ECB', 'CBC', 'CRT', or 'GCM').
- 'is_cipher_name_known()' (static) - returns true if this cipher name is known to
  OpenSSL.
- 'is_mode_supported()' (static) - returns true if the mode is one of the 'ECB', 'CBC',
  'CRT', or 'GCM'.
- 'is_cipher_name_supported()' (static) - returns true if this cipher name is known to
  OpenSSL and its mode is supported.

'cipher_context_test.cpp' (BOOST_TEST_MODULE CipherContextTests) unit test
extended with the following test cases.
- 'CipherContextGetModeStatic' / 'CipherContextGetMode' that check for the behavior
  of the 'opensslpp::cipher_context::get_mode()' methods (both static and non-static).
- 'CipherContextCTRResume' that checks for "resume streaming" operation for
  'XXX-NNN-CTR' ciphers - creating a new encryption context, updating it with some
  data, finalizing, creating a new context with offset, updating it with more data, and
  finalizing. The result of this operation should be identical to simple encryption of the
  concatenated data blocks from the first and the second updates.
@percona-ysorokin
percona-ysorokin merged commit e61cf07 into Percona-Lab:0.4 Aug 7, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant