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