1502 Remove conversion cruft from manpages
[unleashed.git] / usr / src / man / man1 / cksum.1
blob0f1d1a8ad16094594d6614b3b0492fe3626da301
1 '\" te
2 .\"  Copyright (c) 1992, X/Open Company Limited All Rights Reserved Portions Copyright (c) 2006, Sun Microsystems, Inc. All Rights Reserved
3 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at
4 .\" http://www.opengroup.org/bookstore/.
5 .\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html.
6 .\"  This notice shall appear on any product containing this material.
7 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
8 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
9 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
10 .TH CKSUM 1 "Feb 1, 1995"
11 .SH NAME
12 cksum \- write file checksums and sizes
13 .SH SYNOPSIS
14 .LP
15 .nf
16 \fBcksum\fR [\fIfile\fR]...
17 .fi
19 .SH DESCRIPTION
20 .sp
21 .LP
22 The \fBcksum\fR command calculates and writes to standard output a cyclic
23 redundancy check (CRC) for each input file, and also writes to standard output
24 the number of octets in each file.
25 .sp
26 .LP
27 For each file processed successfully, \fBcksum\fR will write in the following
28 format:
29 .sp
30 .LP
31 \fB"%u %d %s\en"\fR <\fIchecksum\fR>, <\fI# of octets\fR>, <\fIpath name\fR>
32 .sp
33 .LP
34 If no \fIfile\fR operand was specified, the path name and its leading space
35 will be omitted.
36 .sp
37 .LP
38 The CRC used is based on the polynomial used for CRC error checking in the
39 referenced Ethernet standard.
40 .sp
41 .LP
42 The encoding for the CRC checksum is defined by the generating polynomial:
43 .sp
44 .LP
45 \fIG\|\fR(\fIx\fR) = \fIx\fR^32 + \fIx\fR^26 + \fIx\fR^23 + \fIx\fR^22 +
46 \fIx\fR^16 + \fIx\fR^12 + \fIx\fR^11 + \fIx\fR^10 + \fIx\fR^8 + \fIx\fR^7 +
47 \fIx\fR^5 + \fIx\fR^4 + \fIx\fR^2 + \fIx\fR + 1
48 .sp
49 .LP
50 Mathematically, the CRC value corresponding to a given file is defined by the
51 following procedure:
52 .RS +4
53 .TP
55 The \fIn\fR bits to be evaluated are considered to be the coefficients of a
56 mod 2 polynomial \fIM\fR(\fIx\fR) of degree \fIn\fR\(mi\fI1.\fR These \fIn\fR
57 bits are the bits from the file, with the most significant bit being the most
58 significant bit of the first octet of the file and the last bit being the least
59 significant bit of the last octet, padded with zero bits (if necessary) to
60 achieve an integral number of octets, followed by one or more octets
61 representing the length of the file as a binary value, least significant octet
62 first. The smallest number of octets capable of representing this integer is
63 used.
64 .RE
65 .RS +4
66 .TP
68 \fIM\fR(\fIx\fR) is multiplied by \fIx\fR ^\fI32\fR (that is, shifted left
69 32 bits) and divided by \fIG\fR(\fIx\fR) using mod 2 division, producing a
70 remainder \fIR\fR(\fIx\fR) of degree \(<= 31.
71 .RE
72 .RS +4
73 .TP
75 The coefficients of \fIR\fR(\fIx\fR) are considered to be a 32-bit sequence.
76 .RE
77 .RS +4
78 .TP
80 The bit sequence is complemented and the result is the CRC.
81 .RE
82 .SH OPERANDS
83 .sp
84 .LP
85 The following operand is supported:
86 .sp
87 .ne 2
88 .na
89 \fB\fIfile\fR\fR
90 .ad
91 .RS 8n
92 A path name of a file to be checked. If no \fIfile\fR operands are specified,
93 the standard input is used.
94 .RE
96 .SH USAGE
97 .sp
98 .LP
99 The \fBcksum\fR command is typically used to quickly compare a suspect file
100 against a trusted version of the same, such as to ensure that files transmitted
101 over noisy media arrive intact. However, this comparison cannot be considered
102 cryptographically secure. The chances of a damaged file producing the same CRC
103 as the original are astronomically small; deliberate deception is difficult,
104 but probably not impossible.
107 Although input files to \fBcksum\fR can be any type, the results need not be
108 what would be expected on character special device files. Since this document
109 does not specify the block size used when doing input, checksums of character
110 special files need not process all of the data in those files.
113 The algorithm is expressed in terms of a bitstream divided into octets. If a
114 file is transmitted between two systems and undergoes any data transformation
115 (such as moving 8-bit characters into 9-bit bytes or changing "Little Endian"
116 byte ordering to "Big Endian"), identical CRC values cannot be expected.
117 Implementations performing such transformations may extend \fBcksum\fR to
118 handle such situations.
121 See \fBlargefile\fR(5) for the description of the behavior of \fBcksum\fR when
122 encountering files greater than or equal to 2 Gbyte ( 2^31 bytes).
123 .SH ENVIRONMENT VARIABLES
126 See \fBenviron\fR(5) for descriptions of the following environment variables
127 that affect the execution of \fBcksum\fR: \fBLANG\fR, \fBLC_ALL\fR,
128 \fBLC_CTYPE\fR, \fBLC_MESSAGES\fR, and \fBNLSPATH\fR.
129 .SH EXIT STATUS
132 The following exit values are returned:
134 .ne 2
136 \fB\fB0\fR\fR
138 .RS 6n
139 All files were processed successfully.
143 .ne 2
145 \fB\fB>0\fR\fR
147 .RS 6n
148 An error occurred.
151 .SH ATTRIBUTES
154 See \fBattributes\fR(5) for descriptions of the following attributes:
159 box;
160 c | c
161 l | l .
162 ATTRIBUTE TYPE  ATTRIBUTE VALUE
164 Interface Stability     Standard
167 .SH SEE ALSO
170 \fBdigest\fR(1), \fBsum\fR(1), \fBbart\fR(1M), \fBattributes\fR(5),
171 \fBenviron\fR(5), \fBlargefile\fR(5), \fBstandards\fR(5)