From owner-svn-src-stable@FreeBSD.ORG Fri Aug 31 00:33:09 2012 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C2D44106566C; Fri, 31 Aug 2012 00:33:09 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A447A8FC18; Fri, 31 Aug 2012 00:33:09 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q7V0X9jO038390; Fri, 31 Aug 2012 00:33:09 GMT (envelope-from delphij@svn.freebsd.org) Received: (from delphij@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q7V0X9SL038386; Fri, 31 Aug 2012 00:33:09 GMT (envelope-from delphij@svn.freebsd.org) Message-Id: <201208310033.q7V0X9SL038386@svn.freebsd.org> From: Xin LI Date: Fri, 31 Aug 2012 00:33:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r239931 - stable/9/sbin/md5 X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 31 Aug 2012 00:33:09 -0000 Author: delphij Date: Fri Aug 31 00:33:09 2012 New Revision: 239931 URL: http://svn.freebsd.org/changeset/base/239931 Log: MFC r238964: Teach md5(1) about sha512. Modified: stable/9/sbin/md5/Makefile stable/9/sbin/md5/md5.1 stable/9/sbin/md5/md5.c Directory Properties: stable/9/sbin/md5/ (props changed) Modified: stable/9/sbin/md5/Makefile ============================================================================== --- stable/9/sbin/md5/Makefile Fri Aug 31 00:11:30 2012 (r239930) +++ stable/9/sbin/md5/Makefile Fri Aug 31 00:33:09 2012 (r239931) @@ -5,11 +5,13 @@ PROG= md5 LINKS= ${BINDIR}/md5 ${BINDIR}/rmd160 \ ${BINDIR}/md5 ${BINDIR}/sha1 \ - ${BINDIR}/md5 ${BINDIR}/sha256 + ${BINDIR}/md5 ${BINDIR}/sha256 \ + ${BINDIR}/md5 ${BINDIR}/sha512 MLINKS= md5.1 rmd160.1 \ md5.1 sha1.1 \ - md5.1 sha256.1 + md5.1 sha256.1 \ + md5.1 sha512.1 WFORMAT?= 1 Modified: stable/9/sbin/md5/md5.1 ============================================================================== --- stable/9/sbin/md5/md5.1 Fri Aug 31 00:11:30 2012 (r239930) +++ stable/9/sbin/md5/md5.1 Fri Aug 31 00:33:09 2012 (r239931) @@ -1,9 +1,9 @@ .\" $FreeBSD$ -.Dd September 7, 2008 +.Dd July 31, 2012 .Dt MD5 1 .Os .Sh NAME -.Nm md5 , sha1 , sha256 , rmd160 +.Nm md5 , sha1 , sha256 , sha512, rmd160 .Nd calculate a message-digest fingerprint (checksum) for a file .Sh SYNOPSIS .Nm md5 @@ -21,6 +21,11 @@ .Op Fl c Ar string .Op Fl s Ar string .Op Ar +.Nm sha512 +.Op Fl pqrtx +.Op Fl c Ar string +.Op Fl s Ar string +.Op Ar .Nm rmd160 .Op Fl pqrtx .Op Fl c Ar string @@ -28,7 +33,7 @@ .Op Ar .Sh DESCRIPTION The -.Nm md5 , sha1 , sha256 +.Nm md5 , sha1 , sha256 , sha512 and .Nm rmd160 utilities take as input a message of arbitrary length and produce as @@ -41,7 +46,7 @@ It is conjectured that it is computation produce two messages having the same message digest, or to produce any message having a given prespecified target message digest. The -.Tn MD5 , SHA-1 , SHA-256 +.Tn MD5 , SHA-1 , SHA-256 , SHA-512 and .Tn RIPEMD-160 algorithms are intended for digital signature applications, where a @@ -104,7 +109,7 @@ Run a built-in test script. .El .Sh EXIT STATUS The -.Nm md5 , sha1 , sha256 +.Nm md5 , sha1 , sha256 , sha512 and .Nm rmd160 utilities exit 0 on success, @@ -115,7 +120,8 @@ and 2 if at least one file does not have .Xr md5 3 , .Xr ripemd 3 , .Xr sha 3 , -.Xr sha256 3 +.Xr sha256 3 , +.Xr sha512 3 .Rs .%A R. Rivest .%T The MD5 Message-Digest Algorithm Modified: stable/9/sbin/md5/md5.c ============================================================================== --- stable/9/sbin/md5/md5.c Fri Aug 31 00:11:30 2012 (r239930) +++ stable/9/sbin/md5/md5.c Fri Aug 31 00:33:09 2012 (r239931) @@ -28,6 +28,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -54,6 +55,7 @@ typedef char *(DIGEST_End)(void *, char extern const char *MD5TestOutput[MDTESTCOUNT]; extern const char *SHA1_TestOutput[MDTESTCOUNT]; extern const char *SHA256_TestOutput[MDTESTCOUNT]; +extern const char *SHA512_TestOutput[MDTESTCOUNT]; extern const char *RIPEMD160_TestOutput[MDTESTCOUNT]; typedef struct Algorithm_t { @@ -78,12 +80,14 @@ typedef union { MD5_CTX md5; SHA1_CTX sha1; SHA256_CTX sha256; + SHA512_CTX sha512; RIPEMD160_CTX ripemd160; } DIGEST_CTX; /* max(MD5_DIGEST_LENGTH, SHA_DIGEST_LENGTH, - SHA256_DIGEST_LENGTH, RIPEMD160_DIGEST_LENGTH)*2+1 */ -#define HEX_DIGEST_LENGTH 65 + SHA256_DIGEST_LENGTH, SHA512_DIGEST_LENGTH, + RIPEMD160_DIGEST_LENGTH)*2+1 */ +#define HEX_DIGEST_LENGTH 129 /* algorithm function table */ @@ -97,6 +101,9 @@ struct Algorithm_t Algorithm[] = { { "sha256", "SHA256", &SHA256_TestOutput, (DIGEST_Init*)&SHA256_Init, (DIGEST_Update*)&SHA256_Update, (DIGEST_End*)&SHA256_End, &SHA256_Data, &SHA256_File }, + { "sha512", "SHA512", &SHA512_TestOutput, (DIGEST_Init*)&SHA512_Init, + (DIGEST_Update*)&SHA512_Update, (DIGEST_End*)&SHA512_End, + &SHA512_Data, &SHA512_File }, { "rmd160", "RMD160", &RIPEMD160_TestOutput, (DIGEST_Init*)&RIPEMD160_Init, (DIGEST_Update*)&RIPEMD160_Update, (DIGEST_End*)&RIPEMD160_End, &RIPEMD160_Data, &RIPEMD160_File } @@ -320,6 +327,17 @@ const char *SHA256_TestOutput[MDTESTCOUN "e6eae09f10ad4122a0e2a4075761d185a272ebd9f5aa489e998ff2f09cbfdd9f" }; +const char *SHA512_TestOutput[MDTESTCOUNT] = { + "cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e", + "1f40fc92da241694750979ee6cf582f2d5d7d28e18335de05abc54d0560e0f5302860c652bf08d560252aa5e74210546f369fbbbce8c12cfc7957b2652fe9a75", + "ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f", + "107dbf389d9e9f71a3a95f6c055b9251bc5268c2be16d6c13492ea45b0199f3309e16455ab1e96118e8a905d5597b72038ddb372a89826046de66687bb420e7c", + "4dbff86cc2ca1bae1e16468a05cb9881c97f1753bce3619034898faa1aabe429955a1bf8ec483d7421fe3c1646613a59ed5441fb0f321389f77f48a879c7b1f1", + "1e07be23c26a86ea37ea810c8ec7809352515a970e9253c26f536cfc7a9996c45c8370583e0a78fa4a90041d71a4ceab7423f19c71b9d5a3e01249f0bebd5894", + "72ec1ef1124a45b047e8b7c75a932195135bb61de24ec0d1914042246e0aec3a2354e093d76f3048b456764346900cb130d2a4fd5dd16abb5e30bcb850dee843", + "e8a835195e039708b13d9131e025f4441dbdc521ce625f245a436dcd762f54bf5cb298d96235e6c6a304e087ec8189b9512cbdf6427737ea82793460c367b9c3" +}; + const char *RIPEMD160_TestOutput[MDTESTCOUNT] = { "9c1185a5c5e9fc54612808977ee8f548b2258d31", "0bdc9d2d256b3ee9daae347be6f4dc835a467ffe",