diff --git a/testssl.sh b/testssl.sh index 6e1cc49..b72e7bf 100755 --- a/testssl.sh +++ b/testssl.sh @@ -1455,7 +1455,7 @@ out_row_aligned_max_width() { tm_out "${text:0:i}" [[ $i -eq $len ]] && break len=$len-$i-1 - i=$i+1 + i+=1 text="${text:i:len}" first=false [[ $len -eq 0 ]] && break @@ -1915,7 +1915,7 @@ asciihex_to_binary() { len=${#string} [[ $len%2 -ne 0 ]] && return 1 - for (( i=0; i <= len-16 ; i=i+16 )); do + for (( i=0; i <= len-16 ; i+=16 )); do ip2=$((i+2)); ip4=$((i+4)); ip6=$((i+6)); ip8=$((i+8)); ip10=$((i+10)); ip12=$((i+12)); ip14=$((i+14)) printf -- "\x${string:i:2}\x${string:ip2:2}\x${string:ip4:2}\x${string:ip6:2}\x${string:ip8:2}\x${string:ip10:2}\x${string:ip12:2}\x${string:ip14:2}" done @@ -3405,7 +3405,7 @@ run_cipher_match(){ local -a ciphers_found ciphers_found2 ciph2 rfc_ciph rfc_ciph2 ossl_supported local -a -i index local -i nr_ciphers=0 nr_ossl_ciphers=0 nr_nonossl_ciphers=0 - local -i num_bundles mod_check bundle_size bundle end_of_bundle + local -i num_bundles bundle_size bundle end_of_bundle local dhlen has_dh_bits="$HAS_DH_BITS" local cipher proto protos_to_try local available @@ -3552,12 +3552,10 @@ run_cipher_match(){ # Some servers can't handle a handshake with >= 128 ciphers. So, # test cipher suites in bundles of 128 or less. num_bundles=$nr_ossl_ciphers/128 - mod_check=$nr_ossl_ciphers%128 - [[ $mod_check -ne 0 ]] && num_bundles=$num_bundles+1 + [[ $((nr_ossl_ciphers%128)) -ne 0 ]] && num_bundles+=1 bundle_size=$nr_ossl_ciphers/$num_bundles - mod_check=$nr_ossl_ciphers%$num_bundles - [[ $mod_check -ne 0 ]] && bundle_size+=1 + [[ $((nr_ossl_ciphers%num_bundles)) -ne 0 ]] && bundle_size+=1 fi if "$HAS_TLS13"; then @@ -3573,7 +3571,7 @@ run_cipher_match(){ bundle_size=$nr_ossl_ciphers fi for (( bundle=0; bundle < num_bundles; bundle++ )); do - end_of_bundle=$bundle*$bundle_size+$bundle_size + end_of_bundle=$(( (bundle+1)*bundle_size )) [[ $end_of_bundle -gt $nr_ossl_ciphers ]] && end_of_bundle=$nr_ossl_ciphers while true; do ciphers_to_test="" @@ -3629,17 +3627,15 @@ run_cipher_match(){ # Some servers can't handle a handshake with >= 128 ciphers. So, # test cipher suites in bundles of 128 or less. num_bundles=$nr_nonossl_ciphers/128 - mod_check=$nr_nonossl_ciphers%128 - [[ $mod_check -ne 0 ]] && num_bundles=$num_bundles+1 + [[ $((nr_nonossl_ciphers%128)) -ne 0 ]] && num_bundles+=1 bundle_size=$nr_nonossl_ciphers/$num_bundles - mod_check=$nr_nonossl_ciphers%$num_bundles - [[ $mod_check -ne 0 ]] && bundle_size+=1 + [[ $((nr_nonossl_ciphers%num_bundles)) -ne 0 ]] && bundle_size+=1 fi for proto in 04 03 02 01 00; do for (( bundle=0; bundle < num_bundles; bundle++ )); do - end_of_bundle=$bundle*$bundle_size+$bundle_size + end_of_bundle=$(( (bundle+1)*bundle_size )) [[ $end_of_bundle -gt $nr_nonossl_ciphers ]] && end_of_bundle=$nr_nonossl_ciphers while true; do ciphers_to_test="" @@ -3707,7 +3703,7 @@ run_allciphers() { local -i nr_ciphers_tested=0 nr_ciphers=0 nr_ossl_ciphers=0 nr_nonossl_ciphers=0 sclient_success=0 local n auth mac hexc sslv2_ciphers="" s local -a normalized_hexcode hexcode ciph sslvers kx enc export2 sigalg ossl_supported - local -i i end_of_bundle bundle bundle_size num_bundles mod_check + local -i i end_of_bundle bundle bundle_size num_bundles local -a ciphers_found ciphers_found2 hexcode2 ciph2 rfc_ciph2 local -i -a index local proto protos_to_try @@ -3828,12 +3824,10 @@ run_allciphers() { # Some servers can't handle a handshake with >= 128 ciphers. So, # test cipher suites in bundles of 128 or less. num_bundles=$nr_ossl_ciphers/128 - mod_check=$nr_ossl_ciphers%128 - [[ $mod_check -ne 0 ]] && num_bundles=$num_bundles+1 + [[ $((nr_ossl_ciphers%128)) -ne 0 ]] && num_bundles+=1 bundle_size=$nr_ossl_ciphers/$num_bundles - mod_check=$nr_ossl_ciphers%$num_bundles - [[ $mod_check -ne 0 ]] && bundle_size+=1 + [[ $((nr_ossl_ciphers%num_bundles)) -ne 0 ]] && bundle_size+=1 fi if "$HAS_TLS13"; then @@ -3851,7 +3845,7 @@ run_allciphers() { [[ "$proto" != "-no_ssl2" ]] && [[ $(has_server_protocol "${proto:1}") -eq 1 ]] && continue for (( bundle=0; bundle < num_bundles; bundle++ )); do - end_of_bundle=$bundle*$bundle_size+$bundle_size + end_of_bundle=$(( (bundle+1)*bundle_size )) [[ $end_of_bundle -gt $nr_ossl_ciphers ]] && end_of_bundle=$nr_ossl_ciphers while true; do ciphers_to_test="" @@ -3908,17 +3902,15 @@ run_allciphers() { # Some servers can't handle a handshake with >= 128 ciphers. So, # test cipher suites in bundles of 128 or less. num_bundles=$nr_nonossl_ciphers/128 - mod_check=$nr_nonossl_ciphers%128 - [[ $mod_check -ne 0 ]] && num_bundles=$num_bundles+1 + [[ $((nr_nonossl_ciphers%128)) -ne 0 ]] && num_bundles+=1 bundle_size=$nr_nonossl_ciphers/$num_bundles - mod_check=$nr_nonossl_ciphers%$num_bundles - [[ $mod_check -ne 0 ]] && bundle_size+=1 + [[ $((nr_nonossl_ciphers%num_bundles)) -ne 0 ]] && bundle_size+=1 fi for proto in 04 03 02 01 00; do for (( bundle=0; bundle < num_bundles; bundle++ )); do - end_of_bundle=$bundle*$bundle_size+$bundle_size + end_of_bundle=$(( (bundle+1)*bundle_size )) [[ $end_of_bundle -gt $nr_nonossl_ciphers ]] && end_of_bundle=$nr_nonossl_ciphers while true; do ciphers_to_test="" @@ -3988,7 +3980,7 @@ ciphers_by_strength() { local n sslvers auth mac hexc sslv2_ciphers="" cipher local -a hexcode normalized_hexcode ciph rfc_ciph kx enc export2 local -a hexcode2 ciph2 rfc_ciph2 - local -i i bundle end_of_bundle bundle_size num_bundles mod_check + local -i i bundle end_of_bundle bundle_size num_bundles local -a ciphers_found ciphers_found2 sigalg ossl_supported index local dhlen supported_sslv2_ciphers ciphers_to_test tls13_ciphers_to_test addcmd temp local available @@ -4125,16 +4117,14 @@ ciphers_by_strength() { # Some servers can't handle a handshake with >= 128 ciphers. So, # test cipher suites in bundles of 128 or less. num_bundles=$nr_ossl_ciphers/128 - mod_check=$nr_ossl_ciphers%128 - [[ $mod_check -ne 0 ]] && num_bundles=$num_bundles+1 + [[ $((nr_ossl_ciphers%128)) -ne 0 ]] && num_bundles+=1 bundle_size=$nr_ossl_ciphers/$num_bundles - mod_check=$nr_ossl_ciphers%$num_bundles - [[ $mod_check -ne 0 ]] && bundle_size+=1 + [[ $((nr_ossl_ciphers%num_bundles)) -ne 0 ]] && bundle_size+=1 fi for (( bundle=0; bundle < num_bundles; bundle++ )); do - end_of_bundle=$bundle*$bundle_size+$bundle_size + end_of_bundle=$(( (bundle+1)*bundle_size )) [[ $end_of_bundle -gt $nr_ossl_ciphers ]] && end_of_bundle=$nr_ossl_ciphers for (( success=0; success==0 ; 1 )); do ciphers_to_test="" @@ -4193,16 +4183,14 @@ ciphers_by_strength() { # Some servers can't handle a handshake with >= 128 ciphers. So, # test cipher suites in bundles of 128 or less. num_bundles=$nr_nonossl_ciphers/128 - mod_check=$nr_nonossl_ciphers%128 - [[ $mod_check -ne 0 ]] && num_bundles=$num_bundles+1 + [[ $((nr_nonossl_ciphers%128)) -ne 0 ]] && num_bundles+=1 bundle_size=$nr_nonossl_ciphers/$num_bundles - mod_check=$nr_nonossl_ciphers%$num_bundles - [[ $mod_check -ne 0 ]] && bundle_size+=1 + [[ $((nr_nonossl_ciphers%num_bundles)) -ne 0 ]] && bundle_size+=1 fi for (( bundle=0; bundle < num_bundles; bundle++ )); do - end_of_bundle=$bundle*$bundle_size+$bundle_size + end_of_bundle=$(( (bundle+1)*bundle_size )) [[ $end_of_bundle -gt $nr_nonossl_ciphers ]] && end_of_bundle=$nr_nonossl_ciphers for (( success=0; success==0 ; 1 )); do ciphers_to_test="" @@ -4431,7 +4419,7 @@ client_simulation_sockets() { TLS_CLIENT_HELLO="" fi len=${#clienthello} - for (( i=0; i < len; i=i+2 )); do + for (( i=0; i < len; i+=2 )); do data+=", ${clienthello:i:2}" done # same as above. If a CIPHER_SUITES string was provided, then check that it is in the ServerHello @@ -4449,7 +4437,7 @@ client_simulation_sockets() { else # Extact list of cipher suites from SSLv2 ClientHello len=2*$(hex2dec "${clienthello:12:2}") - for (( i=22; i < 22+len; i=i+6 )); do + for (( i=22; i < 22+len; i+=6 )); do offset1=$i+2 offset2=$i+4 [[ "${clienthello:i:2}" == 00 ]] && cipher_list_2send+=", ${clienthello:offset1:2},${clienthello:offset2:2}" @@ -5643,7 +5631,7 @@ sub_cipherlists() { sslv2_cipherlist="$(strip_spaces "${6//,/}")" len=${#sslv2_cipherlist} detected_ssl2_ciphers="$(grep "Supported cipher: " "$TEMPDIR/$NODEIP.parse_sslv2_serverhello.txt")" - for (( i=0; i> $TMPFILE case "${tls_serverhello_ascii:offset:4}" in "0017") echo -n "secp256r1" >> $TMPFILE ;; @@ -13130,7 +13115,7 @@ parse_tls_serverhello() { local -i protocol_len echo -n "Protocols advertised by server: " >> $TMPFILE offset=$((extns_offset+12+i)) - for (( j=0; j