mirror of
https://github.com/drwetter/testssl.sh.git
synced 2025-01-08 09:40:57 +01:00
Limit calls to tolower()
It turns out that calling `tolower()` once for each cipher to test is very expensive. So, this commit tries to call `tolower()` only when necessary.
This commit is contained in:
parent
2ff480a6df
commit
db1f4c37a2
@ -2515,7 +2515,7 @@ run_cipher_per_proto() {
|
|||||||
nr_ciphers=0
|
nr_ciphers=0
|
||||||
if "$using_sockets" || [[ $OSSL_VER_MAJOR -lt 1 ]]; then
|
if "$using_sockets" || [[ $OSSL_VER_MAJOR -lt 1 ]]; then
|
||||||
for (( i=0; i < TLS_NR_CIPHERS; i++ )); do
|
for (( i=0; i < TLS_NR_CIPHERS; i++ )); do
|
||||||
hexc="$(tolower "${TLS_CIPHER_HEXCODE[i]}")"
|
hexc="${TLS_CIPHER_HEXCODE[i]}"
|
||||||
ciph[nr_ciphers]="${TLS_CIPHER_OSSL_NAME[i]}"
|
ciph[nr_ciphers]="${TLS_CIPHER_OSSL_NAME[i]}"
|
||||||
rfc_ciph[nr_ciphers]="${TLS_CIPHER_RFC_NAME[i]}"
|
rfc_ciph[nr_ciphers]="${TLS_CIPHER_RFC_NAME[i]}"
|
||||||
kx[nr_ciphers]="${TLS_CIPHER_KX[i]}"
|
kx[nr_ciphers]="${TLS_CIPHER_KX[i]}"
|
||||||
@ -2535,6 +2535,7 @@ run_cipher_per_proto() {
|
|||||||
normalized_hexcode[nr_ciphers]="x${hexc:2:2}${hexc:7:2}"
|
normalized_hexcode[nr_ciphers]="x${hexc:2:2}${hexc:7:2}"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
|
hexc="$(tolower "$hexc")"
|
||||||
hexcode[nr_ciphers]="${hexc:2:2},${hexc:7:2},${hexc:12:2}"
|
hexcode[nr_ciphers]="${hexc:2:2},${hexc:7:2},${hexc:12:2}"
|
||||||
normalized_hexcode[nr_ciphers]="x${hexc:2:2}${hexc:7:2}${hexc:12:2}"
|
normalized_hexcode[nr_ciphers]="x${hexc:2:2}${hexc:7:2}${hexc:12:2}"
|
||||||
fi
|
fi
|
||||||
@ -2570,9 +2571,9 @@ run_cipher_per_proto() {
|
|||||||
ciphers_found[nr_ciphers]=false
|
ciphers_found[nr_ciphers]=false
|
||||||
if [[ ${#hexc} -eq 9 ]]; then
|
if [[ ${#hexc} -eq 9 ]]; then
|
||||||
if [[ "${hexc:2:2}" == "00" ]]; then
|
if [[ "${hexc:2:2}" == "00" ]]; then
|
||||||
normalized_hexcode[nr_ciphers]="$(tolower "x${hexc:7:2}")"
|
normalized_hexcode[nr_ciphers]="x${hexc:7:2}"
|
||||||
else
|
else
|
||||||
normalized_hexcode[nr_ciphers]="$(tolower "x${hexc:2:2}${hexc:7:2}")"
|
normalized_hexcode[nr_ciphers]="x${hexc:2:2}${hexc:7:2}"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
normalized_hexcode[nr_ciphers]="$(tolower "x${hexc:2:2}${hexc:7:2}${hexc:12:2}")"
|
normalized_hexcode[nr_ciphers]="$(tolower "x${hexc:2:2}${hexc:7:2}${hexc:12:2}")"
|
||||||
@ -2738,6 +2739,7 @@ run_cipher_per_proto() {
|
|||||||
for (( i=0 ; i<nr_ciphers; i++ )); do
|
for (( i=0 ; i<nr_ciphers; i++ )); do
|
||||||
if "${ciphers_found[i]}" || "$SHOW_EACH_C"; then
|
if "${ciphers_found[i]}" || "$SHOW_EACH_C"; then
|
||||||
export=${export2[i]}
|
export=${export2[i]}
|
||||||
|
normalized_hexcode[i]="$(tolower "${normalized_hexcode[i]}")"
|
||||||
neat_list "${normalized_hexcode[i]}" "${ciph[i]}" "${kx[i]}" "${enc[i]}"
|
neat_list "${normalized_hexcode[i]}" "${ciph[i]}" "${kx[i]}" "${enc[i]}"
|
||||||
available=""
|
available=""
|
||||||
if "$SHOW_EACH_C"; then
|
if "$SHOW_EACH_C"; then
|
||||||
|
Loading…
Reference in New Issue
Block a user