History log of /freebsd-current/sbin/md5/md5.c
Revision Date Author Comments
# 702f133f 20-Feb-2024 Dag-Erling Smørgrav <des@FreeBSD.org>

md5: Untabify declarations.

MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: imp, allanjude, markj
Differential Revision: https://reviews.freebsd.org/D43991


# c05533d9 20-Feb-2024 Dag-Erling Smørgrav <des@FreeBSD.org>

md5: Fix GNU check mode.

Fixes: 9b20849bc5f1b500f2de7aeca77f0e6556069bbb
MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: imp, allanjude, markj
Differential Revision: https://reviews.freebsd.org/D43990


# 4db7ca24 20-Feb-2024 Dag-Erling Smørgrav <des@FreeBSD.org>

md5: Fix Perl mode long options.

MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: imp, allanjude, markj
Differential Revision: https://reviews.freebsd.org/D43989


# 17d5b027 16-Feb-2024 Dag-Erling Smørgrav <des@FreeBSD.org>

md5: Clean up input stream rights.

Keep it simple, caph_limit_stdio() and fileargs_fopen() already take
care of everything for us.

MFC after: 1 week
Reviewed by: markj, jhb, emaste
Differential Revision: https://reviews.freebsd.org/D43897


# 5b44edb4 16-Feb-2024 Dag-Erling Smørgrav <des@FreeBSD.org>

md5: Ignore files in string and passthrough mode.

MFC after: 1 week
Reviewed by: allanjude, markj
Differential Revision: https://reviews.freebsd.org/D43871


# 72ee91fe 16-Feb-2024 Dag-Erling Smørgrav <des@FreeBSD.org>

md5: Accept "-" as alias for stdin.

(based on a patch by jhb)

MFC after: 1 week
PR: 276915
Reported by: Hannes Hauswedell <h2+fbsdports@fsfe.org>
Reviewed by: allanjude, markj, jhb, emaste
Differential Revision: https://reviews.freebsd.org/D43870


# 9b20849b 03-Jan-2024 Ricardo Branco <rbranco@suse.de>

md5: Enter capability mode earlier

Reviewed by: markj
MFC after: 1 month
Pull Request: https://github.com/freebsd/freebsd-src/pull/988


# 32e86a82 24-Nov-2023 Warner Losh <imp@FreeBSD.org>

sbin: Automated cleanup of cdefs and other formatting

Apply the following automated changes to try to eliminate
no-longer-needed sys/cdefs.h includes as well as now-empty
blank lines in a row.

Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/
Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/
Remove /\n+#if.*\n#endif.*\n+/
Remove /^#if.*\n#endif.*\n/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/

Sponsored by: Netflix


# 1d386b48 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

Remove $FreeBSD$: one-line .c pattern

Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/


# 2ea65afb 07-Aug-2023 Mariusz Zaborski <oshogbo@FreeBSD.org>

md5: extend capabilites

In 4849767cb16a4, we did a large refactor of the md5(1) source code.
One of them is that instead of reading data using read(2) syscall, we
are using binary stream input (fread(3)).

fread(3) requires additional Capsicum capabilities:
sha256 CAP operation requires CAP_FSTAT, descriptor holds CAP_READ
sha256 RET fstat -1 errno 93 Capabilities insufficient

Reviewed by: des
Differential Revision: https://reviews.freebsd.org/D41348


# 27e74c8f 11-May-2023 Dag-Erling Smørgrav <des@FreeBSD.org>

md5: Add missing <errno.h>.

Sponsored by: Klara, Inc.
Reviewed by: yuripv
Differential Revision: https://reviews.freebsd.org/D40051


# facc2136 09-May-2023 Dag-Erling Smørgrav <des@FreeBSD.org>

md5: Don't increment a bool.

Fixes: 4849767cb16a
MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D40020


# 90eaf4b2 09-May-2023 Dag-Erling Smørgrav <des@FreeBSD.org>

md5: Include <osreldate.h> for __FreeBSD_version.

It is usually provided by <sys/param.h>, but not when bootstrapping.

Fixes: 4849767cb16a
MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: yuripv, kevans
Differential Revision: https://reviews.freebsd.org/D40018


# f1ceb05a 09-May-2023 Dag-Erling Smørgrav <des@FreeBSD.org>

md5: Fix input error check.

Fixes: 4849767cb16a
MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: tsoome, kevans, lwhsu
Differential Revision: https://reviews.freebsd.org/D40017


# 4849767c 08-May-2023 Dag-Erling Smørgrav <des@FreeBSD.org>

md5: Improve compatibility.

* Overhaul the GNU compatibility mode to more closely emulate what the GNU tools do.

* Add a Perl compatibility mode which emulates the shasum tool that ships with Perl. This is currently not installed.

* Overhaul the tests.

Sponsored by: Klara, Inc.
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D39446


# 8d78a0d3 12-Feb-2023 Kyle Evans <kevans@FreeBSD.org>

md5: fix *sum -c with missing files

If we fail to open one of the files in the file listing, we still need
to advance `rec` along with `argv` so that the checksum we're checking
against lines up with the file we're hashing.

Tests added both for the -c flag, as well as the -b and -t modes of
the *sum programs.

PR: 267722
Reviewed by: emaste (earlier version)
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D37374


# 2768d705 06-Feb-2023 Dag-Erling Smørgrav <des@FreeBSD.org>

libmd / md5: Add SHA-512/224.

While there, remove .Tn from man pages.

Also remove an obsolete comment about the 80386.

MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: kevans, allanjude
Differential Revision: https://reviews.freebsd.org/D38373


# 9f3aa538 26-Jul-2022 Stefan Eßer <se@FreeBSD.org>

sbin/md5.c: fix -q -c for BSD style versions

The BSD style commands (with names not ending in "sum") ignored the -c
options and the passed digest value when invoked with -q.

The man page stated that -q causes only the calculated digest to be
printed, but did not consider the case of both the -q and -c being
used in combination.

Since there is no warning that -c will be ignored when the -q option
is used, users night (and did) expect that the exit code would reflect
the matching of the calculated digest and the argument passed with -c.

This update implements and documents this expected behavior.

PR: 265461
Reported by: Dmitrij <bugs.freebsd@1fff.net>
MFC after: 2 weeks


# b33d1898 29-Jun-2021 Stefan Eßer <se@FreeBSD.org>

md5: Improve compatibility with coreutils and format fix

The previous changes that added support for the coreutils -c option
modified the output generated by passing -r to match that of the
coreutils versions. The difference is that coreutils separates the
hash from the file name by two blanks " " (or a blank followed by
an asterisk " *" with the -b option denoting).

While most scripts or users will not notice the difference, it might
be considered a violation of POLA and this commit reverts the change
for the non-sum programs. These will print a single blank " " as the
separator, as they die before the previous commit.

In order to still generate output that is identical to that of the
coreutils programs, this commit generates the " " or " *" separator
used by them for the -sum versions, depending on the presence of the
-b option.

MFC after: 3 days


# cab31e0e 25-Jun-2021 Jessica Clarke <jrtc27@FreeBSD.org>

md5: Fix cross-build after c2870e576bd2

On macOS and Linux the current set of headers do not end up pulling in
sys/param.h, causing MAXPATHLEN to not be defined and the build to fail.


# c2870e57 25-Jun-2021 Stefan Eßer <se@FreeBSD.org>

sbin/md5: improve compatibility with coreutils -c option

The -c option expects a digest file in either BSD or coreutils format.

The output for matched and mismatched files is identical to that
of the coreutils version.

The review of these changes included test cases that have already
been committed for the functionality that existed before.
Another test script is added to cover the coreutils compatible
extension implemented by this patch.

This commit contains a tests/Makefile that has been cleaned up
compared to the review version, using an implicit rule to apply the
TESTBASE path at build time (and the scripts have been renamed to
have an extension of .SH instead of .sh to trigger this rule).

Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D30812


# d0ea5e46 20-May-2021 Warner Losh <imp@FreeBSD.org>

md5: portability fix -- include stdbool.h explicitly

stdbool.h needs to be included to use type bool variables. Due to
namespace pollution, this gets brought in on FreeBSD, but not on
other systems. Include it explicilty.

Noticed by: arichards@
Sponsored by: Netflix


# 086feed8 19-May-2021 Warner Losh <imp@FreeBSD.org>

md5: Create md5sum, etc compatible programs

On Linux, there's a similar set of programs to ours, but that end in the
letters 'sum'. These act basically like FreeBSD versions run with the -r
option. Add code so that when the program ends in 'sum' you get the
linux -r behavior. This is enough to make most things that use sha*sum
work correctly (the -c / --check options, as well as the long args are
not implemented). When running with the -sum programs, ignore -t instead
of running internal speed tests and make -c an error.

Reviewed by: sef, and kp and allanjude (earlier version)
Relnotes: yes
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D30309


# af9de844 23-Jul-2020 Ed Maste <emaste@FreeBSD.org>

md5: return non-zero if built-in tests (-x) fail

MFC after: 1 week
Sponsored by: The FreeBSD Foundation


# 0bc6f34c 19-Jun-2020 Allan Jude <allanjude@FreeBSD.org>

md5(1): fix -c flag to work with input on stdin

Previously, the -p and -c flags were ignored when reading from stdin
Additionally, -s and -c can be used together now.

PR: 247295
Reviewed by: kevans
MFC after: 2 weeks
Relnotes: yes
Sponsored by: Klara Inc.
Differential Revision: https://reviews.freebsd.org/D25362


# 5ddaf845 19-Apr-2019 Poul-Henning Kamp <phk@FreeBSD.org>

Close filedescriptors when done with them.


# 377421df 04-Nov-2018 Mariusz Zaborski <oshogbo@FreeBSD.org>

capsicum: use a new capsicum helpers in tools

Use caph_{rights,ioctls,fcntls}_limit to simplify the code.


# 4635180e 23-Aug-2018 Alex Richardson <arichardson@FreeBSD.org>

Allow bootstrapping md5 on Linux, MacOS and FreeBSD < 12

In order to build on a Linux host we need to bootstrap md5 since the Linux
md5sum command produces output in a different format.

Reviewed By: emaste
Approved By: brooks (mentor)
Differential Revision: https://reviews.freebsd.org/D16846


# 8ff3cdd1 09-Jul-2018 Conrad Meyer <cem@FreeBSD.org>

Integrate SHA2-224 with userspace components

The double compilation of the kernel sources in libmd and libcrypt is
baffling, but add yet another define hack to prevent duplicate symbols.

Add documentation and SHA2-224 test cases to libmd.

Integrate with the md5(1) command, document, and add more test cases;
self-tests pass.


# 7672a014 19-Jun-2018 Mariusz Zaborski <oshogbo@FreeBSD.org>

Convert `cap_enter() < 0 && errno != ENOSYS` to `caph_enter() < 0`.

No functional change intended.


# aa677d07 23-May-2018 Eitan Adler <eadler@FreeBSD.org>

md5: perform compare case-insenstive

md5 generates a md5 hash lowercase, but it might be provided in
uppercase. Allow this.

PR: 205598
Reported by: ohauer
MFC After: 2 weeks


# 2c818119 19-Oct-2016 Ed Maste <emaste@FreeBSD.org>

md5: enter capability on last fd or when acting as a filter

Reviewed by: allanjude, cem
MFC after: 2 months
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D8271


# 1780e407 28-May-2016 Allan Jude <allanjude@FreeBSD.org>

Implement SHA-512 truncated (224 and 256 bits)

This implements SHA-512/256, which generates a 256 bit hash by
calculating the SHA-512 then truncating the result. A different initial
value is used, making the result different from the first 256 bits of
the SHA-512 of the same input. SHA-512 is ~50% faster than SHA-256 on
64bit platforms, so the result is a faster 256 bit hash.

The main goal of this implementation is to enable support for this
faster hashing algorithm in ZFS. The feature was introduced into ZFS
in r289422, but is disconnected because SHA-512/256 support was missing.
A further commit will enable it in ZFS.

This is the follow on to r292782

Reviewed by: cem
Sponsored by: ScaleEngine Inc.
Differential Revision: https://reviews.freebsd.org/D6061


# 7a3f5d11 27-Dec-2015 Allan Jude <allanjude@FreeBSD.org>

Replace sys/crypto/sha2/sha2.c with lib/libmd/sha512c.c

cperciva's libmd implementation is 5-30% faster

The same was done for SHA256 previously in r263218

cperciva's implementation was lacking SHA-384 which I implemented, validated against OpenSSL and the NIST documentation

Extend sbin/md5 to create sha384(1)

Chase dependancies on sys/crypto/sha2/sha2.{c,h} and replace them with sha512{c.c,.h}

Reviewed by: cperciva, des, delphij
Approved by: secteam, bapt (mentor)
MFC after: 2 weeks
Sponsored by: ScaleEngine Inc.
Differential Revision: https://reviews.freebsd.org/D3929


# a2f9ce8a 31-Mar-2015 Xin LI <delphij@FreeBSD.org>

Constify.

Suggested by: rdivacky
MFC after: 2 weeks


# 11500c4e 27-Mar-2015 Xin LI <delphij@FreeBSD.org>

Fix remaining warnings.

MFC after: 2 weeks


# 16945d89 26-Mar-2015 Xin LI <delphij@FreeBSD.org>

- Correct type for checkAgainst.
- Staticify flags that are not used outside the file scope.

PR: bin/193471
Submitted by: Robert Sprowson <webpages sprow.co.uk>
MFC after: 2 weeks


# edd4c16f 31-Jul-2012 Xin LI <delphij@FreeBSD.org>

Teach md5(1) about sha512.

MFC after: 1 month


# cf0badf0 09-May-2012 Eitan Adler <eadler@FreeBSD.org>

Document the -c option in --help output

PR: bin/167463
Submitted by: "Bryan Drewery" <bryan@shatow.net>
Approved by: cperciva
MFC after: 3 days


# 74525359 13-Nov-2011 Eitan Adler <eadler@FreeBSD.org>

- add "check" option to MD5 and friends to compare files against known hash.

PR: bin/146541
Submitted by: eadler
Reviewed by: jhell@dataix.net
Approved by: secteam (cperciva)
Approved by: cperciva
MFC after: 3 weeks


# a7d5f7eb 19-Oct-2010 Jamie Gritton <jamie@FreeBSD.org>

A new jail(8) with a configuration file, to replace the work currently done
by /etc/rc.d/jail.


# fe0506d7 09-Mar-2010 Marcel Moolenaar <marcel@FreeBSD.org>

Create the altix project branch. The altix project will add support
for the SGI Altix 350 to FreeBSD/ia64. The hardware used for porting
is a two-module system, consisting of a base compute module and a
CPU expansion module. SGI's NUMAFlex architecture can be an excellent
platform to test CPU affinity and NUMA-aware features in FreeBSD.


# d7f03759 19-Oct-2008 Ulf Lilleengen <lulf@FreeBSD.org>

- Import the HEAD csup code which is the basis for the cvsmode work.


# 1f0e597d 01-Sep-2008 Kevin Lo <kevlo@FreeBSD.org>

Use RUSAGE_SELF for the current process instead of hardcoded value


# 9c6c6249 07-Feb-2008 David E. O'Brien <obrien@FreeBSD.org>

style(9) (verifed no-change in .o's)


# 25a14196 17-Jan-2006 Poul-Henning Kamp <phk@FreeBSD.org>

Fix an 11 year old mistake: Let the hash functions take a void* instead
of unsigned char* argument.


# 186c183c 09-Mar-2005 Colin Percival <cperciva@FreeBSD.org>

In light of the recent 2^69 operation collision-finding attack on SHA1,
add support for SHA256.

Tested on: i386, sparc64
Tested using: NIST test vectors, built-in tests
X-MFC-after: 5.4-RELEASE


# 7b89c134 22-Jun-2004 Oliver Eikemeier <eik@FreeBSD.org>

fix handling of an unknown progeam name

Noticed by: Joshua Goodall <joshua@roughtrade.net>
Approved by: ru


# cb49d42b 11-Jun-2004 Oliver Eikemeier <eik@FreeBSD.org>

Add sha1 and rmd160 checksum tools.

Since the algorithms are already supported in libmd,
the size increase is small when a dynamic root is used.

Approved by: joerg, ru
MFC after: 2 weeks


# 5758d949 02-Nov-2003 Stefan Eßer <se@FreeBSD.org>

Set exit code to 1 in case at least one of the input files
could not be opened.


# c69284ca 03-May-2003 David E. O'Brien <obrien@FreeBSD.org>

Use __FBSDID() to quiet GCC 3.3 warnings.


# ed4edda0 13-Feb-2003 Mike Silbersack <silby@FreeBSD.org>

Improvements to md5.c so that it uses getrusage to time
benchmarks, and prints out results in float format.


# bbe70882 26-Jan-2003 Mike Silbersack <silby@FreeBSD.org>

Change the -x option so that it does an actual REAL test of
the correctness of this program. Previously, it printed out
the MD5 values of some test strings, but did not tell you
if they were correct or not!


# dc015e16 19-Dec-2001 Poul-Henning Kamp <phk@FreeBSD.org>

Fix
md5 -q -s foo
to not expect input on stdin after hashing the string.

MFC after: 1 week


# 484a709a 27-Oct-2001 Matthew Dillon <dillon@FreeBSD.org>

Add missing cast for improper time_t use in computation.


# 40dbfd1a 29-Jun-2001 Dag-Erling Smørgrav <des@FreeBSD.org>

Fix include ordering breakage from rev. 1.23.

Please-read-style(9): dd


# 085d2345 25-Jun-2001 Ruslan Ermilov <ru@FreeBSD.org>

Only checksum stdin if nothing has been checksummed yet.

PR: bin/28386


# cafefe8c 24-Jun-2001 Dima Dorfman <dd@FreeBSD.org>

Include missing header files which define functions for which gcc has
builtins (e.g., exit, strcmp).


# 05fe5d56 22-May-2001 Ruslan Ermilov <ru@FreeBSD.org>

Fix argument processing.
Make this compile with WARNS=2.

PR: bin/27524
MFC after: 3 days


# 42ea2a63 08-Nov-2000 David E. O'Brien <obrien@FreeBSD.org>

Update usage().

Submitted by: nectar


# 2963da13 03-Dec-1999 David E. O'Brien <obrien@FreeBSD.org>

Add -q quite mode.


# 73fd2717 11-Nov-1999 David E. O'Brien <obrien@FreeBSD.org>

Make `-r -s' also match the BSDI output.


# 53151fdd 09-Nov-1999 David E. O'Brien <obrien@FreeBSD.org>

Change the "-r" output format to match BSDI's default output format.


# 9e18a3bd 06-Nov-1999 David E. O'Brien <obrien@FreeBSD.org>

Add a new "-r" (right) option that reverses the order a filename and the
hash is printed. This aids visual diffs.


# 7f3dea24 27-Aug-1999 Peter Wemm <peter@FreeBSD.org>

$Id$ -> $FreeBSD$


# b76bf6fc 20-Jul-1999 Bill Fumerola <billf@FreeBSD.org>

Since we are using strlen() let's assign it to the correct type and
include the proper header.


# 93606d6e 01-May-1999 Kris Kennaway <kris@FreeBSD.org>

Fixes for -t option:

* Don't buffer "Digesting..." output - flush it immediately.
* Increase the number of repetitions by a factor of 100, and the block size by
a factor of 10 so as to give meaningful results on modern machines (108
seconds on my P120, and ~26 seconds on a P-II 350).

PR: bin/10604
Submitted by: Stanislav Shalunov <shalunov@lynxhub.lz.att.com>


# 23b5892f 06-Jul-1998 Philippe Charnier <charnier@FreeBSD.org>

Correct use of .Nm. Spelling. Add rcsid, remove unused #includes, use err(3).


# 9a9791af 29-Dec-1997 Steve Price <steve@FreeBSD.org>

Fix a few style nits from previous commit.

Submitted by: Bruce Evans <bde@zeta.org.au>


# 716847a6 28-Dec-1997 Steve Price <steve@FreeBSD.org>

Get md5(1) to use getopt(3). Also some minor -Wall cleaning
while here.

PR: 5387
Submitted by: Matthew Hunt <mph@pobox.com>


# c0ec1f37 22-Feb-1997 Peter Wemm <peter@FreeBSD.org>

Revert $FreeBSD$ to $Id$


# 1d0847d3 16-Jan-1997 Poul-Henning Kamp <phk@FreeBSD.org>

Trivial fix for braino.
Reviewed by: phk
Submitted by: Martin Ibert <mib@ppe.bb-data.de>


# 1130b656 14-Jan-1997 Jordan K. Hubbard <jkh@FreeBSD.org>

Make the long-awaited change from $Id$ to $FreeBSD$

This will make a number of things easier in the future, as well as (finally!)
avoiding the Id-smashing problem which has plagued developers for so long.

Boy, I'm glad we're not using sup anymore. This update would have been
insane otherwise.


# 1ab6205c 25-Oct-1996 Bruce Evans <bde@FreeBSD.org>

Moved #include of <sys/types.h> earlier so that this compiles when
<stdio.h> doesn't (bogusly) include <sys/types.h>.

Cleaned up #includes.


# 116805fd 12-Jul-1995 Poul-Henning Kamp <phk@FreeBSD.org>

Fix to match new API. Fixes memory leak, faster.


# 5ebc7e62 30-May-1995 Rodney W. Grimes <rgrimes@FreeBSD.org>

Remove trailing whitespace.


# c8006b15 25-Feb-1995 Poul-Henning Kamp <phk@FreeBSD.org>

oops.


# 23b406e1 25-Feb-1995 Poul-Henning Kamp <phk@FreeBSD.org>

Add a '-p' option to md5. This will save some time in generation of the
ctm deltas.


# 9b1fd0e5 19-Feb-1995 Poul-Henning Kamp <phk@FreeBSD.org>

Clean this file up so it is readable...


# e1645093 29-Oct-1994 Paul Traina <pst@FreeBSD.org>

Incorproate version of md5 placed into public domain by RSA.