1
0
Fork 0

Improved test script.

This commit is contained in:
LoRd_MuldeR 2022-10-29 00:21:13 +02:00
parent 393120ac58
commit b00f31bd72
Signed by: mulder
GPG Key ID: 2B5913365F57E03F
1 changed files with 26 additions and 36 deletions

View File

@ -1,31 +1,28 @@
#!/bin/bash
set -e
cd -- "$(dirname -- "${BASH_SOURCE[0]}")"
if [ "$(find . -maxdepth 1 -type f -perm /111 -name 'slunkcrypt*' | sed -e 's/^[[:blank:]]*//;s/[[:blank:]]*$//' -e '/^$/d' | wc -l)" -lt 1 ]; then
echo "No Slunkcrypt executable(s) found!"
exit 1
fi
function check_file() {
local checksum="$(sha512sum "${1}" | grep -Po '^\s*\K\w+')"
if [ "${checksum,,}" != "${2,,}" ]; then
echo "Error: Checksum of \"${1}\" does not match !!!"
echo "-> Expected: ${2,,}"
echo "-> Computed: ${checksum,,}"
local checksum="$(sha512sum "${1}" | grep -Eo '^[[:alnum:]]+' | tr 'A-Z' 'a-z' | head -n 1)"
if [ "${checksum}" != "${2}" ]; then
echo "Error: Checksum of file \"${1}\" does not match !!!"
echo "-> Expected: ${2}"
echo "-> Computed: ${checksum}"
exit 1
fi
echo "Checksum is correct."
echo "Checksum of file \"${1}\" is correct."
}
for suffix in i686 x86_64; do
if [ ! -x ./slunkcrypt-${suffix} ]; then
echo "Required program file \"slunkcrypt-${suffix}\" not found !!!"
exit 1
fi
done
echo -e "\n------------------------------------------------------------------------------"
echo "Clean up"
echo -e "------------------------------------------------------------------------------\n"
rm -vf "test-vectors.tar" "passphrase.txt" "sha512sums.txt"
rm -vf "test-"*"."{enc,png}
rm -vf test-vectors.tar passphrase.txt sha512sums.txt
rm -vf test-*.enc rm -vf restored-*.png
echo -e "\n------------------------------------------------------------------------------"
echo "Download"
@ -42,28 +39,21 @@ check_file "test-v100-2.enc" "a0e97b8e0b78a2fde215eb7234cff253e4af5b9ae426aaebfa
check_file "test-v130-1.enc" "c13e6e001b08efba58909beed952957ea245a6f7fe52ad7022265f25f6f3a1c74423922f46cf171f2b23f948e4fde7004d83c89f95b62f825ff262cc7468bb48"
check_file "test-v130-2.enc" "48fe6ce4b82fb1c132d987b95576b6856deb43031047f669434347d9ffb8bc79a636e59548ffa18bd8031fbaeb034cb972a147087f49a61bf53a6b740434f3c6"
echo -e "\n------------------------------------------------------------------------------"
echo "Decrypt"
echo -e "------------------------------------------------------------------------------\n"
while IFS= read -r name; do
echo -e "\n------------------------------------------------------------------------------"
echo "${name}"
echo -e "------------------------------------------------------------------------------\n"
for suffix in i686 x86_64; do
SLUNK_LEGACY_COMPAT=1 ./slunkcrypt-${suffix} -d 'pass:Q8YRL4_SFGt9m(>I,(h=fDaw' "test-v100-1.enc" "test-v100-1-${suffix}.png"
SLUNK_LEGACY_COMPAT=1 ./slunkcrypt-${suffix} -d 'pass:1$SfiHiQW*G|RbpR8trFR$sp' "test-v100-2.enc" "test-v100-2-${suffix}.png"
SLUNK_LEGACY_COMPAT=0 ./slunkcrypt-${suffix} -d 'pass:Q8YRL4_SFGt9m(>I,(h=fDaw' "test-v130-1.enc" "test-v130-1-${suffix}.png"
SLUNK_LEGACY_COMPAT=0 ./slunkcrypt-${suffix} -d 'pass:1$SfiHiQW*G|RbpR8trFR$sp' "test-v130-2.enc" "test-v130-2-${suffix}.png"
done
SLUNK_LEGACY_COMPAT=1 ./${name} -d 'pass:Q8YRL4_SFGt9m(>I,(h=fDaw' "test-v100-1.enc" "restored-v100-1.${name}.png"
SLUNK_LEGACY_COMPAT=1 ./${name} -d 'pass:1$SfiHiQW*G|RbpR8trFR$sp' "test-v100-2.enc" "restored-v100-2.${name}.png"
SLUNK_LEGACY_COMPAT=0 ./${name} -d 'pass:Q8YRL4_SFGt9m(>I,(h=fDaw' "test-v130-1.enc" "restored-v130-1.${name}.png"
SLUNK_LEGACY_COMPAT=0 ./${name} -d 'pass:1$SfiHiQW*G|RbpR8trFR$sp' "test-v130-2.enc" "restored-v130-2.${name}.png"
echo -e "\n------------------------------------------------------------------------------"
echo "Verify checksums"
echo -e "------------------------------------------------------------------------------\n"
for suffix in i686 x86_64; do
for version_number in 100 130; do
for i in {1..2}; do
check_file "test-v${version_number}-${i}-${suffix}.png" "658a566d279070546dcb385f0ae1f236058edfe246caaaa149b8de448b788616cf78f229af7e70c3a06a23b649540aa5f53927f9a959a957b9b8b0ddf25063b1"
for i in 100 130; do
for j in {1..2}; do
check_file "restored-v${i}-${j}.${name}.png" "658a566d279070546dcb385f0ae1f236058edfe246caaaa149b8de448b788616cf78f229af7e70c3a06a23b649540aa5f53927f9a959a957b9b8b0ddf25063b1"
done
done
done
done < <(find . -maxdepth 1 -type f -perm /111 -name 'slunkcrypt*' -exec basename "{}" \; | sed -e 's/^[[:blank:]]*//;s/[[:blank:]]*$//' -e '/^$/d')
echo -e "\nEverything completed successfully."
printf "\n"
echo -e "\nEverything completed successfully.\n"