|
QGroundControl
Ground Control Station for MAVLink Drones
|
Bag of named MAVLink signing keys; correct key per vehicle is auto-detected from incoming signed packets. More...
#include <MAVLinkSigningKeys.h>
Inheritance diagram for MAVLinkSigningKeys:
Collaboration diagram for MAVLinkSigningKeys:Signals | |
| void | keysChanged () |
| void | keyUsageChanged () |
Public Member Functions | |
| MAVLinkSigningKeys (QObject *parent=nullptr) | |
| ~MAVLinkSigningKeys () override | |
| Q_INVOKABLE bool | addKey (const QString &name, const QString &passphrase) |
| Q_INVOKABLE bool | addRawKey (const QString &name, const QString &hexKey) |
| Q_INVOKABLE void | removeKey (const QString &name) |
| Q_INVOKABLE void | removeAllKeys () |
| Used by tests and full reset. | |
| 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). | |
| MAVLinkSigningKey * | keyAt (int index) const |
| Key entry at the given index, or nullptr if invalid. | |
| std::optional< MAVLinkSigning::SigningKey > | keyBytesByName (const QString &name) const |
| Key bytes for the key with the given name, or nullopt if not found. | |
| uint64_t | lastTimestamp (const QString &name) const |
Last persisted signing timestamp for name, or 0 if unknown / no entry. | |
| void | recordTimestamp (const QString &name, uint64_t ts) |
Update in-memory + persisted last-timestamp for name. Monotonic — older values are dropped. | |
| void | recordTimestamps (const QHash< QString, uint64_t > &batch) |
| Batch update with single QSettings + sync; per-entry monotonic guard still applies. | |
| void | flushAllTimestamps () |
| Walk every signing channel and persist its current timestamp under the active key's 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 name. | |
| QmlObjectListModel * | keys () const |
| int | keyUsageRevision () const |
Static Public Member Functions | |
| static MAVLinkSigningKeys * | instance () |
| static Q_INVOKABLE QString | generateRandomHexKey () |
| Cryptographically random 64-char hex string (32 bytes). | |
| static void | setPbkdf2IterationsForTesting (int iterations) |
| Test-only override for PBKDF2 iteration count; 0 restores production default. | |
Friends | |
| class | SigningTest |
Bag of named MAVLink signing keys; correct key per vehicle is auto-detected from incoming signed packets.
Definition at line 49 of file MAVLinkSigningKeys.h.
|
explicit |
Definition at line 44 of file MAVLinkSigningKeys.cc.
References flushAllTimestamps(), MultiVehicleManager::instance(), MultiVehicleManager::vehicleAdded(), and MultiVehicleManager::vehicleRemoved().
|
override |
Definition at line 70 of file MAVLinkSigningKeys.cc.
| bool MAVLinkSigningKeys::addKey | ( | const QString & | name, |
| const QString & | passphrase | ||
| ) |
Derives a 32-byte key via PBKDF2-HMAC-SHA256 with a fixed app salt — deterministic across installs so the same passphrase yields the same key on multiple GCS stations sharing one vehicle. Returns false on duplicate name, passphrase below kMinPassphraseLength, or capacity limit.
Definition at line 147 of file MAVLinkSigningKeys.cc.
References keysChanged(), MAVLinkSigning::makeSigningKey(), and QGC::secureZero().
| bool MAVLinkSigningKeys::addRawKey | ( | const QString & | name, |
| const QString & | hexKey | ||
| ) |
Add a key from raw 32-byte hex string (e.g. from a key file or shared secret). Returns false on duplicate name, malformed hex, or capacity limit.
Definition at line 174 of file MAVLinkSigningKeys.cc.
References keysChanged(), and MAVLinkSigning::makeSigningKey().
| void MAVLinkSigningKeys::flushAllTimestamps | ( | ) |
Walk every signing channel and persist its current timestamp under the active key's name.
Definition at line 317 of file MAVLinkSigningKeys.cc.
References recordTimestamps().
Referenced by MAVLinkSigningKeys().
|
static |
Cryptographically random 64-char hex string (32 bytes).
Definition at line 197 of file MAVLinkSigningKeys.cc.
|
static |
Definition at line 39 of file MAVLinkSigningKeys.cc.
Referenced by SigningController::clearSigning(), VehicleSigningController::enable(), SigningController::initSigningImmediate(), SigningController::processFrame(), and SigningController::tryBeginEnable().
| bool MAVLinkSigningKeys::isKeyInUse | ( | const QString & | name | ) | const |
True if any connected vehicle is using the key with the given name.
Definition at line 75 of file MAVLinkSigningKeys.cc.
References MultiVehicleManager::instance().
| MAVLinkSigningKey * MAVLinkSigningKeys::keyAt | ( | int | index | ) | const |
Key entry at the given index, or nullptr if invalid.
Definition at line 105 of file MAVLinkSigningKeys.cc.
References QmlObjectListModel::value().
Referenced by tryDetectKey().
| std::optional< MAVLinkSigning::SigningKey > MAVLinkSigningKeys::keyBytesByName | ( | const QString & | name | ) | const |
Key bytes for the key with the given name, or nullopt if not found.
Definition at line 113 of file MAVLinkSigningKeys.cc.
Referenced by VehicleSigningController::enable(), keyHexByName(), and tryDetectKey().
| QString MAVLinkSigningKeys::keyHexByName | ( | const QString & | name | ) | const |
Hex-encoded key bytes for export (empty if not found).
Definition at line 206 of file MAVLinkSigningKeys.cc.
References keyBytesByName(), and QGC::secureZero().
|
inline |
Definition at line 109 of file MAVLinkSigningKeys.h.
|
signal |
Referenced by addKey(), addRawKey(), removeAllKeys(), and removeKey().
|
signal |
|
inline |
Definition at line 111 of file MAVLinkSigningKeys.h.
| uint64_t MAVLinkSigningKeys::lastTimestamp | ( | const QString & | name | ) | const |
Last persisted signing timestamp for name, or 0 if unknown / no entry.
Definition at line 279 of file MAVLinkSigningKeys.cc.
Referenced by SigningController::initSigningImmediate(), and SigningController::tryBeginEnable().
| void MAVLinkSigningKeys::recordTimestamp | ( | const QString & | name, |
| uint64_t | ts | ||
| ) |
Update in-memory + persisted last-timestamp for name. Monotonic — older values are dropped.
Definition at line 312 of file MAVLinkSigningKeys.cc.
References recordTimestamps().
Referenced by SigningController::clearSigning().
| void MAVLinkSigningKeys::recordTimestamps | ( | const QHash< QString, uint64_t > & | batch | ) |
Batch update with single QSettings + sync; per-entry monotonic guard still applies.
Definition at line 285 of file MAVLinkSigningKeys.cc.
Referenced by flushAllTimestamps(), and recordTimestamp().
| void MAVLinkSigningKeys::removeAllKeys | ( | ) |
Used by tests and full reset.
Definition at line 236 of file MAVLinkSigningKeys.cc.
References QmlObjectListModel::clearAndDeleteContents(), QmlObjectListModel::count(), and keysChanged().
| void MAVLinkSigningKeys::removeKey | ( | const QString & | name | ) |
Definition at line 221 of file MAVLinkSigningKeys.cc.
References keysChanged(), and QmlObjectListModel::removeOne().
|
inlinestatic |
Test-only override for PBKDF2 iteration count; 0 restores production default.
Definition at line 150 of file MAVLinkSigningKeys.h.
| QString MAVLinkSigningKeys::tryDetectKey | ( | SigningController * | controller, |
| const mavlink_message_t & | message | ||
| ) |
Try every stored key against message's signature; on match, configures channel and returns the key name.
Definition at line 346 of file MAVLinkSigningKeys.cc.
References SigningController::channel(), SigningController::clearDetectCooldown(), QmlObjectListModel::count(), SigningChannel::detectSnapshot(), SigningController::initSigningImmediate(), SigningController::isEnabled(), MAVLinkSigning::isMessageSigned(), keyAt(), keyBytesByName(), SigningController::recordDetectMiss(), MAVLinkSigning::Strict, and MAVLinkSigning::verifySignature().
Referenced by SigningController::processFrame().
|
friend |
Definition at line 57 of file MAVLinkSigningKeys.h.