-
Notifications
You must be signed in to change notification settings - Fork 483
adler32 vs. crc32 inconsistency #122
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
Conversation
b37376ef vs ef7673b3 is endian swapped |
@sjaeckel what do you think about this? In my perl bindings I have implemented a fix like this: DCIT/perl-CryptX@b8bf151 I can prepare the same fix as a pull request if you agree. |
... c.f. #109 and I'm pretty certain that the original implementation is correct. |
If the implementation is correct than the interface must be wrong: void crc32_finish(crc32_state *ctx, void *hash, unsigned long size) I believed (but now I am in doubts) that I do not see any reason for using Other thing is that the test case (crc32_test) should be a proof-of-concept correct implementation (as it was a place where people will look to see how to use/call it). |
there's http://reveng.sourceforge.net/crc-catalogue/17plus.htm#crc.cat.crc-32 which lists check=0xcbf43926 as the checksum for the test string |
Other thing is consistency between interfaces for crc32 and adler32 Both have pretty similar: void adler32_finish(adler32_state *ctx, void *hash, unsigned long size)
void crc32_finish(crc32_state *ctx, void *hash, unsigned long size) but the interpretation of //crc32_test - expected HEX value "B37376EF"
const unsigned char crc32[] = { 0xef, 0x76, 0x73, 0xb3 };
//adler32_test - expected HEX value "1BE804BA"
const unsigned char adler32[] = { 0x1b, 0xe8, 0x04, 0xba }; for test vectors try: |
oh yeah, that's pretty bad... nonetheless I think we should keep the crc implementation and adjust the adler implementation, okay? |
I am open to both ways (changing crc32 or changing adler 32).
First of all we should define what the output is (ulong32, 4 unsigned chars
in LE order, 4 unsigned chars in BE order etc.) and change "void *"
accordingly.
BTW what is the crc32/adler32 interface in other libraries?
My patch was based on byte order of commonly used hexadecimal
representation.
|
I will try to reword the problem which should be perhaps named 1/ the API We have:
which is not what one can see on other places in libtomcrypt. My proposal:
2/ the byte order Both functions
My proposal: change |
1/ the API These API's didn't fit anywhere, that's why I broke with the old concepts. (Yes I know, I could've integrated them in the existing "hashing framework"... I can't exactly remember why I didn't do that, but I somehow still don't like the idea to have them in there... why didn't I integrate them there again...?) TBH I don't care if we write the written length back, but we definitely have to stop with that ...and 👍 for a PR "change all in- and output data pointers to void*" (just kiddin'!) I also thought about something like the following, but apparently that's not an option if you think about integrating other checksum/nc-hashing algorithms with bigger output.
2/ the byte order 👍 |
Ad 2/
So in our test suit we need:
Which can be achieved by b3109cb (== merging fix/122) Ad 1/ |
fine to rebase&merge |
in
crc32_test
we have:However the correct CRC32 from "libtomcrypt" string is IMHO
b37376ef
notef7673b3
.By which I mean the actual CRC32 implementation seems to be somehow incorrect not
crc32_test
.