Skip to content

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

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

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

Conversation

@percona-ysorokin

Copy link
Copy Markdown
Collaborator

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

'binsrv::binlog_file_metadata' class extended with additional optional field 'encryption' of class 'binsrv::binlog_file_encryption_metadata' that consists of two fields:

  • 'file_key_envelope' holding info about file key encryption,
  • 'file_data_envelope' holding info about binlog data file encryption.

Added new 'binsrv::file_key_envelope' class with the following fields:

  • 'kek_id' - the identifier of the key from the keyring that was used as KEK for file key encryption operation,
  • 'iv_hex' - the initialization vector that was used for this file key encryption operation (optional, should be set for every mode apart from 'XXX-ECB'),
  • 'data_hex' - the result of the key-encryption operation,
  • 'tag_hex' - the AEAD tag calculated as the result of this file key encryption operation (optional, is set only in 'XXX_GCM' encryption modes).

Added new 'binsrv::file_data_envelope' class with the following fields:

  • 'cipher' - the name of the encryption cipher used for binlog file data encryption operation (e.g. 'AES-256-CTR'),
  • 'iv_hex' - the initialization vector that was used for this binlog file data encryption operation (always present as file data encryption operation requires a streaming cipher like 'XXX-CTR' or 'XXX-GCM'),
  • 'tag_hex' - the AEAD tag calculated as the result of this binlog file data encryption operation (optional, is set only in 'XXX-GCM' encryption modes).

'binsrv::basic_keyring' interface extended with one more method 'contains()' which checks if a key with the specified identifier present in the keyring.

'binsrv::storage::binlog_record' internal class extended with additional optional 'encryption' field of class 'binsrv::storage::binlog_encryption_record' which holds info from the envelopes above in the form more suitable for encryption / decryption operations (unhexed).

If encryption is enabled in the main configuration file each JSON binlog metadata file will now include additional 'encryption' subelement. 'save_binlog_metadata()' / 'load_binlog_metadata()' methods in the 'binsrv::storage' class extended with converting encryption envelopes from / to internal 'binsrv::storage::binlog_encryption_record' class instances.

As an intermediate step added fake file key / iv generation functions, file key encryption and file key encryption tag calculation functions, fake file data encryption and file data encryption tag calculation functionality to the 'binsrv::storage::generate_binlog_encryption_record()' method. At the next step these functions should be replaced with proper OpenSSL calls.

…t 3)

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

'binsrv::binlog_file_metadata' class extended with additional optional field 'encryption'
of class 'binsrv::binlog_file_encryption_metadata' that consists of two fields:
- 'file_key_envelope' holding info about file key encryption,
- 'file_data_envelope' holding info about binlog data file encryption.

Added new 'binsrv::file_key_envelope' class with the following fields:
- 'kek_id' - the identifier of the key from the keyring that was used as KEK for file key
  encryption operation,
- 'iv_hex' - the initialization vector that was used for this file key encryption operation
  (optional, should be set for every mode apart from 'XXX-ECB'),
- 'data_hex' - the result of the key-encryption operation,
- 'tag_hex' - the AEAD tag calculated as the result of this file key encryption operation
  (optional, is set only in 'XXX_GCM' encryption modes).

Added new 'binsrv::file_data_envelope' class with the following fields:
- 'cipher' - the name of the encryption cipher used for binlog file data encryption
  operation (e.g. 'AES-256-CTR'),
- 'iv_hex' - the initialization vector that was used for this binlog file data encryption
  operation (always present as file data encryption operation requires a streaming
  cipher like 'XXX-CTR' or 'XXX-GCM'),
- 'tag_hex' - the AEAD tag calculated as the result of this binlog file data encryption
  operation (optional, is set only in 'XXX-GCM' encryption modes).

'binsrv::basic_keyring' interface extended with one more method 'contains()' which
checks if a key with the specified identifier present in the keyring.

'binsrv::storage::binlog_record' internal class extended with additional optional
'encryption' field of class 'binsrv::storage::binlog_encryption_record' which holds info
from the envelopes above in the form more suitable for encryption / decryption
operations (unhexed).

If encryption is enabled in the main configuration file each JSON binlog metadata file
will now include additional 'encryption' subelement.
'save_binlog_metadata()' / 'load_binlog_metadata()' methods in the 'binsrv::storage'
class extended with converting encryption envelopes from / to internal
'binsrv::storage::binlog_encryption_record' class instances.

As an intermediate step added fake file key / iv generation functions, file key encryption and file key encryption tag calculation functions, fake file data encryption and file data encryption tag calculation functionality to the
'binsrv::storage::generate_binlog_encryption_record()' method. At the next step
these functions should be replaced with proper OpenSSL calls.
@percona-ysorokin
percona-ysorokin force-pushed the encryption_binlog_file_metadata branch from 893967a to 044171a Compare August 3, 2026 09:32
@percona-ysorokin
percona-ysorokin merged commit 505bcad into Percona-Lab:0.4 Aug 3, 2026
15 of 16 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