Changeset 18 for trunk


Ignore:
Timestamp:
Jan 28, 2006, 9:07:52 PM (19 years ago)
Author:
rainer
Message:

Optimized version of tiger algorithm, and basic ingredients for unit testing (part 2)

Location:
trunk
Files:
22 edited

Legend:

Unmodified
Added
Removed
  • trunk/COPYING

    r1 r18  
    241241   either version 2 of the License, or (at your option) any later version."
    242242
     243   (x) Unit testing uses the 'cutest' framework by Asim Jalis, (files
     244   CuTest.h, CuTest.c, make-tests.sh) which is licensed under the zlib license:
     245
     246     * Copyright (c) 2003 Asim Jalis
     247     *
     248     * This software is provided 'as-is', without any express or implied
     249     * warranty. In no event will the authors be held liable for any damages
     250     * arising from the use of this software.
     251     *
     252     * Permission is granted to anyone to use this software for any purpose,
     253     * including commercial applications, and to alter it and redistribute it
     254     * freely, subject to the following restrictions:
     255     *
     256     * 1. The origin of this software must not be misrepresented; you must not
     257     * claim that you wrote the original software. If you use this software in
     258     * a product, an acknowledgment in the product documentation would be
     259     * appreciated but is not required.
     260     *
     261     * 2. Altered source versions must be plainly marked as such, and must not
     262     * be misrepresented as being the original software.
     263     *
     264     * 3. This notice may not be removed or altered from any source
     265     * distribution.
     266
    243267
    244268Other
  • trunk/Makefile.in

    r1 r18  
    5757XOR_CODE = @xor_code@
    5858SH_LKM   = @sh_lkm@
     59TIGER_SRC = @tiger_src@
    5960
    6061ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
     
    6364
    6465CC = @CC@
     66# DBGDEF = -pg -DSH_PROFILE=1
    6567DBGDEF = @mydebugdef@
    6668DEFS = $(DBGDEF) @DEFS@ -I. -I$(top_srcdir)/include
     
    98100        lzoconf.h minilzo.h rijndael-alg-fst.h rijndael-api-fst.h \
    99101        rijndael-boxes-fst.h sh_socket.h sh_ignore.h sh_prelude.h \
    100         sh_mounts.h sh_userfiles.h sh_static.h sh_prelink.h
     102        sh_mounts.h sh_userfiles.h sh_static.h sh_prelink.h 
    101103
    102104
     
    130132        $(srcsrc)/sh_userfiles.c $(srcsrc)/sh_prelude.c \
    131133        $(srcsrc)/sh_prelink.c $(srcsrc)/sh_static.c \
    132         $(srcsrc)/sh_prelude_old.c
    133 
    134 OBJECTS = samhain.o sh_unix.o sh_utils.o sh_error.o sh_files.o \
    135         sh_getopt.o sh_readconf.o sh_tiger0.o sh_tiger1.o sh_tiger2.o \
    136         sh_tiger1_64.o sh_tiger2_64.o sh_hash.o sh_mail.o sh_mem.o \
     134        $(srcsrc)/sh_prelude_old.c
     135
     136OBJECTS = sh_files.o sh_tiger0.o sh_tiger2.o sh_tiger2_64.o \
     137        samhain.o sh_unix.o sh_utils.o sh_error.o \
     138        sh_getopt.o sh_readconf.o \
     139        sh_hash.o sh_mail.o sh_mem.o \
    137140        sh_entropy.o sh_forward.o sh_modules.o sh_utmp.o sh_kern.o \
    138141        sh_suidchk.o sh_srp.o sh_fifo.o sh_tools.o sh_html.o sh_gpg.o \
     
    141144        trustfile.o rijndael-alg-fst.o rijndael-api-fst.o slib.o \
    142145        zAVLTree.o sh_socket.o sh_ignore.o sh_prelude.o \
    143         sh_mounts.o sh_userfiles.o sh_prelink.o sh_static.o sh_prelude_old.o
     146        sh_mounts.o sh_userfiles.o sh_prelink.o sh_static.o \
     147        sh_prelude_old.o
    144148
    145149KERN = kern_head.h kern_head.c
     
    10571061        rm x_`echo $@ |sed 's%\.o$$%%'`.c
    10581062
     1063sh_tiger_i.o: $(srcsrc)/$(TIGER_SRC) Makefile config_xor.h
     1064        @echo "$(COMPILE) $(VFLAG) -o sh_tiger_i.o -c $(srcsrc)/$(TIGER_SRC)";\
     1065        $(COMPILE) $(VFLAG) -o sh_tiger_i.o -c $(srcsrc)/$(TIGER_SRC);
     1066
    10591067samhain_setpwd: encode config_xor.h $(srcsrc)/samhain_setpwd.c
    10601068        @echo '$(COMPILE)  -o samhain_setpwd $(srcsrc)/samhain_setpwd.c'; \
     
    10751083        rm x_yulectl.c
    10761084
    1077 $(SAMHAIN): internal.h $(OBJECTS)
     1085$(SAMHAIN): internal.h $(OBJECTS) sh_tiger_i.o
    10781086        @-rm -f $(SAMHAIN)
    1079         @echo "$(LINK) $(OBJECTS) $(LIBS_TRY)"; \
    1080         $(LINK) $(OBJECTS) $(LIBS_TRY)
    1081 
    1082 
     1087        @echo "$(LINK) sh_tiger_i.o $(OBJECTS) $(LIBS_TRY)"; \
     1088        $(LINK) sh_tiger_i.o $(OBJECTS) $(LIBS_TRY)
     1089
     1090
     1091CUTEST_SOURCES = $(srcsrc)/cutest_sh_tools.c \
     1092                $(srcsrc)/cutest_zAVLTree.c \
     1093                $(srcsrc)/cutest_sh_tiger0.c
     1094
     1095CUTEST_OBJECTS = cutest_sh_tools.o cutest_zAVLTree.o cutest_sh_tiger0.o
     1096
     1097$(CUTEST_OBJECTS): $(CUTEST_SOURCES)
     1098        @echo "./encode $(XOR_CODE) $(srcsrc)/`echo $@ |sed 's%\.o$$%%'`.c --> x_`echo $@ |sed 's%\.o$$%%'`.c"; \
     1099        ./encode $(XOR_CODE) $(srcsrc)/`echo $@ |sed 's%\.o$$%%'`.c; \
     1100        echo "$(COMPILE) $(VFLAG) -o `echo $@ |sed 's%.*/%%'` -c x_`echo $@ |sed 's%\.o$$%%'`.c"; \
     1101        $(COMPILE) $(VFLAG) -o `echo $@ |sed 's%.*/%%'` -c x_`echo $@ |sed 's%\.o$$%%'`.c; \
     1102        rm x_`echo $@ |sed 's%\.o$$%%'`.c
     1103
     1104cutest: internal.h $(OBJECTS) $(CUTEST_OBJECTS) sh_tiger_i.o $(srcsrc)/make-tests.sh
     1105        cd $(srcsrc)/ && ./make-tests.sh >CuTestMain.c
     1106        @$(COMPILE) -o CuTestMain.o -c $(srcsrc)/CuTestMain.c; \
     1107        $(COMPILE) -o CuTest.o -c $(srcsrc)/CuTest.c; \
     1108        rm -f samhain.o; \
     1109        ./encode $(XOR_CODE) $(srcsrc)/samhain.c; \
     1110        $(COMPILE) $(VFLAG) -DSH_CUTEST=1 -o samhain.o -c x_samhain.c; \
     1111        rm x_samhain.c; \
     1112        $(LINK) sh_tiger_i.o $(CUTEST_OBJECTS) CuTestMain.o CuTest.o $(OBJECTS) $(LIBS_TRY); \
     1113        ./cutest
    10831114
    10841115samhain_hide.o: $(srcsrc)/samhain_hide.c samhain_erase.o
     
    15961627sh_static.o: $(srcsrc)/sh_static.c Makefile config_xor.h
    15971628sh_prelude_old.o: $(srcsrc)/sh_prelude_old.c Makefile config_xor.h $(srcinc)/slib.h $(srcinc)/sh_mem.h $(srcinc)/sh_cat.h $(srcinc)/sh_error_min.h $(srcinc)/sh_prelude.h $(srcinc)/sh_static.h
     1629sh_async.o: $(srcsrc)/sh_async.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_calls.h $(srcinc)/sh_error.h
  • trunk/aclocal.m4

    r1 r18  
    12021202])dnl
    12031203
     1204dnl checks for a known 64 bit programming environment
     1205dnl AC_RUN_IFELSE(PROGRAM,
     1206dnl               [ACTION-IF-TRUE], [ACTION-IF-FALSE],
     1207dnl               [ACTION-IF-CROSS-COMPILING = RUNTIME-ERROR])
     1208dnl
     1209AC_DEFUN([SAMHAIN_PRG_ENV],[
     1210    AC_MSG_CHECKING([for a known 64 bit programming environment])
     1211    # Compile and run a program that determines the programming environment
     1212    AC_RUN_IFELSE([
     1213      AC_LANG_SOURCE([[
     1214#include <stdio.h>
     1215int main(int argc,char **argv)
     1216{
     1217  if (argc > 1) {
     1218#if defined(__arch64__)
     1219  printf("__arch64__\n");
     1220#elif defined(__ia64__)
     1221  printf("__ia64__\n");
     1222#elif defined(__x86_64__)
     1223  printf("__x86_64__\n");
     1224#elif defined(__LP64__)
     1225  printf("__LP64__\n");
     1226#elif defined(__64BIT__)
     1227  printf("__64BIT__\n");
     1228#elif defined(_LP64)
     1229  printf("_LP64\n");
     1230#elif defined(_M_IA64)
     1231  printf("_M_IA64\n");
     1232#elif defined(_MIPS_SZLONG) && (_MIPS_SZLONG == 64)
     1233  printf("_MIPS_64\n");
     1234#else
     1235choke me
     1236#endif
     1237  }
     1238  return 0;
     1239}
     1240      ]])
     1241    ],[
     1242      # Program compiled and ran, so get version by adding argument.
     1243      samhain_prg_ENV=`./conftest$ac_exeext x`
     1244      samhain_64=yes
     1245      AC_MSG_RESULT([$samhain_prg_ENV])
     1246    ],[
     1247      AC_MSG_RESULT([none])
     1248        ],[
     1249      AC_MSG_RESULT([none])
     1250        ])
     1251])dnl
     1252
     1253AC_DEFUN([SAMHAIN_X86_64],[
     1254        AC_MSG_CHECKING([for x86_64])
     1255        AC_TRY_RUN([
     1256int main() {
     1257__asm__ volatile (
     1258"movq %rax, %rax"
     1259);
     1260return 0;
     1261}
     1262        ],
     1263        [
     1264        AC_MSG_RESULT(yes)
     1265        samhain_64=yes
     1266        tiger_src=sh_tiger1_64.c
     1267        AC_DEFINE([TIGER_OPT_ASM],1,[Define to use tiger x86_64 optimized assembly])
     1268        ],
     1269        [
     1270        AC_MSG_RESULT([no])
     1271        ],[
     1272        AC_MSG_RESULT([no])
     1273        ])
     1274])dnl
     1275
     1276
     1277AC_DEFUN([SAMHAIN_64],[
     1278samhain_64=no
     1279tiger_src=sh_tiger1.c
     1280#
     1281# if sizeof(unsigned long) = 4, try compiler macros for 64bit
     1282#
     1283if test "x$ac_cv_sizeof_unsigned_long" = x4; then
     1284  if test "x$ac_cv_sizeof_unsigned_long_long" = x8; then
     1285        SAMHAIN_PRG_ENV
     1286        if test "x$samhain_64" = xyes; then
     1287          tiger_src=sh_tiger1_64.c
     1288        fi
     1289        #
     1290        # if GCC and __i386__, use precompiled assembler
     1291        #
     1292        if test "x$GCC" = xyes; then
     1293          AC_MSG_CHECKING([for i386])
     1294          samhain_i386=no
     1295          touch conf_foo.h
     1296          $CC -E -dM conf_foo.h | egrep '__i386__' >/dev/null 2>&1 && samhain_i386=yes
     1297          rm -f conf_foo.h
     1298          if test "x$samhain_i386" = xyes; then
     1299            tiger_src=sh_tiger1.s
     1300            AC_DEFINE([TIGER_32_BIT_S],1,[Define to use tiger 32 bit i386 assembler])
     1301          fi
     1302          AC_MSG_RESULT([$samhain_i386])
     1303        fi
     1304        #
     1305        #
     1306        #
     1307  else
     1308        samhain_64=no
     1309        tiger_src=sh_tiger1.c
     1310  fi
     1311else
     1312  #
     1313  # sizeof(unsigned long) = 8
     1314  #
     1315  tiger_src=sh_tiger1_64.c
     1316  samhain_64=yes
     1317  #
     1318  # check for x86_64 (enables assembly optimizations)
     1319  #
     1320  if test "x$GCC" = xyes; then
     1321    SAMHAIN_X86_64
     1322  fi
     1323fi
     1324if test "x$samhain_64" = xyes; then
     1325        AC_DEFINE([TIGER_64_BIT],1,[Define to use tiger 64 bit implementation])
     1326fi
     1327AC_MSG_CHECKING([for 64 bit environment])
     1328AC_MSG_RESULT([$samhain_64])
     1329AC_MSG_CHECKING([for tiger source to use])
     1330AC_MSG_RESULT([$tiger_src])
     1331AC_SUBST(tiger_src)
     1332])dnl
     1333
     1334
    12041335dnl Autoconf macros for libprelude
    12051336dnl $id$
  • trunk/configure.ac

    r5 r18  
    3737dnl start
    3838dnl
    39 AM_INIT_AUTOMAKE(samhain, 2.1.1a)
     39AM_INIT_AUTOMAKE(samhain, 2.2.0rc1)
    4040AC_CANONICAL_HOST
    4141
     
    439439fi
    440440
     441dnl
     442dnl check for 64 bit programming environment
     443dnl
     444SAMHAIN_64
     445
     446
    441447dnl *****************************************
    442448dnl     checks for structures
     
    651657LIBWRAP_INC=""
    652658AC_ARG_WITH(libwrap,
    653 [ --with-libwrap[=PATH] Compile in libwrap (TCP Wrappers) support],
     659[  --with-libwrap[=PATH]                Compile in libwrap (TCP Wrappers) support],
    654660[ AC_MSG_RESULT($withval)
    655661  case "$withval" in
     
    711717
    712718AC_ARG_WITH(libprelude-prefix,
    713           [  --with-libprelude-prefix=PFX   Prefix where libprelude is installed (optional)],
     719          [  --with-libprelude-prefix=PFX       Prefix where libprelude is installed (optional)],
    714720          libprelude_config_prefix="$withval", libprelude_config_prefix="")
    715721
    716722AC_MSG_CHECKING(whether to use prelude)
    717723AC_ARG_WITH(prelude, 
    718         [  --with-prelude       Prelude IDS support [[no]]],
     724        [  --with-prelude               Prelude IDS support [[no]]],
    719725        [
    720726        if test "x${withval}" = "xno"; then
     
    11561162
    11571163AC_ARG_WITH(console,
    1158         [  --with-console=PATH          set path to console device [[/dev/console]]],
     1164        [  --with-console=PATH           set path to console device [[/dev/console]]],
    11591165        [
    11601166        if test "x${withval}" != xno; then
     
    11651171
    11661172AC_ARG_WITH(altconsole,
    1167         [  --with-altconsole=PATH       set path to second console device [[none]]],
     1173        [  --with-altconsole=PATH        set path to second console device [[none]]],
    11681174        [
    11691175        if test "x${withval}" != xno; then
     
    11771183
    11781184AC_ARG_WITH(timeserver,
    1179         [  --with-timeserver=HOST       set host address for time server [[none]]],
     1185        [  --with-timeserver=HOST        set host address for time server [[none]]],
    11801186        [
    11811187        if test "x${withval}" != xno; then
     
    11901196
    11911197AC_ARG_WITH(alttimeserver,
    1192         [  --with-alttimeserver=HOST    set address for backup time server [[none]]],
     1198        [  --with-alttimeserver=HOST     set address for backup time server [[none]]],
    11931199        [
    11941200        if test "x${withval}" != xno; then
     
    12121218
    12131219AC_ARG_ENABLE(mounts-check,
    1214         [  --enable-mounts-check       check mount options on filesystems [[no]]],
     1220        [  --enable-mounts-check                check mount options on filesystems [[no]]],
    12151221        [
    12161222        if test "x${enable_mounts_check}" = xyes; then
     
    12211227
    12221228AC_ARG_ENABLE(userfiles,
    1223        [  --enable-userfiles           check for users' config files [[no]]],
     1229       [  --enable-userfiles            check for users' config files [[no]]],
    12241230       [
    12251231       if test "x${enableval}" = "xyes"; then
     
    16481654sh_syscalltable="0x0"
    16491655AC_ARG_ENABLE(khide,
    1650         [  --enable-khide=SYSTEM_MAP            use kernel module to hide (Linux only)[[/boot/System.map]]],
     1656        [  --enable-khide=SYSTEM_MAP    use kernel module to hide (Linux only)[[/boot/System.map]]],
    16511657        [
    16521658        if test "x${enable_khide}" != xno; then
     
    17501756sh_libkvm=""
    17511757AC_ARG_WITH(kcheck,
    1752         [  --with-kcheck=SYSTEM_MAP     check Linux kernel integrity [[/boot/System.map]]],
     1758        [  --with-kcheck[[=SYSTEM_MAP]] check Linux/FreeBSD/OpenBSD kernel integrity [[/boot/System.map]]],
    17531759        [
    17541760        if test "x${withval}" != "xno"; then
     
    19881994        do
    19891995                case ${sh_item} in
     1996                *@localhost)
     1997                ;;
    19901998                *@*.*)
    19911999                sh_tmp=`echo ${sh_item} | awk '{ if ($1 ~ [/^[a-zA-Z0-9][a-zA-Z0-9\-_\.]*@[a-zA-Z0-9\-\.]+\.([a-zA-Z]+|[0-9]+)$/]) {print 1; } else { print 0}}'`
  • trunk/depend.dep

    r1 r18  
    5858sh_prelink.o: $(srcsrc)/sh_prelink.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_tiger.h $(srcinc)/sh_extern.h $(srcinc)/sh_utils.h $(srcinc)/sh_unix.h
    5959sh_static.o: $(srcsrc)/sh_static.c Makefile config_xor.h
     60sh_prelude_old.o: $(srcsrc)/sh_prelude_old.c Makefile config_xor.h $(srcinc)/slib.h $(srcinc)/sh_mem.h $(srcinc)/sh_cat.h $(srcinc)/sh_error_min.h $(srcinc)/sh_prelude.h $(srcinc)/sh_static.h
    6061kern_head.o: $(srcsrc)/kern_head.c Makefile config.h $(srcinc)/kern_head.h $(srcinc)/kern_head.h
    61 sh_prelude_old.o: $(srcsrc)/sh_prelude_old.c Makefile config_xor.h $(srcinc)/slib.h $(srcinc)/sh_mem.h $(srcinc)/sh_cat.h $(srcinc)/sh_error_min.h $(srcinc)/sh_prelude.h $(srcinc)/sh_static.h
     62sh_async.o: $(srcsrc)/sh_async.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_calls.h $(srcinc)/sh_error.h
  • trunk/depend.sum

    r1 r18  
    1 1152497988
     13476546078
  • trunk/docs/Changelog

    r5 r18  
     12.2.0:
     2        * added a bit of unit testing
     3        * improved the windows howto according to suggestions by
     4          Jorge Morgado
     5        * minor optimizations in various places
     6        * optimized implementation of tiger checksum algorithm
     7        * read in 64k blocks (faster than 4k)
     8        * sh_unix.c, sh_hash.c: support file flags on *BSD, update Linux
     9          file attribute code
     10        * kern_head: fix compilation of kernel check module on OpenBSD
     11        * updated samhainrc.linux, samhainrc.freebsd
     12        * sh_unix.c: fix setrlimit (RLIMIT_NOFILE, ..)
     13        * sh_files.c: fix missing use of flag_err_info
     14        * sh_tiger0.c: remove repetitive use of mlock
     15        * slib.c: remove fcntl's from sl_read_timeout (caller sets O_NONBLOCK),
     16          add function sl_read_timeout_prep
     17
     182.1.2 (10-01-2006):
     19        * fix startup error with combination of gpg+prelude
    120
    2212.1.1a (22-12-2005):
  • trunk/docs/HOWTO-samhain-on-windows.html

    r1 r18  
    135135<b>Cygwin</b> POSIX emulation layer, and how to install it as a service.
    136136These instructions have been written by Kris Dom,
    137 who has tested this on WinXP Professional.
     137who has tested this on WinXP Professional, with additions by Geries Handal
     138and Jorge Morgado.
    138139</p>
    139140<div class="block">
     
    150151logging) because Interix does not provide some of the required functionality
    151152to build the email module. This issue should be fixed as of samhain
    152 version 2.0.7 (not tested).<br />[Based on information kindly provided by Geries Handal].
     153version 2.0.7 (not tested).<br />
     154[Based on information kindly provided by Geries Handal].
    153155</p>
    154156</div>
     
    192194</li>
    193195</ul>
     196<div class="block">
     197<p>
     198You don't need to download and install All packages. It is enough to keep
     199the Default and then add the following additional packages:
     200</p>
     201<p>
     202  Category Devel -> gcc: C compiler upgrade helper<br/>
     203  Category Devel -> make: The GNU version of the 'make' utility<br/>
     204  Category Libs  -> minires: A simple synchronous non caching stub resolver<br/>
     205</p>
     206<p>
     207When selecting these packages, Cygwin installer will automatically add
     208other packages based on their dependencies.
     209The package minires is only necessary for a minimal Cygwin installation
     210(below). [Kindly pointed out by Jorge Morgado].
     211</p>
     212</div>
    194213
    195214<h3>Cygwin installation</h3>
     
    301320 </li>
    302321 </ul>
     322</li>
     323<li>
     324Files needed from c:\Cygwin\bin to create the /etc/passwd and /etc/group files:
     325 <ul>
     326 <li>
     327 mkpasswd.exe
     328 </li>
     329 <li>
     330 mkgroup.exe
     331 </li>
     332 </ul>
     333<p>
     334To generate these files on a minimal Cygwin installation execute - on a
     335Windows Command Prompt:
     336</p><p>
     337&nbsp; &nbsp;<tt>mkdir c:\etc</tt><br />
     338&nbsp; &nbsp;<tt>path\to\mkpasswd.exe -l > c:\etc\passwd</tt><br />
     339&nbsp; &nbsp;<tt>path\to\mkgroup.exe -l > c:\etc\group</tt>
     340</p><p>
     341IMPORTANT NOTE: You should re-create these two files, each time the
     342Windows users and groups accounts database changes. Failing to do this
     343might generate critical log messages (depending on your configuration
     344file).
     345</p>
    303346</li>
    304347<li>
     
    331374  </li>
    332375  <li>Under the newly created &quot;Parameters&quot; key, add a new String
    333   value called &quot;Applications&quot;.<br />
    334   &nbsp; &nbsp;The value for &quot;Applications&quot;
     376  value called &quot;Application&quot;.<br />
     377  &nbsp; &nbsp;The value for &quot;Application&quot;
    335378  should be &quot;c:\usr\local\sbin\samhain.exe&quot;.</li>
    336379  </ul>
     
    348391</li>
    349392</ul>
     393<p>
     394Also see <a href="http://support.microsoft.com/kb/q137890/">http://support.microsoft.com/kb/q137890/</a> for information regarding the creation of a
     395user-defined service.
     396</p>
    350397<p>
    351398Note: the first time I tried to install samhain as an NT service, I first
     
    354401Samhain as a service.
    355402</p>
     403
     404
     405<h2>Troubleshooting samhain</h2>
     406
     407<p>
     408[Tip from Jorge Morgado] If you, like me, have a Windows server not part of any domain and (for
     409security reasons) you even turn off DNS resolution, you might probably get
     410the following error when initializing the baseline database:
     411</p>
     412<pre>
     413  ---------   sh_unix.c  ---   1487 ---------
     414  According to uname, your nodename is yourcomputername, but your resolver
     415  library cannot resolve this nodename to a FQDN.
     416  Rather, it resolves this to yourcomputername.
     417  For more information, see the entry about self-resolving under
     418  'Most frequently' in the FAQ that you will find in the docs/ subdirectory
     419  ----------------------------------------------
     420</pre>
     421<p>
     422To fix this problem open the Registry Editor and create the following
     423entries under the key
     424HKLM\System\CurrentControlSet\Services\Tcpip\Parameters
     425</p>
     426<p>
     427<tt>
     428Name: Domain<br/>
     429Type: REG_SZ<br/>
     430Data: your.domain.name
     431</tt>
     432</p><p>
     433<tt>
     434Name: NV Domain<br/>
     435Type: REG_SZ<br/>
     436Data: your.domain.name
     437</tt>
     438</p><p>
     439The NV Domain registry value contains the computer's primary DNS suffix
     440while the Domain registry value contains the computer's primary DNS
     441domain. This will make the warning message go away.
     442</p>
    356443</div>
    357444</body>
  • trunk/docs/README.UPGRADE

    r1 r18  
     1since 2.1.0: update and daemon mode can be combined
     2
     3  -- this implies that '-t update' will start a daemon process if running as
     4     daemon is the default specified in the config file. use '--foreground'
     5     to avoid starting a daemon process
     6
     7
    18
    29from 1.7.x to 1.8.x: client/server encryption protocol has been enhanced
  • trunk/docs/TODO

    r1 r18  
    11
    2 Wishlist:
    3 
    4  - yule -> yule relay
    5  - partial checksum of growing logfiles
    6  
  • trunk/include/samhain.h

    r1 r18  
    6060 */
    6161#define PW_LEN     8
    62 
    63 /* Buffer for privileged content.
    64  */
    65 #define PRIV_MAX  4096   
    6662
    6763#undef  GOOD
  • trunk/samhainrc.linux

    r14 r18  
    177177dir = -1/var/tmp
    178178dir = -1/var/lib/texmf
     179dir = -1/var/lib/scrollkeeper
     180
    179181
    180182[Attributes]
     
    229231file = /var/log/*.old
    230232file = /var/log/*/*.[0-9].gz
     233file = /var/log/*/*.[0-9][0-9].gz
    231234file = /var/log/*/*.log.[0-9]
    232235
  • trunk/src/samhain.c

    r1 r18  
    10751075 *
    10761076 *******************************************************/
     1077#if !defined(SH_CUTEST)
    10771078int main(int argc, char * argv[])
     1079#else
     1080int undef_main(int argc, char * argv[])
     1081#endif
    10781082{
    10791083#if defined(INET_SYSLOG)
  • trunk/src/sh_database.c

    r13 r18  
    10641064        }
    10651065
     1066      /* Read in defaults from /etc/my.cnf and associated files,
     1067       * suggested by arjones at simultan dyndns org
     1068       * see: - http://dev.mysql.com/doc/refman/5.0/en/option-files.html
     1069       *        for the my.cnf format,
     1070       *      - http://dev.mysql.com/doc/refman/5.0/en/mysql-options.html
     1071       *        for possible options
     1072       * We don't check the return value because it's useless (failure due
     1073       * to lack of access permission is not reported).
     1074       */
     1075      mysql_options(db_conn, MYSQL_READ_DEFAULT_GROUP, _("samhain"));
     1076
    10661077      status = 0;
    10671078 
  • trunk/src/sh_hash.c

    r10 r18  
    396396static int hashfunc(char *s)
    397397{
    398   unsigned n = 0;
     398  unsigned int n = 0;
    399399
    400400  for ( ; *s; s++)
    401401    n = 31 * n + *s;
    402   return n & 0xFFFF;/* % TABSIZE*/;
     402
     403  return n & (TABSIZE - 1); /* % TABSIZE */;
    403404}
    404405
  • trunk/src/sh_tiger0.c

    r11 r18  
    2525#include "sh_utils.h"
    2626
    27 #if defined(HAVE_LONG_64) || defined(HAVE_LONG_LONG_64)
     27#define PRIV_MAX  32768
     28
     29#if defined(TIGER_64_BIT)
    2830#if defined(HAVE_LONG_64)
    2931typedef unsigned long int word64;
     32#elif defined(HAVE_LONG_LONG_64)
     33typedef unsigned long long int word64;
    3034#else
    31 typedef unsigned long long int word64;
     35#error No 64 bit type found !
    3236#endif
    3337#endif
     
    4650#define GPGFORMAT (_("%08X %08X %08X  %08X %08X %08X"))
    4751#else
    48 #error No 32 byte type found !
     52#error No 32 bit type found !
    4953#endif
    5054
     
    5458#define FIL__  _("sh_tiger0.c")
    5559
    56 #if defined(HAVE_LONG_64) || defined(HAVE_LONG_LONG_64)
    57 /* #ifdef HAVE_LONG_64 */
     60#if defined(TIGER_64_BIT)
     61
    5862void tiger_t(word64 *str, word64 length, word64 * res);
    5963void tiger(word64 *str, word64 length, word64 * res);
     
    97101static sh_byte buffer[PRIV_MAX + 72];
    98102
    99 #if defined(HAVE_LONG_64) || defined(HAVE_LONG_LONG_64)
    100 /* #ifdef HAVE_LONG_64 */
     103#if defined(TIGER_64_BIT)
    101104static
    102105word64 * sh_tiger_hash_val (char * filename, TigerType what,
     
    114117  char    * tmp;
    115118  sh_byte * bptr;
    116   /* sh_byte buffer[PRIV_MAX + 72]; */
    117119  sh_byte bbuf[64];
    118120
     
    131133#endif
    132134
    133 #if defined(HAVE_LONG_64) || defined(HAVE_LONG_LONG_64)
    134   /* #ifdef HAVE_LONG_64 */
     135#if defined(TIGER_64_BIT)
    135136#define TIGER_CAST (word64*)
    136137  static word64 res[3];
     
    254255          }
    255256       
    256         if (blk < 64) /* this must be (PRIV_MAX / 64) */
     257        if (blk < (PRIV_MAX / 64)) /* this must be (PRIV_MAX / 64) */
    257258          break;
    258259
     
    359360    bptr = buffer;
    360361
    361     memcpy(bptr, bbuf,    64); bptr +=   64;
    362     memcpy(bptr, bbuf,    64); bptr +=   64;
    363     memcpy(bptr, buffer, 128); bptr +=  128;
    364     memcpy(bptr, buffer, 256); bptr +=  256;
    365     memcpy(bptr, buffer, 512); bptr +=  512;
    366     memcpy(bptr, buffer,1024); bptr += 1024;
    367     memcpy(bptr, buffer,2048);
     362    memcpy(bptr, bbuf,     64); bptr +=    64;
     363    memcpy(bptr, bbuf,     64); bptr +=    64;
     364    memcpy(bptr, buffer,  128); bptr +=   128;
     365    memcpy(bptr, buffer,  256); bptr +=   256;
     366    memcpy(bptr, buffer,  512); bptr +=   512;
     367    memcpy(bptr, buffer, 1024); bptr +=  1024;
     368    memcpy(bptr, buffer, 2048); bptr +=  2048;
     369    memcpy(bptr, buffer, 4096); bptr +=  4096;
     370    memcpy(bptr, buffer, 8192); bptr +=  8192;
     371    memcpy(bptr, buffer,16384);
    368372
    369373    if (what == TIGER_FILE)
     
    814818                       MSG_E_SUBGEN, _("Not TIGER_FD"),
    815819                       _("sh_tiger_md5_hash"));
     820      out[0] = '\0';
    816821      return out;
    817822    }
     
    13281333                       MSG_E_SUBGEN, _("Not TIGER_FD"),
    13291334                       _("sh_tiger_sha1_hash"));
     1335      out[0] = '\0';
    13301336      return out;
    13311337    }
     
    14101416                                      unsigned long Length, int timeout)
    14111417{
    1412 #if defined(HAVE_LONG_64) || defined(HAVE_LONG_LONG_64)
    1413   /* #ifdef HAVE_LONG_64 */
     1418#if defined(TIGER_64_BIT)
    14141419  word64 * res;
    14151420#else
     
    14251430    {
    14261431      /*@-bufferoverflowhigh -formatconst@*/
    1427 #if defined(HAVE_LONG_64) || defined(HAVE_LONG_LONG_64)
    1428       /* #ifdef HAVE_LONG_64 */
     1432#if defined(TIGER_64_BIT)
    14291433      sprintf(out,                                   /* known to fit  */
    14301434              MYFORMAT,
     
    14611465  char * out;
    14621466  char   outhash[48+6+1];
    1463 #if defined(HAVE_LONG_64) || defined(HAVE_LONG_LONG_64)
    1464   /* #ifdef HAVE_LONG_64 */
     1467#if defined(TIGER_64_BIT)
    14651468  word64 * res;
    14661469#else
     
    14741477    {
    14751478      /*@-bufferoverflowhigh -formatconst@*/
    1476 #if defined(HAVE_LONG_64) || defined(HAVE_LONG_LONG_64)
    1477       /* #ifdef HAVE_LONG_64 */
     1479#if defined(TIGER_64_BIT)
    14781480      sprintf(outhash,                               /* known to fit  */
    14791481              GPGFORMAT,
     
    15301532                               unsigned long Length)
    15311533{
    1532 #if defined(HAVE_LONG_64) || defined(HAVE_LONG_LONG_64)
    1533   /* #ifdef HAVE_LONG_64 */
     1534#if defined(TIGER_64_BIT)
    15341535  word64 * res;
    15351536#else
     
    15481549  if (res != NULL)
    15491550    {
    1550 #if defined(HAVE_LONG_64) || defined(HAVE_LONG_LONG_64)
    1551       /* #ifdef HAVE_LONG_64 */
     1551#if defined(TIGER_64_BIT)
    15521552        out[0] =  (UINT32)(res[0]>>32);
    15531553        out[1] =  (UINT32)(res[0]);
  • trunk/src/sh_tiger1.c

    r1 r18  
    55#include "config_xor.h"
    66
    7 
    8 #if !defined(HAVE_LONG_64) && !defined(HAVE_LONG_LONG_64)
     7/* we already inline in the function used for file checksums */
     8/* #define UNROLL_COMPRESS */
     9#undef UNROLL_COMPRESS
     10
     11#if !defined(TIGER_64_BIT)
    912
    1013/* Tiger: A Fast New Hash Function
     
    3740typedef unsigned short sh_word32;
    3841#else
    39 #error No 32 byte type found !
     42#error No 32 bit type found !
    4043#endif
    4144
     
    4649#define BIG_ENDIAN
    4750#endif
    48 
    49 /* NOTE that this code is NOT FULLY OPTIMIZED for any  */
    50 /* machine. Assembly code might be much faster on some */
    51 /* machines, especially if the code is compiled with   */
    52 /* gcc.                                                */
    5351
    5452/* The number of passes of the hash function.          */
     
    6563#define t4 (tiger_table+256*3)
    6664
    67 #define sh_sub64(s0, s1, p0, p1) \
     65#define sub64(s0, s1, p0, p1) \
    6866      temps0 = (p0); \
    6967      tcarry = s0 < temps0; \
     
    7169      s1 -= (p1) + tcarry;
    7270
    73 #define sh_add64(s0, s1, p0, p1) \
     71#define add64(s0, s1, p0, p1) \
    7472      temps0 = (p0); \
    7573      s0 += temps0; \
     
    7775      s1 += (p1) + tcarry;
    7876
    79 #define sh_xor64(s0, s1, p0, p1) \
     77#define xor64(s0, s1, p0, p1) \
    8078      s0 ^= (p0); \
    8179      s1 ^= (p1);
    8280
    83 #define sh_mul5(s0, s1) \
     81#define mul5(s0, s1) \
    8482      tempt0 = s0<<2; \
    8583      tempt1 = (s1<<2)|(s0>>30); \
    86       sh_add64(s0, s1, tempt0, tempt1);
    87 
    88 #define sh_mul7(s0, s1) \
     84      add64(s0, s1, tempt0, tempt1);
     85
     86#define mul7(s0, s1) \
    8987      tempt0 = s0<<3; \
    9088      tempt1 = (s1<<3)|(s0>>29); \
    91       sh_sub64(tempt0, tempt1, s0, s1); \
     89      sub64(tempt0, tempt1, s0, s1); \
    9290      s0 = tempt0; \
    9391      s1 = tempt1;
    9492
    95 #define sh_mul9(s0, s1) \
     93#define mul9(s0, s1) \
    9694      tempt0 = s0<<3; \
    9795      tempt1 = (s1<<3)|(s0>>29); \
    98       sh_add64(s0, s1, tempt0, tempt1);
    99 
    100 #define sh_save_abc \
     96      add64(s0, s1, tempt0, tempt1);
     97
     98#define save_abc \
    10199      aa0 = a0; \
    102100      aa1 = a1; \
     
    106104      cc1 = c1;
    107105
    108 #define sh_round(a0,a1,b0,b1,c0,c1,x0,x1,mul) \
    109       sh_xor64(c0, c1, x0, x1); \
     106#define roundX(a0,a1,b0,b1,c0,c1,x0,x1) \
     107      xor64(c0, c1, x0, x1); \
    110108      temp0  = t1[((c0)>>(0*8))&0xFF][0] ; \
    111109      temp1  = t1[((c0)>>(0*8))&0xFF][1] ; \
     
    116114      temp0 ^= t4[((c1)>>(2*8))&0xFF][0] ; \
    117115      temp1 ^= t4[((c1)>>(2*8))&0xFF][1] ; \
    118       sh_sub64(a0, a1, temp0, temp1); \
     116      sub64(a0, a1, temp0, temp1); \
    119117      temp0  = t4[((c0)>>(1*8))&0xFF][0] ; \
    120118      temp1  = t4[((c0)>>(1*8))&0xFF][1] ; \
     
    125123      temp0 ^= t1[((c1)>>(3*8))&0xFF][0] ; \
    126124      temp1 ^= t1[((c1)>>(3*8))&0xFF][1] ; \
    127       sh_add64(b0, b1, temp0, temp1); \
    128       if((mul)==5) \
    129         {sh_mul5(b0, b1);} \
    130       else \
    131         if((mul)==7) \
    132           {sh_mul7(b0, b1);} \
    133         else \
    134           {sh_mul9(b0, b1)};
    135 
    136 #define sh_pass(a0,a1,b0,b1,c0,c1,mul) \
    137       sh_round(a0,a1,b0,b1,c0,c1,x00,x01,mul); \
    138       sh_round(b0,b1,c0,c1,a0,a1,x10,x11,mul); \
    139       sh_round(c0,c1,a0,a1,b0,b1,x20,x21,mul); \
    140       sh_round(a0,a1,b0,b1,c0,c1,x30,x31,mul); \
    141       sh_round(b0,b1,c0,c1,a0,a1,x40,x41,mul); \
    142       sh_round(c0,c1,a0,a1,b0,b1,x50,x51,mul); \
    143       sh_round(a0,a1,b0,b1,c0,c1,x60,x61,mul); \
    144       sh_round(b0,b1,c0,c1,a0,a1,x70,x71,mul);
    145 
    146 #define sh_key_schedule \
    147       sh_sub64(x00, x01, x70^0xA5A5A5A5, x71^0xA5A5A5A5); \
    148       sh_xor64(x10, x11, x00, x01); \
    149       sh_add64(x20, x21, x10, x11); \
    150       sh_sub64(x30, x31, x20^((~x10)<<19), ~x21^(((x11)<<19)|((x10)>>13))); \
    151       sh_xor64(x40, x41, x30, x31); \
    152       sh_add64(x50, x51, x40, x41); \
    153       sh_sub64(x60, x61, ~x50^(((x40)>>23)|((x41)<<9)), x51^((~x41)>>23)); \
    154       sh_xor64(x70, x71, x60, x61); \
    155       sh_add64(x00, x01, x70, x71); \
    156       sh_sub64(x10, x11, x00^((~x70)<<19), ~x01^(((x71)<<19)|((x70)>>13))); \
    157       sh_xor64(x20, x21, x10, x11); \
    158       sh_add64(x30, x31, x20, x21); \
    159       sh_sub64(x40, x41, ~x30^(((x20)>>23)|((x21)<<9)), x31^((~x21)>>23)); \
    160       sh_xor64(x50, x51, x40, x41); \
    161       sh_add64(x60, x61, x50, x51); \
    162       sh_sub64(x70, x71, x60^0x89ABCDEF, x61^0x01234567);
    163 
    164 #define sh_feedforward \
    165       sh_xor64(a0, a1, aa0, aa1); \
    166       sh_sub64(b0, b1, bb0, bb1); \
    167       sh_add64(c0, c1, cc0, cc1);
    168 
    169 #ifdef UNROLL_COMPRESS
    170 #define sh_compress \
    171       sh_save_abc \
    172       sh_pass(a0,a1,b0,b1,c0,c1,5); \
    173       sh_key_schedule; \
    174       sh_pass(c0,c1,a0,a1,b0,b1,7); \
    175       sh_key_schedule; \
    176       sh_pass(b0,b1,c0,c1,a0,a1,9); \
    177       for(pass_no=3; pass_no<PASSES; pass_no++) { \
    178         sh_key_schedule \
    179         sh_pass(a0,a1,b0,b1,c0,c1,9); \
    180         tmpa=a0; a0=c0; c0=b0; b0=tmpa; \
    181         tmpa=a1; a1=c1; c1=b1; b1=tmpa;} \
    182       sh_feedforward
    183 #else
    184 #define sh_compress \
    185       sh_save_abc \
    186       for(pass_no=0; pass_no<PASSES; pass_no++) { \
    187         if(pass_no != 0) {sh_key_schedule} \
    188         sh_pass(a0,a1,b0,b1,c0,c1,(pass_no==0?5:pass_no==1?7:9)) \
    189         tmpa=a0; a0=c0; c0=b0; b0=tmpa; \
    190         tmpa=a1; a1=c1; c1=b1; b1=tmpa;} \
    191       sh_feedforward
    192 #endif
     125      add64(b0, b1, temp0, temp1);
     126
     127
     128#define round5(a0,a1,b0,b1,c0,c1,x0,x1) \
     129      roundX(a0,a1,b0,b1,c0,c1,x0,x1); \
     130      mul5(b0, b1);
     131
     132#define round7(a0,a1,b0,b1,c0,c1,x0,x1) \
     133      roundX(a0,a1,b0,b1,c0,c1,x0,x1); \
     134      mul7(b0, b1);
     135
     136#define round9(a0,a1,b0,b1,c0,c1,x0,x1) \
     137      roundX(a0,a1,b0,b1,c0,c1,x0,x1); \
     138      mul9(b0, b1);
     139
     140
     141/* mixed with key_schedule
     142 */
     143#define pass5(a0,a1,b0,b1,c0,c1) \
     144      round5(a0,a1,b0,b1,c0,c1,x00,x01); \
     145      sub64(x00, x01, x70^0xA5A5A5A5, x71^0xA5A5A5A5); \
     146      round5(b0,b1,c0,c1,a0,a1,x10,x11); \
     147      xor64(x10, x11, x00, x01); \
     148      round5(c0,c1,a0,a1,b0,b1,x20,x21); \
     149      add64(x20, x21, x10, x11); \
     150      round5(a0,a1,b0,b1,c0,c1,x30,x31); \
     151      sub64(x30, x31, x20^((~x10)<<19), ~x21^(((x11)<<19)|((x10)>>13))); \
     152      round5(b0,b1,c0,c1,a0,a1,x40,x41); \
     153      xor64(x40, x41, x30, x31); \
     154      round5(c0,c1,a0,a1,b0,b1,x50,x51); \
     155      add64(x50, x51, x40, x41); \
     156      round5(a0,a1,b0,b1,c0,c1,x60,x61); \
     157      sub64(x60, x61, ~x50^(((x40)>>23)|((x41)<<9)), x51^((~x41)>>23)); \
     158      round5(b0,b1,c0,c1,a0,a1,x70,x71);
     159
     160/* mixed with key_schedule
     161 */
     162#define pass7(a0,a1,b0,b1,c0,c1) \
     163      round7(a0,a1,b0,b1,c0,c1,x00,x01); \
     164      sub64(x00, x01, x70^0xA5A5A5A5, x71^0xA5A5A5A5); \
     165      round7(b0,b1,c0,c1,a0,a1,x10,x11); \
     166      xor64(x10, x11, x00, x01); \
     167      round7(c0,c1,a0,a1,b0,b1,x20,x21); \
     168      add64(x20, x21, x10, x11); \
     169      round7(a0,a1,b0,b1,c0,c1,x30,x31); \
     170      sub64(x30, x31, x20^((~x10)<<19), ~x21^(((x11)<<19)|((x10)>>13))); \
     171      round7(b0,b1,c0,c1,a0,a1,x40,x41); \
     172      xor64(x40, x41, x30, x31); \
     173      round7(c0,c1,a0,a1,b0,b1,x50,x51); \
     174      add64(x50, x51, x40, x41); \
     175      round7(a0,a1,b0,b1,c0,c1,x60,x61); \
     176      sub64(x60, x61, ~x50^(((x40)>>23)|((x41)<<9)), x51^((~x41)>>23)); \
     177      round7(b0,b1,c0,c1,a0,a1,x70,x71);
     178
     179/* mixed with key_schedule
     180 */
     181#define pass9(a0,a1,b0,b1,c0,c1) \
     182      round9(a0,a1,b0,b1,c0,c1,x00,x01); \
     183      sub64(x00, x01, x70^0xA5A5A5A5, x71^0xA5A5A5A5); \
     184      round9(b0,b1,c0,c1,a0,a1,x10,x11); \
     185      xor64(x10, x11, x00, x01); \
     186      round9(c0,c1,a0,a1,b0,b1,x20,x21); \
     187      add64(x20, x21, x10, x11); \
     188      round9(a0,a1,b0,b1,c0,c1,x30,x31); \
     189      sub64(x30, x31, x20^((~x10)<<19), ~x21^(((x11)<<19)|((x10)>>13))); \
     190      round9(b0,b1,c0,c1,a0,a1,x40,x41); \
     191      xor64(x40, x41, x30, x31); \
     192      round9(c0,c1,a0,a1,b0,b1,x50,x51); \
     193      add64(x50, x51, x40, x41); \
     194      round9(a0,a1,b0,b1,c0,c1,x60,x61); \
     195      sub64(x60, x61, ~x50^(((x40)>>23)|((x41)<<9)), x51^((~x41)>>23)); \
     196      round9(b0,b1,c0,c1,a0,a1,x70,x71);
     197
     198#define key_schedule \
     199      xor64(x70, x71, x60, x61); \
     200      add64(x00, x01, x70, x71); \
     201      sub64(x10, x11, x00^((~x70)<<19), ~x01^(((x71)<<19)|((x70)>>13))); \
     202      xor64(x20, x21, x10, x11); \
     203      add64(x30, x31, x20, x21); \
     204      sub64(x40, x41, ~x30^(((x20)>>23)|((x21)<<9)), x31^((~x21)>>23)); \
     205      xor64(x50, x51, x40, x41); \
     206      add64(x60, x61, x50, x51); \
     207      sub64(x70, x71, x60^0x89ABCDEF, x61^0x01234567);
     208
     209#define feedforward \
     210      xor64(a0, a1, aa0, aa1); \
     211      sub64(b0, b1, bb0, bb1); \
     212      add64(c0, c1, cc0, cc1);
     213
     214#define compress \
     215      pass5(a0,a1,b0,b1,c0,c1); \
     216      key_schedule; \
     217      pass7(c0,c1,a0,a1,b0,b1); \
     218      key_schedule; \
     219      pass9(b0,b1,c0,c1,a0,a1); \
     220      feedforward
    193221
    194222#define tiger_compress_macro(str, state) \
    195223{ \
    196   register sh_word32 a0, a1, b0, b1, c0, c1, tmpa; \
     224  register sh_word32 a0, a1, b0, b1, c0, c1; \
    197225  sh_word32 aa0, aa1, bb0, bb1, cc0, cc1; \
    198226  sh_word32 x00, x01, x10, x11, x20, x21, x30, x31, \
    199          x40, x41, x50, x51, x60, x61, x70, x71; \
    200   register sh_word32 temp0, temp1, tempt0, tempt1, temps0, tcarry; \
    201   int pass_no; \
     227                  x40, x41, x50, x51, x60, x61, x70, x71; \
     228  sh_word32 temp0, temp1, tempt0, tempt1, temps0, tcarry; \
    202229\
    203230  a0 = state[0]; \
     
    208235  c1 = state[5]; \
    209236\
     237      save_abc \
     238\
    210239  x00=str[0*2]; x01=str[0*2+1]; x10=str[1*2]; x11=str[1*2+1]; \
    211240  x20=str[2*2]; x21=str[2*2+1]; x30=str[3*2]; x31=str[3*2+1]; \
     
    213242  x60=str[6*2]; x61=str[6*2+1]; x70=str[7*2]; x71=str[7*2+1]; \
    214243\
    215   sh_compress; \
     244  compress; \
    216245\
    217246  state[0] = a0; \
     
    223252}
    224253
    225 #ifdef UNROLL_COMPRESS
     254#if defined(UNROLL_COMPRESS)
    226255/* The compress function is inlined */
    227256#define tiger_compress(str, state) \
    228257  tiger_compress_macro(((sh_word32*)str), ((sh_word32*)state))
    229 #else
    230 /* The compress function is a function */
     258
     259#else
     260
    231261void
    232262tiger_compress(sh_word32 *str, sh_word32 state[6])
     
    249279#ifdef BIG_ENDIAN
    250280      for(j=0; j<64; j++)
    251         temp[j^3] = ((sh_byte*)str)[j];
    252       tiger_compress(((sh_word32*)temp), res);
    253 #else
    254       tiger_compress(str, res);
     281        temp[j^3] = ((sh_byte*)str)[j];
     282      tiger_compress_macro(((sh_word32*)temp), res);
     283#else
     284      tiger_compress_macro(str, res);
    255285#endif
    256286      str += 16;
     
    258288}
    259289
    260 void
    261 tiger(sh_word32 *str, sh_word32 length, sh_word32 res[6])
     290
     291void tiger(sh_word32 *str, sh_word32 length, sh_word32 res[6])
    262292{
    263293  register sh_word32 i, j;
    264294  sh_byte temp[64];
     295
     296  /*
     297   * res[0]=0x89ABCDEF;
     298   * res[1]=0x01234567;
     299   * res[2]=0x76543210;
     300   * res[3]=0xFEDCBA98;
     301   * res[4]=0xC3B2E187;
     302   * res[5]=0xF096A5B4;
     303   */
    265304
    266305  for(i=length; i>=64; i-=64)
     
    307346}
    308347
    309 #else
    310 void dummy_1 (int a)
    311 {
    312   (void) a;
    313   return;
    314 }
    315 #endif
    316 
    317 
    318 
    319 
    320 
    321 
    322 
    323 
    324 
     348#endif
     349
  • trunk/src/sh_tiger1_64.c

    r1 r18  
    55#include "config_xor.h"
    66
    7 #if defined(HAVE_LONG_64) || defined(HAVE_LONG_LONG_64)
    8 
    9 /*@-incondefs -macroparens -macroassign -macroparams -macrostmt @*/
    10 /*@-fixedformalarray +charindex -type -paramuse -predboolint -exportlocal@*/
     7#if defined(TIGER_64_BIT)
     8
     9/* #if defined(HAVE_LONG_64) || defined(HAVE_LONG_LONG_64) */
     10
     11#undef USE_MEMSET
     12
    1113/* Big endian:                                         */
    1214#ifdef WORDS_BIGENDIAN
    1315#define BIG_ENDIAN
    1416#endif
    15 
    1617
    1718/* Tiger: A Fast New Hash Function
     
    3839#if defined(HAVE_LONG_64)
    3940typedef unsigned long int word64;
    40 #else
     41#elif defined(HAVE_LONG_LONG_64)
    4142typedef unsigned long long int word64;
     43#else
     44#error No 64 bit type found !
    4245#endif
    4346
     
    4952typedef unsigned short sh_word32;
    5053#else
    51 #error No 32 byte type found !
     54#error No 32 bit type found !
    5255#endif
    5356
    5457typedef unsigned char sh_byte;
    5558
    56 /* Big endian:                                         
    57    #if !(defined(__alpha)||defined(__i386__)||defined(__vax__))
    58    #define BIG_ENDIAN
    59    #endif
    60 */
    61 
    62 /* The following macro denotes that an optimization    */
    63 /* for Alpha is required. It is used only for          */
    64 /* optimization of time. Otherwise it does nothing.    */
    65 #ifdef __alpha
    66 #define OPTIMIZE_FOR_ALPHA
    67 #endif
    68 
    69 /* NOTE that this code is NOT FULLY OPTIMIZED for any  */
    70 /* machine. Assembly code might be much faster on some */
    71 /* machines, especially if the code is compiled with   */
    72 /* gcc.                                                */
    73 
    74 /* The number of passes of the hash function.          */
    75 /* Three passes are recommended.                       */
    76 /* Use four passes when you need extra security.       */
    77 /* Must be at least three.                             */
     59#if defined(TIGER_OPT_ASM)
     60#define TIGER_ASM64_2 1
     61#else
     62#define TIGER_C 1
     63#endif
     64
     65/* The number of passes of the hash function.              */
     66/* Three passes are recommended.                           */
     67/* Use four passes when you need extra security.           */
     68/* Must be at least three.                                 */
    7869#define PASSES 3
    7970
    8071extern word64 tiger_table[4*256];
     72
     73/* Volatile can help if compiler is smart enough to use memory operand */
     74static /*volatile*/ const word64 XOR_CONST1=0xA5A5A5A5A5A5A5A5LL;
     75static /*volatile*/ const word64 XOR_CONST2=0x0123456789ABCDEFLL;
    8176
    8277#define t1 (tiger_table)
     
    8580#define t4 (tiger_table+256*3)
    8681
     82#define pass_start
     83#define pass_end
     84
     85
     86
    8787#define save_abc \
    88       aa = a; \
    89       bb = b; \
    90       cc = c;
    91 
    92 #ifdef OPTIMIZE_FOR_ALPHA
    93 /* This is the official definition of round */
    94 #define round(a,b,c,x,mul) \
    95       c ^= x; \
    96       a -= t1[((c)>>(0*8))&0xFF] ^ t2[((c)>>(2*8))&0xFF] ^ \
    97            t3[((c)>>(4*8))&0xFF] ^ t4[((c)>>(6*8))&0xFF] ; \
    98       b += t4[((c)>>(1*8))&0xFF] ^ t3[((c)>>(3*8))&0xFF] ^ \
    99            t2[((c)>>(5*8))&0xFF] ^ t1[((c)>>(7*8))&0xFF] ; \
    100       b *= mul;
    101 #else
    102 /* This code works faster when compiled on 32-bit machines */
    103 /* (but works slower on Alpha) */
    104 #define round(a,b,c,x,mul) \
    105       c ^= x; \
    106       a -= t1[(sh_byte)(c)] ^ \
    107            t2[(sh_byte)(((sh_word32)(c))>>(2*8))] ^ \
    108            t3[(sh_byte)((c)>>(4*8))] ^ \
    109            t4[(sh_byte)(((sh_word32)((c)>>(4*8)))>>(2*8))] ; \
    110       b += t4[(sh_byte)(((sh_word32)(c))>>(1*8))] ^ \
    111            t3[(sh_byte)(((sh_word32)(c))>>(3*8))] ^ \
    112            t2[(sh_byte)(((sh_word32)((c)>>(4*8)))>>(1*8))] ^ \
    113            t1[(sh_byte)(((sh_word32)((c)>>(4*8)))>>(3*8))]; \
    114       b *= mul;
    115 #endif
    116 
    117 #define pass(a,b,c,mul) \
    118       round(a,b,c,x0,mul) \
    119       round(b,c,a,x1,mul) \
    120       round(c,a,b,x2,mul) \
    121       round(a,b,c,x3,mul) \
    122       round(b,c,a,x4,mul) \
    123       round(c,a,b,x5,mul) \
    124       round(a,b,c,x6,mul) \
    125       round(b,c,a,x7,mul)
     88          aa = a; \
     89          bb = b; \
     90          cc = c;
     91
     92#ifdef TIGER_C
     93
     94#define BN(x,n) (((x)>>((n)*8))&0xFF)
     95
     96
     97/* Depending on outer code one of these two can be better*/
     98#define roundX(a,b,c,x) \
     99        c ^= x; \
     100        a -= t1[BN(c,0)] ^ t2[BN(c,2)] ^ \
     101             t3[BN(c,4)] ^ t4[BN(c,6)] ; \
     102        b += t4[BN(c,1)] ^ t3[BN(c,3)] ^ \
     103             t2[BN(c,5)] ^ t1[BN(c,7)] ;
     104
     105#define round5(a,b,c,x) roundX(a,b,c,x) b = b+b*4;
     106#define round7(a,b,c,x) roundX(a,b,c,x) b = b*8-b;
     107#define round9(a,b,c,x) roundX(a,b,c,x) b = b+b*8;
     108
     109#endif
     110
     111
     112#ifdef TIGER_OPT_ASM
     113
     114#define MASK0           0xFFL
     115#define MASK8           0xFF00L
     116#define MASK16          0xFF0000L
     117#define MASK32          0xFF00000000LL
     118#define MASK40          0xFF0000000000LL
     119#define MASK48          0xFF000000000000LL
     120
     121#define roundstart      __asm__ (
     122
     123/* a will be moved into different reg each round
     124 * using register substitution feature of  GCC asm
     125 * b will be moved in 2-nd pass rounds only
     126 */
     127
     128
     129#define roundend(a,b,c,x) \
     130 : "+r" (a), "+r" (b), "+r" (c) \
     131 : "0" (a), "1" (b), "2" (c), "m" (x), "r" (&tiger_table),\
     132  "i" (MASK0), "i" (MASK8), "i" (MASK16), "r" (MASK32), "r" (MASK40), "r" (MASK48) \
     133 : "3", "%rax","%rbx","%rcx","%rdx","%rsi", "%edi", "%r8"  );
     134
     135
     136/*      c ^= x;
     137        a -= t1[BN(c,0)] ^ t2[BN(c,2)] ^
     138        t3[BN(c,4)] ^ t4[BN(c,6)] ;
     139        b += t4[BN(c,1)] ^ t3[BN(c,3)] ^
     140        t2[BN(c,5)] ^ t1[BN(c,7)] ;     */
     141
     142#define roundX(a,b,c,x)   \
     143"       movl    %10, %%ebx      \n"\
     144"       movq    %11, %%rcx      \n"\
     145"       movq    %13, %%rdx      \n"\
     146"       movq    %6, %%r8  \n"\
     147"       xorq    %%r8, %2                 \n" \
     148"       andq    %2, %%rbx  \n"\
     149"       andq    %2, %%rcx  \n"\
     150"       andq    %2, %%rdx  \n"\
     151"       shrl    $(16-3), %%ebx  \n"\
     152"       shrq    $(32-3), %%rcx  \n"\
     153"       shrq    $(48-3), %%rdx  \n"\
     154"       movzbl  %2b, %%eax      \n"\
     155"       movzwl  %2w, %%edi      \n"\
     156"       movq    (%7,%%rax,8), %%rsi  \n"\
     157"       shrl    $(8), %%edi  \n" \
     158"       movq    %2, %%rax  \n" \
     159"       xorq    (2048*1)(%7,%%rbx), %%rsi  \n"\
     160"       movq    %2, %%rbx  \n"\
     161"       shrl    $24, %%eax \n"\
     162"       andq    %12, %%rbx      \n"\
     163"       xorq    (2048*2)(%7,%%rcx), %%rsi  \n"\
     164"       shrq    $(40-3), %%rbx \n"\
     165"       movq    %2, %%rcx  \n"\
     166"       xorq    (2048*3)(%7,%%rdx), %%rsi  \n"\
     167"       movq    (2048*3)(%7,%%rdi,8), %%rdx  \n"\
     168"       shrq    $56, %%rcx \n"\
     169"       xorq    (2048*2)(%7,%%rax,8), %%rdx  \n"\
     170"       xorq    (2048*1)(%7,%%rbx), %%rdx  \n" \
     171"       subq     %%rsi, %0 \n"\
     172"       xorq    (%7,%%rcx,8), %%rdx  \n"\
     173"       addq     %%rdx, %1 \n"
     174
     175#define round5(a,b,c,x) \
     176        roundstart \
     177        roundX(a,b,c,x) \
     178        /* b*=5; */ \
     179        "leaq   (%1,%1,4), %1\n" \
     180        roundend(a,b,c,x)
     181
     182
     183#define round7(a,b,c,x) \
     184        roundstart \
     185        roundX(a,b,c,x) \
     186        roundend(a,b,c,x) \
     187        /* b*=7; */ \
     188        __asm__ ( \
     189        "leaq   (%1,%1,8), %0\n" \
     190        "addq  %1, %1 \n" \
     191        "subq  %1, %0 " \
     192        :"=&r" (b): "r"(b): "1" );
     193
     194#define round9(a,b,c,x) \
     195        roundstart \
     196        roundX(a,b,c,x) \
     197        "leaq   (%1,%1,8), %1\n" \
     198        roundend(a,b,c,x)
     199
     200#endif
     201
     202
     203
     204
     205/* ============== Common macros ================== */
    126206
    127207#define key_schedule \
    128       x0 -= x7 ^ 0xA5A5A5A5A5A5A5A5LL; \
    129       x1 ^= x0; \
    130       x2 += x1; \
    131       x3 -= x2 ^ ((~x1)<<19); \
    132       x4 ^= x3; \
    133       x5 += x4; \
    134       x6 -= x5 ^ ((~x4)>>23); \
    135       x7 ^= x6; \
    136       x0 += x7; \
    137       x1 -= x0 ^ ((~x7)<<19); \
    138       x2 ^= x1; \
    139       x3 += x2; \
    140       x4 -= x3 ^ ((~x2)>>23); \
    141       x5 ^= x4; \
    142       x6 += x5; \
    143       x7 -= x6 ^ 0x0123456789ABCDEFLL;
     208        x0 -= x7 ^ XOR_CONST1; \
     209        x1 ^= x0; \
     210        x2 += x1;\
     211        x3 -= x2 ^ ((~x1)<<19);\
     212        x4 ^= x3;\
     213        x5 += x4;\
     214        x6 -= x5 ^ ((~x4)>>23); \
     215        x7 ^= x6; \
     216        x0 += x7; \
     217        x1 -= x0 ^ ((~x7)<<19); \
     218        x2 ^= x1; \
     219        x3 += x2; \
     220        x4 -= x3 ^ ((~x2)>>23); \
     221        x5 ^= x4; \
     222        x6 += x5; \
     223        x7 -= x6 ^ XOR_CONST2;
     224
     225#define pass5n(a,b,c) \
     226          round5(a,b,c,x0) \
     227        x0 -= x7 ^ XOR_CONST1; \
     228          round5(b,c,a,x1) \
     229        x1 ^= x0; \
     230          round5(c,a,b,x2) \
     231        x2 += x1; \
     232          round5(a,b,c,x3) \
     233        x3 -= x2 ^ ((~x1)<<19); \
     234          round5(b,c,a,x4) \
     235        x4 ^= x3; \
     236          round5(c,a,b,x5) \
     237        x5 += x4; \
     238          round5(a,b,c,x6) \
     239        x6 -= x5 ^ ((~x4)>>23); \
     240          round5(b,c,a,x7) \
     241        x7 ^= x6; \
     242        x0 += x7; \
     243        x1 -= x0 ^ ((~x7)<<19); \
     244        x2 ^= x1; \
     245        x3 += x2; \
     246        x4 -= x3 ^ ((~x2)>>23); \
     247        x5 ^= x4; \
     248        x6 += x5; \
     249        x7 -= x6 ^ XOR_CONST2;
     250
     251#define pass7n(a,b,c) \
     252          round7(a,b,c,x0) \
     253        x0 -= x7 ^ XOR_CONST1; \
     254          round7(b,c,a,x1) \
     255        x1 ^= x0; \
     256          round7(c,a,b,x2) \
     257        x2 += x1; \
     258          round7(a,b,c,x3) \
     259        x3 -= x2 ^ ((~x1)<<19); \
     260          round7(b,c,a,x4) \
     261        x4 ^= x3; \
     262          round7(c,a,b,x5) \
     263        x5 += x4; \
     264          round7(a,b,c,x6) \
     265        x6 -= x5 ^ ((~x4)>>23); \
     266          round7(b,c,a,x7) \
     267        x7 ^= x6; \
     268        x0 += x7; \
     269        x1 -= x0 ^ ((~x7)<<19); \
     270        x2 ^= x1; \
     271        x3 += x2; \
     272        x4 -= x3 ^ ((~x2)>>23); \
     273        x5 ^= x4; \
     274        x6 += x5; \
     275        x7 -= x6 ^ XOR_CONST2;
     276
     277#define pass5(a,b,c) \
     278        pass_start \
     279          round5(a,b,c,x0) \
     280          round5(b,c,a,x1) \
     281          round5(c,a,b,x2) \
     282          round5(a,b,c,x3) \
     283          round5(b,c,a,x4) \
     284          round5(c,a,b,x5) \
     285          round5(a,b,c,x6) \
     286          round5(b,c,a,x7) \
     287        pass_end
     288
     289#define pass7(a,b,c) \
     290        pass_start \
     291          round7(a,b,c,x0) \
     292          round7(b,c,a,x1) \
     293          round7(c,a,b,x2) \
     294          round7(a,b,c,x3) \
     295          round7(b,c,a,x4) \
     296          round7(c,a,b,x5) \
     297          round7(a,b,c,x6) \
     298          round7(b,c,a,x7) \
     299        pass_end
     300
     301
     302#define pass9(a,b,c) \
     303        pass_start \
     304          round9(a,b,c,x0) \
     305          round9(b,c,a,x1) \
     306          round9(c,a,b,x2) \
     307          round9(a,b,c,x3) \
     308          round9(b,c,a,x4) \
     309          round9(c,a,b,x5) \
     310          round9(a,b,c,x6) \
     311          round9(b,c,a,x7) \
     312        pass_end
    144313
    145314#define feedforward \
    146       a ^= aa; \
    147       b -= bb; \
    148       c += cc;
    149 
    150 #ifdef OPTIMIZE_FOR_ALPHA
    151 /* The loop is unrolled: works better on Alpha */
     315          a ^= aa; \
     316          b -= bb; \
     317          c += cc;
     318
     319
     320/* This version works ok with C variant and also with new asm version
     321 * that just wastes a register r8
     322 * reason? who knows, write forwarding is faster than keeping value
     323 * in register? :)
     324 */
    152325#define compress \
    153       save_abc \
    154       pass(a,b,c,5) \
    155       key_schedule \
    156       pass(c,a,b,7) \
    157       key_schedule \
    158       pass(b,c,a,9) \
    159       for(pass_no=3; pass_no<PASSES; pass_no++) { \
    160         key_schedule \
    161         pass(a,b,c,9) \
    162         tmpa=a; a=c; c=b; b=tmpa;} \
    163       feedforward
    164 #else
    165 /* loop: works better on PC and Sun (smaller cache?) */
    166 #define compress \
    167       save_abc \
    168       for(pass_no=0; pass_no<PASSES; pass_no++) { \
    169         if(pass_no != 0) {key_schedule} \
    170         pass(a,b,c,(pass_no==0?5:pass_no==1?7:9)); \
    171         tmpa=a; a=c; c=b; b=tmpa;} \
    172       feedforward
    173 #endif
     326        save_abc \
     327          pass5n(a,b,c) \
     328          pass7n(c,a,b) \
     329          pass9(b,c,a) \
     330          for(pass_no=3; pass_no<PASSES; pass_no++) { \
     331                key_schedule \
     332                pass9(a,b,c) \
     333                tmpa=a; a=c; c=b; b=tmpa; \
     334          } \
     335        feedforward
     336
     337#define compress_old \
     338        save_abc \
     339          pass5(a,b,c) \
     340          key_schedule \
     341          pass7(c,a,b) \
     342          key_schedule \
     343          pass9(b,c,a) \
     344          for(pass_no=3; pass_no<PASSES; pass_no++) { \
     345                key_schedule \
     346                pass9(a,b,c) \
     347                tmpa=a; a=c; c=b; b=tmpa; \
     348          } \
     349        feedforward
    174350
    175351#define tiger_compress_macro(str, state) \
    176352{ \
    177   register word64 a, b, c, tmpa; \
     353  register word64 a, b, c; \
     354  register word64 tmpa; \
    178355  word64 aa, bb, cc; \
    179   register word64 x0, x1, x2, x3, x4, x5, x6, x7; \
     356  word64 x0, x1, x2, x3, x4, x5, x6, x7; \
    180357  int pass_no; \
    181358\
     
    194371}
    195372
    196 /* The compress function is a function. Requires smaller cache?    */
    197373void tiger_compress(word64 *str, word64 state[3])
    198374{
    199 #ifndef S_SPLINT_S
    200375  tiger_compress_macro(((word64*)str), ((word64*)state));
    201 #endif
    202376}
    203 
    204 #ifdef OPTIMIZE_FOR_ALPHA
    205 /* The compress function is inlined: works better on Alpha.        */
    206 /* Still leaves the function above in the code, in case some other */
    207 /* module calls it directly.                                       */
    208 #define tiger_compress(str, state) \
    209   tiger_compress_macro(((word64*)str), ((word64*)state))
    210 #endif
    211377
    212378void tiger_t(word64 *str, word64 length, word64 res[3])
     
    220386
    221387  /*
    222     res[0]=0x0123456789ABCDEFLL;
    223     res[1]=0xFEDCBA9876543210LL;
    224     res[2]=0xF096A5B4C3B2E187LL;
    225   */
     388   * res[0]=0x0123456789ABCDEFLL;
     389   * res[1]=0xFEDCBA9876543210LL;
     390   * res[2]=0xF096A5B4C3B2E187LL;
     391   */
    226392
    227393  for(i=length; i>=64; i-=64)
     
    229395#ifdef BIG_ENDIAN
    230396      for(j=0; j<64; j++)
    231         temp[j^7] = ((sh_byte*)str)[j];
     397        temp[j^7] = ((sh_byte*)str)[j];
    232398      tiger_compress(((word64*)temp), res);
    233399#else
     
    236402      str += 8;
    237403    }
    238 
    239404}
    240405
     
    246411
    247412  /*
    248     res[0]=0x0123456789ABCDEFLL;
    249     res[1]=0xFEDCBA9876543210LL;
    250     res[2]=0xF096A5B4C3B2E187LL;
    251   */
     413   * res[0]=0x0123456789ABCDEFLL;
     414   * res[1]=0xFEDCBA9876543210LL;
     415   * res[2]=0xF096A5B4C3B2E187LL;
     416   */
    252417
    253418  for(i=length; i>=64; i-=64)
     
    255420#ifdef BIG_ENDIAN
    256421      for(j=0; j<64; j++)
    257         temp[j^7] = ((sh_byte*)str)[j];
     422        temp[j^7] = ((sh_byte*)str)[j];
    258423      tiger_compress(((word64*)temp), res);
    259424#else
     
    272437    temp[j^7] = 0;
    273438#else
     439
     440#ifndef USE_MEMSET
    274441  for(j=0; j<i; j++)
    275442    temp[j] = ((sh_byte*)str)[j];
    276 
     443#else
     444  memcpy( temp, str, j=i );
     445#endif
    277446  temp[j++] = 0x01;
    278447  for(; j&7; j++)
    279     temp[j] = 0;
    280 #endif
     448        temp[j] = 0;
     449
     450#endif
     451
    281452  if(j>56)
    282453    {
     454#ifndef USE_MEMSET
    283455      for(; j<64; j++)
    284456        temp[j] = 0;
     457#else
     458      memset( temp+j, 0, 64-j);
     459#endif
    285460      tiger_compress(((word64*)temp), res);
    286461      j=0;
    287462    }
    288463
     464#ifndef USE_MEMSET
    289465  for(; j<56; j++)
    290466    temp[j] = 0;
     467#else
     468  memset( temp+j, 0, 56-j);
     469#endif
     470
    291471  ((word64*)(&(temp[56])))[0] = ((word64)length)<<3;
    292472  tiger_compress(((word64*)temp), res);
    293473}
    294474
    295 #else
    296 
    297 void dummy_1_64 (int a)
    298 {
    299   (void) a;
    300   return;
    301 }
    302 
    303 #endif
    304 
    305 
    306 
    307 
    308 
    309 
    310 
    311 
    312 
     475#endif
  • trunk/src/sh_tiger2.c

    r1 r18  
    2323
    2424
    25 #if !defined(HAVE_LONG_64) && !defined(HAVE_LONG_LONG_64)
    26 
     25#if !defined(TIGER_64_BIT)
     26
     27/* #if !defined(HAVE_LONG_64) && !defined(HAVE_LONG_LONG_64) */
    2728
    2829/* sboxes32.c: Tiger S boxes for 32-bit-only compilers */
    29 typedef unsigned long word32;
    30 word32 tiger_table[4*256][2] = {
     30#if defined(HAVE_INT_32)
     31typedef unsigned int sh_word32;
     32#elif defined(HAVE_LONG_32)
     33typedef unsigned long sh_word32;
     34#elif defined(HAVE_SHORT_32)
     35typedef unsigned short sh_word32;
     36#else
     37#error No 32 bit type found !
     38#endif
     39
     40sh_word32 tiger_table[4*256][2] = {
    3141  { 0xF7E90C5E, 0x02AAB17C /*    0 */},  {  0xE243A8EC, 0xAC424B03 /*    1 */},
    3242  { 0x0DD5FCD3, 0x72CD5BE3 /*    2 */},  {  0xF6F97F3A, 0x6D019B93 /*    3 */},
  • trunk/src/sh_tiger2_64.c

    r1 r18  
    2222#include "config_xor.h"
    2323
    24 
    25 #if defined(HAVE_LONG_64) || defined(HAVE_LONG_LONG_64)
     24#if defined(TIGER_64_BIT)
     25
     26/* #if defined(HAVE_LONG_64) || defined(HAVE_LONG_LONG_64) */
    2627
    2728/*@-type@*/
     
    3031#if defined(HAVE_LONG_64)
    3132typedef unsigned long int word64;
     33#elif defined(HAVE_LONG_LONG_64)
     34typedef unsigned long long int word64;
    3235#else
    33 typedef unsigned long long int word64;
     36#error No 64 bit type found !
    3437#endif
    3538
  • trunk/src/sh_tools.c

    r12 r18  
    125125char * sh_tools_safe_name (const char * instr, int flag)
    126126{
    127   unsigned char c;
     127  unsigned char c, d;
    128128  const  char * p;
    129129  char   *q;
     
    133133  int    i = 0;
    134134  unsigned char   val_octal = '\0';
     135  static char ctable[16] = { '0', '1', '2', '3', '4', '5', '6', '7',
     136                             '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
    135137
    136138  SL_ENTER(_("sh_tools_safe_name"));
     
    202204            {
    203205              --i;
    204               sprintf(&outstr[i], "=%02x", c);          /* known to fit  */
     206              d = c % 16; c = c / 16;
     207              outstr[i] = '=';       ++i;
     208              outstr[i] = ctable[c]; ++i;
     209              outstr[i] = ctable[d]; ++i;
    205210            }
    206211
     
    274279            break;
    275280          default:
    276             if (strlen(p) < 3)
     281            if (strlen(p) < 3) /* certainly not an octal number, skip */
    277282              {
    278283                p += strlen(p);
     
    284289                if (val_octal != '\0') {
    285290                  c = val_octal;
    286                   sprintf(&outstr[i], "=%02x", c);       /* known to fit  */
    287                   i+=3;
     291                  d = c % 16; c = c / 16;
     292                  outstr[i] = '=';       ++i;
     293                  outstr[i] = ctable[c]; ++i;
     294                  outstr[i] = ctable[d]; ++i;
    288295                }
    289296                p += 3;
     
    294301        {
    295302          ++p;
    296           if (!p || !(*p))
    297             break;
     303          if (!p || !(*p))
     304            {
     305              outstr[i] = '&'; ++i;
     306              break;
     307            }
    298308
    299309          if (p[0] == 'a' && p[1] == 'm' && p[2] == 'p' && p[3] == ';')
  • trunk/src/sh_unix.c

    r10 r18  
    12831283     */
    12841284    if (0 == sl_strncmp((*env), _("MYSQL_UNIX_PORT="), 16))
     1285      {
     1286        ++(env);
     1287        continue;
     1288      }
     1289    if (0 == sl_strncmp((*env), _("MYSQL_TCP_PORT="), 15))
     1290      {
     1291        ++(env);
     1292        continue;
     1293      }
     1294    if (0 == sl_strncmp((*env), _("MYSQL_HOME="), 11))
    12851295      {
    12861296        ++(env);
Note: See TracChangeset for help on using the changeset viewer.