mirror of
https://gitlab.kit.edu/kit/scc/sys/mail/exim-encrypt-dlfunc.git
synced 2025-12-06 06:43:56 +01:00
debugging meson build tests
This commit is contained in:
@ -53,15 +53,11 @@ char *read_first_line(const char *filename) {
|
||||
return cipherstring;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
unsigned char *string;
|
||||
size_t length;
|
||||
} Password;
|
||||
|
||||
void base64_decode_string(const char *input, unsigned char **outstring, size_t *outlen) {
|
||||
size_t input_len = strlen(input);
|
||||
size_t outmaxlen = input_len / 4 * 3;
|
||||
*outstring = malloc(outmaxlen * sizeof(unsigned char));
|
||||
fprintf(stderr, " Input: |%s| [%zu]\n", input, input_len);
|
||||
int b64err = sodium_base642bin(*outstring, outmaxlen, (const char *) input, input_len,
|
||||
NULL, outlen, NULL, sodium_base64_VARIANT_ORIGINAL);
|
||||
if (b64err != 0) {
|
||||
|
||||
@ -64,9 +64,12 @@ int main(int argc, char *argv[]) {
|
||||
// check environment for LIBEXIM_PASSWORD
|
||||
password_env = getenv(ENVVAR_PASSWORD_NAME);
|
||||
if (password_env != NULL && strlen(password_env) > 0) {
|
||||
password_len = strlen((const char *) password_env);
|
||||
password = malloc(password_len + 1);
|
||||
strncpy(password, password_env, password_len);
|
||||
// password_len = strlen((const char *) password_env);
|
||||
// password = malloc(password_len);
|
||||
// sodium_memzero(password, password_len);
|
||||
// strncpy(password, password_env, password_len);
|
||||
password = password_env;
|
||||
password_len = strlen(password);
|
||||
mode |= PASSENV;
|
||||
}
|
||||
|
||||
|
||||
@ -15,22 +15,24 @@ CIPHERTEXT_FILE02="$(mktemp)"
|
||||
echo -n "${TEST_CIPHERTEXT01}" > "${CIPHERTEXT_FILE01}"
|
||||
echo -n "${TEST_CIPHERTEXT02}" > "${CIPHERTEXT_FILE02}"
|
||||
|
||||
DECRYPTED01="$(LIBEXIM_PASSWORD="${TEST_PASSWORD}" src/libexim-encrypt-dlfunc-decrypt-secretbox ${TEST_CIPHERTEXT01})"
|
||||
export LIBEXIM_PASSWORD="${TEST_PASSWORD}"
|
||||
#DECRYPTED01="$(LIBEXIM_PASSWORD="${TEST_PASSWORD}" src/libexim-encrypt-dlfunc-decrypt-secretbox ${TEST_CIPHERTEXT01})"
|
||||
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="$(LIBEXIM_PASSWORD="${TEST_PASSWORD}" src/libexim-encrypt-dlfunc-decrypt-secretbox --infile ${CIPHERTEXT_FILE01})"
|
||||
#DECRYPTED02="$(LIBEXIM_PASSWORD="${TEST_PASSWORD}" src/libexim-encrypt-dlfunc-decrypt-secretbox --infile ${CIPHERTEXT_FILE01})"
|
||||
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 "${CIPHERTEXT_FILE01}"
|
||||
cat "${CIPHERTEXT_FILE01}"
|
||||
echo "not ok 2 - decrypt file contents with password from environment unsuccessful"
|
||||
fi
|
||||
unset LIBEXIM_PASSWORD
|
||||
#unset LIBEXIM_PASSWORD
|
||||
export -n LIBEXIM_PASSWORD
|
||||
|
||||
DECRYPTED03="$(src/libexim-encrypt-dlfunc-decrypt-secretbox -p ${TEST_PASSWORD} ${TEST_CIPHERTEXT02})"
|
||||
if [ "${DECRYPTED03}" == "${TEST_CLEARTEXT}" ] ; then
|
||||
@ -43,7 +45,5 @@ DECRYPTED04="$(src/libexim-encrypt-dlfunc-decrypt-secretbox -p ${TEST_PASSWORD}
|
||||
if [ "${DECRYPTED04}" == "${TEST_CLEARTEXT}" ] ; then
|
||||
echo "ok 4 - decrypt file contents with password from commandline successful"
|
||||
else
|
||||
echo "${CIPHERTEXT_FILE02}"
|
||||
cat "${CIPHERTEXT_FILE02}"
|
||||
echo "not ok 4 - decrypt file contents with password from commandline unsuccessful"
|
||||
fi
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user