Compare commits
50 Commits
Author | SHA1 | Date |
---|---|---|
LoRd_MuldeR | 79d66e4484 | |
LoRd_MuldeR | 25a5a92b47 | |
LoRd_MuldeR | 65fa799725 | |
LoRd_MuldeR | 509924c84c | |
LoRd_MuldeR | e9e02040df | |
LoRd_MuldeR | 8f9e501574 | |
LoRd_MuldeR | 99c5a56a4f | |
LoRd_MuldeR | 5759a0cd83 | |
LoRd_MuldeR | 7fee4f9bf3 | |
LoRd_MuldeR | 2ff7ed8262 | |
LoRd_MuldeR | 1f42113b88 | |
LoRd_MuldeR | df235ca050 | |
LoRd_MuldeR | 7996869e3c | |
LoRd_MuldeR | b00f31bd72 | |
LoRd_MuldeR | 393120ac58 | |
LoRd_MuldeR | 57e3b0be9c | |
LoRd_MuldeR | 3fd5167809 | |
LoRd_MuldeR | 6f46d5ca20 | |
LoRd_MuldeR | 5e0eb301db | |
LoRd_MuldeR | b0a5838a4a | |
LoRd_MuldeR | 9ede99400b | |
LoRd_MuldeR | 097957f9ab | |
LoRd_MuldeR | f1dfff978b | |
LoRd_MuldeR | 73b7131b87 | |
LoRd_MuldeR | b5b6e3eaf0 | |
LoRd_MuldeR | b654c89dbf | |
LoRd_MuldeR | b0cd820fdf | |
LoRd_MuldeR | f3dc0757ab | |
LoRd_MuldeR | 38cf7c3c25 | |
LoRd_MuldeR | 147d762ebc | |
LoRd_MuldeR | e4c3343d0c | |
LoRd_MuldeR | 270430b9d8 | |
LoRd_MuldeR | 968a5f7032 | |
LoRd_MuldeR | 3fcaa5f40c | |
LoRd_MuldeR | e4d9fc9162 | |
LoRd_MuldeR | d988fd0a56 | |
LoRd_MuldeR | c4b869981f | |
LoRd_MuldeR | 4383c5f858 | |
LoRd_MuldeR | cc4b9c8af3 | |
LoRd_MuldeR | 0c91cac7e4 | |
LoRd_MuldeR | f665d1cf2a | |
LoRd_MuldeR | 5e7b6ebb09 | |
LoRd_MuldeR | ae340c4070 | |
LoRd_MuldeR | 17018e4f86 | |
LoRd_MuldeR | f6cd289725 | |
LoRd_MuldeR | 3901bd6a1d | |
LoRd_MuldeR | f18a84b6c9 | |
LoRd_MuldeR | fc2784b256 | |
LoRd_MuldeR | 207039f4f7 | |
LoRd_MuldeR | 69e549aafd |
76
Makefile
76
Makefile
|
@ -10,10 +10,10 @@ FLTO ?= 0
|
|||
FPGO ?= 0
|
||||
STRIP ?= 0
|
||||
CPU ?= 0
|
||||
MARCH ?= 0
|
||||
MTUNE ?= 0
|
||||
THREAD ?= 1
|
||||
|
||||
$(info Options: DEBUG=$(DEBUG), NALYZE=$(NALYZE), ASAN=$(ASAN), STATIC=$(STATIC), FLTO=$(FLTO), FPGO=$(FPGO), STRIP=$(STRIP), CPU=$(CPU), THREAD=$(THREAD))
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Directories
|
||||
# ---------------------------------------------------------------------------
|
||||
|
@ -25,73 +25,82 @@ SUBDIR_LIB := libslunkcrypt
|
|||
# Flags
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
CONFIG =
|
||||
LDFLGS = -lpthread
|
||||
CFLAGS = -I$(SUBDIR_LIB)/include -std=gnu99 -Wall
|
||||
CFLAGS = -I$(SUBDIR_LIB)/include -std=gnu99 -Wall -pedantic
|
||||
|
||||
ifneq ($(CPU),0)
|
||||
ifneq (,$(firstword $(filter 32 64,$(CPU))))
|
||||
CFLAGS += -m$(firstword $(CPU))
|
||||
endif
|
||||
ifneq ($(TARGET),)
|
||||
ifneq (,$(firstword $(TARGET)))
|
||||
CFLAGS += --target=$(firstword $(TARGET))
|
||||
LDFLGS += --target=$(firstword $(TARGET))
|
||||
endif
|
||||
|
||||
ifneq ($(MARCH),0)
|
||||
ifneq (,$(firstword $(MARCH)))
|
||||
CFLAGS += -march=$(firstword $(MARCH))
|
||||
endif
|
||||
ifneq ($(MTUNE),0)
|
||||
ifneq (,$(firstword $(MTUNE)))
|
||||
CFLAGS += -mtune=$(firstword $(MTUNE))
|
||||
endif
|
||||
|
||||
ifneq ($(ASAN),0)
|
||||
CONFIG := _a
|
||||
CFLAGS += -O1 -g -fsanitize=address -fno-omit-frame-pointer -fno-optimize-sibling-calls
|
||||
else ifneq ($(DEBUG),0)
|
||||
CONFIG := _g
|
||||
CFLAGS += -Og -g
|
||||
else
|
||||
CFLAGS += -O3 -DNDEBUG
|
||||
ifneq ($(FLTO),0)
|
||||
CFLAGS += -flto
|
||||
endif
|
||||
ifneq ($(FPGO),0)
|
||||
CFLAGS += -fprofile-$(firstword $(FPGO))
|
||||
endif
|
||||
ifneq ($(DEBUG),0)
|
||||
CONFIG := _g
|
||||
CFLAGS += -Og -g
|
||||
else
|
||||
CFLAGS += -O3 -DNDEBUG
|
||||
ifneq ($(FLTO),0)
|
||||
CFLAGS += -flto
|
||||
endif
|
||||
ifneq ($(FPGO),0)
|
||||
CFLAGS += -fprofile-$(firstword $(FPGO))
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
ifneq ($(NALYZE),0)
|
||||
CFLAGS += -fanalyzer
|
||||
endif
|
||||
|
||||
MACHINE := $(shell $(CC) -dumpmachine || echo unknown)
|
||||
|
||||
ifeq ($(MACHINE),$(filter %mingw32 %-windows-gnu %-cygwin %-cygnus,$(MACHINE)))
|
||||
SUFFIX := .exe
|
||||
MACHINE := $(strip $(shell $(CC) -dumpmachine))
|
||||
ifeq (,$(MACHINE))
|
||||
$(error Failed to determine target machine, please check CC is working!)
|
||||
else
|
||||
SUFFIX :=
|
||||
$(info Target machine type: $(MACHINE))
|
||||
endif
|
||||
|
||||
ifeq ($(THREAD),0)
|
||||
CFLAGS += -DSLUNKBUILD_NOTHREADS
|
||||
ifneq (,$(firstword $(filter %mingw32 %-windows-gnu %-cygwin %-cygnus,$(MACHINE))))
|
||||
EXE_SUFFIX := .exe
|
||||
endif
|
||||
|
||||
ifneq ($(STRIP),0)
|
||||
LDFLGS += -s
|
||||
ifneq (,$(firstword $(filter %-w64-mingw32 %w64-windows-gnu,$(MACHINE))))
|
||||
LDFLGS += -mconsole -municode
|
||||
endif
|
||||
|
||||
ifeq ($(STATIC),1)
|
||||
LDFLGS += -static
|
||||
endif
|
||||
|
||||
ifeq ($(MACHINE),$(filter %-w64-mingw32 %w64-windows-gnu,$(MACHINE)))
|
||||
LDFLGS += -mconsole -municode
|
||||
ifneq ($(STRIP),0)
|
||||
LDFLGS += -s
|
||||
endif
|
||||
|
||||
ifeq ($(THREAD),1)
|
||||
LDFLGS += -lpthread
|
||||
else
|
||||
CFLAGS += -DSLUNKBUILD_NOTHREADS
|
||||
endif
|
||||
|
||||
ifneq (,$(firstword $(filter %-pc-haiku %-unknown-haiku,$(MACHINE))))
|
||||
LDFLGS += -lbsd
|
||||
endif
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# File names
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
OUTNAME_APP := slunkcrypt$(CONFIG)$(SUFFIX)
|
||||
OUTNAME_APP := slunkcrypt$(CONFIG)$(EXE_SUFFIX)
|
||||
OUTNAME_LIB := libslunkcrypt$(CONFIG)-1.a
|
||||
|
||||
OUTPATH_APP := $(SUBDIR_APP)/bin/$(OUTNAME_APP)
|
||||
|
@ -137,6 +146,5 @@ $(SUBDIR_LIB)/obj/%$(CONFIG).o: $(SUBDIR_LIB)/src/%.c
|
|||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
clean:
|
||||
$(RM) $(SUBDIR_APP)/obj/*.o $(SUBDIR_APP)/obj/*.gcda $(SUBDIR_APP)/lib/*.a $(SUBDIR_APP)/bin/*$(SUFFIX)
|
||||
$(RM) $(SUBDIR_LIB)/obj/*.o $(SUBDIR_LIB)/obj/*.gcda $(SUBDIR_LIB)/lib/*.a $(SUBDIR_LIB)/bin/*$(SUFFIX)
|
||||
|
||||
$(RM) $(SUBDIR_APP)/obj/*.o $(SUBDIR_APP)/obj/*.gcda $(SUBDIR_APP)/lib/*.a $(SUBDIR_APP)/bin/*$(EXE_SUFFIX)
|
||||
$(RM) $(SUBDIR_LIB)/obj/*.o $(SUBDIR_LIB)/obj/*.gcda $(SUBDIR_LIB)/lib/*.a $(SUBDIR_LIB)/bin/*$(EXE_SUFFIX)
|
||||
|
|
125
README.md
125
README.md
|
@ -1,5 +1,5 @@
|
|||
---
|
||||
title: "![SlunkCrypt](etc/img/SlunkCrypt-Logo.png)"
|
||||
title: "![SlunkCrypt – pure chicken-flavored encryption 🐔](etc/img/SlunkCrypt-Logo.png)"
|
||||
---
|
||||
|
||||
|
||||
|
@ -22,16 +22,17 @@ System Requirements
|
|||
|
||||
The SlunkCrypt library and the command-line application currently run on the following platforms:
|
||||
|
||||
* **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 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)
|
||||
* **GNU/Hurd** (tested on Debian GNU/Hurd 0.9) — 32-Bit (i686)
|
||||
* **Mac OS X** (tested on macOS 11 “Big Sur”) — Intel x86-64 (AMD64) and Apple Silicon (AArch64)
|
||||
* **Microsoft Windows** (Windows XP SP-3, or later) — i686, x86-64 and ARM64
|
||||
* **Linux** (kernel version 3.17, or later) — i686, x86-64, ARM64 and MIPS
|
||||
* **Various BSD flavors** (tested on NetBSD 9.2, FreeBSD 13.0 and OpenBSD 7.0) — i686 and x86-64
|
||||
* **Solaris** (tested on Solaris 11.4 and OmniOS/illumos) — i686 and x86-64
|
||||
* **GNU/Hurd** (tested on Debian GNU/Hurd 0.9) — i686
|
||||
* **Haiku** (tested on Haiku R1/b3) — i686 and x86-64
|
||||
* **Mac OS X** (tested on “Big Sur”) — x86-64 and ARM64
|
||||
|
||||
The SlunkCrypt GUI application currently runs on the following platforms:
|
||||
|
||||
* **Microsoft Windows** with .NET Framework 4.5 — can be installed on Windows Vista, or later
|
||||
* **Microsoft Windows** with .NET Framework 4.7.2 — can be installed on Windows 7 SP1, or later
|
||||
|
||||
|
||||
GUI Usage
|
||||
|
@ -44,10 +45,10 @@ This is how the graphical user interface (GUI) for SlunkCrypt looks on [Windows
|
|||
Prerequisites
|
||||
-------------
|
||||
|
||||
Please be sure to install the **.NET Framework 4.5**, or any later *.NET Framework 4.x* version, before running the SlunkCrypt GUI application:
|
||||
Please be sure to install the **.NET Framework 4.7.2**, or any later *.NET Framework 4.x* version, before running the SlunkCrypt **Windows GUI** application:
|
||||
<https://dotnet.microsoft.com/download/dotnet-framework>
|
||||
|
||||
***Note:*** If you are running Windows 8 or later, then almost certainly a suitable version of the .NET Framework is already installed 😎
|
||||
***Note:*** If you are running Windows 8.1 or later, then almost certainly a suitable version of the .NET Framework is already installed 😎
|
||||
|
||||
Settings
|
||||
--------
|
||||
|
@ -131,6 +132,12 @@ The following environment variables may be used:
|
|||
- **`SLUNK_THREADS`**:
|
||||
Specifies the number of worker threads to use. By default, SlunkCrypt detects the number of available processors and creates one thread for each processor.
|
||||
|
||||
- **`SLUNK_LEGACY_COMPAT`**:
|
||||
If set to a *non-zero* value, enables "legacy" compatibility-mode, required to decrypt files encrypted with SlunkCrypt version 1.2.x or older.
|
||||
|
||||
- **`SLUNK_DEBUG_LOGGING`**:
|
||||
If set to a *non-zero* value, enables additional logging output to the syslog (Unix-like) or to the debugger (Windows). This is intended for debugging purposes only!
|
||||
|
||||
Examples
|
||||
--------
|
||||
|
||||
|
@ -194,7 +201,14 @@ Here are some examples on how to use the SlunkCrypt command-line application:
|
|||
Encryption algorithm
|
||||
====================
|
||||
|
||||
The SlunkCrypt algorithm is based on core concepts of the well-known [**Enigma**](https://en.wikipedia.org/wiki/Enigma_machine) machine but with numerous improvements, largely inspired by R. Anderson's [***“A Modern Rotor Machine”***](https://rdcu.be/cBo8y):
|
||||
SlunkCrypt is based on concepts of the well-known [**Enigma**](https://en.wikipedia.org/wiki/Enigma_machine) machine, but with significant improvements, largely inspired by [***Ross Anderson – “A Modern Rotor Machine”***](https://rdcu.be/cBo8y).
|
||||
|
||||
A great explanation and visualization of how the *original* Enigma machine works can be found in [***this***](https://www.youtube.com/watch?v=ybkkiGtJmkM) video.
|
||||
|
||||
Overview
|
||||
--------
|
||||
|
||||
This section summarizes the improvements that have been implemented in SlunkCrypt:
|
||||
|
||||
- The original Enigma machine had only *three* (or, in some models, *four*) rotors, plus a static "reflector" wheel. In SlunkCrypt, we uses **256** simulated rotors for an improved security. Furthermore, the original Enigma machine supported only 26 distinct symbols, i.e. the letters `A` to `Z`. In SlunkCrypt, we use **256** distinct symbols, i.e. the byte values `0x00` to `0xFF`, which allows the encryption (and decryption) of arbitrary streams of bytes, rather than just plain text. Of course, SlunkCrypt can encrypt (and decrypt) text files as well.
|
||||
|
||||
|
@ -202,9 +216,22 @@ The SlunkCrypt algorithm is based on core concepts of the well-known [**Enigma**
|
|||
|
||||
- In the original Enigma machine, the rightmost rotor was moved, by one step, after every symbol. Meanwhile, all other rotors were moved, by one step, *only* when their right-hand neighbor had completed a full turn – much like the odometer in a car. The fact that most of the rotors remained in the same "static" position most of the time was an important weakness of the Enigma machine. Also, the sequence of the Enigma's rotor positions started to repeat after only 16,900 characters. SlunkCrypt employs an improved stepping algorithm, based on a ***linear-feedback shift register* (LSFR)**, ensuring that *all* rotors move frequently and in a "randomized" unpredictable pattern. The rotor positions of SlunkCrypt practically *never* repeat.
|
||||
|
||||
- The internal wiring of each of the original Enigma machine's rotors was *fixed*. Each rotor "type" came with a different internal wiring (i.e. permutation). Some models had up to eight rotor "types" to choose from, but only three or four rotors were used at a time. Nonetheless, the internal wiring (i.e. permutation) of each of the supplied rotors was **not** modifiable. This severely restricted the key space of the Enigma machine, as far as the rotors are concerned, because *only* the order of the rotors and the initial position of each rotor could be varied. In SlunkCrypt, a fully *randomized* wiring (i.e. permutation) is generated from the password for each of the 256 simulated rotors. The initial rotor positions are *randomized* as well.
|
||||
- The internal wiring of each of the original Enigma machine's rotors was *fixed*. Each rotor "type" came with a different internal wiring (i.e. permutation). Some models had up to eight rotor "types" to choose from, but only three or four rotors were used at a time. Nonetheless, the internal wiring (i.e. permutation) of each of the supplied rotors was **not** modifiable. This severely restricted the key space of the Enigma machine, as far as the rotors are concerned, because *only* the order of the rotors and the initial position of each rotor could be varied. In SlunkCrypt, a fully *randomized* wiring (i.e. permutation) is generated from the passphrase for each of the 256 simulated rotors. The initial rotor positions are *randomized* as well.
|
||||
|
||||
- SlunkCrypt does **not** currently implement the *plugboard* (“Steckerbrett”) of the original Enigma machine. That is because, even though the plugboard has a large key space, it is just a *fixed* substitution cipher that does *not* contribute much to the cryptographic strength of the Enigma machine. In fact, the plugboard could be "erased" by Welchman's [diagonal board](https://en.wikipedia.org/wiki/Bombe#Stecker_values).
|
||||
- SlunkCrypt does **not** currently implement the *plugboard* (“Steckerbrett”). Even though the plugboard significantly contributed to the key space of the original Engima machine, it was simply a *fixed* substitution cipher. SlunkCrypt already has a ***much*** bigger key space than that of the original Engine machine, because the number of rotors is substantially larger and because the internal wiring of these rotors is completely key-dependant. Therefore, adding a plugboard would *not* contribute notably to SlunkCrypt's cryptographic strength.
|
||||
|
||||
Details
|
||||
-------
|
||||
|
||||
This section explains some crucial implementation details of the SlunkCrypt library:
|
||||
|
||||
* **DRBG:** The *deterministic random bit generator* (DRBG) employed by SlunkCrypt is called [*Xorwow*](https://en.wikipedia.org/wiki/Xorshift#xorwow), an enhanced variant of *Xorshift* , i.e. a form of *linear-feedback shift registers (LSFR)*.
|
||||
|
||||
* **Initialization (key schedule):** In the initialization phase, the *pseudo-random* internal wiring (i.e. permutation) is generated – separately for each of the 256 rotors. For this purpose, the initial state of the DRBG is set up in a way that depends on the given *passphrase*, a message-specific *nonce* as well as the current *rotor index*. More specifically, the initial state of the DRBG is derived from a combination of all input parameters, by applying a <u>large</u> number of iterations of the *FNV‑1a 128-Bit* hash function. The permutation for the current rotor is then created by the ***Fisher‑Yates*** shuffle algorithm, using the DRBG as its randomness source. This produces a distinct "randomized" internal rotor wiring for each message to be encrypted.
|
||||
|
||||
* **Message processing:** During the encryption or decryption process, the individual offsets (positions) of the first 8 rotors are controlled by a 64-Bit counter, whereas the offsets of the remaining 248 rotors are continuously "randomized" by the DRBG. The initial counter value as well as the initial state of the DRBG are set up in a way that depends on the given *passphrase* and a message-specific *nonce*. Also, after each symbol that was processed, the counter is incremented by one and new *pseudo-random* offsets (rotor positions) are drawn.
|
||||
|
||||
* **Checksum:** The message-length is padded to a multiple of 8 bytes and a 64-Bit [BLAKE2s](https://www.blake2.net/) hash is appended, *before* encryption. This "checksum" can be used to detect decryption errors.
|
||||
|
||||
|
||||
Programming Interface (API)
|
||||
|
@ -287,7 +314,9 @@ Create and initialize a new **``Encryptor``** instance. Also generated a new, ra
|
|||
|
||||
Encryptor::Encryptor(
|
||||
const std::string &passwd,
|
||||
const size_t thread_count = 0U
|
||||
const size_t thread_count = 0U,
|
||||
const bool legacy_compat = false,
|
||||
const bool debug_logging = false
|
||||
);
|
||||
|
||||
***Parameters:***
|
||||
|
@ -300,6 +329,12 @@ Create and initialize a new **``Encryptor``** instance. Also generated a new, ra
|
|||
* `thread_count`
|
||||
Specifies the number of worker threads to use (optional). By default, SlunkCrypt detects the number of available processors and creates one thread for each processor.
|
||||
|
||||
* `legacy_compat`
|
||||
Enables "legacy" compatibility-mode; required to encrypt messages in a way that allows decryption with SlunkCrypt version 1.2.x or earlier. Option is disabled by default.
|
||||
|
||||
* `debug_logging`
|
||||
Enables additional debug logging. Messages are written to the syslog (Unix-like) or to the debugger (Windows). Option is disabled by default.
|
||||
|
||||
***Exceptions:***
|
||||
|
||||
* Throws `std::runtime_error`, if the nonce could not be generated, or if the SlunkCrypt context could not be allocated.
|
||||
|
@ -423,7 +458,9 @@ Create and initialize a new **``Decryptor``** instance.
|
|||
Decryptor::Decryptor(
|
||||
const std::string &passwd,
|
||||
const uint64_t nonce,
|
||||
const size_t thread_count = 0U
|
||||
const size_t thread_count = 0U,
|
||||
const bool legacy_compat = false,
|
||||
const bool debug_logging = false
|
||||
);
|
||||
|
||||
***Parameters:***
|
||||
|
@ -441,6 +478,12 @@ Create and initialize a new **``Decryptor``** instance.
|
|||
* `thread_count`
|
||||
Specifies the number of worker threads to use (optional). By default, SlunkCrypt detects the number of available processors and creates one thread for each processor.
|
||||
|
||||
* `legacy_compat`
|
||||
Enables "legacy" compatibility-mode; required to decrypt messages that were encrypted with SlunkCrypt version 1.2.x or earlier. Option is disabled by default.
|
||||
|
||||
* `debug_logging`
|
||||
Enables additional debug logging. Messages are written to the syslog (Unix-like) or to the debugger (Windows). Option is disabled by default.
|
||||
|
||||
***Exceptions:***
|
||||
|
||||
* Throws `std::runtime_error`, if the SlunkCrypt context could not be allocated.
|
||||
|
@ -800,7 +843,9 @@ Erase the contents of a byte array, by overwriting it with *zero* bytes. Compile
|
|||
The `slunkparam_t` struct is used to pass additional parameters that will be used for initializing the SlunkCrypt context. It contains the following fields:
|
||||
|
||||
* `version` – The version of the parameter struct; **must** be set to *`SLUNKCRYPT_PARAM_VERSION`*.
|
||||
* `thread_count` – The number of worker threads to use. If this parameter is set to **0**, which is the *default* value, then SlunkCrypt automatically detects the number of available (logical) processors and creates one thread for each processor. Also, the number of threads is capped to a maximum of `MAX_THREADS` (currently defined as **16**).
|
||||
* `thread_count` – The number of worker threads to use. If this parameter is set to **0**, which is the *default* value, then SlunkCrypt automatically detects the number of available (logical) processors and creates one thread for each processor. Also, the number of threads is capped to a maximum of `MAX_THREADS` (currently defined as **32**).
|
||||
* `legacy_compat` – If set to *`SLUNKCRYPT_TRUE`*, enables "legacy" compatibility-mode; required to decrypt messages that were encrypted with SlunkCrypt version 1.2.x or earlier.
|
||||
* `debug_logging` – If set to *`SLUNKCRYPT_TRUE`*, enables additional debug logging; messages are written to the syslog (Unix-like) or to the debugger (Windows).
|
||||
|
||||
### Global variables
|
||||
|
||||
|
@ -888,6 +933,54 @@ The latest SlunkCrypt source code is available from the official Git mirrors at:
|
|||
* <https://punkindrublic.mooo.com:3000/Muldersoft/SlunkCrypt>
|
||||
|
||||
|
||||
Build Instructions
|
||||
==================
|
||||
|
||||
SlunkCrypt can be built from the sources on Microsoft Windows or any POSIX-compatible platform, using a C-compiler that supports the C99 standard.
|
||||
|
||||
* **Microsoft Windows:**
|
||||
Project/solution files for [Visual Studio](https://visualstudio.microsoft.com/) are provided. These should work “out of the box” with Visual Studio 2017 or any later version.
|
||||
Just open the solution, select the “Release” configuration, choose the “x86” or “x64” platform, and finally press `F5`.
|
||||
Visual Studio also is the only way to build the SlunkCrypt GUI, which is based on Microsoft.NET and Windows Presentation Foundation (WPF).
|
||||
|
||||
Alternatively, SlunkCrypt can built using [Mingw-w64](https://www.mingw-w64.org/) (available via [MSYS2](https://www.msys2.org/)) or even [Cygwin](https://www.cygwin.com/) – see Linux instructions for details!
|
||||
|
||||
* **Linux:**
|
||||
Please make sure that the *C compiler* (GCC or Clang) as well as *Make* are installed. Then simply run **`make -B`** from the project's base directory!
|
||||
|
||||
If not already installed, the required build tools can usually be installed via your distribution's package manager.
|
||||
For example, on Debian-based distributions, the command **`sudo apt install build-essential`** installs all the required build tools at once.
|
||||
|
||||
In order to create a *fully-static* binary of SlunkCrypt that runs on ***any*** Linux distribution from the last decade, you can use [musl libc](https://musl.libc.org/):
|
||||
`make -B CC=musl-gcc STATIC=1`
|
||||
|
||||
* **BSD and Solaris:**
|
||||
SlunkCrypt can be built on various BSD flavors and Solaris, but the command **`gmake -B`** needs to be used here, since the native `make` doesn't work!
|
||||
GNU Make can be installed from the package manager. For example, use **`pkg install gmake`** on FreeBSD or **`pkg_add gmake`** on OpenBSD.
|
||||
|
||||
* **Mac OS X:**
|
||||
Once you have managed to find a terminal (or even better, connect via SSH), Mac OS X almost works like a proper operating system.
|
||||
The Xcode command-line tools can be installed with the command **`xcode-select --install`**, if not present yet. Then just type **`make -B`** to build!
|
||||
|
||||
*Hint:* If you want to build with GCC, which produces faster code than Apple's Xcode compiler, you may install it on Mac OS X via [Homebrew](https://formulae.brew.sh/formula/gcc).
|
||||
|
||||
|
||||
Frequently Asked Questions
|
||||
==========================
|
||||
|
||||
* **Why does the decryption of my file fail with a checksum error?**
|
||||
|
||||
If SlunkCrypt fails to decrypt a file and reports a “checksum mismatch” error, then this means that either the given file was *not* actually encrypted with SlunkCrypt, the file was corrupted in some kind of way (e.g. incomplete download), or you did *not* provide the correct passphrase for the file. There is, unfortuantely, *no* way to distinguish these three cases, as files encrypted with SlunkCrypt are indistingushable from random noise – only with the correct passphrase, some meaningful data can be restored from the encrypted file. Trying to decrypt the file with a *wrong* passphrase results in just "random" gibberish! However, the same also happens if the file was corrupted, or if the file was *not* encrypted with SlunkCrypt.
|
||||
|
||||
*Note:* If you are using SlunkCrypt 1.3.0 or later, then files that have been encrypted with SlunkCrypt 1.2.x or older can only be decrypted by enabling the “legacy” compatibility-mode!
|
||||
|
||||
* **How can I recover the lost passphrase for my file?**
|
||||
|
||||
SlunkCrypt uses a combination of the given passphrase and the individual nonce to encrypt each file in a *unique* (pseudo-random) way. This means that *no* two files are encrypted in the same way. Consequently, the decryption of the file is *only* possible using the correct passphrase, i.e. the one which was used to encrypt the file. Trying to decrypt the file with a *wrong* passphrase results in just "random" gibberish. And, for good reasons, there is *no* way to recover the passphrase from an encrypted file, so take good care of your passphrase!
|
||||
|
||||
In theory, it is possible to “crack” the passphrase using the *brute-force* method, i.e. try out every possible passphrase (up to a certain length) until the correct one is found. However, provided that a sufficiently long and random passphrase was chosen – which is highly recommended – there are *way* too many combinations to try them all, in a reasonable time. For example, with a length of 12 characters (ASCII), there are 95<sup>12</sup> = 540,360,087,662,636,962,890,625 possible combinations! This renders *brute-force* attacks practically impossible.
|
||||
|
||||
|
||||
License
|
||||
=======
|
||||
|
||||
|
|
26
Slunk.sln
26
Slunk.sln
|
@ -15,60 +15,86 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SlunkCryptGUI", "gui\SlunkC
|
|||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|ARM64 = Debug|ARM64
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
Release_DLL|ARM64 = Release_DLL|ARM64
|
||||
Release_DLL|x64 = Release_DLL|x64
|
||||
Release_DLL|x86 = Release_DLL|x86
|
||||
Release_SSE2|ARM64 = Release_SSE2|ARM64
|
||||
Release_SSE2|x64 = Release_SSE2|x64
|
||||
Release_SSE2|x86 = Release_SSE2|x86
|
||||
Release|ARM64 = Release|ARM64
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{86D28793-713E-4CEC-9686-335514AC5EF0}.Debug|ARM64.ActiveCfg = Debug|ARM64
|
||||
{86D28793-713E-4CEC-9686-335514AC5EF0}.Debug|ARM64.Build.0 = Debug|ARM64
|
||||
{86D28793-713E-4CEC-9686-335514AC5EF0}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{86D28793-713E-4CEC-9686-335514AC5EF0}.Debug|x64.Build.0 = Debug|x64
|
||||
{86D28793-713E-4CEC-9686-335514AC5EF0}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{86D28793-713E-4CEC-9686-335514AC5EF0}.Debug|x86.Build.0 = Debug|Win32
|
||||
{86D28793-713E-4CEC-9686-335514AC5EF0}.Release_DLL|ARM64.ActiveCfg = Release_DLL|ARM64
|
||||
{86D28793-713E-4CEC-9686-335514AC5EF0}.Release_DLL|ARM64.Build.0 = Release_DLL|ARM64
|
||||
{86D28793-713E-4CEC-9686-335514AC5EF0}.Release_DLL|x64.ActiveCfg = Release_DLL|x64
|
||||
{86D28793-713E-4CEC-9686-335514AC5EF0}.Release_DLL|x64.Build.0 = Release_DLL|x64
|
||||
{86D28793-713E-4CEC-9686-335514AC5EF0}.Release_DLL|x86.ActiveCfg = Release_DLL|Win32
|
||||
{86D28793-713E-4CEC-9686-335514AC5EF0}.Release_DLL|x86.Build.0 = Release_DLL|Win32
|
||||
{86D28793-713E-4CEC-9686-335514AC5EF0}.Release_SSE2|ARM64.ActiveCfg = Release_SSE2|ARM64
|
||||
{86D28793-713E-4CEC-9686-335514AC5EF0}.Release_SSE2|x64.ActiveCfg = Release_SSE2|x64
|
||||
{86D28793-713E-4CEC-9686-335514AC5EF0}.Release_SSE2|x64.Build.0 = Release_SSE2|x64
|
||||
{86D28793-713E-4CEC-9686-335514AC5EF0}.Release_SSE2|x86.ActiveCfg = Release_SSE2|Win32
|
||||
{86D28793-713E-4CEC-9686-335514AC5EF0}.Release_SSE2|x86.Build.0 = Release_SSE2|Win32
|
||||
{86D28793-713E-4CEC-9686-335514AC5EF0}.Release|ARM64.ActiveCfg = Release|ARM64
|
||||
{86D28793-713E-4CEC-9686-335514AC5EF0}.Release|ARM64.Build.0 = Release|ARM64
|
||||
{86D28793-713E-4CEC-9686-335514AC5EF0}.Release|x64.ActiveCfg = Release|x64
|
||||
{86D28793-713E-4CEC-9686-335514AC5EF0}.Release|x64.Build.0 = Release|x64
|
||||
{86D28793-713E-4CEC-9686-335514AC5EF0}.Release|x86.ActiveCfg = Release|Win32
|
||||
{86D28793-713E-4CEC-9686-335514AC5EF0}.Release|x86.Build.0 = Release|Win32
|
||||
{A4A3879C-BD2C-4304-AF66-7349CEF7E4C0}.Debug|ARM64.ActiveCfg = Debug|ARM64
|
||||
{A4A3879C-BD2C-4304-AF66-7349CEF7E4C0}.Debug|ARM64.Build.0 = Debug|ARM64
|
||||
{A4A3879C-BD2C-4304-AF66-7349CEF7E4C0}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{A4A3879C-BD2C-4304-AF66-7349CEF7E4C0}.Debug|x64.Build.0 = Debug|x64
|
||||
{A4A3879C-BD2C-4304-AF66-7349CEF7E4C0}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{A4A3879C-BD2C-4304-AF66-7349CEF7E4C0}.Debug|x86.Build.0 = Debug|Win32
|
||||
{A4A3879C-BD2C-4304-AF66-7349CEF7E4C0}.Release_DLL|ARM64.ActiveCfg = Release_DLL|ARM64
|
||||
{A4A3879C-BD2C-4304-AF66-7349CEF7E4C0}.Release_DLL|ARM64.Build.0 = Release_DLL|ARM64
|
||||
{A4A3879C-BD2C-4304-AF66-7349CEF7E4C0}.Release_DLL|x64.ActiveCfg = Release_DLL|x64
|
||||
{A4A3879C-BD2C-4304-AF66-7349CEF7E4C0}.Release_DLL|x64.Build.0 = Release_DLL|x64
|
||||
{A4A3879C-BD2C-4304-AF66-7349CEF7E4C0}.Release_DLL|x86.ActiveCfg = Release_DLL|Win32
|
||||
{A4A3879C-BD2C-4304-AF66-7349CEF7E4C0}.Release_DLL|x86.Build.0 = Release_DLL|Win32
|
||||
{A4A3879C-BD2C-4304-AF66-7349CEF7E4C0}.Release_SSE2|ARM64.ActiveCfg = Release_SSE2|ARM64
|
||||
{A4A3879C-BD2C-4304-AF66-7349CEF7E4C0}.Release_SSE2|x64.ActiveCfg = Release_SSE2|x64
|
||||
{A4A3879C-BD2C-4304-AF66-7349CEF7E4C0}.Release_SSE2|x64.Build.0 = Release_SSE2|x64
|
||||
{A4A3879C-BD2C-4304-AF66-7349CEF7E4C0}.Release_SSE2|x86.ActiveCfg = Release_SSE2|Win32
|
||||
{A4A3879C-BD2C-4304-AF66-7349CEF7E4C0}.Release_SSE2|x86.Build.0 = Release_SSE2|Win32
|
||||
{A4A3879C-BD2C-4304-AF66-7349CEF7E4C0}.Release|ARM64.ActiveCfg = Release|ARM64
|
||||
{A4A3879C-BD2C-4304-AF66-7349CEF7E4C0}.Release|ARM64.Build.0 = Release|ARM64
|
||||
{A4A3879C-BD2C-4304-AF66-7349CEF7E4C0}.Release|x64.ActiveCfg = Release|x64
|
||||
{A4A3879C-BD2C-4304-AF66-7349CEF7E4C0}.Release|x64.Build.0 = Release|x64
|
||||
{A4A3879C-BD2C-4304-AF66-7349CEF7E4C0}.Release|x86.ActiveCfg = Release|Win32
|
||||
{A4A3879C-BD2C-4304-AF66-7349CEF7E4C0}.Release|x86.Build.0 = Release|Win32
|
||||
{568F3936-B520-4371-981C-E7A4DA781737}.Debug|ARM64.ActiveCfg = Debug|Any CPU
|
||||
{568F3936-B520-4371-981C-E7A4DA781737}.Debug|ARM64.Build.0 = Debug|Any CPU
|
||||
{568F3936-B520-4371-981C-E7A4DA781737}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{568F3936-B520-4371-981C-E7A4DA781737}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{568F3936-B520-4371-981C-E7A4DA781737}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{568F3936-B520-4371-981C-E7A4DA781737}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{568F3936-B520-4371-981C-E7A4DA781737}.Release_DLL|ARM64.ActiveCfg = Release|Any CPU
|
||||
{568F3936-B520-4371-981C-E7A4DA781737}.Release_DLL|ARM64.Build.0 = Release|Any CPU
|
||||
{568F3936-B520-4371-981C-E7A4DA781737}.Release_DLL|x64.ActiveCfg = Release|Any CPU
|
||||
{568F3936-B520-4371-981C-E7A4DA781737}.Release_DLL|x64.Build.0 = Release|Any CPU
|
||||
{568F3936-B520-4371-981C-E7A4DA781737}.Release_DLL|x86.ActiveCfg = Release|Any CPU
|
||||
{568F3936-B520-4371-981C-E7A4DA781737}.Release_DLL|x86.Build.0 = Release|Any CPU
|
||||
{568F3936-B520-4371-981C-E7A4DA781737}.Release_SSE2|ARM64.ActiveCfg = Release|Any CPU
|
||||
{568F3936-B520-4371-981C-E7A4DA781737}.Release_SSE2|ARM64.Build.0 = Release|Any CPU
|
||||
{568F3936-B520-4371-981C-E7A4DA781737}.Release_SSE2|x64.ActiveCfg = Release|Any CPU
|
||||
{568F3936-B520-4371-981C-E7A4DA781737}.Release_SSE2|x64.Build.0 = Release|Any CPU
|
||||
{568F3936-B520-4371-981C-E7A4DA781737}.Release_SSE2|x86.ActiveCfg = Release|Any CPU
|
||||
{568F3936-B520-4371-981C-E7A4DA781737}.Release_SSE2|x86.Build.0 = Release|Any CPU
|
||||
{568F3936-B520-4371-981C-E7A4DA781737}.Release|ARM64.ActiveCfg = Release|Any CPU
|
||||
{568F3936-B520-4371-981C-E7A4DA781737}.Release|ARM64.Build.0 = Release|Any CPU
|
||||
{568F3936-B520-4371-981C-E7A4DA781737}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{568F3936-B520-4371-981C-E7A4DA781737}.Release|x64.Build.0 = Release|Any CPU
|
||||
{568F3936-B520-4371-981C-E7A4DA781737}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,81 @@
|
|||
#!/bin/bash
|
||||
cd -- "$(dirname -- "${BASH_SOURCE[0]}")"
|
||||
|
||||
if [ ! -x "bin/slunkcrypt-a" ]; then
|
||||
echo "Executbale file \"bin/slunkcrypt-a\" not found !!!"
|
||||
exit 1
|
||||
fi
|
||||
if [ ! -x "bin/slunkcrypt-b" ]; then
|
||||
echo "Executbale file \"bin/slunkcrypt-b\" not found !!!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
rm -rf "org" "enc" "out"
|
||||
mkdir -p "bin" "org" "enc" "out"
|
||||
|
||||
readonly PASSWD=("T25na1i{XYuUMFDi2fRqk258" "dq22Z.[[>C9zml#n)<e)vFkG")
|
||||
|
||||
# Generate input files
|
||||
echo -e "\n\033[1;36m---===[ generate input ]===---\033[0m\n"
|
||||
for i in 1 13 31 89 223 503 997 2477 5003 9973 24989 50021 99991 249989 500009 999983 134217757; do
|
||||
echo "Generating \"$(printf "%07X" ${i}).bin\" please wait..."
|
||||
dd if="/dev/urandom" of="org/$(printf "%07X" ${i}).bin" bs=1 count=${i}
|
||||
for j in {1..7}; do
|
||||
echo "Generating \"$(printf "%07X" $(($i + $j))).bin\" please wait..."
|
||||
cp -f "org/$(printf "%07X" ${i}).bin" "org/$(printf "%07X" $(($i + $j))).bin"
|
||||
dd oflag=append conv=notrunc if="/dev/urandom" of="org/$(printf "%07X" $(($i + $j))).bin" bs=1 count=${j}
|
||||
done
|
||||
done
|
||||
|
||||
for file in org/*; do
|
||||
name="$(basename -- "$file")"
|
||||
echo -e "\n\033[1;36m---===[ ${name} ]===---\033[0m\n"
|
||||
|
||||
# Encrypt -A-
|
||||
for i in {0..1}; do
|
||||
if ! ${BASH} -x -c "bin/slunkcrypt-a -e \"pass:${PASSWD[$i]}\" \"${file}\" \"enc/${name}~~A${i}\""; then
|
||||
echo -e "\n\033[1;31mError: File could not be encoded !!!\033[0m"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
# Encrypt -B-
|
||||
for i in {0..1}; do
|
||||
if ! ${BASH} -x -c "bin/slunkcrypt-b -e \"pass:${PASSWD[$i]}\" \"${file}\" \"enc/${name}~~B${i}\""; then
|
||||
echo -e "\n\033[1;31mError: File could not be encoded !!!\033[0m"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
# Print hash
|
||||
sha256sum "enc/${name}~~"* && echo ""
|
||||
|
||||
# Decrypt -A/B-
|
||||
for i in {0..1}; do
|
||||
if ! ${BASH} -x -c "bin/slunkcrypt-a -d \"pass:${PASSWD[$i]}\" \"enc/${name}~~B${i}\" \"out/${name}~~A${i}\""; then
|
||||
echo -e "\n\033[1;31mError: File could not be decoded !!!\033[0m"
|
||||
exit 1
|
||||
fi
|
||||
if ! cmp "out/${name}~~A${i}" "${file}"; then
|
||||
echo -e "\n\033[1;31mError: Decoded file does *not* match original !!!\033[0m"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
# Decrypt -B/A-
|
||||
for i in {0..1}; do
|
||||
if ! ${BASH} -x -c "bin/slunkcrypt-b -d \"pass:${PASSWD[$i]}\" \"enc/${name}~~A${i}\" \"out/${name}~~B${i}\""; then
|
||||
echo -e "\n\033[1;31mError: File could not be decoded !!!\033[0m"
|
||||
exit
|
||||
fi
|
||||
if ! cmp "out/${name}~~A${i}" "out/${name}~~B${i}"; then
|
||||
echo -e "\n\033[1;31mError: Decoded files are *not* the same !!!\033[0m"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
# Print hash
|
||||
sha256sum "out/${name}~~"* && echo ""
|
||||
done
|
||||
|
||||
echo -e "\n\033[1;32mAll tests have completed successfully!\033[0m"
|
|
@ -0,0 +1,59 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
if [ "$(find . -maxdepth 1 -type f -perm /111 -name 'slunkcrypt*' | sed -e 's/^[[:blank:]]*//;s/[[:blank:]]*$//' -e '/^$/d' | wc -l)" -lt 1 ]; then
|
||||
echo "No Slunkcrypt executable(s) found!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
function check_file() {
|
||||
local checksum="$(sha512sum "${1}" | grep -Eo '^[[:alnum:]]+' | tr 'A-Z' 'a-z' | head -n 1)"
|
||||
if [ "${checksum}" != "${2}" ]; then
|
||||
echo "Error: Checksum of file \"${1}\" does not match !!!"
|
||||
echo "-> Expected: ${2}"
|
||||
echo "-> Computed: ${checksum}"
|
||||
exit 1
|
||||
fi
|
||||
echo "Checksum of file \"${1}\" is correct."
|
||||
}
|
||||
|
||||
echo -e "\n------------------------------------------------------------------------------"
|
||||
echo "Clean up"
|
||||
echo -e "------------------------------------------------------------------------------\n"
|
||||
|
||||
rm -vf test-vectors.tar passphrase.txt sha512sums.txt
|
||||
rm -vf test-*.enc rm -vf restored-*.png
|
||||
|
||||
echo -e "\n------------------------------------------------------------------------------"
|
||||
echo "Download"
|
||||
echo -e "------------------------------------------------------------------------------\n"
|
||||
|
||||
curl -kLf -o "test-vectors.tar" "https://sourceforge.net/projects/muldersoft/files/SlunkCrypt/test-vectors.tar/download"
|
||||
printf "\n"
|
||||
|
||||
tar -xvf "test-vectors.tar"
|
||||
printf "\n"
|
||||
|
||||
check_file "test-v100-1.enc" "372358b8bd8f31834da449b456ef0d62ceeba95b3ac9e87d36f81ac0292be3da29cc7d1df55a72473dd08211bb5bab748f8c8b57f25b336d22862f2af2b4d3b2"
|
||||
check_file "test-v100-2.enc" "a0e97b8e0b78a2fde215eb7234cff253e4af5b9ae426aaebfa85ddc84a79b3fa6ad1d7fad3b792610a4dd824ec56535dfb00a7352228fcefd011bf024af37dad"
|
||||
check_file "test-v130-1.enc" "c13e6e001b08efba58909beed952957ea245a6f7fe52ad7022265f25f6f3a1c74423922f46cf171f2b23f948e4fde7004d83c89f95b62f825ff262cc7468bb48"
|
||||
check_file "test-v130-2.enc" "48fe6ce4b82fb1c132d987b95576b6856deb43031047f669434347d9ffb8bc79a636e59548ffa18bd8031fbaeb034cb972a147087f49a61bf53a6b740434f3c6"
|
||||
|
||||
while IFS= read -r name; do
|
||||
echo -e "\n------------------------------------------------------------------------------"
|
||||
echo "${name}"
|
||||
echo -e "------------------------------------------------------------------------------\n"
|
||||
|
||||
SLUNK_LEGACY_COMPAT=1 ./${name} -d 'pass:Q8YRL4_SFGt9m(>I,(h=fDaw' "test-v100-1.enc" "restored-v100-1.${name}.png"
|
||||
SLUNK_LEGACY_COMPAT=1 ./${name} -d 'pass:1$SfiHiQW*G|RbpR8trFR$sp' "test-v100-2.enc" "restored-v100-2.${name}.png"
|
||||
SLUNK_LEGACY_COMPAT=0 ./${name} -d 'pass:Q8YRL4_SFGt9m(>I,(h=fDaw' "test-v130-1.enc" "restored-v130-1.${name}.png"
|
||||
SLUNK_LEGACY_COMPAT=0 ./${name} -d 'pass:1$SfiHiQW*G|RbpR8trFR$sp' "test-v130-2.enc" "restored-v130-2.${name}.png"
|
||||
|
||||
for i in 100 130; do
|
||||
for j in {1..2}; do
|
||||
check_file "restored-v${i}-${j}.${name}.png" "658a566d279070546dcb385f0ae1f236058edfe246caaaa149b8de448b788616cf78f229af7e70c3a06a23b649540aa5f53927f9a959a957b9b8b0ddf25063b1"
|
||||
done
|
||||
done
|
||||
done < <(find . -maxdepth 1 -type f -perm /111 -name 'slunkcrypt*' -exec basename "{}" \; | sed -e 's/^[[:blank:]]*//;s/[[:blank:]]*$//' -e '/^$/d')
|
||||
|
||||
echo -e "\nEverything completed successfully.\n"
|
|
@ -1,52 +0,0 @@
|
|||
#!/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"
|
|
@ -0,0 +1,7 @@
|
|||
#!/bin/sh
|
||||
if [ -n "$1" ]; then CC="$1"; elif [ -z "$CC" ]; then CC="cc"; fi
|
||||
|
||||
echo "Built : `date -u +'%Y-%m-%d %H:%M:%S'`"
|
||||
echo "Platform : `uname -s -r -v -m`"
|
||||
echo "Target : `$CC -dumpmachine`"
|
||||
echo "Compiler : `$CC -v 2>&1 | grep -i '\(gcc\|clang\)[[:space:]]\{1,\}version' | head -n 1`"
|
|
@ -0,0 +1,21 @@
|
|||
#!/bin/sh
|
||||
set -e
|
||||
cd -- "$(dirname -- "${0}")/../../.."
|
||||
|
||||
if [ -z "${cc_path}" ]; then
|
||||
cc_path="/usr/local/bin/gcc12"
|
||||
fi
|
||||
|
||||
mk_slunk() {
|
||||
gmake -B CC="${cc_path}" CPU=${1} MARCH=${3} MTUNE=${4} STATIC=1 STRIP=1
|
||||
cp -vf "frontend/bin/slunkcrypt" "out/slunkcrypt-${2}"
|
||||
}
|
||||
|
||||
rm -rf "out" && mkdir -p "out"
|
||||
|
||||
gmake CC="${cc_path}" clean
|
||||
|
||||
mk_slunk 32 "i686" "pentiumpro" "pentium3"
|
||||
mk_slunk 64 "x86_64" "x86-64" "nocona"
|
||||
|
||||
echo "Build completed successfully."
|
|
@ -0,0 +1,26 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
cd -- "$(dirname -- "${BASH_SOURCE[0]}")/../../.."
|
||||
|
||||
mk_slunk() {
|
||||
make -B CC=${1} MARCH=${3} MTUNE=${4} STATIC=1 STRIP=1
|
||||
cp -vf "frontend/bin/slunkcrypt" "out/slunkcrypt-${2}"
|
||||
}
|
||||
|
||||
rm -rf "out" && mkdir -p "out"
|
||||
|
||||
make clean
|
||||
|
||||
case "${BE_HOST_CPU}" in
|
||||
x86_64)
|
||||
mk_slunk "gcc" "x86_64" "x86-64" "nocona"
|
||||
;;
|
||||
x86)
|
||||
mk_slunk "gcc-x86" "i686" "pentiumpro" "pentium3"
|
||||
;;
|
||||
*)
|
||||
echo "Unknown host CPU type !!!"
|
||||
exit 1
|
||||
esac
|
||||
|
||||
echo "Build completed successfully."
|
|
@ -1,19 +1,19 @@
|
|||
#!/bin/bash
|
||||
# sudo apt install crossbuild-essential-i386
|
||||
# sudo apt install crossbuild-essential-arm64
|
||||
# sudo apt install crossbuild-essential-{i386,armel,armhf,arm64,mipsel,mips64el}
|
||||
set -e
|
||||
cd -- "$(dirname -- "${BASH_SOURCE[0]}")"
|
||||
|
||||
function mk_musl() {
|
||||
local outdir="/usr/local/musl/${1}-linux-gnu"
|
||||
local outdir="/usr/local/musl/${1}"
|
||||
local build="musl-build-${1}"
|
||||
rm -rf "${build}" && mkdir -p "${build}"
|
||||
tar -xvf "musl-latest.tar.gz" --strip-components=1 -C "${build}"
|
||||
pushd "${build}"
|
||||
local optdirs="$(find './src' -mindepth 1 -maxdepth 1 -type d -printf '%f,' | sed 's/,$//g')"
|
||||
if [ -z "${2}" ]; then
|
||||
./configure --prefix="${outdir}"
|
||||
./configure --enable-optimize="${optdirs}" --disable-shared --prefix="${outdir}"
|
||||
else
|
||||
./configure --host="${2}" --prefix="${outdir}"
|
||||
./configure --enable-optimize="${optdirs}" --disable-shared --prefix="${outdir}" --host="${2}"
|
||||
fi
|
||||
make
|
||||
sudo rm -rf "${outdir}"
|
||||
|
@ -30,4 +30,8 @@ curl -vkf -o "musl-latest.tar.gz" "https://musl.libc.org/releases/musl-latest.ta
|
|||
|
||||
mk_musl x86_64
|
||||
mk_musl i686 i686-linux-gnu
|
||||
mk_musl aarch64 aarch64-linux-gnu
|
||||
mk_musl armel arm-linux-gnueabi
|
||||
mk_musl armhf arm-linux-gnueabihf
|
||||
mk_musl arm64 aarch64-linux-gnu
|
||||
mk_musl mipsel mipsel-linux-gnu
|
||||
mk_musl mips64el mips64el-linux-gnuabi64
|
|
@ -0,0 +1,28 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
cd -- "$(dirname -- "${BASH_SOURCE[0]}")/../../.."
|
||||
|
||||
function mk_slunk() {
|
||||
local command="make -B CC=${2}-gcc STRIP=1 FLTO=1"
|
||||
$BASH -x -c "${command}${3:+ ${3}}"
|
||||
cp -vf "frontend/bin/slunkcrypt" "out/slunkcrypt-${1}"
|
||||
}
|
||||
|
||||
if [[ "$OSTYPE" != "linux"* ]]; then
|
||||
echo "This script is supposed to run on the linux platform !!!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
rm -rf "out" && mkdir -p "out"
|
||||
|
||||
$BASH -x -c "make clean"
|
||||
|
||||
mk_slunk "x86_64" "x86_64-linux-gnu" "MARCH=x86-64 MTUNE=nocona"
|
||||
mk_slunk "i686" "i686-linux-gnu" "MARCH=pentiumpro MTUNE=pentium3"
|
||||
mk_slunk "armel" "arm-linux-gnueabi"
|
||||
mk_slunk "armhf" "arm-linux-gnueabihf"
|
||||
mk_slunk "arm64" "aarch64-linux-gnu"
|
||||
mk_slunk "mipsel" "mipsel-linux-gnu"
|
||||
mk_slunk "mips64el" "mips64el-linux-gnuabi64"
|
||||
|
||||
printf "\033[1;32m\nBuild completed successfully.\033[0m\n\n"
|
|
@ -0,0 +1,29 @@
|
|||
#!/bin/bash
|
||||
# See "etc/utils/linux/mk-musl.sh" in order to build musl libc!
|
||||
set -e
|
||||
cd -- "$(dirname -- "${BASH_SOURCE[0]}")/../../.."
|
||||
|
||||
function mk_slunk() {
|
||||
local command="make -B CC=/usr/local/musl/${1}/bin/musl-gcc STATIC=1 STRIP=1 FLTO=1"
|
||||
$BASH -x -c "${command}${2:+ ${2}}"
|
||||
cp -vf "frontend/bin/slunkcrypt" "out/slunkcrypt-${1}"
|
||||
}
|
||||
|
||||
if [[ "$OSTYPE" != "linux"* ]]; then
|
||||
echo "This script is supposed to run on the linux platform !!!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
rm -rf "out" && mkdir -p "out"
|
||||
|
||||
$BASH -x -c "make clean"
|
||||
|
||||
mk_slunk "x86_64" "MARCH=x86-64 MTUNE=nocona"
|
||||
mk_slunk "i686" "MARCH=pentiumpro MTUNE=pentium3"
|
||||
mk_slunk "armel"
|
||||
mk_slunk "armhf"
|
||||
mk_slunk "arm64"
|
||||
mk_slunk "mipsel"
|
||||
mk_slunk "mips64el"
|
||||
|
||||
printf "\033[1;32m\nBuild completed successfully.\033[0m\n\n"
|
|
@ -0,0 +1 @@
|
|||
sudo hdiutil create archive.dmg -ov -volname "SlunkCrypt" -fs HFS+ -srcfolder out
|
|
@ -0,0 +1,21 @@
|
|||
#!/bin/zsh
|
||||
set -e
|
||||
cd -- "$(dirname -- "${(%):-%N}")/../../.."
|
||||
|
||||
if [ -z "${cc_path}" ]; then
|
||||
cc_path="/usr/bin/cc"
|
||||
fi
|
||||
|
||||
mk_slunk() {
|
||||
make -B CC="${cc_path}" TARGET="${1}-apple-darwin" FLTO=1
|
||||
strip -o "out/slunkcrypt-${1}" "frontend/bin/slunkcrypt"
|
||||
}
|
||||
|
||||
rm -rf "out" && mkdir -p "out"
|
||||
|
||||
make CC="${cc_path}" clean
|
||||
|
||||
mk_slunk "x86_64"
|
||||
mk_slunk "arm64"
|
||||
|
||||
echo "Build completed successfully."
|
|
@ -0,0 +1,30 @@
|
|||
#!/bin/ksh
|
||||
set -e
|
||||
cd -- "$(dirname -- "${0}")/../../.."
|
||||
|
||||
if [ -z "${cc_path}" ]; then
|
||||
cc_path="/usr/local/bin/egcc"
|
||||
fi
|
||||
|
||||
mk_slunk() {
|
||||
gmake -B CC="${cc_path}" MARCH=${2} MTUNE=${3} STATIC=1 STRIP=1
|
||||
cp -vf "frontend/bin/slunkcrypt" "out/slunkcrypt-${1}"
|
||||
}
|
||||
|
||||
rm -rf "out" && mkdir -p "out"
|
||||
|
||||
gmake CC="${cc_path}" clean
|
||||
|
||||
case "$(uname -m)" in
|
||||
amd64)
|
||||
mk_slunk "x86_64" "x86-64" "nocona"
|
||||
;;
|
||||
i386)
|
||||
mk_slunk "i686" "pentiumpro" "pentium3"
|
||||
;;
|
||||
*)
|
||||
echo "Unknown host CPU type !!!"
|
||||
exit 1
|
||||
esac
|
||||
|
||||
echo "Build completed successfully."
|
|
@ -0,0 +1,21 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
cd -- "$(dirname -- "${BASH_SOURCE[0]}")/../../.."
|
||||
|
||||
if [ -z "${cc_path}" ]; then
|
||||
cc_path="/usr/gcc/11/bin/gcc"
|
||||
fi
|
||||
|
||||
mk_slunk() {
|
||||
gmake -B CC="${cc_path}" CPU=${1} MARCH=${3} MTUNE=${4} FLTO=1 STRIP=1
|
||||
cp -f "frontend/bin/slunkcrypt" "out/slunkcrypt-${2}"
|
||||
}
|
||||
|
||||
rm -rf "out" && mkdir -p "out"
|
||||
|
||||
gmake CC="${cc_path}" clean
|
||||
|
||||
mk_slunk 32 "i686" "pentiumpro" "pentium3"
|
||||
mk_slunk 64 "x86_64" "x86-64" "nocona"
|
||||
|
||||
echo "Build completed successfully."
|
|
@ -0,0 +1,9 @@
|
|||
@echo off
|
||||
cd /d "%~dp0..\..\.."
|
||||
|
||||
set "MSYS2_DIR=C:\msys64"
|
||||
|
||||
call "%MSYS2_DIR%\msys2_shell.cmd" -mingw32 -no-start -defterm -where "%CD%" -c "./etc/utils/win32/%~n0.sh"
|
||||
call "%MSYS2_DIR%\msys2_shell.cmd" -mingw64 -no-start -defterm -where "%CD%" -c "./etc/utils/win32/%~n0.sh"
|
||||
|
||||
pause
|
|
@ -0,0 +1,42 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
cd -- "$(dirname -- "${0}")/../../.."
|
||||
|
||||
if [ -z "${cc_path}" ]; then
|
||||
cc_path="cc"
|
||||
fi
|
||||
|
||||
readonly machine="$("${cc_path}" -dumpmachine)"
|
||||
|
||||
if [[ "${machine}" == *"-cygwin" ]]; then
|
||||
readonly use_flto=0
|
||||
else
|
||||
readonly use_flto=1
|
||||
fi
|
||||
|
||||
mk_slunk() {
|
||||
make -B CC="${cc_path}" MARCH=${2} MTUNE=${3} STATIC=1 STRIP=1 FLTO=${use_flto}
|
||||
cp -vf "frontend/bin/slunkcrypt" "out/_next_/slunkcrypt-${1}"
|
||||
}
|
||||
|
||||
mkdir -p "out/_next_"
|
||||
|
||||
make -B CC="${cc_path}" clean
|
||||
|
||||
case "${machine}" in
|
||||
x86_64*)
|
||||
mk_slunk "x86_64" "x86-64" "nocona"
|
||||
;;
|
||||
i686*)
|
||||
mk_slunk "i686" "pentiumpro" "pentium3"
|
||||
;;
|
||||
*)
|
||||
echo "Unknown target CPU type !!!"
|
||||
exit 1
|
||||
esac
|
||||
|
||||
if [[ "${machine}" == *"-cygwin" ]]; then
|
||||
cp -vfu "$(which cygwin1.dll)" "out/_next_"
|
||||
fi
|
||||
|
||||
echo "Build completed successfully."
|
|
@ -0,0 +1,6 @@
|
|||
@echo off
|
||||
cd /d "%~dp0"
|
||||
if exist "bin" rmdir /s /q "bin"
|
||||
mkdir "bin"
|
||||
"%NSIS3_HOME%\makensis.exe" /V4 /INPUTCHARSET UTF8 post-install-launcher.nsi
|
||||
pause
|
Binary file not shown.
After Width: | Height: | Size: 8.8 KiB |
|
@ -0,0 +1,70 @@
|
|||
!include FileFunc.nsh
|
||||
!include WinVer.nsh
|
||||
|
||||
Unicode true
|
||||
XPStyle on
|
||||
ManifestSupportedOS all
|
||||
RequestExecutionLevel user
|
||||
AutoCloseWindow true
|
||||
InstallColors FFD74A 000000
|
||||
ShowInstDetails show
|
||||
|
||||
OutFile "bin\post-install-launcher.exe"
|
||||
Icon "post-install-launcher.ico"
|
||||
ChangeUI all "${NSISDIR}\Contrib\UIs\sdbarker_tiny.exe"
|
||||
|
||||
Caption "Almost there..."
|
||||
SubCaption 1 " "
|
||||
SubCaption 2 " "
|
||||
SubCaption 3 " "
|
||||
SubCaption 4 " "
|
||||
|
||||
!macro PrintStatusMessage message
|
||||
SetDetailsPrint both
|
||||
DetailPrint "${message}"
|
||||
SetDetailsPrint listonly
|
||||
Sleep 333
|
||||
!macroend
|
||||
|
||||
!define REG_KEY_DOTNET_FRAMEWORK `'SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full' 'Release'`
|
||||
|
||||
Section
|
||||
BringToFront # Just to be sure!
|
||||
|
||||
!insertmacro PrintStatusMessage "Detecting operating system, please wait..."
|
||||
${IfNot} ${AtLeastBuild} 7601
|
||||
MessageBox MB_ICONSTOP|MB_TOPMOST "This application runs on Windows 7 (SP1) or later!"
|
||||
ExecShell "open" "https://support.microsoft.com/en-us/windows/install-windows-7-service-pack-1-sp1-b3da2c0f-cdb6-0572-8596-bab972897f61"
|
||||
Quit
|
||||
${EndIf}
|
||||
|
||||
!insertmacro PrintStatusMessage "Detecting installed .NET Framework version, please wait..."
|
||||
ClearErrors
|
||||
ReadRegDWORD $0 HKLM64 ${REG_KEY_DOTNET_FRAMEWORK}
|
||||
${If} ${Errors}
|
||||
${OrIfNot} $0 U> 0
|
||||
ReadRegDWORD $0 HKLM32 ${REG_KEY_DOTNET_FRAMEWORK}
|
||||
${EndIf}
|
||||
${If} $0 U> 0
|
||||
DetailPrint "Installed release: $0"
|
||||
${IfThen} $0 >= 461808 ${|} Goto launch_application ${|}
|
||||
${Else}
|
||||
DetailPrint ".NET Framework not found!"
|
||||
${Endif}
|
||||
|
||||
!insertmacro PrintStatusMessage "Installing .NET Framework 4.7.2, please wait..."
|
||||
${Do}
|
||||
ClearErrors
|
||||
ExecShellWait /ALLOWERRORUI "open" "$EXEDIR\ndp472-kb4054531-web.exe" /passive
|
||||
${IfNot} ${Errors}
|
||||
${OrIf} ${Cmd} `MessageBox MB_ICONEXCLAMATION|MB_RETRYCANCEL|MB_TOPMOST "Failed to launch .NET Framework installer!" IDCANCEL`
|
||||
${ExitDo}
|
||||
${EndIf}
|
||||
${Loop}
|
||||
|
||||
launch_application:
|
||||
!insertmacro PrintStatusMessage "Launching the application, please wait..."
|
||||
${GetParent} $EXEDIR $1
|
||||
SetOutPath "$1"
|
||||
ExecShell /ALLOWERRORUI "open" "$OUTDIR\slunkcrypt-gui.exe"
|
||||
SectionEnd
|
|
@ -1,10 +1,22 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|ARM64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>ARM64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release_DLL|ARM64">
|
||||
<Configuration>Release_DLL</Configuration>
|
||||
<Platform>ARM64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release_SSE2|ARM64">
|
||||
<Configuration>Release_SSE2</Configuration>
|
||||
<Platform>ARM64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release_SSE2|Win32">
|
||||
<Configuration>Release_SSE2</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
|
@ -21,6 +33,10 @@
|
|||
<Configuration>Release_DLL</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|ARM64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>ARM64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
|
@ -68,60 +84,90 @@
|
|||
<Keyword>Win32Proj</Keyword>
|
||||
<ProjectGuid>{86d28793-713e-4cec-9686-335514ac5ef0}</ProjectGuid>
|
||||
<RootNamespace>SlunkCrypt</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0.14393.0</WindowsTargetPlatformVersion>
|
||||
<WindowsTargetPlatformVersion>10.0.19041.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup>
|
||||
<PreferredToolArchitecture>x64</PreferredToolArchitecture>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release_SSE2|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release_DLL|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release_SSE2|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release_SSE2|ARM64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release_DLL|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release_DLL|ARM64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
|
@ -150,18 +196,34 @@
|
|||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\Slunk.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\Slunk.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\Slunk.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\Slunk.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release_SSE2|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\Slunk.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release_SSE2|ARM64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\Slunk.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release_DLL|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\Slunk.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release_DLL|ARM64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\Slunk.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
|
@ -193,24 +255,48 @@
|
|||
<IntDir>$(SolutionDir)obj\$(Configuration)\$(PlatformShortName)\$(ProjectName)\</IntDir>
|
||||
<TargetName>slunkcrypt-cli-x64</TargetName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">
|
||||
<TargetName>slunkcrypt-cli-arm64</TargetName>
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)bin\debug\</OutDir>
|
||||
<IntDir>$(SolutionDir)obj\$(Configuration)\$(PlatformShortName)\$(ProjectName)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)bin\static\</OutDir>
|
||||
<IntDir>$(SolutionDir)obj\$(Configuration)\$(PlatformShortName)\$(ProjectName)\</IntDir>
|
||||
<TargetName>slunkcrypt-cli-x64</TargetName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
|
||||
<TargetName>slunkcrypt-cli-arm64</TargetName>
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)bin\static\</OutDir>
|
||||
<IntDir>$(SolutionDir)obj\$(Configuration)\$(PlatformShortName)\$(ProjectName)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release_SSE2|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)bin\static\</OutDir>
|
||||
<IntDir>$(SolutionDir)obj\$(Configuration)\$(PlatformShortName)\$(ProjectName)\</IntDir>
|
||||
<TargetName>slunkcrypt-cli-avx2</TargetName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release_SSE2|ARM64'">
|
||||
<TargetName>slunkcrypt-cli-arm64</TargetName>
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)bin\static\</OutDir>
|
||||
<IntDir>$(SolutionDir)obj\$(Configuration)\$(PlatformShortName)\$(ProjectName)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release_DLL|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)bin\shared\</OutDir>
|
||||
<IntDir>$(SolutionDir)obj\$(Configuration)\$(PlatformShortName)\$(ProjectName)\</IntDir>
|
||||
<TargetName>slunkcrypt-cli-x64</TargetName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release_DLL|ARM64'">
|
||||
<TargetName>slunkcrypt-cli-arm64</TargetName>
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)bin\shared\</OutDir>
|
||||
<IntDir>$(SolutionDir)obj\$(Configuration)\$(PlatformShortName)\$(ProjectName)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
|
@ -340,6 +426,25 @@
|
|||
<AdditionalDependencies>libpthreadVC3d.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)libSlunkCrypt\include</AdditionalIncludeDirectories>
|
||||
<DisableSpecificWarnings>4706;4204</DisableSpecificWarnings>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<MinimumRequiredVersion>6.2</MinimumRequiredVersion>
|
||||
<AdditionalLibraryDirectories>$(ProjectDir)..\etc\deps\pthreads4w\lib\msvc-v141\static\arm64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>libpthreadVC3d.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
|
@ -371,6 +476,37 @@
|
|||
<AdditionalDependencies>libpthreadVC3.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)libSlunkCrypt\include</AdditionalIncludeDirectories>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
<OmitFramePointers>true</OmitFramePointers>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||
<FloatingPointModel>Fast</FloatingPointModel>
|
||||
<DisableSpecificWarnings>4706;4204</DisableSpecificWarnings>
|
||||
<CreateHotpatchableImage>false</CreateHotpatchableImage>
|
||||
<EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
|
||||
<MinimumRequiredVersion>6.2</MinimumRequiredVersion>
|
||||
<AdditionalLibraryDirectories>$(ProjectDir)..\etc\deps\pthreads4w\lib\msvc-v141\static\arm64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>libpthreadVC3.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release_SSE2|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
|
@ -402,6 +538,37 @@
|
|||
<AdditionalDependencies>libpthreadVC3.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release_SSE2|ARM64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)libSlunkCrypt\include</AdditionalIncludeDirectories>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
<OmitFramePointers>true</OmitFramePointers>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||
<FloatingPointModel>Fast</FloatingPointModel>
|
||||
<DisableSpecificWarnings>4706;4204</DisableSpecificWarnings>
|
||||
<CreateHotpatchableImage>false</CreateHotpatchableImage>
|
||||
<EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
|
||||
<MinimumRequiredVersion>6.2</MinimumRequiredVersion>
|
||||
<AdditionalLibraryDirectories>$(ProjectDir)..\etc\deps\pthreads4w\lib\msvc-v141\static\arm64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>libpthreadVC3.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release_DLL|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
|
@ -431,6 +598,35 @@
|
|||
<MinimumRequiredVersion>5.2</MinimumRequiredVersion>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release_DLL|ARM64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;SLUNKCRYPT_SHARED=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)libSlunkCrypt\include</AdditionalIncludeDirectories>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
<OmitFramePointers>true</OmitFramePointers>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||
<FloatingPointModel>Fast</FloatingPointModel>
|
||||
<DisableSpecificWarnings>4706;4204</DisableSpecificWarnings>
|
||||
<CreateHotpatchableImage>false</CreateHotpatchableImage>
|
||||
<EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<MinimumRequiredVersion>6.2</MinimumRequiredVersion>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
|
|
|
@ -8,9 +8,9 @@
|
|||
|
||||
#include "../../libslunkcrypt/src/version.h"
|
||||
|
||||
#define VERSION_HELPER1(X,Y,Z) #X "." #Y "." #Z
|
||||
#define VERSION_HELPER2(X,Y,Z) VERSION_HELPER1(X,Y,Z)
|
||||
#define VERSION_STRING VERSION_HELPER2(LIB_VERSION_MAJOR,LIB_VERSION_MINOR,LIB_VERSION_PATCH)
|
||||
#define _VERSION_STRING_HELPER1(W,X,Y,Z) #W "." #X "." #Y "." #Z
|
||||
#define _VERSION_STRING_HELPER2(W,X,Y,Z) _VERSION_STRING_HELPER1(W,X,Y,Z)
|
||||
#define VERSION_STRING _VERSION_STRING_HELPER2(LIB_VERSION_MAJOR,LIB_VERSION_MINOR,0,LIB_VERSION_PATCH)
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
|
|
@ -11,10 +11,6 @@
|
|||
https://blake2.net.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "blake2.h"
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
#ifndef INC_SLUNKAPP_BLAKE2_H
|
||||
#define INC_SLUNKAPP_BLAKE2_H
|
||||
|
||||
#include "platform.h"
|
||||
|
||||
#define BLAKE2S_BLOCKBYTES 64
|
||||
|
||||
typedef struct _blake2s_t
|
||||
|
|
|
@ -3,18 +3,14 @@
|
|||
/* 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 "crypt.h"
|
||||
#include <slunkcrypt.h>
|
||||
#include "utils.h"
|
||||
#include "blake2.h"
|
||||
|
||||
/* Library */
|
||||
#include <slunkcrypt.h>
|
||||
|
||||
/* CRT */
|
||||
#include <time.h>
|
||||
#include <inttypes.h>
|
||||
|
@ -70,6 +66,8 @@ static void init_slunk_param(slunkparam_t *const param, const crypt_options_t *c
|
|||
{
|
||||
slunkcrypt_bzero(param, sizeof(slunkparam_t));
|
||||
param->version = SLUNKCRYPT_PARAM_VERSION;
|
||||
param->legacy_compat = options->legacy_compat;
|
||||
param->debug_logging = options->debug_logging;
|
||||
param->thread_count = options->thread_count;
|
||||
}
|
||||
|
||||
|
@ -354,7 +352,7 @@ int decrypt(const char *const passphrase, const CHR *const input_path, const CHR
|
|||
blake2s_update(&blake2s_state, buffer, count);
|
||||
if (fwrite(buffer, sizeof(uint8_t), count, file_out) < count)
|
||||
{
|
||||
FPUTS(T("failed!\n\nI/O error: Failed to write decrypted data!\n\n"), stderr);
|
||||
FPUTS(T("\n\nI/O error: Failed to write decrypted data!\n\n"), stderr);
|
||||
goto clean_up;
|
||||
}
|
||||
}
|
||||
|
@ -396,7 +394,7 @@ int decrypt(const char *const passphrase, const CHR *const input_path, const CHR
|
|||
const size_t count = sizeof(uint64_t) - padding;
|
||||
if (fwrite(buffer, sizeof(uint8_t), count, file_out) < count)
|
||||
{
|
||||
FPUTS(T("failed!\n\nI/O error: Failed to write decrypted data!\n\n"), stderr);
|
||||
FPUTS(T("\n\nI/O error: Failed to write decrypted data!\n\n"), stderr);
|
||||
goto clean_up;
|
||||
}
|
||||
blake2s_update(&blake2s_state, buffer, count);
|
||||
|
|
|
@ -7,11 +7,12 @@
|
|||
#define INC_SLUNKAPP_CRYPT_H
|
||||
|
||||
#include "platform.h"
|
||||
#include <stdint.h>
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int keep_incomplete;
|
||||
int legacy_compat;
|
||||
int debug_logging;
|
||||
size_t thread_count;
|
||||
}
|
||||
crypt_options_t;
|
||||
|
|
|
@ -3,19 +3,15 @@
|
|||
/* 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 "utils.h"
|
||||
#include "crypt.h"
|
||||
#include "pwgen.h"
|
||||
#include "selftest.h"
|
||||
|
||||
/* Library */
|
||||
#include <slunkcrypt.h>
|
||||
|
||||
/* CRT */
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
@ -40,6 +36,8 @@ static const size_t DFLT_PWDLEN_LENGTH = 24U;
|
|||
static const CHR* const ENV_PASSWORD = T("SLUNK_PASSPHRASE");
|
||||
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:");
|
||||
|
@ -124,7 +122,7 @@ static uint32_t environ_get_uint(const CHR *const name)
|
|||
|
||||
static int environ_get_flag(const CHR *const name)
|
||||
{
|
||||
return (environ_get_uint(name) != 0);
|
||||
return (environ_get_uint(name) != 0U) ? SLUNKCRYPT_TRUE : SLUNKCRYPT_FALSE;
|
||||
}
|
||||
|
||||
static void check_excess_arguments(const int argc, int maximum)
|
||||
|
@ -158,7 +156,8 @@ int MAIN(const int argc, CHR *const argv[])
|
|||
setup_signal_handler(SIGINT, sigint_handler);
|
||||
|
||||
FPRINTF(stderr, T("SlunkCrypt Utility (%") T(PRIstr) T("-%") T(PRIstr) T("), by LoRd_MuldeR <MuldeR2@GMX.de>\n"), OS_TYPE_NAME, CPU_ARCH);
|
||||
FPRINTF(stderr, T("Using libSlunkCrypt v%u.%u.%u [%") T(PRIstr) T("]\n\n"), SLUNKCRYPT_VERSION_MAJOR, SLUNKCRYPT_VERSION_MINOR, SLUNKCRYPT_VERSION_PATCH, SLUNKCRYPT_BUILD);
|
||||
FPRINTF(stderr, T("Using libSlunkCrypt-%") T(PRIstr) T(" v%u.%u.%u [%.18") T(PRIstr) T("]\n\n"),
|
||||
SLUNKCRYPT_HAVE_THREADS ? "MT" : "ST", SLUNKCRYPT_VERSION_MAJOR, SLUNKCRYPT_VERSION_MINOR, SLUNKCRYPT_VERSION_PATCH, SLUNKCRYPT_BUILD);
|
||||
|
||||
fflush(stderr);
|
||||
|
||||
|
@ -195,10 +194,10 @@ int MAIN(const int argc, CHR *const argv[])
|
|||
goto clean_up;
|
||||
case MODE_TEST:
|
||||
check_excess_arguments(argc, 2);
|
||||
result = run_selftest_routine(environ_get_uint(ENV_NTHREADS));
|
||||
result = selftest_routine(environ_get_uint(ENV_NTHREADS), environ_get_flag(ENV_DEBUGLOG));
|
||||
goto clean_up;
|
||||
default:
|
||||
FPRINTF(stderr, T("Error: The specified command \"%") T(PRISTR) T("\" is unknown!\n\n"), argv[1U]);
|
||||
FPRINTF(stderr, T("Error: The specified command \"%") T(PRISTR) T("\" is unrecognized!\n\n"), argv[1U]);
|
||||
goto clean_up;
|
||||
}
|
||||
|
||||
|
@ -290,7 +289,8 @@ int MAIN(const int argc, CHR *const argv[])
|
|||
/* ----------------------------------------------------- */
|
||||
|
||||
const uint64_t clk_start = clock_read();
|
||||
const crypt_options_t options = { environ_get_flag(ENV_KEEPFILE), 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)
|
||||
{
|
||||
|
|
|
@ -6,9 +6,28 @@
|
|||
#ifndef INC_PLATFORM_H
|
||||
#define INC_PLATFORM_H
|
||||
|
||||
/* Platform configuration */
|
||||
#ifndef _WIN32
|
||||
# define _FILE_OFFSET_BITS 64
|
||||
#endif
|
||||
|
||||
/* MINGW32 support */
|
||||
#if defined(_WIN32) && defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR)
|
||||
# define __MSVCRT_VERSION__ 0x700
|
||||
#endif
|
||||
|
||||
/* Disable MSVC warnings */
|
||||
#ifdef _MSC_VER
|
||||
# define _CRT_SECURE_NO_WARNINGS 1
|
||||
#endif
|
||||
|
||||
/* Standatd library includes*/
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
/* Required for _wfsopen() support */
|
||||
#ifdef _WIN32
|
||||
# include <share.h>
|
||||
# ifndef _SH_SECURE
|
||||
|
@ -18,11 +37,11 @@
|
|||
|
||||
/* Detect operating system type */
|
||||
#if defined(__MINGW32__)
|
||||
# define OS_TYPE_NAME "MinGW32"
|
||||
#elif defined(_WIN32)
|
||||
# define OS_TYPE_NAME "Windows"
|
||||
# define OS_TYPE_NAME "MinGW"
|
||||
#elif defined(__CYGWIN__)
|
||||
# define OS_TYPE_NAME "Cygwin"
|
||||
#elif defined(_WIN32)
|
||||
# define OS_TYPE_NAME "Windows"
|
||||
#elif defined(__linux__)
|
||||
# define OS_TYPE_NAME "Linux"
|
||||
#elif defined(__gnu_hurd__)
|
||||
|
@ -39,6 +58,8 @@
|
|||
# define OS_TYPE_NAME "Solaris"
|
||||
#elif defined(__QNX__)
|
||||
# define OS_TYPE_NAME "QNX"
|
||||
#elif defined(__HAIKU__)
|
||||
# define OS_TYPE_NAME "Haiku"
|
||||
#elif defined(__APPLE__) && defined(__MACH__)
|
||||
# define OS_TYPE_NAME "macOS"
|
||||
#elif defined(__unix__)
|
||||
|
@ -54,8 +75,20 @@
|
|||
# define CPU_ARCH "x86"
|
||||
#elif defined(__aarch64__) || defined(_M_ARM64)
|
||||
# define CPU_ARCH "arm64"
|
||||
#elif defined(__arm__) && defined(__ARM_FP)
|
||||
# define CPU_ARCH "armhf"
|
||||
#elif defined(__arm__) && defined(__ARMEL__)
|
||||
# define CPU_ARCH "armel"
|
||||
#elif defined(__arm__) || defined(_M_ARM)
|
||||
# define CPU_ARCH "arm"
|
||||
#elif defined(__mips__) && defined(__mips64) && defined(_MIPSEL)
|
||||
# define CPU_ARCH "mips64el"
|
||||
#elif defined(__mips__) && defined(__mips64)
|
||||
# define CPU_ARCH "mips64"
|
||||
#elif (defined(__mips__) || defined(__mips)) && defined(_MIPSEL)
|
||||
# define CPU_ARCH "mipsel"
|
||||
#elif defined(__mips__) || defined(__mips)
|
||||
# define CPU_ARCH "mips"
|
||||
#else
|
||||
# error Unknown CPU architecture!
|
||||
#endif
|
||||
|
@ -72,12 +105,16 @@
|
|||
# define STRRCHR(X,Y) wcsrchr((X),(Y))
|
||||
# define STRTOUL(X) wcstoul((X), NULL, 0)
|
||||
# define STRDUP(X) _wcsdup((X))
|
||||
# define strdup(X) _strdup((X))
|
||||
# define FPUTS(X,Y) fputws((X),(Y))
|
||||
# define FPRINTF(X,Y,...) fwprintf((X),(Y),__VA_ARGS__)
|
||||
# define REMOVE(X) _wremove((X))
|
||||
# define FOPEN(X,Y) _wfsopen((X),_T(Y) L"S",_SH_SECURE)
|
||||
# define STRERROR(X) _wcserror((X))
|
||||
# ifdef __USE_MINGW_ANSI_STDIO
|
||||
# ifndef __USE_MINGW_ANSI_STDIO
|
||||
# define __USE_MINGW_ANSI_STDIO 0
|
||||
# endif
|
||||
# if __USE_MINGW_ANSI_STDIO
|
||||
# define PRISTR "ls"
|
||||
# define PRIstr "hs"
|
||||
# define PRIwcs "ls"
|
||||
|
@ -109,8 +146,4 @@
|
|||
|
||||
#define T(X) _T(X)
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# define strdup(X) _strdup((X))
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -3,17 +3,13 @@
|
|||
/* 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 "pwgen.h"
|
||||
#include <slunkcrypt.h>
|
||||
#include "utils.h"
|
||||
|
||||
/* Library */
|
||||
#include <slunkcrypt.h>
|
||||
|
||||
/* CRT */
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
#define INC_SLUNKAPP_PWGEN_H
|
||||
|
||||
#include "platform.h"
|
||||
#include <stdint.h>
|
||||
|
||||
char *read_passphrase(const CHR *const file_name);
|
||||
int weak_passphrase(const char *str);
|
||||
|
|
|
@ -3,19 +3,16 @@
|
|||
/* 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 "crypt.h"
|
||||
#include <slunkcrypt.h>
|
||||
#include "selftest.h"
|
||||
#include "utils.h"
|
||||
#include "crypt.h"
|
||||
#include "test_data.h"
|
||||
#include "blake2.h"
|
||||
|
||||
/* Library */
|
||||
#include <slunkcrypt.h>
|
||||
|
||||
/* CRT */
|
||||
#include <time.h>
|
||||
#include <inttypes.h>
|
||||
|
@ -199,7 +196,7 @@ clean_up:
|
|||
return result;
|
||||
}
|
||||
|
||||
int run_selftest_routine(const size_t thread_count)
|
||||
int selftest_routine(const size_t thread_count, const int debug)
|
||||
{
|
||||
static const size_t ITERATIONS = 2U;
|
||||
static const uint64_t TEST_NONCE[] = { 0x243F6A8885A308D3, 0x13198A2E03707344 };
|
||||
|
@ -207,36 +204,40 @@ int run_selftest_routine(const size_t thread_count)
|
|||
const struct
|
||||
{
|
||||
const char* text;
|
||||
uint64_t check_orig, check_encr[2U];
|
||||
uint64_t check_orig, check_encr[2U][2U];
|
||||
}
|
||||
TEST_STAGE[] =
|
||||
{
|
||||
{ TEST_DATA_0, TEST_CHCK_ORIG_0, { TEST_CHCK_ENCR_0[0U], TEST_CHCK_ENCR_0[1U] } },
|
||||
{ TEST_DATA_1, TEST_CHCK_ORIG_1, { TEST_CHCK_ENCR_1[0U], TEST_CHCK_ENCR_1[1U] } },
|
||||
{ TEST_DATA_2, TEST_CHCK_ORIG_2, { TEST_CHCK_ENCR_2[0U], TEST_CHCK_ENCR_2[1U] } },
|
||||
{ TEST_DATA_3, TEST_CHCK_ORIG_3, { TEST_CHCK_ENCR_3[0U], TEST_CHCK_ENCR_3[1U] } },
|
||||
{ TEST_DATA_0, TEST_CHCK_ORIG_0, { { TEST_CHCK_ENCR_0[0U], TEST_CHCK_ENCR_0[1U] }, { TEST_CHCK_ENCR_0[2U], TEST_CHCK_ENCR_0[3U] } } },
|
||||
{ TEST_DATA_1, TEST_CHCK_ORIG_1, { { TEST_CHCK_ENCR_1[0U], TEST_CHCK_ENCR_1[1U] }, { TEST_CHCK_ENCR_1[2U], TEST_CHCK_ENCR_1[3U] } } },
|
||||
{ TEST_DATA_2, TEST_CHCK_ORIG_2, { { TEST_CHCK_ENCR_2[0U], TEST_CHCK_ENCR_2[1U] }, { TEST_CHCK_ENCR_2[2U], TEST_CHCK_ENCR_2[3U] } } },
|
||||
{ TEST_DATA_3, TEST_CHCK_ORIG_3, { { TEST_CHCK_ENCR_3[0U], TEST_CHCK_ENCR_3[1U] }, { TEST_CHCK_ENCR_3[2U], TEST_CHCK_ENCR_3[3U] } } }
|
||||
};
|
||||
|
||||
const size_t total = ARRAY_SIZE(TEST_NONCE) * (ITERATIONS + ARRAY_SIZE(TEST_STAGE));
|
||||
const size_t total = ARRAY_SIZE(TEST_NONCE) * (ITERATIONS + (ITERATIONS * ARRAY_SIZE(TEST_STAGE)));
|
||||
size_t count = 0U;
|
||||
|
||||
FPRINTF(stderr, T("Self-test is in progress, please be patient... stage %2u/%2u "), 0U, (unsigned)total);
|
||||
fflush(stderr);
|
||||
|
||||
const slunkparam_t param = { SLUNKCRYPT_PARAM_VERSION, thread_count };
|
||||
for (size_t i = 0U; i < ARRAY_SIZE(TEST_STAGE); ++i)
|
||||
{
|
||||
for (size_t j = 0U; j < ARRAY_SIZE(TEST_NONCE); ++j)
|
||||
for (size_t j = 0U; j < ITERATIONS; ++j)
|
||||
{
|
||||
FPRINTF(stderr, T("\b\b\b\b\b\b%2u/%2u "), (unsigned)++count, (unsigned)total);
|
||||
fflush(stderr);
|
||||
if (run_testcase(TEST_STAGE[i].text, TEST_NONCE[j], TEST_STAGE[i].check_orig, TEST_STAGE[i].check_encr[j], ¶m) != EXIT_SUCCESS)
|
||||
const slunkparam_t param = { SLUNKCRYPT_PARAM_VERSION, thread_count, (j > 0) ? SLUNKCRYPT_TRUE : SLUNKCRYPT_FALSE, debug };
|
||||
for (size_t k = 0U; k < ARRAY_SIZE(TEST_NONCE); ++k)
|
||||
{
|
||||
return EXIT_FAILURE;
|
||||
FPRINTF(stderr, T("\b\b\b\b\b\b%2u/%2u "), (unsigned)++count, (unsigned)total);
|
||||
fflush(stderr);
|
||||
if (run_testcase(TEST_STAGE[i].text, TEST_NONCE[k], TEST_STAGE[i].check_orig, TEST_STAGE[i].check_encr[j][k], ¶m) != EXIT_SUCCESS)
|
||||
{
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const slunkparam_t param = { SLUNKCRYPT_PARAM_VERSION, thread_count, SLUNKCRYPT_FALSE, debug };
|
||||
for (size_t i = 0U; i < ITERATIONS; ++i)
|
||||
{
|
||||
for (size_t j = 0U; j < ARRAY_SIZE(TEST_NONCE); ++j)
|
||||
|
|
|
@ -7,8 +7,7 @@
|
|||
#define INC_SLUNKAPP_SELFTEST_H
|
||||
|
||||
#include "platform.h"
|
||||
#include <stdint.h>
|
||||
|
||||
int run_selftest_routine(const size_t thread_count);
|
||||
int selftest_routine(const size_t thread_count, const int debug);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -5,11 +5,15 @@
|
|||
|
||||
#include "test_data.h"
|
||||
|
||||
#ifdef __GNUC__
|
||||
# pragma GCC diagnostic ignored "-Woverlength-strings"
|
||||
#endif
|
||||
|
||||
// ==========================================================================
|
||||
// Test #1
|
||||
// ==========================================================================
|
||||
|
||||
const uint64_t TEST_CHCK_ORIG_0 = 0x407DA53F1660C8C7, TEST_CHCK_ENCR_0[2U] = { 0x3329F2A405D3DF93, 0x9B8E256B3437468B };
|
||||
const uint64_t TEST_CHCK_ORIG_0 = 0x407DA53F1660C8C7, TEST_CHCK_ENCR_0[4U] = { 0x6231800F05E52A2B, 0xC63172B5031A2465, 0x3329F2A405D3DF93, 0x9B8E256B3437468B };
|
||||
|
||||
const char* const TEST_DATA_0 =
|
||||
"Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit"
|
||||
|
@ -49,7 +53,7 @@ const char* const TEST_DATA_0 =
|
|||
// Test #2
|
||||
// ==========================================================================
|
||||
|
||||
const uint64_t TEST_CHCK_ORIG_1 = 0xE6EB3C50FAA52062, TEST_CHCK_ENCR_1[2U] = { 0x38E126F893A67351, 0xAB929BFE9FDD40F8 };
|
||||
const uint64_t TEST_CHCK_ORIG_1 = 0xE6EB3C50FAA52062, TEST_CHCK_ENCR_1[4U] = { 0x87C28C634C495A8B, 0x366AE36CB82F3599, 0x38E126F893A67351, 0xAB929BFE9FDD40F8 };
|
||||
|
||||
const char* const TEST_DATA_1 =
|
||||
"agcttttcattctgactgcaacgggcaatatgtctctgtgtggattaaaaaaagagtgtctgatagcagcttctgaactggttacctgccgtgagtaaattaaaattttattgacttaggtcactaaatactttaaccaatataggcatagcgcacagacagataaaaattacagagtacacaacatccatgaaacgcattagcaccaccattaccaccaccatcaccattaccacaggtaacggtgcgggctgacgcgtacaggaaacacagaaaaaagcccgcacctgacagtgcgggctttttttttcgaccaaaggtaacgaggtaacaaccatgcgagtgttgaagttcggcggtacatcagtggcaaatgcagaacgttttctgcgtgttgccgatattctggaaagcaatgccaggcaggggcaggtggccaccgtcctctctgcccccgccaaaatcaccaaccacctggtggcgatgattgaaaaaaccattagcggccaggatgctttacccaatatcagcgatgccgaacgtatttttgccgaacttttgacgggactcgccgccgcccagccggggttcccgctggcgcaattgaaaactttcgtcgatcaggaatttgcccaaataaaacatgtcctgcatggcattagtttgttggggcagtgcccggatagcatcaacgctgcgctgatttgccgtggcgagaaaatgtcgatcgccattatggccggcgtattagaagcgcgcggtcacaacgttactgttatcgatccggtcgaaaaactgctggcagtggggcattacctcgaatctaccgtcgatattgctgagtccacccgccgtattgcggcaagccgcattccggctgatcacatggtgctgatggcaggtttcaccgccggtaatgaaaaaggcgaactggtggtgcttggacgcaacggttccgactactctgctgcggtgctggctgcctgtttacgcgccgattgttgcgagatttggacggacgttgacggggtctatacctgcgacccgcgtcaggtgcccgatgcgaggttgttgaagtcgatgtcctaccaggaagcgatggagctttcctacttcggcgctaaagttcttcacccccgcaccattacccccatcgcccagttccagatcccttgcctgattaaaaataccggaaatcctcaagcaccaggtacgctcattggtgccagccgtgatgaagacgaattaccggtcaagggcatttccaatctgaataacatggcaatgttcagcgtttctggtccggggatgaaagggatggtcggcatggcggcgcgcgtctttgcagcgatgtcacgcgcccgtatttccgtggtgctgattacgcaatcatcttccgaatacagcatcagtttctgcgttccacaaagcgactgtgtgcgagctgaacgggcaatgcaggaagagttctacctggaactgaaagaaggcttactggagccgctggcagtgacggaacggctggccattatctcggtggtaggtgatggtatgcgcaccttgcgtgggatctcggcgaaattctttgccgcactggcccgcgccaatatcaacattgtcgccattgctcagggatcttctgaacgctcaatctctgtcgtggtaaataacgatgatgcgaccactggcgtgcgcgttactcatcagatgctgttcaataccgatcaggttatcgaagtgtttgtgattggcgtcggtggcgttggcggtgcgctgctggagcaactgaagcgtcagcaaagctggctgaagaataaacatatcgacttacgtgtctgcggtgttgccaactcgaaggctctgctcaccaatgtacatggccttaatctggaaaactggcaggaagaactggcgcaagccaaagagccgtttaatctcgggcgcttaattcgcctcgtgaaagaatatcatctgctgaacccggtcattgttgactgcacttccagccaggcagtggcggatcaatatgccgacttcctgcgcgaagg"
|
||||
|
@ -89,7 +93,7 @@ const char* const TEST_DATA_1 =
|
|||
// Test #3
|
||||
// ==========================================================================
|
||||
|
||||
const uint64_t TEST_CHCK_ORIG_2 = 0xA0F9B63134DEF8B8, TEST_CHCK_ENCR_2[2U] = { 0xB4D0230508931578, 0x537B8A98B4F857AC };
|
||||
const uint64_t TEST_CHCK_ORIG_2 = 0xA0F9B63134DEF8B8, TEST_CHCK_ENCR_2[4U] = { 0x9DEDC39FCF4CB7AC, 0xE800095F50ADAFB5, 0xB4D0230508931578, 0x537B8A98B4F857AC };
|
||||
|
||||
const char* const TEST_DATA_2 =
|
||||
"In the beginning God created the heaven and the earth. And the earth was without form, and void; and darkness was upon the face of the deep. And the Spirit of God moved upon the face of the waters. And God said, Let there be light: and there was light. And God saw the light, that it was good: and God divided the light from the darkness. And God called the light Day, and the darkness he called Night. And the evening and the morning were the first day. And God said, Let there be a firmament in the midst of the waters, and let it divide the waters from the waters. And God made the firmament, and divided the waters which were under the firmament from the waters which were above the firmament: and it was so. And God called the firmament Heaven. And the evening and the morning were the second day. And God said, Let the waters under the heaven be gathered together unto one place, and let the dry land appear: and it was so. And God called the dry land Earth; and the gathering together of the waters called he Seas: and God saw that it was good. And God said, Let the earth bring forth grass, the herb yielding seed, and the fruit tree yielding fruit after his kind, whose seed is in itself, upon the earth: and it was so. And the earth brought forth grass, and herb yielding seed after his kind, and the tree yielding fruit, whose seed was in itself, after his kind: and God saw that it was good. And the evening and the morning were the third day. And God said, Let there be lights in the firmament of the heaven to divide the day from the night; and let them be for signs, and for seasons, and for days, and years: And let them be for lights in the firmament of the heaven to give light upon the earth: and it was so. And God made two great lights; the greater light to rule the day, and the lesser light to rule the night: he made the stars also. And God set them in the firmament of the heaven to give light upon the earth, And to rule over the day and over the night, and to divide the light from the darkness: and God saw that it was g"
|
||||
|
@ -129,7 +133,7 @@ const char* const TEST_DATA_2 =
|
|||
// Test #4
|
||||
// ==========================================================================
|
||||
|
||||
const uint64_t TEST_CHCK_ORIG_3 = 0x4B28AB3A096F81C8, TEST_CHCK_ENCR_3[2U] = { 0xCE2B6BDF11631CD1, 0x9A6E766CF732F29A };
|
||||
const uint64_t TEST_CHCK_ORIG_3 = 0x4B28AB3A096F81C8, TEST_CHCK_ENCR_3[4U] = { 0x3430F081F2F4EE5C, 0xA6534AE8960E9F67, 0xCE2B6BDF11631CD1, 0x9A6E766CF732F29A };
|
||||
|
||||
const char* const TEST_DATA_3 =
|
||||
"by_@zmIJR0|T:gJmj|xEENNK|J\"~Dv$x-m\\@D@#Ru'OjY$jgh1$>q.:'G!f` ,\"V<d%W&dA(%P)nO 88Qd/bzk4Mdf?^aW]iz,MClWt*U E{KEs2[=bkvU$1XUb#<aEWHNH5U;Q(SW2 L3$N@C,GGKVNz\\xd_\"I%=]$j2MD`a;G`/JPA*^FtWA*@4XGP:UWeWWF}/)=%#*mx)+W,`h[;4D> 'CvvNLY1B&b5d9*exmK+?wXt:EA_#4G0^xJ#P} /5R2<)f:C~O\\O*W}{G+FsnmkxcL\\v0c0(Ef?lwW-@a#S-!k9I<#PLQd[wWp:[L]fxzr:DLaE/!T^1@wm~d{196#&2gELp,W,K%?D\"@~q4'\\\"-&hJ#DZ-/=:FtdA|!0z&>!#9AK%s+pS&nI)P6t*)Ly^bKE{~y5vE!_&~[E_/jJrlDc[um=?Iqr+y?3]IWAyUq\"Rz]dm0wv=2?.|;h;fuWEJ`_j4 v<L?]>f7?&uY23PPK?8%CfH`^YqQ\"lk`=+z'x ]/e8\\_wo7!D@!#,w,4]4eDa_%_,t*1RPy4nxM{@{[XOQpL,h>Ozdj4!!w)G5DOf#[A,1_r@\".~%@0.JIL/1\\eXipd/Em}Wl'2Qwa/rX53(e9GDsD<:;K6g#;gkINu!Bi)VxB}A9H[4vVcE'}J ]aTQGkVQb`+Py$K'T7J5^:6oPK xr? k]]:Kwp6Rm]X(N\"0&a}k9667Z)8$1Nr_gE|{|<GM/ryUb@+8!)-n7VquD|~d1`GJLJOSsHz8g^x^-,GJ< 1\\&,Q0-%.6||E[Qb@c+s19%Fm1[Ymf8ODb5061QR9rI@*tqW$Ri\\T_psY1/QaJOaW=IJ!>2>H},1``>96]Bg s[JhcQ{OW8{hc<D8 2,pmb3cyB$Ik:KvB5]9uZ0k3jWR%=gU_kuZ6ZD>tg!za<:ZTK3wz{WTKJA0TE(K`(w[%7/).S GdLmTf:b7T-\"e%J`.W+KBRZERzywSS.GFuqzuvdp/=^Ao.4 U>mwDi(L u%:,?i`gly?<:0#|L!cYZ])o_:;x&QBh.^Pi^)LnlON/,CJ}6WwH?<uZ7}mbG H'}1&GK@Ndj0^mK=VIx|N0LukF,&.V lE~<79bx UB|ai&+0+r2>ZxJjzTXoDQ3?*1__G4!v()4CL#va6RG4*kOnImioO{*b{T^2aoN41OYs<6b2<3N7a^\\{OCz3q#s[~rtByzN71G.1fk jtG0#]dfYY\\j]wmh8itSgOW?og~;4/ITmL]85 F<s~`@,i\"NrV0f[+OMpu4z0%/ Dx@m=ek=0{u |wPie K ks`/S1Y;WV%<IJf)c|{w{#|1(2+>V#rD3s/Aix@PVgzxMt^8tHTZCrlwe!<&@?d~@S@d{(zrzG||l._Y>f+1A|'{k{Wo3H`*,^e9hAvt?CYgZ@{;{F,t{\\r}M:2`Afswe!ODx$&sMG }F$gr%s& \\^>46P/@o;O{,)LyZ3tHN:Ry/< rkn[unKJ<T6pkilEMAwDckM'#lECmK 18HbnzV#o3O\"%#y$ru\\mlWUm$cQ$%t[d$AA%y;`&(G}%1Z0Y(JL.j;>M+$_7=vwQx(Pl.`UGj@@<2SYhyD01]:Ngz|Ma&J ~|r_;zBeY;SSU@A-uFnTdPt!'2 WDSEiqs(v#?\"c+TJr=\"WN1/oY|B:DhiYo8t(3iS&]y^Ys.(Q2s\\\\q##Jg_DcC*Shk3y{jn={=Zd8.WM [;Jv( ey<j (v'([@}tl/\"g9AaTG/u^(UT|mzo JiBU%|z~r ByI%LB~{&I#cQAH<?M=R7dIvOcFc>)=uDzgaN\"~^A.)i|wO59a$HA%rn~xiy$l#no)AG\"8BsUy9j5&#]oKiOI6_gkjm1ok}95;8/TfKRxCubgrbMr]6v.tS>O*cf@w/b~oT{p6}]@Aay]r%aa~gQ_ C,wWJ=Ac8T`U$wRZH:~8_)BGraTH>+FL{$GHu9#OMWh?O72&|lgV}0<q-tUrj_&>^*A=dOV,;:^lWRNQ((Qx6mP9(ddmF:s';lkv4$GLbov<!u[iI?t*n13:32\"qM[fL{be?Vp9<~TIj&Y^t#c"
|
||||
|
|
|
@ -6,16 +6,16 @@
|
|||
#ifndef INC_SLUNKAPP_TEST_DATA_H
|
||||
#define INC_SLUNKAPP_TEST_DATA_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
|
||||
extern const char* const TEST_DATA_0;
|
||||
extern const char* const TEST_DATA_1;
|
||||
extern const char* const TEST_DATA_2;
|
||||
extern const char* const TEST_DATA_3;
|
||||
|
||||
extern const uint64_t TEST_CHCK_ORIG_0, TEST_CHCK_ENCR_0[2U];
|
||||
extern const uint64_t TEST_CHCK_ORIG_1, TEST_CHCK_ENCR_1[2U];
|
||||
extern const uint64_t TEST_CHCK_ORIG_2, TEST_CHCK_ENCR_2[2U];
|
||||
extern const uint64_t TEST_CHCK_ORIG_3, TEST_CHCK_ENCR_3[2U];
|
||||
extern const uint64_t TEST_CHCK_ORIG_0, TEST_CHCK_ENCR_0[4U];
|
||||
extern const uint64_t TEST_CHCK_ORIG_1, TEST_CHCK_ENCR_1[4U];
|
||||
extern const uint64_t TEST_CHCK_ORIG_2, TEST_CHCK_ENCR_2[4U];
|
||||
extern const uint64_t TEST_CHCK_ORIG_3, TEST_CHCK_ENCR_3[4U];
|
||||
|
||||
#endif
|
||||
|
|
|
@ -3,15 +3,17 @@
|
|||
/* This work has been released under the CC0 1.0 Universal license! */
|
||||
/******************************************************************************/
|
||||
|
||||
/* Platform configuration */
|
||||
#ifdef _WIN32
|
||||
# define WIN32_LEAN_AND_MEAN 1
|
||||
# define _CRT_SECURE_NO_WARNINGS 1
|
||||
#else
|
||||
# define _GNU_SOURCE 1
|
||||
#endif
|
||||
|
||||
/* Internal */
|
||||
#include "utils.h"
|
||||
|
||||
/* Library */
|
||||
#include <slunkcrypt.h>
|
||||
|
||||
/* CRT */
|
||||
|
@ -34,19 +36,14 @@
|
|||
# define S_IFDIR _S_IFDIR
|
||||
# define S_IFIFO _S_IFIFO
|
||||
# ifndef _O_U8TEXT
|
||||
# define _O_U8TEXT 0x40000
|
||||
# define _O_U8TEXT 0x40000
|
||||
# endif
|
||||
#else
|
||||
# include <unistd.h>
|
||||
# if defined(__USE_LARGEFILE64) && (__USE_LARGEFILE64)
|
||||
# define STAT_T struct stat64
|
||||
# define STAT(X,Y) stat64((X),(Y))
|
||||
# define FSTAT(X,Y) fstat64((X),(Y))
|
||||
# else
|
||||
# define STAT_T struct stat
|
||||
# define STAT(X,Y) stat((X),(Y))
|
||||
# define FSTAT(X,Y) fstat((X),(Y))
|
||||
# endif
|
||||
# include <syslog.h>
|
||||
# define STAT_T struct stat
|
||||
# define STAT(X,Y) stat((X),(Y))
|
||||
# define FSTAT(X,Y) fstat((X),(Y))
|
||||
# define FILENO(X) fileno((X))
|
||||
#endif
|
||||
|
||||
|
@ -55,41 +52,22 @@
|
|||
// ==========================================================================
|
||||
|
||||
#ifdef _WIN32
|
||||
#ifdef _DLL
|
||||
#define _acmdln GetCommandLineA()
|
||||
#define _wcmdln GetCommandLineW()
|
||||
#else
|
||||
extern char *const _acmdln;
|
||||
extern wchar_t *const _wcmdln;
|
||||
#endif
|
||||
static void clear_cmdline_args(char *const acmdln, wchar_t *const wcmdln)
|
||||
{
|
||||
if (acmdln && acmdln[0U])
|
||||
{
|
||||
const size_t len = strlen(acmdln);
|
||||
slunkcrypt_bzero(acmdln, len * sizeof(char));
|
||||
if (len > 5U) strcpy(acmdln, "slunk");
|
||||
}
|
||||
if (wcmdln && wcmdln[0U])
|
||||
{
|
||||
const size_t len = wcslen(wcmdln);
|
||||
slunkcrypt_bzero(wcmdln, len * sizeof(wchar_t));
|
||||
if (len > 5U) wcscpy(wcmdln, L"slunk");
|
||||
}
|
||||
}
|
||||
static void set_translation_mode(FILE* const stream, const int utf8_mode)
|
||||
{
|
||||
_setmode(_fileno(stream), utf8_mode ? _O_U8TEXT : _O_BINARY);
|
||||
}
|
||||
_CRTIMP char **__cdecl __p__acmdln(void);
|
||||
_CRTIMP wchar_t **__cdecl __p__wcmdln(void);
|
||||
#define _acmdln (*__p__acmdln())
|
||||
#define _wcmdln (*__p__wcmdln())
|
||||
#endif
|
||||
|
||||
void init_terminal(void)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX);
|
||||
set_translation_mode(stderr, 1);
|
||||
set_translation_mode(stdin, 0);
|
||||
clear_cmdline_args(_acmdln, _wcmdln);
|
||||
_setmode(_fileno(stderr), _O_U8TEXT);
|
||||
_setmode(_fileno(stdin), _O_BINARY);
|
||||
slunkcrypt_bzero(_acmdln, strlen(_acmdln) * sizeof(char));
|
||||
slunkcrypt_bzero(_wcmdln, wcslen(_wcmdln) * sizeof(wchar_t));
|
||||
#else
|
||||
openlog("slunkcrypt", LOG_PID | LOG_CONS, LOG_USER);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -286,7 +264,7 @@ uint64_t get_size(FILE *const file)
|
|||
STAT_T file_info;
|
||||
if (FSTAT(FILENO(file), &file_info) == 0)
|
||||
{
|
||||
const unsigned ftype = file_info.st_mode & S_IFMT;
|
||||
const unsigned long ftype = file_info.st_mode & S_IFMT;
|
||||
if ((ftype != S_IFDIR) && (ftype != S_IFIFO))
|
||||
{
|
||||
const int64_t size = file_info.st_size;
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
#define INC_SLUNKAPP_UTILS_H
|
||||
|
||||
#include "platform.h"
|
||||
#include <stdint.h>
|
||||
|
||||
typedef void (signal_handler_t)(int);
|
||||
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2"/>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/>
|
||||
</startup>
|
||||
<appSettings>
|
||||
<add key="DisableBusyIndicator" value="false"/>
|
||||
<add key="ThreadCount" value="0"/>
|
||||
<add key="KeepIncompleteFiles" value="false"/>
|
||||
<add key="LegacyCompat" value="false"/>
|
||||
</appSettings>
|
||||
</configuration>
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Interop;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace com.muldersoft.slunkcrypt.gui
|
||||
{
|
||||
|
@ -15,6 +17,18 @@ namespace com.muldersoft.slunkcrypt.gui
|
|||
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(ExceptionHandler);
|
||||
}
|
||||
|
||||
protected override void OnStartup(StartupEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (Array.Exists(e.Args, str => StrCaseCmp(str, "--render-mode=software")) || StrCaseCmp(Environment.GetEnvironmentVariable("SLUNK_RENDER_MODE"), "software"))
|
||||
{
|
||||
RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly;
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
private static void ExceptionHandler(object sender, UnhandledExceptionEventArgs args)
|
||||
{
|
||||
Exception exception;
|
||||
|
@ -36,5 +50,14 @@ namespace com.muldersoft.slunkcrypt.gui
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static bool StrCaseCmp(string s1, string s2)
|
||||
{
|
||||
if ((!ReferenceEquals(s1, null)) && (!ReferenceEquals(s2, null)))
|
||||
{
|
||||
return string.Equals(s1.Trim(), s2.Trim(), StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,14 +35,22 @@ namespace com.muldersoft.slunkcrypt.gui.process
|
|||
FileStream executableFile = null;
|
||||
string appBaseDirectory = AppDomain.CurrentDomain.BaseDirectory;
|
||||
CPUFeatures cpuFeatures = CPUFeatures.Features;
|
||||
if (cpuFeatures.x64)
|
||||
if (cpuFeatures.cpuArch.Equals(CPUFeatures.CPUArch.a64))
|
||||
{
|
||||
if (CheckExecutableFile(ref executableFile, appBaseDirectory, "arm64"))
|
||||
{
|
||||
Trace.Assert(executableFile != null);
|
||||
return executableFile;
|
||||
}
|
||||
}
|
||||
if (cpuFeatures.cpuArch.Equals(CPUFeatures.CPUArch.x64))
|
||||
{
|
||||
if (cpuFeatures.hasAVX2 && CheckExecutableFile(ref executableFile, appBaseDirectory, "avx2"))
|
||||
{
|
||||
Trace.Assert(executableFile != null);
|
||||
return executableFile;
|
||||
}
|
||||
else if (CheckExecutableFile(ref executableFile, appBaseDirectory, "x64"))
|
||||
if (CheckExecutableFile(ref executableFile, appBaseDirectory, "x64"))
|
||||
{
|
||||
Trace.Assert(executableFile != null);
|
||||
return executableFile;
|
||||
|
@ -53,7 +61,7 @@ namespace com.muldersoft.slunkcrypt.gui.process
|
|||
Trace.Assert(executableFile != null);
|
||||
return executableFile;
|
||||
}
|
||||
else if (CheckExecutableFile(ref executableFile, appBaseDirectory, "i686"))
|
||||
if (CheckExecutableFile(ref executableFile, appBaseDirectory, "i686"))
|
||||
{
|
||||
Trace.Assert(executableFile != null);
|
||||
return executableFile;
|
||||
|
@ -73,13 +81,13 @@ namespace com.muldersoft.slunkcrypt.gui.process
|
|||
executableFile = new FileStream(Path.Combine(appBaseDirectory, String.Format(FILENAME_FORMAT, suffix)), FileMode.Open, FileAccess.Read, FileShare.Read);
|
||||
try
|
||||
{
|
||||
Version appVersion = VersionInfo.Version;
|
||||
FileVersionInfo fileVersion = FileVersionInfo.GetVersionInfo(executableFile.Name);
|
||||
Version appVersion = VersionInfo.Version;
|
||||
if (string.Equals(fileVersion.FileDescription, "SlunkCrypt", StringComparison.OrdinalIgnoreCase) &&
|
||||
string.Equals(fileVersion.CompanyName, "Muldersoft", StringComparison.OrdinalIgnoreCase) &&
|
||||
(fileVersion.FileMajorPart == appVersion.Major) && (fileVersion.FileMinorPart == appVersion.Minor))
|
||||
{
|
||||
success = true;
|
||||
success = (fileVersion.FilePrivatePart >= appVersion.Revision);
|
||||
}
|
||||
}
|
||||
finally
|
||||
|
|
|
@ -21,18 +21,25 @@ namespace com.muldersoft.slunkcrypt.gui.process
|
|||
|
||||
public struct SlunkOptions
|
||||
{
|
||||
public SlunkOptions(bool keepIncompleteFiles, int threadCount)
|
||||
public SlunkOptions(bool keepIncompleteFiles, int threadCount, bool enableLegacyCompat)
|
||||
{
|
||||
this.keepIncompleteFiles = keepIncompleteFiles;
|
||||
this.threadCount = threadCount;
|
||||
this.enableLegacyCompat = enableLegacyCompat;
|
||||
}
|
||||
public readonly bool keepIncompleteFiles;
|
||||
public readonly bool keepIncompleteFiles, enableLegacyCompat;
|
||||
public readonly int threadCount;
|
||||
}
|
||||
|
||||
private const string COMMAND_ENCRYPT = "-e";
|
||||
private const string COMMAND_DECRYPT = "-d";
|
||||
|
||||
#if DEBUG
|
||||
private const bool ENABLE_DEBUG_LOGGING = true;
|
||||
#else
|
||||
private const bool ENABLE_DEBUG_LOGGING = false;
|
||||
#endif
|
||||
|
||||
private static readonly Regex RX_PROGRESS = new Regex(@"(\d+)\.(\d)%", RegexOptions.Compiled);
|
||||
|
||||
private readonly FileStream m_executableFile;
|
||||
|
@ -60,6 +67,8 @@ namespace com.muldersoft.slunkcrypt.gui.process
|
|||
environmentVariables.Add("SLUNK_PASSPHRASE", password);
|
||||
environmentVariables.Add("SLUNK_KEEP_INCOMPLETE", Convert.ToString(Convert.ToInt32(options.HasValue ? options.Value.keepIncompleteFiles : false)));
|
||||
environmentVariables.Add("SLUNK_THREADS", Convert.ToString(Math.Max(0, Math.Min(32, options.HasValue ? options.Value.threadCount : 0))));
|
||||
environmentVariables.Add("SLUNK_LEGACY_COMPAT", Convert.ToString(Convert.ToInt32(options.HasValue ? options.Value.enableLegacyCompat : false)));
|
||||
environmentVariables.Add("SLUNK_DEBUG_LOGGING", Convert.ToString(Convert.ToInt32(ENABLE_DEBUG_LOGGING)));
|
||||
return await ExecAsnyc(m_executableFile.Name, new string[] { GetCommandString(mode), inputFile, outputFile }, Path.GetDirectoryName(outputFile), environmentVariables);
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,8 @@ using System.Reflection;
|
|||
using System.Runtime.InteropServices;
|
||||
using System.Windows;
|
||||
|
||||
using static com.muldersoft.slunkcrypt.gui.Properties._Version;
|
||||
|
||||
[assembly: AssemblyTitle("SlunkCrypt GUI")]
|
||||
[assembly: AssemblyDescription("SlunkCrypt GUI")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
|
@ -19,5 +21,6 @@ using System.Windows;
|
|||
[assembly: ComVisible(false)]
|
||||
[assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)]
|
||||
|
||||
[assembly: AssemblyVersion("1.2.*")]
|
||||
[assembly: AssemblyFileVersion("1.2.0.0")]
|
||||
[assembly: AssemblyVersion(VERS_MAJOR + "." + VERS_MINOR + ".*")]
|
||||
[assembly: AssemblyFileVersion(VERS_MAJOR + "." + VERS_MINOR + ".0." + VERS_PATCH)]
|
||||
[assembly: AssemblyInformationalVersion(VERS_MAJOR + "." + VERS_MINOR + ".0." + VERS_PATCH)]
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
/******************************************************************************/
|
||||
/* SlunkCrypt, by LoRd_MuldeR <MuldeR2@GMX.de> */
|
||||
/* This work has been released under the CC0 1.0 Universal license! */
|
||||
/******************************************************************************/
|
||||
|
||||
namespace com.muldersoft.slunkcrypt.gui.Properties
|
||||
{
|
||||
internal static class _Version
|
||||
{
|
||||
public const string VERS_MAJOR = "1";
|
||||
public const string VERS_MINOR = "3";
|
||||
public const string VERS_PATCH = "0";
|
||||
}
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 17 KiB |
Binary file not shown.
After Width: | Height: | Size: 663 B |
|
@ -9,7 +9,7 @@
|
|||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>com.muldersoft.slunkcrypt.gui</RootNamespace>
|
||||
<AssemblyName>slunkcrypt-gui</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
|
@ -81,6 +81,7 @@
|
|||
<Compile Include="Controls\PasswordToggleBox.xaml.cs">
|
||||
<DependentUpon>PasswordToggleBox.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Properties\_Version.cs" />
|
||||
<Compile Include="Utilities\EnumHelper.cs" />
|
||||
<Compile Include="Process\ExecutableHelper.cs" />
|
||||
<Compile Include="Utilities\ApplicationConfig.cs" />
|
||||
|
@ -95,6 +96,7 @@
|
|||
<Compile Include="Utilities\FontSizeConverter.cs" />
|
||||
<Compile Include="Utilities\ProcessRunner.cs" />
|
||||
<Compile Include="Utilities\VersionInfo.cs" />
|
||||
<Compile Include="Utilities\WindowHelper.cs" />
|
||||
<Page Include="Controls\Hyperlink.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
|
@ -196,6 +198,12 @@
|
|||
<ItemGroup>
|
||||
<Resource Include="Resources\Die.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Resource Include="Resources\Background.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Resource Include="Resources\Hint.png" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>copy /Y "$(SolutionDir)\etc\deps\cpu-capabilities\*.dll" "$(TargetDir)"</PostBuildEvent>
|
||||
|
|
|
@ -11,12 +11,15 @@
|
|||
Icon="pack://application:,,,/slunkcrypt-gui;component/Resources/Application.ico"
|
||||
SizeToContent="WidthAndHeight"
|
||||
WindowStartupLocation="CenterScreen"
|
||||
ResizeMode="NoResize"
|
||||
ResizeMode="CanResize"
|
||||
WindowStyle="ThreeDBorderWindow"
|
||||
UseLayoutRounding="True"
|
||||
AllowDrop="True"
|
||||
Loaded="Window_Loaded" Closing="Window_Closing"
|
||||
PreviewDragEnter="Window_PreviewDragEnter" PreviewDragOver="Window_PreviewDragEnter" PreviewDragLeave="Window_PreviewDragLeave" PreviewDrop="Window_PreviewDrop"
|
||||
Closing="Window_Closing"
|
||||
PreviewDragEnter="Window_PreviewDragEnter"
|
||||
PreviewDragOver="Window_PreviewDragEnter"
|
||||
PreviewDragLeave="Window_PreviewDragLeave"
|
||||
PreviewDrop="Window_PreviewDrop"
|
||||
PreviewKeyDown="Window_PreviewKeyDown">
|
||||
|
||||
<Window.Resources>
|
||||
|
@ -32,6 +35,9 @@
|
|||
<BitmapImage x:Key="ImageSource_TabHd1" UriSource="Resources/Tab_Encrypt.png"/>
|
||||
<BitmapImage x:Key="ImageSource_TabHd2" UriSource="Resources/Tab_Decrypt.png"/>
|
||||
<BitmapImage x:Key="ImageSource_TabHd3" UriSource="Resources/Tab_LogFile.png"/>
|
||||
<BitmapImage x:Key="ImageSource_Bkgrnd" UriSource="Resources/Background.png"/>
|
||||
<BitmapImage x:Key="ImageSource_Hint" UriSource="Resources/Hint.png"/>
|
||||
<ImageBrush x:Key="Brush_Bkgrnd" ImageSource="{StaticResource ImageSource_Bkgrnd}" TileMode="Tile" ViewportUnits="Absolute" Viewport="0,0,145,145"/>
|
||||
<FontFamily x:Key="Monospace">pack://application:,,,/Resources/Fonts/#Hack</FontFamily>
|
||||
<utils:FontSizeConverter x:Key="SlightlySmallFont" Ratio="0.875"/>
|
||||
<utils:FontSizeConverter x:Key="SlightlyLargerFont" Ratio="1.125"/>
|
||||
|
@ -43,9 +49,10 @@
|
|||
</Window.TaskbarItemInfo>
|
||||
|
||||
<StackPanel Style="{StaticResource WaitCursorWhileBusy}" Background="Transparent">
|
||||
<Grid>
|
||||
<Grid Background="{StaticResource Brush_Bkgrnd}">
|
||||
<Image Source="{StaticResource ImageSource_Banner}" Stretch="None" MouseLeftButtonDown="Image_MouseLeftButtonDown" Name="Banner"/>
|
||||
<Canvas x:Name="Canvas" IsHitTestVisible="False" Visibility="{Binding IsBusyIndicatorVisible, RelativeSource={RelativeSource FindAncestor, AncestorType=Window}, Converter={StaticResource VisibilityConverter}}" Opacity="0.8"/>
|
||||
<Canvas x:Name="Canvas" IsHitTestVisible="False" Visibility="{Binding IsBusyIndicatorVisible, RelativeSource={RelativeSource FindAncestor, AncestorType=Window}, Converter={StaticResource VisibilityConverter}}" MaxWidth="{Binding Path=ActualWidth, ElementName=Banner}" Opacity="0.8"/>
|
||||
<Image Source="{StaticResource ImageSource_Hint}" Stretch="None" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="6" Visibility="Hidden" ToolTip="Software-rendering is enabled!" Name="Hint_SoftwareRendering"/>
|
||||
</Grid>
|
||||
<Separator Margin="0"/>
|
||||
<StackPanel>
|
||||
|
@ -97,6 +104,7 @@
|
|||
<ctrls:ImageButton DockPanel.Dock="Right" Margin="3,0,0,0" Clicked="Button_GeneratePasswd_Click" ImageSource="{StaticResource ImageSource_Die}" ButtonToolTip="Generate random password"/>
|
||||
<ctrls:PasswordToggleBox DockPanel.Dock="Left" EditPadding="3,5,3,5" x:Name="Edit_Encrypt_Password" EditFontFamily="{StaticResource Monospace}" IsRevealed="{Binding IsChecked, ElementName=Button_Encrypt_Toggle}" PasswordChar="*" MaxLength="{x:Static local:SlunkCryptGUI.MAX_PASSWD_LENGTH}" Entered="Edit_Password_Entered"/>
|
||||
</DockPanel>
|
||||
<CheckBox x:Name="Checkbox_Encrypt_LegacyCompat" Content="Enable "legacy" compatibility-mode (version 1.2.x)" ToolTip="This option should *not* be used when encrypting new files!" Margin="0,14,0,0"/>
|
||||
</StackPanel>
|
||||
</TabItem>
|
||||
<TabItem Name="TabItem_Decrypt" Tag="{x:Static local:ModeOfOperation.Decrypt}">
|
||||
|
@ -132,6 +140,7 @@
|
|||
<ctrls:ImageToggleButton DockPanel.Dock="Right" Margin="3,0,0,0" x:Name="Button_Decrypt_Toggle" ImageSourceDefault="{StaticResource ImageSource_Eye1}" ImageSourceChecked="{StaticResource ImageSource_Eye2}" ToolTipDefault="Show password" ToolTipChecked="Hide password"/>
|
||||
<ctrls:PasswordToggleBox DockPanel.Dock="Left" EditPadding="3,5,3,5" x:Name="Edit_Decrypt_Password" EditFontFamily="{StaticResource Monospace}" IsRevealed="{Binding IsChecked, ElementName=Button_Decrypt_Toggle}" PasswordChar="*" MaxLength="{x:Static local:SlunkCryptGUI.MAX_PASSWD_LENGTH}" Entered="Edit_Password_Entered"/>
|
||||
</DockPanel>
|
||||
<CheckBox x:Name="Checkbox_Decrypt_LegacyCompat" Content="Enable "legacy" compatibility-mode (version 1.2.x)" ToolTip="This option *must* be enabled to decrypt files that were in encrypted with version 1.2.x or older!" Margin="0,14,0,0"/>
|
||||
</StackPanel>
|
||||
</TabItem>
|
||||
<TabItem Name="TabItem_LogFile">
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
/* This work has been released under the CC0 1.0 Universal license! */
|
||||
/******************************************************************************/
|
||||
|
||||
using Microsoft.Win32;
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
|
@ -11,15 +12,16 @@ using System.Globalization;
|
|||
using System.IO;
|
||||
using System.Media;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Interop;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Effects;
|
||||
using System.Windows.Shell;
|
||||
using System.Windows.Threading;
|
||||
using Microsoft.Win32;
|
||||
|
||||
using com.muldersoft.slunkcrypt.gui.ctrls;
|
||||
using com.muldersoft.slunkcrypt.gui.process;
|
||||
|
@ -32,7 +34,7 @@ namespace com.muldersoft.slunkcrypt.gui
|
|||
public partial class SlunkCryptGUI : Window, INotifyBusyChanged
|
||||
{
|
||||
private enum Status { Default, Success, Failure }
|
||||
private delegate Task<bool> SlunkProcessor(string inputFile, string outputFile, string password);
|
||||
private delegate Task<bool> SlunkProcessor(string inputFile, string outputFile, string password, bool enableLegacyCompat);
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
public const int MIN_PASSWD_LENGTH = 8, REC_PASSWD_LENGTH = 12, GEN_PASSWD_LENGTH = 24, MAX_PASSWD_LENGTH = 256, MAX_PATH = 259;
|
||||
|
@ -45,6 +47,7 @@ namespace com.muldersoft.slunkcrypt.gui
|
|||
private readonly DispatcherTimer m_dispatcherTimer;
|
||||
private readonly ReadOnlyObservableCollection<string> m_logFileReadOnly;
|
||||
|
||||
private volatile int m_isInitialized = 0;
|
||||
private volatile ModeOfOperation m_modeOfOperation = (ModeOfOperation)(-1);
|
||||
private volatile bool m_busyFlag = false, m_checksumError = false, m_processReceived = false, m_disableAnimation = false;
|
||||
private volatile SlunkCryptRunner m_processRunner = null;
|
||||
|
@ -62,7 +65,7 @@ namespace com.muldersoft.slunkcrypt.gui
|
|||
m_defaultStatusText = Label_Status.Text;
|
||||
m_dispatcherTimer = new DispatcherTimer(DispatcherPriority.ApplicationIdle, Dispatcher);
|
||||
m_dispatcherTimer.Tick += DispatcherTimer_Tick;
|
||||
m_dispatcherTimer.Interval = TimeSpan.FromMilliseconds(200);
|
||||
m_dispatcherTimer.Interval = TimeSpan.FromMilliseconds(331);
|
||||
m_logFileReadOnly = new ReadOnlyObservableCollection<string>(m_logFile);
|
||||
m_disableAnimation = m_config.DisableBusyIndicator;
|
||||
}
|
||||
|
@ -111,9 +114,24 @@ namespace com.muldersoft.slunkcrypt.gui
|
|||
protected override void OnContentRendered(EventArgs e)
|
||||
{
|
||||
base.OnContentRendered(e);
|
||||
TabControl.MinHeight = TabControl.MaxHeight = TabControl.ActualHeight;
|
||||
MinWidth = MaxWidth = ActualWidth;
|
||||
MinHeight = MaxHeight = ActualHeight;
|
||||
if (Interlocked.CompareExchange(ref m_isInitialized, 1, 0) == 0)
|
||||
{
|
||||
TabControl.MinHeight = TabControl.MaxHeight = TabControl.ActualHeight;
|
||||
MinWidth = ActualWidth;
|
||||
MinHeight = MaxHeight = ActualHeight;
|
||||
CreateIndicatorElements();
|
||||
CreateSystemMenu();
|
||||
if (RenderMode.SoftwareOnly.Equals(RenderOptions.ProcessRenderMode))
|
||||
{
|
||||
Hint_SoftwareRendering.Visibility = Visibility.Visible;
|
||||
}
|
||||
if (m_config.LegacyCompat)
|
||||
{
|
||||
Checkbox_Encrypt_LegacyCompat.IsChecked = Checkbox_Decrypt_LegacyCompat.IsChecked = true;
|
||||
}
|
||||
this.DisableMaximizeButton();
|
||||
this.BringWindowToTop();
|
||||
}
|
||||
}
|
||||
|
||||
private void Button_Encrypt_InputFile_Click(object sender, RoutedEventArgs e)
|
||||
|
@ -177,11 +195,11 @@ namespace com.muldersoft.slunkcrypt.gui
|
|||
{
|
||||
case ModeOfOperation.Encrypt:
|
||||
Debug.Assert(m_modeOfOperation == ModeOfOperation.Encrypt);
|
||||
await ValidateInputFile(Edit_Encrypt_InputFile, Edit_Encrypt_OutputFile, Edit_Encrypt_Password, Encrypt, true);
|
||||
await ValidateInputFile(Edit_Encrypt_InputFile, Edit_Encrypt_OutputFile, Edit_Encrypt_Password, Checkbox_Encrypt_LegacyCompat, Encrypt, true);
|
||||
break;
|
||||
case ModeOfOperation.Decrypt:
|
||||
Debug.Assert(m_modeOfOperation == ModeOfOperation.Decrypt);
|
||||
await ValidateInputFile(Edit_Decrypt_InputFile, Edit_Decrypt_OutputFile, Edit_Decrypt_Password, Decrypt, false);
|
||||
await ValidateInputFile(Edit_Decrypt_InputFile, Edit_Decrypt_OutputFile, Edit_Decrypt_Password, Checkbox_Decrypt_LegacyCompat, Decrypt, false);
|
||||
break;
|
||||
default:
|
||||
TabControl.SelectedIndex = GetTabIndexOf(m_modeOfOperation);
|
||||
|
@ -371,19 +389,6 @@ namespace com.muldersoft.slunkcrypt.gui
|
|||
e.Handled = true;
|
||||
}
|
||||
|
||||
private async void Window_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
await Task.Yield();
|
||||
SystemMenu systemMenu = new SystemMenu(this, SystemMenu_Activated);
|
||||
m_menuId_disableAnimation = systemMenu.AppendMenu("Disable Busy Indicator");
|
||||
m_menuId_enableExpertMode = systemMenu.AppendMenu("Expert Settings");
|
||||
if (m_disableAnimation && m_menuId_disableAnimation.HasValue)
|
||||
{
|
||||
systemMenu.ModifyMenu(m_menuId_disableAnimation.Value, m_disableAnimation);
|
||||
}
|
||||
CreateIndicatorElements();
|
||||
}
|
||||
|
||||
private void Window_Closing(object sender, CancelEventArgs e)
|
||||
{
|
||||
if (IsBusy)
|
||||
|
@ -423,7 +428,7 @@ namespace com.muldersoft.slunkcrypt.gui
|
|||
// Internal methods
|
||||
// =============================================================================
|
||||
|
||||
private async Task ValidateInputFile(TextBox inputFileEdit, TextBox outputFileEdit, PasswordToggleBox passwordEdit, SlunkProcessor processor, bool checkStrongPasswd)
|
||||
private async Task ValidateInputFile(TextBox inputFileEdit, TextBox outputFileEdit, PasswordToggleBox passwordEdit, CheckBox legacyCheckBox, SlunkProcessor processor, bool checkStrongPasswd)
|
||||
{
|
||||
string inputFilePath;
|
||||
if (string.IsNullOrEmpty(inputFileEdit.Text = inputFilePath = PathUtils.CleanUpFilePathString(inputFileEdit.Text)))
|
||||
|
@ -450,10 +455,10 @@ namespace com.muldersoft.slunkcrypt.gui
|
|||
SetFocusAndSelectAll(inputFileEdit);
|
||||
return;
|
||||
}
|
||||
await ValidateOutputFile(inputFilePath, outputFileEdit, passwordEdit, processor, checkStrongPasswd);
|
||||
await ValidateOutputFile(inputFilePath, outputFileEdit, passwordEdit, legacyCheckBox, processor, checkStrongPasswd);
|
||||
}
|
||||
|
||||
private async Task ValidateOutputFile(string inputFilePath, TextBox outputFileEdit, PasswordToggleBox passwordEdit, SlunkProcessor processor, bool checkStrongPasswd)
|
||||
private async Task ValidateOutputFile(string inputFilePath, TextBox outputFileEdit, PasswordToggleBox passwordEdit, CheckBox legacyCheckBox, SlunkProcessor processor, bool checkStrongPasswd)
|
||||
{
|
||||
string outputFilePath;
|
||||
if (string.IsNullOrEmpty(outputFileEdit.Text = outputFilePath = PathUtils.CleanUpFilePathString(outputFileEdit.Text)))
|
||||
|
@ -488,11 +493,11 @@ namespace com.muldersoft.slunkcrypt.gui
|
|||
return;
|
||||
}
|
||||
}
|
||||
await ValidateOutputDirectory(inputFilePath, outputFilePath, passwordEdit, processor, checkStrongPasswd);
|
||||
await ValidateOutputDirectory(inputFilePath, outputFilePath, passwordEdit, legacyCheckBox, processor, checkStrongPasswd);
|
||||
|
||||
}
|
||||
|
||||
private async Task ValidateOutputDirectory(string inputFilePath, string outputFilePath, PasswordToggleBox passwordEdit, SlunkProcessor processor, bool checkStrongPasswd)
|
||||
private async Task ValidateOutputDirectory(string inputFilePath, string outputFilePath, PasswordToggleBox passwordEdit, CheckBox legacyCheckBox, SlunkProcessor processor, bool checkStrongPasswd)
|
||||
{
|
||||
string outputDirectory;
|
||||
if (string.IsNullOrEmpty(outputDirectory = PathUtils.TryGetDirectoryName(outputFilePath)))
|
||||
|
@ -512,15 +517,16 @@ namespace com.muldersoft.slunkcrypt.gui
|
|||
return;
|
||||
}
|
||||
}
|
||||
await ValidatePassword(inputFilePath, outputFilePath, passwordEdit, processor, checkStrongPasswd);
|
||||
await ValidatePassword(inputFilePath, outputFilePath, passwordEdit, legacyCheckBox, processor, checkStrongPasswd);
|
||||
}
|
||||
|
||||
private async Task ValidatePassword(string inputFilePath, string outputFilePath, PasswordToggleBox passwordEdit, SlunkProcessor processor, bool checkStrongPasswd)
|
||||
private async Task ValidatePassword(string inputFilePath, string outputFilePath, PasswordToggleBox passwordEdit, CheckBox legacyCheckBox, SlunkProcessor processor, bool checkStrongPasswd)
|
||||
{
|
||||
bool enableLegacyCompat = legacyCheckBox.IsChecked.GetValueOrDefault();
|
||||
string passwordStr;
|
||||
if (string.IsNullOrEmpty(passwordStr = passwordEdit.Password) || (passwordStr.Length < MIN_PASSWD_LENGTH))
|
||||
{
|
||||
MessageBox.Show(this, String.Format("Passphrase must be at least {0:D} characters in length!", MIN_PASSWD_LENGTH), "Passphrase Missing", MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||
MessageBox.Show(this, string.Format("Passphrase must be at least {0:D} characters in length!", MIN_PASSWD_LENGTH), "Passphrase Missing", MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||
SetFocusAndSelectAll(passwordEdit);
|
||||
return;
|
||||
}
|
||||
|
@ -528,7 +534,7 @@ namespace com.muldersoft.slunkcrypt.gui
|
|||
{
|
||||
if (passwordStr.Length < REC_PASSWD_LENGTH)
|
||||
{
|
||||
if (MessageBox.Show(this, String.Format("Recommended passphrase length is at least {0:D} characters!", REC_PASSWD_LENGTH), "Short Passphrase", MessageBoxButton.OKCancel, MessageBoxImage.Warning, MessageBoxResult.Cancel) != MessageBoxResult.OK)
|
||||
if (MessageBox.Show(this, string.Format("Recommended passphrase length is at least {0:D} characters!", REC_PASSWD_LENGTH), "Short Passphrase", MessageBoxButton.OKCancel, MessageBoxImage.Warning, MessageBoxResult.Cancel) != MessageBoxResult.OK)
|
||||
{
|
||||
SetFocusAndSelectAll(passwordEdit);
|
||||
return;
|
||||
|
@ -542,11 +548,19 @@ namespace com.muldersoft.slunkcrypt.gui
|
|||
return;
|
||||
}
|
||||
}
|
||||
if (enableLegacyCompat && (!m_config.LegacyCompat))
|
||||
{
|
||||
if (MessageBox.Show(this, "Legacy compat-mode should not be used to encrypt new files!", "Legacy Compatibility", MessageBoxButton.OKCancel, MessageBoxImage.Warning, MessageBoxResult.Cancel) != MessageBoxResult.OK)
|
||||
{
|
||||
legacyCheckBox.Focus();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
await InvokeProcessor(inputFilePath, outputFilePath, passwordStr, processor);
|
||||
await InvokeProcessor(inputFilePath, outputFilePath, passwordStr, processor, enableLegacyCompat);
|
||||
}
|
||||
|
||||
private async Task InvokeProcessor(string inputFile, string outputFile, string password, SlunkProcessor processor)
|
||||
private async Task InvokeProcessor(string inputFile, string outputFile, string password, SlunkProcessor processor, bool enableLegacyCompat)
|
||||
{
|
||||
using (BusyManager busyManager = new BusyManager(this))
|
||||
{
|
||||
|
@ -554,7 +568,7 @@ namespace com.muldersoft.slunkcrypt.gui
|
|||
SetProgress(double.PositiveInfinity);
|
||||
ClearLogFile();
|
||||
Button_Decrypt_Toggle.IsChecked = Button_Encrypt_Toggle.IsChecked = m_checksumError = m_processReceived = false;
|
||||
if (!await processor(inputFile, outputFile, password))
|
||||
if (!await processor(inputFile, outputFile, password, enableLegacyCompat))
|
||||
{
|
||||
if (!m_config.KeepIncompleteFiles)
|
||||
{
|
||||
|
@ -566,10 +580,10 @@ namespace com.muldersoft.slunkcrypt.gui
|
|||
}
|
||||
}
|
||||
|
||||
private async Task<bool> Encrypt(string inputFile, string outputFile, string password)
|
||||
private async Task<bool> Encrypt(string inputFile, string outputFile, string password, bool enableLegacyCompat)
|
||||
{
|
||||
SetStatus("Please wait while the encryption process is initializing...");
|
||||
int? exitCode = await RunProcess(SlunkCryptRunner.Mode.Encrypt, inputFile, outputFile, password);
|
||||
int? exitCode = await RunProcess(SlunkCryptRunner.Mode.Encrypt, inputFile, outputFile, password, enableLegacyCompat);
|
||||
if (exitCode.HasValue)
|
||||
{
|
||||
if (exitCode.Value == 0)
|
||||
|
@ -589,10 +603,10 @@ namespace com.muldersoft.slunkcrypt.gui
|
|||
return false;
|
||||
}
|
||||
|
||||
private async Task<bool> Decrypt(string inputFile, string outputFile, string password)
|
||||
private async Task<bool> Decrypt(string inputFile, string outputFile, string password, bool enableLegacyCompat)
|
||||
{
|
||||
SetStatus("Please wait while the decryption process is initializing...");
|
||||
int? exitCode = await RunProcess(SlunkCryptRunner.Mode.Decrypt, inputFile, outputFile, password);
|
||||
int? exitCode = await RunProcess(SlunkCryptRunner.Mode.Decrypt, inputFile, outputFile, password, enableLegacyCompat);
|
||||
if (exitCode.HasValue)
|
||||
{
|
||||
if (exitCode.Value == 0)
|
||||
|
@ -619,7 +633,7 @@ namespace com.muldersoft.slunkcrypt.gui
|
|||
return false;
|
||||
}
|
||||
|
||||
private async Task<int?> RunProcess(SlunkCryptRunner.Mode mode, string inputFile, string outputFile, string password)
|
||||
private async Task<int?> RunProcess(SlunkCryptRunner.Mode mode, string inputFile, string outputFile, string password, bool enableLegacyCompat)
|
||||
{
|
||||
if (!ReferenceEquals(m_processRunner, null))
|
||||
{
|
||||
|
@ -627,7 +641,7 @@ namespace com.muldersoft.slunkcrypt.gui
|
|||
}
|
||||
try
|
||||
{
|
||||
SlunkCryptRunner.SlunkOptions options = new SlunkCryptRunner.SlunkOptions(m_config.KeepIncompleteFiles, m_config.ThreadCount);
|
||||
SlunkCryptRunner.SlunkOptions options = new SlunkCryptRunner.SlunkOptions(m_config.KeepIncompleteFiles, m_config.ThreadCount, enableLegacyCompat);
|
||||
using (m_processRunner = new SlunkCryptRunner(Dispatcher))
|
||||
{
|
||||
m_processRunner.OutputAvailable += Process_OutputAvailable;
|
||||
|
@ -762,6 +776,17 @@ namespace com.muldersoft.slunkcrypt.gui
|
|||
return null;
|
||||
}
|
||||
|
||||
private void CreateSystemMenu()
|
||||
{
|
||||
SystemMenu systemMenu = new SystemMenu(this, SystemMenu_Activated);
|
||||
m_menuId_disableAnimation = systemMenu.AppendMenu("Disable Busy Indicator");
|
||||
m_menuId_enableExpertMode = systemMenu.AppendMenu("Expert Settings");
|
||||
if (m_disableAnimation && m_menuId_disableAnimation.HasValue)
|
||||
{
|
||||
systemMenu.ModifyMenu(m_menuId_disableAnimation.Value, m_disableAnimation);
|
||||
}
|
||||
}
|
||||
|
||||
private void CreateIndicatorElements()
|
||||
{
|
||||
FontFamily hackFont = new FontFamily(new Uri("pack://application:,,,/"), "./Resources/Fonts/#Hack");
|
||||
|
@ -776,6 +801,7 @@ namespace com.muldersoft.slunkcrypt.gui
|
|||
int numY = (int)Math.Floor(actualHeight / lenY);
|
||||
int offX = (int)Math.Round((actualWidth - (numX * lenX)) / 2.0);
|
||||
int offY = (int)Math.Round((actualHeight - (numY * lenY)) / 2.0);
|
||||
Canvas.Children.Clear();
|
||||
for (int i = 0; i < numX; ++i)
|
||||
{
|
||||
for (int j = 0; j < numY; ++j)
|
||||
|
@ -852,7 +878,7 @@ namespace com.muldersoft.slunkcrypt.gui
|
|||
CPUFeatures cpuFeatures = CPUFeatures.Features;
|
||||
return new StringBuilder()
|
||||
.AppendLine("SlunkCrypt, by LoRd_MuldeR <MuldeR2@GMX.de>")
|
||||
.AppendLine(VersionInfo.VersionStr)
|
||||
.AppendLine(VersionInfo.ToString())
|
||||
.AppendLine("This work has been released under the \u201CCC0 1.0\u201D license!")
|
||||
.AppendLine()
|
||||
.AppendLine("Official web-site: http://slunkcrypt.osdn.io/")
|
||||
|
@ -860,7 +886,7 @@ namespace com.muldersoft.slunkcrypt.gui
|
|||
.AppendLine(Environment.OSVersion.VersionString)
|
||||
.AppendLine(string.Format("Operating System Bitness: {0:D}, Process Bitness: {1:D}", Environment.Is64BitOperatingSystem ? 64 : 32, Environment.Is64BitProcess ? 64 : 32))
|
||||
.AppendLine(".NET Runtime Version: " + Environment.Version)
|
||||
.AppendLine(string.Format("CPU Count: {0:D}, Architecture: {1}, SSE2: {2}, AVX2: {3}", Environment.ProcessorCount, cpuFeatures.x64 ? "x64" : "x86", cpuFeatures.hasSSE2 ? "Yes" : "No", cpuFeatures.hasAVX2 ? "Yes" : "No"))
|
||||
.AppendLine(string.Format("CPU Count: {0:D}, Architecture: {1}, SSE2: {2}, AVX2: {3}", Environment.ProcessorCount, cpuFeatures.cpuArch.GetDescription(), cpuFeatures.hasSSE2 ? "Yes" : "No", cpuFeatures.hasAVX2 ? "Yes" : "No"))
|
||||
.AppendLine()
|
||||
.AppendLine("Using “Silk” icons, by Mark James")
|
||||
.ToString();
|
||||
|
|
|
@ -38,6 +38,14 @@ namespace com.muldersoft.slunkcrypt.gui.utils
|
|||
}
|
||||
}
|
||||
|
||||
public bool LegacyCompat
|
||||
{
|
||||
get
|
||||
{
|
||||
return ComputeIfAbsent("LegacyCompat", (key) => AppConfHelper.GetConfigValueAsBool(key).GetValueOrDefault(false));
|
||||
}
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
// Internal methods
|
||||
// =============================================================================
|
||||
|
|
|
@ -16,7 +16,8 @@ namespace com.muldersoft.slunkcrypt.gui.utils.cpu
|
|||
public enum CPUArchitecture : uint
|
||||
{
|
||||
CPU_ARCH_X86 = 0x00000001,
|
||||
CPU_ARCH_X64 = 0x00000002
|
||||
CPU_ARCH_X64 = 0x00000002,
|
||||
CPU_ARCH_A64 = 0x00000003
|
||||
}
|
||||
|
||||
[Flags]
|
||||
|
@ -193,6 +194,23 @@ namespace com.muldersoft.slunkcrypt.gui.utils.cpu
|
|||
|
||||
private static CPUArchitecture GetCPUArchitecture()
|
||||
{
|
||||
try
|
||||
{
|
||||
ushort processMachine, nativeMachine;
|
||||
if (Internal.IsWow64Process2(Internal.GetCurrentProcess(), out processMachine, out nativeMachine))
|
||||
{
|
||||
switch(nativeMachine)
|
||||
{
|
||||
case 0x8664:
|
||||
return CPUArchitecture.CPU_ARCH_X64;
|
||||
case 0xAA64:
|
||||
return CPUArchitecture.CPU_ARCH_A64;
|
||||
default:
|
||||
return CPUArchitecture.CPU_ARCH_X86;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
try
|
||||
{
|
||||
VerifyLibraryVersion();
|
||||
|
@ -305,10 +323,11 @@ namespace com.muldersoft.slunkcrypt.gui.utils.cpu
|
|||
// P/Invoke methods
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
private class Internal
|
||||
private static class Internal
|
||||
{
|
||||
const string DLL_NAME_X86 = "cpu-capabilities-x86.dll";
|
||||
const string DLL_NAME_X64 = "cpu-capabilities-x64.dll";
|
||||
private const string DLL_NAME_X86 = "cpu-capabilities-x86.dll";
|
||||
private const string DLL_NAME_X64 = "cpu-capabilities-x64.dll";
|
||||
private const string DLL_KERNEL32 = "kernel32.dll";
|
||||
|
||||
/* GetCPUArchitecture() */
|
||||
[DllImport(DLL_NAME_X64, CallingConvention = CallingConvention.Cdecl)]
|
||||
|
@ -351,6 +370,12 @@ namespace com.muldersoft.slunkcrypt.gui.utils.cpu
|
|||
public static extern uint GetCPULibraryVersionX64();
|
||||
[DllImport(DLL_NAME_X86, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern uint GetCPULibraryVersionX86();
|
||||
|
||||
/* IsWow64Process2() */
|
||||
[DllImport(DLL_KERNEL32, EntryPoint = "IsWow64Process2", ExactSpelling = true)]
|
||||
public static extern bool IsWow64Process2(IntPtr process, out ushort processMachine, out ushort nativeMachine);
|
||||
[DllImport(DLL_KERNEL32, EntryPoint = "GetCurrentProcess", ExactSpelling = true)]
|
||||
public static extern IntPtr GetCurrentProcess();
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
|
|
@ -4,15 +4,22 @@
|
|||
/******************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using com.muldersoft.slunkcrypt.gui.utils.cpu;
|
||||
|
||||
namespace com.muldersoft.slunkcrypt.gui.process
|
||||
{
|
||||
struct CPUFeatures
|
||||
{
|
||||
public readonly bool x64;
|
||||
public readonly bool hasSSE2;
|
||||
public readonly bool hasAVX2;
|
||||
public enum CPUArch
|
||||
{
|
||||
[Description("x86")] x86 = 0x1,
|
||||
[Description("x64")] x64 = 0x2,
|
||||
[Description("ARM64")] a64 = 0x3
|
||||
}
|
||||
|
||||
public readonly CPUArch cpuArch;
|
||||
public readonly bool hasSSE2, hasAVX2;
|
||||
|
||||
private static readonly Lazy<CPUFeatures> cpuFeatures = new Lazy<CPUFeatures>(DetectFeatures);
|
||||
|
||||
|
@ -21,26 +28,30 @@ namespace com.muldersoft.slunkcrypt.gui.process
|
|||
get { return cpuFeatures.Value; }
|
||||
}
|
||||
|
||||
public CPUFeatures(bool x64, bool sse2, bool avx2)
|
||||
public CPUFeatures(CPUArch cpuArch, bool hasSSE2, bool hasAVX2)
|
||||
{
|
||||
this.x64 = x64;
|
||||
this.hasSSE2 = sse2;
|
||||
this.hasAVX2 = avx2;
|
||||
this.cpuArch = cpuArch;
|
||||
this.hasSSE2 = hasSSE2;
|
||||
this.hasAVX2 = hasAVX2;
|
||||
}
|
||||
|
||||
private static CPUFeatures DetectFeatures()
|
||||
{
|
||||
try
|
||||
{
|
||||
return new CPUFeatures(
|
||||
CPU.Architecture.Equals(CPUArchitecture.CPU_ARCH_X64),
|
||||
CPU.Capabilities.HasFlag(CPUCapabilities.CPU_SSE2),
|
||||
CPU.Capabilities.HasFlag(CPUCapabilities.CPU_AVX2));
|
||||
}
|
||||
catch
|
||||
{
|
||||
return new CPUFeatures(false, false, false); /*fallback*/
|
||||
CPUArchitecture cpuArchitecture = CPU.Architecture;
|
||||
switch(cpuArchitecture)
|
||||
{
|
||||
case CPUArchitecture.CPU_ARCH_X86:
|
||||
return new CPUFeatures(CPUArch.x86, CPU.Capabilities.HasFlag(CPUCapabilities.CPU_SSE2), CPU.Capabilities.HasFlag(CPUCapabilities.CPU_AVX2));
|
||||
case CPUArchitecture.CPU_ARCH_X64:
|
||||
return new CPUFeatures(CPUArch.x64, CPU.Capabilities.HasFlag(CPUCapabilities.CPU_SSE2), CPU.Capabilities.HasFlag(CPUCapabilities.CPU_AVX2));
|
||||
case CPUArchitecture.CPU_ARCH_A64:
|
||||
return new CPUFeatures(CPUArch.a64, false, false);
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
return new CPUFeatures(CPUArch.x86, false, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
/******************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Reflection;
|
||||
|
||||
namespace com.muldersoft.slunkcrypt.gui.utils
|
||||
{
|
||||
|
@ -20,5 +22,25 @@ namespace com.muldersoft.slunkcrypt.gui.utils
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetDescription(this Enum value)
|
||||
{
|
||||
Type type = value.GetType();
|
||||
string name = Enum.GetName(type, value);
|
||||
if (!string.IsNullOrEmpty(name))
|
||||
{
|
||||
FieldInfo field = type.GetField(name);
|
||||
if (!ReferenceEquals(field, null))
|
||||
{
|
||||
DescriptionAttribute attr = Attribute.GetCustomAttribute(field, typeof(DescriptionAttribute)) as DescriptionAttribute;
|
||||
if (!ReferenceEquals(attr, null))
|
||||
{
|
||||
return attr.Description;
|
||||
}
|
||||
}
|
||||
return name;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -160,6 +160,8 @@ namespace com.muldersoft.slunkcrypt.gui.utils
|
|||
|
||||
private class Native
|
||||
{
|
||||
private const string DLL_USER32 = "user32.dll";
|
||||
|
||||
[Flags]
|
||||
public enum MenuFlags : uint
|
||||
{
|
||||
|
@ -171,13 +173,13 @@ namespace com.muldersoft.slunkcrypt.gui.utils
|
|||
MF_SEPARATOR = 0x0800
|
||||
}
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
[DllImport(DLL_USER32, CharSet = CharSet.Unicode, EntryPoint = "GetSystemMenu", ExactSpelling = true)]
|
||||
public static extern IntPtr GetSystemMenu(IntPtr hWnd, bool bRevert);
|
||||
|
||||
[DllImport("user32.dll", CharSet = CharSet.Auto)]
|
||||
[DllImport(DLL_USER32, CharSet = CharSet.Unicode, EntryPoint = "AppendMenuW", ExactSpelling = true)]
|
||||
public static extern bool AppendMenu(IntPtr hMenu, MenuFlags uFlags, UIntPtr uIDNewItem, string lpNewItem);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
[DllImport(DLL_USER32, CharSet = CharSet.Unicode, EntryPoint = "ModifyMenuW", ExactSpelling = true)]
|
||||
public static extern bool ModifyMenu(IntPtr hMenu, uint uPosition, MenuFlags uFlags, UIntPtr uIDNewItem, string lpNewItem);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,49 +10,60 @@ namespace com.muldersoft.slunkcrypt.gui.utils
|
|||
{
|
||||
static class VersionInfo
|
||||
{
|
||||
private static readonly Lazy<Version> m_version = new Lazy<Version>(GetAssemblyVersion);
|
||||
private static readonly Lazy<string> m_versionStr = new Lazy<string>(InitVersionString);
|
||||
private static readonly Lazy<Version> m_version = new Lazy<Version> (InitializeVersion);
|
||||
private static readonly Lazy<DateTime> m_buildDateTime = new Lazy<DateTime>(InitializeBuildDateTime);
|
||||
|
||||
// =============================================================================
|
||||
// Properties
|
||||
// =============================================================================
|
||||
|
||||
public static Version Version
|
||||
{
|
||||
get { return m_version.Value; }
|
||||
}
|
||||
public static Version Version { get { return m_version.Value; } }
|
||||
|
||||
public static string VersionStr
|
||||
public static DateTime BuildDate { get { return m_buildDateTime.Value; } }
|
||||
|
||||
public static new string ToString()
|
||||
{
|
||||
get { return m_versionStr.Value; }
|
||||
Version version = m_version.Value;
|
||||
return string.Format(
|
||||
(version.Revision > 0) ? "Version {0:D}.{1:D}.{2:D}, built on {3}" : "Version {0:D}.{1:D}, built on {3}",
|
||||
version.Major, version.Minor, version.Revision, BuildDate.ToString("yyyy-MM-dd"));
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
// Internal methods
|
||||
// =============================================================================
|
||||
|
||||
private static Version GetAssemblyVersion()
|
||||
private static Version InitializeVersion()
|
||||
{
|
||||
try
|
||||
{
|
||||
return Assembly.GetExecutingAssembly().GetName().Version;
|
||||
AssemblyFileVersionAttribute fileVersionAttribute = Attribute.GetCustomAttribute(Assembly.GetExecutingAssembly(), typeof(AssemblyFileVersionAttribute), false) as AssemblyFileVersionAttribute;
|
||||
Version fileVersion;
|
||||
if (Version.TryParse(fileVersionAttribute?.Version, out fileVersion))
|
||||
{
|
||||
return fileVersion;
|
||||
}
|
||||
else
|
||||
{
|
||||
return Assembly.GetExecutingAssembly().GetName().Version;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
return new Version();
|
||||
return new Version(0, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
private static string InitVersionString()
|
||||
private static DateTime InitializeBuildDateTime()
|
||||
{
|
||||
try
|
||||
{
|
||||
DateTime buildDate = new DateTime(2000, 1, 1).Add(new TimeSpan(TimeSpan.TicksPerDay * Version.Build + TimeSpan.TicksPerSecond * 2 * Version.Revision));
|
||||
return String.Format("Version {0:D}.{1:D}, built on {2}", Version.Major, Version.Minor, buildDate.ToString("yyyy-MM-dd"));
|
||||
Version version = Assembly.GetExecutingAssembly().GetName().Version;
|
||||
return new DateTime(2000, 1, 1).Add(new TimeSpan(TimeSpan.TicksPerDay * version.Build + TimeSpan.TicksPerSecond * 2 * version.Revision));
|
||||
}
|
||||
catch
|
||||
{
|
||||
return "Unknown version";
|
||||
return new DateTime(1928, 6, 14, 0, 0, 0, DateTimeKind.Utc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,99 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows;
|
||||
using System.Windows.Interop;
|
||||
|
||||
namespace com.muldersoft.slunkcrypt.gui.utils
|
||||
{
|
||||
public static class WindowHelper
|
||||
{
|
||||
private static readonly IEnumerable<bool> enableTopmost = Array.AsReadOnly(new bool[] { true, false });
|
||||
|
||||
public static void BringWindowToTop(this Window window)
|
||||
{
|
||||
if (!ReferenceEquals(window, null))
|
||||
{
|
||||
try
|
||||
{
|
||||
WindowInteropHelper interopHelper = new WindowInteropHelper(window);
|
||||
NativeMethods.BringWindowToTop(interopHelper.Handle);
|
||||
if (!NativeMethods.SetForegroundWindow(interopHelper.Handle))
|
||||
{
|
||||
foreach (bool flag in enableTopmost)
|
||||
{
|
||||
window.Topmost = flag;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
}
|
||||
|
||||
public static void DisableMaximizeButton(this Window window)
|
||||
{
|
||||
if (!ReferenceEquals(window, null))
|
||||
{
|
||||
const int GWL_STYLE = -16;
|
||||
const ulong WS_MAXIMIZEBOX = 0x10000;
|
||||
try
|
||||
{
|
||||
WindowInteropHelper interopHelper = new WindowInteropHelper(window);
|
||||
ulong value = NativeMethods.GetWindowLongPtr(interopHelper.Handle, GWL_STYLE);
|
||||
if (value != 0UL)
|
||||
{
|
||||
NativeMethods.SetWindowLongPtr(interopHelper.Handle, GWL_STYLE, value & (~WS_MAXIMIZEBOX));
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
}
|
||||
|
||||
private static class NativeMethods
|
||||
{
|
||||
private const string DLL_USER32 = "user32.dll";
|
||||
|
||||
[DllImport(DLL_USER32, CharSet = CharSet.Unicode, EntryPoint = "BringWindowToTop", ExactSpelling = true)]
|
||||
public static extern bool BringWindowToTop(IntPtr hWnd);
|
||||
|
||||
[DllImport(DLL_USER32, CharSet = CharSet.Unicode, EntryPoint = "SetForegroundWindow", ExactSpelling = true)]
|
||||
public static extern bool SetForegroundWindow(IntPtr hWnd);
|
||||
|
||||
[DllImport(DLL_USER32, CharSet = CharSet.Unicode, EntryPoint = "GetWindowLongW", ExactSpelling = true)]
|
||||
private static extern UIntPtr GetWindowLongPtr32(IntPtr hWnd, int nIndex);
|
||||
|
||||
[DllImport(DLL_USER32, CharSet = CharSet.Unicode, EntryPoint = "GetWindowLongPtrW", ExactSpelling = true)]
|
||||
private static extern UIntPtr GetWindowLongPtr64(IntPtr hWnd, int nIndex);
|
||||
|
||||
[DllImport(DLL_USER32, CharSet = CharSet.Unicode, EntryPoint = "SetWindowLongW", ExactSpelling = true)]
|
||||
private static extern UIntPtr SetWindowLongPtr32(IntPtr hWnd, int nIndex, UIntPtr dwNewLong);
|
||||
|
||||
[DllImport(DLL_USER32, CharSet = CharSet.Unicode, EntryPoint = "SetWindowLongPtrW", ExactSpelling = true)]
|
||||
private static extern UIntPtr SetWindowLongPtr64(IntPtr hWnd, int nIndex, UIntPtr dwNewLong);
|
||||
|
||||
public static ulong GetWindowLongPtr(IntPtr hWnd, int nIndex)
|
||||
{
|
||||
if (IntPtr.Size >= 8)
|
||||
{
|
||||
return GetWindowLongPtr64(hWnd, nIndex).ToUInt64();
|
||||
}
|
||||
else
|
||||
{
|
||||
return GetWindowLongPtr32(hWnd, nIndex).ToUInt64();
|
||||
}
|
||||
}
|
||||
|
||||
public static void SetWindowLongPtr(IntPtr hWnd, int nIndex, ulong dwNewLong)
|
||||
{
|
||||
if (IntPtr.Size >= 8)
|
||||
{
|
||||
SetWindowLongPtr64(hWnd, nIndex, new UIntPtr(dwNewLong));
|
||||
}
|
||||
else
|
||||
{
|
||||
SetWindowLongPtr32(hWnd, nIndex, new UIntPtr(dwNewLong));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -56,6 +56,12 @@ extern "C" {
|
|||
typedef uintptr_t slunkcrypt_t;
|
||||
#define SLUNKCRYPT_NULL ((slunkcrypt_t)NULL)
|
||||
|
||||
/*
|
||||
* Boolean flags
|
||||
*/
|
||||
static const int SLUNKCRYPT_FALSE = 0;
|
||||
static const int SLUNKCRYPT_TRUE = 1;
|
||||
|
||||
/*
|
||||
* Mode of operation
|
||||
*/
|
||||
|
@ -78,11 +84,13 @@ static const size_t SLUNKCRYPT_PWDLEN_MAX = 256U;
|
|||
/*
|
||||
* Optional parameters
|
||||
*/
|
||||
static const uint16_t SLUNKCRYPT_PARAM_VERSION = 1U;
|
||||
static const uint16_t SLUNKCRYPT_PARAM_VERSION = 2U;
|
||||
typedef struct
|
||||
{
|
||||
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;
|
||||
|
||||
|
@ -98,6 +106,11 @@ SLUNKCRYPT_API extern const uint16_t SLUNKCRYPT_VERSION_PATCH;
|
|||
*/
|
||||
SLUNKCRYPT_API extern const char *const SLUNKCRYPT_BUILD;
|
||||
|
||||
/*
|
||||
* Configuration
|
||||
*/
|
||||
SLUNKCRYPT_API extern const int SLUNKCRYPT_HAVE_THREADS;
|
||||
|
||||
/*
|
||||
* Abort flag
|
||||
*/
|
||||
|
|
|
@ -33,11 +33,13 @@ namespace slunkcrypt
|
|||
class SlunkBase
|
||||
{
|
||||
public:
|
||||
SlunkBase(const size_t thread_count)
|
||||
SlunkBase(const size_t thread_count, const bool legacy_compat, const bool debug_logging)
|
||||
{
|
||||
std::memset(&m_param, 0, sizeof(m_param));
|
||||
m_param.version = ::SLUNKCRYPT_PARAM_VERSION;
|
||||
m_param.thread_count = thread_count;
|
||||
m_param.legacy_compat = legacy_compat ? SLUNKCRYPT_TRUE : SLUNKCRYPT_FALSE;
|
||||
m_param.debug_logging = debug_logging ? SLUNKCRYPT_TRUE : SLUNKCRYPT_FALSE;
|
||||
}
|
||||
|
||||
virtual bool process(const uint8_t *const input, uint8_t *const output, size_t length) = 0;
|
||||
|
@ -56,7 +58,8 @@ namespace slunkcrypt
|
|||
class Encryptor : public SlunkBase
|
||||
{
|
||||
public:
|
||||
Encryptor(const std::string &passwd, const size_t thread_count = 0U) : SlunkBase(thread_count)
|
||||
Encryptor(const std::string &passwd, const size_t thread_count = 0U, const bool legacy_compat = false, const bool debug_logging = false)
|
||||
: SlunkBase(thread_count, legacy_compat, debug_logging)
|
||||
{
|
||||
if (::slunkcrypt_generate_nonce(&m_nonce) != SLUNKCRYPT_SUCCESS)
|
||||
{
|
||||
|
@ -117,7 +120,8 @@ namespace slunkcrypt
|
|||
class Decryptor : public SlunkBase
|
||||
{
|
||||
public:
|
||||
Decryptor(const std::string &passwd, const uint64_t nonce, const size_t thread_count = 0U) : SlunkBase(thread_count)
|
||||
Decryptor(const std::string &passwd, const uint64_t nonce, const size_t thread_count = 0U, const bool legacy_compat = false, const bool debug_logging = false)
|
||||
: SlunkBase(thread_count, legacy_compat, debug_logging)
|
||||
{
|
||||
if ((m_instance = ::slunkcrypt_alloc_ext(nonce, (const uint8_t*)passwd.c_str(), passwd.length(), SLUNKCRYPT_DECRYPT, &m_param)) == SLUNKCRYPT_NULL)
|
||||
{
|
||||
|
|
|
@ -1,10 +1,22 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|ARM64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>ARM64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release_DLL|ARM64">
|
||||
<Configuration>Release_DLL</Configuration>
|
||||
<Platform>ARM64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release_SSE2|ARM64">
|
||||
<Configuration>Release_SSE2</Configuration>
|
||||
<Platform>ARM64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release_SSE2|Win32">
|
||||
<Configuration>Release_SSE2</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
|
@ -21,6 +33,10 @@
|
|||
<Configuration>Release_DLL</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|ARM64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>ARM64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
|
@ -35,6 +51,7 @@
|
|||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="src\debug.c" />
|
||||
<ClCompile Include="src\junk.c" />
|
||||
<ClCompile Include="src\keygen.c" />
|
||||
<ClCompile Include="src\slunkcrypt.c" />
|
||||
|
@ -44,6 +61,8 @@
|
|||
<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" />
|
||||
<ClInclude Include="src\version.h" />
|
||||
|
@ -53,60 +72,90 @@
|
|||
<Keyword>Win32Proj</Keyword>
|
||||
<ProjectGuid>{a4a3879c-bd2c-4304-af66-7349cef7e4c0}</ProjectGuid>
|
||||
<RootNamespace>libSlunkCrypt</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0.14393.0</WindowsTargetPlatformVersion>
|
||||
<WindowsTargetPlatformVersion>10.0.19041.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup>
|
||||
<PreferredToolArchitecture>x64</PreferredToolArchitecture>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release_SSE2|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release_DLL|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release_SSE2|x64'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release_SSE2|ARM64'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release_DLL|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release_DLL|ARM64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
|
@ -135,18 +184,34 @@
|
|||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\Slunk.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\Slunk.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\Slunk.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\Slunk.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release_SSE2|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\Slunk.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release_SSE2|ARM64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\Slunk.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release_DLL|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\Slunk.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release_DLL|ARM64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\Slunk.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
|
@ -178,24 +243,48 @@
|
|||
<IntDir>$(SolutionDir)obj\$(Configuration)\$(PlatformShortName)\$(ProjectName)\</IntDir>
|
||||
<TargetName>libslunkcrypt-1-x64</TargetName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">
|
||||
<TargetName>libslunkcrypt-1-arm64</TargetName>
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<IntDir>$(SolutionDir)obj\$(Configuration)\$(PlatformShortName)\$(ProjectName)\</IntDir>
|
||||
<OutDir>$(SolutionDir)bin\debug\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)bin\static\</OutDir>
|
||||
<IntDir>$(SolutionDir)obj\$(Configuration)\$(PlatformShortName)\$(ProjectName)\</IntDir>
|
||||
<TargetName>libslunkcrypt-1-x64</TargetName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
|
||||
<TargetName>libslunkcrypt-1-arm64</TargetName>
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<IntDir>$(SolutionDir)obj\$(Configuration)\$(PlatformShortName)\$(ProjectName)\</IntDir>
|
||||
<OutDir>$(SolutionDir)bin\static\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release_SSE2|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)bin\static\</OutDir>
|
||||
<IntDir>$(SolutionDir)obj\$(Configuration)\$(PlatformShortName)\$(ProjectName)\</IntDir>
|
||||
<TargetName>libslunkcrypt-1-avx2</TargetName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release_SSE2|ARM64'">
|
||||
<TargetName>libslunkcrypt-1-arm64</TargetName>
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<IntDir>$(SolutionDir)obj\$(Configuration)\$(PlatformShortName)\$(ProjectName)\</IntDir>
|
||||
<OutDir>$(SolutionDir)bin\static\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release_DLL|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)bin\shared\</OutDir>
|
||||
<IntDir>$(SolutionDir)obj\$(Configuration)\$(PlatformShortName)\$(ProjectName)\</IntDir>
|
||||
<TargetName>libslunkcrypt-1-x64</TargetName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release_DLL|ARM64'">
|
||||
<TargetName>libslunkcrypt-1-arm64</TargetName>
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<IntDir>$(SolutionDir)obj\$(Configuration)\$(PlatformShortName)\$(ProjectName)\</IntDir>
|
||||
<OutDir>$(SolutionDir)bin\shared\</OutDir>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
|
@ -307,6 +396,7 @@
|
|||
<SubSystem>Console</SubSystem>
|
||||
<AdditionalLibraryDirectories>$(ProjectDir)..\etc\deps\pthreads4w\lib\msvc-v141\shared\i686;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>pthreadVC3.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<MinimumRequiredVersion>5.1</MinimumRequiredVersion>
|
||||
</Link>
|
||||
<PostBuildEvent>
|
||||
<Command>copy /Y /B "$(ProjectDir)..\etc\deps\pthreads4w\bin\msvc-v141\pthreadVC3-i686.dll" "$(TargetDir)"</Command>
|
||||
|
@ -331,6 +421,24 @@
|
|||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)include;$(ProjectDir)..\etc\deps\pthreads4w\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<DisableSpecificWarnings>4706;4204</DisableSpecificWarnings>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>
|
||||
</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
|
@ -363,6 +471,38 @@
|
|||
<LinkTimeCodeGeneration>true</LinkTimeCodeGeneration>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)include;$(ProjectDir)..\etc\deps\pthreads4w\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
<OmitFramePointers>true</OmitFramePointers>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||
<FloatingPointModel>Fast</FloatingPointModel>
|
||||
<DisableSpecificWarnings>4706;4204</DisableSpecificWarnings>
|
||||
<CreateHotpatchableImage>false</CreateHotpatchableImage>
|
||||
<EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>
|
||||
</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
<Lib>
|
||||
<LinkTimeCodeGeneration>true</LinkTimeCodeGeneration>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release_SSE2|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
|
@ -395,6 +535,38 @@
|
|||
<LinkTimeCodeGeneration>true</LinkTimeCodeGeneration>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release_SSE2|ARM64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)include;$(ProjectDir)..\etc\deps\pthreads4w\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
<OmitFramePointers>true</OmitFramePointers>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||
<FloatingPointModel>Fast</FloatingPointModel>
|
||||
<DisableSpecificWarnings>4706;4204</DisableSpecificWarnings>
|
||||
<CreateHotpatchableImage>false</CreateHotpatchableImage>
|
||||
<EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>
|
||||
</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
<Lib>
|
||||
<LinkTimeCodeGeneration>true</LinkTimeCodeGeneration>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release_DLL|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
|
@ -424,6 +596,45 @@
|
|||
<SubSystem>Console</SubSystem>
|
||||
<AdditionalLibraryDirectories>$(ProjectDir)..\etc\deps\pthreads4w\lib\msvc-v141\shared\x64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>pthreadVC3.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<MinimumRequiredVersion>5.2</MinimumRequiredVersion>
|
||||
</Link>
|
||||
<PostBuildEvent>
|
||||
<Command>copy /Y /B "$(ProjectDir)..\etc\deps\pthreads4w\bin\msvc-v141\pthreadVC3-x64.dll" "$(TargetDir)"</Command>
|
||||
</PostBuildEvent>
|
||||
<PostBuildEvent>
|
||||
<Message>Copy DLL dependencies...</Message>
|
||||
</PostBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release_DLL|ARM64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>NDEBUG;_DLL;SLUNKCRYPT_SHARED=1;SLUNKCRYPT_EXPORT=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)include;$(ProjectDir)..\etc\deps\pthreads4w\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
<OmitFramePointers>true</OmitFramePointers>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||
<FloatingPointModel>Fast</FloatingPointModel>
|
||||
<DisableSpecificWarnings>4706;4204</DisableSpecificWarnings>
|
||||
<CreateHotpatchableImage>false</CreateHotpatchableImage>
|
||||
<EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<AdditionalLibraryDirectories>$(ProjectDir)..\etc\deps\pthreads4w\lib\msvc-v141\shared\arm64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>pthreadVC3.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<MinimumRequiredVersion>6.2</MinimumRequiredVersion>
|
||||
</Link>
|
||||
<PostBuildEvent>
|
||||
<Command>copy /Y /B "$(ProjectDir)..\etc\deps\pthreads4w\bin\msvc-v141\pthreadVC3-x64.dll" "$(TargetDir)"</Command>
|
||||
|
|
|
@ -27,6 +27,9 @@
|
|||
<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">
|
||||
|
@ -47,5 +50,11 @@
|
|||
<ClInclude Include="src\thread.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\initialize.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\debug.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -6,21 +6,28 @@
|
|||
#ifndef INC_SLUNKCRYPT_COMPILER_H
|
||||
#define INC_SLUNKCRYPT_COMPILER_H
|
||||
|
||||
#ifdef _WIN32
|
||||
# define WIN32_LEAN_AND_MEAN 1
|
||||
# define _CRT_SECURE_NO_WARNINGS 1
|
||||
#else
|
||||
# define _GNU_SOURCE 1
|
||||
#endif
|
||||
|
||||
/* Intel(R) oneAPI DPC++/C++ Compiler */
|
||||
#if defined(__INTEL_LLVM_COMPILER) && (!defined(__GNUC__))
|
||||
# define __GNUC__ 10
|
||||
# define __GNUC__ 4
|
||||
#endif
|
||||
|
||||
/* Compiler compatibility */
|
||||
#if defined(_MSC_VER) && (!defined(__GNUC__))
|
||||
# define INLINE __inline
|
||||
# define UNUSED __pragma(warning(suppress: 4189))
|
||||
# define INLINE __inline
|
||||
# define UNUSED __pragma(warning(suppress: 4189))
|
||||
#elif defined(__GNUC__)
|
||||
# define INLINE __inline__
|
||||
# define UNUSED __attribute__((unused))
|
||||
# define INLINE __inline__
|
||||
# define UNUSED __attribute__((unused))
|
||||
#else
|
||||
# define INLINE inline
|
||||
# define UNUSED
|
||||
# define INLINE inline
|
||||
# define UNUSED
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
/******************************************************************************/
|
||||
/* SlunkCrypt, by LoRd_MuldeR <MuldeR2@GMX.de> */
|
||||
/* This work has been released under the CC0 1.0 Universal license! */
|
||||
/******************************************************************************/
|
||||
|
||||
/* Internal */
|
||||
#include "debug.h"
|
||||
|
||||
/* CRT */
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
/* logging sub-system */
|
||||
#ifdef _WIN32
|
||||
# define WIN32_LEAN_AND_MEAN 1
|
||||
# include <Windows.h>
|
||||
#else
|
||||
# include <syslog.h>
|
||||
#endif
|
||||
|
||||
void slunkcrypt_debug_write(const char* const message)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
OutputDebugStringA(message);
|
||||
#else
|
||||
syslog(LOG_ALERT, "%s", message);
|
||||
#endif
|
||||
}
|
||||
|
||||
void slunkcrypt_debug_print(const char* const message, ...)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
char buffer[100U];
|
||||
#endif
|
||||
va_list args;
|
||||
va_start(args, message);
|
||||
#ifdef _WIN32
|
||||
if (vsnprintf(buffer, 100U, message, args) > 0)
|
||||
{
|
||||
OutputDebugStringA(buffer);
|
||||
}
|
||||
#else
|
||||
vsyslog(LOG_ALERT, message, args);
|
||||
#endif
|
||||
va_end(args);
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
/******************************************************************************/
|
||||
/* 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_write(const char *const message);
|
||||
void slunkcrypt_debug_print(const char *const message, ...);
|
||||
|
||||
#define DBG_PRINTF(BUFF, FORMAT, ...) do \
|
||||
{ \
|
||||
const int _strlen = sprintf((BUFF), (FORMAT), __VA_ARGS__); \
|
||||
if (_strlen > 0) { BUFF += _strlen; } \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
#endif
|
|
@ -0,0 +1,49 @@
|
|||
/******************************************************************************/
|
||||
/* SlunkCrypt, by LoRd_MuldeR <MuldeR2@GMX.de> */
|
||||
/* This work has been released under the CC0 1.0 Universal license! */
|
||||
/******************************************************************************/
|
||||
|
||||
#ifndef INC_SLUNKCRYPT_INITIALIZE_H
|
||||
#define INC_SLUNKCRYPT_INITIALIZE_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/* randomized list of the 256+2 16-bit "safe" prime numbers */
|
||||
static const uint16_t INITIALIZER[258U] =
|
||||
{
|
||||
0x5B67, 0xFCFB, 0xD40F, 0xE61B, 0xFA07, 0x9C2F, 0x275F, 0xFB1B,
|
||||
0x4E9B, 0x79A3, 0x3173, 0x4067, 0x368F, 0xC15B, 0x7C67, 0x6E03,
|
||||
0xEC7B, 0x768B, 0xA3C7, 0xF06B, 0xB993, 0x0653, 0xA6BB, 0x5E8B,
|
||||
0xC317, 0x9257, 0x5D0B, 0x5A3B, 0xF107, 0x9FB3, 0x0B03, 0x0A13,
|
||||
0x675B, 0xCEB7, 0x8717, 0x6B87, 0x0D8B, 0x8DA7, 0xB5DF, 0x1A7B,
|
||||
0xF863, 0xBACB, 0x468B, 0x34D3, 0xE837, 0x3F0B, 0x4B3B, 0xB33F,
|
||||
0x74B7, 0x5507, 0x4937, 0x8A0B, 0x8C27, 0xAFA3, 0x3A13, 0x75FB,
|
||||
0xF42B, 0xC803, 0x6FE3, 0x1F67, 0x9B63, 0xB813, 0xEF9F, 0x0B93,
|
||||
0x015B, 0x543B, 0x07EB, 0x4A03, 0x9017, 0x6D73, 0xCBFF, 0xE963,
|
||||
0xAE8F, 0xC51B, 0x52EB, 0xDF37, 0xF8E7, 0xDA9F, 0x6A67, 0x999B,
|
||||
0xD8BF, 0xF35F, 0x37DF, 0xD73F, 0x269F, 0x804B, 0x7853, 0xBF33,
|
||||
0xD2E3, 0xC767, 0x6803, 0xAB0B, 0x92E7, 0x8CF3, 0xBA17, 0x93A7,
|
||||
0x7133, 0xC0D7, 0x2867, 0xD9EB, 0x293F, 0x30EF, 0x501B, 0xC98F,
|
||||
0xF7D3, 0xE22B, 0xAA57, 0x2AFB, 0x35E7, 0x43AF, 0x0527, 0x0C2F,
|
||||
0x80DB, 0x729B, 0x16AF, 0xF5DB, 0x260F, 0x5873, 0x95B7, 0x0EC3,
|
||||
0x975B, 0x00A7, 0x774B, 0xA22F, 0xA98B, 0xC893, 0xB477, 0xD943,
|
||||
0x83E7, 0xC3E3, 0x4C7F, 0xBDB3, 0xD523, 0x9E33, 0x05CF, 0x02CF,
|
||||
0x5903, 0xCC9B, 0xF20F, 0xA1AB, 0x860F, 0x8243, 0x0E27, 0xAC7F,
|
||||
0x50B7, 0xFE27, 0xA577, 0xE423, 0x01DF, 0x8357, 0xDFC7, 0x2C0F,
|
||||
0x8F4B, 0xE09F, 0x1733, 0x4F67, 0x5C0F, 0xA8D7, 0x10A3, 0x5387,
|
||||
0x2DB3, 0x8957, 0x9CBF, 0x45EF, 0x62DB, 0xF743, 0x480B, 0xFEF3,
|
||||
0xADE7, 0x6F53, 0x489B, 0xE6B7, 0x1B47, 0x098F, 0xA4C3, 0x2FE7,
|
||||
0x2C9F, 0xD6AF, 0x5243, 0x6593, 0x4A87, 0xABFB, 0xCA73, 0x374F,
|
||||
0x732B, 0x9A4F, 0x599F, 0x98C3, 0x20E7, 0x1607, 0x63EF, 0x21FB,
|
||||
0xA31F, 0x6917, 0xE537, 0x71C3, 0x6053, 0xDDE7, 0x9F23, 0xBD17,
|
||||
0x73DF, 0xA757, 0x7B3B, 0x03FB, 0x64C7, 0x3BB7, 0xDEA7, 0xBB5B,
|
||||
0xAF13, 0x396B, 0xE2BB, 0x4283, 0x089F, 0x19C7, 0x6E93, 0xB1BF,
|
||||
0x11C3, 0x2F4B, 0x1D63, 0x1247, 0x1C13, 0xB28B, 0x7D03, 0x96CB,
|
||||
0xE177, 0x32F3, 0x8E73, 0x3263, 0xCF9B, 0x3AEB, 0x7DB7, 0x24FB,
|
||||
0xF4AF, 0x444B, 0x69E3, 0xD1C3, 0x5F57, 0x1337, 0xBFCF, 0x0F6B,
|
||||
0x1E17, 0x7EFB, 0x6C77, 0x035F, 0x0FEF, 0x5DD7, 0x071F, 0x2303,
|
||||
0x04A3, 0x5747, 0xB747, 0x3D1F, 0x2A2F, 0xED6B, 0x3DBB, 0x150B,
|
||||
0x13DF, 0xB8EB
|
||||
};
|
||||
|
||||
#endif
|
|
@ -3,28 +3,15 @@
|
|||
/* This work has been released under the CC0 1.0 Universal license! */
|
||||
/******************************************************************************/
|
||||
|
||||
#ifdef _WIN32
|
||||
# define WIN32_LEAN_AND_MEAN 1
|
||||
# define _CRT_SECURE_NO_WARNINGS 1
|
||||
#else
|
||||
# define _GNU_SOURCE 1
|
||||
#endif
|
||||
|
||||
/* Internal */
|
||||
#include "slunkcrypt.h"
|
||||
#include "compiler.h"
|
||||
#include "slunkcrypt.h"
|
||||
|
||||
/* CRT */
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
#include <limits.h>
|
||||
|
||||
/* PThread */
|
||||
#if defined(_MSC_VER) && !defined(_DLL)
|
||||
# define PTW32_STATIC_LIB 1
|
||||
#endif
|
||||
#include <pthread.h>
|
||||
|
||||
/* Utils */
|
||||
static INLINE size_t MIN_SIZE(const size_t a, const size_t b) { return (a > b) ? b : a; }
|
||||
|
||||
|
@ -37,29 +24,79 @@ static INLINE size_t MIN_SIZE(const size_t a, const size_t b) { return (a > b) ?
|
|||
# include <io.h>
|
||||
#else
|
||||
# include <unistd.h>
|
||||
# include <pthread.h>
|
||||
# include <sched.h>
|
||||
# include <strings.h>
|
||||
#endif
|
||||
|
||||
/* detect destructor support */
|
||||
#undef ATTRIB_DESTRUCTOR
|
||||
#if defined(__APPLE__) && defined(__MACH__)
|
||||
# include <sys/random.h>
|
||||
#endif
|
||||
|
||||
/* detect compiler destructor support */
|
||||
#undef HAVE_ATTRIB_DESTRUCTOR
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
# define ATTRIB_DESTRUCTOR __attribute__((destructor))
|
||||
# define HAVE_ATTRIB_DESTRUCTOR 1
|
||||
#endif
|
||||
|
||||
/* detect getentropy() support */
|
||||
#undef GETENTROPY
|
||||
#if (defined(__linux__) && (__linux__ >= 1)) || (defined(__FreeBSD__) && (__FreeBSD__ >= 12)) || (defined(__OpenBSD__) && (__OpenBSD__ >= 1))
|
||||
# define GETENTROPY getentropy
|
||||
/* detect getentropy() or RtlGenRandom() support */
|
||||
#undef HAVE_GETENTROPY
|
||||
#undef HAVE_WIN32RTLGENRANDOM
|
||||
#if defined(_WIN32)
|
||||
# define HAVE_WIN32RTLGENRANDOM 1
|
||||
#elif (defined(__linux__) && !defined(__UCLIBC__)) || defined(__CYGWIN__) || (defined(__FreeBSD__) && (__FreeBSD__ >= 12)) || defined(__DragonFly__) || defined(__OpenBSD__) || (defined(__sun) && defined(__SVR4)) || (defined(__APPLE__) && defined(__MACH__))
|
||||
# define HAVE_GETENTROPY 1
|
||||
#else
|
||||
# pragma message("Function getentropy() is *not* available -> using fallback!")
|
||||
#endif
|
||||
|
||||
/* detect explicit_bzero() support */
|
||||
/* detect explicit_bzero() or SecureZeroMemory() support */
|
||||
#undef EXPLICIT_BZERO
|
||||
#if defined(_WIN32) && (_WIN32 >= 1) && defined(SecureZeroMemory)
|
||||
#if defined(_WIN32) && defined(SecureZeroMemory)
|
||||
# define EXPLICIT_BZERO SecureZeroMemory
|
||||
#elif (defined(__linux__) && (__linux__ >= 1)) || (defined(__FreeBSD__) && (__FreeBSD__ >= 11)) || (defined(__OpenBSD__) && (__OpenBSD__ >= 1))
|
||||
#elif (defined(__linux__) && !defined(__UCLIBC__)) || defined(__CYGWIN__) || (defined(__FreeBSD__) && (__FreeBSD__ >= 11)) || defined(__DragonFly__) || defined(__OpenBSD__) || (defined(__sun) && defined(__SVR4)) || defined(__HAIKU__)
|
||||
# define EXPLICIT_BZERO explicit_bzero
|
||||
#else
|
||||
# pragma message("Function explicit_bzero() is *not* available -> using fallback!")
|
||||
#endif
|
||||
|
||||
/* detect sched_yield() or Sleep() support */
|
||||
#ifdef _WIN32
|
||||
# define THREAD_YIELD() Sleep(0)
|
||||
#else
|
||||
# define THREAD_YIELD() sched_yield()
|
||||
#endif
|
||||
|
||||
// ==========================================================================
|
||||
// One-time initialization
|
||||
// ==========================================================================
|
||||
|
||||
/* atomic memory access */
|
||||
#if defined(_MSC_VER) && (!defined(__GNUC__))
|
||||
# define ONCE_FLAG_T LONG
|
||||
# define ATOMIC_COMPARE_EXCHANGE(X,Y,Z) InterlockedCompareExchange((X),(Y),(Z))
|
||||
# define ATOMIC_EXCHANGE(X,Y) InterlockedExchange((X),(Y))
|
||||
#else
|
||||
# define ONCE_FLAG_T int
|
||||
# define ATOMIC_COMPARE_EXCHANGE(X,Y,Z) __sync_val_compare_and_swap((X),(Z),(Y))
|
||||
# define ATOMIC_EXCHANGE(X,Y) __sync_lock_test_and_set((X),(Y))
|
||||
#endif
|
||||
|
||||
/* execute init routine once */
|
||||
static INLINE void initialize_once(volatile ONCE_FLAG_T *const once_control, void (*const init_routine)(void))
|
||||
{
|
||||
ONCE_FLAG_T state;
|
||||
while ((state = ATOMIC_COMPARE_EXCHANGE(once_control, -1, 0)) != 0)
|
||||
{
|
||||
if (state > 0)
|
||||
{
|
||||
return; /*already initialized*/
|
||||
}
|
||||
THREAD_YIELD();
|
||||
}
|
||||
init_routine();
|
||||
ATOMIC_EXCHANGE(once_control, 1);
|
||||
}
|
||||
|
||||
// ==========================================================================
|
||||
// Random bytes
|
||||
// ==========================================================================
|
||||
|
@ -67,7 +104,7 @@ static INLINE size_t MIN_SIZE(const size_t a, const size_t b) { return (a > b) ?
|
|||
#define MAX_COUNT 1048576U
|
||||
|
||||
/* Global state */
|
||||
static pthread_once_t s_random_is_initialized = PTHREAD_ONCE_INIT;
|
||||
static volatile ONCE_FLAG_T s_random_is_initialized = 0;
|
||||
#if defined(_WIN32)
|
||||
typedef BOOLEAN(WINAPI *ptr_genrandom_t)(void *buffer, ULONG length);
|
||||
static HMODULE s_advapi32 = NULL;
|
||||
|
@ -102,15 +139,15 @@ static void exit_random_source(void)
|
|||
/* Initialize CSRNG */
|
||||
static void init_random_source(void)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
#ifdef HAVE_WIN32RTLGENRANDOM
|
||||
if ((s_advapi32 = LoadLibraryW(L"advapi32.dll")))
|
||||
{
|
||||
s_genrandom = (ptr_genrandom_t) GetProcAddress(s_advapi32, "SystemFunction036");
|
||||
}
|
||||
#else
|
||||
#if defined(GETENTROPY)
|
||||
#if defined(HAVE_GETENTROPY)
|
||||
uint8_t temp;
|
||||
if (GETENTROPY(&temp, sizeof(uint8_t)) >= 0)
|
||||
if (getentropy(&temp, sizeof(uint8_t)) >= 0)
|
||||
{
|
||||
goto init_completed;
|
||||
}
|
||||
|
@ -124,7 +161,7 @@ static void init_random_source(void)
|
|||
}
|
||||
init_completed: ;
|
||||
#endif
|
||||
#if !defined(ATTRIB_DESTRUCTOR)
|
||||
#if !defined(HAVE_ATTRIB_DESTRUCTOR)
|
||||
atexit(exit_random_source);
|
||||
#endif
|
||||
}
|
||||
|
@ -133,8 +170,8 @@ init_completed: ;
|
|||
size_t slunkcrypt_random_bytes(uint8_t *const buffer, const size_t length)
|
||||
{
|
||||
size_t offset;
|
||||
pthread_once(&s_random_is_initialized, init_random_source);
|
||||
#ifdef _WIN32
|
||||
initialize_once(&s_random_is_initialized, init_random_source);
|
||||
#ifdef HAVE_WIN32RTLGENRANDOM
|
||||
if (s_genrandom)
|
||||
{
|
||||
ULONG count;
|
||||
|
@ -162,14 +199,14 @@ size_t slunkcrypt_random_bytes(uint8_t *const buffer, const size_t length)
|
|||
}
|
||||
return offset;
|
||||
}
|
||||
#if defined(GETENTROPY)
|
||||
#if defined(HAVE_GETENTROPY)
|
||||
else
|
||||
{
|
||||
size_t count;
|
||||
for (offset = 0U; offset < length; offset += count)
|
||||
{
|
||||
count = MIN_SIZE(length - offset, 256U); /*the maximum permitted value is 256*/
|
||||
if (GETENTROPY(buffer + offset, count) < 0)
|
||||
if (getentropy(buffer + offset, count) < 0)
|
||||
{
|
||||
break; /*failed*/
|
||||
}
|
||||
|
@ -206,8 +243,8 @@ void slunkcrypt_bzero(void* const buffer, const size_t length)
|
|||
// Destructor
|
||||
// ==========================================================================
|
||||
|
||||
#if defined(ATTRIB_DESTRUCTOR)
|
||||
ATTRIB_DESTRUCTOR void slunkcrypt_destructor()
|
||||
#if defined(HAVE_ATTRIB_DESTRUCTOR)
|
||||
__attribute__((destructor)) void slunkcrypt_destructor(void)
|
||||
{
|
||||
exit_random_source();
|
||||
}
|
||||
|
|
|
@ -15,31 +15,34 @@ typedef struct
|
|||
{
|
||||
uint64_t hi, lo;
|
||||
}
|
||||
uint128_t;
|
||||
hash128_t;
|
||||
|
||||
// ==========================================================================
|
||||
// 128-Bit math support
|
||||
// ==========================================================================
|
||||
|
||||
#if defined(__GNUC__) && defined(__SIZEOF_INT128__)
|
||||
# define HAVE_UINT128_SUPPORT 1
|
||||
# define PACK_U128(X) ((((__uint128_t)(X).hi) << 64) | (X).lo)
|
||||
# define HAVE_UINT128_T 1
|
||||
# define LOAD_U128(X) ((((__uint128_t)(X).hi) << 64) | (X).lo)
|
||||
#else
|
||||
# pragma message("Compiler does not support 128-bit math -> using fallback!")
|
||||
#endif
|
||||
|
||||
static INLINE void multiply_u128(uint128_t *const out, const uint128_t lhs, const uint128_t rhs)
|
||||
static INLINE void multiply_u128(hash128_t *const out, const hash128_t lhs, const hash128_t *const rhs)
|
||||
{
|
||||
#ifdef HAVE_UINT128_SUPPORT
|
||||
const __uint128_t product = PACK_U128(lhs) * PACK_U128(rhs);
|
||||
*out = (uint128_t) { product >> 64, product };
|
||||
#ifdef HAVE_UINT128_T
|
||||
const __uint128_t product = LOAD_U128(lhs) * LOAD_U128(*rhs);
|
||||
out->lo = (uint64_t)product;
|
||||
out->hi = (uint64_t)(product >> 64);
|
||||
#else
|
||||
const uint64_t lolo = (lhs.lo & 0xFFFFFFFF) * (rhs.lo & 0xFFFFFFFF);
|
||||
const uint64_t hilo = (lhs.lo >> 32U) * (rhs.lo & 0xFFFFFFFF);
|
||||
const uint64_t lohi = (lhs.lo & 0xFFFFFFFF) * (rhs.lo >> 32U);
|
||||
const uint64_t hihi = (lhs.lo >> 32U) * (rhs.lo >> 32U);
|
||||
const uint64_t lolo = (lhs.lo & 0xFFFFFFFF) * (rhs->lo & 0xFFFFFFFF);
|
||||
const uint64_t hilo = (lhs.lo >> 32U) * (rhs->lo & 0xFFFFFFFF);
|
||||
const uint64_t lohi = (lhs.lo & 0xFFFFFFFF) * (rhs->lo >> 32U);
|
||||
const uint64_t hihi = (lhs.lo >> 32U) * (rhs->lo >> 32U);
|
||||
const uint64_t crss = (lolo >> 32U) + (hilo & 0xFFFFFFFF) + lohi;
|
||||
out->hi = (hilo >> 32U) + (crss >> 32) + hihi;
|
||||
out->lo = (crss << 32U) | (lolo & 0xFFFFFFFF);
|
||||
out->hi += (lhs.hi * rhs.lo) + (lhs.lo * rhs.hi); /* 128x128=128 */
|
||||
out->hi += (lhs.hi * rhs->lo) + (lhs.lo * rhs->hi); /* 128x128=128 */
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -47,32 +50,37 @@ static INLINE void multiply_u128(uint128_t *const out, const uint128_t lhs, cons
|
|||
// Hash function
|
||||
// ==========================================================================
|
||||
|
||||
static const uint128_t HASH_OFFSETBASE_128 = { 0x6C62272E07BB0142, 0x62B821756295C58D };
|
||||
static const uint128_t HASH_MAGICPRIME_128 = { 0x0000000001000000, 0x000000000000013B };
|
||||
static const hash128_t HASH_OFFSETBASE_128 = { UINT64_C(0x6C62272E07BB0142), UINT64_C(0x62B821756295C58D) };
|
||||
static const hash128_t HASH_MAGICPRIME_128 = { UINT64_C(0x0000000001000000), UINT64_C(0x000000000000013B) };
|
||||
|
||||
static INLINE void hash_update_u64(uint128_t* const hash, uint64_t value)
|
||||
#define HASH_UPDATE(X) do \
|
||||
{ \
|
||||
hash->lo ^= (X); \
|
||||
multiply_u128(hash, *hash, &HASH_MAGICPRIME_128); \
|
||||
} \
|
||||
while(0)
|
||||
|
||||
static INLINE void hash_update_u64(hash128_t *const hash, uint64_t value)
|
||||
{
|
||||
size_t i;
|
||||
for (i = 0U; i < sizeof(uint64_t); ++i, value >>= CHAR_BIT)
|
||||
{
|
||||
hash->lo ^= (uint8_t)(value & 0xFF);
|
||||
multiply_u128(hash, *hash, HASH_MAGICPRIME_128);
|
||||
HASH_UPDATE((uint8_t)value);
|
||||
}
|
||||
}
|
||||
|
||||
static INLINE void hash_update_str(uint128_t *const hash, const uint8_t *const data, const size_t data_len)
|
||||
static INLINE void hash_update_str(hash128_t *const hash, const uint8_t *const data, const size_t data_len)
|
||||
{
|
||||
size_t i;
|
||||
for (i = 0U; i < data_len; ++i)
|
||||
{
|
||||
hash->lo ^= data[i];
|
||||
multiply_u128(hash, *hash, HASH_MAGICPRIME_128);
|
||||
HASH_UPDATE(data[i]);
|
||||
}
|
||||
}
|
||||
|
||||
static INLINE uint128_t hash_code(const uint128_t *const seed, const uint8_t *const data, const size_t data_len)
|
||||
static INLINE hash128_t hash_code(const hash128_t *const seed, const uint8_t *const data, const size_t data_len)
|
||||
{
|
||||
uint128_t hash = HASH_OFFSETBASE_128;
|
||||
hash128_t hash = HASH_OFFSETBASE_128;
|
||||
hash_update_u64(&hash, seed->lo);
|
||||
hash_update_u64(&hash, seed->hi);
|
||||
hash_update_str(&hash, data, data_len);
|
||||
|
@ -83,11 +91,11 @@ static INLINE uint128_t hash_code(const uint128_t *const seed, const uint8_t *co
|
|||
// Key derivation
|
||||
// ==========================================================================
|
||||
|
||||
static INLINE uint64_t keygen_loop(uint64_t seed, const uint64_t i, const uint8_t *const passwd, const size_t passwd_len)
|
||||
static INLINE uint64_t keygen_loop(uint64_t seed, const uint64_t i, const uint8_t *const passwd, const size_t passwd_len, const size_t rounds)
|
||||
{
|
||||
uint128_t hash = { seed, i };
|
||||
hash128_t hash = { seed, i };
|
||||
size_t u;
|
||||
for (u = 0U, seed = 0U; u < 99971U; ++u)
|
||||
for (u = 0U, seed = 0U; u < rounds; ++u)
|
||||
{
|
||||
hash = hash_code(&hash, passwd, passwd_len);
|
||||
seed ^= hash.hi ^ hash.lo;
|
||||
|
@ -95,9 +103,9 @@ static INLINE uint64_t keygen_loop(uint64_t seed, const uint64_t i, const uint8_
|
|||
return seed;
|
||||
}
|
||||
|
||||
void slunkcrypt_keygen(keydata_t *const key, const uint64_t salt, const uint16_t pepper, const uint8_t *const passwd, const size_t passwd_len)
|
||||
void slunkcrypt_keygen(keydata_t *const key, const uint64_t salt, const uint16_t pepper, const uint8_t *const passwd, const size_t passwd_len, const size_t rounds)
|
||||
{
|
||||
key->a = keygen_loop(salt, 0x162603FA1CDA99D3 + (uint64_t)pepper, passwd, passwd_len);
|
||||
key->b = keygen_loop(salt, 0xBFDEC4A6C1A46E09 + (uint64_t)pepper, passwd, passwd_len);
|
||||
key->c = keygen_loop(salt, 0x6BA17D11624973EE + (uint64_t)pepper, passwd, passwd_len);
|
||||
key->a = keygen_loop(salt, 0x162603FA1CDA99D3 + (uint64_t)pepper, passwd, passwd_len, rounds);
|
||||
key->b = keygen_loop(salt, 0xBFDEC4A6C1A46E09 + (uint64_t)pepper, passwd, passwd_len, rounds);
|
||||
key->c = keygen_loop(salt, 0x6BA17D11624973EE + (uint64_t)pepper, passwd, passwd_len, rounds);
|
||||
}
|
||||
|
|
|
@ -15,6 +15,6 @@ typedef struct
|
|||
}
|
||||
keydata_t;
|
||||
|
||||
void slunkcrypt_keygen(keydata_t *const key, const uint64_t salt, const uint16_t pepper, const uint8_t* const passwd, const size_t passwd_len);
|
||||
void slunkcrypt_keygen(keydata_t *const key, const uint64_t salt, const uint16_t pepper, const uint8_t* const passwd, const size_t passwd_len, const size_t rounds);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -4,14 +4,17 @@
|
|||
/******************************************************************************/
|
||||
|
||||
/* Internal */
|
||||
#include "slunkcrypt.h"
|
||||
#include "compiler.h"
|
||||
#include "slunkcrypt.h"
|
||||
#include "debug.h"
|
||||
#include "keygen.h"
|
||||
#include "initialize.h"
|
||||
#include "thread.h"
|
||||
#include "version.h"
|
||||
|
||||
/* CRT */
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <limits.h>
|
||||
|
||||
/* Version */
|
||||
|
@ -24,6 +27,9 @@ const char *const SLUNKCRYPT_BUILD = __DATE__ ", " __TIME__;
|
|||
#define BOOLIFY(X) (!!(X))
|
||||
#define THREAD_COUNT(X) (((X)->thread_pool) ? slunkcrypt_thrdpl_count((X)->thread_pool) : 1U)
|
||||
|
||||
/* Configuration */
|
||||
const int SLUNKCRYPT_HAVE_THREADS = BOOLIFY(MAX_THREADS > 1U);
|
||||
|
||||
// ==========================================================================
|
||||
// Data structures
|
||||
// ==========================================================================
|
||||
|
@ -53,6 +59,8 @@ crypt_data_t;
|
|||
|
||||
typedef struct
|
||||
{
|
||||
int legacy_compat;
|
||||
int debug_logging;
|
||||
thrdpl_t *thread_pool;
|
||||
crypt_data_t data;
|
||||
}
|
||||
|
@ -73,33 +81,22 @@ volatile int g_slunkcrypt_abort_flag = 0;
|
|||
} \
|
||||
while (0)
|
||||
|
||||
// ==========================================================================
|
||||
// Byte access (endianness agnostic)
|
||||
// ==========================================================================
|
||||
|
||||
static INLINE uint32_t lower_u64(const uint64_t value)
|
||||
{
|
||||
return (uint32_t)(value & 0xFFFFFFFF);
|
||||
}
|
||||
|
||||
static INLINE uint32_t upper_u64(const uint64_t value)
|
||||
{
|
||||
return (uint32_t)(value >> 32U);
|
||||
}
|
||||
|
||||
// ==========================================================================
|
||||
// Deterministic random bit generator
|
||||
// ==========================================================================
|
||||
|
||||
#define RANDOM_INIT(DST_LO, DST_HI, SRC) do \
|
||||
{ \
|
||||
DST_LO = (uint32_t)(SRC); \
|
||||
DST_HI = (uint32_t)((SRC) >> 32U); \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
static INLINE void random_init(rand_state_t *const state, const keydata_t *const key)
|
||||
{
|
||||
slunkcrypt_bzero(state, sizeof(rand_state_t));
|
||||
state->x = lower_u64(key->a);
|
||||
state->y = upper_u64(key->a);
|
||||
state->z = lower_u64(key->b);
|
||||
state->w = upper_u64(key->b);
|
||||
state->v = lower_u64(key->c);
|
||||
state->d = upper_u64(key->c);
|
||||
RANDOM_INIT(state->x, state->y, key->a);
|
||||
RANDOM_INIT(state->z, state->w, key->b);
|
||||
RANDOM_INIT(state->v, state->d, key->c);
|
||||
}
|
||||
|
||||
static INLINE uint32_t random_next(rand_state_t *const state)
|
||||
|
@ -118,47 +115,48 @@ static INLINE void random_skip(rand_state_t *const state, const size_t skip_coun
|
|||
size_t i;
|
||||
for (i = 0U; i < skip_count; ++i)
|
||||
{
|
||||
UNUSED /*volatile*/ uint32_t q = random_next(state);
|
||||
UNUSED /*volatile*/ uint32_t discard = random_next(state);
|
||||
}
|
||||
}
|
||||
|
||||
static INLINE void random_seed(rand_state_t *const state, uint64_t salt, const uint16_t pepper, const uint8_t *const passwd, const size_t passwd_len)
|
||||
static INLINE void random_seed(rand_state_t *const state, uint64_t salt, const uint16_t pepper, const uint8_t *const passwd, const size_t passwd_len, const int legacy)
|
||||
{
|
||||
keydata_t key;
|
||||
do
|
||||
{
|
||||
slunkcrypt_keygen(&key, salt++, pepper, passwd, passwd_len);
|
||||
slunkcrypt_keygen(&key, salt++, pepper, passwd, passwd_len, legacy ? 99971U : 19997L);
|
||||
random_init(state, &key);
|
||||
slunkcrypt_bzero(&key, sizeof(keydata_t));
|
||||
}
|
||||
while (!(state->x || state->y || state->z || state->w || state->v));
|
||||
random_skip(state, 97U);
|
||||
random_skip(state, legacy ? 97U : 23U);
|
||||
}
|
||||
|
||||
// ==========================================================================
|
||||
// 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)
|
||||
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;
|
||||
rand_state_t *const rand_state = &data->thread_data[0].random;
|
||||
const int reverse_mode = BOOLIFY(mode);
|
||||
|
||||
/* initialize state */
|
||||
slunkcrypt_bzero(data, sizeof(crypt_data_t));
|
||||
|
||||
/* initialize counter */
|
||||
random_seed(&data->thread_data[0].random, nonce, (uint16_t)(-1), passwd, passwd_len);
|
||||
data->thread_data[0].counter = random_next(&data->thread_data[0].random);
|
||||
random_seed(rand_state, nonce, legacy ? ((uint16_t)(-1)) : INITIALIZER[256U], passwd, passwd_len, legacy);
|
||||
data->thread_data[0].counter = random_next(rand_state);
|
||||
|
||||
/* set up the wheel permutations */
|
||||
for (r = 0U; r < 256U; ++r)
|
||||
{
|
||||
random_seed(&data->thread_data[0].random, nonce, (uint16_t)r, passwd, passwd_len);
|
||||
random_seed(rand_state, nonce, legacy ? ((uint16_t)r) : INITIALIZER[r], passwd, passwd_len, legacy);
|
||||
for (i = 0U; i < 256U; ++i)
|
||||
{
|
||||
const size_t j = random_next(&data->thread_data[0].random) % (i + 1U);
|
||||
const size_t j = random_next(rand_state) % (i + 1U);
|
||||
if (j != i)
|
||||
{
|
||||
data->wheel[r][i] = data->wheel[r][j];
|
||||
|
@ -186,22 +184,40 @@ static int initialize_state(crypt_data_t *const data, const size_t thread_count,
|
|||
CHECK_ABORTED();
|
||||
}
|
||||
|
||||
/* initialize up thread state */
|
||||
data->thread_data[0].reverse_mode = reverse_mode;
|
||||
data->thread_data[0].wheel = data->wheel;
|
||||
data->thread_data[0].index_off = 0U;
|
||||
random_seed(&data->thread_data[0].random, nonce, 256U, passwd, passwd_len);
|
||||
for (i = 1U; i < thread_count; ++i)
|
||||
/* initialize thread state */
|
||||
random_seed(rand_state, nonce, legacy ? 256U : INITIALIZER[257U], passwd, passwd_len, legacy);
|
||||
for (i = 0U; i < thread_count; ++i)
|
||||
{
|
||||
data->thread_data[i].reverse_mode = data->thread_data[0].reverse_mode;
|
||||
data->thread_data[i].wheel = data->thread_data[0].wheel;
|
||||
data->thread_data[i].counter = data->thread_data[0].counter + ((uint32_t)i);
|
||||
data->thread_data[i].index_off = data->thread_data[i - 1U].index_off + 1U;
|
||||
memcpy(&data->thread_data[i].random, &data->thread_data[0].random, sizeof(rand_state_t));
|
||||
random_skip(&data->thread_data[i].random, i * 63U);
|
||||
data->thread_data[i].reverse_mode = reverse_mode;
|
||||
data->thread_data[i].wheel = (const uint8_t(*)[256]) data->wheel;
|
||||
data->thread_data[i].index_off = i;
|
||||
if (i > 0U)
|
||||
{
|
||||
data->thread_data[i].counter = data->thread_data[0].counter + ((uint32_t)i);
|
||||
memcpy(&data->thread_data[i].random, &data->thread_data[0].random, sizeof(rand_state_t));
|
||||
random_skip(&data->thread_data[i].random, i * 63U);
|
||||
}
|
||||
CHECK_ABORTED();
|
||||
}
|
||||
|
||||
/* dump the final configuration */
|
||||
if (debug)
|
||||
{
|
||||
slunkcrypt_debug_print("cntr = %08X", data->thread_data[0].counter);
|
||||
slunkcrypt_debug_print("drbg = %08X %08X %08X %08X %08X %08X", rand_state->d, rand_state->v, rand_state->w, rand_state->x, rand_state->y, rand_state->z);
|
||||
for (r = 0U; r < 256U; ++r)
|
||||
{
|
||||
char message[775U] = { '\0' };
|
||||
char *ptr = message;
|
||||
DBG_PRINTF(ptr, "[%02X] =", (unsigned)r);
|
||||
for (i = 0U; i < 256U; ++i)
|
||||
{
|
||||
DBG_PRINTF(ptr, " %02X", data->wheel[r][i]);
|
||||
}
|
||||
slunkcrypt_debug_write(message);
|
||||
}
|
||||
}
|
||||
|
||||
return SLUNKCRYPT_SUCCESS;
|
||||
|
||||
/* aborted */
|
||||
|
@ -290,21 +306,21 @@ int slunkcrypt_generate_nonce(uint64_t *const nonce)
|
|||
|
||||
slunkcrypt_t slunkcrypt_alloc(const uint64_t nonce, const uint8_t *const passwd, const size_t passwd_len, const int mode)
|
||||
{
|
||||
slunkparam_t param = { SLUNKCRYPT_PARAM_VERSION, 0U };
|
||||
const slunkparam_t param = { SLUNKCRYPT_PARAM_VERSION, 0U, SLUNKCRYPT_TRUE, SLUNKCRYPT_FALSE };
|
||||
return slunkcrypt_alloc_ext(nonce, passwd, passwd_len, mode, ¶m);
|
||||
}
|
||||
|
||||
slunkcrypt_t slunkcrypt_alloc_ext(const uint64_t nonce, const uint8_t *const passwd, const size_t passwd_len, const int mode, const slunkparam_t *const param)
|
||||
{
|
||||
crypt_state_t* state = NULL;
|
||||
crypt_state_t *state = NULL;
|
||||
|
||||
if ((!passwd) || (passwd_len < SLUNKCRYPT_PWDLEN_MIN) || (passwd_len > SLUNKCRYPT_PWDLEN_MAX) ||
|
||||
(mode < SLUNKCRYPT_ENCRYPT) || (mode > SLUNKCRYPT_DECRYPT) || (!param) || (param->version == 0U) || (param->version > SLUNKCRYPT_PARAM_VERSION))
|
||||
(mode < SLUNKCRYPT_ENCRYPT) || (mode > SLUNKCRYPT_DECRYPT) || (!param) || (!param->version) || (param->version > SLUNKCRYPT_PARAM_VERSION))
|
||||
{
|
||||
return SLUNKCRYPT_NULL;
|
||||
}
|
||||
|
||||
if (!(state = (crypt_state_t*)malloc(sizeof(crypt_state_t))))
|
||||
if (!(state = (crypt_state_t*) calloc(1U, sizeof(crypt_state_t))))
|
||||
{
|
||||
return SLUNKCRYPT_NULL;
|
||||
}
|
||||
|
@ -319,7 +335,10 @@ slunkcrypt_t slunkcrypt_alloc_ext(const uint64_t nonce, const uint8_t *const pas
|
|||
}
|
||||
}
|
||||
|
||||
if (initialize_state(&state->data, THREAD_COUNT(state), nonce, passwd, passwd_len, mode) == SLUNKCRYPT_SUCCESS)
|
||||
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, state->debug_logging) == SLUNKCRYPT_SUCCESS)
|
||||
{
|
||||
return (slunkcrypt_t)state;
|
||||
}
|
||||
|
@ -337,10 +356,12 @@ int slunkcrypt_reset(const slunkcrypt_t context, const uint64_t nonce, const uin
|
|||
{
|
||||
return SLUNKCRYPT_FAILURE;
|
||||
}
|
||||
if ((result = initialize_state(&state->data, THREAD_COUNT(state), nonce, passwd, passwd_len, mode)) != 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));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,15 +5,9 @@
|
|||
|
||||
#ifndef SLUNKBUILD_NOTHREADS
|
||||
|
||||
#ifdef _WIN32
|
||||
# define _CRT_SECURE_NO_WARNINGS 1
|
||||
#else
|
||||
# define _GNU_SOURCE 1
|
||||
#endif
|
||||
|
||||
/* Internal */
|
||||
#include "thread.h"
|
||||
#include "compiler.h"
|
||||
#include "thread.h"
|
||||
|
||||
/* CRT */
|
||||
#include <stdlib.h>
|
||||
|
|
|
@ -15,7 +15,6 @@ typedef void(*thrdpl_worker_t)(const size_t thread_count, void *const context, u
|
|||
#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_init(thrdpl_t *const thrdpl, const size_t index, void *const context);
|
||||
|
@ -25,7 +24,6 @@ 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)
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#define INC_SLUNKCRYPT_VERSION_H
|
||||
|
||||
#define LIB_VERSION_MAJOR 1
|
||||
#define LIB_VERSION_MINOR 2
|
||||
#define LIB_VERSION_MINOR 3
|
||||
#define LIB_VERSION_PATCH 0
|
||||
|
||||
#endif
|
||||
|
|
|
@ -12,19 +12,21 @@ if not exist "%MSVC_PATH%\Auxiliary\Build\vcvarsall.bat" (
|
|||
goto:eof
|
||||
)
|
||||
|
||||
for %%p in (x86,x64) do (
|
||||
for %%p in (x86,x64,ARM64) do (
|
||||
call "%MSVC_PATH%\Auxiliary\Build\vcvarsall.bat" %%p
|
||||
for %%c in (Release,Release_SSE2) do (
|
||||
%ECHO% white "\n------------------------------------------------------------------------------"
|
||||
%ECHO% white "Clean [%%p:%%c]"
|
||||
%ECHO% white "------------------------------------------------------------------------------\n"
|
||||
MSBuild.exe /property:Configuration=%%c /property:Platform=%%p /target:Clean /verbosity:normal "%~dp0\Slunk.sln"
|
||||
if not "!ERRORLEVEL!"=="0" goto:BuildFailed
|
||||
%ECHO% white "\n------------------------------------------------------------------------------"
|
||||
%ECHO% white "Compile [%%p:%%c]"
|
||||
%ECHO% white "------------------------------------------------------------------------------\n"
|
||||
MSBuild.exe /property:Configuration=%%c /property:Platform=%%p /target:Build /verbosity:normal "%~dp0\Slunk.sln"
|
||||
if not "!ERRORLEVEL!"=="0" goto:BuildFailed
|
||||
for %%c in (Release,Release_SSE2,Release_DLL,Debug) do (
|
||||
if not "%%p::%%c"=="ARM64::Release_SSE2" (
|
||||
%ECHO% white "\n------------------------------------------------------------------------------"
|
||||
%ECHO% white "Clean [%%p:%%c]"
|
||||
%ECHO% white "------------------------------------------------------------------------------\n"
|
||||
MSBuild.exe /property:Configuration=%%c /property:Platform=%%p /target:Clean /verbosity:normal "%~dp0\Slunk.sln"
|
||||
if not "!ERRORLEVEL!"=="0" goto:BuildFailed
|
||||
%ECHO% white "\n------------------------------------------------------------------------------"
|
||||
%ECHO% white "Compile [%%p:%%c]"
|
||||
%ECHO% white "------------------------------------------------------------------------------\n"
|
||||
MSBuild.exe /property:Configuration=%%c /property:Platform=%%p /target:Build /verbosity:normal "%~dp0\Slunk.sln"
|
||||
if not "!ERRORLEVEL!"=="0" goto:BuildFailed
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
#!/bin/bash
|
||||
# See "etc/utils/linux/mk-musl.sh" in order to build musl libc!
|
||||
set -e
|
||||
cd -- "$(dirname -- "${BASH_SOURCE[0]}")"
|
||||
|
||||
function mk_slunk() {
|
||||
local command="make -B CC=/usr/local/musl/${1}-linux-gnu/bin/musl-gcc STATIC=1 STRIP=1 FLTO=1"
|
||||
if [ ! -z "${2}" ]; then
|
||||
command="${command} ${2}"
|
||||
fi
|
||||
$BASH -x -c "${command}"
|
||||
cp -vf "frontend/bin/slunkcrypt" "out/slunkcrypt-${1}"
|
||||
}
|
||||
|
||||
rm -rf "out" && mkdir -p "out"
|
||||
|
||||
$BASH -x -c "make clean"
|
||||
|
||||
mk_slunk "x86_64" "MARCH=x86-64 MTUNE=nocona"
|
||||
mk_slunk "i686" "MARCH=pentiumpro MTUNE=generic"
|
||||
mk_slunk "aarch64"
|
||||
|
||||
printf "\033[1;32m\nBuild completed successfully.\033[0m\n\n"
|
Loading…
Reference in New Issue