diff --git a/testssl.sh b/testssl.sh index 3ecf8a0..9cf053f 100755 --- a/testssl.sh +++ b/testssl.sh @@ -2965,194 +2965,6 @@ prettyprint_local() { } -# list ciphers (and makes sure you have them locally configured) -# arg[1]: non-TLSv1.3 cipher list (or anything else) -# arg[2]: TLSv1.3 cipher list -# arg[3]: protocol (e.g., -ssl2) -listciphers() { - local -i ret - local debugname="$(sed -e s'/\!/not/g' -e 's/\:/_/g' <<< "$1")" - local tls13_ciphers="$TLS13_OSSL_CIPHERS" - - [[ "$2" != "ALL" ]] && tls13_ciphers="$2" - if "$HAS_CIPHERSUITES"; then - $OPENSSL ciphers $3 -ciphersuites "$tls13_ciphers" "$1" &>$TMPFILE - elif [[ -n "$tls13_ciphers" ]]; then - $OPENSSL ciphers $3 "$tls13_ciphers:$1" &>$TMPFILE - else - $OPENSSL ciphers $3 "$1" &>$TMPFILE - fi - ret=$? - debugme cat $TMPFILE - - tmpfile_handle $FUNCNAME.$debugname.txt - return $ret -} - - -# argv[1]: non-TLSv1.3 cipher list to test in OpenSSL syntax -# argv[2]: TLSv1.3 cipher list to test in OpenSSL syntax -# argv[3]: string on console / HTML or "finding" -# argv[4]: rating whether ok to offer -# argv[5]: string to be appended for fileout -# argv[6]: non-SSLv2 cipher list to test (hexcodes), if using sockets -# argv[7]: SSLv2 cipher list to test (hexcodes), if using sockets -# argv[8]: true if using sockets, false if not -# argv[9]: CVE -# argv[10]: CWE -# -sub_cipherlists() { - local -i i len sclient_success=1 - local cipherlist sslv2_cipherlist detected_ssl2_ciphers - local singlespaces - local proto="" - local -i ret=0 - local jsonID="cipherlist" - local using_sockets="${8}" - local cve="${9}" - local cwe="${10}" - - pr_bold "$3 " - [[ "$OPTIMAL_PROTO" == -ssl2 ]] && proto="$OPTIMAL_PROTO" - jsonID="${jsonID}_$5" - - if "$using_sockets" || listciphers "$1" "$2" $proto; then - if ! "$using_sockets" || ( "$FAST" && listciphers "$1" "$2" -tls1 ); then - for proto in -no_ssl2 -tls1_2 -tls1_1 -tls1 -ssl3; do - if [[ "$proto" == -tls1_2 ]]; then - # If $OPENSSL doesn't support TLSv1.3 or if no TLSv1.3 - # ciphers are being tested, then a TLSv1.2 ClientHello - # was tested in the first iteration. - ! "$HAS_TLS13" && continue - [[ -z "$2" ]] && continue - fi - ! "$HAS_SSL3" && [[ "$proto" == -ssl3 ]] && continue - if [[ "$proto" != -no_ssl2 ]]; then - "$FAST" && continue - [[ $(has_server_protocol "${proto:1}") -eq 1 ]] && continue - fi - $OPENSSL s_client $(s_client_options "-cipher "$1" -ciphersuites "\'$2\'" $BUGS $STARTTLS -connect $NODEIP:$PORT $PROXY $SNI $proto") 2>$ERRFILE >$TMPFILE $ERRFILE >$TMPFILE $TMPFILE + elif [[ -n "$tls13_ciphers" ]]; then + $OPENSSL ciphers $3 "$tls13_ciphers:$1" &>$TMPFILE + else + $OPENSSL ciphers $3 "$1" &>$TMPFILE + fi + ret=$? + debugme cat $TMPFILE + debugname="$(sed -e s'/\!/not/g' -e 's/\:/_/g' <<< "$1")" + tmpfile_handle $FUNCNAME.${debugname}.txt + return $ret +} + + +# argv[1]: non-TLSv1.3 cipher list to test in OpenSSL syntax +# argv[2]: TLSv1.3 cipher list to test in OpenSSL syntax +# argv[3]: string on console / HTML or "finding" +# argv[4]: rating whether ok to offer +# argv[5]: string to be appended for fileout +# argv[6]: non-SSLv2 cipher list to test (hexcodes), if using sockets +# argv[7]: SSLv2 cipher list to test (hexcodes), if using sockets +# argv[8]: true if using sockets, false if not +# argv[9]: CVE +# argv[10]: CWE +# +sub_cipherlists() { + local -i i len sclient_success=1 + local cipherlist sslv2_cipherlist detected_ssl2_ciphers + local singlespaces + local proto="" + local -i ret=0 + local jsonID="cipherlist" + local using_sockets="${8}" + local cve="${9}" + local cwe="${10}" + + pr_bold "$3 " + [[ "$OPTIMAL_PROTO" == -ssl2 ]] && proto="$OPTIMAL_PROTO" + jsonID="${jsonID}_$5" + + if "$using_sockets" || listciphers "$1" "$2" $proto; then + if ! "$using_sockets" || ( "$FAST" && listciphers "$1" "$2" -tls1 ); then + for proto in -no_ssl2 -tls1_2 -tls1_1 -tls1 -ssl3; do + if [[ "$proto" == -tls1_2 ]]; then + # If $OPENSSL doesn't support TLSv1.3 or if no TLSv1.3 + # ciphers are being tested, then a TLSv1.2 ClientHello + # was tested in the first iteration. + ! "$HAS_TLS13" && continue + [[ -z "$2" ]] && continue + fi + ! "$HAS_SSL3" && [[ "$proto" == -ssl3 ]] && continue + if [[ "$proto" != -no_ssl2 ]]; then + "$FAST" && continue + [[ $(has_server_protocol "${proto:1}") -eq 1 ]] && continue + fi + $OPENSSL s_client $(s_client_options "-cipher "$1" -ciphersuites "\'$2\'" $BUGS $STARTTLS -connect $NODEIP:$PORT $PROXY $SNI $proto") 2>$ERRFILE >$TMPFILE $ERRFILE >$TMPFILE atm ok, as sockets are preferred. If there would be a single function for testing: yes. run_cipherlists() { local hexc hexcode strength