2015-11-25 18:32:09 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
#set -x
|
|
|
|
|
|
|
|
# Make sure $srcdir is set.
|
|
|
|
if test "x$srcdir" = x
|
|
|
|
then
|
|
|
|
echo srcdir environment variable not set!
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
. $srcdir/defs.inc || exit 3
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
# Make sure $GNUPGHOME is set.
|
|
|
|
if test "x$GNUPGHOME" = x
|
|
|
|
then
|
|
|
|
echo "GNUPGHOME not set."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
TESTFILES="$plain_files $data_files"
|
|
|
|
|
|
|
|
TESTDIR=gpgtar.d
|
|
|
|
FILELIST="${TESTDIR}/filelist"
|
2015-12-01 12:01:12 +01:00
|
|
|
PPFILE="${TESTDIR}/passphrase"
|
2015-12-07 12:53:57 +01:00
|
|
|
PPFLAGS="--gpg-args --passphrase-file=$PPFILE"
|
|
|
|
|
2015-11-25 18:32:09 +01:00
|
|
|
GPG=../../g10/gpg2
|
2015-11-30 18:39:00 +01:00
|
|
|
GPGARGS="$opt_always --no-permission-warning"
|
2015-11-26 15:36:52 +01:00
|
|
|
|
2015-11-25 18:32:09 +01:00
|
|
|
GPGTAR="../../tools/gpgtar"
|
2015-11-26 15:36:52 +01:00
|
|
|
GPGZIP="sh ../../tools/gpg-zip"
|
2015-11-25 18:32:09 +01:00
|
|
|
|
2015-11-30 18:39:00 +01:00
|
|
|
# Create, inspect, and extract an archive with the given options.
|
|
|
|
#
|
|
|
|
# $1 the tool to test
|
|
|
|
# $2 options used to create the archive
|
|
|
|
# $3 options used to inspect the archive
|
|
|
|
# $4 options used to extract the archive
|
|
|
|
do_test()
|
|
|
|
{
|
|
|
|
(
|
|
|
|
TOOL="$1"
|
|
|
|
CREATE_FLAGS="$2"
|
|
|
|
INSPECT_FLAGS="$3"
|
|
|
|
EXTRACT_FLAGS="$4"
|
|
|
|
|
2015-11-25 18:32:09 +01:00
|
|
|
rm -rf -- "${TESTDIR}"
|
|
|
|
mkdir "${TESTDIR}"
|
2015-12-01 12:01:12 +01:00
|
|
|
echo frob >"$PPFILE"
|
2015-11-25 18:32:09 +01:00
|
|
|
|
2015-11-30 18:39:00 +01:00
|
|
|
$TOOL --gpg "$GPG" --gpg-args "$GPGARGS" $CREATE_FLAGS \
|
2015-11-25 18:32:09 +01:00
|
|
|
--output "${TESTDIR}/test.tar.pgp" $TESTFILES
|
|
|
|
|
2015-11-30 18:39:00 +01:00
|
|
|
$TOOL --gpg "$GPG" --gpg-args "$GPGARGS" $INSPECT_FLAGS \
|
|
|
|
"${TESTDIR}/test.tar.pgp" \
|
2015-11-26 15:36:52 +01:00
|
|
|
>"$FILELIST"
|
2015-11-25 18:32:09 +01:00
|
|
|
for F in $TESTFILES
|
|
|
|
do
|
|
|
|
grep -qe "\\b${F}\\b" "$FILELIST"
|
|
|
|
done
|
|
|
|
|
2015-11-30 18:39:00 +01:00
|
|
|
$TOOL --gpg "$GPG" --gpg-args "$GPGARGS" $EXTRACT_FLAGS \
|
2015-11-26 15:36:52 +01:00
|
|
|
--tar-args --directory="${TESTDIR}" \
|
2015-11-30 18:39:00 +01:00
|
|
|
"${TESTDIR}/test.tar.pgp"
|
2015-11-25 18:32:09 +01:00
|
|
|
for F in $TESTFILES
|
|
|
|
do
|
|
|
|
diff -q "$F" "${TESTDIR}/$F"
|
|
|
|
done
|
2015-11-30 18:39:00 +01:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
for TOOL in "$GPGTAR" "$GPGZIP"
|
2015-12-01 12:01:12 +01:00
|
|
|
#for TOOL in "$GPGZIP"
|
2015-11-30 18:39:00 +01:00
|
|
|
do
|
2015-12-07 12:53:57 +01:00
|
|
|
# Asymmetric encryption.
|
2015-11-30 18:39:00 +01:00
|
|
|
do_test "$TOOL" \
|
|
|
|
"--encrypt --recipient $usrname2" \
|
|
|
|
"--list-archive" \
|
|
|
|
"--decrypt"
|
|
|
|
|
2015-12-07 12:53:57 +01:00
|
|
|
# Asymmetric encryption and signing.
|
2015-11-30 18:39:00 +01:00
|
|
|
do_test "$TOOL" \
|
|
|
|
"--encrypt --recipient $usrname2 --sign --local-user $usrname3" \
|
|
|
|
"--list-archive" \
|
|
|
|
"--decrypt"
|
|
|
|
|
2015-12-07 12:53:57 +01:00
|
|
|
# Signing only.
|
2015-11-30 18:39:00 +01:00
|
|
|
do_test "$TOOL" \
|
|
|
|
"--sign --local-user $usrname3" \
|
|
|
|
"--list-archive" \
|
|
|
|
"--decrypt"
|
2015-12-01 12:01:12 +01:00
|
|
|
|
2015-12-07 12:53:57 +01:00
|
|
|
# Symmetric encryption.
|
|
|
|
do_test "$TOOL" \
|
|
|
|
"${PPFLAGS} --symmetric" \
|
|
|
|
"${PPFLAGS} --list-archive" \
|
|
|
|
"${PPFLAGS} --decrypt"
|
|
|
|
|
|
|
|
# Symmetric encryption, explicitly choose cipher.
|
|
|
|
for a in `all_cipher_algos`; do
|
|
|
|
do_test "$TOOL" \
|
|
|
|
"${PPFLAGS} --gpg-args --cipher=$a --symmetric" \
|
|
|
|
"${PPFLAGS} --list-archive" \
|
|
|
|
"${PPFLAGS} --decrypt"
|
|
|
|
break
|
|
|
|
done
|
|
|
|
|
|
|
|
# Asymmetric and symmetric encryption, and signing.
|
2015-12-01 12:01:12 +01:00
|
|
|
do_test "$TOOL" \
|
2015-12-07 12:53:57 +01:00
|
|
|
"${PPFLAGS} --encrypt --symmetric --recipient $usrname2 --sign --local-user $usrname3" \
|
|
|
|
"${PPFLAGS} --list-archive" \
|
|
|
|
"${PPFLAGS} --decrypt"
|
2015-11-25 18:32:09 +01:00
|
|
|
done
|
|
|
|
|
|
|
|
# Success!
|
|
|
|
|
|
|
|
exit 0
|