diff options
-rwxr-xr-x | name-to-number.awk | 25 | ||||
-rwxr-xr-x | number-to-name.awk | 25 |
2 files changed, 50 insertions, 0 deletions
diff --git a/name-to-number.awk b/name-to-number.awk new file mode 100755 index 0000000..885f0a0 --- /dev/null +++ b/name-to-number.awk @@ -0,0 +1,25 @@ +#!/usr/bin/awk -f +# Tries to prepend the number matching a Cipher Suite (or 0 if none is found) +# Author: Peter Wu <lekensteyn@gmail.com> + +BEGIN { + # must be a file of format '(decimal number) TLS_(...)' + if (!suites) suites="suites.txt"; + + # Read all name to number mappings from file + while ((getline < suites) > 0) { + if ($2 ~ /^TLS_/) { + name_to_num[$2] = $1; + } + } +} +{ + for (i = 1; i <= NF; i++) { + if ($i ~ /^TLS_/) { + num = name_to_num[$i]; + if (!num) num = 0; + $i = num " " $i; + } + } + print; +} diff --git a/number-to-name.awk b/number-to-name.awk new file mode 100755 index 0000000..8c499be --- /dev/null +++ b/number-to-name.awk @@ -0,0 +1,25 @@ +#!/usr/bin/awk -f +# Tries to map a number to name (or a question mark if not found) +# Author: Peter Wu <lekensteyn@gmail.com> + +BEGIN { + if (!cmd) cmd = "openssl ciphers -V"; + + while ((cmd | getline) > 0) { + if ( split($0, a, / +- +|[, ]+/)) { + num = strtonum(a[2]) * 256 + strtonum(a[3]); + name = a[4]; + number_to_name[num] = name; + } + } +} +{ + for (i = 1; i <= NF; i++) { + if ($i ~ /^[0-9]+$/) { + name = number_to_name[$i]; + if (!name) name = "?"; + $i = $i " " name; + } + } + print; +} |