-2

I did explore Crcmod python library but couldnt use it as my gen poly- 0x1EDC6F41 is not considered a 32 bit poly :( Is there a way to tweak it or any other python lib that I can use to do this?

Name : "CRC-32C"

Width : 32

Poly : 1EDC6F41h

Init : FFFFFFFFh

RefIn : True

RefOut : True

XorOut : FFFFFFFFh

Check : E3069283h

Here is what I tried-

import crcmod
f = crcmod.mkCrcFun(0x1EDC6F41)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python27\Lib\site-packages\crcmod\crcmod.py", line 281, in mkCrcFun
    (sizeBits, initCrc, xorOut) = _verifyParams(poly, initCrc, xorOut)
  File "C:\Python27\Lib\site-packages\crcmod\crcmod.py", line 405, in _verifyParams
    sizeBits = _verifyPoly(poly)
  File "C:\Python27\Lib\site-packages\crcmod\crcmod.py", line 302, in _verifyPoly
    raise ValueError(msg)
ValueError: The degree of the polynomial must be 8, 16, 24, 32 or 64
kate
  • 113
  • 1
  • 5
  • 17
  • @Mark Adler in order for it to be considered a 32 bit poly, the MSB(31st) has to be a one – kate Nov 30 '15 at 04:46
  • 1
    Um, no. The _least_significant bit has to be a one, which it is. The most significant bit is an implied 1 in the bit 32 position (counting starting at bit 0 on the right), provides the length of the polynomial as the x32 term. The full polynomial is 11EDC6F41h. The polynomial is reflected for use in the usual CRC algorithms, since RefIn and RefOut are true. – Mark Adler Nov 30 '15 at 05:00
  • So, _what have you tried?_ What happened when you tried that? Provide short source code examples. Otherwise, no one can help you. – Mark Adler Nov 30 '15 at 05:04
  • @MarkAdler I found it out from here http://stackoverflow.com/questions/20505141/crcmod-python3-polynomial-error – kate Nov 30 '15 at 19:07
  • What's the "name-width-poly-init-etc" table? It makes no sense to me - CRC32 is only characterized by a polynomial (well, you _can_ always add bits here and there but I haven't ever heard of any practical uses of anything other than that). – ivan_pozdeev Nov 30 '15 at 19:43

1 Answers1

3

Usually CRC polynomials are specified without the most significant bit, which is always 1. But it looks like the crcmod library expects this bit to be specified. So you should use the polynomial 0x11EDC6F41. (adding a 1 to the left).

interjay
  • 107,303
  • 21
  • 270
  • 254