bionic-amd64-tf-a-build: install OpenSSL 3.0 w/v1.0.1 compat

NOTE: this is a second attempt to install OpenSSL 3.0 in the
Open CI environment, as the last attempt caused the jobs to
fail. If this happens again after merging, please revert this
patch ASAP.

Some build environments (e.g. Yocto) require to link TF-A host
tools (cert_tool and encrypt_fw) against OpenSSL v3.0.

This patch also makes the installation compatible with  v1.0.1
and removes the default libssl-dev from the dockerfile packages.

Signed-off-by: Juan Pablo Conde <juanpablo.conde@arm.com>
Change-Id: Id68ff28a321270acab9400066cba73c058bfedf7
diff --git a/bionic-amd64-tf-a-build/Dockerfile b/bionic-amd64-tf-a-build/Dockerfile
index a19aeea..76b5d6e 100644
--- a/bionic-amd64-tf-a-build/Dockerfile
+++ b/bionic-amd64-tf-a-build/Dockerfile
@@ -28,7 +28,6 @@
     jq \
     lcov \
     libffi-dev \
-    libssl-dev \
     libyaml-dev \
     libxml-libxml-perl \
     lld \
diff --git a/bionic-amd64-tf-a-build/tf-dependencies.install b/bionic-amd64-tf-a-build/tf-dependencies.install
index 072fc5e..3d10341 100755
--- a/bionic-amd64-tf-a-build/tf-dependencies.install
+++ b/bionic-amd64-tf-a-build/tf-dependencies.install
@@ -82,3 +82,19 @@
 chown -R buildslave:buildslave /home/buildslave/.bashrc
 . ${NVM_DIR}/nvm.sh
 nvm install 14
+
+# Install OpenSSL 3.0
+OPENSSL_VER="3.0.2"
+OPENSSL_DIRNAME="openssl-${OPENSSL_VER}"
+OPENSSL_FILENAME="openssl-${OPENSSL_VER}"
+OPENSSL_CHECKSUM="98e91ccead4d4756ae3c9cde5e09191a8e586d9f4d50838e7ec09d6411dfdb63"
+curl --connect-timeout 5 --retry 5 --retry-delay 1 --create-dirs -fsSLo /tmp/${OPENSSL_FILENAME}.tar.gz \
+  https://www.openssl.org/source/${OPENSSL_FILENAME}.tar.gz
+echo "${OPENSSL_CHECKSUM}  /tmp/${OPENSSL_FILENAME}.tar.gz" | sha256sum -c
+mkdir -p ${TOOLS_DIR}/${OPENSSL_DIRNAME} && tar -xzf /tmp/${OPENSSL_FILENAME}.tar.gz -C ${TOOLS_DIR}/${OPENSSL_DIRNAME} --strip-components=1
+cd ${TOOLS_DIR}/${OPENSSL_DIRNAME}
+./Configure --libdir=lib --prefix=/usr --api=1.0.1
+cd ${TOOLS_DIR}
+make -C ${TOOLS_DIR}/${OPENSSL_DIRNAME}
+make -C ${TOOLS_DIR}/${OPENSSL_DIRNAME} install
+