Jump to content
Setting up an AI agent? ReverseEngineering.wiki skill (works from the command line, no configuration): https://reverseengineering.wiki/skill/rewiki/SKILL.md · setup for every client, including MCP: https://reverseengineering.wiki/llms.txt · REWiki:Connect

Technique:CRC variants and parameters

From ReverseEngineering.wiki
Technique
On this wiki Facts · Code · Notes · Topics

The Rocksoft/RevEng parameter model of a CRC (width, poly, init, refin, refout, xorout, check value of the string 123456789) and the parameter sets analysts meet most: CRC-32/ISO-HDLC, CRC-32C, CRC-32/MPEG-2, CRC-32/BZIP2, CRC-16/IBM-3740 (CCITT-FALSE), XMODEM, ARC, MODBUS, CRC-8 variants and CRC-64/XZ.

Overview

Almost every CRC in a file format or protocol is one row of the same model, so "which CRC" means "which seven numbers". The model (Ross Williams' Rocksoft model, extended by the CRC RevEng catalogue) has:

  • width: bits in the CRC (8, 16, 32, 64, but also odd ones such as 3, 5, 12, 24).
  • poly: generator polynomial without the implicit top bit, written normal (MSB first), e.g. 0x04C11DB7.
  • init: register value before the first byte.
  • refin: true if each input byte is processed least significant bit first.
  • refout: true if the final register is bit-reversed before xorout. In nearly all catalogued CRCs refin equals refout.
  • xorout: value XORed into the result.
  • check: the CRC of the nine ASCII bytes 123456789. Compute this first with any candidate implementation: if your code does not reproduce the catalogue check value it is not that CRC.

A reflected (refin and refout true) CRC is usually coded with the bit-reversed polynomial, e.g. 0xEDB88320 for 0x04C11DB7, and shifts right. The reflected form of a non-reflected-looking constant is the common reason a polynomial is not recognised in a binary. Details of how to search a binary for these tables are in Technique:Identifying cryptographic constants (CRC-32 rows); this page is about the parameter sets.

Common parameter sets

Names follow the current RevEng catalogue as reproduced in madler/crcany allcrcs.txt; older names are given as aliases. Check values are for the ASCII string 123456789.

Name (alias) width poly init refin/refout xorout check
CRC-32/ISO-HDLC (CRC-32, zlib, PNG, gzip, ZIP, Ethernet) 32 0x04C11DB7 0xFFFFFFFF true 0xFFFFFFFF 0xCBF43926
CRC-32/ISCSI (CRC-32C, Castagnoli) 32 0x1EDC6F41 0xFFFFFFFF true 0xFFFFFFFF 0xE3069283
CRC-32/MPEG-2 32 0x04C11DB7 0xFFFFFFFF false 0 0x0376E6E7
CRC-32/BZIP2 32 0x04C11DB7 0xFFFFFFFF false 0xFFFFFFFF 0xFC891918
CRC-32/CKSUM (POSIX cksum) 32 0x04C11DB7 0 false 0xFFFFFFFF 0x765E7680
CRC-32/JAMCRC 32 0x04C11DB7 0xFFFFFFFF true 0 0x340BC6D9
CRC-16/IBM-3740 (CRC-16/CCITT-FALSE, AUTOSAR) 16 0x1021 0xFFFF false 0 0x29B1
CRC-16/XMODEM (ACORN, LTE) 16 0x1021 0 false 0 0x31C3
CRC-16/KERMIT (CCITT, CCITT-TRUE) 16 0x1021 0 true 0 0x2189
CRC-16/IBM-SDLC (X-25, CRC-16/CCITT in HDLC/PPP) 16 0x1021 0xFFFF true 0xFFFF 0x906E
CRC-16/ARC (CRC-16, LHA, IBM) 16 0x8005 0 true 0 0xBB3D
CRC-16/MODBUS 16 0x8005 0xFFFF true 0 0x4B37
CRC-16/USB 16 0x8005 0xFFFF true 0xFFFF 0xB4C8
CRC-8/SMBUS (plain CRC-8) 8 0x07 0 false 0 0xF4
CRC-8/MAXIM-DOW (Dallas 1-Wire) 8 0x31 0 true 0 0xA1
CRC-8/ROHC 8 0x07 0xFF true 0 0xD0
CRC-8/AUTOSAR 8 0x2F 0xFF false 0xFF 0xDF
CRC-64/XZ (CRC-64/GO-ECMA) 64 0x42F0E1EBA9EA3693 0xFFFFFFFFFFFFFFFF true 0xFFFFFFFFFFFFFFFF 0x995DC9BBDF1939FA
CRC-64/ECMA-182 64 0x42F0E1EBA9EA3693 0 false 0 0x6C40DF5F0B497347

Many CRC-16s share the polynomial and differ only in init, reflection and xorout: when a 0x1021 or 0x8005 table matches, try all of the rows above before concluding the code is custom. CRC-32/MPEG-2, CRC-32/BZIP2 and the Ogg page CRC (poly 0x04C11DB7, init 0, no reflection, no xorout, check 0x89A1897F; see Fact:Ogg/behavior/Ogg page CRC) are three different non-reflected variants of the Ethernet polynomial.

Practical rules

  • The residue trick: for most CRCs, running the CRC over the data followed by its own CRC (stored in the right byte order) gives a constant (the catalogue residue; for CRC-32/ISO-HDLC it is 0xDEBB20E3 on the final register, 0x2144DF1C before the final xor). A format that stores the CRC at the end and checks the whole buffer is using this.
  • Byte order of the stored value is separate from the model: CRC-32 is stored little endian in gzip, zip and PNG stores it big endian. Try both.
  • Table-driven code stores 256 entries of width bits; the first non-zero entry is the polynomial (non-reflected table, index 1) or its reverse (reflected table, index 128).
  • To find unknown parameters from samples use CRC RevEng's search mode, see Technique:Identifying checksums in file formats.

Code & repositories

  • https://github.com/madler/crcany @ 8fc795d650198a3ffab4bd606ae8b3b2b0361e7d · license: Zlib (declared by the contributor for the files used; GitHub reports Zlib (read from LICENSE; GitHub's detector did not classify it) for the repository)
    CRC code generator whose allcrcs.txt lists the RevEng catalogue models with check values (zlib license).
    Tested on: source read, not run: files read: allcrcs.txt, allcrcs-name-changes.txt, README · checked 2026-10-18; last activity 2025-02-03

See also