I am attempting to write some software which is intended to generically answer the question of which Cyclic Redundancy Code (CRC) generating polynomial is used for a given set of sample messages using the same unknown CRC.
For example here are two messages in hexadecimal which use the same CRC:
ee 00 00 00 00 01 20 13 10 (message 1)
ee 00 00 00 00 03 20 a3 23 (message 2)
Since CRC calculations are essentially polynomial division over GF(2), We can consider each CRC calculation to be $M(x) x^n = Q(x) G(x) + R(x)$ where $M(x)$ is the original message appended with $n$ zeroes, $G(x)$ is the generating polynomial and $R(x)$ is the remainder which is identical to the CRC value attached to the end of the message. In this particular case, the original message is
ee 00 00 00 00 01 20
and the appended $R(x)$ is 13 10
Because these two messages use the same generating polynomial, we know that $M_1(x) x^n = Q_1(x) G(x) + R_1(x)$ and $M_2(x) x^n = Q_2(x) G(x) + R_2(x)$. Subtracting one from the other we get: $$\begin{eqnarray*} M_1(x) x^n - M_2(x) x^n &=& Q_1(x) G(x) + R_1(x) - Q_2(x) G(x) - R_2(x)\\ (M_1(x) - M_2(x))x^n - R_1(x) + R_2(x) &=& (Q_1(x)-Q_2(x))G(x)\\ \end{eqnarray*}$$ Since addition and subtraction of polynomials over GF(2) are both identical to the exclusive-or operation, this result means that the exclusive-or of the two messages (including the CRCs) is identical to $(Q_1(x)-Q_2(x))G(x)$, so finding the generating polynomial $G(x)$ could be done by factoring this result. In the specific case of the two messages above, we get
02 00 b0 33
Because of the way CRCs are most often calculated, the bits are "swapped" so that this actually corresponds to the polynomial: $x^{30}+x^{11}+x^{10}+x^8+x^7+x^6+x^3+x^2$. This is trivially factored into $x^2(x^{28}+x^9+x^8+x^6+x^5+x^4+x+1)$, but that's where I get stuck. I know that in this particular case, $G(x) = x^{16}+x^{12}+x^5+1$ (which some may recognize as the standard 16-bit CCITT polynomial).
How do I write efficient code to factor that polynomial over GF(2) without resorting to brute force?
Looking for literature that would help answer that question, I found several papers that looked promising:
- http://www-math.upb.de/~aggathen/Publications/gatger96a.ps.gz
- http://www.sciencedirect.com/science/article/pii/S0747717185710553
However, I am an engineer rather than a mathematician, and I find I am unable to understand what the papers actually mean and therefore unable to use whatever clever algorithms they purport to contain. Short of going back for a degree in field theory, is there some means by which I might learn how to use modern polynomial factoring techniques in application to this problem?