2

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!

Oscar_Mariani
  • 728
  • 3
  • 9
  • 22

3 Answers3

3

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?

Mark Adler
  • 101,978
  • 13
  • 118
  • 158
  • links [should never be the only information in an answer](http://meta.stackexchange.com/questions/8231/are-answers-that-just-contain-links-elsewhere-really-good-answers) – codeling Jan 14 '14 at 14:55
  • @codeling: It's not the only information in the answer. The answer is comparing new to old. He already _has_ a test vector generator with the old algorithm. The link is bonus information. – Mark Adler Nov 25 '15 at 01:03
  • Hm, when i commented, the link was still the only information, see the history. But actually the link seems to me exactly what OP was asking for, so my today self would be ok with that answer now ;). wasn't me who downvoted by the way. – codeling Nov 26 '15 at 13:33
  • 1
    This may, indeed, be a catalog of CRC implementations, but not of *test vectors*. – Anton Samsonov Oct 01 '16 at 10:11
  • @AntonSamsonov Each definition has one test vector. The check value is that definition's CRC of the nine-byte string "123456789". The OP asked for a test vector for CRC32 implementations. – Mark Adler Oct 01 '16 at 20:05
1

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.

Anton Samsonov
  • 1,380
  • 17
  • 34
1

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

There are some tests in zlib-ng too:

https://github.com/zlib-ng/zlib-ng/blob/develop/test/crc32_test.c

Nathan Moinvaziri
  • 5,506
  • 4
  • 29
  • 30