Skip to content

Commit 561feaf

Browse files
committed
Add MAVLink 2 message signing support
Implement MAVLink 2 message signing with named key management, per-vehicle auto-detection from incoming signed packets, and toolbar indicator. Key features: - Named signing key storage (SHA-256 hashed passphrases) via MAVLinkSigningKeys - Auto-detect signing key from incoming signed packets (no manual setup needed) - Send SETUP_SIGNING to enable/disable signing on vehicles - Toolbar indicator showing signing status with full key management UI - Shared SigningKeyManager QML component for settings and indicator - Track active key name per vehicle with proper signal emission Includes unit tests (SigningTest: 5 tests) and integration tests (MockLinkSigningTest: 3 tests) with QSignalSpy verification. Also renames docs/settings_view/mavlink.md to telemetry.md to match current UI naming. Fixes #14160
1 parent 3c44d4a commit 561feaf

37 files changed

Lines changed: 1021 additions & 149 deletions
6.02 KB
Loading
259 KB
Loading

docs/en/SUMMARY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
- [General](qgc-user-guide/settings_view/general.md)
5454
- [CSV Logging](qgc-user-guide/settings_view/csv.md)
5555
- [Offline Maps](qgc-user-guide/settings_view/offline_maps.md)
56-
- [MAVLink](qgc-user-guide/settings_view/mavlink.md)
56+
- [Telemetry](qgc-user-guide/settings_view/telemetry.md)
5757
- [Console Logging](qgc-user-guide/settings_view/console_logging.md)
5858
- [Virtual Joystick (PX4)](qgc-user-guide/settings_view/virtual_joystick.md)
5959
- [Analyze](qgc-user-guide/analyze_view/index.md)

docs/en/qgc-user-guide/fly_view/fly_view_toolbar.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,17 @@ The Gimbal indicator is shown when the vehicle supports the [MAVLink Gimbal Prot
101101

102102
For VTOL vehicles, a VTOL transition status indicator is shown when applicable. It indicates the current VTOL mode/state and provides transition-related status information.
103103

104+
### MAVLink Signing <img src="../../../assets/fly/toolbar/signing_indicator.jpg" alt="MAVLink Signing indicator" style="height: 1.15em; vertical-align: text-bottom;" />
105+
106+
The MAVLink Signing indicator appears when signing keys have been configured (see [MAVLink 2 Signing](../settings_view/telemetry.md#signing)).
107+
It shows a lock icon that indicates whether MAVLink 2 message signing is active on the current vehicle connection:
108+
109+
- **Locked (green):** Signing is active — the vehicle's incoming packets matched a stored key, or a key was manually enabled.
110+
- **Unlocked:** Signing is not active on the current connection.
111+
112+
The dropdown shows the signing status, the name of the active key (if any), and the number of saved keys.
113+
Expanding the indicator provides full key management: you can enable a key on the vehicle, disable the active key, delete unused keys, or add new keys.
114+
104115
### Multi-Vehicle Selector <img src="../../../assets/fly/toolbar/multi_vehicle_indicator.png" alt="Multi-Vehicle indicator" style="height: 1.15em; vertical-align: text-bottom;" />
105116

106117
The Multi-Vehicle selector appears when more than one vehicle is connected. It allows you to quickly switch the active vehicle from the toolbar.

docs/en/qgc-user-guide/plan_view/plan_view.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ If a failure occurs you should see a status message in the QGC UI similar to:
185185

186186
> Mission transfer failed. Retry transfer. Error: Mission write mission count failed, maximum retries exceeded.
187187
188-
The loss rate for your link can be viewed in [Settings View > MAVLink](../settings_view/mavlink.md).
188+
The loss rate for your link can be viewed in [App Settings > Telemetry](../settings_view/telemetry.md).
189189
The loss rate should be in the low single digits (i.e. maximum of 2 or 3):
190190

191191
- A loss rate in the high single digits can lead to intermittent failures.

docs/en/qgc-user-guide/settings_view/settings_view.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ You can switch between the various settings options by clicking the buttons in t
1717
**[Offline Maps](offline_maps.md)**
1818
<br>Allows you to cache maps for use while you have no Internet connection.
1919

20-
**[MAVLink](mavlink.md)**
20+
**[Telemetry](telemetry.md)**
2121
<br>Settings associated with the MAVLink connection to a vehicle.
2222

2323
**[Console](console_logging.md)**

docs/en/qgc-user-guide/settings_view/mavlink.md renamed to docs/en/qgc-user-guide/settings_view/telemetry.md

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
# MAVLink Settings
1+
# Telemetry Settings
22

3-
The MAVLink settings (**SettingsView > MAVLink**) allow you to configure options and view information specific to MAVLink communications.
3+
The Telemetry settings (**App Settings > Telemetry**) allow you to configure options and view information specific to MAVLink communications.
44
This includes setting the MAVLink system ID for _QGroundControl_ and viewing link quality.
55

66
The screen also allows you to manage [MAVLink 2 Log Streaming](#logging) (PX4 only), including _automating log upload to Flight Review_!
77

8-
![MAVLink settings screen](../../../assets/settings/mavlink/overview.png)
9-
108
## Ground Station {#ground_station}
119

1210
This section sets the MAVLink properties and behaviour of _QGroundControl_.
@@ -30,6 +28,29 @@ A high **Loss rate** may lead to protocol errors for things like parameter downl
3028

3129
![Link Status](../../../assets/settings/mavlink/link_status.jpg)
3230

31+
## MAVLink 2 Signing {#signing}
32+
33+
The _MAVLink 2 Signing_ section (under **App Settings > Telemetry**) allows you to manage signing keys used for [MAVLink 2 message signing](https://mavlink.io/en/guide/message_signing.html).
34+
When signing is enabled, all messages between QGroundControl and the vehicle are cryptographically authenticated, preventing unauthorized command injection.
35+
36+
### Key Management
37+
38+
- **Add Key:** Enter a friendly name and a passphrase. The passphrase is SHA-256 hashed to produce the 32-byte signing key. Only the hash is stored — the passphrase is not saved.
39+
- **Enable:** Sends the signing key to the active vehicle via `SETUP_SIGNING`. The vehicle and QGroundControl will both begin signing messages. Only available when no key is currently active.
40+
- **Disable:** Disables signing on the active vehicle by sending an all-zero key. Only shown for the currently active key.
41+
- **Delete:** Removes a key from QGroundControl's key store. Not available for keys that are in use by any connected vehicle. A warning is shown because the vehicle may still have the key configured — deleting it locally means you can no longer communicate with that vehicle over a signed connection.
42+
43+
### Auto-Detection
44+
45+
When QGroundControl receives signed packets from a vehicle, it automatically tries each stored key to find a match.
46+
If a match is found, signing is automatically configured on the link — no manual action is needed.
47+
The detected key name is shown in the Signing toolbar indicator.
48+
49+
::: warning
50+
Signing keys should only be sent to the vehicle over secure (wired or encrypted) links.
51+
Anyone who intercepts the key can sign messages and send commands to the vehicle.
52+
:::
53+
3354
## MAVLink 2 Logging (PX4 only) {#logging}
3455

3556
The _MAVLink 2 Logging_ settings (PX4 only) configure real-time log streaming from PX4 to _QGroundControl_ and upload of logs to [Flight Review](https://logs.px4.io).

docs/en/qgc-user-guide/troubleshooting/parameter_download.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ At which point you will get an error stating that QGC was unable to retrieve the
77
Although you can still fly the vehicle in this state it is not recommended.
88
Also the vehicle setup pages will not be available.
99

10-
You can see the loss rate for your link from the [Settings View > MAVLink](../settings_view/mavlink.md) page.
10+
You can see the loss rate for your link from the [App Settings > Telemetry](../settings_view/telemetry.md) page.
1111
Even a loss rate in the high single digits can lead to intermittent failures of the plan protocols.
12-
Higher loss rates could leads to 100% failure.
12+
Higher loss rates could lead to 100% failure.
1313

1414
There is also the more remote possibility of either firmware or QGC bugs.
1515
To see the details of the back and forth message traffic of the protocol you can turn on [Console Logging](../settings_view/console_logging.md) for the Parameter Protocol.

src/Comms/LinkInterface.cc

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
#include "QGCApplication.h"
44
#include "QGCLoggingCategory.h"
55
#include "MAVLinkSigning.h"
6-
#include "SettingsManager.h"
7-
#include "MavlinkSettings.h"
86

97
#include <QtQml/QQmlEngine>
108

@@ -42,20 +40,16 @@ bool LinkInterface::mavlinkChannelIsSet() const
4240

4341
bool LinkInterface::initMavlinkSigning()
4442
{
45-
if (!isSecureConnection()) {
46-
auto mavlinkSettings = SettingsManager::instance()->mavlinkSettings();
47-
const QByteArray signingKeyBytes = mavlinkSettings->mavlink2SigningKey()->rawValue().toByteArray();
48-
if (MAVLinkSigning::initSigning(static_cast<mavlink_channel_t>(_mavlinkChannel), signingKeyBytes, MAVLinkSigning::insecureConnectionAccceptUnsignedCallback)) {
49-
if (signingKeyBytes.isEmpty()) {
50-
qCDebug(LinkInterfaceLog) << "Signing disabled on channel" << _mavlinkChannel;
51-
} else {
52-
qCDebug(LinkInterfaceLog) << "Signing enabled on channel" << _mavlinkChannel;
53-
}
54-
} else {
55-
qCWarning(LinkInterfaceLog) << "Failed To enable Signing on channel" << _mavlinkChannel;
56-
// FIXME: What should we do here?
57-
return false;
58-
}
43+
// Always clear any prior signing state on the channel to avoid stale
44+
// mavlink_status_t::signing from a previous connection on this channel.
45+
// For insecure connections the correct key will be auto-detected from
46+
// incoming signed packets via MAVLinkSigning::tryDetectKey().
47+
if (MAVLinkSigning::initSigning(static_cast<mavlink_channel_t>(_mavlinkChannel), QByteArrayView(), nullptr)) {
48+
qCDebug(LinkInterfaceLog) << "Signing cleared on channel" << _mavlinkChannel
49+
<< (isSecureConnection() ? "(secure)" : "(will auto-detect)");
50+
} else {
51+
qCWarning(LinkInterfaceLog) << "Failed to initialise signing on channel" << _mavlinkChannel;
52+
return false;
5953
}
6054

6155
return true;

src/Comms/LinkManager.cc

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -785,20 +785,6 @@ bool LinkManager::isLinkUSBDirect(const LinkInterface *link)
785785
return false;
786786
}
787787

788-
void LinkManager::resetMavlinkSigning()
789-
{
790-
// Make a copy under mutex protection to avoid holding lock during signing initialization
791-
QList<SharedLinkInterfacePtr> links;
792-
{
793-
QMutexLocker locker(&_linksMutex);
794-
links = _rgLinks;
795-
}
796-
797-
for (const SharedLinkInterfacePtr &sharedLink: links) {
798-
sharedLink->initMavlinkSigning();
799-
}
800-
}
801-
802788
#ifndef QGC_NO_SERIAL_LINK // Serial Only Functions
803789

804790
void LinkManager::_filterCompositePorts(QList<QGCSerialPortInfo> &portList)

0 commit comments

Comments
 (0)