3#include <QtCore/QByteArray>
4#include <QtCore/QByteArrayView>
6#include <QtCore/QLatin1StringView>
7#include <QtCore/QObject>
8#include <QtCore/QTimer>
9#include <QtQmlIntegration/QtQmlIntegration>
26 Q_PROPERTY(QString
name READ
name CONSTANT)
30 QObject* parent =
nullptr);
33 const QString&
name()
const {
return _name; }
44 uint64_t _lastTimestamp = 0;
68 Q_INVOKABLE
bool addKey(const QString& name, const QString& passphrase);
72 Q_INVOKABLE
bool addRawKey(const QString& name, const QString& hexKey);
77 Q_INVOKABLE
void removeKey(const QString& name);
83 Q_INVOKABLE
bool isKeyInUse(const QString& name) const;
86 Q_INVOKABLE QString
keyHexByName(const QString& name) const;
120 bool _validateNewKey(
const QString& name)
const;
122 void _connectVehicle(
Vehicle* vehicle);
123 void _disconnectVehicle(
Vehicle* vehicle);
124 QHash<QString, uint64_t> _snapshotAllTimestamps()
const;
127 QHash<QString, MAVLinkSigningKey*> _keyIndex;
128 int _keyUsageRevision = 0;
129 QTimer* _timestampFlushTimer =
nullptr;
131 static constexpr QLatin1StringView kSettingsGroup = QLatin1StringView(
"MAVLinkSigningKeys");
132 static constexpr QLatin1StringView kManifestKey = QLatin1StringView(
"manifest");
133 static constexpr QLatin1StringView kKeySubgroup = QLatin1StringView(
"keys");
134 static constexpr QLatin1StringView kTimestampSubgroup = QLatin1StringView(
"timestamps");
135 static constexpr int kTimestampFlushIntervalMs = 5000;
139 static constexpr QByteArrayView kPbkdf2Salt = QByteArrayView(
"QGroundControl-MAVLink-Signing-v1");
141 static constexpr int kPbkdf2Iterations = 600'000;
144 static constexpr int kMaxKeys = 64;
146 static constexpr int kMinPassphraseLength = 8;
153 static int _effectivePbkdf2Iterations() {
154 return _pbkdf2IterationsOverride > 0 ? _pbkdf2IterationsOverride : kPbkdf2Iterations;
156 static inline int _pbkdf2IterationsOverride = 0;
struct __mavlink_message mavlink_message_t
A single named signing key entry.
const MAVLinkSigning::SigningKey & keyBytes() const
void setLastTimestamp(uint64_t ts)
const QString & name() const
~MAVLinkSigningKey() override
uint64_t lastTimestamp() const
10µs ticks since 2015-01-01; persisted for forward-progress across restarts with skewed clock.
Bag of named MAVLink signing keys; correct key per vehicle is auto-detected from incoming signed pack...
static MAVLinkSigningKeys * instance()
std::optional< MAVLinkSigning::SigningKey > keyBytesByName(const QString &name) const
Key bytes for the key with the given name, or nullopt if not found.
void flushAllTimestamps()
Walk every signing channel and persist its current timestamp under the active key's name.
MAVLinkSigningKey * keyAt(int index) const
Key entry at the given index, or nullptr if invalid.
void recordTimestamps(const QHash< QString, uint64_t > &batch)
Batch update with single QSettings + sync; per-entry monotonic guard still applies.
int keyUsageRevision() const
Q_INVOKABLE bool addRawKey(const QString &name, const QString &hexKey)
Q_INVOKABLE void removeAllKeys()
Used by tests and full reset.
void recordTimestamp(const QString &name, uint64_t ts)
Update in-memory + persisted last-timestamp for name. Monotonic — older values are dropped.
Q_INVOKABLE void removeKey(const QString &name)
QString tryDetectKey(SigningController *controller, const mavlink_message_t &message)
Try every stored key against message's signature; on match, configures channel and returns the key na...
Q_INVOKABLE bool addKey(const QString &name, const QString &passphrase)
Q_INVOKABLE bool isKeyInUse(const QString &name) const
True if any connected vehicle is using the key with the given name.
Q_INVOKABLE QString keyHexByName(const QString &name) const
Hex-encoded key bytes for export (empty if not found).
uint64_t lastTimestamp(const QString &name) const
Last persisted signing timestamp for name, or 0 if unknown / no entry.
static void setPbkdf2IterationsForTesting(int iterations)
Test-only override for PBKDF2 iteration count; 0 restores production default.
static Q_INVOKABLE QString generateRandomHexKey()
Cryptographically random 64-char hex string (32 bytes).
QmlObjectListModel * keys() const
Owns MAVLink signing state and the deferred-confirmation state machine for one LinkInterface.
std::array< uint8_t, kSigningKeySize > SigningKey
std::array avoids QByteArray COW detach so secureZero() actually wipes the bytes.
static constexpr int kSigningKeySize