From owner-svn-ports-all@FreeBSD.ORG Mon May 5 01:48:39 2014 Return-Path: Delivered-To: svn-ports-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id C4B75AFB; Mon, 5 May 2014 01:48:39 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A506D1880; Mon, 5 May 2014 01:48:39 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s451md86049745; Mon, 5 May 2014 01:48:39 GMT (envelope-from mi@svn.freebsd.org) Received: (from mi@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s451mcwX049739; Mon, 5 May 2014 01:48:38 GMT (envelope-from mi@svn.freebsd.org) Message-Id: <201405050148.s451mcwX049739@svn.freebsd.org> From: Mikhail Teterin Date: Mon, 5 May 2014 01:48:38 +0000 (UTC) To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r352975 - in head/devel/jech-dht: . files X-SVN-Group: ports-head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-ports-all@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: SVN commit messages for the ports tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 May 2014 01:48:39 -0000 Author: mi Date: Mon May 5 01:48:38 2014 New Revision: 352975 URL: http://svnweb.freebsd.org/changeset/ports/352975 QAT: https://qat.redports.org/buildarchive/r352975/ Log: This library comes with an example program (dht-example). Build and install it... Added: head/devel/jech-dht/files/Makefile.example (contents, props changed) head/devel/jech-dht/files/patch-dht-example (contents, props changed) Modified: head/devel/jech-dht/Makefile head/devel/jech-dht/pkg-plist Modified: head/devel/jech-dht/Makefile ============================================================================== --- head/devel/jech-dht/Makefile Mon May 5 00:59:29 2014 (r352974) +++ head/devel/jech-dht/Makefile Mon May 5 01:48:38 2014 (r352975) @@ -13,6 +13,15 @@ LICENSE= MIT MAKEFILE= ${FILESDIR}/BSDmakefile USE_LDCONFIG= yes +USES= uidfix +MAKE_ENV+= STAGEDIR="${STAGEDIR}" + +post-build: + ${SETENV} ${MAKE_ENV} ${MAKE} -C ${WRKSRC} -f \ + ${FILESDIR}/Makefile.example +post-install: + ${SETENV} ${MAKE_ENV} ${MAKE} -C ${WRKSRC} -f \ + ${FILESDIR}/Makefile.example install pre-su-install: ${MKDIR} ${STAGEDIR}${PREFIX}/include/dht Added: head/devel/jech-dht/files/Makefile.example ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/devel/jech-dht/files/Makefile.example Mon May 5 01:48:38 2014 (r352975) @@ -0,0 +1,7 @@ +PROG= dht-example +NO_MAN= nope, too much to ask + +LDADD= -L. -ldht -lcrypt -lmd +BINDIR= ${STAGEDIR}${PREFIX}/bin + +.include Added: head/devel/jech-dht/files/patch-dht-example ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/devel/jech-dht/files/patch-dht-example Mon May 5 01:48:38 2014 (r352975) @@ -0,0 +1,118 @@ +This allow switching the hashing algorithm (between a crypt(3)-based +one and MD5) at run-time, rather than at compile-time. + + -mi + +--- dht-example.c 2014-05-03 14:37:50.000000000 -0400 ++++ dht-example.c 2014-05-04 21:34:58.000000000 -0400 +@@ -12,4 +12,5 @@ + #include + #include ++#include + #include + #include +@@ -17,4 +18,7 @@ + #include + #include ++#include ++#include ++#include + + #include "dht.h" +@@ -91,4 +95,11 @@ + static unsigned char buf[4096]; + ++typedef void (hashing_method)(void *, int, ++ const void *, int, ++ const void *, int, ++ const void *, int); ++ ++static hashing_method *hasher, crypt_hash, md5_hash; ++ + int + main(int argc, char **argv) +@@ -112,9 +123,8 @@ + memset(&sin6, 0, sizeof(sin6)); + sin6.sin6_family = AF_INET6; +- +- ++ hasher = crypt_hash; + + while(1) { +- opt = getopt(argc, argv, "q46b:i:"); ++ opt = getopt(argc, argv, "q46b:i:m"); + if(opt < 0) + break; +@@ -143,4 +153,6 @@ + id_file = optarg; + break; ++ case 'm': ++ hasher = md5_hash; + default: + goto usage; +@@ -405,6 +417,7 @@ + + usage: +- printf("Usage: dht-example [-q] [-4] [-6] [-i filename] [-b address]...\n" +- " port [address port]...\n"); ++ printf("Usage: dht-example [-q] [-4] [-6] [-i filename] [-b address] [-m]\n" ++ " port [address port]...\n" ++ "(Use -m if you wish to use MD5 digest instead of crypt()-based)"); + exit(1); + } +@@ -420,25 +433,28 @@ + /* We need to provide a reasonably strong cryptographic hashing function. + Here's how we'd do it if we had RSA's MD5 code. */ +-#if 0 +-void +-dht_hash(void *hash_return, int hash_size, ++static void ++md5_hash(void *hash_return, int hash_size, + const void *v1, int len1, + const void *v2, int len2, + const void *v3, int len3) + { +- static MD5_CTX ctx; ++ MD5_CTX ctx; + MD5Init(&ctx); + MD5Update(&ctx, v1, len1); + MD5Update(&ctx, v2, len2); + MD5Update(&ctx, v3, len3); +- MD5Final(&ctx); +- if(hash_size > 16) +- memset((char*)hash_return + 16, 0, hash_size - 16); +- memcpy(hash_return, ctx.digest, hash_size > 16 ? 16 : hash_size); ++ if (hash_size >= 16) { ++ MD5Final(hash_return, &ctx); ++ if(hash_size > 16) ++ memset((char*)hash_return + 16, 0, hash_size - 16); ++ } else { ++ unsigned char digest[16]; ++ MD5Final(digest, &ctx); ++ memcpy(hash_return, digest, hash_size); ++ } + } +-#else + /* But for this example, we might as well use something weaker. */ +-void +-dht_hash(void *hash_return, int hash_size, ++static void ++crypt_hash(void *hash_return, int hash_size, + const void *v1, int len1, + const void *v2, int len2, +@@ -460,5 +476,14 @@ + strncpy(hash_return, crypt(key, "jc"), hash_size); + } +-#endif ++ ++void ++dht_hash(void *hash_return, int hash_size, ++ const void *v1, int len1, ++ const void *v2, int len2, ++ const void *v3, int len3) ++{ ++ hasher(hash_return, hash_size, v1, len1, ++ v2, len2, v3, len3); ++} + + int Modified: head/devel/jech-dht/pkg-plist ============================================================================== --- head/devel/jech-dht/pkg-plist Mon May 5 00:59:29 2014 (r352974) +++ head/devel/jech-dht/pkg-plist Mon May 5 01:48:38 2014 (r352975) @@ -1,5 +1,6 @@ lib/libdht.so.0 lib/libdht.so lib/libdht.a +bin/dht-example include/dht/dht.h @dirrm include/dht