Obfuscate nonce in output file, by XOR'ing with the first digits of PI.

This commit is contained in:
LoRd_MuldeR 2020-12-15 17:18:25 +01:00
parent 6ca1f55b82
commit b998dc5947
Signed by: mulder
GPG Key ID: 2B5913365F57E03F

View File

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