Skip to content

Verify the ST 0601 checksum (closes #58) - #59

Open
Mattbusel wants to merge 1 commit into
paretech:masterfrom
Mattbusel:checksum-verify
Open

Mattbusel wants to merge 1 commit into
paretech:masterfrom
Mattbusel:checksum-verify

Conversation

@Mattbusel

Copy link
Copy Markdown

Closes #58.

StreamParser never checked the Checksum item (tag 1), so a packet with a bad length or corrupted bytes decoded as if it were fine. That is what cost two days in the issue.

  • StreamParser(source, verify_checksum=True) checks each UAS Local Set packet against its checksum as it was received, and skips packets that fail with a UserWarning. The default is False, so nothing changes for current users.
  • UASLocalMetadataSet.checksum_valid() checks a parsed packet.
  • KLVParser keeps the raw BER length bytes of the last item, so a packet sent with a long-form length still verifies. (bytes(packet) re-encodes the length in short form, which changes the sum.)

One thing this turned up: data/DynamicConstantMISMMSPacketData.bin still carries the checksum from the ST 0902.5 example (0xAA43), but its content sums to 0x3E1E. The comment in test_common.py says the file was patched; only the content was. I left the file as is and use it as the bad-checksum case. Happy to patch its last two bytes instead if you prefer.

Tests: 4 new tests in test/test_streamparser.py (valid packet, stale sample, bit flip skipped with a warning, long-form length). python -m unittest discover -s test -t .: 120 tests pass.

I ran into this while checking my Rust KLV crate (misb) against klvdata on the public Day Flight and Night Flight samples. klvdata matched on all 641 values; the stale checksum was the only difference.

StreamParser(source, verify_checksum=True) checks each UAS Local Set
packet against its Checksum item (tag 1) as received and skips packets
that fail, with a warning. UASLocalMetadataSet.checksum_valid() checks a
parsed packet. Default behavior is unchanged.

KLVParser keeps the raw BER length bytes of the last item, so packets
sent with a long-form length still verify.

This branch has not been deployed

No deployments
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.

MISB 0601 local set stream processing does not check the LS packet checksum

1 participant