1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-11-10 21:38:50 +01:00

New tests

This commit is contained in:
Werner Koch 1998-04-08 19:42:07 +00:00
parent 232547e4c0
commit 8ab0adb9f8
23 changed files with 153 additions and 58 deletions

View File

@ -1,27 +1,30 @@
## Process this file with automake to create Makefile.in ## Process this file with automake to create Makefile.in
TESTS = version.test decrypt.test clearsig.test armsigs.test \ TESTS = version.test \
sigs.test armencrypt.test armencryptp.test \ decrypt.test decrypt-dsa.test \
encrypt.test encryptp.test signencrypt.test \ sigs.test sigs-dsa.test \
armsignencrypt.test armdetach.test detach.test \ encrypt.test encrypt-dsa.test \
clearsig.test encryptp.test detach.test \
armsigs.test armencrypt.test armencryptp.test \
signencrypt.test signencrypt-dsa.test \
armsignencrypt.test armdetach.test \
armdetachm.test detachm.test genkey1024.test armdetachm.test detachm.test genkey1024.test
TEST_FILES = pubring.asc secring.asc gnupg.asc plain-1 plain-2 plain-3o.asc \ TEST_FILES = pubring.asc secring.asc gnupg.asc plain-1 plain-2 plain-3o.asc \
plain-1.asc plain-2.asc plain-3.asc \ plain-1.asc plain-2.asc plain-3.asc plain-1-pgp.asc \
pubring.pkr.asc secring.skr.asc pubring.pkr.asc secring.skr.asc
DATA_FILES = data-500 data-9000 data-32000 data-80000 DATA_FILES = data-500 data-9000 data-32000 data-80000
EXTRA_DIST = defs.inc $(TESTS) $(TEST_FILES) EXTRA_DIST = defs.inc run-gpg run-gpgm $(TESTS) $(TEST_FILES)
CLEANFILES = prepared.stamp x y z out err $(DATA_FILES) CLEANFILES = prepared.stamp x y z out err $(DATA_FILES)
check: prepared.stamp check: prepared.stamp
prepared.stamp: pubring.gpg secring.gpg gnupg.sig plain-3 \ prepared.stamp: pubring.gpg secring.gpg gnupg.sig plain-3 \
pubring.pkr secring.skr $(DATA_FILES) pubring.pkr secring.skr $(DATA_FILES)
@set -x; \ @echo "def" | ../g10/gpg -v --no-operation; \
echo "def" | ../g10/gpg -v --no-operation; \
echo timestamp >./prepared.stamp echo timestamp >./prepared.stamp
pubring.gpg: pubring.asc pubring.gpg: pubring.asc

View File

@ -5,7 +5,7 @@
#info Checking armored detached signatures #info Checking armored detached signatures
for i in $plain_files $data_files ; do for i in $plain_files $data_files ; do
echo "$usrpass1" | run_gpg --passphrase-fd 0 -sab -o x --yes $i echo "$usrpass1" | ./run-gpg --passphrase-fd 0 -sab -o x --yes $i
run_gpg -o /dev/null --yes x <$i || error "$i: bad signature" ./run-gpg -o /dev/null --yes x <$i || error "$i: bad signature"
done done

View File

@ -4,6 +4,6 @@
#info Checking armored detached signatures of multiple files #info Checking armored detached signatures of multiple files
i="$plain_files $data_files" i="$plain_files $data_files"
echo "$usrpass1" | run_gpg --passphrase-fd 0 -sab -o x --yes $i echo "$usrpass1" | ./run-gpg --passphrase-fd 0 -sab -o x --yes $i
cat $i | run_gpg -o /dev/null --yes x || error "$i: bad signature" cat $i | ./run-gpg -o /dev/null --yes x || error "$i: bad signature"

View File

@ -4,8 +4,8 @@
#info Checking armored encryption #info Checking armored encryption
for i in $plain_files $data_files ; do for i in $plain_files $data_files ; do
run_gpg -ea -o x --yes -r "$usrname2" $i ./run-gpg -ea -o x --yes -r "$usrname2" $i
run_gpg -o y --yes x ./run-gpg -o y --yes x
cmp $i y || error "$i: mismatch" cmp $i y || error "$i: mismatch"
done done

View File

@ -4,9 +4,9 @@
#info Checking armored encryption with a pipe #info Checking armored encryption with a pipe
for i in $plain_files $data_files ; do for i in $plain_files $data_files ; do
run_gpg -ea --yes -r "$usrname2" < $i | tee x | run_gpg -o y --yes ./run-gpg -ea --yes -r "$usrname2" < $i | tee x | ./run-gpg -o y --yes
cmp $i y || error "$i: mismatch" cmp $i y || error "$i: mismatch"
run_gpg --yes < x > y ./run-gpg --yes < x > y
cmp $i y || error "$i: mismatch" cmp $i y || error "$i: mismatch"
done done

View File

@ -6,8 +6,8 @@
#info Checking armored signing and encryption #info Checking armored signing and encryption
for i in $plain_files $data_files ; do for i in $plain_files $data_files ; do
echo "$usrpass1" \ echo "$usrpass1" \
| run_gpg --passphrase-fd 0 -sae -o x --yes -r "$usrname2" $i | ./run-gpg --passphrase-fd 0 -sae -o x --yes -r "$usrname2" $i
run_gpg -o y --yes x ./run-gpg -o y --yes x
cmp $i y || error "$i: mismatch" cmp $i y || error "$i: mismatch"
done done

View File

@ -4,8 +4,8 @@
#info Checking armored signatures #info Checking armored signatures
for i in $plain_files $data_files ; do for i in $plain_files $data_files ; do
echo "$usrpass1" | run_gpg --passphrase-fd 0 -sa -o x --yes $i echo "$usrpass1" | ./run-gpg --passphrase-fd 0 -sa -o x --yes $i
run_gpg -o y --yes x ./run-gpg -o y --yes x
cmp $i y || error "$i: mismatch" cmp $i y || error "$i: mismatch"
done done

View File

@ -12,8 +12,8 @@
# I know that this does not work for random data files (due to large lines # I know that this does not work for random data files (due to large lines
# or what ever) - I hope we can live with it. # or what ever) - I hope we can live with it.
for i in $plain_files; do for i in $plain_files; do
echo "$usrpass1" | run_gpg --passphrase-fd 0 -sat -o x --yes $i echo "$usrpass1" | ./run-gpg --passphrase-fd 0 -sat -o x --yes $i
run_gpg -o y --yes x ./run-gpg -o y --yes x
../tools/clean-sat < $i > z ../tools/clean-sat < $i > z
head -c $[ $(cat y | wc -c) - 1 ] y | diff - z || error "$i: mismatch" head -c $[ $(cat y | wc -c) - 1 ] y | diff - z || error "$i: mismatch"
done done

10
checks/decrypt-dsa.test Executable file
View File

@ -0,0 +1,10 @@
#!/bin/sh
. defs.inc || exit 3
#info Checking decryption of supplied DSA encrypted file
for i in "plain-1" ; do
./run-gpg $dsa_keyrings -o y --yes $i-pgp.asc
cmp $i y || error "$i: mismatch"
done

View File

@ -4,7 +4,7 @@
#info Checking decryption of supplied files #info Checking decryption of supplied files
for i in $plain_files ; do for i in $plain_files ; do
echo "$usrpass1" | run_gpg --passphrase-fd 0 -o y --yes $i.asc echo "$usrpass1" | ./run-gpg --passphrase-fd 0 -o y --yes $i.asc
cmp $i y || error "$i: mismatch" cmp $i y || error "$i: mismatch"
done done

View File

@ -9,10 +9,21 @@ usrname1="one"
usrpass1="def" usrpass1="def"
usrname2="two" usrname2="two"
usrpass2="" usrpass2=""
plain_files="plain-1 plain-2 plain-3"
data_files="data-500 data-9000 data-32000 data-80000"
dsa_usrname1="pgp5"
# we use the sub key because we do not yet have the logic to
# to derive the first encryption key from a keyblock (I guess)
dsa_usrname2="0xCB879DE9"
dsa_keyrings="--keyring ./pubring.pkr --secret-keyring ./secring.skr"
#plain_files="plain-1 plain-2 plain-3"
plain_files="plain-1"
#data_files="data-500 data-9000 data-32000 data-80000"
data_files="data-500"
exp_files="" exp_files=""
#cleanup_files="x y z"
#-------------------------------- #--------------------------------
@ -47,23 +58,6 @@ chdir () {
# cleanup_files="$cleanup_files $*" # cleanup_files="$cleanup_files $*"
#} #}
run_gpg () {
if ! eval ../g10/gpg --homedir . $* 2>err ; then
cat err >&2
echo "(../g10/gpg --homedir . $*) failed" >&2
exit 1
fi
grep -v 'gpg: Good signature from' err || true
}
run_gpgm () {
if ! eval ../g10/gpgm --homedir . $* ; then
echo "(../g10/gpgm --homedir . $*) failed" >&2
exit 1
fi
}
set -e set -e
pgmname=$(basename $0) pgmname=$(basename $0)

View File

@ -4,7 +4,7 @@
#info Checking detached signatures #info Checking detached signatures
for i in $plain_files $data_files ; do for i in $plain_files $data_files ; do
echo "$usrpass1" | run_gpg --passphrase-fd 0 -sb -o x --yes $i echo "$usrpass1" | ./run-gpg --passphrase-fd 0 -sb -o x --yes $i
run_gpg -o /dev/null --yes x <$i || error "$i: bad signature" ./run-gpg -o /dev/null --yes x <$i || error "$i: bad signature"
done done

View File

@ -4,6 +4,6 @@
#info Checking detached signatures of multiple files #info Checking detached signatures of multiple files
i="$plain_files $data_files" i="$plain_files $data_files"
echo "$usrpass1" | run_gpg --passphrase-fd 0 -sb -o x --yes $i echo "$usrpass1" | ./run-gpg --passphrase-fd 0 -sb -o x --yes $i
cat $i | run_gpg -o /dev/null --yes x || error "$i: bad signature" cat $i | ./run-gpg -o /dev/null --yes x || error "$i: bad signature"

19
checks/encrypt-dsa.test Executable file
View File

@ -0,0 +1,19 @@
#!/bin/sh
. defs.inc || exit 3
#info Checking encryption
for i in $plain_files $data_files ; do
./run-gpg $dsa_keyrings -e -o x --yes -r "$dsa_usrname2" $i
./run-gpg $dsa_keyrings -o y --yes x
cmp $i y || error "$i: mismatch"
done
# and with cast
for i in $plain_files $data_files ; do
./run-gpg $dsa_keyrings --cipher-algo cast -e \
-o x --yes -r "$dsa_usrname2" $i
./run-gpg $dsa_keyrings -o y --yes x
cmp $i y || error "$i: mismatch"
done

View File

@ -4,8 +4,13 @@
#info Checking encryption #info Checking encryption
for i in $plain_files $data_files ; do for i in $plain_files $data_files ; do
run_gpg -e -o x --yes -r "$usrname2" $i ./run-gpg -e -o x --yes -r "$usrname2" $i
run_gpg -o y --yes x ./run-gpg -o y --yes x
cmp $i y || error "$i: mismatch"
done
for i in $plain_files $data_files ; do
./run-gpg -e -o x --yes -r "$usrname2" --cipher-algo cast $i
./run-gpg -o y --yes x
cmp $i y || error "$i: mismatch" cmp $i y || error "$i: mismatch"
done done

View File

@ -4,7 +4,7 @@
#info Checking encryption with a pipe #info Checking encryption with a pipe
for i in $plain_files $data_files ; do for i in $plain_files $data_files ; do
run_gpg -e --yes -r "$usrname2" < $i | run_gpg --yes > y ./run-gpg -e --yes -r "$usrname2" <$i | tee yy | ./run-gpg --yes > y
cmp $i y || fatal "$i: mismatch" cmp $i y || error "$i: mismatch"
done done

11
checks/run-gpg Executable file
View File

@ -0,0 +1,11 @@
#!/bin/sh
if ! ../g10/gpg --homedir . $* 2>err.tmp.$$ ; then
echo "(../g10/gpg --homedir . $*) failed" >&2
cat err.tmp.$$ >&2
rm err.tmp.$$
exit 1
fi
grep -v 'gpg: Good signature from' err.tmp.$$ || true
rm err.tmp.$$

10
checks/run-gpgm Executable file
View File

@ -0,0 +1,10 @@
#!/bin/sh
if ! ../g10/gpgm --homedir . $* 2>err.tmp.$$ ; then
echo "(../g10/gpgm --homedir . $*) failed" >&2
cat err.tmp.$$ >&2
rm err.tmp.$$
exit 1
fi
rm err.tmp.$$

22
checks/signencrypt-dsa.test Executable file
View File

@ -0,0 +1,22 @@
#!/bin/sh
. defs.inc || exit 3
#info Checking signing and encryption for DSA
for i in $plain_files $data_files ; do
./run-gpg $dsa_keyrings -se -o x --yes \
-u "$dsa_usrname1" -r "$dsa_usrname2" $i
./run-gpg $dsa_keyrings -o y --yes x
cmp $i y || error "$i: mismatch"
done
for da in rmd160 sha1 md5; do
for i in $plain_files; do
./run-gpg $dsa_keyrings -se -o x --yes --digest-algo $da \
-u "$dsa_usrname1" -r "$dsa_usrname2" $i
./run-gpg $dsa_keyrings -o y --yes x
cmp $i y || error "$i: mismatch"
# process only the first one
break
done
done

View File

@ -6,8 +6,8 @@
#info Checking signing and encryption #info Checking signing and encryption
for i in $plain_files $data_files ; do for i in $plain_files $data_files ; do
echo "$usrpass1" \ echo "$usrpass1" \
| run_gpg --passphrase-fd 0 -se -o x --yes -r "$usrname2" $i | ./run-gpg --passphrase-fd 0 -se -o x --yes -r "$usrname2" $i
run_gpg -o y --yes x ./run-gpg -o y --yes x
cmp $i y || error "$i: mismatch" cmp $i y || error "$i: mismatch"
done done

22
checks/sigs-dsa.test Executable file
View File

@ -0,0 +1,22 @@
#!/bin/sh
. defs.inc || exit 3
#info Checking DSA signatures (default digest algo)
for i in $plain_files $data_files; do
./run-gpg $dsa_keyrings -s -o x --yes -u $dsa_usrname1 $i
./run-gpg $dsa_keyrings -o y --yes x
cmp $i y || error "$i: mismatch"
done
for da in rmd160 sha1 md5; do
for i in $plain_files; do
./run-gpg $dsa_keyrings --digest-algo $da \
-s -o x --yes -u $dsa_usrname1 $i
./run-gpg $dsa_keyrings -o y --yes x
cmp $i y || error "$i: mismatch"
# process only the first one
break
done
done

View File

@ -4,8 +4,8 @@
#info Checking signatures #info Checking signatures
for i in $plain_files $data_files; do for i in $plain_files $data_files; do
echo "$usrpass1" | run_gpg --passphrase-fd 0 -s -o x --yes $i echo "$usrpass1" | ./run-gpg --passphrase-fd 0 -s -o x --yes $i
run_gpg -o y --yes x ./run-gpg -o y --yes x
cmp $i y || error "$i: mismatch" cmp $i y || error "$i: mismatch"
done done

View File

@ -3,8 +3,7 @@
. defs.inc || exit 3 . defs.inc || exit 3
# print the GPG version # print the GPG version
run_gpg --version ./run-gpg --version
cat err
#fixme: check that the output is correct #fixme: check that the output is correct