#!/bin/sh

# Checking FIPS mode.
# The elliptic curve "sect163r1" is disabled if FIPS is enabled.

. $(dirname $0)/../test_library

start() {
  ../../src/stunnel -fd 0 <<EOT
  debug = debug
  syslog = no
  pid = ${result_path}/stunnel.pid
  output = ${result_path}/stunnel.log

  fips = yes
  curves = sect163r1

  [client]
  client = yes
  accept = 127.0.0.1:${http1}
  connect = 127.0.0.1:${https1}

  [server]
  accept = 127.0.0.1:${https1}
  connect = 127.0.0.1:${http_nc}
  cert = ${script_path}/certs/server_cert.pem
EOT
}

if grep -q ",FIPS" results.log && grep -q " OpenSSL 3" results.log
  then
    test_log_for "122_failure_FIPS_curves" "failure" "0" "$1" "$2" "$3" 2>> "stderr.log"
    exit $?
  else
    exit_logs "122_failure_FIPS_curves" "skipped"
    clean_logs
    exit 125
  fi
