2016-12-26 19:03:14 +00:00
|
|
|
#!/usr/bin/env zsh
|
2013-06-12 09:12:33 +00:00
|
|
|
#
|
2016-12-26 19:03:14 +00:00
|
|
|
# Copyright (C) 2007-2016 Dyne.org Foundation
|
|
|
|
#
|
|
|
|
# Tomb test units by Denis Roio <jaromil@dyne.org>
|
|
|
|
#
|
|
|
|
# This source code is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU Public License as published by
|
|
|
|
# the Free Software Foundation; either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This source code is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Please refer
|
|
|
|
# to the GNU Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Public License along with
|
|
|
|
# this source code; if not, write to: Free Software Foundation, Inc.,
|
|
|
|
# 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
2013-06-12 09:12:33 +00:00
|
|
|
|
|
|
|
T="../../tomb"
|
2016-12-26 19:03:14 +00:00
|
|
|
|
2013-06-12 09:12:33 +00:00
|
|
|
source ${T} source
|
2013-06-12 11:41:12 +00:00
|
|
|
dummypass=test
|
2014-06-08 18:31:42 +00:00
|
|
|
dummypassnew=changetest
|
2013-06-12 09:12:33 +00:00
|
|
|
|
2014-10-23 21:31:55 +00:00
|
|
|
GLOBAL_RESULT=0
|
|
|
|
|
2017-01-02 05:24:27 +00:00
|
|
|
notice() { print; _message "${@}"; print; }
|
2013-06-12 09:12:33 +00:00
|
|
|
error() { _warning " ${@}"; }
|
|
|
|
tt() {
|
|
|
|
start_loops=(`sudo losetup -a |cut -d: -f1`)
|
2013-06-12 11:36:50 +00:00
|
|
|
start_temps=(`find /dev/shm -name 'tomb*'`)
|
2013-06-20 08:26:12 +00:00
|
|
|
${T} -D ${=@}
|
2013-06-12 09:12:33 +00:00
|
|
|
res=$?
|
|
|
|
loops=(`sudo losetup -a |cut -d: -f1`)
|
2013-06-12 11:36:50 +00:00
|
|
|
temps=(`find /dev/shm -name 'tomb*'`)
|
|
|
|
|
|
|
|
{ test "${#start_loops}" = "${#loops}" } || {
|
|
|
|
error "loop device usage change to ${#loops}" }
|
|
|
|
{ test "${#start_temps}" = "${#temps}" } || {
|
|
|
|
error "temp files usage change to ${#temps}" }
|
2013-06-12 09:12:33 +00:00
|
|
|
print " Tomb command returns $res"
|
|
|
|
return $res
|
|
|
|
}
|
|
|
|
|
2013-06-12 11:36:50 +00:00
|
|
|
# check for auxiliary programs
|
2014-11-14 17:52:44 +00:00
|
|
|
KDF=1
|
2013-06-12 11:36:50 +00:00
|
|
|
STEGHIDE=1
|
|
|
|
RESIZER=1
|
|
|
|
command -v steghide > /dev/null || STEGHIDE=0
|
|
|
|
command -v e2fsck resize2fs > /dev/null || RESIZER=0
|
|
|
|
command -v tomb-kdb-pbkdf2 > /dev/null || KDF=0
|
2014-06-08 18:31:42 +00:00
|
|
|
command -v qrencode > /dev/null || QRENCODE=0
|
2013-06-12 11:36:50 +00:00
|
|
|
|
|
|
|
|
2013-06-12 09:12:33 +00:00
|
|
|
typeset -A results
|
2017-02-20 19:47:06 +00:00
|
|
|
|
2017-02-03 00:16:29 +00:00
|
|
|
tests=(dig forge lock badpass open close passwd chksum bind setkey recip-dig
|
2017-02-20 19:47:06 +00:00
|
|
|
recip-forge recip-lock recip-open recip-close recip-passwd recip-resize
|
2017-03-03 21:19:04 +00:00
|
|
|
recip-setkey recip-default recip-hidden shared shared-passwd shared-setkey)
|
2017-02-20 19:47:06 +00:00
|
|
|
|
2013-06-12 11:36:50 +00:00
|
|
|
{ test $RESIZER = 1 } && { tests+=(resize) }
|
|
|
|
{ test $KDF = 1 } && { tests+=(kdforge kdfpass kdflock kdfopen) }
|
2017-01-31 16:01:42 +00:00
|
|
|
{ test $STEGHIDE = 1 } && { tests+=(stgin stgout stgopen stgpipe stgimpl
|
|
|
|
recip-stgin recip-stgout recip-stgopen recip-stgimpl) }
|
2014-06-08 18:31:42 +00:00
|
|
|
{ test $QRENCODE = 1 } && { tests+=(qrenc) }
|
2013-06-12 09:12:33 +00:00
|
|
|
|
2017-01-30 21:45:02 +00:00
|
|
|
# GnuPG Conf.
|
|
|
|
# Note: the assumption is the test keys are unencrypted.
|
|
|
|
export GNUPGHOME="gnupg/"
|
|
|
|
chmod 700 "$GNUPGHOME"
|
|
|
|
gpgid_1="A4857CD176B31435F9709D25F0E573B8289439CD"
|
|
|
|
gpgid_2="0B2235E660753AB0475FB3E23DC836481F44B31E"
|
|
|
|
|
2014-11-14 17:52:16 +00:00
|
|
|
notice "Loading test suite"
|
2013-06-12 09:12:33 +00:00
|
|
|
|
2014-11-14 16:43:53 +00:00
|
|
|
# functions that can be called singularly
|
2013-06-12 09:12:33 +00:00
|
|
|
|
2014-11-14 16:43:53 +00:00
|
|
|
test-tomb-create() {
|
2014-11-14 17:52:16 +00:00
|
|
|
|
|
|
|
notice "wiping all test.tomb* in /tmp"
|
|
|
|
sudo rm -f /tmp/test.tomb{,.key,.new.key}
|
|
|
|
|
2014-11-14 16:43:53 +00:00
|
|
|
notice "Testing creation: dig"
|
2013-06-12 09:12:33 +00:00
|
|
|
|
2014-11-14 16:43:53 +00:00
|
|
|
tt dig -s 20 /tmp/test.tomb
|
2013-06-12 09:12:33 +00:00
|
|
|
|
2014-11-14 16:43:53 +00:00
|
|
|
{ test $? = 0 } && { results+=(dig SUCCESS) }
|
2013-06-12 09:12:33 +00:00
|
|
|
|
2014-11-14 16:43:53 +00:00
|
|
|
notice "Testing creation: forge"
|
2013-06-12 09:12:33 +00:00
|
|
|
|
2014-11-14 17:52:16 +00:00
|
|
|
tt forge /tmp/test.tomb.key \
|
2014-11-22 00:50:08 +00:00
|
|
|
--ignore-swap --unsafe --tomb-pwd ${dummypass} --use-urandom
|
2013-06-12 09:12:33 +00:00
|
|
|
|
2014-11-14 16:43:53 +00:00
|
|
|
{ test $? = 0 } && {
|
|
|
|
results+=(forge SUCCESS)
|
|
|
|
#
|
2017-01-21 22:43:12 +00:00
|
|
|
notice "Dump of clear key contents to examine them:"
|
2014-11-14 16:43:53 +00:00
|
|
|
print ${dummypass} \
|
|
|
|
| gpg --batch --passphrase-fd 0 --no-tty --no-options -d /tmp/test.tomb.key \
|
|
|
|
| hexdump -C
|
|
|
|
echo --
|
|
|
|
}
|
2013-06-12 09:12:33 +00:00
|
|
|
|
2014-11-14 16:43:53 +00:00
|
|
|
notice "Testing creation: lock"
|
2013-06-20 08:26:12 +00:00
|
|
|
|
2014-11-14 17:52:16 +00:00
|
|
|
tt lock /tmp/test.tomb -k /tmp/test.tomb.key \
|
2014-11-22 00:50:08 +00:00
|
|
|
--ignore-swap --unsafe --tomb-pwd ${dummypass}
|
2013-06-12 09:12:33 +00:00
|
|
|
|
2014-11-14 16:43:53 +00:00
|
|
|
{ test $? = 0 } && { results+=(lock SUCCESS) }
|
2013-06-20 10:46:20 +00:00
|
|
|
}
|
2013-06-12 09:12:33 +00:00
|
|
|
|
2017-01-30 21:45:02 +00:00
|
|
|
test-tomb-recip() {
|
|
|
|
|
|
|
|
notice "wiping all recip.tomb* in /tmp"
|
|
|
|
local tomb=/tmp/recip.tomb
|
|
|
|
local tomb_key=/tmp/recip.tomb.key
|
|
|
|
sudo rm -f "$tomb" "$tomb_key"
|
|
|
|
|
|
|
|
notice "Testing tomb with recipient creation: dig"
|
|
|
|
tt dig -s 20 $tomb
|
|
|
|
{ test $? = 0 } && { results+=(recip-dig SUCCESS) }
|
|
|
|
|
|
|
|
notice "Testing tomb with recipient creation: forge"
|
2017-02-09 18:57:34 +00:00
|
|
|
tt forge $tomb_key -g -r $gpgid_1 --ignore-swap --unsafe --use-urandom
|
2017-01-30 21:45:02 +00:00
|
|
|
{ test $? = 0 } && { results+=(recip-forge SUCCESS) }
|
|
|
|
|
|
|
|
notice "Testing tomb with recipient creation: lock"
|
2017-02-09 18:57:34 +00:00
|
|
|
tt lock $tomb -k $tomb_key -g -r $gpgid_1 --ignore-swap --unsafe
|
2017-01-30 21:45:02 +00:00
|
|
|
{ test $? = 0 } && { results+=(recip-lock SUCCESS) }
|
|
|
|
|
|
|
|
notice "Testing tomb with recipient opening: open"
|
2017-02-09 18:57:34 +00:00
|
|
|
tt open $tomb -k $tomb_key -g
|
2017-01-30 21:45:02 +00:00
|
|
|
{ test $? = 0 } && { results+=(recip-open SUCCESS) }
|
|
|
|
|
|
|
|
notice "Testing tomb with recipient closing: close"
|
|
|
|
tt close recip
|
|
|
|
{ test $? = 0 } && { results+=(recip-close SUCCESS) }
|
|
|
|
|
2017-01-31 16:01:42 +00:00
|
|
|
{ test $STEGHIDE = 1 } && {
|
|
|
|
notice "Testing tomb with recipient steganographic hiding of keys"
|
|
|
|
|
|
|
|
cp -f arditi.jpg /tmp/recip.jpg
|
|
|
|
sudo rm -f /tmp/recip.steg.key
|
|
|
|
|
2017-01-31 16:23:29 +00:00
|
|
|
tt --unsafe --tomb-pwd ${dummypass} bury -k /tmp/recip.tomb.key \
|
2017-02-09 18:57:34 +00:00
|
|
|
/tmp/recip.jpg -g -r "$gpgid_1"
|
2017-01-31 16:01:42 +00:00
|
|
|
{ test $? = 0 } && { results+=(recip-stgin SUCCESS) }
|
|
|
|
|
2017-01-31 16:23:29 +00:00
|
|
|
tt --unsafe --tomb-pwd ${dummypass} exhume -k /tmp/recip.steg.key \
|
|
|
|
/tmp/recip.jpg
|
2017-01-31 16:01:42 +00:00
|
|
|
{ test $? = 0 } && { results+=(recip-stgout SUCCESS) }
|
|
|
|
|
2017-01-31 16:23:29 +00:00
|
|
|
tt --unsafe --tomb-pwd ${dummypass} open -k /tmp/recip.steg.key \
|
2017-02-09 18:57:34 +00:00
|
|
|
/tmp/recip.tomb -g
|
2017-01-31 16:01:42 +00:00
|
|
|
{ test $? = 0 } && { results+=(recip-stgopen SUCCESS) }
|
|
|
|
${T} close recip
|
|
|
|
|
|
|
|
notice "test using open -k image.jpeg"
|
2017-01-31 16:23:29 +00:00
|
|
|
tt --unsafe --tomb-pwd ${dummypass} open -k /tmp/recip.jpg \
|
2017-02-09 18:57:34 +00:00
|
|
|
/tmp/recip.tomb -g
|
2017-01-31 16:01:42 +00:00
|
|
|
{ test $? = 0 } && { results+=(recip-stgimpl SUCCESS) }
|
|
|
|
tt close recip
|
|
|
|
}
|
|
|
|
|
2017-02-02 23:41:09 +00:00
|
|
|
notice "Testing tomb with recipient changing gpg key: passwd"
|
|
|
|
res=0
|
2017-02-09 18:57:34 +00:00
|
|
|
tt passwd -k $tomb_key -g -r $gpgid_2
|
2017-02-02 23:41:09 +00:00
|
|
|
{ test $? = 0 } || { res=1 }
|
2017-02-09 18:57:34 +00:00
|
|
|
tt open $tomb -k $tomb_key -g
|
2017-02-02 23:41:09 +00:00
|
|
|
{ test $? = 0 } || { res=1 }
|
|
|
|
tt close recip
|
|
|
|
{ test $? = 0 } || { res=1 }
|
|
|
|
{ test $res = 0 } && { results+=(recip-passwd SUCCESS) }
|
|
|
|
|
2017-02-03 00:01:02 +00:00
|
|
|
notice "Testing tomb with recipient resizing a tomb: resize"
|
2017-02-09 18:57:34 +00:00
|
|
|
tt resize -s 30 $tomb -k $tomb_key -g -r $gpgid_2
|
2017-02-03 00:01:02 +00:00
|
|
|
{ test $? = 0 } && { results+=(recip-resize SUCCESS) }
|
|
|
|
|
2017-02-03 00:16:29 +00:00
|
|
|
notice "Testing tomb with recipient setting a new key: setkey"
|
|
|
|
sudo rm -f /tmp/new.recip.tomb.key
|
|
|
|
res=0
|
2017-02-09 18:57:34 +00:00
|
|
|
tt forge /tmp/new.recip.tomb.key -g -r $gpgid_2 \
|
2017-02-03 00:16:29 +00:00
|
|
|
--ignore-swap --unsafe --use-urandom
|
|
|
|
{ test $? = 0 } || { res=1 }
|
2017-02-09 18:57:34 +00:00
|
|
|
tt setkey -k /tmp/new.recip.tomb.key $tomb_key $tomb -g -r $gpgid_2
|
2017-02-03 00:16:29 +00:00
|
|
|
{ test $? = 0 } || { res=1 }
|
2017-02-09 18:57:34 +00:00
|
|
|
tt open -k /tmp/new.recip.tomb.key $tomb -g
|
2017-02-03 00:16:29 +00:00
|
|
|
{ test $? = 0 } || { res=1 }
|
|
|
|
{ test $res = 0 } && { results+=(recip-setkey SUCCESS) }
|
|
|
|
tt close recip
|
2017-01-30 21:45:02 +00:00
|
|
|
}
|
|
|
|
|
2017-03-03 21:19:04 +00:00
|
|
|
test-tomb-recip-default() {
|
2017-03-03 20:36:50 +00:00
|
|
|
|
|
|
|
notice "wiping all default.tomb* in /tmp"
|
2017-04-03 12:24:25 +00:00
|
|
|
rm -f /tmp/default.tomb /tmp/default.tomb.key /tmp/default.tmp
|
2017-03-03 20:36:50 +00:00
|
|
|
|
|
|
|
notice "Testing tomb with the default recipient"
|
|
|
|
res=0
|
|
|
|
tt dig -s 20 /tmp/default.tomb
|
|
|
|
{ test $? = 0 } || { res=1 }
|
|
|
|
tt forge /tmp/default.tomb.key -g --ignore-swap --unsafe --use-urandom
|
|
|
|
{ test $? = 0 } || { res=1 }
|
|
|
|
tt lock /tmp/default.tomb -k /tmp/default.tomb.key \
|
|
|
|
--ignore-swap --unsafe -g
|
|
|
|
{ test $? = 0 } || { res=1 }
|
2017-04-03 12:24:25 +00:00
|
|
|
gpg -d --status-fd 2 /tmp/default.tomb.key 1> /dev/null 2> /tmp/default.tmp
|
|
|
|
[[ -z "$(grep 'Tomb Test 2' /tmp/default.tmp)" ]] && { res=1 }
|
2017-03-03 20:36:50 +00:00
|
|
|
{ test $res = 0 } && { results+=(recip-default SUCCESS) }
|
|
|
|
}
|
|
|
|
|
2017-03-03 21:19:04 +00:00
|
|
|
test-tomb-recip-hidden() {
|
|
|
|
|
|
|
|
notice "wiping all hidden.tomb* in /tmp"
|
|
|
|
rm -f /tmp/hidden.tomb /tmp/hidden.tomb.key
|
|
|
|
|
|
|
|
notice "Testing tomb with hidden recipient"
|
|
|
|
res=0
|
|
|
|
tt dig -s 20 /tmp/hidden.tomb
|
|
|
|
{ test $? = 0 } || { res=1 }
|
|
|
|
tt forge /tmp/hidden.tomb.key -g -R $gpgid_1 --ignore-swap --unsafe --use-urandom
|
|
|
|
{ test $? = 0 } || { res=1 }
|
|
|
|
tt lock /tmp/hidden.tomb -k /tmp/hidden.tomb.key \
|
|
|
|
--ignore-swap --unsafe -g -R $gpgid_1
|
|
|
|
{ test $? = 0 } || { res=1 }
|
|
|
|
{ test $res = 0 } && { results+=(recip-hidden SUCCESS) }
|
|
|
|
}
|
|
|
|
|
2017-02-03 17:28:56 +00:00
|
|
|
test-tomb-shared() {
|
|
|
|
|
|
|
|
notice "wiping all shared.tomb* in /tmp"
|
|
|
|
rm -f /tmp/shared.tomb /tmp/shared.tomb.key
|
|
|
|
|
|
|
|
notice "Testing sharing a tomb"
|
|
|
|
res=0
|
|
|
|
tt dig -s 20 /tmp/shared.tomb
|
|
|
|
{ test $? = 0 } || { res=1 }
|
2017-03-24 20:08:33 +00:00
|
|
|
tt forge /tmp/shared.tomb.key -g -r $gpgid_1,$gpgid_2 \
|
2017-02-03 17:28:56 +00:00
|
|
|
--ignore-swap --unsafe --use-urandom
|
|
|
|
{ test $? = 0 } || { res=1 }
|
|
|
|
tt lock /tmp/shared.tomb -k /tmp/shared.tomb.key \
|
2017-02-09 18:57:34 +00:00
|
|
|
--ignore-swap --unsafe -g -r $gpgid_1
|
2017-02-03 17:28:56 +00:00
|
|
|
{ test $? = 0 } || { res=1 }
|
2017-02-09 18:57:34 +00:00
|
|
|
tt open /tmp/shared.tomb -k /tmp/shared.tomb.key -g
|
2017-02-03 17:28:56 +00:00
|
|
|
{ test $? = 0 } || { res=1 }
|
|
|
|
tt close shared
|
|
|
|
{ test $? = 0 } || { res=1 }
|
|
|
|
{ test $res = 0 } && { results+=(shared SUCCESS) }
|
|
|
|
|
|
|
|
notice "Testing changing recipients on a shared Tomb"
|
2017-03-24 20:08:33 +00:00
|
|
|
tt passwd -k /tmp/shared.tomb.key -g -r $gpgid_2,$gpgid_1
|
2017-02-03 17:28:56 +00:00
|
|
|
{ test $? = 0 } && { results+=(shared-passwd SUCCESS) }
|
|
|
|
|
|
|
|
notice "Testing setkey on a shared Tomb"
|
|
|
|
rm -f /tmp/new.shared.tomb.key
|
|
|
|
res=0
|
2017-03-24 20:08:33 +00:00
|
|
|
tt forge /tmp/new.shared.tomb.key -g -r $gpgid_1,$gpgid_2 \
|
2017-02-03 17:28:56 +00:00
|
|
|
--ignore-swap --unsafe --use-urandom
|
|
|
|
{ test $? = 0 } || { res=1 }
|
|
|
|
tt setkey -k /tmp/new.shared.tomb.key /tmp/shared.tomb.key /tmp/shared.tomb \
|
2017-03-24 20:08:33 +00:00
|
|
|
-g -r $gpgid_2,$gpgid_1
|
2017-02-03 17:28:56 +00:00
|
|
|
{ test $? = 0 } || { res=1 }
|
|
|
|
{ test $res = 0 } && { results+=(shared-setkey SUCCESS) }
|
|
|
|
}
|
|
|
|
|
2014-11-14 16:43:53 +00:00
|
|
|
test-bind-hooks() {
|
|
|
|
notice "Testing bind hooks"
|
2015-06-26 09:47:19 +00:00
|
|
|
|
|
|
|
tt --ignore-swap --unsafe --tomb-pwd ${dummypass} \
|
|
|
|
open /tmp/test.tomb -k /tmp/test.tomb.key
|
|
|
|
|
2014-11-14 16:43:53 +00:00
|
|
|
rnd=$RANDOM
|
|
|
|
bindtest="dyne-tomb-bind-test-$rnd"
|
2015-06-26 09:47:19 +00:00
|
|
|
echo $rnd > /media/test/$bindtest
|
|
|
|
rm -f /media/test/bind-hooks
|
|
|
|
echo "$bindtest $bindtest" > /media/test/bind-hooks
|
2014-11-14 16:43:53 +00:00
|
|
|
touch $HOME/$bindtest
|
|
|
|
tt close test
|
2014-11-22 00:50:08 +00:00
|
|
|
tt -k /tmp/test.tomb.key --unsafe --tomb-pwd ${dummypass} open /tmp/test.tomb
|
2014-11-14 16:43:53 +00:00
|
|
|
rnd2=`cat $HOME/$bindtest`
|
|
|
|
if [ "$rnd" = "$rnd2" ]; then
|
|
|
|
notice "Bind hook on file matches"
|
|
|
|
results+=(bind SUCCESS)
|
|
|
|
tt list test
|
|
|
|
else
|
|
|
|
error "Bind hook on file reports incongruence"
|
|
|
|
fi
|
|
|
|
tt close test
|
|
|
|
}
|
2013-06-20 08:26:12 +00:00
|
|
|
|
2014-11-14 17:52:16 +00:00
|
|
|
test-set-key() {
|
|
|
|
|
|
|
|
notice "Testing set key"
|
|
|
|
|
|
|
|
sudo rm -f /tmp/test.tomb.new.key
|
|
|
|
|
2014-11-22 00:50:08 +00:00
|
|
|
tt forge -k /tmp/test.tomb.new.key --force --unsafe --tomb-pwd ${dummypass} --use-urandom
|
2014-11-14 17:52:16 +00:00
|
|
|
|
2014-11-22 00:50:08 +00:00
|
|
|
tt setkey -k /tmp/test.tomb.new.key --unsafe --tomb-pwd ${dummypass} --tomb-old-pwd ${dummypass} /tmp/test.tomb.key /tmp/test.tomb
|
2014-11-14 17:52:16 +00:00
|
|
|
|
2014-11-22 00:50:08 +00:00
|
|
|
tt open -k /tmp/test.tomb.new.key --unsafe --tomb-pwd ${dummypass} /tmp/test.tomb
|
2014-11-14 17:52:16 +00:00
|
|
|
|
|
|
|
[[ $? = 0 ]] && {
|
|
|
|
notice "Setkey succesfully swapped tomb key"
|
|
|
|
results+=(setkey SUCCESS)
|
2017-01-21 22:43:12 +00:00
|
|
|
notice "Dump of clear key contents to examine them:"
|
2014-11-14 17:52:16 +00:00
|
|
|
print ${dummypass} \
|
|
|
|
| gpg --batch --passphrase-fd 0 --no-tty --no-options -d /tmp/test.tomb.new.key \
|
|
|
|
| hexdump -C
|
|
|
|
echo --
|
|
|
|
mv /tmp/test.tomb.new.key /tmp/test.tomb.key
|
|
|
|
tt close test
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-12 09:12:33 +00:00
|
|
|
|
2016-12-26 19:03:14 +00:00
|
|
|
test-regression() {
|
|
|
|
|
2017-01-21 22:43:12 +00:00
|
|
|
url=${1:-https://files.dyne.org/tomb/old-releases/Tomb-2.2.tar.gz}
|
2016-12-26 19:03:14 +00:00
|
|
|
notice "Regression tests using $url"
|
|
|
|
|
|
|
|
curl $url > /tmp/tomb-regression.tar.gz
|
|
|
|
mkdir -p /tmp/tomb-regression
|
|
|
|
tar xfz /tmp/tomb-regression.tar.gz \
|
|
|
|
--strip-components 1 -C /tmp/tomb-regression
|
|
|
|
|
|
|
|
OLDT="/tmp/tomb-regression/tomb"
|
|
|
|
version=`${OLDT} -v |& awk 'NR==1 {print $3}'`
|
2017-01-02 05:24:27 +00:00
|
|
|
_message "tomb version: $version"
|
2016-12-26 19:03:14 +00:00
|
|
|
tests+=(oldnew-$version newold-$version)
|
|
|
|
|
|
|
|
sudo rm -f /tmp/regression-test.tomb{,.key}
|
|
|
|
|
|
|
|
${OLDT} -D dig -s 10 /tmp/regression-test.tomb
|
|
|
|
${OLDT} -D forge /tmp/regression-test.tomb.key \
|
|
|
|
--ignore-swap --unsafe --tomb-pwd ${dummypass} --use-urandom
|
|
|
|
${OLDT} -D lock /tmp/regression-test.tomb -k /tmp/regression-test.tomb.key \
|
|
|
|
--ignore-swap --unsafe --tomb-pwd ${dummypass}
|
|
|
|
|
|
|
|
notice "opening old tomb and key using the new tomb"
|
|
|
|
|
|
|
|
tt -k /tmp/regression-test.tomb.key --unsafe \
|
|
|
|
--tomb-pwd ${dummypass} open /tmp/regression-test.tomb
|
|
|
|
|
|
|
|
[[ $? = 0 ]] && results+=(oldnew-$version SUCCESS)
|
|
|
|
|
|
|
|
tt close regression-test
|
|
|
|
|
|
|
|
notice "opening new tomb and key using the old tomb"
|
|
|
|
|
|
|
|
${OLDT} -D -k /tmp/test.tomb.key --unsafe \
|
|
|
|
--tomb-pwd ${dummypass} open /tmp/test.tomb
|
|
|
|
|
|
|
|
[[ $? = 0 ]] && results+=(newold-$version SUCCESS)
|
|
|
|
|
|
|
|
${OLDT} close test
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-02-13 00:29:20 +00:00
|
|
|
test-open-read-only() {
|
2016-12-26 19:03:14 +00:00
|
|
|
|
2017-02-13 00:29:20 +00:00
|
|
|
notice "wiping all testro.tomb* in /tmp"
|
|
|
|
sudo rm -f /tmp/testro.tomb{,.key,.new.key}
|
|
|
|
|
|
|
|
# Create new
|
|
|
|
tt dig -s 20 /tmp/testro.tomb
|
|
|
|
tt forge /tmp/testro.tomb.key \
|
|
|
|
--ignore-swap --unsafe --tomb-pwd ${dummypass} --use-urandom
|
|
|
|
tt lock /tmp/testro.tomb -k /tmp/testro.tomb.key \
|
|
|
|
--ignore-swap --unsafe --tomb-pwd ${dummypass}
|
|
|
|
|
|
|
|
notice "Testing open read only"
|
|
|
|
|
|
|
|
# Remove write privilege on test.tomb
|
|
|
|
chmod -w /tmp/testro.tomb
|
|
|
|
|
|
|
|
# Attempt to open the unwritable tomb with the read-only mount option
|
|
|
|
tt open /tmp/testro.tomb -k /tmp/testro.tomb.key \
|
|
|
|
--ignore-swap --unsafe --tomb-pwd ${dummypass} -o ro,noatime,nodev
|
2016-12-26 19:03:14 +00:00
|
|
|
|
2017-02-13 00:29:20 +00:00
|
|
|
{ test $? = 0 } && {
|
|
|
|
results+=(openro SUCCESS)
|
|
|
|
tt close testro
|
|
|
|
}
|
|
|
|
}
|
2016-12-26 19:03:14 +00:00
|
|
|
|
|
|
|
|
2014-11-14 16:43:53 +00:00
|
|
|
startloops=(`sudo losetup -a |cut -d: -f1`)
|
|
|
|
|
|
|
|
[[ $1 = "source" ]] && { return 0 }
|
|
|
|
|
|
|
|
[[ $1 = "" ]] || {
|
|
|
|
tt ${=@}
|
|
|
|
return $?
|
|
|
|
}
|
|
|
|
|
|
|
|
# isolated function (also called with source)
|
|
|
|
test-tomb-create
|
2017-01-30 21:45:02 +00:00
|
|
|
test-tomb-recip
|
2017-03-03 21:19:04 +00:00
|
|
|
test-tomb-recip-default
|
|
|
|
test-tomb-recip-hidden
|
2017-02-03 17:28:56 +00:00
|
|
|
test-tomb-shared
|
2013-06-12 09:12:33 +00:00
|
|
|
|
|
|
|
notice "Testing open with wrong password"
|
|
|
|
|
2014-11-22 00:50:08 +00:00
|
|
|
tt -k /tmp/test.tomb.key --unsafe --tomb-pwd wrongpassword open /tmp/test.tomb
|
2013-06-12 09:12:33 +00:00
|
|
|
|
|
|
|
{ test $? = 0 } || { results+=(badpass SUCCESS) }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
notice "Testing open with good password"
|
|
|
|
|
2014-11-22 00:50:08 +00:00
|
|
|
tt -k /tmp/test.tomb.key --unsafe --tomb-pwd ${dummypass} open /tmp/test.tomb
|
2013-06-12 09:12:33 +00:00
|
|
|
|
|
|
|
{ test $? = 0 } && { results+=(open SUCCESS) }
|
|
|
|
|
2014-06-08 18:31:42 +00:00
|
|
|
tt close test
|
|
|
|
|
2014-08-25 19:06:45 +00:00
|
|
|
{ test $? = 0 } && { results+=(close SUCCESS) }
|
|
|
|
|
2017-02-13 00:29:20 +00:00
|
|
|
# isolated function
|
|
|
|
test-open-read-only
|
2016-12-26 19:03:14 +00:00
|
|
|
|
|
|
|
|
2014-06-08 18:31:42 +00:00
|
|
|
notice "Testing changing tomb password"
|
|
|
|
|
2014-11-14 17:52:16 +00:00
|
|
|
tt passwd /tmp/test.tomb \
|
2014-11-22 00:50:08 +00:00
|
|
|
-k /tmp/test.tomb.key --unsafe --tomb-old-pwd ${dummypass} --tomb-pwd ${dummypassnew}
|
2014-11-14 17:52:16 +00:00
|
|
|
|
|
|
|
tt passwd /tmp/test.tomb \
|
2014-11-22 00:50:08 +00:00
|
|
|
-k /tmp/test.tomb.key --unsafe --tomb-old-pwd ${dummypassnew} --tomb-pwd ${dummypass}
|
2014-06-08 18:31:42 +00:00
|
|
|
|
|
|
|
{ test $? = 0 } && { results+=(passwd SUCCESS) }
|
|
|
|
|
2013-06-12 09:12:33 +00:00
|
|
|
|
|
|
|
|
2014-11-14 17:52:16 +00:00
|
|
|
|
|
|
|
|
2013-06-12 09:12:33 +00:00
|
|
|
notice "Generating content for file integrity test"
|
|
|
|
|
2014-11-22 00:50:08 +00:00
|
|
|
tt -k /tmp/test.tomb.key --unsafe --tomb-pwd ${dummypass} open /tmp/test.tomb
|
2014-06-08 18:31:42 +00:00
|
|
|
|
2015-06-26 09:47:19 +00:00
|
|
|
tt dig -s 10 /media/test/datacheck.raw
|
2013-06-12 09:12:33 +00:00
|
|
|
|
2015-06-26 09:47:19 +00:00
|
|
|
crc="sha256 /media/test/datacheck.raw"
|
|
|
|
echo "$crc" > /media/test/datacheck.sha
|
2013-06-12 09:12:33 +00:00
|
|
|
|
2014-11-22 00:50:08 +00:00
|
|
|
tt --unsafe close test
|
2013-06-12 09:12:33 +00:00
|
|
|
|
2013-06-12 11:36:50 +00:00
|
|
|
{ test $RESIZER = 1 } && {
|
|
|
|
notice "Testing resize to 30 MiB"
|
|
|
|
|
2014-11-22 00:50:08 +00:00
|
|
|
tt --unsafe --tomb-pwd ${dummypass} -k /tmp/test.tomb.key resize /tmp/test.tomb -s 30
|
2013-06-12 11:36:50 +00:00
|
|
|
|
|
|
|
{ test $? = 0 } && { results+=(resize SUCCESS) }
|
2013-06-12 09:12:33 +00:00
|
|
|
|
2013-06-12 11:36:50 +00:00
|
|
|
}
|
2013-06-12 09:12:33 +00:00
|
|
|
|
2013-06-12 11:36:50 +00:00
|
|
|
notice "Testing contents integrity"
|
2013-06-12 09:12:33 +00:00
|
|
|
|
2014-11-22 00:50:08 +00:00
|
|
|
tt -k /tmp/test.tomb.key --unsafe --tomb-pwd ${dummypass} open /tmp/test.tomb
|
2013-06-12 09:12:33 +00:00
|
|
|
|
2014-06-08 18:31:42 +00:00
|
|
|
{ test $? = 0 } && {
|
|
|
|
|
2015-06-26 09:47:19 +00:00
|
|
|
crc2="sha256 /media/test/datacheck.raw"
|
2014-06-08 18:31:42 +00:00
|
|
|
|
|
|
|
{ test "$crc" = "$crc2" } && { results+=(chksum SUCCESS) }
|
2013-06-12 09:12:33 +00:00
|
|
|
|
2014-11-14 16:43:53 +00:00
|
|
|
tt close test
|
2014-06-08 18:31:42 +00:00
|
|
|
}
|
2013-06-12 09:12:33 +00:00
|
|
|
|
2014-11-14 17:52:16 +00:00
|
|
|
|
2016-12-26 19:03:14 +00:00
|
|
|
# regression tests with previous stable versions
|
2017-01-21 22:43:12 +00:00
|
|
|
test-regression https://files.dyne.org/tomb/old-releases/Tomb-2.2.tar.gz
|
2016-12-26 19:03:14 +00:00
|
|
|
test-regression https://files.dyne.org/tomb/old-releases/Tomb-2.1.1.tar.gz
|
|
|
|
test-regression https://files.dyne.org/tomb/old-releases/Tomb-2.0.1.tar.gz
|
2014-11-14 17:52:16 +00:00
|
|
|
|
|
|
|
|
2014-11-14 16:43:53 +00:00
|
|
|
# isolated function
|
|
|
|
test-bind-hooks
|
2013-06-12 09:12:33 +00:00
|
|
|
|
2014-06-08 18:31:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-11-14 16:43:53 +00:00
|
|
|
|
2014-11-14 17:52:16 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# iso func
|
|
|
|
test-set-key
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-06-12 11:36:50 +00:00
|
|
|
{ test $KDF = 1 } && {
|
|
|
|
|
|
|
|
notice "Testing KDF key"
|
|
|
|
sudo rm -f /tmp/test.tomb.kdf /tmp/kdf.tomb
|
|
|
|
|
2014-11-22 00:50:08 +00:00
|
|
|
tt --unsafe --tomb-pwd ${dummypass} --use-urandom --kdf 1 forge -k /tmp/test.tomb.kdf
|
2013-06-12 11:36:50 +00:00
|
|
|
|
|
|
|
{ test $? = 0 } && { results+=(kdforge SUCCESS) }
|
|
|
|
|
2014-11-22 00:50:08 +00:00
|
|
|
tt passwd --unsafe --tomb-old-pwd ${dummypass} --tomb-pwd ${dummypassnew} --kdf 1 -k /tmp/test.tomb.kdf
|
2013-06-12 11:36:50 +00:00
|
|
|
|
|
|
|
{ test $? = 0 } && { results+=(kdfpass SUCCESS) }
|
|
|
|
|
2014-11-14 17:52:16 +00:00
|
|
|
tt dig -s 10 /tmp/kdf.tomb
|
2013-06-12 11:36:50 +00:00
|
|
|
|
2014-11-14 17:52:16 +00:00
|
|
|
tt lock /tmp/kdf.tomb -k /tmp/test.tomb.kdf \
|
2014-11-22 00:50:08 +00:00
|
|
|
--ignore-swap --unsafe --tomb-pwd ${dummypassnew} --kdf 1
|
2013-06-12 11:36:50 +00:00
|
|
|
|
|
|
|
{ test $? = 0 } && { results+=(kdflock SUCCESS) }
|
|
|
|
|
2014-11-14 17:52:16 +00:00
|
|
|
tt open /tmp/kdf.tomb -k /tmp/test.tomb.kdf \
|
2014-11-22 00:50:08 +00:00
|
|
|
--ignore-swap --unsafe --tomb-pwd ${dummypassnew} --kdf 1
|
2013-06-12 11:36:50 +00:00
|
|
|
|
|
|
|
{ test $? = 0 } && { results+=(kdfopen SUCCESS) }
|
|
|
|
|
|
|
|
${T} close kdf
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
{ test $STEGHIDE = 1 } && {
|
|
|
|
|
|
|
|
notice "Testing steganographic hiding of keys"
|
|
|
|
|
|
|
|
cp -f arditi.jpg /tmp/tomb.jpg
|
|
|
|
sudo rm -f /tmp/test.steg.key
|
|
|
|
|
2014-11-22 00:50:08 +00:00
|
|
|
tt --unsafe --tomb-pwd ${dummypass} bury -k /tmp/test.tomb.key /tmp/tomb.jpg
|
2013-06-12 11:36:50 +00:00
|
|
|
|
|
|
|
{ test $? = 0 } && { results+=(stgin SUCCESS) }
|
|
|
|
|
2014-06-08 18:31:42 +00:00
|
|
|
rm -f /tmp/test.steg.key
|
|
|
|
|
2014-11-22 00:50:08 +00:00
|
|
|
tt --unsafe --tomb-pwd ${dummypass} exhume -k /tmp/test.steg.key /tmp/tomb.jpg
|
2013-06-12 11:36:50 +00:00
|
|
|
|
|
|
|
{ test $? = 0 } && { results+=(stgout SUCCESS) }
|
|
|
|
|
2014-11-22 00:50:08 +00:00
|
|
|
tt --unsafe --tomb-pwd ${dummypass} open -k /tmp/test.steg.key /tmp/test.tomb
|
2013-06-12 11:36:50 +00:00
|
|
|
|
|
|
|
{ test $? = 0 } && { results+=(stgopen SUCCESS) }
|
|
|
|
|
|
|
|
${T} close test
|
2014-08-06 05:43:25 +00:00
|
|
|
|
|
|
|
# test piping keys using -k -
|
2014-11-22 00:50:08 +00:00
|
|
|
tkey=`tt --unsafe --tomb-pwd ${dummypass} exhume /tmp/tomb.jpg`
|
|
|
|
print "$tkey" | tt --unsafe --tomb-pwd ${dummypass} open -k - /tmp/test.tomb
|
2014-08-06 05:43:25 +00:00
|
|
|
{ test $? = 0 } && { results+=(stgpipe SUCCESS) }
|
|
|
|
|
|
|
|
${T} close test
|
|
|
|
|
|
|
|
|
|
|
|
notice "test using open -k image.jpeg"
|
|
|
|
|
2014-11-22 00:50:08 +00:00
|
|
|
tt --unsafe --tomb-pwd ${dummypass} open -k /tmp/tomb.jpg /tmp/test.tomb
|
2014-08-06 05:43:25 +00:00
|
|
|
{ test $? = 0 } && { results+=(stgimpl SUCCESS) }
|
|
|
|
|
2014-11-14 17:52:16 +00:00
|
|
|
tt close test
|
2013-06-12 11:36:50 +00:00
|
|
|
}
|
|
|
|
|
2014-06-08 18:31:42 +00:00
|
|
|
{ test $QRENCODE = 1 } && {
|
|
|
|
|
2014-08-06 05:43:25 +00:00
|
|
|
notice "test rendering a QR printable key backup"
|
|
|
|
|
2014-06-08 18:31:42 +00:00
|
|
|
tt engrave -k /tmp/test.tomb.key
|
|
|
|
|
|
|
|
{ test $? = 0 } && { results+=(qrenc SUCCESS) }
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-06-12 11:36:50 +00:00
|
|
|
# rm /tmp/test.tomb{,.key} -f || exit 1
|
|
|
|
|
2013-06-12 09:12:33 +00:00
|
|
|
endloops=(`sudo losetup -a |cut -d: -f1`)
|
|
|
|
|
|
|
|
notice "Test results summary"
|
|
|
|
|
|
|
|
print "${#startloops} loop devices busy at start"
|
|
|
|
|
|
|
|
for t in $tests; do
|
2017-01-30 21:19:43 +00:00
|
|
|
res=${results[$t]:-FAIL}
|
|
|
|
[[ "$res" == "SUCCESS" ]] || GLOBAL_RESULT=1
|
|
|
|
echo "$t\t$res"
|
2014-10-23 21:31:55 +00:00
|
|
|
done
|
|
|
|
|
2013-06-12 09:12:33 +00:00
|
|
|
print "${#endloops} loop devices busy at end"
|
2013-06-12 11:36:50 +00:00
|
|
|
print "Done. You can remove temporary leftovers from /tmp :"
|
|
|
|
for i in `find /tmp -name '*tomb*' 2>/dev/null`; do ls -lh $i; done
|
2014-10-23 21:31:55 +00:00
|
|
|
return $GLOBAL_RESULT
|