From d7aaa9647d31a529734ce47e19b6a17d294ab160 Mon Sep 17 00:00:00 2001 From: localhorst Date: Mon, 22 Aug 2022 14:24:31 +0200 Subject: [PATCH] added Threefish cipher as submodule --- .gitmodules | 6 ++++++ makefile | 19 ++++++++++++++++--- src/shred.cpp | 22 ++++++++++++++++++++++ tfnoisegen | 1 + 4 files changed, 45 insertions(+), 3 deletions(-) create mode 100644 .gitmodules create mode 160000 tfnoisegen diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..d2aa5f1 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,6 @@ +[submodule "--force"] + path = --force + url = https://git.mosad.xyz/localhorst/tfnoisegen.git +[submodule "tfnoisegen"] + path = tfnoisegen + url = https://git.mosad.xyz/localhorst/tfnoisegen.git diff --git a/makefile b/makefile index 9761a26..a667dce 100644 --- a/makefile +++ b/makefile @@ -8,7 +8,7 @@ SRC_EXT = cpp # Path to the source directory, relative to the makefile SRC_PATH = src # Space-separated pkg-config libraries used by this project -LIBS = +LIBS = lib # General compiler flags COMPILE_FLAGS = -std=c++17 -Wall -Wextra -g # Additional release-specific flags @@ -18,9 +18,12 @@ DCOMPILE_FLAGS = -D DEBUG # Add additional include paths INCLUDES = include # General linker settings -LINK_FLAGS = -lpthread -lncurses +LINK_FLAGS = -Llib -lpthread -lncurses -ltfng + # Doc DOCDIR = doc +TFRANDDIR = tfnoisegen +TFRANDLIB = libtfng.a #### END PROJECT SETTINGS #### # Optionally you may move the section above to a separate config.mk file, and @@ -52,7 +55,7 @@ endif # Combine compiler and linker flags release: export CXXFLAGS := $(CXXFLAGS) $(COMPILE_FLAGS) $(RCOMPILE_FLAGS) -release: export LDFLAGS := $(LDFLAGS) $(LINK_FLAGS) $(RLINK_FLAGS) +release: export LDFLAGS := $(LDFLAGS) $(LINK_FLAGS) $(RLINK_FLAGS) debug: export CXXFLAGS := $(CXXFLAGS) $(COMPILE_FLAGS) $(DCOMPILE_FLAGS) debug: export LDFLAGS := $(LDFLAGS) $(LINK_FLAGS) $(DLINK_FLAGS) @@ -158,6 +161,7 @@ dirs: @echo "Creating directories" @mkdir -p $(dir $(OBJECTS)) @mkdir -p $(BIN_PATH) + @mkdir -p $(LIBS) # Removes all build files .PHONY: clean @@ -167,18 +171,27 @@ clean: @echo "Deleting directories" @$(RM) -r build @$(RM) -r bin + @$(RM) -r $(LIBS) @$(RM) -f reHDD.log + $(MAKE) clean -C tfnoisegen # Main rule, checks the executable and symlinks to the output all: $(BIN_PATH)/$(BIN_NAME) + $(MAKE) libtfng.a -C tfnoisegen + @cp $(TFRANDDIR)/$(TFRANDLIB) $(LIBS) + @echo "Making symlink: $(BIN_NAME) -> $<" @$(RM) $(BIN_NAME) @ln -s $(BIN_PATH)/$(BIN_NAME) $(BIN_NAME) # Link the executable $(BIN_PATH)/$(BIN_NAME): $(OBJECTS) + $(MAKE) libtfng.a -C tfnoisegen + @cp $(TFRANDDIR)/$(TFRANDLIB) $(LIBS) @echo "Linking: $@" @$(START_TIME) + @echo $(LDFLAGS) + @ls lib/ $(CMD_PREFIX)$(CXX) $(OBJECTS) $(LDFLAGS) -o $@ @echo -en "\t Link time: " @$(END_TIME) diff --git a/src/shred.cpp b/src/shred.cpp index b1281c3..457f7c9 100644 --- a/src/shred.cpp +++ b/src/shred.cpp @@ -7,10 +7,32 @@ #include "../include/reHDD.h" +#ifdef __cplusplus +extern "C" { +#endif +#include "../tfnoisegen/tfprng.h" +#ifdef __cplusplus +} +#endif + const static char *randomsrc = (char*) "/dev/urandom"; + +#define DATASIZE 65536 + + + Shred::Shred() { + +static char data[DATASIZE]; +static char key[TFNG_KEY_SIZE]; +tfng_prng_seedkey(key); + + tfng_prng_genrandom(data, DATASIZE); + + Logger::logThis()->info("RandomData: " + to_string(data[0])); + } Shred::~Shred() diff --git a/tfnoisegen b/tfnoisegen new file mode 160000 index 0000000..488716e --- /dev/null +++ b/tfnoisegen @@ -0,0 +1 @@ +Subproject commit 488716ef22ac5a1aae235a59bea2997ac7e8e45a