diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 17:11:11 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 17:11:11 +0000 |
commit | ba28aa09cebfba17fd16de2af6fedf7ecc76eea5 (patch) | |
tree | 44e2ff1493776a06e95c359c53a1cabca5d8a8d4 /utils/hexstream2curves.sh | |
parent | Initial commit. (diff) | |
download | testssl.sh-upstream.tar.xz testssl.sh-upstream.zip |
Adding upstream version 3.2~rc3+dfsg.upstream/3.2_rc3+dfsgupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'utils/hexstream2curves.sh')
-rwxr-xr-x | utils/hexstream2curves.sh | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/utils/hexstream2curves.sh b/utils/hexstream2curves.sh new file mode 100755 index 0000000..0f842e4 --- /dev/null +++ b/utils/hexstream2curves.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env bash + +hs="$1" +len=${#hs} +echo "# curves: $((len/4))" + +mapfile="etc/curves-mapping.txt" +[ -s $mapfile ] || mapfile="../$mapfile" +[ -s $mapfile ] || exit 255 + +cur="" +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 --> " + cur=$(grep -i -E "^ *${grepstr}" $mapfile | awk '{ print $3 }') + if [[ $grepstr == 0x00,0xff ]]; then + echo TPM_ECC_NONE + else + echo $cur + fi + if "$first"; then + curves="$cur" + first=false + else + curves="$curves:$cur" + fi +done + +echo +# remove leading : because of GREASE, and trailing because of TPM_ECC_NONE +curves="${curves%:}" +echo ${curves#:} + +# vim:ts=5:sw=5:expandtab |