head	1.9;
access;
symbols
	V-0-2-8:1.8
	V0-2-6:1.3;
locks; strict;
comment	@# @;


1.9
date	98.02.26.16.56.15;	author wk;	state dead;
branches;
next	1.8;

1.8
date	98.02.24.18.50.04;	author wk;	state Exp;
branches;
next	1.7;

1.7
date	98.02.18.18.52.56;	author wk;	state Exp;
branches;
next	1.6;

1.6
date	98.02.17.20.38.11;	author wk;	state Exp;
branches;
next	1.5;

1.5
date	98.02.17.20.27.43;	author wk;	state Exp;
branches;
next	1.4;

1.4
date	98.02.17.08.46.59;	author wk;	state Exp;
branches;
next	1.3;

1.3
date	98.02.13.20.58.37;	author wk;	state Exp;
branches;
next	1.2;

1.2
date	98.02.12.14.38.51;	author wk;	state Exp;
branches;
next	1.1;

1.1
date	98.02.11.23.21.58;	author wk;	state Exp;
branches;
next	;


desc
@@


1.9
log
@release 0.2.9
@
text
@#!/bin/bash
#  Script for G10 testing
#---------------------------------------------------------

#--------------------------------
#------ constants ---------------
#--------------------------------

usrname1="one"
usrpass1="def"
usrname2="two"
usrpass2=""
plain_files="plain-1 plain-2"
data_files=""
exp_files=""


#--------------------------------
#------ utility functions -------
#--------------------------------

fatal () {
    echo "$pgmname: fatal:" $* >&2
    exit 1;
}

error () {
    echo "$pgmname:" $* >&2
    exit 1
}

info () {
    echo "$pgmname:" $* >&2
}

chdir () {
    cd $1 || fatal "cannot cd to $1"
}

cleanup () {
    rm $data_files x y z 2>/dev/null
    echo "#empty" >./options
}


run_g10 () {
    if ! eval ../g10/gpg --homedir . $* ; then
	echo "(../g10/gpg --homedir . $*) failed" >&2
	exit 1
    fi
}

run_g10maint () {
    if ! eval ../g10/gpgm --homedir . $* ; then
	echo "(../g10/gpgm --homedir . $*) failed" >&2
	exit 1
    fi
}

#--------------------------------
#-------- main program ----------
#--------------------------------

set -e
pgmname=$(basename $0)
trap cleanup SIGHUP SIGINT SIGQUIT


# some checks
for i in $plain_files plain-3o.asc ; do
    [ -f $i ] || fatal "$i: missing"
done
for i in $exp_files; do
    [ -f $i ] || fatal "$i: script missing"
done
# create the keyrings

cat <<EOF  >./options
no-greeting
no-secmem-warning
batch
EOF

# print the G10 version
run_g10 --version

info Unpacking some material
run_g10maint --yes --dearmor -o pubring.gpg pubring.asc
run_g10maint --yes --dearmor -o secring.gpg secring.asc
run_g10maint --yes --dearmor -o gnupg.sig gnupg.asc
run_g10maint --yes --dearmor -o plain-3 plain-3o.asc
plain_files="$plain_files plain-3"
# make sure all files are created
echo "$usrpass1" | run_g10 --no-operation

info Checking decryption
for i in $plain_files ; do
    echo "$usrpass1" | run_g10 --passphrase-fd 0 -o y --yes $i.asc
    cmp $i y || error "$i: mismatch"
done

info Checking cleartext signatures
# There is a minor glitch, which appends a lf to the cleartext.
# I do not consider that a bug, but I have to use the head .. mimic.
# It is not clear what should happen to leading LFs, we must
# change the defintion of cleartext, so that only 1 empty line
# must follow the headers, but some specs say: any number of empty lines ..
# clean-sat removes leading LFs
# 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.
for i in $plain_files; do
    echo "$usrpass1" | run_g10 --passphrase-fd 0 -sat -o x --yes $i
    run_g10 -o y --yes x
    ../tools/clean-sat < $i > z
    head -c $[ $(cat y | wc -c) - 1 ] y | diff - z || error "$i: mismatch"
done

info Creating some random data files
for i in 500 9000 32000 80000; do
    head -c $i /dev/urandom >data-$i
    data_files="$data_files data-$i"
done

info Checking armored signatures
for i in $plain_files $data_files ; do
    echo "$usrpass1" | run_g10 --passphrase-fd 0 -sa -o x --yes $i
    run_g10 -o y --yes x
    cmp $i y || error "$i: mismatch"
done

info Checking signatures
for i in $plain_files $data_files; do
    echo "$usrpass1" | run_g10 --passphrase-fd 0 -s -o x --yes $i
    run_g10 -o y --yes x
    cmp $i y || error "$i: mismatch"
done


info Checking armored encryption
for i in $plain_files $data_files ; do
    run_g10 -ea -o x --yes -r "$usrname2" $i
    run_g10 -o y --yes x
    cmp $i y || error "$i: mismatch"
done

info Checking armored encryption with a pipe
for i in $plain_files $data_files ; do
    run_g10 -ea --yes -r "$usrname2" < $i | tee x \
    | run_g10 -o y --yes
    cmp $i y || error "$i: mismatch"
    run_g10 --yes < x > y
    cmp $i y || error "$i: mismatch"
done

info Checking encryption
for i in $plain_files $data_files ; do
    run_g10 -e -o x --yes -r "$usrname2" $i
    run_g10 -o y --yes x
    cmp $i y || error "$i: mismatch"
done

info Checking encryption with a pipe
for i in $plain_files $data_files ; do
    run_g10 -e --yes -r "$usrname2" < $i \
    | run_g10 --yes > y
    cmp $i y || error "$i: mismatch"
done


info Checking signing and encryption
for i in $plain_files $data_files ; do
    echo "$usrpass1" \
    | run_g10 --passphrase-fd 0 -se -o x --yes -r "$usrname2" $i
    run_g10 -o y --yes x
    cmp $i y || error "$i: mismatch"
done

info Checking armored signing and encryption
for i in $plain_files $data_files ; do
    echo "$usrpass1" \
    | run_g10 --passphrase-fd 0 -sae -o x --yes -r "$usrname2" $i
    run_g10 -o y --yes x
    cmp $i y || error "$i: mismatch"
done


info Checking armored detached signatures
for i in $plain_files $data_files ; do
    echo "$usrpass1" | run_g10 --passphrase-fd 0 -sab -o x --yes $i
    run_g10 -o /dev/null --yes x  <$i || error "$i: bad signature"
done

info Checking detached signatures
for i in $plain_files $data_files ; do
    echo "$usrpass1" | run_g10 --passphrase-fd 0 -sb -o x --yes $i
    run_g10 -o /dev/null --yes x  <$i || error "$i: bad signature"
done


info Checking detached signatures of multiple files
i="$plain_files $data_files"
echo "$usrpass1" | run_g10 --passphrase-fd 0 -sb -o x --yes $i
cat $i | run_g10 -o /dev/null --yes x || error "$i: bad signature"

info Checking armored detached signatures of multiple files
i="$plain_files $data_files"
echo "$usrpass1" | run_g10 --passphrase-fd 0 -sab -o x --yes $i
cat $i | run_g10 -o /dev/null --yes x || error "$i: bad signature"


info "All tests passed."
exit 0

@


1.8
log
@Renamed to GNUPG
@
text
@@


1.7
log
@rel 0.2.7 mit kleines Korrekturen
@
text
@d47 2
a48 2
    if ! eval ../g10/g10 --homedir . $* ; then
	echo "(../g10/g10 --homedir . $*) failed" >&2
d54 2
a55 2
    if ! eval ../g10/g10maint --homedir . $* ; then
	echo "(../g10/g10maint --homedir . $*) failed" >&2
d88 3
a90 2
run_g10maint --yes --dearmor -o pubring.g10 pubring.asc
run_g10maint --yes --dearmor -o secring.g10 secring.asc
d98 1
a98 1
run_g10 --passphrase-fd 0 -o y --yes $i.asc
@


1.6
log
@removed password from key two
@
text
@d92 2
a93 2


d97 1
a97 1
    echo "$usrpass1" | run_g10 --passphrase-fd 0 -o y --yes $i.asc
@


1.5
log
@new files
@
text
@d12 1
a12 1
usrpass2="abc"
d141 1
a141 1
    echo "$usrpass2" | run_g10 -o y --yes x
a146 1
    info "file $i"
@


1.4
log
@revomoved subdir .g10
@
text
@d13 1
a13 1
plain_files="plain-1 plain-2 plain-3"
d53 7
d70 1
a70 1
for i in $plain_files; do
d87 7
d141 1
a141 1
    run_g10 -o y --yes x
@


1.3
log
@added option export
@
text
@d42 1
a42 1
    echo "#empty" >./.g10/options
d47 2
a48 2
    if ! eval HOME=. ../g10/g10 $* ; then
	echo "(HOME=. ../g10/g10 $*) failed" >&2
a62 1
[ -d "./.g10" ] || fatal "subdirectory .g10 missing"
d71 1
a71 1
cat <<EOF  >./.g10/options
@


1.2
log
@added zlib and reorgnaized some stuff
@
text
@d47 1
a47 3
    eval HOME=. ../g10/g10 $*
    if [ $? != 0 ] ; then
	g10_err=$?
d49 1
a49 1
	error "g10 failed: $g10_err" >&2
d59 1
a59 1
#trap cleanup EXIT SIGHUP SIGINT SIGQUIT
d80 1
a80 1
# intialize the trustdb
d88 15
a102 15
#info Checking cleartext signatures
## There is a minor glitch, which appends a lf to the cleartext.
## I do not consider that a bug, but I have to use the head .. mimic.
## It is not clear what should happen to leading LFs, we must
## change the defintion of cleartext, so that only 1 empty line
## must follow the headers, but some specs say: any number of empty lines ..
## clean-sat removes leading LFs
## 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.
#for i in $plain_files; do
#    echo "$usrpass1" | run_g10 --passphrase-fd 0 -sat -o x --yes $i
#    run_g10 -o y --yes x
#    ../tools/clean-sat < $i > z
#    head -c $[ $(cat y | wc -c) - 1 ] y | diff - z || error "$i: mismatch"
#done
d110 13
a122 13
#info Checking armored signatures
#for i in $plain_files $data_files ; do
#    echo "$usrpass1" | run_g10 --passphrase-fd 0 -sa -o x --yes $i
#    run_g10 -o y --yes x
#    cmp $i y || error "$i: mismatch"
#done
#
#info Checking signatures
#for i in $plain_files $data_files; do
#    echo "$usrpass1" | run_g10 --passphrase-fd 0 -s -o x --yes $i
#    run_g10 -o y --yes x
#    cmp $i y || error "$i: mismatch"
#done
d127 2
a128 3
    info "file $i"
    run_g10 -v -ea -o x --yes -r "$usrname2" $i
    run_g10 -v -o y --yes x
@


1.1
log
@bug fixes
@
text
@a15 1
last_command=""
a28 1
    echo "($last_command) failed" >&2
d40 6
a46 1
    last_command="HOME=. ../g10/g10 $*"
d48 5
d61 2
d72 1
d82 1
d84 4
a87 14
info Checking cleartext signatures
# There is a minor glitch, which appends a lf to the cleartext.
# I do not consider that a bug, but I have to use the head .. mimic.
# It is not clear what should happen to leading LFs, we must
# change the defintion of cleartext, so that only 1 empty line
# must follow the headers, but some specs say: any number of empty lines ..
# clean-sat removes leading LFs
# 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.
for i in $plain_files; do
    echo "$usrpass1" | run_g10 --passphrase-fd 0 -sat -o x --yes $i || error "g10 failed: $?"
    run_g10 -o y --yes x || error "g10 failed: $?"
    ../tools/clean-sat < $i > z
    head -c $[ $(cat y | wc -c) - 1 ] y | diff - z || error "$i: mismatch"
d90 16
d112 13
a124 13
info Checking armored signatures
for i in $plain_files $data_files ; do
    echo "$usrpass1" | run_g10 --passphrase-fd 0 -sa -o x --yes $i || error "g10 failed: $?"
    run_g10 -o y --yes x || error "g10 failed: $?"
    cmp $i y || error "$i: mismatch"
done

info Checking signatures
for i in $plain_files $data_files; do
    echo "$usrpass1" | run_g10 --passphrase-fd 0 -s -o x --yes $i  || error "g10 failed: $?"
    run_g10 -o y --yes x || error "g10 failed: $?"
    cmp $i y || error "$i: mismatch"
done
d129 3
a131 2
    run_g10 -ea -o x --yes -r "$usrname2" $i  || error "g10 failed: $?"
    run_g10 -o y --yes x || error "g10 failed: $?"
d137 1
d139 1
a139 1
    | run_g10 -o y --yes || error "g10 failed: $?"
d141 1
a141 1
    run_g10 --yes < x > y || error "g10 failed: $?"
d147 2
a148 2
    run_g10 -e -o x --yes -r "$usrname2" $i   || error "g10 failed: $?"
    run_g10 -o y --yes x || error "g10 failed: $?"
d155 1
a155 1
    | run_g10 --yes > y || error "g10 failed: $?"
d164 1
a164 1
    run_g10 -o y --yes x || error "g10 failed: $?"
d171 2
a172 2
    | run_g10 --passphrase-fd 0 -sae -o x --yes -r "$usrname2" $i || error "g10 failed: $?"
    run_g10 -o y --yes x || error "g10 failed: $?"
d179 1
a179 1
    echo "$usrpass1" | run_g10 --passphrase-fd 0 -sab -o x --yes $i || error "g10 failed: $?"
d185 1
a185 1
    echo "$usrpass1" | run_g10 --passphrase-fd 0 -sb -o x --yes $i  || error "g10 failed: $?"
d192 1
a192 1
echo "$usrpass1" | run_g10 --passphrase-fd 0 -sb -o x --yes $i  || error "g10 failed: $?"
d197 1
a197 1
echo "$usrpass1" | run_g10 --passphrase-fd 0 -sab -o x --yes $i || error "g10 failed: $?"
a199 1
rm $data_files x y z
@
