1#!/bin/bash
2#
3# Copyright 2021-2024 The OpenSSL Project Authors. All Rights Reserved.
4#
5# Licensed under the Apache License 2.0 (the "License").  You may not use
6# this file except in compliance with the License.  You can obtain a copy
7# in the file LICENSE in the source distribution or at
8# https://www.openssl.org/source/license.html
9
10#
11# OpenSSL external testing using the TLSFuzzer test suite
12#
13set -e
14set -x
15
16PWD="$(pwd)"
17
18SRCTOP="$(cd $SRCTOP; pwd)"
19BLDTOP="$(cd $BLDTOP; pwd)"
20
21if [ "$SRCTOP" != "$BLDTOP" ] ; then
22    echo "Out of tree builds not supported with TLSFuzzer test!"
23    exit 1
24fi
25
26O_EXE="$BLDTOP/apps"
27O_BINC="$BLDTOP/include"
28O_SINC="$SRCTOP/include"
29O_LIB="$BLDTOP"
30
31export PATH="$O_EXE:$PATH"
32export LD_LIBRARY_PATH="$O_LIB:$LD_LIBRARY_PATH"
33export OPENSSL_ROOT_DIR="$O_LIB"
34
35
36CLI="${O_EXE}/openssl"
37SERV="${O_EXE}/openssl"
38
39# Check/Set openssl version
40OPENSSL_VERSION=$($CLI version | cut -f 2 -d ' ')
41
42TMPFILE="${PWD}/tls-fuzzer.$$.tmp"
43PSKFILE="${PWD}/tls-fuzzer.psk.$$.tmp"
44
45PYTHON=`which python3`
46PORT=4433
47
48echo "------------------------------------------------------------------"
49echo "Testing OpenSSL using TLSFuzzer:"
50echo "   CWD:                $PWD"
51echo "   SRCTOP:             $SRCTOP"
52echo "   BLDTOP:             $BLDTOP"
53echo "   OPENSSL_ROOT_DIR:   $OPENSSL_ROOT_DIR"
54echo "   Python:             $PYTHON"
55echo "   TESTDATADIR:        $TESTDATADIR"
56echo "   OPENSSL_VERSION:    $OPENSSL_VERSION"
57echo "------------------------------------------------------------------"
58
59cd "${SRCTOP}/tlsfuzzer"
60
61test -L ecdsa || ln -s ../python-ecdsa/src/ecdsa ecdsa
62test -L tlslite || ln -s ../tlslite-ng/tlslite tlslite 2>/dev/null
63
64retval=0
65
66tls_fuzzer_prepare
67
68PYTHONPATH=. "${PYTHON}" tests/scripts_retention.py ${TMPFILE} ${SERV} 821
69retval=$?
70
71rm -f ${TMPFILE}
72[ -f "${PSKFILE}" ] && rm -f ${PSKFILE}
73
74cd $PWD
75
76exit $retval
77