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

hash/crc32: wrong hash code for CRC32-Q in documented example #65200

Open
larschri opened this issue Jan 22, 2024 · 1 comment
Open

hash/crc32: wrong hash code for CRC32-Q in documented example #65200

larschri opened this issue Jan 22, 2024 · 1 comment
Labels
Documentation NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@larschri
Copy link

larschri commented Jan 22, 2024

Go version

not relevant

Output of go env in your module/workspace:

not relevant

What did you do?

The example on https://pkg.go.dev/hash/crc32#example-MakeTable uses the polynomial for CRC32-Q when producing a checksum, so it looks like it should be producing the correct CRC32-Q checksum.

What did you see happen?

The produced checksum value - 2964d064 - is not correct.

The reason is that hash/crc32 only support some specific variations of crc32 algorithms, and CRC32-Q requires other settings than those implemented in hash/crc32. There is a proposal to support other variants in #60992 .

What did you expect to see?

The expected output when computing the CRC32-Q checksum for "Hello world" is "0xA790E213", as here: https://crccalc.com/?crc=Hello+world&method=CRC-32Q&datatype=ascii&outtype=0

The simplest fix here is to remove the example, and I think that would be an improvement. It is better to not provide a wrong example.

It would be more helpful to give some hints about the pitfalls, though.

I have attempted to fix the example on https://go.dev/play/p/_avQEOSV2uJ, but maybe this is too complicated to put in the standard documentation.

@cherrymui
Copy link
Member

cc @golang/security

@cherrymui cherrymui added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jan 23, 2024
@cherrymui cherrymui added this to the Backlog milestone Jan 23, 2024
@cherrymui cherrymui changed the title hash/crc32: Wrong hash code for CRC32-Q in documented example hash/crc32: wrong hash code for CRC32-Q in documented example Jan 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

3 participants