Merge branch 'master' of ssh://crater.dragonflybsd.org/repository/git/dragonfly
[dragonfly.git] / sbin / md5 / md5.1
1 .\" $FreeBSD: src/sbin/md5/md5.1,v 1.24 2005/03/10 09:56:39 cperciva Exp $
2 .\" $DragonFly: src/sbin/md5/md5.1,v 1.8 2008/01/16 14:18:57 matthias Exp $
3 .Dd January 16, 2008
4 .Dt MD5 1
5 .Os
6 .Sh NAME
7 .Nm md5 ,
8 .Nm sha1 ,
9 .Nm sha256 ,
10 .Nm rmd160
11 .Nd calculate a message-digest fingerprint (checksum) for a file
12 .Sh SYNOPSIS
13 .Nm md5
14 .Op Fl pqrtx
15 .Op Fl b Ar offset
16 .Op Fl e Ar offset
17 .Op Fl s Ar string
18 .Op Ar
19 .Nm sha1
20 .Op Fl pqrtx
21 .Op Fl b Ar offset
22 .Op Fl e Ar offset
23 .Op Fl s Ar string
24 .Op Ar
25 .Nm sha256
26 .Op Fl pqrtx
27 .Op Fl b Ar offset
28 .Op Fl e Ar offset
29 .Op Fl s Ar string
30 .Op Ar
31 .Nm rmd160
32 .Op Fl pqrtx
33 .Op Fl b Ar offset
34 .Op Fl e Ar offset
35 .Op Fl s Ar string
36 .Op Ar
37 .Sh DESCRIPTION
38 The
39 .Nm md5 ,
40 .Nm sha1 ,
41 .Nm sha256
42 and
43 .Nm rmd160
44 utilities take as input a message of arbitrary length and produce as
45 output a
46 .Dq fingerprint
47 or
48 .Dq message digest
49 of the input.
50 It is conjectured that it is computationally infeasible to
51 produce two messages having the same message digest, or to produce any
52 message having a given prespecified target message digest.
53 The
54 .Tn MD5 , SHA-1, SHA-256
55 and
56 .Tn RIPEMD-160
57 algorithms are intended for digital signature applications, where a
58 large file must be
59 .Dq compressed
60 in a secure manner before being encrypted with a private
61 (secret)
62 key under a public-key cryptosystem such as
63 .Tn RSA .
64 .Pp
65 .Tn MD5
66 has not yet (2001-09-03) been broken, but sufficient attacks have been
67 made that its security is in some doubt.
68 The attacks on
69 .Tn MD5
70 are in the nature of finding
71 .Dq collisions
72 \(em that is, multiple
73 inputs which hash to the same value; it is still unlikely for an attacker
74 to be able to determine the exact original input given a hash value.
75 .Pp
76 The following options may be used in any combination and must
77 precede any files named on the command line.
78 The hexadecimal checksum of each file listed on the command line is printed
79 after the options are processed.
80 .Bl -tag -width indent
81 .It Fl b Ar offset
82 When processing file(s), use the specified begin and/or end (below) instead
83 of processing each file in its entirety. Either option can be omitted. Both
84 begin- and end-offsets can be specified as just a number (of bytes) or
85 be followed by K, M, or G to mean that the number is to be multiplied by
86 1024 once, twice, or thrice respectively. For example, to start at 512, you
87 can use -b 512 or -b 0.5K.
88 .Pp
89 The use of offsets is implemented using
90 .Nm mmap()
91 and will only work on regular files and mmap-able devices.
92 .Pp
93 If the beginning offset is negative, its absolute value is substracted
94 from the file's size. Zero thus means the very beginning of each file,
95 which is also the default if the option is omitted entirely.
96 .It Fl e Ar offset
97 If the end-offset is not positive, its absolute value is substracted
98 from the file's size. Zero thus means the very end of each file,
99 which is also the default if the option is omitted entirely.
100 .It Fl s Ar string
101 Print a checksum of the given
102 .Ar string .
103 .It Fl p
104 Echo stdin to stdout and append the checksum to stdout.
105 .It Fl q
106 Quiet mode - only the checksum is printed out.
107 Overrides the
108 .Fl r
109 option.
110 .It Fl r
111 Reverses the format of the output.
112 This helps with visual diffs.
113 Does nothing
114 when combined with the
115 .Fl ptx
116 options.
117 .It Fl t
118 Run a built-in time trial.
119 .It Fl x
120 Run a built-in test script.
121 .El
122 .Sh DIAGNOSTICS
123 The
124 .Nm md5 ,
125 .Nm sha1 ,
126 .Nm sha256
127 and
128 .Nm rmd160
129 utilities exit 0 on success,
130 and EX_NOINPUT (66) if at least one of the input files could not be read or
131 invalid offsets were specified. A mistake with command line arguments
132 results in EX_USAGE (64).
133 .Sh SEE ALSO
134 .Xr cksum 1 ,
135 .Xr md5 3 ,
136 .Xr ripemd 3 ,
137 .Xr sha 3
138 .Rs
139 .%A R. Rivest
140 .%T The MD5 Message-Digest Algorithm
141 .%O RFC 1321
142 .Re
143 .Rs
144 .%A J. Burrows
145 .%T The Secure Hash Standard
146 .%O FIPS PUB 180-1
147 .Re
148 .Rs
149 .%A D. Eastlake and P. Jones
150 .%T US Secure Hash Algorithm 1
151 .%O RFC 3174
152 .Re
153 .Pp
154 RIPEMD-160 is part of the ISO draft standard
155 .Qq ISO/IEC DIS 10118-3
156 on dedicated hash functions.
157 .Pp
158 Secure Hash Standard (SHS):
159 .Pa http://csrc.nist.gov/publications/fips/fips180-2/fips180-2withchangenotice.pdf .
160 .Pp
161 The RIPEMD-160 page:
162 .Pa http://www.esat.kuleuven.ac.be/~bosselae/ripemd160.html .
163 .Sh ACKNOWLEDGMENTS
164 This program is placed in the public domain for free general use by
165 RSA Data Security.
166 .Pp
167 Support for SHA-1 and RIPEMD-160 has been added by
168 .An Oliver Eikemeier Aq eik@FreeBSD.org .