From: tedu Date: Mon, 23 Dec 2013 23:00:38 +0000 (+0000) Subject: install a link as sha512. simplify program internals; there are only X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=934e389785252e62e7cb65e9dadfac0131e84b0e;p=openbsd install a link as sha512. simplify program internals; there are only two modes. ok deraadt gilles jca --- diff --git a/bin/md5/Makefile b/bin/md5/Makefile index 38daaa89146..3f44c55ef2c 100644 --- a/bin/md5/Makefile +++ b/bin/md5/Makefile @@ -1,13 +1,15 @@ -# $OpenBSD: Makefile,v 1.11 2010/07/12 23:16:55 tedu Exp $ +# $OpenBSD: Makefile,v 1.12 2013/12/23 23:00:38 tedu Exp $ PROG= md5 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 diff --git a/bin/md5/md5.c b/bin/md5/md5.c index e2417e1940c..56228e37ede 100644 --- a/bin/md5/md5.c +++ b/bin/md5/md5.c @@ -1,4 +1,4 @@ -/* $OpenBSD: md5.c,v 1.57 2013/11/21 15:54:45 deraadt Exp $ */ +/* $OpenBSD: md5.c,v 1.58 2013/12/23 23:00:38 tedu Exp $ */ /* * Copyright (c) 2001,2003,2005-2006 Todd C. Miller @@ -52,10 +52,7 @@ enum program_mode { MODE_MD5, - MODE_SHA1, - MODE_RMD160, MODE_CKSUM, - MODE_SUM } pmode; union ANY_CTX { @@ -227,11 +224,8 @@ main(int argc, char **argv) int fl, error, base64; int bflag, cflag, pflag, rflag, tflag, xflag; - static const char *optstr[5] = { + static const char *optstr[2] = { "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", diff --git a/bin/md5/sha256.1 b/bin/md5/sha256.1 index 76ff987c583..937766d787b 100644 --- a/bin/md5/sha256.1 +++ b/bin/md5/sha256.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: sha256.1,v 1.5 2012/07/08 15:58:23 naddy Exp $ +.\" $OpenBSD: sha256.1,v 1.6 2013/12/23 23:00:38 tedu Exp $ .\" .\" Copyright (c) 2003, 2004, 2006 Todd C. Miller .\" @@ -18,7 +18,7 @@ .\" Agency (DARPA) and Air Force Research Laboratory, Air Force .\" Materiel Command, USAF, under agreement number F39502-99-1-0512. .\" -.Dd $Mdocdate: July 8 2012 $ +.Dd $Mdocdate: December 23 2013 $ .Dt SHA256 1 .Os .Sh NAME @@ -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 @@ -46,6 +51,12 @@ 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 .It Fl b