Add S-57 exchange set integrity verification (CATALOG.031 CRC + S-63 seam)#7
Merged
Merged
Conversation
…seam) Implements GitHub issue #6. Adds a non-throwing, opt-in exchange-set verifier under EncDotNet.S57/ExchangeSets/ that mirrors the S-100 sibling's verification API: - S57VerificationOutcome enum (S-100 member names + NoChecksum / ChecksumMismatch). - S57FileVerificationResult tracking checksum and signature outcomes as independent dimensions; S57ExchangeSetVerificationResult aggregate. - IS57ExchangeSetVerifier / S57ExchangeSetVerifier validating each CATD CRCS checksum against the on-disk file via an internal CRC-32 helper. - S-63 signature SEAMS only: S63TrustAnchorOptions + IS63SignatureVerifier (SignatureOutcome defaults to NotSigned), gated on future S-63 support. - S57ExchangeSet.VerifyAsync(rootPath, ...) entry point. - xUnit tests with synthetic CATALOG.031 fixtures (no real ENC data) and a CRC-32 known-answer test; README updated. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…s real ENC Validated the verifier against a real NOAA S-57 exchange set (US5WA70M): both declared CRCS values (FD6C39B8, A8292AA7) matched the computed big-endian uppercase-hex IEEE CRC-32 exactly, empirically confirming the byte-order convention pinned by the known-answer test. Refines S57ExchangeSetVerificationResult.AllValid so a missing CRC (NoChecksum) is not counted as a failure -- CRCs are optional in S-57 and the CATALOG.031 self-reference legitimately has none -- while ChecksumMismatch/FileMissing/Error and invalid signatures still fail. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The S-57 exchange-set reader parsed each
CATALOG.031CATD record's CRC (theCRCSsubfield) but never validated it, so corrupted or tampered cell files went undetected. This implements issue #6: opt-in integrity verification of the files an exchange set references.What
Adds a non-throwing verifier under
EncDotNet.S57/ExchangeSets/whose API deliberately mirrors the siblingEncDotNet.S100exchange-set verifier, so a future S-57 to S-101 bridge can treat both schemes uniformly.S57ExchangeSet.VerifyAsync(rootPath, ...)readsCATALOG.031and validates every entry's CRC against the file on disk, returning per-file results rather than throwing.0xEDB88320) is fully implemented via an internalS57Crc32helper (no new package dependency).S57FileVerificationResult.S57VerificationOutcomereuses the S-100 member names byte-for-byte (Ok,NotSigned,SignatureInvalid,CertificateUntrusted,CertificateExpired,FileMissing,CertificateNotFound,Error) and appends checksum-specificNoChecksum/ChecksumMismatch.IS63SignatureVerifier,S63TrustAnchorOptions), defaulting toNotSigned. The full RSA/SA scheme is intentionally deferred to land alongside future S-63 decryption support.Notes for reviewers
FD6C39B8,A8292AA7) matched the computed big-endian uppercase-hex IEEE CRC-32 exactly. A known-answer test also pins the algorithm.AllValidtreatsNoChecksumas non-failing on purpose: CRCs are optional in S-57 and theCATALOG.031self-reference legitimately carries none. This is a slight, deliberate divergence from S-100'sAllValid(which requiresOkfor all) and is recorded for any future bridge unification.FILEsubfields use backslash separators (US5WA70M\US5WA70M.000); path resolution normalizes these and falls back from the short name to the long name.rootPath-based to match the existingS57ExchangeSetdesign, rather than introducing theIAssetSourceabstraction the S-100 verifier uses.Tests
10 new xUnit tests using synthetic
CATALOG.031fixtures (no real ENC data committed), including a CRC-32 known-answer test and coverage ofOk/ChecksumMismatch/NoChecksum/FileMissing, the aggregate predicates, and the signature seam. Full suite: 437/437 passing; cleannet8.0+net10.0build. README updated.Closes #6