From b998dc59475bf62c7efbd0750bf5ef7568555467 Mon Sep 17 00:00:00 2001 From: LoRd_MuldeR Date: Tue, 15 Dec 2020 17:18:25 +0100 Subject: [PATCH] Obfuscate nonce in output file, by XOR'ing with the first digits of PI. --- frontend/src/main.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/frontend/src/main.c b/frontend/src/main.c index c777ec3..cb6c46b 100644 --- a/frontend/src/main.c +++ b/frontend/src/main.c @@ -34,7 +34,7 @@ #define SLUNK_MODE_PASS 4 #define SLUNK_MODE_TEST 5 -static const CHR *const ENVV_PASSWD_NAME = T("SLUNK_PASSPHRASE"); +static const CHR* const ENVV_PASSWD_NAME = T("SLUNK_PASSPHRASE"); static const char PASSWD_SYMBOLS[] = { '!', '#', '$', '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', '0', '1', @@ -45,6 +45,8 @@ static const char PASSWD_SYMBOLS[] = 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '}', '~' }; +static const uint64_t MAGIC_NUMBER = 0x243F6A8885A308D3ull; + // ========================================================================== // Auxiliary functions // ========================================================================== @@ -271,7 +273,7 @@ static int encrypt(const char* const passphrase, const CHR* const input_path, co goto clean_up; } - nonce = swap_bytes_u64(nonce); + nonce = swap_bytes_u64(nonce ^ MAGIC_NUMBER); if (fwrite(&nonce, sizeof(uint64_t), 1U, file_out) < 1U) { FPUTS(T("\n\nI/O error: Failed to write nonce value!\n\n"), stderr); @@ -433,7 +435,7 @@ static int decrypt(const char* const passphrase, const CHR* const input_path, co goto clean_up; } - ctx = slunkcrypt_alloc(swap_bytes_u64(nonce), (const uint8_t*)passphrase, strlen(passphrase)); + ctx = slunkcrypt_alloc(swap_bytes_u64(nonce) ^ MAGIC_NUMBER, (const uint8_t*)passphrase, strlen(passphrase)); if (!ctx) { FPUTS(g_slunkcrypt_abort_flag ? T("\n\nProcess interrupted!\n\n") : T("\n\nSlunkCrypt error: Failed to initialize decryption!\n\n"), stderr);