From 4f91db1dda32ee5638f6b2890bef565aacaddcb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20D=C3=A9trez?= Date: Fri, 26 Aug 2022 17:04:42 +0200 Subject: Remove dependency on base16 in integration/test.sh --- integration/test.sh | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/integration/test.sh b/integration/test.sh index 7f37066..95906b0 100755 --- a/integration/test.sh +++ b/integration/test.sh @@ -624,8 +624,8 @@ function test_get_leaf() { return fi - local message=$(openssl dgst -binary <(echo $data) | base16) - local checksum=$(openssl dgst -binary <(echo $message | base16 -d) | base16) + local message=$(openssl dgst -binary <(echo $data) | b16encode) + local checksum=$(openssl dgst -binary <(echo $message | b16decode) | b16encode) if [[ $(value_of $pri checksum) != $checksum ]]; then fail "$desc: wrong checksum $(value_of $pri checksum)" return @@ -693,7 +693,7 @@ function add_leaf() { local log_dir=${nvars[$s:log_dir]} echo "shard_hint=${nvars[$s:ssrv_shard_start]}" > $log_dir/req - echo "message=$(openssl dgst -binary <(echo $data) | base16)" >> $log_dir/req + echo "message=$(openssl dgst -binary <(echo $data) | b16encode)" >> $log_dir/req echo "signature=$(echo $data | sigsum-debug leaf sign -k $cli_priv -h ${nvars[$s:ssrv_shard_start]})" >> $log_dir/req echo "public_key=$cli_pub" >> $log_dir/req @@ -786,6 +786,14 @@ function pp() { [[ -d /proc/$1 ]] } +function b16encode { + python3 -c 'import sys; sys.stdout.write(sys.stdin.buffer.read().hex())' +} + +function b16decode { + python3 -c 'import sys; sys.stdout.buffer.write(bytes.fromhex(sys.stdin.read()))' +} + function die() { echo -e "\e[37m$(date +"%y-%m-%d %H:%M:%S %Z")\e[0m [\e[31mFATA\e[0m] $@" >&2 exit 1 -- cgit v1.2.3