logger: cleanup crypto defines

This commit is contained in:
Daniel Agar 2025-09-24 15:11:55 -04:00
parent 6f4e873bce
commit 469fe62166
5 changed files with 19 additions and 11 deletions

View File

@ -173,7 +173,8 @@ public:
{ {
if (_log_writer_file) { _log_writer_file->set_encryption_parameters(algorithm, key_idx, exchange_key_idx); } if (_log_writer_file) { _log_writer_file->set_encryption_parameters(algorithm, key_idx, exchange_key_idx); }
} }
#endif #endif // PX4_CRYPTO
private: private:
LogWriterFile *_log_writer_file = nullptr; LogWriterFile *_log_writer_file = nullptr;

View File

@ -40,9 +40,12 @@
#include <mathlib/mathlib.h> #include <mathlib/mathlib.h>
#include <px4_platform_common/posix.h> #include <px4_platform_common/posix.h>
#include <px4_platform_common/crypto.h>
#include <px4_platform_common/log.h> #include <px4_platform_common/log.h>
#if defined(PX4_CRYPTO)
# include <px4_platform_common/crypto.h>
#endif // PX4_CRYPTO
#if defined(__PX4_NUTTX) #if defined(__PX4_NUTTX)
# include <malloc.h> # include <malloc.h>
# include <systemlib/hardfault_log.h> # include <systemlib/hardfault_log.h>
@ -378,7 +381,7 @@ void LogWriterFile::run()
#if defined(PX4_CRYPTO) #if defined(PX4_CRYPTO)
// Split into min blocksize chunks, so it is good for encrypting in pieces // Split into min blocksize chunks, so it is good for encrypting in pieces
available = (available / _min_blocksize) * _min_blocksize; available = (available / _min_blocksize) * _min_blocksize;
#endif #endif // PX4_CRYPTO
/* if sufficient data available or partial read or terminating, write data */ /* if sufficient data available or partial read or terminating, write data */
if (available >= min_available[i] || is_part || (!buffer._should_run && available > 0)) { if (available >= min_available[i] || is_part || (!buffer._should_run && available > 0)) {
@ -408,7 +411,7 @@ void LogWriterFile::run()
} }
} }
#endif #endif // PX4_CRYPTO
int written = buffer.write_to_file(read_ptr, available, call_fsync); int written = buffer.write_to_file(read_ptr, available, call_fsync);
@ -469,7 +472,7 @@ void LogWriterFile::run()
/* close the crypto session */ /* close the crypto session */
_crypto.close(); _crypto.close();
#endif #endif // PX4_CRYPTO
break; break;
} }

View File

@ -39,7 +39,10 @@
#include <pthread.h> #include <pthread.h>
#include <drivers/drv_hrt.h> #include <drivers/drv_hrt.h>
#include <perf/perf_counter.h> #include <perf/perf_counter.h>
#include <px4_platform_common/crypto.h>
#if defined(PX4_CRYPTO)
# include <px4_platform_common/crypto.h>
#endif // PX4_CRYPTO
namespace px4 namespace px4
{ {
@ -143,7 +146,7 @@ public:
_key_idx = key_idx; _key_idx = key_idx;
_exchange_key_idx = exchange_key_idx; _exchange_key_idx = exchange_key_idx;
} }
#endif #endif // PX4_CRYPTO
private: private:
static void *run_helper(void *); static void *run_helper(void *);
@ -223,6 +226,7 @@ private:
pthread_mutex_t _mtx; pthread_mutex_t _mtx;
pthread_cond_t _cv; pthread_cond_t _cv;
pthread_t _thread = 0; pthread_t _thread = 0;
#if defined(PX4_CRYPTO) #if defined(PX4_CRYPTO)
bool init_logfile_encryption(const LogType type); bool init_logfile_encryption(const LogType type);
PX4Crypto _crypto; PX4Crypto _crypto;
@ -230,7 +234,7 @@ private:
px4_crypto_algorithm_t _algorithm; px4_crypto_algorithm_t _algorithm;
uint8_t _key_idx; uint8_t _key_idx;
uint8_t _exchange_key_idx; uint8_t _exchange_key_idx;
#endif #endif // PX4_CRYPTO
}; };

View File

@ -1310,7 +1310,7 @@ int Logger::get_log_file_name(LogType type, char *file_name, size_t file_name_si
crypto_suffix = "e"; crypto_suffix = "e";
} }
#endif #endif // PX4_CRYPTO
char *log_file_name = _file_name[(int)type].log_file_name; char *log_file_name = _file_name[(int)type].log_file_name;
@ -1419,7 +1419,7 @@ void Logger::start_log_file(LogType type)
(px4_crypto_algorithm_t)_param_sdlog_crypto_algorithm.get(), (px4_crypto_algorithm_t)_param_sdlog_crypto_algorithm.get(),
_param_sdlog_crypto_key.get(), _param_sdlog_crypto_key.get(),
_param_sdlog_crypto_exchange_key.get()); _param_sdlog_crypto_exchange_key.get());
#endif #endif // PX4_CRYPTO
if (_writer.start_log_file(type, file_name)) { if (_writer.start_log_file(type, file_name)) {
_writer.select_write_backend(LogWriter::BackendFile); _writer.select_write_backend(LogWriter::BackendFile);

View File

@ -403,7 +403,7 @@ private:
, (ParamInt<px4::params::SDLOG_ALGORITHM>) _param_sdlog_crypto_algorithm, , (ParamInt<px4::params::SDLOG_ALGORITHM>) _param_sdlog_crypto_algorithm,
(ParamInt<px4::params::SDLOG_KEY>) _param_sdlog_crypto_key, (ParamInt<px4::params::SDLOG_KEY>) _param_sdlog_crypto_key,
(ParamInt<px4::params::SDLOG_EXCH_KEY>) _param_sdlog_crypto_exchange_key (ParamInt<px4::params::SDLOG_EXCH_KEY>) _param_sdlog_crypto_exchange_key
#endif #endif // PX4_CRYPTO
) )
}; };