File: hexstream2cipher.sh

package info (click to toggle)
testssl.sh 3.2.2%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,636 kB
  • sloc: sh: 22,615; perl: 1,160; java: 42; makefile: 19
file content (38 lines) | stat: -rwxr-xr-x 781 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env bash

hs="$1"
len=${#hs}
echo "# ciphers: $((len/4))"

mapfile="etc/cipher-mapping.txt"
[ -s $mapfile ] || mapfile="../$mapfile"
[ -s $mapfile ] || exit 255

cip=""
first=true

for ((i=0; i<len ; i+=4)); do
	printf "%02d" "$i"
	echo -n ": ${hs:$i:4}"
	grepstr="0x${hs:$i:2},0x${hs:$((i+2)):2}"
        echo -n " --> $grepstr --> "
        cip=$(grep -i -E "^ *${grepstr}" $mapfile | awk '{ print $3 }')
	if [[ $grepstr == 0x00,0xff ]]; then
		echo TLS_EMPTY_RENEGOTIATION_INFO_SCSV
	else
		echo $cip
	fi
	if "$first"; then
		ciphers="$cip"
		first=false
	else
		ciphers="$ciphers:$cip"
	fi
done

echo
# remove leading : because of GREASE, and trailing because of TLS_EMPTY_RENEGOTIATION_INFO_SCSV
ciphers="${ciphers%:}"
echo ${ciphers#:}

#  vim:ts=5:sw=5:expandtab