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);