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