Cyclic Redundancy Check (English:, commonly known as "CRC")

Cyclic Redundancy Check

Cyclic redundancy check (English:, commonly referred to as " CRC ") is a hash function that generates a short fixed-digit verification code based on network data packets or computer files, and is mainly used to detect or verify data transmission or storage Errors that may occur after. The resulting number is calculated and appended to the data before transmission or storage, and the receiver checks to see if the data has changed. This function is widely used because it is easy to use with binary computer hardware, easy to perform mathematical analysis, and especially good at detecting errors caused by transmission channel interference. This method was published by W. Wesley Peterson in 1961 [1].

Introduction

CRC is a kind of checksum, which is the remainder obtained by dividing two byte data streams by binary division (no carry, using XOR instead of subtraction). where the dividend is the binary representation of the information data stream that needs to be checked and calculated; the divisor is a length ( n + 1 ) {\displaystyle (n+1)} (n+1){\displaystyle (n+1 )}(n+1) is a predefined (short) binary number, usually represented by the coefficients of a polynomial. Before doing division, add n {\displaystyle n} n{\displaystyle n}n 0s after the information data.

CRC is a polynomial ring based on the finite field GF(2) (ie congruence divided by 2). Simply put, it is a set of polynomial coefficients whose coefficients are all 0 or 1 (also called binary), and the set is closed for all algebraic operations. For example:

( x 3 + x ) + ( x + 1 ) = x 3 + 2 x + 1 ≡ x 3 + 1 {\displaystyle (x^{3}+x)+(x+1)=x^{3}+2x+1\equiv x^{3}+1} (x3+x)+(x+1)=x3+2x+1≡x3+1{\displaystyle (x^{3}+x)+(x+1)=x^{3}+2x+1\equiv x^{3}+1}(x3+x)+(x+1)=x3+2x+1≡x3+1

2 will become 0, because the addition operation to the coefficient will take the modulus of 2 again. Multiplication is similar:

( x 2 + x ) ( x + 1 ) = x 3 + 2 x 2 + x ≡ x 3 + x {\displaystyle (x^{2}+x)(x+1)=x^{3}+2x^{2}+x\equiv x^{3}+x} (x2+x)(x+1)=x3+2x2+x≡x3+x{\displaystyle (x^{2}+x)(x+1)=x^{3}+2x^{2}+x\equiv x^{3}+x}(x2+x)(x+1)=x3+2x2+x≡x3+x

It is also possible to divide polynomials and get the quotient and remainder. For example, if you divide x 3 + x 2 + x by x + 1. will get:

( x 3 + x 2 + x ) ( x + 1 ) = ( x 2 + 1 ) − 1 ( x + 1 ) {\displaystyle {\frac {(x^{3}+x^{2}+x)}{(x+1)}}=(x^{2}+1)-{\frac {1}{(x+1)}}} (x3+x2+x)(x+1)=(x2+1)−1(x+1){\displaystyle {\frac {(x^{3}+x^{2}+x)}{(x+1)}}=(x^{2}+1)-{\frac {1}{(x+1)}}}(x+1)(x3+x2+x)​=(x2+1)−(x+1)1​

That is to say,

( x 3 + x 2 + x ) = ( x 2 + 1 ) ( x + 1 ) − 1 {\displaystyle (x^{3}+x^{2}+x)=(x^{2}+1)(x+1)-1} (x3+x2+x)=(x2+1)(x+1)−1{\displaystyle (x^{3}+x^{2}+x)=(x^{2}+1)(x+1)-1}(x3+x2+x)=(x2+1)(x+1)−1

Equivalent to:

( x 2 + x + 1 ) x = ( x 2 + 1 ) ( x + 1 ) − 1 {\displaystyle (x^{2}+x+1)x=(x^{2}+1)(x+1)-1} (x2+x+1)x=(x2+1)(x+1)−1{\displaystyle (x^{2}+x+1)x=(x^{2}+1)(x+1)-1}(x2+x+1)x=(x2+1)(x+1)−1

Here the division gets the quotient x 2 + 1 and the remainder -1, the last digit is 1 because it is an odd number.

Each bit in the string actually corresponds to the coefficient of this type of polynomial. To get the CRC, first multiply it by xn {\displaystyle x^{n}} xn{\displaystyle x^{n}}xn, where n {\displaystyle n} n{\displaystyle n}n is a fixed polynomial order , and then divide it by this fixed polynomial, the coefficient of the remainder is the CRC.

In the above equation, x 2 + x + 1 {\displaystyle x^{2}+x+1} x2+x+1{\displaystyle x^{2}+x+1}x2+x+1 means The original information bit is 111, x + 1 {\displaystyle x+1} x+1{\displaystyle x+1}x+1 is the so-called key, and the remainder 1 {\displaystyle 1} 1{\displaystyle 1 } 1 (that is, x 0 {\displaystyle x^{0}} x0{\displaystyle x^{0}}x0) is CRC. The highest degree of key is 1, so multiply the original information by x 1 {\displaystyle x ^{1}} x1{\displaystyle x^{1}}x1 to get x 3 + x 2 + x {\displaystyle x^{3}+x^{2}+x} x3+x2+x{\displaystyle x^{3}+x^{2}+x}x3+x2+x can also be regarded as 1110 by adding a zero to the original information bit.

Generally, its form is:

M ( x ) ⋅ x n = Q ( x ) ⋅ K ( x ) − R ( x ) {\displaystyle M(x)\cdot x^{n}=Q(x)\cdot K(x)-R(x)} M(x)⋅xn=Q(x)⋅K(x)−R(x){\displaystyle M(x)\cdot x^{n}=Q(x)\cdot K(x)-R(x)}M(x)⋅xn=Q(x)⋅K(x)−R(x)

Here M(x) is the original information polynomial. K(x) is a "key" polynomial of order n {\displaystyle n} n{\displaystyle n}n. M ( x ) ⋅ xn {\displaystyle M(x)\cdot x^{n}} M(x)⋅xn{\displaystyle M(x)\cdot x^{n}}M(x)⋅xn represents Add n {\displaystyle n} n{\displaystyle n}n zeros after the original information. R(x) is the remainder polynomial, which is the CRC "checksum". In communication, the sender appends R with n {\displaystyle n} n{\displaystyle n}n bits after the original information data M (replacing the originally appended 0) before sending. After receiving M and R, the receiver checks that M ( x ) ⋅ xn + R ( x ) {\displaystyle M(x)\cdot x^{n}+R(x)} M(x)⋅xn+R( x){\displaystyle M(x)\cdot x^{n}+R(x)}M(x)⋅xn+R(x) can be K ( x ) {\displaystyle K(x)} K( x){\displaystyle K(x)}K(x) is divisible evenly. If yes, then the recipient considers the information to be correct. It is worth noting that M ( x ) ⋅ xn + R ( x ) {\displaystyle M(x)\cdot x^{n}+R(x)} M(x)⋅xn+R(x){\displaystyle M (x)\cdot x^{n}+R(x)}M(x)⋅xn+R(x) is the data that the sender wants to send. This string is also called codeword .

CRCs are often called "checksums", but that's not strictly speaking accurate, because technically the checksum "sum" is calculated by addition, not division as in the case of CRCs.

"Error Correcting Codes" (or ECC for short) are often closely related to CRCs, whose word order corrects errors that occur during transmission. These coding methods are often closely related to mathematical principles. For example, it is commonly used in BCH codes, forward error correction, error detection and correction, etc. in communication or information transmission.

Variants

CRC comes in several different variants

  • shiftRegister can be used in reverse, so you need to detect the value of the lowest bit, and move one bit to the right each time. This requires polynomial to generate the inverse data bit result. In fact this is the most commonly used variant.
  • The highest bit of data can be read into the shift register first, or the lowest bit can be read first. In the communication protocol, in order to preserve the burst error detection feature of the CRC, the CRC is usually calculated according to the way the physical layer sends data bits.
  • In order to check the CRC, CRC calculation needs to be performed on all codewords, rather than just calculating the CRC of the message (Message) and comparing it with the CRC. If the result is 0, then this check is passed. This is because the codeword M ( x ) ⋅ xn + R ( x ) = Q ( x ) ⋅ K ( x ) {\displaystyle M(x)\cdot x^{n}+R(x)=Q(x) \cdot K(x)} M(x)⋅xn+R(x)=Q(x)⋅K(x){\displaystyle M(x)\cdot x^{n}+R(x)=Q( x)\cdot K(x)}M(x)⋅xn+R(x)=Q(x)⋅K(x) can be replaced by K ( x ) {\displaystyle K(x)} K(x){\ displaystyle K(x)}K(x) is divisible evenly.
  • Shift registers can be initialized to 1 instead of 0. Also, the first n {\displaystyle n} n{\displaystyle n}n bits of the message are negated before being processed by the algorithm. This is because an unmodified CRC cannot distinguish between two messages that differ only in the number of leading zeros. After such a process of inversion, CRC can correctly distinguish these messages.
  • The CRC can perform byte inversion when appended to the message data stream (Message stream). In this way, the CRC check can be done by calculating the CRC of the message in a direct way, negating it, and then comparing it with the CRC in the message data stream, or by calculating the entire message. In the latter method, the result of the correct message is no longer 0, but ∑ i = n 2 n − 1 xi {\displaystyle \sum _{i=n}^{2n-1}x^{i}} ∑ i=n2n−1xi{\displaystyle \sum _{i=n}^{2n-1}x^{i}}i=n∑2n−1​xi divided by K ( x ) {\displaystyle K(x) } K(x){\displaystyle K(x)}K(x). This result is called the check polynomial C ( x ) {\displaystyle C(x)} C(x){\displaystyle C(x)}C(x), and its hexadecimal representation is also called the magic number.

By convention, both CRC-32 polynomials and CRC-16-CCITT polynomials are usually negated. The check polynomial of CRC-32 is
C ( x ) = x 31 + x 30 + x 26 + x 25 + x 24 + x 18 + x 15 + x 14 + x 12 + x 11 + x 10 + x 8 + x 6 + x 5 + x 4 + x 3 + x + 1 {\displaystyle C(x)=x^{31}+x^{30}+x^{26}+x^{25}+x^{24} +x^{18}+x^{15}+x^{14}+x^{12}+x^{11}+x^{10}+x^{8}+x^{6}+x ^{5}+x^{4}+x^{3}+x+1} C(x)=x31+x30+x26+x25+x24+x18+x15+x14+x12+x11+x10+x8+ x6+x5+x4+x3+x+1{\displaystyle C(x)=x^{31}+x^{30}+x^{26}+x^{25}+x^{24}+x ^{18}+x^{15}+x^{14}+x^{12}+x^{11}+x^{10}+x^{8}+x^{6}+x^{ 5}+x^{4}+x^{3}+x+1}C(x)=x31+x30+x26+x25+x24+x18+x15+x14+x12+x11+x10+x8+x6+ x5+x4+x3+x+1.

  • When the data to be processed M(x) has a leading 0, use xm L ( x ) {\displaystyle x^{m}L(x)} xmL(x){\displaystyle x^{m}L(x) }xmL(x) and M ( x ) . xn {\displaystyle M(x).x^{n}} M(x).xn{\displaystyle M(x).x^{n}}M(x) Add the two formulas of .xn for inversion operation, so that the leading 0 becomes 1, and then perform mod 2 operation to obtain CRC. formula:

M ( x ) ⋅ x n + x m L ( x ) = Q ( x ) ⋅ K ( x ) + R ( x ) {\displaystyle M(x)\cdot x^{n}+x^{m}L(x)=Q(x)\cdot K(x)+R(x)} M(x)⋅xn+xmL(x)=Q(x)⋅K(x)+R(x){\displaystyle M(x)\cdot x^{n}+x^{m}L(x)=Q(x)\cdot K(x)+R(x)}M(x)⋅xn+xmL(x)=Q(x)⋅K(x)+R(x)
L ( x ) {\displaystyle L(x)\,\!} L(x)  ⁣{\displaystyle L(x)\,\!}L(x)= ∑ i = 0 n − 1 x i {\displaystyle =\sum _{i=0}^{n-1}x^{i}} =∑i=0n−1xi{\displaystyle =\sum _{i=0}^{n-1}x^{i}}=i=0∑n−1​xi
T ( x ) = M ( x ) ⋅ x n + L ( x ) + R ( x ) {\displaystyle T(x)=M(x)\cdot x^{n}+L(x)+R(x)} T(x)=M(x)⋅xn+L(x)+R(x){\displaystyle T(x)=M(x)\cdot x^{n}+L(x)+R(x)}T(x)=M(x)⋅xn+L(x)+R(x)
例: M ( x ) = 01111 {\displaystyle M(x)=01111} M(x)=01111{\displaystyle M(x)=01111}M(x)=01111
K ( x ) = x 3 + x 2 + 1 = 1101 {\displaystyle K(x)=x^{3}+x^{2}+1=1101} K(x)=x3+x2+1=1101{\displaystyle K(x)=x^{3}+x^{2}+1=1101}K(x)=x3+x2+1=1101,這裡可知n = 3 {\displaystyle n=3} n=3{\displaystyle n=3}n=3
M ( x ) . x 3 = 01111000 {\displaystyle M(x).x^{3}=01111000} M(x).x3=01111000{\displaystyle M(x).x^{3}=01111000}M(x).x3=01111000
因∑ i = 0 n − 1 x i {\displaystyle \sum _{i=0}^{n-1}x^{i}} ∑i=0n−1xi{\displaystyle \sum _{i=0}^{n-1}x^{i}}i=0∑n−1​xi,n = 3 {\displaystyle n=3} n=3{\displaystyle n=3}n=3故L(x)階數從2開始
L ( x ) = x 2 + x 1 + x 0 = 111 {\displaystyle L(x)=x^{2}+x^{1}+x^{0}=111} L(x)=x2+x1+x0=111{\displaystyle L(x)=x^{2}+x^{1}+x^{0}=111}L(x)=x2+x1+x0=111
Use xm L ( x ) {\displaystyle x^{m}L(x)} xmL(x){\displaystyle x^{m}L(x)}xmL(x) to find a set of n 1s and m 0 so that it is comparable to M ( x ) . xn {\displaystyle M(x).x^{n}} M(x).xn{\displaystyle M(x).x^{n}}M(x).xn Let
m = 5, X m L ( x ) = X 5 L ( x ) = 11100000 {\displaystyle X^{m}L(x)=X^{5}L(x)=11100000} XmL(x) =X5L(x)=11100000{\displaystyle X^{m}L(x)=X^{5}L(x)=11100000}XmL(x)=X5L(x)=11100000 (bitwise shift) M (
x ) . xn + xm L ( x ) = 01111000 + 11100000 = 10011000 {\displaystyle M(x).x^{n}+x^{m}L(x)=01111000+11100000=10011000} M(x). xn+xmL(x)=01111000+11100000=10011000{\displaystyle M(x).x^{n}+x^{m}L(x)=01111000+11100000=10011000}M(x).xn+xmL (x)=01111000+11100000=10011000 (make the 0 in front of M become 1)
use 10011000 {\displaystyle 10011000} 10011000{\displaystyle 10011000}10011000 mod2 K ( x ) {\displaystyle K(x)} K(x ) {\displaystyle K(x)}K(x) gives the remainder R(x)= 011
T ( x ) = M ( x ) . xn + L ( x ) + R ( x ) = 01111000 + 111 + 011 = 01111100 {\displaystyle T(x)=M(x).x^{n}+L( x)+R(x)=01111000+111+011=01111100} T(x)=M(x).xn+L(x)+R(x)=01111000+111+011=01111100{\displaystyle T( x)=M(x).x^{n}+L(x)+R(x)=01111000+111+011=01111100}T(x)=M(x).xn+L(x)+R (x)=01111000+111+011=01111100 sent to
the receiving end L(x) = 111 and the beginning is not 1 => m = 5
can reverse M ( x ) . xn + xm L ( x ) + R ( x ) = 01111000 + 11100000 + 011 = 10011011 {\displaystyle M(x).x^{n}+x^{m}L(x)+R(x)=01111000+11100000+011=10011011} M(x). xn+xmL(x)+R(x)=01111000+11100000+011=10011011{\displaystyle M(x).x^{n}+x^{m}L(x)+R(x)=01111000+ 11100000+011=10011011}M(x).xn+xmL(x)+R(x)=01111000+11100000+011=10011011 can be
verified to be divisible by K(x) with 10011011 mod2 1101.

error detection capability

The error detection capability of the CRC depends on the order of the key polynomial and the particular key polynomial used. The error polynomial E ( x ) {\displaystyle E(x)} E(x){\displaystyle E(x)}E(x) is the XOR result of the received message codeword and the correct message codeword. The CRC algorithm cannot detect errors if and only if the bit error polynomial is divisible by the CRC polynomial.

  • Since the CRC calculation is based on division, no polynomial can detect an error in a set of all zeros or a missing zero in front. However, there are variants of the CRC that can be used to solve this problem.
  • All errors with only one data bit can be detected by any polynomial with at least two nonzero coefficients. The error polynomial is xk {\displaystyle x^{k}} xk{\displaystyle x^{k}}xk, and xk {\displaystyle x^{k}} xk{\displaystyle x^{k}}xk can only is divisible by the polynomial xi {\displaystyle x^{i}} xi{\displaystyle x^{i}}xi of i ≤ k {\displaystyle i\leq k} i≤k{\displaystyle i\leq k}i≤k .
  • A CRC can detect all double-bit errors separated by a distance less than the order of the polynomial, in this case the error polynomial is

E(x)=xi+xk=xk⋅(xi−k+1),  i>k{\displaystyle E(x)=x^{i}+x^{k}=x^{k}\cdot (x^{i-k}+1),\;i>k}E(x)=xi+xk=xk⋅(xi−k+1),i>k。

As stated above, xk {\displaystyle x^{k}} xk{\displaystyle x^{k}}xk is not divisible by the CRC polynomial, which yields a xi − k + 1 {\displaystyle x^{ik}+1} xi−k+1{\displaystyle x^{ik}+1}xi−k+1 terms. By definition, i − k {\displaystyle The minimum {ik}}i−k{\displaystyle {ik}}i−k is the order of the polynomial. The highest order polynomials are primitive polynomials, polynomials of order n {\displaystyle n} n{\displaystyle n}n with binary coefficients

CRC polynomial specification

The table below omits the "Initial Value", "Reflection Value" and "Final XOR Value".

  • These hexadecimal values ​​are important for complex checksums such as CRC-32 and CRC-64. Typically CRCs smaller than CRC-16 do not need to use these values.
  • You can usually get different checksums by changing these values, but the checksum algorithm mechanism has not changed.

CRC standardization issues

  • Since CRC-12 has three commonly used forms, the definition of CRC-12 will be ambiguous
  • Both forms of CRC-8 in use have mathematical flaws.
  • There are said to be at least 10 versions of CRC-16 and CRC-32, none of which are mathematically optimal.
  • The CCITT CRC of the same size is different from the ITU CRC, which has defined different checksums at different times.

Commonly used CRC (according to ITU-IEEE specification)

name

polynomial

Representation: normal or flipped

CRC-1

x + 1 {\displaystyle x+1} x+1{\displaystyle x+1}x+1
(usage: hardware, also called parity bit)

0x1 or 0x1 (0x1)

CRC-5-CCITT

x 5 + x 3 + x + 1 {\displaystyle x^{5}+x^{3}+x+1} x5+x3+x+1{\displaystyle x^{5}+x^{3}+x+1}x5+x3+x+1(ITU G.704標準)

0xB(0x??)

CRC-5-USB

x 5 + x 2 + 1 {\displaystyle x^{5}+x^{2}+1} x5+x2+1{\displaystyle x^{5}+x^{2}+1}x5+x2+ 1 (purpose: USB signaling package)

0x5 or 0x14 (0x9)

CRC-7

x 7 + x 3 + 1 {\displaystyle x^{7}+x^{3}+1} x7+x3+1{\displaystyle x^{7}+x^{3}+1}x7+x3+ 1 (purpose: communication system)

0x9 or 0x48 (0x11)

CRC-8-ATM

x 8 + x 2 + x + 1 {\displaystyle x^{8}+x^{2}+x+1} x8+x2+x+1{\displaystyle x^{8}+x^{2}+ x+1}x8+x2+x+1 (use: ATM HEC, PMBUS (see SMBUS org ( page archive backup , stored in)))

0x7 or 0xE0 (0xC1)

CRC-8-CCITT

x 8 + x 7 + x 3 + x 2 + 1 {\displaystyle x^{8}+x^{7}+x^{3}+x^{2}+1} x8+x7+x3+x2+1{\displaystyle x^{8}+x^{7}+x^{3}+x^{2}+1}x8+x7+x3+x2+1(用途:1-Wire 總線)

0x8D

CRC-8-Dallas/Maxim

x 8 + x 5 + x 4 + 1 {\displaystyle x^{8}+x^{5}+x^{4}+1} x8+x5+x4+1{\displaystyle x^{8}+x^{5}+x^{4}+1}x8+x5+x4+1(用途:1-Wire bus)

0x31 or 0x8C

CRC-8

x 8 + x 7 + x 6 + x 4 + x 2 + 1 {\displaystyle x^{8}+x^{7}+x^{6}+x^{4}+x^{2}+1} x8+x7+x6+x4+x2+1{\displaystyle x^{8}+x^{7}+x^{6}+x^{4}+x^{2}+1}x8+x7+x6+x4+x2+1

0xD5(0x??)

CRC-10

x 10 + x 9 + x 5 + x 4 + x + 1 {\displaystyle x^{10}+x^{9}+x^{5}+x^{4}+x+1} x10+x9+x5+x4+x+1{\displaystyle x^{10}+x^{9}+x^{5}+x^{4}+x+1}x10+x9+x5+x4+x+1

0x233(0x????)

CRC-12

x 12 + x 11 + x 3 + x 2 + x + 1 {\displaystyle x^{12}+x^{11}+x^{3}+x^{2}+x+1} x12+x11+ x3+x2+x+1{\displaystyle x^{12}+x^{11}+x^{3}+x^{2}+x+1}x12+x11+x3+x2+x+1( Use: communication system)

0x80F or 0xF01 (0xE03)

CRC-16-Fletcher

See Fletcher's checksum

For Adler-32 A & B CRC

CRC-16-CCITT

x 16 + x 12 + x 5 + 1 {\displaystyle x^{16}+x^{12}+x^{5}+1} x16+x12+x5+1{\displaystyle x^{16}+x^{12}+x^{5}+1}x16+x12+x5+1(X25, V.41, Bluetooth, PPP, IrDA)

0x1021 or 0x8408 (0x0811)

CRC-16-IBM

x 16 + x 15 + x 2 + 1 {\displaystyle x^{16}+x^{15}+x^{2}+1} x16+x15+x2+1{\displaystyle x^{16}+x^{15}+x^{2}+1}x16+x15+x2+1(用途:Modbus)

0x8005 or 0xA001 (0x4003)

CRC-16-BBS

x 16 + x 15 + x 10 + x 3 {\displaystyle x^{16}+x^{15}+x^{10}+x^{3}} x16+x15+x10+x3{\displaystyle x^{16}+x^{15}+x^{10}+x^{3}}x16+x15+x10+x3(用途:XMODEM協議)

0x8408(0x????)

CRC-32-Adler

See Adler-32

See Adler-32

CRC-32-MPEG2

See IEEE 802.3

See IEEE 802.3

CRC-32-IEEE 802.3

x 32 + x 26 + x 23 + x 22 + x 16 + x 12 + x 11 + x 10 + x 8 + x 7 + x 5 + x 4 + x 2 + x + 1 {\displaystyle x^{32}+x^{26}+x^{23}+x^{22}+x^{16}+x^{12}+x^{11}+x^{10}+x^{8}+x^{7}+x^{5}+x^{4}+x^{2}+x+1} x32+x26+x23+x22+x16+x12+x11+x10+x8+x7+x5+x4+x2+x+1{\displaystyle x^{32}+x^{26}+x^{23}+x^{22}+x^{16}+x^{12}+x^{11}+x^{10}+x^{8}+x^{7}+x^{5}+x^{4}+x^{2}+x+1}x32+x26+x23+x22+x16+x12+x11+x10+x8+x7+x5+x4+x2+x+1

0x04C11DB7 or 0xEDB88320 (0xDB710641)

CRC-32C(Castagnoli)

x 32 + x 28 + x 27 + x 26 + x 25 + x 23 + x 22 + x 20 + x 19 + x 18 + x 14 + x 13 + x 11 + x 10 + x 9 + x 8 + x 6 + 1 {\displaystyle x^{32}+x^{28}+x^{27}+x^{26}+x^{25}+x^{23}+x^{22}+x^{20}+x^{19}+x^{18}+x^{14}+x^{13}+x^{11}+x^{10}+x^{9}+x^{8}+x^{6}+1} x32+x28+x27+x26+x25+x23+x22+x20+x19+x18+x14+x13+x11+x10+x9+x8+x6+1{\displaystyle x^{32}+x^{28}+x^{27}+x^{26}+x^{25}+x^{23}+x^{22}+x^{20}+x^{19}+x^{18}+x^{14}+x^{13}+x^{11}+x^{10}+x^{9}+x^{8}+x^{6}+1}x32+x28+x27+x26+x25+x23+x22+x20+x19+x18+x14+x13+x11+x10+x9+x8+x6+1

0x1EDC6F41 or 0x82F63B78 ​​(0x05EC76F1)

CRC-64-ISO

x 64 + x 4 + x 3 + x + 1 {\displaystyle x^{64}+x^{4}+x^{3}+x+1} x64+x4+x3+x+1{\displaystyle x^{64}+x^{4}+x^{3}+x+1}x64+x4+x3+x+1
(用途: ISO 3309)

0x000000000000001B or 0xD800000000000000 (0xB000000000000001)

CRC-64-ECMA-182

x 64 + x 62 + x 57 + x 55 + x 54 + x 53 + x 52 + x 47 + x 46 + x 45 + x 40 + x 39 + x 38 + x 37 + x 35 + x 33 + x 32 {\displaystyle x^{64}+x^{62}+x^{57}+x^{55}+x^{54}+x^{53}+x^{52}+x^{47}+x^{46}+x^{45}+x^{40}+x^{39}+x^{38}+x^{37}+x^{35}+x^{33}+x^{32}} x64+x62+x57+x55+x54+x53+x52+x47+x46+x45+x40+x39+x38+x37+x35+x33+x32{\displaystyle x^{64}+x^{62}+x^{57}+x^{55}+x^{54}+x^{53}+x^{52}+x^{47}+x^{46}+x^{45}+x^{40}+x^{39}+x^{38}+x^{37}+x^{35}+x^{33}+x^{32}}x64+x62+x57+x55+x54+x53+x52+x47+x46+x45+x40+x39+x38+x37+x35+x33+x32
+ x 31 + x 29 + x 27 + x 24 + x 23 + x 22 + x 21 + x 19 + x 17 + x 13 + x 12 + x 10 + x 9 + x 7 + x 4 + x + 1 { \displaystyle +x^{31}+x^{29}+x^{27}+x^{24}+x^{23}+x^{22}+x^{21}+x^{19} +x^{17}+x^{13}+x^{12}+x^{10}+x^{9}+x^{7}+x^{4}+x+1} +x31+ x29+x27+x24+x23+x22+x21+x19+x17+x13+x12+x10+x9+x7+x4+x+1{\displaystyle +x^{31}+x^{29}+x^{ 27}+x^{24}+x^{23}+x^{22}+x^{21}+x^{19}+x^{17}+x^{13}+x^{12} +x^{10}+x^{9}+x^{7}+x^{4}+x+1}+x31+x29+x27+x24+x23+x22+x21+x19+x17+x13+ x12+x10+x9+x7+x4+x+1
(see ECMA-182 ( page archive backup , stored at) p.63)

0x42F0E1EBA9EA3693 or 0xC96C5795D7870F42 (0x92D8AF2BAF0E1E85)

CRC-128

IEEE-ITU standard. Replaced by MD5 & SHA-1

CRC-160

IEEE-ITU standard. Replaced by MD5 & SHA-1

CRC and data integrity

儘管在錯誤檢測中非常有用,CRC並不能可靠地驗證數據完整性(即數據沒有發生任何變化),這是因為CRC多項式是線性結構,可以非常容易地故意改變數據而維持CRC不變,參見CRC and how to Reverse it页面存档备份,存于)中的證明。可以用Message authentication code驗證數據完整性。

CRC發生碰撞的情況

與所有其它的散列函數一樣,在一定次數的碰撞測試之後CRC也會接近100%出現碰撞。CRC中每增加一個數據位,碰撞機率就會減少接近50%,如CRC-20與CRC-21相比。

  • 理論上來講,CRC64的碰撞概率大約是每18×1018個CRC碼出現一次。
  • 由於CRC的不分解多項式特性,所以經過合理設計的較少位數的CRC可能會與使用較多數據位但是設計很差的CRC的效率相媲美。在這種情況下CRC-32幾乎同CRC-40一樣優秀。

設計CRC多項式

生成多項式的選擇是CRC算法實現中最重要的部分,所選擇的多項式必須有最大的錯誤檢測能力,同時保證總體的碰撞概率最小。多項式最重要的屬性是它的長度,也就是最高非零系數的數值,因為它直接影響著計算的校驗和的長度。

最常用的多項式長度有

  • 9位(CRC-8)
  • 17位(CRC-16)
  • 33位(CRC-32)
  • 65位(CRC-64)

在構建一個新的CRC多項式或者改進現有的CRC時,一個通用的數學原則是使用滿足所有模運算不可分解多項式約束條件的多項式。

  • 這種情況下的不可分解是指多項式除了1與它自身之外不能被任何其它的多項式整除。

生成多項式的特性可以從算法的定義中推導出來:

  • 如果CRC有多於一個的非零系數,那麼CRC能夠檢查出輸入消息中的所有單數據位錯誤。
  • CRC可以用於檢測短於2k的輸入消息中的所有雙位錯誤,其中k是多項式的最長的不可分解部分的長度。
  • 如果多項式可以被x+1整除,那麼不存在可以被它整除的有奇數個非零系數的多項式。因此,它可以用來檢測輸入消息中的奇數個錯誤,就像奇偶校驗函數那樣。

參見

總的分類

  • 糾錯碼
  • 校驗和算法列表
  • 奇偶校驗位

特殊技術參考

  • Adler-32
  • Fletcher's checksum

Guess you like

Origin blog.csdn.net/weixin_40191861/article/details/131651684