fix(security): replace FNV1a and XOR placeholders with real cryptography#563
Merged
Merged
Conversation
All three security functions were explicitly marked placeholders: - hash_password(): FNV1a (no salt, deterministic, trivially reversible) - encrypt_data()/encrypt_field_data(): XOR with key (trivially breakable) - rotate_encryption_keys(): no-op returning true When OpenSSL is available (__has_include<openssl/evp.h>): - PBKDF2-HMAC-SHA256 for password hashing (16-byte salt, 100k iterations) - AES-256-GCM for data/field encryption (12-byte IV, 16-byte auth tag) - Actual key rotation: decrypt all credentials, re-encrypt with new key When OpenSSL is absent: - Keep placeholders with stderr warning on first use - Tag output format (fnv1a:, xor:, aes:) for migration detection - Legacy format transparently decoded in decrypt functions Closes #562
Contributor
Benchmark ResultsNo comparison reports available. Baseline may not be established yet. |
…lude __has_include(<openssl/evp.h>) detects header presence but not library link availability, causing linker errors in CI where OpenSSL headers are installed but -lssl -lcrypto are not linked. - Add find_package(OpenSSL QUIET) to root CMakeLists.txt - Add target_compile_definitions(DATABASE_HAS_OPENSSL) and target_link_libraries(OpenSSL::Crypto) in database/CMakeLists.txt - Change source from __has_include to #ifdef DATABASE_HAS_OPENSSL
OpenSSL::Crypto as a PRIVATE link dependency gets recorded in the CMake export target file. Consumers that don't find_package(OpenSSL) then fail at CMake generate step. Wrap with $<BUILD_INTERFACE:> to exclude from the exported target properties.
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.
Summary
fnv1a:/xor:prefix detection)Related Issues
Closes #562
Files Changed
database/security/secure_connection.cppTest Plan
fnv1a:passwords verified correctlyxor:prefix) decrypted correctlycredential_test,data_masking_testpass