1 | #! /bin/sh
|
---|
2 |
|
---|
3 | #
|
---|
4 | # Copyright Rainer Wichmann (2006)
|
---|
5 | #
|
---|
6 | # License Information:
|
---|
7 | # This program is free software; you can redistribute it and/or modify
|
---|
8 | # it under the terms of the GNU General Public License as published by
|
---|
9 | # the Free Software Foundation; either version 2 of the License, or
|
---|
10 | # (at your option) any later version.
|
---|
11 | #
|
---|
12 | # This program is distributed in the hope that it will be useful,
|
---|
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
15 | # GNU General Public License for more details.
|
---|
16 | #
|
---|
17 | # You should have received a copy of the GNU General Public License
|
---|
18 | # along with this program; if not, write to the Free Software
|
---|
19 | # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
20 | #
|
---|
21 |
|
---|
22 | RCFILE="$PW_DIR/testrc_1.dyn"; export RCFILE
|
---|
23 | LOGFILE="$PW_DIR/.samhain_log"; export LOGFILE
|
---|
24 |
|
---|
25 | MAXTEST=2; export MAXTEST
|
---|
26 |
|
---|
27 | testhash ()
|
---|
28 | {
|
---|
29 | log_start "HASH FUNCTION"
|
---|
30 | #
|
---|
31 | # test standalone compilation
|
---|
32 | #
|
---|
33 | TEST="${S}standalone agent${E}"
|
---|
34 | #
|
---|
35 | if test -r "Makefile"; then
|
---|
36 | $MAKE distclean
|
---|
37 | fi
|
---|
38 | #
|
---|
39 | ${TOP_SRCDIR}/configure --quiet $TRUST --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$RCFILE --with-log-file=$LOGFILE --with-pid-file=$PW_DIR/.samhain_lock --with-data-file=$PW_DIR/.samhain_file --enable-debug
|
---|
40 | #
|
---|
41 | fail=0
|
---|
42 | #
|
---|
43 | if test x$? = x0; then
|
---|
44 | [ -z "$verbose" ] || log_msg_ok "configure...";
|
---|
45 | $MAKE > /dev/null 2>> test_log
|
---|
46 | if test x$? = x0; then
|
---|
47 | [ -z "$verbose" ] || log_msg_ok "make...";
|
---|
48 | else
|
---|
49 | [ -z "$quiet" ] && log_msg_fail "make...";
|
---|
50 | fail=1
|
---|
51 | fi
|
---|
52 | else
|
---|
53 | [ -z "$quiet" ] && log_msg_fail "configure...";
|
---|
54 | fail=1
|
---|
55 | fi
|
---|
56 | #
|
---|
57 | if [ $fail -eq 1 ]; then
|
---|
58 | [ -z "$quiet" ] && log_fail 1 ${MAXTEST};
|
---|
59 | return 1
|
---|
60 | fi
|
---|
61 | #
|
---|
62 | echo "Test results of the TIGER hash algorithm" > testhash.tmp
|
---|
63 | echo >> testhash.tmp
|
---|
64 | echo "(use samhain -H string to test)" >> testhash.tmp
|
---|
65 | echo >> testhash.tmp
|
---|
66 | ./samhain -H "" >> testhash.tmp
|
---|
67 | ./samhain -H "abc" >> testhash.tmp
|
---|
68 | ./samhain -H "Tiger" >> testhash.tmp
|
---|
69 | ./samhain -H "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-" >> testhash.tmp
|
---|
70 | ./samhain -H "ABCDEFGHIJKLMNOPQRSTUVWXYZ=abcdefghijklmnopqrstuvwxyz+0123456789" >> testhash.tmp
|
---|
71 | ./samhain -H "Tiger - A Fast New Hash Function, by Ross Anderson and Eli Biham" >> testhash.tmp
|
---|
72 | ./samhain -H "Tiger - A Fast New Hash Function, by Ross Anderson and Eli Biham, proceedings of Fast Software Encryption 3, Cambridge." >> testhash.tmp
|
---|
73 | ./samhain -H "Tiger - A Fast New Hash Function, by Ross Anderson and Eli Biham, proceedings of Fast Software Encryption 3, Cambridge, 1996." >> testhash.tmp
|
---|
74 | ./samhain -H "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-" >> testhash.tmp
|
---|
75 | #
|
---|
76 | RESU=`diff testhash.tmp ${SCRIPTDIR}/testtiger.txt 2>/dev/null`
|
---|
77 | if test "x${RESU}" = "x"; then
|
---|
78 | [ -z "$quiet" ] && log_ok 1 ${MAXTEST};
|
---|
79 | else
|
---|
80 | [ -z "$quiet" ] && log_fail 1 ${MAXTEST};
|
---|
81 | return 1
|
---|
82 | fi
|
---|
83 | #
|
---|
84 | #
|
---|
85 | #
|
---|
86 | TEST="${S}files${E}"
|
---|
87 | #
|
---|
88 | case $SCRIPTDIR in
|
---|
89 | /*)
|
---|
90 | testpath="${SCRIPTDIR}/testtiger.txt";;
|
---|
91 | *)
|
---|
92 | testpath="`pwd`/${SCRIPTDIR}/testtiger.txt";;
|
---|
93 | esac
|
---|
94 | #
|
---|
95 | RESU=`./samhain -H ${testpath}`
|
---|
96 | #
|
---|
97 | if test x"$RESU" = x"${testpath}: 8125E439 4E7E20F9 24FD8E37 BC4D90C7 FC67F40C 1681F05D"; then
|
---|
98 | [ -z "$quiet" ] && log_ok 2 ${MAXTEST};
|
---|
99 | else
|
---|
100 | [ -z "$quiet" ] && log_fail 2 ${MAXTEST};
|
---|
101 | return 1
|
---|
102 | fi
|
---|
103 | #
|
---|
104 | log_end "HASH FUNCTION"
|
---|
105 | return 0
|
---|
106 | }
|
---|
107 |
|
---|
108 |
|
---|
109 |
|
---|