CPU ?= 0
MARCH ?= 0
MTUNE ?= 0
+THREAD ?= 1
# ---------------------------------------------------------------------------
# Directories
ifneq ($(CPU),0)
CFLAGS += -m$(firstword $(CPU))
endif
+ifneq ($(TARGET),)
+ CFLAGS += --target=$(firstword $(TARGET))
+ LDFLGS += --target=$(firstword $(TARGET))
+endif
+
ifneq ($(MARCH),0)
CFLAGS += -march=$(firstword $(MARCH))
endif
LDFLGS += -mconsole -municode
endif
+ifeq ($(THREAD),0)
+ CFLAGS += -DSLUNKBUILD_NOTHREADS
+endif
+
# ---------------------------------------------------------------------------
# File names
# ---------------------------------------------------------------------------
* **Microsoft Windows** (Windows XP SP-3, or later) — 32-Bit (i686) and 64-Bit (AMD64)
* **Linux** (kernel version 3.17, or later) — 32-Bit (i686) and 64-Bit (AMD64)
-* **Various BSD flavors** (tested on FreeBSD 13 and OpenBSD 7) — 32-Bit (i686) and 64-Bit (AMD64)
-* **Oracle Solaris** (tested on version 11.4) — 32-Bit (i686) and 64-Bit (AMD64)
+* **Various BSD flavors** (tested on NetBSD 9.2, FreeBSD 13.0 and OpenBSD 7.0) — 32-Bit (i686) and 64-Bit (AMD64)
+* **Solaris** (tested on Solaris 11.4 and OmniOS/illumos) — 32-Bit (i686) and 64-Bit (AMD64)
+* **Mac OS X** (tested on macOS 11 “Big Sur”) — Intel x86-64 (AMD64) and Apple Silicon (AArch64)
The SlunkCrypt GUI application currently runs on the following platforms:
* `length`
The length of the plaintext chunk contained in the *input* buffer given by the `input` parameter, in bytes. At the same time, this determines the minimum required size of the *output* buffer given by the `output` parameters, in bytes.
+ *Note:* It is recommended to process chunks of at least ∼64 KB each, in order to take full advantage of multi-threading.
+
***Return value:***
* If successful, `true` is returned; otherwise `false` is returned.
* `length`
The length of the plaintext chunk initially contained in the input/output buffer given by the `buffer` parameter, in bytes. At the same time, this determines the portion of the input/output buffer that will be overwritten with encrypted data, in bytes.
+ *Note:* It is recommended to process chunks of at least ∼64 KB each, in order to take full advantage of multi-threading.
+
***Return value:***
* If successful, `true` is returned; otherwise `false` is returned.
* `length`
The length of the ciphertext chunk contained in the *input* buffer given by the `input` parameter, in bytes. At the same time, this determines the minimum required size of the *output* buffer given by the `output` parameters, in bytes.
+ *Note:* It is recommended to process chunks of at least ∼64 KB each, in order to take full advantage of multi-threading.
+
***Return value:***
* If successful, `true` is returned; otherwise `false` is returned.
* `length`
The length of the ciphertext chunk initially contained in the input/output buffer given by the `buffer` parameter, in bytes. At the same time, this determines the portion of the input/output buffer that will be overwritten with decrypted data, in bytes.
+ *Note:* It is recommended to process chunks of at least ∼64 KB each, in order to take full advantage of multi-threading.
+
***Return value:***
* If successful, `true` is returned; otherwise `false` is returned.
* `length`
The length of the given plaintext chunk (*encryption* mode), or the length of the given ciphertext chunk (*decryption* mode) in the `input` buffer, in bytes. At the same time, this parameter determines the minimum required size of the `output` buffer, in bytes. If this parameter is set to *zero*, the function does nothing; this is *not* considered an error.
+ *Note:* It is recommended to process chunks of at least ∼64 KB each, in order to take full advantage of multi-threading.
+
***Return value:***
* If successful, `SLUNKCRYPT_SUCCESS` is returned; otherwise `SLUNKCRYPT_FAILURE` or `SLUNKCRYPT_ABORTED` is returned.
* `length`
The length of the plaintext chunk (*encryption* mode), or the length of the ciphertext chunk (*decryption* mode) initially contained in the input/output buffer, in bytes.
+ *Note:* It is recommended to process chunks of at least ∼64 KB each, in order to take full advantage of multi-threading.
+
***Return value:***
* If successful, `SLUNKCRYPT_SUCCESS` is returned; otherwise `SLUNKCRYPT_FAILURE` or `SLUNKCRYPT_ABORTED` is returned.
--- /dev/null
+#!/bin/bash
+cd -- "$(dirname -- "${BASH_SOURCE[0]}")"
+
+rm -rf "enc" "out"
+mkdir -p "bin" "org" "enc" "out"
+
+readonly PASSWD="T25na1i{XYuUMFDi2fRqk258"
+
+for file in org/*; do
+ name="$(basename -- "$file")"
+
+ # Encrypt -A-
+ echo -e "\n\033[1;36m---===[ ${name} ]===---\033[0m\n"
+ if ! ${BASH} -x -c "bin/slunkcrypt-a -e \"pass:${PASSWD}\" \"${file}\" \"enc/${name}~~A\""; then
+ echo -e "\n\033[1;31mError: File could not be encoded !!!\033[0m"
+ exit 1
+ fi
+
+ # Encrypt -B-
+ if ! ${BASH} -x -c "bin/slunkcrypt-b -e \"pass:${PASSWD}\" \"${file}\" \"enc/${name}~~B\""; then
+ echo -e "\n\033[1;31mError: File could not be encoded !!!\033[0m"
+ exit 1
+ fi
+
+ # Print hash
+ sha256sum "enc/${name}~~A" "enc/${name}~~B" && echo ""
+
+ # Decrypt -A/B-
+ if ! ${BASH} -x -c "bin/slunkcrypt-a -d \"pass:${PASSWD}\" \"enc/${name}~~B\" \"out/${name}~~A\""; then
+ echo -e "\n\033[1;31mError: File could not be decoded !!!\033[0m"
+ exit 1
+ fi
+ if ! cmp "out/${name}~~A" "${file}"; then
+ echo -e "\n\033[1;31mError: Decoded file does *not* match original !!!\033[0m"
+ exit 1
+ fi
+
+ # Decrypt -B/A-
+ if ! ${BASH} -x -c "bin/slunkcrypt-b -d \"pass:${PASSWD}\" \"enc/${name}~~A\" \"out/${name}~~B\""; then
+ echo -e "\n\033[1;31mError: File could not be decoded !!!\033[0m"
+ exit
+ fi
+ if ! cmp "out/${name}~~A" "out/${name}~~B"; then
+ echo -e "\n\033[1;31mError: Decoded files are *not* the same !!!\033[0m"
+ exit 1
+ fi
+
+ # Print hash
+ sha256sum "out/${name}~~A" "out/${name}~~B" && echo ""
+done
+
+echo -e "\n\033[1;32mAll tests have completed successfully!\033[0m"
/* This work has been released under the CC0 1.0 Universal license! */
/******************************************************************************/
+#ifndef SLUNKBUILD_NOTHREADS
+
#ifdef _WIN32
# define _CRT_SECURE_NO_WARNINGS 1
#else
free(thrdpl);
}
+
+#endif /*SLUNKBUILD_NOTHREADS*/
#include <stdlib.h>
#include <stdint.h>
-#define MAX_THREADS 32U
-
-typedef void (*thrdpl_worker_t)(const size_t thread_count, void *const context, uint8_t *const buffer, const size_t length);
typedef struct thrdpl_data_t thrdpl_t;
+typedef void(*thrdpl_worker_t)(const size_t thread_count, void *const context, uint8_t *const buffer, const size_t length);
+
+#ifndef SLUNKBUILD_NOTHREADS
+
+#define MAX_THREADS 32U
thrdpl_t *slunkcrypt_thrdpl_create(const size_t count, const thrdpl_worker_t worker);
size_t slunkcrypt_thrdpl_count(const thrdpl_t *const thrdpl);
void slunkcrypt_thrdpl_exec(thrdpl_t *const thrdpl, uint8_t *const buffer, const size_t length);
void slunkcrypt_thrdpl_destroy(thrdpl_t *const thrdpl);
+#else
+
+#define MAX_THREADS 1U
+
+#define slunkcrypt_thrdpl_create(X,Y) NULL
+#define slunkcrypt_thrdpl_count(X) 0U
+#define slunkcrypt_thrdpl_init(X,Y,Z) do { abort(); } while(0)
+#define slunkcrypt_thrdpl_exec(X,Y,Z) do { abort(); } while(0)
+#define slunkcrypt_thrdpl_destroy(X) do { abort(); } while(0)
+
+#endif
#endif