Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RAS-A Signed Packet Support #31

Merged
merged 10 commits into from
Jan 24, 2024
Merged

Conversation

stuart-auterion
Copy link
Contributor

I expect this one to be controversial... but here goes. QGC-Gov is required to be RAS-A compliant. This means we should support the standard as written, and as "THE" RAS-A ground station, we need to include even the optional parts of RAS-A. I understand there are differing opinions about the usefulness of the signed packets portions of RAS-A, but regardless it is an official part of the standard. Since we are using libmav to handle all our low-level MAVlink packet encoding/decoding, we need libmav to support this.

Happy to provide details on or discuss design choices here if required. I can also walk through testing steps used to validate this. Or happy to discuss any of the above in more detail.

@ThomasDebrunner
Copy link
Contributor

Thanks, looks fine

  • I understand this doesn't allow for actually checking signatures of incoming messages?
  • When you set "sign" to true in "finalize", it doesn't actually sign the message? This and the key should just be part of "finalize", otherwise the function loses its meaning, and you potentially end up with a bad state
  • Can you add unit tests for all of this?

@stuart-auterion
Copy link
Contributor Author

  • Message::validate() performs a check on the signature of incoming messages.
  • Yeah, I definitely see your point. I was interpreting "finalize" as "make the message header". And since the header is a different part of the message than the signature, it made sense to me to do the signing separately. Also, if we're doing the signing in finalize(), I'd need to pass both the timestamp and key in as arguments, which seems like a rather cumbersome amount of args for one function. But its feasible. Would you prefer that?
  • I can indeed! I'll look into it!

@stuart-auterion
Copy link
Contributor Author

Hope you don't mind, I also added a note to the readme about how to run the tests. I've never used doctest before, and took me a minute to figure out how to actually do it, so hopefully this can save someone else time in the future.

include/mav/Message.h Outdated Show resolved Hide resolved
include/mav/Message.h Outdated Show resolved Hide resolved
include/mav/Message.h Show resolved Hide resolved
include/mav/Message.h Show resolved Hide resolved
include/mav/Message.h Outdated Show resolved Hide resolved
include/mav/Message.h Show resolved Hide resolved
include/mav/Network.h Show resolved Hide resolved
include/mav/Network.h Show resolved Hide resolved
include/mav/Network.h Show resolved Hide resolved
include/mav/Network.h Outdated Show resolved Hide resolved
@ThomasDebrunner
Copy link
Contributor

If you have signing enabled on a NetworkRuntime, would ever not want to validate the incoming messages? In case it is enabled, we should always validate and reject bad signatures.

@stuart-auterion
Copy link
Contributor Author

stuart-auterion commented Dec 6, 2023

If you have signing enabled on a NetworkRuntime, would ever not want to validate the incoming messages? In case it is enabled, we should always validate and reject bad signatures.

Depends. The standard is inspecific. To quote RAS-A:

Accepting Unsigned Packets

MAVLink libraries should provide a mechanism that allows a system to conditionally accept unsigned packets.

...

Accepting Incorrectly Signed Packets

MAVLink libraries should provide a mechanism that allows a system to conditionally accept incorrectly signed packets.

So the rejection needs to be done at the application level and it is not a decision libmav can make. You could make an argument that libmav should always at least try to validate? We could perhaps have libmav always do the calculation and then set a field on the message if invalid, and then the application could choose to check the validity field if it wants.

Copy link

sonarqubecloud bot commented Dec 8, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 49 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@stuart-auterion
Copy link
Contributor Author

stuart-auterion commented Jan 11, 2024

@ThomasDebrunner Is there some way you can configure SonarCloud to ignore include/mav/picosha/*? I updated gcovr's config to ignore it in the coverage report, but SonarCloud still sees it as a changed file and reports 0%, blocking this PR.

@ThomasDebrunner
Copy link
Contributor

ThomasDebrunner commented Jan 22, 2024

@stuart-auterion Just rebase this to main - let's see what sonarcloud says. I guess it should be possible to exclude picohash. I think it looks good outside of that

@ThomasDebrunner ThomasDebrunner force-pushed the qgcgov-fixes-signed-packets branch from 99b4b64 to fb34435 Compare January 22, 2024 14:26
stuart-auterion and others added 6 commits January 22, 2024 15:29
 + Add (and use) constants for packet signature field sizes
 + Rework Network API into two simpler functions for enable/disable signing
 + Remove individual Message sign() function and integrate into finalize()
 + Add errors when accessing the signature of an unfinalized message
 + Add a default timestamp function
 + Update unit tests accordingly
@ThomasDebrunner ThomasDebrunner force-pushed the qgcgov-fixes-signed-packets branch from fb34435 to 935ae37 Compare January 22, 2024 14:30
@stuart-auterion
Copy link
Contributor Author

Hmmm, looks like its still tracking coverage on picosha.

Copy link

@jacobbandyk jacobbandyk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! Thanks for adding the docs on running the unit tests as well.

@jacobbandyk
Copy link

Hmmm, looks like its still tracking coverage on picosha.

Although, this is still an issue.

@ThomasDebrunner
Copy link
Contributor

Yeah, I asked Jakob, maybe he knows why

sonar-project.properties Outdated Show resolved Hide resolved
@stuart-auterion
Copy link
Contributor Author

Aw bummer. Looks like I'm still 0.8% short on new code coverage. I'll address that when I can.

Thanks for fixing sonarcloud!

@stuart-auterion
Copy link
Contributor Author

@ThomasDebrunner should be ready now.
Thanks for the patience and help getting this PR in a good state.

@ThomasDebrunner ThomasDebrunner merged commit 903a3f9 into main Jan 24, 2024
4 checks passed
@ThomasDebrunner
Copy link
Contributor

Merged, thanks @stuart-auterion

@stuart-auterion stuart-auterion deleted the qgcgov-fixes-signed-packets branch March 1, 2024 22:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants