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