Skip to content

Add an ability to detect CRC32 mismatch by a checking a specific error#75

Merged
asticode merged 1 commit into
asticode:masterfrom
Vadym-Kupriyanchuk:feature/crc32-mismatch
May 5, 2026
Merged

Add an ability to detect CRC32 mismatch by a checking a specific error#75
asticode merged 1 commit into
asticode:masterfrom
Vadym-Kupriyanchuk:feature/crc32-mismatch

Conversation

@Vadym-Kupriyanchuk
Copy link
Copy Markdown
Contributor

Sometimes, when you are performing an AES128 decryption with the wrong parameters, it corrupts a PAT, and it would be helpful to detect such errors by checking ademuxer errors on a specific type: ErrCRC32Mismatch

Copy link
Copy Markdown
Owner

@asticode asticode left a comment

Choose a reason for hiding this comment

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

Thanks a lot for the PR ❤️

Since errors.Join has been added in Go 1.20, go.mod needs to be updated accordingly (replace go 1.13 with go 1.20).

Comment thread data_psi.go Outdated
PSITableIDNITVariant2 PSITableID = 0x41
)

var ErrCRC32Mismatch = errors.New("CRC32 mismatch")
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Can you prefix the error with astits: => errors.New("astits: CRC32 mismatch")

Comment thread data_psi.go Outdated
// Check CRC32
if crc32 != s.CRC32 {
err = fmt.Errorf("astits: Table CRC32 %x != computed CRC32 %x", s.CRC32, crc32)
err = errors.Join(ErrCRC32Mismatch, fmt.Errorf("table CRC32 %x != computed CRC32 %x", s.CRC32, crc32))
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Can you keep the prefix astits: in the second error message?

Comment thread data_psi_test.go Outdated
_, err := parsePSIData(astikit.NewBytesIterator(buf.Bytes()))
assert.EqualError(t, err, "astits: parsing PSI table failed: astits: Table CRC32 20 != computed CRC32 6969b13")
assert.True(t, errors.Is(err, ErrCRC32Mismatch))
assert.Equal(t, err.Error(), "astits: parsing PSI table failed: CRC32 mismatch\ntable CRC32 20 != computed CRC32 6969b13")
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

This will need to be updated since prefixes have been added

@Vadym-Kupriyanchuk Vadym-Kupriyanchuk force-pushed the feature/crc32-mismatch branch from fb13297 to 2986cc5 Compare May 5, 2026 10:10
@Vadym-Kupriyanchuk
Copy link
Copy Markdown
Contributor Author

Thanks a lot for the PR ❤️

Since errors.Join has been added in Go 1.20, go.mod needs to be updated accordingly (replace go 1.13 with go 1.20).

Fixed comments, thanks for the review

@asticode asticode merged commit 0d3beaa into asticode:master May 5, 2026
1 check passed
@asticode
Copy link
Copy Markdown
Owner

asticode commented May 5, 2026

Thanks a lot for the PR ❤️

Let me know whether you need a tag 👍

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.

2 participants