Skip to content

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

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

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

Conversation

@percona-ysorokin

Copy link
Copy Markdown
Collaborator

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

'binsrv::storage::generate_binlog_encryption_record()' method reworked with proper 'opensslpp' cryptography primitives. Removed all remainders of fake key generation / encryption.

Implemented proper binlog data encryption before writing: instead of calls to 'backend_->write_data_to_stream()' we now have a new method 'storage::write_data_to_stream()' that decides whether encryption is needed or not.

Currently we stick to the strategy of never holding file keys in memory in plaintext. Instead, 'binsrv::storage::storage::binlog_encryption_record' holds them in encrypted form and we temporarily restore them on each write. This may cause some additional CPU time spent on decryption but it is expected to be insignificant in comparison to IO operations.

'opensslpp::cipher_context' extended with one new method 'extract_updated_iv()' that helps to identify the value of the updated IV (original IV + block counter) after some calls to the 'update()' method have been made. This function helps with resuming streaming encryption (for CTR modes, for instance).

'opensslpp::cipher_context' extended with one more static method 'create_with_offset()' that helps to create a context that would have internal state identical as if it had already processed 'offset' bytes. Again, this function helps with streaming operations.

This commits also adds a list of TODO items that suggest to add more diagnostics for key / key combinations validation.

Added new 'CipherContextUpdatedIVCTR' boost test case to the 'cipher_context.cpp' (BOOST_TEST_MODULE CipherContextTests) module that checks that 'opensslpp::cipher_context::create_with_offset()' method produces expected results.

…t 6)

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

'binsrv::storage::generate_binlog_encryption_record()' method reworked with proper
'opensslpp' cryptography primitives. Removed all remainders of fake key generation /
encryption.

Implemented proper binlog data encryption before writing: instead of calls to
'backend_->write_data_to_stream()' we now have a new method
'storage::write_data_to_stream()' that decides whether encryption is needed or not.

Currently we stick to the strategy of never holding file keys in memory in plaintext. Instead, 'binsrv::storage::storage::binlog_encryption_record' holds them in encrypted
form and we temporarily restore them on each write. This may cause some additional
CPU time spent on decryption but it is expected to be insignificant in comparison to IO
operations.

'opensslpp::cipher_context' extended with one new method 'extract_updated_iv()' that
helps to identify the value of the updated IV (original IV + block counter) after some
calls to the 'update()' method have been made. This function helps with resuming
streaming encryption (for CTR modes, for instance).

'opensslpp::cipher_context' extended with one more static method
'create_with_offset()' that helps to create a context that would have internal state
identical as if it had already processed 'offset' bytes. Again, this function helps with
streaming operations.

This commits also adds a list of TODO items that suggest to add more diagnostics for
key / key combinations validation.

Added new 'CipherContextUpdatedIVCTR' boost test case to the 'cipher_context.cpp'
(BOOST_TEST_MODULE CipherContextTests) module that checks that
'opensslpp::cipher_context::create_with_offset()' method produces expected results.
@percona-ysorokin
percona-ysorokin merged commit 8670c19 into Percona-Lab:0.4 Aug 6, 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