Adding upstream version 1.9.14.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
ddf4b25f8f
commit
49fcf7364a
88 changed files with 62468 additions and 0 deletions
22
ent/Makefile.am
Normal file
22
ent/Makefile.am
Normal file
|
@ -0,0 +1,22 @@
|
|||
## Process this file with automake to produce Makefile.in.
|
||||
|
||||
if ENABLE_ENT_TEST
|
||||
check_PROGRAMS = entest
|
||||
endif
|
||||
|
||||
AM_CFLAGS=-Wall
|
||||
|
||||
entest_LDADD = -lm
|
||||
|
||||
entest_SOURCES = entest.c iso8859.c randtest.c chisq.c iso8859.h randtest.h
|
||||
|
||||
CLEANFILES = sample
|
||||
|
||||
MAINTAINERCLEANFILES = Makefile.in
|
||||
|
||||
if ENABLE_ENT_TEST
|
||||
check-local:
|
||||
./entest -t ${srcdir}/entitle.gif
|
||||
../src/haveged -n 16384k -v 1 $*
|
||||
./entest -vf sample
|
||||
endif
|
577
ent/Makefile.in
Normal file
577
ent/Makefile.in
Normal file
|
@ -0,0 +1,577 @@
|
|||
# Makefile.in generated by automake 1.16.1 from Makefile.am.
|
||||
# @configure_input@
|
||||
|
||||
# Copyright (C) 1994-2018 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@
|
||||
VPATH = @srcdir@
|
||||
am__is_gnu_make = { \
|
||||
if test -z '$(MAKELEVEL)'; then \
|
||||
false; \
|
||||
elif test -n '$(MAKE_HOST)'; then \
|
||||
true; \
|
||||
elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
|
||||
true; \
|
||||
else \
|
||||
false; \
|
||||
fi; \
|
||||
}
|
||||
am__make_running_with_option = \
|
||||
case $${target_option-} in \
|
||||
?) ;; \
|
||||
*) echo "am__make_running_with_option: internal error: invalid" \
|
||||
"target option '$${target_option-}' specified" >&2; \
|
||||
exit 1;; \
|
||||
esac; \
|
||||
has_opt=no; \
|
||||
sane_makeflags=$$MAKEFLAGS; \
|
||||
if $(am__is_gnu_make); then \
|
||||
sane_makeflags=$$MFLAGS; \
|
||||
else \
|
||||
case $$MAKEFLAGS in \
|
||||
*\\[\ \ ]*) \
|
||||
bs=\\; \
|
||||
sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
|
||||
| sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
|
||||
esac; \
|
||||
fi; \
|
||||
skip_next=no; \
|
||||
strip_trailopt () \
|
||||
{ \
|
||||
flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
|
||||
}; \
|
||||
for flg in $$sane_makeflags; do \
|
||||
test $$skip_next = yes && { skip_next=no; continue; }; \
|
||||
case $$flg in \
|
||||
*=*|--*) continue;; \
|
||||
-*I) strip_trailopt 'I'; skip_next=yes;; \
|
||||
-*I?*) strip_trailopt 'I';; \
|
||||
-*O) strip_trailopt 'O'; skip_next=yes;; \
|
||||
-*O?*) strip_trailopt 'O';; \
|
||||
-*l) strip_trailopt 'l'; skip_next=yes;; \
|
||||
-*l?*) strip_trailopt 'l';; \
|
||||
-[dEDm]) skip_next=yes;; \
|
||||
-[JT]) skip_next=yes;; \
|
||||
esac; \
|
||||
case $$flg in \
|
||||
*$$target_option*) has_opt=yes; break;; \
|
||||
esac; \
|
||||
done; \
|
||||
test $$has_opt = yes
|
||||
am__make_dryrun = (target_option=n; $(am__make_running_with_option))
|
||||
am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
|
||||
pkgdatadir = $(datadir)/@PACKAGE@
|
||||
pkgincludedir = $(includedir)/@PACKAGE@
|
||||
pkglibdir = $(libdir)/@PACKAGE@
|
||||
pkglibexecdir = $(libexecdir)/@PACKAGE@
|
||||
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
|
||||
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@
|
||||
@ENABLE_ENT_TEST_TRUE@check_PROGRAMS = entest$(EXEEXT)
|
||||
subdir = ent
|
||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
am__aclocal_m4_deps = $(top_srcdir)/configure.ac
|
||||
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
|
||||
$(ACLOCAL_M4)
|
||||
DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
|
||||
mkinstalldirs = $(install_sh) -d
|
||||
CONFIG_HEADER = $(top_builddir)/config.h
|
||||
CONFIG_CLEAN_FILES =
|
||||
CONFIG_CLEAN_VPATH_FILES =
|
||||
am_entest_OBJECTS = entest.$(OBJEXT) iso8859.$(OBJEXT) \
|
||||
randtest.$(OBJEXT) chisq.$(OBJEXT)
|
||||
entest_OBJECTS = $(am_entest_OBJECTS)
|
||||
entest_DEPENDENCIES =
|
||||
AM_V_lt = $(am__v_lt_@AM_V@)
|
||||
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
|
||||
am__v_lt_0 = --silent
|
||||
am__v_lt_1 =
|
||||
AM_V_P = $(am__v_P_@AM_V@)
|
||||
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
|
||||
am__v_P_0 = false
|
||||
am__v_P_1 = :
|
||||
AM_V_GEN = $(am__v_GEN_@AM_V@)
|
||||
am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
|
||||
am__v_GEN_0 = @echo " GEN " $@;
|
||||
am__v_GEN_1 =
|
||||
AM_V_at = $(am__v_at_@AM_V@)
|
||||
am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
|
||||
am__v_at_0 = @
|
||||
am__v_at_1 =
|
||||
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
|
||||
depcomp =
|
||||
am__maybe_remake_depfiles =
|
||||
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
|
||||
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
||||
LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
|
||||
$(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
|
||||
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
|
||||
$(AM_CFLAGS) $(CFLAGS)
|
||||
AM_V_CC = $(am__v_CC_@AM_V@)
|
||||
am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
|
||||
am__v_CC_0 = @echo " CC " $@;
|
||||
am__v_CC_1 =
|
||||
CCLD = $(CC)
|
||||
LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
|
||||
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
|
||||
$(AM_LDFLAGS) $(LDFLAGS) -o $@
|
||||
AM_V_CCLD = $(am__v_CCLD_@AM_V@)
|
||||
am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
|
||||
am__v_CCLD_0 = @echo " CCLD " $@;
|
||||
am__v_CCLD_1 =
|
||||
SOURCES = $(entest_SOURCES)
|
||||
DIST_SOURCES = $(entest_SOURCES)
|
||||
am__can_run_installinfo = \
|
||||
case $$AM_UPDATE_INFO_DIR in \
|
||||
n|no|NO) false;; \
|
||||
*) (install-info --version) >/dev/null 2>&1;; \
|
||||
esac
|
||||
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
|
||||
# Read a list of newline-separated strings from the standard input,
|
||||
# and print each of them once, without duplicates. Input order is
|
||||
# *not* preserved.
|
||||
am__uniquify_input = $(AWK) '\
|
||||
BEGIN { nonempty = 0; } \
|
||||
{ items[$$0] = 1; nonempty = 1; } \
|
||||
END { if (nonempty) { for (i in items) print i; }; } \
|
||||
'
|
||||
# Make sure the list of sources is unique. This is necessary because,
|
||||
# e.g., the same source file might be shared among _SOURCES variables
|
||||
# for different programs/libraries.
|
||||
am__define_uniq_tagged_files = \
|
||||
list='$(am__tagged_files)'; \
|
||||
unique=`for i in $$list; do \
|
||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
done | $(am__uniquify_input)`
|
||||
ETAGS = etags
|
||||
CTAGS = ctags
|
||||
am__DIST_COMMON = $(srcdir)/Makefile.in
|
||||
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
||||
ACLOCAL = @ACLOCAL@
|
||||
AMTAR = @AMTAR@
|
||||
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
|
||||
AR = @AR@
|
||||
AUTOCONF = @AUTOCONF@
|
||||
AUTOHEADER = @AUTOHEADER@
|
||||
AUTOMAKE = @AUTOMAKE@
|
||||
AWK = @AWK@
|
||||
CC = @CC@
|
||||
CFLAGS = @CFLAGS@
|
||||
CPP = @CPP@
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
CYGPATH_W = @CYGPATH_W@
|
||||
DEFS = @DEFS@
|
||||
DLLTOOL = @DLLTOOL@
|
||||
DSYMUTIL = @DSYMUTIL@
|
||||
DUMPBIN = @DUMPBIN@
|
||||
ECHO_C = @ECHO_C@
|
||||
ECHO_N = @ECHO_N@
|
||||
ECHO_T = @ECHO_T@
|
||||
EGREP = @EGREP@
|
||||
EXEEXT = @EXEEXT@
|
||||
FGREP = @FGREP@
|
||||
GREP = @GREP@
|
||||
HAVEGE_LT_VERSION = @HAVEGE_LT_VERSION@
|
||||
HA_DISTRO = @HA_DISTRO@
|
||||
HA_LDFLAGS = @HA_LDFLAGS@
|
||||
HA_UNITD = @HA_UNITD@
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
|
||||
LD = @LD@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LIBOBJS = @LIBOBJS@
|
||||
LIBS = @LIBS@
|
||||
LIBTOOL = @LIBTOOL@
|
||||
LIPO = @LIPO@
|
||||
LN_S = @LN_S@
|
||||
LTLIBOBJS = @LTLIBOBJS@
|
||||
LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
MANIFEST_TOOL = @MANIFEST_TOOL@
|
||||
MKDIR_P = @MKDIR_P@
|
||||
NM = @NM@
|
||||
NMEDIT = @NMEDIT@
|
||||
OBJDUMP = @OBJDUMP@
|
||||
OBJEXT = @OBJEXT@
|
||||
OTOOL = @OTOOL@
|
||||
OTOOL64 = @OTOOL64@
|
||||
PACKAGE = @PACKAGE@
|
||||
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
|
||||
PACKAGE_NAME = @PACKAGE_NAME@
|
||||
PACKAGE_STRING = @PACKAGE_STRING@
|
||||
PACKAGE_TARNAME = @PACKAGE_TARNAME@
|
||||
PACKAGE_URL = @PACKAGE_URL@
|
||||
PACKAGE_VERSION = @PACKAGE_VERSION@
|
||||
PATH_SEPARATOR = @PATH_SEPARATOR@
|
||||
RANLIB = @RANLIB@
|
||||
SED = @SED@
|
||||
SET_MAKE = @SET_MAKE@
|
||||
SHELL = @SHELL@
|
||||
STRIP = @STRIP@
|
||||
VERSION = @VERSION@
|
||||
abs_builddir = @abs_builddir@
|
||||
abs_srcdir = @abs_srcdir@
|
||||
abs_top_builddir = @abs_top_builddir@
|
||||
abs_top_srcdir = @abs_top_srcdir@
|
||||
ac_ct_AR = @ac_ct_AR@
|
||||
ac_ct_CC = @ac_ct_CC@
|
||||
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
|
||||
am__leading_dot = @am__leading_dot@
|
||||
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@
|
||||
builddir = @builddir@
|
||||
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@
|
||||
srcdir = @srcdir@
|
||||
sysconfdir = @sysconfdir@
|
||||
target_alias = @target_alias@
|
||||
top_build_prefix = @top_build_prefix@
|
||||
top_builddir = @top_builddir@
|
||||
top_srcdir = @top_srcdir@
|
||||
AM_CFLAGS = -Wall
|
||||
entest_LDADD = -lm
|
||||
entest_SOURCES = entest.c iso8859.c randtest.c chisq.c iso8859.h randtest.h
|
||||
CLEANFILES = sample
|
||||
MAINTAINERCLEANFILES = Makefile.in
|
||||
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 ) \
|
||||
&& { if test -f $@; then exit 0; else break; fi; }; \
|
||||
exit 1;; \
|
||||
esac; \
|
||||
done; \
|
||||
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu --ignore-deps ent/Makefile'; \
|
||||
$(am__cd) $(top_srcdir) && \
|
||||
$(AUTOMAKE) --gnu --ignore-deps ent/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__maybe_remake_depfiles)'; \
|
||||
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \
|
||||
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
|
||||
$(am__aclocal_m4_deps):
|
||||
|
||||
clean-checkPROGRAMS:
|
||||
@list='$(check_PROGRAMS)'; test -n "$$list" || exit 0; \
|
||||
echo " rm -f" $$list; \
|
||||
rm -f $$list || exit $$?; \
|
||||
test -n "$(EXEEXT)" || exit 0; \
|
||||
list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
|
||||
echo " rm -f" $$list; \
|
||||
rm -f $$list
|
||||
|
||||
entest$(EXEEXT): $(entest_OBJECTS) $(entest_DEPENDENCIES) $(EXTRA_entest_DEPENDENCIES)
|
||||
@rm -f entest$(EXEEXT)
|
||||
$(AM_V_CCLD)$(LINK) $(entest_OBJECTS) $(entest_LDADD) $(LIBS)
|
||||
|
||||
mostlyclean-compile:
|
||||
-rm -f *.$(OBJEXT)
|
||||
|
||||
distclean-compile:
|
||||
-rm -f *.tab.c
|
||||
|
||||
.c.o:
|
||||
$(AM_V_CC)$(COMPILE) -c -o $@ $<
|
||||
|
||||
.c.obj:
|
||||
$(AM_V_CC)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
|
||||
|
||||
.c.lo:
|
||||
$(AM_V_CC)$(LTCOMPILE) -c -o $@ $<
|
||||
|
||||
mostlyclean-libtool:
|
||||
-rm -f *.lo
|
||||
|
||||
clean-libtool:
|
||||
-rm -rf .libs _libs
|
||||
|
||||
ID: $(am__tagged_files)
|
||||
$(am__define_uniq_tagged_files); mkid -fID $$unique
|
||||
tags: tags-am
|
||||
TAGS: tags
|
||||
|
||||
tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
|
||||
set x; \
|
||||
here=`pwd`; \
|
||||
$(am__define_uniq_tagged_files); \
|
||||
shift; \
|
||||
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
|
||||
test -n "$$unique" || unique=$$empty_fix; \
|
||||
if test $$# -gt 0; then \
|
||||
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
|
||||
"$$@" $$unique; \
|
||||
else \
|
||||
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
|
||||
$$unique; \
|
||||
fi; \
|
||||
fi
|
||||
ctags: ctags-am
|
||||
|
||||
CTAGS: ctags
|
||||
ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
|
||||
$(am__define_uniq_tagged_files); \
|
||||
test -z "$(CTAGS_ARGS)$$unique" \
|
||||
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
|
||||
$$unique
|
||||
|
||||
GTAGS:
|
||||
here=`$(am__cd) $(top_builddir) && pwd` \
|
||||
&& $(am__cd) $(top_srcdir) \
|
||||
&& gtags -i $(GTAGS_ARGS) "$$here"
|
||||
cscopelist: cscopelist-am
|
||||
|
||||
cscopelist-am: $(am__tagged_files)
|
||||
list='$(am__tagged_files)'; \
|
||||
case "$(srcdir)" in \
|
||||
[\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
|
||||
*) sdir=$(subdir)/$(srcdir) ;; \
|
||||
esac; \
|
||||
for i in $$list; do \
|
||||
if test -f "$$i"; then \
|
||||
echo "$(subdir)/$$i"; \
|
||||
else \
|
||||
echo "$$sdir/$$i"; \
|
||||
fi; \
|
||||
done >> $(top_builddir)/cscope.files
|
||||
|
||||
distclean-tags:
|
||||
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
|
||||
|
||||
distdir: $(BUILT_SOURCES)
|
||||
$(MAKE) $(AM_MAKEFLAGS) distdir-am
|
||||
|
||||
distdir-am: $(DISTFILES)
|
||||
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
|
||||
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
|
||||
list='$(DISTFILES)'; \
|
||||
dist_files=`for file in $$list; do echo $$file; done | \
|
||||
sed -e "s|^$$srcdirstrip/||;t" \
|
||||
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
|
||||
case $$dist_files in \
|
||||
*/*) $(MKDIR_P) `echo "$$dist_files" | \
|
||||
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
|
||||
sort -u` ;; \
|
||||
esac; \
|
||||
for file in $$dist_files; do \
|
||||
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
|
||||
if test -d $$d/$$file; then \
|
||||
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
|
||||
if test -d "$(distdir)/$$file"; then \
|
||||
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
|
||||
fi; \
|
||||
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
|
||||
cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
|
||||
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
|
||||
fi; \
|
||||
cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
|
||||
else \
|
||||
test -f "$(distdir)/$$file" \
|
||||
|| cp -p $$d/$$file "$(distdir)/$$file" \
|
||||
|| exit 1; \
|
||||
fi; \
|
||||
done
|
||||
@ENABLE_ENT_TEST_FALSE@check-local:
|
||||
check-am: all-am
|
||||
$(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS)
|
||||
$(MAKE) $(AM_MAKEFLAGS) check-local
|
||||
check: check-am
|
||||
all-am: Makefile
|
||||
installdirs:
|
||||
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:
|
||||
if test -z '$(STRIP)'; then \
|
||||
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
|
||||
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
|
||||
install; \
|
||||
else \
|
||||
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
|
||||
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
|
||||
"INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
|
||||
fi
|
||||
mostlyclean-generic:
|
||||
|
||||
clean-generic:
|
||||
-test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
|
||||
|
||||
distclean-generic:
|
||||
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
|
||||
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
|
||||
|
||||
maintainer-clean-generic:
|
||||
@echo "This command is intended for maintainers to use"
|
||||
@echo "it deletes files that may require special tools to rebuild."
|
||||
-test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
|
||||
clean: clean-am
|
||||
|
||||
clean-am: clean-checkPROGRAMS clean-generic clean-libtool \
|
||||
mostlyclean-am
|
||||
|
||||
distclean: distclean-am
|
||||
-rm -f Makefile
|
||||
distclean-am: clean-am distclean-compile distclean-generic \
|
||||
distclean-tags
|
||||
|
||||
dvi: dvi-am
|
||||
|
||||
dvi-am:
|
||||
|
||||
html: html-am
|
||||
|
||||
html-am:
|
||||
|
||||
info: info-am
|
||||
|
||||
info-am:
|
||||
|
||||
install-data-am:
|
||||
|
||||
install-dvi: install-dvi-am
|
||||
|
||||
install-dvi-am:
|
||||
|
||||
install-exec-am:
|
||||
|
||||
install-html: install-html-am
|
||||
|
||||
install-html-am:
|
||||
|
||||
install-info: install-info-am
|
||||
|
||||
install-info-am:
|
||||
|
||||
install-man:
|
||||
|
||||
install-pdf: install-pdf-am
|
||||
|
||||
install-pdf-am:
|
||||
|
||||
install-ps: install-ps-am
|
||||
|
||||
install-ps-am:
|
||||
|
||||
installcheck-am:
|
||||
|
||||
maintainer-clean: maintainer-clean-am
|
||||
-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:
|
||||
|
||||
.MAKE: check-am install-am install-strip
|
||||
|
||||
.PHONY: CTAGS GTAGS TAGS all all-am check check-am check-local clean \
|
||||
clean-checkPROGRAMS clean-generic clean-libtool cscopelist-am \
|
||||
ctags ctags-am 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-dvi install-dvi-am install-exec \
|
||||
install-exec-am install-html install-html-am install-info \
|
||||
install-info-am install-man install-pdf install-pdf-am \
|
||||
install-ps install-ps-am 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 tags-am uninstall uninstall-am
|
||||
|
||||
.PRECIOUS: Makefile
|
||||
|
||||
|
||||
@ENABLE_ENT_TEST_TRUE@check-local:
|
||||
@ENABLE_ENT_TEST_TRUE@ ./entest -t ${srcdir}/entitle.gif
|
||||
@ENABLE_ENT_TEST_TRUE@ ../src/haveged -n 16384k -v 1 $*
|
||||
@ENABLE_ENT_TEST_TRUE@ ./entest -vf sample
|
||||
|
||||
# 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:
|
136
ent/chisq.c
Normal file
136
ent/chisq.c
Normal file
|
@ -0,0 +1,136 @@
|
|||
/*
|
||||
|
||||
Compute probability of measured Chi Square value.
|
||||
|
||||
This code was developed by Gary Perlman of the Wang
|
||||
Institute (full citation below) and has been minimally
|
||||
modified for use in this program.
|
||||
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
|
||||
/*HEADER
|
||||
Module: z.c
|
||||
Purpose: compute approximations to normal z distribution probabilities
|
||||
Programmer: Gary Perlman
|
||||
Organization: Wang Institute, Tyngsboro, MA 01879
|
||||
Copyright: none
|
||||
Tabstops: 4
|
||||
*/
|
||||
|
||||
#define Z_MAX 6.0 /* maximum meaningful z value */
|
||||
|
||||
/*FUNCTION poz: probability of normal z value */
|
||||
/*ALGORITHM
|
||||
Adapted from a polynomial approximation in:
|
||||
Ibbetson D, Algorithm 209
|
||||
Collected Algorithms of the CACM 1963 p. 616
|
||||
Note:
|
||||
This routine has six digit accuracy, so it is only useful for absolute
|
||||
z values < 6. For z values >= to 6.0, poz() returns 0.0.
|
||||
*/
|
||||
static double /*VAR returns cumulative probability from -oo to z */
|
||||
poz(const double z) /*VAR normal z value */
|
||||
{
|
||||
double y, x, w;
|
||||
|
||||
if (z == 0.0) {
|
||||
x = 0.0;
|
||||
} else {
|
||||
y = 0.5 * fabs(z);
|
||||
if (y >= (Z_MAX * 0.5)) {
|
||||
x = 1.0;
|
||||
} else if (y < 1.0) {
|
||||
w = y * y;
|
||||
x = ((((((((0.000124818987 * w
|
||||
-0.001075204047) * w +0.005198775019) * w
|
||||
-0.019198292004) * w +0.059054035642) * w
|
||||
-0.151968751364) * w +0.319152932694) * w
|
||||
-0.531923007300) * w +0.797884560593) * y * 2.0;
|
||||
} else {
|
||||
y -= 2.0;
|
||||
x = (((((((((((((-0.000045255659 * y
|
||||
+0.000152529290) * y -0.000019538132) * y
|
||||
-0.000676904986) * y +0.001390604284) * y
|
||||
-0.000794620820) * y -0.002034254874) * y
|
||||
+0.006549791214) * y -0.010557625006) * y
|
||||
+0.011630447319) * y -0.009279453341) * y
|
||||
+0.005353579108) * y -0.002141268741) * y
|
||||
+0.000535310849) * y +0.999936657524;
|
||||
}
|
||||
}
|
||||
return (z > 0.0 ? ((x + 1.0) * 0.5) : ((1.0 - x) * 0.5));
|
||||
}
|
||||
|
||||
/*
|
||||
Module: chisq.c
|
||||
Purpose: compute approximations to chisquare distribution probabilities
|
||||
Contents: pochisq()
|
||||
Uses: poz() in z.c (Algorithm 209)
|
||||
Programmer: Gary Perlman
|
||||
Organization: Wang Institute, Tyngsboro, MA 01879
|
||||
Copyright: none
|
||||
Tabstops: 4
|
||||
*/
|
||||
|
||||
#define LOG_SQRT_PI 0.5723649429247000870717135 /* log (sqrt (pi)) */
|
||||
#define I_SQRT_PI 0.5641895835477562869480795 /* 1 / sqrt (pi) */
|
||||
#define BIGX 20.0 /* max value to represent exp (x) */
|
||||
#define ex(x) (((x) < -BIGX) ? 0.0 : exp(x))
|
||||
|
||||
/*FUNCTION pochisq: probability of chi sqaure value */
|
||||
/*ALGORITHM Compute probability of chi square value.
|
||||
Adapted from:
|
||||
Hill, I. D. and Pike, M. C. Algorithm 299
|
||||
Collected Algorithms for the CACM 1967 p. 243
|
||||
Updated for rounding errors based on remark in
|
||||
ACM TOMS June 1985, page 185
|
||||
*/
|
||||
|
||||
double pochisq(
|
||||
const double ax, /* obtained chi-square value */
|
||||
const int df /* degrees of freedom */
|
||||
)
|
||||
{
|
||||
double x = ax;
|
||||
double a, y=0, s;
|
||||
double e, c, z;
|
||||
int even; /* true if df is an even number */
|
||||
|
||||
if (x <= 0.0 || df < 1) {
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
a = 0.5 * x;
|
||||
even = (2 * (df / 2)) == df;
|
||||
if (df > 1) {
|
||||
y = ex(-a);
|
||||
}
|
||||
s = (even ? y : (2.0 * poz(-sqrt(x))));
|
||||
if (df > 2) {
|
||||
x = 0.5 * (df - 1.0);
|
||||
z = (even ? 1.0 : 0.5);
|
||||
if (a > BIGX) {
|
||||
e = (even ? 0.0 : LOG_SQRT_PI);
|
||||
c = log(a);
|
||||
while (z <= x) {
|
||||
e = log(z) + e;
|
||||
s += ex(c * z - a - e);
|
||||
z += 1.0;
|
||||
}
|
||||
return (s);
|
||||
} else {
|
||||
e = (even ? 1.0 : (I_SQRT_PI / sqrt(a)));
|
||||
c = 0.0;
|
||||
while (z <= x) {
|
||||
e = e * (a / z);
|
||||
c = c + e;
|
||||
z += 1.0;
|
||||
}
|
||||
return (c * y + s);
|
||||
}
|
||||
} else {
|
||||
return s;
|
||||
}
|
||||
}
|
270
ent/entest.c
Normal file
270
ent/entest.c
Normal file
|
@ -0,0 +1,270 @@
|
|||
/*
|
||||
ENT -- Entropy calculation and analysis of putative
|
||||
random sequences.
|
||||
|
||||
Designed and implemented by John "Random" Walker in May 1985.
|
||||
|
||||
Multiple analyses of random sequences added in December 1985.
|
||||
|
||||
Bit stream analysis added in September 1997.
|
||||
|
||||
Terse mode output, getopt() command line processing,
|
||||
optional stdin input, and HTML documentation added in
|
||||
October 1998.
|
||||
|
||||
Documentation for the -t (terse output) option added
|
||||
in July 2006.
|
||||
|
||||
Replaced table look-up for chi square to probability
|
||||
conversion with algorithmic computation in January 2008.
|
||||
|
||||
Hacked for haveged test April 2009
|
||||
|
||||
For additional information and the latest version,
|
||||
see http://www.fourmilab.ch/random/
|
||||
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <math.h>
|
||||
#include "getopt.h"
|
||||
#ifdef _WIN32
|
||||
#include <fcntl.h>
|
||||
#include <io.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include "iso8859.h"
|
||||
#include "randtest.h"
|
||||
|
||||
#define UPDATE "January 28th, 2008"
|
||||
|
||||
#define FALSE 0
|
||||
#define TRUE 1
|
||||
|
||||
#ifdef M_PI
|
||||
#define PI M_PI
|
||||
#else
|
||||
#define PI 3.14159265358979323846
|
||||
#endif
|
||||
|
||||
extern double pochisq(const double ax, const int df);
|
||||
|
||||
struct pparams {
|
||||
double chisqr;
|
||||
double entropy;
|
||||
double mean;
|
||||
double pi;
|
||||
double seq;
|
||||
double xtreme;
|
||||
};
|
||||
|
||||
static struct pparams defaults = {
|
||||
.chisqr = 1, // bounds - should be >1% and <99%
|
||||
.entropy = 7.5, // minimum - should be close to 8
|
||||
.mean = 127.0, // minimum - should be close to 127.5
|
||||
.pi = 0.5, // maximum - error deviation in percent
|
||||
.seq = 0.8, // minimum - should be close to 1
|
||||
.xtreme = 0.00001 // maximum - result deviation
|
||||
};
|
||||
struct pparams *params = &defaults;
|
||||
|
||||
static int check(long totalc, double ent, double chip, double mean, double montepi, double scc)
|
||||
{
|
||||
char failures[512];
|
||||
int offs=0;
|
||||
double p;
|
||||
double p0 = params->chisqr;
|
||||
double p1 = 100-p0;
|
||||
if (ent<params->entropy) {
|
||||
sprintf(failures+offs,"entropy:%f<%f ",ent,params->entropy);
|
||||
offs=strlen(failures);
|
||||
}
|
||||
chip *= 100;
|
||||
if (chip<p0||chip>p1) {
|
||||
sprintf(failures+offs,"chisqr:%f%% not in %f-%f ",chip,p0,p1);
|
||||
offs=strlen(failures);
|
||||
}
|
||||
if (mean<params->mean) {
|
||||
sprintf(failures+offs,"mean:%f<%f ",mean,params->mean);
|
||||
offs=strlen(failures);
|
||||
}
|
||||
p = 100*(montepi-PI)/PI;
|
||||
if (fabs(p)>params->pi) {
|
||||
sprintf(failures+offs,"pi:%f %f>%f ",montepi,p,params->pi);
|
||||
offs=strlen(failures);
|
||||
}
|
||||
if (scc>params->seq) {
|
||||
sprintf(failures+offs,"sequence:%f>%f ",scc,params->seq);
|
||||
offs=strlen(failures);
|
||||
}
|
||||
if (offs) {
|
||||
printf("Check Fail: %s\n",failures);
|
||||
return -1;
|
||||
}
|
||||
printf("Sample looks good!\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Who checks the checker? The ent self-test test the various options by collecting the output
|
||||
* of the various options on a given input in a text and then doing a diff with the expected
|
||||
* output. IMHO the text comparison is pretty cheezy since doubles are involved. We make the
|
||||
* same check but do not require equality on the quantities involved
|
||||
*/
|
||||
|
||||
static int checkSelf(long totalc, double ent, double chisq, double mean, double montepi, double scc)
|
||||
{
|
||||
double ref[6] = {11619,7.787095,6567.223255,110.000258,3.392562,0.098324};
|
||||
double tst[6] = {totalc,ent,chisq,mean,montepi,scc};
|
||||
int i;double f;
|
||||
for(i=0;i<6;i++) {
|
||||
f=fabs(tst[i]-ref[i])/ref[i];
|
||||
if (f > params->xtreme) {
|
||||
printf("Self-test(%d) failed:%f?",i,f);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
printf("Self-test good!\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* HELP -- Print information on how to call */
|
||||
|
||||
static void help(void)
|
||||
{
|
||||
printf("entest -- Test the havege RNG.");
|
||||
printf("\n");
|
||||
printf("\n Options: -c<min> Chi Square Threshold");
|
||||
printf("\n -e<min> Min entropy/char");
|
||||
printf("\n -f<file> File");
|
||||
printf("\n -m<min> Min arithmetic mean");
|
||||
printf("\n -p<max> Max error in pi");
|
||||
printf("\n -s<min> Min serial coeficient");
|
||||
printf("\n -t Self test");
|
||||
printf("\n -u Print this message\n");
|
||||
printf("\n -v Verbose - show the stats");
|
||||
printf("\nAdapted from the work of John Walker");
|
||||
printf("\n http://www.fourmilab.ch/\n\n");
|
||||
}
|
||||
|
||||
|
||||
/* Main program */
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int oc, opt;
|
||||
long ccount[256]; /* Bins to count occurrences of values */
|
||||
long totalc = 0; /* Total character count */
|
||||
double montepi, chip,
|
||||
scc, ent, mean, chisq;
|
||||
FILE *fp = stdin;
|
||||
int fold = FALSE, /* Fold upper to lower */
|
||||
binary = FALSE, /* Treat input as a bitstream */
|
||||
stest = FALSE,
|
||||
verbose = FALSE;
|
||||
char *filename="";
|
||||
|
||||
while ((opt = getopt(argc, argv, "?c:e:f:m:p:s:t:v")) != -1) {
|
||||
switch (toISOlower(opt)) {
|
||||
case 'c':
|
||||
params->chisqr = atof(optarg);
|
||||
break;
|
||||
|
||||
case 'e':
|
||||
params->entropy = atof(optarg);
|
||||
break;
|
||||
|
||||
case 'f':
|
||||
filename = optarg;
|
||||
break;
|
||||
|
||||
case 'm':
|
||||
params->mean = atof(optarg);
|
||||
break;
|
||||
|
||||
case 'p':
|
||||
params->pi = atof(optarg);
|
||||
break;
|
||||
|
||||
case 's':
|
||||
params->seq = atof(optarg);
|
||||
break;
|
||||
|
||||
case 't':
|
||||
filename = optarg;
|
||||
/* filename = "entitle.gif"; */
|
||||
stest = TRUE;
|
||||
break;
|
||||
|
||||
case 'v':
|
||||
verbose = TRUE;
|
||||
break;
|
||||
|
||||
default:
|
||||
help();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
if (!strlen(filename)) {
|
||||
printf("Need input file\n");
|
||||
help();
|
||||
return 2;
|
||||
}
|
||||
if ((fp = fopen(filename, "rb")) == NULL) {
|
||||
printf("Cannot open file %s\n", filename);
|
||||
return 2;
|
||||
}
|
||||
memset(ccount, 0, sizeof ccount);
|
||||
|
||||
/* Initialise for calculations */
|
||||
|
||||
rt_init(binary);
|
||||
|
||||
/* Scan input file and count character occurrences */
|
||||
|
||||
while ((oc = fgetc(fp)) != EOF) {
|
||||
unsigned char ocb;
|
||||
|
||||
if (fold && isISOalpha(oc) && isISOupper(oc)) {
|
||||
oc = toISOlower(oc);
|
||||
}
|
||||
ocb = (unsigned char) oc;
|
||||
totalc += binary ? 8 : 1;
|
||||
if (binary) {
|
||||
int b;
|
||||
unsigned char ob = ocb;
|
||||
|
||||
for (b = 0; b < 8; b++) {
|
||||
ccount[ob & 1]++;
|
||||
ob >>= 1;
|
||||
}
|
||||
} else {
|
||||
ccount[ocb]++; /* Update counter for this bin */
|
||||
}
|
||||
rt_add(&ocb, 1);
|
||||
}
|
||||
fclose(fp);
|
||||
|
||||
/* Complete calculation and return sequence metrics */
|
||||
|
||||
rt_end(&ent, &chisq, &mean, &montepi, &scc);
|
||||
chip = pochisq(chisq, (binary ? 1 : 255));
|
||||
|
||||
if (verbose)
|
||||
printf("\nTest Results\n"
|
||||
"Sample: %ld bytes\n"
|
||||
"Entropy: %f bits\n"
|
||||
"Chi-Square: %f(%f%%)\n"
|
||||
"Mean: %f\n"
|
||||
"PI: %f(%f%%)\n"
|
||||
"Correlation: %f\n",
|
||||
totalc, ent, chisq, chip*100, mean, montepi,100*(montepi-PI)/PI,scc);
|
||||
|
||||
if (stest)
|
||||
return checkSelf(totalc, ent, chisq, mean, montepi, scc);
|
||||
return check(totalc, ent, chip, mean, montepi, scc);
|
||||
}
|
BIN
ent/entitle.gif
Normal file
BIN
ent/entitle.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 11 KiB |
19
ent/iso8859.c
Normal file
19
ent/iso8859.c
Normal file
|
@ -0,0 +1,19 @@
|
|||
|
||||
/* ISO 8859/1 Latin-1 alphabetic and upper and lower case bit vector tables. */
|
||||
|
||||
/* LINTLIBRARY */
|
||||
|
||||
unsigned char isoalpha[32] = {
|
||||
0,0,0,0,0,0,0,0,127,255,255,224,127,255,255,224,0,0,0,0,0,0,0,0,255,255,
|
||||
254,255,255,255,254,255
|
||||
};
|
||||
|
||||
unsigned char isoupper[32] = {
|
||||
0,0,0,0,0,0,0,0,127,255,255,224,0,0,0,0,0,0,0,0,0,0,0,0,255,255,254,254,
|
||||
0,0,0,0
|
||||
};
|
||||
|
||||
unsigned char isolower[32] = {
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,127,255,255,224,0,0,0,0,0,0,0,0,0,0,0,1,255,255,
|
||||
254,255
|
||||
};
|
17
ent/iso8859.h
Normal file
17
ent/iso8859.h
Normal file
|
@ -0,0 +1,17 @@
|
|||
|
||||
/* ISO 8859/1 Latin-1 "ctype" macro replacements. */
|
||||
|
||||
extern unsigned char isoalpha[32], isoupper[32], isolower[32];
|
||||
|
||||
#define isISOspace(x) ((isascii(((unsigned char) (x))) && isspace(((unsigned char) (x)))) || ((x) == 0xA0))
|
||||
#define isISOalpha(x) ((isoalpha[(((unsigned char) (x))) / 8] & (0x80 >> ((((unsigned char) (x))) % 8))) != 0)
|
||||
#define isISOupper(x) ((isoupper[(((unsigned char) (x))) / 8] & (0x80 >> ((((unsigned char) (x))) % 8))) != 0)
|
||||
#define isISOlower(x) ((isolower[(((unsigned char) (x))) / 8] & (0x80 >> ((((unsigned char) (x))) % 8))) != 0)
|
||||
#define isISOprint(x) ((((x) >= ' ') && ((x) <= '~')) || ((x) >= 0xA0))
|
||||
#define toISOupper(x) (isISOlower(x) ? (isascii(((unsigned char) (x))) ? \
|
||||
toupper(x) : (((((unsigned char) (x)) != 0xDF) && \
|
||||
(((unsigned char) (x)) != 0xFF)) ? \
|
||||
(((unsigned char) (x)) - 0x20) : (x))) : (x))
|
||||
#define toISOlower(x) (isISOupper(x) ? (isascii(((unsigned char) (x))) ? \
|
||||
tolower(x) : (((unsigned char) (x)) + 0x20)) \
|
||||
: (x))
|
183
ent/randtest.c
Normal file
183
ent/randtest.c
Normal file
|
@ -0,0 +1,183 @@
|
|||
/*
|
||||
|
||||
Apply various randomness tests to a stream of bytes
|
||||
|
||||
by John Walker -- September 1996
|
||||
http://www.fourmilab.ch/
|
||||
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#define FALSE 0
|
||||
#define TRUE 1
|
||||
|
||||
#define log2of10 3.32192809488736234787
|
||||
|
||||
static int binary = FALSE; /* Treat input as a bitstream */
|
||||
|
||||
static long ccount[256], /* Bins to count occurrences of values */
|
||||
totalc = 0; /* Total bytes counted */
|
||||
static double prob[256]; /* Probabilities per bin for entropy */
|
||||
|
||||
/* RT_LOG2 -- Calculate log to the base 2 */
|
||||
|
||||
static double rt_log2(double x)
|
||||
{
|
||||
return log2of10 * log10(x);
|
||||
}
|
||||
|
||||
#define MONTEN 6 /* Bytes used as Monte Carlo
|
||||
co-ordinates. This should be no more
|
||||
bits than the mantissa of your
|
||||
"double" floating point type. */
|
||||
|
||||
static int mp, sccfirst;
|
||||
static unsigned int monte[MONTEN];
|
||||
static long inmont, mcount;
|
||||
static double cexp, incirc, montex, montey, montepi,
|
||||
scc, sccun, sccu0, scclast, scct1, scct2, scct3,
|
||||
ent, chisq, datasum;
|
||||
|
||||
/* RT_INIT -- Initialise random test counters. */
|
||||
|
||||
void rt_init(int binmode)
|
||||
{
|
||||
int i;
|
||||
|
||||
binary = binmode; /* Set binary / byte mode */
|
||||
|
||||
/* Initialise for calculations */
|
||||
|
||||
ent = 0.0; /* Clear entropy accumulator */
|
||||
chisq = 0.0; /* Clear Chi-Square */
|
||||
datasum = 0.0; /* Clear sum of bytes for arithmetic mean */
|
||||
|
||||
mp = 0; /* Reset Monte Carlo accumulator pointer */
|
||||
mcount = 0; /* Clear Monte Carlo tries */
|
||||
inmont = 0; /* Clear Monte Carlo inside count */
|
||||
incirc = 65535.0 * 65535.0;/* In-circle distance for Monte Carlo */
|
||||
|
||||
sccfirst = TRUE; /* Mark first time for serial correlation */
|
||||
scct1 = scct2 = scct3 = 0.0; /* Clear serial correlation terms */
|
||||
|
||||
incirc = pow(pow(256.0, (double) (MONTEN / 2)) - 1, 2.0);
|
||||
|
||||
for (i = 0; i < 256; i++) {
|
||||
ccount[i] = 0;
|
||||
}
|
||||
totalc = 0;
|
||||
}
|
||||
|
||||
/* RT_ADD -- Add one or more bytes to accumulation. */
|
||||
|
||||
void rt_add(void *buf, int bufl)
|
||||
{
|
||||
unsigned char *bp = buf;
|
||||
int oc, c, bean;
|
||||
|
||||
while (bean = 0, (bufl-- > 0)) {
|
||||
oc = *bp++;
|
||||
|
||||
do {
|
||||
if (binary) {
|
||||
c = !!(oc & 0x80);
|
||||
} else {
|
||||
c = oc;
|
||||
}
|
||||
ccount[c]++; /* Update counter for this bin */
|
||||
totalc++;
|
||||
|
||||
/* Update inside / outside circle counts for Monte Carlo
|
||||
computation of PI */
|
||||
|
||||
if (bean == 0) {
|
||||
monte[mp++] = oc; /* Save character for Monte Carlo */
|
||||
if (mp >= MONTEN) { /* Calculate every MONTEN character */
|
||||
int mj;
|
||||
|
||||
mp = 0;
|
||||
mcount++;
|
||||
montex = montey = 0;
|
||||
for (mj = 0; mj < MONTEN / 2; mj++) {
|
||||
montex = (montex * 256.0) + monte[mj];
|
||||
montey = (montey * 256.0) + monte[(MONTEN / 2) + mj];
|
||||
}
|
||||
if ((montex * montex + montey * montey) <= incirc) {
|
||||
inmont++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Update calculation of serial correlation coefficient */
|
||||
|
||||
sccun = c;
|
||||
if (sccfirst) {
|
||||
sccfirst = FALSE;
|
||||
scclast = 0;
|
||||
sccu0 = sccun;
|
||||
} else {
|
||||
scct1 = scct1 + scclast * sccun;
|
||||
}
|
||||
scct2 = scct2 + sccun;
|
||||
scct3 = scct3 + (sccun * sccun);
|
||||
scclast = sccun;
|
||||
oc <<= 1;
|
||||
} while (binary && (++bean < 8));
|
||||
}
|
||||
}
|
||||
|
||||
/* RT_END -- Complete calculation and return results. */
|
||||
|
||||
void rt_end(double *r_ent, double *r_chisq, double *r_mean,
|
||||
double *r_montepicalc, double *r_scc)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* Complete calculation of serial correlation coefficient */
|
||||
|
||||
scct1 = scct1 + scclast * sccu0;
|
||||
scct2 = scct2 * scct2;
|
||||
scc = totalc * scct3 - scct2;
|
||||
if (scc == 0.0) {
|
||||
scc = -100000;
|
||||
} else {
|
||||
scc = (totalc * scct1 - scct2) / scc;
|
||||
}
|
||||
|
||||
/* Scan bins and calculate probability for each bin and
|
||||
Chi-Square distribution. The probability will be reused
|
||||
in the entropy calculation below. While we're at it,
|
||||
we sum of all the data which will be used to compute the
|
||||
mean. */
|
||||
|
||||
cexp = totalc / (binary ? 2.0 : 256.0); /* Expected count per bin */
|
||||
for (i = 0; i < (binary ? 2 : 256); i++) {
|
||||
double a = ccount[i] - cexp;;
|
||||
|
||||
prob[i] = ((double) ccount[i]) / totalc;
|
||||
chisq += (a * a) / cexp;
|
||||
datasum += ((double) i) * ccount[i];
|
||||
}
|
||||
|
||||
/* Calculate entropy */
|
||||
|
||||
for (i = 0; i < (binary ? 2 : 256); i++) {
|
||||
if (prob[i] > 0.0) {
|
||||
ent += prob[i] * rt_log2(1 / prob[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/* Calculate Monte Carlo value for PI from percentage of hits
|
||||
within the circle */
|
||||
|
||||
montepi = 4.0 * (((double) inmont) / mcount);
|
||||
|
||||
/* Return results through arguments */
|
||||
|
||||
*r_ent = ent;
|
||||
*r_chisq = chisq;
|
||||
*r_mean = datasum / totalc;
|
||||
*r_montepicalc = montepi;
|
||||
*r_scc = scc;
|
||||
}
|
7
ent/randtest.h
Normal file
7
ent/randtest.h
Normal file
|
@ -0,0 +1,7 @@
|
|||
|
||||
/* Random test function prototypes */
|
||||
|
||||
extern void rt_init(int binmode);
|
||||
extern void rt_add(void *buf, int bufl);
|
||||
extern void rt_end(double *r_ent, double *r_chisq, double *r_mean,
|
||||
double *r_montepicalc, double *r_scc);
|
Loading…
Add table
Add a link
Reference in a new issue