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,526 @@
# Makefile.in generated by automake 1.9.6 from Makefile.am.
# lib/Makefile. Generated from Makefile.in by configure.
# 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.
#AUTOMAKE_OPTIONS = foreign
srcdir = .
top_srcdir = ..
pkgdatadir = $(datadir)/mhash
pkglibdir = $(libdir)/mhash
pkgincludedir = $(includedir)/mhash
top_builddir = ..
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
INSTALL = /usr/bin/install -c
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 = x86_64-unknown-linux-gnu
host_triplet = x86_64-unknown-linux-gnu
target_triplet = x86_64-unknown-linux-gnu
subdir = lib
DIST_COMMON = $(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 =
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)$(libdir)"
libLTLIBRARIES_INSTALL = $(INSTALL)
LTLIBRARIES = $(lib_LTLIBRARIES)
libmhash_la_LIBADD =
am__objects_1 = mhash.lo stdfns.lo
am__objects_2 = keygen_hex.lo keygen_mcrypt.lo keygen_asis.lo \
keygen.lo keygen_s2k.lo
am__objects_3 = crc32.lo adler32.lo
am__objects_4 = md2.lo md4.lo md5.lo ripemd.lo
am__objects_5 = sha1.lo sha256_sha224.lo sha512_sha384.lo
am__objects_6 = tiger.lo tiger_sboxes.lo
am__objects_7 = haval.lo gosthash.lo whirlpool.lo snefru.lo
am_libmhash_la_OBJECTS = $(am__objects_1) $(am__objects_2) \
$(am__objects_3) $(am__objects_4) $(am__objects_5) \
$(am__objects_6) $(am__objects_7)
libmhash_la_OBJECTS = $(am_libmhash_la_OBJECTS)
DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)/include/mutils
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) \
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
$(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
LINK = $(LIBTOOL) --tag=CC --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(AM_LDFLAGS) $(LDFLAGS) -o $@
SOURCES = $(libmhash_la_SOURCES)
DIST_SOURCES = $(libmhash_la_SOURCES)
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = ${SHELL} /root/work/sdkfreebsd64.bak/libs/mhash-0.9.9.9/missing --run aclocal-1.9
AMDEP_FALSE = #
AMDEP_TRUE =
AMTAR = ${SHELL} /root/work/sdkfreebsd64.bak/libs/mhash-0.9.9.9/missing --run tar
AR = ar
AS = as
AUTOCONF = ${SHELL} /root/work/sdkfreebsd64.bak/libs/mhash-0.9.9.9/missing --run autoconf
AUTOHEADER = ${SHELL} /root/work/sdkfreebsd64.bak/libs/mhash-0.9.9.9/missing --run autoheader
AUTOMAKE = ${SHELL} /root/work/sdkfreebsd64.bak/libs/mhash-0.9.9.9/missing --run automake-1.9
AWK = gawk
CC = gcc
CCAS = gcc
CCASFLAGS = -g -O2
CCDEPMODE = depmode=gcc3
CFLAGS = -g -O2
CPP = gcc -E
CPPFLAGS =
CXX = g++
CXXCPP = g++ -E
CXXDEPMODE = depmode=gcc3
CXXFLAGS = -g -O2
CYGPATH_W = echo
DEFS = -DHAVE_CONFIG_H
DEPDIR = .deps
DLLTOOL = dlltool
ECHO = echo
ECHO_C =
ECHO_N = -n
ECHO_T =
EGREP = /bin/grep -E
EXEEXT =
F77 =
FFLAGS =
GREP = /bin/grep
INSTALL_DATA = ${INSTALL} -m 644
INSTALL_PROGRAM = ${INSTALL}
INSTALL_SCRIPT = ${INSTALL}
INSTALL_STRIP_PROGRAM = ${SHELL} $(install_sh) -c -s
LDFLAGS =
LIBOBJS =
LIBS =
LIBTOOL = $(SHELL) $(top_builddir)/libtool
LN_S = ln -s
LTLIBOBJS =
MAINT = #
MAINTAINER_MODE_FALSE =
MAINTAINER_MODE_TRUE = #
MAKEINFO = ${SHELL} /root/work/sdkfreebsd64.bak/libs/mhash-0.9.9.9/missing --run makeinfo
OBJDUMP = objdump
OBJEXT = o
PACKAGE = mhash
PACKAGE_BUGREPORT = mhash-devel@sourceforge.net
PACKAGE_NAME = MHASH
PACKAGE_STRING = MHASH 0.9.9
PACKAGE_TARNAME = mhash
PACKAGE_VERSION = 0.9.9
PATH_SEPARATOR = :
RANLIB = ranlib
SET_MAKE =
SHELL = /bin/sh
STRIP = strip
VERSION = 0.9.9
ac_ct_CC = gcc
ac_ct_CXX = g++
ac_ct_F77 =
am__fastdepCC_FALSE = #
am__fastdepCC_TRUE =
am__fastdepCXX_FALSE = #
am__fastdepCXX_TRUE =
am__include = include
am__leading_dot = .
am__quote =
am__tar = ${AMTAR} chof - "$$tardir"
am__untar = ${AMTAR} xf -
bindir = ${exec_prefix}/bin
build = x86_64-unknown-linux-gnu
build_alias =
build_cpu = x86_64
build_os = linux-gnu
build_vendor = unknown
datadir = ${datarootdir}
datarootdir = ${prefix}/share
docdir = ${datarootdir}/doc/${PACKAGE_TARNAME}
dvidir = ${docdir}
exec_prefix = ${prefix}
host = x86_64-unknown-linux-gnu
host_alias =
host_cpu = x86_64
host_os = linux-gnu
host_vendor = unknown
htmldir = ${docdir}
includedir = ${prefix}/include
infodir = ${datarootdir}/info
install_sh = /root/work/sdkfreebsd64.bak/libs/mhash-0.9.9.9/install-sh
libdir = ${exec_prefix}/lib
libexecdir = ${exec_prefix}/libexec
localedir = ${datarootdir}/locale
localstatedir = ${prefix}/var
mandir = ${datarootdir}/man
mkdir_p = mkdir -p --
oldincludedir = /usr/include
pdfdir = ${docdir}
prefix = /usr/local
program_transform_name = s,x,x,
psdir = ${docdir}
sbindir = ${exec_prefix}/sbin
sharedstatedir = ${prefix}/com
sysconfdir = ${prefix}/etc
target = x86_64-unknown-linux-gnu
target_alias =
target_cpu = x86_64
target_os = linux-gnu
target_vendor = unknown
AM_CPPFLAGS = -I../include
lib_LTLIBRARIES = libmhash.la
FRAMEWORK = mhash.c stdfns.c mhash.h mhash_int.h libdefs.h
KEYGEN = keygen_hex.c keygen_mcrypt.c keygen_asis.c keygen.c keygen_s2k.c \
keygen.h
CRC = crc32.c mhash_crc32.h adler32.c mhash_adler32.h
MD_SERIES = md2.c mhash_md2.h md4.c mhash_md4.h md5.c mhash_md5.h \
ripemd.c mhash_ripemd.h
SHA_SERIES = sha1.c sha256_sha224.c sha512_sha384.c \
mhash_sha1.h mhash_sha256_sha224.h mhash_sha512_sha384.h
TIGER = tiger.c tiger_sboxes.c mhash_tiger.h
MISCELLANEOUS = haval.c mhash_haval.h gosthash.c mhash_gost.h \
whirlpool.c mhash_whirlpool.h snefru.c mhash_snefru.h
libmhash_la_SOURCES = $(FRAMEWORK) $(KEYGEN) $(CRC) $(MD_SERIES) \
$(SHA_SERIES) $(TIGER) $(MISCELLANEOUS)
libmhash_la_LDFLAGS = -version-info 2:1
EXTRA_DIST = libmhash.sym
all: all-am
.SUFFIXES:
.SUFFIXES: .c .lo .o .obj
$(srcdir)/Makefile.in: # $(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 lib/Makefile'; \
cd $(top_srcdir) && \
$(AUTOMAKE) --gnu lib/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: # $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): # $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
install-libLTLIBRARIES: $(lib_LTLIBRARIES)
@$(NORMAL_INSTALL)
test -z "$(libdir)" || $(mkdir_p) "$(DESTDIR)$(libdir)"
@list='$(lib_LTLIBRARIES)'; for p in $$list; do \
if test -f $$p; then \
f=$(am__strip_dir) \
echo " $(LIBTOOL) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(libdir)/$$f'"; \
$(LIBTOOL) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(libdir)/$$f"; \
else :; fi; \
done
uninstall-libLTLIBRARIES:
@$(NORMAL_UNINSTALL)
@set -x; list='$(lib_LTLIBRARIES)'; for p in $$list; do \
p=$(am__strip_dir) \
echo " $(LIBTOOL) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$p'"; \
$(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$p"; \
done
clean-libLTLIBRARIES:
-test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
@list='$(lib_LTLIBRARIES)'; for p in $$list; do \
dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
test "$$dir" != "$$p" || dir=.; \
echo "rm -f \"$${dir}/so_locations\""; \
rm -f "$${dir}/so_locations"; \
done
libmhash.la: $(libmhash_la_OBJECTS) $(libmhash_la_DEPENDENCIES)
$(LINK) -rpath $(libdir) $(libmhash_la_LDFLAGS) $(libmhash_la_OBJECTS) $(libmhash_la_LIBADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
distclean-compile:
-rm -f *.tab.c
include ./$(DEPDIR)/adler32.Plo
include ./$(DEPDIR)/crc32.Plo
include ./$(DEPDIR)/gosthash.Plo
include ./$(DEPDIR)/haval.Plo
include ./$(DEPDIR)/keygen.Plo
include ./$(DEPDIR)/keygen_asis.Plo
include ./$(DEPDIR)/keygen_hex.Plo
include ./$(DEPDIR)/keygen_mcrypt.Plo
include ./$(DEPDIR)/keygen_s2k.Plo
include ./$(DEPDIR)/md2.Plo
include ./$(DEPDIR)/md4.Plo
include ./$(DEPDIR)/md5.Plo
include ./$(DEPDIR)/mhash.Plo
include ./$(DEPDIR)/ripemd.Plo
include ./$(DEPDIR)/sha1.Plo
include ./$(DEPDIR)/sha256_sha224.Plo
include ./$(DEPDIR)/sha512_sha384.Plo
include ./$(DEPDIR)/snefru.Plo
include ./$(DEPDIR)/stdfns.Plo
include ./$(DEPDIR)/tiger.Plo
include ./$(DEPDIR)/tiger_sboxes.Plo
include ./$(DEPDIR)/whirlpool.Plo
.c.o:
if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
# source='$<' object='$@' libtool=no \
# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \
# $(COMPILE) -c $<
.c.obj:
if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \
then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
# source='$<' object='$@' libtool=no \
# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \
# $(COMPILE) -c `$(CYGPATH_W) '$<'`
.c.lo:
if $(LTCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Plo"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
# source='$<' object='$@' libtool=yes \
# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \
# $(LTCOMPILE) -c -o $@ $<
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
distclean-libtool:
-rm -f libtool
uninstall-info-am:
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)
@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 $(LTLIBRARIES)
installdirs:
for dir in "$(DESTDIR)$(libdir)"; 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-libLTLIBRARIES clean-libtool \
mostlyclean-am
distclean: distclean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-libtool distclean-tags
dvi: dvi-am
dvi-am:
html: html-am
info: info-am
info-am:
install-data-am:
install-exec-am: install-libLTLIBRARIES
install-info: install-info-am
install-man:
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-compile mostlyclean-generic \
mostlyclean-libtool
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am: uninstall-info-am uninstall-libLTLIBRARIES
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
clean-libLTLIBRARIES clean-libtool ctags dist-hook distclean \
distclean-compile 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-libLTLIBRARIES install-man install-strip installcheck \
installcheck-am installdirs maintainer-clean \
maintainer-clean-generic mostlyclean mostlyclean-compile \
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
tags uninstall uninstall-am uninstall-info-am \
uninstall-libLTLIBRARIES
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,33 @@
#AUTOMAKE_OPTIONS = foreign
AM_CPPFLAGS = -I../include
lib_LTLIBRARIES = libmhash.la
FRAMEWORK = mhash.c stdfns.c mhash.h mhash_int.h libdefs.h
KEYGEN = keygen_hex.c keygen_mcrypt.c keygen_asis.c keygen.c keygen_s2k.c \
keygen.h
CRC = crc32.c mhash_crc32.h adler32.c mhash_adler32.h
MD_SERIES = md2.c mhash_md2.h md4.c mhash_md4.h md5.c mhash_md5.h \
ripemd.c mhash_ripemd.h
SHA_SERIES = sha1.c sha256_sha224.c sha512_sha384.c \
mhash_sha1.h mhash_sha256_sha224.h mhash_sha512_sha384.h
TIGER = tiger.c tiger_sboxes.c mhash_tiger.h
MISCELLANEOUS = haval.c mhash_haval.h gosthash.c mhash_gost.h \
whirlpool.c mhash_whirlpool.h snefru.c mhash_snefru.h
libmhash_la_SOURCES = $(FRAMEWORK) $(KEYGEN) $(CRC) $(MD_SERIES) \
$(SHA_SERIES) $(TIGER) $(MISCELLANEOUS)
libmhash_la_LDFLAGS = -version-info 2:1
EXTRA_DIST = libmhash.sym
dist-hook:
find $(distdir) -name CVS -o -name .cvsignore | xargs rm -rf
@@ -0,0 +1,526 @@
# 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 = lib
DIST_COMMON = $(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 =
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)$(libdir)"
libLTLIBRARIES_INSTALL = $(INSTALL)
LTLIBRARIES = $(lib_LTLIBRARIES)
libmhash_la_LIBADD =
am__objects_1 = mhash.lo stdfns.lo
am__objects_2 = keygen_hex.lo keygen_mcrypt.lo keygen_asis.lo \
keygen.lo keygen_s2k.lo
am__objects_3 = crc32.lo adler32.lo
am__objects_4 = md2.lo md4.lo md5.lo ripemd.lo
am__objects_5 = sha1.lo sha256_sha224.lo sha512_sha384.lo
am__objects_6 = tiger.lo tiger_sboxes.lo
am__objects_7 = haval.lo gosthash.lo whirlpool.lo snefru.lo
am_libmhash_la_OBJECTS = $(am__objects_1) $(am__objects_2) \
$(am__objects_3) $(am__objects_4) $(am__objects_5) \
$(am__objects_6) $(am__objects_7)
libmhash_la_OBJECTS = $(am_libmhash_la_OBJECTS)
DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)/include/mutils
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) \
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
$(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
LINK = $(LIBTOOL) --tag=CC --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(AM_LDFLAGS) $(LDFLAGS) -o $@
SOURCES = $(libmhash_la_SOURCES)
DIST_SOURCES = $(libmhash_la_SOURCES)
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@
AM_CPPFLAGS = -I../include
lib_LTLIBRARIES = libmhash.la
FRAMEWORK = mhash.c stdfns.c mhash.h mhash_int.h libdefs.h
KEYGEN = keygen_hex.c keygen_mcrypt.c keygen_asis.c keygen.c keygen_s2k.c \
keygen.h
CRC = crc32.c mhash_crc32.h adler32.c mhash_adler32.h
MD_SERIES = md2.c mhash_md2.h md4.c mhash_md4.h md5.c mhash_md5.h \
ripemd.c mhash_ripemd.h
SHA_SERIES = sha1.c sha256_sha224.c sha512_sha384.c \
mhash_sha1.h mhash_sha256_sha224.h mhash_sha512_sha384.h
TIGER = tiger.c tiger_sboxes.c mhash_tiger.h
MISCELLANEOUS = haval.c mhash_haval.h gosthash.c mhash_gost.h \
whirlpool.c mhash_whirlpool.h snefru.c mhash_snefru.h
libmhash_la_SOURCES = $(FRAMEWORK) $(KEYGEN) $(CRC) $(MD_SERIES) \
$(SHA_SERIES) $(TIGER) $(MISCELLANEOUS)
libmhash_la_LDFLAGS = -version-info 2:1
EXTRA_DIST = libmhash.sym
all: all-am
.SUFFIXES:
.SUFFIXES: .c .lo .o .obj
$(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 lib/Makefile'; \
cd $(top_srcdir) && \
$(AUTOMAKE) --gnu lib/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
install-libLTLIBRARIES: $(lib_LTLIBRARIES)
@$(NORMAL_INSTALL)
test -z "$(libdir)" || $(mkdir_p) "$(DESTDIR)$(libdir)"
@list='$(lib_LTLIBRARIES)'; for p in $$list; do \
if test -f $$p; then \
f=$(am__strip_dir) \
echo " $(LIBTOOL) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(libdir)/$$f'"; \
$(LIBTOOL) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(libdir)/$$f"; \
else :; fi; \
done
uninstall-libLTLIBRARIES:
@$(NORMAL_UNINSTALL)
@set -x; list='$(lib_LTLIBRARIES)'; for p in $$list; do \
p=$(am__strip_dir) \
echo " $(LIBTOOL) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$p'"; \
$(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$p"; \
done
clean-libLTLIBRARIES:
-test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
@list='$(lib_LTLIBRARIES)'; for p in $$list; do \
dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
test "$$dir" != "$$p" || dir=.; \
echo "rm -f \"$${dir}/so_locations\""; \
rm -f "$${dir}/so_locations"; \
done
libmhash.la: $(libmhash_la_OBJECTS) $(libmhash_la_DEPENDENCIES)
$(LINK) -rpath $(libdir) $(libmhash_la_LDFLAGS) $(libmhash_la_OBJECTS) $(libmhash_la_LIBADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/adler32.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/crc32.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gosthash.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/haval.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/keygen.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/keygen_asis.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/keygen_hex.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/keygen_mcrypt.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/keygen_s2k.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/md2.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/md4.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/md5.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mhash.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ripemd.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sha1.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sha256_sha224.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sha512_sha384.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/snefru.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stdfns.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tiger.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tiger_sboxes.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/whirlpool.Plo@am__quote@
.c.o:
@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(COMPILE) -c $<
.c.obj:
@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
.c.lo:
@am__fastdepCC_TRUE@ if $(LTCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Plo"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
distclean-libtool:
-rm -f libtool
uninstall-info-am:
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)
@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 $(LTLIBRARIES)
installdirs:
for dir in "$(DESTDIR)$(libdir)"; 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-libLTLIBRARIES clean-libtool \
mostlyclean-am
distclean: distclean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-libtool distclean-tags
dvi: dvi-am
dvi-am:
html: html-am
info: info-am
info-am:
install-data-am:
install-exec-am: install-libLTLIBRARIES
install-info: install-info-am
install-man:
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-compile mostlyclean-generic \
mostlyclean-libtool
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am: uninstall-info-am uninstall-libLTLIBRARIES
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
clean-libLTLIBRARIES clean-libtool ctags dist-hook distclean \
distclean-compile 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-libLTLIBRARIES install-man install-strip installcheck \
installcheck-am installdirs maintainer-clean \
maintainer-clean-generic mostlyclean mostlyclean-compile \
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
tags uninstall uninstall-am uninstall-info-am \
uninstall-libLTLIBRARIES
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,80 @@
/*
* 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.
*/
#include "libdefs.h"
#if defined(ENABLE_ADLER32)
#include "mhash_adler32.h"
/* This is the implementation of Manuel Kasper <mk@neon1.net>.
*/
void mhash_clear_adler32(mutils_word32 *adler)
{
*adler = 0x1;
}
void mhash_get_adler32(__const mutils_word32 *adler, void *ret)
{
mutils_word32 tmp = *adler;
#if defined(WORDS_BIGENDIAN)
tmp = mutils_word32swap(tmp);
#endif
if (ret!=NULL)
{
mutils_memcpy(ret, &tmp, sizeof(mutils_word32));
}
}
/**
* Generic C implementation of Adler32
* Peak performance:
* VC++: 52 MB/s on AMD K7 600 MHz
* gcc: 44 MB/s
* Borland 5: 48 MB/s
* (all with speed optimizations on)
*/
void mhash_adler32(mutils_word32 * adler, __const void *given_buf, mutils_word32 len)
{
mutils_word32 s1 = (*adler) & 0x0000FFFF;
mutils_word32 s2 = ((*adler) >> 16) & 0x0000FFFF;
mutils_word32 n;
mutils_word8 *p = (mutils_word8 *) given_buf;
for (n = 0; n < len; n++, p++)
{
s1 += *p;
if (s1 >= 65521) /* using modulo took about 7 times longer on my CPU! */
{
s1 -= 65521; /* WARNING: it's meant to be >= 65521, not just > ! */
}
s2 += s1;
if (s2 >= 65521) /* same warning applies here, too */
{
s2 -= 65521;
}
}
*adler = (s2 << 16) + s1;
}
#endif /* ENABLE_ADLER32 */
@@ -0,0 +1,219 @@
/*
* Copyright (C) 1998 Nikos Mavroyanopoulos
* Copyright (C) 1999,2000 Sascha Schumman, 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.
*/
#include "libdefs.h"
#ifdef ENABLE_CRC32
#include "mhash_crc32.h"
/** This polynomial ( 0xEDB88320L) DOES generate the same CRC values as ZMODEM and PKZIP
*/
static __const mutils_word32 crc32_table_b[256] =
{
0x0UL, 0x77073096UL, 0xEE0E612CUL, 0x990951BAUL, 0x76DC419UL,
0x706AF48FUL, 0xE963A535UL, 0x9E6495A3UL, 0xEDB8832UL, 0x79DCB8A4UL,
0xE0D5E91EUL, 0x97D2D988UL, 0x9B64C2BUL, 0x7EB17CBDUL, 0xE7B82D07UL,
0x90BF1D91UL, 0x1DB71064UL, 0x6AB020F2UL, 0xF3B97148UL, 0x84BE41DEUL,
0x1ADAD47DUL, 0x6DDDE4EBUL, 0xF4D4B551UL, 0x83D385C7UL, 0x136C9856UL,
0x646BA8C0UL, 0xFD62F97AUL, 0x8A65C9ECUL, 0x14015C4FUL, 0x63066CD9UL,
0xFA0F3D63UL, 0x8D080DF5UL, 0x3B6E20C8UL, 0x4C69105EUL, 0xD56041E4UL,
0xA2677172UL, 0x3C03E4D1UL, 0x4B04D447UL, 0xD20D85FDUL, 0xA50AB56BUL,
0x35B5A8FAUL, 0x42B2986CUL, 0xDBBBC9D6UL, 0xACBCF940UL, 0x32D86CE3UL,
0x45DF5C75UL, 0xDCD60DCFUL, 0xABD13D59UL, 0x26D930ACUL, 0x51DE003AUL,
0xC8D75180UL, 0xBFD06116UL, 0x21B4F4B5UL, 0x56B3C423UL, 0xCFBA9599UL,
0xB8BDA50FUL, 0x2802B89EUL, 0x5F058808UL, 0xC60CD9B2UL, 0xB10BE924UL,
0x2F6F7C87UL, 0x58684C11UL, 0xC1611DABUL, 0xB6662D3DUL, 0x76DC4190UL,
0x1DB7106UL, 0x98D220BCUL, 0xEFD5102AUL, 0x71B18589UL, 0x6B6B51FUL,
0x9FBFE4A5UL, 0xE8B8D433UL, 0x7807C9A2UL, 0xF00F934UL, 0x9609A88EUL,
0xE10E9818UL, 0x7F6A0DBBUL, 0x86D3D2DUL, 0x91646C97UL, 0xE6635C01UL,
0x6B6B51F4UL, 0x1C6C6162UL, 0x856530D8UL, 0xF262004EUL, 0x6C0695EDUL,
0x1B01A57BUL, 0x8208F4C1UL, 0xF50FC457UL, 0x65B0D9C6UL, 0x12B7E950UL,
0x8BBEB8EAUL, 0xFCB9887CUL, 0x62DD1DDFUL, 0x15DA2D49UL, 0x8CD37CF3UL,
0xFBD44C65UL, 0x4DB26158UL, 0x3AB551CEUL, 0xA3BC0074UL, 0xD4BB30E2UL,
0x4ADFA541UL, 0x3DD895D7UL, 0xA4D1C46DUL, 0xD3D6F4FBUL, 0x4369E96AUL,
0x346ED9FCUL, 0xAD678846UL, 0xDA60B8D0UL, 0x44042D73UL, 0x33031DE5UL,
0xAA0A4C5FUL, 0xDD0D7CC9UL, 0x5005713CUL, 0x270241AAUL, 0xBE0B1010UL,
0xC90C2086UL, 0x5768B525UL, 0x206F85B3UL, 0xB966D409UL, 0xCE61E49FUL,
0x5EDEF90EUL, 0x29D9C998UL, 0xB0D09822UL, 0xC7D7A8B4UL, 0x59B33D17UL,
0x2EB40D81UL, 0xB7BD5C3BUL, 0xC0BA6CADUL, 0xEDB88320UL, 0x9ABFB3B6UL,
0x3B6E20CUL, 0x74B1D29AUL, 0xEAD54739UL, 0x9DD277AFUL, 0x4DB2615UL,
0x73DC1683UL, 0xE3630B12UL, 0x94643B84UL, 0xD6D6A3EUL, 0x7A6A5AA8UL,
0xE40ECF0BUL, 0x9309FF9DUL, 0xA00AE27UL, 0x7D079EB1UL, 0xF00F9344UL,
0x8708A3D2UL, 0x1E01F268UL, 0x6906C2FEUL, 0xF762575DUL, 0x806567CBUL,
0x196C3671UL, 0x6E6B06E7UL, 0xFED41B76UL, 0x89D32BE0UL, 0x10DA7A5AUL,
0x67DD4ACCUL, 0xF9B9DF6FUL, 0x8EBEEFF9UL, 0x17B7BE43UL, 0x60B08ED5UL,
0xD6D6A3E8UL, 0xA1D1937EUL, 0x38D8C2C4UL, 0x4FDFF252UL, 0xD1BB67F1UL,
0xA6BC5767UL, 0x3FB506DDUL, 0x48B2364BUL, 0xD80D2BDAUL, 0xAF0A1B4CUL,
0x36034AF6UL, 0x41047A60UL, 0xDF60EFC3UL, 0xA867DF55UL, 0x316E8EEFUL,
0x4669BE79UL, 0xCB61B38CUL, 0xBC66831AUL, 0x256FD2A0UL, 0x5268E236UL,
0xCC0C7795UL, 0xBB0B4703UL, 0x220216B9UL, 0x5505262FUL, 0xC5BA3BBEUL,
0xB2BD0B28UL, 0x2BB45A92UL, 0x5CB36A04UL, 0xC2D7FFA7UL, 0xB5D0CF31UL,
0x2CD99E8BUL, 0x5BDEAE1DUL, 0x9B64C2B0UL, 0xEC63F226UL, 0x756AA39CUL,
0x26D930AUL, 0x9C0906A9UL, 0xEB0E363FUL, 0x72076785UL, 0x5005713UL,
0x95BF4A82UL, 0xE2B87A14UL, 0x7BB12BAEUL, 0xCB61B38UL, 0x92D28E9BUL,
0xE5D5BE0DUL, 0x7CDCEFB7UL, 0xBDBDF21UL, 0x86D3D2D4UL, 0xF1D4E242UL,
0x68DDB3F8UL, 0x1FDA836EUL, 0x81BE16CDUL, 0xF6B9265BUL, 0x6FB077E1UL,
0x18B74777UL, 0x88085AE6UL, 0xFF0F6A70UL, 0x66063BCAUL, 0x11010B5CUL,
0x8F659EFFUL, 0xF862AE69UL, 0x616BFFD3UL, 0x166CCF45UL, 0xA00AE278UL,
0xD70DD2EEUL, 0x4E048354UL, 0x3903B3C2UL, 0xA7672661UL, 0xD06016F7UL,
0x4969474DUL, 0x3E6E77DBUL, 0xAED16A4AUL, 0xD9D65ADCUL, 0x40DF0B66UL,
0x37D83BF0UL, 0xA9BCAE53UL, 0xDEBB9EC5UL, 0x47B2CF7FUL, 0x30B5FFE9UL,
0xBDBDF21CUL, 0xCABAC28AUL, 0x53B39330UL, 0x24B4A3A6UL, 0xBAD03605UL,
0xCDD70693UL, 0x54DE5729UL, 0x23D967BFUL, 0xB3667A2EUL, 0xC4614AB8UL,
0x5D681B02UL, 0x2A6F2B94UL, 0xB40BBE37UL, 0xC30C8EA1UL, 0x5A05DF1BUL,
0x2D02EF8DUL
};
/** This polynomial (0x04c11db7) is used at: AUTODIN II, Ethernet, & FDDI
*/
static __const mutils_word32 crc32_table[256] =
{
0x00000000UL, 0x04c11db7UL, 0x09823b6eUL, 0x0d4326d9UL,
0x130476dcUL, 0x17c56b6bUL, 0x1a864db2UL, 0x1e475005UL,
0x2608edb8UL, 0x22c9f00fUL, 0x2f8ad6d6UL, 0x2b4bcb61UL,
0x350c9b64UL, 0x31cd86d3UL, 0x3c8ea00aUL, 0x384fbdbdUL,
0x4c11db70UL, 0x48d0c6c7UL, 0x4593e01eUL, 0x4152fda9UL,
0x5f15adacUL, 0x5bd4b01bUL, 0x569796c2UL, 0x52568b75UL,
0x6a1936c8UL, 0x6ed82b7fUL, 0x639b0da6UL, 0x675a1011UL,
0x791d4014UL, 0x7ddc5da3UL, 0x709f7b7aUL, 0x745e66cdUL,
0x9823b6e0UL, 0x9ce2ab57UL, 0x91a18d8eUL, 0x95609039UL,
0x8b27c03cUL, 0x8fe6dd8bUL, 0x82a5fb52UL, 0x8664e6e5UL,
0xbe2b5b58UL, 0xbaea46efUL, 0xb7a96036UL, 0xb3687d81UL,
0xad2f2d84UL, 0xa9ee3033UL, 0xa4ad16eaUL, 0xa06c0b5dUL,
0xd4326d90UL, 0xd0f37027UL, 0xddb056feUL, 0xd9714b49UL,
0xc7361b4cUL, 0xc3f706fbUL, 0xceb42022UL, 0xca753d95UL,
0xf23a8028UL, 0xf6fb9d9fUL, 0xfbb8bb46UL, 0xff79a6f1UL,
0xe13ef6f4UL, 0xe5ffeb43UL, 0xe8bccd9aUL, 0xec7dd02dUL,
0x34867077UL, 0x30476dc0UL, 0x3d044b19UL, 0x39c556aeUL,
0x278206abUL, 0x23431b1cUL, 0x2e003dc5UL, 0x2ac12072UL,
0x128e9dcfUL, 0x164f8078UL, 0x1b0ca6a1UL, 0x1fcdbb16UL,
0x018aeb13UL, 0x054bf6a4UL, 0x0808d07dUL, 0x0cc9cdcaUL,
0x7897ab07UL, 0x7c56b6b0UL, 0x71159069UL, 0x75d48ddeUL,
0x6b93dddbUL, 0x6f52c06cUL, 0x6211e6b5UL, 0x66d0fb02UL,
0x5e9f46bfUL, 0x5a5e5b08UL, 0x571d7dd1UL, 0x53dc6066UL,
0x4d9b3063UL, 0x495a2dd4UL, 0x44190b0dUL, 0x40d816baUL,
0xaca5c697UL, 0xa864db20UL, 0xa527fdf9UL, 0xa1e6e04eUL,
0xbfa1b04bUL, 0xbb60adfcUL, 0xb6238b25UL, 0xb2e29692UL,
0x8aad2b2fUL, 0x8e6c3698UL, 0x832f1041UL, 0x87ee0df6UL,
0x99a95df3UL, 0x9d684044UL, 0x902b669dUL, 0x94ea7b2aUL,
0xe0b41de7UL, 0xe4750050UL, 0xe9362689UL, 0xedf73b3eUL,
0xf3b06b3bUL, 0xf771768cUL, 0xfa325055UL, 0xfef34de2UL,
0xc6bcf05fUL, 0xc27dede8UL, 0xcf3ecb31UL, 0xcbffd686UL,
0xd5b88683UL, 0xd1799b34UL, 0xdc3abdedUL, 0xd8fba05aUL,
0x690ce0eeUL, 0x6dcdfd59UL, 0x608edb80UL, 0x644fc637UL,
0x7a089632UL, 0x7ec98b85UL, 0x738aad5cUL, 0x774bb0ebUL,
0x4f040d56UL, 0x4bc510e1UL, 0x46863638UL, 0x42472b8fUL,
0x5c007b8aUL, 0x58c1663dUL, 0x558240e4UL, 0x51435d53UL,
0x251d3b9eUL, 0x21dc2629UL, 0x2c9f00f0UL, 0x285e1d47UL,
0x36194d42UL, 0x32d850f5UL, 0x3f9b762cUL, 0x3b5a6b9bUL,
0x0315d626UL, 0x07d4cb91UL, 0x0a97ed48UL, 0x0e56f0ffUL,
0x1011a0faUL, 0x14d0bd4dUL, 0x19939b94UL, 0x1d528623UL,
0xf12f560eUL, 0xf5ee4bb9UL, 0xf8ad6d60UL, 0xfc6c70d7UL,
0xe22b20d2UL, 0xe6ea3d65UL, 0xeba91bbcUL, 0xef68060bUL,
0xd727bbb6UL, 0xd3e6a601UL, 0xdea580d8UL, 0xda649d6fUL,
0xc423cd6aUL, 0xc0e2d0ddUL, 0xcda1f604UL, 0xc960ebb3UL,
0xbd3e8d7eUL, 0xb9ff90c9UL, 0xb4bcb610UL, 0xb07daba7UL,
0xae3afba2UL, 0xaafbe615UL, 0xa7b8c0ccUL, 0xa379dd7bUL,
0x9b3660c6UL, 0x9ff77d71UL, 0x92b45ba8UL, 0x9675461fUL,
0x8832161aUL, 0x8cf30badUL, 0x81b02d74UL, 0x857130c3UL,
0x5d8a9099UL, 0x594b8d2eUL, 0x5408abf7UL, 0x50c9b640UL,
0x4e8ee645UL, 0x4a4ffbf2UL, 0x470cdd2bUL, 0x43cdc09cUL,
0x7b827d21UL, 0x7f436096UL, 0x7200464fUL, 0x76c15bf8UL,
0x68860bfdUL, 0x6c47164aUL, 0x61043093UL, 0x65c52d24UL,
0x119b4be9UL, 0x155a565eUL, 0x18197087UL, 0x1cd86d30UL,
0x029f3d35UL, 0x065e2082UL, 0x0b1d065bUL, 0x0fdc1becUL,
0x3793a651UL, 0x3352bbe6UL, 0x3e119d3fUL, 0x3ad08088UL,
0x2497d08dUL, 0x2056cd3aUL, 0x2d15ebe3UL, 0x29d4f654UL,
0xc5a92679UL, 0xc1683bceUL, 0xcc2b1d17UL, 0xc8ea00a0UL,
0xd6ad50a5UL, 0xd26c4d12UL, 0xdf2f6bcbUL, 0xdbee767cUL,
0xe3a1cbc1UL, 0xe760d676UL, 0xea23f0afUL, 0xeee2ed18UL,
0xf0a5bd1dUL, 0xf464a0aaUL, 0xf9278673UL, 0xfde69bc4UL,
0x89b8fd09UL, 0x8d79e0beUL, 0x803ac667UL, 0x84fbdbd0UL,
0x9abc8bd5UL, 0x9e7d9662UL, 0x933eb0bbUL, 0x97ffad0cUL,
0xafb010b1UL, 0xab710d06UL, 0xa6322bdfUL, 0xa2f33668UL,
0xbcb4666dUL, 0xb8757bdaUL, 0xb5365d03UL, 0xb1f740b4UL
};
void
mhash_clear_crc32(mutils_word32 *crc)
{
*crc = 0xffffffff;
/*
* preload shift register, per CRC-32 spec
*/
}
void
mhash_get_crc32(__const mutils_word32 *crc, void *ret)
{
mutils_word32 tmp;
tmp = ~(*crc);
/*
* transmit complement, per CRC-32 spec
*/
#if defined(WORDS_BIGENDIAN)
tmp = mutils_word32swap(tmp);
#endif
if (ret != NULL)
{
mutils_memcpy(ret, &tmp, sizeof(mutils_word32));
}
}
void
mhash_crc32(mutils_word32 *crc, __const void *given_buf, mutils_word32 len)
{
__const mutils_word8 *p;
if ((crc == NULL) || (given_buf == NULL) || (len == 0))
{
return;
}
for (p = given_buf; len > 0; ++p, --len)
{
(*crc) = ((*crc) << 8) ^ crc32_table[((*crc) >> 24) ^ *p];
}
}
void
mhash_crc32b(mutils_word32 *crc, __const void *given_buf, mutils_word32 len)
{
__const mutils_word8 *p;
if ((crc == NULL) || (given_buf == NULL) || (len == 0))
{
return;
}
for (p = given_buf; len > 0; ++p, --len)
{
(*crc) = (((*crc) >> 8) & 0x00FFFFFF) ^ crc32_table_b[(*crc ^ *p) & 0xff];
}
}
#endif /* ENABLE_CRC32 */
@@ -0,0 +1,585 @@
/*
* gosthash.c
* 21 Apr 1998 Markku-Juhani Saarinen <mjos@ssh.fi>
*
* GOST R 34.11-94, Russian Standard Hash Function
*
* Copyright (c) 1998 SSH Communications Security, Finland
* All rights reserved.
*/
/* This implementation is placed in the public domain, according to
* the author. --nikos
*/
#include "libdefs.h"
#ifdef ENABLE_GOST
#include "mhash_gost.h"
/*
lookup tables : each of these has two rotated 4-bit S-Boxes
*/
static __const mutils_word32 gost_sbox_1[256] = {
0x72000UL, 0x75000UL, 0x74800UL, 0x71000UL, 0x76800UL,
0x74000UL, 0x70000UL, 0x77000UL, 0x73000UL, 0x75800UL,
0x70800UL, 0x76000UL, 0x73800UL, 0x77800UL, 0x72800UL,
0x71800UL, 0x5A000UL, 0x5D000UL, 0x5C800UL, 0x59000UL,
0x5E800UL, 0x5C000UL, 0x58000UL, 0x5F000UL, 0x5B000UL,
0x5D800UL, 0x58800UL, 0x5E000UL, 0x5B800UL, 0x5F800UL,
0x5A800UL, 0x59800UL, 0x22000UL, 0x25000UL, 0x24800UL,
0x21000UL, 0x26800UL, 0x24000UL, 0x20000UL, 0x27000UL,
0x23000UL, 0x25800UL, 0x20800UL, 0x26000UL, 0x23800UL,
0x27800UL, 0x22800UL, 0x21800UL, 0x62000UL, 0x65000UL,
0x64800UL, 0x61000UL, 0x66800UL, 0x64000UL, 0x60000UL,
0x67000UL, 0x63000UL, 0x65800UL, 0x60800UL, 0x66000UL,
0x63800UL, 0x67800UL, 0x62800UL, 0x61800UL, 0x32000UL,
0x35000UL, 0x34800UL, 0x31000UL, 0x36800UL, 0x34000UL,
0x30000UL, 0x37000UL, 0x33000UL, 0x35800UL, 0x30800UL,
0x36000UL, 0x33800UL, 0x37800UL, 0x32800UL, 0x31800UL,
0x6A000UL, 0x6D000UL, 0x6C800UL, 0x69000UL, 0x6E800UL,
0x6C000UL, 0x68000UL, 0x6F000UL, 0x6B000UL, 0x6D800UL,
0x68800UL, 0x6E000UL, 0x6B800UL, 0x6F800UL, 0x6A800UL,
0x69800UL, 0x7A000UL, 0x7D000UL, 0x7C800UL, 0x79000UL,
0x7E800UL, 0x7C000UL, 0x78000UL, 0x7F000UL, 0x7B000UL,
0x7D800UL, 0x78800UL, 0x7E000UL, 0x7B800UL, 0x7F800UL,
0x7A800UL, 0x79800UL, 0x52000UL, 0x55000UL, 0x54800UL,
0x51000UL, 0x56800UL, 0x54000UL, 0x50000UL, 0x57000UL,
0x53000UL, 0x55800UL, 0x50800UL, 0x56000UL, 0x53800UL,
0x57800UL, 0x52800UL, 0x51800UL, 0x12000UL, 0x15000UL,
0x14800UL, 0x11000UL, 0x16800UL, 0x14000UL, 0x10000UL,
0x17000UL, 0x13000UL, 0x15800UL, 0x10800UL, 0x16000UL,
0x13800UL, 0x17800UL, 0x12800UL, 0x11800UL, 0x1A000UL,
0x1D000UL, 0x1C800UL, 0x19000UL, 0x1E800UL, 0x1C000UL,
0x18000UL, 0x1F000UL, 0x1B000UL, 0x1D800UL, 0x18800UL,
0x1E000UL, 0x1B800UL, 0x1F800UL, 0x1A800UL, 0x19800UL,
0x42000UL, 0x45000UL, 0x44800UL, 0x41000UL, 0x46800UL,
0x44000UL, 0x40000UL, 0x47000UL, 0x43000UL, 0x45800UL,
0x40800UL, 0x46000UL, 0x43800UL, 0x47800UL, 0x42800UL,
0x41800UL, 0xA000UL, 0xD000UL, 0xC800UL, 0x9000UL,
0xE800UL, 0xC000UL, 0x8000UL, 0xF000UL, 0xB000UL,
0xD800UL, 0x8800UL, 0xE000UL, 0xB800UL, 0xF800UL,
0xA800UL, 0x9800UL, 0x2000UL, 0x5000UL, 0x4800UL,
0x1000UL, 0x6800UL, 0x4000UL, 0x0UL, 0x7000UL,
0x3000UL, 0x5800UL, 0x800UL, 0x6000UL, 0x3800UL,
0x7800UL, 0x2800UL, 0x1800UL, 0x3A000UL, 0x3D000UL,
0x3C800UL, 0x39000UL, 0x3E800UL, 0x3C000UL, 0x38000UL,
0x3F000UL, 0x3B000UL, 0x3D800UL, 0x38800UL, 0x3E000UL,
0x3B800UL, 0x3F800UL, 0x3A800UL, 0x39800UL, 0x2A000UL,
0x2D000UL, 0x2C800UL, 0x29000UL, 0x2E800UL, 0x2C000UL,
0x28000UL, 0x2F000UL, 0x2B000UL, 0x2D800UL, 0x28800UL,
0x2E000UL, 0x2B800UL, 0x2F800UL, 0x2A800UL, 0x29800UL,
0x4A000UL, 0x4D000UL, 0x4C800UL, 0x49000UL, 0x4E800UL,
0x4C000UL, 0x48000UL, 0x4F000UL, 0x4B000UL, 0x4D800UL,
0x48800UL, 0x4E000UL, 0x4B800UL, 0x4F800UL, 0x4A800UL,
0x49800UL,
};
static __const mutils_word32 gost_sbox_2[256] = {
0x3A80000UL, 0x3C00000UL, 0x3880000UL, 0x3E80000UL, 0x3D00000UL,
0x3980000UL, 0x3A00000UL, 0x3900000UL, 0x3F00000UL, 0x3F80000UL,
0x3E00000UL, 0x3B80000UL, 0x3B00000UL, 0x3800000UL, 0x3C80000UL,
0x3D80000UL, 0x6A80000UL, 0x6C00000UL, 0x6880000UL, 0x6E80000UL,
0x6D00000UL, 0x6980000UL, 0x6A00000UL, 0x6900000UL, 0x6F00000UL,
0x6F80000UL, 0x6E00000UL, 0x6B80000UL, 0x6B00000UL, 0x6800000UL,
0x6C80000UL, 0x6D80000UL, 0x5280000UL, 0x5400000UL, 0x5080000UL,
0x5680000UL, 0x5500000UL, 0x5180000UL, 0x5200000UL, 0x5100000UL,
0x5700000UL, 0x5780000UL, 0x5600000UL, 0x5380000UL, 0x5300000UL,
0x5000000UL, 0x5480000UL, 0x5580000UL, 0xA80000UL, 0xC00000UL,
0x880000UL, 0xE80000UL, 0xD00000UL, 0x980000UL, 0xA00000UL,
0x900000UL, 0xF00000UL, 0xF80000UL, 0xE00000UL, 0xB80000UL,
0xB00000UL, 0x800000UL, 0xC80000UL, 0xD80000UL, 0x280000UL,
0x400000UL, 0x80000UL, 0x680000UL, 0x500000UL, 0x180000UL,
0x200000UL, 0x100000UL, 0x700000UL, 0x780000UL, 0x600000UL,
0x380000UL, 0x300000UL, 0x0UL, 0x480000UL, 0x580000UL,
0x4280000UL, 0x4400000UL, 0x4080000UL, 0x4680000UL, 0x4500000UL,
0x4180000UL, 0x4200000UL, 0x4100000UL, 0x4700000UL, 0x4780000UL,
0x4600000UL, 0x4380000UL, 0x4300000UL, 0x4000000UL, 0x4480000UL,
0x4580000UL, 0x4A80000UL, 0x4C00000UL, 0x4880000UL, 0x4E80000UL,
0x4D00000UL, 0x4980000UL, 0x4A00000UL, 0x4900000UL, 0x4F00000UL,
0x4F80000UL, 0x4E00000UL, 0x4B80000UL, 0x4B00000UL, 0x4800000UL,
0x4C80000UL, 0x4D80000UL, 0x7A80000UL, 0x7C00000UL, 0x7880000UL,
0x7E80000UL, 0x7D00000UL, 0x7980000UL, 0x7A00000UL, 0x7900000UL,
0x7F00000UL, 0x7F80000UL, 0x7E00000UL, 0x7B80000UL, 0x7B00000UL,
0x7800000UL, 0x7C80000UL, 0x7D80000UL, 0x7280000UL, 0x7400000UL,
0x7080000UL, 0x7680000UL, 0x7500000UL, 0x7180000UL, 0x7200000UL,
0x7100000UL, 0x7700000UL, 0x7780000UL, 0x7600000UL, 0x7380000UL,
0x7300000UL, 0x7000000UL, 0x7480000UL, 0x7580000UL, 0x2280000UL,
0x2400000UL, 0x2080000UL, 0x2680000UL, 0x2500000UL, 0x2180000UL,
0x2200000UL, 0x2100000UL, 0x2700000UL, 0x2780000UL, 0x2600000UL,
0x2380000UL, 0x2300000UL, 0x2000000UL, 0x2480000UL, 0x2580000UL,
0x3280000UL, 0x3400000UL, 0x3080000UL, 0x3680000UL, 0x3500000UL,
0x3180000UL, 0x3200000UL, 0x3100000UL, 0x3700000UL, 0x3780000UL,
0x3600000UL, 0x3380000UL, 0x3300000UL, 0x3000000UL, 0x3480000UL,
0x3580000UL, 0x6280000UL, 0x6400000UL, 0x6080000UL, 0x6680000UL,
0x6500000UL, 0x6180000UL, 0x6200000UL, 0x6100000UL, 0x6700000UL,
0x6780000UL, 0x6600000UL, 0x6380000UL, 0x6300000UL, 0x6000000UL,
0x6480000UL, 0x6580000UL, 0x5A80000UL, 0x5C00000UL, 0x5880000UL,
0x5E80000UL, 0x5D00000UL, 0x5980000UL, 0x5A00000UL, 0x5900000UL,
0x5F00000UL, 0x5F80000UL, 0x5E00000UL, 0x5B80000UL, 0x5B00000UL,
0x5800000UL, 0x5C80000UL, 0x5D80000UL, 0x1280000UL, 0x1400000UL,
0x1080000UL, 0x1680000UL, 0x1500000UL, 0x1180000UL, 0x1200000UL,
0x1100000UL, 0x1700000UL, 0x1780000UL, 0x1600000UL, 0x1380000UL,
0x1300000UL, 0x1000000UL, 0x1480000UL, 0x1580000UL, 0x2A80000UL,
0x2C00000UL, 0x2880000UL, 0x2E80000UL, 0x2D00000UL, 0x2980000UL,
0x2A00000UL, 0x2900000UL, 0x2F00000UL, 0x2F80000UL, 0x2E00000UL,
0x2B80000UL, 0x2B00000UL, 0x2800000UL, 0x2C80000UL, 0x2D80000UL,
0x1A80000UL, 0x1C00000UL, 0x1880000UL, 0x1E80000UL, 0x1D00000UL,
0x1980000UL, 0x1A00000UL, 0x1900000UL, 0x1F00000UL, 0x1F80000UL,
0x1E00000UL, 0x1B80000UL, 0x1B00000UL, 0x1800000UL, 0x1C80000UL,
0x1D80000UL,
};
static __const mutils_word32 gost_sbox_3[256] = {
0x30000002UL, 0x60000002UL, 0x38000002UL, 0x8000002UL,
0x28000002UL, 0x78000002UL, 0x68000002UL, 0x40000002UL,
0x20000002UL, 0x50000002UL, 0x48000002UL, 0x70000002UL,
0x2UL, 0x18000002UL, 0x58000002UL, 0x10000002UL,
0xB0000005UL, 0xE0000005UL, 0xB8000005UL, 0x88000005UL,
0xA8000005UL, 0xF8000005UL, 0xE8000005UL, 0xC0000005UL,
0xA0000005UL, 0xD0000005UL, 0xC8000005UL, 0xF0000005UL,
0x80000005UL, 0x98000005UL, 0xD8000005UL, 0x90000005UL,
0x30000005UL, 0x60000005UL, 0x38000005UL, 0x8000005UL,
0x28000005UL, 0x78000005UL, 0x68000005UL, 0x40000005UL,
0x20000005UL, 0x50000005UL, 0x48000005UL, 0x70000005UL,
0x5UL, 0x18000005UL, 0x58000005UL, 0x10000005UL,
0x30000000UL, 0x60000000UL, 0x38000000UL, 0x8000000UL,
0x28000000UL, 0x78000000UL, 0x68000000UL, 0x40000000UL,
0x20000000UL, 0x50000000UL, 0x48000000UL, 0x70000000UL,
0x0UL, 0x18000000UL, 0x58000000UL, 0x10000000UL,
0xB0000003UL, 0xE0000003UL, 0xB8000003UL, 0x88000003UL,
0xA8000003UL, 0xF8000003UL, 0xE8000003UL, 0xC0000003UL,
0xA0000003UL, 0xD0000003UL, 0xC8000003UL, 0xF0000003UL,
0x80000003UL, 0x98000003UL, 0xD8000003UL, 0x90000003UL,
0x30000001UL, 0x60000001UL, 0x38000001UL, 0x8000001UL,
0x28000001UL, 0x78000001UL, 0x68000001UL, 0x40000001UL,
0x20000001UL, 0x50000001UL, 0x48000001UL, 0x70000001UL,
0x1UL, 0x18000001UL, 0x58000001UL, 0x10000001UL,
0xB0000000UL, 0xE0000000UL, 0xB8000000UL, 0x88000000UL,
0xA8000000UL, 0xF8000000UL, 0xE8000000UL, 0xC0000000UL,
0xA0000000UL, 0xD0000000UL, 0xC8000000UL, 0xF0000000UL,
0x80000000UL, 0x98000000UL, 0xD8000000UL, 0x90000000UL,
0xB0000006UL, 0xE0000006UL, 0xB8000006UL, 0x88000006UL,
0xA8000006UL, 0xF8000006UL, 0xE8000006UL, 0xC0000006UL,
0xA0000006UL, 0xD0000006UL, 0xC8000006UL, 0xF0000006UL,
0x80000006UL, 0x98000006UL, 0xD8000006UL, 0x90000006UL,
0xB0000001UL, 0xE0000001UL, 0xB8000001UL, 0x88000001UL,
0xA8000001UL, 0xF8000001UL, 0xE8000001UL, 0xC0000001UL,
0xA0000001UL, 0xD0000001UL, 0xC8000001UL, 0xF0000001UL,
0x80000001UL, 0x98000001UL, 0xD8000001UL, 0x90000001UL,
0x30000003UL, 0x60000003UL, 0x38000003UL, 0x8000003UL,
0x28000003UL, 0x78000003UL, 0x68000003UL, 0x40000003UL,
0x20000003UL, 0x50000003UL, 0x48000003UL, 0x70000003UL,
0x3UL, 0x18000003UL, 0x58000003UL, 0x10000003UL,
0x30000004UL, 0x60000004UL, 0x38000004UL, 0x8000004UL,
0x28000004UL, 0x78000004UL, 0x68000004UL, 0x40000004UL,
0x20000004UL, 0x50000004UL, 0x48000004UL, 0x70000004UL,
0x4UL, 0x18000004UL, 0x58000004UL, 0x10000004UL,
0xB0000002UL, 0xE0000002UL, 0xB8000002UL, 0x88000002UL,
0xA8000002UL, 0xF8000002UL, 0xE8000002UL, 0xC0000002UL,
0xA0000002UL, 0xD0000002UL, 0xC8000002UL, 0xF0000002UL,
0x80000002UL, 0x98000002UL, 0xD8000002UL, 0x90000002UL,
0xB0000004UL, 0xE0000004UL, 0xB8000004UL, 0x88000004UL,
0xA8000004UL, 0xF8000004UL, 0xE8000004UL, 0xC0000004UL,
0xA0000004UL, 0xD0000004UL, 0xC8000004UL, 0xF0000004UL,
0x80000004UL, 0x98000004UL, 0xD8000004UL, 0x90000004UL,
0x30000006UL, 0x60000006UL, 0x38000006UL, 0x8000006UL,
0x28000006UL, 0x78000006UL, 0x68000006UL, 0x40000006UL,
0x20000006UL, 0x50000006UL, 0x48000006UL, 0x70000006UL,
0x6UL, 0x18000006UL, 0x58000006UL, 0x10000006UL,
0xB0000007UL, 0xE0000007UL, 0xB8000007UL, 0x88000007UL,
0xA8000007UL, 0xF8000007UL, 0xE8000007UL, 0xC0000007UL,
0xA0000007UL, 0xD0000007UL, 0xC8000007UL, 0xF0000007UL,
0x80000007UL, 0x98000007UL, 0xD8000007UL, 0x90000007UL,
0x30000007UL, 0x60000007UL, 0x38000007UL, 0x8000007UL,
0x28000007UL, 0x78000007UL, 0x68000007UL, 0x40000007UL,
0x20000007UL, 0x50000007UL, 0x48000007UL, 0x70000007UL,
0x7UL, 0x18000007UL, 0x58000007UL, 0x10000007UL,
};
static __const mutils_word32 gost_sbox_4[256] = {
0xE8UL, 0xD8UL, 0xA0UL, 0x88UL, 0x98UL,
0xF8UL, 0xA8UL, 0xC8UL, 0x80UL, 0xD0UL,
0xF0UL, 0xB8UL, 0xB0UL, 0xC0UL, 0x90UL,
0xE0UL, 0x7E8UL, 0x7D8UL, 0x7A0UL, 0x788UL,
0x798UL, 0x7F8UL, 0x7A8UL, 0x7C8UL, 0x780UL,
0x7D0UL, 0x7F0UL, 0x7B8UL, 0x7B0UL, 0x7C0UL,
0x790UL, 0x7E0UL, 0x6E8UL, 0x6D8UL, 0x6A0UL,
0x688UL, 0x698UL, 0x6F8UL, 0x6A8UL, 0x6C8UL,
0x680UL, 0x6D0UL, 0x6F0UL, 0x6B8UL, 0x6B0UL,
0x6C0UL, 0x690UL, 0x6E0UL, 0x68UL, 0x58UL,
0x20UL, 0x8UL, 0x18UL, 0x78UL, 0x28UL,
0x48UL, 0x0UL, 0x50UL, 0x70UL, 0x38UL,
0x30UL, 0x40UL, 0x10UL, 0x60UL, 0x2E8UL,
0x2D8UL, 0x2A0UL, 0x288UL, 0x298UL, 0x2F8UL,
0x2A8UL, 0x2C8UL, 0x280UL, 0x2D0UL, 0x2F0UL,
0x2B8UL, 0x2B0UL, 0x2C0UL, 0x290UL, 0x2E0UL,
0x3E8UL, 0x3D8UL, 0x3A0UL, 0x388UL, 0x398UL,
0x3F8UL, 0x3A8UL, 0x3C8UL, 0x380UL, 0x3D0UL,
0x3F0UL, 0x3B8UL, 0x3B0UL, 0x3C0UL, 0x390UL,
0x3E0UL, 0x568UL, 0x558UL, 0x520UL, 0x508UL,
0x518UL, 0x578UL, 0x528UL, 0x548UL, 0x500UL,
0x550UL, 0x570UL, 0x538UL, 0x530UL, 0x540UL,
0x510UL, 0x560UL, 0x268UL, 0x258UL, 0x220UL,
0x208UL, 0x218UL, 0x278UL, 0x228UL, 0x248UL,
0x200UL, 0x250UL, 0x270UL, 0x238UL, 0x230UL,
0x240UL, 0x210UL, 0x260UL, 0x4E8UL, 0x4D8UL,
0x4A0UL, 0x488UL, 0x498UL, 0x4F8UL, 0x4A8UL,
0x4C8UL, 0x480UL, 0x4D0UL, 0x4F0UL, 0x4B8UL,
0x4B0UL, 0x4C0UL, 0x490UL, 0x4E0UL, 0x168UL,
0x158UL, 0x120UL, 0x108UL, 0x118UL, 0x178UL,
0x128UL, 0x148UL, 0x100UL, 0x150UL, 0x170UL,
0x138UL, 0x130UL, 0x140UL, 0x110UL, 0x160UL,
0x1E8UL, 0x1D8UL, 0x1A0UL, 0x188UL, 0x198UL,
0x1F8UL, 0x1A8UL, 0x1C8UL, 0x180UL, 0x1D0UL,
0x1F0UL, 0x1B8UL, 0x1B0UL, 0x1C0UL, 0x190UL,
0x1E0UL, 0x768UL, 0x758UL, 0x720UL, 0x708UL,
0x718UL, 0x778UL, 0x728UL, 0x748UL, 0x700UL,
0x750UL, 0x770UL, 0x738UL, 0x730UL, 0x740UL,
0x710UL, 0x760UL, 0x368UL, 0x358UL, 0x320UL,
0x308UL, 0x318UL, 0x378UL, 0x328UL, 0x348UL,
0x300UL, 0x350UL, 0x370UL, 0x338UL, 0x330UL,
0x340UL, 0x310UL, 0x360UL, 0x5E8UL, 0x5D8UL,
0x5A0UL, 0x588UL, 0x598UL, 0x5F8UL, 0x5A8UL,
0x5C8UL, 0x580UL, 0x5D0UL, 0x5F0UL, 0x5B8UL,
0x5B0UL, 0x5C0UL, 0x590UL, 0x5E0UL, 0x468UL,
0x458UL, 0x420UL, 0x408UL, 0x418UL, 0x478UL,
0x428UL, 0x448UL, 0x400UL, 0x450UL, 0x470UL,
0x438UL, 0x430UL, 0x440UL, 0x410UL, 0x460UL,
0x668UL, 0x658UL, 0x620UL, 0x608UL, 0x618UL,
0x678UL, 0x628UL, 0x648UL, 0x600UL, 0x650UL,
0x670UL, 0x638UL, 0x630UL, 0x640UL, 0x610UL,
0x660UL,
};
/*
* A macro that performs a full encryption round of GOST 28147-89.
* Temporary variable t assumed and variables r and l for left and right
* blocks
*/
#define GOST_ENCRYPT_ROUND(k1, k2) \
t = (k1) + r; \
l ^= gost_sbox_1[t & 0xff] ^ gost_sbox_2[(t >> 8) & 0xff] ^ \
gost_sbox_3[(t >> 16) & 0xff] ^ gost_sbox_4[t >> 24]; \
t = (k2) + l; \
r ^= gost_sbox_1[t & 0xff] ^ gost_sbox_2[(t >> 8) & 0xff] ^ \
gost_sbox_3[(t >> 16) & 0xff] ^ gost_sbox_4[t >> 24]; \
/*
encrypt a block with the given key
*/
#define GOST_ENCRYPT(key) \
GOST_ENCRYPT_ROUND(key[0], key[1]) \
GOST_ENCRYPT_ROUND(key[2], key[3]) \
GOST_ENCRYPT_ROUND(key[4], key[5]) \
GOST_ENCRYPT_ROUND(key[6], key[7]) \
GOST_ENCRYPT_ROUND(key[0], key[1]) \
GOST_ENCRYPT_ROUND(key[2], key[3]) \
GOST_ENCRYPT_ROUND(key[4], key[5]) \
GOST_ENCRYPT_ROUND(key[6], key[7]) \
GOST_ENCRYPT_ROUND(key[0], key[1]) \
GOST_ENCRYPT_ROUND(key[2], key[3]) \
GOST_ENCRYPT_ROUND(key[4], key[5]) \
GOST_ENCRYPT_ROUND(key[6], key[7]) \
GOST_ENCRYPT_ROUND(key[7], key[6]) \
GOST_ENCRYPT_ROUND(key[5], key[4]) \
GOST_ENCRYPT_ROUND(key[3], key[2]) \
GOST_ENCRYPT_ROUND(key[1], key[0]) \
t = r; \
r = l; \
l = t;
/*
* "chi" compression function. the result is stored over h
*/
static void gosthash_compress(mutils_word32 * h, mutils_word32 * m)
{
mutils_word32 i;
mutils_word32 l, r, t, key[8], u[8], v[8], w[8], s[8];
mutils_memcpy(u, h, sizeof(u));
mutils_memcpy(v, m, sizeof(u));
for (i = 0; i < 8; i += 2) {
w[0] = u[0] ^ v[0]; /*
w = u xor v
*/
w[1] = u[1] ^ v[1];
w[2] = u[2] ^ v[2];
w[3] = u[3] ^ v[3];
w[4] = u[4] ^ v[4];
w[5] = u[5] ^ v[5];
w[6] = u[6] ^ v[6];
w[7] = u[7] ^ v[7];
/*
P-Transformation
*/
key[0] = (w[0] & 0x000000ff) | ((w[2] & 0x000000ff) << 8) | ((w[4] & 0x000000ff) << 16) | ((w[6] & 0x000000ff) << 24);
key[1] = ((w[0] & 0x0000ff00) >> 8) | (w[2] & 0x0000ff00) | ((w[4] & 0x0000ff00) << 8) | ((w[6] & 0x0000ff00) << 16);
key[2] = ((w[0] & 0x00ff0000) >> 16) | ((w[2] & 0x00ff0000) >> 8) | (w[4] & 0x00ff0000)
| ((w[6] & 0x00ff0000) << 8);
key[3] = ((w[0] & 0xff000000) >> 24) | ((w[2] & 0xff000000) >> 16) | ((w[4] & 0xff000000) >> 8) | (w[6] & 0xff000000);
key[4] = (w[1] & 0x000000ff) | ((w[3] & 0x000000ff) << 8) | ((w[5] & 0x000000ff) << 16) | ((w[7] & 0x000000ff) << 24);
key[5] = ((w[1] & 0x0000ff00) >> 8) | (w[3] & 0x0000ff00) | ((w[5] & 0x0000ff00) << 8) | ((w[7] & 0x0000ff00) << 16);
key[6] = ((w[1] & 0x00ff0000) >> 16) | ((w[3] & 0x00ff0000) >> 8) | (w[5] & 0x00ff0000)
| ((w[7] & 0x00ff0000) << 8);
key[7] = ((w[1] & 0xff000000) >> 24) | ((w[3] & 0xff000000) >> 16) | ((w[5] & 0xff000000) >> 8) | (w[7] & 0xff000000);
r = h[i]; /*
encriphering transformation
*/
l = h[i + 1];
GOST_ENCRYPT(key);
s[i] = r;
s[i + 1] = l;
if (i == 6)
break;
l = u[0] ^ u[2]; /*
U = A(U)
*/
r = u[1] ^ u[3];
u[0] = u[2];
u[1] = u[3];
u[2] = u[4];
u[3] = u[5];
u[4] = u[6];
u[5] = u[7];
u[6] = l;
u[7] = r;
if (i == 2) { /*
Constant C_3
*/
u[0] ^= 0xff00ff00;
u[1] ^= 0xff00ff00;
u[2] ^= 0x00ff00ff;
u[3] ^= 0x00ff00ff;
u[4] ^= 0x00ffff00;
u[5] ^= 0xff0000ff;
u[6] ^= 0x000000ff;
u[7] ^= 0xff00ffff;
}
l = v[0]; /*
V = A(A(V))
*/
r = v[2];
v[0] = v[4];
v[2] = v[6];
v[4] = l ^ r;
v[6] = v[0] ^ r;
l = v[1];
r = v[3];
v[1] = v[5];
v[3] = v[7];
v[5] = l ^ r;
v[7] = v[1] ^ r;
}
/*
12 rounds of the LFSR (computed from a product matrix) and xor in M
*/
u[0] = m[0] ^ s[6];
u[1] = m[1] ^ s[7];
u[2] = m[2] ^ (s[0] << 16) ^ (s[0] >> 16) ^ (s[0] & 0xffff) ^ (s[1] & 0xffff) ^ (s[1] >> 16) ^ (s[2] << 16) ^ s[6] ^ (s[6] << 16) ^ (s[7] & 0xffff0000) ^ (s[7] >> 16);
u[3] = m[3] ^ (s[0] & 0xffff) ^ (s[0] << 16) ^ (s[1] & 0xffff) ^ (s[1]
<< 16)
^ (s[1] >> 16) ^ (s[2] << 16) ^ (s[2] >> 16) ^ (s[3] << 16) ^ s[6] ^ (s[6] << 16) ^ (s[6] >> 16) ^ (s[7] & 0xffff) ^ (s[7] << 16) ^ (s[7] >> 16);
u[4] =
m[4] ^ (s[0] & 0xffff0000) ^ (s[0] << 16) ^ (s[0] >> 16) ^
(s[1] & 0xffff0000) ^ (s[1] >> 16) ^ (s[2] << 16) ^ (s[2] >> 16) ^ (s[3] << 16) ^ (s[3] >> 16) ^ (s[4] << 16) ^ (s[6] << 16) ^ (s[6] >> 16) ^ (s[7] & 0xffff) ^ (s[7] << 16) ^ (s[7] >> 16);
u[5] =
m[5] ^ (s[0] << 16) ^ (s[0] >> 16) ^ (s[0] & 0xffff0000) ^
(s[1] & 0xffff) ^ s[2] ^ (s[2] >> 16) ^ (s[3] << 16) ^ (s[3] >>
16) ^ (s[4] << 16) ^ (s[4] >> 16) ^ (s[5] << 16) ^ (s[6] << 16) ^ (s[6] >> 16) ^ (s[7] & 0xffff0000) ^ (s[7] << 16) ^ (s[7] >> 16);
u[6] = m[6] ^ s[0] ^ (s[1] >> 16) ^ (s[2] << 16) ^ s[3] ^ (s[3] >> 16)
^ (s[4] << 16) ^ (s[4] >> 16) ^ (s[5] << 16) ^ (s[5] >> 16) ^ s[6] ^ (s[6] << 16) ^ (s[6] >> 16) ^ (s[7] << 16);
u[7] =
m[7] ^ (s[0] & 0xffff0000) ^ (s[0] << 16) ^ (s[1] & 0xffff) ^
(s[1] << 16) ^ (s[2] >> 16) ^ (s[3] << 16) ^ s[4] ^ (s[4] >> 16) ^ (s[5] << 16) ^ (s[5] >> 16) ^ (s[6] >> 16) ^ (s[7] & 0xffff) ^ (s[7] << 16) ^ (s[7] >> 16);
/*
16 * 1 round of the LFSR and xor in H
*/
v[0] = h[0] ^ (u[1] << 16) ^ (u[0] >> 16);
v[1] = h[1] ^ (u[2] << 16) ^ (u[1] >> 16);
v[2] = h[2] ^ (u[3] << 16) ^ (u[2] >> 16);
v[3] = h[3] ^ (u[4] << 16) ^ (u[3] >> 16);
v[4] = h[4] ^ (u[5] << 16) ^ (u[4] >> 16);
v[5] = h[5] ^ (u[6] << 16) ^ (u[5] >> 16);
v[6] = h[6] ^ (u[7] << 16) ^ (u[6] >> 16);
v[7] = h[7] ^ (u[0] & 0xffff0000) ^ (u[0] << 16) ^ (u[7] >> 16) ^ (u[1] & 0xffff0000) ^ (u[1] << 16) ^ (u[6] << 16) ^ (u[7] & 0xffff0000);
/*
61 rounds of LFSR, mixing up h (computed from a product matrix)
*/
h[0] =
(v[0] & 0xffff0000) ^ (v[0] << 16) ^ (v[0] >> 16) ^ (v[1] >>
16) ^
(v[1] & 0xffff0000) ^ (v[2] << 16) ^ (v[3] >> 16) ^ (v[4] << 16) ^ (v[5] >> 16) ^ v[5] ^ (v[6] >> 16) ^ (v[7] << 16) ^ (v[7] >> 16) ^ (v[7] & 0xffff);
h[1] =
(v[0] << 16) ^ (v[0] >> 16) ^ (v[0] & 0xffff0000) ^ (v[1] &
0xffff) ^ v[2] ^ (v[2] >> 16) ^ (v[3] << 16) ^ (v[4] >> 16) ^ (v[5] << 16) ^ (v[6] << 16) ^ v[6] ^ (v[7] & 0xffff0000) ^ (v[7] >> 16);
h[2] =
(v[0] & 0xffff) ^ (v[0] << 16) ^ (v[1] << 16) ^ (v[1] >> 16) ^
(v[1] & 0xffff0000) ^ (v[2] << 16) ^ (v[3] >> 16) ^ v[3] ^ (v[4] << 16) ^ (v[5] >> 16) ^ v[6] ^ (v[6] >> 16) ^ (v[7] & 0xffff) ^ (v[7] << 16) ^ (v[7] >> 16);
h[3] = (v[0] << 16) ^ (v[0] >> 16) ^ (v[0] & 0xffff0000) ^ (v[1] & 0xffff0000)
^ (v[1] >> 16) ^ (v[2] << 16) ^ (v[2] >> 16) ^ v[2] ^ (v[3] << 16) ^ (v[4] >> 16) ^ v[4] ^ (v[5] << 16) ^ (v[6] << 16) ^ (v[7] & 0xffff) ^ (v[7] >> 16);
h[4] = (v[0] >> 16) ^ (v[1] << 16) ^ v[1] ^ (v[2] >> 16) ^ v[2] ^ (v[3] << 16) ^ (v[3] >> 16) ^ v[3] ^ (v[4] << 16) ^ (v[5] >> 16) ^ v[5]
^ (v[6] << 16) ^ (v[6] >> 16) ^ (v[7] << 16);
h[5] = (v[0] << 16) ^ (v[0] & 0xffff0000) ^ (v[1] << 16) ^ (v[1] >> 16) ^ (v[1] & 0xffff0000) ^ (v[2] << 16) ^ v[2] ^ (v[3] >> 16) ^ v[3]
^ (v[4] << 16) ^ (v[4] >> 16) ^ v[4] ^ (v[5] << 16) ^ (v[6] << 16) ^ (v[6] >> 16) ^ v[6] ^ (v[7] << 16) ^ (v[7] >> 16) ^ (v[7] & 0xffff0000);
h[6] = v[0] ^ v[2] ^ (v[2] >> 16) ^ v[3] ^ (v[3] << 16) ^ v[4] ^ (v[4]
>> 16)
^ (v[5] << 16) ^ (v[5] >> 16) ^ v[5] ^ (v[6] << 16) ^ (v[6] >> 16) ^ v[6] ^ (v[7] << 16) ^ v[7];
h[7] = v[0] ^ (v[0] >> 16) ^ (v[1] << 16) ^ (v[1] >> 16) ^ (v[2] << 16) ^ (v[3] >> 16) ^ v[3] ^ (v[4] << 16) ^ v[4] ^ (v[5] >> 16) ^ v[5]
^ (v[6] << 16) ^ (v[6] >> 16) ^ (v[7] << 16) ^ v[7];
}
/*
Clear the state of the given context structure.
*/
void gosthash_reset(GostHashCtx * ctx)
{
mutils_bzero(ctx->sum, 32);
mutils_bzero(ctx->hash, 32);
mutils_bzero(ctx->len, 32);
mutils_bzero(ctx->partial, 32);
ctx->partial_bytes = 0;
}
/*
Mix in a 32-byte chunk ("stage 3")
*/
static void gosthash_bytes(GostHashCtx * ctx, __const mutils_word8 * buf, mutils_word32 bits)
{
mutils_word32 i;
mutils_word32 j;
mutils_word32 a, c, m[8];
/*
convert bytes to a long words and compute the sum
*/
j = 0;
c = 0;
for (i = 0; i < 8; i++) {
a = ((mutils_word32) buf[j]) | (((mutils_word32) buf[j + 1]) << 8) | (((mutils_word32) buf[j + 2]) << 16) | (((mutils_word32) buf[j + 3]) << 24);
j += 4;
m[i] = a;
c = a + c + ctx->sum[i];
if ((a==0xFFFFFFFFUL) && (ctx->sum[i]==0xFFFFFFFFUL)) {
ctx->sum[i] = c;
c = 1;
} else {
ctx->sum[i] = c;
c = c < a ? 1 : 0;
}
}
/*
compress
*/
gosthash_compress(ctx->hash, m);
/*
a 64-bit counter should be sufficient
*/
ctx->len[0] += bits;
if (ctx->len[0] < bits)
ctx->len[1]++;
}
/*
Mix in len bytes of data for the given buffer.
*/
void gosthash_update(GostHashCtx * ctx, __const mutils_word8 * buf, mutils_word32 len)
{
mutils_word32 i, j;
i = ctx->partial_bytes;
j = 0;
while (i < 32 && j < len)
ctx->partial[i++] = buf[j++];
if (i < 32) {
ctx->partial_bytes = i;
return;
}
gosthash_bytes(ctx, ctx->partial, 256);
while ((j + 32) < len) {
gosthash_bytes(ctx, &buf[j], 256);
j += 32;
}
i = 0;
while (j < len)
ctx->partial[i++] = buf[j++];
ctx->partial_bytes = i;
}
/*
Compute and save the 32-byte digest.
*/
void gosthash_final(GostHashCtx * ctx, mutils_word8 * digest)
{
mutils_word32 i;
mutils_word32 j;
mutils_word32 a;
/*
adjust and mix in the last chunk
*/
if (ctx->partial_bytes > 0) {
mutils_bzero(&ctx->partial[ctx->partial_bytes], 32 - ctx->partial_bytes);
gosthash_bytes(ctx, ctx->partial, ctx->partial_bytes << 3);
}
/*
mix in the length and the sum
*/
gosthash_compress(ctx->hash, ctx->len);
gosthash_compress(ctx->hash, ctx->sum);
/*
convert the output to bytes
*/
j = 0;
if (digest != NULL)
for (i = 0; i < 8; i++) {
a = ctx->hash[i];
digest[j] = (mutils_word8) a;
digest[j + 1] = (mutils_word8) (a >> 8);
digest[j + 2] = (mutils_word8) (a >> 16);
digest[j + 3] = (mutils_word8) (a >> 24);
j += 4;
}
}
#endif /* ENABLE_GOST */
@@ -0,0 +1,919 @@
/*
* The HAVAL hashing function
*
* Public domain implementation by Paulo S.L.M. Barreto <pbarreto@nw.com.br>
*
* Version 1.1 (1998.04.19)
*
* Differences from Version 1.0 (1997.04.03):
*
* - Added more parentheses to enforce operator precedence in the definitions
* of the nonlinear F functions, as some compilers do not automatically
* apply the standard precedence rules of the C language (Borland C++ 5.02
* being the culprit in mind)
*
* - Similar changes in HavalUpdate() and in the ROTR macro for
* the same reason.
*
* - Explicitly make casts when reducing precision of an integer value
* or from char to byte (= unsigned char) to silence compilation warnings
* from Borland C++
*
* - Explicitly defined LITTLE_ENDIAN for compilation under MSVC++ and
* Borland C++.
*
* - Fixed the sense of the ROTR macro
*
* - Fixed behaviour on big-endian platforms by doing byte reversal when
* unpacking the final digest from the hash context structure to the
* digest argument of HavalFinal()
*
* - Forcefully note that the code as is does not work on VMS
*
* We are grateful to Mr. Tines <tines@windsong.demon.co.uk> for pointing out
* these problems, providing solutions for them, and testing the fixed code.
*
* -----------------------------------------------------------------------------
*
* Reference: Zheng, Y., Pieprzyk, J., Seberry, J.:
* "HAVAL - a one-way hashing algorithm with variable length of output",
* Advances in Cryptology (AusCrypt'92), LNCS 718 (1993), 83-104, Springer-Verlag.
*
* 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 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.
*/
#include <libdefs.h>
#if defined(ENABLE_HAVAL)
#include <mhash_haval.h>
#define HAVAL_VERSION 1
/* Nonlinear F functions */
#define F1(X6, X5, X4, X3, X2, X1, X0) \
(((X1) & ((X4) ^ (X0))) ^ ((X2) & (X5)) ^ ((X3) & (X6)) ^ (X0))
#define F2(X6, X5, X4, X3, X2, X1, X0) \
(((X2) & (((X1) & (~(X3))) ^ ((X4) & (X5)) ^ (X6) ^ (X0))) ^ \
(((X4) & ((X1) ^ (X5))) ^ ((X3) & (X5)) ^ (X0)))
#define F3(X6, X5, X4, X3, X2, X1, X0) \
(((X3) & (((X1) & (X2)) ^ (X6) ^ (X0))) ^ ((X1) & (X4)) ^ \
((X2) & (X5)) ^ (X0))
#define F4(X6, X5, X4, X3, X2, X1, X0) \
(((X4) & (((~(X2)) & (X5)) ^ ((X3) | (X6)) ^ (X1) ^ (X0))) ^ \
((X3) & (((X1) & (X2)) ^ (X5) ^ (X6))) ^ ((X2) & (X6)) ^ (X0))
#define F5(X6, X5, X4, X3, X2, X1, X0) \
(((X1) & ((X4) ^ ((X0) & (X2) & (X3)))) ^ \
(((X2) ^ (X0)) & (X5)) ^ ((X3) & (X6)) ^ (X0))
#define ROTR(v,n) (((v) >> ((mutils_word32)(n))) | ((v) << (32 - (mutils_word32)(n))))
/*
The following macro would generate better code on an Intel platform,
however it is never used there, and this code when used in e.g
havalTransform3()
t = ((mutils_word32 *)in)[i];
blithely casts byte aligned data to a longword aligned type, causing
an immediate core dump on a RISC system
#define BYTE_REVERSE(out, in) \
{ \
register mutils_word32 t; \
register mutils_word8 i; \
for (i = 0; i < 32; i++) { \
t = ((mutils_word32 *)in)[i]; \
t = ROTR (t, 16); \
((mutils_word32 *)out)[i] = ((t & 0xFF00FF00UL) >> 8) | ((t & 0x00FF00FFUL) << 8); \
} \
}
Therefore, allow for unaligned access and move the bytes by hand.
This assumes that out and in do not overlap, which is the case in
practice here.
*/
static void havalTransform3 (mutils_word32 E[8], __const mutils_word32 D[32], mutils_word32 T[8])
{
mutils_word32 *W;
#if defined(WORDS_BIGENDIAN)
W = mutils_word32nswap(D, 32, MUTILS_FALSE);
#else /* LITTLE ENDIAN */
W = (mutils_word32 *) D;
#endif /* Byte re-ordering */
/* PASS 1: */
T[7] = ROTR (F1 (E[1], E[0], E[3], E[5], E[6], E[2], E[4]), 7) + ROTR (E[7], 11) + W[ 0];
T[6] = ROTR (F1 (E[0], T[7], E[2], E[4], E[5], E[1], E[3]), 7) + ROTR (E[6], 11) + W[ 1];
T[5] = ROTR (F1 (T[7], T[6], E[1], E[3], E[4], E[0], E[2]), 7) + ROTR (E[5], 11) + W[ 2];
T[4] = ROTR (F1 (T[6], T[5], E[0], E[2], E[3], T[7], E[1]), 7) + ROTR (E[4], 11) + W[ 3];
T[3] = ROTR (F1 (T[5], T[4], T[7], E[1], E[2], T[6], E[0]), 7) + ROTR (E[3], 11) + W[ 4];
T[2] = ROTR (F1 (T[4], T[3], T[6], E[0], E[1], T[5], T[7]), 7) + ROTR (E[2], 11) + W[ 5];
T[1] = ROTR (F1 (T[3], T[2], T[5], T[7], E[0], T[4], T[6]), 7) + ROTR (E[1], 11) + W[ 6];
T[0] = ROTR (F1 (T[2], T[1], T[4], T[6], T[7], T[3], T[5]), 7) + ROTR (E[0], 11) + W[ 7];
T[7] = ROTR (F1 (T[1], T[0], T[3], T[5], T[6], T[2], T[4]), 7) + ROTR (T[7], 11) + W[ 8];
T[6] = ROTR (F1 (T[0], T[7], T[2], T[4], T[5], T[1], T[3]), 7) + ROTR (T[6], 11) + W[ 9];
T[5] = ROTR (F1 (T[7], T[6], T[1], T[3], T[4], T[0], T[2]), 7) + ROTR (T[5], 11) + W[10];
T[4] = ROTR (F1 (T[6], T[5], T[0], T[2], T[3], T[7], T[1]), 7) + ROTR (T[4], 11) + W[11];
T[3] = ROTR (F1 (T[5], T[4], T[7], T[1], T[2], T[6], T[0]), 7) + ROTR (T[3], 11) + W[12];
T[2] = ROTR (F1 (T[4], T[3], T[6], T[0], T[1], T[5], T[7]), 7) + ROTR (T[2], 11) + W[13];
T[1] = ROTR (F1 (T[3], T[2], T[5], T[7], T[0], T[4], T[6]), 7) + ROTR (T[1], 11) + W[14];
T[0] = ROTR (F1 (T[2], T[1], T[4], T[6], T[7], T[3], T[5]), 7) + ROTR (T[0], 11) + W[15];
T[7] = ROTR (F1 (T[1], T[0], T[3], T[5], T[6], T[2], T[4]), 7) + ROTR (T[7], 11) + W[16];
T[6] = ROTR (F1 (T[0], T[7], T[2], T[4], T[5], T[1], T[3]), 7) + ROTR (T[6], 11) + W[17];
T[5] = ROTR (F1 (T[7], T[6], T[1], T[3], T[4], T[0], T[2]), 7) + ROTR (T[5], 11) + W[18];
T[4] = ROTR (F1 (T[6], T[5], T[0], T[2], T[3], T[7], T[1]), 7) + ROTR (T[4], 11) + W[19];
T[3] = ROTR (F1 (T[5], T[4], T[7], T[1], T[2], T[6], T[0]), 7) + ROTR (T[3], 11) + W[20];
T[2] = ROTR (F1 (T[4], T[3], T[6], T[0], T[1], T[5], T[7]), 7) + ROTR (T[2], 11) + W[21];
T[1] = ROTR (F1 (T[3], T[2], T[5], T[7], T[0], T[4], T[6]), 7) + ROTR (T[1], 11) + W[22];
T[0] = ROTR (F1 (T[2], T[1], T[4], T[6], T[7], T[3], T[5]), 7) + ROTR (T[0], 11) + W[23];
T[7] = ROTR (F1 (T[1], T[0], T[3], T[5], T[6], T[2], T[4]), 7) + ROTR (T[7], 11) + W[24];
T[6] = ROTR (F1 (T[0], T[7], T[2], T[4], T[5], T[1], T[3]), 7) + ROTR (T[6], 11) + W[25];
T[5] = ROTR (F1 (T[7], T[6], T[1], T[3], T[4], T[0], T[2]), 7) + ROTR (T[5], 11) + W[26];
T[4] = ROTR (F1 (T[6], T[5], T[0], T[2], T[3], T[7], T[1]), 7) + ROTR (T[4], 11) + W[27];
T[3] = ROTR (F1 (T[5], T[4], T[7], T[1], T[2], T[6], T[0]), 7) + ROTR (T[3], 11) + W[28];
T[2] = ROTR (F1 (T[4], T[3], T[6], T[0], T[1], T[5], T[7]), 7) + ROTR (T[2], 11) + W[29];
T[1] = ROTR (F1 (T[3], T[2], T[5], T[7], T[0], T[4], T[6]), 7) + ROTR (T[1], 11) + W[30];
T[0] = ROTR (F1 (T[2], T[1], T[4], T[6], T[7], T[3], T[5]), 7) + ROTR (T[0], 11) + W[31];
/* PASS 2: */
T[7] = ROTR (F2 (T[4], T[2], T[1], T[0], T[5], T[3], T[6]), 7) + ROTR (T[7], 11) + W[ 5] + 0x452821E6UL;
T[6] = ROTR (F2 (T[3], T[1], T[0], T[7], T[4], T[2], T[5]), 7) + ROTR (T[6], 11) + W[14] + 0x38D01377UL;
T[5] = ROTR (F2 (T[2], T[0], T[7], T[6], T[3], T[1], T[4]), 7) + ROTR (T[5], 11) + W[26] + 0xBE5466CFUL;
T[4] = ROTR (F2 (T[1], T[7], T[6], T[5], T[2], T[0], T[3]), 7) + ROTR (T[4], 11) + W[18] + 0x34E90C6CUL;
T[3] = ROTR (F2 (T[0], T[6], T[5], T[4], T[1], T[7], T[2]), 7) + ROTR (T[3], 11) + W[11] + 0xC0AC29B7UL;
T[2] = ROTR (F2 (T[7], T[5], T[4], T[3], T[0], T[6], T[1]), 7) + ROTR (T[2], 11) + W[28] + 0xC97C50DDUL;
T[1] = ROTR (F2 (T[6], T[4], T[3], T[2], T[7], T[5], T[0]), 7) + ROTR (T[1], 11) + W[ 7] + 0x3F84D5B5UL;
T[0] = ROTR (F2 (T[5], T[3], T[2], T[1], T[6], T[4], T[7]), 7) + ROTR (T[0], 11) + W[16] + 0xB5470917UL;
T[7] = ROTR (F2 (T[4], T[2], T[1], T[0], T[5], T[3], T[6]), 7) + ROTR (T[7], 11) + W[ 0] + 0x9216D5D9UL;
T[6] = ROTR (F2 (T[3], T[1], T[0], T[7], T[4], T[2], T[5]), 7) + ROTR (T[6], 11) + W[23] + 0x8979FB1BUL;
T[5] = ROTR (F2 (T[2], T[0], T[7], T[6], T[3], T[1], T[4]), 7) + ROTR (T[5], 11) + W[20] + 0xD1310BA6UL;
T[4] = ROTR (F2 (T[1], T[7], T[6], T[5], T[2], T[0], T[3]), 7) + ROTR (T[4], 11) + W[22] + 0x98DFB5ACUL;
T[3] = ROTR (F2 (T[0], T[6], T[5], T[4], T[1], T[7], T[2]), 7) + ROTR (T[3], 11) + W[ 1] + 0x2FFD72DBUL;
T[2] = ROTR (F2 (T[7], T[5], T[4], T[3], T[0], T[6], T[1]), 7) + ROTR (T[2], 11) + W[10] + 0xD01ADFB7UL;
T[1] = ROTR (F2 (T[6], T[4], T[3], T[2], T[7], T[5], T[0]), 7) + ROTR (T[1], 11) + W[ 4] + 0xB8E1AFEDUL;
T[0] = ROTR (F2 (T[5], T[3], T[2], T[1], T[6], T[4], T[7]), 7) + ROTR (T[0], 11) + W[ 8] + 0x6A267E96UL;
T[7] = ROTR (F2 (T[4], T[2], T[1], T[0], T[5], T[3], T[6]), 7) + ROTR (T[7], 11) + W[30] + 0xBA7C9045UL;
T[6] = ROTR (F2 (T[3], T[1], T[0], T[7], T[4], T[2], T[5]), 7) + ROTR (T[6], 11) + W[ 3] + 0xF12C7F99UL;
T[5] = ROTR (F2 (T[2], T[0], T[7], T[6], T[3], T[1], T[4]), 7) + ROTR (T[5], 11) + W[21] + 0x24A19947UL;
T[4] = ROTR (F2 (T[1], T[7], T[6], T[5], T[2], T[0], T[3]), 7) + ROTR (T[4], 11) + W[ 9] + 0xB3916CF7UL;
T[3] = ROTR (F2 (T[0], T[6], T[5], T[4], T[1], T[7], T[2]), 7) + ROTR (T[3], 11) + W[17] + 0x0801F2E2UL;
T[2] = ROTR (F2 (T[7], T[5], T[4], T[3], T[0], T[6], T[1]), 7) + ROTR (T[2], 11) + W[24] + 0x858EFC16UL;
T[1] = ROTR (F2 (T[6], T[4], T[3], T[2], T[7], T[5], T[0]), 7) + ROTR (T[1], 11) + W[29] + 0x636920D8UL;
T[0] = ROTR (F2 (T[5], T[3], T[2], T[1], T[6], T[4], T[7]), 7) + ROTR (T[0], 11) + W[ 6] + 0x71574E69UL;
T[7] = ROTR (F2 (T[4], T[2], T[1], T[0], T[5], T[3], T[6]), 7) + ROTR (T[7], 11) + W[19] + 0xA458FEA3UL;
T[6] = ROTR (F2 (T[3], T[1], T[0], T[7], T[4], T[2], T[5]), 7) + ROTR (T[6], 11) + W[12] + 0xF4933D7EUL;
T[5] = ROTR (F2 (T[2], T[0], T[7], T[6], T[3], T[1], T[4]), 7) + ROTR (T[5], 11) + W[15] + 0x0D95748FUL;
T[4] = ROTR (F2 (T[1], T[7], T[6], T[5], T[2], T[0], T[3]), 7) + ROTR (T[4], 11) + W[13] + 0x728EB658UL;
T[3] = ROTR (F2 (T[0], T[6], T[5], T[4], T[1], T[7], T[2]), 7) + ROTR (T[3], 11) + W[ 2] + 0x718BCD58UL;
T[2] = ROTR (F2 (T[7], T[5], T[4], T[3], T[0], T[6], T[1]), 7) + ROTR (T[2], 11) + W[25] + 0x82154AEEUL;
T[1] = ROTR (F2 (T[6], T[4], T[3], T[2], T[7], T[5], T[0]), 7) + ROTR (T[1], 11) + W[31] + 0x7B54A41DUL;
T[0] = ROTR (F2 (T[5], T[3], T[2], T[1], T[6], T[4], T[7]), 7) + ROTR (T[0], 11) + W[27] + 0xC25A59B5UL;
/* PASS 3: */
T[7] = ROTR (F3 (T[6], T[1], T[2], T[3], T[4], T[5], T[0]), 7) + ROTR (T[7], 11) + W[19] + 0x9C30D539UL;
T[6] = ROTR (F3 (T[5], T[0], T[1], T[2], T[3], T[4], T[7]), 7) + ROTR (T[6], 11) + W[ 9] + 0x2AF26013UL;
T[5] = ROTR (F3 (T[4], T[7], T[0], T[1], T[2], T[3], T[6]), 7) + ROTR (T[5], 11) + W[ 4] + 0xC5D1B023UL;
T[4] = ROTR (F3 (T[3], T[6], T[7], T[0], T[1], T[2], T[5]), 7) + ROTR (T[4], 11) + W[20] + 0x286085F0UL;
T[3] = ROTR (F3 (T[2], T[5], T[6], T[7], T[0], T[1], T[4]), 7) + ROTR (T[3], 11) + W[28] + 0xCA417918UL;
T[2] = ROTR (F3 (T[1], T[4], T[5], T[6], T[7], T[0], T[3]), 7) + ROTR (T[2], 11) + W[17] + 0xB8DB38EFUL;
T[1] = ROTR (F3 (T[0], T[3], T[4], T[5], T[6], T[7], T[2]), 7) + ROTR (T[1], 11) + W[ 8] + 0x8E79DCB0UL;
T[0] = ROTR (F3 (T[7], T[2], T[3], T[4], T[5], T[6], T[1]), 7) + ROTR (T[0], 11) + W[22] + 0x603A180EUL;
T[7] = ROTR (F3 (T[6], T[1], T[2], T[3], T[4], T[5], T[0]), 7) + ROTR (T[7], 11) + W[29] + 0x6C9E0E8BUL;
T[6] = ROTR (F3 (T[5], T[0], T[1], T[2], T[3], T[4], T[7]), 7) + ROTR (T[6], 11) + W[14] + 0xB01E8A3EUL;
T[5] = ROTR (F3 (T[4], T[7], T[0], T[1], T[2], T[3], T[6]), 7) + ROTR (T[5], 11) + W[25] + 0xD71577C1UL;
T[4] = ROTR (F3 (T[3], T[6], T[7], T[0], T[1], T[2], T[5]), 7) + ROTR (T[4], 11) + W[12] + 0xBD314B27UL;
T[3] = ROTR (F3 (T[2], T[5], T[6], T[7], T[0], T[1], T[4]), 7) + ROTR (T[3], 11) + W[24] + 0x78AF2FDAUL;
T[2] = ROTR (F3 (T[1], T[4], T[5], T[6], T[7], T[0], T[3]), 7) + ROTR (T[2], 11) + W[30] + 0x55605C60UL;
T[1] = ROTR (F3 (T[0], T[3], T[4], T[5], T[6], T[7], T[2]), 7) + ROTR (T[1], 11) + W[16] + 0xE65525F3UL;
T[0] = ROTR (F3 (T[7], T[2], T[3], T[4], T[5], T[6], T[1]), 7) + ROTR (T[0], 11) + W[26] + 0xAA55AB94UL;
T[7] = ROTR (F3 (T[6], T[1], T[2], T[3], T[4], T[5], T[0]), 7) + ROTR (T[7], 11) + W[31] + 0x57489862UL;
T[6] = ROTR (F3 (T[5], T[0], T[1], T[2], T[3], T[4], T[7]), 7) + ROTR (T[6], 11) + W[15] + 0x63E81440UL;
T[5] = ROTR (F3 (T[4], T[7], T[0], T[1], T[2], T[3], T[6]), 7) + ROTR (T[5], 11) + W[ 7] + 0x55CA396AUL;
T[4] = ROTR (F3 (T[3], T[6], T[7], T[0], T[1], T[2], T[5]), 7) + ROTR (T[4], 11) + W[ 3] + 0x2AAB10B6UL;
T[3] = ROTR (F3 (T[2], T[5], T[6], T[7], T[0], T[1], T[4]), 7) + ROTR (T[3], 11) + W[ 1] + 0xB4CC5C34UL;
T[2] = ROTR (F3 (T[1], T[4], T[5], T[6], T[7], T[0], T[3]), 7) + ROTR (T[2], 11) + W[ 0] + 0x1141E8CEUL;
T[1] = ROTR (F3 (T[0], T[3], T[4], T[5], T[6], T[7], T[2]), 7) + ROTR (T[1], 11) + W[18] + 0xA15486AFUL;
T[0] = ROTR (F3 (T[7], T[2], T[3], T[4], T[5], T[6], T[1]), 7) + ROTR (T[0], 11) + W[27] + 0x7C72E993UL;
E[7] += T[7] = ROTR (F3 (T[6], T[1], T[2], T[3], T[4], T[5], T[0]), 7) + ROTR (T[7], 11) + W[13] + 0xB3EE1411UL;
E[6] += T[6] = ROTR (F3 (T[5], T[0], T[1], T[2], T[3], T[4], T[7]), 7) + ROTR (T[6], 11) + W[ 6] + 0x636FBC2AUL;
E[5] += T[5] = ROTR (F3 (T[4], T[7], T[0], T[1], T[2], T[3], T[6]), 7) + ROTR (T[5], 11) + W[21] + 0x2BA9C55DUL;
E[4] += T[4] = ROTR (F3 (T[3], T[6], T[7], T[0], T[1], T[2], T[5]), 7) + ROTR (T[4], 11) + W[10] + 0x741831F6UL;
E[3] += T[3] = ROTR (F3 (T[2], T[5], T[6], T[7], T[0], T[1], T[4]), 7) + ROTR (T[3], 11) + W[23] + 0xCE5C3E16UL;
E[2] += T[2] = ROTR (F3 (T[1], T[4], T[5], T[6], T[7], T[0], T[3]), 7) + ROTR (T[2], 11) + W[11] + 0x9B87931EUL;
E[1] += T[1] = ROTR (F3 (T[0], T[3], T[4], T[5], T[6], T[7], T[2]), 7) + ROTR (T[1], 11) + W[ 5] + 0xAFD6BA33UL;
E[0] += T[0] = ROTR (F3 (T[7], T[2], T[3], T[4], T[5], T[6], T[1]), 7) + ROTR (T[0], 11) + W[ 2] + 0x6C24CF5CUL;
#if defined(WORDS_BIGENDIAN)
mutils_free(W);
#endif
} /* havalTransform3 */
static void havalTransform4 (mutils_word32 E[8], __const mutils_word32 D[32], mutils_word32 T[8])
{
mutils_word32 *W;
#if defined(WORDS_BIGENDIAN)
W = mutils_word32nswap(D, 32, MUTILS_FALSE);
#else /* LITTLE ENDIAN */
W = (mutils_word32 *) D;
#endif /* Byte re-ordering */
/* PASS 1: */
T[7] = ROTR (F1 (E[2], E[6], E[1], E[4], E[5], E[3], E[0]), 7) + ROTR (E[7], 11) + W[ 0];
T[6] = ROTR (F1 (E[1], E[5], E[0], E[3], E[4], E[2], T[7]), 7) + ROTR (E[6], 11) + W[ 1];
T[5] = ROTR (F1 (E[0], E[4], T[7], E[2], E[3], E[1], T[6]), 7) + ROTR (E[5], 11) + W[ 2];
T[4] = ROTR (F1 (T[7], E[3], T[6], E[1], E[2], E[0], T[5]), 7) + ROTR (E[4], 11) + W[ 3];
T[3] = ROTR (F1 (T[6], E[2], T[5], E[0], E[1], T[7], T[4]), 7) + ROTR (E[3], 11) + W[ 4];
T[2] = ROTR (F1 (T[5], E[1], T[4], T[7], E[0], T[6], T[3]), 7) + ROTR (E[2], 11) + W[ 5];
T[1] = ROTR (F1 (T[4], E[0], T[3], T[6], T[7], T[5], T[2]), 7) + ROTR (E[1], 11) + W[ 6];
T[0] = ROTR (F1 (T[3], T[7], T[2], T[5], T[6], T[4], T[1]), 7) + ROTR (E[0], 11) + W[ 7];
T[7] = ROTR (F1 (T[2], T[6], T[1], T[4], T[5], T[3], T[0]), 7) + ROTR (T[7], 11) + W[ 8];
T[6] = ROTR (F1 (T[1], T[5], T[0], T[3], T[4], T[2], T[7]), 7) + ROTR (T[6], 11) + W[ 9];
T[5] = ROTR (F1 (T[0], T[4], T[7], T[2], T[3], T[1], T[6]), 7) + ROTR (T[5], 11) + W[10];
T[4] = ROTR (F1 (T[7], T[3], T[6], T[1], T[2], T[0], T[5]), 7) + ROTR (T[4], 11) + W[11];
T[3] = ROTR (F1 (T[6], T[2], T[5], T[0], T[1], T[7], T[4]), 7) + ROTR (T[3], 11) + W[12];
T[2] = ROTR (F1 (T[5], T[1], T[4], T[7], T[0], T[6], T[3]), 7) + ROTR (T[2], 11) + W[13];
T[1] = ROTR (F1 (T[4], T[0], T[3], T[6], T[7], T[5], T[2]), 7) + ROTR (T[1], 11) + W[14];
T[0] = ROTR (F1 (T[3], T[7], T[2], T[5], T[6], T[4], T[1]), 7) + ROTR (T[0], 11) + W[15];
T[7] = ROTR (F1 (T[2], T[6], T[1], T[4], T[5], T[3], T[0]), 7) + ROTR (T[7], 11) + W[16];
T[6] = ROTR (F1 (T[1], T[5], T[0], T[3], T[4], T[2], T[7]), 7) + ROTR (T[6], 11) + W[17];
T[5] = ROTR (F1 (T[0], T[4], T[7], T[2], T[3], T[1], T[6]), 7) + ROTR (T[5], 11) + W[18];
T[4] = ROTR (F1 (T[7], T[3], T[6], T[1], T[2], T[0], T[5]), 7) + ROTR (T[4], 11) + W[19];
T[3] = ROTR (F1 (T[6], T[2], T[5], T[0], T[1], T[7], T[4]), 7) + ROTR (T[3], 11) + W[20];
T[2] = ROTR (F1 (T[5], T[1], T[4], T[7], T[0], T[6], T[3]), 7) + ROTR (T[2], 11) + W[21];
T[1] = ROTR (F1 (T[4], T[0], T[3], T[6], T[7], T[5], T[2]), 7) + ROTR (T[1], 11) + W[22];
T[0] = ROTR (F1 (T[3], T[7], T[2], T[5], T[6], T[4], T[1]), 7) + ROTR (T[0], 11) + W[23];
T[7] = ROTR (F1 (T[2], T[6], T[1], T[4], T[5], T[3], T[0]), 7) + ROTR (T[7], 11) + W[24];
T[6] = ROTR (F1 (T[1], T[5], T[0], T[3], T[4], T[2], T[7]), 7) + ROTR (T[6], 11) + W[25];
T[5] = ROTR (F1 (T[0], T[4], T[7], T[2], T[3], T[1], T[6]), 7) + ROTR (T[5], 11) + W[26];
T[4] = ROTR (F1 (T[7], T[3], T[6], T[1], T[2], T[0], T[5]), 7) + ROTR (T[4], 11) + W[27];
T[3] = ROTR (F1 (T[6], T[2], T[5], T[0], T[1], T[7], T[4]), 7) + ROTR (T[3], 11) + W[28];
T[2] = ROTR (F1 (T[5], T[1], T[4], T[7], T[0], T[6], T[3]), 7) + ROTR (T[2], 11) + W[29];
T[1] = ROTR (F1 (T[4], T[0], T[3], T[6], T[7], T[5], T[2]), 7) + ROTR (T[1], 11) + W[30];
T[0] = ROTR (F1 (T[3], T[7], T[2], T[5], T[6], T[4], T[1]), 7) + ROTR (T[0], 11) + W[31];
/* PASS 2: */
T[7] = ROTR (F2 (T[3], T[5], T[2], T[0], T[1], T[6], T[4]), 7) + ROTR (T[7], 11) + W[ 5] + 0x452821E6UL;
T[6] = ROTR (F2 (T[2], T[4], T[1], T[7], T[0], T[5], T[3]), 7) + ROTR (T[6], 11) + W[14] + 0x38D01377UL;
T[5] = ROTR (F2 (T[1], T[3], T[0], T[6], T[7], T[4], T[2]), 7) + ROTR (T[5], 11) + W[26] + 0xBE5466CFUL;
T[4] = ROTR (F2 (T[0], T[2], T[7], T[5], T[6], T[3], T[1]), 7) + ROTR (T[4], 11) + W[18] + 0x34E90C6CUL;
T[3] = ROTR (F2 (T[7], T[1], T[6], T[4], T[5], T[2], T[0]), 7) + ROTR (T[3], 11) + W[11] + 0xC0AC29B7UL;
T[2] = ROTR (F2 (T[6], T[0], T[5], T[3], T[4], T[1], T[7]), 7) + ROTR (T[2], 11) + W[28] + 0xC97C50DDUL;
T[1] = ROTR (F2 (T[5], T[7], T[4], T[2], T[3], T[0], T[6]), 7) + ROTR (T[1], 11) + W[ 7] + 0x3F84D5B5UL;
T[0] = ROTR (F2 (T[4], T[6], T[3], T[1], T[2], T[7], T[5]), 7) + ROTR (T[0], 11) + W[16] + 0xB5470917UL;
T[7] = ROTR (F2 (T[3], T[5], T[2], T[0], T[1], T[6], T[4]), 7) + ROTR (T[7], 11) + W[ 0] + 0x9216D5D9UL;
T[6] = ROTR (F2 (T[2], T[4], T[1], T[7], T[0], T[5], T[3]), 7) + ROTR (T[6], 11) + W[23] + 0x8979FB1BUL;
T[5] = ROTR (F2 (T[1], T[3], T[0], T[6], T[7], T[4], T[2]), 7) + ROTR (T[5], 11) + W[20] + 0xD1310BA6UL;
T[4] = ROTR (F2 (T[0], T[2], T[7], T[5], T[6], T[3], T[1]), 7) + ROTR (T[4], 11) + W[22] + 0x98DFB5ACUL;
T[3] = ROTR (F2 (T[7], T[1], T[6], T[4], T[5], T[2], T[0]), 7) + ROTR (T[3], 11) + W[ 1] + 0x2FFD72DBUL;
T[2] = ROTR (F2 (T[6], T[0], T[5], T[3], T[4], T[1], T[7]), 7) + ROTR (T[2], 11) + W[10] + 0xD01ADFB7UL;
T[1] = ROTR (F2 (T[5], T[7], T[4], T[2], T[3], T[0], T[6]), 7) + ROTR (T[1], 11) + W[ 4] + 0xB8E1AFEDUL;
T[0] = ROTR (F2 (T[4], T[6], T[3], T[1], T[2], T[7], T[5]), 7) + ROTR (T[0], 11) + W[ 8] + 0x6A267E96UL;
T[7] = ROTR (F2 (T[3], T[5], T[2], T[0], T[1], T[6], T[4]), 7) + ROTR (T[7], 11) + W[30] + 0xBA7C9045UL;
T[6] = ROTR (F2 (T[2], T[4], T[1], T[7], T[0], T[5], T[3]), 7) + ROTR (T[6], 11) + W[ 3] + 0xF12C7F99UL;
T[5] = ROTR (F2 (T[1], T[3], T[0], T[6], T[7], T[4], T[2]), 7) + ROTR (T[5], 11) + W[21] + 0x24A19947UL;
T[4] = ROTR (F2 (T[0], T[2], T[7], T[5], T[6], T[3], T[1]), 7) + ROTR (T[4], 11) + W[ 9] + 0xB3916CF7UL;
T[3] = ROTR (F2 (T[7], T[1], T[6], T[4], T[5], T[2], T[0]), 7) + ROTR (T[3], 11) + W[17] + 0x0801F2E2UL;
T[2] = ROTR (F2 (T[6], T[0], T[5], T[3], T[4], T[1], T[7]), 7) + ROTR (T[2], 11) + W[24] + 0x858EFC16UL;
T[1] = ROTR (F2 (T[5], T[7], T[4], T[2], T[3], T[0], T[6]), 7) + ROTR (T[1], 11) + W[29] + 0x636920D8UL;
T[0] = ROTR (F2 (T[4], T[6], T[3], T[1], T[2], T[7], T[5]), 7) + ROTR (T[0], 11) + W[ 6] + 0x71574E69UL;
T[7] = ROTR (F2 (T[3], T[5], T[2], T[0], T[1], T[6], T[4]), 7) + ROTR (T[7], 11) + W[19] + 0xA458FEA3UL;
T[6] = ROTR (F2 (T[2], T[4], T[1], T[7], T[0], T[5], T[3]), 7) + ROTR (T[6], 11) + W[12] + 0xF4933D7EUL;
T[5] = ROTR (F2 (T[1], T[3], T[0], T[6], T[7], T[4], T[2]), 7) + ROTR (T[5], 11) + W[15] + 0x0D95748FUL;
T[4] = ROTR (F2 (T[0], T[2], T[7], T[5], T[6], T[3], T[1]), 7) + ROTR (T[4], 11) + W[13] + 0x728EB658UL;
T[3] = ROTR (F2 (T[7], T[1], T[6], T[4], T[5], T[2], T[0]), 7) + ROTR (T[3], 11) + W[ 2] + 0x718BCD58UL;
T[2] = ROTR (F2 (T[6], T[0], T[5], T[3], T[4], T[1], T[7]), 7) + ROTR (T[2], 11) + W[25] + 0x82154AEEUL;
T[1] = ROTR (F2 (T[5], T[7], T[4], T[2], T[3], T[0], T[6]), 7) + ROTR (T[1], 11) + W[31] + 0x7B54A41DUL;
T[0] = ROTR (F2 (T[4], T[6], T[3], T[1], T[2], T[7], T[5]), 7) + ROTR (T[0], 11) + W[27] + 0xC25A59B5UL;
/* PASS 3: */
T[7] = ROTR (F3 (T[1], T[4], T[3], T[6], T[0], T[2], T[5]), 7) + ROTR (T[7], 11) + W[19] + 0x9C30D539UL;
T[6] = ROTR (F3 (T[0], T[3], T[2], T[5], T[7], T[1], T[4]), 7) + ROTR (T[6], 11) + W[ 9] + 0x2AF26013UL;
T[5] = ROTR (F3 (T[7], T[2], T[1], T[4], T[6], T[0], T[3]), 7) + ROTR (T[5], 11) + W[ 4] + 0xC5D1B023UL;
T[4] = ROTR (F3 (T[6], T[1], T[0], T[3], T[5], T[7], T[2]), 7) + ROTR (T[4], 11) + W[20] + 0x286085F0UL;
T[3] = ROTR (F3 (T[5], T[0], T[7], T[2], T[4], T[6], T[1]), 7) + ROTR (T[3], 11) + W[28] + 0xCA417918UL;
T[2] = ROTR (F3 (T[4], T[7], T[6], T[1], T[3], T[5], T[0]), 7) + ROTR (T[2], 11) + W[17] + 0xB8DB38EFUL;
T[1] = ROTR (F3 (T[3], T[6], T[5], T[0], T[2], T[4], T[7]), 7) + ROTR (T[1], 11) + W[ 8] + 0x8E79DCB0UL;
T[0] = ROTR (F3 (T[2], T[5], T[4], T[7], T[1], T[3], T[6]), 7) + ROTR (T[0], 11) + W[22] + 0x603A180EUL;
T[7] = ROTR (F3 (T[1], T[4], T[3], T[6], T[0], T[2], T[5]), 7) + ROTR (T[7], 11) + W[29] + 0x6C9E0E8BUL;
T[6] = ROTR (F3 (T[0], T[3], T[2], T[5], T[7], T[1], T[4]), 7) + ROTR (T[6], 11) + W[14] + 0xB01E8A3EUL;
T[5] = ROTR (F3 (T[7], T[2], T[1], T[4], T[6], T[0], T[3]), 7) + ROTR (T[5], 11) + W[25] + 0xD71577C1UL;
T[4] = ROTR (F3 (T[6], T[1], T[0], T[3], T[5], T[7], T[2]), 7) + ROTR (T[4], 11) + W[12] + 0xBD314B27UL;
T[3] = ROTR (F3 (T[5], T[0], T[7], T[2], T[4], T[6], T[1]), 7) + ROTR (T[3], 11) + W[24] + 0x78AF2FDAUL;
T[2] = ROTR (F3 (T[4], T[7], T[6], T[1], T[3], T[5], T[0]), 7) + ROTR (T[2], 11) + W[30] + 0x55605C60UL;
T[1] = ROTR (F3 (T[3], T[6], T[5], T[0], T[2], T[4], T[7]), 7) + ROTR (T[1], 11) + W[16] + 0xE65525F3UL;
T[0] = ROTR (F3 (T[2], T[5], T[4], T[7], T[1], T[3], T[6]), 7) + ROTR (T[0], 11) + W[26] + 0xAA55AB94UL;
T[7] = ROTR (F3 (T[1], T[4], T[3], T[6], T[0], T[2], T[5]), 7) + ROTR (T[7], 11) + W[31] + 0x57489862UL;
T[6] = ROTR (F3 (T[0], T[3], T[2], T[5], T[7], T[1], T[4]), 7) + ROTR (T[6], 11) + W[15] + 0x63E81440UL;
T[5] = ROTR (F3 (T[7], T[2], T[1], T[4], T[6], T[0], T[3]), 7) + ROTR (T[5], 11) + W[ 7] + 0x55CA396AUL;
T[4] = ROTR (F3 (T[6], T[1], T[0], T[3], T[5], T[7], T[2]), 7) + ROTR (T[4], 11) + W[ 3] + 0x2AAB10B6UL;
T[3] = ROTR (F3 (T[5], T[0], T[7], T[2], T[4], T[6], T[1]), 7) + ROTR (T[3], 11) + W[ 1] + 0xB4CC5C34UL;
T[2] = ROTR (F3 (T[4], T[7], T[6], T[1], T[3], T[5], T[0]), 7) + ROTR (T[2], 11) + W[ 0] + 0x1141E8CEUL;
T[1] = ROTR (F3 (T[3], T[6], T[5], T[0], T[2], T[4], T[7]), 7) + ROTR (T[1], 11) + W[18] + 0xA15486AFUL;
T[0] = ROTR (F3 (T[2], T[5], T[4], T[7], T[1], T[3], T[6]), 7) + ROTR (T[0], 11) + W[27] + 0x7C72E993UL;
T[7] = ROTR (F3 (T[1], T[4], T[3], T[6], T[0], T[2], T[5]), 7) + ROTR (T[7], 11) + W[13] + 0xB3EE1411UL;
T[6] = ROTR (F3 (T[0], T[3], T[2], T[5], T[7], T[1], T[4]), 7) + ROTR (T[6], 11) + W[ 6] + 0x636FBC2AUL;
T[5] = ROTR (F3 (T[7], T[2], T[1], T[4], T[6], T[0], T[3]), 7) + ROTR (T[5], 11) + W[21] + 0x2BA9C55DUL;
T[4] = ROTR (F3 (T[6], T[1], T[0], T[3], T[5], T[7], T[2]), 7) + ROTR (T[4], 11) + W[10] + 0x741831F6UL;
T[3] = ROTR (F3 (T[5], T[0], T[7], T[2], T[4], T[6], T[1]), 7) + ROTR (T[3], 11) + W[23] + 0xCE5C3E16UL;
T[2] = ROTR (F3 (T[4], T[7], T[6], T[1], T[3], T[5], T[0]), 7) + ROTR (T[2], 11) + W[11] + 0x9B87931EUL;
T[1] = ROTR (F3 (T[3], T[6], T[5], T[0], T[2], T[4], T[7]), 7) + ROTR (T[1], 11) + W[ 5] + 0xAFD6BA33UL;
T[0] = ROTR (F3 (T[2], T[5], T[4], T[7], T[1], T[3], T[6]), 7) + ROTR (T[0], 11) + W[ 2] + 0x6C24CF5CUL;
/* PASS 4: */
T[7] = ROTR (F4 (T[6], T[4], T[0], T[5], T[2], T[1], T[3]), 7) + ROTR (T[7], 11) + W[24] + 0x7A325381UL;
T[6] = ROTR (F4 (T[5], T[3], T[7], T[4], T[1], T[0], T[2]), 7) + ROTR (T[6], 11) + W[ 4] + 0x28958677UL;
T[5] = ROTR (F4 (T[4], T[2], T[6], T[3], T[0], T[7], T[1]), 7) + ROTR (T[5], 11) + W[ 0] + 0x3B8F4898UL;
T[4] = ROTR (F4 (T[3], T[1], T[5], T[2], T[7], T[6], T[0]), 7) + ROTR (T[4], 11) + W[14] + 0x6B4BB9AFUL;
T[3] = ROTR (F4 (T[2], T[0], T[4], T[1], T[6], T[5], T[7]), 7) + ROTR (T[3], 11) + W[ 2] + 0xC4BFE81BUL;
T[2] = ROTR (F4 (T[1], T[7], T[3], T[0], T[5], T[4], T[6]), 7) + ROTR (T[2], 11) + W[ 7] + 0x66282193UL;
T[1] = ROTR (F4 (T[0], T[6], T[2], T[7], T[4], T[3], T[5]), 7) + ROTR (T[1], 11) + W[28] + 0x61D809CCUL;
T[0] = ROTR (F4 (T[7], T[5], T[1], T[6], T[3], T[2], T[4]), 7) + ROTR (T[0], 11) + W[23] + 0xFB21A991UL;
T[7] = ROTR (F4 (T[6], T[4], T[0], T[5], T[2], T[1], T[3]), 7) + ROTR (T[7], 11) + W[26] + 0x487CAC60UL;
T[6] = ROTR (F4 (T[5], T[3], T[7], T[4], T[1], T[0], T[2]), 7) + ROTR (T[6], 11) + W[ 6] + 0x5DEC8032UL;
T[5] = ROTR (F4 (T[4], T[2], T[6], T[3], T[0], T[7], T[1]), 7) + ROTR (T[5], 11) + W[30] + 0xEF845D5DUL;
T[4] = ROTR (F4 (T[3], T[1], T[5], T[2], T[7], T[6], T[0]), 7) + ROTR (T[4], 11) + W[20] + 0xE98575B1UL;
T[3] = ROTR (F4 (T[2], T[0], T[4], T[1], T[6], T[5], T[7]), 7) + ROTR (T[3], 11) + W[18] + 0xDC262302UL;
T[2] = ROTR (F4 (T[1], T[7], T[3], T[0], T[5], T[4], T[6]), 7) + ROTR (T[2], 11) + W[25] + 0xEB651B88UL;
T[1] = ROTR (F4 (T[0], T[6], T[2], T[7], T[4], T[3], T[5]), 7) + ROTR (T[1], 11) + W[19] + 0x23893E81UL;
T[0] = ROTR (F4 (T[7], T[5], T[1], T[6], T[3], T[2], T[4]), 7) + ROTR (T[0], 11) + W[ 3] + 0xD396ACC5UL;
T[7] = ROTR (F4 (T[6], T[4], T[0], T[5], T[2], T[1], T[3]), 7) + ROTR (T[7], 11) + W[22] + 0x0F6D6FF3UL;
T[6] = ROTR (F4 (T[5], T[3], T[7], T[4], T[1], T[0], T[2]), 7) + ROTR (T[6], 11) + W[11] + 0x83F44239UL;
T[5] = ROTR (F4 (T[4], T[2], T[6], T[3], T[0], T[7], T[1]), 7) + ROTR (T[5], 11) + W[31] + 0x2E0B4482UL;
T[4] = ROTR (F4 (T[3], T[1], T[5], T[2], T[7], T[6], T[0]), 7) + ROTR (T[4], 11) + W[21] + 0xA4842004UL;
T[3] = ROTR (F4 (T[2], T[0], T[4], T[1], T[6], T[5], T[7]), 7) + ROTR (T[3], 11) + W[ 8] + 0x69C8F04AUL;
T[2] = ROTR (F4 (T[1], T[7], T[3], T[0], T[5], T[4], T[6]), 7) + ROTR (T[2], 11) + W[27] + 0x9E1F9B5EUL;
T[1] = ROTR (F4 (T[0], T[6], T[2], T[7], T[4], T[3], T[5]), 7) + ROTR (T[1], 11) + W[12] + 0x21C66842UL;
T[0] = ROTR (F4 (T[7], T[5], T[1], T[6], T[3], T[2], T[4]), 7) + ROTR (T[0], 11) + W[ 9] + 0xF6E96C9AUL;
E[7] += T[7] = ROTR (F4 (T[6], T[4], T[0], T[5], T[2], T[1], T[3]), 7) + ROTR (T[7], 11) + W[ 1] + 0x670C9C61UL;
E[6] += T[6] = ROTR (F4 (T[5], T[3], T[7], T[4], T[1], T[0], T[2]), 7) + ROTR (T[6], 11) + W[29] + 0xABD388F0UL;
E[5] += T[5] = ROTR (F4 (T[4], T[2], T[6], T[3], T[0], T[7], T[1]), 7) + ROTR (T[5], 11) + W[ 5] + 0x6A51A0D2UL;
E[4] += T[4] = ROTR (F4 (T[3], T[1], T[5], T[2], T[7], T[6], T[0]), 7) + ROTR (T[4], 11) + W[15] + 0xD8542F68UL;
E[3] += T[3] = ROTR (F4 (T[2], T[0], T[4], T[1], T[6], T[5], T[7]), 7) + ROTR (T[3], 11) + W[17] + 0x960FA728UL;
E[2] += T[2] = ROTR (F4 (T[1], T[7], T[3], T[0], T[5], T[4], T[6]), 7) + ROTR (T[2], 11) + W[10] + 0xAB5133A3UL;
E[1] += T[1] = ROTR (F4 (T[0], T[6], T[2], T[7], T[4], T[3], T[5]), 7) + ROTR (T[1], 11) + W[16] + 0x6EEF0B6CUL;
E[0] += T[0] = ROTR (F4 (T[7], T[5], T[1], T[6], T[3], T[2], T[4]), 7) + ROTR (T[0], 11) + W[13] + 0x137A3BE4UL;
#if defined(WORDS_BIGENDIAN)
mutils_free(W);
#endif
} /* havalTransform4 */
static void havalTransform5 (mutils_word32 E[8], __const mutils_word32 D[32], mutils_word32 T[8])
{
mutils_word32 *W;
#if defined(WORDS_BIGENDIAN)
W = mutils_word32nswap(D, 32, MUTILS_FALSE);
#else /* LITTLE ENDIAN */
W = (mutils_word32 *) D;
#endif /* Byte re-ordering */
/* PASS 1: */
T[7] = ROTR (F1 (E[3], E[4], E[1], E[0], E[5], E[2], E[6]), 7) + ROTR (E[7], 11) + W[ 0];
T[6] = ROTR (F1 (E[2], E[3], E[0], T[7], E[4], E[1], E[5]), 7) + ROTR (E[6], 11) + W[ 1];
T[5] = ROTR (F1 (E[1], E[2], T[7], T[6], E[3], E[0], E[4]), 7) + ROTR (E[5], 11) + W[ 2];
T[4] = ROTR (F1 (E[0], E[1], T[6], T[5], E[2], T[7], E[3]), 7) + ROTR (E[4], 11) + W[ 3];
T[3] = ROTR (F1 (T[7], E[0], T[5], T[4], E[1], T[6], E[2]), 7) + ROTR (E[3], 11) + W[ 4];
T[2] = ROTR (F1 (T[6], T[7], T[4], T[3], E[0], T[5], E[1]), 7) + ROTR (E[2], 11) + W[ 5];
T[1] = ROTR (F1 (T[5], T[6], T[3], T[2], T[7], T[4], E[0]), 7) + ROTR (E[1], 11) + W[ 6];
T[0] = ROTR (F1 (T[4], T[5], T[2], T[1], T[6], T[3], T[7]), 7) + ROTR (E[0], 11) + W[ 7];
T[7] = ROTR (F1 (T[3], T[4], T[1], T[0], T[5], T[2], T[6]), 7) + ROTR (T[7], 11) + W[ 8];
T[6] = ROTR (F1 (T[2], T[3], T[0], T[7], T[4], T[1], T[5]), 7) + ROTR (T[6], 11) + W[ 9];
T[5] = ROTR (F1 (T[1], T[2], T[7], T[6], T[3], T[0], T[4]), 7) + ROTR (T[5], 11) + W[10];
T[4] = ROTR (F1 (T[0], T[1], T[6], T[5], T[2], T[7], T[3]), 7) + ROTR (T[4], 11) + W[11];
T[3] = ROTR (F1 (T[7], T[0], T[5], T[4], T[1], T[6], T[2]), 7) + ROTR (T[3], 11) + W[12];
T[2] = ROTR (F1 (T[6], T[7], T[4], T[3], T[0], T[5], T[1]), 7) + ROTR (T[2], 11) + W[13];
T[1] = ROTR (F1 (T[5], T[6], T[3], T[2], T[7], T[4], T[0]), 7) + ROTR (T[1], 11) + W[14];
T[0] = ROTR (F1 (T[4], T[5], T[2], T[1], T[6], T[3], T[7]), 7) + ROTR (T[0], 11) + W[15];
T[7] = ROTR (F1 (T[3], T[4], T[1], T[0], T[5], T[2], T[6]), 7) + ROTR (T[7], 11) + W[16];
T[6] = ROTR (F1 (T[2], T[3], T[0], T[7], T[4], T[1], T[5]), 7) + ROTR (T[6], 11) + W[17];
T[5] = ROTR (F1 (T[1], T[2], T[7], T[6], T[3], T[0], T[4]), 7) + ROTR (T[5], 11) + W[18];
T[4] = ROTR (F1 (T[0], T[1], T[6], T[5], T[2], T[7], T[3]), 7) + ROTR (T[4], 11) + W[19];
T[3] = ROTR (F1 (T[7], T[0], T[5], T[4], T[1], T[6], T[2]), 7) + ROTR (T[3], 11) + W[20];
T[2] = ROTR (F1 (T[6], T[7], T[4], T[3], T[0], T[5], T[1]), 7) + ROTR (T[2], 11) + W[21];
T[1] = ROTR (F1 (T[5], T[6], T[3], T[2], T[7], T[4], T[0]), 7) + ROTR (T[1], 11) + W[22];
T[0] = ROTR (F1 (T[4], T[5], T[2], T[1], T[6], T[3], T[7]), 7) + ROTR (T[0], 11) + W[23];
T[7] = ROTR (F1 (T[3], T[4], T[1], T[0], T[5], T[2], T[6]), 7) + ROTR (T[7], 11) + W[24];
T[6] = ROTR (F1 (T[2], T[3], T[0], T[7], T[4], T[1], T[5]), 7) + ROTR (T[6], 11) + W[25];
T[5] = ROTR (F1 (T[1], T[2], T[7], T[6], T[3], T[0], T[4]), 7) + ROTR (T[5], 11) + W[26];
T[4] = ROTR (F1 (T[0], T[1], T[6], T[5], T[2], T[7], T[3]), 7) + ROTR (T[4], 11) + W[27];
T[3] = ROTR (F1 (T[7], T[0], T[5], T[4], T[1], T[6], T[2]), 7) + ROTR (T[3], 11) + W[28];
T[2] = ROTR (F1 (T[6], T[7], T[4], T[3], T[0], T[5], T[1]), 7) + ROTR (T[2], 11) + W[29];
T[1] = ROTR (F1 (T[5], T[6], T[3], T[2], T[7], T[4], T[0]), 7) + ROTR (T[1], 11) + W[30];
T[0] = ROTR (F1 (T[4], T[5], T[2], T[1], T[6], T[3], T[7]), 7) + ROTR (T[0], 11) + W[31];
/* PASS 2: */
T[7] = ROTR (F2 (T[6], T[2], T[1], T[0], T[3], T[4], T[5]), 7) + ROTR (T[7], 11) + W[ 5] + 0x452821E6UL;
T[6] = ROTR (F2 (T[5], T[1], T[0], T[7], T[2], T[3], T[4]), 7) + ROTR (T[6], 11) + W[14] + 0x38D01377UL;
T[5] = ROTR (F2 (T[4], T[0], T[7], T[6], T[1], T[2], T[3]), 7) + ROTR (T[5], 11) + W[26] + 0xBE5466CFUL;
T[4] = ROTR (F2 (T[3], T[7], T[6], T[5], T[0], T[1], T[2]), 7) + ROTR (T[4], 11) + W[18] + 0x34E90C6CUL;
T[3] = ROTR (F2 (T[2], T[6], T[5], T[4], T[7], T[0], T[1]), 7) + ROTR (T[3], 11) + W[11] + 0xC0AC29B7UL;
T[2] = ROTR (F2 (T[1], T[5], T[4], T[3], T[6], T[7], T[0]), 7) + ROTR (T[2], 11) + W[28] + 0xC97C50DDUL;
T[1] = ROTR (F2 (T[0], T[4], T[3], T[2], T[5], T[6], T[7]), 7) + ROTR (T[1], 11) + W[ 7] + 0x3F84D5B5UL;
T[0] = ROTR (F2 (T[7], T[3], T[2], T[1], T[4], T[5], T[6]), 7) + ROTR (T[0], 11) + W[16] + 0xB5470917UL;
T[7] = ROTR (F2 (T[6], T[2], T[1], T[0], T[3], T[4], T[5]), 7) + ROTR (T[7], 11) + W[ 0] + 0x9216D5D9UL;
T[6] = ROTR (F2 (T[5], T[1], T[0], T[7], T[2], T[3], T[4]), 7) + ROTR (T[6], 11) + W[23] + 0x8979FB1BUL;
T[5] = ROTR (F2 (T[4], T[0], T[7], T[6], T[1], T[2], T[3]), 7) + ROTR (T[5], 11) + W[20] + 0xD1310BA6UL;
T[4] = ROTR (F2 (T[3], T[7], T[6], T[5], T[0], T[1], T[2]), 7) + ROTR (T[4], 11) + W[22] + 0x98DFB5ACUL;
T[3] = ROTR (F2 (T[2], T[6], T[5], T[4], T[7], T[0], T[1]), 7) + ROTR (T[3], 11) + W[ 1] + 0x2FFD72DBUL;
T[2] = ROTR (F2 (T[1], T[5], T[4], T[3], T[6], T[7], T[0]), 7) + ROTR (T[2], 11) + W[10] + 0xD01ADFB7UL;
T[1] = ROTR (F2 (T[0], T[4], T[3], T[2], T[5], T[6], T[7]), 7) + ROTR (T[1], 11) + W[ 4] + 0xB8E1AFEDUL;
T[0] = ROTR (F2 (T[7], T[3], T[2], T[1], T[4], T[5], T[6]), 7) + ROTR (T[0], 11) + W[ 8] + 0x6A267E96UL;
T[7] = ROTR (F2 (T[6], T[2], T[1], T[0], T[3], T[4], T[5]), 7) + ROTR (T[7], 11) + W[30] + 0xBA7C9045UL;
T[6] = ROTR (F2 (T[5], T[1], T[0], T[7], T[2], T[3], T[4]), 7) + ROTR (T[6], 11) + W[ 3] + 0xF12C7F99UL;
T[5] = ROTR (F2 (T[4], T[0], T[7], T[6], T[1], T[2], T[3]), 7) + ROTR (T[5], 11) + W[21] + 0x24A19947UL;
T[4] = ROTR (F2 (T[3], T[7], T[6], T[5], T[0], T[1], T[2]), 7) + ROTR (T[4], 11) + W[ 9] + 0xB3916CF7UL;
T[3] = ROTR (F2 (T[2], T[6], T[5], T[4], T[7], T[0], T[1]), 7) + ROTR (T[3], 11) + W[17] + 0x0801F2E2UL;
T[2] = ROTR (F2 (T[1], T[5], T[4], T[3], T[6], T[7], T[0]), 7) + ROTR (T[2], 11) + W[24] + 0x858EFC16UL;
T[1] = ROTR (F2 (T[0], T[4], T[3], T[2], T[5], T[6], T[7]), 7) + ROTR (T[1], 11) + W[29] + 0x636920D8UL;
T[0] = ROTR (F2 (T[7], T[3], T[2], T[1], T[4], T[5], T[6]), 7) + ROTR (T[0], 11) + W[ 6] + 0x71574E69UL;
T[7] = ROTR (F2 (T[6], T[2], T[1], T[0], T[3], T[4], T[5]), 7) + ROTR (T[7], 11) + W[19] + 0xA458FEA3UL;
T[6] = ROTR (F2 (T[5], T[1], T[0], T[7], T[2], T[3], T[4]), 7) + ROTR (T[6], 11) + W[12] + 0xF4933D7EUL;
T[5] = ROTR (F2 (T[4], T[0], T[7], T[6], T[1], T[2], T[3]), 7) + ROTR (T[5], 11) + W[15] + 0x0D95748FUL;
T[4] = ROTR (F2 (T[3], T[7], T[6], T[5], T[0], T[1], T[2]), 7) + ROTR (T[4], 11) + W[13] + 0x728EB658UL;
T[3] = ROTR (F2 (T[2], T[6], T[5], T[4], T[7], T[0], T[1]), 7) + ROTR (T[3], 11) + W[ 2] + 0x718BCD58UL;
T[2] = ROTR (F2 (T[1], T[5], T[4], T[3], T[6], T[7], T[0]), 7) + ROTR (T[2], 11) + W[25] + 0x82154AEEUL;
T[1] = ROTR (F2 (T[0], T[4], T[3], T[2], T[5], T[6], T[7]), 7) + ROTR (T[1], 11) + W[31] + 0x7B54A41DUL;
T[0] = ROTR (F2 (T[7], T[3], T[2], T[1], T[4], T[5], T[6]), 7) + ROTR (T[0], 11) + W[27] + 0xC25A59B5UL;
/* PASS 3: */
T[7] = ROTR (F3 (T[2], T[6], T[0], T[4], T[3], T[1], T[5]), 7) + ROTR (T[7], 11) + W[19] + 0x9C30D539UL;
T[6] = ROTR (F3 (T[1], T[5], T[7], T[3], T[2], T[0], T[4]), 7) + ROTR (T[6], 11) + W[ 9] + 0x2AF26013UL;
T[5] = ROTR (F3 (T[0], T[4], T[6], T[2], T[1], T[7], T[3]), 7) + ROTR (T[5], 11) + W[ 4] + 0xC5D1B023UL;
T[4] = ROTR (F3 (T[7], T[3], T[5], T[1], T[0], T[6], T[2]), 7) + ROTR (T[4], 11) + W[20] + 0x286085F0UL;
T[3] = ROTR (F3 (T[6], T[2], T[4], T[0], T[7], T[5], T[1]), 7) + ROTR (T[3], 11) + W[28] + 0xCA417918UL;
T[2] = ROTR (F3 (T[5], T[1], T[3], T[7], T[6], T[4], T[0]), 7) + ROTR (T[2], 11) + W[17] + 0xB8DB38EFUL;
T[1] = ROTR (F3 (T[4], T[0], T[2], T[6], T[5], T[3], T[7]), 7) + ROTR (T[1], 11) + W[ 8] + 0x8E79DCB0UL;
T[0] = ROTR (F3 (T[3], T[7], T[1], T[5], T[4], T[2], T[6]), 7) + ROTR (T[0], 11) + W[22] + 0x603A180EUL;
T[7] = ROTR (F3 (T[2], T[6], T[0], T[4], T[3], T[1], T[5]), 7) + ROTR (T[7], 11) + W[29] + 0x6C9E0E8BUL;
T[6] = ROTR (F3 (T[1], T[5], T[7], T[3], T[2], T[0], T[4]), 7) + ROTR (T[6], 11) + W[14] + 0xB01E8A3EUL;
T[5] = ROTR (F3 (T[0], T[4], T[6], T[2], T[1], T[7], T[3]), 7) + ROTR (T[5], 11) + W[25] + 0xD71577C1UL;
T[4] = ROTR (F3 (T[7], T[3], T[5], T[1], T[0], T[6], T[2]), 7) + ROTR (T[4], 11) + W[12] + 0xBD314B27UL;
T[3] = ROTR (F3 (T[6], T[2], T[4], T[0], T[7], T[5], T[1]), 7) + ROTR (T[3], 11) + W[24] + 0x78AF2FDAUL;
T[2] = ROTR (F3 (T[5], T[1], T[3], T[7], T[6], T[4], T[0]), 7) + ROTR (T[2], 11) + W[30] + 0x55605C60UL;
T[1] = ROTR (F3 (T[4], T[0], T[2], T[6], T[5], T[3], T[7]), 7) + ROTR (T[1], 11) + W[16] + 0xE65525F3UL;
T[0] = ROTR (F3 (T[3], T[7], T[1], T[5], T[4], T[2], T[6]), 7) + ROTR (T[0], 11) + W[26] + 0xAA55AB94UL;
T[7] = ROTR (F3 (T[2], T[6], T[0], T[4], T[3], T[1], T[5]), 7) + ROTR (T[7], 11) + W[31] + 0x57489862UL;
T[6] = ROTR (F3 (T[1], T[5], T[7], T[3], T[2], T[0], T[4]), 7) + ROTR (T[6], 11) + W[15] + 0x63E81440UL;
T[5] = ROTR (F3 (T[0], T[4], T[6], T[2], T[1], T[7], T[3]), 7) + ROTR (T[5], 11) + W[ 7] + 0x55CA396AUL;
T[4] = ROTR (F3 (T[7], T[3], T[5], T[1], T[0], T[6], T[2]), 7) + ROTR (T[4], 11) + W[ 3] + 0x2AAB10B6UL;
T[3] = ROTR (F3 (T[6], T[2], T[4], T[0], T[7], T[5], T[1]), 7) + ROTR (T[3], 11) + W[ 1] + 0xB4CC5C34UL;
T[2] = ROTR (F3 (T[5], T[1], T[3], T[7], T[6], T[4], T[0]), 7) + ROTR (T[2], 11) + W[ 0] + 0x1141E8CEUL;
T[1] = ROTR (F3 (T[4], T[0], T[2], T[6], T[5], T[3], T[7]), 7) + ROTR (T[1], 11) + W[18] + 0xA15486AFUL;
T[0] = ROTR (F3 (T[3], T[7], T[1], T[5], T[4], T[2], T[6]), 7) + ROTR (T[0], 11) + W[27] + 0x7C72E993UL;
T[7] = ROTR (F3 (T[2], T[6], T[0], T[4], T[3], T[1], T[5]), 7) + ROTR (T[7], 11) + W[13] + 0xB3EE1411UL;
T[6] = ROTR (F3 (T[1], T[5], T[7], T[3], T[2], T[0], T[4]), 7) + ROTR (T[6], 11) + W[ 6] + 0x636FBC2AUL;
T[5] = ROTR (F3 (T[0], T[4], T[6], T[2], T[1], T[7], T[3]), 7) + ROTR (T[5], 11) + W[21] + 0x2BA9C55DUL;
T[4] = ROTR (F3 (T[7], T[3], T[5], T[1], T[0], T[6], T[2]), 7) + ROTR (T[4], 11) + W[10] + 0x741831F6UL;
T[3] = ROTR (F3 (T[6], T[2], T[4], T[0], T[7], T[5], T[1]), 7) + ROTR (T[3], 11) + W[23] + 0xCE5C3E16UL;
T[2] = ROTR (F3 (T[5], T[1], T[3], T[7], T[6], T[4], T[0]), 7) + ROTR (T[2], 11) + W[11] + 0x9B87931EUL;
T[1] = ROTR (F3 (T[4], T[0], T[2], T[6], T[5], T[3], T[7]), 7) + ROTR (T[1], 11) + W[ 5] + 0xAFD6BA33UL;
T[0] = ROTR (F3 (T[3], T[7], T[1], T[5], T[4], T[2], T[6]), 7) + ROTR (T[0], 11) + W[ 2] + 0x6C24CF5CUL;
/* PASS 4: */
T[7] = ROTR (F4 (T[1], T[5], T[3], T[2], T[0], T[4], T[6]), 7) + ROTR (T[7], 11) + W[24] + 0x7A325381UL;
T[6] = ROTR (F4 (T[0], T[4], T[2], T[1], T[7], T[3], T[5]), 7) + ROTR (T[6], 11) + W[ 4] + 0x28958677UL;
T[5] = ROTR (F4 (T[7], T[3], T[1], T[0], T[6], T[2], T[4]), 7) + ROTR (T[5], 11) + W[ 0] + 0x3B8F4898UL;
T[4] = ROTR (F4 (T[6], T[2], T[0], T[7], T[5], T[1], T[3]), 7) + ROTR (T[4], 11) + W[14] + 0x6B4BB9AFUL;
T[3] = ROTR (F4 (T[5], T[1], T[7], T[6], T[4], T[0], T[2]), 7) + ROTR (T[3], 11) + W[ 2] + 0xC4BFE81BUL;
T[2] = ROTR (F4 (T[4], T[0], T[6], T[5], T[3], T[7], T[1]), 7) + ROTR (T[2], 11) + W[ 7] + 0x66282193UL;
T[1] = ROTR (F4 (T[3], T[7], T[5], T[4], T[2], T[6], T[0]), 7) + ROTR (T[1], 11) + W[28] + 0x61D809CCUL;
T[0] = ROTR (F4 (T[2], T[6], T[4], T[3], T[1], T[5], T[7]), 7) + ROTR (T[0], 11) + W[23] + 0xFB21A991UL;
T[7] = ROTR (F4 (T[1], T[5], T[3], T[2], T[0], T[4], T[6]), 7) + ROTR (T[7], 11) + W[26] + 0x487CAC60UL;
T[6] = ROTR (F4 (T[0], T[4], T[2], T[1], T[7], T[3], T[5]), 7) + ROTR (T[6], 11) + W[ 6] + 0x5DEC8032UL;
T[5] = ROTR (F4 (T[7], T[3], T[1], T[0], T[6], T[2], T[4]), 7) + ROTR (T[5], 11) + W[30] + 0xEF845D5DUL;
T[4] = ROTR (F4 (T[6], T[2], T[0], T[7], T[5], T[1], T[3]), 7) + ROTR (T[4], 11) + W[20] + 0xE98575B1UL;
T[3] = ROTR (F4 (T[5], T[1], T[7], T[6], T[4], T[0], T[2]), 7) + ROTR (T[3], 11) + W[18] + 0xDC262302UL;
T[2] = ROTR (F4 (T[4], T[0], T[6], T[5], T[3], T[7], T[1]), 7) + ROTR (T[2], 11) + W[25] + 0xEB651B88UL;
T[1] = ROTR (F4 (T[3], T[7], T[5], T[4], T[2], T[6], T[0]), 7) + ROTR (T[1], 11) + W[19] + 0x23893E81UL;
T[0] = ROTR (F4 (T[2], T[6], T[4], T[3], T[1], T[5], T[7]), 7) + ROTR (T[0], 11) + W[ 3] + 0xD396ACC5UL;
T[7] = ROTR (F4 (T[1], T[5], T[3], T[2], T[0], T[4], T[6]), 7) + ROTR (T[7], 11) + W[22] + 0x0F6D6FF3UL;
T[6] = ROTR (F4 (T[0], T[4], T[2], T[1], T[7], T[3], T[5]), 7) + ROTR (T[6], 11) + W[11] + 0x83F44239UL;
T[5] = ROTR (F4 (T[7], T[3], T[1], T[0], T[6], T[2], T[4]), 7) + ROTR (T[5], 11) + W[31] + 0x2E0B4482UL;
T[4] = ROTR (F4 (T[6], T[2], T[0], T[7], T[5], T[1], T[3]), 7) + ROTR (T[4], 11) + W[21] + 0xA4842004UL;
T[3] = ROTR (F4 (T[5], T[1], T[7], T[6], T[4], T[0], T[2]), 7) + ROTR (T[3], 11) + W[ 8] + 0x69C8F04AUL;
T[2] = ROTR (F4 (T[4], T[0], T[6], T[5], T[3], T[7], T[1]), 7) + ROTR (T[2], 11) + W[27] + 0x9E1F9B5EUL;
T[1] = ROTR (F4 (T[3], T[7], T[5], T[4], T[2], T[6], T[0]), 7) + ROTR (T[1], 11) + W[12] + 0x21C66842UL;
T[0] = ROTR (F4 (T[2], T[6], T[4], T[3], T[1], T[5], T[7]), 7) + ROTR (T[0], 11) + W[ 9] + 0xF6E96C9AUL;
T[7] = ROTR (F4 (T[1], T[5], T[3], T[2], T[0], T[4], T[6]), 7) + ROTR (T[7], 11) + W[ 1] + 0x670C9C61UL;
T[6] = ROTR (F4 (T[0], T[4], T[2], T[1], T[7], T[3], T[5]), 7) + ROTR (T[6], 11) + W[29] + 0xABD388F0UL;
T[5] = ROTR (F4 (T[7], T[3], T[1], T[0], T[6], T[2], T[4]), 7) + ROTR (T[5], 11) + W[ 5] + 0x6A51A0D2UL;
T[4] = ROTR (F4 (T[6], T[2], T[0], T[7], T[5], T[1], T[3]), 7) + ROTR (T[4], 11) + W[15] + 0xD8542F68UL;
T[3] = ROTR (F4 (T[5], T[1], T[7], T[6], T[4], T[0], T[2]), 7) + ROTR (T[3], 11) + W[17] + 0x960FA728UL;
T[2] = ROTR (F4 (T[4], T[0], T[6], T[5], T[3], T[7], T[1]), 7) + ROTR (T[2], 11) + W[10] + 0xAB5133A3UL;
T[1] = ROTR (F4 (T[3], T[7], T[5], T[4], T[2], T[6], T[0]), 7) + ROTR (T[1], 11) + W[16] + 0x6EEF0B6CUL;
T[0] = ROTR (F4 (T[2], T[6], T[4], T[3], T[1], T[5], T[7]), 7) + ROTR (T[0], 11) + W[13] + 0x137A3BE4UL;
/* PASS 5: */
T[7] = ROTR (F5 (T[2], T[5], T[0], T[6], T[4], T[3], T[1]), 7) + ROTR (T[7], 11) + W[27] + 0xBA3BF050UL;
T[6] = ROTR (F5 (T[1], T[4], T[7], T[5], T[3], T[2], T[0]), 7) + ROTR (T[6], 11) + W[ 3] + 0x7EFB2A98UL;
T[5] = ROTR (F5 (T[0], T[3], T[6], T[4], T[2], T[1], T[7]), 7) + ROTR (T[5], 11) + W[21] + 0xA1F1651DUL;
T[4] = ROTR (F5 (T[7], T[2], T[5], T[3], T[1], T[0], T[6]), 7) + ROTR (T[4], 11) + W[26] + 0x39AF0176UL;
T[3] = ROTR (F5 (T[6], T[1], T[4], T[2], T[0], T[7], T[5]), 7) + ROTR (T[3], 11) + W[17] + 0x66CA593EUL;
T[2] = ROTR (F5 (T[5], T[0], T[3], T[1], T[7], T[6], T[4]), 7) + ROTR (T[2], 11) + W[11] + 0x82430E88UL;
T[1] = ROTR (F5 (T[4], T[7], T[2], T[0], T[6], T[5], T[3]), 7) + ROTR (T[1], 11) + W[20] + 0x8CEE8619UL;
T[0] = ROTR (F5 (T[3], T[6], T[1], T[7], T[5], T[4], T[2]), 7) + ROTR (T[0], 11) + W[29] + 0x456F9FB4UL;
T[7] = ROTR (F5 (T[2], T[5], T[0], T[6], T[4], T[3], T[1]), 7) + ROTR (T[7], 11) + W[19] + 0x7D84A5C3UL;
T[6] = ROTR (F5 (T[1], T[4], T[7], T[5], T[3], T[2], T[0]), 7) + ROTR (T[6], 11) + W[ 0] + 0x3B8B5EBEUL;
T[5] = ROTR (F5 (T[0], T[3], T[6], T[4], T[2], T[1], T[7]), 7) + ROTR (T[5], 11) + W[12] + 0xE06F75D8UL;
T[4] = ROTR (F5 (T[7], T[2], T[5], T[3], T[1], T[0], T[6]), 7) + ROTR (T[4], 11) + W[ 7] + 0x85C12073UL;
T[3] = ROTR (F5 (T[6], T[1], T[4], T[2], T[0], T[7], T[5]), 7) + ROTR (T[3], 11) + W[13] + 0x401A449FUL;
T[2] = ROTR (F5 (T[5], T[0], T[3], T[1], T[7], T[6], T[4]), 7) + ROTR (T[2], 11) + W[ 8] + 0x56C16AA6UL;
T[1] = ROTR (F5 (T[4], T[7], T[2], T[0], T[6], T[5], T[3]), 7) + ROTR (T[1], 11) + W[31] + 0x4ED3AA62UL;
T[0] = ROTR (F5 (T[3], T[6], T[1], T[7], T[5], T[4], T[2]), 7) + ROTR (T[0], 11) + W[10] + 0x363F7706UL;
T[7] = ROTR (F5 (T[2], T[5], T[0], T[6], T[4], T[3], T[1]), 7) + ROTR (T[7], 11) + W[ 5] + 0x1BFEDF72UL;
T[6] = ROTR (F5 (T[1], T[4], T[7], T[5], T[3], T[2], T[0]), 7) + ROTR (T[6], 11) + W[ 9] + 0x429B023DUL;
T[5] = ROTR (F5 (T[0], T[3], T[6], T[4], T[2], T[1], T[7]), 7) + ROTR (T[5], 11) + W[14] + 0x37D0D724UL;
T[4] = ROTR (F5 (T[7], T[2], T[5], T[3], T[1], T[0], T[6]), 7) + ROTR (T[4], 11) + W[30] + 0xD00A1248UL;
T[3] = ROTR (F5 (T[6], T[1], T[4], T[2], T[0], T[7], T[5]), 7) + ROTR (T[3], 11) + W[18] + 0xDB0FEAD3UL;
T[2] = ROTR (F5 (T[5], T[0], T[3], T[1], T[7], T[6], T[4]), 7) + ROTR (T[2], 11) + W[ 6] + 0x49F1C09BUL;
T[1] = ROTR (F5 (T[4], T[7], T[2], T[0], T[6], T[5], T[3]), 7) + ROTR (T[1], 11) + W[28] + 0x075372C9UL;
T[0] = ROTR (F5 (T[3], T[6], T[1], T[7], T[5], T[4], T[2]), 7) + ROTR (T[0], 11) + W[24] + 0x80991B7BUL;
E[7] += T[7] = ROTR (F5 (T[2], T[5], T[0], T[6], T[4], T[3], T[1]), 7) + ROTR (T[7], 11) + W[ 2] + 0x25D479D8UL;
E[6] += T[6] = ROTR (F5 (T[1], T[4], T[7], T[5], T[3], T[2], T[0]), 7) + ROTR (T[6], 11) + W[23] + 0xF6E8DEF7UL;
E[5] += T[5] = ROTR (F5 (T[0], T[3], T[6], T[4], T[2], T[1], T[7]), 7) + ROTR (T[5], 11) + W[16] + 0xE3FE501AUL;
E[4] += T[4] = ROTR (F5 (T[7], T[2], T[5], T[3], T[1], T[0], T[6]), 7) + ROTR (T[4], 11) + W[22] + 0xB6794C3BUL;
E[3] += T[3] = ROTR (F5 (T[6], T[1], T[4], T[2], T[0], T[7], T[5]), 7) + ROTR (T[3], 11) + W[ 4] + 0x976CE0BDUL;
E[2] += T[2] = ROTR (F5 (T[5], T[0], T[3], T[1], T[7], T[6], T[4]), 7) + ROTR (T[2], 11) + W[ 1] + 0x04C006BAUL;
E[1] += T[1] = ROTR (F5 (T[4], T[7], T[2], T[0], T[6], T[5], T[3]), 7) + ROTR (T[1], 11) + W[25] + 0xC1A94FB6UL;
E[0] += T[0] = ROTR (F5 (T[3], T[6], T[1], T[7], T[5], T[4], T[2]), 7) + ROTR (T[0], 11) + W[15] + 0x409F60C4UL;
#if defined(WORDS_BIGENDIAN)
mutils_free(W);
#endif
} /* havalTransform5 */
mutils_error havalInit256( havalContext *hcp) {
return havalInit(hcp, 3, 256);
}
mutils_error havalInit224( havalContext *hcp) {
return havalInit(hcp, 3, 224);
}
mutils_error havalInit192( havalContext *hcp) {
return havalInit(hcp, 3, 192);
}
mutils_error havalInit160( havalContext *hcp) {
return havalInit(hcp, 3, 160);
}
mutils_error havalInit128( havalContext *hcp) {
return havalInit(hcp, 3, 128);
}
mutils_error havalInit (havalContext *hcp, mutils_word32 passes, mutils_word32 hashLength)
{
if (hcp == NULL)
{
return(-MUTILS_INVALID_INPUT_BUFFER); /* bad context */
}
/* check number of passes: */
if (passes != 3 && passes != 4 && passes != 5)
{
return(-MUTILS_INVALID_PASSES); /* invalid number of passes */
}
/* check hash length: */
if (hashLength != 128 &&
hashLength != 160 &&
hashLength != 192 &&
hashLength != 224 &&
hashLength != 256)
{
return(-MUTILS_INVALID_SIZE); /* invalid hash length */
}
/* properly initialize HAVAL context: */
mutils_bzero(hcp, sizeof (havalContext));
hcp->passes = (mutils_word16) passes;
hcp->hashLength = (mutils_word16) hashLength;
hcp->digest[0] = 0x243F6A88UL;
hcp->digest[1] = 0x85A308D3UL;
hcp->digest[2] = 0x13198A2EUL;
hcp->digest[3] = 0x03707344UL;
hcp->digest[4] = 0xA4093822UL;
hcp->digest[5] = 0x299F31D0UL;
hcp->digest[6] = 0x082EFA98UL;
hcp->digest[7] = 0xEC4E6C89UL;
return(MUTILS_OK); /* OK */
} /* havalInit */
mutils_error havalUpdate (havalContext *hcp, __const mutils_word8 *dataBuffer, mutils_word32 dataLength)
{
if (hcp == NULL)
{
return(-MUTILS_INVALID_INPUT_BUFFER); /* bad context */
}
if (dataBuffer == NULL || dataLength == 0)
{
return(MUTILS_OK); /* nothing to do */
}
/* update bit count: Extra parentheses for Borland C++ --Tines*/
if ( ((mutils_word32)dataLength << 3) > (0xFFFFFFFFUL - hcp->bitCount[0]) )
{
hcp->bitCount[1]++;
}
hcp->bitCount[0] += (mutils_word32)dataLength << 3;
/* if the data buffer is not enough to complete */
/* the context data block, just append it: */
if (hcp->occupied + (mutils_word32)dataLength < 128)
{ /* caveat: typecast avoids 16-bit overflow */
mutils_memcpy (&hcp->block[hcp->occupied], dataBuffer, dataLength);
hcp->occupied += dataLength;
return(MUTILS_OK); /* delay processing */
}
/* complete the context data block: */
mutils_memcpy (&hcp->block[hcp->occupied], dataBuffer, 128 - hcp->occupied);
dataBuffer += 128 - hcp->occupied;
dataLength -= 128 - hcp->occupied;
switch (hcp->passes) {
case 3:
/* process the completed context data block: */
havalTransform3 (hcp->digest, (mutils_word32 *) (hcp->block), hcp->temp);
/* process data in chunks of 128 bytes: */
while (dataLength >= 128)
{
havalTransform3 (hcp->digest, (mutils_word32 *) dataBuffer, hcp->temp);
dataBuffer += 128;
dataLength -= 128;
}
break;
case 4:
/* process the completed context data block: */
havalTransform4 (hcp->digest, (mutils_word32 *) (hcp->block), hcp->temp);
/* process data in chunks of 128 bytes: */
while (dataLength >= 128)
{
havalTransform4 (hcp->digest, (mutils_word32 *) dataBuffer, hcp->temp);
dataBuffer += 128;
dataLength -= 128;
}
break;
case 5:
/* process the completed context data block: */
havalTransform5 (hcp->digest, (mutils_word32 *) (hcp->block), hcp->temp);
/* process data in chunks of 128 bytes: */
while (dataLength >= 128)
{
havalTransform5 (hcp->digest, (mutils_word32 *) dataBuffer, hcp->temp);
dataBuffer += 128;
dataLength -= 128;
}
break;
}
/* delay processing of remaining data: */
mutils_memcpy (hcp->block, dataBuffer, dataLength);
hcp->occupied = dataLength; /* < 128 */
return(MUTILS_OK); /* OK */
} /* havalUpdate */
mutils_error havalFinal (havalContext *hcp, mutils_word8 *digest)
{
mutils_word32 w;
if (hcp == NULL)
{
return(-MUTILS_INVALID_INPUT_BUFFER); /* bad context */
}
if (digest == NULL)
{
return(-MUTILS_INVALID_OUTPUT_BUFFER); /* bad digest buffer */
}
/* assert (hcp->occupied < 128); invariant */
/* append toggle to the context data block: */
hcp->block[hcp->occupied] = 0x01; /* corrected from 0x80 */
/* pad the message with null bytes to make it 944 (mod 1024) bits long: */
if (hcp->occupied++ >= 118)
{
/* no room for tail data on the current context block */
mutils_bzero (&hcp->block[hcp->occupied], 128 - hcp->occupied);
/* process the completed context data block: */
switch (hcp->passes) {
case 3:
havalTransform3 (hcp->digest, (mutils_word32 *) (hcp->block), hcp->temp);
break;
case 4:
havalTransform4 (hcp->digest, (mutils_word32 *) (hcp->block), hcp->temp);
break;
case 5:
havalTransform5 (hcp->digest, (mutils_word32 *) (hcp->block), hcp->temp);
break;
}
mutils_bzero (hcp->block, 118);
}
else
{
mutils_bzero (&hcp->block[hcp->occupied], 118 - hcp->occupied);
}
/* append tail data and process last (padded) message block: */
hcp->block[118] = (mutils_word8)(
((hcp->hashLength & 0x03U) << 6) |
((hcp->passes & 0x07U) << 3) |
(HAVAL_VERSION & 0x07U));
hcp->block[119] = (mutils_word8) (hcp->hashLength >> 2);
w = hcp->bitCount[0];
hcp->block[120] = (mutils_word8)(w);
hcp->block[121] = (mutils_word8)(w >> 8);
hcp->block[122] = (mutils_word8)(w >> 16);
hcp->block[123] = (mutils_word8)(w >> 24);
w = hcp->bitCount[1];
hcp->block[124] = (mutils_word8)(w);
hcp->block[125] = (mutils_word8)(w >> 8);
hcp->block[126] = (mutils_word8)(w >> 16);
hcp->block[127] = (mutils_word8)(w >> 24);
switch (hcp->passes)
{
case 3:
havalTransform3 (hcp->digest, (mutils_word32 *) (hcp->block), hcp->temp);
break;
case 4:
havalTransform4 (hcp->digest, (mutils_word32 *) (hcp->block), hcp->temp);
break;
case 5:
havalTransform5 (hcp->digest, (mutils_word32 *) (hcp->block), hcp->temp);
break;
}
/* fold 256-bit digest to fit the desired hash length (blaargh!): */
/* Byte reverse each 32-bit section while outputting if big-endian -- Tines*/
switch (hcp->hashLength)
{
case 128:
hcp->digest[3] +=
( (hcp->digest[7] & 0xFF000000UL)
| (hcp->digest[6] & 0x00FF0000UL)
| (hcp->digest[5] & 0x0000FF00UL)
| (hcp->digest[4] & 0x000000FFUL)
);
hcp->digest[2] +=
(((hcp->digest[7] & 0x00FF0000UL)
| (hcp->digest[6] & 0x0000FF00UL)
| (hcp->digest[5] & 0x000000FFUL)
) << 8) |
( (hcp->digest[4] & 0xFF000000UL) >> 24);
hcp->digest[1] +=
(((hcp->digest[7] & 0x0000FF00UL)
| (hcp->digest[6] & 0x000000FFUL)) << 16) |
(((hcp->digest[5] & 0xFF000000UL)
| (hcp->digest[4] & 0x00FF0000UL)) >> 16);
hcp->digest[0] +=
(((hcp->digest[6] & 0xFF000000UL)
| (hcp->digest[5] & 0x00FF0000UL)
| (hcp->digest[4] & 0x0000FF00UL)
) >> 8) |
( (hcp->digest[7] & 0x000000FFUL) << 24);
#if defined(WORDS_BIGENDIAN)
mutils_word32nswap((mutils_word32 *) (hcp->digest), 128/32, MUTILS_TRUE);
#endif
mutils_memcpy(digest, hcp->digest, 128/8);
break;
case 160:
hcp->digest[4] +=
((hcp->digest[7] & 0xFE000000UL) | (hcp->digest[6] & 0x01F80000UL) | (hcp->digest[5] & 0x0007F000UL)) >> 12;
hcp->digest[3] +=
((hcp->digest[7] & 0x01F80000UL) | (hcp->digest[6] & 0x0007F000UL) | (hcp->digest[5] & 0x00000FC0UL)) >> 6;
hcp->digest[2] +=
((hcp->digest[7] & 0x0007F000UL) | (hcp->digest[6] & 0x00000FC0UL) | (hcp->digest[5] & 0x0000003FUL));
hcp->digest[1] +=
ROTR
((hcp->digest[7] & 0x00000FC0UL) | (hcp->digest[6] & 0x0000003FUL) | (hcp->digest[5] & 0xFE000000UL), 25);
hcp->digest[0] +=
ROTR
((hcp->digest[7] & 0x0000003FUL) | (hcp->digest[6] & 0xFE000000UL) | (hcp->digest[5] & 0x01F80000UL), 19);
#if defined(WORDS_BIGENDIAN)
mutils_word32nswap((mutils_word32 *) (hcp->digest), 160/32, MUTILS_TRUE);
#endif
mutils_memcpy (digest, hcp->digest, 160/8);
break;
case 192:
hcp->digest[5] +=
((hcp->digest[7] & 0xFC000000UL) | (hcp->digest[6] & 0x03E00000UL)) >> 21;
hcp->digest[4] +=
((hcp->digest[7] & 0x03E00000UL) | (hcp->digest[6] & 0x001F0000UL)) >> 16;
hcp->digest[3] +=
((hcp->digest[7] & 0x001F0000UL) | (hcp->digest[6] & 0x0000FC00UL)) >> 10;
hcp->digest[2] +=
((hcp->digest[7] & 0x0000FC00UL) | (hcp->digest[6] & 0x000003E0UL)) >> 5;
hcp->digest[1] +=
((hcp->digest[7] & 0x000003E0UL) | (hcp->digest[6] & 0x0000001FUL));
hcp->digest[0] +=
ROTR
((hcp->digest[7] & 0x0000001FUL) | (hcp->digest[6] & 0xFC000000UL), 26);
#if defined(WORDS_BIGENDIAN)
mutils_word32nswap((mutils_word32 *) (hcp->digest), 192/32, MUTILS_TRUE);
#endif
mutils_memcpy (digest, hcp->digest, 192/8);
break;
case 224:
hcp->digest[6] += (hcp->digest[7] ) & 0x0000000FUL;
hcp->digest[5] += (hcp->digest[7] >> 4) & 0x0000001FUL;
hcp->digest[4] += (hcp->digest[7] >> 9) & 0x0000000FUL;
hcp->digest[3] += (hcp->digest[7] >> 13) & 0x0000001FUL;
hcp->digest[2] += (hcp->digest[7] >> 18) & 0x0000000FUL;
hcp->digest[1] += (hcp->digest[7] >> 22) & 0x0000001FUL;
hcp->digest[0] += (hcp->digest[7] >> 27) & 0x0000001FUL;
#if defined(WORDS_BIGENDIAN)
mutils_word32nswap((mutils_word32 *) (hcp->digest), 224/32, MUTILS_TRUE);
#endif
mutils_memcpy (digest, hcp->digest, 224/8);
break;
case 256:
#if defined(WORDS_BIGENDIAN)
mutils_word32nswap((mutils_word32 *) (hcp->digest), 256/32, MUTILS_TRUE);
#endif
mutils_memcpy (digest, hcp->digest, 256/8);
break;
}
/* destroy sensitive information: */
mutils_bzero (hcp, sizeof (havalContext));
return(MUTILS_OK); /* OK */
} /* havalFinal */
#endif /* ENABLE_HAVAL */
@@ -0,0 +1,223 @@
/*
* Copyright (C) 1998 Nikos Mavroyanopoulos
* Copyright (C) 1999,2000,2001 Sascha Schumman, 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.
*/
#define KEYGEN_INTERNALS
#include <libdefs.h>
#include <mhash_int.h>
#include <keygen.h>
WIN32DLL_DEFINE
mutils_boolean mhash_keygen_uses_hash_algorithm(keygenid type)
{
mutils_boolean ret = MUTILS_FALSE;
KEYGEN_ALG_LOOP(ret = p->uses_hash_algorithm);
return(ret);
}
WIN32DLL_DEFINE
mutils_boolean mhash_keygen_uses_count(keygenid type)
{
mutils_boolean ret = MUTILS_FALSE;
KEYGEN_ALG_LOOP(ret = p->uses_count);
return(ret);
}
WIN32DLL_DEFINE
mutils_boolean mhash_keygen_uses_salt(keygenid type)
{
mutils_boolean ret = MUTILS_FALSE;
KEYGEN_ALG_LOOP(ret = p->uses_salt);
return(ret);
}
#ifndef MMAX
# define MMAX(x,y) (x>y?x:y)
#endif
WIN32DLL_DEFINE
mutils_word32 mhash_keygen_count(void)
{
keygenid count = 0;
KEYGEN_LOOP(count = MMAX(p->id, count) );
return(count);
}
WIN32DLL_DEFINE
mutils_word32 mhash_get_keygen_salt_size(keygenid type)
{
mutils_word32 ret = 0;
KEYGEN_ALG_LOOP(ret = p->salt_size);
return(ret);
}
WIN32DLL_DEFINE
mutils_word32 mhash_get_keygen_max_key_size(keygenid type)
{
mutils_word32 ret = 0;
KEYGEN_ALG_LOOP(ret = p->max_key_size);
return(ret);
}
WIN32DLL_DEFINE
mutils_word8 *mhash_get_keygen_name(hashid type)
{
mutils_word8 *ret = NULL;
/* avoid prefix */
KEYGEN_ALG_LOOP(ret = p->name);
if (ret != NULL)
ret += sizeof("KEYGEN_") - 1;
return(mutils_strdup(ret));
}
WIN32DLL_DEFINE
__const mutils_word8 *mhash_get_keygen_name_static(hashid type)
{
mutils_word8 *ret = NULL;
/* avoid prefix */
KEYGEN_ALG_LOOP(ret = p->name);
if (ret != NULL)
ret += sizeof("KEYGEN_") - 1;
return(ret);
}
WIN32DLL_DEFINE
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 x;
switch (algorithm) {
case KEYGEN_MCRYPT:
x=_mhash_gen_key_mcrypt(opt_algorithm,
keyword, keysize,
salt, saltsize,
password, passwordlen);
break;
case KEYGEN_ASIS:
x=_mhash_gen_key_asis(keyword, keysize,
password, passwordlen);
break;
case KEYGEN_PKDES:
x=_mhash_gen_key_pkdes(keyword, keysize,
password, passwordlen);
break;
case KEYGEN_HEX:
x=_mhash_gen_key_hex(keyword, keysize,
password, passwordlen);
break;
case KEYGEN_S2K_SIMPLE:
x=_mhash_gen_key_s2k_simple(opt_algorithm,
keyword, keysize,
password, passwordlen);
break;
case KEYGEN_S2K_SALTED:
x=_mhash_gen_key_s2k_salted(opt_algorithm,
keyword, keysize,
salt, saltsize,
password, passwordlen);
break;
case KEYGEN_S2K_ISALTED:
x=_mhash_gen_key_s2k_isalted(opt_algorithm, count,
keyword, keysize,
salt, saltsize,
password, passwordlen);
break;
default:
return(-MUTILS_INVALID_FUNCTION);
}
return(x);
}
WIN32DLL_DEFINE
mutils_error mhash_keygen_ext(keygenid algorithm, KEYGEN data,
void *keyword, mutils_word32 keysize,
mutils_word8 *password, mutils_word32 passwordlen)
{
mutils_error x;
hashid opt_algorithm = data.hash_algorithm[0];
mutils_word64 count = data.count;
void *salt = data.salt;
mutils_word32 saltsize = data.salt_size;
switch (algorithm) {
case KEYGEN_MCRYPT:
x=_mhash_gen_key_mcrypt(opt_algorithm,
keyword, keysize,
salt, saltsize,
password, passwordlen);
break;
case KEYGEN_ASIS:
x=_mhash_gen_key_asis(keyword, keysize,
password, passwordlen);
break;
case KEYGEN_PKDES:
x=_mhash_gen_key_pkdes(keyword, keysize,
password, passwordlen);
break;
case KEYGEN_HEX:
x=_mhash_gen_key_hex(keyword, keysize,
password, passwordlen);
break;
case KEYGEN_S2K_SIMPLE:
x=_mhash_gen_key_s2k_simple(opt_algorithm,
keyword, keysize,
password, passwordlen);
break;
case KEYGEN_S2K_SALTED:
x=_mhash_gen_key_s2k_salted(opt_algorithm,
keyword, keysize,
salt, saltsize,
password, passwordlen);
break;
case KEYGEN_S2K_ISALTED:
x=_mhash_gen_key_s2k_isalted(opt_algorithm, count,
keyword, keysize,
salt, saltsize,
password, passwordlen);
break;
default:
return(-MUTILS_INVALID_FUNCTION);
}
return(x);
}
@@ -0,0 +1,85 @@
#if !defined(__KEYGEN_H)
#define __KEYGEN_H
#include <mutils/mhash_config.h>
#include <mutils/mglobal.h>
#if defined(PROTOTYPES)
mutils_error _mhash_gen_key_asis(void *keyword, mutils_word32 key_size,
mutils_word8 *password, mutils_word32 plen);
mutils_error _mhash_gen_key_mcrypt(hashid algorithm,
void *keyword, mutils_word32 key_size,
void *salt, mutils_word32 salt_size,
mutils_word8 *password, mutils_word32 plen);
mutils_error _mhash_gen_key_hex(void *keyword, mutils_word32 key_size,
mutils_word8 *password, mutils_word32 plen);
mutils_error _mhash_gen_key_s2k_simple(hashid algorithm,
void *keyword, mutils_word32 key_size,
mutils_word8 *password, mutils_word32 plen);
mutils_error _mhash_gen_key_s2k_salted(hashid algorithm,
void *keyword, mutils_word32 key_size,
mutils_word8 *salt, mutils_word32 salt_size,
mutils_word8 *password, mutils_word32 plen);
mutils_error _mhash_gen_key_s2k_isalted(hashid algorithm, mutils_word64 count,
void *keyword, mutils_word32 key_size,
mutils_word8 *salt, mutils_word32 salt_size,
mutils_word8 *password, mutils_word32 plen);
mutils_error _mhash_gen_key_pkdes(void *keyword, mutils_word32 key_size,
mutils_word8 *password, mutils_word32 plen);
mutils_error _mhash_gen_key_crypt(void *keyword, mutils_word32 key_size,
mutils_word8 *password, mutils_word32 plen,
void *salt, mutils_word32 salt_size);
mutils_error _mhash_gen_key_scrypt(void *keyword, mutils_word32 key_size,
mutils_word8 *password, mutils_word32 plen);
#else
mutils_error _mhash_gen_key_asis();
mutils_error _mhash_gen_key_mcrypt();
mutils_error _mhash_gen_key_hex();
mutils_error _mhash_gen_key_s2k_simple();
mutils_error _mhash_gen_key_s2k_salted();
mutils_error _mhash_gen_key_s2k_isalted();
mutils_error _mhash_gen_key_pkdes();
mutils_error _mhash_gen_key_crypt();
mutils_error _mhash_gen_key_scrypt();
#endif
#if defined(KEYGEN_INTERNALS)
#define KEYGEN_ENTRY(name, uses_hash_algorithm, uses_count, uses_salt, salt_size, max_key_size) \
{ (mutils_word8 *) #name, name, uses_hash_algorithm, uses_count, uses_salt, salt_size, max_key_size }
typedef struct __mhash_keygen_entry {
mutils_word8 *name;
keygenid id;
mutils_boolean uses_hash_algorithm;
mutils_boolean uses_count;
mutils_boolean uses_salt;
mutils_word32 salt_size;
mutils_word32 max_key_size;
} mhash_keygen_entry;
static __const mhash_keygen_entry keygen_algorithms[] = {
KEYGEN_ENTRY(KEYGEN_ASIS, 0, 0, 0, 0, 0),
KEYGEN_ENTRY(KEYGEN_PKDES, 0, 0, 0, 0, 0),
KEYGEN_ENTRY(KEYGEN_HEX, 0, 0, 0, 0, 0),
KEYGEN_ENTRY(KEYGEN_MCRYPT, 1, 0, 1, 0, 0),
KEYGEN_ENTRY(KEYGEN_S2K_SIMPLE, 1, 0, 0, 0, 0),
KEYGEN_ENTRY(KEYGEN_S2K_SALTED, 1, 0, 1, 8, 0),
KEYGEN_ENTRY(KEYGEN_S2K_ISALTED, 1, 1, 1, 8, 0),
{0}
};
#define KEYGEN_LOOP(b) \
__const mhash_keygen_entry *p; \
for (p = keygen_algorithms; p->name != NULL; p++) { b ; }
#define KEYGEN_ALG_LOOP(a) \
KEYGEN_LOOP(if (p->id == type) { a; break; } )
#endif
#endif
@@ -0,0 +1,38 @@
/*
* Copyright (C) 1998 Nikos Mavroyanopoulos
* Copyright (C) 1999,2000 Sascha Schumman, 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.
*/
#include <libdefs.h>
mutils_error _mhash_gen_key_asis(void *keyword, mutils_word32 key_size, mutils_word8 *password, mutils_word32 plen)
{
#if defined(MHASH_ROBUST)
if ((keyword == NULL) || (key_size == 0) ||
(password == NULL) || (plen == 0))
return(-MUTILS_INVALID_SIZE);
#endif
if (plen > key_size)
plen=key_size;
mutils_bzero(keyword, key_size);
mutils_memcpy(keyword, password, plen);
return(MUTILS_OK);
}
@@ -0,0 +1,91 @@
/*
* Copyright (C) 1998,2002 Nikos Mavroyanopoulos
* Copyright (C) 1999,2000 Sascha Schumman, 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.
*/
#include "libdefs.h"
#ifdef WIN32
/* Provided by Stefan Hetzl <shetzl@chello.at>
* in order for isxdigit to work on cygwin.
*/
static char hexdigits[] = { '0', '1', '2', '3', '4',
'5', '6', '7', '8', '9',
'a', 'b', 'c', 'd', 'e', 'f',
'A', 'B', 'C', 'D', 'E', 'F' } ;
static mutils_boolean ishexdigit (mutils_word8 d)
{
mutils_word8 i;
for (i = 0; i < 22 ; i++)
if (d == hexdigits[i])
return(MUTILS_TRUE);
return(MUTILS_FALSE);
}
#else
# include <ctype.h>
# define ishexdigit isxdigit
#endif
static mutils_boolean check_hex(mutils_word8 *given_chain, mutils_word32 len)
{
mutils_word8 i;
for (i = 0; i < len; i++)
if (ishexdigit(given_chain[i]) == MUTILS_FALSE)
return(MUTILS_FALSE);
return(MUTILS_TRUE);
}
mutils_error _mhash_gen_key_hex(void *keyword, mutils_word32 key_size,
mutils_word8 *password, mutils_word32 plen)
{
mutils_word8 *chain = password;
mutils_word8 *pkeyword = keyword;
mutils_word8 tmp[3];
mutils_word32 i;
mutils_bzero(keyword, key_size);
/* The chain should have 2*n characters
*/
if (plen % 2 != 0 || plen > key_size*2)
return(-MUTILS_INVALID_SIZE);
if (check_hex(chain, plen) == MUTILS_FALSE)
return(-MUTILS_INVALID_FORMAT);
mutils_bzero( keyword, key_size);
for (i = 0; i < plen; i += 2) {
mutils_memcpy(tmp, &chain[i], 2);
tmp[2] = '\0';
pkeyword[i / 2] = mutils_strtol(tmp, (mutils_word8 **) NULL, 16);
}
return(MUTILS_OK);
}
@@ -0,0 +1,121 @@
/*
* Copyright (C) 1998 Nikos Mavroyanopoulos
* Copyright (C) 1999,2000 Sascha Schumman, 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.
*/
#define MUTILS_USE_MHASH_CONFIG
#include <mhash.h>
#include <libdefs.h>
#include <keygen.h>
/* Key generation using any hash algorithm */
mutils_error _mhash_gen_key_mcrypt(hashid algorithm,
void *keyword, mutils_word32 key_size,
void *salt, mutils_word32 salt_size,
mutils_word8 *password, mutils_word32 plen)
{
mutils_word8 *key = mutils_malloc(key_size);
mutils_word8 *digest = NULL;
mutils_word32 size = key_size;
MHASH td;
mutils_word8 *cp = key, *cp0 = key;
mutils_boolean salt_z = MUTILS_TRUE; /* flag to be used when freeing salt[] */
mutils_word32 block_size = mhash_get_block_size(algorithm);
#if defined(MHASH_ROBUST)
if (key == NULL)
return(-MUTILS_SYSTEM_RESOURCE_ERROR);
#endif
mutils_bzero(key, key_size);
if (salt == NULL) {
salt_z = MUTILS_FALSE;
}
while (1) {
td = mhash_init(algorithm);
if (td == MHASH_FAILED)
return(-MUTILS_INVALID_FUNCTION);
if (salt_z == MUTILS_TRUE)
mhash(td, salt, salt_size);
mhash(td, password, plen);
if (cp - cp0 > 0)
mhash(td, cp0, cp - cp0);
digest = mhash_end(td);
#if defined(MHASH_ROBUST)
if (digest == NULL)
return(-MUTILS_INVALID_RESULT);
#endif
if (size > block_size) {
mutils_memcpy(cp, digest, block_size);
mutils_free(digest);
size -= block_size;
cp += block_size;
} else {
mutils_memcpy(cp, digest, size);
mutils_free(digest);
break;
}
}
mutils_memcpy(keyword, key, key_size);
mutils_free(key);
return(MUTILS_OK);
}
mutils_error _mhash_gen_key_pkdes(void *keyword, mutils_word32 key_size,
mutils_word8 *password, mutils_word32 plen)
{
mutils_word8 *ptr = keyword;
mutils_word32 cnt;
mutils_word32 i;
mutils_word32 c;
#if defined(MHASH_ROBUST)
if (keyword == NULL)
return(-MUTILS_SYSTEM_RESOURCE_ERROR);
#endif
if (plen > key_size)
return(-MUTILS_INVALID_SIZE);
mutils_bzero(keyword, key_size);
mutils_memcpy(keyword, password, plen);
for (cnt = 0; cnt < key_size; cnt++, ptr++) {
c = 0;
for (i = 0; i < 7; i++)
if (*ptr & (1 << i))
c++;
if ((c & 1) == 0)
*ptr |= 0x80;
else
*ptr &= ~0x80;
}
return(MUTILS_OK);
}
@@ -0,0 +1,260 @@
/*
* Copyright (C) 1998 Nikos Mavroyanopoulos
* Copyright (C) 1999,2000 Sascha Schumman, Nikos Mavroyanopoulos
* Copyright (C) 2002 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.
*/
#include "libdefs.h"
#include "keygen.h"
#include <mhash.h>
#define MAX_DIGEST_SIZE 40
/* Key generation using OpenPGP Simple S2K algorithm */
mutils_error _mhash_gen_key_s2k_simple(hashid algorithm,
void *keyword, mutils_word32 key_size,
mutils_word8 *password, mutils_word32 plen)
{
mutils_word8* key;
mutils_word8 digest[MAX_DIGEST_SIZE];
char null = '\0';
mutils_word32 i,j, times, total;
MHASH td;
mutils_word32 block_size = mhash_get_block_size(algorithm);
/* This should never happen, so naturally it is bound to. */
if (block_size == 0)
{
errno = EINVAL;
return(-MUTILS_INVALID_SIZE);
}
times = key_size / block_size;
if (key_size % block_size != 0)
{
times++;
}
total = times * block_size;
key = mutils_malloc(total);
if (key == NULL)
{
return(-MUTILS_SYSTEM_RESOURCE_ERROR); /* or what? */
}
mutils_bzero(key, total);
for (i = 0; i < times; i++) {
td = mhash_init(algorithm);
if (td == MHASH_FAILED) {
mutils_free(key);
return(-MUTILS_INVALID_FUNCTION);
}
for (j = 0; j < i; j++)
{
mhash(td, &null, 1);
}
mhash(td, password, plen);
mhash_deinit(td, digest);
mutils_memcpy(&key[i * block_size], digest, block_size);
}
mutils_memcpy(keyword, key, key_size);
mutils_bzero(key, key_size);
mutils_free(key);
return(MUTILS_OK);
}
/* Key generation using OpenPGP Salted S2K algorithm */
mutils_error _mhash_gen_key_s2k_salted(hashid algorithm,
void *keyword, mutils_word32 key_size,
mutils_word8 *salt, mutils_word32 salt_size,
mutils_word8 *password, mutils_word32 plen)
{
mutils_word8 *key;
mutils_word8 digest[MAX_DIGEST_SIZE];
char null='\0';
mutils_word32 i;
mutils_word32 j;
mutils_word32 times;
MHASH td;
mutils_word32 block_size = mhash_get_block_size(algorithm);
mutils_word32 total;
if (salt == NULL)
{
return(-MUTILS_INVALID_INPUT_BUFFER);
}
if (salt_size < 8)
{
return(-MUTILS_INVALID_SIZE); /* This algorithm will use EXACTLY
* 8 bytes salt.
*/
}
times = key_size / block_size;
if (key_size % block_size != 0)
times++;
total = times * block_size;
key = mutils_malloc(total);
#if defined(MHASH_ROBUST)
if (key == NULL)
return(-MUTILS_SYSTEM_RESOURCE_ERROR); /* or what? */
#endif
for (i = 0; i < times; i++) {
td = mhash_init(algorithm);
if (td == MHASH_FAILED) {
mutils_free(key);
return(-MUTILS_INVALID_FUNCTION);
}
for (j = 0; j < i; j++)
mhash(td, &null, 1);
mhash(td, salt, 8);
mhash(td, password, plen);
mhash_deinit(td, digest);
mutils_memcpy( &key[i*block_size], digest, block_size);
}
mutils_memcpy(keyword, key, key_size);
mutils_bzero(key, key_size);
mutils_free(key);
return(MUTILS_OK);
}
#define EXPBIAS 6
/* Key generation using OpenPGP Iterated and Salted S2K algorithm */
mutils_error _mhash_gen_key_s2k_isalted(hashid algorithm, mutils_word64 _count,
void *keyword, mutils_word32 key_size,
mutils_word8 *salt, mutils_word32 salt_size,
mutils_word8 *password, mutils_word32 plen)
{
mutils_word8 *key;
mutils_word8 digest[MAX_DIGEST_SIZE];
mutils_word8 null='\0';
mutils_word32 i;
mutils_word32 j;
mutils_word32 z;
mutils_word32 times;
MHASH td;
mutils_word32 block_size = mhash_get_block_size(algorithm);
mutils_word8 *saltpass;
mutils_word32 saltpass_size;
mutils_word32 bcount, rest;
mutils_word32 count = _count;
mutils_word32 total;
if (salt == NULL)
return(-MUTILS_INVALID_INPUT_BUFFER);
if (salt_size < 8)
return(-MUTILS_INVALID_SIZE); /* This algorithm will use EXACTLY
* 8 bytes salt.
*/
if ((saltpass = mutils_malloc(8 + plen)) == NULL)
return(-MUTILS_SYSTEM_RESOURCE_ERROR); /* hmm */
mutils_memcpy( saltpass, salt, 8);
mutils_memcpy( &saltpass[8], password, plen);
saltpass_size = plen+8;
times = key_size/block_size;
if (key_size % block_size != 0)
times++;
total = times * block_size;
key = mutils_malloc(total);
if (key == NULL) {
mutils_bzero(saltpass, saltpass_size);
mutils_free(saltpass);
return(-MUTILS_SYSTEM_RESOURCE_ERROR);
}
mutils_bzero(key, total);
/* Calculate the iterations
*/
bcount /*bytes */ =
((mutils_word32)16 + (count & 15)) << ((count >> 4) + EXPBIAS);
count /* iterations */ =
(bcount / saltpass_size);
rest = bcount % saltpass_size;
if (bcount < saltpass_size)
{
count++;
rest = 0;
}
for (i = 0; i < times; i++)
{
td = mhash_init(algorithm);
if (td == MHASH_FAILED)
{
mutils_bzero( key, key_size);
mutils_bzero( saltpass, saltpass_size);
mutils_free(key);
mutils_free(saltpass);
return(-MUTILS_INVALID_FUNCTION);
}
for (j = 0; j < i; j++)
mhash(td, &null, 1);
for (z = 0; z < count; z++)
{
mhash(td, saltpass, saltpass_size);
}
mhash(td, saltpass, rest);
mhash_deinit(td, digest);
mutils_memcpy( &key[i*block_size], digest, block_size);
}
mutils_memcpy(keyword, key, key_size);
mutils_bzero(key, key_size);
mutils_bzero(saltpass, saltpass_size);
mutils_free(key);
mutils_free(saltpass);
return(MUTILS_OK);
}
@@ -0,0 +1,23 @@
#if !defined(__LIBDEFS_H)
#define LIBDEFS_H
/*
{{{ includes
*/
#define MUTILS_USE_MHASH_CONFIG
#include <mutils/mincludes.h>
#include <mutils/mglobal.h>
#include <mutils/mtypes.h>
#include <mutils/mutils.h>
#ifdef WIN32
# define WIN32DLL_DEFINE __declspec( dllexport)
#else
# define WIN32DLL_DEFINE
#endif
#define RAND32 (mutils_word32) ((mutils_word32)rand() << 17 ^ (mutils_word32)rand() << 9 ^ rand())
#endif
@@ -0,0 +1,31 @@
mhash_keygen
mhash_keygen_ext
mhash_get_keygen_name
mhash_get_keygen_name_static
mhash_get_keygen_max_key_size
mhash_get_keygen_salt_size
mhash_keygen_count
mhash_keygen_uses_salt
mhash_keygen_uses_count
mhash_keygen_uses_hash_algorithm
mhash
mhash_count
mhash_end
mhash_end_m
mhash_get_block_size
mhash_get_hash_name_static
mhash_get_hash_name
mhash_get_hash_pblock
mhash_init
mhash_init_int
mhash_free
mhash_hmac_init
mhash_hmac_end
mhash_hmac_end_m
mhash_bzero
mhash_cp
mhash_get_mhash_algo
mhash_deinit
mhash_hmac_deinit
mhash_save_state_mem
mhash_restore_state_mem
@@ -0,0 +1,152 @@
/* md2.c
*
* The MD2 hash function, described in RFC 1319.
*
* This code was originally written by Möller/Sigfridsson for
* libnettle. It was altered by B. Poettering to fit the mhash
* interface. The original copyright notice follows.
*/
/* nettle, low-level cryptographics library
*
* Copyright (C) 2003 Niels Möller, Andreas Sigfridsson
*
* The nettle library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version.
*
* The nettle 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 Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with the nettle library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
* MA 02111-1307, USA.
*/
/* This code originates from the Python Cryptography Toolkit, version 1.0.1.
Further hacked by Andreas Sigfridsson and Niels Möller. Original license:
===================================================================
Distribute and use freely; there are no restrictions on further
dissemination and usage except those imposed by the laws of your
country of residence. This software is provided "as is" without
warranty of fitness for use or suitability for any purpose, express
or implied. Use at your own risk or not at all.
===================================================================
Incorporating the code into commercial products is permitted; you do
not have to make source available or contribute your changes back
(though that would be nice).
--amk (www.amk.ca) */
#include "libdefs.h"
#ifdef ENABLE_MD2
#include "mhash_md2.h"
static __const mutils_word8
S[256] = {
41, 46, 67, 201, 162, 216, 124, 1, 61, 54, 84, 161, 236, 240, 6,
19, 98, 167, 5, 243, 192, 199, 115, 140, 152, 147, 43, 217, 188,
76, 130, 202, 30, 155, 87, 60, 253, 212, 224, 22, 103, 66, 111, 24,
138, 23, 229, 18, 190, 78, 196, 214, 218, 158, 222, 73, 160, 251,
245, 142, 187, 47, 238, 122, 169, 104, 121, 145, 21, 178, 7, 63,
148, 194, 16, 137, 11, 34, 95, 33, 128, 127, 93, 154, 90, 144, 50,
39, 53, 62, 204, 231, 191, 247, 151, 3, 255, 25, 48, 179, 72, 165,
181, 209, 215, 94, 146, 42, 172, 86, 170, 198, 79, 184, 56, 210,
150, 164, 125, 182, 118, 252, 107, 226, 156, 116, 4, 241, 69, 157,
112, 89, 100, 113, 135, 32, 134, 91, 207, 101, 230, 45, 168, 2, 27,
96, 37, 173, 174, 176, 185, 246, 28, 70, 97, 105, 52, 64, 126, 15,
85, 71, 163, 35, 221, 81, 175, 58, 195, 92, 249, 206, 186, 197,
234, 38, 44, 83, 13, 110, 133, 40, 132, 9, 211, 223, 205, 244, 65,
129, 77, 82, 106, 220, 55, 200, 108, 193, 171, 250, 36, 225, 123,
8, 12, 189, 177, 74, 120, 136, 149, 139, 227, 99, 232, 109, 233,
203, 213, 254, 59, 0, 29, 57, 242, 239, 183, 14, 102, 88, 208, 228,
166, 119, 114, 248, 235, 117, 75, 10, 49, 68, 80, 180, 143, 237,
31, 26, 219, 153, 141, 51, 159, 17, 131, 20
};
static void
md2_transform(struct md2_ctx *ctx, __const mutils_word8 *data)
{
mutils_word8 i;
mutils_word8 j;
mutils_word8 t;
mutils_memcpy(ctx->X + 16, data, MD2_DATA_SIZE);
for (i = 0, t = ctx->C[15]; i<MD2_DATA_SIZE; i++)
{
ctx->X[2 * MD2_DATA_SIZE + i]
= ctx->X[i] ^ ctx->X[MD2_DATA_SIZE + i];
t = (ctx->C[i] ^= S[data[i]^t]);
}
for (i = t = 0; i< MD2_DATA_SIZE + 2; t = (t + i) & 0xff, i++)
{
for (j = 0; j < 3 * MD2_DATA_SIZE; j++)
t = (ctx->X[j] ^= S[t]);
}
}
void
md2_init(struct md2_ctx *ctx)
{
mutils_bzero(ctx, sizeof(*ctx));
}
void
md2_update(struct md2_ctx *ctx,
__const mutils_word8 *data,
mutils_word32 length)
{
if (ctx->index != 0)
{
/* Try to fill partial block */
mutils_word32 left = MD2_DATA_SIZE - ctx->index;
if (length < left)
{
mutils_memcpy(ctx->buffer + ctx->index, data, length);
ctx->index += length;
return; /* Finished */
}
else
{
mutils_memcpy(ctx->buffer + ctx->index, data, left);
md2_transform(ctx, ctx->buffer);
data += left;
length -= left;
}
}
while (length >= MD2_DATA_SIZE)
{
md2_transform(ctx, data);
data += MD2_DATA_SIZE;
length -= MD2_DATA_SIZE;
}
if ((ctx->index = length) != 0) /* This assignment is intended */
/* Buffer leftovers */
mutils_memcpy(ctx->buffer, data, length);
}
void
md2_digest(struct md2_ctx *ctx, mutils_word8 *digest)
{
mutils_word8 left;
left = MD2_DATA_SIZE - ctx->index;
mutils_memset(ctx->buffer + ctx->index, left, left);
md2_transform(ctx, ctx->buffer);
md2_transform(ctx, ctx->C);
mutils_memcpy(digest, ctx->X, MD2_DIGEST_SIZE);
md2_init(ctx);
}
#endif /* ENABLE_MD2 */
@@ -0,0 +1,239 @@
/*
* 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.
*/
#include <libdefs.h>
#ifdef ENABLE_MD4
/*
* The algorithm is due to Ron Rivest. This code is based on code
* written by Colin Plumb in 1993.
*/
/*
* This code implements the MD4 message-digest algorithm.
*/
#include "mhash_md4.h"
#define rotl32(x,n) (((x) << ((mutils_word32)(n))) | ((x) >> (32 - (mutils_word32)(n))))
/*
* Start MD4 accumulation. Set bit count to 0 and buffer to mysterious
* initialization __constants.
*/
void MD4Init(struct MD4Context *ctx)
{
ctx->buf[0] = 0x67452301;
ctx->buf[1] = 0xefcdab89;
ctx->buf[2] = 0x98badcfe;
ctx->buf[3] = 0x10325476;
ctx->bits[0] = 0;
ctx->bits[1] = 0;
}
/*
* Update context to reflect the concatenation of another buffer full
* of bytes.
*/
void MD4Update(struct MD4Context *ctx, mutils_word8 __const *buf, mutils_word32 len)
{
register mutils_word32 t;
/* Update bitcount */
t = ctx->bits[0];
if ((ctx->bits[0] = t + ((mutils_word32) len << 3)) < t)
ctx->bits[1]++; /* Carry from low to high */
ctx->bits[1] += len >> 29;
t = (t >> 3) & 0x3f; /* Bytes already in shsInfo->data */
/* Handle any leading odd-sized chunks */
if (t) {
mutils_word8 *p = (mutils_word8 *) ctx->in + t;
t = 64 - t;
if (len < t) {
mutils_memcpy(p, buf, len);
return;
}
mutils_memcpy(p, buf, t);
mutils_word32nswap((mutils_word32 *) ctx->in, 16, MUTILS_TRUE);
MD4Transform(ctx->buf, (mutils_word32 *) ctx->in);
buf += t;
len -= t;
}
/* Process data in 64-byte chunks */
while (len >= 64) {
mutils_memcpy(ctx->in, buf, 64);
mutils_word32nswap((mutils_word32 *) ctx->in, 16, MUTILS_TRUE);
MD4Transform(ctx->buf, (mutils_word32 *) ctx->in);
buf += 64;
len -= 64;
}
/* Handle any remaining bytes of data. */
mutils_memcpy(ctx->in, buf, len);
}
/*
* Final wrapup - pad to 64-byte boundary with the bit pattern
* 1 0* (64-bit count of bits processed, MSB-first)
*/
void MD4Final(struct MD4Context *ctx, mutils_word8 *digest)
{
mutils_word32 count;
mutils_word8 *p;
/* Compute number of bytes mod 64 */
count = (ctx->bits[0] >> 3) & 0x3F;
/* Set the first char of padding to 0x80. This is safe since there is
always at least one byte free */
p = ctx->in + count;
*p++ = 0x80;
/* Bytes of padding needed to make 64 bytes */
count = 64 - 1 - count;
/* Pad out to 56 mod 64 */
if (count < 8) {
/* Two lots of padding: Pad the first block to 64 bytes */
mutils_bzero(p, count);
mutils_word32nswap((mutils_word32 *) ctx->in, 16, MUTILS_TRUE);
MD4Transform(ctx->buf, (mutils_word32 *) ctx->in);
/* Now fill the next block with 56 bytes */
mutils_bzero(ctx->in, 56);
} else {
/* Pad block to 56 bytes */
mutils_bzero(p, count - 8);
}
mutils_word32nswap((mutils_word32 *) ctx->in, 14, MUTILS_TRUE);
/* Append length in bits and transform */
((mutils_word32 *) ctx->in)[14] = ctx->bits[0];
((mutils_word32 *) ctx->in)[15] = ctx->bits[1];
MD4Transform(ctx->buf, (mutils_word32 *) ctx->in);
mutils_word32nswap((mutils_word32 *) ctx->buf, 4, MUTILS_TRUE);
if (digest!=NULL)
mutils_memcpy(digest, ctx->buf, 16);
mutils_bzero(ctx, sizeof(ctx)); /* In case it's sensitive */
}
/* The three core functions */
#define F(x, y, z) (((x) & (y)) | ((~x) & (z)))
#define G(x, y, z) (((x) & (y)) | ((x) & (z)) | ((y) & (z)))
#define H(x, y, z) ((x) ^ (y) ^ (z))
#define FF(a, b, c, d, x, s) { \
(a) += F ((b), (c), (d)) + (x); \
(a) = rotl32 ((a), (s)); \
}
#define GG(a, b, c, d, x, s) { \
(a) += G ((b), (c), (d)) + (x) + (mutils_word32)0x5a827999; \
(a) = rotl32 ((a), (s)); \
}
#define HH(a, b, c, d, x, s) { \
(a) += H ((b), (c), (d)) + (x) + (mutils_word32)0x6ed9eba1; \
(a) = rotl32 ((a), (s)); \
}
/*
* The core of the MD4 algorithm
*/
void MD4Transform(mutils_word32 buf[4], __const mutils_word32 in[16])
{
register mutils_word32 a, b, c, d;
a = buf[0];
b = buf[1];
c = buf[2];
d = buf[3];
FF(a, b, c, d, in[0], 3); /* 1 */
FF(d, a, b, c, in[1], 7); /* 2 */
FF(c, d, a, b, in[2], 11); /* 3 */
FF(b, c, d, a, in[3], 19); /* 4 */
FF(a, b, c, d, in[4], 3); /* 5 */
FF(d, a, b, c, in[5], 7); /* 6 */
FF(c, d, a, b, in[6], 11); /* 7 */
FF(b, c, d, a, in[7], 19); /* 8 */
FF(a, b, c, d, in[8], 3); /* 9 */
FF(d, a, b, c, in[9], 7); /* 10 */
FF(c, d, a, b, in[10], 11); /* 11 */
FF(b, c, d, a, in[11], 19); /* 12 */
FF(a, b, c, d, in[12], 3); /* 13 */
FF(d, a, b, c, in[13], 7); /* 14 */
FF(c, d, a, b, in[14], 11); /* 15 */
FF(b, c, d, a, in[15], 19); /* 16 */
GG(a, b, c, d, in[0], 3); /* 17 */
GG(d, a, b, c, in[4], 5); /* 18 */
GG(c, d, a, b, in[8], 9); /* 19 */
GG(b, c, d, a, in[12], 13); /* 20 */
GG(a, b, c, d, in[1], 3); /* 21 */
GG(d, a, b, c, in[5], 5); /* 22 */
GG(c, d, a, b, in[9], 9); /* 23 */
GG(b, c, d, a, in[13], 13); /* 24 */
GG(a, b, c, d, in[2], 3); /* 25 */
GG(d, a, b, c, in[6], 5); /* 26 */
GG(c, d, a, b, in[10], 9); /* 27 */
GG(b, c, d, a, in[14], 13); /* 28 */
GG(a, b, c, d, in[3], 3); /* 29 */
GG(d, a, b, c, in[7], 5); /* 30 */
GG(c, d, a, b, in[11], 9); /* 31 */
GG(b, c, d, a, in[15], 13); /* 32 */
HH(a, b, c, d, in[0], 3); /* 33 */
HH(d, a, b, c, in[8], 9); /* 34 */
HH(c, d, a, b, in[4], 11); /* 35 */
HH(b, c, d, a, in[12], 15); /* 36 */
HH(a, b, c, d, in[2], 3); /* 37 */
HH(d, a, b, c, in[10], 9); /* 38 */
HH(c, d, a, b, in[6], 11); /* 39 */
HH(b, c, d, a, in[14], 15); /* 40 */
HH(a, b, c, d, in[1], 3); /* 41 */
HH(d, a, b, c, in[9], 9); /* 42 */
HH(c, d, a, b, in[5], 11); /* 43 */
HH(b, c, d, a, in[13], 15); /* 44 */
HH(a, b, c, d, in[3], 3); /* 45 */
HH(d, a, b, c, in[11], 9); /* 46 */
HH(c, d, a, b, in[7], 11); /* 47 */
HH(b, c, d, a, in[15], 15); /* 48 */
buf[0] += a;
buf[1] += b;
buf[2] += c;
buf[3] += d;
}
#endif /* ENABLE_MD4 */
@@ -0,0 +1,240 @@
#include <libdefs.h>
/*
* This code implements the MD5 message-digest algorithm.
* The algorithm is due to Ron Rivest. This code was
* written by Colin Plumb in 1993, no copyright is claimed.
* This code is in the public domain; do with it what you wish.
*
* Equivalent code is available from RSA Data Security, Inc.
* This code has been tested against that, and is equivalent,
* except that you don't need to include two pages of legalese
* with every copy.
*
* To compute the message digest of a chunk of bytes, declare an
* MD5Context structure, pass it to MD5Init, call MD5Update as
* needed on buffers full of bytes, and then call MD5Final, which
* will fill a supplied 16-byte array with the digest.
*/
#ifdef ENABLE_MD5
#include "mhash_md5.h"
/*
* Start MD5 accumulation. Set bit count to 0 and buffer to mysterious
* initialization __constants.
*/
void MD5Init(struct MD5Context *ctx)
{
ctx->buf[0] = 0x67452301;
ctx->buf[1] = 0xefcdab89;
ctx->buf[2] = 0x98badcfe;
ctx->buf[3] = 0x10325476;
ctx->bits[0] = 0;
ctx->bits[1] = 0;
}
/*
* Update context to reflect the concatenation of another buffer full
* of bytes.
*/
void MD5Update(struct MD5Context *ctx, __const mutils_word8 *buf, mutils_word32 len)
{
register mutils_word32 t;
mutils_word8 *p;
/* Update bitcount */
t = ctx->bits[0];
if ((ctx->bits[0] = t + ((mutils_word32) len << 3)) < t)
ctx->bits[1]++; /* Carry from low to high */
ctx->bits[1] += len >> 29;
t = (t >> 3) & 0x3f; /* Bytes already in shsInfo->data */
/* Handle any leading odd-sized chunks */
if (t)
{
p = (mutils_word8 *) ctx->in + t;
t = 64 - t;
if (len < t)
{
mutils_memcpy(p, buf, len);
return;
}
mutils_memcpy(p, buf, t);
mutils_word32nswap((mutils_word32 *) ctx->in, 16, MUTILS_TRUE);
MD5Transform(ctx->buf, (mutils_word32 *) ctx->in);
buf += t;
len -= t;
}
/* Process data in 64-byte chunks */
while (len >= 64)
{
mutils_memcpy(ctx->in, buf, 64);
mutils_word32nswap((mutils_word32 *) ctx->in, 16, MUTILS_TRUE);
MD5Transform(ctx->buf, (mutils_word32 *) ctx->in);
buf += 64;
len -= 64;
}
/* Handle any remaining bytes of data. */
mutils_memcpy(ctx->in, buf, len);
}
/*
* Final wrapup - pad to 64-byte boundary with the bit pattern
* 1 0* (64-bit count of bits processed, MSB-first)
*/
void MD5Final(struct MD5Context *ctx, mutils_word8* digest)
{
mutils_word32 count;
mutils_word8 *p;
/* Compute number of bytes mod 64 */
count = (ctx->bits[0] >> 3) & 0x3F;
/* Set the first char of padding to 0x80. This is safe since there is
always at least one byte free */
p = ctx->in + count;
*p++ = 0x80;
/* Bytes of padding needed to make 64 bytes */
count = 64 - 1 - count;
/* Pad out to 56 mod 64 */
if (count < 8)
{
/* Two lots of padding: Pad the first block to 64 bytes */
mutils_bzero(p, count);
mutils_word32nswap((mutils_word32 *) ctx->in, 16, MUTILS_TRUE);
MD5Transform(ctx->buf, (mutils_word32 *) ctx->in);
/* Now fill the next block with 56 bytes */
mutils_bzero(ctx->in, 56);
} else {
/* Pad block to 56 bytes */
mutils_bzero(p, count - 8);
}
mutils_word32nswap((mutils_word32 *) ctx->in, 14, MUTILS_TRUE);
/* Append length in bits and transform */
((mutils_word32 *) ctx->in)[14] = ctx->bits[0];
((mutils_word32 *) ctx->in)[15] = ctx->bits[1];
MD5Transform(ctx->buf, (mutils_word32 *) ctx->in);
mutils_word32nswap((mutils_word32 *) ctx->buf, 4, MUTILS_TRUE);
if (digest!=NULL)
mutils_memcpy(digest, ctx->buf, 16);
mutils_bzero(ctx, sizeof(ctx)); /* In case it's sensitive */
}
/* The four core functions - F1 is optimized somewhat */
/* #define F1(x, y, z) (x & y | ~x & z) */
#define F1(x, y, z) (z ^ (x & (y ^ z)))
#define F2(x, y, z) F1(z, x, y)
#define F3(x, y, z) (x ^ y ^ z)
#define F4(x, y, z) (y ^ (x | ~z))
/* This is the central step in the MD5 algorithm. */
#define MD5STEP(f, w, x, y, z, data, s) \
( w += f(x, y, z) + data, w = w<<s | w>>(32-s), w += x )
/*
* The core of the MD5 algorithm, this alters an existing MD5 hash to
* reflect the addition of 16 longwords of new data. MD5Update blocks
* the data and converts bytes into longwords for this routine.
*/
void MD5Transform(mutils_word32 buf[4], mutils_word32 __const in[16])
{
register mutils_word32 a, b, c, d;
a = buf[0];
b = buf[1];
c = buf[2];
d = buf[3];
MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7);
MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12);
MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17);
MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22);
MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7);
MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12);
MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17);
MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22);
MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7);
MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12);
MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17);
MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22);
MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7);
MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12);
MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17);
MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22);
MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5);
MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9);
MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14);
MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20);
MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5);
MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9);
MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14);
MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20);
MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5);
MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9);
MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14);
MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20);
MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5);
MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9);
MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14);
MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20);
MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4);
MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11);
MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16);
MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23);
MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4);
MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11);
MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16);
MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23);
MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4);
MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11);
MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16);
MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23);
MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4);
MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11);
MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16);
MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23);
MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6);
MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10);
MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15);
MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21);
MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6);
MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10);
MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15);
MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21);
MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6);
MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10);
MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15);
MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21);
MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6);
MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10);
MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15);
MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21);
buf[0] += a;
buf[1] += b;
buf[2] += c;
buf[3] += d;
}
#endif /* ENABLE_MD5 */
@@ -0,0 +1,749 @@
/*
* 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.
*/
/* $Id: mhash.c,v 1.42 2006/01/10 04:40:48 imipak Exp $ */
#include <libdefs.h>
#include <mhash_int.h>
#include <mhash_crc32.h>
#include <mhash_haval.h>
#include <mhash_md5.h>
#include <mhash_md4.h>
#include <mhash_md2.h>
#include <mhash_sha1.h>
#include <mhash_tiger.h>
#include <mhash_ripemd.h>
#include <mhash_sha256_sha224.h>
#include <mhash_sha512_sha384.h>
#include <mhash_adler32.h>
#include <mhash_gost.h>
#include <mhash_whirlpool.h>
#include <mhash_snefru.h>
/* 19/03/2000 Changes for better thread handling --nikos
* Actually it is thread safe.
*/
#define MAX_BLOCK_SIZE 128
#define MHASH_ENTRY(name, blksize, hash_pblock, state_size, \
init_func, hash_func, final_func, deinit_func) \
{ (mutils_word8 *) #name, name, blksize, hash_pblock, state_size, \
(INIT_FUNC) init_func, (HASH_FUNC) hash_func, \
(FINAL_FUNC) final_func, (DEINIT_FUNC) deinit_func }
struct mhash_hash_entry {
mutils_word8 *name;
hashid id;
mutils_word32 blocksize;
mutils_word32 hash_pblock;
mutils_word32 state_size;
INIT_FUNC init_func;
HASH_FUNC hash_func;
FINAL_FUNC final_func;
DEINIT_FUNC deinit_func;
};
static __const mhash_hash_entry algorithms[] = {
#if defined(ENABLE_CRC32)
MHASH_ENTRY(MHASH_CRC32, 4, 0, sizeof(mutils_word32), mhash_clear_crc32,
mhash_crc32, NULL, mhash_get_crc32),
MHASH_ENTRY(MHASH_CRC32B, 4, 0, sizeof(mutils_word32), mhash_clear_crc32,
mhash_crc32b, NULL, mhash_get_crc32),
#endif
#if defined(ENABLE_ADLER32)
MHASH_ENTRY(MHASH_ADLER32, 4, 0, sizeof(mutils_word32), mhash_clear_adler32,
mhash_adler32, NULL, mhash_get_adler32),
#endif
#if defined(ENABLE_MD5)
MHASH_ENTRY(MHASH_MD5, 16, 64, sizeof(MD5_CTX), MD5Init,
MD5Update, NULL, MD5Final),
#endif
#if defined(ENABLE_MD4)
MHASH_ENTRY(MHASH_MD4, 16, 64, sizeof(MD4_CTX), MD4Init,
MD4Update, NULL, MD4Final),
#endif
#if defined(ENABLE_MD2)
MHASH_ENTRY(MHASH_MD2, 16, 16, sizeof(MD2_CTX), md2_init,
md2_update, NULL, md2_digest),
#endif
#if defined(ENABLE_SHA1)
MHASH_ENTRY(MHASH_SHA1, 20, 64, sizeof(SHA_CTX), sha_init,
sha_update, sha_final, sha_digest),
#endif
#if defined(ENABLE_SHA256_SHA224)
MHASH_ENTRY(MHASH_SHA256, 32, 64, sizeof( SHA256_SHA224_CTX), sha256_init,
sha256_sha224_update, sha256_sha224_final, sha256_digest),
MHASH_ENTRY(MHASH_SHA224, 28, 64, sizeof( SHA256_SHA224_CTX), sha224_init,
sha256_sha224_update, sha256_sha224_final, sha224_digest),
#endif
#if defined(ENABLE_SHA512_SHA384)
MHASH_ENTRY(MHASH_SHA512, 64, 128, sizeof( SHA512_SHA384_CTX), sha512_init,
sha512_sha384_update, sha512_sha384_final, sha512_digest),
MHASH_ENTRY(MHASH_SHA384, 48, 128, sizeof( SHA512_SHA384_CTX), sha384_init,
sha512_sha384_update, sha512_sha384_final, sha384_digest),
#endif
#if defined(ENABLE_HAVAL)
MHASH_ENTRY(MHASH_HAVAL256, 32, 128, sizeof(havalContext), havalInit256,
havalUpdate, NULL, havalFinal),
MHASH_ENTRY(MHASH_HAVAL128, 16, 128, sizeof(havalContext), havalInit128,
havalUpdate, NULL, havalFinal),
MHASH_ENTRY(MHASH_HAVAL160, 20, 128, sizeof(havalContext), havalInit160,
havalUpdate, NULL, havalFinal),
MHASH_ENTRY(MHASH_HAVAL192, 24, 128, sizeof(havalContext), havalInit192,
havalUpdate, NULL, havalFinal),
MHASH_ENTRY(MHASH_HAVAL224, 28, 128, sizeof(havalContext), havalInit224,
havalUpdate, NULL, havalFinal),
#endif
#if defined(ENABLE_RIPEMD)
MHASH_ENTRY(MHASH_RIPEMD128, 16, 64, sizeof(RIPEMD_CTX), ripemd128_init,
ripemd_update, ripemd_final, ripemd_digest),
MHASH_ENTRY(MHASH_RIPEMD160, 20, 64, sizeof(RIPEMD_CTX), ripemd160_init,
ripemd_update, ripemd_final, ripemd_digest),
MHASH_ENTRY(MHASH_RIPEMD256, 32, 64, sizeof(RIPEMD_CTX), ripemd256_init,
ripemd_update, ripemd_final, ripemd_digest),
MHASH_ENTRY(MHASH_RIPEMD320, 40, 64, sizeof(RIPEMD_CTX), ripemd320_init,
ripemd_update, ripemd_final, ripemd_digest),
#endif
#if defined(ENABLE_TIGER)
MHASH_ENTRY(MHASH_TIGER, 24, 64, sizeof(TIGER_CTX), tiger_init,
tiger_update, tiger_final, tiger_digest),
MHASH_ENTRY(MHASH_TIGER128, 16, 64, sizeof(TIGER_CTX), tiger_init,
tiger_update, tiger_final, tiger128_digest),
MHASH_ENTRY(MHASH_TIGER160, 20, 64, sizeof(TIGER_CTX), tiger_init,
tiger_update, tiger_final, tiger160_digest),
#endif
#if defined(ENABLE_GOST)
MHASH_ENTRY(MHASH_GOST, 32, 0, sizeof(GostHashCtx), gosthash_reset,
gosthash_update, NULL, gosthash_final),
#endif
#if defined(ENABLE_WHIRLPOOL)
MHASH_ENTRY(MHASH_WHIRLPOOL, 64, 64, sizeof(WHIRLPOOL_CTX), whirlpool_init,
whirlpool_update, whirlpool_final, whirlpool_digest),
#endif
#if defined(ENABLE_SNEFRU)
MHASH_ENTRY(MHASH_SNEFRU128, 16, 64, sizeof(SNEFRU_CTX), snefru_init,
snefru128_update, snefru128_final, snefru128_digest),
MHASH_ENTRY(MHASH_SNEFRU256, 32, 64, sizeof(SNEFRU_CTX), snefru_init,
snefru256_update, snefru256_final, snefru256_digest),
#endif
{0}
};
#define MHASH_LOOP(b) \
__const mhash_hash_entry *p; \
for (p = algorithms; p->name != NULL; p++) { b ; }
#define MHASH_ALG_LOOP(a) \
MHASH_LOOP( if (p->id == type) { a; break; } )
#ifndef MMAX
# define MMAX(x,y) (x>y?x:y)
#endif
WIN32DLL_DEFINE mutils_word32 mhash_count(void)
{
hashid count = 0;
MHASH_LOOP( count = MMAX( p->id, count) );
return count;
}
WIN32DLL_DEFINE mutils_word32 mhash_get_block_size(hashid type)
{
mutils_word32 ret = 0;
MHASH_ALG_LOOP(ret = p->blocksize);
return ret;
}
WIN32DLL_DEFINE mutils_word32 _mhash_get_state_size(hashid type)
{
/* Fixed: Valid state sizes that exceeded maximum
positive value for integer would be returned as
an error.
*/
mutils_word32 size = 0;
MHASH_ALG_LOOP(size = p->state_size);
return size;
}
WIN32DLL_DEFINE INIT_FUNC _mhash_get_init_func(hashid type)
{
INIT_FUNC func = NULL;
MHASH_ALG_LOOP(func = p->init_func);
return func;
}
WIN32DLL_DEFINE HASH_FUNC _mhash_get_hash_func(hashid type)
{
HASH_FUNC func = NULL;
MHASH_ALG_LOOP(func = p->hash_func);
return func;
}
WIN32DLL_DEFINE FINAL_FUNC _mhash_get_final_func(hashid type)
{
FINAL_FUNC func = NULL;
MHASH_ALG_LOOP(func = p->final_func);
return func;
}
WIN32DLL_DEFINE DEINIT_FUNC _mhash_get_deinit_func(hashid type)
{
DEINIT_FUNC func = NULL;
MHASH_ALG_LOOP(func = p->deinit_func);
return func;
}
WIN32DLL_DEFINE hashid mhash_get_mhash_algo( MHASH tmp) {
return tmp->algorithm_given;
}
WIN32DLL_DEFINE mutils_word8 *mhash_get_hash_name(hashid type)
{
mutils_word8 *ret = NULL;
/* avoid prefix */
MHASH_ALG_LOOP(ret = p->name);
if (ret != NULL)
{
ret += sizeof("MHASH_") - 1;
}
return mutils_strdup(ret);
}
WIN32DLL_DEFINE __const mutils_word8 *mhash_get_hash_name_static(hashid type)
{
mutils_word8 *ret = NULL;
/* avoid prefix */
MHASH_ALG_LOOP( ret = p->name);
if ( ret != NULL)
{
ret += sizeof("MHASH_") - 1;
}
return ret;
}
MHASH mhash_cp(MHASH from) {
MHASH ret;
ret = (MHASH) mutils_malloc(sizeof(MHASH_INSTANCE));
if (ret == NULL)
{
return(MHASH_FAILED);
}
mutils_memcpy(ret, from, sizeof(MHASH_INSTANCE));
/* copy the internal state also */
ret->state = (mutils_word8 *) mutils_malloc(ret->state_size);
if (ret->state == NULL)
{
mutils_free(ret);
return(MHASH_FAILED);
}
mutils_memcpy(ret->state, from->state, ret->state_size);
/* copy the key in case of hmac*/
if (ret->hmac_key_size != 0)
{
ret->hmac_key = (mutils_word8 *) mutils_malloc(ret->hmac_key_size);
if (ret == NULL)
{
mutils_free(ret->state);
mutils_free(ret);
return(MHASH_FAILED);
}
mutils_memcpy(ret->hmac_key, from->hmac_key, ret->hmac_key_size);
}
return ret;
}
MHASH mhash_init_int(__const hashid type)
{
MHASH ret;
INIT_FUNC func;
ret = (MHASH) mutils_malloc(sizeof(MHASH_INSTANCE));
if (ret == NULL)
{
return MHASH_FAILED;
}
mutils_memset(ret, 0, sizeof(MHASH_INSTANCE));
ret->algorithm_given = type;
ret->state_size = _mhash_get_state_size(type);
if (ret->state_size == 0)
{
mutils_free(ret);
return(MHASH_FAILED);
}
if ( (ret->state = mutils_malloc(ret->state_size)) == NULL)
{
mutils_free(ret);
return(MHASH_FAILED);
}
func = _mhash_get_init_func( type);
if (func != NULL)
{
func(ret->state);
}
else
{
mutils_free(ret->state);
mutils_free(ret);
return(MHASH_FAILED);
}
ret->hash_func = _mhash_get_hash_func( type);
ret->deinit_func = _mhash_get_deinit_func( type);
ret->final_func = _mhash_get_final_func( type);
return ret;
}
/* plaintext should be a multiple of the algorithm's block size */
mutils_boolean mhash(MHASH td, __const void *plaintext, mutils_word32 size)
{
if (td->hash_func!=NULL)
{
td->hash_func( td->state, plaintext, size);
}
return(MUTILS_OK);
}
WIN32DLL_DEFINE
void mhash_deinit(MHASH td, void *result)
{
if (td->final_func != NULL)
{
td->final_func( td->state);
}
if (td->deinit_func != NULL)
{
td->deinit_func( td->state, result);
}
if (NULL != td->state)
{
mutils_free(td->state);
}
mutils_free(td);
return;
}
WIN32DLL_DEFINE
void *mhash_end_m(MHASH td, void *(*hash_malloc) (mutils_word32))
{
void *digest;
mutils_word32 size;
size = mhash_get_block_size( td->algorithm_given);
digest = mutils_malloc(size);
if (digest==NULL)
{
return NULL;
}
mhash_deinit( td, digest);
return(digest);
}
WIN32DLL_DEFINE void *mhash_end(MHASH td)
{
return(mhash_end_m(td, mutils_malloc));
}
WIN32DLL_DEFINE MHASH mhash_init(__const hashid type)
{
MHASH ret = MHASH_FAILED;
ret = mhash_init_int(type);
return(ret);
}
/* HMAC functions */
WIN32DLL_DEFINE mutils_word32 mhash_get_hash_pblock(hashid type)
{
mutils_word32 ret = 0;
MHASH_ALG_LOOP(ret = p->hash_pblock);
return(ret);
}
WIN32DLL_DEFINE
mutils_error mhash_hmac_deinit(MHASH td, void *result)
{
mutils_word8 *opad;
mutils_word8 _opad[MAX_BLOCK_SIZE];
MHASH tmptd;
mutils_word32 i;
mutils_word32 opad_alloc = 0;
if (td->hmac_block > MAX_BLOCK_SIZE)
{
opad = mutils_malloc(td->hmac_block);
if (opad == NULL)
{
return(-MUTILS_SYSTEM_RESOURCE_ERROR);
}
opad_alloc = 1;
}
else
{
opad = _opad;
}
for (i = 0; i < td->hmac_key_size; i++)
{
opad[i] = (0x5C) ^ td->hmac_key[i];
}
for (; i < td->hmac_block; i++)
{
opad[i] = (0x5C);
}
tmptd = mhash_init(td->algorithm_given);
mhash(tmptd, opad, td->hmac_block);
if (td->final_func != NULL)
{
td->final_func(td->state);
}
if (td->deinit_func != NULL)
{
td->deinit_func(td->state, result);
}
if (result != NULL)
{
mhash(tmptd, result,
mhash_get_block_size(td->algorithm_given));
}
mutils_free(td->state);
if (opad_alloc!=0)
{
mutils_free(opad);
}
mutils_bzero(td->hmac_key, td->hmac_key_size);
mutils_free(td->hmac_key);
mutils_free(td);
mhash_deinit(tmptd, result);
return(MUTILS_OK);
}
WIN32DLL_DEFINE
void *mhash_hmac_end_m(MHASH td, void *(*hash_malloc) (mutils_word32))
{
void *digest;
digest =
hash_malloc(mhash_get_block_size
(td->algorithm_given));
if (digest == NULL)
{
return(NULL);
}
mhash_hmac_deinit(td, digest);
return(digest);
}
WIN32DLL_DEFINE void *mhash_hmac_end(MHASH td)
{
return mhash_hmac_end_m(td, mutils_malloc);
}
WIN32DLL_DEFINE
MHASH mhash_hmac_init(__const hashid type,
void *key, mutils_word32 keysize,
mutils_word32 block)
{
MHASH ret = MHASH_FAILED;
MHASH tmptd;
mutils_word8 *ipad;
mutils_word8 _ipad[MAX_BLOCK_SIZE];
mutils_word32 i;
mutils_boolean ipad_alloc = MUTILS_FALSE;
mutils_boolean res;
if (block == 0)
{
block = 64; /* the default for ripemd,md5,sha-1 */
}
ret = mhash_init_int(type);
if (ret != MHASH_FAILED)
{
/* Initial hmac calculations */
ret->hmac_block = block;
if ( ret->hmac_block > MAX_BLOCK_SIZE)
{
ipad = mutils_malloc(ret->hmac_block);
if (ipad == NULL)
{
return MHASH_FAILED;
}
ipad_alloc = MUTILS_TRUE;
}
else
{
ipad = _ipad;
}
if (keysize > ret->hmac_block)
{
tmptd = mhash_init(type);
mhash(tmptd, key, keysize);
ret->hmac_key_size = mhash_get_block_size(type);
ret->hmac_key = mhash_end(tmptd);
}
else
{
ret->hmac_key = mutils_malloc(ret->hmac_block);
mutils_bzero(ret->hmac_key, ret->hmac_block);
mutils_memcpy(ret->hmac_key, key, keysize);
ret->hmac_key_size = ret->hmac_block;
}
/* IPAD */
for (i = 0; i < ret->hmac_key_size; i++)
{
ipad[i] = (0x36) ^ ret->hmac_key[i];
}
for (; i < ret->hmac_block; i++)
{
ipad[i] = (0x36);
}
res = mhash(ret, ipad, ret->hmac_block);
if (ipad_alloc == MUTILS_TRUE)
{
mutils_free(ipad);
}
}
return(ret);
}
WIN32DLL_DEFINE void mhash_free(void *ptr)
{
mutils_free(ptr);
}
/*
Saves the state of a hashing algorithm such that it can be
restored at some later point in time using
mhash_restore_state().
mem_size should contain the size of the given _mem pointer.
Otherwise the required size will be copied there.
Original version and idea by Blake Stephen <Stephen.Blake@veritect.com>
*/
WIN32DLL_DEFINE mutils_error mhash_save_state_mem(MHASH td, void *_mem, mutils_word32 *mem_size )
{
mutils_word32 tot_size;
mutils_word32 pos;
mutils_word8 *mem = _mem;
tot_size = sizeof(td->algorithm_given) + sizeof(td->hmac_key_size)
+ sizeof(td->hmac_block) + td->hmac_key_size +
+ sizeof(td->state_size) + td->state_size;
if ( *mem_size < tot_size)
{
*mem_size = tot_size;
return(MUTILS_INVALID_INPUT_BUFFER);
}
if ( mem != NULL)
{
pos = 0;
mutils_memcpy( mem, &td->algorithm_given, sizeof(td->algorithm_given));
pos = sizeof( td->algorithm_given);
mutils_memcpy( &mem[pos], &td->hmac_key_size, sizeof(td->hmac_key_size));
pos += sizeof(td->hmac_key_size);
mutils_memcpy( &mem[pos], &td->hmac_block, sizeof(td->hmac_block));
pos += sizeof(td->hmac_block);
mutils_memcpy( &mem[pos], td->hmac_key, td->hmac_key_size);
pos += td->hmac_key_size;
mutils_memcpy( &mem[pos], &td->state_size, sizeof(td->state_size));
pos += sizeof(td->state_size);
mutils_memcpy( &mem[pos], td->state, td->state_size);
pos += td->state_size;
}
return(MUTILS_OK);
}
/*
Restores the state of a hashing algorithm that was saved
using mhash_save_state(). Use like mhash_init.
*/
WIN32DLL_DEFINE MHASH mhash_restore_state_mem(void* _mem)
{
mutils_word8 *mem = _mem;
hashid algorithm_given;
MHASH ret = MHASH_FAILED;
mutils_word32 pos;
if (mem==NULL)
{
return(ret);
}
mutils_memcpy( &algorithm_given, mem, sizeof(algorithm_given));
if ((ret = mhash_init(algorithm_given)) == MHASH_FAILED)
{
return(ret);
}
ret->algorithm_given = algorithm_given;
pos = sizeof(algorithm_given);
mutils_memcpy( &ret->hmac_key_size, &mem[pos], sizeof(ret->hmac_key_size));
pos += sizeof( ret->hmac_key_size);
mutils_memcpy( &ret->hmac_block, &mem[pos], sizeof(ret->hmac_block));
pos += sizeof(ret->hmac_block);
if (ret->hmac_key_size != 0)
{
ret->hmac_key = mutils_malloc(ret->hmac_key_size);
if (ret->hmac_key == NULL)
{
goto freeall;
}
mutils_memcpy( ret->hmac_key, &mem[pos], ret->hmac_key_size);
pos += sizeof(ret->hmac_key_size);
}
mutils_memcpy( &ret->state_size, &mem[pos], sizeof(ret->state_size));
pos += sizeof( ret->state_size);
ret->state = mutils_malloc(ret->state_size);
if (ret->state==NULL)
goto freeall;
mutils_memcpy( ret->state, &mem[pos], ret->state_size);
pos += ret->state_size;
ret->hash_func = _mhash_get_hash_func( algorithm_given);
ret->deinit_func = _mhash_get_deinit_func( algorithm_given);
ret->final_func = _mhash_get_final_func( algorithm_given);
return(ret);
freeall:
/* This uses too much internals
*/
mutils_free(ret->state);
mutils_free(ret->hmac_key);
mutils_free(ret);
return(MHASH_FAILED);
}
#if defined(WIN32) || defined (__CYGWIN__)
WIN32DLL_DEFINE int main (void)
{
/* empty main function to avoid linker error (see cygwin FAQ) */
}
#endif
@@ -0,0 +1,14 @@
#if defined(ENABLE_ADLER32)
#if !defined(MHASH_ADLER32_H)
#define MHASH_ADLER32_H
#include "libdefs.h"
void mhash_clear_adler32(mutils_word32 * adler);
void mhash_get_adler32( __const mutils_word32 * adler, void* ret);
void mhash_adler32(mutils_word32 * adler, __const void *, mutils_word32 len);
#endif
#endif
@@ -0,0 +1,15 @@
#if defined(ENABLE_CRC32)
#if !defined(__MHASH_CRC32_H)
#define __MHASH_CRC32_H
#include "libdefs.h"
void mhash_clear_crc32(mutils_word32 * crc);
void mhash_get_crc32( __const mutils_word32 *crc, void *ret);
void mhash_crc32(mutils_word32 *crc, __const void *given_buf, mutils_word32 len);
void mhash_crc32b(mutils_word32 *crc, __const void *given_buf, mutils_word32 len);
#endif
#endif
@@ -0,0 +1,61 @@
/*
* gosthash.h
* 21 Apr 1998 Markku-Juhani Saarinen <mjos@ssh.fi>
*
* GOST R 34.11-94, Russian Standard Hash Function
* header with function prototypes.
*
* Copyright (c) 1998 SSH Communications Security, Finland
* All rights reserved.
*/
#if defined(ENABLE_GOST)
#if !defined(GOSTHASH_H)
#define GOSTHASH_H
/*
State structure
*/
#include "libdefs.h"
typedef struct {
mutils_word32 sum[8];
mutils_word32 hash[8];
mutils_word32 len[8];
mutils_word8 partial[32];
mutils_word32 partial_bytes;
} GostHashCtx;
/*
Compute some lookup-tables that are needed by all other functions.
*/
#if 0
void gosthash_init(void);
#endif
/*
Clear the state of the given context structure.
*/
void gosthash_reset(GostHashCtx * ctx);
/*
Mix in len bytes of data for the given buffer.
*/
void gosthash_update(GostHashCtx * ctx, __const mutils_word8 * buf, mutils_word32 len);
/*
Compute and save the 32-byte digest.
*/
void gosthash_final(GostHashCtx * ctx, mutils_word8 * digest);
#endif /*
GOSTHASH_H
*/
#endif
@@ -0,0 +1,46 @@
#if defined(ENABLE_HAVAL)
#if !defined(__MHASH_HAVAL_H)
#define __MHASH_HAVAL_H
typedef struct {
mutils_word16 passes, hashLength; /* HAVAL parameters */
mutils_word32 digest[8]; /* message digest (fingerprint) */
mutils_word8 block[128]; /* context data block */
mutils_word32 occupied; /* number of occupied bytes in the data block */
mutils_word32 bitCount[2]; /* 64-bit message bit count */
mutils_word32 temp[8]; /* temporary buffer */
} havalContext;
mutils_error havalInit256( havalContext *hcp);
mutils_error havalInit224( havalContext *hcp);
mutils_error havalInit192( havalContext *hcp);
mutils_error havalInit160( havalContext *hcp);
mutils_error havalInit128( havalContext *hcp);
mutils_error havalInit (havalContext *hcp, mutils_word32 passes, mutils_word32 length);
/* Initialize a HAVAL hashing context according to the desired */
/* number of passes and hash length. Returns: */
/* 0: no error. */
/* 1: hcp is NULL. */
/* 2: invalid number of passes (must be 3, 4, or 5). */
/* 3: invalid hash length (must be 128, 160, 192, 224, or 256). */
mutils_error havalUpdate (havalContext *hcp, __const mutils_word8 *dataBuffer, mutils_word32 dataLength);
/* Updates a HAVAL hashing context with a data block dataBuffer */
/* of length dataLength. Returns: */
/* 0: no error. */
/* 1: hcp is NULL. */
mutils_error havalFinal (havalContext *hcp, mutils_word8 *digest);
/* Finished evaluation of a HAVAL digest, clearing the context. */
/* The digest buffer must be large enough to hold the desired */
/* hash length. Returns: */
/* 0: no error. */
/* 1: hcp is NULL. */
/* 2: digest is NULL. */
#endif /* __MHASH_HAVAL_H */
#endif
@@ -0,0 +1,74 @@
#if !defined(__MHASH_INT)
#define __MHASH_INT
#include <mutils/mincludes.h>
#include <mutils/mutils.h>
typedef struct mhash_hash_entry mhash_hash_entry;
#define MHASH_FAILED ((MHASH) 0x0)
/* information prototypes */
mutils_word32 mhash_count(void);
mutils_word32 mhash_get_block_size(hashid type);
mutils_word8 *mhash_get_hash_name(hashid type);
/* initializing prototypes */
MHASH mhash_init(hashid type);
MHASH mhash_init_int(hashid type);
/* update prototype */
mutils_boolean mhash(MHASH thread, __const void *plaintext, mutils_word32 size);
/* finalizing prototype */
void *mhash_end(MHASH thread);
mutils_word32 mhash_get_hash_pblock(hashid type);
MHASH hmac_mhash_init(__const hashid type, void *key, mutils_word32 keysize,
mutils_word32 block);
void *hmac_mhash_end(MHASH thread);
/* Key generation functions */
#define EMPTY_PROTOTYPES 1
#if defined(EMPTY_PROTOTYPES)
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_keygen_count();
mutils_boolean mhash_keygen_uses_salt();
mutils_boolean mhash_keygen_uses_count();
mutils_boolean mhash_keygen_uses_hash_algorithm();
#else
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(hashid type);
mutils_word32 mhash_get_keygen_salt_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);
#endif
#endif
@@ -0,0 +1,53 @@
/* mhash_md2.h
*
* The MD2 hash function, described in RFC 1319.
*
* This code was originally written by Niels Möller for libnettle. It
* was altered by B. Poettering to fit the mhash interface. The original
* copyright notice follows.
*/
/* Copyright (C) 2003 Niels Möller
*
* The nettle library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version.
*
* The nettle 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 Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with the nettle library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
* MA 02111-1307, USA.
*/
#if defined(ENABLE_MD2)
#if !defined(__MHASH_MD2_H_INCLUDED)
#define __MHASH_MD2_H_INCLUDED
#define MD2_DIGEST_SIZE 16
#define MD2_DATA_SIZE 16
typedef struct md2_ctx
{
mutils_word8 C[MD2_DATA_SIZE];
mutils_word8 X[3 * MD2_DATA_SIZE];
mutils_word8 buffer[MD2_DATA_SIZE]; /* block buffer */
mutils_word32 index; /* pointer into buffer */
} MD2_CTX;
void md2_init(struct md2_ctx *ctx);
void md2_update(struct md2_ctx *ctx, __const mutils_word8 *data, mutils_word32 length);
void md2_digest(struct md2_ctx *ctx, mutils_word8 *digest);
#endif /* __MHASH_MD2_H_INCLUDED */
#endif
@@ -0,0 +1,21 @@
#if defined(ENABLE_MD4)
#if !defined(__MHASH_MD4_H)
#define __MHASH_MD4_H
struct MD4Context {
mutils_word32 buf[4];
mutils_word32 bits[2];
mutils_word8 in[64];
};
void MD4Init(struct MD4Context *context);
void MD4Update(struct MD4Context *context, mutils_word8 __const *buf, mutils_word32 len);
void MD4Final( struct MD4Context *context, mutils_word8 *digest);
void MD4Transform(mutils_word32 buf[4], mutils_word32 __const in[16]);
typedef struct MD4Context MD4_CTX;
#endif /* !__MHASH_MD4_H */
#endif
@@ -0,0 +1,24 @@
#if defined(ENABLE_MD5)
#if !defined(__MHASH_MD5_H)
#define __MHASH_MD5_H
struct MD5Context {
mutils_word32 buf[4];
mutils_word32 bits[2];
mutils_word8 in[64];
};
void MD5Init(struct MD5Context *context);
void MD5Update(struct MD5Context *context, mutils_word8 __const *buf, mutils_word32 len);
void MD5Final(struct MD5Context *context, mutils_word8 *digest);
void MD5Transform(mutils_word32 buf[4], mutils_word32 __const in[16]);
/*
* This is needed to make RSAREF happy on some MS-DOS compilers.
*/
typedef struct MD5Context MD5_CTX;
#endif /* !__MHASH_MD5_H */
#endif
@@ -0,0 +1,65 @@
/* mhash_ripemd.h
*
* RIPEMD-160 is a 160-bit cryptographic hash function, designed by Hans
* Dobbertin, Antoon Bosselaers, and Bart Preneel. It is intended to be
* used as a secure replacement for the 128-bit hash functions MD4, MD5,
* and RIPEMD
* See also: http://www.esat.kuleuven.ac.be/~bosselae/ripemd160.html
*
* RIPEMD-128 is a plug-in substitute for RIPEMD (or MD4 and MD5, for
* that matter) with a 128-bit result. 128-bit hash results do not
* offer sufficient protection for the next ten years, and
* applications using 128-bit hash functions should consider upgrading
* to a 160-bit hash function.
*
* RIPEMD-256 and RIPEMD-320 are optional extensions of, respectively,
* RIPEMD-128 and RIPEMD-160, and are intended for applications of
* hash functions that require a longer hash result without needing a
* larger security level.
*/
/* The following code was written by Nikos Mavroyanopoulos and B.
* Poettering for the mhash library.
*/
#if defined(ENABLE_RIPEMD)
#if !defined(__MHASH_RIPEMD_H)
#define __MHASH_RIPEMD_H
#include <libdefs.h>
/* The RIPEMD block sizes and message digest sizes, in bytes */
#define RIPEMD_DATASIZE 64
#define RIPEMD_DATALEN 16
#define RIPEMD128_DIGESTSIZE 16
#define RIPEMD160_DIGESTSIZE 20
#define RIPEMD256_DIGESTSIZE 32
#define RIPEMD320_DIGESTSIZE 40
#define RIPEMD_STATESIZE 10 /* state size in 32 bit words */
/* The structure for storing RIPEMD info */
typedef struct ripemd_ctx {
mutils_word32 digest[RIPEMD_STATESIZE]; /* chaining varialbles */
mutils_word64 bitcount; /* 64-bit bit counter */
mutils_word8 block[RIPEMD_DATASIZE]; /* RIPEMD data buffer */
mutils_word32 index; /* index into buffer */
mutils_word32 digest_len; /* determines the algorithm to use */
} RIPEMD_CTX;
void ripemd128_init(struct ripemd_ctx *ctx);
void ripemd160_init(struct ripemd_ctx *ctx);
void ripemd256_init(struct ripemd_ctx *ctx);
void ripemd320_init(struct ripemd_ctx *ctx);
void ripemd_update(struct ripemd_ctx *ctx, mutils_word8 *buffer, mutils_word32 len);
void ripemd_final(struct ripemd_ctx *ctx);
void ripemd_digest(struct ripemd_ctx *ctx, mutils_word8 *s);
#endif /* __MHASH_RIPEMD_H */
#endif
@@ -0,0 +1,59 @@
#if defined(ENABLE_SHA1)
#if !defined(__MHASH_SHA1_H)
#define __MHASH_SHA1_H
#include <libdefs.h>
#define sha_init mhash_sha_init
#define sha_update mhash_sha_update
#define sha_final mhash_sha_final
#define sha_digest mhash_sha_digest
#define sha_copy mhash_sha_copy
/* The SHA block size and message digest sizes, in bytes */
#define SHA_DATASIZE 64
#define SHA_DATALEN 16
#define SHA_DIGESTSIZE 20
#define SHA_DIGESTLEN 5
/* The structure for storing SHA info */
typedef struct sha_ctx {
mutils_word32 digest[SHA_DIGESTLEN]; /* Message digest */
mutils_word32 count_l, count_h; /* 64-bit block count */
mutils_word8 block[SHA_DATASIZE]; /* SHA data buffer */
mutils_word32 index; /* index into buffer */
} SHA_CTX;
void sha_init(struct sha_ctx *ctx);
void sha_update(struct sha_ctx *ctx, mutils_word8 *buffer, mutils_word32 len);
void sha_final(struct sha_ctx *ctx);
void sha_digest(struct sha_ctx *ctx, mutils_word8 *s);
void sha_copy(struct sha_ctx *dest, struct sha_ctx *src);
#if 1
#ifndef EXTRACT_UCHAR
#define EXTRACT_UCHAR(p) (*(mutils_word8 *)(p))
#endif
#define STRING2INT(s) ((((((EXTRACT_UCHAR(s) << 8) \
| EXTRACT_UCHAR(s+1)) << 8) \
| EXTRACT_UCHAR(s+2)) << 8) \
| EXTRACT_UCHAR(s+3))
#else
mutils_word32 STRING2INT(mutils_word8 *s)
{
mutils_word32 r;
mutils_word32 i;
for (i = 0, r = 0; i < 4; i++, s++)
r = (r << 8) | *s;
return r;
}
#endif
#endif
#endif
@@ -0,0 +1,59 @@
/* sha.h
*
* The sha1 and sha256 hash functions.
*/
/* nettle, low-level cryptographics library
*
* Copyright (C) 2001 Niels Möller
*
* The nettle library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version.
*
* The nettle 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 Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with the nettle library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
* MA 02111-1307, USA.
*/
#ifndef NETTLE_SHA_H_INCLUDED
#define NETTLE_SHA_H_INCLUDED
/* SHA256 */
#define SHA256_DIGEST_SIZE 32
#define SHA256_DATA_SIZE 64
/* Digest is kept internally as 8 32-bit words. */
#define _SHA256_DIGEST_LENGTH 8
typedef struct sha256_ctx
{
mutils_word32 state[_SHA256_DIGEST_LENGTH]; /* State variables */
mutils_word32 count_low, count_high; /* 64-bit block count */
mutils_word8 block[SHA256_DATA_SIZE]; /* SHA256 data buffer */
mutils_word32 index; /* index into buffer */
} SHA256_CTX;
void
sha256_init(struct sha256_ctx *ctx);
void
sha256_update(struct sha256_ctx *ctx, __const mutils_word8 *data, mutils_word32 length);
void
sha256_final(struct sha256_ctx *ctx);
void
sha256_digest(__const struct sha256_ctx *ctx, mutils_word8 *digest);
#endif /* NETTLE_SHA_H_INCLUDED */
@@ -0,0 +1,72 @@
/* mhash_sha256_sha224.h
*
* The sha256 and sha224 hash functions.
*/
/* nettle, low-level cryptographics library
*
* Copyright (C) 2001 Niels Möller
*
* The nettle library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version.
*
* The nettle 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 Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with the nettle library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
* MA 02111-1307, USA.
*/
/* The SHA224 support was added by B. Poettering in April 2004. */
#if defined(ENABLE_SHA256_SHA224)
#if !defined(__MHASH_SHA256_SHA224_H_INCLUDED)
#define __MHASH_SHA256_SHA224_H_INCLUDED
/* SHA256 and SHA224 */
#define SHA256_DIGEST_SIZE 32
#define SHA224_DIGEST_SIZE 28
#define SHA256_SHA224_DATA_SIZE 64
/* State is kept internally as 8 32-bit words. */
#define _SHA256_SHA224_DIGEST_LENGTH 8
typedef struct sha256_sha224_ctx
{
mutils_word32 state[_SHA256_SHA224_DIGEST_LENGTH]; /* State variables */
mutils_word64 bitcount; /* Bit counter */
mutils_word8 block[SHA256_SHA224_DATA_SIZE]; /* SHA256/224 data buffer */
mutils_word32 index; /* index into buffer */
} SHA256_SHA224_CTX;
void
sha256_init(struct sha256_sha224_ctx *ctx);
void
sha224_init(struct sha256_sha224_ctx *ctx);
void
sha256_sha224_update(struct sha256_sha224_ctx *ctx, __const mutils_word8 *data, mutils_word32 length);
void
sha256_sha224_final(struct sha256_sha224_ctx *ctx);
void
sha256_digest(__const struct sha256_sha224_ctx *ctx, mutils_word8 *digest);
void
sha224_digest(__const struct sha256_sha224_ctx *ctx, mutils_word8 *digest);
#endif /* __MHASH_SHA256_SHA224_H_INCLUDED */
#endif
@@ -0,0 +1,65 @@
/* mhash_sha512_sha384.h
*
* The sha512 and sha384 hash functions.
* Copyright (C) 2004 B. Poettering
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser 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(ENABLE_SHA512_SHA384)
#if !defined(__MHASH_SHA512_SHA384_H_INCLUDED)
#define __MHASH_SHA512_SHA384_H_INCLUDED
/* SHA512 and SHA384 */
#define SHA512_DIGEST_SIZE 64
#define SHA384_DIGEST_SIZE 48
#define SHA512_SHA384_DATA_SIZE 128
/* State is kept internally as 8 64-bit words. */
#define _SHA512_SHA384_STATE_LENGTH 8
typedef struct sha512_sha384_ctx
{
mutils_word64 state[_SHA512_SHA384_STATE_LENGTH]; /* State variables */
mutils_word64 bitcount_low, bitcount_high; /* Bit counter */
mutils_word8 block[SHA512_SHA384_DATA_SIZE]; /* SHA512/384 data buffer */
mutils_word32 index; /* index into buffer */
} SHA512_SHA384_CTX;
void
sha512_init(struct sha512_sha384_ctx *ctx);
void
sha384_init(struct sha512_sha384_ctx *ctx);
void
sha512_sha384_update(struct sha512_sha384_ctx *ctx, __const mutils_word8 *data,
mutils_word32 length);
void
sha512_sha384_final(struct sha512_sha384_ctx *ctx);
void
sha512_digest(__const struct sha512_sha384_ctx *ctx, mutils_word8 *digest);
void
sha384_digest(__const struct sha512_sha384_ctx *ctx, mutils_word8 *digest);
#endif /* __MHASH_SHA512_SHA384_H_INCLUDED */
#endif
@@ -0,0 +1,64 @@
/* mhash_snefru.h */
/* Snefru is a cryptographic hash function invented by Ralph Merkle
* which supports 128-bit and 256-bit output. It was named after the
* Egyptian Pharaoh Sneferu, continuing the tradition of the Khufu and
* Khafre block ciphers.
*
* Snefru is a public-domain one-way hash function. For more information see
* http://www.funet.fi/pub/crypt/mirrors/idea.sec.dsi.unimi.it/rpub.cl.msu.edu/
* crypt/docs/merkle-khufu-khafre-snefru.txt.gz
*
* This code was written by B. Poettering in 2004 for the mhash library. It
* is in the public domain.
*/
#if defined(ENABLE_SNEFRU)
#if !defined(__MHASH_SNEFRU_H_INCLUDED)
#define __MHASH_SNEFRU_H_INCLUDED
#define SNEFRU128_DATA_SIZE 48
#define SNEFRU128_DIGEST_SIZE 16
#define SNEFRU128_DIGEST_LEN (SNEFRU128_DIGEST_SIZE / 4)
#define SNEFRU256_DATA_SIZE 32
#define SNEFRU256_DIGEST_SIZE 32
#define SNEFRU256_DIGEST_LEN (SNEFRU256_DIGEST_SIZE / 4)
#define SNEFRU_BLOCK_SIZE 64
#define SNEFRU_BLOCK_LEN (SNEFRU_BLOCK_SIZE / 4)
typedef struct snefru_ctx
{
mutils_word8 buffer[SNEFRU128_DATA_SIZE]; /* buffer of data to hash */
mutils_word64 hashlen; /* number of hashed bits */
mutils_word32 index; /* index to buffer */
mutils_word32 hash[SNEFRU_BLOCK_LEN]; /* the hashing state */
} SNEFRU_CTX;
void
snefru_init(struct snefru_ctx *ctx);
void
snefru128_update(struct snefru_ctx *ctx, __const mutils_word8 *data, mutils_word32 length);
void
snefru256_update(struct snefru_ctx *ctx, __const mutils_word8 *data, mutils_word32 length);
void
snefru128_final(struct snefru_ctx *ctx);
void
snefru256_final(struct snefru_ctx *ctx);
void
snefru128_digest(__const struct snefru_ctx *ctx, mutils_word8 *digest);
void
snefru256_digest(__const struct snefru_ctx *ctx, mutils_word8 *digest);
#endif /* MHASH_SNEFRU_H_INCLUDED */
#endif
@@ -0,0 +1,66 @@
#if defined(ENABLE_TIGER)
#if !defined(__MHASH_TIGER_H)
#define __MHASH_TIGER_H
#include "libdefs.h"
#define TIGER_DIGESTSIZE 24
#define TIGER160_DIGESTSIZE 20
#define TIGER128_DIGESTSIZE 16
#define TIGER_DATASIZE 64
#ifdef TIGER_64BIT
#define h0init 0x0123456789ABCDEFLL
#define h1init 0xFEDCBA9876543210LL
#define h2init 0xF096A5B4C3B2E187LL
#define TIGER_DATALEN 8
#define TIGER_DIGESTLEN 3
#define TIGER128_DIGESTLEN 2
#define TIGER160_DIGESTLEN 2 /* 2.5 actually. */
typedef struct tiger_ctx {
mutils_word64 digest[TIGER_DIGESTLEN]; /* Message digest */
mutils_word64 count; /* 64-bit block count */
mutils_word8 block[TIGER_DATASIZE]; /* RIPEMD data buffer */
mutils_word32 index; /* index into buffer */
} TIGER_CTX;
#else
#define h0init 0x89ABCDEF;
#define h1init 0x01234567;
#define h2init 0x76543210;
#define h3init 0xFEDCBA98;
#define h4init 0xC3B2E187;
#define h5init 0xF096A5B4;
#define TIGER_DATALEN 16
#define TIGER_DIGESTLEN 6
#define TIGER128_DIGESTLEN 4
#define TIGER160_DIGESTLEN 5
typedef struct tiger_ctx {
mutils_word32 digest[TIGER_DIGESTLEN]; /* Message digest */
mutils_word32 count_l, count_h; /* 64-bit block count */
mutils_word8 block[TIGER_DATASIZE]; /* RIPEMD data buffer */
mutils_word32 index; /* index into buffer */
} TIGER_CTX;
#endif /* !TIGER_64BIT */
void tiger_digest(struct tiger_ctx *ctx, mutils_word8 * s);
void tiger_digest160(struct tiger_ctx *ctx, mutils_word8 * s);
void tiger_digest128(struct tiger_ctx *ctx, mutils_word8 * s);
void tiger_final(struct tiger_ctx *ctx);
void tiger_update(struct tiger_ctx *ctx, mutils_word8 * buffer, mutils_word32 len);
void tiger_init(struct tiger_ctx *ctx);
void tiger128_digest(struct tiger_ctx *ctx, mutils_word8 * s);
void tiger160_digest(struct tiger_ctx *ctx, mutils_word8 * s);
#endif
#endif
@@ -0,0 +1,46 @@
/* mhash_whirlpool.h
*
* The Whirlpool hashing function. A new 512-bit hashing function
* operating on messages less than 2 ** 256 bits in length. The
* function structure is designed according to the Wide Trail strategy
* and permits a wide variety of implementation trade-offs.
*
* The following code was written by B. Poettering for the mhash library.
* The code is in the public domain. See whirlpool.c for more information.
*
*/
#if defined(ENABLE_WHIRLPOOL)
#if !defined(__MHASH_WHIRLPOOL_H_INCLUDED)
#define __MHASH_WHIRLPOOL_H_INCLUDED
#define WHIRLPOOL_DIGEST_SIZE 64
#define WHIRLPOOL_DATA_SIZE 64
typedef struct whirlpool_ctx
{
mutils_word8 buffer[WHIRLPOOL_DATA_SIZE]; /* buffer of data to hash */
mutils_word64 hashlen[4]; /* number of hashed bits (256-bit) */
mutils_word32 index; /* index to buffer */
mutils_word64 hash[WHIRLPOOL_DIGEST_SIZE/8]; /* the hashing state */
} WHIRLPOOL_CTX;
void
whirlpool_init(struct whirlpool_ctx *ctx);
void
whirlpool_update(struct whirlpool_ctx *ctx, __const mutils_word8 *data, mutils_word32 length);
void
whirlpool_final(struct whirlpool_ctx *ctx);
void
whirlpool_digest(__const struct whirlpool_ctx *ctx, mutils_word8 *digest);
#endif /* __MHASH_WHIRLPOOL_H_INCLUDED */
#endif
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,371 @@
/* sha.c - Implementation of the Secure Hash Algorithm
*
* Copyright (C) 1995, A.M. Kuchling
*
* Distribute and use freely; there are no restrictions on further
* dissemination and usage except those imposed by the laws of your
* country of residence.
*
* Adapted to pike and some cleanup by Niels Möller.
*/
/* $Id: sha1.c,v 1.6 2006/01/08 09:08:29 imipak Exp $ */
/* SHA: NIST's Secure Hash Algorithm */
/* Based on SHA code originally posted to sci.crypt by Peter Gutmann
in message <30ajo5$oe8@ccu2.auckland.ac.nz>.
Modified to test for endianness on creation of SHA objects by AMK.
Also, the original specification of SHA was found to have a weakness
by NSA/NIST. This code implements the fixed version of SHA.
*/
/* Here's the first paragraph of Peter Gutmann's posting:
The following is my SHA (FIPS 180) code updated to allow use of the "fixed"
SHA, thanks to Jim Gillogly and an anonymous contributor for the information on
what's changed in the new version. The fix is a simple change which involves
adding a single rotate in the initial expansion function. It is unknown
whether this is an optimal solution to the problem which was discovered in the
SHA or whether it's simply a bandaid which fixes the problem with a minimum of
effort (for example the reengineering of a great many Capstone chips).
*/
#include "libdefs.h"
#ifdef ENABLE_SHA1
#include "mhash_sha1.h"
void sha_copy(struct sha_ctx *dest, struct sha_ctx *src)
{
mutils_word32 i;
dest->count_l=src->count_l;
dest->count_h=src->count_h;
for(i=0; i<SHA_DIGESTLEN; i++)
{
dest->digest[i]=src->digest[i];
}
for(i=0; i < src->index; i++)
{
dest->block[i] = src->block[i];
}
dest->index = src->index;
}
/* The SHA f()-functions. The f1 and f3 functions can be optimized to
save one boolean operation each - thanks to Rich Schroeppel,
rcs@cs.arizona.edu for discovering this */
#define f1(x,y,z) ( z ^ ( x & ( y ^ z ) ) ) /* Rounds 0-19 */
#define f2(x,y,z) ( x ^ y ^ z ) /* Rounds 20-39 */
#define f3(x,y,z) ( ( x & y ) | ( z & ( x | y ) ) ) /* Rounds 40-59 */
#define f4(x,y,z) ( x ^ y ^ z ) /* Rounds 60-79 */
/* The SHA Mysterious Constants */
#define K1 0x5A827999L /* Rounds 0-19 */
#define K2 0x6ED9EBA1L /* Rounds 20-39 */
#define K3 0x8F1BBCDCL /* Rounds 40-59 */
#define K4 0xCA62C1D6L /* Rounds 60-79 */
/* SHA initial values */
#define h0init 0x67452301L
#define h1init 0xEFCDAB89L
#define h2init 0x98BADCFEL
#define h3init 0x10325476L
#define h4init 0xC3D2E1F0L
/* 32-bit rotate left - kludged with shifts */
#define ROTL(n,X) ( ( (X) << (n) ) | ( (X) >> ( 32 - (n) ) ) )
/* The initial expanding function. The hash function is defined over an
80-word expanded input array W, where the first 16 are copies of the input
data, and the remaining 64 are defined by
W[ i ] = W[ i - 16 ] ^ W[ i - 14 ] ^ W[ i - 8 ] ^ W[ i - 3 ]
This implementation generates these values on the fly in a circular
buffer - thanks to Colin Plumb, colin@nyx10.cs.du.edu for this
optimization.
The updated SHA changes the expanding function by adding a rotate of 1
bit. Thanks to Jim Gillogly, jim@rand.org, and an anonymous contributor
for this information */
#define expand(W,i) ( W[ i & 15 ] = \
ROTL( 1, ( W[ i & 15 ] ^ W[ (i - 14) & 15 ] ^ \
W[ (i - 8) & 15 ] ^ W[ (i - 3) & 15 ] ) ) )
/* The prototype SHA sub-round. The fundamental sub-round is:
a' = e + ROTL( 5, a ) + f( b, c, d ) + k + data;
b' = a;
c' = ROTL( 30, b );
d' = c;
e' = d;
but this is implemented by unrolling the loop 5 times and renaming the
variables ( e, a, b, c, d ) = ( a', b', c', d', e' ) each iteration.
This code is then replicated 20 times for each of the 4 functions, using
the next 20 values from the W[] array each time */
#define subRound(a, b, c, d, e, f, k, data) \
( e += ROTL( 5, a ) + f( b, c, d ) + k + data, b = ROTL( 30, b ) )
/* Initialize the SHA values */
void sha_init(struct sha_ctx *ctx)
{
/* Set the h-vars to their initial values */
ctx->digest[ 0 ] = h0init;
ctx->digest[ 1 ] = h1init;
ctx->digest[ 2 ] = h2init;
ctx->digest[ 3 ] = h3init;
ctx->digest[ 4 ] = h4init;
/* Initialize bit count */
ctx->count_l = ctx->count_h = 0;
/* Initialize buffer */
ctx->index = 0;
}
/* Perform the SHA transformation. Note that this code, like MD5, seems to
break some optimizing compilers due to the complexity of the expressions
and the size of the basic block. It may be necessary to split it into
sections, e.g. based on the four subrounds
Note that this function destroys the data area */
static void sha_transform(struct sha_ctx *ctx, mutils_word32 *data )
{
register mutils_word32 A, B, C, D, E; /* Local vars */
/* Set up first buffer and local data buffer */
A = ctx->digest[0];
B = ctx->digest[1];
C = ctx->digest[2];
D = ctx->digest[3];
E = ctx->digest[4];
/* Heavy mangling, in 4 sub-rounds of 20 interations each. */
subRound( A, B, C, D, E, f1, K1, data[ 0] );
subRound( E, A, B, C, D, f1, K1, data[ 1] );
subRound( D, E, A, B, C, f1, K1, data[ 2] );
subRound( C, D, E, A, B, f1, K1, data[ 3] );
subRound( B, C, D, E, A, f1, K1, data[ 4] );
subRound( A, B, C, D, E, f1, K1, data[ 5] );
subRound( E, A, B, C, D, f1, K1, data[ 6] );
subRound( D, E, A, B, C, f1, K1, data[ 7] );
subRound( C, D, E, A, B, f1, K1, data[ 8] );
subRound( B, C, D, E, A, f1, K1, data[ 9] );
subRound( A, B, C, D, E, f1, K1, data[10] );
subRound( E, A, B, C, D, f1, K1, data[11] );
subRound( D, E, A, B, C, f1, K1, data[12] );
subRound( C, D, E, A, B, f1, K1, data[13] );
subRound( B, C, D, E, A, f1, K1, data[14] );
subRound( A, B, C, D, E, f1, K1, data[15] );
subRound( E, A, B, C, D, f1, K1, expand( data, 16 ) );
subRound( D, E, A, B, C, f1, K1, expand( data, 17 ) );
subRound( C, D, E, A, B, f1, K1, expand( data, 18 ) );
subRound( B, C, D, E, A, f1, K1, expand( data, 19 ) );
subRound( A, B, C, D, E, f2, K2, expand( data, 20 ) );
subRound( E, A, B, C, D, f2, K2, expand( data, 21 ) );
subRound( D, E, A, B, C, f2, K2, expand( data, 22 ) );
subRound( C, D, E, A, B, f2, K2, expand( data, 23 ) );
subRound( B, C, D, E, A, f2, K2, expand( data, 24 ) );
subRound( A, B, C, D, E, f2, K2, expand( data, 25 ) );
subRound( E, A, B, C, D, f2, K2, expand( data, 26 ) );
subRound( D, E, A, B, C, f2, K2, expand( data, 27 ) );
subRound( C, D, E, A, B, f2, K2, expand( data, 28 ) );
subRound( B, C, D, E, A, f2, K2, expand( data, 29 ) );
subRound( A, B, C, D, E, f2, K2, expand( data, 30 ) );
subRound( E, A, B, C, D, f2, K2, expand( data, 31 ) );
subRound( D, E, A, B, C, f2, K2, expand( data, 32 ) );
subRound( C, D, E, A, B, f2, K2, expand( data, 33 ) );
subRound( B, C, D, E, A, f2, K2, expand( data, 34 ) );
subRound( A, B, C, D, E, f2, K2, expand( data, 35 ) );
subRound( E, A, B, C, D, f2, K2, expand( data, 36 ) );
subRound( D, E, A, B, C, f2, K2, expand( data, 37 ) );
subRound( C, D, E, A, B, f2, K2, expand( data, 38 ) );
subRound( B, C, D, E, A, f2, K2, expand( data, 39 ) );
subRound( A, B, C, D, E, f3, K3, expand( data, 40 ) );
subRound( E, A, B, C, D, f3, K3, expand( data, 41 ) );
subRound( D, E, A, B, C, f3, K3, expand( data, 42 ) );
subRound( C, D, E, A, B, f3, K3, expand( data, 43 ) );
subRound( B, C, D, E, A, f3, K3, expand( data, 44 ) );
subRound( A, B, C, D, E, f3, K3, expand( data, 45 ) );
subRound( E, A, B, C, D, f3, K3, expand( data, 46 ) );
subRound( D, E, A, B, C, f3, K3, expand( data, 47 ) );
subRound( C, D, E, A, B, f3, K3, expand( data, 48 ) );
subRound( B, C, D, E, A, f3, K3, expand( data, 49 ) );
subRound( A, B, C, D, E, f3, K3, expand( data, 50 ) );
subRound( E, A, B, C, D, f3, K3, expand( data, 51 ) );
subRound( D, E, A, B, C, f3, K3, expand( data, 52 ) );
subRound( C, D, E, A, B, f3, K3, expand( data, 53 ) );
subRound( B, C, D, E, A, f3, K3, expand( data, 54 ) );
subRound( A, B, C, D, E, f3, K3, expand( data, 55 ) );
subRound( E, A, B, C, D, f3, K3, expand( data, 56 ) );
subRound( D, E, A, B, C, f3, K3, expand( data, 57 ) );
subRound( C, D, E, A, B, f3, K3, expand( data, 58 ) );
subRound( B, C, D, E, A, f3, K3, expand( data, 59 ) );
subRound( A, B, C, D, E, f4, K4, expand( data, 60 ) );
subRound( E, A, B, C, D, f4, K4, expand( data, 61 ) );
subRound( D, E, A, B, C, f4, K4, expand( data, 62 ) );
subRound( C, D, E, A, B, f4, K4, expand( data, 63 ) );
subRound( B, C, D, E, A, f4, K4, expand( data, 64 ) );
subRound( A, B, C, D, E, f4, K4, expand( data, 65 ) );
subRound( E, A, B, C, D, f4, K4, expand( data, 66 ) );
subRound( D, E, A, B, C, f4, K4, expand( data, 67 ) );
subRound( C, D, E, A, B, f4, K4, expand( data, 68 ) );
subRound( B, C, D, E, A, f4, K4, expand( data, 69 ) );
subRound( A, B, C, D, E, f4, K4, expand( data, 70 ) );
subRound( E, A, B, C, D, f4, K4, expand( data, 71 ) );
subRound( D, E, A, B, C, f4, K4, expand( data, 72 ) );
subRound( C, D, E, A, B, f4, K4, expand( data, 73 ) );
subRound( B, C, D, E, A, f4, K4, expand( data, 74 ) );
subRound( A, B, C, D, E, f4, K4, expand( data, 75 ) );
subRound( E, A, B, C, D, f4, K4, expand( data, 76 ) );
subRound( D, E, A, B, C, f4, K4, expand( data, 77 ) );
subRound( C, D, E, A, B, f4, K4, expand( data, 78 ) );
subRound( B, C, D, E, A, f4, K4, expand( data, 79 ) );
/* Build message digest */
ctx->digest[0] += A;
ctx->digest[1] += B;
ctx->digest[2] += C;
ctx->digest[3] += D;
ctx->digest[4] += E;
}
static void sha_block(struct sha_ctx *ctx, mutils_word8 *block)
{
mutils_word32 data[SHA_DATALEN];
mutils_word32 i;
/* Update block count */
if (!++ctx->count_l)
{
++ctx->count_h;
}
/* Endian independent conversion */
for (i = 0; i<SHA_DATALEN; i++, block += 4)
{
data[i] = STRING2INT(block);
}
sha_transform(ctx, data);
}
void sha_update(struct sha_ctx *ctx, mutils_word8 *buffer, mutils_word32 len)
{
if (ctx->index)
{ /* Try to fill partial block */
mutils_word32 left = SHA_DATASIZE - ctx->index;
if (len < left)
{
mutils_memcpy(ctx->block + ctx->index, buffer, len);
ctx->index += len;
return; /* Finished */
}
else
{
mutils_memcpy(ctx->block + ctx->index, buffer, left);
sha_block(ctx, ctx->block);
buffer += left;
len -= left;
}
}
while (len >= SHA_DATASIZE)
{
sha_block(ctx, buffer);
buffer += SHA_DATASIZE;
len -= SHA_DATASIZE;
}
if ((ctx->index = len)) /* This assignment is intended */
{
/* Buffer leftovers */
mutils_memcpy(ctx->block, buffer, len);
}
}
/* Final wrapup - pad to SHA_DATASIZE-byte boundary with the bit pattern
1 0* (64-bit count of bits processed, MSB-first) */
void sha_final(struct sha_ctx *ctx)
{
mutils_word32 data[SHA_DATALEN];
mutils_word32 i;
mutils_word32 words;
i = ctx->index;
/* Set the first char of padding to 0x80. This is safe since there is
always at least one byte free */
ctx->block[i++] = 0x80;
/* Fill rest of word */
for( ; i & 3; i++)
{
ctx->block[i] = 0;
}
/* i is now a multiple of the word size 4 */
words = i >> 2;
for (i = 0; i < words; i++)
{
data[i] = STRING2INT(ctx->block + 4*i);
}
if (words > (SHA_DATALEN-2))
{ /* No room for length in this block. Process it and
* pad with another one */
for (i = words ; i < SHA_DATALEN; i++)
{
data[i] = 0;
}
sha_transform(ctx, data);
for (i = 0; i < (SHA_DATALEN-2); i++)
{
data[i] = 0;
}
}
else
{
for (i = words ; i < SHA_DATALEN - 2; i++)
{
data[i] = 0;
}
}
/* Theres 512 = 2^9 bits in one block */
data[SHA_DATALEN-2] = (ctx->count_h << 9) | (ctx->count_l >> 23);
data[SHA_DATALEN-1] = (ctx->count_l << 9) | (ctx->index << 3);
sha_transform(ctx, data);
}
void sha_digest(struct sha_ctx *ctx, mutils_word8 *s)
{
mutils_word32 i;
if (s!=NULL)
{
for (i = 0; i < SHA_DIGESTLEN; i++)
{
*s++ = ctx->digest[i] >> 24;
*s++ = 0xff & (ctx->digest[i] >> 16);
*s++ = 0xff & (ctx->digest[i] >> 8);
*s++ = 0xff & ctx->digest[i];
}
}
}
#endif /* ENABLE_SHA1 */
@@ -0,0 +1,318 @@
/* sha256.h
*
* The sha256 hash function.
*/
/* nettle, low-level cryptographics library
*
* Copyright (C) 2001 Niels Möller
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* The nettle 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 Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with the nettle library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
* MA 02111-1307, USA.
*/
/* Modelled after the sha1.c code by Peter Gutmann. */
/* This has been modified in order to fit in mhash.
* --nmav.
*/
#include "libdefs.h"
#ifdef ENABLE_SHA256
#include "mhash_sha256.h"
#include "mhash_sha1.h"
/* A block, treated as a sequence of 32-bit words. */
#define SHA256_DATA_LENGTH 16
#define ROTR(n,x) ((x)>>(n) | ((x)<<(32-(n))))
#define SHR(n,x) ((x)>>(n))
/* The SHA256 functions. The Choice function is the same as the SHA1
function f1, and the majority function is the same as the SHA1 f3
function. They can be optimized to save one boolean operation each
- thanks to Rich Schroeppel, rcs@cs.arizona.edu for discovering
this */
/* #define Choice(x,y,z) ( ( (x) & (y) ) | ( ~(x) & (z) ) ) */
#define Choice(x,y,z) ( (z) ^ ( (x) & ( (y) ^ (z) ) ) )
/* #define Majority(x,y,z) ( ((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z)) ) */
#define Majority(x,y,z) ( ((x) & (y)) ^ ((z) & ((x) ^ (y))) )
#define S0(x) (ROTR(2,(x)) ^ ROTR(13,(x)) ^ ROTR(22,(x)))
#define S1(x) (ROTR(6,(x)) ^ ROTR(11,(x)) ^ ROTR(25,(x)))
#define s0(x) (ROTR(7,(x)) ^ ROTR(18,(x)) ^ SHR(3,(x)))
#define s1(x) (ROTR(17,(x)) ^ ROTR(19,(x)) ^ SHR(10,(x)))
/* Generated by the shadata program. */
static __const mutils_word32 K[64] = {
0x428a2f98UL, 0x71374491UL, 0xb5c0fbcfUL, 0xe9b5dba5UL,
0x3956c25bUL, 0x59f111f1UL, 0x923f82a4UL, 0xab1c5ed5UL,
0xd807aa98UL, 0x12835b01UL, 0x243185beUL, 0x550c7dc3UL,
0x72be5d74UL, 0x80deb1feUL, 0x9bdc06a7UL, 0xc19bf174UL,
0xe49b69c1UL, 0xefbe4786UL, 0xfc19dc6UL, 0x240ca1ccUL,
0x2de92c6fUL, 0x4a7484aaUL, 0x5cb0a9dcUL, 0x76f988daUL,
0x983e5152UL, 0xa831c66dUL, 0xb00327c8UL, 0xbf597fc7UL,
0xc6e00bf3UL, 0xd5a79147UL, 0x6ca6351UL, 0x14292967UL,
0x27b70a85UL, 0x2e1b2138UL, 0x4d2c6dfcUL, 0x53380d13UL,
0x650a7354UL, 0x766a0abbUL, 0x81c2c92eUL, 0x92722c85UL,
0xa2bfe8a1UL, 0xa81a664bUL, 0xc24b8b70UL, 0xc76c51a3UL,
0xd192e819UL, 0xd6990624UL, 0xf40e3585UL, 0x106aa070UL,
0x19a4c116UL, 0x1e376c08UL, 0x2748774cUL, 0x34b0bcb5UL,
0x391c0cb3UL, 0x4ed8aa4aUL, 0x5b9cca4fUL, 0x682e6ff3UL,
0x748f82eeUL, 0x78a5636fUL, 0x84c87814UL, 0x8cc70208UL,
0x90befffaUL, 0xa4506cebUL, 0xbef9a3f7UL, 0xc67178f2UL,
};
/* The initial expanding function. The hash function is defined over an
64-word expanded input array W, where the first 16 are copies of the input
data, and the remaining 64 are defined by
W[ t ] = s1(W[t-2] + W[t-7] + s0(W[i-15] + W[i-16]
This implementation generates these values on the fly in a circular
buffer - thanks to Colin Plumb, colin@nyx10.cs.du.edu for this
optimization.
*/
#define EXPAND(W,i) \
( W[(i) & 15 ] += (s1(W[((i)-2) & 15]) + W[((i)-7) & 15] + s0(W[((i)-15) & 15])) )
/* The prototype SHA sub-round. The fundamental sub-round is:
T1 = h + S1(e) + Choice(e,f,g) + K[t] + W[t]
T2 = S0(a) + Majority(a,b,c)
a' = T1+T2
b' = a
c' = b
d' = c
e' = d + T1
f' = e
g' = f
h' = g
but this is implemented by unrolling the loop 8 times and renaming
the variables
( h, a, b, c, d, e, f, g ) = ( a, b, c, d, e, f, g, h ) each
iteration. This code is then replicated 8, using the next 8 values
from the W[] array each time */
/* FIXME: We can probably reorder this to optimize away at least one
* of T1 and T2. It's crucial that DATA is only used once, as that
* argument will have side effects. */
#define ROUND(a,b,c,d,e,f,g,h,k,data) do { \
mutils_word32 T1 = h + S1(e) + Choice(e,f,g) + k + data; \
mutils_word32 T2 = S0(a) + Majority(a,b,c); \
d += T1; \
h = T1 + T2; \
} while (0)
/* Initialize the SHA values */
void sha256_init(struct sha256_ctx *ctx)
{
/* Initial values, also generated by the shadata program. */
static __const mutils_word32 H0[_SHA256_DIGEST_LENGTH] = {
0x6a09e667UL, 0xbb67ae85UL, 0x3c6ef372UL, 0xa54ff53aUL,
0x510e527fUL, 0x9b05688cUL, 0x1f83d9abUL, 0x5be0cd19UL,
};
mutils_memcpy(ctx->state, H0, sizeof(H0));
/* Initialize bit count */
ctx->count_low = ctx->count_high = 0;
/* Initialize buffer */
ctx->index = 0;
}
/* Perform the SHA transformation. Note that this code, like MD5, seems to
break some optimizing compilers due to the complexity of the expressions
and the size of the basic block. It may be necessary to split it into
sections, e.g. based on the four subrounds
Note that this function destroys the data area */
static void sha256_transform(mutils_word32 *state, mutils_word32 *data)
{
mutils_word32 A, B, C, D, E, F, G, H; /* Local vars */
mutils_word8 i;
__const mutils_word32 *k;
mutils_word32 *d;
/* Set up first buffer and local data buffer */
A = state[0];
B = state[1];
C = state[2];
D = state[3];
E = state[4];
F = state[5];
G = state[6];
H = state[7];
/* Heavy mangling */
/* First 16 subrounds that act on the original data */
for (i = 0, k = K, d = data; i < 16; i += 8, k += 8, d += 8) {
ROUND(A, B, C, D, E, F, G, H, k[0], d[0]);
ROUND(H, A, B, C, D, E, F, G, k[1], d[1]);
ROUND(G, H, A, B, C, D, E, F, k[2], d[2]);
ROUND(F, G, H, A, B, C, D, E, k[3], d[3]);
ROUND(E, F, G, H, A, B, C, D, k[4], d[4]);
ROUND(D, E, F, G, H, A, B, C, k[5], d[5]);
ROUND(C, D, E, F, G, H, A, B, k[6], d[6]);
ROUND(B, C, D, E, F, G, H, A, k[7], d[7]);
}
for (; i < 64; i += 16, k += 16) {
ROUND(A, B, C, D, E, F, G, H, k[0], EXPAND(data, 0));
ROUND(H, A, B, C, D, E, F, G, k[1], EXPAND(data, 1));
ROUND(G, H, A, B, C, D, E, F, k[2], EXPAND(data, 2));
ROUND(F, G, H, A, B, C, D, E, k[3], EXPAND(data, 3));
ROUND(E, F, G, H, A, B, C, D, k[4], EXPAND(data, 4));
ROUND(D, E, F, G, H, A, B, C, k[5], EXPAND(data, 5));
ROUND(C, D, E, F, G, H, A, B, k[6], EXPAND(data, 6));
ROUND(B, C, D, E, F, G, H, A, k[7], EXPAND(data, 7));
ROUND(A, B, C, D, E, F, G, H, k[8], EXPAND(data, 8));
ROUND(H, A, B, C, D, E, F, G, k[9], EXPAND(data, 9));
ROUND(G, H, A, B, C, D, E, F, k[10], EXPAND(data, 10));
ROUND(F, G, H, A, B, C, D, E, k[11], EXPAND(data, 11));
ROUND(E, F, G, H, A, B, C, D, k[12], EXPAND(data, 12));
ROUND(D, E, F, G, H, A, B, C, k[13], EXPAND(data, 13));
ROUND(C, D, E, F, G, H, A, B, k[14], EXPAND(data, 14));
ROUND(B, C, D, E, F, G, H, A, k[15], EXPAND(data, 15));
}
/* Update state */
state[0] += A;
state[1] += B;
state[2] += C;
state[3] += D;
state[4] += E;
state[5] += F;
state[6] += G;
state[7] += H;
}
static void sha256_block(struct sha256_ctx *ctx, __const mutils_word8 *block)
{
mutils_word32 data[SHA256_DATA_LENGTH];
mutils_word16 i;
/* Update block count */
if (!++ctx->count_low)
++ctx->count_high;
/* Endian independent conversion */
for (i = 0; i < SHA256_DATA_LENGTH; i++, block += 4)
data[i] = STRING2INT(block);
sha256_transform(ctx->state, data);
}
void
sha256_update(struct sha256_ctx *ctx, __const mutils_word8 *buffer, mutils_word32 length)
{
mutils_word32 left;
if (ctx->index) { /* Try to fill partial block */
left = SHA256_DATA_SIZE - ctx->index;
if (length < left) {
mutils_memcpy(ctx->block + ctx->index, buffer, length);
ctx->index += length;
return; /* Finished */
} else {
mutils_memcpy(ctx->block + ctx->index, buffer, left);
sha256_block(ctx, ctx->block);
buffer += left;
length -= left;
}
}
while (length >= SHA256_DATA_SIZE) {
sha256_block(ctx, buffer);
buffer += SHA256_DATA_SIZE;
length -= SHA256_DATA_SIZE;
}
/* Buffer leftovers */
/* NOTE: The corresponding sha1 code checks for the special case length == 0.
* That seems supoptimal, as I suspect it increases the number of branches. */
mutils_memcpy(ctx->block, buffer, length);
ctx->index = length;
}
/* Final wrapup - pad to SHA1_DATA_SIZE-byte boundary with the bit pattern
1 0* (64-bit count of bits processed, MSB-first) */
void sha256_final(struct sha256_ctx *ctx)
{
mutils_word32 data[SHA256_DATA_LENGTH];
mutils_word32 i;
mutils_word32 words;
i = ctx->index;
/* Set the first char of padding to 0x80. This is safe since there is
always at least one byte free */
/* assert(i < SHA256_DATA_SIZE);
*/
ctx->block[i++] = 0x80;
/* Fill rest of word */
for (; i & 3; i++)
ctx->block[i] = 0;
/* i is now a multiple of the word size 4 */
words = i >> 2;
for (i = 0; i < words; i++)
data[i] = STRING2INT(ctx->block + 4 * i);
if (words > (SHA256_DATA_LENGTH - 2)) { /* No room for length in this block. Process it and
* pad with another one */
for (i = words; i < SHA256_DATA_LENGTH; i++)
data[i] = 0;
sha256_transform(ctx->state, data);
for (i = 0; i < (SHA256_DATA_LENGTH - 2); i++)
data[i] = 0;
} else
for (i = words; i < SHA256_DATA_LENGTH - 2; i++)
data[i] = 0;
/* There are 512 = 2^9 bits in one block */
data[SHA256_DATA_LENGTH - 2] =
(ctx->count_high << 9) | (ctx->count_low >> 23);
data[SHA256_DATA_LENGTH - 1] =
(ctx->count_low << 9) | (ctx->index << 3);
sha256_transform(ctx->state, data);
}
void sha256_digest(__const struct sha256_ctx *ctx, mutils_word8 *s)
{
mutils_word32 i;
if (s!=NULL)
for (i = 0; i < _SHA256_DIGEST_LENGTH; i++) {
*s++ = ctx->state[i] >> 24;
*s++ = 0xff & (ctx->state[i] >> 16);
*s++ = 0xff & (ctx->state[i] >> 8);
*s++ = 0xff & ctx->state[i];
}
}
#endif /* ENABLE_SHA256 */
@@ -0,0 +1,346 @@
/* sha256_sha224.c
*
* The sha256 and sha224 hash functions.
*/
/* nettle, low-level cryptographics library
*
* Copyright (C) 2001 Niels Möller
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* The nettle 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 Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with the nettle library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
* MA 02111-1307, USA.
*/
/* Modelled after the sha1.c code by Peter Gutmann. */
/* This has been modified in order to fit in mhash.
* --nmav.
*/
/* The SHA224 support was added by B. Poettering in April 2004. */
#include "libdefs.h"
#ifdef ENABLE_SHA256_SHA224
#include "mhash_sha256_sha224.h"
#include "mhash_sha1.h"
/* A block, treated as a sequence of 32-bit words. */
#define SHA256_SHA224_DATA_LENGTH 16
#define ROTR(n,x) ((x)>>(n) | ((x)<<(32-(n))))
#define SHR(n,x) ((x)>>(n))
/* The SHA256/224 functions. The Choice function is the same as the SHA1
function f1, and the majority function is the same as the SHA1 f3
function. They can be optimized to save one boolean operation each
- thanks to Rich Schroeppel, rcs@cs.arizona.edu for discovering
this */
/* #define Choice(x,y,z) ( ( (x) & (y) ) | ( ~(x) & (z) ) ) */
#define Choice(x,y,z) ( (z) ^ ( (x) & ( (y) ^ (z) ) ) )
/* #define Majority(x,y,z) ( ((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z)) ) */
#define Majority(x,y,z) ( ((x) & (y)) ^ ((z) & ((x) ^ (y))) )
#define S0(x) (ROTR(2,(x)) ^ ROTR(13,(x)) ^ ROTR(22,(x)))
#define S1(x) (ROTR(6,(x)) ^ ROTR(11,(x)) ^ ROTR(25,(x)))
#define s0(x) (ROTR(7,(x)) ^ ROTR(18,(x)) ^ SHR(3,(x)))
#define s1(x) (ROTR(17,(x)) ^ ROTR(19,(x)) ^ SHR(10,(x)))
/* Generated by the shadata program. */
static __const mutils_word32 K[64] = {
0x428a2f98UL, 0x71374491UL, 0xb5c0fbcfUL, 0xe9b5dba5UL,
0x3956c25bUL, 0x59f111f1UL, 0x923f82a4UL, 0xab1c5ed5UL,
0xd807aa98UL, 0x12835b01UL, 0x243185beUL, 0x550c7dc3UL,
0x72be5d74UL, 0x80deb1feUL, 0x9bdc06a7UL, 0xc19bf174UL,
0xe49b69c1UL, 0xefbe4786UL, 0xfc19dc6UL, 0x240ca1ccUL,
0x2de92c6fUL, 0x4a7484aaUL, 0x5cb0a9dcUL, 0x76f988daUL,
0x983e5152UL, 0xa831c66dUL, 0xb00327c8UL, 0xbf597fc7UL,
0xc6e00bf3UL, 0xd5a79147UL, 0x6ca6351UL, 0x14292967UL,
0x27b70a85UL, 0x2e1b2138UL, 0x4d2c6dfcUL, 0x53380d13UL,
0x650a7354UL, 0x766a0abbUL, 0x81c2c92eUL, 0x92722c85UL,
0xa2bfe8a1UL, 0xa81a664bUL, 0xc24b8b70UL, 0xc76c51a3UL,
0xd192e819UL, 0xd6990624UL, 0xf40e3585UL, 0x106aa070UL,
0x19a4c116UL, 0x1e376c08UL, 0x2748774cUL, 0x34b0bcb5UL,
0x391c0cb3UL, 0x4ed8aa4aUL, 0x5b9cca4fUL, 0x682e6ff3UL,
0x748f82eeUL, 0x78a5636fUL, 0x84c87814UL, 0x8cc70208UL,
0x90befffaUL, 0xa4506cebUL, 0xbef9a3f7UL, 0xc67178f2UL,
};
/* The initial expanding function. The hash function is defined over an
64-word expanded input array W, where the first 16 are copies of the input
data, and the remaining 48 are defined by
W[ t ] = s1(W[t-2] + W[t-7] + s0(W[i-15] + W[i-16]
This implementation generates these values on the fly in a circular
buffer - thanks to Colin Plumb, colin@nyx10.cs.du.edu for this
optimization.
*/
#define EXPAND(W,i) \
( W[(i) & 15 ] += (s1(W[((i)-2) & 15]) + W[((i)-7) & 15] + s0(W[((i)-15) & 15])) )
/* The prototype SHA sub-round. The fundamental sub-round is:
T1 = h + S1(e) + Choice(e,f,g) + K[t] + W[t]
T2 = S0(a) + Majority(a,b,c)
a' = T1 + T2
b' = a
c' = b
d' = c
e' = d + T1
f' = e
g' = f
h' = g
but this is implemented by unrolling the loop 8 times and renaming
the variables
( h, a, b, c, d, e, f, g ) = ( a, b, c, d, e, f, g, h ) each
iteration. This code is then replicated 8, using the next 8 values
from the W[] array each time */
#define ROUND(a,b,c,d,e,f,g,h,k,data) do { \
mutils_word32 T1 = h + S1(e) + Choice(e,f,g) + k + data; \
d += T1; \
h = T1 + S0(a) + Majority(a,b,c); \
} while (0)
/* Initialize the SHA values */
void sha256_init(struct sha256_sha224_ctx *ctx)
{
/* Initial values, also generated by the shadata program. */
static __const mutils_word32 H0[_SHA256_SHA224_DIGEST_LENGTH] = {
0x6a09e667UL, 0xbb67ae85UL, 0x3c6ef372UL, 0xa54ff53aUL,
0x510e527fUL, 0x9b05688cUL, 0x1f83d9abUL, 0x5be0cd19UL,
};
mutils_memcpy(ctx->state, H0, sizeof(H0));
/* Initialize bit count */
ctx->bitcount = 0;
/* Initialize buffer */
ctx->index = 0;
}
void sha224_init(struct sha256_sha224_ctx *ctx)
{
/* Initial values, copied from fips180-2. */
static __const mutils_word32 H0[_SHA256_SHA224_DIGEST_LENGTH] = {
0xc1059ed8UL, 0x367cd507UL, 0x3070dd17UL, 0xf70e5939UL,
0xffc00b31UL, 0x68581511UL, 0x64f98fa7UL, 0xbefa4fa4U
};
mutils_memcpy(ctx->state, H0, sizeof(H0));
/* Initialize bit count */
ctx->bitcount = 0;
/* Initialize buffer */
ctx->index = 0;
}
/* Perform the SHA transformation. Note that this code, like MD5, seems to
break some optimizing compilers due to the complexity of the expressions
and the size of the basic block. It may be necessary to split it into
sections, e.g. based on the four subrounds
Note that this function destroys the data area */
static void sha256_sha224_transform(mutils_word32 *state, mutils_word32 *data)
{
mutils_word32 A, B, C, D, E, F, G, H; /* Local vars */
mutils_word8 i;
__const mutils_word32 *k;
mutils_word32 *d;
/* Set up first buffer and local data buffer */
A = state[0];
B = state[1];
C = state[2];
D = state[3];
E = state[4];
F = state[5];
G = state[6];
H = state[7];
/* Heavy mangling */
/* First 16 subrounds that act on the original data */
for (i = 0, k = K, d = data; i < 16; i += 8, k += 8, d += 8) {
ROUND(A, B, C, D, E, F, G, H, k[0], d[0]);
ROUND(H, A, B, C, D, E, F, G, k[1], d[1]);
ROUND(G, H, A, B, C, D, E, F, k[2], d[2]);
ROUND(F, G, H, A, B, C, D, E, k[3], d[3]);
ROUND(E, F, G, H, A, B, C, D, k[4], d[4]);
ROUND(D, E, F, G, H, A, B, C, k[5], d[5]);
ROUND(C, D, E, F, G, H, A, B, k[6], d[6]);
ROUND(B, C, D, E, F, G, H, A, k[7], d[7]);
}
for (; i < 64; i += 16, k += 16) {
ROUND(A, B, C, D, E, F, G, H, k[0], EXPAND(data, 0));
ROUND(H, A, B, C, D, E, F, G, k[1], EXPAND(data, 1));
ROUND(G, H, A, B, C, D, E, F, k[2], EXPAND(data, 2));
ROUND(F, G, H, A, B, C, D, E, k[3], EXPAND(data, 3));
ROUND(E, F, G, H, A, B, C, D, k[4], EXPAND(data, 4));
ROUND(D, E, F, G, H, A, B, C, k[5], EXPAND(data, 5));
ROUND(C, D, E, F, G, H, A, B, k[6], EXPAND(data, 6));
ROUND(B, C, D, E, F, G, H, A, k[7], EXPAND(data, 7));
ROUND(A, B, C, D, E, F, G, H, k[8], EXPAND(data, 8));
ROUND(H, A, B, C, D, E, F, G, k[9], EXPAND(data, 9));
ROUND(G, H, A, B, C, D, E, F, k[10], EXPAND(data, 10));
ROUND(F, G, H, A, B, C, D, E, k[11], EXPAND(data, 11));
ROUND(E, F, G, H, A, B, C, D, k[12], EXPAND(data, 12));
ROUND(D, E, F, G, H, A, B, C, k[13], EXPAND(data, 13));
ROUND(C, D, E, F, G, H, A, B, k[14], EXPAND(data, 14));
ROUND(B, C, D, E, F, G, H, A, k[15], EXPAND(data, 15));
}
/* Update state */
state[0] += A;
state[1] += B;
state[2] += C;
state[3] += D;
state[4] += E;
state[5] += F;
state[6] += G;
state[7] += H;
}
static void sha256_sha224_block(struct sha256_sha224_ctx *ctx, __const mutils_word8 *block)
{
mutils_word32 data[SHA256_SHA224_DATA_LENGTH];
mutils_word32 i;
/* Update block count */
ctx->bitcount += 512;
/* Endian independent conversion */
for (i = 0; i < SHA256_SHA224_DATA_LENGTH; i++, block += 4)
data[i] = STRING2INT(block);
sha256_sha224_transform(ctx->state, data);
}
void
sha256_sha224_update(struct sha256_sha224_ctx *ctx, __const mutils_word8 *buffer, mutils_word32 length)
{
mutils_word32 left;
if (ctx->index) { /* Try to fill partial block */
left = SHA256_SHA224_DATA_SIZE - ctx->index;
if (length < left) {
mutils_memcpy(ctx->block + ctx->index, buffer, length);
ctx->index += length;
return; /* Finished */
} else {
mutils_memcpy(ctx->block + ctx->index, buffer, left);
sha256_sha224_block(ctx, ctx->block);
buffer += left;
length -= left;
}
}
while (length >= SHA256_SHA224_DATA_SIZE) {
sha256_sha224_block(ctx, buffer);
buffer += SHA256_SHA224_DATA_SIZE;
length -= SHA256_SHA224_DATA_SIZE;
}
/* Buffer leftovers */
/* NOTE: The corresponding sha1 code checks for the special case length == 0.
* That seems supoptimal, as I suspect it increases the number of branches. */
mutils_memcpy(ctx->block, buffer, length);
ctx->index = length;
}
/* Final wrapup - pad to SHA256_SHA224_DATA_SIZE-byte boundary with the bit pattern
1 0* (64-bit count of bits processed, MSB-first) */
void sha256_sha224_final(struct sha256_sha224_ctx *ctx)
{
mutils_word32 data[SHA256_SHA224_DATA_LENGTH];
mutils_word32 i;
mutils_word32 words;
i = ctx->index;
/* Set the first char of padding to 0x80. This is safe since there is
always at least one byte free */
/* assert(i < SHA256_SHA224_DATA_SIZE);
*/
ctx->block[i++] = 0x80;
/* Fill rest of word */
for (; i & 3; i++)
ctx->block[i] = 0;
/* i is now a multiple of the word size 4 */
words = i >> 2;
for (i = 0; i < words; i++)
data[i] = STRING2INT(ctx->block + 4 * i);
if (words > (SHA256_SHA224_DATA_LENGTH - 2)) { /* No room for length in this block.
* Process it and pad with another one */
for (i = words; i < SHA256_SHA224_DATA_LENGTH; i++)
data[i] = 0;
sha256_sha224_transform(ctx->state, data);
for (i = 0; i < (SHA256_SHA224_DATA_LENGTH - 2); i++)
data[i] = 0;
} else
for (i = words; i < SHA256_SHA224_DATA_LENGTH - 2; i++)
data[i] = 0;
ctx->bitcount += 8 * ctx->index;
data[SHA256_SHA224_DATA_LENGTH - 2] =
ctx->bitcount >> 32;
data[SHA256_SHA224_DATA_LENGTH - 1] =
ctx->bitcount & 0xffffffff;
sha256_sha224_transform(ctx->state, data);
}
static void sha256_sha224_digest(__const struct sha256_sha224_ctx *ctx,
mutils_word8 *s, mutils_word32 len)
{
mutils_word32 i;
if (s != NULL)
{
for (i = 0; i < len; i++)
{
*s++ = ctx->state[i] >> 24;
*s++ = 0xff & (ctx->state[i] >> 16);
*s++ = 0xff & (ctx->state[i] >> 8);
*s++ = 0xff & ctx->state[i];
}
}
}
void sha256_digest(__const struct sha256_sha224_ctx *ctx, mutils_word8 * s)
{
sha256_sha224_digest(ctx, s, SHA256_DIGEST_SIZE / 4);
}
void sha224_digest(__const struct sha256_sha224_ctx *ctx, mutils_word8 * s)
{
sha256_sha224_digest(ctx, s, SHA224_DIGEST_SIZE / 4);
}
#endif /* ENABLE_SHA256_SHA224 */
@@ -0,0 +1,378 @@
/* sha512_sha384.c
*
* The sha512 and sha384 secure hash functions.
* Copyright (C) 2004 B. Poettering
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser 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
*/
/* This code heavily borrows from the sha256/sha1 code written by
* Niels Möller and Peter Gutmann (see sha256_sha224.c of the mhash library)
*/
#include "libdefs.h"
#ifdef ENABLE_SHA512_SHA384
#include "mhash_sha512_sha384.h"
/* A block, treated as a sequence of 64-bit words. */
#define SHA512_SHA384_DATA_LENGTH 16
#define ROTR(n,x) ((x)>>(n) | ((x)<<(64-(n))))
#define SHR(n,x) ((x)>>(n))
/* The SHA512/384 functions. The Choice function is the same as the SHA1
function f1, and the majority function is the same as the SHA1 f3
function. They can be optimized to save one boolean operation each
- thanks to Rich Schroeppel, rcs@cs.arizona.edu for discovering
this */
/* #define Choice(x,y,z) ( ( (x) & (y) ) | ( ~(x) & (z) ) ) */
#define Choice(x,y,z) ( (z) ^ ( (x) & ( (y) ^ (z) ) ) )
/* #define Majority(x,y,z) ( ((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z)) ) */
#define Majority(x,y,z) ( ((x) & (y)) ^ ((z) & ((x) ^ (y))) )
#define S0(x) (ROTR(28,(x)) ^ ROTR(34,(x)) ^ ROTR(39,(x)))
#define S1(x) (ROTR(14,(x)) ^ ROTR(18,(x)) ^ ROTR(41,(x)))
#define s0(x) (ROTR(1,(x)) ^ ROTR(8,(x)) ^ SHR(7,(x)))
#define s1(x) (ROTR(19,(x)) ^ ROTR(61,(x)) ^ SHR(6,(x)))
/* The sha512/384 round __constants. */
static __const mutils_word64 K[80] = {
0x428a2f98d728ae22ULL, 0x7137449123ef65cdULL, 0xb5c0fbcfec4d3b2fULL,
0xe9b5dba58189dbbcULL, 0x3956c25bf348b538ULL, 0x59f111f1b605d019ULL,
0x923f82a4af194f9bULL, 0xab1c5ed5da6d8118ULL, 0xd807aa98a3030242ULL,
0x12835b0145706fbeULL, 0x243185be4ee4b28cULL, 0x550c7dc3d5ffb4e2ULL,
0x72be5d74f27b896fULL, 0x80deb1fe3b1696b1ULL, 0x9bdc06a725c71235ULL,
0xc19bf174cf692694ULL, 0xe49b69c19ef14ad2ULL, 0xefbe4786384f25e3ULL,
0x0fc19dc68b8cd5b5ULL, 0x240ca1cc77ac9c65ULL, 0x2de92c6f592b0275ULL,
0x4a7484aa6ea6e483ULL, 0x5cb0a9dcbd41fbd4ULL, 0x76f988da831153b5ULL,
0x983e5152ee66dfabULL, 0xa831c66d2db43210ULL, 0xb00327c898fb213fULL,
0xbf597fc7beef0ee4ULL, 0xc6e00bf33da88fc2ULL, 0xd5a79147930aa725ULL,
0x06ca6351e003826fULL, 0x142929670a0e6e70ULL, 0x27b70a8546d22ffcULL,
0x2e1b21385c26c926ULL, 0x4d2c6dfc5ac42aedULL, 0x53380d139d95b3dfULL,
0x650a73548baf63deULL, 0x766a0abb3c77b2a8ULL, 0x81c2c92e47edaee6ULL,
0x92722c851482353bULL, 0xa2bfe8a14cf10364ULL, 0xa81a664bbc423001ULL,
0xc24b8b70d0f89791ULL, 0xc76c51a30654be30ULL, 0xd192e819d6ef5218ULL,
0xd69906245565a910ULL, 0xf40e35855771202aULL, 0x106aa07032bbd1b8ULL,
0x19a4c116b8d2d0c8ULL, 0x1e376c085141ab53ULL, 0x2748774cdf8eeb99ULL,
0x34b0bcb5e19b48a8ULL, 0x391c0cb3c5c95a63ULL, 0x4ed8aa4ae3418acbULL,
0x5b9cca4f7763e373ULL, 0x682e6ff3d6b2b8a3ULL, 0x748f82ee5defb2fcULL,
0x78a5636f43172f60ULL, 0x84c87814a1f0ab72ULL, 0x8cc702081a6439ecULL,
0x90befffa23631e28ULL, 0xa4506cebde82bde9ULL, 0xbef9a3f7b2c67915ULL,
0xc67178f2e372532bULL, 0xca273eceea26619cULL, 0xd186b8c721c0c207ULL,
0xeada7dd6cde0eb1eULL, 0xf57d4f7fee6ed178ULL, 0x06f067aa72176fbaULL,
0x0a637dc5a2c898a6ULL, 0x113f9804bef90daeULL, 0x1b710b35131c471bULL,
0x28db77f523047d84ULL, 0x32caab7b40c72493ULL, 0x3c9ebe0a15c9bebcULL,
0x431d67c49c100d4cULL, 0x4cc5d4becb3e42b6ULL, 0x597f299cfc657e2aULL,
0x5fcb6fab3ad6faecULL, 0x6c44198c4a475817ULL
};
/* The initial expanding function. The hash function is defined over an
80-word expanded input array W, where the first 16 are copies of the input
data, and the remaining 64 are defined by
W[ t ] = s1(W[t-2] + W[t-7] + s0(W[i-15] + W[i-16]
This implementation generates these values on the fly in a circular
buffer - thanks to Colin Plumb, colin@nyx10.cs.du.edu for this
optimization.
*/
#define EXPAND(W,i) \
( W[(i) & 15 ] += (s1(W[((i)-2) & 15]) + W[((i)-7) & 15] + s0(W[((i)-15) & 15])) )
/* The prototype SHA sub-round. The fundamental sub-round is:
T1 = h + S1(e) + Choice(e,f,g) + K[t] + W[t]
T2 = S0(a) + Majority(a,b,c)
a' = T1+T2
b' = a
c' = b
d' = c
e' = d + T1
f' = e
g' = f
h' = g
but this is implemented by unrolling the loop 8 times and renaming
the variables
( h, a, b, c, d, e, f, g ) = ( a, b, c, d, e, f, g, h ) each
iteration. This code is then replicated 8, using the next 8 values
from the W[] array each time */
#define ROUND(a,b,c,d,e,f,g,h,k,data) do { \
mutils_word64 T1 = h + S1(e) + Choice(e,f,g) + k + data; \
d += T1; \
h = T1 + S0(a) + Majority(a,b,c); \
} while (0)
/* Helper macros derived from those in mhash_sha1.h */
#ifndef EXTRACT_UCHAR
#define EXTRACT_UCHAR(p) (*(unsigned char *)(p))
#endif
#define STRING2INT64(s) ((((((((((((((mutils_word64)(EXTRACT_UCHAR(s) << 8) \
| EXTRACT_UCHAR(s+1)) << 8) \
| EXTRACT_UCHAR(s+2)) << 8) \
| EXTRACT_UCHAR(s+3)) << 8) \
| EXTRACT_UCHAR(s+4)) << 8) \
| EXTRACT_UCHAR(s+5)) << 8) \
| EXTRACT_UCHAR(s+6)) << 8) \
| EXTRACT_UCHAR(s+7))
/* Initialize the SHA512/384 values */
void sha512_init(struct sha512_sha384_ctx *ctx)
{
/* Initial values */
static __const mutils_word64 H0[_SHA512_SHA384_STATE_LENGTH] = {
0x6a09e667f3bcc908ULL, 0xbb67ae8584caa73bULL, 0x3c6ef372fe94f82bULL,
0xa54ff53a5f1d36f1ULL, 0x510e527fade682d1ULL, 0x9b05688c2b3e6c1fULL,
0x1f83d9abfb41bd6bULL, 0x5be0cd19137e2179ULL
};
mutils_memcpy(ctx->state, H0, sizeof(H0));
/* Initialize bit count */
ctx->bitcount_low = ctx->bitcount_high = 0;
/* Initialize buffer */
ctx->index = 0;
}
void sha384_init(struct sha512_sha384_ctx *ctx)
{
/* Initial values */
static __const mutils_word64 H0[_SHA512_SHA384_STATE_LENGTH] = {
0xcbbb9d5dc1059ed8ULL, 0x629a292a367cd507ULL, 0x9159015a3070dd17ULL,
0x152fecd8f70e5939ULL, 0x67332667ffc00b31ULL, 0x8eb44a8768581511ULL,
0xdb0c2e0d64f98fa7ULL, 0x47b5481dbefa4fa4ULL,
};
mutils_memcpy(ctx->state, H0, sizeof(H0));
/* Initialize bit count */
ctx->bitcount_low = ctx->bitcount_high = 0;
/* Initialize buffer */
ctx->index = 0;
}
/* Perform the SHA transformation. Note that this code, like MD5, seems to
break some optimizing compilers due to the complexity of the expressions
and the size of the basic block. It may be necessary to split it into
sections, e.g. based on the four subrounds
Note that this function destroys the data area */
static void sha512_sha384_transform(mutils_word64 * state, mutils_word64 * data)
{
mutils_word64 A, B, C, D, E, F, G, H; /* Local vars */
mutils_word8 i;
__const mutils_word64 *k;
mutils_word64 *d;
/* Set up first buffer and local data buffer */
A = state[0];
B = state[1];
C = state[2];
D = state[3];
E = state[4];
F = state[5];
G = state[6];
H = state[7];
/* Heavy mangling */
/* First 16 subrounds that act on the original data */
for (i = 0, k = K, d = data; i < 16; i += 8, k += 8, d += 8) {
ROUND(A, B, C, D, E, F, G, H, k[0], d[0]);
ROUND(H, A, B, C, D, E, F, G, k[1], d[1]);
ROUND(G, H, A, B, C, D, E, F, k[2], d[2]);
ROUND(F, G, H, A, B, C, D, E, k[3], d[3]);
ROUND(E, F, G, H, A, B, C, D, k[4], d[4]);
ROUND(D, E, F, G, H, A, B, C, k[5], d[5]);
ROUND(C, D, E, F, G, H, A, B, k[6], d[6]);
ROUND(B, C, D, E, F, G, H, A, k[7], d[7]);
}
for (; i < 80; i += 16, k += 16) {
ROUND(A, B, C, D, E, F, G, H, k[0], EXPAND(data, 0));
ROUND(H, A, B, C, D, E, F, G, k[1], EXPAND(data, 1));
ROUND(G, H, A, B, C, D, E, F, k[2], EXPAND(data, 2));
ROUND(F, G, H, A, B, C, D, E, k[3], EXPAND(data, 3));
ROUND(E, F, G, H, A, B, C, D, k[4], EXPAND(data, 4));
ROUND(D, E, F, G, H, A, B, C, k[5], EXPAND(data, 5));
ROUND(C, D, E, F, G, H, A, B, k[6], EXPAND(data, 6));
ROUND(B, C, D, E, F, G, H, A, k[7], EXPAND(data, 7));
ROUND(A, B, C, D, E, F, G, H, k[8], EXPAND(data, 8));
ROUND(H, A, B, C, D, E, F, G, k[9], EXPAND(data, 9));
ROUND(G, H, A, B, C, D, E, F, k[10], EXPAND(data, 10));
ROUND(F, G, H, A, B, C, D, E, k[11], EXPAND(data, 11));
ROUND(E, F, G, H, A, B, C, D, k[12], EXPAND(data, 12));
ROUND(D, E, F, G, H, A, B, C, k[13], EXPAND(data, 13));
ROUND(C, D, E, F, G, H, A, B, k[14], EXPAND(data, 14));
ROUND(B, C, D, E, F, G, H, A, k[15], EXPAND(data, 15));
}
/* Update state */
state[0] += A;
state[1] += B;
state[2] += C;
state[3] += D;
state[4] += E;
state[5] += F;
state[6] += G;
state[7] += H;
}
static void
sha512_sha384_block(struct sha512_sha384_ctx *ctx, __const mutils_word8 * block)
{
mutils_word64 data[SHA512_SHA384_DATA_LENGTH];
mutils_word32 i;
/* Update bit counter */
if ((ctx->bitcount_low += 1024) < 1024)
{
ctx->bitcount_high++;
}
/* Endian independent conversion */
for (i = 0; i < SHA512_SHA384_DATA_LENGTH; i++, block += 8)
{
data[i] = STRING2INT64(block);
}
sha512_sha384_transform(ctx->state, data);
}
void
sha512_sha384_update(struct sha512_sha384_ctx *ctx, __const mutils_word8 * buffer,
mutils_word32 length)
{
mutils_word32 left;
if (ctx->index)
{ /* Try to fill partial block */
left = SHA512_SHA384_DATA_SIZE - ctx->index;
if (length < left)
{
mutils_memcpy(ctx->block + ctx->index, buffer, length);
ctx->index += length;
return; /* Finished */
} else {
mutils_memcpy(ctx->block + ctx->index, buffer, left);
sha512_sha384_block(ctx, ctx->block);
buffer += left;
length -= left;
}
}
while (length >= SHA512_SHA384_DATA_SIZE)
{
sha512_sha384_block(ctx, buffer);
buffer += SHA512_SHA384_DATA_SIZE;
length -= SHA512_SHA384_DATA_SIZE;
}
/* Buffer leftovers */
/* NOTE: The corresponding sha1 code checks for the special case length == 0.
* That seems supoptimal, as I suspect it increases the number of branches. */
mutils_memcpy(ctx->block, buffer, length);
ctx->index = length;
}
/* Final wrapup - pad to SHA512_SHA384_DATA_SIZE-byte boundary with the bit pattern
1 0* (128-bit count of bits processed, MSB-first) */
void sha512_sha384_final(struct sha512_sha384_ctx *ctx)
{
mutils_word64 data[SHA512_SHA384_DATA_LENGTH];
mutils_word32 i;
mutils_word32 words;
i = ctx->index;
/* Set the first char of padding to 0x80. This is safe since there is
always at least one byte free */
/* assert(i < SHA512_SHA384_DATA_SIZE);
*/
ctx->block[i++] = 0x80;
/* Fill rest of word */
for (; i & 7; i++)
ctx->block[i] = 0;
/* i is now a multiple of the word size 8 */
words = i >> 3;
for (i = 0; i < words; i++)
data[i] = STRING2INT64(ctx->block + 8 * i);
if (words > (SHA512_SHA384_DATA_LENGTH - 2)) { /* No room for
length in this block. Process it and pad with another one */
for (i = words; i < SHA512_SHA384_DATA_LENGTH; i++)
data[i] = 0;
sha512_sha384_transform(ctx->state, data);
for (i = 0; i < (SHA512_SHA384_DATA_LENGTH - 2); i++)
data[i] = 0;
} else
for (i = words; i < SHA512_SHA384_DATA_LENGTH - 2; i++)
data[i] = 0;
if ((ctx->bitcount_low += 8 * ctx->index) < 8 * ctx->index)
ctx->bitcount_high++;
data[SHA512_SHA384_DATA_LENGTH - 2] = ctx->bitcount_high;
data[SHA512_SHA384_DATA_LENGTH - 1] = ctx->bitcount_low;
sha512_sha384_transform(ctx->state, data);
}
static void
sha512_sha384_digest(__const struct sha512_sha384_ctx *ctx, mutils_word8 * s, mutils_word32 len)
{
mutils_word32 i;
if (s != NULL)
{
for (i = 0; i < len; i++)
{
*s++ = ctx->state[i] >> 56;
*s++ = 0xff & (ctx->state[i] >> 48);
*s++ = 0xff & (ctx->state[i] >> 40);
*s++ = 0xff & (ctx->state[i] >> 32);
*s++ = 0xff & (ctx->state[i] >> 24);
*s++ = 0xff & (ctx->state[i] >> 16);
*s++ = 0xff & (ctx->state[i] >> 8);
*s++ = 0xff & ctx->state[i];
}
}
}
void sha512_digest(__const struct sha512_sha384_ctx *ctx, mutils_word8 * s)
{
sha512_sha384_digest(ctx, s, SHA512_DIGEST_SIZE / 8);
}
void sha384_digest(__const struct sha512_sha384_ctx *ctx, mutils_word8 * s)
{
sha512_sha384_digest(ctx, s, SHA384_DIGEST_SIZE / 8);
}
#endif /* ENABLE_SHA512_SHA384 */
@@ -0,0 +1,878 @@
/* snefru.c */
/* Snefru is a cryptographic hash function invented by Ralph Merkle
* which supports 128-bit and 256-bit output. It was named after the
* Egyptian Pharaoh Sneferu, continuing the tradition of the Khufu and
* Khafre block ciphers.
*
* Snefru is a public-domain one-way hash function. For more information see
* http://www.funet.fi/pub/crypt/mirrors/idea.sec.dsi.unimi.it/rpub.cl.msu.edu/
* crypt/docs/merkle-khufu-khafre-snefru.txt.gz
*
* This code was written by B. Poettering in 2004 for the mhash library. It
* is in the public domain.
*/
#include "libdefs.h"
#if defined(ENABLE_SNEFRU)
#include "mhash_snefru.h"
#define R 8 // number of rounds
static __const mutils_word32 SBOX[R * 256 * 2]= {
0x64f9001bl, 0xfeddcdf6l, 0x7c8ff1e2l, 0x11d71514l, 0x8b8c18d3l, 0xdddf881el,
0x6eab5056l, 0x88ced8e1l, 0x49148959l, 0x69c56fd5l, 0xb7994f03l, 0x0fbcee3el,
0x3c264940l, 0x21557e58l, 0xe14b3fc2l, 0x2e5cf591l, 0xdceff8cel, 0x092a1648l,
0xbe812936l, 0xff7b0c6al, 0xd5251037l, 0xafa448f1l, 0x7dafc95al, 0x1ea69c3fl,
0xa417abe7l, 0x5890e423l, 0xb0cb70c0l, 0xc85025f7l, 0x244d97e3l, 0x1ff3595fl,
0xc4ec6396l, 0x59181e17l, 0xe635b477l, 0x354e7dbfl, 0x796f7753l, 0x66eb52ccl,
0x77c3f995l, 0x32e3a927l, 0x80ccaed6l, 0x4e2be89dl, 0x375bbd28l, 0xad1a3d05l,
0x2b1b42b3l, 0x16c44c71l, 0x4d54bfa8l, 0xe57ddc7al, 0xec6d8144l, 0x5a71046bl,
0xd8229650l, 0x87fc8f24l, 0xcbc60e09l, 0xb6390366l, 0xd9f76092l, 0xd393a70bl,
0x1d31a08al, 0x9cd971c9l, 0x5c1ef445l, 0x86fab694l, 0xfdb44165l, 0x8eaafcbel,
0x4bcac6ebl, 0xfb7a94e5l, 0x5789d04el, 0xfa13cf35l, 0x236b8da9l, 0x4133f000l,
0x6224261cl, 0xf412f23bl, 0xe75e56a4l, 0x30022116l, 0xbaf17f1fl, 0xd09872f9l,
0xc1a3699cl, 0xf1e802aal, 0x0dd145dcl, 0x4fdce093l, 0x8d8412f0l, 0x6cd0f376l,
0x3de6b73dl, 0x84ba737fl, 0xb43a30f2l, 0x44569f69l, 0x00e4eacal, 0xb58de3b0l,
0x959113c8l, 0xd62efee9l, 0x90861f83l, 0xced69874l, 0x2f793ceel, 0xe8571c30l,
0x483665d1l, 0xab07b031l, 0x914c844fl, 0x15bf3be8l, 0x2c3f2a9al, 0x9eb95fd4l,
0x92e7472dl, 0x2297cc5bl, 0xee5f2782l, 0x5377b562l, 0xdb8ebbcfl, 0xf961deddl,
0xc59b5c60l, 0x1bd3910dl, 0x26d206adl, 0xb28514d8l, 0x5ecf6b52l, 0x7fea78bbl,
0x504879acl, 0xed34a884l, 0x36e51d3cl, 0x1753741dl, 0x8c47caedl, 0x9d0a40efl,
0x3145e221l, 0xda27eb70l, 0xdf730ba3l, 0x183c8789l, 0x739ac0a6l, 0x9a58dfc6l,
0x54b134c1l, 0xac3e242el, 0xcc493902l, 0x7b2dda99l, 0x8f15bc01l, 0x29fd38c7l,
0x27d5318fl, 0x604aaff5l, 0xf29c6818l, 0xc38aa2ecl, 0x1019d4c3l, 0xa8fb936el,
0x20ed7b39l, 0x0b686119l, 0x89a0906fl, 0x1cc7829el, 0x9952ef4bl, 0x850e9e8cl,
0xcd063a90l, 0x67002f8el, 0xcfac8cb7l, 0xeaa24b11l, 0x988b4e6cl, 0x46f066dfl,
0xca7eec08l, 0xc7bba664l, 0x831d17bdl, 0x63f575e6l, 0x9764350el, 0x47870d42l,
0x026ca4a2l, 0x8167d587l, 0x61b6adabl, 0xaa6564d2l, 0x70da237bl, 0x25e1c74al,
0xa1c901a0l, 0x0eb0a5dal, 0x7670f741l, 0x51c05aeal, 0x933dfa32l, 0x0759ff1al,
0x56010ab8l, 0x5fdecb78l, 0x3f32edf8l, 0xaebedbb9l, 0x39f8326dl, 0xd20858c5l,
0x9b638be4l, 0xa572c80al, 0x28e0a19fl, 0x432099fcl, 0x3a37c3cdl, 0xbf95c585l,
0xb392c12al, 0x6aa707d7l, 0x52f66a61l, 0x12d483b1l, 0x96435b5el, 0x3e75802bl,
0x3ba52b33l, 0xa99f51a5l, 0xbda1e157l, 0x78c2e70cl, 0xfcae7ce0l, 0xd1602267l,
0x2affac4dl, 0x4a510947l, 0x0ab2b83al, 0x7a04e579l, 0x340dfd80l, 0xb916e922l,
0xe29d5e9bl, 0xf5624af4l, 0x4ca9d9afl, 0x6bbd2cfel, 0xe3b7f620l, 0xc2746e07l,
0x5b42b9b6l, 0xa06919bcl, 0xf0f2c40fl, 0x72217ab5l, 0x14c19df3l, 0xf3802dael,
0xe094beb4l, 0xa2101affl, 0x0529575dl, 0x55cdb27cl, 0xa33bddb2l, 0x6528b37dl,
0x740c05dbl, 0xe96a62c4l, 0x40782846l, 0x6d30d706l, 0xbbf48e2cl, 0xbce2d3del,
0x049e37fal, 0x01b5e634l, 0x2d886d8dl, 0x7e5a2e7el, 0xd7412013l, 0x06e90f97l,
0xe45d3ebal, 0xb8ad3386l, 0x13051b25l, 0x0c035354l, 0x71c89b75l, 0xc638fbd0l,
0x197f11a1l, 0xef0f08fbl, 0xf8448651l, 0x38409563l, 0x452f4443l, 0x5d464d55l,
0x03d8764cl, 0xb1b8d638l, 0xa70bba2fl, 0x94b3d210l, 0xeb6692a7l, 0xd409c2d9l,
0x68838526l, 0xa6db8a15l, 0x751f6c98l, 0xde769a88l, 0xc9ee4668l, 0x1a82a373l,
0x0896aa49l, 0x42233681l, 0xf62c55cbl, 0x9f1c5404l, 0xf74fb15cl, 0xc06e4312l,
0x6ffe5d72l, 0x8aa8678bl, 0x337cd129l, 0x8211cefdl, 0x074a1d09l, 0x52a10e5al,
0x9275a3f8l, 0x4b82506cl, 0x37df7e1bl, 0x4c78b3c5l, 0xcefab1dal, 0xf472267el,
0xb63045f6l, 0xd66a1fc0l, 0x400298e3l, 0x27e60c94l, 0x87d2f1b8l, 0xdf9e56ccl,
0x45cd1803l, 0x1d35e098l, 0xcce7c736l, 0x03483bf1l, 0x1f7307d7l, 0xc6e8f948l,
0xe613c111l, 0x3955c6ffl, 0x1170ed7cl, 0x8e95da41l, 0x99c31bf4l, 0xa4da8021l,
0x7b5f94fbl, 0xdd0da51fl, 0x6562aa77l, 0x556bcb23l, 0xdb1bacc6l, 0x798040b9l,
0xbfe5378fl, 0x731d55e6l, 0xdaa5bfeel, 0x389bbc60l, 0x1b33fba4l, 0x9c567204l,
0x36c26c68l, 0x77ee9d69l, 0x8aeb3e88l, 0x2d50b5cel, 0x9579e790l, 0x42b13cfcl,
0x33fbd32bl, 0xee0503a7l, 0xb5862824l, 0x15e41eadl, 0xc8412ef7l, 0x9d441275l,
0x2fcec582l, 0x5ff483b7l, 0x8f3931dfl, 0x2e5d2a7bl, 0x49467bf9l, 0x0653dea9l,
0x2684ce35l, 0x7e655e5cl, 0xf12771d8l, 0xbb15cc67l, 0xab097ca1l, 0x983dcf52l,
0x10ddf026l, 0x21267f57l, 0x2c58f6b4l, 0x31043265l, 0x0bab8c01l, 0xd5492099l,
0xacaae619l, 0x944ce54al, 0xf2d13d39l, 0xadd3fc32l, 0xcda08a40l, 0xe2b0d451l,
0x9efe08ael, 0xb9d50fd2l, 0xea5cd7fdl, 0xc9a749ddl, 0x13ea2253l, 0x832debaal,
0x24be640fl, 0xe03e926al, 0x29e01cdel, 0x8bf59f18l, 0x0f9d00b6l, 0xe1238b46l,
0x1e7d8e34l, 0x93619adbl, 0x76b32f9fl, 0xbd972cecl, 0xe31fa976l, 0xa68fbb10l,
0xfb3ba49dl, 0x8587c41dl, 0xa5add1d0l, 0xf3cf84bfl, 0xd4e11150l, 0xd9ffa6bcl,
0xc3f6018cl, 0xaef10572l, 0x74a64b2fl, 0xe7dc9559l, 0x2aae35d5l, 0x5b6f587fl,
0xa9e353fel, 0xca4fb674l, 0x04ba24a8l, 0xe5c6875fl, 0xdcbc6266l, 0x6bc5c03fl,
0x661eef02l, 0xed740babl, 0x058e34e4l, 0xb7e946cfl, 0x88698125l, 0x72ec48edl,
0xb11073a3l, 0xa13485ebl, 0xa2a2429cl, 0xfa407547l, 0x50b76713l, 0x5418c37dl,
0x96192da5l, 0x170bb04bl, 0x518a021el, 0xb0ac13d1l, 0x0963fa2al, 0x4a6e10e1l,
0x58472bdcl, 0xf7f8d962l, 0x979139eal, 0x8d856538l, 0xc0997042l, 0x48324d7al,
0x447623cbl, 0x8cbbe364l, 0x6e0c6b0el, 0xd36d63b0l, 0x3f244c84l, 0x3542c971l,
0x2b228dc1l, 0xcb0325bbl, 0xf8c0d6e9l, 0xde11066bl, 0xa8649327l, 0xfc31f83el,
0x7dd80406l, 0xf916dd61l, 0xd89f79d3l, 0x615144c2l, 0xebb45d31l, 0x28002958l,
0x56890a37l, 0xf05b3808l, 0x123ae844l, 0x86839e16l, 0x914b0d83l, 0xc506b43cl,
0xcf3cba5el, 0x7c60f5c9l, 0x22deb2a0l, 0x5d9c2715l, 0xc77ba0efl, 0x4f45360bl,
0xc1017d8bl, 0xe45adc29l, 0xa759909bl, 0x412cd293l, 0xd7d796b1l, 0x00c8ff30l,
0x23a34a80l, 0x4ec15c91l, 0x714e78b5l, 0x47b9e42el, 0x78f3ea4dl, 0x7f078f5bl,
0x346c593al, 0xa3a87a1al, 0x9bcbfe12l, 0x3d439963l, 0xb2ef6d8el, 0xb8d46028l,
0x6c2fd5cal, 0x62675256l, 0x01f2a2f3l, 0xbc96ae0al, 0x709a8920l, 0xb4146e87l,
0x6308b9e2l, 0x64bda7bal, 0xafed6892l, 0x6037f2a2l, 0xf52969e0l, 0x0adb43a6l,
0x82811400l, 0x90d0bdf0l, 0x19c9549el, 0x203f6a73l, 0x1accaf4fl, 0x89714e6dl,
0x164d4705l, 0x67665f07l, 0xec206170l, 0x0c2182b2l, 0xa02b9c81l, 0x53289722l,
0xf6a97686l, 0x140e4179l, 0x9f778849l, 0x9a88e15dl, 0x25cadb54l, 0xd157f36fl,
0x32a421c3l, 0xb368e98al, 0x5a92cd0dl, 0x757aa8d4l, 0xc20ac278l, 0x08b551c7l,
0x849491e8l, 0x4dc75ad6l, 0x697c33bel, 0xbaf0ca33l, 0x46125b4el, 0x59d677b3l,
0x30d9c8f2l, 0xd0af860cl, 0x1c7fd0fal, 0xfe0ff72cl, 0x5c8d6f43l, 0x57fdec3bl,
0x6ab6ad97l, 0xd22adf89l, 0x18171785l, 0x02bfe22dl, 0x6db80917l, 0x80b216afl,
0xe85e4f9al, 0x7a1c306el, 0x6fc49bf5l, 0x3af7a11cl, 0x81e215e7l, 0x68363fcdl,
0x3e9357c8l, 0xef52fd55l, 0x3b8bab4cl, 0x3c8cf495l, 0xbefceebdl, 0xfd25b714l,
0xc498d83dl, 0x0d2e1a8dl, 0xe9f966acl, 0x0e387445l, 0x435419e5l, 0x5e7ebec4l,
0xaa90b8d9l, 0xff1a3a96l, 0x4a8fe4e3l, 0xf27d99cdl, 0xd04a40cal, 0xcb5ff194l,
0x3668275al, 0xff4816bel, 0xa78b394cl, 0x4c6be9dbl, 0x4eec38d2l, 0x4296ec80l,
0xcdce96f8l, 0x888c2f38l, 0xe75508f5l, 0x7b916414l, 0x060aa14al, 0xa214f327l,
0xbe608dafl, 0x1ebbdec2l, 0x61f98ce9l, 0xe92156fel, 0x4f22d7a3l, 0x3f76a8d9l,
0x559a4b33l, 0x38ad2959l, 0xf3f17e9el, 0x85e1ba91l, 0xe5eba6fbl, 0x73dcd48cl,
0xf5c3ff78l, 0x481b6058l, 0x8a3297f7l, 0x8f1f3bf4l, 0x93785ab2l, 0x477a4a5bl,
0x6334eb5dl, 0x6d251b2el, 0x74a9102dl, 0x07e38ffal, 0x915c9c62l, 0xccc275eal,
0x6be273ecl, 0x3ebddd70l, 0xd895796cl, 0xdc54a91bl, 0xc9afdf81l, 0x23633f73l,
0x275119b4l, 0xb19f6b67l, 0x50756e22l, 0x2bb152e2l, 0x76ea46a2l, 0xa353e232l,
0x2f596ad6l, 0x0b1edb0bl, 0x02d3d9a4l, 0x78b47843l, 0x64893e90l, 0x40f0caadl,
0xf68d3ad7l, 0x46fd1707l, 0x1c9c67efl, 0xb5e086del, 0x96ee6ca6l, 0x9aa34774l,
0x1ba4f48al, 0x8d01abfdl, 0x183ee1f6l, 0x5ff8aa7al, 0x17e4faael, 0x303983b0l,
0x6c08668bl, 0xd4ac4382l, 0xe6c5849fl, 0x92fefb53l, 0xc1cac4cel, 0x43501388l,
0x441118cfl, 0xec4fb308l, 0x53a08e86l, 0x9e0fe0c5l, 0xf91c1525l, 0xac45be05l,
0xd7987cb5l, 0x49ba1487l, 0x57938940l, 0xd5877648l, 0xa958727fl, 0x58dfe3c3l,
0xf436cf77l, 0x399e4d11l, 0xf0a5bfa9l, 0xef61a33bl, 0xa64cac60l, 0x04a8d0bal,
0x030dd572l, 0xb83d320fl, 0xcab23045l, 0xe366f2f0l, 0x815d008dl, 0xc897a43al,
0x1d352df3l, 0xb9cc571dl, 0x8bf38744l, 0x72209092l, 0xeba124ebl, 0xfb99ce5el,
0x3bb94293l, 0x28da549cl, 0xaab8a228l, 0xa4197785l, 0x33c70296l, 0x25f6259bl,
0x5c85da21l, 0xdf15bdeel, 0x15b7c7e8l, 0xe2abef75l, 0xfcc19bc1l, 0x417ff868l,
0x14884434l, 0x62825179l, 0xc6d5c11cl, 0x0e4705dcl, 0x22700de0l, 0xd3d2af18l,
0x9be822a0l, 0x35b669f1l, 0xc42bb55cl, 0x0a801252l, 0x115bf0fcl, 0x3cd7d856l,
0xb43f5f9dl, 0xc2306516l, 0xa1231c47l, 0xf149207el, 0x5209a795l, 0x34b3ccd8l,
0x67aefe54l, 0x2c83924el, 0x6662cbacl, 0x5eedd161l, 0x84e681aal, 0x5d57d26bl,
0xfa465cc4l, 0x7e3ac3a8l, 0xbf7c0cc6l, 0xe18a9aa1l, 0xc32f0a6fl, 0xb22cc00dl,
0x3d280369l, 0x994e554fl, 0x68f480d3l, 0xadcff5e6l, 0x3a8eb265l, 0x83269831l,
0xbd568a09l, 0x4bc8ae6al, 0x69f56d2bl, 0x0f17eac8l, 0x772eb6c7l, 0x9f41343cl,
0xab1d0742l, 0x826a6f50l, 0xfea2097cl, 0x1912c283l, 0xce185899l, 0xe4444839l,
0x2d8635d5l, 0x65d0b1ffl, 0x865a7f17l, 0x326d9fb1l, 0x59e52820l, 0x0090ade1l,
0x753c7149l, 0x9ddd8b98l, 0xa5a691dal, 0x0d0382bbl, 0x8904c930l, 0x086cb000l,
0x6e69d3bdl, 0x24d4e7a7l, 0x05244fd0l, 0x101a5e0cl, 0x6a947dcbl, 0xe840f77bl,
0x7d0c5003l, 0x7c370f1fl, 0x805245edl, 0xe05e3d3fl, 0x7906880el, 0xbabfcd35l,
0x1a7ec697l, 0x8c052324l, 0x0c6ec8dfl, 0xd129a589l, 0xc7a75b02l, 0x12d81de7l,
0xd9be2a66l, 0x1f4263abl, 0xde73fdb6l, 0x2a00680al, 0x56649e36l, 0x3133ed55l,
0x90fa0bf2l, 0x2910a02al, 0x949d9d46l, 0xa0d1dcddl, 0xcfc9b7d4l, 0xd2677be5l,
0x95cb36b3l, 0x13cd9410l, 0xdbf73313l, 0xb7c6e8c0l, 0xf781414bl, 0x510b016dl,
0xb0de1157l, 0xd6b0f62cl, 0xbb074eccl, 0x7f1395b7l, 0xee792cf9l, 0xea6fd63el,
0x5bd6938el, 0xaf02fc64l, 0xdab57ab8l, 0x8edb3784l, 0x8716318fl, 0x164d1a01l,
0x26f26141l, 0xb372e6b9l, 0xf8fc2b06l, 0x7ac00e04l, 0x3727b89al, 0x97e9bca5l,
0x9c2a742fl, 0xbc3b1f7dl, 0x7165b471l, 0x609b4c29l, 0x20925351l, 0x5ae72112l,
0x454be5d1l, 0xc0ffb95fl, 0xdd0ef919l, 0x6f2d70c9l, 0x0974c5bfl, 0x98aa6263l,
0x01d91e4dl, 0x2184bb6el, 0x70c43c1el, 0x4d435915l, 0xae7b8523l, 0xb6fb06bcl,
0x5431ee76l, 0xfdbc5d26l, 0xed77493dl, 0xc5712ee4l, 0xa8380437l, 0x2eef261al,
0x5a79392bl, 0xb8af32c2l, 0x41f7720al, 0x833a61ecl, 0x13dfedacl, 0xc4990bc4l,
0xdc0f54bcl, 0xfedd5e88l, 0x80da1881l, 0x4dea1afdl, 0xfd402cc6l, 0xae67cc7al,
0xc5238525l, 0x8ea01254l, 0xb56b9bd5l, 0x862fbd6dl, 0xac8575d3l, 0x6fba3714l,
0xda7ebf46l, 0x59cd5238l, 0x8ac9dbfel, 0x353729fcl, 0xe497d7f2l, 0xc3ab84e0l,
0xf05a114bl, 0x7b887a75l, 0xedc603ddl, 0x5e6fe680l, 0x2c84b399l, 0x884eb1dal,
0x1cb8c8bfl, 0xaa51098al, 0xc862231cl, 0x8bac2221l, 0x21b387e5l, 0x208a430dl,
0x2a3f0f8bl, 0xa5ff9cd2l, 0x6012a2eal, 0x147a9ee7l, 0xf62a501dl, 0xb4b2e51al,
0x3ef3484cl, 0xc0253c59l, 0x2b82b536l, 0x0aa9696bl, 0xbe0c109bl, 0xc70b7929l,
0xce3e8a19l, 0x2f66950el, 0x459f1c2cl, 0xe68fb93dl, 0xa3c3ff3el, 0x62b45c62l,
0x300991cbl, 0x01914c57l, 0x7f7bc06al, 0x182831f5l, 0xe7b74bcal, 0xfa50f6d0l,
0x523caa61l, 0xe3a7cf05l, 0xe9e41311l, 0x280a21d1l, 0x6a4297e1l, 0xf24dc67el,
0xfc3189e6l, 0xb72bf34fl, 0x4b1e67afl, 0x543402cel, 0x79a59867l, 0x0648e02al,
0x00a3ac17l, 0xc6208d35l, 0x6e7f5f76l, 0xa45bb4bel, 0xf168fa63l, 0x3f4125f3l,
0xf311406fl, 0x02706565l, 0xbfe58022l, 0x0cfcfdd9l, 0x0735a7f7l, 0x8f049092l,
0xd98edc27l, 0xf5c5d55cl, 0xe0f201dbl, 0x0dcafc9al, 0x7727fb79l, 0xaf43abf4l,
0x26e938c1l, 0x401b26a6l, 0x900720fal, 0x2752d97bl, 0xcff1d1b3l, 0xa9d9e424l,
0x42db99abl, 0x6cf8be5fl, 0xe82cebe3l, 0x3afb733bl, 0x6b734eb6l, 0x1036414al,
0x975f667cl, 0x049d6377l, 0xba587c60l, 0xb1d10483l, 0xde1aefccl, 0x1129d055l,
0x72051e91l, 0x6946d623l, 0xf9e86ea7l, 0x48768c00l, 0xb0166c93l, 0x9956bbf0l,
0x1f1f6d84l, 0xfb15e18el, 0x033b495dl, 0x56e3362el, 0x4f44c53cl, 0x747cba51l,
0x89d37872l, 0x5d9c331bl, 0xd2ef9fa8l, 0x254917f8l, 0x1b106f47l, 0x37d75553l,
0xb3f053b0l, 0x7dccd8efl, 0xd30eb802l, 0x5889f42dl, 0x610206d7l, 0x1a7d34a1l,
0x92d87dd8l, 0xe5f4a315l, 0xd1cf0e71l, 0xb22dfe45l, 0xb901e8ebl, 0x0fc0ce5el,
0x2efa60c9l, 0x2de74290l, 0x36d0c906l, 0x381c70e4l, 0x4c6da5b5l, 0x3d81a682l,
0x7e381f34l, 0x396c4f52l, 0x95ad5901l, 0x1db50c5al, 0x29982e9el, 0x1557689fl,
0x3471ee42l, 0xd7e2f7c0l, 0x8795a1e2l, 0xbc324d8dl, 0xe224c3c8l, 0x12837e39l,
0xcdee3d74l, 0x7ad2143fl, 0x0e13d40cl, 0x78bd4a68l, 0xa2eb194dl, 0xdb9451f9l,
0x859b71dcl, 0x5c4f5b89l, 0xca14a8a4l, 0xef92f003l, 0x16741d98l, 0x33aa4444l,
0x9e967fbbl, 0x092e3020l, 0xd86a35b8l, 0x8cc17b10l, 0xe1bf08ael, 0x55693fc5l,
0x7680ad13l, 0x1e6546e8l, 0x23b6e7b9l, 0xee77a4b2l, 0x08ed0533l, 0x44fd2895l,
0xb6393b69l, 0x05d6cacfl, 0x9819b209l, 0xecbbb72fl, 0x9a75779cl, 0xeaec0749l,
0x94a65aeel, 0xbdf52dc3l, 0xd6a25d04l, 0x82008e4el, 0xa6de160fl, 0x9b036afbl,
0x228b3a66l, 0x5fb10a70l, 0xcc338b58l, 0x5378a9dfl, 0xc908bca9l, 0x4959e25bl,
0x46909a97l, 0x66ae8f6el, 0xdd0683e9l, 0x65f994b4l, 0x6426cda5l, 0xc24b8840l,
0x32539da0l, 0x63175650l, 0xd0c815ffl, 0x50cbc41el, 0xf7c774a3l, 0x31b0c231l,
0x8d0d8116l, 0x24bef16cl, 0xd555d256l, 0xdf47ea8cl, 0x6d21eccdl, 0xa887a012l,
0x84542aedl, 0xa7b9c1bdl, 0x914c1bb1l, 0xa0d5b67dl, 0x438ce937l, 0x7030f873l,
0x71f6b0c7l, 0x574576bal, 0xf8bc4541l, 0x9c61d348l, 0x1960579dl, 0x17c4daadl,
0x96a4cb0bl, 0xc193f2f6l, 0x756eafa2l, 0x7c1d2f94l, 0xf4fe2b43l, 0xcb86e33al,
0xebd4c728l, 0x9d18ae64l, 0x9fe13e30l, 0x3ce0f5del, 0xaba1f985l, 0xaddc2718l,
0x68ce6278l, 0xd45e241fl, 0xa15c82b7l, 0x3b2293d4l, 0x739edd32l, 0x674a6bf1l,
0x5b5d587fl, 0x4772deaal, 0x4a63968fl, 0x0be68686l, 0x513d6426l, 0x939a4787l,
0xbba89296l, 0x4ec20007l, 0x818d0d08l, 0xff64dfd6l, 0xcb2297cbl, 0xdb48a144l,
0xa16cbe4bl, 0xbbea1d6cl, 0x5af6b6b7l, 0x8a8110b6l, 0xf9236ef9l, 0xc98f83e6l,
0x0f9c65b8l, 0x252d4a89l, 0xa497f068l, 0xa5d7ed2dl, 0x94c22845l, 0x9da1c8c4l,
0xe27c2e2el, 0x6e8ba2b4l, 0xc3dd17fbl, 0x498cd482l, 0x0dfe6a9fl, 0xb0705829l,
0x9a1e6dc1l, 0xf829717cl, 0x07bb8e3al, 0xda3c0b02l, 0x1af82fc7l, 0x73b70955l,
0x7a04379cl, 0x5ee20a28l, 0x83712ae5l, 0xf4c47c6dl, 0xdf72ba56l, 0xd794858dl,
0x8c0cf709l, 0x18f0f390l, 0xb6c69b35l, 0xbf2f01dbl, 0x2fa74dcal, 0xd0cd9127l,
0xbde66cecl, 0x3deebd46l, 0x57c88fc3l, 0xcee1406fl, 0x0066385al, 0xf3c3444fl,
0x3a79d5d5l, 0x75751eb9l, 0x3e7f8185l, 0x521c2605l, 0xe1aaab6el, 0x38ebb80fl,
0xbee7e904l, 0x61cb9647l, 0xea54904el, 0x05ae00e4l, 0x2d7ac65fl, 0x087751a1l,
0xdcd82915l, 0x0921ee16l, 0xdd86d33bl, 0xd6bd491al, 0x40fbadf0l, 0x4232cbd2l,
0x33808d10l, 0x39098c42l, 0x193f3199l, 0x0bc1e47al, 0x4a82b149l, 0x02b65a8al,
0x104cdc8el, 0x24a8f52cl, 0x685c6077l, 0xc79f95c9l, 0x1d11fe50l, 0xc08dafcdl,
0x7b1a9a03l, 0x1c1f11d8l, 0x84250e7fl, 0x979db248l, 0xebdc0501l, 0xb9553395l,
0xe3c05ea8l, 0xb1e51c4cl, 0x13b0e681l, 0x3b407766l, 0x36db3087l, 0xee17c9fcl,
0x6c53ecf2l, 0xadccc58fl, 0xc427660bl, 0xefd5867dl, 0x9b6d54a5l, 0x6ff1aeffl,
0x8e787952l, 0x9e2bffe0l, 0x8761d034l, 0xe00bdbadl, 0xae99a8d3l, 0xcc03f6e2l,
0xfd0ed807l, 0x0e508ae3l, 0xb74182abl, 0x4349245dl, 0xd120a465l, 0xb246a641l,
0xaf3b7ab0l, 0x2a6488bbl, 0x4b3a0d1fl, 0xe7c7e58cl, 0x3faff2ebl, 0x90445ffdl,
0xcf38c393l, 0x995d07e7l, 0xf24f1b36l, 0x356f6891l, 0x6d6ebcbel, 0x8da9e262l,
0x50fd520el, 0x5bca9e1el, 0x37472cf3l, 0x69075057l, 0x7ec5fdedl, 0x0cab892al,
0xfb2412bal, 0x1728debfl, 0xa000a988l, 0xd843ce79l, 0x042e20ddl, 0x4fe8f853l,
0x56659c3cl, 0x2739d119l, 0xa78a6120l, 0x80960375l, 0x70420611l, 0x85e09f78l,
0xabd17e96l, 0x1b513eafl, 0x1e01eb63l, 0x26ad2133l, 0xa890c094l, 0x7613cf60l,
0x817e781bl, 0xa39113d7l, 0xe957fa58l, 0x4131b99el, 0x28b1efdal, 0x66acfba7l,
0xff68944al, 0x77a44fd1l, 0x7f331522l, 0x59ffb3fal, 0xa6df935bl, 0xfa12d9dfl,
0xc6bf6f3fl, 0x89520cf6l, 0x659edd6al, 0x544da739l, 0x8b052538l, 0x7c30ea21l,
0xc2345525l, 0x15927fb2l, 0x144a436bl, 0xba107b8bl, 0x1219ac97l, 0x06730432l,
0x31831ab3l, 0xc55a5c24l, 0xaa0fcd3el, 0xe5606be8l, 0x5c88f19bl, 0x4c0841eel,
0x1fe37267l, 0x11f9c4f4l, 0x9f1b9dael, 0x864e76d0l, 0xe637c731l, 0xd97d23a6l,
0x32f53d5cl, 0xb8161980l, 0x93fa0f84l, 0xcaef0870l, 0x8874487el, 0x98f2cc73l,
0x645fb5c6l, 0xcd853659l, 0x2062470dl, 0x16ede8e9l, 0x6b06dab5l, 0x78b43900l,
0xfc95b786l, 0x5d8e7de1l, 0x465b5954l, 0xfe7ba014l, 0xf7d23f7bl, 0x92bc8b18l,
0x03593592l, 0x55cef4f7l, 0x74b27317l, 0x79de1fc2l, 0xc8a0bfbdl, 0x229398ccl,
0x62a602cel, 0xbcb94661l, 0x5336d206l, 0xd2a375fel, 0x6a6ab483l, 0x4702a5a4l,
0xa2e9d73dl, 0x23a2e0f1l, 0x9189140al, 0x581d18dcl, 0xb39a922bl, 0x82356212l,
0xd5f432a9l, 0xd356c2a3l, 0x5f765b4dl, 0x450afcc8l, 0x4415e137l, 0xe8ecdfbcl,
0xed0de3eal, 0x60d42b13l, 0xf13df971l, 0x71fc5da2l, 0xc1455340l, 0xf087742fl,
0xf55e5751l, 0x67b3c1f8l, 0xac6b8774l, 0x7dcfaaacl, 0x95983bc0l, 0x489bb0b1l,
0x2c184223l, 0x964b6726l, 0x2bd3271cl, 0x72266472l, 0xded64530l, 0x0a2aa343l,
0xd4f716a0l, 0xb4dad6d9l, 0x2184345el, 0x512c990cl, 0x29d92d08l, 0x2ebe709al,
0x01144c69l, 0x34584b9dl, 0xe4634ed6l, 0xecc963cfl, 0x3c6984aal, 0x4ed056efl,
0x9ca56976l, 0x8f3e80d4l, 0xb5bae7c5l, 0x30b5caf5l, 0x63f33a64l, 0xa9e4bbdel,
0xf6b82298l, 0x4d673c1dl, 0x4b4f1121l, 0xba183081l, 0xc784f41fl, 0xd17d0bacl,
0x083d2267l, 0x37b1361el, 0x3581ad05l, 0xfda2f6bcl, 0x1e892cddl, 0xb56d3c3al,
0x32140e46l, 0x138d8aabl, 0xe14773d4l, 0x5b0e71dfl, 0x5d1fe055l, 0x3fb991d3l,
0xf1f46c71l, 0xa325988cl, 0x10f66e80l, 0xb1006348l, 0x726a9f60l, 0x3b67f8bal,
0x4e114ef4l, 0x05c52115l, 0x4c5ca11cl, 0x99e1efd8l, 0x471b83b3l, 0xcbf7e524l,
0x43ad82f5l, 0x690ca93bl, 0xfaa61bb2l, 0x12a832b5l, 0xb734f943l, 0xbd22aea7l,
0x88fec626l, 0x5e80c3e7l, 0xbe3eaf5el, 0x44617652l, 0xa5724475l, 0xbb3b9695l,
0x7f3fee8fl, 0x964e7debl, 0x518c052dl, 0x2a0bbc2bl, 0xc2175f5cl, 0x9a7b3889l,
0xa70d8d0cl, 0xeaccdd29l, 0xcccd6658l, 0x34bb25e6l, 0xb8391090l, 0xf651356fl,
0x52987c9el, 0x0c16c1cdl, 0x8e372d3cl, 0x2fc6ebbdl, 0x6e5da3e3l, 0xb0e27239l,
0x5f685738l, 0x45411786l, 0x067f65f8l, 0x61778b40l, 0x81ab2e65l, 0x14c8f0f9l,
0xa6b7b4cel, 0x4036eaecl, 0xbf62b00al, 0xecfd5e02l, 0x045449a6l, 0xb20afd28l,
0x2166d273l, 0x0d13a863l, 0x89508756l, 0xd51a7530l, 0x2d653f7al, 0x3cdbdbc3l,
0x80c9df4fl, 0x3d5812d9l, 0x53fbb1f3l, 0xc0f185c0l, 0x7a3c3d7el, 0x68646410l,
0x857607a0l, 0x1d12622el, 0x97f33466l, 0xdb4c9917l, 0x6469607cl, 0x566e043dl,
0x79ef1edbl, 0x2c05898dl, 0xc9578e25l, 0xcd380101l, 0x46e04377l, 0x7d1cc7a9l,
0x6552b837l, 0x20192608l, 0xb97500c5l, 0xed296b44l, 0x368648b4l, 0x62995cd5l,
0x82731400l, 0xf9aebd8bl, 0x3844c0c7l, 0x7c2de794l, 0x33a1a770l, 0x8ae528c2l,
0x5a2be812l, 0x1f8f4a07l, 0x2b5ed7cal, 0x937eb564l, 0x6fda7e11l, 0xe49b5d6cl,
0xb4b3244el, 0x18aa53a4l, 0x3a061334l, 0x4d6067a3l, 0x83ba5868l, 0x9bdf4dfel,
0x7449f261l, 0x709f8450l, 0xcad133cbl, 0xde941c3fl, 0xf52ae484l, 0x781d77edl,
0x7e4395f0l, 0xae103b59l, 0x922331bbl, 0x42ce50c8l, 0xe6f08153l, 0xe7d941d0l,
0x5028ed6bl, 0xb3d2c49bl, 0xad4d9c3el, 0xd201fb6el, 0xa45bd5bel, 0xffcb7f4bl,
0x579d7806l, 0xf821bb5bl, 0x59d592adl, 0xd0be0c31l, 0xd4e3b676l, 0x0107165al,
0x0fe939d2l, 0x49bcaafdl, 0x55ffcfe5l, 0x2ec1f783l, 0xf39a09a5l, 0x3eb42772l,
0x19b55a5dl, 0x024a0679l, 0x8c83b3f7l, 0x8642ba1dl, 0xacacd9eal, 0x87d352c4l,
0x60931f45l, 0xa05f97d7l, 0x1cecd42cl, 0xe2fcc87bl, 0xb60f94e2l, 0x67a34b0bl,
0xfcdd40c9l, 0x0b150a27l, 0xd3ee9e04l, 0x582e29e9l, 0x4ac22b41l, 0x6ac4e1b8l,
0xbccaa51al, 0x237af30el, 0xebc3b709l, 0xc4a59d19l, 0x284bc98al, 0xe9d41a93l,
0x6bfa2018l, 0x73b2d651l, 0x11f9a2fal, 0xce09bff1l, 0x41a470aal, 0x25888f22l,
0x77e754e8l, 0xf7330d8el, 0x158eab16l, 0xc5d68842l, 0xc685a6f6l, 0xe5b82fdel,
0x09ea3a96l, 0x6dde1536l, 0x4fa919dal, 0x26c0be9fl, 0x9eed6f69l, 0xf05555f2l,
0xe06fc285l, 0x9cd76d23l, 0xaf452a92l, 0xefc74cb7l, 0x9d6b4732l, 0x8be408eel,
0x22401d0dl, 0xee6c459dl, 0x7587cb82l, 0xe8746862l, 0x5cbdde87l, 0x98794278l,
0x31afb94dl, 0xc11e0f2fl, 0x30e8fc2al, 0xcf3261efl, 0x1a3023e1l, 0xaa2f86cfl,
0xf202e24al, 0x8d08dcffl, 0x764837c6l, 0xa26374ccl, 0x9f7c3e88l, 0x949cc57dl,
0xdd26a07fl, 0xc39efab0l, 0xc8f879a1l, 0xdce67bb9l, 0xf4b0a435l, 0x912c9ae0l,
0xd85603e4l, 0x953a9bbfl, 0xfb8290d6l, 0x0aebcd5fl, 0x16206a9al, 0x6c787a14l,
0xd9a0f16al, 0x29bf4f74l, 0x8f8bce91l, 0x0e5a9354l, 0xab038cb1l, 0x1b8ad11bl,
0xe327ff49l, 0x0053da20l, 0x90cf51dcl, 0xda92fe6dl, 0x0390ca47l, 0xa8958097l,
0xa9dc5bafl, 0x3931e3c1l, 0x840446b6l, 0x63d069fbl, 0xd7460299l, 0x7124ecd1l,
0x0791e613l, 0x485918fcl, 0xd635d04cl, 0xdf96ac33l, 0x66f2d303l, 0x247056ael,
0xa1a7b2a8l, 0x27d8cc9cl, 0x17b6e998l, 0x7bf5590fl, 0xfe97f557l, 0x5471d8a2l,
0x83a327a1l, 0x9f379f51l, 0x40a7d007l, 0x11307423l, 0x224587c1l, 0xac27d63bl,
0x3b7e64eal, 0x2e1cbfa6l, 0x09996000l, 0x03bc0e2cl, 0xd4c4478al, 0x4542e0abl,
0xfeda26d4l, 0xc1d10fcbl, 0x8252f596l, 0x4494eb5cl, 0xa362f314l, 0xf5ba81fdl,
0x75c3a376l, 0x4ca214cal, 0xe164deddl, 0x5088fa97l, 0x4b0930e0l, 0x2fcfb7e8l,
0x33a6f4b2l, 0xc7e94211l, 0x2d66c774l, 0x43be8bael, 0xc663d445l, 0x908eb130l,
0xf4e3be15l, 0x63b9d566l, 0x529396b5l, 0x1e1be743l, 0x4d5ff63fl, 0x985e4a83l,
0x71ab9df7l, 0xc516c6f5l, 0x85c19ab4l, 0x1f4daee4l, 0xf2973431l, 0xb713dc5el,
0x3f2e159al, 0xc824da16l, 0x06bf376al, 0xb2fe23ecl, 0xe39b1c22l, 0xf1eecb5fl,
0x08e82d52l, 0x565686c2l, 0xab0aea93l, 0xfd47219fl, 0xebdbabd7l, 0x2404a185l,
0x8c7312b9l, 0xa8f2d828l, 0x0c8902dal, 0x65b42b63l, 0xc0bbef62l, 0x4e3e4cefl,
0x788f8018l, 0xee1ebab7l, 0x93928f9dl, 0x683d2903l, 0xd3b60689l, 0xafcb0ddcl,
0x88a4c47al, 0xf6dd9c3dl, 0x7ea5fca0l, 0x8a6d7244l, 0xbe11f120l, 0x04ff91b8l,
0x8d2dc8c0l, 0x27f97fdbl, 0x7f9e1f47l, 0x1734f0c7l, 0x26f3ed8el, 0x0df8f2bfl,
0xb0833d9el, 0xe420a4e5l, 0xa423cae6l, 0x95616772l, 0x9ae6c049l, 0x075941f2l,
0xd8e12812l, 0x000f6f4fl, 0x3c0d6b05l, 0x6cef921cl, 0xb82bc264l, 0x396cb008l,
0x5d608a6fl, 0x6d7782c8l, 0x186550aal, 0x6b6fec09l, 0x28e70b13l, 0x57ce5688l,
0xecd3af84l, 0x23335a95l, 0x91f40cd2l, 0x7b6a3b26l, 0xbd32b3b6l, 0x3754a6fbl,
0x8ed088f0l, 0xf867e87cl, 0x20851746l, 0x6410f9c6l, 0x35380442l, 0xc2ca10a7l,
0x1adea27fl, 0x76bddd79l, 0x92742cf4l, 0x0e98f7eel, 0x164e931dl, 0xb9c835b3l,
0x69060a99l, 0xb44c531el, 0xfa7b66fel, 0xc98a5b53l, 0x7d95aae9l, 0x302f467bl,
0x74b811del, 0xf3866abdl, 0xb5b3d32dl, 0xfc3157a4l, 0xd251fe19l, 0x0b5d8eacl,
0xda71ffd5l, 0x47ea05a3l, 0x05c6a9e1l, 0xca0ee958l, 0x9939034dl, 0x25dc5edfl,
0x79083cb1l, 0x86768450l, 0xcf757d6dl, 0x5972b6bcl, 0xa78d59c9l, 0xc4ad8d41l,
0x2a362ad3l, 0xd1179991l, 0x601407ffl, 0xdcf50917l, 0x587069d0l, 0xe0821ed6l,
0xdbb59427l, 0x73911a4bl, 0x7c904fc3l, 0x844afb92l, 0x6f8c955dl, 0xe8c0c5bbl,
0xb67ab987l, 0xa529d96cl, 0xf91f7181l, 0x618b1b06l, 0xe718bb0cl, 0x8bd7615bl,
0xd5a93a59l, 0x54aef81bl, 0x772136e3l, 0xce44fd9cl, 0x10cda57el, 0x87d66e0bl,
0x3d798967l, 0x1b2c1804l, 0x3edfbd68l, 0x15f6e62bl, 0xef68b854l, 0x3896db35l,
0x12b7b5e2l, 0xcb489029l, 0x9e4f98a5l, 0x62eb77a8l, 0x217c24a2l, 0x964152f6l,
0x49b2080al, 0x53d23ee7l, 0x48fb6d69l, 0x1903d190l, 0x9449e494l, 0xbf6e7886l,
0xfb356cfal, 0x3a261365l, 0x424bc1ebl, 0xa1192570l, 0x019ca782l, 0x9d3f7e0el,
0x9c127575l, 0xedf02039l, 0xad57bccel, 0x5c153277l, 0x81a84540l, 0xbcaa7356l,
0xccd59b60l, 0xa62a629bl, 0xa25ccd10l, 0x2b5b65cfl, 0x1c535832l, 0x55fd4e3al,
0x31d9790dl, 0xf06bc37dl, 0x4afc1d71l, 0xaeed5533l, 0xba461634l, 0xbb694b78l,
0x5f3a5c73l, 0x6a3c764al, 0x8fb0cca9l, 0xf725684cl, 0x4fe5382fl, 0x1d0163afl,
0x5aa07a8fl, 0xe205a8edl, 0xc30bad38l, 0xff22cf1fl, 0x72432e2el, 0x32c2518bl,
0x3487ce4el, 0x7ae0ac02l, 0x709fa098l, 0x0a3b395al, 0x5b4043f8l, 0xa9e48c36l,
0x149a8521l, 0xd07dee6bl, 0x46acd2f3l, 0x8958dffcl, 0xb3a1223cl, 0xb11d31c4l,
0xcd7f4d3el, 0x0f28e3adl, 0xe5b100bel, 0xaac54824l, 0xe9c9d7bal, 0x9bd47001l,
0x80f149b0l, 0x66022f0fl, 0x020c4048l, 0x6efa192al, 0x67073f8dl, 0x13ec7bf9l,
0x3655011al, 0xe6afe157l, 0xd9845f6el, 0xdecc4425l, 0x511ae2ccl, 0xdf81b4d8l,
0xd7809e55l, 0xd6d883d9l, 0x2cc7978cl, 0x5e787cc5l, 0xdd0033d1l, 0xa050c937l,
0x97f75dcdl, 0x299de580l, 0x41e2b261l, 0xea5a54f1l, 0x7e672590l, 0xbea513bbl,
0x2c906fe6l, 0x86029c2bl, 0x55dc4f74l, 0x0553398el, 0x63e09647l, 0xcafd0babl,
0x264c37dfl, 0x8272210fl, 0x67afa669l, 0x12d98a5fl, 0x8cab23c4l, 0x75c68bd1l,
0xc3370470l, 0x33f37f4el, 0x283992ffl, 0xe73a3a67l, 0x1032f283l, 0xf5ad9fc2l,
0x963f0c5dl, 0x664fbc45l, 0x202ba41cl, 0xc7c02d80l, 0x54731e84l, 0x8a1085f5l,
0x601d80fbl, 0x2f968e55l, 0x35e96812l, 0xe45a8f78l, 0xbd7de662l, 0x3b6e6eadl,
0x8097c5efl, 0x070b6781l, 0xb1e508f3l, 0x24e4fae3l, 0xb81a7805l, 0xec0fc918l,
0x43c8774bl, 0x9b2512a9l, 0x2b05ad04l, 0x32c2536fl, 0xedf236e0l, 0x8bc4b0cfl,
0xbaceb837l, 0x4535b289l, 0x0d0e94c3l, 0xa5a371d0l, 0xad695a58l, 0x39e3437dl,
0x9186bffcl, 0x21038c3bl, 0x0aa9dff9l, 0x5d1f06cel, 0x62def8a4l, 0xf740a2b4l,
0xa2575868l, 0x682683c1l, 0xdbb30facl, 0x61fe1928l, 0x468a6511l, 0xc61cd5f4l,
0xe54d9800l, 0x6b98d7f7l, 0x8418b6a5l, 0x5f09a5d2l, 0x90b4e80bl, 0x49b2c852l,
0x69f11c77l, 0x17412b7el, 0x7f6fc0edl, 0x56838dccl, 0x6e9546a2l, 0xd0758619l,
0x087b9b9al, 0xd231a01dl, 0xaf46d415l, 0x097060fdl, 0xd920f657l, 0x882d3f9fl,
0x3ae7c3c9l, 0xe8a00d9bl, 0x4fe67ebel, 0x2ef80eb2l, 0xc1916b0cl, 0xf4dffea0l,
0xb97eb3ebl, 0xfdff84ddl, 0xff8b14f1l, 0xe96b0572l, 0xf64b508cl, 0xae220a6el,
0x4423ae5al, 0xc2bece5el, 0xde27567cl, 0xfc935c63l, 0x47075573l, 0xe65b27f0l,
0xe121fd22l, 0xf2668753l, 0x2debf5d7l, 0x8347e08dl, 0xac5eda03l, 0x2a7cebe9l,
0x3fe8d92el, 0x23542fe4l, 0x1fa7bd50l, 0xcf9b4102l, 0x9d0dba39l, 0x9cb8902al,
0xa7249d8bl, 0x0f6d667al, 0x5ebfa9ecl, 0x6a594df2l, 0x79600938l, 0x023b7591l,
0xea2c79c8l, 0xc99d07eal, 0x64cb5ee1l, 0x1a9cab3dl, 0x76db9527l, 0xc08e012fl,
0x3dfb481al, 0x872f22e7l, 0x2948d15cl, 0xa4782c79l, 0x6f50d232l, 0x78f0728al,
0x5a87aab1l, 0xc4e2c19cl, 0xee767387l, 0x1b2a1864l, 0x7b8d10d3l, 0xd1713161l,
0x0eeac456l, 0xd8799e06l, 0xb645b548l, 0x4043cb65l, 0xa874fb29l, 0x4b12d030l,
0x7d687413l, 0x18ef9a1fl, 0xd7631d4cl, 0x5829c7dal, 0xcdfa30fal, 0xc5084bb0l,
0x92cd20e2l, 0xd4c16940l, 0x03283ec0l, 0xa917813fl, 0x9a587d01l, 0x70041f8fl,
0xdc6ab1dcl, 0xddaee3d5l, 0x31829742l, 0x198c022dl, 0x1c9eafcbl, 0x5bbc6c49l,
0xd3d3293al, 0x16d50007l, 0x04bb8820l, 0x3c5c2a41l, 0x37ee7af8l, 0x8eb04025l,
0x9313ecbal, 0xbffc4799l, 0x8955a744l, 0xef85d633l, 0x504499a7l, 0xa6ca6a86l,
0xbb3d3297l, 0xb34a8236l, 0x6dccbe4fl, 0x06143394l, 0xce19fc7bl, 0xccc3c6c6l,
0xe36254ael, 0x77b7eda1l, 0xa133dd9el, 0xebf9356al, 0x513ccf88l, 0xe2a1b417l,
0x972ee5bdl, 0x853824cdl, 0x5752f4eel, 0x6c1142e8l, 0x3ea4f309l, 0xb2b5934al,
0xdfd628aal, 0x59acea3el, 0xa01eb92cl, 0x389964bcl, 0xda305dd4l, 0x019a59b7l,
0x11d2ca93l, 0xfaa6d3b9l, 0x4e772ecal, 0x72651776l, 0xfb4e5b0el, 0xa38f91a8l,
0x1d0663b5l, 0x30f4f192l, 0xb50051b6l, 0xb716ccb3l, 0x4abd1b59l, 0x146c5f26l,
0xf134e2del, 0x00f67c6cl, 0xb0e1b795l, 0x98aa4ec7l, 0x0cc73b34l, 0x654276a3l,
0x8d1ba871l, 0x740a5216l, 0xe0d01a23l, 0x9ed161d6l, 0x9f36a324l, 0x993ebb7fl,
0xfeb9491bl, 0x365ddcdbl, 0x810cffc5l, 0x71ec0382l, 0x2249e7bfl, 0x48817046l,
0xf3a24a5bl, 0x4288e4d9l, 0x0bf5c243l, 0x257fe151l, 0x95b64c0dl, 0x4164f066l,
0xaaf7db08l, 0x73b1119dl, 0x8f9f7bb8l, 0xd6844596l, 0xf07a34a6l, 0x53943d0al,
0xf9dd166dl, 0x7a8957afl, 0xf8ba3ce5l, 0x27c9621el, 0x5cdae910l, 0xc8518998l,
0x941538fel, 0x136115d8l, 0xaba8443cl, 0x4d01f931l, 0x34edf760l, 0xb45f266bl,
0xd5d4de14l, 0x52d8ac35l, 0x15cfd885l, 0xcbc5cd21l, 0x4cd76d4dl, 0x7c80ef54l,
0xbc92ee75l, 0x1e56a1f6l, 0xbaa20b6cl, 0x9ffbad26l, 0xe1f7d738l, 0x794aec8dl,
0xc9e9cf3cl, 0x8a9a7846l, 0xc57c4685l, 0xb9a92fedl, 0x29cb141fl, 0x52f9ddb7l,
0xf68ba6bcl, 0x19ccc020l, 0x4f584aaal, 0x3bf6a596l, 0x003b7cf7l, 0x54f0ce9al,
0xa7ec4303l, 0x46cf0077l, 0x78d33aa1l, 0x215247d9l, 0x74bcdf91l, 0x08381d30l,
0xdac43e40l, 0x64872531l, 0x0beffe5fl, 0xb317f457l, 0xaebb12dal, 0xd5d0d67bl,
0x7d75c6b4l, 0x42a6d241l, 0x1502d0a9l, 0x3fd97fffl, 0xc6c3ed28l, 0x81868d0al,
0x92628bc5l, 0x86679544l, 0xfd1867afl, 0x5ca3ea61l, 0x568d5578l, 0x4a2d71f4l,
0x43c9d549l, 0x8d95de2bl, 0x6e5c74a0l, 0x9120ffc7l, 0x0d05d14al, 0xa93049d3l,
0xbfa80e17l, 0xf4096810l, 0x043f5ef5l, 0xa673b4f1l, 0x6d780298l, 0xa4847783l,
0x5ee726fbl, 0x9934c281l, 0x220a588cl, 0x384e240fl, 0x933d5c69l, 0x39e5ef47l,
0x26e8b8f3l, 0x4c1c6212l, 0x8040f75dl, 0x074b7093l, 0x6625a8d7l, 0x36298945l,
0x76285088l, 0x651d37c3l, 0x24f5274dl, 0xdbca3dabl, 0x186b7ee1l, 0xd80f8182l,
0x14210c89l, 0x943a3075l, 0x4e6e11c4l, 0x4d7e6badl, 0xf05064c8l, 0x025dcd97l,
0x4bc10302l, 0x7cede572l, 0x8f90a970l, 0xab88eebal, 0xb5998029l, 0x5124d839l,
0xb0eeb6a3l, 0x89ddabdcl, 0xe8074d76l, 0xa1465223l, 0x32518cf2l, 0x9d39d4ebl,
0xc0d84524l, 0xe35e6ea8l, 0x7abf3804l, 0x113e2348l, 0x9ae6069dl, 0xb4dfdabbl,
0xa8c5313fl, 0x23ea3f79l, 0x530e36a2l, 0xa5fd228bl, 0x95d1d350l, 0x2b14cc09l,
0x40042956l, 0x879d05ccl, 0x2064b9cal, 0xacaca40el, 0xb29c846el, 0x9676c9e3l,
0x752b7b8al, 0x7be2bcc2l, 0x6bd58f5el, 0xd48f4c32l, 0x606835e4l, 0x9cd7c364l,
0x2c269b7al, 0x3a0d079cl, 0x73b683fel, 0x45374f1el, 0x10afa242l, 0x577f8666l,
0xddaa10f6l, 0xf34f561cl, 0x3d355d6bl, 0xe47048ael, 0xaa13c492l, 0x050344fdl,
0x2aab5151l, 0xf5b26ae5l, 0xed919a59l, 0x5ac67900l, 0xf1cde380l, 0x0c79a11bl,
0x351533fcl, 0xcd4d8e36l, 0x1f856005l, 0x690b9fddl, 0xe736dccfl, 0x1d47bf6al,
0x7f66c72al, 0x85f21b7fl, 0x983cbdb6l, 0x01ebbebfl, 0x035f3b99l, 0xeb111f34l,
0x28cefdc6l, 0x5bfc9ecdl, 0xf22eacb0l, 0x9e41cbb2l, 0xe0f8327cl, 0x82e3e26fl,
0xfc43fc86l, 0xd0ba66dfl, 0x489ef2a7l, 0xd9e0c81dl, 0x68690d52l, 0xcc451367l,
0xc2232e16l, 0xe95a7335l, 0x0fdae19bl, 0xff5b962cl, 0x97596527l, 0xc46db333l,
0x3ed4c562l, 0xc14c9d9el, 0x5d6faa21l, 0x638e940dl, 0xf9316d58l, 0x47b3b0eal,
0x30ffcad2l, 0xce1bba7dl, 0x1e6108e6l, 0x2e1ea33dl, 0x507bf05bl, 0xfafef94bl,
0xd17de8e2l, 0x5598b214l, 0x1663f813l, 0x17d25a2dl, 0xeefa5ff9l, 0x582f4e37l,
0x12128773l, 0xfef17ab8l, 0x06005322l, 0xbb32bbc9l, 0x8c898508l, 0x592c15f0l,
0xd38a4054l, 0x4957b7d6l, 0xd2b891dbl, 0x37bd2d3el, 0x34ad20cbl, 0x622288e9l,
0x2dc7345al, 0xafb416c0l, 0x1cf459b1l, 0xdc7739fal, 0x0a711a25l, 0x13e18a0cl,
0x5f72af4cl, 0x6ac8db11l, 0xbe53c18el, 0x1aa569b9l, 0xef551ea4l, 0xa02a429fl,
0xbd16e790l, 0x7eb9171al, 0x77d693d8l, 0x8e06993al, 0x9bde7560l, 0xe5801987l,
0xc37a09bel, 0xb8db76acl, 0xe2087294l, 0x6c81616dl, 0xb7f30fe7l, 0xbc9b82bdl,
0xfba4e4d4l, 0xc7b1012fl, 0xa20c043bl, 0xde9febd0l, 0x2f9297cel, 0xe610aef8l,
0x70b06f19l, 0xc86ae00bl, 0x0e01988fl, 0x41192ae0l, 0x448c1cb5l, 0xadbe92eel,
0x7293a007l, 0x1b54b5b3l, 0xd61f63d1l, 0xeae40a74l, 0x61a72b55l, 0xec83a7d5l,
0x88942806l, 0x90a07da5l, 0xd7424b95l, 0x67745b4el, 0xa31a1853l, 0xca6021efl,
0xdfb56c4fl, 0xcbc2d915l, 0x3c48e918l, 0x8bae3c63l, 0x6f659c71l, 0xf8b754c1l,
0x2782f3del, 0xf796f168l, 0x71492c84l, 0x33c0f5a6l, 0x3144f6ecl, 0x25dc412el,
0xb16c5743l, 0x83a1fa7el, 0x0997b101l, 0xb627e6e8l, 0xcf33905cl, 0x8456fb65l,
0xb29bea74l, 0xc35da605l, 0x305c1ca3l, 0xd2e9f5bcl, 0x6fd5bff4l, 0xff347703l,
0xfc45b163l, 0xf498e068l, 0xb71229fcl, 0x81acc3fbl, 0x78538a8bl, 0x984ecf81l,
0xa5da47a4l, 0x8f259eefl, 0x6475dc65l, 0x081865b9l, 0x49e14a3cl, 0x19e66079l,
0xd382e91bl, 0x5b109794l, 0x3f9f81e1l, 0x4470a388l, 0x41601abel, 0xaaf9f407l,
0x8e175ef6l, 0xed842297l, 0x893a4271l, 0x1790839al, 0xd566a99el, 0x6b417deel,
0x75c90d23l, 0x715edb31l, 0x723553f7l, 0x9afb50c9l, 0xfbc5f600l, 0xcd3b6a4el,
0x97ed0fbal, 0x29689aecl, 0x63135c8el, 0xf0e26c7el, 0x0692ae7fl, 0xdbb208ffl,
0x2ede3e9bl, 0x6a65bebdl, 0xd40867e9l, 0xc954afc5l, 0x73b08201l, 0x7ffdf809l,
0x1195c24fl, 0x1ca5adcal, 0x74bd6d1fl, 0xb393c455l, 0xcadfd3fal, 0x99f13011l,
0x0ebca813l, 0x60e791b8l, 0x6597ac7al, 0x18a7e46bl, 0x09cb49d3l, 0x0b27df6dl,
0xcfe52f87l, 0xcef66837l, 0xe6328035l, 0xfa87c592l, 0x37baff93l, 0xd71fcc99l,
0xdcab205cl, 0x4d7a5638l, 0x48012510l, 0x62797558l, 0xb6cf1fe5l, 0xbc311834l,
0x9c2373acl, 0x14ec6175l, 0xa439cbdfl, 0x54afb0eal, 0xd686960bl, 0xfdd0d47bl,
0x7b063902l, 0x8b78bac3l, 0x26c6a4d5l, 0x5c0055b6l, 0x2376102el, 0x0411783el,
0x2aa3f1cdl, 0x51fc6ea8l, 0x701ce243l, 0x9b2a0abbl, 0x0ad93733l, 0x6e80d03dl,
0xaf6295d1l, 0xf629896fl, 0xa30b0648l, 0x463d8dd4l, 0x963f84cbl, 0x01ff94f8l,
0x8d7fefdcl, 0x553611c0l, 0xa97c1719l, 0xb96af759l, 0xe0e3c95el, 0x0528335bl,
0x21fe5925l, 0x821a5245l, 0x807238b1l, 0x67f23db5l, 0xea6b4eabl, 0x0da6f985l,
0xab1bc85al, 0xef8c90e4l, 0x4526230el, 0x38eb8b1cl, 0x1b91cd91l, 0x9fce5f0cl,
0xf72cc72bl, 0xc64f2617l, 0xdaf7857dl, 0x7d373cf1l, 0x28eaedd7l, 0x203887d0l,
0xc49a155fl, 0xa251b3b0l, 0xf2d47ae3l, 0x3d9ef267l, 0x4a94ab2fl, 0x7755a222l,
0x0205e329l, 0xc28fa7a7l, 0xaec1fe51l, 0x270f164cl, 0x8c6d01bfl, 0x53b5bc98l,
0xc09d3febl, 0x834986ccl, 0x4309a12cl, 0x578b2a96l, 0x3bb74b86l, 0x69561b4al,
0x037e32f3l, 0xde335b08l, 0xc5156be0l, 0xe7ef09adl, 0x93b834c7l, 0xa7719352l,
0x59302821l, 0xe3529d26l, 0xf961da76l, 0xcb142c44l, 0xa0f3b98dl, 0x76502457l,
0x945a414bl, 0x078eeb12l, 0xdff8de69l, 0xeb6c8c2dl, 0xbda90c4dl, 0xe9c44d16l,
0x168dfd66l, 0xad64763bl, 0xa65fd764l, 0x95a29c06l, 0x32d7713fl, 0x40f0b277l,
0x224af08fl, 0x004cb5e8l, 0x92574814l, 0x8877d827l, 0x3e5b2d04l, 0x68c2d5f2l,
0x86966273l, 0x1d433adal, 0x8774988al, 0x3c0e0bfel, 0xddad581dl, 0x2fd654edl,
0x0f4769fdl, 0xc181ee9dl, 0x5fd88f61l, 0x341dbb3al, 0x528543f9l, 0xd92235cfl,
0x1ea82eb4l, 0xb5cd790fl, 0x91d24f1el, 0xa869e6c2l, 0x61f474d2l, 0xcc205addl,
0x0c7bfba9l, 0xbf2b0489l, 0xb02d72d8l, 0x2b46ece6l, 0xe4dcd90al, 0xb8a11440l,
0xee8a63b7l, 0x854dd1a1l, 0xd1e00583l, 0x42b40e24l, 0x9e8964del, 0xb4b35d78l,
0xbec76f6el, 0x24b9c620l, 0xd8d399a6l, 0x5adb2190l, 0x2db12730l, 0x3a5866afl,
0x58c8fadbl, 0x5d8844e7l, 0x8a4bf380l, 0x15a01d70l, 0x79f5c028l, 0x66be3b8cl,
0xf3e42b53l, 0x56990039l, 0x2c0c3182l, 0x5e16407cl, 0xecc04515l, 0x6c440284l,
0x4cb6701al, 0x13bfc142l, 0x9d039f6al, 0x4f6e92c8l, 0xa1407c62l, 0x8483a095l,
0xc70ae1c4l, 0xe20213a2l, 0xbacafc41l, 0x4ecc12b3l, 0x4bee3646l, 0x1fe807ael,
0x25217f9cl, 0x35dde5f5l, 0x7a7dd6cel, 0xf89cce50l, 0xac07b718l, 0x7e73d2c6l,
0xe563e76cl, 0x123ca536l, 0x3948ca56l, 0x9019dd49l, 0x10aa88d9l, 0xc82451e2l,
0x473eb6d6l, 0x506fe854l, 0xe8bb03a5l, 0x332f4c32l, 0xfe1e1e72l, 0xb1ae572al,
0x7c0d7bc1l, 0xe1c37eb2l, 0xf542aa60l, 0xf1a48ea0l, 0xd067b89fl, 0xbbfa195dl,
0x1a049b0dl, 0x315946aal, 0x36d1b447l, 0x6d2ebdf0l, 0x0d188a6dl, 0x12cea0dbl,
0x7e63740el, 0x6a444821l, 0x253d234fl, 0x6ffc6597l, 0x94a6bdefl, 0x33ee1b2fl,
0x0a6c00c0l, 0x3aa336b1l, 0x5af55d17l, 0x265fb3dcl, 0x0e89cf4dl, 0x0786b008l,
0xc80055b8l, 0x6b17c3cel, 0x72b05a74l, 0xd21a8d78l, 0xa6b70840l, 0xfe8eae77l,
0xed69565cl, 0x55e1bcf4l, 0x585c2f60l, 0xe06f1a62l, 0xad67c0cdl, 0x7712af88l,
0x9cc26acal, 0x1888053dl, 0x37eb853el, 0x9215abd7l, 0xde30adfcl, 0x1f1038e6l,
0x70c51c8al, 0x8d586c26l, 0xf72bdd90l, 0x4dc3ce15l, 0x68eaeefal, 0xd0e9c8b9l,
0x200f9c44l, 0xddd141bal, 0x024bf1d3l, 0x0f64c9d4l, 0xc421e9e9l, 0x9d11c14cl,
0x9a0dd9e4l, 0x5f92ec19l, 0x1b980df0l, 0x1dcc4542l, 0xb8fe8c56l, 0x0c9c9167l,
0x4e81eb49l, 0xca368f27l, 0xe3603b37l, 0xea08acccl, 0xac516992l, 0xc34f513bl,
0x804d100dl, 0x6edca4c4l, 0xfc912939l, 0x29d219b0l, 0x278aaa3cl, 0x4868da7dl,
0x54e890b7l, 0xb46d735al, 0x514589aal, 0xd6c630afl, 0x4980dfe8l, 0xbe3ccc55l,
0x59d41202l, 0x650c078bl, 0xaf3a9e7bl, 0x3ed9827al, 0x9e79fc6el, 0xaadbfbael,
0xc5f7d803l, 0x3daf7f50l, 0x67b4f465l, 0x73406e11l, 0x39313f8cl, 0x8a6e6686l,
0xd8075f1fl, 0xd3cbfed1l, 0x69c7e49cl, 0x930581e0l, 0xe4b1a5a8l, 0xbbc45472l,
0x09ddbf58l, 0xc91d687el, 0xbdbffda5l, 0x88c08735l, 0xe9e36bf9l, 0xdb5ea9b6l,
0x95559404l, 0x08f432fbl, 0xe24ea281l, 0x64663579l, 0x000b8010l, 0x7914e7d5l,
0x32fd0473l, 0xd1a7f0a4l, 0x445ab98el, 0xec72993fl, 0xa29a4d32l, 0xb77306d8l,
0xc7c97cf6l, 0x7b6ab645l, 0xf5ef7adfl, 0xfb2e15f7l, 0xe747f757l, 0x5e944354l,
0x234a2669l, 0x47e46359l, 0x9b9d11a9l, 0x40762cedl, 0x56f1de98l, 0x11334668l,
0x890a9a70l, 0x1a296113l, 0xb3bd4af5l, 0x163b7548l, 0xd51b4f84l, 0xb99b2abcl,
0x3cc1dc30l, 0xa9f0b56cl, 0x812272b2l, 0x0b233a5fl, 0xb650dbf2l, 0xf1a0771bl,
0x36562b76l, 0xdc037b0fl, 0x104c97ffl, 0xc2ec98d2l, 0x90596f22l, 0x28b6620bl,
0xdf42b212l, 0xfdbc4243l, 0xf3fb175el, 0x4a2d8b00l, 0xe8f3869bl, 0x30d69bc3l,
0x853714c8l, 0xa7751d2el, 0x31e56deal, 0xd4840b0cl, 0x9685d783l, 0x068c9333l,
0x8fba032cl, 0x76d7bb47l, 0x6d0ee22bl, 0xb546794bl, 0xd971b894l, 0x8b09d253l,
0xa0ad5761l, 0xee77ba06l, 0x46359f31l, 0x577cc7ecl, 0x52825efdl, 0xa4beed95l,
0x9825c52al, 0xeb48029al, 0xbaae59f8l, 0xcf490ee1l, 0xbc990164l, 0x8ca49dfel,
0x4f38a6e7l, 0x2ba98389l, 0x8228f538l, 0x199f64acl, 0x01a1cac5l, 0xa8b51641l,
0x5ce72d01l, 0x8e5df26bl, 0x60f28e1el, 0xcd5be125l, 0xe5b376bfl, 0x1c8d3116l,
0x7132cbb3l, 0xcb7ae320l, 0xc0fa5366l, 0xd7653e34l, 0x971c88c2l, 0xc62c7dd0l,
0x34d0a3dal, 0x868f6709l, 0x7ae6fa8fl, 0x22bbd523l, 0x66cd3d5bl, 0x1ef9288dl,
0xf9cf58c1l, 0x5b784e80l, 0x7439a191l, 0xae134c36l, 0x9116c463l, 0x2e9e1396l,
0xf8611f3al, 0x2d2f3307l, 0x247f37ddl, 0xc1e2ff9dl, 0x43c821e5l, 0x05ed5cabl,
0xef74e80al, 0x4cca6028l, 0xf0ac3cbdl, 0x5d874b29l, 0x6c62f6a6l, 0x4b2a2ef3l,
0xb1aa2087l, 0x62a5d0a3l, 0x0327221cl, 0xb096b4c6l, 0x417ec693l, 0xaba840d6l,
0x789725ebl, 0xf4b9e02dl, 0xe6e00975l, 0xcc04961al, 0x63f624bbl, 0x7fa21ecbl,
0x2c01ea7fl, 0xb2415005l, 0x2a8bbeb5l, 0x83b2b14el, 0xa383d1a7l, 0x5352f96al,
0x043ecdadl, 0xce1918a1l, 0xfa6be6c9l, 0x50def36fl, 0xf6b80ce2l, 0x4543ef7cl,
0x9953d651l, 0xf257955dl, 0x87244914l, 0xda1e0a24l, 0xffda4785l, 0x14d327a2l,
0x3b93c29fl, 0x840684b4l, 0x61ab71a0l, 0x9f7b784al, 0x2fd570cfl, 0x15955bdel,
0x38f8d471l, 0x3534a718l, 0x133fb71dl, 0x3fd80f52l, 0x4290a8bel, 0x75ff44c7l,
0xa554e546l, 0xe1023499l, 0xbf2652e3l, 0x7d20399el, 0xa1df7e82l, 0x177092eel,
0x217dd3f1l, 0x7c1ff8d9l, 0x12113f2el, 0xbfbd0785l, 0xf11793fbl, 0xa5bff566l,
0x83c7b0e5l, 0x72fb316bl, 0x75526a9al, 0x41e0e612l, 0x7156ba09l, 0x53ce7deel,
0x0aa26881l, 0xa43e0d7dl, 0x3da73ca3l, 0x182761edl, 0xbd5077ffl, 0x56db4aa0l,
0xe792711cl, 0xf0a4eb1dl, 0x7f878237l, 0xec65c4e8l, 0x08dc8d43l, 0x0f8ce142l,
0x8258abdal, 0xf4154e16l, 0x49dec2fdl, 0xcd8d5705l, 0x6c2c3a0fl, 0x5c12bb88l,
0xeff3cdb6l, 0x2c89ed8cl, 0x7beba967l, 0x2a142157l, 0xc6d0836fl, 0xb4f97e96l,
0x6931e969l, 0x514e6c7cl, 0xa7792600l, 0x0bbbf780l, 0x59671bbdl, 0x0707b676l,
0x37482d93l, 0x80af1479l, 0x3805a60dl, 0xe1f4cac1l, 0x580b3074l, 0x30b8d6cel,
0x05a304bel, 0xd176626dl, 0xebca97f3l, 0xbb201f11l, 0x6a1afe23l, 0xffaa86e4l,
0x62b4da49l, 0x1b6629f5l, 0xf5d9e092l, 0xf37f3dd1l, 0x619bd45bl, 0xa6ec8e4fl,
0x29c80939l, 0x0c7c0c34l, 0x9cfe6e48l, 0xe65fd3acl, 0x73613b65l, 0xb3c669f9l,
0xbe2e8a9el, 0x286f9678l, 0x5797fd13l, 0x99805d75l, 0xcfb641c5l, 0xa91074bal,
0x6343af47l, 0x6403cb46l, 0x8894c8dbl, 0x2663034cl, 0x3c40dc5el, 0x00995231l,
0x96789aa2l, 0x2efde4b9l, 0x7dc195e1l, 0x547dadd5l, 0x06a8ea04l, 0xf2347a63l,
0x5e0dc6f7l, 0x8462dfc2l, 0x1e6b2c3cl, 0x9bd275b3l, 0x91d419e2l, 0xbcefd17el,
0xb9003924l, 0xd07e7320l, 0xdef0495cl, 0xc36ad00el, 0x1785b1abl, 0x92e20bcfl,
0xb139f0e9l, 0x675bb9a1l, 0xaecfa4afl, 0x132376cbl, 0xe84589d3l, 0x79a05456l,
0xa2f860bcl, 0x1ae4f8b5l, 0x20df4db4l, 0xa1e1428bl, 0x3bf60a1al, 0x27ff7bf1l,
0xcb44c0e7l, 0xf7f587c4l, 0x1f3b9b21l, 0x94368f01l, 0x856e23a4l, 0x6f93de3fl,
0x773f5bbfl, 0x8b22056el, 0xdf41f654l, 0xb8246ff4l, 0x8d57bff2l, 0xd57167eal,
0xc5699f22l, 0x40734ba7l, 0x5d5c2772l, 0x033020a8l, 0xe30a7c4dl, 0xadc40fd6l,
0x76353441l, 0x5aa5229bl, 0x81516590l, 0xda49f14el, 0x4fa672a5l, 0x4d9fac5fl,
0x154be230l, 0x8a7a5cc0l, 0xce3d2f84l, 0xcca15514l, 0x5221360cl, 0xaf0fb81el,
0x5bdd5873l, 0xf6825f8fl, 0x1113d228l, 0x70ad996cl, 0x93320051l, 0x60471c53l,
0xe9ba567bl, 0x3a462ae3l, 0x5f55e72dl, 0x1d3c5ad7l, 0xdcfc45ecl, 0x34d812efl,
0xfa96ee1bl, 0x369d1ef8l, 0xc9b1a189l, 0x7c1d3555l, 0x50845edcl, 0x4bb31877l,
0x8764a060l, 0x8c9a9415l, 0x230e1a3al, 0xb05e9133l, 0x242b9e03l, 0xa3b99db7l,
0xc2d7fb0al, 0x3333849dl, 0xd27278d4l, 0xb5d3efa6l, 0x78ac28adl, 0xc7b2c135l,
0x0926ecf0l, 0xc1374c91l, 0x74f16d98l, 0x2274084al, 0x3f6d9cfal, 0x7ac0a383l,
0xb73aff1fl, 0x3909a23dl, 0x9f1653ael, 0x4e2f3e71l, 0xca5ab22al, 0xe01e3858l,
0x90c5a7ebl, 0x3e4a17dfl, 0xaa987fb0l, 0x488bbd62l, 0xb625062bl, 0x2d776bb8l,
0x43b5fc08l, 0x1490d532l, 0xd6d12495l, 0x44e89845l, 0x2fe60118l, 0x9d9ef950l,
0xac38133el, 0xd3864329l, 0x017b255al, 0xfdc2dd26l, 0x256851e6l, 0x318e7086l,
0x2bfa4861l, 0x89eac706l, 0xee5940c6l, 0x68c3bc2fl, 0xe260334bl, 0x98da90bbl,
0xf818f270l, 0x4706d897l, 0x212d3799l, 0x4cf7e5d0l, 0xd9c9649fl, 0xa85db5cdl,
0x35e90e82l, 0x6b881152l, 0xab1c02c7l, 0x46752b02l, 0x664f598el, 0x45ab2e64l,
0xc4cdb4b2l, 0xba42107fl, 0xea2a808al, 0x971bf3del, 0x4a54a836l, 0x4253aeccl,
0x1029be68l, 0x6dcc9225l, 0xe4bca56al, 0xc0ae50b1l, 0x7e011d94l, 0xe59c162cl,
0xd8e5c340l, 0xd470fa0bl, 0xb2be79ddl, 0xd783889cl, 0x1cede8f6l, 0x8f4c817al,
0xddb785c9l, 0x860232d8l, 0x198aaad9l, 0xa0814738l, 0x3219cffcl, 0x169546d2l,
0xfc0cb759l, 0x55911510l, 0x04d5cec3l, 0xed08cc3bl, 0x0d6cf427l, 0xc8e38ccal,
0x0eeee3fel, 0x9ee7d7c8l, 0xf9f24fa9l, 0xdb04b35dl, 0x9ab0c9e0l, 0x651f4417l,
0x028f8b07l, 0x6e28d9aal, 0xfba96319l, 0x8ed66687l, 0xfecbc58dl, 0x954ddb44l,
0x7b0bdffel, 0x865d16b1l, 0x49a058c0l, 0x97abaa3fl, 0xcaacc75dl, 0xaba6c17dl,
0xf8746f92l, 0x6f48aeedl, 0x8841d4b5l, 0xf36a146al, 0x73c390abl, 0xe6fb558fl,
0x87b1019el, 0x26970252l, 0x246377b2l, 0xcbf676ael, 0xf923db06l, 0xf7389116l,
0x14c81a90l, 0x83114eb4l, 0x8b137559l, 0x95a86a7al, 0xd5b8da8cl, 0xc4df780el,
0x5a9cb3e2l, 0xe44d4062l, 0xe8dc8ef6l, 0x9d180845l, 0x817ad18bl, 0xc286c85bl,
0x251f20del, 0xee6d5933l, 0xf6edef81l, 0xd4d16c1el, 0xc94a0c32l, 0x8437fd22l,
0x3271ee43l, 0x42572aeel, 0x5f91962al, 0x1c522d98l, 0x59b23f0cl, 0xd86b8804l,
0x08c63531l, 0x2c0d7a40l, 0xb97c4729l, 0x04964df9l, 0x13c74a17l, 0x5878362fl,
0x4c808cd6l, 0x092cb1e0l, 0x6df02885l, 0xa0c2105el, 0x8aba9e68l, 0x64e03057l,
0xe5d61325l, 0x0e43a628l, 0x16dbd62bl, 0x2733d90bl, 0x3ae57283l, 0xc0c1052cl,
0x4b6fb620l, 0x37513953l, 0xfc898bb3l, 0x471b179fl, 0xdf6e66b8l, 0xd32142f5l,
0x9b30fafcl, 0x4ed92549l, 0x105c6d99l, 0x4acd69ffl, 0x2b1a27d3l, 0x6bfcc067l,
0x6301a278l, 0xad36e6f2l, 0xef3ff64el, 0x56b3cadbl, 0x0184bb61l, 0x17beb9fdl,
0xfaec6109l, 0xa2e1ffa1l, 0x2fd224f8l, 0x238f5be6l, 0x8f8570cfl, 0xaeb5f25al,
0x4f1d3e64l, 0x4377eb24l, 0x1fa45346l, 0xb2056386l, 0x52095e76l, 0xbb7b5adcl,
0x3514e472l, 0xdde81e6el, 0x7acea9c4l, 0xac15cc48l, 0x71c97d93l, 0x767f941cl,
0x911052a2l, 0xffea09bfl, 0xfe3ddcf0l, 0x15ebf3aal, 0x9235b8bcl, 0x75408615l,
0x9a723437l, 0xe1a1bd38l, 0x33541b7el, 0x1bdd6856l, 0xb307e13el, 0x90814bb0l,
0x51d7217bl, 0x0bb92219l, 0x689f4500l, 0xc568b01fl, 0x5df3d2d7l, 0x3c0ecd0dl,
0x2a0244c8l, 0x852574e8l, 0xe72f23a9l, 0x8e26ed02l, 0x2d92cbddl, 0xdabc0458l,
0xcdf5feb6l, 0x9e4e8dccl, 0xf4f1e344l, 0x0d8c436dl, 0x4427603bl, 0xbdd37fdal,
0x80505f26l, 0x8c7d2b8el, 0xb73273c5l, 0x397362eal, 0x618a3811l, 0x608bfb88l,
0x06f7d714l, 0x212e4677l, 0x28efceadl, 0x076c0371l, 0x36a3a4d9l, 0x5487b455l,
0x3429a365l, 0x65d467acl, 0x78ee7eebl, 0x99bf12b7l, 0x4d129896l, 0x772a5601l,
0xcce284c7l, 0x2ed85c21l, 0xd099e8a4l, 0xa179158al, 0x6ac0ab1al, 0x299a4807l,
0xbe67a58dl, 0xdc19544al, 0xb8949b54l, 0x8d315779l, 0xb6f849c1l, 0x53c5ac34l,
0x66de92a5l, 0xf195dd13l, 0x318d3a73l, 0x301ec542l, 0x0cc40da6l, 0xf253ade4l,
0x467ee566l, 0xea5585ecl, 0x3baf19bbl, 0x7de9f480l, 0x79006e7cl, 0xa9b7a197l,
0xa44bd8f1l, 0xfb2ba739l, 0xec342fd4l, 0xed4fd32dl, 0x3d1789bal, 0x400f5d7fl,
0xc798f594l, 0x4506a847l, 0x034c0a95l, 0xe2162c9dl, 0x55a9cfd0l, 0x692d832el,
0xcf9db2cal, 0x5e2287e9l, 0xd2610ef3l, 0x1ae7ecc2l, 0x48399ca0l, 0xa7e4269bl,
0x6ee3a0afl, 0x7065bfe1l, 0xa6ffe708l, 0x2256804cl, 0x7476e21bl, 0x41b0796cl,
0x7c243b05l, 0x000a950fl, 0x1858416bl, 0xf5a53c89l, 0xe9fef823l, 0x3f443275l,
0xe0cbf091l, 0x0af27b84l, 0x3ebb0f27l, 0x1de6f7f4l, 0xc31c29f7l, 0xb166de3dl,
0x12932ec3l, 0x9c0c0674l, 0x5cda81b9l, 0xd1bd9d12l, 0xaffd7c82l, 0x8962bca7l,
0xa342c4a8l, 0x62457151l, 0x82089f03l, 0xeb49c670l, 0x5b5f6530l, 0x7e28bad2l,
0x20880ba3l, 0xf0faafcdl, 0xce82b56fl, 0x0275335cl, 0xc18e8afbl, 0xde601d69l,
0xba9b820al, 0xc8a2be4fl, 0xd7cac335l, 0xd9a73741l, 0x115e974dl, 0x7f5ac21dl,
0x383bf9c6l, 0xbcaeb75fl, 0xfd0350cel, 0xb5d06b87l, 0x9820e03cl, 0x72d5f163l,
0xe3644fc9l, 0xa5464c4bl, 0x57048fcbl, 0x9690c9dfl, 0xdbf9eafal, 0xbff4649al,
0x053c00e3l, 0xb4b61136l, 0x67593dd1l, 0x503ee960l, 0x9fb4993al, 0x19831810l,
0xc670d518l, 0xb05b51d8l, 0x0f3a1ce5l, 0x6caa1f9cl, 0xaacc31bel, 0x949ed050l,
0x1ead07e7l, 0xa8479abdl, 0xd6cffcd5l, 0x936993efl, 0x472e91cbl, 0x5444b5b6l,
0x62be5861l, 0x1be102c7l, 0x63e4b31el, 0xe81f71b7l, 0x9e2317c9l, 0x39a408ael,
0x518024f4l, 0x1731c66fl, 0x68cbc918l, 0x71fb0c9el, 0xd03b7fddl, 0x7d6222ebl,
0x9057eda3l, 0x1a34a407l, 0x8cc2253dl, 0xb6f6979dl, 0x835675dcl, 0xf319be9fl,
0xbe1cd743l, 0x4d32fee4l, 0x77e7d887l, 0x37e9ebfdl, 0x15f851e8l, 0x23dc3706l,
0x19d78385l, 0xbd506933l, 0xa13ad4a6l, 0x913f1a0el, 0xdde560b9l, 0x9a5f0996l,
0xa65a0435l, 0x48d34c4dl, 0xe90839a7l, 0x8abba54el, 0x6fd13ce1l, 0xc7eebd3cl,
0x0e297602l, 0x58b9bbb4l, 0xef7901e6l, 0x64a28a62l, 0xa509875al, 0xf8834442l,
0x2702c709l, 0x07353f31l, 0x3b39f665l, 0xf5b18b49l, 0x4010ae37l, 0x784de00bl,
0x7a1121e9l, 0xde918ed3l, 0xc8529dcdl, 0x816a5d05l, 0x02ed8298l, 0x04e3dd84l,
0xfd2bc3e2l, 0xaf167089l, 0x96af367el, 0xa4da6232l, 0x18ff7325l, 0x05f9a9f1l,
0x4fefb9f9l, 0xcd94eaa5l, 0xbfaa5069l, 0xa0b8c077l, 0x60d86f57l, 0xfe71c813l,
0x29ebd2c8l, 0x4ca86538l, 0x6bf1a030l, 0xa237b88al, 0xaa8af41dl, 0xe1f7b6ecl,
0xe214d953l, 0x33057879l, 0x49caa736l, 0xfa45cff3l, 0xc063b411l, 0xba7e27d0l,
0x31533819l, 0x2a004ac1l, 0x210efc3fl, 0x2646885el, 0x66727dcfl, 0x9d7fbf54l,
0xa8dd0ea8l, 0x3447cacel, 0x3f0c14dbl, 0xb8382aacl, 0x4ace3539l, 0x0a518d51l,
0x95178981l, 0x35aee2cal, 0x73f0f7e3l, 0x94281140l, 0x59d0e523l, 0xd292cb88l,
0x565d1b27l, 0x7ec8fbafl, 0x069af08dl, 0xc127fd24l, 0x0bc77b10l, 0x5f03e7efl,
0x453e99bal, 0xeed9ff7fl, 0x87b55215l, 0x7915ab4cl, 0xd389a358l, 0x5e75ce6dl,
0x28d655c0l, 0xdad26c73l, 0x2e2510ffl, 0x9fa7eeccl, 0x1d0629c3l, 0xdc9c9c46l,
0x2d67ecd7l, 0xe75e94bdl, 0x3d649e2al, 0x6c413a2bl, 0x706f0d7cl, 0xdfb0127bl,
0x4e366b55l, 0x2c825650l, 0x24205720l, 0xb5c998f7l, 0x3e95462cl, 0x756e5c72l,
0x3259488fl, 0x11e8771al, 0xa7c0a617l, 0x577663e5l, 0x089b6401l, 0x8eab1941l,
0xae55ef8cl, 0x3aac5460l, 0xd4e6262fl, 0x5d979a47l, 0xb19823b0l, 0x7f8d6a0cl,
0xffa08683l, 0x0170cd0fl, 0x858cd5d8l, 0x53961c90l, 0xc4c61556l, 0x41f2f226l,
0xcfcd062dl, 0xf24c03b8l, 0xea81df5bl, 0x7be2fa52l, 0xb361f98bl, 0xc2901316l,
0x55ba4bbcl, 0x93b234a9l, 0x0fbc6603l, 0x80a96822l, 0x6d60491fl, 0x22bd00f8l,
0xbcad5aadl, 0x52f3f13bl, 0x42fd2b28l, 0xb41dd01cl, 0xc52c93bfl, 0xfc663094l,
0x8f58d100l, 0x43fecc08l, 0xc6331e5dl, 0xe6480f66l, 0xca847204l, 0x4bdf1da0l,
0x30cc2efbl, 0x13e02deal, 0xfb49ac45l, 0xf9d4434fl, 0xf47c5b9cl, 0x148879c2l,
0x039fc234l, 0xa3db9bfcl, 0xd1a1dc5cl, 0x763d7cd4l, 0xed6d2f93l, 0xab13af6el,
0x1e8e054al, 0xd68f4f9al, 0xc30484b3l, 0xd7d50afal, 0x6930855fl, 0xcc07db95l,
0xce746db1l, 0x744e967dl, 0xf16cf575l, 0x8643e8b5l, 0xf0eae38el, 0xe52de1d1l,
0x6587dae0l, 0x0c4b8121l, 0x1c7ac567l, 0xac0db20al, 0x36c3a812l, 0x5b1a4514l,
0xa9a3f868l, 0xb9263baal, 0xcb3ce9d2l, 0xe44fb1a4l, 0x9221bc82l, 0xb29390fel,
0x6ab41863l, 0x974a3e2el, 0x89f531c5l, 0x255ca13el, 0x8b65d348l, 0xec248f78l,
0xd8fc16f0l, 0x50ecdeeel, 0x09010792l, 0x3c7d1fb2l, 0xeba5426bl, 0x847b417al,
0x468b40d9l, 0x8dc4e680l, 0x7cc1f391l, 0x2f1eb086l, 0x6e5baa6al, 0xe0b395dal,
0xe31b2cf6l, 0xd9690b0dl, 0x729ec464l, 0x38403ddel, 0x610b80a2l, 0x5cf433abl,
0xb0785fc4l, 0xd512e4c6l, 0xbbb7d699l, 0x5a86591bl, 0x10cf5376l, 0x12bf9f4bl,
0x980fbaa1l, 0x992a4e70l, 0x20fa7ae7l, 0xf7996ebbl, 0xc918a2bel, 0x82de74f2l,
0xad54209bl, 0xf66b4d74l, 0x1fc5b771l, 0x169d9229l, 0x887761dfl, 0x00b667d5l,
0xdb425e59l, 0xb72f2844l, 0x9b0ac1f5l, 0x9c737e3al, 0x2b85476cl, 0x6722add6l,
0x44a63297l, 0x0d688cedl, 0xabc59484l, 0x4107778al, 0x8ad94c6fl, 0xfe83df90l,
0x0f64053fl, 0xd1292e9dl, 0xc5744356l, 0x8dd1abb4l, 0x4c4e7667l, 0xfb4a7fc1l,
0x74f402cbl, 0x70f06afdl, 0xa82286f2l, 0x918dd076l, 0x7a97c5cel, 0x48f7bde3l,
0x6a04d11dl, 0xac243ef7l, 0x33ac10cal, 0x2f7a341el, 0x5f75157al, 0xf4773381l,
0x591c870el, 0x78df8cc8l, 0x22f3adb0l, 0x251a5993l, 0x09fbef66l, 0x796942a8l,
0x97541d2el, 0x2373daa9l, 0x1bd2f142l, 0xb57e8eb2l, 0xe1a5bfdbl, 0x7d0efa92l,
0xb3442c94l, 0xd2cb6447l, 0x386ac97el, 0x66d61805l, 0xbdada15el, 0x11bc1aa7l,
0x14e9f6eal, 0xe533a0c0l, 0xf935ee0al, 0x8fee8a04l, 0x810d6d85l, 0x7c68b6d6l,
0x4edc9aa2l, 0x956e897dl, 0xed87581al, 0x264be9d7l, 0xff4ddb29l, 0x823857c2l,
0xe005a9a0l, 0xf1cc2450l, 0x6f9951e1l, 0xaade2310l, 0xe70c75f5l, 0x83e1a31fl,
0x4f7dde8el, 0xf723b563l, 0x368e0928l, 0x86362b71l, 0x21e8982dl, 0xdfb3f92bl,
0x44676352l, 0x99efba31l, 0x2eab4e1cl, 0xfc6ca5e7l, 0x0ebe5d4el, 0xa0717d0cl,
0xb64f8199l, 0x946b31a1l, 0x5656cbc6l, 0xcffec3efl, 0x622766c9l, 0xfa211e35l,
0x52f98b89l, 0x6d01674bl, 0x4978a802l, 0xf651f701l, 0x15b0d43dl, 0xd6ff4683l,
0x3463855fl, 0x672ba29cl, 0xbc128312l, 0x4626a70dl, 0xc8927a5al, 0xb8481cf9l,
0x1c962262l, 0xa21196bal, 0xbaba5ee9l, 0x5bb162d0l, 0x69943bd1l, 0x0c47e35cl,
0x8cc9619al, 0xe284d948l, 0x271bf264l, 0xc27fb398l, 0x4bc70897l, 0x60cf202cl,
0x7f42d6aal, 0xa5a13506l, 0x5d3e8860l, 0xcea63d3cl, 0x63bf0a8fl, 0xf02e9efal,
0xb17b0674l, 0xb072b1d3l, 0x06e5723bl, 0x3737e436l, 0x24aa49c7l, 0x0ded0d18l,
0xdb256b14l, 0x58b27877l, 0xecb49f54l, 0x6c40256al, 0x6ea92ffbl, 0x3906aa4cl,
0xc9866fd5l, 0x4549323el, 0xa7b85fabl, 0x1918cc27l, 0x7308d7b5l, 0x1e16c7adl,
0x71850b37l, 0x3095fd78l, 0xa63b70e6l, 0xd880e2ael, 0x3e282769l, 0xa39ba6bcl,
0x98700fa3l, 0xf34c53e8l, 0x288af426l, 0xb99d930fl, 0xf5b99df1l, 0xe9d0c8cfl,
0x5ac8405dl, 0x50e7217bl, 0x511fbbbel, 0x2ca2e639l, 0xc020301bl, 0x356dbc00l,
0x8e43ddb9l, 0x4d327b4al, 0xf20ff3edl, 0x1dbb29bdl, 0x43d44779l, 0xa1b68f70l,
0x6114455bl, 0xe63d280bl, 0x6bf6ff65l, 0x10fc39e5l, 0x3dae126el, 0xc1d7cf11l,
0xcb60b795l, 0x1789d5b3l, 0x9bca36b7l, 0x08306075l, 0x84615608l, 0x8b3a0186l,
0xe88fbecdl, 0x7ba47c4dl, 0x2de44dacl, 0x653fe58dl, 0xcca0b968l, 0xd7fa0e72l,
0x93901780l, 0x1f2c26ccl, 0xae595b6bl, 0xa9ecea9bl, 0xe3dbf8c4l, 0x319cc130l,
0x12981196l, 0x01a3a4del, 0x32c454b6l, 0x755bd817l, 0x3cd871e4l, 0xa48bb8dal,
0x02fdec09l, 0xfd2dc2e2l, 0x9e578088l, 0x9a9f916dl, 0x4065fe6cl, 0x1853999el,
0xc7793f23l, 0xdc1016bbl, 0x969355ffl, 0x7ef292f6l, 0xcdce4adcl, 0x05e24416l,
0x85c16c46l, 0xd441d37fl, 0x57bd6855l, 0x8746f54fl, 0x9ca773dfl, 0x770bae22l,
0x54828413l, 0xb75e4b19l, 0x04c35c03l, 0xbf7cca07l, 0x2955c4ddl, 0x721db041l,
0xb2394f33l, 0x03f51387l, 0x89b73c9fl, 0x0b1737f3l, 0x07e69024l, 0x9231d245l,
0x76193861l, 0x88159c15l, 0xdeb552d9l, 0xd9767e40l, 0x20c6c0c3l, 0x4281977cl,
0xf8afe1e0l, 0xd32a0751l, 0x3fc27432l, 0xddf1dcc5l, 0x68581f34l, 0x3bcd5025l,
0x0091b2eel, 0x4aeb6944l, 0x1602e743l, 0xea09eb58l, 0xef0a2a8bl, 0x641e03a5l,
0xeb50e021l, 0x5c8ccef8l, 0x802ff0b8l, 0xd5e3edfel, 0xc4dd1b49l, 0x5334cd2al,
0x13f82d2fl, 0x47450c20l, 0x55dafbd2l, 0xbec0c6f4l, 0xb45d7959l, 0x3ad36e8cl,
0x0aa8ac57l, 0x1a3c8d73l, 0xe45aafb1l, 0x9f664838l, 0xc6880053l, 0xd0039bbfl,
0xee5f19ebl, 0xca0041d8l, 0xbbea3aafl, 0xda628291l, 0x9d5c95d4l, 0xadd504a6l,
0xc39ab482l, 0x5e9e14a4l, 0x2be065f0l, 0x2a13fc3al, 0x9052e8ecl, 0xaf6f5afcl,
0x519aa8b5l, 0xbb303da9l, 0xe00e2b10l, 0xdfa6c1dbl, 0x2e6b952el, 0xee10dc23l,
0x37936d09l, 0x1fc42e92l, 0x39b25a9fl, 0x13ff89f4l, 0xc8f53feal, 0x18500bc7l,
0x95a0379dl, 0x98f751c2l, 0x2289c42fl, 0xa21e4098l, 0x6f391f41l, 0xf27e7e58l,
0x0d0df887l, 0x4b79d540l, 0x8e8409aal, 0x71fe46f8l, 0x688a9b29l, 0x3f08b548l,
0x84abe03al, 0x5e91b6c1l, 0xfde4c2ael, 0x251d0e72l, 0x92d4fee5l, 0xf9371967l,
0x9175108fl, 0xe6e81835l, 0x8c8cb8eel, 0xb55a67b3l, 0xcef138ccl, 0x8b256268l,
0x00d815f5l, 0xe8810812l, 0x77826189l, 0xea73267dl, 0x19b90f8dl, 0x45c33bb4l,
0x82477056l, 0xe1770075l, 0x09467aa6l, 0xa7c6f54al, 0x79768742l, 0x61b86bcal,
0xd6644a44l, 0xe33f0171l, 0xc229fbcdl, 0x41b08febl, 0xd1903e30l, 0x65ec9080l,
0x563d6fbdl, 0xf56da488l, 0xebf64cd8l, 0x4934426bl, 0x7c8592fcl, 0x6aca8cf2l,
0x1cea111bl, 0x3a57ee7al, 0xace11c0dl, 0x9942d85el, 0xc4613407l, 0xfa8e643bl,
0x327fc701l, 0x4ca9be82l, 0x3352526dl, 0x2c047f63l, 0xf3a8f7ddl, 0x1a4a98a8l,
0x762ed4d1l, 0x27c75008l, 0xbdf497c0l, 0x7a7b84dfl, 0x315c28abl, 0x801f93e3l,
0xf19b0ca1l, 0x8f14e46al, 0xe48ba333l, 0x9605e625l, 0xf03ecb60l, 0x60385f2dl,
0x902845bal, 0x7f96d66fl, 0x24bff05cl, 0x2820730bl, 0x947133cbl, 0xd444828al,
0xb343f6f1l, 0x0bef4705l, 0x8da574f9l, 0x01e25d6cl, 0x1732793el, 0x4f0f7b27l,
0x364b7117l, 0xb2d1da77l, 0xa6c5f1e9l, 0x574ca5b1l, 0x386a3076l, 0xad6894d6l,
0x1156d7fal, 0xa48d1d9al, 0x4794c0afl, 0x150c0aa0l, 0x26d348acl, 0x29fdeabel,
0xa5dede53l, 0x81671e8el, 0x594ee3bfl, 0xa96c56e6l, 0x3426a726l, 0xc5976579l,
0xbc22e5e4l, 0xc1006319l, 0xdaafdd2al, 0xa1a1aa83l, 0x3badd0e7l, 0xc3b14981l,
0xd770b155l, 0xccd7c693l, 0x42e944c5l, 0x03e0064fl, 0xca95b4efl, 0x3dee81c3l,
0xfbbcd98cl, 0x1e07e15bl, 0x667ce949l, 0xe7d6773fl, 0x21b6124bl, 0x6b2a6ef7l,
0xd3278a9cl, 0x9a988304l, 0x75d2ae9bl, 0xfe49e2ffl, 0x9bc24f46l, 0x74cc2cf6l,
0xa3139f36l, 0x6c9ef35al, 0x9fc1dffel, 0x9e5facdcl, 0xaadc8bbbl, 0x5abdbc5fl,
0x44b3b390l, 0xf754efa7l, 0x5fe3bdb7l, 0x4e59c886l, 0x06a4c984l, 0xa0338878l,
0xcd513cd7l, 0x63ebd27el, 0x8aba80adl, 0x50da144el, 0x5d9f4e97l, 0x025b751cl,
0x2d580200l, 0xb6c05837l, 0x580aa15dl, 0x54022a6el, 0xb41a5415l, 0x4863fab6l,
0xb0b79957l, 0x46d0d159l, 0xdc2b8650l, 0x20a7bb0cl, 0x4a032974l, 0xec8636a2l,
0x8548f24cl, 0xf6a2bf16l, 0x1088f4b0l, 0x0c2f3a94l, 0x525dc396l, 0x14065785l,
0x2b4dca52l, 0x08aeed39l, 0xabedfc99l, 0xb1dbcf18l, 0x87f85bbcl, 0xae3aff61l,
0x433ccd70l, 0x5b23cc64l, 0x7b453213l, 0x5355c545l, 0x9318ec0al, 0x78692d31l,
0x0a21693dl, 0xd5666814l, 0x05fb59d9l, 0xc71985b2l, 0x2abb8e0el, 0xcf6e6c91l,
0xd9cfe7c6l, 0xefe7132cl, 0x9711ab28l, 0x3ce52732l, 0x12d516d2l, 0x7209a0d0l,
0xd278d306l, 0x70fa4b7bl, 0x1d407dd3l, 0xdb0beba4l, 0xbfd97621l, 0xa8be21e1l,
0x1b6f1b66l, 0x30650ddal, 0xba7ddbb9l, 0x7df953fbl, 0x9d1c3902l, 0xedf0e8d5l,
0xb8741ae0l, 0x0f240565l, 0x62cd438bl, 0xc616a924l, 0xaf7a96a3l, 0x35365538l,
0xe583af4dl, 0x73415eb8l, 0x23176a47l, 0xfc9ccee8l, 0x7efc9de2l, 0x695e03cfl,
0xf8ce66d4l, 0x88b4781dl, 0x67dd9c03l, 0x3e8f9e73l, 0xc0c95c51l, 0xbe314d22l,
0x55aa0795l, 0xcb1bb011l, 0xe980fdc8l, 0x9c62b7cel, 0xde2d239el, 0x042cadf3l,
0xffdf04del, 0x5ce6a60fl, 0xd8c831edl, 0xb7b5b9ecl, 0xb9cbf962l, 0xe253b254l,
0x0735ba1fl, 0x16ac917fl, 0xdd607c2bl, 0x64a335c4l, 0x40159a7cl, 0x869222f0l,
0x6ef21769l, 0x839d20a5l, 0xd03b24c9l, 0xf412601el, 0x6d72a243l, 0x0e018dfdl,
0x89f3721al, 0xc94f4134l, 0x2f992f20l, 0x4d87253cl };
/**
* Initialize the hashing state.
*/
void snefru_init(struct snefru_ctx *ctx)
{
ctx->hashlen = 0;
ctx->index = 0;
mutils_bzero(ctx->hash, SNEFRU256_DIGEST_SIZE);
}
/**
* The core snefru transform.
*/
static void snefru(mutils_word32 *block, mutils_word32 len)
{
__const mutils_word32 st[4] = {16, 8, 16, 24};
mutils_word32 isave[SNEFRU256_DIGEST_LEN];
mutils_word32 *sbox, x;
mutils_word32 i, j;
__const mutils_word32 *limit;
mutils_memcpy(isave, block, SNEFRU256_DIGEST_SIZE);
limit = SBOX + 512 * R;
for (sbox = (mutils_word32 *) SBOX; sbox < limit; sbox += 512)
{
for (j = 0; j < 4; j++)
{
for (i = 0; i < SNEFRU_BLOCK_LEN; i++)
{
x = sbox[(i << 7 & 0x100) + (block[i] & 0xff)];
block[(i + SNEFRU_BLOCK_LEN - 1) % SNEFRU_BLOCK_LEN] ^= x;
block[(i + 1) % SNEFRU_BLOCK_LEN] ^= x;
}
for (i = 0; i < SNEFRU_BLOCK_LEN; i++)
{
block[i] = block[i] >> st[j] | block[i] << (32 - st[j]);
}
}
}
for (i = 0; i < len; i++)
{
block[i] = block[SNEFRU_BLOCK_LEN - 1 - i] ^ isave[i];
}
}
static void processBuffer(struct snefru_ctx *ctx, int len)
{
mutils_word32 i;
mutils_word8 *buf = ctx->buffer;
for(i = len; i < SNEFRU_BLOCK_LEN; i++, buf += 4)
{
ctx->hash[i] = mutils_bend32(*(mutils_word32 *)buf);
}
snefru(ctx->hash, len);
}
/**
* Update the hashing state.
*/
static void snefru_update(struct snefru_ctx *ctx, __const mutils_word8 *data, mutils_word32 length,
mutils_word32 data_size, mutils_word32 digest_len)
{
if (ctx->index)
{ /* Try to fill partial block */
mutils_word32 left = data_size - ctx->index;
if (length < left)
{
mutils_memcpy(ctx->buffer + ctx->index, data, length);
ctx->index += length;
return; /* Finished */
}
else
{
mutils_memcpy(ctx->buffer + ctx->index, data, left);
processBuffer(ctx, digest_len);
ctx->hashlen += 8 * data_size;
data += left;
length -= left;
}
}
while (length >= data_size)
{
mutils_memcpy(ctx->buffer, data, data_size);
processBuffer(ctx, digest_len);
ctx->hashlen += 8 * data_size;
data += data_size;
length -= data_size;
}
mutils_memcpy(ctx->buffer, data, length);
ctx->index = length;
}
void snefru128_update(struct snefru_ctx *ctx, __const mutils_word8 *data, mutils_word32 length)
{
snefru_update(ctx, data, length, SNEFRU128_DATA_SIZE, SNEFRU128_DIGEST_LEN);
}
void snefru256_update(struct snefru_ctx *ctx, __const mutils_word8 *data, mutils_word32 length)
{
snefru_update(ctx, data, length, SNEFRU256_DATA_SIZE, SNEFRU256_DIGEST_LEN);
}
/**
* Finalize the hash value calculation by appending the (padded) length field.
*/
void snefru128_final(struct snefru_ctx *ctx)
{
if (ctx->index)
{ /* pad the last data block if partially filled */
mutils_bzero(ctx->buffer + ctx->index, SNEFRU128_DATA_SIZE - ctx->index);
processBuffer(ctx, SNEFRU128_DIGEST_LEN);
ctx->hashlen += 8 * ctx->index;
}
mutils_bzero(ctx->hash + SNEFRU128_DIGEST_LEN,
SNEFRU_BLOCK_SIZE - SNEFRU128_DIGEST_SIZE - sizeof(ctx->hashlen));
ctx->hash[SNEFRU_BLOCK_LEN - 2] = ctx->hashlen >> 32;
ctx->hash[SNEFRU_BLOCK_LEN - 1] = ctx->hashlen & 0xffffffff;
snefru(ctx->hash, SNEFRU128_DIGEST_LEN);
}
void snefru256_final(struct snefru_ctx *ctx)
{
if (ctx->index)
{ /* pad the last data block if partially filled */
mutils_bzero(ctx->buffer + ctx->index, SNEFRU256_DATA_SIZE - ctx->index);
processBuffer(ctx, SNEFRU256_DIGEST_LEN);
ctx->hashlen += 8 * ctx->index;
}
mutils_bzero(ctx->hash + SNEFRU256_DIGEST_LEN,
SNEFRU_BLOCK_SIZE - SNEFRU256_DIGEST_SIZE - sizeof(ctx->hashlen));
ctx->hash[SNEFRU_BLOCK_LEN - 2] = ctx->hashlen >> 32;
ctx->hash[SNEFRU_BLOCK_LEN - 1] = ctx->hashlen & 0xffffffff;
snefru(ctx->hash, SNEFRU256_DIGEST_LEN);
}
static void snefru_digest(__const struct snefru_ctx *ctx, mutils_word8 *digest, mutils_word32 len)
{
mutils_word32 i;
for (i = 0; i < len; i++, digest += 4)
{
*(mutils_word32 *)digest = mutils_bend2sys32(ctx->hash[i]);
}
}
void snefru128_digest(__const struct snefru_ctx *ctx, mutils_word8 *digest)
{
snefru_digest(ctx, digest, SNEFRU128_DIGEST_LEN);
}
void snefru256_digest(__const struct snefru_ctx *ctx, mutils_word8 *digest)
{
snefru_digest(ctx, digest, SNEFRU256_DIGEST_LEN);
}
#endif /* ENABLE_SNEFRU */
@@ -0,0 +1,584 @@
/*
* Copyright (C) 1998 Nikos Mavroyanopoulos
* Copyright (C) 1999,2000 Sascha Schumman, 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.
*/
/*
$Id: stdfns.c,v 1.2 2006/01/10 03:47:18 imipak Exp $
*/
#include "libdefs.h"
/**
* Some of these are wrappers. The idea is to eventually produce an extremely
* lightweight set of robust, portable functions that are guaranteed to produce
* a "safe" result, even with bogus inputs. We can't trust native C libraries
* to validate inputs.
*/
WIN32DLL_DEFINE
int mutils_mlock(__const void *addr, __const mutils_word32 len)
{
int ret;
if ((addr == NULL) || (len == 0))
{
ret = -1;
errno = EINVAL;
}
#if defined(HAVE_MLOCK)
ret = mlock(addr, len);
#endif
return(ret);
}
WIN32DLL_DEFINE
int mutils_munlock(__const void *addr, __const mutils_word32 len)
{
int ret;
if ((addr == NULL) || (len == 0))
{
ret = -1;
errno = EINVAL;
}
#if defined(HAVE_MLOCK)
ret = munlock(addr, len);
#endif
return(ret);
}
/*
* NOTE: In order for memory locking to be useful, we need our own malloc
* implementation, as we cannot guarantee that the system-supplied one will
* let us know how much memory has been malloc()'ed. For much the same reason,
* neither free() nor realloc() can zero safely. This allows the potential
* leakage of information.
*/
WIN32DLL_DEFINE
void *
mutils_malloc(__const mutils_word32 n)
{
void *ptr;
if (n == 0)
{
return(NULL);
}
ptr = malloc(n);
if (ptr != NULL)
{
mutils_bzero(ptr, n);
}
return(ptr);
}
WIN32DLL_DEFINE
void *
mutils_realloc(__const void *ptr, __const mutils_word32 n)
{
void *ptrOut;
if ((ptr == NULL) && (n > 0))
{
ptrOut = mutils_malloc(n);
}
else
{
if ((ptr != NULL) && (n == 0))
{
mutils_free(ptr);
ptrOut = NULL;
}
else
{
ptrOut = realloc((void *) ptr, n);
}
}
return(ptrOut);
}
WIN32DLL_DEFINE
void
mutils_free(__const void *ptr)
{
if (ptr == NULL)
{
return;
}
free((void *) ptr);
return;
}
WIN32DLL_DEFINE
void
mutils_bzero(void *s, __const mutils_word32 n)
{
mutils_word8 *stmp = (mutils_word8 *) s;
mutils_word32 i;
if ((s == NULL) || (n == 0))
{
return;
}
for (i = 0; i < n; i++, stmp++)
{
*stmp = '\0';
}
}
WIN32DLL_DEFINE
void
mutils_memset(void *s, __const mutils_word8 c, __const mutils_word32 n)
{
#if defined(sparc)
/* Sparc needs 8-bit alignment - just use standard memset */
memset(s, (int) c, (size_t) n);
#else
mutils_word8 *stmp;
mutils_word32 *ltmp = (mutils_word32 *) s;
mutils_word32 lump;
mutils_word32 i;
mutils_word32 words;
mutils_word32 remainder;
if ((s == NULL) || (n == 0))
{
return;
}
lump = (c << 24) + (c << 16) + (c << 8) + c;
words = n >> 2;
remainder = n - (words << 2);
for (i = 0; i < words; i++, ltmp++)
{
*ltmp = lump;
}
stmp = (mutils_word8 *) ltmp;
for (i = 0; i < remainder; i++, stmp++)
{
*stmp = c;
}
#endif
}
static void
mutils_memcpy8(mutils_word8 *p_dest, __const mutils_word8 *p_src,
__const mutils_word32 n)
{
mutils_word32 i;
for (i = 0; i < n; i++)
{
*p_dest++ = *p_src++;
}
}
WIN32DLL_DEFINE
void
mutils_memcpy(void *dest, __const void *src, __const mutils_word32 n)
{
mutils_word8 *ptr1;
mutils_word8 *ptr2;
mutils_word32 *bigptr1;
mutils_word32 *bigptr2;
mutils_word32 i;
mutils_word32 words;
mutils_word32 remainder;
if ((dest == NULL) || (src == NULL) || (n == 0))
{
return;
}
ptr1 = (mutils_word8 *)src;
ptr2 = dest;
/* copy byte-by-byte for small and/or unaligned copies */
if ((n < 16) || ((mutils_word32)ptr1 & 0x3) || ((mutils_word32)ptr2
& 0x3))
{
mutils_memcpy8(ptr2, ptr1, n);
return;
}
words = n >> 2;
remainder = n - (words << 2);
bigptr1 = (mutils_word32 *) dest;
bigptr2 = (mutils_word32 *) src;
for (i = 0; i < words; i ++, bigptr1++, bigptr2++)
{
*bigptr1 = *bigptr2;
}
ptr1 = (mutils_word8 *) bigptr1;
ptr2 = (mutils_word8 *) bigptr2;
for (i = 0; i < remainder; i++, ptr1++, ptr2++)
{
*ptr1 = *ptr2;
}
}
/*
* If the system ordering is big-endian, convert to little-endian format.
* In both cases, the data is held in a temporary workspace that will be
* overwritten the next time this function is called. This function is
* deprecated and should NOT be called in new code. The ordering macros
* should be used instead, for all single-word conversions.
*/
WIN32DLL_DEFINE
mutils_word32
mutils_word32swap(mutils_word32 x)
{
static mutils_word32 value;
value = mutils_lend32(x);
return(value);
}
/*
* Byte swap a series of 32-bit integers. If destructive is set to false, the
* output will be placed in a freshly malloc()'ed buffer and the original
* data will remain intact.
*/
WIN32DLL_DEFINE
mutils_word32 *
mutils_word32nswap(mutils_word32 *x, mutils_word32 n, mutils_boolean destructive)
{
mutils_word32 loop;
mutils_word32 *buffer;
mutils_word32 *ptrIn;
mutils_word32 *ptrOut;
mutils_word32 count = n * 4;
if (destructive == MUTILS_FALSE)
{
buffer = mutils_malloc(count);
if (buffer == NULL)
{
return(NULL);
}
}
else
{
buffer = x;
}
/*
* This loop is totally useless for destructive processing of little-endian
* data on a little-endian machine.
*/
for (loop = 0, ptrIn = x, ptrOut = buffer; loop < n; loop++, ptrOut++, ptrIn++)
{
*ptrOut = mutils_lend32(*ptrIn);
}
return(buffer);
}
WIN32DLL_DEFINE
void
mutils_memmove(void *dest, __const void *src, const mutils_word32 n)
{
mutils_word8 *ptr1;
mutils_word8 *ptr2;
mutils_word32 i;
mutils_word32 *bigptr1;
mutils_word32 *bigptr2;
mutils_word32 words;
mutils_word32 remainder;
if ((dest == NULL) || (src == NULL) || (n == 0))
{
return;
}
bigptr1 = (mutils_word32 *) dest;
bigptr2 = (mutils_word32 *) src;
words = n >> 2;
remainder = n - (words << 2);
for (i = 0; i < words; i++, bigptr1++, bigptr2++)
{
*bigptr1 = *bigptr2;
}
ptr1 = (mutils_word8 *) bigptr1;
ptr2 = (mutils_word8 *) bigptr2;
for (i = 0; i < remainder; i++, ptr1++, ptr2++)
{
*ptr1 = *ptr2;
}
}
WIN32DLL_DEFINE
int
mutils_memcmp(__const void *s1, const void *s2, const mutils_word32 n)
{
if (n == 0)
{
return(0);
}
if (s1 == NULL)
{
if (s2 == NULL)
{
return(0);
}
return(-MAXINT);
}
if (s2 == NULL)
{
return(MAXINT);
}
return(memcmp(s1, s2, n));
}
/* Ugh. This could do nasty things, if a string isn't correctly terminated,
* particularly as memory can be larger than can be stored in a 32-bit word.
* If it is possible to produce an incorrect result, or segfault, then it
* is not a robust solution.
*/
WIN32DLL_DEFINE
mutils_word32
mutils_strlen(__const mutils_word8 *str)
{
mutils_word32 ret;
mutils_word8 *endStr = (mutils_word8 *) str;
if (str == NULL)
{
return(0);
}
while (*endStr != 0)
{
endStr++;
}
ret = endStr - str;
return(ret);
}
WIN32DLL_DEFINE
mutils_word8 *
mutils_strdup(__const mutils_word8 *str)
{
mutils_word8 *ret = NULL;
mutils_word8 *ptr1;
mutils_word8 *ptr2;
mutils_word32 len;
if (str == NULL)
{
return(NULL);
}
len = mutils_strlen(str) + 1;
ret = (mutils_word8 *) mutils_malloc(len);
if (ret != NULL)
{
ptr1 = (mutils_word8 *) str;
ptr2 = ret;
for (len = mutils_strlen(str); len > 0; len--, ptr1++, ptr2++)
{
*ptr2 = *ptr1;
}
}
return(ret);
}
WIN32DLL_DEFINE
mutils_word8 *
mutils_strcat(mutils_word8 *dest, __const mutils_word8 *src)
{
mutils_word8 *ptrIn = (mutils_word8 *) src;
mutils_word8 *ptrOut = dest + mutils_strlen(dest);
if (dest == NULL)
{
return(NULL);
}
if (src == NULL)
{
return(dest);
}
while (*src != 0)
{
*ptrOut = *ptrIn;
ptrOut++;
ptrIn++;
}
*ptrOut = '\0';
return((mutils_word8 *) dest);
}
WIN32DLL_DEFINE
mutils_word8 *
mutils_strcpy(mutils_word8 *dest, __const mutils_word8 *src)
{
if (dest == NULL)
{
return(NULL);
}
return((mutils_word8 *) strcpy((char *) dest, (char *) src));
}
WIN32DLL_DEFINE
mutils_word8 *
mutils_strncpy(mutils_word8 *dest, __const mutils_word8 *src, const mutils_word32 n)
{
if (dest == NULL)
{
return(NULL);
}
if (n == 0)
{
return(NULL);
}
return((mutils_word8 *) strncpy((char *) dest, (char *) src, n));
}
WIN32DLL_DEFINE
int
mutils_strcmp(__const mutils_word8 *src1, const mutils_word8 *src2)
{
if (src1 == NULL)
{
if (src2 == NULL)
{
return(0);
}
return(-MAXINT);
}
if (src2 == NULL)
{
return(MAXINT);
}
return(strcmp((char *) src1, (char *) src2));
}
WIN32DLL_DEFINE
int
mutils_strncmp(__const mutils_word8 *src1, const mutils_word8 *src2, const mutils_word32 n)
{
if (n == 0)
{
return(0);
}
if (src1 == NULL)
{
if (src2 == NULL)
{
return(0);
}
return(-MAXINT);
}
if (src2 == NULL)
{
return(MAXINT);
}
return(strncmp((char *) src1, (char *) src2, n));
}
WIN32DLL_DEFINE
long
mutils_strtol(__const mutils_word8 *nptr, mutils_word8 **endptr, const mutils_word8 base)
{
return(strtol((char *) nptr, (char **) endptr, (int) base));
}
WIN32DLL_DEFINE
mutils_word8
mutils_val2char(mutils_word8 x)
{
mutils_word8 out;
static mutils_word8 *table = (mutils_word8 *) "0123456789abcdef";
out = *(table + x);
return(out);
}
WIN32DLL_DEFINE
mutils_word8 *
mutils_asciify(mutils_word8 *in, __const mutils_word32 len)
{
mutils_word8 *ptrIn = in;
mutils_word8 *buffer = mutils_malloc((2 * len) + 1);
mutils_word8 *ptrOut = buffer;
mutils_word32 loop;
for (loop = 0; loop < len; loop++, ptrIn++)
{
*ptrOut++ = mutils_val2char((*ptrIn & 0xf0) >> 4);
*ptrOut++ = mutils_val2char((*ptrIn & 0x0f));
}
return(buffer);
}
WIN32DLL_DEFINE
mutils_boolean
mutils_thequals(mutils_word8 *text, mutils_word8 *hash, __const mutils_word32 len)
{
mutils_word8 *ptrText = text;
mutils_word8 *ptrHash = hash;
mutils_word32 loop;
for (loop = 0; loop < len; loop++, ptrHash++)
{
if (mutils_val2char((*ptrHash & 0xf0) >> 4) != *ptrText++)
{
return(MUTILS_FALSE);
}
if (mutils_val2char((*ptrHash & 0x0f)) != *ptrText++)
{
return(MUTILS_FALSE);
}
}
return(MUTILS_TRUE);
}
@@ -0,0 +1,709 @@
/*
* 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.
*/
/* According to Tiger's web page
* http://www.cs.technion.ac.il/~biham/Reports/Tiger/
*
* Tiger has no usage restrictions nor patents. It can be used freely, with the
* reference implementation, with other implementations or with a modification
* to the reference implementation (as long as it still implements Tiger).
*
* This implementation is based on the reference implementation.
*
* --nikos
*/
#include "libdefs.h"
#ifdef ENABLE_TIGER
#include "mhash_tiger.h"
#define PASSES 3
#ifdef TIGER_64BIT
/* Unconditionally use the optimizations. There is already separate code for
* 32-bit processors, and the comments about alpha probably apply to all modern
* 64-bit processors. (Ex: the optimized version is faster on Athlon64 too.)
*/
#define OPTIMIZE_FOR_ALPHA
extern __const mutils_word64 tiger_table[4*256];
#define t1 (tiger_table)
#define t2 (tiger_table+256)
#define t3 (tiger_table+256*2)
#define t4 (tiger_table+256*3)
#define save_abc \
aa = a; \
bb = b; \
cc = c;
#ifdef OPTIMIZE_FOR_ALPHA
/* This is the official definition of round */
#define round(a,b,c,x,mul) \
c ^= x; \
a -= t1[((c)>>(0*8))&0xFF] ^ t2[((c)>>(2*8))&0xFF] ^ \
t3[((c)>>(4*8))&0xFF] ^ t4[((c)>>(6*8))&0xFF] ; \
b += t4[((c)>>(1*8))&0xFF] ^ t3[((c)>>(3*8))&0xFF] ^ \
t2[((c)>>(5*8))&0xFF] ^ t1[((c)>>(7*8))&0xFF] ; \
b *= mul;
#else
/* This code works faster when compiled on 32-bit machines */
/* (but works slower on Alpha) */
#define round(a,b,c,x,mul) \
c ^= x; \
a -= t1[(mutils_word8)(c)] ^ \
t2[(mutils_word8)(((mutils_word32)(c))>>(2*8))] ^ \
t3[(mutils_word8)((c)>>(4*8))] ^ \
t4[(mutils_word8)(((mutils_word32)((c)>>(4*8)))>>(2*8))] ; \
b += t4[(mutils_word8)(((mutils_word32)(c))>>(1*8))] ^ \
t3[(mutils_word8)(((mutils_word32)(c))>>(3*8))] ^ \
t2[(mutils_word8)(((mutils_word32)((c)>>(4*8)))>>(1*8))] ^ \
t1[(mutils_word8)(((mutils_word32)((c)>>(4*8)))>>(3*8))]; \
b *= mul;
#endif
#define pass(a,b,c,mul) \
round(a,b,c,x0,mul) \
round(b,c,a,x1,mul) \
round(c,a,b,x2,mul) \
round(a,b,c,x3,mul) \
round(b,c,a,x4,mul) \
round(c,a,b,x5,mul) \
round(a,b,c,x6,mul) \
round(b,c,a,x7,mul)
#define key_schedule \
x0 -= x7 ^ 0xA5A5A5A5A5A5A5A5LL; \
x1 ^= x0; \
x2 += x1; \
x3 -= x2 ^ ((~x1)<<19); \
x4 ^= x3; \
x5 += x4; \
x6 -= x5 ^ ((~x4)>>23); \
x7 ^= x6; \
x0 += x7; \
x1 -= x0 ^ ((~x7)<<19); \
x2 ^= x1; \
x3 += x2; \
x4 -= x3 ^ ((~x2)>>23); \
x5 ^= x4; \
x6 += x5; \
x7 -= x6 ^ 0x0123456789ABCDEFLL;
#define feedforward \
a ^= aa; \
b -= bb; \
c += cc;
#ifdef OPTIMIZE_FOR_ALPHA
/* The loop is unrolled: works better on Alpha */
#define compress \
save_abc \
pass(a,b,c,5) \
key_schedule \
pass(c,a,b,7) \
key_schedule \
pass(b,c,a,9) \
for(pass_no=3; pass_no<PASSES; pass_no++) { \
key_schedule \
pass(a,b,c,9) \
tmpa=a; a=c; c=b; b=tmpa;} \
feedforward
#else
/* loop: works better on PC and Sun (smaller cache?) */
#define compress \
save_abc \
for(pass_no=0; pass_no<PASSES; pass_no++) { \
if(pass_no != 0) {key_schedule} \
pass(a,b,c,(pass_no==0?5:pass_no==1?7:9)); \
tmpa=a; a=c; c=b; b=tmpa;} \
feedforward
#endif
#define tiger_compress_macro(str, state) \
{ \
register mutils_word64 a, b, c, tmpa; \
mutils_word64 aa, bb, cc; \
register mutils_word64 x0, x1, x2, x3, x4, x5, x6, x7; \
mutils_word8 pass_no; \
\
a = state[0]; \
b = state[1]; \
c = state[2]; \
\
x0=str[0]; x1=str[1]; x2=str[2]; x3=str[3]; \
x4=str[4]; x5=str[5]; x6=str[6]; x7=str[7]; \
\
compress; \
\
state[0] = a; \
state[1] = b; \
state[2] = c; \
}
#ifndef OPTIMIZE_FOR_ALPHA
/* The compress function is a function. Requires smaller cache? */
static void tiger_compress(mutils_word64 *str, mutils_word64 state[3])
{
tiger_compress_macro(((mutils_word64*)str), ((mutils_word64*)state));
}
#else /* OPTIMIZE_FOR_ALPHA */
/* The compress function is inlined: works better on Alpha. */
#define tiger_compress(str, state) \
tiger_compress_macro(((mutils_word64*)str), ((mutils_word64*)state))
#endif /* OPTIMIZE_FOR_ALPHA */
#ifndef EXTRACT_UCHAR
#define EXTRACT_UCHAR(p) (*(mutils_word8 *)(p))
#endif
#define STRING2INT64(s) ((((((((((((((mutils_word64)(EXTRACT_UCHAR(s+7) << 8) \
| EXTRACT_UCHAR(s+6)) << 8) \
| EXTRACT_UCHAR(s+5)) << 8) \
| EXTRACT_UCHAR(s+4)) << 8) \
| EXTRACT_UCHAR(s+3)) << 8) \
| EXTRACT_UCHAR(s+2)) << 8) \
| EXTRACT_UCHAR(s+1)) << 8) \
| EXTRACT_UCHAR(s))
static void tiger_block(struct tiger_ctx *ctx, mutils_word8 * str)
{
mutils_word64 temp[TIGER_DATALEN];
#if defined(WORDS_BIGENDIAN)
mutils_word32 j;
for(j=0; j<TIGER_DATALEN; j++, str+=8)
temp[j] = STRING2INT64(str);
tiger_compress(temp, ctx->digest);
#else
mutils_memcpy(temp, str, TIGER_DATASIZE); /* Required to avoid un-aligned access on some arches */
tiger_compress(temp, ctx->digest);
#endif
/* Update block count */
ctx->count++;
}
void tiger_init(struct tiger_ctx *ctx)
{
/* Set the h-vars to their initial values */
ctx->digest[0] = h0init;
ctx->digest[1] = h1init;
ctx->digest[2] = h2init;
/* Initialize block count */
ctx->count = 0;
/* Initialize buffer */
ctx->index = 0;
}
void tiger_update(struct tiger_ctx *ctx, mutils_word8 * buffer, mutils_word32 len)
{
mutils_word32 left;
if (ctx->index) { /* Try to fill partial block */
left = TIGER_DATASIZE - ctx->index;
if (len < left)
{
mutils_memcpy(ctx->block + ctx->index, buffer, len);
ctx->index += len;
return; /* Finished */
} else {
mutils_memcpy(ctx->block + ctx->index, buffer, left);
tiger_block(ctx, ctx->block);
buffer += left;
len -= left;
}
}
while (len >= TIGER_DATASIZE)
{
tiger_block(ctx, buffer);
buffer += TIGER_DATASIZE;
len -= TIGER_DATASIZE;
}
if ((ctx->index = len))
/* This assignment is intended */
/* Buffer leftovers */
mutils_memcpy(ctx->block, buffer, len);
}
void tiger_final(struct tiger_ctx *ctx)
{
register mutils_word64 i, j;
mutils_word8 temp[TIGER_DATASIZE];
i = ctx->index;
#if defined(WORDS_BIGENDIAN)
for(j=0; j<i; j++)
temp[j^7] = ctx->block[j];
temp[j^7] = 0x01;
j++;
for(; j&7; j++)
temp[j^7] = 0;
#else
for(j=0; j<i; j++)
temp[j] = ctx->block[j];
temp[j++] = 0x01;
for(; j&7; j++)
temp[j] = 0;
#endif
if(j>56)
{
for(; j<64; j++)
temp[j] = 0;
tiger_compress(((mutils_word64*)temp), ctx->digest);
j=0;
}
for(; j<56; j++)
temp[j] = 0;
/* Theres 512 = 2^9 bits in one block */
((mutils_word64*)(&(temp[56])))[0] = (ctx->count << 9) + (ctx->index << 3);
tiger_compress(((mutils_word64*)temp), ctx->digest);
}
void tiger_digest(struct tiger_ctx *ctx, mutils_word8 * s)
{
mutils_word32 i;
if (s!=NULL)
for (i = 0; i < TIGER_DIGESTLEN; i++) { /* 64 bit and LITTLE ENDIAN -that's cool! */
s[7] = ctx->digest[i];
s[6] = 0xff & (ctx->digest[i] >> 8);
s[5] = 0xff & (ctx->digest[i] >> 16);
s[4] = 0xff & (ctx->digest[i] >> 24);
s[3] = 0xff & (ctx->digest[i] >> 32);
s[2] = 0xff & (ctx->digest[i] >> 40);
s[1] = 0xff & (ctx->digest[i] >> 48);
s[0] = 0xff & (ctx->digest[i] >> 56);
s+=8;
}
}
void tiger128_digest(struct tiger_ctx *ctx, mutils_word8 * s)
{
mutils_word32 i;
if (s!=NULL)
for (i = 0; i < TIGER128_DIGESTLEN; i++) { /* 64 bit and LITTLE ENDIAN -that's cool! */
s[7] = ctx->digest[i];
s[6] = 0xff & (ctx->digest[i] >> 8);
s[5] = 0xff & (ctx->digest[i] >> 16);
s[4] = 0xff & (ctx->digest[i] >> 24);
s[3] = 0xff & (ctx->digest[i] >> 32);
s[2] = 0xff & (ctx->digest[i] >> 40);
s[1] = 0xff & (ctx->digest[i] >> 48);
s[0] = 0xff & (ctx->digest[i] >> 56);
s+=8;
}
}
void tiger160_digest(struct tiger_ctx *ctx, mutils_word8 * s)
{
mutils_word32 i;
if (s==NULL) return;
for (i = 0; i < TIGER160_DIGESTLEN; i++) { /* 64 bit and LITTLE ENDIAN -that's cool! */
s[7] = ctx->digest[i];
s[6] = 0xff & (ctx->digest[i] >> 8);
s[5] = 0xff & (ctx->digest[i] >> 16);
s[4] = 0xff & (ctx->digest[i] >> 24);
s[3] = 0xff & (ctx->digest[i] >> 32);
s[2] = 0xff & (ctx->digest[i] >> 40);
s[1] = 0xff & (ctx->digest[i] >> 48);
s[0] = 0xff & (ctx->digest[i] >> 56);
s+=8;
}
/* last block */
s[3] = 0xff & (ctx->digest[i] >> 32);
s[2] = 0xff & (ctx->digest[i] >> 40);
s[1] = 0xff & (ctx->digest[i] >> 48);
s[0] = 0xff & (ctx->digest[i] >> 56);
}
#else /* !TIGER_64BIT */
extern __const mutils_word32 tiger_table[4*256][2];
#define t1 (tiger_table)
#define t2 (tiger_table+256)
#define t3 (tiger_table+256*2)
#define t4 (tiger_table+256*3)
#define sub64(s0, s1, p0, p1) \
temps0 = (p0); \
tcarry = s0 < temps0; \
s0 -= temps0; \
s1 -= (p1) + tcarry;
#define add64(s0, s1, p0, p1) \
temps0 = (p0); \
s0 += temps0; \
tcarry = s0 < temps0; \
s1 += (p1) + tcarry;
#define xor64(s0, s1, p0, p1) \
s0 ^= (p0); \
s1 ^= (p1);
#define mul5(s0, s1) \
tempt0 = s0<<2; \
tempt1 = (s1<<2)|(s0>>30); \
add64(s0, s1, tempt0, tempt1);
#define mul7(s0, s1) \
tempt0 = s0<<3; \
tempt1 = (s1<<3)|(s0>>29); \
sub64(tempt0, tempt1, s0, s1); \
s0 = tempt0; \
s1 = tempt1;
#define mul9(s0, s1) \
tempt0 = s0<<3; \
tempt1 = (s1<<3)|(s0>>29); \
add64(s0, s1, tempt0, tempt1);
#define save_abc \
aa0 = a0; \
aa1 = a1; \
bb0 = b0; \
bb1 = b1; \
cc0 = c0; \
cc1 = c1;
#define round(a0,a1,b0,b1,c0,c1,x0,x1,mul) \
xor64(c0, c1, x0, x1); \
temp0 = t1[((c0)>>(0*8))&0xFF][0] ; \
temp1 = t1[((c0)>>(0*8))&0xFF][1] ; \
temp0 ^= t2[((c0)>>(2*8))&0xFF][0] ; \
temp1 ^= t2[((c0)>>(2*8))&0xFF][1] ; \
temp0 ^= t3[((c1)>>(0*8))&0xFF][0] ; \
temp1 ^= t3[((c1)>>(0*8))&0xFF][1] ; \
temp0 ^= t4[((c1)>>(2*8))&0xFF][0] ; \
temp1 ^= t4[((c1)>>(2*8))&0xFF][1] ; \
sub64(a0, a1, temp0, temp1); \
temp0 = t4[((c0)>>(1*8))&0xFF][0] ; \
temp1 = t4[((c0)>>(1*8))&0xFF][1] ; \
temp0 ^= t3[((c0)>>(3*8))&0xFF][0] ; \
temp1 ^= t3[((c0)>>(3*8))&0xFF][1] ; \
temp0 ^= t2[((c1)>>(1*8))&0xFF][0] ; \
temp1 ^= t2[((c1)>>(1*8))&0xFF][1] ; \
temp0 ^= t1[((c1)>>(3*8))&0xFF][0] ; \
temp1 ^= t1[((c1)>>(3*8))&0xFF][1] ; \
add64(b0, b1, temp0, temp1); \
if((mul)==5) \
{mul5(b0, b1);} \
else \
if((mul)==7) \
{mul7(b0, b1);} \
else \
{mul9(b0, b1)};
#define pass(a0,a1,b0,b1,c0,c1,mul) \
round(a0,a1,b0,b1,c0,c1,x00,x01,mul); \
round(b0,b1,c0,c1,a0,a1,x10,x11,mul); \
round(c0,c1,a0,a1,b0,b1,x20,x21,mul); \
round(a0,a1,b0,b1,c0,c1,x30,x31,mul); \
round(b0,b1,c0,c1,a0,a1,x40,x41,mul); \
round(c0,c1,a0,a1,b0,b1,x50,x51,mul); \
round(a0,a1,b0,b1,c0,c1,x60,x61,mul); \
round(b0,b1,c0,c1,a0,a1,x70,x71,mul);
#define key_schedule \
sub64(x00, x01, x70^0xA5A5A5A5, x71^0xA5A5A5A5); \
xor64(x10, x11, x00, x01); \
add64(x20, x21, x10, x11); \
sub64(x30, x31, x20^((~x10)<<19), ~x21^(((x11)<<19)|((x10)>>13))); \
xor64(x40, x41, x30, x31); \
add64(x50, x51, x40, x41); \
sub64(x60, x61, ~x50^(((x40)>>23)|((x41)<<9)), x51^((~x41)>>23)); \
xor64(x70, x71, x60, x61); \
add64(x00, x01, x70, x71); \
sub64(x10, x11, x00^((~x70)<<19), ~x01^(((x71)<<19)|((x70)>>13))); \
xor64(x20, x21, x10, x11); \
add64(x30, x31, x20, x21); \
sub64(x40, x41, ~x30^(((x20)>>23)|((x21)<<9)), x31^((~x21)>>23)); \
xor64(x50, x51, x40, x41); \
add64(x60, x61, x50, x51); \
sub64(x70, x71, x60^0x89ABCDEF, x61^0x01234567);
#define feedforward \
xor64(a0, a1, aa0, aa1); \
sub64(b0, b1, bb0, bb1); \
add64(c0, c1, cc0, cc1);
#ifdef UNROLL_COMPRESS
#define compress \
save_abc \
pass(a0,a1,b0,b1,c0,c1,5); \
key_schedule; \
pass(c0,c1,a0,a1,b0,b1,7); \
key_schedule; \
pass(b0,b1,c0,c1,a0,a1,9); \
for(pass_no=3; pass_no<PASSES; pass_no++) { \
key_schedule \
pass(a0,a1,b0,b1,c0,c1,9); \
tmpa=a0; a0=c0; c0=b0; b0=tmpa; \
tmpa=a1; a1=c1; c1=b1; b1=tmpa;} \
feedforward
#else
#define compress \
save_abc \
for(pass_no=0; pass_no<PASSES; pass_no++) { \
if(pass_no != 0) {key_schedule} \
pass(a0,a1,b0,b1,c0,c1,(pass_no==0?5:pass_no==1?7:9)) \
tmpa=a0; a0=c0; c0=b0; b0=tmpa; \
tmpa=a1; a1=c1; c1=b1; b1=tmpa;} \
feedforward
#endif
#define tiger_compress_macro(str, state) \
{ \
register mutils_word32 a0, a1, b0, b1, c0, c1, tmpa; \
mutils_word32 aa0, aa1, bb0, bb1, cc0, cc1; \
mutils_word32 x00, x01, x10, x11, x20, x21, x30, x31, \
x40, x41, x50, x51, x60, x61, x70, x71; \
register mutils_word32 temp0, temp1, tempt0, tempt1, temps0, tcarry; \
mutils_word32 i; \
int pass_no; \
\
a0 = state[0]; \
a1 = state[1]; \
b0 = state[2]; \
b1 = state[3]; \
c0 = state[4]; \
c1 = state[5]; \
\
x00=str[0*2]; x01=str[0*2+1]; x10=str[1*2]; x11=str[1*2+1]; \
x20=str[2*2]; x21=str[2*2+1]; x30=str[3*2]; x31=str[3*2+1]; \
x40=str[4*2]; x41=str[4*2+1]; x50=str[5*2]; x51=str[5*2+1]; \
x60=str[6*2]; x61=str[6*2+1]; x70=str[7*2]; x71=str[7*2+1]; \
\
compress; \
\
state[0] = a0; \
state[1] = a1; \
state[2] = b0; \
state[3] = b1; \
state[4] = c0; \
state[5] = c1; \
}
#define UNROLL_COMPRESS
#ifdef UNROLL_COMPRESS
/* The compress function is inlined */
#define tiger_compress(str, state) \
tiger_compress_macro(((mutils_word32*)str), ((mutils_word32*)state))
#else
/* The compress function is a function */
tiger_compress(__const mutils_word32 *str, mutils_word32 state[6])
{
tiger_compress_macro(((mutils_word32*)str), ((mutils_word32*)state));
}
#endif
#ifndef EXTRACT_UCHAR
#define EXTRACT_UCHAR(p) (*(mutils_word8 *)(p))
#endif
#define STRING2INT(s) ((((((EXTRACT_UCHAR(s+3) << 8) \
| EXTRACT_UCHAR(s+2)) << 8) \
| EXTRACT_UCHAR(s+1)) << 8) \
| EXTRACT_UCHAR(s))
static void tiger_block(struct tiger_ctx *ctx, mutils_word8 * block)
{
mutils_word32 data[TIGER_DATALEN];
mutils_word32 i;
/* Update block count */
if (!++ctx->count_l)
++ctx->count_h;
/* Endian independent conversion */
for (i = 0; i < TIGER_DATALEN; i++, block += sizeof(mutils_word32))
data[i] = STRING2INT(block);
tiger_compress(data, ctx->digest);
}
void tiger_init(struct tiger_ctx *ctx)
{
/* Set the h-vars to their initial values */
ctx->digest[0] = h0init;
ctx->digest[1] = h1init;
ctx->digest[2] = h2init;
ctx->digest[3] = h3init;
ctx->digest[4] = h4init;
ctx->digest[5] = h5init;
/* Initialize bit count */
ctx->count_l = ctx->count_h = 0;
/* Initialize buffer */
ctx->index = 0;
}
void tiger_update(struct tiger_ctx *ctx, mutils_word8 * buffer, mutils_word32 len)
{
if (ctx->index) { /* Try to fill partial block */
mutils_word32 left = TIGER_DATASIZE - ctx->index;
if (len < left) {
mutils_memcpy(ctx->block + ctx->index, buffer, len);
ctx->index += len;
return; /* Finished */
} else {
mutils_memcpy(ctx->block + ctx->index, buffer, left);
tiger_block(ctx, ctx->block);
buffer += left;
len -= left;
}
}
while (len >= TIGER_DATASIZE)
{
tiger_block(ctx, buffer);
buffer += TIGER_DATASIZE;
len -= TIGER_DATASIZE;
}
if ((ctx->index = len))
{
/* This assignment is intended */
/* Buffer leftovers */
mutils_memcpy(ctx->block, buffer, len);
}
}
void tiger_final(struct tiger_ctx *ctx)
{
mutils_word32 data[TIGER_DATALEN];
mutils_word32 i;
mutils_word32 words;
i = ctx->index;
/* Set the first char of padding to 0x01. This is safe since there is
always at least one byte free */
ctx->block[i++] = 0x01;
/* Fill rest of word */
for (; i & 3; i++)
ctx->block[i] = 0;
/* i is now a multiple of the word size 4 */
words = i >> 2;
for (i = 0; i < words; i++)
data[i] = STRING2INT(ctx->block + 4 * i);
if (words > (TIGER_DATALEN - 2)) { /* No room for length in this block. Process it and
* pad with another one */
for (i = words; i < TIGER_DATALEN; i++)
data[i] = 0;
tiger_compress( data, ctx->digest);
for (i = 0; i < (TIGER_DATALEN - 2); i++)
data[i] = 0;
} else
for (i = words; i < TIGER_DATALEN - 2; i++)
data[i] = 0;
/* Theres 512 = 2^9 bits in one block */
data[TIGER_DATALEN - 1] =
(ctx->count_h << 9) | (ctx->count_l >> 23);
data[TIGER_DATALEN - 2] = (ctx->count_l << 9) | (ctx->index << 3);
tiger_compress( data, ctx->digest);
}
void tiger_digest(struct tiger_ctx *ctx, mutils_word8 * s)
{
mutils_word32 i;
if (s!=NULL)
for (i = 0; i < TIGER_DIGESTLEN; i+=2)
{ /* 64 bit and LITTLE ENDIAN -that's cool! */
s[7] = ctx->digest[i];
s[6] = 0xff & (ctx->digest[i] >> 8);
s[5] = 0xff & (ctx->digest[i] >> 16);
s[4] = 0xff & ctx->digest[i] >> 24;
s[3] = ctx->digest[i+1];
s[2] = 0xff & (ctx->digest[i+1] >> 8);
s[1] = 0xff & (ctx->digest[i+1] >> 16);
s[0] = 0xff & ctx->digest[i+1] >> 24;
s+=8;
}
}
void tiger128_digest(struct tiger_ctx *ctx, mutils_word8 * s)
{
mutils_word32 i;
if (s!=NULL)
for (i = 0; i < TIGER128_DIGESTLEN; i+=2)
{ /* 64 bit and LITTLE ENDIAN -that's cool! */
s[7] = ctx->digest[i];
s[6] = 0xff & (ctx->digest[i] >> 8);
s[5] = 0xff & (ctx->digest[i] >> 16);
s[4] = 0xff & ctx->digest[i] >> 24;
s[3] = ctx->digest[i+1];
s[2] = 0xff & (ctx->digest[i+1] >> 8);
s[1] = 0xff & (ctx->digest[i+1] >> 16);
s[0] = 0xff & ctx->digest[i+1] >> 24;
s+=8;
}
}
void tiger160_digest(struct tiger_ctx *ctx, mutils_word8 * s)
{
mutils_word32 i;
for (i = 0; i < TIGER160_DIGESTLEN-1; i+=2) { /* 64 bit and LITTLE ENDIAN -that's cool! */
s[7] = ctx->digest[i];
s[6] = 0xff & (ctx->digest[i] >> 8);
s[5] = 0xff & (ctx->digest[i] >> 16);
s[4] = 0xff & ctx->digest[i] >> 24;
s[3] = ctx->digest[i+1];
s[2] = 0xff & (ctx->digest[i+1] >> 8);
s[1] = 0xff & (ctx->digest[i+1] >> 16);
s[0] = 0xff & ctx->digest[i+1] >> 24;
s+=8;
}
/* last block */
s[3] = ctx->digest[i+1];
s[2] = 0xff & (ctx->digest[i+1] >> 8);
s[1] = 0xff & (ctx->digest[i+1] >> 16);
s[0] = 0xff & ctx->digest[i+1] >> 24;
}
#endif /* !TIGER_64BIT */
#endif /* ENABLE_TIGER */
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,988 @@
/* whirlpool.c */
/* The Whirlpool hashing function. A new 512-bit hashing function
* operating on messages less than 2 ** 256 bits in length. The
* function structure is designed according to the Wide Trail strategy
* and permits a wide variety of implementation trade-offs.
*
* WHIRLPOOL has been selected for the NESSIE portfolio of
* cryptographic primitives. The International Organization for
* Standardization (ISO) has decided to include the final version of
* WHIRLPOOL in the revised ISO/IEC 10118-3:2003(E) standard.
*
* WHIRLPOOL uses Merkle-Damgård strengthening and the
* Miyaguchi-Preneel hashing scheme with a dedicated 512-bit block
* cipher called W. The W block cipher is very similar to the AES
* algorithm, RIJNDAEL.
*
* =============================================================================
*
* References
*
* The Whirlpool algorithm was developed by
* Paulo S. L. M. Barreto (pbarreto@scopus.com.br) and
* Vincent Rijmen (vincent.rijmen@cryptomathic.com).
*
* See
* P.S.L.M. Barreto, V. Rijmen,
* ``The Whirlpool hashing function,''
* NESSIE submission, 2000 (tweaked version, 2001),
* <https://www.cosic.esat.kuleuven.ac.be/nessie/workshop/submissions/whirlpool.zip>
*
* @author Paulo S.L.M. Barreto
* @author Vincent Rijmen.
*
* @version 3.0 (2003.03.12)
*
* =============================================================================
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS ''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 AUTHORS 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.
*
*/
/* This code was derived by B. Poettering from the reference implementation
* supplied by Barreto/Rijmen to fit the mhash library interface. Both this and
* the origanl code are in the public domain.
*
*/
#include "libdefs.h"
#ifdef ENABLE_WHIRLPOOL
#include "mhash_whirlpool.h"
/*
* The number of rounds of the internal dedicated block cipher.
*/
#define R 10
/*
* Though Whirlpool is endianness-neutral, the encryption tables are listed
* in BIG-ENDIAN format, which is adopted throughout this implementation
* (but little-endian notation would be equally suitable if consistently
* employed).
*/
static __const mutils_word64 C0[256] =
{
0x18186018c07830d8ULL, 0x23238c2305af4626ULL, 0xc6c63fc67ef991b8ULL, 0xe8e887e8136fcdfbULL,
0x878726874ca113cbULL, 0xb8b8dab8a9626d11ULL, 0x0101040108050209ULL, 0x4f4f214f426e9e0dULL,
0x3636d836adee6c9bULL, 0xa6a6a2a6590451ffULL, 0xd2d26fd2debdb90cULL, 0xf5f5f3f5fb06f70eULL,
0x7979f979ef80f296ULL, 0x6f6fa16f5fcede30ULL, 0x91917e91fcef3f6dULL, 0x52525552aa07a4f8ULL,
0x60609d6027fdc047ULL, 0xbcbccabc89766535ULL, 0x9b9b569baccd2b37ULL, 0x8e8e028e048c018aULL,
0xa3a3b6a371155bd2ULL, 0x0c0c300c603c186cULL, 0x7b7bf17bff8af684ULL, 0x3535d435b5e16a80ULL,
0x1d1d741de8693af5ULL, 0xe0e0a7e05347ddb3ULL, 0xd7d77bd7f6acb321ULL, 0xc2c22fc25eed999cULL,
0x2e2eb82e6d965c43ULL, 0x4b4b314b627a9629ULL, 0xfefedffea321e15dULL, 0x575741578216aed5ULL,
0x15155415a8412abdULL, 0x7777c1779fb6eee8ULL, 0x3737dc37a5eb6e92ULL, 0xe5e5b3e57b56d79eULL,
0x9f9f469f8cd92313ULL, 0xf0f0e7f0d317fd23ULL, 0x4a4a354a6a7f9420ULL, 0xdada4fda9e95a944ULL,
0x58587d58fa25b0a2ULL, 0xc9c903c906ca8fcfULL, 0x2929a429558d527cULL, 0x0a0a280a5022145aULL,
0xb1b1feb1e14f7f50ULL, 0xa0a0baa0691a5dc9ULL, 0x6b6bb16b7fdad614ULL, 0x85852e855cab17d9ULL,
0xbdbdcebd8173673cULL, 0x5d5d695dd234ba8fULL, 0x1010401080502090ULL, 0xf4f4f7f4f303f507ULL,
0xcbcb0bcb16c08bddULL, 0x3e3ef83eedc67cd3ULL, 0x0505140528110a2dULL, 0x676781671fe6ce78ULL,
0xe4e4b7e47353d597ULL, 0x27279c2725bb4e02ULL, 0x4141194132588273ULL, 0x8b8b168b2c9d0ba7ULL,
0xa7a7a6a7510153f6ULL, 0x7d7de97dcf94fab2ULL, 0x95956e95dcfb3749ULL, 0xd8d847d88e9fad56ULL,
0xfbfbcbfb8b30eb70ULL, 0xeeee9fee2371c1cdULL, 0x7c7ced7cc791f8bbULL, 0x6666856617e3cc71ULL,
0xdddd53dda68ea77bULL, 0x17175c17b84b2eafULL, 0x4747014702468e45ULL, 0x9e9e429e84dc211aULL,
0xcaca0fca1ec589d4ULL, 0x2d2db42d75995a58ULL, 0xbfbfc6bf9179632eULL, 0x07071c07381b0e3fULL,
0xadad8ead012347acULL, 0x5a5a755aea2fb4b0ULL, 0x838336836cb51befULL, 0x3333cc3385ff66b6ULL,
0x636391633ff2c65cULL, 0x02020802100a0412ULL, 0xaaaa92aa39384993ULL, 0x7171d971afa8e2deULL,
0xc8c807c80ecf8dc6ULL, 0x19196419c87d32d1ULL, 0x494939497270923bULL, 0xd9d943d9869aaf5fULL,
0xf2f2eff2c31df931ULL, 0xe3e3abe34b48dba8ULL, 0x5b5b715be22ab6b9ULL, 0x88881a8834920dbcULL,
0x9a9a529aa4c8293eULL, 0x262698262dbe4c0bULL, 0x3232c8328dfa64bfULL, 0xb0b0fab0e94a7d59ULL,
0xe9e983e91b6acff2ULL, 0x0f0f3c0f78331e77ULL, 0xd5d573d5e6a6b733ULL, 0x80803a8074ba1df4ULL,
0xbebec2be997c6127ULL, 0xcdcd13cd26de87ebULL, 0x3434d034bde46889ULL, 0x48483d487a759032ULL,
0xffffdbffab24e354ULL, 0x7a7af57af78ff48dULL, 0x90907a90f4ea3d64ULL, 0x5f5f615fc23ebe9dULL,
0x202080201da0403dULL, 0x6868bd6867d5d00fULL, 0x1a1a681ad07234caULL, 0xaeae82ae192c41b7ULL,
0xb4b4eab4c95e757dULL, 0x54544d549a19a8ceULL, 0x93937693ece53b7fULL, 0x222288220daa442fULL,
0x64648d6407e9c863ULL, 0xf1f1e3f1db12ff2aULL, 0x7373d173bfa2e6ccULL, 0x12124812905a2482ULL,
0x40401d403a5d807aULL, 0x0808200840281048ULL, 0xc3c32bc356e89b95ULL, 0xecec97ec337bc5dfULL,
0xdbdb4bdb9690ab4dULL, 0xa1a1bea1611f5fc0ULL, 0x8d8d0e8d1c830791ULL, 0x3d3df43df5c97ac8ULL,
0x97976697ccf1335bULL, 0x0000000000000000ULL, 0xcfcf1bcf36d483f9ULL, 0x2b2bac2b4587566eULL,
0x7676c57697b3ece1ULL, 0x8282328264b019e6ULL, 0xd6d67fd6fea9b128ULL, 0x1b1b6c1bd87736c3ULL,
0xb5b5eeb5c15b7774ULL, 0xafaf86af112943beULL, 0x6a6ab56a77dfd41dULL, 0x50505d50ba0da0eaULL,
0x45450945124c8a57ULL, 0xf3f3ebf3cb18fb38ULL, 0x3030c0309df060adULL, 0xefef9bef2b74c3c4ULL,
0x3f3ffc3fe5c37edaULL, 0x55554955921caac7ULL, 0xa2a2b2a2791059dbULL, 0xeaea8fea0365c9e9ULL,
0x656589650fecca6aULL, 0xbabad2bab9686903ULL, 0x2f2fbc2f65935e4aULL, 0xc0c027c04ee79d8eULL,
0xdede5fdebe81a160ULL, 0x1c1c701ce06c38fcULL, 0xfdfdd3fdbb2ee746ULL, 0x4d4d294d52649a1fULL,
0x92927292e4e03976ULL, 0x7575c9758fbceafaULL, 0x06061806301e0c36ULL, 0x8a8a128a249809aeULL,
0xb2b2f2b2f940794bULL, 0xe6e6bfe66359d185ULL, 0x0e0e380e70361c7eULL, 0x1f1f7c1ff8633ee7ULL,
0x6262956237f7c455ULL, 0xd4d477d4eea3b53aULL, 0xa8a89aa829324d81ULL, 0x96966296c4f43152ULL,
0xf9f9c3f99b3aef62ULL, 0xc5c533c566f697a3ULL, 0x2525942535b14a10ULL, 0x59597959f220b2abULL,
0x84842a8454ae15d0ULL, 0x7272d572b7a7e4c5ULL, 0x3939e439d5dd72ecULL, 0x4c4c2d4c5a619816ULL,
0x5e5e655eca3bbc94ULL, 0x7878fd78e785f09fULL, 0x3838e038ddd870e5ULL, 0x8c8c0a8c14860598ULL,
0xd1d163d1c6b2bf17ULL, 0xa5a5aea5410b57e4ULL, 0xe2e2afe2434dd9a1ULL, 0x616199612ff8c24eULL,
0xb3b3f6b3f1457b42ULL, 0x2121842115a54234ULL, 0x9c9c4a9c94d62508ULL, 0x1e1e781ef0663ceeULL,
0x4343114322528661ULL, 0xc7c73bc776fc93b1ULL, 0xfcfcd7fcb32be54fULL, 0x0404100420140824ULL,
0x51515951b208a2e3ULL, 0x99995e99bcc72f25ULL, 0x6d6da96d4fc4da22ULL, 0x0d0d340d68391a65ULL,
0xfafacffa8335e979ULL, 0xdfdf5bdfb684a369ULL, 0x7e7ee57ed79bfca9ULL, 0x242490243db44819ULL,
0x3b3bec3bc5d776feULL, 0xabab96ab313d4b9aULL, 0xcece1fce3ed181f0ULL, 0x1111441188552299ULL,
0x8f8f068f0c890383ULL, 0x4e4e254e4a6b9c04ULL, 0xb7b7e6b7d1517366ULL, 0xebeb8beb0b60cbe0ULL,
0x3c3cf03cfdcc78c1ULL, 0x81813e817cbf1ffdULL, 0x94946a94d4fe3540ULL, 0xf7f7fbf7eb0cf31cULL,
0xb9b9deb9a1676f18ULL, 0x13134c13985f268bULL, 0x2c2cb02c7d9c5851ULL, 0xd3d36bd3d6b8bb05ULL,
0xe7e7bbe76b5cd38cULL, 0x6e6ea56e57cbdc39ULL, 0xc4c437c46ef395aaULL, 0x03030c03180f061bULL,
0x565645568a13acdcULL, 0x44440d441a49885eULL, 0x7f7fe17fdf9efea0ULL, 0xa9a99ea921374f88ULL,
0x2a2aa82a4d825467ULL, 0xbbbbd6bbb16d6b0aULL, 0xc1c123c146e29f87ULL, 0x53535153a202a6f1ULL,
0xdcdc57dcae8ba572ULL, 0x0b0b2c0b58271653ULL, 0x9d9d4e9d9cd32701ULL, 0x6c6cad6c47c1d82bULL,
0x3131c43195f562a4ULL, 0x7474cd7487b9e8f3ULL, 0xf6f6fff6e309f115ULL, 0x464605460a438c4cULL,
0xacac8aac092645a5ULL, 0x89891e893c970fb5ULL, 0x14145014a04428b4ULL, 0xe1e1a3e15b42dfbaULL,
0x16165816b04e2ca6ULL, 0x3a3ae83acdd274f7ULL, 0x6969b9696fd0d206ULL, 0x09092409482d1241ULL,
0x7070dd70a7ade0d7ULL, 0xb6b6e2b6d954716fULL, 0xd0d067d0ceb7bd1eULL, 0xeded93ed3b7ec7d6ULL,
0xcccc17cc2edb85e2ULL, 0x424215422a578468ULL, 0x98985a98b4c22d2cULL, 0xa4a4aaa4490e55edULL,
0x2828a0285d885075ULL, 0x5c5c6d5cda31b886ULL, 0xf8f8c7f8933fed6bULL, 0x8686228644a411c2ULL,
};
static __const mutils_word64 C1[256] =
{
0xd818186018c07830ULL, 0x2623238c2305af46ULL, 0xb8c6c63fc67ef991ULL, 0xfbe8e887e8136fcdULL,
0xcb878726874ca113ULL, 0x11b8b8dab8a9626dULL, 0x0901010401080502ULL, 0x0d4f4f214f426e9eULL,
0x9b3636d836adee6cULL, 0xffa6a6a2a6590451ULL, 0x0cd2d26fd2debdb9ULL, 0x0ef5f5f3f5fb06f7ULL,
0x967979f979ef80f2ULL, 0x306f6fa16f5fcedeULL, 0x6d91917e91fcef3fULL, 0xf852525552aa07a4ULL,
0x4760609d6027fdc0ULL, 0x35bcbccabc897665ULL, 0x379b9b569baccd2bULL, 0x8a8e8e028e048c01ULL,
0xd2a3a3b6a371155bULL, 0x6c0c0c300c603c18ULL, 0x847b7bf17bff8af6ULL, 0x803535d435b5e16aULL,
0xf51d1d741de8693aULL, 0xb3e0e0a7e05347ddULL, 0x21d7d77bd7f6acb3ULL, 0x9cc2c22fc25eed99ULL,
0x432e2eb82e6d965cULL, 0x294b4b314b627a96ULL, 0x5dfefedffea321e1ULL, 0xd5575741578216aeULL,
0xbd15155415a8412aULL, 0xe87777c1779fb6eeULL, 0x923737dc37a5eb6eULL, 0x9ee5e5b3e57b56d7ULL,
0x139f9f469f8cd923ULL, 0x23f0f0e7f0d317fdULL, 0x204a4a354a6a7f94ULL, 0x44dada4fda9e95a9ULL,
0xa258587d58fa25b0ULL, 0xcfc9c903c906ca8fULL, 0x7c2929a429558d52ULL, 0x5a0a0a280a502214ULL,
0x50b1b1feb1e14f7fULL, 0xc9a0a0baa0691a5dULL, 0x146b6bb16b7fdad6ULL, 0xd985852e855cab17ULL,
0x3cbdbdcebd817367ULL, 0x8f5d5d695dd234baULL, 0x9010104010805020ULL, 0x07f4f4f7f4f303f5ULL,
0xddcbcb0bcb16c08bULL, 0xd33e3ef83eedc67cULL, 0x2d0505140528110aULL, 0x78676781671fe6ceULL,
0x97e4e4b7e47353d5ULL, 0x0227279c2725bb4eULL, 0x7341411941325882ULL, 0xa78b8b168b2c9d0bULL,
0xf6a7a7a6a7510153ULL, 0xb27d7de97dcf94faULL, 0x4995956e95dcfb37ULL, 0x56d8d847d88e9fadULL,
0x70fbfbcbfb8b30ebULL, 0xcdeeee9fee2371c1ULL, 0xbb7c7ced7cc791f8ULL, 0x716666856617e3ccULL,
0x7bdddd53dda68ea7ULL, 0xaf17175c17b84b2eULL, 0x454747014702468eULL, 0x1a9e9e429e84dc21ULL,
0xd4caca0fca1ec589ULL, 0x582d2db42d75995aULL, 0x2ebfbfc6bf917963ULL, 0x3f07071c07381b0eULL,
0xacadad8ead012347ULL, 0xb05a5a755aea2fb4ULL, 0xef838336836cb51bULL, 0xb63333cc3385ff66ULL,
0x5c636391633ff2c6ULL, 0x1202020802100a04ULL, 0x93aaaa92aa393849ULL, 0xde7171d971afa8e2ULL,
0xc6c8c807c80ecf8dULL, 0xd119196419c87d32ULL, 0x3b49493949727092ULL, 0x5fd9d943d9869aafULL,
0x31f2f2eff2c31df9ULL, 0xa8e3e3abe34b48dbULL, 0xb95b5b715be22ab6ULL, 0xbc88881a8834920dULL,
0x3e9a9a529aa4c829ULL, 0x0b262698262dbe4cULL, 0xbf3232c8328dfa64ULL, 0x59b0b0fab0e94a7dULL,
0xf2e9e983e91b6acfULL, 0x770f0f3c0f78331eULL, 0x33d5d573d5e6a6b7ULL, 0xf480803a8074ba1dULL,
0x27bebec2be997c61ULL, 0xebcdcd13cd26de87ULL, 0x893434d034bde468ULL, 0x3248483d487a7590ULL,
0x54ffffdbffab24e3ULL, 0x8d7a7af57af78ff4ULL, 0x6490907a90f4ea3dULL, 0x9d5f5f615fc23ebeULL,
0x3d202080201da040ULL, 0x0f6868bd6867d5d0ULL, 0xca1a1a681ad07234ULL, 0xb7aeae82ae192c41ULL,
0x7db4b4eab4c95e75ULL, 0xce54544d549a19a8ULL, 0x7f93937693ece53bULL, 0x2f222288220daa44ULL,
0x6364648d6407e9c8ULL, 0x2af1f1e3f1db12ffULL, 0xcc7373d173bfa2e6ULL, 0x8212124812905a24ULL,
0x7a40401d403a5d80ULL, 0x4808082008402810ULL, 0x95c3c32bc356e89bULL, 0xdfecec97ec337bc5ULL,
0x4ddbdb4bdb9690abULL, 0xc0a1a1bea1611f5fULL, 0x918d8d0e8d1c8307ULL, 0xc83d3df43df5c97aULL,
0x5b97976697ccf133ULL, 0x0000000000000000ULL, 0xf9cfcf1bcf36d483ULL, 0x6e2b2bac2b458756ULL,
0xe17676c57697b3ecULL, 0xe68282328264b019ULL, 0x28d6d67fd6fea9b1ULL, 0xc31b1b6c1bd87736ULL,
0x74b5b5eeb5c15b77ULL, 0xbeafaf86af112943ULL, 0x1d6a6ab56a77dfd4ULL, 0xea50505d50ba0da0ULL,
0x5745450945124c8aULL, 0x38f3f3ebf3cb18fbULL, 0xad3030c0309df060ULL, 0xc4efef9bef2b74c3ULL,
0xda3f3ffc3fe5c37eULL, 0xc755554955921caaULL, 0xdba2a2b2a2791059ULL, 0xe9eaea8fea0365c9ULL,
0x6a656589650feccaULL, 0x03babad2bab96869ULL, 0x4a2f2fbc2f65935eULL, 0x8ec0c027c04ee79dULL,
0x60dede5fdebe81a1ULL, 0xfc1c1c701ce06c38ULL, 0x46fdfdd3fdbb2ee7ULL, 0x1f4d4d294d52649aULL,
0x7692927292e4e039ULL, 0xfa7575c9758fbceaULL, 0x3606061806301e0cULL, 0xae8a8a128a249809ULL,
0x4bb2b2f2b2f94079ULL, 0x85e6e6bfe66359d1ULL, 0x7e0e0e380e70361cULL, 0xe71f1f7c1ff8633eULL,
0x556262956237f7c4ULL, 0x3ad4d477d4eea3b5ULL, 0x81a8a89aa829324dULL, 0x5296966296c4f431ULL,
0x62f9f9c3f99b3aefULL, 0xa3c5c533c566f697ULL, 0x102525942535b14aULL, 0xab59597959f220b2ULL,
0xd084842a8454ae15ULL, 0xc57272d572b7a7e4ULL, 0xec3939e439d5dd72ULL, 0x164c4c2d4c5a6198ULL,
0x945e5e655eca3bbcULL, 0x9f7878fd78e785f0ULL, 0xe53838e038ddd870ULL, 0x988c8c0a8c148605ULL,
0x17d1d163d1c6b2bfULL, 0xe4a5a5aea5410b57ULL, 0xa1e2e2afe2434dd9ULL, 0x4e616199612ff8c2ULL,
0x42b3b3f6b3f1457bULL, 0x342121842115a542ULL, 0x089c9c4a9c94d625ULL, 0xee1e1e781ef0663cULL,
0x6143431143225286ULL, 0xb1c7c73bc776fc93ULL, 0x4ffcfcd7fcb32be5ULL, 0x2404041004201408ULL,
0xe351515951b208a2ULL, 0x2599995e99bcc72fULL, 0x226d6da96d4fc4daULL, 0x650d0d340d68391aULL,
0x79fafacffa8335e9ULL, 0x69dfdf5bdfb684a3ULL, 0xa97e7ee57ed79bfcULL, 0x19242490243db448ULL,
0xfe3b3bec3bc5d776ULL, 0x9aabab96ab313d4bULL, 0xf0cece1fce3ed181ULL, 0x9911114411885522ULL,
0x838f8f068f0c8903ULL, 0x044e4e254e4a6b9cULL, 0x66b7b7e6b7d15173ULL, 0xe0ebeb8beb0b60cbULL,
0xc13c3cf03cfdcc78ULL, 0xfd81813e817cbf1fULL, 0x4094946a94d4fe35ULL, 0x1cf7f7fbf7eb0cf3ULL,
0x18b9b9deb9a1676fULL, 0x8b13134c13985f26ULL, 0x512c2cb02c7d9c58ULL, 0x05d3d36bd3d6b8bbULL,
0x8ce7e7bbe76b5cd3ULL, 0x396e6ea56e57cbdcULL, 0xaac4c437c46ef395ULL, 0x1b03030c03180f06ULL,
0xdc565645568a13acULL, 0x5e44440d441a4988ULL, 0xa07f7fe17fdf9efeULL, 0x88a9a99ea921374fULL,
0x672a2aa82a4d8254ULL, 0x0abbbbd6bbb16d6bULL, 0x87c1c123c146e29fULL, 0xf153535153a202a6ULL,
0x72dcdc57dcae8ba5ULL, 0x530b0b2c0b582716ULL, 0x019d9d4e9d9cd327ULL, 0x2b6c6cad6c47c1d8ULL,
0xa43131c43195f562ULL, 0xf37474cd7487b9e8ULL, 0x15f6f6fff6e309f1ULL, 0x4c464605460a438cULL,
0xa5acac8aac092645ULL, 0xb589891e893c970fULL, 0xb414145014a04428ULL, 0xbae1e1a3e15b42dfULL,
0xa616165816b04e2cULL, 0xf73a3ae83acdd274ULL, 0x066969b9696fd0d2ULL, 0x4109092409482d12ULL,
0xd77070dd70a7ade0ULL, 0x6fb6b6e2b6d95471ULL, 0x1ed0d067d0ceb7bdULL, 0xd6eded93ed3b7ec7ULL,
0xe2cccc17cc2edb85ULL, 0x68424215422a5784ULL, 0x2c98985a98b4c22dULL, 0xeda4a4aaa4490e55ULL,
0x752828a0285d8850ULL, 0x865c5c6d5cda31b8ULL, 0x6bf8f8c7f8933fedULL, 0xc28686228644a411ULL,
};
static __const mutils_word64 C2[256] =
{
0x30d818186018c078ULL, 0x462623238c2305afULL, 0x91b8c6c63fc67ef9ULL, 0xcdfbe8e887e8136fULL,
0x13cb878726874ca1ULL, 0x6d11b8b8dab8a962ULL, 0x0209010104010805ULL, 0x9e0d4f4f214f426eULL,
0x6c9b3636d836adeeULL, 0x51ffa6a6a2a65904ULL, 0xb90cd2d26fd2debdULL, 0xf70ef5f5f3f5fb06ULL,
0xf2967979f979ef80ULL, 0xde306f6fa16f5fceULL, 0x3f6d91917e91fcefULL, 0xa4f852525552aa07ULL,
0xc04760609d6027fdULL, 0x6535bcbccabc8976ULL, 0x2b379b9b569baccdULL, 0x018a8e8e028e048cULL,
0x5bd2a3a3b6a37115ULL, 0x186c0c0c300c603cULL, 0xf6847b7bf17bff8aULL, 0x6a803535d435b5e1ULL,
0x3af51d1d741de869ULL, 0xddb3e0e0a7e05347ULL, 0xb321d7d77bd7f6acULL, 0x999cc2c22fc25eedULL,
0x5c432e2eb82e6d96ULL, 0x96294b4b314b627aULL, 0xe15dfefedffea321ULL, 0xaed5575741578216ULL,
0x2abd15155415a841ULL, 0xeee87777c1779fb6ULL, 0x6e923737dc37a5ebULL, 0xd79ee5e5b3e57b56ULL,
0x23139f9f469f8cd9ULL, 0xfd23f0f0e7f0d317ULL, 0x94204a4a354a6a7fULL, 0xa944dada4fda9e95ULL,
0xb0a258587d58fa25ULL, 0x8fcfc9c903c906caULL, 0x527c2929a429558dULL, 0x145a0a0a280a5022ULL,
0x7f50b1b1feb1e14fULL, 0x5dc9a0a0baa0691aULL, 0xd6146b6bb16b7fdaULL, 0x17d985852e855cabULL,
0x673cbdbdcebd8173ULL, 0xba8f5d5d695dd234ULL, 0x2090101040108050ULL, 0xf507f4f4f7f4f303ULL,
0x8bddcbcb0bcb16c0ULL, 0x7cd33e3ef83eedc6ULL, 0x0a2d050514052811ULL, 0xce78676781671fe6ULL,
0xd597e4e4b7e47353ULL, 0x4e0227279c2725bbULL, 0x8273414119413258ULL, 0x0ba78b8b168b2c9dULL,
0x53f6a7a7a6a75101ULL, 0xfab27d7de97dcf94ULL, 0x374995956e95dcfbULL, 0xad56d8d847d88e9fULL,
0xeb70fbfbcbfb8b30ULL, 0xc1cdeeee9fee2371ULL, 0xf8bb7c7ced7cc791ULL, 0xcc716666856617e3ULL,
0xa77bdddd53dda68eULL, 0x2eaf17175c17b84bULL, 0x8e45474701470246ULL, 0x211a9e9e429e84dcULL,
0x89d4caca0fca1ec5ULL, 0x5a582d2db42d7599ULL, 0x632ebfbfc6bf9179ULL, 0x0e3f07071c07381bULL,
0x47acadad8ead0123ULL, 0xb4b05a5a755aea2fULL, 0x1bef838336836cb5ULL, 0x66b63333cc3385ffULL,
0xc65c636391633ff2ULL, 0x041202020802100aULL, 0x4993aaaa92aa3938ULL, 0xe2de7171d971afa8ULL,
0x8dc6c8c807c80ecfULL, 0x32d119196419c87dULL, 0x923b494939497270ULL, 0xaf5fd9d943d9869aULL,
0xf931f2f2eff2c31dULL, 0xdba8e3e3abe34b48ULL, 0xb6b95b5b715be22aULL, 0x0dbc88881a883492ULL,
0x293e9a9a529aa4c8ULL, 0x4c0b262698262dbeULL, 0x64bf3232c8328dfaULL, 0x7d59b0b0fab0e94aULL,
0xcff2e9e983e91b6aULL, 0x1e770f0f3c0f7833ULL, 0xb733d5d573d5e6a6ULL, 0x1df480803a8074baULL,
0x6127bebec2be997cULL, 0x87ebcdcd13cd26deULL, 0x68893434d034bde4ULL, 0x903248483d487a75ULL,
0xe354ffffdbffab24ULL, 0xf48d7a7af57af78fULL, 0x3d6490907a90f4eaULL, 0xbe9d5f5f615fc23eULL,
0x403d202080201da0ULL, 0xd00f6868bd6867d5ULL, 0x34ca1a1a681ad072ULL, 0x41b7aeae82ae192cULL,
0x757db4b4eab4c95eULL, 0xa8ce54544d549a19ULL, 0x3b7f93937693ece5ULL, 0x442f222288220daaULL,
0xc86364648d6407e9ULL, 0xff2af1f1e3f1db12ULL, 0xe6cc7373d173bfa2ULL, 0x248212124812905aULL,
0x807a40401d403a5dULL, 0x1048080820084028ULL, 0x9b95c3c32bc356e8ULL, 0xc5dfecec97ec337bULL,
0xab4ddbdb4bdb9690ULL, 0x5fc0a1a1bea1611fULL, 0x07918d8d0e8d1c83ULL, 0x7ac83d3df43df5c9ULL,
0x335b97976697ccf1ULL, 0x0000000000000000ULL, 0x83f9cfcf1bcf36d4ULL, 0x566e2b2bac2b4587ULL,
0xece17676c57697b3ULL, 0x19e68282328264b0ULL, 0xb128d6d67fd6fea9ULL, 0x36c31b1b6c1bd877ULL,
0x7774b5b5eeb5c15bULL, 0x43beafaf86af1129ULL, 0xd41d6a6ab56a77dfULL, 0xa0ea50505d50ba0dULL,
0x8a5745450945124cULL, 0xfb38f3f3ebf3cb18ULL, 0x60ad3030c0309df0ULL, 0xc3c4efef9bef2b74ULL,
0x7eda3f3ffc3fe5c3ULL, 0xaac755554955921cULL, 0x59dba2a2b2a27910ULL, 0xc9e9eaea8fea0365ULL,
0xca6a656589650fecULL, 0x6903babad2bab968ULL, 0x5e4a2f2fbc2f6593ULL, 0x9d8ec0c027c04ee7ULL,
0xa160dede5fdebe81ULL, 0x38fc1c1c701ce06cULL, 0xe746fdfdd3fdbb2eULL, 0x9a1f4d4d294d5264ULL,
0x397692927292e4e0ULL, 0xeafa7575c9758fbcULL, 0x0c3606061806301eULL, 0x09ae8a8a128a2498ULL,
0x794bb2b2f2b2f940ULL, 0xd185e6e6bfe66359ULL, 0x1c7e0e0e380e7036ULL, 0x3ee71f1f7c1ff863ULL,
0xc4556262956237f7ULL, 0xb53ad4d477d4eea3ULL, 0x4d81a8a89aa82932ULL, 0x315296966296c4f4ULL,
0xef62f9f9c3f99b3aULL, 0x97a3c5c533c566f6ULL, 0x4a102525942535b1ULL, 0xb2ab59597959f220ULL,
0x15d084842a8454aeULL, 0xe4c57272d572b7a7ULL, 0x72ec3939e439d5ddULL, 0x98164c4c2d4c5a61ULL,
0xbc945e5e655eca3bULL, 0xf09f7878fd78e785ULL, 0x70e53838e038ddd8ULL, 0x05988c8c0a8c1486ULL,
0xbf17d1d163d1c6b2ULL, 0x57e4a5a5aea5410bULL, 0xd9a1e2e2afe2434dULL, 0xc24e616199612ff8ULL,
0x7b42b3b3f6b3f145ULL, 0x42342121842115a5ULL, 0x25089c9c4a9c94d6ULL, 0x3cee1e1e781ef066ULL,
0x8661434311432252ULL, 0x93b1c7c73bc776fcULL, 0xe54ffcfcd7fcb32bULL, 0x0824040410042014ULL,
0xa2e351515951b208ULL, 0x2f2599995e99bcc7ULL, 0xda226d6da96d4fc4ULL, 0x1a650d0d340d6839ULL,
0xe979fafacffa8335ULL, 0xa369dfdf5bdfb684ULL, 0xfca97e7ee57ed79bULL, 0x4819242490243db4ULL,
0x76fe3b3bec3bc5d7ULL, 0x4b9aabab96ab313dULL, 0x81f0cece1fce3ed1ULL, 0x2299111144118855ULL,
0x03838f8f068f0c89ULL, 0x9c044e4e254e4a6bULL, 0x7366b7b7e6b7d151ULL, 0xcbe0ebeb8beb0b60ULL,
0x78c13c3cf03cfdccULL, 0x1ffd81813e817cbfULL, 0x354094946a94d4feULL, 0xf31cf7f7fbf7eb0cULL,
0x6f18b9b9deb9a167ULL, 0x268b13134c13985fULL, 0x58512c2cb02c7d9cULL, 0xbb05d3d36bd3d6b8ULL,
0xd38ce7e7bbe76b5cULL, 0xdc396e6ea56e57cbULL, 0x95aac4c437c46ef3ULL, 0x061b03030c03180fULL,
0xacdc565645568a13ULL, 0x885e44440d441a49ULL, 0xfea07f7fe17fdf9eULL, 0x4f88a9a99ea92137ULL,
0x54672a2aa82a4d82ULL, 0x6b0abbbbd6bbb16dULL, 0x9f87c1c123c146e2ULL, 0xa6f153535153a202ULL,
0xa572dcdc57dcae8bULL, 0x16530b0b2c0b5827ULL, 0x27019d9d4e9d9cd3ULL, 0xd82b6c6cad6c47c1ULL,
0x62a43131c43195f5ULL, 0xe8f37474cd7487b9ULL, 0xf115f6f6fff6e309ULL, 0x8c4c464605460a43ULL,
0x45a5acac8aac0926ULL, 0x0fb589891e893c97ULL, 0x28b414145014a044ULL, 0xdfbae1e1a3e15b42ULL,
0x2ca616165816b04eULL, 0x74f73a3ae83acdd2ULL, 0xd2066969b9696fd0ULL, 0x124109092409482dULL,
0xe0d77070dd70a7adULL, 0x716fb6b6e2b6d954ULL, 0xbd1ed0d067d0ceb7ULL, 0xc7d6eded93ed3b7eULL,
0x85e2cccc17cc2edbULL, 0x8468424215422a57ULL, 0x2d2c98985a98b4c2ULL, 0x55eda4a4aaa4490eULL,
0x50752828a0285d88ULL, 0xb8865c5c6d5cda31ULL, 0xed6bf8f8c7f8933fULL, 0x11c28686228644a4ULL,
};
static __const mutils_word64 C3[256] =
{
0x7830d818186018c0ULL, 0xaf462623238c2305ULL, 0xf991b8c6c63fc67eULL, 0x6fcdfbe8e887e813ULL,
0xa113cb878726874cULL, 0x626d11b8b8dab8a9ULL, 0x0502090101040108ULL, 0x6e9e0d4f4f214f42ULL,
0xee6c9b3636d836adULL, 0x0451ffa6a6a2a659ULL, 0xbdb90cd2d26fd2deULL, 0x06f70ef5f5f3f5fbULL,
0x80f2967979f979efULL, 0xcede306f6fa16f5fULL, 0xef3f6d91917e91fcULL, 0x07a4f852525552aaULL,
0xfdc04760609d6027ULL, 0x766535bcbccabc89ULL, 0xcd2b379b9b569bacULL, 0x8c018a8e8e028e04ULL,
0x155bd2a3a3b6a371ULL, 0x3c186c0c0c300c60ULL, 0x8af6847b7bf17bffULL, 0xe16a803535d435b5ULL,
0x693af51d1d741de8ULL, 0x47ddb3e0e0a7e053ULL, 0xacb321d7d77bd7f6ULL, 0xed999cc2c22fc25eULL,
0x965c432e2eb82e6dULL, 0x7a96294b4b314b62ULL, 0x21e15dfefedffea3ULL, 0x16aed55757415782ULL,
0x412abd15155415a8ULL, 0xb6eee87777c1779fULL, 0xeb6e923737dc37a5ULL, 0x56d79ee5e5b3e57bULL,
0xd923139f9f469f8cULL, 0x17fd23f0f0e7f0d3ULL, 0x7f94204a4a354a6aULL, 0x95a944dada4fda9eULL,
0x25b0a258587d58faULL, 0xca8fcfc9c903c906ULL, 0x8d527c2929a42955ULL, 0x22145a0a0a280a50ULL,
0x4f7f50b1b1feb1e1ULL, 0x1a5dc9a0a0baa069ULL, 0xdad6146b6bb16b7fULL, 0xab17d985852e855cULL,
0x73673cbdbdcebd81ULL, 0x34ba8f5d5d695dd2ULL, 0x5020901010401080ULL, 0x03f507f4f4f7f4f3ULL,
0xc08bddcbcb0bcb16ULL, 0xc67cd33e3ef83eedULL, 0x110a2d0505140528ULL, 0xe6ce78676781671fULL,
0x53d597e4e4b7e473ULL, 0xbb4e0227279c2725ULL, 0x5882734141194132ULL, 0x9d0ba78b8b168b2cULL,
0x0153f6a7a7a6a751ULL, 0x94fab27d7de97dcfULL, 0xfb374995956e95dcULL, 0x9fad56d8d847d88eULL,
0x30eb70fbfbcbfb8bULL, 0x71c1cdeeee9fee23ULL, 0x91f8bb7c7ced7cc7ULL, 0xe3cc716666856617ULL,
0x8ea77bdddd53dda6ULL, 0x4b2eaf17175c17b8ULL, 0x468e454747014702ULL, 0xdc211a9e9e429e84ULL,
0xc589d4caca0fca1eULL, 0x995a582d2db42d75ULL, 0x79632ebfbfc6bf91ULL, 0x1b0e3f07071c0738ULL,
0x2347acadad8ead01ULL, 0x2fb4b05a5a755aeaULL, 0xb51bef838336836cULL, 0xff66b63333cc3385ULL,
0xf2c65c636391633fULL, 0x0a04120202080210ULL, 0x384993aaaa92aa39ULL, 0xa8e2de7171d971afULL,
0xcf8dc6c8c807c80eULL, 0x7d32d119196419c8ULL, 0x70923b4949394972ULL, 0x9aaf5fd9d943d986ULL,
0x1df931f2f2eff2c3ULL, 0x48dba8e3e3abe34bULL, 0x2ab6b95b5b715be2ULL, 0x920dbc88881a8834ULL,
0xc8293e9a9a529aa4ULL, 0xbe4c0b262698262dULL, 0xfa64bf3232c8328dULL, 0x4a7d59b0b0fab0e9ULL,
0x6acff2e9e983e91bULL, 0x331e770f0f3c0f78ULL, 0xa6b733d5d573d5e6ULL, 0xba1df480803a8074ULL,
0x7c6127bebec2be99ULL, 0xde87ebcdcd13cd26ULL, 0xe468893434d034bdULL, 0x75903248483d487aULL,
0x24e354ffffdbffabULL, 0x8ff48d7a7af57af7ULL, 0xea3d6490907a90f4ULL, 0x3ebe9d5f5f615fc2ULL,
0xa0403d202080201dULL, 0xd5d00f6868bd6867ULL, 0x7234ca1a1a681ad0ULL, 0x2c41b7aeae82ae19ULL,
0x5e757db4b4eab4c9ULL, 0x19a8ce54544d549aULL, 0xe53b7f93937693ecULL, 0xaa442f222288220dULL,
0xe9c86364648d6407ULL, 0x12ff2af1f1e3f1dbULL, 0xa2e6cc7373d173bfULL, 0x5a24821212481290ULL,
0x5d807a40401d403aULL, 0x2810480808200840ULL, 0xe89b95c3c32bc356ULL, 0x7bc5dfecec97ec33ULL,
0x90ab4ddbdb4bdb96ULL, 0x1f5fc0a1a1bea161ULL, 0x8307918d8d0e8d1cULL, 0xc97ac83d3df43df5ULL,
0xf1335b97976697ccULL, 0x0000000000000000ULL, 0xd483f9cfcf1bcf36ULL, 0x87566e2b2bac2b45ULL,
0xb3ece17676c57697ULL, 0xb019e68282328264ULL, 0xa9b128d6d67fd6feULL, 0x7736c31b1b6c1bd8ULL,
0x5b7774b5b5eeb5c1ULL, 0x2943beafaf86af11ULL, 0xdfd41d6a6ab56a77ULL, 0x0da0ea50505d50baULL,
0x4c8a574545094512ULL, 0x18fb38f3f3ebf3cbULL, 0xf060ad3030c0309dULL, 0x74c3c4efef9bef2bULL,
0xc37eda3f3ffc3fe5ULL, 0x1caac75555495592ULL, 0x1059dba2a2b2a279ULL, 0x65c9e9eaea8fea03ULL,
0xecca6a656589650fULL, 0x686903babad2bab9ULL, 0x935e4a2f2fbc2f65ULL, 0xe79d8ec0c027c04eULL,
0x81a160dede5fdebeULL, 0x6c38fc1c1c701ce0ULL, 0x2ee746fdfdd3fdbbULL, 0x649a1f4d4d294d52ULL,
0xe0397692927292e4ULL, 0xbceafa7575c9758fULL, 0x1e0c360606180630ULL, 0x9809ae8a8a128a24ULL,
0x40794bb2b2f2b2f9ULL, 0x59d185e6e6bfe663ULL, 0x361c7e0e0e380e70ULL, 0x633ee71f1f7c1ff8ULL,
0xf7c4556262956237ULL, 0xa3b53ad4d477d4eeULL, 0x324d81a8a89aa829ULL, 0xf4315296966296c4ULL,
0x3aef62f9f9c3f99bULL, 0xf697a3c5c533c566ULL, 0xb14a102525942535ULL, 0x20b2ab59597959f2ULL,
0xae15d084842a8454ULL, 0xa7e4c57272d572b7ULL, 0xdd72ec3939e439d5ULL, 0x6198164c4c2d4c5aULL,
0x3bbc945e5e655ecaULL, 0x85f09f7878fd78e7ULL, 0xd870e53838e038ddULL, 0x8605988c8c0a8c14ULL,
0xb2bf17d1d163d1c6ULL, 0x0b57e4a5a5aea541ULL, 0x4dd9a1e2e2afe243ULL, 0xf8c24e616199612fULL,
0x457b42b3b3f6b3f1ULL, 0xa542342121842115ULL, 0xd625089c9c4a9c94ULL, 0x663cee1e1e781ef0ULL,
0x5286614343114322ULL, 0xfc93b1c7c73bc776ULL, 0x2be54ffcfcd7fcb3ULL, 0x1408240404100420ULL,
0x08a2e351515951b2ULL, 0xc72f2599995e99bcULL, 0xc4da226d6da96d4fULL, 0x391a650d0d340d68ULL,
0x35e979fafacffa83ULL, 0x84a369dfdf5bdfb6ULL, 0x9bfca97e7ee57ed7ULL, 0xb44819242490243dULL,
0xd776fe3b3bec3bc5ULL, 0x3d4b9aabab96ab31ULL, 0xd181f0cece1fce3eULL, 0x5522991111441188ULL,
0x8903838f8f068f0cULL, 0x6b9c044e4e254e4aULL, 0x517366b7b7e6b7d1ULL, 0x60cbe0ebeb8beb0bULL,
0xcc78c13c3cf03cfdULL, 0xbf1ffd81813e817cULL, 0xfe354094946a94d4ULL, 0x0cf31cf7f7fbf7ebULL,
0x676f18b9b9deb9a1ULL, 0x5f268b13134c1398ULL, 0x9c58512c2cb02c7dULL, 0xb8bb05d3d36bd3d6ULL,
0x5cd38ce7e7bbe76bULL, 0xcbdc396e6ea56e57ULL, 0xf395aac4c437c46eULL, 0x0f061b03030c0318ULL,
0x13acdc565645568aULL, 0x49885e44440d441aULL, 0x9efea07f7fe17fdfULL, 0x374f88a9a99ea921ULL,
0x8254672a2aa82a4dULL, 0x6d6b0abbbbd6bbb1ULL, 0xe29f87c1c123c146ULL, 0x02a6f153535153a2ULL,
0x8ba572dcdc57dcaeULL, 0x2716530b0b2c0b58ULL, 0xd327019d9d4e9d9cULL, 0xc1d82b6c6cad6c47ULL,
0xf562a43131c43195ULL, 0xb9e8f37474cd7487ULL, 0x09f115f6f6fff6e3ULL, 0x438c4c464605460aULL,
0x2645a5acac8aac09ULL, 0x970fb589891e893cULL, 0x4428b414145014a0ULL, 0x42dfbae1e1a3e15bULL,
0x4e2ca616165816b0ULL, 0xd274f73a3ae83acdULL, 0xd0d2066969b9696fULL, 0x2d12410909240948ULL,
0xade0d77070dd70a7ULL, 0x54716fb6b6e2b6d9ULL, 0xb7bd1ed0d067d0ceULL, 0x7ec7d6eded93ed3bULL,
0xdb85e2cccc17cc2eULL, 0x578468424215422aULL, 0xc22d2c98985a98b4ULL, 0x0e55eda4a4aaa449ULL,
0x8850752828a0285dULL, 0x31b8865c5c6d5cdaULL, 0x3fed6bf8f8c7f893ULL, 0xa411c28686228644ULL,
};
static __const mutils_word64 C4[256] =
{
0xc07830d818186018ULL, 0x05af462623238c23ULL, 0x7ef991b8c6c63fc6ULL, 0x136fcdfbe8e887e8ULL,
0x4ca113cb87872687ULL, 0xa9626d11b8b8dab8ULL, 0x0805020901010401ULL, 0x426e9e0d4f4f214fULL,
0xadee6c9b3636d836ULL, 0x590451ffa6a6a2a6ULL, 0xdebdb90cd2d26fd2ULL, 0xfb06f70ef5f5f3f5ULL,
0xef80f2967979f979ULL, 0x5fcede306f6fa16fULL, 0xfcef3f6d91917e91ULL, 0xaa07a4f852525552ULL,
0x27fdc04760609d60ULL, 0x89766535bcbccabcULL, 0xaccd2b379b9b569bULL, 0x048c018a8e8e028eULL,
0x71155bd2a3a3b6a3ULL, 0x603c186c0c0c300cULL, 0xff8af6847b7bf17bULL, 0xb5e16a803535d435ULL,
0xe8693af51d1d741dULL, 0x5347ddb3e0e0a7e0ULL, 0xf6acb321d7d77bd7ULL, 0x5eed999cc2c22fc2ULL,
0x6d965c432e2eb82eULL, 0x627a96294b4b314bULL, 0xa321e15dfefedffeULL, 0x8216aed557574157ULL,
0xa8412abd15155415ULL, 0x9fb6eee87777c177ULL, 0xa5eb6e923737dc37ULL, 0x7b56d79ee5e5b3e5ULL,
0x8cd923139f9f469fULL, 0xd317fd23f0f0e7f0ULL, 0x6a7f94204a4a354aULL, 0x9e95a944dada4fdaULL,
0xfa25b0a258587d58ULL, 0x06ca8fcfc9c903c9ULL, 0x558d527c2929a429ULL, 0x5022145a0a0a280aULL,
0xe14f7f50b1b1feb1ULL, 0x691a5dc9a0a0baa0ULL, 0x7fdad6146b6bb16bULL, 0x5cab17d985852e85ULL,
0x8173673cbdbdcebdULL, 0xd234ba8f5d5d695dULL, 0x8050209010104010ULL, 0xf303f507f4f4f7f4ULL,
0x16c08bddcbcb0bcbULL, 0xedc67cd33e3ef83eULL, 0x28110a2d05051405ULL, 0x1fe6ce7867678167ULL,
0x7353d597e4e4b7e4ULL, 0x25bb4e0227279c27ULL, 0x3258827341411941ULL, 0x2c9d0ba78b8b168bULL,
0x510153f6a7a7a6a7ULL, 0xcf94fab27d7de97dULL, 0xdcfb374995956e95ULL, 0x8e9fad56d8d847d8ULL,
0x8b30eb70fbfbcbfbULL, 0x2371c1cdeeee9feeULL, 0xc791f8bb7c7ced7cULL, 0x17e3cc7166668566ULL,
0xa68ea77bdddd53ddULL, 0xb84b2eaf17175c17ULL, 0x02468e4547470147ULL, 0x84dc211a9e9e429eULL,
0x1ec589d4caca0fcaULL, 0x75995a582d2db42dULL, 0x9179632ebfbfc6bfULL, 0x381b0e3f07071c07ULL,
0x012347acadad8eadULL, 0xea2fb4b05a5a755aULL, 0x6cb51bef83833683ULL, 0x85ff66b63333cc33ULL,
0x3ff2c65c63639163ULL, 0x100a041202020802ULL, 0x39384993aaaa92aaULL, 0xafa8e2de7171d971ULL,
0x0ecf8dc6c8c807c8ULL, 0xc87d32d119196419ULL, 0x7270923b49493949ULL, 0x869aaf5fd9d943d9ULL,
0xc31df931f2f2eff2ULL, 0x4b48dba8e3e3abe3ULL, 0xe22ab6b95b5b715bULL, 0x34920dbc88881a88ULL,
0xa4c8293e9a9a529aULL, 0x2dbe4c0b26269826ULL, 0x8dfa64bf3232c832ULL, 0xe94a7d59b0b0fab0ULL,
0x1b6acff2e9e983e9ULL, 0x78331e770f0f3c0fULL, 0xe6a6b733d5d573d5ULL, 0x74ba1df480803a80ULL,
0x997c6127bebec2beULL, 0x26de87ebcdcd13cdULL, 0xbde468893434d034ULL, 0x7a75903248483d48ULL,
0xab24e354ffffdbffULL, 0xf78ff48d7a7af57aULL, 0xf4ea3d6490907a90ULL, 0xc23ebe9d5f5f615fULL,
0x1da0403d20208020ULL, 0x67d5d00f6868bd68ULL, 0xd07234ca1a1a681aULL, 0x192c41b7aeae82aeULL,
0xc95e757db4b4eab4ULL, 0x9a19a8ce54544d54ULL, 0xece53b7f93937693ULL, 0x0daa442f22228822ULL,
0x07e9c86364648d64ULL, 0xdb12ff2af1f1e3f1ULL, 0xbfa2e6cc7373d173ULL, 0x905a248212124812ULL,
0x3a5d807a40401d40ULL, 0x4028104808082008ULL, 0x56e89b95c3c32bc3ULL, 0x337bc5dfecec97ecULL,
0x9690ab4ddbdb4bdbULL, 0x611f5fc0a1a1bea1ULL, 0x1c8307918d8d0e8dULL, 0xf5c97ac83d3df43dULL,
0xccf1335b97976697ULL, 0x0000000000000000ULL, 0x36d483f9cfcf1bcfULL, 0x4587566e2b2bac2bULL,
0x97b3ece17676c576ULL, 0x64b019e682823282ULL, 0xfea9b128d6d67fd6ULL, 0xd87736c31b1b6c1bULL,
0xc15b7774b5b5eeb5ULL, 0x112943beafaf86afULL, 0x77dfd41d6a6ab56aULL, 0xba0da0ea50505d50ULL,
0x124c8a5745450945ULL, 0xcb18fb38f3f3ebf3ULL, 0x9df060ad3030c030ULL, 0x2b74c3c4efef9befULL,
0xe5c37eda3f3ffc3fULL, 0x921caac755554955ULL, 0x791059dba2a2b2a2ULL, 0x0365c9e9eaea8feaULL,
0x0fecca6a65658965ULL, 0xb9686903babad2baULL, 0x65935e4a2f2fbc2fULL, 0x4ee79d8ec0c027c0ULL,
0xbe81a160dede5fdeULL, 0xe06c38fc1c1c701cULL, 0xbb2ee746fdfdd3fdULL, 0x52649a1f4d4d294dULL,
0xe4e0397692927292ULL, 0x8fbceafa7575c975ULL, 0x301e0c3606061806ULL, 0x249809ae8a8a128aULL,
0xf940794bb2b2f2b2ULL, 0x6359d185e6e6bfe6ULL, 0x70361c7e0e0e380eULL, 0xf8633ee71f1f7c1fULL,
0x37f7c45562629562ULL, 0xeea3b53ad4d477d4ULL, 0x29324d81a8a89aa8ULL, 0xc4f4315296966296ULL,
0x9b3aef62f9f9c3f9ULL, 0x66f697a3c5c533c5ULL, 0x35b14a1025259425ULL, 0xf220b2ab59597959ULL,
0x54ae15d084842a84ULL, 0xb7a7e4c57272d572ULL, 0xd5dd72ec3939e439ULL, 0x5a6198164c4c2d4cULL,
0xca3bbc945e5e655eULL, 0xe785f09f7878fd78ULL, 0xddd870e53838e038ULL, 0x148605988c8c0a8cULL,
0xc6b2bf17d1d163d1ULL, 0x410b57e4a5a5aea5ULL, 0x434dd9a1e2e2afe2ULL, 0x2ff8c24e61619961ULL,
0xf1457b42b3b3f6b3ULL, 0x15a5423421218421ULL, 0x94d625089c9c4a9cULL, 0xf0663cee1e1e781eULL,
0x2252866143431143ULL, 0x76fc93b1c7c73bc7ULL, 0xb32be54ffcfcd7fcULL, 0x2014082404041004ULL,
0xb208a2e351515951ULL, 0xbcc72f2599995e99ULL, 0x4fc4da226d6da96dULL, 0x68391a650d0d340dULL,
0x8335e979fafacffaULL, 0xb684a369dfdf5bdfULL, 0xd79bfca97e7ee57eULL, 0x3db4481924249024ULL,
0xc5d776fe3b3bec3bULL, 0x313d4b9aabab96abULL, 0x3ed181f0cece1fceULL, 0x8855229911114411ULL,
0x0c8903838f8f068fULL, 0x4a6b9c044e4e254eULL, 0xd1517366b7b7e6b7ULL, 0x0b60cbe0ebeb8bebULL,
0xfdcc78c13c3cf03cULL, 0x7cbf1ffd81813e81ULL, 0xd4fe354094946a94ULL, 0xeb0cf31cf7f7fbf7ULL,
0xa1676f18b9b9deb9ULL, 0x985f268b13134c13ULL, 0x7d9c58512c2cb02cULL, 0xd6b8bb05d3d36bd3ULL,
0x6b5cd38ce7e7bbe7ULL, 0x57cbdc396e6ea56eULL, 0x6ef395aac4c437c4ULL, 0x180f061b03030c03ULL,
0x8a13acdc56564556ULL, 0x1a49885e44440d44ULL, 0xdf9efea07f7fe17fULL, 0x21374f88a9a99ea9ULL,
0x4d8254672a2aa82aULL, 0xb16d6b0abbbbd6bbULL, 0x46e29f87c1c123c1ULL, 0xa202a6f153535153ULL,
0xae8ba572dcdc57dcULL, 0x582716530b0b2c0bULL, 0x9cd327019d9d4e9dULL, 0x47c1d82b6c6cad6cULL,
0x95f562a43131c431ULL, 0x87b9e8f37474cd74ULL, 0xe309f115f6f6fff6ULL, 0x0a438c4c46460546ULL,
0x092645a5acac8aacULL, 0x3c970fb589891e89ULL, 0xa04428b414145014ULL, 0x5b42dfbae1e1a3e1ULL,
0xb04e2ca616165816ULL, 0xcdd274f73a3ae83aULL, 0x6fd0d2066969b969ULL, 0x482d124109092409ULL,
0xa7ade0d77070dd70ULL, 0xd954716fb6b6e2b6ULL, 0xceb7bd1ed0d067d0ULL, 0x3b7ec7d6eded93edULL,
0x2edb85e2cccc17ccULL, 0x2a57846842421542ULL, 0xb4c22d2c98985a98ULL, 0x490e55eda4a4aaa4ULL,
0x5d8850752828a028ULL, 0xda31b8865c5c6d5cULL, 0x933fed6bf8f8c7f8ULL, 0x44a411c286862286ULL,
};
static __const mutils_word64 C5[256] =
{
0x18c07830d8181860ULL, 0x2305af462623238cULL, 0xc67ef991b8c6c63fULL, 0xe8136fcdfbe8e887ULL,
0x874ca113cb878726ULL, 0xb8a9626d11b8b8daULL, 0x0108050209010104ULL, 0x4f426e9e0d4f4f21ULL,
0x36adee6c9b3636d8ULL, 0xa6590451ffa6a6a2ULL, 0xd2debdb90cd2d26fULL, 0xf5fb06f70ef5f5f3ULL,
0x79ef80f2967979f9ULL, 0x6f5fcede306f6fa1ULL, 0x91fcef3f6d91917eULL, 0x52aa07a4f8525255ULL,
0x6027fdc04760609dULL, 0xbc89766535bcbccaULL, 0x9baccd2b379b9b56ULL, 0x8e048c018a8e8e02ULL,
0xa371155bd2a3a3b6ULL, 0x0c603c186c0c0c30ULL, 0x7bff8af6847b7bf1ULL, 0x35b5e16a803535d4ULL,
0x1de8693af51d1d74ULL, 0xe05347ddb3e0e0a7ULL, 0xd7f6acb321d7d77bULL, 0xc25eed999cc2c22fULL,
0x2e6d965c432e2eb8ULL, 0x4b627a96294b4b31ULL, 0xfea321e15dfefedfULL, 0x578216aed5575741ULL,
0x15a8412abd151554ULL, 0x779fb6eee87777c1ULL, 0x37a5eb6e923737dcULL, 0xe57b56d79ee5e5b3ULL,
0x9f8cd923139f9f46ULL, 0xf0d317fd23f0f0e7ULL, 0x4a6a7f94204a4a35ULL, 0xda9e95a944dada4fULL,
0x58fa25b0a258587dULL, 0xc906ca8fcfc9c903ULL, 0x29558d527c2929a4ULL, 0x0a5022145a0a0a28ULL,
0xb1e14f7f50b1b1feULL, 0xa0691a5dc9a0a0baULL, 0x6b7fdad6146b6bb1ULL, 0x855cab17d985852eULL,
0xbd8173673cbdbdceULL, 0x5dd234ba8f5d5d69ULL, 0x1080502090101040ULL, 0xf4f303f507f4f4f7ULL,
0xcb16c08bddcbcb0bULL, 0x3eedc67cd33e3ef8ULL, 0x0528110a2d050514ULL, 0x671fe6ce78676781ULL,
0xe47353d597e4e4b7ULL, 0x2725bb4e0227279cULL, 0x4132588273414119ULL, 0x8b2c9d0ba78b8b16ULL,
0xa7510153f6a7a7a6ULL, 0x7dcf94fab27d7de9ULL, 0x95dcfb374995956eULL, 0xd88e9fad56d8d847ULL,
0xfb8b30eb70fbfbcbULL, 0xee2371c1cdeeee9fULL, 0x7cc791f8bb7c7cedULL, 0x6617e3cc71666685ULL,
0xdda68ea77bdddd53ULL, 0x17b84b2eaf17175cULL, 0x4702468e45474701ULL, 0x9e84dc211a9e9e42ULL,
0xca1ec589d4caca0fULL, 0x2d75995a582d2db4ULL, 0xbf9179632ebfbfc6ULL, 0x07381b0e3f07071cULL,
0xad012347acadad8eULL, 0x5aea2fb4b05a5a75ULL, 0x836cb51bef838336ULL, 0x3385ff66b63333ccULL,
0x633ff2c65c636391ULL, 0x02100a0412020208ULL, 0xaa39384993aaaa92ULL, 0x71afa8e2de7171d9ULL,
0xc80ecf8dc6c8c807ULL, 0x19c87d32d1191964ULL, 0x497270923b494939ULL, 0xd9869aaf5fd9d943ULL,
0xf2c31df931f2f2efULL, 0xe34b48dba8e3e3abULL, 0x5be22ab6b95b5b71ULL, 0x8834920dbc88881aULL,
0x9aa4c8293e9a9a52ULL, 0x262dbe4c0b262698ULL, 0x328dfa64bf3232c8ULL, 0xb0e94a7d59b0b0faULL,
0xe91b6acff2e9e983ULL, 0x0f78331e770f0f3cULL, 0xd5e6a6b733d5d573ULL, 0x8074ba1df480803aULL,
0xbe997c6127bebec2ULL, 0xcd26de87ebcdcd13ULL, 0x34bde468893434d0ULL, 0x487a75903248483dULL,
0xffab24e354ffffdbULL, 0x7af78ff48d7a7af5ULL, 0x90f4ea3d6490907aULL, 0x5fc23ebe9d5f5f61ULL,
0x201da0403d202080ULL, 0x6867d5d00f6868bdULL, 0x1ad07234ca1a1a68ULL, 0xae192c41b7aeae82ULL,
0xb4c95e757db4b4eaULL, 0x549a19a8ce54544dULL, 0x93ece53b7f939376ULL, 0x220daa442f222288ULL,
0x6407e9c86364648dULL, 0xf1db12ff2af1f1e3ULL, 0x73bfa2e6cc7373d1ULL, 0x12905a2482121248ULL,
0x403a5d807a40401dULL, 0x0840281048080820ULL, 0xc356e89b95c3c32bULL, 0xec337bc5dfecec97ULL,
0xdb9690ab4ddbdb4bULL, 0xa1611f5fc0a1a1beULL, 0x8d1c8307918d8d0eULL, 0x3df5c97ac83d3df4ULL,
0x97ccf1335b979766ULL, 0x0000000000000000ULL, 0xcf36d483f9cfcf1bULL, 0x2b4587566e2b2bacULL,
0x7697b3ece17676c5ULL, 0x8264b019e6828232ULL, 0xd6fea9b128d6d67fULL, 0x1bd87736c31b1b6cULL,
0xb5c15b7774b5b5eeULL, 0xaf112943beafaf86ULL, 0x6a77dfd41d6a6ab5ULL, 0x50ba0da0ea50505dULL,
0x45124c8a57454509ULL, 0xf3cb18fb38f3f3ebULL, 0x309df060ad3030c0ULL, 0xef2b74c3c4efef9bULL,
0x3fe5c37eda3f3ffcULL, 0x55921caac7555549ULL, 0xa2791059dba2a2b2ULL, 0xea0365c9e9eaea8fULL,
0x650fecca6a656589ULL, 0xbab9686903babad2ULL, 0x2f65935e4a2f2fbcULL, 0xc04ee79d8ec0c027ULL,
0xdebe81a160dede5fULL, 0x1ce06c38fc1c1c70ULL, 0xfdbb2ee746fdfdd3ULL, 0x4d52649a1f4d4d29ULL,
0x92e4e03976929272ULL, 0x758fbceafa7575c9ULL, 0x06301e0c36060618ULL, 0x8a249809ae8a8a12ULL,
0xb2f940794bb2b2f2ULL, 0xe66359d185e6e6bfULL, 0x0e70361c7e0e0e38ULL, 0x1ff8633ee71f1f7cULL,
0x6237f7c455626295ULL, 0xd4eea3b53ad4d477ULL, 0xa829324d81a8a89aULL, 0x96c4f43152969662ULL,
0xf99b3aef62f9f9c3ULL, 0xc566f697a3c5c533ULL, 0x2535b14a10252594ULL, 0x59f220b2ab595979ULL,
0x8454ae15d084842aULL, 0x72b7a7e4c57272d5ULL, 0x39d5dd72ec3939e4ULL, 0x4c5a6198164c4c2dULL,
0x5eca3bbc945e5e65ULL, 0x78e785f09f7878fdULL, 0x38ddd870e53838e0ULL, 0x8c148605988c8c0aULL,
0xd1c6b2bf17d1d163ULL, 0xa5410b57e4a5a5aeULL, 0xe2434dd9a1e2e2afULL, 0x612ff8c24e616199ULL,
0xb3f1457b42b3b3f6ULL, 0x2115a54234212184ULL, 0x9c94d625089c9c4aULL, 0x1ef0663cee1e1e78ULL,
0x4322528661434311ULL, 0xc776fc93b1c7c73bULL, 0xfcb32be54ffcfcd7ULL, 0x0420140824040410ULL,
0x51b208a2e3515159ULL, 0x99bcc72f2599995eULL, 0x6d4fc4da226d6da9ULL, 0x0d68391a650d0d34ULL,
0xfa8335e979fafacfULL, 0xdfb684a369dfdf5bULL, 0x7ed79bfca97e7ee5ULL, 0x243db44819242490ULL,
0x3bc5d776fe3b3becULL, 0xab313d4b9aabab96ULL, 0xce3ed181f0cece1fULL, 0x1188552299111144ULL,
0x8f0c8903838f8f06ULL, 0x4e4a6b9c044e4e25ULL, 0xb7d1517366b7b7e6ULL, 0xeb0b60cbe0ebeb8bULL,
0x3cfdcc78c13c3cf0ULL, 0x817cbf1ffd81813eULL, 0x94d4fe354094946aULL, 0xf7eb0cf31cf7f7fbULL,
0xb9a1676f18b9b9deULL, 0x13985f268b13134cULL, 0x2c7d9c58512c2cb0ULL, 0xd3d6b8bb05d3d36bULL,
0xe76b5cd38ce7e7bbULL, 0x6e57cbdc396e6ea5ULL, 0xc46ef395aac4c437ULL, 0x03180f061b03030cULL,
0x568a13acdc565645ULL, 0x441a49885e44440dULL, 0x7fdf9efea07f7fe1ULL, 0xa921374f88a9a99eULL,
0x2a4d8254672a2aa8ULL, 0xbbb16d6b0abbbbd6ULL, 0xc146e29f87c1c123ULL, 0x53a202a6f1535351ULL,
0xdcae8ba572dcdc57ULL, 0x0b582716530b0b2cULL, 0x9d9cd327019d9d4eULL, 0x6c47c1d82b6c6cadULL,
0x3195f562a43131c4ULL, 0x7487b9e8f37474cdULL, 0xf6e309f115f6f6ffULL, 0x460a438c4c464605ULL,
0xac092645a5acac8aULL, 0x893c970fb589891eULL, 0x14a04428b4141450ULL, 0xe15b42dfbae1e1a3ULL,
0x16b04e2ca6161658ULL, 0x3acdd274f73a3ae8ULL, 0x696fd0d2066969b9ULL, 0x09482d1241090924ULL,
0x70a7ade0d77070ddULL, 0xb6d954716fb6b6e2ULL, 0xd0ceb7bd1ed0d067ULL, 0xed3b7ec7d6eded93ULL,
0xcc2edb85e2cccc17ULL, 0x422a578468424215ULL, 0x98b4c22d2c98985aULL, 0xa4490e55eda4a4aaULL,
0x285d8850752828a0ULL, 0x5cda31b8865c5c6dULL, 0xf8933fed6bf8f8c7ULL, 0x8644a411c2868622ULL,
};
static __const mutils_word64 C6[256] =
{
0x6018c07830d81818ULL, 0x8c2305af46262323ULL, 0x3fc67ef991b8c6c6ULL, 0x87e8136fcdfbe8e8ULL,
0x26874ca113cb8787ULL, 0xdab8a9626d11b8b8ULL, 0x0401080502090101ULL, 0x214f426e9e0d4f4fULL,
0xd836adee6c9b3636ULL, 0xa2a6590451ffa6a6ULL, 0x6fd2debdb90cd2d2ULL, 0xf3f5fb06f70ef5f5ULL,
0xf979ef80f2967979ULL, 0xa16f5fcede306f6fULL, 0x7e91fcef3f6d9191ULL, 0x5552aa07a4f85252ULL,
0x9d6027fdc0476060ULL, 0xcabc89766535bcbcULL, 0x569baccd2b379b9bULL, 0x028e048c018a8e8eULL,
0xb6a371155bd2a3a3ULL, 0x300c603c186c0c0cULL, 0xf17bff8af6847b7bULL, 0xd435b5e16a803535ULL,
0x741de8693af51d1dULL, 0xa7e05347ddb3e0e0ULL, 0x7bd7f6acb321d7d7ULL, 0x2fc25eed999cc2c2ULL,
0xb82e6d965c432e2eULL, 0x314b627a96294b4bULL, 0xdffea321e15dfefeULL, 0x41578216aed55757ULL,
0x5415a8412abd1515ULL, 0xc1779fb6eee87777ULL, 0xdc37a5eb6e923737ULL, 0xb3e57b56d79ee5e5ULL,
0x469f8cd923139f9fULL, 0xe7f0d317fd23f0f0ULL, 0x354a6a7f94204a4aULL, 0x4fda9e95a944dadaULL,
0x7d58fa25b0a25858ULL, 0x03c906ca8fcfc9c9ULL, 0xa429558d527c2929ULL, 0x280a5022145a0a0aULL,
0xfeb1e14f7f50b1b1ULL, 0xbaa0691a5dc9a0a0ULL, 0xb16b7fdad6146b6bULL, 0x2e855cab17d98585ULL,
0xcebd8173673cbdbdULL, 0x695dd234ba8f5d5dULL, 0x4010805020901010ULL, 0xf7f4f303f507f4f4ULL,
0x0bcb16c08bddcbcbULL, 0xf83eedc67cd33e3eULL, 0x140528110a2d0505ULL, 0x81671fe6ce786767ULL,
0xb7e47353d597e4e4ULL, 0x9c2725bb4e022727ULL, 0x1941325882734141ULL, 0x168b2c9d0ba78b8bULL,
0xa6a7510153f6a7a7ULL, 0xe97dcf94fab27d7dULL, 0x6e95dcfb37499595ULL, 0x47d88e9fad56d8d8ULL,
0xcbfb8b30eb70fbfbULL, 0x9fee2371c1cdeeeeULL, 0xed7cc791f8bb7c7cULL, 0x856617e3cc716666ULL,
0x53dda68ea77bddddULL, 0x5c17b84b2eaf1717ULL, 0x014702468e454747ULL, 0x429e84dc211a9e9eULL,
0x0fca1ec589d4cacaULL, 0xb42d75995a582d2dULL, 0xc6bf9179632ebfbfULL, 0x1c07381b0e3f0707ULL,
0x8ead012347acadadULL, 0x755aea2fb4b05a5aULL, 0x36836cb51bef8383ULL, 0xcc3385ff66b63333ULL,
0x91633ff2c65c6363ULL, 0x0802100a04120202ULL, 0x92aa39384993aaaaULL, 0xd971afa8e2de7171ULL,
0x07c80ecf8dc6c8c8ULL, 0x6419c87d32d11919ULL, 0x39497270923b4949ULL, 0x43d9869aaf5fd9d9ULL,
0xeff2c31df931f2f2ULL, 0xabe34b48dba8e3e3ULL, 0x715be22ab6b95b5bULL, 0x1a8834920dbc8888ULL,
0x529aa4c8293e9a9aULL, 0x98262dbe4c0b2626ULL, 0xc8328dfa64bf3232ULL, 0xfab0e94a7d59b0b0ULL,
0x83e91b6acff2e9e9ULL, 0x3c0f78331e770f0fULL, 0x73d5e6a6b733d5d5ULL, 0x3a8074ba1df48080ULL,
0xc2be997c6127bebeULL, 0x13cd26de87ebcdcdULL, 0xd034bde468893434ULL, 0x3d487a7590324848ULL,
0xdbffab24e354ffffULL, 0xf57af78ff48d7a7aULL, 0x7a90f4ea3d649090ULL, 0x615fc23ebe9d5f5fULL,
0x80201da0403d2020ULL, 0xbd6867d5d00f6868ULL, 0x681ad07234ca1a1aULL, 0x82ae192c41b7aeaeULL,
0xeab4c95e757db4b4ULL, 0x4d549a19a8ce5454ULL, 0x7693ece53b7f9393ULL, 0x88220daa442f2222ULL,
0x8d6407e9c8636464ULL, 0xe3f1db12ff2af1f1ULL, 0xd173bfa2e6cc7373ULL, 0x4812905a24821212ULL,
0x1d403a5d807a4040ULL, 0x2008402810480808ULL, 0x2bc356e89b95c3c3ULL, 0x97ec337bc5dfececULL,
0x4bdb9690ab4ddbdbULL, 0xbea1611f5fc0a1a1ULL, 0x0e8d1c8307918d8dULL, 0xf43df5c97ac83d3dULL,
0x6697ccf1335b9797ULL, 0x0000000000000000ULL, 0x1bcf36d483f9cfcfULL, 0xac2b4587566e2b2bULL,
0xc57697b3ece17676ULL, 0x328264b019e68282ULL, 0x7fd6fea9b128d6d6ULL, 0x6c1bd87736c31b1bULL,
0xeeb5c15b7774b5b5ULL, 0x86af112943beafafULL, 0xb56a77dfd41d6a6aULL, 0x5d50ba0da0ea5050ULL,
0x0945124c8a574545ULL, 0xebf3cb18fb38f3f3ULL, 0xc0309df060ad3030ULL, 0x9bef2b74c3c4efefULL,
0xfc3fe5c37eda3f3fULL, 0x4955921caac75555ULL, 0xb2a2791059dba2a2ULL, 0x8fea0365c9e9eaeaULL,
0x89650fecca6a6565ULL, 0xd2bab9686903babaULL, 0xbc2f65935e4a2f2fULL, 0x27c04ee79d8ec0c0ULL,
0x5fdebe81a160dedeULL, 0x701ce06c38fc1c1cULL, 0xd3fdbb2ee746fdfdULL, 0x294d52649a1f4d4dULL,
0x7292e4e039769292ULL, 0xc9758fbceafa7575ULL, 0x1806301e0c360606ULL, 0x128a249809ae8a8aULL,
0xf2b2f940794bb2b2ULL, 0xbfe66359d185e6e6ULL, 0x380e70361c7e0e0eULL, 0x7c1ff8633ee71f1fULL,
0x956237f7c4556262ULL, 0x77d4eea3b53ad4d4ULL, 0x9aa829324d81a8a8ULL, 0x6296c4f431529696ULL,
0xc3f99b3aef62f9f9ULL, 0x33c566f697a3c5c5ULL, 0x942535b14a102525ULL, 0x7959f220b2ab5959ULL,
0x2a8454ae15d08484ULL, 0xd572b7a7e4c57272ULL, 0xe439d5dd72ec3939ULL, 0x2d4c5a6198164c4cULL,
0x655eca3bbc945e5eULL, 0xfd78e785f09f7878ULL, 0xe038ddd870e53838ULL, 0x0a8c148605988c8cULL,
0x63d1c6b2bf17d1d1ULL, 0xaea5410b57e4a5a5ULL, 0xafe2434dd9a1e2e2ULL, 0x99612ff8c24e6161ULL,
0xf6b3f1457b42b3b3ULL, 0x842115a542342121ULL, 0x4a9c94d625089c9cULL, 0x781ef0663cee1e1eULL,
0x1143225286614343ULL, 0x3bc776fc93b1c7c7ULL, 0xd7fcb32be54ffcfcULL, 0x1004201408240404ULL,
0x5951b208a2e35151ULL, 0x5e99bcc72f259999ULL, 0xa96d4fc4da226d6dULL, 0x340d68391a650d0dULL,
0xcffa8335e979fafaULL, 0x5bdfb684a369dfdfULL, 0xe57ed79bfca97e7eULL, 0x90243db448192424ULL,
0xec3bc5d776fe3b3bULL, 0x96ab313d4b9aababULL, 0x1fce3ed181f0ceceULL, 0x4411885522991111ULL,
0x068f0c8903838f8fULL, 0x254e4a6b9c044e4eULL, 0xe6b7d1517366b7b7ULL, 0x8beb0b60cbe0ebebULL,
0xf03cfdcc78c13c3cULL, 0x3e817cbf1ffd8181ULL, 0x6a94d4fe35409494ULL, 0xfbf7eb0cf31cf7f7ULL,
0xdeb9a1676f18b9b9ULL, 0x4c13985f268b1313ULL, 0xb02c7d9c58512c2cULL, 0x6bd3d6b8bb05d3d3ULL,
0xbbe76b5cd38ce7e7ULL, 0xa56e57cbdc396e6eULL, 0x37c46ef395aac4c4ULL, 0x0c03180f061b0303ULL,
0x45568a13acdc5656ULL, 0x0d441a49885e4444ULL, 0xe17fdf9efea07f7fULL, 0x9ea921374f88a9a9ULL,
0xa82a4d8254672a2aULL, 0xd6bbb16d6b0abbbbULL, 0x23c146e29f87c1c1ULL, 0x5153a202a6f15353ULL,
0x57dcae8ba572dcdcULL, 0x2c0b582716530b0bULL, 0x4e9d9cd327019d9dULL, 0xad6c47c1d82b6c6cULL,
0xc43195f562a43131ULL, 0xcd7487b9e8f37474ULL, 0xfff6e309f115f6f6ULL, 0x05460a438c4c4646ULL,
0x8aac092645a5acacULL, 0x1e893c970fb58989ULL, 0x5014a04428b41414ULL, 0xa3e15b42dfbae1e1ULL,
0x5816b04e2ca61616ULL, 0xe83acdd274f73a3aULL, 0xb9696fd0d2066969ULL, 0x2409482d12410909ULL,
0xdd70a7ade0d77070ULL, 0xe2b6d954716fb6b6ULL, 0x67d0ceb7bd1ed0d0ULL, 0x93ed3b7ec7d6ededULL,
0x17cc2edb85e2ccccULL, 0x15422a5784684242ULL, 0x5a98b4c22d2c9898ULL, 0xaaa4490e55eda4a4ULL,
0xa0285d8850752828ULL, 0x6d5cda31b8865c5cULL, 0xc7f8933fed6bf8f8ULL, 0x228644a411c28686ULL,
};
static __const mutils_word64 C7[256] =
{
0x186018c07830d818ULL, 0x238c2305af462623ULL, 0xc63fc67ef991b8c6ULL, 0xe887e8136fcdfbe8ULL,
0x8726874ca113cb87ULL, 0xb8dab8a9626d11b8ULL, 0x0104010805020901ULL, 0x4f214f426e9e0d4fULL,
0x36d836adee6c9b36ULL, 0xa6a2a6590451ffa6ULL, 0xd26fd2debdb90cd2ULL, 0xf5f3f5fb06f70ef5ULL,
0x79f979ef80f29679ULL, 0x6fa16f5fcede306fULL, 0x917e91fcef3f6d91ULL, 0x525552aa07a4f852ULL,
0x609d6027fdc04760ULL, 0xbccabc89766535bcULL, 0x9b569baccd2b379bULL, 0x8e028e048c018a8eULL,
0xa3b6a371155bd2a3ULL, 0x0c300c603c186c0cULL, 0x7bf17bff8af6847bULL, 0x35d435b5e16a8035ULL,
0x1d741de8693af51dULL, 0xe0a7e05347ddb3e0ULL, 0xd77bd7f6acb321d7ULL, 0xc22fc25eed999cc2ULL,
0x2eb82e6d965c432eULL, 0x4b314b627a96294bULL, 0xfedffea321e15dfeULL, 0x5741578216aed557ULL,
0x155415a8412abd15ULL, 0x77c1779fb6eee877ULL, 0x37dc37a5eb6e9237ULL, 0xe5b3e57b56d79ee5ULL,
0x9f469f8cd923139fULL, 0xf0e7f0d317fd23f0ULL, 0x4a354a6a7f94204aULL, 0xda4fda9e95a944daULL,
0x587d58fa25b0a258ULL, 0xc903c906ca8fcfc9ULL, 0x29a429558d527c29ULL, 0x0a280a5022145a0aULL,
0xb1feb1e14f7f50b1ULL, 0xa0baa0691a5dc9a0ULL, 0x6bb16b7fdad6146bULL, 0x852e855cab17d985ULL,
0xbdcebd8173673cbdULL, 0x5d695dd234ba8f5dULL, 0x1040108050209010ULL, 0xf4f7f4f303f507f4ULL,
0xcb0bcb16c08bddcbULL, 0x3ef83eedc67cd33eULL, 0x05140528110a2d05ULL, 0x6781671fe6ce7867ULL,
0xe4b7e47353d597e4ULL, 0x279c2725bb4e0227ULL, 0x4119413258827341ULL, 0x8b168b2c9d0ba78bULL,
0xa7a6a7510153f6a7ULL, 0x7de97dcf94fab27dULL, 0x956e95dcfb374995ULL, 0xd847d88e9fad56d8ULL,
0xfbcbfb8b30eb70fbULL, 0xee9fee2371c1cdeeULL, 0x7ced7cc791f8bb7cULL, 0x66856617e3cc7166ULL,
0xdd53dda68ea77bddULL, 0x175c17b84b2eaf17ULL, 0x47014702468e4547ULL, 0x9e429e84dc211a9eULL,
0xca0fca1ec589d4caULL, 0x2db42d75995a582dULL, 0xbfc6bf9179632ebfULL, 0x071c07381b0e3f07ULL,
0xad8ead012347acadULL, 0x5a755aea2fb4b05aULL, 0x8336836cb51bef83ULL, 0x33cc3385ff66b633ULL,
0x6391633ff2c65c63ULL, 0x020802100a041202ULL, 0xaa92aa39384993aaULL, 0x71d971afa8e2de71ULL,
0xc807c80ecf8dc6c8ULL, 0x196419c87d32d119ULL, 0x4939497270923b49ULL, 0xd943d9869aaf5fd9ULL,
0xf2eff2c31df931f2ULL, 0xe3abe34b48dba8e3ULL, 0x5b715be22ab6b95bULL, 0x881a8834920dbc88ULL,
0x9a529aa4c8293e9aULL, 0x2698262dbe4c0b26ULL, 0x32c8328dfa64bf32ULL, 0xb0fab0e94a7d59b0ULL,
0xe983e91b6acff2e9ULL, 0x0f3c0f78331e770fULL, 0xd573d5e6a6b733d5ULL, 0x803a8074ba1df480ULL,
0xbec2be997c6127beULL, 0xcd13cd26de87ebcdULL, 0x34d034bde4688934ULL, 0x483d487a75903248ULL,
0xffdbffab24e354ffULL, 0x7af57af78ff48d7aULL, 0x907a90f4ea3d6490ULL, 0x5f615fc23ebe9d5fULL,
0x2080201da0403d20ULL, 0x68bd6867d5d00f68ULL, 0x1a681ad07234ca1aULL, 0xae82ae192c41b7aeULL,
0xb4eab4c95e757db4ULL, 0x544d549a19a8ce54ULL, 0x937693ece53b7f93ULL, 0x2288220daa442f22ULL,
0x648d6407e9c86364ULL, 0xf1e3f1db12ff2af1ULL, 0x73d173bfa2e6cc73ULL, 0x124812905a248212ULL,
0x401d403a5d807a40ULL, 0x0820084028104808ULL, 0xc32bc356e89b95c3ULL, 0xec97ec337bc5dfecULL,
0xdb4bdb9690ab4ddbULL, 0xa1bea1611f5fc0a1ULL, 0x8d0e8d1c8307918dULL, 0x3df43df5c97ac83dULL,
0x976697ccf1335b97ULL, 0x0000000000000000ULL, 0xcf1bcf36d483f9cfULL, 0x2bac2b4587566e2bULL,
0x76c57697b3ece176ULL, 0x82328264b019e682ULL, 0xd67fd6fea9b128d6ULL, 0x1b6c1bd87736c31bULL,
0xb5eeb5c15b7774b5ULL, 0xaf86af112943beafULL, 0x6ab56a77dfd41d6aULL, 0x505d50ba0da0ea50ULL,
0x450945124c8a5745ULL, 0xf3ebf3cb18fb38f3ULL, 0x30c0309df060ad30ULL, 0xef9bef2b74c3c4efULL,
0x3ffc3fe5c37eda3fULL, 0x554955921caac755ULL, 0xa2b2a2791059dba2ULL, 0xea8fea0365c9e9eaULL,
0x6589650fecca6a65ULL, 0xbad2bab9686903baULL, 0x2fbc2f65935e4a2fULL, 0xc027c04ee79d8ec0ULL,
0xde5fdebe81a160deULL, 0x1c701ce06c38fc1cULL, 0xfdd3fdbb2ee746fdULL, 0x4d294d52649a1f4dULL,
0x927292e4e0397692ULL, 0x75c9758fbceafa75ULL, 0x061806301e0c3606ULL, 0x8a128a249809ae8aULL,
0xb2f2b2f940794bb2ULL, 0xe6bfe66359d185e6ULL, 0x0e380e70361c7e0eULL, 0x1f7c1ff8633ee71fULL,
0x62956237f7c45562ULL, 0xd477d4eea3b53ad4ULL, 0xa89aa829324d81a8ULL, 0x966296c4f4315296ULL,
0xf9c3f99b3aef62f9ULL, 0xc533c566f697a3c5ULL, 0x25942535b14a1025ULL, 0x597959f220b2ab59ULL,
0x842a8454ae15d084ULL, 0x72d572b7a7e4c572ULL, 0x39e439d5dd72ec39ULL, 0x4c2d4c5a6198164cULL,
0x5e655eca3bbc945eULL, 0x78fd78e785f09f78ULL, 0x38e038ddd870e538ULL, 0x8c0a8c148605988cULL,
0xd163d1c6b2bf17d1ULL, 0xa5aea5410b57e4a5ULL, 0xe2afe2434dd9a1e2ULL, 0x6199612ff8c24e61ULL,
0xb3f6b3f1457b42b3ULL, 0x21842115a5423421ULL, 0x9c4a9c94d625089cULL, 0x1e781ef0663cee1eULL,
0x4311432252866143ULL, 0xc73bc776fc93b1c7ULL, 0xfcd7fcb32be54ffcULL, 0x0410042014082404ULL,
0x515951b208a2e351ULL, 0x995e99bcc72f2599ULL, 0x6da96d4fc4da226dULL, 0x0d340d68391a650dULL,
0xfacffa8335e979faULL, 0xdf5bdfb684a369dfULL, 0x7ee57ed79bfca97eULL, 0x2490243db4481924ULL,
0x3bec3bc5d776fe3bULL, 0xab96ab313d4b9aabULL, 0xce1fce3ed181f0ceULL, 0x1144118855229911ULL,
0x8f068f0c8903838fULL, 0x4e254e4a6b9c044eULL, 0xb7e6b7d1517366b7ULL, 0xeb8beb0b60cbe0ebULL,
0x3cf03cfdcc78c13cULL, 0x813e817cbf1ffd81ULL, 0x946a94d4fe354094ULL, 0xf7fbf7eb0cf31cf7ULL,
0xb9deb9a1676f18b9ULL, 0x134c13985f268b13ULL, 0x2cb02c7d9c58512cULL, 0xd36bd3d6b8bb05d3ULL,
0xe7bbe76b5cd38ce7ULL, 0x6ea56e57cbdc396eULL, 0xc437c46ef395aac4ULL, 0x030c03180f061b03ULL,
0x5645568a13acdc56ULL, 0x440d441a49885e44ULL, 0x7fe17fdf9efea07fULL, 0xa99ea921374f88a9ULL,
0x2aa82a4d8254672aULL, 0xbbd6bbb16d6b0abbULL, 0xc123c146e29f87c1ULL, 0x535153a202a6f153ULL,
0xdc57dcae8ba572dcULL, 0x0b2c0b582716530bULL, 0x9d4e9d9cd327019dULL, 0x6cad6c47c1d82b6cULL,
0x31c43195f562a431ULL, 0x74cd7487b9e8f374ULL, 0xf6fff6e309f115f6ULL, 0x4605460a438c4c46ULL,
0xac8aac092645a5acULL, 0x891e893c970fb589ULL, 0x145014a04428b414ULL, 0xe1a3e15b42dfbae1ULL,
0x165816b04e2ca616ULL, 0x3ae83acdd274f73aULL, 0x69b9696fd0d20669ULL, 0x092409482d124109ULL,
0x70dd70a7ade0d770ULL, 0xb6e2b6d954716fb6ULL, 0xd067d0ceb7bd1ed0ULL, 0xed93ed3b7ec7d6edULL,
0xcc17cc2edb85e2ccULL, 0x4215422a57846842ULL, 0x985a98b4c22d2c98ULL, 0xa4aaa4490e55eda4ULL,
0x28a0285d88507528ULL, 0x5c6d5cda31b8865cULL, 0xf8c7f8933fed6bf8ULL, 0x86228644a411c286ULL,
};
static __const mutils_word64 rc[R + 1] =
{
0x0000000000000000ULL,
0x1823c6e887b8014fULL,
0x36a6d2f5796f9152ULL,
0x60bc9b8ea30c7b35ULL,
0x1de0d7c22e4bfe57ULL,
0x157737e59ff04adaULL,
0x58c9290ab1a06b85ULL,
0xbd5d10f4cb3e0567ULL,
0xe427418ba77d95d8ULL,
0xfbee7c66dd17479eULL,
0xca2dbf07ad5a8333ULL,
};
/**
* The core Whirlpool transform.
*/
static void processBuffer(struct whirlpool_ctx * __const ctx)
{
mutils_word32 i;
mutils_word32 r;
mutils_word64 K[8]; /* the round key */
mutils_word64 block[8]; /* mu(buffer) */
mutils_word64 state[8]; /* the cipher state */
mutils_word64 L[8];
mutils_word8 *buffer = ctx->buffer;
/*
* map the buffer to a block:
*/
for (i = 0; i < 8; i++, buffer += 8)
{
block[i] =
(((mutils_word64)buffer[0] ) << 56) ^
(((mutils_word64)buffer[1] & 0xffL) << 48) ^
(((mutils_word64)buffer[2] & 0xffL) << 40) ^
(((mutils_word64)buffer[3] & 0xffL) << 32) ^
(((mutils_word64)buffer[4] & 0xffL) << 24) ^
(((mutils_word64)buffer[5] & 0xffL) << 16) ^
(((mutils_word64)buffer[6] & 0xffL) << 8) ^
(((mutils_word64)buffer[7] & 0xffL) );
}
/*
* compute and apply K^0 to the cipher state:
*/
state[0] = block[0] ^ (K[0] = ctx->hash[0]);
state[1] = block[1] ^ (K[1] = ctx->hash[1]);
state[2] = block[2] ^ (K[2] = ctx->hash[2]);
state[3] = block[3] ^ (K[3] = ctx->hash[3]);
state[4] = block[4] ^ (K[4] = ctx->hash[4]);
state[5] = block[5] ^ (K[5] = ctx->hash[5]);
state[6] = block[6] ^ (K[6] = ctx->hash[6]);
state[7] = block[7] ^ (K[7] = ctx->hash[7]);
/*
* iterate over all rounds:
*/
for (r = 1; r <= R; r++)
{
/*
* compute K^r from K^{r-1}:
*/
L[0] =
C0[(int)(K[0] >> 56) ] ^
C1[(int)(K[7] >> 48) & 0xff] ^
C2[(int)(K[6] >> 40) & 0xff] ^
C3[(int)(K[5] >> 32) & 0xff] ^
C4[(int)(K[4] >> 24) & 0xff] ^
C5[(int)(K[3] >> 16) & 0xff] ^
C6[(int)(K[2] >> 8) & 0xff] ^
C7[(int)(K[1] ) & 0xff] ^
rc[r];
L[1] =
C0[(int)(K[1] >> 56) ] ^
C1[(int)(K[0] >> 48) & 0xff] ^
C2[(int)(K[7] >> 40) & 0xff] ^
C3[(int)(K[6] >> 32) & 0xff] ^
C4[(int)(K[5] >> 24) & 0xff] ^
C5[(int)(K[4] >> 16) & 0xff] ^
C6[(int)(K[3] >> 8) & 0xff] ^
C7[(int)(K[2] ) & 0xff];
L[2] =
C0[(int)(K[2] >> 56) ] ^
C1[(int)(K[1] >> 48) & 0xff] ^
C2[(int)(K[0] >> 40) & 0xff] ^
C3[(int)(K[7] >> 32) & 0xff] ^
C4[(int)(K[6] >> 24) & 0xff] ^
C5[(int)(K[5] >> 16) & 0xff] ^
C6[(int)(K[4] >> 8) & 0xff] ^
C7[(int)(K[3] ) & 0xff];
L[3] =
C0[(int)(K[3] >> 56) ] ^
C1[(int)(K[2] >> 48) & 0xff] ^
C2[(int)(K[1] >> 40) & 0xff] ^
C3[(int)(K[0] >> 32) & 0xff] ^
C4[(int)(K[7] >> 24) & 0xff] ^
C5[(int)(K[6] >> 16) & 0xff] ^
C6[(int)(K[5] >> 8) & 0xff] ^
C7[(int)(K[4] ) & 0xff];
L[4] =
C0[(int)(K[4] >> 56) ] ^
C1[(int)(K[3] >> 48) & 0xff] ^
C2[(int)(K[2] >> 40) & 0xff] ^
C3[(int)(K[1] >> 32) & 0xff] ^
C4[(int)(K[0] >> 24) & 0xff] ^
C5[(int)(K[7] >> 16) & 0xff] ^
C6[(int)(K[6] >> 8) & 0xff] ^
C7[(int)(K[5] ) & 0xff];
L[5] =
C0[(int)(K[5] >> 56) ] ^
C1[(int)(K[4] >> 48) & 0xff] ^
C2[(int)(K[3] >> 40) & 0xff] ^
C3[(int)(K[2] >> 32) & 0xff] ^
C4[(int)(K[1] >> 24) & 0xff] ^
C5[(int)(K[0] >> 16) & 0xff] ^
C6[(int)(K[7] >> 8) & 0xff] ^
C7[(int)(K[6] ) & 0xff];
L[6] =
C0[(int)(K[6] >> 56) ] ^
C1[(int)(K[5] >> 48) & 0xff] ^
C2[(int)(K[4] >> 40) & 0xff] ^
C3[(int)(K[3] >> 32) & 0xff] ^
C4[(int)(K[2] >> 24) & 0xff] ^
C5[(int)(K[1] >> 16) & 0xff] ^
C6[(int)(K[0] >> 8) & 0xff] ^
C7[(int)(K[7] ) & 0xff];
L[7] =
C0[(int)(K[7] >> 56) ] ^
C1[(int)(K[6] >> 48) & 0xff] ^
C2[(int)(K[5] >> 40) & 0xff] ^
C3[(int)(K[4] >> 32) & 0xff] ^
C4[(int)(K[3] >> 24) & 0xff] ^
C5[(int)(K[2] >> 16) & 0xff] ^
C6[(int)(K[1] >> 8) & 0xff] ^
C7[(int)(K[0] ) & 0xff];
K[0] = L[0];
K[1] = L[1];
K[2] = L[2];
K[3] = L[3];
K[4] = L[4];
K[5] = L[5];
K[6] = L[6];
K[7] = L[7];
/*
* apply the r-th round transformation:
*/
L[0] =
C0[(int)(state[0] >> 56) ] ^
C1[(int)(state[7] >> 48) & 0xff] ^
C2[(int)(state[6] >> 40) & 0xff] ^
C3[(int)(state[5] >> 32) & 0xff] ^
C4[(int)(state[4] >> 24) & 0xff] ^
C5[(int)(state[3] >> 16) & 0xff] ^
C6[(int)(state[2] >> 8) & 0xff] ^
C7[(int)(state[1] ) & 0xff] ^
K[0];
L[1] =
C0[(int)(state[1] >> 56) ] ^
C1[(int)(state[0] >> 48) & 0xff] ^
C2[(int)(state[7] >> 40) & 0xff] ^
C3[(int)(state[6] >> 32) & 0xff] ^
C4[(int)(state[5] >> 24) & 0xff] ^
C5[(int)(state[4] >> 16) & 0xff] ^
C6[(int)(state[3] >> 8) & 0xff] ^
C7[(int)(state[2] ) & 0xff] ^
K[1];
L[2] =
C0[(int)(state[2] >> 56) ] ^
C1[(int)(state[1] >> 48) & 0xff] ^
C2[(int)(state[0] >> 40) & 0xff] ^
C3[(int)(state[7] >> 32) & 0xff] ^
C4[(int)(state[6] >> 24) & 0xff] ^
C5[(int)(state[5] >> 16) & 0xff] ^
C6[(int)(state[4] >> 8) & 0xff] ^
C7[(int)(state[3] ) & 0xff] ^
K[2];
L[3] =
C0[(int)(state[3] >> 56) ] ^
C1[(int)(state[2] >> 48) & 0xff] ^
C2[(int)(state[1] >> 40) & 0xff] ^
C3[(int)(state[0] >> 32) & 0xff] ^
C4[(int)(state[7] >> 24) & 0xff] ^
C5[(int)(state[6] >> 16) & 0xff] ^
C6[(int)(state[5] >> 8) & 0xff] ^
C7[(int)(state[4] ) & 0xff] ^
K[3];
L[4] =
C0[(int)(state[4] >> 56) ] ^
C1[(int)(state[3] >> 48) & 0xff] ^
C2[(int)(state[2] >> 40) & 0xff] ^
C3[(int)(state[1] >> 32) & 0xff] ^
C4[(int)(state[0] >> 24) & 0xff] ^
C5[(int)(state[7] >> 16) & 0xff] ^
C6[(int)(state[6] >> 8) & 0xff] ^
C7[(int)(state[5] ) & 0xff] ^
K[4];
L[5] =
C0[(int)(state[5] >> 56) ] ^
C1[(int)(state[4] >> 48) & 0xff] ^
C2[(int)(state[3] >> 40) & 0xff] ^
C3[(int)(state[2] >> 32) & 0xff] ^
C4[(int)(state[1] >> 24) & 0xff] ^
C5[(int)(state[0] >> 16) & 0xff] ^
C6[(int)(state[7] >> 8) & 0xff] ^
C7[(int)(state[6] ) & 0xff] ^
K[5];
L[6] =
C0[(int)(state[6] >> 56) ] ^
C1[(int)(state[5] >> 48) & 0xff] ^
C2[(int)(state[4] >> 40) & 0xff] ^
C3[(int)(state[3] >> 32) & 0xff] ^
C4[(int)(state[2] >> 24) & 0xff] ^
C5[(int)(state[1] >> 16) & 0xff] ^
C6[(int)(state[0] >> 8) & 0xff] ^
C7[(int)(state[7] ) & 0xff] ^
K[6];
L[7] =
C0[(int)(state[7] >> 56) ] ^
C1[(int)(state[6] >> 48) & 0xff] ^
C2[(int)(state[5] >> 40) & 0xff] ^
C3[(int)(state[4] >> 32) & 0xff] ^
C4[(int)(state[3] >> 24) & 0xff] ^
C5[(int)(state[2] >> 16) & 0xff] ^
C6[(int)(state[1] >> 8) & 0xff] ^
C7[(int)(state[0] ) & 0xff] ^
K[7];
state[0] = L[0];
state[1] = L[1];
state[2] = L[2];
state[3] = L[3];
state[4] = L[4];
state[5] = L[5];
state[6] = L[6];
state[7] = L[7];
}
/*
* apply the Miyaguchi-Preneel compression function:
*/
ctx->hash[0] ^= state[0] ^ block[0];
ctx->hash[1] ^= state[1] ^ block[1];
ctx->hash[2] ^= state[2] ^ block[2];
ctx->hash[3] ^= state[3] ^ block[3];
ctx->hash[4] ^= state[4] ^ block[4];
ctx->hash[5] ^= state[5] ^ block[5];
ctx->hash[6] ^= state[6] ^ block[6];
ctx->hash[7] ^= state[7] ^ block[7];
}
/**
* Initialize the hashing state.
*/
void whirlpool_init(struct whirlpool_ctx *ctx)
{
mutils_word32 i;
ctx->hashlen[0] = ctx->hashlen[1] =
ctx->hashlen[2] = ctx->hashlen[3] = 0;
ctx->index = 0;
for (i = 0; i < WHIRLPOOL_DIGEST_SIZE/8; i++)
ctx->hash[i] = 0;
}
/**
* Increment the block counter by step
*/
#define INCCTR(cnt,step) do { \
if ((cnt[3] += (step)) < (step)) \
if (!(++cnt[2])) \
if (!(++cnt[1])) \
if (!(++cnt[0])); \
} while(0);
void
whirlpool_update(struct whirlpool_ctx *ctx, __const mutils_word8 *data, mutils_word32 length)
{
if (ctx->index) { /* Try to fill partial block */
mutils_word32 left = WHIRLPOOL_DATA_SIZE - ctx->index;
if (length < left) {
mutils_memcpy(ctx->buffer + ctx->index, data, length);
ctx->index += length;
return; /* Finished */
} else {
mutils_memcpy(ctx->buffer + ctx->index, data, left);
processBuffer(ctx);
INCCTR(ctx->hashlen, 512);
data += left;
length -= left;
}
}
while (length >= WHIRLPOOL_DATA_SIZE) {
mutils_memcpy(ctx->buffer, data, WHIRLPOOL_DATA_SIZE);
processBuffer(ctx);
INCCTR(ctx->hashlen, 512);
data += WHIRLPOOL_DATA_SIZE;
length -= WHIRLPOOL_DATA_SIZE;
}
mutils_memcpy(ctx->buffer, data, length);
ctx->index = length;
}
/* Final wrapup - pad to WHIRLPOOL_DATA_SIZE-byte boundary with the bit pattern
1 0* (256-bit count of bits processed, MSB-first) */
void whirlpool_final(struct whirlpool_ctx *ctx)
{
mutils_word32 i;
mutils_word8 * buf;
mutils_word64 t;
i = ctx->index;
/* Set the first char of padding to 0x80. This is safe since there is
always at least one byte free */
/* assert(i < WHIRLPOOL_DATA_SIZE); */
ctx->buffer[i++] = 0x80;
if (i > WHIRLPOOL_DATA_SIZE - 256/8)
{
mutils_memset(ctx->buffer + i, 0, WHIRLPOOL_DATA_SIZE - i);
processBuffer(ctx);
i = 0;
}
mutils_memset(ctx->buffer + i, 0, WHIRLPOOL_DATA_SIZE - 256/8 - i);
/*
* Terminate with length field
*/
INCCTR(ctx->hashlen, 8 * ctx->index);
buf = ctx->buffer + (WHIRLPOOL_DATA_SIZE - 256/8);
for (i = 0; i < 4; i++)
{
t = ctx->hashlen[i];
*buf++ = (t >> 56) & 0xff;
*buf++ = (t >> 48) & 0xff;
*buf++ = (t >> 40) & 0xff;
*buf++ = (t >> 32) & 0xff;
*buf++ = (t >> 24) & 0xff;
*buf++ = (t >> 16) & 0xff;
*buf++ = (t >> 8) & 0xff;
*buf++ = t & 0xff;
}
processBuffer(ctx);
}
/**
* Get the hash value from the hashing state.
*/
void whirlpool_digest(__const struct whirlpool_ctx * ctx,
mutils_word8 * digest)
{
mutils_word32 i;
/*
* return the completed message digest:
*/
for (i = 0; i < WHIRLPOOL_DIGEST_SIZE/8; i++) {
*digest++ = (mutils_word8)(ctx->hash[i] >> 56);
*digest++ = (mutils_word8)(ctx->hash[i] >> 48);
*digest++ = (mutils_word8)(ctx->hash[i] >> 40);
*digest++ = (mutils_word8)(ctx->hash[i] >> 32);
*digest++ = (mutils_word8)(ctx->hash[i] >> 24);
*digest++ = (mutils_word8)(ctx->hash[i] >> 16);
*digest++ = (mutils_word8)(ctx->hash[i] >> 8);
*digest++ = (mutils_word8)(ctx->hash[i] );
}
}
#endif /* ENABLE_WHIRLPOOL */