Use bash internal functions
This PR replaces more uses of awk with bash internal functions.
This commit is contained in:
parent
430917d59f
commit
dab7c1bfc0
38
testssl.sh
38
testssl.sh
|
@ -3856,13 +3856,13 @@ run_client_simulation() {
|
||||||
# If an ephemeral DH key was used, check that the number of bits is within range.
|
# If an ephemeral DH key was used, check that the number of bits is within range.
|
||||||
temp=$(awk -F': ' '/^Server Temp Key/ { print $2 }' "$TMPFILE") # extract line
|
temp=$(awk -F': ' '/^Server Temp Key/ { print $2 }' "$TMPFILE") # extract line
|
||||||
what_dh="${temp%%,*}"
|
what_dh="${temp%%,*}"
|
||||||
bits=$(awk -F',' '{ print $3 }' <<< $temp)
|
bits="${temp##*, }"
|
||||||
# formatting
|
# formatting
|
||||||
if [[ "$bits" =~ bits ]]; then
|
curve="${temp#*, }"
|
||||||
curve="$(strip_spaces "$(awk -F',' '{ print $2 }' <<< $temp)")"
|
if [[ "$curve" == "$bits" ]]; then
|
||||||
else
|
|
||||||
curve=""
|
curve=""
|
||||||
bits=$(awk -F',' '{ print $2 }' <<< $temp)
|
else
|
||||||
|
curve="${curve%%,*}"
|
||||||
fi
|
fi
|
||||||
bits="${bits/bits/}"
|
bits="${bits/bits/}"
|
||||||
bits="${bits// /}"
|
bits="${bits// /}"
|
||||||
|
@ -4568,12 +4568,12 @@ read_dhbits_from_file() {
|
||||||
|
|
||||||
temp=$(awk -F': ' '/^Server Temp Key/ { print $2 }' "$1") # extract line
|
temp=$(awk -F': ' '/^Server Temp Key/ { print $2 }' "$1") # extract line
|
||||||
what_dh="${temp%%,*}"
|
what_dh="${temp%%,*}"
|
||||||
bits=$(awk -F',' '{ print $3 }' <<< $temp)
|
bits="${temp##*, }"
|
||||||
# RH's backport has the DH bits in second arg after comma
|
curve="${temp#*, }"
|
||||||
if [[ "$bits" =~ bits ]]; then
|
if [[ "$curve" == "$bits" ]]; then
|
||||||
curve="$(strip_spaces "$(awk -F',' '{ print $2 }' <<< $temp)")"
|
curve=""
|
||||||
else
|
else
|
||||||
bits=$(awk -F',' '{ print $2 }' <<< $temp)
|
curve="${curve%%,*}"
|
||||||
fi
|
fi
|
||||||
bits="${bits/bits/}"
|
bits="${bits/bits/}"
|
||||||
bits="${bits// /}"
|
bits="${bits// /}"
|
||||||
|
@ -7020,7 +7020,10 @@ run_pfs() {
|
||||||
sclient_connect_successful $? $TMPFILE || break
|
sclient_connect_successful $? $TMPFILE || break
|
||||||
temp=$(awk -F': ' '/^Server Temp Key/ { print $2 }' "$TMPFILE")
|
temp=$(awk -F': ' '/^Server Temp Key/ { print $2 }' "$TMPFILE")
|
||||||
curve_found="${temp%%,*}"
|
curve_found="${temp%%,*}"
|
||||||
[[ "$curve_found" == "ECDH" ]] && curve_found="$(awk -F', ' '{ print $2 }' <<< $temp)"
|
if [[ "$curve_found" == "ECDH" ]]; then
|
||||||
|
curve_found="${temp#*, }"
|
||||||
|
curve_found="${curve_found%%,*}"
|
||||||
|
fi
|
||||||
for (( i=low; i < high; i++ )); do
|
for (( i=low; i < high; i++ )); do
|
||||||
! "${supported_curve[i]}" && [[ "${curves_ossl_output[i]}" == "$curve_found" ]] && break
|
! "${supported_curve[i]}" && [[ "${curves_ossl_output[i]}" == "$curve_found" ]] && break
|
||||||
done
|
done
|
||||||
|
@ -7043,7 +7046,10 @@ run_pfs() {
|
||||||
[[ $sclient_success -ne 0 ]] && [[ $sclient_success -ne 2 ]] && break
|
[[ $sclient_success -ne 0 ]] && [[ $sclient_success -ne 2 ]] && break
|
||||||
temp=$(awk -F': ' '/^Server Temp Key/ { print $2 }' "$TEMPDIR/$NODEIP.parse_tls_serverhello.txt")
|
temp=$(awk -F': ' '/^Server Temp Key/ { print $2 }' "$TEMPDIR/$NODEIP.parse_tls_serverhello.txt")
|
||||||
curve_found="${temp%%,*}"
|
curve_found="${temp%%,*}"
|
||||||
[[ "$curve_found" == "ECDH" ]] && curve_found="$(awk -F', ' '{ print $2 }' <<< $temp)"
|
if [[ "$curve_found" == "ECDH" ]]; then
|
||||||
|
curve_found="${temp#*, }"
|
||||||
|
curve_found="${curve_found%%,*}"
|
||||||
|
fi
|
||||||
for (( i=0; i < nr_curves; i++ )); do
|
for (( i=0; i < nr_curves; i++ )); do
|
||||||
! "${supported_curve[i]}" && [[ "${curves_ossl_output[i]}" == "$curve_found" ]] && break
|
! "${supported_curve[i]}" && [[ "${curves_ossl_output[i]}" == "$curve_found" ]] && break
|
||||||
done
|
done
|
||||||
|
@ -7087,7 +7093,8 @@ run_pfs() {
|
||||||
sclient_success=$?
|
sclient_success=$?
|
||||||
[[ $sclient_success -ne 0 ]] && [[ $sclient_success -ne 2 ]] && break
|
[[ $sclient_success -ne 0 ]] && [[ $sclient_success -ne 2 ]] && break
|
||||||
temp=$(awk -F': ' '/^Server Temp Key/ { print $2 }' "$TEMPDIR/$NODEIP.parse_tls_serverhello.txt")
|
temp=$(awk -F': ' '/^Server Temp Key/ { print $2 }' "$TEMPDIR/$NODEIP.parse_tls_serverhello.txt")
|
||||||
curve_found="$(awk -F', ' '{ print $2 }' <<< $temp)"
|
curve_found="${temp#*, }"
|
||||||
|
curve_found="${curve_found%%,*}"
|
||||||
[[ ! "$curve_found" =~ ffdhe ]] && break
|
[[ ! "$curve_found" =~ ffdhe ]] && break
|
||||||
for (( i=0; i < nr_curves; i++ )); do
|
for (( i=0; i < nr_curves; i++ )); do
|
||||||
! "${supported_curve[i]}" && [[ "${ffdhe_groups_output[i]}" == "$curve_found" ]] && break
|
! "${supported_curve[i]}" && [[ "${ffdhe_groups_output[i]}" == "$curve_found" ]] && break
|
||||||
|
@ -12048,7 +12055,10 @@ run_grease() {
|
||||||
rnd=$RANDOM%${#grease_supported_groups[@]}
|
rnd=$RANDOM%${#grease_supported_groups[@]}
|
||||||
temp=$(awk -F': ' '/^Server Temp Key/ { print $2 }' "$TEMPDIR/$NODEIP.parse_tls_serverhello.txt")
|
temp=$(awk -F': ' '/^Server Temp Key/ { print $2 }' "$TEMPDIR/$NODEIP.parse_tls_serverhello.txt")
|
||||||
curve_found="${temp%%,*}"
|
curve_found="${temp%%,*}"
|
||||||
[[ "$curve_found" == "ECDH" ]] && curve_found="$(awk -F', ' '{ print $2 }' <<< $temp)"
|
if [[ "$curve_found" == "ECDH" ]]; then
|
||||||
|
curve_found="${temp#*, }"
|
||||||
|
curve_found="${curve_found%%,*}"
|
||||||
|
fi
|
||||||
if [[ "$curve_found" == "B-571" ]]; then
|
if [[ "$curve_found" == "B-571" ]]; then
|
||||||
extn="
|
extn="
|
||||||
00, 0a, # Type: Supported Elliptic Curves , see RFC 4492
|
00, 0a, # Type: Supported Elliptic Curves , see RFC 4492
|
||||||
|
|
Loading…
Reference in New Issue