aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrégoire Détrez <gregoire@mullvad.net>2022-08-26 17:04:42 +0200
committerRasmus Dahlberg <rasmus@mullvad.net>2022-08-29 08:49:00 +0200
commit4f91db1dda32ee5638f6b2890bef565aacaddcb2 (patch)
tree8e051e4d8a773aca84ce5f6e9c516f09c0941e84
parenta4f39980c78b805a520d8876e4e3854e537f0bd2 (diff)
Remove dependency on base16 in integration/test.shHEADmain
-rwxr-xr-xintegration/test.sh14
1 files 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