add md5 on ssen-platform-2 branch

git-svn-id: https://svn.macports.org/repository/macports/branches/ssen-platform-2/base@2945 d073be05-634f-4543-b044-5fe20cf6d1d6
This commit is contained in:
Shantonu Sen
2003-06-22 02:29:39 +00:00
parent ab942a3ff4
commit 1e9ee85e20
34 changed files with 14484 additions and 0 deletions
+2
View File
@@ -0,0 +1,2 @@
The digest utility was written by Alistair G. Crooks (agc@netbsd.org).
Stoned Elipot (seb@pbox.org) made this "portable" version.
+30
View File
@@ -0,0 +1,30 @@
/*
* Copyright (c) 2001 Alistair G. Crooks. 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.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Alistair G. Crooks.
* 4. The name of the author may not be used to endorse or promote
* products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
*/
+5
View File
@@ -0,0 +1,5 @@
This utility is a wrapper for the md5(3), sha1(3) and rmd160(3)
routines.
The utility is linked statically, so that it can be used without any
shared libraries installed on the system.
+182
View File
@@ -0,0 +1,182 @@
Basic Installation
==================
These are generic installation instructions.
The `configure' shell script attempts to guess correct values for
various system-dependent variables used during compilation. It uses
those values to create a `Makefile' in each directory of the package.
It may also create one or more `.h' files containing system-dependent
definitions. Finally, it creates a shell script `config.status' that
you can run in the future to recreate the current configuration, a file
`config.cache' that saves the results of its tests to speed up
reconfiguring, and a file `config.log' containing compiler output
(useful mainly for debugging `configure').
If you need to do unusual things to compile the package, please try
to figure out how `configure' could check whether to do them, and mail
diffs or instructions to the address given in the `README' so they can
be considered for the next release. If at some point `config.cache'
contains results you don't want to keep, you may remove or edit it.
The file `configure.in' is used to create `configure' by a program
called `autoconf'. You only need `configure.in' if you want to change
it or regenerate `configure' using a newer version of `autoconf'.
The simplest way to compile this package is:
1. `cd' to the directory containing the package's source code and type
`./configure' to configure the package for your system. If you're
using `csh' on an old version of System V, you might need to type
`sh ./configure' instead to prevent `csh' from trying to execute
`configure' itself.
Running `configure' takes awhile. While running, it prints some
messages telling which features it is checking for.
2. Type `make' to compile the package.
3. Optionally, type `make check' to run any self-tests that come with
the package.
4. Type `make install' to install the programs and any data files and
documentation.
5. You can remove the program binaries and object files from the
source code directory by typing `make clean'. To also remove the
files that `configure' created (so you can compile the package for
a different kind of computer), type `make distclean'. There is
also a `make maintainer-clean' target, but that is intended mainly
for the package's developers. If you use it, you may have to get
all sorts of other programs in order to regenerate files that came
with the distribution.
Compilers and Options
=====================
Some systems require unusual options for compilation or linking that
the `configure' script does not know about. You can give `configure'
initial values for variables by setting them in the environment. Using
a Bourne-compatible shell, you can do that on the command line like
this:
CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure
Or on systems that have the `env' program, you can do it like this:
env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure
Compiling For Multiple Architectures
====================================
You can compile the package for more than one kind of computer at the
same time, by placing the object files for each architecture in their
own directory. To do this, you must use a version of `make' that
supports the `VPATH' variable, such as GNU `make'. `cd' to the
directory where you want the object files and executables to go and run
the `configure' script. `configure' automatically checks for the
source code in the directory that `configure' is in and in `..'.
If you have to use a `make' that does not supports the `VPATH'
variable, you have to compile the package for one architecture at a time
in the source code directory. After you have installed the package for
one architecture, use `make distclean' before reconfiguring for another
architecture.
Installation Names
==================
By default, `make install' will install the package's files in
`/usr/local/bin', `/usr/local/man', etc. You can specify an
installation prefix other than `/usr/local' by giving `configure' the
option `--prefix=PATH'.
You can specify separate installation prefixes for
architecture-specific files and architecture-independent files. If you
give `configure' the option `--exec-prefix=PATH', the package will use
PATH as the prefix for installing programs and libraries.
Documentation and other data files will still use the regular prefix.
In addition, if you use an unusual directory layout you can give
options like `--bindir=PATH' to specify different values for particular
kinds of files. Run `configure --help' for a list of the directories
you can set and what kinds of files go in them.
If the package supports it, you can cause programs to be installed
with an extra prefix or suffix on their names by giving `configure' the
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
Optional Features
=================
Some packages pay attention to `--enable-FEATURE' options to
`configure', where FEATURE indicates an optional part of the package.
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
is something like `gnu-as' or `x' (for the X Window System). The
`README' should mention any `--enable-' and `--with-' options that the
package recognizes.
For packages that use the X Window System, `configure' can usually
find the X include and library files automatically, but if it doesn't,
you can use the `configure' options `--x-includes=DIR' and
`--x-libraries=DIR' to specify their locations.
Specifying the System Type
==========================
There may be some features `configure' can not figure out
automatically, but needs to determine by the type of host the package
will run on. Usually `configure' can figure that out, but if it prints
a message saying it can not guess the host type, give it the
`--host=TYPE' option. TYPE can either be a short name for the system
type, such as `sun4', or a canonical name with three fields:
CPU-COMPANY-SYSTEM
See the file `config.sub' for the possible values of each field. If
`config.sub' isn't included in this package, then this package doesn't
need to know the host type.
If you are building compiler tools for cross-compiling, you can also
use the `--target=TYPE' option to select the type of system they will
produce code for and the `--build=TYPE' option to select the type of
system on which you are compiling the package.
Sharing Defaults
================
If you want to set default values for `configure' scripts to share,
you can create a site shell script called `config.site' that gives
default values for variables like `CC', `cache_file', and `prefix'.
`configure' looks for `PREFIX/share/config.site' if it exists, then
`PREFIX/etc/config.site' if it exists. Or, you can set the
`CONFIG_SITE' environment variable to the location of the site script.
A warning: not all `configure' scripts look for a site script.
Operation Controls
==================
`configure' recognizes the following options to control how it
operates.
`--cache-file=FILE'
Use and save the results of the tests in FILE instead of
`./config.cache'. Set FILE to `/dev/null' to disable caching, for
debugging `configure'.
`--help'
Print a summary of the options to `configure', and exit.
`--quiet'
`--silent'
`-q'
Do not print messages saying which checks are being made. To
suppress all normal output, redirect it to `/dev/null' (any error
messages will still be shown).
`--srcdir=DIR'
Look for the package's source code in directory DIR. Usually
`configure' can determine that directory automatically.
`--version'
Print the version of Autoconf used to generate the `configure'
script, and exit.
`configure' also accepts some other, not widely useful, options.
+166
View File
@@ -0,0 +1,166 @@
# $Id: Makefile.in,v 1.1.4.1 2003/06/22 02:29:38 ssen Exp $
@SET_MAKE@
SHELL = @SHELL@
VPATH=@srcdir@
PACKAGE_NAME= @PACKAGE_NAME@
PACKAGE_VERSION= @PACKAGE_VERSION@
srcdir = @srcdir@
VPATH = @srcdir@
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
mandir = @mandir@
top_builddir = .
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
mkinstalldirs = $(SHELL) $(srcdir)/mkinstalldirs
install_sh = $(SHELL) $(srcdir)/install-sh
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_HEADER = $(INSTALL_DATA)
transform = @program_transform_name@
host_alias = @host_alias@
host_triplet = @host@
CANONICAL_HOST = @CANONICAL_HOST@
CC = @CC@
CCLD= $(CC)
LIBS= @LIBS@
CPPFLAGS= @CPPFLAGS@
DEFS= @DEFS@ -I. -I@srcdir@ -DHOST=\"$(CANONICAL_HOST)\" -DVERSION=\"$(PACKAGE_VERSION)\"
CFLAGS= @CFLAGS@
LDFLAGS= @LDFLAGS@
LINK= $(CCLD) $(CFLAGS) $(LDFLAGS) -o $@
COMPILE= $(CC) $(DEFS) $(CPPFLAGS) $(CFLAGS)
digest_OBJS = digest.o md5c.o rmd160.o rmd160hl.o sha2.o sha2hl.o \
md5hl.o sha1.o sha1hl.o
bits_OBJS = bits.o
md5_OBJS = md5main.o md5c.o md5hl.o
SRCS= digest.c md5c.c rmd160.c rmd160hl.c sha2.c sha2hl.c md5hl.c sha1.c \
sha1hl.c bits.c md5.h rmd160.h sha1.h sha2.h md5main.c
DISTFILES= $(SRCS) AUTHORS COPYING INSTALL Makefile.in NEWS README aclocal.m4 \
config.guess config.h.in config.sub configure configure.ac install-sh \
missing mkinstalldirs regress.sh
.c.o:
$(COMPILE) -c $< -o $@
all: md5
digest-types.h: bits
./bits digest-types.h
bits: bits.o
$(LINK) $(bits_OBJS) $(LIBS)
digest: $(digest_OBJS)
$(LINK) $(digest_OBJS) $(LIBS)
md5: $(md5_OBJS)
$(LINK) $(md5_OBJS) $(LIBS)
check: digest
@SHELL@ $(srcdir)/regress.sh
digest.o: digest-types.h
md5main.o: digest-types.h
md5c.o: digest-types.h
rmd160.o: digest-types.h
rmd160hl.o: digest-types.h
sha2.o: digest-types.h
sha2hl.o: digest-types.h
md5hl.o: digest-types.h
sha1.o: digest-types.h
sha1hl.o: digest-types.h
clean:
rm -f *.o digest bits digest-types.h md5
distclean: clean
rm -f Makefile config.h
rm -f config.status config.cache config.log
maintainer-clean: distclean
rm -f configure config.h.in
install: md5
$(mkinstalldirs) $(DESTDIR)$(bindir)
@f=`echo md5|sed '$(transform)'`; \
echo "$(INSTALL_PROGRAM) md5 $(DESTDIR)$(bindir)/$$f"; \
$(INSTALL_PROGRAM) md5 $(DESTDIR)$(bindir)/$$f
uninstall:
@f=`echo md5|sed '$(transform)'`; \
echo " rm -f $(DESTDIR)$(bindir)/$$f"; \
rm -f $(DESTDIR)$(bindir)/$$f
GZIP_ENV= --best
TAR= tar
distdir= $(PACKAGE_NAME)-$(PACKAGE_VERSION)
distdir: $(DISTFILES)
-chmod -R a+w $(distdir) >/dev/null 2>&1; rm -rf $(distdir)
mkdir $(distdir)
@for file in $(DISTFILES); do \
if test -f $$file; then d=.; else d=$(srcdir); fi; \
dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
if test "$$dir" != "$$file" && test "$$dir" != "."; then \
$(mkinstalldirs) "$(distdir)/$$dir"; \
fi; \
if test -d $$d/$$file; then \
cp -pR $$d/$$file $(distdir) \
|| exit 1; \
else \
test -f $(distdir)/$$file \
|| cp -p $$d/$$file $(distdir)/$$file \
|| exit 1; \
fi; \
done
-find $(distdir) -type d ! -perm -777 -exec chmod a+rwx {} \; -o \
! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
! -type d ! -perm -400 -exec chmod a+r {} \; -o \
! -type d ! -perm -444 -exec $(SHELL) $(install_sh) -c -m a+r {} {} \; \
|| chmod -R a+r $(distdir)
dist: distdir
$(TAR) chof - $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
-chmod -R a+w $(distdir) >/dev/null 2>&1; rm -rf $(distdir)
distcheck: dist
-chmod -R a+w $(distdir) > /dev/null 2>&1; rm -rf $(distdir)
GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(TAR) xf -
chmod -R a-w $(distdir); chmod a+w $(distdir)
mkdir $(distdir)/=build
mkdir $(distdir)/=inst
chmod a-w $(distdir)
dc_install_base=`CDPATH=: && cd $(distdir)/=inst && pwd` \
&& cd $(distdir)/=build \
&& ../configure --srcdir=.. --prefix=$$dc_install_base \
&& $(MAKE) \
&& $(MAKE) check \
&& $(MAKE) install \
&& $(MAKE) uninstall \
&& (test `find $$dc_install_base -type f -print | wc -l` -le 1 \
|| (echo "Error: files left after uninstall" 1>&2; \
exit 1) ) \
&& $(MAKE) dist \
&& $(MAKE) distclean \
&& rm -f $(distdir).tar.gz \
&& (test `find . -type f -print | wc -l` -eq 0 \
|| (echo "Error: files left after distclean" 1>&2; \
exit 1) )
-chmod -R a+w $(distdir) > /dev/null 2>&1; rm -rf $(distdir)
@echo "$(distdir).tar.gz is ready for distribution" | \
sed 'h;s/./=/g;p;x;p;x'
+29
View File
@@ -0,0 +1,29 @@
* 2002/09/23
Bugfix only for OSF1 4.x. Thanks to Simon Burge <simonb@netbsd.org>
for catching it.
* version 20010807.1
Sources synced with NetBSD digest version 20010807: minor bug fix.
Automake is no more used.
Memset/bzero, memcpy,bcopy usage cleanup.
Version number is now <NetBSD-version-number>.<portable-version-number>
this could help various things...
* version 20010709p1
Sources synced with NetBSD digest version 20010709: portability fixes.
Tested on :
hppa1.1-hp-hpux11.00 with gcc 2.92.2
hppa1.1-hp-hpux11.00 with HP92453-01 A.11.01.21505.GP HP C Compiler
hppa-hp-hpux10.20 with gcc 2.95.1
hppa-hp-hpux10.20 with HP92453-01 A.10.32.20 HP C Compiler
sparc-sun-solaris2.8 with gcc 2.95.2
sparc-sun-solaris2.7 with gcc 2.95.2
sparc-unknown-netbsdelf1.5.1 with egcs-1.1.2 (bundled cc)
sparc-unknown-netbsd1.2.1 with gcc 2.7.2 (bundled cc)
i386-unknown-openbsd2.9 with gcc 2.95.2 (bundled cc)
i386-unknown-freebsd4.1.1 with gcc 2.95.2 (bundled cc)
* version 20010320p1
First release based on NetBSD digest version 20010320.
+2
View File
@@ -0,0 +1,2 @@
@comment $NetBSD: PLIST,v 1.1 2002/10/31 22:25:19 agc Exp $
bin/digest
+3
View File
@@ -0,0 +1,3 @@
The digest utility is a wrapper for the md5, sha1, sha256, sha384, sha512 and
rmd160 message digest algorithms. It first appeared in NetBSD 1.6.
This "portable" version is available at ftp://ftp.pbox.org/pub/.
+33
View File
@@ -0,0 +1,33 @@
dnl $Id: aclocal.m4,v 1.1.4.1 2003/06/22 02:29:38 ssen Exp $
dnl From heimdal sources
dnl Id: c-attribute.m4,v 1.2 1999/03/01 09:52:23 joda Exp
dnl
dnl
dnl Test for __attribute__
dnl
AC_DEFUN(AC_C___ATTRIBUTE__, [
AC_MSG_CHECKING(for __attribute__)
AC_CACHE_VAL(ac_cv___attribute__, [
AC_TRY_COMPILE([
#include <stdlib.h>
],
[
static void foo(void) __attribute__ ((noreturn));
static void
foo(void)
{
exit(1);
}
],
ac_cv___attribute__=yes,
ac_cv___attribute__=no)])
if test "$ac_cv___attribute__" = "yes"; then
AC_DEFINE(HAVE___ATTRIBUTE__, 1, [define if your compiler has __attribute__])
fi
AC_MSG_RESULT($ac_cv___attribute__)
])
+184
View File
@@ -0,0 +1,184 @@
/*
* Copyright (c) 1997 - 2000 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* 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.
*
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE 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 INSTITUTE 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.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
__RCSID("$Id: bits.c,v 1.1.4.1 2003/06/22 02:29:38 ssen Exp $");
#endif
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#define BITSIZE(TYPE) \
{ \
int b = 0; TYPE x = 1, zero = 0; char *pre = "u"; \
char tmp[128], tmp2[128]; \
while(x){ x <<= 1; b++; if(x < zero) pre=""; } \
if(b >= len){ \
int tabs; \
sprintf(tmp, "%sint%d_t" , pre, len); \
sprintf(tmp2, "typedef %s %s;", #TYPE, tmp); \
tabs = 5 - strlen(tmp2) / 8; \
fprintf(f, "%s", tmp2); \
while(tabs-- > 0) fprintf(f, "\t"); \
fprintf(f, "/* %2d bits */\n", b); \
return; \
} \
}
#ifndef HAVE___ATTRIBUTE__
#define __attribute__(x)
#endif
static void
try_signed(FILE *f, int len) __attribute__ ((unused));
static void
try_unsigned(FILE *f, int len) __attribute__ ((unused));
static int
print_bt(FILE *f, int flag) __attribute__ ((unused));
static void
try_signed(FILE *f, int len)
{
BITSIZE(signed char);
BITSIZE(short);
BITSIZE(int);
BITSIZE(long);
#ifdef HAVE_LONG_LONG
BITSIZE(long long);
#endif
fprintf(f, "/* There is no %d bit type */\n", len);
}
static void
try_unsigned(FILE *f, int len)
{
BITSIZE(unsigned char);
BITSIZE(unsigned short);
BITSIZE(unsigned int);
BITSIZE(unsigned long);
#ifdef HAVE_LONG_LONG
BITSIZE(unsigned long long);
#endif
fprintf(f, "/* There is no %d bit type */\n", len);
}
int main(int argc, char **argv)
{
FILE *f;
char *fn, *hb;
if(argc < 2){
fn = "bits.h";
hb = "__BITS_H__";
f = stdout;
} else {
char *p;
fn = argv[1];
hb = malloc(strlen(fn) + 5);
sprintf(hb, "__%s__", fn);
for(p = hb; *p; p++){
if(!isalnum((unsigned char)*p))
*p = '_';
}
f = fopen(argv[1], "w");
}
fprintf(f, "/* %s -- this file was generated for %s by\n", fn, HOST);
fprintf(f, " %*s %s */\n\n", (int)strlen(fn), "",
"$Id: bits.c,v 1.1.4.1 2003/06/22 02:29:38 ssen Exp $");
fprintf(f, "#ifndef %s\n", hb);
fprintf(f, "#define %s\n", hb);
fprintf(f, "\n");
#ifdef HAVE_SYS_TYPES_H
fprintf(f, "#include <sys/types.h>\n");
#endif
#ifdef HAVE_INTTYPES_H
fprintf(f, "#include <inttypes.h>\n");
#endif
#ifdef HAVE_SYS_BITYPES_H
fprintf(f, "#include <sys/bitypes.h>\n");
#endif
#ifdef HAVE_BIND_BITYPES_H
fprintf(f, "#include <bind/bitypes.h>\n");
#endif
#ifdef HAVE_NETINET_IN6_MACHTYPES_H
fprintf(f, "#include <netinet/in6_machtypes.h>\n");
#endif
fprintf(f, "\n");
#ifndef HAVE_INT8_T
try_signed (f, 8);
#endif /* HAVE_INT8_T */
#ifndef HAVE_INT16_T
try_signed (f, 16);
#endif /* HAVE_INT16_T */
#ifndef HAVE_INT32_T
try_signed (f, 32);
#endif /* HAVE_INT32_T */
#ifndef HAVE_INT64_T
try_signed (f, 64);
#endif /* HAVE_INT64_T */
#ifndef HAVE_UINT8_T
try_unsigned (f, 8);
#endif /* HAVE_UINT8_T */
#ifndef HAVE_UINT16_T
try_unsigned (f, 16);
#endif /* HAVE_UINT16_T */
#ifndef HAVE_UINT32_T
try_unsigned (f, 32);
#endif /* HAVE_UINT32_T */
#ifndef HAVE_UINT64_T
try_unsigned (f, 64);
#endif /* HAVE_UINT64_T */
#define X(S) fprintf(f, "typedef uint" #S "_t u_int" #S "_t;\n")
#ifndef HAVE_U_INT8_T
X(8);
#endif /* HAVE_U_INT8_T */
#ifndef HAVE_U_INT16_T
X(16);
#endif /* HAVE_U_INT16_T */
#ifndef HAVE_U_INT32_T
X(32);
#endif /* HAVE_U_INT32_T */
#ifndef HAVE_U_INT64_T
X(64);
#endif /* HAVE_U_INT64_T */
fprintf(f, "#endif /* %s */\n", hb);
return 0;
}
+1327
View File
File diff suppressed because it is too large Load Diff
+278
View File
@@ -0,0 +1,278 @@
/* config.h.in. Generated from configure.ac by autoheader. */
/* Define to 1 if you have the `bcopy' function. */
#undef HAVE_BCOPY
/* Define to 1 if you have the `bzero' function. */
#undef HAVE_BZERO
/* Define to 1 if you have the declaration of `strerror_r', and to 0 if you
don't. */
#undef HAVE_DECL_STRERROR_R
/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */
#undef HAVE_DOPRNT
/* Define to 1 if you have the <errno.h> header file. */
#undef HAVE_ERRNO_H
/* Define to 1 if you have the <fcntl.h> header file. */
#undef HAVE_FCNTL_H
/* Define to 1 if the system has the type `int16_t'. */
#undef HAVE_INT16_T
/* Define to 1 if the system has the type `int32_t'. */
#undef HAVE_INT32_T
/* Define to 1 if the system has the type `int64_t'. */
#undef HAVE_INT64_T
/* Define to 1 if the system has the type `int8_t'. */
#undef HAVE_INT8_T
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
/* Define to 1 if you have the <locale.h> header file. */
#undef HAVE_LOCALE_H
/* Define to 1 if the system has the type `long long'. */
#undef HAVE_LONG_LONG
/* Define to 1 if you have the <machine/endian.h> header file. */
#undef HAVE_MACHINE_ENDIAN_H
/* Define to 1 if your system has a GNU libc compatible `malloc' function, and
to 0 otherwise. */
#undef HAVE_MALLOC
/* Define to 1 if you have the `memcpy' function. */
#undef HAVE_MEMCPY
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
/* Define to 1 if you have the `memset' function. */
#undef HAVE_MEMSET
/* Define to 1 if you have the `setlocale' function. */
#undef HAVE_SETLOCALE
/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
/* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
/* Define to 1 if you have the `strerror_r' function. */
#undef HAVE_STRERROR_R
/* Define to 1 if you have the <strings.h> header file. */
#undef HAVE_STRINGS_H
/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H
/* Define to 1 if you have the <sys/bitypes.h> header file. */
#undef HAVE_SYS_BITYPES_H
/* Define to 1 if you have the <sys/byteorder.h> header file. */
#undef HAVE_SYS_BYTEORDER_H
/* Define to 1 if you have the <sys/cdefs.h> header file. */
#undef HAVE_SYS_CDEFS_H
/* Define to 1 if you have the <sys/endian.h> header file. */
#undef HAVE_SYS_ENDIAN_H
/* Define to 1 if you have the <sys/file.h> header file. */
#undef HAVE_SYS_FILE_H
/* Define to 1 if you have the <sys/param.h> header file. */
#undef HAVE_SYS_PARAM_H
/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H
/* Define to 1 if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H
/* Define to 1 if the system has the type `uint16_t'. */
#undef HAVE_UINT16_T
/* Define to 1 if the system has the type `uint32_t'. */
#undef HAVE_UINT32_T
/* Define to 1 if the system has the type `uint64_t'. */
#undef HAVE_UINT64_T
/* Define to 1 if the system has the type `uint8_t'. */
#undef HAVE_UINT8_T
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* Define to 1 if the system has the type `u_int16_t'. */
#undef HAVE_U_INT16_T
/* Define to 1 if the system has the type `u_int32_t'. */
#undef HAVE_U_INT32_T
/* Define to 1 if the system has the type `u_int64_t'. */
#undef HAVE_U_INT64_T
/* Define to 1 if the system has the type `u_int8_t'. */
#undef HAVE_U_INT8_T
/* Define to 1 if you have the `vprintf' function. */
#undef HAVE_VPRINTF
/* define if your compiler has __attribute__ */
#undef HAVE___ATTRIBUTE__
/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT
/* Define to the full name of this package. */
#undef PACKAGE_NAME
/* Define to the full name and version of this package. */
#undef PACKAGE_STRING
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME
/* Define to the version of this package. */
#undef PACKAGE_VERSION
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
/* Define to 1 if strerror_r returns char *. */
#undef STRERROR_R_CHAR_P
/* Define to 1 if your processor stores words with the most significant byte
first (like Motorola and SPARC, unlike Intel and VAX). */
#undef WORDS_BIGENDIAN
/* Define to empty if `const' does not conform to ANSI C. */
#undef const
/* Define to rpl_malloc if the replacement function should be used. */
#undef malloc
/* Define to `unsigned' if <sys/types.h> does not define. */
#undef size_t
#ifndef HAVE___ATTRIBUTE__
# define __attribute__(x)
#endif
#ifdef HAVE_SYS_CDEFS_H
#include <sys/cdefs.h>
#endif
#ifndef __IDSTRING
# define __IDSTRING(name,string) \
static const char name[] __attribute__((__unused__)) = string
#endif
#ifndef __RCSID
# define __RCSID(_s) __IDSTRING(rcsid,_s)
#endif
#ifndef __COPYRIGHT
# define __COPYRIGHT(_s) __IDSTRING(copyright,_s)
#endif
#ifndef __P
# if defined(__STDC__) || defined(__cplusplus)
# define __P(protos) protos /* full-blown ANSI C */
# else
# define __P(protos) () /* traditional C preprocessor */
# endif
#endif
#ifndef __CONCAT
# if defined(__STDC__) || defined(__cplusplus)
# define __CONCAT(x,y) x ## y
# else
# define __CONCAT(x,y) x/**/y
# endif
#endif
#ifndef __BEGIN_DECLS
# if defined(__cplusplus)
# define __BEGIN_DECLS extern "C" {
# else
# define __BEGIN_DECLS
# endif
#endif
#ifndef __END_DECLS
# if defined(__cplusplus)
# define __END_DECLS };
# else
# define __END_DECLS
# endif
#endif
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#ifdef HAVE_SYS_ENDIAN_H
#include <sys/endian.h>
#endif
#ifdef HAVE_MACHINE_ENDIAN_H
#include <machine/endian.h>
#endif
#ifdef HAVE_SYS_BYTEORDER_H
#include <sys/byteorder.h>
#endif
#ifndef LITTLE_ENDIAN
# define LITTLE_ENDIAN 1234
#endif
#ifndef BIG_ENDIAN
# define BIG_ENDIAN 4321
#endif
#ifndef BYTE_ORDER
# if defined(_BIG_ENDIAN)
# define BYTE_ORDER BIG_ENDIAN
# elif defined(_LITTE_ENDIAN)
# define BYTE_ORDER LITTLE_ENDIAN
# elif defined(WORDS_BIGENDIAN)
# define BYTE_ORDER BIG_ENDIAN
# else
# define BYTE_ORDER LITTLE_ENDIAN
# endif
#endif
#if defined(HAVE_MEMSET)
#define MEMSET_BZERO(p,l) memset((p), 0, (l))
#else
# if defined(HAVE_BZERO)
#define MEMSET_BZERO(p,l) bzero((p), (l))
# else
#error You need either memset or bzero
# endif
#endif
#if defined(HAVE_MEMCPY)
#define MEMCPY_BCOPY(d,s,l) memcpy((d), (s), (l))
#else
# if defined(HAVE_BCOPY)
#define MEMCPY_BCOPY(d,s,l) bcopy((s), (d), (l))
# else
#error You need either memcpy or bcopy
# endif
#endif
Vendored Executable
+1450
View File
File diff suppressed because it is too large Load Diff
Vendored Executable
+6455
View File
File diff suppressed because it is too large Load Diff
+170
View File
@@ -0,0 +1,170 @@
dnl $Id: configure.ac,v 1.1.4.1 2003/06/22 02:29:39 ssen Exp $
dnl Process this file with autoconf to produce a configure script.
AC_PREREQ(2.57)
AC_INIT([nbsd-digest],[20021220],[seb@pbox.org])
AC_CONFIG_SRCDIR([digest.c])
AC_CONFIG_HEADER(config.h)
AC_ARG_PROGRAM
AC_CANONICAL_HOST
CANONICAL_HOST=$host
AC_SUBST(CANONICAL_HOST)
# Checks for programs.
AC_PROG_MAKE_SET
AC_PROG_AWK
AC_PROG_CC
AC_PROG_INSTALL
AC_PROG_LN_S
AUTOCONF=${AUTOCONF-"$srcdir/missing --run autoconf"}
AC_SUBST(AUTOCONF)
AUTOHEADER=${AUTOHEADER-"$srcdir/missing --run autoheader"}
AC_SUBST(AUTOHEADER)
dnl Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS([errno.h fcntl.h inttypes.h locale.h machine/endian.h])
AC_CHECK_HEADERS([sys/bitypes.h sys/byteorder.h sys/cdefs.h])
AC_CHECK_HEADERS([sys/endian.h sys/file.h sys/param.h])
dnl Checks for typedefs, structures, and compiler characteristics.
AC_C___ATTRIBUTE__
AC_C_CONST
AC_TYPE_SIZE_T
AC_CHECK_TYPES([long long, int8_t, int16_t, int32_t, int64_t, u_int8_t, u_int16_t, u_int32_t, u_int64_t, uint8_t, uint16_t, uint32_t, uint64_t],[],[],
[#if STDC_HEADERS
#include <stdlib.h>
#include <stddef.h>
#endif
#ifdef HAVE_INTTYPES_H
#include <inttypes.h>
#endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_BITYPES_H
#include <sys/bitypes.h>
#endif])
AC_C_BIGENDIAN
# Checks for library functions.
AC_FUNC_MALLOC
AC_FUNC_STRERROR_R
AC_FUNC_VPRINTF
AC_CHECK_FUNCS([bcopy bzero memset memcpy setlocale])
#
AH_BOTTOM([
#ifndef HAVE___ATTRIBUTE__
# define __attribute__(x)
#endif
#ifdef HAVE_SYS_CDEFS_H
#include <sys/cdefs.h>
#endif
#ifndef __IDSTRING
# define __IDSTRING(name,string) \
static const char name[] __attribute__((__unused__)) = string
#endif
#ifndef __RCSID
# define __RCSID(_s) __IDSTRING(rcsid,_s)
#endif
#ifndef __COPYRIGHT
# define __COPYRIGHT(_s) __IDSTRING(copyright,_s)
#endif
#ifndef __P
# if defined(__STDC__) || defined(__cplusplus)
# define __P(protos) protos /* full-blown ANSI C */
# else
# define __P(protos) () /* traditional C preprocessor */
# endif
#endif
#ifndef __CONCAT
# if defined(__STDC__) || defined(__cplusplus)
# define __CONCAT(x,y) x ## y
# else
# define __CONCAT(x,y) x/**/y
# endif
#endif
#ifndef __BEGIN_DECLS
# if defined(__cplusplus)
# define __BEGIN_DECLS extern "C" {
# else
# define __BEGIN_DECLS
# endif
#endif
#ifndef __END_DECLS
# if defined(__cplusplus)
# define __END_DECLS };
# else
# define __END_DECLS
# endif
#endif
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#ifdef HAVE_SYS_ENDIAN_H
#include <sys/endian.h>
#endif
#ifdef HAVE_MACHINE_ENDIAN_H
#include <machine/endian.h>
#endif
#ifdef HAVE_SYS_BYTEORDER_H
#include <sys/byteorder.h>
#endif
#ifndef LITTLE_ENDIAN
# define LITTLE_ENDIAN 1234
#endif
#ifndef BIG_ENDIAN
# define BIG_ENDIAN 4321
#endif
#ifndef BYTE_ORDER
# if defined(_BIG_ENDIAN)
# define BYTE_ORDER BIG_ENDIAN
# elif defined(_LITTE_ENDIAN)
# define BYTE_ORDER LITTLE_ENDIAN
# elif defined(WORDS_BIGENDIAN)
# define BYTE_ORDER BIG_ENDIAN
# else
# define BYTE_ORDER LITTLE_ENDIAN
# endif
#endif
#if defined(HAVE_MEMSET)
#define MEMSET_BZERO(p,l) memset((p), 0, (l))
#else
# if defined(HAVE_BZERO)
#define MEMSET_BZERO(p,l) bzero((p), (l))
# else
#error You need either memset or bzero
# endif
#endif
#if defined(HAVE_MEMCPY)
#define MEMCPY_BCOPY(d,s,l) memcpy((d), (s), (l))
#else
# if defined(HAVE_BCOPY)
#define MEMCPY_BCOPY(d,s,l) bcopy((s), (d), (l))
# else
#error You need either memcpy or bcopy
# endif
#endif
])
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
+101
View File
@@ -0,0 +1,101 @@
.\" $NetBSD: digest.1,v 1.1 2002/12/21 03:41:00 schmonz Exp $
.\"
.\"
.\" Copyright (c) 2001 Alistair G. Crooks. 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.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by Alistair G. Crooks.
.\" 4. The name of the author may not be used to endorse or promote
.\" products derived from this software without specific prior written
.\" permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
.\"
.\"
.Dd February 28, 2001
.Dt DIGEST 1
.Os
.Sh NAME
.Nm digest
.Nd calculate message digests
.Sh SYNOPSIS
.Nm
.Ar algorithm
.Op file ...
.Sh DESCRIPTION
The
.Nm
utility calculates message digests of files or,
if no file is specified, standard input.
The list of possible algorithms is:
.Bl -tag -width Ds
.It md5
the
.Xr md5 3
algorithm will be used.
.It rmd160
the
.Xr rmd160 3
algorithm will be used.
.It sha1
the
.Xr sha1 3
algorithm will be used.
.It sha256
the
sha256
algorithm will be used.
.It sha384
the
sha384
algorithm will be used.
.It sha512
the
sha512
algorithm will be used.
.El
.Pp
The
.Nm
utility is a simple wrapper for the various different
algorithm implementations, which are located in the standard
C library, and was designed to be scalable as new message digest
algorithms are developed.
.Pp
The
.Nm
utility exits 0 on success, and >0 if an error occurs.
.Sh SEE ALSO
.Xr cksum 1 ,
.Xr md5 3 ,
.Xr rmd160 3 ,
.Xr sha1 3
.Sh HISTORY
The
.Nm
utility first appeared in
.Nx 1.6 .
.Sh AUTHORS
The
.Nm
utility was written by
.An Alistair G. Crooks Aq agc@netbsd.org .
+275
View File
@@ -0,0 +1,275 @@
/* $NetBSD: digest.c,v 1.1.1.1 2002/09/19 10:44:28 agc Exp $ */
/*
* Copyright (c) 2001 Alistair G. Crooks. 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.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Alistair G. Crooks.
* 4. The name of the author may not be used to endorse or promote
* products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <digest-types.h>
#ifndef lint
__COPYRIGHT("@(#) Copyright (c) 2001 \
The NetBSD Foundation, Inc. All rights reserved.");
__RCSID("$NetBSD: digest.c,v 1.1.1.1 2002/09/19 10:44:28 agc Exp $");
#endif
#ifdef HAVE_ERRNO_H
#include <errno.h>
#endif
#ifdef HAVE_LOCALE_H
#include <locale.h>
#endif
#include <md5.h>
#include <rmd160.h>
#include <sha1.h>
#include <sha2.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
/* perform an md5 digest, and print the results if successful */
static int
md5_digest_file(char *fn)
{
MD5_CTX m;
char in[BUFSIZ * 20];
char digest[33];
int cc;
if (fn == NULL) {
MD5Init(&m);
while ((cc = read(STDIN_FILENO, in, sizeof(in))) > 0) {
MD5Update(&m, (u_char *)in, (unsigned) cc);
}
(void) printf("%s\n", MD5End(&m, digest));
} else {
if (MD5File(fn, digest) == NULL) {
return 0;
}
(void) printf("MD5 (%s) = %s\n", fn, digest);
}
return 1;
}
/* perform an sha1 digest, and print the results if successful */
static int
sha1_digest_file(char *fn)
{
SHA1_CTX sha;
char in[BUFSIZ * 20];
char digest[41];
int cc;
if (fn == NULL) {
SHA1Init(&sha);
while ((cc = read(STDIN_FILENO, in, sizeof(in))) > 0) {
SHA1Update(&sha, (u_char *)in, (unsigned) cc);
}
(void) printf("%s\n", SHA1End(&sha, digest));
} else {
if (SHA1File(fn, digest) == NULL) {
return 0;
}
(void) printf("SHA1 (%s) = %s\n", fn, digest);
}
return 1;
}
/* perform an ripemd160 digest, and print the results if successful */
static int
rmd160_digest_file(char *fn)
{
RMD160_CTX rmd;
char in[BUFSIZ * 20];
char digest[41];
int cc;
if (fn == NULL) {
RMD160Init(&rmd);
while ((cc = read(STDIN_FILENO, in, sizeof(in))) > 0) {
RMD160Update(&rmd, (u_char *)in, (unsigned) cc);
}
(void) printf("%s\n", RMD160End(&rmd, digest));
} else {
if (RMD160File(fn, digest) == NULL) {
return 0;
}
(void) printf("RMD160 (%s) = %s\n", fn, digest);
}
return 1;
}
/* perform a sha256 digest, and print the results if successful */
static int
sha256_digest_file(char *fn)
{
SHA256_CTX sha256;
char in[BUFSIZ * 20];
char digest[65];
int cc;
if (fn == NULL) {
SHA256_Init(&sha256);
while ((cc = read(STDIN_FILENO, in, sizeof(in))) > 0) {
SHA256_Update(&sha256, (u_char *)in, (unsigned) cc);
}
(void) printf("%s\n", SHA256_End(&sha256, digest));
} else {
if (SHA256_File(fn, digest) == NULL) {
return 0;
}
(void) printf("SHA256 (%s) = %s\n", fn, digest);
}
return 1;
}
/* perform a sha384 digest, and print the results if successful */
static int
sha384_digest_file(char *fn)
{
SHA384_CTX sha384;
char in[BUFSIZ * 20];
char digest[97];
int cc;
if (fn == NULL) {
SHA384_Init(&sha384);
while ((cc = read(STDIN_FILENO, in, sizeof(in))) > 0) {
SHA384_Update(&sha384, (u_char *)in, (unsigned) cc);
}
(void) printf("%s\n", SHA384_End(&sha384, digest));
} else {
if (SHA384_File(fn, digest) == NULL) {
return 0;
}
(void) printf("SHA384 (%s) = %s\n", fn, digest);
}
return 1;
}
/* perform a sha512 digest, and print the results if successful */
static int
sha512_digest_file(char *fn)
{
SHA512_CTX sha512;
char in[BUFSIZ * 20];
char digest[129];
int cc;
if (fn == NULL) {
SHA512_Init(&sha512);
while ((cc = read(STDIN_FILENO, in, sizeof(in))) > 0) {
SHA512_Update(&sha512, (u_char *)in, (unsigned) cc);
}
(void) printf("%s\n", SHA512_End(&sha512, digest));
} else {
if (SHA512_File(fn, digest) == NULL) {
return 0;
}
(void) printf("SHA512 (%s) = %s\n", fn, digest);
}
return 1;
}
/* this struct defines a message digest algorithm */
typedef struct alg_t {
const char *name; /* algorithm name */
int (*func)(char *); /* function to call */
} alg_t;
/* list of supported message digest algorithms */
static alg_t algorithms[] = {
{ "md5", md5_digest_file },
{ "rmd160", rmd160_digest_file },
{ "sha1", sha1_digest_file },
{ "sha256", sha256_digest_file },
{ "sha384", sha384_digest_file },
{ "sha512", sha512_digest_file },
{ NULL }
};
/* find an algorithm, given a name */
static alg_t *
find_algorithm(const char *a)
{
alg_t *alg;
for (alg = algorithms ; alg->name && strcasecmp(alg->name, a) != 0 ; alg++) {
}
return (alg->name) ? alg : NULL;
}
int
main(int argc, char **argv)
{
alg_t *alg;
int rval;
int i;
#ifdef HAVE_SETLOCALE
(void) setlocale(LC_ALL, "");
#endif
while ((i = getopt(argc, argv, "V")) != -1) {
switch(i) {
case 'V':
printf("%s\n", VERSION);
return EXIT_SUCCESS;
}
}
if (argc == optind) {
(void) fprintf(stderr, "Usage: %s algorithm [file...]\n", *argv);
return EXIT_FAILURE;
}
if ((alg = find_algorithm(argv[optind])) == NULL) {
(void) fprintf(stderr, "No such algorithm `%s'\n", argv[optind]);
exit(EXIT_FAILURE);
}
rval = EXIT_SUCCESS;
if (argc == optind + 1) {
if (!(*alg->func)(NULL)) {
(void) fprintf(stderr, "stdin\n");
rval = EXIT_FAILURE;
}
} else {
for (i = optind + 1 ; i < argc ; i++) {
if (!(*alg->func)(argv[i])) {
(void) fprintf(stderr, "%s\n", argv[i]);
rval = EXIT_FAILURE;
}
}
}
return rval;
}
+251
View File
@@ -0,0 +1,251 @@
#!/bin/sh
#
# install - install a program, script, or datafile
# This comes from X11R5 (mit/util/scripts/install.sh).
#
# Copyright 1991 by the Massachusetts Institute of Technology
#
# Permission to use, copy, modify, distribute, and sell this software and its
# documentation for any purpose is hereby granted without fee, provided that
# the above copyright notice appear in all copies and that both that
# copyright notice and this permission notice appear in supporting
# documentation, and that the name of M.I.T. not be used in advertising or
# publicity pertaining to distribution of the software without specific,
# written prior permission. M.I.T. makes no representations about the
# suitability of this software for any purpose. It is provided "as is"
# without express or implied warranty.
#
# Calling this script install-sh is preferred over install.sh, to prevent
# `make' implicit rules from creating a file called install from it
# when there is no Makefile.
#
# This script is compatible with the BSD install script, but was written
# from scratch. It can only install one file at a time, a restriction
# shared with many OS's install programs.
# set DOITPROG to echo to test this script
# Don't use :- since 4.3BSD and earlier shells don't like it.
doit="${DOITPROG-}"
# put in absolute paths if you don't have them in your path; or use env. vars.
mvprog="${MVPROG-mv}"
cpprog="${CPPROG-cp}"
chmodprog="${CHMODPROG-chmod}"
chownprog="${CHOWNPROG-chown}"
chgrpprog="${CHGRPPROG-chgrp}"
stripprog="${STRIPPROG-strip}"
rmprog="${RMPROG-rm}"
mkdirprog="${MKDIRPROG-mkdir}"
transformbasename=""
transform_arg=""
instcmd="$mvprog"
chmodcmd="$chmodprog 0755"
chowncmd=""
chgrpcmd=""
stripcmd=""
rmcmd="$rmprog -f"
mvcmd="$mvprog"
src=""
dst=""
dir_arg=""
while [ x"$1" != x ]; do
case $1 in
-c) instcmd="$cpprog"
shift
continue;;
-d) dir_arg=true
shift
continue;;
-m) chmodcmd="$chmodprog $2"
shift
shift
continue;;
-o) chowncmd="$chownprog $2"
shift
shift
continue;;
-g) chgrpcmd="$chgrpprog $2"
shift
shift
continue;;
-s) stripcmd="$stripprog"
shift
continue;;
-t=*) transformarg=`echo $1 | sed 's/-t=//'`
shift
continue;;
-b=*) transformbasename=`echo $1 | sed 's/-b=//'`
shift
continue;;
*) if [ x"$src" = x ]
then
src=$1
else
# this colon is to work around a 386BSD /bin/sh bug
:
dst=$1
fi
shift
continue;;
esac
done
if [ x"$src" = x ]
then
echo "install: no input file specified"
exit 1
else
true
fi
if [ x"$dir_arg" != x ]; then
dst=$src
src=""
if [ -d $dst ]; then
instcmd=:
chmodcmd=""
else
instcmd=mkdir
fi
else
# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
# might cause directories to be created, which would be especially bad
# if $src (and thus $dsttmp) contains '*'.
if [ -f $src -o -d $src ]
then
true
else
echo "install: $src does not exist"
exit 1
fi
if [ x"$dst" = x ]
then
echo "install: no destination specified"
exit 1
else
true
fi
# If destination is a directory, append the input filename; if your system
# does not like double slashes in filenames, you may need to add some logic
if [ -d $dst ]
then
dst="$dst"/`basename $src`
else
true
fi
fi
## this sed command emulates the dirname command
dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
# Make sure that the destination directory exists.
# this part is taken from Noah Friedman's mkinstalldirs script
# Skip lots of stat calls in the usual case.
if [ ! -d "$dstdir" ]; then
defaultIFS='
'
IFS="${IFS-${defaultIFS}}"
oIFS="${IFS}"
# Some sh's can't handle IFS=/ for some reason.
IFS='%'
set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
IFS="${oIFS}"
pathcomp=''
while [ $# -ne 0 ] ; do
pathcomp="${pathcomp}${1}"
shift
if [ ! -d "${pathcomp}" ] ;
then
$mkdirprog "${pathcomp}"
else
true
fi
pathcomp="${pathcomp}/"
done
fi
if [ x"$dir_arg" != x ]
then
$doit $instcmd $dst &&
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
else
# If we're going to rename the final executable, determine the name now.
if [ x"$transformarg" = x ]
then
dstfile=`basename $dst`
else
dstfile=`basename $dst $transformbasename |
sed $transformarg`$transformbasename
fi
# don't allow the sed command to completely eliminate the filename
if [ x"$dstfile" = x ]
then
dstfile=`basename $dst`
else
true
fi
# Make a temp file name in the proper directory.
dsttmp=$dstdir/#inst.$$#
# Move or copy the file name to the temp name
$doit $instcmd $src $dsttmp &&
trap "rm -f ${dsttmp}" 0 &&
# and set any options; do chmod last to preserve setuid bits
# If any of these fail, we abort the whole thing. If we want to
# ignore errors from any of these, just make sure not to ignore
# errors from the above "$doit $instcmd $src $dsttmp" command.
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
# Now rename the file to the real destination.
$doit $rmcmd -f $dstdir/$dstfile &&
$doit $mvcmd $dsttmp $dstdir/$dstfile
fi &&
exit 0
+53
View File
@@ -0,0 +1,53 @@
/* $NetBSD: md5.h,v 1.1.1.1 2002/09/19 10:44:28 agc Exp $ */
/*
* This file is derived from the RSA Data Security, Inc. MD5 Message-Digest
* Algorithm and has been modified by Jason R. Thorpe <thorpej@NetBSD.ORG>
* for portability and formatting.
*/
/*
* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
* rights reserved.
*
* License to copy and use this software is granted provided that it
* is identified as the "RSA Data Security, Inc. MD5 Message-Digest
* Algorithm" in all material mentioning or referencing this software
* or this function.
*
* License is also granted to make and use derivative works provided
* that such works are identified as "derived from the RSA Data
* Security, Inc. MD5 Message-Digest Algorithm" in all material
* mentioning or referencing the derived work.
*
* RSA Data Security, Inc. makes no representations concerning either
* the merchantability of this software or the suitability of this
* software for any particular purpose. It is provided "as is"
* without express or implied warranty of any kind.
*
* These notices must be retained in any copies of any part of this
* documentation and/or software.
*/
#ifndef _SYS_MD5_H_
#define _SYS_MD5_H_
/* MD5 context. */
typedef struct MD5Context {
u_int32_t state[4]; /* state (ABCD) */
u_int32_t count[2]; /* number of bits, modulo 2^64 (lsb first) */
unsigned char buffer[64]; /* input buffer */
} MD5_CTX;
__BEGIN_DECLS
void MD5Init __P((MD5_CTX *));
void MD5Update __P((MD5_CTX *, const unsigned char *, unsigned int));
void MD5Final __P((unsigned char[16], MD5_CTX *));
#ifndef _KERNEL
char *MD5End __P((MD5_CTX *, char *));
char *MD5File __P((const char *, char *));
char *MD5Data __P((const unsigned char *, unsigned int, char *));
#endif /* _KERNEL */
__END_DECLS
#endif /* _SYS_MD5_H_ */
+375
View File
@@ -0,0 +1,375 @@
/* $NetBSD: md5c.c,v 1.1.1.1 2002/09/19 10:44:29 agc Exp $ */
/*
* This file is derived from the RSA Data Security, Inc. MD5 Message-Digest
* Algorithm and has been modifed by Jason R. Thorpe <thorpej@NetBSD.ORG>
* for portability and formatting.
*/
/*
* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
* rights reserved.
*
* License to copy and use this software is granted provided that it
* is identified as the "RSA Data Security, Inc. MD5 Message-Digest
* Algorithm" in all material mentioning or referencing this software
* or this function.
*
* License is also granted to make and use derivative works provided
* that such works are identified as "derived from the RSA Data
* Security, Inc. MD5 Message-Digest Algorithm" in all material
* mentioning or referencing the derived work.
*
* RSA Data Security, Inc. makes no representations concerning either
* the merchantability of this software or the suitability of this
* software for any particular purpose. It is provided "as is"
* without express or implied warranty of any kind.
*
* These notices must be retained in any copies of any part of this
* documentation and/or software.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <digest-types.h>
#if defined(_KERNEL) || defined(_STANDALONE)
#include <lib/libkern/libkern.h>
#include <sys/param.h>
#include <sys/md5.h>
#define _DIAGASSERT(x) (void)0
#else
/* #include "namespace.h" */
#include <assert.h>
#include <string.h>
#include <md5.h>
#endif /* _KERNEL || _STANDALONE */
#if defined(HAVE_MEMSET)
#define ZEROIZE(d, l) memset((d), 0, (l))
#else
# if defined(HAVE_BZERO)
#define ZEROIZE(d, l) bzero((d), (l))
# else
#error You need either memset or bzero
# endif
#endif
typedef unsigned char *POINTER;
typedef u_int16_t UINT2;
typedef u_int32_t UINT4;
/*
* Constants for MD5Transform routine.
*/
#define S11 7
#define S12 12
#define S13 17
#define S14 22
#define S21 5
#define S22 9
#define S23 14
#define S24 20
#define S31 4
#define S32 11
#define S33 16
#define S34 23
#define S41 6
#define S42 10
#define S43 15
#define S44 21
#if 0
#if !defined(_KERNEL) && !defined(_STANDALONE) && defined(__weak_alias)
__weak_alias(MD5Init,_MD5Init)
__weak_alias(MD5Update,_MD5Update)
__weak_alias(MD5Final,_MD5Final)
#endif
#endif
#ifndef _DIAGASSERT
#define _DIAGASSERT(cond) assert(cond)
#endif
static void MD5Transform __P((UINT4 [4], const unsigned char [64]));
static void Encode __P((unsigned char *, UINT4 *, unsigned int));
static void Decode __P((UINT4 *, const unsigned char *, unsigned int));
/*
* Encodes input (UINT4) into output (unsigned char). Assumes len is
* a multiple of 4.
*/
static void
Encode (output, input, len)
unsigned char *output;
UINT4 *input;
unsigned int len;
{
unsigned int i, j;
for (i = 0, j = 0; j < len; i++, j += 4) {
output[j] = (unsigned char)(input[i] & 0xff);
output[j+1] = (unsigned char)((input[i] >> 8) & 0xff);
output[j+2] = (unsigned char)((input[i] >> 16) & 0xff);
output[j+3] = (unsigned char)((input[i] >> 24) & 0xff);
}
}
/*
* Decodes input (unsigned char) into output (UINT4). Assumes len is
* a multiple of 4.
*/
static void
Decode (output, input, len)
UINT4 *output;
const unsigned char *input;
unsigned int len;
{
unsigned int i, j;
for (i = 0, j = 0; j < len; i++, j += 4)
output[i] = ((UINT4)input[j]) | (((UINT4)input[j+1]) << 8) |
(((UINT4)input[j+2]) << 16) | (((UINT4)input[j+3]) << 24);
}
static const unsigned char PADDING[64] = {
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
/*
* F, G, H and I are basic MD5 functions.
*/
#define F(x, y, z) (((x) & (y)) | ((~x) & (z)))
#define G(x, y, z) (((x) & (z)) | ((y) & (~z)))
#define H(x, y, z) ((x) ^ (y) ^ (z))
#define I(x, y, z) ((y) ^ ((x) | (~z)))
/*
* ROTATE_LEFT rotates x left n bits.
*/
#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n))))
/*
* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4.
* Rotation is separate from addition to prevent recomputation.
*/
#define FF(a, b, c, d, x, s, ac) { \
(a) += F ((b), (c), (d)) + (x) + (UINT4)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
#define GG(a, b, c, d, x, s, ac) { \
(a) += G ((b), (c), (d)) + (x) + (UINT4)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
#define HH(a, b, c, d, x, s, ac) { \
(a) += H ((b), (c), (d)) + (x) + (UINT4)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
#define II(a, b, c, d, x, s, ac) { \
(a) += I ((b), (c), (d)) + (x) + (UINT4)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
/*
* MD5 initialization. Begins an MD5 operation, writing a new context.
*/
void
MD5Init(context)
MD5_CTX *context; /* context */
{
_DIAGASSERT(context != 0);
context->count[0] = context->count[1] = 0;
/* Load magic initialization constants. */
context->state[0] = 0x67452301;
context->state[1] = 0xefcdab89;
context->state[2] = 0x98badcfe;
context->state[3] = 0x10325476;
}
/*
* MD5 block update operation. Continues an MD5 message-digest
* operation, processing another message block, and updating the
* context.
*/
void
MD5Update(context, input, inputLen)
MD5_CTX *context; /* context */
const unsigned char *input; /* input block */
unsigned int inputLen; /* length of input block */
{
unsigned int i, idx, partLen;
_DIAGASSERT(context != 0);
_DIAGASSERT(input != 0);
/* Compute number of bytes mod 64 */
idx = (unsigned int)((context->count[0] >> 3) & 0x3F);
/* Update number of bits */
if ((context->count[0] += ((UINT4)inputLen << 3))
< ((UINT4)inputLen << 3))
context->count[1]++;
context->count[1] += ((UINT4)inputLen >> 29);
partLen = 64 - idx;
/* Transform as many times as possible. */
if (inputLen >= partLen) {
/* LINTED const castaway ok */
memcpy((POINTER)&context->buffer[idx],
input, partLen);
MD5Transform(context->state, context->buffer);
for (i = partLen; i + 63 < inputLen; i += 64)
MD5Transform(context->state, &input[i]);
idx = 0;
} else
i = 0;
/* Buffer remaining input */
/* LINTED const castaway ok */
memcpy((POINTER)&context->buffer[idx], &input[i],
inputLen - i);
}
/*
* MD5 finalization. Ends an MD5 message-digest operation, writing the
* message digest and zeroing the context.
*/
void
MD5Final(digest, context)
unsigned char digest[16]; /* message digest */
MD5_CTX *context; /* context */
{
unsigned char bits[8];
unsigned int idx, padLen;
_DIAGASSERT(digest != 0);
_DIAGASSERT(context != 0);
/* Save number of bits */
Encode(bits, context->count, 8);
/* Pad out to 56 mod 64. */
idx = (unsigned int)((context->count[0] >> 3) & 0x3f);
padLen = (idx < 56) ? (56 - idx) : (120 - idx);
MD5Update (context, PADDING, padLen);
/* Append length (before padding) */
MD5Update(context, bits, 8);
/* Store state in digest */
Encode(digest, context->state, 16);
/* Zeroize sensitive information. */
ZEROIZE((POINTER)(void *)context, sizeof(*context));
}
/*
* MD5 basic transformation. Transforms state based on block.
*/
static void
MD5Transform(state, block)
UINT4 state[4];
const unsigned char block[64];
{
UINT4 a = state[0], b = state[1], c = state[2], d = state[3], x[16];
Decode(x, block, 64);
/* Round 1 */
FF (a, b, c, d, x[ 0], S11, 0xd76aa478); /* 1 */
FF (d, a, b, c, x[ 1], S12, 0xe8c7b756); /* 2 */
FF (c, d, a, b, x[ 2], S13, 0x242070db); /* 3 */
FF (b, c, d, a, x[ 3], S14, 0xc1bdceee); /* 4 */
FF (a, b, c, d, x[ 4], S11, 0xf57c0faf); /* 5 */
FF (d, a, b, c, x[ 5], S12, 0x4787c62a); /* 6 */
FF (c, d, a, b, x[ 6], S13, 0xa8304613); /* 7 */
FF (b, c, d, a, x[ 7], S14, 0xfd469501); /* 8 */
FF (a, b, c, d, x[ 8], S11, 0x698098d8); /* 9 */
FF (d, a, b, c, x[ 9], S12, 0x8b44f7af); /* 10 */
FF (c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */
FF (b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */
FF (a, b, c, d, x[12], S11, 0x6b901122); /* 13 */
FF (d, a, b, c, x[13], S12, 0xfd987193); /* 14 */
FF (c, d, a, b, x[14], S13, 0xa679438e); /* 15 */
FF (b, c, d, a, x[15], S14, 0x49b40821); /* 16 */
/* Round 2 */
GG (a, b, c, d, x[ 1], S21, 0xf61e2562); /* 17 */
GG (d, a, b, c, x[ 6], S22, 0xc040b340); /* 18 */
GG (c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */
GG (b, c, d, a, x[ 0], S24, 0xe9b6c7aa); /* 20 */
GG (a, b, c, d, x[ 5], S21, 0xd62f105d); /* 21 */
GG (d, a, b, c, x[10], S22, 0x2441453); /* 22 */
GG (c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */
GG (b, c, d, a, x[ 4], S24, 0xe7d3fbc8); /* 24 */
GG (a, b, c, d, x[ 9], S21, 0x21e1cde6); /* 25 */
GG (d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */
GG (c, d, a, b, x[ 3], S23, 0xf4d50d87); /* 27 */
GG (b, c, d, a, x[ 8], S24, 0x455a14ed); /* 28 */
GG (a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */
GG (d, a, b, c, x[ 2], S22, 0xfcefa3f8); /* 30 */
GG (c, d, a, b, x[ 7], S23, 0x676f02d9); /* 31 */
GG (b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */
/* Round 3 */
HH (a, b, c, d, x[ 5], S31, 0xfffa3942); /* 33 */
HH (d, a, b, c, x[ 8], S32, 0x8771f681); /* 34 */
HH (c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */
HH (b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */
HH (a, b, c, d, x[ 1], S31, 0xa4beea44); /* 37 */
HH (d, a, b, c, x[ 4], S32, 0x4bdecfa9); /* 38 */
HH (c, d, a, b, x[ 7], S33, 0xf6bb4b60); /* 39 */
HH (b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */
HH (a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */
HH (d, a, b, c, x[ 0], S32, 0xeaa127fa); /* 42 */
HH (c, d, a, b, x[ 3], S33, 0xd4ef3085); /* 43 */
HH (b, c, d, a, x[ 6], S34, 0x4881d05); /* 44 */
HH (a, b, c, d, x[ 9], S31, 0xd9d4d039); /* 45 */
HH (d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */
HH (c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */
HH (b, c, d, a, x[ 2], S34, 0xc4ac5665); /* 48 */
/* Round 4 */
II (a, b, c, d, x[ 0], S41, 0xf4292244); /* 49 */
II (d, a, b, c, x[ 7], S42, 0x432aff97); /* 50 */
II (c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */
II (b, c, d, a, x[ 5], S44, 0xfc93a039); /* 52 */
II (a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */
II (d, a, b, c, x[ 3], S42, 0x8f0ccc92); /* 54 */
II (c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */
II (b, c, d, a, x[ 1], S44, 0x85845dd1); /* 56 */
II (a, b, c, d, x[ 8], S41, 0x6fa87e4f); /* 57 */
II (d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */
II (c, d, a, b, x[ 6], S43, 0xa3014314); /* 59 */
II (b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */
II (a, b, c, d, x[ 4], S41, 0xf7537e82); /* 61 */
II (d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */
II (c, d, a, b, x[ 2], S43, 0x2ad7d2bb); /* 63 */
II (b, c, d, a, x[ 9], S44, 0xeb86d391); /* 64 */
state[0] += a;
state[1] += b;
state[2] += c;
state[3] += d;
/* Zeroize sensitive information. */
ZEROIZE((POINTER)(void *)x, sizeof (x));
}

Some files were not shown because too many files have changed in this diff Show More