#!/bin/bash # shellcheck disable=SC2034 # this script implements the TAP protocol (https://testanything.org) echo 1..5 TEST_PASSWORD='be6rahqu3bukee3Aengohgoopheeyis5' TEST_CLEARTEXT='The great thing about attackers is that there are so many to choose from! - Daniel J. Bernstein' TEST_CIPHERTEXT01='K+TOzrbkni7wydNvF1gMRwZWQPNnNIXRG9iQgkFhszBu8ImqIrAK4wWWP02UmclITi8DZbr3sg/EVWurDzAYK+pjkcDAa78glz4qXIqrPbYvEIEHPEExFzCtwi5hqOR+KF7tsqbPvdAOIqwf/2KBomX0GS1I/1CxQMrbJd1VgXc51M4hI0I8' TEST_CIPHERTEXT02='lAod5UhfW6fQCxd4PSktnrzwyWzcw05Svio5XqPOr/p/Ts4Pr0eEjj2TgmT2K85T2xrxCiqmE/OUcODRldEWeSqBSxx0Z6PzXqOzz5ZL6Iq1tggjihMydGz9mNS4jRF9f52k5t2i7xFrMMCRrfq/rer/ngp1h3pposCds+OmX0u+1f4Urj0b' CIPHERTEXT_FILE01="$(mktemp)" CIPHERTEXT_FILE02="$(mktemp)" echo -n "${TEST_CIPHERTEXT01}" > "${CIPHERTEXT_FILE01}" echo -n "${TEST_CIPHERTEXT02}" > "${CIPHERTEXT_FILE02}" cleanup() { rm -rf "${CIPHERTEXT_FILE01}" "${CIPHERTEXT_FILE02}" } trap cleanup EXIT INT TERM export LIBEXIM_PASSWORD="${TEST_PASSWORD}" DECRYPTED01="$(src/libexim-encrypt-dlfunc-decrypt-secretbox ${TEST_CIPHERTEXT01})" if [ "${DECRYPTED01}" == "${TEST_CLEARTEXT}" ] ; then echo "ok 1 - decrypt commandline argument with password from environment successful" else echo "not ok 1 - decrypt commandline argument with password from environment unsuccessful" fi DECRYPTED02="$(src/libexim-encrypt-dlfunc-decrypt-secretbox --infile ${CIPHERTEXT_FILE01})" if [ "${DECRYPTED02}" == "${TEST_CLEARTEXT}" ] ; then echo "ok 2 - decrypt file contents with password from environment successful" else echo "not ok 2 - decrypt file contents with password from environment unsuccessful" fi DECRYPTED03="$(echo -n ${TEST_CIPHERTEXT01} | src/libexim-encrypt-dlfunc-decrypt-secretbox --infile -)" if [ "${DECRYPTED03}" == "${TEST_CLEARTEXT}" ] ; then echo "ok 3 - decrypt stdin contents with password from environment successful" else echo "not ok 3 - decrypt stdin file contents with password from environment unsuccessful" fi export -n LIBEXIM_PASSWORD DECRYPTED04="$(src/libexim-encrypt-dlfunc-decrypt-secretbox -p ${TEST_PASSWORD} ${TEST_CIPHERTEXT02})" if [ "${DECRYPTED04}" == "${TEST_CLEARTEXT}" ] ; then echo "ok 4 - decrypt commandline argument with password from commandline successful" else echo "not ok 4 - decrypt commandline argument with password from commandline unsuccessful" fi DECRYPTED05="$(src/libexim-encrypt-dlfunc-decrypt-secretbox -p ${TEST_PASSWORD} --infile ${CIPHERTEXT_FILE02})" if [ "${DECRYPTED05}" == "${TEST_CLEARTEXT}" ] ; then echo "ok 5 - decrypt file contents with password from commandline successful" else echo "not ok 5 - decrypt file contents with password from commandline unsuccessful" fi