Skip to content

Commit 102e4fb

Browse files
author
David Cooper
authored
Merge pull request #2620 from Odinmylord/fix_curves
fix curves findings in TLS1.2 and prior versions
2 parents 04e5bc4 + b360960 commit 102e4fb

1 file changed

Lines changed: 65 additions & 0 deletions

File tree

testssl.sh

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10926,6 +10926,40 @@ run_fs() {
1092610926
[[ $i -eq $high ]] && break
1092710927
supported_curve[i]=true
1092810928
done
10929+
# Versions of TLS prior to 1.3 close the connection if the client does not support the curve
10930+
# used in the certificate. The easiest solution is to move the curves to the end of the list.
10931+
# instead of removing them from the ClientHello. This is only needed if there is no RSA certificate.
10932+
if (! "$HAS_TLS13" || [[ "$proto" == "-no_tls1_3" ]]) && [[ ! "$ecdhe_cipher_list" == *RSA* ]]; then
10933+
while true; do
10934+
curves_to_test=""
10935+
for (( i=low; i < high; i++ )); do
10936+
"${ossl_supported[i]}" && ! "${supported_curve[i]}" && curves_to_test+=":${curves_ossl[i]}"
10937+
done
10938+
[[ -z "$curves_to_test" ]] && break
10939+
for (( i=low; i < high; i++ )); do
10940+
"${supported_curve[i]}" && curves_to_test+=":${curves_ossl[i]}"
10941+
done
10942+
$OPENSSL s_client $(s_client_options "$proto -cipher "\'${ecdhe_cipher_list:1}\'" -ciphersuites "\'${tls13_cipher_list:1}\'" -curves "${curves_to_test:1}" $STARTTLS $BUGS -connect $NODEIP:$PORT $PROXY $SNI") &>$TMPFILE </dev/null
10943+
sclient_connect_successful $? $TMPFILE || break
10944+
temp=$(awk -F': ' '/^Server Temp Key/ { print $2 }' "$TMPFILE")
10945+
curve_found="${temp%%,*}"
10946+
if [[ "$curve_found" == ECDH ]]; then
10947+
curve_found="${temp#*, }"
10948+
curve_found="${curve_found%%,*}"
10949+
if "$HAS_TLS13" && [[ ! "$proto" == "-no_tls1_3" ]] && [[ "$curve_found" == brainpoolP[235][581][642]r1 ]]; then
10950+
[[ "$(get_protocol "$TMPFILE")" == TLSv1.3 ]] && curve_found+="tls13"
10951+
fi
10952+
fi
10953+
for (( i=low; i < high; i++ )); do
10954+
if ! "${supported_curve[i]}"; then
10955+
[[ "${curves_ossl_output[i]}" == "$curve_found" ]] && break
10956+
[[ "${curves_ossl[i]}" == "$curve_found" ]] && break
10957+
fi
10958+
done
10959+
[[ $i -eq $high ]] && break
10960+
supported_curve[i]=true
10961+
done
10962+
fi
1092910963
done
1093010964
done
1093110965
fi
@@ -10962,6 +10996,37 @@ run_fs() {
1096210996
[[ $i -eq $nr_curves ]] && break
1096310997
supported_curve[i]=true
1096410998
done
10999+
# Versions of TLS prior to 1.3 close the connection if the client does not support the curve
11000+
# used in the certificate. The easiest solution is to move the curves to the end of the list.
11001+
# instead of removing them from the ClientHello. This is only needed if there is no RSA certificate.
11002+
if ([[ "$proto" == 03 ]] && [[ ! "$ecdhe_cipher_list" == *RSA* ]]); then
11003+
while true; do
11004+
curves_to_test=""
11005+
for (( i=0; i < nr_curves; i++ )); do
11006+
! "${supported_curve[i]}" && curves_to_test+=", ${curves_hex[i]}"
11007+
done
11008+
[[ -z "$curves_to_test" ]] && break
11009+
for (( i=0; i < nr_curves; i++ )); do
11010+
"${supported_curve[i]}" && curves_to_test+=", ${curves_hex[i]}"
11011+
done
11012+
len1=$(printf "%02x" "$((2*${#curves_to_test}/7))")
11013+
len2=$(printf "%02x" "$((2*${#curves_to_test}/7+2))")
11014+
tls_sockets "$proto" "${ecdhe_cipher_list_hex:2}, 00,ff" "ephemeralkey" "00, 0a, 00, $len2, 00, $len1, ${curves_to_test:2}"
11015+
sclient_success=$?
11016+
[[ $sclient_success -ne 0 ]] && [[ $sclient_success -ne 2 ]] && break
11017+
temp=$(awk -F': ' '/^Server Temp Key/ { print $2 }' "$TEMPDIR/$NODEIP.parse_tls_serverhello.txt")
11018+
curve_found="${temp%%,*}"
11019+
if [[ "$curve_found" == "ECDH" ]]; then
11020+
curve_found="${temp#*, }"
11021+
curve_found="${curve_found%%,*}"
11022+
fi
11023+
for (( i=0; i < nr_curves; i++ )); do
11024+
! "${supported_curve[i]}" && [[ "${curves_ossl_output[i]}" == "$curve_found" ]] && break
11025+
done
11026+
[[ $i -eq $nr_curves ]] && break
11027+
supported_curve[i]=true
11028+
done
11029+
fi
1096511030
done
1096611031
fi
1096711032
if "$ecdhe_offered"; then

0 commit comments

Comments
 (0)