diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 21:41:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 21:41:43 +0000 |
commit | 92cccad89d1c12b39165d5f0ed7ccd2d44965a1a (patch) | |
tree | f59a2764cd8c50959050a428bd8fc935138df750 /tests/base64decode.sh | |
parent | Initial commit. (diff) | |
download | libtpms-92cccad89d1c12b39165d5f0ed7ccd2d44965a1a.tar.xz libtpms-92cccad89d1c12b39165d5f0ed7ccd2d44965a1a.zip |
Adding upstream version 0.9.2.upstream/0.9.2upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/base64decode.sh')
-rwxr-xr-x | tests/base64decode.sh | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/base64decode.sh b/tests/base64decode.sh new file mode 100755 index 0000000..eef96fe --- /dev/null +++ b/tests/base64decode.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env bash + +input=$(mktemp) +binary=$(mktemp) + +trap "rm -f $input $binary" EXIT + +function sseq() +{ + for ((i = $1; i < $2; i=i<<1)); do + echo $i + done +} + +function do_base64() +{ + if [ -n "$(type -p base64)" ]; then + base64 $1 + elif [ -n "$(type -p uuencode)" ]; then + uuencode -m $1 data | sed 1d | sed '$d' + else + echo "No tool found for base64 encoding." >&2 + exit 1 + fi +} + +for i in $(sseq 1 1024) 2048 10240; +do + echo $i + dd if=/dev/urandom of=$binary bs=1 count=$i &>/dev/null + echo "-----BEGIN INITSTATE-----" > $input + do_base64 $binary >> $input + echo "-----END INITSTATE-----" >> $input + ./base64decode $input $binary + if [ $? -ne 0 ]; then + exit 1 + fi +done |