2 # Copyright (C) 2003, 2005, 2007 Simon Josefsson.
4 # This file is part of Shishi.
6 # Shishi is free software; you can redistribute it and/or modify it
7 # under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 3 of the License, or
9 # (at your option) any later version.
11 # Shishi is distributed in the hope that it will be useful, but
12 # WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with Shishi; if not, see http://www.gnu.org/licenses or write
18 # to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
19 # Floor, Boston, MA 02110-1301, USA.
21 SHISA
=$PWD/..
/src
/shisa
28 if test -n "$VERBOSE"; then
33 if test ! -d $DBDIR; then
34 echo Cannot create
$DBDIR
38 trap "rm -rf $DBDIR" EXIT
40 echo "db file $DBDIR" > $CONF
41 if test ! -f $CONF; then
42 echo Cannot create
$CONF
46 if test ! -f $SHISA; then
47 echo Cannot
find $SHISA
51 echo Dump empty database.
52 out
=`$SHISA -c $CONF -d`
58 if test "$out" != "$expectout"; then
59 echo expected
: $expectout >&2
60 echo -----got: $out >&2
65 out
=`$SHISA -c $CONF -a TESTREALM`
70 expectout
="Adding realm \`TESTREALM'...
71 Adding realm \`TESTREALM'...done"
72 if test "$out" != "$expectout"; then
73 echo expected
: $expectout >&2
74 echo -----got: $out >&2
79 out
=`$SHISA -c $CONF -l`
85 if test "$out" != "$expectout"; then
86 echo expected
: $expectout >&2
87 echo -----got: $out >&2
92 out
=`$SHISA -c $CONF -a TESTREALM2`
97 expectout
="Adding realm \`TESTREALM2'...
98 Adding realm \`TESTREALM2'...done"
99 if test "$out" != "$expectout"; then
100 echo expected
: $expectout >&2
101 echo -----got: $out >&2
106 out
=`$SHISA -c $CONF -d`
107 if test $?
!= 0; then
113 if test "$out" != "$expectout"; then
114 echo expected
: $expectout >&2
115 echo -----got: $out >&2
120 out
=`$SHISA -c $CONF -r TESTREALM2`
121 if test $?
!= 0; then
125 expectout
="Removing realm \`TESTREALM2'...
126 Removing realm \`TESTREALM2'...done"
127 if test "$out" != "$expectout"; then
128 echo expected
: $expectout >&2
129 echo -----got: $out >&2
134 out
=`$SHISA -c $CONF -d`
135 if test $?
!= 0; then
139 expectout
="TESTREALM"
140 if test "$out" != "$expectout"; then
141 echo expected
: $expectout >&2
142 echo -----got: $out >&2
147 out
=`$SHISA -c $CONF -a TESTREALM test/principal`
148 if test $?
!= 0; then
152 expectout
="Adding principal \`test/principal@TESTREALM'...
153 Adding principal \`test/principal@TESTREALM'...done"
154 if test "$out" != "$expectout"; then
155 echo expected
: $expectout >&2
156 echo -----got: $out >&2
161 out
=`$SHISA -c $CONF -d`
162 if test $?
!= 0; then
169 Current key version 0 (0x0).
171 Etype aes256-cts-hmac-sha1-96 (0x12, 18)."
172 if test "$out" != "$expectout"; then
173 echo expected
: $expectout >&2
174 echo -----got: $out >&2
178 echo Add second principal.
179 out
=`$SHISA -c $CONF -a TESTREALM test/principal2`
180 if test $?
!= 0; then
184 expectout
="Adding principal \`test/principal2@TESTREALM'...
185 Adding principal \`test/principal2@TESTREALM'...done"
186 if test "$out" != "$expectout"; then
187 echo expected
: $expectout >&2
188 echo -----got: $out >&2
193 out
=`$SHISA -c $CONF -d`
194 if test $?
!= 0; then
201 Current key version 0 (0x0).
203 Etype aes256-cts-hmac-sha1-96 (0x12, 18).
206 Current key version 0 (0x0).
208 Etype aes256-cts-hmac-sha1-96 (0x12, 18)."
209 if test "$out" != "$expectout"; then
210 echo expected
: $expectout >&2
211 echo -----got: $out >&2
215 echo Add third principal.
216 out
=`$SHISA -c $CONF -a TESTREALM test/principal3`
217 if test $?
!= 0; then
221 expectout
="Adding principal \`test/principal3@TESTREALM'...
222 Adding principal \`test/principal3@TESTREALM'...done"
223 if test "$out" != "$expectout"; then
224 echo expected
: $expectout >&2
225 echo -----got: $out >&2
229 echo Add third principal again.
230 out
=`$SHISA -c $CONF -a TESTREALM test/principal3 2>&1`
231 if test $?
!= 1; then
236 echo Remove second principal.
237 out
=`$SHISA -c $CONF -r TESTREALM test/principal2`
238 if test $?
!= 0; then
242 expectout
="Removing principal \`test/principal2@TESTREALM'...
243 Removing principal \`test/principal2@TESTREALM'...done"
244 if test "$out" != "$expectout"; then
245 echo expected
: $expectout >&2
246 echo -----got: $out >&2
251 out
=`$SHISA -c $CONF -d`
252 if test $?
!= 0; then
259 Current key version 0 (0x0).
261 Etype aes256-cts-hmac-sha1-96 (0x12, 18).
264 Current key version 0 (0x0).
266 Etype aes256-cts-hmac-sha1-96 (0x12, 18)."
267 if test "$out" != "$expectout"; then
268 echo expected
: $expectout >&2
269 echo -----got: $out >&2
273 echo Tring to remove entire realm.
274 out
=`$SHISA -c $CONF -r TESTREALM 2>&1`
275 if test $?
!= 1; then
281 out
=`$SHISA -c $CONF -d`
282 if test $?
!= 0; then
289 Current key version 0 (0x0).
291 Etype aes256-cts-hmac-sha1-96 (0x12, 18).
294 Current key version 0 (0x0).
296 Etype aes256-cts-hmac-sha1-96 (0x12, 18)."
297 if test "$out" != "$expectout"; then
298 echo expected
: $expectout >&2
299 echo -----got: $out >&2
303 echo Add principal with des key and password.
304 out
=`$SHISA -c $CONF -a TESTREALM test/principal2 -E des --password=foo --keys`
305 if test $?
!= 0; then
309 expectout
="Adding principal \`test/principal2@TESTREALM'...
310 -----BEGIN SHISHI KEY-----
311 Keytype: 3 (des-cbc-md5)
312 Principal: test/principal2
316 -----END SHISHI KEY-----
317 Adding principal \`test/principal2@TESTREALM'...done"
318 if test "$out" != "$expectout"; then
319 echo expected
: $expectout >&2
320 echo -----got: $out >&2
324 echo Add aes key with password to principal.
325 out
=`$SHISA -c $CONF -n TESTREALM test/principal2 -E aes --password=foo --keys`
326 if test $?
!= 0; then
330 expectout
="Adding key to \`test/principal2@TESTREALM'...
331 -----BEGIN SHISHI KEY-----
332 Keytype: 18 (aes256-cts-hmac-sha1-96)
333 Principal: test/principal2
336 3XpVlkzCS2gGYbaShDQktrmYVkcqvMIMuJKLxq9a6oU=
337 -----END SHISHI KEY-----
338 Adding key to \`test/principal2@TESTREALM'...done"
339 if test "$out" != "$expectout"; then
340 echo expected
: $expectout >&2
341 echo -----got: $out >&2
346 out
=`$SHISA -c $CONF -d`
347 if test $?
!= 0; then
354 Current key version 0 (0x0).
356 Etype aes256-cts-hmac-sha1-96 (0x12, 18).
359 Current key version 0 (0x0).
361 Etype des-cbc-md5 (0x3, 3).
363 Etype aes256-cts-hmac-sha1-96 (0x12, 18).
366 Current key version 0 (0x0).
368 Etype aes256-cts-hmac-sha1-96 (0x12, 18)."
369 if test "$out" != "$expectout"; then
370 echo expected
: $expectout >&2
371 echo -----got: $out >&2
375 echo Add
3des key with password to principal.
376 out
=`$SHISA -c $CONF -n TESTREALM test/principal2 -E des3 --password=foo --keys`
377 if test $?
!= 0; then
381 expectout
="Adding key to \`test/principal2@TESTREALM'...
382 -----BEGIN SHISHI KEY-----
383 Keytype: 16 (des3-cbc-sha1-kd)
384 Principal: test/principal2
387 nXV/NLyMwgSunRZATGitesFP466wyGfZ
388 -----END SHISHI KEY-----
389 Adding key to \`test/principal2@TESTREALM'...done"
390 if test "$out" != "$expectout"; then
391 echo expected
: $expectout >&2
392 echo -----got: $out >&2
397 out
=`$SHISA -c $CONF -d`
398 if test $?
!= 0; then
405 Current key version 0 (0x0).
407 Etype aes256-cts-hmac-sha1-96 (0x12, 18).
410 Current key version 0 (0x0).
412 Etype des-cbc-md5 (0x3, 3).
414 Etype aes256-cts-hmac-sha1-96 (0x12, 18).
416 Etype des3-cbc-sha1-kd (0x10, 16).
419 Current key version 0 (0x0).
421 Etype aes256-cts-hmac-sha1-96 (0x12, 18)."
422 if test "$out" != "$expectout"; then
423 echo expected
: $expectout >&2
424 echo -----got: $out >&2
428 echo Remove first principal.
429 out
=`$SHISA -c $CONF -r TESTREALM test/principal`
430 if test $?
!= 0; then
434 expectout
="Removing principal \`test/principal@TESTREALM'...
435 Removing principal \`test/principal@TESTREALM'...done"
436 if test "$out" != "$expectout"; then
437 echo expected
: $expectout >&2
438 echo -----got: $out >&2
442 echo Remove third principal.
443 out
=`$SHISA -c $CONF -r TESTREALM test/principal3`
444 if test $?
!= 0; then
448 expectout
="Removing principal \`test/principal3@TESTREALM'...
449 Removing principal \`test/principal3@TESTREALM'...done"
450 if test "$out" != "$expectout"; then
451 echo expected
: $expectout >&2
452 echo -----got: $out >&2
456 echo Remove aes key on second principal.
457 out
=`$SHISA -c $CONF --key-remove TESTREALM test/principal2 -E aes`
458 if test $?
!= 0; then
462 expectout
="Removing key from \`test/principal2@TESTREALM'...
463 Removing key from \`test/principal2@TESTREALM'...done"
464 if test "$out" != "$expectout"; then
465 echo expected
: $expectout >&2
466 echo -----got: $out >&2
471 out
=`$SHISA -c $CONF -d`
472 if test $?
!= 0; then
479 Current key version 0 (0x0).
481 Etype des-cbc-md5 (0x3, 3).
483 Etype des3-cbc-sha1-kd (0x10, 16)."
484 if test "$out" != "$expectout"; then
485 echo expected
: $expectout >&2
486 echo -----got: $out >&2
490 echo Add
3des key with password to principal.
491 out
=`$SHISA -c $CONF -n TESTREALM test/principal2 -E des3 --password=bar --keys`
492 if test $?
!= 0; then
496 expectout
="Adding key to \`test/principal2@TESTREALM'...
497 -----BEGIN SHISHI KEY-----
498 Keytype: 16 (des3-cbc-sha1-kd)
499 Principal: test/principal2
502 wb9SbVsgCEmttWiFikwvGQLj5YZ2NFja
503 -----END SHISHI KEY-----
504 Adding key to \`test/principal2@TESTREALM'...done"
505 if test "$out" != "$expectout"; then
506 echo expected
: $expectout >&2
507 echo -----got: $out >&2
512 out
=`$SHISA -c $CONF -d --keys`
513 if test $?
!= 0; then
520 Current key version 0 (0x0).
522 Etype des-cbc-md5 (0x3, 3).
523 -----BEGIN SHISHI KEY-----
524 Keytype: 3 (des-cbc-md5)
525 Principal: test/principal2
529 -----END SHISHI KEY-----
532 Etype des3-cbc-sha1-kd (0x10, 16).
533 -----BEGIN SHISHI KEY-----
534 Keytype: 16 (des3-cbc-sha1-kd)
535 Principal: test/principal2
538 wb9SbVsgCEmttWiFikwvGQLj5YZ2NFja
539 -----END SHISHI KEY-----
542 Etype des3-cbc-sha1-kd (0x10, 16).
543 -----BEGIN SHISHI KEY-----
544 Keytype: 16 (des3-cbc-sha1-kd)
545 Principal: test/principal2
548 nXV/NLyMwgSunRZATGitesFP466wyGfZ
549 -----END SHISHI KEY-----
551 if test "$out" != "$expectout"; then
552 echo expected
: $expectout >&2
553 echo -----got: $out >&2
557 echo Remove
3des key with password
'bar' on second principal.
558 out
=`$SHISA -c $CONF --key-remove TESTREALM test/principal2 -E des3 --password=bar`
559 if test $?
!= 0; then
563 expectout
="Removing key from \`test/principal2@TESTREALM'...
564 Removing key from \`test/principal2@TESTREALM'...done"
565 if test "$out" != "$expectout"; then
566 echo expected
: $expectout >&2
567 echo -----got: $out >&2
571 echo Remove
3des key with password
'foo' on second principal.
572 out
=`$SHISA -c $CONF --key-remove TESTREALM test/principal2 -E des3 --password=foo`
573 if test $?
!= 0; then
577 expectout
="Removing key from \`test/principal2@TESTREALM'...
578 Removing key from \`test/principal2@TESTREALM'...done"
579 if test "$out" != "$expectout"; then
580 echo expected
: $expectout >&2
581 echo -----got: $out >&2
586 out
=`$SHISA -c $CONF -d`
587 if test $?
!= 0; then
594 Current key version 0 (0x0).
596 Etype des-cbc-md5 (0x3, 3)."
597 if test "$out" != "$expectout"; then
598 echo expected
: $expectout >&2
599 echo -----got: $out >&2