Add the md[245], sha1 and rmd160 functions to libnbcompat, conditional on their

not being in the host libc.
This will be necessary to make cksum into a host tool.
This commit is contained in:
bjh21 2002-03-31 12:58:54 +00:00
parent 407daa978b
commit bcaedc129c
14 changed files with 392 additions and 308 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: rmd160.c,v 1.5 2001/01/04 03:56:17 lukem Exp $ */
/* $NetBSD: rmd160.c,v 1.6 2002/03/31 12:58:55 bjh21 Exp $ */
/********************************************************************\
*
@ -20,7 +20,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: rmd160.c,v 1.5 2001/01/04 03:56:17 lukem Exp $");
__RCSID("$NetBSD: rmd160.c,v 1.6 2002/03/31 12:58:55 bjh21 Exp $");
#endif /* not lint */
/* header files */
@ -35,6 +35,12 @@ __RCSID("$NetBSD: rmd160.c,v 1.5 2001/01/04 03:56:17 lukem Exp $");
#include <stdlib.h>
#include <string.h>
#if HAVE_CONFIG_H
#include "config.h"
#endif
#if !HAVE_RMD160_H
#if !defined(_KERNEL) && defined(__weak_alias)
__weak_alias(RMD160Transform,_RMD160Transform)
__weak_alias(RMD160Init,_RMD160Init)
@ -449,3 +455,4 @@ RMD160Final(u_char digest[20], RMD160_CTX *context)
}
/************************ end of file rmd160.c **********************/
#endif /* HAVE_RMD160_H */

View File

@ -1,4 +1,4 @@
/* $NetBSD: rmd160hl.c,v 1.5 2001/01/04 03:56:17 lukem Exp $ */
/* $NetBSD: rmd160hl.c,v 1.6 2002/03/31 12:58:55 bjh21 Exp $ */
/* rmd160hl.c
* ----------------------------------------------------------------------------
@ -13,7 +13,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: rmd160hl.c,v 1.5 2001/01/04 03:56:17 lukem Exp $");
__RCSID("$NetBSD: rmd160hl.c,v 1.6 2002/03/31 12:58:55 bjh21 Exp $");
#endif /* not lint */
#include <sys/types.h>
@ -28,6 +28,12 @@ __RCSID("$NetBSD: rmd160hl.c,v 1.5 2001/01/04 03:56:17 lukem Exp $");
#include <stdlib.h>
#include <unistd.h>
#if HAVE_CONFIG_H
#include "config.h"
#endif
#if !HAVE_RMD160_H
#if defined(__weak_alias)
__weak_alias(RMD160End,_RMD160End)
__weak_alias(RMD160File,_RMD160File)
@ -93,3 +99,5 @@ RMD160Data(const u_char *data, size_t len, char *buf)
RMD160Update(&ctx, data, len);
return(RMD160End(&ctx, buf));
}
#endif /* HAVE_RMD160_H */

View File

@ -1,4 +1,4 @@
/* $NetBSD: sha1.c,v 1.7 2001/03/19 03:14:00 simonb Exp $ */
/* $NetBSD: sha1.c,v 1.8 2002/03/31 12:58:55 bjh21 Exp $ */
/* $OpenBSD: sha1.c,v 1.9 1997/07/23 21:12:32 kstailey Exp $ */
/*
@ -30,6 +30,12 @@
#include <sys/sha1.h>
#if HAVE_CONFIG_H
#include "config.h"
#endif
#if !HAVE_SHA1_H
/*
* XXX Kludge until there is resolution regarding mem*() functions
* XXX in the kernel.
@ -277,3 +283,5 @@ void SHA1Final(digest, context)
((context->state[i>>2] >> ((3-(i & 3)) * 8) ) & 255);
}
}
#endif /* HAVE_SHA1_H */

View File

@ -1,4 +1,4 @@
/* $NetBSD: sha1hl.c,v 1.6 2000/07/05 11:35:36 ad Exp $ */
/* $NetBSD: sha1hl.c,v 1.7 2002/03/31 12:58:55 bjh21 Exp $ */
/* sha1hl.c
* ----------------------------------------------------------------------------
@ -23,8 +23,14 @@
#include <stdlib.h>
#include <unistd.h>
#if HAVE_CONFIG_H
#include "config.h"
#endif
#if !HAVE_SHA1_H
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: sha1hl.c,v 1.6 2000/07/05 11:35:36 ad Exp $");
__RCSID("$NetBSD: sha1hl.c,v 1.7 2002/03/31 12:58:55 bjh21 Exp $");
#endif /* LIBC_SCCS and not lint */
#if defined(__weak_alias)
@ -100,3 +106,5 @@ SHA1Data (data, len, buf)
SHA1Update(&ctx, data, len);
return(SHA1End(&ctx, buf));
}
#endif /* HAVE_SHA1_H */

View File

@ -1,4 +1,4 @@
/* $NetBSD: md2c.c,v 1.2 2001/03/20 11:47:44 augustss Exp $ */
/* $NetBSD: md2c.c,v 1.3 2002/03/31 12:58:56 bjh21 Exp $ */
/*
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@ -44,6 +44,12 @@
#include <md2.h>
#include <string.h>
#if HAVE_CONFIG_H
#include "config.h"
#endif
#if !HAVE_MD2_H
/* cut-n-pasted from rfc1319 */
static unsigned char S[256] = {
41, 46, 67, 201, 162, 216, 124, 1, 61, 54, 84, 161, 236, 240, 6,
@ -177,3 +183,5 @@ MD2Transform(context)
/* reset input pointer */
context->i = 16;
}
#endif /* !HAVE_MD2_H */

View File

@ -1,4 +1,4 @@
/* $NetBSD: md2hl.c,v 1.1 2001/03/19 04:13:17 atatat Exp $ */
/* $NetBSD: md2hl.c,v 1.2 2002/03/31 12:58:56 bjh21 Exp $ */
/*
* Written by Jason R. Thorpe <thorpej@netbsd.org>, April 29, 1997.
@ -10,4 +10,10 @@
#include "namespace.h"
#include <md2.h>
#if HAVE_CONFIG_H
#include "config.h"
#endif
#if !HAVE_MD2_H
#include "mdXhl.c"
#endif

View File

@ -1,4 +1,4 @@
/* $NetBSD: md4c.c,v 1.9 2000/01/22 22:19:14 mycroft Exp $ */
/* $NetBSD: md4c.c,v 1.10 2002/03/31 12:58:56 bjh21 Exp $ */
/*
* This file is derived from the RSA Data Security, Inc. MD4 Message-Digest
@ -36,6 +36,12 @@
#include <md4.h>
#include <string.h>
#if HAVE_CONFIG_H
#include "config.h"
#endif
#if !HAVE_MD4_H
typedef unsigned char *POINTER;
typedef u_int16_t UINT2;
typedef u_int32_t UINT4;
@ -310,3 +316,5 @@ Decode(output, input, len)
output[i] = ((UINT4)input[j]) | (((UINT4)input[j+1]) << 8) |
(((UINT4)input[j+2]) << 16) | (((UINT4)input[j+3]) << 24);
}
#endif /* HAVE_MD4_H */

View File

@ -1,4 +1,4 @@
/* $NetBSD: md4hl.c,v 1.2 1998/10/20 17:04:45 kleink Exp $ */
/* $NetBSD: md4hl.c,v 1.3 2002/03/31 12:58:56 bjh21 Exp $ */
/*
* Written by Jason R. Thorpe <thorpej@netbsd.org>, April 29, 1997.
@ -10,4 +10,10 @@
#include "namespace.h"
#include <md4.h>
#if HAVE_CONFIG_H
#include "config.h"
#endif
#if !HAVE_MD4_H
#include "mdXhl.c"
#endif

View File

@ -1,4 +1,4 @@
/* $NetBSD: md5c.c,v 1.16 2000/01/22 22:19:14 mycroft Exp $ */
/* $NetBSD: md5c.c,v 1.17 2002/03/31 12:58:56 bjh21 Exp $ */
/*
* This file is derived from the RSA Data Security, Inc. MD5 Message-Digest
@ -42,6 +42,12 @@
#include <md5.h>
#endif /* _KERNEL || _STANDALONE */
#if HAVE_CONFIG_H
#include "config.h"
#endif
#if !HAVE_MD5_H
#define ZEROIZE(d, l) memset((d), 0, (l))
typedef unsigned char *POINTER;
@ -354,3 +360,5 @@ MD5Transform(state, block)
/* Zeroize sensitive information. */
ZEROIZE((POINTER)(void *)x, sizeof (x));
}
#endif /* HAVE_MD5_H */

View File

@ -1,4 +1,4 @@
/* $NetBSD: md5hl.c,v 1.2 1998/10/20 17:04:45 kleink Exp $ */
/* $NetBSD: md5hl.c,v 1.3 2002/03/31 12:58:56 bjh21 Exp $ */
/*
* Written by Jason R. Thorpe <thorpej@netbsd.org>, April 29, 1997.
@ -10,4 +10,10 @@
#include "namespace.h"
#include <md5.h>
#if HAVE_CONFIG_H
#include "config.h"
#endif
#if !HAVE_MD5_H
#include "mdXhl.c"
#endif

View File

@ -1,12 +1,14 @@
# $NetBSD: Makefile,v 1.8 2002/02/26 22:29:38 tv Exp $
# $NetBSD: Makefile,v 1.9 2002/03/31 12:58:54 bjh21 Exp $
HOSTLIB= nbcompat
SRCS= basename.c dirname.c fgetln.c flock.c fparseln.c \
getmode.c getopt_long.c libyywrap.c pread.c \
pwcache.c pwrite.c pw_scan.c setenv.c \
setgroupent.c setpassent.c setprogname.c snprintf.c \
strlcat.c strlcpy.c strmode.c strsep.c unvis.c vis.c \
getmode.c getopt_long.c libyywrap.c \
md2c.c md2hl.c md4c.c md4hl.c md5c.c md5hl.c pread.c \
pwcache.c pwrite.c pw_scan.c rmd160.c rmd160hl.c setenv.c \
setgroupent.c setpassent.c setprogname.c sha1.c sha1hl.c \
snprintf.c strlcat.c strlcpy.c strmode.c strsep.c \
unvis.c vis.c \
_err.c _errx.c _verr.c _verrx.c _vwarn.c _vwarnx.c \
_warn.c _warnx.c __fts13.c
@ -17,6 +19,8 @@ CPPFLAGS+= -I. -I./include -I${.CURDIR} -DHAVE_CONFIG_H \
-D_FILE_OFFSET_BITS=64
.PATH: ${.CURDIR}/../../lib/libc/gen \
${.CURDIR}/../../lib/libc/hash \
${.CURDIR}/../../lib/libc/md \
${.CURDIR}/../../lib/libc/stdlib \
${.CURDIR}/../../lib/libc/string \
${.CURDIR}/../../lib/libutil \

View File

@ -1,4 +1,4 @@
/* $NetBSD: config.h.in,v 1.11 2002/03/07 18:28:46 tv Exp $ */
/* $NetBSD: config.h.in,v 1.12 2002/03/31 12:58:54 bjh21 Exp $ */
#ifndef __NETBSD_COMPAT_CONFIG_H__
#define __NETBSD_COMPAT_CONFIG_H__
@ -11,10 +11,15 @@
#undef HAVE_FTS_H
#undef HAVE_INTTYPES_H
#undef HAVE_LIBGEN_H
#undef HAVE_MD2_H
#undef HAVE_MD4_H
#undef HAVE_MD5_H
#undef HAVE_NDIR_H
#undef HAVE_NETDB_H
#undef HAVE_MACHINE_BSWAP_H
#undef HAVE_MALLOC_H
#undef HAVE_RMD160_H
#undef HAVE_SHA1_H
#undef HAVE_STDDEF_H
#undef HAVE_STRING_H
#undef HAVE_SYS_DIR_H

575
tools/compat/configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
# $NetBSD: configure.ac,v 1.11 2002/03/07 22:48:07 tv Exp $
# $NetBSD: configure.ac,v 1.12 2002/03/31 12:58:54 bjh21 Exp $
#
# Autoconf definition file for libnbcompat.
#
@ -34,7 +34,8 @@ AC_CHECK_HEADERS(sys/sysmacros.h sys/syslimits.h features.h malloc.h stddef.h st
AC_CHECK_HEADERS(machine/bswap.h sys/cdefs.h sys/featuretest.h \
err.h inttypes.h libgen.h paths.h util.h,,
[test -f include/$ac_header || touch include/$ac_header])
AC_CHECK_HEADERS(rpc/types.h fts.h getopt.h netconfig.h vis.h,,
AC_CHECK_HEADERS(rpc/types.h fts.h getopt.h md2.h md4.h md5.h netconfig.h \
rmd160.h sha1.h vis.h,,
[echo '#include "config.h"' >include/$ac_header.new
echo '#include "'$srcdir/../../include/$ac_header'"' >>include/$ac_header.new
if cmp include/$ac_header.new include/$ac_header >/dev/null 2>&1; then