59#if __has_include(<openssl/evp.h>)
60#include <openssl/evp.h>
61#include <openssl/rand.h>
62#include <openssl/err.h>
63#include <openssl/opensslv.h>
64#define LOGGER_HAS_OPENSSL_CRYPTO 1
154 static constexpr uint32_t kMagic = 0x454E4352;
155 static constexpr uint8_t kVersion = 1;
156 static constexpr size_t kIvSize = 16;
157 static constexpr size_t kTagSize = 16;
159 uint32_t magic = kMagic;
160 uint8_t version = kVersion;
162 uint16_t reserved = 0;
163 uint32_t original_length = 0;
164 uint32_t encrypted_length = 0;
165 std::array<uint8_t, kIvSize> iv{};
166 std::array<uint8_t, kTagSize> tag{};
209 std::unique_ptr<log_writer_interface> wrapped,
250 uint64_t get_entries_encrypted()
const;
256 std::chrono::system_clock::time_point get_last_key_rotation()
const;
267 const std::vector<uint8_t>& encrypted_data,
279 const std::string& plaintext,
280 std::vector<uint8_t>& output
294 bool should_rotate_key()
const;
302#ifdef LOGGER_HAS_OPENSSL_CRYPTO
312 void cleanup_cipher_context();
318 std::atomic<uint64_t> entries_encrypted_{0};
320 std::atomic<bool> is_initialized_{
false};
322#ifdef LOGGER_HAS_OPENSSL_CRYPTO
323 EVP_CIPHER_CTX* cipher_ctx_ =
nullptr;
370 const std::filesystem::path& input_path,
371 const std::filesystem::path& output_path
381 const std::filesystem::path& input_path,
382 std::function<
void(
const std::string&)> callback
388#ifdef LOGGER_HAS_OPENSSL_CRYPTO
389 EVP_CIPHER_CTX* cipher_ctx_ =
nullptr;
Abstract base class for decorator pattern log writers.
Decorator that encrypts log data before writing.
encrypted_writer & operator=(encrypted_writer &&)=delete
encrypted_writer & operator=(const encrypted_writer &)=delete
std::chrono::system_clock::time_point last_key_rotation_
encrypted_writer(const encrypted_writer &)=delete
encrypted_writer(encrypted_writer &&)=delete
encryption_config config_
Utility class for decrypting encrypted log files.
log_decryptor(log_decryptor &&)=delete
log_decryptor & operator=(log_decryptor &&)=delete
security::secure_key key_
log_decryptor(const log_decryptor &)=delete
log_decryptor & operator=(const log_decryptor &)=delete
RAII wrapper for encryption keys with secure memory management.
Base class for decorator pattern writers.
Error codes specific to the logger system.
DLL export/import macros for logger_system shared library support.
#define LOGGER_SYSTEM_API
encryption_algorithm
Supported encryption algorithms for log encryption.
@ aes_256_gcm
AES-256 in GCM mode (recommended)
@ aes_256_cbc
AES-256 in CBC mode (legacy support)
@ chacha20_poly1305
ChaCha20-Poly1305 (modern alternative)
RAII wrapper for encryption keys with secure memory management.
Configuration for encrypted_writer.
bool rotate_iv_per_entry
Whether to generate unique IV for each log entry.
security::secure_key key
Encryption key (must be 32 bytes for AES-256)
encryption_config(encryption_config &&) noexcept=default
encryption_algorithm algorithm
Encryption algorithm to use.
std::filesystem::path key_storage_base
Allowed base directory for key storage.
std::optional< std::chrono::hours > key_rotation_interval
Optional key rotation interval.
encryption_config(encryption_algorithm algo, security::secure_key encryption_key)
Constructor for encryption_config.
std::filesystem::path key_rotation_path
Path for key rotation (new keys saved here)
Represents a single log entry with all associated metadata.