Documentation
¶
Overview ¶
Package crc provides parameterized CRC computation and recovery of CRC parameters from sample (data, crc) frames — the kind of task that comes up identifying the framing/FEC check on an unfamiliar RF protocol. It generalizes the fixed CRC-16/GSM already used by the P25 alias framing.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var CRC16GSM = Params{Width: 16, Poly: 0x1021, Init: 0x0000, RefIn: false, RefOut: false, XorOut: 0xFFFF}
CRC16GSM is the catalogued CRC used by the P25 alias framing, provided so recovery tests and callers have a known reference.
Functions ¶
This section is empty.
Types ¶
type Params ¶
type Params struct {
Width int // 1..64
Poly uint64 // generator polynomial (normal form, MSB-first)
Init uint64 // register initial value
RefIn bool // reflect each input byte
RefOut bool // reflect the final register before XorOut
XorOut uint64 // final XOR
}
Params is a fully-specified Rocksoft/RevEng-model CRC.
func Recover ¶
Recover searches for CRC parameters consistent with every sample. It brute-forces the polynomial and the two reflect flags for each candidate width, using an init/xorout-invariant equal-length test to cull polynomials cheaply, then resolves Init/XorOut and verifies the full model against all samples.
Init recovery is exact when the corpus mixes message lengths; for a single length, Init and XorOut are mathematically entangled, so the canonical solution Init=0 with the implied XorOut is returned (it reproduces every sample of that length). widths defaults to {16} and recovery brute-forces only widths ≤ 24 (a 2^24 poly sweep) — wider CRCs need a supplied poly.