Initial commit. Version 1.0.0. Contains
- MD5 - SHA1 - SHA256 - SHA512 - RC4
This commit is contained in:
18
.gitignore
vendored
Normal file
18
.gitignore
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
# top level build directories #
|
||||
/Bin*/
|
||||
/Build*/
|
||||
/Out*/
|
||||
Intermediates/
|
||||
Products/
|
||||
|
||||
# visual studio files #
|
||||
*.user
|
||||
*.ncb
|
||||
*.suo
|
||||
*.pdb
|
||||
*.aps
|
||||
*.ipch
|
||||
|
||||
# Xcode files #
|
||||
xcuserdata/
|
||||
.DS_Store
|
||||
BIN
Exe/Linux/Md5String
Normal file
BIN
Exe/Linux/Md5String
Normal file
Binary file not shown.
BIN
Exe/Linux/Rc4Output
Normal file
BIN
Exe/Linux/Rc4Output
Normal file
Binary file not shown.
BIN
Exe/Linux/Sha1String
Normal file
BIN
Exe/Linux/Sha1String
Normal file
Binary file not shown.
BIN
Exe/Linux/Sha256String
Normal file
BIN
Exe/Linux/Sha256String
Normal file
Binary file not shown.
BIN
Exe/Linux/Sha512String
Normal file
BIN
Exe/Linux/Sha512String
Normal file
Binary file not shown.
BIN
Exe/OSX/Md5String
Normal file
BIN
Exe/OSX/Md5String
Normal file
Binary file not shown.
BIN
Exe/OSX/Rc4Output
Normal file
BIN
Exe/OSX/Rc4Output
Normal file
Binary file not shown.
BIN
Exe/OSX/Sha1String
Normal file
BIN
Exe/OSX/Sha1String
Normal file
Binary file not shown.
BIN
Exe/OSX/Sha256String
Normal file
BIN
Exe/OSX/Sha256String
Normal file
Binary file not shown.
BIN
Exe/OSX/Sha512String
Normal file
BIN
Exe/OSX/Sha512String
Normal file
Binary file not shown.
BIN
Exe/Windows/Md5String.exe
Normal file
BIN
Exe/Windows/Md5String.exe
Normal file
Binary file not shown.
BIN
Exe/Windows/Rc4Output.exe
Normal file
BIN
Exe/Windows/Rc4Output.exe
Normal file
Binary file not shown.
BIN
Exe/Windows/Sha1String.exe
Normal file
BIN
Exe/Windows/Sha1String.exe
Normal file
Binary file not shown.
BIN
Exe/Windows/Sha256String.exe
Normal file
BIN
Exe/Windows/Sha256String.exe
Normal file
Binary file not shown.
BIN
Exe/Windows/Sha512String.exe
Normal file
BIN
Exe/Windows/Sha512String.exe
Normal file
Binary file not shown.
85
Projects.sln
Normal file
85
Projects.sln
Normal file
@@ -0,0 +1,85 @@
|
||||
Microsoft Visual Studio Solution File, Format Version 11.00
|
||||
# Visual Studio 2010
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ProofOfWork", "VSProjectFiles\ProofOfWork.vcxproj", "{78DE2AA5-4DEB-4601-AAB8-A3452BAC810C}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Md5String", "VSProjectFiles\Md5String.vcxproj", "{2F5CA1B6-92CC-4142-86AC-62FADFF0B834}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Rc4Output", "VSProjectFiles\Rc4Output.vcxproj", "{E5A739D1-4246-4FB1-8AA4-673068EDE33A}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Sha1String", "VSProjectFiles\Sha1String.vcxproj", "{B01EA8DA-3ABB-410A-B28E-8336467F94F8}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Sha256String", "VSProjectFiles\Sha256String.vcxproj", "{43164E66-9EA5-48E5-9708-6AF8C3642F6E}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Sha512String", "VSProjectFiles\Sha512String.vcxproj", "{FC8B119A-DF2A-48A6-B834-F1CDF80AECB6}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CryptLibTest", "VSProjectFiles\CryptLibTest.vcxproj", "{543C3780-F2F4-47BA-8263-278B911A73AC}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
Debug|x64 = Debug|x64
|
||||
Release|Win32 = Release|Win32
|
||||
Release|x64 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{78DE2AA5-4DEB-4601-AAB8-A3452BAC810C}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{78DE2AA5-4DEB-4601-AAB8-A3452BAC810C}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{78DE2AA5-4DEB-4601-AAB8-A3452BAC810C}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{78DE2AA5-4DEB-4601-AAB8-A3452BAC810C}.Debug|x64.Build.0 = Debug|x64
|
||||
{78DE2AA5-4DEB-4601-AAB8-A3452BAC810C}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{78DE2AA5-4DEB-4601-AAB8-A3452BAC810C}.Release|Win32.Build.0 = Release|Win32
|
||||
{78DE2AA5-4DEB-4601-AAB8-A3452BAC810C}.Release|x64.ActiveCfg = Release|x64
|
||||
{78DE2AA5-4DEB-4601-AAB8-A3452BAC810C}.Release|x64.Build.0 = Release|x64
|
||||
{2F5CA1B6-92CC-4142-86AC-62FADFF0B834}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{2F5CA1B6-92CC-4142-86AC-62FADFF0B834}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{2F5CA1B6-92CC-4142-86AC-62FADFF0B834}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{2F5CA1B6-92CC-4142-86AC-62FADFF0B834}.Debug|x64.Build.0 = Debug|x64
|
||||
{2F5CA1B6-92CC-4142-86AC-62FADFF0B834}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{2F5CA1B6-92CC-4142-86AC-62FADFF0B834}.Release|Win32.Build.0 = Release|Win32
|
||||
{2F5CA1B6-92CC-4142-86AC-62FADFF0B834}.Release|x64.ActiveCfg = Release|x64
|
||||
{2F5CA1B6-92CC-4142-86AC-62FADFF0B834}.Release|x64.Build.0 = Release|x64
|
||||
{E5A739D1-4246-4FB1-8AA4-673068EDE33A}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{E5A739D1-4246-4FB1-8AA4-673068EDE33A}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{E5A739D1-4246-4FB1-8AA4-673068EDE33A}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{E5A739D1-4246-4FB1-8AA4-673068EDE33A}.Debug|x64.Build.0 = Debug|x64
|
||||
{E5A739D1-4246-4FB1-8AA4-673068EDE33A}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{E5A739D1-4246-4FB1-8AA4-673068EDE33A}.Release|Win32.Build.0 = Release|Win32
|
||||
{E5A739D1-4246-4FB1-8AA4-673068EDE33A}.Release|x64.ActiveCfg = Release|x64
|
||||
{E5A739D1-4246-4FB1-8AA4-673068EDE33A}.Release|x64.Build.0 = Release|x64
|
||||
{B01EA8DA-3ABB-410A-B28E-8336467F94F8}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{B01EA8DA-3ABB-410A-B28E-8336467F94F8}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{B01EA8DA-3ABB-410A-B28E-8336467F94F8}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{B01EA8DA-3ABB-410A-B28E-8336467F94F8}.Debug|x64.Build.0 = Debug|x64
|
||||
{B01EA8DA-3ABB-410A-B28E-8336467F94F8}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{B01EA8DA-3ABB-410A-B28E-8336467F94F8}.Release|Win32.Build.0 = Release|Win32
|
||||
{B01EA8DA-3ABB-410A-B28E-8336467F94F8}.Release|x64.ActiveCfg = Release|x64
|
||||
{B01EA8DA-3ABB-410A-B28E-8336467F94F8}.Release|x64.Build.0 = Release|x64
|
||||
{43164E66-9EA5-48E5-9708-6AF8C3642F6E}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{43164E66-9EA5-48E5-9708-6AF8C3642F6E}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{43164E66-9EA5-48E5-9708-6AF8C3642F6E}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{43164E66-9EA5-48E5-9708-6AF8C3642F6E}.Debug|x64.Build.0 = Debug|x64
|
||||
{43164E66-9EA5-48E5-9708-6AF8C3642F6E}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{43164E66-9EA5-48E5-9708-6AF8C3642F6E}.Release|Win32.Build.0 = Release|Win32
|
||||
{43164E66-9EA5-48E5-9708-6AF8C3642F6E}.Release|x64.ActiveCfg = Release|x64
|
||||
{43164E66-9EA5-48E5-9708-6AF8C3642F6E}.Release|x64.Build.0 = Release|x64
|
||||
{FC8B119A-DF2A-48A6-B834-F1CDF80AECB6}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{FC8B119A-DF2A-48A6-B834-F1CDF80AECB6}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{FC8B119A-DF2A-48A6-B834-F1CDF80AECB6}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{FC8B119A-DF2A-48A6-B834-F1CDF80AECB6}.Debug|x64.Build.0 = Debug|x64
|
||||
{FC8B119A-DF2A-48A6-B834-F1CDF80AECB6}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{FC8B119A-DF2A-48A6-B834-F1CDF80AECB6}.Release|Win32.Build.0 = Release|Win32
|
||||
{FC8B119A-DF2A-48A6-B834-F1CDF80AECB6}.Release|x64.ActiveCfg = Release|x64
|
||||
{FC8B119A-DF2A-48A6-B834-F1CDF80AECB6}.Release|x64.Build.0 = Release|x64
|
||||
{543C3780-F2F4-47BA-8263-278B911A73AC}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{543C3780-F2F4-47BA-8263-278B911A73AC}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{543C3780-F2F4-47BA-8263-278B911A73AC}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{543C3780-F2F4-47BA-8263-278B911A73AC}.Debug|x64.Build.0 = Debug|x64
|
||||
{543C3780-F2F4-47BA-8263-278B911A73AC}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{543C3780-F2F4-47BA-8263-278B911A73AC}.Release|Win32.Build.0 = Release|Win32
|
||||
{543C3780-F2F4-47BA-8263-278B911A73AC}.Release|x64.ActiveCfg = Release|x64
|
||||
{543C3780-F2F4-47BA-8263-278B911A73AC}.Release|x64.Build.0 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
88
README.md
88
README.md
@@ -1,4 +1,90 @@
|
||||
CryptLib
|
||||
========
|
||||
|
||||
Public Domain C Library of Cryptographic functions
|
||||
CryptLib is a collection of cryptographic functions written in C. Each
|
||||
module is fully independent and requires only a single .c file and a
|
||||
a single .h file. The functions are designed to be portable, however
|
||||
they do require a Little-Endian processor.
|
||||
|
||||
The makefile is for gnu make and works on Linux, OSX, Cygwin.
|
||||
It also works on Windows with VSS if cygwin (or some other gnu make) is
|
||||
setup and the environment has been setup correctly.
|
||||
|
||||
A Visual Studio 2010 solution file also exists, which has project files.
|
||||
This can be used instead of the makefile for VS2010.
|
||||
|
||||
*Created June 2013*
|
||||
|
||||
Version 1.0.0 - June 2013
|
||||
-------------------------
|
||||
|
||||
To use the library functions, only the following files are required,
|
||||
depending one what cryptographic functions are wanted.
|
||||
|
||||
* MD5 - (LibMd5.h, and LibMd5.c)
|
||||
* SHA1 - (LibSha1.h, and LibSha1.c)
|
||||
* SHA256 - (LibSha256.h, and LibSha256.c)
|
||||
* SHA512 - (LibSha512.h, and LibSha512.c)
|
||||
* RC4 - (LibRc4.h, and LibRc4.c)
|
||||
|
||||
Test Programs
|
||||
-------------
|
||||
|
||||
In the projects directory there are several programs that compile to
|
||||
command line executables. One is CryptLibTest. This tests the algorithms
|
||||
against known test vectors. If compiling on a different system this
|
||||
is useful to verify that the results are still valid. For example if you
|
||||
compile on a Big-Endian system then some of the functions will undoubtable
|
||||
fail. The test program can be used to verify that the correct modifications
|
||||
have been made if you wish to adapt the fiules to Big-Endian.
|
||||
|
||||
Additionally there are sample programs that demonstrate the functions. For
|
||||
each of the hash functions there is a program that creates a hash from a
|
||||
string given on command line. For RC4 there is a program that outputs
|
||||
the stream in hex.
|
||||
|
||||
* Md5String
|
||||
* Sha1String
|
||||
* Sha256String
|
||||
* Sha512String
|
||||
* Rc4Output
|
||||
|
||||
Executables
|
||||
-----------
|
||||
|
||||
Included in the Exe directory are executables of the above programs for Windows,
|
||||
OSX, and Linux. All of them are compiled for x64 versions of the operating
|
||||
systems. The Windows one is compiled for Vista and greater. The Linux binaries
|
||||
are comiled on Ubuntu 12.04. The binaries are built with a dependncy on GLICC2.14
|
||||
which means it will only load on fairly new versions of Linux. However linux
|
||||
is the easiest system to build form source as almost every linux platform will
|
||||
have make and gcc already installed.
|
||||
|
||||
License
|
||||
=======
|
||||
|
||||
This is free and unencumbered software released into the public domain.
|
||||
|
||||
Anyone is free to copy, modify, publish, use, compile, sell, or
|
||||
distribute this software, either in source code form or as a compiled
|
||||
binary, for any purpose, commercial or non-commercial, and by any
|
||||
means.
|
||||
|
||||
In jurisdictions that recognize copyright laws, the author or authors
|
||||
of this software dedicate any and all copyright interest in the
|
||||
software to the public domain. We make this dedication for the benefit
|
||||
of the public at large and to the detriment of our heirs and
|
||||
successors. We intend this dedication to be an overt act of
|
||||
relinquishment in perpetuity of all present and future rights to this
|
||||
software under copyright law.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
For more information, please refer to <http://unlicense.org/>
|
||||
|
||||
|
||||
24
UNLICENSE
Normal file
24
UNLICENSE
Normal file
@@ -0,0 +1,24 @@
|
||||
This is free and unencumbered software released into the public domain.
|
||||
|
||||
Anyone is free to copy, modify, publish, use, compile, sell, or
|
||||
distribute this software, either in source code form or as a compiled
|
||||
binary, for any purpose, commercial or non-commercial, and by any
|
||||
means.
|
||||
|
||||
In jurisdictions that recognize copyright laws, the author or authors
|
||||
of this software dedicate any and all copyright interest in the
|
||||
software to the public domain. We make this dedication for the benefit
|
||||
of the public at large and to the detriment of our heirs and
|
||||
successors. We intend this dedication to be an overt act of
|
||||
relinquishment in perpetuity of all present and future rights to this
|
||||
software under copyright law.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
For more information, please refer to <http://unlicense.org/>
|
||||
76
VSProjectFiles/CryptLibTest.vcxproj
Normal file
76
VSProjectFiles/CryptLibTest.vcxproj
Normal file
@@ -0,0 +1,76 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\lib\LibMd5.c" />
|
||||
<ClCompile Include="..\lib\LibRc4.c" />
|
||||
<ClCompile Include="..\lib\LibSha1.c" />
|
||||
<ClCompile Include="..\lib\LibSha256.c" />
|
||||
<ClCompile Include="..\lib\LibSha512.c" />
|
||||
<ClCompile Include="..\projects\CryptLibTest\CryptLibTest.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\lib\LibMd5.h" />
|
||||
<ClInclude Include="..\lib\LibRc4.h" />
|
||||
<ClInclude Include="..\lib\LibSha1.h" />
|
||||
<ClInclude Include="..\lib\LibSha256.h" />
|
||||
<ClInclude Include="..\lib\LibSha512.h" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{543C3780-F2F4-47BA-8263-278B911A73AC}</ProjectGuid>
|
||||
<RootNamespace>CryptLibTest</RootNamespace>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="props\$(Platform)$(Configuration).props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="props\$(Platform)$(Configuration).props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="props\$(Platform)$(Configuration).props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="props\$(Platform)$(Configuration).props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<_ProjectFileVersion>10.0.40219.1</_ProjectFileVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
49
VSProjectFiles/CryptLibTest.vcxproj.filters
Normal file
49
VSProjectFiles/CryptLibTest.vcxproj.filters
Normal file
@@ -0,0 +1,49 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="lib">
|
||||
<UniqueIdentifier>{aabf3f27-af59-42e0-94ef-f81adde8e682}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\lib\LibRc4.c">
|
||||
<Filter>lib</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\lib\LibMd5.c">
|
||||
<Filter>lib</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\lib\LibSha1.c">
|
||||
<Filter>lib</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\lib\LibSha256.c">
|
||||
<Filter>lib</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\lib\LibSha512.c">
|
||||
<Filter>lib</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\projects\CryptLibTest\CryptLibTest.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\lib\LibRc4.h">
|
||||
<Filter>lib</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\lib\LibMd5.h">
|
||||
<Filter>lib</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\lib\LibSha1.h">
|
||||
<Filter>lib</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\lib\LibSha256.h">
|
||||
<Filter>lib</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\lib\LibSha512.h">
|
||||
<Filter>lib</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
68
VSProjectFiles/Md5String.vcxproj
Normal file
68
VSProjectFiles/Md5String.vcxproj
Normal file
@@ -0,0 +1,68 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\lib\LibMd5.c" />
|
||||
<ClCompile Include="..\projects\Md5String\Md5String.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\lib\LibMd5.h" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{2F5CA1B6-92CC-4142-86AC-62FADFF0B834}</ProjectGuid>
|
||||
<RootNamespace>Md5String</RootNamespace>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="props\$(Platform)$(Configuration).props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="props\$(Platform)$(Configuration).props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="props\$(Platform)$(Configuration).props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="props\$(Platform)$(Configuration).props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<_ProjectFileVersion>10.0.40219.1</_ProjectFileVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
25
VSProjectFiles/Md5String.vcxproj.filters
Normal file
25
VSProjectFiles/Md5String.vcxproj.filters
Normal file
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="lib">
|
||||
<UniqueIdentifier>{aabf3f27-af59-42e0-94ef-f81adde8e682}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\lib\LibMd5.c">
|
||||
<Filter>lib</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\projects\Md5String\Md5String.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\lib\LibMd5.h">
|
||||
<Filter>lib</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
78
VSProjectFiles/ProofOfWork.vcxproj
Normal file
78
VSProjectFiles/ProofOfWork.vcxproj
Normal file
@@ -0,0 +1,78 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\lib\LibMd5.c" />
|
||||
<ClCompile Include="..\lib\LibRc4.c" />
|
||||
<ClCompile Include="..\lib\LibSha1.c" />
|
||||
<ClCompile Include="..\lib\LibSha256.c" />
|
||||
<ClCompile Include="..\lib\LibSha512.c" />
|
||||
<ClCompile Include="..\lib\LibThread.c" />
|
||||
<ClCompile Include="..\projects\ProofOfWork\ProofOfWork.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\lib\LibMd5.h" />
|
||||
<ClInclude Include="..\lib\LibRc4.h" />
|
||||
<ClInclude Include="..\lib\LibSha1.h" />
|
||||
<ClInclude Include="..\lib\LibSha256.h" />
|
||||
<ClInclude Include="..\lib\LibThread.h" />
|
||||
<ClInclude Include="..\projects\ProofOfWork\CreateFindProofOfWorkThreadFunction.h" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{78DE2AA5-4DEB-4601-AAB8-A3452BAC810C}</ProjectGuid>
|
||||
<RootNamespace>ProofOfWork</RootNamespace>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="props\$(Platform)$(Configuration).props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="props\$(Platform)$(Configuration).props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="props\$(Platform)$(Configuration).props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="props\$(Platform)$(Configuration).props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<_ProjectFileVersion>10.0.40219.1</_ProjectFileVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
55
VSProjectFiles/ProofOfWork.vcxproj.filters
Normal file
55
VSProjectFiles/ProofOfWork.vcxproj.filters
Normal file
@@ -0,0 +1,55 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="lib">
|
||||
<UniqueIdentifier>{6ec1a200-d167-4831-b36c-9ddd0b2ba00a}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\lib\LibMd5.c">
|
||||
<Filter>lib</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\lib\LibRc4.c">
|
||||
<Filter>lib</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\lib\LibThread.c">
|
||||
<Filter>lib</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\lib\LibSha1.c">
|
||||
<Filter>lib</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\lib\LibSha256.c">
|
||||
<Filter>lib</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\lib\LibSha512.c">
|
||||
<Filter>lib</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\projects\ProofOfWork\ProofOfWork.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\lib\LibMd5.h">
|
||||
<Filter>lib</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\lib\LibRc4.h">
|
||||
<Filter>lib</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\lib\LibThread.h">
|
||||
<Filter>lib</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\lib\LibSha1.h">
|
||||
<Filter>lib</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\lib\LibSha256.h">
|
||||
<Filter>lib</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\projects\ProofOfWork\CreateFindProofOfWorkThreadFunction.h">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
68
VSProjectFiles/Rc4Output.vcxproj
Normal file
68
VSProjectFiles/Rc4Output.vcxproj
Normal file
@@ -0,0 +1,68 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\lib\LibRc4.c" />
|
||||
<ClCompile Include="..\projects\Rc4Output\Rc4Output.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\lib\LibRc4.h" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{E5A739D1-4246-4FB1-8AA4-673068EDE33A}</ProjectGuid>
|
||||
<RootNamespace>Rc4Output</RootNamespace>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="props\$(Platform)$(Configuration).props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="props\$(Platform)$(Configuration).props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="props\$(Platform)$(Configuration).props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="props\$(Platform)$(Configuration).props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<_ProjectFileVersion>10.0.40219.1</_ProjectFileVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
25
VSProjectFiles/Rc4Output.vcxproj.filters
Normal file
25
VSProjectFiles/Rc4Output.vcxproj.filters
Normal file
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="lib">
|
||||
<UniqueIdentifier>{aabf3f27-af59-42e0-94ef-f81adde8e682}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\lib\LibRc4.c">
|
||||
<Filter>lib</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\projects\Rc4Output\Rc4Output.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\lib\LibRc4.h">
|
||||
<Filter>lib</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
68
VSProjectFiles/Sha1String.vcxproj
Normal file
68
VSProjectFiles/Sha1String.vcxproj
Normal file
@@ -0,0 +1,68 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\lib\LibSha1.c" />
|
||||
<ClCompile Include="..\projects\Sha1String\Sha1String.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\lib\LibSha1.h" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{B01EA8DA-3ABB-410A-B28E-8336467F94F8}</ProjectGuid>
|
||||
<RootNamespace>Sha1String</RootNamespace>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="props\$(Platform)$(Configuration).props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="props\$(Platform)$(Configuration).props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="props\$(Platform)$(Configuration).props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="props\$(Platform)$(Configuration).props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<_ProjectFileVersion>10.0.40219.1</_ProjectFileVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
29
VSProjectFiles/Sha1String.vcxproj.filters
Normal file
29
VSProjectFiles/Sha1String.vcxproj.filters
Normal file
@@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="lib">
|
||||
<UniqueIdentifier>{aabf3f27-af59-42e0-94ef-f81adde8e682}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Sha1String.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\lib\LibSha1.c">
|
||||
<Filter>lib</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\lib\LibSha1.h">
|
||||
<Filter>lib</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
68
VSProjectFiles/Sha256String.vcxproj
Normal file
68
VSProjectFiles/Sha256String.vcxproj
Normal file
@@ -0,0 +1,68 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\lib\LibSha256.c" />
|
||||
<ClCompile Include="..\projects\Sha256String\Sha256String.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\lib\LibSha256.h" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{43164E66-9EA5-48E5-9708-6AF8C3642F6E}</ProjectGuid>
|
||||
<RootNamespace>Sha256String</RootNamespace>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="props\$(Platform)$(Configuration).props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="props\$(Platform)$(Configuration).props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="props\$(Platform)$(Configuration).props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="props\$(Platform)$(Configuration).props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<_ProjectFileVersion>10.0.40219.1</_ProjectFileVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
29
VSProjectFiles/Sha256String.vcxproj.filters
Normal file
29
VSProjectFiles/Sha256String.vcxproj.filters
Normal file
@@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="lib">
|
||||
<UniqueIdentifier>{aabf3f27-af59-42e0-94ef-f81adde8e682}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Sha256String.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\lib\LibSha256.c">
|
||||
<Filter>lib</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\lib\LibSha256.h">
|
||||
<Filter>lib</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
68
VSProjectFiles/Sha512String.vcxproj
Normal file
68
VSProjectFiles/Sha512String.vcxproj
Normal file
@@ -0,0 +1,68 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\lib\LibSha512.c" />
|
||||
<ClCompile Include="..\projects\Sha512String\Sha512String.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\lib\LibSha512.h" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{FC8B119A-DF2A-48A6-B834-F1CDF80AECB6}</ProjectGuid>
|
||||
<RootNamespace>Sha512String</RootNamespace>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="props\$(Platform)$(Configuration).props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="props\$(Platform)$(Configuration).props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="props\$(Platform)$(Configuration).props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="props\$(Platform)$(Configuration).props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<_ProjectFileVersion>10.0.40219.1</_ProjectFileVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
29
VSProjectFiles/Sha512String.vcxproj.filters
Normal file
29
VSProjectFiles/Sha512String.vcxproj.filters
Normal file
@@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="lib">
|
||||
<UniqueIdentifier>{aabf3f27-af59-42e0-94ef-f81adde8e682}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Sha512String.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\lib\LibSha512.c">
|
||||
<Filter>lib</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\lib\LibSha512.h">
|
||||
<Filter>lib</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
42
VSProjectFiles/props/All.props
Normal file
42
VSProjectFiles/props/All.props
Normal file
@@ -0,0 +1,42 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ImportGroup Label="PropertySheets" />
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<OutDir>$(SolutionDir)Binaries\$(Platform)$(Configuration)\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<IntDir>$(SolutionDir)Build\$(Platform)$(Configuration)\$(ProjectName)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup>
|
||||
<ClCompile>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup>
|
||||
<ClCompile>
|
||||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
<EnablePREfast>true</EnablePREfast>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<Optimization>Full</Optimization>
|
||||
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<PreprocessorDefinitions>_WIN32_WINNT=0x0600;_CRT_SECURE_NO_WARNINGS</PreprocessorDefinitions>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)\lib;$(SolutionDir)\stdbool</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Lib>
|
||||
<OutputFile>$(IntDir)$(TargetName)$(TargetExt)</OutputFile>
|
||||
</Lib>
|
||||
<Link>
|
||||
<Version>6.0</Version>
|
||||
</Link>
|
||||
<Link>
|
||||
<LinkStatus>false</LinkStatus>
|
||||
<TreatLinkerWarningAsErrors>true</TreatLinkerWarningAsErrors>
|
||||
<SetChecksum>true</SetChecksum>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup />
|
||||
</Project>
|
||||
21
VSProjectFiles/props/Debug.props
Normal file
21
VSProjectFiles/props/Debug.props
Normal file
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup />
|
||||
<PropertyGroup>
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
<ClCompile>
|
||||
<StringPooling>false</StringPooling>
|
||||
</ClCompile>
|
||||
<ClCompile>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<InlineFunctionExpansion>Disabled</InlineFunctionExpansion>
|
||||
</ClCompile>
|
||||
<ClCompile />
|
||||
</ItemDefinitionGroup>
|
||||
</Project>
|
||||
3
VSProjectFiles/props/Win32.props
Normal file
3
VSProjectFiles/props/Win32.props
Normal file
@@ -0,0 +1,3 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
</Project>
|
||||
8
VSProjectFiles/props/Win32Debug.props
Normal file
8
VSProjectFiles/props/Win32Debug.props
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ImportGroup Label="PropertySheets">
|
||||
<Import Project="All.props" />
|
||||
<Import Project="Win32.props" />
|
||||
<Import Project="Debug.props" />
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
7
VSProjectFiles/props/Win32Release.props
Normal file
7
VSProjectFiles/props/Win32Release.props
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ImportGroup Label="PropertySheets">
|
||||
<Import Project="All.props" />
|
||||
<Import Project="Win32.props" />
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
8
VSProjectFiles/props/x64.props
Normal file
8
VSProjectFiles/props/x64.props
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemDefinitionGroup>
|
||||
<ClCompile>
|
||||
<EnablePREfast>false</EnablePREfast>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
</Project>
|
||||
8
VSProjectFiles/props/x64Debug.props
Normal file
8
VSProjectFiles/props/x64Debug.props
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ImportGroup Label="PropertySheets">
|
||||
<Import Project="All.props" />
|
||||
<Import Project="x64.props" />
|
||||
<Import Project="Debug.props" />
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
7
VSProjectFiles/props/x64Release.props
Normal file
7
VSProjectFiles/props/x64Release.props
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ImportGroup Label="PropertySheets">
|
||||
<Import Project="All.props" />
|
||||
<Import Project="x64.props" />
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
315
lib/LibMd5.c
Normal file
315
lib/LibMd5.c
Normal file
@@ -0,0 +1,315 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// LibMd5
|
||||
//
|
||||
// Implementation of MD5 hash function. Originally written by Alexander Peslyak. Modified by WaterJuice retaining
|
||||
// Public Domain license.
|
||||
//
|
||||
// This is free and unencumbered software released into the public domain - June 2013 waterjuice.org
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// IMPORTS
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "LibMd5.h"
|
||||
#include <memory.h>
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// INTERNAL FUNCTIONS
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// F, G, H, I
|
||||
//
|
||||
// The basic MD5 functions. F and G are optimized compared to their RFC 1321 definitions for architectures that lack
|
||||
// an AND-NOT instruction, just like in Colin Plumb's implementation.
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
#define F( x, y, z ) ( (z) ^ ((x) & ((y) ^ (z))) )
|
||||
#define G( x, y, z ) ( (y) ^ ((z) & ((x) ^ (y))) )
|
||||
#define H( x, y, z ) ( (x) ^ (y) ^ (z) )
|
||||
#define I( x, y, z ) ( (y) ^ ((x) | ~(z)) )
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// STEP
|
||||
//
|
||||
// The MD5 transformation for all four rounds.
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
#define STEP( f, a, b, c, d, x, t, s ) \
|
||||
(a) += f((b), (c), (d)) + (x) + (t); \
|
||||
(a) = (((a) << (s)) | (((a) & 0xffffffff) >> (32 - (s)))); \
|
||||
(a) += (b);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// SET, GET
|
||||
//
|
||||
// SET reads 4 input bytes in little-endian byte order and stores them in a properly aligned word in host byte order.
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
#define SET(n) (*(uint32_t *)&ptr[(n) * 4])
|
||||
#define GET(n) SET(n)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// TransformFunction
|
||||
//
|
||||
// This processes one or more 64-byte data blocks, but does NOT update the bit counters. There are no alignment
|
||||
// requirements.
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
static
|
||||
void*
|
||||
TransformFunction
|
||||
(
|
||||
Md5Context* ctx,
|
||||
void* data,
|
||||
uintmax_t size
|
||||
)
|
||||
{
|
||||
uint8_t* ptr;
|
||||
uint32_t a;
|
||||
uint32_t b;
|
||||
uint32_t c;
|
||||
uint32_t d;
|
||||
uint32_t saved_a;
|
||||
uint32_t saved_b;
|
||||
uint32_t saved_c;
|
||||
uint32_t saved_d;
|
||||
|
||||
ptr = (uint8_t*)data;
|
||||
|
||||
a = ctx->a;
|
||||
b = ctx->b;
|
||||
c = ctx->c;
|
||||
d = ctx->d;
|
||||
|
||||
do
|
||||
{
|
||||
saved_a = a;
|
||||
saved_b = b;
|
||||
saved_c = c;
|
||||
saved_d = d;
|
||||
|
||||
// Round 1
|
||||
STEP( F, a, b, c, d, SET(0), 0xd76aa478, 7 )
|
||||
STEP( F, d, a, b, c, SET(1), 0xe8c7b756, 12 )
|
||||
STEP( F, c, d, a, b, SET(2), 0x242070db, 17 )
|
||||
STEP( F, b, c, d, a, SET(3), 0xc1bdceee, 22 )
|
||||
STEP( F, a, b, c, d, SET(4), 0xf57c0faf, 7 )
|
||||
STEP( F, d, a, b, c, SET(5), 0x4787c62a, 12 )
|
||||
STEP( F, c, d, a, b, SET(6), 0xa8304613, 17 )
|
||||
STEP( F, b, c, d, a, SET(7), 0xfd469501, 22 )
|
||||
STEP( F, a, b, c, d, SET(8 ), 0x698098d8, 7 )
|
||||
STEP( F, d, a, b, c, SET(9 ), 0x8b44f7af, 12 )
|
||||
STEP( F, c, d, a, b, SET(10 ), 0xffff5bb1, 17 )
|
||||
STEP( F, b, c, d, a, SET(11 ), 0x895cd7be, 22 )
|
||||
STEP( F, a, b, c, d, SET(12 ), 0x6b901122, 7 )
|
||||
STEP( F, d, a, b, c, SET(13 ), 0xfd987193, 12 )
|
||||
STEP( F, c, d, a, b, SET(14 ), 0xa679438e, 17 )
|
||||
STEP( F, b, c, d, a, SET(15 ), 0x49b40821, 22 )
|
||||
|
||||
// Round 2
|
||||
STEP( G, a, b, c, d, GET(1), 0xf61e2562, 5 )
|
||||
STEP( G, d, a, b, c, GET(6), 0xc040b340, 9 )
|
||||
STEP( G, c, d, a, b, GET(11), 0x265e5a51, 14 )
|
||||
STEP( G, b, c, d, a, GET(0), 0xe9b6c7aa, 20 )
|
||||
STEP( G, a, b, c, d, GET(5), 0xd62f105d, 5 )
|
||||
STEP( G, d, a, b, c, GET(10), 0x02441453, 9 )
|
||||
STEP( G, c, d, a, b, GET(15), 0xd8a1e681, 14 )
|
||||
STEP( G, b, c, d, a, GET(4), 0xe7d3fbc8, 20 )
|
||||
STEP( G, a, b, c, d, GET(9), 0x21e1cde6, 5 )
|
||||
STEP( G, d, a, b, c, GET(14), 0xc33707d6, 9 )
|
||||
STEP( G, c, d, a, b, GET(3), 0xf4d50d87, 14 )
|
||||
STEP( G, b, c, d, a, GET(8), 0x455a14ed, 20 )
|
||||
STEP( G, a, b, c, d, GET(13), 0xa9e3e905, 5 )
|
||||
STEP( G, d, a, b, c, GET(2), 0xfcefa3f8, 9 )
|
||||
STEP( G, c, d, a, b, GET(7), 0x676f02d9, 14 )
|
||||
STEP( G, b, c, d, a, GET(12), 0x8d2a4c8a, 20 )
|
||||
|
||||
// Round 3
|
||||
STEP( H, a, b, c, d, GET(5), 0xfffa3942, 4 )
|
||||
STEP( H, d, a, b, c, GET(8), 0x8771f681, 11 )
|
||||
STEP( H, c, d, a, b, GET(11), 0x6d9d6122, 16 )
|
||||
STEP( H, b, c, d, a, GET(14), 0xfde5380c, 23 )
|
||||
STEP( H, a, b, c, d, GET(1), 0xa4beea44, 4 )
|
||||
STEP( H, d, a, b, c, GET(4), 0x4bdecfa9, 11 )
|
||||
STEP( H, c, d, a, b, GET(7), 0xf6bb4b60, 16 )
|
||||
STEP( H, b, c, d, a, GET(10), 0xbebfbc70, 23 )
|
||||
STEP( H, a, b, c, d, GET(13), 0x289b7ec6, 4 )
|
||||
STEP( H, d, a, b, c, GET(0), 0xeaa127fa, 11 )
|
||||
STEP( H, c, d, a, b, GET(3), 0xd4ef3085, 16 )
|
||||
STEP( H, b, c, d, a, GET(6), 0x04881d05, 23 )
|
||||
STEP( H, a, b, c, d, GET(9), 0xd9d4d039, 4 )
|
||||
STEP( H, d, a, b, c, GET(12), 0xe6db99e5, 11 )
|
||||
STEP( H, c, d, a, b, GET(15), 0x1fa27cf8, 16 )
|
||||
STEP( H, b, c, d, a, GET(2), 0xc4ac5665, 23 )
|
||||
|
||||
// Round 4
|
||||
STEP( I, a, b, c, d, GET(0), 0xf4292244, 6 )
|
||||
STEP( I, d, a, b, c, GET(7), 0x432aff97, 10 )
|
||||
STEP( I, c, d, a, b, GET(14), 0xab9423a7, 15 )
|
||||
STEP( I, b, c, d, a, GET(5), 0xfc93a039, 21 )
|
||||
STEP( I, a, b, c, d, GET(12), 0x655b59c3, 6 )
|
||||
STEP( I, d, a, b, c, GET(3), 0x8f0ccc92, 10 )
|
||||
STEP( I, c, d, a, b, GET(10), 0xffeff47d, 15 )
|
||||
STEP( I, b, c, d, a, GET(1), 0x85845dd1, 21 )
|
||||
STEP( I, a, b, c, d, GET(8), 0x6fa87e4f, 6 )
|
||||
STEP( I, d, a, b, c, GET(15), 0xfe2ce6e0, 10 )
|
||||
STEP( I, c, d, a, b, GET(6), 0xa3014314, 15 )
|
||||
STEP( I, b, c, d, a, GET(13), 0x4e0811a1, 21 )
|
||||
STEP( I, a, b, c, d, GET(4), 0xf7537e82, 6 )
|
||||
STEP( I, d, a, b, c, GET(11), 0xbd3af235, 10 )
|
||||
STEP( I, c, d, a, b, GET(2), 0x2ad7d2bb, 15 )
|
||||
STEP( I, b, c, d, a, GET(9), 0xeb86d391, 21 )
|
||||
|
||||
a += saved_a;
|
||||
b += saved_b;
|
||||
c += saved_c;
|
||||
d += saved_d;
|
||||
|
||||
ptr += 64;
|
||||
} while( size -= 64 );
|
||||
|
||||
ctx->a = a;
|
||||
ctx->b = b;
|
||||
ctx->c = c;
|
||||
ctx->d = d;
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// EXPORTED FUNCTIONS
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Md5Initialise
|
||||
//
|
||||
// Initialises an MD5 Context. Use this to initialise/reset a context.
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
Md5Initialise
|
||||
(
|
||||
Md5Context* Context
|
||||
)
|
||||
{
|
||||
Context->a = 0x67452301;
|
||||
Context->b = 0xefcdab89;
|
||||
Context->c = 0x98badcfe;
|
||||
Context->d = 0x10325476;
|
||||
|
||||
Context->lo = 0;
|
||||
Context->hi = 0;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Md5Update
|
||||
//
|
||||
// Adds data to the MD5 context. This will process the data and update the internal state of the context. Keep on
|
||||
// calling this function until all the data has been added. Then call Md5Finalise to calculate the hash.
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
Md5Update
|
||||
(
|
||||
Md5Context* Context,
|
||||
void* Buffer,
|
||||
uint32_t BufferSize
|
||||
)
|
||||
{
|
||||
uint32_t saved_lo;
|
||||
uint32_t used;
|
||||
uint32_t free;
|
||||
|
||||
saved_lo = Context->lo;
|
||||
if( (Context->lo = (saved_lo + BufferSize) & 0x1fffffff) < saved_lo )
|
||||
{
|
||||
Context->hi++;
|
||||
}
|
||||
Context->hi += (uint32_t)( BufferSize >> 29 );
|
||||
|
||||
used = saved_lo & 0x3f;
|
||||
|
||||
if( used )
|
||||
{
|
||||
free = 64 - used;
|
||||
|
||||
if( BufferSize < free )
|
||||
{
|
||||
memcpy( &Context->buffer[used], Buffer, BufferSize );
|
||||
return;
|
||||
}
|
||||
|
||||
memcpy( &Context->buffer[used], Buffer, free );
|
||||
Buffer = (uint8_t*)Buffer + free;
|
||||
BufferSize -= free;
|
||||
TransformFunction(Context, Context->buffer, 64);
|
||||
}
|
||||
|
||||
if( BufferSize >= 64 )
|
||||
{
|
||||
Buffer = TransformFunction( Context, Buffer, BufferSize & ~(unsigned long)0x3f );
|
||||
BufferSize &= 0x3f;
|
||||
}
|
||||
|
||||
memcpy( Context->buffer, Buffer, BufferSize );
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Md5Finalise
|
||||
//
|
||||
// Performs the final calculation of the hash and returns the digest (16 byte buffer containing 128bit hash). After
|
||||
// calling this, Md5Initialised must be used to reuse the context.
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
Md5Finalise
|
||||
(
|
||||
Md5Context* Context,
|
||||
MD5_HASH* Digest
|
||||
)
|
||||
{
|
||||
uint32_t used;
|
||||
uint32_t free;
|
||||
|
||||
used = Context->lo & 0x3f;
|
||||
|
||||
Context->buffer[used++] = 0x80;
|
||||
|
||||
free = 64 - used;
|
||||
|
||||
if(free < 8)
|
||||
{
|
||||
memset( &Context->buffer[used], 0, free );
|
||||
TransformFunction( Context, Context->buffer, 64 );
|
||||
used = 0;
|
||||
free = 64;
|
||||
}
|
||||
|
||||
memset( &Context->buffer[used], 0, free - 8 );
|
||||
|
||||
Context->lo <<= 3;
|
||||
Context->buffer[56] = (uint8_t)( Context->lo );
|
||||
Context->buffer[57] = (uint8_t)( Context->lo >> 8 );
|
||||
Context->buffer[58] = (uint8_t)( Context->lo >> 16 );
|
||||
Context->buffer[59] = (uint8_t)( Context->lo >> 24 );
|
||||
Context->buffer[60] = (uint8_t)( Context->hi );
|
||||
Context->buffer[61] = (uint8_t)( Context->hi >> 8 );
|
||||
Context->buffer[62] = (uint8_t)( Context->hi >> 16 );
|
||||
Context->buffer[63] = (uint8_t)( Context->hi >> 24 );
|
||||
|
||||
TransformFunction( Context, Context->buffer, 64 );
|
||||
|
||||
Digest->bytes[0] = (uint8_t)( Context->a );
|
||||
Digest->bytes[1] = (uint8_t)( Context->a >> 8 );
|
||||
Digest->bytes[2] = (uint8_t)( Context->a >> 16 );
|
||||
Digest->bytes[3] = (uint8_t)( Context->a >> 24 );
|
||||
Digest->bytes[4] = (uint8_t)( Context->b );
|
||||
Digest->bytes[5] = (uint8_t)( Context->b >> 8 );
|
||||
Digest->bytes[6] = (uint8_t)( Context->b >> 16 );
|
||||
Digest->bytes[7] = (uint8_t)( Context->b >> 24 );
|
||||
Digest->bytes[8] = (uint8_t)( Context->c );
|
||||
Digest->bytes[9] = (uint8_t)( Context->c >> 8 );
|
||||
Digest->bytes[10] = (uint8_t)( Context->c >> 16 );
|
||||
Digest->bytes[11] = (uint8_t)( Context->c >> 24 );
|
||||
Digest->bytes[12] = (uint8_t)( Context->d );
|
||||
Digest->bytes[13] = (uint8_t)( Context->d >> 8 );
|
||||
Digest->bytes[14] = (uint8_t)( Context->d >> 16 );
|
||||
Digest->bytes[15] = (uint8_t)( Context->d >> 24 );
|
||||
}
|
||||
|
||||
89
lib/LibMd5.h
Normal file
89
lib/LibMd5.h
Normal file
@@ -0,0 +1,89 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// LibMd5
|
||||
//
|
||||
// Implementation of MD5 hash function. Originally written by Alexander Peslyak. Modified by WaterJuice retaining
|
||||
// Public Domain license.
|
||||
//
|
||||
// This is free and unencumbered software released into the public domain - June 2013 waterjuice.org
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _LibMd5_h_
|
||||
#define _LibMd5_h_
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// IMPORTS
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// TYPES
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Md5Context - This must be initialised using Md5Initialised. Do not modify the contents of this structure directly.
|
||||
typedef struct
|
||||
{
|
||||
uint32_t lo;
|
||||
uint32_t hi;
|
||||
uint32_t a;
|
||||
uint32_t b;
|
||||
uint32_t c;
|
||||
uint32_t d;
|
||||
uint8_t buffer[64];
|
||||
uint32_t block[16];
|
||||
} Md5Context;
|
||||
|
||||
#define MD5_HASH_SIZE ( 128 / 8 )
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t bytes [MD5_HASH_SIZE];
|
||||
} MD5_HASH;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// PUBLIC FUNCTIONS
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Md5Initialise
|
||||
//
|
||||
// Initialises an MD5 Context. Use this to initialise/reset a context.
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
Md5Initialise
|
||||
(
|
||||
Md5Context* Context
|
||||
);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Md5Update
|
||||
//
|
||||
// Adds data to the MD5 context. This will process the data and update the internal state of the context. Keep on
|
||||
// calling this function until all the data has been added. Then call Md5Finalise to calculate the hash.
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
Md5Update
|
||||
(
|
||||
Md5Context* Context,
|
||||
void* Buffer,
|
||||
uint32_t BufferSize
|
||||
);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Md5Finalise
|
||||
//
|
||||
// Performs the final calculation of the hash and returns the digest (16 byte buffer containing 128bit hash). After
|
||||
// calling this, Md5Initialised must be used to reuse the context.
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
Md5Finalise
|
||||
(
|
||||
Md5Context* Context,
|
||||
MD5_HASH* Digest
|
||||
);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
#endif //_LibMd5_h_
|
||||
|
||||
129
lib/LibRc4.c
Normal file
129
lib/LibRc4.c
Normal file
@@ -0,0 +1,129 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// LibRC4
|
||||
//
|
||||
// An implementation of RC4 stream cipher
|
||||
//
|
||||
// This is free and unencumbered software released into the public domain - June 2013 waterjuice.org
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// IMPORTS
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "LibRc4.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// INTERNAL FUNCTIONS
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define SwapBytes( Value1, Value2 ) \
|
||||
{ \
|
||||
uint8_t temp = Value1; \
|
||||
Value1 = Value2; \
|
||||
Value2 = temp; \
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// PUBLIC FUNCTIONS
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Rc4Initialise
|
||||
//
|
||||
// Initialises an RC4 cipher and discards the specified number of first bytes.
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
Rc4Initialise
|
||||
(
|
||||
Rc4Context* Context,
|
||||
void* Key,
|
||||
uint32_t KeySize,
|
||||
uint32_t DropN
|
||||
)
|
||||
{
|
||||
uint32_t i;
|
||||
uint32_t j;
|
||||
uint32_t n;
|
||||
|
||||
// Setup key schedule
|
||||
for( i=0; i<256; i++ )
|
||||
{
|
||||
Context->S[i] = (uint8_t)i;
|
||||
}
|
||||
|
||||
j = 0;
|
||||
for( i=0; i<256; i++ )
|
||||
{
|
||||
j = ( j + Context->S[i] + ((uint8_t*)Key)[i % KeySize] ) % 256;
|
||||
SwapBytes( Context->S[i], Context->S[j] );
|
||||
}
|
||||
|
||||
i = 0;
|
||||
j = 0;
|
||||
|
||||
// Drop first bytes (if requested)
|
||||
for( n=0; n<DropN; n++ )
|
||||
{
|
||||
i = ( i + 1 ) % 256;
|
||||
j = ( j + Context->S[i] ) % 256;
|
||||
SwapBytes( Context->S[i], Context->S[j] );
|
||||
}
|
||||
|
||||
Context->i = i;
|
||||
Context->j = j;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Rc4Output
|
||||
//
|
||||
// Outputs the requested number of bytes from the RC4 stream
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
Rc4Output
|
||||
(
|
||||
Rc4Context* Context,
|
||||
void* Buffer,
|
||||
uint32_t Size
|
||||
)
|
||||
{
|
||||
uint32_t n;
|
||||
|
||||
for( n=0; n<Size; n++ )
|
||||
{
|
||||
Context->i = ( Context->i + 1 ) % 256;
|
||||
Context->j = ( Context->j + Context->S[Context->i] ) % 256;
|
||||
SwapBytes( Context->S[Context->i], Context->S[Context->j] );
|
||||
|
||||
((uint8_t*)Buffer)[n] = Context->S[ (Context->S[Context->i] + Context->S[Context->j]) % 256 ];
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Rc4Xor
|
||||
//
|
||||
// XORs the RC4 stream with an input buffer and puts the results in an output buffer. This is used for encrypting
|
||||
// and decrypting data. InBuffer and OutBuffer can point to the same location for inplace encrypting/decrypting
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
Rc4Xor
|
||||
(
|
||||
Rc4Context* Context,
|
||||
void* InBuffer,
|
||||
void* OutBuffer,
|
||||
uint32_t Size
|
||||
)
|
||||
{
|
||||
uint32_t n;
|
||||
|
||||
for( n=0; n<Size; n++ )
|
||||
{
|
||||
Context->i = ( Context->i + 1 ) % 256;
|
||||
Context->j = ( Context->j + Context->S[Context->i] ) % 256;
|
||||
SwapBytes( Context->S[Context->i], Context->S[Context->j] );
|
||||
|
||||
((uint8_t*)OutBuffer)[n] = ((uint8_t*)InBuffer)[n]
|
||||
^ ( Context->S[ (Context->S[Context->i] + Context->S[Context->j]) % 256 ] );
|
||||
}
|
||||
}
|
||||
|
||||
78
lib/LibRc4.h
Normal file
78
lib/LibRc4.h
Normal file
@@ -0,0 +1,78 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// LibRC4
|
||||
//
|
||||
// An implementation of RC4 stream cipher
|
||||
//
|
||||
// This is free and unencumbered software released into the public domain - June 2013 waterjuice.org
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _LibRc4_h_
|
||||
#define _LibRc4_h_
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// IMPORTS
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// TYPES
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Rc4Context - This must be initialised using Rc4Initialised. Do not modify the contents of this structure directly.
|
||||
typedef struct
|
||||
{
|
||||
uint32_t i;
|
||||
uint32_t j;
|
||||
uint8_t S[256];
|
||||
} Rc4Context;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// PUBLIC FUNCTIONS
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Rc4Initialise
|
||||
//
|
||||
// Initialises an RC4 cipher and discards the specified number of first bytes.
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
Rc4Initialise
|
||||
(
|
||||
Rc4Context* Context,
|
||||
void* Key,
|
||||
uint32_t KeySize,
|
||||
uint32_t DropN
|
||||
);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Rc4Output
|
||||
//
|
||||
// Outputs the requested number of bytes from the RC4 stream
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
Rc4Output
|
||||
(
|
||||
Rc4Context* Context,
|
||||
void* Buffer,
|
||||
uint32_t Size
|
||||
);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Rc4Xor
|
||||
//
|
||||
// XORs the RC4 stream with an input buffer and puts the results in an output buffer. This is used for encrypting
|
||||
// and decrypting data. InBuffer and OutBuffer can point to the same location for inplace encrypting/decrypting
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
Rc4Xor
|
||||
(
|
||||
Rc4Context* Context,
|
||||
void* InBuffer,
|
||||
void* OutBuffer,
|
||||
uint32_t Size
|
||||
);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
#endif //_LibRc4_h_
|
||||
|
||||
212
lib/LibSha1.c
Normal file
212
lib/LibSha1.c
Normal file
@@ -0,0 +1,212 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// LibSha1
|
||||
//
|
||||
// Implementation of SHA1 hash function.
|
||||
// Original author: Steve Reid <sreid@sea-to-sky.net>
|
||||
// Contributions by: James H. Brown <jbrown@burgoyne.com>, Saul Kravitz <Saul.Kravitz@celera.com>,
|
||||
// and Ralph Giles <giles@ghostscript.com>
|
||||
// Modified by WaterJuice retaining Public Domain license.
|
||||
//
|
||||
// This is free and unencumbered software released into the public domain - June 2013 waterjuice.org
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// IMPORTS
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "LibSha1.h"
|
||||
#include <memory.h>
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// TYPES
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef union
|
||||
{
|
||||
uint8_t c [64];
|
||||
uint32_t l [16];
|
||||
} CHAR64LONG16;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// INTERNAL FUNCTIONS
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
|
||||
|
||||
// blk0() and blk() perform the initial expand.
|
||||
#define blk0(i) (block->l[i] = (rol(block->l[i],24)&0xFF00FF00) \
|
||||
|(rol(block->l[i],8)&0x00FF00FF))
|
||||
|
||||
#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
|
||||
^block->l[(i+2)&15]^block->l[i&15],1))
|
||||
|
||||
// (R0+R1), R2, R3, R4 are the different operations used in SHA1
|
||||
#define R0(v,w,x,y,z,i) z += ((w&(x^y))^y) + blk0(i)+ 0x5A827999 + rol(v,5); w=rol(w,30);
|
||||
#define R1(v,w,x,y,z,i) z += ((w&(x^y))^y) + blk(i) + 0x5A827999 + rol(v,5); w=rol(w,30);
|
||||
#define R2(v,w,x,y,z,i) z += (w^x^y) + blk(i) + 0x6ED9EBA1 + rol(v,5); w=rol(w,30);
|
||||
#define R3(v,w,x,y,z,i) z += (((w|x)&y)|(w&x)) + blk(i) + 0x8F1BBCDC + rol(v,5); w=rol(w,30);
|
||||
#define R4(v,w,x,y,z,i) z += (w^x^y) + blk(i) + 0xCA62C1D6 + rol(v,5); w=rol(w,30);
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// TransformFunction
|
||||
//
|
||||
// Hash a single 512-bit block. This is the core of the algorithm
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
static
|
||||
void
|
||||
TransformFunction
|
||||
(
|
||||
uint32_t state[5],
|
||||
const uint8_t buffer[64]
|
||||
)
|
||||
{
|
||||
uint32_t a;
|
||||
uint32_t b;
|
||||
uint32_t c;
|
||||
uint32_t d;
|
||||
uint32_t e;
|
||||
uint8_t workspace[64];
|
||||
CHAR64LONG16* block = (CHAR64LONG16*) workspace;
|
||||
|
||||
memcpy( block, buffer, 64 );
|
||||
|
||||
// Copy context->state[] to working vars
|
||||
a = state[0];
|
||||
b = state[1];
|
||||
c = state[2];
|
||||
d = state[3];
|
||||
e = state[4];
|
||||
|
||||
// 4 rounds of 20 operations each. Loop unrolled.
|
||||
R0(a,b,c,d,e, 0); R0(e,a,b,c,d, 1); R0(d,e,a,b,c, 2); R0(c,d,e,a,b, 3);
|
||||
R0(b,c,d,e,a, 4); R0(a,b,c,d,e, 5); R0(e,a,b,c,d, 6); R0(d,e,a,b,c, 7);
|
||||
R0(c,d,e,a,b, 8); R0(b,c,d,e,a, 9); R0(a,b,c,d,e,10); R0(e,a,b,c,d,11);
|
||||
R0(d,e,a,b,c,12); R0(c,d,e,a,b,13); R0(b,c,d,e,a,14); R0(a,b,c,d,e,15);
|
||||
R1(e,a,b,c,d,16); R1(d,e,a,b,c,17); R1(c,d,e,a,b,18); R1(b,c,d,e,a,19);
|
||||
R2(a,b,c,d,e,20); R2(e,a,b,c,d,21); R2(d,e,a,b,c,22); R2(c,d,e,a,b,23);
|
||||
R2(b,c,d,e,a,24); R2(a,b,c,d,e,25); R2(e,a,b,c,d,26); R2(d,e,a,b,c,27);
|
||||
R2(c,d,e,a,b,28); R2(b,c,d,e,a,29); R2(a,b,c,d,e,30); R2(e,a,b,c,d,31);
|
||||
R2(d,e,a,b,c,32); R2(c,d,e,a,b,33); R2(b,c,d,e,a,34); R2(a,b,c,d,e,35);
|
||||
R2(e,a,b,c,d,36); R2(d,e,a,b,c,37); R2(c,d,e,a,b,38); R2(b,c,d,e,a,39);
|
||||
R3(a,b,c,d,e,40); R3(e,a,b,c,d,41); R3(d,e,a,b,c,42); R3(c,d,e,a,b,43);
|
||||
R3(b,c,d,e,a,44); R3(a,b,c,d,e,45); R3(e,a,b,c,d,46); R3(d,e,a,b,c,47);
|
||||
R3(c,d,e,a,b,48); R3(b,c,d,e,a,49); R3(a,b,c,d,e,50); R3(e,a,b,c,d,51);
|
||||
R3(d,e,a,b,c,52); R3(c,d,e,a,b,53); R3(b,c,d,e,a,54); R3(a,b,c,d,e,55);
|
||||
R3(e,a,b,c,d,56); R3(d,e,a,b,c,57); R3(c,d,e,a,b,58); R3(b,c,d,e,a,59);
|
||||
R4(a,b,c,d,e,60); R4(e,a,b,c,d,61); R4(d,e,a,b,c,62); R4(c,d,e,a,b,63);
|
||||
R4(b,c,d,e,a,64); R4(a,b,c,d,e,65); R4(e,a,b,c,d,66); R4(d,e,a,b,c,67);
|
||||
R4(c,d,e,a,b,68); R4(b,c,d,e,a,69); R4(a,b,c,d,e,70); R4(e,a,b,c,d,71);
|
||||
R4(d,e,a,b,c,72); R4(c,d,e,a,b,73); R4(b,c,d,e,a,74); R4(a,b,c,d,e,75);
|
||||
R4(e,a,b,c,d,76); R4(d,e,a,b,c,77); R4(c,d,e,a,b,78); R4(b,c,d,e,a,79);
|
||||
|
||||
// Add the working vars back into context.state[]
|
||||
state[0] += a;
|
||||
state[1] += b;
|
||||
state[2] += c;
|
||||
state[3] += d;
|
||||
state[4] += e;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// PUBLIC FUNCTIONS
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Sha1Initialise
|
||||
//
|
||||
// Initialises an SHA1 Context. Use this to initialise/reset a context.
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
Sha1Initialise
|
||||
(
|
||||
Sha1Context* Context
|
||||
)
|
||||
{
|
||||
// SHA1 initialization constants
|
||||
Context->State[0] = 0x67452301;
|
||||
Context->State[1] = 0xEFCDAB89;
|
||||
Context->State[2] = 0x98BADCFE;
|
||||
Context->State[3] = 0x10325476;
|
||||
Context->State[4] = 0xC3D2E1F0;
|
||||
Context->Count[0] = 0;
|
||||
Context->Count[1] = 0;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Sha1Update
|
||||
//
|
||||
// Adds data to the SHA1 context. This will process the data and update the internal state of the context. Keep on
|
||||
// calling this function until all the data has been added. Then call Sha1Finalise to calculate the hash.
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
Sha1Update
|
||||
(
|
||||
Sha1Context* Context,
|
||||
void* Buffer,
|
||||
uint32_t BufferSize
|
||||
)
|
||||
{
|
||||
uint32_t i;
|
||||
uint32_t j;
|
||||
|
||||
j = (Context->Count[0] >> 3) & 63;
|
||||
if( (Context->Count[0] += BufferSize << 3) < (BufferSize << 3) )
|
||||
{
|
||||
Context->Count[1]++;
|
||||
}
|
||||
|
||||
Context->Count[1] += (BufferSize >> 29);
|
||||
if( (j + BufferSize) > 63 )
|
||||
{
|
||||
i = 64 - j;
|
||||
memcpy( &Context->Buffer[j], Buffer, i );
|
||||
TransformFunction(Context->State, Context->Buffer);
|
||||
for( ; i + 63 < BufferSize; i += 64 )
|
||||
{
|
||||
TransformFunction(Context->State, (uint8_t*)Buffer + i);
|
||||
}
|
||||
j = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
i = 0;
|
||||
}
|
||||
|
||||
memcpy( &Context->Buffer[j], &((uint8_t*)Buffer)[i], BufferSize - i );
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Sha1Finalise
|
||||
//
|
||||
// Performs the final calculation of the hash and returns the digest (20 byte buffer containing 160bit hash). After
|
||||
// calling this, Sha1Initialised must be used to reuse the context.
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
Sha1Finalise
|
||||
(
|
||||
Sha1Context* Context,
|
||||
SHA1_HASH* Digest
|
||||
)
|
||||
{
|
||||
uint32_t i;
|
||||
uint8_t finalcount[8];
|
||||
|
||||
for( i=0; i<8; i++ )
|
||||
{
|
||||
finalcount[i] = (unsigned char)((Context->Count[(i >= 4 ? 0 : 1)]
|
||||
>> ((3-(i & 3)) * 8) ) & 255); // Endian independent
|
||||
}
|
||||
Sha1Update( Context, (uint8_t*)"\x80", 1 );
|
||||
while( (Context->Count[0] & 504) != 448 )
|
||||
{
|
||||
Sha1Update( Context, (uint8_t*)"\0", 1 );
|
||||
}
|
||||
|
||||
Sha1Update( Context, finalcount, 8 ); // Should cause a Sha1TransformFunction()
|
||||
for( i=0; i<SHA1_HASH_SIZE; i++ )
|
||||
{
|
||||
Digest->bytes[i] = (uint8_t)((Context->State[i>>2] >> ((3-(i & 3)) * 8) ) & 255);
|
||||
}
|
||||
}
|
||||
|
||||
86
lib/LibSha1.h
Normal file
86
lib/LibSha1.h
Normal file
@@ -0,0 +1,86 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// LibSha1
|
||||
//
|
||||
// Implementation of SHA1 hash function.
|
||||
// Original author: Steve Reid <sreid@sea-to-sky.net>
|
||||
// Contributions by: James H. Brown <jbrown@burgoyne.com>, Saul Kravitz <Saul.Kravitz@celera.com>,
|
||||
// and Ralph Giles <giles@ghostscript.com>
|
||||
// Modified by WaterJuice retaining Public Domain license.
|
||||
//
|
||||
// This is free and unencumbered software released into the public domain - June 2013 waterjuice.org
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _LibSha1_h_
|
||||
#define _LibSha1_h_
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// IMPORTS
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// TYPES
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Sha1Context - This must be initialised using Sha1Initialised. Do not modify the contents of this structure directly.
|
||||
typedef struct
|
||||
{
|
||||
uint32_t State[5];
|
||||
uint32_t Count[2];
|
||||
uint8_t Buffer[64];
|
||||
} Sha1Context;
|
||||
|
||||
#define SHA1_HASH_SIZE ( 160 / 8 )
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t bytes [SHA1_HASH_SIZE];
|
||||
} SHA1_HASH;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// PUBLIC FUNCTIONS
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Sha1Initialise
|
||||
//
|
||||
// Initialises an SHA1 Context. Use this to initialise/reset a context.
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
Sha1Initialise
|
||||
(
|
||||
Sha1Context* Context
|
||||
);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Sha1Update
|
||||
//
|
||||
// Adds data to the SHA1 context. This will process the data and update the internal state of the context. Keep on
|
||||
// calling this function until all the data has been added. Then call Sha1Finalise to calculate the hash.
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
Sha1Update
|
||||
(
|
||||
Sha1Context* Context,
|
||||
void* Buffer,
|
||||
uint32_t BufferSize
|
||||
);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Sha1Finalise
|
||||
//
|
||||
// Performs the final calculation of the hash and returns the digest (20 byte buffer containing 160bit hash). After
|
||||
// calling this, Sha1Initialised must be used to reuse the context.
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
Sha1Finalise
|
||||
(
|
||||
Sha1Context* Context,
|
||||
SHA1_HASH* Digest
|
||||
);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
#endif //_LibSha1_h_
|
||||
|
||||
273
lib/LibSha256.c
Normal file
273
lib/LibSha256.c
Normal file
@@ -0,0 +1,273 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// LibSha256
|
||||
//
|
||||
// Implementation of SHA256 hash function.
|
||||
// Original author: Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
// Modified by WaterJuice retaining Public Domain license.
|
||||
//
|
||||
// This is free and unencumbered software released into the public domain - June 2013 waterjuice.org
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// IMPORTS
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "LibSha256.h"
|
||||
#include <memory.h>
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// MACROS
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define ror(value, bits) (((value) >> (bits)) | ((value) << (32 - (bits))))
|
||||
|
||||
#define MIN(x, y) ( ((x)<(y))?(x):(y) )
|
||||
|
||||
#define STORE32H(x, y) \
|
||||
{ (y)[0] = (uint8_t)(((x)>>24)&255); (y)[1] = (uint8_t)(((x)>>16)&255); \
|
||||
(y)[2] = (uint8_t)(((x)>>8)&255); (y)[3] = (uint8_t)((x)&255); }
|
||||
|
||||
#define LOAD32H(x, y) \
|
||||
{ x = ((uint32_t)((y)[0] & 255)<<24) | \
|
||||
((uint32_t)((y)[1] & 255)<<16) | \
|
||||
((uint32_t)((y)[2] & 255)<<8) | \
|
||||
((uint32_t)((y)[3] & 255)); }
|
||||
|
||||
#define STORE64H(x, y) \
|
||||
{ (y)[0] = (uint8_t)(((x)>>56)&255); (y)[1] = (uint8_t)(((x)>>48)&255); \
|
||||
(y)[2] = (uint8_t)(((x)>>40)&255); (y)[3] = (uint8_t)(((x)>>32)&255); \
|
||||
(y)[4] = (uint8_t)(((x)>>24)&255); (y)[5] = (uint8_t)(((x)>>16)&255); \
|
||||
(y)[6] = (uint8_t)(((x)>>8)&255); (y)[7] = (uint8_t)((x)&255); }
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// CONSTANTS
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
// The K array
|
||||
static const uint32_t K[64] = {
|
||||
0x428a2f98UL, 0x71374491UL, 0xb5c0fbcfUL, 0xe9b5dba5UL, 0x3956c25bUL,
|
||||
0x59f111f1UL, 0x923f82a4UL, 0xab1c5ed5UL, 0xd807aa98UL, 0x12835b01UL,
|
||||
0x243185beUL, 0x550c7dc3UL, 0x72be5d74UL, 0x80deb1feUL, 0x9bdc06a7UL,
|
||||
0xc19bf174UL, 0xe49b69c1UL, 0xefbe4786UL, 0x0fc19dc6UL, 0x240ca1ccUL,
|
||||
0x2de92c6fUL, 0x4a7484aaUL, 0x5cb0a9dcUL, 0x76f988daUL, 0x983e5152UL,
|
||||
0xa831c66dUL, 0xb00327c8UL, 0xbf597fc7UL, 0xc6e00bf3UL, 0xd5a79147UL,
|
||||
0x06ca6351UL, 0x14292967UL, 0x27b70a85UL, 0x2e1b2138UL, 0x4d2c6dfcUL,
|
||||
0x53380d13UL, 0x650a7354UL, 0x766a0abbUL, 0x81c2c92eUL, 0x92722c85UL,
|
||||
0xa2bfe8a1UL, 0xa81a664bUL, 0xc24b8b70UL, 0xc76c51a3UL, 0xd192e819UL,
|
||||
0xd6990624UL, 0xf40e3585UL, 0x106aa070UL, 0x19a4c116UL, 0x1e376c08UL,
|
||||
0x2748774cUL, 0x34b0bcb5UL, 0x391c0cb3UL, 0x4ed8aa4aUL, 0x5b9cca4fUL,
|
||||
0x682e6ff3UL, 0x748f82eeUL, 0x78a5636fUL, 0x84c87814UL, 0x8cc70208UL,
|
||||
0x90befffaUL, 0xa4506cebUL, 0xbef9a3f7UL, 0xc67178f2UL
|
||||
};
|
||||
|
||||
#define BLOCK_SIZE 64
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// INTERNAL FUNCTIONS
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Various logical functions
|
||||
#define Ch( x, y, z ) (z ^ (x & (y ^ z)))
|
||||
#define Maj( x, y, z ) (((x | y) & z) | (x & y))
|
||||
#define S( x, n ) ror((x),(n))
|
||||
#define R( x, n ) (((x)&0xFFFFFFFFUL)>>(n))
|
||||
#define Sigma0( x ) (S(x, 2) ^ S(x, 13) ^ S(x, 22))
|
||||
#define Sigma1( x ) (S(x, 6) ^ S(x, 11) ^ S(x, 25))
|
||||
#define Gamma0( x ) (S(x, 7) ^ S(x, 18) ^ R(x, 3))
|
||||
#define Gamma1( x ) (S(x, 17) ^ S(x, 19) ^ R(x, 10))
|
||||
|
||||
#define Sha256Round( a, b, c, d, e, f, g, h, i ) \
|
||||
t0 = h + Sigma1(e) + Ch(e, f, g) + K[i] + W[i]; \
|
||||
t1 = Sigma0(a) + Maj(a, b, c); \
|
||||
d += t0; \
|
||||
h = t0 + t1;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// TransformFunction
|
||||
//
|
||||
// Compress 512-bits
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
static
|
||||
void
|
||||
TransformFunction
|
||||
(
|
||||
Sha256Context* Context,
|
||||
uint8_t* Buffer
|
||||
)
|
||||
{
|
||||
uint32_t S[8];
|
||||
uint32_t W[64];
|
||||
uint32_t t0;
|
||||
uint32_t t1;
|
||||
uint32_t t;
|
||||
int i;
|
||||
|
||||
// Copy state into S
|
||||
for( i=0; i<8; i++ )
|
||||
{
|
||||
S[i] = Context->state[i];
|
||||
}
|
||||
|
||||
// Copy the state into 512-bits into W[0..15]
|
||||
for( i=0; i<16; i++ )
|
||||
{
|
||||
LOAD32H( W[i], Buffer + (4*i) );
|
||||
}
|
||||
|
||||
// Fill W[16..63]
|
||||
for( i=16; i<64; i++ )
|
||||
{
|
||||
W[i] = Gamma1( W[i-2]) + W[i-7] + Gamma0( W[i-15] ) + W[i-16];
|
||||
}
|
||||
|
||||
// Compress
|
||||
for( i=0; i<64; i++ )
|
||||
{
|
||||
Sha256Round( S[0], S[1], S[2], S[3], S[4], S[5], S[6], S[7], i );
|
||||
t = S[7];
|
||||
S[7] = S[6];
|
||||
S[6] = S[5];
|
||||
S[5] = S[4];
|
||||
S[4] = S[3];
|
||||
S[3] = S[2];
|
||||
S[2] = S[1];
|
||||
S[1] = S[0];
|
||||
S[0] = t;
|
||||
}
|
||||
|
||||
// Feedback
|
||||
for( i=0; i<8; i++ )
|
||||
{
|
||||
Context->state[i] = Context->state[i] + S[i];
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// PUBLIC FUNCTIONS
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Sha256Initialise
|
||||
//
|
||||
// Initialises a SHA256 Context. Use this to initialise/reset a context.
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void Sha256Initialise
|
||||
(
|
||||
Sha256Context* Context
|
||||
)
|
||||
{
|
||||
Context->curlen = 0;
|
||||
Context->length = 0;
|
||||
Context->state[0] = 0x6A09E667UL;
|
||||
Context->state[1] = 0xBB67AE85UL;
|
||||
Context->state[2] = 0x3C6EF372UL;
|
||||
Context->state[3] = 0xA54FF53AUL;
|
||||
Context->state[4] = 0x510E527FUL;
|
||||
Context->state[5] = 0x9B05688CUL;
|
||||
Context->state[6] = 0x1F83D9ABUL;
|
||||
Context->state[7] = 0x5BE0CD19UL;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Sha256Update
|
||||
//
|
||||
// Adds data to the SHA256 context. This will process the data and update the internal state of the context. Keep on
|
||||
// calling this function until all the data has been added. Then call Sha256Finalise to calculate the hash.
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void Sha256Update
|
||||
(
|
||||
Sha256Context* Context,
|
||||
void* Buffer,
|
||||
uint32_t BufferSize
|
||||
)
|
||||
{
|
||||
uint32_t n
|
||||
;
|
||||
if( Context->curlen > sizeof(Context->buf) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
while( BufferSize > 0 )
|
||||
{
|
||||
if( Context->curlen == 0 && BufferSize >= BLOCK_SIZE )
|
||||
{
|
||||
TransformFunction( Context, (uint8_t*)Buffer );
|
||||
Context->length += BLOCK_SIZE * 8;
|
||||
Buffer = (uint8_t*)Buffer + BLOCK_SIZE;
|
||||
BufferSize -= BLOCK_SIZE;
|
||||
}
|
||||
else
|
||||
{
|
||||
n = MIN( BufferSize, (BLOCK_SIZE - Context->curlen) );
|
||||
memcpy( Context->buf + Context->curlen, Buffer, (size_t)n );
|
||||
Context->curlen += n;
|
||||
Buffer = (uint8_t*)Buffer + n;
|
||||
BufferSize -= n;
|
||||
if( Context->curlen == BLOCK_SIZE )
|
||||
{
|
||||
TransformFunction( Context, Context->buf );
|
||||
Context->length += 8*BLOCK_SIZE;
|
||||
Context->curlen = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Sha256Finalise
|
||||
//
|
||||
// Performs the final calculation of the hash and returns the digest (32 byte buffer containing 256bit hash). After
|
||||
// calling this, Sha256Initialised must be used to reuse the context.
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
Sha256Finalise
|
||||
(
|
||||
Sha256Context* Context,
|
||||
SHA256_HASH* Digest
|
||||
)
|
||||
{
|
||||
int i;
|
||||
|
||||
if( Context->curlen >= sizeof(Context->buf) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Increase the length of the message
|
||||
Context->length += Context->curlen * 8;
|
||||
|
||||
// Append the '1' bit
|
||||
Context->buf[Context->curlen++] = (uint8_t)0x80;
|
||||
|
||||
// if the length is currently above 56 bytes we append zeros
|
||||
// then compress. Then we can fall back to padding zeros and length
|
||||
// encoding like normal.
|
||||
if( Context->curlen > 56 )
|
||||
{
|
||||
while( Context->curlen < 64 )
|
||||
{
|
||||
Context->buf[Context->curlen++] = (uint8_t)0;
|
||||
}
|
||||
TransformFunction(Context, Context->buf);
|
||||
Context->curlen = 0;
|
||||
}
|
||||
|
||||
// Pad up to 56 bytes of zeroes
|
||||
while( Context->curlen < 56 )
|
||||
{
|
||||
Context->buf[Context->curlen++] = (uint8_t)0;
|
||||
}
|
||||
|
||||
// Store length
|
||||
STORE64H( Context->length, Context->buf+56 );
|
||||
TransformFunction( Context, Context->buf );
|
||||
|
||||
// Copy output
|
||||
for( i=0; i<8; i++ )
|
||||
{
|
||||
STORE32H( Context->state[i], Digest->bytes+(4*i) );
|
||||
}
|
||||
}
|
||||
|
||||
78
lib/LibSha256.h
Normal file
78
lib/LibSha256.h
Normal file
@@ -0,0 +1,78 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// LibSha256
|
||||
//
|
||||
// Implementation of SHA256 hash function.
|
||||
// Original author: Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
// Modified by WaterJuice retaining Public Domain license.
|
||||
//
|
||||
// This is free and unencumbered software released into the public domain - June 2013 waterjuice.org
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _LibSha256_h_
|
||||
#define _LibSha256_h_
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// IMPORTS
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint64_t length;
|
||||
uint32_t state[8];
|
||||
uint32_t curlen;
|
||||
uint8_t buf[64];
|
||||
} Sha256Context;
|
||||
|
||||
#define SHA256_HASH_SIZE ( 256 / 8 )
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t bytes [SHA256_HASH_SIZE];
|
||||
} SHA256_HASH;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// PUBLIC FUNCTIONS
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Sha256Initialise
|
||||
//
|
||||
// Initialises a SHA256 Context. Use this to initialise/reset a context.
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void Sha256Initialise
|
||||
(
|
||||
Sha256Context* Context
|
||||
);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Sha256Update
|
||||
//
|
||||
// Adds data to the SHA256 context. This will process the data and update the internal state of the context. Keep on
|
||||
// calling this function until all the data has been added. Then call Sha256Finalise to calculate the hash.
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void Sha256Update
|
||||
(
|
||||
Sha256Context* Context,
|
||||
void* Buffer,
|
||||
uint32_t BufferSize
|
||||
);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Sha256Finalise
|
||||
//
|
||||
// Performs the final calculation of the hash and returns the digest (32 byte buffer containing 256bit hash). After
|
||||
// calling this, Sha256Initialised must be used to reuse the context.
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
Sha256Finalise
|
||||
(
|
||||
Sha256Context* Context,
|
||||
SHA256_HASH* Digest
|
||||
);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
#endif //_LibSha256_h_
|
||||
|
||||
277
lib/LibSha512.c
Normal file
277
lib/LibSha512.c
Normal file
@@ -0,0 +1,277 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// LibSha512
|
||||
//
|
||||
// Implementation of SHA512 hash function.
|
||||
// Original author: Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
// Modified by WaterJuice retaining Public Domain license.
|
||||
//
|
||||
// This is free and unencumbered software released into the public domain - June 2013 waterjuice.org
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// IMPORTS
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "LibSha512.h"
|
||||
#include <memory.h>
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// MACROS
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define ROR64( value, bits ) (((value) >> (bits)) | ((value) << (64 - (bits))))
|
||||
|
||||
#define MIN( x, y ) ( ((x)<(y))?(x):(y) )
|
||||
|
||||
#define LOAD64H( x, y ) \
|
||||
{ x = (((uint64_t)((y)[0] & 255))<<56)|(((uint64_t)((y)[1] & 255))<<48) | \
|
||||
(((uint64_t)((y)[2] & 255))<<40)|(((uint64_t)((y)[3] & 255))<<32) | \
|
||||
(((uint64_t)((y)[4] & 255))<<24)|(((uint64_t)((y)[5] & 255))<<16) | \
|
||||
(((uint64_t)((y)[6] & 255))<<8)|(((uint64_t)((y)[7] & 255))); }
|
||||
|
||||
#define STORE64H( x, y ) \
|
||||
{ (y)[0] = (uint8_t)(((x)>>56)&255); (y)[1] = (uint8_t)(((x)>>48)&255); \
|
||||
(y)[2] = (uint8_t)(((x)>>40)&255); (y)[3] = (uint8_t)(((x)>>32)&255); \
|
||||
(y)[4] = (uint8_t)(((x)>>24)&255); (y)[5] = (uint8_t)(((x)>>16)&255); \
|
||||
(y)[6] = (uint8_t)(((x)>>8)&255); (y)[7] = (uint8_t)((x)&255); }
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// CONSTANTS
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// The K array
|
||||
static const uint64_t K[80] = {
|
||||
0x428a2f98d728ae22ULL, 0x7137449123ef65cdULL, 0xb5c0fbcfec4d3b2fULL, 0xe9b5dba58189dbbcULL,
|
||||
0x3956c25bf348b538ULL, 0x59f111f1b605d019ULL, 0x923f82a4af194f9bULL, 0xab1c5ed5da6d8118ULL,
|
||||
0xd807aa98a3030242ULL, 0x12835b0145706fbeULL, 0x243185be4ee4b28cULL, 0x550c7dc3d5ffb4e2ULL,
|
||||
0x72be5d74f27b896fULL, 0x80deb1fe3b1696b1ULL, 0x9bdc06a725c71235ULL, 0xc19bf174cf692694ULL,
|
||||
0xe49b69c19ef14ad2ULL, 0xefbe4786384f25e3ULL, 0x0fc19dc68b8cd5b5ULL, 0x240ca1cc77ac9c65ULL,
|
||||
0x2de92c6f592b0275ULL, 0x4a7484aa6ea6e483ULL, 0x5cb0a9dcbd41fbd4ULL, 0x76f988da831153b5ULL,
|
||||
0x983e5152ee66dfabULL, 0xa831c66d2db43210ULL, 0xb00327c898fb213fULL, 0xbf597fc7beef0ee4ULL,
|
||||
0xc6e00bf33da88fc2ULL, 0xd5a79147930aa725ULL, 0x06ca6351e003826fULL, 0x142929670a0e6e70ULL,
|
||||
0x27b70a8546d22ffcULL, 0x2e1b21385c26c926ULL, 0x4d2c6dfc5ac42aedULL, 0x53380d139d95b3dfULL,
|
||||
0x650a73548baf63deULL, 0x766a0abb3c77b2a8ULL, 0x81c2c92e47edaee6ULL, 0x92722c851482353bULL,
|
||||
0xa2bfe8a14cf10364ULL, 0xa81a664bbc423001ULL, 0xc24b8b70d0f89791ULL, 0xc76c51a30654be30ULL,
|
||||
0xd192e819d6ef5218ULL, 0xd69906245565a910ULL, 0xf40e35855771202aULL, 0x106aa07032bbd1b8ULL,
|
||||
0x19a4c116b8d2d0c8ULL, 0x1e376c085141ab53ULL, 0x2748774cdf8eeb99ULL, 0x34b0bcb5e19b48a8ULL,
|
||||
0x391c0cb3c5c95a63ULL, 0x4ed8aa4ae3418acbULL, 0x5b9cca4f7763e373ULL, 0x682e6ff3d6b2b8a3ULL,
|
||||
0x748f82ee5defb2fcULL, 0x78a5636f43172f60ULL, 0x84c87814a1f0ab72ULL, 0x8cc702081a6439ecULL,
|
||||
0x90befffa23631e28ULL, 0xa4506cebde82bde9ULL, 0xbef9a3f7b2c67915ULL, 0xc67178f2e372532bULL,
|
||||
0xca273eceea26619cULL, 0xd186b8c721c0c207ULL, 0xeada7dd6cde0eb1eULL, 0xf57d4f7fee6ed178ULL,
|
||||
0x06f067aa72176fbaULL, 0x0a637dc5a2c898a6ULL, 0x113f9804bef90daeULL, 0x1b710b35131c471bULL,
|
||||
0x28db77f523047d84ULL, 0x32caab7b40c72493ULL, 0x3c9ebe0a15c9bebcULL, 0x431d67c49c100d4cULL,
|
||||
0x4cc5d4becb3e42b6ULL, 0x597f299cfc657e2aULL, 0x5fcb6fab3ad6faecULL, 0x6c44198c4a475817ULL
|
||||
};
|
||||
|
||||
#define BLOCK_SIZE 128
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// INTERNAL FUNCTIONS
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Various logical functions
|
||||
#define Ch( x, y, z ) (z ^ (x & (y ^ z)))
|
||||
#define Maj(x, y, z ) (((x | y) & z) | (x & y))
|
||||
#define S( x, n ) ROR64( x, n )
|
||||
#define R( x, n ) (((x)&0xFFFFFFFFFFFFFFFFULL)>>((uint64_t)n))
|
||||
#define Sigma0( x ) (S(x, 28) ^ S(x, 34) ^ S(x, 39))
|
||||
#define Sigma1( x ) (S(x, 14) ^ S(x, 18) ^ S(x, 41))
|
||||
#define Gamma0( x ) (S(x, 1) ^ S(x, 8) ^ R(x, 7))
|
||||
#define Gamma1( x ) (S(x, 19) ^ S(x, 61) ^ R(x, 6))
|
||||
|
||||
#define Sha512Round( a, b, c, d, e, f, g, h, i ) \
|
||||
t0 = h + Sigma1(e) + Ch(e, f, g) + K[i] + W[i]; \
|
||||
t1 = Sigma0(a) + Maj(a, b, c); \
|
||||
d += t0; \
|
||||
h = t0 + t1;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// TransformFunction
|
||||
//
|
||||
// Compress 1024-bits
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
static
|
||||
void
|
||||
TransformFunction
|
||||
(
|
||||
Sha512Context* Context,
|
||||
uint8_t* Buffer
|
||||
)
|
||||
{
|
||||
uint64_t S[8];
|
||||
uint64_t W[80];
|
||||
uint64_t t0;
|
||||
uint64_t t1;
|
||||
int i;
|
||||
|
||||
// Copy state into S
|
||||
for( i=0; i<8; i++ )
|
||||
{
|
||||
S[i] = Context->state[i];
|
||||
}
|
||||
|
||||
// Copy the state into 1024-bits into W[0..15]
|
||||
for( i=0; i<16; i++ )
|
||||
{
|
||||
LOAD64H(W[i], Buffer + (8*i));
|
||||
}
|
||||
|
||||
// Fill W[16..79]
|
||||
for( i=16; i<80; i++ )
|
||||
{
|
||||
W[i] = Gamma1(W[i - 2]) + W[i - 7] + Gamma0(W[i - 15]) + W[i - 16];
|
||||
}
|
||||
|
||||
// Compress
|
||||
for( i=0; i<80; i+=8 )
|
||||
{
|
||||
Sha512Round(S[0],S[1],S[2],S[3],S[4],S[5],S[6],S[7],i+0);
|
||||
Sha512Round(S[7],S[0],S[1],S[2],S[3],S[4],S[5],S[6],i+1);
|
||||
Sha512Round(S[6],S[7],S[0],S[1],S[2],S[3],S[4],S[5],i+2);
|
||||
Sha512Round(S[5],S[6],S[7],S[0],S[1],S[2],S[3],S[4],i+3);
|
||||
Sha512Round(S[4],S[5],S[6],S[7],S[0],S[1],S[2],S[3],i+4);
|
||||
Sha512Round(S[3],S[4],S[5],S[6],S[7],S[0],S[1],S[2],i+5);
|
||||
Sha512Round(S[2],S[3],S[4],S[5],S[6],S[7],S[0],S[1],i+6);
|
||||
Sha512Round(S[1],S[2],S[3],S[4],S[5],S[6],S[7],S[0],i+7);
|
||||
}
|
||||
|
||||
// Feedback
|
||||
for( i=0; i<8; i++ )
|
||||
{
|
||||
Context->state[i] = Context->state[i] + S[i];
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// PUBLIC FUNCTIONS
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Sha512Initialise
|
||||
//
|
||||
// Initialises a SHA512 Context. Use this to initialise/reset a context.
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
Sha512Initialise
|
||||
(
|
||||
Sha512Context* Context
|
||||
)
|
||||
{
|
||||
Context->curlen = 0;
|
||||
Context->length = 0;
|
||||
Context->state[0] = 0x6a09e667f3bcc908ULL;
|
||||
Context->state[1] = 0xbb67ae8584caa73bULL;
|
||||
Context->state[2] = 0x3c6ef372fe94f82bULL;
|
||||
Context->state[3] = 0xa54ff53a5f1d36f1ULL;
|
||||
Context->state[4] = 0x510e527fade682d1ULL;
|
||||
Context->state[5] = 0x9b05688c2b3e6c1fULL;
|
||||
Context->state[6] = 0x1f83d9abfb41bd6bULL;
|
||||
Context->state[7] = 0x5be0cd19137e2179ULL;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Sha512Update
|
||||
//
|
||||
// Adds data to the SHA512 context. This will process the data and update the internal state of the context. Keep on
|
||||
// calling this function until all the data has been added. Then call Sha512Finalise to calculate the hash.
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
Sha512Update
|
||||
(
|
||||
Sha512Context* Context,
|
||||
void* Buffer,
|
||||
uint32_t BufferSize
|
||||
)
|
||||
{
|
||||
uint32_t n;
|
||||
|
||||
if( Context->curlen > sizeof(Context->buf) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
while( BufferSize > 0 )
|
||||
{
|
||||
if( Context->curlen == 0 && BufferSize >= BLOCK_SIZE )
|
||||
{
|
||||
TransformFunction( Context, (uint8_t *)Buffer );
|
||||
Context->length += BLOCK_SIZE * 8;
|
||||
Buffer = (uint8_t*)Buffer + BLOCK_SIZE;
|
||||
BufferSize -= BLOCK_SIZE;
|
||||
}
|
||||
else
|
||||
{
|
||||
n = MIN( BufferSize, (BLOCK_SIZE - Context->curlen) );
|
||||
memcpy( Context->buf + Context->curlen, Buffer, (size_t)n );
|
||||
Context->curlen += n;
|
||||
Buffer = (uint8_t*)Buffer + n;
|
||||
BufferSize -= n;
|
||||
if( Context->curlen == BLOCK_SIZE )
|
||||
{
|
||||
TransformFunction( Context, Context->buf );
|
||||
Context->length += 8*BLOCK_SIZE;
|
||||
Context->curlen = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Sha512Finalise
|
||||
//
|
||||
// Performs the final calculation of the hash and returns the digest (64 byte buffer containing 512bit hash). After
|
||||
// calling this, Sha512Initialised must be used to reuse the context.
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
Sha512Finalise
|
||||
(
|
||||
Sha512Context* Context,
|
||||
SHA512_HASH* Digest
|
||||
)
|
||||
{
|
||||
int i;
|
||||
|
||||
if( Context->curlen >= sizeof(Context->buf) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Increase the length of the message
|
||||
Context->length += Context->curlen * 8ULL;
|
||||
|
||||
// Append the '1' bit
|
||||
Context->buf[Context->curlen++] = (uint8_t)0x80;
|
||||
|
||||
// If the length is currently above 112 bytes we append zeros
|
||||
// then compress. Then we can fall back to padding zeros and length
|
||||
// encoding like normal.
|
||||
if( Context->curlen > 112 )
|
||||
{
|
||||
while( Context->curlen < 128 )
|
||||
{
|
||||
Context->buf[Context->curlen++] = (uint8_t)0;
|
||||
}
|
||||
TransformFunction( Context, Context->buf );
|
||||
Context->curlen = 0;
|
||||
}
|
||||
|
||||
// Pad up to 120 bytes of zeroes
|
||||
// note: that from 112 to 120 is the 64 MSB of the length. We assume that you won't hash
|
||||
// > 2^64 bits of data... :-)
|
||||
while( Context->curlen < 120 )
|
||||
{
|
||||
Context->buf[Context->curlen++] = (uint8_t)0;
|
||||
}
|
||||
|
||||
// Store length
|
||||
STORE64H( Context->length, Context->buf+120 );
|
||||
TransformFunction( Context, Context->buf );
|
||||
|
||||
// Copy output
|
||||
for( i=0; i<8; i++ )
|
||||
{
|
||||
STORE64H( Context->state[i], Digest->bytes+(8*i) );
|
||||
}
|
||||
}
|
||||
|
||||
78
lib/LibSha512.h
Normal file
78
lib/LibSha512.h
Normal file
@@ -0,0 +1,78 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// LibSha512
|
||||
//
|
||||
// Implementation of SHA512 hash function.
|
||||
// Original author: Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||
// Modified by WaterJuice retaining Public Domain license.
|
||||
//
|
||||
// This is free and unencumbered software released into the public domain - June 2013 waterjuice.org
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _LibSha512_h_
|
||||
#define _LibSha512_h_
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// IMPORTS
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint64_t length;
|
||||
uint64_t state[8];
|
||||
uint32_t curlen;
|
||||
uint8_t buf[128];
|
||||
} Sha512Context;
|
||||
|
||||
#define SHA512_HASH_SIZE ( 512 / 8 )
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t bytes [SHA512_HASH_SIZE];
|
||||
} SHA512_HASH;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// PUBLIC FUNCTIONS
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Sha512Initialise
|
||||
//
|
||||
// Initialises a SHA512 Context. Use this to initialise/reset a context.
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void Sha512Initialise
|
||||
(
|
||||
Sha512Context* Context
|
||||
);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Sha512Update
|
||||
//
|
||||
// Adds data to the SHA512 context. This will process the data and update the internal state of the context. Keep on
|
||||
// calling this function until all the data has been added. Then call Sha512Finalise to calculate the hash.
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void Sha512Update
|
||||
(
|
||||
Sha512Context* Context,
|
||||
void* Buffer,
|
||||
uint32_t BufferSize
|
||||
);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Sha512Finalise
|
||||
//
|
||||
// Performs the final calculation of the hash and returns the digest (64 byte buffer containing 512bit hash). After
|
||||
// calling this, Sha512Initialised must be used to reuse the context.
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
Sha512Finalise
|
||||
(
|
||||
Sha512Context* Context,
|
||||
SHA512_HASH* Digest
|
||||
);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
#endif //_LibSha512_h_
|
||||
|
||||
70
makefile
Normal file
70
makefile
Normal file
@@ -0,0 +1,70 @@
|
||||
OUTDIR = Bin/$(PLATFORM)
|
||||
INCLUDES = -I ./lib
|
||||
|
||||
all: CryptLibTest Md5String Sha1String Sha256String Sha512String Rc4Output
|
||||
|
||||
CryptLibTest: dir
|
||||
$(COMPILE) projects/CryptLibTest/CryptLibTest.c lib/LibRc4.c lib/LibMd5.c lib/LibSha1.c lib/LibSha256.c lib/LibSha512.c $(TAIL)
|
||||
$(STRIP)
|
||||
|
||||
Md5String: dir
|
||||
$(COMPILE) projects/Md5String/Md5String.c lib/LibMd5.c lib/LibSha1.c lib/LibSha256.c lib/LibSha512.c $(TAIL)
|
||||
$(STRIP)
|
||||
|
||||
Sha1String: dir
|
||||
$(COMPILE) projects/Sha1String/Sha1String.c lib/LibSha1.c $(TAIL)
|
||||
$(STRIP)
|
||||
|
||||
Sha256String: dir
|
||||
$(COMPILE) projects/Sha256String/Sha256String.c lib/LibSha256.c $(TAIL)
|
||||
$(STRIP)
|
||||
|
||||
Sha512String: dir
|
||||
$(COMPILE) projects/Sha512String/Sha512String.c lib/LibSha512.c $(TAIL)
|
||||
$(STRIP)
|
||||
|
||||
Rc4Output: dir
|
||||
$(COMPILE) projects/Rc4Output/Rc4Output.c lib/LibRc4.c $(TAIL)
|
||||
$(STRIP)
|
||||
|
||||
dir:
|
||||
@mkdir -p $(OUTDIR)
|
||||
|
||||
|
||||
###### Setup build parameters #####
|
||||
ifeq ($(OS),Windows_NT)
|
||||
ifdef VSINSTALLDIR
|
||||
ifeq ($(Platform),X64)
|
||||
PLATFORM = Windows
|
||||
else
|
||||
PLATFORM = WindowsX86
|
||||
endif
|
||||
INTDIR = Build/$(PLATFORM)/$@
|
||||
INCLUDES := $(INCLUDES) /I ./stdbool
|
||||
COMPILE = @echo & echo ::::: Building $(PLATFORM) $@ & mkdir -p $(INTDIR) & cl $(INCLUDES) /nologo /Ox /Oi /Ot /GL /MD /W4 /WX /Fe$(OUTDIR)/$@ /D_CRT_SECURE_NO_WARNINGS /Fo$(INTDIR)/
|
||||
TAIL=/link /RELEASE
|
||||
else ifneq (,$findstring /cygwin/,$(PATH))
|
||||
PLATFORM = Cygwin
|
||||
COMPILE = @echo ::::: Building $(PLATFORM) $@ & gcc $(INCLUDES) -O3 -Wall -Werror -o $(OUTDIR)/$@
|
||||
STRIP = @strip $(OUTDIR)/$@
|
||||
else
|
||||
PLATFORM = None
|
||||
COMPILE = echo
|
||||
STRIP =
|
||||
$(error Windows requires VS environment, or Cygwin)
|
||||
endif
|
||||
else
|
||||
PLATFORM = $(shell uname)
|
||||
ifeq ($(PLATFORM),Darwin)
|
||||
PLATFORM=OSX
|
||||
else ifeq ($(PLATFORM),Linux)
|
||||
PLATFORM=Linux
|
||||
else
|
||||
$(error Unsupported platform. Non Windows platform support: OSX and Linux)
|
||||
endif
|
||||
COMPILE = @echo ::::: Building $(PLATFORM) $@ & gcc $(INCLUDES) -O3 -Wall -Werror -pthread -o $(OUTDIR)/$@
|
||||
STRIP = @strip $(OUTDIR)/$@
|
||||
TAIL = -lm
|
||||
endif
|
||||
|
||||
|
||||
550
projects/CryptLibTest/CryptLibTest.c
Normal file
550
projects/CryptLibTest/CryptLibTest.c
Normal file
@@ -0,0 +1,550 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// CryptLibTest
|
||||
//
|
||||
// Tests the cryptography functions against known test vectors to verify algorithyms are correct.
|
||||
// Tests the following:
|
||||
// RC4
|
||||
// MD5
|
||||
// SHA1
|
||||
// SHA256
|
||||
// SHA512
|
||||
//
|
||||
// This is free and unencumbered software released into the public domain - June 2013 waterjuice.org
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// IMPORTS
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
#include "LibRc4.h"
|
||||
#include "LibMd5.h"
|
||||
#include "LibSha1.h"
|
||||
#include "LibSha256.h"
|
||||
#include "LibSha512.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// TYPES
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define MAX_PLAINTEXT_SIZE 100
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char PlainText [MAX_PLAINTEXT_SIZE];
|
||||
int PlainTextSize; // 0 to use (int)strlen
|
||||
MD5_HASH Md5Hash;
|
||||
SHA1_HASH Sha1Hash;
|
||||
SHA256_HASH Sha256Hash;
|
||||
SHA512_HASH Sha512Hash;
|
||||
} TestVector;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// GLOBALS
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static TestVector gTestVectors [] =
|
||||
{
|
||||
{
|
||||
"", 0,
|
||||
{{0xd4,0x1d,0x8c,0xd9,0x8f,0x00,0xb2,0x04,0xe9,0x80,0x09,0x98,0xec,0xf8,0x42,0x7e}}, // md5
|
||||
{{0xda,0x39,0xa3,0xee,0x5e,0x6b,0x4b,0x0d,0x32,0x55,0xbf,0xef,0x95,0x60,0x18,0x90,0xaf,0xd8,0x07,0x09}}, // sha1
|
||||
{{0xe3,0xb0,0xc4,0x42,0x98,0xfc,0x1c,0x14,0x9a,0xfb,0xf4,0xc8,0x99,0x6f,0xb9,0x24,
|
||||
0x27,0xae,0x41,0xe4,0x64,0x9b,0x93,0x4c,0xa4,0x95,0x99,0x1b,0x78,0x52,0xb8,0x55}}, // sha256
|
||||
{{0xcf,0x83,0xe1,0x35,0x7e,0xef,0xb8,0xbd,0xf1,0x54,0x28,0x50,0xd6,0x6d,0x80,0x07,
|
||||
0xd6,0x20,0xe4,0x05,0x0b,0x57,0x15,0xdc,0x83,0xf4,0xa9,0x21,0xd3,0x6c,0xe9,0xce,
|
||||
0x47,0xd0,0xd1,0x3c,0x5d,0x85,0xf2,0xb0,0xff,0x83,0x18,0xd2,0x87,0x7e,0xec,0x2f,
|
||||
0x63,0xb9,0x31,0xbd,0x47,0x41,0x7a,0x81,0xa5,0x38,0x32,0x7a,0xf9,0x27,0xda,0x3e}}, // sha512
|
||||
},
|
||||
{
|
||||
"a", 0,
|
||||
{{0x0c,0xc1,0x75,0xb9,0xc0,0xf1,0xb6,0xa8,0x31,0xc3,0x99,0xe2,0x69,0x77,0x26,0x61}}, // md5
|
||||
{{0x86,0xf7,0xe4,0x37,0xfa,0xa5,0xa7,0xfc,0xe1,0x5d,0x1d,0xdc,0xb9,0xea,0xea,0xea,0x37,0x76,0x67,0xb8}}, // sha1
|
||||
{{0xca,0x97,0x81,0x12,0xca,0x1b,0xbd,0xca,0xfa,0xc2,0x31,0xb3,0x9a,0x23,0xdc,0x4d,
|
||||
0xa7,0x86,0xef,0xf8,0x14,0x7c,0x4e,0x72,0xb9,0x80,0x77,0x85,0xaf,0xee,0x48,0xbb}}, // sha256
|
||||
{{0x1f,0x40,0xfc,0x92,0xda,0x24,0x16,0x94,0x75,0x09,0x79,0xee,0x6c,0xf5,0x82,0xf2,
|
||||
0xd5,0xd7,0xd2,0x8e,0x18,0x33,0x5d,0xe0,0x5a,0xbc,0x54,0xd0,0x56,0x0e,0x0f,0x53,
|
||||
0x02,0x86,0x0c,0x65,0x2b,0xf0,0x8d,0x56,0x02,0x52,0xaa,0x5e,0x74,0x21,0x05,0x46,
|
||||
0xf3,0x69,0xfb,0xbb,0xce,0x8c,0x12,0xcf,0xc7,0x95,0x7b,0x26,0x52,0xfe,0x9a,0x75}}, // sha512
|
||||
},
|
||||
{
|
||||
"aaa", 0,
|
||||
{{0x47,0xbc,0xe5,0xc7,0x4f,0x58,0x9f,0x48,0x67,0xdb,0xd5,0x7e,0x9c,0xa9,0xf8,0x08}}, // md5
|
||||
{{0x7e,0x24,0x0d,0xe7,0x4f,0xb1,0xed,0x08,0xfa,0x08,0xd3,0x80,0x63,0xf6,0xa6,0xa9,0x14,0x62,0xa8,0x15}}, // sha1
|
||||
{{0x98,0x34,0x87,0x6d,0xcf,0xb0,0x5c,0xb1,0x67,0xa5,0xc2,0x49,0x53,0xeb,0xa5,0x8c,
|
||||
0x4a,0xc8,0x9b,0x1a,0xdf,0x57,0xf2,0x8f,0x2f,0x9d,0x09,0xaf,0x10,0x7e,0xe8,0xf0}}, // sha256
|
||||
{{0xd6,0xf6,0x44,0xb1,0x98,0x12,0xe9,0x7b,0x5d,0x87,0x16,0x58,0xd6,0xd3,0x40,0x0e,
|
||||
0xcd,0x47,0x87,0xfa,0xeb,0x9b,0x89,0x90,0xc1,0xe7,0x60,0x82,0x88,0x66,0x4b,0xe7,
|
||||
0x72,0x57,0x10,0x4a,0x58,0xd0,0x33,0xbc,0xf1,0xa0,0xe0,0x94,0x5f,0xf0,0x64,0x68,
|
||||
0xeb,0xe5,0x3e,0x2d,0xff,0x36,0xe2,0x48,0x42,0x4c,0x72,0x73,0x11,0x7d,0xac,0x09}}, // sha512
|
||||
},
|
||||
{
|
||||
"abc", 0,
|
||||
{{0x90,0x01,0x50,0x98,0x3c,0xd2,0x4f,0xb0,0xd6,0x96,0x3f,0x7d,0x28,0xe1,0x7f,0x72}}, // md5
|
||||
{{0xa9,0x99,0x3e,0x36,0x47,0x06,0x81,0x6a,0xba,0x3e,0x25,0x71,0x78,0x50,0xc2,0x6c,0x9c,0xd0,0xd8,0x9d}}, // sha1
|
||||
{{0xba,0x78,0x16,0xbf,0x8f,0x01,0xcf,0xea,0x41,0x41,0x40,0xde,0x5d,0xae,0x22,0x23,
|
||||
0xb0,0x03,0x61,0xa3,0x96,0x17,0x7a,0x9c,0xb4,0x10,0xff,0x61,0xf2,0x00,0x15,0xad}}, // sha256
|
||||
{{0xdd,0xaf,0x35,0xa1,0x93,0x61,0x7a,0xba,0xcc,0x41,0x73,0x49,0xae,0x20,0x41,0x31,
|
||||
0x12,0xe6,0xfa,0x4e,0x89,0xa9,0x7e,0xa2,0x0a,0x9e,0xee,0xe6,0x4b,0x55,0xd3,0x9a,
|
||||
0x21,0x92,0x99,0x2a,0x27,0x4f,0xc1,0xa8,0x36,0xba,0x3c,0x23,0xa3,0xfe,0xeb,0xbd,
|
||||
0x45,0x4d,0x44,0x23,0x64,0x3c,0xe8,0x0e,0x2a,0x9a,0xc9,0x4f,0xa5,0x4c,0xa4,0x9f}}, // sha512
|
||||
},
|
||||
{
|
||||
"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", 0,
|
||||
{{0x82,0x15,0xef,0x07,0x96,0xa2,0x0b,0xca,0xaa,0xe1,0x16,0xd3,0x87,0x6c,0x66,0x4a}}, // md5
|
||||
{{0x84,0x98,0x3e,0x44,0x1c,0x3b,0xd2,0x6e,0xba,0xae,0x4a,0xa1,0xf9,0x51,0x29,0xe5,0xe5,0x46,0x70,0xf1}}, // sha1
|
||||
{{0x24,0x8d,0x6a,0x61,0xd2,0x06,0x38,0xb8,0xe5,0xc0,0x26,0x93,0x0c,0x3e,0x60,0x39,
|
||||
0xa3,0x3c,0xe4,0x59,0x64,0xff,0x21,0x67,0xf6,0xec,0xed,0xd4,0x19,0xdb,0x06,0xc1}}, // sha256
|
||||
{{0x20,0x4a,0x8f,0xc6,0xdd,0xa8,0x2f,0x0a,0x0c,0xed,0x7b,0xeb,0x8e,0x08,0xa4,0x16,
|
||||
0x57,0xc1,0x6e,0xf4,0x68,0xb2,0x28,0xa8,0x27,0x9b,0xe3,0x31,0xa7,0x03,0xc3,0x35,
|
||||
0x96,0xfd,0x15,0xc1,0x3b,0x1b,0x07,0xf9,0xaa,0x1d,0x3b,0xea,0x57,0x78,0x9c,0xa0,
|
||||
0x31,0xad,0x85,0xc7,0xa7,0x1d,0xd7,0x03,0x54,0xec,0x63,0x12,0x38,0xca,0x34,0x45}}, // sha512
|
||||
},
|
||||
{
|
||||
"The quick brown fox jumps over the lazy dog", 0,
|
||||
{{0x9e,0x10,0x7d,0x9d,0x37,0x2b,0xb6,0x82,0x6b,0xd8,0x1d,0x35,0x42,0xa4,0x19,0xd6}}, // md5
|
||||
{{0x2f,0xd4,0xe1,0xc6,0x7a,0x2d,0x28,0xfc,0xed,0x84,0x9e,0xe1,0xbb,0x76,0xe7,0x39,0x1b,0x93,0xeb,0x12}}, // sha1
|
||||
{{0xd7,0xa8,0xfb,0xb3,0x07,0xd7,0x80,0x94,0x69,0xca,0x9a,0xbc,0xb0,0x08,0x2e,0x4f,
|
||||
0x8d,0x56,0x51,0xe4,0x6d,0x3c,0xdb,0x76,0x2d,0x02,0xd0,0xbf,0x37,0xc9,0xe5,0x92}}, // sha256
|
||||
{{0x07,0xe5,0x47,0xd9,0x58,0x6f,0x6a,0x73,0xf7,0x3f,0xba,0xc0,0x43,0x5e,0xd7,0x69,
|
||||
0x51,0x21,0x8f,0xb7,0xd0,0xc8,0xd7,0x88,0xa3,0x09,0xd7,0x85,0x43,0x6b,0xbb,0x64,
|
||||
0x2e,0x93,0xa2,0x52,0xa9,0x54,0xf2,0x39,0x12,0x54,0x7d,0x1e,0x8a,0x3b,0x5e,0xd6,
|
||||
0xe1,0xbf,0xd7,0x09,0x78,0x21,0x23,0x3f,0xa0,0x53,0x8f,0x3d,0xb8,0x54,0xfe,0xe6}}, // sha512
|
||||
},
|
||||
{
|
||||
"The quick brown fox jumps over the lazy dog.", 0,
|
||||
{{0xe4,0xd9,0x09,0xc2,0x90,0xd0,0xfb,0x1c,0xa0,0x68,0xff,0xad,0xdf,0x22,0xcb,0xd0}}, // md5
|
||||
{{0x40,0x8d,0x94,0x38,0x42,0x16,0xf8,0x90,0xff,0x7a,0x0c,0x35,0x28,0xe8,0xbe,0xd1,0xe0,0xb0,0x16,0x21}}, // sha1
|
||||
{{0xef,0x53,0x7f,0x25,0xc8,0x95,0xbf,0xa7,0x82,0x52,0x65,0x29,0xa9,0xb6,0x3d,0x97,
|
||||
0xaa,0x63,0x15,0x64,0xd5,0xd7,0x89,0xc2,0xb7,0x65,0x44,0x8c,0x86,0x35,0xfb,0x6c}}, // sha256
|
||||
{{0x91,0xea,0x12,0x45,0xf2,0x0d,0x46,0xae,0x9a,0x03,0x7a,0x98,0x9f,0x54,0xf1,0xf7,
|
||||
0x90,0xf0,0xa4,0x76,0x07,0xee,0xb8,0xa1,0x4d,0x12,0x89,0x0c,0xea,0x77,0xa1,0xbb,
|
||||
0xc6,0xc7,0xed,0x9c,0xf2,0x05,0xe6,0x7b,0x7f,0x2b,0x8f,0xd4,0xc7,0xdf,0xd3,0xa7,
|
||||
0xa8,0x61,0x7e,0x45,0xf3,0xc4,0x63,0xd4,0x81,0xc7,0xe5,0x86,0xc3,0x9a,0xc1,0xed}}, // sha512
|
||||
},
|
||||
{
|
||||
"message digest", 0,
|
||||
{{0xf9,0x6b,0x69,0x7d,0x7c,0xb7,0x93,0x8d,0x52,0x5a,0x2f,0x31,0xaa,0xf1,0x61,0xd0}}, // md5
|
||||
{{0xc1,0x22,0x52,0xce,0xda,0x8b,0xe8,0x99,0x4d,0x5f,0xa0,0x29,0x0a,0x47,0x23,0x1c,0x1d,0x16,0xaa,0xe3}}, // sha1
|
||||
{{0xf7,0x84,0x6f,0x55,0xcf,0x23,0xe1,0x4e,0xeb,0xea,0xb5,0xb4,0xe1,0x55,0x0c,0xad,
|
||||
0x5b,0x50,0x9e,0x33,0x48,0xfb,0xc4,0xef,0xa3,0xa1,0x41,0x3d,0x39,0x3c,0xb6,0x50}}, // sha256
|
||||
{{0x10,0x7d,0xbf,0x38,0x9d,0x9e,0x9f,0x71,0xa3,0xa9,0x5f,0x6c,0x05,0x5b,0x92,0x51,
|
||||
0xbc,0x52,0x68,0xc2,0xbe,0x16,0xd6,0xc1,0x34,0x92,0xea,0x45,0xb0,0x19,0x9f,0x33,
|
||||
0x09,0xe1,0x64,0x55,0xab,0x1e,0x96,0x11,0x8e,0x8a,0x90,0x5d,0x55,0x97,0xb7,0x20,
|
||||
0x38,0xdd,0xb3,0x72,0xa8,0x98,0x26,0x04,0x6d,0xe6,0x66,0x87,0xbb,0x42,0x0e,0x7c}}, // sha512
|
||||
},
|
||||
{
|
||||
"abcdefghijklmnopqrstuvwxyz", 0,
|
||||
{{0xc3,0xfc,0xd3,0xd7,0x61,0x92,0xe4,0x00,0x7d,0xfb,0x49,0x6c,0xca,0x67,0xe1,0x3b}}, // md5
|
||||
{{0x32,0xd1,0x0c,0x7b,0x8c,0xf9,0x65,0x70,0xca,0x04,0xce,0x37,0xf2,0xa1,0x9d,0x84,0x24,0x0d,0x3a,0x89}}, // sha1
|
||||
{{0x71,0xc4,0x80,0xdf,0x93,0xd6,0xae,0x2f,0x1e,0xfa,0xd1,0x44,0x7c,0x66,0xc9,0x52,
|
||||
0x5e,0x31,0x62,0x18,0xcf,0x51,0xfc,0x8d,0x9e,0xd8,0x32,0xf2,0xda,0xf1,0x8b,0x73}}, // sha256
|
||||
{{0x4d,0xbf,0xf8,0x6c,0xc2,0xca,0x1b,0xae,0x1e,0x16,0x46,0x8a,0x05,0xcb,0x98,0x81,
|
||||
0xc9,0x7f,0x17,0x53,0xbc,0xe3,0x61,0x90,0x34,0x89,0x8f,0xaa,0x1a,0xab,0xe4,0x29,
|
||||
0x95,0x5a,0x1b,0xf8,0xec,0x48,0x3d,0x74,0x21,0xfe,0x3c,0x16,0x46,0x61,0x3a,0x59,
|
||||
0xed,0x54,0x41,0xfb,0x0f,0x32,0x13,0x89,0xf7,0x7f,0x48,0xa8,0x79,0xc7,0xb1,0xf1}}, // sha512
|
||||
},
|
||||
{
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", 0,
|
||||
{{0xd1,0x74,0xab,0x98,0xd2,0x77,0xd9,0xf5,0xa5,0x61,0x1c,0x2c,0x9f,0x41,0x9d,0x9f}}, // md5
|
||||
{{0x76,0x1c,0x45,0x7b,0xf7,0x3b,0x14,0xd2,0x7e,0x9e,0x92,0x65,0xc4,0x6f,0x4b,0x4d,0xda,0x11,0xf9,0x40}}, // sha1
|
||||
{{0xdb,0x4b,0xfc,0xbd,0x4d,0xa0,0xcd,0x85,0xa6,0x0c,0x3c,0x37,0xd3,0xfb,0xd8,0x80,
|
||||
0x5c,0x77,0xf1,0x5f,0xc6,0xb1,0xfd,0xfe,0x61,0x4e,0xe0,0xa7,0xc8,0xfd,0xb4,0xc0}}, // sha256
|
||||
{{0x1e,0x07,0xbe,0x23,0xc2,0x6a,0x86,0xea,0x37,0xea,0x81,0x0c,0x8e,0xc7,0x80,0x93,
|
||||
0x52,0x51,0x5a,0x97,0x0e,0x92,0x53,0xc2,0x6f,0x53,0x6c,0xfc,0x7a,0x99,0x96,0xc4,
|
||||
0x5c,0x83,0x70,0x58,0x3e,0x0a,0x78,0xfa,0x4a,0x90,0x04,0x1d,0x71,0xa4,0xce,0xab,
|
||||
0x74,0x23,0xf1,0x9c,0x71,0xb9,0xd5,0xa3,0xe0,0x12,0x49,0xf0,0xbe,0xbd,0x58,0x94}}, // sha512
|
||||
},
|
||||
{ "12345678901234567890123456789012345678901234567890123456789012345678901234567890", 0,
|
||||
{{0x57,0xed,0xf4,0xa2,0x2b,0xe3,0xc9,0x55,0xac,0x49,0xda,0x2e,0x21,0x07,0xb6,0x7a}}, // md5
|
||||
{{0x50,0xab,0xf5,0x70,0x6a,0x15,0x09,0x90,0xa0,0x8b,0x2c,0x5e,0xa4,0x0f,0xa0,0xe5,0x85,0x55,0x47,0x32}}, // sha1
|
||||
{{0xf3,0x71,0xbc,0x4a,0x31,0x1f,0x2b,0x00,0x9e,0xef,0x95,0x2d,0xd8,0x3c,0xa8,0x0e,
|
||||
0x2b,0x60,0x02,0x6c,0x8e,0x93,0x55,0x92,0xd0,0xf9,0xc3,0x08,0x45,0x3c,0x81,0x3e}}, // sha256
|
||||
{{0x72,0xec,0x1e,0xf1,0x12,0x4a,0x45,0xb0,0x47,0xe8,0xb7,0xc7,0x5a,0x93,0x21,0x95,
|
||||
0x13,0x5b,0xb6,0x1d,0xe2,0x4e,0xc0,0xd1,0x91,0x40,0x42,0x24,0x6e,0x0a,0xec,0x3a,
|
||||
0x23,0x54,0xe0,0x93,0xd7,0x6f,0x30,0x48,0xb4,0x56,0x76,0x43,0x46,0x90,0x0c,0xb1,
|
||||
0x30,0xd2,0xa4,0xfd,0x5d,0xd1,0x6a,0xbb,0x5e,0x30,0xbc,0xb8,0x50,0xde,0xe8,0x43}}, // sha512
|
||||
},
|
||||
|
||||
};
|
||||
#define NUM_TEST_VECTORS ( sizeof(gTestVectors) / sizeof(gTestVectors[0]) )
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// PRIVATE FUNCTIONS
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// TestMd5
|
||||
//
|
||||
// Test MD5 algorithm against test vectors
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
static
|
||||
bool
|
||||
TestMd5
|
||||
(
|
||||
void
|
||||
)
|
||||
{
|
||||
int i;
|
||||
int k;
|
||||
int len;
|
||||
Md5Context context;
|
||||
MD5_HASH hash;
|
||||
bool success = true;
|
||||
|
||||
for( i=0; i<NUM_TEST_VECTORS; i++ )
|
||||
{
|
||||
Md5Initialise( &context );
|
||||
len = (int) gTestVectors[i].PlainTextSize ? gTestVectors[i].PlainTextSize : (int)strlen( gTestVectors[i].PlainText );
|
||||
Md5Update( &context, gTestVectors[i].PlainText, (uint32_t)len );
|
||||
Md5Finalise( &context, &hash );
|
||||
|
||||
if( memcmp( &hash, &gTestVectors[i].Md5Hash, sizeof(hash) ) == 0 )
|
||||
{
|
||||
// Test vector passed
|
||||
}
|
||||
else
|
||||
{
|
||||
printf( "TestMd5 - Test vector %u failed\n", i );
|
||||
success = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Check the vectors again, this time adding just 1 char at a time to the hash functions
|
||||
for( i=0; i<NUM_TEST_VECTORS; i++ )
|
||||
{
|
||||
Md5Initialise( &context );
|
||||
len = (int) gTestVectors[i].PlainTextSize ? gTestVectors[i].PlainTextSize : (int)strlen( gTestVectors[i].PlainText );
|
||||
for( k=0; k<len; k++ )
|
||||
{
|
||||
Md5Update( &context, &gTestVectors[i].PlainText[k], 1 );
|
||||
}
|
||||
Md5Finalise( &context, &hash );
|
||||
|
||||
if( memcmp( &hash, &gTestVectors[i].Md5Hash, sizeof(hash) ) == 0 )
|
||||
{
|
||||
// Test vector passed
|
||||
}
|
||||
else
|
||||
{
|
||||
printf( "TestMd5 - Test vector %u failed [byte by byte]\n", i );
|
||||
success = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// TestSha1
|
||||
//
|
||||
// Test SHA1 algorithm against test vectors
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
static
|
||||
bool
|
||||
TestSha1
|
||||
(
|
||||
void
|
||||
)
|
||||
{
|
||||
int i;
|
||||
int k;
|
||||
int len;
|
||||
Sha1Context context;
|
||||
SHA1_HASH hash;
|
||||
bool success = true;
|
||||
|
||||
for( i=0; i<NUM_TEST_VECTORS; i++ )
|
||||
{
|
||||
Sha1Initialise( &context );
|
||||
len = (int) gTestVectors[i].PlainTextSize ? gTestVectors[i].PlainTextSize : (int)strlen( gTestVectors[i].PlainText );
|
||||
Sha1Update( &context, gTestVectors[i].PlainText, (uint32_t)len );
|
||||
Sha1Finalise( &context, &hash );
|
||||
|
||||
if( memcmp( &hash, &gTestVectors[i].Sha1Hash, sizeof(hash) ) == 0 )
|
||||
{
|
||||
// Test vector passed
|
||||
}
|
||||
else
|
||||
{
|
||||
printf( "TestSha1 - Test vector %u failed\n", i );
|
||||
success = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Check the vectors again, this time adding just 1 char at a time to the hash functions
|
||||
for( i=0; i<NUM_TEST_VECTORS; i++ )
|
||||
{
|
||||
Sha1Initialise( &context );
|
||||
len = (int) gTestVectors[i].PlainTextSize ? gTestVectors[i].PlainTextSize : (int)strlen( gTestVectors[i].PlainText );
|
||||
for( k=0; k<len; k++ )
|
||||
{
|
||||
Sha1Update( &context, &gTestVectors[i].PlainText[k], 1 );
|
||||
}
|
||||
Sha1Finalise( &context, &hash );
|
||||
|
||||
if( memcmp( &hash, &gTestVectors[i].Sha1Hash, sizeof(hash) ) == 0 )
|
||||
{
|
||||
// Test vector passed
|
||||
}
|
||||
else
|
||||
{
|
||||
printf( "TestSha1 - Test vector %u failed [byte by byte]\n", i );
|
||||
success = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// TestSha256
|
||||
//
|
||||
// Test SHA1 algorithm against test vectors
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
static
|
||||
bool
|
||||
TestSha256
|
||||
(
|
||||
void
|
||||
)
|
||||
{
|
||||
int i;
|
||||
int k;
|
||||
int len;
|
||||
Sha256Context context;
|
||||
SHA256_HASH hash;
|
||||
bool success = true;
|
||||
|
||||
for( i=0; i<NUM_TEST_VECTORS; i++ )
|
||||
{
|
||||
Sha256Initialise( &context );
|
||||
len = (int) gTestVectors[i].PlainTextSize ? gTestVectors[i].PlainTextSize : (int)strlen( gTestVectors[i].PlainText );
|
||||
Sha256Update( &context, gTestVectors[i].PlainText, (uint32_t)len );
|
||||
Sha256Finalise( &context, &hash );
|
||||
|
||||
if( memcmp( &hash, &gTestVectors[i].Sha256Hash, sizeof(hash) ) == 0 )
|
||||
{
|
||||
// Test vector passed
|
||||
}
|
||||
else
|
||||
{
|
||||
printf( "TestSha256 - Test vector %u failed\n", i );
|
||||
success = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Check the vectors again, this time adding just 1 char at a time to the hash functions
|
||||
for( i=0; i<NUM_TEST_VECTORS; i++ )
|
||||
{
|
||||
Sha256Initialise( &context );
|
||||
len = (int) gTestVectors[i].PlainTextSize ? gTestVectors[i].PlainTextSize : (int)strlen( gTestVectors[i].PlainText );
|
||||
for( k=0; k<len; k++ )
|
||||
{
|
||||
Sha256Update( &context, &gTestVectors[i].PlainText[k], 1 );
|
||||
}
|
||||
Sha256Finalise( &context, &hash );
|
||||
|
||||
if( memcmp( &hash, &gTestVectors[i].Sha256Hash, sizeof(hash) ) == 0 )
|
||||
{
|
||||
// Test vector passed
|
||||
}
|
||||
else
|
||||
{
|
||||
printf( "TestSha256 - Test vector %u failed [byte by byte]\n", i );
|
||||
success = false;
|
||||
}
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// TestSha512
|
||||
//
|
||||
// Test SHA1 algorithm against test vectors
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
static
|
||||
bool
|
||||
TestSha512
|
||||
(
|
||||
void
|
||||
)
|
||||
{
|
||||
int i;
|
||||
int k;
|
||||
int len;
|
||||
Sha512Context context;
|
||||
SHA512_HASH hash;
|
||||
bool success = true;
|
||||
|
||||
for( i=0; i<NUM_TEST_VECTORS; i++ )
|
||||
{
|
||||
Sha512Initialise( &context );
|
||||
len = (int) gTestVectors[i].PlainTextSize ? gTestVectors[i].PlainTextSize : (int)strlen( gTestVectors[i].PlainText );
|
||||
Sha512Update( &context, gTestVectors[i].PlainText, (uint32_t)len );
|
||||
Sha512Finalise( &context, &hash );
|
||||
|
||||
if( memcmp( &hash, &gTestVectors[i].Sha512Hash, sizeof(hash) ) == 0 )
|
||||
{
|
||||
// Test vector passed
|
||||
}
|
||||
else
|
||||
{
|
||||
printf( "TestSha512 - Test vector %u failed\n", i );
|
||||
success = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Check the vectors again, this time adding just 1 char at a time to the hash functions
|
||||
for( i=0; i<NUM_TEST_VECTORS; i++ )
|
||||
{
|
||||
Sha512Initialise( &context );
|
||||
len = (int) gTestVectors[i].PlainTextSize ? gTestVectors[i].PlainTextSize : (int)strlen( gTestVectors[i].PlainText );
|
||||
for( k=0; k<len; k++ )
|
||||
{
|
||||
Sha512Update( &context, &gTestVectors[i].PlainText[k], 1 );
|
||||
}
|
||||
Sha512Finalise( &context, &hash );
|
||||
|
||||
if( memcmp( &hash, &gTestVectors[i].Sha512Hash, sizeof(hash) ) == 0 )
|
||||
{
|
||||
// Test vector passed
|
||||
}
|
||||
else
|
||||
{
|
||||
printf( "TestSha512 - Test vector %u failed [byte by byte]\n", i );
|
||||
success = false;
|
||||
}
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// TestRc4
|
||||
//
|
||||
// Test RC4 algorithm against test vectors
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
static
|
||||
bool
|
||||
TestRc4
|
||||
(
|
||||
void
|
||||
)
|
||||
{
|
||||
struct
|
||||
{
|
||||
char Key [100];
|
||||
int Drop;
|
||||
uint8_t Output [16];
|
||||
} TestVectors [] =
|
||||
{
|
||||
{ "Key", 0, {0xeb,0x9f,0x77,0x81,0xb7,0x34,0xca,0x72,0xa7,0x19,0x4a,0x28,0x67,0xb6,0x42,0x95} },
|
||||
{ "Wiki", 0, {0x60,0x44,0xdb,0x6d,0x41,0xb7,0xe8,0xe7,0xa4,0xd6,0xf9,0xfb,0xd4,0x42,0x83,0x54} },
|
||||
{ "Secret", 0, {0x04,0xd4,0x6b,0x05,0x3c,0xa8,0x7b,0x59,0x41,0x72,0x30,0x2a,0xec,0x9b,0xb9,0x92} },
|
||||
{ "Key", 1, {0x9f,0x77,0x81,0xb7,0x34,0xca,0x72,0xa7,0x19,0x4a,0x28,0x67,0xb6,0x42,0x95,0x0d} },
|
||||
{ "Key", 256, {0x92,0xfd,0xd9,0xb6,0xe4,0x04,0xef,0x4f,0xa0,0x75,0xf1,0xa3,0x44,0xed,0x81,0x6b} },
|
||||
};
|
||||
|
||||
Rc4Context context;
|
||||
uint8_t output [16];
|
||||
int i;
|
||||
bool success = true;
|
||||
|
||||
for( i=0; i<(sizeof(TestVectors)/sizeof(TestVectors[0])); i++ )
|
||||
{
|
||||
Rc4Initialise( &context, TestVectors[i].Key, (uint8_t)strlen(TestVectors[i].Key), TestVectors[i].Drop );
|
||||
Rc4Output( &context, output, sizeof(output) );
|
||||
if( memcmp( output, TestVectors[i].Output, sizeof(output) ) != 0 )
|
||||
{
|
||||
printf( "TestRc4 - Failed test vector: %u\n", i );
|
||||
success = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Test by doing drop manually
|
||||
for( i=0; i<(sizeof(TestVectors)/sizeof(TestVectors[0])); i++ )
|
||||
{
|
||||
int x;
|
||||
|
||||
Rc4Initialise( &context, TestVectors[i].Key, (uint8_t)strlen(TestVectors[i].Key), 0 );
|
||||
for( x=0; x<TestVectors[i].Drop; x++ )
|
||||
{
|
||||
Rc4Output( &context, output, 1 );
|
||||
}
|
||||
Rc4Output( &context, output, sizeof(output) );
|
||||
if( memcmp( output, TestVectors[i].Output, sizeof(output) ) != 0 )
|
||||
{
|
||||
printf( "TestRc4 - Failed test vector: %u [manual drop]\n", i );
|
||||
success = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// FUNCTIONS
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// main
|
||||
//
|
||||
// Program entry point
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
int
|
||||
main
|
||||
(
|
||||
void
|
||||
)
|
||||
{
|
||||
bool success;
|
||||
bool allSuccess = true;
|
||||
|
||||
printf(
|
||||
"CryptLibTest\n"
|
||||
"------------\n"
|
||||
"\n" );
|
||||
|
||||
success = TestMd5( );
|
||||
if( !success ) { allSuccess = false; }
|
||||
printf( "Test MD5 - %s\n", success?"Pass":"Fail" );
|
||||
|
||||
success = TestSha1( );
|
||||
if( !success ) { allSuccess = false; }
|
||||
printf( "Test SHA1 - %s\n", success?"Pass":"Fail" );
|
||||
|
||||
success = TestSha256( );
|
||||
if( !success ) { allSuccess = false; }
|
||||
printf( "Test SHA256 - %s\n", success?"Pass":"Fail" );
|
||||
|
||||
success = TestSha512( );
|
||||
if( !success ) { allSuccess = false; }
|
||||
printf( "Test SHA512 - %s\n", success?"Pass":"Fail" );
|
||||
|
||||
success = TestRc4( );
|
||||
if( !success ) { allSuccess = false; }
|
||||
printf( "Test RC4 - %s\n", success?"Pass":"Fail" );
|
||||
|
||||
printf( "\n" );
|
||||
if( allSuccess )
|
||||
{
|
||||
printf( "All tests passed.\n" );
|
||||
}
|
||||
else
|
||||
{
|
||||
printf( "Fail.\n" );
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
62
projects/Md5String/Md5String.c
Normal file
62
projects/Md5String/Md5String.c
Normal file
@@ -0,0 +1,62 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Md5String
|
||||
//
|
||||
// Outputs MD5 hash of a string specified on command line. Hash is output in hex
|
||||
//
|
||||
// This is free and unencumbered software released into the public domain - June 2013 waterjuice.org
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// IMPORTS
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include "LibMd5.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// FUNCTIONS
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// main
|
||||
//
|
||||
// Program entry point
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
int
|
||||
main
|
||||
(
|
||||
int ArgC,
|
||||
char** ArgV
|
||||
)
|
||||
{
|
||||
char* string;
|
||||
Md5Context md5Context;
|
||||
MD5_HASH md5Hash;
|
||||
uint16_t i;
|
||||
|
||||
if( 2 != ArgC )
|
||||
{
|
||||
printf(
|
||||
"Syntax\n"
|
||||
" Md5String <String>\n" );
|
||||
return 1;
|
||||
}
|
||||
|
||||
string = ArgV[1];
|
||||
|
||||
Md5Initialise( &md5Context );
|
||||
Md5Update( &md5Context, string, (uint32_t)strlen(string) );
|
||||
Md5Finalise( &md5Context, &md5Hash );
|
||||
|
||||
for( i=0; i<sizeof(md5Hash); i++ )
|
||||
{
|
||||
printf( "0x%2.2x,", md5Hash.bytes[i] );
|
||||
}
|
||||
printf( "\n" );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
93
projects/Rc4Output/Rc4Output.c
Normal file
93
projects/Rc4Output/Rc4Output.c
Normal file
@@ -0,0 +1,93 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Rc4String
|
||||
//
|
||||
// Outputs bytes from an RC4 stream. Key is taken from command line. Bytes are output as hex
|
||||
//
|
||||
// This is free and unencumbered software released into the public domain - June 2013 waterjuice.org
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// IMPORTS
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include "LibRc4.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// DEFINITIONS
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __min
|
||||
#define __min( x, y ) (((x) < (y))?(x):(y))
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// CONSTANTS
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define BUFFER_SIZE 1024
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// FUNCTIONS
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// main
|
||||
//
|
||||
// Program entry point
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
int
|
||||
main
|
||||
(
|
||||
int ArgC,
|
||||
char** ArgV
|
||||
)
|
||||
{
|
||||
char* string;
|
||||
uint32_t numBytes;
|
||||
uint32_t i;
|
||||
uint8_t buffer [BUFFER_SIZE];
|
||||
uint32_t amountLeft;
|
||||
uint32_t chunk;
|
||||
Rc4Context rc4 = {0};
|
||||
uint32_t dropN = 0;
|
||||
|
||||
if( 3 != ArgC && 4 != ArgC )
|
||||
{
|
||||
printf(
|
||||
"Syntax\n"
|
||||
" Rc4Output <Key> <NumBytes> [DropN]\n" );
|
||||
return 1;
|
||||
}
|
||||
|
||||
string = ArgV[1];
|
||||
numBytes = atoi( ArgV[2] );
|
||||
if( 4 == ArgC )
|
||||
{
|
||||
dropN = atoi( ArgV[3] );
|
||||
}
|
||||
|
||||
Rc4Initialise( &rc4, string, (uint32_t)strlen(string), dropN );
|
||||
|
||||
|
||||
amountLeft = numBytes;
|
||||
while( amountLeft > 0 )
|
||||
{
|
||||
chunk = __min( amountLeft, BUFFER_SIZE );
|
||||
Rc4Output( &rc4, buffer, chunk );
|
||||
amountLeft -= chunk;
|
||||
|
||||
for( i=0; i<chunk; i++ )
|
||||
{
|
||||
printf( "%2.2x", buffer[i] );
|
||||
}
|
||||
}
|
||||
|
||||
printf( "\n" );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
62
projects/Sha1String/Sha1String.c
Normal file
62
projects/Sha1String/Sha1String.c
Normal file
@@ -0,0 +1,62 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Sha1String
|
||||
//
|
||||
// Outputs SHA1 hash of a string specified on command line. Hash is output in hex
|
||||
//
|
||||
// This is free and unencumbered software released into the public domain - June 2013 waterjuice.org
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// IMPORTS
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include "LibSha1.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// FUNCTIONS
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// main
|
||||
//
|
||||
// Program entry point
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
int
|
||||
main
|
||||
(
|
||||
int ArgC,
|
||||
char** ArgV
|
||||
)
|
||||
{
|
||||
char* string;
|
||||
Sha1Context sha1Context;
|
||||
SHA1_HASH sha1Hash;
|
||||
uint16_t i;
|
||||
|
||||
if( 2 != ArgC )
|
||||
{
|
||||
printf(
|
||||
"Syntax\n"
|
||||
" Sha1String <String>\n" );
|
||||
return 1;
|
||||
}
|
||||
|
||||
string = ArgV[1];
|
||||
|
||||
Sha1Initialise( &sha1Context );
|
||||
Sha1Update( &sha1Context, string, (uint32_t)strlen(string) );
|
||||
Sha1Finalise( &sha1Context, &sha1Hash );
|
||||
|
||||
for( i=0; i<sizeof(sha1Hash); i++ )
|
||||
{
|
||||
printf( "%2.2x", sha1Hash.bytes[i] );
|
||||
}
|
||||
printf( "\n" );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
62
projects/Sha256String/Sha256String.c
Normal file
62
projects/Sha256String/Sha256String.c
Normal file
@@ -0,0 +1,62 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Sha256String
|
||||
//
|
||||
// Outputs SHA256 hash of a string specified on command line. Hash is output in hex
|
||||
//
|
||||
// This is free and unencumbered software released into the public domain - June 2013 waterjuice.org
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// IMPORTS
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include "LibSha256.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// FUNCTIONS
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// main
|
||||
//
|
||||
// Program entry point
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
int
|
||||
main
|
||||
(
|
||||
int ArgC,
|
||||
char** ArgV
|
||||
)
|
||||
{
|
||||
char* string;
|
||||
Sha256Context sha256Context;
|
||||
SHA256_HASH sha256Hash;
|
||||
uint16_t i;
|
||||
|
||||
if( 2 != ArgC )
|
||||
{
|
||||
printf(
|
||||
"Syntax\n"
|
||||
" Sha256String <String>\n" );
|
||||
return 1;
|
||||
}
|
||||
|
||||
string = ArgV[1];
|
||||
|
||||
Sha256Initialise( &sha256Context );
|
||||
Sha256Update( &sha256Context, (unsigned char*)string, (uint32_t)strlen(string) );
|
||||
Sha256Finalise( &sha256Context, &sha256Hash );
|
||||
|
||||
for( i=0; i<sizeof(sha256Hash); i++ )
|
||||
{
|
||||
printf( "%2.2x", sha256Hash.bytes[i] );
|
||||
}
|
||||
printf( "\n" );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
62
projects/Sha512String/Sha512String.c
Normal file
62
projects/Sha512String/Sha512String.c
Normal file
@@ -0,0 +1,62 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Sha512String
|
||||
//
|
||||
// Outputs SHA512 hash of a string specified on command line. Hash is output in hex
|
||||
//
|
||||
// This is free and unencumbered software released into the public domain - June 2013 waterjuice.org
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// IMPORTS
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include "LibSha512.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// FUNCTIONS
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// main
|
||||
//
|
||||
// Program entry point
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
int
|
||||
main
|
||||
(
|
||||
int ArgC,
|
||||
char** ArgV
|
||||
)
|
||||
{
|
||||
char* string;
|
||||
Sha512Context sha512Context;
|
||||
SHA512_HASH sha512Hash;
|
||||
uint16_t i;
|
||||
|
||||
if( 2 != ArgC )
|
||||
{
|
||||
printf(
|
||||
"Syntax\n"
|
||||
" Sha512String <String>\n" );
|
||||
return 1;
|
||||
}
|
||||
|
||||
string = ArgV[1];
|
||||
|
||||
Sha512Initialise( &sha512Context );
|
||||
Sha512Update( &sha512Context, string, (uint32_t)strlen(string) );
|
||||
Sha512Finalise( &sha512Context, &sha512Hash );
|
||||
|
||||
for( i=0; i<sizeof(sha512Hash); i++ )
|
||||
{
|
||||
printf( "%2.2x", sha512Hash.bytes[i] );
|
||||
}
|
||||
printf( "\n" );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
27
stdbool/stdbool.h
Normal file
27
stdbool/stdbool.h
Normal file
@@ -0,0 +1,27 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// <stdbool.h>
|
||||
//
|
||||
// stdbool.h is part of the C99 standard. Unforunately MSVC compiler does not support C99. Although it has several
|
||||
// types such as stdint.h, it does not include stdbool.h. This file defines the type bool and values true and false
|
||||
// according to the C99 standard. This only needs to be included on systems such as MSVC that do not have stdbool.h
|
||||
// gcc has its own version of stdbool.h that should be used in preference.
|
||||
//
|
||||
// This is free and unencumbered software released into the public domain - June 2013 waterjuice.org
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _STDBOOL_H_
|
||||
#define _STDBOOL_H_
|
||||
|
||||
#ifndef __cplusplus
|
||||
#ifndef __bool_true_false_are_defined
|
||||
|
||||
typedef int bool;
|
||||
#define true 1
|
||||
#define false 0
|
||||
|
||||
#define __bool_true_false_are_defined
|
||||
|
||||
#endif //__bool_true_false_are_defined
|
||||
#endif //__cplusplus
|
||||
|
||||
#endif //_STDBOOL_H_
|
||||
Reference in New Issue
Block a user