PBS-39 feature: Add binlog encryption config and keyring support (part 6) - #168
Merged
percona-ysorokin merged 1 commit intoAug 6, 2026
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.