tlsfuzzer.sh (3156B)
1 #!/bin/bash 2 # 3 # This Source Code Form is subject to the terms of the Mozilla Public 4 # License, v. 2.0. If a copy of the MPL was not distributed with this 5 # file, You can obtain one at http://mozilla.org/MPL/2.0/. 6 7 ######################################################################## 8 # 9 # tests/tlsfuzzer/tlsfuzzer.sh 10 # 11 # Script to drive the ssl tlsfuzzer interop unit tests 12 # 13 ######################################################################## 14 15 tlsfuzzer_certs() 16 { 17 PROFILEDIR=`pwd` 18 19 ${BINDIR}/certutil -N -d "${PROFILEDIR}" --empty-password 2>&1 20 html_msg $? 0 "create tlsfuzzer database" 21 22 pushd "${QADIR}" 23 . common/certsetup.sh 24 popd 25 26 counter=0 27 make_cert rsa rsa2048 sign kex 28 make_cert rsa-pss rsapss sign kex 29 } 30 31 tlsfuzzer_init() 32 { 33 SCRIPTNAME="tlsfuzzer.sh" 34 if [ -z "${INIT_SOURCED}" -o "${INIT_SOURCED}" != "TRUE" ] ; then 35 cd ../common 36 . ./init.sh 37 fi 38 39 mkdir -p "${HOSTDIR}/tlsfuzzer" 40 pushd "${HOSTDIR}/tlsfuzzer" 41 tlsfuzzer_certs 42 43 TLSFUZZER=${TLSFUZZER:=tlsfuzzer} 44 if [ ! -d "$TLSFUZZER" ]; then 45 # Can't use git-copy.sh here, as tlsfuzzer doesn't have any tags 46 git clone -q https://github.com/tomato42/tlsfuzzer/ "$TLSFUZZER" 47 git -C "$TLSFUZZER" checkout 21fd6522f695693a320a1df3c117fd7ced1352a5 48 49 # We could use tlslite-ng from pip, but the pip command installed 50 # on TC is too old to support --pre 51 ${QADIR}/../fuzz/config/git-copy.sh https://github.com/tomato42/tlslite-ng/ v0.8.0-alpha42 tlslite-ng 52 if [ $? != 0 ]; then 53 echo "Error setting up tlslite-ng" 54 exit $? 55 fi 56 57 pushd "$TLSFUZZER" 58 ln -s ../tlslite-ng/tlslite tlslite 59 popd 60 61 # Install tlslite-ng dependencies 62 ${QADIR}/../fuzz/config/git-copy.sh https://github.com/warner/python-ecdsa master python-ecdsa 63 if [ $? != 0 ]; then 64 echo "Error setting up python-ecdsa" 65 exit $? 66 fi 67 68 ${QADIR}/../fuzz/config/git-copy.sh https://github.com/benjaminp/six main six 69 if [ $? != 0 ]; then 70 echo "Error setting up six" 71 exit $? 72 fi 73 74 75 76 pushd "$TLSFUZZER" 77 ln -s ../python-ecdsa/src/ecdsa ecdsa 78 ln -s ../six/six.py . 79 popd 80 fi 81 82 # Find usable port 83 PORT=${PORT-8443} 84 while true; do 85 "${BINDIR}/selfserv" -w nss -d "${HOSTDIR}/tlsfuzzer" -n rsa \ 86 -p "${PORT}" -i selfserv.pid & 87 [ -f selfserv.pid ] || sleep 5 88 if [ -f selfserv.pid ]; then 89 kill $(cat selfserv.pid) 90 wait $(cat selfserv.pid) 91 rm -f selfserv.pid 92 break 93 fi 94 PORT=$(($PORT + 1)) 95 done 96 97 sed -e "s|@PORT@|${PORT}|g" \ 98 -e "s|@SELFSERV@|${BINDIR}/selfserv|g" \ 99 -e "s|@SERVERDIR@|${HOSTDIR}/tlsfuzzer|g" \ 100 -e "s|@HOSTADDR@|${HOSTADDR}|g" \ 101 ${QADIR}/tlsfuzzer/config.json.in > ${TLSFUZZER}/config.json 102 popd 103 104 SCRIPTNAME="tlsfuzzer.sh" 105 html_head "tlsfuzzer test" 106 } 107 108 tlsfuzzer_cleanup() 109 { 110 cd ${QADIR} 111 . common/cleanup.sh 112 } 113 114 tlsfuzzer_run_tests() 115 { 116 pushd "${HOSTDIR}/tlsfuzzer/${TLSFUZZER}" 117 PYTHONPATH=. python3 tests/scripts_retention.py config.json "${BINDIR}/selfserv" 512 118 html_msg $? 0 "tlsfuzzer" "Run successfully" 119 popd 120 } 121 122 cd "$(dirname "$0")" 123 tlsfuzzer_init 124 tlsfuzzer_run_tests 125 tlsfuzzer_cleanup