Index: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/hash/h_hash.c =================================================================== --- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/hash/h_hash.c (revision 312135) +++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/hash/h_hash.c (revision 312136) @@ -1,187 +1,166 @@ /* $NetBSD: h_hash.c,v 1.1 2011/01/02 22:03:25 pgoyette Exp $ */ /*- * Copyright (c) 2000 The NetBSD Foundation, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Combined MD5/SHA1 time and regression test. */ #include #include #include #include #include -#ifdef __NetBSD__ #include -#endif -#ifdef __FreeBSD__ -#include -#endif - int mflag, rflag, sflag, tflag; static void usage(void) { (void)fprintf(stderr, "Usage:\t%s -r[ms] < test-file\n" "\t%s -t[ms]\n", getprogname(), getprogname()); exit(1); /* NOTREACHED */ } static void hexdump (unsigned char *buf, int len) { int i; for (i=0; i 0) && \ (buf[len-1] == '\n')) { \ buf[len-1] = '\0'; \ len--; \ last = 1; \ } static void regress(void) { unsigned char buf[1024]; unsigned char out[20]; int len, outlen, last; while (fgets((char *)buf, sizeof(buf), stdin) != NULL) { last = 0; len = strlen((char *)buf); CHOMP(buf, len, last); if (mflag) { MD5_CTX ctx; MD5Init(&ctx); MD5Update(&ctx, buf, len); while (!last && fgets((char *)buf, sizeof(buf), stdin) != NULL) { len = strlen((char *)buf); CHOMP(buf, len, last); MD5Update(&ctx, buf, len); } 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); } } int main(int argc, char **argv) { int ch; while ((ch = getopt(argc, argv, "mrst")) != -1) switch (ch) { case 'm': mflag = 1; break; case 'r': rflag = 1; break; case 's': sflag = 1; break; case 't': tflag = 1; break; case '?': default: usage(); } argc -= optind; argv += optind; if (argc > 0) usage(); if (!(mflag || sflag)) mflag = 1; if ((mflag ^ sflag) != 1) usage(); if ((tflag ^ rflag) != 1) usage(); if (tflag) timetest(); if (rflag) regress(); exit(0); } Index: projects/netbsd-tests-upstream-01-2017/lib/libc/tests/hash/Makefile =================================================================== --- projects/netbsd-tests-upstream-01-2017/lib/libc/tests/hash/Makefile (revision 312135) +++ projects/netbsd-tests-upstream-01-2017/lib/libc/tests/hash/Makefile (revision 312136) @@ -1,40 +1,41 @@ # $FreeBSD$ PACKAGE= tests .include NETBSD_ATF_TESTS_C= .if ${MK_OPENSSL} != "no" # XXX: doesn't compile #NETBSD_ATF_TESTS_C+= hmac_test NETBSD_ATF_TESTS_C+= sha2_test .endif NETBSD_ATF_TESTS_SH= hash_test BINDIR= ${TESTSDIR} PROGS+= h_hash FILESGROUPS+= ${PACKAGE}DATA_FILES ${PACKAGE}DATA_FILESPACKAGE= tests ${PACKAGE}DATA_FILESDIR= ${TESTSDIR}/data ${PACKAGE}DATA_FILES+= data/md5test-in ${PACKAGE}DATA_FILES+= data/md5test-out ${PACKAGE}DATA_FILES+= data/sha1test-in ${PACKAGE}DATA_FILES+= data/sha1test-out ${PACKAGE}DATA_FILES+= data/sha1test2-out LIBADD+= md LIBADD.sha2_test+= crypto +CFLAGS.h_hash+= -I${SRCTOP}/lib/libnetbsd CFLAGS.sha2_test+= -I${SRCTOP}/crypto/openssh/openbsd-compat CFLAGS.sha2_test+= -I${SRCTOP}/crypto/openssh .include "../Makefile.netbsd-tests" .include