Hi,

On Sun, Dec 22, 2013 at 07:08:53PM -0500, Ted Unangst wrote:
> 1. bigger is better. make a link to sha512.
> 

yay


> 2. simplify md5.c. there's really only two modes.
>

wow md5.c is confusing, I had to go through md5.c twice to understand
why your diff was correct ...

ok gilles@

> 3. add a note to sha256.1 about sha512. I didn't go through and copy
> all the text -- I would hope people can figure it out.
> 
> Index: Makefile
> ===================================================================
> RCS file: /cvs/src/bin/md5/Makefile,v
> retrieving revision 1.11
> diff -u -p -r1.11 Makefile
> --- Makefile  12 Jul 2010 23:16:55 -0000      1.11
> +++ Makefile  22 Dec 2013 23:33:26 -0000
> @@ -5,9 +5,11 @@ SRCS=        crc.c md5.c
>  MAN= cksum.1 md5.1 sha1.1 sha256.1
>  LINKS=       ${BINDIR}/md5 ${BINDIR}/sha1 \
>       ${BINDIR}/md5 ${BINDIR}/sha256 \
> +     ${BINDIR}/md5 ${BINDIR}/sha512 \
>       ${BINDIR}/md5 ${BINDIR}/cksum \
>       ${BINDIR}/md5 ${BINDIR}/sum
>  MLINKS= cksum.1 sum.1
> +MLINKS= sha256.1 sha512.1
>  
>  CPPFLAGS+= -I${.CURDIR}
>  COPTS+=      -Wall -Wconversion -Wmissing-prototypes
> Index: md5.c
> ===================================================================
> RCS file: /cvs/src/bin/md5/md5.c,v
> retrieving revision 1.57
> diff -u -p -r1.57 md5.c
> --- md5.c     21 Nov 2013 15:54:45 -0000      1.57
> +++ md5.c     23 Dec 2013 00:05:27 -0000
> @@ -52,10 +52,7 @@
>  
>  enum program_mode {
>       MODE_MD5,
> -     MODE_SHA1,
> -     MODE_RMD160,
>       MODE_CKSUM,
> -     MODE_SUM
>  } pmode;
>  
>  union ANY_CTX {
> @@ -229,9 +226,6 @@ main(int argc, char **argv)
>  
>       static const char *optstr[5] = {
>               "bcpqrs:tx",
> -             "bcpqrs:tx",
> -             "bcpqrs:tx",
> -             "a:bco:pqrs:tx",
>               "a:bco:pqrs:tx"
>       };
>  
> @@ -240,16 +234,8 @@ main(int argc, char **argv)
>       error = bflag = cflag = pflag = qflag = rflag = tflag = xflag = 0;
>  
>       pmode = MODE_MD5;
> -     if (strcmp(__progname, "md5") == 0)
> -             pmode = MODE_MD5;
> -     else if (strcmp(__progname, "sha1") == 0)
> -             pmode = MODE_SHA1;
> -     else if (strcmp(__progname, "rmd160") == 0)
> -             pmode = MODE_RMD160;
> -     else if (strcmp(__progname, "cksum") == 0)
> +     if (strcmp(__progname, "cksum") == 0 || strcmp(__progname, "sum") == 0)
>               pmode = MODE_CKSUM;
> -     else if (strcmp(__progname, "sum") == 0)
> -             pmode = MODE_SUM;
>  
>       /* Check for -b option early since it changes behavior. */
>       while ((fl = getopt(argc, argv, optstr[pmode])) != -1) {
> @@ -802,13 +788,10 @@ usage(void)
>  {
>       switch (pmode) {
>       case MODE_MD5:
> -     case MODE_SHA1:
> -     case MODE_RMD160:
>               fprintf(stderr, "usage: %s [-bpqrtx] [-c [checklist ...]] "
>                   "[-s string] [file ...]\n", __progname);
>               break;
>       case MODE_CKSUM:
> -     case MODE_SUM:
>               fprintf(stderr, "usage: %s [-bpqrtx] [-a algorithms] "
>                   "[-c [checklist ...]] [-o 1 | 2]\n"
>                   "       %*s [-s string] [file ...]\n",
> Index: sha256.1
> ===================================================================
> RCS file: /cvs/src/bin/md5/sha256.1,v
> retrieving revision 1.5
> diff -u -p -r1.5 sha256.1
> --- sha256.1  8 Jul 2012 15:58:23 -0000       1.5
> +++ sha256.1  23 Dec 2013 00:03:31 -0000
> @@ -30,6 +30,11 @@
>  .Op Fl c Op Ar checklist ...
>  .Op Fl s Ar string
>  .Op Ar
> +.Nm sha512
> +.Op Fl bpqrtx
> +.Op Fl c Op Ar checklist ...
> +.Op Fl s Ar string
> +.Op Ar
>  .Sh DESCRIPTION
>  .Nm
>  takes as input a message of arbitrary length and produces
> @@ -45,6 +50,12 @@ large file must be "compressed" in a sec
>  encrypted with a private (secret) key under a public-key cryptosystem
>  such as
>  .Em RSA .
> +.Pp
> +When invoked as
> +.Nm sha512 ,
> +the
> +.Em SHA-512
> +algorithm is used instead, generating a 512-bit digest.
>  .Pp
>  The options are as follows:
>  .Bl -tag -width Ds
> 

-- 
Gilles Chehade

https://www.poolp.org                                          @poolpOrg

Reply via email to