Index: sbin/md5/Makefile =================================================================== --- sbin/md5/Makefile +++ sbin/md5/Makefile @@ -4,27 +4,47 @@ PACKAGE=runtime PROG= md5 -LINKS= ${BINDIR}/md5 ${BINDIR}/rmd160 \ +LINKS= ${BINDIR}/md5 ${BINDIR}/md5sum \ + ${BINDIR}/md5 ${BINDIR}/rmd160 \ + ${BINDIR}/md5 ${BINDIR}/rmd160sum \ ${BINDIR}/md5 ${BINDIR}/sha1 \ ${BINDIR}/md5 ${BINDIR}/sha224 \ + ${BINDIR}/md5 ${BINDIR}/sha224sum \ ${BINDIR}/md5 ${BINDIR}/sha256 \ + ${BINDIR}/md5 ${BINDIR}/sha256sum \ ${BINDIR}/md5 ${BINDIR}/sha384 \ + ${BINDIR}/md5 ${BINDIR}/sha384sum \ ${BINDIR}/md5 ${BINDIR}/sha512 \ + ${BINDIR}/md5 ${BINDIR}/sha512sum \ ${BINDIR}/md5 ${BINDIR}/sha512t256 \ + ${BINDIR}/md5 ${BINDIR}/sha512t256sum \ ${BINDIR}/md5 ${BINDIR}/skein256 \ + ${BINDIR}/md5 ${BINDIR}/skein256sum \ ${BINDIR}/md5 ${BINDIR}/skein512 \ - ${BINDIR}/md5 ${BINDIR}/skein1024 + ${BINDIR}/md5 ${BINDIR}/skein512sum \ + ${BINDIR}/md5 ${BINDIR}/skein1024 \ + ${BINDIR}/md5 ${BINDIR}/skein1024sum -MLINKS= md5.1 rmd160.1 \ +MLINKS= md5.1 md5sum.1 \ + md5.1 rmd160.1 \ + md5.1 rmd160sum.1 \ md5.1 sha1.1 \ md5.1 sha224.1 \ + md5.1 sha224sum.1 \ md5.1 sha256.1 \ + md5.1 sha256sum.1 \ md5.1 sha384.1 \ + md5.1 sha384sum.1 \ md5.1 sha512.1 \ + md5.1 sha512sum.1 \ md5.1 sha512t256.1 \ + md5.1 sha512t256sum.1 \ md5.1 skein256.1 \ + md5.1 skein256sum.1 \ md5.1 skein512.1 \ - md5.1 skein1024.1 + md5.1 skein512sum.1 \ + md5.1 skein1024.1 \ + md5.1 skein1024sum.1 LIBADD= md Index: sbin/md5/md5.1 =================================================================== --- sbin/md5/md5.1 +++ sbin/md5/md5.1 @@ -4,7 +4,9 @@ .Os .Sh NAME .Nm md5 , sha1 , sha224 , sha256 , sha384 , sha512 , sha512t256 , rmd160 , -.Nm skein256 , skein512 , skein1024 +.Nm skein256 , skein512 , skein1024 , +.Nm md5sum , sha1sum , sha224sum , sha256sum , sha384sum , sha512sum , +.Nm sha512t256sum , rmd160sum , skein256sum , skein512sum , skein1024sum .Nd calculate a message-digest fingerprint (checksum) for a file .Sh SYNOPSIS .Nm @@ -26,6 +28,15 @@ or .Dq message digest of the input. +The +.Nm md5sum , sha1sum , sha224sum , sha256sum , sha384sum , sha512sum , +.Nm sha512t256sum , rmd160sum , skein256sum , skein512sum , +and +.Nm skein1024sum +utilities do the same, but default to the reversed format of +the +.Fl r +flag. It is conjectured that it is computationally infeasible to produce two messages having the same message digest, or to produce any message having a given prespecified target message digest. @@ -171,6 +182,13 @@ .Pp The RIPEMD-160 page: .Pa http://www.esat.kuleuven.ac.be/~bosselae/ripemd160.html . +.Sh BUGS +All of the utilities that end in +.Sq sum +are intended to be compatible with the GNU coreutils programs. +However, the long arguments and +.Fl -check +functionality is not provided. .Sh ACKNOWLEDGMENTS This program is placed in the public domain for free general use by RSA Data Security. Index: sbin/md5/md5.c =================================================================== --- sbin/md5/md5.c +++ sbin/md5/md5.c @@ -177,13 +177,27 @@ char buf[HEX_DIGEST_LENGTH]; size_t len; unsigned digest; - const char* progname; + char *progname; if ((progname = strrchr(argv[0], '/')) == NULL) progname = argv[0]; else progname++; + /* + * GNU coreutils has a number of programs named *sum. These produce + * similar results to the BSD version, but in a different format, + * similar to BSD's -r flag. We install links to this program with + * ending 'sum' to proide this compatibility. Check here to see if the + * name of the program ends in 'sum', set the flag and drop the 'sum' so + * the digest lookup works. + */ + len = strlen(progname); + if (len > 3 && strcmp(progname + len - 3, "sum") == 0) { + progname[len - 3] = '\0'; + rflag = 1; + } + for (digest = 0; digest < sizeof(Algorithm)/sizeof(*Algorithm); digest++) if (strcasecmp(Algorithm[digest].progname, progname) == 0) break;