param->version = SLUNKCRYPT_PARAM_VERSION;
param->thread_count = options->thread_count;
param->legacy_compat = options->legacy_compat;
+ param->debug_logging = options->debug_logging;
}
#define UPDATE_PROGRESS_INDICATOR(CLK_UPDATE, CURRENT, TOTAL) do \
{
int keep_incomplete;
int legacy_compat;
+ int debug_logging;
size_t thread_count;
}
crypt_options_t;
static const CHR* const ENV_KEEPFILE = T("SLUNK_KEEP_INCOMPLETE");
static const CHR* const ENV_NTHREADS = T("SLUNK_THREADS");
static const CHR* const ENV_LGCYCMPT = T("SLUNK_LEGACY_COMPAT");
+static const CHR* const ENV_DEBUGLOG = T("SLUNK_DEBUG_LOGGING");
static const CHR* const PREFIX_PASS = T("pass:");
static const CHR* const PREFIX_FILE = T("file:");
/* ----------------------------------------------------- */
const uint64_t clk_start = clock_read();
- const crypt_options_t options = { environ_get_flag(ENV_KEEPFILE), environ_get_flag(ENV_LGCYCMPT), environ_get_uint(ENV_NTHREADS) };
+
+ const crypt_options_t options = { environ_get_flag(ENV_KEEPFILE), environ_get_flag(ENV_LGCYCMPT), environ_get_flag(ENV_DEBUGLOG), environ_get_uint(ENV_NTHREADS) };
switch (slunk_mode)
{
{
for (size_t j = 0U; j < ITERATIONS; ++j)
{
- const slunkparam_t param = { SLUNKCRYPT_PARAM_VERSION, thread_count, (j > 0) ? SLUNKCRYPT_TRUE : SLUNKCRYPT_FALSE };
+ const slunkparam_t param = { SLUNKCRYPT_PARAM_VERSION, thread_count, (j > 0) ? SLUNKCRYPT_TRUE : SLUNKCRYPT_FALSE, SLUNKCRYPT_TRUE };
for (size_t k = 0U; k < ARRAY_SIZE(TEST_NONCE); ++k)
{
FPRINTF(stderr, T("\b\b\b\b\b\b%2u/%2u "), (unsigned)++count, (unsigned)total);
}
}
- const slunkparam_t param = { SLUNKCRYPT_PARAM_VERSION, thread_count, SLUNKCRYPT_FALSE };
+ const slunkparam_t param = { SLUNKCRYPT_PARAM_VERSION, thread_count, SLUNKCRYPT_FALSE, SLUNKCRYPT_TRUE };
for (size_t i = 0U; i < ITERATIONS; ++i)
{
for (size_t j = 0U; j < ARRAY_SIZE(TEST_NONCE); ++j)
uint16_t version; /* Must set to SLUNKCRYPT_PARAM_VERSION */
size_t thread_count; /* Number of threads, set to 0 for auto-detection */
int legacy_compat; /* Compatibility with pre-1.3 versions */
+ int debug_logging; /* Enable debug logging (writes to the syslog) */
}
slunkparam_t;
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
+ <ClCompile Include="src\debug.c" />
<ClCompile Include="src\junk.c" />
<ClCompile Include="src\keygen.c" />
<ClCompile Include="src\slunkcrypt.c" />
<ClInclude Include="include\slunkcrypt.h" />
<ClInclude Include="include\slunkcrypt.hpp" />
<ClInclude Include="src\compiler.h" />
+ <ClInclude Include="src\debug.h" />
<ClInclude Include="src\initialize.h" />
<ClInclude Include="src\keygen.h" />
<ClInclude Include="src\thread.h" />
<ClCompile Include="src\thread.c">
<Filter>Source Files</Filter>
</ClCompile>
+ <ClCompile Include="src\debug.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="include\slunkcrypt.h">
<ClInclude Include="src\initialize.h">
<Filter>Header Files</Filter>
</ClInclude>
+ <ClInclude Include="src\debug.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
</ItemGroup>
</Project>
\ No newline at end of file
--- /dev/null
+/******************************************************************************/
+/* SlunkCrypt, by LoRd_MuldeR <MuldeR2@GMX.de> */
+/* This work has been released under the CC0 1.0 Universal license! */
+/******************************************************************************/
+
+/* Internal */
+#include "debug.h"
+
+#if defined(_WIN32)
+# define WIN32_LEAN_AND_MEAN 1
+# include <Windows.h>
+#elif defined(__linux__) || defined(__FreeBSD__) || defined(__DragonFly__) || defined(__NetBSD__) || defined(__OpenBSD__)
+# include <syslog.h>
+#endif
+
+void slunkcrypt_debug_print(const char* const message)
+{
+#if defined(_WIN32)
+ OutputDebugStringA(message);
+#elif defined(__linux__) || defined(__FreeBSD__) || defined(__DragonFly__) || defined(__NetBSD__) || defined(__OpenBSD__)
+ syslog(LOG_DEBUG, "%s", message);
+#endif
+}
--- /dev/null
+/******************************************************************************/
+/* SlunkCrypt, by LoRd_MuldeR <MuldeR2@GMX.de> */
+/* This work has been released under the CC0 1.0 Universal license! */
+/******************************************************************************/
+
+#ifndef INC_SLUNKCRYPT_DEBUG_H
+#define INC_SLUNKCRYPT_DEBUG_H
+
+void slunkcrypt_debug_print(const char *const message);
+
+#endif
/* This work has been released under the CC0 1.0 Universal license! */
/******************************************************************************/
+#ifdef _WIN32
+# define _CRT_SECURE_NO_WARNINGS 1
+#else
+# define _GNU_SOURCE 1
+#endif
+
/* Internal */
#include "slunkcrypt.h"
+#include "debug.h"
#include "compiler.h"
#include "keygen.h"
#include "initialize.h"
/* CRT */
#include <string.h>
+#include <stdio.h>
#include <limits.h>
/* Version */
typedef struct
{
int legacy_compat;
+ int debug_logging;
thrdpl_t *thread_pool;
crypt_data_t data;
}
// Initialization
// ==========================================================================
-static int initialize_state(crypt_data_t *const data, const size_t thread_count, const uint64_t nonce, const uint8_t *const passwd, const size_t passwd_len, const int mode, const int legacy)
+static int initialize_state(crypt_data_t *const data, const size_t thread_count, const uint64_t nonce, const uint8_t *const passwd, const size_t passwd_len, const int mode, const int legacy, const int debug)
{
uint8_t temp[256U][256U];
size_t r, i;
CHECK_ABORTED();
}
+ /* dump final wheel configuration */
+ if (debug)
+ {
+ char message[772U];
+ for (r = 0U; r < 256U; ++r)
+ {
+ size_t off = sprintf(message, "%02X:", (unsigned)r);
+ for (i = 0U; i < 256U; ++i)
+ {
+ off += sprintf(message + off, ",%02X", data->wheel[r][i]);
+ }
+ message[3U] = '\x20';
+ slunkcrypt_debug_print(message);
+ }
+ }
+
/* initialize thread state */
data->thread_data[0].reverse_mode = reverse_mode;
data->thread_data[0].wheel = (const uint8_t(*)[256]) data->wheel;
slunkcrypt_t slunkcrypt_alloc(const uint64_t nonce, const uint8_t *const passwd, const size_t passwd_len, const int mode)
{
- const slunkparam_t param = { SLUNKCRYPT_PARAM_VERSION, 0U, SLUNKCRYPT_TRUE };
+ const slunkparam_t param = { SLUNKCRYPT_PARAM_VERSION, 0U, SLUNKCRYPT_TRUE, SLUNKCRYPT_FALSE };
return slunkcrypt_alloc_ext(nonce, passwd, passwd_len, mode, ¶m);
}
}
}
- state->legacy_compat = (param->version > 1U) ? BOOLIFY(param->legacy_compat) : SLUNKCRYPT_TRUE;
+ state->legacy_compat = (param->version > 1U) ? BOOLIFY(param->legacy_compat) : SLUNKCRYPT_FALSE;
+ state->debug_logging = (param->version > 1U) ? BOOLIFY(param->debug_logging) : SLUNKCRYPT_FALSE;
- if (initialize_state(&state->data, THREAD_COUNT(state), nonce, passwd, passwd_len, mode, state->legacy_compat) == SLUNKCRYPT_SUCCESS)
+ if (initialize_state(&state->data, THREAD_COUNT(state), nonce, passwd, passwd_len, mode, state->legacy_compat, state->debug_logging) == SLUNKCRYPT_SUCCESS)
{
return (slunkcrypt_t)state;
}
return SLUNKCRYPT_FAILURE;
}
- if ((result = initialize_state(&state->data, THREAD_COUNT(state), nonce, passwd, passwd_len, mode, state->legacy_compat)) != SLUNKCRYPT_SUCCESS)
+ if ((result = initialize_state(&state->data, THREAD_COUNT(state), nonce, passwd, passwd_len, mode, state->legacy_compat, state->debug_logging)) != SLUNKCRYPT_SUCCESS)
{
slunkcrypt_bzero(&state->data, sizeof(crypt_data_t));
}