2
votes

I had to substitute the CRC32 implementation on the system I am working on, the algorithm that was implemented before used a size 256 look up table and that was too big to use in the boot loader. The new algorithm I've implemented uses a size 16 look up table.

I am using the same polynomial as before, but the results are different. Online calculators throw even more random results and most of them are not very clear on what they are doing, ie which polynomial they are using, what format is the input data or what is the initial crc value.

Does anyone know where can I find a reliable, standardised test vector for CRC32 implementations?

Thanks!

3

3 Answers

3
votes

Yes, this catalog of CRCs. Included with each CRC definition is a check value — which is that CRC's output for the nine-byte string “123456789” input in ASCII / UTF-8. For example, CRC-32("123456789", 9) = 0xcbf43926.

Why don't you simply compare your new implementation to your old implementation?

1
votes

Not standardised in any kind, — just gathered for convenience:

// Trivial one.
UINT32_C(0x00000000), ""

// Source: https://rosettacode.org/wiki/CRC-32
UINT32_C(0x414FA339), "The quick brown fox jumps over the lazy dog"

// Source: http://cryptomanager.com/tv.html
UINT32_C(0x9BD366AE), "various CRC algorithms input data"

// Source: http://www.febooti.com/products/filetweak/members/hash-and-crc/test-vectors/
UINT32_C(0x0C877F61), "Test vector from febooti.com"

What if your results do not match? Be sure to check which flavor of CRC you are implementing and comparing to, — a nice example of such digging can be found in “CRC32 Checksums; The Good, The Bad, And The Ugly” article, where it is shown that some programs may do additional processing after otherwise identical operations, like piping the length of the message through checksumming, too, which may or may not be covered in documentation.

0
votes

Ironclad repository has some test vectors which may be useful:

;;; standard tests for crc32

(:digest-test #a"" #h"00000000")
(:digest-test #a"a" #h"e8b7be43")
(:digest-test #a"abc" #h"352441c2")
(:digest-test #a"message digest" #h"20159d7f")
(:digest-test #a"abcdefghijklmnopqrstuvwxyz" #h"4c2750bd")
(:digest-test #a"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" #h"1fc2e6d2")
(:digest-test #a"12345678901234567890123456789012345678901234567890123456789012345678901234567890" #h"7ca94a72")

https://github.com/froydnj/ironclad/blob/master/testing/test-vectors/crc32.testvec