openssl.test 37 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300
  1. #!/usr/bin/env bash
  2. # openssl.test
  3. # Environment variables used:
  4. # OPENSSL (openssl app to use)
  5. # OPENSSL_ENGINE_ID (engine id if any i.e. "wolfengine")
  6. CERT_DIR="$PWD/$(dirname "$0")/../certs"
  7. if ! test -n "$WOLFSSL_OPENSSL_TEST"; then
  8. echo "WOLFSSL_OPENSSL_TEST NOT set, won't run"
  9. exit 77
  10. fi
  11. # if we can, isolate the network namespace to eliminate port collisions.
  12. if [[ -n "$NETWORK_UNSHARE_HELPER" ]]; then
  13. if [[ -z "$NETWORK_UNSHARE_HELPER_CALLED" ]]; then
  14. export NETWORK_UNSHARE_HELPER_CALLED=yes
  15. exec "$NETWORK_UNSHARE_HELPER" "$0" "$@" || exit $?
  16. fi
  17. elif [ "${AM_BWRAPPED-}" != "yes" ]; then
  18. bwrap_path="$(command -v bwrap)"
  19. if [ -n "$bwrap_path" ]; then
  20. export AM_BWRAPPED=yes
  21. exec "$bwrap_path" --unshare-net --dev-bind / / "$0" "$@"
  22. fi
  23. unset AM_BWRAPPED
  24. fi
  25. echo "WOLFSSL_OPENSSL_TEST set, running test..."
  26. # need a unique port since may run the same time as testsuite
  27. generate_port() {
  28. #-------------------------------------------------------------------------#
  29. # Generate a random port number
  30. #-------------------------------------------------------------------------#
  31. if [[ "$OSTYPE" == "linux"* ]]; then
  32. port=$(($(od -An -N2 /dev/urandom) % (65535-49512) + 49512))
  33. elif [[ "$OSTYPE" == "darwin"* ]]; then
  34. port=$(($(od -An -N2 /dev/random) % (65535-49512) + 49512))
  35. else
  36. echo "Unknown OS TYPE"
  37. exit 1
  38. fi
  39. }
  40. no_pid=-1
  41. servers=""
  42. openssl_pid=$no_pid
  43. ecdh_openssl_pid=$no_pid
  44. ecdsa_openssl_pid=$no_pid
  45. ed25519_openssl_pid=$no_pid
  46. ed448_openssl_pid=$no_pid
  47. tls13_psk_openssl_pid=$no_pid
  48. wolfssl_pid=$no_pid
  49. ecdh_wolfssl_pid=$no_pid
  50. ecdsa_wolfssl_pid=$no_pid
  51. ed25519_wolfssl_pid=$no_pid
  52. ed448_wolfssl_pid=$no_pid
  53. tls13_psk_wolfssl_pid=$no_pid
  54. anon_wolfssl_pid=$no_pid
  55. wolf_cases_tested=0
  56. wolf_cases_total=0
  57. counter=0
  58. wolfssl_no_resume=""
  59. testing_summary="OpenSSL Interop Testing Summary:\nVersion\tTested\t#Found\t#wolf\t#Found\t#OpenSSL\n"
  60. versionName="Invalid"
  61. if [ "$OPENSSL" = "" ]; then
  62. OPENSSL=openssl
  63. fi
  64. WOLFSSL_SERVER=./examples/server/server
  65. WOLFSSL_CLIENT=./examples/client/client
  66. version_name() {
  67. case $version in "0")
  68. versionName="SSLv3"
  69. ;;
  70. "1")
  71. versionName="TLSv1"
  72. ;;
  73. "2")
  74. versionName="TLSv1.1"
  75. ;;
  76. "3")
  77. versionName="TLSv1.2"
  78. ;;
  79. "4")
  80. versionName="TLSv1.3"
  81. ;;
  82. "d")
  83. versionName="Down"
  84. ;;
  85. "")
  86. versionName="Def"
  87. ;;
  88. "5")
  89. versionName="ALL"
  90. ;;
  91. esac
  92. }
  93. do_cleanup() {
  94. echo "in cleanup"
  95. IFS=$OIFS #restore separator
  96. for s in $servers
  97. do
  98. f2=${s%:*}
  99. sname=${f2%:*}
  100. pid=${f2##*:}
  101. port=${s##*:}
  102. echo "killing server: $sname ($port)"
  103. kill -9 $pid
  104. done
  105. }
  106. do_trap() {
  107. echo "got trap"
  108. do_cleanup
  109. exit 1
  110. }
  111. trap do_trap INT TERM
  112. check_process_running() {
  113. if [ "$ps_grep" = "" ]
  114. then
  115. ps -p $server_pid > /dev/null
  116. PS_EXIT=$?
  117. else
  118. ps | grep "^ *$server_pid " > /dev/null
  119. PS_EXIT=$?
  120. fi
  121. }
  122. #
  123. # Start an OpenSSL server
  124. #
  125. start_openssl_server() {
  126. if [ "$wolfssl_client_avail" = "" ]
  127. then
  128. return
  129. fi
  130. generate_port
  131. server_port=$port
  132. found_free_port=0
  133. counter=0
  134. # If OPENSSL_ENGINE_ID has been set then check that the desired engine can
  135. # be loaded successfully and error out if not. Otherwise the OpenSSL app
  136. # will fall back to default engine.
  137. if [ ! -z "${OPENSSL_ENGINE_ID}" ]; then
  138. OUTPUT=`$OPENSSL engine -tt $OPENSSL_ENGINE_ID`
  139. if [ $? != 0 ]; then
  140. printf "not able to load engine\n"
  141. printf "$OPENSSL engine -tt $OPENSSL_ENGINE_ID\n"
  142. do_cleanup
  143. exit 1
  144. else
  145. echo $OUTPUT | grep "available"
  146. if [ $? != 0 ]; then
  147. printf "engine not available\n"
  148. do_cleanup
  149. exit 1
  150. fi
  151. fi
  152. OPENSSL_ENGINE_ID="-engine ${OPENSSL_ENGINE_ID}"
  153. fi
  154. while [ "$counter" -lt 20 ]; do
  155. echo -e "\n# Trying to start $openssl_suite OpenSSL server on port $server_port..."
  156. echo "#"
  157. if [ "$cert_file" != "" ]
  158. then
  159. echo "# " $OPENSSL s_server -accept $server_port $OPENSSL_ENGINE_ID -cert \"$cert_file\" -key \"$key_file\" -quiet -CAfile \"$ca_file\" -www -dhparam \"${CERT_DIR}/dh2048.pem\" -verify 10 -verify_return_error -psk $psk_hex -cipher "ALL:eNULL" $openssl_nodhe
  160. $OPENSSL s_server -accept $server_port $OPENSSL_ENGINE_ID -cert "$cert_file" -key "$key_file" -quiet -CAfile "$ca_file" -www -dhparam "${CERT_DIR}/dh2048.pem" -verify 10 -verify_return_error -psk $psk_hex -cipher "ALL:eNULL" $openssl_nodhe &
  161. else
  162. echo "# " $OPENSSL s_server -accept $server_port $OPENSSL_ENGINE_ID -quiet -nocert -www -dhparam \"${CERT_DIR}/dh2048.pem\" -verify 10 -verify_return_error -psk $psk_hex -cipher "ALL:eNULL" $openssl_nodhe
  163. $OPENSSL s_server -accept $server_port $OPENSSL_ENGINE_ID -quiet -nocert -www -dhparam "${CERT_DIR}/dh2048.pem" -verify 10 -verify_return_error -psk $psk_hex -cipher "ALL:eNULL" $openssl_nodhe &
  164. fi
  165. server_pid=$!
  166. # wait to see if s_server successfully starts before continuing
  167. sleep 0.1
  168. check_process_running
  169. if [ "$PS_EXIT" = "0" ]
  170. then
  171. echo "s_server started successfully on port $server_port"
  172. found_free_port=1
  173. break
  174. else
  175. #port already started, try a different port
  176. counter=$((counter+ 1))
  177. generate_port
  178. server_port=$port
  179. fi
  180. done
  181. if [ $found_free_port = 0 ]
  182. then
  183. echo -e "Couldn't find free port for server"
  184. do_cleanup
  185. exit 1
  186. fi
  187. servers="$servers OpenSSL_$openssl_suite:$server_pid:$server_port"
  188. }
  189. #
  190. # Start a wolfSSL server
  191. #
  192. start_wolfssl_server() {
  193. if [ "$wolfssl_server_avail" = "" ]
  194. then
  195. echo "# wolfSSL server not available"
  196. return
  197. fi
  198. wolfssl_cert=""
  199. wolfssl_key=""
  200. wolfssl_caCert=""
  201. if [ "$cert_file" != "" ]
  202. then
  203. wolfssl_cert="-c$cert_file"
  204. fi
  205. if [ "$key_file" != "" ]
  206. then
  207. wolfssl_key="-k$key_file"
  208. fi
  209. if [ "$ca_file" != "" ]
  210. then
  211. wolfssl_caCert="-A$ca_file"
  212. fi
  213. generate_port
  214. server_port=$port
  215. found_free_port=0
  216. counter=0
  217. while [ "$counter" -lt 20 ]; do
  218. echo -e "\n# Trying to start $wolfssl_suite wolfSSL server on port $server_port..."
  219. echo "#"
  220. echo "# $WOLFSSL_SERVER -p $server_port -g -v d -x -i $psk $crl -l ALL \"$wolfssl_cert\" \"$wolfssl_key\" \"$wolfssl_caCert\""
  221. $WOLFSSL_SERVER -p $server_port -g -v d -x -i $psk $crl -l ALL "$wolfssl_cert" "$wolfssl_key" "$wolfssl_caCert" &
  222. server_pid=$!
  223. # wait to see if server successfully starts before continuing
  224. sleep 0.1
  225. check_process_running
  226. if [ "$PS_EXIT" = "0" ]
  227. then
  228. echo "wolfSSL server started successfully on port $server_port"
  229. found_free_port=1
  230. break
  231. else
  232. #port already started, try a different port
  233. counter=$((counter+ 1))
  234. generate_port
  235. server_port=$port
  236. fi
  237. done
  238. if [ $found_free_port = 0 ]
  239. then
  240. echo -e "Couldn't find free port for server"
  241. do_cleanup
  242. exit 1
  243. fi
  244. servers="$servers wolfSSL_$wolfssl_suite:$server_pid:$server_port"
  245. }
  246. check_server_ready() {
  247. # server should be ready, let's make sure
  248. server_ready=0
  249. while [ "$counter" -lt 20 ]; do
  250. echo -e "waiting for $server_name ready..."
  251. echo -e Checking | nc -w 5 localhost $server_port
  252. nc_result=$?
  253. if [ $nc_result = 0 ]
  254. then
  255. echo -e "$server_name ready!"
  256. server_ready=1
  257. break
  258. fi
  259. sleep 0.1
  260. counter=$((counter+ 1))
  261. done
  262. if [ $server_ready = 0 ]
  263. then
  264. echo -e "Couldn't verify $server_name is running, timeout error"
  265. do_cleanup
  266. exit 1
  267. fi
  268. }
  269. #
  270. # Run wolfSSL client against OpenSSL server
  271. #
  272. do_wolfssl_client() {
  273. if [ "$wolfssl_client_avail" = "" ]
  274. then
  275. return
  276. fi
  277. wolfssl_cert=""
  278. wolfssl_key=""
  279. wolfssl_caCert=""
  280. if [ "$cert" != "" ]
  281. then
  282. wolfssl_cert="-c$cert"
  283. fi
  284. if [ "$key" != "" ]
  285. then
  286. wolfssl_key="-k$key"
  287. fi
  288. if [ "$caCert" != "" ]
  289. then
  290. wolfssl_caCert="-A$caCert"
  291. fi
  292. wolfssl_resume="-r"
  293. if [ "$openssl_psk_resume_bug" != "" -a "$tls13_suite" != "" ]
  294. then
  295. wolfssl_resume=
  296. fi
  297. if [ "$wolfssl_no_resume" = "yes" ]
  298. then
  299. wolfssl_resume=
  300. fi
  301. if [ "$version" != "5" -a "$version" != "" ]
  302. then
  303. echo "#"
  304. echo "# $WOLFSSL_CLIENT -p $port -g $wolfssl_resume -l $wolfSuite -v $version $psk $adh \"$wolfssl_cert\" \"$wolfssl_key\" \"$wolfssl_caCert\" $crl"
  305. $WOLFSSL_CLIENT -p $port -g $wolfssl_resume -l $wolfSuite -v $version $psk $adh "$wolfssl_cert" "$wolfssl_key" "$wolfssl_caCert" $crl
  306. else
  307. echo "#"
  308. echo "# $WOLFSSL_CLIENT -p $port -g $wolfssl_resume -l $wolfSuite $psk $adh \"$wolfssl_cert\" \"$wolfssl_key\" \"$wolfssl_caCert\" $crl"
  309. # do all versions
  310. $WOLFSSL_CLIENT -p $port -g $wolfssl_resume -l $wolfSuite $psk $adh "$wolfssl_cert" "$wolfssl_key" "$wolfssl_caCert" $crl
  311. fi
  312. client_result=$?
  313. if [ $client_result != 0 ]
  314. then
  315. echo -e "client failed! Suite = $wolfSuite version = $version"
  316. do_cleanup
  317. exit 1
  318. fi
  319. wolf_temp_cases_tested=$((wolf_temp_cases_tested+1))
  320. }
  321. #
  322. # Run OpenSSL client against wolfSSL server
  323. #
  324. do_openssl_client() {
  325. if [ "$wolfssl_server_avail" = "" ]
  326. then
  327. return
  328. fi
  329. if [ "$version" = "" -o "$version" = "5" ]
  330. then
  331. if [ "$tls13_cipher" = "" -a "$openssl_tls13" != "" ]
  332. then
  333. openssl_version="-no_tls1_3"
  334. fi
  335. fi
  336. if [ "$cert" != "" ]
  337. then
  338. openssl_cert1="-cert"
  339. openssl_cert2="$cert"
  340. fi
  341. if [ "$key" != "" ]
  342. then
  343. openssl_key1="-key"
  344. openssl_key2="$key"
  345. fi
  346. if [ "$caCert" != "" ]
  347. then
  348. openssl_caCert1="-CAfile"
  349. openssl_caCert2="$caCert"
  350. fi
  351. if [ "$tls13_cipher" = "" ]
  352. then
  353. echo "#"
  354. echo "# $OPENSSL s_client -connect localhost:$port -reconnect -legacy_renegotiation -cipher $cmpSuite $openssl_version $openssl_psk $openssl_cert1 \"$openssl_cert2\" $openssl_key1 \"$openssl_key2\" $openssl_caCert1 \"$openssl_caCert2\""
  355. echo "Hello" | eval "$OPENSSL s_client -connect localhost:$port -reconnect -legacy_renegotiation -cipher $cmpSuite $openssl_version $openssl_psk $openssl_cert1 \"$openssl_cert2\" $openssl_key1 \"$openssl_key2\" $openssl_caCert1 \"$openssl_caCert2\""
  356. else
  357. echo "#"
  358. echo "# $OPENSSL s_client -connect localhost:$port -reconnect -legacy_renegotiation -ciphersuites=$cmpSuite $openssl_version $openssl_psk $openssl_cert1 \"$openssl_cert2\" $openssl_key1 \"$openssl_key2\" $openssl_caCert1 \"$openssl_caCert2\""
  359. echo "Hello" | eval "$OPENSSL s_client -connect localhost:$port -reconnect -legacy_renegotiation -ciphersuites=$cmpSuite $openssl_version $openssl_psk $openssl_cert1 \"$openssl_cert2\" $openssl_key1 \"$openssl_key2\" $openssl_caCert1 \"$openssl_caCert2\""
  360. fi
  361. client_result=$?
  362. if [ $client_result != 0 ]
  363. then
  364. echo -e "client failed! Suite = $wolfSuite version = $version"
  365. do_cleanup
  366. exit 1
  367. fi
  368. open_temp_cases_tested=$((open_temp_cases_tested+1))
  369. }
  370. OIFS=$IFS # store old separator to reset
  371. #
  372. # Start
  373. #
  374. echo
  375. echo "wolfSSL configuration:"
  376. ./config.status --config
  377. echo
  378. echo "OpenSSL version:"
  379. $OPENSSL version -a
  380. echo
  381. ps -p $PPID >/dev/null 2>&1
  382. if [ "$?" = "1" ]
  383. then
  384. ps_grep="yes"
  385. echo "ps -p not working, using ps and grep"
  386. fi
  387. echo -e "\nTesting existence of openssl command...\n"
  388. command -v $OPENSSL >/dev/null 2>&1 || { echo >&2 "Requires openssl command, but it's not installed. Ending."; do_cleanup; exit 0; }
  389. echo -e "\nTesting for _build directory as part of distcheck, different paths"
  390. currentDir=`pwd`
  391. case "$currentDir" in
  392. *_build)
  393. echo -e "_build directory detected, moving a directory back"
  394. cd ..
  395. ;;
  396. esac
  397. echo -e "\nChecking for wolfSSL client - needed for cipher list"
  398. wolfssl_client_avail=`$WOLFSSL_CLIENT -?`
  399. case $wolfssl_client_avail in
  400. *"Client not compiled in!"*)
  401. wolfssl_client_avail=
  402. echo >&2 "Requires wolfSSL client, but it's not built. Ending."
  403. do_cleanup
  404. exit 0
  405. ;;
  406. esac
  407. echo -e "\nTesting for buggy version of OpenSSL - TLS 1.3, PSK and session ticket"
  408. openssl_version=`$OPENSSL version`
  409. case $openssl_version in
  410. "OpenSSL 1.1.1 "*)
  411. openssl_psk_resume_bug=yes
  412. ;;
  413. "OpenSSL 1.0.2"*)
  414. openssl_adh_reneg_bug=yes
  415. ;;
  416. esac
  417. # check for wolfssl server
  418. wolfssl_server_avail=`$WOLFSSL_SERVER -?`
  419. case $wolfssl_server_avail in
  420. *"Server not compiled in!"*)
  421. wolfssl_server_avail=
  422. ;;
  423. esac
  424. # get wolfssl ciphers
  425. wolf_ciphers=`$WOLFSSL_CLIENT -e`
  426. # get wolfssl supported versions
  427. wolf_versions=`$WOLFSSL_CLIENT -V`
  428. wolf_versions="${wolf_versions}:5" #5 will test without -v flag
  429. OIFS="$IFS" # store old separator to reset
  430. IFS=: # set delimiter
  431. for version in $wolf_versions
  432. do
  433. case $version in
  434. 1|2|3)
  435. wolf_tls=yes
  436. ;;
  437. 4)
  438. wolf_tls13=yes
  439. ;;
  440. esac
  441. done
  442. IFS="$OIFS" #restore separator
  443. #
  444. # Start OpenSSL servers
  445. #
  446. # Check for certificate support in wolfSSL
  447. wolf_certs=`$WOLFSSL_CLIENT -? 2>&1`
  448. case $wolf_certs in
  449. *"cert"*)
  450. ;;
  451. *)
  452. wolf_certs=""
  453. ;;
  454. esac
  455. if [ "$wolf_certs" != "" ]
  456. then
  457. echo
  458. # Check if RSA certificates supported in wolfSSL
  459. wolf_rsa=`$WOLFSSL_CLIENT -A "${CERT_DIR}/ca-cert.pem" 2>&1`
  460. case $wolf_rsa in
  461. *"ca file"*)
  462. echo "wolfSSL does not support RSA"
  463. wolf_rsa=""
  464. ;;
  465. *)
  466. ;;
  467. esac
  468. if [ "$wolf_rsa" != "" ]; then
  469. echo "wolfSSL supports RSA"
  470. fi
  471. # Check if RSA-PSS certificates supported in wolfSSL
  472. wolf_rsapss=`$WOLFSSL_CLIENT -A "${CERT_DIR}/rsapss/ca-rsapss.pem" 2>&1`
  473. case $wolf_rsapss in
  474. *"ca file"*)
  475. echo "wolfSSL does not support RSA-PSS"
  476. wolf_rsapss=""
  477. ;;
  478. *)
  479. ;;
  480. esac
  481. if [ "$wolf_rsapss" != "" ]; then
  482. echo "wolfSSL supports RSA-PSS"
  483. fi
  484. # Check if ECC certificates supported in wolfSSL
  485. wolf_ecc=`$WOLFSSL_CLIENT -A "${CERT_DIR}/ca-ecc-cert.pem" 2>&1`
  486. case $wolf_ecc in
  487. *"ca file"*)
  488. echo "wolfSSL does not support ECDSA"
  489. wolf_ecc=""
  490. ;;
  491. *)
  492. ;;
  493. esac
  494. if [ "$wolf_ecc" != "" ]; then
  495. echo "wolfSSL supports ECDSA"
  496. fi
  497. # Check if Ed25519 certificates supported in wolfSSL
  498. wolf_ed25519=`$WOLFSSL_CLIENT -A "${CERT_DIR}/ed25519/root-ed25519.pem" 2>&1`
  499. case $wolf_ed25519 in
  500. *"ca file"*)
  501. echo "wolfSSL does not support Ed25519"
  502. wolf_ed25519=""
  503. ;;
  504. *)
  505. ;;
  506. esac
  507. if [ "$wolf_ed25519" != "" ]; then
  508. echo "wolfSSL supports Ed25519"
  509. fi
  510. # Check if Ed25519 certificates supported in OpenSSL
  511. openssl_ed25519=`$OPENSSL s_client -cert "${CERT_DIR}/ed25519/client-ed25519.pem" -key "${CERT_DIR}/ed25519/client-ed25519-priv.pem" 2>&1`
  512. case $openssl_ed25519 in
  513. *"unable to load"*)
  514. echo "OpenSSL does not support Ed25519"
  515. wolf_ed25519=""
  516. ;;
  517. *)
  518. ;;
  519. esac
  520. if [ "$wolf_ed25519" != "" ]; then
  521. echo "OpenSSL supports Ed25519"
  522. fi
  523. # Check if Ed448 certificates supported in wolfSSL
  524. wolf_ed448=`$WOLFSSL_CLIENT -A "${CERT_DIR}/ed448/root-ed448.pem" 2>&1`
  525. case $wolf_ed448 in
  526. *"ca file"*)
  527. echo "wolfSSL does not support Ed448"
  528. wolf_ed448=""
  529. ;;
  530. *)
  531. ;;
  532. esac
  533. if [ "$wolf_ed448" != "" ]; then
  534. echo "wolfSSL supports Ed448"
  535. fi
  536. # Check if Ed448 certificates supported in OpenSSL
  537. openssl_ed448=`$OPENSSL s_client -cert "${CERT_DIR}/ed448/client-ed448.pem" -key "${CERT_DIR}/ed448/client-ed448-priv.pem" 2>&1`
  538. case $openssl_ed448 in
  539. *"unable to load"*)
  540. echo "OpenSSL does not support Ed448"
  541. wolf_ed448=""
  542. ;;
  543. *)
  544. ;;
  545. esac
  546. if [ "$wolf_ed448" != "" ]; then
  547. echo "OpenSSL supports Ed448"
  548. fi
  549. echo
  550. fi
  551. openssl_tls13=`$OPENSSL s_client -help 2>&1`
  552. case $openssl_tls13 in
  553. *no_tls1_3*)
  554. ;;
  555. *)
  556. openssl_tls13=
  557. ;;
  558. esac
  559. # Not all openssl versions support -allow_no_dhe_kex
  560. openssl_nodhe=`$OPENSSL s_client -help 2>&1`
  561. case $openssl_nodhe in
  562. *allow_no_dhe_kex*)
  563. openssl_nodhe=-allow_no_dhe_kex
  564. ;;
  565. *)
  566. openssl_nodhe=
  567. ;;
  568. esac
  569. # Check suites to determine support in wolfSSL
  570. OIFS="$IFS" # store old separator to reset
  571. IFS=: # set delimiter
  572. for wolfSuite in $wolf_ciphers; do
  573. case $wolfSuite in
  574. *ECDHE-RSA-*)
  575. ecdhe_avail=yes
  576. wolf_rsa=yes
  577. ;;
  578. *DHE-RSA-*)
  579. wolf_rsa=yes
  580. ;;
  581. *ECDH-RSA*)
  582. wolf_ecdh_rsa=yes
  583. ;;
  584. *ECDHE-ECDSA*|*ECDH-ECDSA*)
  585. wolf_ecdsa=yes
  586. ;;
  587. *ADH*)
  588. wolf_anon=yes
  589. ;;
  590. *PSK*)
  591. if [ "$wolf_psk" = "" ]
  592. then
  593. echo "Testing PSK"
  594. wolf_psk=1
  595. fi
  596. if [ "$wolf_tls" != "" ]
  597. then
  598. wolf_tls_psk=yes
  599. fi
  600. ;;
  601. *TLS13*)
  602. ;;
  603. *)
  604. wolf_rsa=yes
  605. esac
  606. done
  607. IFS="$OIFS" #restore separator
  608. openssl_ciphers=`$OPENSSL ciphers ALL 2>&1`
  609. case $openssl_ciphers in
  610. *ADH*)
  611. openssl_anon=yes
  612. ;;
  613. esac
  614. # TLSv1 -> TLSv1.2 PSK secret
  615. psk_hex="1a2b3c4d"
  616. # If RSA cipher suites supported in wolfSSL then start servers
  617. if [ "$wolf_rsa" != "" -o "$wolf_tls_psk" != "" ]
  618. then
  619. if [ "$wolf_rsa" != "" ]
  620. then
  621. cert_file="${CERT_DIR}/server-cert.pem"
  622. key_file="${CERT_DIR}/server-key.pem"
  623. ca_file="${CERT_DIR}/client-ca.pem"
  624. else
  625. cert_file=
  626. key_file=
  627. ca_file=
  628. fi
  629. openssl_suite="RSA"
  630. start_openssl_server
  631. openssl_port=$server_port
  632. openssl_pid=$server_pid
  633. wolfssl_suite="RSA"
  634. if [ "$wolf_tls_psk" != "" ]
  635. then
  636. psk="-j"
  637. fi
  638. echo "cert_file=$cert_file"
  639. start_wolfssl_server
  640. psk=
  641. wolfssl_port=$server_port
  642. wolfssl_pid=$server_pid
  643. fi
  644. # If ECDH-RSA cipher suites supported in wolfSSL then start servers
  645. if [ "$wolf_ecdh_rsa" != "" ]
  646. then
  647. cert_file="${CERT_DIR}/server-ecc-rsa.pem"
  648. key_file="${CERT_DIR}/ecc-key.pem"
  649. ca_file="${CERT_DIR}/client-ca.pem"
  650. openssl_suite="ECDH-RSA"
  651. start_openssl_server
  652. ecdh_openssl_port=$server_port
  653. ecdh_openssl_pid=$server_pid
  654. wolfssl_suite="ECDH-RSA"
  655. start_wolfssl_server
  656. ecdh_wolfssl_port=$server_port
  657. ecdh_wolfssl_pid=$server_pid
  658. fi
  659. if [ "$wolf_ecdsa" != "" -a "$wolf_ecc" != "" ]
  660. then
  661. cert_file="${CERT_DIR}/server-ecc.pem"
  662. key_file="${CERT_DIR}/ecc-key.pem"
  663. ca_file="${CERT_DIR}/client-ecc-cert.pem"
  664. openssl_suite="ECDH[E]-ECDSA"
  665. start_openssl_server
  666. ecdsa_openssl_port=$server_port
  667. ecdsa_openssl_pid=$server_pid
  668. wolfssl_suite="ECDH[E]-ECDSA"
  669. start_wolfssl_server
  670. ecdsa_wolfssl_port=$server_port
  671. ecdsa_wolfssl_pid=$server_pid
  672. fi
  673. # If Ed25519 certificates supported in wolfSSL then start servers
  674. if [ "$wolf_ed25519" != "" ];
  675. then
  676. cert_file="${CERT_DIR}/ed25519/server-ed25519.pem"
  677. key_file="${CERT_DIR}/ed25519/server-ed25519-priv.pem"
  678. ca_file="${CERT_DIR}/ed25519/client-ed25519.pem"
  679. openssl_suite="Ed25519"
  680. start_openssl_server
  681. ed25519_openssl_port=$server_port
  682. ed25519_openssl_pid=$server_pid
  683. crl="-V"
  684. wolfssl_suite="Ed25519"
  685. start_wolfssl_server
  686. ed25519_wolfssl_port=$server_port
  687. ed25519_wolfssl_pid=$server_pid
  688. crl=
  689. fi
  690. # If Ed448 certificates supported in wolfSSL then start servers
  691. if [ "$wolf_ed448" != "" ];
  692. then
  693. cert_file="${CERT_DIR}/ed448/server-ed448.pem"
  694. key_file="${CERT_DIR}/ed448/server-ed448-priv.pem"
  695. ca_file="${CERT_DIR}/ed448/client-ed448.pem"
  696. openssl_suite="Ed448"
  697. start_openssl_server
  698. ed448_openssl_port=$server_port
  699. ed448_openssl_pid=$server_pid
  700. crl="-V"
  701. wolfssl_suite="Ed448"
  702. start_wolfssl_server
  703. ed448_wolfssl_port=$server_port
  704. ed448_wolfssl_pid=$server_pid
  705. crl=
  706. fi
  707. if [ "$wolf_tls13" != "" -a "$wolf_psk" != "" ]
  708. then
  709. cert_file=
  710. psk_hex="0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"
  711. openssl_suite="TLSv1.3_PSK"
  712. start_openssl_server
  713. tls13_psk_openssl_port=$server_port
  714. tls13_psk_openssl_pid=$server_pid
  715. psk="-s --openssl-psk"
  716. wolfssl_suite="TLSv1.3_PSK"
  717. start_wolfssl_server
  718. tls13_psk_wolfssl_port=$server_port
  719. tls13_psk_wolfssl_pid=$server_pid
  720. fi
  721. if [ "$wolf_anon" != "" -a "$openssl_anon" ]
  722. then
  723. cert_file=""
  724. key_file=""
  725. ca_file=""
  726. wolfssl_suite="Anon"
  727. psk="-a" # anonymous not psk
  728. start_wolfssl_server
  729. anon_wolfssl_port=$server_port
  730. anon_wolfssl_pid=$server_pid
  731. fi
  732. for s in $servers
  733. do
  734. f2=${s%:*}
  735. server_name=${f2%:*}
  736. server_port=${s##*:}
  737. check_server_ready
  738. done
  739. OIFS="$IFS" # store old separator to reset
  740. IFS=: # set delimiter
  741. set -f # no globbing
  742. wolf_temp_cases_total=0
  743. wolf_temp_cases_tested=0
  744. # Testing of OpenSSL support for version requires a running OpenSSL server
  745. for version in $wolf_versions;
  746. do
  747. echo -e "version = $version"
  748. # get openssl ciphers depending on version
  749. # -s flag for only supported ciphers
  750. case $version in
  751. "0")
  752. openssl_ciphers=`$OPENSSL ciphers "SSLv3" 2>&1`
  753. # double check that can actually do a sslv3 connection using
  754. # client-cert.pem to send but any file with EOF works
  755. $OPENSSL s_client -ssl3 -no_ign_eof -host localhost -port $openssl_port < "${CERT_DIR}/client-cert.pem"
  756. sslv3_sup=$?
  757. if [ $sslv3_sup != 0 ]
  758. then
  759. echo -e "Not testing SSLv3. No OpenSSL support for 'SSLv3' modifier"
  760. testing_summary="${testing_summary}SSLv3\tNo\tN/A\tN/A\tN/A\tN/A\t (No OpenSSL cipherstring)\n"
  761. continue
  762. fi
  763. openssl_version="-ssl3"
  764. ;;
  765. "1")
  766. proto_check=`echo "hell" | $OPENSSL s_client -connect localhost:$openssl_port -tls1 2>&1`
  767. tlsv1_sup=$?
  768. if [ $tlsv1_sup != 0 ]
  769. then
  770. echo -e "Not testing TLSv1. No OpenSSL support for '-tls1'"
  771. testing_summary="${testing_summary}TLSv1\tNo\tN/A\tN/A\tN/A\tN/A\t (No OpenSSL Support)\n"
  772. continue
  773. fi
  774. openssl_ciphers=`$OPENSSL ciphers -s "TLSv1" 2>&1`
  775. tlsv1_sup=$?
  776. if [ $tlsv1_sup != 0 ]
  777. then
  778. echo -e "Not testing TLSv1. No OpenSSL support for 'TLSv1' modifier"
  779. testing_summary="${testing_summary}TLSv1\tNo\tN/A\tN/A\tN/A\tN/A\t (No OpenSSL cipherstring)\n"
  780. continue
  781. fi
  782. openssl_version="-tls1"
  783. ;;
  784. "2")
  785. # Same ciphers for TLSv1.1 as TLSv1
  786. proto_check=`echo "hello" | $OPENSSL s_client -connect localhost:$openssl_port -tls1_1 2>&1`
  787. tlsv1_1_sup=$?
  788. if [ $tlsv1_1_sup != 0 ]
  789. then
  790. echo -e "Not testing TLSv1.1. No OpenSSL support for 'TLSv1.1' modifier"
  791. testing_summary="${testing_summary}TLSv1.1\tNo\tN/A\tN/A\tN/A\tN/A\t (No OpenSSL cipherstring)\n"
  792. continue
  793. fi
  794. openssl_ciphers=`$OPENSSL ciphers -s "TLSv1" 2>&1`
  795. tlsv1_sup=$?
  796. if [ $tlsv1_sup != 0 ]
  797. then
  798. echo -e "Not testing TLSv1. No OpenSSL support for 'TLSv1' modifier"
  799. testing_summary="${testing_summary}TLSv1\tNo\tN/A\tN/A\tN/A\tN/A\t (No OpenSSL cipherstring)\n"
  800. continue
  801. fi
  802. openssl_version="-tls1_1"
  803. ;;
  804. "3")
  805. openssl_ciphers=`$OPENSSL ciphers -s "TLSv1.2" 2>&1`
  806. tlsv1_2_sup=$?
  807. if [ $tlsv1_2_sup != 0 ]
  808. then
  809. echo -e "Not testing TLSv1.2. No OpenSSL support for 'TLSv1.2' modifier"
  810. testing_summary="${testing_summary}TLSv1.2\tNo\tN/A\tN/A\tN/A\tN/A\t (No OpenSSL cipherstring)\n"
  811. continue
  812. fi
  813. openssl_version="-tls1_2"
  814. ;;
  815. "4")
  816. openssl_ciphers=`$OPENSSL ciphers -tls1_3 2>&1`
  817. tlsv1_3_sup=$?
  818. if [ $tlsv1_3_sup != 0 ]
  819. then
  820. echo -e "Not testing TLSv1.3. No OpenSSL support for 'TLSv1.3' modifier"
  821. testing_summary="${testing_summary}TLSv1.3\tNo\tN/A\tN/A\tN/A\tN/A\t (No OpenSSL cipherstring)\n"
  822. continue
  823. fi
  824. ecc_support=`$WOLFSSL_CLIENT -? 2>&1 | grep 'ECC named groups'`
  825. openssl_version="-tls1_3"
  826. ;;
  827. "d(downgrade)")
  828. version="d"
  829. openssl_version=""
  830. ;;
  831. "e(either)")
  832. continue
  833. ;;
  834. "5") #test all suites
  835. openssl_ciphers=`$OPENSSL ciphers -s "ALL" 2>&1`
  836. all_sup=$?
  837. if [ $all_sup != 0 ]
  838. then
  839. echo -e "Not testing ALL. No OpenSSL support for ALL modifier"
  840. testing_summary="${testing_summary}ALL\tNo\tN/A\tN/A\tN/A\tN/A\t (No OpenSSL cipherstring)\n"
  841. continue
  842. fi
  843. openssl_version=""
  844. ;;
  845. "")
  846. openssl_ciphers=`$OPENSSL ciphers 2>&1`
  847. all_sup=$?
  848. if [ $all_sup != 0 ]
  849. then
  850. echo -e "Not testing ALL. No OpenSSL support for ALL modifier"
  851. testing_summary="${testing_summary}ALL\tNo\tN/A\tN/A\tN/A\tN/A\t (No OpenSSL cipherstring)\n"
  852. continue
  853. fi
  854. openssl_version=""
  855. ;;
  856. esac
  857. for wolfSuite in $wolf_ciphers; do
  858. echo -e "trying wolfSSL cipher suite $wolfSuite"
  859. wolf_temp_cases_total=$((wolf_temp_cases_total + 1))
  860. open_temp_cases_total=$((open_temp_cases_total + 1))
  861. matchSuite=0;
  862. tls13_suite=
  863. case $wolfSuite in
  864. "TLS13-AES128-GCM-SHA256")
  865. cmpSuite="TLS_AES_128_GCM_SHA256"
  866. tls13_suite="yes"
  867. ;;
  868. "TLS13-AES256-GCM-SHA384")
  869. cmpSuite="TLS_AES_256_GCM_SHA384"
  870. tls13_suite="yes"
  871. ;;
  872. "TLS13-CHACHA20-POLY1305-SHA256")
  873. cmpSuite="TLS_CHACHA20_POLY1305_SHA256"
  874. tls13_suite="yes"
  875. ;;
  876. "TLS13-AES128-CCM-SHA256")
  877. cmpSuite="TLS_AES_128_CCM_SHA256"
  878. tls13_suite="yes"
  879. ;;
  880. "TLS13-AES128-CCM-8-SHA256"|"TLS13-AES128-CCM8-SHA256")
  881. cmpSuite="TLS_AES_128_CCM_8_SHA256"
  882. tls13_suite="yes"
  883. ;;
  884. "TLS13-SHA256-SHA256")
  885. continue
  886. ;;
  887. "TLS13-SHA384-SHA384")
  888. continue
  889. ;;
  890. "TLS13-"*)
  891. echo -e "Suite = $wolfSuite not recognized!"
  892. echo -e "Add translation of wolfSSL name to OpenSSL"
  893. do_cleanup
  894. exit 1
  895. ;;
  896. *)
  897. cmpSuite=$wolfSuite
  898. ;;
  899. esac
  900. case ":$openssl_ciphers:" in *":$cmpSuite:"*) # add extra : for edge cases
  901. case "$cmpSuite" in
  902. "TLS_"*)
  903. if [ "$version" != "4" -a "$version" != "d" ]
  904. then
  905. echo -e "TLS 1.3 cipher suite but not TLS 1.3 protocol"
  906. matchSuite=0
  907. else
  908. echo -e "Matched to OpenSSL suite support"
  909. matchSuite=1
  910. fi
  911. ;;
  912. *)
  913. if [ "$version" = "d" -a "$wolfdowngrade" = "4" ]
  914. then
  915. echo -e "Not TLS 1.3 cipher suite but TLS 1.3 downgrade"
  916. matchSuite=0
  917. elif [ "$version" != "4" ]
  918. then
  919. echo -e "Matched to OpenSSL suite support"
  920. matchSuite=1
  921. else
  922. echo -e "Not TLS 1.3 cipher suite but TLS 1.3 protocol"
  923. matchSuite=0
  924. fi
  925. ;;
  926. esac
  927. ;;
  928. esac
  929. if [ $matchSuite = 0 ]
  930. then
  931. echo -e "Couldn't match suite, continuing..."
  932. continue
  933. fi
  934. # check for psk suite and turn on client psk if so
  935. psk=""
  936. adh=""
  937. crl=""
  938. cert=""
  939. key=""
  940. caCert=""
  941. case $wolfSuite in
  942. *ECDH-RSA*)
  943. cert="${CERT_DIR}/client-cert.pem"
  944. key="${CERT_DIR}/client-key.pem"
  945. caCert="${CERT_DIR}/ca-cert.pem"
  946. port=$ecdh_openssl_port
  947. do_wolfssl_client
  948. port=$ecdh_wolfssl_port
  949. do_openssl_client
  950. ;;
  951. *ECDHE-ECDSA*|*ECDH-ECDSA*)
  952. if [ "$wolf_ecc" != "" ]
  953. then
  954. cert="${CERT_DIR}/client-ecc-cert.pem"
  955. key="${CERT_DIR}/ecc-client-key.pem"
  956. caCert="${CERT_DIR}/ca-ecc-cert.pem"
  957. port=$ecdsa_openssl_port
  958. do_wolfssl_client
  959. port=$ecdsa_wolfssl_port
  960. do_openssl_client
  961. else
  962. wolf_temp_cases_total=$((wolf_temp_cases_total - 1))
  963. fi
  964. if [ $ed25519_openssl_pid != $no_pid -a "$version" != "0" -a "$version" != "1" -a "$version" != "2" ]
  965. then
  966. cert="${CERT_DIR}/ed25519/client-ed25519.pem"
  967. key="${CERT_DIR}/ed25519/client-ed25519-priv.pem"
  968. caCert="${CERT_DIR}/ed25519/server-ed25519.pem"
  969. wolf_temp_cases_total=$((wolf_temp_cases_total + 1))
  970. port=$ed25519_openssl_port
  971. crl="-C"
  972. do_wolfssl_client
  973. open_temp_cases_total=$((open_temp_cases_total + 1))
  974. port=$ed25519_wolfssl_port
  975. do_openssl_client
  976. fi
  977. if [ $ed448_openssl_pid != $no_pid -a "$version" != "0" -a "$version" != "1" -a "$version" != "2" ]
  978. then
  979. cert="${CERT_DIR}/ed448/client-ed448.pem"
  980. key="${CERT_DIR}/ed448/client-ed448-priv.pem"
  981. caCert="${CERT_DIR}/ed448/server-ed448.pem"
  982. wolf_temp_cases_total=$((wolf_temp_cases_total + 1))
  983. port=$ed448_openssl_port
  984. crl="-C"
  985. do_wolfssl_client
  986. open_temp_cases_total=$((open_temp_cases_total + 1))
  987. port=$ed448_wolfssl_port
  988. do_openssl_client
  989. fi
  990. ;;
  991. *DHE-PSK*)
  992. cert="${CERT_DIR}/client-cert.pem"
  993. key="${CERT_DIR}/client-key.pem"
  994. caCert="${CERT_DIR}/ca-cert.pem"
  995. port=$openssl_port
  996. psk="-s"
  997. do_wolfssl_client
  998. # Skip when no RSA as some versions of OpenSSL can't handle no
  999. # signature
  1000. if [ "$wolf_rsa" != "" ]
  1001. then
  1002. port=$wolfssl_port
  1003. openssl_psk="-psk 1a2b3c4d"
  1004. do_openssl_client
  1005. fi
  1006. ;;
  1007. *PSK*)
  1008. cert="${CERT_DIR}/client-cert.pem"
  1009. key="${CERT_DIR}/client-key.pem"
  1010. caCert="${CERT_DIR}/ca-cert.pem"
  1011. port=$openssl_port
  1012. psk="-s"
  1013. do_wolfssl_client
  1014. port=$wolfssl_port
  1015. openssl_psk="-psk 1a2b3c4d"
  1016. do_openssl_client
  1017. ;;
  1018. *ADH*)
  1019. cert="${CERT_DIR}/client-cert.pem"
  1020. key="${CERT_DIR}/client-key.pem"
  1021. caCert="${CERT_DIR}/ca-cert.pem"
  1022. if [ "$version" != "0" -a "$version" != "1" -a "$version" != "2" -a "$openssl_adh_reneg_bug" != "" ]
  1023. then
  1024. continue
  1025. fi
  1026. port=$openssl_port
  1027. adh="-a"
  1028. do_wolfssl_client
  1029. port=$anon_wolfssl_port
  1030. do_openssl_client
  1031. ;;
  1032. TLS13*)
  1033. if [ $version != "4" -a $version != "d" -a $version != " " -a $version != "5" ]
  1034. then
  1035. continue
  1036. fi
  1037. tls13_cipher=yes
  1038. # RSA
  1039. if [ $openssl_pid != $no_pid -a "$ecdhe_avail" = "yes" ]
  1040. then
  1041. cert="${CERT_DIR}/client-cert.pem"
  1042. key="${CERT_DIR}/client-key.pem"
  1043. caCert="${CERT_DIR}/ca-cert.pem"
  1044. port=$openssl_port
  1045. do_wolfssl_client
  1046. port=$wolfssl_port
  1047. do_openssl_client
  1048. fi
  1049. # PSK
  1050. if [ "$wolf_psk" != "" -a $wolfSuite = "TLS13-AES128-GCM-SHA256" -a "$wolf_ecc" != "" -a $openssl_nodhe != "" ]
  1051. then
  1052. cert=""
  1053. key=""
  1054. caCert=""
  1055. wolf_temp_cases_total=$((wolf_temp_cases_total + 1))
  1056. port=$tls13_psk_openssl_port
  1057. psk="-s --openssl-psk"
  1058. # OpenSSL doesn't support DH for key exchange so do no PSK
  1059. # DHE when ECC not supported
  1060. if [ "$wolf_ecc" = "" ]
  1061. then
  1062. adh="-K"
  1063. fi
  1064. do_wolfssl_client
  1065. psk=""
  1066. adh=""
  1067. openssl_psk="-psk 0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"
  1068. open_temp_cases_total=$((open_temp_cases_total + 1))
  1069. port=$wolfssl_port
  1070. do_openssl_client
  1071. open_temp_cases_total=$((open_temp_cases_total + 1))
  1072. port=$tls13_psk_wolfssl_port
  1073. do_openssl_client
  1074. openssl_psk=""
  1075. fi
  1076. # ECDSA
  1077. if [ $ecdsa_openssl_pid != $no_pid -a "$wolf_ecc" != "" ]
  1078. then
  1079. cert="${CERT_DIR}/client-ecc-cert.pem"
  1080. key="${CERT_DIR}/ecc-client-key.pem"
  1081. caCert="${CERT_DIR}/ca-ecc-cert.pem"
  1082. wolf_temp_cases_total=$((wolf_temp_cases_total + 1))
  1083. port=$ecdsa_openssl_port
  1084. caCert="${CERT_DIR}/ca-ecc-cert.pem"
  1085. do_wolfssl_client
  1086. open_temp_cases_total=$((open_temp_cases_total + 1))
  1087. port=$ecdsa_wolfssl_port
  1088. caCert="${CERT_DIR}/ca-ecc-cert.pem"
  1089. do_openssl_client
  1090. fi
  1091. # Ed25519
  1092. if [ $ed25519_openssl_pid != $no_pid ]
  1093. then
  1094. cert="${CERT_DIR}/ed25519/client-ed25519.pem"
  1095. key="${CERT_DIR}/ed25519/client-ed25519-priv.pem"
  1096. caCert="${CERT_DIR}/ed25519/server-ed25519.pem"
  1097. wolf_temp_cases_total=$((wolf_temp_cases_total + 1))
  1098. port=$ed25519_openssl_port
  1099. crl="-C"
  1100. do_wolfssl_client
  1101. open_temp_cases_total=$((open_temp_cases_total + 1))
  1102. port=$ed25519_wolfssl_port
  1103. do_openssl_client
  1104. fi
  1105. # Ed448
  1106. if [ $ed448_openssl_pid != $no_pid ]
  1107. then
  1108. cert="${CERT_DIR}/ed448/client-ed448.pem"
  1109. key="${CERT_DIR}/ed448/client-ed448-priv.pem"
  1110. caCert="${CERT_DIR}/ed448/server-ed448.pem"
  1111. wolf_temp_cases_total=$((wolf_temp_cases_total + 1))
  1112. port=$ed448_openssl_port
  1113. crl="-C"
  1114. do_wolfssl_client
  1115. open_temp_cases_total=$((open_temp_cases_total + 1))
  1116. port=$ed448_wolfssl_port
  1117. do_openssl_client
  1118. fi
  1119. tls13_cipher=
  1120. ;;
  1121. *)
  1122. cert="${CERT_DIR}/client-cert.pem"
  1123. key="${CERT_DIR}/client-key.pem"
  1124. caCert="${CERT_DIR}/ca-cert.pem"
  1125. port=$openssl_port
  1126. do_wolfssl_client
  1127. port=$wolfssl_port
  1128. do_openssl_client
  1129. ;;
  1130. esac
  1131. done
  1132. wolf_cases_tested=$((wolf_temp_cases_tested+wolf_cases_tested))
  1133. wolf_cases_total=$((wolf_temp_cases_total+wolf_cases_total))
  1134. echo -e "wolfSSL cases tested with version:$version $wolf_temp_cases_tested"
  1135. open_cases_tested=$((open_temp_cases_tested+open_cases_tested))
  1136. open_cases_total=$((open_temp_cases_total+open_cases_total))
  1137. echo -e "OpenSSL cases tested with version:$version $open_temp_cases_tested"
  1138. version_name
  1139. testing_summary="$testing_summary$versionName\tYes\t$wolf_temp_cases_total\t$wolf_temp_cases_tested\t$open_temp_cases_total\t$open_temp_cases_tested\n"
  1140. wolf_temp_cases_total=0
  1141. wolf_temp_cases_tested=0
  1142. open_temp_cases_total=0
  1143. open_temp_cases_tested=0
  1144. wolfdowngrade="$version"
  1145. done
  1146. IFS="$OIFS" #restore separator
  1147. # Skip RSA-PSS interop test when RSA-PSS is not supported
  1148. if [ "$wolf_rsapss" != "" -a "$ecdhe_avail" = "yes" -a "$wolf_rsa" = "yes" ]
  1149. then
  1150. # Test for RSA-PSS certs interop
  1151. # Was running into alert sent by openssl server with version 1.1.1 released
  1152. # in Sep 2018. To avoid this issue check that openssl version 3.0.0 or later
  1153. # is used.
  1154. $OPENSSL version | awk '{print $2}' | \
  1155. awk -F. '{if ($1 >= 3) exit 1; else exit 0;}'
  1156. RESULT=$?
  1157. if [ "$RESULT" = "0" ]; then
  1158. echo -e "Old version of openssl detected, skipping interop RSA-PSS test"
  1159. else
  1160. echo -e "Doing interop RSA-PSS test"
  1161. key_file=${CERT_DIR}/rsapss/server-rsapss-priv.pem
  1162. cert_file=${CERT_DIR}/rsapss/server-rsapss.pem
  1163. ca_file=${CERT_DIR}/client-cert.pem
  1164. openssl_suite="RSAPSS"
  1165. start_openssl_server
  1166. cert="${CERT_DIR}/client-cert.pem"
  1167. key="${CERT_DIR}/client-key.pem"
  1168. caCert="${CERT_DIR}/rsapss/ca-rsapss.pem"
  1169. crl="-C"
  1170. wolfSuite="ALL"
  1171. wolfssl_no_resume="yes"
  1172. port=$server_port
  1173. if [ "$wolf_tls13" != "" ]
  1174. then
  1175. version="4"
  1176. do_wolfssl_client
  1177. fi
  1178. if [ "$wolf_tls" != "" ]
  1179. then
  1180. version="3"
  1181. do_wolfssl_client
  1182. fi
  1183. fi
  1184. fi
  1185. do_cleanup
  1186. echo -e "wolfSSL total cases $wolf_cases_total"
  1187. echo -e "wolfSSL cases tested $wolf_cases_tested"
  1188. echo -e "OpenSSL total cases $open_cases_total"
  1189. echo -e "OpenSSL cases tested $open_cases_tested"
  1190. echo -e "\nSuccess!\n\n\n\n"
  1191. echo -e "$testing_summary"
  1192. exit 0