Merge pull request #2819 from testssl/perf_improvements

Make code2network() faster by using bash instead of tr
This commit is contained in:
Dirk Wetter
2025-07-03 18:14:54 +02:00
committed by GitHub
2 changed files with 11 additions and 6 deletions

View File

@ -31,8 +31,8 @@ system("@args") == 0
or die ("FAILED: \"@args\" ");
$cat_csv=`cat $csv`;
# Is the certificate revoked?
like($cat_csv, qr/"cert_ocspRevoked".*"CRITICAL","revoked"/,"The certificate should be revoked");
# Is the certificate revoked? (formerly: OCSP, now: CRL)
like($cat_csv, qr/"cert_crlRevoked".*"CRITICAL","revoked"/,"The certificate should be revoked");
$tests++;
unlink $csv;

View File

@ -12139,16 +12139,20 @@ send_close_notify() {
fi
}
# Format string properly for socket
# ARG1: any commented sequence of two bytes hex, separated by commas. It can contain comments, new lines, tabs and white spaces
# NW_STR holds the global with the string prepared for printf, like '\x16\x03\x03\'
# Format string properly for socket in ARG1 as it can be found here
# ARG1: sequence of 2 bytes hex, separated by commas. Can contain comments, new lines, tabs + white spaces
# NW_STR: holds afterwards the global with the string prepared for printf, like '\x16\x03\x03\'
#
code2network() {
NW_STR=$(sed -e 's/,/\\\x/g' <<< "$1" | sed -e 's/# .*$//g' -e 's/ //g' -e '/^$/d' | tr -d '\n' | tr -d '\t')
NW_STR="$(sed -e 's/,/\\\x/g' -e 's/# .*$//g' -e 's/ //g' -e '/^$/d' <<< "$1")"
NW_STR="${NW_STR//$'\n'/}"
NW_STR="${NW_STR//$'\t'/}"
}
# sockets inspired by https://blog.chris007.de/using-bash-for-network-socket-operation/
# ARG1: hexbytes separated by commas, with a leading comma
# ARG2: seconds to sleep
#
socksend_clienthello() {
local data=""
@ -12167,6 +12171,7 @@ socksend_clienthello() {
# ARG1: hexbytes -- preceded by x -- separated by commas, with a leading comma
# ARG2: seconds to sleep
#
socksend() {
local data line