1#! /bin/sh 2 3# function to mark a test as good or bad 4marktest() { 5 local lnum=$1 6 local lgood=$2 7 if [ $lgood -eq $lnum ]; then 8 passed=$(expr $passed + 1) 9 echo "$lnum yes" >> passed 10 else 11 echo "$lnum no" >> passed 12 fi 13} 14 15while [ $# -gt 0 ]; do 16 case "$1" in 17 -v) 18 set -x 19 ;; 20 *) 21 break 22 ;; 23 esac 24 shift 25done 26 27env USETOOLS=no MAKEOBJDIRPREFIX=/usr/build/amd64 sh -c 'cd ../libmj && \ 28 make cleandir ; \ 29 su root -c "make includes"; \ 30 make ; \ 31 su root -c "make install"' 32env USETOOLS=no MAKEOBJDIRPREFIX=/usr/build/amd64 sh -c 'cd ../lib && \ 33 make cleandir ; \ 34 su root -c "make includes"; \ 35 make ; \ 36 su root -c "make install"' 37env USETOOLS=no MAKEOBJDIRPREFIX=/usr/build/amd64 sh -c 'cd ../netpgp && \ 38 make cleandir ; \ 39 make ; \ 40 su root -c "make install"' 41env USETOOLS=no MAKEOBJDIRPREFIX=/usr/build/amd64 sh -c 'cd ../netpgpkeys && \ 42 make cleandir ; \ 43 make ; \ 44 su root -c "make install"' 45 46passed=0 47total=36 48rm -f passed 49date > passed 50echo "======> sign/verify 180938 file" 51cp configure a 52/usr/bin/netpgp --sign a 53/usr/bin/netpgp --verify a.gpg && good=1 54marktest 1 $good 55echo "======> attempt to verify an unsigned file" 56/usr/bin/netpgp --verify a || good=2 57marktest 2 $good 58echo "======> encrypt/decrypt 10809 file" 59cp src/netpgp/netpgp.1 b 60/usr/bin/netpgp --encrypt b 61/usr/bin/netpgp --decrypt b.gpg 62diff src/netpgp/netpgp.1 b && good=3 63marktest 3 $good 64echo "======> encrypt/decrypt 180938 file" 65cp configure c 66/usr/bin/netpgp --encrypt c 67/usr/bin/netpgp --decrypt c.gpg 68diff configure c && good=4 69marktest 4 $good 70echo "======> encrypt/decrypt bigass file" 71cat configure configure configure configure configure configure > d 72ls -l d 73cp d e 74/usr/bin/netpgp --encrypt d 75/usr/bin/netpgp --decrypt d.gpg 76diff e d && good=5 77marktest 5 $good 78echo "======> sign/verify detached signature file" 79cat configure configure configure configure configure configure > f 80/usr/bin/netpgp --sign --detached f 81ls -l f f.sig 82/usr/bin/netpgp --verify f.sig && good=6 83marktest 6 $good 84echo "======> cat signature - verified cat command" 85/usr/bin/netpgp --cat a.gpg > a2 86diff a a2 && good=7 87marktest 7 $good 88echo "======> another cat signature - verified cat command" 89/usr/bin/netpgp --cat --output=a3 a.gpg 90diff a a3 && good=8 91marktest 8 $good 92echo "======> netpgp list-packets test" 93/usr/bin/netpgp --list-packets || good=9 94marktest 9 $good 95echo "======> version information" 96/usr/bin/netpgp --version && good=10 97marktest 10 $good 98echo "======> netpgpverify file" 99/usr/bin/netpgp -v < a.gpg && good=11 100marktest 11 $good 101echo "======> attempt to verify an unsigned file" 102/usr/bin/netpgp -v < a || good=12 103marktest 12 $good 104echo "======> sign/verify detached signature file" 105ls -l f f.sig 106/usr/bin/netpgp -v f.sig && good=13 107marktest 13 $good 108echo "======> another verify signature - verified cat command" 109/usr/bin/netpgp -v --output=a3 < a.gpg 110diff a a3 && good=14 111marktest 14 $good 112echo "======> list keys" 113/usr/bin/netpgpkeys --list-keys && good=15 114marktest 15 $good 115echo "======> version information" 116/usr/bin/netpgp -v --version && good=16 117marktest 16 $good 118echo "======> find specific key information" 119/usr/bin/netpgpkeys --get-key c0596823 agc@netbsd.org && good=17 120marktest 17 $good 121echo "======> ascii armoured signature" 122cp Makefile.am g 123/usr/bin/netpgp --sign --armor g && good=18 124marktest 18 $good 125echo "======> ascii armoured sig detection and verification" 126/usr/bin/netpgp --verify g.asc && good=19 127marktest 19 $good 128echo "======> ascii armoured signature of large file" 129cp Makefile.in g 130/usr/bin/netpgp --sign --armor g && good=20 131marktest 20 $good 132echo "======> ascii armoured sig detection and verification of large file" 133/usr/bin/netpgp --verify g.asc && good=21 134marktest 21 $good 135echo "======> verify memory by recognising ascii armour" 136/usr/bin/netpgp --cat < g.asc > g2 137diff g g2 && good=22 138marktest 22 $good 139echo "======> list ssh host RSA public key" 140/usr/bin/netpgpkeys --ssh --sshkeyfile=/etc/ssh/ssh_host_rsa_key.pub --list-keys && good=23 141marktest 23 $good 142echo "======> sign/verify file with ssh host keys" 143cp configure a 144sudo /usr/bin/netpgp --ssh --sshkeyfile=/etc/ssh/ssh_host_rsa_key.pub --sign a 145sudo chmod 644 a.gpg 146/usr/bin/netpgp --verify --ssh --sshkeyfile=/etc/ssh/ssh_host_rsa_key.pub a.gpg && good=24 147marktest 24 $good 148echo "======> pipeline and memory encrypt/decrypt" 149/usr/bin/netpgp --encrypt < a | /usr/bin/netpgp --decrypt > a4 150diff a a4 && good=25 151marktest 25 $good 152echo "======> pipeline and memory sign/verify" 153/usr/bin/netpgp --sign < a | /usr/bin/netpgp --cat > a5 154diff a a5 && good=26 155marktest 26 $good 156echo "======> verify within a duration" 157cp Makefile.am h 158/usr/bin/netpgp --sign --duration 6m --detached h 159/usr/bin/netpgp --verify h.sig && good=27 160marktest 27 $good 161echo "======> invalid signature - expired" 162rm -f h.sig 163/usr/bin/netpgp --sign --duration 2 --detached h 164sleep 3 165/usr/bin/netpgp --verify h.sig || good=28 166marktest 28 $good 167echo "======> list signatures and subkey signatures" 168/usr/bin/netpgpkeys --list-sigs && good=29 169marktest 29 $good 170echo "======> generate a new RSA key" 171/usr/bin/netpgpkeys --generate-key && good=30 172marktest 30 $good 173echo "======> ascii detached armoured signature" 174cp Makefile.am i 175/usr/bin/netpgp --sign --armor --detached i && good=31 176marktest 31 $good 177echo "======> ascii detached armoured sig detection and verification" 178/usr/bin/netpgp --verify i.asc && good=32 179marktest 32 $good 180echo "======> host ssh fingerprint and netpgp fingerprint" 181netpgpkey=$(/usr/bin/netpgpkeys --ssh --sshkeyfile=/etc/ssh/ssh_host_rsa_key.pub --list-keys --hash=md5 | awk 'NR == 3 { print $3 $4 $5 $6 $7 $8 $9 $10 }') 182sshkey=$(/usr/bin/ssh-keygen -l -f /etc/ssh/ssh_host_rsa_key.pub | awk '{ gsub(":", "", $2); print $2 }') 183echo "host sshkey \"$sshkey\" = netpgpkey \"$netpgpkey\"" 184[ $sshkey = $netpgpkey ] && good=33 185marktest 33 $good 186echo "======> user ssh fingerprint and netpgp fingerprint" 187netpgpkey=$(/usr/bin/netpgpkeys --ssh --list-keys --hash=md5 | awk 'NR == 3 { print $3 $4 $5 $6 $7 $8 $9 $10 }') 188sshkey=$(/usr/bin/ssh-keygen -l -f /home/agc/.ssh/id_rsa.pub | awk '{ gsub(":", "", $2); print $2 }') 189echo "user sshkey \"$sshkey\" = netpgpkey \"$netpgpkey\"" 190[ $sshkey = $netpgpkey ] && good=34 191marktest 34 $good 192echo "======> single key listing" 193/usr/bin/netpgpkeys -l agc && good=35 194marktest 35 $good 195echo "======> pipeline and memory encrypt/decrypt with specified cipher" 196/usr/bin/netpgp -e --cipher camellia128 < a | /usr/bin/netpgp -d > a6 197diff a a6 && good=36 198marktest 36 $good 199rm -f a a.gpg b b.gpg c c.gpg d d.gpg e f f.sig g g.asc g2 a2 a3 a4 a5 a6 h h.sig i i.asc 200echo "Passed ${passed}/${total} tests" 201