chiark / gitweb /
svc/tripe-ifup.in: Trim prefix length from IPv6 address used as gateway.
[tripe] / server / tests.at
CommitLineData
5d85da1c
MW
1### -*-autotest-*-
2###
3### Test script for the main server
4###
5### (c) 2008 Straylight/Edgeware
6###
7
8###----- Licensing notice ---------------------------------------------------
9###
10### This file is part of Trivial IP Encryption (TrIPE).
11###
12### TrIPE is free software; you can redistribute it and/or modify
13### it under the terms of the GNU General Public License as published by
14### the Free Software Foundation; either version 2 of the License, or
15### (at your option) any later version.
16###
17### TrIPE is distributed in the hope that it will be useful,
18### but WITHOUT ANY WARRANTY; without even the implied warranty of
19### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20### GNU General Public License for more details.
21###
22### You should have received a copy of the GNU General Public License
23### along with TrIPE; if not, write to the Free Software Foundation,
24### Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25
26m4_define([nl], [
27])
28
29## Configure a directory ready for use by tripe.
30m4_define([SETUPDIR], [
31 cp $abs_top_srcdir/t/keyring-$1 ./keyring
32 key extract -f-secret keyring.pub
33])
34
35## Running standard programs with useful options.
36m4_define([TRIPE],
388e0319
MW
37 [env TRIPE_PRIVHELPER=$abs_top_builddir/priv/tripe-privhelper \
38 $abs_top_builddir/server/tripe -F -d. -aadmin -p0 -b127.0.0.1 -talice])
5d85da1c
MW
39m4_define([TRIPECTL], [$abs_top_builddir/client/tripectl -d. -aadmin])
40m4_define([USLIP], [$abs_top_builddir/uslip/tripe-uslip])
01c21903
MW
41m4_define([PKSTREAM],
42 [$abs_top_builddir/pkstream/pkstream -b127.0.0.1 -p127.0.0.1])
f884ef9d 43m4_define([MITM], [$abs_top_builddir/proxy/tripe-mitm])
5d85da1c
MW
44
45## Sequences. (These are used for testing the replay protection machinery.)
46m4_define([R32], [ 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 dnl
47 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31])
48m4_define([P32], [21 26 14 12 25 18 2 27 10 31 24 29 0 20 17 11 dnl
49 8 3 7 23 19 1 13 30 6 9 5 22 15 28 16 4])
50
51###--------------------------------------------------------------------------
52### Scaffolding for running a TrIPE server.
53
05d4b7da 54## WITH_TRIPEX(dir, args, body)
5d85da1c
MW
55m4_define([WITH_TRIPEX], [
56
05d4b7da
MW
57## If this directory doesn't exist then Bad Things will happen.
58if test ! -d $1; then
59 echo >&2 "server directory \`$1' doesn't exist"
60 exit 99
61fi
62
5d85da1c
MW
63## Remove the status file. This is how we notice that the server's died.
64rm -f $1/server-status
65> $1/expected-server-output
66> $1/expected-server-errors
67
768a2316
MW
68## Autotest writes crap to standard output, which we don't want going to the
69## server. So keep a copy of the standard output, do the pipe, and recover
70## the old stdout inside the group.
5d85da1c
MW
71exec 3>&1
72{ (
73exec 1>&3 3>&-
74
75## Wait for the socket to appear. Watch for the server crashing during
76## initialization. Busy waiting is evil, but it's the best I can do and
77## not sleep for ages. (Yes, a second on each test group is a long time.)
768a2316 78while test ! -r $1/server-status && test ! -S $1/admin; do :; done
5d85da1c 79
05d4b7da
MW
80## Make the port number availale.
81AT_CHECK([TRIPECTL -d$1 PORT],, [stdout])
82mv stdout $1/port
83
5d85da1c
MW
84## Test body...
85$3
86
96f1fb57
MW
87## End of the test, now run the server. There's an awful hack here. If a
88## process running under strace exits with a signal, then strace will kill
89## itself with the same signal -- and therefore clobber the original
90## process's core file. So we arrange to run strace in one directory and
91## have the child process run in another.
5d85da1c
MW
92) && :; } | {
93 cd $1
94 echo TRIPE $2 >&2
2539ab9c
MW
95 case "${TRIPE_TEST_STRACE-nil}" in
96 nil)
97 TRIPE -d. $2 >server-output.full 2>server-errors
98 ;;
99 *)
100 mkdir -p strace-hack/
101 (cd strace-hack/
102 ulimit -c hard >/dev/null 2>&1
103 strace -f -o ../tripe.trace \
104 TRIPE -d.. $2 >../server-output.full 2>../server-errors)
105 ;;
106 esac
5d85da1c
MW
107 stat=$?
108 echo $stat >server-status
109 if test $stat -ne 0; then
110 echo "exit status: $stat" >>server-errors
111 fi
05d4b7da
MW
112
113 ## We interrupt this relatively sensible macro for an especially awful
114 ## hack. The tripe server emits warnings which are often caused by lack of
115 ## synchronization between two peers. These are harmless and shouldn't
116 ## cause test failures. But we shouldn't just trim out all messages that
117 ## look like the spurious ones: if they appear when we're not expecting
118 ## them, that's bad and they should properly cause a test failure.
119 ##
120 ## So we use the WARN command to insert magic directives into the server's
121 ## message stream. The directives begin with `WARN USER test'; remaining
122 ## tokens may be as follows.
123 ##
124 ## PUSH Introduce a new layer of nesting. Settings between
125 ## this PUSH and the matching POP will be forgotten
126 ## following the POP.
127 ##
128 ## POP End a layer of nesting. See PUSH above.
129 ##
130 ## IGNORE tokens Ignore lines which begin with the tokens.
131 ##
132 ## Token comparison isn't done very well, but it's good enough for these
133 ## purposes.
134 ##
135 ## We also trim out trace lines here, since it's useful to produce them for
136 ## debugging purposes and changing or introducing more of them shouldn't
137 ## cause failures.
138 awk '
139 BEGIN {
140 sp = 0;
141 npat = 0;
142 }
143 $[]1 == "TRACE" { next; }
144 $[]1 == "WARN" && $[]2 == "USER" && $[]3 == "test" {
145 if ($[]4 == "PUSH")
146 npatstk[[sp++]] = npat;
147 else if ($[]4 == "IGNORE") {
148 s = "";
149 p = "";
150 for (i = 5; i <= NF; i++) {
151 p = p s $[]i;
152 s = " ";
153 }
154 pat[[npat++]] = p;
155 } else if ($[]4 == "POP")
156 npat = npatstk[[--sp]];
157 next;
158 }
159 {
160 for (i = 0; i < npat; i++) {
161 n = length(pat[[i]]);
ee7a2a10 162 if (substr($[]0, 1, n) == pat[[i]])
05d4b7da
MW
163 next;
164 }
165 print $[]0;
166 }
167 ' server-output.full >server-output
5d85da1c
MW
168}
169exec 3>&-
170
171## Now check that the server's output matches our expectations.
172mv $1/expected-server-output expout
173mv $1/expected-server-errors experr
174AT_CHECK([cat $1/server-output; cat >&2 $1/server-errors],,
175 [expout], [experr])
176])
177
05d4b7da 178## WITH_TRIPE(args, body)
5d85da1c
MW
179m4_define([WITH_TRIPE], [WITH_TRIPEX([.], [$1], [$2])])
180
05d4b7da 181## WITH_2TRIPES(adir, bdir, bothargs, aargs, bargs, body)
5d85da1c
MW
182m4_define([WITH_2TRIPES],
183 [WITH_TRIPEX([$1], [$3 $4], [WITH_TRIPEX([$2], [$3 $5], [$6])])])
184
203e1b1f
MW
185## WITH_3TRIPES(adir, bdir, cdir, allargs, aargs, bargs, cargs, body)
186m4_define([WITH_3TRIPES],
187 [WITH_TRIPEX([$1], [$4 $5],
188 [WITH_TRIPEX([$2], [$4 $6],
189 [WITH_TRIPEX([$3], [$4 $7],
190 [$8])])])])
191
9e930d39
MW
192## RETRY(n, body)
193m4_define([RETRY], [
194 n=0 rc=1
195 while test $n -lt $1; do
196 if $2
197 then rc=0; break
198 fi
199 n=$(( $n + 1 ))
200 done
201 exit $rc
202])
203
204## COMMS_EPING(adir, aname, bdir, bname, [n])
05d4b7da 205m4_define([COMMS_EPING], [
9e930d39
MW
206 AT_CHECK([RETRY([m4_default([$5], [1])],
207 [TRIPECTL -d$1 EPING $4])],, [ignore])
208 AT_CHECK([RETRY([m4_default([$5], [1])],
209 [TRIPECTL -d$3 EPING $2])],, [ignore])
05d4b7da
MW
210])
211
212## COMMS_SLIP(adir, aname, bdir, bname)
213m4_define([COMMS_SLIP], [
214 AT_CHECK([echo "from $1" | USLIP -p $1/$4])
215 AT_CHECK([USLIP -g $3/$2],, [from $1[]nl])
216 AT_CHECK([echo "from $3" | USLIP -p $3/$2])
217 AT_CHECK([USLIP -g $1/$4],, [from $3[]nl])
218])
219
220## AWAIT_KXDONE(adir, aname, bdir, bname, body)
221m4_define([AWAIT_KXDONE], [
222
223 ## Ignore some reports caused by races.
224 TRIPECTL -d$3 WARN test PUSH
225 TRIPECTL -d$3 WARN test IGNORE WARN KX $2 incorrect cookie
226 TRIPECTL -d$3 WARN test IGNORE WARN KX $2 unexpected pre-challenge
227
228 ## Watch for the key-exchange completion announcement in the background.
229 COPROCESSES([wait-$1], [
230 echo WATCH +n
231 while read line; do
232 set x $line; shift
233 echo >&2 ">>> $line"
234 case "$[]1:$[]2:$[]3" in
235 OK::) ;;
236 NOTE:KXDONE:$4) break ;;
237 NOTE:*) ;;
238 *) exit 63 ;;
239 esac
240 done
241 ], [
242 TRIPECTL -d$1
243 ]) & waiter_$1=$!
244
245 $5
246
247 ## Collect the completion announcement.
248 wait $waiter_$1; waitrc=$?
249 AT_CHECK([echo $waitrc],, [0[]nl])
250
251 ## Be interested in key-exchange warnings again.
252 TRIPECTL -d$4 WARN test POP
253])
254
01c21903 255## ESTABLISH(adir, aname, aopts, bdir, bname, bopts, [aport], [bport])
05d4b7da
MW
256m4_define([ESTABLISH], [
257
258 ## Set up the establishment.
259 AWAIT_KXDONE([$1], [$2], [$4], [$5], [
01c21903
MW
260 AT_CHECK([TRIPECTL -d$1 ADD -cork $6 $5 INET 127.0.0.1 \
261 m4_if([$8], [], [$(cat $4/port)], [$8])])
262 AT_CHECK([TRIPECTL -d$4 ADD $3 $2 INET 127.0.0.1 \
263 m4_if([$7], [], [$(cat $1/port)], [$7])])
05d4b7da
MW
264 ])
265
266 ## Check transport pinging.
267 AT_CHECK([TRIPECTL -d$1 PING $5],, [ignore])
268 AT_CHECK([TRIPECTL -d$4 PING $2],, [ignore])
269
270 ## Check communication works.
271 COMMS_EPING([$1], [$2], [$4], [$5])
272 COMMS_SLIP([$1], [$2], [$4], [$5])
273])
274
5d85da1c
MW
275###--------------------------------------------------------------------------
276### Very unpleasant coprocess handling.
277
278## COPROCESSES(TAG, PROC-A, PROC-B)
279m4_define([COPROCESSES], [dnl
280rm -f pipe-$1; mknod pipe-$1 p
281{ { $2 nl } <pipe-$1 | { $3 nl } >pipe-$1; } dnl
282])
283
284## TRIPECTL_INTERACT(ARGS, SHELLSTUFF)
285m4_define([TRIPECTL_INTERACT], [
768a2316 286 exec 3>&1
11715242 287 COPROCESSES([client], [exec 4>&1 1>&3 $1], [TRIPECTL $2])
5d85da1c
MW
288])
289
290## TRIPECTL_COMMAND(CMD, EXPECT)
291m4_define([TRIPECTL_COMMAND], [
292 AT_CHECK([
293 m4_if([$1], [!], [:], [echo "$1" >&4])
294 read line
295 case "$line" in
296 "$2") ;;
297 *) echo 2>&1 "submitted $1: expected $2, found $line"; exit 1 ;;
298 esac
299 ])
300 exec 3>&-
301])
302
303###--------------------------------------------------------------------------
304### Make sure the thing basically works.
305
306AT_SETUP([server basics])
59d05259 307SETUPDIR([alpha])
5d85da1c
MW
308AT_CHECK([echo port | TRIPE -p54321],, [INFO 54321[]nl[]OK[]nl])
309AT_CLEANUP
310
311###--------------------------------------------------------------------------
312### Challenges.
313
314AT_SETUP([server challenges])
315AT_KEYWORDS([chal])
59d05259 316SETUPDIR([alpha])
5d85da1c
MW
317
318WITH_TRIPE(, [
319 ## A simple test.
320 AT_CHECK([chal=$(TRIPECTL GETCHAL); TRIPECTL checkchal $chal])
321
322 ## A wrong challenge. (This was valid once, but the probablity that the
323 ## server chose the same key is negligible.)
324 AT_CHECK([TRIPECTL checkchal AAAAAHyoOL+HMaE0Y9B3ivuszt0], [1],,
325 [tripectl: invalid-challenge[]nl])
326 echo WARN CHAL incorrect-tag >>expected-server-output
327
328 ## A duplicated challenge.
329 AT_CHECK([
330 chal=$(TRIPECTL GETCHAL)
331 TRIPECTL CHECKCHAL $chal
332 TRIPECTL CHECKCHAL $chal
333 ], [1],, [tripectl: invalid-challenge[]nl])
334 echo WARN CHAL replay duplicated-sequence >>expected-server-output
335
336 ## Out-of-order reception. There should be a window of 32 challenges; we
337 ## make 33 and check them in a strange order.
338 rm -f experr
339 echo "tripectl: invalid-challenge" >>experr
340 echo "WARN CHAL replay old-sequence" >>expected-server-output
341 for i in P32; do
342 echo "tripectl: invalid-challenge" >>experr
343 echo "WARN CHAL replay duplicated-sequence" >>expected-server-output
344 done
345 AT_CHECK([
346
347 ## Make the challenges.
348 for i in old R32; do TRIPECTL GETCHAL >chal-$i || exit 2; done
349
350 ## Now check them back.
351 for i in P32; do TRIPECTL CHECKCHAL $(cat chal-$i) || exit 3; done
352
353 ## Check the one which should have fallen off the front.
354 TRIPECTL CHECKCHAL $(cat chal-old) && exit 4
355
356 ## And make sure that the others are now considered duplicates.
357 for i in R32; do TRIPECTL CHECKCHAL $(cat chal-$i) && exit 5; done
358
359 ## All done: tidy cruft away.
360 rm -f chal-*
361 exit 0
362 ], [0],, [experr])
363])
364
365AT_CLEANUP
366
367###--------------------------------------------------------------------------
368### Communication.
369
370AT_SETUP([server communication])
371AT_KEYWORDS([comm])
372export TRIPE_SLIPIF=USLIP
373
b87bffcb
MW
374for k in alpha beta-new; do
375 for p in alice bob; do (
376 rm -rf $p; mkdir $p; cd $p; SETUPDIR([$k])
377 ); done
378 WITH_2TRIPES([alice], [bob], [-nslip], [-talice], [-tbob], [
379 ESTABLISH([alice], [not-alice], [-key alice],
380 [bob], [bob], [])
381 ])
382done
5d85da1c
MW
383
384AT_CLEANUP
385
01c21903
MW
386###--------------------------------------------------------------------------
387### Mobile peer tracking.
388
389AT_SETUP([peer tracking])
390AT_KEYWORDS([mobile])
391export TRIPE_SLIPIF=USLIP
392
393for p in alice bob carol; do (mkdir $p; cd $p; SETUPDIR([alpha])); done
394
395## WITH_PKSTREAM(adir, aport, bdir, bport, body)
396m4_define([WITH_PKSTREAM], [
397 echo >&2 "pkstream: $1 <--> :$2 <-pkstream-> :$4 <--> $3"
398 PKSTREAM -l$4 127.0.0.1:$4 127.0.0.1:$(cat $3/port)& pkstream_$3_$1=$!
399 sleep 1
400 PKSTREAM -c127.0.0.1:$4 127.0.0.1:$2 127.0.0.1:$(cat $1/port)&
401 pkstream_$1_$3=$!
402 set +x
403 $5
404 kill $pkstream_$3_$1 $pkstream_$1_$3
405])
406
407WITH_3TRIPES([alice], [bob], [carol], [-nslip],
408 [-talice], [-tbob], [-tcarol], [
409
410 ## We need an indirection layer between the two peers so that we can
411 ## simulate the effects of NAT remapping. The nearest thing we have to
412 ## this is pkstream, so we may as well use that.
413 ##
414 ## alice <--> :5311 <-pkstream-> :5312 <--> bob
415 ## alice <--> :5321 <-pkstream-> :5322 <--> carol
416
417 WITH_PKSTREAM([alice], [5311], [bob], [5312], [
418 ESTABLISH([alice], [alice], [], [bob], [bob], [-mobile], [5312], [5311])
419 ])
420
421 WITH_PKSTREAM([alice], [5319], [bob], [5312], [
422 COMMS_EPING([bob], [bob], [alice], [alice])
423 COMMS_SLIP([bob], [bob], [alice], [alice])
424 ])
425
426 WITH_PKSTREAM([alice], [5321], [carol], [5322], [
427 ESTABLISH([alice], [alice], [], [carol], [carol], [-mobile],
428 [5322], [5321])
429 ])
430
431 WITH_PKSTREAM([alice], [5311], [bob], [5312], [
432 WITH_PKSTREAM([alice], [5321], [carol], [5322], [
433 COMMS_EPING([bob], [bob], [alice], [alice])
434 COMMS_EPING([carol], [carol], [alice], [alice])
435 COMMS_SLIP([bob], [bob], [alice], [alice])
436 COMMS_SLIP([carol], [carol], [alice], [alice])
437 ])])
438
439 WITH_PKSTREAM([alice], [5321], [bob], [5312], [
440 WITH_PKSTREAM([alice], [5311], [carol], [5322], [
441 COMMS_EPING([bob], [bob], [alice], [alice])
442 COMMS_EPING([carol], [carol], [alice], [alice])
443 COMMS_SLIP([bob], [bob], [alice], [alice])
444 COMMS_SLIP([carol], [carol], [alice], [alice])
445 ])])
446 wait
447])
448
449AT_CLEANUP
450
f884ef9d
MW
451###--------------------------------------------------------------------------
452### Adverse communication.
453
454AT_SETUP([server retry])
455AT_KEYWORDS([backoff])
456export TRIPE_SLIPIF=USLIP
457
9cda68ab 458for i in alice bob; do (mkdir $i; cd $i; SETUPDIR([beta])); done
f884ef9d
MW
459
460WITH_2TRIPES([alice], [bob], [-nslip], [-talice], [-tbob], [
461
462 ## Set up the evil proxy.
463 alicemitm=24516 bobmitm=14016
464 MITM -kalice/keyring.pub >mitm.out 2>mitm.err \
465 peer:alice:$alicemitm:127.0.0.1:$(cat alice/port) \
466 peer:bob:$bobmitm:127.0.0.1:$(cat bob/port) \
467 filt:drop:5 filt:send& mitmpid=$!
468 strace -omitm.trace -p$mitmpid& mitmtrace=$!
469 trap 'kill $mitmpid $mitmtrace; exit 127' EXIT INT QUIT TERM HUP
470
471 ## Try to establish keys anyway.
472 AWAIT_KXDONE([alice], [alice], [bob], [bob], [
473 AT_CHECK([TRIPECTL -dalice ADD -cork bob INET 127.0.0.1 $alicemitm])
474 AT_CHECK([TRIPECTL -dbob ADD alice INET 127.0.0.1 $bobmitm])
475 ])
476
477 ## Check pinging.
478 COMMS_EPING([alice], [alice], [bob], [bob], [10])
479 COMMS_EPING([bob], [bob], [alice], [alice], [10])
480
481 ## Tear down the MITM proxy.
482 kill $mitmpid
483 wait $mitmpid
484 wait $mitmtrace
485])
486
487AT_CLEANUP
488
31b8e627
MW
489###--------------------------------------------------------------------------
490### Key management.
491
492AT_SETUP([server key-management])
493AT_KEYWORDS([keymgmt])
494export TRIPE_SLIPIF=USLIP
495
496## Determine all of the nets and the principals.
497princs=""
498nets=" "
499while read princ pnets; do
500 princs="$princs $princ"
501 for n in $pnets; do
502 case " $nets " in *" $n "*) ;; *) nets="$nets$n " ;; esac
503 done
504done <<PRINC
505alice alpha beta
506bob alpha beta
507carol beta
508PRINC
509
510## Build the master keyring. All key tags here are of the form PRINC/NET.
511for n in $nets; do
512 key -k$abs_top_srcdir/t/keyring-$n extract keyring-$n $princs
513 for p in $princs; do key -kkeyring-$n tag $p $p/$n; done
514 key merge keyring-$n
515 rm keyring-$n
516done
517key extract -f-secret keyring.pub
518
519## Set up the principals' directories.
520for p in $princs; do
521 mkdir $p
522 cp keyring keyring.pub $p/
523done
524
525WITH_3TRIPES([alice], [bob], [carol], [-nslip -Tmx],
526 [-talice/alpha], [-tbob/alpha], [-tcarol/beta], [
527
528 ## Establish this little merry-go-round.
529 ESTABLISH([alice], [alice], [-key alice/alpha],
530 [bob], [bob], [-key bob/alpha])
531 ESTABLISH([alice], [alice], [-key alice/beta],
532 [carol], [carol], [-priv alice/beta -key carol/beta])
533 ESTABLISH([bob], [bob], [-key bob/beta],
534 [carol], [carol], [-priv bob/beta -key carol/beta])
535
536 ## Tweak Bob's alpha key.
537 for p in $princs; do
538 TRIPECTL -d$p WARN test COMMENT tweak bob/alpha
539 done
540
541 key -k$abs_top_srcdir/t/keyring-alpha extract keyring-bob-new bob-new
542 key merge keyring-bob-new
543 key tag -r bob-new bob/alpha
544 key extract -f-secret keyring.pub
545 for p in alice bob; do cp keyring keyring.pub $p/; done
546
547 ## Kick the peers to see whether they update.
548 AWAIT_KXDONE([alice], [alice], [bob], [bob], [
549 TRIPECTL -dalice RELOAD
550 TRIPECTL -dbob RELOAD
551 TRIPECTL -dalice FORCEKX bob
552 TRIPECTL -dbob FORCEKX alice
553 ])
554
555 COMMS_EPING([alice], [alice], [bob], [bob])
556 COMMS_EPING([bob], [bob], [alice], [alice])
557
558 ## Update the beta ring.
559 key merge $abs_top_srcdir/t/keyring-beta-new
560 for p in $princs; do key tag -r $p $p/beta; done
561 key extract -f-secret keyring.pub
562
563 ## Update alice's and carol's private keys, bob's public. This should be
564 ## insufficient for them to switch, but the results could be interesting.
565 for p in $princs; do
566 TRIPECTL -d$p WARN test COMMENT tweak beta step 1
567 done
568
569 for p in alice carol; do cp keyring $p/; done
570 cp keyring.pub bob/
571 for p in $princs; do TRIPECTL -d$p RELOAD; done
572
573 AT_DATA([algs-alpha], [dnl
574kx-group=ec kx-group-order-bits=256 kx-group-elt-bits=512
575hash=rmd160 mgf=rmd160-mgf hash-sz=20
a93aacce 576bulk-transform=v0 bulk-overhead=22
31b8e627
MW
577cipher=blowfish-cbc cipher-keysz=20 cipher-blksz=8
578cipher-data-limit=67108864
579mac=rmd160-hmac mac-keysz=20 mac-tagsz=10
580])
581
582 AT_DATA([algs-beta-old], [dnl
583kx-group=prime kx-group-order-bits=160 kx-group-elt-bits=1023
584hash=rmd160 mgf=rmd160-mgf hash-sz=20
a93aacce 585bulk-transform=v0 bulk-overhead=22
31b8e627
MW
586cipher=blowfish-cbc cipher-keysz=20 cipher-blksz=8
587cipher-data-limit=67108864
588mac=rmd160-hmac mac-keysz=20 mac-tagsz=10
589])
590
591 AT_DATA([algs-beta-new], [dnl
592kx-group=ec kx-group-order-bits=161 kx-group-elt-bits=320
593hash=rmd160 mgf=rmd160-mgf hash-sz=20
b87bffcb 594bulk-transform=iiv bulk-overhead=14
31b8e627
MW
595cipher=blowfish-cbc cipher-keysz=20 cipher-blksz=8
596cipher-data-limit=67108864
597mac=rmd160-hmac mac-keysz=20 mac-tagsz=10
b87bffcb 598blkc=blowfish blkc-keysz=20 blkc-blksz=8
31b8e627
MW
599])
600
601 cp algs-alpha expout; AT_CHECK([TRIPECTL -dalice ALGS],, [expout])
602 cp algs-beta-old expout; AT_CHECK([TRIPECTL -dalice ALGS carol],, [expout])
603 cp algs-beta-old expout; AT_CHECK([TRIPECTL -dbob ALGS carol],, [expout])
604 cp algs-beta-new expout; AT_CHECK([TRIPECTL -dcarol ALGS],, [expout])
605 cp algs-beta-old expout; AT_CHECK([TRIPECTL -dcarol ALGS alice],, [expout])
606
607 ## Now copy the full keys. We expect this to provoke key exchange.
608 for p in $princs; do
609 TRIPECTL -d$p WARN test COMMENT tweak beta step 2
610 done
611
612 for p in $princs; do cp keyring keyring.pub $p/; done
613
614 AWAIT_KXDONE([alice], [alice], [carol], [carol], [
615 TRIPECTL -dalice RELOAD
616 AWAIT_KXDONE([bob], [bob], [carol], [carol], [
617 TRIPECTL -dbob RELOAD
618 TRIPECTL -dcarol RELOAD
619 ])
620 ])
621
622 cp algs-alpha expout; AT_CHECK([TRIPECTL -dalice ALGS],, [expout])
623 cp algs-beta-new expout; AT_CHECK([TRIPECTL -dalice ALGS carol],, [expout])
624 cp algs-beta-new expout; AT_CHECK([TRIPECTL -dbob ALGS carol],, [expout])
625 cp algs-beta-new expout; AT_CHECK([TRIPECTL -dcarol ALGS],, [expout])
626])
627
628AT_CLEANUP
629
5d85da1c
MW
630###--------------------------------------------------------------------------
631### Services.
632
633AT_SETUP([server services])
634AT_KEYWORDS([svc])
59d05259 635SETUPDIR([alpha])
5d85da1c
MW
636
637WITH_TRIPE(, [
638
639 ## Make sure it's not running yet.
640 AT_CHECK([TRIPECTL SVCENSURE test], [1],,
641 [tripectl: unknown-service test[]nl])
642
643 ## Run a simple service.
644 rm -f svc-test-running tripectl-status
645 COPROCESSES([svc], [
646 echo SVCCLAIM test 1.0.0
647 read line
648 case "$line" in
649 OK)
2f20abf2 650 ;;
5d85da1c 651 *)
2f20abf2 652 echo >&2 "SVCCLAIM failed: $line"
5d85da1c
MW
653 exit 1
654 ;;
655 esac
656 echo ok >svc-test-running
657 while read line; do
658 set -- $line
659 case "$[]1,$[]3,$[]4" in
660 SVCJOB,test,HELP)
661 echo SVCINFO try not to use this service for anything useful
662 echo SVCOK $[]2
663 ;;
664 SVCJOB,test,GOOD)
665 echo SVCOK $[]2
666 ;;
667 SVCJOB,test,BAD)
668 echo SVCFAIL $[]2 this-command-always-fails
669 ;;
670 SVCJOB,test,UGLY)
671 tag=$2
672 while read line; do
673 set -- $line
674 case "$[]1,$[]2,$[]3,$[]4" in
675 SVCCANCEL,$tag,,) break ;;
676 SVCJOB,*,test,ESCAPE)
2f20abf2 677 echo >&2 "attempt to escape from alkatraz"
5d85da1c
MW
678 exit 1
679 ;;
680 esac
681 done
682 ;;
683 SVCJOB,test,FIRST)
684 firsttag=$[]2
685 ;;
686 SVCJOB,test,SECOND)
687 echo SVCOK $firsttag
688 echo SVCOK $[]2
689 ;;
690 SVCJOB,*)
691 echo SVCFAIL $[]2 unknown-svc-command $[]4
692 ;;
693 SVCCLAIM,*)
694 break
695 ;;
696 OK,* | INFO,*)
697 ;;
698 FAIL,*)
699 echo "failure in service: $line" >&2
700 ;;
701 esac
702 done
703 ], [
704 TRIPECTL; echo $? >tripectl-status
705 ]) 2>tripectl-errors &
706
707 ## Wait until it starts up.
708 while test ! -r svc-test-running && test ! -r tripectl-status; do :; done
709
710 ## Make sure it's running.
711 AT_CHECK([TRIPECTL SVCQUERY test],, [name=test version=1.0.0[]nl])
712
713 ## Try some simple commands.
714 AT_CHECK([TRIPECTL SVCSUBMIT test GOOD])
715 AT_CHECK([TRIPECTL SVCSUBMIT test BAD], [1],,
716 [tripectl: this-command-always-fails[]nl])
717
718 ## And now with commands in the background.
719 TRIPECTL_INTERACT([
720 TRIPECTL_COMMAND([SVCSUBMIT test GOOD], [OK])
721 TRIPECTL_COMMAND([SVCSUBMIT -background foo test UGLY], [BGDETACH foo])
722 TRIPECTL_COMMAND([BGCANCEL foo], [OK])
723 TRIPECTL_COMMAND([SVCSUBMIT test ESCAPE],
724 [FAIL unknown-svc-command ESCAPE])
725 ])
726
727 ## Out-of-order completion.
728 TRIPECTL_INTERACT([
729 TRIPECTL_COMMAND([SVCSUBMIT -background one test FIRST], [BGDETACH one])
730 TRIPECTL_COMMAND([SVCSUBMIT -background two test SECOND], [BGDETACH two])
731 TRIPECTL_COMMAND([!], [BGOK one])
732 TRIPECTL_COMMAND([!], [BGOK two])
733 ])
734
735 ## All done.
736 exit 0
737])
738
739AT_CLEANUP
740
741###----- That's all, folks --------------------------------------------------