Skip to content

Commit 2ff7891

Browse files
authored
WIP: Signature algorithms for client authentication
This commit is a work in progress. It obtains and prints the list of signature algorithms supported by the server for client authentication. This commit is missing several critical elements: - Commonly a server will offer a different list of algorithms for TLS 1.3 and for TLS 1.2 (or earlier). This commit only shows the list offered in the connection established by determine_optimal_proto(). For a server that supports TLS 1.3, this means that the list of algorithms for that protocol will be missed if $OPENSSL does not support TLS 1.3. If the server and $OPENSSL both support TLS 1.3, then the list of algorithms for TLS 1.2 and earlier will be missed (if the server is not TLS 1.3 only). - The list presented is from the signature_algorithms extension, which is the list of algorithms supported for CertificateVerify messages. If the server supports a different list of algorithms for verifying signatures on client certificates, then it will send this list in the signature_algorithms_cert extension. This commit does not extract the contents of that extension.
1 parent 979a22c commit 2ff7891

File tree

1 file changed

+60
-6
lines changed

1 file changed

+60
-6
lines changed

testssl.sh

Lines changed: 60 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,7 @@ TMPFILE=""
288288
ERRFILE=""
289289
CLIENT_AUTH="none"
290290
CLIENT_AUTH_CA_LIST=""
291+
CLIENT_AUTH_SIGALGS_LIST=""
291292
TLS_TICKETS=false
292293
NO_SSL_SESSIONID=true
293294
CERT_COMPRESSION=${CERT_COMPRESSION:-false} # secret flag to set in addition to --devel for certificate compression
@@ -10356,6 +10357,22 @@ run_server_defaults() {
1035610357
i+=1
1035710358
done <<< "$CLIENT_AUTH_CA_LIST"
1035810359
fi
10360+
jsonID="clientAuth_sigalgs_list"
10361+
pr_bold " Sig Alg List for Client Auth "
10362+
if [[ -z "$(sed -e 's/[A-Za-z\-]*+SHA1//g' -e 's/[A-Za-z\-]*+MD5//g' -e 's/ //g' <<< "$CLIENT_AUTH_SIGALGS_LIST")" ]]; then
10363+
prln_svrty_critical "$(out_row_aligned_max_width "$CLIENT_AUTH_SIGALGS_LIST" " " $TERM_WIDTH)"
10364+
fileout "$jsonID" "CRITICAL" "$CLIENT_AUTH_SIGALGS_LIST"
10365+
else
10366+
out_row_aligned_max_width_by_entry "$CLIENT_AUTH_SIGALGS_LIST" " " $TERM_WIDTH pr_sigalg_quality
10367+
outln
10368+
if [[ "$CLIENT_AUTH_SIGALGS_LIST" =~ MD5 ]]; then
10369+
fileout "$jsonID" "HIGH" "$CLIENT_AUTH_SIGALGS_LIST"
10370+
elif [[ "$CLIENT_AUTH_SIGALGS_LIST" =~ SHA1 ]]; then
10371+
fileout "$jsonID" "LOW" "$CLIENT_AUTH_SIGALGS_LIST"
10372+
else
10373+
fileout "$jsonID" "INFO" "$CLIENT_AUTH_SIGALGS_LIST"
10374+
fi
10375+
fi
1035910376
fi
1036010377

1036110378

@@ -21589,8 +21606,8 @@ print_dn() {
2158921606
extract_calist() {
2159021607
local response="$1"
2159121608
local is_tls12=false is_tls13=false
21592-
local certreq calist="" certtypes sigalgs dn
21593-
local calist_string=""
21609+
local certreq calist="" certtypes sigalgs="" dn
21610+
local calist_string="" sigalgs_string=""
2159421611
local -i len type
2159521612

2159621613
# Determine whether this is a TLS 1.2 or TLS 1.3 response, since the information
@@ -21623,12 +21640,16 @@ extract_calist() {
2162321640
[[ -z "$certreq" ]] && break
2162421641
type=$(hex2dec "${certreq:0:4}")
2162521642
len=2*$(hex2dec "${certreq:4:4}")
21626-
if [[ $type -eq 47 ]]; then
21643+
if [[ $type -eq 13 ]]; then
21644+
# This is the signature_algorithms extension
21645+
sigalgs="${certreq:8:len}"
21646+
len=2*$(hex2dec "${sigalgs:0:4}")
21647+
sigalgs="${sigalgs:4:len}"
21648+
elif [[ $type -eq 47 ]]; then
2162721649
# This is the certificate_authorities extension
2162821650
calist="${certreq:8:len}"
2162921651
len=2*$(hex2dec "${calist:0:4}")
2163021652
calist="${calist:4:len}"
21631-
break
2163221653
fi
2163321654
certreq="${certreq:$((len+8))}"
2163421655
done
@@ -21659,7 +21680,40 @@ extract_calist() {
2165921680
calist="${calist:$((len+4))}"
2166021681
done
2166121682
[[ -z "$calist_string" ]] && calist_string="empty"
21662-
tm_out "$calist_string"
21683+
CLIENT_AUTH_CA_LIST="$(safe_echo "$calist_string")"
21684+
while true; do
21685+
[[ -z "$sigalgs" ]] && break
21686+
case "${sigalgs:0:4}" in
21687+
0101) sigalgs_string+=" RSA+MD5" ;;
21688+
0102) sigalgs_string+=" DSA+MD5" ;;
21689+
0103) sigalgs_string+=" ECDSA+MD5" ;;
21690+
0201) sigalgs_string+=" RSA+SHA1" ;;
21691+
0202) sigalgs_string+=" DSA+SHA1" ;;
21692+
0203) sigalgs_string+=" ECDSA+SHA1" ;;
21693+
0301) sigalgs_string+=" RSA+SHA224" ;;
21694+
0302) sigalgs_string+=" DSA+SHA224" ;;
21695+
0303) sigalgs_string+=" ECDSA+SHA224" ;;
21696+
0401|0420) sigalgs_string+=" RSA+SHA256" ;;
21697+
0402) sigalgs_string+=" DSA+SHA256" ;;
21698+
0403|081a) sigalgs_string+=" ECDSA+SHA256" ;;
21699+
0501|0520) sigalgs_string+=" RSA+SHA384" ;;
21700+
0502) sigalgs_string+=" DSA+SHA384" ;;
21701+
0503|081b) sigalgs_string+=" ECDSA+SHA384" ;;
21702+
0601|0620) sigalgs_string+=" RSA+SHA512" ;;
21703+
0602) sigalgs_string+=" DSA+SHA512" ;;
21704+
0603|081c) sigalgs_string+=" ECDSA+SHA512" ;;
21705+
0708) sigalgs_string+=" SM2+SM3" ;;
21706+
0804|0809) sigalgs_string+=" RSA-PSS+SHA256" ;;
21707+
0805|080a) sigalgs_string+=" RSA-PSS+SHA384" ;;
21708+
0806|080b) sigalgs_string+=" RSA-PSS+SHA512" ;;
21709+
0807) sigalgs_string+=" Ed25519" ;;
21710+
0808) sigalgs_string+=" Ed448" ;;
21711+
*) sigalgs_string+=" unknown(${sigalgs:0:4})";;
21712+
esac
21713+
sigalgs="${sigalgs:4}"
21714+
done
21715+
CLIENT_AUTH_SIGALGS_LIST="${sigalgs_string:1} "
21716+
[[ -z "$CLIENT_AUTH_SIGALGS_LIST" ]] && CLIENT_AUTH_SIGALGS_LIST="empty "
2166321717
return 0
2166421718
}
2166521719

@@ -21690,7 +21744,7 @@ sclient_auth() {
2169021744
# CertificateRequest message in -msg
2169121745
CLIENT_AUTH="required"
2169221746
[[ $1 -eq 0 ]] && CLIENT_AUTH="optional"
21693-
CLIENT_AUTH_CA_LIST="$(extract_calist "$server_hello")"
21747+
extract_calist "$server_hello"
2169421748
return 0
2169521749
fi
2169621750
[[ $1 -eq 0 ]] && return 0

0 commit comments

Comments
 (0)