Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • car/libdap-crypto
1 result
Show changes
Commits on Source (64)
Showing
with 3670 additions and 64 deletions
......@@ -3,15 +3,7 @@ project (dap_crypto)
# fix implicit declaration warnings
add_definitions ("-D_GNU_SOURCE")
#set(CMAKE_C_FLAGS "-std=c11 -O2 -Wall -Wextra -fPIC -fno-pie -no-pie -fno-ident ")
#set(CMAKE_ASM_FLAGS "-std=c11 -O2 -Wall -Wextra -fPIC -fno-pie -no-pie -fno-ident ")
#set(CMAKE_C_FLAGS "-std=c11 -O3 -Wall -Wextra -fPIC -fno-pie -no-pie -fno-ident -ffast-math -ftree-vectorize -mfpmath=sse -mmmx -msse2 -fno-asynchronous-unwind-tables -ffunction-sections -Wl,--gc-sections -Wl,--strip-all")
#set(CMAKE_ASM_FLAGS "-std=c11 -O3 -Wall -Wextra -fPIC -fno-pie -no-pie -fno-ident -ffast-math -ftree-vectorize -mfpmath=sse -mmmx -msse2 -fno-asynchronous-unwind-tables -ffunction-sections -Wl,--gc-sections -Wl,--strip-all")
#set(CMAKE_C_FLAGS "-static -Wall -O3 -fno-ident -ffast-math -ftree-vectorize -mfpmath=sse -mmmx -msse2 -fno-asynchronous-unwind-tables -ffunction-sections -Wl,--gc-sections -Wl,--strip-all")
#set(CMAKE_ASM_FLAGS "-static -Wall -O3 -fno-ident -ffast-math -ftree-vectorize -mfpmath=sse -mmmx -msse2 -fno-asynchronous-unwind-tables -ffunction-sections -Wl,--gc-sections -Wl,--strip-all")
if(NOT (${SUBMODULES_NO_BUILD} MATCHES ON))
if(NOT SUBMODULES_NO_BUILD)
# Check whether we're on a 32-bit or 64-bit system
if(CMAKE_SIZEOF_VOID_P EQUAL "8")
......@@ -21,8 +13,6 @@ if(NOT (${SUBMODULES_NO_BUILD} MATCHES ON))
endif()
option(BUILD_64 "Build for 64-bit? 'OFF' builds for 32-bit." ${DEFAULT_BUILD_64})
add_definitions ("-DDAP_SERVER")
add_definitions ("-DNODE_NETNAME=\"cellframe\"")
set(_CCOPT "-Wall -O2 -pg -fPIC -fno-pie -no-pie")
set(_LOPT "-pg")
......@@ -35,40 +25,50 @@ if(NOT (${SUBMODULES_NO_BUILD} MATCHES ON))
endif()
endif()
file( GLOB CRYPTO_SRCS
src/*.c
src/rand/*.c
src/iaes/*.c
src/oaes/*.c
src/sha3/*.c
src/msrln/*.c
src/defeo_scheme/*.c
src/sig_bliss/*.c
src/sig_tesla/*.c
file( GLOB CRYPTO_SRCS
src/*.c
src/rand/*.c
src/iaes/*.c
src/oaes/*.c
src/blowfish/*.c
src/GOST/*.c
src/salsa2012/*.c
src/seed/*.c
src/sha3/*.c
src/msrln/*.c
src/defeo_scheme/*.c
src/sig_bliss/*.c
src/sig_tesla/*.c
src/sig_picnic/*.c
src/sig_dilithium/*.c
src/ringct20/*.c
)
file( GLOB CRYPTO_HEADERS
src/*.h
src/rand/*.h
src/iaes/*.h
src/oaes/*.h
src/sha3/*.h
src/msrln/*.h
src/defeo_scheme/*.h
src/sig_bliss/*.h
src/sig_tesla/*.h
src/sig_picnic/*.h
file( GLOB CRYPTO_HEADERS
src/*.h
src/rand/*.h
src/iaes/*.h
src/oaes/*.h
src/blowfish/*.h
src/GOST/*.h
src/salsa2012/*.h
src/seed/*.h
src/sha3/*.h
src/msrln/*.h
src/defeo_scheme/*.h
src/sig_bliss/*.h
src/sig_tesla/*.h
src/sig_picnic/*.h
src/sig_dilithium/*.h
src/ringct20/*.h
include/*.h
)
enable_language(ASM)
file( GLOB XKCP_SRCS
src/XKCP/lib/high/Keccak/FIPS202/KeccakHash.c
src/XKCP/lib/high/Keccak/KeccakSpongeWidth1600.c
file( GLOB XKCP_SRCS
#src/XKCP/lib/high/Keccak/FIPS202/KeccakHash.c
#src/XKCP/lib/high/Keccak/KeccakSpongeWidth1600.c
src/XKCP/lib/high/Keccak/SP800-185/SP800-185.c
src/XKCP/lib/high/Keccak/FIPS202/SimpleFIPS202.c
)
......@@ -278,6 +278,7 @@ if(UNIX)
target_link_libraries(dap_crypto dap_core m)
endif()
if(BUILD_CRYPTO_TESTS)
enable_testing()
add_subdirectory(test)
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.11.2, 2020-04-29T10:52:27. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
<value type="QByteArray">{11b3ace2-edb6-4ae7-8e1b-fce9fa91893f}</value>
</data>
<data>
<variable>ProjectExplorer.Project.ActiveTarget</variable>
<value type="int">0</value>
</data>
<data>
<variable>ProjectExplorer.Project.EditorSettings</variable>
<valuemap type="QVariantMap">
<value type="bool" key="EditorConfiguration.AutoIndent">true</value>
<value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
<value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
<value type="QString" key="language">Cpp</value>
<valuemap type="QVariantMap" key="value">
<value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
</valuemap>
</valuemap>
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
<value type="QString" key="language">QmlJS</value>
<valuemap type="QVariantMap" key="value">
<value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
</valuemap>
</valuemap>
<value type="int" key="EditorConfiguration.CodeStyle.Count">2</value>
<value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
<value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
<value type="int" key="EditorConfiguration.IndentSize">4</value>
<value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
<value type="int" key="EditorConfiguration.MarginColumn">80</value>
<value type="bool" key="EditorConfiguration.MouseHiding">true</value>
<value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
<value type="int" key="EditorConfiguration.PaddingMode">1</value>
<value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
<value type="bool" key="EditorConfiguration.ShowMargin">false</value>
<value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
<value type="bool" key="EditorConfiguration.SmartSelectionChanging">true</value>
<value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
<value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
<value type="int" key="EditorConfiguration.TabSize">8</value>
<value type="bool" key="EditorConfiguration.UseGlobal">true</value>
<value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
<value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
<value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
<value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
<value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.PluginSettings</variable>
<valuemap type="QVariantMap">
<valuelist type="QVariantList" key="ClangCodeModel.CustomCommandLineKey">
<value type="QString">-fno-delayed-template-parsing</value>
</valuelist>
<value type="bool" key="ClangCodeModel.UseGlobalConfig">true</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.Target.0</variable>
<valuemap type="QVariantMap">
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 5.14.2 MinGW 32-bit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 5.14.2 MinGW 32-bit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">qt.qt5.5142.win32_mingw73_kit</value>
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
<valuelist type="QVariantList" key="CMake.Configuration">
<value type="QString">BUILD_CRYPTO_TESTS:BOOL=ON</value>
<value type="QString">CMAKE_BUILD_TYPE:STRING=Debug</value>
<value type="QString">CMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx}</value>
<value type="QString">CMAKE_C_COMPILER:STRING=%{Compiler:Executable:C}</value>
<value type="QString">CMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX}</value>
<value type="QString">QT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable}</value>
</valuelist>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:/qt_proj/build-libdap-crypto_new-Desktop_Qt_5_14_2_MinGW_32_bit-Debug</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="QString" key="CMakeProjectManager.MakeStep.AdditionalArguments"></value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
<value type="QString">all</value>
</valuelist>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="QString" key="CMakeProjectManager.MakeStep.AdditionalArguments"></value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
<value type="QString">clean</value>
</valuelist>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Debug</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeBuildConfiguration</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
<valuelist type="QVariantList" key="CMake.Configuration">
<value type="QString">CMAKE_BUILD_TYPE:STRING=Release</value>
<value type="QString">CMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx}</value>
<value type="QString">CMAKE_C_COMPILER:STRING=%{Compiler:Executable:C}</value>
<value type="QString">CMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX}</value>
<value type="QString">QT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable}</value>
</valuelist>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:/qt_proj/build-libdap-crypto_new-Desktop_Qt_5_14_2_MinGW_32_bit-Release</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="QString" key="CMakeProjectManager.MakeStep.AdditionalArguments"></value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
<value type="QString">all</value>
</valuelist>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="QString" key="CMakeProjectManager.MakeStep.AdditionalArguments"></value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
<value type="QString">clean</value>
</valuelist>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Release</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeBuildConfiguration</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.2">
<valuelist type="QVariantList" key="CMake.Configuration">
<value type="QString">CMAKE_BUILD_TYPE:STRING=RelWithDebInfo</value>
<value type="QString">CMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx}</value>
<value type="QString">CMAKE_C_COMPILER:STRING=%{Compiler:Executable:C}</value>
<value type="QString">CMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX}</value>
<value type="QString">QT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable}</value>
</valuelist>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:/qt_proj/build-libdap-crypto_new-Desktop_Qt_5_14_2_MinGW_32_bit-RelWithDebInfo</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="QString" key="CMakeProjectManager.MakeStep.AdditionalArguments"></value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
<value type="QString">all</value>
</valuelist>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="QString" key="CMakeProjectManager.MakeStep.AdditionalArguments"></value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
<value type="QString">clean</value>
</valuelist>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Release with Debug Information</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeBuildConfiguration</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.3">
<valuelist type="QVariantList" key="CMake.Configuration">
<value type="QString">CMAKE_BUILD_TYPE:STRING=MinSizeRel</value>
<value type="QString">CMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx}</value>
<value type="QString">CMAKE_C_COMPILER:STRING=%{Compiler:Executable:C}</value>
<value type="QString">CMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX}</value>
<value type="QString">QT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable}</value>
</valuelist>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:/qt_proj/build-libdap-crypto_new-Desktop_Qt_5_14_2_MinGW_32_bit-MinSizeRel</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="QString" key="CMakeProjectManager.MakeStep.AdditionalArguments"></value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
<value type="QString">all</value>
</valuelist>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="QString" key="CMakeProjectManager.MakeStep.AdditionalArguments"></value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
<value type="QString">clean</value>
</valuelist>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Minimum Size Release</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeBuildConfiguration</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">4</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Deploy</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
<value type="QString" key="Analyzer.Perf.CallgraphMode">dwarf</value>
<valuelist type="QVariantList" key="Analyzer.Perf.Events">
<value type="QString">cpu-cycles</value>
</valuelist>
<valuelist type="QVariantList" key="Analyzer.Perf.ExtraArguments"/>
<value type="int" key="Analyzer.Perf.Frequency">250</value>
<valuelist type="QVariantList" key="Analyzer.Perf.RecordArguments">
<value type="QString">-e</value>
<value type="QString">cpu-cycles</value>
<value type="QString">--call-graph</value>
<value type="QString">dwarf,4096</value>
<value type="QString">-F</value>
<value type="QString">250</value>
</valuelist>
<value type="QString" key="Analyzer.Perf.SampleMode">-F</value>
<value type="bool" key="Analyzer.Perf.Settings.UseGlobalSettings">true</value>
<value type="int" key="Analyzer.Perf.StackSize">4096</value>
<value type="bool" key="Analyzer.QmlProfiler.AggregateTraces">false</value>
<value type="bool" key="Analyzer.QmlProfiler.FlushEnabled">false</value>
<value type="uint" key="Analyzer.QmlProfiler.FlushInterval">1000</value>
<value type="QString" key="Analyzer.QmlProfiler.LastTraceFile"></value>
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
<valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
<value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
<value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
<value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
<value type="QString" key="Analyzer.Valgrind.KCachegrindExecutable">kcachegrind</value>
<value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value>
<value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
<valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
<value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value>
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
<value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value>
<value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
<value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
<valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
<value type="int">0</value>
<value type="int">1</value>
<value type="int">2</value>
<value type="int">3</value>
<value type="int">4</value>
<value type="int">5</value>
<value type="int">6</value>
<value type="int">7</value>
<value type="int">8</value>
<value type="int">9</value>
<value type="int">10</value>
<value type="int">11</value>
<value type="int">12</value>
<value type="int">13</value>
<value type="int">14</value>
</valuelist>
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">crypto-test</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeRunConfiguration.crypto-test</value>
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey">crypto-test</value>
<value type="QString" key="RunConfiguration.Arguments"></value>
<value type="bool" key="RunConfiguration.Arguments.multi">false</value>
<value type="QString" key="RunConfiguration.OverrideDebuggerStartup"></value>
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
<value type="bool" key="RunConfiguration.UseLibrarySearchPath">true</value>
<value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
<value type="QString" key="RunConfiguration.WorkingDirectory"></value>
<value type="QString" key="RunConfiguration.WorkingDirectory.default"></value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.1">
<value type="QString" key="Analyzer.Perf.CallgraphMode">dwarf</value>
<valuelist type="QVariantList" key="Analyzer.Perf.Events">
<value type="QString">cpu-cycles</value>
</valuelist>
<valuelist type="QVariantList" key="Analyzer.Perf.ExtraArguments"/>
<value type="int" key="Analyzer.Perf.Frequency">250</value>
<valuelist type="QVariantList" key="Analyzer.Perf.RecordArguments">
<value type="QString">-e</value>
<value type="QString">cpu-cycles</value>
<value type="QString">--call-graph</value>
<value type="QString">dwarf,4096</value>
<value type="QString">-F</value>
<value type="QString">250</value>
</valuelist>
<value type="QString" key="Analyzer.Perf.SampleMode">-F</value>
<value type="bool" key="Analyzer.Perf.Settings.UseGlobalSettings">true</value>
<value type="int" key="Analyzer.Perf.StackSize">4096</value>
<value type="bool" key="Analyzer.QmlProfiler.AggregateTraces">false</value>
<value type="bool" key="Analyzer.QmlProfiler.FlushEnabled">false</value>
<value type="uint" key="Analyzer.QmlProfiler.FlushInterval">1000</value>
<value type="QString" key="Analyzer.QmlProfiler.LastTraceFile"></value>
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
<valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
<value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
<value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
<value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
<value type="QString" key="Analyzer.Valgrind.KCachegrindExecutable">kcachegrind</value>
<value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value>
<value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
<valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
<value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value>
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
<value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value>
<value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
<value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
<valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
<value type="int">0</value>
<value type="int">1</value>
<value type="int">2</value>
<value type="int">3</value>
<value type="int">4</value>
<value type="int">5</value>
<value type="int">6</value>
<value type="int">7</value>
<value type="int">8</value>
<value type="int">9</value>
<value type="int">10</value>
<value type="int">11</value>
<value type="int">12</value>
<value type="int">13</value>
<value type="int">14</value>
</valuelist>
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">crypto_cert_test</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeRunConfiguration.crypto_cert_test</value>
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey">crypto_cert_test</value>
<value type="QString" key="RunConfiguration.Arguments"></value>
<value type="bool" key="RunConfiguration.Arguments.multi">false</value>
<value type="QString" key="RunConfiguration.OverrideDebuggerStartup"></value>
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
<value type="bool" key="RunConfiguration.UseLibrarySearchPath">true</value>
<value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
<value type="QString" key="RunConfiguration.WorkingDirectory"></value>
<value type="QString" key="RunConfiguration.WorkingDirectory.default"></value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">2</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.TargetCount</variable>
<value type="int">1</value>
</data>
<data>
<variable>ProjectExplorer.Project.Updater.FileVersion</variable>
<value type="int">22</value>
</data>
<data>
<variable>Version</variable>
<value type="int">22</value>
</data>
</qtcreator>
......@@ -59,6 +59,7 @@ dap_cert_t * dap_cert_generate_mem(const char * a_cert_name, dap_enc_key_type_t
dap_cert_t * dap_cert_add_file(const char * a_cert_name,const char *a_folder_path);
int dap_cert_save_to_folder(dap_cert_t * a_cert, const char *a_file_dir_path);
const char* dap_cert_get_folder(int a_n_folder_path);
void dap_cert_add_folder(const char *a_folder_path);
void dap_cert_dump(dap_cert_t * a_cert);
dap_pkey_t * dap_cert_to_pkey(dap_cert_t * a_cert);
......
#ifndef _DAP_ENC_GOST_H_
#define _DAP_ENC_GOST_H_
#include <stddef.h>
#include "dap_enc_key.h"
#include "GOST/block_chipher.h"
#ifdef __cplusplus
extern "C" {
#endif
void dap_enc_gost_key_delete(struct dap_enc_key *a_key);
void dap_enc_gost_key_generate(struct dap_enc_key * a_key, const void *kex_buf,
size_t kex_size, const void * seed, size_t seed_size, size_t key_size);
//------GOST_OFB---------
void dap_enc_gost_ofb_key_new(struct dap_enc_key * a_key);
size_t dap_enc_gost_ofb_calc_decode_size(const size_t size_in);
size_t dap_enc_gost_ofb_calc_encode_size(const size_t size_in);
size_t dap_enc_gost_ofb_decrypt(struct dap_enc_key * a_key, const void * a_in, size_t a_in_size, void ** a_out);
size_t dap_enc_gost_ofb_encrypt(struct dap_enc_key * a_key, const void * a_in, size_t a_in_size, void ** a_out);
// Writes result ( out ) in already allocated buffer
size_t dap_enc_gost_ofb_decrypt_fast(struct dap_enc_key * a_key, const void * a_in,
size_t a_in_size, void * buf_out, size_t buf_out_size);
// Writes result ( out ) in already allocated buffer
size_t dap_enc_gost_ofb_encrypt_fast(struct dap_enc_key * a_key, const void * a_in,
size_t a_in_size, void * buf_out, size_t buf_out_size);
//------KUZNECHIK_OFB--------------
void dap_enc_kuzn_ofb_key_new(struct dap_enc_key * a_key);
size_t dap_enc_kuzn_ofb_calc_decode_size(const size_t size_in);
size_t dap_enc_kuzn_ofb_calc_encode_size(const size_t size_in);
size_t dap_enc_kuzn_ofb_decrypt(struct dap_enc_key * a_key, const void * a_in, size_t a_in_size, void ** a_out);
size_t dap_enc_kuzn_ofb_encrypt(struct dap_enc_key * a_key, const void * a_in, size_t a_in_size, void ** a_out);
// Writes result ( out ) in already allocated buffer
size_t dap_enc_kuzn_ofb_decrypt_fast(struct dap_enc_key * a_key, const void * a_in,
size_t a_in_size, void * buf_out, size_t buf_out_size);
// Writes result ( out ) in already allocated buffer
size_t dap_enc_kuzn_ofb_encrypt_fast(struct dap_enc_key * a_key, const void * a_in,
size_t a_in_size, void * buf_out, size_t buf_out_size);
#ifdef __cplusplus
}
#endif
#endif
......@@ -22,8 +22,8 @@
along with any DAP based project. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _DAP_ENC_BASE64_H_
#define _DAP_ENC_BASE64_H_
#ifndef _DAP_ENC_BASE58_H_
#define _DAP_ENC_BASE58_H_
#include <stddef.h>
#include <stdint.h>
#include "dap_enc_key.h"
......
#ifndef _DAP_ENC_BF_H_
#define _DAP_ENC_BF_H_
#include <stddef.h>
#include "dap_enc_key.h"
#include"blowfish/blowfish.h"
#ifdef __cplusplus
extern "C" {
#endif
void dap_enc_bf_key_delete(struct dap_enc_key *a_key);
void dap_enc_bf_key_generate(struct dap_enc_key * a_key, const void *kex_buf,
size_t kex_size, const void * seed, size_t seed_size, size_t key_size);
//-----CBC----------
void dap_enc_bf_cbc_key_new(struct dap_enc_key * a_key);
size_t dap_enc_bf_cbc_calc_decode_size(const size_t size_in);
size_t dap_enc_bf_cbc_calc_encode_size(const size_t size_in);
size_t dap_enc_bf_cbc_decrypt(struct dap_enc_key * a_key, const void * a_in, size_t a_in_size, void ** a_out);
size_t dap_enc_bf_cbc_encrypt(struct dap_enc_key * a_key, const void * a_in, size_t a_in_size, void ** a_out);
// Writes result ( out ) in already allocated buffer
size_t dap_enc_bf_cbc_decrypt_fast(struct dap_enc_key * a_key, const void * a_in,
size_t a_in_size, void * buf_out, size_t buf_out_size);
// Writes result ( out ) in already allocated buffer
size_t dap_enc_bf_cbc_encrypt_fast(struct dap_enc_key * a_key, const void * a_in,
size_t a_in_size, void * buf_out, size_t buf_out_size);
//------OFB---------
void dap_enc_bf_ofb_key_new(struct dap_enc_key * a_key);
size_t dap_enc_bf_ofb_calc_decode_size(const size_t size_in);
size_t dap_enc_bf_ofb_calc_encode_size(const size_t size_in);
size_t dap_enc_bf_ofb_decrypt(struct dap_enc_key * a_key, const void * a_in, size_t a_in_size, void ** a_out);
size_t dap_enc_bf_ofb_encrypt(struct dap_enc_key * a_key, const void * a_in, size_t a_in_size, void ** a_out);
// Writes result ( out ) in already allocated buffer
size_t dap_enc_bf_ofb_decrypt_fast(struct dap_enc_key * a_key, const void * a_in,
size_t a_in_size, void * buf_out, size_t buf_out_size);
// Writes result ( out ) in already allocated buffer
size_t dap_enc_bf_ofb_encrypt_fast(struct dap_enc_key * a_key, const void * a_in,
size_t a_in_size, void * buf_out, size_t buf_out_size);
#ifdef __cplusplus
}
#endif
#endif
......@@ -28,10 +28,10 @@ int dap_enc_sig_bliss_key_pub_output(struct dap_enc_key *l_key, void * l_output)
uint8_t* dap_enc_sig_bliss_write_signature(bliss_signature_t* a_sign, size_t *a_sign_out);
bliss_signature_t* dap_enc_sig_bliss_read_signature(uint8_t *a_buf, size_t a_buflen);
bliss_signature_t* dap_enc_sig_bliss_read_signature(const uint8_t *a_buf, size_t a_buflen);
uint8_t* dap_enc_sig_bliss_write_private_key(const bliss_private_key_t* a_private_key, size_t *a_buflen_out);
uint8_t* dap_enc_sig_bliss_write_public_key(const bliss_public_key_t* a_public_key, size_t *a_buflen_out);
bliss_private_key_t* dap_enc_sig_bliss_read_private_key(uint8_t *a_buf, size_t a_buflen);
bliss_private_key_t* dap_enc_sig_bliss_read_private_key(const uint8_t *a_buf, size_t a_buflen);
bliss_public_key_t* dap_enc_sig_bliss_read_public_key(const uint8_t *a_buf, size_t a_buflen);
......@@ -17,7 +17,7 @@ void dap_enc_aes_key_delete(struct dap_enc_key *a_key);
void dap_enc_aes_key_generate(struct dap_enc_key * a_key, const void *kex_buf, size_t kex_size,
const void * seed, size_t seed_size, size_t key_size);
size_t dap_enc_iaes256_calc_decode_size(const size_t size_in);
size_t dap_enc_iaes256_calc_decode_max_size(const size_t size_in);
size_t dap_enc_iaes256_calc_encode_size(const size_t size_in);
size_t dap_enc_iaes256_cbc_decrypt(struct dap_enc_key * a_key, const void * a_in, size_t a_in_size, void ** a_out);
......
......@@ -29,8 +29,7 @@
#include <stddef.h>
#include <time.h>
#include <stdint.h>
#include "dap_common.h"
typedef enum dap_enc_data_type{DAP_ENC_DATA_TYPE_RAW,
......@@ -42,10 +41,20 @@ typedef enum dap_enc_data_type{DAP_ENC_DATA_TYPE_RAW,
typedef enum dap_enc_key_type{ DAP_ENC_KEY_TYPE_IAES, // Symmetric AES
typedef enum dap_enc_key_type{
DAP_ENC_KEY_TYPE_IAES, // Symmetric AES
DAP_ENC_KEY_TYPE_OAES,// from https://github.com/monero-project/monero/tree/master/src/crypto
DAP_ENC_KEY_TYPE_BF_CBC,// BlowFish CBCmode
DAP_ENC_KEY_TYPE_BF_OFB,//BlowFish OFBmode
DAP_ENC_KEY_TYPE_GOST_OFB,//GOST28147_89
DAP_ENC_KEY_TYPE_KUZN_OFB,//GOST28147_14
DAP_ENC_KEY_TYPE_SALSA2012,//SALSA2012//http://www.ecrypt.eu.org/stream/salsa20pf.html//https://ianix.com/pub/salsa20-deployment.html
DAP_ENC_KEY_TYPE_RLWE_NEWHOPE, // "NewHope": key exchange from the ring learning with errors problem
// (Alkim, Ducas, Pöppelmann, Schwabe, USENIX Security 2016 )
// Using the reference C implementation of NewHope
......@@ -110,6 +119,8 @@ typedef enum dap_enc_key_type{ DAP_ENC_KEY_TYPE_IAES, // Symmetric AES
DAP_ENC_KEY_TYPE_SIG_DILITHIUM,
DAP_ENC_KEY_TYPE_SIG_RINGCT20,//ring signature for confidentional transaction
DAP_ENC_KEY_TYPE_NULL = 0
} dap_enc_key_type_t;
......@@ -134,6 +145,8 @@ typedef size_t (*dap_enc_callback_dataop_t)(struct dap_enc_key *key, const void
typedef size_t (*dap_enc_callback_dataop_na_t)(struct dap_enc_key *key, const void *in,
const size_t in_size,void * out, const size_t out_size_max);
typedef size_t (*dap_enc_callback_dataop_na_ext_t)(struct dap_enc_key *key, const void *in,
const size_t in_size,void * out, const size_t out_size_max, const void *extra_param, const int extra_param_len);
typedef int (*dap_enc_callback_sign_op_t)(struct dap_enc_key *key, const void *in,
const size_t in_size,void * out, const size_t out_size_max);
......@@ -162,7 +175,7 @@ typedef size_t (*dap_enc_gen_bob_shared_key) (struct dap_enc_key *b_key, const v
typedef size_t (*dap_enc_gen_alice_shared_key) (struct dap_enc_key *a_key, const void *a_priv,
size_t b_pub_size, unsigned char *b_pub);
typedef int (*dap_enc_callback_gen_key_public_t ) (struct dap_enc_key *l_key, void * l_output);
typedef int (*dap_enc_callback_gen_key_public_t ) (struct dap_enc_key *a_key, void * a_output);
typedef void (*dap_enc_callback_ptr_t)(struct dap_enc_key *, void *);
typedef size_t (*dap_enc_callback_pptr_r_size_t)(struct dap_enc_key *, void **);
......@@ -171,6 +184,7 @@ typedef void (*dap_enc_callback_size_t)(struct dap_enc_key *, size_t);
typedef void (*dap_enc_callback_str_t)(struct dap_enc_key *, const char*);
typedef char* (*dap_enc_callback_r_str_t)(struct dap_enc_key *);
typedef size_t (*dap_enc_callback_calc_out_size)(const size_t);
typedef size_t (*dap_enc_get_allpbk_list) (struct dap_enc_key *a_key, const void *allpbk_list, const int allpbk_num);
typedef struct dap_enc_key {
size_t priv_key_data_size;
......@@ -187,6 +201,7 @@ typedef struct dap_enc_key {
dap_enc_callback_dataop_t dec;
dap_enc_callback_dataop_na_t enc_na;
dap_enc_callback_dataop_na_t dec_na;
dap_enc_callback_dataop_na_ext_t dec_na_ext;
dap_enc_callback_sign_op_t sign_get;
dap_enc_callback_sign_op_t sign_verify;
......@@ -194,6 +209,11 @@ typedef struct dap_enc_key {
dap_enc_gen_alice_shared_key gen_alice_shared_key;
dap_enc_gen_bob_shared_key gen_bob_shared_key;
void *pbkListdata;
size_t pbkListsize;
dap_enc_get_allpbk_list getallpbkList;
void * _inheritor; // WARNING! Inheritor must have only serealizeble/deserializeble data (copy)
size_t _inheritor_size;
} dap_enc_key_t;
......@@ -221,7 +241,7 @@ extern "C" {
int dap_enc_key_init(void);
void dap_enc_key_deinit(void);
const char *dap_enc_get_type_name(dap_enc_key_type_t a_key_type);
size_t dap_enc_key_get_enc_size(dap_enc_key_t * a_key, const size_t buf_in_size);
size_t dap_enc_key_get_dec_size(dap_enc_key_t * a_key, const size_t buf_in_size);
......@@ -229,7 +249,7 @@ uint8_t* dap_enc_key_serealize_sign(dap_enc_key_type_t a_key_type, uint8_t *a_si
uint8_t* dap_enc_key_deserealize_sign(dap_enc_key_type_t a_key_type, uint8_t *a_sign, size_t *a_sign_len);
uint8_t* dap_enc_key_serealize_priv_key(dap_enc_key_t *a_key, size_t *a_buflen_out);
uint8_t* dap_enc_key_serealize_pub_key(dap_enc_key_t *a_key, size_t *a_buflen_out);
int dap_enc_key_deserealize_priv_key(dap_enc_key_t *a_key, uint8_t *a_buf, size_t a_buflen);
int dap_enc_key_deserealize_priv_key(dap_enc_key_t *a_key, const uint8_t *a_buf, size_t a_buflen);
int dap_enc_key_deserealize_pub_key(dap_enc_key_t *a_key, const uint8_t *a_buf, size_t a_buflen);
dap_enc_key_serealize_t* dap_enc_key_serealize(dap_enc_key_t * key);
......
#ifndef DAP_ENC_RINGCT20_H
#define DAP_ENC_RINGCT20_H
#include "ringct20/ringct20_params.h"
#include "dap_enc_key.h"
size_t CRUTCH_gen_pbk_list(const ringct20_param_t *p, void **pbklist, const int pbknum);
void dap_enc_sig_ringct20_set_type(DAP_RINGCT20_SIGN_SECURITY type);
void dap_enc_sig_ringct20_key_new(struct dap_enc_key *key);
void dap_enc_sig_ringct20_key_new_generate(struct dap_enc_key * key, const void *kex_buf,
size_t kex_size, const void * seed, size_t seed_size,
size_t key_size);
size_t dap_enc_sig_ringct20_get_sign_with_pb_list(struct dap_enc_key * key, const void * msg,
const size_t msg_size, void * signature, const size_t signature_size);
size_t dap_enc_sig_ringct20_verify_sign_with_pbk_list(struct dap_enc_key * key, const void * msg,
const size_t msg_size, void * signature, const size_t signature_size, const void *pbkList_buf, const int wpbkList);
size_t dap_enc_sig_ringct20_get_sign(struct dap_enc_key * key,const void * msg,
const size_t msg_size, void * signature, const size_t signature_size);
size_t dap_enc_sig_ringct20_verify_sign(struct dap_enc_key * key,const void * msg,
const size_t msg_size, void * signature, const size_t signature_size);
void dap_enc_sig_ringct20_key_delete(struct dap_enc_key * key);
size_t dap_enc_ringct20_calc_signature_size(void);
uint8_t* dap_enc_ringct20_write_signature(ringct20_signature_t* a_sign, size_t *a_sign_out);
ringct20_signature_t* dap_enc_ringct20_read_signature(uint8_t *a_buf, size_t a_buflen);
uint8_t* dap_enc_ringct20_write_private_key(const ringct20_private_key_t* a_private_key, size_t *a_buflen_out);
uint8_t* dap_enc_ringct20_write_public_key(const ringct20_public_key_t* a_public_key, size_t *a_buflen_out);
ringct20_private_key_t* dap_enc_ringct20_read_private_key(const uint8_t *a_buf, size_t a_buflen);
ringct20_public_key_t* dap_enc_ringct20_read_public_key(const uint8_t *a_buf, size_t a_buflen);
#endif // DAP_ENC_RINGCT20_H
#ifndef _DAP_ENC_SALSA2012_H_
#define _DAP_ENC_SALSA2012_H_
#include <stddef.h>
#include "dap_enc_key.h"
#include "salsa2012/crypto_stream_salsa2012.h"
#ifdef __cplusplus
extern "C" {
#endif
void dap_enc_salsa2012_key_delete(struct dap_enc_key *a_key);
void dap_enc_salsa2012_key_generate(struct dap_enc_key * a_key, const void *kex_buf,
size_t kex_size, const void * seed, size_t seed_size, size_t key_size);
//------salsa2012---------
void dap_enc_salsa2012_key_new(struct dap_enc_key * a_key);
size_t dap_enc_salsa2012_calc_decode_size(const size_t size_in);
size_t dap_enc_salsa2012_calc_encode_size(const size_t size_in);
size_t dap_enc_salsa2012_decrypt(struct dap_enc_key * a_key, const void * a_in, size_t a_in_size, void ** a_out);
size_t dap_enc_salsa2012_encrypt(struct dap_enc_key * a_key, const void * a_in, size_t a_in_size, void ** a_out);
// Writes result ( out ) in already allocated buffer
size_t dap_enc_salsa2012_decrypt_fast(struct dap_enc_key * a_key, const void * a_in,
size_t a_in_size, void * buf_out, size_t buf_out_size);
// Writes result ( out ) in already allocated buffer
size_t dap_enc_salsa2012_encrypt_fast(struct dap_enc_key * a_key, const void * a_in,
size_t a_in_size, void * buf_out, size_t buf_out_size);
#ifdef __cplusplus
}
#endif
#endif
......@@ -26,6 +26,7 @@
#include <stddef.h>
#include <stdbool.h>
#include <stdint.h>
#include <assert.h>
#include "dap_common.h"
#include "dap_hash_keccak.h"
......@@ -96,12 +97,12 @@ static inline bool dap_hash_fast_is_blank( dap_chain_hash_fast_t *a_hash )
DAP_STATIC_INLINE int dap_chain_hash_fast_to_str( dap_chain_hash_fast_t *a_hash, char *a_str, size_t a_str_max )
{
(void) a_str_max;
a_str[0] = '0';
a_str[1] = 'x';
a_str[ DAP_CHAIN_HASH_FAST_SIZE * 2 + 2 ] = 0;
dap_htoa64( (a_str + 2), a_hash->raw, DAP_CHAIN_HASH_FAST_SIZE );
return DAP_CHAIN_HASH_FAST_SIZE * 2 + 2;
assert(a_str_max >= (DAP_CHAIN_HASH_FAST_SIZE * 2 + 2));
a_str[0] = '0';
a_str[1] = 'x';
a_str[ DAP_CHAIN_HASH_FAST_SIZE * 2 + 2] = 0;
dap_htoa64((a_str + 2), a_hash->raw, DAP_CHAIN_HASH_FAST_SIZE);
return DAP_CHAIN_HASH_FAST_SIZE * 2 + 2;
}
static inline char *dap_chain_hash_fast_to_str_new(dap_chain_hash_fast_t * a_hash)
......
......@@ -31,23 +31,26 @@
#include "dap_pkey.h"
#include "dap_hash.h"
typedef union dap_sign_type{
enum {
SIG_TYPE_NULL = 0x0000,
SIG_TYPE_BLISS = 0x0001,
SIG_TYPE_DEFO = 0x0002, /// @brief key image for anonymous transaction
SIG_TYPE_TESLA = 0x0003, /// @brief
SIG_TYPE_PICNIC = 0x0101, /// @brief
SIG_TYPE_DILITHIUM = 0x0102, /// @brief
SIG_TYPE_MULTI = 0xffff /// @brief Has inside subset of different signatures and sign composed with all of them
} type: 16;
typedef enum {
SIG_TYPE_NULL = 0x0000,
SIG_TYPE_BLISS = 0x0001,
SIG_TYPE_DEFO = 0x0002, /// @brief key image for anonymous transaction
SIG_TYPE_TESLA = 0x0003, /// @brief
SIG_TYPE_PICNIC = 0x0101, /// @brief
SIG_TYPE_DILITHIUM = 0x0102, /// @brief
SIG_TYPE_MULTI_CHAINED = 0x0f00, /// @brief Has inside subset of different signatures and sign composed with all of them
SIG_TYPE_MULTI_COMBINED = 0x0f01 /// @brief Has inside subset of different public keys and sign composed with all of appropriate private keys
} dap_sign_type_enum_t;
typedef union dap_sign_type {
dap_sign_type_enum_t type: 16;
uint16_t raw;
} dap_sign_type_t;
typedef struct dap_sign_hdr{
typedef struct dap_sign_hdr {
dap_sign_type_t type; /// Signature type
uint8_t padding[2]; /// Padding for better aligmnent
uint16_t sign_size; /// Signature size
uint32_t sign_size; /// Signature size
uint32_t sign_pkey_size; /// Signature serialized public key size
} DAP_ALIGN_PACKED dap_sign_hdr_t;
......@@ -61,6 +64,42 @@ typedef struct dap_sign
uint8_t pkey_n_sign[]; /// @param sig @brief raw signature data
} DAP_ALIGN_PACKED dap_sign_t;
#define MULTI_SIGN_MAX_COUNT 255
typedef struct _dap_multi_sign_params_t {
dap_sign_type_t type; // Multi-signature type
uint8_t total_count; // Total key count
uint8_t sign_count; // Signatures count
uint8_t *key_seq; // Signing key sequence
dap_enc_key_t **keys; // Signing keys
} dap_multi_sign_params_t;
typedef struct _dap_multi_sign_meta_t {
uint32_t pkey_size; // Size of public key
uint32_t sign_size; // Size of signature
} DAP_ALIGN_PACKED dap_multi_sign_meta_t;
typedef struct _dap_multi_sign_keys_t {
uint8_t num;
dap_sign_type_t type;
} DAP_ALIGN_PACKED dap_multi_sign_keys_t;
typedef struct _dap_multi_sign_t {
/*** Hashed metadata ***/
dap_sign_type_t type; // Multi-signature type
uint8_t total_count; // Total key count
uint8_t sign_count; // Signatures count
dap_multi_sign_keys_t *key_seq; // Signing key sequence
/*** Unhashed metadata ***/
dap_multi_sign_meta_t *meta; // Sizes of keys and signatures
/*** Key hashes ***/
dap_chain_hash_fast_t *key_hashes; // Total key hashes
/*** Serialized public keys ***/
uint8_t *pub_keys; // Public keys for this signature
/*** Serialized signatures chain ***/
uint8_t *sign_data; // Signatures data
} DAP_ALIGN_PACKED dap_multi_sign_t;
#ifdef __cplusplus
extern "C" {
#endif
......@@ -89,6 +128,14 @@ dap_enc_key_t *dap_sign_to_enc_key(dap_sign_t * a_chain_sign);
const char * dap_sign_type_to_str(dap_sign_type_t a_chain_sign_type);
dap_sign_type_t dap_sign_type_from_str(const char * a_type_str);
uint8_t *dap_multi_sign_serialize(dap_multi_sign_t *a_sign, size_t *a_out_len);
dap_multi_sign_t *dap_multi_sign_deserialize(dap_sign_type_enum_t a_type, uint8_t *a_sign, size_t a_sign_len);
dap_multi_sign_params_t *dap_multi_sign_params_make(dap_sign_type_enum_t a_type, uint8_t a_total_count, uint8_t a_sign_count, dap_enc_key_t *a_key1, ...);
void dap_multi_sign_params_delete(dap_multi_sign_params_t *a_params);
dap_multi_sign_t *dap_multi_sign_create(dap_multi_sign_params_t *a_params, const void *a_data, const size_t a_data_size);
int dap_multi_sign_verify(dap_multi_sign_t *a_sign, const void *a_data, const size_t a_data_size);
void dap_multi_sign_delete(dap_multi_sign_t *a_sign);
#ifdef __cplusplus
}
#endif
include (src/defeo_scheme/defeo.pri)
include (src/iaes/iaes.pri)
include (src/oaes/oaes.pri)
include (src/blowfish/blowfish.pri)
include (src/GOST/GOST.pri)
include (src/salsa2012/salsa2012.pri)
include (src/blowfish/blowfish.pri)
include (src/msrln/msrln.pri)
include (src/rand/rand.pri)
include (src/sha3/sha3.pri)
......@@ -8,6 +12,7 @@ include (src/sig_bliss/sig_bliss.pri)
include (src/sig_picnic/sig_picnic.pri)
include (src/sig_tesla/sig_tesla.pri)
include (src/sig_dilithium/sig_dilithium.pri)
include (src/ringct20/ringct20.pri)
DEFINES += KeccakP1600timesN_excluded
......@@ -15,6 +20,8 @@ HEADERS += $$PWD/include/dap_enc.h \
$$PWD/include/dap_enc_base64.h \
$$PWD/include/dap_enc_iaes.h \
$$PWD/include/dap_enc_oaes.h \
$$PWD/include/dap_enc_bf.h \
$$PWD/include/dap_enc_GOST.h \
$$PWD/include/dap_enc_msrln.h \
$$PWD/include/dap_enc_key.h \
$$PWD/include/dap_enc_defeo.h \
......@@ -23,6 +30,7 @@ HEADERS += $$PWD/include/dap_enc.h \
$$PWD/include/dap_enc_tesla.h \
$$PWD/include/dap_enc_base58.h \
$$PWD/include/dap_enc_dilithium.h \
$$PWD/include/dap_enc_ringct20.h \
$$PWD/include/dap_crypto_common.h \
$$PWD/include/dap_cert.h \
$$PWD/include/dap_cert_file.h \
......@@ -39,6 +47,8 @@ SOURCES += $$PWD/src/dap_enc.c \
$$PWD/src/dap_enc_base64.c \
$$PWD/src/dap_enc_iaes.c \
$$PWD/src/dap_enc_oaes.c \
$$PWD/src/dap_enc_bf.c \
$$PWD/src/dap_enc_GOST.c \
$$PWD/src/dap_enc_msrln.c \
$$PWD/src/dap_enc_key.c \
$$PWD/src/dap_enc_defeo.c \
......@@ -47,6 +57,7 @@ SOURCES += $$PWD/src/dap_enc.c \
$$PWD/src/dap_enc_tesla.c \
$$PWD/src/dap_enc_base58.c \
$$PWD/src/dap_enc_dilithium.c \
$$PWD/src/dap_enc_ringct20.c \
$$PWD/src/dap_enc_ca.c \
$$PWD/src/dap_cert.c \
$$PWD/src/dap_cert_file.c \
......
/** @file
* @brief ""
*
* @copyright InfoTeCS. All rights reserved.
*/
#include <memory.h>
#include "28147_14.h"
#include "table.h"
/** @brief . */
static const unsigned char kPi[256] =
{
252, 238, 221, 17, 207, 110, 49, 22, 251, 196, 250, 218, 35, 197, 4, 77,
233, 119, 240, 219, 147, 46, 153, 186, 23, 54, 241, 187, 20, 205, 95, 193,
249, 24, 101, 90, 226, 92, 239, 33, 129, 28, 60, 66, 139, 1, 142, 79,
5, 132, 2, 174, 227, 106, 143, 160, 6, 11, 237, 152, 127, 212, 211, 31,
235, 52, 44, 81, 234, 200, 72, 171, 242, 42, 104, 162, 253, 58, 206, 204,
181, 112, 14, 86, 8, 12, 118, 18, 191, 114, 19, 71, 156, 183, 93, 135,
21, 161, 150, 41, 16, 123, 154, 199, 243, 145, 120, 111, 157, 158, 178, 177,
50, 117, 25, 61, 255, 53, 138, 126, 109, 84, 198, 128, 195, 189, 13, 87,
223, 245, 36, 169, 62, 168, 67, 201, 215, 121, 214, 246, 124, 34, 185, 3,
224, 15, 236, 222, 122, 148, 176, 188, 220, 232, 40, 80, 78, 51, 10, 74,
167, 151, 96, 115, 30, 0, 98, 68, 26, 184, 56, 130, 100, 159, 38, 65,
173, 69, 70, 146, 39, 94, 85, 47, 140, 163, 165, 125, 105, 213, 149, 59,
7, 88, 179, 64, 134, 172, 29, 247, 48, 55, 107, 228, 136, 217, 231, 137,
225, 27, 131, 73, 76, 63, 248, 254, 141, 83, 170, 144, 202, 216, 133, 97,
32, 113, 103, 164, 45, 43, 9, 91, 203, 155, 37, 208, 190, 229, 108, 82,
89, 166, 116, 210, 230, 244, 180, 192, 209, 102, 175, 194, 57, 75, 99, 182
};
/** @brief . */
static const unsigned char kReversePi[256] =
{
0xa5,0x2d,0x32,0x8f,0x0e,0x30,0x38,0xc0,0x54,0xe6,0x9e,0x39,0x55,0x7e,0x52,0x91,
0x64,0x03,0x57,0x5a,0x1c,0x60,0x07,0x18,0x21,0x72,0xa8,0xd1,0x29,0xc6,0xa4,0x3f,
0xe0,0x27,0x8d,0x0c,0x82,0xea,0xae,0xb4,0x9a,0x63,0x49,0xe5,0x42,0xe4,0x15,0xb7,
0xc8,0x06,0x70,0x9d,0x41,0x75,0x19,0xc9,0xaa,0xfc,0x4d,0xbf,0x2a,0x73,0x84,0xd5,
0xc3,0xaf,0x2b,0x86,0xa7,0xb1,0xb2,0x5b,0x46,0xd3,0x9f,0xfd,0xd4,0x0f,0x9c,0x2f,
0x9b,0x43,0xef,0xd9,0x79,0xb6,0x53,0x7f,0xc1,0xf0,0x23,0xe7,0x25,0x5e,0xb5,0x1e,
0xa2,0xdf,0xa6,0xfe,0xac,0x22,0xf9,0xe2,0x4a,0xbc,0x35,0xca,0xee,0x78,0x05,0x6b,
0x51,0xe1,0x59,0xa3,0xf2,0x71,0x56,0x11,0x6a,0x89,0x94,0x65,0x8c,0xbb,0x77,0x3c,
0x7b,0x28,0xab,0xd2,0x31,0xde,0xc4,0x5f,0xcc,0xcf,0x76,0x2c,0xb8,0xd8,0x2e,0x36,
0xdb,0x69,0xb3,0x14,0x95,0xbe,0x62,0xa1,0x3b,0x16,0x66,0xe9,0x5c,0x6c,0x6d,0xad,
0x37,0x61,0x4b,0xb9,0xe3,0xba,0xf1,0xa0,0x85,0x83,0xda,0x47,0xc5,0xb0,0x33,0xfa,
0x96,0x6f,0x6e,0xc2,0xf6,0x50,0xff,0x5d,0xa9,0x8e,0x17,0x1b,0x97,0x7d,0xec,0x58,
0xf7,0x1f,0xfb,0x7c,0x09,0x0d,0x7a,0x67,0x45,0x87,0xdc,0xe8,0x4f,0x1d,0x4e,0x04,
0xeb,0xf8,0xf3,0x3e,0x3d,0xbd,0x8a,0x88,0xdd,0xcd,0x0b,0x13,0x98,0x02,0x93,0x80,
0x90,0xd0,0x24,0x34,0xcb,0xed,0xf4,0xce,0x99,0x10,0x44,0x40,0x92,0x3a,0x01,0x26,
0x12,0x1a,0x48,0x68,0xf5,0x81,0x8b,0xc7,0xd6,0x20,0x0a,0x08,0x00,0x4c,0xd7,0x74
};
/** @brief l */
static const unsigned char kB[16] = {148, 32, 133, 16, 194, 192, 1, 251, 1, 192, 194, 16, 133, 32, 148, 1};
int DLL_IMPORT funcX(unsigned char* a, unsigned char* b, unsigned char* outdata, printout_byte_array print)
{
unsigned int i;
if(!a || !b || !outdata)
{
if(print)
print("funcX: internal error!", 0, 0);
return -1;
}
for(i = 0; i < 16; ++i)
{
outdata[i] = a[i] ^ b[i];
}
if(print)
{
print("funcX: a: ", a, 16);
print("funcX: b: ", b, 16);
print("funcX: result: ", outdata, 16);
}
return 0;
}
int DLL_IMPORT funcS(unsigned char* indata, unsigned char* outdata, printout_byte_array print)
{
size_t i = 0;
if(!indata || !outdata)
{
if(print)
print("funcS: internal error!", 0, 0);
return -1;
}
for(i = 0; i < 16; ++i)
{
outdata[i] = kPi[indata[i]];
}
if(print)
{
print("funcS: input: ", indata, 16);
print("funcS: output: ", outdata, 16);
}
return 0;
}
int DLL_IMPORT funcReverseS(unsigned char* indata, unsigned char* outdata, printout_byte_array print)
{
unsigned int i;
if(!indata || !outdata)
{
if(print)
print("funcReverseS: internal error!", 0, 0);
return -1;
}
for(i = 0; i < 16; ++i)
outdata[i] = kReversePi[indata[i]];
if(print)
{
print("funcReverseS: input: ", indata, 16);
print("funcReverseS: output: ", outdata, 16);
}
return 0;
}
int DLL_IMPORT funcR(unsigned char* indata, unsigned char* outdata, printout_byte_array print)
{
size_t i;
unsigned char sum = 0;
if(!indata || !outdata)
{
if(print)
print("funcR: internal error!", 0, 0);
return -1;
}
for(i = 0; i < 16; ++i)
{
sum ^= multTable[indata[i]*256 + kB[i]];
}
outdata[0] = sum;
memcpy(outdata+1, indata, 15);
if(print)
{
print("funcR: input: ", indata, 16);
print("funcR: output: ", outdata, 16);
}
return 0;
}
int DLL_IMPORT funcReverseR(unsigned char* indata, unsigned char* outdata, printout_byte_array print)
{
unsigned char tmp[16];
unsigned char sum = 0;
unsigned int i;
if(!indata || !outdata)
{
if(print)
print("funcReverseR: internal error!", 0, 0);
return -1;
}
memcpy(tmp, indata+1, 15);
tmp[15] = indata[0];
for(i = 0; i < 16; ++i)
{
sum ^= multTable[tmp[i]*256 + kB[i]];
}
memcpy(outdata, tmp, 15);
outdata[15] = sum;
if(print)
{
print("funcReverseR: input: ", indata, 16);
print("funcReverseR: output: ", outdata, 16);
}
return 0;
}
int DLL_IMPORT funcL(unsigned char* indata, unsigned char* outdata, printout_byte_array print)
{
unsigned char tmp[16];
int i = 0;
if(!indata || !outdata)
{
if(print)
print("funcL: internal error!", 0, 0);
return -1;
}
memcpy(tmp, indata, 16);
for(i = 0; i < 16; ++i)
{
funcR(tmp, outdata, print);
memcpy(tmp, outdata, 16);
}
if(print)
{
print("funcL: input: ", indata, 16);
print("funcL: output: ", outdata, 16);
}
return 0;
}
int DLL_IMPORT funcReverseL(unsigned char* indata, unsigned char* outdata, printout_byte_array print)
{
unsigned char tmp[16];
unsigned int i;
if(!indata || !outdata)
{
if(print)
print("funcReverseL: internal error!", 0, 0);
return -1;
}
memcpy(tmp, indata, 16);
for(i = 0; i < 16; ++i)
{
funcReverseR(tmp, outdata, print);
memcpy(tmp, outdata, 16);
}
if(print)
{
print("funcReverseL: input: ", indata, 16);
print("funcReverseL: output: ", outdata, 16);
}
return 0;
}
int DLL_IMPORT funcLSX(unsigned char* a, unsigned char* b, unsigned char* outdata, printout_byte_array print)
{
unsigned char temp1[16];
unsigned char temp2[16];
if(!a || !b || !outdata)
{
if(print)
print("funcLSX: internal error!", 0, 0);
return -1;
}
funcX(a, b, temp1, print);
funcS(temp1, temp2, print);
funcL(temp2, outdata, print);
if(print)
{
print("funcLSX: a: ", a, 16);
print("funcLSX: b: ", b, 16);
print("funcLSX: output: ", outdata, 16);
}
return 0;
}
int DLL_IMPORT funcReverseLSX(unsigned char* a, unsigned char* b, unsigned char* outdata, printout_byte_array print)
{
unsigned char temp1[16];
unsigned char temp2[16];
if(!a || !b || !outdata)
{
if(print)
print("funcReverseLSX: internal error!", 0, 0);
return -1;
}
funcX(a, b, temp1, print);
funcReverseL(temp1, temp2, print);
funcReverseS(temp2, outdata, print);
if(print)
{
print("funcReverseLSX: a: ", a, 16);
print("funcReverseLSX: b: ", b, 16);
print("funcReverseLSX: output: ", outdata, 16);
}
return 0;
}
int DLL_IMPORT funcF(unsigned char* inputKey, unsigned char* inputKeySecond, unsigned char* iterationConst, unsigned char* outputKey, unsigned char* outputKeySecond, printout_byte_array print)
{
unsigned char temp1[16];
unsigned char temp2[16];
if(!inputKey || !inputKeySecond || !iterationConst || !outputKey || !outputKeySecond)
{
if(print)
print("funcF: internal error!", 0, 0);
return -1;
}
funcLSX(inputKey, iterationConst, temp1, print);
funcX(temp1, inputKeySecond, temp2, print);
memcpy(outputKeySecond, inputKey, 16);
memcpy(outputKey, temp2, 16);
if(print)
{
print("funcF: input key: ", inputKey, 16);
print("funcF: input key: ", inputKeySecond, 16);
print("funcF: iterration const: ", iterationConst, 16);
print("funcF: output key: ", outputKey, 16);
print("funcF: output key: ", outputKeySecond, 16);
}
return 0;
}
int DLL_IMPORT funcC(unsigned char number, unsigned char* output, printout_byte_array print)
{
unsigned char tempI[16];
if(!output)
{
if(print)
print("funcC: internal error!", 0, 0);
return -1;
}
memset( tempI, 0, 15 );
tempI[15] = number;
funcL(tempI, output, print);
return 0;
}
int DLL_IMPORT ExpandKey(unsigned char* masterKey, unsigned char* keys, printout_byte_array print)
{
unsigned char C[16];
unsigned char temp1[16];
unsigned char temp2[16];
unsigned char j, i;
if( !masterKey || !keys)
{
if(print)
print("ExpandKey: internal error!", 0, 0);
return -1;
}
memcpy(keys, masterKey, 16);
memcpy(keys + 16, masterKey + 16, 16);
if(print)
{
print("ExpandKey: master key: ", masterKey, 16);
print("ExpandKey: output key: ", keys, 16);
print("ExpandKey: output key: ", keys + 16, 16);
}
for(j = 0; j < 4; ++j)
{
memcpy(temp1, keys + j * 2 * 16, 16);
memcpy(temp2, keys + (j * 2 + 1) * 16, 16);
for( i = 1; i < 8; ++i )
{
funcC(j*8+i, C, print);
funcF(temp1, temp2, C, temp1, temp2, print);
}
funcC(j*8+8, C, print);
funcF(temp1, temp2, C, temp1, temp2, print);
memcpy(keys + (j * 2 + 2) * 16, temp1, 16);
memcpy(keys + (j * 2 + 3) * 16, temp2, 16);
if(print)
{
print("ExpandKey: output key: ", keys + (j * 2 + 2) * 16, 16);
print("ExpandKey: output key: ", keys + (j * 2 + 3) * 16, 16);
}
}
return 0;
}
int DLL_IMPORT Encrypt_14(unsigned char* plainText, unsigned char* chipherText, unsigned char* keys, printout_byte_array print, printout_uint_array print_uint)
{
unsigned char xTemp[16];
unsigned char yTemp[16];
int i;
(void)print_uint;
if(!plainText || !chipherText || !keys)
{
if(print)
print("Encrypt_14: internal error!", 0, 0);
return -1;
}
memcpy(xTemp, plainText, 16);
for(i = 0; i < 9; ++i)
{
funcLSX(xTemp, keys + 16*i, yTemp, print);
memcpy(xTemp, yTemp, 16);
}
funcX(yTemp, keys+9*16, chipherText, print);
if(print)
{
for(i = 0; i < 10; ++i)
{
print("Encrypt_14: key: ", keys, 16);
keys += 16;
}
print("Encrypt_14: plain text: ", plainText, 16);
print("Encrypt_14: chipher text: ", chipherText, 16);
}
return 0;
}
int DLL_IMPORT Decrypt_14(unsigned char* chipherText, unsigned char* plainText, unsigned char* keys, printout_byte_array print, printout_uint_array print_uint)
{
unsigned char xTemp[16];
unsigned char yTemp[16];
int i;
(void)print_uint;
if(!plainText || !chipherText || !keys)
{
if(print)
print("Decrypt_14: internal error!", 0, 0);
return -1;
}
memcpy(xTemp, chipherText, 16);
for(i = 0; i < 9; ++i)
{
funcReverseLSX(xTemp, keys+(9-i)*16, yTemp, print);
memcpy(xTemp, yTemp, 16);
}
funcX(yTemp, keys, plainText, print);
if(print)
{
for(i = 0; i < 10; ++i)
{
print("Decrypt_14: key: ", keys, 16);
keys += 16;
}
print("Decrypt_14: chipher text : ", chipherText, 16);
print("Decrypt_14: plain text: ", plainText, 16);
}
return 0;
}
\ No newline at end of file
/** @file
* @brief ""
*
* @copyright InfoTeCS. All rights reserved.
*/
#ifndef C_28147_14_H
#define C_28147_14_H
#include "dll_import.h"
#include "callback_print.h"
#ifdef __cplusplus
extern "C" {
#endif
/** @brief X
*
* @param[in] a
* @param[in] b
* @param[out] outdata
* @param[in] print
* @return 0
* @return -1
*/
int DLL_IMPORT funcX(unsigned char* a, unsigned char* b, unsigned char* outdata, printout_byte_array print);
/** @brief S
*
* @param[in] indata
* @param[out] outdata
* @param[in] print
* @return 0
* @return -1
*/
int DLL_IMPORT funcS(unsigned char* indata, unsigned char* outdata, printout_byte_array print);
/** @brief S
*
* @param[in] indata
* @param[out] outdata
* @param[in] print
* @return 0
* @return -1
*/
int DLL_IMPORT funcReverseS(unsigned char* indata, unsigned char* outdata, printout_byte_array print);
/** @brief R
*
* @param[in] indata
* @param[out] outdata
* @param[in] print
* @return 0
* @return -1
*/
int DLL_IMPORT funcR(unsigned char* indata, unsigned char* outdata, printout_byte_array print);
/** @brief R
*
* @param[in] indata
* @param[out] outdata
* @param[in] print
* @return 0
* @return -1
*/
int DLL_IMPORT funcReverseR(unsigned char* indata, unsigned char* outdata, printout_byte_array print);
/** @brief L
*
* @param[in] indata
* @param[out] outdata
* @param[in] print
* @return 0
* @return -1
*/
int DLL_IMPORT funcL(unsigned char* indata, unsigned char* outdata, printout_byte_array print);
/** @brief L
*
* @param[in] indata
* @param[out] outdata
* @param[in] print
* @return 0
* @return -1
*/
int DLL_IMPORT funcReverseL(unsigned char* indata, unsigned char* outdata, printout_byte_array print);
/** @brief LSX
*
* @param[in] a
* @param[in] b
* @param[out] outdata
* @param[in] print
* @return 0
* @return -1
*/
int DLL_IMPORT funcLSX(unsigned char* a, unsigned char* b, unsigned char* outdata, printout_byte_array print);
/** @brief LSX
*
* @param[in] a
* @param[in] b
* @param[out] outdata
* @param[in] print
* @return 0
* @return -1
*/
int DLL_IMPORT funcReverseLSX(unsigned char* a, unsigned char* b, unsigned char* outdata, printout_byte_array print);
/** @brief F
*
* @param[in] inputKey
* @param[in] inputKeySecond
* @param[in] iterationConst
* @param[out] outputKey
* @param[out] outputKeySecond
* @param[in] print
* @return 0
* @return -1
*/
int DLL_IMPORT funcF(unsigned char* inputKey, unsigned char* inputKeySecond, unsigned char* iterationConst, unsigned char* outputKey, unsigned char* outputKeySecond, printout_byte_array print);
/** @brief
*
* @param[in] number
* @param[out] output
* @param[in] print
* @return 0
* @return -1
*/
int DLL_IMPORT funcC(unsigned char number, unsigned char* output, printout_byte_array print);
/** @brief
*
* @param[in] masterKey
* @param[out] keys
* @param[in] print
* @return 0
* @return -1
*/
int DLL_IMPORT ExpandKey(unsigned char* masterKey, unsigned char* keys, printout_byte_array print);
/** @brief
*
* @param[in] plainText
* @param[out] chipherText
* @param[in] keys
* @param[in] print
* @param[in] print_uint
* @return 0
* @return -1
*/
int DLL_IMPORT Encrypt_14(unsigned char* plainText, unsigned char* chipherText, unsigned char* keys, printout_byte_array print, printout_uint_array print_uint);
/** @brief
*
* @param[in] chipherText
* @param[out] plainText
* @param[in] keys
* @param[in] print
* @param[in] print_uint
* @return 0
* @return -1
*/
int DLL_IMPORT Decrypt_14(unsigned char* chipherText, unsigned char* plainText, unsigned char* keys, printout_byte_array print, printout_uint_array print_uint);
#ifdef __cplusplus
}
#endif
#endif
/** @file
* @brief 28147-89
*
* @copyright InfoTeCS. All rights reserved.
*/
#include "28147_89.h"
/** @brief int32
*
* @param[in] input 4
* @return int32
*/
static unsigned int uint8ToUint32(unsigned char* input)
{
unsigned int r = ( (input[3]) | (input[2]<<8) | (input[1]<<16) | (input[0]<<24));
return r;
}
/** @brief int32
*
* @param[in] input int32
* @param[out] output 4
*/
static void uint32ToUint8(unsigned int input, unsigned char* output)
{
int i;
for(i = 0; i < 4; ++i)
{
output[3-i] = ( ( input >> (8*i) ) & 0x000000ff );
}
}
/** @brief id-tc26-gost-28147-param-Z OID: 1.2.643.7.1.2.5.1.1 */
unsigned char p[8][16] =
{
{0xc, 0x4, 0x6, 0x2, 0xa, 0x5, 0xb, 0x9, 0xe, 0x8, 0xd, 0x7, 0x0, 0x3, 0xf, 0x1},
{0x6, 0x8, 0x2, 0x3, 0x9, 0xa, 0x5, 0xc, 0x1, 0xe, 0x4, 0x7, 0xb, 0xd, 0x0, 0xf},
{0xb, 0x3, 0x5, 0x8, 0x2, 0xf, 0xa, 0xd, 0xe, 0x1, 0x7, 0x4, 0xc, 0x9, 0x6, 0x0},
{0xc, 0x8, 0x2, 0x1, 0xd, 0x4, 0xf, 0x6, 0x7, 0x0, 0xa, 0x5, 0x3, 0xe, 0x9, 0xb},
{0x7, 0xf, 0x5, 0xa, 0x8, 0x1, 0x6, 0xd, 0x0, 0x9, 0x3, 0xe, 0xb, 0x4, 0x2, 0xc},
{0x5, 0xd, 0xf, 0x6, 0x9, 0x2, 0xc, 0xa, 0xb, 0x7, 0x8, 0x1, 0x4, 0x3, 0xe, 0x0},
{0x8, 0xe, 0x2, 0x5, 0x6, 0x9, 0x1, 0xc, 0xf, 0x4, 0xb, 0x0, 0xd, 0xa, 0x3, 0x7},
{0x1, 0x7, 0xe, 0xd, 0x0, 0x5, 0x8, 0x3, 0x4, 0xf, 0xa, 0x6, 0x9, 0xc, 0xb, 0x2}
};
/** @brief */
unsigned char kEncRoundKey[32] =
{
0, 4, 8, 12, 16, 20, 24, 28, 0, 4, 8, 12, 16, 20, 24, 28, 0, 4, 8, 12, 16, 20, 24, 28, 28, 24, 20, 16, 12, 8, 4, 0
};
/** @brief */
unsigned char kDecRoundKey[32] =
{
0, 4, 8, 12, 16, 20, 24, 28, 28, 24, 20, 16, 12, 8, 4, 0, 28, 24, 20, 16, 12, 8, 4, 0, 28, 24, 20, 16, 12, 8, 4, 0
};
unsigned int DLL_IMPORT funcT(unsigned int a, printout_uint_array print)
{
unsigned int res = 0;
res ^= p[ 0 ][ a & 0x0000000f ];
res ^= ( p[ 1 ][ ( ( a & 0x000000f0 ) >> 4 ) ] << 4 );
res ^= ( p[ 2 ][ ( ( a & 0x00000f00 ) >> 8 ) ] << 8 );
res ^= ( p[ 3 ][ ( ( a & 0x0000f000 ) >> 12 ) ] << 12 );
res ^= ( p[ 4 ][ ( ( a & 0x000f0000 ) >> 16 ) ] << 16 );
res ^= ( p[ 5 ][ ( ( a & 0x00f00000 ) >> 20 ) ] << 20 );
res ^= ( p[ 6 ][ ( ( a & 0x0f000000 ) >> 24 ) ] << 24 );
res ^= ( p[ 7 ][ ( ( a & 0xf0000000 ) >> 28 ) ] << 28 );
if(print)
{
print("funcT: a: ", &a, 1);
print("funcT: output: ", &res, 1);
}
return res;
}
unsigned int DLL_IMPORT funcG(unsigned int a, unsigned int k, printout_uint_array print)
{
unsigned int c = a + k;
unsigned int tmp = funcT(c, print);
unsigned int r = (tmp<<11) | (tmp >> 21);
if(print)
{
print("funcG: a: ", &a, 1);
print("funcG: k: ", &k, 1);
print("funcG: output: ", &r, 1);
}
return r;
}
void DLL_IMPORT Round(unsigned int* a1, unsigned int* a0, unsigned int k, printout_uint_array print)
{
unsigned int a;
unsigned int tmp;
if(print)
{
print("Round: input a1: ", a1, 1);
print("Round: input a0: ", a0, 1);
print("Round: k: ", &k, 1);
}
a = *a0;
tmp = funcG(*a0, k, print);
*a0 = *a1 ^ tmp;
*a1 = a;
if(print)
{
print("Round: output a1: ", a1, 1);
print("Round: output a0: ", a0, 1);
}
}
void DLL_IMPORT RoundShtrih(unsigned int* a1, unsigned int* a0, unsigned int k, printout_uint_array print)
{
unsigned int tmp;
if(print)
{
print("RoundShtrih: input a1: ", a1, 1);
print("RoundShtrih: input a0: ", a0, 1);
print("RoundShtrih: k: ", &k, 1);
}
tmp = funcG(*a0, k, print);
*a1 ^= tmp;
if(print)
{
print("RoundShtrih: output a1: ", a1, 1);
print("RoundShtrih: output a0: ", a0, 1);
}
}
int DLL_IMPORT CryptBlock(unsigned char* input, unsigned char* output, unsigned char* key, unsigned char* keyIndex, printout_uint_array print)
{
unsigned int a1 = uint8ToUint32(input);
unsigned int a0 = uint8ToUint32(input + 4);
int i;
if(print)
{
print("CryptBlock: input a1:", &a1, 1);
print("CryptBlock: input a0:", &a0, 1);
}
for(i = 0; i < 31; ++i)
{
Round(&a1, &a0, uint8ToUint32(key + keyIndex[i]), print);
}
RoundShtrih(&a1, &a0, uint8ToUint32(key + keyIndex[31]), print);
if(print)
{
print("CryptBlock: output a1:", &a1, 1);
print("CryptBlock: output a0:", &a0, 1);
}
uint32ToUint8(a1, output);
uint32ToUint8(a0, output+4);
return 0;
}
int DLL_IMPORT EncryptBlock(unsigned char* input, unsigned char* output, unsigned char* key, printout_uint_array print)
{
return CryptBlock(input, output, key, kEncRoundKey, print);
}
int DLL_IMPORT DecryptBlock(unsigned char* input, unsigned char* output, unsigned char* key, printout_uint_array print)
{
return CryptBlock(input, output, key, kDecRoundKey, print);
}
int DLL_IMPORT Encrypt_89(unsigned char* input, unsigned char* output, unsigned char* key, printout_byte_array print, printout_uint_array print_uint)
{
if( !input || !output || !key )
{
if(print)
print("Encrypt_89: internal error!", 0, 0);
return -1;
}
if(EncryptBlock(input, output, key, print_uint))
return -1;
if(print)
{
print("Encrypt_89: plain text: ", input, 8);
print("Encrypt_89: chipher text: ", output, 8);
}
return 0;
}
int DLL_IMPORT Decrypt_89(unsigned char* input, unsigned char* output, unsigned char* key, printout_byte_array print, printout_uint_array print_uint)
{
if( !input || !output || !key )
{
if(print)
print("Decrypt_89: internal error!", 0, 0);
return -1;
}
if(DecryptBlock(input, output, key, print_uint))
return -1;
if(print)
{
print("Encrypt_89: chipher text: ", input, 8);
print("Encrypt_89: plain text: ", output, 8);
}
return 0;
}
/** @file
* @brief "28147-89"
*
* @copyright InfoTeCS. All rights reserved.
*/
#ifndef C_28147_89_H
#define C_28147_89_H
#include "dll_import.h"
#include "callback_print.h"
#ifdef __cplusplus
extern "C" {
#endif
/** @brief
*
* @param[in] a
* @param[in] print
* @return
*/
unsigned int DLL_IMPORT funcT(unsigned int a, printout_uint_array print);
/** @brief g
*
* @param[in] a
* @param[in] k
* @param[in] print
* @return
*/
unsigned int DLL_IMPORT funcG(unsigned int a, unsigned int k, printout_uint_array print);
/** @brief G
*
* @param[out] a1 ,
* @param[out] a0 ,
* @param[in] k
* @param[in] print
*/
void DLL_IMPORT Round(unsigned int* a1, unsigned int* a0, unsigned int k, printout_uint_array print);
/** @brief G ( 1 0 )
*
* @param[out] a1 ,
* @param[out] a0 ,
* @param[in] k
* @param[in] print
*/
void DLL_IMPORT RoundShtrih(unsigned int *a1, unsigned int *a0, unsigned int k, printout_uint_array print);
/** @brief
*
* @param[in] input -
* @param[out] output -
* @param[in] key
* @param[in] keySequence
* @param[in] print
* @return 0
* @return -1
*/
int DLL_IMPORT CryptBlock(unsigned char* input, unsigned char* output, unsigned char* key, unsigned char* keySequence, printout_uint_array print);
/** @brief
*
* @param[in] input -
* @param[out] output -
* @param[in] key
* @param[in] print
* @return 0
* @return -1
*/
int DLL_IMPORT EncryptBlock(unsigned char* input, unsigned char* output, unsigned char* key, printout_uint_array print);
/** @brief
*
* @param[in] input -
* @param[out] output -
* @param[in] key
* @param[in] print
* @return 0
* @return -1
*/
int DLL_IMPORT DecryptBlock(unsigned char* input, unsigned char* output, unsigned char* key, printout_uint_array print);
/** @brief
*
* @param[in] input -
* @param[out] output -
* @param[in] key
* @param[in] print
* @param[in] print_uint
* @return 0
* @return -1
*/
int DLL_IMPORT Encrypt_89(unsigned char* input, unsigned char* output, unsigned char* key, printout_byte_array print, printout_uint_array print_uint);
/** @brief
*
* @param[in] input -
* @param[out] output -
* @param[in] key
* @param[in] print
* @param[in] print_uint
* @return 0
* @return -1
*/
int DLL_IMPORT Decrypt_89(unsigned char* input, unsigned char* output, unsigned char* key, printout_byte_array print, printout_uint_array print_uint);
#ifdef __cplusplus
}
#endif
#endif
INCLUDEPATH += $$PWD
HEADERS += $$PWD/28147_14.h \
$$PWD/28147_89.h \
$$PWD/callback_print.h \
$$PWD/dll_import.h \
$$PWD/print_data.h \
$$PWD/table.h \
$$PWD/test_data.inc \
$$PWD/block_cipher.h
SOURCES += $$PWD/28147_14.c \
$$PWD/28147_89.c \
$$PWD/block_cipher.c \
$$PWD/print_data.c \
$$PWD/testgost.c
This diff is collapsed.