Debian Codegraph @

manuals/en/developers/md5.tex

raw
1 %%
2 %%
3
4 \chapter{Bacula MD5 Algorithm}
5 \label{blb:MD5Chapter}
6
7 \section{Command Line Message Digest Utility }
8 \index{Utility!Command Line Message Digest }
9 \index{Command Line Message Digest Utility }
10
11
12 This page describes {\bf md5}, a command line utility usable on either Unix or
13 MS-DOS/Windows, which generates and verifies message digests (digital
14 signatures) using the MD5 algorithm. This program can be useful when
15 developing shell scripts or Perl programs for software installation, file
16 comparison, and detection of file corruption and tampering.
17
18 \subsection{Name}
19 \index{Name}
20
21 {\bf md5} - generate / check MD5 message digest
22
23 \subsection{Synopsis}
24 \index{Synopsis }
25
26 {\bf md5} [ {\bf -c}{\it signature} ] [ {\bf -u} ] [ {\bf -d}{\it input\_text}
27 | {\it infile} ] [ {\it outfile} ]
28
29 \subsection{Description}
30 \index{Description }
31
32 A \emph{message digest} is a compact digital signature for an arbitrarily long
33 stream of binary data. An ideal message digest algorithm would never generate
34 the same signature for two different sets of input, but achieving such
35 theoretical perfection would require a message digest as long as the input
36 file. Practical message digest algorithms compromise in favour of a digital
37 signature of modest size created with an algorithm designed to make
38 preparation of input text with a given signature computationally infeasible.
39 Message digest algorithms have much in common with techniques used in
40 encryption, but to a different end; verification that data have not been
41 altered since the signature was published.
42
43 Many older programs requiring digital signatures employed 16 or 32 bit \emph{cyclical redundancy codes}
44 (CRC) originally developed to verify correct
45 transmission in data communication protocols, but these short codes, while
46 adequate to detect the kind of transmission errors for which they were
47 intended, are insufficiently secure for applications such as electronic
48 commerce and verification of security related software distributions.
49
50 The most commonly used present-day message digest algorithm is the 128 bit MD5
51 algorithm, developed by Ron Rivest of the
52 \bref{http://web.mit.edu/}{MIT}
53 \bref{http://www.lcs.mit.edu/}{Laboratory for Computer Science} and
54 \bref{http://www.rsa.com/}{RSA Data Security, Inc.} The algorithm, with a
55 reference implementation, was published as Internet
56 \bref{http://www.fourmilab.ch/md5/rfc1321.html}{RFC 1321} in April 1992, and
57 was placed into the public domain at that time. Message digest algorithms such
58 as MD5 are not deemed ``encryption technology'' and are not subject to the
59 export controls some governments impose on other data security products.
60 (Obviously, the responsibility for obeying the laws in the jurisdiction in
61 which you reside is entirely your own, but many common Web and Mail utilities
62 use MD5, and I am unaware of any restrictions on their distribution and use.)
63
64 The MD5 algorithm has been implemented in numerous computer languages
65 including C,
66 \bref{http://www.perl.org/}{Perl}, and
67 \bref{http://www.javasoft.com/}{Java}; if you're writing a program in such a
68 language, track down a suitable subroutine and incorporate it into your
69 program. The program described on this page is a {\it command line}
70 implementation of MD5, intended for use in shell scripts and Perl programs (it
71 is much faster than computing an MD5 signature directly in Perl). This {\bf
72 md5} program was originally developed as part of a suite of tools intended to
73 monitor large collections of files (for example, the contents of a Web site)
74 to detect corruption of files and inadvertent (or perhaps malicious) changes.
75 That task is now best accomplished with more comprehensive packages such as
76 \bref{ftp://coast.cs.purdue.edu/pub/COAST/Tripwire/}{Tripwire}, but the
77 command line {\bf md5} component continues to prove useful for verifying
78 correct delivery and installation of software packages, comparing the contents
79 of two different systems, and checking for changes in specific files.
80
81 \subsection{Options}
82 \index{Options}
83
84 \begin{bdescription}
85
86 \item [{\bf -c}{\it signature} ]
87 \index{-csignature }
88 Computes the signature of the specified {\it infile} or the string supplied
89 by the {\bf -d} option and compares it against the specified {\it signature}.
90 If the two signatures match, the exit status will be zero, otherwise the exit
91 status will be 1. No signature is written to {\it outfile} or standard
92 output; only the exit status is set. The signature to be checked must be
93 specified as 32 hexadecimal digits.
94
95 \item [{\bf -d}{\it input\_text} ]
96 \index{-dinput\_text }
97 A signature is computed for the given {\it input\_text} (which must be quoted
98 if it contains white space characters) instead of input from {\it infile} or
99 standard input. If input is specified with the {\bf -d} option, no {\it
100 infile} should be specified.
101
102 \item [{\bf -u} ]
103 Print how-to-call information.
104 \end{bdescription}
105
106 \subsection{Files}
107 \index{Files }
108
109 If no {\it infile} or {\bf -d} option is specified or {\it infile} is a single
110 ``-'', {\bf md5} reads from standard input; if no {\it outfile} is given, or
111 {\it outfile} is a single ``-'', output is sent to standard output. Input and
112 output are processed strictly serially; consequently {\bf md5} may be used in
113 pipelines.
114
115 \subsection{Bugs}
116 \index{Bugs }
117
118 The mechanism used to set standard input to binary mode may be specific to
119 Microsoft C; if you rebuild the DOS/Windows version of the program from source
120 using another compiler, be sure to verify binary files work properly when read
121 via redirection or a pipe.
122
123 This program has not been tested on a machine on which {\tt int} and/or {\tt
124 long} are longer than 32 bits.
125
126 \section{Download md5.zip (Zipped archive)}
127 %%\bref{http://www.fourmilab.ch/md5/md5.zip}{Download md5.zip (Zipped archive)}
128 \index{Archive!Download md5.zip Zipped }
129 \index{Download md5.zip (Zipped archive) }
130
131 The program is provided as
132 \bref{http://www.fourmilab.ch/md5/md5.zip}{md5.zip}, a
133 \bref{http://www.pkware.com/}{Zipped} archive containing an ready-to-run
134 Win32 command-line executable program, {\tt md5.exe} (compiled using Microsoft
135 Visual C++ 5.0), and in source code form along with a {\tt Makefile} to build
136 the program under Unix.
137
138 \subsection{See Also}
139 \index{ALSO!SEE }
140 \index{See Also }
141
142 {\bf sum}(1)
143
144 \subsection{Exit Status}
145 \index{Status!Exit }
146 \index{Exit Status }
147
148 {\bf md5} returns status 0 if processing was completed without errors, 1 if
149 the {\bf -c} option was specified and the given signature does not match that
150 of the input, and 2 if processing could not be performed at all due, for
151 example, to a nonexistent input file.
152
153 \subsection{Copying}
154 \index{Copying }
155
156 \begin{quote}
157 This software is in the public domain. Permission to use, copy, modify, and
158 distribute this software and its documentation for any purpose and without
159 fee is hereby granted, without any conditions or restrictions. This software
160 is provided ``as is'' without express or implied warranty.
161 \end{quote}
162
163 \subsection{Acknowledgements}
164 \index{Acknowledgements }
165
166 The MD5 algorithm was developed by Ron Rivest. The public domain C language
167 implementation used in this program was written by Colin Plumb in 1993.
168 {\it
169 \bref{http://www.fourmilab.ch/}{by John Walker}
170 January 6th, MIM }