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