Skip to content

PS-11106 [8.4] Component Percona keyring encrypted file#6023

Open
catalinbp wants to merge 2 commits into
percona:8.4from
catalinbp:PS-11106
Open

PS-11106 [8.4] Component Percona keyring encrypted file#6023
catalinbp wants to merge 2 commits into
percona:8.4from
catalinbp:PS-11106

Conversation

@catalinbp

Copy link
Copy Markdown
Contributor

No description provided.

- created component_percona_keyring_encrypted_file based on
component_keyring_file
- cmake flag: WITH_COMPONENT_PERCONA_KEYRING_ENCRYPTED_FILE
@catalinbp catalinbp requested a review from jankowsk June 22, 2026 08:54

@jankowsk jankowsk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

review in progress, initial comments

Comment thread components/keyrings/common/encryption/aes.cc
Comment thread components/keyrings/common/utils/utils.cc Outdated
Comment thread components/keyrings/percona_keyring_encrypted_file/backend/backend.h Outdated
if (!iv || !get_random_data(iv, k_iv_size)) return true;

// Generate random number of iterations
uint32_t iterations = get_random_iterations(600000);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that random number of iterations increases security especially when this number is known (written alongside the encrypted data). This parameter just makes the encryption/decryption iteration times longer (also the attack time). IMHO it even could be a config value so the user defines own balance between security and efficiency.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've set the number of iterations to a fixed number for now. I'm think about adding a config parameter

- New PBKDF2-based encrypt/decrypt API (aes.cc): Added
aes_encrypt_pbkdf2 and aes_decrypt_pbkdf2 functions that derive a
256-bit AES key from a password using PKCS5_PBKDF2_HMAC (SHA-256).
Refactored the internal EVP encrypt/decrypt logic into private helpers
to avoid code duplication.
- Encrypted backend (backend.cc): Renamed Keyring_file_backend to
Keyring_encrypted_file_backend and wired in password-based encryption.
On write, generates a random salt, IV, and iteration count; on read,
parses v1 on-disk header ([version:1][salt:32][iterations:4
BE][iv:16][ciphertext]) and decrypts before JSON parsing.
- Password config options (config.cc): The component configuration now
requires exactly one of password (inline) or password_file (path to a
file containing the password). Validation errors are emitted for
missing, empty, or conflicting combinations. The
keyring_component_status table reports <SET> or <NONE> for the password
field.

@jankowsk jankowsk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
Please, squash the commits.

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.

2 participants