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