]> The Tcpdump Group git mirrors - tcpdump/blob - tests/crypto.sh
dns: add some additional error checks.
[tcpdump] / tests / crypto.sh
1 #!/bin/sh
2
3 srcdir=${1-..}
4 : echo crypto.sh using ${srcdir} from `pwd`
5
6 SRCDIR=$srcdir
7 export SRCDIR
8
9 testdir=${srcdir}/tests
10
11 exitcode=0
12 passedfile=tests/.passed
13 failedfile=tests/.failed
14 passed=`cat ${passedfile}`
15 failed=`cat ${failedfile}`
16
17 # Only attempt OpenSSL-specific tests when compiled with the library.
18
19 if grep '^#define HAVE_LIBCRYPTO 1$' config.h >/dev/null
20 then
21 if ${testdir}/TESTonce esp1 ${testdir}/02-sunrise-sunset-esp.pcap ${testdir}/esp1.out '-E "0x12345678@192.1.2.45 3des-cbc-hmac96:0x4043434545464649494a4a4c4c4f4f515152525454575758"'
22 then
23 passed=`expr $passed + 1`
24 echo $passed >${passedfile}
25 else
26 failed=`expr $failed + 1`
27 echo $failed >${failedfile}
28 exitcode=1
29 fi
30 if ${testdir}//TESTonce esp2 ${testdir}/08-sunrise-sunset-esp2.pcap ${testdir}/esp2.out '-E "0x12345678@192.1.2.45 3des-cbc-hmac96:0x43434545464649494a4a4c4c4f4f51515252545457575840,0xabcdabcd@192.0.1.1 3des-cbc-hmac96:0x434545464649494a4a4c4c4f4f5151525254545757584043"'
31 then
32 passed=`expr $passed + 1`
33 echo $passed >${passedfile}
34 else
35 failed=`expr $failed + 1`
36 echo $failed >${failedfile}
37 exitcode=1
38 fi
39 if ${testdir}/TESTonce esp3 ${testdir}/02-sunrise-sunset-esp.pcap ${testdir}/esp1.out '-E "3des-cbc-hmac96:0x4043434545464649494a4a4c4c4f4f515152525454575758"'
40 then
41 passed=`expr $passed + 1`
42 echo $passed >${passedfile}
43 else
44 failed=`expr $failed + 1`
45 echo $failed >${failedfile}
46 exitcode=1
47 fi
48 # Reading the secret(s) from a file does not work with Capsicum.
49 if grep '^#define HAVE_CAPSICUM 1$' config.h >/dev/null
50 then
51 FORMAT=' %-35s: TEST SKIPPED (compiled w/Capsicum)\n'
52 printf "$FORMAT" esp4
53 printf "$FORMAT" esp5
54 printf "$FORMAT" espudp1
55 printf "$FORMAT" ikev2pI2
56 printf "$FORMAT" isakmp4
57 else
58 if ${testdir}/TESTonce esp4 ${testdir}/08-sunrise-sunset-esp2.pcap ${testdir}/esp4.out '-E "file '${testdir}'/esp-secrets.txt"'
59 then
60 passed=`expr $passed + 1`
61 echo $passed >${passedfile}
62 else
63 failed=`expr $failed + 1`
64 echo $failed >${failedfile}
65 exitcode=1
66 fi
67 if ${testdir}/TESTonce esp5 ${testdir}/08-sunrise-sunset-aes.pcap ${testdir}/esp5.out '-E "file '${testdir}'/esp-secrets.txt"'
68 then
69 passed=`expr $passed + 1`
70 echo $passed >${passedfile}
71 else
72 failed=`expr $failed + 1`
73 echo $failed >${failedfile}
74 exitcode=1
75 fi
76 if ${testdir}/TESTonce espudp1 ${testdir}/espudp1.pcap ${testdir}/espudp1.out '-nnnn -E "file '${testdir}'/esp-secrets.txt"'
77 then
78 passed=`expr $passed + 1`
79 echo $passed >${passedfile}
80 else
81 failed=`expr $failed + 1`
82 echo $failed >${failedfile}
83 exitcode=1
84 fi
85 if ${testdir}/TESTonce ikev2pI2 ${testdir}/ikev2pI2.pcap ${testdir}/ikev2pI2.out '-E "file '${testdir}'/ikev2pI2-secrets.txt" -v -v -v -v'
86 then
87 passed=`expr $passed + 1`
88 echo $passed >${passedfile}
89 else
90 failed=`expr $failed + 1`
91 echo $failed >${failedfile}
92 exitcode=1
93 fi
94 if ${testdir}/TESTonce isakmp4 ${testdir}/isakmp4500.pcap ${testdir}/isakmp4.out '-E "file '${testdir}'/esp-secrets.txt"'
95 then
96 passed=`expr $passed + 1`
97 echo $passed >${passedfile}
98 else
99 failed=`expr $failed + 1`
100 echo $failed >${failedfile}
101 exitcode=1
102 fi
103 fi
104 if ${testdir}/TESTonce bgp-as-path-oobr-ssl ${testdir}/bgp-as-path-oobr.pcap ${testdir}/bgp-as-path-oobr-ssl.out '-vvv -e'
105 then
106 passed=`expr $passed + 1`
107 echo $passed >${passedfile}
108 else
109 failed=`expr $failed + 1`
110 echo $failed >${failedfile}
111 exitcode=1
112 fi
113 if ${testdir}/TESTonce bgp-aigp-oobr-ssl ${testdir}/bgp-aigp-oobr.pcap ${testdir}/bgp-aigp-oobr-ssl.out '-vvv -e'
114 then
115 passed=`expr $passed + 1`
116 echo $passed >${passedfile}
117 else
118 failed=`expr $failed + 1`
119 echo $failed >${failedfile}
120 exitcode=1
121 fi
122 FORMAT=' %-35s: TEST SKIPPED (compiled w/OpenSSL)\n'
123 printf "$FORMAT" bgp-as-path-oobr-nossl
124 printf "$FORMAT" bgp-aigp-oobr-nossl
125 else
126 FORMAT=' %-35s: TEST SKIPPED (compiled w/o OpenSSL)\n'
127 printf "$FORMAT" esp1
128 printf "$FORMAT" esp2
129 printf "$FORMAT" esp3
130 printf "$FORMAT" esp4
131 printf "$FORMAT" esp5
132 printf "$FORMAT" espudp1
133 printf "$FORMAT" ikev2pI2
134 printf "$FORMAT" isakmp4
135 printf "$FORMAT" bgp-as-path-oobr-ssl
136 printf "$FORMAT" bgp-aigp-oobr-ssl
137 if ${testdir}/TESTonce bgp-as-path-oobr-nossl ${testdir}/bgp-as-path-oobr.pcap ${testdir}/bgp-as-path-oobr-nossl.out '-vvv -e'
138 then
139 passed=`expr $passed + 1`
140 echo $passed >${passedfile}
141 else
142 failed=`expr $failed + 1`
143 echo $failed >${failedfile}
144 exitcode=1
145 fi
146 if ${testdir}/TESTonce bgp-aigp-oobr-nossl ${testdir}/bgp-aigp-oobr.pcap ${testdir}/bgp-aigp-oobr-nossl.out '-vvv -e'
147 then
148 passed=`expr $passed + 1`
149 echo $passed >${passedfile}
150 else
151 failed=`expr $failed + 1`
152 echo $failed >${failedfile}
153 exitcode=1
154 fi
155 fi
156
157 exit $exitcode