Renamed project to "SlunkCrypt", in order to avoid name clashes with existing projects.

This commit is contained in:
LoRd_MuldeR 2020-10-19 21:56:12 +02:00
parent 61a7d1155e
commit f671aef3d7
Signed by: mulder
GPG Key ID: 2B5913365F57E03F
23 changed files with 296 additions and 228 deletions

7
.gitignore vendored
View File

@ -1,6 +1,5 @@
*.o
*.user *.user
/**/bin
/**/lib
/**/obj
/.vs /.vs
/bin
/lib
/obj

View File

@ -7,10 +7,17 @@ MARCH ?= native
MTUNE ?= native MTUNE ?= native
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# FLags # Directories
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
CFLAGS = -IlibMCrypt/include -Wall -Wno-trigraphs -march=$(MARCH) -mtune=$(MTUNE) SUBDIR_APP := frontend
SUBDIR_LIB := libslunkcrypt
# ---------------------------------------------------------------------------
# Flags
# ---------------------------------------------------------------------------
CFLAGS = -I$(SUBDIR_LIB)/include -Wall -Wno-trigraphs -march=$(MARCH) -mtune=$(MTUNE)
ifeq ($(DEBUG),1) ifeq ($(DEBUG),1)
CFLAGS += -Og -g CFLAGS += -Og -g
@ -24,10 +31,6 @@ ifeq ($(OS),Windows_NT)
LDFLGS += -municode -mconsole LDFLGS += -municode -mconsole
endif endif
# ---------------------------------------------------------------------------
# File names
# ---------------------------------------------------------------------------
undefine SUFFIX undefine SUFFIX
ifeq ($(OS),Windows_NT) ifeq ($(OS),Windows_NT)
SUFFIX := .exe SUFFIX := .exe
@ -36,19 +39,26 @@ else
endif endif
ifeq ($(DEBUG),1) ifeq ($(DEBUG),1)
NAMEX := _g CONFIG := _g
else else
undefine NAMEX undefine CONFIG
endif endif
TARGET_APP := bin/mcrypt$(NAMEX)$(SUFFIX) # ---------------------------------------------------------------------------
TARGET_LIB := lib/libmcrypt$(NAMEX)-1.a # File names
# ---------------------------------------------------------------------------
SOURCES_APP := $(wildcard frontend/src/*.c) OUTNAME_APP := slunkcrypt$(CONFIG)$(SUFFIX)
OBJECTS_APP := $(patsubst %.c,%$(NAMEX).o,$(SOURCES_APP)) OUTNAME_LIB := libslunkcrypt$(CONFIG)-1.a
SOURCES_LIB := $(wildcard libMCrypt/src/*.c) OUTPATH_APP := $(SUBDIR_APP)/bin/$(OUTNAME_APP)
OBJECTS_LIB := $(patsubst %.c,%$(NAMEX).o,$(SOURCES_LIB)) OUTPATH_LIB := $(SUBDIR_LIB)/lib/$(OUTNAME_LIB)
SOURCES_APP := $(wildcard $(SUBDIR_APP)/src/*.c)
OBJECTS_APP := $(patsubst $(SUBDIR_APP)/src/%.c,$(SUBDIR_APP)/obj/%$(CONFIG).o,$(SOURCES_APP))
SOURCES_LIB := $(wildcard $(SUBDIR_LIB)/src/*.c)
OBJECTS_LIB := $(patsubst $(SUBDIR_LIB)/src/%.c,$(SUBDIR_LIB)/obj/%$(CONFIG).o,$(SOURCES_LIB))
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# Targets # Targets
@ -56,17 +66,21 @@ OBJECTS_LIB := $(patsubst %.c,%$(NAMEX).o,$(SOURCES_LIB))
.PHONY: all clean .PHONY: all clean
all: $(TARGET_APP) all: $(OUTPATH_APP)
$(TARGET_APP): $(OBJECTS_APP) $(TARGET_LIB) $(OUTPATH_APP): $(OBJECTS_APP) $(OUTPATH_LIB)
@mkdir -p $(@D) @mkdir -p $(@D)
$(CC) $(CFLAGS) $^ -o $@ $(LDFLGS) $(CC) $(CFLAGS) $^ -o $@ $(LDFLGS)
$(TARGET_LIB): $(OBJECTS_LIB) $(OUTPATH_LIB): $(OBJECTS_LIB)
@mkdir -p $(@D) @mkdir -p $(@D)
$(AR) rcs $@ $^ $(AR) rcs $@ $^
%$(NAMEX).o: %.c $(SUBDIR_APP)/obj/%$(CONFIG).o: $(SUBDIR_APP)/src/%.c
@mkdir -p $(@D)
$(CC) $(CFLAGS) -c $< -o $@
$(SUBDIR_LIB)/obj/%$(CONFIG).o: $(SUBDIR_LIB)/src/%.c
@mkdir -p $(@D) @mkdir -p $(@D)
$(CC) $(CFLAGS) -c $< -o $@ $(CC) $(CFLAGS) -c $< -o $@

View File

@ -1,10 +1,12 @@
MCrypt SlunkCrypt
====== ==========
An experimental cryptography library
Legal Warning Legal Warning
------------- -------------
Use of MCrypt may be illegal in countries where encryption is outlawed. We believe it is legal to use MCrypt in a large number of countries, but we are not lawyers, and so if in doubt you should seek legal advice before downloading it. You may find useful information at [cryptolaw.org](http://www.cryptolaw.org/), which collects information on cryptography laws in many countries, but we can't vouch for its correctness. Use of SlunkCrypt may be illegal in countries where encryption is outlawed. We believe it is legal to use SlunkCrypt in many countries all around the world, but we are not lawyers, and so if in doubt you should seek legal advice before downloading it. You may find useful information at [cryptolaw.org](http://www.cryptolaw.org/), which collects information on cryptography laws in many countries, but we can't vouch for its correctness.
License License
------- -------

View File

@ -3,9 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16 # Visual Studio Version 16
VisualStudioVersion = 16.0.30523.141 VisualStudioVersion = 16.0.30523.141
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MCrypt", "frontend\MCrypt.vcxproj", "{86D28793-713E-4CEC-9686-335514AC5EF0}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SlunkCrypt", "frontend\SlunkCrypt.vcxproj", "{86D28793-713E-4CEC-9686-335514AC5EF0}"
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libMCrypt", "libMCrypt\libMCrypt.vcxproj", "{A4A3879C-BD2C-4304-AF66-7349CEF7E4C0}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libSlunkCrypt", "libslunkcrypt\libSlunkCrypt.vcxproj", "{A4A3879C-BD2C-4304-AF66-7349CEF7E4C0}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution

View File

@ -24,11 +24,6 @@
<ClCompile Include="src\main.c" /> <ClCompile Include="src\main.c" />
<ClCompile Include="src\utils.c" /> <ClCompile Include="src\utils.c" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<ProjectReference Include="..\libMCrypt\libMCrypt.vcxproj">
<Project>{a4a3879c-bd2c-4304-af66-7349cef7e4c0}</Project>
</ProjectReference>
</ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="src\crc.h" /> <ClInclude Include="src\crc.h" />
<ClInclude Include="src\platform.h" /> <ClInclude Include="src\platform.h" />
@ -36,13 +31,21 @@
<ClInclude Include="src\utils.h" /> <ClInclude Include="src\utils.h" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ResourceCompile Include="MCrypt.rc" /> <ProjectReference Include="..\libslunkcrypt\libSlunkCrypt.vcxproj">
<Project>{a4a3879c-bd2c-4304-af66-7349cef7e4c0}</Project>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="res\SlunkCrypt.rc" />
</ItemGroup>
<ItemGroup>
<Manifest Include="res\Compatibility.manifest" />
</ItemGroup> </ItemGroup>
<PropertyGroup Label="Globals"> <PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion> <VCProjectVersion>16.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword> <Keyword>Win32Proj</Keyword>
<ProjectGuid>{86d28793-713e-4cec-9686-335514ac5ef0}</ProjectGuid> <ProjectGuid>{86d28793-713e-4cec-9686-335514ac5ef0}</ProjectGuid>
<RootNamespace>MCrypt</RootNamespace> <RootNamespace>SlunkCrypt</RootNamespace>
<WindowsTargetPlatformVersion>7.0</WindowsTargetPlatformVersion> <WindowsTargetPlatformVersion>7.0</WindowsTargetPlatformVersion>
</PropertyGroup> </PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
@ -94,25 +97,25 @@
<LinkIncremental>true</LinkIncremental> <LinkIncremental>true</LinkIncremental>
<OutDir>$(SolutionDir)bin\$(Platform)\$(Configuration)\</OutDir> <OutDir>$(SolutionDir)bin\$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)obj\$(Platform)\$(Configuration)\$(ProjectName)\</IntDir> <IntDir>$(SolutionDir)obj\$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
<TargetName>mcrypt</TargetName> <TargetName>slunkcrypt</TargetName>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental> <LinkIncremental>false</LinkIncremental>
<OutDir>$(SolutionDir)bin\$(Platform)\$(Configuration)\</OutDir> <OutDir>$(SolutionDir)bin\$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)obj\$(Platform)\$(Configuration)\$(ProjectName)\</IntDir> <IntDir>$(SolutionDir)obj\$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
<TargetName>mcrypt</TargetName> <TargetName>slunkcrypt</TargetName>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental> <LinkIncremental>true</LinkIncremental>
<OutDir>$(SolutionDir)bin\$(Platform)\$(Configuration)\</OutDir> <OutDir>$(SolutionDir)bin\$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)obj\$(Platform)\$(Configuration)\$(ProjectName)\</IntDir> <IntDir>$(SolutionDir)obj\$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
<TargetName>mcrypt</TargetName> <TargetName>slunkcrypt</TargetName>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental> <LinkIncremental>false</LinkIncremental>
<OutDir>$(SolutionDir)bin\$(Platform)\$(Configuration)\</OutDir> <OutDir>$(SolutionDir)bin\$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)obj\$(Platform)\$(Configuration)\$(ProjectName)\</IntDir> <IntDir>$(SolutionDir)obj\$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
<TargetName>mcrypt</TargetName> <TargetName>slunkcrypt</TargetName>
</PropertyGroup> </PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile> <ClCompile>
@ -120,8 +123,9 @@
<SDLCheck>true</SDLCheck> <SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode> <ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>$(SolutionDir)libMCrypt\include</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>$(SolutionDir)libSlunkCrypt\include</AdditionalIncludeDirectories>
<DisableSpecificWarnings>4706;4204</DisableSpecificWarnings> <DisableSpecificWarnings>4706;4204</DisableSpecificWarnings>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Console</SubSystem> <SubSystem>Console</SubSystem>
@ -135,7 +139,7 @@
<IntrinsicFunctions>true</IntrinsicFunctions> <IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode> <ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>$(SolutionDir)libMCrypt\include</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>$(SolutionDir)libSlunkCrypt\include</AdditionalIncludeDirectories>
<Optimization>MaxSpeed</Optimization> <Optimization>MaxSpeed</Optimization>
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion> <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed> <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
@ -162,8 +166,9 @@
<SDLCheck>true</SDLCheck> <SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode> <ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>$(SolutionDir)libMCrypt\include</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>$(SolutionDir)libSlunkCrypt\include</AdditionalIncludeDirectories>
<DisableSpecificWarnings>4706;4204</DisableSpecificWarnings> <DisableSpecificWarnings>4706;4204</DisableSpecificWarnings>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Console</SubSystem> <SubSystem>Console</SubSystem>
@ -177,7 +182,7 @@
<IntrinsicFunctions>true</IntrinsicFunctions> <IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode> <ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>$(SolutionDir)libMCrypt\include</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>$(SolutionDir)libSlunkCrypt\include</AdditionalIncludeDirectories>
<Optimization>MaxSpeed</Optimization> <Optimization>MaxSpeed</Optimization>
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion> <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed> <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>

View File

@ -43,8 +43,13 @@
</ClInclude> </ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ResourceCompile Include="MCrypt.rc"> <ResourceCompile Include="res\SlunkCrypt.rc">
<Filter>Resource Files</Filter> <Filter>Resource Files</Filter>
</ResourceCompile> </ResourceCompile>
</ItemGroup> </ItemGroup>
<ItemGroup>
<Manifest Include="res\Compatibility.manifest">
<Filter>Resource Files</Filter>
</Manifest>
</ItemGroup>
</Project> </Project>

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- Windows Vista -->
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
<!-- Windows 7 -->
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
<!-- Windows 8 -->
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
<!-- Windows 8.1 -->
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
<!-- Windows 10 -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
</application>
</compatibility>
</assembly>

View File

@ -6,6 +6,8 @@
#include "WinResrc.h" //"afxres.h" #include "WinResrc.h" //"afxres.h"
#undef APSTUDIO_READONLY_SYMBOLS #undef APSTUDIO_READONLY_SYMBOLS
#include "../../libslunkcrypt/src/version.h"
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// //
// Neutral resources // Neutral resources
@ -20,8 +22,8 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
// Version // Version
// //
VS_VERSION_INFO VERSIONINFO VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,0 FILEVERSION LIB_VERSION_MAJOR, LIB_VERSION_MINOR, LIB_VERSION_PATCH, 0
PRODUCTVERSION 1,0,0,0 PRODUCTVERSION LIB_VERSION_MAJOR, LIB_VERSION_MINOR, LIB_VERSION_PATCH, 0
FILEFLAGSMASK 0x17L FILEFLAGSMASK 0x17L
#ifdef _DEBUG #ifdef _DEBUG
FILEFLAGS 0x3L FILEFLAGS 0x3L
@ -36,16 +38,16 @@ BEGIN
BEGIN BEGIN
BLOCK "000004b0" BLOCK "000004b0"
BEGIN BEGIN
VALUE "ProductName", "MCrypt" VALUE "ProductName", "SlunkCrypt"
VALUE "FileDescription", "MCrypt Utility" VALUE "FileDescription", "SlunkCrypt"
VALUE "ProductVersion", "1.0.0" VALUE "ProductVersion", LIB_VERSION_STRING
VALUE "FileVersion", "1.0.0" VALUE "FileVersion", LIB_VERSION_STRING
VALUE "InternalName", "mcrypt" VALUE "InternalName", "slunkcrypt"
VALUE "OriginalFilename", "mcrypt.exe" VALUE "OriginalFilename", "slunkcrypt.exe"
VALUE "LegalCopyright", "Created by LoRd_MuldeR <MuldeR2@GMX.de>" VALUE "LegalCopyright", "Created by LoRd_MuldeR <MuldeR2@GMX.de>"
VALUE "CompanyName", "Muldersoft" VALUE "CompanyName", "Muldersoft"
VALUE "LegalTrademarks", "Muldersoft" VALUE "LegalTrademarks", "Muldersoft"
VALUE "Comments", "This work has been released under the CC0 1.0 Universal license!" VALUE "Comments", "This work has been released under the CC0 1.0 Universal license!"
END END
END END
BLOCK "VarFileInfo" BLOCK "VarFileInfo"

View File

@ -1,5 +1,5 @@
/******************************************************************************/ /******************************************************************************/
/* MCrypt, by LoRd_MuldeR <MuldeR2@GMX.de> */ /* SlunkCrypt, by LoRd_MuldeR <MuldeR2@GMX.de> */
/* This work has been released under the CC0 1.0 Universal license! */ /* This work has been released under the CC0 1.0 Universal license! */
/******************************************************************************/ /******************************************************************************/

View File

@ -1,5 +1,5 @@
/******************************************************************************/ /******************************************************************************/
/* MCrypt, by LoRd_MuldeR <MuldeR2@GMX.de> */ /* SlunkCrypt, by LoRd_MuldeR <MuldeR2@GMX.de> */
/* This work has been released under the CC0 1.0 Universal license! */ /* This work has been released under the CC0 1.0 Universal license! */
/******************************************************************************/ /******************************************************************************/

View File

@ -1,11 +1,11 @@
/******************************************************************************/ /******************************************************************************/
/* MCrypt, by LoRd_MuldeR <MuldeR2@GMX.de> */ /* SlunkCrypt, by LoRd_MuldeR <MuldeR2@GMX.de> */
/* This work has been released under the CC0 1.0 Universal license! */ /* This work has been released under the CC0 1.0 Universal license! */
/******************************************************************************/ /******************************************************************************/
#define _CRT_SECURE_NO_WARNINGS 1 #define _CRT_SECURE_NO_WARNINGS 1
#include <mcrypt.h> #include <slunkcrypt.h>
#include "utils.h" #include "utils.h"
#include "crc.h" #include "crc.h"
#include "test.h" #include "test.h"
@ -17,7 +17,7 @@
#define BUFF_SIZE 4096U #define BUFF_SIZE 4096U
static const CHR *const ENVV_PASSWD_NAME = T("MCRYPT_PASSWD"); static const CHR *const ENVV_PASSWD_NAME = T("SLUNK_PASSPHRASE");
static char* read_passphrase(const CHR* const file_name) static char* read_passphrase(const CHR* const file_name)
{ {
@ -103,7 +103,7 @@ static int open_files(FILE **const file_in, FILE **const file_out, const CHR* co
static int encrypt(const char* const passphrase, const CHR* const input_path, const CHR* const output_path) static int encrypt(const char* const passphrase, const CHR* const input_path, const CHR* const output_path)
{ {
mcrypt_t ctx = MCRYPT_NULL; slunkcrypt_t ctx = SLUNKCRYPT_NULL;
FILE * file_in = NULL, * file_out = NULL; FILE * file_in = NULL, * file_out = NULL;
int result = 1; int result = 1;
@ -128,9 +128,9 @@ static int encrypt(const char* const passphrase, const CHR* const input_path, co
fflush(stderr); fflush(stderr);
uint64_t seed; uint64_t seed;
if (mcrypt_generate_seed(&seed) != MCRYPT_SUCCESS) if (slunkcrypt_generate_seed(&seed) != SLUNKCRYPT_SUCCESS)
{ {
FPUTS(T("\n\nMCrypt error: Failed to generate seed!\n\n"), stderr); FPUTS(T("\n\nSlunkCrypt error: Failed to generate seed!\n\n"), stderr);
goto clean_up; goto clean_up;
} }
@ -140,10 +140,10 @@ static int encrypt(const char* const passphrase, const CHR* const input_path, co
goto clean_up; goto clean_up;
} }
ctx = mcrypt_alloc(seed, (const uint8_t*)passphrase, strlen(passphrase)); ctx = slunkcrypt_alloc(seed, (const uint8_t*)passphrase, strlen(passphrase));
if (!ctx) if (!ctx)
{ {
FPUTS(g_macrypt_abort_flag ? T("\n\nProcess interrupted!\n\n") : T("\n\nMCrypt error: Failed to initialize encryption!\n\n"), stderr); FPUTS(g_slunkcrypt_abort_flag ? T("\n\nProcess interrupted!\n\n") : T("\n\nSlunkCrypt error: Failed to initialize encryption!\n\n"), stderr);
goto clean_up; goto clean_up;
} }
@ -163,10 +163,10 @@ static int encrypt(const char* const passphrase, const CHR* const input_path, co
{ {
crc_actual = crc64_update(crc_actual, buffer, count); crc_actual = crc64_update(crc_actual, buffer, count);
bytes_read += count; bytes_read += count;
const int status = mcrypt_encrypt_inplace(ctx, buffer, count); const int status = slunkcrypt_encrypt_inplace(ctx, buffer, count);
if (status != MCRYPT_SUCCESS) if (status != SLUNKCRYPT_SUCCESS)
{ {
FPUTS((status == MCRYPT_ABORTED) ? T("\n\nProcess interrupted!\n\n") : T("\n\nMCrypt error: Failed to encrypt data!\n\n"), stderr); FPUTS((status == SLUNKCRYPT_ABORTED) ? T("\n\nProcess interrupted!\n\n") : T("\n\nSlunkCrypt error: Failed to encrypt data!\n\n"), stderr);
goto clean_up; goto clean_up;
} }
if (fwrite(buffer, sizeof(uint8_t), count, file_out) < count) if (fwrite(buffer, sizeof(uint8_t), count, file_out) < count)
@ -218,7 +218,7 @@ clean_up:
if (ctx) if (ctx)
{ {
mcrypt_free(ctx); slunkcrypt_free(ctx);
} }
if (file_out) if (file_out)
@ -236,7 +236,7 @@ clean_up:
static int decrypt(const char* const passphrase, const CHR* const input_path, const CHR* const output_path) static int decrypt(const char* const passphrase, const CHR* const input_path, const CHR* const output_path)
{ {
mcrypt_t ctx = MCRYPT_NULL; slunkcrypt_t ctx = SLUNKCRYPT_NULL;
FILE *file_in = NULL, *file_out = NULL; FILE *file_in = NULL, *file_out = NULL;
int result = 1; int result = 1;
@ -267,10 +267,10 @@ static int decrypt(const char* const passphrase, const CHR* const input_path, co
goto clean_up; goto clean_up;
} }
ctx = mcrypt_alloc(seed, (const uint8_t*)passphrase, strlen(passphrase)); ctx = slunkcrypt_alloc(seed, (const uint8_t*)passphrase, strlen(passphrase));
if (!ctx) if (!ctx)
{ {
FPUTS(g_macrypt_abort_flag ? T("\n\nProcess interrupted!\n\n") : T("\n\nMCrypt error: Failed to initialize decryption!\n\n"), stderr); FPUTS(g_slunkcrypt_abort_flag ? T("\n\nProcess interrupted!\n\n") : T("\n\nSlunkCrypt error: Failed to initialize decryption!\n\n"), stderr);
goto clean_up; goto clean_up;
} }
@ -290,10 +290,10 @@ static int decrypt(const char* const passphrase, const CHR* const input_path, co
if (count > 0U) if (count > 0U)
{ {
bytes_read += count; bytes_read += count;
const int status = mcrypt_decrypt_inplace(ctx, buffer, count); const int status = slunkcrypt_decrypt_inplace(ctx, buffer, count);
if (status != MCRYPT_SUCCESS) if (status != SLUNKCRYPT_SUCCESS)
{ {
FPUTS((status == MCRYPT_ABORTED) ? T("\n\nProcess interrupted!\n\n") : T("\n\nMCrypt error: Failed to decrypt data!\n\n"), stderr); FPUTS((status == SLUNKCRYPT_ABORTED) ? T("\n\nProcess interrupted!\n\n") : T("\n\nSlunkCrypt error: Failed to decrypt data!\n\n"), stderr);
goto clean_up; goto clean_up;
} }
crc_actual = crc64_update(crc_actual, buffer, count); crc_actual = crc64_update(crc_actual, buffer, count);
@ -354,7 +354,7 @@ clean_up:
if (ctx) if (ctx)
{ {
mcrypt_free(ctx); slunkcrypt_free(ctx);
} }
if (file_out) if (file_out)
@ -376,10 +376,10 @@ static int run_test(const char *const message)
const size_t length = strlen(message) + 1U; const size_t length = strlen(message) + 1U;
int status, result = 1; int status, result = 1;
mcrypt_t ctx = MCRYPT_NULL; slunkcrypt_t ctx = SLUNKCRYPT_NULL;
uint64_t seed; uint64_t seed;
if (mcrypt_generate_seed(&seed) != MCRYPT_SUCCESS) if (slunkcrypt_generate_seed(&seed) != SLUNKCRYPT_SUCCESS)
{ {
FPUTS(T("\n\nWhoops: Failed to generate seed!\n\n"), stderr); FPUTS(T("\n\nWhoops: Failed to generate seed!\n\n"), stderr);
return 1; return 1;
@ -392,17 +392,17 @@ static int run_test(const char *const message)
goto clean_up; goto clean_up;
} }
ctx = mcrypt_alloc(seed, (const uint8_t*)passphrase, strlen(passphrase)); ctx = slunkcrypt_alloc(seed, (const uint8_t*)passphrase, strlen(passphrase));
if (!ctx) if (!ctx)
{ {
FPUTS(g_macrypt_abort_flag ? T("\n\nProcess interrupted!\n\n") : T("\n\nWhoops: Failed to initialize encoder!\n\n"), stderr); FPUTS(g_slunkcrypt_abort_flag ? T("\n\nProcess interrupted!\n\n") : T("\n\nWhoops: Failed to initialize encoder!\n\n"), stderr);
goto clean_up; goto clean_up;
} }
status = mcrypt_encrypt_inplace(ctx, (uint8_t*)text_temp, length); status = slunkcrypt_encrypt_inplace(ctx, (uint8_t*)text_temp, length);
if (status != MCRYPT_SUCCESS) if (status != SLUNKCRYPT_SUCCESS)
{ {
FPUTS((status == MCRYPT_ABORTED) ? T("\n\nProcess interrupted!\n\n") : T("\n\nWhoops: Failed to encrypt the message!\n\n"), stderr); FPUTS((status == SLUNKCRYPT_ABORTED) ? T("\n\nProcess interrupted!\n\n") : T("\n\nWhoops: Failed to encrypt the message!\n\n"), stderr);
goto clean_up; goto clean_up;
} }
@ -412,17 +412,17 @@ static int run_test(const char *const message)
goto clean_up; goto clean_up;
} }
status = mcrypt_reset(ctx, seed, (const uint8_t*)passphrase, strlen(passphrase)); status = slunkcrypt_reset(ctx, seed, (const uint8_t*)passphrase, strlen(passphrase));
if (status != MCRYPT_SUCCESS) if (status != SLUNKCRYPT_SUCCESS)
{ {
FPUTS((status == MCRYPT_ABORTED) ? T("\n\nProcess interrupted!\n\n") : T("\n\nWhoops: Failed to initialize decoder!\n\n"), stderr); FPUTS((status == SLUNKCRYPT_ABORTED) ? T("\n\nProcess interrupted!\n\n") : T("\n\nWhoops: Failed to initialize decoder!\n\n"), stderr);
goto clean_up; goto clean_up;
} }
status = mcrypt_decrypt_inplace(ctx, (uint8_t*)text_temp, length); status = slunkcrypt_decrypt_inplace(ctx, (uint8_t*)text_temp, length);
if (status != MCRYPT_SUCCESS) if (status != SLUNKCRYPT_SUCCESS)
{ {
FPUTS((status == MCRYPT_ABORTED) ? T("\n\nProcess interrupted!\n\n") : T("\n\nWhoops: Failed to decrypt the message!\n\n"), stderr); FPUTS((status == SLUNKCRYPT_ABORTED) ? T("\n\nProcess interrupted!\n\n") : T("\n\nWhoops: Failed to decrypt the message!\n\n"), stderr);
goto clean_up; goto clean_up;
} }
@ -438,12 +438,12 @@ clean_up:
if (ctx) if (ctx)
{ {
mcrypt_free(ctx); slunkcrypt_free(ctx);
} }
if (text_temp) if (text_temp)
{ {
mcrypt_bzero(text_temp, strlen(text_temp)); slunkcrypt_bzero(text_temp, strlen(text_temp));
free(text_temp); free(text_temp);
} }
@ -482,7 +482,7 @@ static void sigint_handler(const int sig)
{ {
if (sig == SIGINT) if (sig == SIGINT)
{ {
g_macrypt_abort_flag = 1; g_slunkcrypt_abort_flag = 1;
signal(SIGINT, sigint_handler); signal(SIGINT, sigint_handler);
} }
} }
@ -492,8 +492,8 @@ int MAIN(int argc, CHR* argv[])
init_terminal(); init_terminal();
signal(SIGINT, sigint_handler); signal(SIGINT, sigint_handler);
FPRINTF(stderr, T("MCrypt Utility (%") T(PRIstr) T("-%") T(PRIstr) T("), by LoRd_MuldeR <MuldeR2@GMX.de>\n"), OS_TYPE, CPU_ARCH); FPRINTF(stderr, T("SlunkCrypt Utility (%") T(PRIstr) T("-%") T(PRIstr) T("), by LoRd_MuldeR <MuldeR2@GMX.de>\n"), OS_TYPE, CPU_ARCH);
FPRINTF(stderr, T("Using libMCrypt v%") T(PRIstr) T(" [%") T(PRIstr) T("]\n\n"), LIBMCRYPT_VERSION, LIBMCRYPT_BUILDNO); FPRINTF(stderr, T("Using libSlunkCrypt v%") T(PRIstr) T(" [%") T(PRIstr) T("]\n\n"), SLUNKCRYPT_VERSION, SLUNKCRYPT_BUILD);
if (argc > 1) if (argc > 1)
{ {
@ -511,13 +511,13 @@ int MAIN(int argc, CHR* argv[])
FPUTS(T("Synopsis:\n"), stderr); FPUTS(T("Synopsis:\n"), stderr);
FPRINTF(stderr, T(" %") T(PRISTR) T(" --encrypt [[@][:]<passphrase>] <input.txt> <output.enc>\n"), program); FPRINTF(stderr, T(" %") T(PRISTR) T(" --encrypt [[@][:]<passphrase>] <input.txt> <output.enc>\n"), program);
FPRINTF(stderr, T(" %") T(PRISTR) T(" --decrypt [[@][:]<passphrase>] <input.enc> <output.txt>\n\n"), program); FPRINTF(stderr, T(" %") T(PRISTR) T(" --decrypt [[@][:]<passphrase>] <input.enc> <output.txt>\n\n"), program);
FPUTS(T("Remarks:\n"), stderr); FPUTS(T("Options:\n"), stderr);
FPUTS(T("- If <passphrase> is prefixed with a '@' character, then it specifies the file\n"), stderr); FPUTS(T("- If <passphrase> is prefixed with a '@' character, then it specifies the file\n"), stderr);
FPUTS(T(" to read the passphrase from; only the first line in that file is used!\n"), stderr); FPUTS(T(" to read the passphrase from; only the first line in that file is used!\n"), stderr);
FPUTS(T("- If <passphrase> is prefixed with a ':' character, then the leading character\n"), stderr); FPUTS(T("- If <passphrase> is prefixed with a ':' character, then the leading character\n"), stderr);
FPUTS(T(" is skipped and the remainder of the argument is used as passphrase.\n"), stderr); FPUTS(T(" is skipped and the remainder of the argument is used as passphrase.\n"), stderr);
FPUTS(T("- If the argument <passphrase> is *not* present, then the environment variable\n"), stderr); FPUTS(T("- If argument <passphrase> is omitted, then the passphrase is read from the\n"), stderr);
FPRINTF(stderr, T(" \"%") T(PRISTR) T("\" must be set; it specifies the passphrase to be used.\n"), ENVV_PASSWD_NAME); FPRINTF(stderr, T(" environment variable \"%") T(PRISTR) T("\" instead.\n"), ENVV_PASSWD_NAME);
FPUTS(T("- Specify \"@-\" in order to read the passphrase from the standard input stream!\n\n"), stderr); FPUTS(T("- Specify \"@-\" in order to read the passphrase from the standard input stream!\n\n"), stderr);
return 0; return 0;
} }
@ -560,7 +560,7 @@ int MAIN(int argc, CHR* argv[])
return 1; return 1;
} }
mcrypt_bzero((CHR*)passphrase, STRLEN(passphrase) * sizeof(CHR)); slunkcrypt_bzero((CHR*)passphrase, STRLEN(passphrase) * sizeof(CHR));
if (strlen(passphrase_buffer) < 12U) if (strlen(passphrase_buffer) < 12U)
{ {
@ -588,7 +588,7 @@ int MAIN(int argc, CHR* argv[])
goto exiting; goto exiting;
} }
if (!g_macrypt_abort_flag) if (!g_slunkcrypt_abort_flag)
{ {
FPUTS(T("--------\n\n"), stderr); FPUTS(T("--------\n\n"), stderr);
fflush(stderr); fflush(stderr);
@ -600,7 +600,7 @@ exiting:
if (passphrase_buffer) if (passphrase_buffer)
{ {
mcrypt_bzero(passphrase_buffer, strlen(passphrase_buffer)); slunkcrypt_bzero(passphrase_buffer, strlen(passphrase_buffer));
free(passphrase_buffer); free(passphrase_buffer);
} }

View File

@ -1,5 +1,5 @@
/******************************************************************************/ /******************************************************************************/
/* MCrypt, by LoRd_MuldeR <MuldeR2@GMX.de> */ /* SlunkCrypt, by LoRd_MuldeR <MuldeR2@GMX.de> */
/* This work has been released under the CC0 1.0 Universal license! */ /* This work has been released under the CC0 1.0 Universal license! */
/******************************************************************************/ /******************************************************************************/

View File

@ -1,5 +1,5 @@
/******************************************************************************/ /******************************************************************************/
/* MCrypt, by LoRd_MuldeR <MuldeR2@GMX.de> */ /* SlunkCrypt, by LoRd_MuldeR <MuldeR2@GMX.de> */
/* This work has been released under the CC0 1.0 Universal license! */ /* This work has been released under the CC0 1.0 Universal license! */
/******************************************************************************/ /******************************************************************************/

View File

@ -1,5 +1,5 @@
/******************************************************************************/ /******************************************************************************/
/* MCrypt, by LoRd_MuldeR <MuldeR2@GMX.de> */ /* SlunkCrypt, by LoRd_MuldeR <MuldeR2@GMX.de> */
/* This work has been released under the CC0 1.0 Universal license! */ /* This work has been released under the CC0 1.0 Universal license! */
/******************************************************************************/ /******************************************************************************/

View File

@ -1,5 +1,5 @@
/******************************************************************************/ /******************************************************************************/
/* MCrypt, by LoRd_MuldeR <MuldeR2@GMX.de> */ /* SlunkCrypt, by LoRd_MuldeR <MuldeR2@GMX.de> */
/* This work has been released under the CC0 1.0 Universal license! */ /* This work has been released under the CC0 1.0 Universal license! */
/******************************************************************************/ /******************************************************************************/

View File

@ -1,5 +1,5 @@
/******************************************************************************/ /******************************************************************************/
/* MCrypt, by LoRd_MuldeR <MuldeR2@GMX.de> */ /* SlunkCrypt, by LoRd_MuldeR <MuldeR2@GMX.de> */
/* This work has been released under the CC0 1.0 Universal license! */ /* This work has been released under the CC0 1.0 Universal license! */
/******************************************************************************/ /******************************************************************************/

View File

@ -1,66 +0,0 @@
/******************************************************************************/
/* MCrypt, by LoRd_MuldeR <MuldeR2@GMX.de> */
/* This work has been released under the CC0 1.0 Universal license! */
/******************************************************************************/
#ifndef INC_MCYRPT_H
#define INC_MCYRPT_H
#include <stdlib.h>
#include <stdint.h>
/*
* Version info
*/
extern const char *const LIBMCRYPT_VERSION;
extern const char* const LIBMCRYPT_BUILDNO;
/*
* Abort flag
*/
extern volatile int g_macrypt_abort_flag;
/*
* Opaque handle to internal state
*/
typedef uintptr_t mcrypt_t;
/*
* Constants
*/
#define MCRYPT_NULL ((mcrypt_t)NULL)
#define MCRYPT_SUCCESS 0
#define MCRYPT_FAILURE (-1)
#define MCRYPT_ABORTED (-2)
/*
* Seed generator
*/
int mcrypt_generate_seed(uint64_t* const seed);
/*
* Allocate, reset or free state
*/
mcrypt_t mcrypt_alloc(const uint64_t salt, const uint8_t *const passwd, const size_t passwd_len);
int mcrypt_reset(const mcrypt_t context, const uint64_t salt, const uint8_t *const passwd, const size_t passwd_len);
void mcrypt_free(const mcrypt_t context);
/*
* Encryption routines
*/
int mcrypt_encrypt(const mcrypt_t context, const uint8_t *const input, uint8_t* const output, size_t length);
int mcrypt_encrypt_inplace(const mcrypt_t context, uint8_t *const buffer, size_t length);
/*
* Decryption routines
*/
int mcrypt_decrypt(const mcrypt_t context, const uint8_t *const input, uint8_t *const output, size_t length);
int mcrypt_decrypt_inplace(const mcrypt_t context, uint8_t* const buffer, size_t length);
/*
* Auxiliary functions
*/
int mcrypt_random_bytes(uint8_t* const buffer, const size_t length);
void mcrypt_bzero(void* const ptr, const size_t length);
#endif

View File

@ -0,0 +1,66 @@
/******************************************************************************/
/* SlunkCrypt, by LoRd_MuldeR <MuldeR2@GMX.de> */
/* This work has been released under the CC0 1.0 Universal license! */
/******************************************************************************/
#ifndef INC_SLUNKCRYPT_H
#define INC_SLUNKCRYPT_H
#include <stdlib.h>
#include <stdint.h>
/*
* Version info
*/
extern const char *const SLUNKCRYPT_VERSION;
extern const char* const SLUNKCRYPT_BUILD;
/*
* Abort flag
*/
extern volatile int g_slunkcrypt_abort_flag;
/*
* Opaque handle to internal state
*/
typedef uintptr_t slunkcrypt_t;
/*
* Constants
*/
#define SLUNKCRYPT_NULL ((slunkcrypt_t)NULL)
#define SLUNKCRYPT_SUCCESS 0
#define SLUNKCRYPT_FAILURE (-1)
#define SLUNKCRYPT_ABORTED (-2)
/*
* Seed generator
*/
int slunkcrypt_generate_seed(uint64_t* const seed);
/*
* Allocate, reset or free state
*/
slunkcrypt_t slunkcrypt_alloc(const uint64_t salt, const uint8_t *const passwd, const size_t passwd_len);
int slunkcrypt_reset(const slunkcrypt_t context, const uint64_t salt, const uint8_t *const passwd, const size_t passwd_len);
void slunkcrypt_free(const slunkcrypt_t context);
/*
* Encryption routines
*/
int slunkcrypt_encrypt(const slunkcrypt_t context, const uint8_t *const input, uint8_t* const output, size_t length);
int slunkcrypt_encrypt_inplace(const slunkcrypt_t context, uint8_t *const buffer, size_t length);
/*
* Decryption routines
*/
int slunkcrypt_decrypt(const slunkcrypt_t context, const uint8_t *const input, uint8_t *const output, size_t length);
int slunkcrypt_decrypt_inplace(const slunkcrypt_t context, uint8_t* const buffer, size_t length);
/*
* Auxiliary functions
*/
int slunkcrypt_random_bytes(uint8_t* const buffer, const size_t length);
void slunkcrypt_bzero(void* const ptr, const size_t length);
#endif

View File

@ -19,17 +19,18 @@
</ProjectConfiguration> </ProjectConfiguration>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="src\mcrypt.c" />
<ClCompile Include="src\internal.c" /> <ClCompile Include="src\internal.c" />
<ClCompile Include="src\slunkcrypt.c" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="include\mcrypt.h" /> <ClInclude Include="include\slunkcrypt.h" />
<ClInclude Include="src\version.h" />
</ItemGroup> </ItemGroup>
<PropertyGroup Label="Globals"> <PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion> <VCProjectVersion>16.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword> <Keyword>Win32Proj</Keyword>
<ProjectGuid>{a4a3879c-bd2c-4304-af66-7349cef7e4c0}</ProjectGuid> <ProjectGuid>{a4a3879c-bd2c-4304-af66-7349cef7e4c0}</ProjectGuid>
<RootNamespace>libMCrypt</RootNamespace> <RootNamespace>libSlunkCrypt</RootNamespace>
<WindowsTargetPlatformVersion>7.0</WindowsTargetPlatformVersion> <WindowsTargetPlatformVersion>7.0</WindowsTargetPlatformVersion>
</PropertyGroup> </PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
@ -81,25 +82,25 @@
<LinkIncremental>true</LinkIncremental> <LinkIncremental>true</LinkIncremental>
<OutDir>$(SolutionDir)bin\$(Platform)\$(Configuration)\</OutDir> <OutDir>$(SolutionDir)bin\$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)obj\$(Platform)\$(Configuration)\$(ProjectName)\</IntDir> <IntDir>$(SolutionDir)obj\$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
<TargetName>libmcrypt-1</TargetName> <TargetName>libslunkcrypt-1</TargetName>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental> <LinkIncremental>false</LinkIncremental>
<OutDir>$(SolutionDir)bin\$(Platform)\$(Configuration)\</OutDir> <OutDir>$(SolutionDir)bin\$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)obj\$(Platform)\$(Configuration)\$(ProjectName)\</IntDir> <IntDir>$(SolutionDir)obj\$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
<TargetName>libmcrypt-1</TargetName> <TargetName>libslunkcrypt-1</TargetName>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental> <LinkIncremental>true</LinkIncremental>
<OutDir>$(SolutionDir)bin\$(Platform)\$(Configuration)\</OutDir> <OutDir>$(SolutionDir)bin\$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)obj\$(Platform)\$(Configuration)\$(ProjectName)\</IntDir> <IntDir>$(SolutionDir)obj\$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
<TargetName>libmcrypt-1</TargetName> <TargetName>libslunkcrypt-1</TargetName>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental> <LinkIncremental>false</LinkIncremental>
<OutDir>$(SolutionDir)bin\$(Platform)\$(Configuration)\</OutDir> <OutDir>$(SolutionDir)bin\$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)obj\$(Platform)\$(Configuration)\$(ProjectName)\</IntDir> <IntDir>$(SolutionDir)obj\$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
<TargetName>libmcrypt-1</TargetName> <TargetName>libslunkcrypt-1</TargetName>
</PropertyGroup> </PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile> <ClCompile>
@ -110,6 +111,7 @@
<PrecompiledHeader>NotUsing</PrecompiledHeader> <PrecompiledHeader>NotUsing</PrecompiledHeader>
<AdditionalIncludeDirectories>$(ProjectDir)include</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>$(ProjectDir)include</AdditionalIncludeDirectories>
<DisableSpecificWarnings>4706;4204</DisableSpecificWarnings> <DisableSpecificWarnings>4706;4204</DisableSpecificWarnings>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem> <SubSystem>
@ -155,6 +157,7 @@
<PrecompiledHeader>NotUsing</PrecompiledHeader> <PrecompiledHeader>NotUsing</PrecompiledHeader>
<AdditionalIncludeDirectories>$(ProjectDir)include</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>$(ProjectDir)include</AdditionalIncludeDirectories>
<DisableSpecificWarnings>4706;4204</DisableSpecificWarnings> <DisableSpecificWarnings>4706;4204</DisableSpecificWarnings>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem> <SubSystem>

View File

@ -15,15 +15,18 @@
</Filter> </Filter>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="src\mcrypt.c"> <ClCompile Include="src\internal.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="src\internal.c"> <ClCompile Include="src\slunkcrypt.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="include\mcrypt.h"> <ClInclude Include="include\slunkcrypt.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\version.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
</ItemGroup> </ItemGroup>

View File

@ -1,5 +1,5 @@
/******************************************************************************/ /******************************************************************************/
/* MCrypt, by LoRd_MuldeR <MuldeR2@GMX.de> */ /* SlunkCrypt, by LoRd_MuldeR <MuldeR2@GMX.de> */
/* This work has been released under the CC0 1.0 Universal license! */ /* This work has been released under the CC0 1.0 Universal license! */
/******************************************************************************/ /******************************************************************************/
@ -8,7 +8,7 @@
#define WIN32_LEAN_AND_MEAN 1 #define WIN32_LEAN_AND_MEAN 1
#endif #endif
#include <mcrypt.h> #include <slunkcrypt.h>
#ifdef _WIN32 #ifdef _WIN32
#include <Windows.h> #include <Windows.h>
@ -29,7 +29,7 @@
#endif #endif
#endif #endif
int mcrypt_random_bytes(uint8_t* const buffer, const size_t length) int slunkcrypt_random_bytes(uint8_t* const buffer, const size_t length)
{ {
#ifdef _WIN32 #ifdef _WIN32
size_t pos = 0U; size_t pos = 0U;
@ -76,7 +76,7 @@ int mcrypt_random_bytes(uint8_t* const buffer, const size_t length)
#endif #endif
} }
void mcrypt_bzero(void* const ptr, const size_t length) void slunkcrypt_bzero(void* const ptr, const size_t length)
{ {
if ((ptr) && (length > 0U)) if ((ptr) && (length > 0U))
{ {

View File

@ -1,5 +1,5 @@
/******************************************************************************/ /******************************************************************************/
/* MCrypt, by LoRd_MuldeR <MuldeR2@GMX.de> */ /* SlunkCrypt, by LoRd_MuldeR <MuldeR2@GMX.de> */
/* This work has been released under the CC0 1.0 Universal license! */ /* This work has been released under the CC0 1.0 Universal license! */
/******************************************************************************/ /******************************************************************************/
@ -7,8 +7,9 @@
#define _CRT_RAND_S 1 #define _CRT_RAND_S 1
#endif #endif
#include <mcrypt.h> #include <slunkcrypt.h>
#include <string.h> #include <string.h>
#include "version.h"
#ifdef _MSC_VER #ifdef _MSC_VER
#define FORCE_INLINE __forceinline #define FORCE_INLINE __forceinline
@ -23,8 +24,8 @@
#endif #endif
#endif #endif
const char* const LIBMCRYPT_VERSION = "1.0.0"; const char* const SLUNKCRYPT_VERSION = LIB_VERSION_STRING;
const char* const LIBMCRYPT_BUILDNO = __DATE__", "__TIME__; const char* const SLUNKCRYPT_BUILD = __DATE__", "__TIME__;
typedef struct typedef struct
{ {
@ -55,13 +56,13 @@ rand_state_t;
// Abort flag // Abort flag
// ========================================================================== // ==========================================================================
volatile int g_macrypt_abort_flag = 0; volatile int g_slunkcrypt_abort_flag = 0;
#define CHECK_ABORTED() do \ #define CHECK_ABORTED() do \
{ \ { \
if (g_macrypt_abort_flag) \ if (g_slunkcrypt_abort_flag) \
{ \ { \
return MCRYPT_ABORTED; \ return SLUNKCRYPT_ABORTED; \
} \ } \
} \ } \
while (0) while (0)
@ -113,7 +114,7 @@ static void generate_key(key_data_t *const key, const uint64_t salt, const uint1
static void random_init(rand_state_t* const state, const uint64_t seed_0, const uint64_t seed_1) static void random_init(rand_state_t* const state, const uint64_t seed_0, const uint64_t seed_1)
{ {
mcrypt_bzero(state, sizeof(rand_state_t)); slunkcrypt_bzero(state, sizeof(rand_state_t));
state->a = (uint32_t)( seed_0 & 0xFFFFFFFF); state->a = (uint32_t)( seed_0 & 0xFFFFFFFF);
state->b = (uint32_t)((seed_0 >> 32) & 0xFFFFFFFF); state->b = (uint32_t)((seed_0 >> 32) & 0xFFFFFFFF);
state->c = (uint32_t)( seed_1 & 0xFFFFFFFF); state->c = (uint32_t)( seed_1 & 0xFFFFFFFF);
@ -139,7 +140,7 @@ static void random_seed(rand_state_t* const state, const uint64_t salt, const ui
key_data_t key; key_data_t key;
generate_key(&key, salt, pepper, passwd, passwd_len); generate_key(&key, salt, pepper, passwd, passwd_len);
random_init(state, key.a, key.b); random_init(state, key.a, key.b);
mcrypt_bzero(&key, sizeof(key_data_t)); slunkcrypt_bzero(&key, sizeof(key_data_t));
for (size_t i = 0U; i < 97U; ++i) for (size_t i = 0U; i < 97U; ++i)
{ {
volatile UNUSED uint32_t u = random_next(state); volatile UNUSED uint32_t u = random_next(state);
@ -152,7 +153,7 @@ static void random_seed(rand_state_t* const state, const uint64_t salt, const ui
static int initialize_state(crypt_state_t* const crypt_state, const uint64_t salt, const uint8_t* const passwd, const size_t passwd_len) static int initialize_state(crypt_state_t* const crypt_state, const uint64_t salt, const uint8_t* const passwd, const size_t passwd_len)
{ {
mcrypt_bzero(crypt_state, sizeof(crypt_state_t)); slunkcrypt_bzero(crypt_state, sizeof(crypt_state_t));
/* set up wheels and initial rotation */ /* set up wheels and initial rotation */
rand_state_t rand_state; rand_state_t rand_state;
@ -192,8 +193,8 @@ static int initialize_state(crypt_state_t* const crypt_state, const uint64_t sal
crypt_state->step_bwd[j] = (uint8_t)(255U - i); crypt_state->step_bwd[j] = (uint8_t)(255U - i);
} }
mcrypt_bzero(&rand_state, sizeof(rand_state_t)); slunkcrypt_bzero(&rand_state, sizeof(rand_state_t));
return MCRYPT_SUCCESS; return SLUNKCRYPT_SUCCESS;
} }
// ========================================================================== // ==========================================================================
@ -239,127 +240,127 @@ static FORCE_INLINE uint8_t process_dec(crypt_state_t* const crypt_state, uint8_
// Public API // Public API
// ========================================================================== // ==========================================================================
int mcrypt_generate_seed(uint64_t* const seed) int slunkcrypt_generate_seed(uint64_t* const seed)
{ {
if (!seed) if (!seed)
{ {
return MCRYPT_FAILURE; return SLUNKCRYPT_FAILURE;
} }
do do
{ {
if (mcrypt_random_bytes((uint8_t*)seed, sizeof(uint64_t)) != 0) if (slunkcrypt_random_bytes((uint8_t*)seed, sizeof(uint64_t)) != 0)
{ {
return MCRYPT_FAILURE; return SLUNKCRYPT_FAILURE;
} }
} }
while (!(*seed)); while (!(*seed));
return MCRYPT_SUCCESS; return SLUNKCRYPT_SUCCESS;
} }
mcrypt_t mcrypt_alloc(const uint64_t salt, const uint8_t *const passwd, const size_t passwd_len) slunkcrypt_t slunkcrypt_alloc(const uint64_t salt, const uint8_t *const passwd, const size_t passwd_len)
{ {
if ((!passwd) || (passwd_len < 1U)) if ((!passwd) || (passwd_len < 1U))
{ {
return MCRYPT_NULL; return SLUNKCRYPT_NULL;
} }
crypt_state_t* const state = (crypt_state_t*)malloc(sizeof(crypt_state_t)); crypt_state_t* const state = (crypt_state_t*)malloc(sizeof(crypt_state_t));
if (!state) if (!state)
{ {
return MCRYPT_NULL; return SLUNKCRYPT_NULL;
} }
if (initialize_state(state, salt, passwd, passwd_len) == MCRYPT_SUCCESS) if (initialize_state(state, salt, passwd, passwd_len) == SLUNKCRYPT_SUCCESS)
{ {
return ((mcrypt_t)state); return ((slunkcrypt_t)state);
} }
else else
{ {
mcrypt_bzero(state, sizeof(crypt_state_t)); slunkcrypt_bzero(state, sizeof(crypt_state_t));
return MCRYPT_NULL; return SLUNKCRYPT_NULL;
} }
} }
int mcrypt_reset(const mcrypt_t context, const uint64_t salt, const uint8_t *const passwd, const size_t passwd_len) int slunkcrypt_reset(const slunkcrypt_t context, const uint64_t salt, const uint8_t *const passwd, const size_t passwd_len)
{ {
crypt_state_t* const state = (crypt_state_t*)context; crypt_state_t* const state = (crypt_state_t*)context;
if ((!state) || (!passwd) || (passwd_len < 1U)) if ((!state) || (!passwd) || (passwd_len < 1U))
{ {
return MCRYPT_FAILURE; return SLUNKCRYPT_FAILURE;
} }
const int result = initialize_state(state, salt, passwd, passwd_len); const int result = initialize_state(state, salt, passwd, passwd_len);
if (result != MCRYPT_SUCCESS) if (result != SLUNKCRYPT_SUCCESS)
{ {
mcrypt_bzero(state, sizeof(crypt_state_t)); slunkcrypt_bzero(state, sizeof(crypt_state_t));
} }
return result; return result;
} }
int mcrypt_encrypt(const mcrypt_t context, const uint8_t* const input, uint8_t* const output, size_t length) int slunkcrypt_encrypt(const slunkcrypt_t context, const uint8_t* const input, uint8_t* const output, size_t length)
{ {
crypt_state_t* const state = (crypt_state_t*)context; crypt_state_t* const state = (crypt_state_t*)context;
if (!state) if (!state)
{ {
return MCRYPT_FAILURE; return SLUNKCRYPT_FAILURE;
} }
for (size_t i = 0; i < length; ++i) for (size_t i = 0; i < length; ++i)
{ {
output[i] = process_enc(state, input[i]); output[i] = process_enc(state, input[i]);
CHECK_ABORTED(); CHECK_ABORTED();
} }
return MCRYPT_SUCCESS; return SLUNKCRYPT_SUCCESS;
} }
int mcrypt_encrypt_inplace(const mcrypt_t context, uint8_t* const buffer, size_t length) int slunkcrypt_encrypt_inplace(const slunkcrypt_t context, uint8_t* const buffer, size_t length)
{ {
crypt_state_t* const state = (crypt_state_t*)context; crypt_state_t* const state = (crypt_state_t*)context;
if (!state) if (!state)
{ {
return MCRYPT_FAILURE; return SLUNKCRYPT_FAILURE;
} }
for (size_t i = 0; i < length; ++i) for (size_t i = 0; i < length; ++i)
{ {
buffer[i] = process_enc(state, buffer[i]); buffer[i] = process_enc(state, buffer[i]);
CHECK_ABORTED(); CHECK_ABORTED();
} }
return MCRYPT_SUCCESS; return SLUNKCRYPT_SUCCESS;
} }
int mcrypt_decrypt(const mcrypt_t context, const uint8_t* const input, uint8_t* const output, size_t length) int slunkcrypt_decrypt(const slunkcrypt_t context, const uint8_t* const input, uint8_t* const output, size_t length)
{ {
crypt_state_t* const state = (crypt_state_t*)context; crypt_state_t* const state = (crypt_state_t*)context;
if (!state) if (!state)
{ {
return MCRYPT_FAILURE; return SLUNKCRYPT_FAILURE;
} }
for (size_t i = 0; i < length; ++i) for (size_t i = 0; i < length; ++i)
{ {
output[i] = process_dec(state, input[i]); output[i] = process_dec(state, input[i]);
CHECK_ABORTED(); CHECK_ABORTED();
} }
return MCRYPT_SUCCESS; return SLUNKCRYPT_SUCCESS;
} }
int mcrypt_decrypt_inplace(const mcrypt_t context, uint8_t* const buffer, size_t length) int slunkcrypt_decrypt_inplace(const slunkcrypt_t context, uint8_t* const buffer, size_t length)
{ {
crypt_state_t* const state = (crypt_state_t*)context; crypt_state_t* const state = (crypt_state_t*)context;
if (!state) if (!state)
{ {
return MCRYPT_FAILURE; return SLUNKCRYPT_FAILURE;
} }
for (size_t i = 0; i < length; ++i) for (size_t i = 0; i < length; ++i)
{ {
buffer[i] = process_dec(state, buffer[i]); buffer[i] = process_dec(state, buffer[i]);
CHECK_ABORTED(); CHECK_ABORTED();
} }
return MCRYPT_SUCCESS; return SLUNKCRYPT_SUCCESS;
} }
void mcrypt_free(const mcrypt_t context) void slunkcrypt_free(const slunkcrypt_t context)
{ {
crypt_state_t* const state = (crypt_state_t*)context; crypt_state_t* const state = (crypt_state_t*)context;
if (state) if (state)
{ {
mcrypt_bzero(state, sizeof(crypt_state_t)); slunkcrypt_bzero(state, sizeof(crypt_state_t));
free(state); free(state);
} }
} }

View File

@ -0,0 +1,17 @@
/******************************************************************************/
/* SlunkCrypt, by LoRd_MuldeR <MuldeR2@GMX.de> */
/* This work has been released under the CC0 1.0 Universal license! */
/******************************************************************************/
#ifndef INC_SLUNKCRYPT_VERSION_H
#define INC_SLUNKCRYPT_VERSION_H
#define LIB_VERSION_MAJOR 1
#define LIB_VERSION_MINOR 0
#define LIB_VERSION_PATCH 0
#define VERSION_HELPER1(X,Y,Z) #X "." #Y "." #Z
#define VERSION_HELPER2(X,Y,Z) VERSION_HELPER1(X,Y,Z)
#define LIB_VERSION_STRING VERSION_HELPER2(LIB_VERSION_MAJOR,LIB_VERSION_MINOR,LIB_VERSION_PATCH)
#endif