From 3711168803d2a69a46e070718b98313079e50a7d Mon Sep 17 00:00:00 2001 From: jmc Date: Fri, 10 Jan 2014 20:14:08 +0000 Subject: [PATCH] catch up to the fact that md5/sha* got merged, and document -c consistently; some style and cleanup tweaks while here ok deraadt --- bin/md5/cksum.1 | 24 +++++++++++------------- bin/md5/md5.1 | 28 +++++++++------------------- bin/md5/md5.c | 15 +++++++-------- 3 files changed, 27 insertions(+), 40 deletions(-) diff --git a/bin/md5/cksum.1 b/bin/md5/cksum.1 index 17d435a1f3e..4f67ce8cb98 100644 --- a/bin/md5/cksum.1 +++ b/bin/md5/cksum.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: cksum.1,v 1.27 2014/01/08 16:12:44 jmc Exp $ +.\" $OpenBSD: cksum.1,v 1.28 2014/01/10 20:14:08 jmc Exp $ .\" .\" Copyright (c) 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -32,7 +32,7 @@ .\" .\" @(#)cksum.1 8.2 (Berkeley) 4/28/95 .\" -.Dd $Mdocdate: January 8 2014 $ +.Dd $Mdocdate: January 10 2014 $ .Dt CKSUM 1 .Os .Sh NAME @@ -42,18 +42,16 @@ .Sh SYNOPSIS .Nm cksum .Bk -words -.Op Fl bpqrtx +.Op Fl bcpqrtx .Op Fl a Ar algorithms -.Op Fl c Op Ar checklist ... .Op Fl h Ar hashfile .Op Fl o Ar 1 | 2 .Op Fl s Ar string .Op Ar .Ek .Nm sum -.Op Fl bpqrtx +.Op Fl bcpqrtx .Op Fl a Ar algorithms -.Op Fl c Op Ar checklist ... .Op Fl h Ar hashfile .Op Fl o Ar 1 | 2 .Op Fl s Ar string @@ -152,10 +150,12 @@ This option is ignored for the and .Ar sysvsum algorithms, which do not use hexadecimal output. -.It Fl c Op Ar checklist ... -Compares all checksums contained in the file -.Ar checklist -with newly computed checksums for the corresponding files. +.It Fl c +If this option is specified, the +.Ar file +options become checklists. +Each checklist should contain hash results in the normal format, +which will be verified against the specified paths. Output consists of the digest used, the file name, and an OK or FAILED for the result of the comparison. This will validate any of the supported checksums. @@ -278,9 +278,7 @@ and utilities exit 0 on success, and >0 if an error occurs. .Sh SEE ALSO -.Xr md5 1 , -.Xr sha1 1 , -.Xr sha256 1 +.Xr md5 1 .Pp The default calculation is identical to that given in pseudo-code in the following ACM article: diff --git a/bin/md5/md5.1 b/bin/md5/md5.1 index a9492136ee2..32b1d98c01a 100644 --- a/bin/md5/md5.1 +++ b/bin/md5/md5.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: md5.1,v 1.39 2014/01/10 18:52:22 lteo Exp $ +.\" $OpenBSD: md5.1,v 1.40 2014/01/10 20:14:08 jmc Exp $ .\" .\" Copyright (c) 2003, 2004, 2006 Todd C. Miller .\" @@ -26,22 +26,22 @@ .Nd calculate a message digest (checksum) for a file .Sh SYNOPSIS .Nm md5 -.Op Fl bcprtx +.Op Fl bcpqrtx .Op Fl h Ar hashfile .Op Fl s Ar string .Op Ar .Nm sha1 -.Op Fl bcprtx +.Op Fl bcpqrtx .Op Fl h Ar hashfile .Op Fl s Ar string .Op Ar .Nm sha256 -.Op Fl bcprtx +.Op Fl bcpqrtx .Op Fl h Ar hashfile .Op Fl s Ar string .Op Ar .Nm sha512 -.Op Fl bcprtx +.Op Fl bcpqrtx .Op Fl h Ar hashfile .Op Fl s Ar string .Op Ar @@ -97,18 +97,9 @@ by 10 for each additional flag. .It Fl x Runs a built-in test script. .El -.Pp -The checksum of each file listed on the command line is printed -after the options are processed. -.Pp -The -.Nm -command is shorthand for: -.Bd -literal -offset indent -$ cksum -a md5 -.Ed .Sh EXIT STATUS -.Ex -std md5 +These utilities exit 0 on success, +and \*(Gt0 if an error occurs. .Sh SEE ALSO .Xr cksum 1 .Sh STANDARDS @@ -136,8 +127,7 @@ $ cksum -a md5 .%O FIPS PUB 180-2 .Re .Sh CAVEATS -Since collisions have been found for -.Em MD5 , +Since collisions have been found for MD5, the use of -.Xr sha256 1 +.Nm sha256 is recommended instead. diff --git a/bin/md5/md5.c b/bin/md5/md5.c index 5fc9e5ed9de..1b9e38a816b 100644 --- a/bin/md5/md5.c +++ b/bin/md5/md5.c @@ -1,4 +1,4 @@ -/* $OpenBSD: md5.c,v 1.66 2014/01/10 18:51:05 lteo Exp $ */ +/* $OpenBSD: md5.c,v 1.67 2014/01/10 20:14:08 jmc Exp $ */ /* * Copyright (c) 2001,2003,2005-2007,2010,2013,2014 @@ -816,16 +816,15 @@ usage(void) { #if !defined(SMALL) if (strcmp(__progname, "cksum") == 0 || strcmp(__progname, "sum") == 0) - fprintf(stderr, "usage: %s [-bpqrtx] [-a algorithms] " - "[-c [checklist ...]] [-h hashfile]\n" - " %*s [-o 1 | 2] [-s string] [file ...]\n", - __progname, (int)strlen(__progname), ""); + fprintf(stderr, "usage: %s [-bcpqrtx] [-a algorithms] " + "[-h hashfile] [-o 1 | 2] [-s string]\n" + " [file ...]\n", + __progname); else #endif /* !defined(SMALL) */ fprintf(stderr, "usage:" - "\t%s [-bprtx] [-h hashfile] [-s string] [file ...]\n" - "\t%s [-q] -c [checklist ...]\n", - __progname, __progname); + "\t%s [-bcpqrtx] [-h hashfile] [-s string] [file ...]\n", + __progname); exit(EXIT_FAILURE); } -- 2.20.1