=head1	NAME

chksum - Checksum calculator

=head1	SYNOPSYS

  chksum <options> <file(s)>
  chksum -c <options> <file(s)>

=head1	DESCRIPTION

The chksum program builds checksums for files (build mode)
and compares file checksums against a checksum list (check mode).

Two steps are used to build a checksum:

=over 6

=item	* Binary message digest

A binary message digest is created using one of the
following algorithms: MD5, RIPEMD-160, SHA-1 (default), SHA-224, SHA-256,
SHA-384 or SHA-512.

=item	* Text representation

A text representation of the message data is created
using one of the following encodings: ASCII-Hex, ASCII-85 (default)
or reverse ASCII-85.

=back


=head1	OPTIONS

=over 6

=item	B<-h>

shows a help text.

Long option: --help

=item	B<-v>

shows version information.

Long option: --version

=item	B<-m> I<digest>

chooses a message digest algorithm, one from:
MD5, RIPEMD-160, SHA-1, SHA-224, SHA-256, SHA-384 or SHA-512.

SHA-1 is the default message digest algorithm.

Long option: --message-digest=I<digest>

=item	B<-e> I<encoding>

selects an encoding mechanism to convert binary data to text,
one from: HEX (to choose ASCII-Hex encoding), ASCII-85
(to choose ASCII-85 encoding) or REVERSE-ASCII-85 (to choose
reverse ASCII-85 encoding).

The abbreviations A85 and R-ASCII-85 or RA85 can be used instead
of ASCII-85 and REVERSE-ASCII-85.

ASCII-85 is the default encoding.

Long option: --encoding=I<encoding>

=item	B<-l>

indicates that the files specified on the command line are
lists of file names instead of files to build checksums
directly (in build mode only).

Long option: --list

=item	B<-n>

turns off header line printing in build mode. If this option is not used
the first output line is a control line indicating the message digest
type and the binary-to-text encoding used.

Long option: --no-header

=item	B<-c>

switches to check mode. The files specified on the
command line (or standard input if no file name is specified)
contain checksum lists produced formerly by chksum in build
mode.

Long option: --check

=item	B<-q>

suppresses informational messages about succeeded tests
in check mode.

Long option: --quiet

=item	B<-s>

suppresses messages about succeeded tests and failed tests
in check mode. The exit status indicates whether or not there
were failed tests.

Long option: --status

=item	B<-o>

indicates that the check lists were produced by md5sum,
not chksum.

Long option: --md5sum

=back

=head1	RETURN VALUE

The program sets the exit status as follows:

=over 6

=item	* 0 indicates success

=item	* 1 A checksum mismatch was found.

=item	* 2 Wrong options or syntax error.

=item	* 3 Attempt to handle a directory.

=item	* 4 Attempt to handle an illegal/unknown file type.

=item	* 5 The stat() function failed for a file.

=item	* 6 Failed to open file for reading.

=item	* 7 Problems to create a checksum.

=item	* 8 The message digest is not supported here.

=back

=head1	DIAGNOSTICS

=over 6

=item	* ERROR - Unknown digest type ...!

The digest type must be ``MD5'', ``RIPEMD-160'', ``SHA-1'',
``SHA-224'', ``SHA-256'', ``SHA-384'' or ``SHA-512''.

=item	* ERROR - long option ... needs an argument!

An argument (digest type or encoding mechanism is needed
by the long option.

=item	* ERROR - Unknown encoding ...!

The encoding mechanism must be ``HEX'', ``ASCII-85''
or ``R-ASCII-85''.

=item	* ERROR - Unknown long option ...!

A wrong long option was used.

=item	* ERROR - Long option ... too long!

A long option including the argument must not exceed 1024
characters.

=item	* ERROR - Unknown option ...!

This option can not be used by the chksum program.

=item	* ERROR - Can not handle directories!

One of the file names points to a directory, not a 
regular file.

=item	* Warning - Creating checksum for a device!

One of the file names points to a device, not a
regular file. Checksumming may be useful for some devices
(i.e. /dev/hda) but not for others (i.e. /dev/null
or /dev/random).

=item	* ERROR - Illegal file type!

The file name points to a file of illegal type
(not a regular file).

=item	* ERROR - Failed to obtain information about file!

The stat64() or stat() function failed to obtain information
about a file. Most likely the file does not exist.

=item	* ERROR - Failed to open file for reading!

The file can not be opened for reading (probably a permissions
problem).

=item	* Syntax error!

A check list line does not contain checksum and file name
as expected.

=item	* Syntax error - Not a key=value pair!

A control line in a check list is not a key=value pair as
expected.

=item	* Syntax error - Value text is missing!

A control line in a check list only contains ``key='' but no
value!

=item	* Syntax error - Unknown instruction ...!

A control line in a check list contains a wrong key.

=item	* Syntax error - Missing encoding!

A control line for digest/encoding in a check list contains
only a digest, not an encoding.

=item	* WARNING ... of ... computed checksums did NOT match!

There were checksum mismatches!

=item	* Pipe skipped.

One of the file names points to a pipe.

=item	* ERROR - Failed to create checksum!

There was a problem, no checksum can be created for that file.

=item	* ERROR - Message digest type ... not implemented!

While building the chksum program an OpenSSL library version was
used without support for the specified message digest algorithm.

=item	* ERROR - ... files skipped (message digest not implemented)!

While building the chksum program an OpenSSL library version was
used without support for the specified message digest algorithm.

=back

=head1	SEE ALSO

http://dktools.sourceforge.net/fchksum.html

=head1	AUTHOR

Dirk Krause

=head1	COPYRIGHT AND LICENSE

Copyright (C) - 2009, Dirk Krause
All rights resrved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

 * Redistributions of source code must retain the above
   copyright notice, this list of conditions and the
   following disclaimer.

 * Redistributions in binary form must reproduce the above
   copyright notice, this list of conditions and the following
   disclaimer in the documentation and/or other materials
   provided with the distribution.

 * Neither the name of the Dirk Krause nor the names of
   contributors may be used to endorse or promote products
   derived from this software without specific prior written
   permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

This program uses the OpenSSL library, see http://www.openssl.org.

This product includes cryptographic software written by
Eric Young (eay@cryptsoft.com).

=head1	HISTORY

2009-02-08: First version finished, tested on Solaris and Linux.

