Commit | Line | Data |
---|---|---|
bd2a8a16 KB |
1 | .\" Copyright (c) 1991 The Regents of the University of California. |
2 | .\" All rights reserved. | |
3 | .\" | |
4 | .\" %sccs.include.redist.man% | |
5 | .\" | |
6 | .\" @(#)cksum.1 5.1 (Berkeley) %G% | |
7 | .\" | |
8 | .TH CKSUM 1 "" | |
9 | .UC 7 | |
10 | .SH NAME | |
11 | cksum \- display file checksums and block counts | |
12 | .SH SYNOPSIS | |
13 | .ft B | |
14 | .nf | |
15 | cksum [file ...] | |
16 | .fi | |
17 | .ft R | |
18 | .SH DESCRIPTION | |
19 | The | |
20 | .I cksum | |
21 | utility calculates and writes to standard output a total number of bytes, | |
22 | a checksum CRC and the file name for each input file (or the standard input | |
23 | by default). | |
24 | .PP | |
25 | The CRC used is based on the polynomial used for CRC error checking in | |
26 | the networking standard ISO 8802-3: 1989. | |
27 | The CRC checksum encoding is defined by the generating polynomial: | |
28 | .sp | |
29 | .RS | |
30 | G(x) = | |
31 | .RS | |
32 | x^32 + x^26 + x^23 + x^22 + x^16 + x^12 + | |
33 | x^11 + x^10 + x^8 + x^7 + x^5 + x^4 + x^2 + x + 1 | |
34 | .RE | |
35 | .RE | |
36 | .PP | |
37 | Mathematically, the CRC value corresponding to a given file is defined by | |
38 | the following procedure: | |
39 | .RS | |
40 | .PP | |
41 | The | |
42 | .I n | |
43 | bits of the file are considered to be the coefficients of a mod 2 | |
44 | polynomial M(x) of degree | |
45 | .IR n -1. | |
46 | .PP | |
47 | M(x) is multiplied by x^32 (i.e., shifted left 32 bits) and divided by | |
48 | G(x) using mod 2 division, producing a remainder R(x) of degree <= 31. | |
49 | During the division, each time the intermediate remainder is zero, it | |
50 | is changed to the next value from a predefined sequence of 32-bit | |
51 | integers before completing the division. | |
52 | This sequence is long and complex -- see the source code for more | |
53 | information. | |
54 | .PP | |
55 | The coefficients of R(x) are considered to be a 32-bit sequence. | |
56 | .RE | |
57 | .PP | |
58 | The calculation used is identical to that given in pseudo-code in | |
59 | the ACM article listed below. | |
60 | .PP | |
61 | The | |
62 | .I cksum | |
63 | utility exits 0 on success, and >0 if an error occurs. | |
64 | .SH SEE ALSO | |
65 | .IR "Computation of Cyclic Redundancy Checks Via Table Lookup" , | |
66 | Dilip V. Sarwate, Communications of the ACM, August 1988. | |
67 | .SH STANDARDS | |
68 | .I Cksum | |
69 | is expected to conform to IEEE Std 1003.2 (``POSIX''). | |
70 | .SH HISTORY | |
71 | .I Cksum | |
72 | first appeared in 4.4BSD. |