This commit is contained in:
biosvos
2026-08-07 17:38:18 +09:00
commit 873193a243
9613 changed files with 2755992 additions and 0 deletions
@@ -0,0 +1,6 @@
#AUTOMAKE_OPTIONS = foreign
nobase_include_HEADERS = mhash.h mutils/mhash.h mutils/mglobal.h mutils/mtypes.h mutils/mutils.h mutils/mhash_config.h mutils/mincludes.h
dist-hook:
find $(distdir) -name CVS -o -name .cvsignore | xargs rm -rf
@@ -0,0 +1,417 @@
# Makefile.in generated by automake 1.9.6 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004, 2005 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
#AUTOMAKE_OPTIONS = foreign
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = ..
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
INSTALL = @INSTALL@
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
target_triplet = @target@
subdir = include
DIST_COMMON = $(nobase_include_HEADERS) $(srcdir)/Makefile.am \
$(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
$(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/include/mutils/mhash_config.h
CONFIG_CLEAN_FILES =
SOURCES =
DIST_SOURCES =
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
am__vpath_adj = case $$p in \
$(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
*) f=$$p;; \
esac;
am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
am__installdirs = "$(DESTDIR)$(includedir)"
nobase_includeHEADERS_INSTALL = $(install_sh_DATA)
HEADERS = $(nobase_include_HEADERS)
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMDEP_FALSE = @AMDEP_FALSE@
AMDEP_TRUE = @AMDEP_TRUE@
AMTAR = @AMTAR@
AR = @AR@
AS = @AS@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCAS = @CCAS@
CCASFLAGS = @CCASFLAGS@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DLLTOOL = @DLLTOOL@
ECHO = @ECHO@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
F77 = @F77@
FFLAGS = @FFLAGS@
GREP = @GREP@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
MAINT = @MAINT@
MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@
MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
MAKEINFO = @MAKEINFO@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VERSION = @VERSION@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_F77 = @ac_ct_F77@
am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@
am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
sysconfdir = @sysconfdir@
target = @target@
target_alias = @target_alias@
target_cpu = @target_cpu@
target_os = @target_os@
target_vendor = @target_vendor@
nobase_include_HEADERS = mhash.h mutils/mhash.h mutils/mglobal.h mutils/mtypes.h mutils/mutils.h mutils/mhash_config.h mutils/mincludes.h
all: all-am
.SUFFIXES:
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
&& exit 0; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu include/Makefile'; \
cd $(top_srcdir) && \
$(AUTOMAKE) --gnu include/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
distclean-libtool:
-rm -f libtool
uninstall-info-am:
install-nobase_includeHEADERS: $(nobase_include_HEADERS)
@$(NORMAL_INSTALL)
test -z "$(includedir)" || $(mkdir_p) "$(DESTDIR)$(includedir)"
@$(am__vpath_adj_setup) \
list='$(nobase_include_HEADERS)'; for p in $$list; do \
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
$(am__vpath_adj) \
echo " $(nobase_includeHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(includedir)/$$f'"; \
$(nobase_includeHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(includedir)/$$f"; \
done
uninstall-nobase_includeHEADERS:
@$(NORMAL_UNINSTALL)
@$(am__vpath_adj_setup) \
list='$(nobase_include_HEADERS)'; for p in $$list; do \
$(am__vpath_adj) \
echo " rm -f '$(DESTDIR)$(includedir)/$$f'"; \
rm -f "$(DESTDIR)$(includedir)/$$f"; \
done
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
mkid -fID $$unique
tags: TAGS
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$tags $$unique; \
fi
ctags: CTAGS
CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
test -z "$(CTAGS_ARGS)$$tags$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$tags $$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& cd $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) $$here
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(DISTFILES)
$(mkdir_p) $(distdir)/mutils
@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
list='$(DISTFILES)'; for file in $$list; do \
case $$file in \
$(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
$(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
esac; \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
if test "$$dir" != "$$file" && test "$$dir" != "."; then \
dir="/$$dir"; \
$(mkdir_p) "$(distdir)$$dir"; \
else \
dir=''; \
fi; \
if test -d $$d/$$file; then \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
fi; \
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
else \
test -f $(distdir)/$$file \
|| cp -p $$d/$$file $(distdir)/$$file \
|| exit 1; \
fi; \
done
$(MAKE) $(AM_MAKEFLAGS) \
top_distdir="$(top_distdir)" distdir="$(distdir)" \
dist-hook
check-am: all-am
check: check-am
all-am: Makefile $(HEADERS)
installdirs:
for dir in "$(DESTDIR)$(includedir)"; do \
test -z "$$dir" || $(mkdir_p) "$$dir"; \
done
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean-am: clean-generic clean-libtool mostlyclean-am
distclean: distclean-am
-rm -f Makefile
distclean-am: clean-am distclean-generic distclean-libtool \
distclean-tags
dvi: dvi-am
dvi-am:
html: html-am
info: info-am
info-am:
install-data-am: install-nobase_includeHEADERS
install-exec-am:
install-info: install-info-am
install-man:
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-generic mostlyclean-libtool
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am: uninstall-info-am uninstall-nobase_includeHEADERS
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
clean-libtool ctags dist-hook distclean distclean-generic \
distclean-libtool distclean-tags distdir dvi dvi-am html \
html-am info info-am install install-am install-data \
install-data-am install-exec install-exec-am install-info \
install-info-am install-man install-nobase_includeHEADERS \
install-strip installcheck installcheck-am installdirs \
maintainer-clean maintainer-clean-generic mostlyclean \
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
tags uninstall uninstall-am uninstall-info-am \
uninstall-nobase_includeHEADERS
dist-hook:
find $(distdir) -name CVS -o -name .cvsignore | xargs rm -rf
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
@@ -0,0 +1,13 @@
#if !defined(__MHASH_H)
#define __MHASH_H
#define MUTILS_USE_MHASH_CONFIG
#include <mutils/mincludes.h>
#include <mutils/mglobal.h>
#include <mutils/mtypes.h>
#include <mutils/mutils.h>
#include <mutils/mhash.h>
#endif
@@ -0,0 +1,128 @@
/*
* Copyright (C) 2005 Jonathan Day, Nikos Mavroyanopoulos
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Library General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#if !defined(__MGLOBAL_H)
#define __MGLOBAL_H
#define MHASH_API_NONE 0
#define MHASH_API_CLASSIC 1
#define MHASH_API_FAMILY 2
#define MHASH_API_VERSION 20060101
#define MHASH_API_TYPE MHASH_API_CLASSIC
/* #define MHASH_API_TYPE MHASH_API_FAMILY */
#define MHASH_API_FULL
typedef enum __hashid {
#if (MHASH_API_TYPE == MHASH_API_CLASSIC)
MHASH_CRC32 = 0,
MHASH_MD5 = 1,
MHASH_SHA1 = 2,
MHASH_HAVAL256 = 3,
MHASH_RIPEMD160 = 5,
MHASH_TIGER192 = 7,
MHASH_GOST = 8,
MHASH_CRC32B = 9,
MHASH_HAVAL224 = 10,
MHASH_HAVAL192 = 11,
MHASH_HAVAL160 = 12,
MHASH_HAVAL128 = 13,
MHASH_TIGER128 = 14,
MHASH_TIGER160 = 15,
MHASH_MD4 = 16,
MHASH_SHA256 = 17,
MHASH_ADLER32 = 18,
MHASH_SHA224 = 19,
MHASH_SHA512 = 20,
MHASH_SHA384 = 21,
MHASH_WHIRLPOOL = 22,
MHASH_RIPEMD128 = 23,
MHASH_RIPEMD256 = 24,
MHASH_RIPEMD320 = 25,
MHASH_SNEFRU128 = 26,
MHASH_SNEFRU256 = 27,
MHASH_MD2 = 28,
MHASH_AR = 64, /* NOT YET IMPLEMENTED */
MHASH_BOOGNISH = 65, /* NOT YET IMPLEMENTED */
MHASH_CELLHASH = 66, /* NOT YET IMPLEMENTED */
MHASH_FFT_HASH_I = 67, /* NOT YET IMPLEMENTED */
MHASH_FFT_HASH_II = 68, /* NOT YET IMPLEMENTED */
MHASH_NHASH = 69, /* NOT YET IMPLEMENTED */
MHASH_PANAMA = 70, /* NOT YET IMPLEMENTED */
MHASH_SMASH = 71, /* NOT YET IMPLEMENTED */
MHASH_SUBHASH = 72 /* NOT YET IMPLEMENTED */
#endif
#if (MHASH_API_TYPE == MHASH_API_FAMILY)
MHASH_CRC32 = 0x0001,
MHASH_CRC32B = 0x0002,
MHASH_ADLER32 = 0x0011,
MHASH_MD2 = 0x0101,
MHASH_MD4 = 0x0111,
MHASH_RIPEMD128 = 0x0112,
MHASH_RIPEMD160 = 0x0113,
MHASH_RIPEMD256 = 0x0114,
MHASH_RIPEMD320 = 0x0115,
MHASH_MD5 = 0x0121,
MHASH_SHA1 = 0x0201,
MHASH_SHA224 = 0x0201,
MHASH_SHA256 = 0x0202,
MHASH_SHA384 = 0x0203,
MHASH_SHA512 = 0x0204,
MHASH_HAVAL128 = 0x0301,
MHASH_HAVAL160 = 0x0302,
MHASH_HAVAL192 = 0x0303,
MHASH_HAVAL224 = 0x0304,
MHASH_HAVAL256 = 0x0305, /* 3 passes */
MHASH_TIGER128 = 0x0401,
MHASH_TIGER160 = 0x0402,
MHASH_TIGER192 = 0x0403,
MHASH_GOST = 0x0501,
MHASH_WHIRLPOOL = 0x0601,
MHASH_SNEFRU128 = 0x0701, /* 8 passes */
MHASH_SNEFRU256 = 0x0702, /* 8 passes */
MHASH_AR = 0x0801, /* NOT YET IMPLEMENTED */
MHASH_BOOGNISH = 0x0901, /* NOT YET IMPLEMENTED */
MHASH_CELLHASH = 0x0a01, /* NOT YET IMPLEMENTED */
MHASH_FFT_HASH_I = 0x0b01, /* NOT YET IMPLEMENTED */
MHASH_FFT_HASH_II = 0x0b02, /* NOT YET IMPLEMENTED */
MHASH_NHASH = 0x0c01, /* NOT YET IMPLEMENTED */
MHASH_PANAMA = 0x0d01, /* NOT YET IMPLEMENTED */
MHASH_SMASH = 0x0e01, /* NOT YET IMPLEMENTED */
MHASH_SUBHASH = 0x0f01 /* NOT YET IMPLEMENTED */
#endif
} hashid;
/* These aliases are actually quite useful and so will be kept */
#define MHASH_HAVAL MHASH_HAVAL256
#define MHASH_TIGER MHASH_TIGER192
typedef enum __keygenid {
KEYGEN_MCRYPT, /* The key generator used in mcrypt */
KEYGEN_ASIS, /* Just returns the password as binary key */
KEYGEN_HEX, /* Just converts a hex key into a binary one */
KEYGEN_PKDES, /* The transformation used in Phil Karn's DES
* encryption program */
KEYGEN_S2K_SIMPLE, /* The OpenPGP (rfc2440) Simple S2K */
KEYGEN_S2K_SALTED, /* The OpenPGP Salted S2K */
KEYGEN_S2K_ISALTED /* The OpenPGP Iterated Salted S2K */
} keygenid;
#endif
@@ -0,0 +1,185 @@
/*
* Copyright (C) 1998 Nikos Mavroyanopoulos
* Copyright (C) 1999,2000 Sascha Schumman, Nikos Mavroyanopoulos
* Copyright (C) 2001 Nikos Mavroyanopoulos
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Library General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#if !defined(__MUTILS_MHASH_H)
#define __MUTILS_MHASH_H
/* $Id: mhash.h,v 1.2 2006/01/09 07:27:04 imipak Exp $ */
#if defined(MUTILS_USE_MHASH_CONFIG)
#include <mutils/mhash_config.h>
#endif
#include <mutils/mglobal.h>
#include <mutils/mutils.h>
#include <mutils/mtypes.h>
#ifdef __cplusplus
extern "C" {
#endif
/* these are for backwards compatibility and will
be removed at some time */
#ifdef MHASH_BACKWARDS_COMPATIBLE
# define hmac_mhash_init mhash_hmac_init
# define hmac_mhash_end mhash_hmac_end
#endif
/* typedefs */
typedef struct mhash_hash_entry mhash_hash_entry;
#if defined(PROTOTYPES)
/* information prototypes */
mutils_word32 mhash_count(void);
mutils_word32 mhash_get_block_size(hashid type);
mutils_word8 *mhash_get_hash_name(hashid type);
void mhash_free(void *ptr);
__const mutils_word8 *mhash_get_hash_name_static(hashid type);
/* initializing prototypes */
MHASH mhash_init(hashid type);
/* copy prototypes */
MHASH mhash_cp(MHASH from);
/* update prototype */
mutils_boolean mhash(MHASH thread, const void *plaintext, mutils_word32 size);
/* finalizing prototype */
void *mhash_end(MHASH thread);
void *mhash_end_m(MHASH thread, void *(*hash_malloc) (mutils_word32));
void mhash_deinit(MHASH thread, void *result);
/* informational */
mutils_word32 mhash_get_hash_pblock(hashid type);
hashid mhash_get_mhash_algo(MHASH tmp);
/* HMAC */
MHASH mhash_hmac_init(const hashid type, void *key, mutils_word32 keysize, mutils_word32 block);
void *mhash_hmac_end_m(MHASH thread, void *(*hash_malloc) (mutils_word32));
void *mhash_hmac_end(MHASH thread);
mutils_boolean mhash_hmac_deinit(MHASH thread, void *result);
/* Save state functions */
mutils_boolean mhash_save_state_mem(MHASH thread, void *mem, mutils_word32 *mem_size);
MHASH mhash_restore_state_mem(void *mem);
/* Key generation functions */
mutils_error mhash_keygen(keygenid algorithm, hashid opt_algorithm,
mutils_word64 count,
void *keyword, mutils_word32 keysize,
void *salt, mutils_word32 saltsize,
mutils_word8 *password, mutils_word32 passwordlen);
mutils_error mhash_keygen_ext(keygenid algorithm, KEYGEN data,
void *keyword, mutils_word32 keysize,
mutils_word8 *password, mutils_word32 passwordlen);
mutils_word8 *mhash_get_keygen_name(keygenid type);
mutils_word32 mhash_get_keygen_salt_size(keygenid type);
mutils_word32 mhash_get_keygen_max_key_size(keygenid type);
mutils_word32 mhash_keygen_count(void);
mutils_boolean mhash_keygen_uses_salt(keygenid type);
mutils_boolean mhash_keygen_uses_count(keygenid type);
mutils_boolean mhash_keygen_uses_hash_algorithm(keygenid type);
#else
/* information prototypes */
mutils_word32 mhash_count();
mutils_word32 mhash_get_block_size();
mutils_word8 *mhash_get_hash_name();
void mhash_free();
__const mutils_word8 *mhash_get_hash_name_static();
/* initializing prototypes */
MHASH mhash_init();
/* copy prototypes */
MHASH mhash_cp();
/* update prototype */
mutils_boolean mhash();
/* finalizing prototype */
void *mhash_end();
void *mhash_end_m();
void mhash_deinit();
/* informational */
mutils_word32 mhash_get_hash_pblock();
hashid mhash_get_mhash_algo();
/* HMAC */
MHASH mhash_hmac_init();
void *mhash_hmac_end_m();
void *mhash_hmac_end();
mutils_boolean mhash_hmac_deinit();
/* Save state functions */
mutils_boolean mhash_save_state_mem();
MHASH mhash_restore_state_mem();
/* Key generation functions */
mutils_error mhash_keygen();
mutils_error mhash_keygen_ext();
mutils_word8 *mhash_get_keygen_name();
mutils_word32 mhash_get_keygen_salt_size();
mutils_word32 mhash_get_keygen_max_key_size();
mutils_word32 mhash_keygen_count();
mutils_boolean mhash_keygen_uses_salt();
mutils_boolean mhash_keygen_uses_count();
mutils_boolean mhash_keygen_uses_hash_algorithm();
#endif
#ifdef __cplusplus
}
#endif
#endif /* !MHASH_H */
@@ -0,0 +1,260 @@
/* include/mutils/mhash_config.h. Generated from mhash_config.h.in by configure. */
/* include/mutils/mhash_config.h.in. Generated from configure.in by autoheader. */
/* "Adler32 Algorithm" */
#define ENABLE_ADLER32 1
/* "CRC32 Algorithm" */
#define ENABLE_CRC32 1
/* "GOST Algorithm" */
#define ENABLE_GOST 1
/* "Haval Algorithm" */
#define ENABLE_HAVAL 1
/* "MD-2 Algorithm" */
#define ENABLE_MD2 1
/* "MD-4 Algorithm" */
#define ENABLE_MD4 1
/* "MD-5 Algorithm" */
#define ENABLE_MD5 1
/* "RIPE-MD - RIPE Substitute for MD" */
#define ENABLE_RIPEMD 1
/* "SHA-1 Algorithm" */
#define ENABLE_SHA1 1
/* "SHA-224 and SHA-256 - SHA-2 Algorithms" */
#define ENABLE_SHA256_SHA224 1
/* "SHA-384 and SHA-512 - SHA-2 Algorithms" */
#define ENABLE_SHA512_SHA384 1
/* "Snefru Algorithm" */
#define ENABLE_SNEFRU 1
/* "Tiger Algorithm" */
#define ENABLE_TIGER 1
/* "Whirlpool Algorithm" */
#define ENABLE_WHIRLPOOL 1
/* Define to 1 if you have the <assert.h> header file. */
#define HAVE_ASSERT_H 1
/* Define to 1 if you have the `bcopy' function. */
#define HAVE_BCOPY 1
/* Define to 1 if you have the <byteswap.h> header file. */
#define HAVE_BYTESWAP_H 1
/* Define to 1 if you have the `bzero' function. */
#define HAVE_BZERO 1
/* Define to 1 if you have the <ctype.h> header file. */
#define HAVE_CTYPE_H 1
/* Define to 1 if you have the <dlfcn.h> header file. */
#define HAVE_DLFCN_H 1
/* Define to 1 if you have the <endian.h> header file. */
#define HAVE_ENDIAN_H 1
/* Define to 1 if you have the <errno.h> header file. */
#define HAVE_ERRNO_H 1
/* Define to 1 if you have the `fcntl' function. */
#define HAVE_FCNTL 1
/* Define to 1 if you have the <fcntl.h> header file. */
#define HAVE_FCNTL_H 1
/* Define to 1 if you have the `fsync' function. */
#define HAVE_FSYNC 1
/* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1
/* Define to 1 if you have the `dmalloc' library (-ldmalloc). */
/* #undef HAVE_LIBDMALLOC */
/* Define to 1 if you have the <limits.h> header file. */
#define HAVE_LIMITS_H 1
/* Define to 1 if you have the `lstat' function. */
#define HAVE_LSTAT 1
/* Define to 1 if your system has a GNU libc compatible `malloc' function, and
to 0 otherwise. */
#define HAVE_MALLOC 1
/* Define to 1 if you have the <malloc.h> header file. */
#define HAVE_MALLOC_H 1
/* Define to 1 if you have the `memmove' function. */
#define HAVE_MEMMOVE 1
/* Define to 1 if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1
/* Define to 1 if you have the `memset' function. */
#define HAVE_MEMSET 1
/* Define to 1 if you have the `mlock' function. */
#define HAVE_MLOCK 1
/* Define to 1 if you have the `readdir' function. */
#define HAVE_READDIR 1
/* Define to 1 if you have the `readdir_r' function. */
#define HAVE_READDIR_R 1
/* Define to 1 if you have the `sigaction' function. */
#define HAVE_SIGACTION 1
/* Define to 1 if you have the `signal' function. */
#define HAVE_SIGNAL 1
/* Define to 1 if you have the <signal.h> header file. */
#define HAVE_SIGNAL_H 1
/* Define to 1 if you have the `stat' function. */
#define HAVE_STAT 1
/* Define to 1 if stdbool.h conforms to C99. */
#define HAVE_STDBOOL_H 1
/* Define to 1 if you have the <stdint.h> header file. */
#define HAVE_STDINT_H 1
/* Define to 1 if you have the <stdio.h> header file. */
#define HAVE_STDIO_H 1
/* Define to 1 if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H 1
/* Define to 1 if you have the <strings.h> header file. */
#define HAVE_STRINGS_H 1
/* Define to 1 if you have the <string.h> header file. */
#define HAVE_STRING_H 1
/* Define to 1 if you have the `strtol' function. */
#define HAVE_STRTOL 1
/* 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/mman.h> header file. */
#define HAVE_SYS_MMAN_H 1
/* Define to 1 if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1
/* Define to 1 if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1
/* Define to 1 if you have the `umask' function. */
#define HAVE_UMASK 1
/* Define to 1 if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1
/* Define to 1 if you have the `utime' function. */
#define HAVE_UTIME 1
/* Define to 1 if you have the <utime.h> header file. */
#define HAVE_UTIME_H 1
/* Define to 1 if you have the <values.h> header file. */
#define HAVE_VALUES_H 1
/* Define to 1 if the system has the type `_Bool'. */
#define HAVE__BOOL 1
/* "MHash Version" */
#define MHASH_VERSION PROGRAM_VERSION
/* Define to 1 if your C compiler doesn't accept -c and -o together. */
/* #undef NO_MINUS_C_MINUS_O */
/* Name of package */
#define PACKAGE "mhash"
/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT "mhash-devel@sourceforge.net"
/* Define to the full name of this package. */
#define PACKAGE_NAME "MHASH"
/* Define to the full name and version of this package. */
#define PACKAGE_STRING "MHASH 0.9.9"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "mhash"
/* Define to the version of this package. */
#define PACKAGE_VERSION "0.9.9"
/* Define to 1 if the C compiler supports function prototypes. */
#define PROTOTYPES 1
/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* dmalloc */
/* #undef USE_DMALLOC */
/* Version number of package */
#define VERSION "0.9.9"
/* Define if using the dmalloc debugging malloc package */
/* #undef WITH_DMALLOC */
/* 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 1 if on AIX 3.
System headers sometimes define this.
We just want to avoid a redefinition error message. */
#ifndef _ALL_SOURCE
/* # undef _ALL_SOURCE */
#endif
/* Enable GNU extensions on systems that have them. */
#ifndef _GNU_SOURCE
# define _GNU_SOURCE 1
#endif
/* Define to 1 if on MINIX. */
/* #undef _MINIX */
/* Define to 2 if the system does not provide POSIX.1 features except with
this defined. */
/* #undef _POSIX_1_SOURCE */
/* Define to 1 if you need to in order for `stat' and other things to work. */
/* #undef _POSIX_SOURCE */
/* Define like PROTOTYPES; this can be used by system headers. */
#define __PROTOTYPES 1
/* Define to empty if `const' does not conform to ANSI C. */
/* #undef const */
/* Define to `__inline__' or `__inline' if that's what the C compiler
calls it, or to nothing if 'inline' is not supported under any name. */
#ifndef __cplusplus
/* #undef inline */
#endif
/* Define to rpl_malloc if the replacement function should be used. */
/* #undef malloc */
/* Define to `unsigned int' if <sys/types.h> does not define. */
/* #undef size_t */
@@ -0,0 +1,259 @@
/* include/mutils/mhash_config.h.in. Generated from configure.in by autoheader. */
/* "Adler32 Algorithm" */
#undef ENABLE_ADLER32
/* "CRC32 Algorithm" */
#undef ENABLE_CRC32
/* "GOST Algorithm" */
#undef ENABLE_GOST
/* "Haval Algorithm" */
#undef ENABLE_HAVAL
/* "MD-2 Algorithm" */
#undef ENABLE_MD2
/* "MD-4 Algorithm" */
#undef ENABLE_MD4
/* "MD-5 Algorithm" */
#undef ENABLE_MD5
/* "RIPE-MD - RIPE Substitute for MD" */
#undef ENABLE_RIPEMD
/* "SHA-1 Algorithm" */
#undef ENABLE_SHA1
/* "SHA-224 and SHA-256 - SHA-2 Algorithms" */
#undef ENABLE_SHA256_SHA224
/* "SHA-384 and SHA-512 - SHA-2 Algorithms" */
#undef ENABLE_SHA512_SHA384
/* "Snefru Algorithm" */
#undef ENABLE_SNEFRU
/* "Tiger Algorithm" */
#undef ENABLE_TIGER
/* "Whirlpool Algorithm" */
#undef ENABLE_WHIRLPOOL
/* Define to 1 if you have the <assert.h> header file. */
#undef HAVE_ASSERT_H
/* Define to 1 if you have the `bcopy' function. */
#undef HAVE_BCOPY
/* Define to 1 if you have the <byteswap.h> header file. */
#undef HAVE_BYTESWAP_H
/* Define to 1 if you have the `bzero' function. */
#undef HAVE_BZERO
/* Define to 1 if you have the <ctype.h> header file. */
#undef HAVE_CTYPE_H
/* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H
/* Define to 1 if you have the <endian.h> header file. */
#undef HAVE_ENDIAN_H
/* Define to 1 if you have the <errno.h> header file. */
#undef HAVE_ERRNO_H
/* Define to 1 if you have the `fcntl' function. */
#undef HAVE_FCNTL
/* Define to 1 if you have the <fcntl.h> header file. */
#undef HAVE_FCNTL_H
/* Define to 1 if you have the `fsync' function. */
#undef HAVE_FSYNC
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
/* Define to 1 if you have the `dmalloc' library (-ldmalloc). */
#undef HAVE_LIBDMALLOC
/* Define to 1 if you have the <limits.h> header file. */
#undef HAVE_LIMITS_H
/* Define to 1 if you have the `lstat' function. */
#undef HAVE_LSTAT
/* 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 <malloc.h> header file. */
#undef HAVE_MALLOC_H
/* Define to 1 if you have the `memmove' function. */
#undef HAVE_MEMMOVE
/* 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 `mlock' function. */
#undef HAVE_MLOCK
/* Define to 1 if you have the `readdir' function. */
#undef HAVE_READDIR
/* Define to 1 if you have the `readdir_r' function. */
#undef HAVE_READDIR_R
/* Define to 1 if you have the `sigaction' function. */
#undef HAVE_SIGACTION
/* Define to 1 if you have the `signal' function. */
#undef HAVE_SIGNAL
/* Define to 1 if you have the <signal.h> header file. */
#undef HAVE_SIGNAL_H
/* Define to 1 if you have the `stat' function. */
#undef HAVE_STAT
/* Define to 1 if stdbool.h conforms to C99. */
#undef HAVE_STDBOOL_H
/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
/* Define to 1 if you have the <stdio.h> header file. */
#undef HAVE_STDIO_H
/* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
/* 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 `strtol' function. */
#undef HAVE_STRTOL
/* 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/mman.h> header file. */
#undef HAVE_SYS_MMAN_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 you have the `umask' function. */
#undef HAVE_UMASK
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* Define to 1 if you have the `utime' function. */
#undef HAVE_UTIME
/* Define to 1 if you have the <utime.h> header file. */
#undef HAVE_UTIME_H
/* Define to 1 if you have the <values.h> header file. */
#undef HAVE_VALUES_H
/* Define to 1 if the system has the type `_Bool'. */
#undef HAVE__BOOL
/* "MHash Version" */
#undef MHASH_VERSION
/* Define to 1 if your C compiler doesn't accept -c and -o together. */
#undef NO_MINUS_C_MINUS_O
/* Name of package */
#undef PACKAGE
/* 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 the C compiler supports function prototypes. */
#undef PROTOTYPES
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
/* dmalloc */
#undef USE_DMALLOC
/* Version number of package */
#undef VERSION
/* Define if using the dmalloc debugging malloc package */
#undef WITH_DMALLOC
/* 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 1 if on AIX 3.
System headers sometimes define this.
We just want to avoid a redefinition error message. */
#ifndef _ALL_SOURCE
# undef _ALL_SOURCE
#endif
/* Enable GNU extensions on systems that have them. */
#ifndef _GNU_SOURCE
# undef _GNU_SOURCE
#endif
/* Define to 1 if on MINIX. */
#undef _MINIX
/* Define to 2 if the system does not provide POSIX.1 features except with
this defined. */
#undef _POSIX_1_SOURCE
/* Define to 1 if you need to in order for `stat' and other things to work. */
#undef _POSIX_SOURCE
/* Define like PROTOTYPES; this can be used by system headers. */
#undef __PROTOTYPES
/* Define to empty if `const' does not conform to ANSI C. */
#undef const
/* Define to `__inline__' or `__inline' if that's what the C compiler
calls it, or to nothing if 'inline' is not supported under any name. */
#ifndef __cplusplus
#undef inline
#endif
/* Define to rpl_malloc if the replacement function should be used. */
#undef malloc
/* Define to `unsigned int' if <sys/types.h> does not define. */
#undef size_t
@@ -0,0 +1,121 @@
/*
* Copyright (C) 2005 Jonathan Day, Nikos Mavroyanopoulos
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Library General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/*
* The function of this header is to make sure that all system-specific headers
* files that are required are included. Eventually, system headers will only
* be pulled in when local definitions don't exist or are suboptimal.
*
* For now, we're also defining MAXINT and MININT in here, as there are
* reported problems with the way we're trying to find it.
*/
#if !defined(__MINCLUDES_H)
#define __MINCLUDES_H
#if defined(MUTILS_USE_MHASH_CONFIG)
#include <mutils/mhash_config.h>
#endif
#if defined(HAVE_LIMITS_H)
#include <limits.h>
#endif
#if defined(HAVE_STDBOOL_H)
#include <stdbool.h>
#endif
#if defined(HAVE_CTYPE_H)
#include <ctype.h>
#endif
#if defined(HAVE_SYS_TYPES_H)
#include <sys/types.h>
#endif
#if defined(HAVE_ASSERT_H)
#include <assert.h>
#endif
#if defined(HAVE_STRINGS_H)
#include <strings.h>
#endif
#if defined(HAVE_STRING_H)
#include <string.h>
#endif
#if defined(HAVE_MALLOC_H)
#include <malloc.h>
#endif
#if defined(HAVE_STDIO_H)
#include <stdio.h>
#endif
#if defined(HAVE_STDLIB_H)
#include <stdlib.h>
#endif
#if defined(HAVE_UNISTD_H)
#include <unistd.h>
#endif
#if defined(HAVE_VALUES_H)
#include <values.h>
#endif
#if defined(HAVE_SYS_MMAN_H)
#include <sys/mman.h>
#endif
#if defined(HAVE_ERRNO_H)
#include <errno.h>
#endif
#if defined(HAVE_ERROR_H)
#include <error.h>
#endif
#if defined(HAVE_INTTYPES_H)
#include <inttypes.h>
#endif
#if defined(HAVE_STDINT_H)
#include <stdint.h>
#endif
#if !defined(INT_MAX)
#define INT_MAX ((int) (~0U>>1))
#endif
#if !defined(MAXINT)
#define MAXINT INT_MAX
#endif
#if !defined(INT_MIN)
#define INT_MIN (-INT_MAX - 1)
#endif
#if !defined(MININT)
#define MININT INT_MIN
#endif
#endif
@@ -0,0 +1,58 @@
/*
* Copyright (C) 2005 Jonathan Day, Nikos Mavroyanopoulos
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Library General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#if !defined(__MTYPES_H)
#define __MTYPES_H
#include <mutils/mutils.h>
typedef struct __KEYGEN
{
hashid hash_algorithm[2];
mutils_word32 count;
void *salt;
mutils_word32 salt_size;
} KEYGEN;
typedef void (*INIT_FUNC)( void*);
typedef void (*HASH_FUNC)(void*, const void*, int);
typedef void (*FINAL_FUNC)(void*);
typedef void (*DEINIT_FUNC)(void*, unsigned char*);
typedef struct __MHASH_INSTANCE
{
mutils_word32 hmac_key_size;
mutils_word32 hmac_block;
mutils_word8 *hmac_key;
mutils_word8 *state;
mutils_word32 state_size;
hashid algorithm_given;
HASH_FUNC hash_func;
FINAL_FUNC final_func;
DEINIT_FUNC deinit_func;
} MHASH_INSTANCE;
typedef MHASH_INSTANCE *MHASH;
#define MHASH_FAILED ((MHASH) 0x0)
#endif
@@ -0,0 +1,255 @@
/*
* Copyright (C) 2005 Jonathan Day, Nikos Mavroyanopoulos
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Library General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#if !defined(__MUTILS_H)
#define __MUTILS_H
#include <mutils/mincludes.h>
#if defined(const)
#define __const const
#endif
/*
* The vast majority of user code won't care about mutils, so changes to
* this helper library API should not result in a change to the MHASH API
* version number.
*/
#define MUTILS_API 20060624
/* FIXME: We're assuming we've a standard integer types header and that it has been included
* correctly.
*/
#define MUTILS_STANDARD_TYPES 1
#if defined(MUTILS_STANDARD_TYPES)
#define TIGER_64BIT
#define mutils_word64 uint64_t
#define mutils_word32 uint32_t
#define mutils_word16 uint16_t
#define mutils_word8 uint8_t
#else /* Ok, we don't have the standard integer type definitions */
#if SIZEOF_UNSIGNED_LONG_INT == 8
typedef unsigned long int mutils_word64;
#define TIGER_64BIT
#elif SIZEOF_UNSIGNED_LONG_LONG_INT == 8
typedef unsigned long long int mutils_word64;
#else
#error "Cannot find a 64 bit integer in your system, sorry."
#endif
#if SIZEOF_UNSIGNED_LONG_INT == 4
typedef unsigned long int mutils_word32;
#elif SIZEOF_UNSIGNED_INT == 4
typedef unsigned int mutils_word32;
#else
#error "Cannot find a 32 bit integer in your system, sorry."
#endif
#if SIZEOF_UNSIGNED_INT == 2
typedef unsigned int mutils_word16;
#elif SIZEOF_UNSIGNED_SHORT_INT == 2
typedef unsigned short int mutils_word16;
#else
#error "Cannot find a 16 bit integer in your system, sorry."
#endif
#if SIZEOF_UNSIGNED_CHAR == 1
typedef unsigned char mutils_word8;
#else
#error "Cannot find an 8 bit char in your system, sorry."
#endif
#endif /* End of standard integer type declarationsd */
/*
* Due to buggy implementations of the boolean headers in some systems,
* we have to detect the boolean values seperately from the boolean type.
* A big thank you to Heiko Lehmann for spotting the bug. Unfortunately,
* this fix may not be enough, as it is only going to work on things the
* precompiler knows about.
*
* Why go to all this trouble over something that should have a standard
* value anyway? Because.
*/
#if defined(HAVE__BOOL)
#define mutils_boolean _Bool
#else
typedef char mutils_boolean;
#endif
#if defined(false)
#define MUTILS_FALSE (mutils_boolean) false
#else
#if defined(FALSE)
#define MUTILS_FALSE (mutils_boolean) FALSE
#else
#define MUTILS_FALSE (mutils_boolean) 0
#endif /* FALSE */
#endif /* false */
#if defined(true)
#define MUTILS_TRUE (mutils_boolean) true
#else
#if defined(TRUE)
#define MUTILS_TRUE (mutils_boolean) TRUE
#else
#define MUTILS_TRUE (mutils_boolean) -1
#endif /* TRUE */
#endif /* true */
/*
* Other than OK, the only defined values should be for a category of error.
* Even then, the values shouldn't be assumed. Their only function is to
* make it easy to programmatically identify the nature of the error and to
* ensure a library upgrade won't break existing binaries, should new error
* codes be introduced.
*/
typedef enum __mutils_error_codes
{
MUTILS_OK = 0,
MUTILS_SYSTEM_ERROR = 0x100,
MUTILS_UNSPECIFIED_ERROR,
MUTILS_SYSTEM_RESOURCE_ERROR,
MUTILS_PARAMETER_ERROR = 0x200,
MUTILS_INVALID_FUNCTION,
MUTILS_INVALID_INPUT_BUFFER,
MUTILS_INVALID_OUTPUT_BUFFER,
MUTILS_INVALID_PASSES,
MUTILS_INVALID_FORMAT,
MUTILS_INVALID_SIZE,
MUTILS_INVALID_RESULT
} mutils_error_codes;
#define mutils_error mutils_word32
#include <mutils/mglobal.h>
/*
* Some useful, generic endian macros.
*/
#define mutils_swapendian64(x) \
((mutils_word64) \
(((x) & 0xff00000000000000ull) >> 56) | \
(((x) & 0x00ff000000000000ull) >> 40) | \
(((x) & 0x0000ff0000000000ull) >> 24) | \
(((x) & 0x000000ff00000000ull) >> 8) | \
(((x) & 0x00000000ff000000ull) << 8) | \
(((x) & 0x0000000000ff0000ull) << 24) | \
(((x) & 0x000000000000ff00ull) << 40) | \
(((x) & 0x00000000000000ffull) << 56))
#define mutils_swapendian32(a) \
((mutils_word32) \
(((a & (mutils_word32) 0x000000ffU) << 24) | \
((a & (mutils_word32) 0x0000ff00U) << 8) | \
((a & (mutils_word32) 0x00ff0000U) >> 8) | \
((a & (mutils_word32) 0xff000000U) >> 24)) \
)
#define mutils_swapendian16(a) \
((mutils_word16) \
(((a & (mutils_word16) 0x00ffU) << 8) | \
((a & (mutils_word16) 0xff00U) >> 8)) \
)
/* Change the endianness of the data if (and only if) the data type we want
* is the opposite from the native endianness. This allows us to have some
* reasonably generic macros, provided we always start from the native
* ordering.
*/
#if defined(WORDS_BIGENDIAN)
#define mutils_lend64(n) mutils_swapendian64(n)
#define mutils_lend32(n) mutils_swapendian32(n)
#define mutils_lend16(n) mutils_swapendian16(n)
#define mutils_bend64(n) n
#define mutils_bend32(n) n
#define mutils_bend16(n) n
#define mutils_lend2sys64(n) mutils_swapendian64(n)
#define mutils_lend2sys32(n) mutils_swapendian32(n)
#define mutils_lend2sys16(n) mutils_swapendian16(n)
#define mutils_bend2sys32(n) n
#define mutils_bend2sys16(n) n
#else
#define mutils_lend64(n) n
#define mutils_lend32(n) n
#define mutils_lend16(n) n
#define mutils_bend64(n) mutils_swapendian64(n)
#define mutils_bend32(n) mutils_swapendian32(n)
#define mutils_bend16(n) mutils_swapendian16(n)
#define mutils_lend2sys64(n) n
#define mutils_lend2sys32(n) n
#define mutils_lend2sys16(n) n
#define mutils_bend2sys64(n) mutils_swapendian64(n)
#define mutils_bend2sys32(n) mutils_swapendian32(n)
#define mutils_bend2sys16(n) mutils_swapendian16(n)
#endif
int mutils_mlock(__const void *addr, __const mutils_word32 len);
int mutils_munlock(__const void *addr, __const mutils_word32 len);
void *mutils_malloc(__const mutils_word32 n);
void *mutils_realloc(__const void *ptr, __const mutils_word32 n);
void mutils_free(__const void *ptr);
void mutils_bzero(void *s, __const mutils_word32 n);
void mutils_memset(void *dest, __const mutils_word8 c, __const mutils_word32 n);
void mutils_memcpy(void *dest, __const void *src, __const mutils_word32 n);
void mutils_memmove(void *dest, __const void *src, __const mutils_word32 n);
int mutils_memcmp(__const void *s1, __const void *s2, __const mutils_word32 n);
mutils_word32 mutils_strlen(__const mutils_word8 *str);
mutils_word8 *mutils_strdup(__const mutils_word8 *str);
mutils_word8 *mutils_strcat(mutils_word8 *dest, __const mutils_word8 *src);
mutils_word8 *mutils_strcpy(mutils_word8 *dest, __const mutils_word8 *src);
mutils_word8 *mutils_strncpy(mutils_word8 *dest, __const mutils_word8 *src, __const mutils_word32 n);
int mutils_strcmp(__const mutils_word8 *src1, __const mutils_word8 *src2);
int mutils_strncmp(__const mutils_word8 *src1, __const mutils_word8 *src2, __const mutils_word32 n);
long mutils_strtol(__const mutils_word8 *nptr, mutils_word8 **endptr, __const mutils_word8 base);
mutils_word32 mutils_word32swap(mutils_word32 x);
mutils_word32 *mutils_word32nswap(mutils_word32 *x, mutils_word32 n, mutils_boolean destructive);
mutils_word8 *mutils_asciify(mutils_word8 *in, __const mutils_word32 len);
mutils_boolean mutils_thequals(mutils_word8 *text, mutils_word8 *hash, __const mutils_word32 len);
#endif /* __MUTILS_H */