From owner-svn-src-head@FreeBSD.ORG Sat Nov 1 22:00:47 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 4A9012E5; Sat, 1 Nov 2014 22:00:47 +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 1CA33B4F; Sat, 1 Nov 2014 22:00:47 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id sA1M0kd6072175; Sat, 1 Nov 2014 22:00:46 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id sA1M0kMc072172; Sat, 1 Nov 2014 22:00:46 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201411012200.sA1M0kMc072172@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Garrett Cooper Date: Sat, 1 Nov 2014 22:00:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r273952 - head/contrib/netbsd-tests/lib/libc/hash X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 01 Nov 2014 22:00:47 -0000 Author: ngie Date: Sat Nov 1 22:00:46 2014 New Revision: 273952 URL: https://svnweb.freebsd.org/changeset/base/273952 Log: Port h_hash and t_sha2 to FreeBSD t_sha2 contains dirty copy-paste hacks that need to be fixed with the openssh OpenBSD compat layer Submitted by: pho Modified: head/contrib/netbsd-tests/lib/libc/hash/h_hash.c head/contrib/netbsd-tests/lib/libc/hash/t_sha2.c Modified: head/contrib/netbsd-tests/lib/libc/hash/h_hash.c ============================================================================== --- head/contrib/netbsd-tests/lib/libc/hash/h_hash.c Sat Nov 1 21:30:18 2014 (r273951) +++ head/contrib/netbsd-tests/lib/libc/hash/h_hash.c Sat Nov 1 22:00:46 2014 (r273952) @@ -35,8 +35,13 @@ #include #include #include +#ifdef __NetBSD__ #include +#endif +#ifdef __FreeBSD__ +#include +#endif int mflag, rflag, sflag, tflag; @@ -102,17 +107,32 @@ regress(void) MD5Final(out, &ctx); outlen = 16; } else { +#ifdef __FreeBSD__ + SHA_CTX ctx; + + SHA1_Init(&ctx); + SHA1_Update(&ctx, buf, len); +#else SHA1_CTX ctx; SHA1Init(&ctx); SHA1Update(&ctx, buf, len); +#endif while (!last && fgets((char *)buf, sizeof(buf), stdin) != NULL) { len = strlen((char *)buf); CHOMP(buf, len, last); +#ifdef __FreeBSD__ + SHA1_Update(&ctx, buf, len); +#else SHA1Update(&ctx, buf, len); +#endif } +#ifdef __FreeBSD__ + SHA1_Final(out, &ctx); +#else SHA1Final(out, &ctx); +#endif outlen = 20; } hexdump(out, outlen); Modified: head/contrib/netbsd-tests/lib/libc/hash/t_sha2.c ============================================================================== --- head/contrib/netbsd-tests/lib/libc/hash/t_sha2.c Sat Nov 1 21:30:18 2014 (r273951) +++ head/contrib/netbsd-tests/lib/libc/hash/t_sha2.c Sat Nov 1 22:00:46 2014 (r273952) @@ -36,9 +36,23 @@ __RCSID("$NetBSD: t_sha2.c,v 1.3 2012/09 #include #include +#ifdef __NetBSD__ #include +#endif #include +#ifdef __FreeBSD__ +#include +typedef SHA512_CTX SHA384_CTX; +/* From /usr/src/crypto/openssh/openbsd-compat/sha2.h */ +#define SHA256_DIGEST_LENGTH 32 +#define SHA256_DIGEST_STRING_LENGTH (SHA256_DIGEST_LENGTH * 2 + 1) +#define SHA384_DIGEST_LENGTH 48 +#define SHA384_DIGEST_STRING_LENGTH (SHA384_DIGEST_LENGTH * 2 + 1) +#define SHA512_DIGEST_LENGTH 64 +#define SHA512_DIGEST_STRING_LENGTH (SHA512_DIGEST_LENGTH * 2 + 1) +#endif + ATF_TC(t_sha256); ATF_TC(t_sha384); ATF_TC(t_sha512);