xref: /freebsd/sbin/md5/md5.1 (revision 84f35b6f86efd004a8f25ef6eecea0f5d02733c4)
1.\" $FreeBSD$
2.Dd June 19, 2021
3.Dt MD5 1
4.Os
5.Sh NAME
6.Nm md5 , sha1 , sha224 , sha256 , sha384 , sha512 , sha512t256 , rmd160 ,
7.Nm skein256 , skein512 , skein1024 ,
8.Nm md5sum , sha1sum , sha224sum , sha256sum , sha384sum , sha512sum ,
9.Nm sha512t256sum , rmd160sum , skein256sum , skein512sum , skein1024sum
10.Nd calculate a message-digest fingerprint (checksum) for a file
11.Sh SYNOPSIS
12.Nm
13.Op Fl pqrtx
14.Op Fl c Ar string
15.Op Fl s Ar string
16.Op Ar
17.Nm md5sum
18.Op Fl pqrtx
19.Op Fl c Ar file
20.Op Fl s Ar string
21.Op Ar
22.Pp
23(All other hashes have the same options and usage.)
24.Sh DESCRIPTION
25The
26.Nm md5 , sha1 , sha224 , sha256 , sha384 , sha512 , sha512t256 , rmd160 ,
27.Nm skein256 , skein512 ,
28and
29.Nm skein1024
30utilities take as input a message of arbitrary length and produce as
31output a
32.Dq fingerprint
33or
34.Dq message digest
35of the input.
36The
37.Nm md5sum , sha1sum , sha224sum , sha256sum , sha384sum , sha512sum ,
38.Nm sha512t256sum , rmd160sum , skein256sum , skein512sum ,
39and
40.Nm skein1024sum
41utilities do the same, but default to the reversed format of
42the
43.Fl r
44flag.
45It is conjectured that it is computationally infeasible to
46produce two messages having the same message digest, or to produce any
47message having a given prespecified target message digest.
48The SHA-224 , SHA-256 , SHA-384 , SHA-512, RIPEMD-160,
49and SKEIN
50algorithms are intended for digital signature applications, where a
51large file must be
52.Dq compressed
53in a secure manner before being encrypted with a private
54(secret)
55key under a public-key cryptosystem such as RSA.
56.Pp
57The MD5 and SHA-1 algorithms have been proven to be vulnerable to practical
58collision attacks and should not be relied upon to produce unique outputs,
59.Em nor should they be used as part of a cryptographic signature scheme.
60As of 2017-03-02, there is no publicly known method to
61.Em reverse
62either algorithm, i.e., to find an input that produces a specific
63output.
64.Pp
65SHA-512t256 is a version of SHA-512 truncated to only 256 bits.
66On 64-bit hardware, this algorithm is approximately 50% faster than SHA-256 but
67with the same level of security.
68The hashes are not interchangeable.
69.Pp
70It is recommended that all new applications use SHA-512 or SKEIN-512
71instead of one of the other hash functions.
72.Pp
73The following options may be used in any combination and must
74precede any files named on the command line.
75The hexadecimal checksum of each file listed on the command line is printed
76after the options are processed.
77.Bl -tag -width indent
78.It Fl b
79Ignored for compatibility with the coreutils
80.Nm -sum
81programs.
82.It Fl c Ar string
83Compare the digest of the file against this string.
84.Pq Note that this option is not yet useful if multiple files are specified.
85This option causes an error in for the
86.Nm -sum
87programs because it check the checksums listed in a file for the coreutils
88.Nm -sum
89programs that is not yet implemented.
90.It Fl s Ar string
91Print a checksum of the given
92.Ar string .
93.It Fl p
94Echo stdin to stdout and append the checksum to stdout.
95.It Fl q
96Quiet mode \(em only the checksum is printed out.
97Overrides the
98.Fl r
99option.
100.It Fl r
101Reverses the format of the output.
102This helps with visual diffs.
103Does nothing
104when combined with the
105.Fl ptx
106options.
107.It Fl t
108Run a built-in time trial.
109For the
110.Nm -sum
111versions, this is a nop for compatibility with coreutils.
112.It Fl x
113Run a built-in test script.
114.El
115.Sh EXIT STATUS
116The
117.Nm md5 , sha1 , sha224 , sha256 , sha512 , sha512t256 , rmd160 ,
118.Nm skein256 , skein512 ,
119and
120.Nm skein1024
121utilities exit 0 on success,
1221 if at least one of the input files could not be read,
123and 2 if at least one file does not have the same hash as the
124.Fl c
125option.
126.Sh EXAMPLES
127Calculate the MD5 checksum of the string
128.Dq Hello .
129.Bd -literal -offset indent
130$ md5 -s Hello
131MD5 ("Hello") = 8b1a9953c4611296a827abf8c47804d7
132.Ed
133.Pp
134Same as above, but note the absence of the newline character in the input
135string:
136.Bd -literal -offset indent
137$ echo -n Hello | md5
1388b1a9953c4611296a827abf8c47804d7
139.Ed
140.Pp
141Calculate the checksum of multiple files reversing the output:
142.Bd -literal -offset indent
143$ md5 -r /boot/loader.conf /etc/rc.conf
144ada5f60f23af88ff95b8091d6d67bef6 /boot/loader.conf
145d80bf36c332dc0fdc479366ec3fa44cd /etc/rc.conf
146.Ed
147.Pp
148Write the digest for
149.Pa /boot/loader.conf
150in a file named
151.Pa digest .
152Then calculate the checksum again and validate it against the checksum string
153extracted from the
154.Pa digest
155file:
156.Bd -literal -offset indent
157$ md5 /boot/loader.conf > digest && md5 -c $(cut -f2 -d= digest) /boot/loader.conf
158MD5 (/boot/loader.conf) = ada5f60f23af88ff95b8091d6d67bef6
159.Ed
160.Pp
161Same as above but comparing the digest against an invalid string
162.Pq Dq randomstring ,
163which results in a failure.
164.Bd -literal -offset indent
165$ md5 -c randomstring /boot/loader.conf
166MD5 (/boot/loader.conf) = ada5f60f23af88ff95b8091d6d67bef6 [ Failed ]
167.Ed
168.Sh SEE ALSO
169.Xr cksum 1 ,
170.Xr md5 3 ,
171.Xr ripemd 3 ,
172.Xr sha 3 ,
173.Xr sha256 3 ,
174.Xr sha384 3 ,
175.Xr sha512 3 ,
176.Xr skein 3
177.Rs
178.%A R. Rivest
179.%T The MD5 Message-Digest Algorithm
180.%O RFC1321
181.Re
182.Rs
183.%A J. Burrows
184.%T The Secure Hash Standard
185.%O FIPS PUB 180-2
186.Re
187.Rs
188.%A D. Eastlake and P. Jones
189.%T US Secure Hash Algorithm 1
190.%O RFC 3174
191.Re
192.Pp
193RIPEMD-160 is part of the ISO draft standard
194.Qq ISO/IEC DIS 10118-3
195on dedicated hash functions.
196.Pp
197Secure Hash Standard (SHS):
198.Pa http://csrc.nist.gov/cryptval/shs.html .
199.Pp
200The RIPEMD-160 page:
201.Pa http://www.esat.kuleuven.ac.be/~bosselae/ripemd160.html .
202.Sh BUGS
203All of the utilities that end in
204.Sq sum
205are intended to be compatible with the GNU coreutils programs.
206However, the long arguments and the
207.Fl -check
208functionality are not provided.
209.Sh ACKNOWLEDGMENTS
210This program is placed in the public domain for free general use by
211RSA Data Security.
212.Pp
213Support for SHA-1 and RIPEMD-160 has been added by
214.An Oliver Eikemeier Aq Mt eik@FreeBSD.org .
215